@agile-team/mach-report 2.24.0 → 2.25.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.
- package/README.md +4 -4
- package/dist/{ExcelBindingWizard-BV12hGiK.cjs → ExcelBindingWizard-BgJG-T6k.cjs} +1 -1
- package/dist/{ExcelBindingWizard-Cy_lPjWV.js → ExcelBindingWizard-NQ_v396s.js} +3 -3
- package/dist/{ParamEditor-DenKjvKu.cjs → ParamEditor-DEP38mBp.cjs} +1 -1
- package/dist/{ParamEditor-PyOqHzzw.js → ParamEditor-Z-3yodp5.js} +2 -2
- package/dist/{ReportBatchPanel-pQ6d0yqJ.cjs → ReportBatchPanel-D33LjMrA.cjs} +1 -1
- package/dist/{ReportBatchPanel-8EFtMrKk.js → ReportBatchPanel-DG8FV-5X.js} +2 -2
- package/dist/{ReportLabelStudio-HUeo2TsU.js → ReportLabelStudio-BZp23_hA.js} +3 -3
- package/dist/{ReportLabelStudio-B_KF3Zc_.cjs → ReportLabelStudio-Bz-xAayk.cjs} +1 -1
- package/dist/{ReportParamPanel-8xR85nz-.cjs → ReportParamPanel-B27IGJjk.cjs} +1 -1
- package/dist/{ReportParamPanel-DA-YpkvC.js → ReportParamPanel-DGXzBzl2.js} +1 -1
- package/dist/{ReportPreview-_wTJnsG1.js → ReportPreview-CilFAS9U.js} +2392 -2342
- package/dist/ReportPreview-dOOzPts2.cjs +6 -0
- package/dist/{ReportTemplateLibrary-DH8jl9IF.js → ReportTemplateLibrary-DpSGgvFa.js} +1 -1
- package/dist/{ReportTemplateLibrary-CjArKxRG.cjs → ReportTemplateLibrary-uG1gENaW.cjs} +1 -1
- package/dist/{RuleEditor-GDydlEHz.js → RuleEditor-BONALh1Q.js} +2 -3
- package/dist/{RuleEditor-Bmj98oC4.cjs → RuleEditor-bLXiRcxL.cjs} +1 -1
- package/dist/{TemplateOutlinePanel-B554_qk1.cjs → TemplateOutlinePanel-C3nfHuaR.cjs} +1 -1
- package/dist/{TemplateOutlinePanel-DjPqzU9h.js → TemplateOutlinePanel-JGBKeF3e.js} +2 -2
- package/dist/{TemplateReusePanel-D0628OYc.cjs → TemplateReusePanel-BKhgp6kg.cjs} +1 -1
- package/dist/{TemplateReusePanel-DtYbCN7U.js → TemplateReusePanel-DXQUO6nQ.js} +2 -2
- package/dist/{TemplateReviewPanel-CSwvCz3f.cjs → TemplateReviewPanel-5RWFUUEf.cjs} +1 -1
- package/dist/{TemplateReviewPanel-D_FR4ISq.js → TemplateReviewPanel-DhL7Hapy.js} +1 -1
- package/dist/analytics.d.cts +1 -1
- package/dist/analytics.d.ts +1 -1
- package/dist/artifact-integrity.json +98 -98
- package/dist/{assets-B4AJIOTB.cjs → assets-BYdpkTIt.cjs} +1 -1
- package/dist/{assets-D0FbszhB.js → assets-C4MIvzQ4.js} +2 -2
- package/dist/{auto-C3mGqzJ8.cjs → auto-D-eDZa_V.cjs} +1 -1
- package/dist/{auto-BksreoKc.js → auto-umW_ozwr.js} +10 -10
- package/dist/{capabilities-lqDEZSq5.js → capabilities-CN_kSVjO.js} +7 -7
- package/dist/{capabilities-CTwlcl8q.cjs → capabilities-D4nfhcvB.cjs} +1 -1
- package/dist/cell-style-B6Qffrx8.js +37 -0
- package/dist/cell-style-y_uh1pZp.cjs +1 -0
- package/dist/{data-bar-BnGtnJ82.js → data-bar-Bfh54sT4.js} +1 -1
- package/dist/{data-bar-2NLRzOCQ.cjs → data-bar-DzceAVeR.cjs} +1 -1
- package/dist/{designer-BNf7NWd6.js → designer-CCyj5WYS.js} +2254 -2248
- package/dist/designer-Cj7fn4Hh.cjs +2 -0
- package/dist/designer.cjs +1 -1
- package/dist/designer.d.cts +6 -6
- package/dist/designer.d.ts +6 -6
- package/dist/designer.js +1 -1
- package/dist/diagnostic-collector-gB07PHy2.js +392 -0
- package/dist/diagnostic-collector-wASg6Fzs.cjs +1 -0
- package/dist/dom-CXWMmwh-.cjs +1 -0
- package/dist/{dom-C90cTM6Y.js → dom-DxdCMLzs.js} +185 -185
- package/dist/{encoding-DSc9zv2F.js → encoding-CEkBtlUP.js} +2 -2
- package/dist/{encoding-CkziAnZI.cjs → encoding-Cipno7dq.cjs} +1 -1
- package/dist/{font-loader-i7lZbqH_.js → font-loader-D4NLIKJL.js} +1 -1
- package/dist/{font-loader-D-znWNWS.cjs → font-loader-p_SyTvqt.cjs} +1 -1
- package/dist/{grid-strokes-BPiV1WHe.js → grid-strokes-DkZEZvcI.js} +1 -1
- package/dist/{grid-strokes-DYf-6DMl.cjs → grid-strokes-RFMR91jn.cjs} +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +137 -137
- package/dist/json-snapshot-DQdkA_At.cjs +2 -0
- package/dist/{json-snapshot-BJWZNryO.js → json-snapshot-x0JpllWL.js} +8 -8
- package/dist/{pdf-DWuq6uxx.cjs → pdf-C060D5UY.cjs} +2 -2
- package/dist/{pdf-0_5XiTCx.js → pdf-DU8HelKd.js} +17 -17
- package/dist/pdf.cjs +1 -1
- package/dist/pdf.js +2 -2
- package/dist/{plugin-BQBz2vLG.cjs → plugin-B_k23hut.cjs} +1 -1
- package/dist/{plugin-B1ydqEmS.js → plugin-CttO46hc.js} +1 -1
- package/dist/{prefill-Cuzh1wxf.js → prefill-BkF9Fw_p.js} +2 -2
- package/dist/{prefill-2p9wrpn9.cjs → prefill-BvkuwooY.cjs} +1 -1
- package/dist/{prepared-DAwe8Il2.cjs → prepared-CSywIEAZ.cjs} +1 -1
- package/dist/{prepared-CVbgO9KR.js → prepared-Cyuh61fJ.js} +2 -2
- package/dist/protocol-BwbJNVZl.cjs +1 -0
- package/dist/protocol-DwtxjXzO.js +96 -0
- package/dist/record-bindings-B7djSjNs.cjs +1 -0
- package/dist/{record-bindings-fhav-NLG.js → record-bindings-Cv7lFiof.js} +47 -47
- package/dist/{region-binding-workflow-DWCUgjZl.cjs → region-binding-workflow-COD8nISZ.cjs} +1 -1
- package/dist/{region-binding-workflow-Cm4mqhih.js → region-binding-workflow-D8I4QWRh.js} +2 -2
- package/dist/report-encoding-worker.cjs +1 -1
- package/dist/report-encoding-worker.js +1 -1
- package/dist/{rich-text-layout-YJHtCWQI.js → rich-text-layout-Ch_N0Ubu.js} +1 -1
- package/dist/{rich-text-layout-X9YOz1JD.cjs → rich-text-layout-yJGuThtC.cjs} +1 -1
- package/dist/runtime-BE30icyB.js +227 -0
- package/dist/runtime-DRSuy_SQ.cjs +1 -0
- package/dist/sbom.cdx.json +1 -1
- package/dist/server-node.cjs +5 -5
- package/dist/server-node.js +1695 -1661
- package/dist/server.cjs +1 -1
- package/dist/server.d.cts +4 -4
- package/dist/server.d.ts +4 -4
- package/dist/server.js +8 -8
- package/dist/style.css +1 -1
- package/dist/{template-catalog--yBX169M.cjs → template-catalog-C0riwrx7.cjs} +1 -1
- package/dist/{template-catalog-Bu7s7ReF.js → template-catalog-D_gl93va.js} +3 -3
- package/dist/{template-fragments-5EzVn7bm.cjs → template-fragments-CgzPdFKB.cjs} +1 -1
- package/dist/{template-fragments-Di2vDFnx.js → template-fragments-D94ZZmPc.js} +2 -2
- package/dist/{template-registry-Bnh5aEYf.cjs → template-registry-BMScUmM4.cjs} +1 -1
- package/dist/{template-registry-BCBF2b8j.js → template-registry-DZOtRY7t.js} +10 -10
- package/dist/{textwrap-CmVkhMhx.js → textwrap-BywMBMXM.js} +1 -1
- package/dist/{textwrap-BPFxhpOw.cjs → textwrap-LhJkHWb1.cjs} +1 -1
- package/dist/vue/async.d.cts +4 -4
- package/dist/vue/async.d.ts +4 -4
- package/dist/vue/index.d.cts +6 -6
- package/dist/vue/index.d.ts +6 -6
- package/dist/vue-async.cjs +1 -1
- package/dist/vue-async.js +3 -3
- package/dist/vue.cjs +1 -1
- package/dist/vue.js +7 -7
- package/dist/{workbook-session-BnPK3T58.cjs → workbook-session-DR2j6Hxm.cjs} +3 -3
- package/dist/{workbook-session-B6P_-5a4.js → workbook-session-SzfILBJJ.js} +106 -107
- package/dist/worker.cjs +1 -1
- package/dist/worker.js +4 -4
- package/dist/xlsx/node.d.cts +30 -1
- package/dist/xlsx/node.d.ts +30 -1
- package/dist/xlsx-node.cjs +42 -42
- package/dist/xlsx-node.js +3908 -3889
- package/dist/xlsx.cjs +2 -2
- package/dist/xlsx.d.cts +2 -2
- package/dist/xlsx.d.ts +2 -2
- package/dist/xlsx.js +151 -151
- package/package.json +1 -1
- package/dist/ReportPreview-CyUXJSVX.cjs +0 -6
- package/dist/designer-DWnZZ_ej.cjs +0 -2
- package/dist/diagnostic-collector-1sqd7DQP.js +0 -355
- package/dist/diagnostic-collector-D3rlvxm3.cjs +0 -1
- package/dist/dom-CxOkm_Sy.cjs +0 -1
- package/dist/json-snapshot-C7QZrRBf.cjs +0 -2
- package/dist/progress-BXzlVbIp.js +0 -29
- package/dist/progress-DJBd9Rb9.cjs +0 -1
- package/dist/protocol-BOri9qJL.js +0 -105
- package/dist/protocol-DD5dHSz-.cjs +0 -1
- package/dist/record-bindings-CAyM5tGg.cjs +0 -1
- package/dist/runtime-BpSAgOw1.js +0 -201
- package/dist/runtime-Cd2UTnwe.cjs +0 -1
|
@@ -1,355 +0,0 @@
|
|
|
1
|
-
const tt = 1.35, et = 10.5, nt = '"Microsoft YaHei", sans-serif', ot = 0.75, B = "#333333", U = "#000000", G = "1.0.0-mach", rt = 25.4, st = 96;
|
|
2
|
-
function R(t = 96) {
|
|
3
|
-
return t / 25.4;
|
|
4
|
-
}
|
|
5
|
-
function it(t, e = 96) {
|
|
6
|
-
return (t || 0) * R(e);
|
|
7
|
-
}
|
|
8
|
-
function at(t, e = 96) {
|
|
9
|
-
return t / R(e);
|
|
10
|
-
}
|
|
11
|
-
function K(t, e = 96) {
|
|
12
|
-
return t * e / 72;
|
|
13
|
-
}
|
|
14
|
-
function ct(t, e) {
|
|
15
|
-
const n = 10 ** e;
|
|
16
|
-
return Math.round(t * n) / n;
|
|
17
|
-
}
|
|
18
|
-
const ut = {
|
|
19
|
-
a3: { widthMm: 297, heightMm: 420 },
|
|
20
|
-
a4: { widthMm: 210, heightMm: 297 },
|
|
21
|
-
a5: { widthMm: 148, heightMm: 210 },
|
|
22
|
-
b4: { widthMm: 250, heightMm: 353 },
|
|
23
|
-
b5: { widthMm: 176, heightMm: 250 }
|
|
24
|
-
};
|
|
25
|
-
function ft(t, e = 96, n = 10.5) {
|
|
26
|
-
if (t?.fontSizePx != null)
|
|
27
|
-
return { fontSizePt: t.fontSizePx * 72 / e, fontSizePx: t.fontSizePx };
|
|
28
|
-
const o = t?.fontSize ?? n;
|
|
29
|
-
return { fontSizePt: o, fontSizePx: K(o, e) };
|
|
30
|
-
}
|
|
31
|
-
function lt(t, e = B) {
|
|
32
|
-
return {
|
|
33
|
-
color: t?.borderColor ?? t?.lineColor ?? e,
|
|
34
|
-
widthPt: t?.lineWidthPt ?? 0.75
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
function dt(t, e = U) {
|
|
38
|
-
return t?.color ?? e;
|
|
39
|
-
}
|
|
40
|
-
function ht(t) {
|
|
41
|
-
return t?.lineHeight ?? 1.35;
|
|
42
|
-
}
|
|
43
|
-
function pt(t) {
|
|
44
|
-
const e = t?.borderTop !== !1, n = t?.borderRight !== !1, o = t?.borderBottom !== !1, r = t?.borderLeft !== !1;
|
|
45
|
-
return { top: e, right: n, bottom: o, left: r, inner: e || n || o || r };
|
|
46
|
-
}
|
|
47
|
-
function mt(t, e) {
|
|
48
|
-
const n = { ...t, ...e };
|
|
49
|
-
return e?.fontSize != null && e.fontSizePx == null && delete n.fontSizePx, e?.fontSizePx != null && e.fontSize == null && delete n.fontSize, n;
|
|
50
|
-
}
|
|
51
|
-
function V(t, e) {
|
|
52
|
-
const n = t.length;
|
|
53
|
-
if (n === 0) return [];
|
|
54
|
-
const o = t.reduce((f, l) => f + l, 0), r = o > 0 && e > 0 ? e / o : 1, i = [];
|
|
55
|
-
let u = 0;
|
|
56
|
-
for (let f = 0; f < n; f++) {
|
|
57
|
-
const l = Math.max(0, t[f] * r);
|
|
58
|
-
i.push({ pos: u, size: l }), u += l;
|
|
59
|
-
}
|
|
60
|
-
return i;
|
|
61
|
-
}
|
|
62
|
-
function L(t, e, n) {
|
|
63
|
-
return t?.length ? V(t, e) : Array.from({ length: n }, (o, r) => ({
|
|
64
|
-
pos: e * r / n,
|
|
65
|
-
size: e / n
|
|
66
|
-
}));
|
|
67
|
-
}
|
|
68
|
-
function gt(t, e, n) {
|
|
69
|
-
const o = t.cells ?? [], r = Math.max(o.length, 1), i = t.colWidthsMm?.length ?? o.reduce((s, a) => Math.max(s, Array.isArray(a) ? a.length : 0), 1), u = L(t.colWidthsMm, e, i), f = (s) => s <= 0 ? 0 : s >= i ? u[u.length - 1].pos + u[u.length - 1].size : u[s].pos, l = L(t.rowHeightsMm, n, r), m = (s) => s <= 0 ? 0 : s >= r ? l[l.length - 1].pos + l[l.length - 1].size : l[s].pos, x = /* @__PURE__ */ new Set(), y = (s, a) => `${s}:${a}`, P = [], _ = /* @__PURE__ */ new Set(), d = /* @__PURE__ */ new Set(), h = (s, a) => `v${s}:${a}`, p = (s, a) => `h${s}:${a}`;
|
|
70
|
-
o.forEach((s, a) => {
|
|
71
|
-
if (!Array.isArray(s)) return;
|
|
72
|
-
let c = 0;
|
|
73
|
-
for (const E of s) {
|
|
74
|
-
for (; c < i && x.has(y(a, c)); ) c++;
|
|
75
|
-
if (c >= i) break;
|
|
76
|
-
const F = Math.max(1, Math.min(E?.colSpan ?? 1, i - c)), H = Math.max(1, E?.rowSpan ?? 1), T = Math.min(r, a + H), A = Math.min(i, c + F);
|
|
77
|
-
for (let b = a; b < T; b++)
|
|
78
|
-
for (let S = c; S < A; S++)
|
|
79
|
-
x.add(y(b, S));
|
|
80
|
-
for (let b = c + 1; b < A; b++)
|
|
81
|
-
for (let S = a; S < T; S++) _.add(h(b, S));
|
|
82
|
-
for (let b = a + 1; b < T; b++)
|
|
83
|
-
for (let S = c; S < A; S++) d.add(p(b, S));
|
|
84
|
-
const I = f(c), C = m(a);
|
|
85
|
-
P.push({
|
|
86
|
-
ri: a,
|
|
87
|
-
ci: c,
|
|
88
|
-
cell: E ?? {},
|
|
89
|
-
xMm: I,
|
|
90
|
-
yMm: C,
|
|
91
|
-
widthMm: f(A) - I,
|
|
92
|
-
heightMm: m(T) - C
|
|
93
|
-
}), c = A;
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
const g = [];
|
|
97
|
-
for (let s = 1; s < i; s++) {
|
|
98
|
-
let a = -1;
|
|
99
|
-
for (let c = 0; c <= r; c++) {
|
|
100
|
-
const E = c < r && !_.has(h(s, c));
|
|
101
|
-
E && a < 0 && (a = c), !E && a >= 0 && (g.push({ kind: "v", pos: f(s), from: m(a), to: m(c) }), a = -1);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
for (let s = 1; s < r; s++) {
|
|
105
|
-
let a = -1;
|
|
106
|
-
for (let c = 0; c <= i; c++) {
|
|
107
|
-
const E = c < i && !d.has(p(s, c));
|
|
108
|
-
E && a < 0 && (a = c), !E && a >= 0 && (g.push({ kind: "h", pos: m(s), from: f(a), to: f(c) }), a = -1);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
return { columns: u, rows: l, cells: P, edges: g };
|
|
112
|
-
}
|
|
113
|
-
function bt(t) {
|
|
114
|
-
if (!t || typeof t != "object" || Array.isArray(t)) return !1;
|
|
115
|
-
const { start: e, end: n, color: o } = t;
|
|
116
|
-
return typeof e == "number" && typeof n == "number" && Number.isFinite(e) && Number.isFinite(n) && e >= 0 && n <= 1 && e <= n && typeof o == "string" && /^#[0-9a-f]{6}$/i.test(o);
|
|
117
|
-
}
|
|
118
|
-
const St = G;
|
|
119
|
-
function Et(t) {
|
|
120
|
-
return (t.kind === "image" || t.kind === "barcode" || t.kind === "qrcode" || t.kind === "chart") && !!t.imageData;
|
|
121
|
-
}
|
|
122
|
-
function xt(t) {
|
|
123
|
-
return t.kind === "text" && Array.isArray(t.richParagraphs) && t.richParagraphs.length > 0;
|
|
124
|
-
}
|
|
125
|
-
function M(t) {
|
|
126
|
-
return !!t && typeof t == "object";
|
|
127
|
-
}
|
|
128
|
-
function v(t, e, n, o, r) {
|
|
129
|
-
if (++r.nodes > 1e6) return { path: e, message: "组件树超过100万个结构节点预算" };
|
|
130
|
-
if (M(t)) {
|
|
131
|
-
if (n > 64) return { path: e, message: "组件嵌套超过64层预算" };
|
|
132
|
-
if (o.has(t)) return { path: e, message: "组件树包含循环引用" };
|
|
133
|
-
if (!(!M(t.grid) || !Array.isArray(t.grid.cells))) {
|
|
134
|
-
o.add(t);
|
|
135
|
-
try {
|
|
136
|
-
for (const [i, u] of t.grid.cells.entries())
|
|
137
|
-
if (Array.isArray(u))
|
|
138
|
-
for (const [f, l] of u.entries()) {
|
|
139
|
-
if (++r.nodes > 1e6) return { path: e, message: "组件树超过100万个结构节点预算" };
|
|
140
|
-
if (!(!M(l) || !Array.isArray(l.children)))
|
|
141
|
-
for (const [m, x] of l.children.entries()) {
|
|
142
|
-
const y = v(x, `${e}.grid.cells.${i}.${f}.children.${m}`, n + 1, o, r);
|
|
143
|
-
if (y) return y;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
} finally {
|
|
147
|
-
o.delete(t);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
function q(t, e = "$.components", n = { nodes: 0 }) {
|
|
153
|
-
for (const [o, r] of t.entries()) {
|
|
154
|
-
const i = v(r, `${e}.${o}`, 0, /* @__PURE__ */ new Set(), n);
|
|
155
|
-
if (i) return i;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
function W(t) {
|
|
159
|
-
const e = { nodes: 0 };
|
|
160
|
-
for (const [n, o] of t.entries()) {
|
|
161
|
-
if (!M(o) || !Array.isArray(o.components)) continue;
|
|
162
|
-
const r = q(o.components, `$.pages.${n}.components`, e);
|
|
163
|
-
if (r) return r;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
function yt(t) {
|
|
167
|
-
const e = W(t.pages);
|
|
168
|
-
if (e) throw new TypeError(`${e.path}: ${e.message}`);
|
|
169
|
-
}
|
|
170
|
-
function w(t) {
|
|
171
|
-
if (t?.aborted) throw t.reason ?? new DOMException("The operation was aborted.", "AbortError");
|
|
172
|
-
}
|
|
173
|
-
function X(t) {
|
|
174
|
-
try {
|
|
175
|
-
Promise.resolve(t()).catch(() => {
|
|
176
|
-
});
|
|
177
|
-
} catch {
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
function Y(t, e, n) {
|
|
181
|
-
w(t.signal), X(() => t.onProgress?.(e, n)), w(t.signal);
|
|
182
|
-
}
|
|
183
|
-
function At(t, e) {
|
|
184
|
-
const n = Promise.resolve(t);
|
|
185
|
-
return e?.aborted ? (n.catch(() => {
|
|
186
|
-
}), Promise.reject(e.reason ?? new DOMException("The operation was aborted.", "AbortError"))) : e ? new Promise((o, r) => {
|
|
187
|
-
const i = () => e.removeEventListener("abort", u), u = () => {
|
|
188
|
-
i(), r(e.reason ?? new DOMException("The operation was aborted.", "AbortError"));
|
|
189
|
-
};
|
|
190
|
-
e.addEventListener("abort", u, { once: !0 }), n.then((f) => {
|
|
191
|
-
i(), o(f);
|
|
192
|
-
}, (f) => {
|
|
193
|
-
i(), r(f);
|
|
194
|
-
}), e.aborted && u();
|
|
195
|
-
}) : n;
|
|
196
|
-
}
|
|
197
|
-
function wt(t, e) {
|
|
198
|
-
const n = () => e.abort(t?.reason);
|
|
199
|
-
return t?.addEventListener("abort", n, { once: !0 }), t?.aborted && n(), () => t?.removeEventListener("abort", n);
|
|
200
|
-
}
|
|
201
|
-
async function Pt(t, e, n) {
|
|
202
|
-
Y(t, e, n), (t.signal || t.onProgress) && await new Promise((o) => setTimeout(o, 0)), w(t.signal);
|
|
203
|
-
}
|
|
204
|
-
function _t(t) {
|
|
205
|
-
let e = 0, n = Date.now();
|
|
206
|
-
return (o = 1) => {
|
|
207
|
-
if (w(t.signal), e += o, !(e < 4096 && Date.now() - n < 8))
|
|
208
|
-
return e = 0, new Promise((r) => setTimeout(r, 0)).then(() => {
|
|
209
|
-
n = Date.now(), w(t.signal);
|
|
210
|
-
});
|
|
211
|
-
};
|
|
212
|
-
}
|
|
213
|
-
const Tt = 200, $ = 1e3, k = 128, O = "other", N = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]), Z = {
|
|
214
|
-
"invalid-image-data": !0,
|
|
215
|
-
"image-budget-exceeded": !0,
|
|
216
|
-
"component-render-failed": !0,
|
|
217
|
-
"unsupported-text": !0,
|
|
218
|
-
"output-degraded": !0,
|
|
219
|
-
"missing-image": !0,
|
|
220
|
-
"unsupported-component": !0,
|
|
221
|
-
"unsupported-image-format": !0,
|
|
222
|
-
"unsupported-style": !0,
|
|
223
|
-
"rich-text-flattened": !0,
|
|
224
|
-
"nested-components-omitted": !0,
|
|
225
|
-
"async-image-required": !0,
|
|
226
|
-
"image-decode-failed": !0,
|
|
227
|
-
"asset-render-failed": !0,
|
|
228
|
-
"asset-budget-exceeded": !0
|
|
229
|
-
}, j = /* @__PURE__ */ new Set([...Object.keys(Z), "pdf-page", "pdf-font", "pdf-fidelity", "xlsx-fidelity", "xlsx-snapshot", "prepared-layout-preserved", "prepared-font-metrics", "layout"]);
|
|
230
|
-
function z(t) {
|
|
231
|
-
if (t === void 0) return 1 / 0;
|
|
232
|
-
if (!Number.isInteger(t) || t < 0 || t > $) throw new RangeError("diagnosticLimit must be an integer between 0 and 1000");
|
|
233
|
-
return t;
|
|
234
|
-
}
|
|
235
|
-
function Mt(t) {
|
|
236
|
-
const e = z(t), n = [], o = /* @__PURE__ */ Object.create(null), r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ Object.create(null);
|
|
237
|
-
let u = 0, f = 0, l = 0;
|
|
238
|
-
function m(d, h) {
|
|
239
|
-
const p = d.length <= 128 && !N.has(d) && (o[d] !== void 0 || l < k || j.has(d)) ? d : O;
|
|
240
|
-
return o[p] === void 0 && l++, o[p] = (o[p] ?? 0) + h, p;
|
|
241
|
-
}
|
|
242
|
-
function x(d, h) {
|
|
243
|
-
const p = `${D(d) ? "e" : "o"}:${h}`;
|
|
244
|
-
if (n.length < e) {
|
|
245
|
-
n.push(d), r.set(p, (r.get(p) ?? 0) + 1);
|
|
246
|
-
return;
|
|
247
|
-
}
|
|
248
|
-
if (!(!e || r.has(p)))
|
|
249
|
-
for (let g = n.length - 1; g >= 0; g--) {
|
|
250
|
-
const s = n[g], a = `${D(s) ? "e" : "o"}:${o[s.code] === void 0 ? O : s.code}`, c = r.get(a) ?? 0;
|
|
251
|
-
if (!(c <= 1)) {
|
|
252
|
-
n[g] = d, r.set(a, c - 1), r.set(p, 1);
|
|
253
|
-
return;
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
function y(d) {
|
|
258
|
-
f++;
|
|
259
|
-
const h = m(d.code, 1);
|
|
260
|
-
D(d) && (u++, i[h] = (i[h] ?? 0) + 1), x(d, h);
|
|
261
|
-
}
|
|
262
|
-
function P(d) {
|
|
263
|
-
f += d.total;
|
|
264
|
-
for (const [h, p] of Object.entries(d.counts)) {
|
|
265
|
-
const g = m(h, p), s = d.explanations?.counts[h] ?? 0;
|
|
266
|
-
s && (u += s, i[g] = (i[g] ?? 0) + s);
|
|
267
|
-
}
|
|
268
|
-
for (const h of d.entries) x(h, o[h.code] === void 0 ? O : h.code);
|
|
269
|
-
}
|
|
270
|
-
function _() {
|
|
271
|
-
return { total: f, counts: { ...o }, entries: n.slice(), omitted: f - n.length, ...u ? { explanations: { total: u, counts: { ...i } } } : {} };
|
|
272
|
-
}
|
|
273
|
-
return { entries: n, push: y, merge: P, snapshot: _, get total() {
|
|
274
|
-
return f;
|
|
275
|
-
} };
|
|
276
|
-
}
|
|
277
|
-
function Ot(t) {
|
|
278
|
-
if (!t || typeof t != "object" || Array.isArray(t)) return !1;
|
|
279
|
-
const e = t;
|
|
280
|
-
if (!Number.isSafeInteger(e.total) || e.total < 0 || !Number.isSafeInteger(e.omitted) || e.omitted < 0 || !Array.isArray(e.entries) || e.entries.length > $ || e.total !== e.entries.length + e.omitted || !e.counts || typeof e.counts != "object" || Array.isArray(e.counts) || Object.keys(e.counts).some((o) => o.length > 128 || N.has(o))) return !1;
|
|
281
|
-
const n = Object.values(e.counts);
|
|
282
|
-
return n.length > k + j.size + 1 || n.some((o) => !Number.isSafeInteger(o) || o <= 0) || n.reduce((o, r) => o + r, 0) !== e.total ? !1 : Q(e) && J(e);
|
|
283
|
-
}
|
|
284
|
-
function J(t) {
|
|
285
|
-
const e = /* @__PURE__ */ new Map();
|
|
286
|
-
for (const n of t.entries) {
|
|
287
|
-
const o = n && typeof n == "object" && typeof n.code == "string" ? n.code : "unknown", r = Object.prototype.hasOwnProperty.call(t.counts, o) ? o : O, i = !!n && typeof n == "object" && D(n), u = `${i ? "e" : "o"}:${r}`, f = (e.get(u) ?? 0) + 1, l = t.explanations?.counts[r] ?? 0;
|
|
288
|
-
if ((i ? l : (t.counts[r] ?? 0) - l) < f) return !1;
|
|
289
|
-
e.set(u, f);
|
|
290
|
-
}
|
|
291
|
-
return !0;
|
|
292
|
-
}
|
|
293
|
-
function D(t) {
|
|
294
|
-
return t.valueState !== void 0;
|
|
295
|
-
}
|
|
296
|
-
function Q(t) {
|
|
297
|
-
if (t.explanations === void 0) return !0;
|
|
298
|
-
const e = t.explanations;
|
|
299
|
-
if (!e || typeof e != "object" || Array.isArray(e) || !Number.isSafeInteger(e.total) || e.total < 0 || e.total > t.total || !e.counts || typeof e.counts != "object" || Array.isArray(e.counts)) return !1;
|
|
300
|
-
const n = Object.entries(e.counts);
|
|
301
|
-
return n.every(([o, r]) => Number.isSafeInteger(r) && r > 0 && r <= (t.counts[o] ?? 0)) && n.reduce((o, [, r]) => o + r, 0) === e.total;
|
|
302
|
-
}
|
|
303
|
-
function Dt(t, e) {
|
|
304
|
-
const n = z(t), o = [];
|
|
305
|
-
let r = 0;
|
|
306
|
-
return { entries: o, get total() {
|
|
307
|
-
return r;
|
|
308
|
-
}, push(...i) {
|
|
309
|
-
for (const u of i)
|
|
310
|
-
r++, o.length < n && o.push(u), e?.(u);
|
|
311
|
-
return r;
|
|
312
|
-
} };
|
|
313
|
-
}
|
|
314
|
-
export {
|
|
315
|
-
bt as A,
|
|
316
|
-
wt as B,
|
|
317
|
-
st as C,
|
|
318
|
-
nt as D,
|
|
319
|
-
Tt as E,
|
|
320
|
-
Ot as F,
|
|
321
|
-
q as G,
|
|
322
|
-
W as H,
|
|
323
|
-
yt as I,
|
|
324
|
-
tt as L,
|
|
325
|
-
rt as M,
|
|
326
|
-
ut as P,
|
|
327
|
-
St as R,
|
|
328
|
-
G as S,
|
|
329
|
-
ft as a,
|
|
330
|
-
ht as b,
|
|
331
|
-
dt as c,
|
|
332
|
-
lt as d,
|
|
333
|
-
pt as e,
|
|
334
|
-
xt as f,
|
|
335
|
-
U as g,
|
|
336
|
-
ot as h,
|
|
337
|
-
Et as i,
|
|
338
|
-
et as j,
|
|
339
|
-
B as k,
|
|
340
|
-
it as l,
|
|
341
|
-
mt as m,
|
|
342
|
-
R as n,
|
|
343
|
-
Pt as o,
|
|
344
|
-
K as p,
|
|
345
|
-
at as q,
|
|
346
|
-
gt as r,
|
|
347
|
-
ct as s,
|
|
348
|
-
Dt as t,
|
|
349
|
-
Mt as u,
|
|
350
|
-
_t as v,
|
|
351
|
-
At as w,
|
|
352
|
-
X as x,
|
|
353
|
-
w as y,
|
|
354
|
-
Y as z
|
|
355
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const q='"Microsoft YaHei", sans-serif';const v="#333333",N="#000000",F="1.0.0-mach";function w(t=96){return t/25.4}function Z(t,e=96){return(t||0)*w(e)}function J(t,e=96){return t/w(e)}function k(t,e=96){return t*e/72}function Q(t,e){const n=10**e;return Math.round(t*n)/n}const tt={a3:{widthMm:297,heightMm:420},a4:{widthMm:210,heightMm:297},a5:{widthMm:148,heightMm:210},b4:{widthMm:250,heightMm:353},b5:{widthMm:176,heightMm:250}};function et(t,e=96,n=10.5){if(t?.fontSizePx!=null)return{fontSizePt:t.fontSizePx*72/e,fontSizePx:t.fontSizePx};const o=t?.fontSize??n;return{fontSizePt:o,fontSizePx:k(o,e)}}function nt(t,e=v){return{color:t?.borderColor??t?.lineColor??e,widthPt:t?.lineWidthPt??.75}}function ot(t,e=N){return t?.color??e}function rt(t){return t?.lineHeight??1.35}function st(t){const e=t?.borderTop!==!1,n=t?.borderRight!==!1,o=t?.borderBottom!==!1,r=t?.borderLeft!==!1;return{top:e,right:n,bottom:o,left:r,inner:e||n||o||r}}function it(t,e){const n={...t,...e};return e?.fontSize!=null&&e.fontSizePx==null&&delete n.fontSizePx,e?.fontSizePx!=null&&e.fontSize==null&&delete n.fontSize,n}function ct(t,e){const n=t.length;if(n===0)return[];const o=t.reduce((f,l)=>f+l,0),r=o>0&&e>0?e/o:1,i=[];let u=0;for(let f=0;f<n;f++){const l=Math.max(0,t[f]*r);i.push({pos:u,size:l}),u+=l}return i}function R(t,e,n){return t?.length?ct(t,e):Array.from({length:n},(o,r)=>({pos:e*r/n,size:e/n}))}function at(t,e,n){const o=t.cells??[],r=Math.max(o.length,1),i=t.colWidthsMm?.length??o.reduce((s,c)=>Math.max(s,Array.isArray(c)?c.length:0),1),u=R(t.colWidthsMm,e,i),f=s=>s<=0?0:s>=i?u[u.length-1].pos+u[u.length-1].size:u[s].pos,l=R(t.rowHeightsMm,n,r),m=s=>s<=0?0:s>=r?l[l.length-1].pos+l[l.length-1].size:l[s].pos,_=new Set,b=(s,c)=>`${s}:${c}`,x=[],O=new Set,d=new Set,h=(s,c)=>`v${s}:${c}`,p=(s,c)=>`h${s}:${c}`;o.forEach((s,c)=>{if(!Array.isArray(s))return;let a=0;for(const T of s){for(;a<i&&_.has(b(c,a));)a++;if(a>=i)break;const W=Math.max(1,Math.min(T?.colSpan??1,i-a)),Y=Math.max(1,T?.rowSpan??1),y=Math.min(r,c+Y),P=Math.min(i,a+W);for(let E=c;E<y;E++)for(let S=a;S<P;S++)_.add(b(E,S));for(let E=a+1;E<P;E++)for(let S=c;S<y;S++)O.add(h(E,S));for(let E=c+1;E<y;E++)for(let S=a;S<P;S++)d.add(p(E,S));const C=f(a),L=m(c);x.push({ri:c,ci:a,cell:T??{},xMm:C,yMm:L,widthMm:f(P)-C,heightMm:m(y)-L}),a=P}});const g=[];for(let s=1;s<i;s++){let c=-1;for(let a=0;a<=r;a++){const T=a<r&&!O.has(h(s,a));T&&c<0&&(c=a),!T&&c>=0&&(g.push({kind:"v",pos:f(s),from:m(c),to:m(a)}),c=-1)}}for(let s=1;s<r;s++){let c=-1;for(let a=0;a<=i;a++){const T=a<i&&!d.has(p(s,a));T&&c<0&&(c=a),!T&&c>=0&&(g.push({kind:"h",pos:m(s),from:f(c),to:f(a)}),c=-1)}}return{columns:u,rows:l,cells:x,edges:g}}function ut(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;const{start:e,end:n,color:o}=t;return typeof e=="number"&&typeof n=="number"&&Number.isFinite(e)&&Number.isFinite(n)&&e>=0&&n<=1&&e<=n&&typeof o=="string"&&/^#[0-9a-f]{6}$/i.test(o)}const ft=F;function lt(t){return(t.kind==="image"||t.kind==="barcode"||t.kind==="qrcode"||t.kind==="chart")&&!!t.imageData}function dt(t){return t.kind==="text"&&Array.isArray(t.richParagraphs)&&t.richParagraphs.length>0}function D(t){return!!t&&typeof t=="object"}function H(t,e,n,o,r){if(++r.nodes>1e6)return{path:e,message:"组件树超过100万个结构节点预算"};if(D(t)){if(n>64)return{path:e,message:"组件嵌套超过64层预算"};if(o.has(t))return{path:e,message:"组件树包含循环引用"};if(!(!D(t.grid)||!Array.isArray(t.grid.cells))){o.add(t);try{for(const[i,u]of t.grid.cells.entries())if(Array.isArray(u))for(const[f,l]of u.entries()){if(++r.nodes>1e6)return{path:e,message:"组件树超过100万个结构节点预算"};if(!(!D(l)||!Array.isArray(l.children)))for(const[m,_]of l.children.entries()){const b=H(_,`${e}.grid.cells.${i}.${f}.children.${m}`,n+1,o,r);if(b)return b}}}finally{o.delete(t)}}}}function $(t,e="$.components",n={nodes:0}){for(const[o,r]of t.entries()){const i=H(r,`${e}.${o}`,0,new Set,n);if(i)return i}}function U(t){const e={nodes:0};for(const[n,o]of t.entries()){if(!D(o)||!Array.isArray(o.components))continue;const r=$(o.components,`$.pages.${n}.components`,e);if(r)return r}}function ht(t){const e=U(t.pages);if(e)throw new TypeError(`${e.path}: ${e.message}`)}function A(t){if(t?.aborted)throw t.reason??new DOMException("The operation was aborted.","AbortError")}function z(t){try{Promise.resolve(t()).catch(()=>{})}catch{}}function B(t,e,n){A(t.signal),z(()=>t.onProgress?.(e,n)),A(t.signal)}function pt(t,e){const n=Promise.resolve(t);return e?.aborted?(n.catch(()=>{}),Promise.reject(e.reason??new DOMException("The operation was aborted.","AbortError"))):e?new Promise((o,r)=>{const i=()=>e.removeEventListener("abort",u),u=()=>{i(),r(e.reason??new DOMException("The operation was aborted.","AbortError"))};e.addEventListener("abort",u,{once:!0}),n.then(f=>{i(),o(f)},f=>{i(),r(f)}),e.aborted&&u()}):n}function mt(t,e){const n=()=>e.abort(t?.reason);return t?.addEventListener("abort",n,{once:!0}),t?.aborted&&n(),()=>t?.removeEventListener("abort",n)}async function gt(t,e,n){B(t,e,n),(t.signal||t.onProgress)&&await new Promise(o=>setTimeout(o,0)),A(t.signal)}function Et(t){let e=0,n=Date.now();return(o=1)=>{if(A(t.signal),e+=o,!(e<4096&&Date.now()-n<8))return e=0,new Promise(r=>setTimeout(r,0)).then(()=>{n=Date.now(),A(t.signal)})}}const St=200,j=1e3,G=128,I="other",V=new Set(["__proto__","prototype","constructor"]),Tt={"invalid-image-data":!0,"image-budget-exceeded":!0,"component-render-failed":!0,"unsupported-text":!0,"output-degraded":!0,"missing-image":!0,"unsupported-component":!0,"unsupported-image-format":!0,"unsupported-style":!0,"rich-text-flattened":!0,"nested-components-omitted":!0,"async-image-required":!0,"image-decode-failed":!0,"asset-render-failed":!0,"asset-budget-exceeded":!0},K=new Set([...Object.keys(Tt),"pdf-page","pdf-font","pdf-fidelity","xlsx-fidelity","xlsx-snapshot","prepared-layout-preserved","prepared-font-metrics","layout"]);function X(t){if(t===void 0)return 1/0;if(!Number.isInteger(t)||t<0||t>j)throw new RangeError("diagnosticLimit must be an integer between 0 and 1000");return t}function _t(t){const e=X(t),n=[],o=Object.create(null),r=new Map,i=Object.create(null);let u=0,f=0,l=0;function m(d,h){const p=d.length<=128&&!V.has(d)&&(o[d]!==void 0||l<G||K.has(d))?d:I;return o[p]===void 0&&l++,o[p]=(o[p]??0)+h,p}function _(d,h){const p=`${M(d)?"e":"o"}:${h}`;if(n.length<e){n.push(d),r.set(p,(r.get(p)??0)+1);return}if(!(!e||r.has(p)))for(let g=n.length-1;g>=0;g--){const s=n[g],c=`${M(s)?"e":"o"}:${o[s.code]===void 0?I:s.code}`,a=r.get(c)??0;if(!(a<=1)){n[g]=d,r.set(c,a-1),r.set(p,1);return}}}function b(d){f++;const h=m(d.code,1);M(d)&&(u++,i[h]=(i[h]??0)+1),_(d,h)}function x(d){f+=d.total;for(const[h,p]of Object.entries(d.counts)){const g=m(h,p),s=d.explanations?.counts[h]??0;s&&(u+=s,i[g]=(i[g]??0)+s)}for(const h of d.entries)_(h,o[h.code]===void 0?I:h.code)}function O(){return{total:f,counts:{...o},entries:n.slice(),omitted:f-n.length,...u?{explanations:{total:u,counts:{...i}}}:{}}}return{entries:n,push:b,merge:x,snapshot:O,get total(){return f}}}function bt(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;const e=t;if(!Number.isSafeInteger(e.total)||e.total<0||!Number.isSafeInteger(e.omitted)||e.omitted<0||!Array.isArray(e.entries)||e.entries.length>j||e.total!==e.entries.length+e.omitted||!e.counts||typeof e.counts!="object"||Array.isArray(e.counts)||Object.keys(e.counts).some(o=>o.length>128||V.has(o)))return!1;const n=Object.values(e.counts);return n.length>G+K.size+1||n.some(o=>!Number.isSafeInteger(o)||o<=0)||n.reduce((o,r)=>o+r,0)!==e.total?!1:Pt(e)&&At(e)}function At(t){const e=new Map;for(const n of t.entries){const o=n&&typeof n=="object"&&typeof n.code=="string"?n.code:"unknown",r=Object.prototype.hasOwnProperty.call(t.counts,o)?o:I,i=!!n&&typeof n=="object"&&M(n),u=`${i?"e":"o"}:${r}`,f=(e.get(u)??0)+1,l=t.explanations?.counts[r]??0;if((i?l:(t.counts[r]??0)-l)<f)return!1;e.set(u,f)}return!0}function M(t){return t.valueState!==void 0}function Pt(t){if(t.explanations===void 0)return!0;const e=t.explanations;if(!e||typeof e!="object"||Array.isArray(e)||!Number.isSafeInteger(e.total)||e.total<0||e.total>t.total||!e.counts||typeof e.counts!="object"||Array.isArray(e.counts))return!1;const n=Object.entries(e.counts);return n.every(([o,r])=>Number.isSafeInteger(r)&&r>0&&r<=(t.counts[o]??0))&&n.reduce((o,[,r])=>o+r,0)===e.total}function xt(t,e){const n=X(t),o=[];let r=0;return{entries:o,get total(){return r},push(...i){for(const u of i)r++,o.length<n&&o.push(u),e?.(u);return r}}}exports.CSS_DPI=96;exports.DEFAULT_BORDER_PT=.75;exports.DEFAULT_DIAGNOSTIC_LIMIT=St;exports.DEFAULT_FONT_FAMILY=q;exports.DEFAULT_FONT_PT=10.5;exports.DEFAULT_STROKE_COLOR=v;exports.DEFAULT_TEXT_COLOR=N;exports.LINE_HEIGHT=1.35;exports.MM_PER_INCH=25.4;exports.PAPER_SIZES=tt;exports.RENDER_PLAN_SCHEMA_VERSION=ft;exports.SCHEMA_VERSION_MACH=F;exports.assertBoundedRenderTree=ht;exports.assertOutputActive=A;exports.componentTreeIssue=$;exports.createDiagnosticCollector=_t;exports.createDiagnosticMessages=xt;exports.createOutputScheduler=Et;exports.forwardOutputAbort=mt;exports.isImageBackedComponent=lt;exports.isRichText=dt;exports.mergeComponentStyles=it;exports.mmToPx=Z;exports.mmToPxFactor=w;exports.notifyOutputProgress=B;exports.observeOutput=z;exports.outputCheckpoint=gt;exports.ptToPx=k;exports.pxToMm=J;exports.renderTreeIssue=U;exports.resolveBoxBorders=st;exports.resolveFontSize=et;exports.resolveGridLayout=at;exports.resolveLineHeight=rt;exports.resolveStroke=nt;exports.resolveTextColor=ot;exports.round=Q;exports.validDataBar=ut;exports.validDiagnosticSummary=bt;exports.waitForOutput=pt;
|
package/dist/dom-CxOkm_Sy.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const z=require("./template-serialization-CqQY4zDg.cjs"),V=require("./data-bar-2NLRzOCQ.cjs"),B=require("./dom-cell-address-DLD1mkTB.cjs"),f=require("./diagnostic-collector-D3rlvxm3.cjs"),D=require("./grid-strokes-DYf-6DMl.cjs"),R=require("./capabilities-CTwlcl8q.cjs");function F(e){const t=/\.pages\[(\d+)\](?:\.components\[(\d+)\])?/.exec(e);return t?{pageIndex:Number(t[1]),...t[2]===void 0?{}:{componentIndex:Number(t[2])}}:{}}function q(e,t,r){return z.collectTemplateDatasetBindings(e).filter(n=>n.dataset===t).flatMap(n=>n.fields.filter(o=>o.field===r).map(o=>({...o,...F(o.path),dataset:t,kind:/\.computed\[/.test(o.path)?"calculation":/\.columns\[\d+\]\.field$/.test(o.path)?"display":"binding"})))}function j(e,t){const r=e.kind==="list"?e.title||e.dataset:e.binding?.field||e.text||e.nid;return`${e.kind} · ${(r||String(t+1)).replace(/\s+/g," ").slice(0,80)}`}function K(e){const t=z.collectTemplateDatasetBindings(e),r=new Map;for(const o of t)for(const l of o.fields){const a=/^\$\.template\.pages\[\d+\]\.components\[\d+\]/.exec(l.path)?.[0];if(!a)continue;const s=r.get(a)??[];s.push({...l,dataset:o.dataset}),r.set(a,s)}const n=[];return e.pages.forEach((o,l)=>{const a=`$.template.pages[${l}]`;n.push({path:a,pageIndex:l,kind:"page",depth:0,title:typeof o.meta?.title=="string"?o.meta.title:`${l+1} · ${o.widthMm} × ${o.heightMm} mm`}),o.components.forEach((s,i)=>{const d=`${a}.components[${i}]`,h={pageIndex:l,componentIndex:i};n.push({path:d,...h,depth:1,kind:"component",title:j(s,i)}),s.kind==="list"&&(s.columns.forEach((m,p)=>n.push({path:`${d}.columns[${p}].field`,...h,depth:2,kind:"field",title:`${m.header} · ${m.field}`,field:m.field,dataset:s.dataset})),s.computed?.forEach((m,p)=>n.push({path:`${d}.computed[${p}]`,...h,depth:2,kind:"calculation",title:m.field,field:m.field,dataset:s.dataset})));const c=new Set;for(const m of r.get(d)??[])/\.columns\[\d+\]\.field$/.test(m.path)||c.has(m.path)||(c.add(m.path),n.push({...m,...h,depth:2,kind:"binding",title:m.field}))})}),n}function M(e,t,r){let n=0,o=e.length;for(;n<o;){const l=n+o>>>1;r(e[l])<t?n=l+1:o=l}return n}function L(e){if(![e.leftMm,e.topMm,e.widthMm,e.heightMm].every(Number.isFinite)||e.widthMm<0||e.heightMm<0)throw new RangeError("Preview viewport must have finite coordinates and nonnegative dimensions.");return e}function U(e){const t=e.rows.map(()=>[]);for(const r of e.cells){const n=Math.min(t.length,r.ri+(r.cell.rowSpan??1));for(let o=r.ri;o<n;o++)t[o].push(r)}for(const r of t)r.sort((n,o)=>n.xMm-o.xMm);return{cells(r){L(r);const n=new Set,o=r.topMm+r.heightMm,l=r.leftMm+r.widthMm;let a=M(e.rows,r.topMm,s=>s.pos+s.size);for(;a<t.length&&e.rows[a].pos<=o;){const s=t[a++];let i=M(s,r.leftMm,d=>d.xMm+d.widthMm);for(;i<s.length&&s[i].xMm<=l;)n.add(s[i++])}return[...n].sort((s,i)=>s.ri-i.ri||s.ci-i.ci)}}}function _(e){const t=["h","v"].map(r=>e.filter(n=>n.kind===r).sort((n,o)=>n.pos-o.pos));return r=>{const n=[];return t.forEach((o,l)=>{const a=l===0?r.topMm:r.leftMm,s=a+(l===0?r.heightMm:r.widthMm),i=l===0?r.leftMm:r.topMm,d=i+(l===0?r.widthMm:r.heightMm);let h=M(o,a,c=>c.pos);for(;h<o.length&&o[h].pos<=s;){const c=o[h++];c.to>=i&&c.from<=d&&n.push(c)}}),n}}function W(){const e=[];return{mount(t){e.push(ee(t))},update(t,r,n,o){L(t);let l=!1;for(const a of e)l=a.update(t,a.component===r?n:void 0,o)||l;return l}}}function X(e,t){const r=Math.max(8,e.widthMm/4),n=Math.max(8,e.heightMm/4);return{leftMm:e.leftMm-t.leftMm-r,topMm:e.topMm-t.topMm-n,widthMm:e.widthMm+2*r,heightMm:e.heightMm+2*n}}function Y(e,t,r){let n=t.get(r);return n||(n=e.table.ownerDocument.createElement("tr"),n.className=e.rowClass,n.setAttribute("role","row"),n.setAttribute("aria-rowindex",String(r+1)),n.style.cssText="all:unset;display:contents;box-sizing:border-box",t.set(r,n)),n}function J(e,t,r,n){const o=new Set(t),l=new Set(t.map(i=>i.ri)),a=new Map;for(const[i,d]of r)if(!o.has(i)){d.remove(),r.delete(i);const h=e.reuseKey?.(i);if(h!==void 0){const c=a.get(h)??[];c.push(d),a.set(h,c)}}for(const[i,d]of n)l.has(i)||(d.remove(),n.delete(i));for(const i of t){let d=r.get(i);if(!d){const c=e.reuseKey?.(i),m=c===void 0?void 0:a.get(c)?.pop();d=m&&e.reuseCell?.(m,i)?m:e.drawCell(i),d.setAttribute("aria-colindex",String(i.ci+1)),r.set(i,d)}const h=Y(e,n,i.ri);d.parentElement!==h&&h.appendChild(d)}const s=new Map;for(const i of t){const d=s.get(i.ri)??[];d.push(r.get(i)),s.set(i.ri,d)}for(const[i,d]of s)A(n.get(i),d);A(e.body,[...l].sort((i,d)=>i-d).map(i=>n.get(i)))}function A(e,t){let r=e.firstElementChild;for(const n of t)n===r?r=r.nextElementSibling:e.insertBefore(n,r)}function Q(e,t){return e.table?.role==="header"?e.heightMm:t.rows[0]?.size??0}function Z(e,t,r,n){const o=[e],l=n.freezeHeaders&&(r.table?.role==="header"||!r.table),a=Q(r,t);l&&o.push({...e,topMm:0,heightMm:Math.max(0,a-1e-4)});const s=Math.max(0,Math.min(20,Math.floor(n.frozenColumns??0)))||0;if(!s||!t.columns.length)return o;const i=t.columns[Math.min(s,t.columns.length)-1],d={...e,leftMm:0,widthMm:Math.max(0,i.pos+i.size-1e-4)};return o.push(d),l&&o.push({...d,topMm:0,heightMm:Math.max(0,a-1e-4)}),o}function ee(e){const t=f.resolveGridLayout(e.grid,e.component.widthMm,e.component.heightMm),r=new Map(t.cells.map(h=>[`${h.ri}:${h.ci}`,h])),n=U(t),o=new Map,l=new Map,a=_(D.resolveGridStrokes(t,e.component));e.table.setAttribute("aria-rowcount",String(t.rows.length)),e.table.setAttribute("aria-colcount",String(t.columns.length));let s="",i="";function d(h,c){const m=new Set;for(const p of Z(h,t,e.component,c??{}))for(const w of n.cells(p))m.add(w);return[...m]}return{component:e.component,update(h,c,m){const p=X(h,e.component),w=d(p,m),y=c&&r.get(`${c.rowIndex}:${c.columnIndex}`);y&&!w.includes(y)&&w.push(y),w.sort((b,$)=>b.ri-$.ri||b.ci-$.ci);const C=w.map(b=>`${b.ri}:${b.ci}`).join(";"),S=a(p),v=S.map(b=>`${b.kind}:${b.pos}:${b.from}:${b.to}`).join(";"),E=C!==s,T=v!==i;return E&&(s=C,J(e,w,o,l)),T&&(i=v,e.edgeHost.replaceChildren(...e.drawEdges(S))),E||T}}}const G=new WeakMap,te={root:"mr-root",page:"mr-page",comp:"mr-comp",text:"mr-text",lines:"mr-lines",line:"mr-line",rich:"mr-rich",paragraph:"mr-paragraph",segment:"mr-segment",image:"mr-image",shape:"mr-shape",grid:"mr-grid",row:"mr-row",cell:"mr-cell",unknown:"mr-unknown"};function g(e,t){return t?.classNames?.[e]??te[e]}class ne{constructor(){this.props=[]}add(t,r){return r==null||r===!1||r===""?this:(this.props.push([t,String(r)]),this)}mm(t,r,n,o=2){return this.add(t,`${f.round(f.mmToPx(r,n),o)}px`)}toString(){let t="";for(const[r,n]of this.props)t+=`${r}:${n};`;return t}applyTo(t){const r=this.toString();r&&(t.style.cssText=r)}}function u(e,t="unset"){return new ne().add("all",t).add("display",e).add("box-sizing","border-box")}function H(e,t,r){e.add("color",t.color).add("font-family",t.fontFamily).add("font-weight",t.bold!=null?t.bold?"700":"400":void 0).add("font-style",t.italic!=null?t.italic?"italic":"normal":void 0).add("text-decoration",t.underline!=null?t.underline?"underline":"none":void 0).add("letter-spacing",t.letterSpacing!=null?`${t.letterSpacing}pt`:void 0).add("line-height",String(f.resolveLineHeight(t))).add("text-align",t.align);const n=f.resolveFontSize(t,r);e.add("font-size",`${f.round(n.fontSizePx,2)}px`)}function re(e,t,r){const n=t.style??{};H(e,n,r);const o=!t.grid&&(t.kind==="ellipse"||t.kind==="line");e.add("background-color",o?void 0:n.backgroundColor).add("opacity",n.opacity!=null?String(n.opacity):void 0).add("transform",n.rotateDeg?`rotate(${n.rotateDeg}deg)`:void 0)}function P(e,t,r,n,o,l){const a=e.cell,s=l.createElement("td");s.className=g("cell",o),B.setDomCellAddress(s,e.ri,e.ci),s.setAttribute("role",t.table?.role==="header"?"columnheader":"cell"),a.colSpan&&(s.colSpan=a.colSpan),a.rowSpan&&(s.rowSpan=a.rowSpan);const i=f.mergeComponentStyles(t.style,a.style),d=u("block").add("position","absolute").mm("left",e.xMm,n).mm("top",e.yMm,n).mm("width",e.widthMm,n).mm("height",e.heightMm,n).add("background-color",i.backgroundColor).add("vertical-align",i.verticalAlign??"middle");H(d,i,n),d.applyTo(s);const h=V.dataBarBox(a.dataBar,e.widthMm,e.heightMm,r);if(h){const m=l.createElement("div");m.className="mr-cell-data-bar",m.setAttribute("aria-hidden","true"),u("block").add("position","absolute").mm("left",h.x,n).mm("top",h.y,n).mm("width",h.width,n).mm("height",h.height,n).add("background-color",h.color).add("opacity","0.35").add("pointer-events","none").applyTo(m),s.appendChild(m)}const c=l.createElement("div");c.className="mr-cell-content",u("flex").add("position","absolute").mm("left",r+(a.indentMm??0),n).mm("right",r,n).mm("top",r,n).mm("bottom",r,n).add("flex-direction","column").add("justify-content",i.verticalAlign==="top"?"flex-start":i.verticalAlign==="bottom"?"flex-end":"center").add("overflow-wrap","anywhere").add("overflow","hidden").applyTo(c),a.richParagraphs?.length?c.appendChild(I({...t,kind:"text",richParagraphs:a.richParagraphs},n,o,l)):a.text!=null&&c.append(a.text);for(const m of a.children??[])c.appendChild(x(m,n,o,l));return s.insertBefore(c,s.firstChild),s}function oe(e,t,r,n){return O(D.resolveGridStrokes(e,t),r,n)}function ie(e){const t=e.cell;if(!(t.children?.length||t.richParagraphs?.length||t.dataBar||(t.colSpan??1)!==1||(t.rowSpan??1)!==1))return JSON.stringify([t.style,t.indentMm])}function le(e,t,r){if(e.style.position!=="absolute"||e.style.zIndex||e.style.transform||e.children.length!==1)return!1;const n=e.firstElementChild;return!(n instanceof HTMLElement)||n.className!=="mr-cell-content"?!1:(B.setDomCellAddress(e,t.ri,t.ci),e.style.left=`${f.round(f.mmToPx(t.xMm,r),2)}px`,e.style.top=`${f.round(f.mmToPx(t.yMm,r),2)}px`,e.style.width=`${f.round(f.mmToPx(t.widthMm,r),2)}px`,e.style.height=`${f.round(f.mmToPx(t.heightMm,r),2)}px`,n.textContent=t.cell.text??"",!0)}function O(e,t,r){return e.map(n=>{const o=`${f.round(n.widthPt*t/72,2)}px solid ${n.color}`,l=r.createElement("div");l.className="mr-grid-edge",l.setAttribute("aria-hidden","true");const a=n.kind==="h";return u("block").add("position","absolute").add("pointer-events","none").mm("left",a?n.from:n.pos,t).mm("top",a?n.pos:n.from,t).mm("width",a?n.to-n.from:0,t).mm("height",a?0:n.to-n.from,t).add(a?"border-top":"border-left",o).applyTo(l),l})}function ae(e,t,r,n,o){const l=o.createElement("table");l.className=g("grid",n),l.setAttribute("role","table"),u("block").add("position","relative").add("width","100%").add("height","100%").applyTo(l);const a=o.createElement("tbody");u("contents").applyTo(a),l.appendChild(a);const s=t.style?.rotateDeg?void 0:G.get(n);if(s){const c=o.createElement("div");u("block").add("position","relative").add("width","100%").add("height","100%").applyTo(c);const m=o.createElement("div");return u("contents").applyTo(m),m.setAttribute("aria-hidden","true"),s.mount({grid:e,component:t,table:l,rowClass:g("row",n),body:a,edgeHost:m,drawCell:p=>P(p,t,e.paddingMm??.5,r,{...n},o),reuseKey:ie,reuseCell:(p,w)=>le(p,w,r),drawEdges:p=>O(p,r,o)}),c.append(l,m),c}const i=f.resolveGridLayout(e,t.widthMm,t.heightMm),d=e.cells.map(()=>{const c=o.createElement("tr");return c.className=g("row",n),c.setAttribute("role","row"),u("contents").applyTo(c),a.appendChild(c),c});for(const c of i.cells)d[c.ri].appendChild(P(c,t,e.paddingMm??.5,r,n,o));const h=o.createElement("div");return u("block").add("position","relative").add("width","100%").add("height","100%").applyTo(h),h.append(l,...oe(i,t,r,o)),h}function se(e,t,r,n){const o=n.createElement("div");o.className=g("paragraph",r),u("block").add("text-align",e.align).add("line-height",e.lineHeight!=null?String(e.lineHeight):void 0).mm("margin-top",e.spaceBeforeMm??0,t).mm("margin-bottom",e.spaceAfterMm??0,t).mm("text-indent",e.indentMm??0,t).applyTo(o);for(const l of e.segments||[]){const a=n.createElement("span");a.className=g("segment",r),a.textContent=l.kind==="field"?l.field??"":l.text??"";const s=u("inline");if(l.style){const i=l.style;s.add("color",i.color).add("background-color",i.backgroundColor).add("font-family",i.fontFamily).add("line-height",i.lineHeight).add("letter-spacing",i.letterSpacing==null?void 0:`${i.letterSpacing*t/72}px`).add("font-weight",i.bold!=null?i.bold?"700":"400":void 0).add("font-style",i.italic!=null?i.italic?"italic":"normal":void 0).add("text-decoration",i.underline!=null?i.underline?"underline":"none":void 0),(i.fontSize!=null||i.fontSizePx!=null)&&s.add("font-size",`${f.round(f.resolveFontSize(i,t).fontSizePx,2)}px`)}s.applyTo(a),o.appendChild(a)}return o}function I(e,t,r,n){if(f.isRichText(e)){const o=n.createElement("div");o.className=g("rich",r),u("block").applyTo(o);for(const l of e.richParagraphs)o.appendChild(se(l,t,r,n));return o}if(Array.isArray(e.lines)&&e.lines.length>0){const o=n.createElement("div");o.className=g("lines",r),u("block").applyTo(o);for(const l of e.lines){const a=n.createElement("div");a.className=g("line",r),a.textContent=l,u("block").add("white-space","pre").add("min-height","1lh").applyTo(a),o.appendChild(a)}return o}return e.text??""}function de(e,t,r,n){const o=n.createElement("div");o.className=g("text",r);const l=e.style||{};return u("flex").add("width","100%").add("height","100%").add("flex-direction","column").add("justify-content",l.verticalAlign==="middle"?"center":l.verticalAlign==="bottom"?"flex-end":"flex-start").add("overflow-wrap","anywhere").add("overflow","hidden").applyTo(o),o.append(I(e,t,r,n)),o}function ce(e,t,r){const n=r.createElement("img");return n.className=g("image",t),n.src=e.imageData,u("block").add("width","100%").add("height","100%").add("object-fit","contain").applyTo(n),n.alt=e.kind,n}function N(e,t,r,n){const o=n.createElement("div");o.className=g("shape",r);const l=e.style||{},a=f.resolveStroke(l),s=f.resolveBoxBorders(l),i=`${f.round(a.widthPt*t/72,2)}px solid ${a.color}`,d=u("block");return e.grid?d.add("position","relative"):e.kind==="rect"?(s.top&&d.add("border-top",i),s.right&&d.add("border-right",i),s.bottom&&d.add("border-bottom",i),s.left&&d.add("border-left",i)):e.kind==="ellipse"?(d.add("border-radius","50%"),s.inner&&d.add("border",i),l.backgroundColor&&d.add("background-color",l.backgroundColor)):e.kind==="line"&&d.add("height","0").add("border-top",i),d.add("box-sizing","border-box").add("width","100%").add("height","100%"),d.applyTo(o),o}function he(e,t,r){const n=r.createElementNS("http://www.w3.org/2000/svg","svg"),o=f.mmToPx(e.widthMm,t),l=f.mmToPx(e.heightMm,t);n.setAttribute("width",String(Math.max(1,o))),n.setAttribute("height",String(Math.max(1,l))),n.setAttribute("aria-hidden","true"),n.style.overflow="visible",n.style.display="block";const a=r.createElementNS("http://www.w3.org/2000/svg","line");a.setAttribute("x1","0"),a.setAttribute("x2",String(o)),a.setAttribute("y1",e.lineDirection==="up"?String(l):"0"),a.setAttribute("y2",e.lineDirection==="up"?"0":String(l));const s=f.resolveStroke({...e.style,borderColor:e.style?.lineColor??e.style?.borderColor});return a.setAttribute("stroke",s.color),a.setAttribute("stroke-width",String(s.widthPt*t/72)),n.appendChild(a),n}function x(e,t,r,n){const o=n.createElement("div");o.className=`${g("comp",r)} mr-kind-${e.kind}`;const l=u("block").add("position","absolute").mm("left",e.leftMm,t).mm("top",e.topMm,t).mm("width",e.widthMm,t).mm("height",e.heightMm,t).add("box-sizing","border-box");if(re(l,e,t),l.applyTo(o),f.isImageBackedComponent(e))return o.appendChild(ce(e,r,n)),o;if(e.kind==="text")return o.appendChild(de(e,t,r,n)),o;if(e.grid){const s=N(e,t,r,n);return s.appendChild(ae(e.grid,e,t,r,n)),o.appendChild(s),o}if(e.kind==="line"&&e.lineDirection)return o.appendChild(he(e,t,n)),o;if(e.kind==="line"||e.kind==="rect"||e.kind==="ellipse")return o.appendChild(N(e,t,r,n)),o;const a=n.createElement("div");return a.className=g("unknown",r),u("block").applyTo(a),a.textContent=e.fallbackText??`[${e.kind}]`,a.dataset.mrUnsupported=e.kind,a.setAttribute("role","note"),o.appendChild(a),o}function k(e,t,r,n){const o=n.createElement("div");return o.className=g("page",r),u("block","initial").add("position","relative").add("font-family",f.DEFAULT_FONT_FAMILY).add("font-size",`${f.round(f.resolveFontSize(void 0,t).fontSizePx,2)}px`).add("line-height",String(f.resolveLineHeight(void 0))).add("white-space","pre-wrap").add("direction","ltr").mm("width",e.pageWidthMm,t).mm("height",e.pageHeightMm,t).add("background-color","#fff").add("color",f.DEFAULT_TEXT_COLOR).add("overflow","hidden").add("box-sizing","border-box").applyTo(o),e.components.forEach((l,a)=>{const s=x(l,t,r,n);s.dataset.mrComponentIndex=String(a),o.appendChild(s)}),o}function me(e,t,r={}){const n=r.dpi??96;R.reportOutputDiagnostics(e,"dom",r);const o=t.createElement("div");return o.className=g("root",r),u("block").applyTo(o),o.dataset.schemaVersion=e.schemaVersion,e.pages.forEach(l=>{o.appendChild(k(l,n,r,t))}),o}function fe(e,t,r,n){const o={...r},l=W();return G.set(o,l),{element:k(e,t,o,n),update(s,i,d){return l.update(s,i&&e.components[i.componentIndex],i,d)}}}exports.classOf=g;exports.collectTemplateOutline=K;exports.createPageViewportRenderer=fe;exports.inspectTemplateFieldUsage=q;exports.renderComponent=x;exports.renderPage=k;exports.renderPlan=me;exports.templatePathLocation=F;
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";const E=require("./diagnostic-collector-D3rlvxm3.cjs"),A=require("./textwrap-BPFxhpOw.cjs"),k=require("./computed-DK6BruFz.cjs"),S=require("./record-bindings-CAyM5tGg.cjs"),_e=require("./matrix-B8QWbsGM.cjs"),W=require("./template-serialization-CqQY4zDg.cjs"),H=require("./template-registry-Bnh5aEYf.cjs"),Kt=require("./report-params-VTg8MoCp.cjs"),Ke=require("./param-validation-C-8sRJLq.cjs"),ze=require("./number-format-CZ2T_5kF.cjs"),Me=require("./dataset-IrlXbUvh.cjs"),jt=4096,je=128*1024;function Dt(e){const t=new Map;let r=0;return{measureMm(n,o){const a=JSON.stringify([n,o.fontSizePt,o.fontFamily,o.bold,o.italic,o.letterSpacingPt]),i=t.get(a);if(i!==void 0)return t.delete(a),t.set(a,i),i;const s=e.measureMm(n,o);if(Number.isFinite(s)&&a.length<=je){for(;t.size>=jt||r+a.length>je;){const c=t.keys().next().value;r-=c.length,t.delete(c)}t.set(a,s),r+=a.length}return s}}}function Bt(e,t){return{member:"body",subtotal:"subtotal",total:"grand-total"}[e?.rows.get(t)?.kind??"member"]}function Ht(e){const t=e.matrix;if(!t.hierarchy)return t;const r=new Map(e.columns.map(o=>[o.field,o.header])),n={sum:"求和",count:"计数",avg:"平均",min:"最小",max:"最大",weightedAvg:"加权平均"};return{...t,hierarchy:{...t.hierarchy,row:{...t.hierarchy.row,labels:t.hierarchy.row?.labels??t.rowFields.map(o=>r.get(o)??o)},column:{...t.hierarchy.column,labels:t.hierarchy.column?.labels??t.columnFields.map(o=>r.get(o)??o)}},measures:t.measures.map(o=>{const a=r.get(o.field)??r.get(o.valueField??o.field);return o.label===void 0&&a?{...o,label:`${a}(${n[o.op]})`}:o})}}function Gt(e,t){if(!e.matrix)return{list:e,rows:t};if(e.detail||e.groupBy||e.groups?.length||e.grandTotal)throw new Error("矩阵不能同时配置普通分组、总计或主从明细");const r=_e.createMatrixTable(t,Ht(e)),n=r.columns.map(s=>({...s,widthMm:s.semanticRole==="dimension"?e.matrix.rowWidthMm??40:e.matrix.columnWidthMm??28,editable:!1,align:s.semanticRole==="dimension"?"center":"right"})),o={...e,columns:n,headerGrid:r.headerGrid,rowKey:void 0,revisionField:void 0,sourceTokenField:void 0};e.layout==="wide"&&(o.widthMm=n.reduce((s,c)=>s+c.widthMm,0));const a=r.metadata,i=a?{rows:new WeakMap(r.rows.map((s,c)=>[s,a.rows[c]])),header:{columns:a.columns,rowFields:a.rowFields,rowLabels:a.rowLabels,columnFields:a.columnFields,columnLabels:a.columnLabels}}:void 0;return{list:o,rows:r.rows,...i?{matrix:i}:{}}}function Vt(e,t){if(!e.matrix?.hierarchy||!e.headerGrid)return e.headerGrid;const r=e.paddingMm??1,n=e.headerGrid.cells.map(()=>e.rowHeightMm??0),o=e.columns.map(c=>c.widthMm),a=E.resolveGridLayout({...e.headerGrid,colWidthsMm:o},o.reduce((c,l)=>c+l,0),n.length),i=new WeakMap;for(const{cell:c,ci:l,ri:u,widthMm:f}of a.cells){const d={...S.resolveListHeaderStyle(e,e.columns[l]),...c.style},m=E.resolveFontSize(d).fontSizePt,b=(A.wrapText(c.text??"",Math.max(1,f-r*2),{fontSizePt:m,fontFamily:d.fontFamily,bold:d.bold,italic:d.italic,letterSpacingPt:d.letterSpacing},t).length*m*(d.lineHeight??E.LINE_HEIGHT)*25.4/72+r*2)/(c.rowSpan??1);for(let w=u;w<u+(c.rowSpan??1);w++)n[w]=Math.max(n[w]??0,b);i.set(c,d)}const s=e.headerGrid.cells.map(c=>c.map(l=>l?{...l,style:i.get(l)}:null));return{...e.headerGrid,cells:s,rowHeightsMm:n}}function Wt(e,t,r){const n=new Set,o=e.cells.map((a,i)=>{const s=[];let c=0;for(const l of a){for(;n.has(`${i}:${c}`);)c++;const u=l?.colSpan??1,f=l?.rowSpan??1;let d=0;for(let m=c;m<c+u;m++){t.has(m)&&d++;for(let g=i+1;g<i+f;g++)n.add(`${g}:${m}`)}d&&s.push(l?{...l,colSpan:d}:null),c+=u}return s});return{...e,cells:o,colWidthsMm:r}}function Je(e){if(!e.columns.some(n=>n.hidden))return e;const t=new Set,r=e.columns.filter((n,o)=>n.hidden?!1:(t.add(o),!0));if(!r.length)throw new Error("列表至少需要一列可见列");return{...e,columns:r,...e.headerGrid?{headerGrid:Wt(e.headerGrid,t,r.map(n=>n.widthMm))}:{}}}function*_t(e){const{page:t}=e;H.validateReportPageFlow(t.components,t.flow);let r=0,n=0;for(const o of H.reportFlowGroups(t.components,t.flow)){e.active();const a=o.band,i=o.components.some(u=>u.kind==="list"&&u.cardinality!=="record"),s=i?0:o.components.reduce((u,f)=>Math.max(u,f.topMm-a.topMm+(f.kind==="list"?e.height(f):f.heightMm)),a.heightMm);let c=Math.max(e.top(),n+a.topMm-r);if(!i&&s>e.bottom()-e.top()+.001)throw new Error(`静态区域 ${a.componentIds.join(",")} 高度超出单页可用范围`);!i&&c+s>e.bottom()+.001&&(e.nextPage(),yield*e.takePages(),e.active(),c=e.top());let l=c+s;for(const u of o.components){const f=c+u.topMm-a.topMm;u.kind==="list"?(yield*e.list(u,f,d=>{l=i?d:Math.max(l,d)}),e.active()):e.append({...u,topMm:f})}n=l,r=a.topMm+a.heightMm}}function zt(e){return!!(e.computed?.length||e.groups?.length||e.groupBy||e.grandTotal||e.rowVisibleWhen||e.matrix||e.tree||e.detail||e.columns.some(t=>t.rules?.length||t.visibleWhen||t.visual))}function Se(e){return e.pages.some(t=>t.components.some(r=>r.kind==="list"?zt(r):!!r.chartBinding))}const Jt=512,De=256*1024;function qt(){const e=new Map;let t=0,r;return(n,o,a,i)=>{i!==r&&(e.clear(),t=0,r=i);const s=JSON.stringify([n,o,a.fontSizePt,a.fontFamily,a.bold,a.italic,a.letterSpacingPt]),c=e.get(s);if(c)return e.delete(s),e.set(s,c),c.lines.slice();const l=A.wrapText(n,o,a,i),u=s.length+l.reduce((f,d)=>f+d.length,0);if(u<=De){for(;e.size>=Jt||t+u>De;){const f=e.keys().next().value;t-=e.get(f).units,e.delete(f)}e.set(s,{lines:l.slice(),units:u}),t+=u}return l}}const qe=1e4,Be=25e4;function xe(e){if(e?.aborted)throw e.reason??new DOMException("标签生成已取消","AbortError")}function Ue(e,t,r){const n=typeof e.copies=="object"?S.readRecordScalar(t,e.copies.field,r):e.copies??1;if(typeof n!="number"||!Number.isSafeInteger(n)||n<1||n>1e3)throw new S.ReportBindingError(`$.datasets.${r.dataset}[${r.rowIndex}]`,"每条记录复制数必须是 1..1000 的数值型整数",r.rowIndex,typeof e.copies=="object"?e.copies.field:void 0);return n}function Xe(e,t,r){if(e.rowKey===void 0)return;const n=S.readRecordScalar(t,e.rowKey,r);if(typeof n=="string"&&n.trim()||typeof n=="number"&&Number.isFinite(n))return n;throw new S.ReportBindingError(`$.datasets.${r.dataset}[${r.rowIndex}].${e.rowKey}`,"业务主键必须是非空字符串或有限数字",r.rowIndex,e.rowKey)}function Ut(e){const t=r=>1+(r.grid?.cells.reduce((n,o)=>n+1+o.length+o.reduce((a,i)=>a+(i?.children?.reduce((s,c)=>s+t(c),0)??0),0),0)??0);return e.pages.reduce((r,n)=>r+n.components.reduce((o,a)=>o+t(a),0),0)}function Xt(e,t,r){const n=e.repeat,o=Object.prototype.hasOwnProperty.call(t,n.dataset)?t[n.dataset]:void 0;if(!Array.isArray(o))throw new S.ReportBindingError(`$.datasets.${n.dataset}`,"逐记录标签数据集缺失,应提供对象数组(允许空数组)");const a=new Set,i=r.maxPages??qe,s=Ut(e);let c=0,l=0;for(const[u,f]of o.entries()){if(xe(r.signal),!f||typeof f!="object"||Array.isArray(f))throw new S.ReportBindingError(`$.datasets.${n.dataset}[${u}]`,"标签记录应为对象",u);const d={rowIndex:u,dataset:n.dataset},m=Xe(n,f,d);if(m!==void 0){const b=JSON.stringify([typeof m,m]);if(a.has(b))throw new S.ReportBindingError(`$.datasets.${n.dataset}[${u}].${n.rowKey}`,"业务主键重复;请先确认记录来源,避免重复打印标签",u,n.rowKey);a.add(b)}const g=Ue(n,f,d);if(c+=g*e.pages.length,l+=g*s,c>i)throw new S.PaginatePageLimitError(i,c);if(l>Be)throw new S.ReportBindingError("$.repeat",`标签组件总量(含网格行、槽位及嵌套组件)超过安全预算 ${Be},请分批生成`,u)}return o}function Yt(e,t,r){if(!e.binding)return e;const{binding:n,...o}=e,a=S.resolveComponentBinding(n,t.row,t);if(e.kind==="image"){if(!a)return;if(!S.isLabelImageData(a))throw new S.ReportBindingError(`${r}.binding`,"图片字段只接受 PNG/JPEG base64 data URL;业务 URL 应由宿主安全加载后转换",t.rowIndex,n.field);return{...o,imageData:a}}return e.kind==="barcode"||e.kind==="qrcode"?(delete o.imageData,{...o,code:{...o.code,value:a},fallbackText:a}):(delete o.lines,delete o.richParagraphs,{...o,text:a})}function Qt(e,t,r){if(e.kind!=="text"||e.grid||e.richParagraphs?.length)return e;const n=e.style??{},o=E.resolveFontSize(n).fontSizePt,a=e.text??e.lines?.join(`
|
|
2
|
-
`)??"";if(a.length>16384)throw new S.ReportBindingError(r,"标签文本超过 16384 字符预算,请缩小字段内容",t.rowIndex);const i=t.wrapText(a,e.widthMm,{fontSizePt:o,bold:n.bold,italic:n.italic,fontFamily:n.fontFamily,letterSpacingPt:n.letterSpacing},t.options.measurer??A.heuristicMeasurer),s=i.length*o*E.resolveLineHeight(n)*25.4/72;if(s>e.heightMm+.05)throw new S.ReportBindingError(r,`标签文字需要约 ${s.toFixed(2)}mm 高,超出 ${e.heightMm}mm;请增大文本区域、减少内容或调整字号`,t.rowIndex,e.binding?.field);return{...e,lines:i}}function Ye(e,t,r){xe(t.options.signal);const n=Yt(e,t,r);if(!n)return;let o=n.grid;return o&&(o={...o,cells:o.cells.map((a,i)=>a.map((s,c)=>s?.children?.length?{...s,children:s.children.flatMap((l,u)=>{const f=Ye(l,t,`${r}.grid.cells.${i}.${c}.children.${u}`);return f?[f]:[]})}:s))}),Qt(o===n.grid?n:{...n,grid:o},t,r)}function Zt(e,t,r,n,o,a){return{...e,components:e.components.flatMap((i,s)=>{const c=Ye(i,r,`$.pages.${t}.components.${s}`);return c?[{...c,meta:{...c.meta,labelSource:{pageIndex:t,componentIndex:s}}}]:[]}),meta:{...e.meta,record:{dataset:r.dataset,rowIndex:r.rowIndex,...a===void 0?{}:{rowKey:a},copyIndex:n,copyCount:o,templatePageIndex:t}}}}function*er(e,t,r){const n=[];if(H.validateTemplateRepeat(e,n),n.length)throw new S.ReportBindingError(n[0].path,n[0].message);if(!e.repeat){for(const[s,c]of e.pages.entries())yield{page:c,pageIndex:s};return}const o=e.repeat,a=Xt(e,t,r),i=qt();for(const[s,c]of a.entries()){const l={row:c,rowIndex:s,dataset:o.dataset,options:r,wrapText:i},u=Ue(o,c,l),f=Xe(o,c,l);for(let d=0;d<u;d++)for(const[m,g]of e.pages.entries())xe(r.signal),yield{page:Zt(g,m,l,d,u,f),pageIndex:m}}}function tr(e){return{widthMm:e.widthMm,heightMm:e.heightMm,marginTopMm:e.marginTopMm??0,marginBottomMm:e.marginBottomMm??0,marginLeftMm:e.marginLeftMm??0,marginRightMm:e.marginRightMm??0,components:[]}}function ee(e,t){const r=t.heightMm-(e.layout==="wide"?t.marginBottomMm:e.marginBottomMm??t.marginBottomMm);return e.components.reduce((n,o)=>o.kind!=="list"&&o.pageAnchor==="footer"?Math.min(n,o.topMm):n,r)}function Y(e){return e.components.reduce((t,r)=>r.kind!=="list"&&r.pageAnchor==="header"?Math.max(t,r.topMm+r.heightMm):t,0)}function Qe(e,t){let r=e.textMetrics.get(t);if(!r){const n=E.resolveFontSize(t).fontSizePt;r={measureOptions:{fontSizePt:n,fontFamily:t.fontFamily??E.DEFAULT_FONT_FAMILY,italic:t.italic,bold:t.bold,letterSpacingPt:t.letterSpacing},lineMm:n*(t.lineHeight??E.LINE_HEIGHT)*25.4/72},e.textMetrics.set(t,r)}return r}function rr(e){if(e===null||typeof e=="string"||typeof e=="boolean"||typeof e=="number"&&Number.isFinite(e))return e}function Re(e,t,r=[],n){const o=e.fontSizePt??E.DEFAULT_FONT_PT,a=e.paddingMm??1,i=e.columns.map(y=>y.align??y.style?.align??e.align??"left"),s=e.columns.map((y,h)=>({...E.mergeComponentStyles({fontSize:o,verticalAlign:"middle"},y.style),align:i[h]==="auto"?"left":i[h]})),c=s.map((y,h)=>i[h]==="auto"?{left:y,center:{...y,align:"center"},right:{...y,align:"right"}}:void 0),l=e.columns.map((y,h)=>y.rules?.map(x=>{const T=c[h];if(T)return{left:E.mergeComponentStyles(T.left,x.style),center:E.mergeComponentStyles(T.center,x.style),right:E.mergeComponentStyles(T.right,x.style)};const I=E.mergeComponentStyles(s[h],x.style);return{left:I,center:I,right:I}})),u=e.columns.map(y=>S.resolveListHeaderStyle(e,y)),f=e.columns.map(y=>y.header);let d=e.rowHeightMm??0;for(let y=0;y<f.length;y++){const h=u[y],x=E.resolveFontSize(h).fontSizePt,T=A.wrapText(f[y],e.columns[y].widthMm-a*2,{fontSizePt:x,fontFamily:h.fontFamily??E.DEFAULT_FONT_FAMILY,italic:h.italic,bold:h.bold,letterSpacingPt:h.letterSpacing},t),I=x*(h.lineHeight??E.LINE_HEIGHT)*25.4/72;d=Math.max(d,Math.max(T.length,1)*I+a*2)}const m=f.map((y,h)=>({text:y,style:u[h]})),g=e.border===!1?{borderTop:!1,borderRight:!1,borderBottom:!1,borderLeft:!1}:{borderBottom:!0,borderLeft:!0,borderRight:!0,borderTop:!0},b=e.columns.map(y=>y.widthMm),w=nr(Vt(e,t),b,{cells:[m],colWidthsMm:b,rowHeightsMm:[d],paddingMm:a});return{fontSizePt:o,paddingMm:a,visuals:W.createColumnVisualResolvers(e.columns,r,n),visibility:e.columns.map(y=>y.visibleWhen?k.compileReportPredicate(y.visibleWhen):void 0),ruleReaders:e.columns.map(y=>y.rules?.map(h=>k.compileReportPredicate(h.when))),cellStyles:s,autoStyles:c,ruleStyles:l,textMetrics:new WeakMap,numberFormats:e.columns.map(y=>S.toExcelNumberFormat(y.format)),derivedFields:new Set(e.computed?.map(y=>y.field)),borderStyle:g,headerHeightMm:w.rowHeightsMm.reduce((y,h)=>y+h,0),headerGrid:w,colWidthsMm:b,columns:e.columns}}function nr(e,t,r){if(!e)return r;if(!e.cells.length)throw new Error("自定义列表表头至少需要一行");const n=e.rowHeightsMm??e.cells.map(()=>r.rowHeightsMm[0]);if(n.length!==e.cells.length||n.some(o=>!Number.isFinite(o)||o<=0))throw new Error("自定义列表表头行高无效");return{...e,colWidthsMm:t,rowHeightsMm:n}}function or(e,t,r){const n=t.format?.kind==="number"||t.format?.kind==="percent";t.valueType!==void 0?e.valueType=t.valueType:n&&(e.valueType="number"),t.editable!==void 0&&(e.editable=t.editable),(typeof e.value=="number"||e.value==null)&&r!==void 0&&(e.numberFormat=r)}function Q(e,t,r){const n=e.columns,o=e.tree?.rows.get(t);let a=e.rowHeightFloorMm;const i=new Array(n.length);for(let s=0;s<n.length;s++){const c=n[s],l=e.visibility[s]?.(t)!==!1,u=l?t[c.field]:null,f=e.autoStyles[s]?S.resolveListAutoAlignment(u,c.format,c.semanticRole):"left";let d=e.autoStyles[s]?.[f]??e.cellStyles[s];if(c.rules){for(let x=0;x<c.rules.length;x++)if(e.ruleReaders[s][x](t)){d=e.ruleStyles[s][x][f];break}}const m=c.format?S.formatValue(u,c.format):S.listCellText(u),g=ar(e,c,o);d=ir(e,c,d,o);const b=Qe(e,d),w=A.wrapText(m,Math.max(1,c.widthMm-e.paddingMm*2-g),b.measureOptions,r);a=Math.max(a,w.length*b.lineMm+e.paddingMm*2);const y=rr(u),h={text:m,style:d};u!=null&&e.visuals[s]?.apply(h,t),y!==void 0&&(h.value=y),or(h,c,e.numberFormats[s]),sr(h,c,e,o,g),e.derivedFields.has(c.field)&&(h.derived=!0,h.editable=!1),l||(h.editable=!1),i[s]=h}return{grid:{cells:[i],colWidthsMm:e.colWidthsMm,rowHeightsMm:[a],paddingMm:e.paddingMm},heightMm:a,...e.matrix?{meta:{matrix:{row:e.matrix.rows.get(t)}}}:{}}}function ar(e,t,r){return!r||t.field!==e.tree.list.tree.labelField?0:S.listTreeIndent(e.tree.list,t,r,e.paddingMm)}function ir(e,t,r,n){return!n||t.field!==e.tree.list.tree.labelField||r.align==="left"?r:{...r,align:"left"}}function sr(e,t,r,n,o=0){n&&(o&&(e.indentMm=o),S.applyListTreeMetadata(e,t,n,r.tree.list))}function Ze(e){if(e!=null&&typeof e!="string"&&typeof e!="boolean"&&!(typeof e=="number"&&Number.isFinite(e)))throw new Error("分组字段应为有限 JSON 标量");return JSON.stringify([typeof e,e??null])}function*et(e,t,r=0){const n=t[r];if(!n){for(const a of e)yield{kind:"row",row:a};return}const o=new Map;for(const a of e){const i=Ze(a[n.field]),s=o.get(i);s?s.push(a):o.set(i,[a])}for(const a of o.values())yield{kind:"groupHeader",label:(n.headerTemplate??"{value}").replace(/\{value\}/g,S.listCellText(a[0][n.field])),firstRow:a[0],group:n,depth:r,rows:a},yield*et(a,t,r+1),(n.subtotal?.length||n.aggregates?.length)&&(yield{kind:"subtotal",label:n.subtotalLabel??"小计",rows:a,group:n,depth:r}),yield{kind:"groupEnd",depth:r}}function tt(e,t,r,n=[]){const o=[...r.filter(a=>!n.some(i=>i.field===a)).map(a=>({field:a,op:"sum"})),...n];return new Map(o.map(a=>{const i=e.find(c=>c.field===a.field)?.format??{kind:"number",thousands:!0},s=k.aggregateRows(t,{...a,field:a.valueField??a.field});return[a.field,{text:S.formatValue(s,i),...s===null?{}:{value:s},...typeof s=="number"?{numberFormat:S.toExcelNumberFormat(i)}:{}}]}))}function rt(e,t){const r=e.findIndex(n=>t.includes(n.field));return r<0?1:r}function X(e,t,r,n,o,a){const i=[],s=Math.max(0,Math.min(a,e.columns.length)),c=E.mergeComponentStyles({fontSize:e.fontSizePt},o);s&&i.push({text:r,colSpan:s,style:{bold:!0,...c}});for(let d=s;d<e.columns.length;d++){const m=e.columns[d],g=n.get(m.field),b=e.autoStyles[d]?.[S.resolveListAutoAlignment(g?.value,m.format)]??e.cellStyles[d];i.push({...g,text:g?.text??"",style:E.mergeComponentStyles(b,o)})}const l={text:r,colSpan:e.columns.length,style:{bold:!0,...c}},u=s?[i]:[[l],i],f=u.map(d=>cr(e,d,t));return{grid:{cells:u,colWidthsMm:e.colWidthsMm,rowHeightsMm:f,paddingMm:e.paddingMm},heightMm:f.reduce((d,m)=>d+m,0)}}function cr(e,t,r){let n=e.rowHeightFloorMm,o=0;for(const a of t){let i=0;const s=o+(a.colSpan??1);for(;o<s;o++)i+=e.colWidthsMm[o]??0;const c=Qe(e,a.style),l=A.wrapText(a.text??"",i-e.paddingMm*2,c.measureOptions,r);n=Math.max(n,l.length*c.lineMm+e.paddingMm*2)}return n}function lr(e,t,r){const{templatePage:n,current:o,warnings:a,nextId:i,pushCurrent:s}=r,c=()=>ee(n,o),l=Math.max(o.marginTopMm,Y(n)),u=n.layout==="wide"?Y(n):l,f={id:r.tableId,columnKeys:e.columns.map(p=>p.field),...e.layout===void 0?{}:{layout:e.layout},...e.title===void 0?{}:{title:e.title}},d=new Map,m=new Map,g={kind:"rect",leftMm:e.leftMm,topMm:0,widthMm:e.widthMm,heightMm:t.headerHeightMm,grid:t.headerGrid,nid:i("listh"),table:{...f,role:"header",rowIndex:-1},style:t.borderStyle,...e.meta||t.matrix?{meta:{...e.meta,...t.matrix?{matrix:t.matrix.header}:{}}}:{}},b=p=>o.components.push({...g,topMm:p});if(r.flow&&e.header!==!1&&t.headerHeightMm>c()-l+.001)throw new Error(`流式列表 ${e.id??e.dataset} 的表头高度超出单页可用范围`);let w=Math.max(r.startTop??e.topMm,l);e.header!==!1&&(b(w),w+=t.headerHeightMm+r.mmPerRow);function y(){const p=Math.max(r.flow||n.layout==="wide"?0:e.topMm,u);return(e.header!==!1&&e.headerEveryPage!==!1?p+t.headerHeightMm:u)+[...m.values()].reduce((R,$)=>R+$.heightMm,0)}function h(){const p=n.layout==="wide"?0:o.marginBottomMm;return Math.min(n.heightMm-p,ee(n,o))-y()}function x(p){if(w+p<=c())return;s(),o.components=[],o.heightMm=n.heightMm,n.layout==="wide"&&(o.marginTopMm=0,o.marginBottomMm=0);const C=Math.max(r.flow||n.layout==="wide"?0:e.topMm,u);e.header!==!1&&e.headerEveryPage!==!1?(b(C),w=C+t.headerHeightMm):w=u;for(const R of m.values())I(R,"listgr","group-header")}function T(p,C,R,$){const v=h();if(r.flow&&p.heightMm>v+.001)throw new Error(`流式列表 ${e.id??e.dataset} 的单行高度超出单页可用范围`);p.heightMm>v&&a.push(`列表 ${e.id??e.dataset} 行高 ${p.heightMm.toFixed(2)}mm 超出单页可用高度 ${v.toFixed(2)}mm,预览与打印可能截断内容`),x(p.heightMm),I(p,C,R,$)}function I(p,C,R,$){const v=p.table?.id??f.id,F=R==="header"?-1:d.get(v)??0;R!=="header"&&d.set(v,F+p.grid.cells.length),o.components.push({kind:"rect",leftMm:e.leftMm,topMm:w,widthMm:e.widthMm,heightMm:p.heightMm,grid:p.grid,nid:i(C),table:{...f,...p.table,role:R,rowIndex:F,...$?{source:$}:{}},style:t.borderStyle,...e.meta||p.meta?{meta:{...e.meta,...p.meta}}:{}}),w+=p.heightMm}function L(p){p<=h()&&x(p)}return{keepTogether:L,placeGridRow:T,setGroupHeader:(p,C)=>{C?m.set(p,C):m.delete(p)},bottom:()=>w}}function dr(e,t){if(!e.rowKey)return;const r=t[e.rowKey];if((typeof r!="string"||!r.trim())&&!(typeof r=="number"&&Number.isFinite(r)))throw new Error(`数据集 ${e.dataset} 的 ${e.rowKey} 应为稳定的字符串或有限数字主键`);const n=e.revisionField?t[e.revisionField]:void 0,o=e.sourceTokenField?t[e.sourceTokenField]:void 0;if(n!==void 0&&typeof n!="string"&&!(typeof n=="number"&&Number.isFinite(n)))throw new Error("业务修订号应为字符串或有限数字");if(o!==void 0&&typeof o!="string")throw new Error("来源令牌应为字符串");return{datasetId:e.dataset,rowKey:r,...n===void 0?{}:{revision:n},...o===void 0?{}:{sourceToken:o}}}function oe(e,t){const r=new Map;if(!e.rowKey)return r;const n=new Set;for(const o of t){const a=dr(e,o),i=JSON.stringify(a.rowKey);if(n.has(i))throw new Error(`数据集 ${e.dataset} 的业务主键重复:${String(a.rowKey)}`);n.add(i),r.set(o,a)}return r}function ur(e,t,r,n,o){if(!e.grandTotal)return;const a=typeof e.grandTotal=="object"?e.grandTotal:void 0,i=ae(e)[0],s=a?.fields??i?.subtotal??[],c=a?.aggregates??i?.aggregates??[];if(s.length===0&&c.length===0){n.warnings.push(`列表 ${e.id??""} 配置了 grandTotal 但未提供合计字段(groupBy.subtotal 或 grandTotal.fields)`);return}const l=X(r,n.measurer,a?.label??"合计",tt(e.columns,t,s,c),a?.style??{},rt(e.columns,[...s,...c.map(u=>u.field)]));o.placeGridRow(l,"listgt","grand-total")}function B(e){if(e?.aborted){const t=new Error("报表排版已取消");throw t.name="AbortError",t}}function ae(e){const t=e.groups??(e.groupBy?[e.groupBy]:[]);if(t.length>16)throw new Error("列表最多支持 16 级分组");return t}function Ce(e){const t=Je(e),r=t.columns.reduce((o,a)=>o+a.widthMm,0),n=r>t.widthMm?t.widthMm/r:1;return n===1?t:{...t,columns:t.columns.map(o=>({...o,widthMm:o.widthMm*n}))}}function fr(e,t,r){const n=e.detail;if(!n)return;const o=new Set;for(const l of t){const u=ge(l[n.parentKey]);if(o.has(u))throw new Error("主从明细的主表关联键重复");o.add(u)}const a=r.datasets[n.dataset]??[],i=new Map,s=[];for(const l of a){const u=l[n.foreignKey];if(!nt(u)&&n.unmatched==="ignore")continue;const f=ge(u);if(!o.has(f)){if(n.unmatched!=="ignore")throw new Error(`明细数据集 ${n.dataset} 存在未关联的业务键`);continue}const d=i.get(f);d?d.push(l):i.set(f,[l]),s.push(l)}const c=Ce({...e,id:`${e.id??e.dataset}:detail`,dataset:n.dataset,rowKey:n.rowKey,revisionField:n.revisionField,sourceTokenField:n.sourceTokenField,computed:void 0,columns:n.columns,headerGrid:void 0,rowHeightMm:n.rowHeightMm??e.rowHeightMm,detail:void 0});return{list:c,inter:{...Re(c,r.measurer,s,r.signal),rowHeightFloorMm:c.rowHeightMm??0},rows:i,sources:oe(c,s)}}function nt(e){return typeof e=="string"&&!!e.trim()||typeof e=="number"&&Number.isFinite(e)}function ge(e){if(!nt(e))throw new Error("主从关联键必须是非空字符串或有限数字");return Ze(e)}function*mr(e,t,r,n,o){if(!r)return;const a=r.rows.get(ge(t[e.detail.parentKey]))??[];if(!a.length)return;const i={id:`${n.tableId}:detail`,columnKeys:r.list.columns.map(s=>s.field),title:e.detail.label};e.detail.label&&o.placeGridRow({...X(r.inter,n.measurer,e.detail.label,new Map,{},r.list.columns.length),table:i},"listdl","group-header"),e.detail.header!==!1&&o.placeGridRow({grid:r.inter.headerGrid,heightMm:r.inter.headerHeightMm,table:i},"listdh","header"),yield*n.takePages();for(const s of a)B(n.signal),o.placeGridRow({...Q(r.inter,s,n.measurer),table:i},"listdr","body",r.sources.get(s)),yield*n.takePages()}function ot(e){if(e.matrix||e.detail||e.groups?.length||e.groupBy||e.rowVisibleWhen)throw new Error("树形布局不能同时配置普通分组、矩阵、主从或行可见条件");if(e.rowKey&&e.rowKey!==e.tree.idField)throw new Error("树形布局的 rowKey 应与 idField 一致");if(!e.columns.some(t=>t.field===e.tree.labelField&&!t.hidden))throw new Error("树形布局需要可见的标签列");W.validateTreeComputed(e.tree,e.computed)}function gr(e,t,r){ot(e);const n=W.createTreeTable(t,e.tree,{signal:r.signal,computed:e.computed?.length?{fields:e.computed,formula:r.formula}:void 0}),o={...e,rowKey:e.tree.idField},a=oe(o,n.entries.map(c=>c.original)),i=new Map,s=new WeakMap;for(const c of n.entries)i.set(c.row,a.get(c.original)),s.set(c.row,c);return{list:o,rows:n.rows,sources:i,treeRows:s,totalRows:n.leaves}}function hr(e,t){if(e.cardinality==="record"){if(t.length>1)throw new Error(`单记录区域 ${e.id??e.dataset} 仅允许 0 或 1 行数据`);if(e.tree||e.matrix||e.detail||e.groups?.length||e.groupBy||e.grandTotal||e.rowVisibleWhen)throw new Error("单记录区域不能配置树、矩阵、主从、分组、总计或行过滤");if(!t.length)return{list:{...e,columns:e.columns.map(r=>({...r,editable:!1}))},rows:[{}],sources:new Map}}}function at(e,t,r){const n=r.prepared.get(e);if(n)return n;const o=hr(e,t);if(o)return r.prepared.set(e,o),o;if(e.tree){const c=gr(e,t,r);return r.prepared.set(e,c),c}let a=e.computed?.length?k.computeDataset(t,{fields:e.computed,signal:r.signal,formula:r.formula}).rows:t;const i=a===t?void 0:new Map(a.map((c,l)=>[c,t[l]]));e.rowVisibleWhen&&(a=a.filter(k.compileReportPredicate(e.rowVisibleWhen)));const s=Gt(e,a);if(!e.matrix){const c=oe(e,i?a.map(l=>i.get(l)):a);s.sources=i?new Map(a.map(l=>[l,c.get(i.get(l))])):c}return r.prepared.set(e,s),s}function pr(e,t,r,n){if(!n.flow)return;const{current:o,templatePage:a}=n,i=Math.max(o.marginTopMm,Y(a)),s=Math.max(n.startTop??e.topMm,i),c=(e.header===!1?0:t.headerHeightMm)+(r[0]?Q(t,r[0],n.measurer).heightMm:0);s+c<=ee(a,o)+.001||s<=i+.001||(n.pushCurrent(),o.components=[],o.heightMm=a.heightMm,a.layout==="wide"&&(o.marginTopMm=0,o.marginBottomMm=0),n.startTop=Math.max(o.marginTopMm,Y(a)))}function*wr(e,t,r){const n=at(e,t,r),o=n.rows;e=n.list,e.layout==="wide"&&(r.current.widthMm=Math.max(r.current.widthMm,e.leftMm+e.widthMm+r.current.marginRightMm));const a=n.sources??oe(e,o),i=Ce(e),s=ae(i),c={...Re(i,r.measurer,o,r.signal),rowHeightFloorMm:i.rowHeightMm??0,matrix:n.matrix,...n.treeRows?{tree:{list:i,rows:n.treeRows}}:{}};pr(i,c,o,r);const l=lr(i,c,r),u=fr(i,o,r);let f;for(const d of et(o,s)){if(B(r.signal),d.kind==="row")l.placeGridRow(f??Q(c,d.row,r.measurer),"listr",Bt(n.matrix,d.row),a.get(d.row)),f=void 0,yield*r.takePages(),yield*mr(i,d.row,u,r,l);else if(d.kind==="groupHeader"){const m=X(c,r.measurer,d.label,new Map,d.group.headerStyle??{},i.columns.length);f??=Q(c,d.firstRow,r.measurer);const g=s.slice(d.depth+1).reduce((b,w)=>b+X(c,r.measurer,(w.headerTemplate??"{value}").replace(/\{value\}/g,S.listCellText(d.firstRow[w.field])),new Map,w.headerStyle??{},i.columns.length).heightMm,0);d.group.keepWithNext!==!1&&l.keepTogether(m.heightMm+g+f.heightMm),l.placeGridRow(m,"listg","group-header"),d.group.repeatHeader&&l.setGroupHeader(d.depth,m)}else if(d.kind==="subtotal"){const m=d.group.subtotal??[],g=d.group.aggregates??[],b=X(c,r.measurer,d.label,tt(i.columns,d.rows,m,g),d.group.subtotalStyle??{},rt(i.columns,[...m,...g.map(w=>w.field)]));l.placeGridRow(b,"listst","subtotal")}else l.setGroupHeader(d.depth);yield*r.takePages()}ur(i,n.totalRows??o,c,r,l),r.finished?.(l.bottom()),yield*r.takePages()}function ie(e){return e.kind!=="list"&&(e.pageAnchor!==void 0||e.kind==="text"&&typeof e.text=="string"&&(e.text.includes("{page}")||e.text.includes("{totalPages}")))}function se(e,t){return{...e,...e.text===void 0?{}:{text:t(e.text)},...e.lines?{lines:e.lines.map(t)}:{},...e.richParagraphs?{richParagraphs:e.richParagraphs.map(r=>({...r,segments:r.segments.map(n=>({...n,...n.text===void 0?{}:{text:t(n.text)}}))}))}:{},...e.grid?{grid:{...e.grid,cells:e.grid.cells.map(r=>r.map(n=>n?{...n,...n.text===void 0?{}:{text:t(n.text)},...n.children?{children:n.children.map(o=>se(o,t))}:{}}:null))}}:{}}}function yr(e){let t=!1;for(const r of e.pages)for(const n of r.components)ie(n)&&se(n,o=>(o.includes("{totalPages}")&&(t=!0),o));return t}function br(e,t,r,n,o,a){const i={pageWidthMm:t.widthMm,pageHeightMm:t.heightMm,...e.layout===void 0?{}:{layout:e.layout},marginTopMm:t.marginTopMm,marginBottomMm:t.marginBottomMm,marginLeftMm:t.marginLeftMm,marginRightMm:t.marginRightMm,components:t.components,...e.meta?{meta:e.meta}:{}},s=c=>{const l=c.replace(/\{page\}/g,String(n));return a===void 0?l:l.replace(/\{totalPages\}/g,String(a))};for(const c of r)i.components.push(se(c,s));if(e.layout==="wide"){const c=i.components.reduce((l,u)=>Math.max(l,u.topMm+u.heightMm),0);i.marginBottomMm=o?e.marginBottomMm??0:0,i.pageHeightMm=Math.max(1,c+i.marginBottomMm)}return i}function Ee(e){return e.cells.reduce((t,r)=>t+r.reduce((n,o)=>n+(o?1+(o.children?.reduce((a,i)=>a+it(i),0)??0):0),0),0)}function it(e){return e.grid?Ee(e.grid):0}function ce(e){for(const t of["maxPages","maxCells","knownTotalPages"])if(e[t]!==void 0&&(!Number.isSafeInteger(e[t])||e[t]<1))throw new RangeError(`${t} 应为正安全整数`);S.validateChartComponentLimit(e.maxChartComponents)}function vr(e,t){const r=at(e,t.datasets[e.dataset]??[],t),n=Ce(r.list),o={...Re(n,t.measurer,r.rows,t.signal),rowHeightFloorMm:n.rowHeightMm??0};return(n.header===!1?0:o.headerHeightMm)+r.rows.reduce((a,i)=>a+Q(o,i,t.measurer).heightMm,0)}function*Mr(e){const{templatePage:t,current:r}=e,n=new Map(t.components.map((a,i)=>[a,i])),o=(a,i,s)=>{const c=e.datasets[a.dataset];return Array.isArray(c)||e.warnings.push(`数据集 ${a.dataset} 未提供数据,列表 ${a.id??""} 输出为空`),wr(a,Array.isArray(c)?c:[],{...e,tableId:`${e.tableId}:${n.get(a)}`,startTop:i,finished:s,flow:!!t.flow})};if(t.flow){yield*_t({page:t,active:()=>B(e.signal),top:()=>Math.max(r.marginTopMm,Y(t)),bottom:()=>ee(t,r),append:a=>{r.components.push(...e.resolveChart(a))},nextPage:()=>{e.pushCurrent(),r.components=[],r.heightMm=t.heightMm,t.layout==="wide"&&(r.marginTopMm=0,r.marginBottomMm=0)},takePages:e.takePages,height:a=>vr(a,e),list:o});return}for(const a of t.components)ie(a)||(a.kind==="list"?yield*o(a):r.components.push(...e.resolveChart(a)))}function*Z(e,t,r,n,o,a=new WeakMap,i){let s=0,c=0,l=0;const u=Dt(r.measurer??A.heuristicMeasurer),f=S.createChartResolver(t,r.signal,r.maxChartComponents),d=m=>`${m}_${(++s).toString(36)}`;for(const{pageIndex:m,page:g}of er(e,t,r)){B(r.signal);const b=tr(g),w=g.components.filter(ie);let y=[];const h=(T=!1)=>{if(B(r.signal),r.maxPages!==void 0&&c>=r.maxPages)throw new S.PaginatePageLimitError(r.maxPages,c+1);if(r.maxCells!==void 0&&(l+=[...b.components,...w].reduce((I,L)=>I+it(L),0),l>r.maxCells))throw new S.PaginateCellLimitError(r.maxCells,l);y.push(br(g,b,w,++c,T,o))},x=()=>{const T=y;return y=[],T};yield*Mr({templatePage:g,current:b,warnings:n,nextId:d,pushCurrent:h,takePages:x,datasets:t,resolveChart:f,signal:r.signal,formula:r.formula,prepared:a,measurer:u,mmPerRow:r.mmPerRow??0,tableId:`table:${m}`}),h(!0),yield*x()}i&&(i.chartComponents=f.used())}function Sr(e,t,r={}){ce(r);let n=0;for(const o of Z(e,t,{...r,onWarning:void 0},[]))n++;return n}function*xr(e,t,r={}){yield*Rr(e,t,r)}function*Rr(e,t,r,n){ce(r);const o=yr(e),a=new WeakMap;let i=r.knownTotalPages;if(o&&i===void 0){i=0;for(const l of Z(e,t,r,[],void 0,a))i++}const s=[];let c=0;for(const l of Z(e,t,r,s,i,a,n)){for(;c<s.length;c++)r.onWarning?.(s[c]);yield l}}function Pe(e,t,r={}){const n=typeof r=="number"?{mmPerRow:r}:r;ce(n);const o=[],a={chartComponents:0},i=[...Z(e,t,n,o,n.knownTotalPages,void 0,a)];return ct(e,n,i,o,a)}async function st(e,t,r={}){ce(r),B(r.signal);const n=[],o=[],a={chartComponents:0};let i=performance.now(),s=0;for(const c of Z(e,t,r,n,r.knownTotalPages,void 0,a))o.push(c),(++s>=8||performance.now()-i>=8)&&(await new Promise(l=>setTimeout(l,0)),B(r.signal),i=performance.now(),s=0);return B(r.signal),ct(e,r,o,n,a)}function ct(e,t,r,n,o){for(const a of r)a.components=a.components.map(i=>ie(i)?se(i,s=>s.replace(/\{totalPages\}/g,String(r.length))):i);return n.forEach(a=>t.onWarning?.(a)),{plan:{schemaVersion:E.RENDER_PLAN_SCHEMA_VERSION,...Se(e)?{requiresRecalculation:!0}:{},pages:r},warnings:n,...o}}function Cr(e){const t=e.columns.find(a=>!a.hidden)?.field;if(!t)return{groups:0,total:0};const r=ae(e),n=(a=[],i=[])=>a.includes(t)||i.some(s=>s.field===t),o=typeof e.grandTotal=="object"?e.grandTotal:void 0;return{groups:r.filter(a=>n(a.subtotal,a.aggregates)).length,total:Number(n(o?.fields??r[0]?.subtotal,o?.aggregates??r[0]?.aggregates))}}function Er(e,t,r){ot(e);const n=W.flattenTreeInput(t[e.dataset]??[],e.tree,r),o=e.columns.filter(i=>!i.hidden).length,a=e.header===!1?0:e.headerGrid?Ee(e.headerGrid):o;return n.length*o+a+ +!!e.grandTotal*2*o}function Pr(e,t,r={}){if(e.tree)return Er(e,t,r.signal);if(e.matrix){let c=t[e.dataset]??[];e.computed?.length&&(c=k.computeDataset(c,{fields:e.computed,...r}).rows),e.rowVisibleWhen&&(c=c.filter(k.compileReportPredicate(e.rowVisibleWhen)));const l=_e.estimateMatrixTable(c,e.matrix);return l.cells+(e.header===!1?0:l.columnCount*(e.matrix.hierarchy?e.matrix.columnFields.length+1:1))}const n=t[e.dataset]?.length??0,o=e.columns.filter(c=>!c.hidden).length,a=ae(e).length,i=Cr(e);let s=(n*(1+2*a+i.groups)+ +!!e.grandTotal*(1+i.total))*o;if(s+=e.header===!1?0:e.headerGrid?Ee(e.headerGrid):o,e.cardinality==="record"&&n===0&&(s+=o),e.detail){const c=t[e.detail.dataset]?.length??0,l=e.detail.columns.filter(u=>!u.hidden).length;s+=(c+n*(+(e.detail.header!==!1)+ +!!e.detail.label))*l}if(!Number.isSafeInteger(s))throw new RangeError("报表单元格估算超出安全整数预算");return s}class lt extends Error{constructor(t){super(t.map(r=>r.message).join(";")),this.issues=t,this.name="ReportValidationError"}}function He(e,t,r){if(!Number.isSafeInteger(e)||e<1||e>r)throw new Error(`校验 ${t} 超出预算`);return e}function Tr(e){if(e.aggregates&&e.scope!=="dataset")throw new Error("仅数据集规则允许汇总");if(e.aggregates&&(!Array.isArray(e.aggregates)||e.aggregates.length>64))throw new Error("校验汇总最多 64 项");const t=new Set;for(const r of e.aggregates??[]){if(k.computationFieldName(r.field),t.has(r.field))throw new Error("校验汇总字段重复");t.add(r.field),r.valueField!==void 0&&k.computationFieldName(r.valueField),r.weightField!==void 0&&k.computationFieldName(r.weightField),k.aggregateRows([],{...r,field:r.valueField??r.field})}}function dt(e){if(!Array.isArray(e)||e.length>256||Object.keys(e).length!==e.length)throw new Error("校验规则最多 256 条且不允许空位");const t=new Set;return e.map(r=>{if(!r||typeof r!="object")throw new Error("校验规则应为声明式对象");if(k.computationFieldName(r.id),t.has(r.id))throw new Error("校验规则 id 重复");if(t.add(r.id),r.field!==void 0&&k.computationFieldName(r.field),r.dataset!==void 0&&k.computationFieldName(r.dataset),typeof r.message!="string"||!r.message.trim()||r.message.length>2048)throw new Error("校验规则需要有界提示文案");if(r.severity!==void 0&&!["error","warning"].includes(r.severity))throw new Error("未知校验严重程度");if(r.scope!==void 0&&!["row","dataset"].includes(r.scope))throw new Error("未知校验范围");Tr(r);const n={nodes:0},o=k.compileReportPredicate(r.assert,n),a=r.when?k.compileReportPredicate(r.when,n):void 0;return{rule:r,assert:o,when:a,checks:n.nodes}})}function Ge(e){if(e?.aborted){const t=new Error("报表校验已取消");throw t.name="AbortError",t}}function kr(e,t,r,n){const o=n&&Object.prototype.hasOwnProperty.call(t,n)?t[n]:void 0;if(o!==void 0&&typeof o!="string"&&!(typeof o=="number"&&Number.isFinite(o)))throw new Error("校验定位需要稳定的文本或数值业务键");return{ruleId:e.id,rowIndex:r,...o===void 0?{}:{rowKey:o},field:e.field,severity:e.severity??"error",message:e.message}}function Ir(e,t){const r=t.computed?.length?{fields:t.computed,formula:t.formula,signal:t.signal}:void 0;if(t.tree){const o=W.createTreeTable(e,t.tree,{signal:t.signal,computed:r});if(o.rows.length>1e5)throw new Error("校验展开后数据最多 100000 行");return{rows:o.rows,summaryRows:o.leaves,rowKey:t.tree.idField}}const n=r?k.computeDataset(e,r).rows:e;return{rows:n,summaryRows:n,rowKey:t.rowKey}}function Fr(e,t){const r=new Set;e.forEach(n=>{if(!n||typeof n!="object"||Array.isArray(n))throw new Error("校验数据行应为对象");if(!t)return;const o=Object.prototype.hasOwnProperty.call(n,t)?n[t]:void 0;if(!(typeof o=="string"&&o.trim())&&!(typeof o=="number"&&Number.isFinite(o)))throw new Error("校验定位需要稳定业务键");if(r.has(o))throw new Error("校验业务键重复");r.add(o)})}function $r(e,t){return ut(e,t,{checks:0})}function ut(e,t,r){if(!Array.isArray(e)||e.length>1e5)throw new Error("校验数据最多 100000 行");Ge(t.signal);const n=He(t.maxChecks??2e6,"maxChecks",1e7),o=He(t.maxIssues??1e3,"maxIssues",1e4);t.rowKey!==void 0&&k.computationFieldName(t.rowKey);const a=Ir(e,t),{rows:i,summaryRows:s,rowKey:c}=a;Fr(i,c);const l=dt(t.rules),u=l.reduce((d,m)=>d+(m.rule.scope==="dataset"?m.checks+s.length*(m.rule.aggregates?.length??0):i.length*m.checks),0);if(r.checks+=u,r.checks>n)throw new Error("整批校验超出 maxChecks 预算");const f=[];for(const d of l)(d.rule.scope==="dataset"?[Object.fromEntries((d.rule.aggregates??[]).map(g=>[g.field,k.aggregateRows(s,{...g,field:g.valueField??g.field})]))]:i).forEach((g,b)=>{if(Ge(t.signal),!g||typeof g!="object"||Array.isArray(g))throw new Error("校验数据行应为对象");if(!(d.when&&!d.when(g)||d.assert(g))){if(f.length>=o)throw new Error("校验问题超出 maxIssues 预算,请缩小范围");f.push(kr(d.rule,g,d.rule.scope==="dataset"?void 0:b,d.rule.scope==="dataset"?void 0:c))}});return f}function ft(e,t="allow"){if(!["allow","block"].includes(t))throw new Error("未知校验警告策略");if(!Array.isArray(e)||e.length>1e4||e.some(r=>!r||!["error","warning"].includes(r.severity)||typeof r.ruleId!="string"||!r.ruleId.trim()||typeof r.message!="string"||!r.message.trim()))throw new Error("校验问题结构无效");if(e.some(r=>r.severity==="error"||t==="block"))throw new lt(e)}function Ve(e,t,r){const n=e.get(t);if(n&&JSON.stringify(n)!==JSON.stringify(r))throw new Error("同一数据集的校验计算/业务键存在歧义,请统一绑定");e.set(t,r)}function Or(e,t,r,n=[]){dt(t.rules);const o=[],a={checks:0};for(const[s,c]of e.entries()){const l=new Map;for(const u of c.template.pages)for(const f of u.components)f.kind==="list"&&(Ve(l,f.dataset,{rowKey:f.tree?.idField??f.rowKey,computed:f.computed,tree:f.tree}),f.detail&&Ve(l,f.detail.dataset,{rowKey:f.detail.rowKey}));for(const[u,f]of l){const d=t.rules.filter(m=>!m.dataset||m.dataset===u);if(d.length&&(o.push(...ut(c.datasets[u]??[],{...t,rules:d,...f,formula:n[s],signal:r},a).map(m=>({...m,dataset:u,sourceScope:c.sourceScope}))),o.length>(t.maxIssues??1e3)))throw new Error("整批候选校验问题超出 maxIssues 预算")}}const i=new Set(e.flatMap(s=>s.template.pages.flatMap(c=>c.components.flatMap(l=>l.kind==="list"?[l.dataset,...l.detail?[l.detail.dataset]:[]]:[]))));if(t.rules.some(s=>s.dataset&&!i.has(s.dataset)))throw new Error("校验目标数据集不存在");return o}function mt(e){return!e||typeof e!="object"?!1:[e.pageIndex,e.componentIndex,e.rowIndex,e.columnIndex].every(t=>Number.isInteger(t)&&t>=0)}function gt(e,t,r){const n=e.grid;if(!n)return null;const o=n.cells[t];if(!o)return null;const i=E.resolveGridLayout(n,e.widthMm,e.heightMm).cells.filter(c=>c.ri===t).findIndex(c=>c.ci===r),s=o[i];return s?{cell:s,sourceColumnIndex:i}:null}function Ar(e){return e.value!==void 0?e.value:e.rawText??e.text??null}function Nr(e,t){return e.valueType?e.valueType:typeof t=="number"?"number":typeof t=="boolean"?"boolean":t===null&&e.numberFormat&&/[0#?]/.test(e.numberFormat)?"number":"text"}function Lr(e,t){if(e.derived)return"derived";if(e.editable===!1)return"cell";if(e.formula!==void 0)return"formula";if(e.children?.length||e.richParagraphs?.length)return"complex";if(t.table&&t.table.role!=="body"&&e.editable!==!0)return"structure"}function Kr(e,t){const r=e.table;if(r)return{id:r.id,rowIndex:r.rowIndex+t.rowIndex,role:r.role,columnKey:r.columnKeys[t.columnIndex]}}function jr(e,t,r){if(e.derived)return;if(e.source)return{...e.source};const n=t.table?.source,o=t.table?.columnKeys[r.columnIndex];if(!(!n||n.rowKey===void 0||o===void 0))return{...n,rowKey:n.rowKey,field:o}}function he(e,t,r){const n=Ar(r),o=Lr(r,e);return{address:{...t},cell:r,component:e,value:n,valueType:Nr(r,n),table:Kr(e,t),source:jr(r,e,t),editable:o===void 0,readOnlyReason:o}}function le(e,t){if(!mt(t))return null;const r=e.pages[t.pageIndex]?.components[t.componentIndex];if(!r)return null;const n=gt(r,t.rowIndex,t.columnIndex);return n?he(r,t,n.cell):null}function ht(e,t=!0){const r=new Map;function n(s){if(!s.grid)return;let c=r.get(s);if(!c){const l=E.resolveGridLayout(s.grid,s.widthMm,s.heightMm),u=new Map,f=new Map;for(const d of l.cells){const m=u.get(d.ri)??0;u.set(d.ri,m+1);const g=s.grid.cells[d.ri]?.[m];g&&f.set(`${d.ri}:${d.ci}`,g)}c={layout:t?l:void 0,cells:f},r.set(s,c)}return c}function o(s){if(!mt(s))return null;const c=e.pages[s.pageIndex]?.components[s.componentIndex];if(!c)return null;const l=n(c)?.cells.get(`${s.rowIndex}:${s.columnIndex}`);return l?he(c,s,l):null}function*a(s,c){const l=e.pages[s]?.components[c],u=l&&n(l);if(u)for(const f of i(l).cells){const d=u.cells.get(`${f.ri}:${f.ci}`);d&&(yield he(l,{pageIndex:s,componentIndex:c,rowIndex:f.ri,columnIndex:f.ci},d))}}function i(s){const c=n(s);return c&&(c.layout??E.resolveGridLayout(s.grid,s.widthMm,s.heightMm))}return{resolve:o,entries:a,layout:i}}function V(e){return ht(e,!1).resolve}class M extends Error{constructor(t){super(`Invalid report cell edit: ${t}`),this.code=t,this.name="ReportCellEditError"}}function Dr(e,t){let r=e.trim();const n=t&&r.endsWith("%");if(n&&(r=r.slice(0,-1).trim()),/^[+-]?\d{1,3}(?:,\d{3})+(?:\.\d*)?(?:[eE][+-]?\d+)?$/.test(r)&&(r=r.replace(/,/g,"")),!/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/.test(r))throw new M("number");return Number(r)/(n?100:1)}function Br(e,t){if(e===null||typeof e=="string"&&e.trim()==="")return null;if(typeof e!="string"&&typeof e!="number")throw new M("number");const r=typeof e=="number"?e:Dr(e,ze.isExcelPercentageFormat(t.cell.numberFormat));if(!Number.isFinite(r)||Number.isInteger(r)&&!Number.isSafeInteger(r))throw new M("number");return r}function Hr(e){if(e===null||typeof e=="string"&&e.trim()==="")return null;if(typeof e=="boolean")return e;const t=String(e).trim().toLowerCase();if(["true","yes","是","1"].includes(t))return!0;if(["false","no","否","0"].includes(t))return!1;throw new M("boolean")}function Te(e,t){return e.valueType==="number"?Br(t,e):e.valueType==="boolean"?Hr(t):t===null?null:String(t)}function Gr(e,t){const r=t.cell.text,o=[["是","否"],["TRUE","FALSE"],["True","False"],["true","false"],["1","0"]].find(a=>a.includes(r??""));return o?o[e?0:1]:String(e)}function _(e,t){return t===null?"":typeof t=="boolean"?Gr(t,e):typeof t=="number"?ze.formatExcelNumber(t,e.cell.numberFormat):String(t)}function Vr(e,t,r){const n=le(e,t);if(!n)throw new M("missing");return z(n,r)}function z(e,t){if(!e.editable)throw new M("readonly");const r=Te(e,t);return{address:{...e.address},table:e.table,source:e.source,previousValue:e.value,previousText:e.cell.text??"",value:r,text:_(e,r)}}function Wr(e,t){const r=e.table,n=t.table;return!r||!n||r.columnKey===void 0?!1:r.id===n.id&&r.rowIndex===n.rowIndex&&r.role===n.role&&r.columnKey===n.columnKey}function pt(e,t,r){const n=e.grid,{rowIndex:o,columnIndex:a}=t.address,i=gt(e,o,a),s=[...n.cells],c=[...s[o]],l=_(t,r.value),u={...i.cell,value:r.value,text:l,rawText:l};return c[i.sourceColumnIndex]=u,s[o]=c,{...e,grid:{...n,cells:s}}}function _r(e,t){const r=e.table?.columnKeys,n=t.table?.columnKey;return r&&n!==void 0?r.flatMap((o,a)=>o===n?[a]:[]):[]}function zr(e,t,r,n,o,a){const i=t.table,s=o.table;if(!i||!s||i.id!==s.id||i.role!==s.role||!t.grid)return t;const c=s.rowIndex-i.rowIndex;if(c<0||c>=t.grid.cells.length)return t;let l=t;for(const u of _r(t,o)){const f=le(e,{pageIndex:r,componentIndex:n,rowIndex:c,columnIndex:u});f?.editable&&Wr(o,f)&&(l=pt(l,f,a))}return l}function Jr(e,t,r,n,o,a){const i=o.address;return o.table?.columnKey!==void 0?zr(e,t,r,n,o,a):i.pageIndex===r&&i.componentIndex===n?pt(t,o,a):t}function de(e,t){const r=t.source;if(!r)return!1;const n=e.source;return!n||["sourceScope","datasetId","rowKey","field","revision","sourceToken"].some(o=>!Object.is(n[o],r[o]))}function qr(e,t){const r=le(e,t.address);if(!r)throw new M("missing");if(!r.editable)throw new M("readonly");if(de(r,t))throw new M("conflict");if(!Object.is(r.value,t.previousValue)||(r.cell.text??"")!==t.previousText)throw new M("conflict");const n=Te(r,t.value),o={...t,value:n,text:_(r,n)};if(Object.is(n,r.value)&&o.text===r.cell.text)return e;const a=e.pages.map((i,s)=>{const c=i.components.map((l,u)=>Jr(e,l,s,u,r,o));return c.every((l,u)=>l===i.components[u])?i:{...i,components:c}});return{...e,pages:a}}function wt(e){const t=[];for(const r of e.template.pages)for(const n of r.components)n.kind==="list"&&(t.push(n.tree?{...n,rowKey:n.tree.idField}:n),n.detail&&t.push({...n.detail,relation:{detail:n.detail,parentRows:e.datasets[n.dataset]??[]}}));return t}function J(e){return JSON.stringify([e.sourceScope,e.datasetId])}function te(e){return JSON.stringify([e.sourceScope,e.datasetId,e.rowKey])}function yt(e){const t=new Map,r=new Set;return e.forEach((n,o)=>{for(const a of wt(n)){if(!a.rowKey)continue;const i=a.relation,s=i?new Set(i.parentRows.map(c=>JSON.stringify(c[i.detail.parentKey]))):void 0;(n.datasets[a.dataset]??[]).forEach((c,l)=>{if(i&&!s.has(JSON.stringify(c[i.detail.foreignKey])))return;const u=c[a.rowKey];if(typeof u!="string"&&typeof u!="number")return;const f=`${o}:${a.dataset}:${l}:${a.rowKey}`;if(r.has(f))return;r.add(f);const d=te({sourceScope:n.sourceScope,datasetId:a.dataset,rowKey:u}),m=t.get(d)??[];m.push({partIndex:o,dataset:a.dataset,rowIndex:l,row:c,binding:a}),t.set(d,m)})}}),n=>{const o=t.get(te(n));if(!o?.length)throw new M("missing");if(new Set(o.map(a=>`${a.partIndex}:${a.dataset}`)).size!==o.length)throw new M("conflict");return o}}function bt(e,t){const r=e.map(o=>({...o,datasets:{...o.datasets}})),n=new Set;for(const{row:o,field:a,value:i}of t){const s=r[o.partIndex],c=JSON.stringify([o.partIndex,o.dataset]);n.has(c)||(s.datasets[o.dataset]=[...s.datasets[o.dataset]],n.add(c)),s.datasets[o.dataset][o.rowIndex]={...s.datasets[o.dataset][o.rowIndex],[a]:i}}for(const o of n){const[a,i]=JSON.parse(o);k.forkComputedDataset(e[a].datasets[i],r[a].datasets[i])}return r}function Ur(e,t,r){const n=[],o=new Set;return e.forEach((a,i)=>{for(const s of wt(a))t.has(J({sourceScope:a.sourceScope,datasetId:s.dataset}))&&(a.datasets[s.dataset]??[]).forEach((c,l)=>{const u={partIndex:i,dataset:s.dataset,rowIndex:l,row:c,binding:s};for(const[f,d]of[[s.revisionField,r.revision],[s.sourceTokenField,r.sourceToken]]){if(!f||d===void 0)continue;const m=`${i}:${s.dataset}:${l}:${f}`;o.has(m)||(o.add(m),n.push({row:u,field:f,value:d}))}})}),n}function vt(e,t,r){if(!r||r.revision===void 0&&r.sourceToken===void 0)return e;const n=new Set(t.edits.flatMap(o=>o.source?[J(o.source)]:[]));return ke(e,new Map([...n].map(o=>[o,r])))}function ke(e,t){if(!t.size)return e;function r(a){const i=a.datasetId&&t.get(J({...a,datasetId:a.datasetId}));return!i||(i.revision===void 0||Object.is(i.revision,a.revision))&&(i.sourceToken===void 0||i.sourceToken===a.sourceToken)?a:{...a,...i.revision!==void 0?{revision:i.revision}:{},...i.sourceToken!==void 0?{sourceToken:i.sourceToken}:{}}}function n(a){const i=a.map(s=>{const c=s.table?.source?r(s.table.source):void 0,l=s.table&&c!==s.table.source?{...s.table,source:c}:s.table,u=s.grid?.cells.map(d=>{const m=d.map(g=>{if(!g)return g;const b=g.source?r(g.source):void 0,w=g.children?n(g.children):void 0;return b===g.source&&w===g.children?g:{...g,source:b,children:w}});return m.some((g,b)=>g!==d[b])?m:d}),f=s.grid&&u?.some((d,m)=>d!==s.grid.cells[m])?{...s.grid,cells:u}:s.grid;return l!==s.table||f!==s.grid?{...s,table:l,grid:f}:s});return i.some((s,c)=>s!==a[c])?i:a}const o=e.pages.map(a=>{const i=n(a.components);return i!==a.components?{...a,components:i}:a});return o.some((a,i)=>a!==e.pages[i])?{...e,pages:o}:e}function Xr(e){return JSON.stringify([e.pageIndex,e.componentIndex,e.rowIndex,e.columnIndex])}function We(e){const t=e.table;return t?.columnKey!==void 0?JSON.stringify([t.id,t.role,t.rowIndex,t.columnKey]):Xr(e.address)}function Yr(e,t){if(!t.length)return e;const r=new Map(t.map(c=>[We(c),c])),n=new Set(t.flatMap(c=>c.table?[c.table.id]:[])),o=new Set(t.map(c=>`${c.address.pageIndex}:${c.address.componentIndex}`)),a=V(e);function i(c,l,u){const f=c.grid;if(!f||!o.has(`${l}:${u}`)&&!n.has(c.table?.id??""))return c;const d=new Map,m=new Map;for(const g of E.resolveGridLayout(f,c.widthMm,c.heightMm).cells){const b=m.get(g.ri)??0;m.set(g.ri,b+1);const w=a({pageIndex:l,componentIndex:u,rowIndex:g.ri,columnIndex:g.ci}),y=w&&r.get(We(w));if(!y||!w.editable)continue;const h=d.get(g.ri)??[...f.cells[g.ri]],x=_(w,y.value);Object.is(w.value,y.value)&&x===w.cell.text||(h[b]={...g.cell,value:y.value,text:x,rawText:x},d.set(g.ri,h))}return d.size?{...c,grid:{...f,cells:f.cells.map((g,b)=>d.get(b)??g)}}:c}const s=e.pages.map((c,l)=>{const u=c.components.map((f,d)=>i(f,l,d));return u.every((f,d)=>f===c.components[d])?c:{...c,components:u}});return s.every((c,l)=>c===e.pages[l])?e:{...e,pages:s}}function N(e){const t=e.source;if(t)return JSON.stringify([t.sourceScope,t.datasetId,t.rowKey,t.field]);const r=e.table;if(r?.columnKey!==void 0)return JSON.stringify([r.id,r.role,r.rowIndex,r.columnKey]);const n=e.address;return JSON.stringify([n.pageIndex,n.componentIndex,n.rowIndex,n.columnIndex])}function Qr(e,t,r){if(typeof r!="string"||!r.trim()||!Array.isArray(t))throw new M("missing");if(t.length>1e4)throw new M("limit");const n=new Set,o=V(e),a=t.map(({address:i,value:s})=>{const c=o(i);if(!c)throw new M("missing");const l=z(c,s),u=N(l);if(n.has(u))throw new M("duplicate");return n.add(u),l});return{requestId:r,edits:a}}function Zr(e,t){if(t.edits.length>1e4)throw new M("limit");const r=V(e),n=new Set,o=t.edits.map(a=>{const i=r(a.address);if(!i)throw new M("missing");const s=N(a);if(n.has(s))throw new M("duplicate");if(n.add(s),de(i,a)||!Object.is(i.value,a.previousValue)||(i.cell.text??"")!==a.previousText)throw new M("conflict");return z(i,a.value)});return Yr(e,o)}function en(e){const t=new Map;for(const r of e){const n=N(r),o=t.get(n),a=o?{...r,previousValue:o.previousValue,previousText:o.previousText}:{...r};Object.is(a.previousValue,a.value)?t.delete(n):t.set(n,a)}return[...t.values()]}function Mt(e){const t=new Map,r=V(e);return e.pages.forEach((n,o)=>n.components.forEach((a,i)=>{if(!(!a.grid||a.table?.role!=="body"))for(let s=0;s<a.grid.cells.length;s++)for(let c=0;c<a.table.columnKeys.length;c++){const l=r({pageIndex:o,componentIndex:i,rowIndex:s,columnIndex:c});l?.source&&l.editable&&t.set(N(l),l)}})),t}function tn(e,t,r){const n=Mt(e),o=V(e);return t.map(a=>{const i=a.source?n.get(N(a)):o(a.address);if(!i||N(i)!==N(a))throw new M("missing");return{address:{...i.address},value:a[r]}})}function St(e,t){if(++e.nodes>1e6||t>128)throw new M("limit")}function re(e,t){const r=Object.getOwnPropertyDescriptor(e,t);if(!r||r.get||r.set)throw new M("conflict");return r.value}function Ie(e){if(Object.getOwnPropertyDescriptor(e,"toJSON"))throw new M("conflict");const t=Object.getPrototypeOf(e);if(Array.isArray(e)&&(t!==Array.prototype||Object.keys(e).length!==e.length))throw new M("conflict");if(!(e instanceof Date)&&!Array.isArray(e)&&t!==Object.prototype&&t!==null)throw new M("conflict");for(const r of Reflect.ownKeys(e))if(!(Array.isArray(e)&&r==="length")){if(typeof r=="symbol"||!Object.getOwnPropertyDescriptor(e,r)?.enumerable)throw new M("conflict");if(e instanceof Date||Array.isArray(e)&&!/^(0|[1-9]\d*)$/.test(r))throw new M("conflict")}}function xt(e,t,r,n,o,a){if(St(n,o),typeof e=="function"||typeof e=="symbol")throw new M("conflict");if(e===null||typeof e!="object")return;if(Ie(e),r.has(e))throw new M("conflict");if(a?.has(e))return;a?.add(e),r.add(e);const i=Object.keys(e),s=i.map(c=>re(e,c));t.push({object:e,prototype:Object.getPrototypeOf(e),keys:i,values:s,...e instanceof Date?{date:Date.prototype.getTime.call(e)}:{},...Array.isArray(e)?{length:e.length}:{}});for(const c of s)xt(c,t,r,n,o+1,a);r.delete(e)}function rn(e){const{object:t,keys:r,values:n}=e;if(Ie(t),Object.getPrototypeOf(t)!==e.prototype||Object.getOwnPropertyDescriptor(t,"toJSON")||e.date!==void 0&&!Object.is(Date.prototype.getTime.call(t),e.date)||e.length!==void 0&&t.length!==e.length)return!1;const o=Object.keys(t);return o.length===r.length&&r.every((a,i)=>o[i]===a&&Object.is(re(t,a),n[i]))}function nn(e){return Rt(e)}function on(e){return Rt(e,new Set)}function Rt(e,t){const r=[];return xt(e,r,new Set,{nodes:0},0,t),()=>{try{return r.every(rn)}catch{return!1}}}function ne(e,t,r,n=!1){if(St(t,r),n){if(typeof e=="function"||typeof e=="symbol")throw new M("conflict");e!==null&&typeof e=="object"&&Ie(e)}if(e===null||typeof e!="object")return e;if(e instanceof Date)return new Date(Date.prototype.getTime.call(e));if(Array.isArray(e)){const o=[];for(let a=0;a<e.length;a++)o[a]=ne(re(e,String(a)),t,r+1,n);return o}return Object.fromEntries(Object.keys(e).map(o=>[o,ne(re(e,o),t,r+1,n)]))}function an(e){return ne(e,{nodes:0},0,!0)}function sn(e){const t=ne(e,{nodes:0},0);for(const r of t)for(const n of Object.values(r.datasets))k.registerComputedDataset(n);return t}async function cn(e,t,r={}){return(await Ct(e,t,r)).plan}async function Ct(e,t,r={}){return st(e,t,{...r,knownTotalPages:void 0})}function ln(e){return e.computed||e.groupBy||e.groups||e.grandTotal||e.tree||e.matrix||e.detail||e.rowVisibleWhen||e.headerGrid?!1:e.columns.every(t=>!t.format&&!t.rules&&!t.visibleWhen&&!t.visual)}function dn(e,t){return e.length!==t.length||t.some(r=>r?.measurer||r?.formula||r?.mmPerRow||r?.knownTotalPages!==void 0)?!1:e.every(r=>!r.template.repeat&&r.template.pages.every(n=>!n.flow&&n.components.every(o=>o.kind==="list"?ln(o):!o.binding&&!o.chartBinding&&!o.grid&&!o.table&&!o.richParagraphs)))}function un(e){const t=new Map;for(const r of e){if(!r.source||typeof r.value!="string"||typeof r.previousValue!="string"||r.previousText!==r.previousValue||![r.previousValue,r.value].every(a=>a.trim().length&&a.length<=16384&&!/[\r\n]/.test(a)))return null;const n=te(r.source),o=t.get(n)??new Map;o.set(r.source.field,r),t.set(n,o)}return t}function Fe(e){return!e.source&&!e.formula&&!e.derived&&!e.richParagraphs&&!e.children&&!e.dataBar&&!e.numberFormat&&!e.colSpan&&!e.rowSpan&&!e.indentMm&&!e.style?.rotateDeg}function fn(e){return e.pages.every(t=>t.components.every(r=>!r.grid||r.grid.cells.every(n=>n.every(o=>!!o&&Fe(o)))))}function mn(e,t,r,n){if(!Fe(e)||e.value!==t.previousValue||e.text!==t.previousText)return!1;const o=r-n*2,a=e.style,i=E.resolveFontSize(a).fontSizePt;if(!Number.isFinite(o)||o<1||!Number.isFinite(i)||i<=0)return!1;const s={fontSizePt:i,fontFamily:a?.fontFamily??E.DEFAULT_FONT_FAMILY,italic:a?.italic,bold:a?.bold,letterSpacingPt:a?.letterSpacing};return A.wrapText(t.previousText,o,s,A.heuristicMeasurer).length===A.wrapText(t.value,o,s,A.heuristicMeasurer).length}function gn(e,t){const r=e.colWidthsMm;if(!r||r.length!==e.cells[0].length||r.length!==t.table.columnKeys.length)return!1;const n=r.reduce((o,a)=>o+a,0);return Number.isFinite(n)&&Math.abs(n-t.widthMm)<=Math.max(1e-7,n*1e-10)}function hn(e,t,r){const n=e.table?.source;if(e.table?.role!=="body"||n?.rowKey===void 0)return e;const o=t.get(te({...n,rowKey:n.rowKey}));if(!o)return e;const a=e.grid;if(!a||a.cells.length!==1||!gn(a,e)||e.style?.rotateDeg)return null;const i=a.cells[0],s=[...i];for(let c=0;c<i.length;c++){const l=i[c];if(!l||!Fe(l))return null;const u=o.get(e.table.columnKeys[c]);if(u){if(!mn(l,u,a.colWidthsMm[c],a.paddingMm??.5))return null;s[c]={...l,value:u.value,text:u.value},r.add(u)}}return s.some((c,l)=>c!==i[l])?{...e,grid:{...a,cells:[s]}}:e}async function pn(e,t,r){const n=un(t);if(!n||!t.length)return null;const o=new Set,a=[];let i=0;for(const c of e.pages){const l=[];for(const u of c.components){if(r?.aborted)return null;const f=hn(u,n,o);if(!f)return null;l.push(f),++i%128===0&&await new Promise(d=>setTimeout(d,0))}a.push(l.some((u,f)=>u!==c.components[f])?{...c,components:l}:c)}if(o.size!==t.length)return null;const s={...e,pages:a};return H.validateRenderPlan(s).ok?s:null}function wn(e,t,r){let n=dn(t,r),o=e,a;function i(c){if(o=c,a=void 0,!!n){if(!fn(c)){n=!1;return}try{a=on(c)}catch{n=!1}}}i(e);async function s(c,l,u){if(!n||c!==o||!a?.())return null;const f=a,d=await pn(c,l,u);return d&&f()?{plan:d,unchanged:f}:null}return{candidate:s,publish:i}}const pe=new WeakMap;function yn(e){return pe.get(e)}function U(e){if(e?.aborted){const t=new Error("报表重算已取消");throw t.name="AbortError",t}}function Et(e,t){return e[t]===void 0?"":e[t]}function bn(e,t){if(t.edits.length>1e4)throw new M("limit");const r=V(e),n=new Set,o=[],a=t.edits.map(i=>{const s=r(i.address);if(!s?.source)throw new M("missing");const c=N(i);if(n.has(c))throw new M("duplicate");if(n.add(c),de(s,i)||!Object.is(s.value,i.previousValue)||(s.cell.text??"")!==i.previousText)throw new M("conflict");return o.push(s),z(s,i.value)});return{batch:{requestId:t.requestId,edits:a},contexts:o}}function vn(e,t){const r=yt(e);return t.flatMap(n=>{if(!n.source)throw new M("missing");return r(n.source).map(o=>{if(!Object.is(Et(o.row,n.source.field),n.previousValue))throw new M("conflict");if(o.binding.rowKey===n.source.field)throw new M("readonly");return{row:o,field:n.source.field,value:n.value}})})}function fe(e,t,r){const n={...e,value:t,source:{...e.source,...r?.revision===void 0?{}:{revision:r.revision},...r?.sourceToken===void 0?{}:{sourceToken:r.sourceToken}}};return n.cell={...e.cell,value:n.value,text:_(n,n.value)},n}function Mn(e,t,r){if(!r||r.revision===void 0&&r.sourceToken===void 0)return[...e];const n=new Set(t.edits.flatMap(o=>o.source?[J(o.source)]:[]));return bt(e,Ur(e,n,r))}function Sn(e,t,r){const n=new Set(t.edits.map(o=>J(o.source)));for(const o of n)e.set(o,{...e.get(o),...r.revision!==void 0?{revision:r.revision}:{},...r.sourceToken!==void 0?{sourceToken:r.sourceToken}:{}});return n}function xn(e,t){return $e(e,t)}function $e(e,t,r){let n=t.parts;const o=t.rebuild,a=[...t.validationFormulas??[]],i=r?wn(e,n,r):void 0;let s=nn(n),c=e,l;const u=new Map,f=new Map;function d(b){if(b!==c)throw new M("conflict");if(l)return l;if(!s?.())throw new M("conflict");return sn(n)}async function m(b,w,y,h={}){U(h.signal),w={requestId:w.requestId,edits:w.edits.map(v=>({...v,address:{...v.address},source:v.source?{...v.source}:void 0,table:v.table?{...v.table}:void 0}))},y=y.map(v=>({...v,address:{...v.address},source:v.source?{...v.source}:void 0,table:v.table?{...v.table}:void 0,cell:{...v.cell}})),await new Promise(v=>setTimeout(v,0)),U(h.signal);const x=d(b),T=bt(x,vn(x,w.edits)),I=await i?.candidate(b,w.edits,h.signal);U(h.signal);const L=ke(I?.plan??await o(T,h.signal),f);U(h.signal);let D=!1,p=[],C="allow",R=!1;function $(v){return R=!0,p=Object.freeze(Or(T,v,h.signal,a).map(F=>Object.freeze({...F}))),R=!1,C=v.warningPolicy??"allow",p}return h.validation&&$(h.validation),{plan:L,get validationIssues(){return p},validate:$,commit(v){if(U(h.signal),D||c!==b)throw new M("conflict");if(I&&!I.unchanged())throw new M("conflict");if(v?.conflicts?.length)throw new M("conflict");if(R)throw new Error("候选规则校验未完成,不能提交");ft(p,C);const F=Mn(T,w,v),K=vt(L,w,v);if(v){const j=Sn(f,w,v);for(const[q,G]of u)j.has(J(G.source))&&u.set(q,fe(G,G.value,v))}return y.forEach((j,q)=>u.set(N(j),fe(j,w.edits[q].value,v))),D=!0,l=F,n=void 0,s=void 0,c=K,i?.publish(c),pe.set(c,g),c}}}const g={get plan(){return c},async prepare(b,w,y){const h=bn(b,w);return m(b,h.batch,h.contexts,y)},async prepareHistory(b,w,y,h,x){if(!h.trim()||w.length>1e4)throw new M("limit");const T=d(b),I=yt(T),L=Mt(b),D=new Set,C=w.map(v=>{if(!v.source)throw new M("missing");const F=N(v);if(D.has(F))throw new M("duplicate");D.add(F);const K=L.get(F)??u.get(F);if(!K?.source)throw new M("missing");const j=I(K.source)[0];return fe(K,Et(j.row,K.source.field))}).map((v,F)=>({context:v,edit:z(v,w[F][y])})).filter(({edit:v})=>!Object.is(v.previousValue,v.value)),R={requestId:h,edits:C.map(({edit:v})=>v)},$=C.map(({context:v})=>v);return{batch:R,contexts:$,prepared:await m(b,R,$,x)}}};return pe.set(e,g),g}function Rn(e){const t=Pe(e.template,e.datasets,e.pagination).plan;return $e(t,{validationFormulas:[e.pagination?.formula],parts:[{template:e.template,datasets:e.datasets}],rebuild:(r,n)=>cn(r[0].template,r[0].datasets,{...e.pagination,signal:n})},[e.pagination])}let Cn=0;function Pt(){return`report-${Date.now()}-${++Cn}`}function we(e,t,r){if(!r?.aborted)try{const n=e?.({...t});n&&typeof n.then=="function"&&Promise.resolve(n).catch(()=>{})}catch{}}function Tt(e){const t=e.taskId??Pt(),r=(n,o,a)=>{we(e.onEvent,{taskId:t,...e.correlationId===void 0?{}:{correlationId:e.correlationId},stage:n,status:o,...a===void 0?{}:{reportId:a}},e.signal)};return{taskId:t,progress(n,o,a){we(e.onEvent,{taskId:t,...e.correlationId===void 0?{}:{correlationId:e.correlationId},stage:n,status:"started",completed:o,total:a},e.signal)},async run(n,o,a){r(n,"started",a);try{const i=await o();return r(n,"completed",a),i}catch(i){throw r(n,"failed",a),i}},runSync(n,o,a){r(n,"started",a);try{const i=o();return r(n,"completed",a),i}catch(i){throw r(n,"failed",a),i}}}}function Oe(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;const t=e,r=n=>typeof n=="string"&&n.trim().length>0&&n.length<=256;return!r(t.datasetId)||!r(t.field)||t.tableId!==void 0&&!r(t.tableId)||t.reportScope!==void 0&&(typeof t.reportScope!="string"||!t.reportScope.trim()||t.reportScope.length>4096)?!1:t.rowKey===void 0?!0:typeof t.rowKey=="string"?t.rowKey.trim().length>0&&t.rowKey.length<=1024:typeof t.rowKey=="number"&&Number.isFinite(t.rowKey)}function kt(e){return e==="missing-source"||e==="not-applicable"||e==="not-calculable"}function It(e){return e.target!==void 0&&!Oe(e.target)?!1:e.valueState===void 0||kt(e.valueState)&&e.target!==void 0}function En(e,t){if(Me.validateDatasetRows([],e),!Oe(t))throw new Error("数据说明目标无效");const r=e.fields.find(o=>o.field===t.field);if(!r)throw new Error("数据说明字段未在契约中声明");const n=[];return r.description&&n.push({code:"field-definition",severity:"info",message:r.description,target:{...t}}),r.calculation&&n.push({code:"field-calculation",severity:"info",message:r.calculation.description,target:{...t}}),n}function Ae(e,t,r={}){const n=new Map;for(const a of e.pages)for(const i of a.components){if(i.kind!=="list"||i.tree?.input!=="nested")continue;const s=n.get(i.dataset);if(s&&(s.childrenField??"children")!==(i.tree.childrenField??"children"))throw new Error("同一数据集的嵌套树应使用相同 childrenField");n.set(i.dataset,i.tree)}if(!n.size)return t;const o={...t};for(const[a,i]of n){const s=Math.min(i.maxRows??1e5,r.maxRows??1/0);o[a]=W.flattenTreeInput(t[a]??[],{...i,maxRows:s},r.signal)}return o}function Pn(e,t,r={}){return Object.values(Ae(e,t,r)).reduce((n,o)=>n+o.length,0)}function Tn(e,t,r){const n=Me.datasetJsonSchema(r),o=e?.pages.flatMap(s=>s.components).find(s=>s.kind==="list"&&s.dataset===t&&s.tree?.input==="nested");if(!o||o.kind!=="list"||!o.tree)return n;const a=n.items,i=o.tree.childrenField??"children";return{...n,items:{$ref:"#/$defs/treeNode"},$defs:{treeNode:{...a,properties:{...a.properties,[i]:{anyOf:[{type:"null"},{type:"array",items:{$ref:"#/$defs/treeNode"}}]}}}}}}function Ne(e,t){return JSON.stringify([e,t])}function Le(e,t,r){return r===void 0?Ne(e,t):JSON.stringify(["shared",r])}function Ft(e,t,r){return e.map(n=>{const o=n.table?{...n.table,id:r(n.table.id),...n.table.source?{source:{...n.table.source,sourceScope:t}}:{}}:void 0,a=n.grid?.cells.map(i=>i.map(s=>!s||!s.source&&!s.children?s:{...s,...s.source?{source:{...s.source,sourceScope:t}}:{},...s.children?{children:Ft(s.children,t,r)}:{}}));return o||a?{...n,...o?{table:o}:{},...a?{grid:{...n.grid,cells:a}}:{}}:n})}function ye(e){return S.validateChartComponentLimit(e.maxChartComponents),{maxPages:e.maxPages,maxCells:e.maxCells,maxChartComponents:e.maxChartComponents??S.DEFAULT_CHART_COMPONENT_LIMIT,usedPages:0,usedCells:0,usedChartComponents:0}}function kn(e,t){if(!e.repeat)return!1;const r=Object.prototype.hasOwnProperty.call(t,e.repeat.dataset)?t[e.repeat.dataset]:void 0;return Array.isArray(r)&&r.length===0}function In(e){const t=r=>r.grid?.cells.reduce((n,o)=>n+o.reduce((a,i)=>a+(i?1+(i.children?.reduce((s,c)=>s+t(c),0)??0):0),0),0)??0;return e.pages.reduce((r,n)=>r+n.components.reduce((o,a)=>o+t(a),0),0)}function be(e,t){return e===void 0?void 0:e-t}function me(e,t){return e===void 0?t:Math.max(1,Math.min(e,t??e))}function $t(e,t,r,n,o){S.validateChartComponentLimit(e?.maxChartComponents);const a=be(t.maxPages,t.usedPages),i=t.maxChartComponents-t.usedChartComponents;if(a!==void 0&&a<1&&r.pages.length&&!kn(r,n))throw new S.PaginatePageLimitError(0,1);if(i<1&&r.pages.some(s=>s.components.some(c=>c.kind!=="list"&&c.chartBinding)))throw new S.PaginateChartComponentLimitError(i,1);return{...e,signal:o??e?.signal,maxPages:me(a,e?.maxPages),maxCells:me(be(t.maxCells,t.usedCells),e?.maxCells),maxChartComponents:me(i,e?.maxChartComponents)}}function Ot(e,t){const r=In(t.plan),n=be(e.maxCells,e.usedCells);if(n!==void 0&&r>n)throw new S.PaginateCellLimitError(n,r);e.usedPages+=t.plan.pages.length,e.usedCells+=r,e.usedChartComponents+=t.chartComponents}function At(e,t){return e instanceof S.PaginatePageLimitError&&t.maxPages!==void 0&&(e.limit===t.maxPages-t.usedPages||e.limit===0)?new S.PaginatePageLimitError(t.maxPages,t.usedPages+e.actual):e instanceof S.PaginateCellLimitError&&t.maxCells!==void 0?new S.PaginateCellLimitError(t.maxCells,t.usedCells+e.actual):e instanceof S.PaginateChartComponentLimitError&&e.limit===t.maxChartComponents-t.usedChartComponents?new S.PaginateChartComponentLimitError(t.maxChartComponents,t.usedChartComponents+e.estimated):e}function Fn(e){if(!("mapData"in e))return e;const{load:t,mapData:r,...n}=e;return{...n,load:async o=>{const a=await t(o);O(o.signal);try{return r(a,o)}catch(i){throw new P("validate",`报表 ${o.reportId} 数据映射失败`,i)}}}}class P extends Error{constructor(t,r,n){super(r),this.name="ReportSourceError",this.code=t,this.cause=n}}function ue(e){const t=new Error("报表加载已取消");return t.name="AbortError",Object.defineProperty(t,"cause",{value:e.reason}),t}function O(e){if(e?.aborted)throw ue(e)}function ve(e,t){return t?new Promise((r,n)=>{const o=()=>t.removeEventListener("abort",a),a=()=>{o(),n(ue(t))};t.addEventListener("abort",a,{once:!0}),t.aborted&&a(),Promise.resolve(e).then(i=>{o(),r(i)},i=>{o(),n(i)})}):Promise.resolve(e)}function $n(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new P("validate",`报表 ${t} 的数据集应为对象`);for(const[r,n]of Object.entries(e))if(!Array.isArray(n)||n.some(o=>!o||typeof o!="object"||Array.isArray(o)))throw new P("validate",`报表 ${t} 的数据集 ${r} 应为对象数组`)}async function On(e,t,r){const{reportId:n,signal:o}=t;try{const a=await ve(e(t),o);O(o);const i=H.validateReportTemplate(a);if(!i.ok)throw new P("validate",`报表 ${n} 模板校验失败:${i.errors.slice(0,3).map(s=>`${s.path}: ${s.message}`).join("; ")}`);return r.push(...i.warnings.map(s=>`${n}: ${s.path}: ${s.message}`)),a}catch(a){throw o?.aborted?ue(o):a instanceof P?a:a instanceof H.ReportTemplateError?new P("validate",`报表 ${n} 模板校验失败:${a.message}`,a):new P("fetch",`报表 ${n} 模板加载失败:${a instanceof Error?a.message:String(a)}`,a)}}async function An(e,t,r,n){const o=t.signal;let a;try{if(e.load)a=await ve(e.load(t),o);else if(e.provider){const i=await ve(e.provider.query(t),o);O(o),Nn(i,r),a=i.datasets,n?.(r,i)}else a=e.datasets??{}}catch(i){throw o?.aborted?ue(o):i instanceof P?i:new P("fetch",`报表 ${r} 取数失败:${i instanceof Error?i.message:String(i)}`,i)}return O(o),a}function Nn(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new P("validate",`报表 ${t} Provider 应返回 datasets 结果对象`);for(const r of["revision","sourceToken"])if(e[r]!==void 0&&typeof e[r]!="string")throw new P("validate",`报表 ${t} Provider ${r} 应为字符串`);if(e.diagnostics!==void 0&&(!Array.isArray(e.diagnostics)||e.diagnostics.some(r=>!r||typeof r.code!="string"||typeof r.message!="string"||!["info","warning","error"].includes(r.severity))))throw new P("validate",`报表 ${t} Provider diagnostics 不符合结构化诊断契约`);if(e.diagnostics?.some(r=>!It(r)))throw new P("validate",`报表 ${t} Provider 数据说明缺少有效的字段身份或值状态`)}function Ln(e,t,r,n,o){try{t=Ae(n,t,{maxRows:e.dataValidation?.maxRows,signal:o})}catch(a){throw new P("validate",`报表 ${r} 树形数据无效:${a instanceof Error?a.message:String(a)}`,a)}for(const[a,i]of Object.entries(e.dataSchema??{})){let s;try{s=Me.validateDatasetRows(Object.prototype.hasOwnProperty.call(t,a)?t[a]:void 0,i,{...e.dataValidation,path:`$.datasets.${a}`})}catch(c){throw new P("config",`报表 ${r} 数据集 ${a} 字段契约配置无效`,c)}if(!s.ok)throw new P("validate",`报表 ${r} 数据集 ${a} 不符合字段契约:${s.issues[0]?.message}`,{issues:s.issues})}}async function Kn(e,t,r,n,o){try{let a;try{a=an(e)}catch{}const i=a??e,s=$t(t.pagination,n,i.template,i.datasets,o),c=a?await st(i.template,i.datasets,s):Pe(i.template,i.datasets,s);return Ot(n,c),{result:c,part:i}}catch(a){O(o);const i=At(a,n);throw new P("validate",`报表 ${r} 排版失败:${i instanceof Error?i.message:String(i)}`,i)}}function Nt(e,t,r,n,o){const a=new Map,i=s=>{let c=a.get(s);return c===void 0&&(c=JSON.stringify([r,n,s]),a.set(s,c)),c};for(const s of t.pages)e.push({...s,meta:{...s.meta,reportScope:Ne(r,n)},components:Ft(s.components,o??Le(r,n),i)})}async function jn(e,t,r,n,o){const a=[],i=ye(n);for(const[l,u]of e.entries()){O(o);try{const f=await Ct(u.template,u.datasets,$t(t[l]?.pagination,i,u.template,u.datasets,o));Ot(i,f),Nt(a,f.plan,l,r[l],u.sourceScope)}catch(f){throw At(f,i)}}const s={schemaVersion:E.RENDER_PLAN_SCHEMA_VERSION,...e.some(l=>Se(l.template))?{requiresRecalculation:!0}:{},pages:a},c=H.validateRenderPlan(s);if(!c.ok)throw new P("validate",`重算渲染计划校验失败:${c.errors[0]?.message}`);return s}function Dn(e,t={}){if(t.maxPages!==void 0&&(!Number.isSafeInteger(t.maxPages)||t.maxPages<1))throw new P("config","maxPages 应为正安全整数");if(t.maxCells!==void 0&&(!Number.isSafeInteger(t.maxCells)||t.maxCells<1))throw new P("config","maxCells 应为正安全整数");try{ye(t)}catch(o){throw new P("config","maxChartComponents 应为 1..1000000 的安全整数",o)}function r(o){const a=Object.prototype.hasOwnProperty.call(e,o)?e[o]:void 0;if(!a)throw new P("config",`未注册报表 ${o}`);if(a.sourceScope!==void 0&&(typeof a.sourceScope!="string"||!a.sourceScope.trim()||a.sourceScope.length>512))throw new P("config","sourceScope 应为不超过 512 字符的非空字符串");return a}return Object.assign(async({reportIds:o,params:a,signal:i,onWarning:s,onQueryResult:c,...l})=>{O(i);const u=Tt({...l,signal:i}),f=[...o],d={...a};if(f.length===0)throw new P("config","缺少报表 ID");const m=f.map(r),g=u.runSync("validate",()=>m.map(p=>Ke.assertReportParams(p.params??(typeof p.template=="function"?[]:p.template.params)??[],d))),b=[],w=[],y=ye(t),h=[];for(const[p,C]of m.entries()){O(i);const R=f[p],$={reportId:R,params:g[p],signal:i},v=typeof C.template=="function"?await u.run("query",()=>On(C.template,$,h),R):C.template;$.params=u.runSync("validate",()=>Ke.assertReportParams(C.params??v.params??[],$.params),R);const F=await u.run("query",()=>An(C,$,R,(G,Lt)=>c?.(G,Lt,p)),R);u.runSync("validate",()=>{$n(F,R),t.onDatasets?.(R,F,v),Ln(C,F,R,v,i)},R),O(i);const K=Le(p,R,C.sourceScope),{result:j,part:q}=await u.run("layout",()=>Kn({template:v,datasets:F,sourceScope:K},C,R,y,i),R);w.push(q),Nt(b,j.plan,p,R,K),h.push(...j.warnings.map(G=>`${R}: ${G}`))}O(i);const x={schemaVersion:E.RENDER_PLAN_SCHEMA_VERSION,...w.some(p=>Se(p.template))?{requiresRecalculation:!0}:{},pages:b},T=u.runSync("validate",()=>{const p=H.validateRenderPlan(x);if(!p.ok)throw new P("validate",`渲染计划校验失败:${p.errors.slice(0,3).map(C=>`${C.path}: ${C.message}`).join("; ")}`);return p});h.push(...T.warnings.map(p=>`${p.path}: ${p.message}`));const I=m.map(p=>({...p,pagination:{...p.pagination}})),L={maxPages:t.maxPages,maxCells:t.maxCells,maxChartComponents:t.maxChartComponents};try{$e(x,{parts:w,validationFormulas:I.map(p=>p.pagination?.formula),rebuild:(p,C)=>jn(p,I,f,L,C)},I.map(p=>p.pagination))}catch{h.push("来源数据无法建立本地重算口径;当前预览仅支持计划内编辑,请使用可序列化模板数据启用规则重算")}const D=s??t.onWarning??(p=>console.warn("[mach-report]",p));for(const p of h)O(i),D(p);return O(i),x},{getParamDefs:o=>Kt.getReportParamDefs(e,o)})}const Bn=new Set([8,9,10,12,13]);function Hn(e,t){const r=Array.isArray(e),n=Object.getPrototypeOf(e);if(n!==(r?Array.prototype:Object.prototype)&&!(n===null&&!r)||Object.getOwnPropertySymbols(e).length)throw t("input","快照应为普通 JSON 对象");const o=Object.getOwnPropertyNames(e).filter(a=>!(r&&a==="length"));if(r&&(o.length!==e.length||o.some((a,i)=>a!==String(i))))throw t("input","快照数组应为连续数组");return{array:r,keys:o}}function Gn(e){if(/^[\u0020-\u007e]*$/.test(e)&&!/["\\]/.test(e))return e.length+2;let t=2;for(let r=0;r<e.length;r++){const n=e.charCodeAt(r);if(n<32)t+=Bn.has(n)?2:6;else if(n===34||n===92)t+=2;else if(n<128)t++;else if(n<2048)t+=2;else if(n>=55296&&n<=57343){const o=e.charCodeAt(r+1);n<=56319&&o>=56320&&o<=57343?(t+=4,r++):t+=6}else t+=3}return t}function Vn(e,t){const r=t.maxNodes??1e6;if(![t.maxBytes,r].every(d=>Number.isSafeInteger(d)&&d>0))throw t.error("budget","快照预算应为正安全整数");let n=0,o=0;const a=new Set,i=new Map;function s(d){if(d.length+2>t.maxBytes-o)throw t.error("budget","快照超过字节预算");const m=i.get(d);if(m!==void 0)return m;const g=Gn(d);return d.length<=256&&i.size<4096&&i.set(d,g),g}function c(d){if(o+=d,o>t.maxBytes)throw t.error("budget","快照超过字节预算")}function l(d,m){if(++n>r||m>64)throw t.error("budget","快照节点或深度超过预算");if(n%1024===0&&t.check?.(),typeof d=="string")return c(s(d)),d;if(d===null||typeof d=="boolean"||typeof d=="number"&&Number.isFinite(d))return c(String(d).length),typeof d=="number"&&Object.is(d,-0)?0:d;if(!d||typeof d!="object"||a.has(d))throw t.error("input","快照应为无循环的有限 JSON 值");return u(d,m)}function u(d,m){const{array:g,keys:b}=Hn(d,t.error);a.add(d),c(2);const w=g?[]:{};let y=0;for(const h of b){const x=Object.getOwnPropertyDescriptor(d,h);if(x.get||x.set||!x.enumerable||["__proto__","constructor","prototype"].includes(h))throw t.error("input","快照不允许访问器或危险键");if(x.value===void 0&&!g)continue;c((y++?1:0)+(g?0:s(h)+1));const T=l(x.value===void 0?null:x.value,m+1);h in w?Object.defineProperty(w,h,{value:T,enumerable:!0,configurable:!0,writable:!0}):w[h]=T}return a.delete(d),w}t.check?.();const f=l(e,0);return t.check?.(),f}exports.DEFAULT_LABEL_PAGE_LIMIT=qe;exports.ReportCellEditError=M;exports.ReportSourceError=P;exports.ReportValidationError=lt;exports.applyReportCellEdit=qr;exports.applyReportCellEditBatch=Zr;exports.applyReportEditResult=vt;exports.applyReportSourceMetadata=ke;exports.assertReportValidation=ft;exports.countTemplatePages=Sr;exports.createReportCellEdit=Vr;exports.createReportCellEditBatch=Qr;exports.createReportCellIndex=ht;exports.createReportCellResolver=V;exports.createReportEditSession=Rn;exports.createReportSource=Dn;exports.createReportTaskReporter=Tt;exports.defineReport=Fn;exports.editFromContext=z;exports.estimateListLayoutCells=Pr;exports.explainDatasetField=En;exports.formatReportCellEdit=_;exports.getReportCellContext=le;exports.getReportEditSession=yn;exports.hasValidDataExplanation=It;exports.isReportDataTarget=Oe;exports.isReportValueState=kt;exports.notifyReportTaskEvent=we;exports.paginateTemplate=Pe;exports.paginateTemplatePages=xr;exports.parseReportCellInput=Te;exports.projectListColumns=Je;exports.registerReportEditSession=xn;exports.relocateReportCellEdits=tn;exports.reportCellEditKey=N;exports.reportOccurrenceScope=Ne;exports.reportSourceScope=Le;exports.reportTaskId=Pt;exports.snapshotReportJson=Vn;exports.sourceChanged=de;exports.summarizeReportCellEdits=en;exports.templateDatasetJsonSchema=Tn;exports.templateDatasetRowCount=Pn;exports.templateValidationDatasets=Ae;exports.validateReportDataset=$r;
|