@office-open/core 0.10.15 → 0.12.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 (93) hide show
  1. package/README.md +2 -1
  2. package/dist/chart/index.d.mts +2 -2
  3. package/dist/chart/index.mjs +2 -2
  4. package/dist/chart-DED4tXC9.mjs +2325 -0
  5. package/dist/chart-DED4tXC9.mjs.map +1 -0
  6. package/dist/color-mapping-CFF0vRSe.mjs +117 -0
  7. package/dist/color-mapping-CFF0vRSe.mjs.map +1 -0
  8. package/dist/data-type-CZMKVaaT.d.mts.map +1 -1
  9. package/dist/descriptor/index.d.mts +2 -2
  10. package/dist/descriptor/index.mjs +1 -1
  11. package/dist/{descriptor-BjNkn5jo.mjs → descriptor-BqaNZrrZ.mjs} +43 -11
  12. package/dist/{descriptor-BjNkn5jo.mjs.map → descriptor-BqaNZrrZ.mjs.map} +1 -1
  13. package/dist/drawing/index.d.mts +2 -0
  14. package/dist/drawing/index.mjs +2 -0
  15. package/dist/{drawingml-sj1J3lb0.mjs → drawing-BCAyrCCw.mjs} +4456 -3452
  16. package/dist/drawing-BCAyrCCw.mjs.map +1 -0
  17. package/dist/{converters-C_Y2QX1w.mjs → ext-uri-BHBcIrW7.mjs} +742 -45
  18. package/dist/ext-uri-BHBcIrW7.mjs.map +1 -0
  19. package/dist/index-BAxlDUQ1.d.mts +590 -0
  20. package/dist/index-BAxlDUQ1.d.mts.map +1 -0
  21. package/dist/index-BP541uS-.d.mts +489 -0
  22. package/dist/index-BP541uS-.d.mts.map +1 -0
  23. package/dist/{index-BVK2dv6C.d.mts → index-BQLIofaF.d.mts} +10 -4
  24. package/dist/index-BQLIofaF.d.mts.map +1 -0
  25. package/dist/{index-k8WKLXnA.d.mts → index-CaNwM5_e.d.mts} +19 -20
  26. package/dist/index-CaNwM5_e.d.mts.map +1 -0
  27. package/dist/index-DPkf_CtG.d.mts +1578 -0
  28. package/dist/index-DPkf_CtG.d.mts.map +1 -0
  29. package/dist/index-DcukVskh.d.mts +31 -0
  30. package/dist/index-DcukVskh.d.mts.map +1 -0
  31. package/dist/index-Di6XPdGl.d.mts +322 -0
  32. package/dist/index-Di6XPdGl.d.mts.map +1 -0
  33. package/dist/index-L6AXewfV.d.mts +872 -0
  34. package/dist/index-L6AXewfV.d.mts.map +1 -0
  35. package/dist/index.d.mts +294 -30
  36. package/dist/index.d.mts.map +1 -1
  37. package/dist/index.mjs +1327 -112
  38. package/dist/index.mjs.map +1 -1
  39. package/dist/{output-D_G_JR_8.d.mts → output-yyxdkG0C.d.mts} +2 -3
  40. package/dist/output-yyxdkG0C.d.mts.map +1 -0
  41. package/dist/patch/index.d.mts +2 -2
  42. package/dist/patch/index.mjs +2 -2
  43. package/dist/{patch-BmRfghOo.mjs → patch-AkQY17CD.mjs} +73 -28
  44. package/dist/patch-AkQY17CD.mjs.map +1 -0
  45. package/dist/smartart/index.d.mts +2 -2
  46. package/dist/smartart/index.mjs +2 -2
  47. package/dist/smartart-n1kYJ6Jg.mjs +1650 -0
  48. package/dist/smartart-n1kYJ6Jg.mjs.map +1 -0
  49. package/dist/style-matrix-B6jhPAT3.mjs +123 -0
  50. package/dist/style-matrix-B6jhPAT3.mjs.map +1 -0
  51. package/dist/theme/index.d.mts +4 -2
  52. package/dist/theme/index.mjs +4 -2
  53. package/dist/theme-BKnXRmvn.mjs +426 -0
  54. package/dist/theme-BKnXRmvn.mjs.map +1 -0
  55. package/dist/theme-options-kO89NUEX.d.mts +109 -0
  56. package/dist/theme-options-kO89NUEX.d.mts.map +1 -0
  57. package/dist/util/index.d.mts +3 -3
  58. package/dist/util/index.mjs +3 -3
  59. package/dist/{util-Tq9PSjK0.mjs → util-ptE16MEk.mjs} +237 -459
  60. package/dist/util-ptE16MEk.mjs.map +1 -0
  61. package/dist/{values-8di32lIe.d.mts → values-BECDm4zr.d.mts} +17 -31
  62. package/dist/values-BECDm4zr.d.mts.map +1 -0
  63. package/dist/vector/index.d.mts +2 -0
  64. package/dist/vector/index.mjs +2 -0
  65. package/dist/vector-DhLGZjP5.mjs +3049 -0
  66. package/dist/vector-DhLGZjP5.mjs.map +1 -0
  67. package/package.json +16 -8
  68. package/dist/chart-DIGJna_6.mjs +0 -582
  69. package/dist/chart-DIGJna_6.mjs.map +0 -1
  70. package/dist/converters-C_Y2QX1w.mjs.map +0 -1
  71. package/dist/drawingml/index.d.mts +0 -2
  72. package/dist/drawingml/index.mjs +0 -2
  73. package/dist/drawingml-sj1J3lb0.mjs.map +0 -1
  74. package/dist/index-BVK2dv6C.d.mts.map +0 -1
  75. package/dist/index-BfHfKuKy.d.mts +0 -275
  76. package/dist/index-BfHfKuKy.d.mts.map +0 -1
  77. package/dist/index-CE53SwpZ.d.mts +0 -1463
  78. package/dist/index-CE53SwpZ.d.mts.map +0 -1
  79. package/dist/index-D6VE-MnJ.d.mts +0 -43
  80. package/dist/index-D6VE-MnJ.d.mts.map +0 -1
  81. package/dist/index-DE4CLElr.d.mts +0 -145
  82. package/dist/index-DE4CLElr.d.mts.map +0 -1
  83. package/dist/index-DlPA26cw.d.mts +0 -91
  84. package/dist/index-DlPA26cw.d.mts.map +0 -1
  85. package/dist/index-k8WKLXnA.d.mts.map +0 -1
  86. package/dist/output-D_G_JR_8.d.mts.map +0 -1
  87. package/dist/patch-BmRfghOo.mjs.map +0 -1
  88. package/dist/smartart-B7ukZ-Tw.mjs +0 -305
  89. package/dist/smartart-B7ukZ-Tw.mjs.map +0 -1
  90. package/dist/theme-CiNzdl-9.mjs +0 -177
  91. package/dist/theme-CiNzdl-9.mjs.map +0 -1
  92. package/dist/util-Tq9PSjK0.mjs.map +0 -1
  93. package/dist/values-8di32lIe.d.mts.map +0 -1
