ooxml-core 1.15.0 → 1.16.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 (102) hide show
  1. package/dist/PptxHandler-3A7VEXVK.cjs +13 -0
  2. package/dist/PptxHandler-7POULDRL.mjs +4 -0
  3. package/dist/{PptxHandler-R5BVKEBW.mjs → PptxHandler-M35YFCUC.mjs} +2 -2
  4. package/dist/PresentationBuilder-C7NPM7OQ.mjs +4 -0
  5. package/dist/{PresentationBuilder-4AF3PZHG.cjs → PresentationBuilder-XVRTITYR.cjs} +6 -5
  6. package/dist/{PresentationBuilder-W67DIJBV.mjs → PresentationBuilder-Y6DJK6H2.mjs} +2 -2
  7. package/dist/automation/index.cjs +935 -535
  8. package/dist/automation/index.mjs +935 -535
  9. package/dist/chunk-5W2QL4SB.cjs +244 -0
  10. package/dist/{chunk-ZWI7MTLF.cjs → chunk-AHRFBMLK.cjs} +2846 -1546
  11. package/dist/{chunk-NWAQEXBK.mjs → chunk-B37EVUMG.mjs} +1 -1
  12. package/dist/{chunk-HU36GIYM.mjs → chunk-C2Y6SZDN.mjs} +421 -129
  13. package/dist/chunk-CA7KCNL3.mjs +236 -0
  14. package/dist/{chunk-BSUIDT6K.cjs → chunk-DWRJ62KP.cjs} +1 -0
  15. package/dist/{chunk-OPBZBSJF.mjs → chunk-KOX5Y5E5.mjs} +1 -1
  16. package/dist/{chunk-JFMIPOPV.mjs → chunk-LM6VBPQJ.mjs} +416 -15
  17. package/dist/{chunk-PC4MTLG4.cjs → chunk-OA5V3JJC.cjs} +8 -8
  18. package/dist/{chunk-7ZIZFJXT.mjs → chunk-OKGQ2X7D.mjs} +1848 -548
  19. package/dist/{chunk-X7MGZQ6C.cjs → chunk-UGWY72WC.cjs} +396 -254
  20. package/dist/{chunk-EMZIHAOH.mjs → chunk-WBCV52YV.mjs} +1846 -565
  21. package/dist/{chunk-2EBMHIGJ.mjs → chunk-WEFFRYXN.mjs} +379 -242
  22. package/dist/{chunk-AXF2FC4D.mjs → chunk-WSRCLCMB.mjs} +1 -0
  23. package/dist/{chunk-LMMP67YN.mjs → chunk-XCJRUBGJ.mjs} +1 -1
  24. package/dist/pptx/automation/index.cjs +2662 -884
  25. package/dist/pptx/automation/index.d.ts +4 -4
  26. package/dist/pptx/automation/index.mjs +5 -5
  27. package/dist/pptx/chunks/{elements-Cadkqht8.d.ts → elements-iUzpAeqR.d.ts} +114 -25
  28. package/dist/pptx/chunks/elements-iUzpAeqR.d.ts.map +1 -0
  29. package/dist/pptx/chunks/{index-CJI2EugA.d.ts → index-BWHNCVNC.d.ts} +1671 -1534
  30. package/dist/pptx/chunks/index-BWHNCVNC.d.ts.map +1 -0
  31. package/dist/pptx/chunks/{index-CozqpSPL.d.ts → index-CiyTR6mm.d.ts} +99 -10
  32. package/dist/pptx/chunks/index-CiyTR6mm.d.ts.map +1 -0
  33. package/dist/pptx/chunks/{text-operations-C3L9xrqx.d.ts → text-operations-CfLVZ7DK.d.ts} +81 -3
  34. package/dist/pptx/chunks/text-operations-CfLVZ7DK.d.ts.map +1 -0
  35. package/dist/pptx/cli/index.cjs +2652 -874
  36. package/dist/pptx/cli/index.d.ts +1 -1
  37. package/dist/pptx/cli/index.mjs +4 -4
  38. package/dist/pptx/converter/index.cjs +45 -1
  39. package/dist/pptx/converter/index.d.ts +1 -1
  40. package/dist/pptx/converter/index.mjs +2 -2
  41. package/dist/pptx/editor/render/collaboration-live-patch-target.cjs +4 -4
  42. package/dist/pptx/editor/render/collaboration-live-patch-target.mjs +2 -2
  43. package/dist/pptx/editor/render/collaboration-reconcile.cjs +7 -7
  44. package/dist/pptx/editor/render/collaboration-reconcile.mjs +2 -2
  45. package/dist/pptx/editor/render/collaboration-sync.cjs +14 -14
  46. package/dist/pptx/editor/render/collaboration-sync.d.ts.map +1 -1
  47. package/dist/pptx/editor/render/collaboration-sync.mjs +1 -1
  48. package/dist/pptx/editor/render/find-replace.cjs +15 -14
  49. package/dist/pptx/editor/render/find-replace.d.ts +2 -2
  50. package/dist/pptx/editor/render/find-replace.mjs +2 -1
  51. package/dist/pptx/editor/render/slide-operations.cjs +9 -8
  52. package/dist/pptx/editor/render/slide-operations.mjs +3 -2
  53. package/dist/pptx/editor/render/slide-size-rescale.cjs +3 -3
  54. package/dist/pptx/editor/render/slide-size-rescale.d.ts +1 -1
  55. package/dist/pptx/editor/render/slide-size-rescale.d.ts.map +1 -1
  56. package/dist/pptx/editor/render/slide-size-rescale.mjs +3 -3
  57. package/dist/pptx/editor/render/text-runs-style-patch.d.ts +1 -1
  58. package/dist/pptx/editor/render/text-style-scope.d.ts +1 -1
  59. package/dist/pptx/index.cjs +3208 -1106
  60. package/dist/pptx/index.d.ts +5 -5
  61. package/dist/pptx/index.mjs +5 -5
  62. package/dist/teams/index.cjs +156 -65
  63. package/dist/teams/index.mjs +156 -65
  64. package/dist/xlsx/edit/pivots.d.ts.map +1 -1
  65. package/dist/xlsx/index.cjs +867 -467
  66. package/dist/xlsx/index.mjs +867 -467
  67. package/dist/xlsx/load/index.cjs +345 -99
  68. package/dist/xlsx/load/index.mjs +345 -99
  69. package/dist/xlsx/model-pivots.d.ts +47 -0
  70. package/dist/xlsx/model-pivots.d.ts.map +1 -1
  71. package/dist/xlsx/pivot/captions-locales.d.ts +3 -0
  72. package/dist/xlsx/pivot/captions-locales.d.ts.map +1 -0
  73. package/dist/xlsx/pivot/captions-read.d.ts +14 -0
  74. package/dist/xlsx/pivot/captions-read.d.ts.map +1 -0
  75. package/dist/xlsx/pivot/captions.d.ts +26 -0
  76. package/dist/xlsx/pivot/captions.d.ts.map +1 -0
  77. package/dist/xlsx/pivot/columns.d.ts.map +1 -1
  78. package/dist/xlsx/pivot/data.d.ts +3 -2
  79. package/dist/xlsx/pivot/data.d.ts.map +1 -1
  80. package/dist/xlsx/pivot/item-labels.d.ts +12 -0
  81. package/dist/xlsx/pivot/item-labels.d.ts.map +1 -0
  82. package/dist/xlsx/pivot/item-names-read.d.ts +8 -0
  83. package/dist/xlsx/pivot/item-names-read.d.ts.map +1 -0
  84. package/dist/xlsx/pivot/measures.d.ts +2 -1
  85. package/dist/xlsx/pivot/measures.d.ts.map +1 -1
  86. package/dist/xlsx/pivot/nested.d.ts.map +1 -1
  87. package/dist/xlsx/pivot/page-filter-admission.d.ts.map +1 -1
  88. package/dist/xlsx/pivot/page-filter.d.ts +1 -1
  89. package/dist/xlsx/pivot/page-filter.d.ts.map +1 -1
  90. package/dist/xlsx/pivot/read.d.ts.map +1 -1
  91. package/dist/xlsx/pivot/table-xml.d.ts.map +1 -1
  92. package/dist/xlsx/ui/commands/i18n/navigation.d.ts.map +1 -1
  93. package/dist/xlsx/ui/index.cjs +800 -621
  94. package/dist/xlsx/ui/index.mjs +800 -621
  95. package/package.json +1 -1
  96. package/dist/PptxHandler-OGLITB3F.cjs +0 -12
  97. package/dist/PptxHandler-UKAA5T5U.mjs +0 -3
  98. package/dist/PresentationBuilder-54QGEZ2F.mjs +0 -3
  99. package/dist/pptx/chunks/elements-Cadkqht8.d.ts.map +0 -1
  100. package/dist/pptx/chunks/index-CJI2EugA.d.ts.map +0 -1
  101. package/dist/pptx/chunks/index-CozqpSPL.d.ts.map +0 -1
  102. package/dist/pptx/chunks/text-operations-C3L9xrqx.d.ts.map +0 -1
@@ -309,7 +309,7 @@ function parseOle2(buffer, options = {}) {
309
309
  fatEntries.push(fatView.getUint32(i2 * 4, true));
310
310
  }
311
311
  }
