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
@@ -5445,11 +5445,11 @@ function moveMarkers(before, after, markers) {
5445
5445
  const move = ({ position: position3, opening, exact }) => {
5446
5446
  if (!exact && opening && position3 === 0) return 0;
5447
5447
  if (!exact && !opening && position3 === from.length) return to.length;
5448
- let shift3 = 0;
5448
+ let shift4 = 0;
5449
5449
  for (const [index4, change] of changes.entries()) {
5450
5450
  if (position3 < change.fromStart) break;
5451
5451
  if (position3 > change.fromEnd) {
5452
- shift3 = change.toEnd - change.fromEnd;
5452
+ shift4 = change.toEnd - change.fromEnd;
5453
5453
  continue;
5454
5454
  }
5455
5455
  const next = changes[index4 + 1];
@@ -5459,7 +5459,7 @@ function moveMarkers(before, after, markers) {
5459
5459
  if (position3 === change.fromEnd) return change.toEnd;
5460
5460
  return opening ? change.toStart : change.toEnd;
5461
5461
  }
5462
- return position3 + shift3;
5462
+ return position3 + shift4;
5463
5463
  };
5464
5464
  return markers.map((marker4) => ({ ...marker4, position: move(marker4) }));
5465
5465
  }
@@ -16307,7 +16307,8 @@ var pie = {
16307
16307
  gd16("stAng", "pin 0 adj1 21599999"),
16308
16308
  gd16("endAng", "pin 0 adj2 21599999"),
16309
16309
  gd16("swAng", "+- endAng 0 stAng"),
16310
- gd16("swAng2", "?: swAng swAng +- 21600000 swAng 0"),
16310
+ gd16("swAngWrap", "+- swAng 21600000 0"),
16311
+ gd16("swAng2", "?: swAng swAng swAngWrap"),
16311
16312
  gd16("stx", "cos wd2 stAng"),
16312
16313
  gd16("sty", "sin hd2 stAng"),
16313
16314
  gd16("x1", "+- hc stx 0"),
@@ -16352,7 +16353,8 @@ var chord = {
16352
16353
  gd16("stAng", "pin 0 adj1 21599999"),
16353
16354
  gd16("endAng", "pin 0 adj2 21599999"),
16354
16355
  gd16("swAng", "+- endAng 0 stAng"),
16355
- gd16("swAng2", "?: swAng swAng +- 21600000 swAng 0"),
16356
+ gd16("swAngWrap", "+- swAng 21600000 0"),
16357
+ gd16("swAng2", "?: swAng swAng swAngWrap"),
16356
16358
  gd16("stx", "cos wd2 stAng"),
16357
16359
  gd16("sty", "sin hd2 stAng"),
16358
16360
  gd16("x1", "+- hc stx 0"),
@@ -16376,7 +16378,8 @@ var arc = {
16376
16378
  gd16("stAng", "pin 0 adj1 21599999"),
16377
16379
  gd16("endAng", "pin 0 adj2 21599999"),
16378
16380
  gd16("swAng", "+- endAng 0 stAng"),
16379
- gd16("swAng2", "?: swAng swAng +- 21600000 swAng 0"),
16381
+ gd16("swAngWrap", "+- swAng 21600000 0"),
16382
+ gd16("swAng2", "?: swAng swAng swAngWrap"),
16380
16383
  gd16("stx", "cos wd2 stAng"),
16381
16384
  gd16("sty", "sin hd2 stAng"),
16382
16385
  gd16("x1", "+- hc stx 0"),
@@ -16471,7 +16474,8 @@ var blockArc = {
16471
16474
  gd16("iwd2", "+- wd2 0 thw"),
16472
16475
  gd16("ihd2", "+- hd2 0 thh2"),
16473
16476
  gd16("swAng", "+- endAng 0 stAng"),
16474
- gd16("swAng2", "?: swAng swAng +- 21600000 swAng 0"),
16477
+ gd16("swAngWrap", "+- swAng 21600000 0"),
16478
+ gd16("swAng2", "?: swAng swAng swAngWrap"),
16475
16479
  gd16("mswAng", "+- 0 0 swAng2"),
16476
16480
  gd16("stx", "cos wd2 stAng"),
16477
16481
  gd16("sty", "sin hd2 stAng"),
@@ -24980,8 +24984,8 @@ function writeDiagramFormatDefinition(source3, change) {
24980
24984
  (entry3) => entry3.id === change.value
24981
24985
  ))
24982
24986
  throw new RangeError("Unknown SmartArt format preset.");
24983
- const template = change.kind === "colors" ? buildFabricatedColorsXml(change.value) : buildFabricatedQuickStyleXml(change.value);
24984
- const fresh = parseXml(template).documentElement;
24987
+ const template2 = change.kind === "colors" ? buildFabricatedColorsXml(change.value) : buildFabricatedQuickStyleXml(change.value);
24988
+ const fresh = parseXml(template2).documentElement;
24985
24989
  if (!source3) {
24986
24990
  fresh.setAttribute("uniqueId", `urn:ooxml-core/${change.kind}/${change.value}`);
24987
24991
  return buildXml(fresh);
@@ -26254,8 +26258,8 @@ function buildGeneratedDiagramCache(dataXml2, input2) {
26254
26258
  );
26255
26259
  const direct = model2.nodes.find((node4) => node4.modelId === shape2.sourceNodeId);
26256
26260
  const fillIndex = shape2.style?.fill?.index;
26257
- const template = fillIndex ? input2.formatScheme?.fillStyles[fillIndex - 1]?.fill : void 0;
26258
- if (!direct?.fill && shape2.fill?.kind === "solid" && shape2.fill.color.kind === "srgb" && (!template || template.kind === "solid" && template.color.kind === "scheme" && template.color.value === "phClr")) {
26261
+ const template2 = fillIndex ? input2.formatScheme?.fillStyles[fillIndex - 1]?.fill : void 0;
26262
+ if (!direct?.fill && shape2.fill?.kind === "solid" && shape2.fill.color.kind === "srgb" && (!template2 || template2.kind === "solid" && template2.color.kind === "scheme" && template2.color.value === "phClr")) {
26259
26263
  const original = themed.get(`#${shape2.fill.color.value}`.toUpperCase());
26260
26264
  if (original)
26261
26265
  shape2.fill.color = {
@@ -26263,9 +26267,9 @@ function buildGeneratedDiagramCache(dataXml2, input2) {
26263
26267
  transforms: [...original.transforms, ...shape2.fill.color.transforms]
26264
26268
  };
26265
26269
  }
26266
- if (!direct?.fill && shape2.fill?.kind === "gradient" && template?.kind === "gradient") {
26270
+ if (!direct?.fill && shape2.fill?.kind === "gradient" && template2?.kind === "gradient") {
26267
26271
  shape2.fill.stops.forEach((stop, index4) => {
26268
- const authored = template.stops[index4]?.color;
26272
+ const authored = template2.stops[index4]?.color;
26269
26273
  if (authored?.kind === "scheme" && authored.value === "phClr" && stop.color.kind === "srgb") {
26270
26274
  const original = themed.get(`#${stop.color.value}`.toUpperCase());
26271
26275
  if (original)
@@ -27282,8 +27286,8 @@ function scottBinCount(values2, min, max) {
27282
27286
  if (values2.length < 2 || max <= min) {
27283
27287
  return 1;
27284
27288
  }
27285
- const mean4 = values2.reduce((sum3, value3) => sum3 + value3, 0) / values2.length;
27286
- const variance3 = values2.reduce((sum3, value3) => sum3 + (value3 - mean4) ** 2, 0) / (values2.length - 1);
27289
+ const mean9 = values2.reduce((sum3, value3) => sum3 + value3, 0) / values2.length;
27290
+ const variance3 = values2.reduce((sum3, value3) => sum3 + (value3 - mean9) ** 2, 0) / (values2.length - 1);
27287
27291
  const sd = Math.sqrt(variance3);
27288
27292
  if (!(sd > 0)) {
27289
27293
  return 1;
@@ -33834,7 +33838,7 @@ function addChartSeries(space, input2) {
33834
33838
  const group3 = groups.find((_, i2) => i2 === (input2.groupIndex ?? groups.length - 1));
33835
33839
  if (!group3) throw new RangeError("The chart has no chart group to add a series to");
33836
33840
  const all2 = chartSpaceSeries(draft);
33837
- const template = all2[0];
33841
+ const template2 = all2[0];
33838
33842
  const series = {
33839
33843
  index: nextNumber(all2.map((item2) => item2.index)),
33840
33844
  order: nextNumber(all2.map((item2) => item2.order)),
@@ -33851,7 +33855,7 @@ function addChartSeries(space, input2) {
33851
33855
  };
33852
33856
  else if (input2.name !== void 0) series.tx = { value: input2.name, text: input2.name };
33853
33857
  if (input2.spPr) series.spPr = structuredClone(input2.spPr);
33854
- const templateCategories = template?.categories ?? template?.xValues;
33858
+ const templateCategories = template2?.categories ?? template2?.xValues;
33855
33859
  if (input2.categories !== void 0)
33856
33860
  series[categoryKey(group3)] = categorySource(
33857
33861
  input2.categories,
@@ -37822,9 +37826,9 @@ function keepsUnmodeledProperties(before, after, basis = basisOf) {
37822
37826
  const owners = (runs) => runs.flatMap((run2) => Array.from({ length: positionText(run2).length }, () => basis(run2)));
37823
37827
  const was = owners(before);
37824
37828
  const now = owners(after);
37825
- const kept = (from, to, shift3) => {
37829
+ const kept = (from, to, shift4) => {
37826
37830
  for (let at3 = from; at3 < to; at3++)
37827
- if (was[at3] !== void 0 && was[at3] !== now[at3 + shift3]) return false;
37831
+ if (was[at3] !== void 0 && was[at3] !== now[at3 + shift4]) return false;
37828
37832
  return true;
37829
37833
  };
37830
37834
  let fromAt = 0;
@@ -39143,7 +39147,7 @@ async function createHeaderFooterParts(zip, model2, base3, docPrIds) {
39143
39147
  }
39144
39148
  async function applyHeaderFooterEdits(zip, model2, base3, pendingMedia, docPrIds, preferred) {
39145
39149
  const next = partContents(model2.sections);
39146
- const better = preferred && partContents(preferred.sections);
39150
+ const better2 = preferred && partContents(preferred.sections);
39147
39151
  const previous = partContents(base3.sections);
39148
39152
  const sources = new Map(
39149
39153
  (model2.sections ?? []).flatMap(
@@ -39161,7 +39165,7 @@ async function applyHeaderFooterEdits(zip, model2, base3, pendingMedia, docPrIds
39161
39165
  for (const [partName, blocks] of next) {
39162
39166
  const original = previous.get(partName) ?? previous.get(sources.get(partName) ?? "") ?? (created.has(partName) ? [] : void 0);
39163
39167
  if (!original) continue;
39164
- const wanted = better?.get(partName);
39168
+ const wanted = better2?.get(partName);
39165
39169
  const choices = wanted && JSON.stringify(wanted) !== JSON.stringify(blocks) ? [wanted, blocks] : [blocks];
39166
39170
  let built;
39167
39171
  for (const [index4, content2] of choices.entries()) {
@@ -45267,7 +45271,7 @@ var ENGLISH_PIVOT_CAPTIONS = {
45267
45271
  functions: FUNCTIONS,
45268
45272
  aggregates: aggregateNames()
45269
45273
  };
45270
- var fillCaption = (template, ...args) => template.replace(/\{(\d)\}/g, (_match, at3) => args[Number(at3)] ?? "");
45274
+ var fillCaption = (template2, ...args) => template2.replace(/\{(\d)\}/g, (_match, at3) => args[Number(at3)] ?? "");
45271
45275
  function pivotCaptions(pivot) {
45272
45276
  const own3 = pivot.captions;
45273
45277
  if (!own3) return ENGLISH_PIVOT_CAPTIONS;
@@ -46050,8 +46054,8 @@ var DIV0 = { error: "#DIV/0!" };
46050
46054
  function variance(numbers3, sample) {
46051
46055
  const n = numbers3.length;
46052
46056
  if (n < (sample ? 2 : 1)) return DIV0;
46053
- const mean4 = numbers3.reduce((total2, value3) => total2 + value3, 0) / n;
46054
- const squares = numbers3.reduce((total2, value3) => total2 + (value3 - mean4) ** 2, 0);
46057
+ const mean9 = numbers3.reduce((total2, value3) => total2 + value3, 0) / n;
46058
+ const squares = numbers3.reduce((total2, value3) => total2 + (value3 - mean9) ** 2, 0);
46055
46059
  return squares / (sample ? n - 1 : n);
46056
46060
  }
46057
46061
  function aggregateValues(records, field2, type) {
@@ -46572,9 +46576,9 @@ function aggregateCaptionsOf(pivot) {
46572
46576
  ]) {
46573
46577
  const at3 = measure4.caption.indexOf(measure4.field);
46574
46578
  if (at3 < 0 || measure4.caption === measure4.field) continue;
46575
- const template = `${measure4.caption.slice(0, at3)}{0}${measure4.caption.slice(at3 + measure4.field.length)}`;
46576
- if (template !== ENGLISH_PIVOT_CAPTIONS.aggregates[measure4.aggregate])
46577
- out[measure4.aggregate] = template;
46579
+ const template2 = `${measure4.caption.slice(0, at3)}{0}${measure4.caption.slice(at3 + measure4.field.length)}`;
46580
+ if (template2 !== ENGLISH_PIVOT_CAPTIONS.aggregates[measure4.aggregate])
46581
+ out[measure4.aggregate] = template2;
46578
46582
  }
46579
46583
  return Object.keys(out).length ? out : void 0;
46580
46584
  }
@@ -48870,9 +48874,9 @@ function prefixText(prefix3) {
48870
48874
  // xlsx/formula/shift-formula.ts
48871
48875
  var templates = /* @__PURE__ */ new Map();
48872
48876
  var MAX_TEMPLATES = 2e5;
48873
- function remember2(text7, template) {
48877
+ function remember2(text7, template2) {
48874
48878
  if (templates.size >= MAX_TEMPLATES) templates.clear();
48875
- templates.set(text7, template);
48879
+ templates.set(text7, template2);
48876
48880
  }
48877
48881
  function mergeSpacedAreas(tokens3) {
48878
48882
  const out = [];
@@ -48903,16 +48907,16 @@ function templateOf2(formula2) {
48903
48907
  const cached7 = templates.get(formula2);
48904
48908
  if (cached7 !== void 0) return cached7;
48905
48909
  const raw2 = safeTokens(formula2);
48906
- let template = null;
48910
+ let template2 = null;
48907
48911
  if (raw2) {
48908
- template = [];
48912
+ template2 = [];
48909
48913
  let literal4 = "";
48910
48914
  for (const token2 of mergeSpacedAreas(raw2)) {
48911
48915
  if (token2.kind !== "ref" && !(token2.kind === "name" && token2.prefix)) {
48912
48916
  literal4 += token2.text;
48913
48917
  continue;
48914
48918
  }
48915
- if (literal4) template.push(literal4);
48919
+ if (literal4) template2.push(literal4);
48916
48920
  literal4 = "";
48917
48921
  const part = { kind: token2.kind, text: token2.text };
48918
48922
  if (token2.prefix) {
@@ -48921,23 +48925,23 @@ function templateOf2(formula2) {
48921
48925
  }
48922
48926
  if (token2.ref) part.ref = token2.ref;
48923
48927
  if (token2.spill) part.spill = true;
48924
- template.push(part);
48928
+ template2.push(part);
48925
48929
  }
48926
- if (literal4) template.push(literal4);
48930
+ if (literal4) template2.push(literal4);
48927
48931
  }
48928
- remember2(formula2, template);
48929
- return template;
48932
+ remember2(formula2, template2);
48933
+ return template2;
48930
48934
  }
48931
48935
  function rewriteTemplate(formula2, rewrite2) {
48932
- const template = templateOf2(formula2);
48933
- if (!template) return formula2;
48936
+ const template2 = templateOf2(formula2);
48937
+ if (!template2) return formula2;
48934
48938
  let next;
48935
- for (let i2 = 0; i2 < template.length; i2++) {
48936
- const part = template[i2];
48939
+ for (let i2 = 0; i2 < template2.length; i2++) {
48940
+ const part = template2[i2];
48937
48941
  if (typeof part === "string") continue;
48938
48942
  const changed = rewrite2(part);
48939
48943
  if (!changed) continue;
48940
- next ??= template.slice();
48944
+ next ??= template2.slice();
48941
48945
  next[i2] = changed;
48942
48946
  }
48943
48947
  if (!next) return formula2;
@@ -49968,7 +49972,12 @@ function vmlCaption(vml, shapeId2) {
49968
49972
  const shape2 = vml.slice(start, end < 0 ? void 0 : end);
49969
49973
  const box5 = /<v:textbox[^>]*>([\s\S]*?)<\/v:textbox>/.exec(shape2)?.[1];
49970
49974
  if (!box5) return void 0;
49971
- const text7 = box5.replace(/<br\s*\/?>/gi, "\n").replace(/<[^>]*>/g, "").replace(/&(#x?[0-9a-f]+|\w+);/gi, (match2, code) => {
49975
+ let stripped = box5.replace(/<br\s*\/?>/gi, "\n");
49976
+ for (let prev = ""; prev !== stripped; ) {
49977
+ prev = stripped;
49978
+ stripped = stripped.replace(/<[^>]*>/g, "");
49979
+ }
49980
+ const text7 = stripped.replace(/&(#x?[0-9a-f]+|\w+);/gi, (match2, code) => {
49972
49981
  if (code.startsWith("#")) {
49973
49982
  const value3 = code[1]?.toLowerCase() === "x" ? parseInt(code.slice(2), 16) : Number(code.slice(1));
49974
49983
  return Number.isFinite(value3) ? String.fromCodePoint(value3) : match2;
@@ -52024,12 +52033,12 @@ function reanchor(xml, anchor2) {
52024
52033
  ).documentElement;
52025
52034
  for (const candidate of Array.from(holder.childNodes)) {
52026
52035
  if (candidate.nodeType !== 1) continue;
52027
- const template = candidate;
52028
- const original = first(old, template.localName, NS.xdr);
52029
- const position3 = original ? original.cloneNode(true) : doc.importNode(template, true);
52030
- for (const attribute4 of Array.from(template.attributes))
52036
+ const template2 = candidate;
52037
+ const original = first(old, template2.localName, NS.xdr);
52038
+ const position3 = original ? original.cloneNode(true) : doc.importNode(template2, true);
52039
+ for (const attribute4 of Array.from(template2.attributes))
52031
52040
  position3.setAttribute(attribute4.name, attribute4.value);
52032
- for (const value3 of Array.from(template.childNodes)) {
52041
+ for (const value3 of Array.from(template2.childNodes)) {
52033
52042
  if (value3.nodeType !== 1) continue;
52034
52043
  const item2 = value3;
52035
52044
  const existing = first(position3, item2.localName, NS.xdr);
@@ -53884,14 +53893,14 @@ function linearFit(xs, ys) {
53884
53893
  return { slope, intercept: my - slope * mx };
53885
53894
  }
53886
53895
  function rank3(values2, x, ascending, average) {
53887
- let better = 0;
53896
+ let better2 = 0;
53888
53897
  let ties = 0;
53889
53898
  for (const v of values2) {
53890
53899
  if (v === x) ties++;
53891
- else if (ascending ? v < x : v > x) better++;
53900
+ else if (ascending ? v < x : v > x) better2++;
53892
53901
  }
53893
53902
  if (ties === 0) fail(ERR.NA);
53894
- return average ? better + (ties + 1) / 2 : better + 1;
53903
+ return average ? better2 + (ties + 1) / 2 : better2 + 1;
53895
53904
  }
53896
53905
  var LANCZOS = [
53897
53906
  676.5203681218851,
@@ -58924,11 +58933,11 @@ function binomDist(k, n, p, cumulative2) {
58924
58933
  for (let i2 = 0; i2 <= kk; i2++) total2 += binomPmf(i2, nn, p);
58925
58934
  return Math.min(1, total2);
58926
58935
  }
58927
- function poisson(k, mean4, cumulative2) {
58936
+ function poisson(k, mean9, cumulative2) {
58928
58937
  const kk = Math.trunc(k);
58929
- if (kk < 0 || mean4 < 0) fail(ERR.NUM);
58930
- if (cumulative2) return 1 - gammaP(kk + 1, mean4);
58931
- return Math.exp(kk * Math.log(mean4) - mean4 - gammaLn(kk + 1));
58938
+ if (kk < 0 || mean9 < 0) fail(ERR.NUM);
58939
+ if (cumulative2) return 1 - gammaP(kk + 1, mean9);
58940
+ return Math.exp(kk * Math.log(mean9) - mean9 - gammaLn(kk + 1));
58932
58941
  }
58933
58942
  var normDist = (x, m, s, cumulative2) => {
58934
58943
  positive2(s);
@@ -58936,13 +58945,272 @@ var normDist = (x, m, s, cumulative2) => {
58936
58945
  return cumulative2 ? normCdf(z2) : normPdf(z2) / s;
58937
58946
  };
58938
58947
 
58948
+ // xlsx/formula/functions/ets-init-three.ts
58949
+ var mean2 = (xs) => xs.reduce((a2, b) => a2 + b, 0) / (xs.length || 1);
58950
+ function slopeOf(v) {
58951
+ const k = v.length;
58952
+ const mx = (k - 1) / 2;
58953
+ const my = mean2(v);
58954
+ let sxy = 0;
58955
+ let sxx = 0;
58956
+ for (let i2 = 0; i2 < k; i2++) {
58957
+ sxy += (i2 - mx) * (v[i2] - my);
58958
+ sxx += (i2 - mx) * (i2 - mx);
58959
+ }
58960
+ return sxx === 0 ? 0 : sxy / sxx;
58961
+ }
58962
+ function positionSlopes(y, m) {
58963
+ return Array.from({ length: m }, (_v, c2) => {
58964
+ const vals = [];
58965
+ for (let t = c2; t < y.length; t += m) vals.push(y[t]);
58966
+ return slopeOf(vals) / m;
58967
+ });
58968
+ }
58969
+ function isThreeSeasonLength(n, m) {
58970
+ return m >= 4 && n >= 3 * m && n <= 3 * m + Math.ceil(m / 2) + 1;
58971
+ }
58972
+ function threeSeasonSeasonals(y, m, slopeSumOverride) {
58973
+ const n = y.length;
58974
+ const extra = n - 3 * m;
58975
+ const j0 = Math.floor(m / 2);
58976
+ const at3 = (t) => y[t];
58977
+ const slope = (j) => (at3(j + 2 * m) - at3(j)) / (2 * m);
58978
+ const B = (j) => j + 2 * m < n ? slope(j) : slope(j % m);
58979
+ const e = (t) => at3(t) - at3(t - 1) - B(t - j0);
58980
+ const slopeSum = slopeSumOverride ?? positionSlopes(y, m).reduce((a2, b) => a2 + b, 0);
58981
+ const out = [0];
58982
+ for (let k = 1; k < m; k++) {
58983
+ let back = 0;
58984
+ for (let t = k + 1; t <= m; t++) back -= e(t);
58985
+ let fwd = 0;
58986
+ for (let t = m + 1; t <= m + k; t++) fwd += e(t);
58987
+ if (k < j0 - 1) {
58988
+ out.push(fwd);
58989
+ continue;
58990
+ }
58991
+ if (k === m - 1 && extra <= Math.ceil(m / 2)) {
58992
+ out.push(back);
58993
+ continue;
58994
+ }
58995
+ const wrapped = Math.max(0, k - j0 + 1 - extra);
58996
+ let corner4 = 0;
58997
+ for (let i2 = extra; i2 <= k - j0; i2++)
58998
+ corner4 += (at3(i2 + m) + at3(i2 + 2 * m) - 2 * at3(i2)) / (4 * m);
58999
+ const level4 = (at3(k) + at3(m + k)) / 2 - at3(m);
59000
+ const bb = back - (at3(k) - at3(m));
59001
+ const ff = fwd - (at3(m + k) - at3(m));
59002
+ out.push(level4 + (bb + ff) / 2 - 3 * wrapped / (4 * m) * slopeSum + corner4);
59003
+ }
59004
+ return out;
59005
+ }
59006
+ function padThreeSeasons(y, m, slopeMean = mean2(positionSlopes(y, m))) {
59007
+ const n = y.length;
59008
+ const total2 = Math.max(3 * m + Math.ceil(m / 2), n);
59009
+ const ext = [...y];
59010
+ for (let t = n; t < total2; t++) ext.push(y[t - 3 * m] + 3 * m * slopeMean);
59011
+ return ext;
59012
+ }
59013
+ function threeSeasonTrend(y, m, rel, slopeMean) {
59014
+ const ext = padThreeSeasons(y, m, slopeMean);
59015
+ const total2 = ext.length;
59016
+ const mx = (total2 - 1) / 2;
59017
+ let sxx = 0;
59018
+ let sxy = 0;
59019
+ for (let t = 0; t < total2; t++) {
59020
+ sxx += (t - mx) * (t - mx);
59021
+ sxy += (t - mx) * (ext[t] - rel[t % m]);
59022
+ }
59023
+ return sxy / sxx;
59024
+ }
59025
+ function isTwoSeasonLength(n, m) {
59026
+ return m >= 4 && n === 2 * m;
59027
+ }
59028
+ function isTwoPlusLength(n, m) {
59029
+ return m >= 4 && n > 2 * m && n < 3 * m;
59030
+ }
59031
+ function slopeSumOf(y, m) {
59032
+ return positionSlopes(y, m).reduce((a2, c2) => a2 + c2, 0);
59033
+ }
59034
+ function extendTwoSeasons(y, m) {
59035
+ const b = mean2(positionSlopes(y, m));
59036
+ const out = [...y];
59037
+ for (let t = y.length; t < 3 * m; t++) out.push(y[t - 2 * m] + 2 * m * b);
59038
+ return out;
59039
+ }
59040
+ function paddedSearchSeries(y, m) {
59041
+ if (isTwoSeasonLength(y.length, m) || isTwoPlusLength(y.length, m))
59042
+ return padThreeSeasons(extendTwoSeasons(y, m), m, slopeSumOf(y, m) / m);
59043
+ if (isThreeSeasonLength(y.length, m)) return padThreeSeasons(y, m);
59044
+ return void 0;
59045
+ }
59046
+
59047
+ // xlsx/formula/functions/ets-init-states.ts
59048
+ var mean3 = (xs) => xs.reduce((a2, b) => a2 + b, 0) / (xs.length || 1);
59049
+ function chainStates(y, m, seasons) {
59050
+ const h2 = Math.floor(seasons / 2);
59051
+ const first3 = seasons - h2;
59052
+ const at3 = (t) => y[t];
59053
+ const meanFirst = (t) => mean3(Array.from({ length: first3 }, (_v, c2) => at3(t + c2 * m)));
59054
+ const slope = (j) => {
59055
+ const early = mean3(Array.from({ length: h2 }, (_v, c2) => at3(j + c2 * m)));
59056
+ const late = mean3(Array.from({ length: h2 }, (_v, c2) => at3(j + (seasons - h2 + c2) * m)));
59057
+ return (late - early) / ((seasons - h2) * m);
59058
+ };
59059
+ const j0 = Math.floor(m / 2);
59060
+ const state = /* @__PURE__ */ new Map([[j0 - 1, 0]]);
59061
+ for (let t = j0; t <= j0 + m - 2; t++)
59062
+ state.set(t, state.get(t - 1) + meanFirst(t) - meanFirst(t - 1) - slope(t - j0));
59063
+ const byPosition2 = new Array(m).fill(0);
59064
+ for (const [t, s] of state) byPosition2[t % m] = s;
59065
+ return byPosition2;
59066
+ }
59067
+ function chainSeasonals(y, m, seasons) {
59068
+ const byPosition2 = chainStates(y, m, seasons);
59069
+ const origin = byPosition2[0];
59070
+ return byPosition2.map((s) => s - origin);
59071
+ }
59072
+
59073
+ // xlsx/formula/functions/ets-init-four.ts
59074
+ var mean4 = (xs) => xs.reduce((a2, b) => a2 + b, 0) / (xs.length || 1);
59075
+ function template(w, m, a2) {
59076
+ const block = (c2) => mean4(w.slice(c2 * m, (c2 + 1) * m));
59077
+ const at3 = (i2) => w[i2];
59078
+ return (block(0) - block(2)) / 12 + (block(1) - block(3)) / 6 - (at3(a2) + at3(a2 + m) - 2 * at3(a2 + 2 * m)) / 6;
59079
+ }
59080
+ function fourSeasonPlusSeasonals(y, m) {
59081
+ const r = y.length - 4 * m;
59082
+ const a2 = Math.floor(m / 2) - 1;
59083
+ const states2 = chainStates(y.slice(0, 4 * m), m, 4);
59084
+ for (let q = 0; q < r; q++) {
59085
+ const pos = (a2 + q) % m;
59086
+ states2[pos] = states2[pos] + template(y.slice(q, q + 4 * m), m, a2);
59087
+ }
59088
+ const origin = states2[0];
59089
+ return states2.map((s) => s - origin);
59090
+ }
59091
+
59092
+ // xlsx/formula/functions/ets-init-threeplus.ts
59093
+ var mean5 = (xs) => xs.reduce((a2, b) => a2 + b, 0) / (xs.length || 1);
59094
+ function isThreePlusLength(n, m) {
59095
+ return m >= 4 && n >= 3 * m + Math.ceil(m / 2) + 2 && n < 4 * m;
59096
+ }
59097
+ function shift2(y, m, k) {
59098
+ const a2 = Math.ceil(m / 2) + 1;
59099
+ const at3 = (i2) => y[i2];
59100
+ return (at3(m + k) - at3(2 * m + k)) / 2 - (mean5(y.slice(a2 + k, a2 + k + m)) - mean5(y.slice(a2 + 2 * m + k, a2 + 3 * m + k))) / 4;
59101
+ }
59102
+ function isLowThreeLength(n, m) {
59103
+ return m === 2 && n >= 5 && n < 8 || m === 3 && n >= 6 && n < 12;
59104
+ }
59105
+ function lowSeasonSeasonals(y, m, slopeSum) {
59106
+ const base3 = threeSeasonSeasonals(y, m, slopeSum);
59107
+ const d = -shift2(y, m, -m);
59108
+ return base3.map((s, k) => k === 0 ? 0 : s + d);
59109
+ }
59110
+ function threePlusSeasonals(y, m) {
59111
+ const base3 = threeSeasonSeasonals(y, m);
59112
+ const moved = y.length - 3 * m - Math.ceil(m / 2) - 1;
59113
+ const z2 = base3.map((s, k) => k < moved ? s - shift2(y, m, k) : s);
59114
+ const origin = z2[0];
59115
+ return z2.map((s) => s - origin);
59116
+ }
59117
+
59118
+ // xlsx/formula/functions/ets-init-short.ts
59119
+ function seasonStart(m) {
59120
+ return Math.ceil(10 * (m + 1) / 7);
59121
+ }
59122
+ function isShortSeasonLength(n, m) {
59123
+ return m >= 5 && n >= seasonStart(m) && n < 2 * m;
59124
+ }
59125
+ function padTwoSeasons(y, m) {
59126
+ const p = [...y];
59127
+ for (let t = y.length; t < 2 * m; t++) p.push(p[t - m]);
59128
+ return p;
59129
+ }
59130
+ function trendShift(m, n) {
59131
+ const j0 = Math.floor(m / 2);
59132
+ const u = 2 * m - 1 - n;
59133
+ return (u * u - (j0 - 2) * u + 2 * (j0 - 1)) / 4;
59134
+ }
59135
+ function shortSeasonStart(y, m) {
59136
+ const n = y.length;
59137
+ const p = padTwoSeasons(y, m);
59138
+ const ss = slopeSumOf(p, m);
59139
+ const ext = extendTwoSeasons(p, m);
59140
+ const base3 = threeSeasonSeasonals(ext, m, ss);
59141
+ const total2 = 3 * m + Math.ceil(m / 2);
59142
+ const sxx = total2 * (total2 * total2 - 1) / 12;
59143
+ const trend = threeSeasonTrend(ext, m, base3, ss / m) + trendShift(m, n) * ss / sxx;
59144
+ const rel = base3.map((s, k) => k >= n - m && k <= m - 2 ? s + ss / 2 : s);
59145
+ return { rel, trend };
59146
+ }
59147
+ function shortSearchSeries(y, m) {
59148
+ const p = padTwoSeasons(y, m);
59149
+ return padThreeSeasons(extendTwoSeasons(p, m), m, slopeSumOf(p, m) / m);
59150
+ }
59151
+
59152
+ // xlsx/formula/functions/ets-init-chain.ts
59153
+ var MAX_SEASONS = 5;
59154
+ var mean6 = (xs) => xs.reduce((a2, b) => a2 + b, 0) / (xs.length || 1);
59155
+ function isExactLength(n, m) {
59156
+ const whole = Math.floor(n / m);
59157
+ return whole >= MAX_SEASONS || whole === 4 || isThreeSeasonLength(n, m) || isThreePlusLength(n, m) || isLowThreeLength(n, m) || isTwoSeasonLength(n, m) || isTwoPlusLength(n, m) || isShortSeasonLength(n, m);
59158
+ }
59159
+ function fromRelative(y0, rel, trend) {
59160
+ const combined = rel.map((s) => y0 + s - trend);
59161
+ const level4 = mean6(combined);
59162
+ return { level: level4, trend, season: combined.map((c2) => c2 - level4) };
59163
+ }
59164
+ function chainStart(y, m) {
59165
+ const n = y.length;
59166
+ const whole = Math.floor(n / m);
59167
+ if (isShortSeasonLength(n, m)) {
59168
+ const { rel: rel2, trend } = shortSeasonStart(y, m);
59169
+ return fromRelative(y[0], rel2, trend);
59170
+ }
59171
+ if (isThreeSeasonLength(n, m) || isTwoSeasonLength(n, m) || isTwoPlusLength(n, m)) {
59172
+ const short = isTwoSeasonLength(n, m) || isTwoPlusLength(n, m);
59173
+ const series = short ? extendTwoSeasons(y, m) : y;
59174
+ const rel2 = threeSeasonSeasonals(series, m, short ? slopeSumOf(y, m) : void 0);
59175
+ return fromRelative(
59176
+ y[0],
59177
+ rel2,
59178
+ threeSeasonTrend(series, m, rel2, short ? slopeSumOf(y, m) / m : void 0)
59179
+ );
59180
+ }
59181
+ if (isLowThreeLength(n, m)) {
59182
+ const short = n < 3 * m;
59183
+ const series = short ? extendTwoSeasons(y, m) : y;
59184
+ const rel2 = lowSeasonSeasonals(series, m, short ? slopeSumOf(y, m) : void 0);
59185
+ const pad8 = short ? slopeSumOf(y, m) / m : void 0;
59186
+ return fromRelative(y[0], rel2, threeSeasonTrend(series, m, rel2, pad8));
59187
+ }
59188
+ if (isThreePlusLength(n, m)) {
59189
+ const rel2 = threePlusSeasonals(y, m);
59190
+ return fromRelative(y[0], rel2, threeSeasonTrend(y, m, rel2));
59191
+ }
59192
+ if (m < 2 || whole < 4) return void 0;
59193
+ const partial2 = whole < MAX_SEASONS && n % m !== 0;
59194
+ const rel = partial2 ? fourSeasonPlusSeasonals(y, m) : chainSeasonals(y, m, Math.min(whole, MAX_SEASONS));
59195
+ const mx = (n - 1) / 2;
59196
+ let sxy = 0;
59197
+ let sxx = 0;
59198
+ const my = mean6(y.map((v, t) => v - rel[t % m]));
59199
+ for (let t = 0; t < n; t++) {
59200
+ const d = y[t] - rel[t % m] - my;
59201
+ sxy += (t - mx) * d;
59202
+ sxx += (t - mx) * (t - mx);
59203
+ }
59204
+ return fromRelative(y[0], rel, sxy / sxx);
59205
+ }
59206
+
58939
59207
  // xlsx/formula/functions/ets-init.ts
58940
59208
  var MAX_EXACT_SEASON = 24;
58941
- var mean2 = (xs) => xs.reduce((a2, b) => a2 + b, 0) / (xs.length || 1);
59209
+ var mean7 = (xs) => xs.reduce((a2, b) => a2 + b, 0) / (xs.length || 1);
58942
59210
  function olsSlope(y) {
58943
59211
  const n = y.length;
58944
59212
  const mx = (n - 1) / 2;
58945
- const my = mean2(y);
59213
+ const my = mean7(y);
58946
59214
  let sxy = 0;
58947
59215
  let sxx = 0;
58948
59216
  for (let i2 = 0; i2 < n; i2++) {
@@ -58951,12 +59219,30 @@ function olsSlope(y) {
58951
59219
  }
58952
59220
  return sxx === 0 ? 0 : sxy / sxx;
58953
59221
  }
59222
+ var PADS = {
59223
+ 6: [[0, 6]],
59224
+ 5: [
59225
+ [1, 4],
59226
+ [0, 6]
59227
+ ],
59228
+ 4: [
59229
+ [0, 4],
59230
+ [1, 4],
59231
+ [0, 6]
59232
+ ]
59233
+ };
59234
+ function shortSeriesTrend(y) {
59235
+ const pads = PADS[y.length];
59236
+ if (!pads) return olsSlope(y);
59237
+ const slope = olsSlope(y);
59238
+ return olsSlope([...y, ...pads.map(([src, lag]) => y[src] + lag * slope)]);
59239
+ }
58954
59240
  function split(trend, combined) {
58955
- const level4 = mean2(combined);
59241
+ const level4 = mean7(combined);
58956
59242
  return { level: level4, trend, season: combined.map((c2) => c2 - level4) };
58957
59243
  }
58958
59244
  function heuristicStates(y, m) {
58959
- const trend = (mean2(y.slice(m, 2 * m)) - mean2(y.slice(0, m))) / m;
59245
+ const trend = (mean7(y.slice(m, 2 * m)) - mean7(y.slice(0, m))) / m;
58960
59246
  return split(
58961
59247
  trend,
58962
59248
  Array.from({ length: m }, (_v, k) => y[k] - trend * (k + 1))
@@ -58993,9 +59279,11 @@ function solveSystem(a2, b) {
58993
59279
  function initialStates(y, m, p, run2) {
58994
59280
  const y0 = y[0];
58995
59281
  if (m < 2) {
58996
- const trend2 = olsSlope(y);
59282
+ const trend2 = shortSeriesTrend(y);
58997
59283
  return { level: y0 - trend2, trend: trend2, season: [] };
58998
59284
  }
59285
+ const exact = chainStart(y, m);
59286
+ if (exact) return exact;
58999
59287
  if (m > MAX_EXACT_SEASON) return heuristicStates(y, m);
59000
59288
  const zeros = new Array(y.length).fill(0);
59001
59289
  const unit3 = (trend2, season) => run2(zeros, m, { level: 0, trend: trend2, season }, p).fitted;
@@ -59015,6 +59303,202 @@ function initialStates(y, m, p, run2) {
59015
59303
  return split(trend, [y0 - trend, ...u.slice(1)]);
59016
59304
  }
59017
59305
 
59306
+ // xlsx/formula/functions/ets-search-map.ts
59307
+ var LOW = 1e-3;
59308
+ var DRIFT_SHIFT = 1.5;
59309
+ var DRIFT_T = 9.3;
59310
+ var CANDIDATES = [
59311
+ ...[2e-3, 0.1, 0.126, 0.25, 0.5, 0.75, 0.9].map((a2) => [a2, LOW]),
59312
+ [0.1, 0.099],
59313
+ [0.126, 0.125],
59314
+ [0.25, 0.249],
59315
+ [0.333333, 0.166667],
59316
+ [0.5, 0.25],
59317
+ [0.5, 0.499],
59318
+ [0.666667, 0.166667],
59319
+ [0.666667, 0.5],
59320
+ [0.75, 0.749],
59321
+ [0.833333, 0.75],
59322
+ [0.9, 0.899],
59323
+ [0.998, 0.099],
59324
+ [0.998, 0.249],
59325
+ [0.998, 0.499],
59326
+ [0.998, 0.749],
59327
+ [0.998, 0.899],
59328
+ [0.166667, 0.0833333],
59329
+ [0.833333, 0.0833333]
59330
+ ];
59331
+ var ALWAYS_DRIFT = /* @__PURE__ */ new Set([
59332
+ "0.1/0.099",
59333
+ "0.998/0.899",
59334
+ "0.998/0.749",
59335
+ "0.166667/0.0833333",
59336
+ "0.25/0.249",
59337
+ "0.9/0.899",
59338
+ "0.666667/0.5",
59339
+ "0.75/0.749"
59340
+ ]);
59341
+ var NEVER_DRIFT = /* @__PURE__ */ new Set(["0.333333/0.166667"]);
59342
+ function trendShape(y, h2) {
59343
+ const n = y.length;
59344
+ const hold = h2 > 0 ? h2 : Math.max(1, Math.round(0.3 * n));
59345
+ const mx = (n - 1) / 2;
59346
+ let my = 0;
59347
+ for (const v of y) my += v;
59348
+ my /= n;
59349
+ let sxy = 0;
59350
+ let sxx = 0;
59351
+ let syy = 0;
59352
+ for (let i2 = 0; i2 < n; i2++) {
59353
+ const dy = y[i2] - my;
59354
+ sxy += (i2 - mx) * dy;
59355
+ sxx += (i2 - mx) * (i2 - mx);
59356
+ syy += dy * dy;
59357
+ }
59358
+ if (syy === 0 || sxx === 0 || n < 3) return { shift: 0, t: 0 };
59359
+ const slope = sxy / sxx;
59360
+ const resid = syy - slope * sxy;
59361
+ const se = Math.sqrt(Math.max(resid, 0) / (n - 2) / sxx);
59362
+ let tail = 0;
59363
+ for (let i2 = n - hold; i2 < n; i2++) tail += y[i2];
59364
+ let head = 0;
59365
+ for (let i2 = 0; i2 < n - hold; i2++) head += y[i2];
59366
+ const shift4 = Math.abs(tail / hold - head / (n - hold)) / Math.sqrt(syy / n);
59367
+ return { shift: shift4, t: se === 0 ? Number.POSITIVE_INFINITY : Math.abs(slope / se) };
59368
+ }
59369
+ function reportedFor(alpha, beta, shape2) {
59370
+ const key2 = `${alpha}/${beta}`;
59371
+ let drift;
59372
+ if (beta === LOW) drift = false;
59373
+ else if (ALWAYS_DRIFT.has(key2)) drift = true;
59374
+ else if (NEVER_DRIFT.has(key2)) drift = false;
59375
+ else drift = shape2.shift <= DRIFT_SHIFT && shape2.t <= DRIFT_T;
59376
+ return { alpha, beta: drift ? LOW : beta, fit: [alpha, beta], drift };
59377
+ }
59378
+
59379
+ // xlsx/formula/functions/ets-search.ts
59380
+ var LOW2 = 1e-3;
59381
+ var MIN_SEARCH_POINTS = 4;
59382
+ var THREE_POINTS = { alpha: 0.1, beta: 0.099, gamma: LOW2, drift: false };
59383
+ var SEASON_ALPHAS = [2e-3, 0.126, 0.251, 0.501, 2 / 3, 0.75, 0.9];
59384
+ var SEASON_STEPS = [LOW2, 0.125, 0.25, 0.5, 0.75, 0.9];
59385
+ var SHORT_SERIES = 16;
59386
+ function better(c2, best) {
59387
+ return c2 < best * (1 - 1e-6) && c2 < best - 1e-12;
59388
+ }
59389
+ var SEASONAL_TRIPLES = [
59390
+ [0.126, LOW2, LOW2],
59391
+ [0.251, LOW2, LOW2],
59392
+ [0.501, LOW2, LOW2],
59393
+ [0.751, LOW2, LOW2],
59394
+ [2e-3, LOW2, 0.125],
59395
+ [2e-3, LOW2, 0.25],
59396
+ [2e-3, LOW2, 0.5],
59397
+ [2e-3, LOW2, 0.75],
59398
+ [0.251, LOW2, 0.25],
59399
+ [0.75, LOW2, 0.249],
59400
+ [0.9, LOW2, 0.099],
59401
+ [0.251, 0.25, LOW2],
59402
+ [0.1, LOW2, 0.899],
59403
+ [0.126, 0.125, LOW2],
59404
+ [0.998, 0.099, LOW2],
59405
+ [0.25, LOW2, 0.749],
59406
+ [0.5, LOW2, 0.499],
59407
+ [0.5, 0.25, LOW2],
59408
+ [0.251, 0.25, 0.25],
59409
+ [0.501, 0.5, LOW2]
59410
+ ];
59411
+ var SHORT_EXTRA_TRIPLES = [
59412
+ [1 / 6, 1 / 12, 1 / 12],
59413
+ [1 / 3, 1 / 6, 1 / 6],
59414
+ [1 / 6, 1 / 12, 0.75],
59415
+ [1 / 3, 1 / 6, 0.5],
59416
+ [5 / 6, 1 / 12, 1 / 12]
59417
+ ];
59418
+ function searchSeasonalLattice(cost, extra = []) {
59419
+ let best = { alpha: 0.126, beta: LOW2, gamma: LOW2 };
59420
+ let bestCost = cost(best);
59421
+ for (const [alpha, beta, gamma2] of [...SEASONAL_TRIPLES, ...extra]) {
59422
+ const c2 = cost({ alpha, beta, gamma: gamma2 });
59423
+ if (better(c2, bestCost)) {
59424
+ bestCost = c2;
59425
+ best = { alpha, beta, gamma: gamma2 };
59426
+ }
59427
+ }
59428
+ return { ...best, drift: false };
59429
+ }
59430
+ function searchSeasonal(n, cost) {
59431
+ let best = { alpha: 0.9, beta: LOW2, gamma: LOW2 };
59432
+ let bestCost = cost(best);
59433
+ for (const a2 of SEASON_ALPHAS)
59434
+ for (const b of n >= 7 && n <= SHORT_SERIES ? [LOW2, a2 - LOW2] : [LOW2])
59435
+ for (const g2 of [...SEASON_STEPS, 1 - a2 - LOW2]) {
59436
+ if (b < LOW2 || g2 > 1 - a2 - LOW2 + 1e-9) continue;
59437
+ const c2 = cost({ alpha: a2, beta: b, gamma: g2 });
59438
+ if (better(c2, bestCost)) {
59439
+ bestCost = c2;
59440
+ best = { alpha: a2, beta: b, gamma: g2 };
59441
+ }
59442
+ }
59443
+ return { ...best, drift: false };
59444
+ }
59445
+ function searchLattice(shape2, cost) {
59446
+ let best = [0.9, LOW2];
59447
+ let bestCost = cost({ alpha: 0.9, beta: LOW2, gamma: LOW2 });
59448
+ for (const [alpha, beta] of CANDIDATES) {
59449
+ const c2 = cost({ alpha, beta, gamma: LOW2 });
59450
+ if (better(c2, bestCost)) {
59451
+ bestCost = c2;
59452
+ best = [alpha, beta];
59453
+ }
59454
+ }
59455
+ const out = reportedFor(best[0], best[1], shape2);
59456
+ const [fa, fb] = out.fit;
59457
+ const same16 = fa === out.alpha && fb === out.beta;
59458
+ return {
59459
+ alpha: out.alpha,
59460
+ beta: out.beta,
59461
+ gamma: LOW2,
59462
+ drift: out.drift,
59463
+ ...same16 ? {} : { fit: { alpha: fa, beta: fb, gamma: LOW2 } }
59464
+ };
59465
+ }
59466
+ function chooseSmoothing(n, m, cost, shape2 = { shift: 9, t: 99 }) {
59467
+ if (m >= 2 && isShortSeasonLength(n, m)) return searchSeasonalLattice(cost, SHORT_EXTRA_TRIPLES);
59468
+ if (m >= 2) return isExactLength(n, m) ? searchSeasonalLattice(cost) : searchSeasonal(n, cost);
59469
+ if (n < MIN_SEARCH_POINTS) return THREE_POINTS;
59470
+ return searchLattice(shape2, cost);
59471
+ }
59472
+
59473
+ // xlsx/formula/functions/ets-validate.ts
59474
+ function etsSearchSeries(y) {
59475
+ const pads = PADS[y.length];
59476
+ if (!pads) return y;
59477
+ const slope = olsSlope(y);
59478
+ return [...y, ...pads.map(([src, lag]) => y[src] + lag * slope)];
59479
+ }
59480
+ function etsValidationCost(y, m, init, p, holdout) {
59481
+ const n = y.length;
59482
+ const train = n - holdout;
59483
+ let { level: level4, trend } = init;
59484
+ const season = [...init.season];
59485
+ let sse = 0;
59486
+ for (let t = 0; t < train; t++) {
59487
+ const k = m >= 2 ? t % m : 0;
59488
+ const e = y[t] - (level4 + trend + (m >= 2 ? season[k] ?? 0 : 0));
59489
+ sse += e * e;
59490
+ level4 += trend + p.alpha * e;
59491
+ trend += p.beta * e;
59492
+ if (m >= 2) season[k] = (season[k] ?? 0) + p.gamma * e;
59493
+ }
59494
+ for (let j = 1; j <= holdout; j++) {
59495
+ const t = train + j - 1;
59496
+ const e = y[t] - (level4 + j * trend + (m >= 2 ? season[t % m] ?? 0 : 0));
59497
+ sse += e * e;
59498
+ }
59499
+ return sse;
59500
+ }
59501
+
59018
59502
  // xlsx/formula/functions/ets-core.ts
59019
59503
  function etsRun(y, m, init, p) {
59020
59504
  let { level: level4, trend } = init;
@@ -59033,36 +59517,36 @@ function etsRun(y, m, init, p) {
59033
59517
  }
59034
59518
  return { fitted, level: level4, trend, season, sse };
59035
59519
  }
59036
- var LOW = 1e-3;
59037
- var SHORT_SERIES = 16;
59038
59520
  var NO_SEASON_GAMMA = Number.EPSILON;
59039
- var ALPHAS = [2e-3, 0.1, 0.126, 0.25, 0.5, 2 / 3, 0.75, 0.9];
59040
- var SEASON_ALPHAS = [2e-3, 0.126, 0.251, 0.501, 2 / 3, 0.75, 0.9];
59041
- var SEASON_STEPS = [LOW, 0.125, 0.25, 0.5, 0.75, 0.9];
59042
59521
  function fitEts(y, seasonLength) {
59043
59522
  const n = y.length;
59044
59523
  if (n < 2) fail(ERR.NUM);
59045
- const m = seasonLength >= 2 && n >= 2 * seasonLength ? seasonLength : 0;
59524
+ const m = seasonLength >= 2 && n >= seasonStart(seasonLength) ? seasonLength : 0;
59046
59525
  const solve2 = (p) => {
59047
59526
  const init = initialStates(y, m, p, etsRun);
59048
59527
  return { init, run: etsRun(y, m, init, p) };
59049
59528
  };
59050
- const cost = (v) => solve2({ alpha: v[0], beta: v[1], gamma: v[2] }).run.sse;
59051
- let best = [0.9, LOW, LOW];
59052
- let bestCost = cost(best);
59053
- for (const a2 of m >= 2 ? SEASON_ALPHAS : ALPHAS)
59054
- for (const b of n >= 7 && n <= SHORT_SERIES ? [LOW, a2 - LOW] : [LOW])
59055
- for (const g2 of m >= 2 ? [...SEASON_STEPS, 1 - a2 - LOW] : [LOW]) {
59056
- if (b < LOW || g2 > 1 - a2 - LOW + 1e-9) continue;
59057
- const c2 = cost([a2, b, g2]);
59058
- if (c2 < bestCost * (1 - 1e-6) && c2 < bestCost - 1e-12) {
59059
- bestCost = c2;
59060
- best = [a2, b, g2];
59061
- }
59062
- }
59063
- const [alpha, beta, gamma2] = best;
59064
- const { run: run2 } = solve2({ alpha, beta, gamma: gamma2 });
59065
- return { alpha, beta, gamma: m >= 2 ? gamma2 : NO_SEASON_GAMMA, m, n, ...run2 };
59529
+ const exact = m < 2 || isExactLength(n, m);
59530
+ const padded = m >= 2 && exact ? isShortSeasonLength(n, m) ? shortSearchSeries(y, m) : paddedSearchSeries(y, m) : void 0;
59531
+ const searched = padded ?? (m >= 2 ? y : etsSearchSeries(y));
59532
+ const holdout = m >= 2 && !exact ? 0 : etsHoldout(padded && !(m >= 2 && isShortSeasonLength(n, m)) ? padded.length : n, m);
59533
+ const { drift, fit: fit3, ...chosen } = chooseSmoothing(
59534
+ n,
59535
+ m,
59536
+ (p) => etsValidationCost(searched, m, solve2(p).init, p, holdout),
59537
+ trendShape(y, holdout)
59538
+ );
59539
+ const { run: run2 } = solve2(fit3 ?? chosen);
59540
+ const state = drift ? solve2({ alpha: 1, beta: 0, gamma: chosen.gamma }).run : run2;
59541
+ return {
59542
+ ...chosen,
59543
+ gamma: m >= 2 ? chosen.gamma : NO_SEASON_GAMMA,
59544
+ m,
59545
+ n,
59546
+ ...run2,
59547
+ level: state.level,
59548
+ trend: state.trend
59549
+ };
59066
59550
  }
59067
59551
  function etsHoldout(n, m) {
59068
59552
  if (n < 11) return 0;
@@ -59087,12 +59571,12 @@ function etsErrorSd(fit3, h2) {
59087
59571
  // xlsx/formula/functions/ets-season.ts
59088
59572
  var MAX_POINTS = 8192;
59089
59573
  var MIN_CYCLES = 3;
59090
- var MIN_SHARE = 0.3;
59091
- var mean3 = (xs) => xs.reduce((a2, b) => a2 + b, 0) / (xs.length || 1);
59574
+ var MIN_ACF = 0.3;
59575
+ var mean8 = (xs) => xs.reduce((a2, b) => a2 + b, 0) / (xs.length || 1);
59092
59576
  function detrend(y) {
59093
59577
  const n = y.length;
59094
59578
  const mx = (n - 1) / 2;
59095
- const my = mean3(y);
59579
+ const my = mean8(y);
59096
59580
  let sxy = 0;
59097
59581
  let sxx = 0;
59098
59582
  for (let i2 = 0; i2 < n; i2++) {
@@ -59109,34 +59593,23 @@ function detectSeasonality(series) {
59109
59593
  const r = detrend(y);
59110
59594
  const scale2 = Math.max(...y.map(Math.abs), 1);
59111
59595
  if (r.every((v) => Math.abs(v) <= 1e-12 * scale2)) return 0;
59112
- const cos2 = new Float64Array(n);
59113
- const sin2 = new Float64Array(n);
59114
- for (let j = 0; j < n; j++) {
59115
- cos2[j] = Math.cos(2 * Math.PI * j / n);
59116
- sin2[j] = Math.sin(2 * Math.PI * j / n);
59117
- }
59118
- let total2 = 0;
59119
- let best = 0;
59120
- let bestK = 0;
59121
- for (let k = 1; k <= Math.floor(n / 2); k++) {
59122
- let re = 0;
59123
- let im = 0;
59124
- for (let t = 0; t < n; t++) {
59125
- const j = k * t % n;
59126
- const v = r[t];
59127
- re += v * cos2[j];
59128
- im -= v * sin2[j];
59129
- }
59130
- const power2 = re * re + im * im;
59131
- total2 += power2;
59132
- if (k >= MIN_CYCLES && power2 > best) {
59133
- best = power2;
59134
- bestK = k;
59135
- }
59596
+ const maxLag = Math.floor(n / MIN_CYCLES);
59597
+ let energy = 0;
59598
+ for (const v of r) energy += v * v;
59599
+ const acf = (lag) => {
59600
+ let s = 0;
59601
+ for (let t = 0; t + lag < n; t++) s += r[t] * r[t + lag];
59602
+ return s / energy;
59603
+ };
59604
+ let prev = acf(1);
59605
+ let cur = acf(2);
59606
+ for (let lag = 2; lag <= maxLag; lag++) {
59607
+ const next = acf(lag + 1);
59608
+ if (cur >= prev && cur >= next && cur >= MIN_ACF) return lag;
59609
+ prev = cur;
59610
+ cur = next;
59136
59611
  }
59137
- if (bestK === 0 || !(best / total2 >= MIN_SHARE)) return 0;
59138
- const period = Math.round(n / bestK);
59139
- return period >= 2 ? period : 0;
59612
+ return 0;
59140
59613
  }
59141
59614
 
59142
59615
  // xlsx/formula/functions/ets-grid.ts
@@ -59208,9 +59681,9 @@ function aggregate2(code, xs) {
59208
59681
  case 4:
59209
59682
  return Math.max(...xs);
59210
59683
  case 5:
59211
- return Math.min(...xs);
59212
- case 6:
59213
59684
  return median2(xs);
59685
+ case 6:
59686
+ return Math.min(...xs);
59214
59687
  default:
59215
59688
  return xs.reduce((a2, b) => a2 + b, 0);
59216
59689
  }
@@ -62941,11 +63414,11 @@ var ParseCache = class {
62941
63414
  parseNew(formula2) {
62942
63415
  if (formula2.length > MAX_TEMPLATE_LENGTH) return treeOf(makeTemplate(formula2, NO_RUNS));
62943
63416
  const shape2 = formulaShape(formula2);
62944
- const template = this.templates.get(shape2.hash);
62945
- const reused = template && fromTemplate(template, formula2, shape2);
63417
+ const template2 = this.templates.get(shape2.hash);
63418
+ const reused = template2 && fromTemplate(template2, formula2, shape2);
62946
63419
  if (reused) return reused;
62947
63420
  const made = makeTemplate(formula2, shape2);
62948
- if (!template && "ast" in made) {
63421
+ if (!template2 && "ast" in made) {
62949
63422
  if (this.templates.size > MAX_TEMPLATES2) this.templates.clear();
62950
63423
  this.templates.set(shape2.hash, made);
62951
63424
  }
@@ -63663,22 +64136,22 @@ function astTraits(ast) {
63663
64136
  traitsCache.set(ast, traits);
63664
64137
  return traits;
63665
64138
  }
63666
- function intervalDelta(a2, b, shift3) {
63667
- const { at: at3, count: count3 } = shift3;
64139
+ function intervalDelta(a2, b, shift4) {
64140
+ const { at: at3, count: count3 } = shift4;
63668
64141
  if (count3 > 0) {
63669
64142
  if (b < at3) return 0;
63670
64143
  if (a2 < at3) return void 0;
63671
- return b + count3 > (shift3.axis === "row" ? MAX_ROW : MAX_COL) ? void 0 : count3;
64144
+ return b + count3 > (shift4.axis === "row" ? MAX_ROW : MAX_COL) ? void 0 : count3;
63672
64145
  }
63673
64146
  const last = at3 - count3 - 1;
63674
64147
  if (b < at3) return 0;
63675
64148
  if (a2 > last) return count3;
63676
64149
  return void 0;
63677
64150
  }
63678
- function areaDelta(area, sheet2, shift3) {
64151
+ function areaDelta(area, sheet2, shift4) {
63679
64152
  if (area.sheet !== sheet2) return 0;
63680
64153
  const { start, end } = area.range;
63681
- return shift3.axis === "row" ? intervalDelta(start.row, end.row, shift3) : intervalDelta(start.col, end.col, shift3);
64154
+ return shift4.axis === "row" ? intervalDelta(start.row, end.row, shift4) : intervalDelta(start.col, end.col, shift4);
63682
64155
  }
63683
64156
  function movedRange(range3, axis, delta) {
63684
64157
  if (delta === 0) return range3;
@@ -63690,10 +64163,10 @@ function movedRange(range3, axis, delta) {
63690
64163
  end: { row: range3.end.row, col: range3.end.col + delta }
63691
64164
  };
63692
64165
  }
63693
- function reachesEdit(areas, sheet2, shift3) {
64166
+ function reachesEdit(areas, sheet2, shift4) {
63694
64167
  for (const area of areas) {
63695
64168
  if (area.sheet !== sheet2) continue;
63696
- if ((shift3.axis === "row" ? area.range.end.row : area.range.end.col) >= shift3.at) return true;
64169
+ if ((shift4.axis === "row" ? area.range.end.row : area.range.end.col) >= shift4.at) return true;
63697
64170
  }
63698
64171
  return false;
63699
64172
  }
@@ -63742,8 +64215,8 @@ var EngineStructure = class extends EngineCore {
63742
64215
  * changed (cells moved, formulas rewritten). Spills on the sheet, array formulas the edit cuts
63743
64216
  * and anything unexpected fall back to a rebuild on the next recalculation.
63744
64217
  */
63745
- shiftCells(sheet2, shift3) {
63746
- if (!this.graphReady() || !this.shiftable(sheet2, shift3)) {
64218
+ shiftCells(sheet2, shift4) {
64219
+ if (!this.graphReady() || !this.shiftable(sheet2, shift4)) {
63747
64220
  this.invalidate();
63748
64221
  return;
63749
64222
  }
@@ -63754,15 +64227,15 @@ var EngineStructure = class extends EngineCore {
63754
64227
  if (own3) {
63755
64228
  const next = /* @__PURE__ */ new Map();
63756
64229
  for (const node4 of own3.values()) {
63757
- const pos = shift3.axis === "row" ? node4.row : node4.col;
63758
- const delta = intervalDelta(pos, pos, shift3);
64230
+ const pos = shift4.axis === "row" ? node4.row : node4.col;
64231
+ const delta = intervalDelta(pos, pos, shift4);
63759
64232
  if (delta === void 0) {
63760
64233
  this.dropNode(node4);
63761
64234
  continue;
63762
64235
  }
63763
64236
  if (delta !== 0) {
63764
64237
  moved.set(node4, delta);
63765
- if (shift3.axis === "row") node4.row += delta;
64238
+ if (shift4.axis === "row") node4.row += delta;
63766
64239
  else node4.col += delta;
63767
64240
  }
63768
64241
  next.set(cellKey(node4.row, node4.col), node4);
@@ -63771,7 +64244,7 @@ var EngineStructure = class extends EngineCore {
63771
64244
  }
63772
64245
  for (const map2 of this.nodes.values())
63773
64246
  for (const node4 of map2.values()) {
63774
- if (!this.shiftNode(node4, sheet2, shift3, moved.get(node4) ?? 0)) {
64247
+ if (!this.shiftNode(node4, sheet2, shift4, moved.get(node4) ?? 0)) {
63775
64248
  this.invalidate();
63776
64249
  return;
63777
64250
  }
@@ -63780,11 +64253,11 @@ var EngineStructure = class extends EngineCore {
63780
64253
  this.graphChanged();
63781
64254
  }
63782
64255
  /** No spill or stale spilled value on the sheet, and no array formula the edit cuts. */
63783
- shiftable(sheet2, shift3) {
64256
+ shiftable(sheet2, shift4) {
63784
64257
  for (const node4 of this.footprints) {
63785
64258
  if (node4.sheet !== sheet2) continue;
63786
64259
  if (node4.spill || node4.blockedSpill) return false;
63787
- if (node4.arrayRange && areaDelta({ sheet: sheet2, range: node4.arrayRange }, sheet2, shift3) === void 0)
64260
+ if (node4.arrayRange && areaDelta({ sheet: sheet2, range: node4.arrayRange }, sheet2, shift4) === void 0)
63788
64261
  return false;
63789
64262
  }
63790
64263
  const ws = this.workbook.sheets[sheet2];
@@ -63800,19 +64273,19 @@ var EngineStructure = class extends EngineCore {
63800
64273
  this.footprints.delete(node4);
63801
64274
  }
63802
64275
  /** Updates one formula for the edit; false when the graph cannot follow it. */
63803
- shiftNode(node4, sheet2, shift3, nodeDelta) {
64276
+ shiftNode(node4, sheet2, shift4, nodeDelta) {
63804
64277
  const cell2 = this.workbook.sheets[node4.sheet]?.rows.get(node4.row)?.get(node4.col);
63805
64278
  if (cell2?.formula === void 0) return false;
63806
64279
  if (node4.arrayRange) {
63807
- const delta = areaDelta({ sheet: node4.sheet, range: node4.arrayRange }, sheet2, shift3);
64280
+ const delta = areaDelta({ sheet: node4.sheet, range: node4.arrayRange }, sheet2, shift4);
63808
64281
  if (delta === void 0) return false;
63809
- node4.arrayRange = movedRange(node4.arrayRange, shift3.axis, delta);
64282
+ node4.arrayRange = movedRange(node4.arrayRange, shift4.axis, delta);
63810
64283
  if (!cell2.arrayRange || !sameRange(node4.arrayRange, normalizeRange(cell2.arrayRange)))
63811
64284
  return false;
63812
64285
  }
63813
64286
  const changed = cell2.formula !== node4.formula;
63814
64287
  const traits = node4.ast && astTraits(node4.ast);
63815
- const reached = reachesEdit(node4.deps, sheet2, shift3) || reachesEdit(node4.dynamicDeps, sheet2, shift3);
64288
+ const reached = reachesEdit(node4.deps, sheet2, shift4) || reachesEdit(node4.dynamicDeps, sheet2, shift4);
63816
64289
  if (!changed && !reached && nodeDelta === 0 && !traits?.descriptive && !traits?.opaque)
63817
64290
  return true;
63818
64291
  if (traits?.complex) {
@@ -63821,10 +64294,10 @@ var EngineStructure = class extends EngineCore {
63821
64294
  this.structuralSeeds.add(node4);
63822
64295
  return true;
63823
64296
  }
63824
- const pos = shift3.axis === "row" ? node4.row - nodeDelta : node4.col - nodeDelta;
64297
+ const pos = shift4.axis === "row" ? node4.row - nodeDelta : node4.col - nodeDelta;
63825
64298
  const moves = { seed: !!traits?.descriptive, moved: false, cut: false };
63826
- const deps = this.moveAreas(node4.deps, sheet2, shift3, pos, nodeDelta, moves);
63827
- const dynamicDeps = this.moveAreas(node4.dynamicDeps, sheet2, shift3, pos, nodeDelta, moves);
64299
+ const deps = this.moveAreas(node4.deps, sheet2, shift4, pos, nodeDelta, moves);
64300
+ const dynamicDeps = this.moveAreas(node4.dynamicDeps, sheet2, shift4, pos, nodeDelta, moves);
63828
64301
  const { cut, moved: anyMoved } = moves;
63829
64302
  let seed = moves.seed;
63830
64303
  if (cut || changed !== anyMoved) {
@@ -63848,20 +64321,20 @@ var EngineStructure = class extends EngineCore {
63848
64321
  * moved, one was cut (deleted, widened, pushed off the grid) and whether implicit intersection
63849
64322
  * with one can now pick another cell.
63850
64323
  */
63851
- moveAreas(list3, sheet2, shift3, pos, nodeDelta, moves) {
64324
+ moveAreas(list3, sheet2, shift4, pos, nodeDelta, moves) {
63852
64325
  let out;
63853
64326
  for (let i2 = 0; i2 < list3.length; i2++) {
63854
64327
  const area = list3[i2];
63855
- const delta = areaDelta(area, sheet2, shift3);
64328
+ const delta = areaDelta(area, sheet2, shift4);
63856
64329
  if (delta === void 0) {
63857
64330
  moves.cut = true;
63858
64331
  continue;
63859
64332
  }
63860
- if (intersectionMoves(area, delta, pos, nodeDelta, shift3.axis)) moves.seed = true;
64333
+ if (intersectionMoves(area, delta, pos, nodeDelta, shift4.axis)) moves.seed = true;
63861
64334
  if (delta === 0) continue;
63862
64335
  moves.moved = true;
63863
64336
  out ??= list3.slice();
63864
- out[i2] = { sheet: area.sheet, range: movedRange(area.range, shift3.axis, delta) };
64337
+ out[i2] = { sheet: area.sheet, range: movedRange(area.range, shift4.axis, delta) };
63865
64338
  }
63866
64339
  return out ?? list3;
63867
64340
  }
@@ -64410,9 +64883,9 @@ function needsArrayEvaluation(formula2) {
64410
64883
 
64411
64884
  // xlsx/edit/range-math.ts
64412
64885
  var axisMax = (axis) => axis === "row" ? MAX_ROW : MAX_COL;
64413
- function shiftSpan(start, end, shift3) {
64414
- const { at: at3, count: count3 } = shift3;
64415
- const max = axisMax(shift3.axis);
64886
+ function shiftSpan(start, end, shift4) {
64887
+ const { at: at3, count: count3 } = shift4;
64888
+ const max = axisMax(shift4.axis);
64416
64889
  if (count3 > 0) {
64417
64890
  if (start >= at3) {
64418
64891
  if (start + count3 > max) return void 0;
@@ -64428,35 +64901,35 @@ function shiftSpan(start, end, shift3) {
64428
64901
  const e = end >= max ? max : end < at3 ? end : end > last ? end - n : at3 - 1;
64429
64902
  return s > e ? void 0 : { start: s, end: e };
64430
64903
  }
64431
- function shiftIndex(index4, shift3) {
64432
- const { at: at3, count: count3 } = shift3;
64904
+ function shiftIndex(index4, shift4) {
64905
+ const { at: at3, count: count3 } = shift4;
64433
64906
  if (index4 < at3) return index4;
64434
- if (count3 > 0) return index4 + count3 > axisMax(shift3.axis) ? void 0 : index4 + count3;
64907
+ if (count3 > 0) return index4 + count3 > axisMax(shift4.axis) ? void 0 : index4 + count3;
64435
64908
  return index4 < at3 - count3 ? void 0 : index4 + count3;
64436
64909
  }
64437
- function shiftIndexClamped(index4, shift3) {
64438
- const moved = shiftIndex(index4, shift3);
64910
+ function shiftIndexClamped(index4, shift4) {
64911
+ const moved = shiftIndex(index4, shift4);
64439
64912
  if (moved !== void 0) return moved;
64440
- return shift3.count > 0 ? axisMax(shift3.axis) : shift3.at;
64913
+ return shift4.count > 0 ? axisMax(shift4.axis) : shift4.at;
64441
64914
  }
64442
- function shiftRange(range3, shift3) {
64443
- if (shift3.axis === "row") {
64444
- const span5 = shiftSpan(range3.start.row, range3.end.row, shift3);
64915
+ function shiftRange(range3, shift4) {
64916
+ if (shift4.axis === "row") {
64917
+ const span5 = shiftSpan(range3.start.row, range3.end.row, shift4);
64445
64918
  return span5 && {
64446
64919
  start: { row: span5.start, col: range3.start.col },
64447
64920
  end: { row: span5.end, col: range3.end.col }
64448
64921
  };
64449
64922
  }
64450
- const span4 = shiftSpan(range3.start.col, range3.end.col, shift3);
64923
+ const span4 = shiftSpan(range3.start.col, range3.end.col, shift4);
64451
64924
  return span4 && {
64452
64925
  start: { row: range3.start.row, col: span4.start },
64453
64926
  end: { row: range3.end.row, col: span4.end }
64454
64927
  };
64455
64928
  }
64456
- function shiftRangeInBand(range3, shift3, lo, hi) {
64457
- const other = shift3.axis === "row" ? "col" : "row";
64929
+ function shiftRangeInBand(range3, shift4, lo, hi) {
64930
+ const other = shift4.axis === "row" ? "col" : "row";
64458
64931
  if (range3.end[other] < lo || range3.start[other] > hi) return range3;
64459
- if (range3.start[other] >= lo && range3.end[other] <= hi) return shiftRange(range3, shift3);
64932
+ if (range3.start[other] >= lo && range3.end[other] <= hi) return shiftRange(range3, shift4);
64460
64933
  return range3;
64461
64934
  }
64462
64935
  function subtractRange(a2, b) {
@@ -64487,7 +64960,7 @@ function pointsAt(token2, formulaSheet, sheet2) {
64487
64960
  if (!prefix3) return formulaSheet.toLowerCase() === sheet2.toLowerCase();
64488
64961
  return prefix3.book === void 0 && prefix3.sheet2 === void 0 && prefix3.sheet.toLowerCase() === sheet2.toLowerCase();
64489
64962
  }
64490
- function shiftFormulaInBand(formula2, formulaSheet, sheet2, shift3, band2) {
64963
+ function shiftFormulaInBand(formula2, formulaSheet, sheet2, shift4, band2) {
64491
64964
  let tokens3;
64492
64965
  try {
64493
64966
  tokens3 = tokenize(formula2);
@@ -64508,7 +64981,7 @@ function shiftFormulaInBand(formula2, formulaSheet, sheet2, shift3, band2) {
64508
64981
  },
64509
64982
  end: { row: Math.max(ref.start.row, ref.end.row), col: Math.max(ref.start.col, ref.end.col) }
64510
64983
  };
64511
- const moved = shiftRangeInBand(range3, shift3, band2.lo, band2.hi);
64984
+ const moved = shiftRangeInBand(range3, shift4, band2.lo, band2.hi);
64512
64985
  if (moved && sameRange2(moved, range3)) continue;
64513
64986
  const prefix3 = token2.prefix?.text ?? "";
64514
64987
  if (!moved) {
@@ -64546,15 +65019,15 @@ function carriedRefEdits(sourceSheets, currentSheets, shiftsOf = () => []) {
64546
65019
  edits2.deleted.push(source3.name);
64547
65020
  continue;
64548
65021
  }
64549
- for (const shift3 of shiftsOf(current)) edits2.shifts.push({ sheet: source3.name, shift: shift3 });
65022
+ for (const shift4 of shiftsOf(current)) edits2.shifts.push({ sheet: source3.name, shift: shift4 });
64550
65023
  if (current.name !== source3.name) edits2.renamed.push([source3.name, current.name]);
64551
65024
  }
64552
65025
  return edits2;
64553
65026
  }
64554
65027
  var hasCarriedRefEdits = (edits2) => edits2.shifts.length > 0 || edits2.deleted.length > 0 || edits2.renamed.length > 0;
64555
- function shiftOne(formula2, formulaSheet, sheet2, shift3) {
64556
- if (shift3.band) return shiftFormulaInBand(formula2, formulaSheet, sheet2, shift3, shift3.band);
64557
- const spec2 = { sheet: sheet2, axis: shift3.axis, at: shift3.at, count: shift3.count };
65028
+ function shiftOne(formula2, formulaSheet, sheet2, shift4) {
65029
+ if (shift4.band) return shiftFormulaInBand(formula2, formulaSheet, sheet2, shift4, shift4.band);
65030
+ const spec2 = { sheet: sheet2, axis: shift4.axis, at: shift4.at, count: shift4.count };
64558
65031
  return shiftFormula(formula2, formulaSheet, spec2);
64559
65032
  }
64560
65033
  function renameAll(formula2, renamed, taken) {
@@ -64577,7 +65050,7 @@ var takenNames = (edits2) => new Set(
64577
65050
  );
64578
65051
  function patchCarriedFormula(formula2, formulaSheet, edits2) {
64579
65052
  let out = formula2;
64580
- for (const { sheet: sheet2, shift: shift3 } of edits2.shifts) out = shiftOne(out, formulaSheet, sheet2, shift3);
65053
+ for (const { sheet: sheet2, shift: shift4 } of edits2.shifts) out = shiftOne(out, formulaSheet, sheet2, shift4);
64581
65054
  for (const sheet2 of edits2.deleted) out = deleteSheetInFormula(out, sheet2);
64582
65055
  return renameAll(out, edits2.renamed, takenNames(edits2));
64583
65056
  }
@@ -68321,8 +68794,8 @@ async function saveXlsx(workbook) {
68321
68794
 
68322
68795
  // xlsx/edit/shift-preserved.ts
68323
68796
  var XM3 = "http://schemas.microsoft.com/office/excel/2006/main";
68324
- function hasPreservedOverflow(sheet2, shift3, clipped, banded) {
68325
- const keys = banded ? ["extLst"] : [shift3.axis === "row" ? "rowBreaks" : "colBreaks", "extLst"];
68797
+ function hasPreservedOverflow(sheet2, shift4, clipped, banded) {
68798
+ const keys = banded ? ["extLst"] : [shift4.axis === "row" ? "rowBreaks" : "colBreaks", "extLst"];
68326
68799
  for (const key2 of keys)
68327
68800
  for (const xml of sheet2.preserved.get(key2) ?? []) {
68328
68801
  if (!xml.includes(key2 === "extLst" ? "sqref" : "brk")) continue;
@@ -68338,7 +68811,7 @@ function hasPreservedOverflow(sheet2, shift3, clipped, banded) {
68338
68811
  ))
68339
68812
  return true;
68340
68813
  } else if (elements(root).some(
68341
- (node4) => node4.localName === "brk" && shiftIndex(Number(node4.getAttribute("id") ?? "0"), shift3) === void 0
68814
+ (node4) => node4.localName === "brk" && shiftIndex(Number(node4.getAttribute("id") ?? "0"), shift4) === void 0
68342
68815
  ))
68343
68816
  return true;
68344
68817
  }
@@ -68370,11 +68843,11 @@ function editEntries(sheet2, key2, edit2, quick) {
68370
68843
  if (next.length) sheet2.preserved.set(key2, next);
68371
68844
  else sheet2.preserved.delete(key2);
68372
68845
  }
68373
- function shiftBreaks(root, shift3) {
68846
+ function shiftBreaks(root, shift4) {
68374
68847
  let changed = false;
68375
68848
  for (const brk of elements(root).filter((e) => e.localName === "brk")) {
68376
68849
  const id4 = Number(brk.getAttribute("id") ?? "0");
68377
- const moved = shiftIndex(id4, shift3);
68850
+ const moved = shiftIndex(id4, shift4);
68378
68851
  if (moved === id4) continue;
68379
68852
  changed = true;
68380
68853
  if (moved === void 0 || moved === 0) root.removeChild(brk);
@@ -68419,12 +68892,12 @@ function shiftSqrefs(root, moveRange) {
68419
68892
  list3.setAttribute("count", String(elements(list3).length));
68420
68893
  return elements(root).length > 0 ? "changed" : "drop";
68421
68894
  }
68422
- function shiftPreservedXml(sheet2, shift3, moveRange, banded) {
68895
+ function shiftPreservedXml(sheet2, shift4, moveRange, banded) {
68423
68896
  if (!banded)
68424
68897
  editEntries(
68425
68898
  sheet2,
68426
- shift3.axis === "row" ? "rowBreaks" : "colBreaks",
68427
- (root) => shiftBreaks(root, shift3),
68899
+ shift4.axis === "row" ? "rowBreaks" : "colBreaks",
68900
+ (root) => shiftBreaks(root, shift4),
68428
68901
  (xml) => xml.includes("brk")
68429
68902
  );
68430
68903
  editEntries(
@@ -69579,25 +70052,25 @@ function setBorders(ctx, s, range3, preset, edge2 = { style: "thin" }) {
69579
70052
  }
69580
70053
 
69581
70054
  // xlsx/edit/insert-guard.ts
69582
- function assertInsertFits(sheet2, shift3, band2) {
70055
+ function assertInsertFits(sheet2, shift4, band2) {
69583
70056
  for (const pivot of sheet2.pivotTables ?? []) {
69584
- const start = pivot.location.start[shift3.axis];
69585
- const end = pivot.location.end[shift3.axis];
69586
- const other2 = shift3.axis === "row" ? "col" : "row";
70057
+ const start = pivot.location.start[shift4.axis];
70058
+ const end = pivot.location.end[shift4.axis];
70059
+ const other2 = shift4.axis === "row" ? "col" : "row";
69587
70060
  if (band2 && (band2.hi < pivot.location.start[other2] || band2.lo > pivot.location.end[other2]))
69588
70061
  continue;
69589
70062
  const partial2 = band2 && (band2.lo > pivot.location.start[other2] || band2.hi < pivot.location.end[other2]);
69590
- const overlap = shift3.count > 0 ? shift3.at > start && shift3.at <= end : shift3.at <= end && shift3.at - shift3.count > start;
69591
- if (overlap || partial2 && shift3.at <= end)
70063
+ const overlap = shift4.count > 0 ? shift4.at > start && shift4.at <= end : shift4.at <= end && shift4.at - shift4.count > start;
70064
+ if (overlap || partial2 && shift4.at <= end)
69592
70065
  throw new Error("Cannot move or remove part of a PivotTable. Delete the PivotTable first.");
69593
70066
  }
69594
- if (shift3.count <= 0) return;
69595
- const max = shift3.axis === "row" ? MAX_ROW : MAX_COL;
69596
- if (shift3.at + shift3.count > max + 1)
70067
+ if (shift4.count <= 0) return;
70068
+ const max = shift4.axis === "row" ? MAX_ROW : MAX_COL;
70069
+ if (shift4.at + shift4.count > max + 1)
69597
70070
  throw new RangeError("The insert area extends beyond the sheet.");
69598
- const first3 = max - shift3.count + 1;
69599
- const lost = shift3.axis === "row" ? cellRange(first3, band2?.lo ?? 0, MAX_ROW, band2?.hi ?? MAX_COL) : cellRange(band2?.lo ?? 0, first3, band2?.hi ?? MAX_ROW, MAX_COL);
69600
- const other = shift3.axis === "row" ? "col" : "row";
70071
+ const first3 = max - shift4.count + 1;
70072
+ const lost = shift4.axis === "row" ? cellRange(first3, band2?.lo ?? 0, MAX_ROW, band2?.hi ?? MAX_COL) : cellRange(band2?.lo ?? 0, first3, band2?.hi ?? MAX_ROW, MAX_COL);
70073
+ const other = shift4.axis === "row" ? "col" : "row";
69601
70074
  const clipped = (range3) => (!band2 || range3.start[other] >= band2.lo && range3.end[other] <= band2.hi) && rangesIntersect(range3, lost);
69602
70075
  const fail4 = () => {
69603
70076
  throw new Error("Cannot insert cells: non-empty cells would be pushed off the sheet.");
@@ -69608,14 +70081,14 @@ function assertInsertFits(sheet2, shift3, band2) {
69608
70081
  if (col >= lost.start.col && col <= lost.end.col && (!isEmptyCell(cell2) || cell2.cellMetadata !== void 0 || cell2.valueMetadata !== void 0))
69609
70082
  fail4();
69610
70083
  }
69611
- if (sheet2.comments.some((c2) => rangesIntersect(cellRange(c2.address.row, c2.address.col), lost)) || sheet2.hyperlinks.some((h2) => rangesIntersect(h2.range, lost)) || sheet2.merges.some((m) => rangesIntersect(m, lost)) || sheet2.tables.some((t) => rangesIntersect(t.range, lost)) || sheet2.dataValidations.some((rule2) => rule2.ranges.some(clipped)) || sheet2.conditionalFormats.some((format8) => format8.ranges.some(clipped)) || sheet2.autoFilter !== void 0 && clipped(sheet2.autoFilter.range) || sheet2.pageSetup?.printArea !== void 0 && clipped(sheet2.pageSetup.printArea) || hasPreservedOverflow(sheet2, shift3, clipped, !!band2))
70084
+ if (sheet2.comments.some((c2) => rangesIntersect(cellRange(c2.address.row, c2.address.col), lost)) || sheet2.hyperlinks.some((h2) => rangesIntersect(h2.range, lost)) || sheet2.merges.some((m) => rangesIntersect(m, lost)) || sheet2.tables.some((t) => rangesIntersect(t.range, lost)) || sheet2.dataValidations.some((rule2) => rule2.ranges.some(clipped)) || sheet2.conditionalFormats.some((format8) => format8.ranges.some(clipped)) || sheet2.autoFilter !== void 0 && clipped(sheet2.autoFilter.range) || sheet2.pageSetup?.printArea !== void 0 && clipped(sheet2.pageSetup.printArea) || hasPreservedOverflow(sheet2, shift4, clipped, !!band2))
69612
70085
  fail4();
69613
70086
  for (const { anchor: anchor2 } of sheet2.drawings) {
69614
70087
  if (band2 && (anchor2.from[other] < band2.lo || anchor2.from[other] > band2.hi)) continue;
69615
- if (anchor2.from[shift3.axis] >= first3 || anchor2.to && anchor2.to[shift3.axis] >= first3) fail4();
70088
+ if (anchor2.from[shift4.axis] >= first3 || anchor2.to && anchor2.to[shift4.axis] >= first3) fail4();
69616
70089
  }
69617
70090
  if (band2) return;
69618
- if (shift3.axis === "row") {
70091
+ if (shift4.axis === "row") {
69619
70092
  for (const [row3, info] of sheet2.rowInfo) if (row3 >= first3 && Object.keys(info).length) fail4();
69620
70093
  } else {
69621
70094
  if (normalizeColumns(sheet2.columns).some((c2) => c2.min >= first3)) fail4();
@@ -69623,11 +70096,11 @@ function assertInsertFits(sheet2, shift3, band2) {
69623
70096
  }
69624
70097
 
69625
70098
  // xlsx/edit/shift-rule-anchors.ts
69626
- function rebaseRulesForDeletion(sheet2, shift3, band2) {
69627
- if (shift3.count >= 0) return;
69628
- const last = shift3.at - shift3.count - 1;
69629
- const removed2 = shift3.axis === "row" ? cellRange(shift3.at, band2?.lo ?? 0, last, band2?.hi ?? MAX_COL) : cellRange(band2?.lo ?? 0, shift3.at, band2?.hi ?? MAX_ROW, last);
69630
- const other = shift3.axis === "row" ? "col" : "row";
70099
+ function rebaseRulesForDeletion(sheet2, shift4, band2) {
70100
+ if (shift4.count >= 0) return;
70101
+ const last = shift4.at - shift4.count - 1;
70102
+ const removed2 = shift4.axis === "row" ? cellRange(shift4.at, band2?.lo ?? 0, last, band2?.hi ?? MAX_COL) : cellRange(band2?.lo ?? 0, shift4.at, band2?.hi ?? MAX_ROW, last);
70103
+ const other = shift4.axis === "row" ? "col" : "row";
69631
70104
  const surviving = (ranges) => ranges.flatMap(
69632
70105
  (range3) => band2 && (range3.start[other] < band2.lo || range3.end[other] > band2.hi) ? [range3] : subtractRange(range3, removed2)
69633
70106
  );
@@ -69883,10 +70356,10 @@ function shiftScenarios(sheet2, move) {
69883
70356
  }
69884
70357
 
69885
70358
  // xlsx/edit/shift-sheet.ts
69886
- function shiftSheetContent(sheet2, shift3, band2) {
69887
- assertInsertFits(sheet2, shift3, band2);
69888
- const moveRange = (range3) => band2 ? shiftRangeInBand(range3, shift3, band2.lo, band2.hi) : shiftRange(range3, shift3);
69889
- shiftCells(sheet2, shift3, band2, moveRange);
70359
+ function shiftSheetContent(sheet2, shift4, band2) {
70360
+ assertInsertFits(sheet2, shift4, band2);
70361
+ const moveRange = (range3) => band2 ? shiftRangeInBand(range3, shift4, band2.lo, band2.hi) : shiftRange(range3, shift4);
70362
+ shiftCells(sheet2, shift4, band2, moveRange);
69890
70363
  sheet2.merges = sheet2.merges.map(moveRange).filter((m) => !!m && (m.start.row !== m.end.row || m.start.col !== m.end.col));
69891
70364
  sheet2.conditionalFormats = sheet2.conditionalFormats.map((cf) => ({ ...cf, ranges: cf.ranges.map(moveRange).filter((r) => !!r) })).filter((cf) => cf.ranges.length > 0);
69892
70365
  sheet2.dataValidations = sheet2.dataValidations.map((dv) => ({ ...dv, ranges: dv.ranges.map(moveRange).filter((r) => !!r) })).filter((dv) => dv.ranges.length > 0);
@@ -69898,7 +70371,7 @@ function shiftSheetContent(sheet2, shift3, band2) {
69898
70371
  const range3 = moveRange({ start: c2.address, end: c2.address });
69899
70372
  return range3 ? [{ ...c2, address: range3.start }] : [];
69900
70373
  });
69901
- sheet2.tables = sheet2.tables.flatMap((t) => shiftTable2(sheet2, t, shift3, moveRange));
70374
+ sheet2.tables = sheet2.tables.flatMap((t) => shiftTable2(sheet2, t, shift4, moveRange));
69902
70375
  shiftDataTables(sheet2, moveRange);
69903
70376
  shiftScenarios(sheet2, moveRange);
69904
70377
  for (const pivot of sheet2.pivotTables ?? []) {
@@ -69908,8 +70381,8 @@ function shiftSheetContent(sheet2, shift3, band2) {
69908
70381
  pivot.dirty = true;
69909
70382
  }
69910
70383
  }
69911
- for (const drawing of sheet2.drawings) shiftAnchor(drawing.anchor, shift3, band2);
69912
- if (!band2) shiftAxisFormats(sheet2, shift3);
70384
+ for (const drawing of sheet2.drawings) shiftAnchor(drawing.anchor, shift4, band2);
70385
+ if (!band2) shiftAxisFormats(sheet2, shift4);
69913
70386
  if (sheet2.autoFilter) {
69914
70387
  const old = sheet2.autoFilter.range;
69915
70388
  const range3 = moveRange(old);
@@ -69918,39 +70391,39 @@ function shiftSheetContent(sheet2, shift3, band2) {
69918
70391
  clearFilteredRows(sheet2);
69919
70392
  } else {
69920
70393
  const filter2 = { ...sheet2.autoFilter, range: range3 };
69921
- if (shift3.axis === "col" && filter2.columns)
70394
+ if (shift4.axis === "col" && filter2.columns)
69922
70395
  filter2.columns = filter2.columns.flatMap((fc) => {
69923
- const abs2 = shiftIndex(old.start.col + fc.offset, shift3);
70396
+ const abs2 = shiftIndex(old.start.col + fc.offset, shift4);
69924
70397
  return abs2 === void 0 ? [] : [{ ...fc, offset: abs2 - range3.start.col }];
69925
70398
  });
69926
70399
  sheet2.autoFilter = filter2;
69927
70400
  }
69928
70401
  }
69929
- if (!band2) shiftFreeze(sheet2, shift3);
70402
+ if (!band2) shiftFreeze(sheet2, shift4);
69930
70403
  const printArea = sheet2.pageSetup?.printArea;
69931
70404
  if (sheet2.pageSetup && printArea) {
69932
70405
  const moved = moveRange(printArea);
69933
70406
  if (moved) sheet2.pageSetup.printArea = moved;
69934
70407
  else delete sheet2.pageSetup.printArea;
69935
70408
  }
69936
- shiftPreservedXml(sheet2, shift3, moveRange, !!band2);
70409
+ shiftPreservedXml(sheet2, shift4, moveRange, !!band2);
69937
70410
  }
69938
- function shiftCells(sheet2, shift3, band2, moveRange) {
70411
+ function shiftCells(sheet2, shift4, band2, moveRange) {
69939
70412
  const old = sheet2.rows;
69940
70413
  sheet2.rows = /* @__PURE__ */ new Map();
69941
70414
  for (const [row3, cells3] of old)
69942
70415
  for (const [col, cell2] of cells3) {
69943
- const along = shift3.axis === "row" ? row3 : col;
69944
- const across = shift3.axis === "row" ? col : row3;
70416
+ const along = shift4.axis === "row" ? row3 : col;
70417
+ const across = shift4.axis === "row" ? col : row3;
69945
70418
  const inBand = !band2 || across >= band2.lo && across <= band2.hi;
69946
- const moved = inBand ? shiftIndex(along, shift3) : along;
70419
+ const moved = inBand ? shiftIndex(along, shift4) : along;
69947
70420
  if (moved === void 0) continue;
69948
70421
  if (cell2.arrayRange) {
69949
70422
  const range3 = moveRange(cell2.arrayRange);
69950
70423
  if (range3) cell2.arrayRange = range3;
69951
70424
  else delete cell2.arrayRange;
69952
70425
  }
69953
- if (shift3.axis === "row") putCell(sheet2, moved, col, cell2);
70426
+ if (shift4.axis === "row") putCell(sheet2, moved, col, cell2);
69954
70427
  else putCell(sheet2, row3, moved, cell2);
69955
70428
  }
69956
70429
  }
@@ -69958,73 +70431,73 @@ function uniqueColumnName(columns2) {
69958
70431
  const taken = new Set(columns2.map((c2) => c2.name.toLowerCase()));
69959
70432
  for (let n = 1; ; n++) if (!taken.has(`column${n}`)) return `Column${n}`;
69960
70433
  }
69961
- function shiftTable2(sheet2, table4, shift3, moveRange) {
70434
+ function shiftTable2(sheet2, table4, shift4, moveRange) {
69962
70435
  const old = table4.range;
69963
70436
  const range3 = moveRange(old);
69964
70437
  if (!range3) return [];
69965
70438
  const next = { ...table4, range: range3, columns: [...table4.columns] };
69966
70439
  const widened = range3.end.col - range3.start.col !== old.end.col - old.start.col;
69967
- if (shift3.axis === "col" && widened) {
69968
- if (shift3.count > 0) {
69969
- const offset2 = shift3.at - old.start.col;
69970
- for (let i2 = 0; i2 < shift3.count; i2++) {
70440
+ if (shift4.axis === "col" && widened) {
70441
+ if (shift4.count > 0) {
70442
+ const offset2 = shift4.at - old.start.col;
70443
+ for (let i2 = 0; i2 < shift4.count; i2++) {
69971
70444
  const column3 = { name: uniqueColumnName(next.columns) };
69972
70445
  next.columns.splice(offset2 + i2, 0, column3);
69973
70446
  if (next.headerRow) {
69974
70447
  const cell2 = { value: column3.name };
69975
- putCell(sheet2, range3.start.row, shift3.at + i2, cell2);
70448
+ putCell(sheet2, range3.start.row, shift4.at + i2, cell2);
69976
70449
  }
69977
70450
  }
69978
70451
  } else {
69979
70452
  next.columns = next.columns.filter(
69980
- (_c, i2) => shiftIndex(old.start.col + i2, shift3) !== void 0
70453
+ (_c, i2) => shiftIndex(old.start.col + i2, shift4) !== void 0
69981
70454
  );
69982
70455
  }
69983
70456
  }
69984
70457
  return [next];
69985
70458
  }
69986
- function shiftAnchor(anchor2, shift3, band2) {
69987
- const key2 = shift3.axis === "row" ? "row" : "col";
69988
- const other = shift3.axis === "row" ? "col" : "row";
70459
+ function shiftAnchor(anchor2, shift4, band2) {
70460
+ const key2 = shift4.axis === "row" ? "row" : "col";
70461
+ const other = shift4.axis === "row" ? "col" : "row";
69989
70462
  if (band2 && (anchor2.from[other] < band2.lo || anchor2.from[other] > band2.hi)) return;
69990
70463
  const from = anchor2.from[key2];
69991
- const movedFrom = shiftIndexClamped(from, shift3);
69992
- if (shiftIndex(from, shift3) === void 0)
70464
+ const movedFrom = shiftIndexClamped(from, shift4);
70465
+ if (shiftIndex(from, shift4) === void 0)
69993
70466
  anchor2.from[key2 === "row" ? "rowOffset" : "colOffset"] = 0;
69994
70467
  anchor2.from[key2] = movedFrom;
69995
70468
  if (anchor2.to) {
69996
70469
  const to = anchor2.to[key2];
69997
- const moved = shiftIndex(to, shift3);
70470
+ const moved = shiftIndex(to, shift4);
69998
70471
  if (moved === void 0) {
69999
- anchor2.to[key2] = Math.max(movedFrom, shiftIndexClamped(to, shift3));
70472
+ anchor2.to[key2] = Math.max(movedFrom, shiftIndexClamped(to, shift4));
70000
70473
  anchor2.to[key2 === "row" ? "rowOffset" : "colOffset"] = 0;
70001
70474
  } else anchor2.to[key2] = moved;
70002
70475
  }
70003
70476
  }
70004
- function shiftAxisFormats(sheet2, shift3) {
70005
- if (shift3.axis === "row") {
70477
+ function shiftAxisFormats(sheet2, shift4) {
70478
+ if (shift4.axis === "row") {
70006
70479
  const old = sheet2.rowInfo;
70007
70480
  sheet2.rowInfo = /* @__PURE__ */ new Map();
70008
70481
  for (const [row3, info] of old) {
70009
- const moved = shiftIndex(row3, shift3);
70482
+ const moved = shiftIndex(row3, shift4);
70010
70483
  if (moved !== void 0) sheet2.rowInfo.set(moved, info);
70011
70484
  }
70012
70485
  return;
70013
70486
  }
70014
70487
  sheet2.columns = normalizeColumns(
70015
70488
  sheet2.columns.flatMap((info) => {
70016
- const span4 = shiftSpan(info.min, info.max, shift3);
70489
+ const span4 = shiftSpan(info.min, info.max, shift4);
70017
70490
  return span4 ? [{ ...info, min: span4.start, max: span4.end }] : [];
70018
70491
  })
70019
70492
  );
70020
70493
  }
70021
- function shiftFreeze(sheet2, shift3) {
70494
+ function shiftFreeze(sheet2, shift4) {
70022
70495
  const freeze = sheet2.view.freeze;
70023
70496
  if (!freeze) return;
70024
- const key2 = shift3.axis === "row" ? "rows" : "cols";
70497
+ const key2 = shift4.axis === "row" ? "rows" : "cols";
70025
70498
  const frozen = freeze[key2];
70026
- if (shift3.at >= frozen) return;
70027
- const next = shift3.count > 0 ? frozen + shift3.count : frozen - Math.min(-shift3.count, frozen - shift3.at);
70499
+ if (shift4.at >= frozen) return;
70500
+ const next = shift4.count > 0 ? frozen + shift4.count : frozen - Math.min(-shift4.count, frozen - shift4.at);
70028
70501
  sheet2.view.freeze = { ...freeze, [key2]: next };
70029
70502
  }
70030
70503
 
@@ -70034,15 +70507,15 @@ function checkSpan(axis, at3, count3) {
70034
70507
  if (!Number.isInteger(at3) || !Number.isInteger(count3) || at3 < 0 || at3 > max || count3 < 1 || at3 + count3 > max + 1)
70035
70508
  throw new RangeError(`Invalid ${axis} span ${at3} + ${count3}`);
70036
70509
  }
70037
- function applyAxisShift(ctx, sheet2, shift3) {
70038
- assertInsertFits(sheet2, shift3);
70039
- rebaseRulesForDeletion(sheet2, shift3);
70040
- const spec2 = { sheet: sheet2.name, axis: shift3.axis, at: shift3.at, count: shift3.count };
70510
+ function applyAxisShift(ctx, sheet2, shift4) {
70511
+ assertInsertFits(sheet2, shift4);
70512
+ rebaseRulesForDeletion(sheet2, shift4);
70513
+ const spec2 = { sheet: sheet2.name, axis: shift4.axis, at: shift4.at, count: shift4.count };
70041
70514
  rewriteFormulas(
70042
70515
  ctx.workbook,
70043
70516
  (formula2, formulaSheet) => shiftFormula(formula2, formulaSheet, spec2)
70044
70517
  );
70045
- shiftSheetContent(sheet2, shift3);
70518
+ shiftSheetContent(sheet2, shift4);
70046
70519
  }
70047
70520
  function inheritFormats(sheet2, axis, at3, count3) {
70048
70521
  if (at3 === 0) return;
@@ -70068,17 +70541,17 @@ function shiftAxis(ctx, s, axis, at3, count3, insert3) {
70068
70541
  checkSpan(axis, at3, count3);
70069
70542
  const sheet2 = sheetAt(ctx.workbook, s);
70070
70543
  const noun = axis === "row" ? count3 === 1 ? "row" : "rows" : count3 === 1 ? "column" : "columns";
70071
- const shift3 = { axis, at: at3, count: insert3 ? count3 : -count3 };
70072
- assertInsertFits(sheet2, shift3);
70544
+ const shift4 = { axis, at: at3, count: insert3 ? count3 : -count3 };
70545
+ assertInsertFits(sheet2, shift4);
70073
70546
  const info = { sheet: s, structural: true };
70074
- if (!sheet2.autoFilter || shiftRange(sheet2.autoFilter.range, shift3))
70075
- info.calc = { kind: "shift", sheet: s, shift: shift3 };
70547
+ if (!sheet2.autoFilter || shiftRange(sheet2.autoFilter.range, shift4))
70548
+ info.calc = { kind: "shift", sheet: s, shift: shift4 };
70076
70549
  ctx.run(
70077
70550
  `${insert3 ? "Insert" : "Delete"} ${noun}`,
70078
70551
  "structure",
70079
- [{ kind: "shift", sheet: s, shift: shift3 }],
70552
+ [{ kind: "shift", sheet: s, shift: shift4 }],
70080
70553
  () => {
70081
- applyAxisShift(ctx, sheet2, shift3);
70554
+ applyAxisShift(ctx, sheet2, shift4);
70082
70555
  if (insert3) inheritFormats(sheet2, axis, at3, count3);
70083
70556
  },
70084
70557
  info
@@ -70090,9 +70563,9 @@ var insertColumns = (ctx, s, at3, count3) => shiftAxis(ctx, s, "col", at3, count
70090
70563
  var deleteColumns = (ctx, s, at3, count3) => shiftAxis(ctx, s, "col", at3, count3, false);
70091
70564
 
70092
70565
  // xlsx/edit/cell-shift.ts
70093
- function assertBandIntact(sheet2, shift3, band2) {
70094
- const zone = shift3.axis === "row" ? cellRange(shift3.at, band2.lo, MAX_ROW, band2.hi) : cellRange(band2.lo, shift3.at, band2.hi, MAX_COL);
70095
- const other = shift3.axis === "row" ? "col" : "row";
70566
+ function assertBandIntact(sheet2, shift4, band2) {
70567
+ const zone = shift4.axis === "row" ? cellRange(shift4.at, band2.lo, MAX_ROW, band2.hi) : cellRange(band2.lo, shift4.at, band2.hi, MAX_COL);
70568
+ const other = shift4.axis === "row" ? "col" : "row";
70096
70569
  const torn = (r) => rangesIntersect(r, zone) && (r.start[other] < band2.lo || r.end[other] > band2.hi);
70097
70570
  if (sheet2.merges.some(torn))
70098
70571
  throw new Error("Cannot shift cells: a merged range would be split.");
@@ -70105,25 +70578,25 @@ function shiftBand(ctx, s, range3, direction) {
70105
70578
  const vertical2 = direction === "down" || direction === "up";
70106
70579
  const insert3 = direction === "down" || direction === "right";
70107
70580
  const size3 = vertical2 ? r.end.row - r.start.row + 1 : r.end.col - r.start.col + 1;
70108
- const shift3 = {
70581
+ const shift4 = {
70109
70582
  axis: vertical2 ? "row" : "col",
70110
70583
  at: vertical2 ? r.start.row : r.start.col,
70111
70584
  count: insert3 ? size3 : -size3
70112
70585
  };
70113
70586
  const band2 = vertical2 ? { lo: r.start.col, hi: r.end.col } : { lo: r.start.row, hi: r.end.row };
70114
- assertBandIntact(sheet2, shift3, band2);
70115
- assertInsertFits(sheet2, shift3, band2);
70587
+ assertBandIntact(sheet2, shift4, band2);
70588
+ assertInsertFits(sheet2, shift4, band2);
70116
70589
  ctx.run(
70117
70590
  `${insert3 ? "Insert" : "Delete"} cells`,
70118
70591
  "structure",
70119
- [{ kind: "shift", sheet: s, shift: shift3, band: band2 }],
70592
+ [{ kind: "shift", sheet: s, shift: shift4, band: band2 }],
70120
70593
  () => {
70121
- rebaseRulesForDeletion(sheet2, shift3, band2);
70594
+ rebaseRulesForDeletion(sheet2, shift4, band2);
70122
70595
  rewriteFormulas(
70123
70596
  ctx.workbook,
70124
- (formula2, formulaSheet) => shiftFormulaInBand(formula2, formulaSheet, sheet2.name, shift3, band2)
70597
+ (formula2, formulaSheet) => shiftFormulaInBand(formula2, formulaSheet, sheet2.name, shift4, band2)
70125
70598
  );
70126
- shiftSheetContent(sheet2, shift3, band2);
70599
+ shiftSheetContent(sheet2, shift4, band2);
70127
70600
  },
70128
70601
  { sheet: s, ranges: [r], structural: true }
70129
70602
  );
@@ -71651,14 +72124,14 @@ function restoreRefs(workbook, data) {
71651
72124
  }
71652
72125
  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;
71653
72126
  var sameEntry = (a2, b) => a2.formula === b.formula && sameRange3(a2.arrayRange, b.arrayRange);
71654
- function movePosition(spec2, shift3, s, row3, col) {
71655
- if (!spec2 || !shift3 || s !== spec2.sheet) return [row3, col];
71656
- const along = shift3.axis === "row" ? row3 : col;
71657
- const across = shift3.axis === "row" ? col : row3;
72127
+ function movePosition(spec2, shift4, s, row3, col) {
72128
+ if (!spec2 || !shift4 || s !== spec2.sheet) return [row3, col];
72129
+ const along = shift4.axis === "row" ? row3 : col;
72130
+ const across = shift4.axis === "row" ? col : row3;
71658
72131
  if (spec2.band && (across < spec2.band.lo || across > spec2.band.hi)) return [row3, col];
71659
- const moved = shiftIndex(along, shift3);
72132
+ const moved = shiftIndex(along, shift4);
71660
72133
  if (moved === void 0) return void 0;
71661
- return shift3.axis === "row" ? [moved, col] : [row3, moved];
72134
+ return shift4.axis === "row" ? [moved, col] : [row3, moved];
71662
72135
  }
71663
72136
  function diffRefs(workbook, before, spec2) {
71664
72137
  const keptBefore = [];
@@ -71679,37 +72152,37 @@ function diffRefs(workbook, before, spec2) {
71679
72152
  before.formulas = keptBefore;
71680
72153
  return keptAfter;
71681
72154
  }
71682
- function moveCellsRaw(sheet2, shift3, band2) {
72155
+ function moveCellsRaw(sheet2, shift4, band2) {
71683
72156
  const old = sheet2.rows;
71684
72157
  sheet2.rows = /* @__PURE__ */ new Map();
71685
- if (shift3.axis === "row" && !band2) {
72158
+ if (shift4.axis === "row" && !band2) {
71686
72159
  for (const [row3, cells3] of old) {
71687
- const moved = shiftIndex(row3, shift3);
72160
+ const moved = shiftIndex(row3, shift4);
71688
72161
  if (moved !== void 0) sheet2.rows.set(moved, cells3);
71689
72162
  }
71690
72163
  return;
71691
72164
  }
71692
72165
  for (const [row3, cells3] of old)
71693
72166
  for (const [col, cell2] of cells3) {
71694
- const along = shift3.axis === "row" ? row3 : col;
71695
- const across = shift3.axis === "row" ? col : row3;
72167
+ const along = shift4.axis === "row" ? row3 : col;
72168
+ const across = shift4.axis === "row" ? col : row3;
71696
72169
  const inBand = !band2 || across >= band2.lo && across <= band2.hi;
71697
- const moved = inBand ? shiftIndex(along, shift3) : along;
72170
+ const moved = inBand ? shiftIndex(along, shift4) : along;
71698
72171
  if (moved === void 0) continue;
71699
- if (shift3.axis === "row") putCell(sheet2, moved, col, cell2);
72172
+ if (shift4.axis === "row") putCell(sheet2, moved, col, cell2);
71700
72173
  else putCell(sheet2, row3, moved, cell2);
71701
72174
  }
71702
72175
  }
71703
72176
  function shiftEdgeCells(sheet2, spec2, phase) {
71704
- const { shift: shift3, band: band2 } = spec2;
72177
+ const { shift: shift4, band: band2 } = spec2;
71705
72178
  const out = [];
71706
- if (phase === "after" && shift3.count < 0) return out;
71707
- const hit = (along) => phase === "before" ? shiftIndex(along, shift3) === void 0 : along >= shift3.at && along < shift3.at + shift3.count;
72179
+ if (phase === "after" && shift4.count < 0) return out;
72180
+ const hit = (along) => phase === "before" ? shiftIndex(along, shift4) === void 0 : along >= shift4.at && along < shift4.at + shift4.count;
71708
72181
  for (const [row3, cells3] of sheet2.rows) {
71709
- if (shift3.axis === "row" && !hit(row3)) continue;
72182
+ if (shift4.axis === "row" && !hit(row3)) continue;
71710
72183
  for (const [col, cell2] of cells3) {
71711
- const along = shift3.axis === "row" ? row3 : col;
71712
- const across = shift3.axis === "row" ? col : row3;
72184
+ const along = shift4.axis === "row" ? row3 : col;
72185
+ const across = shift4.axis === "row" ? col : row3;
71713
72186
  if (band2 && (across < band2.lo || across > band2.hi)) continue;
71714
72187
  if (hit(along)) out.push([row3, col, structuredClone(cell2)]);
71715
72188
  }
@@ -71852,8 +72325,8 @@ function restoreShift(workbook, snapshot2) {
71852
72325
  const { spec: spec2 } = snapshot2;
71853
72326
  const sheet2 = workbook.sheets[spec2.sheet];
71854
72327
  if (!sheet2) return;
71855
- const shift3 = snapshot2.phase === "before" ? { ...spec2.shift, count: -spec2.shift.count } : spec2.shift;
71856
- moveCellsRaw(sheet2, shift3, spec2.band);
72328
+ const shift4 = snapshot2.phase === "before" ? { ...spec2.shift, count: -spec2.shift.count } : spec2.shift;
72329
+ moveCellsRaw(sheet2, shift4, spec2.band);
71857
72330
  for (const [row3, col, cell2] of snapshot2.cells) putCell(sheet2, row3, col, cloneCell(cell2));
71858
72331
  restoreRefs(workbook, snapshot2.data);
71859
72332
  workbook.activeSheet = snapshot2.activeSheet;
@@ -74746,11 +75219,11 @@ var byId = (sheet2, id4) => {
74746
75219
  return table4;
74747
75220
  };
74748
75221
  function insertBandRow(workbook, sheet2, table4, row3) {
74749
- const shift3 = { axis: "row", at: row3, count: 1 };
75222
+ const shift4 = { axis: "row", at: row3, count: 1 };
74750
75223
  const band2 = { lo: table4.range.start.col, hi: table4.range.end.col };
74751
- assertInsertFits(sheet2, shift3, band2);
74752
- rewriteFormulas(workbook, (f6, fs) => shiftFormulaInBand(f6, fs, sheet2.name, shift3, band2));
74753
- shiftSheetContent(sheet2, shift3, band2);
75224
+ assertInsertFits(sheet2, shift4, band2);
75225
+ rewriteFormulas(workbook, (f6, fs) => shiftFormulaInBand(f6, fs, sheet2.name, shift4, band2));
75226
+ shiftSheetContent(sheet2, shift4, band2);
74754
75227
  }
74755
75228
  function setHeaderRow(workbook, sheet2, id4, on) {
74756
75229
  let table4 = byId(sheet2, id4);
@@ -77777,10 +78250,10 @@ function createTable2(ctx, s, range3, hasHeader, styleName = "TableStyleMedium2"
77777
78250
  [hasHeader ? { kind: "sheet", sheet: s } : { kind: "workbook" }],
77778
78251
  () => {
77779
78252
  if (!hasHeader) {
77780
- const shift3 = { axis: "row", at: r.start.row, count: 1 };
78253
+ const shift4 = { axis: "row", at: r.start.row, count: 1 };
77781
78254
  const band2 = { lo: r.start.col, hi: r.end.col };
77782
- rewriteFormulas(workbook, (f6, fs) => shiftFormulaInBand(f6, fs, sheet2.name, shift3, band2));
77783
- shiftSheetContent(sheet2, shift3, band2);
78255
+ rewriteFormulas(workbook, (f6, fs) => shiftFormulaInBand(f6, fs, sheet2.name, shift4, band2));
78256
+ shiftSheetContent(sheet2, shift4, band2);
77784
78257
  r = { start: r.start, end: { row: r.end.row + 1, col: r.end.col } };
77785
78258
  }
77786
78259
  const width = r.end.col - r.start.col + 1;
@@ -91334,9 +91807,9 @@ var isMarkup = (node4) => node4.nodeType !== 3 && node4.nodeType !== 4;
91334
91807
  var knownMarkup = (text7) => Array.from(text7.childNodes).every(
91335
91808
  (node4) => !isMarkup(node4) || ["cp", "pp", "tp", "fld"].includes(node4.localName)
91336
91809
  );
91337
- function assertUnlocked2(shape2, template) {
91810
+ function assertUnlocked2(shape2, template2) {
91338
91811
  const local = children3(shape2, "Cell").some((cell2) => attribute3(cell2, "N") === "LockTextEdit");
91339
- for (const cell2 of children3(local ? shape2 : template, "Cell")) {
91812
+ for (const cell2 of children3(local ? shape2 : template2, "Cell")) {
91340
91813
  if (attribute3(cell2, "N") !== "LockTextEdit") continue;
91341
91814
  if (cell2.hasAttribute("E") || cell2.hasAttribute("F") || Number(attribute3(cell2, "V")) !== 0)
91342
91815
  fail3("EDIT_PROTECTED_CELL", "The shape is protected against text editing.");
@@ -91354,9 +91827,9 @@ function insertBeforeTail(shape2, node4, tail) {
91354
91827
  shape2.insertBefore(node4, after ?? null);
91355
91828
  }
91356
91829
  var AFTER_TEXT = ["Data1", "Data2", "Data3", "ForeignData", "Shapes"];
91357
- function replaceInstanceText(shape2, template, text7) {
91830
+ function replaceInstanceText(shape2, template2, text7) {
91358
91831
  const local = single2(shape2, "The shape");
91359
- const inherited = single2(template, "The master shape");
91832
+ const inherited = single2(template2, "The master shape");
91360
91833
  if (local && Array.from(local.childNodes).some(isMarkup))
91361
91834
  fail3(
91362
91835
  "UNSUPPORTED_TEXT_EDIT",
@@ -91366,8 +91839,8 @@ function replaceInstanceText(shape2, template, text7) {
91366
91839
  fail3("UNSUPPORTED_TEXT_EDIT", "The master text has markup this editor does not know.");
91367
91840
  if (fieldSections(shape2).length)
91368
91841
  fail3("UNSUPPORTED_TEXT_EDIT", "This stencil shape has its own text fields; edit around them.");
91369
- assertUnlocked2(shape2, template);
91370
- const fields = local ? [] : fieldSections(template).flatMap((section3) => children3(section3, "Row"));
91842
+ assertUnlocked2(shape2, template2);
91843
+ const fields = local ? [] : fieldSections(template2).flatMap((section3) => children3(section3, "Row"));
91371
91844
  const current = local ?? inherited;
91372
91845
  if (!fields.length && current && !Array.from(current.childNodes).some(isMarkup)) {
91373
91846
  if (decodeVisioPlainText(current.textContent ?? "") === text7) return false;
@@ -91396,12 +91869,12 @@ function replaceInstanceText(shape2, template, text7) {
91396
91869
  node4.appendChild(document.createTextNode(encodeVisioPlainText(text7)));
91397
91870
  return true;
91398
91871
  }
91399
- function instanceTextNode(shape2, template) {
91872
+ function instanceTextNode(shape2, template2) {
91400
91873
  const local = single2(shape2, "The shape");
91401
- assertUnlocked2(shape2, template);
91874
+ assertUnlocked2(shape2, template2);
91402
91875
  if (local) return { text: local, discard: () => {
91403
91876
  } };
91404
- const inherited = single2(template, "The master shape");
91877
+ const inherited = single2(template2, "The master shape");
91405
91878
  if (!inherited) fail3("UNSUPPORTED_TEXT_RANGE", "The stencil shape has no text to edit.");
91406
91879
  if (!knownMarkup(inherited))
91407
91880
  fail3("UNSUPPORTED_TEXT_RANGE", "The master text has markup this editor does not know.");
@@ -91420,9 +91893,9 @@ async function replacePlainText(root, document, shapeId2, text7, check4, assertD
91420
91893
  if (found.masterId !== void 0) {
91421
91894
  if (!masterTemplate2)
91422
91895
  fail3("UNSUPPORTED_TEXT_EDIT", "Stencil shapes cannot be edited without their masters.");
91423
- const template = await masterTemplate2(found.masterId, found.masterShapeId);
91896
+ const template2 = await masterTemplate2(found.masterId, found.masterShapeId);
91424
91897
  check4();
91425
- return replaceInstanceText(found.node, template, text7);
91898
+ return replaceInstanceText(found.node, template2, text7);
91426
91899
  }
91427
91900
  const target3 = localTextTarget(root, document, shapeId2, check4);
91428
91901
  const texts = children3(target3, "Text");
@@ -91638,7 +92111,7 @@ function assertMasterMarkup(root, known, check4) {
91638
92111
  );
91639
92112
  }
91640
92113
  }
91641
- function masterStyleCells(document, template, instance, check4, charge = () => {
92114
+ function masterStyleCells(document, template2, instance, check4, charge = () => {
91642
92115
  }, verifyMovementProtection = false) {
91643
92116
  const styles = /* @__PURE__ */ new Map();
91644
92117
  for (const container of children3(document, "StyleSheets"))
@@ -91673,7 +92146,7 @@ function masterStyleCells(document, template, instance, check4, charge = () => {
91673
92146
  };
91674
92147
  const result2 = /* @__PURE__ */ new Map();
91675
92148
  for (const category of ["LineStyle", "FillStyle", "TextStyle"]) {
91676
- const id4 = attribute3(instance, category) ?? attribute3(template, category) ?? attribute3(defaults, category) ?? (styles.has("0") ? "0" : void 0);
92149
+ const id4 = attribute3(instance, category) ?? attribute3(template2, category) ?? attribute3(defaults, category) ?? (styles.has("0") ? "0" : void 0);
91677
92150
  if (id4 !== void 0)
91678
92151
  for (const [name3, node4] of collect(id4, category)) {
91679
92152
  charge();
@@ -91789,14 +92262,14 @@ var templates2 = /* @__PURE__ */ new WeakMap();
91789
92262
  var topShapes = (root) => children3(children3(root, "Shapes")[0], "Shape");
91790
92263
  var deleted = (node4) => ["1", "true"].includes(attribute3(node4, "Del") ?? "");
91791
92264
  var plain4 = (shape2) => ["Shape", void 0].includes(attribute3(shape2, "Type")) && !children3(shape2, "Shapes").length && !children3(shape2, "ForeignData").length && !deleted(shape2);
91792
- async function registerStencilShapes(roots, template, check4) {
92265
+ async function registerStencilShapes(roots, template2, check4) {
91793
92266
  for (const root of roots.values())
91794
92267
  for (const shape2 of topShapes(root)) {
91795
92268
  const master2 = attribute3(shape2, "Master");
91796
92269
  if (master2 === void 0 || shape2.hasAttribute("MasterShape") || !plain4(shape2)) continue;
91797
92270
  check4();
91798
92271
  try {
91799
- const source3 = await template(master2);
92272
+ const source3 = await template2(master2);
91800
92273
  if (plain4(source3) && !source3.hasAttribute("Master") && !source3.hasAttribute("MasterShape"))
91801
92274
  templates2.set(shape2, source3);
91802
92275
  } catch (error62) {
@@ -91805,8 +92278,8 @@ async function registerStencilShapes(roots, template, check4) {
91805
92278
  }
91806
92279
  }
91807
92280
  var stencilTemplate = (shape2) => shape2 ? templates2.get(shape2) : void 0;
91808
- function registerStencilShape(shape2, template) {
91809
- templates2.set(shape2, template);
92281
+ function registerStencilShape(shape2, template2) {
92282
+ templates2.set(shape2, template2);
91810
92283
  }
91811
92284
  var cellMap = (parent) => new Map(children3(parent, "Cell").map((node4) => [attribute3(node4, "N") ?? "", node4]));
91812
92285
  function effectiveCells(shape2) {
@@ -91865,8 +92338,8 @@ var LOCAL_FORM = {
91865
92338
  Width: ["inh", "guard(endx-beginx)", "guard(0.25dl)"],
91866
92339
  Height: ["inh", "guard(endy-beginy)", "guard(0.25dl)"]
91867
92340
  };
91868
- function isDynamicConnectorMaster(template) {
91869
- const cells3 = cellMap(template);
92341
+ function isDynamicConnectorMaster(template2) {
92342
+ const cells3 = cellMap(template2);
91870
92343
  if (!END_CELLS.every((name3) => cells3.has(name3))) return false;
91871
92344
  if (!MASTER_FORM.every(
91872
92345
  ([name3, forms]) => forms.includes(normal(attribute3(cells3.get(name3), "F")) ?? "")
@@ -91876,7 +92349,7 @@ function isDynamicConnectorMaster(template) {
91876
92349
  const node4 = cells3.get(name3);
91877
92350
  if (node4 && Number(attribute3(node4, "V") ?? "0") !== 0) return false;
91878
92351
  }
91879
- const geometry2 = children3(template, "Section").filter(
92352
+ const geometry2 = children3(template2, "Section").filter(
91880
92353
  (node4) => attribute3(node4, "N") === "Geometry"
91881
92354
  );
91882
92355
  if (geometry2.length !== 1 || deleted(geometry2[0])) return false;
@@ -91885,7 +92358,7 @@ function isDynamicConnectorMaster(template) {
91885
92358
  (row3, index4) => attribute3(row3, "IX") !== String(index4 + 1) || deleted(row3) || index4 > 0 && attribute3(row3, "T") !== "LineTo" || children3(row3, "Cell").some((cell2) => executableCellFormula(attribute3(cell2, "F")))
91886
92359
  ))
91887
92360
  return false;
91888
- const control = sectionRows2(template, "Control").filter(
92361
+ const control = sectionRows2(template2, "Control").filter(
91889
92362
  (row3) => attribute3(row3, "N") === "TextPosition"
91890
92363
  );
91891
92364
  if (control.length !== 1) return false;
@@ -91893,14 +92366,14 @@ function isDynamicConnectorMaster(template) {
91893
92366
  return normal(attribute3(position3.get("XDyn"), "F")) === "controls.textposition" && normal(attribute3(position3.get("YDyn"), "F")) === "controls.textposition.y";
91894
92367
  }
91895
92368
  function isStencilConnector(shape2) {
91896
- const template = stencilTemplate(shape2);
91897
- return !!template && END_CELLS.some((name3) => cellMap(template).has(name3));
92369
+ const template2 = stencilTemplate(shape2);
92370
+ return !!template2 && END_CELLS.some((name3) => cellMap(template2).has(name3));
91898
92371
  }
91899
92372
  var STENCIL_CONNECTOR_FORM = "This connector comes from a stencil and is not built like Visio's Dynamic connector, so it cannot be rerouted here; it and the shapes glued to it cannot be moved or resized.";
91900
92373
  function proveStencilConnector(shape2) {
91901
- const template = stencilTemplate(shape2);
92374
+ const template2 = stencilTemplate(shape2);
91902
92375
  const refuse4 = () => fail3("UNSUPPORTED_GEOMETRY_EDIT", STENCIL_CONNECTOR_FORM);
91903
- if (!template || !isDynamicConnectorMaster(template)) return refuse4();
92376
+ if (!template2 || !isDynamicConnectorMaster(template2)) return refuse4();
91904
92377
  const local = cellMap(shape2);
91905
92378
  for (const [name3, forms] of Object.entries(LOCAL_FORM)) {
91906
92379
  const node4 = local.get(name3);
@@ -91919,7 +92392,7 @@ function proveStencilConnector(shape2) {
91919
92392
  if (attribute3(row3, "N") !== "TextPosition" || deleted(row3)) refuse4();
91920
92393
  }
91921
92394
  }
91922
- return template;
92395
+ return template2;
91923
92396
  }
91924
92397
  function stencilConnectorRoute(shape2) {
91925
92398
  const cells3 = effectiveCells(shape2);
@@ -91962,8 +92435,8 @@ function unique3(items, key2, what) {
91962
92435
  return result2;
91963
92436
  }
91964
92437
  var cellMap2 = (parent) => unique3(children3(parent, "Cell"), (cell2) => attribute3(cell2, "N") ?? "", "cell");
91965
- function instanceSheet(instance, template, options2 = {}) {
91966
- for (const node4 of [instance, template]) {
92438
+ function instanceSheet(instance, template2, options2 = {}) {
92439
+ for (const node4 of [instance, template2]) {
91967
92440
  const type = attribute3(node4, "Type");
91968
92441
  if (!(options2.group ? ["Shape", "Group", void 0] : ["Shape", void 0]).includes(type) || !options2.group && children3(node4, "Shapes").length > 0 || children3(node4, "ForeignData").length || deleted2(node4))
91969
92442
  fail3(
@@ -91971,11 +92444,11 @@ function instanceSheet(instance, template, options2 = {}) {
91971
92444
  options2.group ? "A stencil shape that holds a picture or a deleted part cannot be changed." : "Only stencil shapes made of one plain shape can be changed; grouped, picture and deleted ones cannot."
91972
92445
  );
91973
92446
  }
91974
- if (template.hasAttribute("Master") || template.hasAttribute("MasterShape"))
92447
+ if (template2.hasAttribute("Master") || template2.hasAttribute("MasterShape"))
91975
92448
  fail3("UNSUPPORTED_INSTANCE_EDIT", "The master of this stencil shape inherits another master.");
91976
92449
  const cells3 = [];
91977
92450
  const localCells = cellMap2(instance);
91978
- const masterCells2 = cellMap2(template);
92451
+ const masterCells2 = cellMap2(template2);
91979
92452
  for (const name3 of /* @__PURE__ */ new Set([...masterCells2.keys(), ...localCells.keys()])) {
91980
92453
  const local = localCells.get(name3), inherited = masterCells2.get(name3);
91981
92454
  cells3.push({
@@ -91987,7 +92460,7 @@ function instanceSheet(instance, template, options2 = {}) {
91987
92460
  });
91988
92461
  }
91989
92462
  const sections2 = (shape2) => unique3(children3(shape2, "Section"), sectionKey, "section");
91990
- const localSections = sections2(instance), masterSections = sections2(template);
92463
+ const localSections = sections2(instance), masterSections = sections2(template2);
91991
92464
  for (const key2 of /* @__PURE__ */ new Set([...masterSections.keys(), ...localSections.keys()])) {
91992
92465
  const localSection = localSections.get(key2), masterSection = masterSections.get(key2);
91993
92466
  const section3 = masterSection ?? localSection;
@@ -92038,7 +92511,7 @@ function instanceSheet(instance, template, options2 = {}) {
92038
92511
  const byName2 = /* @__PURE__ */ new Map();
92039
92512
  for (const cell2 of cells3)
92040
92513
  for (const name3 of cell2.names) if (!byName2.has(name3)) byName2.set(name3, cell2);
92041
- return { instance, template, cells: cells3, byName: byName2 };
92514
+ return { instance, template: template2, cells: cells3, byName: byName2 };
92042
92515
  }
92043
92516
  var effectiveNode = (cell2) => cell2.local?.hasAttribute("V") || !cell2.inherited ? cell2.local : cell2.inherited;
92044
92517
  function effectiveFormula(cell2) {
@@ -92099,7 +92572,7 @@ function writeInstanceCell(sheet2, cell2, value3, options2 = {}) {
92099
92572
  else node4.removeAttribute("F");
92100
92573
  return node4;
92101
92574
  }
92102
- async function instanceTarget(root, shapeId2, template, code = "UNSUPPORTED_INSTANCE_EDIT") {
92575
+ async function instanceTarget(root, shapeId2, template2, code = "UNSUPPORTED_INSTANCE_EDIT") {
92103
92576
  const containers = children3(root, "Shapes");
92104
92577
  if (containers.length !== 1) return void 0;
92105
92578
  const candidates = children3(containers[0], "Shape").filter(
@@ -92109,7 +92582,7 @@ async function instanceTarget(root, shapeId2, template, code = "UNSUPPORTED_INST
92109
92582
  const masterId = instance && attribute3(instance, "Master");
92110
92583
  if (!instance || masterId === void 0) return void 0;
92111
92584
  try {
92112
- return { instance, template: await template(masterId) };
92585
+ return { instance, template: await template2(masterId) };
92113
92586
  } catch (error62) {
92114
92587
  if (error62 instanceof VisioPackageError && error62.code === "UNSUPPORTED_TEXT_EDIT")
92115
92588
  fail3(code, error62.message);
@@ -92188,11 +92661,11 @@ function singleScope(sheet2) {
92188
92661
  }
92189
92662
  var members = (shape2) => children3(shape2, "Shapes").flatMap((container) => children3(container, "Shape"));
92190
92663
  var isGroupInstance = (instance) => attribute3(instance, "Type") === "Group" || members(instance).length > 0;
92191
- async function groupScope(instance, template, code = "UNSUPPORTED_INSTANCE_EDIT") {
92664
+ async function groupScope(instance, template2, code = "UNSUPPORTED_INSTANCE_EDIT") {
92192
92665
  const masterId = attribute3(instance, "Master");
92193
92666
  const resolved = async (masterShapeId) => {
92194
92667
  try {
92195
- return await template(masterId, masterShapeId);
92668
+ return await template2(masterId, masterShapeId);
92196
92669
  } catch (error62) {
92197
92670
  if (error62 instanceof VisioPackageError && error62.code === "UNSUPPORTED_TEXT_EDIT")
92198
92671
  return void 0;
@@ -92235,13 +92708,13 @@ async function groupScope(instance, template, code = "UNSUPPORTED_INSTANCE_EDIT"
92235
92708
  }
92236
92709
  return scopeOf(sheets, byMaster);
92237
92710
  }
92238
- async function instanceScope(root, shapeId2, template, code = "UNSUPPORTED_INSTANCE_EDIT") {
92711
+ async function instanceScope(root, shapeId2, template2, code = "UNSUPPORTED_INSTANCE_EDIT") {
92239
92712
  const containers = children3(root, "Shapes");
92240
92713
  const candidates = containers.length === 1 ? children3(containers[0], "Shape").filter((shape2) => attribute3(shape2, "ID") === shapeId2) : [];
92241
92714
  const instance = candidates.length === 1 ? candidates[0] : void 0;
92242
92715
  if (!instance || !instance.hasAttribute("Master")) return void 0;
92243
- if (isGroupInstance(instance)) return groupScope(instance, template, code);
92244
- const target3 = await instanceTarget(root, shapeId2, template, code);
92716
+ if (isGroupInstance(instance)) return groupScope(instance, template2, code);
92717
+ const target3 = await instanceTarget(root, shapeId2, template2, code);
92245
92718
  return target3 && singleScope(instanceSheet(target3.instance, target3.template));
92246
92719
  }
92247
92720
 
@@ -93563,7 +94036,7 @@ var drop = (shape2, node4) => {
93563
94036
  if (!node4.childNodes.length && node4.parentNode === shape2) shape2.removeChild(node4);
93564
94037
  };
93565
94038
  function writeStencilConnector(shape2, route, vertices) {
93566
- const template = proveStencilConnector(shape2);
94039
+ const template2 = proveStencilConnector(shape2);
93567
94040
  const effective = effectiveCells(shape2);
93568
94041
  for (const [name3, allowed] of [
93569
94042
  ["ShapeRouteStyle", [0, 1, 16]],
@@ -93580,19 +94053,19 @@ function writeStencilConnector(shape2, route, vertices) {
93580
94053
  const dx = end.x - begin.x, dy = end.y - begin.y;
93581
94054
  const flatX = Math.abs(dx) < FLAT - EPSILON4, flatY = Math.abs(dy) < FLAT - EPSILON4;
93582
94055
  const width = flatX ? FLAT : dx, height = flatY ? FLAT : dy;
93583
- put(shape2, template, "PinX", (begin.x + end.x) / 2, "Inh");
93584
- put(shape2, template, "PinY", (begin.y + end.y) / 2, "Inh");
94056
+ put(shape2, template2, "PinX", (begin.x + end.x) / 2, "Inh");
94057
+ put(shape2, template2, "PinY", (begin.y + end.y) / 2, "Inh");
93585
94058
  put(shape2, void 0, "Width", width, flatX ? "GUARD(0.25DL)" : "GUARD(EndX-BeginX)");
93586
94059
  put(shape2, void 0, "Height", height, flatY ? "GUARD(0.25DL)" : "GUARD(EndY-BeginY)");
93587
- put(shape2, template, "LocPinX", width / 2, "Inh");
93588
- put(shape2, template, "LocPinY", height / 2, "Inh");
94060
+ put(shape2, template2, "LocPinX", width / 2, "Inh");
94061
+ put(shape2, template2, "LocPinY", height / 2, "Inh");
93589
94062
  for (const [name3, value3] of [
93590
94063
  ["BeginX", begin.x],
93591
94064
  ["BeginY", begin.y],
93592
94065
  ["EndX", end.x],
93593
94066
  ["EndY", end.y]
93594
94067
  ])
93595
- put(shape2, template, name3, value3);
94068
+ put(shape2, template2, name3, value3);
93596
94069
  const at3 = (point3) => ({
93597
94070
  x: point3.x - (begin.x + end.x) / 2 + width / 2,
93598
94071
  y: point3.y - (begin.y + end.y) / 2 + height / 2
@@ -93600,7 +94073,7 @@ function writeStencilConnector(shape2, route, vertices) {
93600
94073
  const curved2 = route === "curved" && (vertices.length === 5 || !flatX && !flatY && vertices.length === 4);
93601
94074
  const local = (curved2 || route !== "curved" ? vertices : [begin, end]).map(at3);
93602
94075
  const [internalKnot, lastKnot] = local.length === 5 ? cornerCurveKnots(local) : [0, 1];
93603
- const masterGeometry = children3(template, "Section").find(
94076
+ const masterGeometry = children3(template2, "Section").find(
93604
94077
  (item2) => attribute3(item2, "N") === "Geometry"
93605
94078
  );
93606
94079
  const masterRows = children3(masterGeometry, "Row");
@@ -93670,7 +94143,7 @@ function writeStencilConnector(shape2, route, vertices) {
93670
94143
  }
93671
94144
  drop(shape2, geometry2);
93672
94145
  const middle = curved2 ? connectorCurveMiddle(local) : connectorPolylineMiddle(local);
93673
- const masterControl = children3(template, "Section").filter((item2) => attribute3(item2, "N") === "Control").flatMap((item2) => children3(item2, "Row")).find((row3) => attribute3(row3, "N") === "TextPosition");
94146
+ const masterControl = children3(template2, "Section").filter((item2) => attribute3(item2, "N") === "Control").flatMap((item2) => children3(item2, "Row")).find((row3) => attribute3(row3, "N") === "TextPosition");
93674
94147
  const control = section(shape2, "Control");
93675
94148
  let position3 = children3(control, "Row").find((row3) => attribute3(row3, "N") === "TextPosition");
93676
94149
  if (!position3) {
@@ -93684,8 +94157,8 @@ function writeStencilConnector(shape2, route, vertices) {
93684
94157
  put(position3, masterControl, "YDyn", middle.y, "Inh");
93685
94158
  drop(control, position3);
93686
94159
  drop(shape2, control);
93687
- put(shape2, template, "TxtPinX", middle.x, "Inh");
93688
- put(shape2, template, "TxtPinY", middle.y, "Inh");
94160
+ put(shape2, template2, "TxtPinX", middle.x, "Inh");
94161
+ put(shape2, template2, "TxtPinY", middle.y, "Inh");
93689
94162
  }
93690
94163
 
93691
94164
  // visio/edit-stencil-connector-layout.ts
@@ -93745,15 +94218,15 @@ var format = (value3) => String(Object.is(value3, -0) ? 0 : value3);
93745
94218
  var near = (a2, b) => Math.abs(a2 - b) <= 1e-9 * Math.max(1, Math.abs(a2), Math.abs(b));
93746
94219
  var NAMES3 = { begin: ["BeginX", "BeginY"], end: ["EndX", "EndY"] };
93747
94220
  function isStencilLine(shape2) {
93748
- const template = stencilTemplate(shape2);
93749
- return !!shape2 && !!template && isStencilConnector(shape2) && !isDynamicConnectorMaster(template);
94221
+ const template2 = stencilTemplate(shape2);
94222
+ return !!shape2 && !!template2 && isStencilConnector(shape2) && !isDynamicConnectorMaster(template2);
93750
94223
  }
93751
94224
  function proveStencilLine(shape2) {
93752
- const template = stencilTemplate(shape2);
93753
- if (!template) return refuse();
94225
+ const template2 = stencilTemplate(shape2);
94226
+ if (!template2) return refuse();
93754
94227
  let sheet2;
93755
94228
  try {
93756
- sheet2 = instanceSheet(shape2, template);
94229
+ sheet2 = instanceSheet(shape2, template2);
93757
94230
  } catch (error62) {
93758
94231
  if (error62 instanceof VisioPackageError && error62.code === "UNSUPPORTED_INSTANCE_EDIT")
93759
94232
  return refuse();
@@ -94656,11 +95129,11 @@ function measures(shape2) {
94656
95129
  }
94657
95130
  return false;
94658
95131
  }
94659
- async function measuresOwnText(root, shapeId2, template, check4) {
95132
+ async function measuresOwnText(root, shapeId2, template2, check4) {
94660
95133
  try {
94661
95134
  const found = textTarget(root, shapeId2, check4);
94662
95135
  if (measures(found.node)) return true;
94663
- return found.masterId !== void 0 && measures(await template(found.masterId, found.masterShapeId));
95136
+ return found.masterId !== void 0 && measures(await template2(found.masterId, found.masterShapeId));
94664
95137
  } catch (error62) {
94665
95138
  if (!(error62 instanceof VisioPackageError) || error62.code.startsWith("LIMIT_")) throw error62;
94666
95139
  return false;
@@ -94681,7 +95154,7 @@ async function refreshTextSizes(targets, result2, options2, deadline) {
94681
95154
  let resized = 0;
94682
95155
  try {
94683
95156
  const { pkg, parts, pages } = await openEditablePackage(result2.bytes, limits, check4);
94684
- const template = masterTemplate(pkg);
95157
+ const template2 = masterTemplate(pkg);
94685
95158
  const roots = /* @__PURE__ */ new Map();
94686
95159
  for (const [pageId2, path4] of pages) {
94687
95160
  const source3 = await visioXml(pkg, path4, "PageContents");
@@ -94697,7 +95170,7 @@ async function refreshTextSizes(targets, result2, options2, deadline) {
94697
95170
  const trial = new Map(roots).set(target3.pageId, copy8);
94698
95171
  try {
94699
95172
  const found = textTarget(copy8, target3.shapeId, check4);
94700
- const master2 = found.masterId === void 0 ? void 0 : await template(found.masterId, found.masterShapeId);
95173
+ const master2 = found.masterId === void 0 ? void 0 : await template2(found.masterId, found.masterShapeId);
94701
95174
  if (!measures(found.node) && !(master2 && measures(master2))) continue;
94702
95175
  const sheet2 = instanceSheet(
94703
95176
  found.node,
@@ -95045,7 +95518,7 @@ async function refreshLineJumpCaches(pageIds2, source3, result2, options2, deadl
95045
95518
  const { pkg, parts, pages } = await openEditablePackage(result2.bytes, limits, check4);
95046
95519
  const model2 = await parseVsdx(result2.bytes, { limits });
95047
95520
  const before = source3 ? await parseVsdx(source3, { limits }) : void 0;
95048
- const template = masterTemplate(pkg);
95521
+ const template2 = masterTemplate(pkg);
95049
95522
  const changed = new Set(result2.changedParts);
95050
95523
  const kept = [];
95051
95524
  let referenced = false;
@@ -95084,7 +95557,7 @@ async function refreshLineJumpCaches(pageIds2, source3, result2, options2, deadl
95084
95557
  const indices = /* @__PURE__ */ new Map();
95085
95558
  const masterId = attribute3(target3, "Master");
95086
95559
  if (masterId) {
95087
- const master2 = await template(masterId, attribute3(target3, "MasterShape"));
95560
+ const master2 = await template2(masterId, attribute3(target3, "MasterShape"));
95088
95561
  const base3 = children3(master2, "Section").find(
95089
95562
  (node4) => attribute3(node4, "N") === "Geometry" && attribute3(node4, "IX") === attribute3(section3, "IX")
95090
95563
  );
@@ -95235,10 +95708,10 @@ function followConnectors(roots, pageId2, shapeId2, check4) {
95235
95708
  return [...pages];
95236
95709
  }
95237
95710
  var format3 = (value3) => String(Object.is(value3, -0) ? 0 : value3);
95238
- async function applyInstanceGeometryEdit(roots, edit2, template, check4) {
95711
+ async function applyInstanceGeometryEdit(roots, edit2, template2, check4) {
95239
95712
  const root = roots.get(edit2.pageId);
95240
95713
  if (!root) fail3("EDIT_TARGET_NOT_FOUND", "Page does not exist.");
95241
- const scope = await instanceScope(root, edit2.shapeId, template);
95714
+ const scope = await instanceScope(root, edit2.shapeId, template2);
95242
95715
  if (!scope) fail3("EDIT_TARGET_NOT_FOUND", "A unique top-level stencil shape is required.");
95243
95716
  check4();
95244
95717
  const sheet2 = scope.root;
@@ -95412,7 +95885,7 @@ function overlayCells(base3, local) {
95412
95885
  }
95413
95886
  var MAX_MEMBERS3 = 2e3;
95414
95887
  var members2 = (shape2) => children3(shape2, "Shapes").flatMap((container) => children3(container, "Shape"));
95415
- async function formattingInstances(root, shapeId2, template) {
95888
+ async function formattingInstances(root, shapeId2, template2) {
95416
95889
  let found;
95417
95890
  const pending2 = members2(root).map((node4) => ({ node: node4, masterId: attribute3(node4, "Master") }));
95418
95891
  for (let count3 = 0; pending2.length; ) {
@@ -95429,13 +95902,13 @@ async function formattingInstances(root, shapeId2, template) {
95429
95902
  if (!found) return void 0;
95430
95903
  const top = found.node.hasAttribute("Master");
95431
95904
  if (top && !isGroupInstance(found.node)) {
95432
- const single3 = await formattingInstance(root, shapeId2, template);
95905
+ const single3 = await formattingInstance(root, shapeId2, template2);
95433
95906
  return single3 && [single3];
95434
95907
  }
95435
95908
  const masterId = found.masterId;
95436
95909
  const resolved = async (masterShapeId) => {
95437
95910
  try {
95438
- return await template(masterId, masterShapeId);
95911
+ return await template2(masterId, masterShapeId);
95439
95912
  } catch (error62) {
95440
95913
  if (error62 instanceof VisioPackageError && error62.code === "UNSUPPORTED_TEXT_EDIT")
95441
95914
  return void 0;
@@ -95460,8 +95933,8 @@ async function formattingInstances(root, shapeId2, template) {
95460
95933
  }
95461
95934
  return result2;
95462
95935
  }
95463
- async function formattingInstance(root, shapeId2, template) {
95464
- const target3 = await instanceTarget(root, shapeId2, template, "UNSUPPORTED_FORMAT_EDIT");
95936
+ async function formattingInstance(root, shapeId2, template2) {
95937
+ const target3 = await instanceTarget(root, shapeId2, template2, "UNSUPPORTED_FORMAT_EDIT");
95465
95938
  if (!target3) return void 0;
95466
95939
  return formattingView(target3, false);
95467
95940
  }
@@ -95703,14 +96176,14 @@ function reorderVisioShape(root, document, edit2, check4, views = /* @__PURE__ *
95703
96176
  // visio/edit-instance-shape.ts
95704
96177
  var deleted3 = (node4) => ["1", "true"].includes(attribute3(node4, "Del") ?? "");
95705
96178
  var pageShapes = (root) => children3(root, "Shapes").flatMap((container) => children3(container, "Shape"));
95706
- async function stencilInstance(root, shapeId2, template, code = "UNSUPPORTED_INSTANCE_EDIT") {
96179
+ async function stencilInstance(root, shapeId2, template2, code = "UNSUPPORTED_INSTANCE_EDIT") {
95707
96180
  const matches3 = pageShapes(root).filter((shape2) => attribute3(shape2, "ID") === shapeId2);
95708
96181
  const instance = matches3.length === 1 ? matches3[0] : void 0;
95709
96182
  const masterId = instance && attribute3(instance, "Master");
95710
96183
  if (!instance || masterId === void 0) return void 0;
95711
96184
  if (deleted3(instance)) fail3(code, "The stencil shape is deleted.");
95712
96185
  try {
95713
- return { instance, template: await template(masterId) };
96186
+ return { instance, template: await template2(masterId) };
95714
96187
  } catch (error62) {
95715
96188
  if (error62 instanceof VisioPackageError && error62.code === "UNSUPPORTED_TEXT_EDIT")
95716
96189
  fail3(code, error62.message);
@@ -95775,12 +96248,12 @@ async function assertInstanceLayerUnlocked(pkg, root, pageId2, shapeId2) {
95775
96248
  attribute3(cellNamed(shape2, "LayerMember"), "V")
95776
96249
  );
95777
96250
  }
95778
- async function shapeIsStructural(shape2, template) {
96251
+ async function shapeIsStructural(shape2, template2) {
95779
96252
  if (isStructureSheet(shape2)) return true;
95780
96253
  const masterId = attribute3(shape2, "Master");
95781
96254
  if (masterId === void 0) return false;
95782
96255
  try {
95783
- return isStructureSheet(await template(masterId));
96256
+ return isStructureSheet(await template2(masterId));
95784
96257
  } catch {
95785
96258
  return true;
95786
96259
  }
@@ -95868,12 +96341,12 @@ function instancePin(target3) {
95868
96341
  }
95869
96342
 
95870
96343
  // visio/edit-instance-delete.ts
95871
- async function admitInstanceDeletes(pkg, roots, edits2, template, check4) {
96344
+ async function admitInstanceDeletes(pkg, roots, edits2, template2, check4) {
95872
96345
  const admitted4 = /* @__PURE__ */ new Set();
95873
96346
  for (const edit2 of edits2) {
95874
96347
  check4();
95875
96348
  const root = roots.get(edit2.pageId);
95876
- const target3 = root && await stencilInstance(root, edit2.shapeId, template);
96349
+ const target3 = root && await stencilInstance(root, edit2.shapeId, template2);
95877
96350
  if (!target3) continue;
95878
96351
  await assertInstanceUnlocked(pkg, edit2.pageId, target3, ["LockDelete"], "deletion");
95879
96352
  admitted4.add(target3.instance);
@@ -96038,13 +96511,13 @@ var TRANSFORM2 = [
96038
96511
  "FlipX",
96039
96512
  "FlipY"
96040
96513
  ];
96041
- async function prove(pkg, pageId2, instance, template, regroup) {
96514
+ async function prove(pkg, pageId2, instance, template2, regroup) {
96042
96515
  const refuse4 = (message) => fail3("UNSUPPORTED_GROUP_EDIT", message);
96043
96516
  if (["1", "true"].includes(attribute3(instance, "Del") ?? ""))
96044
96517
  refuse4("A stencil shape is deleted.");
96045
96518
  let master2;
96046
96519
  try {
96047
- master2 = await template(attribute3(instance, "Master"));
96520
+ master2 = await template2(attribute3(instance, "Master"));
96048
96521
  } catch (error62) {
96049
96522
  if (!(error62 instanceof VisioPackageError) || error62.code.startsWith("LIMIT_")) throw error62;
96050
96523
  return refuse4("The master of a stencil shape cannot be resolved.");
@@ -96085,7 +96558,7 @@ function instancesIn(top) {
96085
96558
  }
96086
96559
  return found;
96087
96560
  }
96088
- async function groupInstances(pkg, roots, commands, template, check4) {
96561
+ async function groupInstances(pkg, roots, commands, template2, check4) {
96089
96562
  const result2 = /* @__PURE__ */ new Map();
96090
96563
  for (const command2 of commands) {
96091
96564
  check4();
@@ -96101,7 +96574,7 @@ async function groupInstances(pkg, roots, commands, template, check4) {
96101
96574
  const regroup = grouping || command2.type === "ungroup-shape";
96102
96575
  for (const instance of instances)
96103
96576
  if (!result2.has(instance))
96104
- result2.set(instance, await prove(pkg, command2.pageId, instance, template, regroup));
96577
+ result2.set(instance, await prove(pkg, command2.pageId, instance, template2, regroup));
96105
96578
  }
96106
96579
  }
96107
96580
  return result2;
@@ -96220,8 +96693,8 @@ async function linkPage(pkg, parts, pagePath, masterPart, limits, check4) {
96220
96693
  fail3("LIMIT_ENTRIES", "The edit exceeds the package entry limit.");
96221
96694
  parts.set(relsPart, serializeEditedXml(rels, limits, check4).bytes);
96222
96695
  }
96223
- async function replaceInstanceMaster(pkg, parts, pagePath, root, edit2, template, limits, check4) {
96224
- const target3 = await stencilInstance(root, edit2.shapeId, template, "UNSUPPORTED_CHANGE_SHAPE");
96696
+ async function replaceInstanceMaster(pkg, parts, pagePath, root, edit2, template2, limits, check4) {
96697
+ const target3 = await stencilInstance(root, edit2.shapeId, template2, "UNSUPPORTED_CHANGE_SHAPE");
96225
96698
  if (!target3) return refuse2("Only a stencil shape can take another master.");
96226
96699
  const { instance } = target3;
96227
96700
  if (attribute3(instance, "Master") === edit2.masterId) return false;
@@ -96229,7 +96702,7 @@ async function replaceInstanceMaster(pkg, parts, pagePath, root, edit2, template
96229
96702
  let before, replacement;
96230
96703
  try {
96231
96704
  before = instanceSheet(instance, target3.template);
96232
- replacement = await template(edit2.masterId);
96705
+ replacement = await template2(edit2.masterId);
96233
96706
  } catch (error62) {
96234
96707
  if (!(error62 instanceof VisioPackageError) || error62.code.startsWith("LIMIT_")) throw error62;
96235
96708
  return refuse2("Only shapes of a master made of one plain shape can change master.");
@@ -96313,24 +96786,24 @@ async function replaceInstanceMaster(pkg, parts, pagePath, root, edit2, template
96313
96786
  }
96314
96787
 
96315
96788
  // visio/edit-instance-order.ts
96316
- async function orderTargetsAreStructural(roots, commands, template) {
96789
+ async function orderTargetsAreStructural(roots, commands, template2) {
96317
96790
  for (const command2 of commands) {
96318
96791
  const ids = command2.type === "reorder-shape" || command2.type === "ungroup-shape" ? [command2.shapeId] : command2.type === "group-shapes" ? command2.memberIds : [];
96319
96792
  const root = ids.length && "pageId" in command2 ? roots.get(command2.pageId) : void 0;
96320
96793
  for (const id4 of ids) {
96321
96794
  const shape2 = root && pageShapes(root).find((item2) => attribute3(item2, "ID") === id4);
96322
- if (!shape2 || await shapeIsStructural(shape2, template)) return true;
96795
+ if (!shape2 || await shapeIsStructural(shape2, template2)) return true;
96323
96796
  }
96324
96797
  }
96325
96798
  return false;
96326
96799
  }
96327
- async function instanceOrderViews(pkg, pageId2, root, shapeId2, template, check4) {
96800
+ async function instanceOrderViews(pkg, pageId2, root, shapeId2, template2, check4) {
96328
96801
  const views = /* @__PURE__ */ new Map();
96329
96802
  for (const shape2 of pageShapes(root)) {
96330
96803
  check4();
96331
96804
  const id4 = attribute3(shape2, "ID");
96332
96805
  if (id4 === void 0 || !shape2.hasAttribute("Master")) continue;
96333
- const target3 = await stencilInstance(root, id4, template, "UNSUPPORTED_SHAPE_ORDER");
96806
+ const target3 = await stencilInstance(root, id4, template2, "UNSUPPORTED_SHAPE_ORDER");
96334
96807
  if (!target3) continue;
96335
96808
  if (id4 === shapeId2) await assertInstanceUnlocked(pkg, pageId2, target3, [], "reordering");
96336
96809
  views.set(shape2, instanceView(target3, ["DisplayLevel", "LockSelect", "LockFormat"]));
@@ -97517,7 +97990,7 @@ var VISIO_DEFAULT_TITLE = "Title";
97517
97990
  var ACCENT = { background: "Background Accent", border: "Border Accent" };
97518
97991
  function visioShade(color4, amount) {
97519
97992
  const value3 = Number.parseInt(color4.slice(1), 16);
97520
- const channel = (shift3) => Math.round((value3 >> shift3 & 255) * (1 - amount)).toString(16).padStart(2, "0");
97993
+ const channel = (shift4) => Math.round((value3 >> shift4 & 255) * (1 - amount)).toString(16).padStart(2, "0");
97521
97994
  return `#${channel(16)}${channel(8)}${channel(0)}`.toUpperCase();
97522
97995
  }
97523
97996
  function visioDecorationName(name3) {
@@ -101093,32 +101566,32 @@ async function assertVisioMasterIndependence(pkg, roots, commands, check4) {
101093
101566
  if (byTemplate.has(id4)) problem("MasterShape mappings are ambiguous.");
101094
101567
  byTemplate.set(id4, local);
101095
101568
  }
101096
- for (const template of templates3) {
101569
+ for (const template2 of templates3) {
101097
101570
  charge();
101098
101571
  if (bindings.length >= 1e4) problem("Master effective binding limit exceeded.");
101099
101572
  check4();
101100
- if (template.hasAttribute("Master") || template.hasAttribute("MasterShape"))
101573
+ if (template2.hasAttribute("Master") || template2.hasAttribute("MasterShape"))
101101
101574
  problem("Chained master definitions are unsupported.");
101102
- const templateId = attribute3(template, "ID");
101575
+ const templateId = attribute3(template2, "ID");
101103
101576
  if (!templateId || context.has(templateId)) problem("Master-local sheet IDs are ambiguous.");
101104
101577
  const local = byTemplate.get(templateId), cells3 = /* @__PURE__ */ new Map();
101105
101578
  const movedInstance = local === instance && movingTargets.has(JSON.stringify([pageId2, attribute3(local, "ID")]));
101106
101579
  for (const [name3, node4] of masterStyleCells(
101107
101580
  document,
101108
- template,
101581
+ template2,
101109
101582
  local,
101110
101583
  check4,
101111
101584
  charge,
101112
101585
  movedInstance
101113
101586
  ))
101114
101587
  cells3.set(name3, { node: node4, kind: "style" });
101115
- overlay(cells3, masterCells(template, charge), "template", charge);
101588
+ overlay(cells3, masterCells(template2, charge), "template", charge);
101116
101589
  const inheritedCells = new Map(cells3);
101117
101590
  overlay(cells3, masterCells(local, charge), "instance", charge);
101118
101591
  const binding = {
101119
101592
  id: `${pageId2}:${attribute3(instance, "ID")}:${templateId}`,
101120
101593
  pageId: pageId2,
101121
- template,
101594
+ template: template2,
101122
101595
  cells: cells3,
101123
101596
  inheritedCells,
101124
101597
  context,
@@ -103007,7 +103480,7 @@ function planLineCopy(shape2, code = "UNSUPPORTED_DUPLICATE") {
103007
103480
  const local = cells(shape2);
103008
103481
  return { x: numeric4(local.get("PinX")), y: numeric4(local.get("PinY")) };
103009
103482
  }
103010
- var shift2 = (node4, delta, name3) => {
103483
+ var shift3 = (node4, delta, name3) => {
103011
103484
  if (!node4) fail3("UNSUPPORTED_DUPLICATE", `The line has no local ${name3}.`);
103012
103485
  const value3 = numeric4(node4);
103013
103486
  node4.setAttribute("V", String(Object.is(value3 + delta, -0) ? 0 : value3 + delta));
@@ -103019,10 +103492,10 @@ function finishLineCopy(shape2, dx, dy) {
103019
103492
  const node4 = local.get(name3);
103020
103493
  const formula2 = executableCellFormula(attribute3(node4, "F"));
103021
103494
  if (formula2 && isNativeGlueCell(name3, formula2)) node4.removeAttribute("F");
103022
- shift2(node4, name3.endsWith("X") ? dx : dy, name3);
103495
+ shift3(node4, name3.endsWith("X") ? dx : dy, name3);
103023
103496
  }
103024
- shift2(local.get("PinX"), dx, "PinX");
103025
- shift2(local.get("PinY"), dy, "PinY");
103497
+ shift3(local.get("PinX"), dx, "PinX");
103498
+ shift3(local.get("PinY"), dy, "PinY");
103026
103499
  }
103027
103500
  var isStencilConnector2 = (target3) => ENDS2.some((name3) => instanceCell(target3, name3));
103028
103501
  function planConnectorCopy(target3, code = "UNSUPPORTED_DUPLICATE") {
@@ -103038,9 +103511,9 @@ function planConnectorCopy(target3, code = "UNSUPPORTED_DUPLICATE") {
103038
103511
  }
103039
103512
  function finishConnectorCopy(shape2, id4, dx, dy) {
103040
103513
  const local = cells(shape2);
103041
- for (const name3 of ENDS2) shift2(local.get(name3), name3.endsWith("X") ? dx : dy, name3);
103042
- shift2(local.get("PinX"), dx, "PinX");
103043
- shift2(local.get("PinY"), dy, "PinY");
103514
+ for (const name3 of ENDS2) shift3(local.get(name3), name3.endsWith("X") ? dx : dy, name3);
103515
+ shift3(local.get("PinX"), dx, "PinX");
103516
+ shift3(local.get("PinY"), dy, "PinY");
103044
103517
  for (const name3 of ["BegTrigger", "EndTrigger"]) {
103045
103518
  const node4 = local.get(name3);
103046
103519
  if (!node4) continue;
@@ -103097,7 +103570,7 @@ async function planInstanceCopy(pkg, pageId2, sourceRoot, target3, offsetX, offs
103097
103570
  fail3(code, "Duplicated pins exceed coordinate limits.");
103098
103571
  return { x, y, connector: connector2 };
103099
103572
  }
103100
- function finishInstanceCopy(clone3, template, x, y, taken, check4) {
103573
+ function finishInstanceCopy(clone3, template2, x, y, taken, check4) {
103101
103574
  const mapping = /* @__PURE__ */ new Map();
103102
103575
  let next = 0;
103103
103576
  for (const id4 of taken) next = Math.max(next, Number(id4) || 0);
@@ -103135,7 +103608,7 @@ function finishInstanceCopy(clone3, template, x, y, taken, check4) {
103135
103608
  )
103136
103609
  );
103137
103610
  }
103138
- placeInstance({ instance: clone3, template }, x, y, check4);
103611
+ placeInstance({ instance: clone3, template: template2 }, x, y, check4);
103139
103612
  return [...mapping.values()];
103140
103613
  }
103141
103614
 
@@ -103172,11 +103645,11 @@ async function duplicateVisioShapes(pkg, pagePaths, roots, document, edit2, chec
103172
103645
  fail3("INVALID_SHAPE_ID", "Duplicate shape ID already exists.");
103173
103646
  const sourceRoot = detached?.root ?? root;
103174
103647
  const sourcePageId = detached?.pageId ?? edit2.pageId;
103175
- const template = masterTemplate(pkg);
103648
+ const template2 = masterTemplate(pkg);
103176
103649
  let structural = false;
103177
103650
  for (const copy8 of edit2.copies) {
103178
103651
  const source3 = pageShapes(sourceRoot).find((shape2) => attribute3(shape2, "ID") === copy8.shapeId);
103179
- structural ||= !source3 || await shapeIsStructural(source3, template);
103652
+ structural ||= !source3 || await shapeIsStructural(source3, template2);
103180
103653
  }
103181
103654
  await assertDuplicateScope(pkg, pagePaths, root, newIds, check4, structural);
103182
103655
  const glueTargets = new Set(
@@ -103217,7 +103690,7 @@ async function duplicateVisioShapes(pkg, pagePaths, roots, document, edit2, chec
103217
103690
  const stencil = await stencilInstance(
103218
103691
  sourceRoot,
103219
103692
  copy8.shapeId,
103220
- template,
103693
+ template2,
103221
103694
  "UNSUPPORTED_DUPLICATE"
103222
103695
  );
103223
103696
  if (stencil) {
@@ -103967,10 +104440,10 @@ async function applyShapeAltText(pkg, pagePaths, roots, edit2, check4) {
103967
104440
  if (/^visio\/.*\.xml$/i.test(path4) && !pagePaths.has(path4)) inspect3(await pkg.readXml(path4));
103968
104441
  }
103969
104442
  if (target3.masterId !== void 0) {
103970
- const template = await masterTemplate(pkg)(target3.masterId, target3.masterShapeId);
103971
- if (template.hasAttribute("Master") || template.hasAttribute("MasterShape"))
104443
+ const template2 = await masterTemplate(pkg)(target3.masterId, target3.masterShapeId);
104444
+ if (template2.hasAttribute("Master") || template2.hasAttribute("MasterShape"))
103972
104445
  fail3("UNSUPPORTED_METADATA_EDIT", "Chained master accessibility metadata is not supported.");
103973
- const inherited = template.cloneNode(true);
104446
+ const inherited = template2.cloneNode(true);
103974
104447
  for (const section3 of children3(inherited, "Section").filter(
103975
104448
  (section4) => attribute3(section4, "N") === "User"
103976
104449
  )) {
@@ -105141,11 +105614,11 @@ async function captureVisioClipboard(input2, pageId2, shapeIds2, options2 = {})
105141
105614
  if (!path4) fail3("EDIT_TARGET_NOT_FOUND", "Clipboard page does not exist.");
105142
105615
  const root = await visioXml(pkg, path4, "PageContents");
105143
105616
  const document = await visioXml(pkg, await related(pkg, "", "document"), "VisioDocument");
105144
- const template = masterTemplate(pkg);
105617
+ const template2 = masterTemplate(pkg);
105145
105618
  let structural = false;
105146
105619
  for (const id4 of selected2) {
105147
105620
  const shape2 = pageShapes(root).find((item2) => attribute3(item2, "ID") === id4);
105148
- structural ||= !shape2 || await shapeIsStructural(shape2, template);
105621
+ structural ||= !shape2 || await shapeIsStructural(shape2, template2);
105149
105622
  }
105150
105623
  await assertShapeOrderPackageScope(pkg, check4, structural);
105151
105624
  const evaluate = createVisioCellEvaluator(
@@ -105157,7 +105630,7 @@ async function captureVisioClipboard(input2, pageId2, shapeIds2, options2 = {})
105157
105630
  const masterIds = /* @__PURE__ */ new Set();
105158
105631
  for (const id4 of selected2) {
105159
105632
  check4();
105160
- const stencil = await stencilInstance(root, id4, template, "UNSUPPORTED_CLIPBOARD");
105633
+ const stencil = await stencilInstance(root, id4, template2, "UNSUPPORTED_CLIPBOARD");
105161
105634
  if (stencil) {
105162
105635
  await planInstanceCopy(pkg, pageId2, root, stencil, 0, 0, "UNSUPPORTED_CLIPBOARD");
105163
105636
  assertClipboardResourceReferences(stencil.instance, document);