@rowsncolumns/toolkit 24.4.5 → 24.5.1

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 (113) hide show
  1. package/dist/cjs/autofilter-condition.d.ts +45 -1
  2. package/dist/cjs/autofilter-condition.d.ts.map +1 -1
  3. package/dist/cjs/autofilter-condition.js +135 -12
  4. package/dist/cjs/excel-parser/helpers.d.ts +15 -1
  5. package/dist/cjs/excel-parser/helpers.d.ts.map +1 -1
  6. package/dist/cjs/excel-parser/helpers.js +119 -5
  7. package/dist/cjs/excel-parser/interface.d.ts +3 -1
  8. package/dist/cjs/excel-parser/interface.d.ts.map +1 -1
  9. package/dist/cjs/excel-parser/plugins/ods/index.d.ts.map +1 -1
  10. package/dist/cjs/excel-parser/plugins/ods/index.js +186 -97
  11. package/dist/cjs/excel-parser/plugins/ods/styles.d.ts +15 -0
  12. package/dist/cjs/excel-parser/plugins/ods/styles.d.ts.map +1 -1
  13. package/dist/cjs/excel-parser/plugins/ods/styles.js +80 -6
  14. package/dist/cjs/excel-parser/plugins/xlsb/index.d.ts.map +1 -1
  15. package/dist/cjs/excel-parser/plugins/xlsb/index.js +107 -103
  16. package/dist/cjs/excel-parser/plugins/xlsx/charts.d.ts +77 -1
  17. package/dist/cjs/excel-parser/plugins/xlsx/charts.d.ts.map +1 -1
  18. package/dist/cjs/excel-parser/plugins/xlsx/charts.js +920 -122
  19. package/dist/cjs/excel-parser/plugins/xlsx/drawing.d.ts +7 -1
  20. package/dist/cjs/excel-parser/plugins/xlsx/drawing.d.ts.map +1 -1
  21. package/dist/cjs/excel-parser/plugins/xlsx/drawing.js +24 -9
  22. package/dist/cjs/excel-parser/plugins/xlsx/form-controls.d.ts +24 -3
  23. package/dist/cjs/excel-parser/plugins/xlsx/form-controls.d.ts.map +1 -1
  24. package/dist/cjs/excel-parser/plugins/xlsx/form-controls.js +25 -3
  25. package/dist/cjs/excel-parser/plugins/xlsx/index.d.ts +24 -1
  26. package/dist/cjs/excel-parser/plugins/xlsx/index.d.ts.map +1 -1
  27. package/dist/cjs/excel-parser/plugins/xlsx/index.js +561 -394
  28. package/dist/cjs/excel-parser/plugins/xlsx/pivots.d.ts +8 -2
  29. package/dist/cjs/excel-parser/plugins/xlsx/pivots.d.ts.map +1 -1
  30. package/dist/cjs/excel-parser/plugins/xlsx/pivots.js +312 -21
  31. package/dist/cjs/excel-parser/plugins/xlsx/relationships.d.ts +6 -0
  32. package/dist/cjs/excel-parser/plugins/xlsx/relationships.d.ts.map +1 -1
  33. package/dist/cjs/excel-parser/plugins/xlsx/relationships.js +9 -0
  34. package/dist/cjs/excel-parser/plugins/xlsx/theme.d.ts +1 -1
  35. package/dist/cjs/excel-parser/types.d.ts +9 -1
  36. package/dist/cjs/excel-parser/types.d.ts.map +1 -1
  37. package/dist/cjs/excel-parser/workbook.d.ts +1 -0
  38. package/dist/cjs/excel-parser/workbook.d.ts.map +1 -1
  39. package/dist/cjs/excel-parser/workbook.js +5 -0
  40. package/dist/cjs/excel-parser/worker.js +2 -0
  41. package/dist/cjs/exporter/ods/ods-export.d.ts.map +1 -1
  42. package/dist/cjs/exporter/ods/ods-export.js +255 -80
  43. package/dist/cjs/exporter/xlsx/chart-builder.d.ts +7 -1
  44. package/dist/cjs/exporter/xlsx/chart-builder.d.ts.map +1 -1
  45. package/dist/cjs/exporter/xlsx/chart-builder.js +902 -119
  46. package/dist/cjs/exporter/xlsx/form-controls-builder.d.ts +16 -3
  47. package/dist/cjs/exporter/xlsx/form-controls-builder.d.ts.map +1 -1
  48. package/dist/cjs/exporter/xlsx/form-controls-builder.js +30 -8
  49. package/dist/cjs/exporter/xlsx/pivot-builder.d.ts.map +1 -1
  50. package/dist/cjs/exporter/xlsx/pivot-builder.js +206 -162
  51. package/dist/cjs/exporter/xlsx/style-builder.d.ts +8 -2
  52. package/dist/cjs/exporter/xlsx/style-builder.d.ts.map +1 -1
  53. package/dist/cjs/exporter/xlsx/style-builder.js +25 -0
  54. package/dist/cjs/exporter/xlsx/xlsx-export.d.ts +2 -2
  55. package/dist/cjs/exporter/xlsx/xlsx-export.d.ts.map +1 -1
  56. package/dist/cjs/exporter/xlsx/xlsx-export.js +884 -470
  57. package/dist/esm/autofilter-condition.d.ts +45 -1
  58. package/dist/esm/autofilter-condition.d.ts.map +1 -1
  59. package/dist/esm/autofilter-condition.js +131 -11
  60. package/dist/esm/excel-parser/helpers.d.ts +15 -1
  61. package/dist/esm/excel-parser/helpers.d.ts.map +1 -1
  62. package/dist/esm/excel-parser/helpers.js +94 -4
  63. package/dist/esm/excel-parser/interface.d.ts +3 -1
  64. package/dist/esm/excel-parser/interface.d.ts.map +1 -1
  65. package/dist/esm/excel-parser/plugins/ods/index.d.ts.map +1 -1
  66. package/dist/esm/excel-parser/plugins/ods/index.js +105 -22
  67. package/dist/esm/excel-parser/plugins/ods/styles.d.ts +15 -0
  68. package/dist/esm/excel-parser/plugins/ods/styles.d.ts.map +1 -1
  69. package/dist/esm/excel-parser/plugins/ods/styles.js +79 -5
  70. package/dist/esm/excel-parser/plugins/xlsb/index.d.ts.map +1 -1
  71. package/dist/esm/excel-parser/plugins/xlsb/index.js +15 -7
  72. package/dist/esm/excel-parser/plugins/xlsx/charts.d.ts +77 -1
  73. package/dist/esm/excel-parser/plugins/xlsx/charts.d.ts.map +1 -1
  74. package/dist/esm/excel-parser/plugins/xlsx/charts.js +708 -16
  75. package/dist/esm/excel-parser/plugins/xlsx/drawing.d.ts +7 -1
  76. package/dist/esm/excel-parser/plugins/xlsx/drawing.d.ts.map +1 -1
  77. package/dist/esm/excel-parser/plugins/xlsx/drawing.js +23 -0
  78. package/dist/esm/excel-parser/plugins/xlsx/form-controls.d.ts +24 -3
  79. package/dist/esm/excel-parser/plugins/xlsx/form-controls.d.ts.map +1 -1
  80. package/dist/esm/excel-parser/plugins/xlsx/form-controls.js +21 -3
  81. package/dist/esm/excel-parser/plugins/xlsx/index.d.ts +24 -1
  82. package/dist/esm/excel-parser/plugins/xlsx/index.d.ts.map +1 -1
  83. package/dist/esm/excel-parser/plugins/xlsx/index.js +192 -54
  84. package/dist/esm/excel-parser/plugins/xlsx/pivots.d.ts +8 -2
  85. package/dist/esm/excel-parser/plugins/xlsx/pivots.d.ts.map +1 -1
  86. package/dist/esm/excel-parser/plugins/xlsx/pivots.js +220 -4
  87. package/dist/esm/excel-parser/plugins/xlsx/relationships.d.ts +6 -0
  88. package/dist/esm/excel-parser/plugins/xlsx/relationships.d.ts.map +1 -1
  89. package/dist/esm/excel-parser/plugins/xlsx/relationships.js +9 -0
  90. package/dist/esm/excel-parser/plugins/xlsx/theme.d.ts +1 -1
  91. package/dist/esm/excel-parser/types.d.ts +9 -1
  92. package/dist/esm/excel-parser/types.d.ts.map +1 -1
  93. package/dist/esm/excel-parser/workbook.d.ts +1 -0
  94. package/dist/esm/excel-parser/workbook.d.ts.map +1 -1
  95. package/dist/esm/excel-parser/workbook.js +4 -0
  96. package/dist/esm/excel-parser/worker.js +2 -0
  97. package/dist/esm/exporter/ods/ods-export.d.ts.map +1 -1
  98. package/dist/esm/exporter/ods/ods-export.js +238 -72
  99. package/dist/esm/exporter/xlsx/chart-builder.d.ts +7 -1
  100. package/dist/esm/exporter/xlsx/chart-builder.d.ts.map +1 -1
  101. package/dist/esm/exporter/xlsx/chart-builder.js +674 -58
  102. package/dist/esm/exporter/xlsx/form-controls-builder.d.ts +16 -3
  103. package/dist/esm/exporter/xlsx/form-controls-builder.d.ts.map +1 -1
  104. package/dist/esm/exporter/xlsx/form-controls-builder.js +29 -8
  105. package/dist/esm/exporter/xlsx/pivot-builder.d.ts.map +1 -1
  106. package/dist/esm/exporter/xlsx/pivot-builder.js +187 -139
  107. package/dist/esm/exporter/xlsx/style-builder.d.ts +8 -2
  108. package/dist/esm/exporter/xlsx/style-builder.d.ts.map +1 -1
  109. package/dist/esm/exporter/xlsx/style-builder.js +28 -0
  110. package/dist/esm/exporter/xlsx/xlsx-export.d.ts +2 -2
  111. package/dist/esm/exporter/xlsx/xlsx-export.d.ts.map +1 -1
  112. package/dist/esm/exporter/xlsx/xlsx-export.js +600 -206
  113. package/package.json +10 -5
