@evotecit/officeimo 0.1.19 → 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 (102) hide show
  1. package/README.md +44 -10
  2. package/bundles/officeimo-canopyx-adapter.js +147 -65
  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 +134 -53
  6. package/bundles/officeimo-canopyx.js +554 -234
  7. package/bundles/officeimo-canopyx.min.js +1 -1
  8. package/bundles/officeimo-canopyx.min.mjs +1 -1
  9. package/bundles/officeimo-canopyx.mjs +477 -158
  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 +418 -180
  27. package/bundles/officeimo-datatables.min.js +1 -1
  28. package/bundles/officeimo-datatables.min.mjs +1 -1
  29. package/bundles/officeimo-datatables.mjs +350 -112
  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 +136 -59
  39. package/bundles/officeimo-xlsx.min.js +1 -1
  40. package/bundles/officeimo-xlsx.min.mjs +1 -1
  41. package/bundles/officeimo-xlsx.mjs +114 -37
  42. package/bundles/officeimo.js +416 -178
  43. package/bundles/officeimo.min.js +1 -1
  44. package/bundles/officeimo.min.mjs +1 -1
  45. package/bundles/officeimo.mjs +351 -113
  46. package/dist/core/progress.js +7 -2
  47. package/dist/index.d.ts +1 -1
  48. package/dist/integrations/canopyx/index.js +13 -4
  49. package/dist/integrations/canopyx/pdf-number.js +9 -6
  50. package/dist/integrations/canopyx/rule-predicates.d.ts +1 -1
  51. package/dist/integrations/canopyx/rule-predicates.js +2 -1
  52. package/dist/integrations/canopyx/rules.d.ts +1 -1
  53. package/dist/integrations/canopyx/rules.js +11 -13
  54. package/dist/integrations/canopyx/source.js +57 -7
  55. package/dist/integrations/canopyx/tones.d.ts +10 -0
  56. package/dist/integrations/canopyx/tones.js +12 -0
  57. package/dist/integrations/canopyx/types.d.ts +8 -1
  58. package/dist/integrations/chartforgex/capture.d.ts +31 -0
  59. package/dist/integrations/chartforgex/capture.js +103 -0
  60. package/dist/integrations/chartforgex/index.d.ts +13 -0
  61. package/dist/integrations/chartforgex/index.js +88 -0
  62. package/dist/integrations/chartforgex/svg-drawing.d.ts +5 -0
  63. package/dist/integrations/chartforgex/svg-drawing.js +775 -0
  64. package/dist/integrations/chartforgex/svg-geometry.d.ts +23 -0
  65. package/dist/integrations/chartforgex/svg-geometry.js +304 -0
  66. package/dist/integrations/chartforgex/svg-image.d.ts +9 -0
  67. package/dist/integrations/chartforgex/svg-image.js +46 -0
  68. package/dist/integrations/chartforgex/svg-markup.d.ts +10 -0
  69. package/dist/integrations/chartforgex/svg-markup.js +124 -0
  70. package/dist/integrations/chartforgex/svg-paint.d.ts +16 -0
  71. package/dist/integrations/chartforgex/svg-paint.js +146 -0
  72. package/dist/integrations/chartforgex/types.d.ts +77 -0
  73. package/dist/integrations/chartforgex/types.js +1 -0
  74. package/dist/integrations/chartforgex/winansi.d.ts +4 -0
  75. package/dist/integrations/chartforgex/winansi.js +48 -0
  76. package/dist/integrations/chartforgex/workbook.d.ts +12 -0
  77. package/dist/integrations/chartforgex/workbook.js +137 -0
  78. package/dist/pdf/document-drawings.d.ts +1 -1
  79. package/dist/pdf/document-drawings.js +91 -17
  80. package/dist/pdf/document-images.d.ts +7 -1
  81. package/dist/pdf/document-images.js +59 -24
  82. package/dist/pdf/document-types.d.ts +3 -1
  83. package/dist/pdf/document.d.ts +2 -2
  84. package/dist/pdf/document.js +3 -1
  85. package/dist/pdf/drawing-types.d.ts +37 -10
  86. package/dist/pdf/font-resources.d.ts +1 -1
  87. package/dist/pdf/font-resources.js +6 -3
  88. package/dist/pdf/index.d.ts +1 -1
  89. package/dist/pdf/pages.js +15 -0
  90. package/dist/pdf/png.d.ts +11 -2
  91. package/dist/pdf/png.js +50 -23
  92. package/dist/pdf/session.js +3 -2
  93. package/dist/pdf/settings.d.ts +2 -2
  94. package/dist/pdf/settings.js +7 -3
  95. package/dist/xlsx/options.js +2 -2
  96. package/dist/xlsx/portable.js +1 -1
  97. package/dist/xlsx/styles.js +28 -18
  98. package/dist/xlsx/types.d.ts +13 -1
  99. package/dist/xlsx/workbook.js +9 -1
  100. package/dist/xlsx/worksheet.d.ts +13 -1
  101. package/dist/xlsx/worksheet.js +65 -11
  102. package/package.json +9 -2
