@agile-team/mach-report 2.15.0 → 2.17.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 +21 -12
- package/dist/{ExcelBindingWizard-Bs43BGNp.cjs → ExcelBindingWizard-Bq6FYME6.cjs} +1 -1
- package/dist/{ExcelBindingWizard-BKH1nGNS.js → ExcelBindingWizard-Co1svTsw.js} +3 -3
- package/dist/{ParamEditor-Da4akw6V.cjs → ParamEditor-B5UZRgxv.cjs} +1 -1
- package/dist/{ParamEditor-DoAhzJsm.js → ParamEditor-DNNARyeB.js} +1 -1
- package/dist/{ReportBatchPanel-wP9m9Pj1.cjs → ReportBatchPanel-Ctvs2t_9.cjs} +1 -1
- package/dist/{ReportBatchPanel-BMf6boMA.js → ReportBatchPanel-uQh06usx.js} +3 -3
- package/dist/ReportPreview-BdQawRh0.js +4879 -0
- package/dist/ReportPreview-CJC_-j2I.cjs +6 -0
- package/dist/{ReportTemplateLibrary-Sxr3eD0J.cjs → ReportTemplateLibrary-CnP7_1pH.cjs} +1 -1
- package/dist/{ReportTemplateLibrary-C9wutIiT.js → ReportTemplateLibrary-TIL_Oj2l.js} +1 -1
- package/dist/RuleEditor-DkRjOLlr.js +2141 -0
- package/dist/RuleEditor-h5anGsDB.cjs +1 -0
- package/dist/{TemplateOutlinePanel-JTSR53vJ.cjs → TemplateOutlinePanel-BlLxRrfu.cjs} +1 -1
- package/dist/{TemplateOutlinePanel-D6Bkny59.js → TemplateOutlinePanel-BouxsuqQ.js} +1 -1
- package/dist/{TemplateReusePanel-rVuK1kTz.js → TemplateReusePanel-BEACLPaN.js} +2 -2
- package/dist/{TemplateReusePanel-Kx35S0Ql.cjs → TemplateReusePanel-yxsHSO40.cjs} +1 -1
- package/dist/{TemplateReviewPanel-B0ar9_zf.js → TemplateReviewPanel-B1OGRY2i.js} +1 -1
- package/dist/{TemplateReviewPanel-Dn6X9UmY.cjs → TemplateReviewPanel-D9Cx0m2N.cjs} +1 -1
- package/dist/analytics.cjs +1 -1
- package/dist/analytics.d.cts +65 -1
- package/dist/analytics.d.ts +65 -1
- package/dist/analytics.js +4 -4
- package/dist/artifact-integrity.json +105 -101
- package/dist/assets-BIMVwjQe.js +231 -0
- package/dist/assets-Dfs2ElxI.cjs +1 -0
- package/dist/auto-BIOmtVhk.js +240 -0
- package/dist/auto-DDHflI9v.cjs +1 -0
- package/dist/{batch-BfZHN1do.js → batch-WzDIXJAt.js} +1 -1
- package/dist/{batch-CLpELXBl.cjs → batch-z6Aw5GEY.cjs} +1 -1
- package/dist/codes.d.cts +2 -0
- package/dist/codes.d.ts +2 -0
- package/dist/component-tree-Ca6YYfHq.js +61 -0
- package/dist/component-tree-DkGLEfZC.cjs +1 -0
- package/dist/computed-BW5a8QFk.js +612 -0
- package/dist/computed-C2GD3XcE.cjs +1 -0
- package/dist/config-Dg_o8e7m.cjs +1 -0
- package/dist/{config-BVsJXSqS.js → config-XQ4qrQ7Q.js} +66 -64
- package/dist/dataset-DL83majE.js +161 -0
- package/dist/dataset-IrlXbUvh.cjs +1 -0
- package/dist/designer-D9XAxqSc.js +5178 -0
- package/dist/designer-uCDo5XSK.cjs +2 -0
- package/dist/designer.cjs +1 -1
- package/dist/designer.d.cts +178 -3
- package/dist/designer.d.ts +178 -3
- package/dist/designer.js +1 -1
- package/dist/drill-ByN8COs_.cjs +1 -0
- package/dist/{drill-ByJviLXS.js → drill-CKW3Xtfa.js} +5 -5
- package/dist/encoding-BFMFIc4r.cjs +1 -0
- package/dist/encoding-DP_Eaf0A.js +21 -0
- package/dist/{font-loader-B_UkxpzC.cjs → font-loader-7FWVlykp.cjs} +1 -1
- package/dist/{font-loader-Q3bQjmrI.js → font-loader-CQZowp0I.js} +1 -1
- package/dist/index.cjs +8 -9
- package/dist/index.d.cts +175 -1
- package/dist/index.d.ts +175 -1
- package/dist/index.js +1343 -915
- package/dist/json-snapshot-D7PE1NsU.cjs +2 -0
- package/dist/json-snapshot-DYmEe3sO.js +1779 -0
- package/dist/matrix-JLAXlux-.js +302 -0
- package/dist/matrix-gTHpDTGm.cjs +1 -0
- package/dist/{pdf-CvvrjPQg.cjs → pdf-B8JouyYv.cjs} +48 -50
- package/dist/{pdf-BwNyeGpt.js → pdf-l3ea86di.js} +2734 -2748
- package/dist/pdf.cjs +1 -1
- package/dist/pdf.d.cts +14 -0
- package/dist/pdf.d.ts +14 -0
- package/dist/pdf.js +2 -2
- package/dist/{plugin-Ca_XZG3l.js → plugin-BBp74CQZ.js} +1 -1
- package/dist/{plugin-DHO7X8z2.cjs → plugin-CtFX9PFG.cjs} +1 -1
- package/dist/prepared-CARicKYh.js +87 -0
- package/dist/prepared-Ch1x_Gog.cjs +1 -0
- package/dist/progress-BXzlVbIp.js +29 -0
- package/dist/progress-DJBd9Rb9.cjs +1 -0
- package/dist/{progress-D-OTpEav.js → progress-Hc2vxoCs.js} +2 -2
- package/dist/protocol-B5A2uom4.cjs +1 -0
- package/dist/protocol-BaiWjq5w.js +90 -0
- package/dist/record-bindings-B86Sur_y.cjs +1 -0
- package/dist/{record-bindings-Do_b3h4V.js → record-bindings-D4TuMzHs.js} +10 -11
- package/dist/{region-binding-workflow-BMhK_TjP.js → region-binding-workflow-BNasF5kz.js} +2 -2
- package/dist/{region-binding-workflow-DIYJdCUr.cjs → region-binding-workflow-O2Cni3mF.cjs} +1 -1
- package/dist/report-encoding-worker.cjs +1 -0
- package/dist/report-encoding-worker.d.ts +1 -0
- package/dist/report-encoding-worker.js +2 -0
- package/dist/rich-text-layout-ALlMoYOG.cjs +3 -0
- package/dist/rich-text-layout-Ct5WrY1g.js +102 -0
- package/dist/runtime-DakRXui3.js +170 -0
- package/dist/runtime-dL5ygIfa.cjs +1 -0
- package/dist/sbom.cdx.json +2 -2
- package/dist/server/node.d.cts +132 -1
- package/dist/server/node.d.ts +132 -1
- package/dist/server-node.cjs +5 -1
- package/dist/server-node.js +5177 -463
- package/dist/server.cjs +1 -1
- package/dist/server.d.cts +182 -2
- package/dist/server.d.ts +182 -2
- package/dist/server.js +918 -833
- package/dist/sha256-BshdOkCC.cjs +1 -0
- package/dist/sha256-DTG-Gq8i.js +157 -0
- package/dist/style-67OqfNed.js +73 -0
- package/dist/style-C22Pbv3T.cjs +1 -0
- package/dist/style.css +1 -1
- package/dist/template-catalog-Dua8h9ZA.cjs +1 -0
- package/dist/{template-catalog-j2B1MJlL.js → template-catalog-wT1fNeAP.js} +10 -10
- package/dist/{template-fragments-DcKeiylI.cjs → template-fragments-BajTajb4.cjs} +1 -1
- package/dist/{template-fragments-BGbQLGlV.js → template-fragments-DmX5XK4N.js} +2 -2
- package/dist/template-registry-CpysHAxy.cjs +1 -0
- package/dist/{template-registry-BtaKPELV.js → template-registry-u11fPd8D.js} +389 -321
- package/dist/{textwrap-DE1kgcJB.js → textwrap-BEIg2w8y.js} +1 -1
- package/dist/textwrap-BI-yJ6Wt.cjs +4 -0
- package/dist/{tree-BX380Rr7.cjs → tree-CLpxYbKa.cjs} +1 -1
- package/dist/{tree-CjVZLRw7.js → tree-DNJorJUf.js} +1 -1
- package/dist/vue/async.d.cts +174 -2
- package/dist/vue/async.d.ts +174 -2
- package/dist/vue/index.d.cts +218 -3
- package/dist/vue/index.d.ts +218 -3
- 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-BvToI-Fd.js → workbook-session-B8pNW24X.js} +153 -140
- package/dist/{workbook-session-Bjv1YCRK.cjs → workbook-session-DN5LSA5C.cjs} +12 -12
- package/dist/worker.cjs +1 -1
- package/dist/worker.d.cts +84 -1
- package/dist/worker.d.ts +84 -1
- package/dist/worker.js +12 -157
- package/dist/xlsx-node.cjs +33 -33
- package/dist/xlsx-node.js +1282 -1289
- package/dist/xlsx.cjs +4 -3
- package/dist/xlsx.d.cts +90 -2
- package/dist/xlsx.d.ts +90 -2
- package/dist/xlsx.js +279 -259
- package/package.json +6 -3
- package/dist/ReportPreview-ChV19HBp.js +0 -4619
- package/dist/ReportPreview-DbLvvOUT.cjs +0 -6
- package/dist/RuleEditor-C_Clasvd.js +0 -2037
- package/dist/RuleEditor-XhGHK8DE.cjs +0 -1
- package/dist/assets-B9ImAi6_.cjs +0 -1
- package/dist/assets-DEaz4qsp.js +0 -124
- package/dist/batch-BaP6pWDE.cjs +0 -1
- package/dist/batch-CGyt-b2W.js +0 -273
- package/dist/capabilities-CAh2Nrue.cjs +0 -1
- package/dist/capabilities-DskCHs3V.js +0 -69
- package/dist/computed-C-4C2S5h.js +0 -521
- package/dist/computed-CGV2a809.cjs +0 -1
- package/dist/config-D10us76d.cjs +0 -1
- package/dist/data-explanation-B8MZRYVS.js +0 -16
- package/dist/data-explanation-DE55G30w.cjs +0 -1
- package/dist/dataset-BkRmwgeJ.cjs +0 -1
- package/dist/dataset-H5pFuQGU.js +0 -121
- package/dist/defaults-DXhiM1ZD.js +0 -10
- package/dist/defaults-xhmcLLrf.cjs +0 -1
- package/dist/designer-2bDlcNXQ.js +0 -5136
- package/dist/designer-BT7XCdbW.cjs +0 -2
- package/dist/drill-DYTxuL3A.cjs +0 -1
- package/dist/grid-strokes-Cr7DwUux.cjs +0 -1
- package/dist/grid-strokes-DyyG1q_o.js +0 -53
- package/dist/json-snapshot-DFb2eWkf.js +0 -1416
- package/dist/json-snapshot-WWSGlaHG.cjs +0 -2
- package/dist/matrix-CGRGkn5s.js +0 -112
- package/dist/matrix-gEO7ZM_u.cjs +0 -1
- package/dist/prepared-CFy9B75C.cjs +0 -1
- package/dist/prepared-ajM-H-9B.js +0 -69
- package/dist/record-bindings-By_UKZ2g.cjs +0 -1
- package/dist/render-plan-7xpGrCEl.cjs +0 -1
- package/dist/render-plan-Ck6koX9L.js +0 -13
- package/dist/sha256-ArEYjaTI.cjs +0 -1
- package/dist/sha256-DPEuJ3nh.js +0 -155
- package/dist/style-CQ1PK8ZB.js +0 -67
- package/dist/style-UgIJSA1F.cjs +0 -1
- package/dist/template-catalog-FJE_c9Qe.cjs +0 -1
- package/dist/template-registry-Co1zPq5e.cjs +0 -1
- package/dist/textwrap-CWHyzkBH.cjs +0 -4
package/dist/index.js
CHANGED
|
@@ -1,36 +1,137 @@
|
|
|
1
|
-
import { D as
|
|
2
|
-
import {
|
|
3
|
-
import { R as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { v as
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import { r as
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import { r as
|
|
22
|
-
import {
|
|
23
|
-
import { c as
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
1
|
+
import { D as le, a as J, r as _, b as q, c as Ge, d as Y, e as Je, m as ue, f as Ke, g as ye, p as U, P as oe } from "./style-67OqfNed.js";
|
|
2
|
+
import { C as zr, h as Hr, i as Br, j as _r, L as Wr, M as Vr, S as Ur, k as qr, l as Gr } from "./style-67OqfNed.js";
|
|
3
|
+
import { R as Kr, e as Yr, f as Xr, p as Zr, b as Qr, t as ei, d as ti } from "./record-bindings-D4TuMzHs.js";
|
|
4
|
+
import { i as ce, a as Ye } from "./component-tree-Ca6YYfHq.js";
|
|
5
|
+
import { R as ri } from "./component-tree-Ca6YYfHq.js";
|
|
6
|
+
import { v as Xe, R as Ze, a as pe, p as re, b as St } from "./template-registry-u11fPd8D.js";
|
|
7
|
+
import { c as oi, d as ai, e as si, s as li, f as ci, g as di, h as mi } from "./template-registry-u11fPd8D.js";
|
|
8
|
+
import { v as Et } from "./dataset-DL83majE.js";
|
|
9
|
+
import { d as fi } from "./dataset-DL83majE.js";
|
|
10
|
+
import { h as Me, w as Qe } from "./textwrap-BEIg2w8y.js";
|
|
11
|
+
import { c as ui, a as pi, b as wi, m as bi } from "./textwrap-BEIg2w8y.js";
|
|
12
|
+
import { R as ve, d as Ct, s as et, a as Tt, p as Rt } from "./json-snapshot-DYmEe3sO.js";
|
|
13
|
+
import { D as Mi, P as vi, b as xi, c as Si, e as Ei, f as Ci, g as Ti, h as Ri, i as $i, j as Pi, k as Ai, l as ki, m as Oi, n as Ii, o as Ni, q as Li, r as Di, t as ji, u as Fi, v as zi, w as Hi, x as Bi, y as _i, z as Wi, A as Vi, B as Ui, C as qi, E as Gi } from "./json-snapshot-DYmEe3sO.js";
|
|
14
|
+
import { r as xe } from "./grid-geometry-BNptEcMm.js";
|
|
15
|
+
import { r as Se, d as $t } from "./rich-text-layout-Ct5WrY1g.js";
|
|
16
|
+
import { r as Z, n as tt, O as Pt, a as Ee } from "./assets-BIMVwjQe.js";
|
|
17
|
+
import { b as Ki, i as Yi } from "./assets-BIMVwjQe.js";
|
|
18
|
+
import { o as At, w as Le } from "./progress-Hc2vxoCs.js";
|
|
19
|
+
import { c as kt } from "./drill-CKW3Xtfa.js";
|
|
20
|
+
import { R as Zi, a as Qi, m as eo, r as to, v as no } from "./drill-CKW3Xtfa.js";
|
|
21
|
+
import { R as io, a as oo, f as ao, i as so, b as lo, c as co, p as mo, r as ho, v as fo, d as go } from "./param-validation-Do7Eg8Zv.js";
|
|
22
|
+
import { c as po, a as wo, d as bo, r as yo, b as Mo } from "./template-catalog-wT1fNeAP.js";
|
|
23
|
+
import { c as xo, i as So, t as Eo } from "./template-outline-cnWfT_LK.js";
|
|
24
|
+
import { a as To, c as Ro, i as $o, b as Po } from "./template-fragments-DmX5XK4N.js";
|
|
25
|
+
import { T as ko, c as Oo, v as Io } from "./tree-DNJorJUf.js";
|
|
26
|
+
function we(e, t, n) {
|
|
27
|
+
let r = 0, i = e.length;
|
|
28
|
+
for (; r < i; ) {
|
|
29
|
+
const o = r + i >>> 1;
|
|
30
|
+
n(e[o]) < t ? r = o + 1 : i = o;
|
|
31
|
+
}
|
|
32
|
+
return r;
|
|
33
|
+
}
|
|
34
|
+
function nt(e) {
|
|
35
|
+
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.");
|
|
36
|
+
return e;
|
|
37
|
+
}
|
|
38
|
+
function Ot(e) {
|
|
39
|
+
const t = e.rows.map(() => []);
|
|
40
|
+
for (const n of e.cells) {
|
|
41
|
+
const r = Math.min(t.length, n.ri + (n.cell.rowSpan ?? 1));
|
|
42
|
+
for (let i = n.ri; i < r; i++) t[i].push(n);
|
|
43
|
+
}
|
|
44
|
+
for (const n of t) n.sort((r, i) => r.xMm - i.xMm);
|
|
45
|
+
return {
|
|
46
|
+
cells(n) {
|
|
47
|
+
nt(n);
|
|
48
|
+
const r = /* @__PURE__ */ new Set(), i = n.topMm + n.heightMm, o = n.leftMm + n.widthMm;
|
|
49
|
+
let l = we(e.rows, n.topMm, (s) => s.pos + s.size);
|
|
50
|
+
for (; l < t.length && e.rows[l].pos <= i; ) {
|
|
51
|
+
const s = t[l++];
|
|
52
|
+
let a = we(s, n.leftMm, (c) => c.xMm + c.widthMm);
|
|
53
|
+
for (; a < s.length && s[a].xMm <= o; ) r.add(s[a++]);
|
|
54
|
+
}
|
|
55
|
+
return [...r].sort((s, a) => s.ri - a.ri || s.ci - a.ci);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function It(e) {
|
|
60
|
+
const t = ["h", "v"].map((n) => e.filter((r) => r.kind === n).sort((r, i) => r.pos - i.pos));
|
|
61
|
+
return (n) => {
|
|
62
|
+
const r = [];
|
|
63
|
+
return t.forEach((i, o) => {
|
|
64
|
+
const l = o === 0 ? n.topMm : n.leftMm, s = l + (o === 0 ? n.heightMm : n.widthMm), a = o === 0 ? n.leftMm : n.topMm, c = a + (o === 0 ? n.widthMm : n.heightMm);
|
|
65
|
+
let d = we(i, l, (m) => m.pos);
|
|
66
|
+
for (; d < i.length && i[d].pos <= s; ) {
|
|
67
|
+
const m = i[d++];
|
|
68
|
+
m.to >= a && m.from <= c && r.push(m);
|
|
69
|
+
}
|
|
70
|
+
}), r;
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function Nt() {
|
|
74
|
+
const e = [];
|
|
75
|
+
return {
|
|
76
|
+
mount(t) {
|
|
77
|
+
e.push(Ft(t));
|
|
78
|
+
},
|
|
79
|
+
update(t, n, r) {
|
|
80
|
+
nt(t);
|
|
81
|
+
let i = !1;
|
|
82
|
+
for (const o of e) i = o.update(t, o.component === n ? r : void 0) || i;
|
|
83
|
+
return i;
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
function Lt(e, t) {
|
|
88
|
+
const n = Math.max(8, e.widthMm / 4), r = Math.max(8, e.heightMm / 4);
|
|
89
|
+
return {
|
|
90
|
+
leftMm: e.leftMm - t.leftMm - n,
|
|
91
|
+
topMm: e.topMm - t.topMm - r,
|
|
92
|
+
widthMm: e.widthMm + 2 * n,
|
|
93
|
+
heightMm: e.heightMm + 2 * r
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
function Dt(e, t, n) {
|
|
97
|
+
let r = t.get(n);
|
|
98
|
+
return r || (r = e.table.ownerDocument.createElement("tr"), r.className = e.rowClass, r.setAttribute("role", "row"), r.setAttribute("aria-rowindex", String(n + 1)), r.style.cssText = "all:unset;display:contents;box-sizing:border-box", t.set(n, r)), r;
|
|
99
|
+
}
|
|
100
|
+
function jt(e, t, n, r) {
|
|
101
|
+
const i = new Set(t), o = new Set(t.map((s) => s.ri));
|
|
102
|
+
for (const [s, a] of n) i.has(s) || (a.remove(), n.delete(s));
|
|
103
|
+
for (const [s, a] of r) o.has(s) || (a.remove(), r.delete(s));
|
|
104
|
+
for (const s of t) {
|
|
105
|
+
let a = n.get(s);
|
|
106
|
+
a || (a = e.drawCell(s), a.setAttribute("aria-colindex", String(s.ci + 1)), n.set(s, a));
|
|
107
|
+
const c = Dt(e, r, s.ri);
|
|
108
|
+
a.parentElement !== c && c.appendChild(a);
|
|
109
|
+
}
|
|
110
|
+
const l = /* @__PURE__ */ new Map();
|
|
111
|
+
for (const s of t) {
|
|
112
|
+
const a = l.get(s.ri) ?? [];
|
|
113
|
+
a.push(n.get(s)), l.set(s.ri, a);
|
|
114
|
+
}
|
|
115
|
+
for (const [s, a] of l) De(r.get(s), a);
|
|
116
|
+
De(e.body, [...o].sort((s, a) => s - a).map((s) => r.get(s)));
|
|
117
|
+
}
|
|
118
|
+
function De(e, t) {
|
|
119
|
+
let n = e.firstElementChild;
|
|
120
|
+
for (const r of t)
|
|
121
|
+
r === n ? n = n.nextElementSibling : e.insertBefore(r, n);
|
|
122
|
+
}
|
|
123
|
+
function Ft(e) {
|
|
124
|
+
const t = xe(e.grid, e.component.widthMm, e.component.heightMm), n = new Map(t.cells.map((c) => [`${c.ri}:${c.ci}`, c])), r = Ot(t), i = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), l = It(Se(t, e.component));
|
|
125
|
+
e.table.setAttribute("aria-rowcount", String(t.rows.length)), e.table.setAttribute("aria-colcount", String(t.columns.length));
|
|
126
|
+
let s = "", a = "";
|
|
127
|
+
return { component: e.component, update(c, d) {
|
|
128
|
+
const m = Lt(c, e.component), h = r.cells(m), f = d && n.get(`${d.rowIndex}:${d.columnIndex}`);
|
|
129
|
+
f && !h.includes(f) && h.push(f), h.sort((y, N) => y.ri - N.ri || y.ci - N.ci);
|
|
130
|
+
const g = h.map((y) => `${y.ri}:${y.ci}`).join(";"), C = l(m), S = C.map((y) => `${y.kind}:${y.pos}:${y.from}:${y.to}`).join(";"), w = g !== s, v = S !== a;
|
|
131
|
+
return w && (s = g, jt(e, h, i, o)), v && (a = S, e.edgeHost.replaceChildren(...e.drawEdges(C))), w || v;
|
|
132
|
+
} };
|
|
133
|
+
}
|
|
134
|
+
const rt = /* @__PURE__ */ new WeakMap(), zt = {
|
|
34
135
|
root: "mr-root",
|
|
35
136
|
page: "mr-page",
|
|
36
137
|
comp: "mr-comp",
|
|
@@ -47,18 +148,18 @@ const it = {
|
|
|
47
148
|
cell: "mr-cell",
|
|
48
149
|
unknown: "mr-unknown"
|
|
49
150
|
};
|
|
50
|
-
function
|
|
51
|
-
return t?.classNames?.[e] ??
|
|
151
|
+
function $(e, t) {
|
|
152
|
+
return t?.classNames?.[e] ?? zt[e];
|
|
52
153
|
}
|
|
53
|
-
class
|
|
154
|
+
class Ht {
|
|
54
155
|
constructor() {
|
|
55
156
|
this.props = [];
|
|
56
157
|
}
|
|
57
158
|
add(t, n) {
|
|
58
159
|
return n == null || n === !1 || n === "" ? this : (this.props.push([t, String(n)]), this);
|
|
59
160
|
}
|
|
60
|
-
mm(t, n, r,
|
|
61
|
-
return this.add(t, `${
|
|
161
|
+
mm(t, n, r, i = 2) {
|
|
162
|
+
return this.add(t, `${J(ue(n, r), i)}px`);
|
|
62
163
|
}
|
|
63
164
|
toString() {
|
|
64
165
|
let t = "";
|
|
@@ -71,522 +172,582 @@ class ot {
|
|
|
71
172
|
n && (t.style.cssText = n);
|
|
72
173
|
}
|
|
73
174
|
}
|
|
74
|
-
function
|
|
75
|
-
return new
|
|
175
|
+
function x(e, t = "unset") {
|
|
176
|
+
return new Ht().add("all", t).add("display", e).add("box-sizing", "border-box");
|
|
76
177
|
}
|
|
77
|
-
function
|
|
78
|
-
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(
|
|
178
|
+
function it(e, t, n) {
|
|
179
|
+
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(q(t))).add("text-align", t.align);
|
|
79
180
|
const r = _(t, n);
|
|
80
|
-
e.add("font-size", `${
|
|
181
|
+
e.add("font-size", `${J(r.fontSizePx, 2)}px`);
|
|
81
182
|
}
|
|
82
|
-
function
|
|
183
|
+
function Bt(e, t, n) {
|
|
83
184
|
const r = t.style ?? {};
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
function
|
|
87
|
-
const l = e.cell,
|
|
88
|
-
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
for (const
|
|
94
|
-
return
|
|
95
|
-
}
|
|
96
|
-
function
|
|
97
|
-
return
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
185
|
+
it(e, r, n), e.add("background-color", r.backgroundColor).add("opacity", r.opacity != null ? String(r.opacity) : void 0).add("transform", r.rotateDeg ? `rotate(${r.rotateDeg}deg)` : void 0);
|
|
186
|
+
}
|
|
187
|
+
function je(e, t, n, r, i, o) {
|
|
188
|
+
const l = e.cell, s = o.createElement("td");
|
|
189
|
+
s.className = $("cell", i), s.dataset.mrRowIndex = String(e.ri), s.dataset.mrColumnIndex = String(e.ci), s.setAttribute("role", t.table?.role === "header" ? "columnheader" : "cell"), l.colSpan && (s.colSpan = l.colSpan), l.rowSpan && (s.rowSpan = l.rowSpan);
|
|
190
|
+
const a = Ke(t.style, l.style), c = x("block").add("position", "absolute").mm("left", e.xMm, r).mm("top", e.yMm, r).mm("width", e.widthMm, r).mm("height", e.heightMm, r).add("background-color", a.backgroundColor).add("vertical-align", a.verticalAlign ?? "middle");
|
|
191
|
+
it(c, a, r), c.applyTo(s);
|
|
192
|
+
const d = o.createElement("div");
|
|
193
|
+
d.className = "mr-cell-content", x("flex").add("position", "absolute").mm("left", n + (l.indentMm ?? 0), r).mm("right", n, r).mm("top", n, r).mm("bottom", n, r).add("flex-direction", "column").add("justify-content", a.verticalAlign === "top" ? "flex-start" : a.verticalAlign === "bottom" ? "flex-end" : "center").add("overflow-wrap", "anywhere").add("overflow", "hidden").applyTo(d), l.richParagraphs?.length ? d.appendChild(at({ ...t, kind: "text", richParagraphs: l.richParagraphs }, r, i, o)) : l.text != null && d.append(l.text);
|
|
194
|
+
for (const m of l.children ?? []) d.appendChild(st(m, r, i, o));
|
|
195
|
+
return s.appendChild(d), s;
|
|
196
|
+
}
|
|
197
|
+
function _t(e, t, n, r) {
|
|
198
|
+
return ot(Se(e, t), n, r);
|
|
199
|
+
}
|
|
200
|
+
function ot(e, t, n) {
|
|
201
|
+
return e.map((r) => {
|
|
202
|
+
const i = `${J(r.widthPt * t / 72, 2)}px solid ${r.color}`, o = n.createElement("div");
|
|
203
|
+
o.className = "mr-grid-edge", o.setAttribute("aria-hidden", "true");
|
|
204
|
+
const l = r.kind === "h";
|
|
205
|
+
return x("block").add("position", "absolute").add("pointer-events", "none").mm("left", l ? r.from : r.pos, t).mm("top", l ? r.pos : r.from, t).mm("width", l ? r.to - r.from : 0, t).mm("height", l ? 0 : r.to - r.from, t).add(l ? "border-top" : "border-left", i).applyTo(o), o;
|
|
102
206
|
});
|
|
103
207
|
}
|
|
104
|
-
function
|
|
105
|
-
const o =
|
|
106
|
-
o.className =
|
|
107
|
-
const l =
|
|
108
|
-
|
|
109
|
-
const s =
|
|
110
|
-
|
|
111
|
-
|
|
208
|
+
function Wt(e, t, n, r, i) {
|
|
209
|
+
const o = i.createElement("table");
|
|
210
|
+
o.className = $("grid", r), o.setAttribute("role", "table"), x("block").add("position", "relative").add("width", "100%").add("height", "100%").applyTo(o);
|
|
211
|
+
const l = i.createElement("tbody");
|
|
212
|
+
x("contents").applyTo(l), o.appendChild(l);
|
|
213
|
+
const s = t.style?.rotateDeg ? void 0 : rt.get(r);
|
|
214
|
+
if (s) {
|
|
215
|
+
const m = i.createElement("div");
|
|
216
|
+
x("block").add("position", "relative").add("width", "100%").add("height", "100%").applyTo(m);
|
|
217
|
+
const h = i.createElement("div");
|
|
218
|
+
return x("contents").applyTo(h), h.setAttribute("aria-hidden", "true"), s.mount({
|
|
219
|
+
grid: e,
|
|
220
|
+
component: t,
|
|
221
|
+
table: o,
|
|
222
|
+
rowClass: $("row", r),
|
|
223
|
+
body: l,
|
|
224
|
+
edgeHost: h,
|
|
225
|
+
drawCell: (f) => je(f, t, e.paddingMm ?? 0.5, n, { ...r }, i),
|
|
226
|
+
drawEdges: (f) => ot(f, n, i)
|
|
227
|
+
}), m.append(o, h), m;
|
|
228
|
+
}
|
|
229
|
+
const a = xe(e, t.widthMm, t.heightMm), c = e.cells.map(() => {
|
|
230
|
+
const m = i.createElement("tr");
|
|
231
|
+
return m.className = $("row", r), m.setAttribute("role", "row"), x("contents").applyTo(m), l.appendChild(m), m;
|
|
112
232
|
});
|
|
113
|
-
for (const m of
|
|
114
|
-
|
|
115
|
-
const
|
|
116
|
-
return
|
|
117
|
-
}
|
|
118
|
-
function
|
|
119
|
-
const
|
|
120
|
-
|
|
233
|
+
for (const m of a.cells)
|
|
234
|
+
c[m.ri].appendChild(je(m, t, e.paddingMm ?? 0.5, n, r, i));
|
|
235
|
+
const d = i.createElement("div");
|
|
236
|
+
return x("block").add("position", "relative").add("width", "100%").add("height", "100%").applyTo(d), d.append(o, ..._t(a, t, n, i)), d;
|
|
237
|
+
}
|
|
238
|
+
function Vt(e, t, n, r) {
|
|
239
|
+
const i = r.createElement("div");
|
|
240
|
+
i.className = $("paragraph", n), x("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(i);
|
|
121
241
|
for (const o of e.segments || []) {
|
|
122
242
|
const l = r.createElement("span");
|
|
123
|
-
l.className =
|
|
124
|
-
const
|
|
243
|
+
l.className = $("segment", n), l.textContent = o.kind === "field" ? o.field ?? "" : o.text ?? "";
|
|
244
|
+
const s = x("inline");
|
|
125
245
|
if (o.style) {
|
|
126
|
-
const
|
|
127
|
-
|
|
246
|
+
const a = o.style;
|
|
247
|
+
s.add("color", a.color).add("background-color", a.backgroundColor).add("font-family", a.fontFamily).add("line-height", a.lineHeight).add("letter-spacing", a.letterSpacing == null ? void 0 : `${a.letterSpacing * t / 72}px`).add("font-weight", a.bold != null ? a.bold ? "700" : "400" : void 0).add("font-style", a.italic != null ? a.italic ? "italic" : "normal" : void 0).add("text-decoration", a.underline != null ? a.underline ? "underline" : "none" : void 0), (a.fontSize != null || a.fontSizePx != null) && s.add("font-size", `${J(_(a, t).fontSizePx, 2)}px`);
|
|
128
248
|
}
|
|
129
|
-
|
|
249
|
+
s.applyTo(l), i.appendChild(l);
|
|
130
250
|
}
|
|
131
|
-
return
|
|
132
|
-
}
|
|
133
|
-
function
|
|
134
|
-
if (
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
for (const o of e.richParagraphs)
|
|
138
|
-
return
|
|
251
|
+
return i;
|
|
252
|
+
}
|
|
253
|
+
function at(e, t, n, r) {
|
|
254
|
+
if (Ye(e)) {
|
|
255
|
+
const i = r.createElement("div");
|
|
256
|
+
i.className = $("rich", n), x("block").applyTo(i);
|
|
257
|
+
for (const o of e.richParagraphs) i.appendChild(Vt(o, t, n, r));
|
|
258
|
+
return i;
|
|
139
259
|
}
|
|
140
260
|
if (Array.isArray(e.lines) && e.lines.length > 0) {
|
|
141
|
-
const
|
|
142
|
-
|
|
261
|
+
const i = r.createElement("div");
|
|
262
|
+
i.className = $("lines", n), x("block").applyTo(i);
|
|
143
263
|
for (const o of e.lines) {
|
|
144
264
|
const l = r.createElement("div");
|
|
145
|
-
l.className =
|
|
265
|
+
l.className = $("line", n), l.textContent = o, x("block").add("white-space", "pre").add("min-height", "1lh").applyTo(l), i.appendChild(l);
|
|
146
266
|
}
|
|
147
|
-
return
|
|
267
|
+
return i;
|
|
148
268
|
}
|
|
149
269
|
return e.text ?? "";
|
|
150
270
|
}
|
|
151
|
-
function
|
|
152
|
-
const
|
|
153
|
-
|
|
271
|
+
function Ut(e, t, n, r) {
|
|
272
|
+
const i = r.createElement("div");
|
|
273
|
+
i.className = $("text", n);
|
|
154
274
|
const o = e.style || {};
|
|
155
|
-
return
|
|
275
|
+
return x("flex").add("width", "100%").add("height", "100%").add("flex-direction", "column").add("justify-content", o.verticalAlign === "middle" ? "center" : o.verticalAlign === "bottom" ? "flex-end" : "flex-start").add("overflow-wrap", "anywhere").add("overflow", "hidden").applyTo(i), i.append(at(e, t, n, r)), i;
|
|
156
276
|
}
|
|
157
|
-
function
|
|
277
|
+
function qt(e, t, n) {
|
|
158
278
|
const r = n.createElement("img");
|
|
159
|
-
return r.className =
|
|
279
|
+
return r.className = $("image", t), r.src = e.imageData, x("block").add("width", "100%").add("height", "100%").add("object-fit", "contain").applyTo(r), r.alt = e.kind, r;
|
|
160
280
|
}
|
|
161
|
-
function
|
|
162
|
-
const
|
|
163
|
-
|
|
164
|
-
const o = e.style || {}, l =
|
|
165
|
-
return e.grid ? c.add("position", "relative") : e.kind === "rect" ? (
|
|
281
|
+
function Fe(e, t, n, r) {
|
|
282
|
+
const i = r.createElement("div");
|
|
283
|
+
i.className = $("shape", n);
|
|
284
|
+
const o = e.style || {}, l = Y(o), s = Je(o), a = `${J(l.widthPt * t / 72, 2)}px solid ${l.color}`, c = x("block");
|
|
285
|
+
return e.grid ? c.add("position", "relative") : e.kind === "rect" ? (s.top && c.add("border-top", a), s.right && c.add("border-right", a), s.bottom && c.add("border-bottom", a), s.left && c.add("border-left", a)) : e.kind === "ellipse" ? (s.inner && c.add("border", a).add("border-radius", "50%"), o.backgroundColor && c.add("background-color", o.backgroundColor)) : e.kind === "line" && c.add("height", "0").add("border-top", a), c.add("box-sizing", "border-box").add("width", "100%").add("height", "100%"), c.applyTo(i), i;
|
|
166
286
|
}
|
|
167
|
-
function
|
|
168
|
-
const r = n.createElementNS("http://www.w3.org/2000/svg", "svg"),
|
|
169
|
-
r.setAttribute("width", String(Math.max(1,
|
|
287
|
+
function Gt(e, t, n) {
|
|
288
|
+
const r = n.createElementNS("http://www.w3.org/2000/svg", "svg"), i = ue(e.widthMm, t), o = ue(e.heightMm, t);
|
|
289
|
+
r.setAttribute("width", String(Math.max(1, i))), r.setAttribute("height", String(Math.max(1, o))), r.setAttribute("aria-hidden", "true"), r.style.overflow = "visible", r.style.display = "block";
|
|
170
290
|
const l = n.createElementNS("http://www.w3.org/2000/svg", "line");
|
|
171
|
-
l.setAttribute("x1", "0"), l.setAttribute("x2", String(
|
|
172
|
-
const
|
|
173
|
-
return l.setAttribute("stroke",
|
|
174
|
-
}
|
|
175
|
-
function
|
|
176
|
-
const
|
|
177
|
-
|
|
178
|
-
const o =
|
|
179
|
-
if (
|
|
180
|
-
return
|
|
291
|
+
l.setAttribute("x1", "0"), l.setAttribute("x2", String(i)), l.setAttribute("y1", e.lineDirection === "up" ? String(o) : "0"), l.setAttribute("y2", e.lineDirection === "up" ? "0" : String(o));
|
|
292
|
+
const s = Y({ ...e.style, borderColor: e.style?.lineColor ?? e.style?.borderColor });
|
|
293
|
+
return l.setAttribute("stroke", s.color), l.setAttribute("stroke-width", String(s.widthPt * t / 72)), r.appendChild(l), r;
|
|
294
|
+
}
|
|
295
|
+
function st(e, t, n, r) {
|
|
296
|
+
const i = r.createElement("div");
|
|
297
|
+
i.className = `${$("comp", n)} mr-kind-${e.kind}`;
|
|
298
|
+
const o = x("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");
|
|
299
|
+
if (Bt(o, e, t), o.applyTo(i), ce(e))
|
|
300
|
+
return i.appendChild(qt(e, n, r)), i;
|
|
181
301
|
if (e.kind === "text")
|
|
182
|
-
return
|
|
302
|
+
return i.appendChild(Ut(e, t, n, r)), i;
|
|
183
303
|
if (e.grid) {
|
|
184
|
-
const
|
|
185
|
-
return
|
|
304
|
+
const s = Fe(e, t, n, r);
|
|
305
|
+
return s.appendChild(Wt(e.grid, e, t, n, r)), i.appendChild(s), i;
|
|
186
306
|
}
|
|
187
307
|
if (e.kind === "line" && e.lineDirection)
|
|
188
|
-
return
|
|
308
|
+
return i.appendChild(Gt(e, t, r)), i;
|
|
189
309
|
if (e.kind === "line" || e.kind === "rect" || e.kind === "ellipse")
|
|
190
|
-
return
|
|
310
|
+
return i.appendChild(Fe(e, t, n, r)), i;
|
|
191
311
|
const l = r.createElement("div");
|
|
192
|
-
return l.className =
|
|
312
|
+
return l.className = $("unknown", n), x("block").applyTo(l), l.textContent = e.fallbackText ?? `[${e.kind}]`, l.dataset.mrUnsupported = e.kind, l.setAttribute("role", "note"), i.appendChild(l), i;
|
|
193
313
|
}
|
|
194
|
-
function
|
|
195
|
-
const
|
|
196
|
-
return
|
|
197
|
-
const
|
|
198
|
-
|
|
199
|
-
}),
|
|
314
|
+
function lt(e, t, n, r) {
|
|
315
|
+
const i = r.createElement("div");
|
|
316
|
+
return i.className = $("page", n), x("block", "initial").add("position", "relative").add("font-family", le).add("font-size", `${J(_(void 0, t).fontSizePx, 2)}px`).add("line-height", String(q(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", Ge).add("overflow", "hidden").add("box-sizing", "border-box").applyTo(i), e.components.forEach((o, l) => {
|
|
317
|
+
const s = st(o, t, n, r);
|
|
318
|
+
s.dataset.mrComponentIndex = String(l), i.appendChild(s);
|
|
319
|
+
}), i;
|
|
200
320
|
}
|
|
201
|
-
function
|
|
321
|
+
function pr(e, t, n = {}) {
|
|
202
322
|
const r = n.dpi ?? 96;
|
|
203
|
-
|
|
204
|
-
const
|
|
205
|
-
return
|
|
206
|
-
|
|
207
|
-
}),
|
|
323
|
+
Z(e, "dom", n);
|
|
324
|
+
const i = t.createElement("div");
|
|
325
|
+
return i.className = $("root", n), x("block").applyTo(i), i.dataset.schemaVersion = e.schemaVersion, e.pages.forEach((o) => {
|
|
326
|
+
i.appendChild(lt(o, r, n, t));
|
|
327
|
+
}), i;
|
|
328
|
+
}
|
|
329
|
+
function wr(e, t, n, r) {
|
|
330
|
+
const i = { ...n }, o = Nt();
|
|
331
|
+
return rt.set(i, o), { element: lt(e, t, i, r), update(s, a) {
|
|
332
|
+
return o.update(s, a && e.components[a.componentIndex], a);
|
|
333
|
+
} };
|
|
334
|
+
}
|
|
335
|
+
function Ce(e, t, n, r, i, o, l, s = "top") {
|
|
336
|
+
e.font = `${t.italic ? "italic " : ""}${t.bold ? "bold " : ""}${t.fontSizePx}px ${l}`, "letterSpacing" in e && (e.letterSpacing = "0px"), e.fillStyle = t.color, e.textBaseline = "alphabetic";
|
|
337
|
+
const a = t.fontSizePx * t.lineHeight, c = t.text === "" ? [""] : t.text.split(`
|
|
338
|
+
`), d = c.length * a;
|
|
339
|
+
let m = r;
|
|
340
|
+
s === "middle" ? m = r + (o - d) / 2 : s === "bottom" && (m = r + o - d), c.forEach((h, f) => {
|
|
341
|
+
const g = m + f * a + t.fontSizePx * 0.8;
|
|
342
|
+
Jt(e, h, t, n, g, i), t.underline && h && Kt(e, h, t, n, g, i);
|
|
343
|
+
}), e.textAlign = "left";
|
|
208
344
|
}
|
|
209
|
-
function
|
|
345
|
+
function Jt(e, t, n, r, i, o) {
|
|
346
|
+
const l = Array.from(t), s = n.letterSpacingPx ?? 0;
|
|
347
|
+
if (!s) {
|
|
348
|
+
e.textAlign = n.align === "center" ? "center" : n.align === "right" ? "right" : "left";
|
|
349
|
+
const m = n.align === "center" ? r + o / 2 : n.align === "right" ? r + o : r;
|
|
350
|
+
e.fillText(t, m, i);
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
const a = e.measureText(t).width + Math.max(0, l.length - 1) * s, c = n.align === "center" ? r + (o - a) / 2 : n.align === "right" ? r + o - a : r;
|
|
354
|
+
e.textAlign = "left";
|
|
355
|
+
let d = "";
|
|
356
|
+
l.forEach((m, h) => {
|
|
357
|
+
e.fillText(m, c + e.measureText(d).width + h * s, i), d += m;
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
function Kt(e, t, n, r, i, o) {
|
|
361
|
+
const l = e.measureText(t).width + Math.max(0, Array.from(t).length - 1) * (n.letterSpacingPx ?? 0), s = n.align === "center" ? r + (o - l) / 2 : n.align === "right" ? r + o - l : r;
|
|
362
|
+
e.strokeStyle = n.color, e.lineWidth = Math.max(0.5, n.fontSizePx / 20), e.beginPath(), e.moveTo(s, i + 1), e.lineTo(s + l, i + 1), e.stroke();
|
|
363
|
+
}
|
|
364
|
+
function ct(e, t, n, r, i) {
|
|
365
|
+
const o = r / 72, l = (s) => {
|
|
366
|
+
e.font = `${s.italic ? "italic " : ""}${s.bold ? "bold " : ""}${_(s, r).fontSizePx}px ${s.fontFamily ?? i}`, "letterSpacing" in e && (e.letterSpacing = "0px");
|
|
367
|
+
};
|
|
368
|
+
$t(t, { x: n.x / o, yTop: -n.y / o, width: n.width / o, height: n.height / o }, {
|
|
369
|
+
measure(s, a) {
|
|
370
|
+
return l(a), e.measureText(s).width / o + (a.letterSpacing ?? 0);
|
|
371
|
+
},
|
|
372
|
+
draw(s, a, c, d, m) {
|
|
373
|
+
const h = _(a, r).fontSizePx, f = -d * o - h * 0.8;
|
|
374
|
+
a.backgroundColor && (e.fillStyle = a.backgroundColor, e.fillRect(c * o, f, m * o, h * q(a))), Ce(e, { text: s, fontSizePx: h, bold: !!a.bold, italic: a.italic, underline: a.underline, color: ye(a), align: "left", lineHeight: q(a), letterSpacingPx: (a.letterSpacing ?? 0) * o }, c * o, f, m * o, h, a.fontFamily ?? i);
|
|
375
|
+
}
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
function k(e) {
|
|
210
379
|
if (e?.aborted) throw e.reason ?? new DOMException("The operation was aborted.", "AbortError");
|
|
211
380
|
}
|
|
212
|
-
const
|
|
213
|
-
const
|
|
214
|
-
|
|
381
|
+
const Yt = (e, t) => (k(t), /^data:image\/(?:png|jpe?g|webp|gif|svg\+xml)[;,]/i.test(e) ? new Promise((n, r) => {
|
|
382
|
+
const i = new Image(), o = () => {
|
|
383
|
+
i.onload = null, i.onerror = null, t?.removeEventListener("abort", l);
|
|
215
384
|
}, l = () => {
|
|
216
|
-
o(),
|
|
385
|
+
o(), i.src = "", r(t?.reason ?? new DOMException("The operation was aborted.", "AbortError"));
|
|
217
386
|
};
|
|
218
|
-
|
|
219
|
-
o(), n(
|
|
220
|
-
},
|
|
387
|
+
i.onload = () => {
|
|
388
|
+
o(), n(i);
|
|
389
|
+
}, i.onerror = () => {
|
|
221
390
|
o(), r(new Error("Image could not be decoded for Canvas output."));
|
|
222
|
-
}, t?.addEventListener("abort", l, { once: !0 }),
|
|
391
|
+
}, t?.addEventListener("abort", l, { once: !0 }), i.src = e;
|
|
223
392
|
}) : Promise.reject(new TypeError("Canvas imageData must be an image data URL; provide imageLoader for other sources.")));
|
|
224
|
-
function
|
|
225
|
-
return
|
|
226
|
-
const o = () =>
|
|
227
|
-
n.addEventListener("abort", o, { once: !0 }), Promise.resolve().then(() => e(t, n)).then(r,
|
|
393
|
+
function Xt(e, t, n) {
|
|
394
|
+
return k(n), n ? new Promise((r, i) => {
|
|
395
|
+
const o = () => i(n.reason ?? new DOMException("The operation was aborted.", "AbortError"));
|
|
396
|
+
n.addEventListener("abort", o, { once: !0 }), Promise.resolve().then(() => e(t, n)).then(r, i).finally(() => n.removeEventListener("abort", o));
|
|
228
397
|
}) : e(t);
|
|
229
398
|
}
|
|
230
|
-
|
|
399
|
+
function* Te(e) {
|
|
400
|
+
function* t(n, r, i, o) {
|
|
401
|
+
if (o.has(n)) throw new TypeError("Cyclic grid children cannot be rendered.");
|
|
402
|
+
ce(n) && (yield { component: n, componentIndex: r, componentPath: i });
|
|
403
|
+
const l = new Set(o).add(n);
|
|
404
|
+
for (const [s, a] of (n.grid?.cells ?? []).entries()) for (const [c, d] of a.entries()) for (const [m, h] of (d?.children ?? []).entries()) yield* t(h, r, [...i, s, c, m], l);
|
|
405
|
+
}
|
|
406
|
+
for (const [n, r] of e.components.entries()) yield* t(r, n, [], /* @__PURE__ */ new Set());
|
|
407
|
+
}
|
|
408
|
+
async function Zt(e, t, n) {
|
|
231
409
|
const r = /* @__PURE__ */ new Map();
|
|
232
|
-
for (const
|
|
233
|
-
!
|
|
234
|
-
return
|
|
235
|
-
}
|
|
236
|
-
function
|
|
237
|
-
const l = t,
|
|
238
|
-
if (
|
|
239
|
-
const c = Math.min(
|
|
240
|
-
e.drawImage(t, n + (
|
|
241
|
-
}
|
|
242
|
-
function
|
|
243
|
-
return
|
|
244
|
-
}
|
|
245
|
-
const
|
|
246
|
-
function
|
|
247
|
-
const n = t / 96 *
|
|
410
|
+
for (const { component: i } of Te(e))
|
|
411
|
+
!ce(i) || r.has(i.imageData) || r.set(i.imageData, await Xt(t, i.imageData, n));
|
|
412
|
+
return k(n), r;
|
|
413
|
+
}
|
|
414
|
+
function Qt(e, t, n, r, i, o) {
|
|
415
|
+
const l = t, s = l.naturalWidth ?? l.width ?? i, a = l.naturalHeight ?? l.height ?? o;
|
|
416
|
+
if (s <= 0 || a <= 0) throw new RangeError("Decoded Canvas image dimensions must be positive.");
|
|
417
|
+
const c = Math.min(i / s, o / a), d = s * c, m = a * c;
|
|
418
|
+
e.drawImage(t, n + (i - d) / 2, r + (o - m) / 2, d, m);
|
|
419
|
+
}
|
|
420
|
+
function en(e) {
|
|
421
|
+
return kt(e.pageHeightsPx, e.gapPx).window(e.viewportHeightPx, e.scrollTopPx, e.overscan);
|
|
422
|
+
}
|
|
423
|
+
const Re = 96 / 25.4;
|
|
424
|
+
function $e(e, t = 96) {
|
|
425
|
+
const n = t / 96 * Re;
|
|
248
426
|
return {
|
|
249
427
|
widthPx: Math.max(1, Math.round(e.pageWidthMm * n)),
|
|
250
428
|
heightPx: Math.max(1, Math.round(e.pageHeightMm * n))
|
|
251
429
|
};
|
|
252
430
|
}
|
|
253
|
-
function
|
|
431
|
+
function dt(e, t, n, r = 64e6) {
|
|
254
432
|
if (!Number.isFinite(t) || t <= 0 || !Number.isFinite(n) || n <= 0) throw new RangeError("Canvas dpr and dpi must be positive finite numbers.");
|
|
255
433
|
if (!Number.isFinite(r) || r <= 0) throw new RangeError("maxCanvasPixels must be positive and finite.");
|
|
256
|
-
const
|
|
434
|
+
const i = $e(e, n), o = Math.round(i.widthPx * t), l = Math.round(i.heightPx * t);
|
|
257
435
|
if (!Number.isSafeInteger(o) || !Number.isSafeInteger(l) || o * l > r) throw new RangeError("Canvas page exceeds maxCanvasPixels; reduce resolution or split the report.");
|
|
258
436
|
return { width: o, height: l };
|
|
259
437
|
}
|
|
260
|
-
function
|
|
261
|
-
const
|
|
262
|
-
|
|
263
|
-
const
|
|
264
|
-
if (!
|
|
438
|
+
function mt(e, t, n, r) {
|
|
439
|
+
const i = document.createElement("canvas"), { widthPx: o, heightPx: l } = $e(e, n), s = dt(e, t, n, r);
|
|
440
|
+
i.width = s.width, i.height = s.height, i.style.width = `${o}px`, i.style.height = `${l}px`;
|
|
441
|
+
const a = i.getContext("2d");
|
|
442
|
+
if (!a)
|
|
265
443
|
throw new Error("当前环境不支持 Canvas 2D(测试需真浏览器,见 e2e/canvas.spec.ts)");
|
|
266
|
-
return
|
|
444
|
+
return a.scale(t, t), a.fillStyle = "#ffffff", a.fillRect(0, 0, o, l), { canvas: i, ctx: a };
|
|
267
445
|
}
|
|
268
|
-
function
|
|
446
|
+
function br(e, t = 96) {
|
|
269
447
|
return _(e, t).fontSizePx;
|
|
270
448
|
}
|
|
271
|
-
function
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
`), m = c.length * s;
|
|
275
|
-
let d = r;
|
|
276
|
-
i === "middle" ? d = r + (o - m) / 2 : i === "bottom" && (d = r + o - m), c.forEach((h, g) => {
|
|
277
|
-
xt(e, h, t, n, d + g * s + t.fontSizePx * 0.8, a);
|
|
278
|
-
}), e.textAlign = "left";
|
|
449
|
+
function tn(e, t, n, r, i, o, l) {
|
|
450
|
+
for (const s of Se(t, n))
|
|
451
|
+
e.strokeStyle = s.color, e.lineWidth = U(s.widthPt, l), e.beginPath(), s.kind === "v" ? (e.moveTo(r + s.pos * o, i + s.from * o), e.lineTo(r + s.pos * o, i + s.to * o)) : (e.moveTo(r + s.from * o, i + s.pos * o), e.lineTo(r + s.to * o, i + s.pos * o)), e.stroke();
|
|
279
452
|
}
|
|
280
|
-
function
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
453
|
+
function nn(e, t, n, r, i, o) {
|
|
454
|
+
e.beginPath(), t.top && (e.moveTo(n, r), e.lineTo(n + i, r)), t.right && (e.moveTo(n + i, r), e.lineTo(n + i, r + o)), t.bottom && (e.moveTo(n + i, r + o), e.lineTo(n, r + o)), t.left && (e.moveTo(n, r + o), e.lineTo(n, r)), e.stroke();
|
|
455
|
+
}
|
|
456
|
+
function rn(e, t, n, r, i, o, l, s, a, c, d, m) {
|
|
457
|
+
const h = xe(t, o / s, l / s);
|
|
458
|
+
for (const f of h.cells) {
|
|
459
|
+
const g = f.cell.style?.backgroundColor ?? n.style?.backgroundColor;
|
|
460
|
+
g && (e.fillStyle = g, e.fillRect(r + f.xMm * s, i + f.yMm * s, f.widthMm * s, f.heightMm * s));
|
|
461
|
+
}
|
|
462
|
+
tn(e, h, n, r, i, s, a);
|
|
463
|
+
for (const f of h.cells) on(e, f, n, r, i, s, a, c, d, m);
|
|
464
|
+
}
|
|
465
|
+
function on(e, t, n, r, i, o, l, s, a, c) {
|
|
466
|
+
const d = n.grid?.paddingMm ?? 0.5, m = t.cell.text ?? "", h = Ke(n.style, t.cell.style), f = _(h, l), g = t.cell.indentMm ?? 0, C = Math.max(0, t.widthMm - 2 * d - g), S = Qe(m, C, { fontSizePt: f.fontSizePt, bold: h.bold, italic: h.italic, fontFamily: h.fontFamily ?? s, letterSpacingPt: h.letterSpacing }, a).join(`
|
|
467
|
+
`), w = { x: r + (t.xMm + d + g) * o, y: i + (t.yMm + d) * o, width: C * o, height: Math.max(0, t.heightMm - 2 * d) * o };
|
|
468
|
+
e.save(), e.beginPath(), e.rect(w.x, w.y, w.width, w.height), e.clip(), t.cell.richParagraphs?.length ? ct(e, { ...n, richParagraphs: t.cell.richParagraphs, style: { verticalAlign: "middle", ...h } }, w, l, s) : Ce(
|
|
469
|
+
e,
|
|
470
|
+
{
|
|
471
|
+
text: S,
|
|
472
|
+
fontSizePx: f.fontSizePx,
|
|
473
|
+
bold: h.bold ?? !1,
|
|
474
|
+
italic: h.italic,
|
|
475
|
+
underline: h.underline,
|
|
476
|
+
color: ye(h, Ge),
|
|
477
|
+
align: h.align ?? "left",
|
|
478
|
+
lineHeight: q(h),
|
|
479
|
+
letterSpacingPx: U(h.letterSpacing ?? 0, l)
|
|
480
|
+
},
|
|
481
|
+
r + (t.xMm + d + g) * o,
|
|
482
|
+
i + (t.yMm + d) * o,
|
|
483
|
+
C * o,
|
|
484
|
+
Math.max(0, t.heightMm - 2 * d) * o,
|
|
485
|
+
h.fontFamily ?? s,
|
|
486
|
+
h.verticalAlign ?? "middle"
|
|
487
|
+
);
|
|
488
|
+
for (const v of t.cell.children ?? []) de(e, { ...v, leftMm: v.leftMm + w.x / o, topMm: v.topMm + w.y / o }, o, l, s, a, c);
|
|
489
|
+
e.restore();
|
|
490
|
+
}
|
|
491
|
+
function an(e, t, n, r, i, o, l, s, a) {
|
|
492
|
+
const c = t.style ?? {}, d = _(c, l);
|
|
493
|
+
if (Ye(t)) {
|
|
494
|
+
ct(e, t, { x: n, y: r, width: i, height: o }, l, s);
|
|
286
495
|
return;
|
|
287
496
|
}
|
|
288
|
-
const
|
|
289
|
-
|
|
290
|
-
let m = "";
|
|
291
|
-
l.forEach((d, h) => {
|
|
292
|
-
e.fillText(d, c + e.measureText(m).width + h * i, a), m += d;
|
|
293
|
-
});
|
|
294
|
-
}
|
|
295
|
-
function Et(e, t, n, r, a, o, l) {
|
|
296
|
-
for (const i of Le(t, n))
|
|
297
|
-
e.strokeStyle = i.color, e.lineWidth = W(i.widthPt, l), e.beginPath(), i.kind === "v" ? (e.moveTo(r + i.pos * o, a + i.from * o), e.lineTo(r + i.pos * o, a + i.to * o)) : (e.moveTo(r + i.from * o, a + i.pos * o), e.lineTo(r + i.to * o, a + i.pos * o)), e.stroke();
|
|
298
|
-
}
|
|
299
|
-
function St(e, t, n, r, a, o) {
|
|
300
|
-
e.beginPath(), t.top && (e.moveTo(n, r), e.lineTo(n + a, r)), t.right && (e.moveTo(n + a, r), e.lineTo(n + a, r + o)), t.bottom && (e.moveTo(n + a, r + o), e.lineTo(n, r + o)), t.left && (e.moveTo(n, r + o), e.lineTo(n, r)), e.stroke();
|
|
301
|
-
}
|
|
302
|
-
function Tt(e, t, n, r, a, o, l, i, s, c, m) {
|
|
303
|
-
const d = Ne(t, o / i, l / i);
|
|
304
|
-
for (const g of d.cells) {
|
|
305
|
-
const f = g.cell.style?.backgroundColor ?? n.style?.backgroundColor;
|
|
306
|
-
f && (e.fillStyle = f, e.fillRect(r + g.xMm * i, a + g.yMm * i, g.widthMm * i, g.heightMm * i));
|
|
307
|
-
}
|
|
308
|
-
Et(e, d, n, r, a, i, s);
|
|
309
|
-
const h = t.paddingMm ?? 0.5;
|
|
310
|
-
for (const g of d.cells) {
|
|
311
|
-
const f = g.cell.text ?? "";
|
|
312
|
-
if (!f) continue;
|
|
313
|
-
const w = Re(n.style, g.cell.style), C = _(w, s), x = g.cell.indentMm ?? 0, v = Math.max(0, g.widthMm - 2 * h - x), R = Ie(f, v, { fontSizePt: C.fontSizePt, bold: w.bold, italic: w.italic, fontFamily: w.fontFamily ?? c, letterSpacingPt: w.letterSpacing }, m).join(`
|
|
497
|
+
const m = t.lines?.length ? t.lines.join(`
|
|
498
|
+
`) : Qe(t.text ?? "", t.widthMm, { fontSizePt: d.fontSizePt, bold: c.bold, italic: c.italic, fontFamily: c.fontFamily ?? s, letterSpacingPt: c.letterSpacing }, a).join(`
|
|
314
499
|
`);
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
text: R,
|
|
319
|
-
fontSizePx: C.fontSizePx,
|
|
320
|
-
bold: w.bold ?? !1,
|
|
321
|
-
italic: w.italic,
|
|
322
|
-
color: Pe(w, Te),
|
|
323
|
-
align: w.align ?? "left",
|
|
324
|
-
lineHeight: ne(w),
|
|
325
|
-
letterSpacingPx: W(w.letterSpacing ?? 0, s)
|
|
326
|
-
},
|
|
327
|
-
r + (g.xMm + h + x) * i,
|
|
328
|
-
a + (g.yMm + h) * i,
|
|
329
|
-
v * i,
|
|
330
|
-
Math.max(0, g.heightMm - 2 * h) * i,
|
|
331
|
-
w.fontFamily ?? c,
|
|
332
|
-
w.verticalAlign ?? "middle"
|
|
333
|
-
);
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
function Ct(e, t, n, r, a, o, l, i, s) {
|
|
337
|
-
const c = t.style ?? {}, m = _(c, l), d = Ae(t) ? t.richParagraphs.map((h) => h.segments.map((g) => g.text ?? g.field ?? "").join("")).join(`
|
|
338
|
-
`) : t.lines?.length ? t.lines.join(`
|
|
339
|
-
`) : Ie(t.text ?? "", t.widthMm, { fontSizePt: m.fontSizePt, bold: c.bold, italic: c.italic, fontFamily: c.fontFamily ?? i, letterSpacingPt: c.letterSpacing }, s).join(`
|
|
340
|
-
`);
|
|
341
|
-
We(e, {
|
|
342
|
-
text: d,
|
|
343
|
-
fontSizePx: m.fontSizePx,
|
|
500
|
+
Ce(e, {
|
|
501
|
+
text: m,
|
|
502
|
+
fontSizePx: d.fontSizePx,
|
|
344
503
|
bold: c.bold ?? !1,
|
|
345
504
|
italic: c.italic,
|
|
346
|
-
|
|
505
|
+
underline: c.underline,
|
|
506
|
+
color: ye(c),
|
|
347
507
|
align: c.align ?? "left",
|
|
348
|
-
lineHeight:
|
|
349
|
-
letterSpacingPx:
|
|
350
|
-
}, n, r,
|
|
508
|
+
lineHeight: q(c),
|
|
509
|
+
letterSpacingPx: U(c.letterSpacing ?? 0, l)
|
|
510
|
+
}, n, r, i, o, c.fontFamily ?? s, c.verticalAlign);
|
|
351
511
|
}
|
|
352
|
-
function
|
|
353
|
-
const
|
|
354
|
-
if (
|
|
512
|
+
function de(e, t, n, r, i, o, l) {
|
|
513
|
+
const s = t.leftMm * n, a = t.topMm * n, c = t.widthMm * n, d = t.heightMm * n, m = t.style ?? {};
|
|
514
|
+
if (ce(t)) {
|
|
355
515
|
const h = l?.get(t.imageData);
|
|
356
|
-
h ?
|
|
516
|
+
h ? Qt(e, h, s, a, c, d) : ze(e, t, s, a, c, d);
|
|
357
517
|
return;
|
|
358
518
|
}
|
|
359
519
|
if (t.grid) {
|
|
360
|
-
|
|
520
|
+
rn(e, t.grid, t, s, a, c, d, n, r, i, o, l);
|
|
361
521
|
return;
|
|
362
522
|
}
|
|
363
523
|
switch (t.kind) {
|
|
364
524
|
case "text": {
|
|
365
|
-
|
|
525
|
+
an(e, t, s, a, c, d, r, i, o);
|
|
366
526
|
break;
|
|
367
527
|
}
|
|
368
528
|
case "rect": {
|
|
369
|
-
const h =
|
|
370
|
-
|
|
529
|
+
const h = Y(m), f = Je(m);
|
|
530
|
+
m.backgroundColor && (e.fillStyle = m.backgroundColor, e.fillRect(s, a, c, d)), f.inner && (e.strokeStyle = h.color, e.lineWidth = U(h.widthPt, r), nn(e, f, s, a, c, d));
|
|
371
531
|
break;
|
|
372
532
|
}
|
|
373
533
|
case "line": {
|
|
374
|
-
const h =
|
|
375
|
-
e.strokeStyle = h.color, e.lineWidth =
|
|
376
|
-
const
|
|
377
|
-
e.moveTo(
|
|
534
|
+
const h = Y({ ...m, borderColor: m.lineColor ?? m.borderColor });
|
|
535
|
+
e.strokeStyle = h.color, e.lineWidth = U(h.widthPt, r), e.beginPath();
|
|
536
|
+
const f = t.lineDirection === "up" ? a + d : t.lineDirection === "down" ? a : a + d / 2, g = t.lineDirection === "up" ? a : t.lineDirection === "down" ? a + d : a + d / 2;
|
|
537
|
+
e.moveTo(s, f), e.lineTo(s + c, g), e.stroke();
|
|
378
538
|
break;
|
|
379
539
|
}
|
|
380
540
|
case "ellipse": {
|
|
381
|
-
const h =
|
|
382
|
-
e.strokeStyle = h.color, e.lineWidth =
|
|
541
|
+
const h = Y(m);
|
|
542
|
+
e.strokeStyle = h.color, e.lineWidth = U(h.widthPt, r), m.backgroundColor && (e.fillStyle = m.backgroundColor, e.beginPath(), e.ellipse(s + c / 2, a + d / 2, c / 2, d / 2, 0, 0, Math.PI * 2), e.fill()), e.beginPath(), e.ellipse(s + c / 2, a + d / 2, c / 2, d / 2, 0, 0, Math.PI * 2), e.stroke();
|
|
383
543
|
break;
|
|
384
544
|
}
|
|
385
545
|
default:
|
|
386
|
-
|
|
546
|
+
ze(e, t, s, a, c, d);
|
|
387
547
|
break;
|
|
388
548
|
}
|
|
389
549
|
}
|
|
390
|
-
function
|
|
391
|
-
e.save(), e.strokeStyle = "#94a3b8", e.strokeRect(n, r,
|
|
550
|
+
function ze(e, t, n, r, i, o) {
|
|
551
|
+
e.save(), e.strokeStyle = "#94a3b8", e.strokeRect(n, r, i, o), e.fillStyle = "#64748b", e.font = "12px sans-serif", e.fillText(t.fallbackText ?? `[${t.kind}]`, n + 3, r + 14), e.restore();
|
|
392
552
|
}
|
|
393
|
-
async function
|
|
553
|
+
async function yr(e, t = {}) {
|
|
394
554
|
if (typeof document > "u")
|
|
395
555
|
throw new Error("renderPlanToImages 需要浏览器环境(SSR/Node 请在客户端钩子中调用)");
|
|
396
|
-
const { format: n = "png", quality: r = 0.92, ...
|
|
556
|
+
const { format: n = "png", quality: r = 0.92, ...i } = t;
|
|
397
557
|
if (n !== "png" && n !== "jpeg") throw new TypeError("Image format must be png or jpeg.");
|
|
398
558
|
if (!Number.isFinite(r) || r < 0 || r > 1) throw new RangeError("Image quality must be between 0 and 1.");
|
|
399
|
-
|
|
400
|
-
const o = await
|
|
559
|
+
k(t.signal);
|
|
560
|
+
const o = await Ee(e, { ...t, format: "canvas" });
|
|
401
561
|
e = o.plan;
|
|
402
|
-
const l = [...o.diagnostics, ...
|
|
403
|
-
for (let
|
|
404
|
-
|
|
405
|
-
const
|
|
562
|
+
const l = [...o.diagnostics, ...Z(e, "canvas", t)], s = n === "jpeg" ? "image/jpeg" : "image/png", a = [], c = Math.min(e.pages.length - 1, t.end ?? e.pages.length - 1);
|
|
563
|
+
for (let d = Math.max(0, t.start ?? 0); d <= c; d++) {
|
|
564
|
+
k(t.signal);
|
|
565
|
+
const m = await ht(e.pages[d], d, i, l);
|
|
406
566
|
try {
|
|
407
|
-
|
|
567
|
+
a.push(await sn(m, s, r, t.signal));
|
|
408
568
|
} finally {
|
|
409
|
-
|
|
569
|
+
m.width = 0, m.height = 0;
|
|
410
570
|
}
|
|
411
|
-
await
|
|
571
|
+
await At(t, a.length, c - Math.max(0, t.start ?? 0) + 1);
|
|
412
572
|
}
|
|
413
|
-
return
|
|
573
|
+
return k(t.signal), { blobs: a, diagnostics: l };
|
|
414
574
|
}
|
|
415
|
-
function
|
|
416
|
-
return
|
|
575
|
+
function sn(e, t, n, r) {
|
|
576
|
+
return k(r), new Promise((i, o) => {
|
|
417
577
|
const l = () => o(r?.reason ?? new DOMException("The operation was aborted.", "AbortError"));
|
|
418
578
|
r?.addEventListener("abort", l, { once: !0 });
|
|
419
579
|
try {
|
|
420
|
-
e.toBlob((
|
|
421
|
-
r?.removeEventListener("abort", l),
|
|
580
|
+
e.toBlob((s) => {
|
|
581
|
+
r?.removeEventListener("abort", l), s ? i(s) : o(new Error("Canvas encoding failed; no empty image was emitted."));
|
|
422
582
|
}, t, n);
|
|
423
|
-
} catch (
|
|
424
|
-
r?.removeEventListener("abort", l), o(
|
|
583
|
+
} catch (s) {
|
|
584
|
+
r?.removeEventListener("abort", l), o(s);
|
|
425
585
|
}
|
|
426
586
|
});
|
|
427
587
|
}
|
|
428
|
-
function
|
|
429
|
-
if (
|
|
588
|
+
function Mr(e, t = {}) {
|
|
589
|
+
if (k(t.signal), typeof document > "u")
|
|
430
590
|
throw new Error("renderPlanToCanvas 需要浏览器环境(SSR 请在客户端钩子中调用)");
|
|
431
|
-
const n = t.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), r = t.dpi ?? 96,
|
|
432
|
-
for (const h of
|
|
433
|
-
|
|
434
|
-
if (t.fidelity === "strict" &&
|
|
435
|
-
for (let h =
|
|
436
|
-
|
|
437
|
-
const
|
|
438
|
-
for (const
|
|
439
|
-
|
|
440
|
-
c.push(
|
|
441
|
-
}
|
|
442
|
-
return { canvases: c, diagnostics:
|
|
443
|
-
}
|
|
444
|
-
function
|
|
445
|
-
return n < t ? [] : e.pages.slice(t, n + 1).flatMap((r,
|
|
591
|
+
const n = t.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), r = t.dpi ?? 96, i = r / 96 * Re, o = t.fontFamily ?? le, l = t.measurer ?? Me, s = Math.max(0, t.start ?? 0), a = Math.min(e.pages.length - 1, t.end ?? e.pages.length - 1), c = [], d = Z(e, "canvas", t), m = ln(e, s, a);
|
|
592
|
+
for (const h of m)
|
|
593
|
+
tt(h, t), d.push(h);
|
|
594
|
+
if (t.fidelity === "strict" && m.length) throw new Pt(d);
|
|
595
|
+
for (let h = s; h <= a; h++) {
|
|
596
|
+
k(t.signal);
|
|
597
|
+
const f = e.pages[h], { canvas: g, ctx: C } = mt(f, n, r, t.maxCanvasPixels);
|
|
598
|
+
for (const S of f.components)
|
|
599
|
+
de(C, S, i, r, o, l);
|
|
600
|
+
c.push(g);
|
|
601
|
+
}
|
|
602
|
+
return { canvases: c, diagnostics: d };
|
|
603
|
+
}
|
|
604
|
+
function ln(e, t, n) {
|
|
605
|
+
return n < t ? [] : e.pages.slice(t, n + 1).flatMap((r, i) => [...Te(r)].map(({ component: o, componentIndex: l, componentPath: s }) => ({
|
|
446
606
|
code: "async-image-required",
|
|
447
607
|
severity: "warning",
|
|
448
608
|
format: "canvas",
|
|
449
|
-
pageIndex: t +
|
|
609
|
+
pageIndex: t + i,
|
|
450
610
|
componentIndex: l,
|
|
611
|
+
componentPath: s,
|
|
451
612
|
kind: o.kind,
|
|
452
613
|
nid: o.nid,
|
|
453
614
|
message: "Use renderPlanToCanvasAsync or renderPlanToImages to decode and include images."
|
|
454
|
-
}
|
|
615
|
+
})));
|
|
455
616
|
}
|
|
456
|
-
async function
|
|
617
|
+
async function vr(e, t = {}) {
|
|
457
618
|
if (typeof document > "u") throw new Error("renderPlanToCanvasAsync 需要浏览器环境(Node 请使用 PDF 或 XLSX 输出)");
|
|
458
|
-
|
|
459
|
-
const n = await
|
|
619
|
+
k(t.signal);
|
|
620
|
+
const n = await Ee(e, { ...t, format: "canvas" });
|
|
460
621
|
e = n.plan;
|
|
461
|
-
const r = [...n.diagnostics, ...
|
|
622
|
+
const r = [...n.diagnostics, ...Z(e, "canvas", t)], i = [], o = Math.min(e.pages.length - 1, t.end ?? e.pages.length - 1);
|
|
462
623
|
for (let l = Math.max(0, t.start ?? 0); l <= o; l++)
|
|
463
|
-
|
|
464
|
-
return { canvases:
|
|
465
|
-
}
|
|
466
|
-
async function
|
|
467
|
-
const
|
|
468
|
-
|
|
469
|
-
const { canvas:
|
|
470
|
-
for (const
|
|
471
|
-
return
|
|
624
|
+
i.push(await ht(e.pages[l], l, t, r));
|
|
625
|
+
return { canvases: i, diagnostics: r };
|
|
626
|
+
}
|
|
627
|
+
async function ht(e, t, n, r) {
|
|
628
|
+
const i = n.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), o = n.dpi ?? 96, l = n.fontFamily ?? le, s = await ft(e, t, n, r);
|
|
629
|
+
k(n.signal);
|
|
630
|
+
const { canvas: a, ctx: c } = mt(e, i, o, n.maxCanvasPixels);
|
|
631
|
+
for (const d of e.components) de(c, d, o / 25.4, o, l, n.measurer ?? Me, s);
|
|
632
|
+
return a;
|
|
472
633
|
}
|
|
473
|
-
async function
|
|
474
|
-
const
|
|
475
|
-
return
|
|
634
|
+
async function ft(e, t, n, r) {
|
|
635
|
+
const i = n.imageLoader ?? Yt;
|
|
636
|
+
return Zt(e, async (o, l) => {
|
|
476
637
|
try {
|
|
477
|
-
return await
|
|
478
|
-
} catch (
|
|
479
|
-
if (l?.aborted) throw
|
|
480
|
-
const
|
|
481
|
-
throw r.push(
|
|
638
|
+
return await i(o, l);
|
|
639
|
+
} catch (s) {
|
|
640
|
+
if (l?.aborted) throw s;
|
|
641
|
+
const a = [...Te(e)].find(({ component: f }) => f.imageData === o), { component: c, componentIndex: d, componentPath: m } = a, h = { code: "image-decode-failed", severity: "warning", format: "canvas", pageIndex: t, componentIndex: d, componentPath: m, kind: c.kind, nid: c.nid, message: "Image decoding failed; raster output was cancelled instead of omitting the image." };
|
|
642
|
+
throw r.push(h), tt(h, n), s;
|
|
482
643
|
}
|
|
483
644
|
}, n.signal);
|
|
484
645
|
}
|
|
485
|
-
function
|
|
486
|
-
const n = t.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), r = t.dpi ?? 96,
|
|
487
|
-
let
|
|
488
|
-
const
|
|
489
|
-
function
|
|
490
|
-
const
|
|
491
|
-
|
|
492
|
-
const
|
|
493
|
-
for (let
|
|
494
|
-
const
|
|
495
|
-
|
|
646
|
+
function xr(e, t = {}) {
|
|
647
|
+
const n = t.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), r = t.dpi ?? 96, i = r / 96 * Re, o = t.fontFamily ?? le, l = t.measurer ?? Me, s = t.overscan ?? 1, a = t.gapPx ?? 18, c = t.pagesPerFrame ?? 1, d = e.pages.map((p) => p.pageHeightMm * i), m = Math.max(1, ...e.pages.map((p) => p.pageWidthMm * i)), h = { start: 0, end: -1 };
|
|
648
|
+
let f = null, g = null, C = null, S = null, w = [], v = 0, y = [], N = 0, L = new AbortController();
|
|
649
|
+
const Oe = [];
|
|
650
|
+
function yt() {
|
|
651
|
+
const p = f;
|
|
652
|
+
p.innerHTML = "", g = document.createElement("div"), g.style.cssText = `width:${m}px;margin:0 auto;`, C = document.createElement("div"), S = document.createElement("div"), g.appendChild(C), w = [];
|
|
653
|
+
const R = Math.min(e.pages.length, 3 + s * 2);
|
|
654
|
+
for (let z = 0; z < R; z++) {
|
|
655
|
+
const E = document.createElement("div");
|
|
656
|
+
E.style.cssText = `margin:0 auto ${a}px;box-shadow:0 2px 8px rgba(0,0,0,.35);background:#fff;`, g.appendChild(E), w.push(E);
|
|
496
657
|
}
|
|
497
|
-
|
|
498
|
-
}
|
|
499
|
-
async function
|
|
500
|
-
const
|
|
501
|
-
|
|
502
|
-
const P =
|
|
503
|
-
if (
|
|
504
|
-
const { widthPx:
|
|
505
|
-
let
|
|
506
|
-
(!
|
|
507
|
-
const
|
|
508
|
-
|
|
509
|
-
const
|
|
510
|
-
if (
|
|
511
|
-
|
|
512
|
-
for (const
|
|
513
|
-
|
|
514
|
-
|
|
658
|
+
g.appendChild(S), p.appendChild(g);
|
|
659
|
+
}
|
|
660
|
+
async function Mt(p, R) {
|
|
661
|
+
const z = N, E = await Ee(e, { ...t, signal: L.signal, format: "canvas", start: R, end: R });
|
|
662
|
+
Oe.push(...E.diagnostics);
|
|
663
|
+
const P = E.plan.pages[R], ne = await ft(P, R, { ...t, signal: L.signal }, Oe);
|
|
664
|
+
if (z !== N || !f) return;
|
|
665
|
+
const { widthPx: fe, heightPx: ge } = $e(P, r);
|
|
666
|
+
let D = p.firstElementChild;
|
|
667
|
+
(!D || D.tagName !== "CANVAS") && (D = document.createElement("canvas"), p.innerHTML = "", p.appendChild(D));
|
|
668
|
+
const Ne = dt(P, n, r, t.maxCanvasPixels);
|
|
669
|
+
D.width = Ne.width, D.height = Ne.height, D.style.width = `${fe}px`, D.style.height = `${ge}px`;
|
|
670
|
+
const W = D.getContext("2d");
|
|
671
|
+
if (W) {
|
|
672
|
+
W.setTransform(1, 0, 0, 1, 0, 0), W.scale(n, n), W.fillStyle = "#ffffff", W.fillRect(0, 0, fe, ge);
|
|
673
|
+
for (const xt of P.components)
|
|
674
|
+
de(W, xt, i, r, o, l, ne);
|
|
675
|
+
D.dataset.canvasPage = String(R), p.style.height = `${ge}px`, p.style.width = `${fe}px`;
|
|
515
676
|
}
|
|
516
677
|
}
|
|
517
|
-
function
|
|
518
|
-
|
|
519
|
-
const
|
|
520
|
-
|
|
521
|
-
const
|
|
522
|
-
|
|
523
|
-
if (P <
|
|
524
|
-
|
|
525
|
-
const
|
|
526
|
-
|
|
678
|
+
function vt(p) {
|
|
679
|
+
N++, h.start = p.start, h.end = p.end, C.style.height = `${p.start * a + d.slice(0, p.start).reduce((E, P) => E + P, 0)}px`;
|
|
680
|
+
const R = e.pages.length - 1 - p.end;
|
|
681
|
+
S.style.height = `${R * a + d.slice(p.end + 1).reduce((E, P) => E + P, 0)}px`;
|
|
682
|
+
const z = p.end - p.start + 1;
|
|
683
|
+
w.forEach((E, P) => {
|
|
684
|
+
if (P < z) {
|
|
685
|
+
E.style.display = "";
|
|
686
|
+
const ne = p.start + P;
|
|
687
|
+
E.style.height = `${d[ne] ?? 0}px`;
|
|
527
688
|
} else
|
|
528
|
-
|
|
529
|
-
}),
|
|
530
|
-
for (let
|
|
531
|
-
const P =
|
|
689
|
+
E.style.display = "none";
|
|
690
|
+
}), y = [];
|
|
691
|
+
for (let E = p.start; E <= p.end; E++) {
|
|
692
|
+
const P = w[E - p.start];
|
|
532
693
|
if (!P) continue;
|
|
533
|
-
P.firstElementChild?.dataset?.canvasPage !== String(
|
|
694
|
+
P.firstElementChild?.dataset?.canvasPage !== String(E) && y.push(E);
|
|
534
695
|
}
|
|
535
|
-
|
|
696
|
+
he();
|
|
536
697
|
}
|
|
537
|
-
function
|
|
538
|
-
v ||
|
|
698
|
+
function he() {
|
|
699
|
+
v || y.length === 0 || (v = requestAnimationFrame(() => {
|
|
539
700
|
v = 0;
|
|
540
|
-
let
|
|
541
|
-
for (;
|
|
542
|
-
const
|
|
543
|
-
|
|
701
|
+
let p = Math.max(1, c);
|
|
702
|
+
for (; y.length > 0 && p-- > 0; ) {
|
|
703
|
+
const R = y.shift(), z = w[R - h.start];
|
|
704
|
+
z && Mt(z, R).catch(() => {
|
|
544
705
|
});
|
|
545
706
|
}
|
|
546
|
-
|
|
707
|
+
y.length > 0 && he();
|
|
547
708
|
}));
|
|
548
709
|
}
|
|
549
|
-
function
|
|
710
|
+
function ee() {
|
|
550
711
|
v || (v = requestAnimationFrame(() => {
|
|
551
712
|
v = 0;
|
|
552
|
-
const
|
|
553
|
-
pageHeightsPx:
|
|
554
|
-
viewportHeightPx:
|
|
555
|
-
scrollTopPx:
|
|
556
|
-
overscan:
|
|
557
|
-
gapPx:
|
|
713
|
+
const p = f, R = en({
|
|
714
|
+
pageHeightsPx: d,
|
|
715
|
+
viewportHeightPx: p.clientHeight,
|
|
716
|
+
scrollTopPx: p.scrollTop,
|
|
717
|
+
overscan: s,
|
|
718
|
+
gapPx: a
|
|
558
719
|
});
|
|
559
|
-
|
|
720
|
+
R.start !== h.start || R.end !== h.end ? vt(R) : he();
|
|
560
721
|
}));
|
|
561
722
|
}
|
|
562
|
-
let
|
|
723
|
+
let te = null;
|
|
563
724
|
return {
|
|
564
|
-
attach(
|
|
725
|
+
attach(p) {
|
|
565
726
|
if (typeof document > "u")
|
|
566
727
|
throw new Error("createCanvasPager 需要浏览器环境(SSR 请在客户端钩子中调用 attach)");
|
|
567
|
-
|
|
728
|
+
k(t.signal), L = new AbortController(), t.signal?.addEventListener("abort", Ie, { once: !0 }), Z(e, "canvas", t), f = p, yt(), p.addEventListener("scroll", ee, { passive: !0 }), typeof ResizeObserver < "u" && (te = new ResizeObserver(() => ee()), te.observe(p)), ee();
|
|
568
729
|
},
|
|
569
730
|
destroy() {
|
|
570
|
-
|
|
731
|
+
N++, L.abort(), t.signal?.removeEventListener("abort", Ie), v && cancelAnimationFrame(v), v = 0, te?.disconnect(), te = null, f?.removeEventListener("scroll", ee), y = [], g?.remove(), f = null;
|
|
571
732
|
},
|
|
572
733
|
window() {
|
|
573
734
|
return { ...h };
|
|
574
735
|
}
|
|
575
736
|
};
|
|
576
|
-
function
|
|
577
|
-
|
|
737
|
+
function Ie() {
|
|
738
|
+
L.abort(t.signal?.reason);
|
|
578
739
|
}
|
|
579
740
|
}
|
|
580
|
-
function
|
|
581
|
-
let r,
|
|
741
|
+
function gt(e, t, n) {
|
|
742
|
+
let r, i;
|
|
582
743
|
if (typeof e == "string") {
|
|
583
|
-
const o =
|
|
584
|
-
if (!o) throw new Error(`未知纸张预设 "${e}"(可用:${Object.keys(
|
|
585
|
-
r = o.widthMm,
|
|
586
|
-
} else typeof e == "number" ? (r = e,
|
|
587
|
-
return n ? { widthMm:
|
|
744
|
+
const o = oe[e];
|
|
745
|
+
if (!o) throw new Error(`未知纸张预设 "${e}"(可用:${Object.keys(oe).join("/")})`);
|
|
746
|
+
r = o.widthMm, i = o.heightMm;
|
|
747
|
+
} else typeof e == "number" ? (r = e, i = t ?? 297) : (r = e.widthMm, i = e.heightMm);
|
|
748
|
+
return n ? { widthMm: i, heightMm: r } : { widthMm: r, heightMm: i };
|
|
588
749
|
}
|
|
589
|
-
class
|
|
750
|
+
class cn {
|
|
590
751
|
constructor() {
|
|
591
752
|
this.pages = [], this.pending = null, this.templateParams = void 0;
|
|
592
753
|
}
|
|
@@ -619,18 +780,18 @@ class At {
|
|
|
619
780
|
*/
|
|
620
781
|
page(t = "a4", n = {}, r) {
|
|
621
782
|
this.collect();
|
|
622
|
-
const o = r != null && !("margins" in r) && !("landscape" in r) && ("marginTopMm" in r || "marginBottomMm" in r || "marginLeftMm" in r || "marginRightMm" in r) ? { margins: r } : typeof n == "number" ? r ?? {} : n, { widthMm: l, heightMm:
|
|
783
|
+
const o = r != null && !("margins" in r) && !("landscape" in r) && ("marginTopMm" in r || "marginBottomMm" in r || "marginLeftMm" in r || "marginRightMm" in r) ? { margins: r } : typeof n == "number" ? r ?? {} : n, { widthMm: l, heightMm: s } = gt(
|
|
623
784
|
t,
|
|
624
785
|
typeof n == "number" ? n : void 0,
|
|
625
786
|
o.landscape
|
|
626
|
-
),
|
|
627
|
-
return this.pending = new
|
|
787
|
+
), a = o.margins ?? {};
|
|
788
|
+
return this.pending = new dn(this, {
|
|
628
789
|
widthMm: l,
|
|
629
|
-
heightMm:
|
|
630
|
-
marginTopMm:
|
|
631
|
-
marginBottomMm:
|
|
632
|
-
marginLeftMm:
|
|
633
|
-
marginRightMm:
|
|
790
|
+
heightMm: s,
|
|
791
|
+
marginTopMm: a.marginTopMm ?? 10,
|
|
792
|
+
marginBottomMm: a.marginBottomMm ?? 10,
|
|
793
|
+
marginLeftMm: a.marginLeftMm ?? 10,
|
|
794
|
+
marginRightMm: a.marginRightMm ?? 10
|
|
634
795
|
}), this.pending;
|
|
635
796
|
}
|
|
636
797
|
collect() {
|
|
@@ -646,7 +807,7 @@ class At {
|
|
|
646
807
|
};
|
|
647
808
|
}
|
|
648
809
|
}
|
|
649
|
-
class
|
|
810
|
+
class dn {
|
|
650
811
|
constructor(t, n) {
|
|
651
812
|
this.parent = t, this.page = n, this.components = [];
|
|
652
813
|
}
|
|
@@ -661,7 +822,7 @@ class $t {
|
|
|
661
822
|
style: r
|
|
662
823
|
}), this;
|
|
663
824
|
}
|
|
664
|
-
list(t, n, r,
|
|
825
|
+
list(t, n, r, i = {}) {
|
|
665
826
|
return this.components.push({
|
|
666
827
|
kind: "list",
|
|
667
828
|
leftMm: n.leftMm ?? 10,
|
|
@@ -669,20 +830,20 @@ class $t {
|
|
|
669
830
|
widthMm: n.widthMm ?? 180,
|
|
670
831
|
dataset: t,
|
|
671
832
|
columns: r,
|
|
672
|
-
...
|
|
833
|
+
...i
|
|
673
834
|
}), this;
|
|
674
835
|
}
|
|
675
836
|
rect(t, n = {}) {
|
|
676
837
|
return this.components.push({ kind: "rect", ...t, style: n }), this;
|
|
677
838
|
}
|
|
678
|
-
line(t, n, r,
|
|
839
|
+
line(t, n, r, i = {}) {
|
|
679
840
|
return this.components.push({
|
|
680
841
|
kind: "line",
|
|
681
842
|
leftMm: t,
|
|
682
843
|
topMm: n,
|
|
683
844
|
widthMm: r,
|
|
684
845
|
heightMm: 0.5,
|
|
685
|
-
style:
|
|
846
|
+
style: i
|
|
686
847
|
}), this;
|
|
687
848
|
}
|
|
688
849
|
barcode(t, n) {
|
|
@@ -695,11 +856,11 @@ class $t {
|
|
|
695
856
|
fallbackText: t
|
|
696
857
|
}), this;
|
|
697
858
|
}
|
|
698
|
-
qrcode(t, n, r,
|
|
859
|
+
qrcode(t, n, r, i) {
|
|
699
860
|
return this.components.push({
|
|
700
861
|
kind: "qrcode",
|
|
701
862
|
leftMm: r,
|
|
702
|
-
topMm:
|
|
863
|
+
topMm: i,
|
|
703
864
|
widthMm: n,
|
|
704
865
|
heightMm: n,
|
|
705
866
|
fallbackText: t
|
|
@@ -715,26 +876,27 @@ class $t {
|
|
|
715
876
|
return this.done().build();
|
|
716
877
|
}
|
|
717
878
|
}
|
|
718
|
-
function
|
|
719
|
-
return new
|
|
879
|
+
function Sr() {
|
|
880
|
+
return new cn();
|
|
720
881
|
}
|
|
721
|
-
function
|
|
722
|
-
return
|
|
882
|
+
function Er(e, t = {}) {
|
|
883
|
+
return Et([], e), e.fields.map((n) => ({
|
|
723
884
|
field: n.field,
|
|
724
885
|
header: `${n.label ?? n.field}${n.unit ? ` (${n.unit})` : ""}`,
|
|
725
886
|
semanticRole: n.semanticRole ?? (n.type === "number" || n.type === "decimal" ? "measure" : n.type === "date" ? "date" : n.enum ? "dimension" : "text"),
|
|
887
|
+
...n.format ? { format: { ...n.format } } : {},
|
|
726
888
|
...t[n.field]
|
|
727
889
|
}));
|
|
728
890
|
}
|
|
729
|
-
function
|
|
891
|
+
function O(e, t, n = !1) {
|
|
730
892
|
if (!Number.isFinite(e) || (n ? e < 0 : e <= 0))
|
|
731
893
|
throw new Error(`${t} 必须是有限${n ? "非负" : "正"}数`);
|
|
732
894
|
}
|
|
733
|
-
function
|
|
895
|
+
function ae(e, t, n) {
|
|
734
896
|
if (e !== void 0 && !["left", "center", "right", "justify", ...n ? ["auto"] : []].includes(e))
|
|
735
897
|
throw new Error(`${t} 必须是 left/center/right/justify${n ? "/auto" : ""}`);
|
|
736
898
|
}
|
|
737
|
-
function
|
|
899
|
+
function mn(e) {
|
|
738
900
|
const t = e.layout ?? "page";
|
|
739
901
|
if (t !== "page" && t !== "wide")
|
|
740
902
|
throw new Error("layout 必须是 page 或 wide");
|
|
@@ -743,18 +905,18 @@ function kt(e) {
|
|
|
743
905
|
if (t !== "wide" && e.columnWidthMm !== void 0)
|
|
744
906
|
throw new Error('columnWidthMm 仅适用于 layout: "wide"');
|
|
745
907
|
const n = e.columnWidthMm ?? 30;
|
|
746
|
-
return
|
|
908
|
+
return O(n, "columnWidthMm"), { layout: t, columnWidthMm: n };
|
|
747
909
|
}
|
|
748
|
-
function
|
|
910
|
+
function hn(e) {
|
|
749
911
|
const t = e.paper === void 0 ? "a4" : e.paper;
|
|
750
912
|
if (typeof t != "string" && (typeof t != "object" || t === null) || e.landscape !== void 0 && typeof e.landscape != "boolean")
|
|
751
913
|
throw new Error("paper 必须是纸张预设名或 { widthMm, heightMm } 对象,landscape 必须是布尔值");
|
|
752
|
-
if (typeof t == "string" && !Object.prototype.hasOwnProperty.call(
|
|
753
|
-
throw new Error(`未知纸张预设 "${t}"(可用:${Object.keys(
|
|
754
|
-
const n =
|
|
755
|
-
return
|
|
914
|
+
if (typeof t == "string" && !Object.prototype.hasOwnProperty.call(oe, t))
|
|
915
|
+
throw new Error(`未知纸张预设 "${t}"(可用:${Object.keys(oe).join("/")})`);
|
|
916
|
+
const n = gt(t, void 0, e.landscape), r = n.widthMm, i = n.heightMm;
|
|
917
|
+
return O(r, "纸张 widthMm"), O(i, "纸张 heightMm"), { widthMm: r, heightMm: i };
|
|
756
918
|
}
|
|
757
|
-
function
|
|
919
|
+
function fn(e) {
|
|
758
920
|
if (e.margins !== void 0 && (!e.margins || typeof e.margins != "object" || Array.isArray(e.margins)))
|
|
759
921
|
throw new Error("margins 必须是页边距对象");
|
|
760
922
|
const t = e.margins ?? {}, n = {
|
|
@@ -763,133 +925,185 @@ function Nt(e) {
|
|
|
763
925
|
marginLeftMm: t.marginLeftMm === void 0 ? 10 : t.marginLeftMm,
|
|
764
926
|
marginRightMm: t.marginRightMm === void 0 ? 10 : t.marginRightMm
|
|
765
927
|
};
|
|
766
|
-
for (const [r,
|
|
928
|
+
for (const [r, i] of Object.entries(n)) O(i, r, !0);
|
|
767
929
|
return n;
|
|
768
930
|
}
|
|
769
|
-
function
|
|
931
|
+
function gn(e, t) {
|
|
770
932
|
const n = e.dataset === void 0 ? "detail" : e.dataset;
|
|
771
933
|
if (typeof n != "string" || !n.trim())
|
|
772
934
|
throw new Error("dataset 必须是非空字符串");
|
|
773
935
|
if (e.title !== void 0 && typeof e.title != "string")
|
|
774
936
|
throw new Error("title 必须是字符串");
|
|
775
|
-
const r = e.titleHeightMm === void 0 ? 10 : e.titleHeightMm,
|
|
776
|
-
|
|
777
|
-
const o = e.title !== void 0 && e.title.length > 0, l = o ? r +
|
|
937
|
+
const r = e.titleHeightMm === void 0 ? 10 : e.titleHeightMm, i = e.titleGapMm === void 0 ? 4 : e.titleGapMm;
|
|
938
|
+
O(r, "titleHeightMm"), O(i, "titleGapMm", !0);
|
|
939
|
+
const o = e.title !== void 0 && e.title.length > 0, l = o ? r + i : 0;
|
|
778
940
|
if (l >= t)
|
|
779
941
|
throw new Error("标题高度与间距占满页面,必须为表格保留可用高度");
|
|
780
942
|
return { dataset: n, titleHeightMm: r, hasTitle: o, titleSpaceMm: l };
|
|
781
943
|
}
|
|
782
|
-
function
|
|
944
|
+
function un(e) {
|
|
783
945
|
if (e.listOptions !== void 0 && (!e.listOptions || typeof e.listOptions != "object" || Array.isArray(e.listOptions)))
|
|
784
946
|
throw new Error("listOptions 必须是列表配置对象");
|
|
785
947
|
const t = e.listOptions ?? {};
|
|
786
|
-
|
|
948
|
+
ae(t.align, "listOptions.align", !0), ae(t.headerAlign, "listOptions.headerAlign", !1);
|
|
787
949
|
for (const n of ["fontSizePt", "rowHeightMm", "paddingMm"]) {
|
|
788
950
|
const r = t[n];
|
|
789
|
-
r !== void 0 &&
|
|
951
|
+
r !== void 0 && O(r, `listOptions.${n}`, n === "paddingMm");
|
|
790
952
|
}
|
|
791
953
|
return t;
|
|
792
954
|
}
|
|
793
|
-
function
|
|
955
|
+
function pn(e) {
|
|
794
956
|
let t = 0, n = 0;
|
|
795
|
-
for (const [r,
|
|
796
|
-
if (!
|
|
957
|
+
for (const [r, i] of e.entries()) {
|
|
958
|
+
if (!i || typeof i.header != "string" || typeof i.field != "string" || !i.field.trim())
|
|
797
959
|
throw new Error(`columns[${r}] 需要字符串 header 与非空 field`);
|
|
798
|
-
|
|
960
|
+
ae(i.align, `columns[${r}].align`, !0), ae(i.headerAlign, `columns[${r}].headerAlign`, !1), i.flex !== void 0 && O(i.flex, `columns[${r}].flex`), i.widthMm !== void 0 ? (O(i.widthMm, `columns[${r}].widthMm`), t += i.widthMm) : n = Math.max(n, i.flex ?? 1);
|
|
799
961
|
}
|
|
800
962
|
return { fixedWidthMm: t, maxFlex: n };
|
|
801
963
|
}
|
|
802
|
-
function
|
|
803
|
-
const { fixedWidthMm:
|
|
804
|
-
if (t === "page" &&
|
|
805
|
-
throw new Error(`固定列宽 ${
|
|
806
|
-
const l = r -
|
|
964
|
+
function wn(e, t, n, r) {
|
|
965
|
+
const { fixedWidthMm: i, maxFlex: o } = pn(e.columns);
|
|
966
|
+
if (t === "page" && i > r)
|
|
967
|
+
throw new Error(`固定列宽 ${i}mm 超出页面可用宽度 ${r}mm`);
|
|
968
|
+
const l = r - i;
|
|
807
969
|
if (t === "page" && o > 0 && l <= 0)
|
|
808
970
|
throw new Error("固定列占满页面可用宽度,自动列需要正的剩余宽度");
|
|
809
|
-
const
|
|
810
|
-
return { columns: e.columns.map(({ widthMm: c, flex:
|
|
811
|
-
const
|
|
812
|
-
return
|
|
813
|
-
}), fixedWidthMm:
|
|
971
|
+
const s = o > 0 ? e.columns.reduce((c, d) => c + (d.widthMm === void 0 ? (d.flex ?? 1) / o : 0), 0) : 0;
|
|
972
|
+
return { columns: e.columns.map(({ widthMm: c, flex: d, ...m }, h) => {
|
|
973
|
+
const f = c ?? (t === "wide" ? n * (d ?? 1) : l * ((d ?? 1) / o) / s);
|
|
974
|
+
return O(f, `columns[${h}] 分配后的 widthMm`), { ...m, widthMm: f };
|
|
975
|
+
}), fixedWidthMm: i, maxFlex: o };
|
|
814
976
|
}
|
|
815
|
-
function
|
|
977
|
+
function Cr(e) {
|
|
816
978
|
if (!e || typeof e != "object")
|
|
817
979
|
throw new Error("标准明细模板需要 options 对象");
|
|
818
980
|
if (!Array.isArray(e.columns) || e.columns.length === 0)
|
|
819
981
|
throw new Error("columns 至少需要一列");
|
|
820
|
-
const { layout: t, columnWidthMm: n } =
|
|
821
|
-
let
|
|
822
|
-
const o = r.heightMm, l =
|
|
823
|
-
let
|
|
824
|
-
const
|
|
825
|
-
if (t === "page" &&
|
|
982
|
+
const { layout: t, columnWidthMm: n } = mn(e), r = hn(e);
|
|
983
|
+
let i = r.widthMm;
|
|
984
|
+
const o = r.heightMm, l = fn(e);
|
|
985
|
+
let s = i - l.marginLeftMm - l.marginRightMm;
|
|
986
|
+
const a = o - l.marginTopMm - l.marginBottomMm;
|
|
987
|
+
if (t === "page" && s <= 0 || a <= 0)
|
|
826
988
|
throw new Error("页边距占满纸张,必须保留正的可用宽度和高度");
|
|
827
|
-
const { dataset: c, titleHeightMm:
|
|
828
|
-
t === "wide" && (
|
|
829
|
-
const
|
|
830
|
-
return
|
|
989
|
+
const { dataset: c, titleHeightMm: d, hasTitle: m, titleSpaceMm: h } = gn(e, a), f = un(e), { columns: g, fixedWidthMm: C, maxFlex: S } = wn(e, t, n, s);
|
|
990
|
+
t === "wide" && (s = g.reduce((v, y) => v + y.widthMm, 0), O(s, "宽表总列宽"), i = s + l.marginLeftMm + l.marginRightMm, O(i, "宽表总宽度"));
|
|
991
|
+
const w = { widthMm: i, heightMm: o, ...l, components: [], ...t === "wide" ? { layout: t } : {} };
|
|
992
|
+
return m && w.components.push({
|
|
831
993
|
kind: "text",
|
|
832
994
|
text: e.title,
|
|
833
995
|
leftMm: l.marginLeftMm,
|
|
834
996
|
topMm: l.marginTopMm,
|
|
835
|
-
widthMm:
|
|
836
|
-
heightMm:
|
|
997
|
+
widthMm: s,
|
|
998
|
+
heightMm: d,
|
|
837
999
|
style: { fontSize: 16, bold: !0, align: "center", verticalAlign: "middle", ...e.titleStyle }
|
|
838
|
-
}),
|
|
1000
|
+
}), w.components.push({
|
|
839
1001
|
align: "auto",
|
|
840
1002
|
headerAlign: "center",
|
|
841
|
-
...
|
|
1003
|
+
...f,
|
|
842
1004
|
kind: "list",
|
|
843
1005
|
...t === "wide" ? { layout: t } : {},
|
|
844
|
-
...
|
|
1006
|
+
...m ? { title: e.title } : {},
|
|
845
1007
|
dataset: c,
|
|
846
|
-
columns:
|
|
1008
|
+
columns: g,
|
|
847
1009
|
leftMm: l.marginLeftMm,
|
|
848
1010
|
topMm: l.marginTopMm + h,
|
|
849
|
-
widthMm: t === "wide" ||
|
|
850
|
-
}), e.params === void 0 ? { pages: [
|
|
1011
|
+
widthMm: t === "wide" || S > 0 ? s : C
|
|
1012
|
+
}), e.params === void 0 ? { pages: [w] } : { params: e.params, pages: [w] };
|
|
851
1013
|
}
|
|
852
|
-
function
|
|
1014
|
+
function Tr(e) {
|
|
853
1015
|
if (e.components !== void 0 && e.pages !== void 0) throw new TypeError("标签 components 与 pages 只能选择一种");
|
|
854
|
-
const { dataset: t, rowKey: n, copies: r, params:
|
|
1016
|
+
const { dataset: t, rowKey: n, copies: r, params: i } = e, o = e.pages ?? [{ components: e.components ?? [] }], l = {
|
|
855
1017
|
repeat: { dataset: t, ...n === void 0 ? {} : { rowKey: n }, ...r === void 0 ? {} : { copies: r } },
|
|
856
|
-
...
|
|
857
|
-
pages: o.map((
|
|
858
|
-
widthMm:
|
|
859
|
-
heightMm:
|
|
1018
|
+
...i === void 0 ? {} : { params: i },
|
|
1019
|
+
pages: o.map((a) => ({
|
|
1020
|
+
widthMm: a.widthMm ?? e.widthMm ?? 80,
|
|
1021
|
+
heightMm: a.heightMm ?? e.heightMm ?? 55,
|
|
860
1022
|
marginTopMm: 0,
|
|
861
1023
|
marginRightMm: 0,
|
|
862
1024
|
marginBottomMm: 0,
|
|
863
1025
|
marginLeftMm: 0,
|
|
864
|
-
components:
|
|
865
|
-
...
|
|
1026
|
+
components: a.components,
|
|
1027
|
+
...a.meta === void 0 ? {} : { meta: a.meta }
|
|
866
1028
|
}))
|
|
867
|
-
},
|
|
868
|
-
if (!
|
|
1029
|
+
}, s = Xe(l);
|
|
1030
|
+
if (!s.ok) throw new Ze(s.errors);
|
|
869
1031
|
return JSON.parse(JSON.stringify(l));
|
|
870
1032
|
}
|
|
871
|
-
function
|
|
1033
|
+
function bn(e) {
|
|
872
1034
|
if (!e || typeof e != "object" || !e.repeat)
|
|
873
|
-
throw new
|
|
874
|
-
const t =
|
|
875
|
-
if (!t.ok) throw new
|
|
1035
|
+
throw new ve("config", "defineLabelReport 需要带 repeat 的固定标签模板");
|
|
1036
|
+
const t = Xe(e);
|
|
1037
|
+
if (!t.ok) throw new Ze(t.errors);
|
|
876
1038
|
return e.repeat.dataset;
|
|
877
1039
|
}
|
|
878
|
-
function
|
|
879
|
-
if (!Array.isArray(e)) throw new
|
|
1040
|
+
function He(e, t) {
|
|
1041
|
+
if (!Array.isArray(e)) throw new ve("validate", "标签数据应为对象数组;请从业务响应中提取行数组");
|
|
880
1042
|
return { [t]: e };
|
|
881
1043
|
}
|
|
882
|
-
function
|
|
883
|
-
const { template: t, rows: n, load: r, dataSchema:
|
|
1044
|
+
function Rr(e) {
|
|
1045
|
+
const { template: t, rows: n, load: r, dataSchema: i, params: o, pagination: l, dataValidation: s } = e, a = bn(t);
|
|
884
1046
|
if (n !== void 0 == (r !== void 0) || r !== void 0 && typeof r != "function")
|
|
885
|
-
throw new
|
|
886
|
-
const c = { template: t, params: o, pagination: l, dataValidation:
|
|
887
|
-
return r ?
|
|
1047
|
+
throw new ve("config", "标签报表应且只能配置 rows 或 load 其中一种数据来源");
|
|
1048
|
+
const c = { template: t, params: o, pagination: l, dataValidation: s, ...i === void 0 ? {} : { dataSchema: { [a]: i } } };
|
|
1049
|
+
return r ? Ct({ ...c, load: r, mapData: (d) => He(d, a) }) : { ...c, datasets: He(n, a) };
|
|
888
1050
|
}
|
|
889
|
-
function
|
|
1051
|
+
function $r(e) {
|
|
890
1052
|
return e;
|
|
891
1053
|
}
|
|
892
|
-
class
|
|
1054
|
+
class F extends Error {
|
|
1055
|
+
constructor(t, n) {
|
|
1056
|
+
super(n), this.code = t, this.name = "ReportTemplateMigrationError";
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1059
|
+
function Be(e) {
|
|
1060
|
+
let t = e;
|
|
1061
|
+
if (typeof t == "string") {
|
|
1062
|
+
if (t.length > 1e7) throw new F("result", "模板迁移输入超过预算");
|
|
1063
|
+
try {
|
|
1064
|
+
t = JSON.parse(t);
|
|
1065
|
+
} catch {
|
|
1066
|
+
throw new F("result", "模板 JSON 语法无效");
|
|
1067
|
+
}
|
|
1068
|
+
}
|
|
1069
|
+
const n = et(t, { maxBytes: 1e7, error: (r, i) => new F("result", i) });
|
|
1070
|
+
if (!n || typeof n != "object" || Array.isArray(n)) throw new F("result", "模板迁移应返回文档对象");
|
|
1071
|
+
return n;
|
|
1072
|
+
}
|
|
1073
|
+
function yn(e) {
|
|
1074
|
+
if (!Array.isArray(e) || e.length > 32) throw new F("definition", "模板迁移最多声明 32 步");
|
|
1075
|
+
const t = /* @__PURE__ */ new Map();
|
|
1076
|
+
for (const n of e) {
|
|
1077
|
+
if (!n || ![n.from, n.to].every((r) => typeof r == "string" && r.trim() && r.length <= 64) || n.from === n.to || t.has(n.from) || typeof n.migrate != "function" || n.from === pe) throw new F("definition", "迁移起点应唯一,不得从当前版本降级");
|
|
1078
|
+
t.set(n.from, { ...n });
|
|
1079
|
+
}
|
|
1080
|
+
for (const n of t.keys()) {
|
|
1081
|
+
const r = /* @__PURE__ */ new Set();
|
|
1082
|
+
let i = n;
|
|
1083
|
+
for (; t.has(i); ) {
|
|
1084
|
+
if (r.has(i)) throw new F("definition", "模板迁移链存在循环");
|
|
1085
|
+
r.add(i), i = t.get(i).to;
|
|
1086
|
+
}
|
|
1087
|
+
if (i !== pe) throw new F("definition", "每条迁移链应到达当前模板版本");
|
|
1088
|
+
}
|
|
1089
|
+
return t;
|
|
1090
|
+
}
|
|
1091
|
+
function Mn(e = []) {
|
|
1092
|
+
const t = yn(e);
|
|
1093
|
+
return async (n) => {
|
|
1094
|
+
let r = Be(n);
|
|
1095
|
+
const i = [];
|
|
1096
|
+
for (; r.schemaVersion !== pe; ) {
|
|
1097
|
+
const o = typeof r.schemaVersion == "string" ? t.get(r.schemaVersion) : void 0;
|
|
1098
|
+
if (!o) throw new F("unsupported", "未声明此模板版本的迁移路径");
|
|
1099
|
+
const l = r.id, s = Be(await o.migrate(r));
|
|
1100
|
+
if (s.schemaVersion !== o.to || typeof l == "string" && s.id !== l) throw new F("result", "迁移结果版本不匹配或改变了模板身份");
|
|
1101
|
+
i.push({ from: o.from, to: o.to }), r = s;
|
|
1102
|
+
}
|
|
1103
|
+
return { document: re(r), steps: i };
|
|
1104
|
+
};
|
|
1105
|
+
}
|
|
1106
|
+
class j extends Error {
|
|
893
1107
|
constructor(t, n) {
|
|
894
1108
|
super(n), this.code = t, this.name = "ReportTemplateStoreError";
|
|
895
1109
|
}
|
|
@@ -897,626 +1111,840 @@ class D extends Error {
|
|
|
897
1111
|
function I(e) {
|
|
898
1112
|
return JSON.parse(JSON.stringify(e));
|
|
899
1113
|
}
|
|
900
|
-
function
|
|
1114
|
+
function T(e) {
|
|
901
1115
|
if (!e?.aborted) return;
|
|
902
1116
|
const t = new Error("模板操作已取消");
|
|
903
1117
|
throw t.name = "AbortError", t;
|
|
904
1118
|
}
|
|
905
|
-
function
|
|
1119
|
+
function _e(e) {
|
|
906
1120
|
const t = e ? Number(e.revision) : 0;
|
|
907
|
-
if (!Number.isSafeInteger(t) || t < 0 || t >= Number.MAX_SAFE_INTEGER) throw new
|
|
1121
|
+
if (!Number.isSafeInteger(t) || t < 0 || t >= Number.MAX_SAFE_INTEGER) throw new j("history", "修订号无效或已达上限");
|
|
908
1122
|
return String(t + 1);
|
|
909
1123
|
}
|
|
910
|
-
function
|
|
911
|
-
const n = async (
|
|
912
|
-
|
|
913
|
-
const
|
|
914
|
-
return
|
|
915
|
-
},
|
|
916
|
-
const
|
|
917
|
-
if ((
|
|
918
|
-
return
|
|
919
|
-
},
|
|
920
|
-
if (
|
|
921
|
-
return I(
|
|
922
|
-
},
|
|
1124
|
+
function Pr(e, t = {}) {
|
|
1125
|
+
const n = t.migrations ? Mn(t.migrations) : void 0, r = async (a) => n ? (await n(a)).document : re(a), i = async (a, c) => {
|
|
1126
|
+
T(c);
|
|
1127
|
+
const d = await e.read(a, c);
|
|
1128
|
+
return T(c), d ? I(d) : void 0;
|
|
1129
|
+
}, o = async (a, c) => {
|
|
1130
|
+
const d = await i(a, c.signal);
|
|
1131
|
+
if ((d?.revision ?? null) !== c.expectedRevision) throw new j("conflict", "模板已变化,请重新读取后提交");
|
|
1132
|
+
return d;
|
|
1133
|
+
}, l = async (a, c, d) => {
|
|
1134
|
+
if (T(c.signal), !await e.compareAndSwap(a.id, c.expectedRevision, I(a), { signal: c.signal, ...d ? { publication: I(d) } : {} })) throw new j("conflict", "模板已被其他请求更新");
|
|
1135
|
+
return I(a);
|
|
1136
|
+
}, s = async (a, c, d, m) => {
|
|
923
1137
|
if (t.beforePublish) {
|
|
924
|
-
|
|
925
|
-
const
|
|
926
|
-
|
|
927
|
-
S(
|
|
1138
|
+
T(d.signal);
|
|
1139
|
+
const C = a.published ? await r(a.published) : void 0;
|
|
1140
|
+
T(d.signal);
|
|
1141
|
+
const S = await t.beforePublish({ document: re(c), previous: C, signal: d.signal });
|
|
1142
|
+
if (!S || S.ok !== !0) throw new j("review", S?.issues?.find((w) => w.severity === "error")?.message ?? "模板发布检查未通过");
|
|
1143
|
+
T(d.signal);
|
|
928
1144
|
}
|
|
929
|
-
const
|
|
930
|
-
return
|
|
1145
|
+
const h = _e(a), f = re({ ...c, revision: h }), g = { revision: h, document: f, publishedAt: (t.now?.() ?? /* @__PURE__ */ new Date()).toISOString() };
|
|
1146
|
+
return m !== void 0 && (g.restoredFrom = m), l({ id: a.id, revision: h, publishedRevision: h, published: f }, d, g);
|
|
931
1147
|
};
|
|
932
1148
|
return {
|
|
933
|
-
list: async (
|
|
934
|
-
|
|
935
|
-
const
|
|
936
|
-
return
|
|
1149
|
+
list: async (a) => {
|
|
1150
|
+
T(a);
|
|
1151
|
+
const c = await e.list(a);
|
|
1152
|
+
return T(a), I(c);
|
|
937
1153
|
},
|
|
938
|
-
get: async (
|
|
939
|
-
const
|
|
940
|
-
return
|
|
1154
|
+
get: async (a, c = {}) => {
|
|
1155
|
+
const d = await i(a, c.signal), m = c.draft ? d?.draft : d?.published, h = m ? await r(m) : void 0;
|
|
1156
|
+
return T(c.signal), h;
|
|
941
1157
|
},
|
|
942
|
-
history: async (
|
|
943
|
-
|
|
944
|
-
const
|
|
945
|
-
return
|
|
1158
|
+
history: async (a, c) => {
|
|
1159
|
+
T(c);
|
|
1160
|
+
const d = await e.history(a, c);
|
|
1161
|
+
return T(c), I(d);
|
|
946
1162
|
},
|
|
947
|
-
saveDraft: async (
|
|
948
|
-
|
|
949
|
-
const
|
|
950
|
-
return
|
|
951
|
-
id:
|
|
952
|
-
revision:
|
|
953
|
-
draft: { ...
|
|
954
|
-
...
|
|
955
|
-
},
|
|
1163
|
+
saveDraft: async (a, c) => {
|
|
1164
|
+
c = { ...c }, T(c.signal);
|
|
1165
|
+
const d = await r(t.migrate ? await t.migrate(a) : a), m = await o(d.id, c), h = _e(m);
|
|
1166
|
+
return l({
|
|
1167
|
+
id: d.id,
|
|
1168
|
+
revision: h,
|
|
1169
|
+
draft: { ...d, revision: h },
|
|
1170
|
+
...m?.publishedRevision ? { publishedRevision: m.publishedRevision, published: m.published } : {}
|
|
1171
|
+
}, c);
|
|
956
1172
|
},
|
|
957
|
-
publish: async (
|
|
958
|
-
|
|
959
|
-
const
|
|
960
|
-
if (!
|
|
961
|
-
if (!
|
|
962
|
-
return
|
|
1173
|
+
publish: async (a, c) => {
|
|
1174
|
+
c = { ...c };
|
|
1175
|
+
const d = await o(a, c);
|
|
1176
|
+
if (!d) throw new j("missing", "模板不存在");
|
|
1177
|
+
if (!d.draft) throw new j("draft", "没有可发布的草稿");
|
|
1178
|
+
return s(d, await r(d.draft), c);
|
|
963
1179
|
},
|
|
964
|
-
rollback: async (
|
|
965
|
-
|
|
966
|
-
const
|
|
967
|
-
if (!
|
|
968
|
-
|
|
969
|
-
const
|
|
970
|
-
if (!
|
|
971
|
-
return
|
|
1180
|
+
rollback: async (a, c, d) => {
|
|
1181
|
+
d = { ...d };
|
|
1182
|
+
const m = await o(a, d);
|
|
1183
|
+
if (!m) throw new j("missing", "模板不存在");
|
|
1184
|
+
T(d.signal);
|
|
1185
|
+
const h = await e.getVersion(a, c, d.signal);
|
|
1186
|
+
if (!h) throw new j("history", "历史修订不存在");
|
|
1187
|
+
return s(m, await r(h.document), d, c);
|
|
972
1188
|
}
|
|
973
1189
|
};
|
|
974
1190
|
}
|
|
975
|
-
function
|
|
1191
|
+
function Ar() {
|
|
976
1192
|
const e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map();
|
|
977
1193
|
return {
|
|
978
1194
|
read: async (n, r) => {
|
|
979
|
-
|
|
980
|
-
const
|
|
981
|
-
return
|
|
1195
|
+
T(r);
|
|
1196
|
+
const i = e.get(n);
|
|
1197
|
+
return i ? I(i) : void 0;
|
|
982
1198
|
},
|
|
983
|
-
list: async (n) => (
|
|
984
|
-
history: async (n, r) => (
|
|
985
|
-
getVersion: async (n, r,
|
|
986
|
-
|
|
1199
|
+
list: async (n) => (T(n), Array.from(e.values(), ({ id: r, revision: i, publishedRevision: o }) => ({ id: r, revision: i, ...o ? { publishedRevision: o } : {} }))),
|
|
1200
|
+
history: async (n, r) => (T(r), Array.from(t.get(n)?.values() ?? [], (i) => I(i))),
|
|
1201
|
+
getVersion: async (n, r, i) => {
|
|
1202
|
+
T(i);
|
|
987
1203
|
const o = t.get(n)?.get(r);
|
|
988
1204
|
return o ? I(o) : void 0;
|
|
989
1205
|
},
|
|
990
|
-
compareAndSwap: async (n, r,
|
|
991
|
-
if (
|
|
992
|
-
if (
|
|
993
|
-
const l = I(
|
|
994
|
-
if (
|
|
995
|
-
const
|
|
996
|
-
if (
|
|
997
|
-
|
|
1206
|
+
compareAndSwap: async (n, r, i, o) => {
|
|
1207
|
+
if (T(o.signal), (e.get(n)?.revision ?? null) !== r) return !1;
|
|
1208
|
+
if (i.id !== n) throw new j("history", "状态 ID 与存储 ID 不一致");
|
|
1209
|
+
const l = I(i), s = o.publication;
|
|
1210
|
+
if (s) {
|
|
1211
|
+
const a = t.get(n) ?? /* @__PURE__ */ new Map();
|
|
1212
|
+
if (a.has(s.revision) || s.revision !== i.revision || s.document.id !== n) throw new j("history", "发布修订不可覆盖,且必须与状态修订和模板 ID 一致");
|
|
1213
|
+
a.set(s.revision, I(s)), t.set(n, a);
|
|
998
1214
|
}
|
|
999
1215
|
return e.set(n, l), !0;
|
|
1000
1216
|
}
|
|
1001
1217
|
};
|
|
1002
1218
|
}
|
|
1003
|
-
|
|
1219
|
+
class u extends Error {
|
|
1220
|
+
constructor(t, n, r = "$", i) {
|
|
1221
|
+
super(n), this.code = t, this.path = r, this.extensionId = i, this.name = "ReportComponentExtensionError";
|
|
1222
|
+
}
|
|
1223
|
+
}
|
|
1224
|
+
const vn = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
|
|
1225
|
+
function K(e, t = "$", n = { nodes: 0, units: 0 }, r = 0) {
|
|
1226
|
+
if (++n.nodes > 2048 || r > 16) throw new u("binding", "Component extension JSON exceeds its depth/node budget.", t);
|
|
1227
|
+
if (n.units > 64 * 1024) throw new u("binding", "Component extension JSON exceeds 64 Ki UTF-16 units.", t);
|
|
1228
|
+
if (e === null || typeof e == "boolean" || typeof e == "number" && Number.isFinite(e)) return e;
|
|
1229
|
+
if (typeof e == "string") {
|
|
1230
|
+
if (n.units += e.length, n.units > 64 * 1024) throw new u("binding", "Component extension JSON exceeds 64 Ki UTF-16 units.", t);
|
|
1231
|
+
return e;
|
|
1232
|
+
}
|
|
1233
|
+
if (!e || typeof e != "object") throw new u("binding", "Component extension values must be finite JSON data.", t);
|
|
1234
|
+
const i = Object.getPrototypeOf(e);
|
|
1235
|
+
if (Array.isArray(e)) return xn(e, t, n, r);
|
|
1236
|
+
if (i !== Object.prototype && i !== null) throw new u("binding", "Component extension values must be plain JSON objects.", t);
|
|
1237
|
+
return Sn(e, t, n, r);
|
|
1238
|
+
}
|
|
1239
|
+
function Pe(e, t, n) {
|
|
1240
|
+
const r = Object.getOwnPropertyDescriptor(e, t);
|
|
1241
|
+
if (typeof t != "string" || vn.has(t) || !r?.enumerable || r.get || r.set)
|
|
1242
|
+
throw new u("binding", "Component extension JSON contains an unsafe key or accessor.", n);
|
|
1243
|
+
return r.value;
|
|
1244
|
+
}
|
|
1245
|
+
function xn(e, t, n, r) {
|
|
1246
|
+
if (Object.getPrototypeOf(e) !== Array.prototype || e.length > 2048 || Reflect.ownKeys(e).length !== e.length + 1) throw new u("binding", "Component extension arrays must be plain dense JSON arrays.", t);
|
|
1247
|
+
return Object.freeze(Array.from({ length: e.length }, (i, o) => K(Pe(e, String(o), `${t}[${o}]`), `${t}[${o}]`, n, r + 1)));
|
|
1248
|
+
}
|
|
1249
|
+
function Sn(e, t, n, r) {
|
|
1250
|
+
const i = Reflect.ownKeys(e);
|
|
1251
|
+
if (i.length > 2048) throw new u("binding", "Component extension JSON exceeds its node budget.", t);
|
|
1252
|
+
const o = i.map((l) => {
|
|
1253
|
+
const s = `${t}.${String(l)}`, a = Pe(e, l, s);
|
|
1254
|
+
return n.units += String(l).length, [l, K(a, s, n, r + 1)];
|
|
1255
|
+
});
|
|
1256
|
+
return Object.freeze(Object.fromEntries(o));
|
|
1257
|
+
}
|
|
1258
|
+
function Q(e, t) {
|
|
1259
|
+
if (!e || typeof e != "object" || Array.isArray(e)) throw new u("binding", "Expected a component extension object.", t);
|
|
1260
|
+
return e;
|
|
1261
|
+
}
|
|
1262
|
+
function me(e, t, n) {
|
|
1263
|
+
for (const r of Object.keys(e)) if (!t.includes(r)) throw new u("binding", "Unknown component extension property.", `${n}.${r}`);
|
|
1264
|
+
}
|
|
1265
|
+
function be(e, t, n = 160) {
|
|
1266
|
+
if (typeof e != "string" || !e.trim() || e.length > n) throw new u("definition", "Component extension labels must be bounded nonempty strings.", t);
|
|
1267
|
+
}
|
|
1268
|
+
function ut(e, t) {
|
|
1269
|
+
if (typeof e != "string" || !/^[a-z][a-z\d_.-]{0,127}$/i.test(e)) throw new u("definition", "Invalid component extension id.", "$.id");
|
|
1270
|
+
if (typeof t != "string" || t.length > 64 || !/^\d+\.\d+\.\d+(?:-[\da-z.-]+)?(?:\+[\da-z.-]+)?$/i.test(t)) throw new u("definition", "Component extension version must be explicit semantic version text.", "$.version", e);
|
|
1271
|
+
}
|
|
1272
|
+
function Ae(e, t, n) {
|
|
1273
|
+
if (!(e === null && !t.required)) {
|
|
1274
|
+
if (typeof e !== t.type || typeof e == "number" && !Number.isFinite(e)) throw new u("binding", `Expected ${t.type} component property.`, n);
|
|
1275
|
+
if (t.options && !t.options.some((r) => Object.is(r, e))) throw new u("binding", "Component property is outside its declared options.", n);
|
|
1276
|
+
if (typeof e == "number" && (e < (t.min ?? -1 / 0) || e > (t.max ?? 1 / 0))) throw new u("binding", "Component property is outside its declared range.", n);
|
|
1277
|
+
if (typeof e == "string" && e.length > (t.maxLength ?? 64 * 1024)) throw new u("binding", "Component property exceeds maxLength.", n);
|
|
1278
|
+
}
|
|
1279
|
+
}
|
|
1280
|
+
function En(e, t) {
|
|
1281
|
+
const n = Q(e, t);
|
|
1282
|
+
me(n, ["label", "type", "required", "default", "options", "min", "max", "maxLength"], t);
|
|
1283
|
+
const r = n;
|
|
1284
|
+
if (be(r.label, `${t}.label`), !["string", "number", "boolean"].includes(r.type)) throw new u("definition", "Unknown component property type.", t);
|
|
1285
|
+
if (r.required !== void 0 && typeof r.required != "boolean") throw new u("definition", "Component property required must be boolean.", t);
|
|
1286
|
+
Cn(r, t), r.default !== void 0 && Ae(r.default, r, `${t}.default`);
|
|
1287
|
+
}
|
|
1288
|
+
function Cn(e, t) {
|
|
1289
|
+
for (const n of ["min", "max"]) if (e[n] !== void 0 && (e.type !== "number" || !Number.isFinite(e[n]))) throw new u("definition", "Numeric property bounds must be finite numbers.", t);
|
|
1290
|
+
if ((e.min ?? -1 / 0) > (e.max ?? 1 / 0)) throw new u("definition", "Component property min exceeds max.", t);
|
|
1291
|
+
if (e.maxLength !== void 0 && (e.type !== "string" || !Number.isSafeInteger(e.maxLength) || e.maxLength < 0 || e.maxLength > 64 * 1024)) throw new u("definition", "Invalid component property maxLength.", t);
|
|
1292
|
+
if (e.options !== void 0) {
|
|
1293
|
+
if (!Array.isArray(e.options) || !e.options.length || e.options.length > 64) throw new u("definition", "Component property options must contain 1 to 64 values.", t);
|
|
1294
|
+
for (const n of e.options) Ae(n, { ...e, options: void 0 }, `${t}.options`);
|
|
1295
|
+
}
|
|
1296
|
+
}
|
|
1297
|
+
function Tn(e) {
|
|
1298
|
+
const t = Object.getPrototypeOf(e);
|
|
1299
|
+
if (t !== Object.prototype && t !== null) throw new u("definition", "Component extension metadata must be a plain object.");
|
|
1300
|
+
const n = Reflect.ownKeys(e).filter((i) => i !== "load").map((i) => [i, Pe(e, i, `$.${String(i)}`)]), r = K(Object.fromEntries(n));
|
|
1301
|
+
if (me(r, ["id", "version", "kind", "label", "description", "properties"], "$"), ut(r.id, r.version), be(r.label, "$.label"), !["image", "chart", "barcode", "qrcode"].includes(r.kind)) throw new u("definition", "Extension kind must use the existing image-backed output pipeline.", "$.kind");
|
|
1302
|
+
if (r.description !== void 0 && be(r.description, "$.description", 2048), r.properties !== void 0) {
|
|
1303
|
+
const i = Q(r.properties, "$.properties");
|
|
1304
|
+
if (Object.keys(i).length > 64) throw new u("definition", "Component extension supports at most 64 properties.", "$.properties");
|
|
1305
|
+
for (const [o, l] of Object.entries(i)) En(l, `$.properties.${o}`);
|
|
1306
|
+
}
|
|
1307
|
+
return r;
|
|
1308
|
+
}
|
|
1309
|
+
function pt(e, t) {
|
|
1310
|
+
const n = Q(K(t ?? {}), "$.props"), r = {};
|
|
1311
|
+
for (const i of Object.keys(n)) if (!Object.prototype.hasOwnProperty.call(e.properties ?? {}, i)) throw new u("binding", "Unknown component property.", `$.props.${i}`, e.id);
|
|
1312
|
+
for (const [i, o] of Object.entries(e.properties ?? {})) {
|
|
1313
|
+
const l = Object.prototype.hasOwnProperty.call(n, i) ? n[i] : o.default;
|
|
1314
|
+
if (l === void 0) {
|
|
1315
|
+
if (o.required) throw new u("binding", "Required component property is missing.", `$.props.${i}`, e.id);
|
|
1316
|
+
continue;
|
|
1317
|
+
}
|
|
1318
|
+
Ae(l, o, `$.props.${i}`), r[i] = l;
|
|
1319
|
+
}
|
|
1320
|
+
return Object.freeze(r);
|
|
1321
|
+
}
|
|
1322
|
+
const H = "componentExtension";
|
|
1323
|
+
function Rn(e) {
|
|
1324
|
+
const t = Object.getOwnPropertyDescriptor(e, "meta")?.value, n = t && Object.getOwnPropertyDescriptor(t, H);
|
|
1325
|
+
if (n) {
|
|
1326
|
+
if (n.get || n.set) throw new u("binding", "Component extension binding cannot be an accessor.", `$.meta.${H}`);
|
|
1327
|
+
return n.value;
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
1330
|
+
function $n(e, t) {
|
|
1331
|
+
const n = Q(K(Rn(t)), `$.meta.${H}`);
|
|
1332
|
+
me(n, ["id", "version", "props", "binding"], `$.meta.${H}`), ut(n.id, n.version);
|
|
1333
|
+
const r = e.get(n.id);
|
|
1334
|
+
if (!r) throw new u("binding", "Component extension is not registered in this runtime.", `$.meta.${H}.id`, n.id);
|
|
1335
|
+
if (r.metadata.version !== n.version || r.metadata.kind !== t.kind) throw new u("binding", "Component extension version or image kind does not match its registration.", `$.meta.${H}`, r.metadata.id);
|
|
1336
|
+
const i = Object.freeze({ id: r.metadata.id, version: r.metadata.version, props: pt(r.metadata, n.props), ...n.binding === void 0 ? {} : { binding: n.binding } });
|
|
1337
|
+
return { entry: r, extension: i };
|
|
1338
|
+
}
|
|
1339
|
+
function We(e) {
|
|
1340
|
+
return e.released ??= Promise.resolve().then(() => e.renderer?.dispose?.());
|
|
1341
|
+
}
|
|
1342
|
+
function V(e) {
|
|
1343
|
+
if (e) throw new u("disposed", "Component registry has been disposed.");
|
|
1344
|
+
}
|
|
1345
|
+
function Pn(e) {
|
|
1346
|
+
if (!e || typeof e != "object") throw new u("definition", "Component extension definition must be an object.");
|
|
1347
|
+
if (Object.getPrototypeOf(e) !== Object.prototype && Object.getPrototypeOf(e) !== null) throw new u("definition", "Component extension definition must be a plain object.");
|
|
1348
|
+
const t = Object.getOwnPropertyDescriptor(e, "load");
|
|
1349
|
+
if (!t || t.get || t.set || typeof t.value != "function") throw new u("definition", "Component extension needs a trusted runtime loader.", "$.load");
|
|
1350
|
+
return { metadata: Tn(e), load: t.value };
|
|
1351
|
+
}
|
|
1352
|
+
function An(e, t) {
|
|
1353
|
+
if (!(e && typeof e.render == "function" && (e.dispose === void 0 || typeof e.dispose == "function"))) {
|
|
1354
|
+
if (e && typeof e.dispose == "function")
|
|
1355
|
+
try {
|
|
1356
|
+
Promise.resolve(e.dispose()).catch(() => {
|
|
1357
|
+
});
|
|
1358
|
+
} catch {
|
|
1359
|
+
}
|
|
1360
|
+
throw new u("load", "Component loader must return render and optional dispose methods.", "$.load", t);
|
|
1361
|
+
}
|
|
1362
|
+
}
|
|
1363
|
+
function kn(e, t) {
|
|
1364
|
+
const n = new AbortController(), r = () => n.abort(e.reason), i = () => n.abort(t.reason);
|
|
1365
|
+
return e.aborted ? r() : e.addEventListener("abort", r, { once: !0 }), t.aborted ? i() : t.addEventListener("abort", i, { once: !0 }), { signal: n.signal, dispose() {
|
|
1366
|
+
e.removeEventListener("abort", r), t.removeEventListener("abort", i);
|
|
1367
|
+
} };
|
|
1368
|
+
}
|
|
1369
|
+
function kr(e) {
|
|
1370
|
+
if (!Array.isArray(e) || e.length > 128) throw new u("definition", "Register at most 128 component extensions.");
|
|
1371
|
+
const t = /* @__PURE__ */ new Map(), n = new AbortController();
|
|
1372
|
+
let r = !1, i;
|
|
1373
|
+
for (const a of e) {
|
|
1374
|
+
const c = Pn(a), d = c.metadata.id;
|
|
1375
|
+
if (t.has(d)) throw new u("definition", "Component extension id is already registered.", "$.id", d);
|
|
1376
|
+
t.set(d, c);
|
|
1377
|
+
}
|
|
1378
|
+
function o(a) {
|
|
1379
|
+
return V(r), a.pending || (a.pending = Promise.resolve().then(() => (V(r), a.load(n.signal))).then(async (c) => (An(c, a.metadata.id), a.renderer = c, r && (await We(a), V(r)), c)).catch((c) => {
|
|
1380
|
+
throw a.pending = void 0, c instanceof u ? c : Object.assign(new u("load", "Component extension loader failed.", "$.load", a.metadata.id), { cause: c });
|
|
1381
|
+
})), a.pending;
|
|
1382
|
+
}
|
|
1383
|
+
const l = async (a) => {
|
|
1384
|
+
V(r);
|
|
1385
|
+
const { entry: c, extension: d } = $n(t, a.component), m = kn(a.signal, n.signal);
|
|
1386
|
+
try {
|
|
1387
|
+
const h = await Le(o(c), m.signal);
|
|
1388
|
+
return await Le(h.render({ ...a, signal: m.signal, extension: d }), m.signal);
|
|
1389
|
+
} finally {
|
|
1390
|
+
m.dispose();
|
|
1391
|
+
}
|
|
1392
|
+
}, s = {
|
|
1393
|
+
assets: Object.freeze({ get assetRegistry() {
|
|
1394
|
+
return s;
|
|
1395
|
+
} }),
|
|
1396
|
+
describe(a) {
|
|
1397
|
+
return V(r), Object.freeze([...t.values()].map((c) => c.metadata).filter((c) => !a || c.kind === a));
|
|
1398
|
+
},
|
|
1399
|
+
hasExtension(a, c, d) {
|
|
1400
|
+
const m = t.get(a)?.metadata;
|
|
1401
|
+
return !r && m?.version === c && m.kind === d;
|
|
1402
|
+
},
|
|
1403
|
+
rendererFor(a) {
|
|
1404
|
+
const c = Object.getOwnPropertyDescriptor(a, "meta")?.value;
|
|
1405
|
+
return c && Object.prototype.hasOwnProperty.call(c, H) ? l : void 0;
|
|
1406
|
+
},
|
|
1407
|
+
createComponent(a, c = {}) {
|
|
1408
|
+
V(r);
|
|
1409
|
+
const d = t.get(a);
|
|
1410
|
+
if (!d) throw new u("binding", "Component extension is not registered in this runtime.", "$.id", a);
|
|
1411
|
+
const m = Q(K(c), "$");
|
|
1412
|
+
me(m, ["props", "binding"], "$");
|
|
1413
|
+
const h = { id: a, version: d.metadata.version, props: pt(d.metadata, m.props), ...m.binding === void 0 ? {} : { binding: m.binding } };
|
|
1414
|
+
return { kind: d.metadata.kind, meta: { [H]: Object.freeze(h) } };
|
|
1415
|
+
},
|
|
1416
|
+
dispose() {
|
|
1417
|
+
return i || (r = !0, n.abort(new u("disposed", "Component registry has been disposed.")), i = Promise.allSettled([...t.values()].filter((a) => a.renderer).map(We)).then((a) => {
|
|
1418
|
+
const c = a.find((d) => d.status === "rejected");
|
|
1419
|
+
if (c?.status === "rejected") throw c.reason;
|
|
1420
|
+
}), i);
|
|
1421
|
+
}
|
|
1422
|
+
};
|
|
1423
|
+
return s;
|
|
1424
|
+
}
|
|
1425
|
+
function Or(e) {
|
|
1004
1426
|
return e.map((t) => t.map((n) => /[\t\r\n"]/.test(n) ? `"${n.replace(/"/g, '""')}"` : n).join(" ")).join(`\r
|
|
1005
1427
|
`);
|
|
1006
1428
|
}
|
|
1007
|
-
function
|
|
1429
|
+
function On(e, t) {
|
|
1008
1430
|
const n = e[e.length - 1];
|
|
1009
1431
|
e.length > 1 && n?.length === 1 && n[0] === "" && /[\r\n]$/.test(t) && e.pop();
|
|
1010
1432
|
}
|
|
1011
|
-
function
|
|
1433
|
+
function Ir(e, t = 1e4) {
|
|
1012
1434
|
if (e.length > 4 * 1024 * 1024) throw new Error("Clipboard text limit exceeded");
|
|
1013
1435
|
const n = [[]];
|
|
1014
|
-
let r = "",
|
|
1015
|
-
function
|
|
1436
|
+
let r = "", i = !1, o = !1, l = 0;
|
|
1437
|
+
function s() {
|
|
1016
1438
|
if (++l > t) throw new Error("Clipboard cell limit exceeded");
|
|
1017
1439
|
n[n.length - 1].push(r), r = "", o = !1;
|
|
1018
1440
|
}
|
|
1019
|
-
for (let
|
|
1020
|
-
const c = e[
|
|
1021
|
-
if (
|
|
1441
|
+
for (let a = 0; a < e.length; a++) {
|
|
1442
|
+
const c = e[a];
|
|
1443
|
+
if (i) {
|
|
1022
1444
|
if (c !== '"') {
|
|
1023
1445
|
r += c;
|
|
1024
1446
|
continue;
|
|
1025
1447
|
}
|
|
1026
|
-
if (e[
|
|
1027
|
-
r += '"',
|
|
1448
|
+
if (e[a + 1] === '"') {
|
|
1449
|
+
r += '"', a++;
|
|
1028
1450
|
continue;
|
|
1029
1451
|
}
|
|
1030
|
-
|
|
1452
|
+
i = !1, o = !0;
|
|
1031
1453
|
continue;
|
|
1032
1454
|
}
|
|
1033
1455
|
if (c === '"' && !r && !o) {
|
|
1034
|
-
|
|
1456
|
+
i = !0;
|
|
1035
1457
|
continue;
|
|
1036
1458
|
}
|
|
1037
1459
|
if (c === " ") {
|
|
1038
|
-
|
|
1460
|
+
s();
|
|
1039
1461
|
continue;
|
|
1040
1462
|
}
|
|
1041
1463
|
if (c === "\r" || c === `
|
|
1042
1464
|
`) {
|
|
1043
|
-
|
|
1044
|
-
` &&
|
|
1465
|
+
s(), n.push([]), c === "\r" && e[a + 1] === `
|
|
1466
|
+
` && a++;
|
|
1045
1467
|
continue;
|
|
1046
1468
|
}
|
|
1047
1469
|
if (o) throw new Error("Invalid quoted clipboard value");
|
|
1048
1470
|
r += c;
|
|
1049
1471
|
}
|
|
1050
|
-
if (
|
|
1051
|
-
return
|
|
1472
|
+
if (i) throw new Error("Unclosed clipboard quote");
|
|
1473
|
+
return s(), On(n, e), n;
|
|
1052
1474
|
}
|
|
1053
|
-
class
|
|
1475
|
+
class In extends Error {
|
|
1054
1476
|
constructor(t, n, r) {
|
|
1055
|
-
const
|
|
1056
|
-
definition: `${
|
|
1057
|
-
type: `${
|
|
1058
|
-
required: `${
|
|
1059
|
-
min: `${
|
|
1060
|
-
max: `${
|
|
1061
|
-
precision: `${
|
|
1062
|
-
length: `${
|
|
1063
|
-
choice: `${
|
|
1064
|
-
date: `${
|
|
1477
|
+
const i = typeof n.label == "string" ? n.label : "单元格", o = {
|
|
1478
|
+
definition: `${i}的编辑器配置无效`,
|
|
1479
|
+
type: `${i}的编辑器与数据类型不一致`,
|
|
1480
|
+
required: `${i}不能为空`,
|
|
1481
|
+
min: `${i}不能小于 ${r}`,
|
|
1482
|
+
max: `${i}不能大于 ${r}`,
|
|
1483
|
+
precision: `${i}最多保留 ${r} 位小数`,
|
|
1484
|
+
length: `${i}最多允许 ${r} 个字符`,
|
|
1485
|
+
choice: `${i}请选择有效选项`,
|
|
1486
|
+
date: `${i}请输入有效日期(YYYY-MM-DD)`
|
|
1065
1487
|
};
|
|
1066
1488
|
super(o[t]), this.code = t, this.field = n, this.expected = r, this.name = "ReportCellFieldError";
|
|
1067
1489
|
}
|
|
1068
1490
|
}
|
|
1069
|
-
function
|
|
1070
|
-
throw new
|
|
1491
|
+
function b(e, t, n) {
|
|
1492
|
+
throw new In(t, e, n);
|
|
1071
1493
|
}
|
|
1072
|
-
function
|
|
1494
|
+
function wt(e) {
|
|
1073
1495
|
if (typeof e != "string" || !/^\d{4}-\d{2}-\d{2}$/.test(e) || e.startsWith("0000-")) return !1;
|
|
1074
1496
|
const t = /* @__PURE__ */ new Date(`${e}T00:00:00.000Z`);
|
|
1075
1497
|
return Number.isFinite(t.getTime()) && t.toISOString().slice(0, 10) === e;
|
|
1076
1498
|
}
|
|
1077
|
-
function
|
|
1499
|
+
function Nn(e) {
|
|
1078
1500
|
const [t = "", n = "0"] = String(e).toLowerCase().split("e");
|
|
1079
1501
|
return Math.max(0, (t.split(".")[1]?.length ?? 0) - Number(n));
|
|
1080
1502
|
}
|
|
1081
|
-
function
|
|
1082
|
-
e.min !== void 0 && t < e.min &&
|
|
1503
|
+
function Ln(e, t) {
|
|
1504
|
+
e.min !== void 0 && t < e.min && b(e, "min", e.min), e.max !== void 0 && t > e.max && b(e, "max", e.max), e.precision !== void 0 && Nn(t) > e.precision && b(e, "precision", e.precision);
|
|
1083
1505
|
}
|
|
1084
|
-
function
|
|
1085
|
-
|
|
1506
|
+
function Dn(e, t) {
|
|
1507
|
+
wt(t) || b(e, "date"), e.min !== void 0 && t < e.min && b(e, "min", e.min), e.max !== void 0 && t > e.max && b(e, "max", e.max);
|
|
1086
1508
|
}
|
|
1087
|
-
function
|
|
1088
|
-
[e.min, e.max].some((t) => t !== void 0 && !Number.isFinite(t)) &&
|
|
1509
|
+
function jn(e) {
|
|
1510
|
+
[e.min, e.max].some((t) => t !== void 0 && !Number.isFinite(t)) && b(e, "definition"), e.min !== void 0 && e.max !== void 0 && e.min > e.max && b(e, "definition"), e.precision !== void 0 && (!Number.isInteger(e.precision) || e.precision < 0 || e.precision > 15) && b(e, "definition");
|
|
1089
1511
|
}
|
|
1090
|
-
function
|
|
1091
|
-
[e.min, e.max].some((t) => t !== void 0 && !
|
|
1512
|
+
function Fn(e) {
|
|
1513
|
+
[e.min, e.max].some((t) => t !== void 0 && !wt(t)) && b(e, "definition"), e.min !== void 0 && e.max !== void 0 && e.min > e.max && b(e, "definition");
|
|
1092
1514
|
}
|
|
1093
|
-
function
|
|
1094
|
-
(!Array.isArray(t.options) || !t.options.length) &&
|
|
1515
|
+
function zn(e, t) {
|
|
1516
|
+
(!Array.isArray(t.options) || !t.options.length) && b(t, "definition");
|
|
1095
1517
|
const n = e.valueType === "text" ? "string" : e.valueType, r = /* @__PURE__ */ new Set();
|
|
1096
|
-
for (const
|
|
1097
|
-
(!
|
|
1518
|
+
for (const i of t.options)
|
|
1519
|
+
(!i || typeof i.value !== n || typeof i.value == "number" && !Number.isFinite(i.value)) && b(t, "definition"), i.label !== void 0 && typeof i.label != "string" && b(t, "definition"), r.has(i.value) && b(t, "definition"), r.add(i.value);
|
|
1098
1520
|
}
|
|
1099
|
-
function
|
|
1100
|
-
e.required !== void 0 && typeof e.required != "boolean" &&
|
|
1521
|
+
function Hn(e) {
|
|
1522
|
+
e.required !== void 0 && typeof e.required != "boolean" && b(e, "definition"), [e.label, e.hint, e.unit].some((t) => t !== void 0 && typeof t != "string") && b(e, "definition"), e.type === "boolean" && [e.trueLabel, e.falseLabel].some((t) => t !== void 0 && typeof t != "string") && b(e, "definition");
|
|
1101
1523
|
}
|
|
1102
|
-
function
|
|
1103
|
-
(!t || typeof t != "object" || Array.isArray(t) || !["text", "number", "boolean", "enum", "date"].includes(t.type)) &&
|
|
1524
|
+
function Bn(e, t) {
|
|
1525
|
+
(!t || typeof t != "object" || Array.isArray(t) || !["text", "number", "boolean", "enum", "date"].includes(t.type)) && b(t ?? { type: "text" }, "definition"), Hn(t), (t.type === "number" || t.type === "boolean") && e.valueType !== t.type && b(t, "type"), (t.type === "text" || t.type === "date") && e.valueType !== "text" && b(t, "type"), t.type === "number" && jn(t), t.type === "text" && t.maxLength !== void 0 && (!Number.isInteger(t.maxLength) || t.maxLength < 0) && b(t, "definition"), t.type === "date" && Fn(t), t.type === "enum" && zn(e, t);
|
|
1104
1526
|
}
|
|
1105
|
-
function
|
|
1106
|
-
if (!e.editable) throw new
|
|
1107
|
-
n &&
|
|
1108
|
-
const r =
|
|
1109
|
-
return n ? (n.required && typeof r == "string" && !r.trim() &&
|
|
1527
|
+
function Nr(e, t, n) {
|
|
1528
|
+
if (!e.editable) throw new Tt("readonly");
|
|
1529
|
+
n && Bn(e, n);
|
|
1530
|
+
const r = Rt(e, t);
|
|
1531
|
+
return n ? (n.required && typeof r == "string" && !r.trim() && b(n, "required"), r === null || r === "" ? (n.required && b(n, "required"), r) : (n.type === "number" && Ln(n, r), n.type === "date" && Dn(n, r), n.type === "text" && n.maxLength !== void 0 && [...String(r)].length > n.maxLength && b(n, "length", n.maxLength), n.type === "enum" && !n.options.some((i) => Object.is(i.value, r)) && b(n, "choice"), r)) : r;
|
|
1110
1532
|
}
|
|
1111
|
-
class
|
|
1533
|
+
class M extends Error {
|
|
1112
1534
|
constructor(t) {
|
|
1113
1535
|
super(`Report calculation: ${t}`), this.code = t, this.name = "ReportCalculationError";
|
|
1114
1536
|
}
|
|
1115
1537
|
}
|
|
1116
|
-
function
|
|
1538
|
+
function G(e) {
|
|
1117
1539
|
if (!e?.aborted) return;
|
|
1118
1540
|
const t = new Error("Calculation cancelled");
|
|
1119
1541
|
throw t.name = "AbortError", t;
|
|
1120
1542
|
}
|
|
1121
|
-
async function
|
|
1543
|
+
async function se(e, t = 1) {
|
|
1122
1544
|
const n = Math.floor(e.scanned / 2048);
|
|
1123
|
-
if (e.scanned += t, e.scanned > e.maxScanned) throw new
|
|
1124
|
-
|
|
1545
|
+
if (e.scanned += t, e.scanned > e.maxScanned) throw new M("limit");
|
|
1546
|
+
G(e.signal), Math.floor(e.scanned / 2048) > n && (await e.yieldToHost(), G(e.signal));
|
|
1125
1547
|
}
|
|
1126
|
-
function
|
|
1548
|
+
function ke(e) {
|
|
1127
1549
|
return e.table?.role === "header" ? -Math.max(1, e.grid?.cells.length ?? 1) : e.table?.rowIndex ?? 0;
|
|
1128
1550
|
}
|
|
1129
|
-
function
|
|
1130
|
-
if (![t.pageIndex, t.componentIndex, t.rowIndex, t.columnIndex].every((
|
|
1551
|
+
function Ve(e, t, n) {
|
|
1552
|
+
if (![t.pageIndex, t.componentIndex, t.rowIndex, t.columnIndex].every((s) => Number.isSafeInteger(s) && s >= 0)) throw new M("selection");
|
|
1131
1553
|
const r = e.pages[t.pageIndex]?.components[t.componentIndex];
|
|
1132
|
-
if (!r?.grid || t.rowIndex >= r.grid.cells.length) throw new
|
|
1133
|
-
const
|
|
1134
|
-
if (t.columnIndex >=
|
|
1554
|
+
if (!r?.grid || t.rowIndex >= r.grid.cells.length) throw new M("selection");
|
|
1555
|
+
const i = r.grid.colWidthsMm?.length ?? r.grid.cells.reduce((s, a) => Math.max(s, a.length), 1);
|
|
1556
|
+
if (t.columnIndex >= i) throw new M("selection");
|
|
1135
1557
|
const o = r.table, l = e.pages[n.pageIndex]?.components[n.componentIndex]?.table;
|
|
1136
1558
|
if (o && l && o.id === l.id) {
|
|
1137
|
-
const
|
|
1138
|
-
if (
|
|
1139
|
-
return { grid: o.id, row:
|
|
1559
|
+
const s = l.columnKeys.indexOf(o.columnKeys[t.columnIndex] ?? "");
|
|
1560
|
+
if (s < 0) throw new M("selection");
|
|
1561
|
+
return { grid: o.id, row: ke(r) + t.rowIndex, column: s };
|
|
1140
1562
|
}
|
|
1141
1563
|
return { grid: `${t.pageIndex}:${t.componentIndex}`, row: t.rowIndex, column: t.columnIndex };
|
|
1142
1564
|
}
|
|
1143
|
-
function
|
|
1144
|
-
const r =
|
|
1145
|
-
if (r.grid !==
|
|
1146
|
-
const o = (Math.abs(r.row -
|
|
1147
|
-
if (!Number.isSafeInteger(o) || o > n) throw new
|
|
1148
|
-
return { grid: r.grid, rowStart: Math.min(r.row,
|
|
1565
|
+
function _n(e, t, n) {
|
|
1566
|
+
const r = Ve(e, t.anchor, t.anchor), i = Ve(e, t.focus, t.anchor);
|
|
1567
|
+
if (r.grid !== i.grid) throw new M("selection");
|
|
1568
|
+
const o = (Math.abs(r.row - i.row) + 1) * (Math.abs(r.column - i.column) + 1);
|
|
1569
|
+
if (!Number.isSafeInteger(o) || o > n) throw new M("limit");
|
|
1570
|
+
return { grid: r.grid, rowStart: Math.min(r.row, i.row), rowEnd: Math.max(r.row, i.row), columnStart: Math.min(r.column, i.column), columnEnd: Math.max(r.column, i.column), origin: e.pages[t.anchor.pageIndex].components[t.anchor.componentIndex].table };
|
|
1149
1571
|
}
|
|
1150
|
-
function
|
|
1572
|
+
function Wn(e) {
|
|
1151
1573
|
if (!e) return !1;
|
|
1152
1574
|
const t = e.replace(/"[^"]*"|\\.|\[(?![hms]+\])[^\]]*\]/gi, "");
|
|
1153
1575
|
return /[ymdhs]/i.test(t);
|
|
1154
1576
|
}
|
|
1155
|
-
function
|
|
1156
|
-
if (e.valueType === "text" || e.valueType === "boolean" ||
|
|
1577
|
+
function Vn(e) {
|
|
1578
|
+
if (e.valueType === "text" || e.valueType === "boolean" || Wn(e.numberFormat)) return null;
|
|
1157
1579
|
const t = e.value;
|
|
1158
1580
|
if (typeof t != "number" || !Number.isFinite(t)) return null;
|
|
1159
|
-
if (Number.isInteger(t) && !Number.isSafeInteger(t)) throw new
|
|
1581
|
+
if (Number.isInteger(t) && !Number.isSafeInteger(t)) throw new M("precision");
|
|
1160
1582
|
return t;
|
|
1161
1583
|
}
|
|
1162
|
-
function
|
|
1584
|
+
function Un(e, t, n) {
|
|
1163
1585
|
if (e.seen.has(n)) return;
|
|
1164
1586
|
e.seen.add(n), e.selected++;
|
|
1165
|
-
const r = t ?
|
|
1587
|
+
const r = t ? Vn(t) : null;
|
|
1166
1588
|
r === null ? e.excluded++ : e.values.push(r);
|
|
1167
1589
|
}
|
|
1168
|
-
function
|
|
1590
|
+
function qn(e, t, n, r) {
|
|
1169
1591
|
return r.origin ? e.table?.id === r.origin.id : `${t}:${n}` === r.grid;
|
|
1170
1592
|
}
|
|
1171
|
-
function
|
|
1593
|
+
function Gn(e, t, n) {
|
|
1172
1594
|
return n.origin ? n.origin.columnKeys.indexOf(e.table.columnKeys[t] ?? "") : t;
|
|
1173
1595
|
}
|
|
1174
|
-
function
|
|
1175
|
-
const
|
|
1176
|
-
return
|
|
1596
|
+
function Jn(e, t, n, r) {
|
|
1597
|
+
const i = r.origin ? ke(e) + t : t, o = Gn(e, n, r);
|
|
1598
|
+
return i < r.rowStart || i > r.rowEnd || o < r.columnStart || o > r.columnEnd ? null : `${r.grid}:${i}:${o}`;
|
|
1177
1599
|
}
|
|
1178
|
-
function
|
|
1179
|
-
const n = t.origin ?
|
|
1180
|
-
return
|
|
1600
|
+
function Kn(e, t) {
|
|
1601
|
+
const n = t.origin ? ke(e) : 0, r = Math.max(0, t.rowStart - n), i = Math.min(e.grid.cells.length, t.rowEnd - n + 1);
|
|
1602
|
+
return i > r ? i : 0;
|
|
1181
1603
|
}
|
|
1182
|
-
async function
|
|
1604
|
+
async function Yn(e, t, n, r, i) {
|
|
1183
1605
|
const o = e.grid;
|
|
1184
|
-
if (t > r.maxScanned) throw new
|
|
1185
|
-
const l = o.colWidthsMm?.length ?? o.cells.reduce((
|
|
1186
|
-
if (l > r.maxScanned) throw new
|
|
1187
|
-
const
|
|
1188
|
-
for (let
|
|
1189
|
-
|
|
1606
|
+
if (t > r.maxScanned) throw new M("limit");
|
|
1607
|
+
const l = o.colWidthsMm?.length ?? o.cells.reduce((a, c) => Math.max(a, c.length), 1);
|
|
1608
|
+
if (l > r.maxScanned) throw new M("limit");
|
|
1609
|
+
const s = /* @__PURE__ */ new Map();
|
|
1610
|
+
for (let a = 0; a < t; a++) {
|
|
1611
|
+
a > 0 && a % 2048 === 0 && (await r.yieldToHost(), G(r.signal));
|
|
1190
1612
|
let c = 0;
|
|
1191
|
-
for (const
|
|
1192
|
-
for (await
|
|
1613
|
+
for (const d of o.cells[a]) {
|
|
1614
|
+
for (await se(r); c < l && (s.get(c) ?? 0) > a; ) c++;
|
|
1193
1615
|
if (c >= l) break;
|
|
1194
|
-
const
|
|
1195
|
-
|
|
1196
|
-
for (let
|
|
1197
|
-
const
|
|
1198
|
-
|
|
1616
|
+
const m = Math.max(1, Math.min(d?.colSpan ?? 1, l - c)), h = Math.min(o.cells.length, a + Math.max(1, d?.rowSpan ?? 1));
|
|
1617
|
+
m > 1 && await se(r, m - 1);
|
|
1618
|
+
for (let g = c; g < c + m; g++) s.set(g, h);
|
|
1619
|
+
const f = Jn(e, a, c, n);
|
|
1620
|
+
f && Un(i, d, f), c += m;
|
|
1199
1621
|
}
|
|
1200
1622
|
}
|
|
1201
1623
|
}
|
|
1202
|
-
async function
|
|
1624
|
+
async function Xn(e, t, n) {
|
|
1203
1625
|
const r = { values: [], seen: /* @__PURE__ */ new Set(), excluded: 0, selected: 0 };
|
|
1204
|
-
for (let
|
|
1205
|
-
await
|
|
1206
|
-
const o = e.pages[
|
|
1626
|
+
for (let i = 0; i < e.pages.length; i++) {
|
|
1627
|
+
await se(n);
|
|
1628
|
+
const o = e.pages[i];
|
|
1207
1629
|
for (let l = 0; l < o.components.length; l++) {
|
|
1208
|
-
await
|
|
1209
|
-
const
|
|
1210
|
-
if (!
|
|
1211
|
-
const
|
|
1212
|
-
|
|
1630
|
+
await se(n);
|
|
1631
|
+
const s = o.components[l];
|
|
1632
|
+
if (!s.grid || !qn(s, i, l, t) || s.table && s.table.role !== "body") continue;
|
|
1633
|
+
const a = Kn(s, t);
|
|
1634
|
+
a && await Yn(s, a, t, n, r);
|
|
1213
1635
|
}
|
|
1214
1636
|
}
|
|
1215
1637
|
return r;
|
|
1216
1638
|
}
|
|
1217
|
-
function
|
|
1218
|
-
if (!Number.isFinite(e)) throw new
|
|
1639
|
+
function X(e) {
|
|
1640
|
+
if (!Number.isFinite(e)) throw new M("overflow");
|
|
1219
1641
|
return e;
|
|
1220
1642
|
}
|
|
1221
|
-
function
|
|
1643
|
+
function Zn(e) {
|
|
1222
1644
|
let t = 0, n = 0;
|
|
1223
1645
|
for (const r of e) {
|
|
1224
|
-
const
|
|
1225
|
-
n = o - t -
|
|
1646
|
+
const i = r - n, o = X(t + i);
|
|
1647
|
+
n = o - t - i, t = o;
|
|
1226
1648
|
}
|
|
1227
1649
|
return t;
|
|
1228
1650
|
}
|
|
1229
|
-
async function
|
|
1651
|
+
async function Ue(e, t) {
|
|
1230
1652
|
let n = [...e], r = new Array(e.length);
|
|
1231
1653
|
for (let o = 1; o < e.length; o *= 2) {
|
|
1232
1654
|
for (let l = 0; l < e.length; l += o * 2) {
|
|
1233
|
-
const
|
|
1234
|
-
let c = l,
|
|
1235
|
-
for (let
|
|
1236
|
-
r[
|
|
1655
|
+
const s = Math.min(l + o, e.length), a = Math.min(l + o * 2, e.length);
|
|
1656
|
+
let c = l, d = s;
|
|
1657
|
+
for (let m = l; m < a; m++)
|
|
1658
|
+
r[m] = d >= a || c < s && n[c] <= n[d] ? n[c++] : n[d++], m % 2048 === 0 && (await t.yieldToHost(), G(t.signal));
|
|
1237
1659
|
}
|
|
1238
1660
|
[n, r] = [r, n];
|
|
1239
1661
|
}
|
|
1240
|
-
const
|
|
1241
|
-
return n.length % 2 ? n[
|
|
1662
|
+
const i = Math.floor(n.length / 2);
|
|
1663
|
+
return n.length % 2 ? n[i] : X(n[i - 1] / 2 + n[i] / 2);
|
|
1242
1664
|
}
|
|
1243
|
-
function
|
|
1244
|
-
const t =
|
|
1665
|
+
function Qn(e) {
|
|
1666
|
+
const t = Zn(e);
|
|
1245
1667
|
let n = 1 / 0, r = -1 / 0;
|
|
1246
|
-
for (const
|
|
1247
|
-
n = Math.min(n,
|
|
1668
|
+
for (const i of e)
|
|
1669
|
+
n = Math.min(n, i), r = Math.max(r, i);
|
|
1248
1670
|
return { SUM: t, AVERAGE: t / e.length, AVG: t / e.length, MIN: n, MAX: r, COUNT: e.length };
|
|
1249
1671
|
}
|
|
1250
|
-
function
|
|
1251
|
-
if (typeof e != "string" || e.length > 256) throw new
|
|
1672
|
+
function er(e, t) {
|
|
1673
|
+
if (typeof e != "string" || e.length > 256) throw new M("expression");
|
|
1252
1674
|
const n = e.toUpperCase().match(/(?:\d+(?:\.\d*)?|\.\d+)(?:E[+-]?\d+)?|[A-Z_]+|[()+\-*/]|\S/g) ?? [];
|
|
1253
|
-
if (!n.length || n.length > 64) throw new
|
|
1675
|
+
if (!n.length || n.length > 64) throw new M("expression");
|
|
1254
1676
|
let r = 0;
|
|
1255
|
-
function
|
|
1256
|
-
if (
|
|
1257
|
-
const
|
|
1258
|
-
if (
|
|
1259
|
-
if (
|
|
1260
|
-
const c = o(0,
|
|
1261
|
-
if (n[r++] !== ")") throw new
|
|
1677
|
+
function i(s) {
|
|
1678
|
+
if (s > 16) throw new M("expression");
|
|
1679
|
+
const a = n[r++];
|
|
1680
|
+
if (a === "+" || a === "-") return (a === "-" ? -1 : 1) * i(s + 1);
|
|
1681
|
+
if (a === "(") {
|
|
1682
|
+
const c = o(0, s + 1);
|
|
1683
|
+
if (n[r++] !== ")") throw new M("expression");
|
|
1262
1684
|
return c;
|
|
1263
1685
|
}
|
|
1264
|
-
if (
|
|
1265
|
-
if (
|
|
1266
|
-
throw new
|
|
1686
|
+
if (a && /^(?:SUM|AVERAGE|AVG|MIN|MAX|COUNT|MEDIAN)$/.test(a) && Object.prototype.hasOwnProperty.call(t, a)) return X(t[a]);
|
|
1687
|
+
if (a && /^(?:\d+(?:\.\d*)?|\.\d+)(?:E[+-]?\d+)?$/.test(a)) return X(Number(a));
|
|
1688
|
+
throw new M("expression");
|
|
1267
1689
|
}
|
|
1268
|
-
function o(
|
|
1269
|
-
let c = a
|
|
1690
|
+
function o(s, a) {
|
|
1691
|
+
let c = i(a);
|
|
1270
1692
|
for (; r < n.length; ) {
|
|
1271
|
-
const
|
|
1272
|
-
if (!
|
|
1693
|
+
const d = n[r], m = d === "+" || d === "-" ? 1 : d === "*" || d === "/" ? 2 : 0;
|
|
1694
|
+
if (!m || m < s) break;
|
|
1273
1695
|
r++;
|
|
1274
|
-
const h = o(
|
|
1275
|
-
if (
|
|
1276
|
-
c =
|
|
1696
|
+
const h = o(m + 1, a + 1);
|
|
1697
|
+
if (d === "/" && h === 0) throw new M("division");
|
|
1698
|
+
c = X(d === "+" ? c + h : d === "-" ? c - h : d === "*" ? c * h : c / h);
|
|
1277
1699
|
}
|
|
1278
1700
|
return c;
|
|
1279
1701
|
}
|
|
1280
1702
|
const l = o(1, 0);
|
|
1281
|
-
if (r !== n.length) throw new
|
|
1703
|
+
if (r !== n.length) throw new M("expression");
|
|
1282
1704
|
return l;
|
|
1283
1705
|
}
|
|
1284
|
-
function
|
|
1706
|
+
function tr(e) {
|
|
1285
1707
|
const t = e.maxCells ?? 1e5, n = e.maxScannedCells ?? 2e5, r = e.precision ?? 2;
|
|
1286
|
-
if (![t, n].every((
|
|
1287
|
-
if (!Number.isInteger(r) || r < 0 || r > 12) throw new
|
|
1708
|
+
if (![t, n].every((i) => Number.isSafeInteger(i) && i >= 1 && i <= 2e6)) throw new M("limit");
|
|
1709
|
+
if (!Number.isInteger(r) || r < 0 || r > 12) throw new M("precision");
|
|
1288
1710
|
return { maxCells: t, maxScanned: n, precision: r };
|
|
1289
1711
|
}
|
|
1290
|
-
async function
|
|
1291
|
-
const r =
|
|
1292
|
-
|
|
1293
|
-
const o = await
|
|
1294
|
-
if (!["sum", "average", "min", "max", "count", "median", "expression"].includes(l)) throw new
|
|
1295
|
-
let
|
|
1296
|
-
if (l === "count")
|
|
1712
|
+
async function Lr(e, t, n = {}) {
|
|
1713
|
+
const r = tr(n), i = { scanned: 0, maxScanned: r.maxScanned, signal: n.signal, yieldToHost: n.yieldToHost ?? (() => new Promise((a) => setTimeout(a, 0))) };
|
|
1714
|
+
G(i.signal);
|
|
1715
|
+
const o = await Xn(e, _n(e, t, r.maxCells), i), l = n.operation ?? "sum";
|
|
1716
|
+
if (!["sum", "average", "min", "max", "count", "median", "expression"].includes(l)) throw new M("expression");
|
|
1717
|
+
let s = null;
|
|
1718
|
+
if (l === "count") s = o.values.length;
|
|
1297
1719
|
else if (o.values.length)
|
|
1298
|
-
if (l === "median")
|
|
1720
|
+
if (l === "median") s = await Ue(o.values, i);
|
|
1299
1721
|
else {
|
|
1300
|
-
const
|
|
1301
|
-
l === "expression" ? (/\bMEDIAN\b/i.test(n.expression ?? "") && (
|
|
1722
|
+
const a = Qn(o.values);
|
|
1723
|
+
l === "expression" ? (/\bMEDIAN\b/i.test(n.expression ?? "") && (a.MEDIAN = await Ue(o.values, i)), s = er(n.expression ?? "", a)) : s = a[l.toUpperCase()];
|
|
1302
1724
|
}
|
|
1303
|
-
if (
|
|
1304
|
-
return { value:
|
|
1725
|
+
if (G(i.signal), s !== null && Number.isInteger(s) && !Number.isSafeInteger(s)) throw new M("precision");
|
|
1726
|
+
return { value: s, formatted: s === null ? "—" : s.toFixed(r.precision), numericCells: o.values.length, excludedCells: o.excluded, selectedCells: o.selected, precision: r.precision };
|
|
1305
1727
|
}
|
|
1306
1728
|
class A extends Error {
|
|
1307
1729
|
constructor(t, n) {
|
|
1308
1730
|
super(t), this.path = n, this.code = "label-sheet", this.name = "LabelSheetError";
|
|
1309
1731
|
}
|
|
1310
1732
|
}
|
|
1311
|
-
function
|
|
1733
|
+
function ie(e) {
|
|
1312
1734
|
if (e?.aborted) {
|
|
1313
1735
|
const t = new Error("标签拼版已取消");
|
|
1314
1736
|
throw t.name = "AbortError", t;
|
|
1315
1737
|
}
|
|
1316
1738
|
}
|
|
1317
|
-
function
|
|
1739
|
+
function B(e, t, n = !1) {
|
|
1318
1740
|
if (!Number.isFinite(e) || e <= 0 || n && !Number.isSafeInteger(e)) throw new A("应为正有限数字,数量应为安全整数", t);
|
|
1319
1741
|
return e;
|
|
1320
1742
|
}
|
|
1321
|
-
function
|
|
1743
|
+
function qe(e, t) {
|
|
1322
1744
|
if (!Number.isFinite(e) || e < 0) throw new A("应为非负有限数字", t);
|
|
1323
1745
|
return e;
|
|
1324
1746
|
}
|
|
1325
|
-
function
|
|
1747
|
+
function nr(e) {
|
|
1326
1748
|
const t = typeof e.marginMm == "object" ? e.marginMm : { top: e.marginMm ?? 0, left: e.marginMm ?? 0, bottom: e.marginMm ?? 0, right: e.marginMm ?? 0 }, n = typeof e.gapMm == "object" ? e.gapMm : { horizontal: e.gapMm ?? 0, vertical: e.gapMm ?? 0 };
|
|
1327
|
-
for (const r of ["top", "left", "bottom", "right"])
|
|
1328
|
-
for (const r of ["horizontal", "vertical"])
|
|
1749
|
+
for (const r of ["top", "left", "bottom", "right"]) qe(t?.[r], `$.marginMm.${r}`);
|
|
1750
|
+
for (const r of ["horizontal", "vertical"]) qe(n?.[r], `$.gapMm.${r}`);
|
|
1329
1751
|
return { margin: t, gap: n };
|
|
1330
1752
|
}
|
|
1331
|
-
function
|
|
1753
|
+
function rr(e) {
|
|
1332
1754
|
const t = e.paper === void 0 || e.paper === "a4" ? { widthMm: 210, heightMm: 297 } : e.paper;
|
|
1333
|
-
|
|
1334
|
-
const n =
|
|
1335
|
-
if (
|
|
1336
|
-
const { margin: o, gap: l } =
|
|
1337
|
-
if (!Number.isSafeInteger(
|
|
1338
|
-
if (!Number.isFinite(
|
|
1339
|
-
return { paper: t, columns: n, rows: r, capacity:
|
|
1340
|
-
}
|
|
1341
|
-
function
|
|
1342
|
-
return 1 + (e.grid?.cells.reduce((t, n) => t + n.length + 1 + n.reduce((r,
|
|
1343
|
-
}
|
|
1344
|
-
function
|
|
1345
|
-
if (!
|
|
1755
|
+
B(t.widthMm, "$.paper.widthMm"), B(t.heightMm, "$.paper.heightMm");
|
|
1756
|
+
const n = B(e.columns, "$.columns", !0), r = B(e.rows, "$.rows", !0), i = n * r;
|
|
1757
|
+
if (i > 1e3) throw new A("每张纸不能超过 1000 个位置", "$.columns");
|
|
1758
|
+
const { margin: o, gap: l } = nr(e), s = e.startSlot ?? 0, a = e.offsetMm ?? { x: 0, y: 0 };
|
|
1759
|
+
if (!Number.isSafeInteger(s) || s < 0 || s >= i) throw new A("起始位置应在首张纸的有效位置内", "$.startSlot");
|
|
1760
|
+
if (!Number.isFinite(a.x) || !Number.isFinite(a.y)) throw new A("校准偏移应为有限毫米值", "$.offsetMm");
|
|
1761
|
+
return { paper: t, columns: n, rows: r, capacity: i, margin: o, gap: l, startSlot: s, offset: a };
|
|
1762
|
+
}
|
|
1763
|
+
function bt(e) {
|
|
1764
|
+
return 1 + (e.grid?.cells.reduce((t, n) => t + n.length + 1 + n.reduce((r, i) => r + (i?.children?.reduce((o, l) => o + bt(l), 0) ?? 0), 0), 0) ?? 0);
|
|
1765
|
+
}
|
|
1766
|
+
function ir(e, t, n) {
|
|
1767
|
+
if (!St(e).ok) throw new A("标签计划无效", "$.plan");
|
|
1346
1768
|
const r = e.pages[0];
|
|
1347
1769
|
if (!r) return;
|
|
1348
|
-
const { paper:
|
|
1349
|
-
if (
|
|
1350
|
-
let
|
|
1351
|
-
for (const [
|
|
1352
|
-
if (
|
|
1353
|
-
if (
|
|
1354
|
-
for (const
|
|
1355
|
-
}
|
|
1356
|
-
}
|
|
1357
|
-
function
|
|
1358
|
-
|
|
1359
|
-
const n =
|
|
1360
|
-
if (
|
|
1361
|
-
|
|
1362
|
-
const
|
|
1363
|
-
for (const [
|
|
1364
|
-
|
|
1365
|
-
const
|
|
1366
|
-
|
|
1367
|
-
}
|
|
1368
|
-
return { ...
|
|
1770
|
+
const { paper: i, columns: o, rows: l, margin: s, gap: a, offset: c } = n;
|
|
1771
|
+
if (s.left + c.x < 0 || s.top + c.y < 0 || s.left + c.x + o * r.pageWidthMm + (o - 1) * a.horizontal + s.right > i.widthMm + 1e-6 || s.top + c.y + l * r.pageHeightMm + (l - 1) * a.vertical + s.bottom > i.heightMm + 1e-6) throw new A("标签、间距、边距及校准偏移超过纸张尺寸;不会自动缩小标签", "$.paper");
|
|
1772
|
+
let d = 0;
|
|
1773
|
+
for (const [m, h] of e.pages.entries()) {
|
|
1774
|
+
if (ie(t.signal), h.layout === "wide" || h.pageWidthMm !== r.pageWidthMm || h.pageHeightMm !== r.pageHeightMm) throw new A("拼版需要尺寸相同的固定标签页面", `$.pages.${m}`);
|
|
1775
|
+
if (d += h.components.reduce((f, g) => f + bt(g), 0), d > B(t.maxComponents ?? 25e4, "$.maxComponents", !0)) throw new A("拼版组件总量超过预算", "$.maxComponents");
|
|
1776
|
+
for (const f of h.components) if (f.leftMm < 0 || f.topMm < 0 || f.leftMm + f.widthMm > h.pageWidthMm + 1e-6 || f.topMm + f.heightMm > h.pageHeightMm + 1e-6) throw new A("标签内容超出标签边界", `$.pages.${m}.components`);
|
|
1777
|
+
}
|
|
1778
|
+
}
|
|
1779
|
+
function Dr(e, t) {
|
|
1780
|
+
ie(t.signal);
|
|
1781
|
+
const n = rr(t), { paper: r, columns: i, capacity: o, margin: l, gap: s, startSlot: a, offset: c } = n, d = e.pages.length ? Math.ceil((a + e.pages.length) / o) : 0;
|
|
1782
|
+
if (d > B(t.maxSheets ?? 1e4, "$.maxSheets", !0)) throw new A("拼版纸张数量超过预算", "$.maxSheets");
|
|
1783
|
+
B(t.maxComponents ?? 25e4, "$.maxComponents", !0), ir(e, t, n);
|
|
1784
|
+
const m = et(e, { maxBytes: B(t.maxSnapshotBytes ?? 64e6, "$.maxSnapshotBytes", !0), check: () => ie(t.signal), error: (f, g) => new A(g, "$.maxSnapshotBytes") }), h = Array.from({ length: d }, () => ({ pageWidthMm: r.widthMm, pageHeightMm: r.heightMm, components: [], meta: { labelSheet: { columns: i, rows: n.rows, slots: [] } } }));
|
|
1785
|
+
for (const [f, g] of m.pages.entries()) {
|
|
1786
|
+
ie(t.signal);
|
|
1787
|
+
const C = a + f, S = C % o, w = h[Math.floor(C / o)], v = l.left + c.x + S % i * (g.pageWidthMm + s.horizontal), y = l.top + c.y + Math.floor(S / i) * (g.pageHeightMm + s.vertical), N = { sourcePageIndex: f, slotIndex: S, xMm: v, yMm: y, widthMm: g.pageWidthMm, heightMm: g.pageHeightMm, ...g.meta ? { sourceMeta: g.meta } : {} };
|
|
1788
|
+
w.meta.labelSheet.slots.push(N), w.components.push(...g.components.map((L) => ({ ...L, leftMm: L.leftMm + v, topMm: L.topMm + y, meta: { ...L.meta, labelSheet: N } })));
|
|
1789
|
+
}
|
|
1790
|
+
return { ...m, pages: h };
|
|
1369
1791
|
}
|
|
1370
1792
|
export {
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1793
|
+
zr as CSS_DPI,
|
|
1794
|
+
Hr as DEFAULT_BORDER_PT,
|
|
1795
|
+
le as DEFAULT_FONT_FAMILY,
|
|
1796
|
+
Br as DEFAULT_FONT_PT,
|
|
1797
|
+
Mi as DEFAULT_LABEL_PAGE_LIMIT,
|
|
1798
|
+
_r as DEFAULT_STROKE_COLOR,
|
|
1799
|
+
Ge as DEFAULT_TEXT_COLOR,
|
|
1800
|
+
Wr as LINE_HEIGHT,
|
|
1379
1801
|
A as LabelSheetError,
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
Sr as
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1802
|
+
Vr as MM_PER_INCH,
|
|
1803
|
+
Ki as OutputAssetError,
|
|
1804
|
+
Pt as OutputFidelityError,
|
|
1805
|
+
oe as PAPER_SIZES,
|
|
1806
|
+
dn as PageBuilder,
|
|
1807
|
+
vi as PaginateCellLimitError,
|
|
1808
|
+
xi as PaginatePageLimitError,
|
|
1809
|
+
ri as RENDER_PLAN_SCHEMA_VERSION,
|
|
1810
|
+
pe as REPORT_TEMPLATE_DOCUMENT_VERSION,
|
|
1811
|
+
Kr as ReportBindingError,
|
|
1812
|
+
M as ReportCalculationError,
|
|
1813
|
+
Tt as ReportCellEditError,
|
|
1814
|
+
In as ReportCellFieldError,
|
|
1815
|
+
u as ReportComponentExtensionError,
|
|
1816
|
+
Zi as ReportDrillError,
|
|
1817
|
+
io as ReportParamValidationError,
|
|
1818
|
+
ve as ReportSourceError,
|
|
1819
|
+
Ze as ReportTemplateError,
|
|
1820
|
+
F as ReportTemplateMigrationError,
|
|
1821
|
+
j as ReportTemplateStoreError,
|
|
1822
|
+
Ur as SCHEMA_VERSION_MACH,
|
|
1823
|
+
cn as TemplateBuilder,
|
|
1824
|
+
ko as TreeRowLimitError,
|
|
1825
|
+
Si as applyReportCellEdit,
|
|
1826
|
+
Ei as applyReportCellEditBatch,
|
|
1827
|
+
To as applyReportDocumentStyle,
|
|
1828
|
+
Ci as applyReportEditResult,
|
|
1829
|
+
Ti as applyReportSourceMetadata,
|
|
1830
|
+
oi as assertRenderPlan,
|
|
1831
|
+
oo as assertReportParams,
|
|
1832
|
+
Lr as calculateReportSelection,
|
|
1833
|
+
Ro as captureTemplateFragment,
|
|
1834
|
+
ui as charWidthEm,
|
|
1835
|
+
$ as classOf,
|
|
1836
|
+
po as cloneReportTemplate,
|
|
1837
|
+
xo as collectTemplateOutline,
|
|
1838
|
+
Er as columnsFromContract,
|
|
1839
|
+
en as computePageWindow,
|
|
1840
|
+
Ri as countTemplatePages,
|
|
1841
|
+
pi as createCanvasMeasurer,
|
|
1842
|
+
xr as createCanvasPager,
|
|
1843
|
+
wi as createHeuristicMeasurer,
|
|
1844
|
+
Tr as createLabelTemplate,
|
|
1845
|
+
wo as createLocalTemplateCatalog,
|
|
1846
|
+
Ar as createMemoryTemplateStore,
|
|
1847
|
+
wr as createPageViewportRenderer,
|
|
1848
|
+
$r as createProviderReport,
|
|
1849
|
+
$i as createReportCellEdit,
|
|
1850
|
+
Pi as createReportCellEditBatch,
|
|
1851
|
+
Ai as createReportCellResolver,
|
|
1852
|
+
kr as createReportComponentRegistry,
|
|
1853
|
+
Qi as createReportDrillRequest,
|
|
1854
|
+
ki as createReportEditSession,
|
|
1855
|
+
Oi as createReportSource,
|
|
1856
|
+
Cr as createTableTemplate,
|
|
1857
|
+
Sr as createTemplate,
|
|
1858
|
+
Pr as createTemplateManager,
|
|
1859
|
+
Mn as createTemplateMigrator,
|
|
1860
|
+
ai as createTemplateRegistry,
|
|
1861
|
+
Oo as createTreeTable,
|
|
1862
|
+
fi as datasetJsonSchema,
|
|
1863
|
+
Rr as defineLabelReport,
|
|
1864
|
+
Ct as defineReport,
|
|
1865
|
+
si as defineReportTemplate,
|
|
1866
|
+
bo as diffReportTemplates,
|
|
1867
|
+
Ii as estimateListLayoutCells,
|
|
1868
|
+
Yr as evalStyleRule,
|
|
1869
|
+
er as evaluateReportAggregateExpression,
|
|
1870
|
+
Ni as explainDatasetField,
|
|
1871
|
+
Li as formatReportCellEdit,
|
|
1872
|
+
Or as formatReportClipboard,
|
|
1873
|
+
ao as formatReportDateRange,
|
|
1874
|
+
Xr as formatValue,
|
|
1875
|
+
Di as getReportCellContext,
|
|
1876
|
+
ji as getReportEditSession,
|
|
1877
|
+
Fi as hasValidDataExplanation,
|
|
1878
|
+
Me as heuristicMeasurer,
|
|
1879
|
+
Dr as imposeLabelSheets,
|
|
1880
|
+
$o as insertTemplateFragment,
|
|
1881
|
+
Yi as inspectOutputCapabilities,
|
|
1882
|
+
So as inspectTemplateFieldUsage,
|
|
1883
|
+
Po as inspectTemplateFragmentBindings,
|
|
1884
|
+
ce as isImageBackedComponent,
|
|
1885
|
+
zi as isReportDataTarget,
|
|
1886
|
+
so as isReportDate,
|
|
1887
|
+
lo as isReportMonth,
|
|
1888
|
+
Hi as isReportValueState,
|
|
1889
|
+
co as isReportYear,
|
|
1890
|
+
Ye as isRichText,
|
|
1891
|
+
eo as matchReportDrillActions,
|
|
1892
|
+
$e as measurePageSizePx,
|
|
1893
|
+
bi as measureTextMm,
|
|
1894
|
+
Ke as mergeComponentStyles,
|
|
1895
|
+
ue as mmToPx,
|
|
1896
|
+
qr as mmToPxFactor,
|
|
1897
|
+
Bi as paginateTemplate,
|
|
1898
|
+
_i as paginateTemplatePages,
|
|
1899
|
+
Zr as parseDateLocal,
|
|
1900
|
+
Nr as parseReportCellFieldInput,
|
|
1901
|
+
Rt as parseReportCellInput,
|
|
1902
|
+
Ir as parseReportClipboard,
|
|
1903
|
+
mo as parseReportDateRange,
|
|
1904
|
+
re as parseReportTemplate,
|
|
1905
|
+
br as planFontSizePx,
|
|
1906
|
+
Wi as projectListColumns,
|
|
1907
|
+
U as ptToPx,
|
|
1908
|
+
Gr as pxToMm,
|
|
1909
|
+
Vi as registerReportEditSession,
|
|
1910
|
+
Ui as relocateReportCellEdits,
|
|
1911
|
+
st as renderComponent,
|
|
1912
|
+
lt as renderPage,
|
|
1913
|
+
pr as renderPlan,
|
|
1914
|
+
Mr as renderPlanToCanvas,
|
|
1915
|
+
vr as renderPlanToCanvasAsync,
|
|
1916
|
+
yr as renderPlanToImages,
|
|
1917
|
+
qi as reportCellEditKey,
|
|
1918
|
+
Z as reportOutputDiagnostics,
|
|
1919
|
+
ho as reportParamsJsonSchema,
|
|
1920
|
+
Je as resolveBoxBorders,
|
|
1921
|
+
Qr as resolveComponentBinding,
|
|
1494
1922
|
_ as resolveFontSize,
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1923
|
+
xe as resolveGridLayout,
|
|
1924
|
+
q as resolveLineHeight,
|
|
1925
|
+
gt as resolvePaper,
|
|
1926
|
+
Ee as resolvePlanAssets,
|
|
1927
|
+
to as resolveReportDrillReturn,
|
|
1928
|
+
Y as resolveStroke,
|
|
1929
|
+
ye as resolveTextColor,
|
|
1930
|
+
yo as reviewReportTemplate,
|
|
1931
|
+
Mo as reviewReportTemplateAsync,
|
|
1932
|
+
J as round,
|
|
1933
|
+
li as serializeReportTemplate,
|
|
1934
|
+
Gi as summarizeReportCellEdits,
|
|
1935
|
+
Eo as templatePathLocation,
|
|
1936
|
+
ei as toExcelNumberFormat,
|
|
1937
|
+
ti as toNumber,
|
|
1938
|
+
ci as validateComponent,
|
|
1939
|
+
Et as validateDatasetRows,
|
|
1940
|
+
di as validatePage,
|
|
1941
|
+
St as validateRenderPlan,
|
|
1942
|
+
Bn as validateReportCellFieldDefinition,
|
|
1943
|
+
no as validateReportDrillActions,
|
|
1944
|
+
fo as validateReportParamDefinitions,
|
|
1945
|
+
go as validateReportParams,
|
|
1946
|
+
Xe as validateReportTemplate,
|
|
1947
|
+
mi as validateReportTemplateDocument,
|
|
1948
|
+
Io as validateTreeOptions,
|
|
1949
|
+
Qe as wrapText
|
|
1522
1950
|
};
|