ooxml-core 1.17.0 → 1.19.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 (137) hide show
  1. package/dist/{PptxHandler-K7GMS2ST.mjs → PptxHandler-5GBBVJCR.mjs} +2 -2
  2. package/dist/{PptxHandler-L3JPWOBN.mjs → PptxHandler-H43MAMTO.mjs} +1 -1
  3. package/dist/{PptxHandler-U6EFO73T.cjs → PptxHandler-ZHPGBSAF.cjs} +2 -2
  4. package/dist/{PresentationBuilder-XC3F3OPY.mjs → PresentationBuilder-7ZSUKCX5.mjs} +1 -1
  5. package/dist/{PresentationBuilder-OK526SZ4.mjs → PresentationBuilder-IJW42L3R.mjs} +2 -2
  6. package/dist/{PresentationBuilder-LUR6LGHU.cjs → PresentationBuilder-O4H4MMWB.cjs} +4 -4
  7. package/dist/automation/index.cjs +5198 -3235
  8. package/dist/automation/index.mjs +5198 -3235
  9. package/dist/chart/axis-range-auto.d.ts +10 -0
  10. package/dist/chart/axis-range-auto.d.ts.map +1 -0
  11. package/dist/chart/axis-range-types.d.ts +27 -0
  12. package/dist/chart/axis-range-types.d.ts.map +1 -0
  13. package/dist/chart/axis-range.d.ts +37 -0
  14. package/dist/chart/axis-range.d.ts.map +1 -0
  15. package/dist/chart/axis-ticks.d.ts +8 -0
  16. package/dist/chart/axis-ticks.d.ts.map +1 -0
  17. package/dist/chart/data-label-text.d.ts +70 -0
  18. package/dist/chart/data-label-text.d.ts.map +1 -0
  19. package/dist/chart/formatting-nodes.d.ts +6 -0
  20. package/dist/chart/formatting-nodes.d.ts.map +1 -1
  21. package/dist/chart/index.cjs +1536 -571
  22. package/dist/chart/index.d.ts +7 -0
  23. package/dist/chart/index.d.ts.map +1 -1
  24. package/dist/chart/index.mjs +1512 -572
  25. package/dist/chart/line-dash.d.ts +2 -0
  26. package/dist/chart/line-dash.d.ts.map +1 -0
  27. package/dist/chart/marker-shape.d.ts +70 -0
  28. package/dist/chart/marker-shape.d.ts.map +1 -0
  29. package/dist/chart/read-formatting.d.ts.map +1 -1
  30. package/dist/chart/render/chart-svg-axes.d.ts +9 -0
  31. package/dist/chart/render/chart-svg-axes.d.ts.map +1 -0
  32. package/dist/chart/render/chart-svg-bars.d.ts.map +1 -1
  33. package/dist/chart/render/chart-svg-cartesian.d.ts.map +1 -1
  34. package/dist/chart/render/chart-svg-labels.d.ts +42 -0
  35. package/dist/chart/render/chart-svg-labels.d.ts.map +1 -0
  36. package/dist/chart/render/chart-svg-markers.d.ts +6 -0
  37. package/dist/chart/render/chart-svg-markers.d.ts.map +1 -0
  38. package/dist/chart/render/chart-svg-radial.d.ts.map +1 -1
  39. package/dist/chart/render/chart-svg-xy.d.ts.map +1 -1
  40. package/dist/chart/render/chart-view-axes.d.ts +30 -0
  41. package/dist/chart/render/chart-view-axes.d.ts.map +1 -0
  42. package/dist/chart/render/chart-view-labels.d.ts +16 -0
  43. package/dist/chart/render/chart-view-labels.d.ts.map +1 -0
  44. package/dist/chart/render/chart-view-markers.d.ts +27 -0
  45. package/dist/chart/render/chart-view-markers.d.ts.map +1 -0
  46. package/dist/chart/render/chart-view-series.d.ts.map +1 -1
  47. package/dist/chart/render/chart-view.d.ts +7 -1
  48. package/dist/chart/render/chart-view.d.ts.map +1 -1
  49. package/dist/chart/render/index.d.ts +2 -0
  50. package/dist/chart/render/index.d.ts.map +1 -1
  51. package/dist/chart/render/summary-from-space.d.ts +2 -2
  52. package/dist/chart/render/summary-from-space.d.ts.map +1 -1
  53. package/dist/chart/render/summary-labels.d.ts +9 -0
  54. package/dist/chart/render/summary-labels.d.ts.map +1 -0
  55. package/dist/chart/render/summary.d.ts +29 -1
  56. package/dist/chart/render/summary.d.ts.map +1 -1
  57. package/dist/{chunk-IM5LFEA2.mjs → chunk-3XFPCZKB.mjs} +1 -1
  58. package/dist/{chunk-YS43OMM3.mjs → chunk-75GLSRZE.mjs} +4 -4
  59. package/dist/{chunk-A7S2NYAU.mjs → chunk-BIVNVDAH.mjs} +1 -1
  60. package/dist/{chunk-UFGJNXRG.mjs → chunk-QBJRB6WW.mjs} +1 -1
  61. package/dist/{chunk-HLZIALC5.mjs → chunk-RUZEMWDI.mjs} +1 -1
  62. package/dist/docx/embedded.cjs +15 -0
  63. package/dist/docx/embedded.mjs +15 -0
  64. package/dist/docx/index.cjs +1825 -693
  65. package/dist/docx/index.mjs +1825 -693
  66. package/dist/docx/layout/index.cjs +1684 -567
  67. package/dist/docx/layout/index.mjs +1684 -567
  68. package/dist/docx/load/index.cjs +15 -0
  69. package/dist/docx/load/index.mjs +15 -0
  70. package/dist/docx/ui/index.cjs +1696 -579
  71. package/dist/docx/ui/index.mjs +1696 -579
  72. package/dist/index.cjs +1623 -658
  73. package/dist/index.mjs +1623 -658
  74. package/dist/pptx/automation/index.cjs +61 -0
  75. package/dist/pptx/automation/index.mjs +5 -5
  76. package/dist/pptx/cli/index.cjs +61 -0
  77. package/dist/pptx/cli/index.mjs +4 -4
  78. package/dist/pptx/converter/index.mjs +2 -2
  79. package/dist/pptx/editor/render/slide-operations.cjs +1 -1
  80. package/dist/pptx/editor/render/slide-operations.mjs +1 -1
  81. package/dist/pptx/index.cjs +61 -0
  82. package/dist/pptx/index.mjs +5 -5
  83. package/dist/teams/index.cjs +212 -50
  84. package/dist/teams/index.mjs +212 -50
  85. package/dist/visio/edit-chart-object-commands.d.ts +36 -0
  86. package/dist/visio/edit-chart-object-commands.d.ts.map +1 -0
  87. package/dist/visio/edit-chart-object.d.ts +7 -0
  88. package/dist/visio/edit-chart-object.d.ts.map +1 -0
  89. package/dist/visio/edit-commands.d.ts +2 -1
  90. package/dist/visio/edit-commands.d.ts.map +1 -1
  91. package/dist/visio/edit-foreign-frame.d.ts +8 -0
  92. package/dist/visio/edit-foreign-frame.d.ts.map +1 -0
  93. package/dist/visio/edit-metadata-commands.d.ts +7 -0
  94. package/dist/visio/edit-metadata-commands.d.ts.map +1 -1
  95. package/dist/visio/edit-picture.d.ts +8 -0
  96. package/dist/visio/edit-picture.d.ts.map +1 -1
  97. package/dist/visio/edit.d.ts.map +1 -1
  98. package/dist/visio/emf-bitmap.d.ts +8 -0
  99. package/dist/visio/emf-bitmap.d.ts.map +1 -0
  100. package/dist/visio/index.cjs +17505 -6279
  101. package/dist/visio/index.d.ts +2 -0
  102. package/dist/visio/index.d.ts.map +1 -1
  103. package/dist/visio/index.mjs +17503 -6280
  104. package/dist/visio/model.d.ts +18 -0
  105. package/dist/visio/model.d.ts.map +1 -1
  106. package/dist/visio/prepare-embedded.d.ts +10 -0
  107. package/dist/visio/prepare-embedded.d.ts.map +1 -0
  108. package/dist/visio/prepare-images.d.ts.map +1 -1
  109. package/dist/visio/shapes.d.ts.map +1 -1
  110. package/dist/visio/sheet.d.ts +2 -1
  111. package/dist/visio/sheet.d.ts.map +1 -1
  112. package/dist/visio/ui/edit-commands.d.ts.map +1 -1
  113. package/dist/visio/ui/index.cjs +33580 -22875
  114. package/dist/visio/ui/index.mjs +33578 -22875
  115. package/dist/visio/ui/insert.d.ts +11 -0
  116. package/dist/visio/ui/insert.d.ts.map +1 -1
  117. package/dist/xlsx/edit/chart-colors.d.ts.map +1 -1
  118. package/dist/xlsx/index.cjs +1965 -817
  119. package/dist/xlsx/index.mjs +1965 -817
  120. package/dist/xlsx/load/index.cjs +190 -51
  121. package/dist/xlsx/load/index.mjs +190 -51
  122. package/dist/xlsx/model.d.ts +5 -0
  123. package/dist/xlsx/model.d.ts.map +1 -1
  124. package/dist/xlsx/read/chart.d.ts.map +1 -1
  125. package/dist/xlsx/read/load.d.ts.map +1 -1
  126. package/dist/xlsx/read/workbook-part.d.ts +2 -0
  127. package/dist/xlsx/read/workbook-part.d.ts.map +1 -1
  128. package/dist/xlsx/ui/dialogs/grid-chart.d.ts +22 -1
  129. package/dist/xlsx/ui/dialogs/grid-chart.d.ts.map +1 -1
  130. package/dist/xlsx/ui/index.cjs +17482 -4364
  131. package/dist/xlsx/ui/index.mjs +17472 -4362
  132. package/dist/xlsx/write/workbook-part.d.ts.map +1 -1
  133. package/package.json +1 -1
  134. package/dist/visio/edit-foreign-bitmap.d.ts +0 -7
  135. package/dist/visio/edit-foreign-bitmap.d.ts.map +0 -1
  136. /package/dist/{chunk-KU3SMBFU.mjs → chunk-H6TNNXJK.mjs} +0 -0
  137. /package/dist/{chunk-UWWS6VVJ.cjs → chunk-MHMVD23Y.cjs} +0 -0
@@ -73,17 +73,17 @@ function checkXmlLimits(xml, label, limits = {}) {
73
73
  throw new Error(`${label} XML exceeds the nesting depth limit of ${maxDepth}`);
74
74
  }
75
75
  }
