@evotecit/officeimo 0.1.21 → 0.1.43

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 (92) hide show
  1. package/README.md +39 -8
  2. package/bundles/officeimo-canopyx-adapter.js +56 -36
  3. package/bundles/officeimo-canopyx-adapter.min.js +1 -1
  4. package/bundles/officeimo-canopyx-adapter.min.mjs +1 -1
  5. package/bundles/officeimo-canopyx-adapter.mjs +42 -22
  6. package/bundles/officeimo-canopyx.js +420 -177
  7. package/bundles/officeimo-canopyx.min.js +1 -1
  8. package/bundles/officeimo-canopyx.min.mjs +1 -1
  9. package/bundles/officeimo-canopyx.mjs +346 -103
  10. package/bundles/officeimo-chartforgex-adapter.js +1924 -0
  11. package/bundles/officeimo-chartforgex-adapter.min.js +2 -0
  12. package/bundles/officeimo-chartforgex-adapter.min.mjs +2 -0
  13. package/bundles/officeimo-chartforgex-adapter.mjs +1910 -0
  14. package/bundles/officeimo-chartforgex.js +13594 -0
  15. package/bundles/officeimo-chartforgex.min.js +2 -0
  16. package/bundles/officeimo-chartforgex.min.mjs +2 -0
  17. package/bundles/officeimo-chartforgex.mjs +13487 -0
  18. package/bundles/officeimo-csv.js +12 -7
  19. package/bundles/officeimo-csv.min.js +1 -1
  20. package/bundles/officeimo-csv.min.mjs +1 -1
  21. package/bundles/officeimo-csv.mjs +8 -3
  22. package/bundles/officeimo-datatables-adapter.js +11 -11
  23. package/bundles/officeimo-datatables-adapter.min.js +1 -1
  24. package/bundles/officeimo-datatables-adapter.min.mjs +1 -1
  25. package/bundles/officeimo-datatables-adapter.mjs +7 -7
  26. package/bundles/officeimo-datatables.js +375 -152
  27. package/bundles/officeimo-datatables.min.js +1 -1
  28. package/bundles/officeimo-datatables.min.mjs +1 -1
  29. package/bundles/officeimo-datatables.mjs +311 -88
  30. package/bundles/officeimo-execution.js +14 -9
  31. package/bundles/officeimo-execution.min.js +1 -1
  32. package/bundles/officeimo-execution.min.mjs +1 -1
  33. package/bundles/officeimo-execution.mjs +8 -3
  34. package/bundles/officeimo-pdf.js +286 -120
  35. package/bundles/officeimo-pdf.min.js +1 -1
  36. package/bundles/officeimo-pdf.min.mjs +1 -1
  37. package/bundles/officeimo-pdf.mjs +244 -78
  38. package/bundles/officeimo-xlsx.js +93 -31
  39. package/bundles/officeimo-xlsx.min.js +1 -1
  40. package/bundles/officeimo-xlsx.min.mjs +1 -1
  41. package/bundles/officeimo-xlsx.mjs +75 -13
  42. package/bundles/officeimo.js +373 -150
  43. package/bundles/officeimo.min.js +1 -1
  44. package/bundles/officeimo.min.mjs +1 -1
  45. package/bundles/officeimo.mjs +312 -89
  46. package/dist/core/progress.js +7 -2
  47. package/dist/index.d.ts +1 -1
  48. package/dist/integrations/canopyx/index.js +9 -2
  49. package/dist/integrations/canopyx/source.js +26 -13
  50. package/dist/integrations/chartforgex/capture.d.ts +31 -0
  51. package/dist/integrations/chartforgex/capture.js +103 -0
  52. package/dist/integrations/chartforgex/index.d.ts +13 -0
  53. package/dist/integrations/chartforgex/index.js +88 -0
  54. package/dist/integrations/chartforgex/svg-drawing.d.ts +5 -0
  55. package/dist/integrations/chartforgex/svg-drawing.js +775 -0
  56. package/dist/integrations/chartforgex/svg-geometry.d.ts +23 -0
  57. package/dist/integrations/chartforgex/svg-geometry.js +304 -0
  58. package/dist/integrations/chartforgex/svg-image.d.ts +9 -0
  59. package/dist/integrations/chartforgex/svg-image.js +46 -0
  60. package/dist/integrations/chartforgex/svg-markup.d.ts +10 -0
  61. package/dist/integrations/chartforgex/svg-markup.js +124 -0
  62. package/dist/integrations/chartforgex/svg-paint.d.ts +16 -0
  63. package/dist/integrations/chartforgex/svg-paint.js +146 -0
  64. package/dist/integrations/chartforgex/types.d.ts +77 -0
  65. package/dist/integrations/chartforgex/types.js +1 -0
  66. package/dist/integrations/chartforgex/winansi.d.ts +4 -0
  67. package/dist/integrations/chartforgex/winansi.js +48 -0
  68. package/dist/integrations/chartforgex/workbook.d.ts +12 -0
  69. package/dist/integrations/chartforgex/workbook.js +137 -0
  70. package/dist/pdf/document-drawings.d.ts +1 -1
  71. package/dist/pdf/document-drawings.js +91 -17
  72. package/dist/pdf/document-images.d.ts +7 -1
  73. package/dist/pdf/document-images.js +59 -24
  74. package/dist/pdf/document-types.d.ts +3 -1
  75. package/dist/pdf/document.d.ts +2 -2
  76. package/dist/pdf/document.js +3 -1
  77. package/dist/pdf/drawing-types.d.ts +37 -10
  78. package/dist/pdf/font-resources.d.ts +1 -1
  79. package/dist/pdf/font-resources.js +6 -3
  80. package/dist/pdf/index.d.ts +1 -1
  81. package/dist/pdf/pages.js +15 -0
  82. package/dist/pdf/png.d.ts +11 -2
  83. package/dist/pdf/png.js +50 -23
  84. package/dist/pdf/session.js +3 -2
  85. package/dist/pdf/settings.d.ts +2 -2
  86. package/dist/pdf/settings.js +7 -3
  87. package/dist/xlsx/options.js +1 -1
  88. package/dist/xlsx/types.d.ts +8 -0
  89. package/dist/xlsx/workbook.js +6 -0
  90. package/dist/xlsx/worksheet.d.ts +13 -1
  91. package/dist/xlsx/worksheet.js +60 -9
  92. package/package.json +9 -2
@@ -972,19 +972,24 @@ _modules.set("81b3d47c02b7d8443b79e02b3cfb52032d6b73d9a3fb592b777ebe028ad0ef00",
972
972
  return _exports;
973
973
  })();
974
974
 