@@ -0,0 +1,2325 @@
1
+ import { B as xsdAxisCrossBetween, Ct as xsdSizeRepresents, Ft as xsdTrendlineType, H as xsdAxisLabelAlignment, Tt as xsdSplitType, U as xsdAxisOrientation, V as xsdAxisCrosses, W as xsdAxisPosition, Z as xsdDataLabelPosition, Zt as parseOnOff, st as xsdLegendPosition, tt as xsdErrorValueType } from "./ext-uri-BHBcIrW7.mjs";
2
+ import { A as groupShapePropertiesDesc, N as transform2DDesc, a as textBodyDesc, dt as stringifyNonVisualDrawingProperties, hn as blipFillDesc, j as shapePropertiesDesc } from "./drawing-BCAyrCCw.mjs";
3
+ import { o as parse$1, s as stringify$1 } from "./descriptor-BqaNZrrZ.mjs";
4
+ import { i as stringifyShapeStyle, n as parseShapeStyle } from "./style-matrix-B6jhPAT3.mjs";
5
+ import { n as parseColorMapping, r as stringifyColorMapping } from "./color-mapping-CFF0vRSe.mjs";
6
+ import { attr, children, escapeXml, findChild, findFirst, stringify, stringifyElement, textOf } from "@office-open/xml";
7
+ //#region src/chart/chart-collection.ts
8
+ var ChartCollection = class {
9
+ map;
10
+ constructor() {
11
+ this.map = /* @__PURE__ */ new Map();
12
+ }
13
+ addChart(key, chartData) {
14
+ this.map.set(key, chartData);
15
+ }
16
+ get array() {
17
+ return [...this.map.values()];
18
+ }
19
+ };
20
+ //#endregion
21
+ //#region src/chart/chart-descriptors.ts
22
+ /**
23
+ * Chart descriptors — CustomDescriptor for c:chartSpace serialization.
24
+ *
25
+ * @module
26
+ */
27
+ const CHART_TYPE_TAGS = {
28
+ column: "c:barChart",
29
+ bar: "c:barChart",
30
+ line: "c:lineChart",
31
+ pie: "c:pieChart",
32
+ area: "c:areaChart",
33
+ scatter: "c:scatterChart",
34
+ bubble: "c:bubbleChart",
35
+ doughnut: "c:doughnutChart",
36
+ radar: "c:radarChart",
37
+ stock: "c:stockChart",
38
+ surface: "c:surfaceChart",
39
+ ofPie: "c:ofPieChart"
40
+ };
41
+ const CHART_TYPE_TAGS_3D = {
42
+ column: "c:bar3DChart",
43
+ bar: "c:bar3DChart",
44
+ line: "c:line3DChart",
45
+ pie: "c:pie3DChart",
46
+ area: "c:area3DChart"
47
+ };
48
+ const NO_AXES_TYPES = /* @__PURE__ */ new Set([
49
+ "pie",
50
+ "doughnut",
51
+ "ofPie"
52
+ ]);
53
+ const TAG_TO_CHART_TYPE = {
54
+ "c:barChart": { type: "column" },
55
+ "c:bar3DChart": {
56
+ type: "column",
57
+ threeD: true
58
+ },
59
+ "c:lineChart": { type: "line" },
60
+ "c:line3DChart": {
61
+ type: "line",
62
+ threeD: true
63
+ },
64
+ "c:pieChart": { type: "pie" },
65
+ "c:pie3DChart": {
66
+ type: "pie",
67
+ threeD: true
68
+ },
69
+ "c:areaChart": { type: "area" },
70
+ "c:area3DChart": {
71
+ type: "area",
72
+ threeD: true
73
+ },
74
+ "c:scatterChart": { type: "scatter" },
75
+ "c:bubbleChart": { type: "bubble" },
76
+ "c:doughnutChart": { type: "doughnut" },
77
+ "c:radarChart": { type: "radar" },
78
+ "c:stockChart": { type: "stock" },
79
+ "c:surfaceChart": { type: "surface" },
80
+ "c:surface3DChart": {
81
+ type: "surface",
82
+ threeD: true
83
+ },
84
+ "c:ofPieChart": { type: "ofPie" }
85
+ };
86
+ function attrVal(name, value) {
87
+ return `${name}="${escapeXml(String(value))}"`;
88
+ }
89
+ function emptyEl(tag) {
90
+ return `<${tag}/>`;
91
+ }
92
+ function valEl(tag, value) {
93
+ return `<${tag} ${attrVal("val", value)}/>`;
94
+ }
95
+ function boolVal(value) {
96
+ return ` val="${value === false ? 0 : 1}"`;
97
+ }
98
+ function stringifyNumLit(value) {
99
+ return `<c:numLit><c:formatCode>General</c:formatCode><c:ptCount val="1"/><c:pt idx="0"><c:v>${value}</c:v></c:pt></c:numLit>`;
100
+ }
101
+ function stringifyTrendline(opts) {
102
+ const parts = [];
103
+ if (opts.name !== void 0) parts.push(`<c:name>${escapeXml(opts.name)}</c:name>`);
104
+ parts.push(valEl("c:trendlineType", xsdTrendlineType.to(opts.type ?? "linear")));
105
+ if (opts.order !== void 0) parts.push(valEl("c:order", opts.order));
106
+ if (opts.period !== void 0) parts.push(valEl("c:period", opts.period));
107
+ if (opts.forward !== void 0) parts.push(valEl("c:forward", opts.forward));
108
+ if (opts.backward !== void 0) parts.push(valEl("c:backward", opts.backward));
109
+ if (opts.intercept !== void 0) parts.push(valEl("c:intercept", opts.intercept));
110
+ if (opts.dispRSqr !== void 0) parts.push(`<c:dispRSqr${boolVal(opts.dispRSqr)}/>`);
111
+ if (opts.dispEq !== void 0) parts.push(`<c:dispEq${boolVal(opts.dispEq)}/>`);
112
+ const labelFmt = opts.label?.numberFormat;
113
+ if (labelFmt !== void 0) parts.push(`<c:trendlineLbl><c:numFmt formatCode="${escapeXml(labelFmt)}" sourceLinked="0"/></c:trendlineLbl>`);
114
+ return `<c:trendline>${parts.join("")}</c:trendline>`;
115
+ }
116
+ function stringifyErrBars(opts) {
117
+ const parts = [];
118
+ if (opts.direction === "x" || opts.direction === "y") parts.push(valEl("c:errDir", opts.direction));
119
+ parts.push(valEl("c:errBarType", opts.barType ?? "both"));
120
+ parts.push(valEl("c:errValType", xsdErrorValueType.to(opts.valueType ?? "fixedValue")));
121
+ if (opts.noEndCap !== void 0) parts.push(`<c:noEndCap${boolVal(opts.noEndCap)}/>`);
122
+ if (opts.plusValue !== void 0) parts.push(`<c:plus>${stringifyNumLit(opts.plusValue)}</c:plus>`);
123
+ if (opts.minusValue !== void 0) parts.push(`<c:minus>${stringifyNumLit(opts.minusValue)}</c:minus>`);
124
+ if (opts.value !== void 0) parts.push(valEl("c:val", opts.value));
125
+ return `<c:errBars>${parts.join("")}</c:errBars>`;
126
+ }
127
+ function stringifyDataLabel(opts, ctx) {
128
+ if (opts.delete) return `<c:dLbl><c:idx val="${opts.index}"/><c:delete val="1"/></c:dLbl>`;
129
+ const inner = [];
130
+ if (opts.layout === true) inner.push("<c:layout/>");
131
+ else if (opts.layout) inner.push(stringifyLayout(opts.layout));
132
+ if (opts.text) inner.push(`<c:tx><c:rich>${textBodyDesc.stringify(opts.text, ctx) ?? ""}</c:rich></c:tx>`);
133
+ if (opts.numberFormat !== void 0) inner.push(`<c:numFmt formatCode="${escapeXml(opts.numberFormat)}" sourceLinked="0"/>`);
134
+ inner.push(chartSpPr(opts.shapeProperties, ctx));
135
+ if (opts.textProperties) inner.push(`<c:txPr>${textBodyDesc.stringify(opts.textProperties, ctx) ?? ""}</c:txPr>`);
136
+ if (opts.position !== void 0) inner.push(valEl("c:dLblPos", xsdDataLabelPosition.to(opts.position)));
137
+ if (opts.showLegendKey !== void 0) inner.push(`<c:showLegendKey${boolVal(opts.showLegendKey)}/>`);
138
+ if (opts.showVal !== void 0) inner.push(`<c:showVal${boolVal(opts.showVal)}/>`);
139
+ if (opts.showCatName !== void 0) inner.push(`<c:showCatName${boolVal(opts.showCatName)}/>`);
140
+ if (opts.showSerName !== void 0) inner.push(`<c:showSerName${boolVal(opts.showSerName)}/>`);
141
+ if (opts.showPercent !== void 0) inner.push(`<c:showPercent${boolVal(opts.showPercent)}/>`);
142
+ if (opts.showBubbleSize !== void 0) inner.push(`<c:showBubbleSize${boolVal(opts.showBubbleSize)}/>`);
143
+ if (opts.separator !== void 0) inner.push(`<c:separator>${escapeXml(opts.separator)}</c:separator>`);
144
+ return `<c:dLbl><c:idx val="${opts.index}"/>${inner.join("")}</c:dLbl>`;
145
+ }
146
+ function stringifyDataLabels(opts, ctx) {
147
+ const parts = [];
148
+ if (opts.labels) for (const lbl of opts.labels) parts.push(stringifyDataLabel(lbl, ctx));
149
+ if (opts.delete !== void 0) parts.push(`<c:delete${boolVal(opts.delete)}/>`);
150
+ if (opts.numberFormat !== void 0) parts.push(`<c:numFmt formatCode="${escapeXml(opts.numberFormat)}" sourceLinked="0"/>`);
151
+ parts.push(chartSpPr(opts.shapeProperties, ctx));
152
+ if (opts.textProperties) parts.push(`<c:txPr>${textBodyDesc.stringify(opts.textProperties, ctx) ?? ""}</c:txPr>`);
153
+ if (opts.position !== void 0) parts.push(valEl("c:dLblPos", xsdDataLabelPosition.to(opts.position)));
154
+ if (opts.showLegendKey !== void 0) parts.push(`<c:showLegendKey${boolVal(opts.showLegendKey)}/>`);
155
+ if (opts.showVal !== void 0) parts.push(`<c:showVal${boolVal(opts.showVal)}/>`);
156
+ if (opts.showCatName !== void 0) parts.push(`<c:showCatName${boolVal(opts.showCatName)}/>`);
157
+ if (opts.showSerName !== void 0) parts.push(`<c:showSerName${boolVal(opts.showSerName)}/>`);
158
+ if (opts.showPercent !== void 0) parts.push(`<c:showPercent${boolVal(opts.showPercent)}/>`);
159
+ if (opts.showBubbleSize !== void 0) parts.push(`<c:showBubbleSize${boolVal(opts.showBubbleSize)}/>`);
160
+ if (opts.separator !== void 0) parts.push(`<c:separator>${escapeXml(opts.separator)}</c:separator>`);
161
+ if (opts.delete === void 0) {
162
+ if (opts.showLeaderLines !== void 0) parts.push(`<c:showLeaderLines${boolVal(opts.showLeaderLines)}/>`);
163
+ if (opts.leaderLines) parts.push(emptyEl("c:leaderLines"));
164
+ }
165
+ return `<c:dLbls>${parts.join("")}</c:dLbls>`;
166
+ }
167
+ function stringifyView3D(opts) {
168
+ const parts = [];
169
+ if (opts.rotX !== void 0) parts.push(valEl("c:rotX", opts.rotX));
170
+ if (opts.hPercent !== void 0) parts.push(valEl("c:hPercent", opts.hPercent));
171
+ if (opts.rotY !== void 0) parts.push(valEl("c:rotY", opts.rotY));
172
+ if (opts.depthPercent !== void 0) parts.push(valEl("c:depthPercent", opts.depthPercent));
173
+ if (opts.rAngAx !== void 0) parts.push(`<c:rAngAx${boolVal(opts.rAngAx)}/>`);
174
+ if (opts.perspective !== void 0) parts.push(valEl("c:perspective", opts.perspective));
175
+ return `<c:view3D>${parts.join("")}</c:view3D>`;
176
+ }
177
+ function stringifyLayout(manualLayout) {
178
+ if (!manualLayout) return emptyEl("c:layout");
179
+ const parts = [];
180
+ if (manualLayout.layoutTarget !== void 0) parts.push(valEl("c:layoutTarget", manualLayout.layoutTarget));
181
+ if (manualLayout.xMode !== void 0) parts.push(valEl("c:xMode", manualLayout.xMode));
182
+ if (manualLayout.yMode !== void 0) parts.push(valEl("c:yMode", manualLayout.yMode));
183
+ if (manualLayout.wMode !== void 0) parts.push(valEl("c:wMode", manualLayout.wMode));
184
+ if (manualLayout.hMode !== void 0) parts.push(valEl("c:hMode", manualLayout.hMode));
185
+ if (manualLayout.x !== void 0) parts.push(valEl("c:x", manualLayout.x));
186
+ if (manualLayout.y !== void 0) parts.push(valEl("c:y", manualLayout.y));
187
+ if (manualLayout.w !== void 0) parts.push(valEl("c:w", manualLayout.w));
188
+ if (manualLayout.h !== void 0) parts.push(valEl("c:h", manualLayout.h));
189
+ return `<c:layout><c:manualLayout>${parts.join("")}</c:manualLayout></c:layout>`;
190
+ }
191
+ function stringifySurface(tag, opts, ctx) {
192
+ if (!opts) return "";
193
+ const parts = [];
194
+ if (opts.thickness !== void 0) parts.push(valEl("c:thickness", typeof opts.thickness === "string" ? Number(opts.thickness.replace("%", "")) : opts.thickness));
195
+ if (opts.shapeProperties) parts.push(chartSpPr(opts.shapeProperties, ctx));
196
+ return parts.length ? `<${tag}>${parts.join("")}</${tag}>` : `<${tag}/>`;
197
+ }
198
+ const AXIS_TAG = {
199
+ category: "c:catAx",
200
+ value: "c:valAx",
201
+ date: "c:dateAx",
202
+ series: "c:serAx"
203
+ };
204
+ function stringifyScaling(opts) {
205
+ if (!opts) return emptyEl("c:scaling");
206
+ const parts = [];
207
+ if (opts.logBase !== void 0) parts.push(valEl("c:logBase", opts.logBase));
208
+ if (opts.orientation !== void 0) parts.push(valEl("c:orientation", xsdAxisOrientation.to(opts.orientation)));
209
+ if (opts.max !== void 0) parts.push(valEl("c:max", opts.max));
210
+ if (opts.min !== void 0) parts.push(valEl("c:min", opts.min));
211
+ return `<c:scaling>${parts.join("")}</c:scaling>`;
212
+ }
213
+ function stringifyDisplayUnits(opts) {
214
+ const parts = [];
215
+ if (opts.customUnit !== void 0) parts.push(valEl("c:custUnit", opts.customUnit));
216
+ else if (opts.builtInUnit !== void 0) parts.push(valEl("c:builtInUnit", opts.builtInUnit));
217
+ if (opts.label) parts.push(emptyEl("c:dispUnitsLbl"));
218
+ return `<c:dispUnits>${parts.join("")}</c:dispUnits>`;
219
+ }
220
+ /**
221
+ * Serialize an axis. Field order follows the XSD content model exactly:
222
+ * EG_AxShared (axId…crosses/crossesAt), then the kind-specific tail from
223
+ * CT_CatAx / CT_DateAx / CT_SerAx / CT_ValAx.
224
+ */
225
+ function stringifyAxis(opts, ctx) {
226
+ const parts = [];
227
+ parts.push(valEl("c:axId", opts.id));
228
+ parts.push(stringifyScaling(opts.scaling));
229
+ if (opts.delete !== void 0) parts.push(`<c:delete${boolVal(opts.delete)}/>`);
230
+ const axPos = opts.position ?? (opts.kind === "value" ? "left" : "bottom");
231
+ parts.push(valEl("c:axPos", xsdAxisPosition.to(axPos)));
232
+ parts.push(stringifyChartLines("c:majorGridlines", opts.majorGridlines, ctx));
233
+ parts.push(stringifyChartLines("c:minorGridlines", opts.minorGridlines, ctx));
234
+ if (opts.title !== void 0) parts.push(typeof opts.title === "string" && opts.title === "" ? emptyEl("c:title") : stringifyTitle(opts.title, ctx));
235
+ if (opts.numberFormat !== void 0) {
236
+ const fmt = typeof opts.numberFormat === "string" ? { formatCode: opts.numberFormat } : opts.numberFormat;
237
+ const linked = fmt.sourceLinked === void 0 || fmt.sourceLinked ? 1 : 0;
238
+ parts.push(`<c:numFmt formatCode="${escapeXml(fmt.formatCode)}" sourceLinked="${linked}"/>`);
239
+ }
240
+ if (opts.majorTickMark !== void 0) parts.push(valEl("c:majorTickMark", opts.majorTickMark));
241
+ if (opts.minorTickMark !== void 0) parts.push(valEl("c:minorTickMark", opts.minorTickMark));
242
+ if (opts.tickLabelPosition !== void 0) parts.push(valEl("c:tickLblPos", opts.tickLabelPosition));
243
+ parts.push(chartSpPr(opts.shapeProperties, ctx));
244
+ if (opts.textProperties) parts.push(`<c:txPr>${textBodyDesc.stringify(opts.textProperties, ctx) ?? ""}</c:txPr>`);
245
+ parts.push(valEl("c:crossAx", opts.crossAxisId));
246
+ if (opts.crossesAt !== void 0) parts.push(valEl("c:crossesAt", opts.crossesAt));
247
+ else if (opts.crosses !== void 0) parts.push(valEl("c:crosses", xsdAxisCrosses.to(opts.crosses)));
248
+ switch (opts.kind) {
249
+ case "category":
250
+ if (opts.auto !== void 0) parts.push(`<c:auto${boolVal(opts.auto)}/>`);
251
+ if (opts.labelAlignment !== void 0) parts.push(valEl("c:lblAlgn", xsdAxisLabelAlignment.to(opts.labelAlignment)));
252
+ if (opts.labelOffset !== void 0) parts.push(valEl("c:lblOffset", opts.labelOffset));
253
+ if (opts.tickLabelSkip !== void 0) parts.push(valEl("c:tickLblSkip", opts.tickLabelSkip));
254
+ if (opts.tickMarkSkip !== void 0) parts.push(valEl("c:tickMarkSkip", opts.tickMarkSkip));
255
+ if (opts.noMultiLevelLabel !== void 0) parts.push(`<c:noMultiLvlLbl${boolVal(opts.noMultiLevelLabel)}/>`);
256
+ break;
257
+ case "date":
258
+ if (opts.auto !== void 0) parts.push(`<c:auto${boolVal(opts.auto)}/>`);
259
+ if (opts.labelOffset !== void 0) parts.push(valEl("c:lblOffset", opts.labelOffset));
260
+ if (opts.baseTimeUnit !== void 0) parts.push(valEl("c:baseTimeUnit", opts.baseTimeUnit));
261
+ if (opts.majorUnit !== void 0) parts.push(valEl("c:majorUnit", opts.majorUnit));
262
+ if (opts.majorTimeUnit !== void 0) parts.push(valEl("c:majorTimeUnit", opts.majorTimeUnit));
263
+ if (opts.minorUnit !== void 0) parts.push(valEl("c:minorUnit", opts.minorUnit));
264
+ if (opts.minorTimeUnit !== void 0) parts.push(valEl("c:minorTimeUnit", opts.minorTimeUnit));
265
+ break;
266
+ case "series":
267
+ if (opts.tickLabelSkip !== void 0) parts.push(valEl("c:tickLblSkip", opts.tickLabelSkip));
268
+ if (opts.tickMarkSkip !== void 0) parts.push(valEl("c:tickMarkSkip", opts.tickMarkSkip));
269
+ break;
270
+ case "value":
271
+ if (opts.crossBetween !== void 0) parts.push(valEl("c:crossBetween", xsdAxisCrossBetween.to(opts.crossBetween)));
272
+ if (opts.majorUnit !== void 0) parts.push(valEl("c:majorUnit", opts.majorUnit));
273
+ if (opts.minorUnit !== void 0) parts.push(valEl("c:minorUnit", opts.minorUnit));
274
+ if (opts.displayUnits) parts.push(stringifyDisplayUnits(opts.displayUnits));
275
+ }
276
+ const tag = AXIS_TAG[opts.kind];
277
+ return `<${tag}>${parts.join("")}</${tag}>`;
278
+ }
279
+ /** Worksheet reference formula (c:f); empty element when not round-tripped. */
280
+ function refFormula(formula) {
281
+ return `<c:f>${escapeXml(formula ?? "")}</c:f>`;
282
+ }
283
+ function stringifyStrRef(values, formula) {
284
+ const pts = values.map((v, i) => `<c:pt idx="${i}"><c:v>${escapeXml(v ?? "")}</c:v></c:pt>`).join("");
285
+ return `<c:strRef>${refFormula(formula)}<c:strCache><c:ptCount ${attrVal("val", values.length)}/>${pts}</c:strCache></c:strRef>`;
286
+ }
287
+ function stringifyStrLit(values) {
288
+ const pts = values.map((v, i) => `<c:pt idx="${i}"><c:v>${escapeXml(v)}</c:v></c:pt>`).join("");
289
+ return `<c:strLit><c:ptCount ${attrVal("val", values.length)}/>${pts}</c:strLit>`;
290
+ }
291
+ function stringifyMultiLvlStrRef(levels, formula) {
292
+ const ptCount = levels.reduce((max, lvl) => Math.max(max, lvl.length), 0);
293
+ const lvls = levels.map((lvl) => {
294
+ return `<c:lvl>${lvl.map((v, i) => `<c:pt idx="${i}"><c:v>${escapeXml(v)}</c:v></c:pt>`).join("")}</c:lvl>`;
295
+ }).join("");
296
+ return `<c:multiLvlStrRef>${refFormula(formula)}<c:multiLvlStrCache><c:ptCount ${attrVal("val", ptCount)}/>${lvls}</c:multiLvlStrCache></c:multiLvlStrRef>`;
297
+ }
298
+ function stringifyNumCatRef(values, formula, formatCode) {
299
+ const pts = values.map((v, i) => `<c:pt idx="${i}"><c:v>${escapeXml(v)}</c:v></c:pt>`).join("");
300
+ return `<c:numRef>${refFormula(formula)}<c:numCache><c:formatCode>${escapeXml(formatCode ?? "General")}</c:formatCode><c:ptCount ${attrVal("val", values.length)}/>${pts}</c:numCache></c:numRef>`;
301
+ }
302
+ /** Whether the chart carries category-source data (c:cat is optional in CT_Ser). */
303
+ function hasCategoryData(opts) {
304
+ return opts.categories !== void 0 || opts.categoryLabels !== void 0 || opts.multiLevelCategories !== void 0 || opts.numericCategories === true;
305
+ }
306
+ function stringifyCategorySource(opts) {
307
+ if (opts.multiLevelCategories) return stringifyMultiLvlStrRef(opts.multiLevelCategories, opts.categoryFormula);
308
+ if (opts.categoryLabels) return stringifyStrLit(opts.categoryLabels);
309
+ if (opts.numericCategories) return stringifyNumCatRef(opts.categories ?? [], opts.categoryFormula, opts.categoryFormatCode);
310
+ return stringifyStrRef(opts.categories ?? [], opts.categoryFormula);
311
+ }
312
+ function stringifyNumRef(values, formula, formatCode) {
313
+ const pts = values.map((v, i) => `<c:pt idx="${i}"><c:v>${v}</c:v></c:pt>`).join("");
314
+ return `<c:numRef>${refFormula(formula)}<c:numCache><c:formatCode>${escapeXml(formatCode ?? "General")}</c:formatCode><c:ptCount ${attrVal("val", values.length)}/>${pts}</c:numCache></c:numRef>`;
315
+ }
316
+ function stringifyNumLitList(values, formatCode) {
317
+ const pts = values.map((v, i) => `<c:pt idx="${i}"><c:v>${v}</c:v></c:pt>`).join("");
318
+ return `<c:numLit><c:formatCode>${escapeXml(formatCode ?? "General")}</c:formatCode><c:ptCount ${attrVal("val", values.length)}/>${pts}</c:numLit>`;
319
+ }
320
+ function stringifyUpDownBars(gapWidth) {
321
+ const inner = [];
322
+ if (gapWidth !== void 0) inner.push(valEl("c:gapWidth", gapWidth));
323
+ inner.push(emptyEl("c:upBars"));
324
+ inner.push(emptyEl("c:downBars"));
325
+ return `<c:upDownBars>${inner.join("")}</c:upDownBars>`;
326
+ }
327
+ function stringifyDataTable(opts, ctx) {
328
+ const parts = [];
329
+ if (opts.showHorizontalBorder !== void 0) parts.push(`<c:showHorzBorder${boolVal(opts.showHorizontalBorder)}/>`);
330
+ if (opts.showVerticalBorder !== void 0) parts.push(`<c:showVertBorder${boolVal(opts.showVerticalBorder)}/>`);
331
+ if (opts.showOutline !== void 0) parts.push(`<c:showOutline${boolVal(opts.showOutline)}/>`);
332
+ if (opts.showLegendKeys !== void 0) parts.push(`<c:showKeys${boolVal(opts.showLegendKeys)}/>`);
333
+ if (opts.shapeProperties) parts.push(chartSpPr(opts.shapeProperties, ctx));
334
+ if (opts.textProperties) parts.push(`<c:txPr>${textBodyDesc.stringify(opts.textProperties, ctx) ?? ""}</c:txPr>`);
335
+ return `<c:dTable>${parts.join("")}</c:dTable>`;
336
+ }
337
+ function stringifyProtection(opts) {
338
+ const parts = [];
339
+ if (opts.chartObject !== void 0) parts.push(`<c:chartObject val="${opts.chartObject ? 1 : 0}"/>`);
340
+ if (opts.data !== void 0) parts.push(`<c:data val="${opts.data ? 1 : 0}"/>`);
341
+ if (opts.formatting !== void 0) parts.push(`<c:formatting val="${opts.formatting ? 1 : 0}"/>`);
342
+ if (opts.selection !== void 0) parts.push(`<c:selection val="${opts.selection ? 1 : 0}"/>`);
343
+ if (opts.userInterface !== void 0) parts.push(`<c:userInterface val="${opts.userInterface ? 1 : 0}"/>`);
344
+ return `<c:protection>${parts.join("")}</c:protection>`;
345
+ }
346
+ function stringifyExternalData(opts) {
347
+ if (!opts.relationshipId || /^r?Id?(0|undefined)?$/i.test(opts.relationshipId)) return void 0;
348
+ const auto = opts.autoUpdate !== void 0 ? `<c:autoUpdate val="${opts.autoUpdate ? 1 : 0}"/>` : "";
349
+ return `<c:externalData r:id="${escapeXml(opts.relationshipId)}">${auto}</c:externalData>`;
350
+ }
351
+ function stringifyHeaderFooter(opts) {
352
+ const parts = [];
353
+ if (opts.oddHeader !== void 0) parts.push(`<c:oddHeader>${escapeXml(opts.oddHeader)}</c:oddHeader>`);
354
+ if (opts.oddFooter !== void 0) parts.push(`<c:oddFooter>${escapeXml(opts.oddFooter)}</c:oddFooter>`);
355
+ if (opts.evenHeader !== void 0) parts.push(`<c:evenHeader>${escapeXml(opts.evenHeader)}</c:evenHeader>`);
356
+ if (opts.evenFooter !== void 0) parts.push(`<c:evenFooter>${escapeXml(opts.evenFooter)}</c:evenFooter>`);
357
+ if (opts.firstHeader !== void 0) parts.push(`<c:firstHeader>${escapeXml(opts.firstHeader)}</c:firstHeader>`);
358
+ if (opts.firstFooter !== void 0) parts.push(`<c:firstFooter>${escapeXml(opts.firstFooter)}</c:firstFooter>`);
359
+ const attrs = [];
360
+ if (opts.alignWithMargins !== void 0) attrs.push(`alignWithMargins="${opts.alignWithMargins ? 1 : 0}"`);
361
+ if (opts.differentOddEven !== void 0) attrs.push(`differentOddEven="${opts.differentOddEven ? 1 : 0}"`);
362
+ if (opts.differentFirst !== void 0) attrs.push(`differentFirst="${opts.differentFirst ? 1 : 0}"`);
363
+ const attrStr = attrs.length ? " " + attrs.join(" ") : "";
364
+ if (parts.length === 0) return `<c:headerFooter${attrStr}/>`;
365
+ return `<c:headerFooter${attrStr}>${parts.join("")}</c:headerFooter>`;
366
+ }
367
+ function stringifyPageMargins(opts) {
368
+ return `<c:pageMargins l="${opts.left ?? .7}" r="${opts.right ?? .7}" t="${opts.top ?? .75}" b="${opts.bottom ?? .75}" header="${opts.header ?? .3}" footer="${opts.footer ?? .3}"/>`;
369
+ }
370
+ function stringifyPageSetup(opts) {
371
+ const attrs = [];
372
+ if (opts.paperSize !== void 0) attrs.push(`paperSize="${opts.paperSize}"`);
373
+ if (opts.paperHeight !== void 0) attrs.push(`paperHeight="${escapeXml(opts.paperHeight)}"`);
374
+ if (opts.paperWidth !== void 0) attrs.push(`paperWidth="${escapeXml(opts.paperWidth)}"`);
375
+ if (opts.firstPageNumber !== void 0) attrs.push(`firstPageNumber="${opts.firstPageNumber}"`);
376
+ if (opts.orientation !== void 0) attrs.push(`orientation="${opts.orientation}"`);
377
+ if (opts.blackAndWhite !== void 0) attrs.push(`blackAndWhite="${opts.blackAndWhite ? 1 : 0}"`);
378
+ if (opts.draft !== void 0) attrs.push(`draft="${opts.draft ? 1 : 0}"`);
379
+ if (opts.useFirstPageNumber !== void 0) attrs.push(`useFirstPageNumber="${opts.useFirstPageNumber ? 1 : 0}"`);
380
+ if (opts.horizontalDpi !== void 0) attrs.push(`horizontalDpi="${opts.horizontalDpi}"`);
381
+ if (opts.verticalDpi !== void 0) attrs.push(`verticalDpi="${opts.verticalDpi}"`);
382
+ if (opts.copies !== void 0) attrs.push(`copies="${opts.copies}"`);
383
+ if (attrs.length === 0) return `<c:pageSetup/>`;
384
+ return `<c:pageSetup ${attrs.join(" ")}/>`;
385
+ }
386
+ function stringifyPrintSettings(opts) {
387
+ const parts = [];
388
+ if (opts.headerFooter) parts.push(stringifyHeaderFooter(opts.headerFooter));
389
+ if (opts.pageMargins) parts.push(stringifyPageMargins(opts.pageMargins));
390
+ if (opts.pageSetup) parts.push(stringifyPageSetup(opts.pageSetup));
391
+ if (opts.legacyDrawingId !== void 0) parts.push(`<c:legacyDrawingHF r:id="${escapeXml(opts.legacyDrawingId)}"/>`);
392
+ return `<c:printSettings>${parts.join("")}</c:printSettings>`;
393
+ }
394
+ function chartTypeHeader(opts) {
395
+ const tag = opts.threeD ? CHART_TYPE_TAGS_3D[opts.type] : CHART_TYPE_TAGS[opts.type];
396
+ if (!tag) throw new Error(`Unsupported chart type: ${opts.type}`);
397
+ const headerParts = [];
398
+ switch (opts.type) {
399
+ case "column":
400
+ case "bar":
401
+ headerParts.push(valEl("c:barDir", opts.type === "column" ? "col" : "bar"));
402
+ headerParts.push(valEl("c:grouping", opts.grouping ?? "clustered"));
403
+ break;
404
+ case "line":
405
+ case "area":
406
+ headerParts.push(valEl("c:grouping", opts.grouping ?? "standard"));
407
+ break;
408
+ case "scatter":
409
+ headerParts.push(valEl("c:scatterStyle", "line"));
410
+ break;
411
+ case "radar":
412
+ headerParts.push(valEl("c:radarStyle", opts.radarStyle ?? "standard"));
413
+ break;
414
+ case "ofPie":
415
+ headerParts.push(valEl("c:ofPieType", opts.ofPieType ?? "pie"));
416
+ break;
417
+ case "surface": if (opts.wireframe !== void 0) headerParts.push(`<c:wireframe${boolVal(opts.wireframe)}/>`);
418
+ }
419
+ if (opts.varyColors !== void 0) headerParts.push(`<c:varyColors${boolVal(opts.varyColors)}/>`);
420
+ return `<${tag}>${headerParts.join("")}`;
421
+ }
422
+ function chartTypeFooter(opts, ctx) {
423
+ const tag = opts.threeD ? CHART_TYPE_TAGS_3D[opts.type] : CHART_TYPE_TAGS[opts.type];
424
+ const parts = [];
425
+ switch (opts.type) {
426
+ case "column":
427
+ case "bar":
428
+ if (opts.gapWidth !== void 0) parts.push(valEl("c:gapWidth", opts.gapWidth));
429
+ if (opts.threeD) {
430
+ if (opts.gapDepth !== void 0) parts.push(valEl("c:gapDepth", opts.gapDepth));
431
+ if (opts.shape !== void 0) parts.push(valEl("c:shape", opts.shape));
432
+ } else {
433
+ if (opts.overlap !== void 0) parts.push(valEl("c:overlap", opts.overlap));
434
+ parts.push(stringifyChartLines("c:serLines", opts.seriesLines, ctx));
435
+ }
436
+ break;
437
+ case "line":
438
+ parts.push(stringifyChartLines("c:dropLines", opts.dropLines, ctx));
439
+ if (!opts.threeD) {
440
+ parts.push(stringifyChartLines("c:hiLowLines", opts.highLowLines, ctx));
441
+ if (opts.upDownBars) parts.push(stringifyUpDownBars(opts.upDownBarsGapWidth));
442
+ if (opts.markers !== void 0) parts.push(`<c:marker${boolVal(opts.markers)}/>`);
443
+ if (opts.smooth !== void 0) parts.push(`<c:smooth${boolVal(opts.smooth)}/>`);
444
+ } else if (opts.gapDepth !== void 0) parts.push(valEl("c:gapDepth", opts.gapDepth));
445
+ break;
446
+ case "area":
447
+ parts.push(stringifyChartLines("c:dropLines", opts.dropLines, ctx));
448
+ if (opts.threeD && opts.gapDepth !== void 0) parts.push(valEl("c:gapDepth", opts.gapDepth));
449
+ break;
450
+ case "stock":
451
+ parts.push(stringifyChartLines("c:dropLines", opts.dropLines, ctx));
452
+ parts.push(stringifyChartLines("c:hiLowLines", opts.highLowLines, ctx));
453
+ if (opts.upDownBars) parts.push(stringifyUpDownBars(opts.upDownBarsGapWidth));
454
+ break;
455
+ case "pie":
456
+ if (!opts.threeD && opts.firstSliceAngle !== void 0) parts.push(valEl("c:firstSliceAng", opts.firstSliceAngle));
457
+ break;
458
+ case "doughnut":
459
+ if (opts.firstSliceAngle !== void 0) parts.push(valEl("c:firstSliceAng", opts.firstSliceAngle));
460
+ parts.push(valEl("c:holeSize", opts.holeSize ?? 10));
461
+ break;
462
+ case "bubble":
463
+ if (opts.bubbleScale !== void 0) parts.push(valEl("c:bubbleScale", opts.bubbleScale));
464
+ if (opts.showNegativeBubbles !== void 0) parts.push(`<c:showNegBubbles${boolVal(opts.showNegativeBubbles)}/>`);
465
+ if (opts.sizeRepresents !== void 0) parts.push(valEl("c:sizeRepresents", xsdSizeRepresents.to(opts.sizeRepresents)));
466
+ break;
467
+ case "ofPie":
468
+ if (opts.gapWidth !== void 0) parts.push(valEl("c:gapWidth", opts.gapWidth));
469
+ if (opts.splitType !== void 0) parts.push(valEl("c:splitType", xsdSplitType.to(opts.splitType)));
470
+ if (opts.splitPosition !== void 0) parts.push(valEl("c:splitPos", opts.splitPosition));
471
+ if (opts.customSplitPoints?.length) {
472
+ const pts = opts.customSplitPoints.map((p) => valEl("c:secondPiePt", p)).join("");
473
+ parts.push(`<c:custSplit>${pts}</c:custSplit>`);
474
+ }
475
+ if (opts.secondPieSize !== void 0) parts.push(valEl("c:secondPieSize", opts.secondPieSize));
476
+ parts.push(stringifyChartLines("c:serLines", opts.seriesLines, ctx));
477
+ break;
478
+ case "surface": if (opts.bandFormats?.length) parts.push(stringifyBandFormats(opts.bandFormats));
479
+ }
480
+ if (!NO_AXES_TYPES.has(opts.type)) {
481
+ const ids = opts.axes && opts.axisIds ? opts.axisIds : axesFor(opts).map((axis) => axis.id);
482
+ for (const id of ids) parts.push(valEl("c:axId", id));
483
+ }
484
+ return `${parts.join("")}</${tag}>`;
485
+ }
486
+ function stringifyMarker$1(opts, ctx) {
487
+ const parts = [];
488
+ if (opts.symbol !== void 0) parts.push(valEl("c:symbol", opts.symbol));
489
+ if (opts.size !== void 0) parts.push(valEl("c:size", opts.size));
490
+ parts.push(chartSpPr(opts.shapeProperties, ctx));
491
+ return `<c:marker>${parts.join("")}</c:marker>`;
492
+ }
493
+ function stringifyPictureOptions(opts) {
494
+ const parts = [];
495
+ if (opts.applyToFront !== void 0) parts.push(`<c:applyToFront${boolVal(opts.applyToFront)}/>`);
496
+ if (opts.applyToSides !== void 0) parts.push(`<c:applyToSides${boolVal(opts.applyToSides)}/>`);
497
+ if (opts.applyToEnd !== void 0) parts.push(`<c:applyToEnd${boolVal(opts.applyToEnd)}/>`);
498
+ if (opts.pictureFormat !== void 0) parts.push(valEl("c:pictureFormat", opts.pictureFormat));
499
+ if (opts.pictureStackUnit !== void 0) parts.push(valEl("c:pictureStackUnit", opts.pictureStackUnit));
500
+ return `<c:pictureOptions>${parts.join("")}</c:pictureOptions>`;
501
+ }
502
+ function stringifyDataPoint(opts, ctx) {
503
+ const parts = [valEl("c:idx", opts.index)];
504
+ if (opts.invertIfNegative !== void 0) parts.push(`<c:invertIfNegative${boolVal(opts.invertIfNegative)}/>`);
505
+ if (opts.marker) parts.push(stringifyMarker$1(opts.marker, ctx));
506
+ if (opts.bubble3D !== void 0) parts.push(`<c:bubble3D${boolVal(opts.bubble3D)}/>`);
507
+ if (opts.explosion !== void 0) parts.push(valEl("c:explosion", opts.explosion));
508
+ parts.push(chartSpPr(opts.shapeProperties, ctx));
509
+ if (opts.pictureOptions) parts.push(stringifyPictureOptions(opts.pictureOptions));
510
+ return `<c:dPt>${parts.join("")}</c:dPt>`;
511
+ }
512
+ function stringifySeries(index, series, opts, ctx, groupType) {
513
+ const chartType = groupType ?? opts.type;
514
+ const parts = [];
515
+ const s = series;
516
+ parts.push(valEl("c:idx", s.index ?? index));
517
+ parts.push(valEl("c:order", s.order ?? index));
518
+ if (series.nameLiteral && series.name !== void 0) parts.push(`<c:tx><c:v>${escapeXml(series.name)}</c:v></c:tx>`);
519
+ else if (series.name !== void 0 || series.nameFormula !== void 0) parts.push(`<c:tx>${stringifyStrRef([series.name], series.nameFormula)}</c:tx>`);
520
+ parts.push(chartSpPr(s.shapeProperties, ctx));
521
+ if (chartType === "line" || chartType === "scatter" || chartType === "radar") {
522
+ if (s.marker) parts.push(stringifyMarker$1(s.marker, ctx));
523
+ } else if (chartType === "column" || chartType === "bar") {
524
+ if (s.invertIfNegative !== void 0) parts.push(`<c:invertIfNegative${boolVal(s.invertIfNegative)}/>`);
525
+ if (s.pictureOptions) parts.push(stringifyPictureOptions(s.pictureOptions));
526
+ } else if (chartType === "area") {
527
+ if (s.pictureOptions) parts.push(stringifyPictureOptions(s.pictureOptions));
528
+ } else if (chartType === "bubble") {
529
+ if (s.invertIfNegative !== void 0) parts.push(`<c:invertIfNegative${boolVal(s.invertIfNegative)}/>`);
530
+ } else if (chartType === "pie" || chartType === "doughnut" || chartType === "ofPie") {
531
+ if (s.explosion !== void 0) parts.push(valEl("c:explosion", s.explosion));
532
+ }
533
+ if (s.dataPoints) for (const dp of s.dataPoints) parts.push(stringifyDataPoint(dp, ctx));
534
+ if (s.dataLabels) parts.push(stringifyDataLabels(s.dataLabels, ctx));
535
+ if (s.trendlines) for (const tl of s.trendlines) parts.push(stringifyTrendline(tl));
536
+ if (s.errorBars) parts.push(stringifyErrBars(s.errorBars));
537
+ if (chartType === "bubble") {
538
+ const bs = series;
539
+ parts.push(`<c:xVal>${stringifyNumRef(bs.xValues)}</c:xVal>`);
540
+ parts.push(`<c:yVal>${stringifyNumRef(bs.yValues)}</c:yVal>`);
541
+ parts.push(`<c:bubbleSize>${stringifyNumRef(bs.bubbleSize)}</c:bubbleSize>`);
542
+ } else if (chartType === "scatter") {
543
+ if ("xValues" in series) {
544
+ parts.push(`<c:xVal>${stringifyNumRef(series.xValues)}</c:xVal>`);
545
+ parts.push(`<c:yVal>${stringifyNumRef(series.yValues, series.valueFormula, series.formatCode)}</c:yVal>`);
546
+ } else {
547
+ parts.push(`<c:xVal>${stringifyCategorySource(opts)}</c:xVal>`);
548
+ parts.push(`<c:yVal>${stringifyNumRef(s.values, s.valueFormula, s.formatCode)}</c:yVal>`);
549
+ }
550
+ } else if (hasCategoryData(opts)) {
551
+ parts.push(`<c:cat>${stringifyCategorySource(opts)}</c:cat>`);
552
+ parts.push(`<c:val>${s.valueLiteral ? stringifyNumLitList(s.values, s.formatCode) : stringifyNumRef(s.values, s.valueFormula, s.formatCode)}</c:val>`);
553
+ } else parts.push(`<c:val>${s.valueLiteral ? stringifyNumLitList(s.values, s.formatCode) : stringifyNumRef(s.values, s.valueFormula, s.formatCode)}</c:val>`);
554
+ if ((chartType === "line" || chartType === "scatter") && s.smooth !== void 0) parts.push(`<c:smooth${boolVal(s.smooth)}/>`);
555
+ if ((chartType === "column" || chartType === "bar") && s.shape !== void 0) parts.push(valEl("c:shape", s.shape));
556
+ if (chartType === "bubble" && s.bubble3D !== void 0) parts.push(`<c:bubble3D${boolVal(s.bubble3D)}/>`);
557
+ if (s.ext) parts.push(`<c:extLst>${s.ext}</c:extLst>`);
558
+ return `<c:ser>${parts.join("")}</c:ser>`;
559
+ }
560
+ function stringifyChartLines(tag, opts, ctx) {
561
+ if (opts === void 0 || opts === false) return "";
562
+ if (opts === true) return emptyEl(tag);
563
+ return `<${tag}>${chartSpPr(opts.shapeProperties, ctx)}</${tag}>`;
564
+ }
565
+ /** Read any CT_ChartLines element: true when bare, decorations when carried. */
566
+ function readChartLines(parent, tag, ctx) {
567
+ const el = findChild(parent, tag);
568
+ if (!el) return void 0;
569
+ const spPrEl = findChild(el, "c:spPr");
570
+ if (!spPrEl) return true;
571
+ const lines = {};
572
+ const shapeProperties = shapePropertiesDesc.parse(spPrEl, ctx);
573
+ if (shapeProperties) lines.shapeProperties = shapeProperties;
574
+ return lines;
575
+ }
576
+ /** Read one secondary chart group (combo): own series, flags, and 2D group tail. */
577
+ function readSecondaryGroup(secondaryEl, ctx) {
578
+ const mapping = TAG_TO_CHART_TYPE[secondaryEl.name ?? ""];
579
+ if (!mapping) return void 0;
580
+ let secType = mapping.type;
581
+ if (secondaryEl.name === "c:barChart" || secondaryEl.name === "c:bar3DChart") {
582
+ const barDir = findChild(secondaryEl, "c:barDir");
583
+ const barDirVal = barDir ? attr(barDir, "val") : void 0;
584
+ if (barDirVal === "bar") secType = "bar";
585
+ else if (barDirVal === "col") secType = "column";
586
+ }
587
+ const g = {
588
+ type: secType,
589
+ series: []
590
+ };
591
+ const grouping = readValStr(secondaryEl, "c:grouping");
592
+ if (grouping) g.grouping = grouping;
593
+ const varyColors = readBoolAttr(secondaryEl, "c:varyColors");
594
+ if (varyColors !== void 0) g.varyColors = varyColors;
595
+ const groupLabels = readDataLabels(secondaryEl, ctx);
596
+ if (groupLabels) g.dataLabels = groupLabels;
597
+ if (secType === "bar" || secType === "column") {
598
+ const gapWidth = readValNum(secondaryEl, "c:gapWidth");
599
+ if (gapWidth !== void 0) g.gapWidth = gapWidth;
600
+ if (!mapping.threeD) {
601
+ const overlap = readValNum(secondaryEl, "c:overlap");
602
+ if (overlap !== void 0) g.overlap = overlap;
603
+ } else {
604
+ const gapDepth = readValNum(secondaryEl, "c:gapDepth");
605
+ if (gapDepth !== void 0) g.gapDepth = gapDepth;
606
+ }
607
+ const seriesLines = readChartLines(secondaryEl, "c:serLines", ctx);
608
+ if (seriesLines !== void 0) g.seriesLines = seriesLines;
609
+ } else if (secType === "line") {
610
+ const dropLines = readChartLines(secondaryEl, "c:dropLines", ctx);
611
+ if (dropLines !== void 0) g.dropLines = dropLines;
612
+ const highLowLines = readChartLines(secondaryEl, "c:hiLowLines", ctx);
613
+ if (highLowLines !== void 0) g.highLowLines = highLowLines;
614
+ const upDownBars = findChild(secondaryEl, "c:upDownBars");
615
+ if (upDownBars) {
616
+ g.upDownBars = true;
617
+ const gw = readValNum(upDownBars, "c:gapWidth");
618
+ if (gw !== void 0) g.upDownBarsGapWidth = gw;
619
+ }
620
+ const markers = readBoolAttr(secondaryEl, "c:marker");
621
+ if (markers !== void 0) g.markers = markers;
622
+ const smooth = readBoolAttr(secondaryEl, "c:smooth");
623
+ if (smooth !== void 0) g.smooth = smooth;
624
+ } else if (secType === "area") {
625
+ const dropLines = readChartLines(secondaryEl, "c:dropLines", ctx);
626
+ if (dropLines !== void 0) g.dropLines = dropLines;
627
+ }
628
+ const secAxIds = children(secondaryEl, "c:axId");
629
+ if (secAxIds.length > 0) {
630
+ const ids = secAxIds.map((e) => Number(attr(e, "val"))).filter((n) => !isNaN(n));
631
+ if (ids.length > 0) g.axisIds = ids;
632
+ }
633
+ const secSeries = [];
634
+ for (const serEl of children(secondaryEl, "c:ser")) {
635
+ const { name, literal: nameLiteral } = readSeriesName(serEl);
636
+ const txEl = findChild(serEl, "c:tx");
637
+ const nameFormula = txEl ? readRefMeta(txEl).formula : void 0;
638
+ const valueEl = findChild(serEl, "c:val") ?? findChild(serEl, "c:yVal");
639
+ const valueLiteral = valueEl ? findChild(valueEl, "c:numLit") !== void 0 : false;
640
+ const values = valueEl ? readNumCache(valueEl) : [];
641
+ const valMeta = valueEl ? readRefMeta(valueEl) : {};
642
+ secSeries.push({
643
+ name,
644
+ ...nameLiteral ? { nameLiteral } : {},
645
+ ...nameFormula ? { nameFormula } : {},
646
+ ...valueLiteral ? { valueLiteral } : {},
647
+ ...valMeta.formula ? { valueFormula: valMeta.formula } : {},
648
+ ...valMeta.formatCode ? { formatCode: valMeta.formatCode } : {},
649
+ values,
650
+ ...readSeriesCommon(serEl, ctx)
651
+ });
652
+ }
653
+ g.series = secSeries;
654
+ return g;
655
+ }
656
+ function stringifySecondaryGroup(g, opts, ctx) {
657
+ const parts = [chartTypeHeader(g)];
658
+ for (const [i, series] of (g.series ?? []).entries()) parts.push(stringifySeries(i, series, opts, ctx, g.type));
659
+ if (g.dataLabels) parts.push(stringifyDataLabels(g.dataLabels, ctx));
660
+ switch (g.type) {
661
+ case "bar":
662
+ case "column":
663
+ if (g.gapWidth !== void 0) parts.push(valEl("c:gapWidth", g.gapWidth));
664
+ if (g.overlap !== void 0) parts.push(valEl("c:overlap", g.overlap));
665
+ parts.push(stringifyChartLines("c:serLines", g.seriesLines, ctx));
666
+ break;
667
+ case "line":
668
+ parts.push(stringifyChartLines("c:dropLines", g.dropLines, ctx));
669
+ parts.push(stringifyChartLines("c:hiLowLines", g.highLowLines, ctx));
670
+ if (g.upDownBars) parts.push(stringifyUpDownBars(g.upDownBarsGapWidth));
671
+ if (g.markers !== void 0) parts.push(`<c:marker${boolVal(g.markers)}/>`);
672
+ if (g.smooth !== void 0) parts.push(`<c:smooth${boolVal(g.smooth)}/>`);
673
+ break;
674
+ case "area": parts.push(stringifyChartLines("c:dropLines", g.dropLines, ctx));
675
+ }
676
+ for (const id of g.axisIds ?? []) parts.push(valEl("c:axId", id));
677
+ return `${parts.join("")}</${CHART_TYPE_TAGS[g.type]}>`;
678
+ }
679
+ function stringifyTitle(title, ctx) {
680
+ if (typeof title !== "string") {
681
+ const parts = [];
682
+ if (title.text !== void 0) parts.push(typeof title.text === "string" ? `<c:tx><c:rich><a:bodyPr/><a:lstStyle/><a:p><a:r><a:t>${escapeXml(title.text)}</a:t></a:r></a:p></c:rich></c:tx>` : `<c:tx><c:rich>${textBodyDesc.stringify(title.text, ctx) ?? ""}</c:rich></c:tx>`);
683
+ if (title.layout !== void 0) parts.push(title.layout === true ? "<c:layout/>" : stringifyLayout(title.layout));
684
+ if (title.overlay !== void 0) parts.push(`<c:overlay${boolVal(title.overlay)}/>`);
685
+ if (title.shapeProperties) parts.push(chartSpPr(title.shapeProperties, ctx));
686
+ if (title.textProperties) parts.push(`<c:txPr>${textBodyDesc.stringify(title.textProperties, ctx) ?? ""}</c:txPr>`);
687
+ return `<c:title>${parts.join("")}</c:title>`;
688
+ }
689
+ return `<c:title><c:tx><c:rich><a:bodyPr/><a:lstStyle/><a:p><a:r><a:t>${escapeXml(title)}</a:t></a:r></a:p></c:rich></c:tx></c:title>`;
690
+ }
691
+ function stringifyLegendEntry(entry, ctx) {
692
+ if (entry.delete) return `<c:legendEntry><c:idx val="${entry.index}"/><c:delete val="1"/></c:legendEntry>`;
693
+ if (entry.textProperties) {
694
+ const txPr = textBodyDesc.stringify(entry.textProperties, ctx) ?? "";
695
+ return `<c:legendEntry><c:idx val="${entry.index}"/><c:txPr>${txPr}</c:txPr></c:legendEntry>`;
696
+ }
697
+ return "";
698
+ }
699
+ function stringifyLegend(opts, ctx) {
700
+ return `<c:legend>${opts.legendPosition !== void 0 ? `<c:legendPos val="${xsdLegendPosition.to(opts.legendPosition)}"/>` : opts.showLegend === true ? "" : `<c:legendPos val="b"/>`}${(opts.legendEntries ?? []).map((e) => stringifyLegendEntry(e, ctx)).join("")}${opts.legendLayout === true ? "<c:layout/>" : opts.legendLayout ? stringifyLayout(opts.legendLayout) : ""}${opts.legendOverlay !== void 0 ? `<c:overlay${boolVal(opts.legendOverlay)}/>` : ""}${chartSpPr(opts.legendShapeProperties, ctx)}${opts.legendTextProperties ? `<c:txPr>${textBodyDesc.stringify(opts.legendTextProperties, ctx) ?? ""}</c:txPr>` : ""}</c:legend>`;
701
+ }
702
+ function stringifyPivotSource(opts) {
703
+ return `<c:pivotSource><c:name>${escapeXml(opts.name)}</c:name><c:fmtId val="${opts.formatId}"/></c:pivotSource>`;
704
+ }
705
+ function stringifyPivotFormats(formats, ctx) {
706
+ return `<c:pivotFmts>${formats.map((f) => {
707
+ let entry = `<c:idx val="${f.index}"/>`;
708
+ if (f.marker) entry += stringifyMarker$1(f.marker, ctx);
709
+ return `<c:pivotFmt>${entry}</c:pivotFmt>`;
710
+ }).join("")}</c:pivotFmts>`;
711
+ }
712
+ function stringifyBandFormats(formats) {
713
+ return `<c:bandFmts>${formats.map((f) => `<c:bandFmt><c:idx val="${f.index}"/></c:bandFmt>`).join("")}</c:bandFmts>`;
714
+ }
715
+ /**
716
+ * Wrap c:spPr inner content. An empty shape-properties object is a real
717
+ * `<c:spPr/>` placeholder (presence itself is the content), so undefined
718
+ * inner still emits the bare element.
719
+ */
720
+ function chartSpPr(opts, ctx) {
721
+ if (!opts) return "";
722
+ return `<c:spPr>${shapePropertiesDesc.stringify(opts, ctx) ?? ""}</c:spPr>`;
723
+ }
724
+ /** Default bottom category axis (c:catAx) for generated charts. */
725
+ function categoryAxis(id, crossAxisId) {
726
+ return {
727
+ kind: "category",
728
+ id,
729
+ crossAxisId,
730
+ scaling: { orientation: "ascending" },
731
+ delete: false,
732
+ position: "bottom",
733
+ crosses: "zero",
734
+ auto: true,
735
+ labelOffset: 100,
736
+ noMultiLevelLabel: false
737
+ };
738
+ }
739
+ /** Default left value axis (c:valAx). */
740
+ function valueAxis(id, crossAxisId) {
741
+ return {
742
+ kind: "value",
743
+ id,
744
+ crossAxisId,
745
+ scaling: { orientation: "ascending" },
746
+ delete: false,
747
+ position: "left",
748
+ numberFormat: "General",
749
+ crosses: "zero"
750
+ };
751
+ }
752
+ /** Default series axis (c:serAx) for surface charts. */
753
+ function seriesAxis(id, crossAxisId) {
754
+ return {
755
+ kind: "series",
756
+ id,
757
+ crossAxisId,
758
+ scaling: { orientation: "ascending" },
759
+ delete: false,
760
+ position: "bottom",
761
+ numberFormat: "General",
762
+ crosses: "zero",
763
+ tickLabelSkip: 1
764
+ };
765
+ }
766
+ /** Sensible default axes derived from chart type, matching prior hardcoded output. */
767
+ function defaultAxesFor(chartType, threeD) {
768
+ if (NO_AXES_TYPES.has(chartType)) return [];
769
+ if (chartType === "scatter" || chartType === "bubble") return [valueAxis(10, 20), valueAxis(20, 10)];
770
+ if (chartType === "surface") return [
771
+ categoryAxis(10, 20),
772
+ valueAxis(20, 10),
773
+ seriesAxis(30, 10)
774
+ ];
775
+ if (chartType === "stock") return [categoryAxis(10, 20), valueAxis(20, 10)];
776
+ if (threeD) return [
777
+ categoryAxis(10, 20),
778
+ valueAxis(20, 10),
779
+ seriesAxis(30, 10)
780
+ ];
781
+ return [categoryAxis(10, 20), valueAxis(20, 10)];
782
+ }
783
+ /** Provided axes override defaults; otherwise defaults are derived from chart type. */
784
+ function axesFor(opts) {
785
+ if (!opts.axes) return defaultAxesFor(opts.type, opts.threeD);
786
+ const slots = defaultAxesFor(opts.type, opts.threeD);
787
+ return opts.axes.map((axis, i) => {
788
+ const slot = slots[i] ?? slots[slots.length - 1];
789
+ return {
790
+ ...axis,
791
+ id: axis.id ?? slot.id,
792
+ crossAxisId: axis.crossAxisId ?? slot.crossAxisId
793
+ };
794
+ });
795
+ }
796
+ function stringifyAxes(opts, ctx) {
797
+ return axesFor(opts).map((axis) => stringifyAxis(axis, ctx)).join("");
798
+ }
799
+ function readStrCache(el) {
800
+ const strRef = findChild(el, "c:strRef");
801
+ if (!strRef) return [];
802
+ const strCache = findChild(strRef, "c:strCache");
803
+ if (!strCache?.elements) return [];
804
+ const result = [];
805
+ for (const pt of strCache.elements) if (pt.name === "c:pt") {
806
+ const v = findChild(pt, "c:v");
807
+ const text = v ? textOf(v) : "";
808
+ if (text !== "") result.push(text);
809
+ }
810
+ return result;
811
+ }
812
+ /** Numeric category labels read as literal text (c:cat > c:numRef > c:numCache). */
813
+ function readNumCacheText(el) {
814
+ const numRef = findChild(el, "c:numRef");
815
+ if (!numRef) return [];
816
+ const numCache = findChild(numRef, "c:numCache");
817
+ if (!numCache?.elements) return [];
818
+ const result = [];
819
+ for (const pt of numCache.elements) if (pt.name === "c:pt") {
820
+ const v = findChild(pt, "c:v");
821
+ const text = v ? textOf(v) ?? "" : "";
822
+ result.push(text);
823
+ }
824
+ return result;
825
+ }
826
+ /** Reference metadata on a data-source slot: the c:f formula and, for numRef,
827
+ * the cached c:formatCode — both round-trip only. */
828
+ function readRefMeta(el) {
829
+ const strRef = findChild(el, "c:strRef");
830
+ const numRef = strRef ? void 0 : findChild(el, "c:numRef");
831
+ const ref = strRef ?? numRef;
832
+ const meta = {};
833
+ if (ref) {
834
+ const f = findChild(ref, "c:f");
835
+ const text = f ? textOf(f) : "";
836
+ if (text) meta.formula = text;
837
+ }
838
+ if (numRef) {
839
+ const cache = findChild(numRef, "c:numCache");
840
+ const fc = cache ? findChild(cache, "c:formatCode") : void 0;
841
+ const text = fc ? textOf(fc) : "";
842
+ if (text) meta.formatCode = text;
843
+ }
844
+ const numLit = strRef || numRef ? void 0 : findChild(el, "c:numLit");
845
+ if (numLit) {
846
+ const fc = findChild(numLit, "c:formatCode");
847
+ const text = fc ? textOf(fc) : "";
848
+ if (text) meta.formatCode = text;
849
+ }
850
+ return meta;
851
+ }
852
+ function readStrLit(el) {
853
+ const strLit = findChild(el, "c:strLit");
854
+ if (!strLit) return void 0;
855
+ const result = [];
856
+ for (const pt of strLit.elements ?? []) if (pt.name === "c:pt") {
857
+ const v = findChild(pt, "c:v");
858
+ const text = v ? textOf(v) : "";
859
+ if (text !== "") result.push(text);
860
+ }
861
+ return result;
862
+ }
863
+ function readMultiLvlStrCache(el) {
864
+ const ref = findChild(el, "c:multiLvlStrRef");
865
+ if (!ref) return void 0;
866
+ const cache = findChild(ref, "c:multiLvlStrCache");
867
+ if (!cache) return [];
868
+ const levels = [];
869
+ for (const lvl of cache.elements ?? []) {
870
+ if (lvl.name !== "c:lvl") continue;
871
+ const level = [];
872
+ for (const pt of lvl.elements ?? []) if (pt.name === "c:pt") {
873
+ const v = findChild(pt, "c:v");
874
+ const text = v ? textOf(v) : "";
875
+ if (text !== "") level.push(text);
876
+ }
877
+ levels.push(level);
878
+ }
879
+ return levels;
880
+ }
881
+ function readNumLitPoints(numLit) {
882
+ const result = [];
883
+ for (const pt of numLit.elements ?? []) if (pt.name === "c:pt") {
884
+ const v = findChild(pt, "c:v");
885
+ const text = v ? textOf(v) : "";
886
+ if (text !== "") result.push(Number(text));
887
+ }
888
+ return result;
889
+ }
890
+ /** A scatter series carries numeric x values when c:xVal holds the
891
+ * CT_NumDataSource choice (numRef/numLit); the label-x shape stringifies
892
+ * x as a strRef category source instead. */
893
+ function hasNumericXRef(serEl) {
894
+ const xVal = findChild(serEl, "c:xVal");
895
+ return xVal !== void 0 && (findChild(xVal, "c:numRef") !== void 0 || findChild(xVal, "c:numLit") !== void 0);
896
+ }
897
+ function readNumCache(el) {
898
+ const numLit = findChild(el, "c:numLit");
899
+ if (numLit) return readNumLitPoints(numLit);
900
+ const numRef = findChild(el, "c:numRef");
901
+ if (!numRef) return [];
902
+ const numCache = findChild(numRef, "c:numCache");
903
+ if (!numCache?.elements) return [];
904
+ const result = [];
905
+ for (const pt of numCache.elements) if (pt.name === "c:pt") {
906
+ const v = findChild(pt, "c:v");
907
+ const text = v ? textOf(v) : "";
908
+ if (text !== "") result.push(Number(text));
909
+ }
910
+ return result;
911
+ }
912
+ function readSeriesName(serEl) {
913
+ const tx = findChild(serEl, "c:tx");
914
+ if (!tx) return {
915
+ name: void 0,
916
+ literal: false
917
+ };
918
+ const v = findChild(tx, "c:v");
919
+ if (v && !findChild(tx, "c:strRef")) {
920
+ const text = textOf(v);
921
+ return {
922
+ name: text !== "" ? text : void 0,
923
+ literal: true
924
+ };
925
+ }
926
+ return {
927
+ name: readStrCache(tx)[0] ?? "",
928
+ literal: false
929
+ };
930
+ }
931
+ /** Read a c:title. Plain text stays a string; layout/overlay/spPr/txPr
932
+ * decorations promote it to the ChartTitleOptions object form. */
933
+ /** Read the title's c:tx > c:rich body; undefined when absent or strRef-linked. */
934
+ function readTitleBody(titleEl, ctx) {
935
+ const rich = findChild(findChild(titleEl, "c:tx") ?? titleEl, "c:rich");
936
+ if (!rich) return void 0;
937
+ return collapseTitleBody(textBodyDesc.parse(rich, ctx));
938
+ }
939
+ /**
940
+ * Collapse a parsed title body to its plain text when it is exactly what the
941
+ * string form emits (empty bodyPr/listStyle, one bare run), keeping simple
942
+ * titles readable in the Options JSON.
943
+ */
944
+ function collapseTitleBody(body) {
945
+ if (body.listStyle !== void 0) return body;
946
+ if (body.bodyProperties !== void 0 && Object.keys(body.bodyProperties).length > 0) return body;
947
+ const ps = body.paragraphs ?? [];
948
+ if (ps.length !== 1) return body;
949
+ const p = ps[0];
950
+ if (p === void 0) return body;
951
+ if (typeof p === "string") return p;
952
+ if (p.properties !== void 0 || p.children !== void 0) return body;
953
+ if (p.endParagraphProperties !== void 0 && p.endParagraphProperties !== false) return body;
954
+ return p.text ?? "";
955
+ }
956
+ function readTitle(titleEl, ctx) {
957
+ const body = readTitleBody(titleEl, ctx);
958
+ const text = body === void 0 ? readTitleText(titleEl) : void 0;
959
+ const layoutEl = findChild(titleEl, "c:layout");
960
+ const overlayEl = findChild(titleEl, "c:overlay");
961
+ const spPrEl = findChild(titleEl, "c:spPr");
962
+ const txPrEl = findChild(titleEl, "c:txPr");
963
+ if (!layoutEl && !overlayEl && !spPrEl && !txPrEl) {
964
+ if (typeof body === "string" || body === void 0) return body ?? text ?? "";
965
+ return { text: body };
966
+ }
967
+ const title = {};
968
+ if (body !== void 0) title.text = body;
969
+ else if (text !== void 0) title.text = text;
970
+ if (layoutEl) title.layout = readManualLayout(layoutEl) ?? true;
971
+ if (overlayEl) title.overlay = parseOnOff(attr(overlayEl, "val")) ?? false;
972
+ if (spPrEl) title.shapeProperties = shapePropertiesDesc.parse(spPrEl, ctx);
973
+ if (txPrEl) title.textProperties = textBodyDesc.parse(txPrEl, ctx);
974
+ return title;
975
+ }
976
+ function readTitleText(titleEl) {
977
+ const tx = findChild(titleEl, "c:tx");
978
+ if (!tx?.elements) return void 0;
979
+ for (const child of tx.elements) {
980
+ if (child.name !== "c:rich") continue;
981
+ for (const sub of child.elements ?? []) {
982
+ if (sub.name !== "a:p") continue;
983
+ for (const r of sub.elements ?? []) {
984
+ if (r.name !== "a:r") continue;
985
+ const t = findChild(r, "a:t");
986
+ if (t) {
987
+ const text = textOf(t);
988
+ if (text) return text;
989
+ }
990
+ }
991
+ }
992
+ }
993
+ }
994
+ function readBoolAttr(el, childName) {
995
+ const child = findChild(el, childName);
996
+ if (!child) return void 0;
997
+ const v = attr(child, "val");
998
+ if (v === void 0) return true;
999
+ return parseOnOff(v) ?? true;
1000
+ }
1001
+ function readValNum(el, childName) {
1002
+ const child = findChild(el, childName);
1003
+ if (!child) return void 0;
1004
+ const v = attr(child, "val");
1005
+ return v !== void 0 ? Number(v) : void 0;
1006
+ }
1007
+ function readValStr(el, childName) {
1008
+ const child = findChild(el, childName);
1009
+ if (!child) return void 0;
1010
+ return attr(child, "val") ?? void 0;
1011
+ }
1012
+ function readNumLit(el, childName) {
1013
+ const child = findChild(el, childName);
1014
+ if (!child) return void 0;
1015
+ const numLit = findChild(child, "c:numLit");
1016
+ if (!numLit?.elements) return void 0;
1017
+ for (const pt of numLit.elements) if (pt.name === "c:pt") {
1018
+ const v = findChild(pt, "c:v");
1019
+ if (v) {
1020
+ const text = textOf(v);
1021
+ if (text) return Number(text);
1022
+ }
1023
+ }
1024
+ }
1025
+ function readTrendlines(serEl) {
1026
+ const tlEls = children(serEl, "c:trendline");
1027
+ if (tlEls.length === 0) return void 0;
1028
+ return tlEls.map((tl) => {
1029
+ const opts = {};
1030
+ const type = readValStr(tl, "c:trendlineType");
1031
+ if (type) opts.type = xsdTrendlineType.from(type);
1032
+ const order = readValNum(tl, "c:order");
1033
+ if (order !== void 0) opts.order = order;
1034
+ const period = readValNum(tl, "c:period");
1035
+ if (period !== void 0) opts.period = period;
1036
+ const forward = readValNum(tl, "c:forward");
1037
+ if (forward !== void 0) opts.forward = forward;
1038
+ const backward = readValNum(tl, "c:backward");
1039
+ if (backward !== void 0) opts.backward = backward;
1040
+ const intercept = readValNum(tl, "c:intercept");
1041
+ if (intercept !== void 0) opts.intercept = intercept;
1042
+ const dispRSqr = readBoolAttr(tl, "c:dispRSqr");
1043
+ if (dispRSqr !== void 0) opts.dispRSqr = dispRSqr;
1044
+ const dispEq = readBoolAttr(tl, "c:dispEq");
1045
+ if (dispEq !== void 0) opts.dispEq = dispEq;
1046
+ const nameEl = findChild(tl, "c:name");
1047
+ const nameText = textOf(nameEl);
1048
+ if (nameText) opts.name = nameText;
1049
+ const labelFmt = attr(findChild(findChild(tl, "c:trendlineLbl"), "c:numFmt"), "formatCode");
1050
+ if (labelFmt) opts.label = { numberFormat: labelFmt };
1051
+ return opts;
1052
+ });
1053
+ }
1054
+ function readErrBars(serEl) {
1055
+ const ebEl = findChild(serEl, "c:errBars");
1056
+ if (!ebEl) return void 0;
1057
+ const opts = {};
1058
+ const direction = readValStr(ebEl, "c:errDir");
1059
+ if (direction) opts.direction = direction;
1060
+ const barType = readValStr(ebEl, "c:errBarType");
1061
+ if (barType) opts.barType = barType;
1062
+ const valueType = readValStr(ebEl, "c:errValType");
1063
+ if (valueType) opts.valueType = xsdErrorValueType.from(valueType);
1064
+ const noEndCap = readBoolAttr(ebEl, "c:noEndCap");
1065
+ if (noEndCap !== void 0) opts.noEndCap = noEndCap;
1066
+ const plusValue = readNumLit(ebEl, "c:plus");
1067
+ if (plusValue !== void 0) opts.plusValue = plusValue;
1068
+ const minusValue = readNumLit(ebEl, "c:minus");
1069
+ if (minusValue !== void 0) opts.minusValue = minusValue;
1070
+ const value = readValNum(ebEl, "c:val");
1071
+ if (value !== void 0) opts.value = value;
1072
+ return opts;
1073
+ }
1074
+ function readDataLabels(serEl, ctx) {
1075
+ const dlEl = findChild(serEl, "c:dLbls");
1076
+ if (!dlEl) return void 0;
1077
+ const opts = {};
1078
+ const groupDelete = readBoolAttr(dlEl, "c:delete");
1079
+ if (groupDelete !== void 0) opts.delete = groupDelete;
1080
+ const numFmt = attr(findChild(dlEl, "c:numFmt"), "formatCode");
1081
+ if (numFmt) opts.numberFormat = numFmt;
1082
+ const dlSpPr = findChild(dlEl, "c:spPr");
1083
+ if (dlSpPr) {
1084
+ const shapeProperties = shapePropertiesDesc.parse(dlSpPr, ctx);
1085
+ if (shapeProperties) opts.shapeProperties = shapeProperties;
1086
+ }
1087
+ const dlTxPr = findChild(dlEl, "c:txPr");
1088
+ if (dlTxPr) {
1089
+ const textProperties = textBodyDesc.parse(dlTxPr, ctx);
1090
+ if (textProperties) opts.textProperties = textProperties;
1091
+ }
1092
+ const position = readValStr(dlEl, "c:dLblPos");
1093
+ if (position) opts.position = xsdDataLabelPosition.from(position);
1094
+ const showLegendKey = readBoolAttr(dlEl, "c:showLegendKey");
1095
+ if (showLegendKey !== void 0) opts.showLegendKey = showLegendKey;
1096
+ const showVal = readBoolAttr(dlEl, "c:showVal");
1097
+ if (showVal !== void 0) opts.showVal = showVal;
1098
+ const showCatName = readBoolAttr(dlEl, "c:showCatName");
1099
+ if (showCatName !== void 0) opts.showCatName = showCatName;
1100
+ const showSerName = readBoolAttr(dlEl, "c:showSerName");
1101
+ if (showSerName !== void 0) opts.showSerName = showSerName;
1102
+ const showPercent = readBoolAttr(dlEl, "c:showPercent");
1103
+ if (showPercent !== void 0) opts.showPercent = showPercent;
1104
+ const showBubbleSize = readBoolAttr(dlEl, "c:showBubbleSize");
1105
+ if (showBubbleSize !== void 0) opts.showBubbleSize = showBubbleSize;
1106
+ const showLeaderLines = readBoolAttr(dlEl, "c:showLeaderLines");
1107
+ if (showLeaderLines !== void 0) opts.showLeaderLines = showLeaderLines;
1108
+ const sepEl = findChild(dlEl, "c:separator");
1109
+ const sepText = textOf(sepEl);
1110
+ if (sepText) opts.separator = sepText;
1111
+ const lblEls = children(dlEl, "c:dLbl");
1112
+ if (lblEls.length > 0) opts.labels = lblEls.map((el) => {
1113
+ const result = { index: readValNum(el, "c:idx") ?? 0 };
1114
+ if (findChild(el, "c:delete")) result.delete = true;
1115
+ const layoutEl = findChild(el, "c:layout");
1116
+ if (layoutEl) result.layout = readManualLayout(layoutEl) ?? true;
1117
+ const richEl = findChild(findChild(el, "c:tx"), "c:rich");
1118
+ if (richEl) {
1119
+ const text = textBodyDesc.parse(richEl, ctx);
1120
+ if (text) result.text = text;
1121
+ }
1122
+ const numFmt = attr(findChild(el, "c:numFmt"), "formatCode");
1123
+ if (numFmt) result.numberFormat = numFmt;
1124
+ const lblSpPr = findChild(el, "c:spPr");
1125
+ if (lblSpPr) {
1126
+ const shapeProperties = shapePropertiesDesc.parse(lblSpPr, ctx);
1127
+ if (shapeProperties) result.shapeProperties = shapeProperties;
1128
+ }
1129
+ const lblTxPr = findChild(el, "c:txPr");
1130
+ if (lblTxPr) {
1131
+ const textProperties = textBodyDesc.parse(lblTxPr, ctx);
1132
+ if (textProperties) result.textProperties = textProperties;
1133
+ }
1134
+ const pos = readValStr(el, "c:dLblPos");
1135
+ if (pos) result.position = xsdDataLabelPosition.from(pos);
1136
+ for (const flag of [
1137
+ "showLegendKey",
1138
+ "showVal",
1139
+ "showCatName",
1140
+ "showSerName",
1141
+ "showPercent",
1142
+ "showBubbleSize"
1143
+ ]) {
1144
+ const v = readBoolAttr(el, `c:${flag}`);
1145
+ if (v !== void 0) result[flag] = v;
1146
+ }
1147
+ const sep = textOf(findChild(el, "c:separator"));
1148
+ if (sep) result.separator = sep;
1149
+ return result;
1150
+ });
1151
+ if (findChild(dlEl, "c:leaderLines")) opts.leaderLines = true;
1152
+ return opts;
1153
+ }
1154
+ function readMarker$1(parent, ctx) {
1155
+ const el = findChild(parent, "c:marker");
1156
+ if (!el) return void 0;
1157
+ const opts = {};
1158
+ const symbol = readValStr(el, "c:symbol");
1159
+ if (symbol) opts.symbol = symbol;
1160
+ const size = readValNum(el, "c:size");
1161
+ if (size !== void 0) opts.size = size;
1162
+ const spPr = findChild(el, "c:spPr");
1163
+ if (spPr) {
1164
+ const shapeProperties = shapePropertiesDesc.parse(spPr, ctx);
1165
+ if (shapeProperties) opts.shapeProperties = shapeProperties;
1166
+ }
1167
+ return Object.keys(opts).length ? opts : void 0;
1168
+ }
1169
+ function readPictureOptions(parent) {
1170
+ const el = findChild(parent, "c:pictureOptions");
1171
+ if (!el) return void 0;
1172
+ const opts = {};
1173
+ const front = readBoolAttr(el, "c:applyToFront");
1174
+ if (front !== void 0) opts.applyToFront = front;
1175
+ const sides = readBoolAttr(el, "c:applyToSides");
1176
+ if (sides !== void 0) opts.applyToSides = sides;
1177
+ const end = readBoolAttr(el, "c:applyToEnd");
1178
+ if (end !== void 0) opts.applyToEnd = end;
1179
+ const fmt = readValStr(el, "c:pictureFormat");
1180
+ if (fmt) opts.pictureFormat = fmt;
1181
+ const stack = readValNum(el, "c:pictureStackUnit");
1182
+ if (stack !== void 0) opts.pictureStackUnit = stack;
1183
+ return Object.keys(opts).length ? opts : void 0;
1184
+ }
1185
+ function readDataPoints(serEl, ctx) {
1186
+ const els = children(serEl, "c:dPt");
1187
+ if (els.length === 0) return void 0;
1188
+ return els.map((el) => {
1189
+ const dp = { index: readValNum(el, "c:idx") ?? 0 };
1190
+ const invertIfNegative = readBoolAttr(el, "c:invertIfNegative");
1191
+ if (invertIfNegative !== void 0) dp.invertIfNegative = invertIfNegative;
1192
+ const marker = readMarker$1(el, ctx);
1193
+ if (marker) dp.marker = marker;
1194
+ const bubble3D = readBoolAttr(el, "c:bubble3D");
1195
+ if (bubble3D !== void 0) dp.bubble3D = bubble3D;
1196
+ const explosion = readValNum(el, "c:explosion");
1197
+ if (explosion !== void 0) dp.explosion = explosion;
1198
+ const spPr = findChild(el, "c:spPr");
1199
+ if (spPr) {
1200
+ const shapeProperties = shapePropertiesDesc.parse(spPr, ctx);
1201
+ if (shapeProperties) dp.shapeProperties = shapeProperties;
1202
+ }
1203
+ const pictureOptions = readPictureOptions(el);
1204
+ if (pictureOptions) dp.pictureOptions = pictureOptions;
1205
+ return dp;
1206
+ });
1207
+ }
1208
+ /** Read shared ser enhancement fields (CT_Ser children beyond EG_SerShared). */
1209
+ function readSeriesCommon(serEl, ctx) {
1210
+ const common = {};
1211
+ const idx = readValNum(serEl, "c:idx");
1212
+ if (idx !== void 0) common.index = idx;
1213
+ const order = readValNum(serEl, "c:order");
1214
+ if (order !== void 0) common.order = order;
1215
+ const spPrEl = findChild(serEl, "c:spPr");
1216
+ if (spPrEl) common.shapeProperties = shapePropertiesDesc.parse(spPrEl, ctx);
1217
+ const trendlines = readTrendlines(serEl);
1218
+ if (trendlines) common.trendlines = trendlines;
1219
+ const errorBars = readErrBars(serEl);
1220
+ if (errorBars) common.errorBars = errorBars;
1221
+ const dataLabels = readDataLabels(serEl, ctx);
1222
+ if (dataLabels) common.dataLabels = dataLabels;
1223
+ const dataPoints = readDataPoints(serEl, ctx);
1224
+ if (dataPoints) common.dataPoints = dataPoints;
1225
+ const marker = readMarker$1(serEl, ctx);
1226
+ if (marker) common.marker = marker;
1227
+ const invertIfNegative = readBoolAttr(serEl, "c:invertIfNegative");
1228
+ if (invertIfNegative !== void 0) common.invertIfNegative = invertIfNegative;
1229
+ const smooth = readBoolAttr(serEl, "c:smooth");
1230
+ if (smooth !== void 0) common.smooth = smooth;
1231
+ const explosion = readValNum(serEl, "c:explosion");
1232
+ if (explosion !== void 0) common.explosion = explosion;
1233
+ const pictureOptions = readPictureOptions(serEl);
1234
+ if (pictureOptions) common.pictureOptions = pictureOptions;
1235
+ const shape = readValStr(serEl, "c:shape");
1236
+ if (shape) common.shape = shape;
1237
+ const bubble3D = readBoolAttr(serEl, "c:bubble3D");
1238
+ if (bubble3D !== void 0) common.bubble3D = bubble3D;
1239
+ const extLst = findChild(serEl, "c:extLst");
1240
+ if (extLst) {
1241
+ const inner = stringify(extLst);
1242
+ if (inner) common.ext = inner;
1243
+ }
1244
+ return common;
1245
+ }
1246
+ function readView3D(chartEl) {
1247
+ const v3d = findChild(chartEl, "c:view3D");
1248
+ if (!v3d) return void 0;
1249
+ const opts = {};
1250
+ const rotX = readValNum(v3d, "c:rotX");
1251
+ if (rotX !== void 0) opts.rotX = rotX;
1252
+ const hPercent = readValNum(v3d, "c:hPercent");
1253
+ if (hPercent !== void 0) opts.hPercent = hPercent;
1254
+ const rotY = readValNum(v3d, "c:rotY");
1255
+ if (rotY !== void 0) opts.rotY = rotY;
1256
+ const depthPercent = readValNum(v3d, "c:depthPercent");
1257
+ if (depthPercent !== void 0) opts.depthPercent = depthPercent;
1258
+ const rAngAx = readBoolAttr(v3d, "c:rAngAx");
1259
+ if (rAngAx !== void 0) opts.rAngAx = rAngAx;
1260
+ const perspective = readValNum(v3d, "c:perspective");
1261
+ if (perspective !== void 0) opts.perspective = perspective;
1262
+ return opts;
1263
+ }
1264
+ function readManualLayout(layoutEl) {
1265
+ if (!layoutEl) return void 0;
1266
+ const ml = findChild(layoutEl, "c:manualLayout");
1267
+ if (!ml) return void 0;
1268
+ const opts = {};
1269
+ const layoutTarget = readValStr(ml, "c:layoutTarget");
1270
+ if (layoutTarget) opts.layoutTarget = layoutTarget;
1271
+ const xMode = readValStr(ml, "c:xMode");
1272
+ if (xMode) opts.xMode = xMode;
1273
+ const yMode = readValStr(ml, "c:yMode");
1274
+ if (yMode) opts.yMode = yMode;
1275
+ const wMode = readValStr(ml, "c:wMode");
1276
+ if (wMode) opts.wMode = wMode;
1277
+ const hMode = readValStr(ml, "c:hMode");
1278
+ if (hMode) opts.hMode = hMode;
1279
+ const x = readValNum(ml, "c:x");
1280
+ if (x !== void 0) opts.x = x;
1281
+ const y = readValNum(ml, "c:y");
1282
+ if (y !== void 0) opts.y = y;
1283
+ const w = readValNum(ml, "c:w");
1284
+ if (w !== void 0) opts.w = w;
1285
+ const h = readValNum(ml, "c:h");
1286
+ if (h !== void 0) opts.h = h;
1287
+ return Object.keys(opts).length ? opts : void 0;
1288
+ }
1289
+ function readSurface(chartEl, tag, ctx) {
1290
+ const el = findChild(chartEl, tag);
1291
+ if (!el) return void 0;
1292
+ const opts = {};
1293
+ const thickness = readValStr(el, "c:thickness");
1294
+ if (thickness !== void 0) opts.thickness = thickness.endsWith("%") ? thickness : Number(thickness);
1295
+ const spPr = findChild(el, "c:spPr");
1296
+ if (spPr) opts.shapeProperties = shapePropertiesDesc.parse(spPr, ctx);
1297
+ return opts;
1298
+ }
1299
+ function readChartTypeScalars(chartTypeEl, type, threeD, result, ctx) {
1300
+ if (!chartTypeEl) return;
1301
+ if (type !== "surface" && type !== "stock") {
1302
+ const varyColors = readBoolAttr(chartTypeEl, "c:varyColors");
1303
+ if (varyColors !== void 0) result.varyColors = varyColors;
1304
+ }
1305
+ if (type === "column" || type === "bar" || type === "line" || type === "area") {
1306
+ const grouping = readValStr(chartTypeEl, "c:grouping");
1307
+ if (grouping) {
1308
+ if (grouping !== (type === "column" || type === "bar" ? "clustered" : "standard")) result.grouping = grouping;
1309
+ }
1310
+ }
1311
+ if (type === "column" || type === "bar") {
1312
+ const gapWidth = readValNum(chartTypeEl, "c:gapWidth");
1313
+ if (gapWidth !== void 0) result.gapWidth = gapWidth;
1314
+ if (threeD) {
1315
+ const gapDepth = readValNum(chartTypeEl, "c:gapDepth");
1316
+ if (gapDepth !== void 0) result.gapDepth = gapDepth;
1317
+ const shape = readValStr(chartTypeEl, "c:shape");
1318
+ if (shape) result.shape = shape;
1319
+ } else {
1320
+ const overlap = readValNum(chartTypeEl, "c:overlap");
1321
+ if (overlap !== void 0) result.overlap = overlap;
1322
+ }
1323
+ } else if (type === "area" && threeD) {
1324
+ const gapDepth = readValNum(chartTypeEl, "c:gapDepth");
1325
+ if (gapDepth !== void 0) result.gapDepth = gapDepth;
1326
+ } else if (type === "pie" || type === "doughnut") {
1327
+ const firstSliceAng = readValNum(chartTypeEl, "c:firstSliceAng");
1328
+ if (firstSliceAng !== void 0) result.firstSliceAngle = firstSliceAng;
1329
+ const holeSize = readValNum(chartTypeEl, "c:holeSize");
1330
+ if (holeSize !== void 0) result.holeSize = holeSize;
1331
+ } else if (type === "bubble") {
1332
+ const bubbleScale = readValNum(chartTypeEl, "c:bubbleScale");
1333
+ if (bubbleScale !== void 0) result.bubbleScale = bubbleScale;
1334
+ const showNeg = readBoolAttr(chartTypeEl, "c:showNegBubbles");
1335
+ if (showNeg !== void 0) result.showNegativeBubbles = showNeg;
1336
+ const sizeRep = readValStr(chartTypeEl, "c:sizeRepresents");
1337
+ if (sizeRep) result.sizeRepresents = xsdSizeRepresents.from(sizeRep);
1338
+ } else if (type === "surface") {
1339
+ const wireframe = readBoolAttr(chartTypeEl, "c:wireframe");
1340
+ if (wireframe !== void 0) result.wireframe = wireframe;
1341
+ const bandFormats = readBandFormats(chartTypeEl);
1342
+ if (bandFormats) result.bandFormats = bandFormats;
1343
+ } else if (type === "radar") {
1344
+ const radarStyle = readValStr(chartTypeEl, "c:radarStyle");
1345
+ if (radarStyle) result.radarStyle = radarStyle;
1346
+ } else if (type === "ofPie") {
1347
+ const ofPieType = readValStr(chartTypeEl, "c:ofPieType");
1348
+ if (ofPieType) result.ofPieType = ofPieType;
1349
+ const gapWidth = readValNum(chartTypeEl, "c:gapWidth");
1350
+ if (gapWidth !== void 0) result.gapWidth = gapWidth;
1351
+ const splitType = readValStr(chartTypeEl, "c:splitType");
1352
+ if (splitType) result.splitType = xsdSplitType.from(splitType);
1353
+ const splitPos = readValNum(chartTypeEl, "c:splitPos");
1354
+ if (splitPos !== void 0) result.splitPosition = splitPos;
1355
+ const custSplit = findChild(chartTypeEl, "c:custSplit");
1356
+ if (custSplit) {
1357
+ const pts = children(custSplit, "c:secondPiePt").map((el) => attr(el, "val")).filter((v) => v !== void 0).map(Number);
1358
+ if (pts.length) result.customSplitPoints = pts;
1359
+ }
1360
+ const secondPieSize = readValStr(chartTypeEl, "c:secondPieSize");
1361
+ if (secondPieSize !== void 0) result.secondPieSize = secondPieSize.endsWith("%") ? secondPieSize : Number(secondPieSize);
1362
+ const seriesLines = readChartLines(chartTypeEl, "c:serLines", ctx);
1363
+ if (seriesLines !== void 0) result.seriesLines = seriesLines;
1364
+ }
1365
+ }
1366
+ function readChartTypeDecorations(chartTypeEl, type, threeD, result, ctx) {
1367
+ if (!chartTypeEl) return;
1368
+ const readUpDownBars = (el) => {
1369
+ result.upDownBars = true;
1370
+ const gw = readValNum(el, "c:gapWidth");
1371
+ if (gw !== void 0) result.upDownBarsGapWidth = gw;
1372
+ };
1373
+ if (type === "line") {
1374
+ if (threeD) {
1375
+ const dropLinesV = readChartLines(chartTypeEl, "c:dropLines", ctx);
1376
+ if (dropLinesV !== void 0) result.dropLines = dropLinesV;
1377
+ } else {
1378
+ const highLowLinesV = readChartLines(chartTypeEl, "c:hiLowLines", ctx);
1379
+ if (highLowLinesV !== void 0) result.highLowLines = highLowLinesV;
1380
+ const upDownBars = findChild(chartTypeEl, "c:upDownBars");
1381
+ if (upDownBars) readUpDownBars(upDownBars);
1382
+ const dropLinesV = readChartLines(chartTypeEl, "c:dropLines", ctx);
1383
+ if (dropLinesV !== void 0) result.dropLines = dropLinesV;
1384
+ const markers = readBoolAttr(chartTypeEl, "c:marker");
1385
+ if (markers !== void 0) result.markers = markers;
1386
+ const smooth = readBoolAttr(chartTypeEl, "c:smooth");
1387
+ if (smooth !== void 0) result.smooth = smooth;
1388
+ }
1389
+ } else if (type === "area") {
1390
+ const dropLinesV = readChartLines(chartTypeEl, "c:dropLines", ctx);
1391
+ if (dropLinesV !== void 0) result.dropLines = dropLinesV;
1392
+ const threeDSeriesLines = readChartLines(chartTypeEl, "c:serLines", ctx);
1393
+ if (threeD && threeDSeriesLines !== void 0) result.seriesLines = threeDSeriesLines;
1394
+ } else if (type === "stock") {
1395
+ const dropLinesV = readChartLines(chartTypeEl, "c:dropLines", ctx);
1396
+ if (dropLinesV !== void 0) result.dropLines = dropLinesV;
1397
+ const highLowLinesV = readChartLines(chartTypeEl, "c:hiLowLines", ctx);
1398
+ if (highLowLinesV !== void 0) result.highLowLines = highLowLinesV;
1399
+ const upDownBars = findChild(chartTypeEl, "c:upDownBars");
1400
+ if (upDownBars) readUpDownBars(upDownBars);
1401
+ const seriesLines = readChartLines(chartTypeEl, "c:serLines", ctx);
1402
+ if (seriesLines !== void 0) result.seriesLines = seriesLines;
1403
+ } else if ((type === "column" || type === "bar") && !threeD) {
1404
+ const seriesLines = readChartLines(chartTypeEl, "c:serLines", ctx);
1405
+ if (seriesLines !== void 0) result.seriesLines = seriesLines;
1406
+ }
1407
+ }
1408
+ function readDataTable(plotArea, ctx) {
1409
+ if (!plotArea) return void 0;
1410
+ const dTable = findChild(plotArea, "c:dTable");
1411
+ if (!dTable) return void 0;
1412
+ const opts = {};
1413
+ const horz = readBoolAttr(dTable, "c:showHorzBorder");
1414
+ if (horz !== void 0) opts.showHorizontalBorder = horz;
1415
+ const vert = readBoolAttr(dTable, "c:showVertBorder");
1416
+ if (vert !== void 0) opts.showVerticalBorder = vert;
1417
+ const outline = readBoolAttr(dTable, "c:showOutline");
1418
+ if (outline !== void 0) opts.showOutline = outline;
1419
+ const keys = readBoolAttr(dTable, "c:showKeys");
1420
+ if (keys !== void 0) opts.showLegendKeys = keys;
1421
+ const spPrEl = findChild(dTable, "c:spPr");
1422
+ if (spPrEl) opts.shapeProperties = shapePropertiesDesc.parse(spPrEl, ctx);
1423
+ const txPrEl = findChild(dTable, "c:txPr");
1424
+ if (txPrEl) opts.textProperties = textBodyDesc.parse(txPrEl, ctx);
1425
+ return opts;
1426
+ }
1427
+ function readProtection(el) {
1428
+ const protection = findChild(el, "c:protection");
1429
+ if (!protection) return void 0;
1430
+ const opts = {};
1431
+ const readFlag = (tag) => {
1432
+ const child = findChild(protection, tag);
1433
+ if (!child) return void 0;
1434
+ const v = attr(child, "val");
1435
+ return v === void 0 ? void 0 : parseOnOff(v) ?? true;
1436
+ };
1437
+ const chartObject = readFlag("c:chartObject");
1438
+ if (chartObject !== void 0) opts.chartObject = chartObject;
1439
+ const data = readFlag("c:data");
1440
+ if (data !== void 0) opts.data = data;
1441
+ const formatting = readFlag("c:formatting");
1442
+ if (formatting !== void 0) opts.formatting = formatting;
1443
+ const selection = readFlag("c:selection");
1444
+ if (selection !== void 0) opts.selection = selection;
1445
+ const userInterface = readFlag("c:userInterface");
1446
+ if (userInterface !== void 0) opts.userInterface = userInterface;
1447
+ return Object.keys(opts).length ? opts : void 0;
1448
+ }
1449
+ function readExternalData(el) {
1450
+ const externalData = findChild(el, "c:externalData");
1451
+ if (!externalData) return void 0;
1452
+ const relationshipId = attr(externalData, "r:id");
1453
+ if (relationshipId === void 0) return void 0;
1454
+ const opts = { relationshipId };
1455
+ const autoUpdateEl = findChild(externalData, "c:autoUpdate");
1456
+ if (autoUpdateEl) {
1457
+ const v = attr(autoUpdateEl, "val");
1458
+ if (v !== void 0) opts.autoUpdate = parseOnOff(v) ?? true;
1459
+ }
1460
+ return opts;
1461
+ }
1462
+ function readPivotSource(el) {
1463
+ const ps = findChild(el, "c:pivotSource");
1464
+ if (!ps) return void 0;
1465
+ const nameEl = findChild(ps, "c:name");
1466
+ const fmtIdEl = findChild(ps, "c:fmtId");
1467
+ if (!nameEl || !fmtIdEl) return void 0;
1468
+ return {
1469
+ name: textOf(nameEl) ?? "",
1470
+ formatId: Number(attr(fmtIdEl, "val"))
1471
+ };
1472
+ }
1473
+ function readPivotFormats(chart, ctx) {
1474
+ const pf = findChild(chart, "c:pivotFmts");
1475
+ if (!pf) return void 0;
1476
+ const result = [];
1477
+ for (const fmt of children(pf, "c:pivotFmt")) {
1478
+ const idxEl = findChild(fmt, "c:idx");
1479
+ if (!idxEl) continue;
1480
+ const opt = { index: Number(attr(idxEl, "val")) };
1481
+ const marker = readMarker$1(fmt, ctx);
1482
+ if (marker) opt.marker = marker;
1483
+ result.push(opt);
1484
+ }
1485
+ return result.length ? result : void 0;
1486
+ }
1487
+ function readBandFormats(chartTypeEl) {
1488
+ const bf = findChild(chartTypeEl, "c:bandFmts");
1489
+ if (!bf) return void 0;
1490
+ const result = [];
1491
+ for (const fmt of children(bf, "c:bandFmt")) {
1492
+ const idxEl = findChild(fmt, "c:idx");
1493
+ if (idxEl) result.push({ index: Number(attr(idxEl, "val")) });
1494
+ }
1495
+ return result.length ? result : void 0;
1496
+ }
1497
+ function readLegendEntries(legend, ctx) {
1498
+ const entries = children(legend, "c:legendEntry");
1499
+ if (!entries.length) return void 0;
1500
+ const result = [];
1501
+ for (const entry of entries) {
1502
+ const idxEl = findChild(entry, "c:idx");
1503
+ if (!idxEl) continue;
1504
+ const deleteEl = findChild(entry, "c:delete");
1505
+ if (deleteEl) {
1506
+ const v = attr(deleteEl, "val");
1507
+ result.push({
1508
+ index: Number(attr(idxEl, "val")),
1509
+ delete: parseOnOff(v) ?? true
1510
+ });
1511
+ continue;
1512
+ }
1513
+ const txPrEl = findChild(entry, "c:txPr");
1514
+ if (txPrEl) result.push({
1515
+ index: Number(attr(idxEl, "val")),
1516
+ textProperties: textBodyDesc.parse(txPrEl, ctx)
1517
+ });
1518
+ }
1519
+ return result.length ? result : void 0;
1520
+ }
1521
+ function readLegend(chart, ctx) {
1522
+ const legend = findChild(chart, "c:legend");
1523
+ if (!legend) return void 0;
1524
+ const result = {};
1525
+ const posEl = findChild(legend, "c:legendPos");
1526
+ if (posEl) {
1527
+ const v = attr(posEl, "val");
1528
+ if (v) result.position = xsdLegendPosition.from(v);
1529
+ }
1530
+ const entries = readLegendEntries(legend, ctx);
1531
+ if (entries) result.entries = entries;
1532
+ const layoutEl = findChild(legend, "c:layout");
1533
+ if (layoutEl) result.layout = readManualLayout(layoutEl) ?? true;
1534
+ const overlayEl = findChild(legend, "c:overlay");
1535
+ if (overlayEl) result.overlay = parseOnOff(attr(overlayEl, "val")) ?? false;
1536
+ const spPrEl = findChild(legend, "c:spPr");
1537
+ if (spPrEl) result.shapeProperties = shapePropertiesDesc.parse(spPrEl, ctx);
1538
+ const txPr = findChild(legend, "c:txPr");
1539
+ if (txPr) result.textProperties = textBodyDesc.parse(txPr, ctx);
1540
+ return Object.keys(result).length ? result : void 0;
1541
+ }
1542
+ function readHeaderFooter(ps) {
1543
+ const hf = findChild(ps, "c:headerFooter");
1544
+ if (!hf) return void 0;
1545
+ const opts = {};
1546
+ const readStr = (tag) => {
1547
+ const child = findChild(hf, tag);
1548
+ return child ? textOf(child) : void 0;
1549
+ };
1550
+ const oh = readStr("c:oddHeader");
1551
+ if (oh !== void 0) opts.oddHeader = oh;
1552
+ const of = readStr("c:oddFooter");
1553
+ if (of !== void 0) opts.oddFooter = of;
1554
+ const eh = readStr("c:evenHeader");
1555
+ if (eh !== void 0) opts.evenHeader = eh;
1556
+ const ef = readStr("c:evenFooter");
1557
+ if (ef !== void 0) opts.evenFooter = ef;
1558
+ const fh = readStr("c:firstHeader");
1559
+ if (fh !== void 0) opts.firstHeader = fh;
1560
+ const ff = readStr("c:firstFooter");
1561
+ if (ff !== void 0) opts.firstFooter = ff;
1562
+ const readFlag = (name) => {
1563
+ const v = attr(hf, name);
1564
+ return v === void 0 ? void 0 : parseOnOff(v) ?? true;
1565
+ };
1566
+ const alignWithMargins = readFlag("alignWithMargins");
1567
+ if (alignWithMargins !== void 0) opts.alignWithMargins = alignWithMargins;
1568
+ const differentOddEven = readFlag("differentOddEven");
1569
+ if (differentOddEven !== void 0) opts.differentOddEven = differentOddEven;
1570
+ const differentFirst = readFlag("differentFirst");
1571
+ if (differentFirst !== void 0) opts.differentFirst = differentFirst;
1572
+ return opts;
1573
+ }
1574
+ function readPageMargins(ps) {
1575
+ const pm = findChild(ps, "c:pageMargins");
1576
+ if (!pm) return void 0;
1577
+ const opts = {};
1578
+ const readNum = (name) => {
1579
+ const v = attr(pm, name);
1580
+ return v === void 0 ? void 0 : Number(v);
1581
+ };
1582
+ const left = readNum("l");
1583
+ if (left !== void 0) opts.left = left;
1584
+ const right = readNum("r");
1585
+ if (right !== void 0) opts.right = right;
1586
+ const top = readNum("t");
1587
+ if (top !== void 0) opts.top = top;
1588
+ const bottom = readNum("b");
1589
+ if (bottom !== void 0) opts.bottom = bottom;
1590
+ const header = readNum("header");
1591
+ if (header !== void 0) opts.header = header;
1592
+ const footer = readNum("footer");
1593
+ if (footer !== void 0) opts.footer = footer;
1594
+ return Object.keys(opts).length ? opts : void 0;
1595
+ }
1596
+ function readPageSetup(ps) {
1597
+ const pg = findChild(ps, "c:pageSetup");
1598
+ if (!pg) return void 0;
1599
+ const opts = {};
1600
+ const readNum = (name) => {
1601
+ const v = attr(pg, name);
1602
+ return v === void 0 ? void 0 : Number(v);
1603
+ };
1604
+ const readFlag = (name) => {
1605
+ const v = attr(pg, name);
1606
+ return v === void 0 ? void 0 : parseOnOff(v) ?? true;
1607
+ };
1608
+ const paperSize = readNum("paperSize");
1609
+ if (paperSize !== void 0) opts.paperSize = paperSize;
1610
+ const paperHeight = attr(pg, "paperHeight");
1611
+ if (paperHeight !== void 0) opts.paperHeight = paperHeight;
1612
+ const paperWidth = attr(pg, "paperWidth");
1613
+ if (paperWidth !== void 0) opts.paperWidth = paperWidth;
1614
+ const firstPageNumber = readNum("firstPageNumber");
1615
+ if (firstPageNumber !== void 0) opts.firstPageNumber = firstPageNumber;
1616
+ const orientation = attr(pg, "orientation");
1617
+ if (orientation !== void 0) opts.orientation = orientation;
1618
+ const blackAndWhite = readFlag("blackAndWhite");
1619
+ if (blackAndWhite !== void 0) opts.blackAndWhite = blackAndWhite;
1620
+ const draft = readFlag("draft");
1621
+ if (draft !== void 0) opts.draft = draft;
1622
+ const useFirstPageNumber = readFlag("useFirstPageNumber");
1623
+ if (useFirstPageNumber !== void 0) opts.useFirstPageNumber = useFirstPageNumber;
1624
+ const horizontalDpi = readNum("horizontalDpi");
1625
+ if (horizontalDpi !== void 0) opts.horizontalDpi = horizontalDpi;
1626
+ const verticalDpi = readNum("verticalDpi");
1627
+ if (verticalDpi !== void 0) opts.verticalDpi = verticalDpi;
1628
+ const copies = readNum("copies");
1629
+ if (copies !== void 0) opts.copies = copies;
1630
+ return opts;
1631
+ }
1632
+ function readPrintSettings(el) {
1633
+ const ps = findChild(el, "c:printSettings");
1634
+ if (!ps) return void 0;
1635
+ const opts = {};
1636
+ const headerFooter = readHeaderFooter(ps);
1637
+ if (headerFooter) opts.headerFooter = headerFooter;
1638
+ const pageMargins = readPageMargins(ps);
1639
+ if (pageMargins) opts.pageMargins = pageMargins;
1640
+ const pageSetup = readPageSetup(ps);
1641
+ if (pageSetup) opts.pageSetup = pageSetup;
1642
+ const legacyDrawingHF = findChild(ps, "c:legacyDrawingHF");
1643
+ if (legacyDrawingHF) {
1644
+ const rId = attr(legacyDrawingHF, "r:id");
1645
+ if (rId !== void 0) opts.legacyDrawingId = rId;
1646
+ }
1647
+ return Object.keys(opts).length ? opts : void 0;
1648
+ }
1649
+ const AXIS_KIND_BY_TAG = {
1650
+ "c:catAx": "category",
1651
+ "c:valAx": "value",
1652
+ "c:dateAx": "date",
1653
+ "c:serAx": "series"
1654
+ };
1655
+ function readAxis(el, kind, ctx) {
1656
+ const result = {
1657
+ kind,
1658
+ id: readValNum(el, "c:axId") ?? 0,
1659
+ crossAxisId: readValNum(el, "c:crossAx") ?? 0
1660
+ };
1661
+ const scalingEl = findChild(el, "c:scaling");
1662
+ if (scalingEl) {
1663
+ const scaling = {};
1664
+ const logBase = readValNum(scalingEl, "c:logBase");
1665
+ if (logBase !== void 0) scaling.logBase = logBase;
1666
+ const orientation = readValStr(scalingEl, "c:orientation");
1667
+ if (orientation) scaling.orientation = xsdAxisOrientation.from(orientation);
1668
+ const max = readValNum(scalingEl, "c:max");
1669
+ if (max !== void 0) scaling.max = max;
1670
+ const min = readValNum(scalingEl, "c:min");
1671
+ if (min !== void 0) scaling.min = min;
1672
+ if (logBase !== void 0 || orientation || max !== void 0 || min !== void 0) result.scaling = scaling;
1673
+ }
1674
+ const del = readBoolAttr(el, "c:delete");
1675
+ if (del !== void 0) result.delete = del;
1676
+ const pos = readValStr(el, "c:axPos");
1677
+ if (pos) result.position = xsdAxisPosition.from(pos);
1678
+ result.majorGridlines = readChartLines(el, "c:majorGridlines", ctx);
1679
+ result.minorGridlines = readChartLines(el, "c:minorGridlines", ctx);
1680
+ const titleEl = findChild(el, "c:title");
1681
+ if (titleEl) result.title = readTitle(titleEl, ctx);
1682
+ const numFmtEl = findChild(el, "c:numFmt");
1683
+ if (numFmtEl) {
1684
+ const formatCode = attr(numFmtEl, "formatCode");
1685
+ if (formatCode) result.numberFormat = attr(numFmtEl, "sourceLinked") === "0" ? {
1686
+ formatCode,
1687
+ sourceLinked: false
1688
+ } : formatCode;
1689
+ }
1690
+ const majorTickMark = readValStr(el, "c:majorTickMark");
1691
+ if (majorTickMark) result.majorTickMark = majorTickMark;
1692
+ const minorTickMark = readValStr(el, "c:minorTickMark");
1693
+ if (minorTickMark) result.minorTickMark = minorTickMark;
1694
+ const tickLblPos = readValStr(el, "c:tickLblPos");
1695
+ if (tickLblPos) result.tickLabelPosition = tickLblPos;
1696
+ const spPrEl = findChild(el, "c:spPr");
1697
+ if (spPrEl) result.shapeProperties = shapePropertiesDesc.parse(spPrEl, ctx);
1698
+ const axisTxPr = findChild(el, "c:txPr");
1699
+ if (axisTxPr) result.textProperties = textBodyDesc.parse(axisTxPr, ctx);
1700
+ const crossesAt = readValNum(el, "c:crossesAt");
1701
+ if (crossesAt !== void 0) result.crossesAt = crossesAt;
1702
+ else {
1703
+ const crosses = readValStr(el, "c:crosses");
1704
+ if (crosses) result.crosses = xsdAxisCrosses.from(crosses);
1705
+ }
1706
+ if (kind === "category" || kind === "date") {
1707
+ const auto = readBoolAttr(el, "c:auto");
1708
+ if (auto !== void 0) result.auto = auto;
1709
+ }
1710
+ if (kind === "category") {
1711
+ const lblAlgn = readValStr(el, "c:lblAlgn");
1712
+ if (lblAlgn) result.labelAlignment = xsdAxisLabelAlignment.from(lblAlgn);
1713
+ }
1714
+ if (kind === "category" || kind === "date") {
1715
+ const lblOffsetEl = findChild(el, "c:lblOffset");
1716
+ if (lblOffsetEl) {
1717
+ const v = attr(lblOffsetEl, "val");
1718
+ if (v !== void 0) result.labelOffset = v.endsWith("%") ? v : Number(v);
1719
+ }
1720
+ }
1721
+ if (kind === "category" || kind === "series") {
1722
+ const tickLblSkip = readValNum(el, "c:tickLblSkip");
1723
+ if (tickLblSkip !== void 0) result.tickLabelSkip = tickLblSkip;
1724
+ const tickMarkSkip = readValNum(el, "c:tickMarkSkip");
1725
+ if (tickMarkSkip !== void 0) result.tickMarkSkip = tickMarkSkip;
1726
+ }
1727
+ if (kind === "category") {
1728
+ const noMulti = readBoolAttr(el, "c:noMultiLvlLbl");
1729
+ if (noMulti !== void 0) result.noMultiLevelLabel = noMulti;
1730
+ }
1731
+ if (kind === "date") {
1732
+ const baseTimeUnit = readValStr(el, "c:baseTimeUnit");
1733
+ if (baseTimeUnit) result.baseTimeUnit = baseTimeUnit;
1734
+ const majorTimeUnit = readValStr(el, "c:majorTimeUnit");
1735
+ if (majorTimeUnit) result.majorTimeUnit = majorTimeUnit;
1736
+ const minorTimeUnit = readValStr(el, "c:minorTimeUnit");
1737
+ if (minorTimeUnit) result.minorTimeUnit = minorTimeUnit;
1738
+ }
1739
+ if (kind === "date" || kind === "value") {
1740
+ const majorUnit = readValNum(el, "c:majorUnit");
1741
+ if (majorUnit !== void 0) result.majorUnit = majorUnit;
1742
+ const minorUnit = readValNum(el, "c:minorUnit");
1743
+ if (minorUnit !== void 0) result.minorUnit = minorUnit;
1744
+ }
1745
+ if (kind === "value") {
1746
+ const crossBetween = readValStr(el, "c:crossBetween");
1747
+ if (crossBetween) result.crossBetween = xsdAxisCrossBetween.from(crossBetween);
1748
+ const dispUnitsEl = findChild(el, "c:dispUnits");
1749
+ if (dispUnitsEl) {
1750
+ const displayUnits = {};
1751
+ const customUnit = readValNum(dispUnitsEl, "c:custUnit");
1752
+ if (customUnit !== void 0) displayUnits.customUnit = customUnit;
1753
+ const builtInUnit = readValStr(dispUnitsEl, "c:builtInUnit");
1754
+ if (builtInUnit) displayUnits.builtInUnit = builtInUnit;
1755
+ if (findChild(dispUnitsEl, "c:dispUnitsLbl")) displayUnits.label = true;
1756
+ if (customUnit !== void 0 || builtInUnit || displayUnits.label) result.displayUnits = displayUnits;
1757
+ }
1758
+ }
1759
+ return result;
1760
+ }
1761
+ /** Read all axis elements (c:catAx/c:valAx/c:dateAx/c:serAx) under plotArea. */
1762
+ function readAxes(plotArea, ctx) {
1763
+ if (!plotArea?.elements) return void 0;
1764
+ const axes = [];
1765
+ for (const child of plotArea.elements) {
1766
+ if (!child.name) continue;
1767
+ const kind = AXIS_KIND_BY_TAG[child.name];
1768
+ if (kind) axes.push(readAxis(child, kind, ctx));
1769
+ }
1770
+ return axes.length > 0 ? axes : void 0;
1771
+ }
1772
+ const chartSpaceDesc = {
1773
+ kind: "custom",
1774
+ stringify(opts, ctx) {
1775
+ const parts = [];
1776
+ const ns = opts.dialect === "strict" ? `xmlns:c="http://purl.oclc.org/ooxml/drawingml/chart" xmlns:a="http://purl.oclc.org/ooxml/drawingml/main" xmlns:r="http://purl.oclc.org/ooxml/officeDocument/relationships"` : `xmlns:c="http://schemas.openxmlformats.org/drawingml/2006/chart" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"`;
1777
+ parts.push(`<c:chartSpace ${ns}>`);
1778
+ if (opts.date1904 !== void 0) parts.push(`<c:date1904${boolVal(opts.date1904)}/>`);
1779
+ if (opts.lang !== void 0) parts.push(valEl("c:lang", opts.lang));
1780
+ if (opts.roundedCorners !== void 0) parts.push(`<c:roundedCorners${boolVal(opts.roundedCorners)}/>`);
1781
+ if (opts.style2010) {
1782
+ const fallback = opts.style2010.fallbackStyle !== void 0 ? `<mc:Fallback>${valEl("c:style", opts.style2010.fallbackStyle)}</mc:Fallback>` : "";
1783
+ parts.push(`<mc:AlternateContent xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"><mc:Choice xmlns:c14="http://schemas.microsoft.com/office/drawing/2007/8/2/chart" Requires="c14"><c14:style val="${opts.style2010.style}"/></mc:Choice>${fallback}</mc:AlternateContent>`);
1784
+ } else if (opts.style !== void 0) parts.push(valEl("c:style", opts.style));
1785
+ if (opts.colorMappingOverride) parts.push(stringifyColorMapping(opts.colorMappingOverride, "c:clrMapOvr"));
1786
+ if (opts.pivotSource) parts.push(stringifyPivotSource(opts.pivotSource));
1787
+ if (opts.protection) parts.push(stringifyProtection(opts.protection));
1788
+ parts.push("<c:chart>");
1789
+ if (opts.title !== void 0) parts.push(typeof opts.title === "string" && opts.title === "" ? emptyEl("c:title") : stringifyTitle(opts.title, ctx));
1790
+ if (opts.autoTitleDeleted !== void 0) parts.push(`<c:autoTitleDeleted${boolVal(opts.autoTitleDeleted)}/>`);
1791
+ if (opts.pivotFormats?.length) parts.push(stringifyPivotFormats(opts.pivotFormats, ctx));
1792
+ if (opts.view3D) parts.push(stringifyView3D(opts.view3D));
1793
+ parts.push(stringifySurface("c:floor", opts.floor, ctx));
1794
+ parts.push(stringifySurface("c:sideWall", opts.sideWall, ctx));
1795
+ parts.push(stringifySurface("c:backWall", opts.backWall, ctx));
1796
+ parts.push(`<c:plotArea>${stringifyLayout(opts.plotAreaLayout)}`);
1797
+ parts.push(chartTypeHeader(opts));
1798
+ for (const [i, series] of (opts.series ?? []).entries()) parts.push(stringifySeries(i, series, opts, ctx));
1799
+ if (opts.dataLabels) parts.push(stringifyDataLabels(opts.dataLabels, ctx));
1800
+ parts.push(chartTypeFooter(opts, ctx));
1801
+ for (const g of opts.secondaryGroups ?? []) parts.push(stringifySecondaryGroup(g, opts, ctx));
1802
+ parts.push(stringifyAxes(opts, ctx));
1803
+ if (opts.dataTable) parts.push(stringifyDataTable(opts.dataTable, ctx));
1804
+ parts.push(chartSpPr(opts.plotAreaShapeProperties, ctx));
1805
+ parts.push("</c:plotArea>");
1806
+ if (opts.showLegend !== false) parts.push(stringifyLegend(opts, ctx));
1807
+ parts.push(`<c:plotVisOnly${boolVal(opts.plotVisOnly ?? true)}/>`);
1808
+ if (opts.displayBlanksAs !== void 0) parts.push(valEl("c:dispBlanksAs", opts.displayBlanksAs));
1809
+ if (opts.showDataLabelsOverMax !== void 0) parts.push(`<c:showDLblsOverMax${boolVal(opts.showDataLabelsOverMax)}/>`);
1810
+ parts.push("</c:chart>");
1811
+ parts.push(chartSpPr(opts.shapeProperties, ctx));
1812
+ if (opts.textProperties) parts.push(`<c:txPr>${textBodyDesc.stringify(opts.textProperties, ctx) ?? ""}</c:txPr>`);
1813
+ if (opts.externalData) {
1814
+ const ext = stringifyExternalData(opts.externalData);
1815
+ if (ext) parts.push(ext);
1816
+ }
1817
+ if (opts.printSettings) parts.push(stringifyPrintSettings(opts.printSettings));
1818
+ if (opts.userShapes !== void 0) parts.push(`<c:userShapes r:id="${escapeXml(opts.userShapes)}"/>`);
1819
+ if (opts.ext) parts.push(`<c:extLst>${opts.ext}</c:extLst>`);
1820
+ parts.push("</c:chartSpace>");
1821
+ return parts.join("");
1822
+ },
1823
+ parse(el, ctx) {
1824
+ const result = {};
1825
+ if (el.attributes?.["xmlns:c"] === "http://purl.oclc.org/ooxml/drawingml/chart") result.dialect = "strict";
1826
+ const date1904 = readBoolAttr(el, "c:date1904");
1827
+ if (date1904 !== void 0) result.date1904 = date1904;
1828
+ const langVal = readValStr(el, "c:lang");
1829
+ if (langVal) result.lang = langVal;
1830
+ const roundedCorners = readBoolAttr(el, "c:roundedCorners");
1831
+ if (roundedCorners !== void 0) result.roundedCorners = roundedCorners;
1832
+ const mcStyleEl = findChild(el, "mc:AlternateContent");
1833
+ const c14StyleEl = mcStyleEl && findChild(findChild(mcStyleEl, "mc:Choice") ?? mcStyleEl, "c14:style");
1834
+ if (c14StyleEl?.attributes?.["val"] !== void 0) {
1835
+ const fallbackEl = findFirst(mcStyleEl, "c:style");
1836
+ result.style2010 = {
1837
+ style: Number(c14StyleEl.attributes["val"]),
1838
+ ...fallbackEl?.attributes?.["val"] !== void 0 ? { fallbackStyle: Number(fallbackEl.attributes["val"]) } : {}
1839
+ };
1840
+ } else {
1841
+ const styleEl = findChild(el, "c:style");
1842
+ if (styleEl?.attributes?.["val"] !== void 0) result.style = Number(styleEl.attributes["val"]);
1843
+ }
1844
+ const colorMappingOverride = parseColorMapping(findChild(el, "c:clrMapOvr"));
1845
+ if (colorMappingOverride) result.colorMappingOverride = colorMappingOverride;
1846
+ const protection = readProtection(el);
1847
+ if (protection) result.protection = protection;
1848
+ const pivotSource = readPivotSource(el);
1849
+ if (pivotSource) result.pivotSource = pivotSource;
1850
+ const chart = findChild(el, "c:chart");
1851
+ if (!chart) return result;
1852
+ const titleEl = findChild(chart, "c:title");
1853
+ if (titleEl) result.title = readTitle(titleEl, ctx);
1854
+ const autoTitleDeleted = readBoolAttr(chart, "c:autoTitleDeleted");
1855
+ if (autoTitleDeleted !== void 0) result.autoTitleDeleted = autoTitleDeleted;
1856
+ const pivotFormats = readPivotFormats(chart, ctx);
1857
+ if (pivotFormats) result.pivotFormats = pivotFormats;
1858
+ const view3D = readView3D(chart);
1859
+ if (view3D) result.view3D = view3D;
1860
+ const floor = readSurface(chart, "c:floor", ctx);
1861
+ if (floor) result.floor = floor;
1862
+ const sideWall = readSurface(chart, "c:sideWall", ctx);
1863
+ if (sideWall) result.sideWall = sideWall;
1864
+ const backWall = readSurface(chart, "c:backWall", ctx);
1865
+ if (backWall) result.backWall = backWall;
1866
+ const plotArea = findChild(chart, "c:plotArea");
1867
+ if (plotArea?.elements) {
1868
+ const manualLayout = readManualLayout(findChild(plotArea, "c:layout"));
1869
+ if (manualLayout) result.plotAreaLayout = manualLayout;
1870
+ const dataTable = readDataTable(plotArea, ctx);
1871
+ if (dataTable) result.dataTable = dataTable;
1872
+ let detectedType;
1873
+ let threeD = false;
1874
+ let chartTypeEl;
1875
+ const secondaryEls = [];
1876
+ for (const child of plotArea.elements) {
1877
+ if (!child.name) continue;
1878
+ const mapping = TAG_TO_CHART_TYPE[child.name];
1879
+ if (mapping) {
1880
+ if (chartTypeEl) {
1881
+ secondaryEls.push(child);
1882
+ continue;
1883
+ }
1884
+ detectedType = mapping.type;
1885
+ threeD = mapping.threeD ?? false;
1886
+ chartTypeEl = child;
1887
+ if (child.name === "c:barChart" || child.name === "c:bar3DChart") {
1888
+ const barDir = findChild(child, "c:barDir");
1889
+ const barDirVal = barDir ? attr(barDir, "val") : void 0;
1890
+ if (barDirVal === "bar") detectedType = "bar";
1891
+ else if (barDirVal === "col") detectedType = "column";
1892
+ }
1893
+ }
1894
+ }
1895
+ if (detectedType && chartTypeEl) {
1896
+ result.type = detectedType;
1897
+ if (threeD) result.threeD = true;
1898
+ readChartTypeScalars(chartTypeEl, detectedType, threeD, result, ctx);
1899
+ readChartTypeDecorations(chartTypeEl, detectedType, threeD, result, ctx);
1900
+ const groupLabels = readDataLabels(chartTypeEl, ctx);
1901
+ if (groupLabels) result.dataLabels = groupLabels;
1902
+ const axIdEls = children(chartTypeEl, "c:axId");
1903
+ if (axIdEls.length > 0) result.axisIds = axIdEls.map((e) => Number(attr(e, "val"))).filter((n) => !isNaN(n));
1904
+ }
1905
+ const seriesEls = chartTypeEl ? children(chartTypeEl, "c:ser") : [];
1906
+ if (seriesEls.length > 0) {
1907
+ if (detectedType === "bubble") {
1908
+ const bubbleSeries = [];
1909
+ for (const serEl of seriesEls) {
1910
+ const { name } = readSeriesName(serEl);
1911
+ const xVal = findChild(serEl, "c:xVal");
1912
+ const yVal = findChild(serEl, "c:yVal");
1913
+ const bubbleSize = findChild(serEl, "c:bubbleSize");
1914
+ bubbleSeries.push({
1915
+ name,
1916
+ xValues: xVal ? readNumCache(xVal) : [],
1917
+ yValues: yVal ? readNumCache(yVal) : [],
1918
+ bubbleSize: bubbleSize ? readNumCache(bubbleSize) : [],
1919
+ ...readSeriesCommon(serEl, ctx)
1920
+ });
1921
+ }
1922
+ result.series = bubbleSeries;
1923
+ } else if (detectedType === "scatter" && hasNumericXRef(seriesEls[0])) {
1924
+ const xySeries = [];
1925
+ for (const serEl of seriesEls) {
1926
+ const { name, literal: nameLiteral } = readSeriesName(serEl);
1927
+ const txEl = findChild(serEl, "c:tx");
1928
+ const nameFormula = txEl ? readRefMeta(txEl).formula : void 0;
1929
+ const xVal = findChild(serEl, "c:xVal");
1930
+ const yVal = findChild(serEl, "c:yVal");
1931
+ const valueLiteral = yVal ? findChild(yVal, "c:numLit") !== void 0 : false;
1932
+ const yMeta = yVal ? readRefMeta(yVal) : {};
1933
+ xySeries.push({
1934
+ name,
1935
+ ...nameLiteral ? { nameLiteral } : {},
1936
+ ...nameFormula ? { nameFormula } : {},
1937
+ ...valueLiteral ? { valueLiteral } : {},
1938
+ ...yMeta.formula ? { valueFormula: yMeta.formula } : {},
1939
+ ...yMeta.formatCode ? { formatCode: yMeta.formatCode } : {},
1940
+ xValues: xVal ? readNumCache(xVal) : [],
1941
+ yValues: yVal ? readNumCache(yVal) : [],
1942
+ ...readSeriesCommon(serEl, ctx)
1943
+ });
1944
+ }
1945
+ result.series = xySeries;
1946
+ } else {
1947
+ const chartSeries = [];
1948
+ let categories;
1949
+ for (const serEl of seriesEls) {
1950
+ const { name, literal: nameLiteral } = readSeriesName(serEl);
1951
+ const txEl = findChild(serEl, "c:tx");
1952
+ const nameFormula = txEl ? readRefMeta(txEl).formula : void 0;
1953
+ if (!categories && !result.multiLevelCategories && !result.categoryLabels) {
1954
+ const catEl = findChild(serEl, "c:cat") ?? findChild(serEl, "c:xVal");
1955
+ if (catEl) {
1956
+ const multi = readMultiLvlStrCache(catEl);
1957
+ if (multi) {
1958
+ result.multiLevelCategories = multi;
1959
+ const multiRef = findChild(catEl, "c:multiLvlStrRef");
1960
+ const multiF = multiRef ? findChild(multiRef, "c:f") : void 0;
1961
+ const multiText = multiF ? textOf(multiF) : "";
1962
+ if (multiText) result.categoryFormula = multiText;
1963
+ } else {
1964
+ const lit = readStrLit(catEl);
1965
+ if (lit) {
1966
+ result.categoryLabels = lit;
1967
+ categories = lit;
1968
+ } else if (findChild(catEl, "c:numRef")) {
1969
+ result.numericCategories = true;
1970
+ categories = readNumCacheText(catEl);
1971
+ } else categories = readStrCache(catEl);
1972
+ const catMeta = readRefMeta(catEl);
1973
+ if (catMeta.formula) result.categoryFormula = catMeta.formula;
1974
+ if (catMeta.formatCode) result.categoryFormatCode = catMeta.formatCode;
1975
+ }
1976
+ }
1977
+ }
1978
+ const valueEl = findChild(serEl, "c:val") ?? findChild(serEl, "c:yVal");
1979
+ const valueLiteral = valueEl ? findChild(valueEl, "c:numLit") !== void 0 : false;
1980
+ const values = valueEl ? readNumCache(valueEl) : [];
1981
+ const valMeta = valueEl ? readRefMeta(valueEl) : {};
1982
+ chartSeries.push({
1983
+ name,
1984
+ ...nameLiteral ? { nameLiteral } : {},
1985
+ ...nameFormula ? { nameFormula } : {},
1986
+ ...valueLiteral ? { valueLiteral } : {},
1987
+ ...valMeta.formula ? { valueFormula: valMeta.formula } : {},
1988
+ ...valMeta.formatCode ? { formatCode: valMeta.formatCode } : {},
1989
+ values,
1990
+ ...readSeriesCommon(serEl, ctx)
1991
+ });
1992
+ }
1993
+ result.series = chartSeries;
1994
+ if (categories) result.categories = categories;
1995
+ }
1996
+ }
1997
+ if (secondaryEls.length > 0) {
1998
+ const groups = [];
1999
+ for (const secondaryEl of secondaryEls) {
2000
+ const g = readSecondaryGroup(secondaryEl, ctx);
2001
+ if (g) groups.push(g);
2002
+ }
2003
+ if (groups.length > 0) result.secondaryGroups = groups;
2004
+ }
2005
+ }
2006
+ const axes = readAxes(plotArea, ctx);
2007
+ if (axes) result.axes = axes;
2008
+ const plotSpPr = plotArea && findChild(plotArea, "c:spPr");
2009
+ if (plotSpPr) result.plotAreaShapeProperties = shapePropertiesDesc.parse(plotSpPr, ctx);
2010
+ if (!findChild(chart, "c:legend")) result.showLegend = false;
2011
+ else {
2012
+ result.showLegend = true;
2013
+ const legendData = readLegend(chart, ctx);
2014
+ if (legendData?.position) result.legendPosition = legendData.position;
2015
+ if (legendData?.layout !== void 0) result.legendLayout = legendData.layout;
2016
+ if (legendData?.overlay !== void 0) result.legendOverlay = legendData.overlay;
2017
+ if (legendData?.shapeProperties) result.legendShapeProperties = legendData.shapeProperties;
2018
+ if (legendData?.textProperties) result.legendTextProperties = legendData.textProperties;
2019
+ if (legendData?.entries) result.legendEntries = legendData.entries;
2020
+ }
2021
+ const plotVisOnly = readBoolAttr(chart, "c:plotVisOnly");
2022
+ if (plotVisOnly !== void 0) result.plotVisOnly = plotVisOnly;
2023
+ const dispBlanksAs = readValStr(chart, "c:dispBlanksAs");
2024
+ if (dispBlanksAs) result.displayBlanksAs = dispBlanksAs;
2025
+ const showDLblsOverMax = readBoolAttr(chart, "c:showDLblsOverMax");
2026
+ if (showDLblsOverMax !== void 0) result.showDataLabelsOverMax = showDLblsOverMax;
2027
+ const spPrEl = findChild(el, "c:spPr");
2028
+ if (spPrEl) result.shapeProperties = shapePropertiesDesc.parse(spPrEl, ctx);
2029
+ const spaceTxPr = findChild(el, "c:txPr");
2030
+ if (spaceTxPr) result.textProperties = textBodyDesc.parse(spaceTxPr, ctx);
2031
+ const externalData = readExternalData(el);
2032
+ if (externalData) result.externalData = externalData;
2033
+ const printSettings = readPrintSettings(el);
2034
+ if (printSettings) result.printSettings = printSettings;
2035
+ const userShapesEl = findChild(el, "c:userShapes");
2036
+ if (userShapesEl) {
2037
+ const rid = attr(userShapesEl, "r:id");
2038
+ if (rid !== void 0) result.userShapes = rid;
2039
+ }
2040
+ const spaceExtLst = findChild(el, "c:extLst");
2041
+ if (spaceExtLst) result.ext = (spaceExtLst.elements ?? []).map((e) => stringifyElement(e)).join("");
2042
+ return result;
2043
+ }
2044
+ };
2045
+ //#endregion
2046
+ //#region src/chart/user-shapes/user-shapes.ts
2047
+ /**
2048
+ * Chart user shapes part (cdr:userShapes / CT_Drawing in dml-chartDrawing).
2049
+ *
2050
+ * Freeform shapes layered over a chart, anchored relatively (from/to markers,
2051
+ * 0.0–1.0 of the chart area) or absolutely (from marker + EMU extent). The
2052
+ * part hangs off the chart part via `c:userShapes r:id` — that reference is
2053
+ * produced and parsed by chartSpaceDesc; this module is the part body.
2054
+ *
2055
+ * The shape payload reuses the core drawingml descriptors: shapeProperties /
2056
+ * textBody / blipFill / groupShapeProperties / style-matrix / cNvPr.
2057
+ *
2058
+ * Reference: ISO/IEC 29500-4, dml-chartDrawing.xsd, CT_Drawing
2059
+ *
2060
+ * @module
2061
+ */
2062
+ const CDR_NS = "http://schemas.openxmlformats.org/drawingml/2006/chartDrawing";
2063
+ const A_NS = "http://schemas.openxmlformats.org/drawingml/2006/main";
2064
+ const R_NS = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
2065
+ const DIRECT_CTX = {
2066
+ addRelationship: () => "",
2067
+ addMedia: () => "",
2068
+ addHyperlink: () => {}
2069
+ };
2070
+ function stringifyMarker(marker) {
2071
+ return `<cdr:x>${marker.x}</cdr:x><cdr:y>${marker.y}</cdr:y>`;
2072
+ }
2073
+ function stringifyCnvPr(id, nvp) {
2074
+ return stringifyNonVisualDrawingProperties("cdr:cNvPr", id, nvp, "User Shape");
2075
+ }
2076
+ function commonAttrs(opts) {
2077
+ let attrs = "";
2078
+ if (opts.macro !== void 0) attrs += ` macro="${escapeXml(opts.macro)}"`;
2079
+ if (opts.published) attrs += " fPublished=\"1\"";
2080
+ return attrs;
2081
+ }
2082
+ function isRelative(anchor) {
2083
+ return "to" in anchor;
2084
+ }
2085
+ function stringifyObject(obj) {
2086
+ switch (obj.type) {
2087
+ case "shape": {
2088
+ const textLinkAttr = obj.textLink !== void 0 ? ` textlink="${escapeXml(obj.textLink)}"` : "";
2089
+ const locksTextAttr = obj.locksText !== void 0 ? ` fLocksText="${obj.locksText ? 1 : 0}"` : "";
2090
+ const nvSpPr = `<cdr:nvSpPr>${stringifyCnvPr(obj.id, obj.nonVisualProperties)}<cdr:cNvSpPr${obj.textBox ? " txBox=\"1\"" : ""}/></cdr:nvSpPr>`;
2091
+ const spPrXml = stringify$1(shapePropertiesDesc, obj.shapeProperties, DIRECT_CTX) ?? "";
2092
+ const styleXml = obj.style ? stringifyShapeStyle(obj.style, DIRECT_CTX) : "";
2093
+ const txBodyXml = obj.textBody ? stringify$1(textBodyDesc, obj.textBody, DIRECT_CTX) ?? "" : "";
2094
+ return `<cdr:sp${commonAttrs(obj)}${textLinkAttr}${locksTextAttr}>` + nvSpPr + `<cdr:spPr>${spPrXml}</cdr:spPr>` + styleXml + txBodyXml + "</cdr:sp>";
2095
+ }
2096
+ case "connector": {
2097
+ const nvCxnSpPr = `<cdr:nvCxnSpPr>${stringifyCnvPr(obj.id, obj.nonVisualProperties)}<cdr:cNvCxnSpPr/></cdr:nvCxnSpPr>`;
2098
+ const spPrXml = stringify$1(shapePropertiesDesc, obj.shapeProperties, DIRECT_CTX) ?? "";
2099
+ const styleXml = obj.style ? stringifyShapeStyle(obj.style, DIRECT_CTX) : "";
2100
+ return `<cdr:cxnSp${commonAttrs(obj)}>` + nvCxnSpPr + `<cdr:spPr>${spPrXml}</cdr:spPr>` + styleXml + "</cdr:cxnSp>";
2101
+ }
2102
+ case "picture": {
2103
+ const nvPicPr = `<cdr:nvPicPr>${stringifyCnvPr(obj.id, obj.nonVisualProperties)}<cdr:cNvPicPr/></cdr:nvPicPr>`;
2104
+ const fillOpts = {
2105
+ ...obj.blipFill,
2106
+ referenceId: obj.referenceId
2107
+ };
2108
+ const blipFillXml = (stringify$1(blipFillDesc, fillOpts, DIRECT_CTX) ?? "").replace(/pic:blipFill/g, "cdr:blipFill");
2109
+ const spPrXml = stringify$1(shapePropertiesDesc, obj.shapeProperties, DIRECT_CTX) ?? "";
2110
+ const styleXml = obj.style ? stringifyShapeStyle(obj.style, DIRECT_CTX) : "";
2111
+ return `<cdr:pic${commonAttrs(obj)}>` + nvPicPr + blipFillXml + `<cdr:spPr>${spPrXml}</cdr:spPr>` + styleXml + "</cdr:pic>";
2112
+ }
2113
+ case "graphicFrame": {
2114
+ const locks = obj.graphicFrameLocks;
2115
+ const locksXml = locks ? `<a:graphicFrameLocks${Object.entries(locks).filter(([, v]) => v).map(([k]) => ` ${k}="1"`).join("")}/>` : "";
2116
+ const nvGraphicFramePr = `<cdr:nvGraphicFramePr>${stringifyCnvPr(obj.id, obj.nonVisualProperties)}<cdr:cNvGraphicFramePr>${locksXml}</cdr:cNvGraphicFramePr></cdr:nvGraphicFramePr>`;
2117
+ const xfrmXml = (stringify$1(transform2DDesc, obj.transform, DIRECT_CTX) ?? "").replace(/a:xfrm/g, "cdr:xfrm");
2118
+ return `<cdr:graphicFrame${commonAttrs(obj)}>` + nvGraphicFramePr + xfrmXml + obj.graphic + "</cdr:graphicFrame>";
2119
+ }
2120
+ case "group": {
2121
+ const nvGrpSpPr = `<cdr:nvGrpSpPr>${stringifyCnvPr(obj.id, obj.nonVisualProperties)}<cdr:cNvGrpSpPr/></cdr:nvGrpSpPr>`;
2122
+ const grpSpPrXml = stringify$1(groupShapePropertiesDesc, obj.groupShapeProperties, DIRECT_CTX) ?? "";
2123
+ return "<cdr:grpSp>" + nvGrpSpPr + `<cdr:grpSpPr>${grpSpPrXml}</cdr:grpSpPr>` + obj.children.map(stringifyObject).join("") + "</cdr:grpSp>";
2124
+ }
2125
+ }
2126
+ }
2127
+ function readMarker(el) {
2128
+ if (!el) return void 0;
2129
+ const x = findChild(el, "cdr:x");
2130
+ const y = findChild(el, "cdr:y");
2131
+ if (!x || !y) return void 0;
2132
+ return {
2133
+ x: Number(x.elements?.[0]?.text ?? 0),
2134
+ y: Number(y.elements?.[0]?.text ?? 0)
2135
+ };
2136
+ }
2137
+ function readCnvPr(el) {
2138
+ if (!el) return void 0;
2139
+ const attrs = el.attributes ?? {};
2140
+ if (attrs["id"] === void 0) return void 0;
2141
+ const nvp = {};
2142
+ if (attrs["name"] !== void 0) nvp.name = String(attrs["name"]);
2143
+ if (attrs["descr"] !== void 0) nvp.description = String(attrs["descr"]);
2144
+ if (attrs["hidden"] !== void 0) nvp.hidden = parseOnOff(attrs["hidden"]) ?? false;
2145
+ return {
2146
+ id: Number(attrs["id"]),
2147
+ nvp
2148
+ };
2149
+ }
2150
+ /** macro/fPublished attributes shared by every non-group user-shape object. */
2151
+ function readCommonAttrs(el) {
2152
+ const out = {};
2153
+ if (el.attributes?.["macro"] !== void 0) out.macro = String(el.attributes["macro"]);
2154
+ if (el.attributes?.["fPublished"] !== void 0) out.published = parseOnOff(el.attributes["fPublished"]) ?? false;
2155
+ return out;
2156
+ }
2157
+ function readObject(el, ctx) {
2158
+ switch (el.name) {
2159
+ case "cdr:sp": {
2160
+ const nvSpPr = findChild(el, "cdr:nvSpPr");
2161
+ const spPr = findChild(el, "cdr:spPr");
2162
+ if (!nvSpPr || !spPr) return void 0;
2163
+ const cnvPr = readCnvPr(findChild(nvSpPr, "cdr:cNvPr"));
2164
+ if (!cnvPr) return void 0;
2165
+ const cNvSpPr = findChild(nvSpPr, "cdr:cNvSpPr");
2166
+ const result = {
2167
+ type: "shape",
2168
+ id: cnvPr.id,
2169
+ nonVisualProperties: cnvPr.nvp,
2170
+ shapeProperties: parse$1(shapePropertiesDesc, spPr, ctx)
2171
+ };
2172
+ if (cNvSpPr && cNvSpPr.attributes?.["txBox"] !== void 0) result.textBox = parseOnOff(cNvSpPr.attributes["txBox"]) ?? false;
2173
+ const styleEl = findChild(el, "a:style");
2174
+ if (styleEl) result.style = parseShapeStyle(styleEl, ctx);
2175
+ const txBody = findChild(el, "cdr:txBody");
2176
+ if (txBody) result.textBody = parse$1(textBodyDesc, txBody, ctx);
2177
+ Object.assign(result, readCommonAttrs(el));
2178
+ if (el.attributes?.["textlink"] !== void 0) result.textLink = String(el.attributes["textlink"]);
2179
+ if (el.attributes?.["fLocksText"] !== void 0) result.locksText = parseOnOff(el.attributes["fLocksText"]) ?? true;
2180
+ return result;
2181
+ }
2182
+ case "cdr:cxnSp": {
2183
+ const nvCxnSpPr = findChild(el, "cdr:nvCxnSpPr");
2184
+ const spPr = findChild(el, "cdr:spPr");
2185
+ if (!nvCxnSpPr || !spPr) return void 0;
2186
+ const cnvPr = readCnvPr(findChild(nvCxnSpPr, "cdr:cNvPr"));
2187
+ if (!cnvPr) return void 0;
2188
+ const result = {
2189
+ type: "connector",
2190
+ id: cnvPr.id,
2191
+ nonVisualProperties: cnvPr.nvp,
2192
+ shapeProperties: parse$1(shapePropertiesDesc, spPr, ctx)
2193
+ };
2194
+ const styleEl = findChild(el, "a:style");
2195
+ if (styleEl) result.style = parseShapeStyle(styleEl, ctx);
2196
+ Object.assign(result, readCommonAttrs(el));
2197
+ return result;
2198
+ }
2199
+ case "cdr:pic": {
2200
+ const nvPicPr = findChild(el, "cdr:nvPicPr");
2201
+ const blipFill = findChild(el, "cdr:blipFill");
2202
+ const spPr = findChild(el, "cdr:spPr");
2203
+ if (!nvPicPr || !blipFill || !spPr) return void 0;
2204
+ const cnvPr = readCnvPr(findChild(nvPicPr, "cdr:cNvPr"));
2205
+ if (!cnvPr) return void 0;
2206
+ const { referenceId, ...blipFillOpts } = parse$1(blipFillDesc, blipFill, ctx);
2207
+ const result = {
2208
+ type: "picture",
2209
+ id: cnvPr.id,
2210
+ nonVisualProperties: cnvPr.nvp,
2211
+ referenceId: referenceId ?? "",
2212
+ shapeProperties: parse$1(shapePropertiesDesc, spPr, ctx)
2213
+ };
2214
+ if (Object.keys(blipFillOpts).length > 0) result.blipFill = blipFillOpts;
2215
+ const styleEl = findChild(el, "a:style");
2216
+ if (styleEl) result.style = parseShapeStyle(styleEl, ctx);
2217
+ Object.assign(result, readCommonAttrs(el));
2218
+ return result;
2219
+ }
2220
+ case "cdr:graphicFrame": {
2221
+ const nvGraphicFramePr = findChild(el, "cdr:nvGraphicFramePr");
2222
+ const xfrm = findChild(el, "cdr:xfrm");
2223
+ const graphic = findChild(el, "a:graphic");
2224
+ if (!nvGraphicFramePr || !xfrm || !graphic) return void 0;
2225
+ const cnvPr = readCnvPr(findChild(nvGraphicFramePr, "cdr:cNvPr"));
2226
+ if (!cnvPr) return void 0;
2227
+ const result = {
2228
+ type: "graphicFrame",
2229
+ id: cnvPr.id,
2230
+ nonVisualProperties: cnvPr.nvp,
2231
+ transform: parse$1(transform2DDesc, xfrm, ctx),
2232
+ graphic: stringifyElement(graphic)
2233
+ };
2234
+ const cNvGraphicFramePr = findChild(nvGraphicFramePr, "cdr:cNvGraphicFramePr");
2235
+ if (cNvGraphicFramePr) {
2236
+ const locks = findChild(cNvGraphicFramePr, "a:graphicFrameLocks");
2237
+ if (locks) {
2238
+ const flags = {};
2239
+ for (const key of [
2240
+ "noGrp",
2241
+ "noDrilldown",
2242
+ "noSelect",
2243
+ "noChangeAspect",
2244
+ "noMove",
2245
+ "noResize"
2246
+ ]) {
2247
+ const raw = locks.attributes?.[key];
2248
+ if (raw !== void 0) flags[key] = parseOnOff(raw) ?? false;
2249
+ }
2250
+ if (Object.keys(flags).length > 0) result.graphicFrameLocks = flags;
2251
+ } else result.graphicFrameLocks = {};
2252
+ }
2253
+ Object.assign(result, readCommonAttrs(el));
2254
+ return result;
2255
+ }
2256
+ case "cdr:grpSp": {
2257
+ const nvGrpSpPr = findChild(el, "cdr:nvGrpSpPr");
2258
+ const grpSpPr = findChild(el, "cdr:grpSpPr");
2259
+ if (!nvGrpSpPr || !grpSpPr) return void 0;
2260
+ const cnvPr = readCnvPr(findChild(nvGrpSpPr, "cdr:cNvPr"));
2261
+ if (!cnvPr) return void 0;
2262
+ const children = [];
2263
+ for (const child of el.elements ?? []) {
2264
+ const parsed = readObject(child, ctx);
2265
+ if (parsed) children.push(parsed);
2266
+ }
2267
+ return {
2268
+ type: "group",
2269
+ id: cnvPr.id,
2270
+ nonVisualProperties: cnvPr.nvp,
2271
+ groupShapeProperties: parse$1(groupShapePropertiesDesc, grpSpPr, ctx),
2272
+ children
2273
+ };
2274
+ }
2275
+ default: return;
2276
+ }
2277
+ }
2278
+ const userShapesDesc = {
2279
+ kind: "custom",
2280
+ stringify(opts, _ctx) {
2281
+ const anchors = opts.anchors.map((anchor) => {
2282
+ const objectXml = stringifyObject(anchor.object);
2283
+ if (isRelative(anchor)) return `<cdr:relSizeAnchor><cdr:from>${stringifyMarker(anchor.from)}</cdr:from><cdr:to>${stringifyMarker(anchor.to)}</cdr:to>` + objectXml + `</cdr:relSizeAnchor>`;
2284
+ return `<cdr:absSizeAnchor><cdr:from>${stringifyMarker(anchor.from)}</cdr:from><cdr:ext cx="${anchor.extent.width}" cy="${anchor.extent.height}"/>` + objectXml + `</cdr:absSizeAnchor>`;
2285
+ }).join("");
2286
+ return `<cdr:userShapes xmlns:cdr="${CDR_NS}" xmlns:a="${A_NS}" xmlns:r="${R_NS}">` + anchors + `</cdr:userShapes>`;
2287
+ },
2288
+ parse(el, ctx) {
2289
+ const anchors = [];
2290
+ for (const anchorEl of el.elements ?? []) if (anchorEl.name === "cdr:relSizeAnchor") {
2291
+ const from = readMarker(findChild(anchorEl, "cdr:from"));
2292
+ const to = readMarker(findChild(anchorEl, "cdr:to"));
2293
+ const object = readAnchorObject(anchorEl, ctx);
2294
+ if (from && to && object) anchors.push({
2295
+ from,
2296
+ to,
2297
+ object
2298
+ });
2299
+ } else if (anchorEl.name === "cdr:absSizeAnchor") {
2300
+ const from = readMarker(findChild(anchorEl, "cdr:from"));
2301
+ const ext = findChild(anchorEl, "cdr:ext");
2302
+ const object = readAnchorObject(anchorEl, ctx);
2303
+ if (from && ext && object) anchors.push({
2304
+ from,
2305
+ extent: {
2306
+ width: Number(ext.attributes?.["cx"] ?? 0),
2307
+ height: Number(ext.attributes?.["cy"] ?? 0)
2308
+ },
2309
+ object
2310
+ });
2311
+ }
2312
+ return { anchors };
2313
+ }
2314
+ };
2315
+ /** Read the EG_ObjectChoices payload of an anchor element. */
2316
+ function readAnchorObject(anchorEl, ctx) {
2317
+ for (const child of anchorEl.elements ?? []) {
2318
+ const object = readObject(child, ctx);
2319
+ if (object) return object;
2320
+ }
2321
+ }
2322
+ //#endregion
2323
+ export { chartSpaceDesc as n, ChartCollection as r, userShapesDesc as t };
2324
+
2325
+ //# sourceMappingURL=chart-DED4tXC9.mjs.map