@agile-team/mach-report 2.25.1 → 2.26.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 (143) hide show
  1. package/README.md +14 -8
  2. package/dist/ExcelBindingWizard-B418l44t.js +1578 -0
  3. package/dist/ExcelBindingWizard-C4FGVsY_.cjs +1 -0
  4. package/dist/{ParamEditor-CGfaweYX.cjs → ParamEditor-BemJE8n8.cjs} +1 -1
  5. package/dist/{ParamEditor-B7YVD28E.js → ParamEditor-XvMtf_XQ.js} +2 -2
  6. package/dist/{ReportBatchPanel-BRJt0TXp.cjs → ReportBatchPanel-CbY4fvXD.cjs} +1 -1
  7. package/dist/{ReportBatchPanel-BTKHtLTW.js → ReportBatchPanel-Ds0R_uXn.js} +37 -37
  8. package/dist/{ReportLabelStudio-BvK_WBke.cjs → ReportLabelStudio-DuTwN5er.cjs} +1 -1
  9. package/dist/{ReportLabelStudio-CZwqyO3t.js → ReportLabelStudio-ZFy79eRv.js} +26 -26
  10. package/dist/ReportParamPanel-Chxu4MTx.cjs +1 -0
  11. package/dist/{ReportParamPanel-DGXzBzl2.js → ReportParamPanel-Czm3OPo_.js} +216 -205
  12. package/dist/ReportPreview-C9c0Rp7Y.js +7380 -0
  13. package/dist/ReportPreview-CIMR4ERo.cjs +6 -0
  14. package/dist/{ReportTemplateLibrary-ClwxhnC0.cjs → ReportTemplateLibrary-C6lByc69.cjs} +1 -1
  15. package/dist/{ReportTemplateLibrary-C7sB0Jay.js → ReportTemplateLibrary-XJVoTDIz.js} +1 -1
  16. package/dist/{RuleEditor-CsDGFaWz.js → RuleEditor-CeNFPeOc.js} +5 -5
  17. package/dist/{RuleEditor-D-OdaGdR.cjs → RuleEditor-gggUkEwB.cjs} +1 -1
  18. package/dist/{TemplateOutlinePanel-DAqR9zQi.cjs → TemplateOutlinePanel-B0e-umq2.cjs} +1 -1
  19. package/dist/{TemplateOutlinePanel-CXOT7d1r.js → TemplateOutlinePanel-BWN4Y9iz.js} +2 -2
  20. package/dist/{TemplateReusePanel-Dcfx3Hba.js → TemplateReusePanel-CR-4OHoU.js} +2 -2
  21. package/dist/{TemplateReusePanel-ygIi-Ajz.cjs → TemplateReusePanel-Cthig1S1.cjs} +1 -1
  22. package/dist/{TemplateReviewPanel-COU8FqPq.js → TemplateReviewPanel-BkWzyNL4.js} +2 -2
  23. package/dist/{TemplateReviewPanel-DyGULVxr.cjs → TemplateReviewPanel-D8o2gDaK.cjs} +1 -1
  24. package/dist/analytics.cjs +1 -1
  25. package/dist/analytics.js +5 -5
  26. package/dist/artifact-integrity.json +106 -102
  27. package/dist/{assets-C4MIvzQ4.js → assets-BFTP-0WR.js} +2 -2
  28. package/dist/{assets-BYdpkTIt.cjs → assets-CZiZhTf2.cjs} +1 -1
  29. package/dist/{auto-D7x7QsWD.js → auto-C7udkeAa.js} +89 -88
  30. package/dist/auto-CXd2E2aZ.cjs +1 -0
  31. package/dist/capabilities-D8UU2clQ.cjs +1 -0
  32. package/dist/{capabilities-CN_kSVjO.js → capabilities-g0a2j9Yy.js} +50 -46
  33. package/dist/{charts-Cjw5AYkg.cjs → charts-D-Vg-ak9.cjs} +1 -1
  34. package/dist/{charts-CxJZ0XaY.js → charts-D48XCefN.js} +1 -1
  35. package/dist/computed-BQgBrma-.cjs +1 -0
  36. package/dist/{computed-f3pOqWLX.js → computed-CH3NYPOW.js} +198 -188
  37. package/dist/{data-bar-Bfh54sT4.js → data-bar-DjOgTLqu.js} +1 -1
  38. package/dist/{dataset-DL83majE.js → dataset-B8oTsC6o.js} +69 -66
  39. package/dist/dataset-D3OsyzG1.cjs +1 -0
  40. package/dist/designer-COuSUxZ1.cjs +2 -0
  41. package/dist/designer-CT4mlrr0.js +7997 -0
  42. package/dist/designer.cjs +1 -1
  43. package/dist/designer.d.cts +83 -4
  44. package/dist/designer.d.ts +83 -4
  45. package/dist/designer.js +4 -4
  46. package/dist/{diagnostic-collector-gB07PHy2.js → diagnostic-collector-C-JBA016.js} +2 -2
  47. package/dist/dom-DgWc-DY1.js +452 -0
  48. package/dist/dom-Fk4NF-gN.cjs +1 -0
  49. package/dist/{encoding-Amq3XrtU.js → encoding-D480EM2r.js} +2 -2
  50. package/dist/{encoding-DRVXs5xm.cjs → encoding-tWc2Wn89.cjs} +1 -1
  51. package/dist/execution-result-7sG_mdcD.cjs +1 -0
  52. package/dist/execution-result-Ba65gieT.js +39 -0
  53. package/dist/{font-loader-p_SyTvqt.cjs → font-loader-BIxme_9g.cjs} +1 -1
  54. package/dist/{font-loader-D4NLIKJL.js → font-loader-CHmEwkHl.js} +1 -1
  55. package/dist/{grid-strokes-DkZEZvcI.js → grid-strokes-DsoICRjZ.js} +1 -1
  56. package/dist/import-range-BwT86Z3j.cjs +1 -0
  57. package/dist/import-range-D9p_blcb.js +98 -0
  58. package/dist/index.cjs +1 -1
  59. package/dist/index.d.cts +1 -1
  60. package/dist/index.d.ts +1 -1
  61. package/dist/index.js +25 -25
  62. package/dist/{json-snapshot-CBVWZvyC.js → json-snapshot-BZ0CIQln.js} +1142 -951
  63. package/dist/json-snapshot-DGFeI30h.cjs +2 -0
  64. package/dist/{matrix-b6T291xo.js → matrix-CB9TqTEy.js} +1 -1
  65. package/dist/{matrix-DUYPRL7t.cjs → matrix-CcqYOuq_.cjs} +1 -1
  66. package/dist/{pdf-DU8HelKd.js → pdf-DTR7fAIr.js} +3596 -3517
  67. package/dist/{pdf-C060D5UY.cjs → pdf-d9oJ6V0P.cjs} +49 -49
  68. package/dist/pdf.cjs +1 -1
  69. package/dist/pdf.js +2 -2
  70. package/dist/{plugin-DHe8y5pD.cjs → plugin-B7Bi-1te.cjs} +1 -1
  71. package/dist/{plugin-BdCplNe1.js → plugin-OKDFQFS4.js} +1 -1
  72. package/dist/{prefill-Buy4NJ15.js → prefill-C8fF91JB.js} +3 -3
  73. package/dist/{prefill-Cw4ZYGXZ.cjs → prefill-C_Bf_AMo.cjs} +1 -1
  74. package/dist/{prepared-BlNeOjoO.cjs → prepared-BLhV7vdE.cjs} +1 -1
  75. package/dist/{prepared-CBJ7BkK0.js → prepared-DhgQ0d-h.js} +7 -7
  76. package/dist/protocol-CZ-BILne.cjs +1 -0
  77. package/dist/{protocol-CB19KXGr.js → protocol-DHO91-Jt.js} +3 -3
  78. package/dist/{record-bindings-Cv7lFiof.js → record-bindings-DBrCu6zO.js} +3 -3
  79. package/dist/{record-bindings-B7djSjNs.cjs → record-bindings-KEs-DKCS.cjs} +1 -1
  80. package/dist/region-binding-workflow-FSyIZge8.js +882 -0
  81. package/dist/region-binding-workflow-ikpY1Kbw.cjs +3 -0
  82. package/dist/report-encoding-worker.cjs +1 -1
  83. package/dist/report-encoding-worker.js +1 -1
  84. package/dist/rich-text-layout-BYbIc3eJ.cjs +3 -0
  85. package/dist/rich-text-layout-BtygMWZC.js +96 -0
  86. package/dist/runtime-B5HG8poy.cjs +1 -0
  87. package/dist/runtime-BsvAqz4a.js +204 -0
  88. package/dist/sbom.cdx.json +1 -1
  89. package/dist/server-node.cjs +5 -5
  90. package/dist/server-node.js +2323 -2120
  91. package/dist/server.cjs +1 -1
  92. package/dist/server.d.cts +35 -0
  93. package/dist/server.d.ts +35 -0
  94. package/dist/server.js +340 -328
  95. package/dist/style.css +1 -1
  96. package/dist/{template-catalog-CM6U_RlD.js → template-catalog-BbrN9dgu.js} +5 -5
  97. package/dist/{template-catalog-Cj66M84u.cjs → template-catalog-DDH-5J57.cjs} +1 -1
  98. package/dist/{template-fragments-BDxdCuMD.js → template-fragments-CUTE8-_I.js} +3 -3
  99. package/dist/{template-fragments-DbKdxI1z.cjs → template-fragments-cyAQu7aw.cjs} +1 -1
  100. package/dist/{template-registry-B-AK1oam.cjs → template-registry-D24Z8aQf.cjs} +1 -1
  101. package/dist/{template-registry-DeVgwEZj.js → template-registry-PSuLsnyq.js} +4 -4
  102. package/dist/{template-serialization-CqQY4zDg.cjs → template-serialization-BOUidUlh.cjs} +1 -1
  103. package/dist/{template-serialization-CWmHq7lX.js → template-serialization-BgGWYV_1.js} +1 -1
  104. package/dist/{textwrap-BywMBMXM.js → textwrap-Bt_tnI6V.js} +1 -1
  105. package/dist/vue/async.d.cts +46 -3
  106. package/dist/vue/async.d.ts +46 -3
  107. package/dist/vue/index.d.cts +217 -25
  108. package/dist/vue/index.d.ts +217 -25
  109. package/dist/vue-async.cjs +1 -1
  110. package/dist/vue-async.js +3 -3
  111. package/dist/vue.cjs +1 -1
  112. package/dist/vue.js +434 -202
  113. package/dist/workbook-session-BJfZVp4q.cjs +29 -0
  114. package/dist/{workbook-session-B6hRjTyX.js → workbook-session-DRnMjIFK.js} +2377 -2350
  115. package/dist/worker.cjs +1 -1
  116. package/dist/worker.js +4 -4
  117. package/dist/xlsx.cjs +1 -1
  118. package/dist/xlsx.d.cts +27 -2
  119. package/dist/xlsx.d.ts +27 -2
  120. package/dist/xlsx.js +15 -15
  121. package/package.json +1 -1
  122. package/dist/ExcelBindingWizard-bs3F4dD8.js +0 -1486
  123. package/dist/ExcelBindingWizard-jSdjBtWw.cjs +0 -1
  124. package/dist/ReportParamPanel-B27IGJjk.cjs +0 -1
  125. package/dist/ReportPreview-CnxaDTCO.js +0 -7170
  126. package/dist/ReportPreview-DqFBcsJQ.cjs +0 -6
  127. package/dist/auto-mPK9W0y5.cjs +0 -1
  128. package/dist/capabilities-D4nfhcvB.cjs +0 -1
  129. package/dist/computed-DK6BruFz.cjs +0 -1
  130. package/dist/dataset-IrlXbUvh.cjs +0 -1
  131. package/dist/designer-B597ZdC0.js +0 -7595
  132. package/dist/designer-DFIdv_n7.cjs +0 -2
  133. package/dist/dom-CXWMmwh-.cjs +0 -1
  134. package/dist/dom-DxdCMLzs.js +0 -452
  135. package/dist/json-snapshot-DCFEtfFw.cjs +0 -2
  136. package/dist/protocol-BU_4sXP0.cjs +0 -1
  137. package/dist/region-binding-workflow-EYxvUYJ-.js +0 -977
  138. package/dist/region-binding-workflow-NdkMSFCh.cjs +0 -3
  139. package/dist/rich-text-layout-Ch_N0Ubu.js +0 -52
  140. package/dist/rich-text-layout-yJGuThtC.cjs +0 -3
  141. package/dist/runtime-B5d_lQNQ.js +0 -227
  142. package/dist/runtime-BRx8Agqr.cjs +0 -1
  143. package/dist/workbook-session-BclW7KKH.cjs +0 -29
