@agile-team/mach-report 2.16.0 → 2.18.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 (177) hide show
  1. package/README.md +25 -12
  2. package/dist/{ExcelBindingWizard-CP6h2x1f.cjs → ExcelBindingWizard-Czn3C2yE.cjs} +1 -1
  3. package/dist/{ExcelBindingWizard-HhB3hAJE.js → ExcelBindingWizard-DMGZj6I6.js} +3 -3
  4. package/dist/ParamEditor-KzDQvbHY.js +732 -0
  5. package/dist/ParamEditor-oDfD8LgE.cjs +1 -0
  6. package/dist/{ReportBatchPanel-ruxcbfY6.js → ReportBatchPanel-BJK7PvZ4.js} +39 -39
  7. package/dist/ReportBatchPanel-DnmNRssu.cjs +1 -0
  8. package/dist/ReportParamPanel-mQkeN70Q.js +1020 -0
  9. package/dist/ReportParamPanel-sOANVRz-.cjs +1 -0
  10. package/dist/ReportPreview-BxWWTUL5.js +5583 -0
  11. package/dist/ReportPreview-Yf99omi3.cjs +6 -0
  12. package/dist/{ReportTemplateLibrary-DcwrH-63.js → ReportTemplateLibrary-BFjB08Wu.js} +1 -1
  13. package/dist/{ReportTemplateLibrary-BDlNT8JN.cjs → ReportTemplateLibrary-BO42QnWd.cjs} +1 -1
  14. package/dist/RuleEditor-CqxT1a-W.js +2337 -0
  15. package/dist/RuleEditor-D7YWigD9.cjs +1 -0
  16. package/dist/{TemplateOutlinePanel-CGrT5DFN.cjs → TemplateOutlinePanel-B0XX350V.cjs} +1 -1
  17. package/dist/{TemplateOutlinePanel-SXCjaPKR.js → TemplateOutlinePanel-zG0DrsIB.js} +2 -2
  18. package/dist/{TemplateReusePanel-6Z3wRFz8.cjs → TemplateReusePanel-BD0HSKp_.cjs} +1 -1
  19. package/dist/{TemplateReusePanel-lHLOS9Wn.js → TemplateReusePanel-Czwe5GbC.js} +2 -2
  20. package/dist/{TemplateReviewPanel-Dpk7sLcF.cjs → TemplateReviewPanel-CA5sdffM.cjs} +1 -1
  21. package/dist/{TemplateReviewPanel-CJ9PLc48.js → TemplateReviewPanel-NhmQI65C.js} +2 -2
  22. package/dist/analytics.cjs +1 -1
  23. package/dist/analytics.d.cts +163 -42
  24. package/dist/analytics.d.ts +163 -42
  25. package/dist/analytics.js +76 -141
  26. package/dist/artifact-integrity.json +110 -108
  27. package/dist/assets-2eC3mOcV.js +232 -0
  28. package/dist/assets-B0Hxn4l6.cjs +1 -0
  29. package/dist/{auto-uVBjX1j5.cjs → auto-B0EZFIK1.cjs} +1 -1
  30. package/dist/{auto-YR7a4BtF.js → auto-BlchZ1b8.js} +10 -10
  31. package/dist/{batch-WzDIXJAt.js → batch-DGCt44XM.js} +1 -1
  32. package/dist/{batch-z6Aw5GEY.cjs → batch-DYcokH4v.cjs} +1 -1
  33. package/dist/charts-Dlv8j2AG.js +141 -0
  34. package/dist/charts-aCtoswXq.cjs +1 -0
  35. package/dist/codes.cjs +9 -9
  36. package/dist/codes.d.cts +54 -0
  37. package/dist/codes.d.ts +54 -0
  38. package/dist/codes.js +12097 -13668
  39. package/dist/column-visual-BpgQVWwT.js +238 -0
  40. package/dist/column-visual-CtYxnBCP.cjs +1 -0
  41. package/dist/component-tree-6TV7W6Yj.cjs +1 -0
  42. package/dist/component-tree-CvW4lzpv.js +67 -0
  43. package/dist/computed-4TnxzgIh.cjs +1 -0
  44. package/dist/computed-C8NRZQss.js +739 -0
  45. package/dist/data-bar-Ce38juRZ.cjs +1 -0
  46. package/dist/data-bar-PtjXhMgN.js +9 -0
  47. package/dist/dataset-DL83majE.js +161 -0
  48. package/dist/dataset-IrlXbUvh.cjs +1 -0
  49. package/dist/designer--TKECSEc.cjs +2 -0
  50. package/dist/designer-d6hJS41w.js +5683 -0
  51. package/dist/designer.cjs +1 -1
  52. package/dist/designer.d.cts +835 -45
  53. package/dist/designer.d.ts +835 -45
  54. package/dist/designer.js +23 -20
  55. package/dist/{encoding-BYF9ZTl9.cjs → encoding-B--eZpp1.cjs} +1 -1
  56. package/dist/{encoding-BOGq4qYL.js → encoding-mctOLocI.js} +2 -2
  57. package/dist/{font-loader-EKLzOJxf.cjs → font-loader-DBBJ5KE9.cjs} +1 -1
  58. package/dist/{font-loader-CzI1GuBc.js → font-loader-DW8tIaNp.js} +1 -1
  59. package/dist/index-CPh6tqge.js +1575 -0
  60. package/dist/index-CUNw7dL9.cjs +1 -0
  61. package/dist/index.cjs +8 -8
  62. package/dist/index.d.cts +534 -16
  63. package/dist/index.d.ts +534 -16
  64. package/dist/index.js +1393 -955
  65. package/dist/json-snapshot-By4ZVVUt.js +1967 -0
  66. package/dist/json-snapshot-jiXff4lc.cjs +2 -0
  67. package/dist/matrix-0hywp0-F.cjs +1 -0
  68. package/dist/matrix-Dy-tyY7E.js +381 -0
  69. package/dist/param-validation-C-8sRJLq.cjs +1 -0
  70. package/dist/param-validation-CnDEd2l-.js +333 -0
  71. package/dist/{pdf-DJ5S6ukC.js → pdf-CKROKygt.js} +1845 -1845
  72. package/dist/{pdf-ByVCb1i6.cjs → pdf-DqyxJ96U.cjs} +47 -47
  73. package/dist/pdf.cjs +1 -1
  74. package/dist/pdf.d.cts +66 -0
  75. package/dist/pdf.d.ts +66 -0
  76. package/dist/pdf.js +2 -2
  77. package/dist/{plugin-C2j5_mhx.js → plugin-ByjF2kiV.js} +5 -5
  78. package/dist/{plugin-Dr39GBRG.cjs → plugin-DM1M2wlI.cjs} +1 -1
  79. package/dist/prefill-B8H9qwE4.js +371 -0
  80. package/dist/prefill-D7EswyTI.cjs +1 -0
  81. package/dist/{prepared-DqtpvRTn.js → prepared-BE-4jfX5.js} +2 -2
  82. package/dist/{prepared-DdrjLC7L.cjs → prepared-CGVphji3.cjs} +1 -1
  83. package/dist/{protocol-BzwMP4Vw.cjs → protocol-ByRVzzQG.cjs} +1 -1
  84. package/dist/{protocol-kt4Iy6-3.js → protocol-Cr81vFSQ.js} +3 -3
  85. package/dist/{record-bindings-CZWBJ1fU.js → record-bindings-DEJtmo3p.js} +67 -107
  86. package/dist/record-bindings-ehjnCDHt.cjs +1 -0
  87. package/dist/{region-binding-workflow-CWNvIjkV.js → region-binding-workflow-CBg0l_tj.js} +2 -2
  88. package/dist/{region-binding-workflow-CqSMxQ4p.cjs → region-binding-workflow-D05tOYn3.cjs} +1 -1
  89. package/dist/report-encoding-worker.cjs +1 -1
  90. package/dist/report-encoding-worker.js +1 -1
  91. package/dist/{report-params-B1RzkhJj.js → report-params-D9tBuM9B.js} +1 -1
  92. package/dist/{report-params-WDGrA4oP.cjs → report-params-VTg8MoCp.cjs} +1 -1
  93. package/dist/runtime-CDA6d263.cjs +1 -0
  94. package/dist/runtime-CEMvybO7.js +170 -0
  95. package/dist/sbom.cdx.json +1 -1
  96. package/dist/server/node.d.cts +121 -7
  97. package/dist/server/node.d.ts +121 -7
  98. package/dist/server-node.cjs +4 -4
  99. package/dist/server-node.js +3446 -2115
  100. package/dist/server.cjs +1 -1
  101. package/dist/server.d.cts +417 -29
  102. package/dist/server.d.ts +417 -29
  103. package/dist/server.js +787 -544
  104. package/dist/sha256-BDQ1Qk7A.js +158 -0
  105. package/dist/sha256-DgZAKXqI.cjs +1 -0
  106. package/dist/style.css +1 -1
  107. package/dist/template-bindings-Cg5oBLFT.cjs +1 -0
  108. package/dist/template-bindings-TKnXM7ll.js +62 -0
  109. package/dist/{template-catalog-BtR2JmCL.js → template-catalog-CmbWOJqy.js} +16 -16
  110. package/dist/template-catalog-Utu4GP09.cjs +1 -0
  111. package/dist/{template-fragments-BVsbxs4a.cjs → template-fragments-C_zSHJAa.cjs} +1 -1
  112. package/dist/{template-fragments-By0aZC1D.js → template-fragments-DWgo9tlZ.js} +2 -2
  113. package/dist/{template-outline-BwRV_eRo.cjs → template-outline-DWkzZXVC.cjs} +1 -1
  114. package/dist/{template-outline-cnWfT_LK.js → template-outline-DiADphlq.js} +1 -1
  115. package/dist/{template-registry-Cw3vRTX2.js → template-registry-BIhIHOab.js} +319 -314
  116. package/dist/template-registry-DzWswQI5.cjs +1 -0
  117. package/dist/vue/async.d.cts +636 -35
  118. package/dist/vue/async.d.ts +636 -35
  119. package/dist/vue/index.d.cts +746 -67
  120. package/dist/vue/index.d.ts +746 -67
  121. package/dist/vue-async.cjs +1 -1
  122. package/dist/vue-async.js +3 -3
  123. package/dist/vue.cjs +1 -1
  124. package/dist/vue.js +94 -89
  125. package/dist/{workbook-session-Cbts-22R.cjs → workbook-session-B94EwVa_.cjs} +1 -1
  126. package/dist/{workbook-session-BeSO8PFB.js → workbook-session-BoScoOg-.js} +2 -2
  127. package/dist/worker.cjs +1 -1
  128. package/dist/worker.d.cts +75 -7
  129. package/dist/worker.d.ts +75 -7
  130. package/dist/worker.js +4 -4
  131. package/dist/xlsx.cjs +4 -4
  132. package/dist/xlsx.d.cts +208 -15
  133. package/dist/xlsx.d.ts +208 -15
  134. package/dist/xlsx.js +288 -252
  135. package/package.json +1 -1
  136. package/dist/ParamEditor-CUQLgoxa.cjs +0 -1
  137. package/dist/ParamEditor-OKesP_nO.js +0 -594
  138. package/dist/ReportBatchPanel-cZCAMAwH.cjs +0 -1
  139. package/dist/ReportPreview-BcDKCLiK.js +0 -4834
  140. package/dist/ReportPreview-Bk9nLfO9.cjs +0 -6
  141. package/dist/RuleEditor-BX5S8RSF.cjs +0 -1
  142. package/dist/RuleEditor-CGl9XY2s.js +0 -2037
  143. package/dist/assets-CqIbfbTr.js +0 -126
  144. package/dist/assets-e4YSke8n.cjs +0 -1
  145. package/dist/capabilities-DDwXr_cA.js +0 -103
  146. package/dist/capabilities-DNLyZdNw.cjs +0 -1
  147. package/dist/component-tree-Ca6YYfHq.js +0 -61
  148. package/dist/component-tree-DkGLEfZC.cjs +0 -1
  149. package/dist/computed-C-4C2S5h.js +0 -521
  150. package/dist/computed-CGV2a809.cjs +0 -1
  151. package/dist/config-Dg_o8e7m.cjs +0 -1
  152. package/dist/config-XQ4qrQ7Q.js +0 -844
  153. package/dist/dataset-BkRmwgeJ.cjs +0 -1
  154. package/dist/dataset-H5pFuQGU.js +0 -121
  155. package/dist/designer-BfQSahxq.js +0 -5163
  156. package/dist/designer-CPPdeM5_.cjs +0 -2
  157. package/dist/diagnostic-notification-B9K9We3h.cjs +0 -1
  158. package/dist/diagnostic-notification-qGAYZdkB.js +0 -7
  159. package/dist/drill-CsdjgkRM.cjs +0 -1
  160. package/dist/drill-DIGsZfyB.js +0 -145
  161. package/dist/json-snapshot-D6ioHth9.js +0 -1702
  162. package/dist/json-snapshot-DknkjvxP.cjs +0 -2
  163. package/dist/matrix-CGRGkn5s.js +0 -112
  164. package/dist/matrix-gEO7ZM_u.cjs +0 -1
  165. package/dist/param-validation-C3HlcLLO.cjs +0 -1
  166. package/dist/param-validation-Do7Eg8Zv.js +0 -181
  167. package/dist/record-bindings-DUX1VMlR.cjs +0 -1
  168. package/dist/runtime-BjKBI530.js +0 -168
  169. package/dist/runtime-CBFEPKEs.cjs +0 -1
  170. package/dist/sha256-BshdOkCC.cjs +0 -1
  171. package/dist/sha256-DTG-Gq8i.js +0 -157
  172. package/dist/template-bindings-C2SpvsMU.js +0 -58
  173. package/dist/template-bindings-CEtWyiLX.cjs +0 -1
  174. package/dist/template-catalog-C2NLdrwB.cjs +0 -1
  175. package/dist/template-registry-C62vpv4a.cjs +0 -1
  176. package/dist/tree-BX380Rr7.cjs +0 -1
  177. package/dist/tree-CjVZLRw7.js +0 -172
