@evotecit/officeimo 0.1.0 → 0.1.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 (45) hide show
  1. package/README.md +13 -10
  2. package/bundles/officeimo-canopyx.js +813 -358
  3. package/bundles/officeimo-canopyx.mjs +700 -246
  4. package/bundles/officeimo-csv.js +29 -19
  5. package/bundles/officeimo-csv.mjs +17 -7
  6. package/bundles/officeimo-datatables.js +806 -360
  7. package/bundles/officeimo-datatables.mjs +694 -249
  8. package/bundles/officeimo-execution.js +35 -25
  9. package/bundles/officeimo-execution.mjs +17 -7
  10. package/bundles/officeimo-pdf.js +734 -289
  11. package/bundles/officeimo-pdf.mjs +685 -241
  12. package/bundles/officeimo-xlsx.js +88 -77
  13. package/bundles/officeimo-xlsx.mjs +22 -11
  14. package/bundles/officeimo.js +790 -344
  15. package/bundles/officeimo.mjs +680 -235
  16. package/dist/core/index.d.ts +2 -0
  17. package/dist/core/iteration.js +2 -2
  18. package/dist/core/sinks.js +2 -1
  19. package/dist/integrations/canopyx/source.js +13 -7
  20. package/dist/integrations/datatables/snapshot.js +3 -3
  21. package/dist/internal/rows.js +13 -4
  22. package/dist/pdf/document-grouped.js +72 -22
  23. package/dist/pdf/font-resources.js +2 -1
  24. package/dist/pdf/inline-text.js +50 -9
  25. package/dist/pdf/objects.js +188 -11
  26. package/dist/pdf/pages.js +25 -26
  27. package/dist/pdf/paragraph-layout.d.ts +2 -0
  28. package/dist/pdf/paragraph-layout.js +9 -4
  29. package/dist/pdf/session.js +1 -1
  30. package/dist/pdf/settings.d.ts +2 -0
  31. package/dist/pdf/settings.js +27 -2
  32. package/dist/pdf/structure.js +80 -28
  33. package/dist/pdf/table-band-flow.js +26 -11
  34. package/dist/pdf/table-band-plan.js +1 -3
  35. package/dist/pdf/table-layout.d.ts +4 -0
  36. package/dist/pdf/table-layout.js +22 -10
  37. package/dist/pdf/table-structure.js +28 -12
  38. package/dist/pdf/text.js +5 -0
  39. package/dist/pdf/types.d.ts +4 -2
  40. package/dist/pdf/xref.d.ts +1 -0
  41. package/dist/pdf/xref.js +30 -0
  42. package/dist/xlsx/values.js +3 -2
  43. package/dist/zip/entry.js +1 -1
  44. package/dist/zip/index.js +1 -1
  45. package/package.json +1 -1
@@ -42,10 +42,10 @@ _modules.set("d5c945064d81fdd257960f48c421125e106e5f270427d170bb05587dd96a44ea",
42
42
  return _exports;
43
43
  })();
44
44
 