@@ -1,97 +1,98 @@
1
- import { s as S, d as j, c as U, a as H } from "./prepared-CBJ7BkK0.js";
2
- import { H as I } from "./json-snapshot-CBVWZvyC.js";
3
- import { b as W, R as z, v as $, c as N } from "./protocol-CB19KXGr.js";
4
- import { z as G } from "./diagnostic-collector-gB07PHy2.js";
5
- import { c as K, e as X } from "./runtime-B5d_lQNQ.js";
6
- import { D as C, R as O, t as R, v as J, c as D, b as M } from "./sha256-BDQ1Qk7A.js";
1
+ import { s as S, d as j, c as U, a as H } from "./prepared-DhgQ0d-h.js";
2
+ import { H as I } from "./json-snapshot-BZ0CIQln.js";
3
+ import { b as W, R as C, v as $, c as N } from "./protocol-DHO91-Jt.js";
4
+ import { A as G } from "./diagnostic-collector-C-JBA016.js";
5
+ import { c as K, e as X } from "./runtime-BsvAqz4a.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
+ import { a as Q } from "./execution-result-Ba65gieT.js";
7
8
  class T extends Error {
8
9
  constructor(r) {
9
10
  super("报表 Worker 无法启动"), this.cause = r, this.name = "ReportWorkerStartError";
10
11
  }
11
12
  }