@@ -16,6 +16,93 @@ var sanitizeXmlText = function (value) {
16
16
  var cloneTemplate = function (template) {
17
17
  return JSON.parse(JSON.stringify(template));
18
18
  };
19
+ /**
20
+ * Put `groups` where the template's `slotKey` chart group sat, in place, so
21
+ * every chart group keeps preceding `c:catAx` / `c:valAx` (CT_PlotArea:
22
+ * layout, chart groups, axes, dTable, spPr). Assigning a new key onto the
23
+ * plotArea object would append it after the axes.
24
+ */
25
+ var replacePlotAreaChartGroups = function (plotArea, groups, slotKey) {
26
+ var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e;
27
+ if (slotKey === void 0) { slotKey = "c:barChart"; }
28
+ var rebuilt = {};
29
+ var placed = false;
30
+ try {
31
+ for (var _f = __values(Object.entries(plotArea)), _g = _f.next(); !_g.done; _g = _f.next()) {
32
+ var _h = __read(_g.value, 2), key = _h[0], value = _h[1];
33
+ if (key === slotKey) {
34
+ try {
35
+ for (var groups_1 = (e_2 = void 0, __values(groups)), groups_1_1 = groups_1.next(); !groups_1_1.done; groups_1_1 = groups_1.next()) {
36
+ var _j = __read(groups_1_1.value, 2), groupKey = _j[0], group = _j[1];
37
+ rebuilt[groupKey] = group;
38
+ }
39
+ }
40
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
41
+ finally {
42
+ try {
43
+ if (groups_1_1 && !groups_1_1.done && (_b = groups_1.return)) _b.call(groups_1);
44
+ }
45
+ finally { if (e_2) throw e_2.error; }
46
+ }
47
+ placed = true;
48
+ continue;
49
+ }
50
+ if (!placed && (key === "c:catAx" || key === "c:valAx")) {
51
+ try {
52
+ for (var groups_2 = (e_3 = void 0, __values(groups)), groups_2_1 = groups_2.next(); !groups_2_1.done; groups_2_1 = groups_2.next()) {
53
+ var _k = __read(groups_2_1.value, 2), groupKey = _k[0], group = _k[1];
54
+ rebuilt[groupKey] = group;
55
+ }
56
+ }
57
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
58
+ finally {
59
+ try {
60
+ if (groups_2_1 && !groups_2_1.done && (_c = groups_2.return)) _c.call(groups_2);
61
+ }
62
+ finally { if (e_3) throw e_3.error; }
63
+ }
64
+ placed = true;
65
+ }
66
+ rebuilt[key] = value;
67
+ }
68
+ }
69
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
70
+ finally {
71
+ try {
72
+ if (_g && !_g.done && (_a = _f.return)) _a.call(_f);
73
+ }
74
+ finally { if (e_1) throw e_1.error; }
75
+ }
76
+ if (!placed) {
77
+ try {
78
+ for (var groups_3 = __values(groups), groups_3_1 = groups_3.next(); !groups_3_1.done; groups_3_1 = groups_3.next()) {
79
+ var _l = __read(groups_3_1.value, 2), groupKey = _l[0], group = _l[1];
80
+ rebuilt[groupKey] = group;
81
+ }
82
+ }
83
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
84
+ finally {
85
+ try {
86
+ if (groups_3_1 && !groups_3_1.done && (_d = groups_3.return)) _d.call(groups_3);
87
+ }
88
+ finally { if (e_4) throw e_4.error; }
89
+ }
90
+ }
91
+ try {
92
+ for (var _m = __values(Object.keys(plotArea)), _o = _m.next(); !_o.done; _o = _m.next()) {
93
+ var key = _o.value;
94
+ delete plotArea[key];
95
+ }
96
+ }
97
+ catch (e_5_1) { e_5 = { error: e_5_1 }; }
98
+ finally {
99
+ try {
100
+ if (_o && !_o.done && (_e = _m.return)) _e.call(_m);
101
+ }
102
+ finally { if (e_5) throw e_5.error; }
103
+ }
104
+ Object.assign(plotArea, rebuilt);
105
+ };
19
106
  var removeProp = function (obj, key) {
20
107
  delete obj[key];
21
108
  };
@@ -698,7 +785,7 @@ var groupSeriesByChartType = function (series, seriesRefs, defaultChartType) {
698
785
  * Check if a chart has multiple series types (combo chart).
699
786
  */
700
787
  var isComboChart = function (series, defaultChartType) {
701
- var e_1, _a;
788
+ var e_6, _a;
702
789
  var _b;
703
790
  var types = new Set();
704
791
  try {
@@ -707,12 +794,12 @@ var isComboChart = function (series, defaultChartType) {
707
794
  types.add((_b = s.seriesChartType) !== null && _b !== void 0 ? _b : defaultChartType);
708
795
  }
709
796
  }
710
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
797
+ catch (e_6_1) { e_6 = { error: e_6_1 }; }
711
798
  finally {
712
799
  try {
713
800
  if (series_1_1 && !series_1_1.done && (_a = series_1.return)) _a.call(series_1);
714
801
  }
715
- finally { if (e_1) throw e_1.error; }
802
+ finally { if (e_6) throw e_6.error; }
716
803
  }
717
804
  return types.size > 1;
718
805
  };
@@ -793,11 +880,22 @@ var buildBarSeriesNode = function (index, ref, seriesData, domainRef, sheetName,
793
880
  /**
794
881
  * Build a line series node.
795
882
  */
796
- var buildLineSeriesNode = function (index, ref, seriesData, domainRef, sheetName, smooth) {
883
+ var buildLineSeriesNode = function (index, ref, seriesData, domainRef, sheetName, smooth, showMarkers) {
797
884
  var _a, _b;
885
+ if (showMarkers === void 0) { showMarkers = false; }
798
886
  var seriesNode = cloneTemplate(line_series);
799
887
  seriesNode["c:idx"] = { a$: { val: index.toString() } };
800
888
  seriesNode["c:order"] = { a$: { val: index.toString() } };
889
+ // A series' own marker wins; otherwise "Line with Markers" leaves the
890
+ // symbol to Excel's automatic marker and a plain Line keeps the
891
+ // template's <c:symbol val="none"/> — same rule as the pure line branch.
892
+ var markerNode = buildMarkerNode(seriesData === null || seriesData === void 0 ? void 0 : seriesData.marker);
893
+ if (markerNode) {
894
+ seriesNode["c:marker"] = markerNode;
895
+ }
896
+ else if (showMarkers) {
897
+ removeProp(seriesNode, "c:marker");
898
+ }
801
899
  var seriesColor = seriesData === null || seriesData === void 0 ? void 0 : seriesData.color;
802
900
  // Line series carry the stroke fill on `c:spPr/a:ln`. A gradient on
803
901
  // a line stroke is unusual (Excel renders a flat-color stroke even
@@ -882,7 +980,7 @@ var buildAreaSeriesNode = function (index, ref, seriesData, domainRef, sheetName
882
980
  * reference.
883
981
  */
884
982
  var appendExtraCircularSeries = function (chartNode, groupKey, seriesRefs, seriesCatRefs, domainRef, series, sheetName) {
885
- var e_2, _a;
983
+ var e_7, _a;
886
984
  var _b, _c, _d, _e, _f, _g, _h;
887
985
  var group = (_b = chartNode["c:plotArea"]) === null || _b === void 0 ? void 0 : _b[groupKey];
888
986
  if (!group)
@@ -922,12 +1020,12 @@ var appendExtraCircularSeries = function (chartNode, groupKey, seriesRefs, serie
922
1020
  sers.push(node);
923
1021
  }
924
1022
  }
925
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
1023
+ catch (e_7_1) { e_7 = { error: e_7_1 }; }
926
1024
  finally {
927
1025
  try {
928
1026
  if (extra_1_1 && !extra_1_1.done && (_a = extra_1.return)) _a.call(extra_1);
929
1027
  }
930
- finally { if (e_2) throw e_2.error; }
1028
+ finally { if (e_7) throw e_7.error; }
931
1029
  }
932
1030
  group["c:ser"] = sers;
933
1031
  };
@@ -937,8 +1035,7 @@ var buildPieChart = function (domainRef, valueRef, title, subtitle) {
937
1035
  var plotArea = pieChart["c:plotArea"];
938
1036
  var donut = plotArea["c:doughnutChart"];
939
1037
  removeProp(donut, "c:holeSize");
940
- plotArea["c:pieChart"] = donut;
941
- removeProp(plotArea, "c:doughnutChart");
1038
+ replacePlotAreaChartGroups(plotArea, [["c:pieChart", donut]], "c:doughnutChart");
942
1039
  var seriesNode = plotArea["c:pieChart"]["c:ser"];
943
1040
  if (domainRef) {
944
1041
  seriesNode["c:cat"]["c:strRef"]["c:f"] = domainRef;
@@ -981,8 +1078,7 @@ var buildOfPieChart = function (domainRef, valueRef, title, spec, subtitle) {
981
1078
  Number.isFinite(spec.secondPieSize)
982
1079
  ? { "c:secondPieSize": { a$: { val: String(Math.round(spec.secondPieSize)) } } }
983
1080
  : {})), { "c:serLines": {} });
984
- plotArea["c:ofPieChart"] = ofPieNode;
985
- removeProp(plotArea, "c:doughnutChart");
1081
+ replacePlotAreaChartGroups(plotArea, [["c:ofPieChart", ofPieNode]], "c:doughnutChart");
986
1082
  var seriesNode = ofPieNode["c:ser"];
987
1083
  if (domainRef) {
988
1084
  seriesNode["c:cat"]["c:strRef"]["c:f"] = domainRef;
@@ -1015,8 +1111,7 @@ var buildRadarLikeChart = function (chartElementKey, domainRef, seriesRefs, titl
1015
1111
  a$: { val: radarStyle !== null && radarStyle !== void 0 ? radarStyle : "standard" },
1016
1112
  };
1017
1113
  }
1018
- removeProp(plotArea, "c:barChart");
1019
- plotArea[chartElementKey] = containerNode;
1114
+ replacePlotAreaChartGroups(plotArea, [[chartElementKey, containerNode]]);
1020
1115
  var seriesContainer = containerNode["c:ser"];
1021
1116
  seriesRefs.forEach(function (ref, index) {
1022
1117
  if (!ref)
@@ -1035,6 +1130,72 @@ var buildRadarLikeChart = function (chartElementKey, domainRef, seriesRefs, titl
1035
1130
  });
1036
1131
  return chartObj;
1037
1132
  };
1133
+ /**
1134
+ * Stock chart. The price series (high/low/close, or open/high/low/close)
1135
+ * go in `<c:stockChart>`; Excel's VHLC / VOHLC layouts carry the volume
1136
+ * as the first series in a sibling `<c:barChart>`, which the parser reads
1137
+ * back as the V-variant. Excel plots that volume on a secondary value
1138
+ * axis; here both groups share the primary axes. CT_StockChart order is
1139
+ * ser, hiLowLines, upDownBars, axId: every layout draws the high-low
1140
+ * lines, and an open (OHLC / VOHLC) adds Excel's up/down bars between
1141
+ * open and close — without them Excel renders bare, disconnected markers.
1142
+ */
1143
+ var buildStockChart = function (domainRef, seriesRefs, title, stockVariant, subtitle) {
1144
+ var e_8, _a;
1145
+ var _b, _c;
1146
+ var hasVolume = stockVariant === "VHLC" || stockVariant === "VOHLC";
1147
+ var hasOpen = stockVariant === "OHLC" || stockVariant === "VOHLC";
1148
+ var chartObj = cloneTemplate(column_json);
1149
+ applyChartTitle(chartObj, title, undefined, subtitle);
1150
+ var plotArea = chartObj["c:plotArea"];
1151
+ var axisIds = (_c = (_b = plotArea["c:barChart"]) === null || _b === void 0 ? void 0 : _b["c:axId"]) !== null && _c !== void 0 ? _c : [];
1152
+ var buildSeriesNode = function (ref, index) { return (__assign(__assign({ "c:idx": { a$: { val: String(index) } }, "c:order": { a$: { val: String(index) } } }, (domainRef ? { "c:cat": { "c:strRef": { "c:f": domainRef } } } : {})), { "c:val": { "c:numRef": { "c:f": ref } } })); };
1153
+ var volumeRef = hasVolume ? seriesRefs[0] : undefined;
1154
+ var priceRefs = hasVolume ? seriesRefs.slice(1) : seriesRefs;
1155
+ var priceOffset = hasVolume ? 1 : 0;
1156
+ var stockNode = __assign(__assign({ "c:ser": priceRefs.flatMap(function (ref, index) {
1157
+ return ref ? [buildSeriesNode(ref, index + priceOffset)] : [];
1158
+ }), "c:hiLowLines": {} }, (hasOpen
1159
+ ? {
1160
+ "c:upDownBars": {
1161
+ "c:gapWidth": { a$: { val: "150" } },
1162
+ "c:upBars": {},
1163
+ "c:downBars": {},
1164
+ },
1165
+ }
1166
+ : {})), { "c:axId": axisIds });
1167
+ // Swap the template's bar group in place so the chart groups keep
1168
+ // preceding the axes (CT_PlotArea order).
1169
+ var rebuilt = {};
1170
+ try {
1171
+ for (var _d = __values(Object.entries(plotArea)), _e = _d.next(); !_e.done; _e = _d.next()) {
1172
+ var _f = __read(_e.value, 2), key = _f[0], value = _f[1];
1173
+ if (key !== "c:barChart") {
1174
+ rebuilt[key] = value;
1175
+ continue;
1176
+ }
1177
+ if (volumeRef) {
1178
+ rebuilt["c:barChart"] = {
1179
+ "c:barDir": { a$: { val: "col" } },
1180
+ "c:grouping": { a$: { val: "clustered" } },
1181
+ "c:varyColors": { a$: { val: "0" } },
1182
+ "c:ser": [buildSeriesNode(volumeRef, 0)],
1183
+ "c:axId": axisIds,
1184
+ };
1185
+ }
1186
+ rebuilt["c:stockChart"] = stockNode;
1187
+ }
1188
+ }
1189
+ catch (e_8_1) { e_8 = { error: e_8_1 }; }
1190
+ finally {
1191
+ try {
1192
+ if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
1193
+ }
1194
+ finally { if (e_8) throw e_8.error; }
1195
+ }
1196
+ chartObj["c:plotArea"] = rebuilt;
1197
+ return chartObj;
1198
+ };
1038
1199
  var buildDoughnutChart = function (domainRef, valueRef, title, subtitle) {
1039
1200
  // Doughnut uses the same donut_json template as pie but keeps the
1040
1201
  // <c:doughnutChart> wrapper (and the holeSize, which we set later
@@ -1051,9 +1212,33 @@ var buildDoughnutChart = function (domainRef, valueRef, title, subtitle) {
1051
1212
  }
1052
1213
  return chartObj;
1053
1214
  };
1054
- export var buildChartXml = function (chart, sheetNameById) {
1055
- var e_3, _a, e_4, _b, e_5, _c;
1056
- var _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8;
1215
+ /**
1216
+ * Excel's Change Colors palette has no OOXML element of its own — the
1217
+ * colours it implies are written on each `<c:ser><c:spPr>`. Resolve
1218
+ * `spec.palette` onto every series that carries no fill of its own so the
1219
+ * file shows the palette in Excel and the parser reads the colours back.
1220
+ */
1221
+ var resolvePaletteIntoSeries = function (chart) {
1222
+ var _a;
1223
+ var palette = chart.spec.palette;
1224
+ var series = (_a = chart.spec) === null || _a === void 0 ? void 0 : _a.series;
1225
+ if (!(palette === null || palette === void 0 ? void 0 : palette.length) || !Array.isArray(series))
1226
+ return chart;
1227
+ // A pie / doughnut colours SLICES from the palette, not the series — a
1228
+ // series fill would paint every slice alike. `applySliceColors` writes
1229
+ // the palette per slice as `<c:dPt>` instead.
1230
+ if (isCircularChartType(chart.spec.chartType))
1231
+ return chart;
1232
+ return __assign(__assign({}, chart), { spec: __assign(__assign({}, chart.spec), { series: series.map(function (entry, index) {
1233
+ return (entry === null || entry === void 0 ? void 0 : entry.color) || (entry === null || entry === void 0 ? void 0 : entry.gradient) || (entry === null || entry === void 0 ? void 0 : entry.noFill)
1234
+ ? entry
1235
+ : __assign(__assign({}, entry), { color: palette[index % palette.length] });
1236
+ }) }) });
1237
+ };
1238
+ export var buildChartXml = function (input, sheetNameById, resolvePivotSourceName) {
1239
+ var e_9, _a, e_10, _b, e_11, _c;
1240
+ var _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10;
1241
+ var chart = resolvePaletteIntoSeries(input);
1057
1242
  var series = (_e = (_d = chart.spec) === null || _d === void 0 ? void 0 : _d.series) !== null && _e !== void 0 ? _e : [];
1058
1243
  if (!series.length)
1059
1244
  return undefined;
@@ -1061,20 +1246,27 @@ export var buildChartXml = function (chart, sheetNameById) {
1061
1246
  var seriesRefs = series.map(function (entry) {
1062
1247
  return formatSourcesRef(entry === null || entry === void 0 ? void 0 : entry.sources, sheetNameById);
1063
1248
  });
1249
+ // Excel keeps one category axis per axis group: a series on the
1250
+ // secondary axis takes the second chart domain (`domains[1]`) as its
1251
+ // `<c:cat>` when it carries no category range of its own.
1252
+ var secondaryDomainRef = formatSourcesRef((_j = (_h = chart.spec.domains) === null || _h === void 0 ? void 0 : _h[1]) === null || _j === void 0 ? void 0 : _j.sources, sheetNameById);
1064
1253
  var seriesCatRefs = series.map(function (entry) {
1065
- return seriesCategoryRef(entry, sheetNameById);
1254
+ var _a;
1255
+ return (_a = seriesCategoryRef(entry, sheetNameById)) !== null && _a !== void 0 ? _a : ((entry === null || entry === void 0 ? void 0 : entry.useSecondaryAxis) && secondaryDomainRef
1256
+ ? secondaryDomainRef
1257
+ : undefined);
1066
1258
  });
1067
1259
  if (!seriesRefs.some(Boolean))
1068
1260
  return undefined;
1069
1261
  var chartType = chart.spec.chartType;
1070
- var chartTitle = (_h = chart.spec.title) !== null && _h !== void 0 ? _h : undefined;
1262
+ var chartTitle = (_k = chart.spec.title) !== null && _k !== void 0 ? _k : undefined;
1071
1263
  // Subtitle line rendered under the title (e.g. a "Total Value to
1072
1264
  // Paid-In" caption under "Net MOIC by Fund Vintage"). Emitted as a
1073
1265
  // second `<a:p>` in the title's rich block — see `applyChartTitle`.
1074
- var chartSubtitle = (_j = chart.spec.subtitle) !== null && _j !== void 0 ? _j : undefined;
1266
+ var chartSubtitle = (_l = chart.spec.subtitle) !== null && _l !== void 0 ? _l : undefined;
1075
1267
  // Authored title text formatting (color/font/bold) — round-tripped
1076
1268
  // back so Excel keeps the styled title we read on import.
1077
- var chartTitleFmt = (_k = chart.spec.titleTextFormat) !== null && _k !== void 0 ? _k : undefined;
1269
+ var chartTitleFmt = (_m = chart.spec.titleTextFormat) !== null && _m !== void 0 ? _m : undefined;
1078
1270
  var smooth = "smooth" in chart.spec ? chart.spec.smooth : undefined;
1079
1271
  var chartSpace = cloneTemplate(chart_template);
1080
1272
  var sheetName = sheetNameById.get(chart.position.sheetId);
@@ -1086,14 +1278,16 @@ export var buildChartXml = function (chart, sheetNameById) {
1086
1278
  applyChartTitle(comboChart, chartTitle, chartTitleFmt, chartSubtitle);
1087
1279
  var plotArea = comboChart["c:plotArea"];
1088
1280
  var baseBarChart = plotArea["c:barChart"];
1089
- var axisIds = (_l = baseBarChart === null || baseBarChart === void 0 ? void 0 : baseBarChart["c:axId"]) !== null && _l !== void 0 ? _l : [];
1090
- var dLbls = (_m = baseBarChart === null || baseBarChart === void 0 ? void 0 : baseBarChart["c:dLbls"]) !== null && _m !== void 0 ? _m : {};
1091
- // Remove the default bar chart - we'll add specific chart types
1092
- removeProp(plotArea, "c:barChart");
1281
+ var axisIds = (_o = baseBarChart === null || baseBarChart === void 0 ? void 0 : baseBarChart["c:axId"]) !== null && _o !== void 0 ? _o : [];
1282
+ var dLbls = (_p = baseBarChart === null || baseBarChart === void 0 ? void 0 : baseBarChart["c:dLbls"]) !== null && _p !== void 0 ? _p : {};
1283
+ var comboStackedType = chart.spec.stackedType;
1284
+ var showMarkers = Boolean(chart.spec.showMarkers);
1285
+ // One container per chart type, swapped into the template's bar slot
1286
+ // together so they all precede the axes (CT_PlotArea order).
1287
+ var comboGroups = [];
1093
1288
  try {
1094
- // Add chart type containers for each group
1095
- for (var groups_1 = __values(groups), groups_1_1 = groups_1.next(); !groups_1_1.done; groups_1_1 = groups_1.next()) {
1096
- var _9 = __read(groups_1_1.value, 2), groupType = _9[0], groupSeries = _9[1];
1289
+ for (var groups_4 = __values(groups), groups_4_1 = groups_4.next(); !groups_4_1.done; groups_4_1 = groups_4.next()) {
1290
+ var _11 = __read(groups_4_1.value, 2), groupType = _11[0], groupSeries = _11[1];
1097
1291
  if (groupType === "bar" || groupType === "column") {
1098
1292
  var barChartNode = {
1099
1293
  "c:barDir": { a$: { val: groupType === "bar" ? "bar" : "col" } },
@@ -1104,35 +1298,46 @@ export var buildChartXml = function (chart, sheetNameById) {
1104
1298
  "c:axId": axisIds,
1105
1299
  };
1106
1300
  for (var i = 0; i < groupSeries.length; i++) {
1107
- var _10 = groupSeries[i], index = _10.index, ref = _10.ref, data = _10.data;
1108
- var seriesNode = buildBarSeriesNode(index, ref, data, (_o = seriesCatRefs[index]) !== null && _o !== void 0 ? _o : domainRef, sheetName, i === 0);
1301
+ var _12 = groupSeries[i], index = _12.index, ref = _12.ref, data = _12.data;
1302
+ var seriesNode = buildBarSeriesNode(index, ref, data, (_q = seriesCatRefs[index]) !== null && _q !== void 0 ? _q : domainRef, sheetName, i === 0);
1109
1303
  barChartNode["c:ser"].push(seriesNode);
1110
1304
  }
1111
- plotArea["c:barChart"] = barChartNode;
1305
+ comboGroups.push(["c:barChart", barChartNode]);
1112
1306
  }
1113
1307
  else if (groupType === "line") {
1308
+ // The line group honours the same grouping / marker rules as the
1309
+ // pure line branch (CT_LineChart: ser, dLbls, marker, axId).
1114
1310
  var lineChartNode = {
1115
- "c:grouping": { a$: { val: "standard" } },
1311
+ "c:grouping": {
1312
+ a$: {
1313
+ val: comboStackedType === "STACKED"
1314
+ ? "stacked"
1315
+ : comboStackedType === "PERCENT_STACKED"
1316
+ ? "percentStacked"
1317
+ : "standard",
1318
+ },
1319
+ },
1116
1320
  "c:varyColors": { a$: { val: "0" } },
1117
1321
  "c:ser": [],
1118
1322
  "c:dLbls": dLbls,
1323
+ "c:marker": { a$: { val: "1" } },
1119
1324
  "c:axId": axisIds,
1120
1325
  };
1121
1326
  try {
1122
- for (var groupSeries_1 = (e_4 = void 0, __values(groupSeries)), groupSeries_1_1 = groupSeries_1.next(); !groupSeries_1_1.done; groupSeries_1_1 = groupSeries_1.next()) {
1123
- var _11 = groupSeries_1_1.value, index = _11.index, ref = _11.ref, data = _11.data;
1124
- var seriesNode = buildLineSeriesNode(index, ref, data, (_p = seriesCatRefs[index]) !== null && _p !== void 0 ? _p : domainRef, sheetName, smooth);
1327
+ for (var groupSeries_1 = (e_10 = void 0, __values(groupSeries)), groupSeries_1_1 = groupSeries_1.next(); !groupSeries_1_1.done; groupSeries_1_1 = groupSeries_1.next()) {
1328
+ var _13 = groupSeries_1_1.value, index = _13.index, ref = _13.ref, data = _13.data;
1329
+ var seriesNode = buildLineSeriesNode(index, ref, data, (_r = seriesCatRefs[index]) !== null && _r !== void 0 ? _r : domainRef, sheetName, smooth, showMarkers);
1125
1330
  lineChartNode["c:ser"].push(seriesNode);
1126
1331
  }
1127
1332
  }
1128
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
1333
+ catch (e_10_1) { e_10 = { error: e_10_1 }; }
1129
1334
  finally {
1130
1335
  try {
1131
1336
  if (groupSeries_1_1 && !groupSeries_1_1.done && (_b = groupSeries_1.return)) _b.call(groupSeries_1);
1132
1337
  }
1133
- finally { if (e_4) throw e_4.error; }
1338
+ finally { if (e_10) throw e_10.error; }
1134
1339
  }
1135
- plotArea["c:lineChart"] = lineChartNode;
1340
+ comboGroups.push(["c:lineChart", lineChartNode]);
1136
1341
  }
1137
1342
  else if (groupType === "area") {
1138
1343
  var areaChartNode = {
@@ -1143,36 +1348,37 @@ export var buildChartXml = function (chart, sheetNameById) {
1143
1348
  "c:axId": axisIds,
1144
1349
  };
1145
1350
  try {
1146
- for (var groupSeries_2 = (e_5 = void 0, __values(groupSeries)), groupSeries_2_1 = groupSeries_2.next(); !groupSeries_2_1.done; groupSeries_2_1 = groupSeries_2.next()) {
1147
- var _12 = groupSeries_2_1.value, index = _12.index, ref = _12.ref, data = _12.data;
1148
- var seriesNode = buildAreaSeriesNode(index, ref, data, (_q = seriesCatRefs[index]) !== null && _q !== void 0 ? _q : domainRef, sheetName);
1351
+ for (var groupSeries_2 = (e_11 = void 0, __values(groupSeries)), groupSeries_2_1 = groupSeries_2.next(); !groupSeries_2_1.done; groupSeries_2_1 = groupSeries_2.next()) {
1352
+ var _14 = groupSeries_2_1.value, index = _14.index, ref = _14.ref, data = _14.data;
1353
+ var seriesNode = buildAreaSeriesNode(index, ref, data, (_s = seriesCatRefs[index]) !== null && _s !== void 0 ? _s : domainRef, sheetName);
1149
1354
  areaChartNode["c:ser"].push(seriesNode);
1150
1355
  }
1151
1356
  }
1152
- catch (e_5_1) { e_5 = { error: e_5_1 }; }
1357
+ catch (e_11_1) { e_11 = { error: e_11_1 }; }
1153
1358
  finally {
1154
1359
  try {
1155
1360
  if (groupSeries_2_1 && !groupSeries_2_1.done && (_c = groupSeries_2.return)) _c.call(groupSeries_2);
1156
1361
  }
1157
- finally { if (e_5) throw e_5.error; }
1362
+ finally { if (e_11) throw e_11.error; }
1158
1363
  }
1159
- plotArea["c:areaChart"] = areaChartNode;
1364
+ comboGroups.push(["c:areaChart", areaChartNode]);
1160
1365
  }
1161
1366
  }
1162
1367
  }
1163
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
1368
+ catch (e_9_1) { e_9 = { error: e_9_1 }; }
1164
1369
  finally {
1165
1370
  try {
1166
- if (groups_1_1 && !groups_1_1.done && (_a = groups_1.return)) _a.call(groups_1);
1371
+ if (groups_4_1 && !groups_4_1.done && (_a = groups_4.return)) _a.call(groups_4);
1167
1372
  }
1168
- finally { if (e_3) throw e_3.error; }
1373
+ finally { if (e_9) throw e_9.error; }
1169
1374
  }
1375
+ replacePlotAreaChartGroups(plotArea, comboGroups);
1376
+ // Legend, data labels, axis options, overlays and the secondary axis
1377
+ // group are applied by the shared formatting pass below, like every
1378
+ // other chart type.
1170
1379
  chartSpace["c:chartSpace"]["c:chart"] = comboChart;
1171
- var xml_1 = chartBuilder.build(chartSpace);
1172
- return "".concat(XML_DECLARATION).concat(xml_1);
1173
1380
  }
1174
- // Handle non-combo charts (original logic)
1175
- if (isC15ChartType(chartType)) {
1381
+ else if (isC15ChartType(chartType)) {
1176
1382
  // Histogram / boxplot / waterfall / funnel emit as a barChart for
1177
1383
  // older Excel compatibility. For histogram (Phase 5.5b), the
1178
1384
  // barChart is wrapped in mc:AlternateContent with a c15:histogramChart
@@ -1222,8 +1428,8 @@ export var buildChartXml = function (chart, sheetNameById) {
1222
1428
  // c:catAx / c:valAx stay at c:plotArea level — both Choice and
1223
1429
  // Fallback reference them through matching axId values.
1224
1430
  var axIdNodes = bar["c:axId"];
1225
- var catAxId = (_t = (_s = (_r = axIdNodes === null || axIdNodes === void 0 ? void 0 : axIdNodes[0]) === null || _r === void 0 ? void 0 : _r.a$) === null || _s === void 0 ? void 0 : _s.val) !== null && _t !== void 0 ? _t : "1";
1226
- var valAxId = (_w = (_v = (_u = axIdNodes === null || axIdNodes === void 0 ? void 0 : axIdNodes[1]) === null || _u === void 0 ? void 0 : _u.a$) === null || _v === void 0 ? void 0 : _v.val) !== null && _w !== void 0 ? _w : "2";
1431
+ var catAxId = (_v = (_u = (_t = axIdNodes === null || axIdNodes === void 0 ? void 0 : axIdNodes[0]) === null || _t === void 0 ? void 0 : _t.a$) === null || _u === void 0 ? void 0 : _u.val) !== null && _v !== void 0 ? _v : "1";
1432
+ var valAxId = (_y = (_x = (_w = axIdNodes === null || axIdNodes === void 0 ? void 0 : axIdNodes[1]) === null || _w === void 0 ? void 0 : _w.a$) === null || _x === void 0 ? void 0 : _x.val) !== null && _y !== void 0 ? _y : "2";
1227
1433
  var c15Args = {
1228
1434
  seriesRefs: seriesRefs,
1229
1435
  series: series,
@@ -1244,8 +1450,9 @@ export var buildChartXml = function (chart, sheetNameById) {
1244
1450
  c15Chart = buildC15FunnelChartNode(chart.spec, c15Args.seriesRefs, c15Args.series, c15Args.domainRef, c15Args.axIds);
1245
1451
  }
1246
1452
  var altContent = buildC15AlternateContent(chartType, c15Chart, bar);
1247
- removeProp(barChartDoc["c:plotArea"], "c:barChart");
1248
- barChartDoc["c:plotArea"]["mc:AlternateContent"] = altContent;
1453
+ replacePlotAreaChartGroups(barChartDoc["c:plotArea"], [
1454
+ ["mc:AlternateContent", altContent],
1455
+ ]);
1249
1456
  chartSpace["c:chartSpace"]["c:chart"] = barChartDoc;
1250
1457
  }
1251
1458
  else if (chartType === "bar" || chartType === "column") {
@@ -1278,7 +1485,7 @@ export var buildChartXml = function (chart, sheetNameById) {
1278
1485
  var seriesContainer_2 = bar["c:ser"];
1279
1486
  // Inline categories — when no cell-range, use the first domain's
1280
1487
  // inlineValues directly on the first series' c:cat.
1281
- var inlineDomainValues_1 = (_y = (_x = chart.spec.domains) === null || _x === void 0 ? void 0 : _x[0]) === null || _y === void 0 ? void 0 : _y.inlineValues;
1488
+ var inlineDomainValues_1 = (_0 = (_z = chart.spec.domains) === null || _z === void 0 ? void 0 : _z[0]) === null || _0 === void 0 ? void 0 : _0.inlineValues;
1282
1489
  seriesRefs.forEach(function (ref, index) {
1283
1490
  var _a, _b;
1284
1491
  if (!ref && !((_a = series[index]) === null || _a === void 0 ? void 0 : _a.inlineValues))
@@ -1298,7 +1505,7 @@ export var buildChartXml = function (chart, sheetNameById) {
1298
1505
  var specAny = chart.spec;
1299
1506
  // Pie-of-pie / bar-of-pie round-trips as <c:ofPieChart> when the
1300
1507
  // spec carries the OF_PIE marker (or an explicit ofPieType).
1301
- var isOfPie = String((_z = specAny === null || specAny === void 0 ? void 0 : specAny.sourceChartType) !== null && _z !== void 0 ? _z : "").toUpperCase() === "OF_PIE" ||
1508
+ var isOfPie = String((_1 = specAny === null || specAny === void 0 ? void 0 : specAny.sourceChartType) !== null && _1 !== void 0 ? _1 : "").toUpperCase() === "OF_PIE" ||
1302
1509
  (specAny === null || specAny === void 0 ? void 0 : specAny.ofPieType) === "pie" ||
1303
1510
  (specAny === null || specAny === void 0 ? void 0 : specAny.ofPieType) === "bar";
1304
1511
  var pieChart = isOfPie
@@ -1316,11 +1523,11 @@ export var buildChartXml = function (chart, sheetNameById) {
1316
1523
  chartSpace["c:chartSpace"]["c:chart"] = doughnutChart;
1317
1524
  }
1318
1525
  else if (chartType === "radar") {
1319
- var radarChart = buildRadarLikeChart("c:radarChart", domainRef, seriesRefs, chartTitle, (_0 = chart.spec.radarStyle) !== null && _0 !== void 0 ? _0 : "standard", chartSubtitle);
1526
+ var radarChart = buildRadarLikeChart("c:radarChart", domainRef, seriesRefs, chartTitle, (_2 = chart.spec.radarStyle) !== null && _2 !== void 0 ? _2 : "standard", chartSubtitle);
1320
1527
  chartSpace["c:chartSpace"]["c:chart"] = radarChart;
1321
1528
  }
1322
1529
  else if (chartType === "stock") {
1323
- var stockChart = buildRadarLikeChart("c:stockChart", domainRef, seriesRefs, chartTitle, undefined, chartSubtitle);
1530
+ var stockChart = buildStockChart(domainRef, seriesRefs, chartTitle, chart.spec.stockVariant, chartSubtitle);
1324
1531
  chartSpace["c:chartSpace"]["c:chart"] = stockChart;
1325
1532
  }
1326
1533
  else if (chartType === "line") {
@@ -1328,10 +1535,16 @@ export var buildChartXml = function (chart, sheetNameById) {
1328
1535
  applyChartTitle(lineChart, chartTitle, chartTitleFmt, chartSubtitle);
1329
1536
  var plotArea = lineChart["c:plotArea"];
1330
1537
  var barChart = plotArea["c:barChart"];
1538
+ var lineStackedType = chart.spec.stackedType;
1539
+ var showMarkers_1 = Boolean(chart.spec.showMarkers);
1331
1540
  var lineChartNode = {
1332
1541
  "c:grouping": {
1333
1542
  a$: {
1334
- val: "standard",
1543
+ val: lineStackedType === "STACKED"
1544
+ ? "stacked"
1545
+ : lineStackedType === "PERCENT_STACKED"
1546
+ ? "percentStacked"
1547
+ : "standard",
1335
1548
  },
1336
1549
  },
1337
1550
  "c:varyColors": {
@@ -1340,14 +1553,16 @@ export var buildChartXml = function (chart, sheetNameById) {
1340
1553
  },
1341
1554
  },
1342
1555
  "c:ser": [],
1343
- "c:dLbls": (_1 = barChart === null || barChart === void 0 ? void 0 : barChart["c:dLbls"]) !== null && _1 !== void 0 ? _1 : {},
1344
- "c:axId": (_2 = barChart === null || barChart === void 0 ? void 0 : barChart["c:axId"]) !== null && _2 !== void 0 ? _2 : [],
1556
+ "c:dLbls": (_3 = barChart === null || barChart === void 0 ? void 0 : barChart["c:dLbls"]) !== null && _3 !== void 0 ? _3 : {},
1557
+ // Excel writes the chart-level flag on every line chart and hides
1558
+ // a plain Line's markers per series (<c:symbol val="none"/>).
1559
+ "c:marker": { a$: { val: "1" } },
1560
+ "c:axId": (_4 = barChart === null || barChart === void 0 ? void 0 : barChart["c:axId"]) !== null && _4 !== void 0 ? _4 : [],
1345
1561
  };
1346
- removeProp(plotArea, "c:barChart");
1347
- plotArea["c:lineChart"] = lineChartNode;
1562
+ replacePlotAreaChartGroups(plotArea, [["c:lineChart", lineChartNode]]);
1348
1563
  var seriesContainer_3 = lineChartNode["c:ser"];
1349
1564
  seriesRefs.forEach(function (ref, index) {
1350
- var _a, _b, _c, _d, _e;
1565
+ var _a, _b, _c, _d, _e, _f;
1351
1566
  if (!ref)
1352
1567
  return;
1353
1568
  var seriesNode = cloneTemplate(line_series);
@@ -1374,7 +1589,17 @@ export var buildChartXml = function (chart, sheetNameById) {
1374
1589
  if (smooth) {
1375
1590
  seriesNode["c:smooth"].a$.val = "1";
1376
1591
  }
1377
- var labelNode = buildSeriesLabel((_d = (_c = series[index]) === null || _c === void 0 ? void 0 : _c.dataLabel) !== null && _d !== void 0 ? _d : undefined, sheetNameById.get(chart.position.sheetId), (_e = series[index]) === null || _e === void 0 ? void 0 : _e.dataLabelRef);
1592
+ // A series' own marker wins; otherwise "Line with Markers" leaves
1593
+ // the symbol to Excel's automatic marker and a plain Line keeps the
1594
+ // template's <c:symbol val="none"/>.
1595
+ var markerNode = buildMarkerNode((_c = series[index]) === null || _c === void 0 ? void 0 : _c.marker);
1596
+ if (markerNode) {
1597
+ seriesNode["c:marker"] = markerNode;
1598
+ }
1599
+ else if (showMarkers_1) {
1600
+ removeProp(seriesNode, "c:marker");
1601
+ }
1602
+ var labelNode = buildSeriesLabel((_e = (_d = series[index]) === null || _d === void 0 ? void 0 : _d.dataLabel) !== null && _e !== void 0 ? _e : undefined, sheetNameById.get(chart.position.sheetId), (_f = series[index]) === null || _f === void 0 ? void 0 : _f.dataLabelRef);
1378
1603
  if (labelNode) {
1379
1604
  seriesNode["c:tx"] = labelNode["c:tx"];
1380
1605
  }
@@ -1399,11 +1624,10 @@ export var buildChartXml = function (chart, sheetNameById) {
1399
1624
  },
1400
1625
  },
1401
1626
  "c:ser": [],
1402
- "c:dLbls": (_3 = barChart === null || barChart === void 0 ? void 0 : barChart["c:dLbls"]) !== null && _3 !== void 0 ? _3 : {},
1403
- "c:axId": (_4 = barChart === null || barChart === void 0 ? void 0 : barChart["c:axId"]) !== null && _4 !== void 0 ? _4 : [],
1627
+ "c:dLbls": (_5 = barChart === null || barChart === void 0 ? void 0 : barChart["c:dLbls"]) !== null && _5 !== void 0 ? _5 : {},
1628
+ "c:axId": (_6 = barChart === null || barChart === void 0 ? void 0 : barChart["c:axId"]) !== null && _6 !== void 0 ? _6 : [],
1404
1629
  };
1405
- removeProp(plotArea, "c:barChart");
1406
- plotArea["c:areaChart"] = areaChartNode;
1630
+ replacePlotAreaChartGroups(plotArea, [["c:areaChart", areaChartNode]]);
1407
1631
  var seriesContainer_4 = areaChartNode["c:ser"];
1408
1632
  seriesRefs.forEach(function (ref, index) {
1409
1633
  var _a, _b, _c, _d, _e;
@@ -1442,10 +1666,10 @@ export var buildChartXml = function (chart, sheetNameById) {
1442
1666
  }
1443
1667
  else if (chartType === "scatter" || chartType === "bubble") {
1444
1668
  var bubbleSpec = chart.spec;
1445
- var domainEntries_1 = (_5 = bubbleSpec.domains) !== null && _5 !== void 0 ? _5 : [];
1446
- var seriesEntries = (_6 = bubbleSpec.series) !== null && _6 !== void 0 ? _6 : [];
1447
- var bubbleSizeEntries_1 = (_7 = bubbleSpec.bubbleSizes) !== null && _7 !== void 0 ? _7 : [];
1448
- var bubbleLabelEntries_1 = (_8 = bubbleSpec.bubbleLabels) !== null && _8 !== void 0 ? _8 : [];
1669
+ var domainEntries_1 = (_7 = bubbleSpec.domains) !== null && _7 !== void 0 ? _7 : [];
1670
+ var seriesEntries = (_8 = bubbleSpec.series) !== null && _8 !== void 0 ? _8 : [];
1671
+ var bubbleSizeEntries_1 = (_9 = bubbleSpec.bubbleSizes) !== null && _9 !== void 0 ? _9 : [];
1672
+ var bubbleLabelEntries_1 = (_10 = bubbleSpec.bubbleLabels) !== null && _10 !== void 0 ? _10 : [];
1449
1673
  var seriesContainer_5 = [];
1450
1674
  var seriesTemplate_1 = chartType === "bubble" ? bubble_series : scatter_series;
1451
1675
  seriesEntries.forEach(function (entry, index) {
@@ -1498,12 +1722,11 @@ export var buildChartXml = function (chart, sheetNameById) {
1498
1722
  var plotArea = chartDoc["c:plotArea"];
1499
1723
  var scatterChart = plotArea["c:scatterChart"];
1500
1724
  if (chartType === "bubble") {
1501
- removeProp(plotArea, "c:scatterChart");
1502
1725
  removeProp(scatterChart, "c:scatterStyle");
1503
1726
  scatterChart["c:bubbleScale"] = { a$: { val: "100" } };
1504
1727
  scatterChart["c:showNegBubbles"] = { a$: { val: "0" } };
1505
1728
  scatterChart["c:sizeRepresents"] = { a$: { val: "area" } };
1506
- plotArea["c:bubbleChart"] = scatterChart;
1729
+ replacePlotAreaChartGroups(plotArea, [["c:bubbleChart", scatterChart]], "c:scatterChart");
1507
1730
  }
1508
1731
  else {
1509
1732
  // <c:scatterStyle> — Excel default is "lineMarker". Round-trip
@@ -1550,9 +1773,40 @@ export var buildChartXml = function (chart, sheetNameById) {
1550
1773
  if (chart.spec.roundedCorners) {
1551
1774
  chartSpace["c:chartSpace"]["c:roundedCorners"] = { a$: { val: "1" } };
1552
1775
  }
1776
+ // Chart Styles gallery pick — `<c:style val>` (1-48) with the Office
1777
+ // 2010+ `<c14:style>` twin at +100 in the mc:Choice the template
1778
+ // already carries. Unstyled charts keep the template's default (2).
1779
+ var chartStyle = Number(chart.spec.chartStyle);
1780
+ if (Number.isInteger(chartStyle) && chartStyle >= 1 && chartStyle <= 48) {
1781
+ var alternate = chartSpace["c:chartSpace"]["mc:AlternateContent"];
1782
+ alternate["mc:Choice"]["c14:style"].a$.val = String(100 + chartStyle);
1783
+ alternate["mc:Fallback"]["c:style"].a$.val = String(chartStyle);
1784
+ }
1785
+ applyPivotChartBinding(chartSpace, chart.spec, resolvePivotSourceName);
1786
+ // Format Chart Area → Fill / Border: the chartSpace `<c:spPr>`. The
1787
+ // template's theme fill (`bg1`) and hairline stay when nothing is
1788
+ // authored so untouched charts export exactly as before.
1789
+ var chartSpacePr = chartSpace["c:chartSpace"]["c:spPr"];
1790
+ var backgroundHex = toHex(chart.spec.backgroundColor);
1791
+ if (backgroundHex) {
1792
+ chartSpacePr["a:solidFill"] = { "a:srgbClr": { a$: { val: backgroundHex } } };
1793
+ }
1794
+ var borderHex = toHex(chart.borderColor);
1795
+ if (borderHex) {
1796
+ chartSpacePr["a:ln"]["a:solidFill"] = {
1797
+ "a:srgbClr": { a$: { val: borderHex } },
1798
+ };
1799
+ }
1553
1800
  var xml = chartBuilder.build(chartSpace);
1554
1801
  return "".concat(XML_DECLARATION).concat(xml);
1555
1802
  };
1803
+ /** `#RRGGBB` / `RRGGBB` → uppercase `RRGGBB`; anything else is not emitted. */
1804
+ var toHex = function (color) {
1805
+ if (typeof color !== "string")
1806
+ return undefined;
1807
+ var hex = color.trim().replace(/^#/, "");
1808
+ return /^[0-9a-fA-F]{6}$/.test(hex) ? hex.toUpperCase() : undefined;
1809
+ };
1556
1810
  // -------------------------- 3-D / surface --------------------------
1557
1811
  /** Series-axis id for the 3-D chart groups that take a third axis. */
1558
1812
  var SER_AX_ID = "1789284465";
@@ -1577,7 +1831,7 @@ var normalizeThreeDToken = function (value) {
1577
1831
  };
1578
1832
  /** Copy `keys` (in order) from `source` into `target`, skipping absent ones. */
1579
1833
  var pickKeys = function (target, source, keys) {
1580
- var e_6, _a;
1834
+ var e_12, _a;
1581
1835
  try {
1582
1836
  for (var keys_1 = __values(keys), keys_1_1 = keys_1.next(); !keys_1_1.done; keys_1_1 = keys_1.next()) {
1583
1837
  var key = keys_1_1.value;
@@ -1585,12 +1839,12 @@ var pickKeys = function (target, source, keys) {
1585
1839
  target[key] = source[key];
1586
1840
  }
1587
1841
  }
1588
- catch (e_6_1) { e_6 = { error: e_6_1 }; }
1842
+ catch (e_12_1) { e_12 = { error: e_12_1 }; }
1589
1843
  finally {
1590
1844
  try {
1591
1845
  if (keys_1_1 && !keys_1_1.done && (_a = keys_1.return)) _a.call(keys_1);
1592
1846
  }
1593
- finally { if (e_6) throw e_6.error; }
1847
+ finally { if (e_12) throw e_12.error; }
1594
1848
  }
1595
1849
  };
1596
1850
  /**
@@ -1673,7 +1927,7 @@ var buildView3DNode = function (token) {
1673
1927
  * match the emitted chart group (the 2-D chart is left untouched).
1674
1928
  */
1675
1929
  var applyThreeDChartType = function (chartNode, sourceChartType) {
1676
- var e_7, _a, e_8, _b, e_9, _c;
1930
+ var e_13, _a, e_14, _b, e_15, _c;
1677
1931
  var _d, _e, _f, _g, _h, _j;
1678
1932
  var token = normalizeThreeDToken(sourceChartType);
1679
1933
  if (!token || !chartNode)
@@ -1709,12 +1963,12 @@ var applyThreeDChartType = function (chartNode, sourceChartType) {
1709
1963
  }
1710
1964
  }
1711
1965
  }
1712
- catch (e_7_1) { e_7 = { error: e_7_1 }; }
1966
+ catch (e_13_1) { e_13 = { error: e_13_1 }; }
1713
1967
  finally {
1714
1968
  try {
1715
1969
  if (_m && !_m.done && (_a = _l.return)) _a.call(_l);
1716
1970
  }
1717
- finally { if (e_7) throw e_7.error; }
1971
+ finally { if (e_13) throw e_13.error; }
1718
1972
  }
1719
1973
  // Rebuild the chart node so `<c:view3D>` lands before `<c:plotArea>`.
1720
1974
  var rebuiltChart = {};
@@ -1729,12 +1983,12 @@ var applyThreeDChartType = function (chartNode, sourceChartType) {
1729
1983
  rebuiltChart[key] = value;
1730
1984
  }
1731
1985
  }
1732
- catch (e_8_1) { e_8 = { error: e_8_1 }; }
1986
+ catch (e_14_1) { e_14 = { error: e_14_1 }; }
1733
1987
  finally {
1734
1988
  try {
1735
1989
  if (_q && !_q.done && (_b = _p.return)) _b.call(_p);
1736
1990
  }
1737
- finally { if (e_8) throw e_8.error; }
1991
+ finally { if (e_14) throw e_14.error; }
1738
1992
  }
1739
1993
  try {
1740
1994
  for (var _s = __values(Object.keys(chartNode)), _t = _s.next(); !_t.done; _t = _s.next()) {
@@ -1742,12 +1996,12 @@ var applyThreeDChartType = function (chartNode, sourceChartType) {
1742
1996
  delete chartNode[key];
1743
1997
  }
1744
1998
  }
1745
- catch (e_9_1) { e_9 = { error: e_9_1 }; }
1999
+ catch (e_15_1) { e_15 = { error: e_15_1 }; }
1746
2000
  finally {
1747
2001
  try {
1748
2002
  if (_t && !_t.done && (_c = _s.return)) _c.call(_s);
1749
2003
  }
1750
- finally { if (e_9) throw e_9.error; }
2004
+ finally { if (e_15) throw e_15.error; }
1751
2005
  }
1752
2006
  Object.assign(chartNode, rebuiltChart);
1753
2007
  };
@@ -1768,11 +2022,12 @@ var DLBL_POS = {
1768
2022
  bestFit: "bestFit",
1769
2023
  };
1770
2024
  var applyChartFormatting = function (chartSpace, spec, sheetNameById) {
1771
- var _a;
2025
+ var _a, _b;
1772
2026
  var chartNode = (_a = chartSpace === null || chartSpace === void 0 ? void 0 : chartSpace["c:chartSpace"]) === null || _a === void 0 ? void 0 : _a["c:chart"];
1773
2027
  if (!chartNode)
1774
2028
  return;
1775
2029
  applyLegend(chartNode, spec === null || spec === void 0 ? void 0 : spec.legend);
2030
+ applyEmptyCellsOptions(chartNode, spec === null || spec === void 0 ? void 0 : spec.emptyCells, spec === null || spec === void 0 ? void 0 : spec.showNaAsEmpty);
1776
2031
  var plotArea = chartNode["c:plotArea"];
1777
2032
  if (!plotArea)
1778
2033
  return;
@@ -1780,8 +2035,10 @@ var applyChartFormatting = function (chartSpace, spec, sheetNameById) {
1780
2035
  applyAxisOptions(plotArea, spec === null || spec === void 0 ? void 0 : spec.valueAxisOptions, "value");
1781
2036
  applyAxisOptions(plotArea, spec === null || spec === void 0 ? void 0 : spec.categoryAxisOptions, "category");
1782
2037
  applyDoughnutHole(plotArea, spec === null || spec === void 0 ? void 0 : spec.doughnutHoleSize);
2038
+ applyExplosion(plotArea, spec === null || spec === void 0 ? void 0 : spec.explosion);
2039
+ applySliceColors(plotArea, spec);
1783
2040
  applySeriesOverlays(plotArea, spec === null || spec === void 0 ? void 0 : spec.series, sheetNameById);
1784
- applySecondaryAxis(plotArea, spec === null || spec === void 0 ? void 0 : spec.secondaryValueAxisOptions);
2041
+ applySecondaryAxisGroup(plotArea, spec, (_b = spec === null || spec === void 0 ? void 0 : spec.series) !== null && _b !== void 0 ? _b : []);
1785
2042
  };
1786
2043
  var SERIES_CONTAINER_KEYS = [
1787
2044
  "c:barChart",
@@ -1798,56 +2055,80 @@ var SERIES_CONTAINER_KEYS = [
1798
2055
  * matches the order emitted by the builder, so we index by position.
1799
2056
  */
1800
2057
  var applySeriesOverlays = function (plotArea, series, sheetNameById) {
1801
- var e_10, _a, e_11, _b;
2058
+ var e_16, _a, e_17, _b, e_18, _c;
2059
+ var _d, _e;
1802
2060
  if (!Array.isArray(series) || !series.length)
1803
2061
  return;
1804
2062
  var seriesIndex = 0;
1805
2063
  try {
1806
2064
  for (var SERIES_CONTAINER_KEYS_1 = __values(SERIES_CONTAINER_KEYS), SERIES_CONTAINER_KEYS_1_1 = SERIES_CONTAINER_KEYS_1.next(); !SERIES_CONTAINER_KEYS_1_1.done; SERIES_CONTAINER_KEYS_1_1 = SERIES_CONTAINER_KEYS_1.next()) {
1807
2065
  var key = SERIES_CONTAINER_KEYS_1_1.value;
1808
- var container = plotArea[key];
1809
- if (!container)
2066
+ var containers = plotArea[key];
2067
+ if (!containers)
1810
2068
  continue;
1811
- var ser = container["c:ser"];
1812
- if (!ser)
1813
- continue;
1814
- var list = Array.isArray(ser) ? ser : [ser];
2069
+ // A split secondary axis group is an array of containers.
2070
+ var containerList = Array.isArray(containers)
2071
+ ? containers
2072
+ : [containers];
1815
2073
  try {
1816
- for (var list_1 = (e_11 = void 0, __values(list)), list_1_1 = list_1.next(); !list_1_1.done; list_1_1 = list_1.next()) {
1817
- var node = list_1_1.value;
1818
- var data = series[seriesIndex++];
1819
- if (!data)
2074
+ for (var containerList_1 = (e_17 = void 0, __values(containerList)), containerList_1_1 = containerList_1.next(); !containerList_1_1.done; containerList_1_1 = containerList_1.next()) {
2075
+ var container = containerList_1_1.value;
2076
+ var ser = container === null || container === void 0 ? void 0 : container["c:ser"];
2077
+ if (!ser)
1820
2078
  continue;
1821
- if (Array.isArray(data.trendlines) && data.trendlines.length) {
1822
- var built = data.trendlines
1823
- .map(buildTrendlineNode)
1824
- .filter(Boolean);
1825
- // OOXML allows multiple <c:trendline> on a series; preserve the
1826
- // order from the spec.
1827
- node["c:trendline"] = built.length === 1 ? built[0] : built;
2079
+ var list = Array.isArray(ser) ? ser : [ser];
2080
+ try {
2081
+ for (var list_1 = (e_18 = void 0, __values(list)), list_1_1 = list_1.next(); !list_1_1.done; list_1_1 = list_1.next()) {
2082
+ var node = list_1_1.value;
2083
+ // A combo chart groups its series by chart type, so the emitted
2084
+ // order differs from spec.series — `<c:idx>` carries the spec
2085
+ // index; fall back to emission order for nodes without one.
2086
+ var idx = Number((_e = (_d = node === null || node === void 0 ? void 0 : node["c:idx"]) === null || _d === void 0 ? void 0 : _d.a$) === null || _e === void 0 ? void 0 : _e.val);
2087
+ var data = Number.isInteger(idx)
2088
+ ? series[idx]
2089
+ : series[seriesIndex];
2090
+ seriesIndex++;
2091
+ if (!data)
2092
+ continue;
2093
+ if (Array.isArray(data.trendlines) && data.trendlines.length) {
2094
+ var built = data.trendlines
2095
+ .map(buildTrendlineNode)
2096
+ .filter(Boolean);
2097
+ // OOXML allows multiple <c:trendline> on a series; preserve the
2098
+ // order from the spec.
2099
+ node["c:trendline"] = built.length === 1 ? built[0] : built;
2100
+ }
2101
+ if (data.errorBars) {
2102
+ var built = buildErrorBarsNode(data.errorBars, sheetNameById);
2103
+ if (built)
2104
+ node["c:errBars"] = built;
2105
+ }
2106
+ }
1828
2107
  }
1829
- if (data.errorBars) {
1830
- var built = buildErrorBarsNode(data.errorBars, sheetNameById);
1831
- if (built)
1832
- node["c:errBars"] = built;
2108
+ catch (e_18_1) { e_18 = { error: e_18_1 }; }
2109
+ finally {
2110
+ try {
2111
+ if (list_1_1 && !list_1_1.done && (_c = list_1.return)) _c.call(list_1);
2112
+ }
2113
+ finally { if (e_18) throw e_18.error; }
1833
2114
  }
1834
2115
  }
1835
2116
  }
1836
- catch (e_11_1) { e_11 = { error: e_11_1 }; }
2117
+ catch (e_17_1) { e_17 = { error: e_17_1 }; }
1837
2118
  finally {
1838
2119
  try {
1839
- if (list_1_1 && !list_1_1.done && (_b = list_1.return)) _b.call(list_1);
2120
+ if (containerList_1_1 && !containerList_1_1.done && (_b = containerList_1.return)) _b.call(containerList_1);
1840
2121
  }
1841
- finally { if (e_11) throw e_11.error; }
2122
+ finally { if (e_17) throw e_17.error; }
1842
2123
  }
1843
2124
  }
1844
2125
  }
1845
- catch (e_10_1) { e_10 = { error: e_10_1 }; }
2126
+ catch (e_16_1) { e_16 = { error: e_16_1 }; }
1846
2127
  finally {
1847
2128
  try {
1848
2129
  if (SERIES_CONTAINER_KEYS_1_1 && !SERIES_CONTAINER_KEYS_1_1.done && (_a = SERIES_CONTAINER_KEYS_1.return)) _a.call(SERIES_CONTAINER_KEYS_1);
1849
2130
  }
1850
- finally { if (e_10) throw e_10.error; }
2131
+ finally { if (e_16) throw e_16.error; }
1851
2132
  }
1852
2133
  };
1853
2134
  var buildTrendlineNode = function (t) {
@@ -1939,12 +2220,358 @@ var applySecondaryAxis = function (plotArea, opts) {
1939
2220
  "c:scaling": { "c:orientation": { a$: { val: "minMax" } } },
1940
2221
  "c:delete": { a$: { val: "0" } },
1941
2222
  "c:axPos": { a$: { val: "r" } },
2223
+ "c:numFmt": { a$: { formatCode: "General", sourceLinked: "1" } },
1942
2224
  "c:crossAx": { a$: { val: String(primaryAxId) } },
1943
2225
  };
1944
2226
  // Apply the same logarithmic / reverse / min / max / gridlines etc.
1945
2227
  applyAxisOptions({ "c:valAx": secondary }, opts, "value");
1946
2228
  plotArea["c:valAx"] = __spreadArray(__spreadArray([], __read(existingArr), false), [secondary], false);
1947
2229
  };
2230
+ /** Category-axis chart groups a series can be plotted on a secondary axis in. */
2231
+ var CATEGORY_GROUP_KEYS = ["c:barChart", "c:lineChart", "c:areaChart"];
2232
+ /** `<c:axPos>` opposite the primary axis — where Excel draws the secondary one. */
2233
+ var OPPOSITE_AX_POS = { b: "t", t: "b", l: "r", r: "l" };
2234
+ var asNodeArray = function (value) {
2235
+ return value === undefined || value === null
2236
+ ? []
2237
+ : Array.isArray(value)
2238
+ ? value
2239
+ : [value];
2240
+ };
2241
+ var axIdValueOf = function (axis) { var _a, _b; return (_b = (_a = axis === null || axis === void 0 ? void 0 : axis["c:axId"]) === null || _a === void 0 ? void 0 : _a.a$) === null || _b === void 0 ? void 0 : _b.val; };
2242
+ /**
2243
+ * Excel plots "Plot Series On: Secondary Axis" series in their own chart
2244
+ * group bound to a second `<c:catAx>` / `<c:valAx>` pair (one category axis
2245
+ * and one value axis per axis group). Move every `useSecondaryAxis` series
2246
+ * out of its primary group into a clone of that group carrying the
2247
+ * secondary axIds (so a bar-primary + line-secondary combo keeps one bar
2248
+ * group and one line group), then add the secondary axis pair: the
2249
+ * category axis sits opposite the primary and is hidden (`<c:delete
2250
+ * val="1"/>`) when it shares the primary categories, shown when the spec
2251
+ * carries its own `domains[1]`; the value axis sits opposite the primary,
2252
+ * crosses at `max`, and takes `secondaryValueAxisOptions`.
2253
+ *
2254
+ * Charts with no secondary-axis series keep the old single-group layout
2255
+ * (a bare second `<c:valAx>` for `secondaryValueAxisOptions` alone), as do
2256
+ * the 3-D and c15 (histogram / boxplot / waterfall / funnel) bodies.
2257
+ */
2258
+ var applySecondaryAxisGroup = function (plotArea, spec, series) {
2259
+ var e_19, _a, e_20, _b;
2260
+ var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
2261
+ var opts = spec === null || spec === void 0 ? void 0 : spec.secondaryValueAxisOptions;
2262
+ var secondaryIdx = new Set();
2263
+ var plottedSeries = 0;
2264
+ (series !== null && series !== void 0 ? series : []).forEach(function (entry, index) {
2265
+ if (!entry)
2266
+ return;
2267
+ plottedSeries += 1;
2268
+ if (entry.useSecondaryAxis)
2269
+ secondaryIdx.add(String(index));
2270
+ });
2271
+ var groupKeys = CATEGORY_GROUP_KEYS.filter(function (key) { return plotArea === null || plotArea === void 0 ? void 0 : plotArea[key]; });
2272
+ var catAxes = asNodeArray(plotArea === null || plotArea === void 0 ? void 0 : plotArea["c:catAx"]);
2273
+ var valAxes = asNodeArray(plotArea === null || plotArea === void 0 ? void 0 : plotArea["c:valAx"]);
2274
+ if (!secondaryIdx.size ||
2275
+ secondaryIdx.size >= plottedSeries ||
2276
+ !groupKeys.length ||
2277
+ plotArea["mc:AlternateContent"] ||
2278
+ normalizeThreeDToken(spec === null || spec === void 0 ? void 0 : spec.sourceChartType) ||
2279
+ catAxes.length !== 1 ||
2280
+ valAxes.length !== 1) {
2281
+ applySecondaryAxis(plotArea, opts);
2282
+ return;
2283
+ }
2284
+ var primaryCat = catAxes[0];
2285
+ var primaryVal = valAxes[0];
2286
+ var catAxId = parseInt((_c = axIdValueOf(primaryCat)) !== null && _c !== void 0 ? _c : "47003664", 10);
2287
+ var valAxId = parseInt((_d = axIdValueOf(primaryVal)) !== null && _d !== void 0 ? _d : "1789284464", 10);
2288
+ var secondaryCatAxId = String(catAxId + 100);
2289
+ var secondaryValAxId = String(valAxId + 100);
2290
+ var secondaryAxIds = [
2291
+ { a$: { val: secondaryCatAxId } },
2292
+ { a$: { val: secondaryValAxId } },
2293
+ ];
2294
+ var moved = false;
2295
+ try {
2296
+ for (var groupKeys_1 = __values(groupKeys), groupKeys_1_1 = groupKeys_1.next(); !groupKeys_1_1.done; groupKeys_1_1 = groupKeys_1.next()) {
2297
+ var key = groupKeys_1_1.value;
2298
+ var primaries = [];
2299
+ var secondaries = [];
2300
+ try {
2301
+ for (var _p = (e_20 = void 0, __values(asNodeArray(plotArea[key]))), _q = _p.next(); !_q.done; _q = _p.next()) {
2302
+ var container = _q.value;
2303
+ var sers = asNodeArray(container["c:ser"]);
2304
+ var keep = sers.filter(function (node) { var _a, _b; return !secondaryIdx.has(String((_b = (_a = node === null || node === void 0 ? void 0 : node["c:idx"]) === null || _a === void 0 ? void 0 : _a.a$) === null || _b === void 0 ? void 0 : _b.val)); });
2305
+ var move = sers.filter(function (node) { var _a, _b; return secondaryIdx.has(String((_b = (_a = node === null || node === void 0 ? void 0 : node["c:idx"]) === null || _a === void 0 ? void 0 : _a.a$) === null || _b === void 0 ? void 0 : _b.val)); });
2306
+ if (!move.length) {
2307
+ primaries.push(container);
2308
+ continue;
2309
+ }
2310
+ moved = true;
2311
+ if (keep.length)
2312
+ primaries.push(__assign(__assign({}, container), { "c:ser": keep }));
2313
+ // Same group shape (grouping, gapWidth, dLbls, …) — only the series
2314
+ // and the axis binding differ.
2315
+ var secondary = cloneTemplate(container);
2316
+ secondary["c:ser"] = move;
2317
+ secondary["c:axId"] = secondaryAxIds;
2318
+ secondaries.push(secondary);
2319
+ }
2320
+ }
2321
+ catch (e_20_1) { e_20 = { error: e_20_1 }; }
2322
+ finally {
2323
+ try {
2324
+ if (_q && !_q.done && (_b = _p.return)) _b.call(_p);
2325
+ }
2326
+ finally { if (e_20) throw e_20.error; }
2327
+ }
2328
+ var groups = __spreadArray(__spreadArray([], __read(primaries), false), __read(secondaries), false);
2329
+ plotArea[key] = groups.length === 1 ? groups[0] : groups;
2330
+ }
2331
+ }
2332
+ catch (e_19_1) { e_19 = { error: e_19_1 }; }
2333
+ finally {
2334
+ try {
2335
+ if (groupKeys_1_1 && !groupKeys_1_1.done && (_a = groupKeys_1.return)) _a.call(groupKeys_1);
2336
+ }
2337
+ finally { if (e_19) throw e_19.error; }
2338
+ }
2339
+ if (!moved) {
2340
+ applySecondaryAxis(plotArea, opts);
2341
+ return;
2342
+ }
2343
+ // Secondary category axis — opposite the primary; hidden unless the
2344
+ // secondary group has its own category list (domains[1]).
2345
+ var hasSecondaryDomain = Boolean((_g = (_f = (_e = spec === null || spec === void 0 ? void 0 : spec.domains) === null || _e === void 0 ? void 0 : _e[1]) === null || _f === void 0 ? void 0 : _f.sources) === null || _g === void 0 ? void 0 : _g.length);
2346
+ var catAx2 = cloneTemplate(column_json["c:plotArea"]["c:catAx"]);
2347
+ catAx2["c:axId"] = { a$: { val: secondaryCatAxId } };
2348
+ catAx2["c:delete"] = { a$: { val: hasSecondaryDomain ? "0" : "1" } };
2349
+ catAx2["c:axPos"] = {
2350
+ a$: { val: (_k = OPPOSITE_AX_POS[(_j = (_h = primaryCat === null || primaryCat === void 0 ? void 0 : primaryCat["c:axPos"]) === null || _h === void 0 ? void 0 : _h.a$) === null || _j === void 0 ? void 0 : _j.val]) !== null && _k !== void 0 ? _k : "t" },
2351
+ };
2352
+ catAx2["c:crossAx"] = { a$: { val: secondaryValAxId } };
2353
+ catAx2["c:crosses"] = { a$: { val: "autoZero" } };
2354
+ // Secondary value axis — opposite the primary, crossing at max, no
2355
+ // gridlines (Excel's default for a secondary axis).
2356
+ var valAx2 = cloneTemplate(column_json["c:plotArea"]["c:valAx"]);
2357
+ valAx2["c:axId"] = { a$: { val: secondaryValAxId } };
2358
+ valAx2["c:delete"] = { a$: { val: "0" } };
2359
+ valAx2["c:axPos"] = {
2360
+ a$: { val: (_o = OPPOSITE_AX_POS[(_m = (_l = primaryVal === null || primaryVal === void 0 ? void 0 : primaryVal["c:axPos"]) === null || _l === void 0 ? void 0 : _l.a$) === null || _m === void 0 ? void 0 : _m.val]) !== null && _o !== void 0 ? _o : "r" },
2361
+ };
2362
+ removeProp(valAx2, "c:majorGridlines");
2363
+ valAx2["c:crossAx"] = { a$: { val: secondaryCatAxId } };
2364
+ valAx2["c:crosses"] = { a$: { val: "max" } };
2365
+ applyAxisOptions({ "c:valAx": valAx2 }, opts, "value");
2366
+ plotArea["c:catAx"] = [primaryCat, catAx2];
2367
+ plotArea["c:valAx"] = [primaryVal, valAx2];
2368
+ };
2369
+ var PIVOT_OPTIONS_EXT_URI = "{781A3756-C4B2-4CAC-9D66-4F8BD8637D16}";
2370
+ var C14_NS = "http://schemas.microsoft.com/office/drawing/2007/8/2/chart";
2371
+ /**
2372
+ * PivotChart binding — `<c:pivotSource>` (name + fmtId) at the chartSpace
2373
+ * root so Excel keeps the chart on the pivot cache, `<c:pivotFmts>` inside
2374
+ * `<c:chart>` and the c14 `<c14:pivotOptions>` field-button choices in the
2375
+ * chartSpace `<c:extLst>`. All three only for a chart bound to an exported
2376
+ * pivot; a chart whose pivot is missing exports as a plain chart, which is
2377
+ * what Excel does when a PivotChart loses its pivot.
2378
+ */
2379
+ var applyPivotChartBinding = function (chartSpace, spec, resolvePivotSourceName) {
2380
+ var _a, _b, _c, _d, _e;
2381
+ var pivotTableId = spec.pivotTableId;
2382
+ if (pivotTableId == null || !resolvePivotSourceName)
2383
+ return;
2384
+ var name = resolvePivotSourceName(pivotTableId);
2385
+ if (!name)
2386
+ return;
2387
+ var root = chartSpace["c:chartSpace"];
2388
+ setChildInOrder(root, "c:pivotSource", {
2389
+ "c:name": name,
2390
+ "c:fmtId": { a$: { val: String((_b = (_a = spec.pivotSource) === null || _a === void 0 ? void 0 : _a.formatId) !== null && _b !== void 0 ? _b : 0) } },
2391
+ }, ["c:protection", "c:chart"]);
2392
+ var formats = (_c = spec.pivotFormats) !== null && _c !== void 0 ? _c : [];
2393
+ if (formats.length) {
2394
+ setChildInOrder(root["c:chart"], "c:pivotFmts", {
2395
+ "c:pivotFmt": formats.map(function (format) {
2396
+ var _a;
2397
+ var idx = { "c:idx": { a$: { val: String(format.index) } } };
2398
+ // A verbatim body (C-83) carries its own <c:spPr>; the fill-only
2399
+ // form is for formats authored in-app.
2400
+ if ((_a = format.body) === null || _a === void 0 ? void 0 : _a.length) {
2401
+ return __assign(__assign({}, idx), chartXmlElementsToBuilderObject(format.body));
2402
+ }
2403
+ var hex = toHex(format.color);
2404
+ return __assign(__assign({}, idx), (hex
2405
+ ? { "c:spPr": { "a:solidFill": { "a:srgbClr": { a$: { val: hex } } } } }
2406
+ : {}));
2407
+ }),
2408
+ }, ["c:view3D", "c:floor", "c:sideWall", "c:backWall", "c:plotArea"]);
2409
+ }
2410
+ var buttons = (_d = spec.pivotFieldButtons) !== null && _d !== void 0 ? _d : {};
2411
+ var flag = function (shown) { return ({
2412
+ a$: { val: shown === false ? "0" : "1" },
2413
+ }); };
2414
+ var existing = (_e = root["c:extLst"]) === null || _e === void 0 ? void 0 : _e["c:ext"];
2415
+ var exts = Array.isArray(existing) ? existing : existing ? [existing] : [];
2416
+ root["c:extLst"] = {
2417
+ "c:ext": __spreadArray(__spreadArray([], __read(exts), false), [
2418
+ {
2419
+ a$: { uri: PIVOT_OPTIONS_EXT_URI, "xmlns:c14": C14_NS },
2420
+ "c14:pivotOptions": {
2421
+ "c14:dropZoneFilter": flag(buttons.reportFilter),
2422
+ "c14:dropZoneCategories": flag(buttons.axis),
2423
+ "c14:dropZoneData": flag(buttons.value),
2424
+ "c14:dropZoneSeries": flag(buttons.legend),
2425
+ "c14:dropZonesVisible": flag(buttons.visible),
2426
+ },
2427
+ },
2428
+ ], false),
2429
+ };
2430
+ };
2431
+ /** Prefixes the chartSpace root declares; any other prefix is declared on the element that uses it. */
2432
+ var ROOT_CHART_PREFIXES = new Set(["c", "a", "r"]);
2433
+ var CHART_XML_PREFIX_URIS = {
2434
+ mc: "http://schemas.openxmlformats.org/markup-compatibility/2006",
2435
+ c14: "http://schemas.microsoft.com/office/drawing/2007/8/2/chart",
2436
+ c15: "http://schemas.microsoft.com/office/drawing/2012/chart",
2437
+ c16: "http://schemas.microsoft.com/office/drawing/2014/chart",
2438
+ c16r2: "http://schemas.microsoft.com/office/drawing/2015/06/chart",
2439
+ c16r3: "http://schemas.microsoft.com/office/drawing/2017/03/chart",
2440
+ a14: "http://schemas.microsoft.com/office/drawing/2010/main",
2441
+ a16: "http://schemas.microsoft.com/office/drawing/2014/main",
2442
+ };
2443
+ /**
2444
+ * Verbatim `ChartXmlElement`s → the XMLBuilder object shape (`a$` attributes,
2445
+ * `t$` text), keys in document order; same-named siblings group into an array.
2446
+ * An extension prefix the root does not declare is declared on the first
2447
+ * element that uses it (`declared` tracks the ancestors' declarations).
2448
+ */
2449
+ var chartXmlElementsToBuilderObject = function (elements, declared) {
2450
+ var e_21, _a;
2451
+ var _b, _c;
2452
+ if (declared === void 0) { declared = ROOT_CHART_PREFIXES; }
2453
+ var out = {};
2454
+ try {
2455
+ for (var elements_1 = __values(elements), elements_1_1 = elements_1.next(); !elements_1_1.done; elements_1_1 = elements_1.next()) {
2456
+ var element = elements_1_1.value;
2457
+ var prefix = element.tag.includes(":") ? element.tag.slice(0, element.tag.indexOf(":")) : "";
2458
+ var scope = new Set(declared);
2459
+ var attributes = __assign({}, ((_b = element.attributes) !== null && _b !== void 0 ? _b : {}));
2460
+ if (prefix && !scope.has(prefix) && CHART_XML_PREFIX_URIS[prefix]) {
2461
+ attributes["xmlns:".concat(prefix)] = CHART_XML_PREFIX_URIS[prefix];
2462
+ scope.add(prefix);
2463
+ }
2464
+ var node = {};
2465
+ if (Object.keys(attributes).length)
2466
+ node.a$ = attributes;
2467
+ if ((_c = element.children) === null || _c === void 0 ? void 0 : _c.length) {
2468
+ Object.assign(node, chartXmlElementsToBuilderObject(element.children, scope));
2469
+ }
2470
+ else if (element.text != null) {
2471
+ node.t$ = element.text;
2472
+ }
2473
+ var existing = out[element.tag];
2474
+ if (existing === undefined)
2475
+ out[element.tag] = node;
2476
+ else if (Array.isArray(existing))
2477
+ existing.push(node);
2478
+ else
2479
+ out[element.tag] = [existing, node];
2480
+ }
2481
+ }
2482
+ catch (e_21_1) { e_21 = { error: e_21_1 }; }
2483
+ finally {
2484
+ try {
2485
+ if (elements_1_1 && !elements_1_1.done && (_a = elements_1.return)) _a.call(elements_1);
2486
+ }
2487
+ finally { if (e_21) throw e_21.error; }
2488
+ }
2489
+ return out;
2490
+ };
2491
+ /** `emptyCells` → `<c:dispBlanksAs val>`. */
2492
+ var DISP_BLANKS_AS = {
2493
+ gaps: "gap",
2494
+ zero: "zero",
2495
+ connect: "span",
2496
+ };
2497
+ /**
2498
+ * Set `key` on `node` keeping the schema order: an existing key is
2499
+ * overwritten in place, a new one is inserted ahead of the first of
2500
+ * `beforeKeys` that is present (else appended).
2501
+ */
2502
+ var setChildInOrder = function (node, key, value, beforeKeys) {
2503
+ var e_22, _a, e_23, _b;
2504
+ if (key in node) {
2505
+ node[key] = value;
2506
+ return;
2507
+ }
2508
+ var entries = Object.entries(node);
2509
+ var at = entries.findIndex(function (_a) {
2510
+ var _b = __read(_a, 1), k = _b[0];
2511
+ return beforeKeys.includes(k);
2512
+ });
2513
+ if (at === -1) {
2514
+ node[key] = value;
2515
+ return;
2516
+ }
2517
+ entries.splice(at, 0, [key, value]);
2518
+ try {
2519
+ for (var _c = __values(Object.keys(node)), _d = _c.next(); !_d.done; _d = _c.next()) {
2520
+ var k = _d.value;
2521
+ delete node[k];
2522
+ }
2523
+ }
2524
+ catch (e_22_1) { e_22 = { error: e_22_1 }; }
2525
+ finally {
2526
+ try {
2527
+ if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
2528
+ }
2529
+ finally { if (e_22) throw e_22.error; }
2530
+ }
2531
+ try {
2532
+ for (var entries_1 = __values(entries), entries_1_1 = entries_1.next(); !entries_1_1.done; entries_1_1 = entries_1.next()) {
2533
+ var _e = __read(entries_1_1.value, 2), k = _e[0], v = _e[1];
2534
+ node[k] = v;
2535
+ }
2536
+ }
2537
+ catch (e_23_1) { e_23 = { error: e_23_1 }; }
2538
+ finally {
2539
+ try {
2540
+ if (entries_1_1 && !entries_1_1.done && (_b = entries_1.return)) _b.call(entries_1);
2541
+ }
2542
+ finally { if (e_23) throw e_23.error; }
2543
+ }
2544
+ };
2545
+ /**
2546
+ * Excel's "Hidden and Empty Cells" dialog: `<c:dispBlanksAs>` (gap /
2547
+ * zero / span) and the 2017 `<c16r3:dispNaAsBlank>` extension for "Show
2548
+ * #N/A as an empty cell". Both only when authored, so a file imported
2549
+ * without them round-trips unchanged.
2550
+ */
2551
+ var applyEmptyCellsOptions = function (chartNode, emptyCells, showNaAsEmpty) {
2552
+ var _a;
2553
+ var dispBlanksAs = emptyCells ? DISP_BLANKS_AS[emptyCells] : undefined;
2554
+ if (dispBlanksAs) {
2555
+ setChildInOrder(chartNode, "c:dispBlanksAs", { a$: { val: dispBlanksAs } }, ["c:showDLblsOverMax", "c:extLst"]);
2556
+ }
2557
+ if (typeof showNaAsEmpty === "boolean") {
2558
+ var existing = (_a = chartNode["c:extLst"]) === null || _a === void 0 ? void 0 : _a["c:ext"];
2559
+ var exts = Array.isArray(existing) ? existing : existing ? [existing] : [];
2560
+ chartNode["c:extLst"] = {
2561
+ "c:ext": __spreadArray(__spreadArray([], __read(exts), false), [
2562
+ {
2563
+ a$: {
2564
+ uri: "{56B9EC1D-385E-4148-901F-78D8002777C0}",
2565
+ "xmlns:c16r3": "http://schemas.microsoft.com/office/drawing/2017/03/chart",
2566
+ },
2567
+ "c16r3:dataDisplayOptions16": {
2568
+ "c16r3:dispNaAsBlank": { a$: { val: showNaAsEmpty ? "1" : "0" } },
2569
+ },
2570
+ },
2571
+ ], false),
2572
+ };
2573
+ }
2574
+ };
1948
2575
  var applyLegend = function (chartNode, legend) {
1949
2576
  var _a;
1950
2577
  if (!legend)
@@ -1972,20 +2599,24 @@ var applyLegend = function (chartNode, legend) {
1972
2599
  chartNode["c:legend"] = __assign({ "c:legendPos": { a$: { val: posCode } }, "c:overlay": { a$: { val: "0" } } }, (txPr ? { "c:txPr": txPr } : {}));
1973
2600
  };
1974
2601
  var applyDataLabels = function (plotArea, dataLabels) {
2602
+ var e_24, _a;
1975
2603
  if (!(dataLabels === null || dataLabels === void 0 ? void 0 : dataLabels.show))
1976
2604
  return;
1977
2605
  // Find the chart-type container inside <c:plotArea>. We attach <c:dLbls>
1978
2606
  // to whichever exists.
1979
- var containerKey = [
2607
+ // Chart-level labels apply to every chart group — a combo chart has
2608
+ // one per series type.
2609
+ var containers = [
1980
2610
  "c:barChart",
1981
2611
  "c:lineChart",
1982
2612
  "c:pieChart",
1983
2613
  "c:doughnutChart",
1984
2614
  "c:areaChart",
1985
- ].find(function (k) { return plotArea[k]; });
1986
- if (!containerKey)
2615
+ ]
2616
+ .flatMap(function (k) { return (Array.isArray(plotArea[k]) ? plotArea[k] : [plotArea[k]]); })
2617
+ .filter(Boolean);
2618
+ if (!containers.length)
1987
2619
  return;
1988
- var container = plotArea[containerKey];
1989
2620
  var posCode = dataLabels.position && DLBL_POS[dataLabels.position];
1990
2621
  var dLbls = {};
1991
2622
  if (posCode)
@@ -2023,7 +2654,19 @@ var applyDataLabels = function (plotArea, dataLabels) {
2023
2654
  a$: { val: dataLabels.showPercent ? "1" : "0" },
2024
2655
  };
2025
2656
  dLbls["c:showBubbleSize"] = { a$: { val: "0" } };
2026
- container["c:dLbls"] = dLbls;
2657
+ try {
2658
+ for (var containers_1 = __values(containers), containers_1_1 = containers_1.next(); !containers_1_1.done; containers_1_1 = containers_1.next()) {
2659
+ var container = containers_1_1.value;
2660
+ container["c:dLbls"] = cloneTemplate(dLbls);
2661
+ }
2662
+ }
2663
+ catch (e_24_1) { e_24 = { error: e_24_1 }; }
2664
+ finally {
2665
+ try {
2666
+ if (containers_1_1 && !containers_1_1.done && (_a = containers_1.return)) _a.call(containers_1);
2667
+ }
2668
+ finally { if (e_24) throw e_24.error; }
2669
+ }
2027
2670
  };
2028
2671
  var applyAxisOptions = function (plotArea, options, kind) {
2029
2672
  var _a;
@@ -2058,6 +2701,13 @@ var applyAxisOptions = function (plotArea, options, kind) {
2058
2701
  if (options.showMajorGridlines === false && node["c:majorGridlines"]) {
2059
2702
  delete node["c:majorGridlines"];
2060
2703
  }
2704
+ // <c:numFmt sourceLinked="0"> — an explicit tick-label format. Without
2705
+ // one the axis stays "Linked to source" (the template's General/1).
2706
+ if (options.numberFormatPattern) {
2707
+ node["c:numFmt"] = {
2708
+ a$: { formatCode: options.numberFormatPattern, sourceLinked: "0" },
2709
+ };
2710
+ }
2061
2711
  // <c:txPr> — axis tick-label color/font. Without this, exported
2062
2712
  // axes would render with the default theme color instead of the
2063
2713
  // authored one (BEP.xlsx axis colors #14325A / #F0621C).
@@ -2065,6 +2715,139 @@ var applyAxisOptions = function (plotArea, options, kind) {
2065
2715
  if (txPr)
2066
2716
  node["c:txPr"] = txPr;
2067
2717
  };
2718
+ /**
2719
+ * Exploded pie / doughnut — `<c:explosion val="…"/>` on every slice series.
2720
+ * CT_PieSer order: idx, order, tx, spPr, explosion, dPt, dLbls, cat, val.
2721
+ */
2722
+ var PIE_SER_KEYS_BEFORE_EXPLOSION = new Set([
2723
+ "c:idx",
2724
+ "c:order",
2725
+ "c:tx",
2726
+ "c:spPr",
2727
+ ]);
2728
+ var applyExplosion = function (plotArea, explosion) {
2729
+ var _a;
2730
+ if (typeof explosion !== "number" || !(explosion > 0))
2731
+ return;
2732
+ var group = (_a = plotArea === null || plotArea === void 0 ? void 0 : plotArea["c:pieChart"]) !== null && _a !== void 0 ? _a : plotArea === null || plotArea === void 0 ? void 0 : plotArea["c:doughnutChart"];
2733
+ if (!group)
2734
+ return;
2735
+ var sers = Array.isArray(group["c:ser"])
2736
+ ? group["c:ser"]
2737
+ : group["c:ser"]
2738
+ ? [group["c:ser"]]
2739
+ : [];
2740
+ var explosionNode = { a$: { val: String(Math.round(explosion)) } };
2741
+ var rebuiltSers = sers.map(function (ser) {
2742
+ var e_25, _a;
2743
+ var rebuilt = {};
2744
+ var placed = false;
2745
+ try {
2746
+ for (var _b = __values(Object.entries(ser)), _c = _b.next(); !_c.done; _c = _b.next()) {
2747
+ var _d = __read(_c.value, 2), key = _d[0], value = _d[1];
2748
+ if (key === "c:explosion")
2749
+ continue;
2750
+ if (!placed && !PIE_SER_KEYS_BEFORE_EXPLOSION.has(key)) {
2751
+ rebuilt["c:explosion"] = explosionNode;
2752
+ placed = true;
2753
+ }
2754
+ rebuilt[key] = value;
2755
+ }
2756
+ }
2757
+ catch (e_25_1) { e_25 = { error: e_25_1 }; }
2758
+ finally {
2759
+ try {
2760
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
2761
+ }
2762
+ finally { if (e_25) throw e_25.error; }
2763
+ }
2764
+ if (!placed)
2765
+ rebuilt["c:explosion"] = explosionNode;
2766
+ return rebuilt;
2767
+ });
2768
+ group["c:ser"] = Array.isArray(group["c:ser"]) ? rebuiltSers : rebuiltSers[0];
2769
+ };
2770
+ var isCircularChartType = function (chartType) {
2771
+ return chartType === "pie" || chartType === "doughnut";
2772
+ };
2773
+ /** How many points a series' first source range holds (a column or a row of cells). */
2774
+ var sourcePointCount = function (source) {
2775
+ if (!source)
2776
+ return 0;
2777
+ var rows = source.endRowIndex - source.startRowIndex + 1;
2778
+ var cols = source.endColumnIndex - source.startColumnIndex + 1;
2779
+ return Math.max(0, rows > 1 ? rows : cols);
2780
+ };
2781
+ /**
2782
+ * Per-slice colours of a pie / doughnut — the renderer paints each slice
2783
+ * from `dataPointColors` when authored, else from the palette cycle
2784
+ * (`spec.palette`, else the theme accents Excel's `<c:varyColors>` also
2785
+ * cycles). Excel keeps a slice's own colour only as a `<c:dPt>`, so every
2786
+ * slice series gets one per point: authored overrides first, else the
2787
+ * palette colour of each slice index (nothing when the theme cycle is
2788
+ * in effect — `<c:varyColors val="1"/>` reproduces it). Replaces the
2789
+ * template's placeholder `<c:dPt>` and keeps CT_PieSer order (dPt after
2790
+ * spPr / explosion, before dLbls / cat / val).
2791
+ */
2792
+ var PIE_SER_KEYS_BEFORE_DPT = new Set([
2793
+ "c:idx",
2794
+ "c:order",
2795
+ "c:tx",
2796
+ "c:spPr",
2797
+ "c:explosion",
2798
+ ]);
2799
+ var applySliceColors = function (plotArea, spec) {
2800
+ var _a, _b;
2801
+ if (!isCircularChartType(spec === null || spec === void 0 ? void 0 : spec.chartType))
2802
+ return;
2803
+ var group = (_a = plotArea === null || plotArea === void 0 ? void 0 : plotArea["c:pieChart"]) !== null && _a !== void 0 ? _a : plotArea === null || plotArea === void 0 ? void 0 : plotArea["c:doughnutChart"];
2804
+ if (!group)
2805
+ return;
2806
+ var sers = Array.isArray(group["c:ser"])
2807
+ ? group["c:ser"]
2808
+ : group["c:ser"]
2809
+ ? [group["c:ser"]]
2810
+ : [];
2811
+ var palette = spec === null || spec === void 0 ? void 0 : spec.palette;
2812
+ var series = ((_b = spec === null || spec === void 0 ? void 0 : spec.series) !== null && _b !== void 0 ? _b : []);
2813
+ var rebuiltSers = sers.map(function (ser, index) {
2814
+ var e_26, _a;
2815
+ var _b;
2816
+ var entry = series[index];
2817
+ var authored = entry === null || entry === void 0 ? void 0 : entry.dataPointColors;
2818
+ var pointColors = (authored === null || authored === void 0 ? void 0 : authored.length)
2819
+ ? authored
2820
+ : (palette === null || palette === void 0 ? void 0 : palette.length)
2821
+ ? Array.from({ length: sourcePointCount((_b = entry === null || entry === void 0 ? void 0 : entry.sources) === null || _b === void 0 ? void 0 : _b[0]) }, function (_, idx) { return ({ idx: idx, color: palette[idx % palette.length] }); })
2822
+ : undefined;
2823
+ var dPtNodes = buildDataPointNodes(pointColors);
2824
+ var rebuilt = {};
2825
+ var placed = false;
2826
+ try {
2827
+ for (var _c = __values(Object.entries(ser)), _d = _c.next(); !_d.done; _d = _c.next()) {
2828
+ var _e = __read(_d.value, 2), key = _e[0], value = _e[1];
2829
+ if (key === "c:dPt")
2830
+ continue;
2831
+ if (dPtNodes && !placed && !PIE_SER_KEYS_BEFORE_DPT.has(key)) {
2832
+ rebuilt["c:dPt"] = dPtNodes;
2833
+ placed = true;
2834
+ }
2835
+ rebuilt[key] = value;
2836
+ }
2837
+ }
2838
+ catch (e_26_1) { e_26 = { error: e_26_1 }; }
2839
+ finally {
2840
+ try {
2841
+ if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
2842
+ }
2843
+ finally { if (e_26) throw e_26.error; }
2844
+ }
2845
+ if (dPtNodes && !placed)
2846
+ rebuilt["c:dPt"] = dPtNodes;
2847
+ return rebuilt;
2848
+ });
2849
+ group["c:ser"] = Array.isArray(group["c:ser"]) ? rebuiltSers : rebuiltSers[0];
2850
+ };
2068
2851
  var applyDoughnutHole = function (plotArea, holeSize) {
2069
2852
  if (typeof holeSize !== "number")
2070
2853
  return;