ooxml-core 1.4.0 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7614,8 +7614,8 @@ function svgBlipRelId(blip) {
7614
7614
  return svgBlip && getR(svgBlip, "embed") || void 0;
7615
7615
  }
7616
7616
  function textBoxParagraphs(graphicData) {
7617
- const box2 = descendantNS(graphicData, WPS_NS2, "txbx");
7618
- const content2 = descendantNS(box2, W_NS2, "txbxContent");
7617
+ const box3 = descendantNS(graphicData, WPS_NS2, "txbx");
7618
+ const content2 = descendantNS(box3, W_NS2, "txbxContent");
7619
7619
  if (!content2) return void 0;
7620
7620
  const paragraphs = [];
7621
7621
  const visit2 = (node) => {
@@ -13112,11 +13112,35 @@ function rowMatchesFilter(workbook, sheet, row2, filter2) {
13112
13112
  return text2 === "" ? !!column.blank : (column.values ?? []).includes(text2);
13113
13113
  });
13114
13114
  }
13115
+ function setRowFiltered(sheet, row2, filteredOut, hasCriteria = false) {
13116
+ const info = { ...sheet.rowInfo.get(row2) };
13117
+ const manual = info.manuallyHidden || info.hidden && !info.filteredOut;
13118
+ if (filteredOut) {
13119
+ info.hidden = true;
13120
+ info.filteredOut = true;
13121
+ if (manual) info.manuallyHidden = true;
13122
+ } else {
13123
+ delete info.filteredOut;
13124
+ delete info.manuallyHidden;
13125
+ if (manual) {
13126
+ info.hidden = true;
13127
+ if (hasCriteria) info.filteredOut = false;
13128
+ } else delete info.hidden;
13129
+ }
13130
+ if (Object.keys(info).length) sheet.rowInfo.set(row2, info);
13131
+ else sheet.rowInfo.delete(row2);
13132
+ }
13133
+ function clearFilteredRows(sheet) {
13134
+ for (const [row2, info] of sheet.rowInfo)
13135
+ if (info.filteredOut !== void 0 || info.manuallyHidden !== void 0)
13136
+ setRowFiltered(sheet, row2, false);
13137
+ }
13115
13138
  function isFilteredRow(workbook, sheet, row2) {
13139
+ const filter2 = sheet.autoFilter;
13140
+ if (!filter2) return false;
13116
13141
  const info = sheet.rowInfo.get(row2);
13117
13142
  if (info?.filteredOut !== void 0) return info.filteredOut;
13118
- const filter2 = sheet.autoFilter;
13119
- return !!info?.hidden && !!filter2 && row2 > filter2.range.start.row && row2 <= filter2.range.end.row && !rowMatchesFilter(workbook, sheet, row2, filter2);
13143
+ return !!info?.hidden && row2 > filter2.range.start.row && row2 <= filter2.range.end.row && !rowMatchesFilter(workbook, sheet, row2, filter2);
13120
13144
  }
13121
13145
  function readFilteredRows(workbook) {
13122
13146
  for (const sheet of workbook.sheets)
@@ -23511,31 +23535,31 @@ function fitLeastSquares(x, y, hasIntercept) {
23511
23535
  }
23512
23536
  return { slopes, intercept, inverse, means, n, hasIntercept, ssTotal, ssResid };
23513
23537
  }