312
- function followChain(table2, start, label4, needed) {
312
+ function followChain(table2, start, label2, needed) {
313
313
  const ids = [];
314
314
  const visited = /* @__PURE__ */ new Set();
315
315
  let current = start;
@@ -317,26 +317,26 @@ function parseOle2(buffer, options = {}) {
317
317
  if (!strict && needed !== void 0 && ids.length >= needed)
318
318
  return ids;
319
319
  if (visited.has(current)) {
320
- throw new Ole2ParseError(`Circular reference in ${label4} chain at sector ${current}`);
320
+ throw new Ole2ParseError(`Circular reference in ${label2} chain at sector ${current}`);
321
321
  }
322
322
  visited.add(current);
323
323
  ids.push(current);
324
324
  if (table2[current] === void 0)
325
- throw new Ole2ParseError(`Missing ${label4} chain entry`);
325
+ throw new Ole2ParseError(`Missing ${label2} chain entry`);
326
326
  current = table2[current];
327
327
  }
328
328
  if (current !== ENDOFCHAIN) {
329
329
  if (strict || needed === void 0 || ids.length < needed) {
330
- throw new Ole2ParseError(`Invalid ${label4} chain terminator`);
330
+ throw new Ole2ParseError(`Invalid ${label2} chain terminator`);
331
331
  }
332
- warnings.push({ code: "chain-terminator", message: `Accepted ${label4} chain ending in 0x${current.toString(16)}` });
332
+ warnings.push({ code: "chain-terminator", message: `Accepted ${label2} chain ending in 0x${current.toString(16)}` });
333
333
  }
334
334
  return ids;
335
335
  }
336
- function readMetadataChain(startSector, label4) {
336
+ function readMetadataChain(startSector, label2) {
337
337
  if (startSector > MAXREGSECT)
338
338
  return new Uint8Array(0);
339
- const ids = followChain(fatEntries, startSector, label4 === "directory" ? "FAT" : label4);
339
+ const ids = followChain(fatEntries, startSector, label2 === "directory" ? "FAT" : label2);
340
340
  const result2 = new Uint8Array(ids.length * sectorSize);
341
341
  ids.forEach((id, i2) => result2.set(readSector(id), i2 * sectorSize));
342
342
  return result2;
@@ -3249,7 +3249,7 @@ var DEFAULT_XML_LIMITS = {
3249
3249
  maxNodes: 5e6
3250
3250
  };
3251
3251
  var MARKUP_RE = /<!--[\s\S]*?-->|<!\[CDATA\[[\s\S]*?\]\]>|<\?[\s\S]*?\?>|<(\/?)([^\s\/>]+)(?:\s+[^\s=\/>]+\s*=\s*(?:"[^"]*"|'[^']*'))*\s*(\/?)>/g;
3252
- function checkXmlLimits(xml, label4, limits = {}) {
3252
+ function checkXmlLimits(xml, label2, limits = {}) {
3253
3253
  const maxDepth = limits.maxDepth ?? DEFAULT_XML_LIMITS.maxDepth;
3254
3254
  const maxNodes = limits.maxNodes ?? DEFAULT_XML_LIMITS.maxNodes;
3255
3255
  let depth = 0;
@@ -3262,16 +3262,16 @@ function checkXmlLimits(xml, label4, limits = {}) {
3262
3262
  continue;
3263
3263
  }
3264
3264
  nodes++;
3265
- if (nodes > maxNodes) throw new Error(`${label4} XML exceeds the limit of ${maxNodes} elements`);
3265
+ if (nodes > maxNodes) throw new Error(`${label2} XML exceeds the limit of ${maxNodes} elements`);
3266
3266
  if (!selfClosing && ++depth > maxDepth)
3267
- throw new Error(`${label4} XML exceeds the nesting depth limit of ${maxDepth}`);
3267
+ throw new Error(`${label2} XML exceeds the nesting depth limit of ${maxDepth}`);
3268
3268
  }
3269
3269
  }
3270
3270
  function parseXml(xml, options = {}) {
3271
- const label4 = options.label ?? "OOXML";
3271
+ const label2 = options.label ?? "OOXML";
3272
3272
  if (/<!DOCTYPE|<!ENTITY/i.test(xml))
3273
- throw new Error(`${label4} XML with DTD or entity declarations is not supported`);
3274
- checkXmlLimits(xml, label4, options.limits);
3273
+ throw new Error(`${label2} XML with DTD or entity declarations is not supported`);
3274
+ checkXmlLimits(xml, label2, options.limits);
3275
3275
  let parseError = "";
3276
3276
  let parsed;
3277
3277
  try {
@@ -3282,12 +3282,12 @@ function parseXml(xml, options = {}) {
3282
3282
  }).parseFromString(xml, "application/xml");
3283
3283
  } catch (error) {
3284
3284
  throw new Error(
3285
- `Invalid ${label4} XML: ${error instanceof Error ? error.message : String(error)}`,
3285
+ `Invalid ${label2} XML: ${error instanceof Error ? error.message : String(error)}`,
3286
3286
  { cause: error }
3287
3287
  );
3288
3288
  }
3289
3289
  if (parseError || !parsed.documentElement)
3290
- throw new Error(`Invalid ${label4} XML: ${parseError || "missing root element"}`);
3290
+ throw new Error(`Invalid ${label2} XML: ${parseError || "missing root element"}`);
3291
3291
  return parsed;
3292
3292
  }
3293
3293
  var buildXml = (node2) => new XMLSerializer().serializeToString(node2);
@@ -4397,19 +4397,19 @@ var DIGITAL_SIGNATURE_ORIGIN_REL_TYPE = "http://schemas.openxmlformats.org/packa
4397
4397
  var MAX_ROW = 1048575;
4398
4398
  var MAX_COL = 16383;
4399
4399
  function columnLabel(col) {
4400
- let label4 = "";
4400
+ let label2 = "";
4401
4401
  let n = col + 1;
4402
4402
  while (n > 0) {
4403
4403
  const rem = (n - 1) % 26;
4404
- label4 = String.fromCharCode(65 + rem) + label4;
4404
+ label2 = String.fromCharCode(65 + rem) + label2;
4405
4405
  n = Math.floor((n - 1) / 26);
4406
4406
  }
4407
- return label4;
4407
+ return label2;
4408
4408
  }
4409
- function columnIndex(label4) {
4410
- if (!/^[A-Za-z]{1,3}$/.test(label4)) return -1;
4409
+ function columnIndex(label2) {
4410
+ if (!/^[A-Za-z]{1,3}$/.test(label2)) return -1;
4411
4411
  let n = 0;
4412
- for (const ch of label4.toUpperCase()) n = n * 26 + (ch.charCodeAt(0) - 64);
4412
+ for (const ch of label2.toUpperCase()) n = n * 26 + (ch.charCodeAt(0) - 64);
4413
4413
  return n - 1;
4414
4414
  }
4415
4415
  var formatAddress = (address2) => `${columnLabel(address2.col)}${address2.row + 1}`;
@@ -6731,6 +6731,71 @@ var pivotColumnFields = (pivot) => [
6731
6731
  ...pivot.columnField ? pivot.moreColumnFields ?? [] : []
6732
6732
  ];
6733
6733
 
6734
+ // xlsx/pivot/captions.ts
6735
+ var FUNCTIONS = {
6736
+ sum: "Sum",
6737
+ count: "Count",
6738
+ average: "Average",
6739
+ max: "Max",
6740
+ min: "Min",
6741
+ product: "Product",
6742
+ countNums: "Count",
6743
+ stdDev: "StdDev",
6744
+ stdDevp: "StdDevp",
6745
+ var: "Var",
6746
+ varp: "Varp"
6747
+ };
6748
+ var aggregateNames = () => Object.fromEntries(
6749
+ Object.keys(FUNCTIONS).map((fn) => [
6750
+ fn,
6751
+ `${fn[0].toUpperCase()}${fn.slice(1)} of {0}`
6752
+ ])
6753
+ );
6754
+ var ENGLISH_PIVOT_CAPTIONS = {
6755
+ rowLabels: "Row Labels",
6756
+ columnLabels: "Column Labels",
6757
+ grandTotal: "Grand Total",
6758
+ values: "Values",
6759
+ all: "(All)",
6760
+ blank: "(blank)",
6761
+ subtotal: "{0} Total",
6762
+ measureTotal: "Total {0}",
6763
+ functions: FUNCTIONS,
6764
+ aggregates: aggregateNames()
6765
+ };
6766
+ var fillCaption = (template, ...args) => template.replace(/\{(\d)\}/g, (_match, at) => args[Number(at)] ?? "");
6767
+ function pivotCaptions(pivot) {
6768
+ const own = pivot.captions;
6769
+ if (!own) return ENGLISH_PIVOT_CAPTIONS;
6770
+ return {
6771
+ ...ENGLISH_PIVOT_CAPTIONS,
6772
+ ...Object.fromEntries(Object.entries(own).filter(([, value2]) => typeof value2 === "string")),
6773
+ functions: { ...ENGLISH_PIVOT_CAPTIONS.functions, ...own.functions },
6774
+ aggregates: { ...ENGLISH_PIVOT_CAPTIONS.aggregates, ...own.aggregates }
6775
+ };
6776
+ }
6777
+ function trimmedCaptions(caps) {
6778
+ const out = {};
6779
+ for (const key of [
6780
+ "rowLabels",
6781
+ "columnLabels",
6782
+ "grandTotal",
6783
+ "values",
6784
+ "all",
6785
+ "blank",
6786
+ "subtotal",
6787
+ "measureTotal"
6788
+ ])
6789
+ if (caps[key] !== ENGLISH_PIVOT_CAPTIONS[key]) out[key] = caps[key];
6790
+ for (const key of ["functions", "aggregates"]) {
6791
+ const changed = Object.keys(caps[key]).filter(
6792
+ (fn) => caps[key][fn] !== ENGLISH_PIVOT_CAPTIONS[key][fn]
6793
+ );
6794
+ if (changed.length) out[key] = Object.fromEntries(changed.map((fn) => [fn, caps[key][fn]]));
6795
+ }
6796
+ return Object.keys(out).length ? out : void 0;
6797
+ }
6798
+
6734
6799
  // xlsx/formula/date-serial.ts
6735
6800
  var DAY_MS = 864e5;
6736
6801
  var EPOCH_19002 = Date.UTC(1899, 11, 30);
@@ -7165,6 +7230,17 @@ function validatePivotItemFilters(pivot) {
7165
7230
  }
7166
7231
  }
7167
7232
 
7233
+ // xlsx/pivot/item-labels.ts
7234
+ var keyOf = (field, item) => `${field}\0${pivotValueKey(item)}`;
7235
+ function pivotItemLabeler(pivot) {
7236
+ const blank = pivotCaptions(pivot).blank;
7237
+ const names = pivot.itemNames?.length ? new Map(pivot.itemNames.map((entry3) => [keyOf(entry3.field, entry3.item), entry3.name])) : void 0;
7238
+ return (field, value2) => names?.get(keyOf(field, value2)) ?? (value2 === null || value2 === "" ? blank : pivotItemLabel(value2));
7239
+ }
7240
+ var pivotItemName = (pivot, field, item) => pivot.itemNames?.find(
7241
+ (entry3) => entry3.field === field && pivotValueKey(entry3.item) === pivotValueKey(item)
7242
+ )?.name;
7243
+
7168
7244
  // xlsx/pivot/page-filter.ts
7169
7245
  function validatePivotPageFilter(pivot) {
7170
7246
  const filter2 = pivot.pageFilter;
@@ -7176,8 +7252,8 @@ function validatePivotPageFilter(pivot) {
7176
7252
  pivot.columnField,
7177
7253
  pivot.valueField,
7178
7254
  ...extras.map((v) => v?.field)
7179
- ].includes(filter2.field) || pivot.valuesAxis === "rows")
7180
- throw new Error("Report filters require Values on columns and a separate source field.");
7255
+ ].includes(filter2.field))
7256
+ throw new Error("Report filters require a separate source field.");
7181
7257
  if (filter2.item !== void 0 && !(filter2.item === null || typeof filter2.item === "string" || typeof filter2.item === "boolean" || typeof filter2.item === "number" && Number.isFinite(filter2.item) || isCellError(filter2.item) && isErrorCode(filter2.item.error) && Object.keys(filter2.item).length === 1))
7182
7258
  throw new Error("Choose a cached literal report filter item.");
7183
7259
  }
