@agile-team/mach-report 2.14.0 → 2.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (282) hide show
  1. package/README.md +26 -16
  2. package/THIRD_PARTY_NOTICES.md +3 -1
  3. package/dist/{ExcelBindingWizard-CLT2p7P3.cjs → ExcelBindingWizard-CP6h2x1f.cjs} +1 -1
  4. package/dist/{ExcelBindingWizard-CvsWR8Ga.js → ExcelBindingWizard-HhB3hAJE.js} +3 -3
  5. package/dist/ParamEditor-CUQLgoxa.cjs +1 -0
  6. package/dist/ParamEditor-OKesP_nO.js +594 -0
  7. package/dist/{ReportBatchPanel-DkxTzBkD.cjs → ReportBatchPanel-cZCAMAwH.cjs} +1 -1
  8. package/dist/{ReportBatchPanel-LqVgiqp7.js → ReportBatchPanel-ruxcbfY6.js} +39 -39
  9. package/dist/ReportPreview-BcDKCLiK.js +4834 -0
  10. package/dist/ReportPreview-Bk9nLfO9.cjs +6 -0
  11. package/dist/{ReportTemplateLibrary-cQ1sqNYo.cjs → ReportTemplateLibrary-BDlNT8JN.cjs} +1 -1
  12. package/dist/{ReportTemplateLibrary-MjWEtc7X.js → ReportTemplateLibrary-DcwrH-63.js} +1 -1
  13. package/dist/{RuleEditor-BaR6xUiI.cjs → RuleEditor-BX5S8RSF.cjs} +1 -1
  14. package/dist/{RuleEditor-ChuXMlei.js → RuleEditor-CGl9XY2s.js} +5 -5
  15. package/dist/{TemplateOutlinePanel-BHKP89Xz.cjs → TemplateOutlinePanel-CGrT5DFN.cjs} +1 -1
  16. package/dist/{TemplateOutlinePanel-Dci6aRn1.js → TemplateOutlinePanel-SXCjaPKR.js} +2 -2
  17. package/dist/{TemplateReusePanel-CY5eO2Sh.cjs → TemplateReusePanel-6Z3wRFz8.cjs} +1 -1
  18. package/dist/{TemplateReusePanel-B7Gmyc1z.js → TemplateReusePanel-lHLOS9Wn.js} +2 -2
  19. package/dist/{TemplateReviewPanel-DjlX3xpt.js → TemplateReviewPanel-CJ9PLc48.js} +2 -2
  20. package/dist/{TemplateReviewPanel-JvZe9_4G.cjs → TemplateReviewPanel-Dpk7sLcF.cjs} +1 -1
  21. package/dist/analytics.cjs +1 -1
  22. package/dist/analytics.d.cts +5 -1
  23. package/dist/analytics.d.ts +5 -1
  24. package/dist/analytics.js +154 -60
  25. package/dist/artifact-integrity.json +143 -0
  26. package/dist/assets-CqIbfbTr.js +126 -0
  27. package/dist/assets-e4YSke8n.cjs +1 -0
  28. package/dist/auto-YR7a4BtF.js +240 -0
  29. package/dist/auto-uVBjX1j5.cjs +1 -0
  30. package/dist/batch-WzDIXJAt.js +220 -0
  31. package/dist/batch-z6Aw5GEY.cjs +1 -0
  32. package/dist/capabilities-DDwXr_cA.js +103 -0
  33. package/dist/capabilities-DNLyZdNw.cjs +1 -0
  34. package/dist/codes.d.cts +4 -0
  35. package/dist/codes.d.ts +4 -0
  36. package/dist/component-tree-Ca6YYfHq.js +61 -0
  37. package/dist/component-tree-DkGLEfZC.cjs +1 -0
  38. package/dist/{computed-Bvk0W15F.js → computed-C-4C2S5h.js} +3 -3
  39. package/dist/config-Dg_o8e7m.cjs +1 -0
  40. package/dist/config-XQ4qrQ7Q.js +844 -0
  41. package/dist/designer-BfQSahxq.js +5163 -0
  42. package/dist/designer-CPPdeM5_.cjs +2 -0
  43. package/dist/designer.cjs +1 -1
  44. package/dist/designer.d.cts +197 -16
  45. package/dist/designer.d.ts +197 -16
  46. package/dist/designer.js +1 -1
  47. package/dist/diagnostic-notification-B9K9We3h.cjs +1 -0
  48. package/dist/diagnostic-notification-qGAYZdkB.js +7 -0
  49. package/dist/drill-CsdjgkRM.cjs +1 -0
  50. package/dist/drill-DIGsZfyB.js +145 -0
  51. package/dist/encoding-BOGq4qYL.js +21 -0
  52. package/dist/encoding-BYF9ZTl9.cjs +1 -0
  53. package/dist/{font-loader-DHto6Lra.js → font-loader-CzI1GuBc.js} +1 -1
  54. package/dist/{font-loader-vhCT8znW.cjs → font-loader-EKLzOJxf.cjs} +1 -1
  55. package/dist/index.cjs +8 -9
  56. package/dist/index.d.cts +84 -4
  57. package/dist/index.d.ts +84 -4
  58. package/dist/index.js +829 -833
  59. package/dist/json-snapshot-D6ioHth9.js +1702 -0
  60. package/dist/json-snapshot-DknkjvxP.cjs +2 -0
  61. package/dist/licenses/_bwip-js_generic-4.11.4.txt +24 -0
  62. package/dist/licenses/_fast-csv_format-4.3.5.txt +22 -0
  63. package/dist/licenses/_fast-csv_parse-4.3.6.txt +22 -0
  64. package/dist/licenses/_pdf-lib_fontkit-1.1.1.txt +326 -0
  65. package/dist/licenses/_pdf-lib_standard-fonts-1.0.0.txt +22 -0
  66. package/dist/licenses/_pdf-lib_upng-1.0.1.txt +22 -0
  67. package/dist/licenses/_types_node-14.18.63.txt +22 -0
  68. package/dist/licenses/_types_pako-2.0.3.txt +22 -0
  69. package/dist/licenses/_types_pegjs-0.10.6.txt +22 -0
  70. package/dist/licenses/archiver-5.3.2.txt +23 -0
  71. package/dist/licenses/archiver-utils-2.1.0.txt +23 -0
  72. package/dist/licenses/archiver-utils-3.0.4.txt +23 -0
  73. package/dist/licenses/async-3.2.6.txt +20 -0
  74. package/dist/licenses/balanced-match-1.0.2.txt +22 -0
  75. package/dist/licenses/base64-js-1.5.1.txt +22 -0
  76. package/dist/licenses/big-integer-1.6.52.txt +25 -0
  77. package/dist/licenses/binary-0.3.0.txt +178 -0
  78. package/dist/licenses/bl-4.1.0.txt +14 -0
  79. package/dist/licenses/bluebird-3.4.7.txt +22 -0
  80. package/dist/licenses/brace-expansion-1.1.21.txt +22 -0
  81. package/dist/licenses/brace-expansion-2.1.7.txt +22 -0
  82. package/dist/licenses/buffer-5.7.1.txt +22 -0
  83. package/dist/licenses/buffer-crc32-0.2.13.txt +20 -0
  84. package/dist/licenses/buffer-indexof-polyfill-1.0.2.txt +23 -0
  85. package/dist/licenses/buffers-0.1.1.txt +140 -0
  86. package/dist/licenses/chainsaw-0.1.0.txt +184 -0
  87. package/dist/licenses/compress-commons-4.1.2.txt +23 -0
  88. package/dist/licenses/concat-map-0.0.1.txt +19 -0
  89. package/dist/licenses/core-util-is-1.0.3.txt +20 -0
  90. package/dist/licenses/crc-32-1.2.2.txt +202 -0
  91. package/dist/licenses/crc32-stream-4.0.3.txt +23 -0
  92. package/dist/licenses/dayjs-1.11.23.txt +22 -0
  93. package/dist/licenses/duplexer2-0.1.4.txt +27 -0
  94. package/dist/licenses/end-of-stream-1.4.5.txt +22 -0
  95. package/dist/licenses/exceljs-4.4.0.txt +23 -0
  96. package/dist/licenses/fast-csv-4.3.6.txt +22 -0
  97. package/dist/licenses/fast-png-6.4.0.txt +22 -0
  98. package/dist/licenses/fs-constants-1.0.0.txt +22 -0
  99. package/dist/licenses/fs.realpath-1.0.0.txt +44 -0
  100. package/dist/licenses/fstream-1.0.12.txt +16 -0
  101. package/dist/licenses/glob-7.2.3.txt +22 -0
  102. package/dist/licenses/graceful-fs-4.2.11.txt +16 -0
  103. package/dist/licenses/ieee754-1.2.1.txt +12 -0
  104. package/dist/licenses/immediate-3.0.6.txt +21 -0
  105. package/dist/licenses/inflight-1.0.6.txt +16 -0
  106. package/dist/licenses/inherits-2.0.4.txt +17 -0
  107. package/dist/licenses/iobuffer-5.4.0.txt +23 -0
  108. package/dist/licenses/isarray-1.0.0.txt +61 -0
  109. package/dist/licenses/jszip-3.10.2.txt +652 -0
  110. package/dist/licenses/lazystream-1.0.1.txt +24 -0
  111. package/dist/licenses/lie-3.3.0.txt +8 -0
  112. package/dist/licenses/listenercount-1.0.1.txt +6 -0
  113. package/dist/licenses/lodash.defaults-4.2.0.txt +48 -0
  114. package/dist/licenses/lodash.difference-4.5.0.txt +48 -0
  115. package/dist/licenses/lodash.escaperegexp-4.1.2.txt +48 -0
  116. package/dist/licenses/lodash.flatten-4.4.0.txt +48 -0
  117. package/dist/licenses/lodash.groupby-4.6.0.txt +48 -0
  118. package/dist/licenses/lodash.isboolean-3.0.3.txt +23 -0
  119. package/dist/licenses/lodash.isequal-4.5.0.txt +48 -0
  120. package/dist/licenses/lodash.isfunction-3.0.9.txt +48 -0
  121. package/dist/licenses/lodash.isnil-4.0.0.txt +23 -0
  122. package/dist/licenses/lodash.isplainobject-4.0.6.txt +48 -0
  123. package/dist/licenses/lodash.isundefined-3.0.1.txt +23 -0
  124. package/dist/licenses/lodash.union-4.6.0.txt +48 -0
  125. package/dist/licenses/lodash.uniq-4.5.0.txt +48 -0
  126. package/dist/licenses/minimatch-3.1.5.txt +16 -0
  127. package/dist/licenses/minimatch-5.1.9.txt +16 -0
  128. package/dist/licenses/minimist-1.2.8.txt +19 -0
  129. package/dist/licenses/mkdirp-0.5.6.txt +22 -0
  130. package/dist/licenses/node-sql-parser-5.4.0.txt +202 -0
  131. package/dist/licenses/normalize-path-3.0.0.txt +22 -0
  132. package/dist/licenses/once-1.4.0.txt +16 -0
  133. package/dist/licenses/pako-1.0.11.txt +22 -0
  134. package/dist/licenses/pako-2.2.0.txt +22 -0
  135. package/dist/licenses/path-is-absolute-1.0.1.txt +22 -0
  136. package/dist/licenses/pdf-lib-1.17.1.txt +22 -0
  137. package/dist/licenses/process-nextick-args-2.0.1.txt +20 -0
  138. package/dist/licenses/readable-stream-2.3.8.txt +48 -0
  139. package/dist/licenses/readable-stream-3.6.2.txt +48 -0
  140. package/dist/licenses/readdir-glob-1.1.3.txt +202 -0
  141. package/dist/licenses/rimraf-2.7.1.txt +16 -0
  142. package/dist/licenses/safe-buffer-5.1.2.txt +22 -0
  143. package/dist/licenses/safe-buffer-5.2.1.txt +22 -0
  144. package/dist/licenses/saxes-5.0.1.txt +397 -0
  145. package/dist/licenses/setimmediate-1.0.5.txt +21 -0
  146. package/dist/licenses/string_decoder-1.1.1.txt +49 -0
  147. package/dist/licenses/string_decoder-1.3.0.txt +49 -0
  148. package/dist/licenses/tar-stream-2.2.0.txt +22 -0
  149. package/dist/licenses/tmp-0.2.7.txt +22 -0
  150. package/dist/licenses/traverse-0.3.9.txt +25 -0
  151. package/dist/licenses/tslib-1.14.1.txt +13 -0
  152. package/dist/licenses/unzipper-0.10.14.txt +26 -0
  153. package/dist/licenses/util-deprecate-1.0.2.txt +25 -0
  154. package/dist/licenses/uuid-11.1.1.txt +10 -0
  155. package/dist/licenses/wrappy-1.0.2.txt +16 -0
  156. package/dist/licenses/xmlchars-2.2.0.txt +19 -0
  157. package/dist/licenses/zip-stream-4.1.1.txt +23 -0
  158. package/dist/matrix-CGRGkn5s.js +112 -0
  159. package/dist/matrix-gEO7ZM_u.cjs +1 -0
  160. package/dist/media-B7vnpD8k.cjs +1 -0
  161. package/dist/media-Y90dHK9z.js +70 -0
  162. package/dist/param-validation-C3HlcLLO.cjs +1 -0
  163. package/dist/param-validation-Do7Eg8Zv.js +181 -0
  164. package/dist/{pdf-AyJGb22z.cjs → pdf-ByVCb1i6.cjs} +49 -49
  165. package/dist/{pdf-8UPQebOE.js → pdf-DJ5S6ukC.js} +4924 -4872
  166. package/dist/pdf.cjs +1 -1
  167. package/dist/pdf.d.cts +20 -3
  168. package/dist/pdf.d.ts +20 -3
  169. package/dist/pdf.js +2 -2
  170. package/dist/{plugin-BGKf-Tqg.js → plugin-C2j5_mhx.js} +2 -2
  171. package/dist/{plugin-CktLH_Iy.cjs → plugin-Dr39GBRG.cjs} +1 -1
  172. package/dist/prepared-DdrjLC7L.cjs +1 -0
  173. package/dist/prepared-DqtpvRTn.js +87 -0
  174. package/dist/progress-B0ctFpKf.cjs +1 -0
  175. package/dist/progress-BXzlVbIp.js +29 -0
  176. package/dist/progress-DJBd9Rb9.cjs +1 -0
  177. package/dist/progress-Hc2vxoCs.js +52 -0
  178. package/dist/protocol-BzwMP4Vw.cjs +1 -0
  179. package/dist/protocol-kt4Iy6-3.js +90 -0
  180. package/dist/record-bindings-CZWBJ1fU.js +195 -0
  181. package/dist/record-bindings-DUX1VMlR.cjs +1 -0
  182. package/dist/{region-binding-workflow-DEJbhpCv.js → region-binding-workflow-CWNvIjkV.js} +1 -1
  183. package/dist/{region-binding-workflow-BzfbxRiR.cjs → region-binding-workflow-CqSMxQ4p.cjs} +1 -1
  184. package/dist/report-encoding-worker.cjs +1 -0
  185. package/dist/report-encoding-worker.d.ts +1 -0
  186. package/dist/report-encoding-worker.js +2 -0
  187. package/dist/{report-params-B44imUd4.js → report-params-B1RzkhJj.js} +1 -1
  188. package/dist/{report-params-SJfhKgaX.cjs → report-params-WDGrA4oP.cjs} +1 -1
  189. package/dist/rich-text-layout-ALlMoYOG.cjs +3 -0
  190. package/dist/rich-text-layout-Ct5WrY1g.js +102 -0
  191. package/dist/runtime-BjKBI530.js +168 -0
  192. package/dist/runtime-CBFEPKEs.cjs +1 -0
  193. package/dist/sbom.cdx.json +3982 -0
  194. package/dist/server/node.d.cts +106 -2
  195. package/dist/server/node.d.ts +106 -2
  196. package/dist/server-node.cjs +5 -1
  197. package/dist/server-node.js +4634 -539
  198. package/dist/server.cjs +1 -1
  199. package/dist/server.d.cts +780 -5
  200. package/dist/server.d.ts +780 -5
  201. package/dist/server.js +773 -691
  202. package/dist/sha256-BshdOkCC.cjs +1 -0
  203. package/dist/sha256-DTG-Gq8i.js +157 -0
  204. package/dist/style-67OqfNed.js +73 -0
  205. package/dist/style-C22Pbv3T.cjs +1 -0
  206. package/dist/style.css +1 -1
  207. package/dist/template-bindings-C2SpvsMU.js +58 -0
  208. package/dist/template-bindings-CEtWyiLX.cjs +1 -0
  209. package/dist/template-catalog-BtR2JmCL.js +414 -0
  210. package/dist/template-catalog-C2NLdrwB.cjs +1 -0
  211. package/dist/{template-fragments-DFUpq5QM.cjs → template-fragments-BVsbxs4a.cjs} +1 -1
  212. package/dist/{template-fragments-CLkGo6To.js → template-fragments-By0aZC1D.js} +21 -21
  213. package/dist/{template-outline-B3xVkzSv.cjs → template-outline-BwRV_eRo.cjs} +1 -1
  214. package/dist/{template-outline-CFenM1PV.js → template-outline-cnWfT_LK.js} +3 -3
  215. package/dist/template-registry-C62vpv4a.cjs +1 -0
  216. package/dist/template-registry-Cw3vRTX2.js +801 -0
  217. package/dist/textwrap-BEIg2w8y.js +110 -0
  218. package/dist/textwrap-BI-yJ6Wt.cjs +4 -0
  219. package/dist/{tree-CqcQ99NM.js → tree-CjVZLRw7.js} +1 -1
  220. package/dist/vue/async.d.cts +189 -14
  221. package/dist/vue/async.d.ts +189 -14
  222. package/dist/vue/index.d.cts +246 -22
  223. package/dist/vue/index.d.ts +246 -22
  224. package/dist/vue-async.cjs +1 -1
  225. package/dist/vue-async.js +3 -3
  226. package/dist/vue.cjs +1 -1
  227. package/dist/vue.js +80 -78
  228. package/dist/{workbook-session-BfK1yHOO.js → workbook-session-BeSO8PFB.js} +5460 -5295
  229. package/dist/{workbook-session-DNa2RHNG.cjs → workbook-session-Cbts-22R.cjs} +19 -19
  230. package/dist/worker.cjs +1 -1
  231. package/dist/worker.d.cts +104 -2
  232. package/dist/worker.d.ts +104 -2
  233. package/dist/worker.js +12 -156
  234. package/dist/xlsx-node.cjs +35 -35
  235. package/dist/xlsx-node.js +2138 -2137
  236. package/dist/xlsx.cjs +4 -4
  237. package/dist/xlsx.d.cts +24 -10
  238. package/dist/xlsx.d.ts +24 -10
  239. package/dist/xlsx.js +303 -277
  240. package/package.json +7 -4
  241. package/dist/ParamEditor-CflQV3eQ.js +0 -526
  242. package/dist/ParamEditor-vIDzvpPV.cjs +0 -1
  243. package/dist/ReportPreview-CvbqLUzM.cjs +0 -6
  244. package/dist/ReportPreview-D_ywJ_-H.js +0 -4533
  245. package/dist/assets-C2U-e-Sz.cjs +0 -4
  246. package/dist/assets-Q0wUwNrV.js +0 -217
  247. package/dist/batch-DzaTNLWI.js +0 -371
  248. package/dist/batch-xMkqYiTr.cjs +0 -1
  249. package/dist/capabilities-CK_7hizc.js +0 -63
  250. package/dist/capabilities-CsZ-pNHR.cjs +0 -1
  251. package/dist/config-0UIohTS7.cjs +0 -1
  252. package/dist/config-Dt9NtCPl.js +0 -566
  253. package/dist/data-explanation-BktvER5B.cjs +0 -1
  254. package/dist/data-explanation-C_J6jYNi.js +0 -16
  255. package/dist/defaults-DXhiM1ZD.js +0 -10
  256. package/dist/defaults-xhmcLLrf.cjs +0 -1
  257. package/dist/designer-Ci1LizA9.js +0 -5020
  258. package/dist/designer-rtmVIIdN.cjs +0 -2
  259. package/dist/grid-strokes-Cr7DwUux.cjs +0 -1
  260. package/dist/grid-strokes-DyyG1q_o.js +0 -53
  261. package/dist/json-snapshot-BeFT3Tso.js +0 -1952
  262. package/dist/json-snapshot-D1NTP2oI.cjs +0 -2
  263. package/dist/matrix-DVyWiYsd.cjs +0 -1
  264. package/dist/matrix-yZsGnldA.js +0 -227
  265. package/dist/page-window-index-CIuT4BAv.js +0 -43
  266. package/dist/page-window-index-DEjnM6IB.cjs +0 -1
  267. package/dist/param-validation-BlHHXs6u.js +0 -153
  268. package/dist/param-validation-DCK039V1.cjs +0 -1
  269. package/dist/progress-7OSZbFok.js +0 -39
  270. package/dist/progress-BnLiS5eH.cjs +0 -1
  271. package/dist/render-plan-7xpGrCEl.cjs +0 -1
  272. package/dist/render-plan-Ck6koX9L.js +0 -13
  273. package/dist/style-CQ1PK8ZB.js +0 -67
  274. package/dist/style-UgIJSA1F.cjs +0 -1
  275. package/dist/task-events-DQ276fn2.cjs +0 -1
  276. package/dist/task-events-Dpsvf_t2.js +0 -47
  277. package/dist/template-bindings-BJR4k7qZ.cjs +0 -1
  278. package/dist/template-bindings-Daui7hLF.js +0 -252
  279. package/dist/template-registry-COXDEJEM.js +0 -570
  280. package/dist/template-registry-D3SjENi6.cjs +0 -1
  281. package/dist/validate-BJ5HIWY8.cjs +0 -1
  282. package/dist/validate-CkQBWCeg.js +0 -163
