@office-open/core 0.10.15 → 0.11.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 (83) 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-Kf_utasF.mjs +1780 -0
  5. package/dist/chart-Kf_utasF.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/descriptor/index.d.mts +2 -2
  9. package/dist/descriptor/index.mjs +1 -1
  10. package/dist/{descriptor-BjNkn5jo.mjs → descriptor-BX8xW8na.mjs} +6 -2
  11. package/dist/{descriptor-BjNkn5jo.mjs.map → descriptor-BX8xW8na.mjs.map} +1 -1
  12. package/dist/drawing/index.d.mts +2 -0
  13. package/dist/drawing/index.mjs +2 -0
  14. package/dist/{drawingml-sj1J3lb0.mjs → drawing-FBzd2I0m.mjs} +2596 -1518
  15. package/dist/drawing-FBzd2I0m.mjs.map +1 -0
  16. package/dist/{converters-C_Y2QX1w.mjs → generators-CElPsAhd.mjs} +699 -258
  17. package/dist/generators-CElPsAhd.mjs.map +1 -0
  18. package/dist/index-BsTUn4K1.d.mts +28 -0
  19. package/dist/index-BsTUn4K1.d.mts.map +1 -0
  20. package/dist/index-C0ClOhmZ.d.mts +869 -0
  21. package/dist/index-C0ClOhmZ.d.mts.map +1 -0
  22. package/dist/{index-BVK2dv6C.d.mts → index-CLX7gU9J.d.mts} +8 -3
  23. package/dist/index-CLX7gU9J.d.mts.map +1 -0
  24. package/dist/index-Cgz88FU0.d.mts +308 -0
  25. package/dist/index-Cgz88FU0.d.mts.map +1 -0
  26. package/dist/{index-CE53SwpZ.d.mts → index-CnjCK-lF.d.mts} +497 -351
  27. package/dist/index-CnjCK-lF.d.mts.map +1 -0
  28. package/dist/{index-BfHfKuKy.d.mts → index-DpPeyf5f.d.mts} +61 -20
  29. package/dist/index-DpPeyf5f.d.mts.map +1 -0
  30. package/dist/index-DxwLMnBF.d.mts +384 -0
  31. package/dist/index-DxwLMnBF.d.mts.map +1 -0
  32. package/dist/index.d.mts +175 -22
  33. package/dist/index.d.mts.map +1 -1
  34. package/dist/index.mjs +523 -70
  35. package/dist/index.mjs.map +1 -1
  36. package/dist/patch/index.mjs +1 -1
  37. package/dist/{patch-BmRfghOo.mjs → patch-3KLx2yEP.mjs} +4 -4
  38. package/dist/patch-3KLx2yEP.mjs.map +1 -0
  39. package/dist/smartart/index.d.mts +2 -2
  40. package/dist/smartart/index.mjs +2 -2
  41. package/dist/smartart-BxnkROOp.mjs +1649 -0
  42. package/dist/smartart-BxnkROOp.mjs.map +1 -0
  43. package/dist/style-matrix-DAP6XrLv.mjs +123 -0
  44. package/dist/style-matrix-DAP6XrLv.mjs.map +1 -0
  45. package/dist/theme/index.d.mts +4 -2
  46. package/dist/theme/index.mjs +3 -2
  47. package/dist/theme-OAuRcA9_.mjs +460 -0
  48. package/dist/theme-OAuRcA9_.mjs.map +1 -0
  49. package/dist/theme-options-BbWccl85.d.mts +109 -0
  50. package/dist/theme-options-BbWccl85.d.mts.map +1 -0
  51. package/dist/util/index.d.mts +3 -3
  52. package/dist/util/index.mjs +3 -3
  53. package/dist/{util-Tq9PSjK0.mjs → util-C94-JKtp.mjs} +175 -429
  54. package/dist/util-C94-JKtp.mjs.map +1 -0
  55. package/dist/{values-8di32lIe.d.mts → values-aVoirbWB.d.mts} +4 -2
  56. package/dist/values-aVoirbWB.d.mts.map +1 -0
  57. package/dist/vector/index.d.mts +2 -0
  58. package/dist/vector/index.mjs +2 -0
  59. package/dist/vector-TpjW6ZSc.mjs +3092 -0
  60. package/dist/vector-TpjW6ZSc.mjs.map +1 -0
  61. package/package.json +15 -7
  62. package/dist/chart-DIGJna_6.mjs +0 -582
  63. package/dist/chart-DIGJna_6.mjs.map +0 -1
  64. package/dist/converters-C_Y2QX1w.mjs.map +0 -1
  65. package/dist/drawingml/index.d.mts +0 -2
  66. package/dist/drawingml/index.mjs +0 -2
  67. package/dist/drawingml-sj1J3lb0.mjs.map +0 -1
  68. package/dist/index-BVK2dv6C.d.mts.map +0 -1
  69. package/dist/index-BfHfKuKy.d.mts.map +0 -1
  70. package/dist/index-CE53SwpZ.d.mts.map +0 -1
  71. package/dist/index-D6VE-MnJ.d.mts +0 -43
  72. package/dist/index-D6VE-MnJ.d.mts.map +0 -1
  73. package/dist/index-DE4CLElr.d.mts +0 -145
  74. package/dist/index-DE4CLElr.d.mts.map +0 -1
  75. package/dist/index-DlPA26cw.d.mts +0 -91
  76. package/dist/index-DlPA26cw.d.mts.map +0 -1
  77. package/dist/patch-BmRfghOo.mjs.map +0 -1
  78. package/dist/smartart-B7ukZ-Tw.mjs +0 -305
  79. package/dist/smartart-B7ukZ-Tw.mjs.map +0 -1
  80. package/dist/theme-CiNzdl-9.mjs +0 -177
  81. package/dist/theme-CiNzdl-9.mjs.map +0 -1
  82. package/dist/util-Tq9PSjK0.mjs.map +0 -1
  83. package/dist/values-8di32lIe.d.mts.map +0 -1