@@ -7190,10 +7266,10 @@ function pagedProjection(pivot) {
7190
7266
  if (!filter2) return pivot;
7191
7267
  const labels = /* @__PURE__ */ new Map();
7192
7268
  for (const item of pivotItems(pivot, filter2.field)) {
7193
- const label4 = String(pivotItemLabel(item)).toLowerCase(), key2 = pivotValueKey(item);
7194
- if (label4 === "(all)" || labels.has(label4) && labels.get(label4) !== key2)
7269
+ const label2 = String(pivotItemLabel(item)).toLowerCase(), key2 = pivotValueKey(item);
7270
+ if (label2 === "(all)" || labels.has(label2) && labels.get(label2) !== key2)
7195
7271
  throw new Error("Ambiguous report filter item captions are preserved.");
7196
- labels.set(label4, key2);
7272
+ labels.set(label2, key2);
7197
7273
  }
7198
7274
  if (filter2.item === void 0) return pivot;
7199
7275
  const index3 = pivot.fields.indexOf(filter2.field), key = pivotValueKey(filter2.item);
@@ -7211,7 +7287,7 @@ function prependPivotPage(grid, pivot) {
7211
7287
  values: [
7212
7288
  [
7213
7289
  pivot.pageFilter.field,
7214
- pivot.pageFilter.item === void 0 ? "(All)" : pivotItemLabel(pivot.pageFilter.item),
7290
+ pivot.pageFilter.item === void 0 ? pivotCaptions(pivot).all : pivotItemLabeler(pivot)(pivot.pageFilter.field, pivot.pageFilter.item),
7215
7291
  ...Array(width - 2).fill(null)
7216
7292
  ],
7217
7293
  Array(width).fill(null),
@@ -7326,7 +7402,7 @@ function validatePivotFields(pivot) {
7326
7402
  throw new Error("Values before or between fields require two row fields and Values on rows.");
7327
7403
  if (pivot.valuesAxis === "rows" && (!Array.isArray(extras) || !extras.length))
7328
7404
  throw new Error("Values on rows require multiple measures.");
7329
- if (extras.length > 0 && pivot.sourceXml && parseXml(pivot.sourceXml).documentElement.getAttribute("dataCaption") !== "Values")
7405
+ if (extras.length > 0 && pivot.sourceXml && parseXml(pivot.sourceXml).documentElement.getAttribute("dataCaption") !== pivotCaptions(pivot).values)
7330
7406
  throw new Error("This PivotTable uses unsupported Values header captions.");
7331
7407
  if (!Array.isArray(extras) || extras.length > 15 || extras.some(
7332
7408
  (measure) => !measure || !pivot.fields.includes(measure.field) || !PIVOT_AGGREGATES.includes(measure.aggregate) || typeof measure.caption !== "string" || !measure.caption.trim() || measure.caption.length > 255 || pivot.fields.some((field) => field.toLowerCase() === measure.caption.toLowerCase())
@@ -7415,7 +7491,6 @@ var pivotMeasureNumber = (pivot, records, measure) => aggregateValues(records, p
7415
7491
 
7416
7492
  // xlsx/pivot/columns.ts
7417
7493
  var SEPARATOR = "";
7418
- var label = pivotItemLabel;
7419
7494
  var columnKey = (keys, depth) => keys.slice(0, depth).join(SEPARATOR);
7420
7495
  var recordColumnKeys = (record, indices) => indices.map((index3) => pivotValueKey(record[index3] ?? null));
7421
7496
  function pivotColumnEntries(pivot) {
@@ -7490,7 +7565,9 @@ function pivotColumnHeaders(pivot, columns, rowLabels, valuesOnRows = false) {
7490
7565
  const rows = levels + 1 + Number(count2 > 1);
7491
7566
  const grid = Array.from({ length: rows }, () => Array(width).fill(null));
7492
7567
  if (count2 === 1 && !valuesOnRows) grid[0][0] = pivot.valueCaption;
7493
- const titles = compact ? ["Column Labels"] : [...columns.names, ...count2 > 1 ? ["Values"] : []];
7568
+ const caps = pivotCaptions(pivot);
7569
+ const labelOf = pivotItemLabeler(pivot);
7570
+ const titles = compact ? [caps.columnLabels] : [...columns.names, ...count2 > 1 ? [caps.values] : []];
7494
7571
  titles.forEach((title, i2) => {
7495
7572
  grid[0][labelColumns + i2] = title;
7496
7573
  });
@@ -7503,17 +7580,17 @@ function pivotColumnHeaders(pivot, columns, rowLabels, valuesOnRows = false) {
7503
7580
  if (entry3.kind === "leaf") {
7504
7581
  entry3.path.forEach((_index, level) => {
7505
7582
  const continued = entry3.path.slice(0, level + 1).every((p, i2) => p === previous[i2]);
7506
- if (!continued) grid[1 + level][at] = label(entry3.values[level]);
7583
+ if (!continued) grid[1 + level][at] = labelOf(columns.names[level], entry3.values[level]);
7507
7584
  });
7508
7585
  previous = entry3.path;
7509
7586
  if (count2 > 1) measures.forEach((measure, m) => grid[rows - 1][at + m] = measure.caption);
7510
7587
  return;
7511
7588
  }
7512
7589
  const row2 = entry3.kind === "grand" ? 1 : entry3.path.length;
7513
- const name = entry3.kind === "grand" ? "" : String(label(entry3.values.at(-1)));
7590
+ const name = entry3.kind === "grand" ? "" : String(labelOf(columns.names[entry3.path.length - 1], entry3.values.at(-1)));
7514
7591
  measures.forEach((measure, m) => {
7515
- const custom = entry3.fn ? PIVOT_SUBTOTALS[entry3.fn].label : void 0;
7516
- grid[row2][at + m] = custom ? count2 === 1 ? `${name} ${custom}` : `${name} ${custom} of ${measure.field}` : count2 === 1 ? entry3.kind === "grand" ? "Grand Total" : `${name} Total` : entry3.kind === "grand" ? `Total ${measure.caption}` : `${name} ${measure.caption}`;
7592
+ const custom = entry3.fn ? caps.functions[entry3.fn] : void 0;
7593
+ grid[row2][at + m] = custom ? count2 === 1 ? `${name} ${custom}` : `${name} ${custom} of ${measure.field}` : count2 === 1 ? entry3.kind === "grand" ? caps.grandTotal : fillCaption(caps.subtotal, name) : entry3.kind === "grand" ? fillCaption(caps.measureTotal, measure.caption) : `${name} ${measure.caption}`;
7517
7594
  });
7518
7595
  });
7519
7596
  return grid;
@@ -7546,7 +7623,6 @@ function pivotColumnItemsXml(entries, measures, remap) {
7546
7623
  }
7547
7624
 
7548
7625
  // xlsx/pivot/nested.ts
7549
- var label2 = pivotItemLabel;
7550
7626
  var MAX_CELLS = 1e6;
7551
7627
  var node = (index3, value2) => ({
7552
7628
  index: index3,
@@ -7576,6 +7652,8 @@ function nestedPivotGrid(pivot) {
7576
7652
  const labelColumns = compact ? 1 : levels;
7577
7653
  const measures = pivotMeasures(pivot);
7578
7654
  const functions = names.map((name) => fieldSubtotalFunctions(pivot, name));
7655
+ const caps = pivotCaptions(pivot);
7656
+ const labelOf = pivotItemLabeler(pivot);
7579
7657
  const root = node(0, null);
7580
7658
  for (const record of pivot.records) {
7581
7659
  const keys = recordColumnKeys(record, columnFields);
@@ -7602,7 +7680,7 @@ function nestedPivotGrid(pivot) {
7602
7680
  }
7603
7681
  const dimensions = pivotColumnDimensions(pivot, columns, labelColumns, onRows);
7604
7682
  const rowTitles = names.map((name) => name);
7605
- if (onRows) rowTitles.splice(valuesAt, 0, "Values");
7683
+ if (onRows) rowTitles.splice(valuesAt, 0, caps.values);
7606
7684
  let values2 = [];
7607
7685
  let indents = [];
7608
7686
  const rowEntries = [];
@@ -7681,11 +7759,11 @@ function nestedPivotGrid(pivot) {
7681
7759
  const children2 = [...group.children.values()].sort((a2, b) => a2.index - b.index);
7682
7760
  children2.forEach((child4, position) => {
7683
7761
  const here = {
7684
- labels: [...path2.labels, label2(child4.value)],
7762
+ labels: [...path2.labels, labelOf(names[field], child4.value)],
7685
7763
  indices: [...path2.indices, child4.index],
7686
7764
  firsts: [...path2.firsts, position === 0]
7687
7765
  };
7688
- const text2 = label2(child4.value);
7766
+ const text2 = labelOf(names[field], child4.value);
7689
7767
  if (last)
7690
7768
  return push(level, () => [
7691
7769
  labelCells(path2, leafShown(here.firsts), level, text2),
@@ -7708,14 +7786,14 @@ function nestedPivotGrid(pivot) {
7708
7786
  ]);
7709
7787
  if (own === "auto") {
7710
7788
  if (showsValue) return;
7711
- if (valuesAbove) subtotal(`${caption} Total`, void 0, measure);
7789
+ if (valuesAbove) subtotal(fillCaption(caps.subtotal, caption), void 0, measure);
7712
7790
  else measures.forEach((one2, m) => subtotal(`${caption} ${one2.caption}`, void 0, m));
7713
7791
  } else
7714
7792
  for (const fn of own)
7715
- if (valuesAbove) subtotal(`${caption} ${PIVOT_SUBTOTALS[fn].label}`, fn, measure);
7793
+ if (valuesAbove) subtotal(`${caption} ${caps.functions[fn]}`, fn, measure);
7716
7794
  else
7717
7795
  measures.forEach(
7718
- (one2, m) => subtotal(`${caption} ${PIVOT_SUBTOTALS[fn].label} of ${one2.field}`, fn, m)
7796
+ (one2, m) => subtotal(`${caption} ${caps.functions[fn]} of ${one2.field}`, fn, m)
7719
7797
  );
7720
7798
  });
7721
7799
  };
@@ -7726,12 +7804,12 @@ function nestedPivotGrid(pivot) {
7726
7804
  ]);
7727
7805
  const build = () => {
7728
7806
  walk(0, root, void 0, { labels: [], indices: [], firsts: [] });
7729
- if (onRows) measures.forEach((one2, m) => grand(`Total ${one2.caption}`, m));
7730
- else grand("Grand Total");
7807
+ if (onRows) measures.forEach((one2, m) => grand(fillCaption(caps.measureTotal, one2.caption), m));
7808
+ else grand(caps.grandTotal);
7731
7809
  };
7732
7810
  build();
7733
7811
  counting = false;
7734
- values2 = pivotColumnHeaders(pivot, columns, compact ? ["Row Labels"] : rowTitles, onRows);
7812
+ values2 = pivotColumnHeaders(pivot, columns, compact ? [caps.rowLabels] : rowTitles, onRows);
7735
7813
  const firstDataRow = values2.length;
7736
7814
  indents = values2.map(() => 0);
7737
7815
  build();
@@ -7764,14 +7842,14 @@ function pivotTableAt(sheet, at) {
7764
7842
  var X14 = "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main";
7765
7843
  var LAYOUT = "http://schemas.microsoft.com/office/spreadsheetml/2016/pivotdefaultlayout";
7766
7844
  var TABLE = {
7767
- pivotTableDefinition: "name cacheId dataCaption dataOnRows dataPosition updatedVersion minRefreshableVersion createdVersion applyNumberFormats applyBorderFormats applyFontFormats applyPatternFormats applyAlignmentFormats applyWidthHeightFormats useAutoFormatting itemPrintTitles indent compact compactData outline outlineData multipleFieldFilters rowGrandTotals colGrandTotals",
7845
+ pivotTableDefinition: "name cacheId dataCaption grandTotalCaption rowHeaderCaption colHeaderCaption dataOnRows dataPosition updatedVersion minRefreshableVersion createdVersion applyNumberFormats applyBorderFormats applyFontFormats applyPatternFormats applyAlignmentFormats applyWidthHeightFormats useAutoFormatting itemPrintTitles indent compact compactData outline outlineData multipleFieldFilters rowGrandTotals colGrandTotals",
7768
7846
  location: "ref firstHeaderRow firstDataRow firstDataCol rowPageCount colPageCount",
7769
7847
  pageFields: "count",
7770
7848
  pageField: "fld item hier",
7771
7849
  pivotFields: "count",
7772
7850
  pivotField: "axis dataField compact outline showAll subtotalTop defaultSubtotal numFmtId sumSubtotal countASubtotal avgSubtotal maxSubtotal minSubtotal productSubtotal countSubtotal stdDevSubtotal stdDevPSubtotal varSubtotal varPSubtotal",
7773
7851
  items: "count",
7774
- item: "x t h",
7852
+ item: "x t h n",
7775
7853
  rowFields: "count",
7776
7854
  colFields: "count",
7777
7855
  field: "x",
@@ -7884,6 +7962,121 @@ function assertPivotRecords(records) {
7884
7962
  );
7885
7963
  }
7886
7964
 
7965
+ // xlsx/pivot/captions-read.ts
7966
+ var ATTRIBUTES = {
7967
+ rowHeaderCaption: "rowLabels",
7968
+ colHeaderCaption: "columnLabels",
7969
+ grandTotalCaption: "grandTotal",
7970
+ dataCaption: "values"
7971
+ };
7972
+ function readPivotCaptionAttributes(root) {
7973
+ const out = {};
7974
+ for (const [attribute2, key] of Object.entries(ATTRIBUTES)) {
7975
+ const text2 = att(root, attribute2);
7976
+ if (text2 !== void 0)
7977
+ out[key] = decodeEscapes(text2);
7978
+ }
7979
+ return out;
7980
+ }
7981
+ function aggregateCaptionsOf(pivot) {
7982
+ const out = {};
7983
+ for (const measure of [
7984
+ { field: pivot.valueField, aggregate: pivot.aggregate, caption: pivot.valueCaption },
7985
+ ...pivot.additionalValues ?? []
7986
+ ]) {
7987
+ const at = measure.caption.indexOf(measure.field);
7988
+ if (at < 0 || measure.caption === measure.field) continue;
7989
+ const template = `${measure.caption.slice(0, at)}{0}${measure.caption.slice(at + measure.field.length)}`;
7990
+ if (template !== ENGLISH_PIVOT_CAPTIONS.aggregates[measure.aggregate])
7991
+ out[measure.aggregate] = template;
7992
+ }
7993
+ return Object.keys(out).length ? out : void 0;
7994
+ }
7995
+ var MARK = "";
7996
+ var SENTINELS = {
7997
+ rowLabels: `${MARK}R`,
7998
+ columnLabels: `${MARK}C`,
7999
+ grandTotal: `${MARK}G`,
8000
+ values: `${MARK}V`,
8001
+ all: `${MARK}A`,
8002
+ blank: `${MARK}B`,
8003
+ subtotal: `{0}${MARK}S`,
8004
+ measureTotal: `${MARK}M{0}`,
8005
+ functions: Object.fromEntries(
8006
+ Object.keys(ENGLISH_PIVOT_CAPTIONS.functions).map((fn) => [fn, `${MARK}F${fn}`])
8007
+ ),
8008
+ aggregates: ENGLISH_PIVOT_CAPTIONS.aggregates
8009
+ };
8010
+ function templateOf(cached, arg) {
8011
+ if (!arg || !cached.includes(arg)) return void 0;
8012
+ if (cached.startsWith(arg)) return `{0}${cached.slice(arg.length)}`;
8013
+ if (cached.endsWith(arg)) return `${cached.slice(0, -arg.length)}{0}`;
8014
+ const at = cached.indexOf(arg);
8015
+ return `${cached.slice(0, at)}{0}${cached.slice(at + arg.length)}`;
8016
+ }
8017
+ function inferPivotCaptions(pivot, sheet, named2) {
8018
+ const known = pivotCaptions({ captions: named2 });
8019
+ const probe = { ...SENTINELS };
8020
+ for (const key of Object.keys(named2))
8021
+ if (typeof named2[key] === "string")
8022
+ probe[key] = known[key];
8023
+ const grid = pivotGrid({ ...pivot, captions: probe });
8024
+ const found = /* @__PURE__ */ new Map();
8025
+ const set = (key, value2) => {
8026
+ if (value2 === void 0) return;
8027
+ const before = found.get(key);
8028
+ found.set(key, before === void 0 || before === value2 ? value2 : null);
8029
+ };
8030
+ grid.values.forEach(
8031
+ (line2, r) => line2.forEach((expected, c2) => {
8032
+ if (typeof expected !== "string" || !expected.includes(MARK)) return;
8033
+ const cached = getCell(
8034
+ sheet,
8035
+ pivot.location.start.row + r,
8036
+ pivot.location.start.col + c2
8037
+ )?.value;
8038
+ if (typeof cached !== "string") return;
8039
+ const kind = /\u0001([RCGVASMFB])(\w*)/.exec(expected);
8040
+ if (!kind) return;
8041
+ const at = kind.index;
8042
+ switch (kind[1]) {
8043
+ case "R":
8044
+ return set("rowLabels", cached);
8045
+ case "C":
8046
+ return set("columnLabels", cached);
8047
+ case "G":
8048
+ return set("grandTotal", cached);
8049
+ case "V":
8050
+ return set("values", cached);
8051
+ case "A":
8052
+ return set("all", cached);
8053
+ case "B":
8054
+ return set("blank", cached);
8055
+ case "S":
8056
+ return set("subtotal", templateOf(cached, expected.slice(0, at)));
8057
+ case "M":
8058
+ return set("measureTotal", templateOf(cached, expected.slice(at + 2)));
8059
+ case "F": {
8060
+ const item = expected.slice(0, at - 1);
8061
+ const of = / of (.*)$/.exec(expected.slice(at));
8062
+ const word = cached.slice(item.length + 1, of ? cached.length - of[0].length : void 0);
8063
+ if (cached.startsWith(`${item} `) && (!of || cached.endsWith(of[0])))
8064
+ set(`function:${kind[2]}`, word);
8065
+ }
8066
+ }
8067
+ })
8068
+ );
8069
+ const out = pivotCaptions({ captions: named2 });
8070
+ const functions = { ...out.functions };
8071
+ for (const [key, value2] of found) {
8072
+ if (value2 === null) continue;
8073
+ if (key.startsWith("function:")) functions[key.slice(9)] = value2;
8074
+ else out[key] = value2;
8075
+ }
8076
+ out.functions = functions;
8077
+ return trimmedCaptions(out);
8078
+ }
8079
+
7887
8080
  // xlsx/slicer/read-slicers.ts
7888
8081
  var TABLE_SLICER_URI = "{2F2917AC-EB37-4324-AD4E-5DD8C200BD13}";
7889
8082
  var X152 = "http://schemas.microsoft.com/office/spreadsheetml/2010/11/main";
@@ -8323,7 +8516,7 @@ function readFieldGroups(fields, names) {
8323
8516
  throw new Error("Unsupported pivot field group");
8324
8517
  const labels = children(list, "s", NS.x).map((node2) => decodeEscapes(att(node2, "v") ?? ""));
8325
8518
  const expected = numberGroupLabels({ start, end, by });
8326
- if (elements(list).length !== labels.length || labels.length !== expected.length || labels.some((label4, i2) => label4 !== expected[i2]))
8519
+ if (elements(list).length !== labels.length || labels.length !== expected.length || labels.some((label2, i2) => label2 !== expected[i2]))
8327
8520
  throw new Error("Unsupported pivot group items");
8328
8521
  groups.push({ field: names[index3] ?? "", start, end, by });
8329
8522
  });
@@ -8407,7 +8600,7 @@ function readDateGroups(fields, count2, names, dateFields, records, date1904) {
8407
8600
  const node2 = first(first(entry3.node, "fieldGroup", NS.x), "groupItems", NS.x);
8408
8601
  const actual = children(node2, "s", NS.x).map((item) => decodeEscapes(att(item, "v") ?? ""));
8409
8602
  const name = decodeEscapes(att(entry3.node, "name") ?? "");
8410
- if (!name || elements(node2).length !== actual.length || actual.length !== labels.length || actual.some((label4) => !label4) || new Set(actual).size !== actual.length)
8603
+ if (!name || elements(node2).length !== actual.length || actual.length !== labels.length || actual.some((label2) => !label2) || new Set(actual).size !== actual.length)
8411
8604
  throw unsupported("group items");
8412
8605
  if (name !== dateGroupFieldName(entry3.unit, field) || actual.some((l, i2) => l !== labels[i2]))
8413
8606
  localized[entry3.unit] = { name, labels: actual };
@@ -8465,6 +8658,25 @@ function readItemFilters(fields, names, shared) {
8465
8658
  return filters.length ? filters : void 0;
8466
8659
  }
8467
8660
 
8661
+ // xlsx/pivot/item-names-read.ts
8662
+ function readItemNames(tableFields, names, shared) {
8663
+ const out = [];
8664
+ tableFields.forEach((field, index3) => {
8665
+ const list = first(field, "items", NS.x);
8666
+ if (!list || index3 >= names.length) return;
8667
+ for (const item of children(list, "item", NS.x)) {
8668
+ const name = att(item, "n");
8669
+ if (name === void 0) continue;
8670
+ const at = Number(att(item, "x"));
8671
+ const value2 = shared[index3]?.[at];
8672
+ if (att(item, "t") !== void 0 || !Number.isInteger(at) || value2 === void 0)
8673
+ throw new Error("Unsupported pivot item name");
8674
+ out.push({ field: names[index3], item: value2, name: decodeEscapes(name) });
8675
+ }
8676
+ });
8677
+ return out;
8678
+ }
8679
+
8468
8680
  // xlsx/pivot/values-axis.ts
8469
8681
  function remapPivotRowEntries(entries, axes2) {
8470
8682
  return entries.map(
@@ -8628,7 +8840,10 @@ function assertPageAxisItems(root, pivot, shared, cache2, recordRoot) {
8628
8840
  };
8629
8841
  const rowAxes = pivotRowFields(pivot).map((name) => axisValues(name, "axisRow")), rowItems = read("rowItems");
8630
8842
  const grid = pivotGrid(pivot);
8631
- const entries = grid.rowEntries ? remapPivotRowEntries(grid.rowEntries, rowAxes) : [
8843
+ const valuesAt = pivotValuesIndex(pivot);
8844
+ const levelAxes = [...rowAxes];
8845
+ if (valuesAt >= 0) levelAxes.splice(valuesAt, 0, null);
8846
+ const entries = grid.rowEntries ? remapPivotRowEntries(grid.rowEntries, levelAxes) : [
8632
8847
  ...rowAxes[0].map((index3) => ({ indices: [index3] })),
8633
8848
  { indices: [0], type: "grand" }
8634
8849
  ];
@@ -8638,11 +8853,11 @@ function assertPageAxisItems(root, pivot, shared, cache2, recordRoot) {
8638
8853
  const expected2 = entries[i2];
8639
8854
  const xs = children(item, "x", NS.x).map((x) => integer(x.getAttribute("v"), 0)), prefix = integer(item.getAttribute("r"), 0);
8640
8855
  const type = expected2.type === void 0 || expected2.type === "default" || expected2.type === "grand" ? expected2.type : PIVOT_SUBTOTALS[expected2.type].item;
8641
- if (item.getAttribute("t") !== (type ?? null) || !Number.isInteger(prefix) || prefix < 0 || prefix > previousRow.length || prefix >= expected2.indices.length || expected2.type === "grand" && prefix !== 0 || integer(item.getAttribute("i"), 0) !== 0 || JSON.stringify([...previousRow.slice(0, prefix), ...xs]) !== JSON.stringify(expected2.indices))
8856
+ if (item.getAttribute("t") !== (type ?? null) || !Number.isInteger(prefix) || prefix < 0 || prefix > previousRow.length || prefix >= expected2.indices.length || expected2.type === "grand" && prefix !== 0 || integer(item.getAttribute("i"), 0) !== (expected2.measure ?? 0) || JSON.stringify([...previousRow.slice(0, prefix), ...xs]) !== JSON.stringify(expected2.indices))
8642
8857
  throw new Error("Unmodeled page row item");
8643
8858
  previousRow = expected2.type === "grand" ? [] : expected2.indices;
8644
8859
  });
8645
- const measures = 1 + (pivot.additionalValues?.length ?? 0), columns = pivot.columnField ? axisValues(pivot.columnField, "axisCol") : void 0, expected = [];
8860
+ const measures = valuesAt >= 0 ? 1 : 1 + (pivot.additionalValues?.length ?? 0), columns = pivot.columnField ? axisValues(pivot.columnField, "axisCol") : void 0, expected = [];
8646
8861
  if (columns)
8647
8862
  for (const col of columns)
8648
8863
  for (let m = 0; m < measures; m++) expected.push(measures > 1 ? [col, m] : [col]);
@@ -8684,6 +8899,10 @@ function value(node2, date1904 = false) {
8684
8899
  if (node2.localName === "e" && isErrorCode(v)) return { error: v };
8685
8900
  throw new Error("Unsupported pivot cache item");
8686
8901
  }
8902
+ var namedAggregates = (pivot) => {
8903
+ const aggregates = aggregateCaptionsOf(pivot);
8904
+ return aggregates ? { aggregates } : {};
8905
+ };
8687
8906
  function readOne(workbook, source2, part) {
8688
8907
  const xml = source2.text(part);
8689
8908
  const root = parseXml(xml).documentElement;
@@ -8830,6 +9049,7 @@ function readOne(workbook, source2, part) {
8830
9049
  location.start.row -= 2;
8831
9050
  }
8832
9051
  const itemFilters = readItemFilters(tableFields, names, shared);
9052
+ const itemNames = readItemNames(tableFields, names, shared);
8833
9053
  const slicerCacheId = readSlicerCacheId(cache2);
8834
9054
  const fieldGroups = readFieldGroups(fields, names);
8835
9055
  const dateFields = readDateFields(fields, names);
@@ -8868,6 +9088,7 @@ function readOne(workbook, source2, part) {
8868
9088
  const pivot = {
8869
9089
  ...pageFilter ? { pageFilter } : {},
8870
9090
  ...itemFilters ? { itemFilters } : {},
9091
+ ...itemNames.length ? { itemNames } : {},
8871
9092
  ...fieldGroups.length ? { fieldGroups } : {},
8872
9093
  ...dateFields.length ? { dateFields } : {},
8873
9094
  ...dateGroups.length ? { dateGroups } : {},
@@ -8910,6 +9131,12 @@ function readOne(workbook, source2, part) {
8910
9131
  ...col ? { columnField: col } : {},
8911
9132
  ...moreColumns.length ? { moreColumnFields: moreColumns } : {}
8912
9133
  };
9134
+ const captions = trimmedCaptions(
9135
+ pivotCaptions({
9136
+ captions: { ...readPivotCaptionAttributes(root), ...namedAggregates(pivot) }
9137
+ })
9138
+ );
9139
+ if (captions) pivot.captions = captions;
8913
9140
  if (pageFilter && moreColumns.length) throw new Error("Report filters support one column field");
8914
9141
  assertPageAxisItems(root, pivot, shared, cache2, recordRoot);
8915
9142
  return pivot;
@@ -8937,6 +9164,12 @@ function readPivotTables(workbook, source2, warn, slicers) {
8937
9164
  if (slicers.blocked.has(pivotKey(sheet.sheetId, name)) || cache2 && (caches2.get(cache2) ?? 0) > 1)
8938
9165
  throw new Error("Shared pivot cache or unsupported slicer connection");
8939
9166
  const pivot = readOne(workbook, source2, part);
9167
+ const inferred = inferPivotCaptions(pivot, sheet, {
9168
+ ...readPivotCaptionAttributes(parseXml(pivot.sourceXml).documentElement),
9169
+ ...namedAggregates(pivot)
9170
+ });
9171
+ if (inferred) pivot.captions = inferred;
9172
+ else delete pivot.captions;
8940
9173
  const grid = pivotGrid(pivot);
8941
9174
  if (grid.values.length !== pivot.location.end.row - pivot.location.start.row + 1 || grid.values[0].length !== pivot.location.end.col - pivot.location.start.col + 1 || grid.values.some(
8942
9175
  (line2, r) => line2.some(
@@ -9697,7 +9930,7 @@ function mergeSpacedAreas(tokens2) {
9697
9930
  }
9698
9931
  return out;
9699
9932
  }
9700
- function templateOf(formula) {
9933
+ function templateOf2(formula) {
9701
9934
  const cached = templates.get(formula);
9702
9935
  if (cached !== void 0) return cached;
9703
9936
  const raw2 = safeTokens(formula);
@@ -9727,7 +9960,7 @@ function templateOf(formula) {
9727
9960
  return template;
9728
9961
  }
9729
9962
  function rewriteTemplate(formula, rewrite2) {
9730
- const template = templateOf(formula);
9963
+ const template = templateOf2(formula);
9731
9964
  if (!template) return formula;
9732
9965
  let next;
9733
9966
  for (let i2 = 0; i2 < template.length; i2++) {
@@ -10309,8 +10542,8 @@ function parseDiagramDataModel(source2, part) {
10309
10542
  "CONNECTION_ENDPOINT_MISSING",
10310
10543
  `dgm:cxn ${attribute2} references missing point: ${id}.`
10311
10544
  );
10312
- const label4 = connectionLabel(connection, transitionText);
10313
- connections.push(label4 ? { ...connection, label: label4 } : connection);
10545
+ const label2 = connectionLabel(connection, transitionText);
10546
+ connections.push(label2 ? { ...connection, label: label2 } : connection);
10314
10547
  if ((!connection.type || connection.type === "parOf") && !parentById.has(connection.destId))
10315
10548
  parentById.set(connection.destId, connection.sourceId);
10316
10549
  }
@@ -10349,14 +10582,14 @@ function colorList(container2) {
10349
10582
  }
10350
10583
  function parseDiagramColors(source2) {
10351
10584
  const root = rootOf2(source2);
10352
- const labels = children(root, "styleLbl", NS.dgm).map((label4) => ({
10353
- name: stringAttribute(label4, "name") ?? "",
10354
- fill: colorList(first(label4, "fillClrLst", NS.dgm)),
10355
- line: colorList(first(label4, "linClrLst", NS.dgm)),
10356
- effect: colorList(first(label4, "effectClrLst", NS.dgm)),
10357
- textLine: colorList(first(label4, "txLinClrLst", NS.dgm)),
10358
- textFill: colorList(first(label4, "txFillClrLst", NS.dgm)),
10359
- textEffect: colorList(first(label4, "txEffectClrLst", NS.dgm))
10585
+ const labels = children(root, "styleLbl", NS.dgm).map((label2) => ({
10586
+ name: stringAttribute(label2, "name") ?? "",
10587
+ fill: colorList(first(label2, "fillClrLst", NS.dgm)),
10588
+ line: colorList(first(label2, "linClrLst", NS.dgm)),
10589
+ effect: colorList(first(label2, "effectClrLst", NS.dgm)),
10590
+ textLine: colorList(first(label2, "txLinClrLst", NS.dgm)),
10591
+ textFill: colorList(first(label2, "txFillClrLst", NS.dgm)),
10592
+ textEffect: colorList(first(label2, "txEffectClrLst", NS.dgm))
10360
10593
  }));
10361
10594
  return { ...parseDefinitionHeader(root), labels };
10362
10595
  }
@@ -10389,16 +10622,16 @@ function parseStyleReferences(style2) {
10389
10622
  var hasContent = (element2) => Boolean(element2 && (element2.attributes.length > 0 || elements(element2).length > 0));
10390
10623
  function parseDiagramQuickStyle(source2) {
10391
10624
  const root = rootOf2(source2);
10392
- const labels = children(root, "styleLbl", NS.dgm).map((label4) => ({
10393
- name: stringAttribute(label4, "name") ?? "",
10394
- ...parseStyleReferences(first(label4, "style", NS.dgm)),
10395
- hasScene3d: Boolean(first(label4, "scene3d", NS.dgm)),
10396
- hasShape3d: hasContent(first(label4, "sp3d", NS.dgm))
10625
+ const labels = children(root, "styleLbl", NS.dgm).map((label2) => ({
10626
+ name: stringAttribute(label2, "name") ?? "",
10627
+ ...parseStyleReferences(first(label2, "style", NS.dgm)),
10628
+ hasScene3d: Boolean(first(label2, "scene3d", NS.dgm)),
10629
+ hasShape3d: hasContent(first(label2, "sp3d", NS.dgm))
10397
10630
  }));
10398
10631
  return {
10399
10632
  ...parseDefinitionHeader(root),
10400
10633
  labels,
10401
- has3d: labels.some((label4) => label4.hasShape3d)
10634
+ has3d: labels.some((label2) => label2.hasShape3d)
10402
10635
  };
10403
10636
  }
10404
10637
  function parseDiagramLayoutSummary(source2) {
@@ -12075,10 +12308,10 @@ function parseDisplayUnits(context, element2) {
12075
12308
  if (!element2) return void 0;
12076
12309
  reportUnmodelled(context, element2, DISPLAY_UNITS);
12077
12310
  const labelElement = cChild(element2, "dispUnitsLbl");
12078
- let label4;
12311
+ let label2;
12079
12312
  if (labelElement) {
12080
12313
  reportUnmodelled(context, labelElement, DISPLAY_UNITS_LABEL);
12081
- label4 = assignDefined(
12314
+ label2 = assignDefined(
12082
12315
  {},
12083
12316
  {
12084
12317
  layout: manualLayout(labelElement),
@@ -12093,7 +12326,7 @@ function parseDisplayUnits(context, element2) {
12093
12326
  {
12094
12327
  builtInUnit: cVal(element2, "builtInUnit"),
12095
12328
  customUnit: cNumber(context, element2, "custUnit"),
12096
- label: label4,
12329
+ label: label2,
12097
12330
  extLst: extensionList(element2)
12098
12331
  }
12099
12332
  );
@@ -13689,8 +13922,8 @@ function parseTable(xml, partName) {
13689
13922
  if (id !== void 0 && Number.isInteger(id) && id >= 0) column2.sourceId = id;
13690
13923
  const fn = att(node2, "totalsRowFunction");
13691
13924
  if (fn && fn !== "none") column2.totalsRowFunction = fn;
13692
- const label4 = att(node2, "totalsRowLabel");
13693
- if (label4 !== void 0) column2.totalsRowLabel = label4;
13925
+ const label2 = att(node2, "totalsRowLabel");
13926
+ if (label2 !== void 0) column2.totalsRowLabel = label2;
13694
13927
  const calculated = xFirst(node2, "calculatedColumnFormula");
13695
13928
  if (calculated) column2.calculatedColumnFormula = stripFuturePrefixes(xText(calculated));
13696
13929
  return column2;
@@ -14574,10 +14807,10 @@ function titleXml(context, title) {
14574
14807
  function labelOptionsXml(context, options) {
14575
14808
  return numberFormatXml(options.numberFormat) + shapePropertiesXml(context, options.spPr) + textBodyXml(context, options.txPr) + valXml("dLblPos", options.position) + valXml("showLegendKey", options.showLegendKey) + valXml("showVal", options.showValue) + valXml("showCatName", options.showCategoryName) + valXml("showSerName", options.showSeriesName) + valXml("showPercent", options.showPercent) + valXml("showBubbleSize", options.showBubbleSize) + (options.separator === void 0 ? "" : textElement("separator", options.separator));
14576
14809
  }
14577
- function labelXml(context, label4) {
14810
+ function labelXml(context, label2) {
14578
14811
  return elementXml(
14579
14812
  "dLbl",
14580
- valXml("idx", label4.index) + valXml("delete", label4.deleted) + layoutXml(context, label4.layout) + chartTextXml(context, label4.tx, false) + labelOptionsXml(context, label4) + raw(context, label4.extLst)
14813
+ valXml("idx", label2.index) + valXml("delete", label2.deleted) + layoutXml(context, label2.layout) + chartTextXml(context, label2.tx, false) + labelOptionsXml(context, label2) + raw(context, label2.extLst)
14581
14814
  );
14582
14815
  }
14583
14816
  function dataLabelsXml(context, labels) {
@@ -14585,7 +14818,7 @@ function dataLabelsXml(context, labels) {
14585
14818
  const leaderLines = labels.leaderLines ? elementXml("leaderLines", shapePropertiesXml(context, labels.leaderLines.spPr)) : "";
14586
14819
  return elementXml(
14587
14820
  "dLbls",
14588
- labels.labels.map((label4) => labelXml(context, label4)).join("") + valXml("delete", labels.deleted) + labelOptionsXml(context, labels) + valXml("showLeaderLines", labels.showLeaderLines) + leaderLines + raw(context, labels.extLst)
14821
+ labels.labels.map((label2) => labelXml(context, label2)).join("") + valXml("delete", labels.deleted) + labelOptionsXml(context, labels) + valXml("showLeaderLines", labels.showLeaderLines) + leaderLines + raw(context, labels.extLst)
14589
14822
  );
14590
14823
  }
14591
14824
 
@@ -14606,12 +14839,12 @@ function dataTableXml(context, table2) {
14606
14839
  }
14607
14840
  function displayUnitsXml(context, units) {
14608
14841
  if (!units) return "";
14609
- const label4 = units.label;
14842
+ const label2 = units.label;
14610
14843
  return elementXml(
14611
14844
  "dispUnits",
14612
- valXml("custUnit", units.customUnit) + (units.customUnit === void 0 ? valXml("builtInUnit", units.builtInUnit) : "") + (label4 ? elementXml(
14845
+ valXml("custUnit", units.customUnit) + (units.customUnit === void 0 ? valXml("builtInUnit", units.builtInUnit) : "") + (label2 ? elementXml(
14613
14846
  "dispUnitsLbl",
14614
- layoutXml(context, label4.layout) + chartTextXml(context, label4.tx, false) + shapePropertiesXml(context, label4.spPr) + textBodyXml(context, label4.txPr)
14847
+ layoutXml(context, label2.layout) + chartTextXml(context, label2.tx, false) + shapePropertiesXml(context, label2.spPr) + textBodyXml(context, label2.txPr)
14615
14848
  ) : "") + raw(context, units.extLst)
14616
14849
  );
14617
14850
  }
@@ -14636,11 +14869,11 @@ function axisXml(context, axis) {
14636
14869
  }
14637
14870
 
14638
14871
  // chart/write-analysis.ts
14639
- function trendlineLabelXml(context, label4) {
14640
- if (!label4) return "";
14872
+ function trendlineLabelXml(context, label2) {
14873
+ if (!label2) return "";
14641
14874
  return elementXml(
14642
14875
  "trendlineLbl",
14643
- layoutXml(context, label4.layout) + chartTextXml(context, label4.tx, false) + numberFormatXml(label4.numberFormat) + shapePropertiesXml(context, label4.spPr) + textBodyXml(context, label4.txPr) + raw(context, label4.extLst)
14876
+ layoutXml(context, label2.layout) + chartTextXml(context, label2.tx, false) + numberFormatXml(label2.numberFormat) + shapePropertiesXml(context, label2.spPr) + textBodyXml(context, label2.txPr) + raw(context, label2.extLst)
14644
14877
  );
14645
14878
  }
14646
14879
  function trendlineXml(context, trendline) {
@@ -16657,14 +16890,14 @@ function unique(args, ctx) {
16657
16890
  const byCol = args.length > 1 && args[1] !== null && toBool(ctx.toScalar(args[1] ?? null));
16658
16891
  const once = args.length > 2 && args[2] !== null && toBool(ctx.toScalar(args[2] ?? null));
16659
16892
  if (byCol) m = transpose(m);
16660
- const keyOf2 = (row2) => JSON.stringify(
16893
+ const keyOf3 = (row2) => JSON.stringify(
16661
16894
  row2.map(
16662
16895
  (v) => isError(v) ? `#${v.error}` : typeof v === "string" ? `s${v.toLowerCase()}` : v
16663
16896
  )
16664
16897
  );
16665
16898
  const counts = /* @__PURE__ */ new Map();
16666
16899
  for (const row2 of m.data) {
16667
- const key = keyOf2(row2);
16900
+ const key = keyOf3(row2);
16668
16901
  const entry3 = counts.get(key);
16669
16902
  if (entry3) entry3.count++;
16670
16903
  else counts.set(key, { row: row2, count: 1 });
@@ -16949,11 +17182,11 @@ function gammaLn(z) {
16949
17182
 
16950
17183
  // xlsx/formula/functions/database.ts
16951
17184
  var C3 = "Database";
16952
- var label3 = (value2) => value2 === null ? "" : typeof value2 === "string" ? value2 : String(value2);
17185
+ var label = (value2) => value2 === null ? "" : typeof value2 === "string" ? value2 : String(value2);
16953
17186
  function tableOf(ctx, value2) {
16954
17187
  const [head, ...records] = ctx.toMatrix(value2 ?? null).data;
16955
17188
  if (!head || records.length === 0) fail(ERR.VALUE);
16956
- return { headers: head.map((v) => label3(v).toLowerCase()), records };
17189
+ return { headers: head.map((v) => label(v).toLowerCase()), records };
16957
17190
  }
16958
17191
  function fieldIndex(table2, field) {
16959
17192
  const value2 = scalar2(field);
@@ -16963,7 +17196,7 @@ function fieldIndex(table2, field) {
16963
17196
  if (index4 < 0 || index4 >= table2.headers.length) fail(ERR.VALUE);
16964
17197
  return index4;
16965
17198
  }
16966
- const index3 = table2.headers.indexOf(label3(value2).toLowerCase());
17199
+ const index3 = table2.headers.indexOf(label(value2).toLowerCase());
16967
17200
  if (index3 < 0) fail(ERR.VALUE);
16968
17201
  return index3;
16969
17202
  }
@@ -16972,7 +17205,7 @@ function recordFilter(table2, criteria) {
16972
17205
  if (!head || rows.length === 0) fail(ERR.VALUE);
16973
17206
  const columns = head.map((name) => {
16974
17207
  if (name === null || name === "") return -1;
16975
- return table2.headers.indexOf(label3(name).toLowerCase());
17208
+ return table2.headers.indexOf(label(name).toLowerCase());
16976
17209
  });
16977
17210
  const alternatives = rows.map(
16978
17211
  (row2) => row2.flatMap((cell, c2) => {
@@ -24187,7 +24420,7 @@ function headerMode(args, i2, ctx, firstRow) {
24187
24420
  if (mode === 1 || mode === 3) return true;
24188
24421
  return fail(ERR.VALUE);
24189
24422
  }
24190
- var keyOf = (values2) => JSON.stringify(values2);
24423
+ var keyOf2 = (values2) => JSON.stringify(values2);
24191
24424
  var plain2 = (v) => v === void 0 || isError(v) ? null : v;
24192
24425
  function compareBy(keys, rows) {
24193
24426
  return (a2, b) => {
@@ -24227,7 +24460,7 @@ function groupby(args, ctx) {
24227
24460
  if (rows.length === 0) fail(ERR.CALC);
24228
24461
  const groups = /* @__PURE__ */ new Map();
24229
24462
  for (const r of rows) {
24230
- const key = keyOf(keysM.data[r]);
24463
+ const key = keyOf2(keysM.data[r]);
24231
24464
  const found = groups.get(key);
24232
24465
  if (found) found.push(r);
24233
24466
  else groups.set(key, [r]);
@@ -24294,8 +24527,8 @@ function pivotby(args, ctx) {
24294
24527
  const colKeys = /* @__PURE__ */ new Map();
24295
24528
  for (const r of used) {
24296
24529
  for (const [map, key] of [
24297
- [rowKeys, keyOf(rowsM.data[r])],
24298
- [colKeys, keyOf(colsM.data[r])]
24530
+ [rowKeys, keyOf2(rowsM.data[r])],
24531
+ [colKeys, keyOf2(colsM.data[r])]
24299
24532
  ]) {
24300
24533
  const found = map.get(key);
24301
24534
  if (found) found.push(r);
@@ -27095,13 +27328,13 @@ function derivedFieldXml(pivot, entry3, date1904) {
27095
27328
  const days = dateGroupDays(entry3.group);
27096
27329
  const labels = dateUnitLabels(entry3.unit, range, days, date1904, entry3.group);
27097
27330
  const base = pivot.fields.indexOf(entry3.group.field);
27098
- return `<cacheField${attrs({ name: encodeEscapes(entry3.name), numFmtId: 0, databaseField: false })}><fieldGroup base="${base}"><rangePr${attrs({ autoStart: entry3.autoStart ? void 0 : false, autoEnd: entry3.autoEnd ? void 0 : false, groupBy: entry3.unit, startDate: serialToIso(range.start, date1904), endDate: serialToIso(range.end, date1904), groupInterval: days > 1 ? days : void 0 })}/><groupItems count="${labels.length}">${labels.map((label4) => `<s v="${escapeAttr3(label4)}"/>`).join("")}</groupItems></fieldGroup></cacheField>`;
27331
+ return `<cacheField${attrs({ name: encodeEscapes(entry3.name), numFmtId: 0, databaseField: false })}><fieldGroup base="${base}"><rangePr${attrs({ autoStart: entry3.autoStart ? void 0 : false, autoEnd: entry3.autoEnd ? void 0 : false, groupBy: entry3.unit, startDate: serialToIso(range.start, date1904), endDate: serialToIso(range.end, date1904), groupInterval: days > 1 ? days : void 0 })}/><groupItems count="${labels.length}">${labels.map((label2) => `<s v="${escapeAttr3(label2)}"/>`).join("")}</groupItems></fieldGroup></cacheField>`;
27099
27332
  }
27100
27333
  function groupXml2(pivot, name, index3) {
27101
27334
  const group = groupOf(pivot, name);
27102
27335
  if (!group) return "";
27103
27336
  const labels = numberGroupLabels(group);
27104
- return `<fieldGroup base="${index3}"><rangePr autoStart="0" autoEnd="0" startNum="${group.start}" endNum="${group.end}" groupInterval="${group.by}"/><groupItems count="${labels.length}">${labels.map((label4) => `<s v="${escapeAttr3(label4)}"/>`).join("")}</groupItems></fieldGroup>`;
27337
+ return `<fieldGroup base="${index3}"><rangePr autoStart="0" autoEnd="0" startNum="${group.start}" endNum="${group.end}" groupInterval="${group.by}"/><groupItems count="${labels.length}">${labels.map((label2) => `<s v="${escapeAttr3(label2)}"/>`).join("")}</groupItems></fieldGroup>`;
27105
27338
  }
27106
27339
  function slicerExt(pivot) {
27107
27340
  if (pivot.slicerCacheId === void 0) return "";
@@ -27161,6 +27394,10 @@ function pivotTableXml(source2, cacheId, cache2) {
27161
27394
  const compact = pivot.layout === "compact";
27162
27395
  const outline = pivot.layout === "compact" || pivot.layout === "outline";
27163
27396
  const top = (pivot.subtotalPosition ?? (outline ? "top" : "bottom")) === "top";
27397
+ const named2 = (field, item) => {
27398
+ const text2 = pivotItemName(pivot, field, item);
27399
+ return text2 === void 0 ? "" : attrs({ n: encodeEscapes(text2) });
27400
+ };
27164
27401
  const fields = pivot.fields.map((name, index3) => {
27165
27402
  const isDate = pivot.dateFields?.includes(name) ?? false;
27166
27403
  const at = rowIdx.indexOf(index3);
@@ -27175,7 +27412,7 @@ function pivotTableXml(source2, cacheId, cache2) {
27175
27412
  custom.map((fn) => [PIVOT_SUBTOTALS[fn].attr, true])
27176
27413
  );
27177
27414
  const entries = automatic ? '<item t="default"/>' : custom.map((fn) => `<item t="${PIVOT_SUBTOTALS[fn].item}"/>`).join("");
27178
- return `<pivotField${attrs({ axis: index3 === page ? "axisPage" : at >= 0 ? "axisRow" : colAt >= 0 ? "axisCol" : void 0, dataField: measures.some((measure) => pivot.fields.indexOf(measure.field) === index3) ? true : void 0, compact, outline, showAll: false, subtotalTop: at >= 0 ? top : void 0, numFmtId: isDate ? 14 : void 0, defaultSubtotal: automatic ? void 0 : false, ...flags })}>${items2 ? `<items count="${items2.length + (automatic ? 1 : custom.length)}">${items2.map((item) => `<item${hidden.has(pivotValueKey(item)) ? ' h="1"' : ""} x="${itemX(index3, item)}"/>`).join("")}${entries}</items>` : ""}${repeated}</pivotField>`;
27415
+ return `<pivotField${attrs({ axis: index3 === page ? "axisPage" : at >= 0 ? "axisRow" : colAt >= 0 ? "axisCol" : void 0, dataField: measures.some((measure) => pivot.fields.indexOf(measure.field) === index3) ? true : void 0, compact, outline, showAll: false, subtotalTop: at >= 0 ? top : void 0, numFmtId: isDate ? 14 : void 0, defaultSubtotal: automatic ? void 0 : false, ...flags })}>${items2 ? `<items count="${items2.length + (automatic ? 1 : custom.length)}">${items2.map((item) => `<item${hidden.has(pivotValueKey(item)) ? ' h="1"' : ""}${named2(name, item)} x="${itemX(index3, item)}"/>`).join("")}${entries}</items>` : ""}${repeated}</pivotField>`;
27179
27416
  }).join("");
27180
27417
  const items = (count2, indices) => Array.from({ length: count2 }, (_v, i2) => `<i><x v="${indices?.[i2] ?? i2}"/></i>`).join("") + '<i t="grand"><x/></i>';
27181
27418
  const header = grid.firstHeaderRow !== void 0 ? grid.firstHeaderRow - pageOffset : col >= 0 ? 1 : grid.firstDataRow - pageOffset - 1;
@@ -27205,6 +27442,15 @@ function pivotTableXml(source2, cacheId, cache2) {
27205
27442
  const root = doc.documentElement;
27206
27443
  root.setAttribute("name", pivot.name);
27207
27444
  root.setAttribute("cacheId", String(cacheId));
27445
+ const caps = pivotCaptions(pivot);
27446
+ root.setAttribute("dataCaption", caps.values);
27447
+ for (const [attribute2, key] of [
27448
+ ["rowHeaderCaption", "rowLabels"],
27449
+ ["colHeaderCaption", "columnLabels"],
27450
+ ["grandTotalCaption", "grandTotal"]
27451
+ ])
27452
+ if (caps[key] !== ENGLISH_PIVOT_CAPTIONS[key] || root.hasAttribute(attribute2))
27453
+ root.setAttribute(attribute2, caps[key]);
27208
27454
  root.setAttribute("dataOnRows", rowsAxis ? "1" : "0");
27209
27455
  if (rowsAxis && valuesAt < rowIdx.length) root.setAttribute("dataPosition", String(valuesAt));
27210
27456
  else root.removeAttribute("dataPosition");
@@ -30011,9 +30257,9 @@ function parseSheet(bound, records, start, globals) {
30011
30257
  default: {
30012
30258
  if (opcode === 157)
30013
30259
  hasAutoFilter = true;
30014
- const label4 = UNSUPPORTED[opcode];
30015
- if (label4)
30016
- addUnique(sheet.unsupported, label4);
30260
+ const label2 = UNSUPPORTED[opcode];
30261
+ if (label2)
30262
+ addUnique(sheet.unsupported, label2);
30017
30263
  }
30018
30264
  }
30019
30265
  }