@agile-team/mach-report 0.8.0 → 0.9.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/dist/index.js CHANGED
@@ -1,42 +1,57 @@
1
- import { h as rt, R as Pt, D as X, w as Z, L as Q, i as At, r as G, m as Et, a as V, b as ut, c as O, d as tt, p as K, e as $t, f as pt, g as Ht, P as ct } from "./style-6ihHKVCM.js";
2
- import { C as ue, j as pe, k as Me, M as be, S as ye, l as we, n as Se, o as Te, q as xe, s as ke, t as ve, u as Ce, v as Pe, x as Ae } from "./style-6ihHKVCM.js";
1
+ import { h as ot, R as At, D as X, w as Z, L as Q, i as Et, r as G, m as $t, a as V, b as ut, c as O, d as tt, p as K, e as Ht, f as pt, g as Nt, P as ht } from "./style-6ihHKVCM.js";
2
+ import { C as be, j as ye, k as we, M as Se, S as Te, l as xe, n as ke, o as ve, q as Ce, s as Pe, t as Ae, u as Ee, v as $e, x as He } from "./style-6ihHKVCM.js";
3
3
  import { r as Rt } from "./grid-geometry-Bs8QXz1X.js";
4
- function ht(t, e) {
5
- return e != null ? t.toLocaleString("en-US", {
4
+ function Bt(t) {
5
+ const e = /^(\d{4})[-/](\d{1,2})[-/](\d{1,2})$/.exec(t.trim());
6
+ if (e) {
7
+ const n = new Date(Number(e[1]), Number(e[2]) - 1, Number(e[3]));
8
+ return Number.isNaN(n.getTime()) ? null : n;
9
+ }
10
+ const r = new Date(t);
11
+ return Number.isNaN(r.getTime()) ? null : r;
12
+ }
13
+ function nt(t, e) {
14
+ return t.toLocaleString("en-US", {
6
15
  minimumFractionDigits: e,
7
16
  maximumFractionDigits: e
8
- }) : t.toLocaleString("en-US");
17
+ });
9
18
  }
10
- function Nt(t, e) {
11
- const r = (n, i = 2) => String(n).padStart(i, "0");
19
+ function Lt(t, e) {
20
+ const r = (n) => String(n).padStart(2, "0");
12
21
  return e.replace(/YYYY/g, String(t.getFullYear())).replace(/MM/g, r(t.getMonth() + 1)).replace(/DD/g, r(t.getDate())).replace(/hh/g, r(t.getHours())).replace(/mm/g, r(t.getMinutes())).replace(/ss/g, r(t.getSeconds()));
13
22
  }
23
+ function Ft(t, e, r) {
24
+ return r != null ? e ? nt(t, r) : t.toFixed(r) : e ? nt(t) : String(t);
25
+ }
26
+ function rt(t) {
27
+ const e = typeof t == "number" ? t : Number(String(t).replace(/,/g, ""));
28
+ return Number.isFinite(e) ? e : null;
29
+ }
14
30
  function Mt(t, e) {
15
31
  if (t == null || t === "" || !e) return String(t ?? "");
16
32
  switch (e.kind) {
17
33
  case "number": {
18
- const r = typeof t == "number" ? t : Number(String(t).replace(/,/g, ""));
19
- return Number.isFinite(r) ? e.thousands === !1 ? r.toFixed(e.digits ?? 0).replace(/\.?0+$/, "") || String(r) : ht(r, e.digits) : String(t);
34
+ const r = rt(t);
35
+ return r == null ? String(t) : Ft(r, e.thousands === !0, e.digits);
20
36
  }
21
37
  case "percent": {
22
- const r = typeof t == "number" ? t : Number(String(t).replace(/,/g, ""));
23
- if (!Number.isFinite(r)) return String(t);
24
- const n = e.digits ?? 2;
25
- return `${ht(r * 100, n)}%`;
38
+ const r = rt(t);
39
+ return r == null ? String(t) : `${nt(r * 100, e.digits ?? 2)}%`;
26
40
  }
27
41
  case "date": {
28
- const r = e.pattern ?? "YYYY-MM-DD", n = t instanceof Date ? t : new Date(t);
29
- return Number.isNaN(n.getTime()) ? String(t) : Nt(n, r);
42
+ const r = e.pattern ?? "YYYY-MM-DD", n = t instanceof Date ? t : Bt(String(t));
43
+ return n ? Lt(n, r) : String(t);
30
44
  }
31
45
  default:
32
46
  return String(t);
33
47
  }
34
48
  }
35
- function Bt(t, e) {
49
+ function zt(t, e) {
36
50
  const r = t[e.field];
51
+ if (r == null || r === "") return !1;
37
52
  if (typeof e.value == "number") {
38
- const s = typeof r == "number" ? r : Number(r);
39
- if (!Number.isFinite(s)) return !1;
53
+ const s = rt(r);
54
+ if (s == null) return !1;
40
55
  switch (e.op) {
41
56
  case ">":
42
57
  return s > e.value;
@@ -52,24 +67,24 @@ function Bt(t, e) {
52
67
  return s !== e.value;
53
68
  }
54
69
  }
55
- const n = String(r ?? ""), i = String(e.value);
70
+ const n = String(r), o = String(e.value);
56
71
  switch (e.op) {
57
72
  case "==":
58
- return n === i;
73
+ return n === o;
59
74
  case "!=":
60
- return n !== i;
75
+ return n !== o;
61
76
  case ">":
62
- return n > i;
77
+ return n > o;
63
78
  case ">=":
64
- return n >= i;
79
+ return n >= o;
65
80
  case "<":
66
- return n < i;
81
+ return n < o;
67
82
  case "<=":
68
- return n <= i;
83
+ return n <= o;
69
84
  }
70
85
  return !1;
71
86
  }
72
- const Ft = /* @__PURE__ */ new Set([
87
+ const Dt = /* @__PURE__ */ new Set([
73
88
  "text",
74
89
  "image",
75
90
  "barcode",
@@ -82,53 +97,53 @@ const Ft = /* @__PURE__ */ new Set([
82
97
  function I(t) {
83
98
  return typeof t == "object" && t !== null && !Array.isArray(t);
84
99
  }
85
- function Lt(t, e, r, n) {
86
- const i = t[e];
87
- i != null && (typeof i != "number" || !Number.isFinite(i)) && n.push({ path: `${r}.${e}`, message: `应为有限数字,实际 ${JSON.stringify(i)}` });
100
+ function _t(t, e, r, n) {
101
+ const o = t[e];
102
+ o != null && (typeof o != "number" || !Number.isFinite(o)) && n.push({ path: `${r}.${e}`, message: `应为有限数字,实际 ${JSON.stringify(o)}` });
88
103
  }
89
104
  function bt(t, e, r, n = []) {
90
105
  if (!I(t)) {
91
106
  r.push({ path: e, message: "组件应为对象" });
92
107
  return;
93
108
  }
94
- const i = t.kind;
95
- typeof i != "string" ? r.push({ path: `${e}.kind`, message: "组件缺少 kind 字符串" }) : Ft.has(i) || n.push({
109
+ const o = t.kind;
110
+ typeof o != "string" ? r.push({ path: `${e}.kind`, message: "组件缺少 kind 字符串" }) : Dt.has(o) || n.push({
96
111
  path: `${e}.kind`,
97
- message: `未知组件类型 ${JSON.stringify(i)},将以兜底方式渲染`
112
+ message: `未知组件类型 ${JSON.stringify(o)},将以兜底方式渲染`
98
113
  });
99
- for (const o of ["leftMm", "topMm", "widthMm", "heightMm"])
100
- Lt(t, o, e, r);
114
+ for (const i of ["leftMm", "topMm", "widthMm", "heightMm"])
115
+ _t(t, i, e, r);
101
116
  t.leftMm != null && t.widthMm != null && (t.leftMm < -100 || t.widthMm < 0) && r.push({ path: e, message: "几何数值异常(leftMm<-100 或 widthMm<0)" });
102
117
  const s = t.grid;
103
- s !== void 0 && (!I(s) || !Array.isArray(s.cells) ? r.push({ path: `${e}.grid.cells`, message: "grid.cells 应为二维数组" }) : s.cells.forEach((o, d) => {
104
- if (!Array.isArray(o)) {
118
+ s !== void 0 && (!I(s) || !Array.isArray(s.cells) ? r.push({ path: `${e}.grid.cells`, message: "grid.cells 应为二维数组" }) : s.cells.forEach((i, d) => {
119
+ if (!Array.isArray(i)) {
105
120
  r.push({ path: `${e}.grid.cells.${d}`, message: "行应为数组" });
106
121
  return;
107
122
  }
108
- o.forEach((c, h) => {
109
- c != null && I(c) && Array.isArray(c.children) && c.children.forEach((g, l) => {
110
- bt(g, `${e}.grid.cells.${d}.${h}.children.${l}`, r, n);
123
+ i.forEach((c, h) => {
124
+ c != null && I(c) && Array.isArray(c.children) && c.children.forEach((m, l) => {
125
+ bt(m, `${e}.grid.cells.${d}.${h}.children.${l}`, r, n);
111
126
  });
112
127
  });
113
128
  }));
114
129
  const a = t.richParagraphs;
115
- a !== void 0 && (Array.isArray(a) ? a.forEach((o, d) => {
116
- (!I(o) || !Array.isArray(o.segments)) && r.push({ path: `${e}.richParagraphs.${d}`, message: "段落缺少 segments 数组" });
130
+ a !== void 0 && (Array.isArray(a) ? a.forEach((i, d) => {
131
+ (!I(i) || !Array.isArray(i.segments)) && r.push({ path: `${e}.richParagraphs.${d}`, message: "段落缺少 segments 数组" });
117
132
  }) : r.push({ path: `${e}.richParagraphs`, message: "richParagraphs 应为数组" }));
118
133
  }
119
- function zt(t, e, r, n = []) {
134
+ function Wt(t, e, r, n = []) {
120
135
  if (!I(t)) {
121
136
  r.push({ path: e, message: "页应为对象" });
122
137
  return;
123
138
  }
124
- const i = t.pageWidthMm, s = t.pageHeightMm;
125
- (typeof i != "number" || !(i > 0 && i < 3e3)) && r.push({ path: `${e}.pageWidthMm`, message: `页宽非法: ${JSON.stringify(i)}` }), (typeof s != "number" || !(s > 0 && s < 5e3)) && r.push({ path: `${e}.pageHeightMm`, message: `页高非法: ${JSON.stringify(s)}` });
139
+ const o = t.pageWidthMm, s = t.pageHeightMm;
140
+ (typeof o != "number" || !(o > 0 && o < 3e3)) && r.push({ path: `${e}.pageWidthMm`, message: `页宽非法: ${JSON.stringify(o)}` }), (typeof s != "number" || !(s > 0 && s < 5e3)) && r.push({ path: `${e}.pageHeightMm`, message: `页高非法: ${JSON.stringify(s)}` });
126
141
  const a = t.components;
127
142
  a !== void 0 && !Array.isArray(a) ? r.push({ path: `${e}.components`, message: "components 应为数组" }) : Array.isArray(a) && a.forEach(
128
- (o, d) => bt(o, `${e}.components.${d}`, r, n)
143
+ (i, d) => bt(i, `${e}.components.${d}`, r, n)
129
144
  );
130
145
  }
131
- function _t(t) {
146
+ function It(t) {
132
147
  const e = [], r = [], n = I(t) ? t.pages : void 0;
133
148
  if (!Array.isArray(n))
134
149
  e.push({
@@ -136,30 +151,30 @@ function _t(t) {
136
151
  message: t == null ? "渲染计划为空" : "渲染计划缺少 pages 数组"
137
152
  });
138
153
  else {
139
- n.forEach((s, a) => zt(s, `$.pages.${a}`, e, r)), n.length > 2e3 && r.push({
154
+ n.forEach((s, a) => Wt(s, `$.pages.${a}`, e, r)), n.length > 2e3 && r.push({
140
155
  path: "$.pages",
141
156
  message: `页数异常大(${n.length} 页),渲染与打印耗时可能显著增加`
142
157
  });
143
- const i = n.reduce(
158
+ const o = n.reduce(
144
159
  (s, a) => s + (I(a) && Array.isArray(a.components) ? a.components.length : 0),
145
160
  0
146
161
  );
147
- i > 5e4 && r.push({
162
+ o > 5e4 && r.push({
148
163
  path: "$.pages",
149
- message: `组件总数异常大(${i} 个),可能触发浏览器性能限制`
164
+ message: `组件总数异常大(${o} 个),可能触发浏览器性能限制`
150
165
  });
151
166
  }
152
167
  return { ok: e.length === 0, errors: e, warnings: r };
153
168
  }
154
- function oe(t) {
155
- const e = _t(t);
169
+ function le(t) {
170
+ const e = It(t);
156
171
  if (!e.ok) {
157
172
  const r = e.errors.slice(0, 3).map((n) => `${n.path}: ${n.message}`).join("; ");
158
173
  throw new Error(`渲染计划校验失败(${e.errors.length} 处): ${r}`);
159
174
  }
160
175
  return t.pages;
161
176
  }
162
- function gt(t) {
177
+ function mt(t) {
163
178
  return {
164
179
  widthMm: t.widthMm,
165
180
  heightMm: t.heightMm,
@@ -170,14 +185,14 @@ function gt(t) {
170
185
  components: []
171
186
  };
172
187
  }
173
- function Dt(t, e) {
188
+ function jt(t, e) {
174
189
  return e.heightMm - (t.marginBottomMm ?? e.marginBottomMm);
175
190
  }
176
- function Wt(t, e) {
177
- const n = (t.fontSizePt ?? X) * Q * 25.4 / 72, i = (t.paddingMm ?? 1) * 2;
178
- return Math.max(t.rowHeightMm ?? 0, e * n + i);
191
+ function Ot(t, e) {
192
+ const n = (t.fontSizePt ?? X) * Q * 25.4 / 72, o = (t.paddingMm ?? 1) * 2;
193
+ return Math.max(t.rowHeightMm ?? 0, e * n + o);
179
194
  }
180
- function nt(t) {
195
+ function yt(t) {
181
196
  if (t == null) return "";
182
197
  if (typeof t == "string") return t;
183
198
  if (typeof t == "number") return String(t);
@@ -189,8 +204,8 @@ function nt(t) {
189
204
  return String(t);
190
205
  }
191
206
  }
192
- function It(t, e) {
193
- const r = t.fontSizePt ?? X, n = t.paddingMm ?? 1, i = t.columns.map(
207
+ function Gt(t, e) {
208
+ const r = t.fontSizePt ?? X, n = t.paddingMm ?? 1, o = t.columns.map(
194
209
  (l) => l.style ? { align: "left", verticalAlign: "middle", ...l.style } : { align: "left", verticalAlign: "middle" }
195
210
  ), s = t.columns.map(
196
211
  (l) => ({
@@ -200,69 +215,69 @@ function It(t, e) {
200
215
  backgroundColor: t.headerBackgroundColor,
201
216
  ...l.style || {}
202
217
  })
203
- ), a = t.columns.map((l) => l.header), o = a.map(
218
+ ), a = t.columns.map((l) => l.header), i = a.map(
204
219
  (l, f) => Z(
205
220
  l,
206
221
  t.columns[f].widthMm - n * 2,
207
222
  { fontSizePt: r, bold: t.headerBold ?? !0 },
208
223
  e
209
224
  )
210
- ), d = Math.max(...o.map((l) => l.length), 1), c = Wt(t, d), h = a.map((l, f) => ({
225
+ ), d = Math.max(...i.map((l) => l.length), 1), c = Ot(t, d), h = a.map((l, f) => ({
211
226
  text: l,
212
227
  style: s[f]
213
- })), g = t.border === !1 ? { borderTop: !1, borderRight: !1, borderBottom: !1, borderLeft: !1 } : { borderBottom: !0, borderLeft: !0, borderRight: !0, borderTop: !0 };
228
+ })), m = t.border === !1 ? { borderTop: !1, borderRight: !1, borderBottom: !1, borderLeft: !1 } : { borderBottom: !0, borderLeft: !0, borderRight: !0, borderTop: !0 };
214
229
  return {
215
230
  fontSizePt: r,
216
231
  paddingMm: n,
217
- cellStyles: i,
218
- borderStyle: g,
232
+ cellStyles: o,
233
+ borderStyle: m,
219
234
  headerHeightMm: c,
220
235
  headerGrid: { cells: [h], rowHeightsMm: [c] },
221
236
  columns: t.columns
222
237
  };
223
238
  }
224
- function mt(t, e, r) {
225
- const n = t.columns, i = new Array(n.length);
239
+ function gt(t, e, r) {
240
+ const n = t.columns, o = new Array(n.length);
226
241
  let s = 1;
227
242
  for (let h = 0; h < n.length; h++) {
228
- const g = n[h];
229
- i[h] = g.format ? Mt(e[g.field], g.format) : nt(e[g.field]);
243
+ const m = n[h];
244
+ o[h] = m.format ? Mt(e[m.field], m.format) : yt(e[m.field]);
230
245
  }
231
246
  const a = new Array(n.length);
232
247
  for (let h = 0; h < n.length; h++) {
233
- const g = Z(
234
- i[h],
248
+ const m = Z(
249
+ o[h],
235
250
  n[h].widthMm - t.paddingMm * 2,
236
251
  { fontSizePt: t.fontSizePt },
237
252
  r
238
253
  );
239
- a[h] = g, g.length > s && (s = g.length);
254
+ a[h] = m, m.length > s && (s = m.length);
240
255
  }
241
- const o = t.fontSizePt * Q * 25.4 / 72, d = Math.max(
256
+ const i = t.fontSizePt * Q * 25.4 / 72, d = Math.max(
242
257
  t.rowHeightFloorMm,
243
- s * o + t.paddingMm * 2
258
+ s * i + t.paddingMm * 2
244
259
  ), c = new Array(n.length);
245
260
  for (let h = 0; h < n.length; h++) {
246
- const g = n[h];
261
+ const m = n[h];
247
262
  let l = t.cellStyles[h];
248
- if (g.rules) {
249
- for (const f of g.rules)
250
- if (Bt(e, f.when)) {
263
+ if (m.rules) {
264
+ for (const f of m.rules)
265
+ if (zt(e, f.when)) {
251
266
  l = { ...l ?? {}, ...f.style };
252
267
  break;
253
268
  }
254
269
  }
255
- c[h] = { text: i[h], style: l };
270
+ c[h] = { text: o[h], style: l };
256
271
  }
257
272
  return { grid: { cells: [c], rowHeightsMm: [d] }, heightMm: d };
258
273
  }
259
- function se(t, e, r = {}) {
260
- const n = typeof r == "number" ? { mmPerRow: r } : r, i = n.mmPerRow ?? 0, s = n.measurer ?? rt, a = [], o = [];
274
+ function de(t, e, r = {}) {
275
+ const n = typeof r == "number" ? { mmPerRow: r } : r, o = n.mmPerRow ?? 0, s = n.measurer ?? ot, a = [], i = [];
261
276
  let d = 0;
262
- const c = (g) => `${g}_${(++d).toString(36)}`, h = [];
263
- for (const g of t.pages) {
264
- const l = gt(g), f = () => Dt(g, l), m = l.marginTopMm, w = [], E = () => {
265
- if (o.push({
277
+ const c = (m) => `${m}_${(++d).toString(36)}`, h = [];
278
+ for (const m of t.pages) {
279
+ const l = mt(m), f = () => jt(m, l), g = l.marginTopMm, w = [], E = () => {
280
+ if (i.push({
266
281
  pageWidthMm: l.widthMm,
267
282
  pageHeightMm: l.heightMm,
268
283
  marginTopMm: l.marginTopMm,
@@ -271,33 +286,33 @@ function se(t, e, r = {}) {
271
286
  marginRightMm: l.marginRightMm,
272
287
  components: l.components
273
288
  }), w.length > 0) {
274
- const T = o.length;
289
+ const x = i.length;
275
290
  for (const b of w) {
276
291
  const C = {
277
292
  ...b,
278
- text: String(b.text ?? "").replace(/\{page\}/g, String(T))
293
+ text: String(b.text ?? "").replace(/\{page\}/g, String(x))
279
294
  };
280
- o[o.length - 1].components.push(C), C.text.includes("{totalPages}") && h.push(C);
295
+ i[i.length - 1].components.push(C), C.text.includes("{totalPages}") && h.push(C);
281
296
  }
282
297
  }
283
298
  };
284
- for (const T of g.components) {
285
- if (T.kind !== "list") {
286
- if (T.kind === "text" && typeof T.text == "string") {
287
- const p = T.text;
299
+ for (const x of m.components) {
300
+ if (x.kind !== "list") {
301
+ if (x.kind === "text" && typeof x.text == "string") {
302
+ const p = x.text;
288
303
  if (p.includes("{page}") || p.includes("{totalPages}")) {
289
- w.push(T);
304
+ w.push(x);
290
305
  continue;
291
306
  }
292
307
  }
293
- l.components.push(T);
308
+ l.components.push(x);
294
309
  continue;
295
310
  }
296
- const b = T, C = e[b.dataset];
311
+ const b = x, C = e[b.dataset];
297
312
  Array.isArray(C) || a.push(`数据集 ${b.dataset} 未提供数据,列表 ${b.id ?? ""} 输出为空`);
298
- const S = Array.isArray(C) ? C : [], J = b.columns.reduce((p, M) => p + M.widthMm, 0), q = J > b.widthMm ? b.widthMm / J : 1, x = q === 1 ? b : { ...b, columns: b.columns.map((p) => ({ ...p, widthMm: p.widthMm * q })) }, $ = {
299
- ...It(x, s),
300
- rowHeightFloorMm: x.rowHeightMm ?? 0
313
+ const S = Array.isArray(C) ? C : [], J = b.columns.reduce((p, M) => p + M.widthMm, 0), q = J > b.widthMm ? b.widthMm / J : 1, k = q === 1 ? b : { ...b, columns: b.columns.map((p) => ({ ...p, widthMm: p.widthMm * q })) }, $ = {
314
+ ...Gt(k, s),
315
+ rowHeightFloorMm: k.rowHeightMm ?? 0
301
316
  }, j = {
302
317
  kind: "rect",
303
318
  leftMm: b.leftMm,
@@ -312,14 +327,14 @@ function se(t, e, r = {}) {
312
327
  const H = (p, M) => {
313
328
  p.components.push({ ...j, topMm: M });
314
329
  };
315
- H(l, u), u += $.headerHeightMm + i;
330
+ H(l, u), u += $.headerHeightMm + o;
316
331
  const L = (p) => {
317
332
  if (u + p > f()) {
318
333
  E();
319
- const M = gt(g);
320
- l.components = M.components, l.heightMm = M.heightMm, x.headerEveryPage !== !1 ? (H(l, b.topMm), u = b.topMm + $.headerHeightMm) : u = m;
334
+ const M = mt(m);
335
+ l.components = M.components, l.heightMm = M.heightMm, k.headerEveryPage !== !1 ? (H(l, b.topMm), u = b.topMm + $.headerHeightMm) : u = g;
321
336
  }
322
- }, y = (p, M, k) => {
337
+ }, y = (p, M, T) => {
323
338
  L(M), l.components.push({
324
339
  kind: "rect",
325
340
  leftMm: b.leftMm,
@@ -327,86 +342,83 @@ function se(t, e, r = {}) {
327
342
  widthMm: b.widthMm,
328
343
  heightMm: M,
329
344
  grid: p,
330
- nid: c(k),
345
+ nid: c(T),
331
346
  style: $.borderStyle
332
347
  }), u += M;
333
- }, R = () => mt($, {}, s).heightMm, P = (p, M, k, v) => {
334
- const B = [], lt = Math.max(1, Math.min(v, x.columns.length));
335
- B.push({ text: p, colSpan: lt, style: { bold: !0, ...k } });
336
- for (let et = lt; et < x.columns.length; et++) {
337
- const Ct = x.columns[et];
338
- B.push({ text: M.get(Ct.field) ?? "", style: k });
348
+ }, N = () => gt($, {}, s).heightMm, P = (p, M, T, v) => {
349
+ const D = [], dt = Math.max(1, Math.min(v, k.columns.length));
350
+ D.push({ text: p, colSpan: dt, style: { bold: !0, ...T } });
351
+ for (let et = dt; et < k.columns.length; et++) {
352
+ const Pt = k.columns[et];
353
+ D.push({ text: M.get(Pt.field) ?? "", style: T });
339
354
  }
340
- const vt = $.fontSizePt * Q * 25.4 / 72, dt = Math.max($.rowHeightFloorMm, vt + $.paddingMm * 2);
341
- return { grid: { cells: [B], rowHeightsMm: [dt] }, heightMm: dt };
342
- }, D = (p, M) => {
343
- let k = 0;
355
+ const Ct = $.fontSizePt * Q * 25.4 / 72, ct = Math.max($.rowHeightFloorMm, Ct + $.paddingMm * 2);
356
+ return { grid: { cells: [D], rowHeightsMm: [ct] }, heightMm: ct };
357
+ }, _ = (p, M) => {
358
+ let T = 0;
344
359
  for (const v of p) {
345
- const B = typeof v[M] == "number" ? v[M] : Number(v[M]);
346
- Number.isFinite(B) && (k += B);
360
+ const D = typeof v[M] == "number" ? v[M] : Number(v[M]);
361
+ Number.isFinite(D) && (T += D);
347
362
  }
348
- return k;
363
+ return T;
349
364
  }, U = (p, M) => {
350
- const k = x.columns.find((v) => v.field === M);
351
- return Mt(D(p, M), k?.format ?? { kind: "number", thousands: !0 });
352
- }, z = x.groupBy, kt = typeof x.grandTotal == "object" && x.grandTotal.fields || z?.subtotal || [], ot = x.columns.findIndex((p) => kt.includes(p.field)), st = ot > 0 ? ot : 1, Y = [];
353
- if (z) {
354
- let p = null, M = [];
355
- const k = () => {
356
- if (M.length === 0) return;
357
- const v = nt(M[0][z.field]);
365
+ const T = k.columns.find((v) => v.field === M);
366
+ return Mt(_(p, M), T?.format ?? { kind: "number", thousands: !0 });
367
+ }, F = k.groupBy, vt = typeof k.grandTotal == "object" && k.grandTotal.fields || F?.subtotal || [], st = k.columns.findIndex((p) => vt.includes(p.field)), at = st > 0 ? st : 1, Y = [];
368
+ if (F) {
369
+ const p = /* @__PURE__ */ new Map();
370
+ for (const M of S) {
371
+ const T = yt(M[F.field]), v = p.get(T);
372
+ v ? v.push(M) : p.set(T, [M]);
373
+ }
374
+ for (const [M, T] of p) {
358
375
  Y.push({
359
376
  kind: "groupHeader",
360
- label: (z.headerTemplate ?? "{value}").replace(/\{value\}/g, v)
377
+ label: (F.headerTemplate ?? "{value}").replace(/\{value\}/g, M)
361
378
  });
362
- for (const B of M) Y.push({ kind: "row", row: B });
363
- z.subtotal && z.subtotal.length > 0 && Y.push({
379
+ for (const v of T) Y.push({ kind: "row", row: v });
380
+ F.subtotal && F.subtotal.length > 0 && Y.push({
364
381
  kind: "subtotal",
365
- label: z.subtotalLabel ?? "小计",
366
- rows: M
382
+ label: F.subtotalLabel ?? "小计",
383
+ rows: T
367
384
  });
368
- };
369
- for (const v of S) {
370
- const B = nt(v[z.field]);
371
- p === null && (p = B), B !== p && (k(), M = [], p = B), M.push(v);
372
385
  }
373
- k();
374
386
  } else
375
387
  for (const p of S) Y.push({ kind: "row", row: p });
376
- const at = R();
388
+ const lt = N();
377
389
  for (const p of Y)
378
390
  if (p.kind === "row") {
379
- const M = mt($, p.row, s);
391
+ const M = gt($, p.row, s);
380
392
  y(M.grid, M.heightMm, "listr");
381
393
  } else if (p.kind === "groupHeader") {
382
394
  const M = P(
383
395
  p.label,
384
396
  /* @__PURE__ */ new Map(),
385
- z?.headerStyle ?? {},
386
- x.columns.length
397
+ F?.headerStyle ?? {},
398
+ k.columns.length
387
399
  );
388
- z?.keepWithNext !== !1 && u + M.heightMm + at > f() && L(M.heightMm + at), y(M.grid, M.heightMm, "listg");
400
+ F?.keepWithNext !== !1 && u + M.heightMm + lt > f() && L(M.heightMm + lt), y(M.grid, M.heightMm, "listg");
389
401
  } else if (p.kind === "subtotal") {
390
402
  const M = /* @__PURE__ */ new Map();
391
- for (const v of z.subtotal ?? []) M.set(v, U(p.rows, v));
392
- const k = P(
403
+ for (const v of F.subtotal ?? []) M.set(v, U(p.rows, v));
404
+ const T = P(
393
405
  p.label,
394
406
  M,
395
- z?.subtotalStyle ?? {},
396
- st
407
+ F?.subtotalStyle ?? {},
408
+ at
397
409
  );
398
- y(k.grid, k.heightMm, "listst");
410
+ y(T.grid, T.heightMm, "listst");
399
411
  }
400
- if (x.grandTotal) {
401
- const p = typeof x.grandTotal == "object" ? x.grandTotal : void 0, M = p?.fields ?? z?.subtotal ?? [];
412
+ if (k.grandTotal) {
413
+ const p = typeof k.grandTotal == "object" ? k.grandTotal : void 0, M = p?.fields ?? F?.subtotal ?? [];
402
414
  if (M.length > 0) {
403
- const k = /* @__PURE__ */ new Map();
404
- for (const B of M) k.set(B, U(S, B));
415
+ const T = /* @__PURE__ */ new Map();
416
+ for (const D of M) T.set(D, U(S, D));
405
417
  const v = P(
406
418
  p?.label ?? "合计",
407
- k,
419
+ T,
408
420
  p?.style ?? {},
409
- st
421
+ at
410
422
  );
411
423
  y(v.grid, v.heightMm, "listgt");
412
424
  } else
@@ -415,16 +427,16 @@ function se(t, e, r = {}) {
415
427
  }
416
428
  E();
417
429
  }
418
- for (const g of h) {
419
- const l = g.text;
420
- typeof l == "string" && l.includes("{totalPages}") && (g.text = l.replace(/\{totalPages\}/g, String(o.length)));
430
+ for (const m of h) {
431
+ const l = m.text;
432
+ typeof l == "string" && l.includes("{totalPages}") && (m.text = l.replace(/\{totalPages\}/g, String(i.length)));
421
433
  }
422
434
  return {
423
- plan: { schemaVersion: Pt, pages: o },
435
+ plan: { schemaVersion: At, pages: i },
424
436
  warnings: a
425
437
  };
426
438
  }
427
- const jt = {
439
+ const Vt = {
428
440
  root: "mr-root",
429
441
  page: "mr-page",
430
442
  comp: "mr-comp",
@@ -441,18 +453,18 @@ const jt = {
441
453
  cell: "mr-cell",
442
454
  unknown: "mr-unknown"
443
455
  };
444
- function F(t, e) {
445
- return e?.classNames?.[t] ?? jt[t];
456
+ function B(t, e) {
457
+ return e?.classNames?.[t] ?? Vt[t];
446
458
  }
447
- class _ {
459
+ class z {
448
460
  constructor() {
449
461
  this.props = [];
450
462
  }
451
463
  add(e, r) {
452
464
  return r == null || r === !1 || r === "" ? this : (this.props.push([e, String(r)]), this);
453
465
  }
454
- mm(e, r, n, i = 2) {
455
- return this.add(e, `${G(Et(r, n), i)}px`);
466
+ mm(e, r, n, o = 2) {
467
+ return this.add(e, `${G($t(r, n), o)}px`);
456
468
  }
457
469
  toString() {
458
470
  let e = "";
@@ -465,228 +477,228 @@ class _ {
465
477
  r && (e.style.cssText = r);
466
478
  }
467
479
  }
468
- function yt(t, e, r) {
480
+ function wt(t, e, r) {
469
481
  const n = e.style || {};
470
482
  t.add("color", n.color).add("background-color", n.backgroundColor).add("font-family", n.fontFamily).add("font-weight", n.bold ? "700" : void 0).add("font-style", n.italic ? "italic" : void 0).add("text-decoration", n.underline ? "underline" : void 0).add("letter-spacing", n.letterSpacing != null ? `${n.letterSpacing}pt` : void 0).add("opacity", n.opacity != null ? String(n.opacity) : void 0).add("transform", n.rotateDeg ? `rotate(${n.rotateDeg}deg)` : void 0);
471
- const i = V(n, r);
472
- t.add("font-size", `${G(i.fontSizePx, 2)}px`);
483
+ const o = V(n, r);
484
+ t.add("font-size", `${G(o.fontSizePx, 2)}px`);
473
485
  }
474
- function Ot(t, e, r, n, i) {
475
- const s = i.createElement("table");
476
- if (s.className = F("grid", n), new _().add("width", "100%").add("height", "100%").add("border-collapse", "collapse").add("table-layout", t.colWidthsMm ? "fixed" : "auto").applyTo(s), t.colWidthsMm) {
477
- const c = i.createElement("colgroup");
486
+ function Yt(t, e, r, n, o) {
487
+ const s = o.createElement("table");
488
+ if (s.className = B("grid", n), new z().add("width", "100%").add("height", "100%").add("border-collapse", "collapse").add("table-layout", t.colWidthsMm ? "fixed" : "auto").applyTo(s), t.colWidthsMm) {
489
+ const c = o.createElement("colgroup");
478
490
  for (const h of t.colWidthsMm) {
479
- const g = i.createElement("col");
480
- new _().mm("width", h, r).applyTo(g), c.appendChild(g);
491
+ const m = o.createElement("col");
492
+ new z().mm("width", h, r).applyTo(m), c.appendChild(m);
481
493
  }
482
494
  s.appendChild(c);
483
495
  }
484
- const a = tt(e.style), o = O(e.style), d = a.inner ? `${G(o.widthPt * r / 72, 2)}px solid ${o.color}` : "";
496
+ const a = tt(e.style), i = O(e.style), d = a.inner ? `${G(i.widthPt * r / 72, 2)}px solid ${i.color}` : "";
485
497
  return t.cells.forEach((c, h) => {
486
- const g = i.createElement("tr");
487
- g.className = F("row", n), t.rowHeightsMm?.[h] != null && new _().mm("height", t.rowHeightsMm[h], r).applyTo(g), (c || []).forEach((l) => {
488
- const f = i.createElement("td");
489
- f.className = F("cell", n), l?.colSpan && (f.colSpan = l.colSpan), l?.rowSpan && (f.rowSpan = l.rowSpan);
490
- const m = new _();
491
- if (d && m.add("border", d), l?.style) {
498
+ const m = o.createElement("tr");
499
+ m.className = B("row", n), t.rowHeightsMm?.[h] != null && new z().mm("height", t.rowHeightsMm[h], r).applyTo(m), (c || []).forEach((l) => {
500
+ const f = o.createElement("td");
501
+ f.className = B("cell", n), l?.colSpan && (f.colSpan = l.colSpan), l?.rowSpan && (f.rowSpan = l.rowSpan);
502
+ const g = new z();
503
+ if (d && g.add("border", d), l?.style) {
492
504
  const w = l.style;
493
- m.add("text-align", w.align).add("vertical-align", w.verticalAlign).add("background-color", w.backgroundColor).add("color", w.color).add("font-weight", w.bold ? "700" : void 0), m.add("font-size", `${G(V(w, r).fontSizePx, 2)}px`);
505
+ g.add("text-align", w.align).add("vertical-align", w.verticalAlign).add("background-color", w.backgroundColor).add("color", w.color).add("font-weight", w.bold ? "700" : void 0), g.add("font-size", `${G(V(w, r).fontSizePx, 2)}px`);
494
506
  }
495
- if (m.applyTo(f), l?.text != null && (f.textContent = l.text), l?.children?.length)
507
+ if (g.applyTo(f), l?.text != null && (f.textContent = l.text), l?.children?.length)
496
508
  for (const w of l.children)
497
- f.appendChild(wt(w, r, n, i));
498
- g.appendChild(f);
499
- }), s.appendChild(g);
509
+ f.appendChild(St(w, r, n, o));
510
+ m.appendChild(f);
511
+ }), s.appendChild(m);
500
512
  }), s;
501
513
  }
502
- function Gt(t, e, r, n) {
503
- const i = n.createElement("div");
504
- i.className = F("text", r);
505
- const s = t.style || {}, a = new _().add("text-align", s.align).add("display", "flex").add("flex-direction", "column").add(
514
+ function Jt(t, e, r, n) {
515
+ const o = n.createElement("div");
516
+ o.className = B("text", r);
517
+ const s = t.style || {}, a = new z().add("text-align", s.align).add("display", "flex").add("flex-direction", "column").add(
506
518
  "justify-content",
507
519
  s.verticalAlign === "middle" ? "center" : s.verticalAlign === "bottom" ? "flex-end" : "flex-start"
508
520
  ).add("overflow", "hidden");
509
- if (yt(a, t, e), a.applyTo(i), ut(t)) {
510
- const o = n.createElement("div");
511
- o.className = F("rich", r);
521
+ if (wt(a, t, e), a.applyTo(o), ut(t)) {
522
+ const i = n.createElement("div");
523
+ i.className = B("rich", r);
512
524
  for (const d of t.richParagraphs) {
513
525
  const c = n.createElement("div");
514
- c.className = F("paragraph", r), new _().add("text-align", d.align).add("line-height", d.lineHeight != null ? String(d.lineHeight) : void 0).mm("margin-top", d.spaceBeforeMm ?? 0, e).mm("margin-bottom", d.spaceAfterMm ?? 0, e).mm("text-indent", d.indentMm ?? 0, e).applyTo(c);
515
- for (const g of d.segments || []) {
526
+ c.className = B("paragraph", r), new z().add("text-align", d.align).add("line-height", d.lineHeight != null ? String(d.lineHeight) : void 0).mm("margin-top", d.spaceBeforeMm ?? 0, e).mm("margin-bottom", d.spaceAfterMm ?? 0, e).mm("text-indent", d.indentMm ?? 0, e).applyTo(c);
527
+ for (const m of d.segments || []) {
516
528
  const l = n.createElement("span");
517
- if (l.className = F("segment", r), l.textContent = g.kind === "field" ? g.field ?? "" : g.text ?? "", g.style) {
518
- const f = new _().add("color", g.style.color).add("font-weight", g.style.bold ? "700" : void 0);
519
- f.add("font-size", `${G(V(g.style, e).fontSizePx, 2)}px`), f.applyTo(l);
529
+ if (l.className = B("segment", r), l.textContent = m.kind === "field" ? m.field ?? "" : m.text ?? "", m.style) {
530
+ const f = new z().add("color", m.style.color).add("font-weight", m.style.bold ? "700" : void 0);
531
+ f.add("font-size", `${G(V(m.style, e).fontSizePx, 2)}px`), f.applyTo(l);
520
532
  }
521
533
  c.appendChild(l);
522
534
  }
523
- o.appendChild(c);
535
+ i.appendChild(c);
524
536
  }
525
- return i.appendChild(o), i;
537
+ return o.appendChild(i), o;
526
538
  }
527
539
  if (Array.isArray(t.lines) && t.lines.length > 0) {
528
- const o = n.createElement("div");
529
- o.className = F("lines", r), s.lineHeight != null && new _().add("line-height", String(s.lineHeight)).applyTo(o);
540
+ const i = n.createElement("div");
541
+ i.className = B("lines", r), s.lineHeight != null && new z().add("line-height", String(s.lineHeight)).applyTo(i);
530
542
  for (const d of t.lines) {
531
543
  const c = n.createElement("div");
532
- c.className = F("line", r), c.textContent = d, o.appendChild(c);
544
+ c.className = B("line", r), c.textContent = d, i.appendChild(c);
533
545
  }
534
- return i.appendChild(o), i;
546
+ return o.appendChild(i), o;
535
547
  }
536
- return i.textContent = t.text ?? "", i;
548
+ return o.textContent = t.text ?? "", o;
537
549
  }
538
- function Vt(t, e, r) {
550
+ function qt(t, e, r) {
539
551
  const n = r.createElement("img");
540
- return n.className = F("image", e), n.src = t.imageData, new _().add("width", "100%").add("height", "100%").add("object-fit", "contain").add("display", "block").applyTo(n), n.alt = t.kind, n;
552
+ return n.className = B("image", e), n.src = t.imageData, new z().add("width", "100%").add("height", "100%").add("object-fit", "contain").add("display", "block").applyTo(n), n.alt = t.kind, n;
541
553
  }
542
554
  function ft(t, e, r, n) {
543
- const i = n.createElement("div");
544
- i.className = F("shape", r);
545
- const s = t.style || {}, a = O(s), o = tt(s), d = `${G(a.widthPt * e / 72, 2)}px solid ${a.color}`, c = new _();
546
- return t.grid || t.kind === "rect" ? (o.top && c.add("border-top", d), o.right && c.add("border-right", d), o.bottom && c.add("border-bottom", d), o.left && c.add("border-left", d)) : t.kind === "ellipse" ? (o.inner && c.add("border", d).add("border-radius", "50%"), s.backgroundColor && c.add("background-color", s.backgroundColor)) : t.kind === "line" && c.add("height", "0").add("border-top", d), c.add("box-sizing", "border-box").add("width", "100%").add("height", "100%"), c.applyTo(i), i;
555
+ const o = n.createElement("div");
556
+ o.className = B("shape", r);
557
+ const s = t.style || {}, a = O(s), i = tt(s), d = `${G(a.widthPt * e / 72, 2)}px solid ${a.color}`, c = new z();
558
+ return t.grid || t.kind === "rect" ? (i.top && c.add("border-top", d), i.right && c.add("border-right", d), i.bottom && c.add("border-bottom", d), i.left && c.add("border-left", d)) : t.kind === "ellipse" ? (i.inner && c.add("border", d).add("border-radius", "50%"), s.backgroundColor && c.add("background-color", s.backgroundColor)) : t.kind === "line" && c.add("height", "0").add("border-top", d), c.add("box-sizing", "border-box").add("width", "100%").add("height", "100%"), c.applyTo(o), o;
547
559
  }
548
- function wt(t, e, r, n) {
549
- const i = n.createElement("div");
550
- i.className = `${F("comp", r)} mr-kind-${t.kind}`;
551
- const s = new _().add("position", "absolute").mm("left", t.leftMm, e).mm("top", t.topMm, e).mm("width", t.widthMm, e).mm("height", t.heightMm, e).add("box-sizing", "border-box");
552
- if (yt(s, t, e), s.applyTo(i), At(t))
553
- return i.appendChild(Vt(t, r, n)), i;
560
+ function St(t, e, r, n) {
561
+ const o = n.createElement("div");
562
+ o.className = `${B("comp", r)} mr-kind-${t.kind}`;
563
+ const s = new z().add("position", "absolute").mm("left", t.leftMm, e).mm("top", t.topMm, e).mm("width", t.widthMm, e).mm("height", t.heightMm, e).add("box-sizing", "border-box");
564
+ if (wt(s, t, e), s.applyTo(o), Et(t))
565
+ return o.appendChild(qt(t, r, n)), o;
554
566
  if (t.kind === "text")
555
- return i.appendChild(Gt(t, e, r, n)), i;
567
+ return o.appendChild(Jt(t, e, r, n)), o;
556
568
  if (t.grid) {
557
- const o = ft(t, e, r, n);
558
- return o.appendChild(Ot(t.grid, t, e, r, n)), i.appendChild(o), i;
569
+ const i = ft(t, e, r, n);
570
+ return i.appendChild(Yt(t.grid, t, e, r, n)), o.appendChild(i), o;
559
571
  }
560
572
  if (t.kind === "line" || t.kind === "rect" || t.kind === "ellipse" || t.kind === "chart")
561
- return i.appendChild(ft(t, e, r, n)), i;
573
+ return o.appendChild(ft(t, e, r, n)), o;
562
574
  const a = n.createElement("div");
563
- return a.className = F("unknown", r), a.textContent = t.fallbackText ?? "", i.appendChild(a), i;
575
+ return a.className = B("unknown", r), a.textContent = t.fallbackText ?? "", o.appendChild(a), o;
564
576
  }
565
- function Yt(t, e, r, n) {
566
- const i = n.createElement("div");
567
- i.className = F("page", r), new _().add("position", "relative").mm("width", t.pageWidthMm, e).mm("height", t.pageHeightMm, e).add("background-color", "#fff").add("overflow", "hidden").add("box-sizing", "border-box").applyTo(i);
577
+ function Ut(t, e, r, n) {
578
+ const o = n.createElement("div");
579
+ o.className = B("page", r), new z().add("position", "relative").mm("width", t.pageWidthMm, e).mm("height", t.pageHeightMm, e).add("background-color", "#fff").add("overflow", "hidden").add("box-sizing", "border-box").applyTo(o);
568
580
  for (const s of t.components)
569
- i.appendChild(wt(s, e, r, n));
570
- return i;
581
+ o.appendChild(St(s, e, r, n));
582
+ return o;
571
583
  }
572
- function ae(t, e, r = {}) {
573
- const n = r.dpi ?? 96, i = e.createElement("div");
574
- return i.className = F("root", r), i.dataset.schemaVersion = t.schemaVersion, t.pages.forEach((s) => {
575
- i.appendChild(Yt(s, n, r, e));
576
- }), i;
584
+ function ce(t, e, r = {}) {
585
+ const n = r.dpi ?? 96, o = e.createElement("div");
586
+ return o.className = B("root", r), o.dataset.schemaVersion = t.schemaVersion, t.pages.forEach((s) => {
587
+ o.appendChild(Ut(s, n, r, e));
588
+ }), o;
577
589
  }
578
- function Jt(t) {
579
- const { pageHeightsPx: e, viewportHeightPx: r, scrollTopPx: n, overscan: i = 1, gapPx: s = 0 } = t, a = e.length;
590
+ function Kt(t) {
591
+ const { pageHeightsPx: e, viewportHeightPx: r, scrollTopPx: n, overscan: o = 1, gapPx: s = 0 } = t, a = e.length;
580
592
  if (a === 0)
581
593
  return { start: 0, end: -1, padTopPx: 0, padBottomPx: 0 };
582
- const o = Math.max(0, s), d = new Array(a + 1);
594
+ const i = Math.max(0, s), d = new Array(a + 1);
583
595
  d[0] = 0;
584
596
  for (let S = 0; S < a; S++)
585
- d[S + 1] = d[S] + Math.max(0, e[S] ?? 0) + o;
597
+ d[S + 1] = d[S] + Math.max(0, e[S] ?? 0) + i;
586
598
  const c = d[a], h = Math.max(0, n);
587
- let g = 0, l = 0, f = a - 1;
599
+ let m = 0, l = 0, f = a - 1;
588
600
  for (; l <= f; ) {
589
601
  const S = l + f >> 1;
590
- d[S] <= h ? (g = S, l = S + 1) : f = S - 1;
602
+ d[S] <= h ? (m = S, l = S + 1) : f = S - 1;
591
603
  }
592
- const m = Math.max(0, Math.min(a - 1, g - i)), w = d[g] + Math.max(0, r);
604
+ const g = Math.max(0, Math.min(a - 1, m - o)), w = d[m] + Math.max(0, r);
593
605
  let E = a - 1;
594
606
  for (l = 0, f = a - 1; l <= f; ) {
595
607
  const S = l + f >> 1;
596
608
  d[S + 1] < w ? l = S + 1 : (E = S, f = S - 1);
597
609
  }
598
- const T = Math.min(a - 1, E + i), b = d[m], C = Math.max(0, c - d[T + 1]);
599
- return { start: m, end: T, padTopPx: b, padBottomPx: C };
610
+ const x = Math.min(a - 1, E + o), b = d[g], C = Math.max(0, c - d[x + 1]);
611
+ return { start: g, end: x, padTopPx: b, padBottomPx: C };
600
612
  }
601
613
  const it = 96 / 25.4;
602
- function St(t, e = 96) {
614
+ function Tt(t, e = 96) {
603
615
  const r = e / 96 * it;
604
616
  return {
605
617
  widthPx: Math.max(1, Math.round(t.pageWidthMm * r)),
606
618
  heightPx: Math.max(1, Math.round(t.pageHeightMm * r))
607
619
  };
608
620
  }
609
- function qt(t, e, r) {
610
- const n = document.createElement("canvas"), { widthPx: i, heightPx: s } = St(t, r);
611
- n.width = Math.round(i * e), n.height = Math.round(s * e), n.style.width = `${i}px`, n.style.height = `${s}px`;
621
+ function Xt(t, e, r) {
622
+ const n = document.createElement("canvas"), { widthPx: o, heightPx: s } = Tt(t, r);
623
+ n.width = Math.round(o * e), n.height = Math.round(s * e), n.style.width = `${o}px`, n.style.height = `${s}px`;
612
624
  const a = n.getContext("2d");
613
625
  if (!a)
614
626
  throw new Error("当前环境不支持 Canvas 2D(测试需真浏览器,见 e2e/canvas.spec.ts)");
615
- return a.scale(e, e), a.fillStyle = "#ffffff", a.fillRect(0, 0, i, s), { canvas: n, ctx: a };
627
+ return a.scale(e, e), a.fillStyle = "#ffffff", a.fillRect(0, 0, o, s), { canvas: n, ctx: a };
616
628
  }
617
- function le(t, e = 96) {
629
+ function he(t, e = 96) {
618
630
  return V(t, e).fontSizePx;
619
631
  }
620
- function Tt(t, e, r, n, i, s, a, o = "top") {
632
+ function xt(t, e, r, n, o, s, a, i = "top") {
621
633
  t.font = `${e.bold ? "bold " : ""}${e.fontSizePx}px ${a}`, t.fillStyle = e.color, t.textBaseline = "alphabetic";
622
634
  const d = e.fontSizePx * e.lineHeight, c = e.text === "" ? [""] : e.text.split(`
623
635
  `), h = c.length * d;
624
- let g = n;
625
- o === "middle" ? g = n + (s - h) / 2 : o === "bottom" && (g = n + s - h), c.forEach((l, f) => {
636
+ let m = n;
637
+ i === "middle" ? m = n + (s - h) / 2 : i === "bottom" && (m = n + s - h), c.forEach((l, f) => {
626
638
  t.textAlign = e.align === "center" ? "center" : e.align === "right" ? "right" : "left";
627
- const m = e.align === "center" ? r + i / 2 : e.align === "right" ? r + i : r;
628
- t.fillText(l, m, g + f * d + e.fontSizePx * 0.8, i);
639
+ const g = e.align === "center" ? r + o / 2 : e.align === "right" ? r + o : r;
640
+ t.fillText(l, g, m + f * d + e.fontSizePx * 0.8, o);
629
641
  }), t.textAlign = "left";
630
642
  }
631
- function Ut(t, e, r, n, i, s, a, o, d, c, h) {
632
- const g = Rt(e, s / o, a / o), l = tt(r.style), f = O(r.style);
633
- for (const m of g.cells) {
634
- const w = m.cell.style?.backgroundColor;
643
+ function Zt(t, e, r, n, o, s, a, i, d, c, h) {
644
+ const m = Rt(e, s / i, a / i), l = tt(r.style), f = O(r.style);
645
+ for (const g of m.cells) {
646
+ const w = g.cell.style?.backgroundColor;
635
647
  w && (t.fillStyle = w, t.fillRect(
636
- n + m.xMm * o,
637
- i + m.yMm * o,
638
- m.widthMm * o,
639
- m.heightMm * o
648
+ n + g.xMm * i,
649
+ o + g.yMm * i,
650
+ g.widthMm * i,
651
+ g.heightMm * i
640
652
  ));
641
653
  }
642
654
  if (l.inner) {
643
655
  t.strokeStyle = f.color, t.lineWidth = K(f.widthPt, d);
644
- for (const m of g.edges)
645
- t.beginPath(), m.kind === "v" ? (t.moveTo(n + m.pos * o, i + m.from * o), t.lineTo(n + m.pos * o, i + m.to * o)) : (t.moveTo(n + m.from * o, i + m.pos * o), t.lineTo(n + m.to * o, i + m.pos * o)), t.stroke();
646
- t.beginPath(), l.top && (t.moveTo(n, i), t.lineTo(n + s, i)), l.right && (t.moveTo(n + s, i), t.lineTo(n + s, i + a)), l.bottom && (t.moveTo(n + s, i + a), t.lineTo(n, i + a)), l.left && (t.moveTo(n, i + a), t.lineTo(n, i)), t.stroke();
656
+ for (const g of m.edges)
657
+ t.beginPath(), g.kind === "v" ? (t.moveTo(n + g.pos * i, o + g.from * i), t.lineTo(n + g.pos * i, o + g.to * i)) : (t.moveTo(n + g.from * i, o + g.pos * i), t.lineTo(n + g.to * i, o + g.pos * i)), t.stroke();
658
+ t.beginPath(), l.top && (t.moveTo(n, o), t.lineTo(n + s, o)), l.right && (t.moveTo(n + s, o), t.lineTo(n + s, o + a)), l.bottom && (t.moveTo(n + s, o + a), t.lineTo(n, o + a)), l.left && (t.moveTo(n, o + a), t.lineTo(n, o)), t.stroke();
647
659
  }
648
- for (const m of g.cells) {
649
- const w = typeof m.cell.text == "string" ? m.cell.text : "";
660
+ for (const g of m.cells) {
661
+ const w = typeof g.cell.text == "string" ? g.cell.text : "";
650
662
  if (!w) continue;
651
- const E = m.cell.style, T = E?.fontSize ?? X, b = Z(
663
+ const E = g.cell.style, x = E?.fontSize ?? X, b = Z(
652
664
  w,
653
- m.widthMm - 1,
654
- { fontSizePt: T },
665
+ g.widthMm - 1,
666
+ { fontSizePt: x },
655
667
  h
656
668
  ).join(`
657
669
  `);
658
- Tt(
670
+ xt(
659
671
  t,
660
672
  {
661
673
  text: b,
662
674
  fontSizePx: V(E, d).fontSizePx,
663
675
  bold: E?.bold ?? !1,
664
- color: E?.color ?? pt(r.style, Ht),
676
+ color: E?.color ?? pt(r.style, Nt),
665
677
  align: E?.align ?? "left",
666
678
  lineHeight: Q
667
679
  },
668
- n + (m.xMm + 0.5) * o,
669
- i + m.yMm * o,
670
- Math.max(0, (m.widthMm - 1) * o),
671
- m.heightMm * o,
680
+ n + (g.xMm + 0.5) * i,
681
+ o + g.yMm * i,
682
+ Math.max(0, (g.widthMm - 1) * i),
683
+ g.heightMm * i,
672
684
  c,
673
685
  E?.verticalAlign ?? "middle"
674
686
  );
675
687
  }
676
688
  }
677
- function xt(t, e, r, n, i, s) {
678
- const a = e.leftMm * r, o = e.topMm * r, d = e.widthMm * r, c = e.heightMm * r, h = e.style ?? {};
689
+ function kt(t, e, r, n, o, s) {
690
+ const a = e.leftMm * r, i = e.topMm * r, d = e.widthMm * r, c = e.heightMm * r, h = e.style ?? {};
679
691
  if (e.grid) {
680
- Ut(t, e.grid, e, a, o, d, c, r, n, i, s);
692
+ Zt(t, e.grid, e, a, i, d, c, r, n, o, s);
681
693
  return;
682
694
  }
683
695
  switch (e.kind) {
684
696
  case "text": {
685
- const g = h.fontSize ?? X, l = ut(e) ? e.richParagraphs.map((f) => (f.segments ?? []).map((m) => m.text ?? m.field ?? "").join("")).join(`
697
+ const m = h.fontSize ?? X, l = ut(e) ? e.richParagraphs.map((f) => (f.segments ?? []).map((g) => g.text ?? g.field ?? "").join("")).join(`
686
698
  `) : Array.isArray(e.lines) && e.lines.length > 0 ? e.lines.join(`
687
- `) : Z(e.text ?? "", e.widthMm, { fontSizePt: g }, s).join(`
699
+ `) : Z(e.text ?? "", e.widthMm, { fontSizePt: m }, s).join(`
688
700
  `);
689
- Tt(
701
+ xt(
690
702
  t,
691
703
  {
692
704
  text: l,
@@ -694,113 +706,113 @@ function xt(t, e, r, n, i, s) {
694
706
  bold: h.bold ?? !1,
695
707
  color: pt(h),
696
708
  align: h.align ?? "left",
697
- lineHeight: $t(h)
709
+ lineHeight: Ht(h)
698
710
  },
699
711
  a,
700
- o,
712
+ i,
701
713
  d,
702
714
  c,
703
- i,
715
+ o,
704
716
  h.verticalAlign
705
717
  );
706
718
  break;
707
719
  }
708
720
  case "rect": {
709
- const g = O(h), l = tt(h);
710
- h.backgroundColor && (t.fillStyle = h.backgroundColor, t.fillRect(a, o, d, c)), l.inner && (t.strokeStyle = g.color, t.lineWidth = K(g.widthPt, n), t.beginPath(), l.top && (t.moveTo(a, o), t.lineTo(a + d, o)), l.right && (t.moveTo(a + d, o), t.lineTo(a + d, o + c)), l.bottom && (t.moveTo(a + d, o + c), t.lineTo(a, o + c)), l.left && (t.moveTo(a, o + c), t.lineTo(a, o)), t.stroke());
721
+ const m = O(h), l = tt(h);
722
+ h.backgroundColor && (t.fillStyle = h.backgroundColor, t.fillRect(a, i, d, c)), l.inner && (t.strokeStyle = m.color, t.lineWidth = K(m.widthPt, n), t.beginPath(), l.top && (t.moveTo(a, i), t.lineTo(a + d, i)), l.right && (t.moveTo(a + d, i), t.lineTo(a + d, i + c)), l.bottom && (t.moveTo(a + d, i + c), t.lineTo(a, i + c)), l.left && (t.moveTo(a, i + c), t.lineTo(a, i)), t.stroke());
711
723
  break;
712
724
  }
713
725
  case "line": {
714
- const g = O({ ...h, borderColor: h.lineColor ?? h.borderColor });
715
- t.strokeStyle = g.color, t.lineWidth = K(g.widthPt, n), t.beginPath(), t.moveTo(a, o + c / 2), t.lineTo(a + d, o + c / 2), t.stroke();
726
+ const m = O({ ...h, borderColor: h.lineColor ?? h.borderColor });
727
+ t.strokeStyle = m.color, t.lineWidth = K(m.widthPt, n), t.beginPath(), t.moveTo(a, i + c / 2), t.lineTo(a + d, i + c / 2), t.stroke();
716
728
  break;
717
729
  }
718
730
  case "ellipse": {
719
- const g = O(h);
720
- t.strokeStyle = g.color, t.lineWidth = K(g.widthPt, n), h.backgroundColor && (t.fillStyle = h.backgroundColor, t.beginPath(), t.ellipse(a + d / 2, o + c / 2, d / 2, c / 2, 0, 0, Math.PI * 2), t.fill()), t.beginPath(), t.ellipse(a + d / 2, o + c / 2, d / 2, c / 2, 0, 0, Math.PI * 2), t.stroke();
731
+ const m = O(h);
732
+ t.strokeStyle = m.color, t.lineWidth = K(m.widthPt, n), h.backgroundColor && (t.fillStyle = h.backgroundColor, t.beginPath(), t.ellipse(a + d / 2, i + c / 2, d / 2, c / 2, 0, 0, Math.PI * 2), t.fill()), t.beginPath(), t.ellipse(a + d / 2, i + c / 2, d / 2, c / 2, 0, 0, Math.PI * 2), t.stroke();
721
733
  break;
722
734
  }
723
735
  }
724
736
  }
725
- function de(t, e = {}) {
737
+ function me(t, e = {}) {
726
738
  if (typeof document > "u")
727
739
  throw new Error("renderPlanToCanvas 需要浏览器环境(SSR 请在客户端钩子中调用)");
728
- const r = e.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), n = e.dpi ?? 96, i = n / 96 * it, s = e.fontFamily ?? '"Microsoft YaHei", sans-serif', a = e.measurer ?? rt, o = Math.max(0, e.start ?? 0), d = Math.min(t.pages.length - 1, e.end ?? t.pages.length - 1), c = [];
729
- for (let h = o; h <= d; h++) {
730
- const g = t.pages[h], { canvas: l, ctx: f } = qt(g, r, n);
731
- for (const m of g.components)
732
- xt(f, m, i, n, s, a);
740
+ const r = e.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), n = e.dpi ?? 96, o = n / 96 * it, s = e.fontFamily ?? '"Microsoft YaHei", sans-serif', a = e.measurer ?? ot, i = Math.max(0, e.start ?? 0), d = Math.min(t.pages.length - 1, e.end ?? t.pages.length - 1), c = [];
741
+ for (let h = i; h <= d; h++) {
742
+ const m = t.pages[h], { canvas: l, ctx: f } = Xt(m, r, n);
743
+ for (const g of m.components)
744
+ kt(f, g, o, n, s, a);
733
745
  c.push(l);
734
746
  }
735
747
  return { canvases: c };
736
748
  }
737
- function ce(t, e = {}) {
738
- const r = e.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), n = e.dpi ?? 96, i = n / 96 * it, s = e.fontFamily ?? '"Microsoft YaHei", sans-serif', a = e.measurer ?? rt, o = e.overscan ?? 1, d = e.gapPx ?? 18, c = e.pagesPerFrame ?? 1, h = t.pages.map((u) => u.pageHeightMm * i), g = Math.max(1, ...t.pages.map((u) => u.pageWidthMm * i)), l = { start: 0, end: -1 };
739
- let f = null, m = null, w = null, E = null, T = [], b = 0, C = [];
749
+ function ge(t, e = {}) {
750
+ const r = e.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), n = e.dpi ?? 96, o = n / 96 * it, s = e.fontFamily ?? '"Microsoft YaHei", sans-serif', a = e.measurer ?? ot, i = e.overscan ?? 1, d = e.gapPx ?? 18, c = e.pagesPerFrame ?? 1, h = t.pages.map((u) => u.pageHeightMm * o), m = Math.max(1, ...t.pages.map((u) => u.pageWidthMm * o)), l = { start: 0, end: -1 };
751
+ let f = null, g = null, w = null, E = null, x = [], b = 0, C = [];
740
752
  function S() {
741
753
  const u = f;
742
- u.innerHTML = "", m = document.createElement("div"), m.style.cssText = `width:${g}px;margin:0 auto;`, w = document.createElement("div"), E = document.createElement("div"), m.appendChild(w), T = [];
743
- const H = Math.min(t.pages.length, 3 + o * 2);
754
+ u.innerHTML = "", g = document.createElement("div"), g.style.cssText = `width:${m}px;margin:0 auto;`, w = document.createElement("div"), E = document.createElement("div"), g.appendChild(w), x = [];
755
+ const H = Math.min(t.pages.length, 3 + i * 2);
744
756
  for (let L = 0; L < H; L++) {
745
757
  const y = document.createElement("div");
746
- y.style.cssText = `margin:0 auto ${d}px;box-shadow:0 2px 8px rgba(0,0,0,.35);background:#fff;`, m.appendChild(y), T.push(y);
758
+ y.style.cssText = `margin:0 auto ${d}px;box-shadow:0 2px 8px rgba(0,0,0,.35);background:#fff;`, g.appendChild(y), x.push(y);
747
759
  }
748
- m.appendChild(E), u.appendChild(m);
760
+ g.appendChild(E), u.appendChild(g);
749
761
  }
750
762
  function J(u, H) {
751
- const L = t.pages[H], { widthPx: y, heightPx: R } = St(L, n);
763
+ const L = t.pages[H], { widthPx: y, heightPx: N } = Tt(L, n);
752
764
  let P = u.firstElementChild;
753
- (!P || P.tagName !== "CANVAS") && (P = document.createElement("canvas"), u.innerHTML = "", u.appendChild(P)), P.width = Math.round(y * r), P.height = Math.round(R * r), P.style.width = `${y}px`, P.style.height = `${R}px`;
754
- const D = P.getContext("2d");
755
- if (D) {
756
- D.setTransform(1, 0, 0, 1, 0, 0), D.scale(r, r), D.fillStyle = "#ffffff", D.fillRect(0, 0, y, R);
765
+ (!P || P.tagName !== "CANVAS") && (P = document.createElement("canvas"), u.innerHTML = "", u.appendChild(P)), P.width = Math.round(y * r), P.height = Math.round(N * r), P.style.width = `${y}px`, P.style.height = `${N}px`;
766
+ const _ = P.getContext("2d");
767
+ if (_) {
768
+ _.setTransform(1, 0, 0, 1, 0, 0), _.scale(r, r), _.fillStyle = "#ffffff", _.fillRect(0, 0, y, N);
757
769
  for (const U of L.components)
758
- xt(D, U, i, n, s, a);
759
- P.dataset.canvasPage = String(H), u.style.height = `${R}px`, u.style.width = `${y}px`;
770
+ kt(_, U, o, n, s, a);
771
+ P.dataset.canvasPage = String(H), u.style.height = `${N}px`, u.style.width = `${y}px`;
760
772
  }
761
773
  }
762
774
  function q(u) {
763
- l.start = u.start, l.end = u.end, w.style.height = `${u.start * d + h.slice(0, u.start).reduce((y, R) => y + R, 0)}px`;
775
+ l.start = u.start, l.end = u.end, w.style.height = `${u.start * d + h.slice(0, u.start).reduce((y, N) => y + N, 0)}px`;
764
776
  const H = t.pages.length - 1 - u.end;
765
- E.style.height = `${H * d + h.slice(u.end + 1).reduce((y, R) => y + R, 0)}px`;
777
+ E.style.height = `${H * d + h.slice(u.end + 1).reduce((y, N) => y + N, 0)}px`;
766
778
  const L = u.end - u.start + 1;
767
- T.forEach((y, R) => {
768
- if (R < L) {
779
+ x.forEach((y, N) => {
780
+ if (N < L) {
769
781
  y.style.display = "";
770
- const P = u.start + R;
782
+ const P = u.start + N;
771
783
  y.style.height = `${h[P] ?? 0}px`;
772
784
  } else
773
785
  y.style.display = "none";
774
786
  }), C = [];
775
787
  for (let y = u.start; y <= u.end; y++) {
776
- const R = T[y - u.start];
777
- if (!R) continue;
778
- R.firstElementChild?.dataset?.canvasPage !== String(y) && C.push(y);
788
+ const N = x[y - u.start];
789
+ if (!N) continue;
790
+ N.firstElementChild?.dataset?.canvasPage !== String(y) && C.push(y);
779
791
  }
780
- x();
792
+ k();
781
793
  }
782
- function x() {
794
+ function k() {
783
795
  b || C.length === 0 || (b = requestAnimationFrame(() => {
784
796
  b = 0;
785
797
  let u = Math.max(1, c);
786
798
  for (; C.length > 0 && u-- > 0; ) {
787
- const H = C.shift(), L = T[H - l.start];
799
+ const H = C.shift(), L = x[H - l.start];
788
800
  L && J(L, H);
789
801
  }
790
- C.length > 0 && x();
802
+ C.length > 0 && k();
791
803
  }));
792
804
  }
793
805
  function $() {
794
806
  b || (b = requestAnimationFrame(() => {
795
807
  b = 0;
796
- const u = f, H = Jt({
808
+ const u = f, H = Kt({
797
809
  pageHeightsPx: h,
798
810
  viewportHeightPx: u.clientHeight,
799
811
  scrollTopPx: u.scrollTop,
800
- overscan: o,
812
+ overscan: i,
801
813
  gapPx: d
802
814
  });
803
- H.start !== l.start || H.end !== l.end ? q(H) : x();
815
+ H.start !== l.start || H.end !== l.end ? q(H) : k();
804
816
  }));
805
817
  }
806
818
  let j = null;
@@ -811,7 +823,7 @@ function ce(t, e = {}) {
811
823
  f = u, S(), u.addEventListener("scroll", $, { passive: !0 }), typeof ResizeObserver < "u" && (j = new ResizeObserver(() => $()), j.observe(u)), $();
812
824
  },
813
825
  destroy() {
814
- b && cancelAnimationFrame(b), b = 0, j?.disconnect(), j = null, f?.removeEventListener("scroll", $), C = [], m?.remove(), f = null;
826
+ b && cancelAnimationFrame(b), b = 0, j?.disconnect(), j = null, f?.removeEventListener("scroll", $), C = [], g?.remove(), f = null;
815
827
  },
816
828
  window() {
817
829
  return { ...l };
@@ -821,61 +833,61 @@ function ce(t, e = {}) {
821
833
  function A(t, e) {
822
834
  return typeof t == "number" && Number.isFinite(t) ? t : e;
823
835
  }
824
- function N(t, e = "") {
836
+ function R(t, e = "") {
825
837
  return typeof t == "string" ? t : e;
826
838
  }
827
839
  function W(t) {
828
840
  return typeof t == "object" && t !== null && !Array.isArray(t);
829
841
  }
830
- function Kt(t) {
842
+ function Qt(t) {
831
843
  return t === "Center" ? "center" : t === "Right" ? "right" : "left";
832
844
  }
833
- function Xt(t) {
845
+ function te(t) {
834
846
  return t === "Center" ? "middle" : t === "Bottom" ? "bottom" : "top";
835
847
  }
836
- function Zt(t) {
837
- const e = parseFloat(N(t.FontSize, "10.5"));
848
+ function ee(t) {
849
+ const e = parseFloat(R(t.FontSize, "10.5"));
838
850
  return {
839
851
  fontSize: Number.isFinite(e) ? e : 10.5,
840
- fontFamily: N(t.FontFamily, "黑体") || void 0,
841
- bold: N(t.FontWeight) === "bold" || void 0,
842
- italic: N(t.FontStyle) === "italic" || void 0,
852
+ fontFamily: R(t.FontFamily, "黑体") || void 0,
853
+ bold: R(t.FontWeight) === "bold" || void 0,
854
+ italic: R(t.FontStyle) === "italic" || void 0,
843
855
  underline: t.Underline === !0 || void 0,
844
- color: N(t.FontColor) || void 0,
845
- backgroundColor: N(t.BackgroundColor) || void 0,
846
- align: Kt(N(t.HorAlignment, "Left")),
847
- verticalAlign: Xt(N(t.VertAlignment, "Top")),
856
+ color: R(t.FontColor) || void 0,
857
+ backgroundColor: R(t.BackgroundColor) || void 0,
858
+ align: Qt(R(t.HorAlignment, "Left")),
859
+ verticalAlign: te(R(t.VertAlignment, "Top")),
848
860
  lineHeight: (() => {
849
- const r = parseFloat(N(t.RowSpace, "1"));
861
+ const r = parseFloat(R(t.RowSpace, "1"));
850
862
  return Number.isFinite(r) && r !== 1 ? r : void 0;
851
863
  })(),
852
- borderColor: N(t.BorderColor) || void 0,
864
+ borderColor: R(t.BorderColor) || void 0,
853
865
  borderTop: t.BorderTop !== !1,
854
866
  borderRight: t.BorderRight !== !1,
855
867
  borderBottom: t.BorderBottom !== !1,
856
868
  borderLeft: t.BorderLeft !== !1
857
869
  };
858
870
  }
859
- function Qt(t, e) {
860
- const r = N(t.uitype), n = {
871
+ function ne(t, e) {
872
+ const r = R(t.uitype), n = {
861
873
  kind: "text",
862
874
  leftMm: A(t.left, 0),
863
875
  topMm: A(t.top, 0),
864
876
  widthMm: A(t.width, 40),
865
877
  heightMm: A(t.height, 8),
866
- nid: N(t.nid) || void 0,
867
- style: Zt(t)
878
+ nid: R(t.nid) || void 0,
879
+ style: ee(t)
868
880
  };
869
881
  switch (r) {
870
882
  case "text": {
871
883
  n.kind = "text";
872
- const i = t.Text ?? t.text ?? t.Value;
873
- n.text = i == null ? "" : String(i);
884
+ const o = t.Text ?? t.text ?? t.Value;
885
+ n.text = o == null ? "" : String(o);
874
886
  const s = t.Lines ?? t.lines;
875
887
  return Array.isArray(s) && (n.lines = s.map((a) => String(a))), n;
876
888
  }
877
889
  case "richtext":
878
- return n.kind = "text", n.text = N(t.Text), e.push(`富文本 ${n.nid ?? ""} 导入为纯文本(版式细节可能损失)`), n;
890
+ return n.kind = "text", n.text = R(t.Text), e.push(`富文本 ${n.nid ?? ""} 导入为纯文本(版式细节可能损失)`), n;
879
891
  case "image":
880
892
  case "barcode":
881
893
  case "qrcode":
@@ -883,13 +895,13 @@ function Qt(t, e) {
883
895
  return n.kind = r === "image" ? "image" : r, n.fallbackText = `[${r}]`, e.push(`图片类组件 ${n.nid ?? ""} 需运行时数据(imageData),已导入为占位`), n;
884
896
  case "table": {
885
897
  n.kind = "rect";
886
- const i = t.Cells ?? t.cells;
887
- if (Array.isArray(i)) {
898
+ const o = t.Cells ?? t.cells;
899
+ if (Array.isArray(o)) {
888
900
  const s = {
889
- cells: i.map(
890
- (a) => Array.isArray(a) ? a.map((o) => ({
891
- text: W(o) ? N(o.Text ?? o.text) : "",
892
- colSpan: W(o) ? A(o.ColSpan, 1) : 1
901
+ cells: o.map(
902
+ (a) => Array.isArray(a) ? a.map((i) => ({
903
+ text: W(i) ? R(i.Text ?? i.text) : "",
904
+ colSpan: W(i) ? A(i.ColSpan, 1) : 1
893
905
  })) : []
894
906
  )
895
907
  };
@@ -901,10 +913,10 @@ function Qt(t, e) {
901
913
  case "subreport":
902
914
  return e.push(`子报表 ${n.nid ?? ""} 暂不支持导入,已跳过`), null;
903
915
  default:
904
- return N(t.ShapeType) === "hline" || r === "hline" || r === "vline" ? (n.kind = "line", n) : r === "rect" || r === "oval" || r === "shape" ? (n.kind = r === "oval" ? "ellipse" : "rect", n) : (e.push(`未知组件类型 ${r},已跳过`), null);
916
+ return R(t.ShapeType) === "hline" || r === "hline" || r === "vline" ? (n.kind = "line", n) : r === "rect" || r === "oval" || r === "shape" ? (n.kind = r === "oval" ? "ellipse" : "rect", n) : (e.push(`未知组件类型 ${r},已跳过`), null);
905
917
  }
906
918
  }
907
- function he(t) {
919
+ function fe(t) {
908
920
  const e = [];
909
921
  let r = null;
910
922
  if (typeof t == "string")
@@ -920,22 +932,22 @@ function he(t) {
920
932
  else W(t) && (r = t);
921
933
  if (!r)
922
934
  return { template: { pages: [] }, warnings: ["content 为空"] };
923
- const n = W(r.GlobalConfig) ? r.GlobalConfig : {}, i = A(n.paperWidthMm, 210), s = A(n.paperHeightMm, 297), a = {
935
+ const n = W(r.GlobalConfig) ? r.GlobalConfig : {}, o = A(n.paperWidthMm, 210), s = A(n.paperHeightMm, 297), a = {
924
936
  top: A(n.marginTop, 10),
925
937
  bottom: A(n.marginBottom, 10),
926
938
  left: A(n.marginLeft, 10),
927
939
  right: A(n.marginRight, 10)
928
- }, o = Array.isArray(r.children) ? r.children.filter((c) => W(c) && N(c.uitype) === "page") : [];
929
- o.length === 0 && e.push("content 中没有 uitype=page 的页节点");
930
- const d = o.map((c) => {
931
- const h = c, g = Array.isArray(h.children) ? h.children : [], l = [];
932
- for (const f of g) {
940
+ }, i = Array.isArray(r.children) ? r.children.filter((c) => W(c) && R(c.uitype) === "page") : [];
941
+ i.length === 0 && e.push("content 中没有 uitype=page 的页节点");
942
+ const d = i.map((c) => {
943
+ const h = c, m = Array.isArray(h.children) ? h.children : [], l = [];
944
+ for (const f of m) {
933
945
  if (!W(f)) continue;
934
- const m = Qt(f, e);
935
- m && l.push(m);
946
+ const g = ne(f, e);
947
+ g && l.push(g);
936
948
  }
937
949
  return {
938
- widthMm: A(h.width, i),
950
+ widthMm: A(h.width, o),
939
951
  heightMm: A(h.DesignHeight, s),
940
952
  marginTopMm: A(h.MarginTop, a.top),
941
953
  marginBottomMm: A(h.MarginBottom, a.bottom),
@@ -945,22 +957,22 @@ function he(t) {
945
957
  };
946
958
  });
947
959
  return d.length === 0 && (e.push("转换结果为空页,已回退一张空白页"), d.push({
948
- widthMm: i,
960
+ widthMm: o,
949
961
  heightMm: s,
950
962
  ...a,
951
963
  components: []
952
964
  })), { template: { pages: d }, warnings: e };
953
965
  }
954
- function te(t, e, r) {
955
- let n, i;
966
+ function re(t, e, r) {
967
+ let n, o;
956
968
  if (typeof t == "string") {
957
- const s = ct[t];
958
- if (!s) throw new Error(`未知纸张预设 "${t}"(可用:${Object.keys(ct).join("/")})`);
959
- n = s.widthMm, i = s.heightMm;
960
- } else typeof t == "number" ? (n = t, i = e ?? 297) : (n = t.widthMm, i = t.heightMm);
961
- return r ? { widthMm: i, heightMm: n } : { widthMm: n, heightMm: i };
969
+ const s = ht[t];
970
+ if (!s) throw new Error(`未知纸张预设 "${t}"(可用:${Object.keys(ht).join("/")})`);
971
+ n = s.widthMm, o = s.heightMm;
972
+ } else typeof t == "number" ? (n = t, o = e ?? 297) : (n = t.widthMm, o = t.heightMm);
973
+ return r ? { widthMm: o, heightMm: n } : { widthMm: n, heightMm: o };
962
974
  }
963
- class ee {
975
+ class oe {
964
976
  constructor() {
965
977
  this.pages = [], this.pending = null;
966
978
  }
@@ -972,14 +984,14 @@ class ee {
972
984
  */
973
985
  page(e = "a4", r = {}, n) {
974
986
  this.collect();
975
- const s = n != null && !("margins" in n) && !("landscape" in n) && ("marginTopMm" in n || "marginBottomMm" in n || "marginLeftMm" in n || "marginRightMm" in n) ? { margins: n } : n ?? {}, { widthMm: a, heightMm: o } = te(
987
+ const s = n != null && !("margins" in n) && !("landscape" in n) && ("marginTopMm" in n || "marginBottomMm" in n || "marginLeftMm" in n || "marginRightMm" in n) ? { margins: n } : n ?? {}, { widthMm: a, heightMm: i } = re(
976
988
  e,
977
989
  typeof r == "number" ? r : void 0,
978
990
  s.landscape
979
991
  ), d = s.margins ?? {};
980
- return this.pending = new ne(this, {
992
+ return this.pending = new ie(this, {
981
993
  widthMm: a,
982
- heightMm: o,
994
+ heightMm: i,
983
995
  marginTopMm: d.marginTopMm ?? 10,
984
996
  marginBottomMm: d.marginBottomMm ?? 10,
985
997
  marginLeftMm: d.marginLeftMm ?? 10,
@@ -995,7 +1007,7 @@ class ee {
995
1007
  return { pages: this.pages };
996
1008
  }
997
1009
  }
998
- class ne {
1010
+ class ie {
999
1011
  constructor(e, r) {
1000
1012
  this.parent = e, this.page = r, this.components = [];
1001
1013
  }
@@ -1010,7 +1022,7 @@ class ne {
1010
1022
  style: n
1011
1023
  }), this;
1012
1024
  }
1013
- list(e, r, n, i = {}) {
1025
+ list(e, r, n, o = {}) {
1014
1026
  return this.components.push({
1015
1027
  kind: "list",
1016
1028
  leftMm: r.leftMm ?? 10,
@@ -1018,20 +1030,20 @@ class ne {
1018
1030
  widthMm: r.widthMm ?? 180,
1019
1031
  dataset: e,
1020
1032
  columns: n,
1021
- ...i
1033
+ ...o
1022
1034
  }), this;
1023
1035
  }
1024
1036
  rect(e, r = {}) {
1025
1037
  return this.components.push({ kind: "rect", ...e, style: r }), this;
1026
1038
  }
1027
- line(e, r, n, i = {}) {
1039
+ line(e, r, n, o = {}) {
1028
1040
  return this.components.push({
1029
1041
  kind: "line",
1030
1042
  leftMm: e,
1031
1043
  topMm: r,
1032
1044
  widthMm: n,
1033
1045
  heightMm: 0.5,
1034
- style: i
1046
+ style: o
1035
1047
  }), this;
1036
1048
  }
1037
1049
  barcode(e, r) {
@@ -1044,11 +1056,11 @@ class ne {
1044
1056
  fallbackText: e
1045
1057
  }), this;
1046
1058
  }
1047
- qrcode(e, r, n, i) {
1059
+ qrcode(e, r, n, o) {
1048
1060
  return this.components.push({
1049
1061
  kind: "qrcode",
1050
1062
  leftMm: n,
1051
- topMm: i,
1063
+ topMm: o,
1052
1064
  widthMm: r,
1053
1065
  heightMm: r,
1054
1066
  fallbackText: e
@@ -1064,61 +1076,63 @@ class ne {
1064
1076
  return this.done().build();
1065
1077
  }
1066
1078
  }
1067
- function ge() {
1068
- return new ee();
1079
+ function ue() {
1080
+ return new oe();
1069
1081
  }
1070
1082
  export {
1071
- ue as CSS_DPI,
1072
- pe as DEFAULT_BORDER_PT,
1083
+ be as CSS_DPI,
1084
+ ye as DEFAULT_BORDER_PT,
1073
1085
  X as DEFAULT_FONT_PT,
1074
- Me as DEFAULT_STROKE_COLOR,
1075
- Ht as DEFAULT_TEXT_COLOR,
1086
+ we as DEFAULT_STROKE_COLOR,
1087
+ Nt as DEFAULT_TEXT_COLOR,
1076
1088
  Q as LINE_HEIGHT,
1077
- be as MM_PER_INCH,
1078
- ct as PAPER_SIZES,
1079
- ne as PageBuilder,
1080
- Pt as RENDER_PLAN_SCHEMA_VERSION,
1081
- ye as SCHEMA_VERSION_JH4J,
1082
- we as SCHEMA_VERSION_LOCAL,
1083
- Se as SCHEMA_VERSION_MACH,
1084
- ee as TemplateBuilder,
1085
- oe as assertRenderPlan,
1086
- Te as charWidthEm,
1087
- F as classOf,
1088
- Jt as computePageWindow,
1089
- xe as createCanvasMeasurer,
1090
- ce as createCanvasPager,
1091
- ke as createHeuristicMeasurer,
1092
- ge as createTemplate,
1093
- Bt as evalStyleRule,
1089
+ Se as MM_PER_INCH,
1090
+ ht as PAPER_SIZES,
1091
+ ie as PageBuilder,
1092
+ At as RENDER_PLAN_SCHEMA_VERSION,
1093
+ Te as SCHEMA_VERSION_JH4J,
1094
+ xe as SCHEMA_VERSION_LOCAL,
1095
+ ke as SCHEMA_VERSION_MACH,
1096
+ oe as TemplateBuilder,
1097
+ le as assertRenderPlan,
1098
+ ve as charWidthEm,
1099
+ B as classOf,
1100
+ Kt as computePageWindow,
1101
+ Ce as createCanvasMeasurer,
1102
+ ge as createCanvasPager,
1103
+ Pe as createHeuristicMeasurer,
1104
+ ue as createTemplate,
1105
+ zt as evalStyleRule,
1094
1106
  Mt as formatValue,
1095
- rt as heuristicMeasurer,
1096
- he as importJh4jTemplateContent,
1097
- At as isImageBackedComponent,
1107
+ ot as heuristicMeasurer,
1108
+ fe as importJh4jTemplateContent,
1109
+ Et as isImageBackedComponent,
1098
1110
  ut as isRichText,
1099
- St as measurePageSizePx,
1100
- ve as measureTextMm,
1101
- Et as mmToPx,
1102
- Ce as mmToPxFactor,
1103
- se as paginateTemplate,
1104
- le as planFontSizePx,
1111
+ Tt as measurePageSizePx,
1112
+ Ae as measureTextMm,
1113
+ $t as mmToPx,
1114
+ Ee as mmToPxFactor,
1115
+ de as paginateTemplate,
1116
+ Bt as parseDateLocal,
1117
+ he as planFontSizePx,
1105
1118
  K as ptToPx,
1106
- Pe as pxToMm,
1107
- wt as renderComponent,
1108
- Yt as renderPage,
1109
- ae as renderPlan,
1110
- de as renderPlanToCanvas,
1119
+ $e as pxToMm,
1120
+ St as renderComponent,
1121
+ Ut as renderPage,
1122
+ ce as renderPlan,
1123
+ me as renderPlanToCanvas,
1111
1124
  tt as resolveBoxBorders,
1112
1125
  V as resolveFontSize,
1113
1126
  Rt as resolveGridLayout,
1114
- $t as resolveLineHeight,
1115
- te as resolvePaper,
1127
+ Ht as resolveLineHeight,
1128
+ re as resolvePaper,
1116
1129
  O as resolveStroke,
1117
1130
  pt as resolveTextColor,
1118
1131
  G as round,
1119
- Ae as toRenderPlan,
1132
+ rt as toNumber,
1133
+ He as toRenderPlan,
1120
1134
  bt as validateComponent,
1121
- zt as validatePage,
1122
- _t as validateRenderPlan,
1135
+ Wt as validatePage,
1136
+ It as validateRenderPlan,
1123
1137
  Z as wrapText
1124
1138
  };