@@ -2,15 +2,15 @@
2
2
  import { __officeimoModules } from "./officeimo.mjs";
3
3
  const _core = key => { const value = __officeimoModules[key]; if (!value) throw new Error("officeimo-canopyx-adapter.mjs needs officeimo.mjs or officeimo.min.mjs from the same OfficeIMO build, loaded first."); return value; };
4
4
  const _c0 = _core("81b3d47c02b7d8443b79e02b3cfb52032d6b73d9a3fb592b777ebe028ad0ef00");
5
- const _c1 = _core("6cfd3e806439f6301003a2d1699a74fdfa574d935550ab62b97b528728eaee1f");
5
+ const _c1 = _core("4eea31c4336d3c43bc743739843a3ef31803d8f0ed553f5645ee9de2554eb244");
6
6
  const _c2 = _core("50b3c10b690ceff693c8c5f809195ba6845b20e60f408e791a750d2ecbd5c669");
7
7
  const _c3 = _core("42faf379960e5674a6fdfa8c8fca0bb68bbd74587231248d2524d7004def3671");
8
8
  const _c4 = _core("f0627ba89e5c8fcb376ebe3ce72dcc8d68c34952981f8703e36b8bb1a9894208");
9
- const _c5 = _core("4a089607f7cbe50e13d4382d1cc4e5f6ce32c5773bbec2df84178710f54d9a38");
10
- const _c6 = _core("477ff98f49343b8ec4213008254b57a60dd42d07cb9843b3791d5e5f8e295865");
11
- const _c7 = _core("d6587a933b36ccfdba9a2a252389924ac8461f672b3a500082cceb5e53c8b0b6");
12
- const _c8 = _core("b48bcab805d4c75294dd8d8e8dc57f96d9db3f5af31a8f0ddc6562f010f566e4");
13
- const _c9 = _core("027aafa08408056b10d7d717d63d1f7c0ee20ecfc68213aa66feacc75ec525fe");
9
+ const _c5 = _core("6c92204b587bb12cfa85c60eb1fd921804dfa51304538c7be3353e2927551b02");
10
+ const _c6 = _core("fd70ccda89f27c6b874c8840ac944b3ec723dbdef3dfe7600f7bdb81f4660c96");
11
+ const _c7 = _core("edf1bf5cb6d749de0e6823397df6610a6c1cc88768898c1b4d7083ee96ef6759");
12
+ const _c8 = _core("406ac6c93ee68eae70c6f52a1e6f4c56b84f43cae12576040c766dcc5598a580");
13
+ const _c9 = _core("344fd55ffe1a37b32a8eb6a2bdaa14dff90e0fee0f37282457f9e4c3b7bce1ca");
14
14
  const _c10 = _core("0391fe35ea7d02b25804ab4d0e7543136d6bb615f368f268c74aa135f23aa6bc");
15
15
  const _c11 = _core("732224f6995c2478cf33a6ed01f3e3d3dcccb159a731d6db9280104bd5040fc5");
16
16
  const _c12 = _core("e88a83ca79cd099fc2de29689554c913c7d04b17018098f81c43044064fcdfb8");