45
- const _m4 = _modules.get("1ae4f4554ececbf0fc1e5d32f40275e35f228dca922cfc0760ae681fd9690d7e") ?? (() => {
45
+ const _m4 = _modules.get("87c24efeaa0f1579c19afeeb4918caeb4f8f65a88d24a246e2cfd712b37dbac3") ?? (() => {
46
46
  function checkAbort(signal) {
47
47
  if (signal?.aborted)
48
- throw signal.reason ?? new DOMException("Export cancelled.", "AbortError");
48
+ throw signal.reason;
49
49
  }
50
50
  /** Race a pending producer or sink operation without leaving abort listeners behind. */
51
51
  function withAbort(promise, signal) {
@@ -53,7 +53,7 @@ function withAbort(promise, signal) {
53
53
  return Promise.resolve(promise);
54
54
  return new Promise((resolve, reject) => {
55
55
  const cleanup = () => signal.removeEventListener("abort", abort);
56
- const abort = () => { cleanup(); reject(signal.reason ?? new DOMException("Export cancelled.", "AbortError")); };
56
+ const abort = () => { cleanup(); reject(signal.reason); };
57
57
  signal.addEventListener("abort", abort, { once: true });
58
58
  Promise.resolve(promise).then(value => { cleanup(); resolve(value); }, error => { cleanup(); reject(error); });
59
59
  if (signal.aborted)
@@ -193,11 +193,11 @@ function pause() {
193
193
  });
194
194
  }
195
195
  const _exports = Object.freeze({ checkAbort: checkAbort, withAbort: withAbort, inputRows: inputRows, rowsFromBatches: rowsFromBatches, concatRows: concatRows, consumeRows: consumeRows, beginTask: beginTask, taskYieldDue: taskYieldDue, pause: pause });
196
- _modules.set("1ae4f4554ececbf0fc1e5d32f40275e35f228dca922cfc0760ae681fd9690d7e", _exports);
196
+ _modules.set("87c24efeaa0f1579c19afeeb4918caeb4f8f65a88d24a246e2cfd712b37dbac3", _exports);
197
197
  return _exports;
198
198
  })();
199
199
 
200
- const _m3 = _modules.get("0c4bd256ca66b488390b27a6d197e5ba99ae051ae662621b67a5e80b0479eefc") ?? (() => {
200
+ const _m3 = _modules.get("5337d1e3bd5ae0c1d10a476fcd31540d20337ccf7aa93c7e9e26c2b1a7dab92b") ?? (() => {
201
201
  const { checkAbort, consumeRows, withAbort, pause, taskYieldDue } = _m4;
202
202
 
203
203
  const { OfficeIMOError } = _m2;
@@ -207,8 +207,9 @@ async function withDestination(destination, operation) {
207
207
  // Native streams can belong to another browser realm; constructor identity is not portable.
208
208
  if (destination && typeof destination.getWriter === "function") {
209
209
  const writer = destination.getWriter();
210
+ // Native streams may retain accepted chunks after write resolves.
210
211
  try {
211
- return await operation({ write: bytes => writer.write(bytes) });
212
+ return await operation({ write: bytes => writer.write(new Uint8Array(bytes)) });
212
213
  }
213
214
  finally {
214
215
  writer.releaseLock();
@@ -302,7 +303,7 @@ async function writeBytes(source, sink, signal) {
302
303
  });
303
304
  }
304
305
  const _exports = Object.freeze({ withDestination: withDestination, BlobByteSink: BlobByteSink, ChunkedTextSink: ChunkedTextSink, writeBytes: writeBytes });
305
- _modules.set("0c4bd256ca66b488390b27a6d197e5ba99ae051ae662621b67a5e80b0479eefc", _exports);
306
+ _modules.set("5337d1e3bd5ae0c1d10a476fcd31540d20337ccf7aa93c7e9e26c2b1a7dab92b", _exports);
306
307
  return _exports;
307
308
  })();
308
309
 
@@ -499,7 +500,7 @@ _modules.set("42faf379960e5674a6fdfa8c8fca0bb68bbd74587231248d2524d7004def3671",
499
500
  return _exports;
500
501
  })();
501
502
 
502
- const _m11 = _modules.get("c15eede1e0b2a0a81c7153114bbb20e411413650f1c70c29bbda627241c59dbd") ?? (() => {
503
+ const _m11 = _modules.get("0391fe35ea7d02b25804ab4d0e7543136d6bb615f368f268c74aa135f23aa6bc") ?? (() => {
503
504
  const { assertExportValue } = _m5;
504
505
 
505
506
  const { checkAbort } = _m4;
@@ -512,11 +513,18 @@ function createRowProjector(columns, worksheet, signal, validate = assertExportV
512
513
  const getters = columns.some(column => column.value);
513
514
  return (row, rowIndex = 0) => {
514
515
  if (Array.isArray(row) && !getters) {
515
- if (row.length > columns.length)
516
+ const length = row.length;
517
+ if (length > columns.length)
516
518
  throw new RangeError("Row has more values than declared columns.");
517
- for (const value of row)
519
+ // Resolve each positional value once, just like key/value projections. Returning the
520
+ // source array would let an accessor change a value after the portable-value check.
521
+ const values = new Array(length);
522
+ for (let index = 0; index < length; index++) {
523
+ const value = row[index];
518
524
  validate(value);
519
- return row;
525
+ values[index] = value;
526
+ }
527
+ return values;
520
528
  }
521
529
  if (!row || typeof row !== "object" || isDate(row))
522
530
  throw new TypeError("A row must be an array or object.");
@@ -545,7 +553,7 @@ function createRowProjector(columns, worksheet, signal, validate = assertExportV
545
553
  };
546
554
  }
547
555
  /** @internal Shared metadata fields for full columns and adapter-owned partial overrides. */
548
- const columnOptionFields = ["header", "key", "value", "width", "type", "format", "wrapText", "alignment", "groups", "style", "valueFormatter"];
556
+ const columnOptionFields = ["header", "key", "value", "width", "type", "format", "wrapText", "alignment", "rowHeader", "groups", "style", "valueFormatter"];
549
557
  function copyColumns(columns, workbookStyles = false) {
550
558
  if (!Array.isArray(columns))
551
559
  throw new TypeError("Declare the columns in export order.");
@@ -561,6 +569,8 @@ function copyColumns(columns, workbookStyles = false) {
561
569
  throw new TypeError("Each column needs a string header and an optional string key.");
562
570
  if (captured.value !== undefined && typeof captured.value !== "function")
563
571
  throw new TypeError("Column value getters must be functions.");
572
+ if (captured.rowHeader !== undefined && typeof captured.rowHeader !== "boolean")
573
+ throw new TypeError("Column rowHeader must be boolean.");
564
574
  if (captured.groups !== undefined) {
565
575
  if (!Array.isArray(captured.groups))
566
576
  throw new TypeError("Column groups must be an array of strings.");
@@ -573,7 +583,7 @@ function copyColumns(columns, workbookStyles = false) {
573
583
  });
574
584
  }
575
585
  const _exports = Object.freeze({ createRowProjector: createRowProjector, columnOptionFields: columnOptionFields, copyColumns: copyColumns });
576
- _modules.set("c15eede1e0b2a0a81c7153114bbb20e411413650f1c70c29bbda627241c59dbd", _exports);
586
+ _modules.set("0391fe35ea7d02b25804ab4d0e7543136d6bb615f368f268c74aa135f23aa6bc", _exports);
577
587
  return _exports;
578
588
  })();
579
589
 
@@ -647,7 +657,7 @@ _modules.set("e95bb0e3f342d1379b67a3d541fa808e06361da8460169a6aec152ee7deb69b2",
647
657
  return _exports;
648
658
  })();
649
659
 
650
- const _m8 = _modules.get("18d120e0ba2b5d6d4a098d72a6f558dec1c936c1f1a0e4996c6d240a928c931e") ?? (() => {
660
+ const _m8 = _modules.get("046b305cdccf817d847addb75a778131622de23f2840830bbe1c0c26053a68c0") ?? (() => {
651
661
  const { ExportCell, assertScalar } = _m5;
652
662
 
653
663
  const { isDate } = _m6;
@@ -909,11 +919,11 @@ function createGroupedReport(rows, options) {
909
919
  return source;
910
920
  }
911
921
  const _exports = Object.freeze({ assertGroupedReportSource: assertGroupedReportSource, groupedReportEvents: groupedReportEvents, groupedReportOperation: groupedReportOperation, createGroupedReport: createGroupedReport });
912
- _modules.set("18d120e0ba2b5d6d4a098d72a6f558dec1c936c1f1a0e4996c6d240a928c931e", _exports);
922
+ _modules.set("046b305cdccf817d847addb75a778131622de23f2840830bbe1c0c26053a68c0", _exports);
913
923
  return _exports;
914
924
  })();
915
925
 
916
- const _m1 = _modules.get("4af46fa949e848316dc59f9073630c7949316a763a7c9a753335d276c580b8e6") ?? (() => {
926
+ const _m1 = _modules.get("81b3d47c02b7d8443b79e02b3cfb52032d6b73d9a3fb592b777ebe028ad0ef00") ?? (() => {
917
927
 
918
928
 
919
929
 
@@ -958,7 +968,7 @@ function saveBlob(blob, fileName) {
958
968
  }
959
969
  }
960
970
  const _exports = Object.freeze({ OfficeIMOError: _m2.OfficeIMOError, NotSupportedError: _m2.NotSupportedError, BlobByteSink: _m3.BlobByteSink, ChunkedTextSink: _m3.ChunkedTextSink, writeBytes: _m3.writeBytes, ExportCell: _m5.ExportCell, createGroupedReport: _m8.createGroupedReport, checkAbort: _m4.checkAbort, withAbort: _m4.withAbort, inputRows: _m4.inputRows, pause: _m4.pause, detectFeatures: detectFeatures, saveBlob: saveBlob });
961
- _modules.set("4af46fa949e848316dc59f9073630c7949316a763a7c9a753335d276c580b8e6", _exports);
971
+ _modules.set("81b3d47c02b7d8443b79e02b3cfb52032d6b73d9a3fb592b777ebe028ad0ef00", _exports);
962
972
  return _exports;
963
973
  })();
964
974
 
@@ -1187,7 +1197,7 @@ _modules.set("9b33d9107e62ba8299c576072de40d24a261464f118de4ace64f23154fc78307",
1187
1197
  return _exports;
1188
1198
  })();
1189
1199
 
1190
- const _m17 = _modules.get("87a3335ede8f46b6e42f2c03e68f3df802321aa23c52dc4cdfb11165529a5270") ?? (() => {
1200
+ const _m17 = _modules.get("4a089607f7cbe50e13d4382d1cc4e5f6ce32c5773bbec2df84178710f54d9a38") ?? (() => {
1191
1201
  const { OfficeIMOError } = _m2;
1192
1202
 
1193
1203
  const { ExportBudget } = _m9;
@@ -1262,10 +1272,34 @@ function captureWideTable(input) {
1262
1272
  if (repeatColumns !== undefined && !Array.isArray(repeatColumns))
1263
1273
  throw new TypeError("repeatColumns must be an array.");
1264
1274
  const repeats = repeatColumns === undefined ? [] : [...repeatColumns];
1265
- if (repeats.some((value, index) => !Number.isSafeInteger(value) || value < 0 || index > 0 && value <= repeats[index - 1]))
1266
- throw new RangeError("repeatColumns must contain sorted unique nonnegative indices.");
1275
+ if (repeats.some(value => typeof value === "number" ? !Number.isSafeInteger(value) || value < 0 : typeof value !== "string" || !value.length))
1276
+ throw new RangeError("repeatColumns must contain nonnegative indices or nonempty stable keys.");
1277
+ if (repeats.every(value => typeof value === "number") && repeats.some((value, index) => index > 0 && value <= repeats[index - 1]))
1278
+ throw new RangeError("Numeric repeatColumns must contain sorted unique nonnegative indices.");
1267
1279
  return Object.freeze({ mode, ...(minimumColumnWidth === undefined ? {} : { minimumColumnWidth }), repeatColumns: Object.freeze(repeats) });
1268
1280
  }
1281
+ /** Resolve identities against this table's captured selection, without consulting a grid or opening its rows. */
1282
+ function repeatedColumns(policy, columns) {
1283
+ if (typeof policy !== "object")
1284
+ return Object.freeze([]);
1285
+ const selected = new Set();
1286
+ for (const selector of policy.repeatColumns ?? []) {
1287
+ let position;
1288
+ if (typeof selector === "number")
1289
+ position = selector;
1290
+ else {
1291
+ position = columns.findIndex(column => column.key === selector);
1292
+ if (position < 0 || columns.some((column, index) => index !== position && column.key === selector))
1293
+ throw new TypeError("repeatColumns requires an unambiguous selected column key: " + selector);
1294
+ }
1295
+ if (position >= columns.length)
1296
+ throw new RangeError("repeatColumns index exceeds the declared columns.");
1297
+ if (selected.has(position))
1298
+ throw new TypeError("repeatColumns selects the same column more than once.");
1299
+ selected.add(position);
1300
+ }
1301
+ return Object.freeze([...selected].sort((left, right) => left - right));
1302
+ }
1269
1303
  function settings(input, document = false) {
1270
1304
  const configuration = { ...capturePdfOptions(input) };
1271
1305
  configuration.booleanText = captureBooleanText(configuration.booleanText);
@@ -1367,10 +1401,11 @@ function settings(input, document = false) {
1367
1401
  }
1368
1402
  const maxImageWorkingBytes = options.limits?.maxImageWorkingBytes;
1369
1403
  return { options: { ...options, paragraphStyles }, paragraphStyles, page, margins, fontSize, padding,
1404
+ repeatedColumns: document ? Object.freeze([]) : repeatedColumns(options.wideTable, columns),
1370
1405
  limits: { ...limits, ...(maxImageWorkingBytes === undefined ? {} : { maxImageWorkingBytes }) }, budget };
1371
1406
  }
1372
1407
  const _exports = Object.freeze({ positive: _m20.positive, color: _m20.color, presentation: _m20.presentation, pdfOptionFields: pdfOptionFields, pdfLimitFields: pdfLimitFields, capturePdfOptions: capturePdfOptions, capturePdfLimits: capturePdfLimits, captureWideTable: captureWideTable, settings: settings });
1373
- _modules.set("87a3335ede8f46b6e42f2c03e68f3df802321aa23c52dc4cdfb11165529a5270", _exports);
1408
+ _modules.set("4a089607f7cbe50e13d4382d1cc4e5f6ce32c5773bbec2df84178710f54d9a38", _exports);
1374
1409
  return _exports;
1375
1410
  })();
1376
1411
 
@@ -1397,7 +1432,7 @@ _modules.set("e00bc0213b723678d050e3e1f11b39ed3d6b0b0fd6a39b403beb1a6bef69e282",
1397
1432
  return _exports;
1398
1433
  })();
1399
1434
 
1400
- const _m15 = _modules.get("46b68ddd3bfb2a9f845c2684cd1de5fc4212610a87dc8da7d3e35fefc2a34367") ?? (() => {
1435
+ const _m15 = _modules.get("58066519dce31ad3bb7f5f5c377585d3374a84578358ad519e2c021efa1a26f8") ?? (() => {
1401
1436
  const { captureFields } = _m10;
1402
1437
 
1403
1438
  const { ExportBudget } = _m9;
@@ -1438,7 +1473,7 @@ function capturePdfOptions(input = {}) {
1438
1473
  return { ...options, ...(options.limits === undefined ? {} : { limits: capturePdfLimits(options.limits) }) };
1439
1474
  }
1440
1475
  const _exports = Object.freeze({ captureCommonLimits: captureCommonLimits, mergeAdapterLimits: mergeAdapterLimits, captureXlsxOptions: captureXlsxOptions, captureCsvOptions: captureCsvOptions, capturePdfOptions: capturePdfOptions });
1441
- _modules.set("46b68ddd3bfb2a9f845c2684cd1de5fc4212610a87dc8da7d3e35fefc2a34367", _exports);
1476
+ _modules.set("58066519dce31ad3bb7f5f5c377585d3374a84578358ad519e2c021efa1a26f8", _exports);
1442
1477
  return _exports;
1443
1478
  })();
1444
1479
 
@@ -1490,7 +1525,7 @@ _modules.set("8ece66b561682170c879991995105163f4c484c8355d5e451fc6f52a9fbc3f82",
1490
1525
  return _exports;
1491
1526
  })();
1492
1527
 
1493
- const _m28 = _modules.get("47668dc33afddf93a09736e08c39f34d52518f2bf719e5ef386363758f42e4b7") ?? (() => {
1528
+ const _m28 = _modules.get("2b85e926659d505b8142c9f8a4d8faf64a695a97dea19022031415c30e63d364") ?? (() => {
1494
1529
  const { OfficeIMOError } = _m2;
1495
1530
 
1496
1531
  const { ChunkedTextSink } = _m3;
@@ -1568,11 +1603,11 @@ class XmlWriter {
1568
1603
  throw new OfficeIMOError("INVALID_STATE", "XML writer is closed."); }
1569
1604
  }
1570
1605
  const _exports = Object.freeze({ xmlDeclaration: xmlDeclaration, cleanXml: cleanXml, escapeXml: escapeXml, escapeOoxmlAttribute: escapeOoxmlAttribute, validateXmlName: validateXmlName, XmlWriter: XmlWriter });
1571
- _modules.set("47668dc33afddf93a09736e08c39f34d52518f2bf719e5ef386363758f42e4b7", _exports);
1606
+ _modules.set("2b85e926659d505b8142c9f8a4d8faf64a695a97dea19022031415c30e63d364", _exports);
1572
1607
  return _exports;
1573
1608
  })();
1574
1609
 
1575
- const _m27 = _modules.get("75f1dfdbbf7685a7bfd416b8d7d4b82698a1852f973cf0264456086cf8c20723") ?? (() => {
1610
+ const _m27 = _modules.get("cd6fbdc4df9506c140f11083b3740d048b39c012670222001051b552dbc7bfb0") ?? (() => {
1576
1611
  const { escapeXml, xmlDeclaration } = _m28;
1577
1612
 
1578
1613
  const { isDate } = _m6;
@@ -1594,7 +1629,7 @@ function appPropertiesXml(properties = {}, policy = "strip") {
1594
1629
  '<Application>' + escapeXml(properties.application ?? "OfficeIMO", policy) + '</Application><Company>' + escapeXml(properties.company ?? "", policy) + '</Company></Properties>';
1595
1630
  }
1596
1631
  const _exports = Object.freeze({ corePropertiesXml: corePropertiesXml, appPropertiesXml: appPropertiesXml });
1597
- _modules.set("75f1dfdbbf7685a7bfd416b8d7d4b82698a1852f973cf0264456086cf8c20723", _exports);
1632
+ _modules.set("cd6fbdc4df9506c140f11083b3740d048b39c012670222001051b552dbc7bfb0", _exports);
1598
1633
  return _exports;
1599
1634
  })();
1600
1635
 
@@ -1621,7 +1656,7 @@ _modules.set("790c15edc51b308be3e7d8222630d407f8c79c31ab21ba0b9f92c00f44ab4021",
1621
1656
  return _exports;
1622
1657
  })();
1623
1658
 
1624
- const _m30 = _modules.get("34b448ff5052fe659ccb250d80fc2a0b13ab82890f50132ef5c9e51da369a582") ?? (() => {
1659
+ const _m30 = _modules.get("597d152d20a2a28ee5cd6d4243a79a71ce8b83769a77441bfc944aadc0a6efbd") ?? (() => {
1625
1660
  const { checkAbort, withAbort } = _m4;
1626
1661
 
1627
1662
  const { OfficeIMOError } = _m2;
@@ -1652,7 +1687,7 @@ class EntryWriter {
1652
1687
  closed = false;
1653
1688
  cleaned = false;
1654
1689
  lifetime = new AbortController();
1655
- abort = () => { this.fail(this.signal?.reason ?? new DOMException("Export cancelled.", "AbortError")); };
1690
+ abort = () => { this.fail(this.signal?.reason); };
1656
1691
  constructor(compression, sink, signal) {
1657
1692
  this.sink = sink;
1658
1693
  this.signal = signal;
@@ -1749,11 +1784,11 @@ class EntryWriter {
1749
1784
  }
1750
1785
  }
1751
1786
  const _exports = Object.freeze({ Crc32: _m31.Crc32, zipLimit: zipLimit, zipSize: zipSize, EntryWriter: EntryWriter });
1752
- _modules.set("34b448ff5052fe659ccb250d80fc2a0b13ab82890f50132ef5c9e51da369a582", _exports);
1787
+ _modules.set("597d152d20a2a28ee5cd6d4243a79a71ce8b83769a77441bfc944aadc0a6efbd", _exports);
1753
1788
  return _exports;
1754
1789
  })();
1755
1790
 
1756
- const _m29 = _modules.get("cc7c3953e35bb436d0f5fe5c35a60b7e97a00d2e729df52d219d9e246f326b32") ?? (() => {
1791
+ const _m29 = _modules.get("699a019e0c3f317a62bf3a6e59b76b6cf1645908b0f1b1f157c18f4d4f368dfb") ?? (() => {
1757
1792
 
1758
1793
 
1759
1794
  const { EntryWriter, zipSize } = _m30;
@@ -1817,7 +1852,7 @@ class ZipWriter {
1817
1852
  /** Pending header/directory writes and source reads must also stop on explicit discard. */
1818
1853
  async acceptance(operation) {
1819
1854
  const signal = this.options.signal;
1820
- const abort = () => this.lifetime.abort(signal?.reason ?? new DOMException("Export cancelled.", "AbortError"));
1855
+ const abort = () => this.lifetime.abort(signal?.reason);
1821
1856
  signal?.addEventListener("abort", abort, { once: true });
1822
1857
  try {
1823
1858
  checkAbort(signal);
@@ -2009,11 +2044,11 @@ class ZipWriter {
2009
2044
  }
2010
2045
  }
2011
2046
  const _exports = Object.freeze({ Crc32: _m30.Crc32, validateEntryName: validateEntryName, ZipWriter: ZipWriter });
2012
- _modules.set("cc7c3953e35bb436d0f5fe5c35a60b7e97a00d2e729df52d219d9e246f326b32", _exports);
2047
+ _modules.set("699a019e0c3f317a62bf3a6e59b76b6cf1645908b0f1b1f157c18f4d4f368dfb", _exports);
2013
2048
  return _exports;
2014
2049
  })();
2015
2050
 
2016
- const _m25 = _modules.get("c982e9efabd891df539c26c513a3e9cf5a644ae13516f48f9d19f7ed6b584c06") ?? (() => {
2051
+ const _m25 = _modules.get("3bedb42cf4cced6fffb6c1b9e798b93ccb70159cf6cfc582237e723187cc465f") ?? (() => {
2017
2052
 
2018
2053
 
2019
2054
 
@@ -2258,7 +2293,7 @@ class OpcPackage {
2258
2293
  }
2259
2294
  }
2260
2295
  const _exports = Object.freeze({ partUri: _m26.partUri, relationshipPartUri: _m26.relationshipPartUri, relativePartTarget: _m26.relativePartTarget, corePropertiesXml: _m27.corePropertiesXml, appPropertiesXml: _m27.appPropertiesXml, relationshipsNamespace: relationshipsNamespace, officeRelationshipsNamespace: officeRelationshipsNamespace, contentTypesNamespace: contentTypesNamespace, relationshipTypes: relationshipTypes, ContentTypes: ContentTypes, OpcPackage: OpcPackage });
2261
- _modules.set("c982e9efabd891df539c26c513a3e9cf5a644ae13516f48f9d19f7ed6b584c06", _exports);
2296
+ _modules.set("3bedb42cf4cced6fffb6c1b9e798b93ccb70159cf6cfc582237e723187cc465f", _exports);
2262
2297
  return _exports;
2263
2298
  })();
2264
2299
 
@@ -2274,7 +2309,7 @@ _modules.set("204def412284dfb11df9aececd57c8c0455db2927ebdb483dd255e7b29f6f359",
2274
2309
  return _exports;
2275
2310
  })();
2276
2311
 
2277
- const _m34 = _modules.get("27f56318b4276c3e6f79cfb300855315ff9cd1897d4748fa2f306b2deef98c36") ?? (() => {
2312
+ const _m34 = _modules.get("2c814aac0c36fa7d9a1fb54d327695a3655309ef22db0c10974813f8f9d4d6ae") ?? (() => {
2278
2313
  const { OfficeIMOError } = _m2;
2279
2314
 
2280
2315
  const { cleanXml, escapeOoxmlAttribute } = _m28;
@@ -2381,11 +2416,11 @@ function differentialXml(style, policy, numberFormat) {
2381
2416
  return xml;
2382
2417
  }
2383
2418
  const _exports = Object.freeze({ fields: fields, optionalBoolean: optionalBoolean, DifferentialStyles: DifferentialStyles, differentialXml: differentialXml });
2384
- _modules.set("27f56318b4276c3e6f79cfb300855315ff9cd1897d4748fa2f306b2deef98c36", _exports);
2419
+ _modules.set("2c814aac0c36fa7d9a1fb54d327695a3655309ef22db0c10974813f8f9d4d6ae", _exports);
2385
2420
  return _exports;
2386
2421
  })();
2387
2422
 
2388
- const _m32 = _modules.get("bf7ec82677b616a41d07306ba385b32456bc03509817c13bbe65a1ba390a6253") ?? (() => {
2423
+ const _m32 = _modules.get("a4ad9a4388ed41b6b7ce4f5a20c44598082db5adc307e96d12de2840e9508d7e") ?? (() => {
2389
2424
  const { escapeOoxmlAttribute, cleanXml, xmlDeclaration } = _m28;
2390
2425
 
2391
2426
  const { OfficeIMOError } = _m2;
@@ -2595,11 +2630,11 @@ class StyleRegistry {
2595
2630
  }
2596
2631
  }
2597
2632
  const _exports = Object.freeze({ colorArgb: _m33.colorArgb, spreadsheetNamespace: spreadsheetNamespace, NumberFormats: NumberFormats, validateStylePatch: validateStylePatch, copyStylePatch: copyStylePatch, StyleRegistry: StyleRegistry });
2598
- _modules.set("bf7ec82677b616a41d07306ba385b32456bc03509817c13bbe65a1ba390a6253", _exports);
2633
+ _modules.set("a4ad9a4388ed41b6b7ce4f5a20c44598082db5adc307e96d12de2840e9508d7e", _exports);
2599
2634
  return _exports;
2600
2635
  })();
2601
2636
 
2602
- const _m36 = _modules.get("6d0c9930eb0b5d96d92b93ba72759417a324dfd119a592c5a2ee4de0ff3495ec") ?? (() => {
2637
+ const _m36 = _modules.get("bf52f9d5aae9685c7fc71f3e5d6cf248beef190df1f28f89d27617e1c2023429") ?? (() => {
2603
2638
  const { NotSupportedError } = _m2;
2604
2639
 
2605
2640
  const { cleanXml, escapeXml } = _m28;
@@ -2707,11 +2742,11 @@ function formulaXml(cell) {
2707
2742
  return "<f>" + escapeXml(cell.formula, "reject") + "</f><v>" + (cell.cachedValue ?? "") + "</v>";
2708
2743
  }
2709
2744
  const _exports = Object.freeze({ FormulaCell: FormulaCell, isSubtotalFormula: isSubtotalFormula, formulaXml: formulaXml });
2710
- _modules.set("6d0c9930eb0b5d96d92b93ba72759417a324dfd119a592c5a2ee4de0ff3495ec", _exports);
2745
+ _modules.set("bf52f9d5aae9685c7fc71f3e5d6cf248beef190df1f28f89d27617e1c2023429", _exports);
2711
2746
  return _exports;
2712
2747
  })();
2713
2748
 
2714
- const _m35 = _modules.get("45bcbd0fd875662d537921217d5e747170e665dedc70927041f59d5782ed21b0") ?? (() => {
2749
+ const _m35 = _modules.get("597ac0803c83556e97bf37d53e2a3aef4351032669f740ebcf8a06369bf940ed") ?? (() => {
2715
2750
  const { cleanXml, escapeXml } = _m28;
2716
2751
 
2717
2752
  const { assertExportValue, assertScalar } = _m5;
@@ -2775,12 +2810,13 @@ function sheetName(requested, names, policy, register = true) {
2775
2810
  throw new TypeError("Sheet name must be a string.");
2776
2811
  // Validate and deduplicate the decoded literal value, before ST_Xstring attribute encoding.
2777
2812
  // A requested _xHHHH_ token is literal text; the serializer protects its leading underscore.
2778
- let base = cleanXml(requested, policy).replace(/[\[\]:*?/\\]/g, "_").trim().replace(/^'+|'+$/g, "").trim();
2813
+ let base = cleanXml(requested, policy).replace(/[\[\]:*?/\\]/g, "_").replace(/^[\s']+|[\s']+$/g, "");
2814
+ // Clipping can expose an internal apostrophe or the reserved History name.
2815
+ base = clipName(base, 31).replace(/[\s']+$/g, "");
2779
2816
  if (!base)
2780
2817
  base = "Sheet";
2781
2818
  if (base.toLowerCase() === "history")
2782
2819
  base += "_";
2783
- base = clipName(base, 31);
2784
2820
  let name = base, suffix = 2;
2785
2821
  while (names.has(name.toLowerCase())) {
2786
2822
  const tail = " (" + suffix++ + ")";
@@ -2803,11 +2839,11 @@ function excelDate(date, mode) {
2803
2839
  return (time - Date.UTC(1899, 11, 31)) / 86400000 + (time >= Date.UTC(1900, 2, 1) ? 1 : 0);
2804
2840
  }
2805
2841
  const _exports = Object.freeze({ Cell: Cell, assertXlsxValue: assertXlsxValue, copyValue: copyValue, cellText: cellText, inlineText: inlineText, columnName: columnName, sheetName: sheetName, excelDate: excelDate });
2806
- _modules.set("45bcbd0fd875662d537921217d5e747170e665dedc70927041f59d5782ed21b0", _exports);
2842
+ _modules.set("597ac0803c83556e97bf37d53e2a3aef4351032669f740ebcf8a06369bf940ed", _exports);
2807
2843
  return _exports;
2808
2844
  })();
2809
2845
 
2810
- const _m39 = _modules.get("7e3adf1ed8ebd3d36cf5e10c55f94387f7044e585e7a1e14fbf597db4e2e4fea") ?? (() => {
2846
+ const _m39 = _modules.get("abbe9e1ad9c0a68c86d0f20348fd324b7eef48b857c0bd9aa04e8959a7e70622") ?? (() => {
2811
2847
  const { ChunkedTextSink } = _m3;
2812
2848
 
2813
2849
  const { escapeXml, xmlDeclaration } = _m28;
@@ -2916,11 +2952,11 @@ async function writeChartXml(chart, destination, policy, signal) {
2916
2952
  await text.close();
2917
2953
  }
2918
2954
  const _exports = Object.freeze({ chartNamespace: chartNamespace, chartContentType: chartContentType, chartAnchorXml: chartAnchorXml, writeChartXml: writeChartXml });
2919
- _modules.set("7e3adf1ed8ebd3d36cf5e10c55f94387f7044e585e7a1e14fbf597db4e2e4fea", _exports);
2955
+ _modules.set("abbe9e1ad9c0a68c86d0f20348fd324b7eef48b857c0bd9aa04e8959a7e70622", _exports);
2920
2956
  return _exports;
2921
2957
  })();
2922
2958
 
2923
- const _m38 = _modules.get("2a8fdd646d18edd986a29c54b3860ff16650da92d97b03a7cdd3cacd843c5246") ?? (() => {
2959
+ const _m38 = _modules.get("0afdc9d464a68ac5ace8863d7c6e25862748c96faa03ed7b8e46402515a552b8") ?? (() => {
2924
2960
  const { cleanXml, escapeXml, escapeOoxmlAttribute, xmlDeclaration } = _m28;
2925
2961
 
2926
2962
  const { copyExportLink } = _m7;
@@ -2994,11 +3030,11 @@ function drawingXml(images, policy, charts = []) {
2994
3030
  }
2995
3031
  const drawingContentType = "application/vnd.openxmlformats-officedocument.drawing+xml";
2996
3032
  const _exports = Object.freeze({ copyDrawingAnchor: copyDrawingAnchor, cellPosition: cellPosition, copyHyperlink: copyHyperlink, copyImage: copyImage, hyperlinksXml: hyperlinksXml, drawingXml: drawingXml, drawingContentType: drawingContentType });
2997
- _modules.set("2a8fdd646d18edd986a29c54b3860ff16650da92d97b03a7cdd3cacd843c5246", _exports);
3033
+ _modules.set("0afdc9d464a68ac5ace8863d7c6e25862748c96faa03ed7b8e46402515a552b8", _exports);
2998
3034
  return _exports;
2999
3035
  })();
3000
3036
 
3001
- const _m41 = _modules.get("dbb48ba4ffa2659e2972a395c603d203c11ea8addb71c38103c006d6d7937506") ?? (() => {
3037
+ const _m41 = _modules.get("e2e414a8ba22e778a769375327988cd080347bbbc863673a702e1dcfa6e9112a") ?? (() => {
3002
3038
  const { OfficeIMOError } = _m2;
3003
3039
 
3004
3040
  const { cellPosition } = _m38;
@@ -3099,11 +3135,11 @@ class MergeRegions {
3099
3135
  throw new RangeError("Merged ranges must stay within exported rows."); }
3100
3136
  }
3101
3137
  const _exports = Object.freeze({ MergeRegions: MergeRegions });
3102
- _modules.set("dbb48ba4ffa2659e2972a395c603d203c11ea8addb71c38103c006d6d7937506", _exports);
3138
+ _modules.set("e2e414a8ba22e778a769375327988cd080347bbbc863673a702e1dcfa6e9112a", _exports);
3103
3139
  return _exports;
3104
3140
  })();
3105
3141
 
3106
- const _m42 = _modules.get("b9d400aa8d995edccef22cef96a0e14cb28ce2071c42d8cf29de94d74fe82355") ?? (() => {
3142
+ const _m42 = _modules.get("ac538bedcdc7144616b2777232e7049d2fd6449a087017fd9c10d31e0f86b292") ?? (() => {
3107
3143
  const { ExportCell } = _m5;
3108
3144
 
3109
3145
  const { tableSpans } = _m18;
@@ -3136,11 +3172,11 @@ class StructuredRows {
3136
3172
  }
3137
3173
  }
3138
3174
  const _exports = Object.freeze({ StructuredRows: StructuredRows });
3139
- _modules.set("b9d400aa8d995edccef22cef96a0e14cb28ce2071c42d8cf29de94d74fe82355", _exports);
3175
+ _modules.set("ac538bedcdc7144616b2777232e7049d2fd6449a087017fd9c10d31e0f86b292", _exports);
3140
3176
  return _exports;
3141
3177
  })();
3142
3178
 
3143
- const _m40 = _modules.get("26966342ea634f631f6b1e684842fb8d3a01e38fe33cac9b74261ba9ff4c11cb") ?? (() => {
3179
+ const _m40 = _modules.get("47c0c236e4ae7b71726d1d7ebe0d2df8f0eb9204b3865adf34b5163f720d4bd5") ?? (() => {
3144
3180
  const { ExportCell } = _m5;
3145
3181
 
3146
3182
  const { isDate } = _m6;
@@ -3337,11 +3373,11 @@ function printXml(options, policy) {
3337
3373
  (options.footer === undefined ? "" : '<oddFooter>' + escapeOoxmlAttribute("&C" + options.footer.replace(/&/g, "&&"), policy) + '</oddFooter>') + '</headerFooter>' : "");
3338
3374
  }
3339
3375
  const _exports = Object.freeze({ ComputedTotal: ComputedTotal, ReportLayout: ReportLayout, totalFormula: totalFormula, printXml: printXml });
3340
- _modules.set("26966342ea634f631f6b1e684842fb8d3a01e38fe33cac9b74261ba9ff4c11cb", _exports);
3376
+ _modules.set("47c0c236e4ae7b71726d1d7ebe0d2df8f0eb9204b3865adf34b5163f720d4bd5", _exports);
3341
3377
  return _exports;
3342
3378
  })();
3343
3379
 
3344
- const _m44 = _modules.get("4d984092c5be653d0d5c8c910638fe0c0d560f8e74ea34c1a7b52b24be29fbf5") ?? (() => {
3380
+ const _m44 = _modules.get("93ad877d48a12898018a8842f86e9c1a073ae9d16e4ddbdf0de422fdb7567732") ?? (() => {
3345
3381
  const { columnName } = _m35;
3346
3382
 
3347
3383
  /** @internal Data-column selectors use stable keys or one-based worksheet columns. */
@@ -3368,11 +3404,11 @@ function qualifiedCell(sheetName, column, row) {
3368
3404
  return qualifiedColumnRange(sheetName, column, row, 1).split(":")[0];
3369
3405
  }
3370
3406
  const _exports = Object.freeze({ resolveDataColumn: resolveDataColumn, qualifiedColumnRange: qualifiedColumnRange, qualifiedCell: qualifiedCell });
3371
- _modules.set("4d984092c5be653d0d5c8c910638fe0c0d560f8e74ea34c1a7b52b24be29fbf5", _exports);
3407
+ _modules.set("93ad877d48a12898018a8842f86e9c1a073ae9d16e4ddbdf0de422fdb7567732", _exports);
3372
3408
  return _exports;
3373
3409
  })();
3374
3410
 
3375
- const _m45 = _modules.get("216c77d37374c34583daebcedae5d725280614b84266d0048b25fc94d816bbad") ?? (() => {
3411
+ const _m45 = _modules.get("e988da1cd05e9b574b66f0b3e28e40168bcc06e9ec1cdb023e42f358770b7fad") ?? (() => {
3376
3412
  const { OfficeIMOError } = _m2;
3377
3413
 
3378
3414
  const { columnName } = _m35;
@@ -3415,11 +3451,11 @@ function dataRowReference(firstColumn, lastColumn, headerRows, dataRows, ranges)
3415
3451
  return reference || undefined;
3416
3452
  }
3417
3453
  const _exports = Object.freeze({ retainDataRowRanges: retainDataRowRanges, dataRowRanges: dataRowRanges, dataRowCount: dataRowCount, dataRowReference: dataRowReference });
3418
- _modules.set("216c77d37374c34583daebcedae5d725280614b84266d0048b25fc94d816bbad", _exports);
3454
+ _modules.set("e988da1cd05e9b574b66f0b3e28e40168bcc06e9ec1cdb023e42f358770b7fad", _exports);
3419
3455
  return _exports;
3420
3456
  })();
3421
3457
 
3422
- const _m43 = _modules.get("a1fdc34474873603d9907928d65684efabe0bfce470a26305f49b46b5fb5b12a") ?? (() => {
3458
+ const _m43 = _modules.get("f1cb0c25677191521382757695257e846c3da2c5657cd5b640aea352094162e6") ?? (() => {
3423
3459
  const { cleanXml, escapeXml, escapeOoxmlAttribute } = _m28;
3424
3460
 
3425
3461
  const { cellPosition } = _m38;
@@ -3585,11 +3621,11 @@ class ConditionalFormats {
3585
3621
  }
3586
3622
  }
3587
3623
  const _exports = Object.freeze({ prepareConditionalFormats: prepareConditionalFormats, ConditionalFormats: ConditionalFormats });
3588
- _modules.set("a1fdc34474873603d9907928d65684efabe0bfce470a26305f49b46b5fb5b12a", _exports);
3624
+ _modules.set("f1cb0c25677191521382757695257e846c3da2c5657cd5b640aea352094162e6", _exports);
3589
3625
  return _exports;
3590
3626
  })();
3591
3627
 
3592
- const _m46 = _modules.get("082c5d69b3ae3fbd0b4477ae5cfd07155401158d890162c4a223eb67ffeb489b") ?? (() => {
3628
+ const _m46 = _modules.get("cf47c14a3d20ea8306932e3174606385830dd257bdb9ffac8c5114724b4d9257") ?? (() => {
3593
3629
  const { OfficeIMOError } = _m2;
3594
3630
 
3595
3631
  const { checkAbort } = _m4;
@@ -3689,11 +3725,11 @@ function* dataValidationsXml(prepared, headerRows, dataRows, ranges) {
3689
3725
  yield '</dataValidations>';
3690
3726
  }
3691
3727
  const _exports = Object.freeze({ prepareDataValidations: prepareDataValidations, dataValidationsXml: dataValidationsXml });
3692
- _modules.set("082c5d69b3ae3fbd0b4477ae5cfd07155401158d890162c4a223eb67ffeb489b", _exports);
3728
+ _modules.set("cf47c14a3d20ea8306932e3174606385830dd257bdb9ffac8c5114724b4d9257", _exports);
3693
3729
  return _exports;
3694
3730
  })();
3695
3731
 
3696
- const _m37 = _modules.get("5d200c22b866a7be40782b9b348f2ad3b781abd8434f420d780e89aa65ede587") ?? (() => {
3732
+ const _m37 = _modules.get("03e235a81010f60bce2d7cc02a313dd95b5b2b77d09535b160ae02a3556c55b4") ?? (() => {
3697
3733
  const { checkAbort, consumeRows, inputRows, pause, taskYieldDue } = _m4;
3698
3734
 
3699
3735
  const { ChunkedTextSink, BlobByteSink } = _m3;
@@ -4415,11 +4451,11 @@ class Worksheet {
4415
4451
  async discard(error) { this.failed = true; this.error = error; this.pending = []; this.pendingCharacters = 0; this.prepared = undefined; this.buffer = undefined; this.nativeCharts.length = 0; this.chartSources.length = 0; this.output.discard(); await this.entry?.discard(error); }
4416
4452
  }
4417
4453
  const _exports = Object.freeze({ Worksheet: Worksheet });
4418
- _modules.set("5d200c22b866a7be40782b9b348f2ad3b781abd8434f420d780e89aa65ede587", _exports);
4454
+ _modules.set("03e235a81010f60bce2d7cc02a313dd95b5b2b77d09535b160ae02a3556c55b4", _exports);
4419
4455
  return _exports;
4420
4456
  })();
4421
4457
 
4422
- const _m47 = _modules.get("87ebdbcd48a4e7d39257ef5bdfe726a889dbf5eaf3cd3f51a0205bf65090f6cf") ?? (() => {
4458
+ const _m47 = _modules.get("69b817e85a5cf991b2c75390de7cfb5657f53786c2bf2221e310d489f4e50fa0") ?? (() => {
4423
4459
  const { escapeOoxmlAttribute, escapeXml, xmlDeclaration } = _m28;
4424
4460
 
4425
4461
  const { cellText, columnName } = _m35;
@@ -4462,11 +4498,11 @@ function tableXml(table, rowCount, policy, headerRow = 1, footer) {
4462
4498
  '" showColumnStripes="' + (options.bandedColumns ? 1 : 0) + '"/></table>';
4463
4499
  }
4464
4500
  const _exports = Object.freeze({ defineTable: defineTable, tableXml: tableXml });
4465
- _modules.set("87ebdbcd48a4e7d39257ef5bdfe726a889dbf5eaf3cd3f51a0205bf65090f6cf", _exports);
4501
+ _modules.set("69b817e85a5cf991b2c75390de7cfb5657f53786c2bf2221e310d489f4e50fa0", _exports);
4466
4502
  return _exports;
4467
4503
  })();
4468
4504
 
4469
- const _m48 = _modules.get("9c165af1760666d37381c410b96136694d28d86e1e5fcf4847f2d1087bb952f4") ?? (() => {
4505
+ const _m48 = _modules.get("326038be5df97f3a5a5909d06720e4b63162b0f69961c79600f915e768bd41fb") ?? (() => {
4470
4506
  const { OfficeIMOError } = _m2;
4471
4507
 
4472
4508
  const { cleanXml } = _m28;
@@ -4530,11 +4566,11 @@ function* splitText(text) {
4530
4566
  }
4531
4567
  }
4532
4568
  const _exports = Object.freeze({ TextOverflow: TextOverflow, clipText: clipText });
4533
- _modules.set("9c165af1760666d37381c410b96136694d28d86e1e5fcf4847f2d1087bb952f4", _exports);
4569
+ _modules.set("326038be5df97f3a5a5909d06720e4b63162b0f69961c79600f915e768bd41fb", _exports);
4534
4570
  return _exports;
4535
4571
  })();
4536
4572
 
4537
- const _m50 = _modules.get("bd66b325c9055258132735218be91a78281910aaac042bcac4c5b0f594e35379") ?? (() => {
4573
+ const _m50 = _modules.get("5fcd8ab43752d758bd1b311eae9378643c828dfca1de2875b2bd5f16fc8b4abc") ?? (() => {
4538
4574
  const { checkAbort } = _m4;
4539
4575
 
4540
4576
  const { NotSupportedError, OfficeIMOError } = _m2;
@@ -4662,11 +4698,11 @@ function prepareChartBinding(input, descriptor, budgets, signal, type = "columnC
4662
4698
  }, finish });
4663
4699
  }
4664
4700
  const _exports = Object.freeze({ captureChartRange: captureChartRange, prepareChartBinding: prepareChartBinding });
4665
- _modules.set("bd66b325c9055258132735218be91a78281910aaac042bcac4c5b0f594e35379", _exports);
4701
+ _modules.set("5fcd8ab43752d758bd1b311eae9378643c828dfca1de2875b2bd5f16fc8b4abc", _exports);
4666
4702
  return _exports;
4667
4703
  })();
4668
4704
 
4669
- const _m49 = _modules.get("1a72338dda567009c435c547ffc3b6a8e798369b5455bb94c629f8fab0771eb7") ?? (() => {
4705
+ const _m49 = _modules.get("28c1f1e37db546192ff92887f5cf59224cf6b98370eb79848e428946a7000e76") ?? (() => {
4670
4706
  const { checkAbort } = _m4;
4671
4707
 
4672
4708
  const { NotSupportedError, OfficeIMOError } = _m2;
@@ -4833,11 +4869,11 @@ function prepareChart(input, policy, availablePoints, availableText, signal, res
4833
4869
  points, textCharacters });
4834
4870
  }
4835
4871
  const _exports = Object.freeze({ prepareChart: prepareChart });
4836
- _modules.set("1a72338dda567009c435c547ffc3b6a8e798369b5455bb94c629f8fab0771eb7", _exports);
4872
+ _modules.set("28c1f1e37db546192ff92887f5cf59224cf6b98370eb79848e428946a7000e76", _exports);
4837
4873
  return _exports;
4838
4874
  })();
4839
4875
 
4840
- const _m24 = _modules.get("ae55b8ef5a8ee860d084264e4184cae35d6b359c73b70c059503e435df68f397") ?? (() => {
4876
+ const _m24 = _modules.get("982718d202723335e72aab0c32adf982f3bdaba804612744478ab794f3c9386c") ?? (() => {
4841
4877
  const { beginTask, checkAbort, pause, taskYieldDue } = _m4;
4842
4878
 
4843
4879
  const { OfficeIMOError } = _m2;
@@ -5312,7 +5348,7 @@ class Workbook {
5312
5348
  }
5313
5349
  }
5314
5350
  const _exports = Object.freeze({ Workbook: Workbook });
5315
- _modules.set("ae55b8ef5a8ee860d084264e4184cae35d6b359c73b70c059503e435df68f397", _exports);
5351
+ _modules.set("982718d202723335e72aab0c32adf982f3bdaba804612744478ab794f3c9386c", _exports);
5316
5352
  return _exports;
5317
5353
  })();
5318
5354
 
@@ -5369,7 +5405,7 @@ _modules.set("89111eab1f3857529c2d0cd849f16598097e62bd73841211b9c66ccc7b1b7ca2",
5369
5405
  return _exports;
5370
5406
  })();
5371
5407
 
5372
- const _m51 = _modules.get("d4f8b447d0a2834af0ecb5f89766e5402a65980c89f3a4973b4493cac65051b4") ?? (() => {
5408
+ const _m51 = _modules.get("59ef9ad8736be48605a1d5005a096b977be8e44c0d2a4249345127b2b7f81339") ?? (() => {
5373
5409
  const { withDestination } = _m3;
5374
5410
 
5375
5411
  const { copyColumns } = _m11;
@@ -5424,11 +5460,11 @@ async function writeXlsxTo(rows, destination, configuration) {
5424
5460
  });
5425
5461
  }
5426
5462
  const _exports = Object.freeze({ writeXlsx: writeXlsx, writeXlsxTo: writeXlsxTo });
5427
- _modules.set("d4f8b447d0a2834af0ecb5f89766e5402a65980c89f3a4973b4493cac65051b4", _exports);
5463
+ _modules.set("59ef9ad8736be48605a1d5005a096b977be8e44c0d2a4249345127b2b7f81339", _exports);
5428
5464
  return _exports;
5429
5465
  })();
5430
5466
 
5431
- const _m54 = _modules.get("1c910dc1be8cd6844c1384524ba7c64dc75d80ff09de2fbd5a4752b9cdfd943b") ?? (() => {
5467
+ const _m54 = _modules.get("de7c4720443cbafe0e11a1142f952c4977c47158c42f0a20704db65e3a19bf8b") ?? (() => {
5432
5468
  const { assertGroupedReportSource } = _m8;
5433
5469
 
5434
5470
  const { captureFields } = _m10;
@@ -5517,11 +5553,11 @@ function prepareGroupedSheet(report, configuration, maxConditionalFormats = 1000
5517
5553
  ...(options.grandTotalStyle ? { grandTotalStyle: copyStylePatch(options.grandTotalStyle) } : {}) };
5518
5554
  }
5519
5555
  const _exports = Object.freeze({ groupedOptionFields: groupedOptionFields, prepareGroupedSheet: prepareGroupedSheet });
5520
- _modules.set("1c910dc1be8cd6844c1384524ba7c64dc75d80ff09de2fbd5a4752b9cdfd943b", _exports);
5556
+ _modules.set("de7c4720443cbafe0e11a1142f952c4977c47158c42f0a20704db65e3a19bf8b", _exports);
5521
5557
  return _exports;
5522
5558
  })();
5523
5559
 
5524
- const _m53 = _modules.get("59f736fd5084497af8fb6fd211c910f5980174a39d31641216eda50f6d78bb63") ?? (() => {
5560
+ const _m53 = _modules.get("50d544d4c980d1a8f6a81b2d3e376bf92bed5c415a275b6eacacdb86b15d57b0") ?? (() => {
5525
5561
  const { groupedReportOperation } = _m8;
5526
5562
 
5527
5563
  const { checkAbort, withAbort } = _m4;
@@ -5694,14 +5730,14 @@ async function writeGroupedXlsxTo(report, destination, options) {
5694
5730
  return withDestination(destination, async (sink) => (await write(report, prepared, sink)).result);
5695
5731
  }
5696
5732
  const _exports = Object.freeze({ addGroupedXlsx: addGroupedXlsx, writeGroupedXlsx: writeGroupedXlsx, writeGroupedXlsxTo: writeGroupedXlsxTo });
5697
- _modules.set("59f736fd5084497af8fb6fd211c910f5980174a39d31641216eda50f6d78bb63", _exports);
5733
+ _modules.set("50d544d4c980d1a8f6a81b2d3e376bf92bed5c415a275b6eacacdb86b15d57b0", _exports);
5698
5734
  return _exports;
5699
5735
  })();
5700
5736
 
5701
- const _m23 = _modules.get("5f2337c50c0e9b88b7a8095f5b5df2f3fde33723e3115223465178731cfab42d") ?? (() => {
5737
+ const _m23 = _modules.get("d494060a59e45633a76ad2e4aeb08b6ffbc730ce6c4d50686aa4e3a51ad0ed6e") ?? (() => {
5702
5738
 
5703
5739
  const _exports = Object.freeze({ Workbook: _m24.Workbook, writeXlsx: _m51.writeXlsx, writeXlsxTo: _m51.writeXlsxTo, writeGroupedXlsx: _m53.writeGroupedXlsx, writeGroupedXlsxTo: _m53.writeGroupedXlsxTo, addGroupedXlsx: _m53.addGroupedXlsx, createGroupedReport: _m8.createGroupedReport, Worksheet: _m37.Worksheet, Cell: _m35.Cell, FormulaCell: _m36.FormulaCell, StyleRegistry: _m32.StyleRegistry, NumberFormats: _m32.NumberFormats, saveBlob: _m1.saveBlob, ExportCell: _m5.ExportCell });
5704
- _modules.set("5f2337c50c0e9b88b7a8095f5b5df2f3fde33723e3115223465178731cfab42d", _exports);
5740
+ _modules.set("d494060a59e45633a76ad2e4aeb08b6ffbc730ce6c4d50686aa4e3a51ad0ed6e", _exports);
5705
5741
  return _exports;
5706
5742
  })();
5707
5743
 
@@ -5727,7 +5763,7 @@ _modules.set("2f5c0823847e9209017d01b2a753f36056df2a9988fae1f3a1bd5fd186545220",
5727
5763
  return _exports;
5728
5764
  })();
5729
5765
 
5730
- const _m55 = _modules.get("9c3d47f5bb21af4555c6ad7b10e216b7c957f2e71027f576989d75e7cf563d1d") ?? (() => {
5766
+ const _m55 = _modules.get("b6dbf755b495baef5c7d7651e6a55b2098f2ee304edca2c8b285a0bd7ec127a1") ?? (() => {
5731
5767
  const { beginTask, checkAbort, consumeRows, taskYieldDue, withAbort } = _m4;
5732
5768
 
5733
5769
  const { BlobByteSink, ChunkedTextSink, withDestination } = _m3;
@@ -5874,15 +5910,74 @@ async function writeCsv(rows, configuration) {
5874
5910
  }
5875
5911
  }
5876
5912
  const _exports = Object.freeze({ saveBlob: _m1.saveBlob, ExportCell: _m5.ExportCell, writeCsvTo: writeCsvTo, writeCsv: writeCsv });
5877
- _modules.set("9c3d47f5bb21af4555c6ad7b10e216b7c957f2e71027f576989d75e7cf563d1d", _exports);
5913
+ _modules.set("b6dbf755b495baef5c7d7651e6a55b2098f2ee304edca2c8b285a0bd7ec127a1", _exports);
5914
+ return _exports;
5915
+ })();
5916
+
5917
+ const _m61 = _modules.get("e3d39f39aebcbaf063fd8221df0d9cb5902ad2545a9d9e474bb59d47f15e2c01") ?? (() => {
5918
+ /** @internal One type byte, an eight-byte offset/container number and a two-byte generation/index. */
5919
+ const pdfXrefEntryBytes = 11;
5920
+ function unsigned(bytes, offset, value, width) {
5921
+ if (!Number.isSafeInteger(value) || value < 0 || value >= 2 ** (width * 8))
5922
+ throw new RangeError("Invalid PDF cross-reference field.");
5923
+ // Bitwise shifts truncate to 32 bits. Arithmetic preserves every supported byte offset.
5924
+ for (let index = width - 1; index >= 0; index--) {
5925
+ bytes[offset + index] = value % 256;
5926
+ value = Math.floor(value / 256);
5927
+ }
5928
+ }
5929
+ /** @internal Stream a complete single-section xref, including its own ordinary-object entry.
5930
+ * A defined member index means that the location is an object-stream number rather than a byte offset. */
5931
+ function* pdfXrefChunks(locations, indices) {
5932
+ if (locations.length !== indices.length)
5933
+ throw new Error("PDF cross-reference locations must align.");
5934
+ const perChunk = Math.floor(32768 / pdfXrefEntryBytes);
5935
+ for (let first = 0; first < locations.length; first += perChunk) {
5936
+ const count = Math.min(perChunk, locations.length - first), bytes = new Uint8Array(count * pdfXrefEntryBytes);
5937
+ for (let index = 0; index < count; index++) {
5938
+ const id = first + index, position = index * pdfXrefEntryBytes, location = locations[id], member = indices.at(id);
5939
+ if (location === undefined)
5940
+ throw new Error("PDF contains unwritten objects.");
5941
+ bytes[position] = id === 0 ? 0 : member === undefined ? 1 : 2;
5942
+ unsigned(bytes, position + 1, location, 8);
5943
+ unsigned(bytes, position + 9, id === 0 ? 65535 : member ?? 0, 2);
5944
+ }
5945
+ yield bytes;
5946
+ }
5947
+ }
5948
+ const _exports = Object.freeze({ pdfXrefEntryBytes: pdfXrefEntryBytes, pdfXrefChunks: pdfXrefChunks });
5949
+ _modules.set("e3d39f39aebcbaf063fd8221df0d9cb5902ad2545a9d9e474bb59d47f15e2c01", _exports);
5878
5950
  return _exports;
5879
5951
  })();
5880
5952
 
5881
- const _m60 = _modules.get("5424d3dd13b6ba1c76052de820b3d99e9bac24c012ea36e41b04fd99c779ee8c") ?? (() => {
5953
+ const _m60 = _modules.get("e716b8b1da464094622f5f671518493c78e63ff22a029d61544d2d193b63ce8f") ?? (() => {
5882
5954
  const { checkAbort, withAbort, pause, taskYieldDue } = _m4;
5883
5955
 
5884
5956
  const { OfficeIMOError } = _m2;
5885
5957
 
5958
+ const { pdfXrefChunks, pdfXrefEntryBytes } = _m61;
5959
+
5960
+ const compactObjectCount = 256, compactObjectBytes = 32768;
5961
+ const compactIndexChunkEntries = 4096;
5962
+ /** Lazy Uint16 chunks store compact membership; untouched zero slots denote ordinary objects. */
5963
+ class PdfCompactIndices {
5964
+ count;
5965
+ chunks = [];
5966
+ constructor(count) {
5967
+ this.count = count;
5968
+ }
5969
+ get length() { return this.count; }
5970
+ reserve() { this.count++; }
5971
+ set(id, member) {
5972
+ const chunk = this.chunks[Math.floor(id / compactIndexChunkEntries)] ??= new Uint16Array(compactIndexChunkEntries);
5973
+ // The current batch cap permits indices 0..255; adding one preserves index 255 as 256.
5974
+ chunk[id % compactIndexChunkEntries] = member + 1;
5975
+ }
5976
+ at(id) {
5977
+ const encoded = this.chunks[Math.floor(id / compactIndexChunkEntries)]?.[id % compactIndexChunkEntries] ?? 0;
5978
+ return encoded ? encoded - 1 : undefined;
5979
+ }
5980
+ }
5886
5981
  function pdfNumber(value) {
5887
5982
  if (!Number.isFinite(value) || Math.abs(value) > 1e9)
5888
5983
  throw new RangeError("PDF coordinates and metrics must be finite and bounded.");
@@ -5899,25 +5994,33 @@ function unicodeHex(text) {
5899
5994
  }
5900
5995
  return hex;
5901
5996
  }
5902
- /** @internal Forward-only PDF objects. Only xref offsets and page references survive a completed page. */
5997
+ /** @internal Forward-only PDF objects. Completed objects retain only their xref location. */
5903
5998
  class PdfObjects {
5904
5999
  sink;
5905
6000
  signal;
5906
6001
  maxBytes;
6002
+ compressObjects;
5907
6003
  offsets = [0];
6004
+ // A defined index changes the corresponding full-width offset into an object-stream number.
6005
+ // Membership chunks are allocated only when a compact member needs their ID range.
6006
+ compactIndices;
6007
+ compactBatch;
6008
+ compactArena;
6009
+ compactUnavailable = false;
5908
6010
  encoder = new TextEncoder();
5909
6011
  buffer = new Uint8Array(32768);
5910
6012
  buffered = 0;
5911
6013
  bytes = 0;
5912
- constructor(sink, signal, maxBytes = Number.MAX_SAFE_INTEGER) {
6014
+ constructor(sink, signal, maxBytes = Number.MAX_SAFE_INTEGER, compressObjects = false) {
5913
6015
  this.sink = sink;
5914
6016
  this.signal = signal;
5915
6017
  this.maxBytes = maxBytes;
6018
+ this.compressObjects = compressObjects;
5916
6019
  }
5917
- reserve() { this.offsets.push(undefined); return this.offsets.length - 1; }
6020
+ reserve() { this.offsets.push(undefined); this.compactIndices?.reserve(); return this.offsets.length - 1; }
5918
6021
  async raw(bytes) {
5919
6022
  checkAbort(this.signal);
5920
- if (this.bytes + bytes.length > this.maxBytes)
6023
+ if (!Number.isSafeInteger(this.bytes + bytes.length) || this.bytes + bytes.length > this.maxBytes)
5921
6024
  throw new OfficeIMOError("RESOURCE_LIMIT", "maxOutputBytes exceeded.");
5922
6025
  this.bytes += bytes.length;
5923
6026
  for (let offset = 0; offset < bytes.length;) {
@@ -5926,21 +6029,139 @@ class PdfObjects {
5926
6029
  offset += n;
5927
6030
  this.buffered += n;
5928
6031
  if (this.buffered === this.buffer.length)
5929
- await this.flush();
6032
+ await this.flushBytes();
5930
6033
  }
5931
6034
  }
5932
6035
  async text(text) { await this.raw(this.encoder.encode(text)); }
5933
6036
  async flush() {
6037
+ await this.flushCompact();
6038
+ await this.flushBytes();
6039
+ }
6040
+ /** Publish completed page bytes without forcing a partial structure container to end. */
6041
+ async flushBytes() {
5934
6042
  if (this.buffered) {
5935
6043
  const bytes = this.buffer.subarray(0, this.buffered);
5936
6044
  await withAbort(Promise.resolve(this.sink.write(bytes)), this.signal);
5937
- this.buffer = new Uint8Array(32768);
6045
+ // The sink borrows this view until acceptance; failed or cancelled writes must not reuse it.
5938
6046
  this.buffered = 0;
5939
6047
  }
5940
6048
  if (taskYieldDue())
5941
6049
  await pause();
5942
6050
  checkAbort(this.signal);
5943
6051
  }
6052
+ /** @internal Append only when an existing compact batch can accept a member without async work. */
6053
+ tryCompactObject(id, body) {
6054
+ checkAbort(this.signal);
6055
+ this.validateObject(id);
6056
+ const batch = this.compactBatch;
6057
+ if (!batch || !this.compressObjects || this.compactUnavailable || typeof CompressionStream !== "function" ||
6058
+ body.length > compactObjectBytes || batch.ids.length + 1 >= compactObjectCount)
6059
+ return false;
6060
+ const indexBytes = String(id).length + String(batch.bodyBytes).length + 2;
6061
+ const written = this.encodeCompactBody(body, batch.bodyBytes, compactObjectBytes - batch.indexBytes - indexBytes - batch.bodyBytes - 2);
6062
+ if (written === undefined)
6063
+ return false;
6064
+ this.storeCompactBody(batch, id, written);
6065
+ return true;
6066
+ }
6067
+ /** Small logical structure values share one bounded object-stream container. Other callers keep
6068
+ * ordinary objects; unavailable deflate preserves the classic representation before packing starts. */
6069
+ async compactObject(id, body) {
6070
+ checkAbort(this.signal);
6071
+ this.validateObject(id);
6072
+ if (!this.compressObjects || this.compactUnavailable || body.length > compactObjectBytes)
6073
+ return this.object(id, body);
6074
+ if (typeof CompressionStream !== "function") {
6075
+ if (this.compactIndices)
6076
+ throw new Error("PDF object compression became unavailable.");
6077
+ this.compactUnavailable = true;
6078
+ return this.object(id, body);
6079
+ }
6080
+ const firstIndexBytes = String(id).length + 4;
6081
+ let batch = this.compactBatch;
6082
+ const indexBytes = String(id).length + String(batch?.bodyBytes ?? 0).length + 2;
6083
+ let written = batch && batch.ids.length < compactObjectCount ? this.encodeCompactBody(body, batch.bodyBytes, compactObjectBytes - batch.indexBytes - indexBytes - batch.bodyBytes - 2) : undefined;
6084
+ if (batch && written === undefined) {
6085
+ // Partial encodings only touch the uncommitted suffix. Flush the committed prefix and retry
6086
+ // the whole string so a multibyte scalar is never split between containers.
6087
+ await this.flushCompact();
6088
+ batch = undefined;
6089
+ checkAbort(this.signal);
6090
+ }
6091
+ if (!batch) {
6092
+ written = this.encodeCompactBody(body, 0, compactObjectBytes - firstIndexBytes - 1);
6093
+ if (written === undefined)
6094
+ return this.object(id, body);
6095
+ let compressor;
6096
+ // Probe before selecting the compact representation. Later batches need no idle native
6097
+ // codec while they accumulate, including while ordinary page streams are compressed.
6098
+ if (!this.compactIndices) {
6099
+ try {
6100
+ compressor = new CompressionStream("deflate");
6101
+ }
6102
+ catch {
6103
+ this.compactUnavailable = true;
6104
+ return this.object(id, body);
6105
+ }
6106
+ }
6107
+ batch = { id: this.reserve(), compressor, ids: [], bodyOffsets: [], bodyBytes: 0, indexBytes: 1 };
6108
+ this.compactIndices ??= new PdfCompactIndices(this.offsets.length);
6109
+ this.compactBatch = batch;
6110
+ }
6111
+ this.storeCompactBody(batch, id, written);
6112
+ if (batch.ids.length === compactObjectCount)
6113
+ await this.flushCompact();
6114
+ }
6115
+ storeCompactBody(batch, id, written) {
6116
+ this.offsets[id] = batch.id;
6117
+ this.compactIndices.set(id, batch.ids.length);
6118
+ batch.indexBytes += String(id).length + String(batch.bodyBytes).length + 2;
6119
+ batch.ids.push(id);
6120
+ batch.bodyOffsets.push(batch.bodyBytes);
6121
+ this.compactArena[batch.bodyBytes + written] = 10;
6122
+ batch.bodyBytes += written + 1;
6123
+ }
6124
+ /** An incomplete encoding leaves only scratch bytes beyond the committed batch prefix. */
6125
+ encodeCompactBody(body, offset, available) {
6126
+ if (available < 0)
6127
+ return undefined;
6128
+ const destination = (this.compactArena ??= new Uint8Array(compactObjectBytes)).subarray(offset, offset + available);
6129
+ if (typeof this.encoder.encodeInto === "function") {
6130
+ const result = this.encoder.encodeInto(body, destination);
6131
+ return result.read === body.length ? result.written : undefined;
6132
+ }
6133
+ // Preserve TextEncoder implementations that only expose encode().
6134
+ const bytes = this.encoder.encode(body);
6135
+ if (bytes.length > available)
6136
+ return undefined;
6137
+ destination.set(bytes);
6138
+ return bytes.length;
6139
+ }
6140
+ async flushCompact() {
6141
+ const batch = this.compactBatch;
6142
+ if (!batch)
6143
+ return;
6144
+ this.compactBatch = undefined;
6145
+ let index = "";
6146
+ for (let member = 0; member < batch.ids.length; member++)
6147
+ index += batch.ids[member] + " " + batch.bodyOffsets[member] + " ";
6148
+ const header = this.encoder.encode(index + "\n"), count = batch.ids.length;
6149
+ // Keep the index separate from the arena. Reuse waits for the compressed read or all raw
6150
+ // writes below, so later members cannot overwrite a borrowed batch body.
6151
+ const body = this.compactArena.subarray(0, batch.bodyBytes);
6152
+ batch.ids.length = 0;
6153
+ batch.bodyOffsets.length = 0;
6154
+ if (batch.compressor) {
6155
+ await this.compressedStream(batch.id, body, "/Type /ObjStm /N " + count + " /First " + header.length, batch.compressor, header);
6156
+ }
6157
+ else {
6158
+ this.start(batch.id);
6159
+ await this.text(batch.id + " 0 obj\n<< /Length " + (header.length + body.length) + " /Type /ObjStm /N " + count + " /First " + header.length + " >>\nstream\n");
6160
+ await this.raw(header);
6161
+ await this.raw(body);
6162
+ await this.text("\nendstream\nendobj\n");
6163
+ }
6164
+ }
5944
6165
  async object(id, body) {
5945
6166
  this.start(id);
5946
6167
  if (typeof body === "string") {
@@ -5964,9 +6185,12 @@ class PdfObjects {
5964
6185
  }
5965
6186
  await this.text(chunk + "\nendobj\n");
5966
6187
  }
5967
- start(id) {
5968
- if (!Number.isInteger(id) || id <= 0 || id >= this.offsets.length || this.offsets[id] !== undefined)
6188
+ validateObject(id) {
6189
+ if (!Number.isSafeInteger(id) || id <= 0 || id >= this.offsets.length || this.offsets[id] !== undefined)
5969
6190
  throw new Error("Invalid PDF object state.");
6191
+ }
6192
+ start(id) {
6193
+ this.validateObject(id);
5970
6194
  this.offsets[id] = this.bytes;
5971
6195
  }
5972
6196
  async stream(id, source, dictionary = "", compression = true, owned = false) {
@@ -5987,7 +6211,15 @@ class PdfObjects {
5987
6211
  }
5988
6212
  // Verified internal producers can transfer immutable ownership; other byte sources retain the defensive snapshot.
5989
6213
  const sourceBytes = typeof source === "string" || owned ? bytes : new Uint8Array(bytes);
5990
- const input = new ReadableStream({ start(controller) { controller.enqueue(sourceBytes); controller.close(); } });
6214
+ await this.compressedStream(id, sourceBytes, dictionary, compressor);
6215
+ }
6216
+ async compressedStream(id, sourceBytes, dictionary, compressor, prefix) {
6217
+ const input = new ReadableStream({ start(controller) {
6218
+ if (prefix)
6219
+ controller.enqueue(prefix);
6220
+ controller.enqueue(sourceBytes);
6221
+ controller.close();
6222
+ } });
5991
6223
  const reader = input.pipeThrough(compressor).getReader(), lengthId = this.reserve();
5992
6224
  let length = 0, complete = false;
5993
6225
  try {
@@ -6012,10 +6244,14 @@ class PdfObjects {
6012
6244
  }
6013
6245
  }
6014
6246
  async finish(root, info) {
6015
- if (this.offsets.slice(1).some(offset => offset === undefined))
6016
- throw new Error("PDF contains unwritten objects.");
6247
+ await this.flushCompact();
6248
+ for (let id = 1; id < this.offsets.length; id++)
6249
+ if (this.offsets[id] === undefined)
6250
+ throw new Error("PDF contains unwritten objects.");
6017
6251
  if (this.bytes > 9999999999)
6018
6252
  throw new OfficeIMOError("RESOURCE_LIMIT", "PDF exceeds classic cross-reference offset capacity.");
6253
+ if (this.compactIndices)
6254
+ return this.finishCompact(root, info);
6019
6255
  const start = this.bytes;
6020
6256
  await this.text("xref\n0 " + this.offsets.length + "\n0000000000 65535 f \n");
6021
6257
  for (let i = 1; i < this.offsets.length; i++)
@@ -6023,13 +6259,27 @@ class PdfObjects {
6023
6259
  await this.text("trailer\n<< /Size " + this.offsets.length + " /Root " + root + " 0 R /Info " + info + " 0 R >>\nstartxref\n" + start + "\n%%EOF\n");
6024
6260
  await this.flush();
6025
6261
  }
6262
+ /** Xref payloads have a known length and are emitted in bounded chunks, without another copy
6263
+ * of the document's random-access location arrays or a whole-xref compression buffer. */
6264
+ async finishCompact(root, info) {
6265
+ const id = this.reserve(), start = this.bytes, length = this.offsets.length * pdfXrefEntryBytes;
6266
+ if (!Number.isSafeInteger(length))
6267
+ throw new OfficeIMOError("RESOURCE_LIMIT", "PDF cross-reference stream is too large.");
6268
+ this.start(id);
6269
+ await this.text(id + " 0 obj\n<< /Type /XRef /Size " + this.offsets.length + " /W [1 8 2] /Root " + root + " 0 R /Info " + info +
6270
+ " 0 R /Length " + length + " >>\nstream\n");
6271
+ for (const chunk of pdfXrefChunks(this.offsets, this.compactIndices))
6272
+ await this.raw(chunk);
6273
+ await this.text("\nendstream\nendobj\nstartxref\n" + start + "\n%%EOF\n");
6274
+ await this.flushBytes();
6275
+ }
6026
6276
  }
6027
6277
  const _exports = Object.freeze({ pdfNumber: pdfNumber, unicodeHex: unicodeHex, PdfObjects: PdfObjects });
6028
- _modules.set("5424d3dd13b6ba1c76052de820b3d99e9bac24c012ea36e41b04fd99c779ee8c", _exports);
6278
+ _modules.set("e716b8b1da464094622f5f671518493c78e63ff22a029d61544d2d193b63ce8f", _exports);
6029
6279
  return _exports;
6030
6280
  })();
6031
6281
 
6032
- const _m64 = _modules.get("1e169e6ecdeceff319b5da4bf01f4c653c1a3d9e8ad696b141bf8ac52d9f446c") ?? (() => {
6282
+ const _m65 = _modules.get("1e169e6ecdeceff319b5da4bf01f4c653c1a3d9e8ad696b141bf8ac52d9f446c") ?? (() => {
6033
6283
  /** @internal Bounded big-endian reader used for caller-provided TrueType programs. */
6034
6284
  class FontReader {
6035
6285
  bytes;
@@ -6059,8 +6309,8 @@ _modules.set("1e169e6ecdeceff319b5da4bf01f4c653c1a3d9e8ad696b141bf8ac52d9f446c",
6059
6309
  return _exports;
6060
6310
  })();
6061
6311
 
6062
- const _m65 = _modules.get("0534e48516ba3859978bb5f21d4ddfb17b4276c5e4650a7c7d6d384c25f6b681") ?? (() => {
6063
- const { align4 } = _m64;
6312
+ const _m66 = _modules.get("ecf6c6ab2f9c5f747338d0d59d9f2cae0b006d9d2a210bcb1545db1f046eb80c") ?? (() => {
6313
+ const { align4 } = _m65;
6064
6314
 
6065
6315
  const { checkAbort, pause, taskYieldDue } = _m4;
6066
6316
 
@@ -6280,16 +6530,16 @@ function* checksumSteps(bytes) {
6280
6530
  return sum;
6281
6531
  }
6282
6532
  const _exports = Object.freeze({ subsetTrueType: subsetTrueType, subsetTrueTypeCooperatively: subsetTrueTypeCooperatively });
6283
- _modules.set("0534e48516ba3859978bb5f21d4ddfb17b4276c5e4650a7c7d6d384c25f6b681", _exports);
6533
+ _modules.set("ecf6c6ab2f9c5f747338d0d59d9f2cae0b006d9d2a210bcb1545db1f046eb80c", _exports);
6284
6534
  return _exports;
6285
6535
  })();
6286
6536
 
6287
- const _m63 = _modules.get("77a2a9756cb6f59426300e1b3e601bd68acacdd40e6c30fbeb3cc99607c84891") ?? (() => {
6537
+ const _m64 = _modules.get("2e1fa1582af797386e2e2914c0a27237309b1692a3cc2be688f46590eb74480d") ?? (() => {
6288
6538
  const { NotSupportedError } = _m2;
6289
6539
 
6290
- const { FontReader } = _m64;
6540
+ const { FontReader } = _m65;
6291
6541
 
6292
- const { subsetTrueType, subsetTrueTypeCooperatively } = _m65;
6542
+ const { subsetTrueType, subsetTrueTypeCooperatively } = _m66;
6293
6543
 
6294
6544
  const { checkAbort, pause, taskYieldDue } = _m4;
6295
6545
 
@@ -6525,12 +6775,12 @@ function* parseFont(reader) {
6525
6775
  return { tables, glyphCount, units, ascent, descent, bbox, widths, offsets, canSubset, cmaps };
6526
6776
  }
6527
6777
  const _exports = Object.freeze({ TrueTypeFont: TrueTypeFont });
6528
- _modules.set("77a2a9756cb6f59426300e1b3e601bd68acacdd40e6c30fbeb3cc99607c84891", _exports);
6778
+ _modules.set("2e1fa1582af797386e2e2914c0a27237309b1692a3cc2be688f46590eb74480d", _exports);
6529
6779
  return _exports;
6530
6780
  })();
6531
6781
 
6532
- const _m62 = _modules.get("832d36356946811343532af7b630ef1c2016b6a48d0897282f4be774e20a1de2") ?? (() => {
6533
- const { TrueTypeFont } = _m63;
6782
+ const _m63 = _modules.get("d9c1509dff0538488752433e47cd0927ece5f93c559ad0e32dc56602dfd44596") ?? (() => {
6783
+ const { TrueTypeFont } = _m64;
6534
6784
 
6535
6785
  const { beginTask, checkAbort } = _m4;
6536
6786
 
@@ -6589,11 +6839,11 @@ class PdfFont {
6589
6839
  toBytes() { return fontProgram(this).bytes.slice(); }
6590
6840
  }
6591
6841
  const _exports = Object.freeze({ fontProgram: fontProgram, PdfFont: PdfFont });
6592
- _modules.set("832d36356946811343532af7b630ef1c2016b6a48d0897282f4be774e20a1de2", _exports);
6842
+ _modules.set("d9c1509dff0538488752433e47cd0927ece5f93c559ad0e32dc56602dfd44596", _exports);
6593
6843
  return _exports;
6594
6844
  })();
6595
6845
 
6596
- const _m67 = _modules.get("1ed4965a6e2963a91190baa8a58ada8ce0edde8fe653bcb6609002e872af0d61") ?? (() => {
6846
+ const _m68 = _modules.get("1ed4965a6e2963a91190baa8a58ada8ce0edde8fe653bcb6609002e872af0d61") ?? (() => {
6597
6847
  // Generated by scripts/pdf-widths.mjs from OfficeIMO.Pdf's Adobe AFM-derived metrics.
6598
6848
  const helveticaWidths = new Map([
6599
6849
  [32, [278, 278]],
@@ -6916,12 +7166,12 @@ _modules.set("1ed4965a6e2963a91190baa8a58ada8ce0edde8fe653bcb6609002e872af0d61",
6916
7166
  return _exports;
6917
7167
  })();
6918
7168
 
6919
- const _m66 = _modules.get("cb116ec8bc322f9c03d14c60009ac989d78b64636b24d77b44f5eece758dfbde") ?? (() => {
7169
+ const _m67 = _modules.get("59911f0fe023545e9e97521b268551078bdc4c5f303e446a13b7d52f905e8070") ?? (() => {
6920
7170
  const { OfficeIMOError } = _m2;
6921
7171
 
6922
- const { PdfFont, fontProgram } = _m62;
7172
+ const { PdfFont, fontProgram } = _m63;
6923
7173
 
6924
- const { helveticaWidths } = _m67;
7174
+ const { helveticaWidths } = _m68;
6925
7175
 
6926
7176
  const winAnsiExtras = new Map([0x20ac, 0, 0x201a, 0x192, 0x201e, 0x2026, 0x2020, 0x2021, 0x2c6, 0x2030, 0x160, 0x2039, 0x152, 0, 0x17d, 0, 0, 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014, 0x2dc, 0x2122, 0x161, 0x203a, 0x153, 0, 0x17e, 0x178].map((cp, i) => [cp, i + 128]));
6927
7177
  /** @internal Called after scalar support succeeds when encoding a standard-font run. */
@@ -6981,21 +7231,22 @@ function selectFont(fonts, bold, italic) {
6981
7231
  return { font, syntheticBold: !!font && bold && !exact, syntheticItalic: !!font && italic && !exact };
6982
7232
  }
6983
7233
  const _exports = Object.freeze({ standardCode: standardCode, resolveScalar: resolveScalar, validateFonts: validateFonts, selectFont: selectFont });
6984
- _modules.set("cb116ec8bc322f9c03d14c60009ac989d78b64636b24d77b44f5eece758dfbde", _exports);
7234
+ _modules.set("59911f0fe023545e9e97521b268551078bdc4c5f303e446a13b7d52f905e8070", _exports);
6985
7235
  return _exports;
6986
7236
  })();
6987
7237
 
6988
- const _m61 = _modules.get("1b9b0585e9faa850e57fc123c307e79711fd1fb6e877b9f14dff1995a019d5b4") ?? (() => {
7238
+ const _m62 = _modules.get("7da602b40c346a3838e75963f9a3f10c95ac5ce08a7b0a23b9d96f8898a01db7") ?? (() => {
6989
7239
  const { NotSupportedError, OfficeIMOError } = _m2;
6990
7240
 
6991
- const { fontProgram } = _m62;
7241
+ const { fontProgram } = _m63;
6992
7242
 
6993
- const { resolveScalar, selectFont, standardCode, validateFonts } = _m66;
7243
+ const { resolveScalar, selectFont, standardCode, validateFonts } = _m67;
6994
7244
 
6995
7245
  const { pdfNumber, unicodeHex } = _m60;
6996
7246
 
6997
7247
  const { checkAbort, pause, taskYieldDue } = _m4;
6998
7248
 
7249
+ const standardHexBytes = Object.freeze(Array.from({ length: 256 }, (_, byte) => byte.toString(16).padStart(2, "0")));
6999
7250
  class PdfFontResource {
7000
7251
  index;
7001
7252
  bold;
@@ -7058,7 +7309,7 @@ class PdfFontResource {
7058
7309
  for (const char of text) {
7059
7310
  const cp = char.codePointAt(0);
7060
7311
  this.width(cp);
7061
- hex += (this.program ? this.mappings.get(cp).cid : standardCode(cp)).toString(16).padStart(this.program ? 4 : 2, "0");
7312
+ hex += this.program ? this.mappings.get(cp).cid.toString(16).padStart(4, "0") : standardHexBytes[standardCode(cp)];
7062
7313
  }
7063
7314
  return "<" + hex + ">";
7064
7315
  }
@@ -7193,11 +7444,11 @@ class PdfFontResources {
7193
7444
  dictionary() { return "<< " + this.resources.map(f => "/" + f.name + " " + f.object + " 0 R").join(" ") + " >>"; }
7194
7445
  }
7195
7446
  const _exports = Object.freeze({ PdfFontResource: PdfFontResource, PdfFontResources: PdfFontResources });
7196
- _modules.set("1b9b0585e9faa850e57fc123c307e79711fd1fb6e877b9f14dff1995a019d5b4", _exports);
7447
+ _modules.set("7da602b40c346a3838e75963f9a3f10c95ac5ce08a7b0a23b9d96f8898a01db7", _exports);
7197
7448
  return _exports;
7198
7449
  })();
7199
7450
 
7200
- const _m69 = _modules.get("4201fbf42dfbfff0db44c5296d810e8eb98e2be18116bac5c8dc4b6046f72e71") ?? (() => {
7451
+ const _m70 = _modules.get("253db2c0eab1f298fda61fb40a5ddaacbf6ad12a7408ee3d8c12d27f88e7ca27") ?? (() => {
7201
7452
  const { OfficeIMOError } = _m2;
7202
7453
 
7203
7454
  const { ExportCell, assertExportValue } = _m5;
@@ -7208,6 +7459,11 @@ const { isDate } = _m6;
7208
7459
 
7209
7460
  const { defaultBooleanText } = _m21;
7210
7461
 
7462
+ /** @internal Charge displayed characters: tabs paint four spaces, while CR/LF only separate lines.
7463
+ * Raw text remains authoritative for input limits and layout. Skip normalization when no text ceiling observes it. */
7464
+ function pdfBudgetText(text, budget) {
7465
+ return budget.limits.maxTextCharacters === undefined ? text : text.replace(/[\t\r\n]/g, character => character === "\t" ? " " : "");
7466
+ }
7211
7467
  function synchronousText(value, name) {
7212
7468
  if (typeof value === "string")
7213
7469
  return value;
@@ -7299,12 +7555,12 @@ function* wrapSteps(text, font, size, width, maxCharacters, maxLines, wrap) {
7299
7555
  }
7300
7556
  return lines;
7301
7557
  }
7302
- const _exports = Object.freeze({ synchronousText: synchronousText, displayText: displayText, wrapText: wrapText, wrapTextCooperatively: wrapTextCooperatively });
7303
- _modules.set("4201fbf42dfbfff0db44c5296d810e8eb98e2be18116bac5c8dc4b6046f72e71", _exports);
7558
+ const _exports = Object.freeze({ pdfBudgetText: pdfBudgetText, synchronousText: synchronousText, displayText: displayText, wrapText: wrapText, wrapTextCooperatively: wrapTextCooperatively });
7559
+ _modules.set("253db2c0eab1f298fda61fb40a5ddaacbf6ad12a7408ee3d8c12d27f88e7ca27", _exports);
7304
7560
  return _exports;
7305
7561
  })();
7306
7562
 
7307
- const _m71 = _modules.get("1a586388978acf7fd9edef2207a526d0d36336e55020e79c863580e612e9d775") ?? (() => {
7563
+ const _m72 = _modules.get("8be3fb029e08d100ce8ffcf50916d5ba7f7bc00d62156cc33815fd58554a9ed6") ?? (() => {
7308
7564
  const { NotSupportedError, OfficeIMOError } = _m2;
7309
7565
 
7310
7566
  const { checkAbort, pause, taskYieldDue, withAbort } = _m4;
@@ -7513,11 +7769,11 @@ async function wrapShapedPdfText(captured, fonts, size, width, settings, wrap) {
7513
7769
  return lines;
7514
7770
  }
7515
7771
  const _exports = Object.freeze({ wrapShapedPdfText: wrapShapedPdfText });
7516
- _modules.set("1a586388978acf7fd9edef2207a526d0d36336e55020e79c863580e612e9d775", _exports);
7772
+ _modules.set("8be3fb029e08d100ce8ffcf50916d5ba7f7bc00d62156cc33815fd58554a9ed6", _exports);
7517
7773
  return _exports;
7518
7774
  })();
7519
7775
 
7520
- const _m70 = _modules.get("b51711edc0702a2ed2cb63ed106ca8b53fcb5c281571cb495a29cb72d37241fe") ?? (() => {
7776
+ const _m71 = _modules.get("0a1c79b51ac9a164b86197239117df6497f45ca2892b423b1ec77a663ccc1c47") ?? (() => {
7521
7777
  const { NotSupportedError, OfficeIMOError } = _m2;
7522
7778
 
7523
7779
  const { copyExportLink } = _m7;
@@ -7526,21 +7782,30 @@ const { checkAbort, pause, taskYieldDue } = _m4;
7526
7782
 
7527
7783
  const { presentation, color } = _m17;
7528
7784
 
7529
- const { wrapShapedPdfText } = _m71;
7785
+ const { wrapShapedPdfText } = _m72;
7530
7786
 
7531
- const { PdfFont } = _m62;
7787
+ const { PdfFont } = _m63;
7532
7788
 
7533
- /** @internal A run list is a PDF presentation value, never an alternate shared table value model. */
7534
- function capturePdfText(value, base, settings, fonts, countEmpty = true) {
7535
- const input = typeof value === "string" ? [{ text: value }] : value;
7789
+ const { pdfBudgetText } = _m70;
7790
+
7791
+ /** @internal Callers supply an owned, validated, frozen base presentation. A run list is a PDF presentation value, never an alternate shared table value model. */
7792
+ function capturePdfText(value, base, settings, fonts, countEmpty = true, reserveBudget = true) {
7793
+ if (typeof value === "string") {
7794
+ if (value.length > settings.limits.maxCellCharacters)
7795
+ throw new OfficeIMOError("RESOURCE_LIMIT", "maxCellCharacters exceeded.");
7796
+ if (reserveBudget && (value.length || countEmpty))
7797
+ settings.budget.reserve(1, pdfBudgetText(value, settings.budget).length);
7798
+ return Object.freeze({ text: value, runs: Object.freeze([Object.freeze({ text: value, style: base })]) });
7799
+ }
7800
+ const input = value;
7536
7801
  if (!Array.isArray(input)) {
7537
7802
  if (input && typeof input.then === "function")
7538
7803
  void Promise.resolve(input).catch(() => { });
7539
7804
  throw new TypeError("PDF text must be a string or a synchronous array of text runs.");
7540
7805
  }
7541
- if (typeof value !== "string" && input.length > settings.limits.maxTextRuns)
7806
+ if (input.length > settings.limits.maxTextRuns)
7542
7807
  throw new OfficeIMOError("RESOURCE_LIMIT", "maxTextRuns exceeded.");
7543
- let characters = 0;
7808
+ let characters = 0, budgetCharacters = 0;
7544
7809
  const runs = [];
7545
7810
  for (const run of input) {
7546
7811
  if (!run || typeof run !== "object" || Object.keys(run).some(key => !["text", "bold", "italic", "color", "link", "font"].includes(key)))
@@ -7556,14 +7821,16 @@ function capturePdfText(value, base, settings, fonts, countEmpty = true) {
7556
7821
  characters += text.length;
7557
7822
  if (characters > settings.limits.maxCellCharacters)
7558
7823
  throw new OfficeIMOError("RESOURCE_LIMIT", "maxCellCharacters exceeded.");
7824
+ if (reserveBudget)
7825
+ budgetCharacters += pdfBudgetText(text, settings.budget).length;
7559
7826
  const style = presentation({ ...base, ...(bold === undefined ? {} : { bold }), ...(italic === undefined ? {} : { italic }), ...(color === undefined ? {} : { color }) });
7560
7827
  if (settings.options.tagged && link !== undefined && text.length && !text.trim())
7561
7828
  throw new TypeError("Tagged PDF inline links require nonempty displayed text.");
7562
7829
  runs.push(Object.freeze({ text, style, ...(font === undefined ? {} : { font }), ...(link === undefined ? {} : { link: copyExportLink(link) }) }));
7563
7830
  }
7564
7831
  // Reserve before allocating a joined rich-text value or retaining it in a kept paragraph chain.
7565
- if (characters || countEmpty)
7566
- settings.budget.reserve(1, characters);
7832
+ if (reserveBudget && (characters || countEmpty))
7833
+ settings.budget.reserve(1, budgetCharacters);
7567
7834
  return Object.freeze({ text: runs.map(run => run.text).join(""), runs: Object.freeze(runs) });
7568
7835
  }
7569
7836
  /** @internal Greedy wrapping over the continuous text stream, preserving run emphasis and URI geometry. */
@@ -7572,8 +7839,39 @@ async function wrapPdfText(captured, fonts, size, width, settings, wrap = true)
7572
7839
  return wrapShapedPdfText(captured, fonts, size, width, settings, wrap);
7573
7840
  const { signal } = settings.options, { text, runs } = captured;
7574
7841
  checkAbort(signal);
7575
- const faces = runs.map(run => fonts.select(run.style.bold, run.style.italic, run.font));
7576
- const fallback = fonts.select(), lines = [];
7842
+ // Keep font-selection order while deferring a single-run face array until wrapping needs it.
7843
+ const single = runs.length === 1 ? runs[0] : undefined;
7844
+ const singleFace = single && fonts.select(single.style.bold, single.style.italic, single.font);
7845
+ const selectedFaces = singleFace ? undefined : runs.map(run => fonts.select(run.style.bold, run.style.italic, run.font));
7846
+ const fallback = fonts.select();
7847
+ // Short fitting runs need no per-character layout arrays. Longer text keeps the existing
7848
+ // cooperative checkpoints; controls or the first overflowing advance use the general path.
7849
+ if (single && text.length > 0 && text.length < 4096) {
7850
+ const run = single, font = singleFace;
7851
+ let widthSoFar = 0, fits = true;
7852
+ for (let offset = 0; offset < text.length;) {
7853
+ const scalar = text.codePointAt(offset);
7854
+ if (scalar === 9 || scalar === 10 || scalar === 13) {
7855
+ fits = false;
7856
+ break;
7857
+ }
7858
+ const advance = font.width(scalar) * size / 1000;
7859
+ if (advance > width + .001 || widthSoFar + advance > width + .001) {
7860
+ fits = false;
7861
+ break;
7862
+ }
7863
+ widthSoFar += advance;
7864
+ offset += scalar > 0xffff ? 2 : 1;
7865
+ }
7866
+ if (fits) {
7867
+ if (settings.limits.maxRowLines < 1)
7868
+ throw new OfficeIMOError("RESOURCE_LIMIT", "maxRowLines exceeded.");
7869
+ return [{ text, width: widthSoFar, segments: [{ text, width: widthSoFar, font,
7870
+ ...(run.style.color === undefined ? {} : { color: run.style.color }), ...(run.link ? { link: run.link } : {}) }],
7871
+ lineHeight: font.lineHeight(size), ascent: Math.max(0, (font.program?.ascent ?? 800) * size / 1000) }];
7872
+ }
7873
+ }
7874
+ const faces = selectedFaces ?? [singleFace], lines = [];
7577
7875
  let chars = [], advances = [], owners = [], measured = 0, breakAt = -1;
7578
7876
  let runIndex = 0, runEnd = runs[0]?.text.length ?? 0, scanned = 0;
7579
7877
  const emit = (count) => {
@@ -7667,23 +7965,21 @@ async function wrapPdfText(captured, fonts, size, width, settings, wrap = true)
7667
7965
  return lines;
7668
7966
  }
7669
7967
  const _exports = Object.freeze({ capturePdfText: capturePdfText, wrapPdfText: wrapPdfText });
7670
- _modules.set("b51711edc0702a2ed2cb63ed106ca8b53fcb5c281571cb495a29cb72d37241fe", _exports);
7968
+ _modules.set("0a1c79b51ac9a164b86197239117df6497f45ca2892b423b1ec77a663ccc1c47", _exports);
7671
7969
  return _exports;
7672
7970
  })();
7673
7971
 
7674
- const _m72 = _modules.get("58480ded0056f234aea5e0c26637308eea7708e97ccc9987242b62c4dbc4f9b8") ?? (() => {
7972
+ const _m73 = _modules.get("9a88773878eacc51df9f05bb5ee90cc2b683b083ebea8fb54375092301388e96") ?? (() => {
7675
7973
  const { OfficeIMOError } = _m2;
7676
7974
 
7677
- const { wrapPdfText } = _m70;
7975
+ const { wrapPdfText } = _m71;
7678
7976
 
7679
7977
  /** Plan without opening a source. Exact column widths never shrink in band mode. */
7680
7978
  function planTableBands(widths, settings) {
7681
7979
  const policy = settings.options.wideTable;
7682
7980
  if (typeof policy !== "object")
7683
7981
  return undefined;
7684
- const available = settings.page.width - settings.margins.left - settings.margins.right, repeats = policy.repeatColumns ?? [];
7685
- if (repeats.some(index => index >= widths.length))
7686
- throw new RangeError("repeatColumns index exceeds the declared columns.");
7982
+ const available = settings.page.width - settings.margins.left - settings.margins.right, repeats = settings.repeatedColumns;
7687
7983
  const repeated = new Set(repeats), rest = widths.map((_, index) => index).filter(index => !repeated.has(index));
7688
7984
  const prefix = repeats.reduce((sum, index) => sum + widths[index], 0);
7689
7985
  if (prefix > available + .001)
@@ -7760,11 +8056,11 @@ function alignBandBlocks(bands, settings) {
7760
8056
  cells: row.cells.map(cell => ({ ...cell, height: heights.slice(index, index + (cell.rowSpan ?? 1)).reduce((sum, value) => sum + value, 0) })) })));
7761
8057
  }
7762
8058
  const _exports = Object.freeze({ planTableBands: planTableBands, projectBandRows: projectBandRows, alignBandBlocks: alignBandBlocks });
7763
- _modules.set("58480ded0056f234aea5e0c26637308eea7708e97ccc9987242b62c4dbc4f9b8", _exports);
8059
+ _modules.set("9a88773878eacc51df9f05bb5ee90cc2b683b083ebea8fb54375092301388e96", _exports);
7764
8060
  return _exports;
7765
8061
  })();
7766
8062
 
7767
- const _m68 = _modules.get("49d84273bffe31099c2dd7f47ecb6d4a7de7b6efd0d3b7e3e02761bcb3646c9c") ?? (() => {
8063
+ const _m69 = _modules.get("07d2da8d8b93f12f172a48b97c1807e485555cf608e2eaa5b7610aa91d4a5305") ?? (() => {
7768
8064
  const { ExportCell } = _m5;
7769
8065
 
7770
8066
  const { copyExportLink } = _m7;
@@ -7775,11 +8071,11 @@ const { createTotals } = _m12;
7775
8071
 
7776
8072
  const { presentation, positive } = _m17;
7777
8073
 
7778
- const { displayText } = _m69;
8074
+ const { displayText, pdfBudgetText } = _m70;
7779
8075
 
7780
- const { capturePdfText, wrapPdfText } = _m70;
8076
+ const { capturePdfText, wrapPdfText } = _m71;
7781
8077
 
7782
- const { planTableBands, projectBandRows, alignBandBlocks } = _m72;
8078
+ const { planTableBands, projectBandRows, alignBandBlocks } = _m73;
7783
8079
 
7784
8080
  class PdfTableLayout {
7785
8081
  settings;
@@ -7792,11 +8088,13 @@ class PdfTableLayout {
7792
8088
  totals;
7793
8089
  repeatedColumns;
7794
8090
  structuredBandRows = new WeakMap();
8091
+ /** Plain/alternate ordinary-data defaults, validated only when a column first needs them. */
8092
+ dataPresentations = [];
7795
8093
  constructor(settings, fonts) {
7796
8094
  this.settings = settings;
7797
8095
  this.fonts = fonts;
7798
8096
  const { options, padding, fontSize, page, margins } = settings, columns = options.columns, available = page.width - margins.left - margins.right;
7799
- this.repeatedColumns = new Set(typeof options.wideTable === "object" ? options.wideTable.repeatColumns : []);
8097
+ this.repeatedColumns = new Set(settings.repeatedColumns);
7800
8098
  let digit;
7801
8099
  if (options.columnWidths && options.columnWidths.length !== columns.length)
7802
8100
  throw new RangeError("columnWidths must declare one point width per column.");
@@ -7837,13 +8135,22 @@ class PdfTableLayout {
7837
8135
  this.headings = headings;
7838
8136
  this.totals = createTotals(columns, options.footer?.totals);
7839
8137
  }
7840
- async cell(value, first, span, row, style) {
8138
+ async cell(value, first, span, row, style, ordinaryData = false) {
7841
8139
  const { options, padding, fontSize, budget } = this.settings, column = options.columns[first];
7842
8140
  const own = value instanceof ExportCell ? value.presentation : undefined;
7843
8141
  const link = value instanceof ExportCell && value.link ? copyExportLink(value.link) : undefined;
7844
- const combined = presentation({ ...(column.alignment === undefined ? {} : { alignment: column.alignment }),
7845
- ...(column.wrapText === undefined ? {} : { wrapText: column.wrapText }), ...style, ...own });
7846
- const font = this.fonts.select(combined.bold, combined.italic), width = this.widths.slice(first, first + span).reduce((n, w) => n + w, 0);
8142
+ const alternate = ordinaryData && row % 2 && options.alternateRowColor ? options.alternateRowColor : undefined;
8143
+ const slot = first * 2 + (alternate ? 1 : 0), reusable = ordinaryData && own === undefined;
8144
+ let combined = reusable ? this.dataPresentations[slot] : undefined;
8145
+ if (!combined) {
8146
+ const rowStyle = ordinaryData ? alternate ? { background: alternate } : {} : style;
8147
+ combined = presentation({ ...(column.alignment === undefined ? {} : { alignment: column.alignment }),
8148
+ ...(column.wrapText === undefined ? {} : { wrapText: column.wrapText }), ...rowStyle, ...own });
8149
+ // Validate only the first reached default; an authored cell may override invalid column defaults.
8150
+ if (reusable)
8151
+ this.dataPresentations[slot] = combined;
8152
+ }
8153
+ const font = this.fonts.select(combined.bold, combined.italic), width = span === 1 ? this.widths[first] : this.widths.slice(first, first + span).reduce((n, w) => n + w, 0);
7847
8154
  const context = { rowIndex: row, columnIndex: first, column }, raw = value instanceof ExportCell ? value.value : value;
7848
8155
  let text;
7849
8156
  if (options.formatRuns && row >= 0 && !(value instanceof ExportCell && value.text !== undefined)) {
@@ -7862,10 +8169,11 @@ class PdfTableLayout {
7862
8169
  throw new TypeError("Tagged PDF cell links require nonempty displayed text.");
7863
8170
  if (link && captured.runs.some(run => run.link))
7864
8171
  throw new TypeError("A PDF cell link cannot be combined with inline run links.");
8172
+ const budgetText = pdfBudgetText(captured.text, budget);
7865
8173
  if (this.bands)
7866
- budget.release(1, captured.text.length);
8174
+ budget.release(1, budgetText.length);
7867
8175
  else
7868
- budget.cell(captured.text, captured.text.length);
8176
+ budget.cell(budgetText, budgetText.length);
7869
8177
  const lines = await wrapPdfText(captured, this.fonts, fontSize, width - padding * 2, this.settings, combined.wrapText !== false);
7870
8178
  return { first, span, width, font, style: combined, lineHeight: lines.reduce((height, line) => Math.max(height, line.lineHeight), font.lineHeight(fontSize)),
7871
8179
  ...(link ? { link } : {}), ...(this.bands ? { captured } : {}),
@@ -7964,8 +8272,8 @@ class PdfTableLayout {
7964
8272
  const value = values[column], raw = value instanceof ExportCell ? value.value : value;
7965
8273
  if (!footer)
7966
8274
  this.totals[column].accept(raw);
7967
- const style = footer ? options.footerPresentation ?? {} : index % 2 && options.alternateRowColor ? { background: options.alternateRowColor } : {};
7968
- cells.push(await this.cell(value, column, 1, index, style));
8275
+ const cell = await this.cell(value, column, 1, index, footer ? options.footerPresentation ?? {} : undefined, !footer);
8276
+ cells.push(!footer && options.columns[column].rowHeader ? { ...cell, rowHeader: true } : cell);
7969
8277
  }
7970
8278
  return this.row(cells);
7971
8279
  }
@@ -7979,11 +8287,11 @@ class PdfTableLayout {
7979
8287
  }
7980
8288
  }
7981
8289
  const _exports = Object.freeze({ PdfTableLayout: PdfTableLayout });
7982
- _modules.set("49d84273bffe31099c2dd7f47ecb6d4a7de7b6efd0d3b7e3e02761bcb3646c9c", _exports);
8290
+ _modules.set("07d2da8d8b93f12f172a48b97c1807e485555cf608e2eaa5b7610aa91d4a5305", _exports);
7983
8291
  return _exports;
7984
8292
  })();
7985
8293
 
7986
- const _m74 = _modules.get("fc3b4b4c188e35a35e2451638421293be30b545b691151f1605295d87223a981") ?? (() => {
8294
+ const _m75 = _modules.get("67ad5f4adbd6bc0dddafe5cf82638d46d150237f4ff0bee15c0ace652d5095f4") ?? (() => {
7987
8295
  const { OfficeIMOError } = _m2;
7988
8296
 
7989
8297
  const { checkAbort } = _m4;
@@ -8027,7 +8335,7 @@ class PdfTableBandFlow {
8027
8335
  await this.flush();
8028
8336
  }
8029
8337
  async row(row, allowFirstFragment = false) {
8030
- const { padding, options } = this.layout.settings, minimumLines = this.layout.minimumRowLines(row), minimumHeight = this.layout.minimumRowHeight(row);
8338
+ const { padding, fontSize, options } = this.layout.settings, minimumLines = this.layout.minimumRowLines(row), minimumHeight = this.layout.minimumRowHeight(row);
8031
8339
  if (minimumHeight > this.painter.firstFullCapacity + .001 || minimumHeight > this.painter.continuationCapacity + .001)
8032
8340
  throw new RangeError("Repeated PDF identifiers must fit intact below the first and continued band headings/context.");
8033
8341
  // Keep ordinary rows intact when they fit fresh. A kept heading/caption can deliberately
@@ -8053,16 +8361,29 @@ class PdfTableBandFlow {
8053
8361
  const lines = Math.min(row.lines - first, Math.floor((this.capacity - this.height - padding * 2 + .001) / row.lineHeight));
8054
8362
  if (lines < 1)
8055
8363
  throw new RangeError("PDF page cannot fit a table line below horizontal band headings.");
8056
- const paintedLines = Math.max(lines, minimumLines), height = paintedLines * row.lineHeight + padding * 2;
8364
+ // Reserve one shared logical fragment, but paint only each band's visible cell geometry.
8365
+ const reservedLines = Math.max(lines, minimumLines), height = reservedLines * row.lineHeight + padding * 2;
8057
8366
  const projected = await this.layout.bandRows([row]);
8058
- const fragments = projected.map((rows, index) => [{ ...rows[0], lines: paintedLines, height,
8059
- cells: rows[0].cells.map(cell => {
8060
- const source = this.layout.bands[index].columns[cell.first];
8061
- const visible = this.layout.repeatedColumn(source) ? cell.lines : cell.lines.slice(first, first + lines);
8062
- const { height: _height, ...plain } = cell;
8063
- return { ...plain, lines: visible, ...(first > 0 && this.layout.repeatedColumn(source) ? { semanticArtifact: true } : {}) };
8064
- }) }]);
8065
- await this.accept({ rows: fragments, height, count: 1, completed: first + lines >= row.lines ? [row] : [] });
8367
+ const exhaustedBands = [];
8368
+ const fragments = projected.map((rows, index) => {
8369
+ let remaining = false;
8370
+ const cells = rows[0].cells.map(cell => {
8371
+ const source = this.layout.bands[index].columns[cell.first];
8372
+ const repeated = this.layout.repeatedColumn(source), visible = repeated ? cell.lines : cell.lines.slice(first, first + lines);
8373
+ if (!repeated && (visible.length > 0 || cell.link !== undefined))
8374
+ remaining = true;
8375
+ const { height: _height, ...plain } = cell;
8376
+ return { ...plain, lines: visible,
8377
+ lineHeight: visible.reduce((value, line) => Math.max(value, line.lineHeight), cell.font.lineHeight(fontSize)),
8378
+ ...(first > 0 && repeated ? { semanticArtifact: true } : {}) };
8379
+ });
8380
+ const fragmentLines = Math.max(1, ...cells.map(cell => cell.lines.length));
8381
+ const lineHeight = Math.max(this.layout.lineHeight, ...cells.filter(cell => cell.lines.length > 0).map(cell => cell.lineHeight));
8382
+ // Never omit an initial/new row, a structured block, or a nonrepeated link obligation.
8383
+ exhaustedBands.push(first > 0 && !remaining);
8384
+ return [{ ...rows[0], cells, lines: fragmentLines, lineHeight, height: fragmentLines * lineHeight + padding * 2 }];
8385
+ });
8386
+ await this.accept({ rows: fragments, height, count: 1, completed: first + lines >= row.lines ? [row] : [], exhaustedBands });
8066
8387
  first += lines;
8067
8388
  if (first < row.lines)
8068
8389
  await this.flush();
@@ -8074,7 +8395,7 @@ class PdfTableBandFlow {
8074
8395
  throw new OfficeIMOError("RESOURCE_LIMIT", "A structured PDF block exceeds maxTableWindowRows.");
8075
8396
  for (const row of rows)
8076
8397
  await this.painter.prepareRow?.(row);
8077
- await this.accept({ rows: projected, height, count: rows.length, completed: rows });
8398
+ await this.accept({ rows: projected, height, count: rows.length, completed: rows, exhaustedBands: projected.map(() => false) });
8078
8399
  }
8079
8400
  async keptRows(rows, allowFirstFragment = false) {
8080
8401
  const height = rows.reduce((sum, row) => sum + row.height, 0), fits = height <= this.painter.continuationCapacity + .001;
@@ -8088,6 +8409,8 @@ class PdfTableBandFlow {
8088
8409
  return;
8089
8410
  for (let band = 0; band < this.layout.bands.length; band++) {
8090
8411
  checkAbort(this.layout.settings.options.signal);
8412
+ if (!this.firstWindow && this.entries.length > 0 && this.entries.every(entry => entry.exhaustedBands[band]))
8413
+ continue;
8091
8414
  await this.painter.paint(band, this.headings[band], this.entries.flatMap(entry => entry.rows[band]), this.firstWindow ? this.caption : this.continuation, this.firstWindow, band === 0);
8092
8415
  }
8093
8416
  for (const entry of this.entries)
@@ -8101,11 +8424,11 @@ class PdfTableBandFlow {
8101
8424
  }
8102
8425
  }
8103
8426
  const _exports = Object.freeze({ PdfTableBandFlow: PdfTableBandFlow });
8104
- _modules.set("fc3b4b4c188e35a35e2451638421293be30b545b691151f1605295d87223a981", _exports);
8427
+ _modules.set("67ad5f4adbd6bc0dddafe5cf82638d46d150237f4ff0bee15c0ace652d5095f4", _exports);
8105
8428
  return _exports;
8106
8429
  })();
8107
8430
 
8108
- const _m75 = _modules.get("2d9fcf56989ea33b92c7f79cc6e1b06b7f5a82cf421559ce3e2f6b67813a17c3") ?? (() => {
8431
+ const _m76 = _modules.get("b52424ed74721dce3a2621456888fe1c6af0490627063e56f690df9abcb1dfff") ?? (() => {
8109
8432
  /** @internal Source-cell identities survive page fragments and horizontal band projections.
8110
8433
  * Only column headers and still-owned row objects remain reachable from this table owner. */
8111
8434
  class PdfTableStructure {
@@ -8115,6 +8438,8 @@ class PdfTableStructure {
8115
8438
  cells = new WeakMap();
8116
8439
  rows = new WeakMap();
8117
8440
  columnHeaders = [];
8441
+ /** Ordinary cells without row headers share immutable dictionary references, bounded by column count. */
8442
+ ordinaryAttributes = [];
8118
8443
  headerCount = 0;
8119
8444
  headersPrepared = false;
8120
8445
  constructor(structure, table, headers) {
@@ -8155,19 +8480,30 @@ class PdfTableStructure {
8155
8480
  return row.cells.map(cell => this.cells.get(cell));
8156
8481
  const rowId = this.structure.element("TR", parent);
8157
8482
  this.rows.set(row, rowId);
8158
- const ids = [];
8159
- let rowHeaderIdentifier;
8160
- // Allocating in source-column order preserves the record's logical reading order.
8483
+ const headers = row.cells.map((cell, index) => rowHeaderIndex === undefined ? cell.rowHeader === true : index === rowHeaderIndex);
8484
+ // Allocate in source order, then resolve every row header before associating even earlier data cells.
8485
+ // Generated summary labels override detail roles so numeric subtotal cells never become row headers.
8486
+ const ids = row.cells.map((cell, index) => {
8487
+ const id = this.structure.element(headers[index] ? "TH" : "TD", rowId);
8488
+ this.cells.set(cell, id);
8489
+ return id;
8490
+ });
8491
+ const rowHeaders = [];
8492
+ for (let index = 0; index < ids.length; index++)
8493
+ if (headers[index])
8494
+ rowHeaders.push(await this.structure.identifier(ids[index]));
8161
8495
  for (let index = 0; index < row.cells.length; index++) {
8162
- const cell = row.cells[index], isRowHeader = index === rowHeaderIndex;
8496
+ const cell = row.cells[index];
8497
+ if (!rowHeaders.length && cell.span === 1 && (cell.rowSpan ?? 1) === 1) {
8498
+ const attributes = this.ordinaryAttributes[cell.first] ??=
8499
+ await this.structure.attributeReference(this.attributeDictionary(cell, this.associations(cell)));
8500
+ this.structure.setAttributes(ids[index], attributes);
8501
+ continue;
8502
+ }
8163
8503
  const associations = this.associations(cell);
8164
- if (rowHeaderIdentifier !== undefined && !isRowHeader)
8165
- associations.push(rowHeaderIdentifier);
8166
- const id = this.structure.element(isRowHeader ? "TH" : "TD", rowId, this.attributes(cell, associations, isRowHeader ? "Row" : undefined));
8167
- this.cells.set(cell, id);
8168
- ids.push(id);
8169
- if (isRowHeader)
8170
- rowHeaderIdentifier = await this.structure.identifier(id);
8504
+ if (!headers[index])
8505
+ associations.push(...rowHeaders);
8506
+ this.structure.setAttributes(ids[index], this.attributes(cell, associations, headers[index] ? "Row" : undefined));
8171
8507
  }
8172
8508
  return ids;
8173
8509
  }
@@ -8193,17 +8529,20 @@ class PdfTableStructure {
8193
8529
  return [...headers].sort((left, right) => left.order - right.order).map(header => header.identifier);
8194
8530
  }
8195
8531
  attributes(cell, headers, scope) {
8196
- return " /A << /O /Table" + (scope === undefined ? "" : " /Scope /" + scope) +
8532
+ return " /A " + this.attributeDictionary(cell, headers, scope);
8533
+ }
8534
+ attributeDictionary(cell, headers, scope) {
8535
+ return "<< /O /Table" + (scope === undefined ? "" : " /Scope /" + scope) +
8197
8536
  (cell.span > 1 ? " /ColSpan " + cell.span : "") + ((cell.rowSpan ?? 1) > 1 ? " /RowSpan " + cell.rowSpan : "") +
8198
8537
  (headers.length ? " /Headers [" + headers.map(id => "(" + id + ")").join(" ") + "]" : "") + " >>";
8199
8538
  }
8200
8539
  }
8201
8540
  const _exports = Object.freeze({ PdfTableStructure: PdfTableStructure });
8202
- _modules.set("2d9fcf56989ea33b92c7f79cc6e1b06b7f5a82cf421559ce3e2f6b67813a17c3", _exports);
8541
+ _modules.set("b52424ed74721dce3a2621456888fe1c6af0490627063e56f690df9abcb1dfff", _exports);
8203
8542
  return _exports;
8204
8543
  })();
8205
8544
 
8206
- const _m76 = _modules.get("c5f5a4892d01de11258381c667d72e97f69410f87c8ddb307be3a7bbb3d6857a") ?? (() => {
8545
+ const _m77 = _modules.get("09c712096a1028af340e275d5a273e870546413797e71ed709657ad0482ea170") ?? (() => {
8207
8546
  const { OfficeIMOError } = _m2;
8208
8547
 
8209
8548
  const { pdfNumber, unicodeHex } = _m60;
@@ -8245,11 +8584,11 @@ function linkAnnotation(link, x, bottom, width, height, maxBytes, structParent,
8245
8584
  (link.tooltip === undefined ? "" : " /Contents <feff" + unicodeHex(link.tooltip) + ">") + " >>";
8246
8585
  }
8247
8586
  const _exports = Object.freeze({ linkAnnotation: linkAnnotation });
8248
- _modules.set("c5f5a4892d01de11258381c667d72e97f69410f87c8ddb307be3a7bbb3d6857a", _exports);
8587
+ _modules.set("09c712096a1028af340e275d5a273e870546413797e71ed709657ad0482ea170", _exports);
8249
8588
  return _exports;
8250
8589
  })();
8251
8590
 
8252
- const _m77 = _modules.get("93a48e0c780b5ff91a51fef40169622179fe47eb3f3bd159989ce92f83b57b80") ?? (() => {
8591
+ const _m78 = _modules.get("c68d18d668366fb9b96d1b53c79dc6305f84cb83c05e4942fcf1cdf96ed1a73f") ?? (() => {
8253
8592
  const { OfficeIMOError } = _m2;
8254
8593
 
8255
8594
  const { unicodeHex } = _m60;
@@ -8294,11 +8633,11 @@ function captureSection(block, settings) {
8294
8633
  ...(pageNumbers === undefined ? {} : { pageNumbers }) });
8295
8634
  }
8296
8635
  const _exports = Object.freeze({ captureBookmark: captureBookmark, captureSection: captureSection });
8297
- _modules.set("93a48e0c780b5ff91a51fef40169622179fe47eb3f3bd159989ce92f83b57b80", _exports);
8636
+ _modules.set("c68d18d668366fb9b96d1b53c79dc6305f84cb83c05e4942fcf1cdf96ed1a73f", _exports);
8298
8637
  return _exports;
8299
8638
  })();
8300
8639
 
8301
- const _m78 = _modules.get("31017b0c80e6e8ace64ed268298a4f155b992b295138be6ad0bffe8d9365710d") ?? (() => {
8640
+ const _m79 = _modules.get("a66257a32f03d958aa57be4de9da7f80b708cebca26b5cc6404de0ee11bfe052") ?? (() => {
8302
8641
  const { settings } = _m17;
8303
8642
 
8304
8643
  /** @internal Every section derives from captured document defaults, never the preceding section. */
@@ -8313,11 +8652,11 @@ function sectionSettings(base, section) {
8313
8652
  return { ...base, page: derived.page, margins: derived.margins, options };
8314
8653
  }
8315
8654
  const _exports = Object.freeze({ sectionSettings: sectionSettings });
8316
- _modules.set("31017b0c80e6e8ace64ed268298a4f155b992b295138be6ad0bffe8d9365710d", _exports);
8655
+ _modules.set("a66257a32f03d958aa57be4de9da7f80b708cebca26b5cc6404de0ee11bfe052", _exports);
8317
8656
  return _exports;
8318
8657
  })();
8319
8658
 
8320
- const _m73 = _modules.get("d0559c6c6f06cb5c1ba8d2494280159aa12c9514566498ca28b1a4a7fefd92db") ?? (() => {
8659
+ const _m74 = _modules.get("ce2a4bebe6ca61c77a6a974bd91981622b1f263d4e56e6b8466af41419151410") ?? (() => {
8321
8660
  const { OfficeIMOError } = _m2;
8322
8661
 
8323
8662
  const { checkAbort } = _m4;
@@ -8326,19 +8665,19 @@ const { pdfNumber } = _m60;
8326
8665
 
8327
8666
  const { color } = _m17;
8328
8667
 
8329
- const { PdfTableBandFlow } = _m74;
8668
+ const { PdfTableBandFlow } = _m75;
8330
8669
 
8331
- const { PdfTableStructure } = _m75;
8670
+ const { PdfTableStructure } = _m76;
8332
8671
 
8333
- const { wrapText, wrapTextCooperatively, synchronousText } = _m69;
8672
+ const { wrapText, wrapTextCooperatively, synchronousText, pdfBudgetText } = _m70;
8334
8673
 
8335
- const { linkAnnotation } = _m76;
8674
+ const { linkAnnotation } = _m77;
8336
8675
 
8337
8676
  const { unicodeHex } = _m60;
8338
8677
 
8339
- const { captureSection, captureBookmark } = _m77;
8678
+ const { captureSection, captureBookmark } = _m78;
8340
8679
 
8341
- const { sectionSettings } = _m78;
8680
+ const { sectionSettings } = _m79;
8342
8681
 
8343
8682
  /** @internal One page of drawing commands and O(page count) references, never the complete report body. */
8344
8683
  class PdfPages {
@@ -8476,8 +8815,9 @@ class PdfPages {
8476
8815
  const lineActualText = !this.structure && line.actualText !== undefined && line.actualText.length > 0;
8477
8816
  if (lineActualText)
8478
8817
  this.add("/Span << /ActualText <FEFF" + unicodeHex(line.actualText) + "> >> BDC\n");
8479
- const marks = new Map();
8818
+ let marks;
8480
8819
  if (line.actualText !== undefined && this.structure && element !== undefined) {
8820
+ marks = new Map();
8481
8821
  // Allocate MCIDs/Link children in logical order, then paint the independently positioned visual order.
8482
8822
  for (const segment of [...line.segments].sort((a, b) => (a.logicalStart ?? 0) - (b.logicalStart ?? 0))) {
8483
8823
  const owner = segment.link ? this.structure.link(element, segment.link) : element;
@@ -8485,7 +8825,7 @@ class PdfPages {
8485
8825
  }
8486
8826
  }
8487
8827
  for (const segment of line.segments) {
8488
- const registered = marks.get(segment), owner = registered?.owner ?? (segment.link && this.structure && element !== undefined ? this.structure.link(element, segment.link) : element);
8828
+ const registered = marks?.get(segment), owner = registered?.owner ?? (segment.link && this.structure && element !== undefined ? this.structure.link(element, segment.link) : element);
8489
8829
  if (segment.glyphs) {
8490
8830
  const font = segment.font, n = pdfNumber, shear = font.syntheticItalic ? .213 : 0;
8491
8831
  let cursor = x, command = "q " + this.rgb(segment.color ?? "111827") + " rg " + this.rgb(segment.color ?? "111827") + " RG\nBT /" + font.name + " " + n(size) + " Tf " +
@@ -8519,7 +8859,7 @@ class PdfPages {
8519
8859
  decoration(text, x, y, width) {
8520
8860
  if (!text)
8521
8861
  return;
8522
- this.settings.budget.cell(text);
8862
+ this.settings.budget.cell(pdfBudgetText(text, this.settings.budget));
8523
8863
  const font = this.fonts.select(), lines = wrapText(text, font, this.settings.fontSize, width, this.settings.limits.maxCellCharacters, 1, false);
8524
8864
  this.text(lines[0].text, font, this.settings.fontSize, x, y);
8525
8865
  }
@@ -8580,9 +8920,7 @@ class PdfPages {
8580
8920
  }
8581
8921
  const headers = preparedHeadings ?? (tableHeadings && this.layout ? this.activeHeadings ??= await this.layout.headers() : []), headerHeight = headers.reduce((n, h) => n + h.height, 0), continuation = tableHeadings && this.layout ? this.continuationCaption : undefined;
8582
8922
  if (continuation?.lines.length) {
8583
- if (this.continuationCaptionPaints++ > 0)
8584
- this.settings.budget.cell(continuation.text.text);
8585
- else
8923
+ if (this.continuationCaptionPaints++ === 0)
8586
8924
  this.tableCaptionOwner = this.captionAnnotations(continuation, this.tableCaptionOwner);
8587
8925
  await this.paragraphs([continuation], headerHeight + lineHeight + this.settings.padding * 2, true, { artifact: true, ...(this.tableCaptionOwner === undefined ? {} : { annotationParent: this.tableCaptionOwner }) });
8588
8926
  }
@@ -8700,7 +9038,7 @@ class PdfPages {
8700
9038
  async paragraph(text, style = {}, size = this.settings.fontSize, paginate = true, headingLevel) {
8701
9039
  await this.ensureStarted();
8702
9040
  const { margins, page, limits } = this.settings, font = this.fonts.select(style.bold, style.italic), lineHeight = font.lineHeight(size);
8703
- this.settings.budget.cell(text);
9041
+ this.settings.budget.cell(pdfBudgetText(text, this.settings.budget));
8704
9042
  const lines = await wrapTextCooperatively(text, font, size, page.width - margins.left - margins.right, limits.maxCellCharacters, limits.maxRowLines, true, this.settings.options.signal);
8705
9043
  if (lineHeight > page.height - margins.top - margins.bottom)
8706
9044
  throw new RangeError("PDF page cannot fit a paragraph line at the selected font metrics.");
@@ -8743,6 +9081,8 @@ class PdfPages {
8743
9081
  if (keepTogether && visible.length)
8744
9082
  await this.reserveSpace(visible.reduce((height, paragraph) => height + paragraph.height, 0) + reservations.at(-1), "Kept PDF paragraph group");
8745
9083
  for (const [index, paragraph] of visible.entries()) {
9084
+ if (paragraph.budgetOnPaint)
9085
+ this.settings.budget.cell(pdfBudgetText(paragraph.text.text, this.settings.budget));
8746
9086
  if (paragraph.keepTogether || paragraph.keepWithNext)
8747
9087
  await this.reserveSpace(paragraph.height + reservations[index], "Kept PDF paragraph chain");
8748
9088
  const { margins, page } = this.settings;
@@ -8795,10 +9135,11 @@ class PdfPages {
8795
9135
  /** The generated summary label is a row heading; no localized text/style inference is used. */
8796
9136
  summary(row) { this.summaryRows.add(row); }
8797
9137
  /** Begin an independent table on the current page, retaining its headings on continuation pages.
8798
- * Group context uses captionArtifact: it stays visually complete without duplicating logical headings. */
8799
- async beginTable(layout, preparedHeadings, minimumDataHeight = layout.lineHeight + this.settings.padding * 2, caption, continuationCaption, headingsOnNewPageOnly = false, captionArtifact = false) {
9138
+ * Group context uses captionArtifact: it stays visually complete without duplicating logical headings.
9139
+ * An already-painted opening path only suppresses its artifact caption on that existing page. */
9140
+ async beginTable(layout, preparedHeadings, minimumDataHeight = layout.lineHeight + this.settings.padding * 2, caption, continuationCaption, headingsOnNewPageOnly = false, captionArtifact = false, openingContextAlreadyPainted = false) {
8800
9141
  if (layout.bands)
8801
- return this.beginBands(layout, preparedHeadings, minimumDataHeight, caption, continuationCaption, captionArtifact);
9142
+ return this.beginBands(layout, preparedHeadings, minimumDataHeight, caption, continuationCaption, captionArtifact, openingContextAlreadyPainted);
8802
9143
  await this.ensureStarted();
8803
9144
  this.layout = layout;
8804
9145
  this.paintedHeaderCells = new WeakSet();
@@ -8812,7 +9153,7 @@ class PdfPages {
8812
9153
  // Its own headings remain available when it moves or splits onto a fresh page.
8813
9154
  const initialHeadings = headingsOnNewPageOnly && this.bodyAdded && !this.structure ? [] : headings;
8814
9155
  const height = initialHeadings.reduce((n, row) => n + row.height, 0);
8815
- if (caption) {
9156
+ if (caption && !(captionArtifact && openingContextAlreadyPainted)) {
8816
9157
  await this.reserveSpace(caption.height + height + minimumDataHeight, "Kept PDF table caption and first data fragment");
8817
9158
  this.tableCaptionOwner = captionArtifact ? this.captionAnnotations(caption)
8818
9159
  : caption.lines.length ? this.structure?.element("Caption", this.tableElement) : undefined;
@@ -8834,7 +9175,7 @@ class PdfPages {
8834
9175
  this.dataTop = this.y;
8835
9176
  }
8836
9177
  /** Bind the bounded logical-window owner to the existing physical page painter. */
8837
- async beginBands(layout, preparedHeadings, minimumDataHeight, caption, continuation, captionArtifact) {
9178
+ async beginBands(layout, preparedHeadings, minimumDataHeight, caption, continuation, captionArtifact, openingContextAlreadyPainted) {
8838
9179
  await this.ensureStarted();
8839
9180
  const logicalHeadings = preparedHeadings ?? await layout.headers(), headings = await layout.bandRows(logicalHeadings, true);
8840
9181
  const headerHeight = headings[0].reduce((sum, row) => sum + row.height, 0), { page, margins, padding } = this.settings;
@@ -8843,13 +9184,15 @@ class PdfPages {
8843
9184
  const continuationCapacity = page.height - margins.top - margins.bottom - headerHeight - (continuation?.height ?? 0);
8844
9185
  if (continuationCapacity + .001 < layout.lineHeight + padding * 2)
8845
9186
  throw new RangeError("PDF band headings and continuation context leave no room for a data line.");
8846
- if (this.y - margins.bottom - headerHeight - (caption?.height ?? 0) + .001 < minimum)
9187
+ let openingContextPainted = captionArtifact && openingContextAlreadyPainted;
9188
+ if (this.y - margins.bottom - headerHeight - (openingContextPainted ? 0 : caption?.height ?? 0) + .001 < minimum) {
8847
9189
  await this.pageBreak();
8848
- let initialOffset = page.height - margins.top - this.y;
8849
- const firstCapacity = this.y - margins.bottom - headerHeight - (caption?.height ?? 0);
9190
+ openingContextPainted = false;
9191
+ }
9192
+ const firstCapacity = this.y - margins.bottom - headerHeight - (openingContextPainted ? 0 : caption?.height ?? 0);
8850
9193
  if (firstCapacity + .001 < minimum)
8851
9194
  throw new RangeError("PDF band caption and headings leave no room for a data line.");
8852
- let captionPaints = 0, continuationPaints = 0;
9195
+ let continuationPaints = 0;
8853
9196
  this.tableElement = this.structure?.element("Table", this.groupParent);
8854
9197
  this.paintedHeaderCells = new WeakSet();
8855
9198
  let captionElement = this.structure && caption?.lines.length ? captionArtifact ? this.captionAnnotations(caption)
@@ -8863,21 +9206,16 @@ class PdfPages {
8863
9206
  this.bandFlow = new PdfTableBandFlow(layout, headings, { firstCapacity, firstFullCapacity, continuationCapacity,
8864
9207
  prepareRow: async (row) => { await this.tableStructure?.prepareHeaders(); await this.rowElements(row); },
8865
9208
  completeRow: async (row) => { await this.tableStructure?.completeRow(row.source ?? row); },
8866
- moveFirstToFreshPage: async () => { await this.pageBreak(); initialOffset = 0; },
9209
+ moveFirstToFreshPage: async () => { await this.pageBreak(); openingContextPainted = false; },
8867
9210
  paint: async (band, headers, rows, currentCaption, firstWindow, firstBand) => {
8868
9211
  if (!(firstWindow && firstBand))
8869
9212
  await this.pageBreak();
8870
- if (firstWindow && !firstBand)
8871
- this.y -= initialOffset;
8872
9213
  const frame = layout.bands[band];
8873
9214
  this.layout = { lefts: frame.lefts, lineHeight: layout.lineHeight, headers: async () => headers };
8874
9215
  this.bandCellBudget = true;
8875
9216
  try {
8876
- if (currentCaption?.lines.length) {
8877
- const paints = firstWindow ? captionPaints++ : continuationPaints++;
8878
- if (paints > 0)
8879
- this.settings.budget.cell(currentCaption.text.text);
8880
- if (!firstWindow && paints === 0)
9217
+ if (currentCaption?.lines.length && !(firstWindow && firstBand && openingContextPainted)) {
9218
+ if (!firstWindow && continuationPaints++ === 0)
8881
9219
  captionElement = this.captionAnnotations(currentCaption, captionElement);
8882
9220
  const annotationParent = captionElement;
8883
9221
  await this.paragraphs([currentCaption], headerHeight + minimum, true, firstWindow && firstBand && !captionArtifact ? { role: "Caption", keepOpen: true, ...(captionElement === undefined ? {} : { owner: captionElement }) }
@@ -8981,7 +9319,7 @@ class PdfPages {
8981
9319
  this.annotations = [];
8982
9320
  this.commandBytes = 0;
8983
9321
  this.current = 0;
8984
- await this.objects.flush();
9322
+ await this.objects.flushBytes();
8985
9323
  }
8986
9324
  async finish() {
8987
9325
  if (this.bandFlow) {
@@ -9009,11 +9347,11 @@ class PdfPages {
9009
9347
  }
9010
9348
  }
9011
9349
  const _exports = Object.freeze({ PdfPages: PdfPages });
9012
- _modules.set("d0559c6c6f06cb5c1ba8d2494280159aa12c9514566498ca28b1a4a7fefd92db", _exports);
9350
+ _modules.set("ce2a4bebe6ca61c77a6a974bd91981622b1f263d4e56e6b8466af41419151410", _exports);
9013
9351
  return _exports;
9014
9352
  })();
9015
9353
 
9016
- const _m80 = _modules.get("7a58e8ccb5164de51db14e39ca9695af6487c354df909509f0ae6bfac8ae3887") ?? (() => {
9354
+ const _m81 = _modules.get("7a58e8ccb5164de51db14e39ca9695af6487c354df909509f0ae6bfac8ae3887") ?? (() => {
9017
9355
  /** @internal Incremental PDF number tree: at most 64 entries/children per retained level. */
9018
9356
  class PdfParentTree {
9019
9357
  objects;
@@ -9076,15 +9414,38 @@ _modules.set("7a58e8ccb5164de51db14e39ca9695af6487c354df909509f0ae6bfac8ae3887",
9076
9414
  return _exports;
9077
9415
  })();
9078
9416
 
9079
- const _m79 = _modules.get("b37e74556d1c4d6d8617e6b585127f56635e2ea8e03105a026031f5d3adbce9e") ?? (() => {
9417
+ const _m80 = _modules.get("1c1828a3d6dfc2edda674566203e7aa8e97c984114b7928df13cb373859977d0") ?? (() => {
9080
9418
  const { OfficeIMOError } = _m2;
9081
9419
 
9082
9420
  const { checkAbort } = _m4;
9083
9421
 
9084
9422
  const { unicodeHex } = _m60;
9085
9423
 
9086
- const { PdfParentTree } = _m80;
9424
+ const { PdfParentTree } = _m81;
9087
9425
 
9426
+ /** Same-page marked content uses integer K; cross-page MCR and annotation OBJR stay explicit. */
9427
+ function structureChild(child) {
9428
+ return typeof child === "number" ? (child < 0 ? -child - 1 + " " : child + " 0 R ") : child + " ";
9429
+ }
9430
+ function structurePrefix(element) {
9431
+ return "<< /Type /StructElem /S /" + element.role + " /P " + element.parent + " 0 R" +
9432
+ (element.markedPage === undefined ? "" : " /Pg " + element.markedPage + " 0 R") +
9433
+ (element.identifier === undefined ? "" : " /ID (" + element.identifier + ")") + " /K [";
9434
+ }
9435
+ /** Keep the same bounded small-object representation for both completion paths. */
9436
+ function compactStructureBody(element, prefix) {
9437
+ const remaining = 32768 - prefix.length - element.attributes.length - 4;
9438
+ if (remaining < 0)
9439
+ return undefined;
9440
+ let children = "";
9441
+ for (const child of element.children) {
9442
+ const token = structureChild(child);
9443
+ if (children.length + token.length > remaining)
9444
+ return undefined;
9445
+ children += token;
9446
+ }
9447
+ return prefix + children + "]" + element.attributes + " >>";
9448
+ }
9088
9449
  /** A sorted name tree retains only a small open leaf and branch at each level. */
9089
9450
  class PdfStructureIds {
9090
9451
  objects;
@@ -9174,7 +9535,7 @@ class PdfStructure {
9174
9535
  checkAbort(this.settings.options.signal);
9175
9536
  if (++this.allocated > this.settings.limits.maxStructureElements)
9176
9537
  throw new OfficeIMOError("RESOURCE_LIMIT", "maxStructureElements exceeded.");
9177
- const id = this.objects.reserve(), element = { id, parent, role, children: [], attributes, linkIdentities: [] };
9538
+ const id = this.objects.reserve(), element = { id, parent, role, children: [], attributes };
9178
9539
  this.elements.set(id, element);
9179
9540
  const owner = this.elements.get(parent);
9180
9541
  // A continuation-only linked caption is discovered during painting, after rows may exist.
@@ -9185,6 +9546,20 @@ class PdfStructure {
9185
9546
  owner?.children.push(id);
9186
9547
  return id;
9187
9548
  }
9549
+ /** Attach resolved table associations while a source-ordered logical element is still open. */
9550
+ setAttributes(elementId, attributes) {
9551
+ const element = this.elements.get(elementId);
9552
+ if (!element)
9553
+ throw new Error("PDF structure attributes require an open logical owner.");
9554
+ element.attributes = attributes;
9555
+ }
9556
+ /** Write one immutable attribute dictionary. Its caller owns the bounded scope of reference reuse. */
9557
+ async attributeReference(dictionary) {
9558
+ checkAbort(this.settings.options.signal);
9559
+ const id = this.objects.reserve();
9560
+ await this.objects.object(id, dictionary);
9561
+ return " /A " + id + " 0 R";
9562
+ }
9188
9563
  /** Flat visual sections share the same logical Document and cumulative resource policy. */
9189
9564
  async beginSection() {
9190
9565
  await this.complete(this.section);
@@ -9218,7 +9593,8 @@ class PdfStructure {
9218
9593
  return existing;
9219
9594
  const id = this.element("Link", parent, alternativeText === undefined ? "" : " /Alt <feff" + unicodeHex(alternativeText) + ">");
9220
9595
  parents.set(parent, id);
9221
- this.elements.get(parent).linkIdentities.push(identity);
9596
+ const owner = this.elements.get(parent);
9597
+ (owner.linkIdentities ??= []).push(identity);
9222
9598
  return id;
9223
9599
  }
9224
9600
  /** Associate a native annotation in both directions: OBJR child and annotation ParentTree entry. */
@@ -9241,7 +9617,9 @@ class PdfStructure {
9241
9617
  throw new Error("Marked content requires an open logical owner.");
9242
9618
  const mcid = this.pageParents.length;
9243
9619
  this.pageParents.push(elementId);
9244
- element.children.push("<< /Type /MCR /Pg " + this.pageId + " 0 R /MCID " + mcid + " >>");
9620
+ element.markedPage ??= this.pageId;
9621
+ element.children.push(element.markedPage === this.pageId ? -(mcid + 1) :
9622
+ "<< /Type /MCR /Pg " + this.pageId + " 0 R /MCID " + mcid + " >>");
9245
9623
  return "/" + element.role + " << /MCID " + mcid + (actualText === undefined ? "" : " /ActualText <FEFF" + unicodeHex(actualText) + ">") + " >> BDC\n";
9246
9624
  }
9247
9625
  get pageDictionary() { return " /StructParents " + this.pageKey + " /Tabs /S"; }
@@ -9265,37 +9643,49 @@ class PdfStructure {
9265
9643
  if (!element)
9266
9644
  return;
9267
9645
  for (const child of element.children)
9268
- if (typeof child === "number" && this.elements.has(child))
9646
+ if (typeof child === "number" && child > 0 && !this.completeBuffered(child))
9269
9647
  await this.complete(child);
9270
9648
  checkAbort(this.settings.options.signal);
9271
- const prefix = "<< /Type /StructElem /S /" + element.role + " /P " + element.parent + " 0 R" +
9272
- (element.identifier === undefined ? "" : " /ID (" + element.identifier + ")") + " /K [";
9273
- const remaining = 32768 - prefix.length - element.attributes.length - 4;
9274
- let children = "", small = remaining >= 0;
9275
- if (small)
9276
- for (const child of element.children) {
9277
- const token = typeof child === "number" ? child + " 0 R " : child + " ";
9278
- if (children.length + token.length > remaining) {
9279
- small = false;
9280
- break;
9281
- }
9282
- children += token;
9283
- }
9649
+ const prefix = structurePrefix(element), body = compactStructureBody(element, prefix);
9284
9650
  // Most table cells/rows fit in one encoding. Large parents and alternatives remain streamed.
9285
- await this.objects.object(id, small ? prefix + children + "]" + element.attributes + " >>" : this.body(element));
9286
- for (const identity of element.linkIdentities) {
9287
- const parents = this.links.get(identity);
9288
- parents?.delete(id);
9289
- if (!parents?.size)
9290
- this.links.delete(identity);
9291
- }
9292
- this.elements.delete(id);
9293
- }
9294
- *body(element) {
9295
- yield "<< /Type /StructElem /S /" + element.role + " /P " + element.parent + " 0 R" +
9296
- (element.identifier === undefined ? "" : " /ID (" + element.identifier + ")") + " /K [";
9651
+ if (body !== undefined) {
9652
+ if (!this.objects.tryCompactObject(id, body))
9653
+ await this.objects.compactObject(id, body);
9654
+ }
9655
+ else
9656
+ await this.objects.object(id, this.body(element, prefix));
9657
+ this.releaseElement(element);
9658
+ }
9659
+ /** Close already-bufferable children without creating an async chain per leaf. A false result
9660
+ * leaves the current owner open for the existing awaited flush or ordinary-object path. */
9661
+ completeBuffered(id) {
9662
+ const element = this.elements.get(id);
9663
+ if (!element)
9664
+ return true;
9665
+ for (const child of element.children)
9666
+ if (typeof child === "number" && child > 0 && !this.completeBuffered(child))
9667
+ return false;
9668
+ checkAbort(this.settings.options.signal);
9669
+ const body = compactStructureBody(element, structurePrefix(element));
9670
+ if (body === undefined || !this.objects.tryCompactObject(id, body))
9671
+ return false;
9672
+ this.releaseElement(element);
9673
+ return true;
9674
+ }
9675
+ releaseElement(element) {
9676
+ if (element.linkIdentities)
9677
+ for (const identity of element.linkIdentities) {
9678
+ const parents = this.links.get(identity);
9679
+ parents?.delete(element.id);
9680
+ if (!parents?.size)
9681
+ this.links.delete(identity);
9682
+ }
9683
+ this.elements.delete(element.id);
9684
+ }
9685
+ *body(element, prefix) {
9686
+ yield prefix;
9297
9687
  for (const child of element.children)
9298
- yield typeof child === "number" ? child + " 0 R " : child + " ";
9688
+ yield structureChild(child);
9299
9689
  yield "]" + element.attributes + " >>";
9300
9690
  }
9301
9691
  async completeRow(cells) {
@@ -9332,11 +9722,11 @@ function graphicAlternative(value, settings) {
9332
9722
  return alternativeText;
9333
9723
  }
9334
9724
  const _exports = Object.freeze({ PdfStructure: PdfStructure, graphicAlternative: graphicAlternative });
9335
- _modules.set("b37e74556d1c4d6d8617e6b585127f56635e2ea8e03105a026031f5d3adbce9e", _exports);
9725
+ _modules.set("1c1828a3d6dfc2edda674566203e7aa8e97c984114b7928df13cb373859977d0", _exports);
9336
9726
  return _exports;
9337
9727
  })();
9338
9728
 
9339
- const _m81 = _modules.get("29578404bfc3df4d4b6b8036db67bd83212dbfe6182fadb62c55beb0584b5ca8") ?? (() => {
9729
+ const _m82 = _modules.get("52c78ca6833cee7e5a96b657e2c00172d550176daf2c95e742692f8416977bea") ?? (() => {
9340
9730
  const { OfficeIMOError } = _m2;
9341
9731
 
9342
9732
  const { checkAbort } = _m4;
@@ -9396,22 +9786,22 @@ class PdfOutlines {
9396
9786
  }
9397
9787
  }
9398
9788
  const _exports = Object.freeze({ PdfOutlines: PdfOutlines });
9399
- _modules.set("29578404bfc3df4d4b6b8036db67bd83212dbfe6182fadb62c55beb0584b5ca8", _exports);
9789
+ _modules.set("52c78ca6833cee7e5a96b657e2c00172d550176daf2c95e742692f8416977bea", _exports);
9400
9790
  return _exports;
9401
9791
  })();
9402
9792
 
9403
- const _m59 = _modules.get("50d54cd77023f226b6e16a5fd158bb587e58b21cbf9b731e51b093c4bc32afac") ?? (() => {
9793
+ const _m59 = _modules.get("6f13eca1cc6a3dee16e260ffb7ee38115cc2390084e9b156f0a90915fa5b18b9") ?? (() => {
9404
9794
  const { PdfObjects, unicodeHex } = _m60;
9405
9795
 
9406
- const { PdfFontResources } = _m61;
9796
+ const { PdfFontResources } = _m62;
9407
9797
 
9408
- const { PdfTableLayout } = _m68;
9798
+ const { PdfTableLayout } = _m69;
9409
9799
 
9410
- const { PdfPages } = _m73;
9800
+ const { PdfPages } = _m74;
9411
9801
 
9412
- const { PdfStructure } = _m79;
9802
+ const { PdfStructure } = _m80;
9413
9803
 
9414
- const { PdfOutlines } = _m81;
9804
+ const { PdfOutlines } = _m82;
9415
9805
 
9416
9806
  /** One resource/catalog owner shared by table convenience exports and composed documents. */
9417
9807
  class PdfWriteSession {
@@ -9428,7 +9818,7 @@ class PdfWriteSession {
9428
9818
  info;
9429
9819
  constructor(sink, settings, table = false) {
9430
9820
  this.settings = settings;
9431
- this.objects = new PdfObjects(sink, settings.options.signal, settings.budget.limits.maxOutputBytes);
9821
+ this.objects = new PdfObjects(sink, settings.options.signal, settings.budget.limits.maxOutputBytes, settings.options.compression !== false);
9432
9822
  this.root = this.objects.reserve();
9433
9823
  this.parent = this.objects.reserve();
9434
9824
  this.resources = this.objects.reserve();
@@ -9463,11 +9853,11 @@ class PdfWriteSession {
9463
9853
  }
9464
9854
  }
9465
9855
  const _exports = Object.freeze({ PdfWriteSession: PdfWriteSession });
9466
- _modules.set("50d54cd77023f226b6e16a5fd158bb587e58b21cbf9b731e51b093c4bc32afac", _exports);
9856
+ _modules.set("6f13eca1cc6a3dee16e260ffb7ee38115cc2390084e9b156f0a90915fa5b18b9", _exports);
9467
9857
  return _exports;
9468
9858
  })();
9469
9859
 
9470
- const _m58 = _modules.get("b236032efbf4bb6015fe9a546f753fac23127635b62114367e3c67776de83f5b") ?? (() => {
9860
+ const _m58 = _modules.get("4a658d1639cc333dc8b174a84d2d80a7e20bec2f0e86409d00c3f77199e2eda2") ?? (() => {
9471
9861
  const { BlobByteSink, withDestination } = _m3;
9472
9862
 
9473
9863
  const { beginTask, checkAbort, consumeRows, pause, taskYieldDue } = _m4;
@@ -9532,11 +9922,11 @@ async function writePdfTo(rows, destination, configuration) {
9532
9922
  });
9533
9923
  }
9534
9924
  const _exports = Object.freeze({ writePdf: writePdf, writePdfTo: writePdfTo });
9535
- _modules.set("b236032efbf4bb6015fe9a546f753fac23127635b62114367e3c67776de83f5b", _exports);
9925
+ _modules.set("4a658d1639cc333dc8b174a84d2d80a7e20bec2f0e86409d00c3f77199e2eda2", _exports);
9536
9926
  return _exports;
9537
9927
  })();
9538
9928
 
9539
- const _m85 = _modules.get("55eee1527c670926d154776e46828f4a0f8ae4df5c041a62ff851925b349f9db") ?? (() => {
9929
+ const _m86 = _modules.get("749d1ec5422c0087787f525ef42e3b8d3a94d2b70eb5e42d2e3723a870777ad6") ?? (() => {
9540
9930
  const { NotSupportedError, OfficeIMOError } = _m2;
9541
9931
 
9542
9932
  const { checkAbort, pause, taskYieldDue, withAbort } = _m4;
@@ -9800,16 +10190,16 @@ function paeth(left, up, upperLeft) {
9800
10190
  return a <= b && a <= c ? left : b <= c ? up : upperLeft;
9801
10191
  }
9802
10192
  const _exports = Object.freeze({ pngPixels: pngPixels });
9803
- _modules.set("55eee1527c670926d154776e46828f4a0f8ae4df5c041a62ff851925b349f9db", _exports);
10193
+ _modules.set("749d1ec5422c0087787f525ef42e3b8d3a94d2b70eb5e42d2e3723a870777ad6", _exports);
9804
10194
  return _exports;
9805
10195
  })();
9806
10196
 
9807
- const _m84 = _modules.get("f7e93a79ae9f66b8bbc83d3534c0f5b8df6e85447494ee0532d86f7c53aa7746") ?? (() => {
10197
+ const _m85 = _modules.get("7dca2d9ca5c43893abdaf86df5b1bcb1f3de3d5d33532d082fdfe04711999d21") ?? (() => {
9808
10198
  const { NotSupportedError, OfficeIMOError } = _m2;
9809
10199
 
9810
10200
  const { checkAbort, pause, taskYieldDue } = _m4;
9811
10201
 
9812
- const { pngPixels } = _m85;
10202
+ const { pngPixels } = _m86;
9813
10203
 
9814
10204
  /** Shared document image resources; source objects are captured on first consumption. */
9815
10205
  class PdfDocumentImages {
@@ -9934,11 +10324,11 @@ function jpegSize(bytes) {
9934
10324
  throw new TypeError("JPEG image has no complete frame and scan.");
9935
10325
  }
9936
10326
  const _exports = Object.freeze({ PdfDocumentImages: PdfDocumentImages });
9937
- _modules.set("f7e93a79ae9f66b8bbc83d3534c0f5b8df6e85447494ee0532d86f7c53aa7746", _exports);
10327
+ _modules.set("7dca2d9ca5c43893abdaf86df5b1bcb1f3de3d5d33532d082fdfe04711999d21", _exports);
9938
10328
  return _exports;
9939
10329
  })();
9940
10330
 
9941
- const _m86 = _modules.get("7904dbe183e98e39e18538292dfe007832e8efe39b812f98f1ec5bc96d4e5459") ?? (() => {
10331
+ const _m87 = _modules.get("3290c84fdf80725af802f497d947bc088aa8d93d9db0a33f6f829f9153aa6fd6") ?? (() => {
9942
10332
  const { OfficeIMOError } = _m2;
9943
10333
 
9944
10334
  const { checkAbort, pause, taskYieldDue } = _m4;
@@ -10021,11 +10411,11 @@ async function vectorCommands(block, settings, used) {
10021
10411
  commands.join("") + (fill !== undefined && stroke !== undefined ? "B" : fill !== undefined ? "f" : "S") + (fill !== undefined && fillRule === "evenodd" ? "*" : "") + "\n" };
10022
10412
  }
10023
10413
  const _exports = Object.freeze({ vectorCommands: vectorCommands });
10024
- _modules.set("7904dbe183e98e39e18538292dfe007832e8efe39b812f98f1ec5bc96d4e5459", _exports);
10414
+ _modules.set("3290c84fdf80725af802f497d947bc088aa8d93d9db0a33f6f829f9153aa6fd6", _exports);
10025
10415
  return _exports;
10026
10416
  })();
10027
10417
 
10028
- const _m87 = _modules.get("3bd0bb004f6877b01eb84161fdbcdee0e02df16f4d746e0c2b58d0e001e8a1fe") ?? (() => {
10418
+ const _m88 = _modules.get("da9ad00f94b9ae28e2e3de796928ff0c4eab1d73382b1441e7d779fad4278ef7") ?? (() => {
10029
10419
  const { NotSupportedError, OfficeIMOError } = _m2;
10030
10420
 
10031
10421
  const { checkAbort, pause, taskYieldDue } = _m4;
@@ -10268,25 +10658,27 @@ async function prepareDrawing(drawing, settings, fonts, used) {
10268
10658
  return { width: captured.width, height: captured.height, content: fragments.join(""), commands: captured.commands, elements: captured.elements };
10269
10659
  }
10270
10660
  const _exports = Object.freeze({ checkDrawingBlock: checkDrawingBlock, prepareDrawing: prepareDrawing });
10271
- _modules.set("3bd0bb004f6877b01eb84161fdbcdee0e02df16f4d746e0c2b58d0e001e8a1fe", _exports);
10661
+ _modules.set("da9ad00f94b9ae28e2e3de796928ff0c4eab1d73382b1441e7d779fad4278ef7", _exports);
10272
10662
  return _exports;
10273
10663
  })();
10274
10664
 
10275
- const _m88 = _modules.get("7e360ac48a118b9a220b682e942dcf53d2e14ed8e0730a8fde6df009828b0966") ?? (() => {
10665
+ const _m89 = _modules.get("5e4503b77b357ee6d9fad1f52690085b0f0b140cd3b550b63c5100ed95a92f88") ?? (() => {
10276
10666
  const { OfficeIMOError } = _m2;
10277
10667
 
10278
- const { capturePdfText, wrapPdfText } = _m70;
10668
+ const { capturePdfText, wrapPdfText } = _m71;
10279
10669
 
10280
10670
  const { positive } = _m17;
10281
10671
 
10282
10672
  const { resolveParagraphStyle } = _m19;
10283
10673
 
10284
- const { captureBookmark } = _m77;
10674
+ const { captureBookmark } = _m78;
10285
10675
 
10286
10676
  const { captureFields } = _m10;
10287
10677
 
10678
+ const { pdfBudgetText } = _m70;
10679
+
10288
10680
  /** @internal Copy public paragraph input before any cooperative layout or source enumeration. */
10289
- function captureParagraph(block, settings, fonts) {
10681
+ function captureParagraph(block, settings, fonts, budgetOnPaint = false) {
10290
10682
  if (!block || block.kind !== "paragraph")
10291
10683
  throw new TypeError("PDF paragraph groups accept paragraph blocks only.");
10292
10684
  const { text, headingLevel, presentation: inputStyle, fontSize, keepTogether, keepWithNext, spaceBefore, spaceAfter, style: styleName, bookmark: inputBookmark } = block;
@@ -10299,7 +10691,8 @@ function captureParagraph(block, settings, fonts) {
10299
10691
  }, settings.paragraphStyles);
10300
10692
  const style = resolved.presentation ?? Object.freeze({}), size = positive(resolved.fontSize ?? settings.fontSize, "Paragraph font size", 144);
10301
10693
  const bookmark = captureBookmark(inputBookmark, settings);
10302
- return Object.freeze({ text: capturePdfText(text, style, settings, fonts, false), style, size,
10694
+ return Object.freeze({ text: capturePdfText(text, style, settings, fonts, false, !budgetOnPaint), style, size,
10695
+ ...(budgetOnPaint ? { budgetOnPaint: true } : {}),
10303
10696
  ...(headingLevel === undefined ? {} : { headingLevel }), ...(bookmark === undefined ? {} : { bookmark }),
10304
10697
  keepTogether: resolved.keepTogether ?? false, keepWithNext: resolved.keepWithNext ?? false,
10305
10698
  spaceBefore: resolved.spaceBefore ?? 0, spaceAfter: resolved.spaceAfter ?? 8 });
@@ -10310,13 +10703,16 @@ function captureCaption(caption, settings, fonts) {
10310
10703
  Object.keys(caption).some(key => !["text", "style", "fontSize", "presentation", "spaceBefore", "spaceAfter"].includes(key)))
10311
10704
  throw new TypeError("PDF captions support text, style, fontSize, presentation, spaceBefore and spaceAfter.");
10312
10705
  return captureParagraph({ ...captureFields(caption, ["text", "style", "fontSize", "presentation", "spaceBefore", "spaceAfter"]),
10313
- kind: "paragraph", keepTogether: true, keepWithNext: true }, settings, fonts);
10706
+ kind: "paragraph", keepTogether: true, keepWithNext: true }, settings, fonts, true);
10314
10707
  }
10315
10708
  /** @internal Layout is bounded by the same per-cell text and wrapped-line limits as table cells. */
10316
10709
  async function prepareParagraph(captured, settings, fonts, width = settings.page.width - settings.margins.left - settings.margins.right) {
10317
10710
  if (!captured.text.text)
10318
10711
  return { ...captured, lines: [], height: 0, firstHeight: 0 };
10319
- settings.budget.cell(captured.text.text, captured.text.text.length);
10712
+ if (!captured.budgetOnPaint) {
10713
+ const budgetText = pdfBudgetText(captured.text.text, settings.budget);
10714
+ settings.budget.cell(budgetText, budgetText.length);
10715
+ }
10320
10716
  const lines = await wrapPdfText(captured.text, fonts, captured.size, positive(width, "Paragraph width"), settings);
10321
10717
  return { ...captured, lines, height: captured.spaceBefore + lines.reduce((height, line) => height + line.lineHeight, 0) + captured.spaceAfter,
10322
10718
  firstHeight: captured.spaceBefore + lines[0].lineHeight };
@@ -10346,14 +10742,14 @@ function paragraphStartHeight(paragraphs) {
10346
10742
  return required;
10347
10743
  }
10348
10744
  const _exports = Object.freeze({ captureParagraph: captureParagraph, captureCaption: captureCaption, prepareParagraph: prepareParagraph, checkParagraphBuffer: checkParagraphBuffer, paragraphStartHeight: paragraphStartHeight });
10349
- _modules.set("7e360ac48a118b9a220b682e942dcf53d2e14ed8e0730a8fde6df009828b0966", _exports);
10745
+ _modules.set("5e4503b77b357ee6d9fad1f52690085b0f0b140cd3b550b63c5100ed95a92f88", _exports);
10350
10746
  return _exports;
10351
10747
  })();
10352
10748
 
10353
- const _m89 = _modules.get("57e348628775da4857f6a81eb64a59b0ce1669657fa7b1fa2a7bb17485be2475") ?? (() => {
10354
- const { capturePdfText, wrapPdfText } = _m70;
10749
+ const _m90 = _modules.get("1d57c429705ae0cbc14d98dcfef4c8a6c2df06f391c8f58e99cacb02f2d1cbc7") ?? (() => {
10750
+ const { capturePdfText, wrapPdfText } = _m71;
10355
10751
 
10356
- const { captureParagraph, prepareParagraph } = _m88;
10752
+ const { captureParagraph, prepareParagraph } = _m89;
10357
10753
 
10358
10754
  const { resolveParagraphStyle } = _m19;
10359
10755
 
@@ -10404,11 +10800,11 @@ async function prepareListItem(item, index, options, settings, fonts) {
10404
10800
  height: paragraph.height + lineHeight - first.lineHeight, firstHeight: paragraph.spaceBefore + lineHeight } };
10405
10801
  }
10406
10802
  const _exports = Object.freeze({ captureListOptions: captureListOptions, prepareListItem: prepareListItem });
10407
- _modules.set("57e348628775da4857f6a81eb64a59b0ce1669657fa7b1fa2a7bb17485be2475", _exports);
10803
+ _modules.set("1d57c429705ae0cbc14d98dcfef4c8a6c2df06f391c8f58e99cacb02f2d1cbc7", _exports);
10408
10804
  return _exports;
10409
10805
  })();
10410
10806
 
10411
- const _m91 = _modules.get("0c51d89c5cf0ebfeddbe03d5cd04c8bd29a78cdf70b244a68d44fdf82f0f0016") ?? (() => {
10807
+ const _m92 = _modules.get("d04686d2c067355dfd215333b83eb5f79f96e9e4be49f942e050f21ac0795343") ?? (() => {
10412
10808
  const { assertGroupedReportSource } = _m8;
10413
10809
 
10414
10810
  const { captureFields } = _m10;
@@ -10454,26 +10850,26 @@ function captureGroupedPdfTableOptions(configuration) {
10454
10850
  ...(captured.footerPresentation === undefined ? {} : { footerPresentation: presentation(captured.footerPresentation) }) });
10455
10851
  }
10456
10852
  const _exports = Object.freeze({ groupedPdfLabelFields: groupedPdfLabelFields, groupedPdfTableFields: groupedPdfTableFields, pdfGroupedTable: pdfGroupedTable, captureGroupedPdfTableOptions: captureGroupedPdfTableOptions });
10457
- _modules.set("0c51d89c5cf0ebfeddbe03d5cd04c8bd29a78cdf70b244a68d44fdf82f0f0016", _exports);
10853
+ _modules.set("d04686d2c067355dfd215333b83eb5f79f96e9e4be49f942e050f21ac0795343", _exports);
10458
10854
  return _exports;
10459
10855
  })();
10460
10856
 
10461
- const _m90 = _modules.get("1b926dd1b74341a9639f4b5672eff09e7f4454be52608ee78d5782bf3417f0f7") ?? (() => {
10857
+ const _m91 = _modules.get("d43e573fd5bad18a7ec2d71752168c422c4f8fabbc51f1cef8e3ba389f298715") ?? (() => {
10462
10858
  const { assertGroupedReportSource, groupedReportOperation } = _m8;
10463
10859
 
10464
10860
  const { consumeRows } = _m4;
10465
10861
 
10466
10862
  const { ExportCell } = _m5;
10467
10863
 
10468
- const { captureGroupedPdfTableOptions } = _m91;
10864
+ const { captureGroupedPdfTableOptions } = _m92;
10469
10865
 
10470
10866
  const { settings } = _m17;
10471
10867
 
10472
- const { PdfTableLayout } = _m68;
10868
+ const { PdfTableLayout } = _m69;
10473
10869
 
10474
- const { captureCaption, captureParagraph, prepareParagraph } = _m88;
10870
+ const { captureCaption, captureParagraph, prepareParagraph } = _m89;
10475
10871
 
10476
- const { synchronousText } = _m69;
10872
+ const { synchronousText } = _m70;
10477
10873
 
10478
10874
  /** @internal Render one analytical source in the existing document session. Retain one detail row and
10479
10875
  * at most four closing subtotals. All captions, rows, pages, bytes and fonts use the document owners. */
@@ -10502,10 +10898,44 @@ async function renderGroupedPdfTable(block, context) {
10502
10898
  const continuationLabels = new WeakMap();
10503
10899
  let pending;
10504
10900
  const closing = [];
10505
- const summaryValues = (label, values) => Object.freeze([
10901
+ const aggregatePositions = report.columns.flatMap((column, index) => Object.hasOwn(report.totals, column.key) ? [index] : []);
10902
+ const summaryValues = (label, values, positions) => Object.freeze([
10506
10903
  new ExportCell(label, { text: label, presentation: table.options.footerPresentation }),
10507
- ...values.map(value => new ExportCell(value, { presentation: table.options.footerPresentation }))
10904
+ ...(positions ? positions.map(index => values[index]) : values).map(value => new ExportCell(value, { presentation: table.options.footerPresentation }))
10508
10905
  ]);
10906
+ // Independent summaries have no detail values in non-aggregate columns. Project their
10907
+ // declared operations, including zero/null results, rather than emitting label-only bands.
10908
+ // Keep callback positions in the original source model after this physical projection.
10909
+ const summaryLayouts = new Map();
10910
+ const summaryLayout = (grand) => {
10911
+ const existing = summaryLayouts.get(grand);
10912
+ if (existing)
10913
+ return existing;
10914
+ const positions = [0, ...aggregatePositions.map(index => index + 1)];
10915
+ const projected = positions.map(position => {
10916
+ const column = columns[position];
10917
+ if (!grand)
10918
+ return column;
10919
+ const { groups: _groups, ...leaf } = column;
10920
+ return leaf;
10921
+ });
10922
+ const originalPosition = (position) => {
10923
+ const columnIndex = positions[position.columnIndex];
10924
+ return { ...position, columnIndex, column: columns[columnIndex] };
10925
+ };
10926
+ const repeatColumns = positions.flatMap((position, index) => position === 0 || table.repeatedColumns.includes(position) ? [index] : []);
10927
+ const wideTable = table.options.wideTable;
10928
+ const projectedSettings = { ...sharedTable,
10929
+ repeatedColumns: Object.freeze(repeatColumns), options: { ...table.options, columns: projected,
10930
+ ...(table.options.columnWidths === undefined ? {} : { columnWidths: positions.map(position => table.options.columnWidths[position]) }),
10931
+ ...(typeof wideTable !== "object" ? {} : { wideTable: { ...wideTable, repeatColumns } }),
10932
+ ...(table.options.formatValue === undefined ? {} : { formatValue: (value, position) => table.options.formatValue(value, originalPosition(position)) }),
10933
+ ...(table.options.formatRuns === undefined ? {} : { formatRuns: (value, position) => table.options.formatRuns(value, originalPosition(position)) })
10934
+ } };
10935
+ const projectedLayout = new PdfTableLayout(projectedSettings, fonts);
10936
+ summaryLayouts.set(grand, projectedLayout);
10937
+ return projectedLayout;
10938
+ };
10509
10939
  const prepareGroupContext = async () => {
10510
10940
  const caption = await prepareParagraph(captureCaption({ text: path.map(group => group.label).join("\n"),
10511
10941
  presentation: { bold: true }, spaceAfter: 4 }, pages.settings, fonts), pages.settings, fonts);
@@ -10568,26 +10998,46 @@ async function renderGroupedPdfTable(block, context) {
10568
10998
  ...(group.label.trim() ? { bookmark: { title: group.label, level: (groupHeadingLevel + group.level) } } : {})
10569
10999
  }, pages.settings, fonts), pages.settings, fonts));
10570
11000
  const groupHeight = groupHeadings.reduce((height, heading) => height + heading.height, 0);
10571
- await context.flushParagraphs((caption?.height ?? 0) + groupHeight + headingHeight + minimum);
10572
- let followingHeight = groupHeight + caption.height + headingHeight + minimum;
11001
+ // Newly opened semantic headings already paint the end of this path. Only the open
11002
+ // ancestor prefix needs an artifact here; later physical bands still paint the full path.
11003
+ const ancestorCaption = semantic && semanticDepth > 0 ? await prepareParagraph(captureCaption({
11004
+ text: path.slice(0, semanticDepth).map(group => group.label).join("\n"), presentation: { bold: true }, spaceAfter: 4
11005
+ }, pages.settings, fonts), pages.settings, fonts) : undefined;
11006
+ const openingHeight = semantic ? (ancestorCaption?.height ?? 0) + groupHeight : caption.height;
11007
+ await context.flushParagraphs(openingHeight + headingHeight + minimum);
11008
+ if (ancestorCaption)
11009
+ await pages.paragraphs([ancestorCaption], groupHeight + headingHeight + minimum, true, { artifact: true });
11010
+ let followingHeight = groupHeight + (semantic ? 0 : caption.height) + headingHeight + minimum;
10573
11011
  for (const heading of groupHeadings) {
10574
11012
  followingHeight -= heading.height;
10575
11013
  await pages.beginGroup(semanticDepth++, heading, followingHeight);
10576
11014
  }
10577
- await pages.beginTable(layout, headings, minimum, caption, continuation, false, semantic);
11015
+ await pages.beginTable(layout, headings, minimum, caption, continuation, false, semantic, semantic);
10578
11016
  started = true;
10579
11017
  firstFragment = (caption?.lines.length ?? 0) > 0 || groupHeadings.some(heading => heading.lines.length > 0);
10580
11018
  };
10581
- const semanticSubtotal = async (row, level) => {
11019
+ const semanticSubtotal = async (row, level, values) => {
11020
+ if (level === report.groupBy.length - 1) {
11021
+ // A leaf's own subtotal shares its detail table and header identities. Keep the last
11022
+ // detail/summary bundle when it fits; the existing flow owns continuation and limits.
11023
+ pages.summary(row);
11024
+ closing.push(row);
11025
+ await finishLeaf();
11026
+ await pages.endGroup(level);
11027
+ semanticDepth = level;
11028
+ path = path.slice(0, level);
11029
+ return;
11030
+ }
10582
11031
  await finishLeaf();
10583
11032
  const { caption, continuation } = await prepareGroupContext();
10584
- const minimum = layout.minimumRowHeight(row);
10585
- await context.flushParagraphs(caption.height + headingHeight + minimum);
11033
+ const projected = summaryLayout(false), summaryHeadings = await projected.headers();
11034
+ const summaryRow = await projected.data(values, 0, true), minimum = projected.minimumRowHeight(summaryRow);
11035
+ await context.flushParagraphs(caption.height + await projected.blockHeight(summaryHeadings) + minimum);
10586
11036
  // An ancestor subtotal belongs to that ancestor's section, never the final child's table.
10587
11037
  // Its own visible column headings keep the separate logical summary table truthful.
10588
- await pages.beginTable(layout, headings, minimum, caption, continuation, false, true);
10589
- pages.summary(row);
10590
- await pages.row(row, caption.lines.length > 0 || headings.length > 0);
11038
+ await pages.beginTable(projected, summaryHeadings, minimum, caption, continuation, false, true);
11039
+ pages.summary(summaryRow);
11040
+ await pages.row(summaryRow, caption.lines.length > 0 || summaryHeadings.length > 0);
10591
11041
  await pages.endTable();
10592
11042
  await pages.endGroup(level);
10593
11043
  semanticDepth = level;
@@ -10597,25 +11047,19 @@ async function renderGroupedPdfTable(block, context) {
10597
11047
  await finishLeaf();
10598
11048
  if (!includeGrandTotal && summary.rows !== 0)
10599
11049
  return;
10600
- const completeColumns = summary.rows === 0 ? columns : columns.map(column => {
10601
- const { groups: _groups, ...leaf } = column;
10602
- return leaf;
10603
- });
10604
- const completeTable = settings({ ...table.options, columns: completeColumns,
10605
- includeHeader: input.includeHeader ?? true });
10606
- const completeLayout = summary.rows === 0 ? layout : new PdfTableLayout({ ...completeTable, budget: prepared.budget }, fonts);
11050
+ const completeLayout = summary.rows === 0 ? layout : summaryLayout(true);
10607
11051
  const completeHeadings = summary.rows === 0 ? headings : await completeLayout.headers();
10608
11052
  rowIndex = -1;
10609
11053
  let total;
10610
11054
  if (includeGrandTotal) {
10611
11055
  context.acceptRow(false);
10612
- total = await completeLayout.data(summaryValues(synchronousText(grandTotalLabel(summary), "grandTotalLabel"), summary.totals), 0, true);
11056
+ total = await completeLayout.data(summaryValues(synchronousText(grandTotalLabel(summary), "grandTotalLabel"), summary.totals, summary.rows === 0 ? undefined : aggregatePositions), 0, true);
10613
11057
  }
10614
11058
  if (!completeHeadings.length && !total)
10615
11059
  return;
10616
11060
  const minimum = total ? completeLayout.minimumRowHeight(total) : 0;
10617
11061
  await context.flushParagraphs(await completeLayout.blockHeight(completeHeadings) + minimum);
10618
- await pages.beginTable(completeLayout, completeHeadings, minimum, undefined, undefined, !semantic && summary.rows !== 0);
11062
+ await pages.beginTable(completeLayout, completeHeadings, minimum);
10619
11063
  if (total) {
10620
11064
  if (semantic)
10621
11065
  pages.summary(total);
@@ -10643,9 +11087,11 @@ async function renderGroupedPdfTable(block, context) {
10643
11087
  case "groupEnd": {
10644
11088
  rowIndex = -1;
10645
11089
  context.acceptRow(false);
10646
- const row = await layout.data(summaryValues(synchronousText(subtotalLabel(event), "subtotalLabel"), event.totals), 0, true);
11090
+ const separate = semantic && event.level !== report.groupBy.length - 1;
11091
+ const values = summaryValues(synchronousText(subtotalLabel(event), "subtotalLabel"), event.totals, separate ? aggregatePositions : undefined);
11092
+ const row = separate ? undefined : await layout.data(values, 0, true);
10647
11093
  if (semantic)
10648
- await semanticSubtotal(row, event.level);
11094
+ await semanticSubtotal(row, event.level, values);
10649
11095
  else
10650
11096
  closing.push(row);
10651
11097
  break;
@@ -10662,11 +11108,11 @@ async function renderGroupedPdfTable(block, context) {
10662
11108
  }
10663
11109
  }
10664
11110
  const _exports = Object.freeze({ renderGroupedPdfTable: renderGroupedPdfTable });
10665
- _modules.set("1b926dd1b74341a9639f4b5672eff09e7f4454be52608ee78d5782bf3417f0f7", _exports);
11111
+ _modules.set("d43e573fd5bad18a7ec2d71752168c422c4f8fabbc51f1cef8e3ba389f298715", _exports);
10666
11112
  return _exports;
10667
11113
  })();
10668
11114
 
10669
- const _m83 = _modules.get("0b53b552fbfad950bf3455ae0266ec34d40deadc96dd3e1fe03d26cce63ea40f") ?? (() => {
11115
+ const _m84 = _modules.get("67060b0c8b6d3f6a6d9d53d41dd780ee99ffdae0ed0f90004ac675d382a80223") ?? (() => {
10670
11116
  const { BlobByteSink, withDestination } = _m3;
10671
11117
 
10672
11118
  const { OfficeIMOError } = _m2;
@@ -10683,25 +11129,25 @@ const { settings, captureWideTable } = _m17;
10683
11129
 
10684
11130
  const { pdfNumber: n } = _m60;
10685
11131
 
10686
- const { PdfTableLayout } = _m68;
11132
+ const { PdfTableLayout } = _m69;
10687
11133
 
10688
11134
  const { PdfWriteSession } = _m59;
10689
11135
 
10690
- const { PdfDocumentImages } = _m84;
11136
+ const { PdfDocumentImages } = _m85;
10691
11137
 
10692
- const { vectorCommands } = _m86;
11138
+ const { vectorCommands } = _m87;
10693
11139
 
10694
- const { graphicAlternative } = _m79;
11140
+ const { graphicAlternative } = _m80;
10695
11141
 
10696
- const { checkDrawingBlock, prepareDrawing } = _m87;
11142
+ const { checkDrawingBlock, prepareDrawing } = _m88;
10697
11143
 
10698
- const { captureParagraph, captureCaption, prepareParagraph, checkParagraphBuffer, paragraphStartHeight } = _m88;
11144
+ const { captureParagraph, captureCaption, prepareParagraph, checkParagraphBuffer, paragraphStartHeight } = _m89;
10699
11145
 
10700
- const { captureListOptions, prepareListItem } = _m89;
11146
+ const { captureListOptions, prepareListItem } = _m90;
10701
11147
 
10702
- const { captureSection } = _m77;
11148
+ const { captureSection } = _m78;
10703
11149
 
10704
- const { renderGroupedPdfTable } = _m90;
11150
+ const { renderGroupedPdfTable } = _m91;
10705
11151
 
10706
11152
  const tableOptionFields = ["columns", "includeHeader", "headerRows", "footer", "headerPresentation", "footerPresentation", "alternateRowColor", "columnWidths", "wideTable", "formatValue", "formatRuns"];
10707
11153
  /** Capture typed columns for a single-use table source in a composed document. */
@@ -10956,22 +11402,22 @@ function captureTableOptions(options) {
10956
11402
  return { ...captured, ...(captured.wideTable === undefined ? {} : { wideTable: captureWideTable(captured.wideTable) }) };
10957
11403
  }
10958
11404
  const _exports = Object.freeze({ pdfTable: pdfTable, writePdfDocument: writePdfDocument, writePdfDocumentTo: writePdfDocumentTo });
10959
- _modules.set("0b53b552fbfad950bf3455ae0266ec34d40deadc96dd3e1fe03d26cce63ea40f", _exports);
11405
+ _modules.set("67060b0c8b6d3f6a6d9d53d41dd780ee99ffdae0ed0f90004ac675d382a80223", _exports);
10960
11406
  return _exports;
10961
11407
  })();
10962
11408
 
10963
- const _m82 = _modules.get("3f9d005ed3e31b1080249d471774fa84044f9fa1ec30d71d01d3c2cf77818c4d") ?? (() => {
11409
+ const _m83 = _modules.get("91d1ab43a388d5d7a78db095e27ed8b0f6d28004358cbf296ac818479c58c557") ?? (() => {
10964
11410
  const { assertGroupedReportSource } = _m8;
10965
11411
 
10966
11412
  const { BlobByteSink } = _m3;
10967
11413
 
10968
- const { writePdfDocumentTo } = _m83;
11414
+ const { writePdfDocumentTo } = _m84;
10969
11415
 
10970
11416
  const { pdfOptionFields } = _m17;
10971
11417
 
10972
11418
  const { captureFields } = _m10;
10973
11419
 
10974
- const { pdfGroupedTable, groupedPdfLabelFields, groupedPdfTableFields } = _m91;
11420
+ const { pdfGroupedTable, groupedPdfLabelFields, groupedPdfTableFields } = _m92;
10975
11421
 
10976
11422
 
10977
11423
 
@@ -11005,15 +11451,15 @@ async function writeGroupedPdfTo(report, destination, configuration) {
11005
11451
  delete documentOptions.footer;
11006
11452
  return writePdfDocumentTo([pdfGroupedTable(report, tableOptions)], destination, documentOptions);
11007
11453
  }
11008
- const _exports = Object.freeze({ pdfGroupedTable: _m91.pdfGroupedTable, writeGroupedPdf: writeGroupedPdf, writeGroupedPdfTo: writeGroupedPdfTo });
11009
- _modules.set("3f9d005ed3e31b1080249d471774fa84044f9fa1ec30d71d01d3c2cf77818c4d", _exports);
11454
+ const _exports = Object.freeze({ pdfGroupedTable: _m92.pdfGroupedTable, writeGroupedPdf: writeGroupedPdf, writeGroupedPdfTo: writeGroupedPdfTo });
11455
+ _modules.set("91d1ab43a388d5d7a78db095e27ed8b0f6d28004358cbf296ac818479c58c557", _exports);
11010
11456
  return _exports;
11011
11457
  })();
11012
11458
 
11013
- const _m92 = _modules.get("6ac9b32affc9008e5bd8620fd3792022dfdcd4e0fe51c678bb2ba26bcbe95fd9") ?? (() => {
11014
- const { fontProgram } = _m62;
11459
+ const _m93 = _modules.get("3d777096288d1be55a05a80bc015d4674212e587703f25a7e7cf99a8065feb86") ?? (() => {
11460
+ const { fontProgram } = _m63;
11015
11461
 
11016
- const { resolveScalar, selectFont, validateFonts } = _m66;
11462
+ const { resolveScalar, selectFont, validateFonts } = _m67;
11017
11463
 
11018
11464
  /**
11019
11465
  * Check one text run against the writer's selected font and scalar-layout rules.
@@ -11046,18 +11492,18 @@ function preflightPdfText(text, options = {}) {
11046
11492
  return { supported: true };
11047
11493
  }
11048
11494
  const _exports = Object.freeze({ preflightPdfText: preflightPdfText });
11049
- _modules.set("6ac9b32affc9008e5bd8620fd3792022dfdcd4e0fe51c678bb2ba26bcbe95fd9", _exports);
11495
+ _modules.set("3d777096288d1be55a05a80bc015d4674212e587703f25a7e7cf99a8065feb86", _exports);
11050
11496
  return _exports;
11051
11497
  })();
11052
11498
 
11053
- const _m57 = _modules.get("71169c44be949c319579ad95fc607b6a64115646c56e93cb6b58d6b9e26fb0bf") ?? (() => {
11499
+ const _m57 = _modules.get("dcf6840f5eda4f8535cb4e226425587c2ae436c0eebfbd746aa0bc8a7acb6c4c") ?? (() => {
11054
11500
 
11055
- const _exports = Object.freeze({ writePdf: _m58.writePdf, writePdfTo: _m58.writePdfTo, writeGroupedPdf: _m82.writeGroupedPdf, writeGroupedPdfTo: _m82.writeGroupedPdfTo, pdfGroupedTable: _m82.pdfGroupedTable, createGroupedReport: _m8.createGroupedReport, writePdfDocument: _m83.writePdfDocument, writePdfDocumentTo: _m83.writePdfDocumentTo, pdfTable: _m83.pdfTable, PdfFont: _m62.PdfFont, preflightPdfText: _m92.preflightPdfText, ExportCell: _m5.ExportCell, saveBlob: _m1.saveBlob });
11056
- _modules.set("71169c44be949c319579ad95fc607b6a64115646c56e93cb6b58d6b9e26fb0bf", _exports);
11501
+ const _exports = Object.freeze({ writePdf: _m58.writePdf, writePdfTo: _m58.writePdfTo, writeGroupedPdf: _m83.writeGroupedPdf, writeGroupedPdfTo: _m83.writeGroupedPdfTo, pdfGroupedTable: _m83.pdfGroupedTable, createGroupedReport: _m8.createGroupedReport, writePdfDocument: _m84.writePdfDocument, writePdfDocumentTo: _m84.writePdfDocumentTo, pdfTable: _m84.pdfTable, PdfFont: _m63.PdfFont, preflightPdfText: _m93.preflightPdfText, ExportCell: _m5.ExportCell, saveBlob: _m1.saveBlob });
11502
+ _modules.set("dcf6840f5eda4f8535cb4e226425587c2ae436c0eebfbd746aa0bc8a7acb6c4c", _exports);
11057
11503
  return _exports;
11058
11504
  })();
11059
11505
 
11060
- const _m94 = _modules.get("c0aee2c5df0df3e62ca31fc685243cdd4b449f083834e8d28cf92c20dfa7b27f") ?? (() => {
11506
+ const _m95 = _modules.get("c0aee2c5df0df3e62ca31fc685243cdd4b449f083834e8d28cf92c20dfa7b27f") ?? (() => {
11061
11507
  /** @internal Typed conversion follows declared datetime intent, never localized display text. */
11062
11508
  function datetime(value, mode, clock) {
11063
11509
  if (mode === "text")
@@ -11097,13 +11543,21 @@ _modules.set("c0aee2c5df0df3e62ca31fc685243cdd4b449f083834e8d28cf92c20dfa7b27f",
11097
11543
  return _exports;
11098
11544
  })();
11099
11545
 
11100
- const _m93 = _modules.get("20013c352d57841d53f13cbdd4e143293f2233f5ae601646738aab07e3d4043e") ?? (() => {
11546
+ const _m94 = _modules.get("91dbdf35d8f192b3c0ea92dfab6b9812872fbe3c8d85a5d2afe389bd61262ba2") ?? (() => {
11101
11547
  const { ExportCell, checkAbort, inputRows } = _m1;
11102
11548
 
11103
- const { datetime } = _m94;
11549
+ const { datetime } = _m95;
11550
+
11551
+ const { captureFields } = _m10;
11552
+
11553
+ const { copyColumns } = _m11;
11554
+
11555
+ const { copyCellPresentation } = _m5;
11104
11556
 
11557
+ const columnFields = ["width", "format", "wrapText", "alignment", "rowHeader", "groups"];
11105
11558
  /** Map an immutable CanopyX record capture to a writer without querying the grid or retaining its body. */
11106
11559
  function createCanopyExport(capture, format, options = {}) {
11560
+ options = captureFields(options, ["tones", "columnOptions", "unsupportedPresentation", "datetime", "xlsx", "signal", "onDiagnostic"]);
11107
11561
  if (format !== "xlsx" && format !== "csv" && format !== "pdf")
11108
11562
  throw new TypeError("Canopy export format must be xlsx, csv or pdf.");
11109
11563
  if (!capture || typeof capture.rows !== "function" || !capture.request)
@@ -11146,7 +11600,7 @@ function createCanopyExport(capture, format, options = {}) {
11146
11600
  const tones = new Map(Object.entries(options.tones ?? {}).map(([name, style]) => {
11147
11601
  if (!style || typeof style !== "object" || Array.isArray(style))
11148
11602
  throw new TypeError("Tone mappings must be portable presentation objects.");
11149
- return [name, Object.freeze({ ...style })];
11603
+ return [name, copyCellPresentation(style)];
11150
11604
  }));
11151
11605
  const tone = (name, rowId, columnId) => {
11152
11606
  if (name === undefined)
@@ -11170,15 +11624,16 @@ function createCanopyExport(capture, format, options = {}) {
11170
11624
  throw new TypeError("Invalid or duplicate Canopy export column.");
11171
11625
  ids.add(column.id);
11172
11626
  diagnostics(column.diagnostics, undefined, column.id);
11173
- const override = Object.hasOwn(options.columnOptions ?? {}, column.id) ? options.columnOptions[column.id] : {};
11174
- for (const key of Object.keys(override))
11175
- if (!["width", "format", "wrapText", "alignment", "groups"].includes(key))
11627
+ const selected = Object.hasOwn(options.columnOptions ?? {}, column.id) ? options.columnOptions[column.id] : {};
11628
+ for (const key of Object.keys(selected))
11629
+ if (!columnFields.includes(key))
11176
11630
  throw new TypeError("Unsupported Canopy column option: " + key);
11177
- return Object.freeze({ id: column.id, kind: column.kind, column: Object.freeze({ ...override, key: column.id, header: column.title,
11631
+ const override = captureFields(selected, columnFields);
11632
+ const [captured] = copyColumns([{ ...override, key: column.id, header: column.title,
11178
11633
  ...(values === "raw" && column.kind === "number" ? { type: "number" } : {}),
11179
11634
  ...(override.wrapText === undefined && column.wrap === undefined ? {} : { wrapText: override.wrapText ?? column.wrap }),
11180
- ...(override.alignment === undefined && column.alignment === undefined ? {} : { alignment: override.alignment ?? column.alignment }),
11181
- ...(override.groups === undefined ? {} : { groups: Object.freeze([...override.groups]) }) }) });
11635
+ ...(override.alignment === undefined && column.alignment === undefined ? {} : { alignment: override.alignment ?? column.alignment }) }]);
11636
+ return Object.freeze({ id: column.id, kind: column.kind, column: Object.freeze(captured) });
11182
11637
  });
11183
11638
  const rowCount = request.recordCount;
11184
11639
  return Object.freeze({ columns: Object.freeze(specs.map(spec => spec.column)), rowCount, async *rows() {
@@ -11217,11 +11672,11 @@ function createCanopyExport(capture, format, options = {}) {
11217
11672
  } });
11218
11673
  }
11219
11674
  const _exports = Object.freeze({ createCanopyExport: createCanopyExport });
11220
- _modules.set("20013c352d57841d53f13cbdd4e143293f2233f5ae601646738aab07e3d4043e", _exports);
11675
+ _modules.set("91dbdf35d8f192b3c0ea92dfab6b9812872fbe3c8d85a5d2afe389bd61262ba2", _exports);
11221
11676
  return _exports;
11222
11677
  })();
11223
11678
 
11224
- const _m0 = _modules.get("54c6cf7d7c4fe3f6e0bf7600bd33d2771371b96ec5284da01930f72e83278130") ?? (() => {
11679
+ const _m0 = _modules.get("6ebd256ad3ef99ead0a703b00c46781fd46dd9a03d21a4636e3fcecd8147d96c") ?? (() => {
11225
11680
  const { BlobByteSink } = _m1;
11226
11681
 
11227
11682
  const { notifyProgress } = _m14;
@@ -11236,7 +11691,7 @@ const { writeCsvTo } = _m55;
11236
11691
 
11237
11692
  const { writePdfTo } = _m57;
11238
11693
 
11239
- const { createCanopyExport } = _m93;
11694
+ const { createCanopyExport } = _m94;
11240
11695
 
11241
11696
 
11242
11697
 
@@ -11278,8 +11733,8 @@ async function exportCanopy(capture, format, options = {}) {
11278
11733
  throw error;
11279
11734
  }
11280
11735
  }
11281
- const _exports = Object.freeze({ createCanopyExport: _m93.createCanopyExport, ExportCell: _m5.ExportCell, PdfFont: _m62.PdfFont, writeCanopyTo: writeCanopyTo, exportCanopy: exportCanopy });
11282
- _modules.set("54c6cf7d7c4fe3f6e0bf7600bd33d2771371b96ec5284da01930f72e83278130", _exports);
11736
+ const _exports = Object.freeze({ createCanopyExport: _m94.createCanopyExport, ExportCell: _m5.ExportCell, PdfFont: _m63.PdfFont, writeCanopyTo: writeCanopyTo, exportCanopy: exportCanopy });
11737
+ _modules.set("6ebd256ad3ef99ead0a703b00c46781fd46dd9a03d21a4636e3fcecd8147d96c", _exports);
11283
11738
  return _exports;
11284
11739
  })();
11285
11740
  Object.assign(officeimo, _m0);