@@ -0,0 +1,232 @@
1
+ import { b as D, i as O, v as P } from "./component-tree-CvW4lzpv.js";
2
+ import { r as R } from "./grid-geometry-BNptEcMm.js";
3
+ import { b as h, a as C, w as L } from "./progress-Hc2vxoCs.js";
4
+ import { c as j, I } from "./media-Y90dHK9z.js";
5
+ function x(e, t) {
6
+ h(t.signal), C(() => t.onDiagnostic?.(e)), h(t.signal);
7
+ }
8
+ class k extends Error {
9
+ constructor(t) {
10
+ super(`Output contains ${t.length} known fidelity issue(s): ${t[0]?.code}`), this.diagnostics = t, this.code = "output-fidelity", this.name = "OutputFidelityError";
11
+ }
12
+ }
13
+ const T = /* @__PURE__ */ new Set(["text", "rect", "line", "ellipse"]), X = /* @__PURE__ */ new Set(["image", "chart", "barcode", "qrcode"]);
14
+ function G(e, t) {
15
+ if (!e.grid) {
16
+ if (O(e))
17
+ return (t === "pdf" || t === "xlsx") && !/^data:image\/(png|jpe?g);base64,/i.test(e.imageData) ? { code: "unsupported-image-format", message: `${t.toUpperCase()} accepts PNG or JPEG data URLs; convert this image before exporting.` } : void 0;
18
+ if (X.has(e.kind)) return { code: "missing-image", message: `${e.kind} requires imageData or a renderer adapter before output.` };
19
+ if (!T.has(e.kind)) return { code: "unsupported-component", message: `Unsupported component kind: ${e.kind}.` };
20
+ if (t === "xlsx" && e.kind !== "text") return { code: "unsupported-component", message: `XLSX data export omits ${e.kind} geometry.` };
21
+ }
22
+ }
23
+ function p(e, t, n, s, i) {
24
+ const r = Object.getOwnPropertyDescriptor(e, "meta")?.value, a = r && Object.getOwnPropertyDescriptor(r, "componentExtension")?.value, o = a && Object.getOwnPropertyDescriptor(a, "id")?.value, d = a && Object.getOwnPropertyDescriptor(a, "version")?.value, c = typeof o == "string" && o.length <= 128 && typeof d == "string" && d.length <= 64 ? { id: o, version: d } : void 0;
25
+ return { ...i, severity: "warning", format: t, pageIndex: n, componentIndex: s, kind: e.kind, nid: e.nid, ...c ? { extension: c } : {} };
26
+ }
27
+ function b(e, t) {
28
+ if (!e || t === "dom") return;
29
+ const n = [];
30
+ return e.rotateDeg && n.push("rotateDeg"), e.opacity !== void 0 && e.opacity !== 1 && n.push("opacity"), t !== "xlsx" && e.align === "justify" && n.push("justify"), t === "xlsx" && e.letterSpacing && n.push("letterSpacing"), n.length ? `${t} does not preserve these styles: ${n.join(", ")}.` : void 0;
31
+ }
32
+ function S(e) {
33
+ if (!e) return;
34
+ const t = ["backgroundColor", "align", "verticalAlign", "lineHeight", "borderTop", "borderRight", "borderBottom", "borderLeft", "borderColor", "lineColor", "lineWidthPt"].filter((n) => e[n] !== void 0);
35
+ return t.length ? `XLSX rich text does not retain independent run styles: ${t.join(", ")}.` : void 0;
36
+ }
37
+ function F(e) {
38
+ if (e.kind !== "text") return;
39
+ const t = S(e.style);
40
+ if (e.leftMm || e.topMm || t) return { code: "unsupported-style", message: `Nested XLSX text is retained as rich text in component order; absolute child offsets and independent paragraph styles are not retained.${t ? ` ${t}` : ""}` };
41
+ }
42
+ function A(e, t, n, s, i, r) {
43
+ const a = (o) => {
44
+ i.push({ ...p(e, t, n, s, { code: "unsupported-style", message: o }), componentPath: r });
45
+ };
46
+ for (const o of e.richParagraphs ?? []) {
47
+ t === "xlsx" && (o.spaceBeforeMm || o.spaceAfterMm || o.indentMm || o.align || o.lineHeight) && a("XLSX rich text preserves fonts and paragraph newlines; paragraph spacing, indentation and alignment are not retained.");
48
+ const d = b({ align: o.align }, t);
49
+ d && a(d);
50
+ for (const c of o.segments) {
51
+ const u = b(c.style, t) ?? (t === "xlsx" ? S(c.style) : void 0);
52
+ u && a(u);
53
+ }
54
+ }
55
+ }
56
+ function $(e, t, n, s, i, r, a) {
57
+ if (a.has(e)) return;
58
+ const o = new Set(a).add(e), d = G(e, t);
59
+ d && r.push({ ...p(e, t, n, s, d), componentPath: i });
60
+ const c = b(e.style, t);
61
+ c && r.push({ ...p(e, t, n, s, { code: "unsupported-style", message: c }), componentPath: i }), A(e, t, n, s, r, i), q(e, t, n, s, i, r, o);
62
+ }
63
+ function N(e, t, n) {
64
+ if (e.grid) return { code: "nested-components-omitted", message: "XLSX cannot place a nested grid inside a single cell; the nested grid is omitted." };
65
+ const s = F(e);
66
+ if (s) return s;
67
+ if (O(e) && (e.leftMm < 0 || e.topMm < 0 || e.leftMm + e.widthMm > t + 1e-3 || e.topMm + e.heightMm > n + 1e-3)) return { code: "unsupported-style", message: "XLSX cannot clip a child image to a cell; it retains the original image dimensions." };
68
+ }
69
+ function U(e) {
70
+ let t;
71
+ return (n, s, i, r) => {
72
+ t ??= new Map(R(e.grid, e.widthMm, e.heightMm).cells.map((d) => [`${d.ri}:${d.ci}`, d]));
73
+ const a = t.get(`${s}:${i}`), o = 2 * (e.grid?.paddingMm ?? 0.5);
74
+ return N(n, (a?.widthMm ?? 0) - o - (r?.indentMm ?? 0), (a?.heightMm ?? 0) - o);
75
+ };
76
+ }
77
+ function q(e, t, n, s, i, r, a) {
78
+ const o = U(e);
79
+ for (const [d, c] of (e.grid?.cells ?? []).entries()) for (const [u, g] of c.entries()) {
80
+ g?.dataBar !== void 0 && !P(g.dataBar) && r.push({ ...p(e, t, n, s, { code: "unsupported-style", message: "Invalid resolved data-bar geometry or color; visual data bars require ordered 0–1 ratios and #RRGGBB colors." }), componentPath: [...i, d, u] });
81
+ const l = b(g?.style, t);
82
+ l && r.push({ ...p(e, t, n, s, { code: "unsupported-style", message: l }), componentPath: [...i, d, u] }), g?.richParagraphs?.length && A({ ...e, richParagraphs: g.richParagraphs }, t, n, s, r, [...i, d, u]);
83
+ for (const [f, m] of (g?.children ?? []).entries()) {
84
+ const M = [...i, d, u, f];
85
+ if (t === "xlsx") {
86
+ const E = o(m, d, u, g);
87
+ if (E && r.push({ ...p(m, t, n, s, E), componentPath: M }), m.grid) continue;
88
+ }
89
+ $(m, t, n, s, M, r, a);
90
+ }
91
+ }
92
+ }
93
+ function H(e, t) {
94
+ D(e);
95
+ const n = [];
96
+ return e.pages.forEach((s, i) => s.components.forEach((r, a) => $(r, t, i, a, [], n, /* @__PURE__ */ new Set()))), n;
97
+ }
98
+ function ne(e, t, n) {
99
+ h(n.signal);
100
+ const s = H(e, t);
101
+ if (s.forEach((i) => x(i, n)), n.fidelity === "strict" && s.length) throw new k(s);
102
+ return s;
103
+ }
104
+ class v extends Error {
105
+ constructor(t, n) {
106
+ super(t.message), this.name = "OutputAssetError", this.diagnostic = t, this.cause = n;
107
+ }
108
+ }
109
+ function w(e) {
110
+ if (e.aborted) throw e.reason ?? new DOMException("The operation was aborted.", "AbortError");
111
+ }
112
+ function K(e) {
113
+ const t = { maxAssets: 1e3, maxImageBytes: 33554432, maxTotalImageBytes: 134217728, maxDurationMs: 3e4, ...e.assetBudget };
114
+ for (const [n, s] of Object.entries(t))
115
+ if (!Number.isSafeInteger(s) || s <= 0 || s > 2147483647) throw new RangeError(`${n} must be a positive safe integer at most 2147483647.`);
116
+ return t;
117
+ }
118
+ function W(e) {
119
+ const t = /^data:image\/[a-z0-9.+-]+(;base64)?,(.*)$/is.exec(e);
120
+ if (!t) throw new TypeError("Asset renderers must return an image data URL.");
121
+ return t[1] ? Math.ceil(t[2].length * 3 / 4) : new TextEncoder().encode(decodeURIComponent(t[2])).byteLength;
122
+ }
123
+ function y(e, t, n, s, i) {
124
+ const r = { code: n, message: s, severity: "warning", format: e.options.format ?? "dom", pageIndex: t.pageIndex, componentIndex: t.componentIndex, componentPath: t.componentPath, kind: t.component.kind, nid: t.component.nid };
125
+ if (e.diagnostics.push(r), x(r, { ...e.options, signal: e.signal }), e.options.assetFailure !== "placeholder") throw new v(r, i);
126
+ }
127
+ async function _(e, t, n) {
128
+ const s = e.options.assetRegistry?.rendererFor(t) ?? e.options.assetRenderers?.[t.kind];
129
+ if (t.imageData || !s) return t.imageData;
130
+ if (++e.rendered > e.budget.maxAssets) return y(e, n, "asset-budget-exceeded", "Output exceeded the asset count budget.");
131
+ let i;
132
+ try {
133
+ if (e.active = n, i = await L(s({ ...n, signal: e.signal }), e.signal), w(e.signal), i.length > e.budget.maxImageBytes * 4 + 1024) return y(e, n, "asset-budget-exceeded", "Output exceeded the image payload byte budget.");
134
+ const r = W(i);
135
+ if (r > e.budget.maxImageBytes || e.bytes + r > e.budget.maxTotalImageBytes) return y(e, n, "asset-budget-exceeded", "Output exceeded the encoded image byte budget.");
136
+ /^data:image\/(png|jpe?g);base64,/i.test(i) && e.inspectImage(i), e.bytes += r;
137
+ } catch (r) {
138
+ if (e.signal.aborted || r instanceof v || r instanceof I && r.code === "image-budget-exceeded") throw r;
139
+ return y(e, n, "asset-render-failed", `Asset renderer failed for ${t.kind}; output was not silently omitted.`, r);
140
+ }
141
+ return i;
142
+ }
143
+ function z(e, t) {
144
+ const n = e.active;
145
+ if (!n) {
146
+ t.abort(new Error("Asset rendering exceeded maxDurationMs."));
147
+ return;
148
+ }
149
+ const s = { code: "asset-budget-exceeded", message: "Asset rendering exceeded maxDurationMs.", severity: "warning", format: e.options.format ?? "dom", pageIndex: n.pageIndex, componentIndex: n.componentIndex, componentPath: n.componentPath, kind: n.component.kind, nid: n.component.nid };
150
+ e.diagnostics.push(s);
151
+ try {
152
+ x(s, { ...e.options, signal: e.signal });
153
+ } catch (i) {
154
+ t.abort(i);
155
+ return;
156
+ }
157
+ t.abort(new v(s));
158
+ }
159
+ async function J(e, t, n, s, i) {
160
+ if (!t?.children?.length) return t;
161
+ const r = [];
162
+ for (const [a, o] of t.children.entries())
163
+ r.push(await B(e, o, { ...n, component: o, componentPath: [...s, a] }, i));
164
+ return r.some((a, o) => a !== t.children[o]) ? { ...t, children: r } : t;
165
+ }
166
+ async function B(e, t, n, s) {
167
+ if (w(e.signal), s.has(t)) throw new TypeError("Cyclic grid children cannot be rendered.");
168
+ let i = e.cache.get(t);
169
+ i || (i = _(e, t, n), e.cache.set(t, i));
170
+ const r = await i;
171
+ w(e.signal);
172
+ let a = t.grid;
173
+ if (a) {
174
+ const o = new Set(s).add(t), d = [];
175
+ for (const [c, u] of a.cells.entries()) {
176
+ const g = [];
177
+ for (const [l, f] of u.entries()) g.push(await J(e, f, n, [...n.componentPath, c, l], o));
178
+ d.push(g);
179
+ }
180
+ d.some((c, u) => c.some((g, l) => g !== a.cells[u][l])) && (a = { ...a, cells: d });
181
+ }
182
+ return r !== t.imageData || a !== t.grid ? { ...t, imageData: r, grid: a } : t;
183
+ }
184
+ function V(e, t, n) {
185
+ const s = /* @__PURE__ */ new Set(), i = (r) => {
186
+ if (h(n), !s.has(r)) {
187
+ if (s.add(r), r.imageData && /^data:image\/(png|jpe?g);base64,/i.test(r.imageData))
188
+ try {
189
+ t(r.imageData);
190
+ } catch (a) {
191
+ if (!(a instanceof I) || a.code === "image-budget-exceeded") throw a;
192
+ }
193
+ for (const a of r.grid?.cells ?? []) for (const o of a) for (const d of o?.children ?? []) i(d);
194
+ }
195
+ };
196
+ for (const r of e.pages) for (const a of r.components) i(a);
197
+ }
198
+ function Q(e) {
199
+ if (e.options.fidelity === "strict" && e.diagnostics.length) throw new k(e.diagnostics);
200
+ }
201
+ async function re(e, t = {}) {
202
+ h(t.signal), D(e);
203
+ const n = K(t), s = j(t);
204
+ if (V(e, s, t.signal), t.signal?.aborted) throw t.signal.reason ?? new DOMException("The operation was aborted.", "AbortError");
205
+ const i = new AbortController(), r = () => i.abort(t.signal?.reason);
206
+ if (t.signal?.addEventListener("abort", r, { once: !0 }), !t.assetRegistry && (!t.assetRenderers || !Object.keys(t.assetRenderers).length))
207
+ return t.signal?.removeEventListener("abort", r), { plan: e, diagnostics: [] };
208
+ const a = { options: t, signal: i.signal, diagnostics: [], rendered: 0, bytes: 0, budget: n, cache: /* @__PURE__ */ new WeakMap(), inspectImage: s }, o = setTimeout(() => z(a, i), n.maxDurationMs);
209
+ try {
210
+ const d = [];
211
+ for (const [c, u] of e.pages.entries()) {
212
+ if (c < (t.start ?? 0) || c > (t.end ?? e.pages.length - 1)) {
213
+ d.push(u);
214
+ continue;
215
+ }
216
+ const g = [];
217
+ for (const [l, f] of u.components.entries()) g.push(await B(a, f, { component: f, pageIndex: c, componentIndex: l, componentPath: [] }, /* @__PURE__ */ new Set()));
218
+ d.push(g.some((l, f) => l !== u.components[f]) ? { ...u, components: g } : u);
219
+ }
220
+ return w(a.signal), Q(a), { plan: d.some((c, u) => c !== e.pages[u]) ? { ...e, pages: d } : e, diagnostics: a.diagnostics };
221
+ } finally {
222
+ clearTimeout(o), t.signal?.removeEventListener("abort", r);
223
+ }
224
+ }
225
+ export {
226
+ k as O,
227
+ re as a,
228
+ v as b,
229
+ H as i,
230
+ x as n,
231
+ ne as r
232
+ };
@@ -0,0 +1 @@
1
+ "use strict";const m=require("./component-tree-6TV7W6Yj.cjs"),P=require("./grid-geometry-CZ_cYB6O.cjs"),f=require("./progress-B0ctFpKf.cjs"),E=require("./media-B7vnpD8k.cjs");function v(e,t){f.assertOutputActive(t.signal),f.observeOutput(()=>t.onDiagnostic?.(e)),f.assertOutputActive(t.signal)}class M extends Error{constructor(t){super(`Output contains ${t.length} known fidelity issue(s): ${t[0]?.code}`),this.diagnostics=t,this.code="output-fidelity",this.name="OutputFidelityError"}}const C=new Set(["text","rect","line","ellipse"]),R=new Set(["image","chart","barcode","qrcode"]);function T(e,t){if(!e.grid){if(m.isImageBackedComponent(e))return(t==="pdf"||t==="xlsx")&&!/^data:image\/(png|jpe?g);base64,/i.test(e.imageData)?{code:"unsupported-image-format",message:`${t.toUpperCase()} accepts PNG or JPEG data URLs; convert this image before exporting.`}:void 0;if(R.has(e.kind))return{code:"missing-image",message:`${e.kind} requires imageData or a renderer adapter before output.`};if(!C.has(e.kind))return{code:"unsupported-component",message:`Unsupported component kind: ${e.kind}.`};if(t==="xlsx"&&e.kind!=="text")return{code:"unsupported-component",message:`XLSX data export omits ${e.kind} geometry.`}}}function h(e,t,n,s,i){const r=Object.getOwnPropertyDescriptor(e,"meta")?.value,o=r&&Object.getOwnPropertyDescriptor(r,"componentExtension")?.value,a=o&&Object.getOwnPropertyDescriptor(o,"id")?.value,d=o&&Object.getOwnPropertyDescriptor(o,"version")?.value,c=typeof a=="string"&&a.length<=128&&typeof d=="string"&&d.length<=64?{id:a,version:d}:void 0;return{...i,severity:"warning",format:t,pageIndex:n,componentIndex:s,kind:e.kind,nid:e.nid,...c?{extension:c}:{}}}function w(e,t){if(!e||t==="dom")return;const n=[];return e.rotateDeg&&n.push("rotateDeg"),e.opacity!==void 0&&e.opacity!==1&&n.push("opacity"),t!=="xlsx"&&e.align==="justify"&&n.push("justify"),t==="xlsx"&&e.letterSpacing&&n.push("letterSpacing"),n.length?`${t} does not preserve these styles: ${n.join(", ")}.`:void 0}function A(e){if(!e)return;const t=["backgroundColor","align","verticalAlign","lineHeight","borderTop","borderRight","borderBottom","borderLeft","borderColor","lineColor","lineWidthPt"].filter(n=>e[n]!==void 0);return t.length?`XLSX rich text does not retain independent run styles: ${t.join(", ")}.`:void 0}function L(e){if(e.kind!=="text")return;const t=A(e.style);if(e.leftMm||e.topMm||t)return{code:"unsupported-style",message:`Nested XLSX text is retained as rich text in component order; absolute child offsets and independent paragraph styles are not retained.${t?` ${t}`:""}`}}function k(e,t,n,s,i,r){const o=a=>{i.push({...h(e,t,n,s,{code:"unsupported-style",message:a}),componentPath:r})};for(const a of e.richParagraphs??[]){t==="xlsx"&&(a.spaceBeforeMm||a.spaceAfterMm||a.indentMm||a.align||a.lineHeight)&&o("XLSX rich text preserves fonts and paragraph newlines; paragraph spacing, indentation and alignment are not retained.");const d=w({align:a.align},t);d&&o(d);for(const c of a.segments){const u=w(c.style,t)??(t==="xlsx"?A(c.style):void 0);u&&o(u)}}}function S(e,t,n,s,i,r,o){if(o.has(e))return;const a=new Set(o).add(e),d=T(e,t);d&&r.push({...h(e,t,n,s,d),componentPath:i});const c=w(e.style,t);c&&r.push({...h(e,t,n,s,{code:"unsupported-style",message:c}),componentPath:i}),k(e,t,n,s,r,i),G(e,t,n,s,i,r,a)}function j(e,t,n){if(e.grid)return{code:"nested-components-omitted",message:"XLSX cannot place a nested grid inside a single cell; the nested grid is omitted."};const s=L(e);if(s)return s;if(m.isImageBackedComponent(e)&&(e.leftMm<0||e.topMm<0||e.leftMm+e.widthMm>t+.001||e.topMm+e.heightMm>n+.001))return{code:"unsupported-style",message:"XLSX cannot clip a child image to a cell; it retains the original image dimensions."}}function X(e){let t;return(n,s,i,r)=>{t??=new Map(P.resolveGridLayout(e.grid,e.widthMm,e.heightMm).cells.map(d=>[`${d.ri}:${d.ci}`,d]));const o=t.get(`${s}:${i}`),a=2*(e.grid?.paddingMm??.5);return j(n,(o?.widthMm??0)-a-(r?.indentMm??0),(o?.heightMm??0)-a)}}function G(e,t,n,s,i,r,o){const a=X(e);for(const[d,c]of(e.grid?.cells??[]).entries())for(const[u,g]of c.entries()){g?.dataBar!==void 0&&!m.validDataBar(g.dataBar)&&r.push({...h(e,t,n,s,{code:"unsupported-style",message:"Invalid resolved data-bar geometry or color; visual data bars require ordered 0–1 ratios and #RRGGBB colors."}),componentPath:[...i,d,u]});const l=w(g?.style,t);l&&r.push({...h(e,t,n,s,{code:"unsupported-style",message:l}),componentPath:[...i,d,u]}),g?.richParagraphs?.length&&k({...e,richParagraphs:g.richParagraphs},t,n,s,r,[...i,d,u]);for(const[p,y]of(g?.children??[]).entries()){const D=[...i,d,u,p];if(t==="xlsx"){const I=a(y,d,u,g);if(I&&r.push({...h(y,t,n,s,I),componentPath:D}),y.grid)continue}S(y,t,n,s,D,r,o)}}}function B(e,t){m.assertBoundedRenderTree(e);const n=[];return e.pages.forEach((s,i)=>s.components.forEach((r,o)=>S(r,t,i,o,[],n,new Set))),n}function q(e,t,n){f.assertOutputActive(n.signal);const s=B(e,t);if(s.forEach(i=>v(i,n)),n.fidelity==="strict"&&s.length)throw new M(s);return s}class O extends Error{constructor(t,n){super(t.message),this.name="OutputAssetError",this.diagnostic=t,this.cause=n}}function x(e){if(e.aborted)throw e.reason??new DOMException("The operation was aborted.","AbortError")}function F(e){const t={maxAssets:1e3,maxImageBytes:33554432,maxTotalImageBytes:134217728,maxDurationMs:3e4,...e.assetBudget};for(const[n,s]of Object.entries(t))if(!Number.isSafeInteger(s)||s<=0||s>2147483647)throw new RangeError(`${n} must be a positive safe integer at most 2147483647.`);return t}function N(e){const t=/^data:image\/[a-z0-9.+-]+(;base64)?,(.*)$/is.exec(e);if(!t)throw new TypeError("Asset renderers must return an image data URL.");return t[1]?Math.ceil(t[2].length*3/4):new TextEncoder().encode(decodeURIComponent(t[2])).byteLength}function b(e,t,n,s,i){const r={code:n,message:s,severity:"warning",format:e.options.format??"dom",pageIndex:t.pageIndex,componentIndex:t.componentIndex,componentPath:t.componentPath,kind:t.component.kind,nid:t.component.nid};if(e.diagnostics.push(r),v(r,{...e.options,signal:e.signal}),e.options.assetFailure!=="placeholder")throw new O(r,i)}async function U(e,t,n){const s=e.options.assetRegistry?.rendererFor(t)??e.options.assetRenderers?.[t.kind];if(t.imageData||!s)return t.imageData;if(++e.rendered>e.budget.maxAssets)return b(e,n,"asset-budget-exceeded","Output exceeded the asset count budget.");let i;try{if(e.active=n,i=await f.waitForOutput(s({...n,signal:e.signal}),e.signal),x(e.signal),i.length>e.budget.maxImageBytes*4+1024)return b(e,n,"asset-budget-exceeded","Output exceeded the image payload byte budget.");const r=N(i);if(r>e.budget.maxImageBytes||e.bytes+r>e.budget.maxTotalImageBytes)return b(e,n,"asset-budget-exceeded","Output exceeded the encoded image byte budget.");/^data:image\/(png|jpe?g);base64,/i.test(i)&&e.inspectImage(i),e.bytes+=r}catch(r){if(e.signal.aborted||r instanceof O||r instanceof E.ImageMediaError&&r.code==="image-budget-exceeded")throw r;return b(e,n,"asset-render-failed",`Asset renderer failed for ${t.kind}; output was not silently omitted.`,r)}return i}function H(e,t){const n=e.active;if(!n){t.abort(new Error("Asset rendering exceeded maxDurationMs."));return}const s={code:"asset-budget-exceeded",message:"Asset rendering exceeded maxDurationMs.",severity:"warning",format:e.options.format??"dom",pageIndex:n.pageIndex,componentIndex:n.componentIndex,componentPath:n.componentPath,kind:n.component.kind,nid:n.component.nid};e.diagnostics.push(s);try{v(s,{...e.options,signal:e.signal})}catch(i){t.abort(i);return}t.abort(new O(s))}async function K(e,t,n,s,i){if(!t?.children?.length)return t;const r=[];for(const[o,a]of t.children.entries())r.push(await $(e,a,{...n,component:a,componentPath:[...s,o]},i));return r.some((o,a)=>o!==t.children[a])?{...t,children:r}:t}async function $(e,t,n,s){if(x(e.signal),s.has(t))throw new TypeError("Cyclic grid children cannot be rendered.");let i=e.cache.get(t);i||(i=U(e,t,n),e.cache.set(t,i));const r=await i;x(e.signal);let o=t.grid;if(o){const a=new Set(s).add(t),d=[];for(const[c,u]of o.cells.entries()){const g=[];for(const[l,p]of u.entries())g.push(await K(e,p,n,[...n.componentPath,c,l],a));d.push(g)}d.some((c,u)=>c.some((g,l)=>g!==o.cells[u][l]))&&(o={...o,cells:d})}return r!==t.imageData||o!==t.grid?{...t,imageData:r,grid:o}:t}function W(e,t,n){const s=new Set,i=r=>{if(f.assertOutputActive(n),!s.has(r)){if(s.add(r),r.imageData&&/^data:image\/(png|jpe?g);base64,/i.test(r.imageData))try{t(r.imageData)}catch(o){if(!(o instanceof E.ImageMediaError)||o.code==="image-budget-exceeded")throw o}for(const o of r.grid?.cells??[])for(const a of o)for(const d of a?.children??[])i(d)}};for(const r of e.pages)for(const o of r.components)i(o)}function _(e){if(e.options.fidelity==="strict"&&e.diagnostics.length)throw new M(e.diagnostics)}async function z(e,t={}){f.assertOutputActive(t.signal),m.assertBoundedRenderTree(e);const n=F(t),s=E.createImageMediaInspector(t);if(W(e,s,t.signal),t.signal?.aborted)throw t.signal.reason??new DOMException("The operation was aborted.","AbortError");const i=new AbortController,r=()=>i.abort(t.signal?.reason);if(t.signal?.addEventListener("abort",r,{once:!0}),!t.assetRegistry&&(!t.assetRenderers||!Object.keys(t.assetRenderers).length))return t.signal?.removeEventListener("abort",r),{plan:e,diagnostics:[]};const o={options:t,signal:i.signal,diagnostics:[],rendered:0,bytes:0,budget:n,cache:new WeakMap,inspectImage:s},a=setTimeout(()=>H(o,i),n.maxDurationMs);try{const d=[];for(const[c,u]of e.pages.entries()){if(c<(t.start??0)||c>(t.end??e.pages.length-1)){d.push(u);continue}const g=[];for(const[l,p]of u.components.entries())g.push(await $(o,p,{component:p,pageIndex:c,componentIndex:l,componentPath:[]},new Set));d.push(g.some((l,p)=>l!==u.components[p])?{...u,components:g}:u)}return x(o.signal),_(o),{plan:d.some((c,u)=>c!==e.pages[u])?{...e,pages:d}:e,diagnostics:o.diagnostics}}finally{clearTimeout(a),t.signal?.removeEventListener("abort",r)}}exports.OutputAssetError=O;exports.OutputFidelityError=M;exports.inspectOutputCapabilities=B;exports.notifyOutputDiagnostic=v;exports.reportOutputDiagnostics=q;exports.resolvePlanAssets=z;
@@ -1 +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;
1
+ "use strict";const T=require("./prepared-CGVphji3.cjs"),S=require("./json-snapshot-jiXff4lc.cjs"),R=require("./protocol-ByRVzzQG.cjs"),I=require("./progress-B0ctFpKf.cjs"),_=require("./runtime-CDA6d263.cjs"),d=require("./sha256-DgZAKXqI.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;
@@ -1,20 +1,20 @@
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";
1
+ import { s as A, c as C, a as q } from "./prepared-BE-4jfX5.js";
2
+ import { J as U } from "./json-snapshot-By4ZVVUt.js";
3
+ import { b as T, R as S, v as I, c as $ } from "./protocol-Cr81vFSQ.js";
4
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";
5
+ import { c as N, e as G } from "./runtime-CEMvybO7.js";
6
+ import { D as j, R as M, t as R, v as J, b as L, c as W } from "./sha256-BDQ1Qk7A.js";
7
7
  class O extends Error {
8
8
  constructor(r) {
9
9
  super("报表 Worker 无法启动"), this.cause = r, this.name = "ReportWorkerStartError";
10
10
  }
11
11
  }
12
- let X = 0;
12
+ let K = 0;
13
13
  function D(e) {
14
14
  const r = new Error("报表 Worker 任务已取消");
15
15
  return r.name = "AbortError", Object.defineProperty(r, "cause", { value: e }), r;
16
16
  }
17
- function J(e, r) {
17
+ function X(e, r) {
18
18
  if (!e || typeof e != "object") return;
19
19
  const t = e;
20
20
  return t.protocol === S && t.id === r ? t : void 0;
@@ -30,7 +30,7 @@ function Q(e, r = {}) {
30
30
  i(new O(l));
31
31
  return;
32
32
  }
33
- const w = `mach-report-${Date.now()}-${++X}`;
33
+ const w = `mach-report-${Date.now()}-${++K}`;
34
34
  let m = !1, u = () => {
35
35
  }, y;
36
36
  const p = (l, c) => {
@@ -47,7 +47,7 @@ function Q(e, r = {}) {
47
47
  (E) => i(l ?? E)
48
48
  );
49
49
  }, x = () => p(D(a?.reason)), d = (l) => {
50
- const c = J(l, w);
50
+ const c = X(l, w);
51
51
  if (!(!c || m)) {
52
52
  if ("type" in c && c.type === "event") {
53
53
  const b = "event" in c ? c.event : void 0;
@@ -156,7 +156,7 @@ function re(e, r) {
156
156
  function te(e) {
157
157
  if (e.mode !== void 0 && !["auto", "local", "worker"].includes(e.mode)) throw new TypeError("无效的导出执行模式");
158
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 });
159
+ J({ ...e.budget, maxDurationMs: e.timeoutMs ?? e.budget?.maxDurationMs ?? 12e4 });
160
160
  }
161
161
  function _(e, r) {
162
162
  H(() => e.onDecision?.({ ...r, estimate: { ...r.estimate } }));
@@ -1,4 +1,4 @@
1
- import { a as x, t as N } from "./sha256-DTG-Gq8i.js";
1
+ import { a as x, t as N } from "./sha256-BDQ1Qk7A.js";
2
2
  function R(e = {}) {
3
3
  const t = {
4
4
  maxRecords: e.maxRecords ?? 1e4,
@@ -1 +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;
1
+ "use strict";const v=require("./sha256-DgZAKXqI.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;
@@ -0,0 +1,141 @@
1
+ import { f as w } from "./matrix-Dy-tyY7E.js";
2
+ const g = ["#2563eb", "#0d9488", "#d97706", "#7c3aed", "#dc2626", "#0284c7"];
3
+ function x(e) {
4
+ if (!["bar", "line", "stackedBar", "percentBar"].includes(e.type)) throw new Error("未知图表类型");
5
+ if (!Array.isArray(e.categories) || !Array.isArray(e.series) || !e.categories.length || e.categories.length > 200 || !e.series.length || e.series.length > 12) throw new Error("图表支持 1–200 个分类、1–12 个系列;大数据应先聚合");
6
+ const t = w(e.categories, 200, "图表分类"), r = w(e.series, 12, "图表系列").map((a) => ({ ...a, values: w(a?.values, 200, "图表数值") }));
7
+ for (const a of t) if (typeof a != "string") throw new Error("图表分类应为字符串");
8
+ C(e);
9
+ for (const a of r) N(a, t.length);
10
+ return { ...e, categories: t, series: r };
11
+ }
12
+ function C(e) {
13
+ for (const t of ["leftMm", "topMm", "widthMm", "heightMm"])
14
+ if (!Number.isFinite(e[t]) || e[t] < 0) throw new Error(`${t} 应为有限非负数`);
15
+ if (e.widthMm < 45 || e.heightMm < 35) throw new Error("图表至少需要 45×35mm");
16
+ if (!Number.isFinite(e.leftMm + e.widthMm) || !Number.isFinite(e.topMm + e.heightMm)) throw new Error("图表几何范围溢出");
17
+ }
18
+ function N(e, t) {
19
+ if (!e || typeof e.name != "string" || !Array.isArray(e.values) || e.values.length !== t) throw new Error("图表系列应提供名称及逐分类的有限数字或 null");
20
+ for (const r of e.values) if (r !== null && !Number.isFinite(r)) throw new Error("图表系列应提供名称及逐分类的有限数字或 null");
21
+ if (e.color !== void 0 && !/^#[\da-f]{6}$/i.test(e.color)) throw new Error("图表颜色应为 #RRGGBB");
22
+ }
23
+ function y(e, t, r, a, c, n = 0.8) {
24
+ return { kind: "line", leftMm: Math.min(e, r), topMm: Math.min(t, a), widthMm: Math.abs(r - e), heightMm: Math.abs(a - t), lineDirection: a < t ? "up" : "down", style: { lineColor: c, lineWidthPt: n } };
25
+ }
26
+ function o(e, t, r, a, c = "center") {
27
+ return { kind: "text", text: e, leftMm: t, topMm: r, widthMm: a, heightMm: 5, style: { fontSize: 8, color: "#475569", align: c, verticalAlign: "middle" } };
28
+ }
29
+ function M(e) {
30
+ return Number(e.toPrecision(5)).toString();
31
+ }
32
+ function A(e) {
33
+ let t = 0, r = 0;
34
+ const a = E(e) ? S(e) : void 0;
35
+ if (a)
36
+ t = a.min, r = a.max;
37
+ else for (const u of e.series) for (const f of u.values) f !== null && (t = Math.min(t, f), r = Math.max(r, f));
38
+ t === r && (r = t + 1);
39
+ const c = e.leftMm + 13, n = e.topMm + 8, l = e.widthMm - 17, i = e.heightMm - 23, h = Math.max(Math.abs(t), Math.abs(r), 1), m = t / h, s = r / h - m;
40
+ return { left: c, top: n, width: l, height: i, min: t, max: r, y: (u) => n + i * (1 - (u / h - m) / s) };
41
+ }
42
+ function E(e) {
43
+ return e.type === "stackedBar" || e.type === "percentBar";
44
+ }
45
+ function S(e) {
46
+ let t = 0, r = e.type === "percentBar" ? 100 : 0;
47
+ for (let a = 0; a < e.categories.length; a++) {
48
+ let c = 0, n = 0;
49
+ for (const l of e.series) {
50
+ const i = l.values[a] ?? 0;
51
+ i < 0 ? n += i : c += i;
52
+ }
53
+ if (!Number.isFinite(c) || !Number.isFinite(n)) throw new Error("图表堆叠合计溢出,请先明确缩放单位");
54
+ t = Math.min(t, n), r = Math.max(r, c);
55
+ }
56
+ return { min: t, max: r };
57
+ }
58
+ function z(e) {
59
+ if (e.type !== "percentBar") return e;
60
+ const t = e.categories.map((r, a) => {
61
+ let c = 0;
62
+ for (const n of e.series) {
63
+ const l = n.values[a];
64
+ if (l !== null && l < 0) throw new Error("占比图需要非负度量,负数口径应由业务明确处理");
65
+ c = Math.max(c, l ?? 0);
66
+ }
67
+ return { scale: c, total: c ? e.series.reduce((n, l) => n + (l.values[a] ?? 0) / c, 0) : 0 };
68
+ });
69
+ return { ...e, series: e.series.map((r) => ({ ...r, values: r.values.map((a, c) => {
70
+ if (a === null) return null;
71
+ const { scale: n, total: l } = t[c];
72
+ return n && l ? a / n / l * 100 : 0;
73
+ }) })) };
74
+ }
75
+ function F(e, t) {
76
+ const r = [], a = t.width / e.categories.length;
77
+ return e.categories.forEach((c, n) => {
78
+ let l = 0, i = 0;
79
+ e.series.forEach((h, m) => {
80
+ const s = h.values[n];
81
+ if (s == null) return;
82
+ const u = s < 0 ? i : l, f = u + s;
83
+ s < 0 ? i = f : l = f;
84
+ const b = Math.min(t.y(u), t.y(f)), d = Math.abs(t.y(f) - t.y(u)), B = h.color ?? g[m % g.length], v = t.left + a * (n + 0.15), k = a * 0.7;
85
+ r.push({ kind: "rect", leftMm: v, topMm: b, widthMm: k, heightMm: d, style: { backgroundColor: B, borderTop: !1, borderRight: !1, borderBottom: !1, borderLeft: !1 } }), e.showValues && d >= 5 && r.push({ ...o(e.type === "percentBar" ? `${M(s)}%` : M(s), v, b + d / 2 - 2.5, k), style: { fontSize: 7, color: "#ffffff", align: "center" } });
86
+ });
87
+ }), r;
88
+ }
89
+ function R(e, t) {
90
+ const r = [];
91
+ e.title && r.push({ ...o(e.title, e.leftMm, e.topMm, e.widthMm), style: { fontSize: 10, bold: !0, align: "left" } });
92
+ for (let n = 0; n <= 4; n++) {
93
+ const l = n / 4, i = t.min * (1 - l) + t.max * l, h = t.y(i);
94
+ r.push(y(t.left, h, t.left + t.width, h, "#e2e8f0", 0.4), o(`${M(i)}${e.type === "percentBar" ? "%" : ""}`, e.leftMm, h - 2.5, 11, "right"));
95
+ }
96
+ r.push(y(t.left, t.top, t.left, t.top + t.height, "#94a3b8"));
97
+ const a = Math.max(1, Math.ceil(e.categories.length / Math.max(1, Math.floor(t.width / 14))));
98
+ e.categories.forEach((n, l) => {
99
+ l % a === 0 && r.push(o(n, t.left + (l + 0.5) * t.width / e.categories.length - 7, t.top + t.height + 1, 14));
100
+ });
101
+ const c = t.width / e.series.length;
102
+ return e.series.forEach((n, l) => {
103
+ r.push({ ...o(n.name, t.left + l * c, e.topMm + e.heightMm - 5, c), style: { fontSize: 8, color: n.color ?? g[l % g.length], align: "center" } });
104
+ }), r;
105
+ }
106
+ function W(e, t, r, a) {
107
+ const c = [], n = r.color ?? g[a % g.length], l = t.width / e.categories.length, i = l * 0.75 / e.series.length;
108
+ let h;
109
+ return r.values.forEach((m, s) => {
110
+ if (m === null) {
111
+ h = void 0;
112
+ return;
113
+ }
114
+ const u = t.left + (s + 0.5) * l, f = t.y(m);
115
+ e.type === "bar" ? c.push({ kind: "rect", leftMm: t.left + s * l + l * 0.125 + a * i, topMm: Math.min(f, t.y(0)), widthMm: i, heightMm: Math.abs(t.y(0) - f), style: { backgroundColor: n, borderTop: !1, borderRight: !1, borderBottom: !1, borderLeft: !1 } }) : (h && c.push(y(h.x, h.y, u, f, n, 1.2)), c.push({ kind: "ellipse", leftMm: u - 0.7, topMm: f - 0.7, widthMm: 1.4, heightMm: 1.4, style: { backgroundColor: n, borderColor: n } }), h = { x: u, y: f }), e.showValues && c.push({ ...o(M(m), u - l / 2, Math.max(t.top, f - 5), l), style: { fontSize: 7, color: n, align: "center" } });
116
+ }), c;
117
+ }
118
+ function $(e, t) {
119
+ let r = 0, a = !1;
120
+ for (const c of t.values) {
121
+ if (c === null) {
122
+ a = !1;
123
+ continue;
124
+ }
125
+ r += 1 + +!!e.showValues, e.type === "line" && a && r++, a = !0;
126
+ }
127
+ return r;
128
+ }
129
+ function G(e) {
130
+ const t = e.categories.length, r = Math.max(1, Math.ceil(t / Math.max(1, Math.floor((e.widthMm - 17) / 14)))), a = 11 + +!!e.title + Math.ceil(t / r) + e.series.length;
131
+ return e.series.reduce((c, n) => c + $(e, n), a);
132
+ }
133
+ function O(e) {
134
+ e = z(x(e));
135
+ const t = A(e);
136
+ return [...R(e, t), ...E(e) ? F(e, t) : e.series.flatMap((r, a) => W(e, t, r, a))];
137
+ }
138
+ export {
139
+ G as a,
140
+ O as c
141
+ };
@@ -0,0 +1 @@
1
+ "use strict";const w=require("./matrix-0hywp0-F.cjs"),g=["#2563eb","#0d9488","#d97706","#7c3aed","#dc2626","#0284c7"];function E(e){if(!["bar","line","stackedBar","percentBar"].includes(e.type))throw new Error("未知图表类型");if(!Array.isArray(e.categories)||!Array.isArray(e.series)||!e.categories.length||e.categories.length>200||!e.series.length||e.series.length>12)throw new Error("图表支持 1–200 个分类、1–12 个系列;大数据应先聚合");const t=w.chartArray(e.categories,200,"图表分类"),r=w.chartArray(e.series,12,"图表系列").map(a=>({...a,values:w.chartArray(a?.values,200,"图表数值")}));for(const a of t)if(typeof a!="string")throw new Error("图表分类应为字符串");x(e);for(const a of r)A(a,t.length);return{...e,categories:t,series:r}}function x(e){for(const t of["leftMm","topMm","widthMm","heightMm"])if(!Number.isFinite(e[t])||e[t]<0)throw new Error(`${t} 应为有限非负数`);if(e.widthMm<45||e.heightMm<35)throw new Error("图表至少需要 45×35mm");if(!Number.isFinite(e.leftMm+e.widthMm)||!Number.isFinite(e.topMm+e.heightMm))throw new Error("图表几何范围溢出")}function A(e,t){if(!e||typeof e.name!="string"||!Array.isArray(e.values)||e.values.length!==t)throw new Error("图表系列应提供名称及逐分类的有限数字或 null");for(const r of e.values)if(r!==null&&!Number.isFinite(r))throw new Error("图表系列应提供名称及逐分类的有限数字或 null");if(e.color!==void 0&&!/^#[\da-f]{6}$/i.test(e.color))throw new Error("图表颜色应为 #RRGGBB")}function y(e,t,r,a,c,n=.8){return{kind:"line",leftMm:Math.min(e,r),topMm:Math.min(t,a),widthMm:Math.abs(r-e),heightMm:Math.abs(a-t),lineDirection:a<t?"up":"down",style:{lineColor:c,lineWidthPt:n}}}function o(e,t,r,a,c="center"){return{kind:"text",text:e,leftMm:t,topMm:r,widthMm:a,heightMm:5,style:{fontSize:8,color:"#475569",align:c,verticalAlign:"middle"}}}function M(e){return Number(e.toPrecision(5)).toString()}function N(e){let t=0,r=0;const a=B(e)?S(e):void 0;if(a)t=a.min,r=a.max;else for(const u of e.series)for(const f of u.values)f!==null&&(t=Math.min(t,f),r=Math.max(r,f));t===r&&(r=t+1);const c=e.leftMm+13,n=e.topMm+8,h=e.widthMm-17,i=e.heightMm-23,l=Math.max(Math.abs(t),Math.abs(r),1),m=t/l,s=r/l-m;return{left:c,top:n,width:h,height:i,min:t,max:r,y:u=>n+i*(1-(u/l-m)/s)}}function B(e){return e.type==="stackedBar"||e.type==="percentBar"}function S(e){let t=0,r=e.type==="percentBar"?100:0;for(let a=0;a<e.categories.length;a++){let c=0,n=0;for(const h of e.series){const i=h.values[a]??0;i<0?n+=i:c+=i}if(!Number.isFinite(c)||!Number.isFinite(n))throw new Error("图表堆叠合计溢出,请先明确缩放单位");t=Math.min(t,n),r=Math.max(r,c)}return{min:t,max:r}}function z(e){if(e.type!=="percentBar")return e;const t=e.categories.map((r,a)=>{let c=0;for(const n of e.series){const h=n.values[a];if(h!==null&&h<0)throw new Error("占比图需要非负度量,负数口径应由业务明确处理");c=Math.max(c,h??0)}return{scale:c,total:c?e.series.reduce((n,h)=>n+(h.values[a]??0)/c,0):0}});return{...e,series:e.series.map(r=>({...r,values:r.values.map((a,c)=>{if(a===null)return null;const{scale:n,total:h}=t[c];return n&&h?a/n/h*100:0})}))}}function F(e,t){const r=[],a=t.width/e.categories.length;return e.categories.forEach((c,n)=>{let h=0,i=0;e.series.forEach((l,m)=>{const s=l.values[n];if(s==null)return;const u=s<0?i:h,f=u+s;s<0?i=f:h=f;const b=Math.min(t.y(u),t.y(f)),d=Math.abs(t.y(f)-t.y(u)),C=l.color??g[m%g.length],v=t.left+a*(n+.15),k=a*.7;r.push({kind:"rect",leftMm:v,topMm:b,widthMm:k,heightMm:d,style:{backgroundColor:C,borderTop:!1,borderRight:!1,borderBottom:!1,borderLeft:!1}}),e.showValues&&d>=5&&r.push({...o(e.type==="percentBar"?`${M(s)}%`:M(s),v,b+d/2-2.5,k),style:{fontSize:7,color:"#ffffff",align:"center"}})})}),r}function R(e,t){const r=[];e.title&&r.push({...o(e.title,e.leftMm,e.topMm,e.widthMm),style:{fontSize:10,bold:!0,align:"left"}});for(let n=0;n<=4;n++){const h=n/4,i=t.min*(1-h)+t.max*h,l=t.y(i);r.push(y(t.left,l,t.left+t.width,l,"#e2e8f0",.4),o(`${M(i)}${e.type==="percentBar"?"%":""}`,e.leftMm,l-2.5,11,"right"))}r.push(y(t.left,t.top,t.left,t.top+t.height,"#94a3b8"));const a=Math.max(1,Math.ceil(e.categories.length/Math.max(1,Math.floor(t.width/14))));e.categories.forEach((n,h)=>{h%a===0&&r.push(o(n,t.left+(h+.5)*t.width/e.categories.length-7,t.top+t.height+1,14))});const c=t.width/e.series.length;return e.series.forEach((n,h)=>{r.push({...o(n.name,t.left+h*c,e.topMm+e.heightMm-5,c),style:{fontSize:8,color:n.color??g[h%g.length],align:"center"}})}),r}function W(e,t,r,a){const c=[],n=r.color??g[a%g.length],h=t.width/e.categories.length,i=h*.75/e.series.length;let l;return r.values.forEach((m,s)=>{if(m===null){l=void 0;return}const u=t.left+(s+.5)*h,f=t.y(m);e.type==="bar"?c.push({kind:"rect",leftMm:t.left+s*h+h*.125+a*i,topMm:Math.min(f,t.y(0)),widthMm:i,heightMm:Math.abs(t.y(0)-f),style:{backgroundColor:n,borderTop:!1,borderRight:!1,borderBottom:!1,borderLeft:!1}}):(l&&c.push(y(l.x,l.y,u,f,n,1.2)),c.push({kind:"ellipse",leftMm:u-.7,topMm:f-.7,widthMm:1.4,heightMm:1.4,style:{backgroundColor:n,borderColor:n}}),l={x:u,y:f}),e.showValues&&c.push({...o(M(m),u-h/2,Math.max(t.top,f-5),h),style:{fontSize:7,color:n,align:"center"}})}),c}function $(e,t){let r=0,a=!1;for(const c of t.values){if(c===null){a=!1;continue}r+=1+ +!!e.showValues,e.type==="line"&&a&&r++,a=!0}return r}function L(e){const t=e.categories.length,r=Math.max(1,Math.ceil(t/Math.max(1,Math.floor((e.widthMm-17)/14)))),a=11+ +!!e.title+Math.ceil(t/r)+e.series.length;return e.series.reduce((c,n)=>c+$(e,n),a)}function G(e){e=z(E(e));const t=N(e);return[...R(e,t),...B(e)?F(e,t):e.series.flatMap((r,a)=>W(e,t,r,a))]}exports.chartComponentUpperBound=L;exports.createChartComponents=G;