@@ -18,7 +18,7 @@ const _c13 = _core("046b305cdccf817d847addb75a778131622de23f2840830bbe1c0c26053a
18
18
  const _c14 = _core("87c24efeaa0f1579c19afeeb4918caeb4f8f65a88d24a246e2cfd712b37dbac3");
19
19
  const _c15 = _core("c9fde2c438e186da56f740105fcd41c265fdfdd855a4f1b811d556a02387479b");
20
20
  const _c16 = _core("227236fd7adc9472e188831b8f16fdc69338c4d779f2b69a8abbd8dbfa95b585");
21
- const _c17 = _core("a10003e971cd5ec2cee127bc9b029a0aa06fe3d50112838929d7a04a55e177c0");
21
+ const _c17 = _core("d6884428c3e4d15a691ecf2523372a03b32de22a890edfbfc9961f2dc92711c2");
22
22
  const _c18 = _core("5337d1e3bd5ae0c1d10a476fcd31540d20337ccf7aa93c7e9e26c2b1a7dab92b");
23
23
  const _c19 = _core("d9c1509dff0538488752433e47cd0927ece5f93c559ad0e32dc56602dfd44596");
24
24
  const _c20 = _core("59911f0fe023545e9e97521b268551078bdc4c5f303e446a13b7d52f905e8070");
@@ -248,6 +248,23 @@ const _exports = Object.freeze({ canopyXlsxWidth: canopyXlsxWidth, canopyNumberF
248
248
  return _exports;
249
249
  })();
250
250
 
251
+ const _m19 = (() => {
252
+ /** Stable document palette for CanopyX's standard tones. Browser CSS variables and resolved cell.format are never interpreted.
253
+ * Each foreground keeps at least a 4.5:1 contrast ratio on its background. */
254
+ const canopyTonePalette = Object.freeze({
255
+ info: Object.freeze({ color: "4472C4", background: "DDEBF7", foreground: "1F4E78" }),
256
+ success: Object.freeze({ color: "70AD47", background: "E2F0D9", foreground: "375623" }),
257
+ warning: Object.freeze({ color: "FFC000", background: "FFF2CC", foreground: "7F5000" }),
258
+ danger: Object.freeze({ color: "C00000", background: "FFC7CE", foreground: "9C0006" }),
259
+ // Muted tones dim the text rather than painting the cell.
260
+ muted: Object.freeze({ color: "A6A6A6", foreground: "595959" })
261
+ });
262
+ /** Default cell presentation for a standard tone; `neutral` and unknown tones have none. */
263
+ const canopyDefaultTones = new Map(Object.entries(canopyTonePalette).map(([name, tone]) => [name, Object.freeze({ ...(tone.background === undefined ? {} : { background: tone.background }), color: tone.foreground })]));
264
+ const _exports = Object.freeze({ canopyTonePalette: canopyTonePalette, canopyDefaultTones: canopyDefaultTones });
265
+ return _exports;
266
+ })();
267
+
251
268
  const _m13 = (() => {
252
269
  const { ExportCell, checkAbort, inputRows } = _c0;
253
270
 
@@ -265,8 +282,21 @@ const { canopyDiagnostics } = _m12;
265
282
 
266
283
  const { canopyNumberFormat, canopyXlsxWidth } = _m18;
267
284
 
285
+ const { canopyDefaultTones } = _m19;
286
+
268
287
  const columnFields = ["width", "format", "wrapText", "alignment", "rowHeader", "groups"];
288
+ // Captured presentations whose cell text already carries the readable content (badge labels are appended below).
289
+ // Their visual loss is reported, never treated as an unsupported export.
290
+ const textFallbacks = new Set(["relative-link", "history-series", "badges", "custom-class", "custom-renderer"]);
291
+ const badgeSeparator = " \u00b7 ";
269
292
  const rawIdentities = new WeakMap();
293
+ // Appended badge labels, kept apart so later passes that re-render a cell's text (PDF numbers) can carry them over.
294
+ const badgeSuffixes = new WeakMap();
295
+ /** @internal The text a later pass may re-render, and the badge suffix it must append back unchanged. */
296
+ function canopyBadgeSplit(cell) {
297
+ const suffix = badgeSuffixes.get(cell), text = cell.text ?? "";
298
+ return suffix !== undefined && text.endsWith(suffix) ? { text: text.slice(0, text.length - suffix.length), suffix } : { text, suffix: "" };
299
+ }
270
300
  /** @internal Grouping uses captured identity even when a detail cell displays a relative-link label. */
271
301
  function canopyIdentityValue(value) {
272
302
  if (!(value instanceof ExportCell))
@@ -274,6 +304,30 @@ function canopyIdentityValue(value) {
274
304
  const original = rawIdentities.get(value);
275
305
  return original === undefined ? value.value : original;
276
306
  }
307
+ // Grids accept any number of badges. Exports keep the first labels that stay readable and fit an Excel text cell,
308
+ // and report how many were left out instead of failing the whole document.
309
+ const maximumBadges = 64, maximumCellText = 32767;
310
+ function badgeText(input, text) {
311
+ if (!Array.isArray(input))
312
+ throw new TypeError("Canopy cell badges must be an array of { text, tone?, title? }.");
313
+ let labels = "", kept = 0, dropped = 0;
314
+ for (const badge of input) {
315
+ const value = typeof badge === "string" ? badge : badge && typeof badge === "object" ? badge.text : undefined;
316
+ if (typeof value !== "string")
317
+ throw new TypeError("Canopy cell badges must be an array of { text, tone?, title? }.");
318
+ const label = value.trim();
319
+ if (!label)
320
+ continue;
321
+ const next = labels ? labels + badgeSeparator + label : label;
322
+ if (kept >= maximumBadges || (text ? text.length + badgeSeparator.length : 0) + next.length > maximumCellText) {
323
+ dropped++;
324
+ continue;
325
+ }
326
+ labels = next;
327
+ kept++;
328
+ }
329
+ return { labels: labels || undefined, dropped };
330
+ }
277
331
  /** Map an immutable CanopyX record capture to a writer without querying the grid or retaining its body. */
278
332
  function createCanopyExport(capture, format, options = {}) {
279
333
  return prepareCanopyExport(capture, format, options).source;
@@ -307,7 +361,7 @@ function prepareCanopyExport(capture, format, options = {}) {
307
361
  throw new TypeError("Canopy presentation diagnostics must be strings.");
308
362
  for (const code of items) {
309
363
  const diagnostic = { code, ...(rowId === undefined ? {} : { rowId }), ...(columnId === undefined ? {} : { columnId }) };
310
- (code === "relative-link" || code === "history-series" ? fallback : report)(diagnostic);
364
+ (textFallbacks.has(code) ? fallback : report)(diagnostic);
311
365
  }
312
366
  };
313
367
  if (request.presentation !== "text" && request.presentation !== "semantic")
@@ -322,11 +376,13 @@ function prepareCanopyExport(capture, format, options = {}) {
322
376
  return undefined;
323
377
  if (typeof name !== "string")
324
378
  throw new TypeError("Canopy tones must be strings.");
325
- const style = tones.get(name);
379
+ const style = tones.get(name) ?? canopyDefaultTones.get(name);
326
380
  if (!style && name !== "neutral")
327
381
  fallback({ code: "UNMAPPED_TONE:" + name, rowId, ...(columnId === undefined ? {} : { columnId }) });
328
382
  return style;
329
383
  };
384
+ // The full writer fills this with columns read by the native rules it emits, before any row is enumerated.
385
+ const ruleOperands = new Set();
330
386
  const ids = new Set();
331
387
  const specs = (pivot?.columns ?? request.columns).map(input => {
332
388
  const fields = captureFields(input, ["id", "title", "kind", "width", "pinned", "format", "wrap", "alignment", "diagnostics"]);
@@ -385,8 +441,17 @@ function prepareCanopyExport(capture, format, options = {}) {
385
441
  diagnostics(cell.diagnostics, row.id, spec.id);
386
442
  // A relative destination is navigation metadata, not the visible label.
387
443
  // History captures already carry their frozen latest scalar (or null).
388
- const relativeLabel = spec.kind === "text" && cell.diagnostics?.includes("relative-link");
389
- let value = values === "display" || relativeLabel ? cell.text : cell.value;
444
+ // Columns read by an emitted native rule keep the raw scalar the rule compares, so the label goes to the text only.
445
+ const relativeLabel = spec.kind === "text" && cell.diagnostics?.includes("relative-link") && !ruleOperands.has(spec.id);
446
+ const badged = cell.badges === undefined ? undefined : badgeText(cell.badges, cell.text), badges = badged?.labels;
447
+ if (badged?.dropped)
448
+ fallback({ code: "BADGES_TRUNCATED:" + badged.dropped, rowId: row.id, columnId: spec.id });
449
+ const text = badges ? cell.text ? cell.text + badgeSeparator + badges : badges : cell.text;
450
+ // Badges belong to the visible label, so a badged text cell exports that composed label rather than a raw/label hybrid.
451
+ // Typed columns keep their scalar, and native rule operands keep the raw value the rule compares; both carry badges in the text only.
452
+ // A cell whose badges were all left out still exports its captured label, as it would with the badges.
453
+ const badgedValue = (!!badges || !!badged?.dropped) && values === "raw" && !relativeLabel && spec.kind === "text" && !ruleOperands.has(spec.id);
454
+ let value = values === "display" || relativeLabel || badgedValue ? text : cell.value;
390
455
  if (format === "xlsx" && values === "raw" && spec.kind === "datetime" && typeof value === "string")
391
456
  value = datetime(value, dateMode, clock);
392
457
  const capturedFormat = pivot && spec.kind === "number" && cell.value !== null ? pivotNumberFormat(cell) : undefined;
@@ -401,9 +466,12 @@ function prepareCanopyExport(capture, format, options = {}) {
401
466
  if (format === "csv")
402
467
  result.push(value);
403
468
  else {
404
- const exported = new ExportCell(value, { text: cell.text, ...(presentation ? { presentation } : {}), ...(cell.link === undefined ? {} : { link: cell.link }) });
405
- if (relativeLabel)
469
+ const exported = new ExportCell(value, { text, ...(presentation ? { presentation } : {}), ...(cell.link === undefined ? {} : { link: cell.link }) });
470
+ if (relativeLabel || badgedValue)
406
471
  rawIdentities.set(exported, cell.value);
472
+ // A badge-only label is all suffix: later passes then see the captured label as empty.
473
+ if (badges)
474
+ badgeSuffixes.set(exported, cell.text ? badgeSeparator + badges : badges);
407
475
  result.push(exported);
408
476
  }
409
477
  }
@@ -415,13 +483,13 @@ function prepareCanopyExport(capture, format, options = {}) {
415
483
  if (rowCount !== null && count !== rowCount)
416
484
  throw new TypeError("Canopy capture did not produce its declared recordCount.");
417
485
  } });
418
- return Object.freeze({ source, request: Object.freeze({ ...request, columns: Object.freeze(specs.map(spec => spec.input)) }), report, tones, pivot });
486
+ return Object.freeze({ source, request: Object.freeze({ ...request, columns: Object.freeze(specs.map(spec => spec.input)) }), report, tones, pivot, ruleOperands });
419
487
  }
420
- const _exports = Object.freeze({ canopyIdentityValue: canopyIdentityValue, createCanopyExport: createCanopyExport, prepareCanopyExport: prepareCanopyExport });
488
+ const _exports = Object.freeze({ canopyBadgeSplit: canopyBadgeSplit, canopyIdentityValue: canopyIdentityValue, createCanopyExport: createCanopyExport, prepareCanopyExport: prepareCanopyExport });
421
489
  return _exports;
422
490
  })();
423
491
 
424
- const _m20 = (() => {
492
+ const _m21 = (() => {
425
493
  const { columnName, excelDate } = _c12;
426
494
 
427
495
  const { captureFields } = _c2;
@@ -429,7 +497,7 @@ const { captureFields } = _c2;
429
497
  const { datetime } = _m15;
430
498
 
431
499
  /** Compile only comparisons whose raw types and native encodings have a faithful bounded mapping. */
432
- function canopyPredicate(request, grouped, options, root, unsupported, cellTypes) {
500
+ function canopyPredicate(request, grouped, options, root, unsupported, cellTypes, operands) {
433
501
  let nodes = 0;
434
502
  const operations = { eq: "=", ne: "<>", gt: ">", ge: ">=", lt: "<", le: "<=" };
435
503
  const numeric = (value) => {
@@ -476,6 +544,7 @@ function canopyPredicate(request, grouped, options, root, unsupported, cellTypes
476
544
  const index = request.columns.findIndex(column => column.id === filter.column);
477
545
  if (index < 0)
478
546
  return unsupported("RULE_COLUMN_NOT_EXPORTED:" + filter.column);
547
+ operands?.add(filter.column);
479
548
  const column = request.columns[index], letter = columnName(index + 1 + (grouped ? 1 : 0));
480
549
  const reference = "INDEX($" + letter + ":$" + letter + ",ROW())", present = "NOT(ISBLANK(" + reference + "))";
481
550
  if (column.kind === "number")
@@ -539,24 +608,19 @@ const _exports = Object.freeze({ canopyPredicate: canopyPredicate });
539
608
  return _exports;
540
609
  })();
541
610
 
542
- const _m19 = (() => {
611
+ const _m20 = (() => {
543
612
  const { captureFields } = _c2;
544
613
 
545
- const { canopyPredicate } = _m20;
614
+ const { canopyPredicate } = _m21;
615
+
616
+ const { canopyDefaultTones, canopyTonePalette: palette } = _m19;
546
617
 
547
- // Stable document palette. Browser CSS variables and resolved cell.format are never interpreted.
548
- const palette = {
549
- info: { color: "4472C4", background: "DDEBF7", foreground: "1F4E78" },
550
- success: { color: "70AD47", background: "E2F0D9", foreground: "375623" },
551
- warning: { color: "FFC000", background: "FFF2CC", foreground: "9C6500" },
552
- danger: { color: "C00000", background: "FFC7CE", foreground: "9C0006" }
553
- };
554
618
  class UnsupportedRule extends Error {
555
619
  }
556
620
  const unsupported = (message) => { throw new UnsupportedRule(message); };
557
621
  /** Compile declarations in source order, then emit native target/aspect priorities.
558
622
  * Data-column selectors let grouped writers exclude generated headings, subtotals and grand totals. */
559
- function canopyRules(request, format, grouped, tones, report, options = {}, cellTypes) {
623
+ function canopyRules(request, format, grouped, tones, report, options = {}, cellTypes, operands) {
560
624
  if (request.formatRules === undefined || format === "csv")
561
625
  return [];
562
626
  if (!Array.isArray(request.formatRules) || request.formatRules.length > 1000)
@@ -595,7 +659,7 @@ function canopyRules(request, format, grouped, tones, report, options = {}, cell
595
659
  }
596
660
  const priorStops = [];
597
661
  const priorRows = [], priorCells = new Map();
598
- const requiredCells = new Map();
662
+ const requiredCells = new Map(), emittedOperands = new Set();
599
663
  const column = (id) => {
600
664
  const index = columns.findIndex(column => column.id === id);
601
665
  if (index < 0)
@@ -613,8 +677,7 @@ function canopyRules(request, format, grouped, tones, report, options = {}, cell
613
677
  return value;
614
678
  };
615
679
  const style = (name) => {
616
- const defaults = palette[name];
617
- const mapping = tones.get(name) ?? (defaults ? { background: defaults.background, color: defaults.foreground } : undefined);
680
+ const mapping = tones.get(name) ?? canopyDefaultTones.get(name);
618
681
  if (!mapping)
619
682
  return unsupported("UNMAPPED_RULE_TONE:" + name);
620
683
  if ("alignment" in mapping || "wrapText" in mapping)
@@ -687,8 +750,8 @@ function canopyRules(request, format, grouped, tones, report, options = {}, cell
687
750
  const range = rule.target === "row" ? { column: columns[0].id, through: columns.at(-1).id } : { column: rule.column };
688
751
  if (rule.column !== undefined)
689
752
  column(rule.column);
690
- const ruleCells = new Map();
691
- const ownPredicate = canopyPredicate(request, grouped, options, rule.when, unsupported, ruleCells);
753
+ const ruleCells = new Map(), ruleOperands = new Set();
754
+ const ownPredicate = canopyPredicate(request, grouped, options, rule.when, unsupported, ruleCells, ruleOperands);
692
755
  const reachable = priorStops.length ? "AND(" + ownPredicate + ",NOT(OR(" + priorStops.join(",") + ")))" : ownPredicate;
693
756
  const previous = rule.target === "row" ? priorRows : priorCells.get(rule.column) ?? [];
694
757
  const formula = previous.length ? "AND(" + reachable + ",NOT(OR(" + previous.join(",") + ")))" : reachable;
@@ -700,6 +763,8 @@ function canopyRules(request, format, grouped, tones, report, options = {}, cell
700
763
  priorCells.set(rule.column, previous);
701
764
  for (const [column, type] of ruleCells)
702
765
  requiredCells.set(column, type);
766
+ for (const id of ruleOperands)
767
+ emittedOperands.add(id);
703
768
  // A matched declaration still stops the row when an earlier tone on that target already won.
704
769
  if (rule.stopIfTrue)
705
770
  priorStops.push(ownPredicate);
@@ -715,6 +780,9 @@ function canopyRules(request, format, grouped, tones, report, options = {}, cell
715
780
  }
716
781
  for (const [column, type] of requiredCells)
717
782
  cellTypes?.set(column, type);
783
+ // Only emitted rules read raw cells; a rejected comparison leaves its column free to carry badge labels.
784
+ for (const id of emittedOperands)
785
+ operands?.add(id);
718
786
  // Canopy paints cell visuals/tones over the row tint. Build masks before changing native priority order.
719
787
  return Object.freeze([...visuals, ...cells, ...rows]);
720
788
  }
@@ -722,7 +790,7 @@ const _exports = Object.freeze({ canopyRules: canopyRules });
722
790
  return _exports;
723
791
  })();
724
792
 
725
- const _m22 = (() => {
793
+ const _m23 = (() => {
726
794
  const { createGroupedReport } = _c13;
727
795
 
728
796
  const { checkAbort } = _c14;
@@ -931,7 +999,7 @@ const _exports = Object.freeze({ canopyGrouped: canopyGrouped });
931
999
  return _exports;
932
1000
  })();
933
1001
 
934
- const _m26 = (() => {
1002
+ const _m27 = (() => {
935
1003
  const { cellText } = _c12;
936
1004
 
937
1005
  const { cleanXml } = _c16;
@@ -989,7 +1057,7 @@ const _exports = Object.freeze({ canopyAbout: canopyAbout });
989
1057
  return _exports;
990
1058
  })();
991
1059
 
992
- const _m28 = (() => {
1060
+ const _m29 = (() => {
993
1061
  const { Workbook, addGroupedXlsx } = _c7;
994
1062
 
995
1063
  const { portableWorkbook } = _c17;
@@ -1049,9 +1117,11 @@ const _exports = Object.freeze({ writeCanopyWorkbook: writeCanopyWorkbook });
1049
1117
  return _exports;
1050
1118
  })();
1051
1119
 
1052
- const _m34 = (() => {
1120
+ const _m35 = (() => {
1053
1121
  const { ExportCell } = _c0;
1054
1122
 
1123
+ const { canopyBadgeSplit } = _m13;
1124
+
1055
1125
  /** Fixed numeric formats affect PDF text, not the frozen numeric value used by other writers. */
1056
1126
  function numericProfile(format) {
1057
1127
  // No declared precision: whole values (including counts) stay whole.
@@ -1099,11 +1169,11 @@ function documentDecimal(sample, columns) {
1099
1169
  const profile = numericProfile(cell.presentation?.numberFormat ?? column.format);
1100
1170
  if (!profile)
1101
1171
  continue;
1102
- const captured = capturedNumber(cell.text ?? "", profile);
1172
+ const label = canopyBadgeSplit(cell).text, captured = capturedNumber(label, profile);
1103
1173
  if (!captured)
1104
1174
  continue;
1105
1175
  // A literal percent label is a culture signal without requesting numeric scaling.
1106
- const percentageSignal = profile.percent || profile.prefix.includes("%") || profile.suffix.includes("%") || (cell.text ?? "").includes("%");
1176
+ const percentageSignal = profile.percent || profile.prefix.includes("%") || profile.suffix.includes("%") || label.includes("%");
1107
1177
  if (percentageSignal !== percent)
1108
1178
  continue;
1109
1179
  const match = /([.,])(\d+)$/.exec(captured.number.trimEnd());
@@ -1130,10 +1200,12 @@ function canopyPdfNumbers(sample, columns) {
1130
1200
  return value;
1131
1201
  const format = value.presentation?.numberFormat ?? columns[index].format;
1132
1202
  let profile = numericProfile(format);
1133
- if (!profile || value.text === "")
1203
+ // Badge labels are not part of the number: format the captured label alone, then append them unchanged.
1204
+ const { text: label, suffix: badges } = canopyBadgeSplit(value);
1205
+ if (!profile || label === "")
1134
1206
  return value;
1135
- const captured = capturedNumber(value.text ?? "", profile);
1136
- if (value.text && !captured)
1207
+ const captured = capturedNumber(label, profile);
1208
+ if (label && !captured)
1137
1209
  return value;
1138
1210
  // Undeclared formats normalize only plain numeric labels; a decoration
1139
1211
  // alone does not declare how the raw value was transformed for display.
@@ -1165,7 +1237,7 @@ function canopyPdfNumbers(sample, columns) {
1165
1237
  let suffix = captured?.suffix || profile.suffix;
1166
1238
  if (profile.percent && !profile.suffix)
1167
1239
  suffix = suffix.replace(/%/g, "");
1168
- return new ExportCell(value.value, { text: leadingSign + prefix + formatted + (profile.percent ? "%" : "") + suffix,
1240
+ return new ExportCell(value.value, { text: leadingSign + prefix + formatted + (profile.percent ? "%" : "") + suffix + badges,
1169
1241
  ...(value.presentation ? { presentation: value.presentation } : {}), ...(value.link ? { link: value.link } : {}) });
1170
1242
  });
1171
1243
  }
@@ -1173,7 +1245,7 @@ const _exports = Object.freeze({ canopyPdfNumbers: canopyPdfNumbers });
1173
1245
  return _exports;
1174
1246
  })();
1175
1247
 
1176
- const _m31 = (() => {
1248
+ const _m32 = (() => {
1177
1249
  const { ExportCell, NotSupportedError, OfficeIMOError } = _c0;
1178
1250
 
1179
1251
  const { inputRows, checkAbort, pause, taskYieldDue } = _c14;
@@ -1184,7 +1256,7 @@ const { resolveScalar, selectFont, validateFonts } = _c20;
1184
1256
 
1185
1257
  const { settings } = _c5;
1186
1258
 
1187
- const { canopyPdfNumbers } = _m34;
1259
+ const { canopyPdfNumbers } = _m35;
1188
1260
 
1189
1261
  /** A bounded lookahead is replayed once; no second capture, full-dataset copy or smaller font is needed. */
1190
1262
  async function withCanopyPdfLayout(source, captured, options, write) {
@@ -1284,7 +1356,7 @@ return _exports;
1284
1356
  const _m0 = (() => {
1285
1357
  const { BlobByteSink, ExportCell } = _c0;
1286
1358
 
1287
- const { notifyProgress } = _c1;
1359
+ const { notifyProgress, notifySynchronously } = _c1;
1288
1360
 
1289
1361
  const { captureFields } = _c2;
1290
1362
 
@@ -1302,15 +1374,15 @@ const { prepareCanopyExport } = _m13;
1302
1374
 
1303
1375
  const { canopyPins } = _m18;
1304
1376
 
1305
- const { canopyRules } = _m19;
1377
+ const { canopyRules } = _m20;
1306
1378
 
1307
- const { canopyGrouped } = _m22;
1379
+ const { canopyGrouped } = _m23;
1308
1380
 
1309
- const { canopyAbout } = _m26;
1381
+ const { canopyAbout } = _m27;
1310
1382
 
1311
- const { writeCanopyWorkbook } = _m28;
1383
+ const { writeCanopyWorkbook } = _m29;
1312
1384
 
1313
- const { withCanopyPdfLayout } = _m31;
1385
+ const { withCanopyPdfLayout } = _m32;
1314
1386
 
1315
1387
 
1316
1388
 
@@ -1318,6 +1390,7 @@ const { withCanopyPdfLayout } = _m31;
1318
1390
 
1319
1391
 
1320
1392
 
1393
+ const canopyHeaderFill = "E7EDF5", canopyHeaderBorder = Object.freeze({ bottom: Object.freeze({ style: "thin", color: "A6B4C8" }) });
1321
1394
  /** Write a captured CanopyX grid to a caller-owned destination; partial bytes remain caller-owned on failure. */
1322
1395
  async function writeCanopyTo(capture, format, destination, options = {}) {
1323
1396
  const selected = captureFields(options, ["tones", "columnOptions", "unsupportedPresentation", "datetime", "xlsx", "csv", "pdf", "signal", "onDiagnostic", "limits", "onProgress", "grouped", "about"]);
@@ -1357,17 +1430,25 @@ async function writeCanopyTo(capture, format, destination, options = {}) {
1357
1430
  const stream = { ...(signal ? { signal } : {}), ...progress };
1358
1431
  if (format === "xlsx") {
1359
1432
  const formatLimits = mergeAdapterLimits(xlsx.limits, limits), grouped = pivot ? undefined : canopyGrouped(source, request, { ...selected, xlsx }, formatLimits, report, format);
1360
- const pinned = canopyPins(request.columns, report), rules = canopyRules(request, format, grouped !== undefined, tones, report, { ...selected, xlsx }, ruleCellTypes);
1433
+ const pinned = canopyPins(request.columns, report), rules = canopyRules(request, format, grouped !== undefined, tones, report, { ...selected, xlsx }, ruleCellTypes, prepared.ruleOperands);
1361
1434
  if (pivot && (xlsx.sheet?.rowOutline !== undefined || xlsx.sheet?.columnOutlines !== undefined || xlsx.sheet?.maxOutlineLevel !== undefined ||
1362
1435
  xlsx.sheet?.outlineSummaryBelow !== undefined || xlsx.sheet?.outlineSummaryRight !== undefined || xlsx.sheet?.table !== undefined || xlsx.sheet?.footer !== undefined))
1363
1436
  throw new TypeError("Captured pivot metadata owns outlines and totals; worksheet overrides cannot regroup or recalculate it.");
1364
1437
  if (pivot && xlsx.cellValueWriters !== undefined)
1365
1438
  throw new TypeError("Captured pivot exports use frozen values rather than custom cellValueWriters.");
1366
- const sheet = { ...xlsx.sheet, ...(pivot?.sheet ?? {}), ...(pivot ? { autoFilter: false } : {}),
1439
+ // The header matches the PDF table heading: shaded, bold, wrapped and ruled off from the data.
1440
+ const sheet = { headerFill: canopyHeaderFill, headerBorder: canopyHeaderBorder, headerWrap: true, ...xlsx.sheet, ...(pivot?.sheet ?? {}), ...(pivot ? { autoFilter: false } : {}),
1367
1441
  freezeHeader: xlsx.sheet?.freezeHeader ?? (xlsx.sheet?.includeHeader !== false),
1368
1442
  freezeColumns: xlsx.sheet?.freezeColumns ?? (pinned ? pinned + (grouped ? 1 : 0) : 0),
1369
1443
  conditionalFormats: [...rules, ...(xlsx.sheet?.conditionalFormats ?? [])] };
1370
- const settings = { ...xlsx, ...stream, columns: source.columns, sheet, dateMode: xlsx.dateMode ?? request.timeZone, limits: formatLimits };
1444
+ // Data-cell links past Excel's per-worksheet limit keep their label; the worksheet reserves every link it cannot drop.
1445
+ const linkFallback = canopyDiagnostics(format, { ...selected, unsupportedPresentation: "text" }), onHyperlinkOverflow = xlsx.onHyperlinkOverflow;
1446
+ const settings = { ...xlsx, ...stream, columns: source.columns, sheet, dateMode: xlsx.dateMode ?? request.timeZone, limits: formatLimits,
1447
+ hyperlinkOverflow: xlsx.hyperlinkOverflow ?? "drop",
1448
+ onHyperlinkOverflow: (overflow) => {
1449
+ notifySynchronously("onHyperlinkOverflow", onHyperlinkOverflow, overflow);
1450
+ linkFallback({ code: "LINKS_TRUNCATED:" + overflow.dropped });
1451
+ } };
1371
1452
  if (grouped || about)
1372
1453
  return writeCanopyWorkbook(source, grouped, destination, settings, capturedLabels, about);
1373
1454
  return writeXlsxTo(source.rows(), destination, settings);