@agile-team/mach-report 2.21.1 → 2.23.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 (169) hide show
  1. package/README.md +20 -5
  2. package/dist/{ExcelBindingWizard-mnAO2qOX.js → ExcelBindingWizard-D4FLind-.js} +3 -3
  3. package/dist/{ExcelBindingWizard-Bu0LUlzl.cjs → ExcelBindingWizard-D4RS5Bpg.cjs} +1 -1
  4. package/dist/{ParamEditor-38ZfNrPU.cjs → ParamEditor-C-6C9rd2.cjs} +1 -1
  5. package/dist/{ParamEditor-C8l0EC8m.js → ParamEditor-CASZt-Ma.js} +2 -2
  6. package/dist/{ReportBatchPanel-CfUVhvkO.js → ReportBatchPanel-Bq7t8a5r.js} +2 -2
  7. package/dist/{ReportBatchPanel-nCC06Nfp.cjs → ReportBatchPanel-YVj5IO5y.cjs} +1 -1
  8. package/dist/ReportLabelStudio-Cqhita1b.cjs +1 -0
  9. package/dist/ReportLabelStudio-Dj7GXhuv.js +783 -0
  10. package/dist/ReportParamPanel-DZbFVmDL.cjs +1 -0
  11. package/dist/{ReportParamPanel-peB-KEmm.js → ReportParamPanel-Dgmqro1Y.js} +265 -244
  12. package/dist/ReportPreview-DeWzG8jQ.js +6257 -0
  13. package/dist/ReportPreview-FFIryrIr.cjs +6 -0
  14. package/dist/{ReportTemplateLibrary-DVlsf72p.cjs → ReportTemplateLibrary-BaWodmpm.cjs} +1 -1
  15. package/dist/{ReportTemplateLibrary-B5t_EcIs.js → ReportTemplateLibrary-DdAAAD2I.js} +1 -1
  16. package/dist/{RuleEditor-kT1JsZ9f.js → RuleEditor-D2UwQGF6.js} +59 -59
  17. package/dist/{RuleEditor-xFkCVlii.cjs → RuleEditor-DcT9xI1v.cjs} +1 -1
  18. package/dist/TemplateOutlinePanel-CUHFFiNM.cjs +1 -0
  19. package/dist/{TemplateOutlinePanel-BesgGR1P.js → TemplateOutlinePanel-DrT7XN0m.js} +2 -2
  20. package/dist/{TemplateReusePanel-BNFU6V-W.js → TemplateReusePanel-4eejkNqi.js} +2 -2
  21. package/dist/{TemplateReusePanel-BG9Or5-P.cjs → TemplateReusePanel-DZMyiX5I.cjs} +1 -1
  22. package/dist/{TemplateReviewPanel-CwvwyCSs.js → TemplateReviewPanel-BIhNLeNw.js} +2 -2
  23. package/dist/TemplateReviewPanel-DnYImiXu.cjs +1 -0
  24. package/dist/analytics.cjs +1 -1
  25. package/dist/analytics.js +26 -26
  26. package/dist/artifact-integrity.json +108 -106
  27. package/dist/assets-D2gHc4Mz.cjs +1 -0
  28. package/dist/assets-T_gDeFaz.js +132 -0
  29. package/dist/auto-4pK9HePf.cjs +1 -0
  30. package/dist/auto-CTIJ6PnR.js +257 -0
  31. package/dist/capabilities-DiBj4Qgl.cjs +1 -0
  32. package/dist/capabilities-pg7j7VLT.js +106 -0
  33. package/dist/charts-Cjw5AYkg.cjs +1 -0
  34. package/dist/{charts-Dlv8j2AG.js → charts-CxJZ0XaY.js} +1 -1
  35. package/dist/computed-DK6BruFz.cjs +1 -0
  36. package/dist/{computed-C8NRZQss.js → computed-f3pOqWLX.js} +381 -301
  37. package/dist/data-bar-CeZuFmYl.cjs +1 -0
  38. package/dist/{data-bar-8baGYEZ9.js → data-bar-IkI6VvMQ.js} +1 -1
  39. package/dist/designer-DhrE7jzw.js +7169 -0
  40. package/dist/designer-IAZu6kBX.cjs +2 -0
  41. package/dist/designer.cjs +1 -1
  42. package/dist/designer.d.cts +246 -46
  43. package/dist/designer.d.ts +246 -46
  44. package/dist/designer.js +15 -14
  45. package/dist/dom-ChE5D-L-.cjs +1 -0
  46. package/dist/dom-JWrchIre.js +452 -0
  47. package/dist/dom-cell-address-DLD1mkTB.cjs +1 -0
  48. package/dist/dom-cell-address-Fn-8nk7D.js +11 -0
  49. package/dist/{encoding-B79hW4zq.cjs → encoding-BefcaHdp.cjs} +1 -1
  50. package/dist/{encoding-BSeUwrN7.js → encoding-CL6rXEkR.js} +2 -2
  51. package/dist/{font-loader-Di0lQKFf.js → font-loader-BT5baV-o.js} +1 -1
  52. package/dist/{font-loader-BB372_XN.cjs → font-loader-Ga51c2VC.cjs} +1 -1
  53. package/dist/grid-strokes-Be24LGuV.cjs +1 -0
  54. package/dist/grid-strokes-EoY66L2f.js +53 -0
  55. package/dist/index.cjs +8 -8
  56. package/dist/index.d.cts +44 -1
  57. package/dist/index.d.ts +44 -1
  58. package/dist/index.js +961 -1256
  59. package/dist/json-snapshot-1tvQNzQE.cjs +2 -0
  60. package/dist/{json-snapshot-Kgn459Oj.js → json-snapshot-OqkPyUk5.js} +763 -776
  61. package/dist/matrix-B8QWbsGM.cjs +1 -0
  62. package/dist/matrix-C6e_r_vp.js +302 -0
  63. package/dist/{pdf-CARdBcuw.cjs → pdf-HiEeXe9H.cjs} +42 -42
  64. package/dist/{pdf-DmlnL5eB.js → pdf-aobetCsy.js} +20 -20
  65. package/dist/pdf.cjs +1 -1
  66. package/dist/pdf.js +2 -2
  67. package/dist/{plugin-BaRUGORD.cjs → plugin-BFANt-i8.cjs} +1 -1
  68. package/dist/{plugin-D4kAxfLG.js → plugin-DeYYAL6F.js} +1 -1
  69. package/dist/{prefill-CJSazcVY.js → prefill-Dk4C6S5R.js} +21 -21
  70. package/dist/prefill-DsUD5OoK.cjs +1 -0
  71. package/dist/prepared-DCIxhKFo.js +94 -0
  72. package/dist/prepared-Dv-XM3i1.cjs +1 -0
  73. package/dist/progress-ByiOxUD3.js +250 -0
  74. package/dist/progress-WomPRP3B.cjs +1 -0
  75. package/dist/{protocol-C8VWF9An.cjs → protocol-B9YgfQ_d.cjs} +1 -1
  76. package/dist/{protocol-Bs9-ohHN.js → protocol-DxeUKGYG.js} +3 -3
  77. package/dist/record-bindings-DatJZv_e.js +200 -0
  78. package/dist/record-bindings-MBxbeBsi.cjs +1 -0
  79. package/dist/{region-binding-workflow-Cy4GIOUo.js → region-binding-workflow-DjrXuR1q.js} +2 -2
  80. package/dist/{region-binding-workflow-JNowHd0A.cjs → region-binding-workflow-l7NGfagJ.cjs} +2 -2
  81. package/dist/report-encoding-worker.cjs +1 -1
  82. package/dist/report-encoding-worker.js +1 -1
  83. package/dist/rich-text-layout-Ciwa6D2o.js +52 -0
  84. package/dist/rich-text-layout-DK7A_a5r.cjs +3 -0
  85. package/dist/{runtime-BDf5x1i1.js → runtime-75Y5Oq5B.js} +52 -51
  86. package/dist/runtime-DKlGd_D4.cjs +1 -0
  87. package/dist/sbom.cdx.json +1 -1
  88. package/dist/server/node.d.cts +9 -0
  89. package/dist/server/node.d.ts +9 -0
  90. package/dist/server-node.cjs +5 -4
  91. package/dist/server-node.js +2178 -2044
  92. package/dist/server.cjs +1 -1
  93. package/dist/server.d.cts +81 -0
  94. package/dist/server.d.ts +81 -0
  95. package/dist/server.js +24 -24
  96. package/dist/style.css +1 -1
  97. package/dist/{template-catalog-DFwIS9aN.js → template-catalog--cjxzgH7.js} +17 -17
  98. package/dist/template-catalog-CoT7jm_6.cjs +1 -0
  99. package/dist/{template-fragments-Dng-AlHk.js → template-fragments-CPpGpQoz.js} +24 -24
  100. package/dist/{template-fragments-DZVUBhuB.cjs → template-fragments-GVjpew_q.cjs} +1 -1
  101. package/dist/template-registry-DI59PXVK.cjs +1 -0
  102. package/dist/{template-registry-DhBqoD7W.js → template-registry-O0hNIOfB.js} +333 -261
  103. package/dist/template-serialization-CWmHq7lX.js +307 -0
  104. package/dist/template-serialization-CqQY4zDg.cjs +1 -0
  105. package/dist/{textwrap-CkGjRFT3.js → textwrap-BIjtEWmq.js} +1 -1
  106. package/dist/textwrap-Cy7o1hIR.cjs +4 -0
  107. package/dist/vue/async.d.cts +121 -2
  108. package/dist/vue/async.d.ts +121 -2
  109. package/dist/vue/index.d.cts +222 -5
  110. package/dist/vue/index.d.ts +222 -5
  111. package/dist/vue-async.cjs +1 -1
  112. package/dist/vue-async.js +3 -3
  113. package/dist/vue.cjs +1 -1
  114. package/dist/vue.js +101 -91
  115. package/dist/{workbook-session-NYv01LHe.cjs → workbook-session-C6-SrnCT.cjs} +4 -4
  116. package/dist/{workbook-session-oinxX3qo.js → workbook-session-C9ZmCBwY.js} +15 -16
  117. package/dist/workbook-sheets-CaPAulQ6.cjs +2 -0
  118. package/dist/workbook-sheets-D4M7XXBh.js +44 -0
  119. package/dist/worker.cjs +1 -1
  120. package/dist/worker.d.cts +9 -0
  121. package/dist/worker.d.ts +9 -0
  122. package/dist/worker.js +4 -4
  123. package/dist/xlsx.cjs +4 -4
  124. package/dist/xlsx.d.cts +39 -2
  125. package/dist/xlsx.d.ts +39 -2
  126. package/dist/xlsx.js +300 -275
  127. package/package.json +1 -1
  128. package/dist/ReportLabelStudio-CaEvYuSK.cjs +0 -1
  129. package/dist/ReportLabelStudio-DQPBmh4v.js +0 -765
  130. package/dist/ReportParamPanel-CVpK8mFc.cjs +0 -1
  131. package/dist/ReportPreview-BBJNlu2U.js +0 -5740
  132. package/dist/ReportPreview-nf4Dk1Jc.cjs +0 -6
  133. package/dist/TemplateOutlinePanel-CDI6mfWx.cjs +0 -1
  134. package/dist/TemplateReviewPanel-BmBrjt6P.cjs +0 -1
  135. package/dist/assets-CxHunY_9.js +0 -232
  136. package/dist/assets-vbjAGgk8.cjs +0 -1
  137. package/dist/auto-BkdGiNtr.js +0 -240
  138. package/dist/auto-Tq7ReIC1.cjs +0 -1
  139. package/dist/charts-aCtoswXq.cjs +0 -1
  140. package/dist/component-tree-1_QCiQJX.js +0 -67
  141. package/dist/component-tree-BjZIp6w9.cjs +0 -1
  142. package/dist/computed-4TnxzgIh.cjs +0 -1
  143. package/dist/data-bar-YltqGTaC.cjs +0 -1
  144. package/dist/designer-DU3yDWgs.cjs +0 -2
  145. package/dist/designer-HQi-03R6.js +0 -6869
  146. package/dist/grid-geometry-D3SJgWFv.js +0 -136
  147. package/dist/grid-geometry-D8ReblRV.cjs +0 -1
  148. package/dist/json-snapshot-I5VI84Vp.cjs +0 -2
  149. package/dist/matrix-0hywp0-F.cjs +0 -1
  150. package/dist/matrix-Dy-tyY7E.js +0 -381
  151. package/dist/prefill-Bpyn58AZ.cjs +0 -1
  152. package/dist/prepared-BiSz_9vN.cjs +0 -1
  153. package/dist/prepared-BwjwEzFz.js +0 -87
  154. package/dist/progress-B0ctFpKf.cjs +0 -1
  155. package/dist/progress-Hc2vxoCs.js +0 -52
  156. package/dist/record-bindings-Ct1HkPrc.cjs +0 -1
  157. package/dist/record-bindings-VZGS-Qd8.js +0 -155
  158. package/dist/rich-text-layout-K48VHUoW.cjs +0 -3
  159. package/dist/rich-text-layout-wxBhnAS7.js +0 -102
  160. package/dist/runtime-DsJt1PIf.cjs +0 -1
  161. package/dist/template-bindings-Cg5oBLFT.cjs +0 -1
  162. package/dist/template-bindings-TKnXM7ll.js +0 -62
  163. package/dist/template-catalog-D_2jdnkL.cjs +0 -1
  164. package/dist/template-outline-DWkzZXVC.cjs +0 -1
  165. package/dist/template-outline-DiADphlq.js +0 -88
  166. package/dist/template-registry-DpLUSLwF.cjs +0 -1
  167. package/dist/template-serialization-Cc3h-miv.js +0 -247
  168. package/dist/template-serialization-D1R5oAqh.cjs +0 -1
  169. package/dist/textwrap-OTOUMr4f.cjs +0 -4