@@ -0,0 +1,1780 @@
1
+ import { ut as parseOnOff } from "./generators-CElPsAhd.mjs";
2
+ import { o as parse$1, s as stringify$1 } from "./descriptor-BX8xW8na.mjs";
3
+ import { B as blipFillDesc, C as shapePropertiesDesc, S as groupShapePropertiesDesc, T as transform2DDesc, a as textBodyDesc, pt as stringifyNonVisualDrawingProperties } from "./drawing-FBzd2I0m.mjs";
4
+ import { i as stringifyShapeStyle, n as parseShapeStyle } from "./style-matrix-DAP6XrLv.mjs";
5
+ import { n as parseColorMapping, r as stringifyColorMapping } from "./color-mapping-CFF0vRSe.mjs";
6
+ import { attr, children, escapeXml, findChild, 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 = 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 value === false ? ` val="0"` : "";
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", 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 !== void 0) parts.push(valEl("c:errDir", opts.direction));
119
+ parts.push(valEl("c:errBarType", opts.barType ?? "both"));
120
+ parts.push(valEl("c:errValType", opts.valueType ?? "fixedVal"));
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) {
128
+ if (opts.delete) return `<c:dLbl><c:idx val="${opts.index}"/><c:delete val="1"/></c:dLbl>`;
129
+ const inner = [];
130
+ if (opts.numberFormat !== void 0) inner.push(`<c:numFmt formatCode="${escapeXml(opts.numberFormat)}" sourceLinked="0"/>`);
131
+ if (opts.position !== void 0) inner.push(valEl("c:dLblPos", opts.position));
132
+ return `<c:dLbl><c:idx val="${opts.index}"/>${inner.join("")}</c:dLbl>`;
133
+ }
134
+ function stringifyDataLabels(opts) {
135
+ const parts = [];
136
+ if (opts.labels) for (const lbl of opts.labels) parts.push(stringifyDataLabel(lbl));
137
+ if (opts.position !== void 0) parts.push(valEl("c:dLblPos", opts.position));
138
+ if (opts.showLegendKey !== void 0) parts.push(`<c:showLegendKey${boolVal(opts.showLegendKey)}/>`);
139
+ if (opts.showVal !== void 0) parts.push(`<c:showVal${boolVal(opts.showVal)}/>`);
140
+ if (opts.showCatName !== void 0) parts.push(`<c:showCatName${boolVal(opts.showCatName)}/>`);
141
+ if (opts.showSerName !== void 0) parts.push(`<c:showSerName${boolVal(opts.showSerName)}/>`);
142
+ if (opts.showPercent !== void 0) parts.push(`<c:showPercent${boolVal(opts.showPercent)}/>`);
143
+ if (opts.showBubbleSize !== void 0) parts.push(`<c:showBubbleSize${boolVal(opts.showBubbleSize)}/>`);
144
+ if (opts.separator !== void 0) parts.push(`<c:separator>${escapeXml(opts.separator)}</c:separator>`);
145
+ if (opts.showLeaderLines !== void 0) parts.push(`<c:showLeaderLines${boolVal(opts.showLeaderLines)}/>`);
146
+ if (opts.leaderLines) parts.push(emptyEl("c:leaderLines"));
147
+ return `<c:dLbls>${parts.join("")}</c:dLbls>`;
148
+ }
149
+ function stringifyView3D(opts) {
150
+ const parts = [];
151
+ if (opts.rotX !== void 0) parts.push(valEl("c:rotX", opts.rotX));
152
+ if (opts.hPercent !== void 0) parts.push(valEl("c:hPercent", opts.hPercent));
153
+ if (opts.rotY !== void 0) parts.push(valEl("c:rotY", opts.rotY));
154
+ if (opts.depthPercent !== void 0) parts.push(valEl("c:depthPercent", opts.depthPercent));
155
+ if (opts.rAngAx !== void 0) parts.push(`<c:rAngAx${boolVal(opts.rAngAx)}/>`);
156
+ if (opts.perspective !== void 0) parts.push(valEl("c:perspective", opts.perspective));
157
+ return `<c:view3D>${parts.join("")}</c:view3D>`;
158
+ }
159
+ function stringifyLayout(manualLayout) {
160
+ if (!manualLayout) return emptyEl("c:layout");
161
+ const parts = [];
162
+ if (manualLayout.layoutTarget !== void 0) parts.push(valEl("c:layoutTarget", manualLayout.layoutTarget));
163
+ if (manualLayout.xMode !== void 0) parts.push(valEl("c:xMode", manualLayout.xMode));
164
+ if (manualLayout.yMode !== void 0) parts.push(valEl("c:yMode", manualLayout.yMode));
165
+ if (manualLayout.wMode !== void 0) parts.push(valEl("c:wMode", manualLayout.wMode));
166
+ if (manualLayout.hMode !== void 0) parts.push(valEl("c:hMode", manualLayout.hMode));
167
+ if (manualLayout.x !== void 0) parts.push(valEl("c:x", manualLayout.x));
168
+ if (manualLayout.y !== void 0) parts.push(valEl("c:y", manualLayout.y));
169
+ if (manualLayout.w !== void 0) parts.push(valEl("c:w", manualLayout.w));
170
+ if (manualLayout.h !== void 0) parts.push(valEl("c:h", manualLayout.h));
171
+ return `<c:layout><c:manualLayout>${parts.join("")}</c:manualLayout></c:layout>`;
172
+ }
173
+ function stringifySurface(tag, opts) {
174
+ if (!opts) return "";
175
+ const parts = [];
176
+ if (opts.thickness !== void 0) parts.push(valEl("c:thickness", typeof opts.thickness === "string" ? Number(opts.thickness.replace("%", "")) : opts.thickness));
177
+ return parts.length ? `<${tag}>${parts.join("")}</${tag}>` : `<${tag}/>`;
178
+ }
179
+ const AXIS_TAG = {
180
+ category: "c:catAx",
181
+ value: "c:valAx",
182
+ date: "c:dateAx",
183
+ series: "c:serAx"
184
+ };
185
+ function stringifyScaling(opts) {
186
+ if (!opts) return emptyEl("c:scaling");
187
+ const parts = [];
188
+ if (opts.logBase !== void 0) parts.push(valEl("c:logBase", opts.logBase));
189
+ if (opts.orientation !== void 0) parts.push(valEl("c:orientation", opts.orientation));
190
+ if (opts.max !== void 0) parts.push(valEl("c:max", opts.max));
191
+ if (opts.min !== void 0) parts.push(valEl("c:min", opts.min));
192
+ return `<c:scaling>${parts.join("")}</c:scaling>`;
193
+ }
194
+ function stringifyAxisTitle(title) {
195
+ 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:overlay val="0"/></c:title>`;
196
+ }
197
+ function stringifyDisplayUnits(opts) {
198
+ const parts = [];
199
+ if (opts.customUnit !== void 0) parts.push(valEl("c:custUnit", opts.customUnit));
200
+ else if (opts.builtInUnit !== void 0) parts.push(valEl("c:builtInUnit", opts.builtInUnit));
201
+ if (opts.label) parts.push(emptyEl("c:dispUnitsLbl"));
202
+ return `<c:dispUnits>${parts.join("")}</c:dispUnits>`;
203
+ }
204
+ /**
205
+ * Serialize an axis. Field order follows the XSD content model exactly:
206
+ * EG_AxShared (axId…crosses/crossesAt), then the kind-specific tail from
207
+ * CT_CatAx / CT_DateAx / CT_SerAx / CT_ValAx.
208
+ */
209
+ function stringifyAxis(opts) {
210
+ const parts = [];
211
+ parts.push(valEl("c:axId", opts.id));
212
+ parts.push(stringifyScaling(opts.scaling));
213
+ if (opts.delete !== void 0) parts.push(`<c:delete${boolVal(opts.delete)}/>`);
214
+ if (opts.position !== void 0) parts.push(valEl("c:axPos", opts.position));
215
+ if (opts.majorGridlines) parts.push(emptyEl("c:majorGridlines"));
216
+ if (opts.minorGridlines) parts.push(emptyEl("c:minorGridlines"));
217
+ if (opts.title !== void 0) parts.push(stringifyAxisTitle(opts.title));
218
+ if (opts.numberFormat !== void 0) parts.push(`<c:numFmt formatCode="${escapeXml(opts.numberFormat)}" sourceLinked="1"/>`);
219
+ if (opts.majorTickMark !== void 0) parts.push(valEl("c:majorTickMark", opts.majorTickMark));
220
+ if (opts.minorTickMark !== void 0) parts.push(valEl("c:minorTickMark", opts.minorTickMark));
221
+ if (opts.tickLabelPosition !== void 0) parts.push(valEl("c:tickLblPos", opts.tickLabelPosition));
222
+ parts.push(valEl("c:crossAx", opts.crossAxisId));
223
+ if (opts.crossesAt !== void 0) parts.push(valEl("c:crossesAt", opts.crossesAt));
224
+ else if (opts.crosses !== void 0) parts.push(valEl("c:crosses", opts.crosses));
225
+ switch (opts.kind) {
226
+ case "category":
227
+ if (opts.auto !== void 0) parts.push(`<c:auto${boolVal(opts.auto)}/>`);
228
+ if (opts.labelAlignment !== void 0) parts.push(valEl("c:lblAlgn", opts.labelAlignment));
229
+ if (opts.labelOffset !== void 0) parts.push(valEl("c:lblOffset", opts.labelOffset));
230
+ if (opts.tickLabelSkip !== void 0) parts.push(valEl("c:tickLblSkip", opts.tickLabelSkip));
231
+ if (opts.tickMarkSkip !== void 0) parts.push(valEl("c:tickMarkSkip", opts.tickMarkSkip));
232
+ if (opts.noMultiLevelLabel !== void 0) parts.push(`<c:noMultiLvlLbl${boolVal(opts.noMultiLevelLabel)}/>`);
233
+ break;
234
+ case "date":
235
+ if (opts.auto !== void 0) parts.push(`<c:auto${boolVal(opts.auto)}/>`);
236
+ if (opts.labelOffset !== void 0) parts.push(valEl("c:lblOffset", opts.labelOffset));
237
+ if (opts.baseTimeUnit !== void 0) parts.push(valEl("c:baseTimeUnit", opts.baseTimeUnit));
238
+ if (opts.majorUnit !== void 0) parts.push(valEl("c:majorUnit", opts.majorUnit));
239
+ if (opts.majorTimeUnit !== void 0) parts.push(valEl("c:majorTimeUnit", opts.majorTimeUnit));
240
+ if (opts.minorUnit !== void 0) parts.push(valEl("c:minorUnit", opts.minorUnit));
241
+ if (opts.minorTimeUnit !== void 0) parts.push(valEl("c:minorTimeUnit", opts.minorTimeUnit));
242
+ break;
243
+ case "series":
244
+ if (opts.tickLabelSkip !== void 0) parts.push(valEl("c:tickLblSkip", opts.tickLabelSkip));
245
+ if (opts.tickMarkSkip !== void 0) parts.push(valEl("c:tickMarkSkip", opts.tickMarkSkip));
246
+ break;
247
+ case "value":
248
+ if (opts.crossBetween !== void 0) parts.push(valEl("c:crossBetween", opts.crossBetween));
249
+ if (opts.majorUnit !== void 0) parts.push(valEl("c:majorUnit", opts.majorUnit));
250
+ if (opts.minorUnit !== void 0) parts.push(valEl("c:minorUnit", opts.minorUnit));
251
+ if (opts.displayUnits) parts.push(stringifyDisplayUnits(opts.displayUnits));
252
+ break;
253
+ }
254
+ const tag = AXIS_TAG[opts.kind];
255
+ return `<${tag}>${parts.join("")}</${tag}>`;
256
+ }
257
+ function stringifyStrRef(values) {
258
+ const pts = values.map((v, i) => `<c:pt idx="${i}"><c:v>${escapeXml(v)}</c:v></c:pt>`).join("");
259
+ return `<c:strRef><c:f/><c:strCache><c:ptCount ${attrVal("val", values.length)}/>${pts}</c:strCache></c:strRef>`;
260
+ }
261
+ function stringifyStrLit(values) {
262
+ const pts = values.map((v, i) => `<c:pt idx="${i}"><c:v>${escapeXml(v)}</c:v></c:pt>`).join("");
263
+ return `<c:strLit><c:ptCount ${attrVal("val", values.length)}/>${pts}</c:strLit>`;
264
+ }
265
+ function stringifyMultiLvlStrRef(levels) {
266
+ const ptCount = levels.reduce((max, lvl) => Math.max(max, lvl.length), 0);
267
+ const lvls = levels.map((lvl) => {
268
+ return `<c:lvl>${lvl.map((v, i) => `<c:pt idx="${i}"><c:v>${escapeXml(v)}</c:v></c:pt>`).join("")}</c:lvl>`;
269
+ }).join("");
270
+ return `<c:multiLvlStrRef><c:f/><c:multiLvlStrCache><c:ptCount ${attrVal("val", ptCount)}/>${lvls}</c:multiLvlStrCache></c:multiLvlStrRef>`;
271
+ }
272
+ function stringifyCategorySource(opts) {
273
+ if (opts.multiLevelCategories) return stringifyMultiLvlStrRef(opts.multiLevelCategories);
274
+ if (opts.categoryLabels) return stringifyStrLit(opts.categoryLabels);
275
+ return stringifyStrRef(opts.categories ?? []);
276
+ }
277
+ function stringifyNumRef(values) {
278
+ const pts = values.map((v, i) => `<c:pt idx="${i}"><c:v>${v}</c:v></c:pt>`).join("");
279
+ return `<c:numRef><c:f/><c:numCache><c:formatCode>General</c:formatCode><c:ptCount ${attrVal("val", values.length)}/>${pts}</c:numCache></c:numRef>`;
280
+ }
281
+ function stringifyUpDownBars(gapWidth) {
282
+ const inner = [];
283
+ if (gapWidth !== void 0) inner.push(valEl("c:gapWidth", gapWidth));
284
+ inner.push(emptyEl("c:upBars"));
285
+ inner.push(emptyEl("c:downBars"));
286
+ return `<c:upDownBars>${inner.join("")}</c:upDownBars>`;
287
+ }
288
+ function stringifyDataTable(opts) {
289
+ const parts = [];
290
+ if (opts.showHorizontalBorder !== void 0) parts.push(`<c:showHorzBorder${boolVal(opts.showHorizontalBorder)}/>`);
291
+ if (opts.showVerticalBorder !== void 0) parts.push(`<c:showVertBorder${boolVal(opts.showVerticalBorder)}/>`);
292
+ if (opts.showOutline !== void 0) parts.push(`<c:showOutline${boolVal(opts.showOutline)}/>`);
293
+ if (opts.showLegendKeys !== void 0) parts.push(`<c:showKeys${boolVal(opts.showLegendKeys)}/>`);
294
+ return `<c:dTable>${parts.join("")}</c:dTable>`;
295
+ }
296
+ function stringifyProtection(opts) {
297
+ const parts = [];
298
+ if (opts.chartObject !== void 0) parts.push(`<c:chartObject val="${opts.chartObject ? 1 : 0}"/>`);
299
+ if (opts.data !== void 0) parts.push(`<c:data val="${opts.data ? 1 : 0}"/>`);
300
+ if (opts.formatting !== void 0) parts.push(`<c:formatting val="${opts.formatting ? 1 : 0}"/>`);
301
+ if (opts.selection !== void 0) parts.push(`<c:selection val="${opts.selection ? 1 : 0}"/>`);
302
+ if (opts.userInterface !== void 0) parts.push(`<c:userInterface val="${opts.userInterface ? 1 : 0}"/>`);
303
+ return `<c:protection>${parts.join("")}</c:protection>`;
304
+ }
305
+ function stringifyExternalData(opts) {
306
+ const auto = opts.autoUpdate !== void 0 ? `<c:autoUpdate val="${opts.autoUpdate ? 1 : 0}"/>` : "";
307
+ return `<c:externalData r:id="${escapeXml(opts.relationshipId)}">${auto}</c:externalData>`;
308
+ }
309
+ function stringifyHeaderFooter(opts) {
310
+ const parts = [];
311
+ if (opts.oddHeader !== void 0) parts.push(`<c:oddHeader>${escapeXml(opts.oddHeader)}</c:oddHeader>`);
312
+ if (opts.oddFooter !== void 0) parts.push(`<c:oddFooter>${escapeXml(opts.oddFooter)}</c:oddFooter>`);
313
+ if (opts.evenHeader !== void 0) parts.push(`<c:evenHeader>${escapeXml(opts.evenHeader)}</c:evenHeader>`);
314
+ if (opts.evenFooter !== void 0) parts.push(`<c:evenFooter>${escapeXml(opts.evenFooter)}</c:evenFooter>`);
315
+ if (opts.firstHeader !== void 0) parts.push(`<c:firstHeader>${escapeXml(opts.firstHeader)}</c:firstHeader>`);
316
+ if (opts.firstFooter !== void 0) parts.push(`<c:firstFooter>${escapeXml(opts.firstFooter)}</c:firstFooter>`);
317
+ const attrs = [];
318
+ if (opts.alignWithMargins !== void 0) attrs.push(`alignWithMargins="${opts.alignWithMargins ? 1 : 0}"`);
319
+ if (opts.differentOddEven !== void 0) attrs.push(`differentOddEven="${opts.differentOddEven ? 1 : 0}"`);
320
+ if (opts.differentFirst !== void 0) attrs.push(`differentFirst="${opts.differentFirst ? 1 : 0}"`);
321
+ return `<c:headerFooter${attrs.length ? " " + attrs.join(" ") : ""}>${parts.join("")}</c:headerFooter>`;
322
+ }
323
+ function stringifyPageMargins(opts) {
324
+ 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}"/>`;
325
+ }
326
+ function stringifyPageSetup(opts) {
327
+ const attrs = [];
328
+ if (opts.paperSize !== void 0) attrs.push(`paperSize="${opts.paperSize}"`);
329
+ if (opts.paperHeight !== void 0) attrs.push(`paperHeight="${escapeXml(opts.paperHeight)}"`);
330
+ if (opts.paperWidth !== void 0) attrs.push(`paperWidth="${escapeXml(opts.paperWidth)}"`);
331
+ if (opts.firstPageNumber !== void 0) attrs.push(`firstPageNumber="${opts.firstPageNumber}"`);
332
+ if (opts.orientation !== void 0) attrs.push(`orientation="${opts.orientation}"`);
333
+ if (opts.blackAndWhite !== void 0) attrs.push(`blackAndWhite="${opts.blackAndWhite ? 1 : 0}"`);
334
+ if (opts.draft !== void 0) attrs.push(`draft="${opts.draft ? 1 : 0}"`);
335
+ if (opts.useFirstPageNumber !== void 0) attrs.push(`useFirstPageNumber="${opts.useFirstPageNumber ? 1 : 0}"`);
336
+ if (opts.horizontalDpi !== void 0) attrs.push(`horizontalDpi="${opts.horizontalDpi}"`);
337
+ if (opts.verticalDpi !== void 0) attrs.push(`verticalDpi="${opts.verticalDpi}"`);
338
+ if (opts.copies !== void 0) attrs.push(`copies="${opts.copies}"`);
339
+ return `<c:pageSetup ${attrs.join(" ")}/>`;
340
+ }
341
+ function stringifyPrintSettings(opts) {
342
+ const parts = [];
343
+ if (opts.headerFooter) parts.push(stringifyHeaderFooter(opts.headerFooter));
344
+ if (opts.pageMargins) parts.push(stringifyPageMargins(opts.pageMargins));
345
+ if (opts.pageSetup) parts.push(stringifyPageSetup(opts.pageSetup));
346
+ if (opts.legacyDrawingId !== void 0) parts.push(`<c:legacyDrawingHF r:id="${escapeXml(opts.legacyDrawingId)}"/>`);
347
+ return `<c:printSettings>${parts.join("")}</c:printSettings>`;
348
+ }
349
+ function chartTypeHeader(opts) {
350
+ const tag = opts.threeD ? CHART_TYPE_TAGS_3D[opts.type] : CHART_TYPE_TAGS[opts.type];
351
+ if (!tag) throw new Error(`Unsupported chart type: ${opts.type}`);
352
+ const headerParts = [];
353
+ switch (opts.type) {
354
+ case "column":
355
+ case "bar":
356
+ headerParts.push(valEl("c:barDir", opts.type === "column" ? "col" : "bar"));
357
+ headerParts.push(valEl("c:grouping", "clustered"));
358
+ break;
359
+ case "line":
360
+ case "area":
361
+ headerParts.push(valEl("c:grouping", "standard"));
362
+ break;
363
+ case "scatter":
364
+ headerParts.push(valEl("c:scatterStyle", "line"));
365
+ break;
366
+ case "radar":
367
+ headerParts.push(valEl("c:radarStyle", "standard"));
368
+ break;
369
+ case "ofPie":
370
+ headerParts.push(valEl("c:ofPieType", opts.ofPieType ?? "pie"));
371
+ headerParts.push(valEl("c:varyColors", 1));
372
+ break;
373
+ case "pie":
374
+ case "doughnut":
375
+ case "bubble":
376
+ headerParts.push(valEl("c:varyColors", 1));
377
+ break;
378
+ case "surface":
379
+ if (opts.wireframe !== void 0) headerParts.push(`<c:wireframe${boolVal(opts.wireframe)}/>`);
380
+ break;
381
+ }
382
+ return `<${tag}>${headerParts.join("")}`;
383
+ }
384
+ function chartTypeFooter(opts) {
385
+ const tag = opts.threeD ? CHART_TYPE_TAGS_3D[opts.type] : CHART_TYPE_TAGS[opts.type];
386
+ const parts = [];
387
+ switch (opts.type) {
388
+ case "column":
389
+ case "bar":
390
+ if (opts.gapWidth !== void 0) parts.push(valEl("c:gapWidth", opts.gapWidth));
391
+ if (opts.threeD) {
392
+ if (opts.gapDepth !== void 0) parts.push(valEl("c:gapDepth", opts.gapDepth));
393
+ } else {
394
+ if (opts.overlap !== void 0) parts.push(valEl("c:overlap", opts.overlap));
395
+ if (opts.seriesLines) parts.push(emptyEl("c:serLines"));
396
+ }
397
+ break;
398
+ case "line":
399
+ if (opts.dropLines) parts.push(emptyEl("c:dropLines"));
400
+ if (!opts.threeD) {
401
+ if (opts.highLowLines) parts.push(emptyEl("c:hiLowLines"));
402
+ if (opts.upDownBars) parts.push(stringifyUpDownBars(opts.upDownBarsGapWidth));
403
+ } else if (opts.gapDepth !== void 0) parts.push(valEl("c:gapDepth", opts.gapDepth));
404
+ break;
405
+ case "area":
406
+ if (opts.dropLines) parts.push(emptyEl("c:dropLines"));
407
+ if (opts.threeD && opts.gapDepth !== void 0) parts.push(valEl("c:gapDepth", opts.gapDepth));
408
+ break;
409
+ case "stock":
410
+ if (opts.dropLines) parts.push(emptyEl("c:dropLines"));
411
+ if (opts.highLowLines) parts.push(emptyEl("c:hiLowLines"));
412
+ if (opts.upDownBars) parts.push(stringifyUpDownBars(opts.upDownBarsGapWidth));
413
+ break;
414
+ case "pie":
415
+ if (!opts.threeD && opts.firstSliceAngle !== void 0) parts.push(valEl("c:firstSliceAng", opts.firstSliceAngle));
416
+ break;
417
+ case "doughnut":
418
+ if (opts.firstSliceAngle !== void 0) parts.push(valEl("c:firstSliceAng", opts.firstSliceAngle));
419
+ if (opts.holeSize !== void 0) parts.push(valEl("c:holeSize", opts.holeSize));
420
+ break;
421
+ case "bubble":
422
+ if (opts.bubbleScale !== void 0) parts.push(valEl("c:bubbleScale", opts.bubbleScale));
423
+ if (opts.showNegativeBubbles !== void 0) parts.push(`<c:showNegBubbles${boolVal(opts.showNegativeBubbles)}/>`);
424
+ if (opts.sizeRepresents !== void 0) parts.push(valEl("c:sizeRepresents", opts.sizeRepresents));
425
+ break;
426
+ case "ofPie":
427
+ if (opts.gapWidth !== void 0) parts.push(valEl("c:gapWidth", opts.gapWidth));
428
+ if (opts.splitType !== void 0) parts.push(valEl("c:splitType", opts.splitType));
429
+ if (opts.splitPosition !== void 0) parts.push(valEl("c:splitPos", opts.splitPosition));
430
+ if (opts.customSplitPoints?.length) {
431
+ const pts = opts.customSplitPoints.map((p) => valEl("c:secondPiePt", p)).join("");
432
+ parts.push(`<c:custSplit>${pts}</c:custSplit>`);
433
+ }
434
+ if (opts.secondPieSize !== void 0) parts.push(valEl("c:secondPieSize", opts.secondPieSize));
435
+ if (opts.seriesLines) parts.push(emptyEl("c:serLines"));
436
+ break;
437
+ case "surface":
438
+ if (opts.bandFormats?.length) parts.push(stringifyBandFormats(opts.bandFormats));
439
+ break;
440
+ }
441
+ if (!NO_AXES_TYPES.has(opts.type)) for (const axis of axesFor(opts)) parts.push(valEl("c:axId", axis.id));
442
+ return `${parts.join("")}</${tag}>`;
443
+ }
444
+ function stringifyMarker$1(opts) {
445
+ const parts = [];
446
+ if (opts.symbol !== void 0) parts.push(valEl("c:symbol", opts.symbol));
447
+ if (opts.size !== void 0) parts.push(valEl("c:size", opts.size));
448
+ return `<c:marker>${parts.join("")}</c:marker>`;
449
+ }
450
+ function stringifyPictureOptions(opts) {
451
+ const parts = [];
452
+ if (opts.applyToFront !== void 0) parts.push(`<c:applyToFront${boolVal(opts.applyToFront)}/>`);
453
+ if (opts.applyToSides !== void 0) parts.push(`<c:applyToSides${boolVal(opts.applyToSides)}/>`);
454
+ if (opts.applyToEnd !== void 0) parts.push(`<c:applyToEnd${boolVal(opts.applyToEnd)}/>`);
455
+ if (opts.pictureFormat !== void 0) parts.push(valEl("c:pictureFormat", opts.pictureFormat));
456
+ if (opts.pictureStackUnit !== void 0) parts.push(valEl("c:pictureStackUnit", opts.pictureStackUnit));
457
+ return `<c:pictureOptions>${parts.join("")}</c:pictureOptions>`;
458
+ }
459
+ function stringifyDataPoint(opts) {
460
+ const parts = [valEl("c:idx", opts.index)];
461
+ if (opts.invertIfNegative !== void 0) parts.push(`<c:invertIfNegative${boolVal(opts.invertIfNegative)}/>`);
462
+ if (opts.marker) parts.push(stringifyMarker$1(opts.marker));
463
+ if (opts.bubble3D !== void 0) parts.push(`<c:bubble3D${boolVal(opts.bubble3D)}/>`);
464
+ if (opts.explosion !== void 0) parts.push(valEl("c:explosion", opts.explosion));
465
+ if (opts.pictureOptions) parts.push(stringifyPictureOptions(opts.pictureOptions));
466
+ return `<c:dPt>${parts.join("")}</c:dPt>`;
467
+ }
468
+ function stringifySeries(index, series, opts) {
469
+ const chartType = opts.type;
470
+ const categories = opts.categories ?? [];
471
+ const parts = [];
472
+ const s = series;
473
+ parts.push(valEl("c:idx", index));
474
+ parts.push(valEl("c:order", index));
475
+ parts.push(`<c:tx>${stringifyStrRef([series.name])}</c:tx>`);
476
+ parts.push(emptyEl("c:spPr"));
477
+ if (chartType === "line" || chartType === "scatter" || chartType === "radar") {
478
+ if (s.marker) parts.push(stringifyMarker$1(s.marker));
479
+ } else if (chartType === "column" || chartType === "bar") {
480
+ if (s.invertIfNegative !== void 0) parts.push(`<c:invertIfNegative${boolVal(s.invertIfNegative)}/>`);
481
+ if (s.pictureOptions) parts.push(stringifyPictureOptions(s.pictureOptions));
482
+ } else if (chartType === "area") {
483
+ if (s.pictureOptions) parts.push(stringifyPictureOptions(s.pictureOptions));
484
+ } else if (chartType === "bubble") {
485
+ if (s.invertIfNegative !== void 0) parts.push(`<c:invertIfNegative${boolVal(s.invertIfNegative)}/>`);
486
+ } else if (chartType === "pie" || chartType === "doughnut" || chartType === "ofPie") {
487
+ if (s.explosion !== void 0) parts.push(valEl("c:explosion", s.explosion));
488
+ }
489
+ if (s.dataPoints) for (const dp of s.dataPoints) parts.push(stringifyDataPoint(dp));
490
+ if (s.dataLabels) parts.push(stringifyDataLabels(s.dataLabels));
491
+ if (s.trendlines) for (const tl of s.trendlines) parts.push(stringifyTrendline(tl));
492
+ if (s.errorBars) parts.push(stringifyErrBars(s.errorBars));
493
+ if (chartType === "bubble") {
494
+ const bs = series;
495
+ parts.push(`<c:xVal>${stringifyNumRef(bs.xValues)}</c:xVal>`);
496
+ parts.push(`<c:yVal>${stringifyNumRef(bs.yValues)}</c:yVal>`);
497
+ parts.push(`<c:bubbleSize>${stringifyNumRef(bs.bubbleSize)}</c:bubbleSize>`);
498
+ } else if (chartType === "scatter") {
499
+ parts.push(`<c:xVal>${stringifyStrRef(categories)}</c:xVal>`);
500
+ parts.push(`<c:yVal>${stringifyNumRef(s.values)}</c:yVal>`);
501
+ } else {
502
+ parts.push(`<c:cat>${stringifyCategorySource(opts)}</c:cat>`);
503
+ parts.push(`<c:val>${stringifyNumRef(s.values)}</c:val>`);
504
+ }
505
+ if ((chartType === "line" || chartType === "scatter") && s.smooth !== void 0) parts.push(`<c:smooth${boolVal(s.smooth)}/>`);
506
+ if ((chartType === "column" || chartType === "bar") && s.shape !== void 0) parts.push(valEl("c:shape", s.shape));
507
+ if (chartType === "bubble" && s.bubble3D !== void 0) parts.push(`<c:bubble3D${boolVal(s.bubble3D)}/>`);
508
+ return `<c:ser>${parts.join("")}</c:ser>`;
509
+ }
510
+ function stringifyTitle(title) {
511
+ 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:overlay val="0"/></c:title>`;
512
+ }
513
+ const LEGEND_TXPR = "<c:txPr><a:bodyPr rot=\"0\" spcFirstLastPara=\"1\" vertOverflow=\"ellipsis\" vert=\"horz\" wrap=\"square\" anchor=\"ctr\" anchorCtr=\"1\"/><a:lstStyle/><a:p><a:pPr><a:defRPr/></a:pPr><a:endParaRPr lang=\"en-US\"/></a:p></c:txPr>";
514
+ function stringifyLegendEntry(entry) {
515
+ if (!entry.delete) return "";
516
+ return `<c:legendEntry><c:idx val="${entry.index}"/><c:delete val="1"/></c:legendEntry>`;
517
+ }
518
+ function stringifyLegend(opts) {
519
+ return `<c:legend><c:legendPos val="${opts.legendPosition ?? "b"}"/>${(opts.legendEntries ?? []).map(stringifyLegendEntry).join("")}<c:layout/><c:overlay val="0"/><c:spPr><a:noFill/><a:ln><a:noFill/></a:ln><a:effectLst/></c:spPr>${LEGEND_TXPR}</c:legend>`;
520
+ }
521
+ function stringifyPivotSource(opts) {
522
+ return `<c:pivotSource><c:name>${escapeXml(opts.name)}</c:name><c:fmtId val="${opts.formatId}"/></c:pivotSource>`;
523
+ }
524
+ function stringifyPivotFormats(formats) {
525
+ return `<c:pivotFmts>${formats.map((f) => {
526
+ let entry = `<c:idx val="${f.index}"/>`;
527
+ if (f.marker) entry += stringifyMarker$1(f.marker);
528
+ return `<c:pivotFmt>${entry}</c:pivotFmt>`;
529
+ }).join("")}</c:pivotFmts>`;
530
+ }
531
+ function stringifyBandFormats(formats) {
532
+ return `<c:bandFmts>${formats.map((f) => `<c:bandFmt><c:idx val="${f.index}"/></c:bandFmt>`).join("")}</c:bandFmts>`;
533
+ }
534
+ function noFillSpPr() {
535
+ return `<c:spPr><a:noFill/><a:ln><a:noFill/></a:ln><a:effectLst/></c:spPr>`;
536
+ }
537
+ function chartTxPr() {
538
+ return `<c:txPr><a:bodyPr/><a:lstStyle/><a:p><a:pPr><a:defRPr/></a:pPr><a:endParaRPr lang="en-US"/></a:p></c:txPr>`;
539
+ }
540
+ /** Default bottom category axis (c:catAx) for generated charts. */
541
+ function categoryAxis(id, crossAxisId) {
542
+ return {
543
+ kind: "category",
544
+ id,
545
+ crossAxisId,
546
+ scaling: { orientation: "minMax" },
547
+ delete: false,
548
+ position: "b",
549
+ crosses: "autoZero",
550
+ auto: true,
551
+ labelOffset: 100,
552
+ noMultiLevelLabel: false
553
+ };
554
+ }
555
+ /** Default left value axis (c:valAx). */
556
+ function valueAxis(id, crossAxisId) {
557
+ return {
558
+ kind: "value",
559
+ id,
560
+ crossAxisId,
561
+ scaling: { orientation: "minMax" },
562
+ delete: false,
563
+ position: "l",
564
+ numberFormat: "General",
565
+ crosses: "autoZero"
566
+ };
567
+ }
568
+ /** Default series axis (c:serAx) for surface charts. */
569
+ function seriesAxis(id, crossAxisId) {
570
+ return {
571
+ kind: "series",
572
+ id,
573
+ crossAxisId,
574
+ scaling: { orientation: "minMax" },
575
+ delete: false,
576
+ position: "b",
577
+ numberFormat: "General",
578
+ crosses: "autoZero",
579
+ tickLabelSkip: 1
580
+ };
581
+ }
582
+ /** Sensible default axes derived from chart type, matching prior hardcoded output. */
583
+ function defaultAxesFor(chartType, threeD) {
584
+ if (NO_AXES_TYPES.has(chartType)) return [];
585
+ if (chartType === "scatter" || chartType === "bubble") return [valueAxis(10, 20), valueAxis(20, 10)];
586
+ if (chartType === "surface") return [
587
+ categoryAxis(10, 20),
588
+ valueAxis(20, 10),
589
+ seriesAxis(30, 10)
590
+ ];
591
+ if (chartType === "stock") return [categoryAxis(10, 20), valueAxis(20, 10)];
592
+ if (threeD) return [
593
+ categoryAxis(10, 20),
594
+ valueAxis(20, 10),
595
+ seriesAxis(30, 10)
596
+ ];
597
+ return [categoryAxis(10, 20), valueAxis(20, 10)];
598
+ }
599
+ /** Provided axes override defaults; otherwise defaults are derived from chart type. */
600
+ function axesFor(opts) {
601
+ return opts.axes ?? defaultAxesFor(opts.type, opts.threeD);
602
+ }
603
+ function stringifyAxes(opts) {
604
+ return axesFor(opts).map(stringifyAxis).join("");
605
+ }
606
+ function readStrCache(el) {
607
+ const strRef = findChild(el, "c:strRef");
608
+ if (!strRef) return [];
609
+ const strCache = findChild(strRef, "c:strCache");
610
+ if (!strCache?.elements) return [];
611
+ const result = [];
612
+ for (const pt of strCache.elements) if (pt.name === "c:pt" && pt.elements) {
613
+ const v = pt.elements.find((c) => c.name === "c:v");
614
+ const text = v ? textOf(v) : "";
615
+ if (text !== "") result.push(text);
616
+ }
617
+ return result;
618
+ }
619
+ function readStrLit(el) {
620
+ const strLit = findChild(el, "c:strLit");
621
+ if (!strLit) return void 0;
622
+ const result = [];
623
+ for (const pt of strLit.elements ?? []) if (pt.name === "c:pt") {
624
+ const v = findChild(pt, "c:v");
625
+ const text = v ? textOf(v) : "";
626
+ if (text !== "") result.push(text);
627
+ }
628
+ return result;
629
+ }
630
+ function readMultiLvlStrCache(el) {
631
+ const ref = findChild(el, "c:multiLvlStrRef");
632
+ if (!ref) return void 0;
633
+ const cache = findChild(ref, "c:multiLvlStrCache");
634
+ if (!cache) return [];
635
+ const levels = [];
636
+ for (const lvl of cache.elements ?? []) {
637
+ if (lvl.name !== "c:lvl") continue;
638
+ const level = [];
639
+ for (const pt of lvl.elements ?? []) if (pt.name === "c:pt") {
640
+ const v = findChild(pt, "c:v");
641
+ const text = v ? textOf(v) : "";
642
+ if (text !== "") level.push(text);
643
+ }
644
+ levels.push(level);
645
+ }
646
+ return levels;
647
+ }
648
+ function readNumCache(el) {
649
+ const numRef = findChild(el, "c:numRef");
650
+ if (!numRef) return [];
651
+ const numCache = findChild(numRef, "c:numCache");
652
+ if (!numCache?.elements) return [];
653
+ const result = [];
654
+ for (const pt of numCache.elements) if (pt.name === "c:pt" && pt.elements) {
655
+ const v = pt.elements.find((c) => c.name === "c:v");
656
+ const text = v ? textOf(v) : "";
657
+ if (text !== "") result.push(Number(text));
658
+ }
659
+ return result;
660
+ }
661
+ function readSeriesName(serEl) {
662
+ const tx = findChild(serEl, "c:tx");
663
+ if (!tx) return "";
664
+ return readStrCache(tx)[0] ?? "";
665
+ }
666
+ function readTitleText(titleEl) {
667
+ const tx = findChild(titleEl, "c:tx");
668
+ if (!tx?.elements) return void 0;
669
+ for (const child of tx.elements) if (child.name === "c:rich" && child.elements) {
670
+ for (const sub of child.elements) if (sub.name === "a:p" && sub.elements) {
671
+ for (const r of sub.elements) if (r.name === "a:r" && r.elements) {
672
+ for (const t of r.elements) if (t.name === "a:t") {
673
+ const text = textOf(t);
674
+ if (text) return text;
675
+ }
676
+ }
677
+ }
678
+ }
679
+ }
680
+ function readBoolAttr(el, childName) {
681
+ const child = findChild(el, childName);
682
+ if (!child) return void 0;
683
+ const v = attr(child, "val");
684
+ if (v === void 0) return true;
685
+ return parseOnOff(v) ?? true;
686
+ }
687
+ function readValNum(el, childName) {
688
+ const child = findChild(el, childName);
689
+ if (!child) return void 0;
690
+ const v = attr(child, "val");
691
+ return v !== void 0 ? Number(v) : void 0;
692
+ }
693
+ function readValStr(el, childName) {
694
+ const child = findChild(el, childName);
695
+ if (!child) return void 0;
696
+ return attr(child, "val") ?? void 0;
697
+ }
698
+ function readNumLit(el, childName) {
699
+ const child = findChild(el, childName);
700
+ if (!child) return void 0;
701
+ const numLit = findChild(child, "c:numLit");
702
+ if (!numLit?.elements) return void 0;
703
+ for (const pt of numLit.elements) if (pt.name === "c:pt" && pt.elements) {
704
+ const v = pt.elements.find((c) => c.name === "c:v");
705
+ if (v) {
706
+ const text = textOf(v);
707
+ if (text) return Number(text);
708
+ }
709
+ }
710
+ }
711
+ function readTrendlines(serEl) {
712
+ const tlEls = children(serEl, "c:trendline");
713
+ if (tlEls.length === 0) return void 0;
714
+ return tlEls.map((tl) => {
715
+ const opts = {};
716
+ const type = readValStr(tl, "c:trendlineType");
717
+ if (type) opts.type = type;
718
+ const order = readValNum(tl, "c:order");
719
+ if (order !== void 0) opts.order = order;
720
+ const period = readValNum(tl, "c:period");
721
+ if (period !== void 0) opts.period = period;
722
+ const forward = readValNum(tl, "c:forward");
723
+ if (forward !== void 0) opts.forward = forward;
724
+ const backward = readValNum(tl, "c:backward");
725
+ if (backward !== void 0) opts.backward = backward;
726
+ const intercept = readValNum(tl, "c:intercept");
727
+ if (intercept !== void 0) opts.intercept = intercept;
728
+ const dispRSqr = readBoolAttr(tl, "c:dispRSqr");
729
+ if (dispRSqr !== void 0) opts.dispRSqr = dispRSqr;
730
+ const dispEq = readBoolAttr(tl, "c:dispEq");
731
+ if (dispEq !== void 0) opts.dispEq = dispEq;
732
+ const nameText = textOf(findChild(tl, "c:name"));
733
+ if (nameText) opts.name = nameText;
734
+ const labelFmt = attr(findChild(findChild(tl, "c:trendlineLbl"), "c:numFmt"), "formatCode");
735
+ if (labelFmt) opts.label = { numberFormat: labelFmt };
736
+ return opts;
737
+ });
738
+ }
739
+ function readErrBars(serEl) {
740
+ const ebEl = findChild(serEl, "c:errBars");
741
+ if (!ebEl) return void 0;
742
+ const opts = {};
743
+ const direction = readValStr(ebEl, "c:errDir");
744
+ if (direction) opts.direction = direction;
745
+ const barType = readValStr(ebEl, "c:errBarType");
746
+ if (barType) opts.barType = barType;
747
+ const valueType = readValStr(ebEl, "c:errValType");
748
+ if (valueType) opts.valueType = valueType;
749
+ const noEndCap = readBoolAttr(ebEl, "c:noEndCap");
750
+ if (noEndCap !== void 0) opts.noEndCap = noEndCap;
751
+ const plusValue = readNumLit(ebEl, "c:plus");
752
+ if (plusValue !== void 0) opts.plusValue = plusValue;
753
+ const minusValue = readNumLit(ebEl, "c:minus");
754
+ if (minusValue !== void 0) opts.minusValue = minusValue;
755
+ const value = readValNum(ebEl, "c:val");
756
+ if (value !== void 0) opts.value = value;
757
+ return opts;
758
+ }
759
+ function readDataLabels(serEl) {
760
+ const dlEl = findChild(serEl, "c:dLbls");
761
+ if (!dlEl) return void 0;
762
+ const opts = {};
763
+ const position = readValStr(dlEl, "c:dLblPos");
764
+ if (position) opts.position = position;
765
+ const showLegendKey = readBoolAttr(dlEl, "c:showLegendKey");
766
+ if (showLegendKey !== void 0) opts.showLegendKey = showLegendKey;
767
+ const showVal = readBoolAttr(dlEl, "c:showVal");
768
+ if (showVal !== void 0) opts.showVal = showVal;
769
+ const showCatName = readBoolAttr(dlEl, "c:showCatName");
770
+ if (showCatName !== void 0) opts.showCatName = showCatName;
771
+ const showSerName = readBoolAttr(dlEl, "c:showSerName");
772
+ if (showSerName !== void 0) opts.showSerName = showSerName;
773
+ const showPercent = readBoolAttr(dlEl, "c:showPercent");
774
+ if (showPercent !== void 0) opts.showPercent = showPercent;
775
+ const showBubbleSize = readBoolAttr(dlEl, "c:showBubbleSize");
776
+ if (showBubbleSize !== void 0) opts.showBubbleSize = showBubbleSize;
777
+ const showLeaderLines = readBoolAttr(dlEl, "c:showLeaderLines");
778
+ if (showLeaderLines !== void 0) opts.showLeaderLines = showLeaderLines;
779
+ const sepText = textOf(findChild(dlEl, "c:separator"));
780
+ if (sepText) opts.separator = sepText;
781
+ const lblEls = children(dlEl, "c:dLbl");
782
+ if (lblEls.length > 0) opts.labels = lblEls.map((el) => {
783
+ const result = { index: readValNum(el, "c:idx") ?? 0 };
784
+ if (findChild(el, "c:delete")) result.delete = true;
785
+ const numFmt = attr(findChild(el, "c:numFmt"), "formatCode");
786
+ if (numFmt) result.numberFormat = numFmt;
787
+ const pos = readValStr(el, "c:dLblPos");
788
+ if (pos) result.position = pos;
789
+ return result;
790
+ });
791
+ if (findChild(dlEl, "c:leaderLines")) opts.leaderLines = true;
792
+ return opts;
793
+ }
794
+ function readMarker$1(parent) {
795
+ const el = findChild(parent, "c:marker");
796
+ if (!el) return void 0;
797
+ const opts = {};
798
+ const symbol = readValStr(el, "c:symbol");
799
+ if (symbol) opts.symbol = symbol;
800
+ const size = readValNum(el, "c:size");
801
+ if (size !== void 0) opts.size = size;
802
+ return Object.keys(opts).length ? opts : void 0;
803
+ }
804
+ function readPictureOptions(parent) {
805
+ const el = findChild(parent, "c:pictureOptions");
806
+ if (!el) return void 0;
807
+ const opts = {};
808
+ const front = readBoolAttr(el, "c:applyToFront");
809
+ if (front !== void 0) opts.applyToFront = front;
810
+ const sides = readBoolAttr(el, "c:applyToSides");
811
+ if (sides !== void 0) opts.applyToSides = sides;
812
+ const end = readBoolAttr(el, "c:applyToEnd");
813
+ if (end !== void 0) opts.applyToEnd = end;
814
+ const fmt = readValStr(el, "c:pictureFormat");
815
+ if (fmt) opts.pictureFormat = fmt;
816
+ const stack = readValNum(el, "c:pictureStackUnit");
817
+ if (stack !== void 0) opts.pictureStackUnit = stack;
818
+ return Object.keys(opts).length ? opts : void 0;
819
+ }
820
+ function readDataPoints(serEl) {
821
+ const els = children(serEl, "c:dPt");
822
+ if (els.length === 0) return void 0;
823
+ return els.map((el) => {
824
+ const dp = { index: readValNum(el, "c:idx") ?? 0 };
825
+ const invertIfNegative = readBoolAttr(el, "c:invertIfNegative");
826
+ if (invertIfNegative !== void 0) dp.invertIfNegative = invertIfNegative;
827
+ const marker = readMarker$1(el);
828
+ if (marker) dp.marker = marker;
829
+ const bubble3D = readBoolAttr(el, "c:bubble3D");
830
+ if (bubble3D !== void 0) dp.bubble3D = bubble3D;
831
+ const explosion = readValNum(el, "c:explosion");
832
+ if (explosion !== void 0) dp.explosion = explosion;
833
+ const pictureOptions = readPictureOptions(el);
834
+ if (pictureOptions) dp.pictureOptions = pictureOptions;
835
+ return dp;
836
+ });
837
+ }
838
+ /** Read shared ser enhancement fields (CT_Ser children beyond EG_SerShared). */
839
+ function readSeriesCommon(serEl) {
840
+ const common = {};
841
+ const trendlines = readTrendlines(serEl);
842
+ if (trendlines) common.trendlines = trendlines;
843
+ const errorBars = readErrBars(serEl);
844
+ if (errorBars) common.errorBars = errorBars;
845
+ const dataLabels = readDataLabels(serEl);
846
+ if (dataLabels) common.dataLabels = dataLabels;
847
+ const dataPoints = readDataPoints(serEl);
848
+ if (dataPoints) common.dataPoints = dataPoints;
849
+ const marker = readMarker$1(serEl);
850
+ if (marker) common.marker = marker;
851
+ const invertIfNegative = readBoolAttr(serEl, "c:invertIfNegative");
852
+ if (invertIfNegative !== void 0) common.invertIfNegative = invertIfNegative;
853
+ const smooth = readBoolAttr(serEl, "c:smooth");
854
+ if (smooth !== void 0) common.smooth = smooth;
855
+ const explosion = readValNum(serEl, "c:explosion");
856
+ if (explosion !== void 0) common.explosion = explosion;
857
+ const pictureOptions = readPictureOptions(serEl);
858
+ if (pictureOptions) common.pictureOptions = pictureOptions;
859
+ const shape = readValStr(serEl, "c:shape");
860
+ if (shape) common.shape = shape;
861
+ const bubble3D = readBoolAttr(serEl, "c:bubble3D");
862
+ if (bubble3D !== void 0) common.bubble3D = bubble3D;
863
+ return common;
864
+ }
865
+ function readView3D(chartEl) {
866
+ const v3d = findChild(chartEl, "c:view3D");
867
+ if (!v3d) return void 0;
868
+ const opts = {};
869
+ const rotX = readValNum(v3d, "c:rotX");
870
+ if (rotX !== void 0) opts.rotX = rotX;
871
+ const hPercent = readValNum(v3d, "c:hPercent");
872
+ if (hPercent !== void 0) opts.hPercent = hPercent;
873
+ const rotY = readValNum(v3d, "c:rotY");
874
+ if (rotY !== void 0) opts.rotY = rotY;
875
+ const depthPercent = readValNum(v3d, "c:depthPercent");
876
+ if (depthPercent !== void 0) opts.depthPercent = depthPercent;
877
+ const rAngAx = readBoolAttr(v3d, "c:rAngAx");
878
+ if (rAngAx !== void 0) opts.rAngAx = rAngAx;
879
+ const perspective = readValNum(v3d, "c:perspective");
880
+ if (perspective !== void 0) opts.perspective = perspective;
881
+ return opts;
882
+ }
883
+ function readManualLayout(layoutEl) {
884
+ if (!layoutEl) return void 0;
885
+ const ml = findChild(layoutEl, "c:manualLayout");
886
+ if (!ml) return void 0;
887
+ const opts = {};
888
+ const layoutTarget = readValStr(ml, "c:layoutTarget");
889
+ if (layoutTarget) opts.layoutTarget = layoutTarget;
890
+ const xMode = readValStr(ml, "c:xMode");
891
+ if (xMode) opts.xMode = xMode;
892
+ const yMode = readValStr(ml, "c:yMode");
893
+ if (yMode) opts.yMode = yMode;
894
+ const wMode = readValStr(ml, "c:wMode");
895
+ if (wMode) opts.wMode = wMode;
896
+ const hMode = readValStr(ml, "c:hMode");
897
+ if (hMode) opts.hMode = hMode;
898
+ const x = readValNum(ml, "c:x");
899
+ if (x !== void 0) opts.x = x;
900
+ const y = readValNum(ml, "c:y");
901
+ if (y !== void 0) opts.y = y;
902
+ const w = readValNum(ml, "c:w");
903
+ if (w !== void 0) opts.w = w;
904
+ const h = readValNum(ml, "c:h");
905
+ if (h !== void 0) opts.h = h;
906
+ return Object.keys(opts).length ? opts : void 0;
907
+ }
908
+ function readSurface(chartEl, tag) {
909
+ const el = findChild(chartEl, tag);
910
+ if (!el) return void 0;
911
+ const thickness = readValStr(el, "c:thickness");
912
+ if (thickness === void 0) return void 0;
913
+ return { thickness: thickness.endsWith("%") ? thickness : Number(thickness) };
914
+ }
915
+ function readChartTypeScalars(chartTypeEl, type, threeD, result) {
916
+ if (!chartTypeEl) return;
917
+ if (type === "column" || type === "bar") {
918
+ const gapWidth = readValNum(chartTypeEl, "c:gapWidth");
919
+ if (gapWidth !== void 0) result.gapWidth = gapWidth;
920
+ if (threeD) {
921
+ const gapDepth = readValNum(chartTypeEl, "c:gapDepth");
922
+ if (gapDepth !== void 0) result.gapDepth = gapDepth;
923
+ } else {
924
+ const overlap = readValNum(chartTypeEl, "c:overlap");
925
+ if (overlap !== void 0) result.overlap = overlap;
926
+ }
927
+ } else if (type === "pie" || type === "doughnut") {
928
+ const firstSliceAng = readValNum(chartTypeEl, "c:firstSliceAng");
929
+ if (firstSliceAng !== void 0) result.firstSliceAngle = firstSliceAng;
930
+ const holeSize = readValNum(chartTypeEl, "c:holeSize");
931
+ if (holeSize !== void 0) result.holeSize = holeSize;
932
+ } else if (type === "bubble") {
933
+ const bubbleScale = readValNum(chartTypeEl, "c:bubbleScale");
934
+ if (bubbleScale !== void 0) result.bubbleScale = bubbleScale;
935
+ const showNeg = readBoolAttr(chartTypeEl, "c:showNegBubbles");
936
+ if (showNeg !== void 0) result.showNegativeBubbles = showNeg;
937
+ const sizeRep = readValStr(chartTypeEl, "c:sizeRepresents");
938
+ if (sizeRep) result.sizeRepresents = sizeRep;
939
+ } else if (type === "surface") {
940
+ const wireframe = readBoolAttr(chartTypeEl, "c:wireframe");
941
+ if (wireframe !== void 0) result.wireframe = wireframe;
942
+ const bandFormats = readBandFormats(chartTypeEl);
943
+ if (bandFormats) result.bandFormats = bandFormats;
944
+ } else if (type === "ofPie") {
945
+ const ofPieType = readValStr(chartTypeEl, "c:ofPieType");
946
+ if (ofPieType) result.ofPieType = ofPieType;
947
+ const gapWidth = readValNum(chartTypeEl, "c:gapWidth");
948
+ if (gapWidth !== void 0) result.gapWidth = gapWidth;
949
+ const splitType = readValStr(chartTypeEl, "c:splitType");
950
+ if (splitType) result.splitType = splitType;
951
+ const splitPos = readValNum(chartTypeEl, "c:splitPos");
952
+ if (splitPos !== void 0) result.splitPosition = splitPos;
953
+ const custSplit = findChild(chartTypeEl, "c:custSplit");
954
+ if (custSplit) {
955
+ const pts = children(custSplit, "c:secondPiePt").map((el) => attr(el, "val")).filter((v) => v !== void 0).map(Number);
956
+ if (pts.length) result.customSplitPoints = pts;
957
+ }
958
+ const secondPieSize = readValStr(chartTypeEl, "c:secondPieSize");
959
+ if (secondPieSize !== void 0) result.secondPieSize = secondPieSize.endsWith("%") ? secondPieSize : Number(secondPieSize);
960
+ if (findChild(chartTypeEl, "c:serLines")) result.seriesLines = true;
961
+ }
962
+ }
963
+ function readChartTypeDecorations(chartTypeEl, type, threeD, result) {
964
+ if (!chartTypeEl) return;
965
+ const readUpDownBars = (el) => {
966
+ result.upDownBars = true;
967
+ const gw = readValNum(el, "c:gapWidth");
968
+ if (gw !== void 0) result.upDownBarsGapWidth = gw;
969
+ };
970
+ if (type === "line") if (threeD) {
971
+ if (findChild(chartTypeEl, "c:dropLines")) result.dropLines = true;
972
+ } else {
973
+ if (findChild(chartTypeEl, "c:hiLowLines")) result.highLowLines = true;
974
+ const upDownBars = findChild(chartTypeEl, "c:upDownBars");
975
+ if (upDownBars) readUpDownBars(upDownBars);
976
+ if (findChild(chartTypeEl, "c:dropLines")) result.dropLines = true;
977
+ }
978
+ else if (type === "area") {
979
+ if (findChild(chartTypeEl, "c:dropLines")) result.dropLines = true;
980
+ if (threeD && findChild(chartTypeEl, "c:serLines")) result.seriesLines = true;
981
+ } else if (type === "stock") {
982
+ if (findChild(chartTypeEl, "c:dropLines")) result.dropLines = true;
983
+ if (findChild(chartTypeEl, "c:hiLowLines")) result.highLowLines = true;
984
+ const upDownBars = findChild(chartTypeEl, "c:upDownBars");
985
+ if (upDownBars) readUpDownBars(upDownBars);
986
+ if (findChild(chartTypeEl, "c:serLines")) result.seriesLines = true;
987
+ } else if ((type === "column" || type === "bar") && !threeD) {
988
+ if (findChild(chartTypeEl, "c:serLines")) result.seriesLines = true;
989
+ }
990
+ }
991
+ function readDataTable(plotArea) {
992
+ if (!plotArea) return void 0;
993
+ const dTable = findChild(plotArea, "c:dTable");
994
+ if (!dTable) return void 0;
995
+ const opts = {};
996
+ const horz = readBoolAttr(dTable, "c:showHorzBorder");
997
+ if (horz !== void 0) opts.showHorizontalBorder = horz;
998
+ const vert = readBoolAttr(dTable, "c:showVertBorder");
999
+ if (vert !== void 0) opts.showVerticalBorder = vert;
1000
+ const outline = readBoolAttr(dTable, "c:showOutline");
1001
+ if (outline !== void 0) opts.showOutline = outline;
1002
+ const keys = readBoolAttr(dTable, "c:showKeys");
1003
+ if (keys !== void 0) opts.showLegendKeys = keys;
1004
+ return Object.keys(opts).length ? opts : void 0;
1005
+ }
1006
+ function readProtection(el) {
1007
+ const protection = findChild(el, "c:protection");
1008
+ if (!protection) return void 0;
1009
+ const opts = {};
1010
+ const readFlag = (tag) => {
1011
+ const child = findChild(protection, tag);
1012
+ if (!child) return void 0;
1013
+ const v = attr(child, "val");
1014
+ return v === void 0 ? void 0 : parseOnOff(v) ?? true;
1015
+ };
1016
+ const chartObject = readFlag("c:chartObject");
1017
+ if (chartObject !== void 0) opts.chartObject = chartObject;
1018
+ const data = readFlag("c:data");
1019
+ if (data !== void 0) opts.data = data;
1020
+ const formatting = readFlag("c:formatting");
1021
+ if (formatting !== void 0) opts.formatting = formatting;
1022
+ const selection = readFlag("c:selection");
1023
+ if (selection !== void 0) opts.selection = selection;
1024
+ const userInterface = readFlag("c:userInterface");
1025
+ if (userInterface !== void 0) opts.userInterface = userInterface;
1026
+ return Object.keys(opts).length ? opts : void 0;
1027
+ }
1028
+ function readExternalData(el) {
1029
+ const externalData = findChild(el, "c:externalData");
1030
+ if (!externalData) return void 0;
1031
+ const relationshipId = attr(externalData, "r:id");
1032
+ if (relationshipId === void 0) return void 0;
1033
+ const opts = { relationshipId };
1034
+ const autoUpdateEl = findChild(externalData, "c:autoUpdate");
1035
+ if (autoUpdateEl) {
1036
+ const v = attr(autoUpdateEl, "val");
1037
+ if (v !== void 0) opts.autoUpdate = parseOnOff(v) ?? true;
1038
+ }
1039
+ return opts;
1040
+ }
1041
+ function readPivotSource(el) {
1042
+ const ps = findChild(el, "c:pivotSource");
1043
+ if (!ps) return void 0;
1044
+ const nameEl = findChild(ps, "c:name");
1045
+ const fmtIdEl = findChild(ps, "c:fmtId");
1046
+ if (!nameEl || !fmtIdEl) return void 0;
1047
+ return {
1048
+ name: textOf(nameEl) ?? "",
1049
+ formatId: Number(attr(fmtIdEl, "val"))
1050
+ };
1051
+ }
1052
+ function readPivotFormats(chart) {
1053
+ const pf = findChild(chart, "c:pivotFmts");
1054
+ if (!pf) return void 0;
1055
+ const result = [];
1056
+ for (const fmt of children(pf, "c:pivotFmt")) {
1057
+ const idxEl = findChild(fmt, "c:idx");
1058
+ if (!idxEl) continue;
1059
+ const opt = { index: Number(attr(idxEl, "val")) };
1060
+ const marker = readMarker$1(fmt);
1061
+ if (marker) opt.marker = marker;
1062
+ result.push(opt);
1063
+ }
1064
+ return result.length ? result : void 0;
1065
+ }
1066
+ function readBandFormats(chartTypeEl) {
1067
+ const bf = findChild(chartTypeEl, "c:bandFmts");
1068
+ if (!bf) return void 0;
1069
+ const result = [];
1070
+ for (const fmt of children(bf, "c:bandFmt")) {
1071
+ const idxEl = findChild(fmt, "c:idx");
1072
+ if (idxEl) result.push({ index: Number(attr(idxEl, "val")) });
1073
+ }
1074
+ return result.length ? result : void 0;
1075
+ }
1076
+ function readLegendEntries(legend) {
1077
+ const entries = children(legend, "c:legendEntry");
1078
+ if (!entries.length) return void 0;
1079
+ const result = [];
1080
+ for (const entry of entries) {
1081
+ const idxEl = findChild(entry, "c:idx");
1082
+ if (!idxEl) continue;
1083
+ const deleteEl = findChild(entry, "c:delete");
1084
+ if (!deleteEl) continue;
1085
+ const v = attr(deleteEl, "val");
1086
+ result.push({
1087
+ index: Number(attr(idxEl, "val")),
1088
+ delete: parseOnOff(v) ?? true
1089
+ });
1090
+ }
1091
+ return result.length ? result : void 0;
1092
+ }
1093
+ function readLegend(chart) {
1094
+ const legend = findChild(chart, "c:legend");
1095
+ if (!legend) return void 0;
1096
+ const result = {};
1097
+ const posEl = findChild(legend, "c:legendPos");
1098
+ if (posEl) {
1099
+ const v = attr(posEl, "val");
1100
+ if (v) result.position = v;
1101
+ }
1102
+ const entries = readLegendEntries(legend);
1103
+ if (entries) result.entries = entries;
1104
+ return Object.keys(result).length ? result : void 0;
1105
+ }
1106
+ function readHeaderFooter(ps) {
1107
+ const hf = findChild(ps, "c:headerFooter");
1108
+ if (!hf) return void 0;
1109
+ const opts = {};
1110
+ const readStr = (tag) => {
1111
+ const child = findChild(hf, tag);
1112
+ return child ? textOf(child) : void 0;
1113
+ };
1114
+ const oh = readStr("c:oddHeader");
1115
+ if (oh !== void 0) opts.oddHeader = oh;
1116
+ const of = readStr("c:oddFooter");
1117
+ if (of !== void 0) opts.oddFooter = of;
1118
+ const eh = readStr("c:evenHeader");
1119
+ if (eh !== void 0) opts.evenHeader = eh;
1120
+ const ef = readStr("c:evenFooter");
1121
+ if (ef !== void 0) opts.evenFooter = ef;
1122
+ const fh = readStr("c:firstHeader");
1123
+ if (fh !== void 0) opts.firstHeader = fh;
1124
+ const ff = readStr("c:firstFooter");
1125
+ if (ff !== void 0) opts.firstFooter = ff;
1126
+ const readFlag = (name) => {
1127
+ const v = attr(hf, name);
1128
+ return v === void 0 ? void 0 : parseOnOff(v) ?? true;
1129
+ };
1130
+ const alignWithMargins = readFlag("alignWithMargins");
1131
+ if (alignWithMargins !== void 0) opts.alignWithMargins = alignWithMargins;
1132
+ const differentOddEven = readFlag("differentOddEven");
1133
+ if (differentOddEven !== void 0) opts.differentOddEven = differentOddEven;
1134
+ const differentFirst = readFlag("differentFirst");
1135
+ if (differentFirst !== void 0) opts.differentFirst = differentFirst;
1136
+ return Object.keys(opts).length ? opts : void 0;
1137
+ }
1138
+ function readPageMargins(ps) {
1139
+ const pm = findChild(ps, "c:pageMargins");
1140
+ if (!pm) return void 0;
1141
+ const opts = {};
1142
+ const readNum = (name) => {
1143
+ const v = attr(pm, name);
1144
+ return v === void 0 ? void 0 : Number(v);
1145
+ };
1146
+ const left = readNum("l");
1147
+ if (left !== void 0) opts.left = left;
1148
+ const right = readNum("r");
1149
+ if (right !== void 0) opts.right = right;
1150
+ const top = readNum("t");
1151
+ if (top !== void 0) opts.top = top;
1152
+ const bottom = readNum("b");
1153
+ if (bottom !== void 0) opts.bottom = bottom;
1154
+ const header = readNum("header");
1155
+ if (header !== void 0) opts.header = header;
1156
+ const footer = readNum("footer");
1157
+ if (footer !== void 0) opts.footer = footer;
1158
+ return Object.keys(opts).length ? opts : void 0;
1159
+ }
1160
+ function readPageSetup(ps) {
1161
+ const pg = findChild(ps, "c:pageSetup");
1162
+ if (!pg) return void 0;
1163
+ const opts = {};
1164
+ const readNum = (name) => {
1165
+ const v = attr(pg, name);
1166
+ return v === void 0 ? void 0 : Number(v);
1167
+ };
1168
+ const readFlag = (name) => {
1169
+ const v = attr(pg, name);
1170
+ return v === void 0 ? void 0 : parseOnOff(v) ?? true;
1171
+ };
1172
+ const paperSize = readNum("paperSize");
1173
+ if (paperSize !== void 0) opts.paperSize = paperSize;
1174
+ const paperHeight = attr(pg, "paperHeight");
1175
+ if (paperHeight !== void 0) opts.paperHeight = paperHeight;
1176
+ const paperWidth = attr(pg, "paperWidth");
1177
+ if (paperWidth !== void 0) opts.paperWidth = paperWidth;
1178
+ const firstPageNumber = readNum("firstPageNumber");
1179
+ if (firstPageNumber !== void 0) opts.firstPageNumber = firstPageNumber;
1180
+ const orientation = attr(pg, "orientation");
1181
+ if (orientation !== void 0) opts.orientation = orientation;
1182
+ const blackAndWhite = readFlag("blackAndWhite");
1183
+ if (blackAndWhite !== void 0) opts.blackAndWhite = blackAndWhite;
1184
+ const draft = readFlag("draft");
1185
+ if (draft !== void 0) opts.draft = draft;
1186
+ const useFirstPageNumber = readFlag("useFirstPageNumber");
1187
+ if (useFirstPageNumber !== void 0) opts.useFirstPageNumber = useFirstPageNumber;
1188
+ const horizontalDpi = readNum("horizontalDpi");
1189
+ if (horizontalDpi !== void 0) opts.horizontalDpi = horizontalDpi;
1190
+ const verticalDpi = readNum("verticalDpi");
1191
+ if (verticalDpi !== void 0) opts.verticalDpi = verticalDpi;
1192
+ const copies = readNum("copies");
1193
+ if (copies !== void 0) opts.copies = copies;
1194
+ return Object.keys(opts).length ? opts : void 0;
1195
+ }
1196
+ function readPrintSettings(el) {
1197
+ const ps = findChild(el, "c:printSettings");
1198
+ if (!ps) return void 0;
1199
+ const opts = {};
1200
+ const headerFooter = readHeaderFooter(ps);
1201
+ if (headerFooter) opts.headerFooter = headerFooter;
1202
+ const pageMargins = readPageMargins(ps);
1203
+ if (pageMargins) opts.pageMargins = pageMargins;
1204
+ const pageSetup = readPageSetup(ps);
1205
+ if (pageSetup) opts.pageSetup = pageSetup;
1206
+ const legacyDrawingHF = findChild(ps, "c:legacyDrawingHF");
1207
+ if (legacyDrawingHF) {
1208
+ const rId = attr(legacyDrawingHF, "r:id");
1209
+ if (rId !== void 0) opts.legacyDrawingId = rId;
1210
+ }
1211
+ return Object.keys(opts).length ? opts : void 0;
1212
+ }
1213
+ const AXIS_KIND_BY_TAG = {
1214
+ "c:catAx": "category",
1215
+ "c:valAx": "value",
1216
+ "c:dateAx": "date",
1217
+ "c:serAx": "series"
1218
+ };
1219
+ function readAxis(el, kind) {
1220
+ const result = {
1221
+ kind,
1222
+ id: readValNum(el, "c:axId") ?? 0,
1223
+ crossAxisId: readValNum(el, "c:crossAx") ?? 0
1224
+ };
1225
+ const scalingEl = findChild(el, "c:scaling");
1226
+ if (scalingEl) {
1227
+ const scaling = {};
1228
+ const logBase = readValNum(scalingEl, "c:logBase");
1229
+ if (logBase !== void 0) scaling.logBase = logBase;
1230
+ const orientation = readValStr(scalingEl, "c:orientation");
1231
+ if (orientation) scaling.orientation = orientation;
1232
+ const max = readValNum(scalingEl, "c:max");
1233
+ if (max !== void 0) scaling.max = max;
1234
+ const min = readValNum(scalingEl, "c:min");
1235
+ if (min !== void 0) scaling.min = min;
1236
+ if (logBase !== void 0 || orientation || max !== void 0 || min !== void 0) result.scaling = scaling;
1237
+ }
1238
+ const del = readBoolAttr(el, "c:delete");
1239
+ if (del !== void 0) result.delete = del;
1240
+ const pos = readValStr(el, "c:axPos");
1241
+ if (pos) result.position = pos;
1242
+ if (findChild(el, "c:majorGridlines")) result.majorGridlines = true;
1243
+ if (findChild(el, "c:minorGridlines")) result.minorGridlines = true;
1244
+ const titleEl = findChild(el, "c:title");
1245
+ if (titleEl) {
1246
+ const titleText = readTitleText(titleEl);
1247
+ if (titleText !== void 0) result.title = titleText;
1248
+ }
1249
+ const numFmtEl = findChild(el, "c:numFmt");
1250
+ if (numFmtEl) {
1251
+ const formatCode = attr(numFmtEl, "formatCode");
1252
+ if (formatCode) result.numberFormat = formatCode;
1253
+ }
1254
+ const majorTickMark = readValStr(el, "c:majorTickMark");
1255
+ if (majorTickMark) result.majorTickMark = majorTickMark;
1256
+ const minorTickMark = readValStr(el, "c:minorTickMark");
1257
+ if (minorTickMark) result.minorTickMark = minorTickMark;
1258
+ const tickLblPos = readValStr(el, "c:tickLblPos");
1259
+ if (tickLblPos) result.tickLabelPosition = tickLblPos;
1260
+ const crossesAt = readValNum(el, "c:crossesAt");
1261
+ if (crossesAt !== void 0) result.crossesAt = crossesAt;
1262
+ else {
1263
+ const crosses = readValStr(el, "c:crosses");
1264
+ if (crosses) result.crosses = crosses;
1265
+ }
1266
+ if (kind === "category" || kind === "date") {
1267
+ const auto = readBoolAttr(el, "c:auto");
1268
+ if (auto !== void 0) result.auto = auto;
1269
+ }
1270
+ if (kind === "category") {
1271
+ const lblAlgn = readValStr(el, "c:lblAlgn");
1272
+ if (lblAlgn) result.labelAlignment = lblAlgn;
1273
+ }
1274
+ if (kind === "category" || kind === "date") {
1275
+ const lblOffsetEl = findChild(el, "c:lblOffset");
1276
+ if (lblOffsetEl) {
1277
+ const v = attr(lblOffsetEl, "val");
1278
+ if (v !== void 0) result.labelOffset = v.endsWith("%") ? v : Number(v);
1279
+ }
1280
+ }
1281
+ if (kind === "category" || kind === "series") {
1282
+ const tickLblSkip = readValNum(el, "c:tickLblSkip");
1283
+ if (tickLblSkip !== void 0) result.tickLabelSkip = tickLblSkip;
1284
+ const tickMarkSkip = readValNum(el, "c:tickMarkSkip");
1285
+ if (tickMarkSkip !== void 0) result.tickMarkSkip = tickMarkSkip;
1286
+ }
1287
+ if (kind === "category") {
1288
+ const noMulti = readBoolAttr(el, "c:noMultiLvlLbl");
1289
+ if (noMulti !== void 0) result.noMultiLevelLabel = noMulti;
1290
+ }
1291
+ if (kind === "date") {
1292
+ const baseTimeUnit = readValStr(el, "c:baseTimeUnit");
1293
+ if (baseTimeUnit) result.baseTimeUnit = baseTimeUnit;
1294
+ const majorTimeUnit = readValStr(el, "c:majorTimeUnit");
1295
+ if (majorTimeUnit) result.majorTimeUnit = majorTimeUnit;
1296
+ const minorTimeUnit = readValStr(el, "c:minorTimeUnit");
1297
+ if (minorTimeUnit) result.minorTimeUnit = minorTimeUnit;
1298
+ }
1299
+ if (kind === "date" || kind === "value") {
1300
+ const majorUnit = readValNum(el, "c:majorUnit");
1301
+ if (majorUnit !== void 0) result.majorUnit = majorUnit;
1302
+ const minorUnit = readValNum(el, "c:minorUnit");
1303
+ if (minorUnit !== void 0) result.minorUnit = minorUnit;
1304
+ }
1305
+ if (kind === "value") {
1306
+ const crossBetween = readValStr(el, "c:crossBetween");
1307
+ if (crossBetween) result.crossBetween = crossBetween;
1308
+ const dispUnitsEl = findChild(el, "c:dispUnits");
1309
+ if (dispUnitsEl) {
1310
+ const displayUnits = {};
1311
+ const customUnit = readValNum(dispUnitsEl, "c:custUnit");
1312
+ if (customUnit !== void 0) displayUnits.customUnit = customUnit;
1313
+ const builtInUnit = readValStr(dispUnitsEl, "c:builtInUnit");
1314
+ if (builtInUnit) displayUnits.builtInUnit = builtInUnit;
1315
+ if (findChild(dispUnitsEl, "c:dispUnitsLbl")) displayUnits.label = true;
1316
+ if (customUnit !== void 0 || builtInUnit || displayUnits.label) result.displayUnits = displayUnits;
1317
+ }
1318
+ }
1319
+ return result;
1320
+ }
1321
+ /** Read all axis elements (c:catAx/c:valAx/c:dateAx/c:serAx) under plotArea. */
1322
+ function readAxes(plotArea) {
1323
+ if (!plotArea?.elements) return void 0;
1324
+ const axes = [];
1325
+ for (const child of plotArea.elements) {
1326
+ if (!child.name) continue;
1327
+ const kind = AXIS_KIND_BY_TAG[child.name];
1328
+ if (kind) axes.push(readAxis(child, kind));
1329
+ }
1330
+ return axes.length > 0 ? axes : void 0;
1331
+ }
1332
+ const chartSpaceDesc = {
1333
+ kind: "custom",
1334
+ stringify(opts, _ctx) {
1335
+ const parts = [];
1336
+ parts.push(`<c:chartSpace 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">`);
1337
+ parts.push(valEl("c:date1904", 0));
1338
+ parts.push(valEl("c:lang", "en-US"));
1339
+ parts.push(valEl("c:roundedCorners", 0));
1340
+ if (opts.style !== void 0) parts.push(valEl("c:style", opts.style));
1341
+ if (opts.colorMappingOverride) parts.push(stringifyColorMapping(opts.colorMappingOverride, "c:clrMapOvr"));
1342
+ if (opts.pivotSource) parts.push(stringifyPivotSource(opts.pivotSource));
1343
+ if (opts.protection) parts.push(stringifyProtection(opts.protection));
1344
+ parts.push("<c:chart>");
1345
+ if (opts.title) parts.push(stringifyTitle(opts.title));
1346
+ parts.push(valEl("c:autoTitleDeleted", 0));
1347
+ if (opts.pivotFormats?.length) parts.push(stringifyPivotFormats(opts.pivotFormats));
1348
+ if (opts.view3D) parts.push(stringifyView3D(opts.view3D));
1349
+ parts.push(stringifySurface("c:floor", opts.floor));
1350
+ parts.push(stringifySurface("c:sideWall", opts.sideWall));
1351
+ parts.push(stringifySurface("c:backWall", opts.backWall));
1352
+ parts.push(`<c:plotArea>${stringifyLayout(opts.plotAreaLayout)}`);
1353
+ parts.push(chartTypeHeader(opts));
1354
+ for (const [i, series] of opts.series.entries()) parts.push(stringifySeries(i, series, opts));
1355
+ parts.push(chartTypeFooter(opts));
1356
+ parts.push(stringifyAxes(opts));
1357
+ if (opts.dataTable) parts.push(stringifyDataTable(opts.dataTable));
1358
+ parts.push("</c:plotArea>");
1359
+ if (opts.showLegend !== false) parts.push(stringifyLegend(opts));
1360
+ parts.push(`<c:plotVisOnly${boolVal(opts.plotVisOnly ?? true)}/>`);
1361
+ if (opts.displayBlanksAs !== void 0) parts.push(valEl("c:dispBlanksAs", opts.displayBlanksAs));
1362
+ if (opts.showDataLabelsOverMax !== void 0) parts.push(`<c:showDLblsOverMax${boolVal(opts.showDataLabelsOverMax)}/>`);
1363
+ parts.push("</c:chart>");
1364
+ parts.push(noFillSpPr());
1365
+ parts.push(chartTxPr());
1366
+ if (opts.externalData) parts.push(stringifyExternalData(opts.externalData));
1367
+ if (opts.printSettings) parts.push(stringifyPrintSettings(opts.printSettings));
1368
+ if (opts.userShapes !== void 0) parts.push(`<c:userShapes r:id="${escapeXml(opts.userShapes)}"/>`);
1369
+ parts.push("</c:chartSpace>");
1370
+ return parts.join("");
1371
+ },
1372
+ parse(el, _ctx) {
1373
+ const result = {};
1374
+ const styleEl = findChild(el, "c:style");
1375
+ if (styleEl?.attributes?.["val"] !== void 0) result.style = Number(styleEl.attributes["val"]);
1376
+ const colorMappingOverride = parseColorMapping(findChild(el, "c:clrMapOvr"));
1377
+ if (colorMappingOverride) result.colorMappingOverride = colorMappingOverride;
1378
+ const protection = readProtection(el);
1379
+ if (protection) result.protection = protection;
1380
+ const pivotSource = readPivotSource(el);
1381
+ if (pivotSource) result.pivotSource = pivotSource;
1382
+ const chart = findChild(el, "c:chart");
1383
+ if (!chart) return result;
1384
+ const titleEl = findChild(chart, "c:title");
1385
+ if (titleEl) {
1386
+ const title = readTitleText(titleEl);
1387
+ if (title !== void 0) result.title = title;
1388
+ }
1389
+ const pivotFormats = readPivotFormats(chart);
1390
+ if (pivotFormats) result.pivotFormats = pivotFormats;
1391
+ const view3D = readView3D(chart);
1392
+ if (view3D) result.view3D = view3D;
1393
+ const floor = readSurface(chart, "c:floor");
1394
+ if (floor) result.floor = floor;
1395
+ const sideWall = readSurface(chart, "c:sideWall");
1396
+ if (sideWall) result.sideWall = sideWall;
1397
+ const backWall = readSurface(chart, "c:backWall");
1398
+ if (backWall) result.backWall = backWall;
1399
+ const plotArea = findChild(chart, "c:plotArea");
1400
+ if (plotArea?.elements) {
1401
+ const manualLayout = readManualLayout(findChild(plotArea, "c:layout"));
1402
+ if (manualLayout) result.plotAreaLayout = manualLayout;
1403
+ const dataTable = readDataTable(plotArea);
1404
+ if (dataTable) result.dataTable = dataTable;
1405
+ let detectedType;
1406
+ let threeD = false;
1407
+ let chartTypeEl;
1408
+ for (const child of plotArea.elements) {
1409
+ if (!child.name) continue;
1410
+ const mapping = TAG_TO_CHART_TYPE[child.name];
1411
+ if (mapping) {
1412
+ detectedType = mapping.type;
1413
+ threeD = mapping.threeD ?? false;
1414
+ chartTypeEl = child;
1415
+ if (child.name === "c:barChart" || child.name === "c:bar3DChart") {
1416
+ const barDir = findChild(child, "c:barDir");
1417
+ const barDirVal = barDir ? attr(barDir, "val") : void 0;
1418
+ if (barDirVal === "bar") detectedType = "bar";
1419
+ else if (barDirVal === "col") detectedType = "column";
1420
+ }
1421
+ break;
1422
+ }
1423
+ }
1424
+ if (detectedType) {
1425
+ result.type = detectedType;
1426
+ if (threeD) result.threeD = true;
1427
+ readChartTypeScalars(chartTypeEl, detectedType, threeD, result);
1428
+ readChartTypeDecorations(chartTypeEl, detectedType, threeD, result);
1429
+ }
1430
+ const seriesEls = chartTypeEl ? children(chartTypeEl, "c:ser") : [];
1431
+ if (seriesEls.length > 0) if (detectedType === "bubble") {
1432
+ const bubbleSeries = [];
1433
+ for (const serEl of seriesEls) {
1434
+ const name = readSeriesName(serEl);
1435
+ const xVal = findChild(serEl, "c:xVal");
1436
+ const yVal = findChild(serEl, "c:yVal");
1437
+ const bubbleSize = findChild(serEl, "c:bubbleSize");
1438
+ bubbleSeries.push({
1439
+ name,
1440
+ xValues: xVal ? readNumCache(xVal) : [],
1441
+ yValues: yVal ? readNumCache(yVal) : [],
1442
+ bubbleSize: bubbleSize ? readNumCache(bubbleSize) : [],
1443
+ ...readSeriesCommon(serEl)
1444
+ });
1445
+ }
1446
+ result.series = bubbleSeries;
1447
+ } else {
1448
+ const chartSeries = [];
1449
+ let categories;
1450
+ for (const serEl of seriesEls) {
1451
+ const name = readSeriesName(serEl);
1452
+ if (!categories && !result.multiLevelCategories && !result.categoryLabels) {
1453
+ const catEl = findChild(serEl, "c:cat") ?? findChild(serEl, "c:xVal");
1454
+ if (catEl) {
1455
+ const multi = readMultiLvlStrCache(catEl);
1456
+ if (multi) result.multiLevelCategories = multi;
1457
+ else {
1458
+ const lit = readStrLit(catEl);
1459
+ if (lit) {
1460
+ result.categoryLabels = lit;
1461
+ categories = lit;
1462
+ } else categories = readStrCache(catEl);
1463
+ }
1464
+ }
1465
+ }
1466
+ const valEl = findChild(serEl, "c:val") ?? findChild(serEl, "c:yVal");
1467
+ const values = valEl ? readNumCache(valEl) : [];
1468
+ chartSeries.push({
1469
+ name,
1470
+ values,
1471
+ ...readSeriesCommon(serEl)
1472
+ });
1473
+ }
1474
+ result.series = chartSeries;
1475
+ if (categories?.length) result.categories = categories;
1476
+ }
1477
+ }
1478
+ const axes = readAxes(plotArea);
1479
+ if (axes) result.axes = axes;
1480
+ if (!findChild(chart, "c:legend")) result.showLegend = false;
1481
+ else {
1482
+ const legendData = readLegend(chart);
1483
+ if (legendData?.position) result.legendPosition = legendData.position;
1484
+ if (legendData?.entries) result.legendEntries = legendData.entries;
1485
+ }
1486
+ const plotVisOnly = readBoolAttr(chart, "c:plotVisOnly");
1487
+ if (plotVisOnly !== void 0) result.plotVisOnly = plotVisOnly;
1488
+ const dispBlanksAs = readValStr(chart, "c:dispBlanksAs");
1489
+ if (dispBlanksAs) result.displayBlanksAs = dispBlanksAs;
1490
+ const showDLblsOverMax = readBoolAttr(chart, "c:showDLblsOverMax");
1491
+ if (showDLblsOverMax !== void 0) result.showDataLabelsOverMax = showDLblsOverMax;
1492
+ const externalData = readExternalData(el);
1493
+ if (externalData) result.externalData = externalData;
1494
+ const printSettings = readPrintSettings(el);
1495
+ if (printSettings) result.printSettings = printSettings;
1496
+ const userShapesEl = findChild(el, "c:userShapes");
1497
+ if (userShapesEl) {
1498
+ const rid = attr(userShapesEl, "r:id");
1499
+ if (rid !== void 0) result.userShapes = rid;
1500
+ }
1501
+ return result;
1502
+ }
1503
+ };
1504
+ //#endregion
1505
+ //#region src/chart/user-shapes/user-shapes.ts
1506
+ /**
1507
+ * Chart user shapes part (cdr:userShapes / CT_Drawing in dml-chartDrawing).
1508
+ *
1509
+ * Freeform shapes layered over a chart, anchored relatively (from/to markers,
1510
+ * 0.0–1.0 of the chart area) or absolutely (from marker + EMU extent). The
1511
+ * part hangs off the chart part via `c:userShapes r:id` — that reference is
1512
+ * produced and parsed by chartSpaceDesc; this module is the part body.
1513
+ *
1514
+ * The shape payload reuses the core drawingml descriptors: shapeProperties /
1515
+ * textBody / blipFill / groupShapeProperties / style-matrix / cNvPr.
1516
+ *
1517
+ * Reference: ISO/IEC 29500-4, dml-chartDrawing.xsd, CT_Drawing
1518
+ *
1519
+ * @module
1520
+ */
1521
+ const CDR_NS = "http://schemas.openxmlformats.org/drawingml/2006/chartDrawing";
1522
+ const A_NS = "http://schemas.openxmlformats.org/drawingml/2006/main";
1523
+ const R_NS = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
1524
+ const DIRECT_CTX = {
1525
+ addRelationship: () => "",
1526
+ addMedia: () => "",
1527
+ addHyperlink: () => {}
1528
+ };
1529
+ function stringifyMarker(marker) {
1530
+ return `<cdr:x>${marker.x}</cdr:x><cdr:y>${marker.y}</cdr:y>`;
1531
+ }
1532
+ function stringifyCnvPr(id, nvp) {
1533
+ return stringifyNonVisualDrawingProperties("cdr:cNvPr", id, nvp, "User Shape");
1534
+ }
1535
+ function commonAttrs(opts) {
1536
+ let attrs = "";
1537
+ if (opts.macro !== void 0) attrs += ` macro="${escapeXml(opts.macro)}"`;
1538
+ if (opts.published) attrs += " fPublished=\"1\"";
1539
+ return attrs;
1540
+ }
1541
+ function isRelative(anchor) {
1542
+ return "to" in anchor;
1543
+ }
1544
+ function stringifyObject(obj) {
1545
+ switch (obj.type) {
1546
+ case "shape": {
1547
+ const textLinkAttr = obj.textLink !== void 0 ? ` textlink="${escapeXml(obj.textLink)}"` : "";
1548
+ const locksTextAttr = obj.locksText !== void 0 ? ` fLocksText="${obj.locksText ? 1 : 0}"` : "";
1549
+ const nvSpPr = `<cdr:nvSpPr>${stringifyCnvPr(obj.id, obj.nonVisualProperties)}<cdr:cNvSpPr${obj.textBox ? " txBox=\"1\"" : ""}/></cdr:nvSpPr>`;
1550
+ const spPrXml = stringify$1(shapePropertiesDesc, obj.shapeProperties, DIRECT_CTX) ?? "";
1551
+ const styleXml = obj.style ? stringifyShapeStyle(obj.style, DIRECT_CTX) : "";
1552
+ const txBodyXml = obj.textBody ? stringify$1(textBodyDesc, obj.textBody, DIRECT_CTX) ?? "" : "";
1553
+ return `<cdr:sp${commonAttrs(obj)}${textLinkAttr}${locksTextAttr}>` + nvSpPr + `<cdr:spPr>${spPrXml}</cdr:spPr>` + styleXml + txBodyXml + "</cdr:sp>";
1554
+ }
1555
+ case "connector": {
1556
+ const nvCxnSpPr = `<cdr:nvCxnSpPr>${stringifyCnvPr(obj.id, obj.nonVisualProperties)}<cdr:cNvCxnSpPr/></cdr:nvCxnSpPr>`;
1557
+ const spPrXml = stringify$1(shapePropertiesDesc, obj.shapeProperties, DIRECT_CTX) ?? "";
1558
+ const styleXml = obj.style ? stringifyShapeStyle(obj.style, DIRECT_CTX) : "";
1559
+ return `<cdr:cxnSp${commonAttrs(obj)}>` + nvCxnSpPr + `<cdr:spPr>${spPrXml}</cdr:spPr>` + styleXml + "</cdr:cxnSp>";
1560
+ }
1561
+ case "picture": {
1562
+ const nvPicPr = `<cdr:nvPicPr>${stringifyCnvPr(obj.id, obj.nonVisualProperties)}<cdr:cNvPicPr/></cdr:nvPicPr>`;
1563
+ const blipFillXml = (stringify$1(blipFillDesc, {
1564
+ ...obj.blipFill,
1565
+ referenceId: obj.referenceId
1566
+ }, DIRECT_CTX) ?? "").replace(/pic:blipFill/g, "cdr:blipFill");
1567
+ const spPrXml = stringify$1(shapePropertiesDesc, obj.shapeProperties, DIRECT_CTX) ?? "";
1568
+ const styleXml = obj.style ? stringifyShapeStyle(obj.style, DIRECT_CTX) : "";
1569
+ return `<cdr:pic${commonAttrs(obj)}>` + nvPicPr + blipFillXml + `<cdr:spPr>${spPrXml}</cdr:spPr>` + styleXml + "</cdr:pic>";
1570
+ }
1571
+ case "graphicFrame": {
1572
+ const locks = obj.graphicFrameLocks;
1573
+ const locksXml = locks ? `<a:graphicFrameLocks${Object.entries(locks).filter(([, v]) => v).map(([k]) => ` ${k}="1"`).join("")}/>` : "";
1574
+ const nvGraphicFramePr = `<cdr:nvGraphicFramePr>${stringifyCnvPr(obj.id, obj.nonVisualProperties)}<cdr:cNvGraphicFramePr>${locksXml}</cdr:cNvGraphicFramePr></cdr:nvGraphicFramePr>`;
1575
+ const xfrmXml = (stringify$1(transform2DDesc, obj.transform, DIRECT_CTX) ?? "").replace(/a:xfrm/g, "cdr:xfrm");
1576
+ return `<cdr:graphicFrame${commonAttrs(obj)}>` + nvGraphicFramePr + xfrmXml + obj.graphic + "</cdr:graphicFrame>";
1577
+ }
1578
+ case "group": {
1579
+ const nvGrpSpPr = `<cdr:nvGrpSpPr>${stringifyCnvPr(obj.id, obj.nonVisualProperties)}<cdr:cNvGrpSpPr/></cdr:nvGrpSpPr>`;
1580
+ const grpSpPrXml = stringify$1(groupShapePropertiesDesc, obj.groupShapeProperties, DIRECT_CTX) ?? "";
1581
+ return "<cdr:grpSp>" + nvGrpSpPr + `<cdr:grpSpPr>${grpSpPrXml}</cdr:grpSpPr>` + obj.children.map(stringifyObject).join("") + "</cdr:grpSp>";
1582
+ }
1583
+ }
1584
+ }
1585
+ function readMarker(el) {
1586
+ if (!el) return void 0;
1587
+ const x = findChild(el, "cdr:x");
1588
+ const y = findChild(el, "cdr:y");
1589
+ if (!x || !y) return void 0;
1590
+ return {
1591
+ x: Number(x.elements?.[0]?.text ?? 0),
1592
+ y: Number(y.elements?.[0]?.text ?? 0)
1593
+ };
1594
+ }
1595
+ function readCnvPr(el) {
1596
+ if (!el) return void 0;
1597
+ const attrs = el.attributes ?? {};
1598
+ if (attrs["id"] === void 0) return void 0;
1599
+ const nvp = {};
1600
+ if (attrs["name"] !== void 0) nvp.name = String(attrs["name"]);
1601
+ if (attrs["descr"] !== void 0) nvp.description = String(attrs["descr"]);
1602
+ if (attrs["hidden"] !== void 0) nvp.hidden = parseOnOff(attrs["hidden"]) ?? false;
1603
+ return {
1604
+ id: Number(attrs["id"]),
1605
+ nvp
1606
+ };
1607
+ }
1608
+ function readObject(el, ctx) {
1609
+ switch (el.name) {
1610
+ case "cdr:sp": {
1611
+ const nvSpPr = findChild(el, "cdr:nvSpPr");
1612
+ const spPr = findChild(el, "cdr:spPr");
1613
+ if (!nvSpPr || !spPr) return void 0;
1614
+ const cnvPr = readCnvPr(findChild(nvSpPr, "cdr:cNvPr"));
1615
+ if (!cnvPr) return void 0;
1616
+ const cNvSpPr = findChild(nvSpPr, "cdr:cNvSpPr");
1617
+ const result = {
1618
+ type: "shape",
1619
+ id: cnvPr.id,
1620
+ nonVisualProperties: cnvPr.nvp,
1621
+ shapeProperties: parse$1(shapePropertiesDesc, spPr, ctx)
1622
+ };
1623
+ if (cNvSpPr && cNvSpPr.attributes?.["txBox"] !== void 0) result.textBox = parseOnOff(cNvSpPr.attributes["txBox"]) ?? false;
1624
+ const styleEl = findChild(el, "a:style");
1625
+ if (styleEl) result.style = parseShapeStyle(styleEl, ctx);
1626
+ const txBody = findChild(el, "cdr:txBody");
1627
+ if (txBody) result.textBody = parse$1(textBodyDesc, txBody, ctx);
1628
+ if (el.attributes?.["macro"] !== void 0) result.macro = String(el.attributes["macro"]);
1629
+ if (el.attributes?.["textlink"] !== void 0) result.textLink = String(el.attributes["textlink"]);
1630
+ if (el.attributes?.["fLocksText"] !== void 0) result.locksText = parseOnOff(el.attributes["fLocksText"]) ?? true;
1631
+ if (el.attributes?.["fPublished"] !== void 0) result.published = parseOnOff(el.attributes["fPublished"]) ?? false;
1632
+ return result;
1633
+ }
1634
+ case "cdr:cxnSp": {
1635
+ const nvCxnSpPr = findChild(el, "cdr:nvCxnSpPr");
1636
+ const spPr = findChild(el, "cdr:spPr");
1637
+ if (!nvCxnSpPr || !spPr) return void 0;
1638
+ const cnvPr = readCnvPr(findChild(nvCxnSpPr, "cdr:cNvPr"));
1639
+ if (!cnvPr) return void 0;
1640
+ const result = {
1641
+ type: "connector",
1642
+ id: cnvPr.id,
1643
+ nonVisualProperties: cnvPr.nvp,
1644
+ shapeProperties: parse$1(shapePropertiesDesc, spPr, ctx)
1645
+ };
1646
+ const styleEl = findChild(el, "a:style");
1647
+ if (styleEl) result.style = parseShapeStyle(styleEl, ctx);
1648
+ if (el.attributes?.["macro"] !== void 0) result.macro = String(el.attributes["macro"]);
1649
+ if (el.attributes?.["fPublished"] !== void 0) result.published = parseOnOff(el.attributes["fPublished"]) ?? false;
1650
+ return result;
1651
+ }
1652
+ case "cdr:pic": {
1653
+ const nvPicPr = findChild(el, "cdr:nvPicPr");
1654
+ const blipFill = findChild(el, "cdr:blipFill");
1655
+ const spPr = findChild(el, "cdr:spPr");
1656
+ if (!nvPicPr || !blipFill || !spPr) return void 0;
1657
+ const cnvPr = readCnvPr(findChild(nvPicPr, "cdr:cNvPr"));
1658
+ if (!cnvPr) return void 0;
1659
+ const { referenceId, ...blipFillOpts } = parse$1(blipFillDesc, blipFill, ctx);
1660
+ const result = {
1661
+ type: "picture",
1662
+ id: cnvPr.id,
1663
+ nonVisualProperties: cnvPr.nvp,
1664
+ referenceId: referenceId ?? "",
1665
+ shapeProperties: parse$1(shapePropertiesDesc, spPr, ctx)
1666
+ };
1667
+ if (Object.keys(blipFillOpts).length > 0) result.blipFill = blipFillOpts;
1668
+ const styleEl = findChild(el, "a:style");
1669
+ if (styleEl) result.style = parseShapeStyle(styleEl, ctx);
1670
+ if (el.attributes?.["macro"] !== void 0) result.macro = String(el.attributes["macro"]);
1671
+ if (el.attributes?.["fPublished"] !== void 0) result.published = parseOnOff(el.attributes["fPublished"]) ?? false;
1672
+ return result;
1673
+ }
1674
+ case "cdr:graphicFrame": {
1675
+ const nvGraphicFramePr = findChild(el, "cdr:nvGraphicFramePr");
1676
+ const xfrm = findChild(el, "cdr:xfrm");
1677
+ const graphic = findChild(el, "a:graphic");
1678
+ if (!nvGraphicFramePr || !xfrm || !graphic) return void 0;
1679
+ const cnvPr = readCnvPr(findChild(nvGraphicFramePr, "cdr:cNvPr"));
1680
+ if (!cnvPr) return void 0;
1681
+ const result = {
1682
+ type: "graphicFrame",
1683
+ id: cnvPr.id,
1684
+ nonVisualProperties: cnvPr.nvp,
1685
+ transform: parse$1(transform2DDesc, xfrm, ctx),
1686
+ graphic: stringifyElement(graphic)
1687
+ };
1688
+ const cNvGraphicFramePr = findChild(nvGraphicFramePr, "cdr:cNvGraphicFramePr");
1689
+ if (cNvGraphicFramePr) {
1690
+ const locks = findChild(cNvGraphicFramePr, "a:graphicFrameLocks");
1691
+ if (locks) {
1692
+ const flags = {};
1693
+ for (const key of [
1694
+ "noGrp",
1695
+ "noDrilldown",
1696
+ "noSelect",
1697
+ "noChangeAspect",
1698
+ "noMove",
1699
+ "noResize"
1700
+ ]) {
1701
+ const raw = locks.attributes?.[key];
1702
+ if (raw !== void 0) flags[key] = parseOnOff(raw) ?? false;
1703
+ }
1704
+ if (Object.keys(flags).length > 0) result.graphicFrameLocks = flags;
1705
+ } else result.graphicFrameLocks = {};
1706
+ }
1707
+ if (el.attributes?.["macro"] !== void 0) result.macro = String(el.attributes["macro"]);
1708
+ if (el.attributes?.["fPublished"] !== void 0) result.published = parseOnOff(el.attributes["fPublished"]) ?? false;
1709
+ return result;
1710
+ }
1711
+ case "cdr:grpSp": {
1712
+ const nvGrpSpPr = findChild(el, "cdr:nvGrpSpPr");
1713
+ const grpSpPr = findChild(el, "cdr:grpSpPr");
1714
+ if (!nvGrpSpPr || !grpSpPr) return void 0;
1715
+ const cnvPr = readCnvPr(findChild(nvGrpSpPr, "cdr:cNvPr"));
1716
+ if (!cnvPr) return void 0;
1717
+ const children = [];
1718
+ for (const child of el.elements ?? []) {
1719
+ const parsed = readObject(child, ctx);
1720
+ if (parsed) children.push(parsed);
1721
+ }
1722
+ return {
1723
+ type: "group",
1724
+ id: cnvPr.id,
1725
+ nonVisualProperties: cnvPr.nvp,
1726
+ groupShapeProperties: parse$1(groupShapePropertiesDesc, grpSpPr, ctx),
1727
+ children
1728
+ };
1729
+ }
1730
+ default: return;
1731
+ }
1732
+ }
1733
+ const userShapesDesc = {
1734
+ kind: "custom",
1735
+ stringify(opts, _ctx) {
1736
+ const anchors = opts.anchors.map((anchor) => {
1737
+ const objectXml = stringifyObject(anchor.object);
1738
+ if (isRelative(anchor)) return `<cdr:relSizeAnchor><cdr:from>${stringifyMarker(anchor.from)}</cdr:from><cdr:to>${stringifyMarker(anchor.to)}</cdr:to>` + objectXml + `</cdr:relSizeAnchor>`;
1739
+ return `<cdr:absSizeAnchor><cdr:from>${stringifyMarker(anchor.from)}</cdr:from><cdr:ext cx="${anchor.extent.width}" cy="${anchor.extent.height}"/>` + objectXml + `</cdr:absSizeAnchor>`;
1740
+ }).join("");
1741
+ return `<cdr:userShapes xmlns:cdr="${CDR_NS}" xmlns:a="${A_NS}" xmlns:r="${R_NS}">` + anchors + `</cdr:userShapes>`;
1742
+ },
1743
+ parse(el, ctx) {
1744
+ const anchors = [];
1745
+ for (const anchorEl of el.elements ?? []) if (anchorEl.name === "cdr:relSizeAnchor") {
1746
+ const from = readMarker(findChild(anchorEl, "cdr:from"));
1747
+ const to = readMarker(findChild(anchorEl, "cdr:to"));
1748
+ const object = readAnchorObject(anchorEl, ctx);
1749
+ if (from && to && object) anchors.push({
1750
+ from,
1751
+ to,
1752
+ object
1753
+ });
1754
+ } else if (anchorEl.name === "cdr:absSizeAnchor") {
1755
+ const from = readMarker(findChild(anchorEl, "cdr:from"));
1756
+ const ext = findChild(anchorEl, "cdr:ext");
1757
+ const object = readAnchorObject(anchorEl, ctx);
1758
+ if (from && ext && object) anchors.push({
1759
+ from,
1760
+ extent: {
1761
+ width: Number(ext.attributes?.["cx"] ?? 0),
1762
+ height: Number(ext.attributes?.["cy"] ?? 0)
1763
+ },
1764
+ object
1765
+ });
1766
+ }
1767
+ return { anchors };
1768
+ }
1769
+ };
1770
+ /** Read the EG_ObjectChoices payload of an anchor element. */
1771
+ function readAnchorObject(anchorEl, ctx) {
1772
+ for (const child of anchorEl.elements ?? []) {
1773
+ const object = readObject(child, ctx);
1774
+ if (object) return object;
1775
+ }
1776
+ }
1777
+ //#endregion
1778
+ export { chartSpaceDesc as n, ChartCollection as r, userShapesDesc as t };
1779
+
1780
+ //# sourceMappingURL=chart-Kf_utasF.mjs.map