975
- const _m14 = _modules.get("6cfd3e806439f6301003a2d1699a74fdfa574d935550ab62b97b528728eaee1f") ?? (() => {
975
+ const _m14 = _modules.get("4eea31c4336d3c43bc743739843a3ef31803d8f0ed553f5645ee9de2554eb244") ?? (() => {
976
976
  /** @internal Notify synchronously; observe an accidental promise before rejecting its unsupported use. */
977
977
  function notifyProgress(callback, progress) {
978
+ notifySynchronously("onProgress", callback, progress);
979
+ }
980
+ /** @internal Run a host notification that must finish before the export continues. A returned promise is observed,
981
+ * so its rejection is never unhandled, and the export fails instead of reporting success before the callback ends. */
982
+ function notifySynchronously(name, callback, value) {
978
983
  if (!callback)
979
984
  return;
980
- const result = callback(progress);
985
+ const result = callback(value);
981
986
  if (result && typeof result.then === "function") {
982
987
  void Promise.resolve(result).catch(() => { });
983
- throw new TypeError("onProgress must be synchronous.");
988
+ throw new TypeError(name + " must be synchronous.");
984
989
  }
985
990
  }
986
- const _exports = Object.freeze({ notifyProgress: notifyProgress });
987
- _modules.set("6cfd3e806439f6301003a2d1699a74fdfa574d935550ab62b97b528728eaee1f", _exports);
991
+ const _exports = Object.freeze({ notifyProgress: notifyProgress, notifySynchronously: notifySynchronously });
992
+ _modules.set("4eea31c4336d3c43bc743739843a3ef31803d8f0ed553f5645ee9de2554eb244", _exports);
988
993
  return _exports;
989
994
  })();
990
995
 
@@ -1197,7 +1202,7 @@ _modules.set("9b33d9107e62ba8299c576072de40d24a261464f118de4ace64f23154fc78307",
1197
1202
  return _exports;
1198
1203
  })();
1199
1204
 
1200
- const _m17 = _modules.get("4a089607f7cbe50e13d4382d1cc4e5f6ce32c5773bbec2df84178710f54d9a38") ?? (() => {
1205
+ const _m17 = _modules.get("6c92204b587bb12cfa85c60eb1fd921804dfa51304538c7be3353e2927551b02") ?? (() => {
1201
1206
  const { OfficeIMOError } = _m2;
1202
1207
 
1203
1208
  const { ExportBudget } = _m9;
@@ -1224,12 +1229,16 @@ const sizes = {
1224
1229
  };
1225
1230
  /** @internal Shared capture schema for thin format adapters and the grouped writer. */
1226
1231
  const pdfOptionFields = ["columns", "signal", "onProgress", "limits", "textShaper", "textDirection", "pageSize", "orientation", "margins", "fonts", "tagged", "fontSize",
1227
- "title", "messageTop", "messageBottom", "includeHeader", "headerRows", "footer", "headerPresentation", "footerPresentation", "alternateRowColor", "padding",
1232
+ "title", "metadataTitle", "messageTop", "messageBottom", "includeHeader", "headerRows", "footer", "headerPresentation", "footerPresentation", "alternateRowColor", "padding",
1228
1233
  "columnWidths", "wideTable", "pageHeader", "pageFooter", "pageNumbers", "pageNumberLabels", "booleanText", "formatValue", "formatRuns", "compression", "paragraphStyles"];
1229
1234
  /** @internal Complete PDF limit schema used when a host combines format and shared limits. */
1230
1235
  const pdfLimitFields = ["maxRows", "maxCells", "maxTextCharacters", "maxOutputBytes", "maxPages", "maxColumns", "maxTableBands", "maxTableWindowRows", "maxCellCharacters", "maxTextRuns", "maxGroupBlocks", "maxRowLines",
1231
1236
  "maxFontBytes", "maxPageBytes", "maxHyperlinks", "maxImageBytes", "maxImagePixels", "maxImageWorkingBytes", "maxVectorCommands", "maxDrawingElements", "maxStructureElements",
1232
1237
  "maxMarkedContentReferences", "maxSections", "maxBookmarks", "maxListItems", "maxParagraphStyles"];
1238
+ /** @internal Default ceilings shared by the drawing writer and its producers. */
1239
+ const pdfDrawingLimits = Object.freeze({ maxVectorCommands: 100000, maxDrawingElements: 100000 });
1240
+ /** @internal Maximum number of retained drawing levels including the leaf. */
1241
+ const pdfDrawingMaxDepth = 32;
1233
1242
  /** @internal Capture supported structural properties once, including class-based options with prototype accessors. */
1234
1243
  function capturePdfOptions(input) {
1235
1244
  if (!input || typeof input !== "object" || Array.isArray(input))
@@ -1340,7 +1349,7 @@ function settings(input, document = false) {
1340
1349
  footerPresentation: Object.freeze({ background: "eef2f6", bold: true, ...presentation(configuration.footerPresentation) }) };
1341
1350
  const budget = new ExportBudget(options.limits);
1342
1351
  const limits = { maxPages: 10000, maxColumns: 1024, maxTableBands: 64, maxTableWindowRows: 256, maxCellCharacters: 1000000, maxTextRuns: 10000, maxGroupBlocks: 256, maxRowLines: 100000, maxFontBytes: 16 * 1024 * 1024, maxPageBytes: 8 * 1024 * 1024, maxHyperlinks: 100000,
1343
- maxImageBytes: 32 * 1024 * 1024, maxImagePixels: 16 * 1024 * 1024, maxVectorCommands: 100000, maxDrawingElements: 100000,
1352
+ maxImageBytes: 32 * 1024 * 1024, maxImagePixels: 16 * 1024 * 1024, ...pdfDrawingLimits,
1344
1353
  maxStructureElements: 1000000, maxMarkedContentReferences: 2000000,
1345
1354
  maxListItems: 100000, maxParagraphStyles: 256, maxSections: 1000, maxBookmarks: 10000 };
1346
1355
  for (const key of Object.keys(limits)) {
@@ -1368,7 +1377,7 @@ function settings(input, document = false) {
1368
1377
  const fontSize = positive(options.fontSize ?? 9, "Font size", 144), padding = options.padding ?? 4;
1369
1378
  if (!Number.isFinite(padding) || padding < 0 || padding > 72)
1370
1379
  throw new RangeError("PDF padding must be from 0 through 72 points.");
1371
- for (const key of ["title", "messageTop", "messageBottom"])
1380
+ for (const key of ["title", "metadataTitle", "messageTop", "messageBottom"])
1372
1381
  if (options[key] !== undefined && typeof options[key] !== "string")
1373
1382
  throw new TypeError(key + " must be text.");
1374
1383
  for (const key of ["pageHeader", "pageFooter"])
@@ -1404,16 +1413,16 @@ function settings(input, document = false) {
1404
1413
  repeatedColumns: document ? Object.freeze([]) : repeatedColumns(options.wideTable, columns),
1405
1414
  limits: { ...limits, ...(maxImageWorkingBytes === undefined ? {} : { maxImageWorkingBytes }) }, budget };
1406
1415
  }
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 });
1408
- _modules.set("4a089607f7cbe50e13d4382d1cc4e5f6ce32c5773bbec2df84178710f54d9a38", _exports);
1416
+ const _exports = Object.freeze({ positive: _m20.positive, color: _m20.color, presentation: _m20.presentation, pdfOptionFields: pdfOptionFields, pdfLimitFields: pdfLimitFields, pdfDrawingLimits: pdfDrawingLimits, pdfDrawingMaxDepth: pdfDrawingMaxDepth, capturePdfOptions: capturePdfOptions, capturePdfLimits: capturePdfLimits, captureWideTable: captureWideTable, settings: settings });
1417
+ _modules.set("6c92204b587bb12cfa85c60eb1fd921804dfa51304538c7be3353e2927551b02", _exports);
1409
1418
  return _exports;
1410
1419
  })();
1411
1420
 
1412
- const _m22 = _modules.get("8f13b484030aa6b921e616d803614fd061f718241692003633375fab4c36045e") ?? (() => {
1421
+ const _m22 = _modules.get("fd70ccda89f27c6b874c8840ac944b3ec723dbdef3dfe7600f7bdb81f4660c96") ?? (() => {
1413
1422
  const { captureFields } = _m10;
1414
1423
 
1415
1424
  /** @internal The workbook owner captures these settings before validation or adapter merging. */
1416
- const workbookOptionFields = ["signal", "onProgress", "limits", "sink", "dateMode", "compression", "invalidCharacterPolicy", "appProperties", "cellValueWriters", "oversizedText", "creator", "title", "subject", "description", "created", "modified"];
1425
+ const workbookOptionFields = ["signal", "onProgress", "limits", "sink", "dateMode", "compression", "invalidCharacterPolicy", "appProperties", "cellValueWriters", "oversizedText", "hyperlinkOverflow", "onHyperlinkOverflow", "creator", "title", "subject", "description", "created", "modified"];
1417
1426
  /** @internal Worksheet settings also used by the portable sheet owner. */
1418
1427
  const sheetOptionFields = ["columns", "includeHeader", "headerRows", "freezeHeader", "autoFilter", "boldHeader", "headerFill", "headerBorder", "headerWrap", "headerStyle", "alternatingRowStyle", "rowStyle", "cellStyle", "rowOutline", "maxOutlineLevel", "outlineSummaryBelow", "outlineSummaryRight", "columnOutlines", "rowHeight", "headerHeight", "defaultColumnWidth", "freezeColumns", "table", "autoSize", "footer", "print", "title", "mergedCells", "hyperlinks", "conditionalFormats", "dataValidation"];
1419
1428
  /** @internal Includes inherited format-specific ceilings before a wrapper combines stream settings. */
@@ -1428,11 +1437,11 @@ function captureWorkbookOptions(options) {
1428
1437
  return { ...captured, ...(captured.limits === undefined ? {} : { limits: captureWorkbookLimits(captured.limits) }) };
1429
1438
  }
1430
1439
  const _exports = Object.freeze({ workbookOptionFields: workbookOptionFields, sheetOptionFields: sheetOptionFields, workbookLimitFields: workbookLimitFields, captureWorkbookLimits: captureWorkbookLimits, captureWorkbookOptions: captureWorkbookOptions });
1431
- _modules.set("8f13b484030aa6b921e616d803614fd061f718241692003633375fab4c36045e", _exports);
1440
+ _modules.set("fd70ccda89f27c6b874c8840ac944b3ec723dbdef3dfe7600f7bdb81f4660c96", _exports);
1432
1441
  return _exports;
1433
1442
  })();
1434
1443
 
1435
- const _m15 = _modules.get("bbf637a660bc4dc3fa6fc932009b7b8fb557ad6403af8b5479a1cc857cc020a4") ?? (() => {
1444
+ const _m15 = _modules.get("2ab57874b786ef4d2b4841b9072fedd27d40c308f72c6548962810139359deb9") ?? (() => {
1436
1445
  const { captureFields } = _m10;
1437
1446
 
1438
1447
  const { ExportBudget } = _m9;
@@ -1473,7 +1482,7 @@ function capturePdfOptions(input = {}) {
1473
1482
  return { ...options, ...(options.limits === undefined ? {} : { limits: capturePdfLimits(options.limits) }) };
1474
1483
  }
1475
1484
  const _exports = Object.freeze({ captureCommonLimits: captureCommonLimits, mergeAdapterLimits: mergeAdapterLimits, captureXlsxOptions: captureXlsxOptions, captureCsvOptions: captureCsvOptions, capturePdfOptions: capturePdfOptions });
1476
- _modules.set("bbf637a660bc4dc3fa6fc932009b7b8fb557ad6403af8b5479a1cc857cc020a4", _exports);
1485
+ _modules.set("2ab57874b786ef4d2b4841b9072fedd27d40c308f72c6548962810139359deb9", _exports);
1477
1486
  return _exports;
1478
1487
  })();
1479
1488
 
@@ -3808,14 +3817,14 @@ _modules.set("13fa96d976e4dec7343dd3a392829567f1fcb574324a98f5a5d3a61c9a0dc27d",
3808
3817
  return _exports;
3809
3818
  })();
3810
3819
 
3811
- const _m38 = _modules.get("151a5a04c5f57081eb7df9705d62fc75f098c719c8fc832c59ef3ab0c4305b6a") ?? (() => {
3820
+ const _m38 = _modules.get("d5957683aa1945575924c89c63b427878e6e6e47ef5c229dc524b1879d146499") ?? (() => {
3812
3821
  const { checkAbort, consumeRows, inputRows, pause, taskYieldDue } = _m4;
3813
3822
 
3814
3823
  const { ChunkedTextSink, BlobByteSink } = _m3;
3815
3824
 
3816
3825
  const { OfficeIMOError } = _m2;
3817
3826
 
3818
- const { notifyProgress } = _m14;
3827
+ const { notifyProgress, notifySynchronously } = _m14;
3819
3828
 
3820
3829
  const { copyColumns, createRowProjector } = _m11;
3821
3830
 
@@ -3887,8 +3896,14 @@ class Worksheet {
3887
3896
  pendingCharacters = 0;
3888
3897
  reservedLayout = false;
3889
3898
  internalLinks = [];
3899
+ // Evicted entries become holes and are compacted in one pass when the links are read, keeping eviction O(1).
3890
3900
  links = [];
3901
+ evictedLinks = 0;
3891
3902
  linkedCells = new Set();
3903
+ /** Indexes in `links` of data-cell links that `hyperlinkOverflow: "drop"` may give up, in row order. */
3904
+ droppable = [];
3905
+ droppableLinks = new WeakSet();
3906
+ droppedLinks = 0;
3892
3907
  pictures = [];
3893
3908
  nativeCharts = [];
3894
3909
  conditional;
@@ -4100,7 +4115,8 @@ class Worksheet {
4100
4115
  const cell = col.letter + row;
4101
4116
  if (link || this.linkedCells.has(cell))
4102
4117
  throw new TypeError("A text-preservation cell cannot also have an external hyperlink.");
4103
- checkHyperlinkCount(this.links.length + this.internalLinks.length + 1);
4118
+ this.makeLinkRoom();
4119
+ checkHyperlinkCount(this.linkCount + 1);
4104
4120
  this.book.checkLinks(1);
4105
4121
  // Replace a generated cell's original reservation with its preview and overflow records.
4106
4122
  if (reservedCharacters !== undefined) {
@@ -4114,7 +4130,7 @@ class Worksheet {
4114
4130
  value = preserved.preview;
4115
4131
  }
4116
4132
  if (link)
4117
- this.appendHyperlink({ cell: col.letter + row, ...link });
4133
+ this.appendHyperlink({ cell: col.letter + row, ...link }, !header && !footer && !title && this.book.settings.hyperlinkOverflow === "drop");
4118
4134
  if (type === "date")
4119
4135
  value = excelDate(value, this.book.settings.dateMode);
4120
4136
  if (!header && !footer && visible && (!formula || !isSubtotalFormula(formula)))
@@ -4423,20 +4439,61 @@ class Worksheet {
4423
4439
  throw this.error;
4424
4440
  this.appendHyperlink(link);
4425
4441
  }
4426
- appendHyperlink(link) {
4442
+ appendHyperlink(link, droppable = false) {
4443
+ // Validate before any overflow decision, so a dropped link can never hide an unsafe target.
4427
4444
  const copied = copyHyperlink(link, this.book.settings.invalidCharacterPolicy);
4428
4445
  const position = cellPosition(copied.cell);
4429
4446
  if (this.layout.regions.covered(position.column, position.row))
4430
4447
  throw new TypeError("Hyperlinks cannot address a covered merged cell.");
4431
4448
  if (this.linkedCells.has(copied.cell))
4432
4449
  throw new TypeError("Duplicate hyperlink cell: " + copied.cell);
4433
- checkHyperlinkCount(this.links.length + this.internalLinks.length + 1);
4450
+ if (droppable && this.linkCount >= maximumHyperlinks) {
4451
+ this.droppedLinks++;
4452
+ return;
4453
+ }
4454
+ if (!droppable)
4455
+ this.makeLinkRoom();
4456
+ checkHyperlinkCount(this.linkCount + 1);
4434
4457
  this.book.retainLink();
4458
+ if (droppable) {
4459
+ this.droppable.push(this.links.length);
4460
+ this.droppableLinks.add(copied);
4461
+ }
4435
4462
  this.links.push(copied);
4436
4463
  this.linkedCells.add(copied.cell);
4437
4464
  }
4465
+ /** Links the worksheet holds now, not counting evicted holes. */
4466
+ get linkCount() { return this.links.length - this.evictedLinks + this.internalLinks.length; }
4467
+ /** A full worksheet gives up its latest data-cell link for a link that cannot be dropped. Hyperlinks are serialized after
4468
+ * the rows, so the cell keeps its written value. The entry becomes a hole, so other indexes stay valid until compaction. */
4469
+ makeLinkRoom() {
4470
+ if (this.linkCount < maximumHyperlinks || !this.droppable.length)
4471
+ return;
4472
+ const index = this.droppable.pop(), removed = this.links[index];
4473
+ this.links[index] = undefined;
4474
+ this.evictedLinks++;
4475
+ this.linkedCells.delete(removed.cell);
4476
+ this.book.releaseLink();
4477
+ this.droppedLinks++;
4478
+ }
4479
+ /** One ordered pass removes evicted holes and rebuilds the droppable indexes. */
4480
+ compactLinks() {
4481
+ if (this.evictedLinks) {
4482
+ const kept = [], droppable = [];
4483
+ for (const link of this.links)
4484
+ if (link) {
4485
+ if (this.droppableLinks.has(link))
4486
+ droppable.push(kept.length);
4487
+ kept.push(link);
4488
+ }
4489
+ this.links = kept;
4490
+ this.droppable = droppable;
4491
+ this.evictedLinks = 0;
4492
+ }
4493
+ return this.links;
4494
+ }
4438
4495
  /** @internal */
4439
- get hyperlinks() { return this.links; }
4496
+ get hyperlinks() { return this.compactLinks(); }
4440
4497
  /** @internal */
4441
4498
  get images() { return this.pictures; }
4442
4499
  /** @internal An empty export has no data table; it still emits the declared headers. */
@@ -4487,7 +4544,7 @@ class Worksheet {
4487
4544
  for (const binding of this.chartSources)
4488
4545
  binding.finish();
4489
4546
  this.chartSources.length = 0;
4490
- for (const link of this.links) {
4547
+ for (const link of this.compactLinks()) {
4491
4548
  const position = cellPosition(link.cell);
4492
4549
  if (position.column > this.columns.length || position.row > this.totalRows)
4493
4550
  throw new RangeError("Hyperlinks must address cells within the exported rows and columns.");
@@ -4517,8 +4574,11 @@ class Worksheet {
4517
4574
  await this.buffer.write(xml);
4518
4575
  for (const xml of dataValidationsXml(this.validations, this.headerRows, this.count, detailRanges))
4519
4576
  await this.buffer.write(xml);
4520
- if (this.links.length || this.internalLinks.length)
4521
- await this.buffer.write(hyperlinksXml(this.links, this.book.settings.invalidCharacterPolicy, this.internalLinks));
4577
+ if (this.droppedLinks)
4578
+ notifySynchronously("onHyperlinkOverflow", this.book.settings.onHyperlinkOverflow, Object.freeze({ sheetName: this.name, dropped: this.droppedLinks }));
4579
+ const links = this.compactLinks();
4580
+ if (links.length || this.internalLinks.length)
4581
+ await this.buffer.write(hyperlinksXml(links, this.book.settings.invalidCharacterPolicy, this.internalLinks));
4522
4582
  await this.buffer.write(printXml(this.options.print, this.book.settings.invalidCharacterPolicy));
4523
4583
  if (this.pictures.length || this.nativeCharts.length)
4524
4584
  await this.buffer.write('<drawing r:id="drawing"/>');
@@ -4543,7 +4603,7 @@ class Worksheet {
4543
4603
  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); }
4544
4604
  }
4545
4605
  const _exports = Object.freeze({ Worksheet: Worksheet });
4546
- _modules.set("151a5a04c5f57081eb7df9705d62fc75f098c719c8fc832c59ef3ab0c4305b6a", _exports);
4606
+ _modules.set("d5957683aa1945575924c89c63b427878e6e6e47ef5c229dc524b1879d146499", _exports);
4547
4607
  return _exports;
4548
4608
  })();
4549
4609
 
@@ -4965,7 +5025,7 @@ _modules.set("24f1417c3c320a8a41137c28f70b72091256c63010be0c88b684dce85f54950c",
4965
5025
  return _exports;
4966
5026
  })();
4967
5027
 
4968
- const _m24 = _modules.get("fe4b78533e92385c8af50681c6a1273e1f9ec6f4f9ae8342684c06e904cfb8e0") ?? (() => {
5028
+ const _m24 = _modules.get("a34a46ed9564c388d5f3ca087c70819f8aa897e469ca50f8547233c264a8e8af") ?? (() => {
4969
5029
  const { beginTask, checkAbort, pause, taskYieldDue } = _m4;
4970
5030
 
4971
5031
  const { OfficeIMOError } = _m2;
@@ -5098,6 +5158,10 @@ class Workbook {
5098
5158
  throw new RangeError("compression must be auto or store.");
5099
5159
  if (options.oversizedText !== undefined && !["reject", "preserve"].includes(options.oversizedText))
5100
5160
  throw new RangeError("oversizedText must be reject or preserve.");
5161
+ if (options.hyperlinkOverflow !== undefined && !["reject", "drop"].includes(options.hyperlinkOverflow))
5162
+ throw new RangeError("hyperlinkOverflow must be reject or drop.");
5163
+ if (options.onHyperlinkOverflow !== undefined && typeof options.onHyperlinkOverflow !== "function")
5164
+ throw new TypeError("onHyperlinkOverflow must be a function.");
5101
5165
  cleanXml("", policy);
5102
5166
  corePropertiesXml(options, policy);
5103
5167
  this.budget = new ExportBudget(options.limits);
@@ -5175,6 +5239,8 @@ class Workbook {
5175
5239
  }
5176
5240
  /** @internal Reserve a preflighted worksheet batch or one row hyperlink. */
5177
5241
  retainLink(count = 1) { this.checkLinks(count); this.links += count; }
5242
+ /** @internal A worksheet dropped a data-cell link it had retained. */
5243
+ releaseLink() { this.links--; }
5178
5244
  /** @internal */
5179
5245
  checkImage(bytes) {
5180
5246
  if (this.settings.limits?.maxImageBytes !== undefined && this.imageBytes + bytes > this.settings.limits.maxImageBytes)
@@ -5448,11 +5514,11 @@ class Workbook {
5448
5514
  }
5449
5515
  }
5450
5516
  const _exports = Object.freeze({ Workbook: Workbook });
5451
- _modules.set("fe4b78533e92385c8af50681c6a1273e1f9ec6f4f9ae8342684c06e904cfb8e0", _exports);
5517
+ _modules.set("a34a46ed9564c388d5f3ca087c70819f8aa897e469ca50f8547233c264a8e8af", _exports);
5452
5518
  return _exports;
5453
5519
  })();
5454
5520
 
5455
- const _m53 = _modules.get("62ff1bcbf8ca07e8ab92cd1f6afbd54049346193e18160ab0afec48e03950bba") ?? (() => {
5521
+ const _m53 = _modules.get("d6884428c3e4d15a691ecf2523372a03b32de22a890edfbfc9961f2dc92711c2") ?? (() => {
5456
5522
  const { ExportCell, assertScalar } = _m5;
5457
5523
 
5458
5524
  const { captureWorkbookOptions, sheetOptionFields } = _m22;
@@ -5501,11 +5567,11 @@ function portableWorkbook(options = {}) {
5501
5567
  return { ...options, cellValueWriters: wrapped };
5502
5568
  }
5503
5569
  const _exports = Object.freeze({ portableSheet: portableSheet, portableWorkbook: portableWorkbook });
5504
- _modules.set("62ff1bcbf8ca07e8ab92cd1f6afbd54049346193e18160ab0afec48e03950bba", _exports);
5570
+ _modules.set("d6884428c3e4d15a691ecf2523372a03b32de22a890edfbfc9961f2dc92711c2", _exports);
5505
5571
  return _exports;
5506
5572
  })();
5507
5573
 
5508
- const _m52 = _modules.get("05d6afb9e04ef4bfee413c0cee45f432de701dd04c8673077e711f82ed4a3471") ?? (() => {
5574
+ const _m52 = _modules.get("b9b1793c41e466048fe823422088a6fcc1fd8393c67293df3f0cd83a5d5ec7e1") ?? (() => {
5509
5575
  const { withDestination } = _m3;
5510
5576
 
5511
5577
  const { copyColumns } = _m11;
@@ -5560,11 +5626,11 @@ async function writeXlsxTo(rows, destination, configuration) {
5560
5626
  });
5561
5627
  }
5562
5628
  const _exports = Object.freeze({ writeXlsx: writeXlsx, writeXlsxTo: writeXlsxTo });
5563
- _modules.set("05d6afb9e04ef4bfee413c0cee45f432de701dd04c8673077e711f82ed4a3471", _exports);
5629
+ _modules.set("b9b1793c41e466048fe823422088a6fcc1fd8393c67293df3f0cd83a5d5ec7e1", _exports);
5564
5630
  return _exports;
5565
5631
  })();
5566
5632
 
5567
- const _m55 = _modules.get("8df3d4472935cf1e82313946c2473abf41dd8c539922d3283439958b72548576") ?? (() => {
5633
+ const _m55 = _modules.get("ba0e1f29c8de5d46b966b7b097260529e42b80f662e92a7f9e8add22df747a50") ?? (() => {
5568
5634
  const { assertGroupedReportSource } = _m8;
5569
5635
 
5570
5636
  const { captureFields } = _m10;
@@ -5653,11 +5719,11 @@ function prepareGroupedSheet(report, configuration, maxConditionalFormats = 1000
5653
5719
  ...(options.grandTotalStyle ? { grandTotalStyle: copyStylePatch(options.grandTotalStyle) } : {}) };
5654
5720
  }
5655
5721
  const _exports = Object.freeze({ groupedOptionFields: groupedOptionFields, prepareGroupedSheet: prepareGroupedSheet });
5656
- _modules.set("8df3d4472935cf1e82313946c2473abf41dd8c539922d3283439958b72548576", _exports);
5722
+ _modules.set("ba0e1f29c8de5d46b966b7b097260529e42b80f662e92a7f9e8add22df747a50", _exports);
5657
5723
  return _exports;
5658
5724
  })();
5659
5725
 
5660
- const _m54 = _modules.get("26f5f707c4feb95052da5c9787df79bf6a94178780b276c4f74677ce0f96e87a") ?? (() => {
5726
+ const _m54 = _modules.get("d7cfa6a7b1be9758925a4ccb860a80a33eb0de2c88c80cc55e438213595f2b71") ?? (() => {
5661
5727
  const { groupedReportOperation } = _m8;
5662
5728
 
5663
5729
  const { checkAbort, withAbort } = _m4;
@@ -5830,14 +5896,14 @@ async function writeGroupedXlsxTo(report, destination, options) {
5830
5896
  return withDestination(destination, async (sink) => (await write(report, prepared, sink)).result);
5831
5897
  }
5832
5898
  const _exports = Object.freeze({ addGroupedXlsx: addGroupedXlsx, writeGroupedXlsx: writeGroupedXlsx, writeGroupedXlsxTo: writeGroupedXlsxTo });
5833
- _modules.set("26f5f707c4feb95052da5c9787df79bf6a94178780b276c4f74677ce0f96e87a", _exports);
5899
+ _modules.set("d7cfa6a7b1be9758925a4ccb860a80a33eb0de2c88c80cc55e438213595f2b71", _exports);
5834
5900
  return _exports;
5835
5901
  })();
5836
5902
 
5837
- const _m23 = _modules.get("e5310c591178a3de9292f150e2e6f1477b94b895ef0c90840c72adef00f75974") ?? (() => {
5903
+ const _m23 = _modules.get("edf1bf5cb6d749de0e6823397df6610a6c1cc88768898c1b4d7083ee96ef6759") ?? (() => {
5838
5904
 
5839
5905
  const _exports = Object.freeze({ Workbook: _m24.Workbook, writeXlsx: _m52.writeXlsx, writeXlsxTo: _m52.writeXlsxTo, writeGroupedXlsx: _m54.writeGroupedXlsx, writeGroupedXlsxTo: _m54.writeGroupedXlsxTo, addGroupedXlsx: _m54.addGroupedXlsx, createGroupedReport: _m8.createGroupedReport, Worksheet: _m38.Worksheet, Cell: _m35.Cell, FormulaCell: _m36.FormulaCell, StyleRegistry: _m32.StyleRegistry, NumberFormats: _m32.NumberFormats, saveBlob: _m1.saveBlob, ExportCell: _m5.ExportCell });
5840
- _modules.set("e5310c591178a3de9292f150e2e6f1477b94b895ef0c90840c72adef00f75974", _exports);
5906
+ _modules.set("edf1bf5cb6d749de0e6823397df6610a6c1cc88768898c1b4d7083ee96ef6759", _exports);
5841
5907
  return _exports;
5842
5908
  })();
5843
5909
 
@@ -5863,7 +5929,7 @@ _modules.set("2f5c0823847e9209017d01b2a753f36056df2a9988fae1f3a1bd5fd186545220",
5863
5929
  return _exports;
5864
5930
  })();
5865
5931
 
5866
- const _m56 = _modules.get("b48bcab805d4c75294dd8d8e8dc57f96d9db3f5af31a8f0ddc6562f010f566e4") ?? (() => {
5932
+ const _m56 = _modules.get("406ac6c93ee68eae70c6f52a1e6f4c56b84f43cae12576040c766dcc5598a580") ?? (() => {
5867
5933
  const { beginTask, checkAbort, consumeRows, taskYieldDue, withAbort } = _m4;
5868
5934
 
5869
5935
  const { BlobByteSink, ChunkedTextSink, withDestination } = _m3;
@@ -6013,7 +6079,7 @@ async function writeCsv(rows, configuration) {
6013
6079
  }
6014
6080
  }
6015
6081
  const _exports = Object.freeze({ saveBlob: _m1.saveBlob, ExportCell: _m5.ExportCell, writeCsvTo: writeCsvTo, writeCsv: writeCsv });
6016
- _modules.set("b48bcab805d4c75294dd8d8e8dc57f96d9db3f5af31a8f0ddc6562f010f566e4", _exports);
6082
+ _modules.set("406ac6c93ee68eae70c6f52a1e6f4c56b84f43cae12576040c766dcc5598a580", _exports);
6017
6083
  return _exports;
6018
6084
  })();
6019
6085
 
@@ -7338,7 +7404,7 @@ _modules.set("59911f0fe023545e9e97521b268551078bdc4c5f303e446a13b7d52f905e8070",
7338
7404
  return _exports;
7339
7405
  })();
7340
7406
 
7341
- const _m63 = _modules.get("4d4736e6b8e2aaecc6f6c1b124b7e6bc0a5e141dcc725edf0ad4847d87fca1b3") ?? (() => {
7407
+ const _m63 = _modules.get("7825c87ba92a9992baf6b5c8a5e146948268985c31584ef9c8bf395359942e4f") ?? (() => {
7342
7408
  const { NotSupportedError, OfficeIMOError } = _m2;
7343
7409
 
7344
7410
  const { fontProgram } = _m64;
@@ -7539,7 +7605,7 @@ class PdfFontResources {
7539
7605
  this.fontBytes += bytes;
7540
7606
  this.registered.add(font);
7541
7607
  }
7542
- select(bold = false, italic = false, explicit) {
7608
+ select(bold = false, italic = false, explicit, standardForMissingFace = false) {
7543
7609
  if (explicit)
7544
7610
  this.registerFont(explicit);
7545
7611
  let selections = this.selections;
@@ -7549,10 +7615,13 @@ class PdfFontResources {
7549
7615
  if (!found)
7550
7616
  this.explicitSelections.set(explicit, selections);
7551
7617
  }
7552
- const key = (bold ? 2 : 0) | (italic ? 1 : 0), existing = selections.get(key);
7618
+ const fallback = standardForMissingFace && !explicit && this.fonts !== undefined &&
7619
+ this.fonts[bold ? italic ? "boldItalic" : "bold" : italic ? "italic" : "regular"] === undefined;
7620
+ const key = (bold ? 2 : 0) | (italic ? 1 : 0) | (fallback ? 4 : 0), existing = selections.get(key);
7553
7621
  if (existing)
7554
7622
  return existing;
7555
- const { font, syntheticBold, syntheticItalic } = explicit ? { font: explicit, syntheticBold: bold, syntheticItalic: italic } : selectFont(this.fonts, bold, italic);
7623
+ const { font, syntheticBold, syntheticItalic } = explicit ? { font: explicit, syntheticBold: bold, syntheticItalic: italic } :
7624
+ selectFont(fallback ? undefined : this.fonts, bold, italic);
7556
7625
  const shared = font ? this.programs.get(font) : undefined;
7557
7626
  const resource = new PdfFontResource(this.resources.length + 1, bold, italic, font, this.objects, syntheticBold, syntheticItalic, shared, this.signal);
7558
7627
  if (!shared) {
@@ -7566,7 +7635,7 @@ class PdfFontResources {
7566
7635
  dictionary() { return "<< " + this.resources.map(f => "/" + f.name + " " + f.object + " 0 R").join(" ") + " >>"; }
7567
7636
  }
7568
7637
  const _exports = Object.freeze({ PdfFontResource: PdfFontResource, PdfFontResources: PdfFontResources });
7569
- _modules.set("4d4736e6b8e2aaecc6f6c1b124b7e6bc0a5e141dcc725edf0ad4847d87fca1b3", _exports);
7638
+ _modules.set("7825c87ba92a9992baf6b5c8a5e146948268985c31584ef9c8bf395359942e4f", _exports);
7570
7639
  return _exports;
7571
7640
  })();
7572
7641
 
@@ -7895,7 +7964,7 @@ _modules.set("8be3fb029e08d100ce8ffcf50916d5ba7f7bc00d62156cc33815fd58554a9ed6",
7895
7964
  return _exports;
7896
7965
  })();
7897
7966
 
7898
- const _m72 = _modules.get("0a1c79b51ac9a164b86197239117df6497f45ca2892b423b1ec77a663ccc1c47") ?? (() => {
7967
+ const _m72 = _modules.get("abbfad7ffb3c318822659c9fbde9126630ce2c137dc2e2b88402148424255e2d") ?? (() => {
7899
7968
  const { NotSupportedError, OfficeIMOError } = _m2;
7900
7969
 
7901
7970
  const { copyExportLink } = _m7;
@@ -8087,11 +8156,11 @@ async function wrapPdfText(captured, fonts, size, width, settings, wrap = true)
8087
8156
  return lines;
8088
8157
  }
8089
8158
  const _exports = Object.freeze({ capturePdfText: capturePdfText, wrapPdfText: wrapPdfText });
8090
- _modules.set("0a1c79b51ac9a164b86197239117df6497f45ca2892b423b1ec77a663ccc1c47", _exports);
8159
+ _modules.set("abbfad7ffb3c318822659c9fbde9126630ce2c137dc2e2b88402148424255e2d", _exports);
8091
8160
  return _exports;
8092
8161
  })();
8093
8162
 
8094
- const _m74 = _modules.get("2f40af05ba09102fe440c1d46385b64cecdd233371771796c9ae4e8d523f2cea") ?? (() => {
8163
+ const _m74 = _modules.get("04b189837f06067364240b6731efdf86d61d81fd0848fac3666f25c5f27817b8") ?? (() => {
8095
8164
  const { OfficeIMOError } = _m2;
8096
8165
 
8097
8166
  const { wrapPdfText } = _m72;
@@ -8186,11 +8255,11 @@ function alignBandBlocks(bands, settings) {
8186
8255
  cells: row.cells.map(cell => ({ ...cell, height: heights.slice(index, index + (cell.rowSpan ?? 1)).reduce((sum, value) => sum + value, 0) })) })));
8187
8256
  }
8188
8257
  const _exports = Object.freeze({ planTableBands: planTableBands, projectBandRows: projectBandRows, alignBandBlocks: alignBandBlocks });
8189
- _modules.set("2f40af05ba09102fe440c1d46385b64cecdd233371771796c9ae4e8d523f2cea", _exports);
8258
+ _modules.set("04b189837f06067364240b6731efdf86d61d81fd0848fac3666f25c5f27817b8", _exports);
8190
8259
  return _exports;
8191
8260
  })();
8192
8261
 
8193
- const _m70 = _modules.get("ad81357e627d3100e1068a8ce521aa1c1cd65de5c6c6ab36f807a3e5da50d874") ?? (() => {
8262
+ const _m70 = _modules.get("6fd77694f46f8c87510a82e8a58a3c424099d6172bfb1942f92d048b39169945") ?? (() => {
8194
8263
  const { ExportCell } = _m5;
8195
8264
 
8196
8265
  const { copyExportLink } = _m7;
@@ -8421,7 +8490,7 @@ class PdfTableLayout {
8421
8490
  }
8422
8491
  }
8423
8492
  const _exports = Object.freeze({ PdfTableLayout: PdfTableLayout });
8424
- _modules.set("ad81357e627d3100e1068a8ce521aa1c1cd65de5c6c6ab36f807a3e5da50d874", _exports);
8493
+ _modules.set("6fd77694f46f8c87510a82e8a58a3c424099d6172bfb1942f92d048b39169945", _exports);
8425
8494
  return _exports;
8426
8495
  })();
8427
8496
 
@@ -8777,7 +8846,7 @@ _modules.set("c68d18d668366fb9b96d1b53c79dc6305f84cb83c05e4942fcf1cdf96ed1a73f",
8777
8846
  return _exports;
8778
8847
  })();
8779
8848
 
8780
- const _m80 = _modules.get("a66257a32f03d958aa57be4de9da7f80b708cebca26b5cc6404de0ee11bfe052") ?? (() => {
8849
+ const _m80 = _modules.get("8fc594bfca7312071f0f128ad25fb929d023d176323e66e389cddd27032a4d15") ?? (() => {
8781
8850
  const { settings } = _m17;
8782
8851
 
8783
8852
  /** @internal Every section derives from captured document defaults, never the preceding section. */
@@ -8792,11 +8861,11 @@ function sectionSettings(base, section) {
8792
8861
  return { ...base, page: derived.page, margins: derived.margins, options };
8793
8862
  }
8794
8863
  const _exports = Object.freeze({ sectionSettings: sectionSettings });
8795
- _modules.set("a66257a32f03d958aa57be4de9da7f80b708cebca26b5cc6404de0ee11bfe052", _exports);
8864
+ _modules.set("8fc594bfca7312071f0f128ad25fb929d023d176323e66e389cddd27032a4d15", _exports);
8796
8865
  return _exports;
8797
8866
  })();
8798
8867
 
8799
- const _m75 = _modules.get("3ed7114181be5a3066742336da574fef7f2fc04ee6dfc5e64211f3bedad4cab9") ?? (() => {
8868
+ const _m75 = _modules.get("c16c0303d9d4be12ab9e0bab7cfdac73b252ed233c9689e3e0141cc8115aa941") ?? (() => {
8800
8869
  const { OfficeIMOError } = _m2;
8801
8870
 
8802
8871
  const { checkAbort } = _m4;
@@ -8857,6 +8926,7 @@ class PdfPages {
8857
8926
  rectangleLefts;
8858
8927
  rectangleColumns = [];
8859
8928
  externalObjects = new Map();
8929
+ opacityStates = new Map();
8860
8930
  bandFlow;
8861
8931
  bandCellBudget = false;
8862
8932
  tableElement;
@@ -9439,6 +9509,20 @@ class PdfPages {
9439
9509
  }
9440
9510
  async pageBreak() { await this.ensureStarted(); await this.finishPage(); await this.start(false); }
9441
9511
  registerXObject(name, id) { this.externalObjects.set(name, id); }
9512
+ /** One shared constant-opacity graphics state per serialized alpha value. */
9513
+ opacityState(alpha) {
9514
+ const value = pdfNumber(alpha);
9515
+ let name = this.opacityStates.get(value);
9516
+ if (!name) {
9517
+ name = "GA" + (this.opacityStates.size + 1);
9518
+ this.opacityStates.set(value, name);
9519
+ }
9520
+ return name;
9521
+ }
9522
+ graphicsStates() {
9523
+ const entries = [...this.opacityStates].map(([alpha, name]) => "/" + name + " << /ca " + alpha + " /CA " + alpha + " >>");
9524
+ return entries.length ? " /ExtGState << " + entries.join(" ") + " >>" : "";
9525
+ }
9442
9526
  /** Height after the existing fit-to-page graphic policy, used by heading keep constraints. */
9443
9527
  graphicHeight(width, height) {
9444
9528
  const { page, margins } = this.settings;
@@ -9534,7 +9618,7 @@ class PdfPages {
9534
9618
  }
9535
9619
  }
9536
9620
  const _exports = Object.freeze({ PdfPages: PdfPages });
9537
- _modules.set("3ed7114181be5a3066742336da574fef7f2fc04ee6dfc5e64211f3bedad4cab9", _exports);
9621
+ _modules.set("c16c0303d9d4be12ab9e0bab7cfdac73b252ed233c9689e3e0141cc8115aa941", _exports);
9538
9622
  return _exports;
9539
9623
  })();
9540
9624
 
@@ -9977,7 +10061,7 @@ _modules.set("52c78ca6833cee7e5a96b657e2c00172d550176daf2c95e742692f8416977bea",
9977
10061
  return _exports;
9978
10062
  })();
9979
10063
 
9980
- const _m60 = _modules.get("afdad27eb363e8de0c3bd69ebf358860eb76f5c6fb29f43a87635807cb7fc273") ?? (() => {
10064
+ const _m60 = _modules.get("3de6cb5a744388b84e9e2295a2e580e70ab993d44bbb4c94da5f98daba11c350") ?? (() => {
9981
10065
  const { PdfObjects, unicodeHex } = _m61;
9982
10066
 
9983
10067
  const { PdfFontResources } = _m63;
@@ -10029,22 +10113,23 @@ class PdfWriteSession {
10029
10113
  await pages.finish();
10030
10114
  for (const font of fonts.resources)
10031
10115
  await font.write(objects, options.compression !== false);
10032
- await objects.object(this.resources, "<< /Font " + fonts.dictionary() + pages.xobjects() + " >>");
10116
+ await objects.object(this.resources, "<< /Font " + fonts.dictionary() + pages.xobjects() + pages.graphicsStates() + " >>");
10033
10117
  await objects.object(this.parent, "<< /Type /Pages /Count " + pages.references.length + " /Kids [" + pages.references.map(id => id + " 0 R").join(" ") + "] >>");
10034
10118
  if (this.structure)
10035
10119
  await this.structure.finish();
10036
10120
  await this.outlines.finish();
10037
10121
  await objects.object(this.root, "<< /Type /Catalog /Pages " + this.parent + " 0 R" + (this.structure?.catalogDictionary ?? "") + this.outlines.catalogDictionary + " >>");
10038
- await objects.object(this.info, "<< /Producer (OfficeIMO.js)" + (options.title === undefined ? "" : " /Title <feff" + unicodeHex(options.title) + ">") + " >>");
10122
+ const title = options.metadataTitle ?? options.title;
10123
+ await objects.object(this.info, "<< /Producer (OfficeIMO.js)" + (title === undefined ? "" : " /Title <feff" + unicodeHex(title) + ">") + " >>");
10039
10124
  await objects.finish(this.root, this.info);
10040
10125
  }
10041
10126
  }
10042
10127
  const _exports = Object.freeze({ PdfWriteSession: PdfWriteSession });
10043
- _modules.set("afdad27eb363e8de0c3bd69ebf358860eb76f5c6fb29f43a87635807cb7fc273", _exports);
10128
+ _modules.set("3de6cb5a744388b84e9e2295a2e580e70ab993d44bbb4c94da5f98daba11c350", _exports);
10044
10129
  return _exports;
10045
10130
  })();
10046
10131
 
10047
- const _m59 = _modules.get("45cf9fd6b6293c1a83bc8554e1bcb5cf119f44701fbad7849f39a712cab5074b") ?? (() => {
10132
+ const _m59 = _modules.get("01ffda1779a340d72e953fd6e02429f341c89fcab28eb0fce4dc8beb65a5fd43") ?? (() => {
10048
10133
  const { BlobByteSink, withDestination } = _m3;
10049
10134
 
10050
10135
  const { beginTask, checkAbort, consumeRows, pause, taskYieldDue } = _m4;
@@ -10109,11 +10194,11 @@ async function writePdfTo(rows, destination, configuration) {
10109
10194
  });
10110
10195
  }
10111
10196
  const _exports = Object.freeze({ writePdf: writePdf, writePdfTo: writePdfTo });
10112
- _modules.set("45cf9fd6b6293c1a83bc8554e1bcb5cf119f44701fbad7849f39a712cab5074b", _exports);
10197
+ _modules.set("01ffda1779a340d72e953fd6e02429f341c89fcab28eb0fce4dc8beb65a5fd43", _exports);
10113
10198
  return _exports;
10114
10199
  })();
10115
10200
 
10116
- const _m87 = _modules.get("749d1ec5422c0087787f525ef42e3b8d3a94d2b70eb5e42d2e3723a870777ad6") ?? (() => {
10201
+ const _m87 = _modules.get("6b0244b5ec6d550c705b4e4cbb47997331f1ecd99e2bf8a06f7c646eebbffbf8") ?? (() => {
10117
10202
  const { NotSupportedError, OfficeIMOError } = _m2;
10118
10203
 
10119
10204
  const { checkAbort, pause, taskYieldDue, withAbort } = _m4;
@@ -10122,15 +10207,10 @@ const { Crc32 } = _m31;
10122
10207
 
10123
10208
  const signature = [137, 80, 78, 71, 13, 10, 26, 10];
10124
10209
  const unsupportedChunks = new Set(["PLTE", "tRNS", "iCCP", "sRGB", "gAMA", "cHRM", "cICP", "mDCV", "cLLI", "sBIT", "eXIf", "acTL", "fcTL", "fdAT"]);
10125
- /** Decode the static unprofiled 8-bit RGB/RGBA profile without canvas or a second compression engine. */
10126
- async function pngPixels(inputSource, maxPixels, signal, maxWorkingBytes) {
10210
+ /** Decode an owned static unprofiled PNG without canvas or a second compression engine. */
10211
+ async function pngPixels(source, shape, signal) {
10127
10212
  checkAbort(signal);
10128
- const shape = pngShape(inputSource, maxPixels);
10129
10213
  const imagePixels = shape.width * shape.height;
10130
- const workingBytes = inputSource.length + imagePixels * shape.components + (shape.components === 4 ? shape.width * 8 : 0);
10131
- if (maxWorkingBytes !== undefined && workingBytes > maxWorkingBytes)
10132
- throw new OfficeIMOError("RESOURCE_LIMIT", "maxImageWorkingBytes exceeded by PNG source, image planes and scanlines.");
10133
- const source = new Uint8Array(inputSource);
10134
10214
  const header = await pngHeader(source, shape, signal);
10135
10215
  checkAbort(signal);
10136
10216
  let stream;
@@ -10144,9 +10224,6 @@ async function pngPixels(inputSource, maxPixels, signal, maxWorkingBytes) {
10144
10224
  }
10145
10225
  const { width, height, components } = header, rowBytes = width * components;
10146
10226
  const expected = (rowBytes + 1) * height;
10147
- // All dimensions and the exact filtered length are bounded before allocating decoded pixels.
10148
- if (!Number.isSafeInteger(expected) || expected > 0x7fffffff)
10149
- throw new OfficeIMOError("RESOURCE_LIMIT", "PNG filtered data exceeds the supported decoded byte length.");
10150
10227
  // RGBA is reconstructed one scanline at a time directly into PDF RGB/alpha planes.
10151
10228
  // It never retains an additional full interleaved RGBA image.
10152
10229
  const pixels = new Uint8Array(width * height * 3), alpha = components === 4 ? new Uint8Array(imagePixels) : undefined;
@@ -10294,20 +10371,55 @@ async function verifyPngZlibEnd(source, header, expected, signal) {
10294
10371
  reader.releaseLock();
10295
10372
  }
10296
10373
  }
10374
+ function pngChunk(source, view, offset) {
10375
+ if (offset + 12 > source.length)
10376
+ throw new TypeError("Truncated PNG chunk.");
10377
+ const length = view.getUint32(offset), end = offset + 12 + length;
10378
+ if (length > 0x7fffffff || end > source.length)
10379
+ throw new TypeError("Truncated or oversized PNG chunk.");
10380
+ const type = String.fromCharCode(...source.subarray(offset + 4, offset + 8));
10381
+ if (!/^[A-Za-z]{2}[A-Z][A-Za-z]$/.test(type))
10382
+ throw new TypeError("Invalid PNG chunk type.");
10383
+ return { length, end, type };
10384
+ }
10385
+ function checkAncillaryChunk(type) {
10386
+ if (unsupportedChunks.has(type))
10387
+ throw new NotSupportedError("PNG chunk " + type + "; normalize color, orientation, transparency or animation first");
10388
+ if (type.charCodeAt(0) < 97)
10389
+ throw new NotSupportedError("Required PNG chunk " + type);
10390
+ }
10391
+ /** Check the image profile for SVG placement without inflating pixels. Embedding still verifies CRCs and image data. */
10392
+ function pngEmbeddableSize(source) {
10393
+ const shape = pngShape(source, Infinity);
10394
+ const view = new DataView(source.buffer, source.byteOffset, source.byteLength);
10395
+ let hasData = false, dataClosed = false;
10396
+ for (let offset = 33; offset < source.length;) {
10397
+ const { length, end, type } = pngChunk(source, view, offset);
10398
+ if (type === "IEND") {
10399
+ if (length === 0 && hasData && end === source.length)
10400
+ return shape;
10401
+ break;
10402
+ }
10403
+ if (type === "IDAT") {
10404
+ if (dataClosed)
10405
+ throw new TypeError("PNG IDAT chunks must be consecutive.");
10406
+ hasData = true;
10407
+ }
10408
+ else {
10409
+ checkAncillaryChunk(type);
10410
+ dataClosed ||= hasData;
10411
+ }
10412
+ offset = end;
10413
+ }
10414
+ throw new TypeError("PNG requires a final empty IEND after IDAT.");
10415
+ }
10297
10416
  /** Verify the complete source and critical chunk order before any decompressed image allocation. */
10298
10417
  async function pngHeader(source, shape, signal) {
10299
10418
  const view = new DataView(source.buffer, source.byteOffset, source.byteLength);
10300
10419
  let firstData = 0, dataEnd = 0, lastDataByte = -1, dataClosed = false;
10301
10420
  for (let offset = 8; offset < source.length;) {
10302
10421
  checkAbort(signal);
10303
- if (offset + 12 > source.length)
10304
- throw new TypeError("Truncated PNG chunk.");
10305
- const length = view.getUint32(offset), end = offset + 12 + length;
10306
- if (length > 0x7fffffff || end > source.length)
10307
- throw new TypeError("Truncated or oversized PNG chunk.");
10308
- const type = String.fromCharCode(...source.subarray(offset + 4, offset + 8));
10309
- if (!/^[A-Za-z]{2}[A-Z][A-Za-z]$/.test(type))
10310
- throw new TypeError("Invalid PNG chunk type.");
10422
+ const { length, end, type } = pngChunk(source, view, offset);
10311
10423
  const crc = new Crc32();
10312
10424
  for (let p = offset + 4; p < end - 4; p += 65536) {
10313
10425
  crc.update(source.subarray(p, Math.min(end - 4, p + 65536)));
@@ -10339,17 +10451,14 @@ async function pngHeader(source, shape, signal) {
10339
10451
  throw new TypeError("PNG requires a final empty IEND after IDAT.");
10340
10452
  return { ...shape, firstData, dataEnd, lastDataByte };
10341
10453
  }
10342
- if (unsupportedChunks.has(type))
10343
- throw new NotSupportedError("PNG chunk " + type + "; normalize color, orientation, transparency or animation first");
10344
- if ((source[offset + 4] & 32) === 0)
10345
- throw new NotSupportedError("Required PNG chunk " + type);
10454
+ checkAncillaryChunk(type);
10346
10455
  }
10347
10456
  offset = end;
10348
10457
  }
10349
10458
  throw new TypeError("PNG requires a complete final IEND chunk.");
10350
10459
  }
10351
10460
  /** Check source metadata synchronously, before capturing source bytes or allocating any image plane. */
10352
- function pngShape(source, maxPixels) {
10461
+ function pngShape(source, maxPixels, maxWorkingBytes) {
10353
10462
  if (source.length < 33 || signature.some((value, index) => source[index] !== value))
10354
10463
  throw new TypeError("Invalid PNG signature or truncated IHDR.");
10355
10464
  const view = new DataView(source.buffer, source.byteOffset, source.byteLength);
@@ -10369,6 +10478,9 @@ function pngShape(source, maxPixels) {
10369
10478
  const components = source[25] === 6 ? 4 : 3;
10370
10479
  if (!Number.isSafeInteger((width * components + 1) * height) || (width * components + 1) * height > 0x7fffffff)
10371
10480
  throw new OfficeIMOError("RESOURCE_LIMIT", "PNG filtered data exceeds the supported decoded byte length.");
10481
+ const workingBytes = source.length + width * height * components + (components === 4 ? width * 8 : 0);
10482
+ if (maxWorkingBytes !== undefined && workingBytes > maxWorkingBytes)
10483
+ throw new OfficeIMOError("RESOURCE_LIMIT", "maxImageWorkingBytes exceeded by PNG source, image planes and scanlines.");
10372
10484
  return { width, height, components };
10373
10485
  }
10374
10486
  function paeth(left, up, upperLeft) {
@@ -10376,64 +10488,93 @@ function paeth(left, up, upperLeft) {
10376
10488
  const a = Math.abs(prediction - left), b = Math.abs(prediction - up), c = Math.abs(prediction - upperLeft);
10377
10489
  return a <= b && a <= c ? left : b <= c ? up : upperLeft;
10378
10490
  }
10379
- const _exports = Object.freeze({ pngPixels: pngPixels });
10380
- _modules.set("749d1ec5422c0087787f525ef42e3b8d3a94d2b70eb5e42d2e3723a870777ad6", _exports);
10491
+ const _exports = Object.freeze({ pngPixels: pngPixels, pngEmbeddableSize: pngEmbeddableSize, pngShape: pngShape });
10492
+ _modules.set("6b0244b5ec6d550c705b4e4cbb47997331f1ecd99e2bf8a06f7c646eebbffbf8", _exports);
10381
10493
  return _exports;
10382
10494
  })();
10383
10495
 
10384
- const _m86 = _modules.get("7dca2d9ca5c43893abdaf86df5b1bcb1f3de3d5d33532d082fdfe04711999d21") ?? (() => {
10496
+ const _m86 = _modules.get("32ca4982f963f400829c2e364b7d3479f36d91740dafb32d600f29b5cac487ec") ?? (() => {
10385
10497
  const { NotSupportedError, OfficeIMOError } = _m2;
10386
10498
 
10387
10499
  const { checkAbort, pause, taskYieldDue } = _m4;
10388
10500
 
10389
- const { pngPixels } = _m87;
10501
+ const { pngPixels, pngShape } = _m87;
10390
10502
 
10391
10503
  /** Shared document image resources; source objects are captured on first consumption. */
10392
10504
  class PdfDocumentImages {
10393
10505
  objects;
10394
10506
  settings;
10395
10507
  images = new Map();
10508
+ snapshots = new WeakMap();
10396
10509
  bytes = 0;
10510
+ pendingBytes = 0;
10397
10511
  constructor(objects, settings) {
10398
10512
  this.objects = objects;
10399
10513
  this.settings = settings;
10400
10514
  }
10401
- async prepare(image) {
10402
- const existing = this.images.get(image);
10403
- if (existing)
10404
- return existing;
10515
+ /** Own a drawing image before preparing earlier elements can yield to the caller. */
10516
+ snapshot(image) {
10517
+ if (this.images.has(image) || this.snapshots.has(image))
10518
+ return;
10519
+ const captured = this.capture(image);
10520
+ this.snapshots.set(image, captured);
10521
+ this.pendingBytes += captured.data.length;
10522
+ }
10523
+ capture(image) {
10405
10524
  const { limits, options } = this.settings;
10525
+ checkAbort(options.signal);
10406
10526
  if (!image || typeof image !== "object")
10407
10527
  throw new TypeError("PDF images require a byte array.");
10408
- const data = image.data, format = image.format;
10528
+ const format = image.format;
10529
+ // Dimension getters may change a resizable backing buffer. Read them before measuring the byte view.
10530
+ const raw = format === "rgb" || format === "rgba" ? image : undefined;
10531
+ const widthValue = raw?.width, heightValue = raw?.height;
10532
+ const data = image.data;
10409
10533
  if (!(data instanceof Uint8Array))
10410
10534
  throw new TypeError("PDF images require a byte array.");
10411
10535
  const byteLength = data.length;
10412
- if (this.bytes + byteLength > limits.maxImageBytes)
10536
+ if (this.bytes + this.pendingBytes + byteLength > limits.maxImageBytes)
10413
10537
  throw new OfficeIMOError("RESOURCE_LIMIT", "maxImageBytes exceeded.");
10414
- let width, height, components, decoded, decodedAlpha;
10415
10538
  const maximumWorkingBytes = limits.maxImageWorkingBytes;
10416
- if (format === "png")
10417
- ({ width, height, components, data: decoded, alpha: decodedAlpha } = await pngPixels(data, limits.maxImagePixels, options.signal, maximumWorkingBytes));
10418
- else if (format === "jpeg")
10419
- ({ width, height, components } = jpegSize(data));
10539
+ if (format === "png") {
10540
+ const shape = pngShape(data, limits.maxImagePixels, maximumWorkingBytes);
10541
+ return { format, shape, data: new Uint8Array(data) };
10542
+ }
10543
+ let shape;
10544
+ if (format === "jpeg")
10545
+ shape = jpegSize(data);
10420
10546
  else if (format === "rgb" || format === "rgba") {
10421
- ({ width, height } = image);
10422
- components = format === "rgba" ? 4 : 3;
10547
+ shape = { width: widthValue, height: heightValue, components: format === "rgba" ? 4 : 3 };
10423
10548
  }
10424
10549
  else
10425
10550
  throw new NotSupportedError("PDF images support unprofiled PNG/JPEG or decoded RGB/RGBA pixels.");
10551
+ const { width, height, components } = shape;
10426
10552
  if (!Number.isSafeInteger(width) || !Number.isSafeInteger(height) || width < 1 || height < 1 ||
10427
10553
  !Number.isSafeInteger(width * height) || width * height > limits.maxImagePixels)
10428
10554
  throw new OfficeIMOError("RESOURCE_LIMIT", "Image dimensions must be positive integers within maxImagePixels.");
10429
- if ((format === "rgb" || format === "rgba") && byteLength !== width * height * components)
10555
+ if (format !== "jpeg" && byteLength !== width * height * components)
10430
10556
  throw new RangeError("Raw image bytes must match width × height × channels exactly.");
10431
- if (format !== "png" && maximumWorkingBytes !== undefined && byteLength + (components === 4 ? width * height : 0) > maximumWorkingBytes)
10557
+ if (maximumWorkingBytes !== undefined && byteLength + (components === 4 ? width * height : 0) > maximumWorkingBytes)
10432
10558
  throw new OfficeIMOError("RESOURCE_LIMIT", "maxImageWorkingBytes exceeded by image snapshot and alpha plane.");
10559
+ return { format, shape, data: new Uint8Array(data) };
10560
+ }
10561
+ async prepare(image) {
10562
+ const existing = this.images.get(image);
10563
+ if (existing)
10564
+ return existing;
10565
+ const { options } = this.settings, snapshot = this.snapshots.get(image);
10566
+ const source = snapshot ?? this.capture(image);
10567
+ if (snapshot) {
10568
+ this.snapshots.delete(image);
10569
+ this.pendingBytes -= source.data.length;
10570
+ }
10571
+ this.bytes += source.data.length;
10572
+ const { format } = source;
10573
+ const decoded = format === "png" ? await pngPixels(source.data, source.shape, options.signal) : undefined;
10574
+ const { width, height, components } = decoded ?? source.shape;
10433
10575
  checkAbort(options.signal);
10434
10576
  const id = this.objects.reserve(), name = "Image" + (this.images.size + 1);
10435
- this.bytes += byteLength;
10436
- const captured = decoded ?? new Uint8Array(data);
10577
+ const captured = decoded?.data ?? source.data, decodedAlpha = decoded?.alpha;
10437
10578
  let pixels = captured, alpha = decodedAlpha, mask;
10438
10579
  if (components === 4) {
10439
10580
  // Compact the owned RGBA snapshot in place. Forward writes never overwrite unread channels.
@@ -10455,20 +10596,22 @@ class PdfDocumentImages {
10455
10596
  mask = this.objects.reserve();
10456
10597
  await this.objects.stream(mask, alpha, "/Type /XObject /Subtype /Image /Width " + width + " /Height " + height + " /ColorSpace /DeviceGray /BitsPerComponent 8", options.compression !== false, true);
10457
10598
  }
10599
+ const jpegFilter = format === "jpeg" ? " /Filter /DCTDecode" +
10600
+ (source.shape.colorTransform === 0 ? " /DecodeParms << /ColorTransform 0 >>" : "") : "";
10458
10601
  const dictionary = "/Type /XObject /Subtype /Image /Width " + width + " /Height " + height + " /ColorSpace /" +
10459
10602
  (components === 1 ? "DeviceGray" : "DeviceRGB") + " /BitsPerComponent 8" + (mask ? " /SMask " + mask + " 0 R" : "") +
10460
- (format === "jpeg" ? " /Filter /DCTDecode" : "");
10603
+ jpegFilter;
10461
10604
  await this.objects.stream(id, pixels, dictionary, format === "jpeg" ? false : options.compression !== false, true);
10462
10605
  const resource = { name, id, width, height };
10463
10606
  this.images.set(image, resource);
10464
10607
  return resource;
10465
10608
  }
10466
10609
  }
10467
- /** Inspect bounded JPEG headers; JPEG entropy decoding remains the independent reader's job. */
10610
+ /** @internal Inspect bounded JPEG headers; JPEG entropy decoding remains the independent reader's job. */
10468
10611
  function jpegSize(bytes) {
10469
10612
  if (bytes.length < 4 || bytes[0] !== 255 || bytes[1] !== 216 || bytes[bytes.length - 2] !== 255 || bytes[bytes.length - 1] !== 217)
10470
10613
  throw new TypeError("JPEG images need complete SOI/EOI markers.");
10471
- let result;
10614
+ let result, rgb = false, adobe = false;
10472
10615
  for (let p = 2; p < bytes.length;) {
10473
10616
  if (bytes[p++] !== 255)
10474
10617
  throw new TypeError("Invalid JPEG marker.");
@@ -10478,7 +10621,8 @@ function jpegSize(bytes) {
10478
10621
  if (marker === 218) {
10479
10622
  if (!result)
10480
10623
  throw new TypeError("JPEG scan precedes its frame header.");
10481
- return result;
10624
+ // PDF decoders otherwise assume a color transform for three-component JPEGs.
10625
+ return rgb && !adobe ? { ...result, colorTransform: 0 } : result;
10482
10626
  }
10483
10627
  if (marker === 217)
10484
10628
  break;
@@ -10487,6 +10631,8 @@ function jpegSize(bytes) {
10487
10631
  const length = bytes[p] * 256 + bytes[p + 1], end = p + length;
10488
10632
  if (length < 2 || end > bytes.length)
10489
10633
  throw new TypeError("Truncated JPEG segment.");
10634
+ if (marker === 238 && length >= 14 && String.fromCharCode(...bytes.subarray(p + 2, p + 7)) === "Adobe")
10635
+ adobe = true;
10490
10636
  if (marker === 226 && length >= 14 && String.fromCharCode(...bytes.subarray(p + 2, p + 14)) === "ICC_PROFILE\0")
10491
10637
  throw new NotSupportedError("Normalize ICC-profiled JPEG colors before PDF embedding.");
10492
10638
  if (marker === 225 && length >= 8 && String.fromCharCode(...bytes.subarray(p + 2, p + 8)) === "Exif\0\0")
@@ -10499,7 +10645,8 @@ function jpegSize(bytes) {
10499
10645
  throw new NotSupportedError("PDF JPEG images require grayscale or RGB components; CMYK is unsupported.");
10500
10646
  if (components === 3) {
10501
10647
  const ids = [bytes[p + 8], bytes[p + 11], bytes[p + 14]].join(",");
10502
- if (ids !== "1,2,3" && ids !== "82,71,66")
10648
+ rgb = ids === "82,71,66";
10649
+ if (ids !== "1,2,3" && !rgb)
10503
10650
  throw new NotSupportedError("Unsupported JPEG component color layout.");
10504
10651
  }
10505
10652
  if (result)
@@ -10510,12 +10657,12 @@ function jpegSize(bytes) {
10510
10657
  }
10511
10658
  throw new TypeError("JPEG image has no complete frame and scan.");
10512
10659
  }
10513
- const _exports = Object.freeze({ PdfDocumentImages: PdfDocumentImages });
10514
- _modules.set("7dca2d9ca5c43893abdaf86df5b1bcb1f3de3d5d33532d082fdfe04711999d21", _exports);
10660
+ const _exports = Object.freeze({ PdfDocumentImages: PdfDocumentImages, jpegSize: jpegSize });
10661
+ _modules.set("32ca4982f963f400829c2e364b7d3479f36d91740dafb32d600f29b5cac487ec", _exports);
10515
10662
  return _exports;
10516
10663
  })();
10517
10664
 
10518
- const _m88 = _modules.get("3290c84fdf80725af802f497d947bc088aa8d93d9db0a33f6f829f9153aa6fd6") ?? (() => {
10665
+ const _m88 = _modules.get("9ba2dfd6f5c8ef9b1a51427ddee0d0971b139afdd49a175bf6525812ca7d87c8") ?? (() => {
10519
10666
  const { OfficeIMOError } = _m2;
10520
10667
 
10521
10668
  const { checkAbort, pause, taskYieldDue } = _m4;
@@ -10598,16 +10745,16 @@ async function vectorCommands(block, settings, used) {
10598
10745
  commands.join("") + (fill !== undefined && stroke !== undefined ? "B" : fill !== undefined ? "f" : "S") + (fill !== undefined && fillRule === "evenodd" ? "*" : "") + "\n" };
10599
10746
  }
10600
10747
  const _exports = Object.freeze({ vectorCommands: vectorCommands });
10601
- _modules.set("3290c84fdf80725af802f497d947bc088aa8d93d9db0a33f6f829f9153aa6fd6", _exports);
10748
+ _modules.set("9ba2dfd6f5c8ef9b1a51427ddee0d0971b139afdd49a175bf6525812ca7d87c8", _exports);
10602
10749
  return _exports;
10603
10750
  })();
10604
10751
 
10605
- const _m89 = _modules.get("da9ad00f94b9ae28e2e3de796928ff0c4eab1d73382b1441e7d779fad4278ef7") ?? (() => {
10752
+ const _m89 = _modules.get("da0657c49ac1393409d051be5e5dd70d2a0dc5221d363b422d7da31e9b940ea2") ?? (() => {
10606
10753
  const { NotSupportedError, OfficeIMOError } = _m2;
10607
10754
 
10608
10755
  const { checkAbort, pause, taskYieldDue } = _m4;
10609
10756
 
10610
- const { color, positive } = _m17;
10757
+ const { color, pdfDrawingMaxDepth, positive } = _m17;
10611
10758
 
10612
10759
  const { pdfNumber: n } = _m61;
10613
10760
 
@@ -10629,22 +10776,50 @@ function clipRectangle(value) {
10629
10776
  const clip = record(value, ["x", "y", "width", "height"], "drawing clip");
10630
10777
  return { x: coordinate(clip.x), y: coordinate(clip.y), width: positive(clip.width, "Drawing clip width", 1000000), height: positive(clip.height, "Drawing clip height", 1000000) };
10631
10778
  }
10779
+ /** A PDF dash array: 1 through 16 nonnegative lengths, not all zero, and a finite phase. */
10780
+ function dashPattern(value, offset) {
10781
+ if (value === undefined) {
10782
+ if (offset !== undefined)
10783
+ throw new TypeError("Drawing dashOffset requires dash.");
10784
+ return "";
10785
+ }
10786
+ if (!Array.isArray(value) || !value.length || value.length > 16)
10787
+ throw new TypeError("Drawing dash must list 1 through 16 nonnegative lengths with at least one positive length.");
10788
+ const lengths = Array.from(value, item => {
10789
+ if (typeof item !== "number" || !Number.isFinite(item) || item < 0 || item > 14400)
10790
+ throw new TypeError("Drawing dash lengths must be from 0 through 14,400 points.");
10791
+ return n(item);
10792
+ });
10793
+ if (lengths.every(length => length === "0"))
10794
+ throw new TypeError("Drawing dash needs a positive length after PDF rounding.");
10795
+ let phase = coordinate(offset ?? 0);
10796
+ if (phase < 0) {
10797
+ // Work in serialized thousandths of a point. Odd arrays repeat twice before the paint state repeats.
10798
+ const period = lengths.reduce((sum, length) => sum + Math.round(Number(length) * 1000), 0) * (lengths.length % 2 ? 2 : 1);
10799
+ phase = ((Math.round(phase * 1000) % period + period) % period) / 1000;
10800
+ }
10801
+ return "[" + lengths.join(" ") + "] " + n(phase) + " d\n";
10802
+ }
10632
10803
  async function cooperate(settings) {
10633
10804
  if (taskYieldDue())
10634
10805
  await pause();
10635
10806
  checkAbort(settings.options.signal);
10636
10807
  }
10637
10808
  /** Take ownership of one bounded schema before any cooperative or font work can run caller code. */
10638
- function captureDrawing(drawing, settings, used) {
10809
+ function captureDrawing(drawing, settings, used, images) {
10639
10810
  checkAbort(settings.options.signal);
10640
- const root = record(drawing, ["version", "width", "height", "elements"], "drawing");
10641
- if (root.version !== 1)
10642
- throw new NotSupportedError("Only portable drawing version 1 is supported.");
10811
+ const root = record(drawing, ["version", "width", "height", "elements", "standardFonts"], "drawing");
10812
+ const standardFonts = root.standardFonts;
10813
+ if (standardFonts !== undefined && typeof standardFonts !== "boolean")
10814
+ throw new TypeError("Drawing standardFonts must be boolean.");
10815
+ const version = root.version;
10816
+ if (version !== 1 && version !== 2)
10817
+ throw new NotSupportedError("Only portable drawing versions 1 and 2 are supported.");
10643
10818
  const width = positive(root.width, "Drawing width"), height = positive(root.height, "Drawing height");
10644
10819
  let commands = used.commands, elements = used.elements;
10645
10820
  const ancestors = new Set();
10646
10821
  function path(value) {
10647
- record(value, ["kind", "commands", "fill", "stroke", "strokeWidth", "fillRule", "lineCap", "lineJoin"], "drawing path");
10822
+ record(value, ["kind", "commands", "fill", "stroke", "strokeWidth", "fillRule", "lineCap", "lineJoin", "miterLimit", "dash", "dashOffset"], "drawing path");
10648
10823
  const source = value.commands;
10649
10824
  if (!Array.isArray(source))
10650
10825
  throw new TypeError("Drawing path commands must be an array.");
@@ -10666,6 +10841,10 @@ function captureDrawing(drawing, settings, used) {
10666
10841
  throw new TypeError("Invalid drawing lineCap.");
10667
10842
  if (lineJoin !== undefined && !["miter", "round", "bevel"].includes(lineJoin))
10668
10843
  throw new TypeError("Invalid drawing lineJoin.");
10844
+ const miterLimit = positive(value.miterLimit ?? 10, "Drawing miter limit", 1000000);
10845
+ if (miterLimit < 1)
10846
+ throw new RangeError("Drawing miter limit must be at least 1.");
10847
+ const dash = dashPattern(value.dash, value.dashOffset);
10669
10848
  for (let i = 0; i < snapshot.length; i++) {
10670
10849
  const c = snapshot[i];
10671
10850
  if (!c || typeof c !== "object")
@@ -10698,11 +10877,12 @@ function captureDrawing(drawing, settings, used) {
10698
10877
  if (!started)
10699
10878
  throw new TypeError("A drawing path needs at least one command.");
10700
10879
  return { kind: "path", commands: copied, style: (fill === undefined ? "" : fill + " rg\n") + (stroke === undefined ? "" : stroke + " RG\n" + n(strokeWidth) + " w\n") +
10701
- String(["butt", "round", "square"].indexOf(lineCap ?? "butt")) + " J\n" + String(["miter", "round", "bevel"].indexOf(lineJoin ?? "miter")) + " j\n10 M\n",
10880
+ String(["butt", "round", "square"].indexOf(lineCap ?? "butt")) + " J\n" + String(["miter", "round", "bevel"].indexOf(lineJoin ?? "miter")) +
10881
+ " j\n" + n(miterLimit) + " M\n" + dash,
10702
10882
  paint: (fill !== undefined && stroke !== undefined ? "B" : fill !== undefined ? "f" : "S") + (fill !== undefined && fillRule === "evenodd" ? "*" : "") + "\n" };
10703
10883
  }
10704
10884
  function text(value) {
10705
- record(value, ["kind", "text", "x", "y", "font", "fontSize", "color"], "drawing text");
10885
+ record(value, ["kind", "text", "x", "y", "font", "fontSize", "color", "anchor", "rotation"], "drawing text");
10706
10886
  const snapshot = value.text, slot = value.font;
10707
10887
  if (typeof snapshot !== "string")
10708
10888
  throw new TypeError("Drawing text must be a string.");
@@ -10713,14 +10893,33 @@ function captureDrawing(drawing, settings, used) {
10713
10893
  if (!["regular", "bold", "italic", "boldItalic"].includes(slot))
10714
10894
  throw new TypeError("Invalid drawing font slot.");
10715
10895
  const x = coordinate(value.x), y = coordinate(value.y), size = positive(value.fontSize, "Drawing font size"), foreground = color(value.color);
10896
+ const anchor = value.anchor, rotation = value.rotation ?? 0;
10897
+ if (anchor !== undefined && !["start", "middle", "end"].includes(anchor))
10898
+ throw new TypeError("Invalid drawing text anchor.");
10899
+ if (typeof rotation !== "number" || !Number.isFinite(rotation) || Math.abs(rotation) > 360)
10900
+ throw new RangeError("Drawing text rotation must be finite degrees within -360 through 360.");
10716
10901
  settings.budget.cell(snapshot);
10717
- return { kind: "text", text: snapshot, x, y, size, color: foreground, font: slot };
10902
+ // Quarter turns stay exact so upright and vertical axis labels keep integral matrices.
10903
+ const turn = rotation % 90 === 0 ? (((rotation / 90) % 4) + 4) % 4 : -1, radians = rotation * Math.PI / 180;
10904
+ const cos = turn < 0 ? Math.cos(radians) : [1, 0, -1, 0][turn], sin = turn < 0 ? Math.sin(radians) : [0, 1, 0, -1][turn];
10905
+ return { kind: "text", text: snapshot, x, y, size, color: foreground, font: slot, anchor: anchor === "middle" ? .5 : anchor === "end" ? 1 : 0, cos, sin };
10906
+ }
10907
+ function image(value) {
10908
+ record(value, ["kind", "image", "x", "y", "width", "height", "opacity"], "drawing image");
10909
+ const x = coordinate(value.x), y = coordinate(value.y), suppliedOpacity = value.opacity;
10910
+ const opacity = suppliedOpacity === undefined ? 1 : suppliedOpacity;
10911
+ const width = positive(value.width, "Drawing image width", 1000000), height = positive(value.height, "Drawing image height", 1000000);
10912
+ if (typeof opacity !== "number" || !(opacity >= 0 && opacity <= 1))
10913
+ throw new RangeError("Drawing image opacity must be from 0 through 1.");
10914
+ const source = value.image;
10915
+ images.snapshot(source);
10916
+ return { kind: "image", image: source, x, y, width, height, opacity };
10718
10917
  }
10719
10918
  function children(input, depth) {
10720
10919
  if (!Array.isArray(input))
10721
10920
  throw new TypeError("Drawing elements must be an array.");
10722
- if (depth > 32 && input.length)
10723
- throw new RangeError("Drawing groups support at most 32 element levels.");
10921
+ if (depth > pdfDrawingMaxDepth && input.length)
10922
+ throw new RangeError("Drawing groups support at most " + pdfDrawingMaxDepth + " element levels.");
10724
10923
  if (elements + input.length > settings.limits.maxDrawingElements)
10725
10924
  throw new OfficeIMOError("RESOURCE_LIMIT", "maxDrawingElements exceeded.");
10726
10925
  checkAbort(settings.options.signal);
@@ -10738,6 +10937,8 @@ function captureDrawing(drawing, settings, used) {
10738
10937
  output.push(path(value));
10739
10938
  else if (kind === "text")
10740
10939
  output.push(text(value));
10940
+ else if (kind === "image" && version === 2)
10941
+ output.push(image(value));
10741
10942
  else if (kind === "group") {
10742
10943
  record(value, ["kind", "clip", "elements"], "drawing group");
10743
10944
  const clipValue = value.clip, clip = clipValue === undefined ? undefined : clipRectangle(clipValue);
@@ -10754,29 +10955,35 @@ function captureDrawing(drawing, settings, used) {
10754
10955
  }
10755
10956
  const plan = children(root.elements, 1);
10756
10957
  checkAbort(settings.options.signal);
10757
- return { width, height, plan, commands: commands - used.commands, elements: elements - used.elements };
10958
+ return { width, height, plan, commands: commands - used.commands, elements: elements - used.elements, standardFonts: standardFonts === true };
10758
10959
  }
10759
10960
  /** Preflight and paint owned records. The existing font owner retains glyph maps and subsets. */
10760
- async function prepareDrawing(drawing, settings, fonts, used) {
10961
+ async function prepareDrawing(drawing, settings, fonts, used, resources) {
10761
10962
  // A drawing's bounded capture is synchronous; yielding here would leave later caller records borrowed.
10762
- const captured = captureDrawing(drawing, settings, used), drawingFonts = new Map();
10963
+ const { images } = resources, captured = captureDrawing(drawing, settings, used, images), drawingFonts = new Map();
10763
10964
  function fontFor(slot) {
10764
10965
  const existing = drawingFonts.get(slot);
10765
10966
  if (existing)
10766
10967
  return existing;
10767
- const font = fonts.select(slot === "bold" || slot === "boldItalic", slot === "italic" || slot === "boldItalic");
10768
- if (!font.program || font.syntheticBold || font.syntheticItalic)
10968
+ const font = fonts.select(slot === "bold" || slot === "boldItalic", slot === "italic" || slot === "boldItalic", undefined, captured.standardFonts);
10969
+ if (font.syntheticBold || font.syntheticItalic || !font.program && !captured.standardFonts)
10769
10970
  throw new NotSupportedError("Drawing text without an exact embedded font face at fonts." + slot);
10770
10971
  drawingFonts.set(slot, font);
10771
10972
  return font;
10772
10973
  }
10773
10974
  // The work budget belongs to the drawing, including short runs in separate sibling groups.
10774
10975
  let preflightCharacters = 0, preflightElements = 0;
10976
+ const imageNames = new Map();
10775
10977
  async function preflight(nodes) {
10776
10978
  for (let i = 0; i < nodes.length; i++) {
10777
10979
  const node = nodes[i];
10778
10980
  if (node.kind === "group")
10779
10981
  await preflight(node.children);
10982
+ else if (node.kind === "image" && !imageNames.has(node.image)) {
10983
+ const resource = await images.prepare(node.image);
10984
+ resources.registerImage(resource.name, resource.id);
10985
+ imageNames.set(node.image, resource.name);
10986
+ }
10780
10987
  else if (node.kind === "text") {
10781
10988
  const font = fontFor(node.font);
10782
10989
  for (const character of node.text) {
@@ -10819,9 +11026,23 @@ async function prepareDrawing(drawing, settings, fonts, used) {
10819
11026
  }
10820
11027
  add(node.paint);
10821
11028
  }
11029
+ else if (node.kind === "image") {
11030
+ // Image space is a unit square with a bottom-left origin; the drawing's y axis points down.
11031
+ if (node.opacity < 1)
11032
+ add("/" + resources.opacity(node.opacity) + " gs\n");
11033
+ add([node.width, 0, 0, -node.height, node.x, node.y + node.height].map(n).join(" ") + " cm /" + imageNames.get(node.image) + " Do\n");
11034
+ }
10822
11035
  else {
10823
11036
  const font = fontFor(node.font);
10824
- add(node.color + " rg\nBT /" + font.name + " " + n(node.size) + " Tf 0 Tr 1 0 0 -1 " + n(node.x) + " " + n(node.y) + " Tm <");
11037
+ let shift = 0;
11038
+ if (node.anchor) {
11039
+ for (const character of node.text)
11040
+ shift += font.width(character.codePointAt(0));
11041
+ shift *= node.size / 1000 * node.anchor;
11042
+ }
11043
+ // Text space is upright in the drawing's downward y axis; rotation turns the baseline clockwise about its anchor.
11044
+ add(node.color + " rg\nBT /" + font.name + " " + n(node.size) + " Tf 0 Tr " +
11045
+ [node.cos, node.sin, node.sin, -node.cos, node.x - shift * node.cos, node.y - shift * node.sin].map(n).join(" ") + " Tm <");
10825
11046
  let chunk = "";
10826
11047
  for (const character of node.text) {
10827
11048
  chunk += character;
@@ -10845,11 +11066,11 @@ async function prepareDrawing(drawing, settings, fonts, used) {
10845
11066
  return { width: captured.width, height: captured.height, content: fragments.join(""), commands: captured.commands, elements: captured.elements };
10846
11067
  }
10847
11068
  const _exports = Object.freeze({ checkDrawingBlock: checkDrawingBlock, prepareDrawing: prepareDrawing });
10848
- _modules.set("da9ad00f94b9ae28e2e3de796928ff0c4eab1d73382b1441e7d779fad4278ef7", _exports);
11069
+ _modules.set("da0657c49ac1393409d051be5e5dd70d2a0dc5221d363b422d7da31e9b940ea2", _exports);
10849
11070
  return _exports;
10850
11071
  })();
10851
11072
 
10852
- const _m90 = _modules.get("5e4503b77b357ee6d9fad1f52690085b0f0b140cd3b550b63c5100ed95a92f88") ?? (() => {
11073
+ const _m90 = _modules.get("37923737a6bcae4c342ab023bd3cb01ddeaced28543718aad078b51b54d8f31d") ?? (() => {
10853
11074
  const { OfficeIMOError } = _m2;
10854
11075
 
10855
11076
  const { capturePdfText, wrapPdfText } = _m72;
@@ -10929,11 +11150,11 @@ function paragraphStartHeight(paragraphs) {
10929
11150
  return required;
10930
11151
  }
10931
11152
  const _exports = Object.freeze({ captureParagraph: captureParagraph, captureCaption: captureCaption, prepareParagraph: prepareParagraph, checkParagraphBuffer: checkParagraphBuffer, paragraphStartHeight: paragraphStartHeight });
10932
- _modules.set("5e4503b77b357ee6d9fad1f52690085b0f0b140cd3b550b63c5100ed95a92f88", _exports);
11153
+ _modules.set("37923737a6bcae4c342ab023bd3cb01ddeaced28543718aad078b51b54d8f31d", _exports);
10933
11154
  return _exports;
10934
11155
  })();
10935
11156
 
10936
- const _m91 = _modules.get("1d57c429705ae0cbc14d98dcfef4c8a6c2df06f391c8f58e99cacb02f2d1cbc7") ?? (() => {
11157
+ const _m91 = _modules.get("964206f2e7c45a34e414d4d690243bf90eb4cf99793e13d1cda834de3d386773") ?? (() => {
10937
11158
  const { capturePdfText, wrapPdfText } = _m72;
10938
11159
 
10939
11160
  const { captureParagraph, prepareParagraph } = _m90;
@@ -10987,11 +11208,11 @@ async function prepareListItem(item, index, options, settings, fonts) {
10987
11208
  height: paragraph.height + lineHeight - first.lineHeight, firstHeight: paragraph.spaceBefore + lineHeight } };
10988
11209
  }
10989
11210
  const _exports = Object.freeze({ captureListOptions: captureListOptions, prepareListItem: prepareListItem });
10990
- _modules.set("1d57c429705ae0cbc14d98dcfef4c8a6c2df06f391c8f58e99cacb02f2d1cbc7", _exports);
11211
+ _modules.set("964206f2e7c45a34e414d4d690243bf90eb4cf99793e13d1cda834de3d386773", _exports);
10991
11212
  return _exports;
10992
11213
  })();
10993
11214
 
10994
- const _m93 = _modules.get("d04686d2c067355dfd215333b83eb5f79f96e9e4be49f942e050f21ac0795343") ?? (() => {
11215
+ const _m93 = _modules.get("f254a333f483757dc21be9d40dbd3ca51013d32a3c646b564270e3902226a590") ?? (() => {
10995
11216
  const { assertGroupedReportSource } = _m8;
10996
11217
 
10997
11218
  const { captureFields } = _m10;
@@ -11037,11 +11258,11 @@ function captureGroupedPdfTableOptions(configuration) {
11037
11258
  ...(captured.footerPresentation === undefined ? {} : { footerPresentation: presentation(captured.footerPresentation) }) });
11038
11259
  }
11039
11260
  const _exports = Object.freeze({ groupedPdfLabelFields: groupedPdfLabelFields, groupedPdfTableFields: groupedPdfTableFields, pdfGroupedTable: pdfGroupedTable, captureGroupedPdfTableOptions: captureGroupedPdfTableOptions });
11040
- _modules.set("d04686d2c067355dfd215333b83eb5f79f96e9e4be49f942e050f21ac0795343", _exports);
11261
+ _modules.set("f254a333f483757dc21be9d40dbd3ca51013d32a3c646b564270e3902226a590", _exports);
11041
11262
  return _exports;
11042
11263
  })();
11043
11264
 
11044
- const _m92 = _modules.get("289fa3a052c7fbab2a3ca0fb91fb9974db709d24b7d850f1175810258f0409a0") ?? (() => {
11265
+ const _m92 = _modules.get("a3ebee86ff33369e9ebc8b994d71bad32497a55433a313c426676277cb660d2f") ?? (() => {
11045
11266
  const { assertGroupedReportSource, groupedReportOperation } = _m8;
11046
11267
 
11047
11268
  const { consumeRows } = _m4;
@@ -11295,11 +11516,11 @@ async function renderGroupedPdfTable(block, context) {
11295
11516
  }
11296
11517
  }
11297
11518
  const _exports = Object.freeze({ renderGroupedPdfTable: renderGroupedPdfTable });
11298
- _modules.set("289fa3a052c7fbab2a3ca0fb91fb9974db709d24b7d850f1175810258f0409a0", _exports);
11519
+ _modules.set("a3ebee86ff33369e9ebc8b994d71bad32497a55433a313c426676277cb660d2f", _exports);
11299
11520
  return _exports;
11300
11521
  })();
11301
11522
 
11302
- const _m85 = _modules.get("9051bf9fc3168e24b53b16c123a42816198456846003fb49191c03a18cdab904") ?? (() => {
11523
+ const _m85 = _modules.get("e7fe5a5c6b675c6217db5f5a72d8883609e8417ee3c6f3c2184d375463f93231") ?? (() => {
11303
11524
  const { BlobByteSink, withDestination } = _m3;
11304
11525
 
11305
11526
  const { OfficeIMOError } = _m2;
@@ -11549,7 +11770,9 @@ async function writePdfDocumentTo(blocks, destination, configuration = {}) {
11549
11770
  const inputDrawing = block.drawing, capturedCaption = snapshotCaption(block.caption), alternative = graphicAlternative(block, pages.settings), alignment = graphicAlignment(block.alignment);
11550
11771
  if (capturedCaption && alternative === undefined)
11551
11772
  throw new TypeError("A captioned PDF graphic requires alternativeText and cannot be decorative.");
11552
- const drawing = await prepareDrawing(inputDrawing, pages.settings, fonts, { commands, elements: drawingElements }), caption = await prepareCaption(capturedCaption);
11773
+ const drawing = await prepareDrawing(inputDrawing, pages.settings, fonts, { commands, elements: drawingElements }, {
11774
+ images, registerImage: (name, id) => pages.registerXObject(name, id), opacity: alpha => pages.opacityState(alpha)
11775
+ }), caption = await prepareCaption(capturedCaption);
11553
11776
  commands += drawing.commands;
11554
11777
  drawingElements += drawing.elements;
11555
11778
  await flushParagraphs((caption?.height ?? 0) + pages.graphicHeight(drawing.width, drawing.height));
@@ -11589,11 +11812,11 @@ function captureTableOptions(options) {
11589
11812
  return { ...captured, ...(captured.wideTable === undefined ? {} : { wideTable: captureWideTable(captured.wideTable) }) };
11590
11813
  }
11591
11814
  const _exports = Object.freeze({ pdfTable: pdfTable, writePdfDocument: writePdfDocument, writePdfDocumentTo: writePdfDocumentTo });
11592
- _modules.set("9051bf9fc3168e24b53b16c123a42816198456846003fb49191c03a18cdab904", _exports);
11815
+ _modules.set("e7fe5a5c6b675c6217db5f5a72d8883609e8417ee3c6f3c2184d375463f93231", _exports);
11593
11816
  return _exports;
11594
11817
  })();
11595
11818
 
11596
- const _m84 = _modules.get("abe76e52ffeed11ab42477c83ddde1d1d7de28b803096436b5b23cb153af58ba") ?? (() => {
11819
+ const _m84 = _modules.get("37e4a768d57818c4335fd3d61b9b7aae633cde303e7634579655a6a3de4a86ce") ?? (() => {
11597
11820
  const { assertGroupedReportSource } = _m8;
11598
11821
 
11599
11822
  const { BlobByteSink } = _m3;
@@ -11639,7 +11862,7 @@ async function writeGroupedPdfTo(report, destination, configuration) {
11639
11862
  return writePdfDocumentTo([pdfGroupedTable(report, tableOptions)], destination, documentOptions);
11640
11863
  }
11641
11864
  const _exports = Object.freeze({ pdfGroupedTable: _m93.pdfGroupedTable, writeGroupedPdf: writeGroupedPdf, writeGroupedPdfTo: writeGroupedPdfTo });
11642
- _modules.set("abe76e52ffeed11ab42477c83ddde1d1d7de28b803096436b5b23cb153af58ba", _exports);
11865
+ _modules.set("37e4a768d57818c4335fd3d61b9b7aae633cde303e7634579655a6a3de4a86ce", _exports);
11643
11866
  return _exports;
11644
11867
  })();
11645
11868
 
@@ -11683,10 +11906,10 @@ _modules.set("3d777096288d1be55a05a80bc015d4674212e587703f25a7e7cf99a8065feb86",
11683
11906
  return _exports;
11684
11907
  })();
11685
11908
 
11686
- const _m58 = _modules.get("027aafa08408056b10d7d717d63d1f7c0ee20ecfc68213aa66feacc75ec525fe") ?? (() => {
11909
+ const _m58 = _modules.get("344fd55ffe1a37b32a8eb6a2bdaa14dff90e0fee0f37282457f9e4c3b7bce1ca") ?? (() => {
11687
11910
 
11688
11911
  const _exports = Object.freeze({ writePdf: _m59.writePdf, writePdfTo: _m59.writePdfTo, writeGroupedPdf: _m84.writeGroupedPdf, writeGroupedPdfTo: _m84.writeGroupedPdfTo, pdfGroupedTable: _m84.pdfGroupedTable, createGroupedReport: _m8.createGroupedReport, writePdfDocument: _m85.writePdfDocument, writePdfDocumentTo: _m85.writePdfDocumentTo, pdfTable: _m85.pdfTable, PdfFont: _m64.PdfFont, preflightPdfText: _m94.preflightPdfText, ExportCell: _m5.ExportCell, saveBlob: _m1.saveBlob });
11689
- _modules.set("027aafa08408056b10d7d717d63d1f7c0ee20ecfc68213aa66feacc75ec525fe", _exports);
11912
+ _modules.set("344fd55ffe1a37b32a8eb6a2bdaa14dff90e0fee0f37282457f9e4c3b7bce1ca", _exports);
11690
11913
  return _exports;
11691
11914
  })();
11692
11915
 
@@ -11894,7 +12117,7 @@ _modules.set("09d56e54463cbff00a2b225e10a62b06c881933290525c614bb5e276167e9eac",
11894
12117
  return _exports;
11895
12118
  })();
11896
12119
 
11897
- const _m96 = _modules.get("1c14f8a6ef9eb43a6a59948c7ec08999e0d5d7759b2dcc6468e6e425680d0d50") ?? (() => {
12120
+ const _m96 = _modules.get("0e36f96a408d499b21fb3e84433a016befbb873883a9da15eb4505c40aba3ba7") ?? (() => {
11898
12121
  const { ExportCell, checkAbort, inputRows } = _m1;
11899
12122
 
11900
12123
  const { canopyPivot, pivotNumberFormat } = _m97;
@@ -11933,19 +12156,29 @@ function canopyIdentityValue(value) {
11933
12156
  const original = rawIdentities.get(value);
11934
12157
  return original === undefined ? value.value : original;
11935
12158
  }
11936
- function badgeText(input) {
11937
- if (!Array.isArray(input) || input.length > 64)
11938
- throw new TypeError("Canopy cell badges must be a bounded array of { text, tone?, title? }.");
11939
- const labels = [];
12159
+ // Grids accept any number of badges. Exports keep the first labels that stay readable and fit an Excel text cell,
12160
+ // and report how many were left out instead of failing the whole document.
12161
+ const maximumBadges = 64, maximumCellText = 32767;
12162
+ function badgeText(input, text) {
12163
+ if (!Array.isArray(input))
12164
+ throw new TypeError("Canopy cell badges must be an array of { text, tone?, title? }.");
12165
+ let labels = "", kept = 0, dropped = 0;
11940
12166
  for (const badge of input) {
11941
- const text = typeof badge === "string" ? badge : badge && typeof badge === "object" ? badge.text : undefined;
11942
- if (typeof text !== "string")
11943
- throw new TypeError("Canopy cell badges must be a bounded array of { text, tone?, title? }.");
11944
- const label = text.trim();
11945
- if (label)
11946
- labels.push(label);
12167
+ const value = typeof badge === "string" ? badge : badge && typeof badge === "object" ? badge.text : undefined;
12168
+ if (typeof value !== "string")
12169
+ throw new TypeError("Canopy cell badges must be an array of { text, tone?, title? }.");
12170
+ const label = value.trim();
12171
+ if (!label)
12172
+ continue;
12173
+ const next = labels ? labels + badgeSeparator + label : label;
12174
+ if (kept >= maximumBadges || (text ? text.length + badgeSeparator.length : 0) + next.length > maximumCellText) {
12175
+ dropped++;
12176
+ continue;
12177
+ }
12178
+ labels = next;
12179
+ kept++;
11947
12180
  }
11948
- return labels.length ? labels.join(badgeSeparator) : undefined;
12181
+ return { labels: labels || undefined, dropped };
11949
12182
  }
11950
12183
  /** Map an immutable CanopyX record capture to a writer without querying the grid or retaining its body. */
11951
12184
  function createCanopyExport(capture, format, options = {}) {
@@ -12062,11 +12295,14 @@ function prepareCanopyExport(capture, format, options = {}) {
12062
12295
  // History captures already carry their frozen latest scalar (or null).
12063
12296
  // Columns read by an emitted native rule keep the raw scalar the rule compares, so the label goes to the text only.
12064
12297
  const relativeLabel = spec.kind === "text" && cell.diagnostics?.includes("relative-link") && !ruleOperands.has(spec.id);
12065
- const badges = cell.badges === undefined ? undefined : badgeText(cell.badges);
12298
+ const badged = cell.badges === undefined ? undefined : badgeText(cell.badges, cell.text), badges = badged?.labels;
12299
+ if (badged?.dropped)
12300
+ fallback({ code: "BADGES_TRUNCATED:" + badged.dropped, rowId: row.id, columnId: spec.id });
12066
12301
  const text = badges ? cell.text ? cell.text + badgeSeparator + badges : badges : cell.text;
12067
12302
  // Badges belong to the visible label, so a badged text cell exports that composed label rather than a raw/label hybrid.
12068
12303
  // Typed columns keep their scalar, and native rule operands keep the raw value the rule compares; both carry badges in the text only.
12069
- const badgedValue = !!badges && values === "raw" && !relativeLabel && spec.kind === "text" && !ruleOperands.has(spec.id);
12304
+ // A cell whose badges were all left out still exports its captured label, as it would with the badges.
12305
+ const badgedValue = (!!badges || !!badged?.dropped) && values === "raw" && !relativeLabel && spec.kind === "text" && !ruleOperands.has(spec.id);
12070
12306
  let value = values === "display" || relativeLabel || badgedValue ? text : cell.value;
12071
12307
  if (format === "xlsx" && values === "raw" && spec.kind === "datetime" && typeof value === "string")
12072
12308
  value = datetime(value, dateMode, clock);
@@ -12102,7 +12338,7 @@ function prepareCanopyExport(capture, format, options = {}) {
12102
12338
  return Object.freeze({ source, request: Object.freeze({ ...request, columns: Object.freeze(specs.map(spec => spec.input)) }), report, tones, pivot, ruleOperands });
12103
12339
  }
12104
12340
  const _exports = Object.freeze({ canopyBadgeSplit: canopyBadgeSplit, canopyIdentityValue: canopyIdentityValue, createCanopyExport: createCanopyExport, prepareCanopyExport: prepareCanopyExport });
12105
- _modules.set("1c14f8a6ef9eb43a6a59948c7ec08999e0d5d7759b2dcc6468e6e425680d0d50", _exports);
12341
+ _modules.set("0e36f96a408d499b21fb3e84433a016befbb873883a9da15eb4505c40aba3ba7", _exports);
12106
12342
  return _exports;
12107
12343
  })();
12108
12344
 
@@ -12409,7 +12645,7 @@ _modules.set("9e37b2d273c800b7b2952c298b4c50a1368f06b9192f89d6bc3097e4ccb3bcf8",
12409
12645
  return _exports;
12410
12646
  })();
12411
12647
 
12412
- const _m103 = _modules.get("74324ccf7f5e453329bc1a37bb4bf20600f9c12e02c0386f09e94c935126c014") ?? (() => {
12648
+ const _m103 = _modules.get("c94fd416cd3506a68a309631d8b299fc27e75552449835f011ae9d291367f16a") ?? (() => {
12413
12649
  const { createGroupedReport } = _m8;
12414
12650
 
12415
12651
  const { checkAbort } = _m4;
@@ -12615,7 +12851,7 @@ function canopyGrouped(source, request, options, limits, report, format) {
12615
12851
  ...(options.signal === undefined ? {} : { signal: options.signal }), ...(sourceLimits === undefined ? {} : { limits: sourceLimits }) });
12616
12852
  }
12617
12853
  const _exports = Object.freeze({ canopyGrouped: canopyGrouped });
12618
- _modules.set("74324ccf7f5e453329bc1a37bb4bf20600f9c12e02c0386f09e94c935126c014", _exports);
12854
+ _modules.set("c94fd416cd3506a68a309631d8b299fc27e75552449835f011ae9d291367f16a", _exports);
12619
12855
  return _exports;
12620
12856
  })();
12621
12857
 
@@ -12678,7 +12914,7 @@ _modules.set("99b23f94e240ecbeee81dbc96909e40786623c7df225f74ae7bd4d719b15d1e8",
12678
12914
  return _exports;
12679
12915
  })();
12680
12916
 
12681
- const _m105 = _modules.get("ff9ebe6611a20221f004b38be28c8bad2eb2498628f9c024ff76c73699b0eaca") ?? (() => {
12917
+ const _m105 = _modules.get("c5008cf665c9e1408fbcd0f1daac214a0d44d3ff5a2a5593c7be4dc2506469d8") ?? (() => {
12682
12918
  const { Workbook, addGroupedXlsx } = _m23;
12683
12919
 
12684
12920
  const { portableWorkbook } = _m53;
@@ -12735,11 +12971,11 @@ async function writeCanopyWorkbook(source, grouped, destination, options, labels
12735
12971
  });
12736
12972
  }
12737
12973
  const _exports = Object.freeze({ writeCanopyWorkbook: writeCanopyWorkbook });
12738
- _modules.set("ff9ebe6611a20221f004b38be28c8bad2eb2498628f9c024ff76c73699b0eaca", _exports);
12974
+ _modules.set("c5008cf665c9e1408fbcd0f1daac214a0d44d3ff5a2a5593c7be4dc2506469d8", _exports);
12739
12975
  return _exports;
12740
12976
  })();
12741
12977
 
12742
- const _m107 = _modules.get("42874f77dd285c63f48c430331320f2732b3df1245c086552923233647a9149d") ?? (() => {
12978
+ const _m107 = _modules.get("e22371f890c61b2c5f4f1539c53e6e49077f39eed3cbfec0904d989c57f4c48d") ?? (() => {
12743
12979
  const { ExportCell } = _m1;
12744
12980
 
12745
12981
  const { canopyBadgeSplit } = _m96;
@@ -12864,11 +13100,11 @@ function canopyPdfNumbers(sample, columns) {
12864
13100
  });
12865
13101
  }
12866
13102
  const _exports = Object.freeze({ canopyPdfNumbers: canopyPdfNumbers });
12867
- _modules.set("42874f77dd285c63f48c430331320f2732b3df1245c086552923233647a9149d", _exports);
13103
+ _modules.set("e22371f890c61b2c5f4f1539c53e6e49077f39eed3cbfec0904d989c57f4c48d", _exports);
12868
13104
  return _exports;
12869
13105
  })();
12870
13106
 
12871
- const _m106 = _modules.get("1e292c5b5b97e0a02496b29c710025ff18638d06c66533d294ba6dfea9f86f30") ?? (() => {
13107
+ const _m106 = _modules.get("1be58fa87f0eaff8548ddb4bd19a10ca4b913d22dc17764c6b589091e00a5c49") ?? (() => {
12872
13108
  const { ExportCell, NotSupportedError, OfficeIMOError } = _m1;
12873
13109
 
12874
13110
  const { inputRows, checkAbort, pause, taskYieldDue } = _m4;
@@ -12973,14 +13209,14 @@ async function withCanopyPdfLayout(source, captured, options, write) {
12973
13209
  }
12974
13210
  }
12975
13211
  const _exports = Object.freeze({ withCanopyPdfLayout: withCanopyPdfLayout });
12976
- _modules.set("1e292c5b5b97e0a02496b29c710025ff18638d06c66533d294ba6dfea9f86f30", _exports);
13212
+ _modules.set("1be58fa87f0eaff8548ddb4bd19a10ca4b913d22dc17764c6b589091e00a5c49", _exports);
12977
13213
  return _exports;
12978
13214
  })();
12979
13215
 
12980
- const _m0 = _modules.get("5ec26f81c5d8452a1fc7f672295741a5e07f235fc91ce8d73a7263a181c91027") ?? (() => {
13216
+ const _m0 = _modules.get("3ee33e684b087e413a9a9d38781f252a494e92c57c9bdf7022324580eb1e3b54") ?? (() => {
12981
13217
  const { BlobByteSink, ExportCell } = _m1;
12982
13218
 
12983
- const { notifyProgress } = _m14;
13219
+ const { notifyProgress, notifySynchronously } = _m14;
12984
13220
 
12985
13221
  const { captureFields } = _m10;
12986
13222
 
@@ -13065,7 +13301,14 @@ async function writeCanopyTo(capture, format, destination, options = {}) {
13065
13301
  freezeHeader: xlsx.sheet?.freezeHeader ?? (xlsx.sheet?.includeHeader !== false),
13066
13302
  freezeColumns: xlsx.sheet?.freezeColumns ?? (pinned ? pinned + (grouped ? 1 : 0) : 0),
13067
13303
  conditionalFormats: [...rules, ...(xlsx.sheet?.conditionalFormats ?? [])] };
13068
- const settings = { ...xlsx, ...stream, columns: source.columns, sheet, dateMode: xlsx.dateMode ?? request.timeZone, limits: formatLimits };
13304
+ // Data-cell links past Excel's per-worksheet limit keep their label; the worksheet reserves every link it cannot drop.
13305
+ const linkFallback = canopyDiagnostics(format, { ...selected, unsupportedPresentation: "text" }), onHyperlinkOverflow = xlsx.onHyperlinkOverflow;
13306
+ const settings = { ...xlsx, ...stream, columns: source.columns, sheet, dateMode: xlsx.dateMode ?? request.timeZone, limits: formatLimits,
13307
+ hyperlinkOverflow: xlsx.hyperlinkOverflow ?? "drop",
13308
+ onHyperlinkOverflow: (overflow) => {
13309
+ notifySynchronously("onHyperlinkOverflow", onHyperlinkOverflow, overflow);
13310
+ linkFallback({ code: "LINKS_TRUNCATED:" + overflow.dropped });
13311
+ } };
13069
13312
  if (grouped || about)
13070
13313
  return writeCanopyWorkbook(source, grouped, destination, settings, capturedLabels, about);
13071
13314
  return writeXlsxTo(source.rows(), destination, settings);
@@ -13118,7 +13361,7 @@ async function exportCanopy(capture, format, options = {}) {
13118
13361
  }
13119
13362
  }
13120
13363
  const _exports = Object.freeze({ createCanopyExport: _m96.createCanopyExport, ExportCell: _m5.ExportCell, PdfFont: _m64.PdfFont, writeCanopyTo: writeCanopyTo, exportCanopy: exportCanopy });
13121
- _modules.set("5ec26f81c5d8452a1fc7f672295741a5e07f235fc91ce8d73a7263a181c91027", _exports);
13364
+ _modules.set("3ee33e684b087e413a9a9d38781f252a494e92c57c9bdf7022324580eb1e3b54", _exports);
13122
13365
  return _exports;
13123
13366
  })();
13124
13367
  Object.assign(officeimo, _m0);