23514
- function fitStatistics(fit) {
23515
- const k = fit.slopes.length;
23516
- const df = fit.n - k - (fit.hasIntercept ? 1 : 0);
23538
+ function fitStatistics(fit2) {
23539
+ const k = fit2.slopes.length;
23540
+ const df = fit2.n - k - (fit2.hasIntercept ? 1 : 0);
23517
23541
  if (df < 1) fail(ERR.NUM);
23518
- const ssRegression = fit.ssTotal - fit.ssResid;
23519
- const variance2 = fit.ssResid / df;
23542
+ const ssRegression = fit2.ssTotal - fit2.ssResid;
23543
+ const variance2 = fit2.ssResid / df;
23520
23544
  const standardError = Math.sqrt(variance2);
23521
- const slopeErrors = fit.inverse.map((row2, j) => Math.sqrt(variance2 * (row2[j] ?? 0)));
23545
+ const slopeErrors = fit2.inverse.map((row2, j) => Math.sqrt(variance2 * (row2[j] ?? 0)));
23522
23546
  let interceptError;
23523
- if (fit.hasIntercept) {
23547
+ if (fit2.hasIntercept) {
23524
23548
  let quad = 0;
23525
23549
  for (let a2 = 0; a2 < k; a2++)
23526
23550
  for (let b = 0; b < k; b++)
23527
- quad += (fit.means[a2] ?? 0) * (fit.inverse[a2]?.[b] ?? 0) * (fit.means[b] ?? 0);
23528
- interceptError = Math.sqrt(variance2 * (1 / fit.n + quad));
23551
+ quad += (fit2.means[a2] ?? 0) * (fit2.inverse[a2]?.[b] ?? 0) * (fit2.means[b] ?? 0);
23552
+ interceptError = Math.sqrt(variance2 * (1 / fit2.n + quad));
23529
23553
  }
23530
23554
  return {
23531
23555
  slopeErrors,
23532
23556
  interceptError,
23533
- rSquared: fit.ssTotal === 0 ? 1 : ssRegression / fit.ssTotal,
23557
+ rSquared: fit2.ssTotal === 0 ? 1 : ssRegression / fit2.ssTotal,
23534
23558
  standardError,
23535
- fStatistic: fit.ssResid === 0 ? Infinity : ssRegression / k / variance2,
23559
+ fStatistic: fit2.ssResid === 0 ? Infinity : ssRegression / k / variance2,
23536
23560
  df,
23537
23561
  ssRegression,
23538
- ssResidual: fit.ssResid
23562
+ ssResidual: fit2.ssResid
23539
23563
  };
23540
23564
  }
23541
23565
 
@@ -23572,13 +23596,13 @@ var row = (values2, width) => [
23572
23596
  ...values2,
23573
23597
  ...new Array(Math.max(0, width - values2.length)).fill(ERR.NA)
23574
23598
  ];
23575
- function coefficientTable(fit, stats, transform7) {
23576
- const k = fit.slopes.length;
23599
+ function coefficientTable(fit2, stats, transform7) {
23600
+ const k = fit2.slopes.length;
23577
23601
  const width = k + 1;
23578
- const slopes = [...fit.slopes].reverse().map(transform7);
23579
- const head = [...slopes, transform7(fit.intercept)];
23602
+ const slopes = [...fit2.slopes].reverse().map(transform7);
23603
+ const head = [...slopes, transform7(fit2.intercept)];
23580
23604
  if (!stats) return new Matrix([head]);
23581
- const s = fitStatistics(fit);
23605
+ const s = fitStatistics(fit2);
23582
23606
  const errors = [...s.slopeErrors].reverse();
23583
23607
  return new Matrix([
23584
23608
  head,
@@ -23588,16 +23612,16 @@ function coefficientTable(fit, stats, transform7) {
23588
23612
  row([s.ssRegression, s.ssResidual], width)
23589
23613
  ]);
23590
23614
  }
23591
- function predictions(ctx, args, lay, fit, transform7) {
23592
- const predict = (obs) => transform7(fit.intercept + fit.slopes.reduce((a2, m, j) => a2 + m * (obs[j] ?? 0), 0));
23615
+ function predictions(ctx, args, lay, fit2, transform7) {
23616
+ const predict = (obs) => transform7(fit2.intercept + fit2.slopes.reduce((a2, m, j) => a2 + m * (obs[j] ?? 0), 0));
23593
23617
  if (omitted(args, 2)) {
23594
23618
  const out2 = lay.x.map(predict);
23595
23619
  return new Matrix(lay.column ? out2.map((v) => [v]) : [out2]);
23596
23620
  }
23597
23621
  const target = numbersOf2(ctx, args[2]);
23598
- if (fit.slopes.length === 1) return new Matrix(target.map((r) => r.map((v) => predict([v]))));
23622
+ if (fit2.slopes.length === 1) return new Matrix(target.map((r) => r.map((v) => predict([v]))));
23599
23623
  const observations = asObservations(target, lay.column);
23600
- if ((observations[0]?.length ?? 0) !== fit.slopes.length) fail(ERR.REF);
23624
+ if ((observations[0]?.length ?? 0) !== fit2.slopes.length) fail(ERR.REF);
23601
23625
  const out = observations.map(predict);
23602
23626
  return new Matrix(lay.column ? out.map((v) => [v]) : [out]);
23603
23627
  }
@@ -23616,8 +23640,8 @@ var REGRESSION_FUNCTIONS = [
23616
23640
  4,
23617
23641
  (args, ctx) => {
23618
23642
  const lay = layout2(ctx, args);
23619
- const fit = fitLeastSquares(lay.x, lay.y, withConst(args, 2));
23620
- return coefficientTable(fit, !omitted(args, 3) && bool(args[3]), (v) => v);
23643
+ const fit2 = fitLeastSquares(lay.x, lay.y, withConst(args, 2));
23644
+ return coefficientTable(fit2, !omitted(args, 3) && bool(args[3]), (v) => v);
23621
23645
  },
23622
23646
  ARGS
23623
23647
  ),
@@ -23630,11 +23654,11 @@ var REGRESSION_FUNCTIONS = [
23630
23654
  4,
23631
23655
  (args, ctx) => {
23632
23656
  const lay = logs(layout2(ctx, args));
23633
- const fit = fitLeastSquares(lay.x, lay.y, withConst(args, 2));
23657
+ const fit2 = fitLeastSquares(lay.x, lay.y, withConst(args, 2));
23634
23658
  const stats = !omitted(args, 3) && bool(args[3]);
23635
- const table2 = coefficientTable(fit, stats, Math.exp);
23659
+ const table2 = coefficientTable(fit2, stats, Math.exp);
23636
23660
  if (!stats) return table2;
23637
- const plain2 = coefficientTable(fit, true, (v) => v).data;
23661
+ const plain2 = coefficientTable(fit2, true, (v) => v).data;
23638
23662
  return new Matrix([table2.data[0] ?? [], ...plain2.slice(1)]);
23639
23663
  },
23640
23664
  ARGS
@@ -23648,8 +23672,8 @@ var REGRESSION_FUNCTIONS = [
23648
23672
  4,
23649
23673
  (args, ctx) => {
23650
23674
  const lay = layout2(ctx, args);
23651
- const fit = fitLeastSquares(lay.x, lay.y, withConst(args, 3));
23652
- return predictions(ctx, args, lay, fit, (v) => v);
23675
+ const fit2 = fitLeastSquares(lay.x, lay.y, withConst(args, 3));
23676
+ return predictions(ctx, args, lay, fit2, (v) => v);
23653
23677
  },
23654
23678
  ARGS
23655
23679
  ),
@@ -23662,8 +23686,8 @@ var REGRESSION_FUNCTIONS = [
23662
23686
  4,
23663
23687
  (args, ctx) => {
23664
23688
  const lay = logs(layout2(ctx, args));
23665
- const fit = fitLeastSquares(lay.x, lay.y, withConst(args, 3));
23666
- return predictions(ctx, args, lay, fit, Math.exp);
23689
+ const fit2 = fitLeastSquares(lay.x, lay.y, withConst(args, 3));
23690
+ return predictions(ctx, args, lay, fit2, Math.exp);
23667
23691
  },
23668
23692
  ARGS
23669
23693
  )
@@ -24429,8 +24453,8 @@ var STATISTICAL_MORE = [
24429
24453
  (args, ctx) => {
24430
24454
  const x = num2(args[0]);
24431
24455
  const { xs, ys } = pairedNumbers(ctx, args[2] ?? null, args[1] ?? null);
24432
- const fit = linearFit(xs, ys);
24433
- return fit.intercept + fit.slope * x;
24456
+ const fit2 = linearFit(xs, ys);
24457
+ return fit2.intercept + fit2.slope * x;
24434
24458
  },
24435
24459
  ["value", "any"]
24436
24460
  )
@@ -26408,15 +26432,15 @@ var push2 = (c2, area) => {
26408
26432
  function spans(areas) {
26409
26433
  const boxes = /* @__PURE__ */ new Map();
26410
26434
  for (const { sheet, range } of areas) {
26411
- const box2 = boxes.get(sheet);
26412
- if (!box2) {
26435
+ const box3 = boxes.get(sheet);
26436
+ if (!box3) {
26413
26437
  boxes.set(sheet, { sheet, range: { start: { ...range.start }, end: { ...range.end } } });
26414
26438
  continue;
26415
26439
  }
26416
- box2.range.start.row = Math.min(box2.range.start.row, range.start.row);
26417
- box2.range.start.col = Math.min(box2.range.start.col, range.start.col);
26418
- box2.range.end.row = Math.max(box2.range.end.row, range.end.row);
26419
- box2.range.end.col = Math.max(box2.range.end.col, range.end.col);
26440
+ box3.range.start.row = Math.min(box3.range.start.row, range.start.row);
26441
+ box3.range.start.col = Math.min(box3.range.start.col, range.start.col);
26442
+ box3.range.end.row = Math.max(box3.range.end.row, range.end.row);
26443
+ box3.range.end.col = Math.max(box3.range.end.col, range.end.col);
26420
26444
  }
26421
26445
  return [...boxes.values()];
26422
26446
  }
@@ -27966,12 +27990,12 @@ function within(spec2, range) {
27966
27990
  start: { row: spec2.start.row, col: spec2.start.col },
27967
27991
  end: { row: spec2.end.row, col: spec2.end.col }
27968
27992
  });
27969
- const box2 = normalizeRange(range);
27970
- return r.start.row >= box2.start.row && r.end.row <= box2.end.row && r.start.col >= box2.start.col && r.end.col <= box2.end.col;
27993
+ const box3 = normalizeRange(range);
27994
+ return r.start.row >= box3.start.row && r.end.row <= box3.end.row && r.start.col >= box3.start.col && r.end.col <= box3.end.col;
27971
27995
  }
27972
- var shifted = (box2, dRow, dCol) => ({
27973
- start: { row: box2.start.row + dRow, col: box2.start.col + dCol },
27974
- end: { row: box2.end.row + dRow, col: box2.end.col + dCol }
27996
+ var shifted = (box3, dRow, dCol) => ({
27997
+ start: { row: box3.start.row + dRow, col: box3.start.col + dCol },
27998
+ end: { row: box3.end.row + dRow, col: box3.end.col + dCol }
27975
27999
  });
27976
28000
  function withPrefix(sheet, body) {
27977
28001
  return sheet === void 0 ? body : prefixText({ sheet }) + body;
@@ -29334,7 +29358,7 @@ var headerFooterOf = (page) => {
29334
29358
  };
29335
29359
  function setupXml(sheet, page) {
29336
29360
  const source2 = snapshotElement(sheet, "pageSetup");
29337
- const fit = page.fitToWidth !== void 0 || page.fitToHeight !== void 0;
29361
+ const fit2 = page.fitToWidth !== void 0 || page.fitToHeight !== void 0;
29338
29362
  const pick4 = (p) => ({
29339
29363
  orientation: p.orientation,
29340
29364
  paperSize: p.paperSize,
@@ -29342,13 +29366,13 @@ function setupXml(sheet, page) {
29342
29366
  fitToWidth: p.fitToWidth,
29343
29367
  fitToHeight: p.fitToHeight
29344
29368
  });
29345
- const modelled = fit || page.orientation !== void 0 || page.paperSize !== void 0 || page.scale !== void 0;
29369
+ const modelled = fit2 || page.orientation !== void 0 || page.paperSize !== void 0 || page.scale !== void 0;
29346
29370
  if (!source2 && !modelled) return "";
29347
29371
  if (source2) {
29348
- const before = readPageSetup(void 0, source2, void 0, fit) ?? {};
29372
+ const before = readPageSetup(void 0, source2, void 0, fit2) ?? {};
29349
29373
  if (sameModel(pick4(before), pick4(page))) return snapshotXml(sheet, "pageSetup") ?? "";
29350
29374
  }
29351
- const fitValues = fit ? { fitToWidth: page.fitToWidth, fitToHeight: page.fitToHeight } : {};
29375
+ const fitValues = fit2 ? { fitToWidth: page.fitToWidth, fitToHeight: page.fitToHeight } : {};
29352
29376
  return `<pageSetup${mergedAttrs(source2, {
29353
29377
  paperSize: page.paperSize,
29354
29378
  scale: page.scale,
@@ -29942,17 +29966,17 @@ function writeSheetDrawing(ctx, sheet, partName, rels, sourceDrawing) {
29942
29966
  var sqref = (ranges) => ranges.map((range) => formatRange(range)).join(" ");
29943
29967
  function sheetPrXml(sheet) {
29944
29968
  const source2 = snapshotElement(sheet, "sheetPr");
29945
- const fit = sheet.pageSetup?.fitToWidth !== void 0 || sheet.pageSetup?.fitToHeight !== void 0;
29946
- if (source2 && sameModel(readTabColor(source2), sheet.tabColor) && readFitToPage(source2) === fit)
29969
+ const fit2 = sheet.pageSetup?.fitToWidth !== void 0 || sheet.pageSetup?.fitToHeight !== void 0;
29970
+ if (source2 && sameModel(readTabColor(source2), sheet.tabColor) && readFitToPage(source2) === fit2)
29947
29971
  return snapshotXml(sheet, "sheetPr") ?? "";
29948
29972
  const sourceAttrs = source2 ? Array.from(source2.attributes).filter((a2) => !a2.name.startsWith("xmlns")).map((a2) => ` ${a2.name}="${escapeAttr3(a2.value)}"`).join("") : "";
29949
29973
  const children4 = source2 ? elements(source2) : [];
29950
29974
  const outline2 = children4.find((node) => node.localName === "outlinePr");
29951
29975
  const setUp = children4.find((node) => node.localName === "pageSetUpPr");
29952
29976
  let setUpXml = "";
29953
- if (setUp || fit) {
29977
+ if (setUp || fit2) {
29954
29978
  const keep2 = setUp ? Array.from(setUp.attributes).filter((a2) => a2.name !== "fitToPage" && !a2.name.startsWith("xmlns")).map((a2) => ` ${a2.name}="${escapeAttr3(a2.value)}"`).join("") : "";
29955
- setUpXml = `<pageSetUpPr${keep2}${fit ? ' fitToPage="1"' : ""}/>`;
29979
+ setUpXml = `<pageSetUpPr${keep2}${fit2 ? ' fitToPage="1"' : ""}/>`;
29956
29980
  if (setUpXml === "<pageSetUpPr/>") setUpXml = "";
29957
29981
  }
29958
29982
  const inner2 = colorXml(sheet.tabColor, "tabColor") + (outline2 ? outerXml(outline2) : "") + setUpXml;
@@ -31725,8 +31749,10 @@ function shiftSheetContent(sheet, shift2, band) {
31725
31749
  if (sheet.autoFilter) {
31726
31750
  const old = sheet.autoFilter.range;
31727
31751
  const range = moveRange(old);
31728
- if (!range) delete sheet.autoFilter;
31729
- else {
31752
+ if (!range) {
31753
+ delete sheet.autoFilter;
31754
+ clearFilteredRows(sheet);
31755
+ } else {
31730
31756
  const filter2 = { ...sheet.autoFilter, range };
31731
31757
  if (shift2.axis === "col" && filter2.columns)
31732
31758
  filter2.columns = filter2.columns.flatMap((fc) => {
@@ -31877,6 +31903,9 @@ function shiftAxis(ctx, s, axis, at2, count2, insert) {
31877
31903
  const sheet = sheetAt(ctx.workbook, s);
31878
31904
  const noun = axis === "row" ? count2 === 1 ? "row" : "rows" : count2 === 1 ? "column" : "columns";
31879
31905
  const shift2 = { axis, at: at2, count: insert ? count2 : -count2 };
31906
+ const info = { sheet: s, structural: true };
31907
+ if (!sheet.autoFilter || shiftRange(sheet.autoFilter.range, shift2))
31908
+ info.calc = { kind: "shift", sheet: s, shift: shift2 };
31880
31909
  ctx.run(
31881
31910
  `${insert ? "Insert" : "Delete"} ${noun}`,
31882
31911
  "structure",
@@ -31885,7 +31914,7 @@ function shiftAxis(ctx, s, axis, at2, count2, insert) {
31885
31914
  applyAxisShift(ctx, sheet, shift2);
31886
31915
  if (insert) inheritFormats(sheet, axis, at2, count2);
31887
31916
  },
31888
- { sheet: s, structural: true, calc: { kind: "shift", sheet: s, shift: shift2 } }
31917
+ info
31889
31918
  );
31890
31919
  }
31891
31920
  var insertRows = (ctx, s, at2, count2) => shiftAxis(ctx, s, "row", at2, count2, true);
@@ -32936,9 +32965,9 @@ function setRowHeight(ctx, s, rows, height) {
32936
32965
  for (const row2 of rows) {
32937
32966
  const info = { ...sheet.rowInfo.get(row2) };
32938
32967
  if (height === "auto") {
32939
- const fit = fitRowHeight(ctx, sheet, row2);
32940
- if (fit === sheet.defaultRowHeight) delete info.height;
32941
- else info.height = fit;
32968
+ const fit2 = fitRowHeight(ctx, sheet, row2);
32969
+ if (fit2 === sheet.defaultRowHeight) delete info.height;
32970
+ else info.height = fit2;
32942
32971
  delete info.customHeight;
32943
32972
  } else {
32944
32973
  const h2 = Math.max(0, Math.min(MAX_HEIGHT, height));
@@ -32982,11 +33011,12 @@ function setHidden(ctx, s, axis, indices, hidden) {
32982
33011
  continue;
32983
33012
  }
32984
33013
  const filter2 = sheet.autoFilter;
32985
- if (filter2?.columns?.length && row2 > filter2.range.start.row && row2 <= filter2.range.end.row)
33014
+ if (hidden && filter2?.columns?.length && row2 > filter2.range.start.row && row2 <= filter2.range.end.row)
32986
33015
  info.filteredOut = false;
32987
33016
  if (hidden) info.hidden = true;
32988
33017
  else {
32989
33018
  delete info.hidden;
33019
+ delete info.filteredOut;
32990
33020
  if (info.height === 0) delete info.height;
32991
33021
  }
32992
33022
  if (Object.keys(info).length) sheet.rowInfo.set(row2, info);
@@ -33139,22 +33169,7 @@ function applyFilter(ctx, sheet, filter2) {
33139
33169
  const { range } = filter2;
33140
33170
  for (let row2 = range.start.row + 1; row2 <= range.end.row; row2++) {
33141
33171
  const visible = rowMatchesFilter(ctx.workbook, sheet, row2, filter2);
33142
- const info = { ...sheet.rowInfo.get(row2) };
33143
- const manual = info.manuallyHidden || info.hidden && !info.filteredOut;
33144
- if (visible) {
33145
- delete info.filteredOut;
33146
- delete info.manuallyHidden;
33147
- if (manual) {
33148
- info.hidden = true;
33149
- if (filter2.columns?.length) info.filteredOut = false;
33150
- } else delete info.hidden;
33151
- } else {
33152
- info.hidden = true;
33153
- info.filteredOut = true;
33154
- if (manual) info.manuallyHidden = true;
33155
- }
33156
- if (Object.keys(info).length) sheet.rowInfo.set(row2, info);
33157
- else sheet.rowInfo.delete(row2);
33172
+ setRowFiltered(sheet, row2, !visible, !!filter2.columns?.length);
33158
33173
  }
33159
33174
  }
33160
33175
  function setAutoFilter(ctx, s, range) {
@@ -37408,9 +37423,9 @@ function wrappedLineCount(text2, width, measure) {
37408
37423
  current = word.trimStart();
37409
37424
  }
37410
37425
  while (current.length > 1 && measure(current) > width) {
37411
- let fit = 1;
37412
- while (fit < current.length && measure(current.slice(0, fit + 1)) <= width) fit++;
37413
- current = current.slice(fit);
37426
+ let fit2 = 1;
37427
+ while (fit2 < current.length && measure(current.slice(0, fit2 + 1)) <= width) fit2++;
37428
+ current = current.slice(fit2);
37414
37429
  lines++;
37415
37430
  }
37416
37431
  }
@@ -37452,8 +37467,8 @@ function autoGrowRows(ctx, s, rows, measure = approximateMeasure) {
37452
37467
  for (const row2 of new Set(rows)) {
37453
37468
  const info = sheet.rowInfo.get(row2);
37454
37469
  if (info?.customHeight || info?.hidden) continue;
37455
- const fit = Math.min(MAX_HEIGHT2, autoFitRowHeight(ctx.workbook, s, row2, measure));
37456
- const next = Math.abs(fit - sheet.defaultRowHeight) < 1e-9 ? void 0 : fit;
37470
+ const fit2 = Math.min(MAX_HEIGHT2, autoFitRowHeight(ctx.workbook, s, row2, measure));
37471
+ const next = Math.abs(fit2 - sheet.defaultRowHeight) < 1e-9 ? void 0 : fit2;
37457
37472
  const current = info?.height;
37458
37473
  if (current === next) continue;
37459
37474
  if (current !== void 0 && next !== void 0 && Math.abs(current - next) < 1e-9) continue;
@@ -46212,6 +46227,203 @@ async function replaceScopedTextRanges(pkg, pagePaths, roots, document, edit, ch
46212
46227
  return true;
46213
46228
  }
46214
46229
 
46230
+ // visio/basic-shapes.ts
46231
+ var VISIO_BASIC_SHAPES = [
46232
+ "rectangle",
46233
+ "square",
46234
+ "triangle",
46235
+ "right-triangle",
46236
+ "pentagon",
46237
+ "hexagon",
46238
+ "octagon",
46239
+ "star",
46240
+ "diamond",
46241
+ "rounded-rectangle",
46242
+ "cross",
46243
+ "parallelogram",
46244
+ "trapezoid",
46245
+ "can",
46246
+ "cube",
46247
+ "chevron"
46248
+ ];
46249
+ var isVisioBasicShape = (value) => VISIO_BASIC_SHAPES.includes(value);
46250
+ function fit(points) {
46251
+ const xs = points.map(([x]) => x), ys = points.map(([, y]) => y);
46252
+ const left2 = Math.min(...xs), bottom = Math.min(...ys);
46253
+ const width = Math.max(...xs) - left2, height = Math.max(...ys) - bottom;
46254
+ return points.map(([x, y]) => [(x - left2) / width, (y - bottom) / height]);
46255
+ }
46256
+ function polygon(count2, inner2) {
46257
+ const steps = inner2 === void 0 ? count2 : count2 * 2;
46258
+ return fit(
46259
+ Array.from({ length: steps }, (_, index2) => {
46260
+ const radius = inner2 !== void 0 && index2 % 2 ? inner2 : 1;
46261
+ const angle = Math.PI / 2 + index2 * 2 * Math.PI / steps;
46262
+ return [radius * Math.cos(angle), radius * Math.sin(angle)];
46263
+ })
46264
+ );
46265
+ }
46266
+ function arc(cy, ry, from, to) {
46267
+ const segments = 12;
46268
+ return Array.from({ length: segments + 1 }, (_, index2) => {
46269
+ const angle = from + (to - from) * index2 / segments;
46270
+ return [0.5 + 0.5 * Math.cos(angle), cy + ry * Math.sin(angle)];
46271
+ });
46272
+ }
46273
+ var box2 = [
46274
+ [0, 0],
46275
+ [1, 0],
46276
+ [1, 1],
46277
+ [0, 1]
46278
+ ];
46279
+ var LID = 0.2;
46280
+ var CUT = 1 / (2 + Math.SQRT2);
46281
+ var OUTLINES = {
46282
+ rectangle: { paths: [box2] },
46283
+ square: { paths: [box2] },
46284
+ triangle: {
46285
+ paths: [
46286
+ [
46287
+ [0, 0],
46288
+ [1, 0],
46289
+ [0.5, 1]
46290
+ ]
46291
+ ]
46292
+ },
46293
+ "right-triangle": {
46294
+ paths: [
46295
+ [
46296
+ [0, 0],
46297
+ [1, 0],
46298
+ [0, 1]
46299
+ ]
46300
+ ]
46301
+ },
46302
+ pentagon: { paths: [polygon(5)] },
46303
+ hexagon: {
46304
+ paths: [
46305
+ [
46306
+ [0.25, 0],
46307
+ [0.75, 0],
46308
+ [1, 0.5],
46309
+ [0.75, 1],
46310
+ [0.25, 1],
46311
+ [0, 0.5]
46312
+ ]
46313
+ ]
46314
+ },
46315
+ octagon: {
46316
+ paths: [
46317
+ [
46318
+ [CUT, 0],
46319
+ [1 - CUT, 0],
46320
+ [1, CUT],
46321
+ [1, 1 - CUT],
46322
+ [1 - CUT, 1],
46323
+ [CUT, 1],
46324
+ [0, 1 - CUT],
46325
+ [0, CUT]
46326
+ ]
46327
+ ]
46328
+ },
46329
+ star: { paths: [polygon(5, 0.382)] },
46330
+ diamond: {
46331
+ paths: [
46332
+ [
46333
+ [0.5, 0],
46334
+ [1, 0.5],
46335
+ [0.5, 1],
46336
+ [0, 0.5]
46337
+ ]
46338
+ ]
46339
+ },
46340
+ "rounded-rectangle": { paths: [box2], rounding: 0.15 },
46341
+ cross: {
46342
+ paths: [
46343
+ [
46344
+ [1 / 3, 0],
46345
+ [2 / 3, 0],
46346
+ [2 / 3, 1 / 3],
46347
+ [1, 1 / 3],
46348
+ [1, 2 / 3],
46349
+ [2 / 3, 2 / 3],
46350
+ [2 / 3, 1],
46351
+ [1 / 3, 1],
46352
+ [1 / 3, 2 / 3],
46353
+ [0, 2 / 3],
46354
+ [0, 1 / 3],
46355
+ [1 / 3, 1 / 3]
46356
+ ]
46357
+ ]
46358
+ },
46359
+ parallelogram: {
46360
+ paths: [
46361
+ [
46362
+ [0, 0],
46363
+ [0.75, 0],
46364
+ [1, 1],
46365
+ [0.25, 1]
46366
+ ]
46367
+ ]
46368
+ },
46369
+ trapezoid: {
46370
+ paths: [
46371
+ [
46372
+ [0, 0],
46373
+ [1, 0],
46374
+ [0.75, 1],
46375
+ [0.25, 1]
46376
+ ]
46377
+ ]
46378
+ },
46379
+ can: {
46380
+ paths: [
46381
+ // The body: down the left side, round the front of the base, up the right side and
46382
+ // back along the front of the lid.
46383
+ [...arc(LID / 2, LID / 2, Math.PI, 2 * Math.PI), ...arc(1 - LID / 2, LID / 2, 0, -Math.PI)],
46384
+ // The lid, drawn over the body.
46385
+ arc(1 - LID / 2, LID / 2, 0, 2 * Math.PI).slice(0, -1)
46386
+ ]
46387
+ },
46388
+ cube: {
46389
+ paths: [
46390
+ [
46391
+ [0, 0],
46392
+ [0.75, 0],
46393
+ [0.75, 0.75],
46394
+ [0, 0.75]
46395
+ ],
46396
+ [
46397
+ [0, 0.75],
46398
+ [0.75, 0.75],
46399
+ [1, 1],
46400
+ [0.25, 1]
46401
+ ],
46402
+ [
46403
+ [0.75, 0],
46404
+ [1, 0.25],
46405
+ [1, 1],
46406
+ [0.75, 0.75]
46407
+ ]
46408
+ ]
46409
+ },
46410
+ chevron: {
46411
+ paths: [
46412
+ [
46413
+ [0, 0],
46414
+ [0.75, 0],
46415
+ [1, 0.5],
46416
+ [0.75, 1],
46417
+ [0, 1],
46418
+ [0.25, 0.5]
46419
+ ]
46420
+ ]
46421
+ }
46422
+ };
46423
+ function visioBasicShapeOutline(shape2) {
46424
+ return OUTLINES[shape2];
46425
+ }
46426
+
46215
46427
  // visio/edit-text-range-commands.ts
46216
46428
  var invalidXmlText = /[\u0000-\u0008\u000b\u000c\u000d\u000e-\u001f\ufffe\uffff]|[\ud800-\udbff](?![\udc00-\udfff])|(?<![\ud800-\udbff])[\udc00-\udfff]/u;
46217
46429
  function textRangeBoundary(text2, offset2) {
@@ -46578,7 +46790,10 @@ function snapshotVisioEdits(edits, maxEdits, maxText) {
46578
46790
  return { ...target, type: edit.type, beginX, beginY, endX, endY };
46579
46791
  }
46580
46792
  case "create-rectangle":
46581
- case "create-ellipse":
46793
+ case "create-ellipse": {
46794
+ const shape2 = edit.type === "create-rectangle" ? edit.shape : void 0;
46795
+ if (shape2 !== void 0 && !isVisioBasicShape(shape2))
46796
+ fail2("INVALID_EDIT", "Unknown basic shape.");
46582
46797
  return {
46583
46798
  ...target,
46584
46799
  type: edit.type,
@@ -46586,8 +46801,10 @@ function snapshotVisioEdits(edits, maxEdits, maxText) {
46586
46801
  y: numeric5(edit.y),
46587
46802
  width: numeric5(edit.width, true),
46588
46803
  height: numeric5(edit.height, true),
46589
- ...edit.text === void 0 ? {} : { text: text2(edit.text) }
46804
+ ...edit.text === void 0 ? {} : { text: text2(edit.text) },
46805
+ ...shape2 === void 0 ? {} : { shape: shape2 }
46590
46806
  };
46807
+ }
46591
46808
  case "rotate-shape":
46592
46809
  return { ...target, type: edit.type, angle: numeric5(edit.angle) };
46593
46810
  case "flip-shape":
@@ -47001,24 +47218,25 @@ function createRectangle(root, document, edit) {
47001
47218
  }
47002
47219
  const doc = root.ownerDocument;
47003
47220
  const node = (name) => doc.createElementNS(root.namespaceURI, name);
47004
- const section = node("Section");
47005
- section.setAttribute("N", "Geometry");
47006
- section.setAttribute("IX", "0");
47007
- for (const [index2, [x, y]] of [
47008
- [0, 0],
47009
- [1, 0],
47010
- [1, 1],
47011
- [0, 1],
47012
- [0, 0]
47013
- ].entries()) {
47014
- const row2 = node("Row");
47015
- row2.setAttribute("IX", String(index2 + 1));
47016
- row2.setAttribute("T", index2 ? "RelLineTo" : "RelMoveTo");
47017
- setCell(row2, "X", x);
47018
- setCell(row2, "Y", y);
47019
- section.appendChild(row2);
47221
+ const outline2 = visioBasicShapeOutline(
47222
+ edit.type === "create-rectangle" ? edit.shape ?? "rectangle" : "rectangle"
47223
+ );
47224
+ if (outline2.rounding)
47225
+ setCell(shape2, "Rounding", outline2.rounding * Math.min(edit.width, edit.height));
47226
+ for (const [sectionIndex, points] of outline2.paths.entries()) {
47227
+ const section = node("Section");
47228
+ section.setAttribute("N", "Geometry");
47229
+ section.setAttribute("IX", String(sectionIndex));
47230
+ for (const [index2, [x, y]] of [...points, points[0]].entries()) {
47231
+ const row2 = node("Row");
47232
+ row2.setAttribute("IX", String(index2 + 1));
47233
+ row2.setAttribute("T", index2 ? "RelLineTo" : "RelMoveTo");
47234
+ setCell(row2, "X", x);
47235
+ setCell(row2, "Y", y);
47236
+ section.appendChild(row2);
47237
+ }
47238
+ shape2.appendChild(section);
47020
47239
  }
47021
- shape2.appendChild(section);
47022
47240
  const text2 = node("Text");
47023
47241
  text2.appendChild(doc.createTextNode(encodeVisioPlainText(edit.text ?? "")));
47024
47242
  shape2.appendChild(text2);