@@ -0,0 +1,126 @@
1
+ import { b as I } from "./component-tree-Ca6YYfHq.js";
2
+ import { n as b } from "./diagnostic-notification-qGAYZdkB.js";
3
+ import { b as w, w as v } from "./progress-Hc2vxoCs.js";
4
+ import { c as E, I as x } from "./media-Y90dHK9z.js";
5
+ class p extends Error {
6
+ constructor(e, r) {
7
+ super(e.message), this.name = "OutputAssetError", this.diagnostic = e, this.cause = r;
8
+ }
9
+ }
10
+ function h(n) {
11
+ if (n.aborted) throw n.reason ?? new DOMException("The operation was aborted.", "AbortError");
12
+ }
13
+ function A(n) {
14
+ const e = { maxAssets: 1e3, maxImageBytes: 33554432, maxTotalImageBytes: 134217728, maxDurationMs: 3e4, ...n.assetBudget };
15
+ for (const [r, i] of Object.entries(e))
16
+ if (!Number.isSafeInteger(i) || i <= 0 || i > 2147483647) throw new RangeError(`${r} must be a positive safe integer at most 2147483647.`);
17
+ return e;
18
+ }
19
+ function D(n) {
20
+ const e = /^data:image\/[a-z0-9.+-]+(;base64)?,(.*)$/is.exec(n);
21
+ if (!e) throw new TypeError("Asset renderers must return an image data URL.");
22
+ return e[1] ? Math.ceil(e[2].length * 3 / 4) : new TextEncoder().encode(decodeURIComponent(e[2])).byteLength;
23
+ }
24
+ function l(n, e, r, i, s) {
25
+ const t = { code: r, message: i, severity: "warning", format: n.options.format ?? "dom", pageIndex: e.pageIndex, componentIndex: e.componentIndex, componentPath: e.componentPath, kind: e.component.kind, nid: e.component.nid };
26
+ if (n.diagnostics.push(t), b(t, { ...n.options, signal: n.signal }), n.options.assetFailure !== "placeholder") throw new p(t, s);
27
+ }
28
+ async function O(n, e, r) {
29
+ const i = n.options.assetRenderers?.[e.kind];
30
+ if (e.imageData || !i) return e.imageData;
31
+ if (++n.rendered > n.budget.maxAssets) return l(n, r, "asset-budget-exceeded", "Output exceeded the asset count budget.");
32
+ let s;
33
+ try {
34
+ if (n.active = r, s = await v(i({ ...r, signal: n.signal }), n.signal), h(n.signal), s.length > n.budget.maxImageBytes * 4 + 1024) return l(n, r, "asset-budget-exceeded", "Output exceeded the image payload byte budget.");
35
+ const t = D(s);
36
+ if (t > n.budget.maxImageBytes || n.bytes + t > n.budget.maxTotalImageBytes) return l(n, r, "asset-budget-exceeded", "Output exceeded the encoded image byte budget.");
37
+ /^data:image\/(png|jpe?g);base64,/i.test(s) && n.inspectImage(s), n.bytes += t;
38
+ } catch (t) {
39
+ if (n.signal.aborted || t instanceof p || t instanceof x && t.code === "image-budget-exceeded") throw t;
40
+ return l(n, r, "asset-render-failed", `Asset renderer failed for ${e.kind}; output was not silently omitted.`, t);
41
+ }
42
+ return s;
43
+ }
44
+ function M(n, e) {
45
+ const r = n.active;
46
+ if (!r) {
47
+ e.abort(new Error("Asset rendering exceeded maxDurationMs."));
48
+ return;
49
+ }
50
+ const i = { code: "asset-budget-exceeded", message: "Asset rendering exceeded maxDurationMs.", severity: "warning", format: n.options.format ?? "dom", pageIndex: r.pageIndex, componentIndex: r.componentIndex, componentPath: r.componentPath, kind: r.component.kind, nid: r.component.nid };
51
+ n.diagnostics.push(i);
52
+ try {
53
+ b(i, { ...n.options, signal: n.signal });
54
+ } catch (s) {
55
+ e.abort(s);
56
+ return;
57
+ }
58
+ e.abort(new p(i));
59
+ }
60
+ async function T(n, e, r, i, s) {
61
+ if (!e?.children?.length) return e;
62
+ const t = [];
63
+ for (const [a, d] of e.children.entries())
64
+ t.push(await y(n, d, { ...r, component: d, componentPath: [...i, a] }, s));
65
+ return t.some((a, d) => a !== e.children[d]) ? { ...e, children: t } : e;
66
+ }
67
+ async function y(n, e, r, i) {
68
+ if (h(n.signal), i.has(e)) throw new TypeError("Cyclic grid children cannot be rendered.");
69
+ let s = n.cache.get(e);
70
+ s || (s = O(n, e, r), n.cache.set(e, s));
71
+ const t = await s;
72
+ h(n.signal);
73
+ let a = e.grid;
74
+ if (a) {
75
+ const d = new Set(i).add(e), c = [];
76
+ for (const [g, o] of a.cells.entries()) {
77
+ const u = [];
78
+ for (const [m, f] of o.entries()) u.push(await T(n, f, r, [...r.componentPath, g, m], d));
79
+ c.push(u);
80
+ }
81
+ c.some((g, o) => g.some((u, m) => u !== a.cells[o][m])) && (a = { ...a, cells: c });
82
+ }
83
+ return t !== e.imageData || a !== e.grid ? { ...e, imageData: t, grid: a } : e;
84
+ }
85
+ function k(n, e, r) {
86
+ const i = /* @__PURE__ */ new Set(), s = (t) => {
87
+ if (w(r), !i.has(t)) {
88
+ if (i.add(t), t.imageData && /^data:image\/(png|jpe?g);base64,/i.test(t.imageData))
89
+ try {
90
+ e(t.imageData);
91
+ } catch (a) {
92
+ if (!(a instanceof x) || a.code === "image-budget-exceeded") throw a;
93
+ }
94
+ for (const a of t.grid?.cells ?? []) for (const d of a) for (const c of d?.children ?? []) s(c);
95
+ }
96
+ };
97
+ for (const t of n.pages) for (const a of t.components) s(a);
98
+ }
99
+ async function L(n, e = {}) {
100
+ w(e.signal), I(n);
101
+ const r = A(e), i = E(e);
102
+ if (k(n, i, e.signal), e.signal?.aborted) throw e.signal.reason ?? new DOMException("The operation was aborted.", "AbortError");
103
+ const s = new AbortController(), t = () => s.abort(e.signal?.reason);
104
+ if (e.signal?.addEventListener("abort", t, { once: !0 }), !e.assetRenderers || !Object.keys(e.assetRenderers).length)
105
+ return e.signal?.removeEventListener("abort", t), { plan: n, diagnostics: [] };
106
+ const a = { options: e, signal: s.signal, diagnostics: [], rendered: 0, bytes: 0, budget: r, cache: /* @__PURE__ */ new WeakMap(), inspectImage: i }, d = setTimeout(() => M(a, s), r.maxDurationMs);
107
+ try {
108
+ const c = [];
109
+ for (const [g, o] of n.pages.entries()) {
110
+ if (g < (e.start ?? 0) || g > (e.end ?? n.pages.length - 1)) {
111
+ c.push(o);
112
+ continue;
113
+ }
114
+ const u = [];
115
+ for (const [m, f] of o.components.entries()) u.push(await y(a, f, { component: f, pageIndex: g, componentIndex: m, componentPath: [] }, /* @__PURE__ */ new Set()));
116
+ c.push(u.some((m, f) => m !== o.components[f]) ? { ...o, components: u } : o);
117
+ }
118
+ return h(a.signal), { plan: c.some((g, o) => g !== n.pages[o]) ? { ...n, pages: c } : n, diagnostics: a.diagnostics };
119
+ } finally {
120
+ clearTimeout(d), e.signal?.removeEventListener("abort", t);
121
+ }
122
+ }
123
+ export {
124
+ p as O,
125
+ L as r
126
+ };
@@ -0,0 +1 @@
1
+ "use strict";const I=require("./component-tree-DkGLEfZC.cjs"),y=require("./diagnostic-notification-B9K9We3h.cjs"),b=require("./progress-B0ctFpKf.cjs"),w=require("./media-B7vnpD8k.cjs");class p extends Error{constructor(e,r){super(e.message),this.name="OutputAssetError",this.diagnostic=e,this.cause=r}}function h(t){if(t.aborted)throw t.reason??new DOMException("The operation was aborted.","AbortError")}function v(t){const e={maxAssets:1e3,maxImageBytes:33554432,maxTotalImageBytes:134217728,maxDurationMs:3e4,...t.assetBudget};for(const[r,a]of Object.entries(e))if(!Number.isSafeInteger(a)||a<=0||a>2147483647)throw new RangeError(`${r} must be a positive safe integer at most 2147483647.`);return e}function E(t){const e=/^data:image\/[a-z0-9.+-]+(;base64)?,(.*)$/is.exec(t);if(!e)throw new TypeError("Asset renderers must return an image data URL.");return e[1]?Math.ceil(e[2].length*3/4):new TextEncoder().encode(decodeURIComponent(e[2])).byteLength}function l(t,e,r,a,s){const n={code:r,message:a,severity:"warning",format:t.options.format??"dom",pageIndex:e.pageIndex,componentIndex:e.componentIndex,componentPath:e.componentPath,kind:e.component.kind,nid:e.component.nid};if(t.diagnostics.push(n),y.notifyOutputDiagnostic(n,{...t.options,signal:t.signal}),t.options.assetFailure!=="placeholder")throw new p(n,s)}async function A(t,e,r){const a=t.options.assetRenderers?.[e.kind];if(e.imageData||!a)return e.imageData;if(++t.rendered>t.budget.maxAssets)return l(t,r,"asset-budget-exceeded","Output exceeded the asset count budget.");let s;try{if(t.active=r,s=await b.waitForOutput(a({...r,signal:t.signal}),t.signal),h(t.signal),s.length>t.budget.maxImageBytes*4+1024)return l(t,r,"asset-budget-exceeded","Output exceeded the image payload byte budget.");const n=E(s);if(n>t.budget.maxImageBytes||t.bytes+n>t.budget.maxTotalImageBytes)return l(t,r,"asset-budget-exceeded","Output exceeded the encoded image byte budget.");/^data:image\/(png|jpe?g);base64,/i.test(s)&&t.inspectImage(s),t.bytes+=n}catch(n){if(t.signal.aborted||n instanceof p||n instanceof w.ImageMediaError&&n.code==="image-budget-exceeded")throw n;return l(t,r,"asset-render-failed",`Asset renderer failed for ${e.kind}; output was not silently omitted.`,n)}return s}function D(t,e){const r=t.active;if(!r){e.abort(new Error("Asset rendering exceeded maxDurationMs."));return}const a={code:"asset-budget-exceeded",message:"Asset rendering exceeded maxDurationMs.",severity:"warning",format:t.options.format??"dom",pageIndex:r.pageIndex,componentIndex:r.componentIndex,componentPath:r.componentPath,kind:r.component.kind,nid:r.component.nid};t.diagnostics.push(a);try{y.notifyOutputDiagnostic(a,{...t.options,signal:t.signal})}catch(s){e.abort(s);return}e.abort(new p(a))}async function O(t,e,r,a,s){if(!e?.children?.length)return e;const n=[];for(const[i,d]of e.children.entries())n.push(await x(t,d,{...r,component:d,componentPath:[...a,i]},s));return n.some((i,d)=>i!==e.children[d])?{...e,children:n}:e}async function x(t,e,r,a){if(h(t.signal),a.has(e))throw new TypeError("Cyclic grid children cannot be rendered.");let s=t.cache.get(e);s||(s=A(t,e,r),t.cache.set(e,s));const n=await s;h(t.signal);let i=e.grid;if(i){const d=new Set(a).add(e),c=[];for(const[g,o]of i.cells.entries()){const u=[];for(const[m,f]of o.entries())u.push(await O(t,f,r,[...r.componentPath,g,m],d));c.push(u)}c.some((g,o)=>g.some((u,m)=>u!==i.cells[o][m]))&&(i={...i,cells:c})}return n!==e.imageData||i!==e.grid?{...e,imageData:n,grid:i}:e}function M(t,e,r){const a=new Set,s=n=>{if(b.assertOutputActive(r),!a.has(n)){if(a.add(n),n.imageData&&/^data:image\/(png|jpe?g);base64,/i.test(n.imageData))try{e(n.imageData)}catch(i){if(!(i instanceof w.ImageMediaError)||i.code==="image-budget-exceeded")throw i}for(const i of n.grid?.cells??[])for(const d of i)for(const c of d?.children??[])s(c)}};for(const n of t.pages)for(const i of n.components)s(i)}async function T(t,e={}){b.assertOutputActive(e.signal),I.assertBoundedRenderTree(t);const r=v(e),a=w.createImageMediaInspector(e);if(M(t,a,e.signal),e.signal?.aborted)throw e.signal.reason??new DOMException("The operation was aborted.","AbortError");const s=new AbortController,n=()=>s.abort(e.signal?.reason);if(e.signal?.addEventListener("abort",n,{once:!0}),!e.assetRenderers||!Object.keys(e.assetRenderers).length)return e.signal?.removeEventListener("abort",n),{plan:t,diagnostics:[]};const i={options:e,signal:s.signal,diagnostics:[],rendered:0,bytes:0,budget:r,cache:new WeakMap,inspectImage:a},d=setTimeout(()=>D(i,s),r.maxDurationMs);try{const c=[];for(const[g,o]of t.pages.entries()){if(g<(e.start??0)||g>(e.end??t.pages.length-1)){c.push(o);continue}const u=[];for(const[m,f]of o.components.entries())u.push(await x(i,f,{component:f,pageIndex:g,componentIndex:m,componentPath:[]},new Set));c.push(u.some((m,f)=>m!==o.components[f])?{...o,components:u}:o)}return h(i.signal),{plan:c.some((g,o)=>g!==t.pages[o])?{...t,pages:c}:t,diagnostics:i.diagnostics}}finally{clearTimeout(d),e.signal?.removeEventListener("abort",n)}}exports.OutputAssetError=p;exports.resolvePlanAssets=T;
@@ -0,0 +1,240 @@
1
+ import { s as A, c as C, a as q } from "./prepared-DqtpvRTn.js";
2
+ import { E as U } from "./json-snapshot-D6ioHth9.js";
3
+ import { b as T, R as S, v as I, c as $ } from "./protocol-kt4Iy6-3.js";
4
+ import { a as H } from "./progress-Hc2vxoCs.js";
5
+ import { c as N, e as G } from "./runtime-BjKBI530.js";
6
+ import { D as j, R as M, t as R, v as K, b as L, c as W } from "./sha256-DTG-Gq8i.js";
7
+ class O extends Error {
8
+ constructor(r) {
9
+ super("报表 Worker 无法启动"), this.cause = r, this.name = "ReportWorkerStartError";
10
+ }
11
+ }
12
+ let X = 0;
13
+ function D(e) {
14
+ const r = new Error("报表 Worker 任务已取消");
15
+ return r.name = "AbortError", Object.defineProperty(r, "cause", { value: e }), r;
16
+ }
17
+ function J(e, r) {
18
+ if (!e || typeof e != "object") return;
19
+ const t = e;
20
+ return t.protocol === S && t.id === r ? t : void 0;
21
+ }
22
+ function Q(e, r = {}) {
23
+ const t = r.timeoutMs ?? 12e4;
24
+ if (!Number.isFinite(t) || t <= 0 || t > 2147483647) throw new RangeError("Worker timeoutMs 应为正有限数字,且不能超过 2147483647");
25
+ const n = (o, s, a, f) => a?.aborted ? Promise.reject(D(a.reason)) : new Promise((v, i) => {
26
+ let g;
27
+ try {
28
+ g = e();
29
+ } catch (l) {
30
+ i(new O(l));
31
+ return;
32
+ }
33
+ const w = `mach-report-${Date.now()}-${++X}`;
34
+ let m = !1, u = () => {
35
+ }, y;
36
+ const p = (l, c) => {
37
+ if (m) return;
38
+ m = !0, y && clearTimeout(y);
39
+ let b;
40
+ try {
41
+ u();
42
+ } catch (E) {
43
+ b = E;
44
+ }
45
+ a?.removeEventListener("abort", x), l ??= b, Promise.resolve().then(() => g.terminate()).then(
46
+ () => l === void 0 ? v(c) : i(l),
47
+ (E) => i(l ?? E)
48
+ );
49
+ }, x = () => p(D(a?.reason)), d = (l) => {
50
+ const c = J(l, w);
51
+ if (!(!c || m)) {
52
+ if ("type" in c && c.type === "event") {
53
+ const b = "event" in c ? c.event : void 0;
54
+ I(b, s) ? U(f, b, a) : p(new Error("报表 Worker 返回无效阶段事件"));
55
+ return;
56
+ }
57
+ c.error && typeof c.error.name == "string" && typeof c.error.message == "string" ? p(new T(c.error)) : $(c.result, o) && (o === "prepare" || "format" in c.result && "format" in s && c.result.format === s.format) ? p(void 0, c.result) : p(new Error("报表 Worker 返回无效响应"));
58
+ }
59
+ };
60
+ try {
61
+ if (u = g.subscribe(d, (l) => p(l ?? new Error("报表 Worker 执行失败"))), m) {
62
+ u();
63
+ return;
64
+ }
65
+ if (a?.addEventListener("abort", x, { once: !0 }), y = setTimeout(() => p(new T({ name: "ReportRuntimeError", code: "timeout", message: `报表 Worker 执行超过 ${t}ms` })), t), a?.aborted) x();
66
+ else {
67
+ const { onEvent: l, signal: c, ...b } = s, E = V(b);
68
+ g.postMessage({ protocol: S, id: w, operation: o, input: b, ...r.budget ? { budget: r.budget } : {} }, E);
69
+ }
70
+ } catch (l) {
71
+ p(l);
72
+ }
73
+ });
74
+ return { exportPrepared: (o, s, a) => n("exportPrepared", o, s, a), prepare: (o, s, a) => n("prepare", o, s, a), export: (o, s, a) => n("export", o, s, a) };
75
+ }
76
+ function V(e) {
77
+ return e.pdf ? (e.pdf = A(e.pdf), (e.pdf?.customFontFaces ? Object.values(e.pdf.customFontFaces) : [e.pdf?.customFontBytes]).filter((t) => t instanceof Uint8Array).map((t) => t.buffer)) : [];
78
+ }
79
+ function Y(e, r = {}) {
80
+ return Q(() => {
81
+ const t = e();
82
+ return {
83
+ postMessage: (n, o) => t.postMessage(n, o),
84
+ terminate: () => t.terminate(),
85
+ subscribe: (n, o) => {
86
+ const s = (f) => n(f.data), a = (f) => o(f instanceof ErrorEvent ? new Error(f.message) : new Error("报表 Worker 消息无法解码"));
87
+ return t.addEventListener("message", s), t.addEventListener("error", a), t.addEventListener("messageerror", a), () => {
88
+ t.removeEventListener("message", s), t.removeEventListener("error", a), t.removeEventListener("messageerror", a);
89
+ };
90
+ }
91
+ };
92
+ }, r);
93
+ }
94
+ const Z = { cells: 2e4, pages: 20, bytes: 2e6 };
95
+ function P(e) {
96
+ return e.cells >= e.limits.cells || e.pages >= e.limits.pages || e.bytes >= e.limits.bytes || e.capped;
97
+ }
98
+ function k(e) {
99
+ return ++e.visits >= 1e5 && (e.capped = !0), !P(e);
100
+ }
101
+ function h(e) {
102
+ return typeof e == "string" ? e.length * 2 : 0;
103
+ }
104
+ function F(e, r) {
105
+ for (const t of e ?? []) {
106
+ if (!k(r)) return;
107
+ for (const n of t.segments) {
108
+ if (!k(r)) return;
109
+ r.bytes += h(n.text);
110
+ }
111
+ }
112
+ }
113
+ function z(e, r, t) {
114
+ if (t > 32) {
115
+ r.capped = !0;
116
+ return;
117
+ }
118
+ if (k(r)) {
119
+ r.bytes += h(e.text) + h(e.rawText) + h(e.imageData), F(e.richParagraphs, r);
120
+ for (const n of e.lines ?? []) {
121
+ if (!k(r)) return;
122
+ r.bytes += h(n);
123
+ }
124
+ for (const n of e.grid?.cells ?? []) {
125
+ if (!k(r)) return;
126
+ for (const o of n) {
127
+ if (!k(r)) return;
128
+ if (o) {
129
+ r.cells++, r.bytes += h(o.text) + h(o.rawText) + h(o.value), F(o.richParagraphs, r);
130
+ for (const s of o.children ?? []) {
131
+ if (P(r)) return;
132
+ z(s, r, t + 1);
133
+ }
134
+ }
135
+ }
136
+ }
137
+ }
138
+ }
139
+ function ee(e) {
140
+ const r = { ...Z, ...e.thresholds };
141
+ for (const t of Object.values(r)) if (!Number.isSafeInteger(t) || t <= 0) throw new RangeError("导出隔离阈值应为正安全整数");
142
+ return r;
143
+ }
144
+ function re(e, r) {
145
+ const t = ee(r), n = e.pdf?.customFontFaces ? Object.values(e.pdf.customFontFaces) : [e.pdf?.customFontBytes], o = { pages: e.prepared.plan.pages.length, cells: 0, bytes: n.reduce((f, v) => f + (v?.byteLength ?? 0), 0), visits: 0, capped: !1, limits: t };
146
+ for (const f of e.prepared.plan.pages) {
147
+ if (P(o)) break;
148
+ for (const v of f.components) {
149
+ if (P(o)) break;
150
+ z(v, o, 0);
151
+ }
152
+ }
153
+ let s = P(o) ? "worker" : "local", a = o.capped ? "scan-limit" : s === "worker" ? "threshold" : "small-task";
154
+ return r.mode === "local" && (s = "local", a = "explicit-local"), r.mode === "worker" && (s = "worker", a = "explicit-worker"), Object.values(e.xlsx ?? {}).some((f) => typeof f == "function") && (s = "local", a = "nonserializable-options"), { mode: s, reason: a, estimate: { pages: o.pages, cells: o.cells, bytes: o.bytes }, hardCancellation: s === "worker" };
155
+ }
156
+ function te(e) {
157
+ if (e.mode !== void 0 && !["auto", "local", "worker"].includes(e.mode)) throw new TypeError("无效的导出执行模式");
158
+ if (e.fallback !== void 0 && !["local", "error"].includes(e.fallback)) throw new TypeError("无效的导出回退策略");
159
+ K({ ...e.budget, maxDurationMs: e.timeoutMs ?? e.budget?.maxDurationMs ?? 12e4 });
160
+ }
161
+ function _(e, r) {
162
+ H(() => e.onDecision?.({ ...r, estimate: { ...r.estimate } }));
163
+ }
164
+ function B(e, r) {
165
+ return { ...e, mode: "local", reason: r, hardCancellation: !1 };
166
+ }
167
+ function oe(e, r) {
168
+ const t = { ...j, ...r.budget }, n = C(e.prepared, t.maxPreparedBytes, e.signal), o = G(n.prepared, t);
169
+ n.prepared.stats = o.stats;
170
+ const s = { ...e, prepared: n.prepared, pdf: A(e.pdf), xlsx: q(e.xlsx) };
171
+ return { request: s, forward: () => ({ ...s, prepared: n.forward() }) };
172
+ }
173
+ function se(e, r) {
174
+ te(e);
175
+ const t = { ...e, thresholds: { ...e.thresholds }, budget: { ...j, ...e.budget } }, n = t.timeoutMs ?? t.budget.maxDurationMs ?? 12e4, o = N({ reports: {}, budget: { ...t.budget, maxDurationMs: n } }), s = /* @__PURE__ */ new Set();
176
+ let a = !1;
177
+ const f = t.mode !== "worker" && t.fallback !== "error";
178
+ async function v(i, g) {
179
+ const w = Date.now(), m = () => {
180
+ const d = n - (Date.now() - w);
181
+ if (d <= 0) throw new M("timeout", `报表执行超过 ${n}ms`);
182
+ return d;
183
+ };
184
+ let u = re(i, t);
185
+ if (u.reason === "nonserializable-options" && t.mode === "worker") throw new TypeError("Worker 模式不接受函数选项;请使用本地模式或可序列化配置");
186
+ if (u.mode === "worker" && !r) {
187
+ if (!f) throw new O(new Error("未配置 workerFactory"));
188
+ u = B(u, "worker-unavailable");
189
+ }
190
+ const y = oe(i, t), p = y.request;
191
+ if (_(t, u), R(i.signal), u.mode === "worker")
192
+ try {
193
+ const d = r(m());
194
+ if (!d.exportPrepared) throw new TypeError("隔离执行器缺少 exportPrepared");
195
+ const { signal: l, onEvent: c, ...b } = p, E = await d.exportPrepared(b, l, c);
196
+ return R(l), L(t.budget, "maxOutputBytes", E.bytes.byteLength), { ...E, execution: u };
197
+ } catch (d) {
198
+ if (!(d instanceof O) || !f) throw d;
199
+ R(i.signal), u = B(u, "worker-start-failed"), _(t, u);
200
+ }
201
+ const x = g ? await W(i.signal, m(), (d) => g({ ...p, signal: d })) : await W(i.signal, m(), (d) => o.exportPrepared({ ...y.forward(), signal: d }));
202
+ return R(i.signal), L(t.budget, "maxOutputBytes", x.bytes.byteLength), { ...x, execution: u };
203
+ }
204
+ return {
205
+ async exportPrepared(i, g) {
206
+ if (a) throw new M("closed", "导出执行器已释放");
207
+ if (R(i.signal), s.size >= 2) throw new M("queue-full", "同时导出的任务已达 2 个,请等待完成后重试");
208
+ const w = new AbortController();
209
+ s.add(w);
210
+ const m = () => w.abort(i.signal?.reason);
211
+ i.signal?.addEventListener("abort", m, { once: !0 });
212
+ try {
213
+ return await v({ ...i, signal: w.signal }, g);
214
+ } finally {
215
+ i.signal?.removeEventListener("abort", m), s.delete(w);
216
+ }
217
+ },
218
+ cancel() {
219
+ for (const i of s) i.abort();
220
+ },
221
+ dispose() {
222
+ a = !0;
223
+ for (const i of s) i.abort();
224
+ }
225
+ };
226
+ }
227
+ function ne(e = {}) {
228
+ const r = e.workerFactory, t = { timeoutMs: e.timeoutMs ?? e.budget?.maxDurationMs, budget: { ...e.budget } };
229
+ return se(e, r ? (n) => Y(r, { ...t, timeoutMs: n }) : void 0);
230
+ }
231
+ const de = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
232
+ __proto__: null,
233
+ createAutoReportExporter: ne
234
+ }, Symbol.toStringTag, { value: "Module" }));
235
+ export {
236
+ O as R,
237
+ Y as a,
238
+ de as b,
239
+ ne as c
240
+ };
@@ -0,0 +1 @@
1
+ "use strict";const T=require("./prepared-DdrjLC7L.cjs"),S=require("./json-snapshot-DknkjvxP.cjs"),R=require("./protocol-BzwMP4Vw.cjs"),I=require("./progress-B0ctFpKf.cjs"),_=require("./runtime-CBFEPKEs.cjs"),d=require("./sha256-BshdOkCC.cjs");class M extends Error{constructor(r){super("报表 Worker 无法启动"),this.cause=r,this.name="ReportWorkerStartError"}}let j=0;function W(e){const r=new Error("报表 Worker 任务已取消");return r.name="AbortError",Object.defineProperty(r,"cause",{value:e}),r}function U(e,r){if(!e||typeof e!="object")return;const t=e;return t.protocol===R.REPORT_WORKER_PROTOCOL&&t.id===r?t:void 0}function C(e,r={}){const t=r.timeoutMs??12e4;if(!Number.isFinite(t)||t<=0||t>2147483647)throw new RangeError("Worker timeoutMs 应为正有限数字,且不能超过 2147483647");const n=(o,s,a,u)=>a?.aborted?Promise.reject(W(a.reason)):new Promise((v,c)=>{let w;try{w=e()}catch(l){c(new M(l));return}const E=`mach-report-${Date.now()}-${++j}`;let m=!1,f=()=>{},k;const b=(l,i)=>{if(m)return;m=!0,k&&clearTimeout(k);let g;try{f()}catch(h){g=h}a?.removeEventListener("abort",x),l??=g,Promise.resolve().then(()=>w.terminate()).then(()=>l===void 0?v(i):c(l),h=>c(l??h))},x=()=>b(W(a?.reason)),p=l=>{const i=U(l,E);if(!(!i||m)){if("type"in i&&i.type==="event"){const g="event"in i?i.event:void 0;R.validReportWorkerEvent(g,s)?S.notifyReportTaskEvent(u,g,a):b(new Error("报表 Worker 返回无效阶段事件"));return}i.error&&typeof i.error.name=="string"&&typeof i.error.message=="string"?b(new R.ReportWorkerError(i.error)):R.validReportWorkerResult(i.result,o)&&(o==="prepare"||"format"in i.result&&"format"in s&&i.result.format===s.format)?b(void 0,i.result):b(new Error("报表 Worker 返回无效响应"))}};try{if(f=w.subscribe(p,l=>b(l??new Error("报表 Worker 执行失败"))),m){f();return}if(a?.addEventListener("abort",x,{once:!0}),k=setTimeout(()=>b(new R.ReportWorkerError({name:"ReportRuntimeError",code:"timeout",message:`报表 Worker 执行超过 ${t}ms`})),t),a?.aborted)x();else{const{onEvent:l,signal:i,...g}=s,h=z(g);w.postMessage({protocol:R.REPORT_WORKER_PROTOCOL,id:E,operation:o,input:g,...r.budget?{budget:r.budget}:{}},h)}}catch(l){b(l)}});return{exportPrepared:(o,s,a)=>n("exportPrepared",o,s,a),prepare:(o,s,a)=>n("prepare",o,s,a),export:(o,s,a)=>n("export",o,s,a)}}function z(e){return e.pdf?(e.pdf=T.snapshotPdfFonts(e.pdf),(e.pdf?.customFontFaces?Object.values(e.pdf.customFontFaces):[e.pdf?.customFontBytes]).filter(t=>t instanceof Uint8Array).map(t=>t.buffer)):[]}function A(e,r={}){return C(()=>{const t=e();return{postMessage:(n,o)=>t.postMessage(n,o),terminate:()=>t.terminate(),subscribe:(n,o)=>{const s=u=>n(u.data),a=u=>o(u instanceof ErrorEvent?new Error(u.message):new Error("报表 Worker 消息无法解码"));return t.addEventListener("message",s),t.addEventListener("error",a),t.addEventListener("messageerror",a),()=>{t.removeEventListener("message",s),t.removeEventListener("error",a),t.removeEventListener("messageerror",a)}}}},r)}const N={cells:2e4,pages:20,bytes:2e6};function P(e){return e.cells>=e.limits.cells||e.pages>=e.limits.pages||e.bytes>=e.limits.bytes||e.capped}function O(e){return++e.visits>=1e5&&(e.capped=!0),!P(e)}function y(e){return typeof e=="string"?e.length*2:0}function L(e,r){for(const t of e??[]){if(!O(r))return;for(const n of t.segments){if(!O(r))return;r.bytes+=y(n.text)}}}function B(e,r,t){if(t>32){r.capped=!0;return}if(O(r)){r.bytes+=y(e.text)+y(e.rawText)+y(e.imageData),L(e.richParagraphs,r);for(const n of e.lines??[]){if(!O(r))return;r.bytes+=y(n)}for(const n of e.grid?.cells??[]){if(!O(r))return;for(const o of n){if(!O(r))return;if(o){r.cells++,r.bytes+=y(o.text)+y(o.rawText)+y(o.value),L(o.richParagraphs,r);for(const s of o.children??[]){if(P(r))return;B(s,r,t+1)}}}}}}function $(e){const r={...N,...e.thresholds};for(const t of Object.values(r))if(!Number.isSafeInteger(t)||t<=0)throw new RangeError("导出隔离阈值应为正安全整数");return r}function H(e,r){const t=$(r),n=e.pdf?.customFontFaces?Object.values(e.pdf.customFontFaces):[e.pdf?.customFontBytes],o={pages:e.prepared.plan.pages.length,cells:0,bytes:n.reduce((u,v)=>u+(v?.byteLength??0),0),visits:0,capped:!1,limits:t};for(const u of e.prepared.plan.pages){if(P(o))break;for(const v of u.components){if(P(o))break;B(v,o,0)}}let s=P(o)?"worker":"local",a=o.capped?"scan-limit":s==="worker"?"threshold":"small-task";return r.mode==="local"&&(s="local",a="explicit-local"),r.mode==="worker"&&(s="worker",a="explicit-worker"),Object.values(e.xlsx??{}).some(u=>typeof u=="function")&&(s="local",a="nonserializable-options"),{mode:s,reason:a,estimate:{pages:o.pages,cells:o.cells,bytes:o.bytes},hardCancellation:s==="worker"}}function G(e){if(e.mode!==void 0&&!["auto","local","worker"].includes(e.mode))throw new TypeError("无效的导出执行模式");if(e.fallback!==void 0&&!["local","error"].includes(e.fallback))throw new TypeError("无效的导出回退策略");d.validateBudget({...e.budget,maxDurationMs:e.timeoutMs??e.budget?.maxDurationMs??12e4})}function F(e,r){I.observeOutput(()=>e.onDecision?.({...r,estimate:{...r.estimate}}))}function D(e,r){return{...e,mode:"local",reason:r,hardCancellation:!1}}function K(e,r){const t={...d.DEFAULT_REPORT_RUNTIME_BUDGET,...r.budget},n=T.capturePreparedHandoff(e.prepared,t.maxPreparedBytes,e.signal),o=_.enforcePrepared(n.prepared,t);n.prepared.stats=o.stats;const s={...e,prepared:n.prepared,pdf:T.snapshotPdfFonts(e.pdf),xlsx:T.snapshotXlsxOptions(e.xlsx)};return{request:s,forward:()=>({...s,prepared:n.forward()})}}function X(e,r){G(e);const t={...e,thresholds:{...e.thresholds},budget:{...d.DEFAULT_REPORT_RUNTIME_BUDGET,...e.budget}},n=t.timeoutMs??t.budget.maxDurationMs??12e4,o=_.createReportRuntime({reports:{},budget:{...t.budget,maxDurationMs:n}}),s=new Set;let a=!1;const u=t.mode!=="worker"&&t.fallback!=="error";async function v(c,w){const E=Date.now(),m=()=>{const p=n-(Date.now()-E);if(p<=0)throw new d.ReportRuntimeError("timeout",`报表执行超过 ${n}ms`);return p};let f=H(c,t);if(f.reason==="nonserializable-options"&&t.mode==="worker")throw new TypeError("Worker 模式不接受函数选项;请使用本地模式或可序列化配置");if(f.mode==="worker"&&!r){if(!u)throw new M(new Error("未配置 workerFactory"));f=D(f,"worker-unavailable")}const k=K(c,t),b=k.request;if(F(t,f),d.throwIfAborted(c.signal),f.mode==="worker")try{const p=r(m());if(!p.exportPrepared)throw new TypeError("隔离执行器缺少 exportPrepared");const{signal:l,onEvent:i,...g}=b,h=await p.exportPrepared(g,l,i);return d.throwIfAborted(l),d.assertBudget(t.budget,"maxOutputBytes",h.bytes.byteLength),{...h,execution:f}}catch(p){if(!(p instanceof M)||!u)throw p;d.throwIfAborted(c.signal),f=D(f,"worker-start-failed"),F(t,f)}const x=w?await d.controlled(c.signal,m(),p=>w({...b,signal:p})):await d.controlled(c.signal,m(),p=>o.exportPrepared({...k.forward(),signal:p}));return d.throwIfAborted(c.signal),d.assertBudget(t.budget,"maxOutputBytes",x.bytes.byteLength),{...x,execution:f}}return{async exportPrepared(c,w){if(a)throw new d.ReportRuntimeError("closed","导出执行器已释放");if(d.throwIfAborted(c.signal),s.size>=2)throw new d.ReportRuntimeError("queue-full","同时导出的任务已达 2 个,请等待完成后重试");const E=new AbortController;s.add(E);const m=()=>E.abort(c.signal?.reason);c.signal?.addEventListener("abort",m,{once:!0});try{return await v({...c,signal:E.signal},w)}finally{c.signal?.removeEventListener("abort",m),s.delete(E)}},cancel(){for(const c of s)c.abort()},dispose(){a=!0;for(const c of s)c.abort()}}}function q(e={}){const r=e.workerFactory,t={timeoutMs:e.timeoutMs??e.budget?.maxDurationMs,budget:{...e.budget}};return X(e,r?n=>A(r,{...t,timeoutMs:n}):void 0)}const J=Object.freeze(Object.defineProperty({__proto__:null,createAutoReportExporter:q},Symbol.toStringTag,{value:"Module"}));exports.ReportWorkerStartError=M;exports.auto=J;exports.createAutoReportExporter=q;exports.createBrowserReportExecutor=A;
@@ -0,0 +1,220 @@
1
+ import { a as x, t as N } from "./sha256-DTG-Gq8i.js";
2
+ function R(e = {}) {
3
+ const t = {
4
+ maxRecords: e.maxRecords ?? 1e4,
5
+ maxBytes: e.maxBytes ?? 67108864,
6
+ maxResultBytes: e.maxResultBytes ?? 262144,
7
+ controlReserveBytes: e.controlReserveBytes ?? 4096,
8
+ maxTombstones: e.maxTombstones ?? 1e4,
9
+ maxTombstoneBytes: e.maxTombstoneBytes ?? 16777216
10
+ };
11
+ if (!Object.values(t).every((n) => Number.isSafeInteger(n) && n > 0) || t.controlReserveBytes < 4096) throw new c("input", "任务容量应为正整数,控制状态预留至少4096字节");
12
+ return t;
13
+ }
14
+ function b(e) {
15
+ return new TextEncoder().encode(d(e)).byteLength;
16
+ }
17
+ function A(e, t) {
18
+ const n = { scope: e.scope, id: e.id, revision: 1, request: e.request, status: "queued", createdAt: e.createdAt, updatedAt: e.createdAt, attempt: 0 }, r = { ...e };
19
+ delete r.result;
20
+ const a = e.result === void 0 ? 0 : b(e.result);
21
+ if (a > t.maxResultBytes) throw new c("capacity", "任务结果超过独立预算,请保存文件引用");
22
+ return Math.max(b(n) + t.controlReserveBytes, b(r)) + a;
23
+ }
24
+ function v(e) {
25
+ return e.status !== "queued" && e.status !== "running";
26
+ }
27
+ function B(e) {
28
+ const t = { ...e, tombstoneRetentionMs: e.tombstoneRetentionMs ?? 6048e5, limit: e.limit ?? 100 };
29
+ if (![t.now, t.terminalBefore].every((n) => Number.isSafeInteger(n) && n >= 0) || t.terminalBefore > t.now) throw new c("input", "终态清理时间应为不超过当前时间的非负整数");
30
+ if (![t.tombstoneRetentionMs, t.limit].every((n) => Number.isSafeInteger(n) && n > 0) || !Number.isSafeInteger(t.now + t.tombstoneRetentionMs)) throw new c("input", "幂等保留期与清理批量应为正整数");
31
+ return t;
32
+ }
33
+ async function O(e) {
34
+ const t = new TextEncoder().encode(d(e)), n = globalThis.crypto?.subtle;
35
+ if (!n) return x(t);
36
+ const r = await n.digest("SHA-256", t);
37
+ return Array.from(new Uint8Array(r), (a) => a.toString(16).padStart(2, "0")).join("");
38
+ }
39
+ async function J(e, t) {
40
+ if (!v(e)) throw new c("input", "只能归档终态任务");
41
+ return { scope: e.scope, id: e.id, revision: e.revision, status: e.status, createdAt: e.createdAt, updatedAt: e.updatedAt, attempt: e.attempt, requestHash: await O(e.request), expiresAt: t };
42
+ }
43
+ class c extends Error {
44
+ constructor(t, n) {
45
+ super(n), this.code = t, this.name = "ReportJobError";
46
+ }
47
+ }
48
+ function j(e, t) {
49
+ if (typeof e != "string" || !e.trim() || e.length > 256 || typeof t != "string" || t !== t.trim() || !/^[a-zA-Z0-9][a-zA-Z0-9_.:-]{0,127}$/.test(t)) throw new c("input", "任务范围应非空,ID应为1–128位安全标识");
50
+ }
51
+ function q(e) {
52
+ const t = Array.isArray(e), n = Object.getPrototypeOf(e), r = Object.keys(e);
53
+ if (n !== (t ? Array.prototype : Object.prototype) && !(n === null && !t)) throw new c("input", "任务对象应为普通 JSON 对象");
54
+ if (Object.getOwnPropertySymbols(e).length) throw new c("input", "任务不能包含Symbol");
55
+ if (Object.getOwnPropertyNames(e).filter((i) => !(t && i === "length")).length !== r.length) throw new c("input", "任务不能包含不可枚举属性");
56
+ if (t && (r.length !== e.length || r.some((i) => i !== String(Number(i)) || !Number.isSafeInteger(Number(i)) || Number(i) < 0 || Number(i) >= e.length))) throw new c("input", "任务数组不能稀疏或包含额外属性");
57
+ return r.sort();
58
+ }
59
+ function I(e, t) {
60
+ const n = Object.getOwnPropertyDescriptor(e, t);
61
+ if (["__proto__", "prototype", "constructor"].includes(t) || n.get || n.set) throw new c("input", "任务不能包含危险键或访问器");
62
+ return n.value;
63
+ }
64
+ function d(e, t = {}) {
65
+ const n = t.maxNodes ?? 2e4, r = t.maxCharacters ?? 1e6;
66
+ if (!Number.isSafeInteger(n) || n < 1 || n > 2e4 || !Number.isSafeInteger(r) || r < 1 || r > 1e6) throw new c("input", "任务JSON预算无效");
67
+ let a = 0, i = 0;
68
+ const y = /* @__PURE__ */ new Set();
69
+ function w(s, u) {
70
+ if (++a > n || u > 32) throw new c("input", "任务数据超过节点或深度预算");
71
+ if (typeof s == "string") {
72
+ if (i += s.length, i > r) throw new c("input", "任务文本超过预算");
73
+ return s;
74
+ }
75
+ if (s === null || typeof s == "boolean" || typeof s == "number" && Number.isFinite(s)) return s;
76
+ if (!s || typeof s != "object" || y.has(s)) throw new c("input", "任务只允许无循环的有限 JSON 值");
77
+ const o = Array.isArray(s), p = q(s);
78
+ y.add(s);
79
+ const l = /* @__PURE__ */ Object.create(null);
80
+ for (const f of p) {
81
+ if (i += f.length, i > r) throw new c("input", "任务文本超过预算");
82
+ l[f] = w(I(s, f), u + 1);
83
+ }
84
+ return y.delete(s), o ? Array.from({ length: s.length }, (f, g) => l[String(g)]) : l;
85
+ }
86
+ const h = JSON.stringify(w(e, 0));
87
+ if (h.length > r) throw new c("input", "任务序列化数据超过字符预算");
88
+ return h;
89
+ }
90
+ function m(e) {
91
+ return JSON.parse(JSON.stringify(e));
92
+ }
93
+ function E(e, t, n, r) {
94
+ if (j(t, n), e.scope !== t || e.id !== n || e.revision !== (r ?? 0) + 1 || !Number.isSafeInteger(e.revision)) throw new c("input", "任务身份或修订不匹配");
95
+ if (![e.createdAt, e.updatedAt, e.attempt].every((a) => Number.isSafeInteger(a) && a >= 0) || !["queued", "running", "completed", "failed", "cancelled"].includes(e.status)) throw new c("input", "任务状态无效");
96
+ if (e.lease && (!e.lease.owner || !Number.isSafeInteger(e.lease.expiresAt))) throw new c("input", "任务租约无效");
97
+ if (!e.request || typeof e.request.kind != "string" || !e.request.kind.trim() || e.request.kind.length > 128) throw new c("input", "任务类型无效");
98
+ d(e.request.payload, { maxNodes: 19e3, maxCharacters: 75e4 }), d(e);
99
+ }
100
+ function T(e, t) {
101
+ if (e && (e.createdAt !== t.createdAt || d(e.request) !== d(t.request))) throw new c("input", "任务创建时间与请求不可变更,请使用新任务ID");
102
+ }
103
+ function M(e, t) {
104
+ return e.status === "queued" || e.status === "running" && (e.lease?.expiresAt ?? 0) <= t;
105
+ }
106
+ function k(e = {}) {
107
+ const t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), r = R(e);
108
+ let a = 0, i = 0, y = Promise.resolve();
109
+ const w = (s, u) => JSON.stringify([s, u]), h = (s) => {
110
+ const u = y.then(s);
111
+ return y = u.then(() => {
112
+ }, () => {
113
+ }), u;
114
+ };
115
+ return {
116
+ read: async (s, u) => {
117
+ await y;
118
+ const o = t.get(w(s, u));
119
+ return o ? m(o) : void 0;
120
+ },
121
+ readTombstone: async (s, u) => {
122
+ await y;
123
+ const o = n.get(w(s, u));
124
+ return o ? m(o) : void 0;
125
+ },
126
+ candidates: async (s, u) => (await y, Array.from(t.values()).filter((o) => M(o, s)).sort((o, p) => o.createdAt - p.createdAt).slice(0, u).map(m)),
127
+ compareAndSwap: async (s, u, o, p) => {
128
+ E(p, s, u, o);
129
+ const l = m(p);
130
+ return h(async () => {
131
+ const f = w(s, u), g = t.get(f);
132
+ if ((g?.revision ?? null) !== o || n.has(f)) return !1;
133
+ T(g, l);
134
+ const S = a - (g ? A(g, r) : 0) + A(l, r);
135
+ if (S > r.maxBytes || !g && t.size >= r.maxRecords) throw new c("capacity", "任务容量已满,请清理终态任务或扩大显式预算");
136
+ return t.set(f, l), a = S, !0;
137
+ });
138
+ },
139
+ prune: async (s) => {
140
+ const u = B(s);
141
+ return h(async () => {
142
+ const o = { archived: 0, expired: 0 };
143
+ for (const [p, l] of n)
144
+ l.expiresAt > u.now || o.expired >= u.limit || (n.delete(p), i -= b(l), o.expired++);
145
+ for (const [p, l] of t) {
146
+ if (!v(l) || l.updatedAt > u.terminalBefore || o.archived + o.expired >= u.limit) continue;
147
+ const f = await J(l, u.now + u.tombstoneRetentionMs), g = b(f);
148
+ if (n.size >= r.maxTombstones || i + g > r.maxTombstoneBytes) break;
149
+ n.set(p, f), i += g, t.delete(p), a -= A(l, r), o.archived++;
150
+ }
151
+ return o;
152
+ });
153
+ }
154
+ };
155
+ }
156
+ function C(e, t = 100) {
157
+ if (!Number.isSafeInteger(t) || t < 1 || t > 1e3 || !Array.isArray(e) || e.length > t) throw new RangeError("批量参数应包含 1–maxCases 条,maxCases 最大为 1000");
158
+ const n = JSON.parse(d(e)), r = /* @__PURE__ */ new Set();
159
+ for (const a of n) {
160
+ if (!a || typeof a.id != "string" || a.id !== a.id.trim() || !/^[a-zA-Z0-9][a-zA-Z0-9_.:-]{0,127}$/.test(a.id) || r.has(a.id)) throw new TypeError("批量行 ID 应唯一且为安全标识");
161
+ if (!a.params || Array.isArray(a.params) || typeof a.params != "object" || Object.values(a.params).some((i) => typeof i != "string")) throw new TypeError("批量参数应为字符串字典");
162
+ r.add(a.id);
163
+ }
164
+ return n;
165
+ }
166
+ function z(e, t) {
167
+ if (!t) return;
168
+ const n = { completed: 0, total: e.length, failed: 0, cancelled: 0 };
169
+ for (const r of e)
170
+ r && (n.completed++, r.status === "failed" && n.failed++, r.status === "cancelled" && n.cancelled++);
171
+ try {
172
+ t(n);
173
+ } catch {
174
+ }
175
+ }
176
+ async function _(e, t, n = {}) {
177
+ const r = n.concurrency ?? 2;
178
+ if (!Number.isSafeInteger(r) || r < 1 || r > 16) throw new RangeError("批量并发应为 1–16");
179
+ if (n.failure !== void 0 && n.failure !== "continue" && n.failure !== "stop") throw new TypeError("批量失败策略无效");
180
+ const a = C(e, n.maxCases ?? 100);
181
+ if (!a.length) throw new RangeError("批量生成至少需要一组参数");
182
+ const i = Array.from({ length: a.length }), y = new AbortController(), w = () => y.abort(n.signal?.reason);
183
+ n.signal?.addEventListener("abort", w, { once: !0 }), n.signal?.aborted && w();
184
+ let h = 0, s = !1;
185
+ async function u() {
186
+ for (; h < a.length; ) {
187
+ const o = h++, p = a[o], l = { id: p.id, index: o };
188
+ if (s || y.signal.aborted) i[o] = { ...l, status: "cancelled" };
189
+ else
190
+ try {
191
+ N(y.signal);
192
+ const f = await t(p, { index: o, signal: y.signal });
193
+ i[o] = { ...l, status: "completed", value: f };
194
+ } catch (f) {
195
+ y.signal.aborted ? i[o] = { ...l, status: "cancelled" } : (i[o] = { ...l, status: "failed", error: { name: f instanceof Error ? f.name : "Error", message: f instanceof Error ? f.message : String(f) } }, n.failure === "stop" && (s = !0));
196
+ }
197
+ z(i, n.onProgress);
198
+ }
199
+ }
200
+ try {
201
+ await Promise.all(Array.from({ length: Math.min(r, a.length) }, u));
202
+ } finally {
203
+ n.signal?.removeEventListener("abort", w);
204
+ }
205
+ return i;
206
+ }
207
+ export {
208
+ c as R,
209
+ m as a,
210
+ O as b,
211
+ j as c,
212
+ k as d,
213
+ M as e,
214
+ C as f,
215
+ T as g,
216
+ b as j,
217
+ _ as r,
218
+ d as s,
219
+ E as v
220
+ };
@@ -0,0 +1 @@
1
+ "use strict";const v=require("./sha256-BshdOkCC.cjs");function j(e={}){const t={maxRecords:e.maxRecords??1e4,maxBytes:e.maxBytes??67108864,maxResultBytes:e.maxResultBytes??262144,controlReserveBytes:e.controlReserveBytes??4096,maxTombstones:e.maxTombstones??1e4,maxTombstoneBytes:e.maxTombstoneBytes??16777216};if(!Object.values(t).every(n=>Number.isSafeInteger(n)&&n>0)||t.controlReserveBytes<4096)throw new c("input","任务容量应为正整数,控制状态预留至少4096字节");return t}function g(e){return new TextEncoder().encode(d(e)).byteLength}function A(e,t){const n={scope:e.scope,id:e.id,revision:1,request:e.request,status:"queued",createdAt:e.createdAt,updatedAt:e.createdAt,attempt:0},r={...e};delete r.result;const a=e.result===void 0?0:g(e.result);if(a>t.maxResultBytes)throw new c("capacity","任务结果超过独立预算,请保存文件引用");return Math.max(g(n)+t.controlReserveBytes,g(r))+a}function x(e){return e.status!=="queued"&&e.status!=="running"}function I(e){const t={...e,tombstoneRetentionMs:e.tombstoneRetentionMs??6048e5,limit:e.limit??100};if(![t.now,t.terminalBefore].every(n=>Number.isSafeInteger(n)&&n>=0)||t.terminalBefore>t.now)throw new c("input","终态清理时间应为不超过当前时间的非负整数");if(![t.tombstoneRetentionMs,t.limit].every(n=>Number.isSafeInteger(n)&&n>0)||!Number.isSafeInteger(t.now+t.tombstoneRetentionMs))throw new c("input","幂等保留期与清理批量应为正整数");return t}async function R(e){const t=new TextEncoder().encode(d(e)),n=globalThis.crypto?.subtle;if(!n)return v.portableSha256HexAsync(t);const r=await n.digest("SHA-256",t);return Array.from(new Uint8Array(r),a=>a.toString(16).padStart(2,"0")).join("")}async function E(e,t){if(!x(e))throw new c("input","只能归档终态任务");return{scope:e.scope,id:e.id,revision:e.revision,status:e.status,createdAt:e.createdAt,updatedAt:e.updatedAt,attempt:e.attempt,requestHash:await R(e.request),expiresAt:t}}class c extends Error{constructor(t,n){super(n),this.code=t,this.name="ReportJobError"}}function J(e,t){if(typeof e!="string"||!e.trim()||e.length>256||typeof t!="string"||t!==t.trim()||!/^[a-zA-Z0-9][a-zA-Z0-9_.:-]{0,127}$/.test(t))throw new c("input","任务范围应非空,ID应为1–128位安全标识")}function T(e){const t=Array.isArray(e),n=Object.getPrototypeOf(e),r=Object.keys(e);if(n!==(t?Array.prototype:Object.prototype)&&!(n===null&&!t))throw new c("input","任务对象应为普通 JSON 对象");if(Object.getOwnPropertySymbols(e).length)throw new c("input","任务不能包含Symbol");if(Object.getOwnPropertyNames(e).filter(i=>!(t&&i==="length")).length!==r.length)throw new c("input","任务不能包含不可枚举属性");if(t&&(r.length!==e.length||r.some(i=>i!==String(Number(i))||!Number.isSafeInteger(Number(i))||Number(i)<0||Number(i)>=e.length)))throw new c("input","任务数组不能稀疏或包含额外属性");return r.sort()}function M(e,t){const n=Object.getOwnPropertyDescriptor(e,t);if(["__proto__","prototype","constructor"].includes(t)||n.get||n.set)throw new c("input","任务不能包含危险键或访问器");return n.value}function d(e,t={}){const n=t.maxNodes??2e4,r=t.maxCharacters??1e6;if(!Number.isSafeInteger(n)||n<1||n>2e4||!Number.isSafeInteger(r)||r<1||r>1e6)throw new c("input","任务JSON预算无效");let a=0,i=0;const y=new Set;function b(s,u){if(++a>n||u>32)throw new c("input","任务数据超过节点或深度预算");if(typeof s=="string"){if(i+=s.length,i>r)throw new c("input","任务文本超过预算");return s}if(s===null||typeof s=="boolean"||typeof s=="number"&&Number.isFinite(s))return s;if(!s||typeof s!="object"||y.has(s))throw new c("input","任务只允许无循环的有限 JSON 值");const o=Array.isArray(s),h=T(s);y.add(s);const l=Object.create(null);for(const f of h){if(i+=f.length,i>r)throw new c("input","任务文本超过预算");l[f]=b(M(s,f),u+1)}return y.delete(s),o?Array.from({length:s.length},(f,p)=>l[String(p)]):l}const w=JSON.stringify(b(e,0));if(w.length>r)throw new c("input","任务序列化数据超过字符预算");return w}function m(e){return JSON.parse(JSON.stringify(e))}function N(e,t,n,r){if(J(t,n),e.scope!==t||e.id!==n||e.revision!==(r??0)+1||!Number.isSafeInteger(e.revision))throw new c("input","任务身份或修订不匹配");if(![e.createdAt,e.updatedAt,e.attempt].every(a=>Number.isSafeInteger(a)&&a>=0)||!["queued","running","completed","failed","cancelled"].includes(e.status))throw new c("input","任务状态无效");if(e.lease&&(!e.lease.owner||!Number.isSafeInteger(e.lease.expiresAt)))throw new c("input","任务租约无效");if(!e.request||typeof e.request.kind!="string"||!e.request.kind.trim()||e.request.kind.length>128)throw new c("input","任务类型无效");d(e.request.payload,{maxNodes:19e3,maxCharacters:75e4}),d(e)}function B(e,t){if(e&&(e.createdAt!==t.createdAt||d(e.request)!==d(t.request)))throw new c("input","任务创建时间与请求不可变更,请使用新任务ID")}function O(e,t){return e.status==="queued"||e.status==="running"&&(e.lease?.expiresAt??0)<=t}function C(e={}){const t=new Map,n=new Map,r=j(e);let a=0,i=0,y=Promise.resolve();const b=(s,u)=>JSON.stringify([s,u]),w=s=>{const u=y.then(s);return y=u.then(()=>{},()=>{}),u};return{read:async(s,u)=>{await y;const o=t.get(b(s,u));return o?m(o):void 0},readTombstone:async(s,u)=>{await y;const o=n.get(b(s,u));return o?m(o):void 0},candidates:async(s,u)=>(await y,Array.from(t.values()).filter(o=>O(o,s)).sort((o,h)=>o.createdAt-h.createdAt).slice(0,u).map(m)),compareAndSwap:async(s,u,o,h)=>{N(h,s,u,o);const l=m(h);return w(async()=>{const f=b(s,u),p=t.get(f);if((p?.revision??null)!==o||n.has(f))return!1;B(p,l);const S=a-(p?A(p,r):0)+A(l,r);if(S>r.maxBytes||!p&&t.size>=r.maxRecords)throw new c("capacity","任务容量已满,请清理终态任务或扩大显式预算");return t.set(f,l),a=S,!0})},prune:async s=>{const u=I(s);return w(async()=>{const o={archived:0,expired:0};for(const[h,l]of n)l.expiresAt>u.now||o.expired>=u.limit||(n.delete(h),i-=g(l),o.expired++);for(const[h,l]of t){if(!x(l)||l.updatedAt>u.terminalBefore||o.archived+o.expired>=u.limit)continue;const f=await E(l,u.now+u.tombstoneRetentionMs),p=g(f);if(n.size>=r.maxTombstones||i+p>r.maxTombstoneBytes)break;n.set(h,f),i+=p,t.delete(h),a-=A(l,r),o.archived++}return o})}}}function q(e,t=100){if(!Number.isSafeInteger(t)||t<1||t>1e3||!Array.isArray(e)||e.length>t)throw new RangeError("批量参数应包含 1–maxCases 条,maxCases 最大为 1000");const n=JSON.parse(d(e)),r=new Set;for(const a of n){if(!a||typeof a.id!="string"||a.id!==a.id.trim()||!/^[a-zA-Z0-9][a-zA-Z0-9_.:-]{0,127}$/.test(a.id)||r.has(a.id))throw new TypeError("批量行 ID 应唯一且为安全标识");if(!a.params||Array.isArray(a.params)||typeof a.params!="object"||Object.values(a.params).some(i=>typeof i!="string"))throw new TypeError("批量参数应为字符串字典");r.add(a.id)}return n}function z(e,t){if(!t)return;const n={completed:0,total:e.length,failed:0,cancelled:0};for(const r of e)r&&(n.completed++,r.status==="failed"&&n.failed++,r.status==="cancelled"&&n.cancelled++);try{t(n)}catch{}}async function k(e,t,n={}){const r=n.concurrency??2;if(!Number.isSafeInteger(r)||r<1||r>16)throw new RangeError("批量并发应为 1–16");if(n.failure!==void 0&&n.failure!=="continue"&&n.failure!=="stop")throw new TypeError("批量失败策略无效");const a=q(e,n.maxCases??100);if(!a.length)throw new RangeError("批量生成至少需要一组参数");const i=Array.from({length:a.length}),y=new AbortController,b=()=>y.abort(n.signal?.reason);n.signal?.addEventListener("abort",b,{once:!0}),n.signal?.aborted&&b();let w=0,s=!1;async function u(){for(;w<a.length;){const o=w++,h=a[o],l={id:h.id,index:o};if(s||y.signal.aborted)i[o]={...l,status:"cancelled"};else try{v.throwIfAborted(y.signal);const f=await t(h,{index:o,signal:y.signal});i[o]={...l,status:"completed",value:f}}catch(f){y.signal.aborted?i[o]={...l,status:"cancelled"}:(i[o]={...l,status:"failed",error:{name:f instanceof Error?f.name:"Error",message:f instanceof Error?f.message:String(f)}},n.failure==="stop"&&(s=!0))}z(i,n.onProgress)}}try{await Promise.all(Array.from({length:Math.min(r,a.length)},u))}finally{n.signal?.removeEventListener("abort",b)}return i}exports.ReportJobError=c;exports.checkJobIdentity=J;exports.cloneJob=m;exports.createMemoryReportJobStore=C;exports.jobByteLength=g;exports.jobRequestHash=R;exports.runReportBatch=k;exports.runnableJob=O;exports.serializeJobJson=d;exports.snapshotReportBatchCases=q;exports.validateJobRecord=N;exports.validateJobTransition=B;