ooxml-core 1.35.0 → 1.36.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.
Files changed (49) hide show
  1. package/dist/automation/index.cjs +1290 -825
  2. package/dist/automation/index.mjs +1290 -825
  3. package/dist/visio/bevel-3d.d.ts +31 -4
  4. package/dist/visio/bevel-3d.d.ts.map +1 -1
  5. package/dist/visio/cff-author.d.ts +14 -0
  6. package/dist/visio/cff-author.d.ts.map +1 -0
  7. package/dist/visio/cff-masters.d.ts +11 -0
  8. package/dist/visio/cff-masters.d.ts.map +1 -1
  9. package/dist/visio/edit-commands.d.ts +7 -0
  10. package/dist/visio/edit-commands.d.ts.map +1 -1
  11. package/dist/visio/edit-formatting-commands.d.ts +6 -0
  12. package/dist/visio/edit-formatting-commands.d.ts.map +1 -1
  13. package/dist/visio/edit-formatting-paint.d.ts.map +1 -1
  14. package/dist/visio/edit-instance-geometry.d.ts.map +1 -1
  15. package/dist/visio/edit-instance-recalculate.d.ts +6 -1
  16. package/dist/visio/edit-instance-recalculate.d.ts.map +1 -1
  17. package/dist/visio/edit-shape-create.d.ts.map +1 -1
  18. package/dist/visio/edit-stencil-connector.d.ts.map +1 -1
  19. package/dist/visio/edit-swimlane-stamp.d.ts +22 -0
  20. package/dist/visio/edit-swimlane-stamp.d.ts.map +1 -0
  21. package/dist/visio/edit.d.ts.map +1 -1
  22. package/dist/visio/index.cjs +1338 -568
  23. package/dist/visio/index.d.ts +3 -1
  24. package/dist/visio/index.d.ts.map +1 -1
  25. package/dist/visio/index.mjs +1331 -569
  26. package/dist/visio/model.d.ts +6 -2
  27. package/dist/visio/model.d.ts.map +1 -1
  28. package/dist/visio/path-segments.d.ts +25 -0
  29. package/dist/visio/path-segments.d.ts.map +1 -0
  30. package/dist/visio/shape-sections.d.ts +4 -3
  31. package/dist/visio/shape-sections.d.ts.map +1 -1
  32. package/dist/visio/solid-3d.d.ts +55 -0
  33. package/dist/visio/solid-3d.d.ts.map +1 -0
  34. package/dist/visio/style.d.ts.map +1 -1
  35. package/dist/visio/theme-solid.d.ts +21 -0
  36. package/dist/visio/theme-solid.d.ts.map +1 -0
  37. package/dist/visio/ui/data-visualizer-edits.d.ts +1 -0
  38. package/dist/visio/ui/data-visualizer-edits.d.ts.map +1 -1
  39. package/dist/visio/ui/edit-commands.d.ts.map +1 -1
  40. package/dist/visio/ui/index.cjs +1188 -571
  41. package/dist/visio/ui/index.mjs +1188 -572
  42. package/dist/visio/ui/org-chart-belt.d.ts +20 -0
  43. package/dist/visio/ui/org-chart-belt.d.ts.map +1 -0
  44. package/dist/visio/ui/org-chart-edit.d.ts +8 -1
  45. package/dist/visio/ui/org-chart-edit.d.ts.map +1 -1
  46. package/dist/visio/ui/org-chart-import.d.ts.map +1 -1
  47. package/dist/visio/ui/scene-validation.d.ts.map +1 -1
  48. package/dist/visio/ui/snapshot-scene.d.ts.map +1 -1
  49. package/package.json +1 -1
@@ -83,8 +83,8 @@ function sanitizeVisioPresence(raw2) {
83
83
  }
