@evotecit/officeimo 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (261) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1222 -2
  3. package/bundles/officeimo-canopyx.js +11741 -0
  4. package/bundles/officeimo-canopyx.mjs +11639 -0
  5. package/bundles/officeimo-csv.js +1264 -0
  6. package/bundles/officeimo-csv.mjs +1239 -0
  7. package/bundles/officeimo-datatables.js +12018 -0
  8. package/bundles/officeimo-datatables.mjs +11915 -0
  9. package/bundles/officeimo-execution.js +1513 -0
  10. package/bundles/officeimo-execution.mjs +1489 -0
  11. package/bundles/officeimo-pdf.js +7009 -0
  12. package/bundles/officeimo-pdf.mjs +6946 -0
  13. package/bundles/officeimo-xlsx.js +5344 -0
  14. package/bundles/officeimo-xlsx.mjs +5290 -0
  15. package/bundles/officeimo.js +11468 -0
  16. package/bundles/officeimo.mjs +11369 -0
  17. package/dist/core/dates.d.ts +1 -0
  18. package/dist/core/dates.js +16 -0
  19. package/dist/core/errors.d.ts +12 -0
  20. package/dist/core/errors.js +31 -0
  21. package/dist/core/grouped-report.d.ts +87 -0
  22. package/dist/core/grouped-report.js +252 -0
  23. package/dist/core/index.d.ts +74 -0
  24. package/dist/core/index.js +37 -0
  25. package/dist/core/iteration.d.ts +7 -0
  26. package/dist/core/iteration.js +149 -0
  27. package/dist/core/limits.d.ts +7 -0
  28. package/dist/core/limits.js +56 -0
  29. package/dist/core/links.d.ts +5 -0
  30. package/dist/core/links.js +14 -0
  31. package/dist/core/presentation.d.ts +29 -0
  32. package/dist/core/presentation.js +59 -0
  33. package/dist/core/progress.d.ts +1 -0
  34. package/dist/core/progress.js +10 -0
  35. package/dist/core/sinks.d.ts +33 -0
  36. package/dist/core/sinks.js +102 -0
  37. package/dist/core/table.d.ts +8 -0
  38. package/dist/core/table.js +1 -0
  39. package/dist/core/value-text.d.ts +7 -0
  40. package/dist/core/value-text.js +13 -0
  41. package/dist/csv/index.d.ts +44 -0
  42. package/dist/csv/index.js +133 -0
  43. package/dist/csv/options.d.ts +1 -0
  44. package/dist/csv/options.js +8 -0
  45. package/dist/csv/structured-rows.d.ts +3 -0
  46. package/dist/csv/structured-rows.js +15 -0
  47. package/dist/execution/host.d.ts +5 -0
  48. package/dist/execution/host.js +164 -0
  49. package/dist/execution/index.d.ts +3 -0
  50. package/dist/execution/index.js +2 -0
  51. package/dist/execution/protocol.d.ts +48 -0
  52. package/dist/execution/protocol.js +173 -0
  53. package/dist/execution/types.d.ts +42 -0
  54. package/dist/execution/types.js +1 -0
  55. package/dist/execution/worker.d.ts +3 -0
  56. package/dist/execution/worker.js +147 -0
  57. package/dist/index.d.ts +32 -0
  58. package/dist/index.js +14 -0
  59. package/dist/integrations/canopyx/dates.d.ts +1 -0
  60. package/dist/integrations/canopyx/dates.js +34 -0
  61. package/dist/integrations/canopyx/index.d.ts +10 -0
  62. package/dist/integrations/canopyx/index.js +45 -0
  63. package/dist/integrations/canopyx/source.d.ts +3 -0
  64. package/dist/integrations/canopyx/source.js +122 -0
  65. package/dist/integrations/canopyx/types.d.ts +83 -0
  66. package/dist/integrations/canopyx/types.js +1 -0
  67. package/dist/integrations/datatables/api.d.ts +1 -0
  68. package/dist/integrations/datatables/api.js +27 -0
  69. package/dist/integrations/datatables/headings.d.ts +1 -0
  70. package/dist/integrations/datatables/headings.js +65 -0
  71. package/dist/integrations/datatables/index.d.ts +12 -0
  72. package/dist/integrations/datatables/index.js +167 -0
  73. package/dist/integrations/datatables/snapshot.d.ts +3 -0
  74. package/dist/integrations/datatables/snapshot.js +206 -0
  75. package/dist/integrations/datatables/types.d.ts +98 -0
  76. package/dist/integrations/datatables/types.js +1 -0
  77. package/dist/integrations/options.d.ts +13 -0
  78. package/dist/integrations/options.js +34 -0
  79. package/dist/internal/capture.d.ts +4 -0
  80. package/dist/internal/capture.js +14 -0
  81. package/dist/internal/columns.d.ts +27 -0
  82. package/dist/internal/columns.js +1 -0
  83. package/dist/internal/crc32.d.ts +6 -0
  84. package/dist/internal/crc32.js +17 -0
  85. package/dist/internal/export-values.d.ts +3 -0
  86. package/dist/internal/export-values.js +14 -0
  87. package/dist/internal/rows.d.ts +6 -0
  88. package/dist/internal/rows.js +77 -0
  89. package/dist/internal/table-spans.d.ts +11 -0
  90. package/dist/internal/table-spans.js +58 -0
  91. package/dist/internal/totals.d.ts +15 -0
  92. package/dist/internal/totals.js +42 -0
  93. package/dist/opc/index.d.ts +67 -0
  94. package/dist/opc/index.js +233 -0
  95. package/dist/opc/properties.d.ts +15 -0
  96. package/dist/opc/properties.js +18 -0
  97. package/dist/opc/uri.d.ts +5 -0
  98. package/dist/opc/uri.js +41 -0
  99. package/dist/pdf/annotations.d.ts +1 -0
  100. package/dist/pdf/annotations.js +38 -0
  101. package/dist/pdf/binary.d.ts +6 -0
  102. package/dist/pdf/binary.js +24 -0
  103. package/dist/pdf/document-drawings.d.ts +15 -0
  104. package/dist/pdf/document-drawings.js +237 -0
  105. package/dist/pdf/document-grouped.d.ts +1 -0
  106. package/dist/pdf/document-grouped.js +244 -0
  107. package/dist/pdf/document-images.d.ts +19 -0
  108. package/dist/pdf/document-images.js +125 -0
  109. package/dist/pdf/document-types.d.ts +160 -0
  110. package/dist/pdf/document-types.js +1 -0
  111. package/dist/pdf/document-vectors.d.ts +11 -0
  112. package/dist/pdf/document-vectors.js +77 -0
  113. package/dist/pdf/document.d.ts +9 -0
  114. package/dist/pdf/document.js +270 -0
  115. package/dist/pdf/drawing-types.d.ts +53 -0
  116. package/dist/pdf/drawing-types.js +1 -0
  117. package/dist/pdf/font-resources.d.ts +43 -0
  118. package/dist/pdf/font-resources.js +202 -0
  119. package/dist/pdf/font-support.d.ts +1 -0
  120. package/dist/pdf/font-support.js +60 -0
  121. package/dist/pdf/font.d.ts +17 -0
  122. package/dist/pdf/font.js +56 -0
  123. package/dist/pdf/grouped-table.d.ts +6 -0
  124. package/dist/pdf/grouped-table.js +40 -0
  125. package/dist/pdf/grouped-types.d.ts +34 -0
  126. package/dist/pdf/grouped-types.js +1 -0
  127. package/dist/pdf/grouped.d.ts +10 -0
  128. package/dist/pdf/grouped.js +37 -0
  129. package/dist/pdf/index.d.ts +22 -0
  130. package/dist/pdf/index.js +8 -0
  131. package/dist/pdf/inline-text.d.ts +30 -0
  132. package/dist/pdf/inline-text.js +183 -0
  133. package/dist/pdf/inline-types.d.ts +15 -0
  134. package/dist/pdf/inline-types.js +1 -0
  135. package/dist/pdf/list-layout.d.ts +6 -0
  136. package/dist/pdf/list-layout.js +49 -0
  137. package/dist/pdf/objects.d.ts +2 -0
  138. package/dist/pdf/objects.js +320 -0
  139. package/dist/pdf/outlines.d.ts +1 -0
  140. package/dist/pdf/outlines.js +55 -0
  141. package/dist/pdf/page-context.d.ts +1 -0
  142. package/dist/pdf/page-context.js +12 -0
  143. package/dist/pdf/pages.d.ts +1 -0
  144. package/dist/pdf/pages.js +678 -0
  145. package/dist/pdf/paragraph-layout.d.ts +21 -0
  146. package/dist/pdf/paragraph-layout.js +71 -0
  147. package/dist/pdf/paragraph-styles.d.ts +1 -0
  148. package/dist/pdf/paragraph-styles.js +66 -0
  149. package/dist/pdf/png.d.ts +9 -0
  150. package/dist/pdf/png.js +259 -0
  151. package/dist/pdf/preflight.d.ts +7 -0
  152. package/dist/pdf/preflight.js +32 -0
  153. package/dist/pdf/presentation-settings.d.ts +5 -0
  154. package/dist/pdf/presentation-settings.js +28 -0
  155. package/dist/pdf/providers/harfbuzz.d.ts +60 -0
  156. package/dist/pdf/providers/harfbuzz.js +112 -0
  157. package/dist/pdf/providers/unicode13-profile.d.ts +2 -0
  158. package/dist/pdf/providers/unicode13-profile.js +115 -0
  159. package/dist/pdf/section-types.d.ts +15 -0
  160. package/dist/pdf/section-types.js +40 -0
  161. package/dist/pdf/session.d.ts +25 -0
  162. package/dist/pdf/session.js +55 -0
  163. package/dist/pdf/settings.d.ts +17 -0
  164. package/dist/pdf/settings.js +196 -0
  165. package/dist/pdf/shaped-text.d.ts +5 -0
  166. package/dist/pdf/shaped-text.js +205 -0
  167. package/dist/pdf/standard-widths.d.ts +1 -0
  168. package/dist/pdf/standard-widths.js +317 -0
  169. package/dist/pdf/structure-parent-tree.d.ts +1 -0
  170. package/dist/pdf/structure-parent-tree.js +57 -0
  171. package/dist/pdf/structure.d.ts +6 -0
  172. package/dist/pdf/structure.js +302 -0
  173. package/dist/pdf/table-band-flow.d.ts +34 -0
  174. package/dist/pdf/table-band-flow.js +129 -0
  175. package/dist/pdf/table-band-plan.d.ts +10 -0
  176. package/dist/pdf/table-band-plan.js +83 -0
  177. package/dist/pdf/table-layout.d.ts +75 -0
  178. package/dist/pdf/table-layout.js +217 -0
  179. package/dist/pdf/table-structure.d.ts +1 -0
  180. package/dist/pdf/table-structure.js +108 -0
  181. package/dist/pdf/text-shaping-types.d.ts +39 -0
  182. package/dist/pdf/text-shaping-types.js +1 -0
  183. package/dist/pdf/text.d.ts +13 -0
  184. package/dist/pdf/text.js +101 -0
  185. package/dist/pdf/truetype-subset.d.ts +5 -0
  186. package/dist/pdf/truetype-subset.js +217 -0
  187. package/dist/pdf/truetype.d.ts +1 -0
  188. package/dist/pdf/truetype.js +235 -0
  189. package/dist/pdf/types.d.ts +171 -0
  190. package/dist/pdf/types.js +1 -0
  191. package/dist/pdf/write.d.ts +6 -0
  192. package/dist/pdf/write.js +57 -0
  193. package/dist/pdf/xref.d.ts +1 -0
  194. package/dist/pdf/xref.js +30 -0
  195. package/dist/xlsx/attachments.d.ts +30 -0
  196. package/dist/xlsx/attachments.js +67 -0
  197. package/dist/xlsx/chart-bindings.d.ts +1 -0
  198. package/dist/xlsx/chart-bindings.js +122 -0
  199. package/dist/xlsx/chart-types.d.ts +73 -0
  200. package/dist/xlsx/chart-types.js +1 -0
  201. package/dist/xlsx/chart-xml.d.ts +2 -0
  202. package/dist/xlsx/chart-xml.js +103 -0
  203. package/dist/xlsx/charts.d.ts +1 -0
  204. package/dist/xlsx/charts.js +159 -0
  205. package/dist/xlsx/conditional-formatting.d.ts +1 -0
  206. package/dist/xlsx/conditional-formatting.js +158 -0
  207. package/dist/xlsx/conditional-types.d.ts +64 -0
  208. package/dist/xlsx/conditional-types.js +1 -0
  209. package/dist/xlsx/data-row-ranges.d.ts +5 -0
  210. package/dist/xlsx/data-row-ranges.js +39 -0
  211. package/dist/xlsx/differential-styles.d.ts +1 -0
  212. package/dist/xlsx/differential-styles.js +102 -0
  213. package/dist/xlsx/formula.d.ts +8 -0
  214. package/dist/xlsx/formula.js +104 -0
  215. package/dist/xlsx/grouped-layout.d.ts +61 -0
  216. package/dist/xlsx/grouped-layout.js +79 -0
  217. package/dist/xlsx/grouped.d.ts +16 -0
  218. package/dist/xlsx/grouped.js +161 -0
  219. package/dist/xlsx/index.d.ts +24 -0
  220. package/dist/xlsx/index.js +10 -0
  221. package/dist/xlsx/layout.d.ts +1 -0
  222. package/dist/xlsx/layout.js +186 -0
  223. package/dist/xlsx/options.d.ts +1 -0
  224. package/dist/xlsx/options.js +16 -0
  225. package/dist/xlsx/portable.d.ts +27 -0
  226. package/dist/xlsx/portable.js +44 -0
  227. package/dist/xlsx/preservation.d.ts +1 -0
  228. package/dist/xlsx/preservation.js +60 -0
  229. package/dist/xlsx/ranges.d.ts +1 -0
  230. package/dist/xlsx/ranges.js +24 -0
  231. package/dist/xlsx/regions.d.ts +1 -0
  232. package/dist/xlsx/regions.js +97 -0
  233. package/dist/xlsx/structured-rows.d.ts +11 -0
  234. package/dist/xlsx/structured-rows.js +28 -0
  235. package/dist/xlsx/style-xml.d.ts +1 -0
  236. package/dist/xlsx/style-xml.js +6 -0
  237. package/dist/xlsx/styles.d.ts +70 -0
  238. package/dist/xlsx/styles.js +203 -0
  239. package/dist/xlsx/table.d.ts +12 -0
  240. package/dist/xlsx/table.js +35 -0
  241. package/dist/xlsx/types.d.ts +180 -0
  242. package/dist/xlsx/types.js +1 -0
  243. package/dist/xlsx/validation-types.d.ts +18 -0
  244. package/dist/xlsx/validation-types.js +1 -0
  245. package/dist/xlsx/validation.d.ts +1 -0
  246. package/dist/xlsx/validation.js +92 -0
  247. package/dist/xlsx/values.d.ts +13 -0
  248. package/dist/xlsx/values.js +87 -0
  249. package/dist/xlsx/workbook.d.ts +50 -0
  250. package/dist/xlsx/workbook.js +452 -0
  251. package/dist/xlsx/worksheet.d.ts +71 -0
  252. package/dist/xlsx/worksheet.js +700 -0
  253. package/dist/xlsx/write.d.ts +15 -0
  254. package/dist/xlsx/write.js +47 -0
  255. package/dist/xml/index.d.ts +24 -0
  256. package/dist/xml/index.js +74 -0
  257. package/dist/zip/entry.d.ts +39 -0
  258. package/dist/zip/entry.js +122 -0
  259. package/dist/zip/index.d.ts +44 -0
  260. package/dist/zip/index.js +248 -0
  261. package/package.json +104 -4