76
- function parseXml(xml, options = {}) {
77
- const label = options.label ?? "OOXML";
76
+ function parseXml(xml, options2 = {}) {
77
+ const label = options2.label ?? "OOXML";
78
78
  if (/<!DOCTYPE|<!ENTITY/i.test(xml))
79
79
  throw new Error(`${label} XML with DTD or entity declarations is not supported`);
80
- checkXmlLimits(xml, label, options.limits);
80
+ checkXmlLimits(xml, label, options2.limits);
81
81
  let parseError = "";
82
82
  let parsed;
83
83
  try {
84
84
  parsed = new xmldom.DOMParser({
85
- onError: (level, message) => {
86
- if (level !== "warning") parseError = message;
85
+ onError: (level2, message) => {
86
+ if (level2 !== "warning") parseError = message;
87
87
  }
88
88
  }).parseFromString(xml, "application/xml");
89
89
  } catch (error) {
@@ -1291,8 +1291,8 @@ function parseTableStyleCatalog(xml) {
1291
1291
 
1292
1292
  // docx/default-styles.ts
1293
1293
  var W = "http://schemas.openxmlformats.org/wordprocessingml/2006/main";
1294
- var heading = (id, name, level, before, size, color) => `<w:style w:type="paragraph" w:styleId="${id}"><w:name w:val="${name}"/><w:basedOn w:val="Normal"/><w:next w:val="Normal"/><w:uiPriority w:val="9"/><w:qFormat/><w:pPr><w:keepNext/><w:keepLines/><w:spacing w:before="${before}" w:after="0"/><w:outlineLvl w:val="${level}"/></w:pPr><w:rPr><w:rFonts w:ascii="Calibri Light" w:hAnsi="Calibri Light" w:eastAsia="Calibri Light" w:cs="Times New Roman"/><w:color w:val="${color}"/><w:sz w:val="${size}"/><w:szCs w:val="${size}"/></w:rPr></w:style>`;
1295
- var toc = (level) => `<w:style w:type="paragraph" w:styleId="TOC${level}"><w:name w:val="toc ${level}"/><w:basedOn w:val="Normal"/><w:next w:val="Normal"/><w:uiPriority w:val="39"/><w:unhideWhenUsed/><w:pPr><w:spacing w:after="100"/>${level > 1 ? `<w:ind w:left="${(level - 1) * 220}"/>` : ""}</w:pPr></w:style>`;
1294
+ var heading = (id, name, level2, before, size, color) => `<w:style w:type="paragraph" w:styleId="${id}"><w:name w:val="${name}"/><w:basedOn w:val="Normal"/><w:next w:val="Normal"/><w:uiPriority w:val="9"/><w:qFormat/><w:pPr><w:keepNext/><w:keepLines/><w:spacing w:before="${before}" w:after="0"/><w:outlineLvl w:val="${level2}"/></w:pPr><w:rPr><w:rFonts w:ascii="Calibri Light" w:hAnsi="Calibri Light" w:eastAsia="Calibri Light" w:cs="Times New Roman"/><w:color w:val="${color}"/><w:sz w:val="${size}"/><w:szCs w:val="${size}"/></w:rPr></w:style>`;
1295
+ var toc = (level2) => `<w:style w:type="paragraph" w:styleId="TOC${level2}"><w:name w:val="toc ${level2}"/><w:basedOn w:val="Normal"/><w:next w:val="Normal"/><w:uiPriority w:val="39"/><w:unhideWhenUsed/><w:pPr><w:spacing w:after="100"/>${level2 > 1 ? `<w:ind w:left="${(level2 - 1) * 220}"/>` : ""}</w:pPr></w:style>`;
1296
1296
  var noteStyles = (id, name) => `<w:style w:type="paragraph" w:styleId="${id}Text"><w:name w:val="${name} text"/><w:basedOn w:val="Normal"/><w:link w:val="${id}TextChar"/><w:uiPriority w:val="99"/><w:semiHidden/><w:unhideWhenUsed/><w:pPr><w:spacing w:after="0" w:line="240" w:lineRule="auto"/></w:pPr><w:rPr><w:sz w:val="20"/><w:szCs w:val="20"/></w:rPr></w:style><w:style w:type="character" w:styleId="${id}TextChar"><w:name w:val="${name} Text Char"/><w:basedOn w:val="DefaultParagraphFont"/><w:link w:val="${id}Text"/><w:uiPriority w:val="99"/><w:semiHidden/><w:rPr><w:sz w:val="20"/><w:szCs w:val="20"/></w:rPr></w:style><w:style w:type="character" w:styleId="${id}Reference"><w:name w:val="${name} reference"/><w:basedOn w:val="DefaultParagraphFont"/><w:uiPriority w:val="99"/><w:semiHidden/><w:unhideWhenUsed/><w:rPr><w:vertAlign w:val="superscript"/></w:rPr></w:style>`;
1297
1297
  var DEFAULT_STYLES_XML = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><w:styles xmlns:w="${W}"><w:docDefaults><w:rPrDefault><w:rPr><w:rFonts w:ascii="Calibri" w:eastAsia="Calibri" w:hAnsi="Calibri" w:cs="Times New Roman"/><w:sz w:val="22"/><w:szCs w:val="22"/><w:lang w:val="en-US" w:eastAsia="en-US" w:bidi="ar-SA"/></w:rPr></w:rPrDefault><w:pPrDefault><w:pPr><w:spacing w:after="160" w:line="259" w:lineRule="auto"/></w:pPr></w:pPrDefault></w:docDefaults><w:style w:type="paragraph" w:default="1" w:styleId="Normal"><w:name w:val="Normal"/><w:qFormat/></w:style><w:style w:type="character" w:default="1" w:styleId="DefaultParagraphFont"><w:name w:val="Default Paragraph Font"/><w:uiPriority w:val="1"/><w:semiHidden/><w:unhideWhenUsed/></w:style><w:style w:type="table" w:default="1" w:styleId="TableNormal"><w:name w:val="Normal Table"/><w:uiPriority w:val="99"/><w:semiHidden/><w:unhideWhenUsed/><w:tblPr><w:tblInd w:w="0" w:type="dxa"/><w:tblCellMar><w:top w:w="0" w:type="dxa"/><w:left w:w="108" w:type="dxa"/><w:bottom w:w="0" w:type="dxa"/><w:right w:w="108" w:type="dxa"/></w:tblCellMar></w:tblPr></w:style><w:style w:type="numbering" w:default="1" w:styleId="NoList"><w:name w:val="No List"/><w:uiPriority w:val="99"/><w:semiHidden/><w:unhideWhenUsed/></w:style><w:style w:type="paragraph" w:styleId="Title"><w:name w:val="Title"/><w:basedOn w:val="Normal"/><w:next w:val="Normal"/><w:uiPriority w:val="10"/><w:qFormat/><w:pPr><w:spacing w:after="0" w:line="240" w:lineRule="auto"/><w:contextualSpacing/></w:pPr><w:rPr><w:rFonts w:ascii="Calibri Light" w:hAnsi="Calibri Light" w:eastAsia="Calibri Light" w:cs="Times New Roman"/><w:spacing w:val="-10"/><w:kern w:val="28"/><w:sz w:val="56"/><w:szCs w:val="56"/></w:rPr></w:style>` + heading("Heading1", "heading 1", 0, 240, 32, "2F5496") + heading("Heading2", "heading 2", 1, 40, 26, "2F5496") + heading("Heading3", "heading 3", 2, 40, 24, "1F3763") + toc(1) + toc(2) + toc(3) + noteStyles("Footnote", "footnote") + noteStyles("Endnote", "endnote") + '<w:style w:type="character" w:styleId="Hyperlink"><w:name w:val="Hyperlink"/><w:basedOn w:val="DefaultParagraphFont"/><w:uiPriority w:val="99"/><w:unhideWhenUsed/><w:rPr><w:color w:val="0563C1"/><w:u w:val="single"/></w:rPr></w:style><w:style w:type="character" w:styleId="PlaceholderText"><w:name w:val="Placeholder Text"/><w:basedOn w:val="DefaultParagraphFont"/><w:uiPriority w:val="99"/><w:semiHidden/><w:rPr><w:color w:val="808080"/></w:rPr></w:style></w:styles>';
1298
1298
  var cached;
@@ -1501,8 +1501,8 @@ function resolveRunFormatting(run, context = {}) {
1501
1501
  if (state) result[key] = true;
1502
1502
  }
1503
1503
  for (const key of OVERRIDE_KEYS) {
1504
- for (const level of levels) {
1505
- const value = level[key];
1504
+ for (const level2 of levels) {
1505
+ const value = level2[key];
1506
1506
  if (value !== void 0) result[key] = value;
1507
1507
  }
1508
1508
  }
@@ -1575,8 +1575,8 @@ function rgbToHsl(r, g, b) {
1575
1575
  }
1576
1576
  return { h, s: clampUnitInterval(s), l: clampUnitInterval(l) };
1577
1577
  }
1578
- function hslToRgb(h, s, l, roundChannel = Math.round, options) {
1579
- const sC = options?.clampSaturation === false ? s : clampUnitInterval(s);
1578
+ function hslToRgb(h, s, l, roundChannel = Math.round, options2) {
1579
+ const sC = options2?.clampSaturation === false ? s : clampUnitInterval(s);
1580
1580
  const lC = clampUnitInterval(l);
1581
1581
  const hN = (h % 360 + 360) % 360;
1582
1582
  const c2 = (1 - Math.abs(2 * lC - 1)) * sC;
@@ -2113,13 +2113,13 @@ var APPLIED = /* @__PURE__ */ new Set([
2113
2113
  "lumMod",
2114
2114
  "lumOff"
2115
2115
  ]);
2116
- function resolveDrawingColor(color, theme, options) {
2116
+ function resolveDrawingColor(color, theme, options2) {
2117
2117
  const base = baseHex(color, theme);
2118
2118
  const rgb = base ? hexToRgbChannels(base) : null;
2119
2119
  if (!rgb) return void 0;
2120
- if (options?.transformOrder === "document") {
2120
+ if (options2?.transformOrder === "document") {
2121
2121
  const value = orderedColorTransforms(rgb, color.transforms);
2122
- const round2 = options.hslRounding === "halfDown" ? (channel) => Math.ceil(channel - 0.5) : Math.round;
2122
+ const round2 = options2.hslRounding === "halfDown" ? (channel) => Math.ceil(channel - 0.5) : Math.round;
2123
2123
  return {
2124
2124
  hex: `#${toHex(round2(value.r))}${toHex(round2(value.g))}${toHex(round2(value.b))}`,
2125
2125
  alpha: value.alpha,
@@ -2170,7 +2170,7 @@ function resolveDrawingColor(color, theme, options) {
2170
2170
  if (lumMod !== void 0) hsl.l = clampUnitInterval(hsl.l * lumMod);
2171
2171
  const lumOff = parseDrawingFraction(find("lumOff"));
2172
2172
  if (lumOff !== void 0) hsl.l = clampUnitInterval(hsl.l + lumOff);
2173
- const round2 = options?.hslRounding === "halfDown" ? (value) => Math.ceil(value - 0.5) : Math.round;
2173
+ const round2 = options2?.hslRounding === "halfDown" ? (value) => Math.ceil(value - 0.5) : Math.round;
2174
2174
  ({ r, g, b } = hslToRgb(hsl.h, hsl.s, hsl.l, round2));
2175
2175
  }
2176
2176
  let alpha = parseDrawingPercent(find("alpha")) ?? 1;
@@ -2838,13 +2838,13 @@ function parseKind(sdtPr) {
2838
2838
  return "richText";
2839
2839
  }
2840
2840
  var generated = 0;
2841
- function parseContentControl(sdt, level) {
2841
+ function parseContentControl(sdt, level2) {
2842
2842
  const sdtPr = first2(sdt, "sdtPr");
2843
- if (!sdtPr) return { id: `sdt-gen-${++generated}`, level, kind: "richText" };
2843
+ if (!sdtPr) return { id: `sdt-gen-${++generated}`, level: level2, kind: "richText" };
2844
2844
  const kind = parseKind(sdtPr);
2845
2845
  const control = {
2846
2846
  id: getW(first2(sdtPr, "id"), "val") ?? `sdt-gen-${++generated}`,
2847
- level,
2847
+ level: level2,
2848
2848
  kind
2849
2849
  };
2850
2850
  const alias = getW(first2(sdtPr, "alias"), "val");
@@ -3026,7 +3026,7 @@ function parseInlineControl(sdt, parseRun3, parseOther, resolveLink, comments, m
3026
3026
  for (const run of runs) run.contentControl ??= control;
3027
3027
  return runs;
3028
3028
  }
3029
- function flatChildren(parent, names, level = "block", enclosing, controls = /* @__PURE__ */ new Map()) {
3029
+ function flatChildren(parent, names, level2 = "block", enclosing, controls = /* @__PURE__ */ new Map()) {
3030
3030
  const found = [];
3031
3031
  for (const child4 of Array.from(parent.childNodes).filter(isElement)) {
3032
3032
  if (isSdt(child4)) {
@@ -3034,10 +3034,10 @@ function flatChildren(parent, names, level = "block", enclosing, controls = /* @
3034
3034
  if (!content) continue;
3035
3035
  let control = controls.get(child4);
3036
3036
  if (!control) {
3037
- control = parseContentControl(child4, level);
3037
+ control = parseContentControl(child4, level2);
3038
3038
  controls.set(child4, control);
3039
3039
  }
3040
- found.push(...flatChildren(content, names, level, { control, sdt: child4 }, controls));
3040
+ found.push(...flatChildren(content, names, level2, { control, sdt: child4 }, controls));
3041
3041
  } else if (names.some((name) => named2(child4, name)))
3042
3042
  found.push({
3043
3043
  element: child4,
@@ -4528,8 +4528,8 @@ function writeNewReferences(doc, sectPr, section, previous, references) {
4528
4528
  }
4529
4529
  }
4530
4530
  var paragraphSection = (node) => node?.localName === "p" ? first2(first2(node, "pPr"), "sectPr") : void 0;
4531
- function applySectionEdits(doc, body, blocks, sections, base, references = /* @__PURE__ */ new Map()) {
4532
- if (!sections.length) {
4531
+ function applySectionEdits(doc, body, blocks, sections2, base, references = /* @__PURE__ */ new Map()) {
4532
+ if (!sections2.length) {
4533
4533
  if (base.length)
4534
4534
  throw new Error("A document needs at least one section; the section list cannot be emptied.");
4535
4535
  return;
@@ -4538,7 +4538,7 @@ function applySectionEdits(doc, body, blocks, sections, base, references = /* @_
4538
4538
  (node) => node.nodeType === 1 && ["p", "tbl"].includes(node.localName)
4539
4539
  );
4540
4540
  const nodeFor = (id) => topLevel2[blocks.findIndex((block) => block.id === id)];
4541
- const ends = new Set(sections.slice(0, -1).map((section) => section.endsAtBlockId));
4541
+ const ends = new Set(sections2.slice(0, -1).map((section) => section.endsAtBlockId));
4542
4542
  blocks.forEach((block, index) => {
4543
4543
  const sectPr = paragraphSection(topLevel2[index]);
4544
4544
  if (sectPr && !ends.has(block.id)) sectPr.parentNode?.removeChild(sectPr);
@@ -4550,10 +4550,10 @@ function applySectionEdits(doc, body, blocks, sections, base, references = /* @_
4550
4550
  }
4551
4551
  const baseByEnd = new Map(base.map((section) => [section.endsAtBlockId, section]));
4552
4552
  let following = bodySection;
4553
- for (let index = sections.length - 1; index >= 0; index--) {
4554
- const section = sections[index];
4553
+ for (let index = sections2.length - 1; index >= 0; index--) {
4554
+ const section = sections2[index];
4555
4555
  if (!section) continue;
4556
- const last = index === sections.length - 1;
4556
+ const last = index === sections2.length - 1;
4557
4557
  let sectPr = last ? bodySection : paragraphSection(nodeFor(section.endsAtBlockId));
4558
4558
  const previous = last ? base.at(-1) : baseByEnd.get(section.endsAtBlockId);
4559
4559
  if (!sectPr) {
@@ -5893,7 +5893,7 @@ function resolveInnerRect(fillToRect, focalPoint) {
5893
5893
  function lerpEdge(inner, outer, t) {
5894
5894
  return inner + (outer - inner) * t;
5895
5895
  }
5896
- function buildRectPathGradientSvg(stops, focalPoint, fillToRect, options) {
5896
+ function buildRectPathGradientSvg(stops, focalPoint, fillToRect, options2) {
5897
5897
  if (stops.length === 0) {
5898
5898
  return '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"/>';
5899
5899
  }
@@ -5902,7 +5902,7 @@ function buildRectPathGradientSvg(stops, focalPoint, fillToRect, options) {
5902
5902
  const rects = [];
5903
5903
  const alphaRects = [];
5904
5904
  const masked = sorted.some((stop) => (stop.opacity ?? 1) < 1);
5905
- const bands = options?.bands;
5905
+ const bands = options2?.bands;
5906
5906
  if (!Number.isInteger(bands) || bands < 1) throw new RangeError("Invalid gradient band count");
5907
5907
  for (let i = bands; i >= 0; i -= 1) {
5908
5908
  const t = i / bands;
@@ -15771,16 +15771,16 @@ function parseDiagramLayoutSummary(source) {
15771
15771
 
15772
15772
  // diagram/drawing.ts
15773
15773
  var IDENTITY = { offsetX: 0, offsetY: 0, scaleX: 1, scaleY: 1 };
15774
- function applyGroup(frame2, group) {
15774
+ function applyGroup(frame2, group2) {
15775
15775
  return {
15776
- x: Math.round(group.offsetX + frame2.x * group.scaleX),
15777
- y: Math.round(group.offsetY + frame2.y * group.scaleY),
15778
- width: Math.round(frame2.width * group.scaleX),
15779
- height: Math.round(frame2.height * group.scaleY)
15776
+ x: Math.round(group2.offsetX + frame2.x * group2.scaleX),
15777
+ y: Math.round(group2.offsetY + frame2.y * group2.scaleY),
15778
+ width: Math.round(frame2.width * group2.scaleX),
15779
+ height: Math.round(frame2.height * group2.scaleY)
15780
15780
  };
15781
15781
  }
15782
- function groupTransform(group, parent) {
15783
- const xfrm = first(first(group, "grpSpPr", NS.dsp), "xfrm", NS.a);
15782
+ function groupTransform(group2, parent) {
15783
+ const xfrm = first(first(group2, "grpSpPr", NS.dsp), "xfrm", NS.a);
15784
15784
  const off = first(xfrm, "off", NS.a);
15785
15785
  const ext = first(xfrm, "ext", NS.a);
15786
15786
  const chOff = first(xfrm, "chOff", NS.a);
@@ -15807,14 +15807,14 @@ function groupTransform(group, parent) {
15807
15807
  scaleY: parent.scaleY * local.scaleY
15808
15808
  };
15809
15809
  }
15810
- function parseShape2(sp, index, group, issues) {
15810
+ function parseShape2(sp, index, group2, issues) {
15811
15811
  const spPr = first(sp, "spPr", NS.dsp);
15812
15812
  const transform2 = parseTransform(first(spPr, "xfrm", NS.a));
15813
15813
  if (!transform2) return void 0;
15814
15814
  const modelId = stringAttribute(sp, "modelId") ?? stringAttribute(first(first(sp, "nvSpPr", NS.dsp), "cNvPr", NS.dsp), "id") ?? `dsp-${index}`;
15815
15815
  const { geometry: geometry2, adjustments, paths, issue } = parseDrawingGeometry(spPr);
15816
15816
  if (issue) issues.push({ code: issue, message: `Shape ${modelId}: ${issue}.` });
15817
- const frame2 = applyGroup(transform2.frame, group);
15817
+ const frame2 = applyGroup(transform2.frame, group2);
15818
15818
  if ((frame2.width <= 0 || frame2.height <= 0) && geometry2 !== "line") return void 0;
15819
15819
  const shape2 = {
15820
15820
  modelId,
@@ -15836,7 +15836,7 @@ function parseShape2(sp, index, group, issues) {
15836
15836
  const text3 = parseDrawingTextBody(first(sp, "txBody", NS.dsp));
15837
15837
  if (text3) shape2.text = text3;
15838
15838
  const textFrame = parseFrame(first(sp, "txXfrm", NS.dsp));
15839
- if (textFrame) shape2.textFrame = applyGroup(textFrame, group);
15839
+ if (textFrame) shape2.textFrame = applyGroup(textFrame, group2);
15840
15840
  return shape2;
15841
15841
  }
15842
15842
  function parseDiagramDrawing(source, part) {
@@ -15845,14 +15845,14 @@ function parseDiagramDrawing(source, part) {
15845
15845
  const shapes = [];
15846
15846
  const tree = root.localName === "spTree" ? root : first(root, "spTree", NS.dsp);
15847
15847
  let counter = 0;
15848
- const visit = (container, group) => {
15848
+ const visit = (container, group2) => {
15849
15849
  for (const child4 of Array.from(container.childNodes)) {
15850
15850
  if (child4.nodeType !== 1) continue;
15851
15851
  const element = child4;
15852
15852
  if (element.localName === "sp") {
15853
- const shape2 = parseShape2(element, counter++, group, issues);
15853
+ const shape2 = parseShape2(element, counter++, group2, issues);
15854
15854
  if (shape2) shapes.push(shape2);
15855
- } else if (element.localName === "grpSp") visit(element, groupTransform(element, group));
15855
+ } else if (element.localName === "grpSp") visit(element, groupTransform(element, group2));
15856
15856
  else if (element.localName === "pic")
15857
15857
  issues.push({
15858
15858
  code: "DIAGRAM_DRAWING_PICTURE_SKIPPED",
@@ -16199,13 +16199,297 @@ function groupRowsByCategory(rawCategories) {
16199
16199
  return { uniqueCategories, rowIndexesByCategory };
16200
16200
  }
16201
16201
 
16202
+ // chart/number-format-pattern.ts
16203
+ var NAMED_FORMAT_COLORS = {
16204
+ black: "#000000",
16205
+ blue: "#0000FF",
16206
+ cyan: "#00FFFF",
16207
+ green: "#00FF00",
16208
+ magenta: "#FF00FF",
16209
+ red: "#FF0000",
16210
+ white: "#FFFFFF",
16211
+ yellow: "#FFFF00"
16212
+ };
16213
+ var PLACEHOLDER = /[0#?]/u;
16214
+ function parsePattern(code) {
16215
+ let scale = 1;
16216
+ let scientific = false;
16217
+ let color;
16218
+ const chars = [];
16219
+ let inQuotes = false;
16220
+ for (let i = 0; i < code.length; i += 1) {
16221
+ const ch = code[i] ?? "";
16222
+ if (ch === '"') {
16223
+ inQuotes = !inQuotes;
16224
+ continue;
16225
+ }
16226
+ if (inQuotes) {
16227
+ chars.push({ ch, literal: true });
16228
+ continue;
16229
+ }
16230
+ if (ch === "\\" || ch === "*" || ch === "_") {
16231
+ const next = code[i + 1];
16232
+ i += 1;
16233
+ if (ch === "\\" && next !== void 0) {
16234
+ chars.push({ ch: next, literal: true });
16235
+ }
16236
+ continue;
16237
+ }
16238
+ if (ch === "%") {
16239
+ scale *= 100;
16240
+ chars.push({ ch, literal: true });
16241
+ continue;
16242
+ }
16243
+ if (ch === "E" && (code[i + 1] === "+" || code[i + 1] === "-")) {
16244
+ scientific = true;
16245
+ chars.push({ ch: "E", literal: false });
16246
+ i += 1;
16247
+ continue;
16248
+ }
16249
+ if (ch === "[") {
16250
+ const close = code.indexOf("]", i);
16251
+ const token = code.slice(i + 1, close === -1 ? code.length : close);
16252
+ const named3 = NAMED_FORMAT_COLORS[token.trim().toLowerCase()];
16253
+ if (named3 && color === void 0) {
16254
+ color = named3;
16255
+ }
16256
+ i = close === -1 ? code.length : close;
16257
+ continue;
16258
+ }
16259
+ chars.push({ ch, literal: false });
16260
+ }
16261
+ const firstDigit = chars.findIndex((c2) => !c2.literal && PLACEHOLDER.test(c2.ch));
16262
+ if (firstDigit === -1) {
16263
+ return void 0;
16264
+ }
16265
+ let lastDigit = firstDigit;
16266
+ for (let i = chars.length - 1; i >= firstDigit; i -= 1) {
16267
+ const c2 = chars[i];
16268
+ if (c2 && !c2.literal && (PLACEHOLDER.test(c2.ch) || c2.ch === "." || c2.ch === "," || c2.ch === "E")) {
16269
+ lastDigit = i;
16270
+ break;
16271
+ }
16272
+ }
16273
+ const numeric = chars.slice(firstDigit, lastDigit + 1);
16274
+ const prefix2 = chars.slice(0, firstDigit).map((c2) => c2.ch).join("");
16275
+ const suffix = chars.slice(lastDigit + 1).map((c2) => c2.ch).join("");
16276
+ let grouped = false;
16277
+ let intDigits = 0;
16278
+ let required = 0;
16279
+ let optional = 0;
16280
+ let afterPoint = false;
16281
+ let inExponent = false;
16282
+ for (let i = 0; i < numeric.length; i += 1) {
16283
+ const { ch, literal } = numeric[i] ?? { ch: "", literal: true };
16284
+ if (literal) {
16285
+ continue;
16286
+ }
16287
+ if (ch === "E") {
16288
+ inExponent = true;
16289
+ continue;
16290
+ }
16291
+ if (inExponent) {
16292
+ continue;
16293
+ }
16294
+ if (ch === ".") {
16295
+ afterPoint = true;
16296
+ continue;
16297
+ }
16298
+ if (ch === ",") {
16299
+ const next = numeric.slice(i + 1).find((c2) => !c2.literal);
16300
+ if (!next || next.ch === "." || !PLACEHOLDER.test(next.ch)) {
16301
+ scale /= 1e3;
16302
+ } else {
16303
+ grouped = true;
16304
+ }
16305
+ continue;
16306
+ }
16307
+ if (!PLACEHOLDER.test(ch)) {
16308
+ continue;
16309
+ }
16310
+ if (afterPoint) {
16311
+ if (ch === "0") {
16312
+ required += 1;
16313
+ } else {
16314
+ optional += 1;
16315
+ }
16316
+ } else if (ch === "0") {
16317
+ intDigits += 1;
16318
+ }
16319
+ }
16320
+ return {
16321
+ prefix: prefix2,
16322
+ suffix,
16323
+ intDigits,
16324
+ decimals: { required, optional },
16325
+ grouped,
16326
+ scale,
16327
+ scientific,
16328
+ color
16329
+ };
16330
+ }
16331
+ function group(intPart) {
16332
+ return intPart.replace(/\B(?=(\d{3})+(?!\d))/gu, ",");
16333
+ }
16334
+ function applyPattern(value, pattern, forcePositive) {
16335
+ const scaled = value * pattern.scale;
16336
+ const magnitude = forcePositive ? Math.abs(scaled) : scaled;
16337
+ if (pattern.scientific) {
16338
+ const digits = pattern.decimals.required + pattern.decimals.optional;
16339
+ const exponential = magnitude.toExponential(digits);
16340
+ const [mantissa = "", exponent = "0"] = exponential.split("e");
16341
+ const sign = exponent.startsWith("-") ? "-" : "+";
16342
+ const power = Math.abs(Number(exponent)).toString().padStart(2, "0");
16343
+ return `${pattern.prefix}${mantissa}E${sign}${power}${pattern.suffix}`;
16344
+ }
16345
+ const maxDecimals = pattern.decimals.required + pattern.decimals.optional;
16346
+ let body = magnitude.toFixed(maxDecimals);
16347
+ if (pattern.decimals.optional > 0) {
16348
+ body = body.replace(/(\.\d*?)0+$/u, "$1").replace(/\.$/u, "");
16349
+ const [, frac = ""] = body.split(".");
16350
+ if (frac.length < pattern.decimals.required) {
16351
+ body = Number(body).toFixed(pattern.decimals.required);
16352
+ }
16353
+ }
16354
+ const [rawIntPart = "", fracPart] = body.split(".");
16355
+ let intPart = rawIntPart;
16356
+ const hasMinusChar = intPart.startsWith("-");
16357
+ const negative = hasMinusChar && Number(body) !== 0;
16358
+ if (hasMinusChar) {
16359
+ intPart = intPart.slice(1);
16360
+ }
16361
+ if (intPart.length < pattern.intDigits) {
16362
+ intPart = intPart.padStart(pattern.intDigits, "0");
16363
+ }
16364
+ if (pattern.intDigits === 0 && intPart === "0" && fracPart !== void 0) {
16365
+ intPart = "";
16366
+ }
16367
+ if (pattern.grouped) {
16368
+ intPart = group(intPart);
16369
+ }
16370
+ const number = fracPart === void 0 ? intPart : `${intPart}.${fracPart}`;
16371
+ return `${negative ? "-" : ""}${pattern.prefix}${number}${pattern.suffix}`;
16372
+ }
16373
+
16374
+ // chart/number-format.ts
16375
+ var GENERAL = /* @__PURE__ */ new Set(["", "general", "@"]);
16376
+ function sections(code) {
16377
+ const out = [];
16378
+ let current = "";
16379
+ let inQuotes = false;
16380
+ for (let i = 0; i < code.length; i += 1) {
16381
+ const ch = code[i];
16382
+ if (ch === '"') {
16383
+ inQuotes = !inQuotes;
16384
+ current += ch;
16385
+ continue;
16386
+ }
16387
+ if (ch === "\\") {
16388
+ current += ch + (code[i + 1] ?? "");
16389
+ i += 1;
16390
+ continue;
16391
+ }
16392
+ if (ch === ";" && !inQuotes) {
16393
+ out.push(current);
16394
+ current = "";
16395
+ continue;
16396
+ }
16397
+ current += ch;
16398
+ }
16399
+ out.push(current);
16400
+ return out;
16401
+ }
16402
+ function sectionFor(value, parts) {
16403
+ if (parts.length === 1) {
16404
+ return { code: parts[0] ?? "", forcePositive: false };
16405
+ }
16406
+ if (value < 0 && parts[1] !== void 0) {
16407
+ return { code: parts[1] ?? "", forcePositive: true };
16408
+ }
16409
+ if (value === 0 && parts[2] !== void 0) {
16410
+ return { code: parts[2] ?? "", forcePositive: false };
16411
+ }
16412
+ return { code: parts[0] ?? "", forcePositive: false };
16413
+ }
16414
+ function formatChartNumberWithColor(value, formatCode) {
16415
+ if (!Number.isFinite(value)) {
16416
+ return void 0;
16417
+ }
16418
+ const code = (formatCode ?? "").trim();
16419
+ if (GENERAL.has(code.toLowerCase())) {
16420
+ return void 0;
16421
+ }
16422
+ if (/(?:^|[^\\"])(?:yy|mm?m|dd?|hh|ss)/iu.test(code) && !/[0#?]/u.test(code)) {
16423
+ return void 0;
16424
+ }
16425
+ const { code: section, forcePositive } = sectionFor(value, sections(code));
16426
+ const pattern = parsePattern(section);
16427
+ if (!pattern) {
16428
+ return void 0;
16429
+ }
16430
+ try {
16431
+ return { text: applyPattern(value, pattern, forcePositive), color: pattern.color };
16432
+ } catch {
16433
+ return void 0;
16434
+ }
16435
+ }
16436
+ function formatChartNumber(value, formatCode) {
16437
+ return formatChartNumberWithColor(value, formatCode)?.text;
16438
+ }
16439
+
16440
+ // chart/data-label-text.ts
16441
+ var DATA_LABEL_SEPARATOR = ", ";
16442
+ var DATA_LABEL_CATEGORY_PERCENT_SEPARATOR = "\n";
16443
+ var FLAG_KEYS = [
16444
+ "showValue",
16445
+ "showCategory",
16446
+ "showSeriesName",
16447
+ "showPercent",
16448
+ "showBubbleSize"
16449
+ ];
16450
+ function resolveDataLabelFlags(levels) {
16451
+ const { point, series, chart } = levels;
16452
+ const picked = {};
16453
+ for (const key of FLAG_KEYS) picked[key] = point?.[key] ?? series?.[key] ?? chart?.[key];
16454
+ const anyDeclared = FLAG_KEYS.some((key) => picked[key] !== void 0);
16455
+ return {
16456
+ showValue: anyDeclared ? picked.showValue === true : levels.siblingOwnsLabels !== true,
16457
+ showCategory: picked.showCategory === true,
16458
+ showSeriesName: picked.showSeriesName === true,
16459
+ showPercent: picked.showPercent === true,
16460
+ showBubbleSize: picked.showBubbleSize === true,
16461
+ separator: point?.separator ?? series?.separator ?? chart?.separator ?? (picked.showCategory === true && picked.showPercent === true ? DATA_LABEL_CATEGORY_PERCENT_SEPARATOR : DATA_LABEL_SEPARATOR)
16462
+ };
16463
+ }
16464
+ function composeDataLabelText(input) {
16465
+ const { flags, value, numberFormat: numberFormat2 } = input;
16466
+ const parts = [];
16467
+ let valueColor;
16468
+ if (flags.showSeriesName && input.seriesName) parts.push(input.seriesName);
16469
+ if (flags.showCategory && input.category) parts.push(input.category);
16470
+ if (flags.showValue) {
16471
+ const formatted = formatChartNumberWithColor(value, numberFormat2);
16472
+ parts.push(formatted?.text ?? (input.formatValue ?? String)(value, numberFormat2));
16473
+ valueColor = formatted?.color;
16474
+ }
16475
+ if (flags.showPercent) {
16476
+ const base = input.percentBase;
16477
+ parts.push(base > 0 ? `${Math.round(Math.abs(value) / base * 100)}%` : "0%");
16478
+ }
16479
+ if (flags.showBubbleSize && input.bubbleSize !== void 0)
16480
+ parts.push((input.formatBubbleSize ?? String)(input.bubbleSize));
16481
+ const text3 = parts.join(flags.separator);
16482
+ if (text3.length === 0) return void 0;
16483
+ return { text: text3, color: parts.length === 1 && flags.showValue ? valueColor : void 0 };
16484
+ }
16485
+
16202
16486
  // chart/bubble-radius.ts
16203
- function computeBubbleRadius(sizeVal, maxBubble, medianRadius, options) {
16204
- const scale = (options?.bubbleScale ?? 100) / 100;
16487
+ function computeBubbleRadius(sizeVal, maxBubble, medianRadius, options2) {
16488
+ const scale = (options2?.bubbleScale ?? 100) / 100;
16205
16489
  if (sizeVal === void 0) return medianRadius * scale;
16206
16490
  const denom = maxBubble > 0 ? maxBubble : 1;
16207
16491
  const magnitude = Math.abs(sizeVal);
16208
- const ratio = (options?.sizeRepresents ?? "w") === "area" ? Math.sqrt(magnitude) / Math.sqrt(denom) : magnitude / denom;
16492
+ const ratio = (options2?.sizeRepresents ?? "w") === "area" ? Math.sqrt(magnitude) / Math.sqrt(denom) : magnitude / denom;
16209
16493
  return medianRadius * scale * 0.5 + ratio * medianRadius * scale * 1.5;
16210
16494
  }
16211
16495
  function maxBubbleSize(sizes) {
@@ -16311,10 +16595,10 @@ function squarify(nodes, box) {
16311
16595
 
16312
16596
  // chart/hierarchy.ts
16313
16597
  function normalizeLevels(levels, pointCount) {
16314
- return levels.map((level) => {
16598
+ return levels.map((level2) => {
16315
16599
  let previous = "";
16316
16600
  return Array.from({ length: pointCount }, (_, index) => {
16317
- const label = level[index]?.trim() ?? "";
16601
+ const label = level2[index]?.trim() ?? "";
16318
16602
  if (label) previous = label;
16319
16603
  return label || previous;
16320
16604
  });
@@ -16472,12 +16756,12 @@ function computeSunburstArcs(series, cx2, cy, maxR) {
16472
16756
  });
16473
16757
  return out;
16474
16758
  }
16475
- function hierarchyKey(levels, level, index) {
16476
- return levels.slice(level).map((labels) => labels[index] ?? "").join("\0");
16759
+ function hierarchyKey(levels, level2, index) {
16760
+ return levels.slice(level2).map((labels) => labels[index] ?? "").join("\0");
16477
16761
  }
16478
16762
  function computeHierarchicalSunburstArcs(categoryLevels2, values, cx2, cy, maxR) {
16479
- const levels = categoryLevels2.filter((level) => level.length > 0);
16480
- const leafCount = Math.max(values.length, ...levels.map((level) => level.length), 0);
16763
+ const levels = categoryLevels2.filter((level2) => level2.length > 0);
16764
+ const leafCount = Math.max(values.length, ...levels.map((level2) => level2.length), 0);
16481
16765
  if (levels.length === 0 || leafCount === 0) return [];
16482
16766
  const rawWeights = Array.from({ length: leafCount }, (_, index) => Math.abs(values[index] ?? 0));
16483
16767
  const weights = rawWeights.some((value) => value !== 0) ? rawWeights : rawWeights.map(() => 1);
@@ -16488,15 +16772,15 @@ function computeHierarchicalSunburstArcs(categoryLevels2, values, cx2, cy, maxR)
16488
16772
  const rootLabels = levels[levels.length - 1] ?? [];
16489
16773
  const rootColors = /* @__PURE__ */ new Map();
16490
16774
  const out = [];
16491
- for (let level = levels.length - 1; level >= 0; level--) {
16492
- const ringIndex = levels.length - 1 - level;
16775
+ for (let level2 = levels.length - 1; level2 >= 0; level2--) {
16776
+ const ringIndex = levels.length - 1 - level2;
16493
16777
  const innerRadius = ringWidth * (ringIndex + 0.5);
16494
16778
  const outerRadius = ringWidth * (ringIndex + 1.5);
16495
16779
  let start = 0;
16496
16780
  while (start < leafCount) {
16497
- const key = hierarchyKey(levels, level, start);
16781
+ const key = hierarchyKey(levels, level2, start);
16498
16782
  let end = start + 1;
16499
- while (end < leafCount && hierarchyKey(levels, level, end) === key) end++;
16783
+ while (end < leafCount && hierarchyKey(levels, level2, end) === key) end++;
16500
16784
  const startAngle = -Math.PI / 2 + (prefix2[start] ?? 0) / total * Math.PI * 2;
16501
16785
  const endAngle = -Math.PI / 2 + (prefix2[end] ?? 0) / total * Math.PI * 2;
16502
16786
  const rootLabel = rootLabels[start] ?? "";
@@ -16506,8 +16790,8 @@ function computeHierarchicalSunburstArcs(categoryLevels2, values, cx2, cy, maxR)
16506
16790
  colorIndex: rootColors.get(rootLabel) ?? start,
16507
16791
  opacity: Math.max(0.1, 0.9 - ringIndex * 0.1),
16508
16792
  level: ringIndex,
16509
- label: levels[level]?.[start] ?? "",
16510
- ...level === 0 && end === start + 1 ? { pointIndex: start } : {},
16793
+ label: levels[level2]?.[start] ?? "",
16794
+ ...level2 === 0 && end === start + 1 ? { pointIndex: start } : {},
16511
16795
  ...arcLabelPlacement(cx2, cy, (innerRadius + outerRadius) / 2, startAngle, endAngle)
16512
16796
  });
16513
16797
  start = end;
@@ -16533,14 +16817,14 @@ function scottBinCount(values, min, max) {
16533
16817
  const width = 3.49 * sd * values.length ** (-1 / 3);
16534
16818
  return Math.max(1, Math.ceil((max - min) / width));
16535
16819
  }
16536
- function computeHistogramBins(values, options, format = String) {
16537
- const closed = options.intervalClosed ?? "l";
16820
+ function computeHistogramBins(values, options2, format = String) {
16821
+ const closed = options2.intervalClosed ?? "l";
16538
16822
  const finite2 = values.map((value, sourceIndex) => ({ value, sourceIndex })).filter((item) => Number.isFinite(item.value));
16539
16823
  if (finite2.length === 0) {
16540
16824
  return [];
16541
16825
  }
16542
- const underflow = typeof options.underflow === "number" ? options.underflow : void 0;
16543
- const overflow = typeof options.overflow === "number" ? options.overflow : void 0;
16826
+ const underflow = typeof options2.underflow === "number" ? options2.underflow : void 0;
16827
+ const overflow = typeof options2.overflow === "number" ? options2.overflow : void 0;
16544
16828
  const under = underflow === void 0 ? [] : finite2.filter(
16545
16829
  (item) => closed === "r" ? item.value <= underflow : item.value < underflow
16546
16830
  );
@@ -16557,8 +16841,8 @@ function computeHistogramBins(values, options, format = String) {
16557
16841
  if (regular.length > 0) {
16558
16842
  const min = Math.min(...regular.map((item) => item.value));
16559
16843
  const max = Math.max(...regular.map((item) => item.value));
16560
- const requestedSize = options.binSize && options.binSize > 0 ? options.binSize : void 0;
16561
- const requestedCount = options.binCount && options.binCount > 0 ? options.binCount : void 0;
16844
+ const requestedSize = options2.binSize && options2.binSize > 0 ? options2.binSize : void 0;
16845
+ const requestedCount = options2.binCount && options2.binCount > 0 ? options2.binCount : void 0;
16562
16846
  const start = requestedSize ? Math.floor(min / requestedSize) * requestedSize : min;
16563
16847
  const count = requestedSize ? Math.max(
16564
16848
  closed === "l" ? Math.floor((max - start) / requestedSize) + 1 : Math.ceil((max - start) / requestedSize),
@@ -16609,9 +16893,9 @@ function aggregateByCategory(values, rawCategories) {
16609
16893
  }
16610
16894
 
16611
16895
  // chart/waterfall.ts
16612
- function buildWaterfallSteps(values, options) {
16896
+ function buildWaterfallSteps(values, options2) {
16613
16897
  const subtotalIndices = new Set(
16614
- options?.subtotalIndices ?? (values.length > 0 ? [values.length - 1] : [])
16898
+ options2?.subtotalIndices ?? (values.length > 0 ? [values.length - 1] : [])
16615
16899
  );
16616
16900
  const steps = [];
16617
16901
  let runningTotal = 0;
@@ -16671,13 +16955,13 @@ var noFit = () => ({
16671
16955
  rSquared: 0,
16672
16956
  coefficients: []
16673
16957
  });
16674
- function fitModel(options, xVals, yVals) {
16958
+ function fitModel(options2, xVals, yVals) {
16675
16959
  const xs = [...xVals];
16676
16960
  const ys = [...yVals];
16677
- switch (options.kind) {
16961
+ switch (options2.kind) {
16678
16962
  case "linear": {
16679
16963
  const reg = computeLinearRegression(xs, ys);
16680
- const fixed = options.intercept;
16964
+ const fixed = options2.intercept;
16681
16965
  const slope = fixed !== void 0 ? ys.reduce((s, y, i) => s + (y - fixed) * xs[i], 0) / xs.reduce((s, x) => s + x * x, 0) : reg.slope;
16682
16966
  const b = fixed ?? reg.intercept;
16683
16967
  return {
@@ -16727,7 +17011,7 @@ function fitModel(options, xVals, yVals) {
16727
17011
  };
16728
17012
  }
16729
17013
  case "polynomial": {
16730
- const order = Math.min(options.order ?? 2, 6);
17014
+ const order = Math.min(options2.order ?? 2, 6);
16731
17015
  const coeffs = fitPolynomial(xs, ys, order);
16732
17016
  const evaluate = (x) => coeffs.reduce((s, c2, i) => s + c2 * x ** i, 0);
16733
17017
  return {
@@ -16741,11 +17025,11 @@ function fitModel(options, xVals, yVals) {
16741
17025
  return void 0;
16742
17026
  }
16743
17027
  }
16744
- function fitChartTrendline(options, xVals, yVals) {
17028
+ function fitChartTrendline(options2, xVals, yVals) {
16745
17029
  const count = yVals.length;
16746
17030
  if (count < 2) return noFit();
16747
- if (options.kind === "movingAvg") {
16748
- const period = options.period ?? 2;
17031
+ if (options2.kind === "movingAvg") {
17032
+ const period = options2.period ?? 2;
16749
17033
  const points2 = [];
16750
17034
  for (let i = period - 1; i < count; i++) {
16751
17035
  let sum = 0;
@@ -16754,10 +17038,10 @@ function fitChartTrendline(options, xVals, yVals) {
16754
17038
  }
16755
17039
  return { points: points2, equation: `${period}-period moving average`, rSquared: 0, coefficients: [] };
16756
17040
  }
16757
- const model = fitModel(options, xVals, yVals);
17041
+ const model = fitModel(options2, xVals, yVals);
16758
17042
  if (!model) return noFit();
16759
- const startX = Math.min(...xVals) - (options.backward ?? 0);
16760
- const endX = Math.max(...xVals) + (options.forward ?? 0);
17043
+ const startX = Math.min(...xVals) - (options2.backward ?? 0);
17044
+ const endX = Math.max(...xVals) + (options2.forward ?? 0);
16761
17045
  const steps = Math.max(Math.ceil((endX - startX) * 4), 20);
16762
17046
  const points = [];
16763
17047
  for (let step = 0; step <= steps; step++) {
@@ -16780,19 +17064,78 @@ function chartSampleVariance(values) {
16780
17064
  const mean = values.reduce((sum, value) => sum + value, 0) / count;
16781
17065
  return values.reduce((sum, value) => sum + (value - mean) ** 2, 0) / Math.max(count - 1, 1);
16782
17066
  }
16783
- function chartErrorBarAmount(options, values, displayIndex, sourceIndex, side) {
16784
- switch (options.valueType) {
17067
+ function chartErrorBarAmount(options2, values, displayIndex, sourceIndex, side) {
17068
+ switch (options2.valueType) {
16785
17069
  case "fixedVal":
16786
- return options.value ?? 0;
17070
+ return options2.value ?? 0;
16787
17071
  case "percentage":
16788
- return Math.abs(values[displayIndex] ?? 0) * ((options.value ?? 0) / 100);
17072
+ return Math.abs(values[displayIndex] ?? 0) * ((options2.value ?? 0) / 100);
16789
17073
  case "stdDev":
16790
- return Math.sqrt(chartSampleVariance(values)) * (options.value ?? 1);
17074
+ return Math.sqrt(chartSampleVariance(values)) * (options2.value ?? 1);
16791
17075
  case "stdErr":
16792
17076
  return Math.sqrt(chartSampleVariance(values) / Math.max(values.length, 1));
16793
17077
  case "cust":
16794
- return side === "plus" ? options.customPlus?.[sourceIndex] ?? 0 : options.customMinus?.[sourceIndex] ?? 0;
17078
+ return side === "plus" ? options2.customPlus?.[sourceIndex] ?? 0 : options2.customMinus?.[sourceIndex] ?? 0;
17079
+ }
17080
+ }
17081
+
17082
+ // chart/pie-best-fit.ts
17083
+ var PX_PER_PT = 4 / 3;
17084
+ var BEST_FIT_RIM_INSET = 4 * PX_PER_PT;
17085
+ var BEST_FIT_EDGE_TOLERANCE = 1.5 * PX_PER_PT;
17086
+ var BEST_FIT_OUTSIDE_GAP = 2 * PX_PER_PT;
17087
+ function farCorner(x, y, w, h) {
17088
+ return Math.hypot(Math.abs(x) + w / 2, Math.abs(y) + h / 2);
17089
+ }
17090
+ function insideDistance(ux, uy, w, h, limit) {
17091
+ if (farCorner(0, 0, w, h) > limit) {
17092
+ return void 0;
17093
+ }
17094
+ let lo = 0;
17095
+ let hi = limit;
17096
+ for (let i = 0; i < 40; i++) {
17097
+ const mid = (lo + hi) / 2;
17098
+ if (farCorner(mid * ux, mid * uy, w, h) > limit) {
17099
+ hi = mid;
17100
+ } else {
17101
+ lo = mid;
17102
+ }
17103
+ }
17104
+ return lo;
17105
+ }
17106
+ function edgeOverhang(x, y, w, h, slice) {
17107
+ let worst = Number.NEGATIVE_INFINITY;
17108
+ const corners = [
17109
+ [-w / 2, -h / 2],
17110
+ [w / 2, -h / 2],
17111
+ [-w / 2, h / 2],
17112
+ [w / 2, h / 2]
17113
+ ];
17114
+ for (const [dx, dy] of corners) {
17115
+ const px3 = x + dx;
17116
+ const py = y + dy;
17117
+ const fromStart = Math.cos(slice.startAngle) * py - Math.sin(slice.startAngle) * px3;
17118
+ const fromEnd = Math.sin(slice.endAngle) * px3 - Math.cos(slice.endAngle) * py;
17119
+ worst = Math.max(worst, -fromStart, -fromEnd);
17120
+ }
17121
+ return worst;
17122
+ }
17123
+ function placeBestFitLabel(slice, w, h) {
17124
+ const mid = (slice.startAngle + slice.endAngle) / 2;
17125
+ const ux = Math.cos(mid);
17126
+ const uy = Math.sin(mid);
17127
+ const distance = insideDistance(ux, uy, w, h, slice.outerR - BEST_FIT_RIM_INSET);
17128
+ if (distance !== void 0) {
17129
+ const x = distance * ux;
17130
+ const y = distance * uy;
17131
+ const reflex = slice.endAngle - slice.startAngle >= Math.PI;
17132
+ if (reflex || edgeOverhang(x, y, w, h, slice) <= BEST_FIT_EDGE_TOLERANCE) {
17133
+ return { x: slice.cx + x, y: slice.cy + y, inside: true };
17134
+ }
16795
17135
  }
17136
+ const extent = Math.abs(ux) * w / 2 + Math.abs(uy) * h / 2;
17137
+ const outside = slice.outerR + BEST_FIT_OUTSIDE_GAP + extent;
17138
+ return { x: slice.cx + outside * ux, y: slice.cy + outside * uy, inside: false };
16796
17139
  }
16797
17140
 
16798
17141
  // chart/color-palettes.ts
@@ -17003,6 +17346,19 @@ function readChartAppearance(text3, properties2) {
17003
17346
  }
17004
17347
 
17005
17348
  // chart/formatting-nodes.ts
17349
+ function chartDataLabelNode(root) {
17350
+ const plot = first(first(root, "chart", NS.c), "plotArea", NS.c);
17351
+ const groups = plot ? elements(plot).filter((node) => node.localName.endsWith("Chart")) : [];
17352
+ const candidates = groups.flatMap((group2) => [
17353
+ ...children(group2, "ser", NS.c).map((ser) => first(ser, "dLbls", NS.c)),
17354
+ first(group2, "dLbls", NS.c)
17355
+ ]);
17356
+ return candidates.find(
17357
+ (node) => node !== void 0 && (first(node, "txPr", NS.c) !== void 0 || elements(node).some(
17358
+ (child4) => child4.localName.startsWith("show") && child4.getAttribute("val") === "1"
17359
+ ))
17360
+ );
17361
+ }
17006
17362
  function chartFormattingNodes(root) {
17007
17363
  const chart = first(root, "chart", NS.c);
17008
17364
  const plot = first(chart, "plotArea", NS.c);
@@ -17098,6 +17454,8 @@ function readChartFormatting(root) {
17098
17454
  const entries = Object.fromEntries(
17099
17455
  Object.entries(nodes).flatMap(([name, node]) => node ? [[name, entry(node)]] : [])
17100
17456
  );
17457
+ const labels = chartDataLabelNode(root);
17458
+ if (labels) entries["dataLabel"] = entry(labels);
17101
17459
  const builtInStyle = readBuiltInChartStyle(root);
17102
17460
  const textBody = c(root, "txPr");
17103
17461
  const textDefaults = textBody ? {
@@ -18216,6 +18574,191 @@ function drawingLineXml(line3) {
18216
18574
  return buildXml(doc);
18217
18575
  }
18218
18576
 
18577
+ // chart/marker-shape.ts
18578
+ var CHART_PX_PER_PT = 4 / 3;
18579
+ var DEFAULT_MARKER_OUTLINE_PT = 0.75;
18580
+ var AUTOMATIC_MARKER_CYCLE = [
18581
+ "diamond",
18582
+ "square",
18583
+ "triangle",
18584
+ "x",
18585
+ "star",
18586
+ "circle",
18587
+ "plus",
18588
+ "dot",
18589
+ "dash"
18590
+ ];
18591
+ function automaticMarkerSymbol(seriesIdx) {
18592
+ const length = AUTOMATIC_MARKER_CYCLE.length;
18593
+ const normalized = (Math.trunc(seriesIdx) % length + length) % length;
18594
+ return AUTOMATIC_MARKER_CYCLE[Number.isFinite(normalized) ? normalized : 0];
18595
+ }
18596
+ function markerRadius(size, defaultRadius) {
18597
+ if (size === void 0 || !Number.isFinite(size) || size <= 0) {
18598
+ return defaultRadius;
18599
+ }
18600
+ return size / 2;
18601
+ }
18602
+ function polygonPoints(vertices) {
18603
+ return vertices.map(([x, y]) => `${x.toFixed(2)},${y.toFixed(2)}`).join(" ");
18604
+ }
18605
+ function starVertices(cx2, cy, r) {
18606
+ const inner = r * 0.5;
18607
+ const out = [];
18608
+ for (let i = 0; i < 10; i++) {
18609
+ const radius = i % 2 === 0 ? r : inner;
18610
+ const angle = -Math.PI / 2 + Math.PI * i / 5;
18611
+ out.push([cx2 + radius * Math.cos(angle), cy + radius * Math.sin(angle)]);
18612
+ }
18613
+ return out;
18614
+ }
18615
+ function rectPolygon(x, y, w, h) {
18616
+ return polygonPoints([
18617
+ [x, y],
18618
+ [x + w, y],
18619
+ [x + w, y + h],
18620
+ [x, y + h]
18621
+ ]);
18622
+ }
18623
+ function buildMarkerPrimitive(input) {
18624
+ const { symbol, cx: cx2, cy, fill } = input;
18625
+ const part = input.part === void 0 ? {} : { part: input.part };
18626
+ if (symbol === "none") {
18627
+ return null;
18628
+ }
18629
+ const r = markerRadius(input.size, input.defaultRadius);
18630
+ const outline2 = input.stroke ? {
18631
+ stroke: input.stroke,
18632
+ strokeWidth: input.strokeWidth ?? DEFAULT_MARKER_OUTLINE_PT * CHART_PX_PER_PT
18633
+ } : void 0;
18634
+ const polygonStroke = outline2 ?? { stroke: fill, strokeWidth: 0 };
18635
+ const lineStroke = input.stroke ?? fill;
18636
+ switch (symbol) {
18637
+ case "square":
18638
+ case "dash": {
18639
+ const h = symbol === "dash" ? r * 0.64 : r * 2;
18640
+ const y = cy - h / 2;
18641
+ if (outline2) {
18642
+ return {
18643
+ kind: "polygon",
18644
+ points: rectPolygon(cx2 - r, y, r * 2, h),
18645
+ fill,
18646
+ ...outline2,
18647
+ ...part
18648
+ };
18649
+ }
18650
+ return { kind: "rect", x: cx2 - r, y, w: r * 2, h, fill, ...part };
18651
+ }
18652
+ case "diamond":
18653
+ return {
18654
+ kind: "polygon",
18655
+ points: polygonPoints([
18656
+ [cx2, cy - r],
18657
+ [cx2 + r, cy],
18658
+ [cx2, cy + r],
18659
+ [cx2 - r, cy]
18660
+ ]),
18661
+ fill,
18662
+ ...polygonStroke,
18663
+ ...part
18664
+ };
18665
+ case "triangle":
18666
+ return {
18667
+ kind: "polygon",
18668
+ points: polygonPoints([
18669
+ [cx2, cy - r],
18670
+ [cx2 + r * 0.9, cy + r * 0.75],
18671
+ [cx2 - r * 0.9, cy + r * 0.75]
18672
+ ]),
18673
+ fill,
18674
+ ...polygonStroke,
18675
+ ...part
18676
+ };
18677
+ case "star":
18678
+ return {
18679
+ kind: "polygon",
18680
+ points: polygonPoints(starVertices(cx2, cy, r)),
18681
+ fill,
18682
+ ...polygonStroke,
18683
+ ...part
18684
+ };
18685
+ case "plus":
18686
+ return {
18687
+ kind: "path",
18688
+ d: `M${(cx2 - r).toFixed(2)},${cy.toFixed(2)} L${(cx2 + r).toFixed(2)},${cy.toFixed(2)} M${cx2.toFixed(2)},${(cy - r).toFixed(2)} L${cx2.toFixed(2)},${(cy + r).toFixed(2)}`,
18689
+ fill: "none",
18690
+ stroke: lineStroke,
18691
+ strokeWidth: Math.max(1, r * 0.4),
18692
+ ...part
18693
+ };
18694
+ case "x":
18695
+ return {
18696
+ kind: "path",
18697
+ d: `M${(cx2 - r).toFixed(2)},${(cy - r).toFixed(2)} L${(cx2 + r).toFixed(2)},${(cy + r).toFixed(2)} M${(cx2 + r).toFixed(2)},${(cy - r).toFixed(2)} L${(cx2 - r).toFixed(2)},${(cy + r).toFixed(2)}`,
18698
+ fill: "none",
18699
+ stroke: lineStroke,
18700
+ strokeWidth: Math.max(1, r * 0.4),
18701
+ ...part
18702
+ };
18703
+ case "dot":
18704
+ return { kind: "circle", cx: cx2, cy, r: Math.max(r * 0.6, 1), fill, ...part, ...outline2 };
18705
+ default:
18706
+ return { kind: "circle", cx: cx2, cy, r, fill, ...part, ...outline2 };
18707
+ }
18708
+ }
18709
+
18710
+ // chart/render/chart-view-markers.ts
18711
+ function summaryMarkers(source, group2, seriesPosition) {
18712
+ if (!["line", "scatter", "radar"].includes(group2.kind)) return {};
18713
+ const enabled2 = group2.kind === "line" ? group2.marker === true : group2.kind === "radar" ? group2.radarStyle === "marker" : !["line", "smooth", "none"].includes(group2.scatterStyle ?? "marker");
18714
+ const symbol = source.marker?.symbol;
18715
+ const marker = {
18716
+ ...source.marker,
18717
+ symbol: symbol && symbol !== "auto" ? symbol : source.marker || enabled2 ? automaticMarkerSymbol(source.index ?? seriesPosition) : "none"
18718
+ };
18719
+ const pointMarkers = {};
18720
+ for (const point of source.dataPoints) {
18721
+ if (point.index === void 0 || !point.marker) continue;
18722
+ const override = point.marker;
18723
+ pointMarkers[point.index] = {
18724
+ ...marker,
18725
+ ...override,
18726
+ ...override.symbol === "auto" || !source.marker && override.symbol === void 0 ? { symbol: automaticMarkerSymbol(source.index ?? seriesPosition) } : {},
18727
+ ...marker.spPr || override.spPr ? {
18728
+ spPr: {
18729
+ ...marker.spPr,
18730
+ ...override.spPr,
18731
+ ...marker.spPr?.line || override.spPr?.line ? { line: { ...marker.spPr?.line, ...override.spPr?.line } } : {}
18732
+ }
18733
+ } : {}
18734
+ };
18735
+ }
18736
+ return { marker, ...Object.keys(pointMarkers).length ? { pointMarkers } : {} };
18737
+ }
18738
+ function seriesMarkerViews(source, drawingColor) {
18739
+ const fillColor = (fill) => fill?.kind === "none" ? "none" : fill?.kind === "solid" ? drawingColor(fill.color) : void 0;
18740
+ const resolve = (marker) => {
18741
+ const fill = fillColor(marker.spPr?.fill);
18742
+ const stroke = fillColor(marker.spPr?.line?.fill);
18743
+ const width = marker.spPr?.line?.widthEmu;
18744
+ return {
18745
+ ...marker.symbol !== void 0 ? { symbol: marker.symbol } : {},
18746
+ ...marker.size !== void 0 ? { size: marker.size } : {},
18747
+ ...fill !== void 0 ? { fill } : {},
18748
+ ...stroke !== void 0 ? { stroke } : {},
18749
+ ...width !== void 0 ? { strokeWidth: width / 9525 } : {}
18750
+ };
18751
+ };
18752
+ return {
18753
+ ...source.marker ? { marker: resolve(source.marker) } : {},
18754
+ ...source.pointMarkers ? {
18755
+ pointMarkers: Object.fromEntries(
18756
+ Object.entries(source.pointMarkers).map(([i, marker]) => [i, resolve(marker)])
18757
+ )
18758
+ } : {}
18759
+ };
18760
+ }
18761
+
18219
18762
  // chart/render/summary-analysis.ts
18220
18763
  function summaryTrendline(source) {
18221
18764
  const kind = chartTrendlineKind(source.trendlineType);
@@ -18256,6 +18799,41 @@ function summaryAnalysis(series) {
18256
18799
  };
18257
18800
  }
18258
18801
 
18802
+ // chart/render/summary-labels.ts
18803
+ function level(options2, custom) {
18804
+ const out = {};
18805
+ if (options2.deleted !== void 0) out.deleted = options2.deleted;
18806
+ if (options2.showValue !== void 0) out.showValue = options2.showValue;
18807
+ if (options2.showCategoryName !== void 0) out.showCategory = options2.showCategoryName;
18808
+ if (options2.showSeriesName !== void 0) out.showSeriesName = options2.showSeriesName;
18809
+ if (options2.showPercent !== void 0) out.showPercent = options2.showPercent;
18810
+ if (options2.showBubbleSize !== void 0) out.showBubbleSize = options2.showBubbleSize;
18811
+ if (options2.separator !== void 0) out.separator = options2.separator;
18812
+ if (options2.position) out.position = options2.position;
18813
+ if (options2.numberFormat?.formatCode) out.numberFormat = options2.numberFormat.formatCode;
18814
+ if (custom?.text !== void 0) out.text = custom.text;
18815
+ return out;
18816
+ }
18817
+ function shows(levels, point) {
18818
+ const flags = resolveDataLabelFlags({ ...levels, ...point ? { point } : {} });
18819
+ return point?.text !== void 0 || Object.values(flags).some((value) => value === true);
18820
+ }
18821
+ function summaryDataLabels(series, group2) {
18822
+ const own2 = series.dataLabels;
18823
+ if (!own2 && !group2) return void 0;
18824
+ const out = {};
18825
+ if (group2) out.chart = level(group2);
18826
+ if (own2) out.series = level(own2);
18827
+ const points = {};
18828
+ for (const labels of [group2, own2])
18829
+ for (const label of labels?.labels ?? [])
18830
+ if (label.index !== void 0)
18831
+ points[label.index] = { ...points[label.index], ...level(label, label.tx) };
18832
+ if (Object.keys(points).length) out.points = points;
18833
+ if (!shows(out) && !Object.values(points).some((point) => shows(out, point))) return void 0;
18834
+ return out;
18835
+ }
18836
+
18259
18837
  // chart/render/summary-from-space.ts
18260
18838
  var solidColor = (fill) => fill?.kind === "solid" ? fill.color : void 0;
18261
18839
  var isSolidFill = (fill) => fill?.kind === "solid" || fill?.kind === "unsupported" && fill.element === "solidFill";
@@ -18273,7 +18851,7 @@ var GROUP_TYPES = {
18273
18851
  surface: "surface"
18274
18852
  };
18275
18853
  var GROUPINGS = /* @__PURE__ */ new Set(["clustered", "stacked", "percentStacked", "standard"]);
18276
- function chartSummarySeries(source, chartType) {
18854
+ function chartSummarySeries(source, chartType, groupLabels) {
18277
18855
  const categories = source.categories ?? source.xValues;
18278
18856
  const values = source.values ?? source.yValues;
18279
18857
  const numeric = (v) => typeof v === "number" ? v : v === "" ? null : Number.isFinite(Number(v)) ? Number(v) : null;
@@ -18281,6 +18859,7 @@ function chartSummarySeries(source, chartType) {
18281
18859
  categories: chartSourceValues(categories),
18282
18860
  values: chartSourceValues(values).map(numeric)
18283
18861
  };
18862
+ if (values?.cache?.formatCode !== void 0) out.numberFormat = values.cache.formatCode;
18284
18863
  if (source.bubbleSizes) {
18285
18864
  out.bubbleSizes = chartSourceValues(source.bubbleSizes).map(numeric);
18286
18865
  if (source.bubbleSizes.formula) out.bubbleSizesRef = source.bubbleSizes.formula;
@@ -18309,6 +18888,8 @@ function chartSummarySeries(source, chartType) {
18309
18888
  }
18310
18889
  if (Object.keys(points).length) out.pointColors = points;
18311
18890
  if (Object.keys(pointFills).length) out.pointFills = pointFills;
18891
+ const dataLabels = summaryDataLabels(source, groupLabels);
18892
+ if (dataLabels) out.dataLabels = dataLabels;
18312
18893
  Object.assign(out, summaryAnalysis(source));
18313
18894
  return out;
18314
18895
  }
@@ -18317,12 +18898,12 @@ function valueAxisId(chartSpace, axisIds) {
18317
18898
  (id) => chartSpace.plotArea.axes.some((a2) => a2.id === id && a2.kind === "val")
18318
18899
  );
18319
18900
  }
18320
- function stockStyle(group) {
18901
+ function stockStyle(group2) {
18321
18902
  return {
18322
- ...group.hiLowLinesSpPr ? { hiLowLines: group.hiLowLinesSpPr } : {},
18323
- ...group.upBars?.spPr ? { upBars: group.upBars.spPr } : {},
18324
- ...group.downBars?.spPr ? { downBars: group.downBars.spPr } : {},
18325
- ...group.upDownBarsGapWidth === void 0 ? {} : { gapWidth: group.upDownBarsGapWidth }
18903
+ ...group2.hiLowLinesSpPr ? { hiLowLines: group2.hiLowLinesSpPr } : {},
18904
+ ...group2.upBars?.spPr ? { upBars: group2.upBars.spPr } : {},
18905
+ ...group2.downBars?.spPr ? { downBars: group2.downBars.spPr } : {},
18906
+ ...group2.upDownBarsGapWidth === void 0 ? {} : { gapWidth: group2.upDownBarsGapWidth }
18326
18907
  };
18327
18908
  }
18328
18909
  function extraGroups(chartSpace, firstType) {
@@ -18330,54 +18911,62 @@ function extraGroups(chartSpace, firstType) {
18330
18911
  if (!first3 || !["column", "line", "area"].includes(firstType)) return [];
18331
18912
  const primary = valueAxisId(chartSpace, first3.axisIds);
18332
18913
  const out = [];
18333
- for (const group of rest) {
18334
- const stockOverColumns = group.kind === "stock" && firstType === "column";
18335
- if (group.is3D || !(["bar", "line", "area"].includes(group.kind) || stockOverColumns)) continue;
18336
- const type = group.kind === "bar" ? "column" : group.kind;
18914
+ for (const group2 of rest) {
18915
+ const stockOverColumns = group2.kind === "stock" && firstType === "column";
18916
+ if (group2.is3D || !(["bar", "line", "area"].includes(group2.kind) || stockOverColumns)) continue;
18917
+ const type = group2.kind === "bar" ? "column" : group2.kind;
18337
18918
  const entry2 = {
18338
18919
  chartType: type,
18339
- series: group.series.map((source) => chartSummarySeries(source, type)),
18340
- secondary: valueAxisId(chartSpace, group.axisIds) !== primary
18920
+ series: group2.series.map((source, index) => ({
18921
+ ...chartSummarySeries(source, type, group2.dataLabels),
18922
+ ...summaryMarkers(source, group2, index)
18923
+ })),
18924
+ secondary: valueAxisId(chartSpace, group2.axisIds) !== primary
18341
18925
  };
18342
- if (group.grouping && GROUPINGS.has(group.grouping))
18343
- entry2.grouping = group.grouping;
18344
- if (type === "stock") entry2.stock = stockStyle(group);
18926
+ if (group2.grouping && GROUPINGS.has(group2.grouping))
18927
+ entry2.grouping = group2.grouping;
18928
+ if (type === "stock") entry2.stock = stockStyle(group2);
18345
18929
  if (type === "column") {
18346
- if (group.gapWidth !== void 0) entry2.barGapWidth = group.gapWidth;
18347
- if (group.overlap !== void 0) entry2.barOverlap = group.overlap;
18930
+ if (group2.gapWidth !== void 0) entry2.barGapWidth = group2.gapWidth;
18931
+ if (group2.overlap !== void 0) entry2.barOverlap = group2.overlap;
18348
18932
  }
18349
18933
  if (entry2.series.length) out.push(entry2);
18350
18934
  }
18351
18935
  return out;
18352
18936
  }
18353
18937
  function chartSummaryFromSpace(chartSpace, extras = {}) {
18354
- const group = chartSpace.plotArea.groups[0];
18355
- let chartType = group ? GROUP_TYPES[group.kind] : "column";
18356
- if (chartType === "bar" && group?.barDirection !== "bar") chartType = "column";
18357
- const series = (group?.series ?? []).map((source) => chartSummarySeries(source, chartType));
18938
+ const group2 = chartSpace.plotArea.groups[0];
18939
+ let chartType = group2 ? GROUP_TYPES[group2.kind] : "column";
18940
+ if (chartType === "bar" && group2?.barDirection !== "bar") chartType = "column";
18941
+ const series = (group2?.series ?? []).map((source, index) => ({
18942
+ ...chartSummarySeries(source, chartType, group2?.dataLabels),
18943
+ ...group2 ? summaryMarkers(source, group2, index) : {}
18944
+ }));
18358
18945
  const summary = {
18359
18946
  chartType,
18360
18947
  series,
18361
- showLegend: chartSpace.legend !== void 0
18948
+ showLegend: chartSpace.legend !== void 0,
18949
+ axes: chartSpace.plotArea.axes,
18950
+ axisIds: group2?.axisIds ?? []
18362
18951
  };
18363
18952
  const combined = extraGroups(chartSpace, chartType);
18364
18953
  if (combined.length) summary.extraGroups = combined;
18365
- if (chartType === "stock" && group) summary.stock = stockStyle(group);
18366
- if (chartType === "bubble" && group) {
18367
- const sizeRepresents = group.sizeRepresents === "w" ? "w" : "area";
18954
+ if (chartType === "stock" && group2) summary.stock = stockStyle(group2);
18955
+ if (chartType === "bubble" && group2) {
18956
+ const sizeRepresents = group2.sizeRepresents === "w" ? "w" : "area";
18368
18957
  summary.bubble = {
18369
18958
  sizeRepresents,
18370
- ...group.bubbleScale === void 0 ? {} : { bubbleScale: group.bubbleScale },
18371
- showNegativeBubbles: group.showNegativeBubbles === true
18959
+ ...group2.bubbleScale === void 0 ? {} : { bubbleScale: group2.bubbleScale },
18960
+ showNegativeBubbles: group2.showNegativeBubbles === true
18372
18961
  };
18373
18962
  }
18374
- const grouping = group?.grouping;
18963
+ const grouping = group2?.grouping;
18375
18964
  if (grouping && GROUPINGS.has(grouping))
18376
18965
  summary.grouping = grouping;
18377
18966
  if (chartType === "bar" || chartType === "column") {
18378
18967
  for (const [value, field, fallback, min, max] of [
18379
- [group?.gapWidth, "barGapWidth", 150, 0, 500],
18380
- [group?.overlap, "barOverlap", 0, -100, 100]
18968
+ [group2?.gapWidth, "barGapWidth", 150, 0, 500],
18969
+ [group2?.overlap, "barOverlap", 0, -100, 100]
18381
18970
  ]) {
18382
18971
  const resolved = value ?? fallback;
18383
18972
  if (Number.isInteger(resolved) && resolved >= min && resolved <= max)
@@ -18420,9 +19009,9 @@ function dimension(data, kind, type) {
18420
19009
  const out = { points: [] };
18421
19010
  const formula = text(cx(element, "f"));
18422
19011
  if (formula) out.formula = formula;
18423
- const level = cx(element, "lvl");
18424
- const count = Number(level?.getAttribute("ptCount") ?? 0);
18425
- for (const point of level ? children(level, "pt", NS.cx) : []) {
19012
+ const level2 = cx(element, "lvl");
19013
+ const count = Number(level2?.getAttribute("ptCount") ?? 0);
19014
+ for (const point of level2 ? children(level2, "pt", NS.cx) : []) {
18426
19015
  const index = Number(point.getAttribute("idx") ?? out.points.length);
18427
19016
  if (Number.isInteger(index) && index >= 0) out.points[index] = text(point);
18428
19017
  }
@@ -18431,10 +19020,10 @@ function dimension(data, kind, type) {
18431
19020
  }
18432
19021
  function categoryLevels(data) {
18433
19022
  const element = data ? children(data, "strDim", NS.cx).find((d) => (d.getAttribute("type") ?? "") === "cat") : void 0;
18434
- return (element ? children(element, "lvl", NS.cx) : []).map((level) => {
19023
+ return (element ? children(element, "lvl", NS.cx) : []).map((level2) => {
18435
19024
  const points = [];
18436
- const count = Number(level.getAttribute("ptCount") ?? 0);
18437
- for (const point of children(level, "pt", NS.cx)) {
19025
+ const count = Number(level2.getAttribute("ptCount") ?? 0);
19026
+ for (const point of children(level2, "pt", NS.cx)) {
18438
19027
  const index = Number(point.getAttribute("idx") ?? points.length);
18439
19028
  if (Number.isInteger(index) && index >= 0) points[index] = text(point);
18440
19029
  }
@@ -18598,64 +19187,430 @@ function chartBarSpacing(chart) {
18598
19187
  };
18599
19188
  }
18600
19189
 
18601
- // chart/render/chart-svg-bars.ts
18602
- function barLayout(model, frame2) {
18603
- const count = Math.max(1, model.series.length);
18604
- const geometry2 = clusteredBarGeometry(frame2.bandSize, count, chartBarSpacing(model));
18605
- const barSize = geometry2.singleBarWidth;
18606
- const offset = (si) => model.horizontal ? geometry2.clusterWidth / 2 - barSize - si * geometry2.step : -geometry2.clusterWidth / 2 + si * geometry2.step;
18607
- return { barSize, offset };
18608
- }
18609
- function bars(model, frame2, out, values) {
18610
- const stacked = model.grouping === "stacked" || model.grouping === "percentStacked";
18611
- const { barSize, offset: barOffset } = barLayout(model, frame2);
18612
- const base = frame2.value(0);
18613
- const pos = new Array(model.categories.length).fill(0);
18614
- const neg = new Array(model.categories.length).fill(0);
18615
- model.series.forEach((s, si) => {
18616
- values[si]?.forEach((v, i) => {
18617
- if (v === null || i >= model.categories.length) return;
18618
- let from = 0;
18619
- let to = v;
18620
- if (stacked) {
18621
- const acc = v >= 0 ? pos : neg;
18622
- from = acc[i] ?? 0;
18623
- to = from + v;
18624
- acc[i] = to;
18625
- }
18626
- const a2 = stacked ? frame2.value(from) : base;
18627
- const b = frame2.value(to);
18628
- const offset = barOffset(si);
18629
- const center = frame2.band(i);
18630
- const width = model.horizontal ? Math.abs(b - a2) : barSize;
18631
- const height = model.horizontal ? barSize : Math.abs(b - a2);
18632
- let color = s.pointColors?.[i] ?? s.color;
18633
- const gradient = s.pointGradients?.[i] ?? (s.pointColors?.[i] === void 0 ? s.gradient : void 0);
18634
- if (gradient && (gradient.path === "circle" || gradient.path === "shape")) {
18635
- const baseId = color.match(/^url\(#(.+)\)$/)?.[1];
18636
- if (baseId) {
18637
- const id = baseId.replace(/(-s\d+(?:-p\d+)?)$/, `-mark${i}$1`);
18638
- const def = buildChartGradientDef(id, gradient, {
18639
- width: Number(n(width)),
18640
- height: Number(n(height)),
18641
- shape: "rect"
18642
- });
18643
- out.push(`<defs>${chartGradientMarkup(def)}</defs>`);
18644
- color = `url(#${id})`;
18645
- }
18646
- }
18647
- out.push(`<g data-chart-series="${si}" data-chart-point="${i}">`);
18648
- if (model.horizontal)
18649
- out.push(
18650
- rect2(Math.min(a2, b), center + offset, Math.abs(b - a2), barSize, color, s.shadowFilter)
18651
- );
18652
- else
18653
- out.push(
18654
- rect2(center + offset, Math.min(a2, b), barSize, Math.abs(b - a2), color, s.shadowFilter)
18655
- );
18656
- out.push("</g>");
18657
- });
18658
- });
19190
+ // chart/render/theme-palette.ts
19191
+ var THEME_SLOTS = [
19192
+ "lt1",
19193
+ "dk1",
19194
+ "lt2",
19195
+ "dk2",
19196
+ "accent1",
19197
+ "accent2",
19198
+ "accent3",
19199
+ "accent4",
19200
+ "accent5",
19201
+ "accent6",
19202
+ "hlink",
19203
+ "folHlink"
19204
+ ];
19205
+ var DEFAULT_THEME_COLORS = [
19206
+ "FFFFFF",
19207
+ "000000",
19208
+ "E7E6E6",
19209
+ "44546A",
19210
+ "4472C4",
19211
+ "ED7D31",
19212
+ "A5A5A5",
19213
+ "FFC000",
19214
+ "5B9BD5",
19215
+ "70AD47",
19216
+ "0563C1",
19217
+ "954F72"
19218
+ ];
19219
+ function themeColor(theme, index) {
19220
+ const hex = theme.colors[index] ?? DEFAULT_THEME_COLORS[index];
19221
+ return hex && parseArgbHex(hex) ? hex.replace(/^#/, "") : void 0;
19222
+ }
19223
+
19224
+ // chart/render/chart-colors.ts
19225
+ function chartColorScheme(theme) {
19226
+ const slots = Object.fromEntries(
19227
+ THEME_SLOTS.map((slot2, index) => [slot2, `#${themeColor(theme, index) ?? "000000"}`])
19228
+ );
19229
+ return {
19230
+ ...slots,
19231
+ bg1: slots.lt1,
19232
+ tx1: slots.dk1,
19233
+ bg2: slots.lt2,
19234
+ tx2: slots.dk2
19235
+ };
19236
+ }
19237
+ function autoSeriesColor(theme, index) {
19238
+ const i = Math.max(0, Math.floor(index));
19239
+ return chartPaletteSeriesColor(findChartColorPalette(10), i, i + 1, chartColorScheme(theme));
19240
+ }
19241
+
19242
+ // chart/text-inheritance.ts
19243
+ var TEXT_KEYS = [
19244
+ "fontSize",
19245
+ "bold",
19246
+ "italic",
19247
+ "underline",
19248
+ "typeface",
19249
+ "textColor",
19250
+ "fontRef"
19251
+ ];
19252
+ var TEXT_PARTS = [
19253
+ "title",
19254
+ "axisTitle",
19255
+ "categoryAxis",
19256
+ "valueAxis",
19257
+ "legend",
19258
+ "dataLabel"
19259
+ ];
19260
+ function inheritChartText(part, entry2, builtIn, root) {
19261
+ if (!root || !TEXT_PARTS.includes(part)) return entry2;
19262
+ const out = { ...entry2 };
19263
+ for (const key of TEXT_KEYS) {
19264
+ delete out[key];
19265
+ const value = root[key] ?? builtIn?.[key];
19266
+ if (value !== void 0) Object.assign(out, { [key]: value });
19267
+ }
19268
+ if (part === "title" && root.fontSize !== void 0) out.fontSize = root.fontSize * 1.2;
19269
+ if (root.textEffectsXml !== void 0) out.textEffectsXml = root.textEffectsXml;
19270
+ return out;
19271
+ }
19272
+
19273
+ // chart/render/chart-appearance.ts
19274
+ var chartPointsToPixels = (points) => points * EMU_PER_POINT / EMU_PER_PIXEL;
19275
+ function typeface(entry2, theme) {
19276
+ const name = entry2.typeface;
19277
+ if (name?.startsWith("+mj-")) return theme.majorFont;
19278
+ if (name?.startsWith("+mn-")) return theme.minorFont;
19279
+ return name ?? (entry2.fontRef?.index === "major" ? theme.majorFont : entry2.fontRef?.index === "minor" ? theme.minorFont : void 0);
19280
+ }
19281
+ function chartAppearance(chart, theme) {
19282
+ const defaults = builtInChartTextStyle(effectiveBuiltInChartStyle(chart.formatting));
19283
+ const entries = {};
19284
+ for (const part of CHART_STYLE_PARTS) {
19285
+ const base = chart.styleDefinition?.entries[part];
19286
+ const direct = chart.formatting?.entries[part];
19287
+ if (!defaults[part] && !base && !direct) continue;
19288
+ const entry2 = {
19289
+ ...inheritChartText(
19290
+ part,
19291
+ { ...defaults[part], ...base, sourceXml: base?.sourceXml ?? "" },
19292
+ defaults[part],
19293
+ chart.formatting?.textDefaults
19294
+ ),
19295
+ ...direct,
19296
+ sourceXml: direct?.sourceXml ?? base?.sourceXml ?? ""
19297
+ };
19298
+ if (base?.line || direct?.line) entry2.line = { ...base?.line, ...direct?.line };
19299
+ entries[part] = entry2;
19300
+ }
19301
+ const scheme = chartColorScheme(theme);
19302
+ const resolve = (color) => resolveDrawingColor(
19303
+ color,
19304
+ { scheme: (name) => scheme[name] },
19305
+ { hslRounding: "halfDown", transformOrder: "document" }
19306
+ );
19307
+ const out = resolveChartStyleDefinition(
19308
+ { entries},
19309
+ (color) => drawingColorCss(resolve(color))
19310
+ ) ?? {};
19311
+ for (const part of CHART_STYLE_PARTS) {
19312
+ const entry2 = entries[part];
19313
+ if (!entry2) continue;
19314
+ const family = typeface(entry2, theme);
19315
+ const shadow = resolveDrawingShadowXml(entry2.textEffectsXml, {
19316
+ scheme: (name) => scheme[name]
19317
+ });
19318
+ if (shadow) (out[part] ??= {}).textShadow = shadow;
19319
+ if (family) (out[part] ??= {}).typeface = family;
19320
+ if (entry2.axisVisible !== void 0) (out[part] ??= {}).axisVisible = entry2.axisVisible;
19321
+ if (entry2.labelsVisible !== void 0) (out[part] ??= {}).labelsVisible = entry2.labelsVisible;
19322
+ if (entry2.line?.widthEmu === 0) (out[part] ??= {}).lineWidth = 0;
19323
+ if (entry2.fill?.kind === "gradient") {
19324
+ (out[part] ??= {}).gradient = resolveChartGradient(entry2.fill, resolve);
19325
+ }
19326
+ }
19327
+ return out;
19328
+ }
19329
+
19330
+ // text/css-font-family.ts
19331
+ var FALLBACKS = {
19332
+ calibri: '"Calibri", "Carlito", "Segoe UI", Arial, sans-serif',
19333
+ "calibri light": '"Calibri Light", "Calibri", "Carlito", "Segoe UI", Arial, sans-serif',
19334
+ cambria: '"Cambria", "Caladea", Georgia, serif',
19335
+ arial: 'Arial, "Liberation Sans", Helvetica, sans-serif',
19336
+ "times new roman": '"Times New Roman", "Liberation Serif", Times, serif',
19337
+ "courier new": '"Courier New", "Liberation Mono", monospace',
19338
+ aptos: '"Aptos", "Calibri", "Carlito", "Segoe UI", sans-serif'
19339
+ };
19340
+ function cssFontFamily(name) {
19341
+ const known = FALLBACKS[name.toLowerCase()];
19342
+ if (known) return known;
19343
+ const quoted = `"${name.replace(/["\\]/g, "")}"`;
19344
+ return `${quoted}, "Calibri", "Carlito", "Segoe UI", sans-serif`;
19345
+ }
19346
+
19347
+ // chart/render/chart-svg-appearance.ts
19348
+ var nextPaintId = 0;
19349
+ function chartGradientPaint(model, width = 1024, height = 768) {
19350
+ const prefix2 = `xlsx-chart-${++nextPaintId}`;
19351
+ const appearance = { ...model.appearance };
19352
+ const defs = [];
19353
+ const shadowPaint = (shadow, suffix) => {
19354
+ const id = `${prefix2}-${suffix}`;
19355
+ const pad = Math.max(4, shadow.blur * 3 + Math.abs(shadow.dx) + Math.abs(shadow.dy));
19356
+ defs.push(
19357
+ `<filter id="${id}" filterUnits="userSpaceOnUse" x="${n(-pad)}" y="${n(-pad)}" width="${n(width + pad * 2)}" height="${n(height + pad * 2)}" color-interpolation-filters="sRGB">${svgDropShadowElement(shadow, { number: n, color: (value) => esc(value) })}</filter>`
19358
+ );
19359
+ return `url(#${id})`;
19360
+ };
19361
+ for (const [part, entry2] of Object.entries(appearance)) {
19362
+ if (entry2?.textShadow)
19363
+ appearance[part] = {
19364
+ ...entry2,
19365
+ textShadowFilter: shadowPaint(entry2.textShadow, `${part}-text-shadow`)
19366
+ };
19367
+ }
19368
+ const paint2 = (gradient, suffix, bounds) => {
19369
+ const def = buildChartGradientDef(`${prefix2}-${suffix}`, gradient, bounds);
19370
+ defs.push(chartGradientMarkup(def));
19371
+ return `url(#${def.id})`;
19372
+ };
19373
+ for (const part of ["chartArea", "plotArea"]) {
19374
+ const entry2 = appearance[part];
19375
+ if (!entry2?.gradient) continue;
19376
+ if (part === "plotArea" && ["circle", "shape"].includes(entry2.gradient.path ?? "")) continue;
19377
+ appearance[part] = {
19378
+ ...entry2,
19379
+ fillColor: paint2(entry2.gradient, part, { width, height, shape: "rect" })
19380
+ };
19381
+ }
19382
+ const series = model.series.map((source, index) => {
19383
+ const view = { ...source };
19384
+ if (source.shadow) view.shadowFilter = shadowPaint(source.shadow, `s${index}-shadow`);
19385
+ const bounds = model.type === "bar" || model.type === "column" ? { width: 1, height: 1, shape: "rect" } : void 0;
19386
+ if (source.gradient) view.color = paint2(source.gradient, `s${index}`, bounds);
19387
+ if (source.pointGradients) {
19388
+ view.pointColors = [...source.pointColors ?? []];
19389
+ for (const [key, gradient] of Object.entries(source.pointGradients))
19390
+ view.pointColors[Number(key)] = paint2(gradient, `s${index}-p${key}`, bounds);
19391
+ }
19392
+ return view;
19393
+ });
19394
+ return defs.length ? { model: { ...model, appearance, series }, defs: `<defs>${defs.join("")}</defs>` } : { model, defs: "" };
19395
+ }
19396
+ function chartTextAttributes(model, part, fallbackSize = FONT_SIZE) {
19397
+ const entry2 = model.appearance?.[part];
19398
+ return {
19399
+ size: entry2?.fontSize === void 0 ? fallbackSize : chartPointsToPixels(entry2.fontSize),
19400
+ ...entry2?.color === void 0 ? {} : { fill: entry2.color },
19401
+ ...entry2?.bold === void 0 ? {} : { weight: entry2.bold ? "bold" : "normal" },
19402
+ ...entry2?.italic === void 0 ? {} : { italic: entry2.italic },
19403
+ ...entry2?.underline === void 0 ? {} : { underline: entry2.underline },
19404
+ ...entry2?.typeface === void 0 ? {} : { family: cssFontFamily(entry2.typeface) },
19405
+ ...entry2?.textShadowFilter === void 0 ? {} : { filter: entry2.textShadowFilter }
19406
+ };
19407
+ }
19408
+ function chartStroke(model, part) {
19409
+ const entry2 = model.appearance?.[part];
19410
+ return {
19411
+ color: entry2?.axisVisible === false ? "none" : entry2?.lineColor ?? (part.startsWith("gridline") ? GRID_COLOR : AXIS_COLOR),
19412
+ width: entry2?.lineWidth === void 0 ? 1 : chartPointsToPixels(entry2.lineWidth)
19413
+ };
19414
+ }
19415
+ function chartAreaRect(model, part, area) {
19416
+ if (area.w <= 0 || area.h <= 0) return "";
19417
+ const entry2 = model.appearance?.[part];
19418
+ let fill = entry2?.fillColor ?? (part === "chartArea" ? "#FFFFFF" : "none");
19419
+ let defs = "";
19420
+ if (part !== "chartArea" && entry2?.gradient && (part !== "plotArea" || ["circle", "shape"].includes(entry2.gradient.path ?? ""))) {
19421
+ const def = buildChartGradientDef(`xlsx-chart-${++nextPaintId}-${part}`, entry2.gradient, {
19422
+ width: area.w,
19423
+ height: area.h,
19424
+ shape: "rect"
19425
+ });
19426
+ defs = `<defs>${chartGradientMarkup(def)}</defs>`;
19427
+ fill = `url(#${def.id})`;
19428
+ }
19429
+ const stroke = entry2?.lineColor ?? "none";
19430
+ if (fill === "none" && stroke === "none") return "";
19431
+ const width = entry2?.lineWidth === void 0 ? 1 : chartPointsToPixels(entry2.lineWidth);
19432
+ return `${defs}<rect x="${n(area.x)}" y="${n(area.y)}" width="${n(area.w)}" height="${n(area.h)}" fill="${esc(fill)}" stroke="${esc(stroke)}" stroke-width="${n(width)}" data-chart-part="${part}"/>`;
19433
+ }
19434
+
19435
+ // chart/render/chart-svg-labels.ts
19436
+ var GAP = 3;
19437
+ var LINE = 1.2;
19438
+ var NAMED_COLORS = /^(black|blue|cyan|green|magenta|red|white|yellow)$/iu;
19439
+ function measure(model, label) {
19440
+ const attrs2 = chartTextAttributes(model, "dataLabel", 10);
19441
+ const size = attrs2.size ?? 10;
19442
+ const lines = label.text.split("\n");
19443
+ return {
19444
+ lines,
19445
+ size,
19446
+ w: Math.max(...lines.map((l) => textWidth(l, size))),
19447
+ h: lines.length * size * LINE,
19448
+ attrs: attrs2
19449
+ };
19450
+ }
19451
+ function draw(m, label, x, y, anchor, out) {
19452
+ const fill = label.color && NAMED_COLORS.test(label.color) ? label.color.toLowerCase() : void 0;
19453
+ m.lines.forEach((line3, k) => {
19454
+ const lineY = y - m.h / 2 + (k + 0.5) * m.size * LINE + m.size * 0.35;
19455
+ out.push(text2(x, lineY, line3, { ...m.attrs, ...fill ? { fill } : {}, anchor }));
19456
+ });
19457
+ }
19458
+ function barLabels(model, marks, out) {
19459
+ const stacked = model.grouping === "stacked" || model.grouping === "percentStacked";
19460
+ for (const mark of marks) {
19461
+ const label = mark.series.labels?.[mark.index];
19462
+ if (!label) continue;
19463
+ const m = measure(model, label);
19464
+ let position2 = label.position ?? (stacked ? "ctr" : "outEnd");
19465
+ if (stacked && position2 === "outEnd") position2 = "ctr";
19466
+ const cx2 = mark.x + mark.w / 2;
19467
+ const cy = mark.y + mark.h / 2;
19468
+ if (model.horizontal) {
19469
+ const end = mark.negative ? mark.x : mark.x + mark.w;
19470
+ const base = mark.negative ? mark.x + mark.w : mark.x;
19471
+ const dir2 = mark.negative ? -1 : 1;
19472
+ const side = (at, outward) => [
19473
+ at + (outward ? dir2 : -dir2) * GAP,
19474
+ (outward ? dir2 : -dir2) > 0 ? "start" : "end"
19475
+ ];
19476
+ const [x, anchor] = position2 === "ctr" ? [cx2, "middle"] : position2 === "inEnd" ? side(end, false) : position2 === "inBase" ? side(base, true) : side(end, true);
19477
+ draw(m, label, x, cy, anchor, out);
19478
+ continue;
19479
+ }
19480
+ const top = mark.negative ? mark.y + mark.h : mark.y;
19481
+ const bottom = mark.negative ? mark.y : mark.y + mark.h;
19482
+ const dir = mark.negative ? 1 : -1;
19483
+ const y = position2 === "ctr" ? cy : position2 === "inEnd" ? top - dir * (GAP + m.h / 2) : position2 === "inBase" ? bottom + dir * (GAP + m.h / 2) : top + dir * (GAP + m.h / 2);
19484
+ draw(m, label, cx2, y, "middle", out);
19485
+ }
19486
+ }
19487
+ function pointLabels(model, marks, out) {
19488
+ for (const mark of marks) {
19489
+ const label = mark.series.labels?.[mark.index];
19490
+ if (!label) continue;
19491
+ const m = measure(model, label);
19492
+ const reach = mark.radius + GAP;
19493
+ switch (model.type === "area" ? "ctr" : label.position ?? "r") {
19494
+ case "ctr":
19495
+ draw(m, label, mark.x, mark.y, "middle", out);
19496
+ break;
19497
+ case "t":
19498
+ draw(m, label, mark.x, mark.y - reach - m.h / 2, "middle", out);
19499
+ break;
19500
+ case "b":
19501
+ draw(m, label, mark.x, mark.y + reach + m.h / 2, "middle", out);
19502
+ break;
19503
+ case "l":
19504
+ draw(m, label, mark.x - reach, mark.y, "end", out);
19505
+ break;
19506
+ default:
19507
+ draw(m, label, mark.x + reach, mark.y, "start", out);
19508
+ }
19509
+ }
19510
+ }
19511
+ function sliceLabels(model, marks, out) {
19512
+ for (const mark of marks) {
19513
+ const label = mark.series.labels?.[mark.index];
19514
+ if (!label) continue;
19515
+ const m = measure(model, label);
19516
+ const mid = (mark.start + mark.end) / 2;
19517
+ const ux = Math.sin(mid);
19518
+ const uy = -Math.cos(mid);
19519
+ const place2 = (radius) => [
19520
+ mark.cx + radius * ux,
19521
+ mark.cy + radius * uy
19522
+ ];
19523
+ const position2 = model.type === "doughnut" ? "ctr" : label.position ?? "bestFit";
19524
+ let x;
19525
+ let y;
19526
+ if (position2 === "ctr") [x, y] = place2(mark.inner + (mark.outer - mark.inner) / 2);
19527
+ else if (position2 === "inEnd") {
19528
+ const extent = Math.abs(ux) * m.w / 2 + Math.abs(uy) * m.h / 2;
19529
+ [x, y] = place2(Math.max(0, mark.outer - GAP - extent));
19530
+ } else if (position2 === "outEnd") {
19531
+ const extent = Math.abs(ux) * m.w / 2 + Math.abs(uy) * m.h / 2;
19532
+ [x, y] = place2(mark.outer + GAP + extent);
19533
+ } else {
19534
+ const placed = placeBestFitLabel(
19535
+ {
19536
+ cx: mark.cx,
19537
+ cy: mark.cy,
19538
+ outerR: mark.outer,
19539
+ startAngle: mark.start - Math.PI / 2,
19540
+ endAngle: mark.end - Math.PI / 2
19541
+ },
19542
+ m.w,
19543
+ m.h
19544
+ );
19545
+ x = placed.x;
19546
+ y = placed.y;
19547
+ }
19548
+ draw(m, label, x, y, "middle", out);
19549
+ }
19550
+ }
19551
+ function hasOutsideLabels(model) {
19552
+ return model.series.some(
19553
+ (s) => s.labels?.some(
19554
+ (l) => l !== void 0 && ["bestFit", "outEnd"].includes(l.position ?? "bestFit")
19555
+ )
19556
+ );
19557
+ }
19558
+
19559
+ // chart/render/chart-svg-bars.ts
19560
+ function barLayout(model, frame2) {
19561
+ const count = Math.max(1, model.series.length);
19562
+ const geometry2 = clusteredBarGeometry(frame2.bandSize, count, chartBarSpacing(model));
19563
+ const barSize = geometry2.singleBarWidth;
19564
+ const offset = (si) => model.horizontal ? geometry2.clusterWidth / 2 - barSize - si * geometry2.step : -geometry2.clusterWidth / 2 + si * geometry2.step;
19565
+ return { barSize, offset };
19566
+ }
19567
+ function bars(model, frame2, out, values) {
19568
+ const stacked = model.grouping === "stacked" || model.grouping === "percentStacked";
19569
+ const { barSize, offset: barOffset } = barLayout(model, frame2);
19570
+ const base = frame2.value(0);
19571
+ const pos = new Array(model.categories.length).fill(0);
19572
+ const neg = new Array(model.categories.length).fill(0);
19573
+ const marks = [];
19574
+ model.series.forEach((s, si) => {
19575
+ values[si]?.forEach((v, i) => {
19576
+ if (v === null || i >= model.categories.length) return;
19577
+ let from = 0;
19578
+ let to = v;
19579
+ if (stacked) {
19580
+ const acc = v >= 0 ? pos : neg;
19581
+ from = acc[i] ?? 0;
19582
+ to = from + v;
19583
+ acc[i] = to;
19584
+ }
19585
+ const a2 = stacked ? frame2.value(from) : base;
19586
+ const b = frame2.value(to);
19587
+ const offset = barOffset(si);
19588
+ const center = frame2.band(i);
19589
+ const width = model.horizontal ? Math.abs(b - a2) : barSize;
19590
+ const height = model.horizontal ? barSize : Math.abs(b - a2);
19591
+ let color = s.pointColors?.[i] ?? s.color;
19592
+ const gradient = s.pointGradients?.[i] ?? (s.pointColors?.[i] === void 0 ? s.gradient : void 0);
19593
+ if (gradient && (gradient.path === "circle" || gradient.path === "shape")) {
19594
+ const baseId = color.match(/^url\(#(.+)\)$/)?.[1];
19595
+ if (baseId) {
19596
+ const id = baseId.replace(/(-s\d+(?:-p\d+)?)$/, `-mark${i}$1`);
19597
+ const def = buildChartGradientDef(id, gradient, {
19598
+ width: Number(n(width)),
19599
+ height: Number(n(height)),
19600
+ shape: "rect"
19601
+ });
19602
+ out.push(`<defs>${chartGradientMarkup(def)}</defs>`);
19603
+ color = `url(#${id})`;
19604
+ }
19605
+ }
19606
+ out.push(`<g data-chart-series="${si}" data-chart-point="${i}">`);
19607
+ const box = model.horizontal ? { x: Math.min(a2, b), y: center + offset, w: Math.abs(b - a2), h: barSize } : { x: center + offset, y: Math.min(a2, b), w: barSize, h: Math.abs(b - a2) };
19608
+ out.push(rect2(box.x, box.y, box.w, box.h, color, s.shadowFilter));
19609
+ out.push("</g>");
19610
+ marks.push({ series: s, index: i, ...box, negative: v < 0 });
19611
+ });
19612
+ });
19613
+ barLabels(model, marks, out);
18659
19614
  }
18660
19615
 
18661
19616
  // chart/render/chart-svg-analysis.ts
@@ -18744,6 +19699,60 @@ function scatterAnalysis(model, px3, py, out) {
18744
19699
  });
18745
19700
  }
18746
19701
 
19702
+ // chart/render/chart-svg-markers.ts
19703
+ function chartMarkerRadius(series, index, defaultRadius = 3) {
19704
+ const marker = { ...series.marker, ...series.pointMarkers?.[index] };
19705
+ if (marker.symbol === "none") return 0;
19706
+ const radius = markerRadius(marker.size, defaultRadius);
19707
+ return marker.symbol === "dot" ? Math.max(radius * 0.6, 1) : radius;
19708
+ }
19709
+ function chartSeriesMarkerSvg(series, index, cx2, cy, defaultRadius = 3) {
19710
+ const marker = { ...series.marker, ...series.pointMarkers?.[index] };
19711
+ const primitive = buildMarkerPrimitive({
19712
+ ...marker,
19713
+ symbol: marker.symbol,
19714
+ size: marker.size,
19715
+ cx: cx2,
19716
+ cy,
19717
+ fill: marker.fill ?? series.pointColors?.[index] ?? series.color,
19718
+ defaultRadius
19719
+ });
19720
+ if (!primitive) return "";
19721
+ let geometry2;
19722
+ switch (primitive.kind) {
19723
+ case "circle":
19724
+ geometry2 = `cx="${n(primitive.cx)}" cy="${n(primitive.cy)}" r="${n(primitive.r)}"`;
19725
+ break;
19726
+ case "rect":
19727
+ geometry2 = `x="${n(primitive.x)}" y="${n(primitive.y)}" width="${n(primitive.w)}" height="${n(primitive.h)}"`;
19728
+ break;
19729
+ case "path":
19730
+ geometry2 = `d="${esc(primitive.d)}"`;
19731
+ break;
19732
+ case "polygon":
19733
+ geometry2 = `points="${esc(primitive.points)}"`;
19734
+ break;
19735
+ }
19736
+ const outline2 = primitive.stroke ? ` stroke="${esc(primitive.stroke)}" stroke-width="${n(primitive.strokeWidth ?? 1)}"` : "";
19737
+ const filter = series.shadowFilter ? ` filter="${esc(series.shadowFilter)}"` : "";
19738
+ return `<${primitive.kind} ${geometry2} fill="${esc(primitive.fill)}"${outline2}${filter}/>`;
19739
+ }
19740
+
19741
+ // chart/line-dash.ts
19742
+ function chartLineDashArray(style, width) {
19743
+ if (!style || style === "solid") {
19744
+ return void 0;
19745
+ }
19746
+ const unit = Math.max(width, 1);
19747
+ if (style === "dot" || style === "sysDot") {
19748
+ return `${unit} ${unit * 2}`;
19749
+ }
19750
+ if (style === "lgDash") {
19751
+ return `${unit * 6} ${unit * 3}`;
19752
+ }
19753
+ return `${unit * 3} ${unit * 2}`;
19754
+ }
19755
+
18747
19756
  // chart/render/chart-scale.ts
18748
19757
  var clean = (n2) => Number(n2.toPrecision(12));
18749
19758
  function* units(raw) {
@@ -18754,14 +19763,14 @@ function* units(raw) {
18754
19763
  exp++;
18755
19764
  }
18756
19765
  }
18757
- function niceScale(dataMin, dataMax, options = {}) {
18758
- const maxIntervals = Math.max(1, options.maxIntervals ?? 10);
19766
+ function niceScale(dataMin, dataMax, options2 = {}) {
19767
+ const maxIntervals = Math.max(1, options2.maxIntervals ?? 10);
18759
19768
  let lo = Number.isFinite(dataMin) ? dataMin : 0;
18760
19769
  let hi = Number.isFinite(dataMax) ? dataMax : 0;
18761
19770
  if (lo > hi) [lo, hi] = [hi, lo];
18762
19771
  if (lo === hi) {
18763
19772
  if (lo === 0) hi = 1;
18764
- else if (options.noZero) {
19773
+ else if (options2.noZero) {
18765
19774
  const pad = Math.abs(lo) * 0.1 || 1;
18766
19775
  lo -= pad;
18767
19776
  hi += pad;
@@ -18770,7 +19779,7 @@ function niceScale(dataMin, dataMax, options = {}) {
18770
19779
  }
18771
19780
  let fixedLo = false;
18772
19781
  let fixedHi = false;
18773
- if (!options.noZero) {
19782
+ if (!options2.noZero) {
18774
19783
  if (lo >= 0 && hi - lo >= hi / 6) {
18775
19784
  lo = 0;
18776
19785
  fixedLo = true;
@@ -18801,153 +19810,240 @@ var PERCENT_SCALE = {
18801
19810
  ticks: [0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1]
18802
19811
  };
18803
19812
  function formatAxisValue(value, percent = false) {
18804
- if (percent) return `${clean(value * 100)}%`;
18805
- const v = clean(value);
18806
- if (Math.abs(v) >= 1e15 || v !== 0 && Math.abs(v) < 1e-6)
18807
- return v.toExponential(2).replace("e+", "E+").replace("e-", "E-");
18808
- const [int2 = "0", frac] = String(Math.abs(v)).split(".");
18809
- const grouped = int2.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
18810
- return `${v < 0 ? "-" : ""}${grouped}${frac ? `.${frac}` : ""}`;
18811
- }
18812
-
18813
- // chart/render/theme-palette.ts
18814
- var THEME_SLOTS = [
18815
- "lt1",
18816
- "dk1",
18817
- "lt2",
18818
- "dk2",
18819
- "accent1",
18820
- "accent2",
18821
- "accent3",
18822
- "accent4",
18823
- "accent5",
18824
- "accent6",
18825
- "hlink",
18826
- "folHlink"
18827
- ];
18828
- var DEFAULT_THEME_COLORS = [
18829
- "FFFFFF",
18830
- "000000",
18831
- "E7E6E6",
18832
- "44546A",
18833
- "4472C4",
18834
- "ED7D31",
18835
- "A5A5A5",
18836
- "FFC000",
18837
- "5B9BD5",
18838
- "70AD47",
18839
- "0563C1",
18840
- "954F72"
18841
- ];
18842
- function themeColor(theme, index) {
18843
- const hex = theme.colors[index] ?? DEFAULT_THEME_COLORS[index];
18844
- return hex && parseArgbHex(hex) ? hex.replace(/^#/, "") : void 0;
18845
- }
18846
-
18847
- // chart/render/chart-colors.ts
18848
- function chartColorScheme(theme) {
18849
- const slots = Object.fromEntries(
18850
- THEME_SLOTS.map((slot2, index) => [slot2, `#${themeColor(theme, index) ?? "000000"}`])
18851
- );
18852
- return {
18853
- ...slots,
18854
- bg1: slots.lt1,
18855
- tx1: slots.dk1,
18856
- bg2: slots.lt2,
18857
- tx2: slots.dk2
18858
- };
18859
- }
18860
- function autoSeriesColor(theme, index) {
18861
- const i = Math.max(0, Math.floor(index));
18862
- return chartPaletteSeriesColor(findChartColorPalette(10), i, i + 1, chartColorScheme(theme));
18863
- }
18864
-
18865
- // chart/text-inheritance.ts
18866
- var TEXT_KEYS = [
18867
- "fontSize",
18868
- "bold",
18869
- "italic",
18870
- "underline",
18871
- "typeface",
18872
- "textColor",
18873
- "fontRef"
18874
- ];
18875
- var TEXT_PARTS = [
18876
- "title",
18877
- "axisTitle",
18878
- "categoryAxis",
18879
- "valueAxis",
18880
- "legend",
18881
- "dataLabel"
18882
- ];
18883
- function inheritChartText(part, entry2, builtIn, root) {
18884
- if (!root || !TEXT_PARTS.includes(part)) return entry2;
18885
- const out = { ...entry2 };
18886
- for (const key of TEXT_KEYS) {
18887
- delete out[key];
18888
- const value = root[key] ?? builtIn?.[key];
18889
- if (value !== void 0) Object.assign(out, { [key]: value });
19813
+ if (percent) return `${clean(value * 100)}%`;
19814
+ const v = clean(value);
19815
+ if (Math.abs(v) >= 1e15 || v !== 0 && Math.abs(v) < 1e-6)
19816
+ return v.toExponential(2).replace("e+", "E+").replace("e-", "E-");
19817
+ const [int2 = "0", frac] = String(Math.abs(v)).split(".");
19818
+ const grouped = int2.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
19819
+ return `${v < 0 ? "-" : ""}${grouped}${frac ? `.${frac}` : ""}`;
19820
+ }
19821
+
19822
+ // chart/render/chart-svg-axes.ts
19823
+ function axisTickText(value, axis, percent = false) {
19824
+ return formatChartNumber(value, axis?.source.numberFormat?.formatCode) ?? formatAxisValue(value, percent);
19825
+ }
19826
+ function axisLine(model, axis, part, x1, y1, x2, y2) {
19827
+ if (axis?.source.deleted) return "";
19828
+ return styledAxisLine(x1, y1, x2, y2, axis?.line, chartStroke(model, part));
19829
+ }
19830
+ function styledAxisLine(x1, y1, x2, y2, paint2, fallback) {
19831
+ const color = paint2?.color ?? fallback.color;
19832
+ const width = paint2?.width ?? fallback.width;
19833
+ if (color === "none" || width === 0) return "";
19834
+ const dash = chartLineDashArray(paint2?.dash, width);
19835
+ return line2(x1, y1, x2, y2, esc(color), width).replace(
19836
+ "/>",
19837
+ dash ? ` stroke-dasharray="${dash}"/>` : "/>"
19838
+ );
19839
+ }
19840
+ function axisGridlines(model, axis, ticks, position2, plot, vertical) {
19841
+ const draw2 = (values, paint2, minor2) => {
19842
+ const fallback = chartStroke(model, minor2 ? "gridlineMinor" : "gridlineMajor");
19843
+ return values.map((value) => {
19844
+ const p = position2(value);
19845
+ return vertical ? styledAxisLine(p, plot.y, p, plot.y + plot.h, paint2, fallback) : styledAxisLine(plot.x, p, plot.x + plot.w, p, paint2, fallback);
19846
+ }).join("");
19847
+ };
19848
+ const major = !axis || axis.source.majorGridlines ? draw2(ticks, axis?.majorGrid, false) : "";
19849
+ const minor = axis?.source.minorGridlines ? draw2(axis.minorTicks, axis.minorGrid, true) : "";
19850
+ return major + minor;
19851
+ }
19852
+
19853
+ // chart/axis-range.ts
19854
+ function computeLogValueRange(series, logBase) {
19855
+ const allValues = series.flatMap((item) => item.values).filter((value) => value !== null && Number.isFinite(value) && value > 0);
19856
+ if (allValues.length === 0) {
19857
+ return { min: 1, max: logBase, span: 1, logScale: true, logBase };
19858
+ }
19859
+ const dataMin = Math.min(...allValues);
19860
+ const dataMax = Math.max(...allValues);
19861
+ const logMin = Math.floor(Math.log(dataMin) / Math.log(logBase));
19862
+ const logMax = Math.ceil(Math.log(dataMax) / Math.log(logBase));
19863
+ const min = logBase ** logMin;
19864
+ const max = logBase ** Math.max(logMax, logMin + 1);
19865
+ return {
19866
+ min,
19867
+ max,
19868
+ span: Math.max(Math.log(max) / Math.log(logBase) - Math.log(min) / Math.log(logBase), 1),
19869
+ logScale: true,
19870
+ logBase
19871
+ };
19872
+ }
19873
+ function withAxisBounds(automatic, axis, logBase) {
19874
+ const validMin = typeof axis?.min === "number" && Number.isFinite(axis.min) && (!logBase || axis.min > 0) ? axis.min : void 0;
19875
+ const validMax = typeof axis?.max === "number" && Number.isFinite(axis.max) && (!logBase || axis.max > 0) ? axis.max : void 0;
19876
+ const min = validMin ?? automatic.min;
19877
+ let max = validMax ?? automatic.max;
19878
+ const majorUnit = validMin === void 0 && validMax === void 0 ? automatic.majorUnit : void 0;
19879
+ if (max <= min) {
19880
+ max = logBase ? min * logBase : min + 1;
18890
19881
  }
18891
- if (part === "title" && root.fontSize !== void 0) out.fontSize = root.fontSize * 1.2;
18892
- if (root.textEffectsXml !== void 0) out.textEffectsXml = root.textEffectsXml;
18893
- return out;
19882
+ const span = logBase ? Math.log(max) / Math.log(logBase) - Math.log(min) / Math.log(logBase) : max - min;
19883
+ return {
19884
+ min,
19885
+ max,
19886
+ span: Math.max(span, Number.EPSILON),
19887
+ ...majorUnit !== void 0 ? { majorUnit } : {},
19888
+ ...logBase ? { logScale: true, logBase } : {},
19889
+ ...axis?.orientation === "maxMin" ? { reverseOrder: true } : {}
19890
+ };
18894
19891
  }
18895
19892
 
18896
- // chart/render/chart-appearance.ts
18897
- var chartPointsToPixels = (points) => points * EMU_PER_POINT / EMU_PER_PIXEL;
18898
- function typeface(entry2, theme) {
18899
- const name = entry2.typeface;
18900
- if (name?.startsWith("+mj-")) return theme.majorFont;
18901
- if (name?.startsWith("+mn-")) return theme.minorFont;
18902
- return name ?? (entry2.fontRef?.index === "major" ? theme.majorFont : entry2.fontRef?.index === "minor" ? theme.minorFont : void 0);
19893
+ // chart/axis-ticks.ts
19894
+ var LOG_EXPONENT_TOLERANCE = 1e-12;
19895
+ function generateLogTicks(range) {
19896
+ if (!range.logScale || !range.logBase) {
19897
+ return [];
19898
+ }
19899
+ const base = range.logBase;
19900
+ const logMin = Math.log(range.min) / Math.log(base);
19901
+ const logMax = Math.log(range.max) / Math.log(base);
19902
+ const firstExponent = Math.ceil(logMin - LOG_EXPONENT_TOLERANCE);
19903
+ const lastExponent = Math.floor(logMax + LOG_EXPONENT_TOLERANCE);
19904
+ if (lastExponent < firstExponent) {
19905
+ return range.min === range.max ? [range.min] : [range.min, range.max];
19906
+ }
19907
+ return Array.from(
19908
+ { length: lastExponent - firstExponent + 1 },
19909
+ (_unused, index) => base ** (firstExponent + index)
19910
+ );
18903
19911
  }
18904
- function chartAppearance(chart, theme) {
18905
- const defaults = builtInChartTextStyle(effectiveBuiltInChartStyle(chart.formatting));
18906
- const entries = {};
18907
- for (const part of CHART_STYLE_PARTS) {
18908
- const base = chart.styleDefinition?.entries[part];
18909
- const direct = chart.formatting?.entries[part];
18910
- if (!defaults[part] && !base && !direct) continue;
18911
- const entry2 = {
18912
- ...inheritChartText(
18913
- part,
18914
- { ...defaults[part], ...base, sourceXml: base?.sourceXml ?? "" },
18915
- defaults[part],
18916
- chart.formatting?.textDefaults
18917
- ),
18918
- ...direct,
18919
- sourceXml: direct?.sourceXml ?? base?.sourceXml ?? ""
18920
- };
18921
- if (base?.line || direct?.line) entry2.line = { ...base?.line, ...direct?.line };
18922
- entries[part] = entry2;
19912
+ function generateIntervalTicks(range, unit) {
19913
+ if (!Number.isFinite(unit) || unit <= 0 || range.logScale) {
19914
+ return [];
18923
19915
  }
18924
- const scheme = chartColorScheme(theme);
18925
- const resolve = (color) => resolveDrawingColor(
18926
- color,
18927
- { scheme: (name) => scheme[name] },
18928
- { hslRounding: "halfDown", transformOrder: "document" }
19916
+ const tolerance = Math.max(1, Math.abs(range.min), Math.abs(range.max)) * 1e-12;
19917
+ const first3 = Math.ceil((range.min - tolerance) / unit);
19918
+ const last = Math.floor((range.max + tolerance) / unit);
19919
+ const count = Math.min(Math.max(last - first3 + 1, 0), 2e3);
19920
+ return Array.from({ length: count }, (_, index) => (first3 + index) * unit);
19921
+ }
19922
+ function generateAxisTicks(range, axis, defaultIntervals) {
19923
+ if (range.logScale && range.logBase) {
19924
+ return generateLogTicks(range);
19925
+ }
19926
+ const explicit = generateIntervalTicks(range, axis?.majorUnit ?? 0);
19927
+ if (explicit.length > 0) {
19928
+ return explicit;
19929
+ }
19930
+ const automatic = generateIntervalTicks(range, range.majorUnit ?? 0);
19931
+ if (automatic.length > 0) {
19932
+ return automatic;
19933
+ }
19934
+ return Array.from(
19935
+ { length: defaultIntervals + 1 },
19936
+ (_, index) => range.min + range.span / defaultIntervals * index
18929
19937
  );
18930
- const out = resolveChartStyleDefinition(
18931
- { entries},
18932
- (color) => drawingColorCss(resolve(color))
18933
- ) ?? {};
18934
- for (const part of CHART_STYLE_PARTS) {
18935
- const entry2 = entries[part];
18936
- if (!entry2) continue;
18937
- const family = typeface(entry2, theme);
18938
- const shadow = resolveDrawingShadowXml(entry2.textEffectsXml, {
18939
- scheme: (name) => scheme[name]
18940
- });
18941
- if (shadow) (out[part] ??= {}).textShadow = shadow;
18942
- if (family) (out[part] ??= {}).typeface = family;
18943
- if (entry2.axisVisible !== void 0) (out[part] ??= {}).axisVisible = entry2.axisVisible;
18944
- if (entry2.labelsVisible !== void 0) (out[part] ??= {}).labelsVisible = entry2.labelsVisible;
18945
- if (entry2.line?.widthEmu === 0) (out[part] ??= {}).lineWidth = 0;
18946
- if (entry2.fill?.kind === "gradient") {
18947
- (out[part] ??= {}).gradient = resolveChartGradient(entry2.fill, resolve);
18948
- }
19938
+ }
19939
+ function generateMinorAxisTicks(range, axis) {
19940
+ const minor = generateIntervalTicks(range, axis?.minorUnit ?? 0);
19941
+ if (minor.length === 0) {
19942
+ return [];
18949
19943
  }
18950
- return out;
19944
+ const majorUnit = axis?.majorUnit;
19945
+ if (!majorUnit || !Number.isFinite(majorUnit) || majorUnit <= 0) {
19946
+ return minor;
19947
+ }
19948
+ const tolerance = Math.max(1, Math.abs(range.min), Math.abs(range.max)) * 1e-10;
19949
+ return minor.filter(
19950
+ (value) => Math.abs(value / majorUnit - Math.round(value / majorUnit)) > tolerance
19951
+ );
19952
+ }
19953
+
19954
+ // chart/render/chart-view-axes.ts
19955
+ function chartAxisRatio(value, scale, axis) {
19956
+ const range = axis?.range;
19957
+ const ratio = range?.logScale ? Math.log(Math.max(value, range.min) / range.min) / Math.log(range.max / range.min) : (value - scale.min) / (scale.max - scale.min || 1);
19958
+ return range?.reverseOrder ? 1 - ratio : ratio;
19959
+ }
19960
+ function chartAxisLabels(axis) {
19961
+ return axis?.source.deleted !== true && axis?.source.tickLabelPosition !== "none";
19962
+ }
19963
+ function options(axis) {
19964
+ return {
19965
+ ...axis.scaling,
19966
+ ...axis.scaling.logBase === void 0 ? {} : { logScale: true },
19967
+ ...axis.majorUnit === void 0 ? {} : { majorUnit: axis.majorUnit },
19968
+ ...axis.minorUnit === void 0 ? {} : { minorUnit: axis.minorUnit }
19969
+ };
19970
+ }
19971
+ function applyChartAxes(model, chart, color) {
19972
+ if (!chart.axes?.length) return;
19973
+ const axes = chart.axes;
19974
+ const linked = axes.filter((axis) => axis.id !== void 0 && chart.axisIds?.includes(axis.id));
19975
+ const candidates = linked.length ? linked : axes;
19976
+ const xy = model.type === "scatter" || model.type === "bubble";
19977
+ const value = candidates.find((axis) => axis.kind === "val" && !["b", "t"].includes(axis.position ?? "")) ?? candidates.find((axis) => axis.kind === "val");
19978
+ const category = candidates.find(
19979
+ (axis) => xy ? axis.kind === "val" && axis !== value : axis.kind === "cat" || axis.kind === "date"
19980
+ );
19981
+ const secondary = axes.find((axis) => axis.kind === "val" && axis !== value && axis !== category);
19982
+ const paint2 = (shape2) => {
19983
+ const ln = shape2?.line;
19984
+ const fill = ln?.fill;
19985
+ const resolved = fill?.kind === "none" ? "none" : color(fill?.kind === "solid" ? fill.color : void 0);
19986
+ return {
19987
+ ...resolved === void 0 ? {} : { color: resolved },
19988
+ ...ln?.widthEmu === void 0 ? {} : { width: ln.widthEmu / EMU_PER_PIXEL },
19989
+ ...ln?.dash === void 0 ? {} : { dash: ln.dash }
19990
+ };
19991
+ };
19992
+ const bind = (axis, scale, values) => {
19993
+ const opts = options(axis);
19994
+ const automatic = opts.logScale ? computeLogValueRange(
19995
+ [{ values: values ?? [] }],
19996
+ opts.logBase && Number.isFinite(opts.logBase) && opts.logBase > 1 ? opts.logBase : 10
19997
+ ) : {
19998
+ min: scale?.min ?? 0,
19999
+ max: scale?.max ?? 1,
20000
+ span: (scale?.max ?? 1) - (scale?.min ?? 0),
20001
+ ...scale ? { majorUnit: scale.majorUnit } : {}
20002
+ };
20003
+ const logBase = automatic.logBase;
20004
+ const range = withAxisBounds(automatic, opts, logBase);
20005
+ if (scale) {
20006
+ scale.min = range.min;
20007
+ scale.max = range.max;
20008
+ scale.ticks = generateAxisTicks(range, opts, 5);
20009
+ }
20010
+ return {
20011
+ source: axis,
20012
+ range,
20013
+ minorTicks: generateMinorAxisTicks(range, opts),
20014
+ line: paint2(axis.spPr),
20015
+ majorGrid: paint2(axis.majorGridlinesSpPr),
20016
+ minorGrid: paint2(axis.minorGridlinesSpPr)
20017
+ };
20018
+ };
20019
+ const out = {};
20020
+ if (value)
20021
+ out.value = bind(
20022
+ value,
20023
+ model.valueAxis,
20024
+ [
20025
+ ...model.series,
20026
+ ...model.extraGroups?.filter((g) => !g.secondary).flatMap((g) => g.series) ?? []
20027
+ ].flatMap((s) => s.values)
20028
+ );
20029
+ if (category)
20030
+ out.category = bind(
20031
+ category,
20032
+ model.xAxis ?? {
20033
+ min: 0,
20034
+ max: Math.max(1, model.categories.length - 1),
20035
+ majorUnit: 1,
20036
+ ticks: []
20037
+ },
20038
+ model.series.flatMap((s) => s.xValues ?? [])
20039
+ );
20040
+ if (secondary)
20041
+ out.secondary = bind(
20042
+ secondary,
20043
+ model.secondaryAxis,
20044
+ model.extraGroups?.filter((g) => g.secondary).flatMap((g) => g.series.flatMap((s) => s.values))
20045
+ );
20046
+ model.axes = out;
18951
20047
  }
18952
20048
 
18953
20049
  // chart/render/chart-view-analysis.ts
@@ -18999,15 +20095,15 @@ function seriesName(series, index, evaluateRef) {
18999
20095
  const fromRef = resolveRef(series.nameRef, evaluateRef)?.map(toText).filter((t) => t !== "").join(" ");
19000
20096
  return fromRef || series.name || `Series${index + 1}`;
19001
20097
  }
19002
- function seriesContext(chart, theme, options) {
20098
+ function seriesContext(chart, theme, options2) {
19003
20099
  const scheme = chartColorScheme(theme);
19004
20100
  const resolver = { scheme: (name) => scheme[name] };
19005
20101
  return {
19006
20102
  theme,
19007
20103
  scheme,
19008
20104
  palette: chart.colorPalette === void 0 ? void 0 : findChartColorPalette(chart.colorPalette),
19009
- evaluateRef: options.evaluateRef ?? (() => []),
19010
- seriesColor: options.seriesColor,
20105
+ evaluateRef: options2.evaluateRef ?? (() => []),
20106
+ seriesColor: options2.seriesColor,
19011
20107
  drawingColor: (color) => color && drawingColorCss(resolveDrawingColor(color, resolver, { transformOrder: "document" })),
19012
20108
  gradient: (fill) => fill?.kind === "gradient" ? resolveChartGradient(
19013
20109
  fill,
@@ -19033,7 +20129,11 @@ function seriesView(ctx, s, index, total, categoriesOf) {
19033
20129
  })
19034
20130
  );
19035
20131
  if (Object.keys(points).length) view.pointGradients = points;
19036
- Object.assign(view, analysisView(s, color, ctx.drawingColor));
20132
+ Object.assign(
20133
+ view,
20134
+ analysisView(s, color, ctx.drawingColor),
20135
+ seriesMarkerViews(s, ctx.drawingColor)
20136
+ );
19037
20137
  return view;
19038
20138
  }
19039
20139
 
@@ -19206,12 +20306,70 @@ function chartTitleText(chart, theme) {
19206
20306
  };
19207
20307
  }
19208
20308
 
20309
+ // chart/render/chart-view-labels.ts
20310
+ function labelsOf(source, view, categories, numberFormat2) {
20311
+ const { chart, series, points } = source;
20312
+ if ((series?.deleted ?? chart?.deleted) === true) return void 0;
20313
+ const percentBase = view.values.reduce(
20314
+ (sum, v) => sum + (v === null ? 0 : Math.abs(v)),
20315
+ 0
20316
+ );
20317
+ const out = [];
20318
+ let any = false;
20319
+ view.values.forEach((value, i) => {
20320
+ const point = points?.[i];
20321
+ if (value === null || point?.deleted === true) return;
20322
+ const position2 = point?.position ?? series?.position ?? chart?.position;
20323
+ const x = view.xValues?.[i];
20324
+ const category = x === void 0 || x === null ? categories[i] : formatAxisValue(x);
20325
+ let built;
20326
+ if (point?.text !== void 0) built = { text: point.text };
20327
+ else {
20328
+ const flags = resolveDataLabelFlags({
20329
+ ...point ? { point } : {},
20330
+ ...series ? { series } : {},
20331
+ ...chart ? { chart } : {}
20332
+ });
20333
+ built = composeDataLabelText({
20334
+ flags,
20335
+ seriesName: view.name,
20336
+ category,
20337
+ value,
20338
+ numberFormat: point?.numberFormat ?? series?.numberFormat ?? chart?.numberFormat ?? numberFormat2,
20339
+ percentBase,
20340
+ bubbleSize: view.sizes?.[i] ?? void 0,
20341
+ formatValue: (v) => formatAxisValue(v),
20342
+ formatBubbleSize: (size) => formatAxisValue(size)
20343
+ });
20344
+ }
20345
+ if (!built) return;
20346
+ any = true;
20347
+ out[i] = {
20348
+ text: built.text,
20349
+ ...position2 ? { position: position2 } : {},
20350
+ ...built.color ? { color: built.color } : {}
20351
+ };
20352
+ });
20353
+ return any ? out : void 0;
20354
+ }
20355
+ function applyDataLabels(model, sources, extra) {
20356
+ const apply = (source, view) => {
20357
+ if (!source?.dataLabels) return;
20358
+ const labels = labelsOf(source.dataLabels, view, model.categories, source.numberFormat);
20359
+ if (labels) view.labels = labels;
20360
+ };
20361
+ model.series.forEach((view, i) => apply(sources[i], view));
20362
+ model.extraGroups?.forEach(
20363
+ (group2, g) => group2.series.forEach((view, i) => apply(extra[g]?.series[i], view))
20364
+ );
20365
+ }
20366
+
19209
20367
  // chart/render/chart-view-ex.ts
19210
20368
  function groupsAxis(groups, categories) {
19211
20369
  let min = Infinity;
19212
20370
  let max = -Infinity;
19213
- for (const group of groups) {
19214
- const extent = valueExtent(group.type, group.grouping, group.series, categories);
20371
+ for (const group2 of groups) {
20372
+ const extent = valueExtent(group2.type, group2.grouping, group2.series, categories);
19215
20373
  min = Math.min(min, extent.min);
19216
20374
  max = Math.max(max, extent.max);
19217
20375
  }
@@ -19220,17 +20378,17 @@ function groupsAxis(groups, categories) {
19220
20378
  function chartExtraView(chart, model, ctx, total, categoriesOf) {
19221
20379
  let index = chart.series.length;
19222
20380
  const groups = [];
19223
- for (const group of chart.extraGroups ?? []) {
19224
- const series = group.series.map((s) => seriesView(ctx, s, index++, total, categoriesOf));
20381
+ for (const group2 of chart.extraGroups ?? []) {
20382
+ const series = group2.series.map((s) => seriesView(ctx, s, index++, total, categoriesOf));
19225
20383
  const view = {
19226
- type: group.chartType,
19227
- grouping: group.grouping ?? (group.chartType === "column" ? "clustered" : "standard"),
20384
+ type: group2.chartType,
20385
+ grouping: group2.grouping ?? (group2.chartType === "column" ? "clustered" : "standard"),
19228
20386
  series,
19229
- secondary: group.secondary
20387
+ secondary: group2.secondary
19230
20388
  };
19231
- if (group.chartType === "stock") view.stock = stockView(group.stock, ctx);
19232
- if (group.barGapWidth !== void 0) view.barGapWidth = group.barGapWidth;
19233
- if (group.barOverlap !== void 0) view.barOverlap = group.barOverlap;
20389
+ if (group2.chartType === "stock") view.stock = stockView(group2.stock, ctx);
20390
+ if (group2.barGapWidth !== void 0) view.barGapWidth = group2.barGapWidth;
20391
+ if (group2.barOverlap !== void 0) view.barOverlap = group2.barOverlap;
19234
20392
  groups.push(view);
19235
20393
  }
19236
20394
  if (!groups.length) return;
@@ -19247,8 +20405,8 @@ function chartExtraAxes(model) {
19247
20405
  const own2 = valueExtent(model.type, model.grouping, model.series, count);
19248
20406
  let min = own2.min;
19249
20407
  let max = own2.max;
19250
- for (const group of shared) {
19251
- const extent = valueExtent(group.type, group.grouping, group.series, count);
20408
+ for (const group2 of shared) {
20409
+ const extent = valueExtent(group2.type, group2.grouping, group2.series, count);
19252
20410
  min = Math.min(min, extent.min);
19253
20411
  max = Math.max(max, extent.max);
19254
20412
  }
@@ -19275,11 +20433,11 @@ function histogramView(chart, model) {
19275
20433
  const first3 = model.series[0];
19276
20434
  if (!first3) return;
19277
20435
  const raw = first3.values.map((v) => v ?? Number.NaN);
19278
- const options = chart.histogram ?? {};
19279
- const bins = options.aggregateByCategory ? aggregateByCategory(
20436
+ const options2 = chart.histogram ?? {};
20437
+ const bins = options2.aggregateByCategory ? aggregateByCategory(
19280
20438
  first3.values.map((v) => v ?? 0),
19281
20439
  model.categories
19282
- ) : computeHistogramBins(raw, options, formatAxisValue);
20440
+ ) : computeHistogramBins(raw, options2, formatAxisValue);
19283
20441
  model.categories = bins.map((bin) => bin.label);
19284
20442
  first3.values = bins.map((bin) => bin.value);
19285
20443
  model.barGapWidth = 0;
@@ -19303,11 +20461,11 @@ var SUPPORTED = /* @__PURE__ */ new Set([
19303
20461
  "treemap",
19304
20462
  "sunburst"
19305
20463
  ]);
19306
- function chartSummaryView(chart, theme, options = {}) {
20464
+ function chartSummaryView(chart, theme, options2 = {}) {
19307
20465
  const type = chart.chartType;
19308
20466
  const radial = type === "pie" || type === "doughnut";
19309
20467
  const byPoint = radial || type === "treemap" || type === "sunburst";
19310
- const ctx = seriesContext(chart, theme, options);
20468
+ const ctx = seriesContext(chart, theme, options2);
19311
20469
  const { palette, scheme, drawingColor } = ctx;
19312
20470
  const grouping = chart.grouping ?? (type === "bar" || type === "column" ? "clustered" : "standard");
19313
20471
  const rawCategories = [];
@@ -19391,128 +20549,23 @@ function chartSummaryView(chart, theme, options = {}) {
19391
20549
  chartExtraView(chart, model, ctx, total, collect);
19392
20550
  if (type === "waterfall") waterfallView(chart, model, ctx);
19393
20551
  else if (!byPoint) model.valueAxis = valueAxis(model);
20552
+ applyDataLabels(model, chart.series, extra);
19394
20553
  chartExtraAxes(model);
20554
+ applyChartAxes(model, chart, ctx.drawingColor);
19395
20555
  return model;
19396
20556
  }
19397
20557
 
19398
- // text/css-font-family.ts
19399
- var FALLBACKS = {
19400
- calibri: '"Calibri", "Carlito", "Segoe UI", Arial, sans-serif',
19401
- "calibri light": '"Calibri Light", "Calibri", "Carlito", "Segoe UI", Arial, sans-serif',
19402
- cambria: '"Cambria", "Caladea", Georgia, serif',
19403
- arial: 'Arial, "Liberation Sans", Helvetica, sans-serif',
19404
- "times new roman": '"Times New Roman", "Liberation Serif", Times, serif',
19405
- "courier new": '"Courier New", "Liberation Mono", monospace',
19406
- aptos: '"Aptos", "Calibri", "Carlito", "Segoe UI", sans-serif'
19407
- };
19408
- function cssFontFamily(name) {
19409
- const known = FALLBACKS[name.toLowerCase()];
19410
- if (known) return known;
19411
- const quoted = `"${name.replace(/["\\]/g, "")}"`;
19412
- return `${quoted}, "Calibri", "Carlito", "Segoe UI", sans-serif`;
19413
- }
19414
-
19415
- // chart/render/chart-svg-appearance.ts
19416
- var nextPaintId = 0;
19417
- function chartGradientPaint(model, width = 1024, height = 768) {
19418
- const prefix2 = `xlsx-chart-${++nextPaintId}`;
19419
- const appearance = { ...model.appearance };
19420
- const defs = [];
19421
- const shadowPaint = (shadow, suffix) => {
19422
- const id = `${prefix2}-${suffix}`;
19423
- const pad = Math.max(4, shadow.blur * 3 + Math.abs(shadow.dx) + Math.abs(shadow.dy));
19424
- defs.push(
19425
- `<filter id="${id}" filterUnits="userSpaceOnUse" x="${n(-pad)}" y="${n(-pad)}" width="${n(width + pad * 2)}" height="${n(height + pad * 2)}" color-interpolation-filters="sRGB">${svgDropShadowElement(shadow, { number: n, color: (value) => esc(value) })}</filter>`
19426
- );
19427
- return `url(#${id})`;
19428
- };
19429
- for (const [part, entry2] of Object.entries(appearance)) {
19430
- if (entry2?.textShadow)
19431
- appearance[part] = {
19432
- ...entry2,
19433
- textShadowFilter: shadowPaint(entry2.textShadow, `${part}-text-shadow`)
19434
- };
19435
- }
19436
- const paint2 = (gradient, suffix, bounds) => {
19437
- const def = buildChartGradientDef(`${prefix2}-${suffix}`, gradient, bounds);
19438
- defs.push(chartGradientMarkup(def));
19439
- return `url(#${def.id})`;
19440
- };
19441
- for (const part of ["chartArea", "plotArea"]) {
19442
- const entry2 = appearance[part];
19443
- if (!entry2?.gradient) continue;
19444
- if (part === "plotArea" && ["circle", "shape"].includes(entry2.gradient.path ?? "")) continue;
19445
- appearance[part] = {
19446
- ...entry2,
19447
- fillColor: paint2(entry2.gradient, part, { width, height, shape: "rect" })
19448
- };
19449
- }
19450
- const series = model.series.map((source, index) => {
19451
- const view = { ...source };
19452
- if (source.shadow) view.shadowFilter = shadowPaint(source.shadow, `s${index}-shadow`);
19453
- const bounds = model.type === "bar" || model.type === "column" ? { width: 1, height: 1, shape: "rect" } : void 0;
19454
- if (source.gradient) view.color = paint2(source.gradient, `s${index}`, bounds);
19455
- if (source.pointGradients) {
19456
- view.pointColors = [...source.pointColors ?? []];
19457
- for (const [key, gradient] of Object.entries(source.pointGradients))
19458
- view.pointColors[Number(key)] = paint2(gradient, `s${index}-p${key}`, bounds);
19459
- }
19460
- return view;
19461
- });
19462
- return defs.length ? { model: { ...model, appearance, series }, defs: `<defs>${defs.join("")}</defs>` } : { model, defs: "" };
19463
- }
19464
- function chartTextAttributes(model, part, fallbackSize = FONT_SIZE) {
19465
- const entry2 = model.appearance?.[part];
19466
- return {
19467
- size: entry2?.fontSize === void 0 ? fallbackSize : chartPointsToPixels(entry2.fontSize),
19468
- ...entry2?.color === void 0 ? {} : { fill: entry2.color },
19469
- ...entry2?.bold === void 0 ? {} : { weight: entry2.bold ? "bold" : "normal" },
19470
- ...entry2?.italic === void 0 ? {} : { italic: entry2.italic },
19471
- ...entry2?.underline === void 0 ? {} : { underline: entry2.underline },
19472
- ...entry2?.typeface === void 0 ? {} : { family: cssFontFamily(entry2.typeface) },
19473
- ...entry2?.textShadowFilter === void 0 ? {} : { filter: entry2.textShadowFilter }
19474
- };
19475
- }
19476
- function chartStroke(model, part) {
19477
- const entry2 = model.appearance?.[part];
19478
- return {
19479
- color: entry2?.axisVisible === false ? "none" : entry2?.lineColor ?? (part === "gridlineMajor" ? GRID_COLOR : AXIS_COLOR),
19480
- width: entry2?.lineWidth === void 0 ? 1 : chartPointsToPixels(entry2.lineWidth)
19481
- };
19482
- }
19483
- function chartAreaRect(model, part, area) {
19484
- if (area.w <= 0 || area.h <= 0) return "";
19485
- const entry2 = model.appearance?.[part];
19486
- let fill = entry2?.fillColor ?? (part === "chartArea" ? "#FFFFFF" : "none");
19487
- let defs = "";
19488
- if (part !== "chartArea" && entry2?.gradient && (part !== "plotArea" || ["circle", "shape"].includes(entry2.gradient.path ?? ""))) {
19489
- const def = buildChartGradientDef(`xlsx-chart-${++nextPaintId}-${part}`, entry2.gradient, {
19490
- width: area.w,
19491
- height: area.h,
19492
- shape: "rect"
19493
- });
19494
- defs = `<defs>${chartGradientMarkup(def)}</defs>`;
19495
- fill = `url(#${def.id})`;
19496
- }
19497
- const stroke = entry2?.lineColor ?? "none";
19498
- if (fill === "none" && stroke === "none") return "";
19499
- const width = entry2?.lineWidth === void 0 ? 1 : chartPointsToPixels(entry2.lineWidth);
19500
- return `${defs}<rect x="${n(area.x)}" y="${n(area.y)}" width="${n(area.w)}" height="${n(area.h)}" fill="${esc(fill)}" stroke="${esc(stroke)}" stroke-width="${n(width)}" data-chart-part="${part}"/>`;
19501
- }
19502
-
19503
20558
  // chart/render/chart-svg-cartesian.ts
19504
20559
  function cartesianAxes(model, area, out) {
19505
20560
  const scale = model.valueAxis;
19506
20561
  if (!scale) return void 0;
19507
- const labels = scale.ticks.map((t) => formatAxisValue(t, scale.percent));
20562
+ const labels = scale.ticks.map((t) => axisTickText(t, model.axes?.value, scale.percent));
19508
20563
  const valueAttrs = chartTextAttributes(model, "valueAxis");
19509
20564
  const categoryAttrs = chartTextAttributes(model, "categoryAxis");
19510
20565
  const valueSize = valueAttrs.size ?? 10;
19511
20566
  const categorySize = categoryAttrs.size ?? 10;
19512
- const grid = chartStroke(model, "gridlineMajor");
19513
- const axis = chartStroke(model, "categoryAxis");
19514
- const valueLabels = model.appearance?.valueAxis?.labelsVisible !== false;
19515
- const categoryLabels = model.appearance?.categoryAxis?.labelsVisible !== false;
20567
+ const valueLabels = chartAxisLabels(model.axes?.value) && model.appearance?.valueAxis?.labelsVisible !== false;
20568
+ const categoryLabels = chartAxisLabels(model.axes?.category) && model.appearance?.categoryAxis?.labelsVisible !== false;
19516
20569
  const labelW = valueLabels ? Math.max(...labels.map((l) => textWidth(l, valueSize)), 8) + 6 : 4;
19517
20570
  const horizontal = model.horizontal;
19518
20571
  const cats = Math.max(1, model.categories.length);
@@ -19521,7 +20574,7 @@ function cartesianAxes(model, area, out) {
19521
20574
  Math.max(...model.categories.map((c2) => textWidth(c2, categorySize)), 8) + 6
19522
20575
  );
19523
20576
  const second = horizontal ? void 0 : model.secondaryAxis;
19524
- const secondLabels = second?.ticks.map((t) => formatAxisValue(t, second.percent)) ?? [];
20577
+ const secondLabels = second?.ticks.map((t) => axisTickText(t, model.axes?.secondary, second.percent)) ?? [];
19525
20578
  const secondW = second ? valueLabels ? Math.max(...secondLabels.map((l) => textWidth(l, valueSize)), 8) + 8 : 4 : 0;
19526
20579
  const plot = horizontal ? {
19527
20580
  x: area.x + catW,
@@ -19534,29 +20587,47 @@ function cartesianAxes(model, area, out) {
19534
20587
  w: Math.max(1, area.w - labelW - 4 - secondW),
19535
20588
  h: Math.max(1, area.h - Math.max(20, categorySize * 1.5))
19536
20589
  };
19537
- const span = scale.max - scale.min || 1;
19538
- const value = horizontal ? (v) => plot.x + (v - scale.min) / span * plot.w : (v) => plot.y + plot.h - (v - scale.min) / span * plot.h;
20590
+ const value = horizontal ? (v) => plot.x + chartAxisRatio(v, scale, model.axes?.value) * plot.w : (v) => plot.y + plot.h - chartAxisRatio(v, scale, model.axes?.value) * plot.h;
19539
20591
  const bandSize = (horizontal ? plot.h : plot.w) / cats;
19540
- const band = horizontal ? (i) => plot.y + plot.h - bandSize * (i + 0.5) : (i) => plot.x + bandSize * (i + 0.5);
20592
+ const index = (i) => model.axes?.category?.range.reverseOrder ? cats - 1 - i : i;
20593
+ const band = horizontal ? (i) => plot.y + plot.h - bandSize * (index(i) + 0.5) : (i) => plot.x + bandSize * (index(i) + 0.5);
19541
20594
  out.push(chartAreaRect(model, "plotArea", plot));
20595
+ out.push(axisGridlines(model, model.axes?.value, scale.ticks, value, plot, horizontal));
20596
+ if (model.axes?.category?.source.majorGridlines || model.axes?.category?.source.minorGridlines)
20597
+ out.push(
20598
+ axisGridlines(
20599
+ model,
20600
+ model.axes.category,
20601
+ model.categories.map((_, i) => i),
20602
+ band,
20603
+ plot,
20604
+ !horizontal
20605
+ )
20606
+ );
19542
20607
  scale.ticks.forEach((t, i) => {
19543
20608
  const p = value(t);
19544
20609
  const label = labels[i] ?? "";
19545
20610
  if (horizontal) {
19546
- out.push(line2(p, plot.y, p, plot.y + plot.h, grid.color, grid.width));
19547
20611
  if (valueLabels)
19548
20612
  out.push(
19549
20613
  text2(p, plot.y + plot.h + valueSize + 2, label, { anchor: "middle", ...valueAttrs })
19550
20614
  );
19551
20615
  } else {
19552
- out.push(line2(plot.x, p, plot.x + plot.w, p, grid.color, grid.width));
19553
20616
  if (valueLabels)
19554
20617
  out.push(text2(plot.x - 4, p + valueSize * 0.3, label, { anchor: "end", ...valueAttrs }));
19555
20618
  }
19556
20619
  });
19557
- const zero = value(Math.min(Math.max(0, scale.min), scale.max));
19558
- if (horizontal) out.push(line2(zero, plot.y, zero, plot.y + plot.h, axis.color, axis.width));
19559
- else out.push(line2(plot.x, zero, plot.x + plot.w, zero, axis.color, axis.width));
20620
+ const source = model.axes?.value?.source;
20621
+ const crossing = source?.crosses === "max" ? scale.max : source?.crosses === "min" ? scale.min : source?.crossesAt ?? 0;
20622
+ const zero = value(Math.min(Math.max(crossing, scale.min), scale.max));
20623
+ if (horizontal)
20624
+ out.push(
20625
+ axisLine(model, model.axes?.category, "categoryAxis", zero, plot.y, zero, plot.y + plot.h)
20626
+ );
20627
+ else
20628
+ out.push(
20629
+ axisLine(model, model.axes?.category, "categoryAxis", plot.x, zero, plot.x + plot.w, zero)
20630
+ );
19560
20631
  const step = Math.max(
19561
20632
  1,
19562
20633
  Math.ceil(cats / Math.max(1, Math.floor((horizontal ? plot.h : plot.w) / 14)))
@@ -19581,20 +20652,23 @@ function cartesianAxes(model, area, out) {
19581
20652
  });
19582
20653
  const frame2 = { plot, value, band, bandSize };
19583
20654
  if (second) {
19584
- const secondSpan = second.max - second.min || 1;
19585
- frame2.secondary = (v) => plot.y + plot.h - (v - second.min) / secondSpan * plot.h;
19586
- const secondAxis = chartStroke(model, "valueAxis");
20655
+ frame2.secondary = (v) => plot.y + plot.h - chartAxisRatio(v, second, model.axes?.secondary) * plot.h;
19587
20656
  out.push(
19588
- line2(
20657
+ axisLine(
20658
+ model,
20659
+ model.axes?.secondary,
20660
+ "valueAxis",
19589
20661
  plot.x + plot.w,
19590
20662
  plot.y,
19591
20663
  plot.x + plot.w,
19592
- plot.y + plot.h,
19593
- secondAxis.color,
19594
- secondAxis.width
20664
+ plot.y + plot.h
19595
20665
  )
19596
20666
  );
19597
- if (valueLabels)
20667
+ if (model.axes?.secondary?.source.majorGridlines || model.axes?.secondary?.source.minorGridlines)
20668
+ out.push(
20669
+ axisGridlines(model, model.axes.secondary, second.ticks, frame2.secondary, plot, false)
20670
+ );
20671
+ if (chartAxisLabels(model.axes?.secondary))
19598
20672
  second.ticks.forEach(
19599
20673
  (t, i) => out.push(
19600
20674
  text2(plot.x + plot.w + 4, frame2.secondary(t) + valueSize * 0.3, secondLabels[i] ?? "", {
@@ -19618,6 +20692,7 @@ function linesAndAreas(model, frame2, out) {
19618
20692
  const stacked = model.grouping === "stacked" || model.grouping === "percentStacked";
19619
20693
  const acc = new Array(model.categories.length).fill(0);
19620
20694
  const area = model.type === "area";
20695
+ const marks = [];
19621
20696
  const layers = [];
19622
20697
  model.series.forEach((s, si) => {
19623
20698
  const points = [];
@@ -19632,16 +20707,24 @@ function linesAndAreas(model, frame2, out) {
19632
20707
  const top = below + (v ?? 0);
19633
20708
  if (stacked) acc[i] = top;
19634
20709
  points.push([frame2.band(i), frame2.value(top)]);
20710
+ marks.push({
20711
+ series: s,
20712
+ index: i,
20713
+ x: frame2.band(i),
20714
+ y: frame2.value(top),
20715
+ radius: area ? 0 : chartMarkerRadius(s, i, 2.5)
20716
+ });
19635
20717
  lower.push([frame2.band(i), frame2.value(below)]);
19636
20718
  });
19637
20719
  layers.push({
20720
+ series: s,
19638
20721
  points,
19639
20722
  lower,
19640
20723
  color: s.color,
19641
20724
  filter: s.shadowFilter ? ` filter="${s.shadowFilter}"` : ""
19642
20725
  });
19643
20726
  });
19644
- for (const { points, lower, color, filter } of area ? [...layers].reverse() : layers) {
20727
+ for (const { points, lower, color, filter, series } of area ? [...layers].reverse() : layers) {
19645
20728
  if (area) {
19646
20729
  const poly = [...points, ...[...lower].reverse()].map(([x, y]) => `${n(x)},${n(y)}`).join(" ");
19647
20730
  out.push(`<polygon points="${poly}" fill="${color}" fill-opacity="0.85"${filter}/>`);
@@ -19660,10 +20743,11 @@ function linesAndAreas(model, frame2, out) {
19660
20743
  else segment2.push(`${n(x)},${n(y)}`);
19661
20744
  }
19662
20745
  flush();
19663
- for (const [x, y] of points)
19664
- if (!Number.isNaN(x))
19665
- out.push(`<circle cx="${n(x)}" cy="${n(y)}" r="2.5" fill="${color}"${filter}/>`);
20746
+ points.forEach(([x, y], index) => {
20747
+ if (!Number.isNaN(x)) out.push(chartSeriesMarkerSvg(series, index, x, y, 2.5));
20748
+ });
19666
20749
  }
20750
+ pointLabels(model, marks, out);
19667
20751
  }
19668
20752
 
19669
20753
  // chart/render/chart-svg-xy.ts
@@ -19671,16 +20755,14 @@ function scatter(model, area, out) {
19671
20755
  const ys = model.valueAxis;
19672
20756
  const xs = model.xAxis;
19673
20757
  if (!ys || !xs) return;
19674
- const yLabels = ys.ticks.map((t) => formatAxisValue(t));
20758
+ const yLabels = ys.ticks.map((t) => axisTickText(t, model.axes?.value));
19675
20759
  const valueAttrs = chartTextAttributes(model, "valueAxis");
19676
20760
  const categoryAttrs = chartTextAttributes(model, "categoryAxis");
19677
20761
  const valueSize = valueAttrs.size ?? 10;
19678
20762
  const categorySize = categoryAttrs.size ?? 10;
19679
- const grid = chartStroke(model, "gridlineMajor");
19680
20763
  const xAxis = chartStroke(model, "categoryAxis");
19681
- const yAxis = chartStroke(model, "valueAxis");
19682
- const valueLabels = model.appearance?.valueAxis?.labelsVisible !== false;
19683
- const categoryLabels = model.appearance?.categoryAxis?.labelsVisible !== false;
20764
+ const valueLabels = chartAxisLabels(model.axes?.value) && model.appearance?.valueAxis?.labelsVisible !== false;
20765
+ const categoryLabels = chartAxisLabels(model.axes?.category) && model.appearance?.categoryAxis?.labelsVisible !== false;
19684
20766
  const labelW = valueLabels ? Math.max(...yLabels.map((l) => textWidth(l, valueSize)), 8) + 6 : 4;
19685
20767
  const plot = {
19686
20768
  x: area.x + labelW,
@@ -19700,17 +20782,24 @@ function scatter(model, area, out) {
19700
20782
  s.values.forEach((_, i) => {
19701
20783
  reach = Math.max(reach, radiusOf(s.sizes?.[i] ?? void 0) ?? 0);
19702
20784
  });
19703
- const widen = (s, length) => {
20785
+ const widen = (s, length, axis) => {
20786
+ if (axis?.range.logScale) return s;
19704
20787
  const pad = reach * (s.max - s.min || 1) / Math.max(1, length - 2 * reach);
19705
- return { ...s, min: s.min - pad, max: s.max + pad };
20788
+ return {
20789
+ ...s,
20790
+ min: axis?.source.scaling.min === void 0 ? s.min - pad : s.min,
20791
+ max: axis?.source.scaling.max === void 0 ? s.max + pad : s.max
20792
+ };
19706
20793
  };
19707
- const xView = widen(xs, plot.w);
19708
- const yView = widen(ys, plot.h);
19709
- const px3 = (v) => plot.x + (v - xView.min) / (xView.max - xView.min || 1) * plot.w;
19710
- const py = (v) => plot.y + plot.h - (v - yView.min) / (yView.max - yView.min || 1) * plot.h;
20794
+ const xView = widen(xs, plot.w, model.axes?.category);
20795
+ const yView = widen(ys, plot.h, model.axes?.value);
20796
+ const px3 = (v) => plot.x + chartAxisRatio(v, xView, model.axes?.category) * plot.w;
20797
+ const py = (v) => plot.y + plot.h - chartAxisRatio(v, yView, model.axes?.value) * plot.h;
19711
20798
  out.push(chartAreaRect(model, "plotArea", plot));
20799
+ out.push(axisGridlines(model, model.axes?.value, ys.ticks, py, plot, false));
20800
+ if (model.axes?.category)
20801
+ out.push(axisGridlines(model, model.axes.category, xs.ticks, px3, plot, true));
19712
20802
  ys.ticks.forEach((t, i) => {
19713
- out.push(line2(plot.x, py(t), plot.x + plot.w, py(t), grid.color, grid.width));
19714
20803
  if (valueLabels)
19715
20804
  out.push(
19716
20805
  text2(plot.x - 4, py(t) + valueSize * 0.3, yLabels[i] ?? "", {
@@ -19720,19 +20809,31 @@ function scatter(model, area, out) {
19720
20809
  );
19721
20810
  });
19722
20811
  for (const t of xs.ticks) {
19723
- out.push(line2(px3(t), plot.y + plot.h, px3(t), plot.y + plot.h + 3, xAxis.color, xAxis.width));
20812
+ if (!model.axes?.category?.source.deleted)
20813
+ out.push(line2(px3(t), plot.y + plot.h, px3(t), plot.y + plot.h + 3, xAxis.color, xAxis.width));
19724
20814
  if (categoryLabels)
19725
20815
  out.push(
19726
- text2(px3(t), plot.y + plot.h + categorySize + 3, formatAxisValue(t), {
20816
+ text2(px3(t), plot.y + plot.h + categorySize + 3, axisTickText(t, model.axes?.category), {
19727
20817
  anchor: "middle",
19728
20818
  ...categoryAttrs
19729
20819
  })
19730
20820
  );
19731
20821
  }
19732
20822
  out.push(
19733
- line2(plot.x, plot.y + plot.h, plot.x + plot.w, plot.y + plot.h, xAxis.color, xAxis.width)
20823
+ axisLine(
20824
+ model,
20825
+ model.axes?.category,
20826
+ "categoryAxis",
20827
+ plot.x,
20828
+ plot.y + plot.h,
20829
+ plot.x + plot.w,
20830
+ plot.y + plot.h
20831
+ )
20832
+ );
20833
+ out.push(
20834
+ axisLine(model, model.axes?.value, "valueAxis", plot.x, plot.y, plot.x, plot.y + plot.h)
19734
20835
  );
19735
- out.push(line2(plot.x, plot.y, plot.x, plot.y + plot.h, yAxis.color, yAxis.width));
20836
+ const marks = [];
19736
20837
  for (const [si, s] of model.series.entries())
19737
20838
  s.values.forEach((v, i) => {
19738
20839
  const x = s.xValues?.[i] ?? null;
@@ -19740,15 +20841,18 @@ function scatter(model, area, out) {
19740
20841
  const filter = s.shadowFilter ? ` filter="${s.shadowFilter}"` : "";
19741
20842
  const fill = s.pointColors?.[i] ?? s.color;
19742
20843
  if (!bubble) {
19743
- out.push(`<circle cx="${n(px3(x))}" cy="${n(py(v))}" r="3" fill="${fill}"${filter}/>`);
20844
+ out.push(chartSeriesMarkerSvg(s, i, px3(x), py(v)));
20845
+ marks.push({ series: s, index: i, x: px3(x), y: py(v), radius: chartMarkerRadius(s, i) });
19744
20846
  return;
19745
20847
  }
19746
20848
  const r = radiusOf(s.sizes?.[i] ?? void 0);
19747
20849
  if (r === void 0) return;
20850
+ marks.push({ series: s, index: i, x: px3(x), y: py(v), radius: r });
19748
20851
  out.push(
19749
20852
  `<circle cx="${n(px3(x))}" cy="${n(py(v))}" r="${n(r)}" fill="${fill}" fill-opacity="0.6" data-chart-series="${si}" data-chart-point="${i}"${filter}/>`
19750
20853
  );
19751
20854
  });
20855
+ pointLabels(model, marks, out);
19752
20856
  scatterAnalysis(model, px3, py, out);
19753
20857
  }
19754
20858
 
@@ -19865,21 +20969,21 @@ function cartesianSvg(model, area) {
19865
20969
  return out.join("");
19866
20970
  }
19867
20971
  const layers = [{ model, frame: frame2 }];
19868
- for (const group of model.extraGroups ?? []) {
20972
+ for (const group2 of model.extraGroups ?? []) {
19869
20973
  const grouped = {
19870
20974
  ...model,
19871
- type: group.type,
19872
- grouping: group.grouping,
19873
- series: group.series,
20975
+ type: group2.type,
20976
+ grouping: group2.grouping,
20977
+ series: group2.series,
19874
20978
  horizontal: false
19875
20979
  };
19876
- if (group.stock) grouped.stock = group.stock;
20980
+ if (group2.stock) grouped.stock = group2.stock;
19877
20981
  else delete grouped.stock;
19878
- if (group.barGapWidth !== void 0) grouped.barGapWidth = group.barGapWidth;
20982
+ if (group2.barGapWidth !== void 0) grouped.barGapWidth = group2.barGapWidth;
19879
20983
  else delete grouped.barGapWidth;
19880
- if (group.barOverlap !== void 0) grouped.barOverlap = group.barOverlap;
20984
+ if (group2.barOverlap !== void 0) grouped.barOverlap = group2.barOverlap;
19881
20985
  else delete grouped.barOverlap;
19882
- const value = group.secondary && frame2.secondary ? frame2.secondary : frame2.value;
20986
+ const value = group2.secondary && frame2.secondary ? frame2.secondary : frame2.value;
19883
20987
  layers.push({ model: grouped, frame: { ...frame2, value } });
19884
20988
  }
19885
20989
  layers.map((layer, order) => ({ layer, order })).sort(
@@ -19913,7 +21017,9 @@ function pieSvg(model, area) {
19913
21017
  const out = [chartAreaRect(model, "plotArea", area)];
19914
21018
  const cx2 = area.x + area.w / 2;
19915
21019
  const cy = area.y + area.h / 2;
19916
- const radius = Math.max(1, Math.min(area.w, area.h) / 2 - 4);
21020
+ const margin = hasOutsideLabels(model) ? Math.min(area.w, area.h) * 0.12 : 0;
21021
+ const radius = Math.max(1, Math.min(area.w, area.h) / 2 - 4 - margin);
21022
+ const slices = [];
19917
21023
  const rings = model.type === "doughnut" ? model.series : model.series.slice(0, 1);
19918
21024
  const hole = model.type === "doughnut" ? radius * 0.5 : 0;
19919
21025
  const ringSize = (radius - hole) / Math.max(1, rings.length);
@@ -19930,9 +21036,20 @@ function pieSvg(model, area) {
19930
21036
  out.push(
19931
21037
  `<path d="${slicePath(cx2, cy, outer, inner, angle, angle + sweep)}" fill="${color}" stroke="#FFFFFF" stroke-width="1"${s.shadowFilter ? ` filter="${s.shadowFilter}"` : ""}/>`
19932
21038
  );
21039
+ slices.push({
21040
+ series: s,
21041
+ index: i,
21042
+ cx: cx2,
21043
+ cy,
21044
+ outer,
21045
+ inner,
21046
+ start: angle,
21047
+ end: angle + sweep
21048
+ });
19933
21049
  angle += sweep;
19934
21050
  });
19935
21051
  });
21052
+ sliceLabels(model, slices, out);
19936
21053
  return out.join("");
19937
21054
  }
19938
21055
  function radarSvg(model, area) {
@@ -19945,32 +21062,37 @@ function radarSvg(model, area) {
19945
21062
  const valueSize = valueAttrs.size ?? 9;
19946
21063
  const categorySize = categoryAttrs.size ?? 10;
19947
21064
  const grid = chartStroke(model, "gridlineMajor");
19948
- const axis = chartStroke(model, "categoryAxis");
19949
21065
  const cx2 = area.x + area.w / 2;
19950
21066
  const cy = area.y + area.h / 2 + 4;
19951
21067
  const radius = Math.max(1, Math.min(area.w, area.h) / 2 - Math.max(18, categorySize * 1.8));
19952
21068
  const angle = (i) => i / count * Math.PI * 2;
19953
- const r = (v) => (v - scale.min) / (scale.max - scale.min || 1) * radius;
21069
+ const r = (v) => chartAxisRatio(v, scale, model.axes?.value) * radius;
19954
21070
  const labelEvery = Math.max(
19955
21071
  1,
19956
21072
  Math.ceil(12 / Math.max(1, radius / Math.max(1, scale.ticks.length - 1)))
19957
21073
  );
19958
21074
  for (const [k, t] of scale.ticks.entries()) {
19959
21075
  const ring = Array.from({ length: count }, (_, i) => polar(cx2, cy, r(t), angle(i))).map(([x, y]) => `${n(x)},${n(y)}`).join(" ");
19960
- out.push(
19961
- `<polygon points="${ring}" fill="none" stroke="${grid.color}" stroke-width="${n(grid.width)}"/>`
19962
- );
19963
- if (model.appearance?.valueAxis?.labelsVisible !== false && k % labelEvery === 0)
21076
+ if (!model.axes?.value || model.axes.value.source.majorGridlines)
21077
+ out.push(
21078
+ `<polygon points="${ring}" fill="none" stroke="${grid.color}" stroke-width="${n(grid.width)}"/>`
21079
+ );
21080
+ if (chartAxisLabels(model.axes?.value) && model.appearance?.valueAxis?.labelsVisible !== false && k % labelEvery === 0)
19964
21081
  out.push(
19965
- text2(cx2 + 3, cy - r(t) + valueSize * 0.3, formatAxisValue(t, scale.percent), valueAttrs)
21082
+ text2(
21083
+ cx2 + 3,
21084
+ cy - r(t) + valueSize * 0.3,
21085
+ axisTickText(t, model.axes?.value, scale.percent),
21086
+ valueAttrs
21087
+ )
19966
21088
  );
19967
21089
  }
19968
21090
  model.categories.forEach((c2, i) => {
19969
21091
  const [x, y] = polar(cx2, cy, radius, angle(i));
19970
- out.push(line2(cx2, cy, x, y, axis.color, axis.width));
21092
+ out.push(axisLine(model, model.axes?.category, "categoryAxis", cx2, cy, x, y));
19971
21093
  const [lx, ly] = polar(cx2, cy, radius + 10, angle(i));
19972
21094
  const anchor = Math.abs(lx - cx2) < 2 ? "middle" : lx > cx2 ? "start" : "end";
19973
- if (model.appearance?.categoryAxis?.labelsVisible !== false)
21095
+ if (chartAxisLabels(model.axes?.category) && model.appearance?.categoryAxis?.labelsVisible !== false)
19974
21096
  out.push(
19975
21097
  text2(lx, ly + categorySize * 0.3, fit(c2, area.w / 4, categorySize), {
19976
21098
  anchor,
@@ -19978,12 +21100,22 @@ function radarSvg(model, area) {
19978
21100
  })
19979
21101
  );
19980
21102
  });
21103
+ const marks = [];
19981
21104
  for (const s of model.series) {
19982
- const points = s.values.slice(0, count).map((v, i) => polar(cx2, cy, r(v ?? scale.min), angle(i))).map(([x, y]) => `${n(x)},${n(y)}`).join(" ");
21105
+ const vertices = s.values.slice(0, count).map((v, i) => polar(cx2, cy, r(v ?? scale.min), angle(i)));
21106
+ vertices.forEach(([x, y], i) => {
21107
+ if (s.values[i] === null) return;
21108
+ const markerSeries = s;
21109
+ if (markerSeries.marker || markerSeries.pointMarkers)
21110
+ out.push(chartSeriesMarkerSvg(s, i, x, y));
21111
+ marks.push({ series: s, index: i, x, y, radius: chartMarkerRadius(s, i) });
21112
+ });
21113
+ const points = vertices.map(([x, y]) => `${n(x)},${n(y)}`).join(" ");
19983
21114
  out.push(
19984
21115
  `<polygon points="${points}" fill="none" stroke="${s.color}" stroke-width="2"${s.shadowFilter ? ` filter="${s.shadowFilter}"` : ""}/>`
19985
21116
  );
19986
21117
  }
21118
+ pointLabels(model, marks, out);
19987
21119
  return out.join("");
19988
21120
  }
19989
21121
 
@@ -20074,33 +21206,33 @@ var CHART_FONT_FAMILY = "Calibri, Carlito, Arial, sans-serif";
20074
21206
  function cssFont(attrs2) {
20075
21207
  return `${attrs2.italic ? "italic" : "normal"} ${attrs2.weight ?? "normal"} ${attrs2.size ?? 10}px ${attrs2.family ?? CHART_FONT_FAMILY}`;
20076
21208
  }
20077
- function chartFontMetrics(attrs2, options) {
20078
- const metrics = options.measureFont?.(cssFont(attrs2));
21209
+ function chartFontMetrics(attrs2, options2) {
21210
+ const metrics = options2.measureFont?.(cssFont(attrs2));
20079
21211
  return metrics && Number.isFinite(metrics.ascent) && Number.isFinite(metrics.descent) && metrics.ascent >= 0 && metrics.descent >= 0 && metrics.ascent + metrics.descent > 0 ? metrics : void 0;
20080
21212
  }
20081
- function chartTextWidth(content, attrs2, options) {
20082
- const width = options.measureText?.(content, cssFont(attrs2));
21213
+ function chartTextWidth(content, attrs2, options2) {
21214
+ const width = options2.measureText?.(content, cssFont(attrs2));
20083
21215
  return width !== void 0 && Number.isFinite(width) && width >= 0 ? width : textWidth(content, attrs2.size);
20084
21216
  }
20085
- function fitChartText(content, maxWidth, attrs2, options) {
20086
- if (!options.measureText) return fit(content, maxWidth, attrs2.size);
20087
- if (chartTextWidth(content, attrs2, options) <= maxWidth) return content;
21217
+ function fitChartText(content, maxWidth, attrs2, options2) {
21218
+ if (!options2.measureText) return fit(content, maxWidth, attrs2.size);
21219
+ if (chartTextWidth(content, attrs2, options2) <= maxWidth) return content;
20088
21220
  const points = [...content];
20089
21221
  let low = 0;
20090
21222
  let high = points.length;
20091
21223
  while (low < high) {
20092
21224
  const mid = Math.ceil((low + high) / 2);
20093
- if (chartTextWidth(`${points.slice(0, mid).join("")}\u2026`, attrs2, options) <= maxWidth) low = mid;
21225
+ if (chartTextWidth(`${points.slice(0, mid).join("")}\u2026`, attrs2, options2) <= maxWidth) low = mid;
20094
21226
  else high = mid - 1;
20095
21227
  }
20096
21228
  return `${points.slice(0, low).join("")}\u2026`;
20097
21229
  }
20098
21230
 
20099
21231
  // chart/render/chart-svg-legend.ts
20100
- function chartLegendSvg(model, area, frame2, options) {
21232
+ function chartLegendSvg(model, area, frame2, options2) {
20101
21233
  const automatic = [];
20102
21234
  const bounds = {};
20103
- const reserved = automaticLegend(model, area, automatic, options, bounds);
21235
+ const reserved = automaticLegend(model, area, automatic, options2, bounds);
20104
21236
  const plot = model.legendOverlay ? area : reserved;
20105
21237
  const box = bounds.box;
20106
21238
  if (!box) return { plot, markup: "", foreground: false };
@@ -20114,11 +21246,11 @@ function chartLegendSvg(model, area, frame2, options) {
20114
21246
  const entries = legendEntries(model);
20115
21247
  const attrs2 = chartTextAttributes(model, "legend");
20116
21248
  const size = attrs2.size ?? 10;
20117
- const font = chartFontMetrics(attrs2, options);
21249
+ const font = chartFontMetrics(attrs2, options2);
20118
21250
  const keySize = size / 2;
20119
21251
  const keyGap = size / 4;
20120
21252
  const widths = entries.map(
20121
- (entry2) => chartTextWidth(entry2.label, attrs2, options) + keySize + keyGap
21253
+ (entry2) => chartTextWidth(entry2.label, attrs2, options2) + keySize + keyGap
20122
21254
  );
20123
21255
  const horizontal = manual.width > manual.height && widths.reduce((sum, width) => sum + width, 0) + size <= manual.width;
20124
21256
  const rowWidth = horizontal ? manual.width / entries.length : manual.width;
@@ -20133,8 +21265,8 @@ function chartLegendSvg(model, area, frame2, options) {
20133
21265
  ];
20134
21266
  const baselineOffset = font ? (font.ascent - font.descent) / 2 : size * 0.35;
20135
21267
  entries.forEach((entry2, i) => {
20136
- const available = horizontal ? chartTextWidth(entry2.label, attrs2, options) : Math.max(0, rowWidth - size / 2 - keySize - keyGap);
20137
- const label = fitChartText(entry2.label, available, attrs2, options);
21268
+ const available = horizontal ? chartTextWidth(entry2.label, attrs2, options2) : Math.max(0, rowWidth - size / 2 - keySize - keyGap);
21269
+ const label = fitChartText(entry2.label, available, attrs2, options2);
20138
21270
  const contentWidth = Math.min(
20139
21271
  horizontal ? widths[i] ?? 0 : Math.max(...widths),
20140
21272
  rowWidth - size / 2
@@ -20177,7 +21309,7 @@ function legendEntries(model) {
20177
21309
  color: s.color
20178
21310
  }));
20179
21311
  }
20180
- function automaticLegend(model, area, out, options, bounds) {
21312
+ function automaticLegend(model, area, out, options2, bounds) {
20181
21313
  const entries = legendEntries(model);
20182
21314
  if (!model.showLegend || entries.length === 0) return area;
20183
21315
  const pos = model.legendPosition;
@@ -20186,7 +21318,7 @@ function automaticLegend(model, area, out, options, bounds) {
20186
21318
  const rowH = Math.max(16, size * 1.4);
20187
21319
  if (pos === "t" || pos === "b") {
20188
21320
  const widths = entries.map(
20189
- (e) => Math.min(chartTextWidth(e.label, attrs2, options) + 20, area.w / 2)
21321
+ (e) => Math.min(chartTextWidth(e.label, attrs2, options2) + 20, area.w / 2)
20190
21322
  );
20191
21323
  const total = widths.reduce((a2, b) => a2 + b, 0);
20192
21324
  let x2 = area.x + Math.max(0, (area.w - total) / 2);
@@ -20203,14 +21335,14 @@ function automaticLegend(model, area, out, options, bounds) {
20203
21335
  entries.forEach((e, i) => {
20204
21336
  const w = widths[i] ?? 0;
20205
21337
  out.push(rect2(x2, y, 8, 8, e.color));
20206
- out.push(text2(x2 + 12, y + 8, fitChartText(e.label, w - 16, attrs2, options), attrs2));
21338
+ out.push(text2(x2 + 12, y + 8, fitChartText(e.label, w - 16, attrs2, options2), attrs2));
20207
21339
  x2 += w;
20208
21340
  });
20209
21341
  return pos === "t" ? { x: area.x, y: area.y + rowH + 4, w: area.w, h: area.h - rowH - 4 } : { x: area.x, y: area.y, w: area.w, h: area.h - rowH - 4 };
20210
21342
  }
20211
21343
  const width = Math.min(
20212
21344
  area.w * 0.35,
20213
- Math.max(...entries.map((e) => chartTextWidth(e.label, attrs2, options))) + 22
21345
+ Math.max(...entries.map((e) => chartTextWidth(e.label, attrs2, options2))) + 22
20214
21346
  );
20215
21347
  const height = entries.length * rowH;
20216
21348
  const x = pos === "l" ? area.x + 4 : area.x + area.w - width;
@@ -20228,24 +21360,24 @@ function automaticLegend(model, area, out, options, bounds) {
20228
21360
  const y = y0 + i * rowH;
20229
21361
  if (y + rowH > area.y + area.h + 2) return;
20230
21362
  out.push(rect2(x, y + 3, 8, 8, e.color));
20231
- out.push(text2(x + 12, y + 11, fitChartText(e.label, width - 16, attrs2, options), attrs2));
21363
+ out.push(text2(x + 12, y + 11, fitChartText(e.label, width - 16, attrs2, options2), attrs2));
20232
21364
  });
20233
21365
  return pos === "l" ? { x: area.x + width + 8, y: area.y, w: area.w - width - 8, h: area.h } : { x: area.x, y: area.y, w: area.w - width - 8, h: area.h };
20234
21366
  }
20235
21367
 
20236
21368
  // text/wrap-styled-runs.ts
20237
21369
  var graphemes = new Intl.Segmenter(void 0, { granularity: "grapheme" });
20238
- function wrapStyledRuns(runs, maxWidth, measure, options = {}) {
21370
+ function wrapStyledRuns(runs, maxWidth, measure2, options2 = {}) {
20239
21371
  const groups = [];
20240
21372
  for (const [source, run] of runs.entries()) {
20241
21373
  for (const token of run.text.split(/(\r\n|[\r\n]|[ \t]+)/u).filter(Boolean)) {
20242
21374
  const kind = /^[\r\n]+$/u.test(token) ? "break" : /^[ \t]+$/u.test(token) ? "space" : "word";
20243
- let group = groups.at(-1);
20244
- if (!group || group.kind !== kind || kind === "break") {
20245
- group = { kind, pieces: [] };
20246
- groups.push(group);
21375
+ let group2 = groups.at(-1);
21376
+ if (!group2 || group2.kind !== kind || kind === "break") {
21377
+ group2 = { kind, pieces: [] };
21378
+ groups.push(group2);
20247
21379
  }
20248
- if (kind !== "break") group.pieces.push({ run, source, text: token });
21380
+ if (kind !== "break") group2.pieces.push({ run, source, text: token });
20249
21381
  }
20250
21382
  }
20251
21383
  const merged = (left, right) => {
@@ -20258,7 +21390,7 @@ function wrapStyledRuns(runs, maxWidth, measure, options = {}) {
20258
21390
  return result2;
20259
21391
  };
20260
21392
  const width = (pieces) => pieces.reduce((sum, piece) => {
20261
- const advance = measure(piece.text, piece.run);
21393
+ const advance = measure2(piece.text, piece.run);
20262
21394
  return sum + (Number.isFinite(advance) && advance >= 0 ? advance : 0);
20263
21395
  }, 0);
20264
21396
  const result = [];
@@ -20269,29 +21401,29 @@ function wrapStyledRuns(runs, maxWidth, measure, options = {}) {
20269
21401
  line3 = [];
20270
21402
  spaces = [];
20271
21403
  };
20272
- for (const group of groups) {
20273
- if (group.kind === "break") {
21404
+ for (const group2 of groups) {
21405
+ if (group2.kind === "break") {
20274
21406
  flush();
20275
21407
  continue;
20276
21408
  }
20277
- if (group.kind === "space") {
20278
- spaces = group.pieces;
21409
+ if (group2.kind === "space") {
21410
+ spaces = group2.pieces;
20279
21411
  continue;
20280
21412
  }
20281
21413
  const separator = line3.length ? spaces : [];
20282
- const wordWidth = width(group.pieces);
20283
- if (line3.length && width(merged(line3, [...separator, ...group.pieces])) > maxWidth) flush();
21414
+ const wordWidth = width(group2.pieces);
21415
+ if (line3.length && width(merged(line3, [...separator, ...group2.pieces])) > maxWidth) flush();
20284
21416
  else line3 = merged(line3, separator);
20285
21417
  spaces = [];
20286
- if (options.breakWords && wordWidth > maxWidth) {
20287
- for (const piece of group.pieces) {
21418
+ if (options2.breakWords && wordWidth > maxWidth) {
21419
+ for (const piece of group2.pieces) {
20288
21420
  for (const { segment: segment2 } of graphemes.segment(piece.text)) {
20289
21421
  const next = { ...piece, text: segment2 };
20290
21422
  if (line3.length && width(merged(line3, [next])) > maxWidth) flush();
20291
21423
  line3 = merged(line3, [next]);
20292
21424
  }
20293
21425
  }
20294
- } else line3 = merged(line3, group.pieces);
21426
+ } else line3 = merged(line3, group2.pieces);
20295
21427
  }
20296
21428
  flush();
20297
21429
  return result;
@@ -20301,11 +21433,11 @@ function wrapStyledRuns(runs, maxWidth, measure, options = {}) {
20301
21433
  function spacing(value, naturalHeight, fallback) {
20302
21434
  return value ? value.unit === "points" ? chartPointsToPixels(value.value) : naturalHeight * value.value : fallback;
20303
21435
  }
20304
- function chartRichTitleSvg(model, width, options = {}, frameHeight = 400) {
21436
+ function chartRichTitleSvg(model, width, options2 = {}, frameHeight = 400) {
20305
21437
  if (!model.title) return void 0;
20306
21438
  const base = chartTextAttributes(model, "title", 14);
20307
21439
  const capacity = Math.max(1, width * 0.8 - 8);
20308
- if (!model.titleText && !hasManualLayoutFields(model.titleLayout) && !model.titleOverlay && !model.title.includes("\n") && chartTextWidth(model.title, base, options) <= capacity)
21440
+ if (!model.titleText && !hasManualLayoutFields(model.titleLayout) && !model.titleOverlay && !model.title.includes("\n") && chartTextWidth(model.title, base, options2) <= capacity)
20309
21441
  return void 0;
20310
21442
  const paragraphs = model.titleText?.paragraphs ?? [
20311
21443
  {
@@ -20341,7 +21473,7 @@ function chartRichTitleSvg(model, width, options = {}, frameHeight = 400) {
20341
21473
  "title",
20342
21474
  base.size
20343
21475
  ),
20344
- options
21476
+ options2
20345
21477
  ),
20346
21478
  { breakWords: true }
20347
21479
  );
@@ -20365,10 +21497,10 @@ function chartRichTitleSvg(model, width, options = {}, frameHeight = 400) {
20365
21497
  return {
20366
21498
  ...line3,
20367
21499
  runs,
20368
- width: runs.reduce((sum, run) => sum + chartTextWidth(run.text, run.attrs, options), 0),
21500
+ width: runs.reduce((sum, run) => sum + chartTextWidth(run.text, run.attrs, options2), 0),
20369
21501
  size: runs.length ? Math.max(...runs.map((run) => run.attrs.size ?? 14)) : base.size ?? 14,
20370
21502
  fontMetrics: (runs.length ? runs.map((run) => run.attrs) : [base]).map(
20371
- (attrs2) => chartFontMetrics(attrs2, options)
21503
+ (attrs2) => chartFontMetrics(attrs2, options2)
20372
21504
  )
20373
21505
  };
20374
21506
  });
@@ -20406,7 +21538,7 @@ function chartRichTitleSvg(model, width, options = {}, frameHeight = 400) {
20406
21538
  anchor: "start"
20407
21539
  }).replace("<text ", '<tspan data-chart-title-run="true" ').replace("</text>", "</tspan>")
20408
21540
  );
20409
- x += chartTextWidth(run.text, run.attrs, options);
21541
+ x += chartTextWidth(run.text, run.attrs, options2);
20410
21542
  }
20411
21543
  }
20412
21544
  const parent = text2(0, 0, "", { ...base, underline: false }).replace(
@@ -20432,7 +21564,7 @@ function chartRichTitleSvg(model, width, options = {}, frameHeight = 400) {
20432
21564
  }
20433
21565
 
20434
21566
  // chart/render/chart-svg.ts
20435
- function renderChartSvg(model, width, height, options = {}) {
21567
+ function renderChartSvg(model, width, height, options2 = {}) {
20436
21568
  const paint2 = chartGradientPaint(model, Math.max(1, width), Math.max(1, height));
20437
21569
  model = paint2.model;
20438
21570
  const w = Math.max(1, width);
@@ -20446,7 +21578,7 @@ function renderChartSvg(model, width, height, options = {}) {
20446
21578
  if (paint2.defs) out.push(paint2.defs);
20447
21579
  out.push(chartAreaRect(model, "chartArea", { x: 0, y: 0, w, h }));
20448
21580
  let area = { x: 8, y: 8, w: w - 16, h: h - 16 };
20449
- const richTitle = chartRichTitleSvg(model, w, options, h);
21581
+ const richTitle = chartRichTitleSvg(model, w, options2, h);
20450
21582
  if (richTitle) {
20451
21583
  if (model.titleLayout || model.titleOverlay) foregroundTitle = richTitle.markup;
20452
21584
  else out.push(richTitle.markup);
@@ -20455,9 +21587,9 @@ function renderChartSvg(model, width, height, options = {}) {
20455
21587
  } else if (model.title) {
20456
21588
  const attrs2 = chartTextAttributes(model, "title", 14);
20457
21589
  const size = attrs2.size ?? 14;
20458
- const label = fitChartText(model.title, w - 16, attrs2, options);
20459
- const titleWidth = Math.min(w - 16, chartTextWidth(label, attrs2, options) + 8);
20460
- const font = chartFontMetrics(attrs2, options);
21590
+ const label = fitChartText(model.title, w - 16, attrs2, options2);
21591
+ const titleWidth = Math.min(w - 16, chartTextWidth(label, attrs2, options2) + 8);
21592
+ const font = chartFontMetrics(attrs2, options2);
20461
21593
  const titleHeight = Math.max(24, font ? font.ascent + font.descent + 4 : size * 1.4 + 4);
20462
21594
  out.push(
20463
21595
  chartAreaRect(model, "title", {
@@ -20485,7 +21617,7 @@ function renderChartSvg(model, width, height, options = {}) {
20485
21617
  out.push("</svg>");
20486
21618
  return out.join("");
20487
21619
  }
20488
- const legend = chartLegendSvg(model, area, { width: w, height: h }, options);
21620
+ const legend = chartLegendSvg(model, area, { width: w, height: h }, options2);
20489
21621
  area = legend.plot;
20490
21622
  if (!legend.foreground) out.push(legend.markup);
20491
21623
  if (area.w > 4 && area.h > 4) {
@@ -20532,8 +21664,8 @@ function chartSpaceKind(space) {
20532
21664
  const type = chartSummaryFromSpace(space).chartType;
20533
21665
  return { type, drawn: DRAWN_CHART_TYPES.has(type) };
20534
21666
  }
20535
- function renderChartSpaceSvg(space, options) {
20536
- const { width, height, theme, fonts, formatting, colorPalette, styleDefinition, ...svg } = options;
21667
+ function renderChartSpaceSvg(space, options2) {
21668
+ const { width, height, theme, fonts, formatting, colorPalette, styleDefinition, ...svg } = options2;
20537
21669
  const summary = chartSummaryFromSpace(space, {
20538
21670
  ...formatting ? { formatting } : {},
20539
21671
  ...colorPalette !== void 0 ? { colorPalette } : {},
@@ -20542,8 +21674,8 @@ function renderChartSpaceSvg(space, options) {
20542
21674
  const view = chartSummaryView(summary, chartThemePalette(theme, fonts));
20543
21675
  return renderChartSvg(view, width, height, svg);
20544
21676
  }
20545
- function renderChartSummarySvg(summary, options) {
20546
- const { width, height, theme, fonts, ...svg } = options;
21677
+ function renderChartSummarySvg(summary, options2) {
21678
+ const { width, height, theme, fonts, ...svg } = options2;
20547
21679
  const view = chartSummaryView(summary, chartThemePalette(theme, fonts));
20548
21680
  return renderChartSvg(view, width, height, svg);
20549
21681
  }
@@ -21986,36 +23118,36 @@ function buildInlineContent(doc, runs, base, slots, allocator, ranges) {
21986
23118
  const output = [];
21987
23119
  let index = 0;
21988
23120
  while (index < runs.length) {
21989
- const group = containerGroup(runAt(index));
21990
- if (!group) {
23121
+ const group2 = containerGroup(runAt(index));
23122
+ if (!group2) {
21991
23123
  output.push(...nodesFor(index));
21992
23124
  index++;
21993
23125
  continue;
21994
23126
  }
21995
23127
  const start = index;
21996
- while (index < runs.length && sameGroup(containerGroup(runAt(index)), group)) index++;
23128
+ while (index < runs.length && sameGroup(containerGroup(runAt(index)), group2)) index++;
21997
23129
  const oldContainers = new Set(slots.slice(start, index).map((slot2) => slot2?.container));
21998
23130
  const [onlyContainer] = oldContainers;
21999
- const reusable = oldContainers.size === 1 && onlyContainer !== void 0 && onlyContainer.localName === (group.kind === "link" ? "hyperlink" : group.kind === "control" ? "sdt" : "fldSimple") && base?.slice(start, index).every((run) => sameGroup(run && containerGroup(run), group)) === true;
23131
+ const reusable = oldContainers.size === 1 && onlyContainer !== void 0 && onlyContainer.localName === (group2.kind === "link" ? "hyperlink" : group2.kind === "control" ? "sdt" : "fldSimple") && base?.slice(start, index).every((run) => sameGroup(run && containerGroup(run), group2)) === true;
22000
23132
  let container;
22001
23133
  let target;
22002
- if (reusable && group.kind === "control") {
23134
+ if (reusable && group2.kind === "control") {
22003
23135
  container = onlyContainer;
22004
- target = resetContentControl(doc, container, group.control);
23136
+ target = resetContentControl(doc, container, group2.control);
22005
23137
  } else if (reusable) {
22006
23138
  container = onlyContainer;
22007
23139
  for (const child4 of Array.from(container.childNodes)) container.removeChild(child4);
22008
- } else if (group.kind === "control") {
22009
- const created = createContentControl(doc, group.control);
23140
+ } else if (group2.kind === "control") {
23141
+ const created = createContentControl(doc, group2.control);
22010
23142
  container = created.sdt;
22011
23143
  target = created.content;
22012
- } else if (group.kind === "link") container = newHyperlink(doc, group.link, allocator);
23144
+ } else if (group2.kind === "link") container = newHyperlink(doc, group2.link, allocator);
22013
23145
  else {
22014
23146
  container = makeW(doc, "fldSimple");
22015
- setW6(container, "instr", ` ${group.instr} `);
23147
+ setW6(container, "instr", ` ${group2.instr} `);
22016
23148
  }
22017
- if (group.kind === "simpleField") writeFieldFlags(container, runAt(start).fieldFlags);
22018
- const edges = group.kind === "simpleField" ? takeSimpleFieldCommentEdges(doc, runs, start, index, opens, closes) : { before: [], after: [] };
23149
+ if (group2.kind === "simpleField") writeFieldFlags(container, runAt(start).fieldFlags);
23150
+ const edges = group2.kind === "simpleField" ? takeSimpleFieldCommentEdges(doc, runs, start, index, opens, closes) : { before: [], after: [] };
22019
23151
  for (let item = start; item < index; item++)
22020
23152
  for (const node of nodesFor(item)) (target ?? container).appendChild(node);
22021
23153
  output.push(...edges.before, container, ...edges.after);
@@ -22824,37 +23956,37 @@ function validateSection(c2, section) {
22824
23956
  }
22825
23957
  }
22826
23958
  function validateNumberingCatalog(c2, catalog) {
22827
- const levelOf = (at, level) => {
22828
- at.enum("numFmt", level.numFmt, isStNumberFormat, "ST_NumberFormat");
22829
- at.signed("start", level.start, "ST_DecimalNumber");
22830
- at.unsigned("level", level.level, "ST_DecimalNumber");
23959
+ const levelOf = (at, level2) => {
23960
+ at.enum("numFmt", level2.numFmt, isStNumberFormat, "ST_NumberFormat");
23961
+ at.signed("start", level2.start, "ST_DecimalNumber");
23962
+ at.unsigned("level", level2.level, "ST_DecimalNumber");
22831
23963
  at.check(
22832
23964
  "lvlJc",
22833
- level.lvlJc,
23965
+ level2.lvlJc,
22834
23966
  (v) => v === "left" || v === "center" || v === "right",
22835
23967
  'must be "left", "center" or "right"'
22836
23968
  );
22837
23969
  at.check(
22838
23970
  "suffix",
22839
- level.suffix,
23971
+ level2.suffix,
22840
23972
  (v) => v === "tab" || v === "space" || v === "none",
22841
23973
  'must be "tab", "space" or "none"'
22842
23974
  );
22843
- at.check("lvlText", level.lvlText, (v) => typeof v === "string", "must be a string");
23975
+ at.check("lvlText", level2.lvlText, (v) => typeof v === "string", "must be a string");
22844
23976
  at.check(
22845
23977
  "paragraphStyleId",
22846
- level.paragraphStyleId,
23978
+ level2.paragraphStyleId,
22847
23979
  (v) => typeof v === "string" && v.length > 0,
22848
23980
  "must be a nonempty style ID"
22849
23981
  );
22850
- at.signed("indentLeftTwips", level.indentLeftTwips, "ST_SignedTwipsMeasure");
22851
- at.unsigned("hangingTwips", level.hangingTwips, "ST_TwipsMeasure");
22852
- at.unsigned("firstLineTwips", level.firstLineTwips, "ST_TwipsMeasure");
22853
- at.unsigned("lvlRestart", level.lvlRestart, "ST_DecimalNumber");
23982
+ at.signed("indentLeftTwips", level2.indentLeftTwips, "ST_SignedTwipsMeasure");
23983
+ at.unsigned("hangingTwips", level2.hangingTwips, "ST_TwipsMeasure");
23984
+ at.unsigned("firstLineTwips", level2.firstLineTwips, "ST_TwipsMeasure");
23985
+ at.unsigned("lvlRestart", level2.lvlRestart, "ST_DecimalNumber");
22854
23986
  };
22855
23987
  for (const [id, abstract] of Object.entries(catalog.abstractNums))
22856
- for (const [key, level] of Object.entries(abstract.levels))
22857
- levelOf(new Checker(c2.issues, `${c2.path}.abstractNums[${id}].levels[${key}]`), level);
23988
+ for (const [key, level2] of Object.entries(abstract.levels))
23989
+ levelOf(new Checker(c2.issues, `${c2.path}.abstractNums[${id}].levels[${key}]`), level2);
22858
23990
  for (const [id, num] of Object.entries(catalog.nums))
22859
23991
  for (const [key, override] of Object.entries(num.levelOverrides ?? {})) {
22860
23992
  const at = new Checker(c2.issues, `${c2.path}.nums[${id}].levelOverrides[${key}]`);
@@ -22989,14 +24121,14 @@ function parseMarkerFormat(rPr) {
22989
24121
  return Object.keys(format).length ? format : void 0;
22990
24122
  }
22991
24123
  function parseNumberingLevel(lvl) {
22992
- const level = integer2(getW(lvl, "ilvl"), 0);
24124
+ const level2 = integer2(getW(lvl, "ilvl"), 0);
22993
24125
  const start = clampStart(integer2(getW(first2(lvl, "start"), "val"), 1));
22994
24126
  const numFmt = enumValue(isStNumberFormat, getW(first2(lvl, "numFmt"), "val"), "w:numFmt") ?? "decimal";
22995
24127
  const lvlText = getW(first2(lvl, "lvlText"), "val") ?? "";
22996
24128
  const jc = getW(first2(lvl, "lvlJc"), "val");
22997
24129
  const ind = first2(first2(lvl, "pPr"), "ind");
22998
24130
  const suffRaw = getW(first2(lvl, "suff"), "val");
22999
- const result = { level, start, numFmt, lvlText };
24131
+ const result = { level: level2, start, numFmt, lvlText };
23000
24132
  if (!first2(lvl, "start")) result.startWasOmitted = true;
23001
24133
  const paragraphStyleId = getW(first2(lvl, "pStyle"), "val");
23002
24134
  if (paragraphStyleId) result.paragraphStyleId = paragraphStyleId;
@@ -23035,13 +24167,13 @@ function parseNum(element) {
23035
24167
  const abstractNumId = getW(first2(element, "abstractNumId"), "val") ?? "";
23036
24168
  const levelOverrides = dictionary();
23037
24169
  for (const override of children2(element, "lvlOverride")) {
23038
- const level = integer2(getW(override, "ilvl"), 0);
24170
+ const level2 = integer2(getW(override, "ilvl"), 0);
23039
24171
  const entry2 = {};
23040
24172
  const startOverride = getW(first2(override, "startOverride"), "val");
23041
24173
  if (startOverride !== void 0) entry2.startOverride = clampStart(integer2(startOverride, 1));
23042
24174
  const lvl = first2(override, "lvl");
23043
24175
  if (lvl) entry2.lvl = parseNumberingLevel(lvl);
23044
- if (Object.keys(entry2).length) levelOverrides[level] = entry2;
24176
+ if (Object.keys(entry2).length) levelOverrides[level2] = entry2;
23045
24177
  }
23046
24178
  return {
23047
24179
  id,
@@ -23075,11 +24207,11 @@ function parseNumberingCatalog(xml) {
23075
24207
  }
23076
24208
  return { abstractNums, nums, warnings: [...new Set(warnings)] };
23077
24209
  }
23078
- function resolveNumberingLevel(catalog, numId, level) {
24210
+ function resolveNumberingLevel(catalog, numId, level2) {
23079
24211
  const num = own(catalog.nums, numId);
23080
24212
  if (!num) return void 0;
23081
- const override = num.levelOverrides?.[level];
23082
- const sourceAbstract = own(catalog.abstractNums, num.abstractNumId)?.levels[level];
24213
+ const override = num.levelOverrides?.[level2];
24214
+ const sourceAbstract = own(catalog.abstractNums, num.abstractNumId)?.levels[level2];
23083
24215
  const abstract = sourceAbstract?.startWasOmitted && sourceAbstract.start === 1 ? { ...sourceAbstract, start: 0 } : sourceAbstract;
23084
24216
  let base = override?.lvl ?? abstract;
23085
24217
  if (!base) return void 0;
@@ -23100,20 +24232,20 @@ function resolveNumberingLevel(catalog, numId, level) {
23100
24232
  }
23101
24233
 
23102
24234
  // docx/numbering-start-edit.ts
23103
- function assertListStartValue(level, start) {
23104
- if (!Number.isInteger(level) || level < 0 || level > 8)
24235
+ function assertListStartValue(level2, start) {
24236
+ if (!Number.isInteger(level2) || level2 < 0 || level2 > 8)
23105
24237
  throw new Error("List level must be an integer from 0 through 8.");
23106
24238
  if (!Number.isInteger(start) || start < 0 || start > 2147483647)
23107
24239
  throw new Error("List start must be an integer from 0 through 2147483647.");
23108
24240
  }
23109
- function setListStartOverride(catalog, numId, level, start) {
23110
- assertListStartValue(level, start);
24241
+ function setListStartOverride(catalog, numId, level2, start) {
24242
+ assertListStartValue(level2, start);
23111
24243
  if (!Number.isSafeInteger(numId) || numId <= 0) throw new Error("Invalid list instance id.");
23112
24244
  const id = String(numId);
23113
24245
  const num = catalog.nums[id];
23114
- if (!num || !resolveNumberingLevel(catalog, id, level))
24246
+ if (!num || !resolveNumberingLevel(catalog, id, level2))
23115
24247
  throw new Error("List instance or level does not exist.");
23116
- const override = num.levelOverrides?.[level];
24248
+ const override = num.levelOverrides?.[level2];
23117
24249
  if (override?.lvl) throw new Error("Changing starts with a full level override is unsupported.");
23118
24250
  if (override?.startOverride === start) return catalog;
23119
24251
  return {
@@ -23124,7 +24256,7 @@ function setListStartOverride(catalog, numId, level, start) {
23124
24256
  ...num,
23125
24257
  levelOverrides: {
23126
24258
  ...num.levelOverrides,
23127
- [level]: { ...override, startOverride: start }
24259
+ [level2]: { ...override, startOverride: start }
23128
24260
  }
23129
24261
  }
23130
24262
  }
@@ -23135,9 +24267,9 @@ function setListStartOverride(catalog, numId, level, start) {
23135
24267
  function withoutStarts(num) {
23136
24268
  const { levelOverrides, ...properties2 } = num;
23137
24269
  const kept = {};
23138
- for (const [level, override] of Object.entries(levelOverrides ?? {})) {
24270
+ for (const [level2, override] of Object.entries(levelOverrides ?? {})) {
23139
24271
  const { startOverride: _start, ...rest } = override;
23140
- if (Object.keys(rest).length) kept[level] = rest;
24272
+ if (Object.keys(rest).length) kept[level2] = rest;
23141
24273
  }
23142
24274
  return { ...properties2, ...Object.keys(kept).length ? { levelOverrides: kept } : {} };
23143
24275
  }
@@ -23153,18 +24285,18 @@ function numberingStartChanges(prior, next) {
23153
24285
  ...Object.keys(previous.levelOverrides ?? {}),
23154
24286
  ...Object.keys(current.levelOverrides ?? {})
23155
24287
  ])) {
23156
- const level = Number(key);
23157
- const old = previous.levelOverrides?.[level];
23158
- const value = current.levelOverrides?.[level];
24288
+ const level2 = Number(key);
24289
+ const old = previous.levelOverrides?.[level2];
24290
+ const value = current.levelOverrides?.[level2];
23159
24291
  if (old?.startOverride === value?.startOverride) continue;
23160
24292
  if (value?.startOverride === void 0)
23161
24293
  throw new Error("Removing a list start override is unsupported.");
23162
- assertListStartValue(level, value.startOverride);
23163
- if (String(level) !== key || !prior || !resolveNumberingLevel(prior, id, level))
24294
+ assertListStartValue(level2, value.startOverride);
24295
+ if (String(level2) !== key || !prior || !resolveNumberingLevel(prior, id, level2))
23164
24296
  throw new Error("List instance or level does not exist.");
23165
24297
  if (old?.lvl || value.lvl)
23166
24298
  throw new Error("Changing starts with a full level override is unsupported.");
23167
- changes.push({ numId: id, level, start: value.startOverride });
24299
+ changes.push({ numId: id, level: level2, start: value.startOverride });
23168
24300
  }
23169
24301
  }
23170
24302
  return changes;
@@ -23271,17 +24403,17 @@ function buildAbstractNumElement(doc, def) {
23271
24403
  const element = makeW(doc, "abstractNum");
23272
24404
  setAttribute8(element, "abstractNumId", def.id);
23273
24405
  element.appendChild(valueElement(doc, "multiLevelType", "hybridMultilevel"));
23274
- for (const level of Object.values(def.levels).sort((a2, b) => a2.level - b.level))
23275
- element.appendChild(buildLevelElement(doc, level));
24406
+ for (const level2 of Object.values(def.levels).sort((a2, b) => a2.level - b.level))
24407
+ element.appendChild(buildLevelElement(doc, level2));
23276
24408
  return element;
23277
24409
  }
23278
24410
  function buildNumElement(doc, def) {
23279
24411
  const element = makeW(doc, "num");
23280
24412
  setAttribute8(element, "numId", def.id);
23281
24413
  element.appendChild(valueElement(doc, "abstractNumId", def.abstractNumId));
23282
- for (const [level, override] of Object.entries(def.levelOverrides ?? {})) {
24414
+ for (const [level2, override] of Object.entries(def.levelOverrides ?? {})) {
23283
24415
  const lvlOverride = makeW(doc, "lvlOverride");
23284
- setAttribute8(lvlOverride, "ilvl", level);
24416
+ setAttribute8(lvlOverride, "ilvl", level2);
23285
24417
  if (override.startOverride !== void 0)
23286
24418
  lvlOverride.appendChild(valueElement(doc, "startOverride", String(override.startOverride)));
23287
24419
  if (override.lvl) lvlOverride.appendChild(buildLevelElement(doc, override.lvl));
@@ -23355,11 +24487,11 @@ function setNumPr(style, numbering) {
23355
24487
  for (const existing of children2(pPr, "numPr")) pPr.removeChild(existing);
23356
24488
  if (numbering) {
23357
24489
  const numPr = makeW(doc, "numPr");
23358
- const level = makeW(doc, "ilvl");
23359
- level.setAttributeNS(WORD_NS, "w:val", String(numbering.level));
24490
+ const level2 = makeW(doc, "ilvl");
24491
+ level2.setAttributeNS(WORD_NS, "w:val", String(numbering.level));
23360
24492
  const id = makeW(doc, "numId");
23361
24493
  id.setAttributeNS(WORD_NS, "w:val", String(numbering.numId));
23362
- numPr.appendChild(level);
24494
+ numPr.appendChild(level2);
23363
24495
  numPr.appendChild(id);
23364
24496
  pPr.appendChild(numPr);
23365
24497
  }
@@ -23440,9 +24572,9 @@ var PART_KINDS = {
23440
24572
  headers: { root: "hdr", relation: "header", contentType: "header" },
23441
24573
  footers: { root: "ftr", relation: "footer", contentType: "footer" }
23442
24574
  };
23443
- function partContents(sections) {
24575
+ function partContents(sections2) {
23444
24576
  const parts = /* @__PURE__ */ new Map();
23445
- for (const section of sections ?? [])
24577
+ for (const section of sections2 ?? [])
23446
24578
  for (const kind of KINDS)
23447
24579
  for (const content of Object.values(
23448
24580
  section[kind] ?? {}
@@ -24651,14 +25783,14 @@ function parseOneSection(section, endsAtBlockId) {
24651
25783
  };
24652
25784
  }
24653
25785
  function parseRawSections(body, blocks) {
24654
- const sections = [];
25786
+ const sections2 = [];
24655
25787
  let position2 = 0;
24656
25788
  for (const node of Array.from(body.childNodes).filter(isElement)) {
24657
25789
  if (named2(node, "p")) {
24658
25790
  const sectPr = first2(first2(node, "pPr"), "sectPr");
24659
25791
  if (sectPr) {
24660
25792
  const blockId = blocks[position2]?.id;
24661
- if (blockId) sections.push(parseOneSection(sectPr, blockId));
25793
+ if (blockId) sections2.push(parseOneSection(sectPr, blockId));
24662
25794
  }
24663
25795
  position2++;
24664
25796
  } else if (named2(node, "tbl")) {
@@ -24668,9 +25800,9 @@ function parseRawSections(body, blocks) {
24668
25800
  const finalSectPr = children2(body, "sectPr").at(-1);
24669
25801
  if (finalSectPr) {
24670
25802
  const lastBlockId = blocks.at(-1)?.id;
24671
- if (lastBlockId) sections.push(parseOneSection(finalSectPr, lastBlockId));
25803
+ if (lastBlockId) sections2.push(parseOneSection(finalSectPr, lastBlockId));
24672
25804
  }
24673
- return sections;
25805
+ return sections2;
24674
25806
  }
24675
25807
 
24676
25808
  // docx/cell-blocks.ts
@@ -24878,7 +26010,7 @@ async function parseDocumentParts(zip, body, blocks, drawings) {
24878
26010
  const settings = withParseWarnings(warnings, () => parseSettings(settingsXml));
24879
26011
  const cache = /* @__PURE__ */ new Map();
24880
26012
  const fieldMarkup = { seen: false };
24881
- const sections = [];
26013
+ const sections2 = [];
24882
26014
  for (const { headerRefs, footerRefs, ...rest } of raw) {
24883
26015
  const headers = await resolveSlots(
24884
26016
  zip,
@@ -24898,7 +26030,7 @@ async function parseDocumentParts(zip, body, blocks, drawings) {
24898
26030
  drawings,
24899
26031
  warnings
24900
26032
  );
24901
- sections.push({ ...rest, ...headers ? { headers } : {}, ...footers ? { footers } : {} });
26033
+ sections2.push({ ...rest, ...headers ? { headers } : {}, ...footers ? { footers } : {} });
24902
26034
  }
24903
26035
  const footnotesXml = await readPart(zip, "word/footnotes.xml");
24904
26036
  const endnotesXml = await readPart(zip, "word/endnotes.xml");
@@ -24909,7 +26041,7 @@ async function parseDocumentParts(zip, body, blocks, drawings) {
24909
26041
  const footnotes = footnotesXml ? parseNotesPart(footnotesXml, "footnote", await notesParser("word/footnotes.xml")) : void 0;
24910
26042
  const footnoteSeparators = footnotesXml ? parseFootnoteSeparators(footnotesXml, await notesParser("word/footnotes.xml")) : void 0;
24911
26043
  const endnotes = endnotesXml ? parseNotesPart(endnotesXml, "endnote", await notesParser("word/endnotes.xml")) : void 0;
24912
- if (sections.some((section) => section.columns.count > 1))
26044
+ if (sections2.some((section) => section.columns.count > 1))
24913
26045
  warnings.push(
24914
26046
  "Columns render in Print Layout and, for single-section documents, on the editing surface; column breaks balance approximately."
24915
26047
  );
@@ -24918,7 +26050,7 @@ async function parseDocumentParts(zip, body, blocks, drawings) {
24918
26050
  "PAGE, NUMPAGES, SECTIONPAGES, DATE and TIME fields are recalculated in Print Layout; other fields show the result Word last saved. Field results are editable and field codes are preserved."
24919
26051
  );
24920
26052
  return {
24921
- sections,
26053
+ sections: sections2,
24922
26054
  ...settings.compatibilityMode !== void 0 ? { compatibilityMode: settings.compatibilityMode } : {},
24923
26055
  ...footnotes ? { footnotes } : {},
24924
26056
  ...footnoteSeparators ? { footnoteSeparators } : {},
@@ -25416,10 +26548,10 @@ function resolveParagraphNumbering(paragraph, styleCatalog, numberingCatalog) {
25416
26548
  const inherited = resolveStyleNumbering(paragraph.style, styleCatalog);
25417
26549
  if (!inherited || inherited.numId <= 0) return void 0;
25418
26550
  if (numberingCatalog && paragraph.style && styleCatalog.styles[paragraph.style]) {
25419
- for (let level = 0; level < 9; level++) {
25420
- const definition = resolveNumberingLevel(numberingCatalog, String(inherited.numId), level);
26551
+ for (let level2 = 0; level2 < 9; level2++) {
26552
+ const definition = resolveNumberingLevel(numberingCatalog, String(inherited.numId), level2);
25421
26553
  if (definition?.paragraphStyleId === paragraph.style)
25422
- return { numId: inherited.numId, level };
26554
+ return { numId: inherited.numId, level: level2 };
25423
26555
  }
25424
26556
  }
25425
26557
  return inherited;
@@ -25452,23 +26584,23 @@ var NumberingCounters = class {
25452
26584
  return started;
25453
26585
  }
25454
26586
  /** Advances one level and resets deeper counters according to their resolved restart rules. */
25455
- advance(numId, level, def, catalog) {
26587
+ advance(numId, level2, def, catalog) {
25456
26588
  const counts = this.forNum(numId);
25457
26589
  const started = this.startedLevels(numId);
25458
- const next = started.has(level) ? (counts.get(level) ?? def.start) + 1 : def.start;
25459
- counts.set(level, next);
25460
- started.add(level);
26590
+ const next = started.has(level2) ? (counts.get(level2) ?? def.start) + 1 : def.start;
26591
+ counts.set(level2, next);
26592
+ started.add(level2);
25461
26593
  for (const deeper of [...started]) {
25462
- if (deeper <= level) continue;
26594
+ if (deeper <= level2) continue;
25463
26595
  const deeperDef = resolveNumberingLevel(catalog, numId, deeper);
25464
26596
  const restart = deeperDef?.lvlRestart;
25465
26597
  if (restart === 0) continue;
25466
26598
  const trigger = restart !== void 0 && restart > 0 && restart <= deeper ? restart - 1 : deeper - 1;
25467
- if (level > trigger) continue;
26599
+ if (level2 > trigger) continue;
25468
26600
  counts.delete(deeper);
25469
26601
  started.delete(deeper);
25470
26602
  }
25471
- for (let ancestor = 0; ancestor < level; ancestor++) {
26603
+ for (let ancestor = 0; ancestor < level2; ancestor++) {
25472
26604
  if (started.has(ancestor)) continue;
25473
26605
  const ancestorDef = resolveNumberingLevel(catalog, numId, ancestor);
25474
26606
  if (!ancestorDef) continue;
@@ -25478,14 +26610,14 @@ var NumberingCounters = class {
25478
26610
  return next;
25479
26611
  }
25480
26612
  /** Current value for an ancestor placeholder, defaulting to its own start when never instantiated. */
25481
- current(numId, level, start) {
25482
- return this.forNum(numId).get(level) ?? start;
26613
+ current(numId, level2, start) {
26614
+ return this.forNum(numId).get(level2) ?? start;
25483
26615
  }
25484
26616
  };
25485
- function substituteLvlText(lvlText, numId, level, catalog, counters, forceDecimal) {
26617
+ function substituteLvlText(lvlText, numId, level2, catalog, counters, forceDecimal) {
25486
26618
  return lvlText.replace(/%([1-9])/g, (match, digit) => {
25487
26619
  const ancestorLevel = Number(digit) - 1;
25488
- if (ancestorLevel > level) return match;
26620
+ if (ancestorLevel > level2) return match;
25489
26621
  const ancestorDef = resolveNumberingLevel(catalog, numId, ancestorLevel);
25490
26622
  const start = ancestorDef?.start ?? 1;
25491
26623
  const value = counters.current(numId, ancestorLevel, start);
@@ -25502,15 +26634,15 @@ function computeListLabels(model) {
25502
26634
  const numbering = resolveParagraphNumbering(paragraph, model.paragraphStyles, catalog);
25503
26635
  if (!numbering) continue;
25504
26636
  const numId = String(numbering.numId);
25505
- const level = Math.min(8, Math.max(0, numbering.level));
25506
- const def = resolveNumberingLevel(catalog, numId, level);
26637
+ const level2 = Math.min(8, Math.max(0, numbering.level));
26638
+ const def = resolveNumberingLevel(catalog, numId, level2);
25507
26639
  if (!def) continue;
25508
26640
  if (def.numFmt === "none") continue;
25509
- counters.advance(numId, level, def, catalog);
25510
- const text3 = def.numFmt === "bullet" ? def.lvlText : substituteLvlText(def.lvlText, numId, level, catalog, counters, Boolean(def.isLgl));
26641
+ counters.advance(numId, level2, def, catalog);
26642
+ const text3 = def.numFmt === "bullet" ? def.lvlText : substituteLvlText(def.lvlText, numId, level2, catalog, counters, Boolean(def.isLgl));
25511
26643
  labels.set(paragraph.id, {
25512
26644
  numId,
25513
- level,
26645
+ level: level2,
25514
26646
  text: text3,
25515
26647
  suffix: def.suffix ?? "tab",
25516
26648
  ...definedProps({
@@ -25543,9 +26675,9 @@ function displayListLabel(text3) {
25543
26675
  // docx/heading-list-kinds.ts
25544
26676
  var SPECS = {
25545
26677
  // 1 Heading 1 / 1.1 Heading 2 / 1.1.1 Heading 3 ...
25546
- headings: Array.from({ length: 9 }, (_, level) => [
26678
+ headings: Array.from({ length: 9 }, (_, level2) => [
25547
26679
  "decimal",
25548
- Array.from({ length: level + 1 }, (_2, i) => `%${i + 1}`).join(".")
26680
+ Array.from({ length: level2 + 1 }, (_2, i) => `%${i + 1}`).join(".")
25549
26681
  ]),
25550
26682
  // Article I. / Section 1.1 (Arabic) / (a) / (i)
25551
26683
  article: [
@@ -25574,15 +26706,15 @@ var SPECS = {
25574
26706
  };
25575
26707
  var isHeadingListKind = (value) => value in SPECS;
25576
26708
  function headingListLevels(kind) {
25577
- return SPECS[kind].map(([numFmt, lvlText, legal], level) => {
25578
- const indent = 432 + 144 * level;
26709
+ return SPECS[kind].map(([numFmt, lvlText, legal], level2) => {
26710
+ const indent = 432 + 144 * level2;
25579
26711
  return {
25580
- level,
26712
+ level: level2,
25581
26713
  start: 1,
25582
26714
  numFmt,
25583
26715
  lvlText,
25584
26716
  ...legal ? { isLgl: true } : {},
25585
- paragraphStyleId: `Heading${level + 1}`,
26717
+ paragraphStyleId: `Heading${level2 + 1}`,
25586
26718
  indentLeftTwips: signedTwips(indent),
25587
26719
  hangingTwips: twips(indent),
25588
26720
  suffix: "tab"
@@ -25596,19 +26728,19 @@ var OUTLINE_FORMATS = [
25596
26728
  ["lowerLetter", ")"],
25597
26729
  ["lowerRoman", "."]
25598
26730
  ];
25599
- function levelText(kind, level) {
26731
+ function levelText(kind, level2) {
25600
26732
  if (kind === "bullet")
25601
- return expectDefined(BULLET_GLYPHS[level % BULLET_GLYPHS.length], "bullet glyph");
26733
+ return expectDefined(BULLET_GLYPHS[level2 % BULLET_GLYPHS.length], "bullet glyph");
25602
26734
  if (kind === "multilevel")
25603
- return `${Array.from({ length: level + 1 }, (_, i) => `%${i + 1}`).join(".")}.`;
25604
- const [, close] = expectDefined(OUTLINE_FORMATS[level % 3], "outline format");
25605
- return `%${level + 1}${close}`;
26735
+ return `${Array.from({ length: level2 + 1 }, (_, i) => `%${i + 1}`).join(".")}.`;
26736
+ const [, close] = expectDefined(OUTLINE_FORMATS[level2 % 3], "outline format");
26737
+ return `%${level2 + 1}${close}`;
25606
26738
  }
25607
- function levelFormat(kind, level) {
26739
+ function levelFormat(kind, level2) {
25608
26740
  if (kind === "bullet") return "bullet";
25609
26741
  if (kind === "decimal")
25610
- return expectDefined(DECIMAL_FORMATS[level % DECIMAL_FORMATS.length], "decimal format");
25611
- return kind === "multilevel" ? "decimal" : expectDefined(OUTLINE_FORMATS[level % 3], "outline format")[0];
26742
+ return expectDefined(DECIMAL_FORMATS[level2 % DECIMAL_FORMATS.length], "decimal format");
26743
+ return kind === "multilevel" ? "decimal" : expectDefined(OUTLINE_FORMATS[level2 % 3], "outline format")[0];
25612
26744
  }
25613
26745
  var BULLET_GLYPHS = ["\u2022", "\u25E6", "\u25AA"];
25614
26746
  var DECIMAL_FORMATS = ["decimal", "lowerLetter", "lowerRoman"];
@@ -25621,17 +26753,17 @@ function nextId(ids, floor) {
25621
26753
  }
25622
26754
  function buildLevels(kind) {
25623
26755
  const levels = {};
25624
- for (let level = 0; level < 9; level++) {
26756
+ for (let level2 = 0; level2 < 9; level2++) {
25625
26757
  const base = {
25626
- level,
26758
+ level: level2,
25627
26759
  start: 1,
25628
- numFmt: levelFormat(kind, level),
25629
- lvlText: kind === "decimal" ? `%${level + 1}.` : levelText(kind, level),
25630
- indentLeftTwips: signedTwips(720 * (level + 1)),
26760
+ numFmt: levelFormat(kind, level2),
26761
+ lvlText: kind === "decimal" ? `%${level2 + 1}.` : levelText(kind, level2),
26762
+ indentLeftTwips: signedTwips(720 * (level2 + 1)),
25631
26763
  hangingTwips: twips(kind === "multilevel" ? 720 : 360),
25632
26764
  suffix: "tab"
25633
26765
  };
25634
- levels[level] = base;
26766
+ levels[level2] = base;
25635
26767
  }
25636
26768
  return levels;
25637
26769
  }
@@ -25639,9 +26771,9 @@ function ensureListDefinition(catalog, kind) {
25639
26771
  return createListDefinition(catalog, Object.values(buildLevels(kind)));
25640
26772
  }
25641
26773
  function createListDefinition(catalog, levels) {
25642
- if (!levels.length || levels.length > 9 || new Set(levels.map((level) => level.level)).size !== levels.length || levels.some((level) => !Number.isInteger(level.level) || level.level < 0 || level.level > 8))
26774
+ if (!levels.length || levels.length > 9 || new Set(levels.map((level2) => level2.level)).size !== levels.length || levels.some((level2) => !Number.isInteger(level2.level) || level2.level < 0 || level2.level > 8))
25643
26775
  throw new Error("A list must have 1 to 9 distinct levels numbered 0 through 8.");
25644
- const copied = Object.fromEntries(levels.map((level) => [level.level, { ...level }]));
26776
+ const copied = Object.fromEntries(levels.map((level2) => [level2.level, { ...level2 }]));
25645
26777
  const issues = [];
25646
26778
  validateNumberingCatalog(new Checker(issues, "numberingCatalog"), {
25647
26779
  abstractNums: { "0": { id: "0", levels: copied } },
@@ -25661,9 +26793,9 @@ function createListDefinition(catalog, levels) {
25661
26793
  function linkStylesToList(styles, levels, numId) {
25662
26794
  if (!styles) return styles;
25663
26795
  const next = { ...styles, styles: { ...styles.styles } };
25664
- for (const level of levels) {
25665
- const style = level.paragraphStyleId ? next.styles[level.paragraphStyleId] : void 0;
25666
- if (style) next.styles[style.id] = { ...style, numbering: { numId, level: level.level } };
26796
+ for (const level2 of levels) {
26797
+ const style = level2.paragraphStyleId ? next.styles[level2.paragraphStyleId] : void 0;
26798
+ if (style) next.styles[style.id] = { ...style, numbering: { numId, level: level2.level } };
25667
26799
  }
25668
26800
  return next;
25669
26801
  }
@@ -25935,7 +27067,7 @@ function datePicture(instr) {
25935
27067
  }
25936
27068
  var TOKENS = /yyyy|yy|MMMM|MMM|MM|M|dddd|ddd|dd|d|HH|H|hh|h|mm|ss|am\/pm|AM\/PM|'[^']*'/g;
25937
27069
  function formatWordDate(date, picture, locale = "en-US") {
25938
- const name = (options) => new Intl.DateTimeFormat(locale, options).format(date);
27070
+ const name = (options2) => new Intl.DateTimeFormat(locale, options2).format(date);
25939
27071
  const pad = (value) => String(value).padStart(2, "0");
25940
27072
  const hours12 = date.getHours() % 12 || 12;
25941
27073
  return picture.replace(TOKENS, (token) => {
@@ -25993,9 +27125,9 @@ function styleMap(instruction) {
25993
27125
  const parts = (match?.[1] ?? match?.[2] ?? "").split(/[,;]/).map((part) => part.trim());
25994
27126
  for (let i = 0; i + 1 < parts.length; i += 2) {
25995
27127
  const name = parts[i];
25996
- const level = Number(parts[i + 1]);
25997
- if (name && Number.isInteger(level) && level >= 1 && level <= 9)
25998
- map.set(name.toLowerCase(), level);
27128
+ const level2 = Number(parts[i + 1]);
27129
+ if (name && Number.isInteger(level2) && level2 >= 1 && level2 <= 9)
27130
+ map.set(name.toLowerCase(), level2);
25999
27131
  }
26000
27132
  return map;
26001
27133
  }
@@ -26061,14 +27193,14 @@ function tocEntries(model, instruction = DEFAULT_TOC_INSTRUCTION) {
26061
27193
  const entries = [];
26062
27194
  for (const block of model.blocks) {
26063
27195
  if (block.type !== "paragraph") continue;
26064
- const level = entryLevel(block, model.paragraphStyles, switches);
27196
+ const level2 = entryLevel(block, model.paragraphStyles, switches);
26065
27197
  const text3 = plainText(block);
26066
- if (level !== void 0 && text3) entries.push({ level, text: text3, blockId: block.id });
27198
+ if (level2 !== void 0 && text3) entries.push({ level: level2, text: text3, blockId: block.id });
26067
27199
  }
26068
27200
  return entries;
26069
27201
  }
26070
27202
  function entryLevel(paragraph, catalog, switches) {
26071
- const inRange = (level) => level !== void 0 && level >= switches.from && level <= switches.to ? level : void 0;
27203
+ const inRange = (level2) => level2 !== void 0 && level2 >= switches.from && level2 <= switches.to ? level2 : void 0;
26072
27204
  if (switches.styles.size > 0 && paragraph.style) {
26073
27205
  const name = catalog?.styles[paragraph.style]?.name;
26074
27206
  const mapped = switches.styles.get(paragraph.style.toLowerCase()) ?? (name ? switches.styles.get(name.toLowerCase()) : void 0);
@@ -26142,25 +27274,25 @@ function withTocBookmarks(model, added) {
26142
27274
  )
26143
27275
  };
26144
27276
  }
26145
- function buildTableOfContents(model, options) {
26146
- const instruction = options.instruction ?? DEFAULT_TOC_INSTRUCTION;
27277
+ function buildTableOfContents(model, options2) {
27278
+ const instruction = options2.instruction ?? DEFAULT_TOC_INSTRUCTION;
26147
27279
  const field = { instr: instruction.trim() };
26148
- const width = options.contentWidthTwips ?? twips(9360);
27280
+ const width = options2.contentWidthTwips ?? twips(9360);
26149
27281
  const styles = model.paragraphStyles?.styles ?? {};
26150
27282
  const entries = tocEntries(model, instruction);
26151
27283
  const figures = tocCaptionLabel(instruction) !== void 0;
26152
27284
  const paragraphs = (entries.length ? entries : [void 0]).map((entry2) => {
26153
- const level = entry2?.level ?? 1;
26154
- const style = figures ? "TableofFigures" : `TOC${level}`;
26155
- const page = entry2 ? options.pageNumbers?.get(entry2.blockId) : void 0;
26156
- const bookmark = entry2 ? options.bookmarks?.get(entry2.blockId) : void 0;
27285
+ const level2 = entry2?.level ?? 1;
27286
+ const style = figures ? "TableofFigures" : `TOC${level2}`;
27287
+ const page = entry2 ? options2.pageNumbers?.get(entry2.blockId) : void 0;
27288
+ const bookmark = entry2 ? options2.bookmarks?.get(entry2.blockId) : void 0;
26157
27289
  const runs = !entry2 ? [{ text: figures ? EMPTY_FIGURES_TEXT : EMPTY_TOC_TEXT, bold: true, field }] : bookmark ? linkedEntry(entry2.text, bookmark, page) : [{ text: page ? `${entry2.text} ${page}` : entry2.text, field }];
26158
27290
  return {
26159
27291
  type: "paragraph",
26160
- id: options.newId(),
27292
+ id: options2.newId(),
26161
27293
  runs,
26162
27294
  ...styles[style] ? { style } : {
26163
- ...level > 1 ? { indentLeftTwips: signedTwips((level - 1) * 220) } : {},
27295
+ ...level2 > 1 ? { indentLeftTwips: signedTwips((level2 - 1) * 220) } : {},
26164
27296
  spacingAfterTwips: twips(100)
26165
27297
  },
26166
27298
  tabStops: [{ posTwips: width, align: "right", leader: "dot" }]
@@ -26199,12 +27331,12 @@ function findTableOfContents(blocks, accepts = (instruction) => tocCaptionLabel(
26199
27331
  }
26200
27332
  return void 0;
26201
27333
  }
26202
- function updateTableOfContents(model, options) {
27334
+ function updateTableOfContents(model, options2) {
26203
27335
  const found = findTableOfContents(model.blocks);
26204
27336
  if (!found) return void 0;
26205
27337
  const linked = tocHyperlinks(found.instruction) ? tocBookmarks(model, tocEntries(model, found.instruction)) : void 0;
26206
27338
  const rebuilt = buildTableOfContents(model, {
26207
- ...options,
27339
+ ...options2,
26208
27340
  instruction: found.instruction,
26209
27341
  ...linked ? { bookmarks: linked.bookmarks } : {}
26210
27342
  });
@@ -26391,9 +27523,9 @@ function parseLineSpacingValue(value) {
26391
27523
  }
26392
27524
 
26393
27525
  // docx/section-layout.ts
26394
- function sectionLayoutJson(sections) {
27526
+ function sectionLayoutJson(sections2) {
26395
27527
  return JSON.stringify(
26396
- sections.map(({ headers: _headers, footers: _footers, ...layout2 }) => layout2)
27528
+ sections2.map(({ headers: _headers, footers: _footers, ...layout2 }) => layout2)
26397
27529
  );
26398
27530
  }
26399
27531
  function sectionsFromLayout(json, prior, blocks) {
@@ -26501,13 +27633,13 @@ function transformCase(text3, mode, atSentenceStart = true) {
26501
27633
  // docx/section-edit.ts
26502
27634
  var px2 = twipsToPixels;
26503
27635
  function withSection(model, index, change) {
26504
- const sections = sectionsOf(model).map(
27636
+ const sections2 = sectionsOf(model).map(
26505
27637
  (section, position2) => position2 === index ? change(structuredClone(section)) : section
26506
27638
  );
26507
- const last = sections.at(-1);
27639
+ const last = sections2.at(-1);
26508
27640
  return {
26509
27641
  ...model,
26510
- sections,
27642
+ sections: sections2,
26511
27643
  page: {
26512
27644
  width: px2(last.pageWidthTwips),
26513
27645
  height: px2(last.pageHeightTwips),
@@ -26865,9 +27997,9 @@ var SHAPE_PALETTE = [
26865
27997
  ]
26866
27998
  }
26867
27999
  ];
26868
- var SHAPE_PALETTE_NAMES = SHAPE_PALETTE.flatMap((group) => [
26869
- group.name,
26870
- ...group.shapes.map((item) => item.name)
28000
+ var SHAPE_PALETTE_NAMES = SHAPE_PALETTE.flatMap((group2) => [
28001
+ group2.name,
28002
+ ...group2.shapes.map((item) => item.name)
26871
28003
  ]);
26872
28004
  var DEFAULT_DRAWN_SHAPE = { widthPx: 96, heightPx: 64 };
26873
28005
  var isDirectionalPreset = (preset) => /^(line|straightConnector1|bentConnector\d|curvedConnector\d)$/.test(preset);