84
84
  if (Array.isArray(raw2.selection)) {
85
85
  const ids = /* @__PURE__ */ new Set();
86
- for (const entry3 of raw2.selection) {
87
- const id4 = clean(entry3);
86
+ for (const entry4 of raw2.selection) {
87
+ const id4 = clean(entry4);
88
88
  if (id4) ids.add(id4);
89
89
  if (ids.size >= VISIO_PRESENCE_MAX_SELECTION) break;
90
90
  }
@@ -333,7 +333,7 @@ var DocumentHistory = class {
333
333
  }
334
334
  #trim() {
335
335
  const retained = () => /* @__PURE__ */ new Set([this.original, ...this.#entries]);
336
- while (this.#entries.length > this.#maxEntries || [...retained()].reduce((sum, entry3) => sum + entry3.bytes.byteLength, 0) > EDIT_HISTORY_LIMITS.maxBytes) {
336
+ while (this.#entries.length > this.#maxEntries || [...retained()].reduce((sum, entry4) => sum + entry4.bytes.byteLength, 0) > EDIT_HISTORY_LIMITS.maxBytes) {
337
337
  if (this.#index === 0) throw new Error("Source snapshots exceed the retained history limit.");
338
338
  this.#entries.shift();
339
339
  this.#index--;
@@ -433,13 +433,13 @@ function searchDocumentText(index3, query) {
433
433
  let resultsTruncated = false;
434
434
  if (query.trim()) {
435
435
  const folded = query.toLowerCase();
436
- for (const entry3 of index3.entries) {
437
- if (!entry3.foldedText.includes(folded)) continue;
436
+ for (const entry4 of index3.entries) {
437
+ if (!entry4.foldedText.includes(folded)) continue;
438
438
  if (results.length === TEXT_SEARCH_LIMITS.results) {
439
439
  resultsTruncated = true;
440
440
  break;
441
441
  }
442
- results.push(entry3.result);
442
+ results.push(entry4.result);
443
443
  }
444
444
  }
445
445
  return Object.freeze({
@@ -1816,8 +1816,8 @@ var VisioPackage = class _VisioPackage {
1816
1816
  this.entries = entries;
1817
1817
  this.limits = limits;
1818
1818
  this.deadline = deadline;
1819
- for (const entry3 of entries.values())
1820
- if (!entry3.directory) this.decodedNames.set(decodePath(entry3.name), entry3.name);
1819
+ for (const entry4 of entries.values())
1820
+ if (!entry4.directory) this.decodedNames.set(decodePath(entry4.name), entry4.name);
1821
1821
  }
1822
1822
  zip;
1823
1823
  entries;
@@ -1877,15 +1877,15 @@ var VisioPackage = class _VisioPackage {
1877
1877
  }
1878
1878
  /** The declared CRC-32 and size of a part, or an empty string when the package lacks it. */
1879
1879
  printOf(path3) {
1880
- const entry3 = this.entries.get(path3);
1881
- return entry3 && !entry3.directory ? `${entry3.crc}:${entry3.size}` : "";
1880
+ const entry4 = this.entries.get(path3);
1881
+ return entry4 && !entry4.directory ? `${entry4.crc}:${entry4.size}` : "";
1882
1882
  }
1883
1883
  has(path3) {
1884
1884
  this.noted?.add(path3);
1885
1885
  return this.entries.get(path3)?.directory === false;
1886
1886
  }
1887
1887
  paths() {
1888
- return [...this.entries.values()].filter((entry3) => !entry3.directory).map((entry3) => entry3.name);
1888
+ return [...this.entries.values()].filter((entry4) => !entry4.directory).map((entry4) => entry4.name);
1889
1889
  }
1890
1890
  async readXml(path3, expectedRoot) {
1891
1891
  this.check();
@@ -1907,9 +1907,9 @@ var VisioPackage = class _VisioPackage {
1907
1907
  this.check();
1908
1908
  this.noted?.add(path3);
1909
1909
  safePath(path3);
1910
- const entry3 = this.entries.get(path3);
1911
- if (!entry3 || entry3.directory) fail("MISSING_PART", `Missing package part: ${path3}`);
1912
- return entry3.size;
1910
+ const entry4 = this.entries.get(path3);
1911
+ if (!entry4 || entry4.directory) fail("MISSING_PART", `Missing package part: ${path3}`);
1912
+ return entry4.size;
1913
1913
  }
1914
1914
  /** Shared package-owned bytes. Treat the returned buffer as immutable. */
1915
1915
  async readBytes(path3) {
@@ -1926,8 +1926,8 @@ var VisioPackage = class _VisioPackage {
1926
1926
  return bytes;
1927
1927
  }
1928
1928
  async loadBytes(path3) {
1929
- const entry3 = this.entries.get(path3), file = this.zip.file(path3);
1930
- if (!entry3 || entry3.directory || !file)
1929
+ const entry4 = this.entries.get(path3), file = this.zip.file(path3);
1930
+ if (!entry4 || entry4.directory || !file)
1931
1931
  return fail("MISSING_PART", `Missing package part: ${path3}`);
1932
1932
  return new Promise((resolve, reject) => {
1933
1933
  const stream = file.internalStream("uint8array");
@@ -1958,9 +1958,9 @@ var VisioPackage = class _VisioPackage {
1958
1958
  fail("LIMIT_ENTRY", `Actual inflated entry exceeds limit: ${path3}`);
1959
1959
  if (this.totalOutput > this.limits.maxTotalBytes)
1960
1960
  fail("LIMIT_TOTAL", "Actual inflated ZIP total exceeds limit");
1961
- if (size3 > Math.max(1, entry3.compressed) * this.limits.maxCompressionRatio)
1961
+ if (size3 > Math.max(1, entry4.compressed) * this.limits.maxCompressionRatio)
1962
1962
  fail("LIMIT_RATIO", `Actual ZIP compression ratio exceeds limit: ${path3}`);
1963
- if (size3 > entry3.size)
1963
+ if (size3 > entry4.size)
1964
1964
  fail("ZIP_MISMATCH", `Actual ZIP entry exceeds declared size: ${path3}`);
1965
1965
  crc = crc32(chunk, crc);
1966
1966
  chunks.push(chunk);
@@ -1969,7 +1969,7 @@ var VisioPackage = class _VisioPackage {
1969
1969
  }
1970
1970
  }).on("error", abort).on("end", () => {
1971
1971
  if (settled) return;
1972
- if (size3 !== entry3.size || (crc ^ 4294967295) >>> 0 !== entry3.crc) {
1972
+ if (size3 !== entry4.size || (crc ^ 4294967295) >>> 0 !== entry4.crc) {
1973
1973
  abort(new VisioPackageError("ZIP_MISMATCH", `Inflated size or CRC mismatch: ${path3}`));
1974
1974
  return;
1975
1975
  }
@@ -4596,9 +4596,28 @@ function createLine(root2, document, edit) {
4596
4596
  setCell(row2, "Y", 0);
4597
4597
  section3.appendChild(row2);
4598
4598
  }
4599
+ if (edit.text !== void 0) appendLineTextCells(shape, width);
4599
4600
  shape.appendChild(section3);
4601
+ if (edit.text !== void 0) {
4602
+ const text9 = root2.ownerDocument.createElementNS(root2.namespaceURI, "Text");
4603
+ text9.appendChild(root2.ownerDocument.createTextNode(encodeVisioPlainText(edit.text)));
4604
+ shape.appendChild(text9);
4605
+ }
4600
4606
  return shape;
4601
4607
  }
4608
+ function appendLineTextCells(shape, width) {
4609
+ const box6 = Math.max(0.5, Math.min(width, 1.2));
4610
+ const entries = [
4611
+ ["TxtPinX", width / 2, "Width*0.5"],
4612
+ ["TxtPinY", 0, "Height*0.5"],
4613
+ ["TxtWidth", box6],
4614
+ ["TxtHeight", 0.25],
4615
+ ["TxtLocPinX", box6 / 2, "TxtWidth*0.5"],
4616
+ ["TxtLocPinY", 0.125, "TxtHeight*0.5"],
4617
+ ["TxtAngle", 0, "-Angle"]
4618
+ ];
4619
+ for (const [name3, value3, formula2] of entries) setCell(shape, name3, value3, formula2);
4620
+ }
4602
4621
 
4603
4622
  // visio/path-fit.ts
4604
4623
  var finite = (point2) => Number.isFinite(point2.x) && Number.isFinite(point2.y);
@@ -7365,9 +7384,9 @@ function roundedRectanglePath(points2, rounding, point2) {
7365
7384
  const sweep = a2[0] * b[1] - a2[1] * b[0] > 0 ? 1 : 0;
7366
7385
  const start = after[0], commands = [`M ${point2(start[0], start[1])}`];
7367
7386
  for (let i = 1; i <= 4; i++) {
7368
- const entry3 = before[i % 4], exit2 = after[i % 4];
7387
+ const entry4 = before[i % 4], exit2 = after[i % 4];
7369
7388
  commands.push(
7370
- `L ${point2(entry3[0], entry3[1])}`,
7389
+ `L ${point2(entry4[0], entry4[1])}`,
7371
7390
  `A ${point2(radius, radius)} 0 0 ${sweep} ${point2(exit2[0], exit2[1])}`
7372
7391
  );
7373
7392
  }
@@ -7413,7 +7432,7 @@ function roundedOrthogonalPath(points2, radius, point2) {
7413
7432
  const radius2 = radii[i];
7414
7433
  if (!Number.isFinite(radius2) || radius2 < 1e-9) return void 0;
7415
7434
  const incoming = directions[i - 1], outgoing = directions[i];
7416
- const entry3 = [
7435
+ const entry4 = [
7417
7436
  vertex[0] - incoming[0] * radius2,
7418
7437
  vertex[1] - incoming[1] * radius2
7419
7438
  ];
@@ -7421,11 +7440,11 @@ function roundedOrthogonalPath(points2, radius, point2) {
7421
7440
  vertex[0] + outgoing[0] * radius2,
7422
7441
  vertex[1] + outgoing[1] * radius2
7423
7442
  ];
7424
- if (!entry3.every(Number.isFinite) || !exit2.every(Number.isFinite) || point2(...entry3) === point2(...vertex) || point2(...exit2) === point2(...vertex))
7443
+ if (!entry4.every(Number.isFinite) || !exit2.every(Number.isFinite) || point2(...entry4) === point2(...vertex) || point2(...exit2) === point2(...vertex))
7425
7444
  return void 0;
7426
7445
  const sweep = incoming[0] * outgoing[1] - incoming[1] * outgoing[0] > 0 ? 1 : 0;
7427
7446
  commands.push(
7428
- `L ${point2(...entry3)}`,
7447
+ `L ${point2(...entry4)}`,
7429
7448
  `A ${point2(radius2, radius2)} 0 0 ${sweep} ${point2(...exit2)}`
7430
7449
  );
7431
7450
  extraCommands++;
@@ -7741,13 +7760,17 @@ function effectiveNumber(cells4, name3, fallback) {
7741
7760
  fail("UNSUPPORTED_GEOMETRY_EDIT", `${name3} of the stencil shape is out of range.`);
7742
7761
  return value3;
7743
7762
  }
7744
- var sectionRows2 = (shape, name3) => children2(shape, "Section").filter((section3) => attribute2(section3, "N") === name3 && !deleted(section3)).flatMap((section3) => children2(section3, "Row"));
7763
+ var sectionRows2 = (shape, name3) => children2(shape, "Section").filter((section3) => attribute2(section3, "N") === name3 && !deleted(section3)).flatMap(
7764
+ (section3) => children2(section3, "Row").map((row2, position) => ({
7765
+ row: row2,
7766
+ index: attribute2(row2, "IX") === void 0 ? position : Number(attribute2(row2, "IX"))
7767
+ }))
7768
+ );
7745
7769
  function effectiveRows(shape, section3) {
7746
7770
  const rows = /* @__PURE__ */ new Map();
7747
7771
  const gone = /* @__PURE__ */ new Set();
7748
7772
  for (const source of [templates.get(shape), shape])
7749
- for (const row2 of sectionRows2(source, section3)) {
7750
- const index3 = Number(attribute2(row2, "IX") ?? "0");
7773
+ for (const { row: row2, index: index3 } of sectionRows2(source, section3)) {
7751
7774
  if (deleted(row2)) {
7752
7775
  gone.add(index3);
7753
7776
  continue;
@@ -8239,7 +8262,7 @@ var PASSIVE = /* @__PURE__ */ new Set([
8239
8262
  "Reviewer",
8240
8263
  "Annotation"
8241
8264
  ]);
8242
- var LENGTHS = /^(width|height|pinx|piny|locpinx|locpiny|txtpinx|txtpiny|txtwidth|txtheight|txtlocpinx|txtlocpiny|beginx|beginy|endx|endy)$/;
8265
+ var LENGTHS = /^(width|height|pinx|piny|locpinx|locpiny|txtpinx|txtpiny|txtwidth|txtheight|txtlocpinx|txtlocpiny|beginx|beginy|endx|endy|lineweight|imgoffsetx|imgoffsety|imgwidth|imgheight)$/;
8243
8266
  function expectedUnit(cell) {
8244
8267
  const unit4 = attribute2(cell.local, "U") ?? attribute2(cell.inherited, "U");
8245
8268
  if (unit4 === void 0 && cell.section && PASSIVE.has(cell.section.name)) return void 0;
@@ -8257,7 +8280,12 @@ function expectedUnit(cell) {
8257
8280
  return "length";
8258
8281
  return !cell.relative && /^(geometry\d+|connections|controls)\.[xy]\d+$/.test(name3) ? "length" : "scalar";
8259
8282
  }
8260
- function recalculateInstanceCaches(target2, changed, check, pins = /* @__PURE__ */ new Map(), text9) {
8283
+ function untaggedLength(cell) {
8284
+ if (cell.section?.name !== "User") return void 0;
8285
+ const formula2 = effectiveFormula(cell);
8286
+ return formula2 && /^\s*[\d.]+\s*(?:MM|CM|IN|FT|M)/i.test(formula2) ? "length" : void 0;
8287
+ }
8288
+ function recalculateInstanceCaches(target2, changed, check, pins = /* @__PURE__ */ new Map(), text9, keepTextSize = false) {
8261
8289
  const scope2 = "sheets" in target2 ? target2 : singleScope(target2);
8262
8290
  const overrides = new Map(changed);
8263
8291
  const pinned = /* @__PURE__ */ new Map();
@@ -8279,11 +8307,11 @@ function recalculateInstanceCaches(target2, changed, check, pins = /* @__PURE__
8279
8307
  try {
8280
8308
  const ast = parseVisioFormula(source);
8281
8309
  const analysis = analyzeVisioFormula(ast);
8282
- const sized = text9 && analysis.dynamic ? textSizeFormula(ast) : void 0;
8310
+ const sized = analysis.dynamic && (text9 || keepTextSize) ? textSizeFormula(ast) : void 0;
8283
8311
  result2 = sized ? {
8284
8312
  ast,
8285
8313
  local,
8286
- text: true,
8314
+ ...text9 ? { text: true } : { deferText: true },
8287
8315
  references: sized.references.flatMap((ref) => found(ref.cell, ref.shapeId))
8288
8316
  } : analysis.dynamic ? { local, references: mentioned() } : {
8289
8317
  ast,
@@ -8329,22 +8357,42 @@ function recalculateInstanceCaches(target2, changed, check, pins = /* @__PURE__
8329
8357
  if (!node3 || node3.hasAttribute("E")) throw new Unevaluable();
8330
8358
  try {
8331
8359
  const value3 = visioFormulaCachedValue(attribute2(node3, "V") ?? "", attribute2(node3, "U"));
8332
- const unit4 = expectedUnit(cell);
8360
+ const unit4 = expectedUnit(cell) ?? untaggedLength(cell);
8333
8361
  return value3.unit === "scalar" && unit4 && unit4 !== "scalar" ? { ...value3, unit: unit4 } : value3;
8334
8362
  } catch {
8335
8363
  throw new Unevaluable();
8336
8364
  }
8337
8365
  };
8366
+ const tainted = /* @__PURE__ */ new Set();
8367
+ let sawDeferred = false;
8338
8368
  const evaluate = (cell) => {
8369
+ const outer = sawDeferred;
8370
+ sawDeferred = false;
8371
+ try {
8372
+ const result2 = evaluateCell(cell);
8373
+ if (sawDeferred) tainted.add(cell);
8374
+ return result2;
8375
+ } finally {
8376
+ sawDeferred = sawDeferred || outer;
8377
+ }
8378
+ };
8379
+ const evaluateCell = (cell) => {
8339
8380
  check();
8340
8381
  if (--steps < 0)
8341
8382
  fail("LIMIT_FORMULA_STEPS", "ShapeSheet dependency evaluation limit exceeded.");
8342
8383
  const override = overrides.get(cell);
8343
8384
  if (override !== void 0) return { value: override, unit: expectedUnit(cell) ?? "scalar" };
8344
8385
  const known = values.get(cell);
8345
- if (known) return known;
8386
+ if (known) {
8387
+ if (tainted.has(cell)) sawDeferred = true;
8388
+ return known;
8389
+ }
8346
8390
  if (!isAffected(cell, /* @__PURE__ */ new Set())) return cached5(cell);
8347
8391
  const own = dependenciesOf(cell);
8392
+ if (own?.deferText) {
8393
+ sawDeferred = true;
8394
+ return cached5(cell);
8395
+ }
8348
8396
  const ast = own?.ast;
8349
8397
  if (!ast || evaluating.has(cell)) throw new Unevaluable();
8350
8398
  evaluating.add(cell);
@@ -8388,9 +8436,11 @@ function recalculateInstanceCaches(target2, changed, check, pins = /* @__PURE__
8388
8436
  let value3;
8389
8437
  let length;
8390
8438
  try {
8439
+ sawDeferred = false;
8391
8440
  const result2 = evaluate(cell);
8392
8441
  value3 = result2.value;
8393
8442
  length = result2.unit === "length";
8443
+ if (tainted.has(cell) && cell.section && PASSIVE.has(cell.section.name)) continue;
8394
8444
  } catch (error) {
8395
8445
  if (!(error instanceof Unevaluable)) throw error;
8396
8446
  if (cell.section && PASSIVE.has(cell.section.name)) continue;
@@ -9773,12 +9823,12 @@ function pathVertices(sheet, width, height, writes) {
9773
9823
  return refuse();
9774
9824
  }
9775
9825
  }
9776
- const entry3 = rows.get(item2.row) ?? { relative: item2.relative };
9777
- entry3[item2.name === "X" ? "x" : "y"] = number6;
9778
- rows.set(item2.row, entry3);
9826
+ const entry4 = rows.get(item2.row) ?? { relative: item2.relative };
9827
+ entry4[item2.name === "X" ? "x" : "y"] = number6;
9828
+ rows.set(item2.row, entry4);
9779
9829
  }
9780
- return [...rows.values()].filter((entry3) => entry3.x !== void 0 && entry3.y !== void 0).map(
9781
- (entry3) => entry3.relative ? { x: entry3.x * width, y: entry3.y * height } : { x: entry3.x, y: entry3.y }
9830
+ return [...rows.values()].filter((entry4) => entry4.x !== void 0 && entry4.y !== void 0).map(
9831
+ (entry4) => entry4.relative ? { x: entry4.x * width, y: entry4.y * height } : { x: entry4.x, y: entry4.y }
9782
9832
  );
9783
9833
  }
9784
9834
  function layoutStencilLine(root2, pageId2, shape, ends, check) {
@@ -10658,7 +10708,9 @@ async function applyInstanceGeometryEdit(roots2, edit, template, check) {
10658
10708
  scope2,
10659
10709
  overrides,
10660
10710
  check,
10661
- new Map(pins.map((item2) => [item2, item2 === cell("Width") ? width : height]))
10711
+ new Map(pins.map((item2) => [item2, item2 === cell("Width") ? width : height])),
10712
+ void 0,
10713
+ true
10662
10714
  );
10663
10715
  for (const [item2, value3] of pinned) {
10664
10716
  assertOverridable(item2, "The size");
@@ -11377,7 +11429,7 @@ var VISIO_BUILT_IN_THEMES = [
11377
11429
  )
11378
11430
  ];
11379
11431
  function visioBuiltInTheme(id4) {
11380
- return VISIO_BUILT_IN_THEMES.find((entry3) => entry3.id === id4);
11432
+ return VISIO_BUILT_IN_THEMES.find((entry4) => entry4.id === id4);
11381
11433
  }
11382
11434
  function visioThemeVariantColors(source, variant) {
11383
11435
  const accents = source.colors.slice(4, 10);
@@ -11433,8 +11485,8 @@ var VISIO_COMMENT_LIMIT = 1e4;
11433
11485
  var VISIO_COMMENT_TEXT_LIMIT = 16384;
11434
11486
  var VISIO_COMMENT_AUTHOR_LIMIT = 256;
11435
11487
  var unsigned = (value3) => value3 !== void 0 && /^(0|[1-9]\d{0,9})$/.test(value3) && Number(value3) <= 4294967295 ? value3 : void 0;
11436
- function visioCommentId(entry3, index3) {
11437
- return unsigned(attribute2(entry3, "CommentID")) ?? `n${index3}`;
11488
+ function visioCommentId(entry4, index3) {
11489
+ return unsigned(attribute2(entry4, "CommentID")) ?? `n${index3}`;
11438
11490
  }
11439
11491
  async function readVisioComments(pkg, documentPart2, report) {
11440
11492
  const path3 = await related(pkg, documentPart2, "comments", false);
@@ -11459,10 +11511,10 @@ async function readVisioComments(pkg, documentPart2, report) {
11459
11511
  const comments = [];
11460
11512
  const ids = /* @__PURE__ */ new Set();
11461
11513
  let characters = 0;
11462
- entries.slice(0, VISIO_COMMENT_LIMIT).forEach((entry3, index3) => {
11463
- const pageId2 = unsigned(attribute2(entry3, "PageID"));
11464
- const id4 = visioCommentId(entry3, index3);
11465
- const text9 = entry3.textContent ?? "";
11514
+ entries.slice(0, VISIO_COMMENT_LIMIT).forEach((entry4, index3) => {
11515
+ const pageId2 = unsigned(attribute2(entry4, "PageID"));
11516
+ const id4 = visioCommentId(entry4, index3);
11517
+ const text9 = entry4.textContent ?? "";
11466
11518
  characters += text9.length;
11467
11519
  if (pageId2 === void 0 || ids.has(id4) || characters > 1e6) {
11468
11520
  report(
@@ -11475,10 +11527,10 @@ async function readVisioComments(pkg, documentPart2, report) {
11475
11527
  return;
11476
11528
  }
11477
11529
  ids.add(id4);
11478
- const shapeId2 = unsigned(attribute2(entry3, "ShapeID"));
11479
- const author = authors.get(attribute2(entry3, "AuthorID") ?? "");
11480
- const date2 = attribute2(entry3, "Date");
11481
- const editDate = attribute2(entry3, "EditDate");
11530
+ const shapeId2 = unsigned(attribute2(entry4, "ShapeID"));
11531
+ const author = authors.get(attribute2(entry4, "AuthorID") ?? "");
11532
+ const date2 = attribute2(entry4, "Date");
11533
+ const editDate = attribute2(entry4, "EditDate");
11482
11534
  comments.push({
11483
11535
  id: id4,
11484
11536
  pageId: pageId2,
@@ -11488,7 +11540,7 @@ async function readVisioComments(pkg, documentPart2, report) {
11488
11540
  ...date2 ? { date: date2.slice(0, 64) } : {},
11489
11541
  ...editDate ? { editDate: editDate.slice(0, 64) } : {},
11490
11542
  text: text9.slice(0, VISIO_COMMENT_TEXT_LIMIT),
11491
- ...yes(attribute2(entry3, "Done")) ? { done: true } : {}
11543
+ ...yes(attribute2(entry4, "Done")) ? { done: true } : {}
11492
11544
  });
11493
11545
  });
11494
11546
  return comments;
@@ -14956,12 +15008,12 @@ function sigmaGradientStops(stops) {
14956
15008
  // color/hex-rgb.ts
14957
15009
  function parseArgbHex(hex2) {
14958
15010
  const clean6 = hex2.replace(/^#/, "");
14959
- const rgb6 = clean6.length === 8 ? clean6.slice(2) : clean6;
14960
- if (!/^[0-9a-fA-F]{6}$/.test(rgb6)) return void 0;
14961
- return [0, 2, 4].map((i) => parseInt(rgb6.slice(i, i + 2), 16));
15011
+ const rgb7 = clean6.length === 8 ? clean6.slice(2) : clean6;
15012
+ if (!/^[0-9a-fA-F]{6}$/.test(rgb7)) return void 0;
15013
+ return [0, 2, 4].map((i) => parseInt(rgb7.slice(i, i + 2), 16));
14962
15014
  }
14963
15015
  var clamp255 = (v) => Math.max(0, Math.min(255, v));
14964
- var rgbToUpperHex = (rgb6) => `#${rgb6.map((v) => clamp255(Math.round(v)).toString(16).padStart(2, "0")).join("").toUpperCase()}`;
15016
+ var rgbToUpperHex = (rgb7) => `#${rgb7.map((v) => clamp255(Math.round(v)).toString(16).padStart(2, "0")).join("").toUpperCase()}`;
14965
15017
 
14966
15018
  // color/theme-palette.ts
14967
15019
  function themePaletteVariantLuminance(variant) {
@@ -14970,9 +15022,9 @@ function themePaletteVariantLuminance(variant) {
14970
15022
  return variant.kind === "lighter" ? { lumMod, lumOff: fraction } : { lumMod };
14971
15023
  }
14972
15024
  function applyThemePaletteVariant(hex2, variant) {
14973
- const rgb6 = hexToRgbChannels(hex2);
14974
- if (!rgb6) return hex2;
14975
- const { h, s, l } = rgbToHsl(rgb6.r, rgb6.g, rgb6.b);
15025
+ const rgb7 = hexToRgbChannels(hex2);
15026
+ if (!rgb7) return hex2;
15027
+ const { h, s, l } = rgbToHsl(rgb7.r, rgb7.g, rgb7.b);
14976
15028
  const { lumMod, lumOff } = themePaletteVariantLuminance(variant);
14977
15029
  const next = hslToRgb(h, s, l * lumMod + (lumOff ?? 0), (value3) => Math.floor(value3 + 1e-6));
14978
15030
  return `#${toHex(next.r)}${toHex(next.g)}${toHex(next.b)}`.toLowerCase();
@@ -15170,10 +15222,10 @@ var APPLIED = /* @__PURE__ */ new Set([
15170
15222
  ]);
15171
15223
  function resolveDrawingColor(color2, theme2, options2) {
15172
15224
  const base2 = baseHex(color2, theme2);
15173
- const rgb6 = base2 ? hexToRgbChannels(base2) : null;
15174
- if (!rgb6) return void 0;
15225
+ const rgb7 = base2 ? hexToRgbChannels(base2) : null;
15226
+ if (!rgb7) return void 0;
15175
15227
  if (options2?.transformOrder === "document") {
15176
- const value3 = orderedColorTransforms(rgb6, color2.transforms);
15228
+ const value3 = orderedColorTransforms(rgb7, color2.transforms);
15177
15229
  const round6 = options2.hslRounding === "halfDown" ? (channel) => Math.ceil(channel - 0.5) : Math.round;
15178
15230
  return {
15179
15231
  hex: `#${toHex(round6(value3.r))}${toHex(round6(value3.g))}${toHex(round6(value3.b))}`,
@@ -15183,9 +15235,9 @@ function resolveDrawingColor(color2, theme2, options2) {
15183
15235
  )
15184
15236
  };
15185
15237
  }
15186
- let { r, g, b } = rgb6;
15187
- const find = (name3) => color2.transforms.find((entry3) => entry3.name === name3)?.value;
15188
- const has = (name3) => color2.transforms.some((entry3) => entry3.name === name3);
15238
+ let { r, g, b } = rgb7;
15239
+ const find = (name3) => color2.transforms.find((entry4) => entry4.name === name3)?.value;
15240
+ const has = (name3) => color2.transforms.some((entry4) => entry4.name === name3);
15189
15241
  if (has("comp")) {
15190
15242
  const hsl = rgbToHsl(r, g, b);
15191
15243
  ({ r, g, b } = hslToRgb((hsl.h + 180) % 360, hsl.s, hsl.l));
@@ -15236,7 +15288,7 @@ function resolveDrawingColor(color2, theme2, options2) {
15236
15288
  return {
15237
15289
  hex: `#${toHex(r)}${toHex(g)}${toHex(b)}`,
15238
15290
  alpha,
15239
- unapplied: [...new Set(color2.transforms.map((entry3) => entry3.name))].filter(
15291
+ unapplied: [...new Set(color2.transforms.map((entry4) => entry4.name))].filter(
15240
15292
  (name3) => !APPLIED.has(name3)
15241
15293
  )
15242
15294
  };
@@ -16725,8 +16777,8 @@ function sortKeys(value3) {
16725
16777
  if (value3 && typeof value3 === "object") {
16726
16778
  const out = {};
16727
16779
  for (const key2 of Object.keys(value3).sort()) {
16728
- const entry3 = value3[key2];
16729
- if (entry3 !== void 0) out[key2] = sortKeys(entry3);
16780
+ const entry4 = value3[key2];
16781
+ if (entry4 !== void 0) out[key2] = sortKeys(entry4);
16730
16782
  }
16731
16783
  return out;
16732
16784
  }
@@ -17938,10 +17990,10 @@ function hls240ToRgb({ h, l, s }) {
17938
17990
  var parseHex = parseArgbHex;
17939
17991
  var toHexColor = rgbToUpperHex;
17940
17992
  function applyTint(hex2, tint) {
17941
- const rgb6 = parseHex(hex2) ?? [0, 0, 0];
17942
- if (!tint) return toHexColor(rgb6);
17993
+ const rgb7 = parseHex(hex2) ?? [0, 0, 0];
17994
+ if (!tint) return toHexColor(rgb7);
17943
17995
  const t = Math.max(-1, Math.min(1, tint));
17944
- const hls = rgbToHls240(...rgb6);
17996
+ const hls = rgbToHls240(...rgb7);
17945
17997
  const l = t < 0 ? Math.trunc(hls.l * (1 + t)) : Math.round(hls.l * (1 - t) + HLSMAX * t);
17946
17998
  return toHexColor(hls240ToRgb({ ...hls, l: Math.max(0, Math.min(HLSMAX, l)) }));
17947
17999
  }
@@ -18857,7 +18909,7 @@ function countDerived(pivot) {
18857
18909
  }
18858
18910
  var pivotAxisFieldNames = (pivot) => [
18859
18911
  ...pivot.fields,
18860
- ...derivedDateFields(pivot).filter((entry3) => !pivot.fields.includes(entry3.name)).map((entry3) => entry3.name)
18912
+ ...derivedDateFields(pivot).filter((entry4) => !pivot.fields.includes(entry4.name)).map((entry4) => entry4.name)
18861
18913
  ];
18862
18914
  function resolveDateGroups(pivot) {
18863
18915
  return (pivot.dateGroups ?? []).map((group2) => {
@@ -18868,11 +18920,11 @@ function resolveDateGroups(pivot) {
18868
18920
  });
18869
18921
  }
18870
18922
  function derivedDateLabels(pivot, name3) {
18871
- const entry3 = derivedDateFields(pivot).find((candidate) => candidate.name === name3);
18872
- if (!entry3) return void 0;
18873
- const [group2] = resolveDateGroups({ ...pivot, dateGroups: [entry3.group] });
18923
+ const entry4 = derivedDateFields(pivot).find((candidate) => candidate.name === name3);
18924
+ if (!entry4) return void 0;
18925
+ const [group2] = resolveDateGroups({ ...pivot, dateGroups: [entry4.group] });
18874
18926
  const range2 = { start: group2.start, end: group2.end };
18875
- return dateUnitLabels(entry3.unit, range2, dateGroupDays(group2), pivot.date1904 ?? false, group2);
18927
+ return dateUnitLabels(entry4.unit, range2, dateGroupDays(group2), pivot.date1904 ?? false, group2);
18876
18928
  }
18877
18929
  function validateDateGroups(pivot) {
18878
18930
  const groups = pivot.dateGroups;
@@ -18908,19 +18960,19 @@ function expandDateGroups(pivot) {
18908
18960
  const resolved = { ...pivot, dateGroups: groups };
18909
18961
  const derived = derivedDateFields(resolved);
18910
18962
  const date1904 = pivot.date1904 ?? false;
18911
- const tables = derived.map((entry3) => {
18912
- const range2 = { start: entry3.group.start, end: entry3.group.end };
18913
- const days = dateGroupDays(entry3.group);
18914
- const labels = dateUnitLabels(entry3.unit, range2, days, date1904, entry3.group);
18963
+ const tables = derived.map((entry4) => {
18964
+ const range2 = { start: entry4.group.start, end: entry4.group.end };
18965
+ const days = dateGroupDays(entry4.group);
18966
+ const labels = dateUnitLabels(entry4.unit, range2, days, date1904, entry4.group);
18915
18967
  return {
18916
- base: pivot.fields.indexOf(entry3.group.field),
18968
+ base: pivot.fields.indexOf(entry4.group.field),
18917
18969
  labels,
18918
- index: (serial) => dateUnitIndex(entry3.unit, range2, days, date1904, serial, labels.length)
18970
+ index: (serial) => dateUnitIndex(entry4.unit, range2, days, date1904, serial, labels.length)
18919
18971
  };
18920
18972
  });
18921
18973
  return {
18922
18974
  ...resolved,
18923
- fields: [...pivot.fields, ...derived.map((entry3) => entry3.name)],
18975
+ fields: [...pivot.fields, ...derived.map((entry4) => entry4.name)],
18924
18976
  records: pivot.records.map((record2) => [
18925
18977
  ...record2,
18926
18978
  ...tables.map((table2) => {
@@ -18965,7 +19017,7 @@ function validateFieldGroups(pivot) {
18965
19017
  if (!group2 || typeof group2 !== "object" || index3 < 0 || seen.has(group2.field) || ![group2.start, group2.end, group2.by].every(Number.isInteger) || group2.by < 1 || group2.start >= group2.end || groupBucketCount(group2) > MAX_BUCKETS)
18966
19018
  throw new Error("Choose a valid number group.");
18967
19019
  seen.add(group2.field);
18968
- if (pivot.pageFilter?.field === group2.field || pivot.valueField === group2.field || (pivot.additionalValues ?? []).some((measure3) => measure3.field === group2.field) || (pivot.dateFields ?? []).includes(group2.field) || (pivot.itemFilters ?? []).some((filter) => filter.field === group2.field))
19020
+ if (pivot.pageFilter?.field === group2.field || pivot.valueField === group2.field || (pivot.additionalValues ?? []).some((measure4) => measure4.field === group2.field) || (pivot.dateFields ?? []).includes(group2.field) || (pivot.itemFilters ?? []).some((filter) => filter.field === group2.field))
18969
19021
  throw new Error("A grouped field cannot also be a filter, date field or value field.");
18970
19022
  for (const record2 of pivot.records) {
18971
19023
  const value3 = record2[index3];
@@ -19030,8 +19082,8 @@ var PIVOT_SUBTOTAL_ORDER = [
19030
19082
  "varp"
19031
19083
  ];
19032
19084
  function fieldSubtotalFunctions(pivot, field3) {
19033
- const entry3 = pivot.fieldSubtotals?.find((item2) => item2.field === field3);
19034
- if (entry3) return PIVOT_SUBTOTAL_ORDER.filter((fn) => entry3.functions.includes(fn));
19085
+ const entry4 = pivot.fieldSubtotals?.find((item2) => item2.field === field3);
19086
+ if (entry4) return PIVOT_SUBTOTAL_ORDER.filter((fn) => entry4.functions.includes(fn));
19035
19087
  return field3 === pivot.rowField && pivot.subtotals === false ? [] : "auto";
19036
19088
  }
19037
19089
  function validateFieldSubtotals(pivot, axisFields) {
@@ -19039,22 +19091,22 @@ function validateFieldSubtotals(pivot, axisFields) {
19039
19091
  if (entries === void 0) return;
19040
19092
  if (!Array.isArray(entries)) throw new Error("Choose valid field subtotals.");
19041
19093
  const seen = /* @__PURE__ */ new Set();
19042
- for (const entry3 of entries) {
19043
- if (!entry3 || typeof entry3 !== "object" || !axisFields.includes(entry3.field) || seen.has(entry3.field) || !Array.isArray(entry3.functions) || entry3.functions.some((fn) => !PIVOT_AGGREGATES.includes(fn)) || new Set(entry3.functions).size !== entry3.functions.length)
19094
+ for (const entry4 of entries) {
19095
+ if (!entry4 || typeof entry4 !== "object" || !axisFields.includes(entry4.field) || seen.has(entry4.field) || !Array.isArray(entry4.functions) || entry4.functions.some((fn) => !PIVOT_AGGREGATES.includes(fn)) || new Set(entry4.functions).size !== entry4.functions.length)
19044
19096
  throw new Error("Choose valid field subtotals.");
19045
- seen.add(entry3.field);
19097
+ seen.add(entry4.field);
19046
19098
  }
19047
19099
  }
19048
19100
 
19049
19101
  // xlsx/pivot/item-filters.ts
19050
19102
  function applyPivotItemFilters(pivot) {
19051
- const active = (pivot.itemFilters ?? []).filter((entry3) => entry3.hidden.length);
19103
+ const active = (pivot.itemFilters ?? []).filter((entry4) => entry4.hidden.length);
19052
19104
  const range2 = pivot.dateFilter;
19053
19105
  if (!active.length && !range2) return pivot;
19054
19106
  const dateIndex = range2 ? pivot.fields.indexOf(range2.field) : -1;
19055
- const tests = active.map((entry3) => ({
19056
- index: pivot.fields.indexOf(entry3.field),
19057
- hidden: new Set(entry3.hidden.map(pivotValueKey))
19107
+ const tests = active.map((entry4) => ({
19108
+ index: pivot.fields.indexOf(entry4.field),
19109
+ hidden: new Set(entry4.hidden.map(pivotValueKey))
19058
19110
  }));
19059
19111
  return {
19060
19112
  ...pivot,
@@ -19097,7 +19149,7 @@ function validatePivotItemFilters(pivot) {
19097
19149
  var keyOf = (field3, item2) => `${field3}\0${pivotValueKey(item2)}`;
19098
19150
  function pivotItemLabeler(pivot) {
19099
19151
  const blank = pivotCaptions(pivot).blank;
19100
- const names = pivot.itemNames?.length ? new Map(pivot.itemNames.map((entry3) => [keyOf(entry3.field, entry3.item), entry3.name])) : void 0;
19152
+ const names = pivot.itemNames?.length ? new Map(pivot.itemNames.map((entry4) => [keyOf(entry4.field, entry4.item), entry4.name])) : void 0;
19101
19153
  return (field3, value3) => names?.get(keyOf(field3, value3)) ?? (value3 === null || value3 === "" ? blank : pivotItemLabel(value3));
19102
19154
  }
19103
19155
 
@@ -19265,9 +19317,9 @@ function validatePivotFields(pivot) {
19265
19317
  if (extras.length > 0 && pivot.sourceXml && parseXml(pivot.sourceXml).documentElement.getAttribute("dataCaption") !== pivotCaptions(pivot).values)
19266
19318
  throw new Error("This PivotTable uses unsupported Values header captions.");
19267
19319
  if (!Array.isArray(extras) || extras.length > 15 || extras.some(
19268
- (measure3) => !measure3 || !pivot.fields.includes(measure3.field) || !PIVOT_AGGREGATES.includes(measure3.aggregate) || typeof measure3.caption !== "string" || !measure3.caption.trim() || measure3.caption.length > 255 || pivot.fields.some((field3) => field3.toLowerCase() === measure3.caption.toLowerCase())
19320
+ (measure4) => !measure4 || !pivot.fields.includes(measure4.field) || !PIVOT_AGGREGATES.includes(measure4.aggregate) || typeof measure4.caption !== "string" || !measure4.caption.trim() || measure4.caption.length > 255 || pivot.fields.some((field3) => field3.toLowerCase() === measure4.caption.toLowerCase())
19269
19321
  ) || new Set(
19270
- [pivot.valueCaption, ...extras.map((measure3) => measure3.caption)].map(
19322
+ [pivot.valueCaption, ...extras.map((measure4) => measure4.caption)].map(
19271
19323
  (caption) => caption?.toLowerCase()
19272
19324
  )
19273
19325
  ).size !== extras.length + 1)
@@ -19308,7 +19360,7 @@ function aggregateValues(records2, field3, type) {
19308
19360
  const sum = numbers.reduce((total, value3) => total + value3, 0);
19309
19361
  return type === "average" ? sum / numbers.length : sum;
19310
19362
  }
19311
- var pivotMeasureNumber = (pivot, records2, measure3) => aggregateValues(records2, pivot.fields.indexOf(measure3.field), measure3.aggregate);
19363
+ var pivotMeasureNumber = (pivot, records2, measure4) => aggregateValues(records2, pivot.fields.indexOf(measure4.field), measure4.aggregate);
19312
19364
 
19313
19365
  // xlsx/pivot/columns.ts
19314
19366
  var SEPARATOR = "";
@@ -19345,17 +19397,17 @@ function pivotColumnEntries(pivot) {
19345
19397
  values: [...values, child3[1].value],
19346
19398
  keys: [...keys, child3[0]]
19347
19399
  };
19348
- const entry3 = {
19400
+ const entry4 = {
19349
19401
  path: here.path,
19350
19402
  key: columnKey(here.keys, here.keys.length),
19351
19403
  values: here.values
19352
19404
  };
19353
- if (level3 === names.length - 1) entries.push({ kind: "leaf", ...entry3 });
19405
+ if (level3 === names.length - 1) entries.push({ kind: "leaf", ...entry4 });
19354
19406
  else {
19355
19407
  visit(child3[1], level3 + 1, here.path, here.values, here.keys);
19356
19408
  const own = functions[level3];
19357
- if (own === "auto") entries.push({ kind: "subtotal", ...entry3 });
19358
- else for (const fn of own) entries.push({ kind: "subtotal", ...entry3, fn });
19409
+ if (own === "auto") entries.push({ kind: "subtotal", ...entry4 });
19410
+ else for (const fn of own) entries.push({ kind: "subtotal", ...entry4, fn });
19359
19411
  }
19360
19412
  }
19361
19413
  };
@@ -19378,7 +19430,7 @@ function pivotColumnHeaders(pivot, columns, rowLabels, valuesOnRows = false) {
19378
19430
  const levels = columns.names.length;
19379
19431
  if (!levels)
19380
19432
  return [
19381
- [...rowLabels, ...valuesOnRows ? [null] : measures2.map((measure3) => measure3.caption)]
19433
+ [...rowLabels, ...valuesOnRows ? [null] : measures2.map((measure4) => measure4.caption)]
19382
19434
  ];
19383
19435
  const compact = pivot.layout === "compact";
19384
19436
  const labelColumns = rowLabels.length;
@@ -19396,22 +19448,22 @@ function pivotColumnHeaders(pivot, columns, rowLabels, valuesOnRows = false) {
19396
19448
  grid[rows - 1][i] = text9;
19397
19449
  });
19398
19450
  let previous = [];
19399
- columns.entries.forEach((entry3, j) => {
19451
+ columns.entries.forEach((entry4, j) => {
19400
19452
  const at3 = labelColumns + j * count;
19401
- if (entry3.kind === "leaf") {
19402
- entry3.path.forEach((_index, level3) => {
19403
- const continued = entry3.path.slice(0, level3 + 1).every((p, i) => p === previous[i]);
19404
- if (!continued) grid[1 + level3][at3] = labelOf(columns.names[level3], entry3.values[level3]);
19453
+ if (entry4.kind === "leaf") {
19454
+ entry4.path.forEach((_index, level3) => {
19455
+ const continued = entry4.path.slice(0, level3 + 1).every((p, i) => p === previous[i]);
19456
+ if (!continued) grid[1 + level3][at3] = labelOf(columns.names[level3], entry4.values[level3]);
19405
19457
  });
19406
- previous = entry3.path;
19407
- if (count > 1) measures2.forEach((measure3, m) => grid[rows - 1][at3 + m] = measure3.caption);
19458
+ previous = entry4.path;
19459
+ if (count > 1) measures2.forEach((measure4, m) => grid[rows - 1][at3 + m] = measure4.caption);
19408
19460
  return;
19409
19461
  }
19410
- const row2 = entry3.kind === "grand" ? 1 : entry3.path.length;
19411
- const name3 = entry3.kind === "grand" ? "" : String(labelOf(columns.names[entry3.path.length - 1], entry3.values.at(-1)));
19412
- measures2.forEach((measure3, m) => {
19413
- const custom = entry3.fn ? caps.functions[entry3.fn] : void 0;
19414
- grid[row2][at3 + m] = custom ? count === 1 ? `${name3} ${custom}` : `${name3} ${custom} of ${measure3.field}` : count === 1 ? entry3.kind === "grand" ? caps.grandTotal : fillCaption(caps.subtotal, name3) : entry3.kind === "grand" ? fillCaption(caps.measureTotal, measure3.caption) : `${name3} ${measure3.caption}`;
19462
+ const row2 = entry4.kind === "grand" ? 1 : entry4.path.length;
19463
+ const name3 = entry4.kind === "grand" ? "" : String(labelOf(columns.names[entry4.path.length - 1], entry4.values.at(-1)));
19464
+ measures2.forEach((measure4, m) => {
19465
+ const custom = entry4.fn ? caps.functions[entry4.fn] : void 0;
19466
+ grid[row2][at3 + m] = custom ? count === 1 ? `${name3} ${custom}` : `${name3} ${custom} of ${measure4.field}` : count === 1 ? entry4.kind === "grand" ? caps.grandTotal : fillCaption(caps.subtotal, name3) : entry4.kind === "grand" ? fillCaption(caps.measureTotal, measure4.caption) : `${name3} ${measure4.caption}`;
19415
19467
  });
19416
19468
  });
19417
19469
  return grid;
@@ -19483,11 +19535,11 @@ function nestedPivotGrid(pivot) {
19483
19535
  let rowCount = 0;
19484
19536
  const width = dimensions3.width - labelColumns;
19485
19537
  const blanks = () => Array(width).fill(null);
19486
- const cells4 = (group2, rowFn, measure3) => columns.entries.flatMap((entry3) => {
19487
- const records2 = entry3.kind === "grand" ? group2.records : group2.columns.get(entry3.key) ?? [];
19488
- const picked = measure3 === void 0 ? measures2 : [measures2[measure3]];
19489
- if (rowFn && entry3.fn && rowFn !== entry3.fn) return picked.map(() => null);
19490
- const fn = rowFn ?? entry3.fn;
19538
+ const cells4 = (group2, rowFn, measure4) => columns.entries.flatMap((entry4) => {
19539
+ const records2 = entry4.kind === "grand" ? group2.records : group2.columns.get(entry4.key) ?? [];
19540
+ const picked = measure4 === void 0 ? measures2 : [measures2[measure4]];
19541
+ if (rowFn && entry4.fn && rowFn !== entry4.fn) return picked.map(() => null);
19542
+ const fn = rowFn ?? entry4.fn;
19491
19543
  return picked.map(
19492
19544
  (one) => fn ? aggregateValues(records2, pivot.fields.indexOf(one.field), fn) : pivotMeasureNumber(pivot, records2, one)
19493
19545
  );
@@ -19507,17 +19559,17 @@ function nestedPivotGrid(pivot) {
19507
19559
  throw new Error("The PivotTable result is too large.");
19508
19560
  return;
19509
19561
  }
19510
- const [cells5, numbers, entry3] = build2();
19562
+ const [cells5, numbers, entry4] = build2();
19511
19563
  values.push([...cells5, ...numbers]);
19512
- rowEntries.push(entry3);
19564
+ rowEntries.push(entry4);
19513
19565
  indents.push(compact ? indent : 0);
19514
19566
  };
19515
- const entryOf = (indices, measure3, type) => ({
19567
+ const entryOf = (indices, measure4, type) => ({
19516
19568
  indices,
19517
- ...measure3 !== void 0 ? { measure: measure3 } : {},
19569
+ ...measure4 !== void 0 ? { measure: measure4 } : {},
19518
19570
  ...type ? { type } : {}
19519
19571
  });
19520
- const walk = (level3, group2, measure3, path3) => {
19572
+ const walk = (level3, group2, measure4, path3) => {
19521
19573
  const field3 = fieldOf(level3);
19522
19574
  const last = level3 === levels - 1;
19523
19575
  const repeated = Array.from(
@@ -19562,16 +19614,16 @@ function nestedPivotGrid(pivot) {
19562
19614
  if (last)
19563
19615
  return push(level3, () => [
19564
19616
  labelCells(path3, leafShown(here.firsts), level3, text9),
19565
- cells4(child3, void 0, measure3),
19566
- entryOf(here.indices, measure3)
19617
+ cells4(child3, void 0, measure4),
19618
+ entryOf(here.indices, measure4)
19567
19619
  ]);
19568
19620
  if (!tabular)
19569
19621
  push(level3, () => [
19570
19622
  labelCells(path3, repeated, level3, text9),
19571
- showsValue ? cells4(child3, void 0, measure3) : blanks(),
19572
- entryOf(here.indices, measure3)
19623
+ showsValue ? cells4(child3, void 0, measure4) : blanks(),
19624
+ entryOf(here.indices, measure4)
19573
19625
  ]);
19574
- walk(level3 + 1, child3, measure3, here);
19626
+ walk(level3 + 1, child3, measure4, here);
19575
19627
  if (field3 === depth - 1) return;
19576
19628
  const caption = String(text9);
19577
19629
  const subtotal = (title, fn, one) => push(level3, () => [
@@ -19581,21 +19633,21 @@ function nestedPivotGrid(pivot) {
19581
19633
  ]);
19582
19634
  if (own === "auto") {
19583
19635
  if (showsValue) return;
19584
- if (valuesAbove) subtotal(fillCaption(caps.subtotal, caption), void 0, measure3);
19636
+ if (valuesAbove) subtotal(fillCaption(caps.subtotal, caption), void 0, measure4);
19585
19637
  else measures2.forEach((one, m) => subtotal(`${caption} ${one.caption}`, void 0, m));
19586
19638
  } else
19587
19639
  for (const fn of own)
19588
- if (valuesAbove) subtotal(`${caption} ${caps.functions[fn]}`, fn, measure3);
19640
+ if (valuesAbove) subtotal(`${caption} ${caps.functions[fn]}`, fn, measure4);
19589
19641
  else
19590
19642
  measures2.forEach(
19591
19643
  (one, m) => subtotal(`${caption} ${caps.functions[fn]} of ${one.field}`, fn, m)
19592
19644
  );
19593
19645
  });
19594
19646
  };
19595
- const grand = (text9, measure3) => push(0, () => [
19647
+ const grand = (text9, measure4) => push(0, () => [
19596
19648
  compact ? [text9] : [text9, ...Array(levels - 1).fill(null)],
19597
- cells4(root2, void 0, measure3),
19598
- entryOf([0], measure3, "grand")
19649
+ cells4(root2, void 0, measure4),
19650
+ entryOf([0], measure4, "grand")
19599
19651
  ]);
19600
19652
  const build = () => {
19601
19653
  walk(0, root2, void 0, { labels: [], indices: [], firsts: [] });
@@ -19802,8 +19854,8 @@ function isSafePartName(name3) {
19802
19854
  if (body.startsWith("/")) return false;
19803
19855
  return !body.split("/").some((segment) => segment === "..");
19804
19856
  }
19805
- function declaredEntrySize(entry3) {
19806
- const data = entry3._data;
19857
+ function declaredEntrySize(entry4) {
19858
+ const data = entry4._data;
19807
19859
  const size3 = Number(data?.uncompressedSize ?? 0);
19808
19860
  return Number.isFinite(size3) && size3 > 0 ? size3 : 0;
19809
19861
  }
@@ -19817,10 +19869,10 @@ function resolveLimits(limits) {
19817
19869
  fail: (message, limit2, kind, actual) => create3 ? create3(message, { limit: limit2, kind, actual }) : new ZipLimitError(message, { limit: limit2, kind, actual })
19818
19870
  };
19819
19871
  }
19820
- async function inflateEntryGuarded(entry3, alreadyRead, limits) {
19872
+ async function inflateEntryGuarded(entry4, alreadyRead, limits) {
19821
19873
  const chunks = [];
19822
19874
  let size3 = 0;
19823
- for await (const chunk of streamEntryGuarded(entry3, alreadyRead, limits)) {
19875
+ for await (const chunk of streamEntryGuarded(entry4, alreadyRead, limits)) {
19824
19876
  chunks.push(chunk);
19825
19877
  size3 += chunk.byteLength;
19826
19878
  }
@@ -19834,10 +19886,10 @@ async function inflateEntryGuarded(entry3, alreadyRead, limits) {
19834
19886
  return out;
19835
19887
  }
19836
19888
  var AHEAD = 8;
19837
- async function* streamEntryGuarded(entry3, alreadyRead, limits) {
19889
+ async function* streamEntryGuarded(entry4, alreadyRead, limits) {
19838
19890
  const r = resolveLimits(limits);
19839
- const declared = declaredEntrySize(entry3);
19840
- const stream = entry3.internalStream("uint8array");
19891
+ const declared = declaredEntrySize(entry4);
19892
+ const stream = entry4.internalStream("uint8array");
19841
19893
  const queue = [];
19842
19894
  let size3 = 0;
19843
19895
  let ended = false;
@@ -19867,7 +19919,7 @@ async function* streamEntryGuarded(entry3, alreadyRead, limits) {
19867
19919
  if (size3 > declared || size3 > r.maxEntryBytes)
19868
19920
  return fail3(
19869
19921
  r.fail(
19870
- `${r.label} part ${entry3.name} inflates past its declared size`,
19922
+ `${r.label} part ${entry4.name} inflates past its declared size`,
19871
19923
  r.maxEntryBytes,
19872
19924
  size3 > declared ? "declaredSize" : "maxEntryBytes",
19873
19925
  size3
@@ -19930,15 +19982,15 @@ function guardZip(zip, limits = {}) {
19930
19982
  entries.length
19931
19983
  );
19932
19984
  let declared = 0;
19933
- for (const entry3 of entries) {
19934
- const original = entry3.unsafeOriginalName;
19935
- if (!isSafePartName(entry3.name) || original !== void 0 && !isSafePartName(original))
19985
+ for (const entry4 of entries) {
19986
+ const original = entry4.unsafeOriginalName;
19987
+ if (!isSafePartName(entry4.name) || original !== void 0 && !isSafePartName(original))
19936
19988
  throw r.fail(`${r.label} package has an unsafe part name`, r.maxEntries, "partName");
19937
- if (entry3.dir) continue;
19938
- const size3 = declaredEntrySize(entry3);
19989
+ if (entry4.dir) continue;
19990
+ const size3 = declaredEntrySize(entry4);
19939
19991
  if (size3 > r.maxEntryBytes)
19940
19992
  throw r.fail(
19941
- `${r.label} part ${entry3.name} exceeds the uncompressed part size limit`,
19993
+ `${r.label} part ${entry4.name} exceeds the uncompressed part size limit`,
19942
19994
  r.maxEntryBytes,
19943
19995
  "maxEntryBytes",
19944
19996
  size3
@@ -19954,15 +20006,15 @@ function guardZip(zip, limits = {}) {
19954
20006
  );
19955
20007
  const produced = /* @__PURE__ */ new Map();
19956
20008
  let total = 0;
19957
- for (const entry3 of entries) {
19958
- if (entry3.dir) continue;
19959
- const inflateOriginal = entry3.async.bind(entry3);
19960
- entry3.async = async (type, onUpdate) => {
19961
- const previous = produced.get(entry3.name) ?? 0;
19962
- const bytes = await inflateEntryGuarded(entry3, total - previous, limits);
20009
+ for (const entry4 of entries) {
20010
+ if (entry4.dir) continue;
20011
+ const inflateOriginal = entry4.async.bind(entry4);
20012
+ entry4.async = async (type, onUpdate) => {
20013
+ const previous = produced.get(entry4.name) ?? 0;
20014
+ const bytes = await inflateEntryGuarded(entry4, total - previous, limits);
19963
20015
  if (bytes.byteLength > previous) {
19964
20016
  total += bytes.byteLength - previous;
19965
- produced.set(entry3.name, bytes.byteLength);
20017
+ produced.set(entry4.name, bytes.byteLength);
19966
20018
  }
19967
20019
  switch (type) {
19968
20020
  case "uint8array":
@@ -20540,15 +20592,15 @@ function readPivotCaptionAttributes(root2) {
20540
20592
  }
20541
20593
  function aggregateCaptionsOf(pivot) {
20542
20594
  const out = {};
20543
- for (const measure3 of [
20595
+ for (const measure4 of [
20544
20596
  { field: pivot.valueField, aggregate: pivot.aggregate, caption: pivot.valueCaption },
20545
20597
  ...pivot.additionalValues ?? []
20546
20598
  ]) {
20547
- const at3 = measure3.caption.indexOf(measure3.field);
20548
- if (at3 < 0 || measure3.caption === measure3.field) continue;
20549
- const template = `${measure3.caption.slice(0, at3)}{0}${measure3.caption.slice(at3 + measure3.field.length)}`;
20550
- if (template !== ENGLISH_PIVOT_CAPTIONS.aggregates[measure3.aggregate])
20551
- out[measure3.aggregate] = template;
20599
+ const at3 = measure4.caption.indexOf(measure4.field);
20600
+ if (at3 < 0 || measure4.caption === measure4.field) continue;
20601
+ const template = `${measure4.caption.slice(0, at3)}{0}${measure4.caption.slice(at3 + measure4.field.length)}`;
20602
+ if (template !== ENGLISH_PIVOT_CAPTIONS.aggregates[measure4.aggregate])
20603
+ out[measure4.aggregate] = template;
20552
20604
  }
20553
20605
  return Object.keys(out).length ? out : void 0;
20554
20606
  }
@@ -20931,17 +20983,17 @@ function settleSlicers(workbook, warn) {
20931
20983
  const book = workbook.slicers;
20932
20984
  if (!book) return;
20933
20985
  const pivotAt = (tabId, name3) => {
20934
- const sheet = workbook.sheets.find((entry3) => entry3.sheetId === tabId);
20935
- const pivot = sheet?.pivotTables?.find((entry3) => entry3.name === name3);
20986
+ const sheet = workbook.sheets.find((entry4) => entry4.sheetId === tabId);
20987
+ const pivot = sheet?.pivotTables?.find((entry4) => entry4.name === name3);
20936
20988
  return sheet && pivot ? { sheet, pivot } : void 0;
20937
20989
  };
20938
20990
  const good = (cache2) => {
20939
20991
  if (cache2.source.kind === "table") {
20940
20992
  const { tableId, column } = cache2.source;
20941
20993
  for (const sheet of workbook.sheets) {
20942
- const table2 = sheet.tables.find((entry3) => entry3.id === tableId);
20994
+ const table2 = sheet.tables.find((entry4) => entry4.id === tableId);
20943
20995
  if (table2)
20944
- return table2.headerRow && !table2.filterNotModeled && table2.columns.some((entry3) => entry3.sourceId === column);
20996
+ return table2.headerRow && !table2.filterNotModeled && table2.columns.some((entry4) => entry4.sourceId === column);
20945
20997
  }
20946
20998
  return false;
20947
20999
  }
@@ -21110,13 +21162,13 @@ function readDateGroups(fields2, count, names, dateFields, records2, date1904) {
21110
21162
  for (const [base2, list3] of members3) {
21111
21163
  const field3 = names[base2] ?? "";
21112
21164
  const parent = first(fields2[base2], "fieldGroup", NS.x);
21113
- const units3 = list3.map((entry3) => entry3.unit);
21165
+ const units3 = list3.map((entry4) => entry4.unit);
21114
21166
  if (!dateFields.includes(field3) || Number(att(parent, "par")) !== list3.at(-1).index || units3.some(
21115
21167
  (unit4, i) => i > 0 && PIVOT_DATE_UNITS.indexOf(unit4) <= PIVOT_DATE_UNITS.indexOf(units3[i - 1])
21116
21168
  ))
21117
21169
  throw unsupported4("group parent");
21118
21170
  const ranges = list3.map(
21119
- (entry3) => first(first(entry3.node, "fieldGroup", NS.x), "rangePr", NS.x)
21171
+ (entry4) => first(first(entry4.node, "fieldGroup", NS.x), "rangePr", NS.x)
21120
21172
  );
21121
21173
  const sample = ranges[0];
21122
21174
  const autoStart = att(sample, "autoStart") !== "0";
@@ -21144,15 +21196,15 @@ function readDateGroups(fields2, count, names, dateFields, records2, date1904) {
21144
21196
  if (!close2(expected.start, start) || !close2(expected.end, end))
21145
21197
  throw unsupported4("stale range");
21146
21198
  const localized = {};
21147
- for (const entry3 of list3) {
21148
- const labels = englishDateUnitLabels(entry3.unit, expected, dateGroupDays(group2), date1904);
21149
- const node3 = first(first(entry3.node, "fieldGroup", NS.x), "groupItems", NS.x);
21199
+ for (const entry4 of list3) {
21200
+ const labels = englishDateUnitLabels(entry4.unit, expected, dateGroupDays(group2), date1904);
21201
+ const node3 = first(first(entry4.node, "fieldGroup", NS.x), "groupItems", NS.x);
21150
21202
  const actual = children(node3, "s", NS.x).map((item2) => decodeEscapes(att(item2, "v") ?? ""));
21151
- const name3 = decodeEscapes(att(entry3.node, "name") ?? "");
21203
+ const name3 = decodeEscapes(att(entry4.node, "name") ?? "");
21152
21204
  if (!name3 || elements(node3).length !== actual.length || actual.length !== labels.length || actual.some((label2) => !label2) || new Set(actual).size !== actual.length)
21153
21205
  throw unsupported4("group items");
21154
- if (name3 !== dateGroupFieldName(entry3.unit, field3) || actual.some((l, i) => l !== labels[i]))
21155
- localized[entry3.unit] = { name: name3, labels: actual };
21206
+ if (name3 !== dateGroupFieldName(entry4.unit, field3) || actual.some((l, i) => l !== labels[i]))
21207
+ localized[entry4.unit] = { name: name3, labels: actual };
21156
21208
  }
21157
21209
  groups.push(Object.keys(localized).length ? { ...group2, localized } : group2);
21158
21210
  }
@@ -21229,9 +21281,9 @@ function readItemNames(tableFields, names, shared) {
21229
21281
  // xlsx/pivot/values-axis.ts
21230
21282
  function remapPivotRowEntries(entries, axes) {
21231
21283
  return entries.map(
21232
- (entry3) => entry3.type === "grand" ? entry3 : {
21233
- ...entry3,
21234
- indices: entry3.indices.map((item2, axis) => {
21284
+ (entry4) => entry4.type === "grand" ? entry4 : {
21285
+ ...entry4,
21286
+ indices: entry4.indices.map((item2, axis) => {
21235
21287
  if (axes[axis] === null) return item2;
21236
21288
  const index3 = axes[axis]?.[item2];
21237
21289
  if (index3 === void 0) throw new Error("Invalid report row axis item");
@@ -21367,9 +21419,9 @@ function assertPageAxisItems(root2, pivot, shared, cache2, recordRoot) {
21367
21419
  throw new Error("Invalid page column items");
21368
21420
  let previous = [];
21369
21421
  colItems.forEach((item2, i) => {
21370
- const grand = i >= expected.length, measure3 = grand ? i - expected.length : i % measures2;
21422
+ const grand = i >= expected.length, measure4 = grand ? i - expected.length : i % measures2;
21371
21423
  const xs = children(item2, "x", NS.x).map((x) => integer2(x.getAttribute("v"), 0)), prefix2 = integer2(item2.getAttribute("r"), 0);
21372
- if (integer2(item2.getAttribute("i"), 0) !== measure3 || !Number.isInteger(prefix2) || prefix2 < 0 || prefix2 > Math.max(0, previous.length - 1))
21424
+ if (integer2(item2.getAttribute("i"), 0) !== measure4 || !Number.isInteger(prefix2) || prefix2 < 0 || prefix2 > Math.max(0, previous.length - 1))
21373
21425
  throw new Error("Invalid page column prefix");
21374
21426
  if (grand) {
21375
21427
  if (item2.getAttribute("t") !== "grand" || prefix2 !== 0 || xs.length !== 1 || xs[0] !== 0)
@@ -21411,12 +21463,12 @@ function readOne(workbook, source, part) {
21411
21463
  const cachePart = source.targetOfType(part, RELATIONSHIP_TYPES.pivotCacheDefinition);
21412
21464
  if (!cachePart) throw new Error("Missing pivot cache");
21413
21465
  const bookPart = source.workbookPart();
21414
- const entry3 = children(
21466
+ const entry4 = children(
21415
21467
  first(parseXml(source.text(bookPart)).documentElement, "pivotCaches", NS.x),
21416
21468
  "pivotCache",
21417
21469
  NS.x
21418
21470
  ).find((node3) => Number(att(node3, "cacheId")) === cacheId);
21419
- const relationship2 = entry3 && source.rels(bookPart).get(relAttr(entry3, "id") ?? "");
21471
+ const relationship2 = entry4 && source.rels(bookPart).get(relAttr(entry4, "id") ?? "");
21420
21472
  if (!relationship2 || source.target(bookPart, relationship2) !== cachePart)
21421
21473
  throw new Error("Inconsistent pivot cache identity");
21422
21474
  const cache2 = parseXml(source.text(cachePart)).documentElement;
@@ -21471,7 +21523,7 @@ function readOne(workbook, source, part) {
21471
21523
  if (rowFields.length < 1 || dataFields.length < 1 || dataFields.length > 16 || !supportedPivotAxes(rowFields, colFields, dataFields.length, rowsAxis) || root2.getAttribute("rowGrandTotals") === "0" || root2.getAttribute("colGrandTotals") === "0")
21472
21524
  throw new Error("Unsupported pivot layout");
21473
21525
  const valueIndex = pivotValueIndex(root2, rowsAxis ? rowFields : colFields);
21474
- const measure3 = dataFields[0];
21526
+ const measure4 = dataFields[0];
21475
21527
  const definition = elements(first(root2, "extLst", NS.x) ?? parseXml("<root/>").documentElement).map(
21476
21528
  (extension2) => first(
21477
21529
  extension2,
@@ -21495,8 +21547,8 @@ function readOne(workbook, source, part) {
21495
21547
  throw new Error("Unsupported Values axis item");
21496
21548
  }
21497
21549
  }
21498
- const aggregate = att(measure3, "subtotal") ?? "sum";
21499
- if (!PIVOT_AGGREGATES.includes(aggregate) || att(measure3, "showDataAs") && att(measure3, "showDataAs") !== "normal")
21550
+ const aggregate = att(measure4, "subtotal") ?? "sum";
21551
+ if (!PIVOT_AGGREGATES.includes(aggregate) || att(measure4, "showDataAs") && att(measure4, "showDataAs") !== "normal")
21500
21552
  throw new Error("Unsupported pivot aggregate");
21501
21553
  const names = fields2.map((field3) => decodeEscapes(att(field3, "name") ?? ""));
21502
21554
  const axisNames = allFields.map((field3) => decodeEscapes(att(field3, "name") ?? ""));
@@ -21517,7 +21569,7 @@ function readOne(workbook, source, part) {
21517
21569
  const rowDefinitions = realRows.map((field3) => tableFields[Number(att(field3, "x"))]);
21518
21570
  const subtotalSettings = fieldSubtotalsOf(rowDefinitions, [row2, second, ...more]);
21519
21571
  const subtotal = !subtotalSettings.some(
21520
- (entry4) => entry4.field === row2 && entry4.functions.length === 0
21572
+ (entry5) => entry5.field === row2 && entry5.functions.length === 0
21521
21573
  );
21522
21574
  const repeat = realRows.map((field3) => {
21523
21575
  const node3 = tableFields[Number(att(field3, "x"))];
@@ -21531,7 +21583,7 @@ function readOne(workbook, source, part) {
21531
21583
  "fillDownLabels"
21532
21584
  ) === "1";
21533
21585
  });
21534
- if (repeat.some((entry4) => entry4 !== repeat[0])) throw new Error("Mixed field label repetition");
21586
+ if (repeat.some((entry5) => entry5 !== repeat[0])) throw new Error("Mixed field label repetition");
21535
21587
  const columnDefs = dataFields.length > 1 && !rowsAxis ? colFields.slice(0, -1) : colFields;
21536
21588
  const columnNames = columnDefs.map((field3) => axisNames[Number(att(field3, "x"))]);
21537
21589
  const hasColumn = columnDefs.length > 0;
@@ -21540,7 +21592,7 @@ function readOne(workbook, source, part) {
21540
21592
  const columnDefinitions = columnDefs.map((field3) => tableFields[Number(att(field3, "x"))]);
21541
21593
  if (columnNames.some((name3) => !name3)) throw new Error("Invalid pivot column fields");
21542
21594
  const columnSubtotals = fieldSubtotalsOf(columnDefinitions, columnNames);
21543
- const data = names[Number(att(measure3, "fld"))];
21595
+ const data = names[Number(att(measure4, "fld"))];
21544
21596
  const location = parseRange(att(first(root2, "location", NS.x), "ref") ?? "");
21545
21597
  if (!row2 || !data || !location || hasColumn && !col || realRows.length === 2 && !second)
21546
21598
  throw new Error("Invalid pivot fields");
@@ -21582,7 +21634,7 @@ function readOne(workbook, source, part) {
21582
21634
  if (dateFields.some((field3) => onAxis.has(field3)))
21583
21635
  throw new Error("Date fields used as rows, columns or values are preserved");
21584
21636
  const fieldSubtotals = [
21585
- ...subtotalSettings.filter((entry4) => entry4.field !== row2 || entry4.functions.length),
21637
+ ...subtotalSettings.filter((entry5) => entry5.field !== row2 || entry5.functions.length),
21586
21638
  ...columnSubtotals
21587
21639
  ];
21588
21640
  const pivot = {
@@ -21612,14 +21664,14 @@ function readOne(workbook, source, part) {
21612
21664
  },
21613
21665
  valueField: data,
21614
21666
  aggregate,
21615
- valueCaption: decodeEscapes(att(measure3, "name") ?? data),
21667
+ valueCaption: decodeEscapes(att(measure4, "name") ?? data),
21616
21668
  ...dataFields.length > 1 ? {
21617
- additionalValues: dataFields.slice(1).map((measure4) => {
21618
- const field3 = names[Number(att(measure4, "fld"))];
21619
- const aggregate2 = att(measure4, "subtotal") ?? "sum";
21620
- if (!field3 || !PIVOT_AGGREGATES.includes(aggregate2) || att(measure4, "showDataAs") && att(measure4, "showDataAs") !== "normal")
21669
+ additionalValues: dataFields.slice(1).map((measure5) => {
21670
+ const field3 = names[Number(att(measure5, "fld"))];
21671
+ const aggregate2 = att(measure5, "subtotal") ?? "sum";
21672
+ if (!field3 || !PIVOT_AGGREGATES.includes(aggregate2) || att(measure5, "showDataAs") && att(measure5, "showDataAs") !== "normal")
21621
21673
  throw new Error("Unsupported pivot measure");
21622
- return { field: field3, aggregate: aggregate2, caption: decodeEscapes(att(measure4, "name") ?? field3) };
21674
+ return { field: field3, aggregate: aggregate2, caption: decodeEscapes(att(measure5, "name") ?? field3) };
21623
21675
  })
21624
21676
  } : {},
21625
21677
  fields: names,
@@ -21925,9 +21977,9 @@ async function openPackage(input, limits) {
21925
21977
  async function readZipParts(input, limits = {}) {
21926
21978
  const zip = await openPackage(input, resolveLoadLimits(limits));
21927
21979
  const parts = /* @__PURE__ */ new Map();
21928
- for (const entry3 of Object.values(zip.files)) {
21929
- if (entry3.dir) continue;
21930
- parts.set(entry3.name.replace(/^\//, ""), await entry3.async("uint8array"));
21980
+ for (const entry4 of Object.values(zip.files)) {
21981
+ if (entry4.dir) continue;
21982
+ parts.set(entry4.name.replace(/^\//, ""), await entry4.async("uint8array"));
21931
21983
  }
21932
21984
  return parts;
21933
21985
  }
@@ -22051,10 +22103,10 @@ function splitSheetData(xml) {
22051
22103
  function parseColor(element2, palette) {
22052
22104
  if (!element2) return void 0;
22053
22105
  const color2 = {};
22054
- const rgb6 = att(element2, "rgb");
22106
+ const rgb7 = att(element2, "rgb");
22055
22107
  const theme2 = numAttr(element2, "theme");
22056
22108
  const indexed = numAttr(element2, "indexed");
22057
- if (rgb6 && /^[0-9A-Fa-f]{6}([0-9A-Fa-f]{2})?$/.test(rgb6)) color2.rgb = rgb6.toUpperCase();
22109
+ if (rgb7 && /^[0-9A-Fa-f]{6}([0-9A-Fa-f]{2})?$/.test(rgb7)) color2.rgb = rgb7.toUpperCase();
22058
22110
  else if (theme2 !== void 0) color2.theme = theme2;
22059
22111
  else if (indexed !== void 0) {
22060
22112
  const override = palette?.[indexed];
@@ -22338,15 +22390,15 @@ function parseStyles(xml, warnings) {
22338
22390
  const xfId = numAttr(node3, "xfId") ?? 0;
22339
22391
  const name3 = att(node3, "name") ?? `Style ${xfId}`;
22340
22392
  const style3 = styleXfs[xfId] ?? fallback;
22341
- const entry3 = { name: name3, style: structuredClone(style3) };
22393
+ const entry4 = { name: name3, style: structuredClone(style3) };
22342
22394
  const builtinId = numAttr(node3, "builtinId");
22343
- if (builtinId !== void 0) entry3.builtinId = builtinId;
22395
+ if (builtinId !== void 0) entry4.builtinId = builtinId;
22344
22396
  if (!namesByXf.has(xfId)) namesByXf.set(xfId, name3);
22345
- namedStyles.push(entry3);
22397
+ namedStyles.push(entry4);
22346
22398
  }
22347
- const normalAt = namedStyles.findIndex((entry3) => entry3.builtinId === 0);
22399
+ const normalAt = namedStyles.findIndex((entry4) => entry4.builtinId === 0);
22348
22400
  if (normalAt > 0) namedStyles.unshift(...namedStyles.splice(normalAt, 1));
22349
- if (!namedStyles.some((entry3) => entry3.name === "Normal"))
22401
+ if (!namedStyles.some((entry4) => entry4.name === "Normal"))
22350
22402
  namedStyles.unshift({ name: "Normal", style: styleXfs[0] ?? defaultCellStyle(), builtinId: 0 });
22351
22403
  const styles = [];
22352
22404
  const keys = /* @__PURE__ */ new Map();
@@ -22432,13 +22484,13 @@ function readDateGroup(node3) {
22432
22484
  return item2;
22433
22485
  }
22434
22486
  function readFilterColumn(column, dxfs) {
22435
- const entry3 = { offset: numAttr(column, "colId") ?? 0 };
22487
+ const entry4 = { offset: numAttr(column, "colId") ?? 0 };
22436
22488
  const filters = xFirst(column, "filters");
22437
22489
  if (filters) {
22438
- entry3.values = xChildren(filters, "filter").map((f) => att(f, "val") ?? "");
22439
- if (boolAttr(filters, "blank")) entry3.blank = true;
22490
+ entry4.values = xChildren(filters, "filter").map((f) => att(f, "val") ?? "");
22491
+ if (boolAttr(filters, "blank")) entry4.blank = true;
22440
22492
  const groups = xChildren(filters, "dateGroupItem").map(readDateGroup).filter((g) => g !== void 0);
22441
- if (groups.length) entry3.dateGroups = groups;
22493
+ if (groups.length) entry4.dateGroups = groups;
22442
22494
  }
22443
22495
  const custom = xFirst(column, "customFilters");
22444
22496
  if (custom) {
@@ -22449,12 +22501,12 @@ function readFilterColumn(column, dxfs) {
22449
22501
  value: att(c2, "val") ?? ""
22450
22502
  };
22451
22503
  });
22452
- entry3.custom = { ...boolAttr(custom, "and") ? { and: true } : {}, conditions };
22504
+ entry4.custom = { ...boolAttr(custom, "and") ? { and: true } : {}, conditions };
22453
22505
  }
22454
22506
  const top = xFirst(column, "top10");
22455
22507
  if (top) {
22456
22508
  const filterValue = numAttr(top, "filterVal");
22457
- entry3.top10 = {
22509
+ entry4.top10 = {
22458
22510
  top: boolAttr(top, "top", true),
22459
22511
  percent: boolAttr(top, "percent", false),
22460
22512
  value: numAttr(top, "val") ?? 10,
@@ -22465,7 +22517,7 @@ function readFilterColumn(column, dxfs) {
22465
22517
  if (dynamic2) {
22466
22518
  const value3 = numAttr(dynamic2, "val");
22467
22519
  const maxValue = numAttr(dynamic2, "maxVal");
22468
- entry3.dynamic = {
22520
+ entry4.dynamic = {
22469
22521
  type: att(dynamic2, "type") ?? "null",
22470
22522
  ...value3 !== void 0 ? { value: value3 } : {},
22471
22523
  ...maxValue !== void 0 ? { maxValue } : {}
@@ -22475,7 +22527,7 @@ function readFilterColumn(column, dxfs) {
22475
22527
  if (color2) {
22476
22528
  const dxfId = numAttr(color2, "dxfId");
22477
22529
  const style3 = dxfId === void 0 ? void 0 : dxfs?.[dxfId];
22478
- entry3.color = {
22530
+ entry4.color = {
22479
22531
  cellColor: boolAttr(color2, "cellColor", true),
22480
22532
  ...dxfId !== void 0 ? { dxfId } : {},
22481
22533
  ...style3 ? { style: structuredClone(style3) } : {}
@@ -22485,11 +22537,11 @@ function readFilterColumn(column, dxfs) {
22485
22537
  const iconSet = att(icon, "iconSet");
22486
22538
  if (iconSet) {
22487
22539
  const iconId = numAttr(icon, "iconId");
22488
- entry3.icon = { iconSet, ...iconId !== void 0 ? { iconId } : {} };
22540
+ entry4.icon = { iconSet, ...iconId !== void 0 ? { iconId } : {} };
22489
22541
  }
22490
- if (boolAttr(column, "hiddenButton")) entry3.hiddenButton = true;
22491
- entry3.sourceXml = outerXml(column).replace(MAIN_NS_DECL, "");
22492
- return entry3;
22542
+ if (boolAttr(column, "hiddenButton")) entry4.hiddenButton = true;
22543
+ entry4.sourceXml = outerXml(column).replace(MAIN_NS_DECL, "");
22544
+ return entry4;
22493
22545
  }
22494
22546
 
22495
22547
  // xlsx/read/sort-state.ts
@@ -23878,7 +23930,7 @@ function diagramNodesInTreeOrder(data) {
23878
23930
  nodes.sort(
23879
23931
  (a2, b) => (order.get(a2.node.id) ?? Number.MAX_SAFE_INTEGER) - (order.get(b.node.id) ?? Number.MAX_SAFE_INTEGER) || a2.index - b.index
23880
23932
  );
23881
- return treeOrderDiagramNodes(nodes.map((entry3) => entry3.node));
23933
+ return treeOrderDiagramNodes(nodes.map((entry4) => entry4.node));
23882
23934
  }
23883
23935
 
23884
23936
  // units/constants.ts
@@ -23888,7 +23940,7 @@ var EMU_PER_POINT = 12700;
23888
23940
  // drawingml/drawing-shadow.ts
23889
23941
  function resolveDrawingShadow(effects, theme2) {
23890
23942
  const effect = parseDrawingEffects(effects)?.effects.find(
23891
- (entry3) => entry3.kind === "outerShadow"
23943
+ (entry4) => entry4.kind === "outerShadow"
23892
23944
  );
23893
23945
  return effect?.kind === "outerShadow" ? resolveDrawingOuterShadow(effect, theme2) : void 0;
23894
23946
  }
@@ -24439,12 +24491,12 @@ function captureDiagramPictures(model, dataXml, dataParts, drawing2) {
24439
24491
  id4 = `ooxmlDiagramPicture${index3}`;
24440
24492
  parts[id4] = part;
24441
24493
  }
24442
- const entry3 = { ...source, fill: remapFill(source.fill, id4) };
24494
+ const entry4 = { ...source, fill: remapFill(source.fill, id4) };
24443
24495
  const existing = pictures.findIndex(
24444
- (item2) => item2.nodeId === entry3.nodeId && (item2.role === entry3.role && item2.styleLabel === entry3.styleLabel || !item2.role && !item2.styleLabel && item2.fill.relId === entry3.fill.relId)
24496
+ (item2) => item2.nodeId === entry4.nodeId && (item2.role === entry4.role && item2.styleLabel === entry4.styleLabel || !item2.role && !item2.styleLabel && item2.fill.relId === entry4.fill.relId)
24445
24497
  );
24446
- if (existing < 0) pictures.push(entry3);
24447
- else pictures[existing] = entry3;
24498
+ if (existing < 0) pictures.push(entry4);
24499
+ else pictures[existing] = entry4;
24448
24500
  };
24449
24501
  const root2 = parseXml(dataXml).documentElement;
24450
24502
  const saved2 = root2.getElementsByTagNameNS(DIAGRAM_PICTURE_SOURCE_NS, "picture");
@@ -24520,7 +24572,7 @@ async function resolveDiagramDrawingPart(hostPart, dataRelId, drawingExtensionRe
24520
24572
  const entries = await host.readRelationshipEntries(diagramRelationshipsPart(dataPath));
24521
24573
  if (!entries) return void 0;
24522
24574
  const drawing2 = entries.find(
24523
- (entry3) => (!drawingExtensionRelId || entry3.id.trim() === drawingExtensionRelId) && entry3.type.endsWith("/diagramDrawing")
24575
+ (entry4) => (!drawingExtensionRelId || entry4.id.trim() === drawingExtensionRelId) && entry4.type.endsWith("/diagramDrawing")
24524
24576
  );
24525
24577
  const id4 = drawing2?.id.trim() ?? "";
24526
24578
  const target2 = drawing2?.target.trim() ?? "";
@@ -24959,13 +25011,13 @@ async function loadDiagram(hostPart, relationshipIds, host) {
24959
25011
  diagramRelationshipsPart(drawingResolution.path)
24960
25012
  );
24961
25013
  const pictures = (entries ?? []).filter(
24962
- (entry3) => entry3.type.endsWith("/image") && entry3.mode !== "External" && !/^[a-z][a-z0-9+.-]*:/i.test(entry3.target)
25014
+ (entry4) => entry4.type.endsWith("/image") && entry4.mode !== "External" && !/^[a-z][a-z0-9+.-]*:/i.test(entry4.target)
24963
25015
  );
24964
25016
  if (pictures.length)
24965
25017
  drawing2.pictureParts = Object.fromEntries(
24966
- pictures.map((entry3) => [
24967
- entry3.id,
24968
- host.resolvePath(drawingResolution.path, entry3.target)
25018
+ pictures.map((entry4) => [
25019
+ entry4.id,
25020
+ host.resolvePath(drawingResolution.path, entry4.target)
24969
25021
  ])
24970
25022
  );
24971
25023
  } catch {
@@ -24989,8 +25041,8 @@ async function loadDiagram(hostPart, relationshipIds, host) {
24989
25041
  const entries = await host.readRelationshipEntries(diagramRelationshipsPart(owner));
24990
25042
  pictureParts = Object.fromEntries(
24991
25043
  (entries ?? []).filter(
24992
- (entry3) => entry3.type.endsWith("/image") && entry3.mode !== "External" && !/^[a-z][a-z0-9+.-]*:/i.test(entry3.target)
24993
- ).map((entry3) => [entry3.id, host.resolvePath(owner, entry3.target)])
25044
+ (entry4) => entry4.type.endsWith("/image") && entry4.mode !== "External" && !/^[a-z][a-z0-9+.-]*:/i.test(entry4.target)
25045
+ ).map((entry4) => [entry4.id, host.resolvePath(owner, entry4.target)])
24994
25046
  );
24995
25047
  } catch {
24996
25048
  issues.push({
@@ -26457,12 +26509,12 @@ var LEGEND = /* @__PURE__ */ new Set(["legendPos", "legendEntry", "layout", "ove
26457
26509
  function parseLegend(context, element2) {
26458
26510
  reportUnmodelled(context, element2, LEGEND);
26459
26511
  const entries = children(element2, "legendEntry", NS.c).map(
26460
- (entry3) => assignDefined(
26512
+ (entry4) => assignDefined(
26461
26513
  {},
26462
26514
  {
26463
- index: cNumber(context, entry3, "idx"),
26464
- deleted: cBool(context, entry3, "delete"),
26465
- txPr: textProperties(entry3)
26515
+ index: cNumber(context, entry4, "idx"),
26516
+ deleted: cBool(context, entry4, "delete"),
26517
+ txPr: textProperties(entry4)
26466
26518
  }
26467
26519
  )
26468
26520
  );
@@ -26946,9 +26998,9 @@ function view3DXml(view) {
26946
26998
  function legendXml(context, legend) {
26947
26999
  if (!legend) return "";
26948
27000
  const entries = legend.entries.map(
26949
- (entry3) => elementXml(
27001
+ (entry4) => elementXml(
26950
27002
  "legendEntry",
26951
- valXml("idx", entry3.index) + valXml("delete", entry3.deleted) + textBodyXml(context, entry3.txPr)
27003
+ valXml("idx", entry4.index) + valXml("delete", entry4.deleted) + textBodyXml(context, entry4.txPr)
26952
27004
  )
26953
27005
  ).join("");
26954
27006
  return elementXml(
@@ -27099,8 +27151,8 @@ function summaryErrorBars(source) {
27099
27151
  return out;
27100
27152
  }
27101
27153
  function summaryAnalysis(series) {
27102
- const trendlines = (series.trendlines ?? []).map(summaryTrendline).filter((entry3) => entry3 !== void 0);
27103
- const errorBars = (series.errorBars ?? []).map(summaryErrorBars).filter((entry3) => entry3 !== void 0);
27154
+ const trendlines = (series.trendlines ?? []).map(summaryTrendline).filter((entry4) => entry4 !== void 0);
27155
+ const errorBars = (series.errorBars ?? []).map(summaryErrorBars).filter((entry4) => entry4 !== void 0);
27104
27156
  return {
27105
27157
  ...trendlines.length ? { trendlines } : {},
27106
27158
  ...errorBars.length ? { errorBars } : {}
@@ -27510,7 +27562,7 @@ function extraGroups(chartSpace, firstType) {
27510
27562
  const stockOverColumns = group2.kind === "stock" && firstType === "column";
27511
27563
  if (group2.is3D || !(["bar", "line", "area"].includes(group2.kind) || stockOverColumns)) continue;
27512
27564
  const type = group2.kind === "bar" ? "column" : group2.kind;
27513
- const entry3 = {
27565
+ const entry4 = {
27514
27566
  chartType: type,
27515
27567
  series: group2.series.map((source, index3) => ({
27516
27568
  ...chartSummarySeries(
@@ -27524,13 +27576,13 @@ function extraGroups(chartSpace, firstType) {
27524
27576
  secondary: valueAxisId(chartSpace, group2.axisIds) !== primary
27525
27577
  };
27526
27578
  if (group2.grouping && GROUPINGS.has(group2.grouping))
27527
- entry3.grouping = group2.grouping;
27528
- if (type === "stock") entry3.stock = stockStyle(group2);
27579
+ entry4.grouping = group2.grouping;
27580
+ if (type === "stock") entry4.stock = stockStyle(group2);
27529
27581
  if (type === "column") {
27530
- if (group2.gapWidth !== void 0) entry3.barGapWidth = group2.gapWidth;
27531
- if (group2.overlap !== void 0) entry3.barOverlap = group2.overlap;
27582
+ if (group2.gapWidth !== void 0) entry4.barGapWidth = group2.gapWidth;
27583
+ if (group2.overlap !== void 0) entry4.barOverlap = group2.overlap;
27532
27584
  }
27533
- if (entry3.series.length) out.push(entry3);
27585
+ if (entry4.series.length) out.push(entry4);
27534
27586
  }
27535
27587
  return out;
27536
27588
  }
@@ -28234,20 +28286,20 @@ function resolveChartStyleDefinition(style3, resolve) {
28234
28286
  for (const name3 of CHART_STYLE_PARTS) {
28235
28287
  const source = style3.entries[name3];
28236
28288
  if (!source) continue;
28237
- const entry3 = {};
28289
+ const entry4 = {};
28238
28290
  for (const key2 of ["fontSize", "bold", "italic", "underline"]) {
28239
28291
  const value3 = source[key2];
28240
- if (value3 !== void 0) Object.assign(entry3, { [key2]: value3 });
28292
+ if (value3 !== void 0) Object.assign(entry4, { [key2]: value3 });
28241
28293
  }
28242
28294
  const line2 = fillColor(source.line?.fill) ?? (source.lineRef?.color && resolve(source.lineRef.color));
28243
28295
  const fill = fillColor(source.fill) ?? (source.fillRef?.color && resolve(source.fillRef.color));
28244
28296
  const color2 = (source.textColor && resolve(source.textColor)) ?? (source.fontRef?.color && resolve(source.fontRef.color));
28245
- if (color2 !== void 0) entry3.color = color2;
28246
- if (line2 !== void 0) entry3.lineColor = line2;
28247
- if (fill !== void 0) entry3.fillColor = fill;
28297
+ if (color2 !== void 0) entry4.color = color2;
28298
+ if (line2 !== void 0) entry4.lineColor = line2;
28299
+ if (fill !== void 0) entry4.fillColor = fill;
28248
28300
  if (source.line?.widthEmu !== void 0 && source.line.widthEmu > 0)
28249
- entry3.lineWidth = source.line.widthEmu / 12700;
28250
- if (Object.keys(entry3).length) out[name3] = entry3;
28301
+ entry4.lineWidth = source.line.widthEmu / 12700;
28302
+ if (Object.keys(entry4).length) out[name3] = entry4;
28251
28303
  }
28252
28304
  return Object.keys(out).length ? out : void 0;
28253
28305
  }
@@ -28394,9 +28446,9 @@ var TEXT_PARTS = [
28394
28446
  "legend",
28395
28447
  "dataLabel"
28396
28448
  ];
28397
- function inheritChartText(part, entry3, builtIn, root2) {
28398
- if (!root2 || !TEXT_PARTS.includes(part)) return entry3;
28399
- const out = { ...entry3 };
28449
+ function inheritChartText(part, entry4, builtIn, root2) {
28450
+ if (!root2 || !TEXT_PARTS.includes(part)) return entry4;
28451
+ const out = { ...entry4 };
28400
28452
  for (const key2 of TEXT_KEYS) {
28401
28453
  delete out[key2];
28402
28454
  const value3 = root2[key2] ?? builtIn?.[key2];
@@ -28409,11 +28461,11 @@ function inheritChartText(part, entry3, builtIn, root2) {
28409
28461
 
28410
28462
  // chart/render/chart-appearance.ts
28411
28463
  var chartPointsToPixels = (points2) => points2 * EMU_PER_POINT / EMU_PER_PIXEL;
28412
- function typeface(entry3, theme2) {
28413
- const name3 = entry3.typeface;
28464
+ function typeface(entry4, theme2) {
28465
+ const name3 = entry4.typeface;
28414
28466
  if (name3?.startsWith("+mj-")) return theme2.majorFont;
28415
28467
  if (name3?.startsWith("+mn-")) return theme2.minorFont;
28416
- return name3 ?? (entry3.fontRef?.index === "major" ? theme2.majorFont : entry3.fontRef?.index === "minor" ? theme2.minorFont : void 0);
28468
+ return name3 ?? (entry4.fontRef?.index === "major" ? theme2.majorFont : entry4.fontRef?.index === "minor" ? theme2.minorFont : void 0);
28417
28469
  }
28418
28470
  function chartAppearance(chart, theme2) {
28419
28471
  const defaults = builtInChartTextStyle(effectiveBuiltInChartStyle(chart.formatting));
@@ -28422,7 +28474,7 @@ function chartAppearance(chart, theme2) {
28422
28474
  const base2 = chart.styleDefinition?.entries[part];
28423
28475
  const direct = chart.formatting?.entries[part];
28424
28476
  if (!defaults[part] && !base2 && !direct) continue;
28425
- const entry3 = {
28477
+ const entry4 = {
28426
28478
  ...inheritChartText(
28427
28479
  part,
28428
28480
  { ...defaults[part], ...base2, sourceXml: base2?.sourceXml ?? "" },
@@ -28432,8 +28484,8 @@ function chartAppearance(chart, theme2) {
28432
28484
  ...direct,
28433
28485
  sourceXml: direct?.sourceXml ?? base2?.sourceXml ?? ""
28434
28486
  };
28435
- if (base2?.line || direct?.line) entry3.line = { ...base2?.line, ...direct?.line };
28436
- entries[part] = entry3;
28487
+ if (base2?.line || direct?.line) entry4.line = { ...base2?.line, ...direct?.line };
28488
+ entries[part] = entry4;
28437
28489
  }
28438
28490
  const scheme = chartColorScheme(theme2);
28439
28491
  const resolve = (color2) => resolveDrawingColor(
@@ -28446,19 +28498,19 @@ function chartAppearance(chart, theme2) {
28446
28498
  (color2) => drawingColorCss(resolve(color2))
28447
28499
  ) ?? {};
28448
28500
  for (const part of CHART_STYLE_PARTS) {
28449
- const entry3 = entries[part];
28450
- if (!entry3) continue;
28451
- const family = typeface(entry3, theme2);
28452
- const shadow = resolveDrawingShadowXml(entry3.textEffectsXml, {
28501
+ const entry4 = entries[part];
28502
+ if (!entry4) continue;
28503
+ const family = typeface(entry4, theme2);
28504
+ const shadow = resolveDrawingShadowXml(entry4.textEffectsXml, {
28453
28505
  scheme: (name3) => scheme[name3]
28454
28506
  });
28455
28507
  if (shadow) (out[part] ??= {}).textShadow = shadow;
28456
28508
  if (family) (out[part] ??= {}).typeface = family;
28457
- if (entry3.axisVisible !== void 0) (out[part] ??= {}).axisVisible = entry3.axisVisible;
28458
- if (entry3.labelsVisible !== void 0) (out[part] ??= {}).labelsVisible = entry3.labelsVisible;
28459
- if (entry3.line?.widthEmu === 0) (out[part] ??= {}).lineWidth = 0;
28460
- if (entry3.fill?.kind === "gradient") {
28461
- (out[part] ??= {}).gradient = resolveChartGradient(entry3.fill, resolve);
28509
+ if (entry4.axisVisible !== void 0) (out[part] ??= {}).axisVisible = entry4.axisVisible;
28510
+ if (entry4.labelsVisible !== void 0) (out[part] ??= {}).labelsVisible = entry4.labelsVisible;
28511
+ if (entry4.line?.widthEmu === 0) (out[part] ??= {}).lineWidth = 0;
28512
+ if (entry4.fill?.kind === "gradient") {
28513
+ (out[part] ??= {}).gradient = resolveChartGradient(entry4.fill, resolve);
28462
28514
  }
28463
28515
  }
28464
28516
  return out;
@@ -28477,8 +28529,8 @@ function chartRunStyle(run2) {
28477
28529
  }
28478
28530
  function chartTitleText(chart, theme2) {
28479
28531
  const formatting = chart.formatting;
28480
- const entry3 = formatting?.entries.title;
28481
- const body = entry3?.textBody;
28532
+ const entry4 = formatting?.entries.title;
28533
+ const body = entry4?.textBody;
28482
28534
  if (!formatting || !body || body.text !== chart.title) return void 0;
28483
28535
  if (body.paragraphs.length === 1 && body.paragraphs[0].runs.length <= 1 && !body.text.includes("\n") && !body.paragraphs[0].lineSpacing && !body.paragraphs[0].spaceBefore && !body.paragraphs[0].spaceAfter)
28484
28536
  return void 0;
@@ -28491,7 +28543,7 @@ function chartTitleText(chart, theme2) {
28491
28543
  runs: paragraph2.runs.map((run2) => {
28492
28544
  const direct = {
28493
28545
  sourceXml: "",
28494
- ...entry3.textBodyStyle,
28546
+ ...entry4.textBodyStyle,
28495
28547
  ...chartRunStyle(paragraph2.defaultProperties ?? {}),
28496
28548
  ...chartRunStyle(run2)
28497
28549
  };
@@ -29317,23 +29369,23 @@ function readValue2(ctx, c2, cell) {
29317
29369
  const raw2 = v ? v.textContent ?? "" : void 0;
29318
29370
  switch (type) {
29319
29371
  case "s": {
29320
- const entry3 = ctx.sharedStrings[Number(raw2)];
29321
- if (!entry3) {
29372
+ const entry4 = ctx.sharedStrings[Number(raw2)];
29373
+ if (!entry4) {
29322
29374
  if (raw2 !== void 0) ctx.warn("A cell refers to a missing shared string.");
29323
29375
  return;
29324
29376
  }
29325
- cell.value = entry3.text;
29326
- if (entry3.runs) cell.richText = entry3.runs.map((run2) => ({ ...run2 }));
29327
- if (entry3.phonetic) cell.phonetic = structuredClone(entry3.phonetic);
29377
+ cell.value = entry4.text;
29378
+ if (entry4.runs) cell.richText = entry4.runs.map((run2) => ({ ...run2 }));
29379
+ if (entry4.phonetic) cell.phonetic = structuredClone(entry4.phonetic);
29328
29380
  return;
29329
29381
  }
29330
29382
  case "inlineStr": {
29331
29383
  const is = xFirst(c2, "is");
29332
29384
  if (!is) return;
29333
- const entry3 = parseRichString(is, ctx.palette);
29334
- cell.value = entry3.text;
29335
- if (entry3.runs) cell.richText = entry3.runs;
29336
- if (entry3.phonetic) cell.phonetic = entry3.phonetic;
29385
+ const entry4 = parseRichString(is, ctx.palette);
29386
+ cell.value = entry4.text;
29387
+ if (entry4.runs) cell.richText = entry4.runs;
29388
+ if (entry4.phonetic) cell.phonetic = entry4.phonetic;
29337
29389
  return;
29338
29390
  }
29339
29391
  case "str":
@@ -29826,13 +29878,13 @@ async function loadXlsx(input, options2 = {}) {
29826
29878
  const warn = (message) => {
29827
29879
  if (!warnings.includes(message)) warnings.push(message);
29828
29880
  };
29829
- const partOf = (type) => source.targetOfType(workbookPart, type);
29830
- const stylesPart = partOf(RELATIONSHIP_TYPES.styles);
29881
+ const partOf2 = (type) => source.targetOfType(workbookPart, type);
29882
+ const stylesPart = partOf2(RELATIONSHIP_TYPES.styles);
29831
29883
  const styles = parseStyles(stylesPart ? source.text(stylesPart) : void 0, warnings);
29832
- const themePart = partOf(RELATIONSHIP_TYPES.theme);
29833
- const stringsPart = partOf(RELATIONSHIP_TYPES.sharedStrings);
29834
- const personsPart = partOf(RELATIONSHIP_TYPES.person);
29835
- const metadataPart = partOf(RELATIONSHIP_TYPES.sheetMetadata);
29884
+ const themePart = partOf2(RELATIONSHIP_TYPES.theme);
29885
+ const stringsPart = partOf2(RELATIONSHIP_TYPES.sharedStrings);
29886
+ const personsPart = partOf2(RELATIONSHIP_TYPES.person);
29887
+ const metadataPart = partOf2(RELATIONSHIP_TYPES.sheetMetadata);
29836
29888
  const ctx = {
29837
29889
  source,
29838
29890
  sharedStrings: parseSharedStrings(
@@ -29850,24 +29902,24 @@ async function loadXlsx(input, options2 = {}) {
29850
29902
  maxXmlElements: limits.maxXmlElements
29851
29903
  };
29852
29904
  const rels = source.rels(workbookPart);
29853
- const sheets = book.sheets.map((entry3) => {
29854
- const rel = rels.get(entry3.relId);
29905
+ const sheets = book.sheets.map((entry4) => {
29906
+ const rel = rels.get(entry4.relId);
29855
29907
  const target2 = rel ? source.target(workbookPart, rel) : void 0;
29856
29908
  let sheet;
29857
29909
  if (rel?.type === RELATIONSHIP_TYPES.worksheet && target2) {
29858
- sheet = parseWorksheet(ctx, target2, entry3.name, entry3.sheetId);
29910
+ sheet = parseWorksheet(ctx, target2, entry4.name, entry4.sheetId);
29859
29911
  } else {
29860
- sheet = createWorksheet(entry3.name, entry3.sheetId);
29912
+ sheet = createWorksheet(entry4.name, entry4.sheetId);
29861
29913
  if (target2) sheet.partName = target2;
29862
29914
  const kind = rel?.type.split("/").pop() ?? "sheet";
29863
- warn(`Sheet "${entry3.name}" is a ${kind}; it is kept on save but cannot be shown or edited.`);
29915
+ warn(`Sheet "${entry4.name}" is a ${kind}; it is kept on save but cannot be shown or edited.`);
29864
29916
  }
29865
- sheet.state = entry3.state;
29917
+ sheet.state = entry4.state;
29866
29918
  return sheet;
29867
29919
  });
29868
- if (source.has("xl/vbaProject.bin") || partOf(RELATIONSHIP_TYPES.vbaProject))
29920
+ if (source.has("xl/vbaProject.bin") || partOf2(RELATIONSHIP_TYPES.vbaProject))
29869
29921
  warn("The workbook contains VBA macros; they are kept on save but never run.");
29870
- if (partOf(RELATIONSHIP_TYPES.externalLink))
29922
+ if (partOf2(RELATIONSHIP_TYPES.externalLink))
29871
29923
  warn("External workbook links are kept but not updated.");
29872
29924
  const signatures = detectDigitalSignatures([...parts.keys()]);
29873
29925
  if (signatures.hasSignatures)
@@ -30591,14 +30643,14 @@ function strokeOf(line2, fallback, resolve) {
30591
30643
  }
30592
30644
  function analysisView(source, seriesColor, resolve) {
30593
30645
  const plain3 = seriesColor === "none" || seriesColor.startsWith("url(") ? TEXT_COLOR : seriesColor;
30594
- const trendlines = (source.trendlines ?? []).flatMap((entry3) => {
30595
- const { name: _name, line: line2, ...fit3 } = entry3;
30646
+ const trendlines = (source.trendlines ?? []).flatMap((entry4) => {
30647
+ const { name: _name, line: line2, ...fit3 } = entry4;
30596
30648
  const fallback = { color: plain3, width: chartPointsToPixels(1.5), dash: "sysDot" };
30597
30649
  const stroke = strokeOf(line2, fallback, resolve);
30598
30650
  return stroke ? [{ fit: fit3, stroke }] : [];
30599
30651
  });
30600
- const errorBars = (source.errorBars ?? []).flatMap((entry3) => {
30601
- const { direction: direction2, barType, noEndCap, line: line2, ...amount } = entry3;
30652
+ const errorBars = (source.errorBars ?? []).flatMap((entry4) => {
30653
+ const { direction: direction2, barType, noEndCap, line: line2, ...amount } = entry4;
30602
30654
  const stroke = strokeOf(line2, { color: TEXT_COLOR, width: chartPointsToPixels(0.75) }, resolve);
30603
30655
  return stroke ? [{ direction: direction2, barType, amount, endCap: noEndCap !== true, stroke }] : [];
30604
30656
  });
@@ -31833,20 +31885,20 @@ function drawingPaint(node3, colors, placeholder3, depth = 0) {
31833
31885
  (transform2) => !SUPPORTED_TRANSFORMS.has(transform2.name) || (integer4(transform2.value) ?? 100001) > 1e5
31834
31886
  ))
31835
31887
  return void 0;
31836
- let rgb6;
31888
+ let rgb7;
31837
31889
  let inherited;
31838
- if (color2.kind === "srgb") rgb6 = color2.value;
31839
- else if (color2.kind === "system") rgb6 = color2.fallback;
31890
+ if (color2.kind === "srgb") rgb7 = color2.value;
31891
+ else if (color2.kind === "system") rgb7 = color2.fallback;
31840
31892
  else if (color2.kind === "scheme") {
31841
- if (color2.value === "phClr") rgb6 = placeholder3;
31893
+ if (color2.value === "phClr") rgb7 = placeholder3;
31842
31894
  else {
31843
31895
  inherited = drawingPaint(colors.get(color2.value), colors, placeholder3, depth + 1);
31844
- rgb6 = inherited?.color;
31896
+ rgb7 = inherited?.color;
31845
31897
  }
31846
31898
  }
31847
- if (!rgb6 || !/^#?[\da-f]{6}$/i.test(rgb6)) return void 0;
31899
+ if (!rgb7 || !/^#?[\da-f]{6}$/i.test(rgb7)) return void 0;
31848
31900
  const resolved = resolveDrawingColor(
31849
- { kind: "srgb", value: rgb6.replace(/^#/, ""), transforms },
31901
+ { kind: "srgb", value: rgb7.replace(/^#/, ""), transforms },
31850
31902
  void 0,
31851
31903
  { transformOrder: "document" }
31852
31904
  );
@@ -32875,7 +32927,7 @@ function shapeShadow(cells4, color2, report, themed) {
32875
32927
  "approximate-shadow-offset",
32876
32928
  "A shadow without a shape offset uses Visio's default 0.125 inch page offset."
32877
32929
  );
32878
- const clamp3 = (value3, limit2) => Math.max(-limit2, Math.min(limit2, value3));
32930
+ const clamp4 = (value3, limit2) => Math.max(-limit2, Math.min(limit2, value3));
32879
32931
  const transparency = number(cells4, "ShdwForegndTrans", 0, report);
32880
32932
  report(
32881
32933
  "unverified-shadow",
@@ -32884,8 +32936,8 @@ function shapeShadow(cells4, color2, report, themed) {
32884
32936
  return {
32885
32937
  color: color2("ShdwForegnd", "#000000"),
32886
32938
  opacity: Math.max(0, Math.min(1, 1 - transparency)),
32887
- offsetX: clamp3(hasOffset ? number(cells4, "ShapeShdwOffsetX", 0.125, report) : 0.125, 1e3),
32888
- offsetY: clamp3(hasOffset ? number(cells4, "ShapeShdwOffsetY", -0.125, report) : -0.125, 1e3),
32939
+ offsetX: clamp4(hasOffset ? number(cells4, "ShapeShdwOffsetX", 0.125, report) : 0.125, 1e3),
32940
+ offsetY: clamp4(hasOffset ? number(cells4, "ShapeShdwOffsetY", -0.125, report) : -0.125, 1e3),
32889
32941
  blur: Math.max(0, Math.min(10, number(cells4, "ShapeShdwBlur", 0, report)))
32890
32942
  };
32891
32943
  }
@@ -32893,30 +32945,30 @@ function shapeShadow(cells4, color2, report, themed) {
32893
32945
  // visio/effects.ts
32894
32946
  function shapeEffects(cells4, color2, report, themed) {
32895
32947
  const explicit = (name3) => cells4.has(name3) && cells4.get(name3)?.value !== "Themed";
32896
- const clamp3 = (value3, maximum) => Math.max(0, Math.min(maximum, value3));
32948
+ const clamp4 = (value3, maximum) => Math.max(0, Math.min(maximum, value3));
32897
32949
  const result2 = {};
32898
- const glow = explicit("GlowSize") ? clamp3(number(cells4, "GlowSize", 0, report), 2.5) : 0;
32950
+ const glow = explicit("GlowSize") ? clamp4(number(cells4, "GlowSize", 0, report), 2.5) : 0;
32899
32951
  if (glow > 0) {
32900
- const opacity2 = 1 - clamp3(number(cells4, "GlowColorTrans", 0, report), 1);
32952
+ const opacity2 = 1 - clamp4(number(cells4, "GlowColorTrans", 0, report), 1);
32901
32953
  if (opacity2 > 0) result2.glow = { color: color2("GlowColor", "#000000"), opacity: opacity2, size: glow };
32902
32954
  }
32903
- const soft = explicit("SoftEdgesSize") ? clamp3(number(cells4, "SoftEdgesSize", 0, report), 2) : 0;
32955
+ const soft = explicit("SoftEdgesSize") ? clamp4(number(cells4, "SoftEdgesSize", 0, report), 2) : 0;
32904
32956
  if (soft > 0) result2.softEdges = soft;
32905
- const size3 = explicit("ReflectionSize") ? clamp3(number(cells4, "ReflectionSize", 0, report), 1) : 0;
32957
+ const size3 = explicit("ReflectionSize") ? clamp4(number(cells4, "ReflectionSize", 0, report), 1) : 0;
32906
32958
  if (size3 > 0) {
32907
- const opacity2 = 1 - clamp3(number(cells4, "ReflectionTrans", 0, report), 1);
32959
+ const opacity2 = 1 - clamp4(number(cells4, "ReflectionTrans", 0, report), 1);
32908
32960
  if (opacity2 > 0)
32909
32961
  result2.reflection = {
32910
32962
  opacity: opacity2,
32911
32963
  size: size3,
32912
- distance: clamp3(number(cells4, "ReflectionDist", 0, report), 2),
32913
- blur: clamp3(number(cells4, "ReflectionBlur", 0, report), 2)
32964
+ distance: clamp4(number(cells4, "ReflectionDist", 0, report), 2),
32965
+ blur: clamp4(number(cells4, "ReflectionBlur", 0, report), 2)
32914
32966
  };
32915
32967
  }
32916
- const themedCell = (...names) => names.some((name3) => cells4.get(name3)?.value === "Themed");
32917
- if (themed?.glow && themedCell("GlowSize")) result2.glow = themed.glow;
32918
- if (themed?.softEdges && themedCell("SoftEdgesSize")) result2.softEdges = themed.softEdges;
32919
- if (themed?.reflection && themedCell("ReflectionSize", "ReflectionTrans"))
32968
+ const themedCell2 = (...names) => names.some((name3) => cells4.get(name3)?.value === "Themed");
32969
+ if (themed?.glow && themedCell2("GlowSize")) result2.glow = themed.glow;
32970
+ if (themed?.softEdges && themedCell2("SoftEdgesSize")) result2.softEdges = themed.softEdges;
32971
+ if (themed?.reflection && themedCell2("ReflectionSize", "ReflectionTrans"))
32920
32972
  result2.reflection = themed.reflection;
32921
32973
  if (result2.glow || result2.softEdges || result2.reflection)
32922
32974
  report(
@@ -32952,7 +33004,11 @@ var VISIO_ROTATION_PRESETS = [
32952
33004
  ["off-axis-right", "Off Axis Right", 30, 20, 0, 0],
32953
33005
  ["perspective-left", "Perspective Left", -35, 0, 0, 60],
32954
33006
  ["perspective-right", "Perspective Right", 35, 0, 0, 60],
32955
- ["perspective-relaxed", "Perspective Relaxed", 20, 10, 0, 60]
33007
+ ["perspective-relaxed", "Perspective Relaxed", 20, 10, 0, 60],
33008
+ ["perspective-above", "Perspective Above", 0, -25, 0, 60],
33009
+ ["perspective-below", "Perspective Below", 0, 25, 0, 60],
33010
+ ["perspective-heroic-left", "Perspective Heroic Left", -45, -20, 0, 90],
33011
+ ["perspective-heroic-right", "Perspective Heroic Right", 45, -20, 0, 90]
32956
33012
  ].map(([id4, label2, x, y, z, perspective]) => ({
32957
33013
  id: id4,
32958
33014
  label: label2,
@@ -32977,6 +33033,39 @@ function rotationWrites(id4, add) {
32977
33033
  add("RotationZAngle", radians(preset.z), "FillStyle", "DEG");
32978
33034
  add("Perspective", radians(preset.perspective), "FillStyle", "DEG");
32979
33035
  }
33036
+ var rgb = (color2) => `RGB(${[1, 3, 5].map((index3) => parseInt(color2.slice(index3, index3 + 2), 16)).join(",")})`;
33037
+ function solidWrites(edit, add) {
33038
+ if (edit.extrusionDepth !== void 0)
33039
+ add("BevelDepthSize", edit.extrusionDepth / 72, "FillStyle", "PT");
33040
+ if (edit.extrusionColor !== void 0)
33041
+ add("BevelDepthColor", edit.extrusionColor, "FillStyle", void 0, rgb(edit.extrusionColor));
33042
+ if (edit.contourSize !== void 0)
33043
+ add("BevelContourSize", edit.contourSize / 72, "FillStyle", "PT");
33044
+ if (edit.contourColor !== void 0)
33045
+ add("BevelContourColor", edit.contourColor, "FillStyle", void 0, rgb(edit.contourColor));
33046
+ }
33047
+ function snapshotSolid(edit) {
33048
+ const length = (value3, high2, what) => {
33049
+ if (typeof value3 !== "number" || !Number.isFinite(value3) || value3 < 0 || value3 > high2)
33050
+ fail("INVALID_EDIT", `${what} must be 0 to ${high2} points.`);
33051
+ return Math.round(value3 * 100) / 100;
33052
+ };
33053
+ const color2 = (value3, what) => {
33054
+ if (typeof value3 !== "string" || !/^#[0-9a-f]{6}$/i.test(value3))
33055
+ fail("INVALID_EDIT", `${what} requires six hexadecimal digits.`);
33056
+ return value3.toLowerCase();
33057
+ };
33058
+ const result2 = {};
33059
+ if (edit.extrusionDepth !== void 0)
33060
+ result2.extrusionDepth = length(edit.extrusionDepth, 288, "Extrusion depth");
33061
+ if (edit.extrusionColor !== void 0)
33062
+ result2.extrusionColor = color2(edit.extrusionColor, "The extrusion colour");
33063
+ if (edit.contourSize !== void 0)
33064
+ result2.contourSize = length(edit.contourSize, 72, "Contour size");
33065
+ if (edit.contourColor !== void 0)
33066
+ result2.contourColor = color2(edit.contourColor, "The contour colour");
33067
+ return result2;
33068
+ }
32980
33069
  function snapshotBevel(value3) {
32981
33070
  if (!isVisioBevelPreset(value3)) fail("INVALID_EDIT", "Unknown bevel preset.");
32982
33071
  return value3;
@@ -32985,14 +33074,29 @@ function snapshotRotation(value3) {
32985
33074
  if (!isVisioRotationPreset(value3)) fail("INVALID_EDIT", "Unknown 3-D rotation preset.");
32986
33075
  return value3;
32987
33076
  }
32988
- var saved = (cells4, name3) => cells4.has(name3) && cells4.get(name3)?.value !== "Themed" ? number(cells4, name3, 0) : 0;
32989
- function shapeBevel(cells4) {
32990
- const type = Math.trunc(saved(cells4, "BevelTopType"));
32991
- const width = Math.max(0, Math.min(2, saved(cells4, "BevelTopWidth")));
32992
- const height = Math.max(0, Math.min(2, saved(cells4, "BevelTopHeight")));
32993
- return type >= 1 && type <= 12 && (width > 0 || height > 0) ? { type, width, height } : void 0;
32994
- }
32995
- var hasUndrawnBevel = (cells4) => saved(cells4, "BevelBottomType") > 0 || saved(cells4, "BevelContourSize") > 0;
33077
+ var themedCell = (cells4, name3) => cells4.get(name3)?.value === "Themed";
33078
+ var saved = (cells4, name3) => cells4.has(name3) && !themedCell(cells4, name3) ? number(cells4, name3, 0) : 0;
33079
+ var clamp2 = (value3, high2) => Math.max(0, Math.min(high2, value3));
33080
+ function shapeBevel(cells4, themed) {
33081
+ const read = (name3, themeValue) => themedCell(cells4, name3) ? themeValue ?? 0 : saved(cells4, name3);
33082
+ const type = Math.trunc(read("BevelTopType", themed?.bevel?.type));
33083
+ const width = clamp2(read("BevelTopWidth", themed?.bevel?.width), 2);
33084
+ const height = clamp2(read("BevelTopHeight", themed?.bevel?.height), 2);
33085
+ return type >= 1 && type <= 12 ? { type, width, height } : void 0;
33086
+ }
33087
+ function shapeExtrusion(cells4, solid2, colorOf) {
33088
+ const depth = clamp2(saved(cells4, "BevelDepthSize"), 4);
33089
+ return solid2 && depth > 0 ? { depth, color: colorOf("BevelDepthColor", "#ffffff") } : void 0;
33090
+ }
33091
+ function shapeContour(cells4, solid2, themed, colorOf) {
33092
+ const size3 = clamp2(
33093
+ themedCell(cells4, "BevelContourSize") ? themed?.contour?.size ?? 0 : saved(cells4, "BevelContourSize"),
33094
+ 1
33095
+ );
33096
+ const color2 = themedCell(cells4, "BevelContourColor") ? themed?.contour?.color ?? colorOf("BevelContourColor", "#000000") : colorOf("BevelContourColor", "#000000");
33097
+ return solid2 && size3 > 0 ? { size: size3, color: color2 } : void 0;
33098
+ }
33099
+ var hasUndrawnBevel = (cells4) => saved(cells4, "BevelBottomType") > 0;
32996
33100
  function shapeRotation3d(cells4) {
32997
33101
  const angle = (name3) => Math.max(-Math.PI, Math.min(Math.PI, saved(cells4, name3)));
32998
33102
  const x = angle("RotationXAngle"), y = angle("RotationYAngle"), z = angle("RotationZAngle");
@@ -33007,6 +33111,52 @@ function shapeRotation3d(cells4) {
33007
33111
  };
33008
33112
  }
33009
33113
 
33114
+ // visio/theme-solid.ts
33115
+ var PRESETS = [
33116
+ "circle",
33117
+ "relaxedInset",
33118
+ "cross",
33119
+ "coolSlant",
33120
+ "angle",
33121
+ "softRound",
33122
+ "convex",
33123
+ "slope",
33124
+ "divot",
33125
+ "riblet",
33126
+ "hardEdge",
33127
+ "artDeco"
33128
+ ];
33129
+ var EMU2 = 914400;
33130
+ var measure2 = (node3, name3, fallback) => {
33131
+ const raw2 = node3.getAttribute(name3);
33132
+ return raw2 !== null && /^\d{1,10}$/.test(raw2) ? Number(raw2) / EMU2 : fallback;
33133
+ };
33134
+ function themeSolid(cells4, resources, placeholder3) {
33135
+ const solid2 = themeChild(themeFormat(cells4, "Effects", resources), "sp3d");
33136
+ if (!solid2) return void 0;
33137
+ const result2 = {};
33138
+ const top = themeChild(solid2, "bevelT");
33139
+ if (top) {
33140
+ const type = PRESETS.indexOf(top.getAttribute("prst") ?? "circle") + 1;
33141
+ if (type > 0)
33142
+ result2.bevel = {
33143
+ type,
33144
+ width: measure2(top, "w", 76200 / EMU2),
33145
+ height: measure2(top, "h", 76200 / EMU2)
33146
+ };
33147
+ }
33148
+ const size3 = measure2(solid2, "contourW", 0);
33149
+ if (size3 > 0) {
33150
+ const paint3 = drawingPaint(
33151
+ colorChoice(themeChild(solid2, "contourClr")),
33152
+ /* @__PURE__ */ new Map(),
33153
+ placeholder3
33154
+ );
33155
+ result2.contour = { size: size3, ...paint3 ? { color: paint3.color } : {} };
33156
+ }
33157
+ return result2;
33158
+ }
33159
+
33010
33160
  // visio/text-background.ts
33011
33161
  function textBackground(cells4, resources, report) {
33012
33162
  const raw2 = cells4.get("TextBkgnd")?.value;
@@ -33652,8 +33802,8 @@ function color(cells4, name3, fallback, resources, report, themeCells = cells4,
33652
33802
  if (value3 === void 0) return fallback;
33653
33803
  if (/^#[0-9a-f]{6}$/i.test(value3)) return value3;
33654
33804
  if (/^\d+$/.test(value3)) {
33655
- const entry3 = resources.colors.get(value3) ?? PALETTE[Number(value3)];
33656
- if (entry3 && /^#[0-9a-f]{6}$/i.test(entry3)) return entry3;
33805
+ const entry4 = resources.colors.get(value3) ?? PALETTE[Number(value3)];
33806
+ if (entry4 && /^#[0-9a-f]{6}$/i.test(entry4)) return entry4;
33657
33807
  }
33658
33808
  if (value3 === "Themed") {
33659
33809
  const resolved = themeColor2(themeCells, name3, resources, report, gradientRendered);
@@ -33721,15 +33871,27 @@ function shapeStyle(sheet, resources, report, width = number(sheet.cells, "Width
33721
33871
  report,
33722
33872
  themedEffects
33723
33873
  );
33724
- const bevel = shapeBevel(cells4);
33874
+ const themedSolid = themeSolid(
33875
+ cells4,
33876
+ resources,
33877
+ color(cells4, "FillForegnd", "#ffffff", resources, () => {
33878
+ })
33879
+ );
33880
+ const bevel = shapeBevel(cells4, themedSolid);
33881
+ const solidColor2 = (name3, fallback) => color(cells4, name3, fallback, resources, report);
33882
+ const extrusion = shapeExtrusion(cells4, !!bevel, solidColor2);
33883
+ const contour = shapeContour(cells4, !!bevel, themedSolid, solidColor2);
33725
33884
  const rotation3d = shapeRotation3d(cells4);
33726
- if (bevel || rotation3d)
33885
+ if (bevel && (bevel.width > 0 || bevel.height > 0) || rotation3d || extrusion || contour)
33727
33886
  report(
33728
33887
  "approximated-3d",
33729
- "Bevel and 3-D rotation are approximated by a lighting overlay and a parallel projection; perspective and extrusion are not drawn."
33888
+ "Bevel, 3-D rotation, perspective, extrusion and contour are approximations: a lighting overlay, a projection and flat-shaded side faces, not Visio's renderer."
33730
33889
  );
33731
33890
  if (hasUndrawnBevel(cells4))
33732
- report("unsupported-bevel", "Bottom bevels and bevel contours are not drawn.");
33891
+ report(
33892
+ "unsupported-bevel",
33893
+ "Bottom bevels are not drawn (Visio 16 shows no change on the front of a shape)."
33894
+ );
33733
33895
  const themedBegin = themeArrow(cells4, resources, "Begin");
33734
33896
  const themedEnd = themeArrow(cells4, resources, "End");
33735
33897
  const cap = lineCap(cells4, resources, report);
@@ -33757,6 +33919,8 @@ function shapeStyle(sheet, resources, report, width = number(sheet.cells, "Width
33757
33919
  ...shadow ? { shadow } : {},
33758
33920
  ...effects,
33759
33921
  ...bevel ? { bevel } : {},
33922
+ ...extrusion ? { extrusion } : {},
33923
+ ...contour ? { contour } : {},
33760
33924
  ...rotation3d ? { rotation3d } : {}
33761
33925
  };
33762
33926
  }
@@ -34006,7 +34170,7 @@ function visioPageTheme(themes, pageCells) {
34006
34170
  const light = drawingColor(theme2.colors.get("lt1"), theme2.colors);
34007
34171
  const dark = drawingColor(theme2.colors.get("dk1"), theme2.colors);
34008
34172
  const builtIn = VISIO_BUILT_IN_THEMES.find(
34009
- (entry3) => entry3.schemeId === id4 && entry3.name === theme2.name
34173
+ (entry4) => entry4.schemeId === id4 && entry4.name === theme2.name
34010
34174
  );
34011
34175
  return {
34012
34176
  name: theme2.name ?? `Theme ${id4}`,
@@ -34035,7 +34199,7 @@ function visioPageThemeSchemes(themes, pageCells) {
34035
34199
  if (!themes || id4 === void 0 || id4 === 0 || id4 >= 65534) continue;
34036
34200
  const matches2 = themes.filter((theme2) => theme2[field3] === id4);
34037
34201
  const builtIn = matches2.length === 1 ? VISIO_BUILT_IN_THEMES.find(
34038
- (entry3) => entry3.schemeId === id4 && entry3.name === matches2[0].name
34202
+ (entry4) => entry4.schemeId === id4 && entry4.name === matches2[0].name
34039
34203
  ) : void 0;
34040
34204
  if (builtIn) result2[key2] = builtIn.id;
34041
34205
  }
@@ -34371,7 +34535,7 @@ function optionsKey(options2) {
34371
34535
  const { metafileConverter: _converter, pages: _pages, documentCache: _cache, ...rest } = options2;
34372
34536
  return JSON.stringify(rest);
34373
34537
  }
34374
- var cacheMatches = (entry3, pkg, options2) => entry3 !== void 0 && entry3.options === optionsKey(options2) && entry3.converter === options2.metafileConverter && entry3.reads.every(([path3, print]) => pkg.printOf(path3) === print);
34538
+ var cacheMatches = (entry4, pkg, options2) => entry4 !== void 0 && entry4.options === optionsKey(options2) && entry4.converter === options2.metafileConverter && entry4.reads.every(([path3, print]) => pkg.printOf(path3) === print);
34375
34539
  async function readDocumentLevel(pkg, documentPart2, options2, checkTime, forward) {
34376
34540
  const reports = [];
34377
34541
  const report = (...args) => {
@@ -36135,13 +36299,13 @@ function masterMediaParts(media, directory, taken, types, existing) {
36135
36299
  node3.setAttribute("Target", `../media/${part.slice(folder.length)}`);
36136
36300
  rels.appendChild(node3);
36137
36301
  const known = Array.from(types.getElementsByTagNameNS(types.namespaceURI, "Default")).some(
36138
- (entry3) => entry3.getAttribute("Extension")?.toLowerCase() === extension2
36302
+ (entry4) => entry4.getAttribute("Extension")?.toLowerCase() === extension2
36139
36303
  );
36140
36304
  if (!known) {
36141
- const entry3 = types.ownerDocument.createElementNS(types.namespaceURI, "Default");
36142
- entry3.setAttribute("Extension", extension2);
36143
- entry3.setAttribute("ContentType", MEDIA_TYPES[extension2] ?? "application/octet-stream");
36144
- types.insertBefore(entry3, types.firstChild);
36305
+ const entry4 = types.ownerDocument.createElementNS(types.namespaceURI, "Default");
36306
+ entry4.setAttribute("Extension", extension2);
36307
+ entry4.setAttribute("ContentType", MEDIA_TYPES[extension2] ?? "application/octet-stream");
36308
+ types.insertBefore(entry4, types.firstChild);
36145
36309
  }
36146
36310
  }
36147
36311
  return { rels, parts };
@@ -36170,17 +36334,17 @@ async function addMasterToDrawing(source, spec, limits, maxOutput, deadline, che
36170
36334
  if (entries.length >= MAX_MASTERS)
36171
36335
  fail("LIMIT_EDITS", "The drawing holds too many masters to add another.");
36172
36336
  const same8 = (value3, other) => value3?.toLowerCase() === other.toLowerCase();
36173
- const ours = spec.uniqueId && entries.find((entry3) => same8(attribute2(entry3, "UniqueID"), spec.uniqueId));
36337
+ const ours = spec.uniqueId && entries.find((entry4) => same8(attribute2(entry4, "UniqueID"), spec.uniqueId));
36174
36338
  if (ours) return { bytes: source, masterId: attribute2(ours, "ID") ?? "", changedParts: [] };
36175
36339
  const name3 = spec.name;
36176
36340
  const reused = await spec.reuse?.({ pkg, existingPart, entries, check });
36177
36341
  if (reused !== void 0) return { bytes: source, masterId: reused, changedParts: [] };
36178
- const ids = entries.map((entry3) => Number(attribute2(entry3, "ID")));
36342
+ const ids = entries.map((entry4) => Number(attribute2(entry4, "ID")));
36179
36343
  if (ids.some((id5) => !Number.isSafeInteger(id5) || id5 < 0))
36180
36344
  fail("UNSUPPORTED_EDIT_PACKAGE", "The drawing has masters without canonical IDs.");
36181
36345
  const id4 = String(Math.max(1, ...ids.map((value3) => value3 + 1)));
36182
36346
  const names = new Set(
36183
- entries.flatMap((entry3) => [attribute2(entry3, "NameU"), attribute2(entry3, "Name")])
36347
+ entries.flatMap((entry4) => [attribute2(entry4, "NameU"), attribute2(entry4, "Name")])
36184
36348
  );
36185
36349
  const unique2 = names.has(name3) ? `${name3}.${id4}` : name3;
36186
36350
  const relsPart = relationshipsPartFor(mastersPart);
@@ -36220,11 +36384,11 @@ async function addMasterToDrawing(source, spec, limits, maxOutput, deadline, che
36220
36384
  spec.entry(masters, id4, unique2, relId);
36221
36385
  const documentCopy = copy2(document);
36222
36386
  let documentTouched = false;
36223
- const contents = await spec.contents(documentCopy, () => documentTouched = true);
36387
+ const contents2 = await spec.contents(documentCopy, () => documentTouched = true);
36224
36388
  const dirty = /* @__PURE__ */ new Map([
36225
36389
  [mastersPart, masters],
36226
36390
  [relsPart, rels],
36227
- [masterPart, contents],
36391
+ [masterPart, contents2],
36228
36392
  ["[Content_Types].xml", types]
36229
36393
  ]);
36230
36394
  if (documentTouched) dirty.set(documentPart2, documentCopy);
@@ -36532,18 +36696,18 @@ async function ensureStencilMaster(source, master2, limits, maxOutput, deadline,
36532
36696
  uniqueId: builtIn.uniqueId,
36533
36697
  name: name3,
36534
36698
  async reuse({ pkg, existingPart, entries, check: tick }) {
36535
- for (const entry3 of entries) {
36699
+ for (const entry4 of entries) {
36536
36700
  tick();
36537
- if (!existingPart || !same8(attribute2(entry3, "NameU") ?? attribute2(entry3, "Name"), name3))
36701
+ if (!existingPart || !same8(attribute2(entry4, "NameU") ?? attribute2(entry4, "Name"), name3))
36538
36702
  continue;
36539
36703
  try {
36540
- const part = await indexedPart(pkg, existingPart, entry3, "master");
36704
+ const part = await indexedPart(pkg, existingPart, entry4, "master");
36541
36705
  const roots2 = shapesOf2(await visioXml(pkg, part, "MasterContents")).filter(
36542
36706
  (shape) => attribute2(shape, "Del") !== "1"
36543
36707
  );
36544
36708
  const cells4 = new Set(children2(roots2[0], "Cell").map((cell) => attribute2(cell, "N")));
36545
36709
  if (roots2.length === 1 && !cells4.has("BeginX") && !roots2[0].hasAttribute("Master"))
36546
- return attribute2(entry3, "ID") ?? "";
36710
+ return attribute2(entry4, "ID") ?? "";
36547
36711
  } catch {
36548
36712
  }
36549
36713
  }
@@ -36635,26 +36799,26 @@ async function importStencilMaster(source, stencil, stencilMasterId, limits, max
36635
36799
  const stencilDocument = await visioXml(pkg, documentPart2, "VisioDocument");
36636
36800
  const mastersPart = await related(pkg, documentPart2, "masters", false);
36637
36801
  if (!mastersPart) fail("EDIT_TARGET_NOT_FOUND", "The stencil has no masters.");
36638
- const entry3 = children2(await visioXml(pkg, mastersPart, "Masters"), "Master").find(
36802
+ const entry4 = children2(await visioXml(pkg, mastersPart, "Masters"), "Master").find(
36639
36803
  (node3) => attribute2(node3, "ID") === stencilMasterId
36640
36804
  );
36641
- if (!entry3) fail("EDIT_TARGET_NOT_FOUND", "The stencil has no such master.");
36642
- const part = await indexedPart(pkg, mastersPart, entry3, "master");
36805
+ if (!entry4) fail("EDIT_TARGET_NOT_FOUND", "The stencil has no such master.");
36806
+ const part = await indexedPart(pkg, mastersPart, entry4, "master");
36643
36807
  const media = await masterPictures(pkg, part);
36644
- const contents = await visioXml(pkg, part, "MasterContents");
36645
- const name3 = attribute2(entry3, "NameU") ?? attribute2(entry3, "Name") ?? `Master ${stencilMasterId}`;
36808
+ const contents2 = await visioXml(pkg, part, "MasterContents");
36809
+ const name3 = attribute2(entry4, "NameU") ?? attribute2(entry4, "Name") ?? `Master ${stencilMasterId}`;
36646
36810
  return addMasterToDrawing(
36647
36811
  source,
36648
36812
  {
36649
- uniqueId: attribute2(entry3, "UniqueID") ?? "",
36813
+ uniqueId: attribute2(entry4, "UniqueID") ?? "",
36650
36814
  name: name3,
36651
36815
  entry(masters, id4, unique2, relationshipId) {
36652
- const node3 = masters.ownerDocument.importNode(entry3, true);
36816
+ const node3 = masters.ownerDocument.importNode(entry4, true);
36653
36817
  if (node3.namespaceURI !== masters.namespaceURI)
36654
36818
  fail("UNSUPPORTED_EDIT_PACKAGE", "The stencil uses another Visio namespace.");
36655
36819
  node3.setAttribute("ID", id4);
36656
36820
  node3.setAttribute("NameU", unique2);
36657
- if (node3.hasAttribute("Name") && attribute2(entry3, "Name") === name3)
36821
+ if (node3.hasAttribute("Name") && attribute2(entry4, "Name") === name3)
36658
36822
  node3.setAttribute("Name", unique2);
36659
36823
  for (const sheet of children2(node3, "PageSheet"))
36660
36824
  for (const style3 of STYLE_ATTRIBUTES)
@@ -36665,7 +36829,7 @@ async function importStencilMaster(source, stencil, stencilMasterId, limits, max
36665
36829
  media,
36666
36830
  contents(document, touch) {
36667
36831
  const map = styleMapper(stencilDocument, document, touch);
36668
- const root2 = copy2(contents);
36832
+ const root2 = copy2(contents2);
36669
36833
  if (root2.namespaceURI !== document.namespaceURI)
36670
36834
  fail("UNSUPPORTED_EDIT_PACKAGE", "The stencil uses another Visio namespace.");
36671
36835
  for (const shape of Array.from(root2.getElementsByTagNameNS(root2.namespaceURI, "Shape")))
@@ -39534,7 +39698,7 @@ function visioFallbackQuickStyle(style3) {
39534
39698
  return { fill: mix2(base2, 0, 0.5), line: mix2(base2, 0, 0.5), font: light };
39535
39699
  }
39536
39700
  }
39537
- var rgb = (color2) => `RGB(${[1, 3, 5].map((index3) => parseInt(color2.slice(index3, index3 + 2), 16)).join(",")})`;
39701
+ var rgb2 = (color2) => `RGB(${[1, 3, 5].map((index3) => parseInt(color2.slice(index3, index3 + 2), 16)).join(",")})`;
39538
39702
  function shadowWrites(preset, add) {
39539
39703
  if (preset === "none") {
39540
39704
  add("ShdwPattern", 0, "FillStyle");
@@ -39542,7 +39706,7 @@ function shadowWrites(preset, add) {
39542
39706
  }
39543
39707
  const { x, y, blur } = visioShadowPresetGeometry(preset);
39544
39708
  add("ShdwPattern", 1, "FillStyle");
39545
- add("ShdwForegnd", "#000000", "FillStyle", void 0, rgb("#000000"));
39709
+ add("ShdwForegnd", "#000000", "FillStyle", void 0, rgb2("#000000"));
39546
39710
  add("ShdwForegndTrans", 0.6, "FillStyle");
39547
39711
  add("ShapeShdwType", 1, "FillStyle");
39548
39712
  add("ShapeShdwOffsetX", x / 72, "FillStyle", "PT");
@@ -39571,7 +39735,7 @@ async function quickStyleWrites(pkg, document, shape, pageId2, style3, add, chec
39571
39735
  );
39572
39736
  for (const [name3, value3, category] of selectors2) add(name3, value3, category);
39573
39737
  const fallback = visioFallbackQuickStyle(style3);
39574
- const paint3 = (name3, category, color2) => themed ? add(name3, "Themed", category, void 0, "THEMEVAL()") : add(name3, color2, category, void 0, rgb(color2));
39738
+ const paint3 = (name3, category, color2) => themed ? add(name3, "Themed", category, void 0, "THEMEVAL()") : add(name3, color2, category, void 0, rgb2(color2));
39575
39739
  add("FillPattern", 1, "FillStyle");
39576
39740
  add("FillForegndTrans", 0, "FillStyle");
39577
39741
  add("LinePattern", 1, "LineStyle");
@@ -39636,12 +39800,12 @@ function snapshotReflection(value3) {
39636
39800
  blur: bounded3(value3.blur, 100, "Reflection blur must be 0 to 100 points.")
39637
39801
  };
39638
39802
  }
39639
- var rgb2 = (color2) => `RGB(${[1, 3, 5].map((index3) => parseInt(color2.slice(index3, index3 + 2), 16)).join(",")})`;
39803
+ var rgb3 = (color2) => `RGB(${[1, 3, 5].map((index3) => parseInt(color2.slice(index3, index3 + 2), 16)).join(",")})`;
39640
39804
  function effectWrites(edit, add) {
39641
39805
  if (edit.glow) {
39642
39806
  add("GlowSize", edit.glow.size / 72, "FillStyle", "PT");
39643
39807
  if (edit.glow.size > 0) {
39644
- add("GlowColor", edit.glow.color, "FillStyle", void 0, rgb2(edit.glow.color));
39808
+ add("GlowColor", edit.glow.color, "FillStyle", void 0, rgb3(edit.glow.color));
39645
39809
  add("GlowColorTrans", edit.glow.transparency / 100, "FillStyle");
39646
39810
  }
39647
39811
  }
@@ -39865,7 +40029,11 @@ function snapshotFormatting(edit) {
39865
40029
  "softEdges",
39866
40030
  "reflection",
39867
40031
  "bevel",
39868
- "rotation3d"
40032
+ "rotation3d",
40033
+ "extrusionDepth",
40034
+ "extrusionColor",
40035
+ "contourSize",
40036
+ "contourColor"
39869
40037
  ].includes(key2) && edit[key2] !== void 0
39870
40038
  ))
39871
40039
  fail("INVALID_EDIT", "A Quick Style replaces fill, line and font paint as a whole.");
@@ -39879,6 +40047,7 @@ function snapshotFormatting(edit) {
39879
40047
  if (edit.reflection !== void 0) result2.reflection = snapshotReflection(edit.reflection);
39880
40048
  if (edit.bevel !== void 0) result2.bevel = snapshotBevel(edit.bevel);
39881
40049
  if (edit.rotation3d !== void 0) result2.rotation3d = snapshotRotation(edit.rotation3d);
40050
+ Object.assign(result2, snapshotSolid(edit));
39882
40051
  if (result2.fillColor === "none" && result2.fillPattern !== void 0 && result2.fillPattern !== 0)
39883
40052
  fail("INVALID_EDIT", "No fill conflicts with a visible fill pattern.");
39884
40053
  }
@@ -40051,7 +40220,8 @@ function snapshotVisioEdits(edits, maxEdits, maxText) {
40051
40220
  endX,
40052
40221
  endY,
40053
40222
  ...connect ? { connect } : {},
40054
- ...route ? { route } : {}
40223
+ ...route ? { route } : {},
40224
+ ...edit.text !== void 0 ? { text: text9(edit.text) } : {}
40055
40225
  };
40056
40226
  }
40057
40227
  case "create-rectangle":
@@ -40100,7 +40270,7 @@ function snapshotVisioEdits(edits, maxEdits, maxText) {
40100
40270
  };
40101
40271
  }
40102
40272
  case "delete-shape":
40103
- return { ...target2, type: edit.type };
40273
+ return { ...target2, type: edit.type, ...edit.deferred ? { deferred: true } : {} };
40104
40274
  default:
40105
40275
  return fail("INVALID_EDIT", "Unsupported edit command.");
40106
40276
  }
@@ -40218,7 +40388,8 @@ function snapshotEdits(edits) {
40218
40388
  endX: command2.endX,
40219
40389
  endY: command2.endY,
40220
40390
  ...connect ? { connect } : {},
40221
- ...route ? { route } : {}
40391
+ ...route ? { route } : {},
40392
+ ...command2.text !== void 0 ? { text: text9(command2.text) } : {}
40222
40393
  };
40223
40394
  }
40224
40395
  case "replace-plain-text":
@@ -40230,7 +40401,11 @@ function snapshotEdits(edits) {
40230
40401
  case "update-text-field":
40231
40402
  return snapshotTextFieldUpdate(command2);
40232
40403
  case "delete-shape":
40233
- return { type: command2.type, ...target2 };
40404
+ return {
40405
+ type: command2.type,
40406
+ ...target2,
40407
+ ...command2.deferred ? { deferred: true } : {}
40408
+ };
40234
40409
  case "rotate-shape":
40235
40410
  numbers(command2.angle);
40236
40411
  return { type: command2.type, ...target2, angle: command2.angle };
@@ -41325,7 +41500,7 @@ var designTextMeasurer = {
41325
41500
  return em === void 0 ? void 0 : em * style3.fontSize + (style3.letterSpacing ?? 0) * text9.length;
41326
41501
  }
41327
41502
  };
41328
- function measure2(text9, style3) {
41503
+ function measure3(text9, style3) {
41329
41504
  for (const measurer of [designTextMeasurer]) {
41330
41505
  const width = measurer.width(text9, style3);
41331
41506
  if (width !== void 0 && Number.isFinite(width) && width >= 0)
@@ -41369,7 +41544,7 @@ function layoutParagraph(pieces, fallback, paragraph2, available) {
41369
41544
  for (const piece of pieces) {
41370
41545
  for (const token of piece.text.match(/ +|[^ ]+/g) ?? []) {
41371
41546
  if (UNSUPPORTED2.test(token)) return void 0;
41372
- const measured = measure2(token, piece.run);
41547
+ const measured = measure3(token, piece.run);
41373
41548
  if (!measured) return void 0;
41374
41549
  if (token.startsWith(" ")) {
41375
41550
  if (width > 0) pending2 += measured.width;
@@ -41385,7 +41560,7 @@ function layoutParagraph(pieces, fallback, paragraph2, available) {
41385
41560
  pending2 = 0;
41386
41561
  if (start === 0 && Number.isFinite(room()) && measured.width > room()) {
41387
41562
  for (const character of token) {
41388
- const one = measure2(character, piece.run);
41563
+ const one = measure3(character, piece.run);
41389
41564
  if (!one) return void 0;
41390
41565
  const edge = room();
41391
41566
  if (width > 0) {
@@ -41437,7 +41612,7 @@ function visioTextExtents(text9) {
41437
41612
  width(maximum) {
41438
41613
  const inner = maximum === void 0 ? Infinity : maximum - text9.margins.left - text9.margins.right;
41439
41614
  const laid = layout(inner);
41440
- const mark = measure2(" ", text9.runs.at(-1) ?? fallback);
41615
+ const mark = measure3(" ", text9.runs.at(-1) ?? fallback);
41441
41616
  if (!laid || !mark) return void 0;
41442
41617
  let widest = 0;
41443
41618
  laid.forEach((lines3, index3) => {
@@ -43810,13 +43985,13 @@ function createVisioPagePart(parts, pages, pageId2, check) {
43810
43985
  override.setAttribute("PartName", `/${path3}`);
43811
43986
  override.setAttribute("ContentType", contentType);
43812
43987
  parts.types.appendChild(override);
43813
- const contents = parseXml(`<PageContents xmlns="${pages.namespaceURI}"/>`).documentElement;
43814
- contents.setAttributeNS("http://www.w3.org/XML/1998/namespace", "xml:space", "preserve");
43815
- parts.dirty.set(path3, contents);
43988
+ const contents2 = parseXml(`<PageContents xmlns="${pages.namespaceURI}"/>`).documentElement;
43989
+ contents2.setAttributeNS("http://www.w3.org/XML/1998/namespace", "xml:space", "preserve");
43990
+ parts.dirty.set(path3, contents2);
43816
43991
  parts.dirty.set(parts.pagesPart, pages);
43817
43992
  parts.dirty.set(parts.relsPart, parts.rels);
43818
43993
  parts.dirty.set("[Content_Types].xml", parts.types);
43819
- return { page, contents };
43994
+ return { page, contents: contents2 };
43820
43995
  }
43821
43996
 
43822
43997
  // visio/edit-page-decoration.ts
@@ -44218,7 +44393,7 @@ function formattingFont(document, family) {
44218
44393
  var hasCharacterExtras = (edit) => textExtraCharacterKeys.some((key2) => edit[key2] !== void 0);
44219
44394
  var hasParagraphExtras = (edit) => textExtraParagraphKeys.some((key2) => edit[key2] !== void 0);
44220
44395
  var quoted = (text9) => `"${text9.replaceAll('"', '""')}"`;
44221
- var rgb3 = (color2) => `RGB(${[1, 3, 5].map((i) => parseInt(color2.slice(i, i + 2), 16)).join(",")})`;
44396
+ var rgb4 = (color2) => `RGB(${[1, 3, 5].map((i) => parseInt(color2.slice(i, i + 2), 16)).join(",")})`;
44222
44397
  var inches = (value3) => Number(value3.toFixed(10));
44223
44398
  function characterExtraWrites(edit, name3, add) {
44224
44399
  if (edit.fontTransparency !== void 0) add(name3("ColorTrans"), edit.fontTransparency / 100);
@@ -44271,7 +44446,7 @@ function textBlockWrites(shape, edit, add) {
44271
44446
  }
44272
44447
  if (edit.textBackground !== void 0) {
44273
44448
  if (edit.textBackground === "none") add("TextBkgnd", 0);
44274
- else add("TextBkgnd", edit.textBackground, void 0, `${rgb3(edit.textBackground)}+1`);
44449
+ else add("TextBkgnd", edit.textBackground, void 0, `${rgb4(edit.textBackground)}+1`);
44275
44450
  }
44276
44451
  if (edit.textBackgroundTransparency !== void 0)
44277
44452
  add("TextBkgndTrans", edit.textBackgroundTransparency / 100);
@@ -44435,7 +44610,7 @@ function shapeFormattingWrites(edit) {
44435
44610
  edit.fillColor,
44436
44611
  "FillStyle",
44437
44612
  void 0,
44438
- edit.fillColorTheme ? visioThemeColorFormula(edit.fillColorTheme) : rgb4(edit.fillColor)
44613
+ edit.fillColorTheme ? visioThemeColorFormula(edit.fillColorTheme) : rgb5(edit.fillColor)
44439
44614
  );
44440
44615
  add("FillForegndTrans", 0, "FillStyle");
44441
44616
  }
@@ -44450,7 +44625,7 @@ function shapeFormattingWrites(edit) {
44450
44625
  edit.fillBackgroundColor,
44451
44626
  "FillStyle",
44452
44627
  void 0,
44453
- rgb4(edit.fillBackgroundColor)
44628
+ rgb5(edit.fillBackgroundColor)
44454
44629
  );
44455
44630
  }
44456
44631
  if (edit.fillTransparency !== void 0) {
@@ -44463,7 +44638,7 @@ function shapeFormattingWrites(edit) {
44463
44638
  edit.lineColor,
44464
44639
  "LineStyle",
44465
44640
  void 0,
44466
- edit.lineColorTheme ? visioThemeColorFormula(edit.lineColorTheme) : rgb4(edit.lineColor)
44641
+ edit.lineColorTheme ? visioThemeColorFormula(edit.lineColorTheme) : rgb5(edit.lineColor)
44467
44642
  );
44468
44643
  add("LineColorTrans", 0, "LineStyle");
44469
44644
  add("LineGradientEnabled", 0, "LineStyle");
@@ -44502,6 +44677,7 @@ async function shapeFormattingPlan(pkg, document, shape, edit, check) {
44502
44677
  effectWrites(edit, add);
44503
44678
  if (edit.bevel !== void 0) bevelWrites(edit.bevel, add);
44504
44679
  if (edit.rotation3d !== void 0) rotationWrites(edit.rotation3d, add);
44680
+ solidWrites(edit, add);
44505
44681
  return { writes: [...writes.values()], ...rows ? { rows } : {} };
44506
44682
  }
44507
44683
  async function assertShapeFormattingPaintScope(pkg, document, shape, edit, changed, check) {
@@ -44511,7 +44687,7 @@ async function assertShapeFormattingPaintScope(pkg, document, shape, edit, chang
44511
44687
  if (edit.lineColor === void 0 && changed.has("LineColorTrans"))
44512
44688
  await assertNonGradientPaint(pkg, document, shape, edit.pageId, "Line", check);
44513
44689
  }
44514
- function rgb4(color2) {
44690
+ function rgb5(color2) {
44515
44691
  return `RGB(${[1, 3, 5].map((index3) => parseInt(color2.slice(index3, index3 + 2), 16)).join(",")})`;
44516
44692
  }
44517
44693
 
@@ -45196,11 +45372,11 @@ async function masterEntry(pkg, masterId) {
45196
45372
  async function masterIdentities(pkg, masterIds) {
45197
45373
  const result2 = [];
45198
45374
  for (const id4 of masterIds) {
45199
- const entry3 = await masterEntry(pkg, id4);
45200
- if (!entry3) fail("UNSUPPORTED_CLIPBOARD", "The master of a stencil shape cannot be resolved.");
45375
+ const entry4 = await masterEntry(pkg, id4);
45376
+ if (!entry4) fail("UNSUPPORTED_CLIPBOARD", "The master of a stencil shape cannot be resolved.");
45201
45377
  result2.push({
45202
45378
  id: id4,
45203
- identity: ["UniqueID", "BaseID", "NameU"].map((name3) => attribute2(entry3.master, name3) ?? "").join("|")
45379
+ identity: ["UniqueID", "BaseID", "NameU"].map((name3) => attribute2(entry4.master, name3) ?? "").join("|")
45204
45380
  });
45205
45381
  }
45206
45382
  return result2;
@@ -45208,11 +45384,11 @@ async function masterIdentities(pkg, masterIds) {
45208
45384
  async function assertClipboardMasters(pkg, pagePath, source, captured) {
45209
45385
  for (const id4 of instanceMasterIds(source)) {
45210
45386
  const known = captured?.find((master2) => master2.id === id4);
45211
- const entry3 = await masterEntry(pkg, id4);
45212
- if (!known || !entry3) fail("CLIPBOARD_RESOURCE_MISMATCH", ELSEWHERE);
45387
+ const entry4 = await masterEntry(pkg, id4);
45388
+ if (!known || !entry4) fail("CLIPBOARD_RESOURCE_MISMATCH", ELSEWHERE);
45213
45389
  const [actual] = await masterIdentities(pkg, [id4]);
45214
45390
  if (actual.identity !== known.identity) fail("CLIPBOARD_RESOURCE_MISMATCH", ELSEWHERE);
45215
- const masterPart = await indexedPart(pkg, entry3.mastersPart, entry3.master, "master");
45391
+ const masterPart = await indexedPart(pkg, entry4.mastersPart, entry4.master, "master");
45216
45392
  const linked = [...(await pkg.relationships(pagePath)).values()].some(
45217
45393
  (rel) => rel.type === MASTER_RELATIONSHIP3 && rel.target === masterPart
45218
45394
  );
@@ -45810,14 +45986,14 @@ async function editVsdxPicture(pkg, parts, pages, edit, limits, maxOutput, deadl
45810
45986
  (node3) => node3.getAttribute("Extension")?.toLowerCase() === format6.extension
45811
45987
  );
45812
45988
  if (!declared || declared.getAttribute("ContentType") !== info.mimeType) {
45813
- const entry3 = types.ownerDocument.createElementNS(
45989
+ const entry4 = types.ownerDocument.createElementNS(
45814
45990
  types.namespaceURI,
45815
45991
  declared ? "Override" : "Default"
45816
45992
  );
45817
- if (declared) entry3.setAttribute("PartName", `/${media}`);
45818
- else entry3.setAttribute("Extension", format6.extension);
45819
- entry3.setAttribute("ContentType", info.mimeType);
45820
- types.insertBefore(entry3, declared ? null : types.firstElementChild ?? null);
45993
+ if (declared) entry4.setAttribute("PartName", `/${media}`);
45994
+ else entry4.setAttribute("Extension", format6.extension);
45995
+ entry4.setAttribute("ContentType", info.mimeType);
45996
+ types.insertBefore(entry4, declared ? null : types.firstElementChild ?? null);
45821
45997
  }
45822
45998
  const dirty = /* @__PURE__ */ new Map([
45823
45999
  [path3, root2],
@@ -45876,14 +46052,14 @@ function declareType(types, extension2, contentType2, partName) {
45876
46052
  (node3) => node3.getAttribute("Extension")?.toLowerCase() === extension2
45877
46053
  );
45878
46054
  if (declared?.getAttribute("ContentType") === contentType2) return;
45879
- const entry3 = types.ownerDocument.createElementNS(
46055
+ const entry4 = types.ownerDocument.createElementNS(
45880
46056
  types.namespaceURI,
45881
46057
  declared ? "Override" : "Default"
45882
46058
  );
45883
- if (declared) entry3.setAttribute("PartName", `/${partName}`);
45884
- else entry3.setAttribute("Extension", extension2);
45885
- entry3.setAttribute("ContentType", contentType2);
45886
- types.insertBefore(entry3, declared ? null : types.firstElementChild ?? null);
46059
+ if (declared) entry4.setAttribute("PartName", `/${partName}`);
46060
+ else entry4.setAttribute("Extension", extension2);
46061
+ entry4.setAttribute("ContentType", contentType2);
46062
+ types.insertBefore(entry4, declared ? null : types.firstElementChild ?? null);
45887
46063
  }
45888
46064
  async function stage(pkg, parts) {
45889
46065
  const types = cloneRoot(await pkg.readXml("[Content_Types].xml", "Types"));
@@ -46070,7 +46246,7 @@ function refreshThemeColorCaches(root2, colors, check) {
46070
46246
  }
46071
46247
 
46072
46248
  // visio/edit-page-theme-recolor.ts
46073
- var rgb5 = (color2) => `RGB(${[1, 3, 5].map((index3) => parseInt(color2.slice(index3, index3 + 2), 16)).join(",")})`;
46249
+ var rgb6 = (color2) => `RGB(${[1, 3, 5].map((index3) => parseInt(color2.slice(index3, index3 + 2), 16)).join(",")})`;
46074
46250
  function formattingCell2(sheet, name3) {
46075
46251
  const matches2 = children2(sheet, "Cell").filter((cell) => attribute2(cell, "N") === name3);
46076
46252
  return matches2.length === 1 ? matches2[0] : void 0;
@@ -46094,14 +46270,14 @@ function style2(shape, kind) {
46094
46270
  function convert(cell, fallback, mode) {
46095
46271
  if (!cell || cell.hasAttribute("E")) return false;
46096
46272
  if (mode === "themed") {
46097
- if (normal2(attribute2(cell, "F")) !== rgb5(fallback)) return false;
46273
+ if (normal2(attribute2(cell, "F")) !== rgb6(fallback)) return false;
46098
46274
  cell.setAttribute("V", "Themed");
46099
46275
  cell.setAttribute("F", "THEMEVAL()");
46100
46276
  } else {
46101
46277
  if (normal2(attribute2(cell, "F")) !== "THEMEVAL()" || attribute2(cell, "V") !== "Themed")
46102
46278
  return false;
46103
46279
  cell.setAttribute("V", fallback);
46104
- cell.setAttribute("F", rgb5(fallback));
46280
+ cell.setAttribute("F", rgb6(fallback));
46105
46281
  }
46106
46282
  cell.removeAttribute("U");
46107
46283
  return true;
@@ -46320,7 +46496,7 @@ async function editVsdxPageTheme(pkg, parts, pages, edit, limits, maxOutput, dea
46320
46496
  });
46321
46497
  const dirty = /* @__PURE__ */ new Map([[pagesPath, pagesRoot]]);
46322
46498
  const created = /* @__PURE__ */ new Map();
46323
- const contents = copy6(await visioXml(pkg, contentsPath, "PageContents"));
46499
+ const contents2 = copy6(await visioXml(pkg, contentsPath, "PageContents"));
46324
46500
  let recolored = false;
46325
46501
  const part = PAGE_THEME_PARTS.find((name3) => edit[name3] !== void 0);
46326
46502
  if (edit.embellishment !== void 0)
@@ -46333,8 +46509,8 @@ async function editVsdxPageTheme(pkg, parts, pages, edit, limits, maxOutput, dea
46333
46509
  (style3) => attribute2(style3, "ID") === "0"
46334
46510
  );
46335
46511
  if (attribute2(root2, "NameU") !== "No Style")
46336
- recolored = recolorQuickStyledShapes(contents, "fallback", check);
46337
- recolored = refreshThemeColorCaches(contents, VISIO_UNTHEMED_COLORS, check) || recolored;
46512
+ recolored = recolorQuickStyledShapes(contents2, "fallback", check);
46513
+ recolored = refreshThemeColorCaches(contents2, VISIO_UNTHEMED_COLORS, check) || recolored;
46338
46514
  } else if (edit.theme || part) {
46339
46515
  const source = visioBuiltInTheme(edit.theme ?? edit[part]);
46340
46516
  await ensureBuiltInThemePart(pkg, parts, documentPath, themes, source, dirty, created, check);
@@ -46343,7 +46519,7 @@ async function editVsdxPageTheme(pkg, parts, pages, edit, limits, maxOutput, dea
46343
46519
  if (!part || part === "colors") {
46344
46520
  for (const name3 of ["VariationColorIndex", "VariationStyleIndex"])
46345
46521
  setCell(sheet, name3, edit.variant ?? 0);
46346
- recolored = recolorQuickStyledShapes(contents, "themed", check);
46522
+ recolored = recolorQuickStyledShapes(contents2, "themed", check);
46347
46523
  }
46348
46524
  const hex2 = (index3) => `#${source.colors[index3].toLowerCase()}`;
46349
46525
  const variant = visioThemeVariantColors(source, edit.variant ?? 0);
@@ -46352,7 +46528,7 @@ async function editVsdxPageTheme(pkg, parts, pages, edit, limits, maxOutput, dea
46352
46528
  for (let index3 = 1; index3 <= 7; index3++)
46353
46529
  colors[`variant${index3}`] = `#${variant[index3 - 1].toLowerCase()}`;
46354
46530
  if (!part || part === "colors")
46355
- recolored = refreshThemeColorCaches(contents, colors, check) || recolored;
46531
+ recolored = refreshThemeColorCaches(contents2, colors, check) || recolored;
46356
46532
  } else if (edit.variant !== void 0) {
46357
46533
  const current = pageSelectedTheme(themes, sheet);
46358
46534
  if (!current || current.variants.length <= edit.variant)
@@ -46372,9 +46548,9 @@ async function editVsdxPageTheme(pkg, parts, pages, edit, limits, maxOutput, dea
46372
46548
  const color2 = drawingColor(current.colors.get(key2), current.colors);
46373
46549
  if (color2) colors[slot2] = color2;
46374
46550
  }
46375
- recolored = refreshThemeColorCaches(contents, colors, check);
46551
+ recolored = refreshThemeColorCaches(contents2, colors, check);
46376
46552
  }
46377
- if (recolored) dirty.set(contentsPath, contents);
46553
+ if (recolored) dirty.set(contentsPath, contents2);
46378
46554
  if ((/* @__PURE__ */ new Set([...parts.keys(), ...dirty.keys(), ...created.keys()])).size > limits.maxEntries)
46379
46555
  fail("LIMIT_ENTRIES", "The theme exceeds the package entry limit.");
46380
46556
  let total = [...parts.values()].reduce((sum, bytes2) => sum + bytes2.length, 0);
@@ -46465,7 +46641,7 @@ async function editVsdxComments(pkg, parts, pages, edits, limits, maxOutput, dea
46465
46641
  const authors = list(root2, "AuthorList");
46466
46642
  const comments = list(root2, "CommentList");
46467
46643
  const byId = new Map(
46468
- children2(comments, "CommentEntry").map((entry3, index3) => [visioCommentId(entry3, index3), entry3])
46644
+ children2(comments, "CommentEntry").map((entry4, index3) => [visioCommentId(entry4, index3), entry4])
46469
46645
  );
46470
46646
  const removed = /* @__PURE__ */ new Set();
46471
46647
  for (const edit of edits) {
@@ -46488,29 +46664,29 @@ async function editVsdxComments(pkg, parts, pages, edits, limits, maxOutput, dea
46488
46664
  if (edit.initials) author.setAttribute("Initials", edit.initials);
46489
46665
  authors.appendChild(author);
46490
46666
  }
46491
- const entry4 = root2.ownerDocument.createElementNS(root2.namespaceURI, "CommentEntry");
46492
- entry4.setAttribute("AuthorID", attribute2(author, "ID"));
46493
- entry4.setAttribute("PageID", edit.pageId);
46494
- if (edit.shapeId !== void 0) entry4.setAttribute("ShapeID", edit.shapeId);
46495
- entry4.setAttribute("Date", edit.date);
46496
- entry4.setAttribute("CommentID", nextId(children2(comments, "CommentEntry"), "CommentID"));
46497
- entry4.textContent = edit.text;
46498
- comments.appendChild(entry4);
46667
+ const entry5 = root2.ownerDocument.createElementNS(root2.namespaceURI, "CommentEntry");
46668
+ entry5.setAttribute("AuthorID", attribute2(author, "ID"));
46669
+ entry5.setAttribute("PageID", edit.pageId);
46670
+ if (edit.shapeId !== void 0) entry5.setAttribute("ShapeID", edit.shapeId);
46671
+ entry5.setAttribute("Date", edit.date);
46672
+ entry5.setAttribute("CommentID", nextId(children2(comments, "CommentEntry"), "CommentID"));
46673
+ entry5.textContent = edit.text;
46674
+ comments.appendChild(entry5);
46499
46675
  continue;
46500
46676
  }
46501
- const entry3 = byId.get(edit.commentId);
46502
- if (!entry3 || removed.has(entry3) || attribute2(entry3, "PageID") !== edit.pageId)
46677
+ const entry4 = byId.get(edit.commentId);
46678
+ if (!entry4 || removed.has(entry4) || attribute2(entry4, "PageID") !== edit.pageId)
46503
46679
  fail("EDIT_TARGET_NOT_FOUND", "Comment does not exist on the page.");
46504
46680
  if (edit.type === "delete-comment") {
46505
- entry3.parentNode.removeChild(entry3);
46506
- removed.add(entry3);
46681
+ entry4.parentNode.removeChild(entry4);
46682
+ removed.add(entry4);
46507
46683
  continue;
46508
46684
  }
46509
46685
  if (edit.text !== void 0) {
46510
- entry3.textContent = edit.text;
46511
- entry3.setAttribute("EditDate", edit.date);
46686
+ entry4.textContent = edit.text;
46687
+ entry4.setAttribute("EditDate", edit.date);
46512
46688
  }
46513
- if (edit.done !== void 0) entry3.setAttribute("Done", edit.done ? "1" : "0");
46689
+ if (edit.done !== void 0) entry4.setAttribute("Done", edit.done ? "1" : "0");
46514
46690
  }
46515
46691
  const dirty = /* @__PURE__ */ new Map([[path3, root2]]);
46516
46692
  if (created) {
@@ -46973,9 +47149,21 @@ var ROLES = {
46973
47149
  "swimlane list": "swimlane-list",
46974
47150
  "phase list": "phase-list"
46975
47151
  };
47152
+ var CFF_AUTHORED_IDS = {
47153
+ frame: "{0F0C7A10-0001-0000-8E40-00608CF305B2}",
47154
+ "swimlane-list": "{0F0C7A10-0002-0000-8E40-00608CF305B2}",
47155
+ "phase-list": "{0F0C7A10-0003-0000-8E40-00608CF305B2}",
47156
+ lane: "{0F0C7A10-0004-0000-8E40-00608CF305B2}",
47157
+ separator: "{0F0C7A10-0005-0000-8E40-00608CF305B2}"
47158
+ };
47159
+ var AUTHORED_ROLES = new Map(
47160
+ Object.entries(CFF_AUTHORED_IDS).map(([role, id4]) => [id4, role])
47161
+ );
46976
47162
  var noCffMasters = {
46977
47163
  get: () => void 0,
46978
47164
  roleOf: () => void 0,
47165
+ authoredId: () => void 0,
47166
+ authoredPart: () => void 0,
46979
47167
  empty: true
46980
47168
  };
46981
47169
  async function loadCffMasters(pkg) {
@@ -46985,25 +47173,31 @@ async function loadCffMasters(pkg) {
46985
47173
  const list3 = await visioXml(pkg, mastersPart, "Masters");
46986
47174
  const shapes = /* @__PURE__ */ new Map();
46987
47175
  const roles = /* @__PURE__ */ new Map();
47176
+ const authored = /* @__PURE__ */ new Map();
46988
47177
  for (const master2 of children2(list3, "Master")) {
46989
47178
  const id4 = attribute2(master2, "ID");
46990
47179
  const role = ROLES[(attribute2(master2, "NameU") ?? attribute2(master2, "Name") ?? "").toLowerCase()];
46991
- if (!id4 || !role) continue;
46992
- const root2 = await visioXml(
46993
- pkg,
46994
- await indexedPart(pkg, mastersPart, master2, "master"),
46995
- "MasterContents"
46996
- );
47180
+ if (!id4) continue;
47181
+ const own = AUTHORED_ROLES.get((attribute2(master2, "UniqueID") ?? "").toUpperCase());
47182
+ if (!role && !own) continue;
47183
+ const part = await indexedPart(pkg, mastersPart, master2, "master");
47184
+ if (own) {
47185
+ authored.set(own, { id: id4, part });
47186
+ continue;
47187
+ }
47188
+ const root2 = await visioXml(pkg, part, "MasterContents");
46997
47189
  const top = children2(children2(root2, "Shapes")[0], "Shape");
46998
47190
  if (top.length !== 1) continue;
46999
47191
  shapes.set(id4, top[0]);
47000
47192
  roles.set(id4, role);
47001
47193
  }
47002
- if (!shapes.size) return noCffMasters;
47194
+ if (!shapes.size && !authored.size) return noCffMasters;
47003
47195
  return {
47004
47196
  get: (id4) => shapes.get(id4),
47005
47197
  roleOf: (id4) => id4 ? roles.get(id4) : void 0,
47006
- empty: false
47198
+ authoredId: (role) => authored.get(role)?.id,
47199
+ authoredPart: (role) => authored.get(role)?.part,
47200
+ empty: !shapes.size
47007
47201
  };
47008
47202
  }
47009
47203
 
@@ -47026,10 +47220,10 @@ function turnSwimlanes(from, frame, showTitle, lanes) {
47026
47220
  box: horizontal3 ? { minX: 0, maxX: size3, minY: 0, maxY: cross } : { minX: 0, maxX: cross, minY: 0, maxY: size3 }
47027
47221
  }))
47028
47222
  );
47029
- const turned = stacking.lanes.map((entry3, index3) => ({
47030
- id: entry3.id,
47223
+ const turned = stacking.lanes.map((entry4, index3) => ({
47224
+ id: entry4.id,
47031
47225
  from: lanes[index3].box,
47032
- to: entry3.target
47226
+ to: entry4.target
47033
47227
  }));
47034
47228
  return {
47035
47229
  direction: direction2,
@@ -47773,13 +47967,13 @@ function relayout(scope2, frame, order) {
47773
47967
  const titleSize2 = native && options2.title && Number.isFinite(laneTop) ? Math.max(0, frameBox.maxY - laneTop) : void 0;
47774
47968
  const stacking = stackSwimlanes(options2.direction, frameBox, options2.title, boxes, titleSize2);
47775
47969
  const carried = new Map(
47776
- stacking.lanes.map((entry3, index3) => [index3, [...containerClosure(scope2.root, lanes[index3])]])
47970
+ stacking.lanes.map((entry4, index3) => [index3, [...containerClosure(scope2.root, lanes[index3])]])
47777
47971
  );
47778
47972
  if (scope2.contents === "move") for (const ids of carried.values()) assertMovable(scope2.root, ids);
47779
- stacking.lanes.forEach((entry3, index3) => {
47973
+ stacking.lanes.forEach((entry4, index3) => {
47780
47974
  scope2.check();
47781
- place(scope2, lanes[index3], entry3.target);
47782
- if (scope2.contents === "move") shift3(scope2, carried.get(index3), entry3.dx, entry3.dy);
47975
+ place(scope2, lanes[index3], entry4.target);
47976
+ if (scope2.contents === "move") shift3(scope2, carried.get(index3), entry4.dx, entry4.dy);
47783
47977
  });
47784
47978
  const bars = separatorsOf(scope2, frame);
47785
47979
  for (const shape of bars) {
@@ -48132,8 +48326,8 @@ function applySwimlaneEdit(roots2, document, edit, check, instances = /* @__PURE
48132
48326
  check();
48133
48327
  const root2 = roots2.get(edit.pageId);
48134
48328
  if (!root2) fail("EDIT_TARGET_NOT_FOUND", "Page does not exist.");
48135
- const contents = "contents" in edit && edit.contents === "leave" ? "leave" : "move";
48136
- const scope2 = { roots: roots2, document, root: root2, pageId: edit.pageId, check, contents, masters };
48329
+ const contents2 = "contents" in edit && edit.contents === "leave" ? "leave" : "move";
48330
+ const scope2 = { roots: roots2, document, root: root2, pageId: edit.pageId, check, contents: contents2, masters };
48137
48331
  refuseBuiltByVisio(scope2, edit);
48138
48332
  if (edit.type === "create-swimlanes") createSwimlanes(scope2, edit);
48139
48333
  else if (edit.type === "insert-swimlane") insertSwimlane(scope2, edit);
@@ -48143,6 +48337,251 @@ function applySwimlaneEdit(roots2, document, edit, check, instances = /* @__PURE
48143
48337
  else setOptions(scope2, edit);
48144
48338
  }
48145
48339
 
48340
+ // visio/edit-swimlane-stamp.ts
48341
+ var MASTER_RELATIONSHIP4 = "http://schemas.microsoft.com/visio/2010/relationships/master";
48342
+ var CFF_ROLES = Object.keys(CFF_AUTHORED_IDS);
48343
+ function partOf(shape) {
48344
+ if (userValue(shape, VISIO_SWIMLANE_FRAME_ROW) === "1") return "frame";
48345
+ if (userValue(shape, VISIO_SWIMLANE_LANE_ROW) === "1") return "lane";
48346
+ if (userValue(shape, VISIO_SEPARATOR_ROW) === "1") return "separator";
48347
+ if (userValue(shape, "msvStructureType")?.toLowerCase() !== "list") return void 0;
48348
+ const kind = userValue(shape, "msvSDListRequiredCategories");
48349
+ return kind === "Swimlane" ? "swimlane-list" : kind === "Phase" ? "phase-list" : void 0;
48350
+ }
48351
+ function unstampCffMasters(root2, masters) {
48352
+ const ids = new Set(CFF_ROLES.map((role) => masters.authoredId(role)).filter(Boolean));
48353
+ if (!ids.size) return;
48354
+ for (const shape of topLevelShapes(root2))
48355
+ if (ids.has(attribute2(shape, "Master"))) shape.removeAttribute("Master");
48356
+ }
48357
+ function stampCffMasters(root2, masters) {
48358
+ const used = /* @__PURE__ */ new Set();
48359
+ for (const shape of topLevelShapes(root2)) {
48360
+ const id4 = attribute2(shape, "Master");
48361
+ const role = CFF_ROLES.find((item2) => masters.authoredId(item2) === id4);
48362
+ if (role && id4) used.add(role);
48363
+ }
48364
+ for (const shape of topLevelShapes(root2)) {
48365
+ if (attribute2(shape, "Master") || !shapeIdOf(shape)) continue;
48366
+ const role = partOf(shape);
48367
+ const id4 = role && masters.authoredId(role);
48368
+ if (!id4) continue;
48369
+ shape.setAttribute("Master", id4);
48370
+ used.add(role);
48371
+ }
48372
+ return used;
48373
+ }
48374
+ async function relateCffMasters(pkg, parts, pagePath, roles, masters) {
48375
+ const part = relationshipsPartFor(pagePath);
48376
+ const rels = parts.has(part) ? copy2(await pkg.readXml(part, "Relationships")) : parseXml(`<Relationships xmlns="${NS.rels}"/>`).documentElement;
48377
+ const existing = () => Array.from(rels.getElementsByTagNameNS(rels.namespaceURI, "Relationship"));
48378
+ let changed = false;
48379
+ for (const role of roles) {
48380
+ const target2 = masters.authoredPart(role);
48381
+ if (!target2) continue;
48382
+ const linked = existing().some(
48383
+ (rel) => rel.getAttribute("Type") === MASTER_RELATIONSHIP4 && rel.getAttribute("TargetMode") !== "External" && resolvePartPath(pagePath, rel.getAttribute("Target") ?? "") === target2
48384
+ );
48385
+ if (linked) continue;
48386
+ const ids = new Set(existing().map((rel) => rel.getAttribute("Id") ?? ""));
48387
+ let index3 = 1;
48388
+ while (ids.has(`rId${index3}`)) index3++;
48389
+ const relationship2 = rels.ownerDocument.createElementNS(rels.namespaceURI, "Relationship");
48390
+ relationship2.setAttribute("Id", `rId${index3}`);
48391
+ relationship2.setAttribute("Type", MASTER_RELATIONSHIP4);
48392
+ const from = pagePath.split("/").slice(0, -1);
48393
+ const to = target2.split("/");
48394
+ let shared = 0;
48395
+ while (shared < from.length && shared < to.length - 1 && from[shared] === to[shared]) shared++;
48396
+ relationship2.setAttribute(
48397
+ "Target",
48398
+ [...from.slice(shared).map(() => ".."), ...to.slice(shared)].join("/")
48399
+ );
48400
+ rels.appendChild(relationship2);
48401
+ changed = true;
48402
+ }
48403
+ return changed ? { part, rels } : void 0;
48404
+ }
48405
+
48406
+ // visio/cff-author.ts
48407
+ var MM = 1 / 25.4;
48408
+ var STENCIL = ["visMasterStencil", "xfunc_m.vss"];
48409
+ var VERSION = ["visVersion", "15", ""];
48410
+ var HIDDEN_LAYER = ["msvSDMembersOnHiddenLayer", "1", "BOOL"];
48411
+ var QUIET = [
48412
+ ["msvSDContainerNoHighlight", "1", "BOOL"],
48413
+ ["msvSDContainerNoRibbon", "1", "BOOL"]
48414
+ ];
48415
+ var ALL_PARTS = "CFF Container;CFF List;Swimlane;Phase;NonCFF";
48416
+ var DEFINITIONS = {
48417
+ frame: {
48418
+ name: "CFF Container",
48419
+ size: { width: 150 * MM, height: 100 * MM },
48420
+ rows: [
48421
+ ["msvShapeCategories", "CFF Container;DoNotContain"],
48422
+ ["msvStructureType", "Container"],
48423
+ ...QUIET,
48424
+ ["msvSDContainerRequiredCategories", "CFF List"],
48425
+ ["msvSDContainerExcludedCategories", ""],
48426
+ STENCIL,
48427
+ VERSION
48428
+ ]
48429
+ },
48430
+ "swimlane-list": {
48431
+ name: "Swimlane List",
48432
+ size: { width: 125 * MM, height: 100 * MM },
48433
+ rows: [
48434
+ ["msvStructureType", "List"],
48435
+ ["msvShapeCategories", "CFF List;DoNotContain"],
48436
+ ["msvSDListRequiredCategories", "Swimlane"],
48437
+ ["msvSDContainerExcludedCategories", "CFF Container;CFF List;Phase;NonCFF"],
48438
+ ...QUIET,
48439
+ ["msvSDListDirection", "2", ""],
48440
+ HIDDEN_LAYER,
48441
+ STENCIL,
48442
+ VERSION
48443
+ ]
48444
+ },
48445
+ "phase-list": {
48446
+ name: "Phase List",
48447
+ size: { width: 100 * MM, height: 150 * MM },
48448
+ rows: [
48449
+ ["msvStructureType", "List"],
48450
+ ["msvShapeCategories", "CFF List;DoNotContain"],
48451
+ ["msvSDContainerRequiredCategories", "Phase"],
48452
+ ["msvSDListRequiredCategories", "Phase"],
48453
+ ...QUIET,
48454
+ ["msvSDListDirection", "0", ""],
48455
+ HIDDEN_LAYER,
48456
+ STENCIL,
48457
+ VERSION
48458
+ ]
48459
+ },
48460
+ lane: {
48461
+ name: "Swimlane",
48462
+ size: { width: 125 * MM, height: 30 * MM },
48463
+ rows: [
48464
+ ["msvShapeCategories", "Swimlane;DoNotContain"],
48465
+ ["msvStructureType", "Container"],
48466
+ ["msvSDContainerNoRibbon", "1", "BOOL"],
48467
+ ["msvSDContainerExcludedCategories", ALL_PARTS],
48468
+ HIDDEN_LAYER,
48469
+ STENCIL,
48470
+ VERSION
48471
+ ]
48472
+ },
48473
+ separator: {
48474
+ name: "Separator",
48475
+ size: { width: 0.1, height: 100 * MM },
48476
+ rows: [
48477
+ ["msvStructureType", "Container"],
48478
+ ["msvShapeCategories", "Phase;DoNotContain"],
48479
+ ["msvSDContainerExcludedCategories", ALL_PARTS],
48480
+ ...QUIET,
48481
+ HIDDEN_LAYER,
48482
+ STENCIL,
48483
+ VERSION
48484
+ ]
48485
+ }
48486
+ };
48487
+ var CFF_ROLES2 = [
48488
+ "frame",
48489
+ "swimlane-list",
48490
+ "phase-list",
48491
+ "lane",
48492
+ "separator"
48493
+ ];
48494
+ var baseId = (uniqueId) => uniqueId.replace(/^\{[0-9A-F]{8}/, "{4F0C7A10");
48495
+ function entry3(role) {
48496
+ return (masters, id4, name3, relationshipId) => {
48497
+ const doc = masters.ownerDocument;
48498
+ const node3 = (parent, tag) => parent.appendChild(doc.createElementNS(masters.namespaceURI, tag));
48499
+ const master2 = node3(masters, "Master");
48500
+ const { size: size3 } = DEFINITIONS[role];
48501
+ for (const [attribute4, value3] of [
48502
+ ["ID", id4],
48503
+ ["NameU", name3],
48504
+ ["IsCustomNameU", "1"],
48505
+ ["Name", name3],
48506
+ ["IsCustomName", "1"],
48507
+ ["Prompt", ""],
48508
+ ["IconSize", "1"],
48509
+ ["AlignName", "2"],
48510
+ ["MatchByName", "0"],
48511
+ ["IconUpdate", "1"],
48512
+ ["UniqueID", CFF_AUTHORED_IDS[role]],
48513
+ ["BaseID", baseId(CFF_AUTHORED_IDS[role])],
48514
+ ["PatternFlags", "0"],
48515
+ ["Hidden", "1"],
48516
+ ["MasterType", "34"]
48517
+ ])
48518
+ master2.setAttribute(attribute4, value3);
48519
+ const sheet = node3(master2, "PageSheet");
48520
+ for (const style3 of ["LineStyle", "FillStyle", "TextStyle"]) sheet.setAttribute(style3, "0");
48521
+ for (const [cell, value3] of [
48522
+ ["PageWidth", size3.width],
48523
+ ["PageHeight", size3.height],
48524
+ ["PageScale", 1],
48525
+ ["DrawingScale", 1],
48526
+ ["DrawingSizeType", 4],
48527
+ ["DrawingScaleType", 0]
48528
+ ])
48529
+ setCell(sheet, cell, value3);
48530
+ node3(master2, "Rel").setAttributeNS(NS.r, "r:id", relationshipId);
48531
+ };
48532
+ }
48533
+ function contents(role) {
48534
+ return (document) => {
48535
+ const namespace = document.namespaceURI;
48536
+ const root2 = parseXml(`<MasterContents xmlns="${namespace}"/>`).documentElement;
48537
+ root2.setAttributeNS("http://www.w3.org/XML/1998/namespace", "xml:space", "preserve");
48538
+ const doc = root2.ownerDocument;
48539
+ const shapes = root2.appendChild(doc.createElementNS(namespace, "Shapes"));
48540
+ const shape = shapes.appendChild(doc.createElementNS(namespace, "Shape"));
48541
+ shape.setAttribute("ID", "5");
48542
+ shape.setAttribute("Type", "Shape");
48543
+ applyShapeCreationStyles(shape, document);
48544
+ const { width, height } = DEFINITIONS[role].size;
48545
+ for (const [name3, value3, formula2] of [
48546
+ ["PinX", width / 2],
48547
+ ["PinY", height / 2],
48548
+ ["Width", width],
48549
+ ["Height", height],
48550
+ ["LocPinX", width / 2, "Width*0.5"],
48551
+ ["LocPinY", height / 2, "Height*0.5"],
48552
+ ["Angle", 0],
48553
+ ["FlipX", 0],
48554
+ ["FlipY", 0],
48555
+ ["ResizeMode", 0]
48556
+ ])
48557
+ setCell(shape, name3, value3, formula2);
48558
+ shape.appendChild(userSection(shape, DEFINITIONS[role].rows));
48559
+ return root2;
48560
+ };
48561
+ }
48562
+ async function ensureCffMasters(source, limits, maxOutput, deadline, check) {
48563
+ let bytes = source;
48564
+ const changedParts = /* @__PURE__ */ new Set();
48565
+ for (const role of CFF_ROLES2) {
48566
+ const added = await addMasterToDrawing(
48567
+ bytes,
48568
+ {
48569
+ uniqueId: CFF_AUTHORED_IDS[role],
48570
+ name: DEFINITIONS[role].name,
48571
+ entry: entry3(role),
48572
+ contents: contents(role)
48573
+ },
48574
+ limits,
48575
+ maxOutput,
48576
+ deadline,
48577
+ check
48578
+ );
48579
+ bytes = added.bytes;
48580
+ for (const part of added.changedParts) changedParts.add(part);
48581
+ }
48582
+ return { bytes, changedParts: [...changedParts] };
48583
+ }
48584
+
48146
48585
  // visio/edit-layers.ts
48147
48586
  var copy8 = (root2) => root2.ownerDocument.cloneNode(true).documentElement;
48148
48587
  var cellValue2 = (owner, name3) => attribute2(
@@ -48504,11 +48943,33 @@ async function editVsdx(input, edits, options2 = {}) {
48504
48943
  ] : [],
48505
48944
  ...prepared2.templateConverted ? [{ code: "TEMPLATE_SAVED_AS_DRAWING", message: "The template was saved as a drawing." }] : []
48506
48945
  ];
48507
- const final = await editVisioPrepared(prepared2.bytes, snapshot, options2, clock);
48946
+ const final = await editWithDeletionsLast(prepared2.bytes, snapshot, options2, clock);
48508
48947
  return notes.length ? { ...final, diagnostics: [...notes, ...final.diagnostics] } : final;
48509
48948
  }
48949
+ async function editWithDeletionsLast(input, edits, options2, clock) {
48950
+ const deferred2 = edits.filter((edit) => edit.type === "delete-shape" && edit.deferred);
48951
+ if (!deferred2.length) return editVisioPrepared(input, edits, options2, clock);
48952
+ const rest = edits.filter((edit) => !deferred2.includes(edit));
48953
+ const first2 = rest.length ? await editVsdx(input, rest, options2) : { bytes: input, changedParts: [], diagnostics: [] };
48954
+ const plain3 = deferred2.map((edit) => ({ ...edit, deferred: false }));
48955
+ const second = await editVsdx(first2.bytes, plain3, options2);
48956
+ return {
48957
+ bytes: second.bytes,
48958
+ changedParts: [.../* @__PURE__ */ new Set([...first2.changedParts, ...second.changedParts])],
48959
+ diagnostics: [...first2.diagnostics, ...second.diagnostics]
48960
+ };
48961
+ }
48510
48962
  async function editVisioPrepared(input, edits, options2, clock) {
48511
- const edited = await editVsdxTransaction(input, edits, options2, clock);
48963
+ const limits = { ...DEFAULTS, ...options2.limits };
48964
+ const cff = edits.some((edit) => edit.type === "create-swimlanes") ? await ensureCffMasters(
48965
+ input,
48966
+ limits,
48967
+ positive2(options2.maxOutputBytes ?? limits.maxInputBytes),
48968
+ Date.now() + limits.maxRuntimeMs,
48969
+ () => void 0
48970
+ ) : void 0;
48971
+ const first2 = await editVsdxTransaction(cff?.bytes ?? input, edits, options2, clock);
48972
+ const edited = cff ? { ...first2, changedParts: [.../* @__PURE__ */ new Set([...cff.changedParts, ...first2.changedParts])] } : first2;
48512
48973
  const resized = await refreshTextSizes(clock.textSizes, edited, options2, clock.deadline);
48513
48974
  const result2 = await refreshLineJumpCaches(
48514
48975
  clock.jumpPages,
@@ -48695,7 +49156,7 @@ async function editVsdxTransaction(input, edits, options2, clock = {
48695
49156
  (command2) => command2.type !== "replace-plain-text" && command2.type !== "replace-text-ranges" && command2.type !== "insert-text-field" && command2.type !== "update-text-field" && command2.type !== "reorder-shape" && command2.type !== "duplicate-shapes" && command2.type !== "paste-shapes" && command2.type !== "change-shape" && command2.type !== "insert-picture" && !isVisioChartObjectEdit(command2) && command2.type !== "set-page-theme" && !isVisioMetadataEdit(command2) && command2.type !== "set-shape-data" && !isVisioControlEdit(command2) && !isVisioActionEdit(command2) && !isVisioGroupEdit(command2) && !isVisioDiagramPartEdit(command2) && !isVisioContainerEdit(command2) && !isVisioPictureEdit(command2) && !isVisioGuideEdit(command2) && !isVisioFormatEdit(command2)
48696
49157
  );
48697
49158
  let document;
48698
- const cffMasters = commands.some(isVisioSwimlaneEdit) ? await loadCffMasters(pkg) : noCffMasters;
49159
+ const cffMasters = await loadCffMasters(pkg);
48699
49160
  let masterMovePins = emptyMasterMoveProof();
48700
49161
  const instanceCommands = /* @__PURE__ */ new Set();
48701
49162
  let instanceDeletes = /* @__PURE__ */ new Set();
@@ -48705,7 +49166,9 @@ async function editVsdxTransaction(input, edits, options2, clock = {
48705
49166
  )) {
48706
49167
  for (const [pageId2, path4] of pages) {
48707
49168
  const sourceRoot = await visioXml(pkg, path4, "PageContents");
48708
- roots2.set(pageId2, sourceRoot.ownerDocument.cloneNode(true).documentElement);
49169
+ const root2 = sourceRoot.ownerDocument.cloneNode(true).documentElement;
49170
+ unstampCffMasters(root2, cffMasters);
49171
+ roots2.set(pageId2, root2);
48709
49172
  }
48710
49173
  for (const [pageId2, root2] of roots2) {
48711
49174
  const ids = new Set(
@@ -48969,12 +49432,18 @@ async function editVsdxTransaction(input, edits, options2, clock = {
48969
49432
  for (const shapeId2 of takeDeferredTextSizes(root2)) clock.textSizes.push({ pageId: pageId2, shapeId: shapeId2 });
48970
49433
  let totalBytes = [...parts.values()].reduce((sum, bytes2) => sum + bytes2.length, 0);
48971
49434
  let nodes = 0;
49435
+ for (const [path3, root2] of [...dirty]) {
49436
+ if (![...pages.values()].includes(path3)) continue;
49437
+ const used = stampCffMasters(root2, cffMasters);
49438
+ const related2 = used.size ? await relateCffMasters(pkg, parts, path3, used, cffMasters) : void 0;
49439
+ if (related2) dirty.set(related2.part, related2.rels);
49440
+ }
48972
49441
  for (const [path3, root2] of dirty) {
48973
49442
  const serialized = serializeEditedXml(root2, limits, check);
48974
49443
  nodes += serialized.nodes;
48975
49444
  if (nodes > limits.maxTotalXmlNodes)
48976
49445
  fail("LIMIT_XML_TOTAL", "Edited XML node total exceeds limit.");
48977
- totalBytes += serialized.bytes.length - parts.get(path3).length;
49446
+ totalBytes += serialized.bytes.length - (parts.get(path3)?.length ?? 0);
48978
49447
  if (totalBytes > limits.maxTotalBytes)
48979
49448
  fail("LIMIT_TOTAL", "Edited package total exceeds limit.");
48980
49449
  parts.set(path3, serialized.bytes);
@@ -48990,7 +49459,8 @@ async function editVsdxTransaction(input, edits, options2, clock = {
48990
49459
  { ...limits, maxInputBytes: maxOutput, maxRuntimeMs: Math.max(1, deadline - Date.now()) },
48991
49460
  check
48992
49461
  );
48993
- for (const path3 of dirty.keys()) await visioXml(verified.pkg, path3, "PageContents");
49462
+ for (const path3 of dirty.keys())
49463
+ if (!path3.endsWith(".rels")) await visioXml(verified.pkg, path3, "PageContents");
48994
49464
  check();
48995
49465
  }
48996
49466
  return {
@@ -49717,6 +50187,16 @@ function assertViewableDocument(model) {
49717
50187
  finite6(bevel.width, "bevel width", 0, 10);
49718
50188
  finite6(bevel.height, "bevel height", 0, 10);
49719
50189
  }
50190
+ const { extrusion, contour } = shape.style;
50191
+ for (const [item2, label3, size3] of [
50192
+ [extrusion, "extrusion", extrusion?.depth],
50193
+ [contour, "contour", contour?.size]
50194
+ ]) {
50195
+ if (!item2) continue;
50196
+ if (typeof item2.color !== "string" || !/^#[0-9a-f]{6}$/i.test(item2.color))
50197
+ throw new Error(`The scene has an invalid ${label3} color.`);
50198
+ finite6(size3 ?? Number.NaN, `${label3} size`, 0, 10);
50199
+ }
49720
50200
  if (rotation3d)
49721
50201
  for (const key2 of ["x", "y", "z", "perspective"])
49722
50202
  finite6(rotation3d[key2], "3-D rotation", -7, 7);
@@ -50008,6 +50488,8 @@ function copySnapshotScene(model) {
50008
50488
  ...source.softEdges === void 0 ? {} : { softEdges: source.softEdges },
50009
50489
  ...source.rounding === void 0 ? {} : { rounding: source.rounding },
50010
50490
  ...source.bevel ? { bevel: fields(source.bevel, ["type", "width", "height"]) } : {},
50491
+ ...source.extrusion ? { extrusion: fields(source.extrusion, ["depth", "color"]) } : {},
50492
+ ...source.contour ? { contour: fields(source.contour, ["size", "color"]) } : {},
50011
50493
  ...source.rotation3d ? { rotation3d: fields(source.rotation3d, ["x", "y", "z", "perspective", "keepTextFlat"]) } : {},
50012
50494
  ...source.reflection ? { reflection: fields(source.reflection, ["opacity", "size", "distance", "blur"]) } : {},
50013
50495
  ...source.fillPattern ? {
@@ -50431,7 +50913,7 @@ function visioStencilInstanceShape(page, shapeId2) {
50431
50913
  const candidates2 = page.shapes.filter((shape2) => shape2.id === shapeId2);
50432
50914
  const shape = candidates2.length === 1 ? candidates2[0] : void 0;
50433
50915
  if (!shape?.masterId || shape.hidden || (shape.kind === "group" ? !shape.children.length : shape.kind !== "shape") || shape.kind === "shape" && shape.children.length > 0 || holdsForeign(shape) || shape.layerIds?.some(
50434
- (layer) => page.layers?.find((entry3) => entry3.id === layer)?.locked !== false
50916
+ (layer) => page.layers?.find((entry4) => entry4.id === layer)?.locked !== false
50435
50917
  ))
50436
50918
  return void 0;
50437
50919
  return shape;
@@ -50456,7 +50938,7 @@ function visioStencilShape(page, shapeId2) {
50456
50938
  const candidates2 = page.shapes.filter((shape2) => shape2.id === shapeId2);
50457
50939
  const shape = candidates2.length === 1 ? candidates2[0] : void 0;
50458
50940
  if (!shape?.masterId || shape.hidden || !["shape", "group"].includes(shape.kind) || shape.image || shape.foreignVector || shape.layerIds?.some(
50459
- (layer) => page.layers?.find((entry3) => entry3.id === layer)?.locked !== false
50941
+ (layer) => page.layers?.find((entry4) => entry4.id === layer)?.locked !== false
50460
50942
  ))
50461
50943
  return void 0;
50462
50944
  return shape;
@@ -50681,7 +51163,7 @@ function visioOrderingShape(page, shapeId2) {
50681
51163
  if (!shape || shape.hidden) return void 0;
50682
51164
  if (shape.masterId)
50683
51165
  return shape.layerIds?.some(
50684
- (layer) => page.layers?.find((entry3) => entry3.id === layer)?.locked !== false
51166
+ (layer) => page.layers?.find((entry4) => entry4.id === layer)?.locked !== false
50685
51167
  ) ? void 0 : shape;
50686
51168
  return shape.kind === "shape" && !shape.children.length && !shape.image && !shape.foreignVector && !shape.layerIds?.length ? shape : void 0;
50687
51169
  }
@@ -51026,7 +51508,7 @@ function drawingBox(page, box6) {
51026
51508
  height: box6.height / ratio
51027
51509
  };
51028
51510
  }
51029
- var clamp2 = (value3, low2, high2) => Math.min(Math.max(value3, low2), Math.max(low2, high2));
51511
+ var clamp3 = (value3, low2, high2) => Math.min(Math.max(value3, low2), Math.max(low2, high2));
51030
51512
  function visioContainerCommand(page, shapeIds2, style3, heading = "Container") {
51031
51513
  if (shapeIds2.length > 1e3 || new Set(shapeIds2).size !== shapeIds2.length) return void 0;
51032
51514
  const members3 = shapeIds2.map((id4) => topLevel2(page, id4));
@@ -51070,8 +51552,8 @@ function visioCalloutCommand(page, shapeIds2, style3, text9 = "") {
51070
51552
  if (Number(shapeId2) >= 4294967295) return void 0;
51071
51553
  const box6 = visioShapePageBounds(target2);
51072
51554
  const { width, height } = CALLOUT;
51073
- const x = clamp2(box6.maxX + CALLOUT_OFFSET + width / 2, width / 2, page.width - width / 2);
51074
- const y = clamp2(box6.maxY + CALLOUT_OFFSET + height / 2, height / 2, page.height - height / 2);
51555
+ const x = clamp3(box6.maxX + CALLOUT_OFFSET + width / 2, width / 2, page.width - width / 2);
51556
+ const y = clamp3(box6.maxY + CALLOUT_OFFSET + height / 2, height / 2, page.height - height / 2);
51075
51557
  return {
51076
51558
  type: "insert-callout",
51077
51559
  pageId: page.id,
@@ -51169,7 +51651,7 @@ function layeredShape(page, id4) {
51169
51651
  const unlayered = { ...page, shapes: [{ ...shape, layerIds: [] }] };
51170
51652
  const plain3 = visioStyleFormattingShape(unlayered, id4) ?? visioMovableGroup(unlayered, id4, true);
51171
51653
  const locked = shape.layerIds.some(
51172
- (layer) => page.layers?.find((entry3) => entry3.id === layer)?.locked !== false
51654
+ (layer) => page.layers?.find((entry4) => entry4.id === layer)?.locked !== false
51173
51655
  );
51174
51656
  return plain3 && !locked ? shape : void 0;
51175
51657
  }
@@ -51369,9 +51851,9 @@ function visioMasterDropCommand(page, master2, centre2) {
51369
51851
  if (!(ratio > 0) || !Number.isFinite(ratio) || !(page.width > 0) || !(page.height > 0))
51370
51852
  throw new Error("The page size or drawing scale is unusable for dropping a shape.");
51371
51853
  const size3 = visioMasterDropSize(master2);
51372
- const clamp3 = (value3, half, extent2) => extent2 > 2 * half ? Math.min(extent2 - half, Math.max(half, value3)) : extent2 / 2;
51373
- const x = clamp3(centre2?.x ?? page.width / 2, size3.width * ratio / 2, page.width);
51374
- const y = clamp3(centre2?.y ?? page.height / 2, size3.height * ratio / 2, page.height);
51854
+ const clamp4 = (value3, half, extent2) => extent2 > 2 * half ? Math.min(extent2 - half, Math.max(half, value3)) : extent2 / 2;
51855
+ const x = clamp4(centre2?.x ?? page.width / 2, size3.width * ratio / 2, page.width);
51856
+ const y = clamp4(centre2?.y ?? page.height / 2, size3.height * ratio / 2, page.height);
51375
51857
  if (!Number.isFinite(x) || !Number.isFinite(y)) throw new Error("Invalid drop point.");
51376
51858
  return {
51377
51859
  type: "insert-master-instance",
@@ -51389,9 +51871,9 @@ function visioStencilDropCommand(page, master2, centre2, keepOnPage = true) {
51389
51871
  if (!(ratio > 0) || !Number.isFinite(ratio) || !(page.width > 0) || !(page.height > 0))
51390
51872
  throw new Error("The page size or drawing scale is unusable for dropping a shape.");
51391
51873
  const { width, height } = builtIn.master.size;
51392
- const clamp3 = (value3, half, extent2) => !keepOnPage ? value3 : extent2 > 2 * half ? Math.min(extent2 - half, Math.max(half, value3)) : extent2 / 2;
51393
- const x = clamp3(centre2?.x ?? page.width / 2, width * ratio / 2, page.width);
51394
- const y = clamp3(centre2?.y ?? page.height / 2, height * ratio / 2, page.height);
51874
+ const clamp4 = (value3, half, extent2) => !keepOnPage ? value3 : extent2 > 2 * half ? Math.min(extent2 - half, Math.max(half, value3)) : extent2 / 2;
51875
+ const x = clamp4(centre2?.x ?? page.width / 2, width * ratio / 2, page.width);
51876
+ const y = clamp4(centre2?.y ?? page.height / 2, height * ratio / 2, page.height);
51395
51877
  if (!Number.isFinite(x) || !Number.isFinite(y)) throw new Error("Invalid drop point.");
51396
51878
  return {
51397
51879
  type: "drop-stencil-master",
@@ -51640,7 +52122,7 @@ function visioAutoConnectPlan(page, shapeId2, direction2, target2, route = "righ
51640
52122
  // visio/ui/shape-resize.ts
51641
52123
  function unlockedLayers(page, shape) {
51642
52124
  return (shape.layerIds ?? []).every(
51643
- (layer) => page.layers?.find((entry3) => entry3.id === layer)?.locked === false
52125
+ (layer) => page.layers?.find((entry4) => entry4.id === layer)?.locked === false
51644
52126
  );
51645
52127
  }
51646
52128
  function resizableLocalGroup(page, shape) {
@@ -52443,11 +52925,11 @@ function replaceEntries(model, scope2, requirePage = true) {
52443
52925
  if (names > VISIO_TEXT_REPLACE_LIMITS.names) textReplaceError("Replace shape names exceed aggregate limits.");
52444
52926
  characters += text9.length;
52445
52927
  if (characters > VISIO_TEXT_REPLACE_LIMITS.text) textReplaceError("Replace text exceeds aggregate limits.");
52446
- const entry3 = { pageId: pageId2, shapeId: shapeId2, name: name3, pageIndex, text: text9, end: 0 };
52928
+ const entry4 = { pageId: pageId2, shapeId: shapeId2, name: name3, pageIndex, text: text9, end: 0 };
52447
52929
  identities.set(JSON.stringify([pageId2, shapeId2]), all.length);
52448
- all.push(entry3);
52930
+ all.push(entry4);
52449
52931
  walk(shape.children, depth + 1);
52450
- entry3.end = all.length;
52932
+ entry4.end = all.length;
52451
52933
  }
52452
52934
  };
52453
52935
  walk(page.shapes, 0);
@@ -52455,20 +52937,20 @@ function replaceEntries(model, scope2, requirePage = true) {
52455
52937
  if (requirePage && !pageIds2.has(scope2.pageId))
52456
52938
  textReplaceError("Replace current page does not exist.");
52457
52939
  if (scope2.scope === "all-pages") return all;
52458
- if (scope2.scope === "current-page") return all.filter((entry3) => entry3.pageId === scope2.pageId);
52940
+ if (scope2.scope === "current-page") return all.filter((entry4) => entry4.pageId === scope2.pageId);
52459
52941
  const result2 = [], added = /* @__PURE__ */ new Set();
52460
52942
  for (const selected2 of scope2.selection ?? []) {
52461
52943
  const pageId2 = selected2.pageId ?? scope2.pageId;
52462
52944
  const start = identities.get(JSON.stringify([pageId2, selected2.id]));
52463
52945
  if (start === void 0) return textReplaceError("Replace selected shape does not exist.");
52464
52946
  for (let index3 = start; index3 < all[start].end; index3++) {
52465
- const entry3 = all[index3];
52466
- if (added.has(entry3)) {
52467
- index3 = entry3.end - 1;
52947
+ const entry4 = all[index3];
52948
+ if (added.has(entry4)) {
52949
+ index3 = entry4.end - 1;
52468
52950
  continue;
52469
52951
  }
52470
- result2.push(entry3);
52471
- added.add(entry3);
52952
+ result2.push(entry4);
52953
+ added.add(entry4);
52472
52954
  }
52473
52955
  }
52474
52956
  return result2;
@@ -52484,31 +52966,31 @@ function visioTextOccurrenceSelection(model, occurrence) {
52484
52966
  { pageId: pageId2, scope: "all-pages"},
52485
52967
  false
52486
52968
  );
52487
- const entry3 = entries.find((item2) => item2.pageId === pageId2 && item2.shapeId === shapeId2);
52488
- if (!entry3 || end > entry3.text.length) return void 0;
52969
+ const entry4 = entries.find((item2) => item2.pageId === pageId2 && item2.shapeId === shapeId2);
52970
+ if (!entry4 || end > entry4.text.length) return void 0;
52489
52971
  return Object.freeze({
52490
- pageIndex: entry3.pageIndex,
52491
- selection: Object.freeze({ id: shapeId2, name: entry3.name, pageId: pageId2 })
52972
+ pageIndex: entry4.pageIndex,
52973
+ selection: Object.freeze({ id: shapeId2, name: entry4.name, pageId: pageId2 })
52492
52974
  });
52493
52975
  }
52494
52976
 
52495
52977
  // visio/ui/text-replace.ts
52496
52978
  function occurrences(entries, query) {
52497
52979
  const result2 = [];
52498
- for (const entry3 of entries) {
52499
- let start = entry3.text.indexOf(query);
52980
+ for (const entry4 of entries) {
52981
+ let start = entry4.text.indexOf(query);
52500
52982
  while (start >= 0) {
52501
52983
  if (result2.length >= VISIO_TEXT_REPLACE_LIMITS.matches)
52502
52984
  textReplaceError("Replace occurrence count exceeds limits.");
52503
52985
  result2.push(
52504
52986
  Object.freeze({
52505
- pageId: entry3.pageId,
52506
- shapeId: entry3.shapeId,
52987
+ pageId: entry4.pageId,
52988
+ shapeId: entry4.shapeId,
52507
52989
  start,
52508
52990
  end: start + query.length
52509
52991
  })
52510
52992
  );
52511
- start = entry3.text.indexOf(query, start + query.length);
52993
+ start = entry4.text.indexOf(query, start + query.length);
52512
52994
  }
52513
52995
  }
52514
52996
  return Object.freeze(result2);
@@ -52527,7 +53009,7 @@ function visioTextReplaceFindNext(model, input, current) {
52527
53009
  }
52528
53010
  var records = /* @__PURE__ */ new WeakMap();
52529
53011
  var sameOccurrence = (a2, b) => a2.pageId === b.pageId && a2.shapeId === b.shapeId && a2.start === b.start && a2.end === b.end;
52530
- var sameTarget = (entry3, match) => entry3.pageId === match.pageId && entry3.shapeId === match.shapeId;
53012
+ var sameTarget = (entry4, match) => entry4.pageId === match.pageId && entry4.shapeId === match.shapeId;
52531
53013
  function snapshotOccurrence(original) {
52532
53014
  if (original === void 0) return void 0;
52533
53015
  const current = {
@@ -52562,9 +53044,9 @@ function visioTextReplacePlan(model, input) {
52562
53044
  if (targets.size > VISIO_TEXT_REPLACE_LIMITS.commands) textReplaceError("Replace command count exceeds limits.");
52563
53045
  const edits = [], updated = [];
52564
53046
  let outputCharacters = 0, commandCharacters = 0;
52565
- for (const entry3 of entries) {
52566
- const matches2 = targets.get(JSON.stringify([entry3.pageId, entry3.shapeId]));
52567
- let text9 = entry3.text;
53047
+ for (const entry4 of entries) {
53048
+ const matches2 = targets.get(JSON.stringify([entry4.pageId, entry4.shapeId]));
53049
+ let text9 = entry4.text;
52568
53050
  if (matches2) {
52569
53051
  const length = text9.length + matches2.length * (replacement2.length - scope2.query.length);
52570
53052
  outputCharacters += length;
@@ -52578,17 +53060,17 @@ function visioTextReplacePlan(model, input) {
52578
53060
  }
52579
53061
  parts.push(text9.slice(from));
52580
53062
  text9 = parts.join("");
52581
- const target2 = { pageId: entry3.pageId, shapeId: entry3.shapeId };
53063
+ const target2 = { pageId: entry4.pageId, shapeId: entry4.shapeId };
52582
53064
  if (replacement2.includes("\n") || scope2.query.includes("\n")) {
52583
53065
  commandCharacters += text9.length;
52584
53066
  edits.push(Object.freeze({ type: "replace-plain-text", ...target2, text: text9 }));
52585
53067
  } else {
52586
- commandCharacters += entry3.text.length + matches2.length * replacement2.length;
53068
+ commandCharacters += entry4.text.length + matches2.length * replacement2.length;
52587
53069
  edits.push(
52588
53070
  Object.freeze({
52589
53071
  type: "replace-text-ranges",
52590
53072
  ...target2,
52591
- expectedText: entry3.text,
53073
+ expectedText: entry4.text,
52592
53074
  ranges: Object.freeze(
52593
53075
  matches2.map(
52594
53076
  (match) => Object.freeze({ start: match.start, end: match.end, text: replacement2 })
@@ -52600,12 +53082,12 @@ function visioTextReplacePlan(model, input) {
52600
53082
  if (commandCharacters > VISIO_TEXT_REPLACE_LIMITS.output)
52601
53083
  textReplaceError("Replace input exceeds aggregate command text limits.");
52602
53084
  }
52603
- updated.push({ ...entry3, text: text9 });
53085
+ updated.push({ ...entry4, text: text9 });
52604
53086
  }
52605
53087
  const remaining = mode === "current" ? occurrences(updated, scope2.query) : [];
52606
- const activeEntry = active ? entries.findIndex((entry3) => sameTarget(entry3, active)) : -1;
53088
+ const activeEntry = active ? entries.findIndex((entry4) => sameTarget(entry4, active)) : -1;
52607
53089
  const entryIndices = new Map(
52608
- entries.map((entry3, index3) => [JSON.stringify([entry3.pageId, entry3.shapeId]), index3])
53090
+ entries.map((entry4, index3) => [JSON.stringify([entry4.pageId, entry4.shapeId]), index3])
52609
53091
  );
52610
53092
  const nextOccurrence = active ? remaining.find((match) => {
52611
53093
  const index3 = entryIndices.get(JSON.stringify([match.pageId, match.shapeId]));
@@ -52624,9 +53106,9 @@ function visioTextReplaceCommands(model, plan) {
52624
53106
  const record2 = records.get(plan);
52625
53107
  if (!record2) return textReplaceError("Replace plan was not produced by this planner.");
52626
53108
  const current = replaceEntries(model, record2.scope);
52627
- if (current.length !== record2.entries.length || current.some((entry3, index3) => {
53109
+ if (current.length !== record2.entries.length || current.some((entry4, index3) => {
52628
53110
  const saved2 = record2.entries[index3];
52629
- return entry3.pageId !== saved2.pageId || entry3.shapeId !== saved2.shapeId || entry3.text !== saved2.text;
53111
+ return entry4.pageId !== saved2.pageId || entry4.shapeId !== saved2.shapeId || entry4.text !== saved2.text;
52630
53112
  }))
52631
53113
  textReplaceError("Replace plan is stale. Search the current drawing again.");
52632
53114
  return plan.edits.map(
@@ -53390,12 +53872,12 @@ function contentClosure(page, lane) {
53390
53872
  function carryContents(page, stacked) {
53391
53873
  const ratio = scale(page);
53392
53874
  const edits = [];
53393
- for (const entry3 of stacked) {
53394
- const lane = topLevel3(page, entry3.id);
53395
- if (!lane || Math.abs(entry3.dx) < 1e-9 && Math.abs(entry3.dy) < 1e-9) continue;
53875
+ for (const entry4 of stacked) {
53876
+ const lane = topLevel3(page, entry4.id);
53877
+ if (!lane || Math.abs(entry4.dx) < 1e-9 && Math.abs(entry4.dy) < 1e-9) continue;
53396
53878
  const ids = contentIds(page, lane);
53397
53879
  if (!ids.length) continue;
53398
- const moves2 = visioMoveCommands(page, ids, { x: entry3.dx * ratio, y: entry3.dy * ratio });
53880
+ const moves2 = visioMoveCommands(page, ids, { x: entry4.dx * ratio, y: entry4.dy * ratio });
53399
53881
  if (!moves2) return void 0;
53400
53882
  edits.push(...moves2);
53401
53883
  }
@@ -53496,11 +53978,11 @@ function visioResizeSwimlane(page, laneId, size3) {
53496
53978
  if (!info || !lane || !Number.isFinite(size3)) return void 0;
53497
53979
  const drawingSize = Math.max(VISIO_SWIMLANE_MIN, size3 / scale(page));
53498
53980
  const horizontal3 = info.options.direction === "horizontal";
53499
- const inputs = stackInput(page, info.lanes).map((entry3) => {
53500
- if (entry3.id !== laneId) return entry3;
53501
- const box6 = entry3.box;
53981
+ const inputs = stackInput(page, info.lanes).map((entry4) => {
53982
+ if (entry4.id !== laneId) return entry4;
53983
+ const box6 = entry4.box;
53502
53984
  return {
53503
- id: entry3.id,
53985
+ id: entry4.id,
53504
53986
  box: horizontal3 ? { ...box6, minY: box6.maxY - drawingSize } : { ...box6, maxX: box6.minX + drawingSize }
53505
53987
  };
53506
53988
  });
@@ -53740,7 +54222,7 @@ function components(graph) {
53740
54222
  }
53741
54223
  if (ids.length === 1) isolated.push(node3.id);
53742
54224
  else {
53743
- const order = new Map(graph.nodes.map((entry3, index3) => [entry3.id, index3]));
54225
+ const order = new Map(graph.nodes.map((entry4, index3) => [entry4.id, index3]));
53744
54226
  connected.push(ids.sort((a2, b) => order.get(a2) - order.get(b)));
53745
54227
  }
53746
54228
  }
@@ -54033,9 +54515,9 @@ function visioConnectorEdges(page) {
54033
54515
  for (const connection of page.connectors) {
54034
54516
  const end = /^Begin/i.test(connection.fromCell) ? "begin" : /^End/i.test(connection.fromCell) ? "end" : void 0;
54035
54517
  if (!end) continue;
54036
- const entry3 = ends.get(connection.fromShapeId) ?? {};
54037
- entry3[end] ??= connection.toShapeId;
54038
- ends.set(connection.fromShapeId, entry3);
54518
+ const entry4 = ends.get(connection.fromShapeId) ?? {};
54519
+ entry4[end] ??= connection.toShapeId;
54520
+ ends.set(connection.fromShapeId, entry4);
54039
54521
  }
54040
54522
  const edges = [];
54041
54523
  for (const { begin, end } of ends.values())
@@ -54442,6 +54924,56 @@ function visioOrgReLayout(page) {
54442
54924
  return result2 && result2.moves.length ? result2.moves : void 0;
54443
54925
  }
54444
54926
 
54927
+ // visio/ui/org-chart-belt.ts
54928
+ function visioOrgSwapMaster(page, old, newId, drop2) {
54929
+ const ratio = page.drawingToPageScale ?? 1;
54930
+ const box6 = visioShapePageBounds(old);
54931
+ const data = {};
54932
+ for (const { row: row2 } of VISIO_ORG_ROWS) {
54933
+ const value3 = old.shapeData?.find((item2) => item2.name === row2)?.rawValue;
54934
+ if (value3 !== void 0) data[row2] = String(value3);
54935
+ }
54936
+ const rest = [
54937
+ {
54938
+ type: "replace-plain-text",
54939
+ pageId: page.id,
54940
+ shapeId: newId,
54941
+ text: old.text.plainText.trim() ? old.text.plainText : visioOrgText(data)
54942
+ },
54943
+ ...VISIO_ORG_ROWS.filter(({ row: row2 }) => data[row2] !== void 0).map(
54944
+ ({ row: row2, label: label2 }) => ({
54945
+ type: "set-shape-data",
54946
+ pageId: page.id,
54947
+ shapeId: newId,
54948
+ row: row2,
54949
+ data: { label: label2, prompt: "", type: "string", format: "", value: data[row2] ?? "" }
54950
+ })
54951
+ )
54952
+ ];
54953
+ for (const connection of page.connectors) {
54954
+ if (connection.toShapeId !== old.id) continue;
54955
+ const endpoint = /^Begin/i.test(connection.fromCell) ? "begin" : /^End/i.test(connection.fromCell) ? "end" : void 0;
54956
+ if (!endpoint) continue;
54957
+ const point2 = /^Connections\.X(\d+)$/.exec(connection.toCell);
54958
+ rest.push({
54959
+ type: "glue-connector",
54960
+ pageId: page.id,
54961
+ shapeId: connection.fromShapeId,
54962
+ endpoint,
54963
+ target: newId,
54964
+ ...point2 ? { point: Number(point2[1]) - 1 } : {}
54965
+ });
54966
+ }
54967
+ return {
54968
+ drop: drop2({
54969
+ x: (box6.minX + box6.maxX) / 2 / ratio,
54970
+ y: (box6.minY + box6.maxY) / 2 / ratio
54971
+ }),
54972
+ rest,
54973
+ removal: { type: "delete-shape", pageId: page.id, shapeId: old.id }
54974
+ };
54975
+ }
54976
+
54445
54977
  // visio/ui/org-chart-stencil-data.ts
54446
54978
  var ORG_STENCIL_MASTER_IDS = {
54447
54979
  "Executive Belt": "2",
@@ -54749,7 +55281,8 @@ function visioOrgDropPosition(pageId2, shapeId2, master2, at3) {
54749
55281
  y: at3.y
54750
55282
  };
54751
55283
  }
54752
- function visioOrgReportingLine(pageId2, lineId, manager, subordinate, between) {
55284
+ var ORG_POINT = { top: 0, bottom: 3 };
55285
+ function visioOrgReportingLine(pageId2, lineId, manager, subordinate, between, assistant = false) {
54753
55286
  return {
54754
55287
  drop: {
54755
55288
  type: "drop-stencil-master",
@@ -54761,8 +55294,24 @@ function visioOrgReportingLine(pageId2, lineId, manager, subordinate, between) {
54761
55294
  y: between.y
54762
55295
  },
54763
55296
  glue: [
54764
- { type: "glue-connector", pageId: pageId2, shapeId: lineId, endpoint: "begin", target: manager },
54765
- { type: "glue-connector", pageId: pageId2, shapeId: lineId, endpoint: "end", target: subordinate }
55297
+ // Visio's org chart glues the line to the manager's Bottom and the subordinate's Top
55298
+ // connection points, so the line keeps those points when a position moves.
55299
+ {
55300
+ type: "glue-connector",
55301
+ pageId: pageId2,
55302
+ shapeId: lineId,
55303
+ endpoint: "begin",
55304
+ target: manager,
55305
+ ...assistant ? {} : { point: ORG_POINT.bottom }
55306
+ },
55307
+ {
55308
+ type: "glue-connector",
55309
+ pageId: pageId2,
55310
+ shapeId: lineId,
55311
+ endpoint: "end",
55312
+ target: subordinate,
55313
+ ...assistant ? {} : { point: ORG_POINT.top }
55314
+ }
54766
55315
  ]
54767
55316
  };
54768
55317
  }
@@ -54777,10 +55326,11 @@ function visioOrgAddPosition(page, shapeId2, kind) {
54777
55326
  if (!selected2) return void 0;
54778
55327
  const managerId = kind === "peer" ? hierarchy.parentOf(shapeId2) : shapeId2;
54779
55328
  const manager = hierarchy.positions.find((shape) => shape.id === managerId);
54780
- const ids = visioOrgFreeIds(page, 1, 1);
55329
+ const promote = !!manager && kind !== "assistant" && masterOf(manager) === "Position Belt" && !hierarchy.childrenOf(manager.id).length;
55330
+ const ids = visioOrgFreeIds(page, promote ? 2 : 1, 1);
54781
55331
  if (!manager || !ids) return void 0;
54782
55332
  const newId = ids.positions[0];
54783
- const master2 = kind === "assistant" ? "Assistant Belt" : kind === "peer" ? masterOf(selected2) : "Position Belt";
55333
+ const master2 = kind === "assistant" || kind === "peer" && visioIsOrgAssistant(selected2) ? "Assistant Belt" : "Position Belt";
54784
55334
  const assistant = master2 === "Assistant Belt";
54785
55335
  const planned = layoutOrgPage(page, [
54786
55336
  { id: newId, ...VISIO_ORG_SIZE, parent: manager.id, ...assistant ? { assistant } : {} }
@@ -54789,20 +55339,40 @@ function visioOrgAddPosition(page, shapeId2, kind) {
54789
55339
  if (!planned || !centre2) return void 0;
54790
55340
  const data = { Name: "Name", Title: assistant ? "Assistant" : "Position" };
54791
55341
  const managerBox = drawingBox3(page, manager);
54792
- const line2 = visioOrgReportingLine(page.id, ids.lines[0], manager.id, newId, {
54793
- x: (managerBox.minX + managerBox.maxX + centre2.x * 2) / 4,
54794
- y: (managerBox.minY + centre2.y) / 2
54795
- });
55342
+ const promotedId = ids.positions[1];
55343
+ const swap = promote && promotedId ? visioOrgSwapMaster(
55344
+ page,
55345
+ manager,
55346
+ promotedId,
55347
+ (at3) => visioOrgDropPosition(page.id, promotedId, "Manager Belt", at3)
55348
+ ) : void 0;
55349
+ const line2 = visioOrgReportingLine(
55350
+ page.id,
55351
+ ids.lines[0],
55352
+ swap ? promotedId : manager.id,
55353
+ newId,
55354
+ {
55355
+ x: (managerBox.minX + managerBox.maxX + centre2.x * 2) / 4,
55356
+ y: (managerBox.minY + centre2.y) / 2
55357
+ },
55358
+ assistant
55359
+ );
54796
55360
  const pageId2 = page.id;
55361
+ const moves2 = planned.moves.map(
55362
+ (move) => swap && "shapeId" in move && move.shapeId === manager.id ? { ...move, shapeId: promotedId } : move
55363
+ );
54797
55364
  return {
54798
55365
  newId,
54799
55366
  edits: [
55367
+ ...swap ? [swap.drop] : [],
54800
55368
  visioOrgDropPosition(pageId2, newId, master2, centre2),
54801
55369
  line2.drop,
54802
55370
  { type: "replace-plain-text", pageId: pageId2, shapeId: newId, text: visioOrgText(data) },
54803
55371
  ...visioOrgDataEdits(pageId2, newId, data),
54804
- ...planned.moves,
54805
- ...line2.glue
55372
+ ...moves2,
55373
+ ...swap ? swap.rest : [],
55374
+ ...line2.glue,
55375
+ ...swap ? [swap.removal] : []
54806
55376
  ]
54807
55377
  };
54808
55378
  }
@@ -54821,10 +55391,17 @@ function visioOrgDeletePosition(page, shapeId2) {
54821
55391
  const joins = manager ? children3.map((child3, index3) => {
54822
55392
  const a2 = drawingBox3(page, manager);
54823
55393
  const b = drawingBox3(page, child3);
54824
- return visioOrgReportingLine(page.id, ids.lines[index3], manager.id, child3.id, {
54825
- x: (a2.minX + a2.maxX + b.minX + b.maxX) / 4,
54826
- y: (a2.minY + b.maxY) / 2
54827
- });
55394
+ return visioOrgReportingLine(
55395
+ page.id,
55396
+ ids.lines[index3],
55397
+ manager.id,
55398
+ child3.id,
55399
+ {
55400
+ x: (a2.minX + a2.maxX + b.minX + b.maxX) / 4,
55401
+ y: (a2.minY + b.maxY) / 2
55402
+ },
55403
+ visioIsOrgAssistant(child3)
55404
+ );
54828
55405
  }) : [];
54829
55406
  const removal = [...connectors, shapeId2].map((id4) => ({
54830
55407
  type: "delete-shape",
@@ -54953,7 +55530,8 @@ function visioOrgImportEdits(page, people) {
54953
55530
  ids.lines[index3],
54954
55531
  ids.positions[node3.parent],
54955
55532
  ids.positions[node3.index],
54956
- { x: (a2.x + b.x) / 2, y: (a2.y + b.y) / 2 }
55533
+ { x: (a2.x + b.x) / 2, y: (a2.y + b.y) / 2 },
55534
+ !!node3.person.assistant
54957
55535
  );
54958
55536
  });
54959
55537
  const edits = [
@@ -55667,17 +56245,23 @@ var LANE = 1.4;
55667
56245
  var TITLE3 = 0.35;
55668
56246
  var LEFT = 0.6;
55669
56247
  var GUTTER = 1.5;
56248
+ var norm2 = (value3) => value3.toLowerCase().replace(/[^a-z0-9]/g, "");
55670
56249
  var rowName = (name3) => name3.replace(/[^A-Za-z0-9]/g, "") || "Column";
55671
56250
  function visioVisualizerShapes(page) {
55672
56251
  const steps = /* @__PURE__ */ new Map();
55673
56252
  const links2 = [];
56253
+ const linkKeys = /* @__PURE__ */ new Map();
55674
56254
  for (const shape of page.shapes) {
55675
56255
  const row2 = shape.shapeData?.find((item2) => item2.name === VISIO_VISUALIZER_ROW);
55676
56256
  if (!row2) continue;
55677
- if (row2.label === "step") steps.set(String(row2.value ?? row2.rawValue ?? ""), shape.id);
55678
- else links2.push(shape.id);
56257
+ const value3 = String(row2.value ?? row2.rawValue ?? "");
56258
+ if (row2.label === "step") steps.set(value3, shape.id);
56259
+ else {
56260
+ links2.push(shape.id);
56261
+ if (!value3.endsWith(":label")) linkKeys.set(value3, shape.id);
56262
+ }
55679
56263
  }
55680
- return { steps, links: links2 };
56264
+ return { steps, links: links2, linkKeys };
55681
56265
  }
55682
56266
  var hidden2 = (label2, value3, invisible = true) => ({
55683
56267
  label: label2,
@@ -55696,10 +56280,31 @@ function visioDataVisualizerEdits(page, steps, variant) {
55696
56280
  if (shape?.rotation)
55697
56281
  centre2.set(stepId, { x: shape.rotation.pinX / ratio, y: shape.rotation.pinY / ratio });
55698
56282
  }
55699
- const removals = [...old.links, ...old.steps.values()].map((shapeId2) => ({
56283
+ const byId = new Map(page.shapes.map((shape) => [shape.id, shape]));
56284
+ const kept = /* @__PURE__ */ new Map();
56285
+ for (const step4 of steps) {
56286
+ const shapeId2 = old.steps.get(step4.id);
56287
+ const shape = shapeId2 ? byId.get(shapeId2) : void 0;
56288
+ const type = shape?.shapeData?.find((row2) => row2.name === "ShapeType");
56289
+ if (shapeId2 && shape && norm2(String(type?.value ?? "Process")) === norm2(step4.shapeType))
56290
+ kept.set(step4.id, shapeId2);
56291
+ }
56292
+ const wanted = new Set(steps.flatMap((step4) => step4.next.map((link) => `${step4.id}>${link.id}`)));
56293
+ const keptLinks = /* @__PURE__ */ new Map();
56294
+ for (const [key2, shapeId2] of old.linkKeys) {
56295
+ const [from, to] = key2.split(">");
56296
+ if (wanted.has(key2) && kept.has(from) && kept.has(to)) keptLinks.set(key2, shapeId2);
56297
+ }
56298
+ const gone = new Set(keptLinks.values());
56299
+ const goneSteps = new Set(kept.values());
56300
+ const removals = [
56301
+ ...old.links.filter((shapeId2) => !gone.has(shapeId2)),
56302
+ ...[...old.steps.values()].filter((shapeId2) => !goneSteps.has(shapeId2))
56303
+ ].map((shapeId2) => ({
55700
56304
  type: "delete-shape",
55701
56305
  pageId: page.id,
55702
- shapeId: shapeId2
56306
+ shapeId: shapeId2,
56307
+ deferred: true
55703
56308
  }));
55704
56309
  const edits = [];
55705
56310
  const notes = [];
@@ -55763,10 +56368,10 @@ function visioDataVisualizerEdits(page, steps, variant) {
55763
56368
  return { name: lane.text.plainText.trim(), y: (box6.minY + box6.maxY) / 2 / ratio };
55764
56369
  });
55765
56370
  for (const step4 of steps) {
55766
- const wanted = step4.lane || "Unassigned";
55767
- const lane = lanes.find((item2) => item2.name === wanted) ?? lanes[0];
55768
- if (lane.name !== wanted)
55769
- notes.push(`Step ${step4.id}: there is no "${wanted}" lane; placed in "${lane.name}".`);
56371
+ const wanted2 = step4.lane || "Unassigned";
56372
+ const lane = lanes.find((item2) => item2.name === wanted2) ?? lanes[0];
56373
+ if (lane.name !== wanted2)
56374
+ notes.push(`Step ${step4.id}: there is no "${wanted2}" lane; placed in "${lane.name}".`);
55770
56375
  at3.set(step4.id, {
55771
56376
  x: centre2.get(step4.id)?.x ?? left + GUTTER + depth.get(step4.id) * COLUMN - 0.4,
55772
56377
  y: lane.y
@@ -55802,10 +56407,40 @@ function visioDataVisualizerEdits(page, steps, variant) {
55802
56407
  y: bottom + frameHeight - TITLE3 - (names.indexOf(step4.lane || "Unassigned") + 0.5) * LANE
55803
56408
  });
55804
56409
  }
55805
- const shapeIds2 = new Map(steps.map((step4) => [step4.id, id4()]));
56410
+ const shapeIds2 = new Map(steps.map((step4) => [step4.id, kept.get(step4.id) ?? id4()]));
56411
+ const data = (shapeId2, step4) => [
56412
+ ...step4.values.map((value3) => ({
56413
+ type: "set-shape-data",
56414
+ pageId: page.id,
56415
+ shapeId: shapeId2,
56416
+ row: rowName(value3.name),
56417
+ data: hidden2(value3.label, value3.value, false)
56418
+ })),
56419
+ {
56420
+ type: "set-shape-data",
56421
+ pageId: page.id,
56422
+ shapeId: shapeId2,
56423
+ row: VISIO_VISUALIZER_ROW,
56424
+ data: hidden2("step", step4.id)
56425
+ }
56426
+ ];
55806
56427
  for (const step4 of steps) {
55807
56428
  const shapeId2 = shapeIds2.get(step4.id);
55808
56429
  const place2 = at3.get(step4.id);
56430
+ if (kept.has(step4.id)) {
56431
+ const before = centre2.get(step4.id);
56432
+ if (!before || Math.hypot(before.x - place2.x, before.y - place2.y) > 0.01)
56433
+ edits.push({ type: "move-shape", pageId: page.id, shapeId: shapeId2, x: place2.x, y: place2.y });
56434
+ if (byId.get(shapeId2)?.text.plainText !== step4.description)
56435
+ edits.push({
56436
+ type: "replace-plain-text",
56437
+ pageId: page.id,
56438
+ shapeId: shapeId2,
56439
+ text: step4.description
56440
+ });
56441
+ edits.push(...data(shapeId2, step4));
56442
+ continue;
56443
+ }
55809
56444
  edits.push(
55810
56445
  {
55811
56446
  type: "drop-stencil-master",
@@ -55824,24 +56459,23 @@ function visioDataVisualizerEdits(page, steps, variant) {
55824
56459
  fillColor: FILLS3[step4.master] ?? "#D8EFEB",
55825
56460
  lineColor: LINE2
55826
56461
  },
55827
- ...step4.values.map((value3) => ({
55828
- type: "set-shape-data",
55829
- pageId: page.id,
55830
- shapeId: shapeId2,
55831
- row: rowName(value3.name),
55832
- data: hidden2(value3.label, value3.value, false)
55833
- })),
55834
- {
55835
- type: "set-shape-data",
55836
- pageId: page.id,
55837
- shapeId: shapeId2,
55838
- row: VISIO_VISUALIZER_ROW,
55839
- data: hidden2("step", step4.id)
55840
- }
56462
+ ...data(shapeId2, step4)
55841
56463
  );
55842
56464
  }
55843
56465
  for (const step4 of steps)
55844
56466
  for (const link of step4.next) {
56467
+ const key2 = `${step4.id}>${link.id}`;
56468
+ const existing = keptLinks.get(key2);
56469
+ if (existing) {
56470
+ if (byId.get(existing)?.text.plainText !== link.label)
56471
+ edits.push({
56472
+ type: "replace-plain-text",
56473
+ pageId: page.id,
56474
+ shapeId: existing,
56475
+ text: link.label
56476
+ });
56477
+ continue;
56478
+ }
55845
56479
  const from = at3.get(step4.id);
55846
56480
  const to = at3.get(link.id);
55847
56481
  const shapeId2 = id4();
@@ -55854,7 +56488,8 @@ function visioDataVisualizerEdits(page, steps, variant) {
55854
56488
  beginY: from.y,
55855
56489
  endX: to.x,
55856
56490
  endY: to.y,
55857
- connect: { begin: shapeIds2.get(step4.id), end: shapeIds2.get(link.id) }
56491
+ connect: { begin: shapeIds2.get(step4.id), end: shapeIds2.get(link.id) },
56492
+ text: link.label
55858
56493
  },
55859
56494
  { type: "format-shape", pageId: page.id, shapeId: shapeId2, lineColor: LINE2 },
55860
56495
  {
@@ -55862,35 +56497,16 @@ function visioDataVisualizerEdits(page, steps, variant) {
55862
56497
  pageId: page.id,
55863
56498
  shapeId: shapeId2,
55864
56499
  row: VISIO_VISUALIZER_ROW,
55865
- data: hidden2("link", `${step4.id}>${link.id}`)
56500
+ data: hidden2("link", key2)
55866
56501
  }
55867
56502
  );
55868
- if (link.label) {
55869
- const labelId = id4();
55870
- edits.push(
55871
- {
55872
- type: "create-text-box",
55873
- pageId: page.id,
55874
- shapeId: labelId,
55875
- x: (from.x + to.x) / 2 + 0.05,
55876
- y: (from.y + to.y) / 2,
55877
- width: 0.7,
55878
- height: 0.25,
55879
- text: link.label
55880
- },
55881
- {
55882
- type: "set-shape-data",
55883
- pageId: page.id,
55884
- shapeId: labelId,
55885
- row: VISIO_VISUALIZER_ROW,
55886
- data: hidden2("link", `${step4.id}>${link.id}:label`)
55887
- }
55888
- );
55889
- }
55890
56503
  }
55891
56504
  if (variant === "cross-functional")
55892
56505
  edits.push({ type: "reconcile-containers", pageId: page.id, shapeIds: [...shapeIds2.values()] });
55893
- return { batches: [pageEdits, removals, edits].filter((batch) => batch.length), notes };
56506
+ return {
56507
+ batches: [[...pageEdits, ...edits, ...removals]].filter((batch) => batch.length),
56508
+ notes
56509
+ };
55894
56510
  }
55895
56511
 
55896
56512
  // visio/ui/select-by-type.ts
@@ -55920,8 +56536,8 @@ function visioPageMasters(page) {
55920
56536
  const masters = /* @__PURE__ */ new Map();
55921
56537
  for (const shape of page.shapes) {
55922
56538
  if (shape.masterId === void 0) continue;
55923
- const entry3 = masters.get(shape.masterId);
55924
- if (entry3) ++entry3.count;
56539
+ const entry4 = masters.get(shape.masterId);
56540
+ if (entry4) ++entry4.count;
55925
56541
  else masters.set(shape.masterId, { id: shape.masterId, example: shape.name, count: 1 });
55926
56542
  }
55927
56543
  return [...masters.values()];
@@ -56737,6 +57353,7 @@ exports.EMPTY_TEXT_SEARCH = EMPTY_TEXT_SEARCH;
56737
57353
  exports.FOREIGN_VECTOR_SCENE_LIMITS = FOREIGN_VECTOR_SCENE_LIMITS;
56738
57354
  exports.ForeignVectorBudget = ForeignVectorBudget;
56739
57355
  exports.MAX_INPUT_BYTES = MAX_INPUT_BYTES;
57356
+ exports.ORG_POINT = ORG_POINT;
56740
57357
  exports.TEXT_SEARCH_LIMITS = TEXT_SEARCH_LIMITS;
56741
57358
  exports.VISIO_AUTO_CONNECT_DIRECTIONS = VISIO_AUTO_CONNECT_DIRECTIONS;
56742
57359
  exports.VISIO_AUTO_CONNECT_GAP = VISIO_AUTO_CONNECT_GAP;