12
- let Q = 0;
13
+ let V = 0;
13
14
  function F(e) {
14
15
  const r = new Error("报表 Worker 任务已取消");
15
16
  return r.name = "AbortError", Object.defineProperty(r, "cause", { value: e }), r;
16
17
  }
17
- function V(e, r) {
18
+ function Y(e, r) {
18
19
  if (!e || typeof e != "object") return;
19
20
  const t = e;
20
- return t.protocol === z && t.id === r ? t : void 0;
21
+ return t.protocol === C && t.id === r ? t : void 0;
21
22
  }
22
- function Y(e, r = {}) {
23
+ function Z(e, r = {}) {
23
24
  const t = r.timeoutMs ?? 12e4;
24
25
  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;
26
+ const a = (o, s, n, u) => n?.aborted ? Promise.reject(F(n.reason)) : new Promise((v, i) => {
27
+ let p;
27
28
  try {
28
- b = e();
29
+ p = e();
29
30
  } catch (f) {
30
31
  i(new T(f));
31
32
  return;
32
33
  }
33
- const E = `mach-report-${Date.now()}-${++Q}`;
34
- let p = !1, d = () => {
35
- }, y;
34
+ const E = `mach-report-${Date.now()}-${++V}`;
35
+ let b = !1, d = () => {
36
+ }, k;
36
37
  const l = (f, c) => {
37
- if (p) return;
38
- p = !0, y && clearTimeout(y);
38
+ if (b) return;
39
+ b = !0, k && clearTimeout(k);
39
40
  let g;
40
41
  try {
41
42
  d();
42
43
  } catch (x) {
43
44
  g = x;
44
45
  }
45
- a?.removeEventListener("abort", k), f ??= g, Promise.resolve().then(() => b.terminate()).then(
46
+ n?.removeEventListener("abort", y), f ??= g, Promise.resolve().then(() => p.terminate()).then(
46
47
  () => f === void 0 ? v(c) : i(f),
47
48
  (x) => i(f ?? x)
48
49
  );
49
- }, k = () => l(F(a?.reason)), m = (f) => {
50
- const c = V(f, E);
51
- if (!(!c || p)) {
50
+ }, y = () => l(F(n?.reason)), m = (f) => {
51
+ const c = Y(f, E);
52
+ if (!(!c || b)) {
52
53
  if ("type" in c && c.type === "event") {
53
54
  const g = "event" in c ? c.event : void 0;
54
- $(g, s) ? I(u, g, a) : l(new Error("报表 Worker 返回无效阶段事件"));
55
+ $(g, s) ? I(u, g, n) : l(new Error("报表 Worker 返回无效阶段事件"));
55
56
  return;
56
57
  }
57
58
  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
  }
59
60
  };
60
61
  try {
61
- if (d = b.subscribe(m, (f) => l(f ?? new Error("报表 Worker 执行失败"))), p) {
62
+ if (d = p.subscribe(m, (f) => l(f ?? new Error("报表 Worker 执行失败"))), b) {
62
63
  d();
63
64
  return;
64
65
  }
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
+ if (n?.addEventListener("abort", y, { once: !0 }), k = setTimeout(() => l(new W({ name: "ReportRuntimeError", code: "timeout", message: `报表 Worker 执行超过 ${t}ms` })), t), n?.aborted) y();
66
67
  else {
67
- const { onEvent: f, signal: c, ...g } = s, x = Z(g);
68
- b.postMessage({ protocol: z, id: E, operation: o, input: g, ...r.budget ? { budget: r.budget } : {} }, x);
68
+ const { onEvent: f, signal: c, ...g } = s, x = ee(g);
69
+ p.postMessage({ protocol: C, id: E, operation: o, input: g, ...r.budget ? { budget: r.budget } : {} }, x);
69
70
  }
70
71
  } catch (f) {
71
72
  l(f);
72
73
  }
73
74
  });
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
+ return { exportPrepared: (o, s, n) => a("exportPrepared", o, s, n), prepare: (o, s, n) => a("prepare", o, s, n), export: (o, s, n) => a("export", o, s, n) };
75
76
  }
76
- function Z(e) {
77
+ function ee(e) {
77
78
  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
  }
79
- function ee(e, r = {}) {
80
- return Y(() => {
80
+ function re(e, r = {}) {
81
+ return Z(() => {
81
82
  const t = e();
82
83
  return {
83
- postMessage: (n, o) => t.postMessage(n, o),
84
+ postMessage: (a, o) => t.postMessage(a, o),
84
85
  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);
86
+ subscribe: (a, o) => {
87
+ const s = (u) => a(u.data), n = (u) => o(u instanceof ErrorEvent ? new Error(u.message) : new Error("报表 Worker 消息无法解码"));
88
+ return t.addEventListener("message", s), t.addEventListener("error", n), t.addEventListener("messageerror", n), () => {
89
+ t.removeEventListener("message", s), t.removeEventListener("error", n), t.removeEventListener("messageerror", n);
89
90
  };
90
91
  }
91
92
  };
92
93
  }, r);
93
94
  }
94
- const re = { cells: 2e4, pages: 20, bytes: 2e6 };
95
+ const te = { cells: 2e4, pages: 20, bytes: 2e6 };
95
96
  function P(e) {
96
97
  return e.cells >= e.limits.cells || e.pages >= e.limits.pages || e.bytes >= e.limits.bytes || e.capped;
97
98
  }
@@ -104,9 +105,9 @@ function w(e) {
104
105
  function L(e, r) {
105
106
  for (const t of e ?? []) {
106
107
  if (!h(r)) return;
107
- for (const n of t.segments) {
108
+ for (const a of t.segments) {
108
109
  if (!h(r)) return;
109
- r.bytes += w(n.text);
110
+ r.bytes += w(a.text);
110
111
  }
111
112
  }
112
113
  }
@@ -117,13 +118,13 @@ function q(e, r, t) {
117
118
  }
118
119
  if (h(r)) {
119
120
  r.bytes += w(e.text) + w(e.rawText) + w(e.imageData), L(e.richParagraphs, r);
120
- for (const n of e.lines ?? []) {
121
+ for (const a of e.lines ?? []) {
121
122
  if (!h(r)) return;
122
- r.bytes += w(n);
123
+ r.bytes += w(a);
123
124
  }
124
- for (const n of e.grid?.cells ?? []) {
125
+ for (const a of e.grid?.cells ?? []) {
125
126
  if (!h(r)) return;
126
- for (const o of n) {
127
+ for (const o of a) {
127
128
  if (!h(r)) return;
128
129
  if (o) {
129
130
  r.cells++, r.bytes += w(o.text) + w(o.rawText) + w(o.value), L(o.richParagraphs, r);
@@ -136,27 +137,27 @@ function q(e, r, t) {
136
137
  }
137
138
  }
138
139
  }
139
- function te(e, r) {
140
+ function oe(e, r) {
140
141
  if (e.format === "xlsx")
141
142
  for (const t of e.xlsx?.additionalSheets ?? []) {
142
143
  if (!h(r)) return;
143
144
  r.bytes += w(t?.name);
144
- for (const n of t?.rows ?? []) {
145
+ for (const a of t?.rows ?? []) {
145
146
  if (!h(r)) return;
146
- for (const o of n ?? []) {
147
+ for (const o of a ?? []) {
147
148
  if (!h(r)) return;
148
149
  r.cells++, r.bytes += w(o);
149
150
  }
150
151
  }
151
152
  }
152
153
  }
153
- function oe(e) {
154
- const r = { ...re, ...e.thresholds };
154
+ function se(e) {
155
+ const r = { ...te, ...e.thresholds };
155
156
  for (const t of Object.values(r)) if (!Number.isSafeInteger(t) || t <= 0) throw new RangeError("导出隔离阈值应为正安全整数");
156
157
  return r;
157
158
  }
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 };
159
+ function ae(e, r) {
160
+ const t = se(r), a = e.pdf?.customFontFaces ? Object.values(e.pdf.customFontFaces) : [e.pdf?.customFontBytes], o = { pages: e.prepared.plan.pages.length, cells: 0, bytes: a.reduce((u, v) => u + (v?.byteLength ?? 0), 0), visits: 0, capped: !1, limits: t };
160
161
  for (const u of e.prepared.plan.pages) {
161
162
  if (P(o)) break;
162
163
  for (const v of u.components) {
@@ -164,94 +165,94 @@ function se(e, r) {
164
165
  q(v, o, 0);
165
166
  }
166
167
  }
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" };
168
+ oe(e, o);
169
+ let s = P(o) ? "worker" : "local", n = o.capped ? "scan-limit" : s === "worker" ? "threshold" : "small-task";
170
+ return r.mode === "local" && (s = "local", n = "explicit-local"), r.mode === "worker" && (s = "worker", n = "explicit-worker"), Object.values(e.xlsx ?? {}).some((u) => typeof u == "function") && (s = "local", n = "nonserializable-options"), { mode: s, reason: n, estimate: { pages: o.pages, cells: o.cells, bytes: o.bytes }, hardCancellation: s === "worker" };
170
171
  }
171
172
  function ne(e) {
172
173
  if (e.mode !== void 0 && !["auto", "local", "worker"].includes(e.mode)) throw new TypeError("无效的导出执行模式");
173
174
  if (e.fallback !== void 0 && !["local", "error"].includes(e.fallback)) throw new TypeError("无效的导出回退策略");
174
175
  J({ ...e.budget, maxDurationMs: e.timeoutMs ?? e.budget?.maxDurationMs ?? 12e4 });
175
176
  }
176
- function _(e, r) {
177
+ function A(e, r) {
177
178
  G(() => e.onDecision?.({ ...r, estimate: { ...r.estimate } }));
178
179
  }
179
- function A(e, r) {
180
+ function _(e, r) {
180
181
  return { ...e, mode: "local", reason: r, hardCancellation: !1 };
181
182
  }
182
183
  function B(e, r, t) {
183
184
  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
  }
185
- function ae(e, r) {
186
- const t = { ...C, ...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
186
  function ie(e, r) {
187
+ const t = { ...z, ...r.budget }, a = U(e.prepared, t.maxPreparedBytes, e.signal), o = { ...e, prepared: a.prepared, pdf: S(e.pdf), xlsx: H(e.xlsx) };
188
+ return { request: o, forward: () => ({ ...o, prepared: a.forward() }) };
189
+ }
190
+ function ce(e, r) {
190
191
  ne(e);
191
- const t = { ...e, thresholds: { ...e.thresholds }, budget: { ...C, ...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;
192
+ const t = { ...e, thresholds: { ...e.thresholds }, budget: { ...z, ...e.budget } }, a = t.timeoutMs ?? t.budget.maxDurationMs ?? 12e4, o = K({ reports: {}, budget: { ...t.budget, maxDurationMs: a } }), s = /* @__PURE__ */ new Set();
193
+ let n = !1;
193
194
  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`);
195
+ async function v(i, p) {
196
+ const E = Date.now(), b = () => {
197
+ const m = a - (Date.now() - E);
198
+ if (m <= 0) throw new O("timeout", `报表执行超过 ${a}ms`);
198
199
  return m;
199
200
  };
200
- let d = se(i, t);
201
+ let d = ae(i, t);
201
202
  if (d.reason === "nonserializable-options" && t.mode === "worker") throw new TypeError("Worker 模式不接受函数选项;请使用本地模式或可序列化配置");
202
203
  if (d.mode === "worker" && !r) {
203
204
  if (!u) throw new T(new Error("未配置 workerFactory"));
204
- d = A(d, "worker-unavailable");
205
+ d = _(d, "worker-unavailable");
205
206
  }
206
- const y = ae(i, t), l = y.request;
207
- if (_(t, d), R(i.signal), d.mode === "worker")
207
+ const k = ie(i, t), l = k.request;
208
+ if (A(t, d), R(i.signal), d.mode === "worker")
208
209
  try {
209
- const m = r(p());
210
+ const m = r(b());
210
211
  if (!m.exportPrepared) throw new TypeError("隔离执行器缺少 exportPrepared");
211
212
  const { signal: f, onEvent: c, ...g } = l, x = await m.exportPrepared(g, f, c);
212
213
  return R(f), B(x, l, t.budget), { ...x, execution: d };
213
214
  } catch (m) {
214
215
  if (!(m instanceof T) || !u) throw m;
215
- R(i.signal), d = A(d, "worker-start-failed"), _(t, d);
216
+ R(i.signal), d = _(d, "worker-start-failed"), A(t, d);
216
217
  }
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 };
218
+ p && (l.prepared = X(l.prepared, t.budget), j(l, t.budget));
219
+ const y = p ? await D(i.signal, b(), (m) => p({ ...l, signal: m })) : await D(i.signal, b(), (m) => o.exportPrepared({ ...k.forward(), signal: m }));
220
+ return R(i.signal), p && Q(y, l.format), B(y, l, t.budget), { ...y, execution: d };
220
221
  }
221
222
  return {
222
- async exportPrepared(i, b) {
223
- if (a) throw new O("closed", "导出执行器已释放");
223
+ async exportPrepared(i, p) {
224
+ if (n) throw new O("closed", "导出执行器已释放");
224
225
  if (R(i.signal), s.size >= 2) throw new O("queue-full", "同时导出的任务已达 2 个,请等待完成后重试");
225
226
  const E = new AbortController();
226
227
  s.add(E);
227
- const p = () => E.abort(i.signal?.reason);
228
- i.signal?.addEventListener("abort", p, { once: !0 });
228
+ const b = () => E.abort(i.signal?.reason);
229
+ i.signal?.addEventListener("abort", b, { once: !0 });
229
230
  try {
230
- return await v({ ...i, signal: E.signal }, b);
231
+ return await v({ ...i, signal: E.signal }, p);
231
232
  } finally {
232
- i.signal?.removeEventListener("abort", p), s.delete(E);
233
+ i.signal?.removeEventListener("abort", b), s.delete(E);
233
234
  }
234
235
  },
235
236
  cancel() {
236
237
  for (const i of s) i.abort();
237
238
  },
238
239
  dispose() {
239
- a = !0;
240
+ n = !0;
240
241
  for (const i of s) i.abort();
241
242
  }
242
243
  };
243
244
  }
244
- function ce(e = {}) {
245
+ function le(e = {}) {
245
246
  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
+ return ce(e, r ? (a) => re(r, { ...t, timeoutMs: a }) : void 0);
247
248
  }
248
- const be = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
249
+ const we = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
249
250
  __proto__: null,
250
- createAutoReportExporter: ce
251
+ createAutoReportExporter: le
251
252
  }, Symbol.toStringTag, { value: "Module" }));
252
253
  export {
253
254
  T as R,
254
- ee as a,
255
- be as b,
256
- ce as c
255
+ re as a,
256
+ we as b,
257
+ le as c
257
258
  };
@@ -0,0 +1 @@
1
+ "use strict";const O=require("./prepared-BLhV7vdE.cjs"),C=require("./json-snapshot-DGFeI30h.cjs"),P=require("./protocol-CZ-BILne.cjs"),I=require("./diagnostic-collector-wASg6Fzs.cjs"),W=require("./runtime-B5HG8poy.cjs"),u=require("./sha256-DgZAKXqI.cjs"),j=require("./execution-result-7sG_mdcD.cjs");class M extends Error{constructor(r){super("报表 Worker 无法启动"),this.cause=r,this.name="ReportWorkerStartError"}}let U=0;function F(e){const r=new Error("报表 Worker 任务已取消");return r.name="AbortError",Object.defineProperty(r,"cause",{value:e}),r}function z(e,r){if(!e||typeof e!="object")return;const t=e;return t.protocol===P.REPORT_WORKER_PROTOCOL&&t.id===r?t:void 0}function N(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,d)=>a?.aborted?Promise.reject(F(a.reason)):new Promise((y,i)=>{let b;try{b=e()}catch(f){i(new M(f));return}const h=`mach-report-${Date.now()}-${++U}`;let g=!1,p=()=>{},k;const l=(f,c)=>{if(g)return;g=!0,k&&clearTimeout(k);let w;try{p()}catch(R){w=R}a?.removeEventListener("abort",v),f??=w,Promise.resolve().then(()=>b.terminate()).then(()=>f===void 0?y(c):i(f),R=>i(f??R))},v=()=>l(F(a?.reason)),m=f=>{const c=z(f,h);if(!(!c||g)){if("type"in c&&c.type==="event"){const w="event"in c?c.event:void 0;P.validReportWorkerEvent(w,s)?C.notifyReportTaskEvent(d,w,a):l(new Error("报表 Worker 返回无效阶段事件"));return}c.error&&typeof c.error.name=="string"&&typeof c.error.message=="string"?l(new P.ReportWorkerError(c.error)):P.validReportWorkerResult(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 返回无效响应"))}};try{if(p=b.subscribe(m,f=>l(f??new Error("报表 Worker 执行失败"))),g){p();return}if(a?.addEventListener("abort",v,{once:!0}),k=setTimeout(()=>l(new P.ReportWorkerError({name:"ReportRuntimeError",code:"timeout",message:`报表 Worker 执行超过 ${t}ms`})),t),a?.aborted)v();else{const{onEvent:f,signal:c,...w}=s,R=$(w);b.postMessage({protocol:P.REPORT_WORKER_PROTOCOL,id:h,operation:o,input:w,...r.budget?{budget:r.budget}:{}},R)}}catch(f){l(f)}});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 $(e){return e.pdf?(e.pdf=O.snapshotPdfFonts(e.pdf),(e.pdf?.customFontFaces?Object.values(e.pdf.customFontFaces):[e.pdf?.customFontBytes]).filter(t=>t instanceof Uint8Array).map(t=>t.buffer)):[]}function _(e,r={}){return N(()=>{const t=e();return{postMessage:(n,o)=>t.postMessage(n,o),terminate:()=>t.terminate(),subscribe:(n,o)=>{const s=d=>n(d.data),a=d=>o(d instanceof ErrorEvent?new Error(d.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 H={cells:2e4,pages:20,bytes:2e6};function T(e){return e.cells>=e.limits.cells||e.pages>=e.limits.pages||e.bytes>=e.limits.bytes||e.capped}function x(e){return++e.visits>=1e5&&(e.capped=!0),!T(e)}function E(e){return typeof e=="string"?e.length*2:0}function L(e,r){for(const t of e??[]){if(!x(r))return;for(const n of t.segments){if(!x(r))return;r.bytes+=E(n.text)}}}function q(e,r,t){if(t>32){r.capped=!0;return}if(x(r)){r.bytes+=E(e.text)+E(e.rawText)+E(e.imageData),L(e.richParagraphs,r);for(const n of e.lines??[]){if(!x(r))return;r.bytes+=E(n)}for(const n of e.grid?.cells??[]){if(!x(r))return;for(const o of n){if(!x(r))return;if(o){r.cells++,r.bytes+=E(o.text)+E(o.rawText)+E(o.value),L(o.richParagraphs,r);for(const s of o.children??[]){if(T(r))return;q(s,r,t+1)}}}}}}function G(e,r){if(e.format==="xlsx")for(const t of e.xlsx?.additionalSheets??[]){if(!x(r))return;r.bytes+=E(t?.name);for(const n of t?.rows??[]){if(!x(r))return;for(const o of n??[]){if(!x(r))return;r.cells++,r.bytes+=E(o)}}}}function K(e){const r={...H,...e.thresholds};for(const t of Object.values(r))if(!Number.isSafeInteger(t)||t<=0)throw new RangeError("导出隔离阈值应为正安全整数");return r}function X(e,r){const t=K(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((d,y)=>d+(y?.byteLength??0),0),visits:0,capped:!1,limits:t};for(const d of e.prepared.plan.pages){if(T(o))break;for(const y of d.components){if(T(o))break;q(y,o,0)}}G(e,o);let s=T(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(d=>typeof d=="function")&&(s="local",a="nonserializable-options"),{mode:s,reason:a,estimate:{pages:o.pages,cells:o.cells,bytes:o.bytes},hardCancellation:s==="worker"}}function J(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("无效的导出回退策略");u.validateBudget({...e.budget,maxDurationMs:e.timeoutMs??e.budget?.maxDurationMs??12e4})}function A(e,r){I.observeOutput(()=>e.onDecision?.({...r,estimate:{...r.estimate}}))}function B(e,r){return{...e,mode:"local",reason:r,hardCancellation:!1}}function D(e,r,t){u.assertBudget(t,"maxRows",e.stats.rows),u.assertBudget(t,"maxPages",e.stats.pages),u.assertBudget(t,"maxCells",e.stats.cells),u.assertBudget(t,"maxOutputBytes",e.bytes.byteLength),O.assertPreparedOutputBudget({...r,prepared:{...r.prepared,stats:e.stats}},t)}function Q(e,r){const t={...u.DEFAULT_REPORT_RUNTIME_BUDGET,...r.budget},n=O.capturePreparedHandoff(e.prepared,t.maxPreparedBytes,e.signal),o={...e,prepared:n.prepared,pdf:O.snapshotPdfFonts(e.pdf),xlsx:O.snapshotXlsxOptions(e.xlsx)};return{request:o,forward:()=>({...o,prepared:n.forward()})}}function V(e,r){J(e);const t={...e,thresholds:{...e.thresholds},budget:{...u.DEFAULT_REPORT_RUNTIME_BUDGET,...e.budget}},n=t.timeoutMs??t.budget.maxDurationMs??12e4,o=W.createReportRuntime({reports:{},budget:{...t.budget,maxDurationMs:n}}),s=new Set;let a=!1;const d=t.mode!=="worker"&&t.fallback!=="error";async function y(i,b){const h=Date.now(),g=()=>{const m=n-(Date.now()-h);if(m<=0)throw new u.ReportRuntimeError("timeout",`报表执行超过 ${n}ms`);return m};let p=X(i,t);if(p.reason==="nonserializable-options"&&t.mode==="worker")throw new TypeError("Worker 模式不接受函数选项;请使用本地模式或可序列化配置");if(p.mode==="worker"&&!r){if(!d)throw new M(new Error("未配置 workerFactory"));p=B(p,"worker-unavailable")}const k=Q(i,t),l=k.request;if(A(t,p),u.throwIfAborted(i.signal),p.mode==="worker")try{const m=r(g());if(!m.exportPrepared)throw new TypeError("隔离执行器缺少 exportPrepared");const{signal:f,onEvent:c,...w}=l,R=await m.exportPrepared(w,f,c);return u.throwIfAborted(f),D(R,l,t.budget),{...R,execution:p}}catch(m){if(!(m instanceof M)||!d)throw m;u.throwIfAborted(i.signal),p=B(p,"worker-start-failed"),A(t,p)}b&&(l.prepared=W.enforcePrepared(l.prepared,t.budget),O.assertPreparedOutputBudget(l,t.budget));const v=b?await u.controlled(i.signal,g(),m=>b({...l,signal:m})):await u.controlled(i.signal,g(),m=>o.exportPrepared({...k.forward(),signal:m}));return u.throwIfAborted(i.signal),b&&j.assertReportExportResult(v,l.format),D(v,l,t.budget),{...v,execution:p}}return{async exportPrepared(i,b){if(a)throw new u.ReportRuntimeError("closed","导出执行器已释放");if(u.throwIfAborted(i.signal),s.size>=2)throw new u.ReportRuntimeError("queue-full","同时导出的任务已达 2 个,请等待完成后重试");const h=new AbortController;s.add(h);const g=()=>h.abort(i.signal?.reason);i.signal?.addEventListener("abort",g,{once:!0});try{return await y({...i,signal:h.signal},b)}finally{i.signal?.removeEventListener("abort",g),s.delete(h)}},cancel(){for(const i of s)i.abort()},dispose(){a=!0;for(const i of s)i.abort()}}}function S(e={}){const r=e.workerFactory,t={timeoutMs:e.timeoutMs??e.budget?.maxDurationMs,budget:{...e.budget}};return V(e,r?n=>_(r,{...t,timeoutMs:n}):void 0)}const Y=Object.freeze(Object.defineProperty({__proto__:null,createAutoReportExporter:S},Symbol.toStringTag,{value:"Module"}));exports.ReportWorkerStartError=M;exports.auto=Y;exports.createAutoReportExporter=S;exports.createBrowserReportExecutor=_;
@@ -0,0 +1 @@
1
+ "use strict";const c=require("./diagnostic-collector-wASg6Fzs.cjs");function b(e,t){c.assertOutputActive(t.signal),c.observeOutput(()=>t.onDiagnostic?.(e)),c.assertOutputActive(t.signal)}class M extends Error{constructor(t,i){super(`Output contains ${i?.total??t.length} known fidelity issue(s): ${t[0]?.code??Object.keys(i?.counts??{})[0]??"unknown"}`),this.diagnostics=t,this.diagnosticSummary=i,this.code="output-fidelity",this.name="OutputFidelityError"}}const C=new Set(["text","rect","line","ellipse"]),k=new Set(["image","chart","barcode","qrcode"]);function $(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(!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 g(e,t,i,s,n){const o=Object.getOwnPropertyDescriptor(e,"meta")?.value,a=o&&Object.getOwnPropertyDescriptor(o,"componentExtension")?.value,u=a&&Object.getOwnPropertyDescriptor(a,"id")?.value,r=a&&Object.getOwnPropertyDescriptor(a,"version")?.value,d=typeof u=="string"&&u.length<=128&&typeof r=="string"&&r.length<=64?{id:u,version:r}:void 0;return{...n,severity:"warning",format:t,pageIndex:i,componentIndex:s,kind:e.kind,nid:e.nid,...d?{extension:d}:{}}}function L(e,t){const i=[];return e.rotateDeg&&(t||!Number.isFinite(e.rotateDeg))&&i.push("rotateDeg"),e.opacity!==void 0&&e.opacity!==1&&(t||!Number.isFinite(e.opacity)||e.opacity<0||e.opacity>1)&&i.push("opacity"),i}function h(e,t,i=!1){if(!e||t==="dom")return;const s=t==="pdf"?L(e,i):[];return t!=="pdf"&&(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}function S(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=S(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 m(e,t,i,s,n,o){const a=u=>{n.push({...g(e,t,i,s,{code:"unsupported-style",message:u}),componentPath:o})};for(const u of e.richParagraphs??[]){t==="xlsx"&&(u.spaceBeforeMm||u.spaceAfterMm||u.indentMm||u.align||u.lineHeight)&&a("XLSX rich text preserves fonts and paragraph newlines; paragraph spacing, indentation and alignment are not retained.");const r=h({align:u.align},t);r&&a(r);for(const d of u.segments){const l=h(d.style,t,!0)??(t==="xlsx"?S(d.style):void 0);l&&a(l)}}}function w(e,t,i,s,n,o,a){if(a.has(e))return;const u=new Set(a).add(e),r=$(e,t);r&&o.push({...g(e,t,i,s,r),componentPath:n});const d=h(e.style,t);d&&o.push({...g(e,t,i,s,{code:"unsupported-style",message:d}),componentPath:n}),m(e,t,i,s,o,n),A(e,t,i,s,n,o,u)}function j(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 B(e){let t;return(i,s,n,o)=>{t??=new Map(c.resolveGridLayout(e.grid,e.widthMm,e.heightMm).cells.map(r=>[`${r.ri}:${r.ci}`,r]));const a=t.get(`${s}:${n}`),u=2*(e.grid?.paddingMm??.5);return j(i,(a?.widthMm??0)-u-(o?.indentMm??0),(a?.heightMm??0)-u)}}function A(e,t,i,s,n,o,a){const u=B(e);for(const[r,d]of(e.grid?.cells??[]).entries())for(const[l,p]of d.entries()){p?.dataBar!==void 0&&!c.validDataBar(p.dataBar)&&o.push({...g(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:[...n,r,l]});const v=h(p?.style,t);v&&o.push({...g(e,t,i,s,{code:"unsupported-style",message:v}),componentPath:[...n,r,l]}),p?.richParagraphs?.length&&m({...e,richParagraphs:p.richParagraphs},t,i,s,o,[...n,r,l]);for(const[E,f]of(p?.children??[]).entries()){const O=[...n,r,l,E];if(t==="xlsx"){const D=u(f,r,l,p);if(D&&o.push({...g(f,t,i,s,D),componentPath:O}),f.grid)continue}w(f,t,i,s,O,o,a)}}}function y(e,t,i){c.assertBoundedRenderTree(e),e.pages.forEach((s,n)=>s.components.forEach((o,a)=>w(o,t,n,a,[],i,new Set)))}function G(e,t){const i=[];return y(e,t,i),i}function P(e,t,i=c.DEFAULT_DIAGNOSTIC_LIMIT){const s=c.createDiagnosticCollector(i);return y(e,t,s),s.snapshot()}function x(e,t,i,s){c.assertOutputActive(i.signal);const n=c.createDiagnosticCollector(i.diagnosticLimit);s?.diagnosticSummary?n.merge(s.diagnosticSummary):s?.diagnostics.forEach(r=>n.push(r));const o=n.entries.length,a=i.diagnosticLimit===void 0?void 0:new Set(n.entries);if(y(e,t,{push:r=>{c.assertOutputActive(i.signal),n.push(r)}}),(a?n.entries.filter(r=>!a.has(r)):n.entries.slice(o)).forEach(r=>b(r,i)),i.fidelity==="strict"&&n.total)throw new M(n.entries,i.diagnosticLimit===void 0?void 0:n.snapshot());return n}function N(e,t,i){return x(e,t,i).entries}exports.OutputFidelityError=M;exports.collectOutputDiagnostics=x;exports.inspectOutputCapabilities=G;exports.inspectOutputCapabilitiesSummary=P;exports.notifyOutputDiagnostic=b;exports.reportOutputDiagnostics=N;
@@ -1,4 +1,4 @@
1
- import { A as f, z as E, G as k, x as M, N as $, i as O, E as L, r as C } from "./diagnostic-collector-gB07PHy2.js";
1
+ import { z as f, A as E, G as k, x, N as $, i as M, E as L, r as C } from "./diagnostic-collector-C-JBA016.js";
2
2
  function X(e, t) {
3
3
  f(t.signal), E(() => t.onDiagnostic?.(e)), f(t.signal);
4
4
  }
@@ -7,108 +7,112 @@ class j extends Error {
7
7
  super(`Output contains ${i?.total ?? t.length} known fidelity issue(s): ${t[0]?.code ?? Object.keys(i?.counts ?? {})[0] ?? "unknown"}`), this.diagnostics = t, this.diagnosticSummary = i, this.code = "output-fidelity", this.name = "OutputFidelityError";
8
8
  }
9
9
  }
10
- const B = /* @__PURE__ */ new Set(["text", "rect", "line", "ellipse"]), G = /* @__PURE__ */ new Set(["image", "chart", "barcode", "qrcode"]);
11
- function P(e, t) {
10
+ const G = /* @__PURE__ */ new Set(["text", "rect", "line", "ellipse"]), B = /* @__PURE__ */ new Set(["image", "chart", "barcode", "qrcode"]);
11
+ function N(e, t) {
12
12
  if (!e.grid) {
13
- if (O(e))
13
+ if (M(e))
14
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 (G.has(e.kind)) return { code: "missing-image", message: `${e.kind} requires imageData or a renderer adapter before output.` };
16
- if (!B.has(e.kind)) return { code: "unsupported-component", message: `Unsupported component kind: ${e.kind}.` };
15
+ if (B.has(e.kind)) return { code: "missing-image", message: `${e.kind} requires imageData or a renderer adapter before output.` };
16
+ if (!G.has(e.kind)) return { code: "unsupported-component", message: `Unsupported component kind: ${e.kind}.` };
17
17
  if (t === "xlsx" && e.kind !== "text") return { code: "unsupported-component", message: `XLSX data export omits ${e.kind} geometry.` };
18
18
  }
19
19
  }
20
- function g(e, t, i, n, s) {
20
+ function g(e, t, i, s, n) {
21
21
  const o = Object.getOwnPropertyDescriptor(e, "meta")?.value, a = o && Object.getOwnPropertyDescriptor(o, "componentExtension")?.value, u = a && Object.getOwnPropertyDescriptor(a, "id")?.value, r = a && Object.getOwnPropertyDescriptor(a, "version")?.value, d = typeof u == "string" && u.length <= 128 && typeof r == "string" && r.length <= 64 ? { id: u, version: r } : void 0;
22
- return { ...s, severity: "warning", format: t, pageIndex: i, componentIndex: n, kind: e.kind, nid: e.nid, ...d ? { extension: d } : {} };
22
+ return { ...n, severity: "warning", format: t, pageIndex: i, componentIndex: s, kind: e.kind, nid: e.nid, ...d ? { extension: d } : {} };
23
23
  }
24
- function h(e, t) {
25
- if (!e || t === "dom") return;
24
+ function P(e, t) {
26
25
  const i = [];
27
- 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;
26
+ return e.rotateDeg && (t || !Number.isFinite(e.rotateDeg)) && i.push("rotateDeg"), e.opacity !== void 0 && e.opacity !== 1 && (t || !Number.isFinite(e.opacity) || e.opacity < 0 || e.opacity > 1) && i.push("opacity"), i;
27
+ }
28
+ function h(e, t, i = !1) {
29
+ if (!e || t === "dom") return;
30
+ const s = t === "pdf" ? P(e, i) : [];
31
+ return t !== "pdf" && (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
32
  }
29
- function S(e) {
33
+ function O(e) {
30
34
  if (!e) return;
31
35
  const t = ["backgroundColor", "align", "verticalAlign", "lineHeight", "borderTop", "borderRight", "borderBottom", "borderLeft", "borderColor", "lineColor", "lineWidthPt"].filter((i) => e[i] !== void 0);
32
36
  return t.length ? `XLSX rich text does not retain independent run styles: ${t.join(", ")}.` : void 0;
33
37
  }
34
38
  function A(e) {
35
39
  if (e.kind !== "text") return;
36
- const t = S(e.style);
40
+ const t = O(e.style);
37
41
  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
42
  }
39
- function w(e, t, i, n, s, o) {
43
+ function S(e, t, i, s, n, o) {
40
44
  const a = (u) => {
41
- s.push({ ...g(e, t, i, n, { code: "unsupported-style", message: u }), componentPath: o });
45
+ n.push({ ...g(e, t, i, s, { code: "unsupported-style", message: u }), componentPath: o });
42
46
  };
43
47
  for (const u of e.richParagraphs ?? []) {
44
48
  t === "xlsx" && (u.spaceBeforeMm || u.spaceAfterMm || u.indentMm || u.align || u.lineHeight) && a("XLSX rich text preserves fonts and paragraph newlines; paragraph spacing, indentation and alignment are not retained.");
45
49
  const r = h({ align: u.align }, t);
46
50
  r && a(r);
47
51
  for (const d of u.segments) {
48
- const c = h(d.style, t) ?? (t === "xlsx" ? S(d.style) : void 0);
52
+ const c = h(d.style, t, !0) ?? (t === "xlsx" ? O(d.style) : void 0);
49
53
  c && a(c);
50
54
  }
51
55
  }
52
56
  }
53
- function D(e, t, i, n, s, o, a) {
57
+ function w(e, t, i, s, n, o, a) {
54
58
  if (a.has(e)) return;
55
- const u = new Set(a).add(e), r = P(e, t);
56
- r && o.push({ ...g(e, t, i, n, r), componentPath: s });
59
+ const u = new Set(a).add(e), r = N(e, t);
60
+ r && o.push({ ...g(e, t, i, s, r), componentPath: n });
57
61
  const d = h(e.style, t);
58
- d && o.push({ ...g(e, t, i, n, { code: "unsupported-style", message: d }), componentPath: s }), w(e, t, i, n, o, s), T(e, t, i, n, s, o, u);
62
+ d && o.push({ ...g(e, t, i, s, { code: "unsupported-style", message: d }), componentPath: n }), S(e, t, i, s, o, n), F(e, t, i, s, n, o, u);
59
63
  }
60
- function N(e, t, i) {
64
+ function T(e, t, i) {
61
65
  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 n = A(e);
63
- if (n) return n;
64
- if (O(e) && (e.leftMm < 0 || e.topMm < 0 || e.leftMm + e.widthMm > t + 1e-3 || e.topMm + e.heightMm > i + 1e-3)) return { code: "unsupported-style", message: "XLSX cannot clip a child image to a cell; it retains the original image dimensions." };
66
+ const s = A(e);
67
+ if (s) return s;
68
+ if (M(e) && (e.leftMm < 0 || e.topMm < 0 || e.leftMm + e.widthMm > t + 1e-3 || e.topMm + e.heightMm > i + 1e-3)) return { code: "unsupported-style", message: "XLSX cannot clip a child image to a cell; it retains the original image dimensions." };
65
69
  }
66
70
  function R(e) {
67
71
  let t;
68
- return (i, n, s, o) => {
72
+ return (i, s, n, o) => {
69
73
  t ??= new Map(C(e.grid, e.widthMm, e.heightMm).cells.map((r) => [`${r.ri}:${r.ci}`, r]));
70
- const a = t.get(`${n}:${s}`), u = 2 * (e.grid?.paddingMm ?? 0.5);
71
- return N(i, (a?.widthMm ?? 0) - u - (o?.indentMm ?? 0), (a?.heightMm ?? 0) - u);
74
+ const a = t.get(`${s}:${n}`), u = 2 * (e.grid?.paddingMm ?? 0.5);
75
+ return T(i, (a?.widthMm ?? 0) - u - (o?.indentMm ?? 0), (a?.heightMm ?? 0) - u);
72
76
  };
73
77
  }
74
- function T(e, t, i, n, s, o, a) {
78
+ function F(e, t, i, s, n, o, a) {
75
79
  const u = R(e);
76
80
  for (const [r, d] of (e.grid?.cells ?? []).entries()) for (const [c, l] of d.entries()) {
77
- l?.dataBar !== void 0 && !L(l.dataBar) && o.push({ ...g(e, t, i, n, { code: "unsupported-style", message: "Invalid resolved data-bar geometry or color; visual data bars require ordered 0–1 ratios and #RRGGBB colors." }), componentPath: [...s, r, c] });
81
+ l?.dataBar !== void 0 && !L(l.dataBar) && o.push({ ...g(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: [...n, r, c] });
78
82
  const v = h(l?.style, t);
79
- v && o.push({ ...g(e, t, i, n, { code: "unsupported-style", message: v }), componentPath: [...s, r, c] }), l?.richParagraphs?.length && w({ ...e, richParagraphs: l.richParagraphs }, t, i, n, o, [...s, r, c]);
83
+ v && o.push({ ...g(e, t, i, s, { code: "unsupported-style", message: v }), componentPath: [...n, r, c] }), l?.richParagraphs?.length && S({ ...e, richParagraphs: l.richParagraphs }, t, i, s, o, [...n, r, c]);
80
84
  for (const [m, p] of (l?.children ?? []).entries()) {
81
- const b = [...s, r, c, m];
85
+ const b = [...n, r, c, m];
82
86
  if (t === "xlsx") {
83
- const x = u(p, r, c, l);
84
- if (x && o.push({ ...g(p, t, i, n, x), componentPath: b }), p.grid) continue;
87
+ const D = u(p, r, c, l);
88
+ if (D && o.push({ ...g(p, t, i, s, D), componentPath: b }), p.grid) continue;
85
89
  }
86
- D(p, t, i, n, b, o, a);
90
+ w(p, t, i, s, b, o, a);
87
91
  }
88
92
  }
89
93
  }
90
94
  function y(e, t, i) {
91
- $(e), e.pages.forEach((n, s) => n.components.forEach((o, a) => D(o, t, s, a, [], i, /* @__PURE__ */ new Set())));
95
+ $(e), e.pages.forEach((s, n) => s.components.forEach((o, a) => w(o, t, n, a, [], i, /* @__PURE__ */ new Set())));
92
96
  }
93
97
  function _(e, t) {
94
98
  const i = [];
95
99
  return y(e, t, i), i;
96
100
  }
97
101
  function q(e, t, i = k) {
98
- const n = M(i);
99
- return y(e, t, n), n.snapshot();
102
+ const s = x(i);
103
+ return y(e, t, s), s.snapshot();
100
104
  }
101
- function I(e, t, i, n) {
105
+ function I(e, t, i, s) {
102
106
  f(i.signal);
103
- const s = M(i.diagnosticLimit);
104
- n?.diagnosticSummary ? s.merge(n.diagnosticSummary) : n?.diagnostics.forEach((r) => s.push(r));
105
- const o = s.entries.length, a = i.diagnosticLimit === void 0 ? void 0 : new Set(s.entries);
107
+ const n = x(i.diagnosticLimit);
108
+ s?.diagnosticSummary ? n.merge(s.diagnosticSummary) : s?.diagnostics.forEach((r) => n.push(r));
109
+ const o = n.entries.length, a = i.diagnosticLimit === void 0 ? void 0 : new Set(n.entries);
106
110
  if (y(e, t, { push: (r) => {
107
- f(i.signal), s.push(r);
108
- } }), (a ? s.entries.filter((r) => !a.has(r)) : s.entries.slice(o)).forEach((r) => X(r, i)), i.fidelity === "strict" && s.total) throw new j(s.entries, i.diagnosticLimit === void 0 ? void 0 : s.snapshot());
109
- return s;
111
+ f(i.signal), n.push(r);
112
+ } }), (a ? n.entries.filter((r) => !a.has(r)) : n.entries.slice(o)).forEach((r) => X(r, i)), i.fidelity === "strict" && n.total) throw new j(n.entries, i.diagnosticLimit === void 0 ? void 0 : n.snapshot());
113
+ return n;
110
114
  }
111
- function F(e, t, i) {
115
+ function H(e, t, i) {
112
116
  return I(e, t, i).entries;
113
117
  }
114
118
  export {
@@ -117,5 +121,5 @@ export {
117
121
  I as c,
118
122
  _ as i,
119
123
  X as n,
120
- F as r
124
+ H as r
121
125
  };
@@ -1 +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
+ "use strict";const w=require("./computed-BQgBrma-.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 { u as w } from "./computed-f3pOqWLX.js";
1
+ import { w } from "./computed-CH3NYPOW.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("未知图表类型");