@@ -0,0 +1,257 @@
1
+ import { s as S, b as j, c as U, a as H } from "./prepared-DCIxhKFo.js";
2
+ import { H as I } from "./json-snapshot-OqkPyUk5.js";
3
+ import { b as W, R as C, v as $, c as N } from "./protocol-DxeUKGYG.js";
4
+ import { u as G } from "./progress-ByiOxUD3.js";
5
+ import { c as K, e as X } from "./runtime-75Y5Oq5B.js";
6
+ import { D as z, R as O, t as R, v as J, c as D, b as M } from "./sha256-BDQ1Qk7A.js";
7
+ class T extends Error {
8
+ constructor(r) {
9
+ super("报表 Worker 无法启动"), this.cause = r, this.name = "ReportWorkerStartError";
10
+ }
11
+ }
12
+ let Q = 0;
13
+ function F(e) {
14
+ const r = new Error("报表 Worker 任务已取消");
15
+ return r.name = "AbortError", Object.defineProperty(r, "cause", { value: e }), r;
16
+ }
17
+ function V(e, r) {
18
+ if (!e || typeof e != "object") return;
19
+ const t = e;
20
+ return t.protocol === C && t.id === r ? t : void 0;
21
+ }
22
+ function Y(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, u) => a?.aborted ? Promise.reject(F(a.reason)) : new Promise((v, i) => {
26
+ let b;
27
+ try {
28
+ b = e();
29
+ } catch (f) {
30
+ i(new T(f));
31
+ return;
32
+ }
33
+ const E = `mach-report-${Date.now()}-${++Q}`;
34
+ let p = !1, d = () => {
35
+ }, y;
36
+ const l = (f, c) => {
37
+ if (p) return;
38
+ p = !0, y && clearTimeout(y);
39
+ let g;
40
+ try {
41
+ d();
42
+ } catch (x) {
43
+ g = x;
44
+ }
45
+ a?.removeEventListener("abort", k), f ??= g, Promise.resolve().then(() => b.terminate()).then(
46
+ () => f === void 0 ? v(c) : i(f),
47
+ (x) => i(f ?? x)
48
+ );
49
+ }, k = () => l(F(a?.reason)), m = (f) => {
50
+ const c = V(f, E);
51
+ if (!(!c || p)) {
52
+ if ("type" in c && c.type === "event") {
53
+ const g = "event" in c ? c.event : void 0;
54
+ $(g, s) ? I(u, g, a) : l(new Error("报表 Worker 返回无效阶段事件"));
55
+ return;
56
+ }
57
+ c.error && typeof c.error.name == "string" && typeof c.error.message == "string" ? l(new W(c.error)) : N(c.result, o) && (o === "prepare" || "format" in c.result && "format" in s && c.result.format === s.format) ? l(void 0, c.result) : l(new Error("报表 Worker 返回无效响应"));
58
+ }
59
+ };
60
+ try {
61
+ if (d = b.subscribe(m, (f) => l(f ?? new Error("报表 Worker 执行失败"))), p) {
62
+ d();
63
+ return;
64
+ }
65
+ if (a?.addEventListener("abort", k, { once: !0 }), y = setTimeout(() => l(new W({ name: "ReportRuntimeError", code: "timeout", message: `报表 Worker 执行超过 ${t}ms` })), t), a?.aborted) k();
66
+ else {
67
+ const { onEvent: f, signal: c, ...g } = s, x = Z(g);
68
+ b.postMessage({ protocol: C, id: E, operation: o, input: g, ...r.budget ? { budget: r.budget } : {} }, x);
69
+ }
70
+ } catch (f) {
71
+ l(f);
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 Z(e) {
77
+ return e.pdf ? (e.pdf = S(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 ee(e, r = {}) {
80
+ return Y(() => {
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 = (u) => n(u.data), a = (u) => o(u instanceof ErrorEvent ? new Error(u.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 re = { 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 h(e) {
99
+ return ++e.visits >= 1e5 && (e.capped = !0), !P(e);
100
+ }
101
+ function w(e) {
102
+ return typeof e == "string" ? e.length * 2 : 0;
103
+ }
104
+ function L(e, r) {
105
+ for (const t of e ?? []) {
106
+ if (!h(r)) return;
107
+ for (const n of t.segments) {
108
+ if (!h(r)) return;
109
+ r.bytes += w(n.text);
110
+ }
111
+ }
112
+ }
113
+ function q(e, r, t) {
114
+ if (t > 32) {
115
+ r.capped = !0;
116
+ return;
117
+ }
118
+ if (h(r)) {
119
+ r.bytes += w(e.text) + w(e.rawText) + w(e.imageData), L(e.richParagraphs, r);
120
+ for (const n of e.lines ?? []) {
121
+ if (!h(r)) return;
122
+ r.bytes += w(n);
123
+ }
124
+ for (const n of e.grid?.cells ?? []) {
125
+ if (!h(r)) return;
126
+ for (const o of n) {
127
+ if (!h(r)) return;
128
+ if (o) {
129
+ r.cells++, r.bytes += w(o.text) + w(o.rawText) + w(o.value), L(o.richParagraphs, r);
130
+ for (const s of o.children ?? []) {
131
+ if (P(r)) return;
132
+ q(s, r, t + 1);
133
+ }
134
+ }
135
+ }
136
+ }
137
+ }
138
+ }
139
+ function te(e, r) {
140
+ if (e.format === "xlsx")
141
+ for (const t of e.xlsx?.additionalSheets ?? []) {
142
+ if (!h(r)) return;
143
+ r.bytes += w(t?.name);
144
+ for (const n of t?.rows ?? []) {
145
+ if (!h(r)) return;
146
+ for (const o of n ?? []) {
147
+ if (!h(r)) return;
148
+ r.cells++, r.bytes += w(o);
149
+ }
150
+ }
151
+ }
152
+ }
153
+ function oe(e) {
154
+ const r = { ...re, ...e.thresholds };
155
+ for (const t of Object.values(r)) if (!Number.isSafeInteger(t) || t <= 0) throw new RangeError("导出隔离阈值应为正安全整数");
156
+ return r;
157
+ }
158
+ function se(e, r) {
159
+ const t = oe(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 };
160
+ for (const u of e.prepared.plan.pages) {
161
+ if (P(o)) break;
162
+ for (const v of u.components) {
163
+ if (P(o)) break;
164
+ q(v, o, 0);
165
+ }
166
+ }
167
+ te(e, o);
168
+ let s = P(o) ? "worker" : "local", a = o.capped ? "scan-limit" : s === "worker" ? "threshold" : "small-task";
169
+ 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" };
170
+ }
171
+ function ne(e) {
172
+ if (e.mode !== void 0 && !["auto", "local", "worker"].includes(e.mode)) throw new TypeError("无效的导出执行模式");
173
+ if (e.fallback !== void 0 && !["local", "error"].includes(e.fallback)) throw new TypeError("无效的导出回退策略");
174
+ J({ ...e.budget, maxDurationMs: e.timeoutMs ?? e.budget?.maxDurationMs ?? 12e4 });
175
+ }
176
+ function _(e, r) {
177
+ G(() => e.onDecision?.({ ...r, estimate: { ...r.estimate } }));
178
+ }
179
+ function A(e, r) {
180
+ return { ...e, mode: "local", reason: r, hardCancellation: !1 };
181
+ }
182
+ function B(e, r, t) {
183
+ M(t, "maxRows", e.stats.rows), M(t, "maxPages", e.stats.pages), M(t, "maxCells", e.stats.cells), M(t, "maxOutputBytes", e.bytes.byteLength), j({ ...r, prepared: { ...r.prepared, stats: e.stats } }, t);
184
+ }
185
+ function ae(e, r) {
186
+ const t = { ...z, ...r.budget }, n = U(e.prepared, t.maxPreparedBytes, e.signal), o = { ...e, prepared: n.prepared, pdf: S(e.pdf), xlsx: H(e.xlsx) };
187
+ return { request: o, forward: () => ({ ...o, prepared: n.forward() }) };
188
+ }
189
+ function ie(e, r) {
190
+ ne(e);
191
+ const t = { ...e, thresholds: { ...e.thresholds }, budget: { ...z, ...e.budget } }, n = t.timeoutMs ?? t.budget.maxDurationMs ?? 12e4, o = K({ reports: {}, budget: { ...t.budget, maxDurationMs: n } }), s = /* @__PURE__ */ new Set();
192
+ let a = !1;
193
+ const u = t.mode !== "worker" && t.fallback !== "error";
194
+ async function v(i, b) {
195
+ const E = Date.now(), p = () => {
196
+ const m = n - (Date.now() - E);
197
+ if (m <= 0) throw new O("timeout", `报表执行超过 ${n}ms`);
198
+ return m;
199
+ };
200
+ let d = se(i, t);
201
+ if (d.reason === "nonserializable-options" && t.mode === "worker") throw new TypeError("Worker 模式不接受函数选项;请使用本地模式或可序列化配置");
202
+ if (d.mode === "worker" && !r) {
203
+ if (!u) throw new T(new Error("未配置 workerFactory"));
204
+ d = A(d, "worker-unavailable");
205
+ }
206
+ const y = ae(i, t), l = y.request;
207
+ if (_(t, d), R(i.signal), d.mode === "worker")
208
+ try {
209
+ const m = r(p());
210
+ if (!m.exportPrepared) throw new TypeError("隔离执行器缺少 exportPrepared");
211
+ const { signal: f, onEvent: c, ...g } = l, x = await m.exportPrepared(g, f, c);
212
+ return R(f), B(x, l, t.budget), { ...x, execution: d };
213
+ } catch (m) {
214
+ if (!(m instanceof T) || !u) throw m;
215
+ R(i.signal), d = A(d, "worker-start-failed"), _(t, d);
216
+ }
217
+ b && (l.prepared = X(l.prepared, t.budget), j(l, t.budget));
218
+ const k = b ? await D(i.signal, p(), (m) => b({ ...l, signal: m })) : await D(i.signal, p(), (m) => o.exportPrepared({ ...y.forward(), signal: m }));
219
+ return R(i.signal), B(k, l, t.budget), { ...k, execution: d };
220
+ }
221
+ return {
222
+ async exportPrepared(i, b) {
223
+ if (a) throw new O("closed", "导出执行器已释放");
224
+ if (R(i.signal), s.size >= 2) throw new O("queue-full", "同时导出的任务已达 2 个,请等待完成后重试");
225
+ const E = new AbortController();
226
+ s.add(E);
227
+ const p = () => E.abort(i.signal?.reason);
228
+ i.signal?.addEventListener("abort", p, { once: !0 });
229
+ try {
230
+ return await v({ ...i, signal: E.signal }, b);
231
+ } finally {
232
+ i.signal?.removeEventListener("abort", p), s.delete(E);
233
+ }
234
+ },
235
+ cancel() {
236
+ for (const i of s) i.abort();
237
+ },
238
+ dispose() {
239
+ a = !0;
240
+ for (const i of s) i.abort();
241
+ }
242
+ };
243
+ }
244
+ function ce(e = {}) {
245
+ const r = e.workerFactory, t = { timeoutMs: e.timeoutMs ?? e.budget?.maxDurationMs, budget: { ...e.budget } };
246
+ return ie(e, r ? (n) => ee(r, { ...t, timeoutMs: n }) : void 0);
247
+ }
248
+ const be = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
249
+ __proto__: null,
250
+ createAutoReportExporter: ce
251
+ }, Symbol.toStringTag, { value: "Module" }));
252
+ export {
253
+ T as R,
254
+ ee as a,
255
+ be as b,
256
+ ce as c
257
+ };
@@ -0,0 +1 @@
1
+ "use strict";const c=require("./progress-WomPRP3B.cjs");function M(e,t){c.assertOutputActive(t.signal),c.observeOutput(()=>t.onDiagnostic?.(e)),c.assertOutputActive(t.signal)}class b 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 $=new Set(["text","rect","line","ellipse"]),k=new Set(["image","chart","barcode","qrcode"]);function m(e,t){if(!e.grid){if(c.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(k.has(e.kind))return{code:"missing-image",message:`${e.kind} requires imageData or a renderer adapter before output.`};if(!$.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 p(e,t,i,s,r){const o=Object.getOwnPropertyDescriptor(e,"meta")?.value,u=o&&Object.getOwnPropertyDescriptor(o,"componentExtension")?.value,n=u&&Object.getOwnPropertyDescriptor(u,"id")?.value,a=u&&Object.getOwnPropertyDescriptor(u,"version")?.value,d=typeof n=="string"&&n.length<=128&&typeof a=="string"&&a.length<=64?{id:n,version:a}:void 0;return{...r,severity:"warning",format:t,pageIndex:i,componentIndex:s,kind:e.kind,nid:e.nid,...d?{extension:d}:{}}}function h(e,t){if(!e||t==="dom")return;const i=[];return e.rotateDeg&&i.push("rotateDeg"),e.opacity!==void 0&&e.opacity!==1&&i.push("opacity"),t!=="xlsx"&&e.align==="justify"&&i.push("justify"),t==="xlsx"&&e.letterSpacing&&i.push("letterSpacing"),i.length?`${t} does not preserve these styles: ${i.join(", ")}.`:void 0}function x(e){if(!e)return;const t=["backgroundColor","align","verticalAlign","lineHeight","borderTop","borderRight","borderBottom","borderLeft","borderColor","lineColor","lineWidthPt"].filter(i=>e[i]!==void 0);return t.length?`XLSX rich text does not retain independent run styles: ${t.join(", ")}.`:void 0}function X(e){if(e.kind!=="text")return;const t=x(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 w(e,t,i,s,r,o){const u=n=>{r.push({...p(e,t,i,s,{code:"unsupported-style",message:n}),componentPath:o})};for(const n of e.richParagraphs??[]){t==="xlsx"&&(n.spaceBeforeMm||n.spaceAfterMm||n.indentMm||n.align||n.lineHeight)&&u("XLSX rich text preserves fonts and paragraph newlines; paragraph spacing, indentation and alignment are not retained.");const a=h({align:n.align},t);a&&u(a);for(const d of n.segments){const l=h(d.style,t)??(t==="xlsx"?x(d.style):void 0);l&&u(l)}}}function D(e,t,i,s,r,o,u){if(u.has(e))return;const n=new Set(u).add(e),a=m(e,t);a&&o.push({...p(e,t,i,s,a),componentPath:r});const d=h(e.style,t);d&&o.push({...p(e,t,i,s,{code:"unsupported-style",message:d}),componentPath:r}),w(e,t,i,s,o,r),j(e,t,i,s,r,o,n)}function B(e,t,i){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=X(e);if(s)return s;if(c.isImageBackedComponent(e)&&(e.leftMm<0||e.topMm<0||e.leftMm+e.widthMm>t+.001||e.topMm+e.heightMm>i+.001))return{code:"unsupported-style",message:"XLSX cannot clip a child image to a cell; it retains the original image dimensions."}}function C(e){let t;return(i,s,r,o)=>{t??=new Map(c.resolveGridLayout(e.grid,e.widthMm,e.heightMm).cells.map(a=>[`${a.ri}:${a.ci}`,a]));const u=t.get(`${s}:${r}`),n=2*(e.grid?.paddingMm??.5);return B(i,(u?.widthMm??0)-n-(o?.indentMm??0),(u?.heightMm??0)-n)}}function j(e,t,i,s,r,o,u){const n=C(e);for(const[a,d]of(e.grid?.cells??[]).entries())for(const[l,g]of d.entries()){g?.dataBar!==void 0&&!c.validDataBar(g.dataBar)&&o.push({...p(e,t,i,s,{code:"unsupported-style",message:"Invalid resolved data-bar geometry or color; visual data bars require ordered 0–1 ratios and #RRGGBB colors."}),componentPath:[...r,a,l]});const y=h(g?.style,t);y&&o.push({...p(e,t,i,s,{code:"unsupported-style",message:y}),componentPath:[...r,a,l]}),g?.richParagraphs?.length&&w({...e,richParagraphs:g.richParagraphs},t,i,s,o,[...r,a,l]);for(const[E,f]of(g?.children??[]).entries()){const v=[...r,a,l,E];if(t==="xlsx"){const O=n(f,a,l,g);if(O&&o.push({...p(f,t,i,s,O),componentPath:v}),f.grid)continue}D(f,t,i,s,v,o,u)}}}function S(e,t){c.assertBoundedRenderTree(e);const i=[];return e.pages.forEach((s,r)=>s.components.forEach((o,u)=>D(o,t,r,u,[],i,new Set))),i}function L(e,t,i){c.assertOutputActive(i.signal);const s=S(e,t);if(s.forEach(r=>M(r,i)),i.fidelity==="strict"&&s.length)throw new b(s);return s}exports.OutputFidelityError=b;exports.inspectOutputCapabilities=S;exports.notifyOutputDiagnostic=M;exports.reportOutputDiagnostics=L;
@@ -0,0 +1,106 @@
1
+ import { v as h, u as D, E, i as M, y as $, r as k } from "./progress-ByiOxUD3.js";
2
+ function m(e, t) {
3
+ h(t.signal), D(() => t.onDiagnostic?.(e)), h(t.signal);
4
+ }
5
+ class X extends Error {
6
+ constructor(t) {
7
+ super(`Output contains ${t.length} known fidelity issue(s): ${t[0]?.code}`), this.diagnostics = t, this.code = "output-fidelity", this.name = "OutputFidelityError";
8
+ }
9
+ }
10
+ const j = /* @__PURE__ */ new Set(["text", "rect", "line", "ellipse"]), B = /* @__PURE__ */ new Set(["image", "chart", "barcode", "qrcode"]);
11
+ function L(e, t) {
12
+ if (!e.grid) {
13
+ if (M(e))
14
+ 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;
15
+ if (B.has(e.kind)) return { code: "missing-image", message: `${e.kind} requires imageData or a renderer adapter before output.` };
16
+ if (!j.has(e.kind)) return { code: "unsupported-component", message: `Unsupported component kind: ${e.kind}.` };
17
+ if (t === "xlsx" && e.kind !== "text") return { code: "unsupported-component", message: `XLSX data export omits ${e.kind} geometry.` };
18
+ }
19
+ }
20
+ function g(e, t, s, i, r) {
21
+ const o = Object.getOwnPropertyDescriptor(e, "meta")?.value, u = o && Object.getOwnPropertyDescriptor(o, "componentExtension")?.value, n = u && Object.getOwnPropertyDescriptor(u, "id")?.value, a = u && Object.getOwnPropertyDescriptor(u, "version")?.value, d = typeof n == "string" && n.length <= 128 && typeof a == "string" && a.length <= 64 ? { id: n, version: a } : void 0;
22
+ return { ...r, severity: "warning", format: t, pageIndex: s, componentIndex: i, kind: e.kind, nid: e.nid, ...d ? { extension: d } : {} };
23
+ }
24
+ function f(e, t) {
25
+ if (!e || t === "dom") return;
26
+ const s = [];
27
+ return e.rotateDeg && s.push("rotateDeg"), e.opacity !== void 0 && e.opacity !== 1 && s.push("opacity"), t !== "xlsx" && e.align === "justify" && s.push("justify"), t === "xlsx" && e.letterSpacing && s.push("letterSpacing"), s.length ? `${t} does not preserve these styles: ${s.join(", ")}.` : void 0;
28
+ }
29
+ function b(e) {
30
+ if (!e) return;
31
+ const t = ["backgroundColor", "align", "verticalAlign", "lineHeight", "borderTop", "borderRight", "borderBottom", "borderLeft", "borderColor", "lineColor", "lineWidthPt"].filter((s) => e[s] !== void 0);
32
+ return t.length ? `XLSX rich text does not retain independent run styles: ${t.join(", ")}.` : void 0;
33
+ }
34
+ function C(e) {
35
+ if (e.kind !== "text") return;
36
+ const t = b(e.style);
37
+ 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}` : ""}` };
38
+ }
39
+ function w(e, t, s, i, r, o) {
40
+ const u = (n) => {
41
+ r.push({ ...g(e, t, s, i, { code: "unsupported-style", message: n }), componentPath: o });
42
+ };
43
+ for (const n of e.richParagraphs ?? []) {
44
+ t === "xlsx" && (n.spaceBeforeMm || n.spaceAfterMm || n.indentMm || n.align || n.lineHeight) && u("XLSX rich text preserves fonts and paragraph newlines; paragraph spacing, indentation and alignment are not retained.");
45
+ const a = f({ align: n.align }, t);
46
+ a && u(a);
47
+ for (const d of n.segments) {
48
+ const l = f(d.style, t) ?? (t === "xlsx" ? b(d.style) : void 0);
49
+ l && u(l);
50
+ }
51
+ }
52
+ }
53
+ function O(e, t, s, i, r, o, u) {
54
+ if (u.has(e)) return;
55
+ const n = new Set(u).add(e), a = L(e, t);
56
+ a && o.push({ ...g(e, t, s, i, a), componentPath: r });
57
+ const d = f(e.style, t);
58
+ d && o.push({ ...g(e, t, s, i, { code: "unsupported-style", message: d }), componentPath: r }), w(e, t, s, i, o, r), R(e, t, s, i, r, o, n);
59
+ }
60
+ function P(e, t, s) {
61
+ if (e.grid) return { code: "nested-components-omitted", message: "XLSX cannot place a nested grid inside a single cell; the nested grid is omitted." };
62
+ const i = C(e);
63
+ if (i) return i;
64
+ if (M(e) && (e.leftMm < 0 || e.topMm < 0 || e.leftMm + e.widthMm > t + 1e-3 || e.topMm + e.heightMm > s + 1e-3)) return { code: "unsupported-style", message: "XLSX cannot clip a child image to a cell; it retains the original image dimensions." };
65
+ }
66
+ function G(e) {
67
+ let t;
68
+ return (s, i, r, o) => {
69
+ t ??= new Map(k(e.grid, e.widthMm, e.heightMm).cells.map((a) => [`${a.ri}:${a.ci}`, a]));
70
+ const u = t.get(`${i}:${r}`), n = 2 * (e.grid?.paddingMm ?? 0.5);
71
+ return P(s, (u?.widthMm ?? 0) - n - (o?.indentMm ?? 0), (u?.heightMm ?? 0) - n);
72
+ };
73
+ }
74
+ function R(e, t, s, i, r, o, u) {
75
+ const n = G(e);
76
+ for (const [a, d] of (e.grid?.cells ?? []).entries()) for (const [l, c] of d.entries()) {
77
+ c?.dataBar !== void 0 && !$(c.dataBar) && o.push({ ...g(e, t, s, i, { code: "unsupported-style", message: "Invalid resolved data-bar geometry or color; visual data bars require ordered 0–1 ratios and #RRGGBB colors." }), componentPath: [...r, a, l] });
78
+ const y = f(c?.style, t);
79
+ y && o.push({ ...g(e, t, s, i, { code: "unsupported-style", message: y }), componentPath: [...r, a, l] }), c?.richParagraphs?.length && w({ ...e, richParagraphs: c.richParagraphs }, t, s, i, o, [...r, a, l]);
80
+ for (const [S, p] of (c?.children ?? []).entries()) {
81
+ const v = [...r, a, l, S];
82
+ if (t === "xlsx") {
83
+ const x = n(p, a, l, c);
84
+ if (x && o.push({ ...g(p, t, s, i, x), componentPath: v }), p.grid) continue;
85
+ }
86
+ O(p, t, s, i, v, o, u);
87
+ }
88
+ }
89
+ }
90
+ function N(e, t) {
91
+ E(e);
92
+ const s = [];
93
+ return e.pages.forEach((i, r) => i.components.forEach((o, u) => O(o, t, r, u, [], s, /* @__PURE__ */ new Set()))), s;
94
+ }
95
+ function T(e, t, s) {
96
+ h(s.signal);
97
+ const i = N(e, t);
98
+ if (i.forEach((r) => m(r, s)), s.fidelity === "strict" && i.length) throw new X(i);
99
+ return i;
100
+ }
101
+ export {
102
+ X as O,
103
+ N as i,
104
+ m as n,
105
+ T as r
106
+ };
@@ -0,0 +1 @@
1
+ "use strict";const w=require("./computed-DK6BruFz.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;
@@ -1,4 +1,4 @@
1
- import { f as w } from "./matrix-Dy-tyY7E.js";
1
+ import { u as w } from "./computed-f3pOqWLX.js";
2
2
  const g = ["#2563eb", "#0d9488", "#d97706", "#7c3aed", "#dc2626", "#0284c7"];
3
3
  function x(e) {
4
4
  if (!["bar", "line", "stackedBar", "percentBar"].includes(e.type)) throw new Error("未知图表类型");
@@ -0,0 +1 @@
1
+ "use strict";function Y(r,e,t){if(!Array.isArray(r)||Object.getPrototypeOf(r)!==Array.prototype||r.length>e)throw new TypeError(`${t}应为有界普通数组`);if(Reflect.ownKeys(r).length!==r.length+1)throw new TypeError(`${t}不支持自定义数组方法或迭代器`);const n=[];for(let o=0;o<r.length;o++){const c=Object.getOwnPropertyDescriptor(r,String(o));if(!c||!Object.prototype.hasOwnProperty.call(c,"value"))throw new TypeError(`${t}不支持空洞或访问器`);n.push(c.value)}return n}const O=1e3;function p(r){if(!Number.isSafeInteger(r)||r<0||r>O*2)throw new Error("十进制精度超出预算");return 10n**BigInt(r)}function j(r){if(r.coefficient.toString().length>O*2||r.scale>O*2)throw new Error("十进制结果超出精度预算");return r}function u(r){if(typeof r!="string"&&!(typeof r=="number"&&Number.isFinite(r)))throw new Error("十进制参数必须是有限数字或十进制文本");const e=String(r);if(e.length>O)throw new Error("十进制文本超出精度预算");const t=/^([+-]?)(\d+)(?:\.(\d*))?(?:[eE]([+-]?\d{1,4}))?$/.exec(e);if(!t)throw new Error("无效十进制文本");const n=t[3]??"",o=Number(t[4]??0),c=n.length-o,i=BigInt(`${t[1]==="-"?"-":""}${t[2]}${n}`);return j(c<0?{coefficient:i*p(-c),scale:0}:{coefficient:i,scale:c})}function L(r,e){const t=Math.max(r.scale,e.scale);return[r.coefficient*p(t-r.scale),e.coefficient*p(t-e.scale),t]}function y(r,e){const[t,n]=L(r,e);return t<n?-1:t>n?1:0}function E(r,e){const[t,n,o]=L(r,e);return j({coefficient:t+n,scale:o})}function M(r,e){return j({coefficient:r.coefficient*e.coefficient,scale:r.scale+e.scale})}function H(r,e){const t=r/e,n=r%e,o=c=>c<0n?-c:c;return o(n)*2n<o(e)?t:t+(r<0n==e<0n?1n:-1n)}function h(r){if(!Number.isInteger(r)||r<0||r>100)throw new Error("十进制小数位应为 0–100 的整数")}function N(r,e,t=20){if(h(t),e.coefficient===0n)throw new Error("不能除以零");const n=e.scale-r.scale+t,o=r.coefficient*p(Math.max(0,n)),c=e.coefficient*p(Math.max(0,-n));return j({coefficient:H(o,c),scale:t})}function A(r,e){let t=r.coefficient,n=r.scale;e!==void 0&&(h(e),t=e>=n?t*p(e-n):H(t,p(n-e)),n=e);const o=t<0n,c=(o?-t:t).toString().padStart(n+1,"0");let i=n?c.slice(-n):"";return e===void 0&&(i=i.replace(/0+$/,"")),`${o?"-":""}${n?c.slice(0,-n):c}${i?`.${i}`:""}`}function nr(r,e,t=!1,n=!1){let o=u(r);n&&(o=M(o,{coefficient:100n,scale:0}));const[c,i]=A(o,e).split(".");return`${t?c.replace(/\B(?=(\d{3})+(?!\d))/g,","):c}${i===void 0?"":`.${i}`}${n?"%":""}`}const or=["sum","count","avg","min","max","weightedAvg"];function V(r){if(typeof r!="number"||!Number.isFinite(r))throw new Error("聚合度量必须是有限数字,不能隐式转换;小数文本请显式选择 decimal");return r}function D(r,e){return e&&Object.prototype.hasOwnProperty.call(r,e)?r[e]:void 0}function ir(r){let e=0,t=0,n=0,o=0,c=1/0,i=-1/0;const a=s=>{const f=s-n,l=t+f;n=l-t-f,t=l};return{add(s){const f=D(s,r.field);if(r.op==="count"){(!r.field||f!=null)&&e++;return}if(f==null)return;const l=V(f),d=r.op==="weightedAvg"?D(s,r.weightField):1;if(d==null)return;const x=V(d);if(r.op==="weightedAvg"&&x<0)throw new Error("加权平均的权重不能为负数");["sum","avg","weightedAvg"].includes(r.op)&&a(l*x),o+=x,c=Math.min(c,l),i=Math.max(i,l),e++},value(){if(r.op==="count")return e;if(!e)return null;const s=r.op==="min"?c:r.op==="max"?i:r.op==="avg"?t/e:r.op==="weightedAvg"?o===0?null:t/o:t;if(s!==null&&!Number.isFinite(s))throw new Error("聚合计算溢出");return s}}}function cr(r){let e=0,t=u("0"),n=u("0"),o,c;return{add(i){const a=D(i,r.field);if(r.op==="count"){(!r.field||a!=null)&&e++;return}if(a==null)return;const s=r.op==="weightedAvg"?D(i,r.weightField):"1";if(s==null)return;const f=u(a),l=u(s);if(r.op==="weightedAvg"&&l.coefficient<0n)throw new Error("加权平均的权重不能为负数");["sum","avg","weightedAvg"].includes(r.op)&&(t=E(t,M(f,l))),r.op==="weightedAvg"&&(n=E(n,l)),(!o||y(f,o)<0)&&(o=f),(!c||y(f,c)>0)&&(c=f),e++},value(){if(r.op==="count")return e;if(!e||r.op==="weightedAvg"&&n.coefficient===0n)return null;let i=r.op==="min"?o:r.op==="max"?c:t;return r.op==="avg"&&(i=N(t,u(e),r.digits)),r.op==="weightedAvg"&&(i=N(t,n,r.digits)),A(i,r.digits)}}}function R(r){if(r.digits!==void 0&&h(r.digits),r.numeric!==void 0&&r.numeric!=="number"&&r.numeric!=="decimal")throw new Error("未知聚合数值模式");if(!or.includes(r.op))throw new Error("未知聚合操作");if(r.op!=="count"&&!r.field)throw new Error("聚合需要度量字段");if(r.op==="weightedAvg"&&!r.weightField)throw new Error("加权平均需要权重字段");return r.numeric==="decimal"?cr(r):ir(r)}function P(r,e){const t=R(e);for(const n of r)t.add(n);return t.value()}const Q=new Set(["__proto__","prototype","constructor"]);function q(r){if(!r||typeof r!="object"||Array.isArray(r)||![Object.prototype,null].includes(Object.getPrototypeOf(r)))throw new Error("条件应为普通声明式对象");for(const[e,t]of Object.entries(Object.getOwnPropertyDescriptors(r)))if(Q.has(e)||!Object.prototype.hasOwnProperty.call(t,"value"))throw new Error("条件不允许访问器或不安全属性")}function W(r){if(typeof r!="string"||!r.trim()||r.length>512||Q.has(r))throw new Error("条件字段应为安全的非空字段名")}function k(r){if(r!==null&&typeof r!="boolean"&&typeof r!="string"&&!(typeof r=="number"&&Number.isFinite(r)))throw new Error("条件常量应为有限 JSON 标量");if(typeof r=="string"&&r.length>16384)throw new Error("条件文本超出预算")}function T(r){if(typeof r!="string"||!/^\d{4}-\d{2}-\d{2}$/.test(r))throw new Error("日期条件使用 YYYY-MM-DD 日历日");const[e,t,n]=r.split("-").map(Number),o=new Date(0);if(o.setUTCFullYear(e,t-1,n),o.setUTCHours(0,0,0,0),o.getUTCFullYear()!==e||o.getUTCMonth()!==t-1||o.getUTCDate()!==n)throw new Error("无效日历日");return r}function z(r){return["string","boolean"].includes(typeof r)||typeof r=="number"&&Number.isFinite(r)}function J(r){return r==null||r===""}function ar(r){const e=r.values?.[0]??(r.right&&"value"in r.right?r.right.value:r.value);return r.valueType??r.numeric??(typeof e=="number"?"decimal":typeof e=="boolean"?"boolean":"text")}function b(r,e,t){if(J(r)||J(e))return;const n=ar(t);try{if(n==="decimal")return y(u(r),u(e));if(n==="number")return!["number","string"].includes(typeof r)||!["number","string"].includes(typeof e)?void 0:y(u(r),u(e));if(n==="date"&&(r=T(r),e=T(e)),n==="boolean"&&(typeof r!="boolean"||typeof e!="boolean")||n==="text"&&(!z(r)||!z(e)))return;const o=String(r),c=String(e);return o<c?-1:o>c?1:0}catch{return}}function sr(r){if(W(r.field),![">",">=","<","<=","==","!=","between","contains","isNull","isNotNull"].includes(r.op))throw new Error("未知条件运算符");if(r.numeric!==void 0&&!["number","decimal"].includes(r.numeric))throw new Error("未知条件数值模式");if(r.valueType!==void 0&&!["number","decimal","text","date","boolean"].includes(r.valueType))throw new Error("未知条件值类型");if(!(r.op==="isNull"||r.op==="isNotNull"))if(r.op==="between"){if(!Array.isArray(r.values)||r.values.length!==2||Object.keys(r.values).length!==2)throw new Error("范围条件需要两个明确边界");r.values.forEach(k);const e=b(r.values[0],r.values[1],r);if(e===void 0||e>0)throw new Error("范围边界无效或顺序颠倒")}else if(r.right!==void 0){if(q(r.right),Object.keys(r.right).length!==1)throw new Error("条件 right 只能指定一个 field 或 value");if("field"in r.right?W(r.right.field):k(r.right.value),r.value!==void 0)throw new Error("条件不能同时指定 value 和 right")}else k(r.value)}function C(r,e){if(e===void 0)return!1;switch(r){case">":return e>0;case">=":return e>=0;case"<":return e<0;case"<=":return e<=0;case"==":return e===0;case"!=":return e!==0;default:return!1}}function fr(r){sr(r),r={...r,right:r.right?{...r.right}:void 0,values:r.values?[r.values[0],r.values[1]]:void 0};const e=(t,n)=>Object.prototype.hasOwnProperty.call(t,n)?t[n]:void 0;return t=>{const n=e(t,r.field);if(r.op==="isNull")return n==null;if(r.op==="isNotNull")return n!=null;if(r.op==="between")return C(">=",b(n,r.values[0],r))&&C("<=",b(n,r.values[1],r));const o=r.right?"field"in r.right?e(t,r.right.field):r.right.value:r.value;return r.op==="contains"?typeof n=="string"&&typeof o=="string"&&n.includes(o):C(r.op,b(n,o,r))}}function w(r,e={nodes:0},t=0){if(++e.nodes>256||t>16)throw new Error("条件超出深度或节点预算");if(q(r),["all","any","not","field"].filter(o=>Object.prototype.hasOwnProperty.call(r,o)).length!==1)throw new Error("条件只能指定一种组合或比较");if("not"in r){const o=w(r.not,e,t+1);return c=>!o(c)}if("all"in r||"any"in r){const o="all"in r?r.all:r.any;if(!Array.isArray(o)||o.length<1||o.length>256||Object.keys(o).length!==o.length)throw new Error("组合条件需要有界、无空位的非空数组");const c=o.map(i=>w(i,e,t+1));return"all"in r?i=>c.every(a=>a(i)):i=>c.some(a=>a(i))}return fr(r)}function lr(r,e){return w(e)(r)}function rr(r){w(r);const e=new Set;function t(n){"all"in n?n.all.forEach(t):"any"in n?n.any.forEach(t):"not"in n?t(n.not):(e.add(n.field),n.right&&"field"in n.right&&e.add(n.right.field))}return t(r),[...e]}const ur=[{name:"add",minArgs:2,maxArgs:256,input:"numeric",output:"numeric",example:"add(quantity, adjustment)"},{name:"subtract",minArgs:2,maxArgs:2,input:"numeric",output:"numeric",example:"subtract(input, output)"},{name:"multiply",minArgs:2,maxArgs:256,input:"numeric",output:"numeric",example:"multiply(quantity, price)"},{name:"divide",minArgs:2,maxArgs:2,input:"numeric",output:"numeric",example:"divide(amount, quantity)"},{name:"coalesce",minArgs:2,maxArgs:256,input:"scalar",output:"scalar",example:"coalesce(actual, planned)"},{name:"if",minArgs:2,maxArgs:2,input:"condition + branches",output:"scalar",example:"if(quantity > 0, divide(amount, quantity), null)"},{name:"round",minArgs:1,maxArgs:2,input:"numeric, digits?",output:"numeric",example:"round(amount, 2)"},{name:"abs",minArgs:1,maxArgs:1,input:"numeric",output:"numeric",example:"abs(difference)"},{name:"concat",minArgs:2,maxArgs:256,input:"text",output:"text",example:"concat(plant, '-' , heat)"},{name:"trim",minArgs:1,maxArgs:1,input:"text",output:"text",example:"trim(heat)"},{name:"upper",minArgs:1,maxArgs:1,input:"text",output:"text",example:"upper(grade)"},{name:"lower",minArgs:1,maxArgs:1,input:"text",output:"text",example:"lower(code)"},{name:"dateYear",minArgs:1,maxArgs:1,input:"YYYY-MM-DD",output:"number",example:"dateYear(reportDate)"},{name:"dateMonth",minArgs:1,maxArgs:1,input:"YYYY-MM-DD",output:"number",example:"dateMonth(reportDate)"},{name:"dateDay",minArgs:1,maxArgs:1,input:"YYYY-MM-DD",output:"number",example:"dateDay(reportDate)"}],$=Object.freeze(ur.map(r=>Object.freeze(r)));function mr(r,e,t,n,o){if(e.some(a=>a==null)){if(o==="error")throw new Error("函数参数包含空值");return null}if(r==="round"||r==="abs")return dr(r,e,t,n);if(r.startsWith("date")){const a=T(e[0]);return Number(a.slice(r==="dateYear"?0:r==="dateMonth"?5:8,r==="dateYear"?4:r==="dateMonth"?7:10))}if(e.some(a=>typeof a!="string"))throw new Error("文本函数只接受文本,不隐式转换数字或空值");if(e.reduce((a,s)=>a+s.length,0)>1e6)throw new Error("计算文本超出长度预算");const c=e[0],i=r==="concat"?e.join(""):r==="trim"?c.trim():r==="upper"?c.toUpperCase():c.toLowerCase();if(i.length>1e6)throw new Error("计算文本超出长度预算");return i}function dr(r,e,t,n){const o=e[0];if(t!=="decimal"&&(typeof o!="number"||!Number.isFinite(o)))throw new Error("普通数值函数需要有限数字");const c=u(o);r==="abs"&&(c.coefficient=c.coefficient<0n?-c.coefficient:c.coefficient);const i=r==="round"?e.length===2?e[1]:n??0:n;if(i!==void 0){if(typeof i!="number")throw new Error("小数位必须为数字");h(i)}const a=A(c,i),s=Number(a);if(t!=="decimal"&&!Number.isFinite(s))throw new Error("计算结果不是有限数字");return t==="decimal"?a:s}const gr=new Set(["__proto__","prototype","constructor"]);function m(r){if(typeof r!="string"||!r.trim()||gr.has(r))throw new Error("计算字段应为安全的非空字段名")}function _(r){return r===null||["string","boolean"].includes(typeof r)||typeof r=="number"&&Number.isFinite(r)}function pr(r){if(r.some(e=>typeof e!="number"||!Number.isFinite(e)))throw new Error("算术参数必须是有限数字;空值和小数文本不会隐式转换");return r}function wr(r,e){const t=pr(e);let n;if(r==="add")n=t.reduce((o,c)=>o+c,0);else if(r==="multiply")n=t.reduce((o,c)=>o*c,1);else if(r==="subtract")n=t[0]-t[1];else{if(t[1]===0)throw new Error("不能除以零");n=t[0]/t[1]}if(!Number.isFinite(n))throw new Error("计算结果不是有限数字");return n}function hr(r,e,t){const n=e.map(u);let o;return r==="add"?o=n.reduce(E):r==="multiply"?o=n.reduce(M):r==="subtract"?o=E(n[0],{...n[1],coefficient:-n[1].coefficient}):o=N(n[0],n[1],t),A(o,t)}function yr(r,e,t){return t.nulls!=="error"&&e.some(n=>n==null)||r==="divide"&&t.divisionByZero==="null"&&(t.numeric==="decimal"?u(e[1]).coefficient===0n:e[1]===0)?null:t.numeric==="decimal"?hr(r,e,t.digits):wr(r,e)}function Er(r,e){r.field!==void 0&&m(r.field),r.weightField!==void 0&&m(r.weightField);const t={op:r.aggregate,field:r.field,weightField:r.weightField,numeric:e.numeric,digits:e.digits};P([],t);const n=new WeakMap;return o=>{let c=n.get(o.rows);if(!c){try{c={value:P(o.rows,t)}}catch(i){c={error:i instanceof Error?i:new Error(String(i))}}n.set(o.rows,c)}if(c.error)throw c.error;return c.value}}function Ar(r,e){for(const t of r){const n=t(e);if(n!=null)return n}return null}function I(r,e={},t={nodes:0},n=0){if(++t.nodes>256||n>16)throw new Error("计算表达式超出深度或节点预算");if(!r||typeof r!="object"||Array.isArray(r))throw new Error("计算表达式应为声明式对象");if("aggregate"in r)return Er(r,e);if("field"in r){m(r.field);const o=r.field;return({row:c})=>Object.prototype.hasOwnProperty.call(c,o)?c[o]:void 0}if("value"in r){if(!_(r.value))throw new Error("常量应为有限 JSON 标量");return()=>r.value}return br(r,e,t,n)}function br(r,e,t,n){const o=$.find(a=>a.name===r.op);if(!o||!Array.isArray(r.args))throw new Error("未知计算操作");if(r.args.length>256||Object.keys(r.args).length!==r.args.length)throw new Error("计算参数超出预算或包含空位");if(r.args.length<o.minArgs||r.args.length>o.maxArgs)throw new Error("运算参数数量不正确");const c=r.op==="if"?w(r.condition,t,n+1):void 0;if(r.op!=="if"&&r.condition!==void 0)throw new Error("仅 IF 运算接受 condition");const i=r.args.map(a=>I(a,e,t,n+1));return c?a=>i[c(a.row)?0:1](a):["add","subtract","multiply","divide","coalesce"].includes(r.op)?r.op==="coalesce"?a=>Ar(i,a):a=>yr(r.op,i.map(s=>s(a)),e):a=>mr(r.op,i.map(s=>s(a)),e.numeric,e.digits,e.nulls)}function vr(r){I(r);const e=new Set,t=n=>{"field"in n&&n.field&&e.add(n.field),"aggregate"in n&&n.weightField&&e.add(n.weightField),"args"in n&&(n.args.forEach(t),n.condition&&rr(n.condition).forEach(o=>e.add(o)))};return t(r),[...e]}function S(r,e,t){if(r===void 0)return e;if(!Number.isSafeInteger(r)||Number(r)<1||Number(r)>t)throw new RangeError("图表预算超出允许范围");return Number(r)}function er(r){if(!r||typeof r!="object"||Array.isArray(r))throw new TypeError("图表绑定应为对象");if(m(r.dataset),m(r.categoryField),!["bar","line","stackedBar","percentBar"].includes(r.type))throw new TypeError("图表类型无效");if(r.sort!==void 0&&!["asc","desc"].includes(r.sort))throw new TypeError("图表排序无效");if(r.title!==void 0&&(typeof r.title!="string"||r.title.length>512))throw new TypeError("图表标题过长");if(r.showValues!==void 0&&typeof r.showValues!="boolean")throw new TypeError("图表数值标签应为布尔值");if(!Array.isArray(r.measures)||!r.measures.length||r.measures.length>12)throw new RangeError("图表支持 1–12 个度量");for(const e of Y(r.measures,12,"图表度量"))Or(e);S(r.maxRows,1e5,1e5),S(r.maxCategories,200,200)}function Or(r){if(!r||typeof r!="object"||Array.isArray(r))throw new TypeError("图表度量应为对象");if(r.field!==void 0&&m(r.field),r.weightField!==void 0&&m(r.weightField),r.label!==void 0&&(typeof r.label!="string"||r.label.length>256))throw new TypeError("图表系列名称过长");if(r.color!==void 0&&!/^#[\da-f]{6}$/i.test(r.color))throw new TypeError("图表颜色应为 #RRGGBB");R(r)}function Nr(r){if(r==null)return{key:"null",label:"—"};if(typeof r!="string"&&typeof r!="boolean"&&!(typeof r=="number"&&Number.isFinite(r)))throw new TypeError("图表分类应为文本、布尔或有限数字");const e=String(r);if(e.length>512)throw new RangeError("图表分类名称过长");return{key:JSON.stringify([typeof r,r]),label:e}}function Dr(r){if(r===null)return null;const e=Number(r);if(!Number.isFinite(e))throw new RangeError("聚合结果超出图表有限数值范围");return e}function Sr(r,e,t){if(t?.aborted){const a=new Error("图表数据处理已取消");throw a.name="AbortError",a}er(e);const n=Y(e.measures,12,"图表度量");if(!Array.isArray(r)||r.length>S(e.maxRows,1e5,1e5))throw new RangeError("图表数据超出行数预算");const o=new Map,c=S(e.maxCategories,200,200);for(let a=0;a<r.length;a++){if(t?.aborted){const d=new Error("图表数据处理已取消");throw d.name="AbortError",d}const s=r[a];if(!s||typeof s!="object"||Array.isArray(s))throw new TypeError("图表数据行应为对象");const f=Nr(Object.prototype.hasOwnProperty.call(s,e.categoryField)?s[e.categoryField]:null);let l=o.get(f.key);if(!l){if(o.size>=c)throw new RangeError("图表分类超出预算,请明确筛选或聚合数据");l={label:f.label,accumulators:n.map(R)},o.set(f.key,l)}l.accumulators.forEach(d=>d.add(s))}const i=[...o.values()];return e.sort&&i.sort((a,s)=>(e.sort==="desc"?-1:1)*(a.label<s.label?-1:a.label>s.label?1:0)),{categories:i.map(a=>a.label),series:n.map((a,s)=>({name:a.label??`${a.field??"记录"} · ${a.op}`,values:i.map(f=>Dr(f.accumulators[s].value())),...a.color?{color:a.color}:{}}))}}const Fr=16,B=1024*1024,K=5e5,F=new WeakMap,g=Symbol("uncacheable-computation-definition");function v(r,e,t=0){if(++e.nodes>1e4||t>32)throw g;if(r==null)return[String(r)];if(typeof r=="number")return["number",Object.is(r,-0)?"-0":String(r)];if(typeof r=="boolean")return["boolean",r];if(typeof r=="string"){if(e.units+=r.length,e.units>B)throw g;return["string",r]}if(typeof r!="object")throw g;if(Array.isArray(r)){if(Object.getPrototypeOf(r)!==Array.prototype||Object.keys(r).length!==r.length)throw g;return["array",Array.from({length:r.length},(n,o)=>v(X(r,String(o)),e,t+1))]}if(Object.getPrototypeOf(r)!==Object.prototype&&Object.getPrototypeOf(r)!==null)throw g;return["object",Object.keys(r).map(n=>[v(n,e,t+1),v(X(r,n),e,t+1)])]}function X(r,e){const t=Object.getOwnPropertyDescriptor(r,e);if(!t||t.get||t.set)throw g;return t.value}function jr(r){try{return JSON.stringify(v(r,{nodes:0,units:0}))}catch(e){if(e!==g)throw e;return}}function Mr(r){F.set(r,{programs:new Map,units:0,slots:0})}function Rr(r,e){const t=F.get(r);if(!t)return;const n={programs:new Map,units:t.units,slots:t.slots};for(const[o,c]of t.programs){const i=new WeakMap;e.forEach((a,s)=>{const f=c.rows.get(r[s]);f&&i.set(a,f)}),n.programs.set(o,{...c,rows:i})}F.set(e,n)}function xr(r,e,t){const n=F.get(r);if(!n||e.some(f=>typeof f.expression=="string"))return;const o=jr(e);if(o===void 0||o.length>B)return;const c=n.programs.get(o);if(c)return c;const i=t(),a=r.length*i.reduce((f,l)=>f+l.dependencies.length+1,0),s={fields:i,rows:new WeakMap,slots:a,cacheRows:a<=K};if(!s.cacheRows)return s;for(;n.programs.size>=Fr||n.units+o.length>B||n.slots+a>K;){const f=n.programs.keys().next().value;n.slots-=n.programs.get(f).slots,n.units-=f.length,n.programs.delete(f)}return n.programs.set(o,s),n.units+=o.length,n.slots+=a,s}function kr(r,e,t,n){if((t.definition.scope??"row")!=="row")return;const o=r.program?.rows.get(e)?.get(t.definition.field);return o?.dependencies.every((c,i)=>Object.is(n[t.dependencies[i]],c))?o:void 0}function Cr(r,e,t,n,o){const c=r.program;if(!c?.cacheRows||(t.definition.scope??"row")!=="row")return;let i=r.writes.get(e);i||(i=new Map(c.rows.get(e)),r.writes.set(e,i),c.rows.set(e,i)),i.set(t.definition.field,{dependencies:t.dependencies.map(a=>n[a]),value:n[t.definition.field],...o?{issue:{field:o.field,message:o.message}}:{}})}function Pr(r){if(m(r.field),r.scope!==void 0&&!["row","group","dataset"].includes(r.scope))throw new Error("未知计算范围");if(r.numeric!==void 0&&r.numeric!=="number"&&r.numeric!=="decimal")throw new Error("未知数值模式");if(r.digits!==void 0&&h(r.digits),r.nulls!==void 0&&r.nulls!=="propagate"&&r.nulls!=="error")throw new Error("未知空值规则");if(r.divisionByZero!==void 0&&r.divisionByZero!=="null"&&r.divisionByZero!=="error")throw new Error("未知除零规则");if(r.scope==="group"&&(!Array.isArray(r.groupBy)||!r.groupBy.length))throw new Error("分组计算需要 groupBy 字段");Tr(r)}function Tr(r){if(r.groupBy!==void 0){if(!Array.isArray(r.groupBy)||r.groupBy.length>16)throw new Error("计算分组最多 16 级");r.groupBy.forEach(m)}if(r.dependsOn!==void 0){if(!Array.isArray(r.dependsOn)||r.dependsOn.length>2048)throw new Error("计算依赖超出预算");r.dependsOn.forEach(m)}}function U(r){return[...new Set([...typeof r.expression=="string"?r.dependsOn??[]:vr(r.expression),...r.groupBy??[]])]}function tr(r){if(!Array.isArray(r)||r.length>2048)throw new Error("计算字段应为数组且最多2048项");const e=new Map;for(const i of r){if(Pr(i),e.has(i.field))throw new Error(`计算字段重复:${i.field}`);e.set(i.field,i)}const t=new Set,n=new Set,o=[];function c(i){if(!n.has(i.field)){if(t.has(i.field))throw new Error(`计算字段存在循环依赖:${[...t,i.field].join(" → ")}`);t.add(i.field);for(const a of U(i)){const s=e.get(a);s&&c(s)}t.delete(i.field),n.add(i.field),o.push(i)}}return r.forEach(c),o}function $r(r){try{const e=tr(r);return{valid:!0,errors:[],order:e.map(t=>t.field),fields:r.map(t=>({field:t.field,dependencies:U(t),scope:t.scope??"row"}))}}catch(e){return{valid:!1,errors:[e instanceof Error?e.message:String(e)],fields:[],order:[]}}}function Br(r=[]){return{fields:r.map(e=>({...e})),functions:$,operations:$.map(e=>e.name),aggregates:["sum","count","avg","min","max","weightedAvg"],scopes:["row","group","dataset"],numericModes:["number","decimal"],rules:{nulls:"propagate",aggregateNulls:"skip",emptyAggregate:null,countEmpty:0,divisionByZero:"error",decimalOutput:"string",rounding:"half-away-from-zero"}}}function Z(r){return tr(r.fields).map(e=>{const t=U(e);if(typeof e.expression!="string")return{definition:e,dependencies:t,read:I(e.expression,e)};if(!r.formula)throw new Error("字符串公式需要显式配置 formula adapter");const n=e.expression;return{definition:e,dependencies:t,read:o=>r.formula.evaluate(n,o)}})}function Yr(r,e){return JSON.stringify(e.map(t=>{const n=Object.prototype.hasOwnProperty.call(r,t)?r[t]:null;if(n!=null&&!_(n))throw new Error("分组字段应为有限 JSON 标量");return[typeof n,n??null]}))}function _r(r,e){if(e.scope==="dataset")return()=>r;if(e.scope!=="group"){const o=new WeakMap;return c=>{let i=o.get(c);return i||(i=[c],o.set(c,i)),i}}const t=new Map,n=new WeakMap;for(const o of r){const c=Yr(o,e.groupBy);n.set(o,c);const i=t.get(c);i?i.push(o):t.set(c,[o])}return o=>t.get(n.get(o))}function Ir(r,e){const t=e.maxRows??1e5,n=e.maxCells??2e6;if(!Array.isArray(r)||!Number.isSafeInteger(t)||t<1||r.length>t)throw new Error("计算数据行数超出预算或输入不是数组");if(!Array.isArray(e.fields)||e.fields.length>2048)throw new Error("计算字段应为数组且最多2048项");if(!Number.isSafeInteger(n)||n<1||r.length*e.fields.length>n)throw new Error("计算单元格超出 maxCells 预算")}function G(r){if(r?.aborted){const e=new Error("数据计算已取消");throw e.name="AbortError",e}}function Ur(r,e,t,n,o,c){try{const i=r.read({row:e,rowIndex:t,rows:n});if(i!==void 0&&!_(i))throw new Error("计算结果应为有限 JSON 标量,异步公式请先在数据源中求值");e[r.definition.field]=i??null}catch(i){const a=i instanceof Error?i.message:String(i);if(o.onError!=="null")throw Object.assign(new Error(`第 ${t+1} 行 ${r.definition.field}:${a}`),{cause:i});e[r.definition.field]=null,c.push({rowIndex:t,field:r.definition.field,message:a})}}function Vr(r,e,t,n,o,c,i,a){const s=kr(r,e,t,n);if(s&&(!s.issue||i.onError==="null")){n[t.definition.field]=s.value,s.issue&&a.push({...s.issue,rowIndex:o});return}const f=a.length;Ur(t,n,o,c,i,a),Cr(r,e,t,n,a.length>f?a[a.length-1]:void 0)}function Wr(r,e){Ir(r,e),G(e.signal);const t=xr(r,e.fields,()=>Z(e)),n={program:t,writes:new WeakMap},o=t?.fields??Z(e),c=[],i=r.map((a,s)=>{if(!a||typeof a!="object"||Array.isArray(a))throw new Error(`第 ${s+1} 行应为对象`);return{...a}});for(const a of o){const s=_r(i,a.definition);i.forEach((f,l)=>{G(e.signal),Vr(n,r[l],a,f,l,s(f),e,c)})}return{rows:i,issues:c}}exports.addDecimal=E;exports.aggregateRows=P;exports.chartArray=Y;exports.compareDecimal=y;exports.compileReportPredicate=w;exports.computationFieldName=m;exports.computeDataset=Wr;exports.createAggregateAccumulator=R;exports.createReportChartData=Sr;exports.decimalDigits=h;exports.divideDecimal=N;exports.evaluateReportPredicate=lr;exports.forkComputedDataset=Rr;exports.formatDecimal=nr;exports.getComputationMetadata=Br;exports.multiplyDecimal=M;exports.parseDecimal=u;exports.printDecimal=A;exports.registerComputedDataset=Mr;exports.reportPredicateFields=rr;exports.validateComputedFields=$r;exports.validateReportChartBinding=er;