@@ -0,0 +1,1264 @@
1
+ // Generated by OfficeIMO.JavaScript/scripts/bundles.mjs from tsc output. MIT.
2
+ (function (root) {
3
+ "use strict";
4
+ const officeimo = root.OfficeIMO || (root.OfficeIMO = {});
5
+ const cacheKey = Symbol.for("@evotecit/officeimo/modules");
6
+ const _modules = officeimo[cacheKey] || new Map();
7
+ if (!officeimo[cacheKey]) Object.defineProperty(officeimo, cacheKey, { value: _modules });
8
+ const _m1 = _modules.get("87c24efeaa0f1579c19afeeb4918caeb4f8f65a88d24a246e2cfd712b37dbac3") ?? (() => {
9
+ function checkAbort(signal) {
10
+ if (signal?.aborted)
11
+ throw signal.reason;
12
+ }
13
+ /** Race a pending producer or sink operation without leaving abort listeners behind. */
14
+ function withAbort(promise, signal) {
15
+ if (!signal)
16
+ return Promise.resolve(promise);
17
+ return new Promise((resolve, reject) => {
18
+ const cleanup = () => signal.removeEventListener("abort", abort);
19
+ const abort = () => { cleanup(); reject(signal.reason); };
20
+ signal.addEventListener("abort", abort, { once: true });
21
+ Promise.resolve(promise).then(value => { cleanup(); resolve(value); }, error => { cleanup(); reject(error); });
22
+ if (signal.aborted)
23
+ abort();
24
+ });
25
+ }
26
+ /** Consume once; return the iterator on failure or cancellation. Pass the signal to I/O producers too. */
27
+ async function* inputRows(input, signal) {
28
+ checkAbort(signal);
29
+ const iterator = input?.[Symbol.asyncIterator]?.() ?? input?.[Symbol.iterator]?.();
30
+ if (!iterator)
31
+ throw new TypeError("Rows must be a synchronous or asynchronous iterable.");
32
+ let done = false, failed = false;
33
+ try {
34
+ while (true) {
35
+ checkAbort(signal);
36
+ const item = await withAbort(Promise.resolve(iterator.next()), signal);
37
+ checkAbort(signal);
38
+ if (item.done) {
39
+ done = true;
40
+ return;
41
+ }
42
+ yield item.value;
43
+ }
44
+ }
45
+ catch (error) {
46
+ failed = true;
47
+ throw error;
48
+ }
49
+ finally {
50
+ if (!done && iterator.return) {
51
+ try {
52
+ const returned = iterator.return();
53
+ if (signal?.aborted || failed)
54
+ Promise.resolve(returned).catch(() => { });
55
+ else
56
+ await withAbort(Promise.resolve(returned), signal);
57
+ }
58
+ catch (error) {
59
+ if (!signal?.aborted && !failed)
60
+ throw error;
61
+ }
62
+ }
63
+ }
64
+ }
65
+ const rowConsumers = new WeakMap();
66
+ /** @internal Keep bounded pages as ordinary async rows, with direct batch consumption for owned writers. */
67
+ function rowsFromBatches(batches) {
68
+ let consumed = false;
69
+ const claim = () => { if (consumed)
70
+ throw new TypeError("A row source can be consumed only once."); consumed = true; };
71
+ const rows = { [Symbol.asyncIterator]() { claim(); return iterate(); } };
72
+ async function* iterate() { for await (const batch of inputRows(batches))
73
+ yield* batch; }
74
+ rowConsumers.set(rows, (signal, accept) => {
75
+ claim();
76
+ return consumeRows(batches, signal, batch => consumeRows(batch, signal, accept));
77
+ });
78
+ return rows;
79
+ }
80
+ /** @internal Concatenate headings, body and footer without another per-row async delegation. */
81
+ function concatRows(...sources) {
82
+ const rows = { async *[Symbol.asyncIterator]() { for (const source of sources)
83
+ yield* source; } };
84
+ rowConsumers.set(rows, async (signal, accept) => { for (const source of sources)
85
+ await consumeRows(source, signal, accept); });
86
+ return rows;
87
+ }
88
+ /** @internal Consume synchronous work without an async-generator and per-row Promise.
89
+ * Async producers, promised values and destination backpressure keep the same cancellation/return contract. */
90
+ async function consumeRows(input, signal, accept) {
91
+ checkAbort(signal);
92
+ const consume = rowConsumers.get(input);
93
+ if (consume)
94
+ return consume(signal, accept);
95
+ const iterator = input?.[Symbol.asyncIterator]?.() ?? input?.[Symbol.iterator]?.();
96
+ if (!iterator)
97
+ throw new TypeError("Rows must be a synchronous or asynchronous iterable.");
98
+ let done = false;
99
+ try {
100
+ while (true) {
101
+ checkAbort(signal);
102
+ let item = iterator.next();
103
+ const next = item;
104
+ if (typeof next?.then === "function")
105
+ item = await withAbort(next, signal);
106
+ checkAbort(signal);
107
+ const result = item;
108
+ if (result.done) {
109
+ done = true;
110
+ return;
111
+ }
112
+ let value = result.value;
113
+ if (typeof value?.then === "function")
114
+ value = await withAbort(value, signal);
115
+ checkAbort(signal);
116
+ const pending = accept(value);
117
+ if (pending !== undefined)
118
+ await withAbort(pending, signal);
119
+ }
120
+ }
121
+ finally {
122
+ if (!done && iterator.return) {
123
+ // Any exit before exhaustion is a producer/consumer failure or cancellation.
124
+ // Observe cleanup, but an unresponsive return must not replace or hold the original failure.
125
+ try {
126
+ void Promise.resolve(iterator.return()).catch(() => { });
127
+ }
128
+ catch { /* Preserve the original failure. */ }
129
+ }
130
+ }
131
+ }
132
+ let taskDeadline;
133
+ const taskBudgetMs = 32;
134
+ /** @internal Start a new write phase without carrying an idle operation's expired deadline. */
135
+ function beginTask() { taskDeadline = performance.now() + taskBudgetMs; }
136
+ /** @internal Pipeline stages share the last completed yield instead of pausing back-to-back. */
137
+ function taskYieldDue() {
138
+ const now = performance.now();
139
+ taskDeadline ??= now + taskBudgetMs;
140
+ return now >= taskDeadline;
141
+ }
142
+ /** Yield a task so input, rendering and cancellation can run without nested timer delays. */
143
+ function pause() {
144
+ const scheduler = globalThis.scheduler;
145
+ // A normal-priority task keeps the export progressing beside a busy host.
146
+ // It has no boosted continuation; due input and cancellation can still run.
147
+ if (typeof scheduler?.postTask === "function")
148
+ return scheduler.postTask(() => {
149
+ taskDeadline = performance.now() + taskBudgetMs;
150
+ }, { priority: "user-visible" });
151
+ return new Promise(resolve => {
152
+ setTimeout(function finish() {
153
+ taskDeadline = performance.now() + taskBudgetMs;
154
+ resolve();
155
+ }, 0);
156
+ });
157
+ }
158
+ const _exports = Object.freeze({ checkAbort: checkAbort, withAbort: withAbort, inputRows: inputRows, rowsFromBatches: rowsFromBatches, concatRows: concatRows, consumeRows: consumeRows, beginTask: beginTask, taskYieldDue: taskYieldDue, pause: pause });
159
+ _modules.set("87c24efeaa0f1579c19afeeb4918caeb4f8f65a88d24a246e2cfd712b37dbac3", _exports);
160
+ return _exports;
161
+ })();
162
+
163
+ const _m3 = _modules.get("d5c945064d81fdd257960f48c421125e106e5f270427d170bb05587dd96a44ea") ?? (() => {
164
+ const errorBrand = Symbol.for("@evotecit/officeimo/OfficeIMOError");
165
+ const unsupportedBrand = Symbol.for("@evotecit/officeimo/NotSupportedError");
166
+ class OfficeIMOError extends Error {
167
+ code;
168
+ static [Symbol.hasInstance](value) {
169
+ // Inherited checks on user subclasses must retain their own prototype identity.
170
+ if (this !== OfficeIMOError)
171
+ return Function.prototype[Symbol.hasInstance].call(this, value);
172
+ return !!value && typeof value === "object" && value[errorBrand] === true;
173
+ }
174
+ constructor(code, message, options) {
175
+ super(message, options);
176
+ this.code = code;
177
+ Object.defineProperty(this, errorBrand, { value: true });
178
+ this.name = "OfficeIMOError";
179
+ }
180
+ }
181
+ class NotSupportedError extends OfficeIMOError {
182
+ feature;
183
+ static [Symbol.hasInstance](value) {
184
+ if (this !== NotSupportedError)
185
+ return Function.prototype[Symbol.hasInstance].call(this, value);
186
+ return !!value && typeof value === "object" && value[unsupportedBrand] === true;
187
+ }
188
+ constructor(feature) {
189
+ super("NOT_SUPPORTED", feature + " is not supported yet.");
190
+ this.feature = feature;
191
+ Object.defineProperty(this, unsupportedBrand, { value: true });
192
+ this.name = "NotSupportedError";
193
+ }
194
+ }
195
+ const _exports = Object.freeze({ OfficeIMOError: OfficeIMOError, NotSupportedError: NotSupportedError });
196
+ _modules.set("d5c945064d81fdd257960f48c421125e106e5f270427d170bb05587dd96a44ea", _exports);
197
+ return _exports;
198
+ })();
199
+
200
+ const _m2 = _modules.get("5337d1e3bd5ae0c1d10a476fcd31540d20337ccf7aa93c7e9e26c2b1a7dab92b") ?? (() => {
201
+ const { checkAbort, consumeRows, withAbort, pause, taskYieldDue } = _m1;
202
+
203
+ const { OfficeIMOError } = _m3;
204
+
205
+ /** @internal Borrow a stream writer without closing or aborting the caller's destination. */
206
+ async function withDestination(destination, operation) {
207
+ // Native streams can belong to another browser realm; constructor identity is not portable.
208
+ if (destination && typeof destination.getWriter === "function") {
209
+ const writer = destination.getWriter();
210
+ // Native streams may retain accepted chunks after write resolves.
211
+ try {
212
+ return await operation({ write: bytes => writer.write(new Uint8Array(bytes)) });
213
+ }
214
+ finally {
215
+ writer.releaseLock();
216
+ }
217
+ }
218
+ if (!destination || typeof destination.write !== "function")
219
+ throw new TypeError("Destination must be a ByteSink or WritableStream.");
220
+ return operation(destination);
221
+ }
222
+ /** Collects output only; it does not retain source rows or XML strings. */
223
+ class BlobByteSink {
224
+ parts = [];
225
+ state = "open";
226
+ result;
227
+ write(bytes) {
228
+ if (this.state !== "open")
229
+ throw new OfficeIMOError("INVALID_STATE", "Byte sink is closed.");
230
+ // A caller may reuse its input buffer as soon as write resolves.
231
+ this.parts.push(new Uint8Array(bytes));
232
+ }
233
+ toBlob(type = "application/octet-stream") {
234
+ if (this.state === "discarded")
235
+ throw new OfficeIMOError("INVALID_STATE", "Byte sink was discarded.");
236
+ this.state = "closed";
237
+ if (!this.result) {
238
+ this.result = new Blob(this.parts, { type });
239
+ this.parts = [];
240
+ }
241
+ return this.result.type === type ? this.result : new Blob([this.result], { type });
242
+ }
243
+ /** @internal Transfer buffered compressor chunks without a Blob read in the worker. */
244
+ takeChunks() {
245
+ if (this.state !== "open")
246
+ throw new OfficeIMOError("INVALID_STATE", "Byte sink is closed.");
247
+ const parts = this.parts;
248
+ this.parts = [];
249
+ this.state = "discarded";
250
+ return parts;
251
+ }
252
+ discard() { this.parts = []; this.result = undefined; this.state = "discarded"; }
253
+ }
254
+ /** Bounded UTF-8 batches, preserving surrogate pairs across append boundaries. */
255
+ class ChunkedTextSink {
256
+ sink;
257
+ signal;
258
+ chunkSize;
259
+ text = "";
260
+ encoder = new TextEncoder();
261
+ constructor(sink, signal, chunkSize = 32768) {
262
+ this.sink = sink;
263
+ this.signal = signal;
264
+ this.chunkSize = chunkSize;
265
+ if (!Number.isInteger(chunkSize) || chunkSize < 2)
266
+ throw new RangeError("Text chunk size must be at least 2.");
267
+ }
268
+ append(value) {
269
+ checkAbort(this.signal);
270
+ this.text += value;
271
+ return this.text.length >= this.chunkSize || taskYieldDue();
272
+ }
273
+ /** Flush full text, keeping a trailing high surrogate until the next append. */
274
+ async flush(final = false) {
275
+ checkAbort(this.signal);
276
+ while (this.text.length) {
277
+ let end = Math.min(this.text.length, this.chunkSize);
278
+ if (/[\ud800-\udbff]/.test(this.text[end - 1]) && (end < this.text.length || !final))
279
+ end--;
280
+ if (!end)
281
+ break;
282
+ const bytes = this.encoder.encode(this.text.slice(0, end));
283
+ this.text = this.text.slice(end);
284
+ await withAbort(Promise.resolve(this.sink.write(bytes)), this.signal);
285
+ if (taskYieldDue())
286
+ await pause();
287
+ checkAbort(this.signal);
288
+ }
289
+ }
290
+ async write(text) { if (this.append(text))
291
+ await this.flush(); }
292
+ async close() { await this.flush(true); }
293
+ }
294
+ /** Feed a byte source into a caller-owned sink with backpressure and cancellation. */
295
+ async function writeBytes(source, sink, signal) {
296
+ await consumeRows(source instanceof Uint8Array ? [source] : source, signal, bytes => {
297
+ if (!(bytes instanceof Uint8Array))
298
+ throw new TypeError("Byte sources must yield Uint8Array chunks.");
299
+ const pending = sink.write(bytes);
300
+ if (taskYieldDue())
301
+ return Promise.resolve(pending).then(() => { checkAbort(signal); return pause(); });
302
+ return pending;
303
+ });
304
+ }
305
+ const _exports = Object.freeze({ withDestination: withDestination, BlobByteSink: BlobByteSink, ChunkedTextSink: ChunkedTextSink, writeBytes: writeBytes });
306
+ _modules.set("5337d1e3bd5ae0c1d10a476fcd31540d20337ccf7aa93c7e9e26c2b1a7dab92b", _exports);
307
+ return _exports;
308
+ })();
309
+
310
+ const _m5 = _modules.get("50b3c10b690ceff693c8c5f809195ba6845b20e60f408e791a750d2ecbd5c669") ?? (() => {
311
+ /** Capture a structural option record before validation or asynchronous work.
312
+ * Own fields and supported prototype accessors are read once. Nested values remain
313
+ * borrowed until their owning format captures or validates them. */
314
+ function captureFields(input, fields) {
315
+ const captured = { ...input };
316
+ for (const field of fields) {
317
+ if (Object.hasOwn(captured, field))
318
+ continue;
319
+ const value = input[field];
320
+ if (value !== undefined)
321
+ captured[field] = value;
322
+ }
323
+ return captured;
324
+ }
325
+ const _exports = Object.freeze({ captureFields: captureFields });
326
+ _modules.set("50b3c10b690ceff693c8c5f809195ba6845b20e60f408e791a750d2ecbd5c669", _exports);
327
+ return _exports;
328
+ })();
329
+
330
+ const _m4 = _modules.get("42faf379960e5674a6fdfa8c8fca0bb68bbd74587231248d2524d7004def3671") ?? (() => {
331
+ const { OfficeIMOError } = _m3;
332
+
333
+ const { captureFields } = _m5;
334
+
335
+ /** @internal Check before accepting the next value or chunk. */
336
+ class ExportBudget {
337
+ cells = 0;
338
+ text = 0;
339
+ reservedCells = 0;
340
+ reservedText = 0;
341
+ limits;
342
+ constructor(limits = {}) {
343
+ if (!limits || typeof limits !== "object" || Array.isArray(limits))
344
+ throw new TypeError("Export limits must be an object.");
345
+ // Capture before validation. Supported class getters are ordinary structural
346
+ // options too, and an accessor must not change the ceiling after validation.
347
+ const captured = captureFields(limits, ["maxRows", "maxCells", "maxTextCharacters", "maxOutputBytes"]);
348
+ for (const [key, value] of Object.entries(captured))
349
+ if (value !== undefined && (!Number.isSafeInteger(value) || value < 0))
350
+ throw new RangeError(key + " must be a nonnegative safe integer.");
351
+ this.limits = Object.freeze(captured);
352
+ }
353
+ check(kind, value) {
354
+ const maximum = this.limits[kind];
355
+ if (maximum !== undefined && value > maximum)
356
+ throw new OfficeIMOError("RESOURCE_LIMIT", kind + " exceeded (" + value + " > " + maximum + ").");
357
+ }
358
+ row(count) { this.check("maxRows", count); }
359
+ reserve(cells, characters) {
360
+ this.check("maxCells", this.cells + this.reservedCells + cells);
361
+ this.check("maxTextCharacters", this.text + this.reservedText + characters);
362
+ this.reservedCells += cells;
363
+ this.reservedText += characters;
364
+ }
365
+ release(cells, characters) { this.reservedCells -= cells; this.reservedText -= characters; }
366
+ cell(value, reservedCharacters) {
367
+ if (reservedCharacters !== undefined)
368
+ this.release(1, reservedCharacters);
369
+ // Immutable limits cannot acquire a ceiling later. Avoid per-cell accounting
370
+ // when neither emitted-cell nor text totals are observable by a resource cap.
371
+ if (this.limits.maxCells === undefined && this.limits.maxTextCharacters === undefined)
372
+ return;
373
+ this.check("maxCells", this.cells + this.reservedCells + 1);
374
+ const length = typeof value === "string" ? value.length : 0;
375
+ this.check("maxTextCharacters", this.text + this.reservedText + length);
376
+ this.cells++;
377
+ this.text += length;
378
+ }
379
+ }
380
+ /** @internal Ownership stays with the caller. */
381
+ function boundedSink(sink, budget) {
382
+ let bytes = 0;
383
+ return { write(chunk) {
384
+ budget.check("maxOutputBytes", bytes + chunk.length);
385
+ bytes += chunk.length;
386
+ return sink.write(chunk);
387
+ } };
388
+ }
389
+ const _exports = Object.freeze({ ExportBudget: ExportBudget, boundedSink: boundedSink });
390
+ _modules.set("42faf379960e5674a6fdfa8c8fca0bb68bbd74587231248d2524d7004def3671", _exports);
391
+ return _exports;
392
+ })();
393
+
394
+ const _m7 = _modules.get("501f5fccaecb27d9e514b74cf64893649e50616692250593d120ca315b510c04") ?? (() => {
395
+ /** @internal Recognize native Date values across iframe realms without trusting a string tag. */
396
+ function isDate(value) {
397
+ if (value === null || typeof value !== "object")
398
+ return false;
399
+ try {
400
+ // Ordinary rows take the cheap negative path. A custom string tag can be an
401
+ // accessor: use the native brand check directly without reading that tag.
402
+ if (!(value instanceof Date) && !(Symbol.toStringTag in value) && Object.prototype.toString.call(value) !== "[object Date]")
403
+ return false;
404
+ Date.prototype.getTime.call(value);
405
+ return true;
406
+ }
407
+ catch {
408
+ return false;
409
+ }
410
+ }
411
+ const _exports = Object.freeze({ isDate: isDate });
412
+ _modules.set("501f5fccaecb27d9e514b74cf64893649e50616692250593d120ca315b510c04", _exports);
413
+ return _exports;
414
+ })();
415
+
416
+ const _m8 = _modules.get("d363b84eac65064b2e372063af61a4e9e5c576501693c862628297c812ba7832") ?? (() => {
417
+ /** @internal One target policy shared by document writers and portable cells. */
418
+ function copyExportLink(link) {
419
+ if (!link || typeof link !== "object")
420
+ throw new TypeError("Hyperlinks require an absolute HTTP, HTTPS or mailto target without whitespace or controls.");
421
+ const { target, tooltip } = link;
422
+ if (typeof target !== "string" || !/^(?:https?:\/\/|mailto:)/i.test(target) || /[\u0000-\u0020\u007f]/.test(target))
423
+ throw new TypeError("Hyperlinks require an absolute HTTP, HTTPS or mailto target without whitespace or controls.");
424
+ const url = new URL(target);
425
+ if ((url.protocol === "http:" || url.protocol === "https:") && (!url.hostname || url.username || url.password))
426
+ throw new TypeError("Hyperlink HTTP targets need a host and must not contain credentials.");
427
+ if (tooltip !== undefined && typeof tooltip !== "string")
428
+ throw new TypeError("Hyperlink tooltip must be text.");
429
+ return Object.freeze({ target: url.href, ...(tooltip === undefined ? {} : { tooltip }) });
430
+ }
431
+ const _exports = Object.freeze({ copyExportLink: copyExportLink });
432
+ _modules.set("d363b84eac65064b2e372063af61a4e9e5c576501693c862628297c812ba7832", _exports);
433
+ return _exports;
434
+ })();
435
+
436
+ const _m6 = _modules.get("732224f6995c2478cf33a6ed01f3e3d3dcccb159a731d6db9280104bd5040fc5") ?? (() => {
437
+ const { isDate } = _m7;
438
+
439
+ const { copyExportLink } = _m8;
440
+
441
+ const exportCellBrand = Symbol.for("@evotecit/officeimo/ExportCell");
442
+ /** @internal Capture only portable scalar presentation fields before retaining or cloning a cell. */
443
+ function copyCellPresentation(value) {
444
+ if (!value || typeof value !== "object" || Array.isArray(value))
445
+ throw new TypeError("Cell presentation must be an object.");
446
+ const result = {};
447
+ for (const key of ["background", "color", "numberFormat", "bold", "italic", "wrapText", "alignment"]) {
448
+ const field = value[key];
449
+ if (field === undefined)
450
+ continue;
451
+ if (["bold", "italic", "wrapText"].includes(key)) {
452
+ if (typeof field !== "boolean")
453
+ throw new TypeError("Cell presentation " + key + " must be boolean.");
454
+ }
455
+ else if (typeof field !== "string")
456
+ throw new TypeError("Cell presentation " + key + " must be text.");
457
+ if (key === "alignment" && !["left", "center", "right", "fill", "justify", "distributed"].includes(field))
458
+ throw new TypeError("Invalid cell presentation alignment.");
459
+ result[key] = field;
460
+ }
461
+ return Object.freeze(result);
462
+ }
463
+ /** One resolved value/presentation decision that can be reused across exports. Strings remain literal data. */
464
+ class ExportCell {
465
+ value;
466
+ static [Symbol.hasInstance](value) { return !!value && typeof value === "object" && value[exportCellBrand] === true; }
467
+ text;
468
+ presentation;
469
+ link;
470
+ constructor(value, options = {}) {
471
+ this.value = value;
472
+ const { text, presentation, link } = options;
473
+ if (text !== undefined && typeof text !== "string")
474
+ throw new TypeError("Display text must be a string.");
475
+ assertScalar(value);
476
+ this.text = text;
477
+ this.presentation = presentation === undefined ? undefined : copyCellPresentation(presentation);
478
+ this.link = link === undefined ? undefined : copyExportLink(link);
479
+ Object.defineProperty(this, exportCellBrand, { value: true });
480
+ Object.freeze(this);
481
+ }
482
+ }
483
+ /** @internal Reject async formatters while observing their rejection immediately. */
484
+ function assertScalar(value) {
485
+ const kind = typeof value;
486
+ if (value == null || kind === "string" || kind === "number" || kind === "boolean" || isDate(value))
487
+ return;
488
+ if (typeof value.then === "function")
489
+ void Promise.resolve(value).catch(() => { });
490
+ throw new TypeError("Export values and formatter results must be synchronous strings, numbers, booleans, Dates or null.");
491
+ }
492
+ /** @internal Validate selected values before a destination interprets presentation. */
493
+ function assertExportValue(value) {
494
+ if (value !== null && typeof value === "object" && value instanceof ExportCell)
495
+ return;
496
+ assertScalar(value);
497
+ }
498
+ const _exports = Object.freeze({ copyCellPresentation: copyCellPresentation, ExportCell: ExportCell, assertScalar: assertScalar, assertExportValue: assertExportValue });
499
+ _modules.set("732224f6995c2478cf33a6ed01f3e3d3dcccb159a731d6db9280104bd5040fc5", _exports);
500
+ return _exports;
501
+ })();
502
+
503
+ const _m9 = _modules.get("6cfd3e806439f6301003a2d1699a74fdfa574d935550ab62b97b528728eaee1f") ?? (() => {
504
+ /** @internal Notify synchronously; observe an accidental promise before rejecting its unsupported use. */
505
+ function notifyProgress(callback, progress) {
506
+ if (!callback)
507
+ return;
508
+ const result = callback(progress);
509
+ if (result && typeof result.then === "function") {
510
+ void Promise.resolve(result).catch(() => { });
511
+ throw new TypeError("onProgress must be synchronous.");
512
+ }
513
+ }
514
+ const _exports = Object.freeze({ notifyProgress: notifyProgress });
515
+ _modules.set("6cfd3e806439f6301003a2d1699a74fdfa574d935550ab62b97b528728eaee1f", _exports);
516
+ return _exports;
517
+ })();
518
+
519
+ const _m10 = _modules.get("0391fe35ea7d02b25804ab4d0e7543136d6bb615f368f268c74aa135f23aa6bc") ?? (() => {
520
+ const { assertExportValue } = _m6;
521
+
522
+ const { checkAbort } = _m1;
523
+
524
+ const { isDate } = _m7;
525
+
526
+ const { captureFields } = _m5;
527
+
528
+ function createRowProjector(columns, worksheet, signal, validate = assertExportValue) {
529
+ const getters = columns.some(column => column.value);
530
+ return (row, rowIndex = 0) => {
531
+ if (Array.isArray(row) && !getters) {
532
+ const length = row.length;
533
+ if (length > columns.length)
534
+ throw new RangeError("Row has more values than declared columns.");
535
+ // Resolve each positional value once, just like key/value projections. Returning the
536
+ // source array would let an accessor change a value after the portable-value check.
537
+ const values = new Array(length);
538
+ for (let index = 0; index < length; index++) {
539
+ const value = row[index];
540
+ validate(value);
541
+ values[index] = value;
542
+ }
543
+ return values;
544
+ }
545
+ if (!row || typeof row !== "object" || isDate(row))
546
+ throw new TypeError("A row must be an array or object.");
547
+ if (Array.isArray(row) && row.length > columns.length && !columns.every(column => column.value))
548
+ throw new RangeError("Project every column explicitly when selecting from a wider array row.");
549
+ return columns.map((c, columnIndex) => {
550
+ if (c.value) {
551
+ checkAbort(signal);
552
+ const context = { rowIndex, columnIndex, column: c,
553
+ ...(worksheet ? { sheetName: worksheet.sheetName, worksheetRow: worksheet.firstDataRow + rowIndex } : {}) };
554
+ const result = c.value(row, context);
555
+ validate(result);
556
+ checkAbort(signal);
557
+ return result;
558
+ }
559
+ if (Array.isArray(row)) {
560
+ const result = row[columnIndex];
561
+ validate(result);
562
+ return result;
563
+ }
564
+ const key = c.key ?? c.header;
565
+ const result = Object.prototype.hasOwnProperty.call(row, key) ? row[key] : undefined;
566
+ validate(result);
567
+ return result;
568
+ });
569
+ };
570
+ }
571
+ /** @internal Shared metadata fields for full columns and adapter-owned partial overrides. */
572
+ const columnOptionFields = ["header", "key", "value", "width", "type", "format", "wrapText", "alignment", "rowHeader", "groups", "style", "valueFormatter"];
573
+ function copyColumns(columns, workbookStyles = false) {
574
+ if (!Array.isArray(columns))
575
+ throw new TypeError("Declare the columns in export order.");
576
+ return columns.map(c => {
577
+ if (!c || typeof c !== "object" && typeof c !== "function")
578
+ throw new TypeError("Each column needs a string header and an optional string key.");
579
+ // Own extension metadata remains available to its format owner. Capture the
580
+ // supported structural fields even when a class exposes prototype getters.
581
+ const captured = captureFields(c, columnOptionFields);
582
+ if (!workbookStyles && captured.style !== undefined)
583
+ throw new TypeError("Workbook-local column styles require the advanced Workbook API; use portable ExportCell presentation.");
584
+ if (typeof captured.header !== "string" || (captured.key !== undefined && typeof captured.key !== "string"))
585
+ throw new TypeError("Each column needs a string header and an optional string key.");
586
+ if (captured.value !== undefined && typeof captured.value !== "function")
587
+ throw new TypeError("Column value getters must be functions.");
588
+ if (captured.rowHeader !== undefined && typeof captured.rowHeader !== "boolean")
589
+ throw new TypeError("Column rowHeader must be boolean.");
590
+ if (captured.groups !== undefined) {
591
+ if (!Array.isArray(captured.groups))
592
+ throw new TypeError("Column groups must be an array of strings.");
593
+ const groups = Array.from(captured.groups);
594
+ if (groups.some(group => typeof group !== "string"))
595
+ throw new TypeError("Column groups must be an array of strings.");
596
+ return { ...captured, groups: Object.freeze(groups) };
597
+ }
598
+ return captured;
599
+ });
600
+ }
601
+ const _exports = Object.freeze({ createRowProjector: createRowProjector, columnOptionFields: columnOptionFields, copyColumns: copyColumns });
602
+ _modules.set("0391fe35ea7d02b25804ab4d0e7543136d6bb615f368f268c74aa135f23aa6bc", _exports);
603
+ return _exports;
604
+ })();
605
+
606
+ const _m13 = _modules.get("e95bb0e3f342d1379b67a3d541fa808e06361da8460169a6aec152ee7deb69b2") ?? (() => {
607
+ const { ExportCell, assertExportValue } = _m6;
608
+
609
+ const { isDate } = _m7;
610
+
611
+ /** Copy portable values when an operation retains metadata or a projected row beyond its producer's turn. */
612
+ function copyExportValue(value) {
613
+ assertExportValue(value);
614
+ if (isDate(value))
615
+ return new Date(Date.prototype.getTime.call(value));
616
+ if (value instanceof ExportCell) {
617
+ const { value: scalar, text, presentation, link } = value;
618
+ return new ExportCell(isDate(scalar) ? new Date(Date.prototype.getTime.call(scalar)) : scalar, { ...(text === undefined ? {} : { text }), ...(presentation === undefined ? {} : { presentation }),
619
+ ...(link === undefined ? {} : { link }) });
620
+ }
621
+ return value;
622
+ }
623
+ const _exports = Object.freeze({ copyExportValue: copyExportValue });
624
+ _modules.set("e95bb0e3f342d1379b67a3d541fa808e06361da8460169a6aec152ee7deb69b2", _exports);
625
+ return _exports;
626
+ })();
627
+
628
+ const _m12 = _modules.get("d56b24243cff6f3552a2f7b45521af4491494375ec76117e9ac1ebb047ce02da") ?? (() => {
629
+ const { assertExportValue } = _m6;
630
+
631
+ const { copyExportValue } = _m13;
632
+
633
+ /** Capture a bounded public matrix before validation or asynchronous report production can revisit its fields. */
634
+ function captureTableSpans(rows, columns) {
635
+ if (!Array.isArray(rows) || !rows.length || rows.length > 16)
636
+ throw new RangeError("Spanned headings/footers need from 1 through 16 rows.");
637
+ const captured = rows.map(row => {
638
+ if (!Array.isArray(row) || row.length !== columns)
639
+ throw new TypeError("Spanned rows must have the declared column count.");
640
+ return Object.freeze(row.map(cell => {
641
+ if (cell === null)
642
+ return null;
643
+ if (!cell || typeof cell !== "object")
644
+ throw new TypeError("Uncovered heading/footer cells need an anchor value.");
645
+ const { value, columnSpan, rowSpan } = cell;
646
+ return Object.freeze({ value: copyExportValue(value), ...(columnSpan === undefined ? {} : { columnSpan }),
647
+ ...(rowSpan === undefined ? {} : { rowSpan }) });
648
+ }));
649
+ });
650
+ tableSpans(captured, columns);
651
+ return Object.freeze(captured);
652
+ }
653
+ /** Validate one small, rectangular heading/footer matrix before any drawing. */
654
+ function tableSpans(rows, columns) {
655
+ if (!Array.isArray(rows) || !rows.length || rows.length > 16)
656
+ throw new RangeError("Spanned headings/footers need from 1 through 16 rows.");
657
+ const covered = Array.from({ length: rows.length }, () => new Uint8Array(columns));
658
+ return rows.map((row, level) => {
659
+ if (!Array.isArray(row) || row.length !== columns)
660
+ throw new TypeError("Spanned rows must have the declared column count.");
661
+ const anchors = [];
662
+ for (let first = 0; first < columns; first++) {
663
+ const cell = row[first];
664
+ if (covered[level][first]) {
665
+ if (cell !== null)
666
+ throw new TypeError("Covered heading/footer cells must be null.");
667
+ continue;
668
+ }
669
+ if (!cell || typeof cell !== "object")
670
+ throw new TypeError("Uncovered heading/footer cells need an anchor value.");
671
+ const span = cell.columnSpan ?? 1, rowSpan = cell.rowSpan ?? 1;
672
+ if (!Number.isInteger(span) || !Number.isInteger(rowSpan) || span < 1 || rowSpan < 1 || first + span > columns || level + rowSpan > rows.length)
673
+ throw new RangeError("Heading/footer spans must stay inside the declared matrix.");
674
+ const value = cell.value;
675
+ assertExportValue(value);
676
+ for (let r = level; r < level + rowSpan; r++)
677
+ for (let c = first; c < first + span; c++) {
678
+ if (covered[r][c])
679
+ throw new TypeError("Heading/footer spans overlap.");
680
+ if ((r !== level || c !== first) && rows[r]?.[c] !== null)
681
+ throw new TypeError("Covered heading/footer cells must be null.");
682
+ covered[r][c] = 1;
683
+ }
684
+ anchors.push(Object.freeze({ first, span, rowSpan, value }));
685
+ }
686
+ return Object.freeze(anchors);
687
+ });
688
+ }
689
+ const _exports = Object.freeze({ captureTableSpans: captureTableSpans, tableSpans: tableSpans });
690
+ _modules.set("d56b24243cff6f3552a2f7b45521af4491494375ec76117e9ac1ebb047ce02da", _exports);
691
+ return _exports;
692
+ })();
693
+
694
+ const _m11 = _modules.get("2f5c0823847e9209017d01b2a753f36056df2a9988fae1f3a1bd5fd186545220") ?? (() => {
695
+ const { captureTableSpans, tableSpans } = _m12;
696
+
697
+ /** Snapshot small report matrices; flattening is an explicit format decision, never inferred from labels. */
698
+ function csvStructuredRows(rows, columns, mode) {
699
+ const anchors = tableSpans(captureTableSpans(rows, columns), columns), output = anchors.map(() => Array(columns).fill(""));
700
+ for (let row = 0; row < anchors.length; row++)
701
+ for (const anchor of anchors[row]) {
702
+ if ((anchor.span > 1 || anchor.rowSpan > 1) && mode === undefined)
703
+ throw new TypeError("CSV spanned headings/footers require an explicit spanMode: repeat or anchors.");
704
+ const value = anchor.value;
705
+ for (let r = row; r < row + (mode === "repeat" ? anchor.rowSpan : 1); r++)
706
+ for (let c = anchor.first; c < anchor.first + (mode === "repeat" ? anchor.span : 1); c++)
707
+ output[r][c] = value;
708
+ }
709
+ return output;
710
+ }
711
+ const _exports = Object.freeze({ csvStructuredRows: csvStructuredRows });
712
+ _modules.set("2f5c0823847e9209017d01b2a753f36056df2a9988fae1f3a1bd5fd186545220", _exports);
713
+ return _exports;
714
+ })();
715
+
716
+ const _m14 = _modules.get("9b33d9107e62ba8299c576072de40d24a261464f118de4ace64f23154fc78307") ?? (() => {
717
+ /** Compatibility display policy; hosts can supply labels without changing typed source values. */
718
+ const defaultBooleanText = Object.freeze({ true: "True", false: "False" });
719
+ /** @internal Capture display policy once, before source iteration or asynchronous output. */
720
+ function captureBooleanText(input) {
721
+ if (input === undefined)
722
+ return defaultBooleanText;
723
+ if (!input || typeof input !== "object")
724
+ throw new TypeError("booleanText must contain true and false strings.");
725
+ const yes = input.true, no = input.false;
726
+ if (typeof yes !== "string" || typeof no !== "string")
727
+ throw new TypeError("booleanText must contain true and false strings.");
728
+ return Object.freeze({ true: yes, false: no });
729
+ }
730
+ const _exports = Object.freeze({ defaultBooleanText: defaultBooleanText, captureBooleanText: captureBooleanText });
731
+ _modules.set("9b33d9107e62ba8299c576072de40d24a261464f118de4ace64f23154fc78307", _exports);
732
+ return _exports;
733
+ })();
734
+
735
+ const _m15 = _modules.get("f0627ba89e5c8fcb376ebe3ce72dcc8d68c34952981f8703e36b8bb1a9894208") ?? (() => {
736
+ const { captureFields } = _m5;
737
+
738
+ /** @internal Share the format's capture policy with thin adapters before they compose options. */
739
+ function captureCsvOptions(input) {
740
+ if (!input || typeof input !== "object")
741
+ throw new TypeError("CSV options are required.");
742
+ return captureFields(input, ["columns", "signal", "limits", "onProgress", "valueMode", "delimiter", "lineEnding", "bom", "includeHeader", "headerRows",
743
+ "footer", "spanMode", "formulaInjectionProtection", "quote", "nullValue", "booleanText"]);
744
+ }
745
+ const _exports = Object.freeze({ captureCsvOptions: captureCsvOptions });
746
+ _modules.set("f0627ba89e5c8fcb376ebe3ce72dcc8d68c34952981f8703e36b8bb1a9894208", _exports);
747
+ return _exports;
748
+ })();
749
+
750
+ const _m18 = _modules.get("c9fde2c438e186da56f740105fcd41c265fdfdd855a4f1b811d556a02387479b") ?? (() => {
751
+ class NumericAggregate {
752
+ operation;
753
+ count = 0;
754
+ sum = 0;
755
+ mean = 0;
756
+ min = Infinity;
757
+ max = -Infinity;
758
+ constructor(operation) {
759
+ this.operation = operation;
760
+ }
761
+ accept(value) {
762
+ if (!this.operation || typeof value !== "number" || !Number.isFinite(value))
763
+ return;
764
+ this.count++;
765
+ if (this.operation === "sum") {
766
+ this.sum += value;
767
+ if (!Number.isFinite(this.sum))
768
+ throw new RangeError("Numeric total exceeds finite number range.");
769
+ }
770
+ else if (this.operation === "average") {
771
+ const delta = value - this.mean;
772
+ this.mean = this.count === 1 ? value : Number.isFinite(delta) ? this.mean + delta / this.count : this.mean * ((this.count - 1) / this.count) + value / this.count;
773
+ }
774
+ else if (this.operation === "min")
775
+ this.min = Math.min(this.min, value);
776
+ else if (this.operation === "max")
777
+ this.max = Math.max(this.max, value);
778
+ }
779
+ value() {
780
+ return this.operation === "count" ? this.count : this.operation === "sum" ? this.sum : !this.count ? null : this.operation === "average" ? this.mean : this.operation === "min" ? this.min : this.max;
781
+ }
782
+ }
783
+ function createTotals(columns, totals = {}) {
784
+ const keys = columns.map(c => c.key ?? c.header);
785
+ for (const [key, operation] of Object.entries(totals)) {
786
+ if (keys.filter(k => k === key).length !== 1)
787
+ throw new TypeError("Totals need an unambiguous declared column key: " + key);
788
+ if (!["sum", "count", "average", "min", "max"].includes(operation))
789
+ throw new TypeError("Invalid total operation.");
790
+ }
791
+ return keys.map(key => new NumericAggregate(Object.prototype.hasOwnProperty.call(totals, key) ? totals[key] : undefined));
792
+ }
793
+ const _exports = Object.freeze({ NumericAggregate: NumericAggregate, createTotals: createTotals });
794
+ _modules.set("c9fde2c438e186da56f740105fcd41c265fdfdd855a4f1b811d556a02387479b", _exports);
795
+ return _exports;
796
+ })();
797
+
798
+ const _m17 = _modules.get("046b305cdccf817d847addb75a778131622de23f2840830bbe1c0c26053a68c0") ?? (() => {
799
+ const { ExportCell, assertScalar } = _m6;
800
+
801
+ const { isDate } = _m7;
802
+
803
+ const { checkAbort, inputRows, pause, taskYieldDue } = _m1;
804
+
805
+ const { ExportBudget } = _m4;
806
+
807
+ const { OfficeIMOError } = _m3;
808
+
809
+ const { copyColumns, createRowProjector } = _m10;
810
+
811
+ const { createTotals } = _m18;
812
+
813
+ const { copyExportValue } = _m13;
814
+
815
+ const sources = new WeakMap();
816
+ /** @internal Writers accept the owned immutable event source rather than trusting caller-authored event protocols. */
817
+ function assertGroupedReportSource(value) {
818
+ if (!value || typeof value !== "object" || !sources.has(value))
819
+ throw new TypeError("Create grouped report sources with createGroupedReport.");
820
+ }
821
+ /** @internal The consuming writer's signal reaches pending source reads as well as destination writes. */
822
+ function groupedReportEvents(source, signal) {
823
+ assertGroupedReportSource(source);
824
+ return { async *[Symbol.asyncIterator]() {
825
+ const operation = groupedReportOperation(source, signal);
826
+ try {
827
+ yield* operation.events;
828
+ }
829
+ finally {
830
+ operation.dispose();
831
+ }
832
+ } };
833
+ }
834
+ /** @internal Share cancellation between original source reads and destination writes; callers dispose in finally. */
835
+ function groupedReportOperation(source, signal) {
836
+ assertGroupedReportSource(source);
837
+ const factory = sources.get(source), linked = linkedSignals(factory.signal, signal);
838
+ return { signal: linked.signal, events: factory.events(linked.signal), dispose: linked.dispose };
839
+ }
840
+ function linkedSignals(source, consumer) {
841
+ if (!source || !consumer || source === consumer)
842
+ return { signal: source ?? consumer, dispose() { } };
843
+ const controller = new AbortController(), abortSource = () => controller.abort(source.reason), abortConsumer = () => controller.abort(consumer.reason);
844
+ source.addEventListener("abort", abortSource, { once: true });
845
+ consumer.addEventListener("abort", abortConsumer, { once: true });
846
+ if (source.aborted)
847
+ abortSource();
848
+ else if (consumer.aborted)
849
+ abortConsumer();
850
+ return { signal: controller.signal, dispose() { source.removeEventListener("abort", abortSource); consumer.removeEventListener("abort", abortConsumer); } };
851
+ }
852
+ function maximum(value, fallback, name) {
853
+ const result = value ?? fallback;
854
+ if (!Number.isSafeInteger(result) || result < 0)
855
+ throw new RangeError(name + " must be a nonnegative safe integer.");
856
+ return result;
857
+ }
858
+ function scalar(value) { return value instanceof ExportCell ? value.value : value; }
859
+ function identity(value) {
860
+ if (value == null)
861
+ return { key: null, id: "null", text: "" };
862
+ if (isDate(value)) {
863
+ const time = Date.prototype.getTime.call(value);
864
+ if (!Number.isFinite(time))
865
+ throw new TypeError("A group key date must be valid.");
866
+ return { key: new Date(time), id: "date:" + time, text: new Date(time).toISOString() };
867
+ }
868
+ if (typeof value === "number" && !Number.isFinite(value))
869
+ throw new TypeError("A numeric group key must be finite.");
870
+ const text = String(value);
871
+ return { key: value, id: typeof value + ":" + text, text };
872
+ }
873
+ function eventKey(value) { return isDate(value) ? new Date(Date.prototype.getTime.call(value)) : value; }
874
+ function result(aggregates) {
875
+ return Object.freeze(aggregates.map(aggregate => aggregate.operation === undefined ? null : aggregate.value()));
876
+ }
877
+ function groupingLevels(input, keys, groupLabel) {
878
+ const selected = typeof input === "string" ? [input] : Array.isArray(input) ? Array.from(input) : undefined;
879
+ if (!selected || selected.length < 1 || selected.length > 4)
880
+ throw new TypeError("groupBy must declare between one and four grouping levels.");
881
+ if (groupLabel !== undefined && typeof groupLabel !== "function")
882
+ throw new TypeError("groupLabel must be a synchronous function.");
883
+ if (groupLabel && selected.length !== 1)
884
+ throw new TypeError("groupLabel is only available for one grouping level; use descriptor labels for a hierarchy.");
885
+ const seen = new Set();
886
+ return Object.freeze(selected.map(level => {
887
+ if (typeof level !== "string" && (!level || typeof level !== "object" || Array.isArray(level)))
888
+ throw new TypeError("A grouping level must name a stable column key or provide a descriptor.");
889
+ // Supported structural fields, including prototype accessors, are captured once.
890
+ const { key, value, label } = typeof level === "string" ? { key: level, value: undefined, label: undefined } : level;
891
+ if (typeof key !== "string" || !key.length || seen.has(key))
892
+ throw new TypeError("Grouping levels need unique, nonempty stable keys.");
893
+ seen.add(key);
894
+ if (value !== undefined && typeof value !== "function")
895
+ throw new TypeError("Grouping value getters must be synchronous functions.");
896
+ if (label !== undefined && typeof label !== "function")
897
+ throw new TypeError("Grouping labels must be synchronous functions.");
898
+ if (label && groupLabel)
899
+ throw new TypeError("Specify either groupLabel or the grouping descriptor label.");
900
+ const column = keys.indexOf(key);
901
+ if (column >= 0 && value !== undefined)
902
+ throw new TypeError("A declared grouping column reuses its projected value; do not provide another value getter.");
903
+ if (column < 0 && value === undefined)
904
+ throw new TypeError("groupBy must name a declared stable column key; hidden grouping fields need an explicit value getter.");
905
+ return Object.freeze({ key, column, value, label: label ?? groupLabel });
906
+ }));
907
+ }
908
+ /** Copy date keys on every event so a consumer cannot mutate later hierarchy decisions. */
909
+ function groupPath(active) {
910
+ return Object.freeze(active.map(({ group }) => Object.freeze({ ...group, key: eventKey(group.key) })));
911
+ }
912
+ function labelText(format, key, fallback) {
913
+ if (!format)
914
+ return fallback;
915
+ const formatted = format(eventKey(key));
916
+ if (typeof formatted?.then === "function")
917
+ void Promise.resolve(formatted).catch(() => { });
918
+ if (typeof formatted !== "string")
919
+ throw new TypeError("Grouping labels must return synchronous text.");
920
+ return formatted;
921
+ }
922
+ /** Group a preordered row source once. Closed-group recurrence within the same parent rejects.
923
+ * Equality is locale independent: strings are exact, numbers and booleans retain their types, dates compare
924
+ * by UTC instant, and null/undefined share one group. No sorting or complete group-body retention occurs. */
925
+ function createGroupedReport(rows, options) {
926
+ if (!options || typeof options !== "object")
927
+ throw new TypeError("Grouped report options are required.");
928
+ // Capture configuration before validation so accessors cannot select different columns in later stages.
929
+ const { columns: selected, groupBy, totals: selectedTotals, groupLabel, maxGroups: requestedGroups, maxGroupKeyCharacters: requestedCharacters, signal: sourceSignal, limits } = options;
930
+ if (limits !== undefined && (!limits || typeof limits !== "object" || Array.isArray(limits)))
931
+ throw new TypeError("Grouped source limits must be an object.");
932
+ if (limits !== undefined && "maxOutputBytes" in limits)
933
+ throw new TypeError("Set maxOutputBytes on the format writer, not the grouped source.");
934
+ if (!Array.isArray(selected) || !selected.length)
935
+ throw new TypeError("A grouped report needs declared columns.");
936
+ const columns = copyColumns(selected);
937
+ const keys = columns.map(column => column.key);
938
+ if (keys.some(key => typeof key !== "string" || key.length === 0) || new Set(keys).size !== keys.length)
939
+ throw new TypeError("Grouped report columns need unique, nonempty stable keys.");
940
+ const levels = groupingLevels(groupBy, keys, groupLabel);
941
+ const totals = Object.freeze({ ...selectedTotals });
942
+ const grand = createTotals(columns, totals);
943
+ for (let column = 0; column < columns.length; column++)
944
+ if (grand[column].operation !== undefined && columns[column].type !== "number")
945
+ throw new TypeError("Grouped numeric totals require a column declared with type:number.");
946
+ const maxGroups = maximum(requestedGroups, 1000, "maxGroups");
947
+ const maxCharacters = maximum(requestedCharacters, 1000000, "maxGroupKeyCharacters");
948
+ const budget = new ExportBudget(limits);
949
+ const portable = Object.freeze(columns.map(column => {
950
+ const { value: _getter, ...metadata } = column;
951
+ return Object.freeze(metadata);
952
+ }));
953
+ for (const column of columns) {
954
+ budget.cell(column.header);
955
+ for (const group of column.groups ?? [])
956
+ budget.reserve(0, group.length);
957
+ Object.freeze(column);
958
+ }
959
+ let consumed = false;
960
+ const eventsFor = (signal) => Object.freeze({ [Symbol.asyncIterator]() {
961
+ if (consumed)
962
+ throw new TypeError("A grouped report source can be consumed only once.");
963
+ consumed = true;
964
+ return iterate(signal);
965
+ } });
966
+ const events = eventsFor(sourceSignal);
967
+ async function* iterate(signal) {
968
+ const project = createRowProjector(columns, undefined, signal);
969
+ const seen = new Set(), active = [];
970
+ let characters = 0, rowCount = 0, groups = 0;
971
+ for await (const input of inputRows(rows, signal)) {
972
+ // Copy positional input once before the shared projector validates and inspects its values.
973
+ const snapshot = Array.isArray(input) ? Array.from(input) : input;
974
+ const projected = project(snapshot, rowCount), values = [];
975
+ for (let column = 0; column < columns.length; column++)
976
+ values.push(copyExportValue(projected[column]) ?? null);
977
+ checkAbort(signal);
978
+ const next = levels.map((level, index) => {
979
+ checkAbort(signal);
980
+ const value = level.column >= 0 ? scalar(values[level.column]) : level.value(snapshot, Object.freeze({ rowIndex: rowCount, level: index, key: level.key }));
981
+ assertScalar(value);
982
+ checkAbort(signal);
983
+ return identity(value);
984
+ });
985
+ budget.row(rowCount + 1);
986
+ for (let column = 0; column < values.length; column++) {
987
+ const value = values[column], raw = scalar(value);
988
+ if (grand[column].operation !== undefined && raw != null && (typeof raw !== "number" || !Number.isFinite(raw)))
989
+ throw new TypeError("Grouped numeric metrics must resolve to finite numbers or null.");
990
+ budget.cell(raw);
991
+ if (value instanceof ExportCell && value.text !== undefined)
992
+ budget.reserve(0, value.text.length);
993
+ }
994
+ let common = 0;
995
+ while (common < active.length && active[common].id === next[common].id)
996
+ common++;
997
+ const pending = [];
998
+ for (let level = common; level < levels.length; level++) {
999
+ const value = next[level], parent = pending.at(-1) ?? active[level - 1];
1000
+ // Parent indexes are generated integers, so scalar strings containing delimiters cannot collide.
1001
+ const scopedId = (parent?.group.groupIndex ?? -1) + ":" + value.id;
1002
+ if (seen.has(scopedId))
1003
+ throw new TypeError("Grouped rows must be contiguous; a closed group key occurred again within the same parent.");
1004
+ if (groups === maxGroups)
1005
+ throw new OfficeIMOError("RESOURCE_LIMIT", "maxGroups exceeded.");
1006
+ const label = labelText(levels[level].label, value.key, value.text);
1007
+ checkAbort(signal);
1008
+ const nextCharacters = characters + scopedId.length + label.length;
1009
+ if (!Number.isSafeInteger(nextCharacters) || nextCharacters > maxCharacters)
1010
+ throw new OfficeIMOError("RESOURCE_LIMIT", "maxGroupKeyCharacters exceeded.");
1011
+ budget.reserve(0, label.length);
1012
+ pending.push({ id: value.id, group: Object.freeze({ groupIndex: groups, key: value.key, label, level }),
1013
+ rows: 0, aggregates: createTotals(columns, totals) });
1014
+ characters = nextCharacters;
1015
+ seen.add(scopedId);
1016
+ groups++;
1017
+ }
1018
+ while (active.length > common) {
1019
+ checkAbort(signal);
1020
+ const path = groupPath(active), ending = active.pop();
1021
+ yield Object.freeze({ kind: "groupEnd", ...path.at(-1), path, rows: ending.rows, totals: result(ending.aggregates) });
1022
+ }
1023
+ for (const opening of pending) {
1024
+ checkAbort(signal);
1025
+ active.push(opening);
1026
+ const path = groupPath(active);
1027
+ yield Object.freeze({ kind: "groupStart", ...path.at(-1), path });
1028
+ }
1029
+ for (let column = 0; column < values.length; column++) {
1030
+ const raw = scalar(values[column]);
1031
+ for (const group of active)
1032
+ group.aggregates[column].accept(raw);
1033
+ grand[column].accept(raw);
1034
+ }
1035
+ for (const group of active)
1036
+ group.rows++;
1037
+ checkAbort(signal);
1038
+ yield Object.freeze({ kind: "row", values: Object.freeze(values), rowIndex: rowCount,
1039
+ groupIndex: active.at(-1).group.groupIndex, path: groupPath(active) });
1040
+ rowCount++;
1041
+ if (taskYieldDue()) {
1042
+ await pause();
1043
+ checkAbort(signal);
1044
+ }
1045
+ }
1046
+ checkAbort(signal);
1047
+ while (active.length) {
1048
+ checkAbort(signal);
1049
+ const path = groupPath(active), ending = active.pop();
1050
+ yield Object.freeze({ kind: "groupEnd", ...path.at(-1), path, rows: ending.rows, totals: result(ending.aggregates) });
1051
+ }
1052
+ checkAbort(signal);
1053
+ yield Object.freeze({ kind: "complete", rows: rowCount, groups, totals: result(grand) });
1054
+ }
1055
+ const source = Object.freeze({ columns: portable, groupBy: Object.freeze(levels.map(level => level.key)), totals, events });
1056
+ sources.set(source, { signal: sourceSignal, events: eventsFor });
1057
+ return source;
1058
+ }
1059
+ const _exports = Object.freeze({ assertGroupedReportSource: assertGroupedReportSource, groupedReportEvents: groupedReportEvents, groupedReportOperation: groupedReportOperation, createGroupedReport: createGroupedReport });
1060
+ _modules.set("046b305cdccf817d847addb75a778131622de23f2840830bbe1c0c26053a68c0", _exports);
1061
+ return _exports;
1062
+ })();
1063
+
1064
+ const _m16 = _modules.get("81b3d47c02b7d8443b79e02b3cfb52032d6b73d9a3fb592b777ebe028ad0ef00") ?? (() => {
1065
+
1066
+
1067
+
1068
+
1069
+
1070
+
1071
+
1072
+
1073
+
1074
+
1075
+ const { OfficeIMOError } = _m3;
1076
+
1077
+ /** Feature detection has no import-time DOM or compressor side effects. */
1078
+ function detectFeatures() {
1079
+ let deflateRaw = false;
1080
+ if (typeof CompressionStream === "function") {
1081
+ try {
1082
+ new CompressionStream("deflate-raw");
1083
+ deflateRaw = true;
1084
+ }
1085
+ catch { /* stored fallback */ }
1086
+ }
1087
+ return { blob: typeof Blob === "function", streams: typeof WritableStream === "function", deflateRaw,
1088
+ download: typeof document !== "undefined" && typeof URL.createObjectURL === "function" };
1089
+ }
1090
+ /** Browser download helper. Workers and Node should deliver the Blob themselves. */
1091
+ function saveBlob(blob, fileName) {
1092
+ if (!(blob instanceof Blob) || typeof fileName !== "string" || !fileName)
1093
+ throw new TypeError("A Blob and file name are required.");
1094
+ if (typeof document === "undefined" || typeof URL.createObjectURL !== "function")
1095
+ throw new OfficeIMOError("PLATFORM_UNAVAILABLE", "saveBlob requires a browser document and object URLs.");
1096
+ const url = URL.createObjectURL(blob), link = document.createElement("a");
1097
+ try {
1098
+ link.href = url;
1099
+ link.download = fileName;
1100
+ document.body.append(link);
1101
+ link.click();
1102
+ }
1103
+ finally {
1104
+ link.remove();
1105
+ setTimeout(() => URL.revokeObjectURL(url), 30000);
1106
+ }
1107
+ }
1108
+ const _exports = Object.freeze({ OfficeIMOError: _m3.OfficeIMOError, NotSupportedError: _m3.NotSupportedError, BlobByteSink: _m2.BlobByteSink, ChunkedTextSink: _m2.ChunkedTextSink, writeBytes: _m2.writeBytes, ExportCell: _m6.ExportCell, createGroupedReport: _m17.createGroupedReport, checkAbort: _m1.checkAbort, withAbort: _m1.withAbort, inputRows: _m1.inputRows, pause: _m1.pause, detectFeatures: detectFeatures, saveBlob: saveBlob });
1109
+ _modules.set("81b3d47c02b7d8443b79e02b3cfb52032d6b73d9a3fb592b777ebe028ad0ef00", _exports);
1110
+ return _exports;
1111
+ })();
1112
+
1113
+ const _m0 = _modules.get("b6dbf755b495baef5c7d7651e6a55b2098f2ee304edca2c8b285a0bd7ec127a1") ?? (() => {
1114
+ const { beginTask, checkAbort, consumeRows, taskYieldDue, withAbort } = _m1;
1115
+
1116
+ const { BlobByteSink, ChunkedTextSink, withDestination } = _m2;
1117
+
1118
+ const { ExportBudget, boundedSink } = _m4;
1119
+
1120
+ const { ExportCell } = _m6;
1121
+
1122
+ const { isDate } = _m7;
1123
+
1124
+ const { notifyProgress } = _m9;
1125
+
1126
+ const { copyColumns, createRowProjector } = _m10;
1127
+
1128
+ const { csvStructuredRows } = _m11;
1129
+
1130
+ const { captureBooleanText } = _m14;
1131
+
1132
+ const { captureCsvOptions } = _m15;
1133
+
1134
+
1135
+
1136
+
1137
+
1138
+ function csvField(value, delimiter, protect, quote, booleanText, nullValue) {
1139
+ if (value == null && nullValue !== undefined)
1140
+ value = nullValue;
1141
+ let text;
1142
+ if (value == null)
1143
+ text = "";
1144
+ else if (isDate(value))
1145
+ text = Number.isFinite(value.getTime()) ? value.toISOString() : "";
1146
+ else if (typeof value === "boolean")
1147
+ text = booleanText[value ? "true" : "false"];
1148
+ else if (typeof value === "number")
1149
+ text = Number.isFinite(value) ? String(value) : "";
1150
+ else if (typeof value === "string")
1151
+ text = value;
1152
+ else {
1153
+ if (typeof value.then === "function")
1154
+ void Promise.resolve(value).catch(() => { });
1155
+ throw new TypeError("CSV cells and formatter results must be synchronous strings, numbers, booleans, Dates or null.");
1156
+ }
1157
+ if (protect && (typeof value === "string" || typeof value === "boolean") && /^ *[=+\-@\t\r\n]/.test(text))
1158
+ text = "'" + text;
1159
+ return quote === "all" || (quote === "strings" && typeof value === "string") || text.includes(delimiter) || /["\r\n]/.test(text)
1160
+ ? '"' + text.replace(/"/g, '""') + '"' : text;
1161
+ }
1162
+ async function writeCsvTo(rows, destination, configuration) {
1163
+ const options = captureCsvOptions(configuration);
1164
+ return withDestination(destination, sink => write(rows, sink, options));
1165
+ }
1166
+ async function write(rows, sink, options) {
1167
+ beginTask();
1168
+ const columns = copyColumns(options.columns).map(c => Object.freeze(c)), delimiter = options.delimiter ?? ",", lineEnding = options.lineEnding ?? "\r\n", quote = options.quote ?? "minimal";
1169
+ const booleanText = captureBooleanText(options.booleanText);
1170
+ if (![",", ";", "\t"].includes(delimiter))
1171
+ throw new RangeError("Delimiter must be comma, semicolon or tab.");
1172
+ if (!["\r\n", "\n", "\r"].includes(lineEnding))
1173
+ throw new RangeError("Invalid line ending.");
1174
+ if (!["minimal", "all", "strings"].includes(quote))
1175
+ throw new RangeError("Quoting must be minimal, all or strings.");
1176
+ if (options.valueMode !== undefined && !["raw", "display"].includes(options.valueMode))
1177
+ throw new RangeError("valueMode must be raw or display.");
1178
+ if (options.nullValue !== undefined && typeof options.nullValue !== "string")
1179
+ throw new TypeError("nullValue must be a string.");
1180
+ if (options.spanMode !== undefined && options.spanMode !== "repeat" && options.spanMode !== "anchors")
1181
+ throw new TypeError("CSV spanMode must be repeat or anchors.");
1182
+ const headings = options.includeHeader === false ? [] : options.headerRows === undefined ? columns.length ? [columns.map(c => c.header)] : [] : csvStructuredRows(options.headerRows, columns.length, options.spanMode);
1183
+ const footers = options.footer === undefined ? [] : csvStructuredRows(options.footer.rows, columns.length, options.spanMode);
1184
+ for (const column of columns)
1185
+ if (column.valueFormatter !== undefined && typeof column.valueFormatter !== "function")
1186
+ throw new TypeError("CSV value formatters must be functions.");
1187
+ const budget = new ExportBudget(options.limits);
1188
+ let bytes = 0;
1189
+ const accepted = sink;
1190
+ sink = boundedSink({ async write(chunk) { await accepted.write(chunk); bytes += chunk.byteLength; } }, budget);
1191
+ const project = createRowProjector(columns, undefined, options.signal);
1192
+ const hasFormatters = columns.some(column => column.valueFormatter);
1193
+ const signal = options.signal, protect = options.formulaInjectionProtection !== false, buffer = new ChunkedTextSink(sink, signal);
1194
+ checkAbort(signal);
1195
+ if (options.bom)
1196
+ await withAbort(Promise.resolve(sink.write(new Uint8Array([239, 187, 191]))), signal);
1197
+ let count = 0;
1198
+ const resolved = (value) => value !== null && typeof value === "object" && value instanceof ExportCell ? options.valueMode === "display" && value.text !== undefined ? value.text : value.value : value;
1199
+ function record(values, header = false, first = 0, snapshot) {
1200
+ if (!header && hasFormatters && first === 0)
1201
+ snapshot = Object.freeze(columns.map((_, i) => resolved(values[i])));
1202
+ let text = "";
1203
+ for (let i = first; i < columns.length; i++) {
1204
+ checkAbort(signal);
1205
+ const column = columns[i];
1206
+ const raw = resolved(values[i]);
1207
+ let value = !header && column.valueFormatter ? column.valueFormatter(raw, { rowIndex: count, columnIndex: i, column, values: snapshot }) : raw;
1208
+ if (value == null && options.nullValue !== undefined)
1209
+ value = options.nullValue;
1210
+ budget.cell(typeof value === "boolean" ? booleanText[value ? "true" : "false"] : value);
1211
+ checkAbort(signal);
1212
+ text += (i ? delimiter : "") + csvField(value, delimiter, protect, quote, booleanText, options.nullValue);
1213
+ if (text.length >= buffer.chunkSize || (i & 127) === 127 && taskYieldDue()) {
1214
+ if (buffer.append(text))
1215
+ return buffer.flush().then(() => record(values, header, i + 1, snapshot));
1216
+ text = "";
1217
+ }
1218
+ }
1219
+ if (buffer.append(text + lineEnding))
1220
+ return buffer.flush().then(() => { notifyProgress(options.onProgress, { phase: "rows", rows: count + (header ? 0 : 1) }); });
1221
+ }
1222
+ for (const heading of headings)
1223
+ await record(heading, true);
1224
+ await consumeRows(rows, signal, row => {
1225
+ budget.row(count + 1);
1226
+ const pending = record(project(row, count));
1227
+ if (pending)
1228
+ return pending.then(() => { count++; });
1229
+ count++;
1230
+ });
1231
+ for (const footer of footers)
1232
+ await record(footer, true);
1233
+ await buffer.close();
1234
+ notifyProgress(options.onProgress, { phase: "complete", rows: count, bytes });
1235
+ checkAbort(signal);
1236
+ return { rows: count, columns: columns.length, bytes };
1237
+ }
1238
+ async function writeCsv(rows, configuration) {
1239
+ const options = captureCsvOptions(configuration);
1240
+ const sink = new BlobByteSink();
1241
+ try {
1242
+ let completedRows = 0;
1243
+ await write(rows, sink, { ...options, onProgress: p => {
1244
+ if (p.phase === "complete")
1245
+ completedRows = p.rows;
1246
+ else
1247
+ notifyProgress(options.onProgress, p);
1248
+ } });
1249
+ const blob = sink.toBlob("text/csv;charset=utf-8");
1250
+ notifyProgress(options.onProgress, { phase: "complete", rows: completedRows, bytes: blob.size });
1251
+ checkAbort(options.signal);
1252
+ return blob;
1253
+ }
1254
+ catch (error) {
1255
+ sink.discard();
1256
+ throw error;
1257
+ }
1258
+ }
1259
+ const _exports = Object.freeze({ saveBlob: _m16.saveBlob, ExportCell: _m6.ExportCell, writeCsvTo: writeCsvTo, writeCsv: writeCsv });
1260
+ _modules.set("b6dbf755b495baef5c7d7651e6a55b2098f2ee304edca2c8b285a0bd7ec127a1", _exports);
1261
+ return _exports;
1262
+ })();
1263
+ Object.assign(officeimo, _m0, { core: _m16, csv: _m0 });
1264
+ })(globalThis);