@agile-team/mach-report 2.7.0 → 2.8.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 +24 -6
- package/dist/ReportPreview-BKKDAv8e.js +4481 -0
- package/dist/ReportPreview-E3cm67Tk.cjs +6 -0
- package/dist/designer.d.cts +54 -1
- package/dist/designer.d.ts +54 -1
- package/dist/index.cjs +8 -8
- package/dist/index.d.cts +42 -0
- package/dist/index.d.ts +42 -0
- package/dist/index.js +917 -719
- package/dist/{plugin-s8Ay8kKk.js → plugin-PCgxBVB2.js} +1 -1
- package/dist/{plugin-9t_ZFwhz.cjs → plugin-mAfvgSey.cjs} +1 -1
- package/dist/style.css +1 -1
- package/dist/vue/async.d.cts +54 -8
- package/dist/vue/async.d.ts +54 -8
- package/dist/vue/index.d.cts +124 -35
- package/dist/vue/index.d.ts +124 -35
- package/dist/vue-async.cjs +1 -1
- package/dist/vue-async.js +3 -3
- package/dist/vue.cjs +1 -1
- package/dist/vue.js +58 -55
- package/package.json +1 -1
- package/dist/ReportPreview-BdvoqdOd.cjs +0 -6
- package/dist/ReportPreview-COFkbeEM.js +0 -3719
package/dist/index.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { i as
|
|
2
|
-
import { c as
|
|
3
|
-
import { v as
|
|
4
|
-
import { P as
|
|
5
|
-
import { r as
|
|
6
|
-
import { C as
|
|
7
|
-
import { a as
|
|
8
|
-
import { h as
|
|
9
|
-
import { c as
|
|
10
|
-
import { r as
|
|
11
|
-
import { r as
|
|
12
|
-
import { O as
|
|
13
|
-
import { r as
|
|
14
|
-
import { i as
|
|
15
|
-
import { c as
|
|
16
|
-
import { p as
|
|
17
|
-
import { R as
|
|
18
|
-
import { R as
|
|
19
|
-
import { f as
|
|
20
|
-
const
|
|
1
|
+
import { i as Q, D as ee, a as Pe, b as Re } from "./render-plan-uzZYYSy1.js";
|
|
2
|
+
import { c as or, d as ar, e as sr, L as lr, R as cr, S as dr } from "./render-plan-uzZYYSy1.js";
|
|
3
|
+
import { v as et } from "./report-source-BXHNy_AD.js";
|
|
4
|
+
import { P as mr, R as fr, c as hr, d as gr, a as pr, e as wr, f as br, p as vr, b as yr, t as xr, g as Mr } from "./report-source-BXHNy_AD.js";
|
|
5
|
+
import { r as H, a as j, b as te, c as B, d as Ae, m as se, e as ke, p as L, f as $e, P as Y } from "./style-Dv5o_x6b.js";
|
|
6
|
+
import { C as Sr, M as Tr, g as Cr, h as Ir } from "./style-Dv5o_x6b.js";
|
|
7
|
+
import { a as Rr, v as Ar, b as kr, c as $r } from "./validate-S6CgIm5d.js";
|
|
8
|
+
import { h as le, w as Ne } from "./textwrap-DOl04hCQ.js";
|
|
9
|
+
import { c as Fr, a as Or, b as Dr, m as Lr } from "./textwrap-DOl04hCQ.js";
|
|
10
|
+
import { r as K, o as tt } from "./progress-DD964VAB.js";
|
|
11
|
+
import { r as Fe, a as ce } from "./assets-B9qJku3V.js";
|
|
12
|
+
import { O as Hr } from "./assets-B9qJku3V.js";
|
|
13
|
+
import { r as V, n as Oe, O as nt } from "./capabilities-joSutDF8.js";
|
|
14
|
+
import { i as Wr } from "./capabilities-joSutDF8.js";
|
|
15
|
+
import { c as rt } from "./page-window-index-CIuT4BAv.js";
|
|
16
|
+
import { p as ae } from "./template-registry-NpOakidD.js";
|
|
17
|
+
import { R as _r, a as Kr, c as Vr, d as Gr, s as Ur, v as qr, b as Jr } from "./template-registry-NpOakidD.js";
|
|
18
|
+
import { R as Xr, a as Zr, i as Qr, r as ei, v as ti, b as ni } from "./param-validation-BWNjLcN0.js";
|
|
19
|
+
import { f as it, i as ot } from "./number-format-BA_KwrZe.js";
|
|
20
|
+
const at = {
|
|
21
21
|
root: "mr-root",
|
|
22
22
|
page: "mr-page",
|
|
23
23
|
comp: "mr-comp",
|
|
@@ -34,10 +34,10 @@ const Ze = {
|
|
|
34
34
|
cell: "mr-cell",
|
|
35
35
|
unknown: "mr-unknown"
|
|
36
36
|
};
|
|
37
|
-
function
|
|
38
|
-
return t?.classNames?.[e] ??
|
|
37
|
+
function C(e, t) {
|
|
38
|
+
return t?.classNames?.[e] ?? at[e];
|
|
39
39
|
}
|
|
40
|
-
class
|
|
40
|
+
class st {
|
|
41
41
|
constructor() {
|
|
42
42
|
this.props = [];
|
|
43
43
|
}
|
|
@@ -45,7 +45,7 @@ class et {
|
|
|
45
45
|
return n == null || n === !1 || n === "" ? this : (this.props.push([t, String(n)]), this);
|
|
46
46
|
}
|
|
47
47
|
mm(t, n, r, i = 2) {
|
|
48
|
-
return this.add(t, `${
|
|
48
|
+
return this.add(t, `${H(se(n, r), i)}px`);
|
|
49
49
|
}
|
|
50
50
|
toString() {
|
|
51
51
|
let t = "";
|
|
@@ -58,522 +58,522 @@ class et {
|
|
|
58
58
|
n && (t.style.cssText = n);
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
function
|
|
62
|
-
return new
|
|
61
|
+
function x(e, t = "unset") {
|
|
62
|
+
return new st().add("all", t).add("display", e).add("box-sizing", "border-box");
|
|
63
63
|
}
|
|
64
|
-
function
|
|
65
|
-
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(
|
|
66
|
-
const r =
|
|
67
|
-
e.add("font-size", `${
|
|
64
|
+
function De(e, t, n) {
|
|
65
|
+
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(te(t))).add("text-align", t.align);
|
|
66
|
+
const r = j(t, n);
|
|
67
|
+
e.add("font-size", `${H(r.fontSizePx, 2)}px`);
|
|
68
68
|
}
|
|
69
|
-
function
|
|
69
|
+
function lt(e, t, n) {
|
|
70
70
|
const r = t.style ?? {};
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
function
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
const d =
|
|
79
|
-
d.className = "mr-cell-content",
|
|
80
|
-
for (const u of
|
|
81
|
-
return
|
|
82
|
-
}
|
|
83
|
-
function
|
|
84
|
-
return
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
const
|
|
88
|
-
return
|
|
71
|
+
De(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);
|
|
72
|
+
}
|
|
73
|
+
function ct(e, t, n, r, i, s) {
|
|
74
|
+
const l = e.cell, o = s.createElement("td");
|
|
75
|
+
o.className = C("cell", i), o.dataset.mrRowIndex = String(e.ri), o.dataset.mrColumnIndex = String(e.ci), o.setAttribute("role", t.table?.role === "header" ? "columnheader" : "cell"), l.colSpan && (o.colSpan = l.colSpan), l.rowSpan && (o.rowSpan = l.rowSpan);
|
|
76
|
+
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");
|
|
77
|
+
De(c, a, r), c.applyTo(o);
|
|
78
|
+
const d = s.createElement("div");
|
|
79
|
+
d.className = "mr-cell-content", x("flex").add("position", "absolute").mm("left", n, 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.text != null && d.append(l.text);
|
|
80
|
+
for (const u of l.children ?? []) d.appendChild(Le(u, r, i, s));
|
|
81
|
+
return o.appendChild(d), o;
|
|
82
|
+
}
|
|
83
|
+
function dt(e, t, n, r) {
|
|
84
|
+
return Fe(e, t).map((i) => {
|
|
85
|
+
const s = `${H(i.widthPt * n / 72, 2)}px solid ${i.color}`, l = r.createElement("div");
|
|
86
|
+
l.className = "mr-grid-edge", l.setAttribute("aria-hidden", "true");
|
|
87
|
+
const o = i.kind === "h";
|
|
88
|
+
return x("block").add("position", "absolute").add("pointer-events", "none").mm("left", o ? i.from : i.pos, n).mm("top", o ? i.pos : i.from, n).mm("width", o ? i.to - i.from : 0, n).mm("height", o ? 0 : i.to - i.from, n).add(o ? "border-top" : "border-left", s).applyTo(l), l;
|
|
89
89
|
});
|
|
90
90
|
}
|
|
91
|
-
function
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
const
|
|
91
|
+
function ut(e, t, n, r, i) {
|
|
92
|
+
const s = i.createElement("table");
|
|
93
|
+
s.className = C("grid", r), s.setAttribute("role", "table"), x("block").add("position", "relative").add("width", "100%").add("height", "100%").applyTo(s);
|
|
94
|
+
const l = K(e, t.widthMm, t.heightMm), o = i.createElement("tbody");
|
|
95
|
+
x("contents").applyTo(o), s.appendChild(o);
|
|
96
|
+
const a = e.cells.map(() => {
|
|
97
97
|
const d = i.createElement("tr");
|
|
98
|
-
return d.className =
|
|
98
|
+
return d.className = C("row", r), d.setAttribute("role", "row"), x("contents").applyTo(d), o.appendChild(d), d;
|
|
99
99
|
});
|
|
100
|
-
for (const d of
|
|
101
|
-
|
|
100
|
+
for (const d of l.cells)
|
|
101
|
+
a[d.ri].appendChild(ct(d, t, e.paddingMm ?? 0.5, n, r, i));
|
|
102
102
|
const c = i.createElement("div");
|
|
103
|
-
return
|
|
103
|
+
return x("block").add("position", "relative").add("width", "100%").add("height", "100%").applyTo(c), c.append(s, ...dt(l, t, n, i)), c;
|
|
104
104
|
}
|
|
105
|
-
function
|
|
105
|
+
function mt(e, t, n, r) {
|
|
106
106
|
const i = r.createElement("div");
|
|
107
|
-
i.className =
|
|
108
|
-
for (const
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
const
|
|
112
|
-
if (
|
|
113
|
-
const
|
|
114
|
-
|
|
107
|
+
i.className = C("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);
|
|
108
|
+
for (const s of e.segments || []) {
|
|
109
|
+
const l = r.createElement("span");
|
|
110
|
+
l.className = C("segment", n), l.textContent = s.kind === "field" ? s.field ?? "" : s.text ?? "";
|
|
111
|
+
const o = x("inline");
|
|
112
|
+
if (s.style) {
|
|
113
|
+
const a = s.style;
|
|
114
|
+
o.add("color", a.color).add("font-family", a.fontFamily).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) && o.add("font-size", `${H(j(a, t).fontSizePx, 2)}px`);
|
|
115
115
|
}
|
|
116
|
-
|
|
116
|
+
o.applyTo(l), i.appendChild(l);
|
|
117
117
|
}
|
|
118
118
|
return i;
|
|
119
119
|
}
|
|
120
|
-
function
|
|
121
|
-
if (
|
|
120
|
+
function ft(e, t, n, r) {
|
|
121
|
+
if (Re(e)) {
|
|
122
122
|
const i = r.createElement("div");
|
|
123
|
-
i.className =
|
|
124
|
-
for (const
|
|
123
|
+
i.className = C("rich", n), x("block").applyTo(i);
|
|
124
|
+
for (const s of e.richParagraphs) i.appendChild(mt(s, t, n, r));
|
|
125
125
|
return i;
|
|
126
126
|
}
|
|
127
127
|
if (Array.isArray(e.lines) && e.lines.length > 0) {
|
|
128
128
|
const i = r.createElement("div");
|
|
129
|
-
i.className =
|
|
130
|
-
for (const
|
|
131
|
-
const
|
|
132
|
-
|
|
129
|
+
i.className = C("lines", n), x("block").applyTo(i);
|
|
130
|
+
for (const s of e.lines) {
|
|
131
|
+
const l = r.createElement("div");
|
|
132
|
+
l.className = C("line", n), l.textContent = s, x("block").add("white-space", "pre").add("min-height", "1lh").applyTo(l), i.appendChild(l);
|
|
133
133
|
}
|
|
134
134
|
return i;
|
|
135
135
|
}
|
|
136
136
|
return e.text ?? "";
|
|
137
137
|
}
|
|
138
|
-
function
|
|
138
|
+
function ht(e, t, n, r) {
|
|
139
139
|
const i = r.createElement("div");
|
|
140
|
-
i.className =
|
|
141
|
-
const
|
|
142
|
-
return
|
|
140
|
+
i.className = C("text", n);
|
|
141
|
+
const s = e.style || {};
|
|
142
|
+
return x("flex").add("width", "100%").add("height", "100%").add("flex-direction", "column").add("justify-content", s.verticalAlign === "middle" ? "center" : s.verticalAlign === "bottom" ? "flex-end" : "flex-start").add("overflow-wrap", "anywhere").add("overflow", "hidden").applyTo(i), i.append(ft(e, t, n, r)), i;
|
|
143
143
|
}
|
|
144
|
-
function
|
|
144
|
+
function gt(e, t, n) {
|
|
145
145
|
const r = n.createElement("img");
|
|
146
|
-
return r.className =
|
|
146
|
+
return r.className = C("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;
|
|
147
147
|
}
|
|
148
|
-
function
|
|
148
|
+
function Me(e, t, n, r) {
|
|
149
149
|
const i = r.createElement("div");
|
|
150
|
-
i.className =
|
|
151
|
-
const
|
|
152
|
-
return e.grid ? c.add("position", "relative") : e.kind === "rect" ? (
|
|
153
|
-
}
|
|
154
|
-
function
|
|
155
|
-
const r = n.createElementNS("http://www.w3.org/2000/svg", "svg"), i =
|
|
156
|
-
r.setAttribute("width", String(Math.max(1, i))), r.setAttribute("height", String(Math.max(1,
|
|
157
|
-
const
|
|
158
|
-
|
|
159
|
-
const
|
|
160
|
-
return
|
|
161
|
-
}
|
|
162
|
-
function
|
|
150
|
+
i.className = C("shape", n);
|
|
151
|
+
const s = e.style || {}, l = B(s), o = Ae(s), a = `${H(l.widthPt * t / 72, 2)}px solid ${l.color}`, c = x("block");
|
|
152
|
+
return e.grid ? c.add("position", "relative") : e.kind === "rect" ? (o.top && c.add("border-top", a), o.right && c.add("border-right", a), o.bottom && c.add("border-bottom", a), o.left && c.add("border-left", a)) : e.kind === "ellipse" ? (o.inner && c.add("border", a).add("border-radius", "50%"), s.backgroundColor && c.add("background-color", s.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;
|
|
153
|
+
}
|
|
154
|
+
function pt(e, t, n) {
|
|
155
|
+
const r = n.createElementNS("http://www.w3.org/2000/svg", "svg"), i = se(e.widthMm, t), s = se(e.heightMm, t);
|
|
156
|
+
r.setAttribute("width", String(Math.max(1, i))), r.setAttribute("height", String(Math.max(1, s))), r.setAttribute("aria-hidden", "true"), r.style.overflow = "visible", r.style.display = "block";
|
|
157
|
+
const l = n.createElementNS("http://www.w3.org/2000/svg", "line");
|
|
158
|
+
l.setAttribute("x1", "0"), l.setAttribute("x2", String(i)), l.setAttribute("y1", e.lineDirection === "up" ? String(s) : "0"), l.setAttribute("y2", e.lineDirection === "up" ? "0" : String(s));
|
|
159
|
+
const o = B({ ...e.style, borderColor: e.style?.lineColor ?? e.style?.borderColor });
|
|
160
|
+
return l.setAttribute("stroke", o.color), l.setAttribute("stroke-width", String(o.widthPt * t / 72)), r.appendChild(l), r;
|
|
161
|
+
}
|
|
162
|
+
function Le(e, t, n, r) {
|
|
163
163
|
const i = r.createElement("div");
|
|
164
|
-
i.className = `${
|
|
165
|
-
const
|
|
166
|
-
if (
|
|
167
|
-
return i.appendChild(
|
|
164
|
+
i.className = `${C("comp", n)} mr-kind-${e.kind}`;
|
|
165
|
+
const s = 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");
|
|
166
|
+
if (lt(s, e, t), s.applyTo(i), Q(e))
|
|
167
|
+
return i.appendChild(gt(e, n, r)), i;
|
|
168
168
|
if (e.kind === "text")
|
|
169
|
-
return i.appendChild(
|
|
169
|
+
return i.appendChild(ht(e, t, n, r)), i;
|
|
170
170
|
if (e.grid) {
|
|
171
|
-
const
|
|
172
|
-
return
|
|
171
|
+
const o = Me(e, t, n, r);
|
|
172
|
+
return o.appendChild(ut(e.grid, e, t, n, r)), i.appendChild(o), i;
|
|
173
173
|
}
|
|
174
174
|
if (e.kind === "line" && e.lineDirection)
|
|
175
|
-
return i.appendChild(
|
|
175
|
+
return i.appendChild(pt(e, t, r)), i;
|
|
176
176
|
if (e.kind === "line" || e.kind === "rect" || e.kind === "ellipse")
|
|
177
|
-
return i.appendChild(
|
|
178
|
-
const
|
|
179
|
-
return
|
|
177
|
+
return i.appendChild(Me(e, t, n, r)), i;
|
|
178
|
+
const l = r.createElement("div");
|
|
179
|
+
return l.className = C("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;
|
|
180
180
|
}
|
|
181
|
-
function
|
|
181
|
+
function wt(e, t, n, r) {
|
|
182
182
|
const i = r.createElement("div");
|
|
183
|
-
return i.className =
|
|
184
|
-
const
|
|
185
|
-
|
|
183
|
+
return i.className = C("page", n), x("block", "initial").add("position", "relative").add("font-family", ee).add("font-size", `${H(j(void 0, t).fontSizePx, 2)}px`).add("line-height", String(te(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", Pe).add("overflow", "hidden").add("box-sizing", "border-box").applyTo(i), e.components.forEach((s, l) => {
|
|
184
|
+
const o = Le(s, t, n, r);
|
|
185
|
+
o.dataset.mrComponentIndex = String(l), i.appendChild(o);
|
|
186
186
|
}), i;
|
|
187
187
|
}
|
|
188
|
-
function
|
|
188
|
+
function On(e, t, n = {}) {
|
|
189
189
|
const r = n.dpi ?? 96;
|
|
190
|
-
|
|
190
|
+
V(e, "dom", n);
|
|
191
191
|
const i = t.createElement("div");
|
|
192
|
-
return i.className =
|
|
193
|
-
i.appendChild(
|
|
192
|
+
return i.className = C("root", n), x("block").applyTo(i), i.dataset.schemaVersion = e.schemaVersion, e.pages.forEach((s) => {
|
|
193
|
+
i.appendChild(wt(s, r, n, t));
|
|
194
194
|
}), i;
|
|
195
195
|
}
|
|
196
|
-
function
|
|
196
|
+
function A(e) {
|
|
197
197
|
if (e?.aborted) throw e.reason ?? new DOMException("The operation was aborted.", "AbortError");
|
|
198
198
|
}
|
|
199
|
-
const
|
|
200
|
-
const i = new Image(),
|
|
201
|
-
i.onload = null, i.onerror = null, t?.removeEventListener("abort",
|
|
202
|
-
},
|
|
203
|
-
|
|
199
|
+
const bt = (e, t) => (A(t), /^data:image\/(?:png|jpe?g|webp|gif|svg\+xml)[;,]/i.test(e) ? new Promise((n, r) => {
|
|
200
|
+
const i = new Image(), s = () => {
|
|
201
|
+
i.onload = null, i.onerror = null, t?.removeEventListener("abort", l);
|
|
202
|
+
}, l = () => {
|
|
203
|
+
s(), i.src = "", r(t?.reason ?? new DOMException("The operation was aborted.", "AbortError"));
|
|
204
204
|
};
|
|
205
205
|
i.onload = () => {
|
|
206
|
-
|
|
206
|
+
s(), n(i);
|
|
207
207
|
}, i.onerror = () => {
|
|
208
|
-
|
|
209
|
-
}, t?.addEventListener("abort",
|
|
208
|
+
s(), r(new Error("Image could not be decoded for Canvas output."));
|
|
209
|
+
}, t?.addEventListener("abort", l, { once: !0 }), i.src = e;
|
|
210
210
|
}) : Promise.reject(new TypeError("Canvas imageData must be an image data URL; provide imageLoader for other sources.")));
|
|
211
|
-
function
|
|
212
|
-
return
|
|
213
|
-
const
|
|
214
|
-
n.addEventListener("abort",
|
|
211
|
+
function vt(e, t, n) {
|
|
212
|
+
return A(n), n ? new Promise((r, i) => {
|
|
213
|
+
const s = () => i(n.reason ?? new DOMException("The operation was aborted.", "AbortError"));
|
|
214
|
+
n.addEventListener("abort", s, { once: !0 }), Promise.resolve().then(() => e(t, n)).then(r, i).finally(() => n.removeEventListener("abort", s));
|
|
215
215
|
}) : e(t);
|
|
216
216
|
}
|
|
217
|
-
async function
|
|
217
|
+
async function yt(e, t, n) {
|
|
218
218
|
const r = /* @__PURE__ */ new Map();
|
|
219
219
|
for (const i of e.components)
|
|
220
|
-
!
|
|
221
|
-
return
|
|
220
|
+
!Q(i) || r.has(i.imageData) || r.set(i.imageData, await vt(t, i.imageData, n));
|
|
221
|
+
return A(n), r;
|
|
222
222
|
}
|
|
223
|
-
function
|
|
224
|
-
const
|
|
225
|
-
if (
|
|
226
|
-
const c = Math.min(i /
|
|
227
|
-
e.drawImage(t, n + (i - d) / 2, r + (
|
|
223
|
+
function xt(e, t, n, r, i, s) {
|
|
224
|
+
const l = t, o = l.naturalWidth ?? l.width ?? i, a = l.naturalHeight ?? l.height ?? s;
|
|
225
|
+
if (o <= 0 || a <= 0) throw new RangeError("Decoded Canvas image dimensions must be positive.");
|
|
226
|
+
const c = Math.min(i / o, s / a), d = o * c, u = a * c;
|
|
227
|
+
e.drawImage(t, n + (i - d) / 2, r + (s - u) / 2, d, u);
|
|
228
228
|
}
|
|
229
|
-
function
|
|
230
|
-
return
|
|
229
|
+
function Mt(e) {
|
|
230
|
+
return rt(e.pageHeightsPx, e.gapPx).window(e.viewportHeightPx, e.scrollTopPx, e.overscan);
|
|
231
231
|
}
|
|
232
|
-
const
|
|
233
|
-
function
|
|
234
|
-
const n = t / 96 *
|
|
232
|
+
const de = 96 / 25.4;
|
|
233
|
+
function ue(e, t = 96) {
|
|
234
|
+
const n = t / 96 * de;
|
|
235
235
|
return {
|
|
236
236
|
widthPx: Math.max(1, Math.round(e.pageWidthMm * n)),
|
|
237
237
|
heightPx: Math.max(1, Math.round(e.pageHeightMm * n))
|
|
238
238
|
};
|
|
239
239
|
}
|
|
240
|
-
function
|
|
240
|
+
function ze(e, t, n, r = 64e6) {
|
|
241
241
|
if (!Number.isFinite(t) || t <= 0 || !Number.isFinite(n) || n <= 0) throw new RangeError("Canvas dpr and dpi must be positive finite numbers.");
|
|
242
242
|
if (!Number.isFinite(r) || r <= 0) throw new RangeError("maxCanvasPixels must be positive and finite.");
|
|
243
|
-
const i =
|
|
244
|
-
if (!Number.isSafeInteger(
|
|
245
|
-
return { width:
|
|
246
|
-
}
|
|
247
|
-
function
|
|
248
|
-
const i = document.createElement("canvas"), { widthPx:
|
|
249
|
-
i.width =
|
|
250
|
-
const
|
|
251
|
-
if (!
|
|
243
|
+
const i = ue(e, n), s = Math.round(i.widthPx * t), l = Math.round(i.heightPx * t);
|
|
244
|
+
if (!Number.isSafeInteger(s) || !Number.isSafeInteger(l) || s * l > r) throw new RangeError("Canvas page exceeds maxCanvasPixels; reduce resolution or split the report.");
|
|
245
|
+
return { width: s, height: l };
|
|
246
|
+
}
|
|
247
|
+
function He(e, t, n, r) {
|
|
248
|
+
const i = document.createElement("canvas"), { widthPx: s, heightPx: l } = ue(e, n), o = ze(e, t, n, r);
|
|
249
|
+
i.width = o.width, i.height = o.height, i.style.width = `${s}px`, i.style.height = `${l}px`;
|
|
250
|
+
const a = i.getContext("2d");
|
|
251
|
+
if (!a)
|
|
252
252
|
throw new Error("当前环境不支持 Canvas 2D(测试需真浏览器,见 e2e/canvas.spec.ts)");
|
|
253
|
-
return
|
|
253
|
+
return a.scale(t, t), a.fillStyle = "#ffffff", a.fillRect(0, 0, s, l), { canvas: i, ctx: a };
|
|
254
254
|
}
|
|
255
|
-
function
|
|
256
|
-
return
|
|
255
|
+
function Dn(e, t = 96) {
|
|
256
|
+
return j(e, t).fontSizePx;
|
|
257
257
|
}
|
|
258
|
-
function
|
|
259
|
-
e.font = `${t.italic ? "italic " : ""}${t.bold ? "bold " : ""}${t.fontSizePx}px ${
|
|
260
|
-
const
|
|
261
|
-
`), d = c.length *
|
|
258
|
+
function je(e, t, n, r, i, s, l, o = "top") {
|
|
259
|
+
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";
|
|
260
|
+
const a = t.fontSizePx * t.lineHeight, c = t.text === "" ? [""] : t.text.split(`
|
|
261
|
+
`), d = c.length * a;
|
|
262
262
|
let u = r;
|
|
263
|
-
|
|
264
|
-
|
|
263
|
+
o === "middle" ? u = r + (s - d) / 2 : o === "bottom" && (u = r + s - d), c.forEach((m, f) => {
|
|
264
|
+
Et(e, m, t, n, u + f * a + t.fontSizePx * 0.8, i);
|
|
265
265
|
}), e.textAlign = "left";
|
|
266
266
|
}
|
|
267
|
-
function
|
|
268
|
-
const
|
|
269
|
-
if (!
|
|
267
|
+
function Et(e, t, n, r, i, s) {
|
|
268
|
+
const l = Array.from(t), o = n.letterSpacingPx ?? 0;
|
|
269
|
+
if (!o) {
|
|
270
270
|
e.textAlign = n.align === "center" ? "center" : n.align === "right" ? "right" : "left";
|
|
271
|
-
const u = n.align === "center" ? r +
|
|
271
|
+
const u = n.align === "center" ? r + s / 2 : n.align === "right" ? r + s : r;
|
|
272
272
|
e.fillText(t, u, i);
|
|
273
273
|
return;
|
|
274
274
|
}
|
|
275
|
-
const
|
|
275
|
+
const a = e.measureText(t).width + Math.max(0, l.length - 1) * o, c = n.align === "center" ? r + (s - a) / 2 : n.align === "right" ? r + s - a : r;
|
|
276
276
|
e.textAlign = "left";
|
|
277
277
|
let d = "";
|
|
278
|
-
|
|
279
|
-
e.fillText(u, c + e.measureText(d).width + m *
|
|
278
|
+
l.forEach((u, m) => {
|
|
279
|
+
e.fillText(u, c + e.measureText(d).width + m * o, i), d += u;
|
|
280
280
|
});
|
|
281
281
|
}
|
|
282
|
-
function
|
|
283
|
-
for (const
|
|
284
|
-
e.strokeStyle =
|
|
282
|
+
function St(e, t, n, r, i, s, l) {
|
|
283
|
+
for (const o of Fe(t, n))
|
|
284
|
+
e.strokeStyle = o.color, e.lineWidth = L(o.widthPt, l), e.beginPath(), o.kind === "v" ? (e.moveTo(r + o.pos * s, i + o.from * s), e.lineTo(r + o.pos * s, i + o.to * s)) : (e.moveTo(r + o.from * s, i + o.pos * s), e.lineTo(r + o.to * s, i + o.pos * s)), e.stroke();
|
|
285
285
|
}
|
|
286
|
-
function
|
|
287
|
-
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 +
|
|
286
|
+
function Tt(e, t, n, r, i, s) {
|
|
287
|
+
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 + s)), t.bottom && (e.moveTo(n + i, r + s), e.lineTo(n, r + s)), t.left && (e.moveTo(n, r + s), e.lineTo(n, r)), e.stroke();
|
|
288
288
|
}
|
|
289
|
-
function
|
|
290
|
-
const u =
|
|
289
|
+
function Ct(e, t, n, r, i, s, l, o, a, c, d) {
|
|
290
|
+
const u = K(t, s / o, l / o);
|
|
291
291
|
for (const f of u.cells) {
|
|
292
292
|
const h = f.cell.style?.backgroundColor ?? n.style?.backgroundColor;
|
|
293
|
-
h && (e.fillStyle = h, e.fillRect(r + f.xMm *
|
|
293
|
+
h && (e.fillStyle = h, e.fillRect(r + f.xMm * o, i + f.yMm * o, f.widthMm * o, f.heightMm * o));
|
|
294
294
|
}
|
|
295
|
-
|
|
295
|
+
St(e, u, n, r, i, o, a);
|
|
296
296
|
const m = t.paddingMm ?? 0.5;
|
|
297
297
|
for (const f of u.cells) {
|
|
298
298
|
const h = f.cell.text ?? "";
|
|
299
299
|
if (!h) continue;
|
|
300
|
-
const g =
|
|
300
|
+
const g = ke(n.style, f.cell.style), b = j(g, a), E = Math.max(0, f.widthMm - 2 * m), S = Ne(h, E, { fontSizePt: b.fontSizePt, bold: g.bold, italic: g.italic, fontFamily: g.fontFamily ?? c, letterSpacingPt: g.letterSpacing }, d).join(`
|
|
301
301
|
`);
|
|
302
|
-
|
|
302
|
+
je(
|
|
303
303
|
e,
|
|
304
304
|
{
|
|
305
|
-
text:
|
|
305
|
+
text: S,
|
|
306
306
|
fontSizePx: b.fontSizePx,
|
|
307
307
|
bold: g.bold ?? !1,
|
|
308
308
|
italic: g.italic,
|
|
309
|
-
color:
|
|
309
|
+
color: $e(g, Pe),
|
|
310
310
|
align: g.align ?? "left",
|
|
311
|
-
lineHeight:
|
|
312
|
-
letterSpacingPx:
|
|
311
|
+
lineHeight: te(g),
|
|
312
|
+
letterSpacingPx: L(g.letterSpacing ?? 0, a)
|
|
313
313
|
},
|
|
314
|
-
r + (f.xMm + m) *
|
|
315
|
-
i + (f.yMm + m) *
|
|
316
|
-
|
|
317
|
-
Math.max(0, f.heightMm - 2 * m) *
|
|
314
|
+
r + (f.xMm + m) * o,
|
|
315
|
+
i + (f.yMm + m) * o,
|
|
316
|
+
E * o,
|
|
317
|
+
Math.max(0, f.heightMm - 2 * m) * o,
|
|
318
318
|
g.fontFamily ?? c,
|
|
319
319
|
g.verticalAlign ?? "middle"
|
|
320
320
|
);
|
|
321
321
|
}
|
|
322
322
|
}
|
|
323
|
-
function
|
|
324
|
-
const c = t.style ?? {}, d =
|
|
323
|
+
function It(e, t, n, r, i, s, l, o, a) {
|
|
324
|
+
const c = t.style ?? {}, d = j(c, l), u = Re(t) ? t.richParagraphs.map((m) => m.segments.map((f) => f.text ?? f.field ?? "").join("")).join(`
|
|
325
325
|
`) : t.lines?.length ? t.lines.join(`
|
|
326
|
-
`) :
|
|
326
|
+
`) : Ne(t.text ?? "", t.widthMm, { fontSizePt: d.fontSizePt, bold: c.bold, italic: c.italic, fontFamily: c.fontFamily ?? o, letterSpacingPt: c.letterSpacing }, a).join(`
|
|
327
327
|
`);
|
|
328
|
-
|
|
328
|
+
je(e, {
|
|
329
329
|
text: u,
|
|
330
330
|
fontSizePx: d.fontSizePx,
|
|
331
331
|
bold: c.bold ?? !1,
|
|
332
332
|
italic: c.italic,
|
|
333
|
-
color:
|
|
333
|
+
color: $e(c),
|
|
334
334
|
align: c.align ?? "left",
|
|
335
|
-
lineHeight:
|
|
336
|
-
letterSpacingPx:
|
|
337
|
-
}, n, r, i,
|
|
338
|
-
}
|
|
339
|
-
function
|
|
340
|
-
const
|
|
341
|
-
if (
|
|
342
|
-
const m =
|
|
343
|
-
m ?
|
|
335
|
+
lineHeight: te(c),
|
|
336
|
+
letterSpacingPx: L(c.letterSpacing ?? 0, l)
|
|
337
|
+
}, n, r, i, s, c.fontFamily ?? o, c.verticalAlign);
|
|
338
|
+
}
|
|
339
|
+
function me(e, t, n, r, i, s, l) {
|
|
340
|
+
const o = t.leftMm * n, a = t.topMm * n, c = t.widthMm * n, d = t.heightMm * n, u = t.style ?? {};
|
|
341
|
+
if (Q(t)) {
|
|
342
|
+
const m = l?.get(t.imageData);
|
|
343
|
+
m ? xt(e, m, o, a, c, d) : Ee(e, t, o, a, c, d);
|
|
344
344
|
return;
|
|
345
345
|
}
|
|
346
346
|
if (t.grid) {
|
|
347
|
-
|
|
347
|
+
Ct(e, t.grid, t, o, a, c, d, n, r, i, s);
|
|
348
348
|
return;
|
|
349
349
|
}
|
|
350
350
|
switch (t.kind) {
|
|
351
351
|
case "text": {
|
|
352
|
-
|
|
352
|
+
It(e, t, o, a, c, d, r, i, s);
|
|
353
353
|
break;
|
|
354
354
|
}
|
|
355
355
|
case "rect": {
|
|
356
|
-
const m =
|
|
357
|
-
u.backgroundColor && (e.fillStyle = u.backgroundColor, e.fillRect(
|
|
356
|
+
const m = B(u), f = Ae(u);
|
|
357
|
+
u.backgroundColor && (e.fillStyle = u.backgroundColor, e.fillRect(o, a, c, d)), f.inner && (e.strokeStyle = m.color, e.lineWidth = L(m.widthPt, r), Tt(e, f, o, a, c, d));
|
|
358
358
|
break;
|
|
359
359
|
}
|
|
360
360
|
case "line": {
|
|
361
|
-
const m =
|
|
362
|
-
e.strokeStyle = m.color, e.lineWidth =
|
|
363
|
-
const f = t.lineDirection === "up" ?
|
|
364
|
-
e.moveTo(
|
|
361
|
+
const m = B({ ...u, borderColor: u.lineColor ?? u.borderColor });
|
|
362
|
+
e.strokeStyle = m.color, e.lineWidth = L(m.widthPt, r), e.beginPath();
|
|
363
|
+
const f = t.lineDirection === "up" ? a + d : t.lineDirection === "down" ? a : a + d / 2, h = t.lineDirection === "up" ? a : t.lineDirection === "down" ? a + d : a + d / 2;
|
|
364
|
+
e.moveTo(o, f), e.lineTo(o + c, h), e.stroke();
|
|
365
365
|
break;
|
|
366
366
|
}
|
|
367
367
|
case "ellipse": {
|
|
368
|
-
const m =
|
|
369
|
-
e.strokeStyle = m.color, e.lineWidth =
|
|
368
|
+
const m = B(u);
|
|
369
|
+
e.strokeStyle = m.color, e.lineWidth = L(m.widthPt, r), u.backgroundColor && (e.fillStyle = u.backgroundColor, e.beginPath(), e.ellipse(o + c / 2, a + d / 2, c / 2, d / 2, 0, 0, Math.PI * 2), e.fill()), e.beginPath(), e.ellipse(o + c / 2, a + d / 2, c / 2, d / 2, 0, 0, Math.PI * 2), e.stroke();
|
|
370
370
|
break;
|
|
371
371
|
}
|
|
372
372
|
default:
|
|
373
|
-
|
|
373
|
+
Ee(e, t, o, a, c, d);
|
|
374
374
|
break;
|
|
375
375
|
}
|
|
376
376
|
}
|
|
377
|
-
function
|
|
378
|
-
e.save(), e.strokeStyle = "#94a3b8", e.strokeRect(n, r, i,
|
|
377
|
+
function Ee(e, t, n, r, i, s) {
|
|
378
|
+
e.save(), e.strokeStyle = "#94a3b8", e.strokeRect(n, r, i, s), e.fillStyle = "#64748b", e.font = "12px sans-serif", e.fillText(t.fallbackText ?? `[${t.kind}]`, n + 3, r + 14), e.restore();
|
|
379
379
|
}
|
|
380
|
-
async function
|
|
380
|
+
async function Ln(e, t = {}) {
|
|
381
381
|
if (typeof document > "u")
|
|
382
382
|
throw new Error("renderPlanToImages 需要浏览器环境(SSR/Node 请在客户端钩子中调用)");
|
|
383
383
|
const { format: n = "png", quality: r = 0.92, ...i } = t;
|
|
384
384
|
if (n !== "png" && n !== "jpeg") throw new TypeError("Image format must be png or jpeg.");
|
|
385
385
|
if (!Number.isFinite(r) || r < 0 || r > 1) throw new RangeError("Image quality must be between 0 and 1.");
|
|
386
|
-
|
|
387
|
-
const
|
|
388
|
-
e =
|
|
389
|
-
const
|
|
386
|
+
A(t.signal);
|
|
387
|
+
const s = await ce(e, { ...t, format: "canvas" });
|
|
388
|
+
e = s.plan;
|
|
389
|
+
const l = [...s.diagnostics, ...V(e, "canvas", t)], o = n === "jpeg" ? "image/jpeg" : "image/png", a = [], c = Math.min(e.pages.length - 1, t.end ?? e.pages.length - 1);
|
|
390
390
|
for (let d = Math.max(0, t.start ?? 0); d <= c; d++) {
|
|
391
|
-
|
|
392
|
-
const u = await
|
|
391
|
+
A(t.signal);
|
|
392
|
+
const u = await We(e.pages[d], d, i, l);
|
|
393
393
|
try {
|
|
394
|
-
|
|
394
|
+
a.push(await Pt(u, o, r, t.signal));
|
|
395
395
|
} finally {
|
|
396
396
|
u.width = 0, u.height = 0;
|
|
397
397
|
}
|
|
398
|
-
await
|
|
398
|
+
await tt(t, a.length, c - Math.max(0, t.start ?? 0) + 1);
|
|
399
399
|
}
|
|
400
|
-
return
|
|
400
|
+
return A(t.signal), { blobs: a, diagnostics: l };
|
|
401
401
|
}
|
|
402
|
-
function
|
|
403
|
-
return
|
|
404
|
-
const
|
|
405
|
-
r?.addEventListener("abort",
|
|
402
|
+
function Pt(e, t, n, r) {
|
|
403
|
+
return A(r), new Promise((i, s) => {
|
|
404
|
+
const l = () => s(r?.reason ?? new DOMException("The operation was aborted.", "AbortError"));
|
|
405
|
+
r?.addEventListener("abort", l, { once: !0 });
|
|
406
406
|
try {
|
|
407
|
-
e.toBlob((
|
|
408
|
-
r?.removeEventListener("abort",
|
|
407
|
+
e.toBlob((o) => {
|
|
408
|
+
r?.removeEventListener("abort", l), o ? i(o) : s(new Error("Canvas encoding failed; no empty image was emitted."));
|
|
409
409
|
}, t, n);
|
|
410
|
-
} catch (
|
|
411
|
-
r?.removeEventListener("abort",
|
|
410
|
+
} catch (o) {
|
|
411
|
+
r?.removeEventListener("abort", l), s(o);
|
|
412
412
|
}
|
|
413
413
|
});
|
|
414
414
|
}
|
|
415
|
-
function
|
|
416
|
-
if (
|
|
415
|
+
function zn(e, t = {}) {
|
|
416
|
+
if (A(t.signal), typeof document > "u")
|
|
417
417
|
throw new Error("renderPlanToCanvas 需要浏览器环境(SSR 请在客户端钩子中调用)");
|
|
418
|
-
const n = t.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), r = t.dpi ?? 96, i = r / 96 *
|
|
418
|
+
const n = t.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), r = t.dpi ?? 96, i = r / 96 * de, s = t.fontFamily ?? ee, l = t.measurer ?? le, o = Math.max(0, t.start ?? 0), a = Math.min(e.pages.length - 1, t.end ?? e.pages.length - 1), c = [], d = V(e, "canvas", t), u = Rt(e, o, a);
|
|
419
419
|
for (const m of u)
|
|
420
|
-
|
|
421
|
-
if (t.fidelity === "strict" && u.length) throw new
|
|
422
|
-
for (let m =
|
|
423
|
-
|
|
424
|
-
const f = e.pages[m], { canvas: h, ctx: g } =
|
|
420
|
+
Oe(m, t), d.push(m);
|
|
421
|
+
if (t.fidelity === "strict" && u.length) throw new nt(d);
|
|
422
|
+
for (let m = o; m <= a; m++) {
|
|
423
|
+
A(t.signal);
|
|
424
|
+
const f = e.pages[m], { canvas: h, ctx: g } = He(f, n, r, t.maxCanvasPixels);
|
|
425
425
|
for (const b of f.components)
|
|
426
|
-
|
|
426
|
+
me(g, b, i, r, s, l);
|
|
427
427
|
c.push(h);
|
|
428
428
|
}
|
|
429
429
|
return { canvases: c, diagnostics: d };
|
|
430
430
|
}
|
|
431
|
-
function
|
|
432
|
-
return n < t ? [] : e.pages.slice(t, n + 1).flatMap((r, i) => r.components.flatMap((
|
|
431
|
+
function Rt(e, t, n) {
|
|
432
|
+
return n < t ? [] : e.pages.slice(t, n + 1).flatMap((r, i) => r.components.flatMap((s, l) => Q(s) ? [{
|
|
433
433
|
code: "async-image-required",
|
|
434
434
|
severity: "warning",
|
|
435
435
|
format: "canvas",
|
|
436
436
|
pageIndex: t + i,
|
|
437
|
-
componentIndex:
|
|
438
|
-
kind:
|
|
439
|
-
nid:
|
|
437
|
+
componentIndex: l,
|
|
438
|
+
kind: s.kind,
|
|
439
|
+
nid: s.nid,
|
|
440
440
|
message: "Use renderPlanToCanvasAsync or renderPlanToImages to decode and include images."
|
|
441
441
|
}] : []));
|
|
442
442
|
}
|
|
443
|
-
async function
|
|
443
|
+
async function Hn(e, t = {}) {
|
|
444
444
|
if (typeof document > "u") throw new Error("renderPlanToCanvasAsync 需要浏览器环境(Node 请使用 PDF 或 XLSX 输出)");
|
|
445
|
-
|
|
446
|
-
const n = await
|
|
445
|
+
A(t.signal);
|
|
446
|
+
const n = await ce(e, { ...t, format: "canvas" });
|
|
447
447
|
e = n.plan;
|
|
448
|
-
const r = [...n.diagnostics, ...
|
|
449
|
-
for (let
|
|
450
|
-
i.push(await
|
|
448
|
+
const r = [...n.diagnostics, ...V(e, "canvas", t)], i = [], s = Math.min(e.pages.length - 1, t.end ?? e.pages.length - 1);
|
|
449
|
+
for (let l = Math.max(0, t.start ?? 0); l <= s; l++)
|
|
450
|
+
i.push(await We(e.pages[l], l, t, r));
|
|
451
451
|
return { canvases: i, diagnostics: r };
|
|
452
452
|
}
|
|
453
|
-
async function
|
|
454
|
-
const i = n.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1),
|
|
455
|
-
|
|
456
|
-
const { canvas:
|
|
457
|
-
for (const d of e.components)
|
|
458
|
-
return
|
|
453
|
+
async function We(e, t, n, r) {
|
|
454
|
+
const i = n.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), s = n.dpi ?? 96, l = n.fontFamily ?? ee, o = await Be(e, t, n, r);
|
|
455
|
+
A(n.signal);
|
|
456
|
+
const { canvas: a, ctx: c } = He(e, i, s, n.maxCanvasPixels);
|
|
457
|
+
for (const d of e.components) me(c, d, s / 25.4, s, l, n.measurer ?? le, o);
|
|
458
|
+
return a;
|
|
459
459
|
}
|
|
460
|
-
async function
|
|
461
|
-
const i = n.imageLoader ??
|
|
462
|
-
return
|
|
460
|
+
async function Be(e, t, n, r) {
|
|
461
|
+
const i = n.imageLoader ?? bt;
|
|
462
|
+
return yt(e, async (s, l) => {
|
|
463
463
|
try {
|
|
464
|
-
return await i(
|
|
465
|
-
} catch (
|
|
466
|
-
if (
|
|
467
|
-
const
|
|
468
|
-
throw r.push(d),
|
|
464
|
+
return await i(s, l);
|
|
465
|
+
} catch (o) {
|
|
466
|
+
if (l?.aborted) throw o;
|
|
467
|
+
const a = e.components.findIndex((u) => u.imageData === s), c = e.components[a], d = { code: "image-decode-failed", severity: "warning", format: "canvas", pageIndex: t, componentIndex: a, kind: c.kind, nid: c.nid, message: "Image decoding failed; raster output was cancelled instead of omitting the image." };
|
|
468
|
+
throw r.push(d), Oe(d, n), o;
|
|
469
469
|
}
|
|
470
470
|
}, n.signal);
|
|
471
471
|
}
|
|
472
|
-
function
|
|
473
|
-
const n = t.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), r = t.dpi ?? 96, i = r / 96 *
|
|
474
|
-
let f = null, h = null, g = null, b = null,
|
|
475
|
-
const
|
|
476
|
-
function
|
|
472
|
+
function jn(e, t = {}) {
|
|
473
|
+
const n = t.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), r = t.dpi ?? 96, i = r / 96 * de, s = t.fontFamily ?? ee, l = t.measurer ?? le, o = t.overscan ?? 1, a = t.gapPx ?? 18, c = t.pagesPerFrame ?? 1, d = e.pages.map((p) => p.pageHeightMm * i), u = Math.max(1, ...e.pages.map((p) => p.pageWidthMm * i)), m = { start: 0, end: -1 };
|
|
474
|
+
let f = null, h = null, g = null, b = null, E = [], S = 0, R = [], G = 0, W = new AbortController();
|
|
475
|
+
const ve = [];
|
|
476
|
+
function Ye() {
|
|
477
477
|
const p = f;
|
|
478
|
-
p.innerHTML = "", h = document.createElement("div"), h.style.cssText = `width:${u}px;margin:0 auto;`, g = document.createElement("div"), b = document.createElement("div"), h.appendChild(g),
|
|
479
|
-
const
|
|
480
|
-
for (let
|
|
481
|
-
const
|
|
482
|
-
|
|
478
|
+
p.innerHTML = "", h = document.createElement("div"), h.style.cssText = `width:${u}px;margin:0 auto;`, g = document.createElement("div"), b = document.createElement("div"), h.appendChild(g), E = [];
|
|
479
|
+
const T = Math.min(e.pages.length, 3 + o * 2);
|
|
480
|
+
for (let F = 0; F < T; F++) {
|
|
481
|
+
const y = document.createElement("div");
|
|
482
|
+
y.style.cssText = `margin:0 auto ${a}px;box-shadow:0 2px 8px rgba(0,0,0,.35);background:#fff;`, h.appendChild(y), E.push(y);
|
|
483
483
|
}
|
|
484
484
|
h.appendChild(b), p.appendChild(h);
|
|
485
485
|
}
|
|
486
|
-
async function
|
|
487
|
-
const
|
|
488
|
-
|
|
489
|
-
const
|
|
490
|
-
if (
|
|
491
|
-
const { widthPx:
|
|
492
|
-
let
|
|
493
|
-
(
|
|
494
|
-
const
|
|
495
|
-
|
|
496
|
-
const
|
|
497
|
-
if (
|
|
498
|
-
|
|
499
|
-
for (const
|
|
500
|
-
|
|
501
|
-
|
|
486
|
+
async function Xe(p, T) {
|
|
487
|
+
const F = G, y = await ce(e, { ...t, signal: W.signal, format: "canvas", start: T, end: T });
|
|
488
|
+
ve.push(...y.diagnostics);
|
|
489
|
+
const I = y.plan.pages[T], J = await Be(I, T, { ...t, signal: W.signal }, ve);
|
|
490
|
+
if (F !== G || !f) return;
|
|
491
|
+
const { widthPx: ie, heightPx: oe } = ue(I, r);
|
|
492
|
+
let N = p.firstElementChild;
|
|
493
|
+
(!N || N.tagName !== "CANVAS") && (N = document.createElement("canvas"), p.innerHTML = "", p.appendChild(N));
|
|
494
|
+
const xe = ze(I, n, r, t.maxCanvasPixels);
|
|
495
|
+
N.width = xe.width, N.height = xe.height, N.style.width = `${ie}px`, N.style.height = `${oe}px`;
|
|
496
|
+
const D = N.getContext("2d");
|
|
497
|
+
if (D) {
|
|
498
|
+
D.setTransform(1, 0, 0, 1, 0, 0), D.scale(n, n), D.fillStyle = "#ffffff", D.fillRect(0, 0, ie, oe);
|
|
499
|
+
for (const Qe of I.components)
|
|
500
|
+
me(D, Qe, i, r, s, l, J);
|
|
501
|
+
N.dataset.canvasPage = String(T), p.style.height = `${oe}px`, p.style.width = `${ie}px`;
|
|
502
502
|
}
|
|
503
503
|
}
|
|
504
|
-
function
|
|
505
|
-
|
|
506
|
-
const
|
|
507
|
-
b.style.height = `${
|
|
508
|
-
const
|
|
509
|
-
|
|
510
|
-
if (
|
|
511
|
-
|
|
512
|
-
const
|
|
513
|
-
|
|
504
|
+
function Ze(p) {
|
|
505
|
+
G++, m.start = p.start, m.end = p.end, g.style.height = `${p.start * a + d.slice(0, p.start).reduce((y, I) => y + I, 0)}px`;
|
|
506
|
+
const T = e.pages.length - 1 - p.end;
|
|
507
|
+
b.style.height = `${T * a + d.slice(p.end + 1).reduce((y, I) => y + I, 0)}px`;
|
|
508
|
+
const F = p.end - p.start + 1;
|
|
509
|
+
E.forEach((y, I) => {
|
|
510
|
+
if (I < F) {
|
|
511
|
+
y.style.display = "";
|
|
512
|
+
const J = p.start + I;
|
|
513
|
+
y.style.height = `${d[J] ?? 0}px`;
|
|
514
514
|
} else
|
|
515
|
-
|
|
516
|
-
}),
|
|
517
|
-
for (let
|
|
518
|
-
const
|
|
519
|
-
if (!
|
|
520
|
-
|
|
515
|
+
y.style.display = "none";
|
|
516
|
+
}), R = [];
|
|
517
|
+
for (let y = p.start; y <= p.end; y++) {
|
|
518
|
+
const I = E[y - p.start];
|
|
519
|
+
if (!I) continue;
|
|
520
|
+
I.firstElementChild?.dataset?.canvasPage !== String(y) && R.push(y);
|
|
521
521
|
}
|
|
522
|
-
|
|
522
|
+
re();
|
|
523
523
|
}
|
|
524
|
-
function
|
|
525
|
-
|
|
526
|
-
|
|
524
|
+
function re() {
|
|
525
|
+
S || R.length === 0 || (S = requestAnimationFrame(() => {
|
|
526
|
+
S = 0;
|
|
527
527
|
let p = Math.max(1, c);
|
|
528
|
-
for (;
|
|
529
|
-
const
|
|
530
|
-
|
|
528
|
+
for (; R.length > 0 && p-- > 0; ) {
|
|
529
|
+
const T = R.shift(), F = E[T - m.start];
|
|
530
|
+
F && Xe(F, T).catch(() => {
|
|
531
531
|
});
|
|
532
532
|
}
|
|
533
|
-
|
|
533
|
+
R.length > 0 && re();
|
|
534
534
|
}));
|
|
535
535
|
}
|
|
536
|
-
function
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
const p = f,
|
|
536
|
+
function U() {
|
|
537
|
+
S || (S = requestAnimationFrame(() => {
|
|
538
|
+
S = 0;
|
|
539
|
+
const p = f, T = Mt({
|
|
540
540
|
pageHeightsPx: d,
|
|
541
541
|
viewportHeightPx: p.clientHeight,
|
|
542
542
|
scrollTopPx: p.scrollTop,
|
|
543
|
-
overscan:
|
|
544
|
-
gapPx:
|
|
543
|
+
overscan: o,
|
|
544
|
+
gapPx: a
|
|
545
545
|
});
|
|
546
|
-
|
|
546
|
+
T.start !== m.start || T.end !== m.end ? Ze(T) : re();
|
|
547
547
|
}));
|
|
548
548
|
}
|
|
549
|
-
let
|
|
549
|
+
let q = null;
|
|
550
550
|
return {
|
|
551
551
|
attach(p) {
|
|
552
552
|
if (typeof document > "u")
|
|
553
553
|
throw new Error("createCanvasPager 需要浏览器环境(SSR 请在客户端钩子中调用 attach)");
|
|
554
|
-
|
|
554
|
+
A(t.signal), W = new AbortController(), t.signal?.addEventListener("abort", ye, { once: !0 }), V(e, "canvas", t), f = p, Ye(), p.addEventListener("scroll", U, { passive: !0 }), typeof ResizeObserver < "u" && (q = new ResizeObserver(() => U()), q.observe(p)), U();
|
|
555
555
|
},
|
|
556
556
|
destroy() {
|
|
557
|
-
|
|
557
|
+
G++, W.abort(), t.signal?.removeEventListener("abort", ye), S && cancelAnimationFrame(S), S = 0, q?.disconnect(), q = null, f?.removeEventListener("scroll", U), R = [], h?.remove(), f = null;
|
|
558
558
|
},
|
|
559
559
|
window() {
|
|
560
560
|
return { ...m };
|
|
561
561
|
}
|
|
562
562
|
};
|
|
563
|
-
function
|
|
564
|
-
|
|
563
|
+
function ye() {
|
|
564
|
+
W.abort(t.signal?.reason);
|
|
565
565
|
}
|
|
566
566
|
}
|
|
567
|
-
function
|
|
567
|
+
function _e(e, t, n) {
|
|
568
568
|
let r, i;
|
|
569
569
|
if (typeof e == "string") {
|
|
570
|
-
const
|
|
571
|
-
if (!
|
|
572
|
-
r =
|
|
570
|
+
const s = Y[e];
|
|
571
|
+
if (!s) throw new Error(`未知纸张预设 "${e}"(可用:${Object.keys(Y).join("/")})`);
|
|
572
|
+
r = s.widthMm, i = s.heightMm;
|
|
573
573
|
} else typeof e == "number" ? (r = e, i = t ?? 297) : (r = e.widthMm, i = e.heightMm);
|
|
574
574
|
return n ? { widthMm: i, heightMm: r } : { widthMm: r, heightMm: i };
|
|
575
575
|
}
|
|
576
|
-
class
|
|
576
|
+
class At {
|
|
577
577
|
constructor() {
|
|
578
578
|
this.pages = [], this.pending = null, this.templateParams = void 0;
|
|
579
579
|
}
|
|
@@ -602,18 +602,18 @@ class Tt {
|
|
|
602
602
|
*/
|
|
603
603
|
page(t = "a4", n = {}, r) {
|
|
604
604
|
this.collect();
|
|
605
|
-
const
|
|
605
|
+
const s = 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: o } = _e(
|
|
606
606
|
t,
|
|
607
607
|
typeof n == "number" ? n : void 0,
|
|
608
|
-
|
|
609
|
-
),
|
|
610
|
-
return this.pending = new
|
|
611
|
-
widthMm:
|
|
612
|
-
heightMm:
|
|
613
|
-
marginTopMm:
|
|
614
|
-
marginBottomMm:
|
|
615
|
-
marginLeftMm:
|
|
616
|
-
marginRightMm:
|
|
608
|
+
s.landscape
|
|
609
|
+
), a = s.margins ?? {};
|
|
610
|
+
return this.pending = new kt(this, {
|
|
611
|
+
widthMm: l,
|
|
612
|
+
heightMm: o,
|
|
613
|
+
marginTopMm: a.marginTopMm ?? 10,
|
|
614
|
+
marginBottomMm: a.marginBottomMm ?? 10,
|
|
615
|
+
marginLeftMm: a.marginLeftMm ?? 10,
|
|
616
|
+
marginRightMm: a.marginRightMm ?? 10
|
|
617
617
|
}), this.pending;
|
|
618
618
|
}
|
|
619
619
|
collect() {
|
|
@@ -625,7 +625,7 @@ class Tt {
|
|
|
625
625
|
return this.templateParams ? { params: this.templateParams, pages: this.pages } : { pages: this.pages };
|
|
626
626
|
}
|
|
627
627
|
}
|
|
628
|
-
class
|
|
628
|
+
class kt {
|
|
629
629
|
constructor(t, n) {
|
|
630
630
|
this.parent = t, this.page = n, this.components = [];
|
|
631
631
|
}
|
|
@@ -694,26 +694,26 @@ class Et {
|
|
|
694
694
|
return this.done().build();
|
|
695
695
|
}
|
|
696
696
|
}
|
|
697
|
-
function
|
|
698
|
-
return new
|
|
697
|
+
function Wn() {
|
|
698
|
+
return new At();
|
|
699
699
|
}
|
|
700
|
-
function
|
|
701
|
-
return
|
|
700
|
+
function Bn(e, t = {}) {
|
|
701
|
+
return et([], e), e.fields.map((n) => ({
|
|
702
702
|
field: n.field,
|
|
703
703
|
header: `${n.label ?? n.field}${n.unit ? ` (${n.unit})` : ""}`,
|
|
704
704
|
semanticRole: n.semanticRole ?? (n.type === "number" || n.type === "decimal" ? "measure" : n.type === "date" ? "date" : n.enum ? "dimension" : "text"),
|
|
705
705
|
...t[n.field]
|
|
706
706
|
}));
|
|
707
707
|
}
|
|
708
|
-
function
|
|
708
|
+
function k(e, t, n = !1) {
|
|
709
709
|
if (!Number.isFinite(e) || (n ? e < 0 : e <= 0))
|
|
710
710
|
throw new Error(`${t} 必须是有限${n ? "非负" : "正"}数`);
|
|
711
711
|
}
|
|
712
|
-
function
|
|
712
|
+
function X(e, t, n) {
|
|
713
713
|
if (e !== void 0 && !["left", "center", "right", "justify", ...n ? ["auto"] : []].includes(e))
|
|
714
714
|
throw new Error(`${t} 必须是 left/center/right/justify${n ? "/auto" : ""}`);
|
|
715
715
|
}
|
|
716
|
-
function
|
|
716
|
+
function $t(e) {
|
|
717
717
|
const t = e.layout ?? "page";
|
|
718
718
|
if (t !== "page" && t !== "wide")
|
|
719
719
|
throw new Error("layout 必须是 page 或 wide");
|
|
@@ -722,18 +722,18 @@ function St(e) {
|
|
|
722
722
|
if (t !== "wide" && e.columnWidthMm !== void 0)
|
|
723
723
|
throw new Error('columnWidthMm 仅适用于 layout: "wide"');
|
|
724
724
|
const n = e.columnWidthMm ?? 30;
|
|
725
|
-
return
|
|
725
|
+
return k(n, "columnWidthMm"), { layout: t, columnWidthMm: n };
|
|
726
726
|
}
|
|
727
|
-
function
|
|
727
|
+
function Nt(e) {
|
|
728
728
|
const t = e.paper === void 0 ? "a4" : e.paper;
|
|
729
729
|
if (typeof t != "string" && (typeof t != "object" || t === null) || e.landscape !== void 0 && typeof e.landscape != "boolean")
|
|
730
730
|
throw new Error("paper 必须是纸张预设名或 { widthMm, heightMm } 对象,landscape 必须是布尔值");
|
|
731
|
-
if (typeof t == "string" && !Object.prototype.hasOwnProperty.call(
|
|
732
|
-
throw new Error(`未知纸张预设 "${t}"(可用:${Object.keys(
|
|
733
|
-
const n =
|
|
734
|
-
return
|
|
731
|
+
if (typeof t == "string" && !Object.prototype.hasOwnProperty.call(Y, t))
|
|
732
|
+
throw new Error(`未知纸张预设 "${t}"(可用:${Object.keys(Y).join("/")})`);
|
|
733
|
+
const n = _e(t, void 0, e.landscape), r = n.widthMm, i = n.heightMm;
|
|
734
|
+
return k(r, "纸张 widthMm"), k(i, "纸张 heightMm"), { widthMm: r, heightMm: i };
|
|
735
735
|
}
|
|
736
|
-
function
|
|
736
|
+
function Ft(e) {
|
|
737
737
|
if (e.margins !== void 0 && (!e.margins || typeof e.margins != "object" || Array.isArray(e.margins)))
|
|
738
738
|
throw new Error("margins 必须是页边距对象");
|
|
739
739
|
const t = e.margins ?? {}, n = {
|
|
@@ -742,79 +742,79 @@ function Pt(e) {
|
|
|
742
742
|
marginLeftMm: t.marginLeftMm === void 0 ? 10 : t.marginLeftMm,
|
|
743
743
|
marginRightMm: t.marginRightMm === void 0 ? 10 : t.marginRightMm
|
|
744
744
|
};
|
|
745
|
-
for (const [r, i] of Object.entries(n))
|
|
745
|
+
for (const [r, i] of Object.entries(n)) k(i, r, !0);
|
|
746
746
|
return n;
|
|
747
747
|
}
|
|
748
|
-
function
|
|
748
|
+
function Ot(e, t) {
|
|
749
749
|
const n = e.dataset === void 0 ? "detail" : e.dataset;
|
|
750
750
|
if (typeof n != "string" || !n.trim())
|
|
751
751
|
throw new Error("dataset 必须是非空字符串");
|
|
752
752
|
if (e.title !== void 0 && typeof e.title != "string")
|
|
753
753
|
throw new Error("title 必须是字符串");
|
|
754
754
|
const r = e.titleHeightMm === void 0 ? 10 : e.titleHeightMm, i = e.titleGapMm === void 0 ? 4 : e.titleGapMm;
|
|
755
|
-
|
|
756
|
-
const
|
|
757
|
-
if (
|
|
755
|
+
k(r, "titleHeightMm"), k(i, "titleGapMm", !0);
|
|
756
|
+
const s = e.title !== void 0 && e.title.length > 0, l = s ? r + i : 0;
|
|
757
|
+
if (l >= t)
|
|
758
758
|
throw new Error("标题高度与间距占满页面,必须为表格保留可用高度");
|
|
759
|
-
return { dataset: n, titleHeightMm: r, hasTitle:
|
|
759
|
+
return { dataset: n, titleHeightMm: r, hasTitle: s, titleSpaceMm: l };
|
|
760
760
|
}
|
|
761
|
-
function
|
|
761
|
+
function Dt(e) {
|
|
762
762
|
if (e.listOptions !== void 0 && (!e.listOptions || typeof e.listOptions != "object" || Array.isArray(e.listOptions)))
|
|
763
763
|
throw new Error("listOptions 必须是列表配置对象");
|
|
764
764
|
const t = e.listOptions ?? {};
|
|
765
|
-
|
|
765
|
+
X(t.align, "listOptions.align", !0), X(t.headerAlign, "listOptions.headerAlign", !1);
|
|
766
766
|
for (const n of ["fontSizePt", "rowHeightMm", "paddingMm"]) {
|
|
767
767
|
const r = t[n];
|
|
768
|
-
r !== void 0 &&
|
|
768
|
+
r !== void 0 && k(r, `listOptions.${n}`, n === "paddingMm");
|
|
769
769
|
}
|
|
770
770
|
return t;
|
|
771
771
|
}
|
|
772
|
-
function
|
|
772
|
+
function Lt(e) {
|
|
773
773
|
let t = 0, n = 0;
|
|
774
774
|
for (const [r, i] of e.entries()) {
|
|
775
775
|
if (!i || typeof i.header != "string" || typeof i.field != "string" || !i.field.trim())
|
|
776
776
|
throw new Error(`columns[${r}] 需要字符串 header 与非空 field`);
|
|
777
|
-
|
|
777
|
+
X(i.align, `columns[${r}].align`, !0), X(i.headerAlign, `columns[${r}].headerAlign`, !1), i.flex !== void 0 && k(i.flex, `columns[${r}].flex`), i.widthMm !== void 0 ? (k(i.widthMm, `columns[${r}].widthMm`), t += i.widthMm) : n = Math.max(n, i.flex ?? 1);
|
|
778
778
|
}
|
|
779
779
|
return { fixedWidthMm: t, maxFlex: n };
|
|
780
780
|
}
|
|
781
|
-
function
|
|
782
|
-
const { fixedWidthMm: i, maxFlex:
|
|
781
|
+
function zt(e, t, n, r) {
|
|
782
|
+
const { fixedWidthMm: i, maxFlex: s } = Lt(e.columns);
|
|
783
783
|
if (t === "page" && i > r)
|
|
784
784
|
throw new Error(`固定列宽 ${i}mm 超出页面可用宽度 ${r}mm`);
|
|
785
|
-
const
|
|
786
|
-
if (t === "page" &&
|
|
785
|
+
const l = r - i;
|
|
786
|
+
if (t === "page" && s > 0 && l <= 0)
|
|
787
787
|
throw new Error("固定列占满页面可用宽度,自动列需要正的剩余宽度");
|
|
788
|
-
const
|
|
788
|
+
const o = s > 0 ? e.columns.reduce((c, d) => c + (d.widthMm === void 0 ? (d.flex ?? 1) / s : 0), 0) : 0;
|
|
789
789
|
return { columns: e.columns.map(({ widthMm: c, flex: d, ...u }, m) => {
|
|
790
|
-
const f = c ?? (t === "wide" ? n * (d ?? 1) :
|
|
791
|
-
return
|
|
792
|
-
}), fixedWidthMm: i, maxFlex:
|
|
790
|
+
const f = c ?? (t === "wide" ? n * (d ?? 1) : l * ((d ?? 1) / s) / o);
|
|
791
|
+
return k(f, `columns[${m}] 分配后的 widthMm`), { ...u, widthMm: f };
|
|
792
|
+
}), fixedWidthMm: i, maxFlex: s };
|
|
793
793
|
}
|
|
794
|
-
function
|
|
794
|
+
function _n(e) {
|
|
795
795
|
if (!e || typeof e != "object")
|
|
796
796
|
throw new Error("标准明细模板需要 options 对象");
|
|
797
797
|
if (!Array.isArray(e.columns) || e.columns.length === 0)
|
|
798
798
|
throw new Error("columns 至少需要一列");
|
|
799
|
-
const { layout: t, columnWidthMm: n } =
|
|
799
|
+
const { layout: t, columnWidthMm: n } = $t(e), r = Nt(e);
|
|
800
800
|
let i = r.widthMm;
|
|
801
|
-
const
|
|
802
|
-
let
|
|
803
|
-
const
|
|
804
|
-
if (t === "page" &&
|
|
801
|
+
const s = r.heightMm, l = Ft(e);
|
|
802
|
+
let o = i - l.marginLeftMm - l.marginRightMm;
|
|
803
|
+
const a = s - l.marginTopMm - l.marginBottomMm;
|
|
804
|
+
if (t === "page" && o <= 0 || a <= 0)
|
|
805
805
|
throw new Error("页边距占满纸张,必须保留正的可用宽度和高度");
|
|
806
|
-
const { dataset: c, titleHeightMm: d, hasTitle: u, titleSpaceMm: m } =
|
|
807
|
-
t === "wide" && (
|
|
808
|
-
const
|
|
809
|
-
return u &&
|
|
806
|
+
const { dataset: c, titleHeightMm: d, hasTitle: u, titleSpaceMm: m } = Ot(e, a), f = Dt(e), { columns: h, fixedWidthMm: g, maxFlex: b } = zt(e, t, n, o);
|
|
807
|
+
t === "wide" && (o = h.reduce((S, R) => S + R.widthMm, 0), k(o, "宽表总列宽"), i = o + l.marginLeftMm + l.marginRightMm, k(i, "宽表总宽度"));
|
|
808
|
+
const E = { widthMm: i, heightMm: s, ...l, components: [], ...t === "wide" ? { layout: t } : {} };
|
|
809
|
+
return u && E.components.push({
|
|
810
810
|
kind: "text",
|
|
811
811
|
text: e.title,
|
|
812
|
-
leftMm:
|
|
813
|
-
topMm:
|
|
814
|
-
widthMm:
|
|
812
|
+
leftMm: l.marginLeftMm,
|
|
813
|
+
topMm: l.marginTopMm,
|
|
814
|
+
widthMm: o,
|
|
815
815
|
heightMm: d,
|
|
816
816
|
style: { fontSize: 16, bold: !0, align: "center", verticalAlign: "middle", ...e.titleStyle }
|
|
817
|
-
}),
|
|
817
|
+
}), E.components.push({
|
|
818
818
|
align: "auto",
|
|
819
819
|
headerAlign: "center",
|
|
820
820
|
...f,
|
|
@@ -823,20 +823,20 @@ function xn(e) {
|
|
|
823
823
|
...u ? { title: e.title } : {},
|
|
824
824
|
dataset: c,
|
|
825
825
|
columns: h,
|
|
826
|
-
leftMm:
|
|
827
|
-
topMm:
|
|
828
|
-
widthMm: t === "wide" || b > 0 ?
|
|
829
|
-
}), e.params === void 0 ? { pages: [
|
|
826
|
+
leftMm: l.marginLeftMm,
|
|
827
|
+
topMm: l.marginTopMm + m,
|
|
828
|
+
widthMm: t === "wide" || b > 0 ? o : g
|
|
829
|
+
}), e.params === void 0 ? { pages: [E] } : { params: e.params, pages: [E] };
|
|
830
830
|
}
|
|
831
|
-
function
|
|
831
|
+
function Kn(e) {
|
|
832
832
|
return e;
|
|
833
833
|
}
|
|
834
|
-
class
|
|
834
|
+
class O extends Error {
|
|
835
835
|
constructor(t, n) {
|
|
836
836
|
super(n), this.code = t, this.name = "ReportTemplateStoreError";
|
|
837
837
|
}
|
|
838
838
|
}
|
|
839
|
-
function
|
|
839
|
+
function $(e) {
|
|
840
840
|
return JSON.parse(JSON.stringify(e));
|
|
841
841
|
}
|
|
842
842
|
function P(e) {
|
|
@@ -844,120 +844,120 @@ function P(e) {
|
|
|
844
844
|
const t = new Error("模板操作已取消");
|
|
845
845
|
throw t.name = "AbortError", t;
|
|
846
846
|
}
|
|
847
|
-
function
|
|
847
|
+
function Se(e) {
|
|
848
848
|
const t = e ? Number(e.revision) : 0;
|
|
849
|
-
if (!Number.isSafeInteger(t) || t < 0 || t >= Number.MAX_SAFE_INTEGER) throw new
|
|
849
|
+
if (!Number.isSafeInteger(t) || t < 0 || t >= Number.MAX_SAFE_INTEGER) throw new O("history", "修订号无效或已达上限");
|
|
850
850
|
return String(t + 1);
|
|
851
851
|
}
|
|
852
|
-
function
|
|
853
|
-
const n = async (
|
|
854
|
-
P(
|
|
855
|
-
const
|
|
856
|
-
return P(
|
|
857
|
-
}, r = async (
|
|
858
|
-
const
|
|
859
|
-
if ((
|
|
860
|
-
return
|
|
861
|
-
}, i = async (o, a
|
|
862
|
-
if (P(
|
|
863
|
-
return
|
|
864
|
-
},
|
|
865
|
-
const d =
|
|
866
|
-
return c !== void 0 && (m.restoredFrom = c), i({ id:
|
|
852
|
+
function Vn(e, t = {}) {
|
|
853
|
+
const n = async (l, o) => {
|
|
854
|
+
P(o);
|
|
855
|
+
const a = await e.read(l, o);
|
|
856
|
+
return P(o), a ? $(a) : void 0;
|
|
857
|
+
}, r = async (l, o) => {
|
|
858
|
+
const a = await n(l, o.signal);
|
|
859
|
+
if ((a?.revision ?? null) !== o.expectedRevision) throw new O("conflict", "模板已变化,请重新读取后提交");
|
|
860
|
+
return a;
|
|
861
|
+
}, i = async (l, o, a) => {
|
|
862
|
+
if (P(o.signal), !await e.compareAndSwap(l.id, o.expectedRevision, $(l), { signal: o.signal, ...a ? { publication: $(a) } : {} })) throw new O("conflict", "模板已被其他请求更新");
|
|
863
|
+
return $(l);
|
|
864
|
+
}, s = (l, o, a, c) => {
|
|
865
|
+
const d = Se(l), u = ae({ ...o, revision: d }), m = { revision: d, document: u, publishedAt: (t.now?.() ?? /* @__PURE__ */ new Date()).toISOString() };
|
|
866
|
+
return c !== void 0 && (m.restoredFrom = c), i({ id: l.id, revision: d, publishedRevision: d, published: u }, a, m);
|
|
867
867
|
};
|
|
868
868
|
return {
|
|
869
|
-
list: async (
|
|
870
|
-
P(
|
|
871
|
-
const
|
|
872
|
-
return P(
|
|
869
|
+
list: async (l) => {
|
|
870
|
+
P(l);
|
|
871
|
+
const o = await e.list(l);
|
|
872
|
+
return P(l), $(o);
|
|
873
873
|
},
|
|
874
|
-
get: async (
|
|
875
|
-
const
|
|
876
|
-
return c ?
|
|
874
|
+
get: async (l, o = {}) => {
|
|
875
|
+
const a = await n(l, o.signal), c = o.draft ? a?.draft : a?.published;
|
|
876
|
+
return c ? ae(c) : void 0;
|
|
877
877
|
},
|
|
878
|
-
history: async (
|
|
879
|
-
P(
|
|
880
|
-
const
|
|
881
|
-
return P(
|
|
878
|
+
history: async (l, o) => {
|
|
879
|
+
P(o);
|
|
880
|
+
const a = await e.history(l, o);
|
|
881
|
+
return P(o), $(a);
|
|
882
882
|
},
|
|
883
|
-
saveDraft: async (
|
|
884
|
-
P(
|
|
885
|
-
const
|
|
883
|
+
saveDraft: async (l, o) => {
|
|
884
|
+
P(o.signal);
|
|
885
|
+
const a = ae(t.migrate ? await t.migrate(l) : l), c = await r(a.id, o), d = Se(c);
|
|
886
886
|
return i({
|
|
887
|
-
id:
|
|
887
|
+
id: a.id,
|
|
888
888
|
revision: d,
|
|
889
|
-
draft: { ...
|
|
889
|
+
draft: { ...a, revision: d },
|
|
890
890
|
...c?.publishedRevision ? { publishedRevision: c.publishedRevision, published: c.published } : {}
|
|
891
|
-
},
|
|
891
|
+
}, o);
|
|
892
892
|
},
|
|
893
|
-
publish: async (
|
|
894
|
-
const
|
|
895
|
-
if (!
|
|
896
|
-
if (!
|
|
897
|
-
return
|
|
893
|
+
publish: async (l, o) => {
|
|
894
|
+
const a = await r(l, o);
|
|
895
|
+
if (!a) throw new O("missing", "模板不存在");
|
|
896
|
+
if (!a.draft) throw new O("draft", "没有可发布的草稿");
|
|
897
|
+
return s(a, a.draft, o);
|
|
898
898
|
},
|
|
899
|
-
rollback: async (o, a
|
|
900
|
-
const c = await r(
|
|
901
|
-
if (!c) throw new
|
|
902
|
-
P(
|
|
903
|
-
const d = await e.getVersion(o, a
|
|
904
|
-
if (!d) throw new
|
|
905
|
-
return
|
|
899
|
+
rollback: async (l, o, a) => {
|
|
900
|
+
const c = await r(l, a);
|
|
901
|
+
if (!c) throw new O("missing", "模板不存在");
|
|
902
|
+
P(a.signal);
|
|
903
|
+
const d = await e.getVersion(l, o, a.signal);
|
|
904
|
+
if (!d) throw new O("history", "历史修订不存在");
|
|
905
|
+
return s(c, d.document, a, o);
|
|
906
906
|
}
|
|
907
907
|
};
|
|
908
908
|
}
|
|
909
|
-
function
|
|
909
|
+
function Gn() {
|
|
910
910
|
const e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map();
|
|
911
911
|
return {
|
|
912
912
|
read: async (n, r) => {
|
|
913
913
|
P(r);
|
|
914
914
|
const i = e.get(n);
|
|
915
|
-
return i ?
|
|
915
|
+
return i ? $(i) : void 0;
|
|
916
916
|
},
|
|
917
|
-
list: async (n) => (P(n), Array.from(e.values(), ({ id: r, revision: i, publishedRevision:
|
|
918
|
-
history: async (n, r) => (P(r), Array.from(t.get(n)?.values() ?? [], (i) =>
|
|
917
|
+
list: async (n) => (P(n), Array.from(e.values(), ({ id: r, revision: i, publishedRevision: s }) => ({ id: r, revision: i, ...s ? { publishedRevision: s } : {} }))),
|
|
918
|
+
history: async (n, r) => (P(r), Array.from(t.get(n)?.values() ?? [], (i) => $(i))),
|
|
919
919
|
getVersion: async (n, r, i) => {
|
|
920
920
|
P(i);
|
|
921
|
-
const
|
|
922
|
-
return
|
|
921
|
+
const s = t.get(n)?.get(r);
|
|
922
|
+
return s ? $(s) : void 0;
|
|
923
923
|
},
|
|
924
|
-
compareAndSwap: async (n, r, i,
|
|
925
|
-
if (P(
|
|
926
|
-
if (i.id !== n) throw new
|
|
927
|
-
const
|
|
928
|
-
if (
|
|
929
|
-
const
|
|
930
|
-
if (
|
|
931
|
-
|
|
924
|
+
compareAndSwap: async (n, r, i, s) => {
|
|
925
|
+
if (P(s.signal), (e.get(n)?.revision ?? null) !== r) return !1;
|
|
926
|
+
if (i.id !== n) throw new O("history", "状态 ID 与存储 ID 不一致");
|
|
927
|
+
const l = $(i), o = s.publication;
|
|
928
|
+
if (o) {
|
|
929
|
+
const a = t.get(n) ?? /* @__PURE__ */ new Map();
|
|
930
|
+
if (a.has(o.revision) || o.revision !== i.revision || o.document.id !== n) throw new O("history", "发布修订不可覆盖,且必须与状态修订和模板 ID 一致");
|
|
931
|
+
a.set(o.revision, $(o)), t.set(n, a);
|
|
932
932
|
}
|
|
933
|
-
return e.set(n,
|
|
933
|
+
return e.set(n, l), !0;
|
|
934
934
|
}
|
|
935
935
|
};
|
|
936
936
|
}
|
|
937
|
-
function
|
|
937
|
+
function Ke(e) {
|
|
938
938
|
return !e || typeof e != "object" ? !1 : [e.pageIndex, e.componentIndex, e.rowIndex, e.columnIndex].every((t) => Number.isInteger(t) && t >= 0);
|
|
939
939
|
}
|
|
940
|
-
function
|
|
940
|
+
function Ve(e, t, n) {
|
|
941
941
|
const r = e.grid;
|
|
942
942
|
if (!r) return null;
|
|
943
943
|
const i = r.cells[t];
|
|
944
944
|
if (!i) return null;
|
|
945
|
-
const
|
|
946
|
-
return
|
|
945
|
+
const l = K(r, e.widthMm, e.heightMm).cells.filter((a) => a.ri === t).findIndex((a) => a.ci === n), o = i[l];
|
|
946
|
+
return o ? { cell: o, sourceColumnIndex: l } : null;
|
|
947
947
|
}
|
|
948
|
-
function
|
|
948
|
+
function Ht(e) {
|
|
949
949
|
return e.value !== void 0 ? e.value : e.rawText ?? e.text ?? null;
|
|
950
950
|
}
|
|
951
|
-
function
|
|
951
|
+
function jt(e, t) {
|
|
952
952
|
return e.valueType ? e.valueType : typeof t == "number" ? "number" : typeof t == "boolean" ? "boolean" : t === null && e.numberFormat && /[0#?]/.test(e.numberFormat) ? "number" : "text";
|
|
953
953
|
}
|
|
954
|
-
function
|
|
954
|
+
function Wt(e, t) {
|
|
955
955
|
if (e.editable === !1) return "cell";
|
|
956
956
|
if (e.formula !== void 0) return "formula";
|
|
957
957
|
if (e.children?.length) return "complex";
|
|
958
958
|
if (t.table && t.table.role !== "body" && e.editable !== !0) return "structure";
|
|
959
959
|
}
|
|
960
|
-
function
|
|
960
|
+
function Bt(e, t) {
|
|
961
961
|
const n = e.table;
|
|
962
962
|
if (n)
|
|
963
963
|
return {
|
|
@@ -967,53 +967,53 @@ function Ft(e, t) {
|
|
|
967
967
|
columnKey: n.columnKeys[t.columnIndex]
|
|
968
968
|
};
|
|
969
969
|
}
|
|
970
|
-
function
|
|
970
|
+
function _t(e, t, n) {
|
|
971
971
|
if (e.source) return { ...e.source };
|
|
972
972
|
const r = t.table?.source, i = t.table?.columnKeys[n.columnIndex];
|
|
973
973
|
if (!(!r || r.rowKey === void 0 || i === void 0))
|
|
974
974
|
return { ...r, rowKey: r.rowKey, field: i };
|
|
975
975
|
}
|
|
976
|
-
function
|
|
977
|
-
const r =
|
|
976
|
+
function Ge(e, t, n) {
|
|
977
|
+
const r = Ht(n), i = Wt(n, e);
|
|
978
978
|
return {
|
|
979
979
|
address: { ...t },
|
|
980
980
|
cell: n,
|
|
981
981
|
component: e,
|
|
982
982
|
value: r,
|
|
983
|
-
valueType:
|
|
984
|
-
table:
|
|
985
|
-
source:
|
|
983
|
+
valueType: jt(n, r),
|
|
984
|
+
table: Bt(e, t),
|
|
985
|
+
source: _t(n, e, t),
|
|
986
986
|
editable: i === void 0,
|
|
987
987
|
readOnlyReason: i
|
|
988
988
|
};
|
|
989
989
|
}
|
|
990
|
-
function
|
|
991
|
-
if (!
|
|
990
|
+
function fe(e, t) {
|
|
991
|
+
if (!Ke(t)) return null;
|
|
992
992
|
const n = e.pages[t.pageIndex]?.components[t.componentIndex];
|
|
993
993
|
if (!n) return null;
|
|
994
|
-
const r =
|
|
995
|
-
return r ?
|
|
994
|
+
const r = Ve(n, t.rowIndex, t.columnIndex);
|
|
995
|
+
return r ? Ge(n, t, r.cell) : null;
|
|
996
996
|
}
|
|
997
|
-
function
|
|
997
|
+
function he(e) {
|
|
998
998
|
const t = /* @__PURE__ */ new Map();
|
|
999
999
|
return (n) => {
|
|
1000
|
-
if (!
|
|
1000
|
+
if (!Ke(n)) return null;
|
|
1001
1001
|
const r = e.pages[n.pageIndex]?.components[n.componentIndex];
|
|
1002
1002
|
if (!r?.grid) return null;
|
|
1003
1003
|
let i = t.get(r);
|
|
1004
1004
|
if (!i) {
|
|
1005
|
-
const
|
|
1005
|
+
const l = /* @__PURE__ */ new Map();
|
|
1006
1006
|
i = /* @__PURE__ */ new Map();
|
|
1007
|
-
for (const
|
|
1008
|
-
const
|
|
1009
|
-
|
|
1010
|
-
const c = r.grid.cells[
|
|
1011
|
-
c && i.set(`${
|
|
1007
|
+
for (const o of K(r.grid, r.widthMm, r.heightMm).cells) {
|
|
1008
|
+
const a = l.get(o.ri) ?? 0;
|
|
1009
|
+
l.set(o.ri, a + 1);
|
|
1010
|
+
const c = r.grid.cells[o.ri]?.[a];
|
|
1011
|
+
c && i.set(`${o.ri}:${o.ci}`, c);
|
|
1012
1012
|
}
|
|
1013
1013
|
t.set(r, i);
|
|
1014
1014
|
}
|
|
1015
|
-
const
|
|
1016
|
-
return
|
|
1015
|
+
const s = i.get(`${n.rowIndex}:${n.columnIndex}`);
|
|
1016
|
+
return s ? Ge(r, n, s) : null;
|
|
1017
1017
|
};
|
|
1018
1018
|
}
|
|
1019
1019
|
class M extends Error {
|
|
@@ -1021,20 +1021,20 @@ class M extends Error {
|
|
|
1021
1021
|
super(`Invalid report cell edit: ${t}`), this.code = t, this.name = "ReportCellEditError";
|
|
1022
1022
|
}
|
|
1023
1023
|
}
|
|
1024
|
-
function
|
|
1024
|
+
function Kt(e, t) {
|
|
1025
1025
|
let n = e.trim();
|
|
1026
1026
|
const r = t && n.endsWith("%");
|
|
1027
1027
|
if (r && (n = n.slice(0, -1).trim()), /^[+-]?\d{1,3}(?:,\d{3})+(?:\.\d*)?(?:[eE][+-]?\d+)?$/.test(n) && (n = n.replace(/,/g, "")), !/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/.test(n)) throw new M("number");
|
|
1028
1028
|
return Number(n) / (r ? 100 : 1);
|
|
1029
1029
|
}
|
|
1030
|
-
function
|
|
1030
|
+
function Vt(e, t) {
|
|
1031
1031
|
if (e === null || typeof e == "string" && e.trim() === "") return null;
|
|
1032
1032
|
if (typeof e != "string" && typeof e != "number") throw new M("number");
|
|
1033
|
-
const n = typeof e == "number" ? e :
|
|
1033
|
+
const n = typeof e == "number" ? e : Kt(e, ot(t.cell.numberFormat));
|
|
1034
1034
|
if (!Number.isFinite(n) || Number.isInteger(n) && !Number.isSafeInteger(n)) throw new M("number");
|
|
1035
1035
|
return n;
|
|
1036
1036
|
}
|
|
1037
|
-
function
|
|
1037
|
+
function Gt(e) {
|
|
1038
1038
|
if (e === null || typeof e == "string" && e.trim() === "") return null;
|
|
1039
1039
|
if (typeof e == "boolean") return e;
|
|
1040
1040
|
const t = String(e).trim().toLowerCase();
|
|
@@ -1042,24 +1042,24 @@ function jt(e) {
|
|
|
1042
1042
|
if (["false", "no", "否", "0"].includes(t)) return !1;
|
|
1043
1043
|
throw new M("boolean");
|
|
1044
1044
|
}
|
|
1045
|
-
function
|
|
1046
|
-
return e.valueType === "number" ?
|
|
1045
|
+
function ge(e, t) {
|
|
1046
|
+
return e.valueType === "number" ? Vt(t, e) : e.valueType === "boolean" ? Gt(t) : t === null ? null : String(t);
|
|
1047
1047
|
}
|
|
1048
|
-
function
|
|
1049
|
-
const n = t.cell.text, i = [["是", "否"], ["TRUE", "FALSE"], ["True", "False"], ["true", "false"], ["1", "0"]].find((
|
|
1048
|
+
function Ut(e, t) {
|
|
1049
|
+
const n = t.cell.text, i = [["是", "否"], ["TRUE", "FALSE"], ["True", "False"], ["true", "false"], ["1", "0"]].find((s) => s.includes(n ?? ""));
|
|
1050
1050
|
return i ? i[e ? 0 : 1] : String(e);
|
|
1051
1051
|
}
|
|
1052
|
-
function
|
|
1053
|
-
return t === null ? "" : typeof t == "boolean" ?
|
|
1052
|
+
function ne(e, t) {
|
|
1053
|
+
return t === null ? "" : typeof t == "boolean" ? Ut(t, e) : typeof t == "number" ? it(t, e.cell.numberFormat) : String(t);
|
|
1054
1054
|
}
|
|
1055
|
-
function
|
|
1056
|
-
const r =
|
|
1055
|
+
function Un(e, t, n) {
|
|
1056
|
+
const r = fe(e, t);
|
|
1057
1057
|
if (!r) throw new M("missing");
|
|
1058
|
-
return
|
|
1058
|
+
return pe(r, n);
|
|
1059
1059
|
}
|
|
1060
|
-
function
|
|
1060
|
+
function pe(e, t) {
|
|
1061
1061
|
if (!e.editable) throw new M("readonly");
|
|
1062
|
-
const n =
|
|
1062
|
+
const n = ge(e, t);
|
|
1063
1063
|
return {
|
|
1064
1064
|
address: { ...e.address },
|
|
1065
1065
|
table: e.table,
|
|
@@ -1067,88 +1067,88 @@ function me(e, t) {
|
|
|
1067
1067
|
previousValue: e.value,
|
|
1068
1068
|
previousText: e.cell.text ?? "",
|
|
1069
1069
|
value: n,
|
|
1070
|
-
text:
|
|
1070
|
+
text: ne(e, n)
|
|
1071
1071
|
};
|
|
1072
1072
|
}
|
|
1073
|
-
function
|
|
1073
|
+
function qt(e, t) {
|
|
1074
1074
|
const n = e.table, r = t.table;
|
|
1075
1075
|
return !n || !r || n.columnKey === void 0 ? !1 : n.id === r.id && n.rowIndex === r.rowIndex && n.role === r.role && n.columnKey === r.columnKey;
|
|
1076
1076
|
}
|
|
1077
|
-
function
|
|
1078
|
-
const r = e.grid, { rowIndex: i, columnIndex:
|
|
1079
|
-
return
|
|
1077
|
+
function Ue(e, t, n) {
|
|
1078
|
+
const r = e.grid, { rowIndex: i, columnIndex: s } = t.address, l = Ve(e, i, s), o = [...r.cells], a = [...o[i]], c = ne(t, n.value), d = { ...l.cell, value: n.value, text: c, rawText: c };
|
|
1079
|
+
return a[l.sourceColumnIndex] = d, o[i] = a, { ...e, grid: { ...r, cells: o } };
|
|
1080
1080
|
}
|
|
1081
|
-
function
|
|
1081
|
+
function Jt(e, t) {
|
|
1082
1082
|
const n = e.table?.columnKeys, r = t.table?.columnKey;
|
|
1083
|
-
return n && r !== void 0 ? n.flatMap((i,
|
|
1083
|
+
return n && r !== void 0 ? n.flatMap((i, s) => i === r ? [s] : []) : [];
|
|
1084
1084
|
}
|
|
1085
|
-
function
|
|
1086
|
-
const
|
|
1087
|
-
if (!
|
|
1088
|
-
const
|
|
1089
|
-
if (
|
|
1085
|
+
function Yt(e, t, n, r, i, s) {
|
|
1086
|
+
const l = t.table, o = i.table;
|
|
1087
|
+
if (!l || !o || l.id !== o.id || l.role !== o.role || !t.grid) return t;
|
|
1088
|
+
const a = o.rowIndex - l.rowIndex;
|
|
1089
|
+
if (a < 0 || a >= t.grid.cells.length) return t;
|
|
1090
1090
|
let c = t;
|
|
1091
|
-
for (const d of
|
|
1092
|
-
const u =
|
|
1093
|
-
u?.editable &&
|
|
1091
|
+
for (const d of Jt(t, i)) {
|
|
1092
|
+
const u = fe(e, { pageIndex: n, componentIndex: r, rowIndex: a, columnIndex: d });
|
|
1093
|
+
u?.editable && qt(i, u) && (c = Ue(c, u, s));
|
|
1094
1094
|
}
|
|
1095
1095
|
return c;
|
|
1096
1096
|
}
|
|
1097
|
-
function
|
|
1098
|
-
const
|
|
1099
|
-
return i.table?.columnKey !== void 0 ?
|
|
1097
|
+
function Xt(e, t, n, r, i, s) {
|
|
1098
|
+
const l = i.address;
|
|
1099
|
+
return i.table?.columnKey !== void 0 ? Yt(e, t, n, r, i, s) : l.pageIndex === n && l.componentIndex === r ? Ue(t, i, s) : t;
|
|
1100
1100
|
}
|
|
1101
|
-
function
|
|
1101
|
+
function qe(e, t) {
|
|
1102
1102
|
const n = t.source;
|
|
1103
1103
|
if (!n) return !1;
|
|
1104
1104
|
const r = e.source;
|
|
1105
1105
|
return !r || ["datasetId", "rowKey", "field", "revision", "sourceToken"].some((i) => !Object.is(r[i], n[i]));
|
|
1106
1106
|
}
|
|
1107
|
-
function
|
|
1108
|
-
const n =
|
|
1107
|
+
function qn(e, t) {
|
|
1108
|
+
const n = fe(e, t.address);
|
|
1109
1109
|
if (!n) throw new M("missing");
|
|
1110
1110
|
if (!n.editable) throw new M("readonly");
|
|
1111
|
-
if (
|
|
1111
|
+
if (qe(n, t)) throw new M("conflict");
|
|
1112
1112
|
if (!Object.is(n.value, t.previousValue) || (n.cell.text ?? "") !== t.previousText) throw new M("conflict");
|
|
1113
|
-
const r =
|
|
1113
|
+
const r = ge(n, t.value), i = { ...t, value: r, text: ne(n, r) };
|
|
1114
1114
|
if (Object.is(r, n.value) && i.text === n.cell.text) return e;
|
|
1115
|
-
const
|
|
1116
|
-
const
|
|
1117
|
-
return
|
|
1115
|
+
const s = e.pages.map((l, o) => {
|
|
1116
|
+
const a = l.components.map((c, d) => Xt(e, c, o, d, n, i));
|
|
1117
|
+
return a.every((c, d) => c === l.components[d]) ? l : { ...l, components: a };
|
|
1118
1118
|
});
|
|
1119
|
-
return { ...e, pages:
|
|
1119
|
+
return { ...e, pages: s };
|
|
1120
1120
|
}
|
|
1121
|
-
function
|
|
1121
|
+
function Zt(e) {
|
|
1122
1122
|
return JSON.stringify([e.pageIndex, e.componentIndex, e.rowIndex, e.columnIndex]);
|
|
1123
1123
|
}
|
|
1124
|
-
function
|
|
1124
|
+
function Te(e) {
|
|
1125
1125
|
const t = e.table;
|
|
1126
|
-
return t?.columnKey !== void 0 ? JSON.stringify([t.id, t.role, t.rowIndex, t.columnKey]) :
|
|
1126
|
+
return t?.columnKey !== void 0 ? JSON.stringify([t.id, t.role, t.rowIndex, t.columnKey]) : Zt(e.address);
|
|
1127
1127
|
}
|
|
1128
|
-
function
|
|
1128
|
+
function Qt(e, t) {
|
|
1129
1129
|
if (!t.length) return e;
|
|
1130
|
-
const n = new Map(t.map((
|
|
1131
|
-
function
|
|
1132
|
-
const u =
|
|
1133
|
-
if (!u || !i.has(`${c}:${d}`) && !r.has(
|
|
1130
|
+
const n = new Map(t.map((a) => [Te(a), a])), r = new Set(t.flatMap((a) => a.table ? [a.table.id] : [])), i = new Set(t.map((a) => `${a.address.pageIndex}:${a.address.componentIndex}`)), s = he(e);
|
|
1131
|
+
function l(a, c, d) {
|
|
1132
|
+
const u = a.grid;
|
|
1133
|
+
if (!u || !i.has(`${c}:${d}`) && !r.has(a.table?.id ?? "")) return a;
|
|
1134
1134
|
const m = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map();
|
|
1135
|
-
for (const h of
|
|
1135
|
+
for (const h of K(u, a.widthMm, a.heightMm).cells) {
|
|
1136
1136
|
const g = f.get(h.ri) ?? 0;
|
|
1137
1137
|
f.set(h.ri, g + 1);
|
|
1138
|
-
const b =
|
|
1139
|
-
if (!
|
|
1140
|
-
const
|
|
1141
|
-
Object.is(b.value,
|
|
1138
|
+
const b = s({ pageIndex: c, componentIndex: d, rowIndex: h.ri, columnIndex: h.ci }), E = b && n.get(Te(b));
|
|
1139
|
+
if (!E || !b.editable) continue;
|
|
1140
|
+
const S = m.get(h.ri) ?? [...u.cells[h.ri]], R = ne(b, E.value);
|
|
1141
|
+
Object.is(b.value, E.value) && R === b.cell.text || (S[g] = { ...h.cell, value: E.value, text: R, rawText: R }, m.set(h.ri, S));
|
|
1142
1142
|
}
|
|
1143
|
-
return m.size ? { ...
|
|
1143
|
+
return m.size ? { ...a, grid: { ...u, cells: u.cells.map((h, g) => m.get(g) ?? h) } } : a;
|
|
1144
1144
|
}
|
|
1145
|
-
const
|
|
1146
|
-
const d =
|
|
1147
|
-
return d.every((u, m) => u ===
|
|
1145
|
+
const o = e.pages.map((a, c) => {
|
|
1146
|
+
const d = a.components.map((u, m) => l(u, c, m));
|
|
1147
|
+
return d.every((u, m) => u === a.components[m]) ? a : { ...a, components: d };
|
|
1148
1148
|
});
|
|
1149
|
-
return
|
|
1149
|
+
return o.every((a, c) => a === e.pages[c]) ? e : { ...e, pages: o };
|
|
1150
1150
|
}
|
|
1151
|
-
function
|
|
1151
|
+
function we(e) {
|
|
1152
1152
|
const t = e.source;
|
|
1153
1153
|
if (t) return JSON.stringify([t.datasetId, t.rowKey, t.field]);
|
|
1154
1154
|
const n = e.table;
|
|
@@ -1156,114 +1156,114 @@ function fe(e) {
|
|
|
1156
1156
|
const r = e.address;
|
|
1157
1157
|
return JSON.stringify([r.pageIndex, r.componentIndex, r.rowIndex, r.columnIndex]);
|
|
1158
1158
|
}
|
|
1159
|
-
function
|
|
1159
|
+
function Jn(e, t, n) {
|
|
1160
1160
|
if (typeof n != "string" || !n.trim() || !Array.isArray(t)) throw new M("missing");
|
|
1161
1161
|
if (t.length > 1e4) throw new M("limit");
|
|
1162
|
-
const r = /* @__PURE__ */ new Set(), i =
|
|
1163
|
-
const
|
|
1164
|
-
if (!
|
|
1165
|
-
const c =
|
|
1162
|
+
const r = /* @__PURE__ */ new Set(), i = he(e), s = t.map(({ address: l, value: o }) => {
|
|
1163
|
+
const a = i(l);
|
|
1164
|
+
if (!a) throw new M("missing");
|
|
1165
|
+
const c = pe(a, o), d = we(c);
|
|
1166
1166
|
if (r.has(d)) throw new M("duplicate");
|
|
1167
1167
|
return r.add(d), c;
|
|
1168
1168
|
});
|
|
1169
|
-
return { requestId: n, edits:
|
|
1169
|
+
return { requestId: n, edits: s };
|
|
1170
1170
|
}
|
|
1171
|
-
function
|
|
1171
|
+
function Yn(e, t) {
|
|
1172
1172
|
if (t.edits.length > 1e4) throw new M("limit");
|
|
1173
|
-
const n =
|
|
1174
|
-
const
|
|
1175
|
-
if (!
|
|
1176
|
-
const
|
|
1177
|
-
if (r.has(
|
|
1178
|
-
if (r.add(
|
|
1179
|
-
return
|
|
1173
|
+
const n = he(e), r = /* @__PURE__ */ new Set(), i = t.edits.map((s) => {
|
|
1174
|
+
const l = n(s.address);
|
|
1175
|
+
if (!l) throw new M("missing");
|
|
1176
|
+
const o = we(s);
|
|
1177
|
+
if (r.has(o)) throw new M("duplicate");
|
|
1178
|
+
if (r.add(o), qe(l, s) || !Object.is(l.value, s.previousValue) || (l.cell.text ?? "") !== s.previousText) throw new M("conflict");
|
|
1179
|
+
return pe(l, s.value);
|
|
1180
1180
|
});
|
|
1181
|
-
return
|
|
1181
|
+
return Qt(e, i);
|
|
1182
1182
|
}
|
|
1183
|
-
function
|
|
1183
|
+
function Xn(e) {
|
|
1184
1184
|
const t = /* @__PURE__ */ new Map();
|
|
1185
1185
|
for (const n of e) {
|
|
1186
|
-
const r =
|
|
1187
|
-
Object.is(
|
|
1186
|
+
const r = we(n), i = t.get(r), s = i ? { ...n, previousValue: i.previousValue, previousText: i.previousText } : { ...n };
|
|
1187
|
+
Object.is(s.previousValue, s.value) ? t.delete(r) : t.set(r, s);
|
|
1188
1188
|
}
|
|
1189
1189
|
return [...t.values()];
|
|
1190
1190
|
}
|
|
1191
|
-
function
|
|
1191
|
+
function Zn(e) {
|
|
1192
1192
|
return e.map((t) => t.map((n) => /[\t\r\n"]/.test(n) ? `"${n.replace(/"/g, '""')}"` : n).join(" ")).join(`\r
|
|
1193
1193
|
`);
|
|
1194
1194
|
}
|
|
1195
|
-
function
|
|
1195
|
+
function en(e, t) {
|
|
1196
1196
|
const n = e[e.length - 1];
|
|
1197
1197
|
e.length > 1 && n?.length === 1 && n[0] === "" && /[\r\n]$/.test(t) && e.pop();
|
|
1198
1198
|
}
|
|
1199
|
-
function
|
|
1199
|
+
function Qn(e, t = 1e4) {
|
|
1200
1200
|
if (e.length > 4 * 1024 * 1024) throw new Error("Clipboard text limit exceeded");
|
|
1201
1201
|
const n = [[]];
|
|
1202
|
-
let r = "", i = !1,
|
|
1203
|
-
function
|
|
1204
|
-
if (++
|
|
1205
|
-
n[n.length - 1].push(r), r = "",
|
|
1202
|
+
let r = "", i = !1, s = !1, l = 0;
|
|
1203
|
+
function o() {
|
|
1204
|
+
if (++l > t) throw new Error("Clipboard cell limit exceeded");
|
|
1205
|
+
n[n.length - 1].push(r), r = "", s = !1;
|
|
1206
1206
|
}
|
|
1207
|
-
for (let
|
|
1208
|
-
const c = e[
|
|
1207
|
+
for (let a = 0; a < e.length; a++) {
|
|
1208
|
+
const c = e[a];
|
|
1209
1209
|
if (i) {
|
|
1210
1210
|
if (c !== '"') {
|
|
1211
1211
|
r += c;
|
|
1212
1212
|
continue;
|
|
1213
1213
|
}
|
|
1214
|
-
if (e[
|
|
1215
|
-
r += '"',
|
|
1214
|
+
if (e[a + 1] === '"') {
|
|
1215
|
+
r += '"', a++;
|
|
1216
1216
|
continue;
|
|
1217
1217
|
}
|
|
1218
|
-
i = !1,
|
|
1218
|
+
i = !1, s = !0;
|
|
1219
1219
|
continue;
|
|
1220
1220
|
}
|
|
1221
|
-
if (c === '"' && !r && !
|
|
1221
|
+
if (c === '"' && !r && !s) {
|
|
1222
1222
|
i = !0;
|
|
1223
1223
|
continue;
|
|
1224
1224
|
}
|
|
1225
1225
|
if (c === " ") {
|
|
1226
|
-
|
|
1226
|
+
o();
|
|
1227
1227
|
continue;
|
|
1228
1228
|
}
|
|
1229
1229
|
if (c === "\r" || c === `
|
|
1230
1230
|
`) {
|
|
1231
|
-
|
|
1232
|
-
` &&
|
|
1231
|
+
o(), n.push([]), c === "\r" && e[a + 1] === `
|
|
1232
|
+
` && a++;
|
|
1233
1233
|
continue;
|
|
1234
1234
|
}
|
|
1235
|
-
if (
|
|
1235
|
+
if (s) throw new Error("Invalid quoted clipboard value");
|
|
1236
1236
|
r += c;
|
|
1237
1237
|
}
|
|
1238
1238
|
if (i) throw new Error("Unclosed clipboard quote");
|
|
1239
|
-
return
|
|
1239
|
+
return o(), en(n, e), n;
|
|
1240
1240
|
}
|
|
1241
|
-
function
|
|
1241
|
+
function er(e, t, n) {
|
|
1242
1242
|
if (!n || n.revision === void 0 && n.sourceToken === void 0) return e;
|
|
1243
|
-
const r = new Set(t.edits.flatMap((
|
|
1243
|
+
const r = new Set(t.edits.flatMap((l) => l.source ? [l.source.datasetId] : []));
|
|
1244
1244
|
if (!r.size) return e;
|
|
1245
|
-
function i(
|
|
1246
|
-
return !
|
|
1245
|
+
function i(l) {
|
|
1246
|
+
return !l.datasetId || !r.has(l.datasetId) || (n.revision === void 0 || Object.is(n.revision, l.revision)) && (n.sourceToken === void 0 || n.sourceToken === l.sourceToken) ? l : { ...l, ...n.revision !== void 0 ? { revision: n.revision } : {}, ...n.sourceToken !== void 0 ? { sourceToken: n.sourceToken } : {} };
|
|
1247
1247
|
}
|
|
1248
|
-
const
|
|
1249
|
-
const
|
|
1250
|
-
const c =
|
|
1248
|
+
const s = e.pages.map((l) => {
|
|
1249
|
+
const o = l.components.map((a) => {
|
|
1250
|
+
const c = a.table?.source ? i(a.table.source) : void 0, d = a.table && c !== a.table.source ? { ...a.table, source: c } : a.table, u = a.grid?.cells.map((f) => {
|
|
1251
1251
|
const h = f.map((g) => {
|
|
1252
1252
|
if (!g?.source) return g;
|
|
1253
1253
|
const b = i(g.source);
|
|
1254
1254
|
return b === g.source ? g : { ...g, source: b };
|
|
1255
1255
|
});
|
|
1256
1256
|
return h.some((g, b) => g !== f[b]) ? h : f;
|
|
1257
|
-
}), m =
|
|
1258
|
-
return d !==
|
|
1257
|
+
}), m = a.grid && u?.some((f, h) => f !== a.grid.cells[h]) ? { ...a.grid, cells: u } : a.grid;
|
|
1258
|
+
return d !== a.table || m !== a.grid ? { ...a, table: d, grid: m } : a;
|
|
1259
1259
|
});
|
|
1260
|
-
return
|
|
1260
|
+
return o.some((a, c) => a !== l.components[c]) ? { ...l, components: o } : l;
|
|
1261
1261
|
});
|
|
1262
|
-
return
|
|
1262
|
+
return s.some((l, o) => l !== e.pages[o]) ? { ...e, pages: s } : e;
|
|
1263
1263
|
}
|
|
1264
|
-
class
|
|
1264
|
+
class tn extends Error {
|
|
1265
1265
|
constructor(t, n, r) {
|
|
1266
|
-
const i = typeof n.label == "string" ? n.label : "单元格",
|
|
1266
|
+
const i = typeof n.label == "string" ? n.label : "单元格", s = {
|
|
1267
1267
|
definition: `${i}的编辑器配置无效`,
|
|
1268
1268
|
type: `${i}的编辑器与数据类型不一致`,
|
|
1269
1269
|
required: `${i}不能为空`,
|
|
@@ -1274,154 +1274,352 @@ class Ut extends Error {
|
|
|
1274
1274
|
choice: `${i}请选择有效选项`,
|
|
1275
1275
|
date: `${i}请输入有效日期(YYYY-MM-DD)`
|
|
1276
1276
|
};
|
|
1277
|
-
super(
|
|
1277
|
+
super(s[t]), this.code = t, this.field = n, this.expected = r, this.name = "ReportCellFieldError";
|
|
1278
1278
|
}
|
|
1279
1279
|
}
|
|
1280
1280
|
function w(e, t, n) {
|
|
1281
|
-
throw new
|
|
1281
|
+
throw new tn(t, e, n);
|
|
1282
1282
|
}
|
|
1283
|
-
function
|
|
1283
|
+
function Je(e) {
|
|
1284
1284
|
if (typeof e != "string" || !/^\d{4}-\d{2}-\d{2}$/.test(e) || e.startsWith("0000-")) return !1;
|
|
1285
1285
|
const t = /* @__PURE__ */ new Date(`${e}T00:00:00.000Z`);
|
|
1286
1286
|
return Number.isFinite(t.getTime()) && t.toISOString().slice(0, 10) === e;
|
|
1287
1287
|
}
|
|
1288
|
-
function
|
|
1288
|
+
function nn(e) {
|
|
1289
1289
|
const [t = "", n = "0"] = String(e).toLowerCase().split("e");
|
|
1290
1290
|
return Math.max(0, (t.split(".")[1]?.length ?? 0) - Number(n));
|
|
1291
1291
|
}
|
|
1292
|
-
function
|
|
1293
|
-
e.min !== void 0 && t < e.min && w(e, "min", e.min), e.max !== void 0 && t > e.max && w(e, "max", e.max), e.precision !== void 0 &&
|
|
1292
|
+
function rn(e, t) {
|
|
1293
|
+
e.min !== void 0 && t < e.min && w(e, "min", e.min), e.max !== void 0 && t > e.max && w(e, "max", e.max), e.precision !== void 0 && nn(t) > e.precision && w(e, "precision", e.precision);
|
|
1294
1294
|
}
|
|
1295
|
-
function
|
|
1296
|
-
|
|
1295
|
+
function on(e, t) {
|
|
1296
|
+
Je(t) || w(e, "date"), e.min !== void 0 && t < e.min && w(e, "min", e.min), e.max !== void 0 && t > e.max && w(e, "max", e.max);
|
|
1297
1297
|
}
|
|
1298
|
-
function
|
|
1298
|
+
function an(e) {
|
|
1299
1299
|
[e.min, e.max].some((t) => t !== void 0 && !Number.isFinite(t)) && w(e, "definition"), e.min !== void 0 && e.max !== void 0 && e.min > e.max && w(e, "definition"), e.precision !== void 0 && (!Number.isInteger(e.precision) || e.precision < 0 || e.precision > 15) && w(e, "definition");
|
|
1300
1300
|
}
|
|
1301
|
-
function
|
|
1302
|
-
[e.min, e.max].some((t) => t !== void 0 && !
|
|
1301
|
+
function sn(e) {
|
|
1302
|
+
[e.min, e.max].some((t) => t !== void 0 && !Je(t)) && w(e, "definition"), e.min !== void 0 && e.max !== void 0 && e.min > e.max && w(e, "definition");
|
|
1303
1303
|
}
|
|
1304
|
-
function
|
|
1304
|
+
function ln(e, t) {
|
|
1305
1305
|
(!Array.isArray(t.options) || !t.options.length) && w(t, "definition");
|
|
1306
1306
|
const n = e.valueType === "text" ? "string" : e.valueType, r = /* @__PURE__ */ new Set();
|
|
1307
1307
|
for (const i of t.options)
|
|
1308
1308
|
(!i || typeof i.value !== n || typeof i.value == "number" && !Number.isFinite(i.value)) && w(t, "definition"), i.label !== void 0 && typeof i.label != "string" && w(t, "definition"), r.has(i.value) && w(t, "definition"), r.add(i.value);
|
|
1309
1309
|
}
|
|
1310
|
-
function
|
|
1310
|
+
function cn(e) {
|
|
1311
1311
|
e.required !== void 0 && typeof e.required != "boolean" && w(e, "definition"), [e.label, e.hint, e.unit].some((t) => t !== void 0 && typeof t != "string") && w(e, "definition"), e.type === "boolean" && [e.trueLabel, e.falseLabel].some((t) => t !== void 0 && typeof t != "string") && w(e, "definition");
|
|
1312
1312
|
}
|
|
1313
|
-
function
|
|
1314
|
-
(!t || typeof t != "object" || Array.isArray(t) || !["text", "number", "boolean", "enum", "date"].includes(t.type)) && w(t ?? { type: "text" }, "definition"),
|
|
1313
|
+
function dn(e, t) {
|
|
1314
|
+
(!t || typeof t != "object" || Array.isArray(t) || !["text", "number", "boolean", "enum", "date"].includes(t.type)) && w(t ?? { type: "text" }, "definition"), cn(t), (t.type === "number" || t.type === "boolean") && e.valueType !== t.type && w(t, "type"), (t.type === "text" || t.type === "date") && e.valueType !== "text" && w(t, "type"), t.type === "number" && an(t), t.type === "text" && t.maxLength !== void 0 && (!Number.isInteger(t.maxLength) || t.maxLength < 0) && w(t, "definition"), t.type === "date" && sn(t), t.type === "enum" && ln(e, t);
|
|
1315
1315
|
}
|
|
1316
|
-
function
|
|
1316
|
+
function tr(e, t, n) {
|
|
1317
1317
|
if (!e.editable) throw new M("readonly");
|
|
1318
|
-
n &&
|
|
1319
|
-
const r =
|
|
1320
|
-
return n ? (n.required && typeof r == "string" && !r.trim() && w(n, "required"), r === null || r === "" ? (n.required && w(n, "required"), r) : (n.type === "number" &&
|
|
1318
|
+
n && dn(e, n);
|
|
1319
|
+
const r = ge(e, t);
|
|
1320
|
+
return n ? (n.required && typeof r == "string" && !r.trim() && w(n, "required"), r === null || r === "" ? (n.required && w(n, "required"), r) : (n.type === "number" && rn(n, r), n.type === "date" && on(n, r), n.type === "text" && n.maxLength !== void 0 && [...String(r)].length > n.maxLength && w(n, "length", n.maxLength), n.type === "enum" && !n.options.some((i) => Object.is(i.value, r)) && w(n, "choice"), r)) : r;
|
|
1321
|
+
}
|
|
1322
|
+
class v extends Error {
|
|
1323
|
+
constructor(t) {
|
|
1324
|
+
super(`Report calculation: ${t}`), this.code = t, this.name = "ReportCalculationError";
|
|
1325
|
+
}
|
|
1326
|
+
}
|
|
1327
|
+
function z(e) {
|
|
1328
|
+
if (!e?.aborted) return;
|
|
1329
|
+
const t = new Error("Calculation cancelled");
|
|
1330
|
+
throw t.name = "AbortError", t;
|
|
1331
|
+
}
|
|
1332
|
+
async function Z(e, t = 1) {
|
|
1333
|
+
const n = Math.floor(e.scanned / 2048);
|
|
1334
|
+
if (e.scanned += t, e.scanned > e.maxScanned) throw new v("limit");
|
|
1335
|
+
z(e.signal), Math.floor(e.scanned / 2048) > n && (await e.yieldToHost(), z(e.signal));
|
|
1336
|
+
}
|
|
1337
|
+
function be(e) {
|
|
1338
|
+
return e.table?.role === "header" ? -Math.max(1, e.grid?.cells.length ?? 1) : e.table?.rowIndex ?? 0;
|
|
1339
|
+
}
|
|
1340
|
+
function Ce(e, t, n) {
|
|
1341
|
+
if (![t.pageIndex, t.componentIndex, t.rowIndex, t.columnIndex].every((o) => Number.isSafeInteger(o) && o >= 0)) throw new v("selection");
|
|
1342
|
+
const r = e.pages[t.pageIndex]?.components[t.componentIndex];
|
|
1343
|
+
if (!r?.grid || t.rowIndex >= r.grid.cells.length) throw new v("selection");
|
|
1344
|
+
const i = r.grid.colWidthsMm?.length ?? r.grid.cells.reduce((o, a) => Math.max(o, a.length), 1);
|
|
1345
|
+
if (t.columnIndex >= i) throw new v("selection");
|
|
1346
|
+
const s = r.table, l = e.pages[n.pageIndex]?.components[n.componentIndex]?.table;
|
|
1347
|
+
if (s && l && s.id === l.id) {
|
|
1348
|
+
const o = l.columnKeys.indexOf(s.columnKeys[t.columnIndex] ?? "");
|
|
1349
|
+
if (o < 0) throw new v("selection");
|
|
1350
|
+
return { grid: s.id, row: be(r) + t.rowIndex, column: o };
|
|
1351
|
+
}
|
|
1352
|
+
return { grid: `${t.pageIndex}:${t.componentIndex}`, row: t.rowIndex, column: t.columnIndex };
|
|
1353
|
+
}
|
|
1354
|
+
function un(e, t, n) {
|
|
1355
|
+
const r = Ce(e, t.anchor, t.anchor), i = Ce(e, t.focus, t.anchor);
|
|
1356
|
+
if (r.grid !== i.grid) throw new v("selection");
|
|
1357
|
+
const s = (Math.abs(r.row - i.row) + 1) * (Math.abs(r.column - i.column) + 1);
|
|
1358
|
+
if (!Number.isSafeInteger(s) || s > n) throw new v("limit");
|
|
1359
|
+
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 };
|
|
1360
|
+
}
|
|
1361
|
+
function mn(e) {
|
|
1362
|
+
if (!e) return !1;
|
|
1363
|
+
const t = e.replace(/"[^"]*"|\\.|\[(?![hms]+\])[^\]]*\]/gi, "");
|
|
1364
|
+
return /[ymdhs]/i.test(t);
|
|
1365
|
+
}
|
|
1366
|
+
function fn(e) {
|
|
1367
|
+
if (e.valueType === "text" || e.valueType === "boolean" || mn(e.numberFormat)) return null;
|
|
1368
|
+
const t = e.value;
|
|
1369
|
+
if (typeof t != "number" || !Number.isFinite(t)) return null;
|
|
1370
|
+
if (Number.isInteger(t) && !Number.isSafeInteger(t)) throw new v("precision");
|
|
1371
|
+
return t;
|
|
1372
|
+
}
|
|
1373
|
+
function hn(e, t, n) {
|
|
1374
|
+
if (e.seen.has(n)) return;
|
|
1375
|
+
e.seen.add(n), e.selected++;
|
|
1376
|
+
const r = t ? fn(t) : null;
|
|
1377
|
+
r === null ? e.excluded++ : e.values.push(r);
|
|
1378
|
+
}
|
|
1379
|
+
function gn(e, t, n, r) {
|
|
1380
|
+
return r.origin ? e.table?.id === r.origin.id : `${t}:${n}` === r.grid;
|
|
1381
|
+
}
|
|
1382
|
+
function pn(e, t, n) {
|
|
1383
|
+
return n.origin ? n.origin.columnKeys.indexOf(e.table.columnKeys[t] ?? "") : t;
|
|
1384
|
+
}
|
|
1385
|
+
function wn(e, t, n, r) {
|
|
1386
|
+
const i = r.origin ? be(e) + t : t, s = pn(e, n, r);
|
|
1387
|
+
return i < r.rowStart || i > r.rowEnd || s < r.columnStart || s > r.columnEnd ? null : `${r.grid}:${i}:${s}`;
|
|
1388
|
+
}
|
|
1389
|
+
function bn(e, t) {
|
|
1390
|
+
const n = t.origin ? be(e) : 0, r = Math.max(0, t.rowStart - n), i = Math.min(e.grid.cells.length, t.rowEnd - n + 1);
|
|
1391
|
+
return i > r ? i : 0;
|
|
1392
|
+
}
|
|
1393
|
+
async function vn(e, t, n, r, i) {
|
|
1394
|
+
const s = e.grid;
|
|
1395
|
+
if (t > r.maxScanned) throw new v("limit");
|
|
1396
|
+
const l = s.colWidthsMm?.length ?? s.cells.reduce((a, c) => Math.max(a, c.length), 1);
|
|
1397
|
+
if (l > r.maxScanned) throw new v("limit");
|
|
1398
|
+
const o = /* @__PURE__ */ new Map();
|
|
1399
|
+
for (let a = 0; a < t; a++) {
|
|
1400
|
+
a > 0 && a % 2048 === 0 && (await r.yieldToHost(), z(r.signal));
|
|
1401
|
+
let c = 0;
|
|
1402
|
+
for (const d of s.cells[a]) {
|
|
1403
|
+
for (await Z(r); c < l && (o.get(c) ?? 0) > a; ) c++;
|
|
1404
|
+
if (c >= l) break;
|
|
1405
|
+
const u = Math.max(1, Math.min(d?.colSpan ?? 1, l - c)), m = Math.min(s.cells.length, a + Math.max(1, d?.rowSpan ?? 1));
|
|
1406
|
+
u > 1 && await Z(r, u - 1);
|
|
1407
|
+
for (let h = c; h < c + u; h++) o.set(h, m);
|
|
1408
|
+
const f = wn(e, a, c, n);
|
|
1409
|
+
f && hn(i, d, f), c += u;
|
|
1410
|
+
}
|
|
1411
|
+
}
|
|
1412
|
+
}
|
|
1413
|
+
async function yn(e, t, n) {
|
|
1414
|
+
const r = { values: [], seen: /* @__PURE__ */ new Set(), excluded: 0, selected: 0 };
|
|
1415
|
+
for (let i = 0; i < e.pages.length; i++) {
|
|
1416
|
+
await Z(n);
|
|
1417
|
+
const s = e.pages[i];
|
|
1418
|
+
for (let l = 0; l < s.components.length; l++) {
|
|
1419
|
+
await Z(n);
|
|
1420
|
+
const o = s.components[l];
|
|
1421
|
+
if (!o.grid || !gn(o, i, l, t) || o.table && o.table.role !== "body") continue;
|
|
1422
|
+
const a = bn(o, t);
|
|
1423
|
+
a && await vn(o, a, t, n, r);
|
|
1424
|
+
}
|
|
1425
|
+
}
|
|
1426
|
+
return r;
|
|
1427
|
+
}
|
|
1428
|
+
function _(e) {
|
|
1429
|
+
if (!Number.isFinite(e)) throw new v("overflow");
|
|
1430
|
+
return e;
|
|
1431
|
+
}
|
|
1432
|
+
function xn(e) {
|
|
1433
|
+
let t = 0, n = 0;
|
|
1434
|
+
for (const r of e) {
|
|
1435
|
+
const i = r - n, s = _(t + i);
|
|
1436
|
+
n = s - t - i, t = s;
|
|
1437
|
+
}
|
|
1438
|
+
return t;
|
|
1439
|
+
}
|
|
1440
|
+
async function Ie(e, t) {
|
|
1441
|
+
let n = [...e], r = new Array(e.length);
|
|
1442
|
+
for (let s = 1; s < e.length; s *= 2) {
|
|
1443
|
+
for (let l = 0; l < e.length; l += s * 2) {
|
|
1444
|
+
const o = Math.min(l + s, e.length), a = Math.min(l + s * 2, e.length);
|
|
1445
|
+
let c = l, d = o;
|
|
1446
|
+
for (let u = l; u < a; u++)
|
|
1447
|
+
r[u] = d >= a || c < o && n[c] <= n[d] ? n[c++] : n[d++], u % 2048 === 0 && (await t.yieldToHost(), z(t.signal));
|
|
1448
|
+
}
|
|
1449
|
+
[n, r] = [r, n];
|
|
1450
|
+
}
|
|
1451
|
+
const i = Math.floor(n.length / 2);
|
|
1452
|
+
return n.length % 2 ? n[i] : _(n[i - 1] / 2 + n[i] / 2);
|
|
1453
|
+
}
|
|
1454
|
+
function Mn(e) {
|
|
1455
|
+
const t = xn(e);
|
|
1456
|
+
let n = 1 / 0, r = -1 / 0;
|
|
1457
|
+
for (const i of e)
|
|
1458
|
+
n = Math.min(n, i), r = Math.max(r, i);
|
|
1459
|
+
return { SUM: t, AVERAGE: t / e.length, AVG: t / e.length, MIN: n, MAX: r, COUNT: e.length };
|
|
1460
|
+
}
|
|
1461
|
+
function En(e, t) {
|
|
1462
|
+
if (typeof e != "string" || e.length > 256) throw new v("expression");
|
|
1463
|
+
const n = e.toUpperCase().match(/(?:\d+(?:\.\d*)?|\.\d+)(?:E[+-]?\d+)?|[A-Z_]+|[()+\-*/]|\S/g) ?? [];
|
|
1464
|
+
if (!n.length || n.length > 64) throw new v("expression");
|
|
1465
|
+
let r = 0;
|
|
1466
|
+
function i(o) {
|
|
1467
|
+
if (o > 16) throw new v("expression");
|
|
1468
|
+
const a = n[r++];
|
|
1469
|
+
if (a === "+" || a === "-") return (a === "-" ? -1 : 1) * i(o + 1);
|
|
1470
|
+
if (a === "(") {
|
|
1471
|
+
const c = s(0, o + 1);
|
|
1472
|
+
if (n[r++] !== ")") throw new v("expression");
|
|
1473
|
+
return c;
|
|
1474
|
+
}
|
|
1475
|
+
if (a && /^(?:SUM|AVERAGE|AVG|MIN|MAX|COUNT|MEDIAN)$/.test(a) && Object.prototype.hasOwnProperty.call(t, a)) return _(t[a]);
|
|
1476
|
+
if (a && /^(?:\d+(?:\.\d*)?|\.\d+)(?:E[+-]?\d+)?$/.test(a)) return _(Number(a));
|
|
1477
|
+
throw new v("expression");
|
|
1478
|
+
}
|
|
1479
|
+
function s(o, a) {
|
|
1480
|
+
let c = i(a);
|
|
1481
|
+
for (; r < n.length; ) {
|
|
1482
|
+
const d = n[r], u = d === "+" || d === "-" ? 1 : d === "*" || d === "/" ? 2 : 0;
|
|
1483
|
+
if (!u || u < o) break;
|
|
1484
|
+
r++;
|
|
1485
|
+
const m = s(u + 1, a + 1);
|
|
1486
|
+
if (d === "/" && m === 0) throw new v("division");
|
|
1487
|
+
c = _(d === "+" ? c + m : d === "-" ? c - m : d === "*" ? c * m : c / m);
|
|
1488
|
+
}
|
|
1489
|
+
return c;
|
|
1490
|
+
}
|
|
1491
|
+
const l = s(1, 0);
|
|
1492
|
+
if (r !== n.length) throw new v("expression");
|
|
1493
|
+
return l;
|
|
1494
|
+
}
|
|
1495
|
+
function Sn(e) {
|
|
1496
|
+
const t = e.maxCells ?? 1e5, n = e.maxScannedCells ?? 2e5, r = e.precision ?? 2;
|
|
1497
|
+
if (![t, n].every((i) => Number.isSafeInteger(i) && i >= 1 && i <= 2e6)) throw new v("limit");
|
|
1498
|
+
if (!Number.isInteger(r) || r < 0 || r > 12) throw new v("precision");
|
|
1499
|
+
return { maxCells: t, maxScanned: n, precision: r };
|
|
1500
|
+
}
|
|
1501
|
+
async function nr(e, t, n = {}) {
|
|
1502
|
+
const r = Sn(n), i = { scanned: 0, maxScanned: r.maxScanned, signal: n.signal, yieldToHost: n.yieldToHost ?? (() => new Promise((a) => setTimeout(a, 0))) };
|
|
1503
|
+
z(i.signal);
|
|
1504
|
+
const s = await yn(e, un(e, t, r.maxCells), i), l = n.operation ?? "sum";
|
|
1505
|
+
if (!["sum", "average", "min", "max", "count", "median", "expression"].includes(l)) throw new v("expression");
|
|
1506
|
+
let o = null;
|
|
1507
|
+
if (l === "count") o = s.values.length;
|
|
1508
|
+
else if (s.values.length)
|
|
1509
|
+
if (l === "median") o = await Ie(s.values, i);
|
|
1510
|
+
else {
|
|
1511
|
+
const a = Mn(s.values);
|
|
1512
|
+
l === "expression" ? (/\bMEDIAN\b/i.test(n.expression ?? "") && (a.MEDIAN = await Ie(s.values, i)), o = En(n.expression ?? "", a)) : o = a[l.toUpperCase()];
|
|
1513
|
+
}
|
|
1514
|
+
if (z(i.signal), o !== null && Number.isInteger(o) && !Number.isSafeInteger(o)) throw new v("precision");
|
|
1515
|
+
return { value: o, formatted: o === null ? "—" : o.toFixed(r.precision), numericCells: s.values.length, excludedCells: s.excluded, selectedCells: s.selected, precision: r.precision };
|
|
1321
1516
|
}
|
|
1322
1517
|
export {
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1518
|
+
Sr as CSS_DPI,
|
|
1519
|
+
or as DEFAULT_BORDER_PT,
|
|
1520
|
+
ee as DEFAULT_FONT_FAMILY,
|
|
1521
|
+
ar as DEFAULT_FONT_PT,
|
|
1522
|
+
sr as DEFAULT_STROKE_COLOR,
|
|
1523
|
+
Pe as DEFAULT_TEXT_COLOR,
|
|
1524
|
+
lr as LINE_HEIGHT,
|
|
1525
|
+
Tr as MM_PER_INCH,
|
|
1526
|
+
Hr as OutputAssetError,
|
|
1527
|
+
nt as OutputFidelityError,
|
|
1528
|
+
Y as PAPER_SIZES,
|
|
1529
|
+
kt as PageBuilder,
|
|
1530
|
+
mr as PaginatePageLimitError,
|
|
1531
|
+
cr as RENDER_PLAN_SCHEMA_VERSION,
|
|
1532
|
+
_r as REPORT_TEMPLATE_DOCUMENT_VERSION,
|
|
1533
|
+
v as ReportCalculationError,
|
|
1338
1534
|
M as ReportCellEditError,
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
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
|
-
|
|
1535
|
+
tn as ReportCellFieldError,
|
|
1536
|
+
Xr as ReportParamValidationError,
|
|
1537
|
+
fr as ReportSourceError,
|
|
1538
|
+
Kr as ReportTemplateError,
|
|
1539
|
+
O as ReportTemplateStoreError,
|
|
1540
|
+
dr as SCHEMA_VERSION_MACH,
|
|
1541
|
+
At as TemplateBuilder,
|
|
1542
|
+
qn as applyReportCellEdit,
|
|
1543
|
+
Yn as applyReportCellEditBatch,
|
|
1544
|
+
er as applyReportEditResult,
|
|
1545
|
+
Rr as assertRenderPlan,
|
|
1546
|
+
Zr as assertReportParams,
|
|
1547
|
+
nr as calculateReportSelection,
|
|
1548
|
+
Fr as charWidthEm,
|
|
1549
|
+
C as classOf,
|
|
1550
|
+
Bn as columnsFromContract,
|
|
1551
|
+
Mt as computePageWindow,
|
|
1552
|
+
Or as createCanvasMeasurer,
|
|
1553
|
+
jn as createCanvasPager,
|
|
1554
|
+
Dr as createHeuristicMeasurer,
|
|
1555
|
+
Gn as createMemoryTemplateStore,
|
|
1556
|
+
Kn as createProviderReport,
|
|
1557
|
+
Un as createReportCellEdit,
|
|
1558
|
+
Jn as createReportCellEditBatch,
|
|
1559
|
+
he as createReportCellResolver,
|
|
1560
|
+
hr as createReportSource,
|
|
1561
|
+
_n as createTableTemplate,
|
|
1562
|
+
Wn as createTemplate,
|
|
1563
|
+
Vn as createTemplateManager,
|
|
1564
|
+
Vr as createTemplateRegistry,
|
|
1565
|
+
gr as datasetJsonSchema,
|
|
1566
|
+
pr as defineReport,
|
|
1567
|
+
Gr as defineReportTemplate,
|
|
1568
|
+
wr as evalStyleRule,
|
|
1569
|
+
En as evaluateReportAggregateExpression,
|
|
1570
|
+
ne as formatReportCellEdit,
|
|
1571
|
+
Zn as formatReportClipboard,
|
|
1572
|
+
br as formatValue,
|
|
1573
|
+
fe as getReportCellContext,
|
|
1574
|
+
le as heuristicMeasurer,
|
|
1575
|
+
Wr as inspectOutputCapabilities,
|
|
1576
|
+
Q as isImageBackedComponent,
|
|
1577
|
+
Qr as isReportDate,
|
|
1578
|
+
Re as isRichText,
|
|
1579
|
+
ue as measurePageSizePx,
|
|
1580
|
+
Lr as measureTextMm,
|
|
1581
|
+
ke as mergeComponentStyles,
|
|
1582
|
+
se as mmToPx,
|
|
1583
|
+
Cr as mmToPxFactor,
|
|
1584
|
+
vr as paginateTemplate,
|
|
1585
|
+
yr as parseDateLocal,
|
|
1586
|
+
tr as parseReportCellFieldInput,
|
|
1587
|
+
ge as parseReportCellInput,
|
|
1588
|
+
Qn as parseReportClipboard,
|
|
1589
|
+
ae as parseReportTemplate,
|
|
1590
|
+
Dn as planFontSizePx,
|
|
1591
|
+
L as ptToPx,
|
|
1592
|
+
Ir as pxToMm,
|
|
1593
|
+
Le as renderComponent,
|
|
1594
|
+
wt as renderPage,
|
|
1595
|
+
On as renderPlan,
|
|
1596
|
+
zn as renderPlanToCanvas,
|
|
1597
|
+
Hn as renderPlanToCanvasAsync,
|
|
1598
|
+
Ln as renderPlanToImages,
|
|
1599
|
+
we as reportCellEditKey,
|
|
1600
|
+
V as reportOutputDiagnostics,
|
|
1601
|
+
ei as reportParamsJsonSchema,
|
|
1602
|
+
Ae as resolveBoxBorders,
|
|
1603
|
+
j as resolveFontSize,
|
|
1604
|
+
K as resolveGridLayout,
|
|
1605
|
+
te as resolveLineHeight,
|
|
1606
|
+
_e as resolvePaper,
|
|
1607
|
+
ce as resolvePlanAssets,
|
|
1608
|
+
B as resolveStroke,
|
|
1609
|
+
$e as resolveTextColor,
|
|
1610
|
+
H as round,
|
|
1611
|
+
Ur as serializeReportTemplate,
|
|
1612
|
+
Xn as summarizeReportCellEdits,
|
|
1613
|
+
xr as toExcelNumberFormat,
|
|
1614
|
+
Mr as toNumber,
|
|
1615
|
+
Ar as validateComponent,
|
|
1616
|
+
et as validateDatasetRows,
|
|
1617
|
+
kr as validatePage,
|
|
1618
|
+
$r as validateRenderPlan,
|
|
1619
|
+
dn as validateReportCellFieldDefinition,
|
|
1620
|
+
ti as validateReportParamDefinitions,
|
|
1621
|
+
ni as validateReportParams,
|
|
1622
|
+
qr as validateReportTemplate,
|
|
1623
|
+
Jr as validateReportTemplateDocument,
|
|
1624
|
+
Ne as wrapText
|
|
1427
1625
|
};
|