@agile-team/mach-report 2.11.2 → 2.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/README.md +30 -5
  2. package/THIRD_PARTY_NOTICES.md +270 -0
  3. package/dist/{ExcelBindingWizard-LWX6G1A2.js → ExcelBindingWizard-CeAf4QSE.js} +2 -2
  4. package/dist/{ExcelBindingWizard-a4kslPHF.cjs → ExcelBindingWizard-y0mT-AHR.cjs} +1 -1
  5. package/dist/{ReportBatchPanel-B5ClP9tm.js → ReportBatchPanel-CW2HV9I8.js} +1 -1
  6. package/dist/{ReportBatchPanel-Dc-SDkYA.cjs → ReportBatchPanel-Fp1ePFag.cjs} +1 -1
  7. package/dist/ReportPreview-BN6fk7Wz.cjs +6 -0
  8. package/dist/ReportPreview-D2Jkyh1U.js +4243 -0
  9. package/dist/{RuleEditor-C2QsOHOs.cjs → RuleEditor-ChRzNQuF.cjs} +1 -1
  10. package/dist/{RuleEditor-D9wQHrkf.js → RuleEditor-DzAmW5YH.js} +1 -1
  11. package/dist/analytics.d.cts +28 -0
  12. package/dist/analytics.d.ts +28 -0
  13. package/dist/assets-C2U-e-Sz.cjs +4 -0
  14. package/dist/assets-Q0wUwNrV.js +217 -0
  15. package/dist/code-options-BKXXY7NI.js +18 -0
  16. package/dist/code-options-BUTChiZZ.cjs +1 -0
  17. package/dist/codes.cjs +9 -0
  18. package/dist/codes.d.cts +223 -0
  19. package/dist/codes.d.ts +223 -0
  20. package/dist/codes.js +26917 -0
  21. package/dist/config-Bb7RiIO5.cjs +1 -0
  22. package/dist/{config-B612mw0x.js → config-XVwG87IA.js} +4 -0
  23. package/dist/designer.cjs +2 -2
  24. package/dist/designer.d.cts +283 -0
  25. package/dist/designer.d.ts +283 -0
  26. package/dist/designer.js +2852 -2010
  27. package/dist/grid-strokes-Cr7DwUux.cjs +1 -0
  28. package/dist/grid-strokes-DyyG1q_o.js +53 -0
  29. package/dist/index.cjs +7 -7
  30. package/dist/index.d.cts +105 -1
  31. package/dist/index.d.ts +105 -1
  32. package/dist/index.js +488 -439
  33. package/dist/pdf.cjs +76 -59
  34. package/dist/pdf.d.cts +51 -0
  35. package/dist/pdf.d.ts +51 -0
  36. package/dist/pdf.js +32128 -32048
  37. package/dist/{plugin-Cd5G2QQn.js → plugin-D4wizDXB.js} +1 -1
  38. package/dist/{plugin-BDTU4D94.cjs → plugin-DzS6pxTA.cjs} +1 -1
  39. package/dist/record-bindings-By_UKZ2g.cjs +1 -0
  40. package/dist/{list-cell-ClFra1zS.js → record-bindings-D-5jQlTj.js} +67 -44
  41. package/dist/{region-binding-workflow-DhQvu1co.cjs → region-binding-workflow-BzfbxRiR.cjs} +1 -1
  42. package/dist/{region-binding-workflow-CXDmt9Bs.js → region-binding-workflow-CcUq8W2Q.js} +1 -1
  43. package/dist/server/node.d.cts +52 -1
  44. package/dist/server/node.d.ts +52 -1
  45. package/dist/server-node.cjs +1 -1
  46. package/dist/server-node.js +239 -210
  47. package/dist/server.cjs +1 -1
  48. package/dist/server.d.cts +95 -3
  49. package/dist/server.d.ts +95 -3
  50. package/dist/server.js +457 -434
  51. package/dist/style.css +1 -1
  52. package/dist/{template-registry-WNXdkiET.js → template-registry-BjE1VS6g.js} +221 -157
  53. package/dist/template-registry-D3SjENi6.cjs +1 -0
  54. package/dist/template-review-DGwWOoCv.cjs +2 -0
  55. package/dist/{template-review-BdcXSYbx.js → template-review-PgEe_Wr9.js} +792 -666
  56. package/dist/validate-BJ5HIWY8.cjs +1 -0
  57. package/dist/validate-DbgEM1Hh.js +163 -0
  58. package/dist/vue/async.d.cts +125 -2
  59. package/dist/vue/async.d.ts +125 -2
  60. package/dist/vue/index.d.cts +121 -8
  61. package/dist/vue/index.d.ts +121 -8
  62. package/dist/vue-async.cjs +1 -1
  63. package/dist/vue-async.js +3 -3
  64. package/dist/vue.cjs +1 -1
  65. package/dist/vue.js +5 -5
  66. package/dist/{workbook-session-BKOTwcoq.js → workbook-session-BPb3TMnT.js} +1 -1
  67. package/dist/{workbook-session-CLYLhZWu.cjs → workbook-session-DNa2RHNG.cjs} +1 -1
  68. package/dist/worker.cjs +1 -1
  69. package/dist/worker.d.cts +52 -1
  70. package/dist/worker.d.ts +52 -1
  71. package/dist/worker.js +2 -2
  72. package/dist/xlsx.cjs +1 -1
  73. package/dist/xlsx.d.cts +40 -0
  74. package/dist/xlsx.d.ts +40 -0
  75. package/dist/xlsx.js +3 -3
  76. package/package.json +16 -3
  77. package/dist/ReportPreview-DWXROHBP.cjs +0 -6
  78. package/dist/ReportPreview-DiNXhQI0.js +0 -4138
  79. package/dist/assets-Bu6UohJx.cjs +0 -1
  80. package/dist/assets-DegqDNqY.js +0 -160
  81. package/dist/config-BRoLo2oj.cjs +0 -1
  82. package/dist/list-cell-BuYn4tGF.cjs +0 -1
  83. package/dist/template-registry-ukBGlm8N.cjs +0 -1
  84. package/dist/template-review-BXp2oyqg.cjs +0 -1
  85. package/dist/textwrap-CWHyzkBH.cjs +0 -4
  86. package/dist/textwrap-DE1kgcJB.js +0 -110
  87. package/dist/validate-7s0yn6ii.js +0 -148
  88. package/dist/validate-DsRiNw8h.cjs +0 -1
@@ -1,40 +1,40 @@
1
- import { R as Z } from "./render-plan-Ck6koX9L.js";
2
- import { c as Ee } from "./validate-7s0yn6ii.js";
3
- import { g as mt } from "./report-params-B44imUd4.js";
4
- import { e as gt, r as ht, v as pt, a as wt, p as le } from "./template-registry-WNXdkiET.js";
5
- import { a as Se, d as yt } from "./param-validation-BlHHXs6u.js";
6
- import { r as me } from "./grid-geometry-BNptEcMm.js";
7
- import { f as bt, i as vt } from "./number-format-BA_KwrZe.js";
8
- import { c as Mt } from "./task-events-Dpsvf_t2.js";
9
- import { d as $t, v as Fe } from "./dataset-H5pFuQGU.js";
10
- import { c as xt, D as Ie, L as Ae } from "./defaults-DXhiM1ZD.js";
11
- import { h as St, w as ge } from "./textwrap-DE1kgcJB.js";
12
- import { e as W, l as he, b as Tt, t as Oe, d as Ke, f as je, g as kt, h as Pt } from "./list-cell-ClFra1zS.js";
13
- import { d as Ne, b as Rt } from "./computed-Bvk0W15F.js";
14
- import { e as Ct, a as Et } from "./matrix-yZsGnldA.js";
15
- import { f as He, a as Ft, c as It } from "./tree-CqcQ99NM.js";
16
- import { e as K, r as Be } from "./style-CQ1PK8ZB.js";
17
- import { i as At } from "./capabilities-CK_7hizc.js";
18
- function Ot(e, t, r) {
1
+ import { R as ee } from "./render-plan-Ck6koX9L.js";
2
+ import { c as Ke } from "./validate-DbgEM1Hh.js";
3
+ import { g as xt } from "./report-params-B44imUd4.js";
4
+ import { e as St, r as Tt, f as It, v as Pt, R as kt, p as de } from "./template-registry-BjE1VS6g.js";
5
+ import { a as Pe, d as Rt } from "./param-validation-BlHHXs6u.js";
6
+ import { r as pe } from "./grid-geometry-BNptEcMm.js";
7
+ import { f as Et, i as Ct } from "./number-format-BA_KwrZe.js";
8
+ import { c as Ft } from "./task-events-Dpsvf_t2.js";
9
+ import { d as At, v as je } from "./dataset-H5pFuQGU.js";
10
+ import { c as Ot, D as Ne, L as Le } from "./defaults-DXhiM1ZD.js";
11
+ import { w as te, h as He } from "./assets-Q0wUwNrV.js";
12
+ import { R as F, g as Be, b as Kt, i as jt, e as D, l as he, c as Nt, t as We, h as De, f as Ve, j as Lt, k as Ht } from "./record-bindings-D-5jQlTj.js";
13
+ import { d as Ge, b as Bt } from "./computed-Bvk0W15F.js";
14
+ import { e as Wt, a as Dt } from "./matrix-yZsGnldA.js";
15
+ import { f as ze, a as Vt, c as Gt } from "./tree-CqcQ99NM.js";
16
+ import { r as we, b as zt, e as j } from "./style-CQ1PK8ZB.js";
17
+ import { i as Jt } from "./capabilities-CK_7hizc.js";
18
+ function qt(e, t, r) {
19
19
  const n = /* @__PURE__ */ new Set(), o = e.cells.map((a, s) => {
20
- const l = [];
20
+ const c = [];
21
21
  let i = 0;
22
- for (const c of a) {
22
+ for (const l of a) {
23
23
  for (; n.has(`${s}:${i}`); ) i++;
24
- const d = c?.colSpan ?? 1, u = c?.rowSpan ?? 1;
24
+ const d = l?.colSpan ?? 1, u = l?.rowSpan ?? 1;
25
25
  let f = 0;
26
26
  for (let m = i; m < i + d; m++) {
27
27
  t.has(m) && f++;
28
- for (let w = s + 1; w < s + u; w++)
29
- n.add(`${w}:${m}`);
28
+ for (let p = s + 1; p < s + u; p++)
29
+ n.add(`${p}:${m}`);
30
30
  }
31
- f && l.push(c ? { ...c, colSpan: f } : null), i += d;
31
+ f && c.push(l ? { ...l, colSpan: f } : null), i += d;
32
32
  }
33
- return l;
33
+ return c;
34
34
  });
35
35
  return { ...e, cells: o, colWidthsMm: r };
36
36
  }
37
- function Kt(e) {
37
+ function _t(e) {
38
38
  if (!e.columns.some((n) => n.hidden)) return e;
39
39
  const t = /* @__PURE__ */ new Set(), r = e.columns.filter((n, o) => n.hidden ? !1 : (t.add(o), !0));
40
40
  if (!r.length) throw new Error("列表至少需要一列可见列");
@@ -42,7 +42,7 @@ function Kt(e) {
42
42
  ...e,
43
43
  columns: r,
44
44
  ...e.headerGrid ? {
45
- headerGrid: Ot(
45
+ headerGrid: qt(
46
46
  e.headerGrid,
47
47
  t,
48
48
  r.map((n) => n.widthMm)
@@ -50,33 +50,53 @@ function Kt(e) {
50
50
  } : {}
51
51
  };
52
52
  }
53
- function* jt(e) {
53
+ function* Ut(e) {
54
54
  const { page: t } = e;
55
- gt(t.components, t.flow);
55
+ St(t.components, t.flow);
56
56
  let r = 0, n = 0;
57
- for (const o of ht(t.components, t.flow)) {
57
+ for (const o of Tt(t.components, t.flow)) {
58
58
  e.active();
59
- const a = o.band, s = o.components.some((d) => d.kind === "list" && d.cardinality !== "record"), l = s ? 0 : o.components.reduce((d, u) => Math.max(d, u.topMm - a.topMm + (u.kind === "list" ? e.height(u) : u.heightMm)), a.heightMm);
59
+ const a = o.band, s = o.components.some((d) => d.kind === "list" && d.cardinality !== "record"), c = s ? 0 : o.components.reduce((d, u) => Math.max(d, u.topMm - a.topMm + (u.kind === "list" ? e.height(u) : u.heightMm)), a.heightMm);
60
60
  let i = Math.max(e.top(), n + a.topMm - r);
61
- if (!s && l > e.bottom() - e.top() + 1e-3) throw new Error(`静态区域 ${a.componentIds.join(",")} 高度超出单页可用范围`);
62
- !s && i + l > e.bottom() + 1e-3 && (e.nextPage(), yield* e.takePages(), e.active(), i = e.top());
63
- let c = i + l;
61
+ if (!s && c > e.bottom() - e.top() + 1e-3) throw new Error(`静态区域 ${a.componentIds.join(",")} 高度超出单页可用范围`);
62
+ !s && i + c > e.bottom() + 1e-3 && (e.nextPage(), yield* e.takePages(), e.active(), i = e.top());
63
+ let l = i + c;
64
64
  for (const d of o.components) {
65
65
  const u = i + d.topMm - a.topMm;
66
66
  d.kind === "list" ? (yield* e.list(d, u, (f) => {
67
- c = s ? f : Math.max(c, f);
67
+ l = s ? f : Math.max(l, f);
68
68
  }), e.active()) : e.append({ ...d, topMm: u });
69
69
  }
70
- n = c, r = a.topMm + a.heightMm;
70
+ n = l, r = a.topMm + a.heightMm;
71
71
  }
72
72
  }
73
- function Nt(e) {
73
+ function Xt(e) {
74
74
  return !!(e.computed?.length || e.groups?.length || e.groupBy || e.grandTotal || e.rowVisibleWhen || e.matrix || e.tree || e.detail || e.columns.some((t) => t.rules?.length || t.visibleWhen));
75
75
  }
76
- function ee(e) {
77
- return e.pages.some((t) => t.components.some((r) => r.kind === "list" && Nt(r)));
76
+ function re(e) {
77
+ return e.pages.some((t) => t.components.some((r) => r.kind === "list" && Xt(r)));
78
+ }
79
+ const Yt = 512, ke = 256 * 1024;
80
+ function Qt() {
81
+ const e = /* @__PURE__ */ new Map();
82
+ let t = 0, r;
83
+ return (n, o, a, s) => {
84
+ s !== r && (e.clear(), t = 0, r = s);
85
+ const c = JSON.stringify([n, o, a.fontSizePt, a.fontFamily, a.bold, a.italic, a.letterSpacingPt]), i = e.get(c);
86
+ if (i)
87
+ return e.delete(c), e.set(c, i), i.lines.slice();
88
+ const l = te(n, o, a, s), d = c.length + l.reduce((u, f) => u + f.length, 0);
89
+ if (d <= ke) {
90
+ for (; e.size >= Yt || t + d > ke; ) {
91
+ const u = e.keys().next().value;
92
+ t -= e.get(u).units, e.delete(u);
93
+ }
94
+ e.set(c, { lines: l.slice(), units: d }), t += d;
95
+ }
96
+ return l;
97
+ };
78
98
  }
79
- class L extends Error {
99
+ class H extends Error {
80
100
  constructor(t, r) {
81
101
  super(`报表页数超出上限 ${t}(至少 ${r} 页)`), this.limit = t, this.actual = r, this.code = "page-limit", this.name = "PaginatePageLimitError";
82
102
  }
@@ -86,7 +106,98 @@ class V extends Error {
86
106
  super(`报表单元格数量超出上限 ${t}(至少 ${r} 格)`), this.limit = t, this.actual = r, this.code = "cell-limit", this.name = "PaginateCellLimitError";
87
107
  }
88
108
  }
89
- function Ht(e) {
109
+ const Zt = 1e4, Re = 25e4;
110
+ function ye(e) {
111
+ if (e?.aborted) throw e.reason ?? new DOMException("标签生成已取消", "AbortError");
112
+ }
113
+ function Je(e, t, r) {
114
+ const n = typeof e.copies == "object" ? Be(t, e.copies.field, r) : e.copies ?? 1;
115
+ if (typeof n != "number" || !Number.isSafeInteger(n) || n < 1 || n > 1e3) throw new F(`$.datasets.${r.dataset}[${r.rowIndex}]`, "每条记录复制数必须是 1..1000 的数值型整数", r.rowIndex, typeof e.copies == "object" ? e.copies.field : void 0);
116
+ return n;
117
+ }
118
+ function qe(e, t, r) {
119
+ if (e.rowKey === void 0) return;
120
+ const n = Be(t, e.rowKey, r);
121
+ if (typeof n == "string" && n.trim() || typeof n == "number" && Number.isFinite(n)) return n;
122
+ throw new F(`$.datasets.${r.dataset}[${r.rowIndex}].${e.rowKey}`, "业务主键必须是非空字符串或有限数字", r.rowIndex, e.rowKey);
123
+ }
124
+ function er(e) {
125
+ const t = (r) => 1 + (r.grid?.cells.reduce((n, o) => n + 1 + o.length + o.reduce((a, s) => a + (s?.children?.reduce((c, i) => c + t(i), 0) ?? 0), 0), 0) ?? 0);
126
+ return e.pages.reduce((r, n) => r + n.components.reduce((o, a) => o + t(a), 0), 0);
127
+ }
128
+ function tr(e, t, r) {
129
+ const n = e.repeat, o = Object.prototype.hasOwnProperty.call(t, n.dataset) ? t[n.dataset] : void 0;
130
+ if (!Array.isArray(o)) throw new F(`$.datasets.${n.dataset}`, "逐记录标签数据集缺失,应提供对象数组(允许空数组)");
131
+ const a = /* @__PURE__ */ new Set(), s = r.maxPages ?? Zt, c = er(e);
132
+ let i = 0, l = 0;
133
+ for (const [d, u] of o.entries()) {
134
+ if (ye(r.signal), !u || typeof u != "object" || Array.isArray(u)) throw new F(`$.datasets.${n.dataset}[${d}]`, "标签记录应为对象", d);
135
+ const f = { rowIndex: d, dataset: n.dataset }, m = qe(n, u, f);
136
+ if (m !== void 0) {
137
+ const g = JSON.stringify([typeof m, m]);
138
+ if (a.has(g)) throw new F(`$.datasets.${n.dataset}[${d}].${n.rowKey}`, "业务主键重复;请先确认记录来源,避免重复打印标签", d, n.rowKey);
139
+ a.add(g);
140
+ }
141
+ const p = Je(n, u, f);
142
+ if (i += p * e.pages.length, l += p * c, i > s) throw new H(s, i);
143
+ if (l > Re) throw new F("$.repeat", `标签组件总量(含网格行、槽位及嵌套组件)超过安全预算 ${Re},请分批生成`, d);
144
+ }
145
+ return o;
146
+ }
147
+ function rr(e, t, r) {
148
+ if (!e.binding) return e;
149
+ const { binding: n, ...o } = e, a = Kt(n, t.row, t);
150
+ if (e.kind === "image") {
151
+ if (!a) return;
152
+ if (!jt(a)) throw new F(`${r}.binding`, "图片字段只接受 PNG/JPEG base64 data URL;业务 URL 应由宿主安全加载后转换", t.rowIndex, n.field);
153
+ return { ...o, imageData: a };
154
+ }
155
+ return e.kind === "barcode" || e.kind === "qrcode" ? (delete o.imageData, { ...o, code: { ...o.code, value: a }, fallbackText: a }) : (delete o.lines, delete o.richParagraphs, { ...o, text: a });
156
+ }
157
+ function nr(e, t, r) {
158
+ if (e.kind !== "text" || e.grid || e.richParagraphs?.length) return e;
159
+ const n = e.style ?? {}, o = we(n).fontSizePt, a = e.text ?? e.lines?.join(`
160
+ `) ?? "";
161
+ if (a.length > 16384) throw new F(r, "标签文本超过 16384 字符预算,请缩小字段内容", t.rowIndex);
162
+ const s = t.wrapText(a, e.widthMm, { fontSizePt: o, bold: n.bold, italic: n.italic, fontFamily: n.fontFamily, letterSpacingPt: n.letterSpacing }, t.options.measurer ?? He), c = s.length * o * zt(n) * 25.4 / 72;
163
+ if (c > e.heightMm + 0.05) throw new F(r, `标签文字需要约 ${c.toFixed(2)}mm 高,超出 ${e.heightMm}mm;请增大文本区域、减少内容或调整字号`, t.rowIndex, e.binding?.field);
164
+ return { ...e, lines: s };
165
+ }
166
+ function _e(e, t, r) {
167
+ ye(t.options.signal);
168
+ const n = rr(e, t, r);
169
+ if (!n) return;
170
+ let o = n.grid;
171
+ return o && (o = { ...o, cells: o.cells.map((a, s) => a.map((c, i) => c?.children?.length ? { ...c, children: c.children.flatMap((l, d) => {
172
+ const u = _e(l, t, `${r}.grid.cells.${s}.${i}.children.${d}`);
173
+ return u ? [u] : [];
174
+ }) } : c)) }), nr(o === n.grid ? n : { ...n, grid: o }, t, r);
175
+ }
176
+ function or(e, t, r, n, o, a) {
177
+ return {
178
+ ...e,
179
+ components: e.components.flatMap((s, c) => {
180
+ const i = _e(s, r, `$.pages.${t}.components.${c}`);
181
+ return i ? [{ ...i, meta: { ...i.meta, labelSource: { pageIndex: t, componentIndex: c } } }] : [];
182
+ }),
183
+ meta: { ...e.meta, record: { dataset: r.dataset, rowIndex: r.rowIndex, ...a === void 0 ? {} : { rowKey: a }, copyIndex: n, copyCount: o, templatePageIndex: t } }
184
+ };
185
+ }
186
+ function* ar(e, t, r) {
187
+ const n = [];
188
+ if (It(e, n), n.length) throw new F(n[0].path, n[0].message);
189
+ if (!e.repeat) {
190
+ for (const [c, i] of e.pages.entries()) yield { page: i, pageIndex: c };
191
+ return;
192
+ }
193
+ const o = e.repeat, a = tr(e, t, r), s = Qt();
194
+ for (const [c, i] of a.entries()) {
195
+ const l = { row: i, rowIndex: c, dataset: o.dataset, options: r, wrapText: s }, d = Je(o, i, l), u = qe(o, i, l);
196
+ for (let f = 0; f < d; f++) for (const [m, p] of e.pages.entries())
197
+ ye(r.signal), yield { page: or(p, m, l, f, d, u), pageIndex: m };
198
+ }
199
+ }
200
+ function sr(e) {
90
201
  return {
91
202
  widthMm: e.widthMm,
92
203
  heightMm: e.heightMm,
@@ -101,60 +212,60 @@ function Q(e, t) {
101
212
  const r = t.heightMm - (e.layout === "wide" ? t.marginBottomMm : e.marginBottomMm ?? t.marginBottomMm);
102
213
  return e.components.reduce((n, o) => o.kind !== "list" && o.pageAnchor === "footer" ? Math.min(n, o.topMm) : n, r);
103
214
  }
104
- function D(e) {
215
+ function z(e) {
105
216
  return e.components.reduce((t, r) => r.kind !== "list" && r.pageAnchor === "header" ? Math.max(t, r.topMm + r.heightMm) : t, 0);
106
217
  }
107
- function We(e, t) {
218
+ function Ue(e, t) {
108
219
  let r = e.textMetrics.get(t);
109
220
  if (!r) {
110
- const n = Be(t).fontSizePt;
221
+ const n = we(t).fontSizePt;
111
222
  r = {
112
223
  measureOptions: {
113
224
  fontSizePt: n,
114
- fontFamily: t.fontFamily ?? Ie,
225
+ fontFamily: t.fontFamily ?? Ne,
115
226
  italic: t.italic,
116
227
  bold: t.bold,
117
228
  letterSpacingPt: t.letterSpacing
118
229
  },
119
- lineMm: n * (t.lineHeight ?? Ae) * 25.4 / 72
230
+ lineMm: n * (t.lineHeight ?? Le) * 25.4 / 72
120
231
  }, e.textMetrics.set(t, r);
121
232
  }
122
233
  return r;
123
234
  }
124
- function Bt(e) {
235
+ function ir(e) {
125
236
  if (e === null || typeof e == "string" || typeof e == "boolean" || typeof e == "number" && Number.isFinite(e)) return e;
126
237
  }
127
- function pe(e, t) {
128
- const r = e.fontSizePt ?? xt, n = e.paddingMm ?? 1, o = e.columns.map((g) => g.align ?? g.style?.align ?? e.align ?? "left"), a = e.columns.map((g, h) => ({
129
- ...K({
238
+ function be(e, t) {
239
+ const r = e.fontSizePt ?? Ot, n = e.paddingMm ?? 1, o = e.columns.map((g) => g.align ?? g.style?.align ?? e.align ?? "left"), a = e.columns.map((g, h) => ({
240
+ ...j({
130
241
  fontSize: r,
131
242
  verticalAlign: "middle"
132
243
  }, g.style),
133
244
  align: o[h] === "auto" ? "left" : o[h]
134
- })), s = a.map((g, h) => o[h] === "auto" ? { left: g, center: { ...g, align: "center" }, right: { ...g, align: "right" } } : void 0), l = e.columns.map((g, h) => g.rules?.map((v) => {
245
+ })), s = a.map((g, h) => o[h] === "auto" ? { left: g, center: { ...g, align: "center" }, right: { ...g, align: "right" } } : void 0), c = e.columns.map((g, h) => g.rules?.map((v) => {
135
246
  const M = s[h];
136
247
  if (M) return {
137
- left: K(M.left, v.style),
138
- center: K(M.center, v.style),
139
- right: K(M.right, v.style)
248
+ left: j(M.left, v.style),
249
+ center: j(M.center, v.style),
250
+ right: j(M.right, v.style)
140
251
  };
141
- const y = K(a[h], v.style);
252
+ const y = j(a[h], v.style);
142
253
  return { left: y, center: y, right: y };
143
- })), i = e.columns.map((g) => Tt(e, g)), c = e.columns.map((g) => g.header);
254
+ })), i = e.columns.map((g) => Nt(e, g)), l = e.columns.map((g) => g.header);
144
255
  let d = e.rowHeightMm ?? 0;
145
- for (let g = 0; g < c.length; g++) {
146
- const h = i[g], v = Be(h).fontSizePt, M = ge(
147
- c[g],
256
+ for (let g = 0; g < l.length; g++) {
257
+ const h = i[g], v = we(h).fontSizePt, M = te(
258
+ l[g],
148
259
  e.columns[g].widthMm - n * 2,
149
- { fontSizePt: v, fontFamily: h.fontFamily ?? Ie, italic: h.italic, bold: h.bold, letterSpacingPt: h.letterSpacing },
260
+ { fontSizePt: v, fontFamily: h.fontFamily ?? Ne, italic: h.italic, bold: h.bold, letterSpacingPt: h.letterSpacing },
150
261
  t
151
- ), y = v * (h.lineHeight ?? Ae) * 25.4 / 72;
262
+ ), y = v * (h.lineHeight ?? Le) * 25.4 / 72;
152
263
  d = Math.max(d, Math.max(M.length, 1) * y + n * 2);
153
264
  }
154
- const u = c.map((g, h) => ({
265
+ const u = l.map((g, h) => ({
155
266
  text: g,
156
267
  style: i[h]
157
- })), f = e.border === !1 ? { borderTop: !1, borderRight: !1, borderBottom: !1, borderLeft: !1 } : { borderBottom: !0, borderLeft: !0, borderRight: !0, borderTop: !0 }, m = e.columns.map((g) => g.widthMm), w = Wt(e.headerGrid, m, {
268
+ })), f = e.border === !1 ? { borderTop: !1, borderRight: !1, borderBottom: !1, borderLeft: !1 } : { borderBottom: !0, borderLeft: !0, borderRight: !0, borderTop: !0 }, m = e.columns.map((g) => g.widthMm), p = cr(e.headerGrid, m, {
158
269
  cells: [u],
159
270
  colWidthsMm: m,
160
271
  rowHeightsMm: [d],
@@ -165,69 +276,69 @@ function pe(e, t) {
165
276
  paddingMm: n,
166
277
  cellStyles: a,
167
278
  autoStyles: s,
168
- ruleStyles: l,
279
+ ruleStyles: c,
169
280
  textMetrics: /* @__PURE__ */ new WeakMap(),
170
- numberFormats: e.columns.map((g) => Oe(g.format)),
281
+ numberFormats: e.columns.map((g) => We(g.format)),
171
282
  derivedFields: new Set(e.computed?.map((g) => g.field)),
172
283
  borderStyle: f,
173
- headerHeightMm: w.rowHeightsMm.reduce((g, h) => g + h, 0),
174
- headerGrid: w,
284
+ headerHeightMm: p.rowHeightsMm.reduce((g, h) => g + h, 0),
285
+ headerGrid: p,
175
286
  colWidthsMm: m,
176
287
  columns: e.columns
177
288
  };
178
289
  }
179
- function Wt(e, t, r) {
290
+ function cr(e, t, r) {
180
291
  if (!e) return r;
181
292
  if (!e.cells.length) throw new Error("自定义列表表头至少需要一行");
182
293
  const n = e.rowHeightsMm ?? e.cells.map(() => r.rowHeightsMm[0]);
183
294
  if (n.length !== e.cells.length || n.some((o) => !Number.isFinite(o) || o <= 0)) throw new Error("自定义列表表头行高无效");
184
295
  return { ...e, colWidthsMm: t, rowHeightsMm: n };
185
296
  }
186
- function Lt(e, t, r) {
297
+ function lr(e, t, r) {
187
298
  const n = t.format?.kind === "number" || t.format?.kind === "percent";
188
299
  t.valueType !== void 0 ? e.valueType = t.valueType : n && (e.valueType = "number"), t.editable !== void 0 && (e.editable = t.editable), (typeof e.value == "number" || e.value == null) && r !== void 0 && (e.numberFormat = r);
189
300
  }
190
- function z(e, t, r) {
301
+ function J(e, t, r) {
191
302
  const n = e.columns, o = e.tree?.rows.get(t);
192
303
  let a = e.rowHeightFloorMm;
193
304
  const s = new Array(n.length);
194
- for (let l = 0; l < n.length; l++) {
195
- const i = n[l], c = i.visibleWhen && !W(t, i.visibleWhen) ? null : t[i.field], d = e.autoStyles[l] ? Ke(c, i.format, i.semanticRole) : "left";
196
- let u = e.autoStyles[l]?.[d] ?? e.cellStyles[l];
305
+ for (let c = 0; c < n.length; c++) {
306
+ const i = n[c], l = i.visibleWhen && !D(t, i.visibleWhen) ? null : t[i.field], d = e.autoStyles[c] ? De(l, i.format, i.semanticRole) : "left";
307
+ let u = e.autoStyles[c]?.[d] ?? e.cellStyles[c];
197
308
  if (i.rules)
198
309
  for (let M = 0; M < i.rules.length; M++) {
199
310
  const y = i.rules[M];
200
- if (W(t, y.when)) {
201
- u = e.ruleStyles[l][M][d];
311
+ if (D(t, y.when)) {
312
+ u = e.ruleStyles[c][M][d];
202
313
  break;
203
314
  }
204
315
  }
205
- const f = i.format ? je(c, i.format) : he(c), m = Vt(e, i, o);
206
- u = Gt(e, i, u, o);
207
- const w = We(e, u), g = ge(f, Math.max(1, i.widthMm - e.paddingMm * 2 - m), w.measureOptions, r);
208
- a = Math.max(a, g.length * w.lineMm + e.paddingMm * 2);
209
- const h = Bt(c), v = { text: f, style: u };
210
- h !== void 0 && (v.value = h), Lt(v, i, e.numberFormats[l]), Dt(v, i, e, o, m), e.derivedFields.has(i.field) && (v.derived = !0, v.editable = !1), i.visibleWhen && c === null && !W(t, i.visibleWhen) && (v.editable = !1), s[l] = v;
316
+ const f = i.format ? Ve(l, i.format) : he(l), m = dr(e, i, o);
317
+ u = ur(e, i, u, o);
318
+ const p = Ue(e, u), g = te(f, Math.max(1, i.widthMm - e.paddingMm * 2 - m), p.measureOptions, r);
319
+ a = Math.max(a, g.length * p.lineMm + e.paddingMm * 2);
320
+ const h = ir(l), v = { text: f, style: u };
321
+ h !== void 0 && (v.value = h), lr(v, i, e.numberFormats[c]), fr(v, i, e, o, m), e.derivedFields.has(i.field) && (v.derived = !0, v.editable = !1), i.visibleWhen && l === null && !D(t, i.visibleWhen) && (v.editable = !1), s[c] = v;
211
322
  }
212
323
  return {
213
324
  grid: { cells: [s], colWidthsMm: e.colWidthsMm, rowHeightsMm: [a], paddingMm: e.paddingMm },
214
325
  heightMm: a
215
326
  };
216
327
  }
217
- function Vt(e, t, r) {
218
- return !r || t.field !== e.tree.list.tree.labelField ? 0 : kt(e.tree.list, t, r, e.paddingMm);
328
+ function dr(e, t, r) {
329
+ return !r || t.field !== e.tree.list.tree.labelField ? 0 : Lt(e.tree.list, t, r, e.paddingMm);
219
330
  }
220
- function Gt(e, t, r, n) {
331
+ function ur(e, t, r, n) {
221
332
  return !n || t.field !== e.tree.list.tree.labelField || r.align === "left" ? r : { ...r, align: "left" };
222
333
  }
223
- function Dt(e, t, r, n, o = 0) {
224
- n && (o && (e.indentMm = o), Pt(e, t, n, r.tree.list));
334
+ function fr(e, t, r, n, o = 0) {
335
+ n && (o && (e.indentMm = o), Ht(e, t, n, r.tree.list));
225
336
  }
226
- function Le(e) {
337
+ function Xe(e) {
227
338
  if (e != null && typeof e != "string" && typeof e != "boolean" && !(typeof e == "number" && Number.isFinite(e))) throw new Error("分组字段应为有限 JSON 标量");
228
339
  return JSON.stringify([typeof e, e ?? null]);
229
340
  }
230
- function* Ve(e, t, r = 0) {
341
+ function* Ye(e, t, r = 0) {
231
342
  const n = t[r];
232
343
  if (!n) {
233
344
  for (const a of e) yield { kind: "row", row: a };
@@ -235,54 +346,54 @@ function* Ve(e, t, r = 0) {
235
346
  }
236
347
  const o = /* @__PURE__ */ new Map();
237
348
  for (const a of e) {
238
- const s = Le(a[n.field]), l = o.get(s);
239
- l ? l.push(a) : o.set(s, [a]);
349
+ const s = Xe(a[n.field]), c = o.get(s);
350
+ c ? c.push(a) : o.set(s, [a]);
240
351
  }
241
352
  for (const a of o.values())
242
- yield { kind: "groupHeader", label: (n.headerTemplate ?? "{value}").replace(/\{value\}/g, he(a[0][n.field])), firstRow: a[0], group: n, depth: r, rows: a }, yield* Ve(a, t, r + 1), (n.subtotal?.length || n.aggregates?.length) && (yield { kind: "subtotal", label: n.subtotalLabel ?? "小计", rows: a, group: n, depth: r }), yield { kind: "groupEnd", depth: r };
353
+ yield { kind: "groupHeader", label: (n.headerTemplate ?? "{value}").replace(/\{value\}/g, he(a[0][n.field])), firstRow: a[0], group: n, depth: r, rows: a }, yield* Ye(a, t, r + 1), (n.subtotal?.length || n.aggregates?.length) && (yield { kind: "subtotal", label: n.subtotalLabel ?? "小计", rows: a, group: n, depth: r }), yield { kind: "groupEnd", depth: r };
243
354
  }
244
- function Ge(e, t, r, n = []) {
355
+ function Qe(e, t, r, n = []) {
245
356
  const o = [...r.filter((a) => !n.some((s) => s.field === a)).map((a) => ({ field: a, op: "sum" })), ...n];
246
357
  return new Map(o.map((a) => {
247
- const s = e.find((i) => i.field === a.field)?.format ?? { kind: "number", thousands: !0 }, l = Rt(t, { ...a, field: a.valueField ?? a.field });
248
- return [a.field, { text: je(l, s), ...l === null ? {} : { value: l }, ...typeof l == "number" ? { numberFormat: Oe(s) } : {} }];
358
+ const s = e.find((i) => i.field === a.field)?.format ?? { kind: "number", thousands: !0 }, c = Bt(t, { ...a, field: a.valueField ?? a.field });
359
+ return [a.field, { text: Ve(c, s), ...c === null ? {} : { value: c }, ...typeof c == "number" ? { numberFormat: We(s) } : {} }];
249
360
  }));
250
361
  }
251
- function De(e, t) {
362
+ function Ze(e, t) {
252
363
  const r = e.findIndex((n) => t.includes(n.field));
253
364
  return r < 0 ? 1 : r;
254
365
  }
255
366
  function G(e, t, r, n, o, a) {
256
- const s = [], l = Math.max(0, Math.min(a, e.columns.length)), i = K({ fontSize: e.fontSizePt }, o);
257
- l && s.push({ text: r, colSpan: l, style: { bold: !0, ...i } });
258
- for (let f = l; f < e.columns.length; f++) {
259
- const m = e.columns[f], w = n.get(m.field), g = e.autoStyles[f]?.[Ke(w?.value, m.format)] ?? e.cellStyles[f];
260
- s.push({ ...w, text: w?.text ?? "", style: K(g, o) });
367
+ const s = [], c = Math.max(0, Math.min(a, e.columns.length)), i = j({ fontSize: e.fontSizePt }, o);
368
+ c && s.push({ text: r, colSpan: c, style: { bold: !0, ...i } });
369
+ for (let f = c; f < e.columns.length; f++) {
370
+ const m = e.columns[f], p = n.get(m.field), g = e.autoStyles[f]?.[De(p?.value, m.format)] ?? e.cellStyles[f];
371
+ s.push({ ...p, text: p?.text ?? "", style: j(g, o) });
261
372
  }
262
- const c = { text: r, colSpan: e.columns.length, style: { bold: !0, ...i } }, d = l ? [s] : [[c], s], u = d.map((f) => zt(e, f, t));
373
+ const l = { text: r, colSpan: e.columns.length, style: { bold: !0, ...i } }, d = c ? [s] : [[l], s], u = d.map((f) => mr(e, f, t));
263
374
  return {
264
375
  grid: { cells: d, colWidthsMm: e.colWidthsMm, rowHeightsMm: u, paddingMm: e.paddingMm },
265
376
  heightMm: u.reduce((f, m) => f + m, 0)
266
377
  };
267
378
  }
268
- function zt(e, t, r) {
379
+ function mr(e, t, r) {
269
380
  let n = e.rowHeightFloorMm, o = 0;
270
381
  for (const a of t) {
271
382
  let s = 0;
272
- const l = o + (a.colSpan ?? 1);
273
- for (; o < l; o++) s += e.colWidthsMm[o] ?? 0;
274
- const i = We(e, a.style), c = ge(a.text ?? "", s - e.paddingMm * 2, i.measureOptions, r);
275
- n = Math.max(n, c.length * i.lineMm + e.paddingMm * 2);
383
+ const c = o + (a.colSpan ?? 1);
384
+ for (; o < c; o++) s += e.colWidthsMm[o] ?? 0;
385
+ const i = Ue(e, a.style), l = te(a.text ?? "", s - e.paddingMm * 2, i.measureOptions, r);
386
+ n = Math.max(n, l.length * i.lineMm + e.paddingMm * 2);
276
387
  }
277
388
  return n;
278
389
  }
279
- function qt(e, t, r) {
280
- const { templatePage: n, current: o, warnings: a, nextId: s, pushCurrent: l } = r, i = () => Q(n, o), c = Math.max(o.marginTopMm, D(n)), d = n.layout === "wide" ? D(n) : c, u = {
390
+ function gr(e, t, r) {
391
+ const { templatePage: n, current: o, warnings: a, nextId: s, pushCurrent: c } = r, i = () => Q(n, o), l = Math.max(o.marginTopMm, z(n)), d = n.layout === "wide" ? z(n) : l, u = {
281
392
  id: r.tableId,
282
- columnKeys: e.columns.map((p) => p.field),
393
+ columnKeys: e.columns.map((w) => w.field),
283
394
  ...e.layout === void 0 ? {} : { layout: e.layout },
284
395
  ...e.title === void 0 ? {} : { title: e.title }
285
- }, f = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), w = {
396
+ }, f = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), p = {
286
397
  kind: "rect",
287
398
  leftMm: e.leftMm,
288
399
  topMm: 0,
@@ -293,53 +404,53 @@ function qt(e, t, r) {
293
404
  table: { ...u, role: "header", rowIndex: -1 },
294
405
  style: t.borderStyle,
295
406
  ...e.meta ? { meta: e.meta } : {}
296
- }, g = (p) => o.components.push({ ...w, topMm: p });
297
- if (r.flow && e.header !== !1 && t.headerHeightMm > i() - c + 1e-3) throw new Error(`流式列表 ${e.id ?? e.dataset} 的表头高度超出单页可用范围`);
298
- let h = Math.max(r.startTop ?? e.topMm, c);
407
+ }, g = (w) => o.components.push({ ...p, topMm: w });
408
+ if (r.flow && e.header !== !1 && t.headerHeightMm > i() - l + 1e-3) throw new Error(`流式列表 ${e.id ?? e.dataset} 的表头高度超出单页可用范围`);
409
+ let h = Math.max(r.startTop ?? e.topMm, l);
299
410
  e.header !== !1 && (g(h), h += t.headerHeightMm + r.mmPerRow);
300
411
  function v() {
301
- const p = Math.max(r.flow || n.layout === "wide" ? 0 : e.topMm, d);
302
- return (e.header !== !1 && e.headerEveryPage !== !1 ? p + t.headerHeightMm : d) + [...m.values()].reduce((x, k) => x + k.heightMm, 0);
412
+ const w = Math.max(r.flow || n.layout === "wide" ? 0 : e.topMm, d);
413
+ return (e.header !== !1 && e.headerEveryPage !== !1 ? w + t.headerHeightMm : d) + [...m.values()].reduce((x, I) => x + I.heightMm, 0);
303
414
  }
304
415
  function M() {
305
- const p = n.layout === "wide" ? 0 : o.marginBottomMm;
306
- return Math.min(n.heightMm - p, Q(n, o)) - v();
416
+ const w = n.layout === "wide" ? 0 : o.marginBottomMm;
417
+ return Math.min(n.heightMm - w, Q(n, o)) - v();
307
418
  }
308
- function y(p) {
309
- if (h + p <= i()) return;
310
- l(), o.components = [], o.heightMm = n.heightMm, n.layout === "wide" && (o.marginTopMm = 0, o.marginBottomMm = 0);
419
+ function y(w) {
420
+ if (h + w <= i()) return;
421
+ c(), o.components = [], o.heightMm = n.heightMm, n.layout === "wide" && (o.marginTopMm = 0, o.marginBottomMm = 0);
311
422
  const $ = Math.max(r.flow || n.layout === "wide" ? 0 : e.topMm, d);
312
423
  e.header !== !1 && e.headerEveryPage !== !1 ? (g($), h = $ + t.headerHeightMm) : h = d;
313
- for (const x of m.values()) A(x, "listgr", "group-header");
424
+ for (const x of m.values()) O(x, "listgr", "group-header");
314
425
  }
315
- function j(p, $, x, k) {
426
+ function N(w, $, x, I) {
316
427
  const P = M();
317
- if (r.flow && p.heightMm > P + 1e-3) throw new Error(`流式列表 ${e.id ?? e.dataset} 的单行高度超出单页可用范围`);
318
- p.heightMm > P && a.push(`列表 ${e.id ?? e.dataset} 行高 ${p.heightMm.toFixed(2)}mm 超出单页可用高度 ${P.toFixed(2)}mm,预览与打印可能截断内容`), y(p.heightMm), A(p, $, x, k);
428
+ if (r.flow && w.heightMm > P + 1e-3) throw new Error(`流式列表 ${e.id ?? e.dataset} 的单行高度超出单页可用范围`);
429
+ w.heightMm > P && a.push(`列表 ${e.id ?? e.dataset} 行高 ${w.heightMm.toFixed(2)}mm 超出单页可用高度 ${P.toFixed(2)}mm,预览与打印可能截断内容`), y(w.heightMm), O(w, $, x, I);
319
430
  }
320
- function A(p, $, x, k) {
321
- const P = p.table?.id ?? u.id, O = x === "header" ? -1 : f.get(P) ?? 0;
322
- x !== "header" && f.set(P, O + p.grid.cells.length), o.components.push({
431
+ function O(w, $, x, I) {
432
+ const P = w.table?.id ?? u.id, K = x === "header" ? -1 : f.get(P) ?? 0;
433
+ x !== "header" && f.set(P, K + w.grid.cells.length), o.components.push({
323
434
  kind: "rect",
324
435
  leftMm: e.leftMm,
325
436
  topMm: h,
326
437
  widthMm: e.widthMm,
327
- heightMm: p.heightMm,
328
- grid: p.grid,
438
+ heightMm: w.heightMm,
439
+ grid: w.grid,
329
440
  nid: s($),
330
- table: { ...u, ...p.table, role: x, rowIndex: O, ...k ? { source: k } : {} },
441
+ table: { ...u, ...w.table, role: x, rowIndex: K, ...I ? { source: I } : {} },
331
442
  style: t.borderStyle,
332
443
  ...e.meta ? { meta: e.meta } : {}
333
- }), h += p.heightMm;
444
+ }), h += w.heightMm;
334
445
  }
335
- function R(p) {
336
- p <= M() && y(p);
446
+ function k(w) {
447
+ w <= M() && y(w);
337
448
  }
338
- return { keepTogether: R, placeGridRow: j, setGroupHeader: (p, $) => {
339
- $ ? m.set(p, $) : m.delete(p);
449
+ return { keepTogether: k, placeGridRow: N, setGroupHeader: (w, $) => {
450
+ $ ? m.set(w, $) : m.delete(w);
340
451
  }, bottom: () => h };
341
452
  }
342
- function Jt(e, t) {
453
+ function pr(e, t) {
343
454
  if (!e.rowKey) return;
344
455
  const r = t[e.rowKey];
345
456
  if ((typeof r != "string" || !r.trim()) && !(typeof r == "number" && Number.isFinite(r)))
@@ -349,26 +460,26 @@ function Jt(e, t) {
349
460
  if (o !== void 0 && typeof o != "string") throw new Error("来源令牌应为字符串");
350
461
  return { datasetId: e.dataset, rowKey: r, ...n === void 0 ? {} : { revision: n }, ...o === void 0 ? {} : { sourceToken: o } };
351
462
  }
352
- function te(e, t) {
463
+ function ne(e, t) {
353
464
  const r = /* @__PURE__ */ new Map();
354
465
  if (!e.rowKey) return r;
355
466
  const n = /* @__PURE__ */ new Set();
356
467
  for (const o of t) {
357
- const a = Jt(e, o), s = JSON.stringify(a.rowKey);
468
+ const a = pr(e, o), s = JSON.stringify(a.rowKey);
358
469
  if (n.has(s)) throw new Error(`数据集 ${e.dataset} 的业务主键重复:${String(a.rowKey)}`);
359
470
  n.add(s), r.set(o, a);
360
471
  }
361
472
  return r;
362
473
  }
363
- function _t(e, t, r, n, o) {
474
+ function hr(e, t, r, n, o) {
364
475
  if (!e.grandTotal) return;
365
- const a = typeof e.grandTotal == "object" ? e.grandTotal : void 0, s = re(e)[0], l = a?.fields ?? s?.subtotal ?? [], i = a?.aggregates ?? s?.aggregates ?? [];
366
- if (l.length === 0 && i.length === 0) {
476
+ const a = typeof e.grandTotal == "object" ? e.grandTotal : void 0, s = oe(e)[0], c = a?.fields ?? s?.subtotal ?? [], i = a?.aggregates ?? s?.aggregates ?? [];
477
+ if (c.length === 0 && i.length === 0) {
367
478
  n.warnings.push(`列表 ${e.id ?? ""} 配置了 grandTotal 但未提供合计字段(groupBy.subtotal 或 grandTotal.fields)`);
368
479
  return;
369
480
  }
370
- const c = G(r, n.measurer, a?.label ?? "合计", Ge(e.columns, t, l, i), a?.style ?? {}, De(e.columns, [...l, ...i.map((d) => d.field)]));
371
- o.placeGridRow(c, "listgt", "grand-total");
481
+ const l = G(r, n.measurer, a?.label ?? "合计", Qe(e.columns, t, c, i), a?.style ?? {}, Ze(e.columns, [...c, ...i.map((d) => d.field)]));
482
+ o.placeGridRow(l, "listgt", "grand-total");
372
483
  }
373
484
  function q(e) {
374
485
  if (e?.aborted) {
@@ -376,147 +487,147 @@ function q(e) {
376
487
  throw t.name = "AbortError", t;
377
488
  }
378
489
  }
379
- function re(e) {
490
+ function oe(e) {
380
491
  const t = e.groups ?? (e.groupBy ? [e.groupBy] : []);
381
492
  if (t.length > 16) throw new Error("列表最多支持 16 级分组");
382
493
  return t;
383
494
  }
384
- function we(e) {
385
- const t = Kt(e), r = t.columns.reduce((o, a) => o + a.widthMm, 0), n = r > t.widthMm ? t.widthMm / r : 1;
495
+ function ve(e) {
496
+ const t = _t(e), r = t.columns.reduce((o, a) => o + a.widthMm, 0), n = r > t.widthMm ? t.widthMm / r : 1;
386
497
  return n === 1 ? t : { ...t, columns: t.columns.map((o) => ({ ...o, widthMm: o.widthMm * n })) };
387
498
  }
388
- function Ut(e, t, r) {
499
+ function wr(e, t, r) {
389
500
  const n = e.detail;
390
501
  if (!n) return;
391
502
  const o = /* @__PURE__ */ new Set();
392
- for (const c of t) {
393
- const d = ce(c[n.parentKey]);
503
+ for (const l of t) {
504
+ const d = ue(l[n.parentKey]);
394
505
  if (o.has(d)) throw new Error("主从明细的主表关联键重复");
395
506
  o.add(d);
396
507
  }
397
- const a = r.datasets[n.dataset] ?? [], s = /* @__PURE__ */ new Map(), l = [];
398
- for (const c of a) {
399
- const d = c[n.foreignKey];
400
- if (!ze(d) && n.unmatched === "ignore") continue;
401
- const u = ce(d);
508
+ const a = r.datasets[n.dataset] ?? [], s = /* @__PURE__ */ new Map(), c = [];
509
+ for (const l of a) {
510
+ const d = l[n.foreignKey];
511
+ if (!et(d) && n.unmatched === "ignore") continue;
512
+ const u = ue(d);
402
513
  if (!o.has(u)) {
403
514
  if (n.unmatched !== "ignore") throw new Error(`明细数据集 ${n.dataset} 存在未关联的业务键`);
404
515
  continue;
405
516
  }
406
517
  const f = s.get(u);
407
- f ? f.push(c) : s.set(u, [c]), l.push(c);
518
+ f ? f.push(l) : s.set(u, [l]), c.push(l);
408
519
  }
409
- const i = we({ ...e, id: `${e.id ?? e.dataset}:detail`, dataset: n.dataset, rowKey: n.rowKey, revisionField: n.revisionField, sourceTokenField: n.sourceTokenField, computed: void 0, columns: n.columns, headerGrid: void 0, rowHeightMm: n.rowHeightMm ?? e.rowHeightMm, detail: void 0 });
410
- return { list: i, inter: { ...pe(i, r.measurer), rowHeightFloorMm: i.rowHeightMm ?? 0 }, rows: s, sources: te(i, l) };
520
+ const i = ve({ ...e, id: `${e.id ?? e.dataset}:detail`, dataset: n.dataset, rowKey: n.rowKey, revisionField: n.revisionField, sourceTokenField: n.sourceTokenField, computed: void 0, columns: n.columns, headerGrid: void 0, rowHeightMm: n.rowHeightMm ?? e.rowHeightMm, detail: void 0 });
521
+ return { list: i, inter: { ...be(i, r.measurer), rowHeightFloorMm: i.rowHeightMm ?? 0 }, rows: s, sources: ne(i, c) };
411
522
  }
412
- function ze(e) {
523
+ function et(e) {
413
524
  return typeof e == "string" && !!e.trim() || typeof e == "number" && Number.isFinite(e);
414
525
  }
415
- function ce(e) {
416
- if (!ze(e)) throw new Error("主从关联键必须是非空字符串或有限数字");
417
- return Le(e);
526
+ function ue(e) {
527
+ if (!et(e)) throw new Error("主从关联键必须是非空字符串或有限数字");
528
+ return Xe(e);
418
529
  }
419
- function* Yt(e, t, r, n, o) {
530
+ function* yr(e, t, r, n, o) {
420
531
  if (!r) return;
421
- const a = r.rows.get(ce(t[e.detail.parentKey])) ?? [];
532
+ const a = r.rows.get(ue(t[e.detail.parentKey])) ?? [];
422
533
  if (!a.length) return;
423
- const s = { id: `${n.tableId}:detail`, columnKeys: r.list.columns.map((l) => l.field), title: e.detail.label };
534
+ const s = { id: `${n.tableId}:detail`, columnKeys: r.list.columns.map((c) => c.field), title: e.detail.label };
424
535
  e.detail.label && o.placeGridRow({ ...G(r.inter, n.measurer, e.detail.label, /* @__PURE__ */ new Map(), {}, r.list.columns.length), table: s }, "listdl", "group-header"), e.detail.header !== !1 && o.placeGridRow({ grid: r.inter.headerGrid, heightMm: r.inter.headerHeightMm, table: s }, "listdh", "header"), yield* n.takePages();
425
- for (const l of a)
426
- q(n.signal), o.placeGridRow({ ...z(r.inter, l, n.measurer), table: s }, "listdr", "body", r.sources.get(l)), yield* n.takePages();
536
+ for (const c of a)
537
+ q(n.signal), o.placeGridRow({ ...J(r.inter, c, n.measurer), table: s }, "listdr", "body", r.sources.get(c)), yield* n.takePages();
427
538
  }
428
- function Qt(e, t) {
539
+ function br(e, t) {
429
540
  if (!e.matrix) return { list: e, rows: t };
430
541
  if (e.detail || e.groupBy || e.groups?.length || e.grandTotal) throw new Error("矩阵不能同时配置普通分组、总计或主从明细");
431
- const r = Et(t, e.matrix), n = r.columns.map((a, s) => ({ ...a, widthMm: s === 0 ? e.matrix.rowWidthMm ?? 40 : e.matrix.columnWidthMm ?? 28, editable: !1, align: s === 0 ? "center" : "right" })), o = { ...e, columns: n, headerGrid: void 0, rowKey: void 0, revisionField: void 0, sourceTokenField: void 0 };
542
+ const r = Dt(t, e.matrix), n = r.columns.map((a, s) => ({ ...a, widthMm: s === 0 ? e.matrix.rowWidthMm ?? 40 : e.matrix.columnWidthMm ?? 28, editable: !1, align: s === 0 ? "center" : "right" })), o = { ...e, columns: n, headerGrid: void 0, rowKey: void 0, revisionField: void 0, sourceTokenField: void 0 };
432
543
  return e.layout === "wide" && (o.widthMm = n.reduce((a, s) => a + s.widthMm, 0)), { list: o, rows: r.rows };
433
544
  }
434
- function qe(e) {
545
+ function tt(e) {
435
546
  if (e.matrix || e.detail || e.groups?.length || e.groupBy || e.rowVisibleWhen) throw new Error("树形布局不能同时配置普通分组、矩阵、主从或行可见条件");
436
547
  if (e.rowKey && e.rowKey !== e.tree.idField) throw new Error("树形布局的 rowKey 应与 idField 一致");
437
548
  if (!e.columns.some((t) => t.field === e.tree.labelField && !t.hidden)) throw new Error("树形布局需要可见的标签列");
438
- Ft(e.tree, e.computed);
549
+ Vt(e.tree, e.computed);
439
550
  }
440
- function Xt(e, t, r) {
441
- qe(e);
442
- const n = It(t, e.tree, { signal: r.signal, computed: e.computed?.length ? { fields: e.computed, formula: r.formula } : void 0 }), o = { ...e, rowKey: e.tree.idField }, a = te(o, n.entries.map((i) => i.original)), s = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new WeakMap();
551
+ function vr(e, t, r) {
552
+ tt(e);
553
+ const n = Gt(t, e.tree, { signal: r.signal, computed: e.computed?.length ? { fields: e.computed, formula: r.formula } : void 0 }), o = { ...e, rowKey: e.tree.idField }, a = ne(o, n.entries.map((i) => i.original)), s = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new WeakMap();
443
554
  for (const i of n.entries)
444
- s.set(i.row, a.get(i.original)), l.set(i.row, i);
445
- return { list: o, rows: n.rows, sources: s, treeRows: l, totalRows: n.leaves };
555
+ s.set(i.row, a.get(i.original)), c.set(i.row, i);
556
+ return { list: o, rows: n.rows, sources: s, treeRows: c, totalRows: n.leaves };
446
557
  }
447
- function Zt(e, t) {
558
+ function Mr(e, t) {
448
559
  if (e.cardinality === "record") {
449
560
  if (t.length > 1) throw new Error(`单记录区域 ${e.id ?? e.dataset} 仅允许 0 或 1 行数据`);
450
561
  if (e.tree || e.matrix || e.detail || e.groups?.length || e.groupBy || e.grandTotal || e.rowVisibleWhen) throw new Error("单记录区域不能配置树、矩阵、主从、分组、总计或行过滤");
451
562
  if (!t.length) return { list: { ...e, columns: e.columns.map((r) => ({ ...r, editable: !1 })) }, rows: [{}], sources: /* @__PURE__ */ new Map() };
452
563
  }
453
564
  }
454
- function Je(e, t, r) {
565
+ function rt(e, t, r) {
455
566
  const n = r.prepared.get(e);
456
567
  if (n) return n;
457
- const o = Zt(e, t);
568
+ const o = Mr(e, t);
458
569
  if (o)
459
570
  return r.prepared.set(e, o), o;
460
571
  if (e.tree) {
461
- const i = Xt(e, t, r);
572
+ const i = vr(e, t, r);
462
573
  return r.prepared.set(e, i), i;
463
574
  }
464
- let a = e.computed?.length ? Ne(t, { fields: e.computed, signal: r.signal, formula: r.formula }).rows : t;
465
- const s = a === t ? void 0 : new Map(a.map((i, c) => [i, t[c]]));
466
- e.rowVisibleWhen && (a = a.filter((i) => W(i, e.rowVisibleWhen)));
467
- const l = Qt(e, a);
575
+ let a = e.computed?.length ? Ge(t, { fields: e.computed, signal: r.signal, formula: r.formula }).rows : t;
576
+ const s = a === t ? void 0 : new Map(a.map((i, l) => [i, t[l]]));
577
+ e.rowVisibleWhen && (a = a.filter((i) => D(i, e.rowVisibleWhen)));
578
+ const c = br(e, a);
468
579
  if (!e.matrix) {
469
- const i = te(e, s ? a.map((c) => s.get(c)) : a);
470
- l.sources = s ? new Map(a.map((c) => [c, i.get(s.get(c))])) : i;
580
+ const i = ne(e, s ? a.map((l) => s.get(l)) : a);
581
+ c.sources = s ? new Map(a.map((l) => [l, i.get(s.get(l))])) : i;
471
582
  }
472
- return r.prepared.set(e, l), l;
583
+ return r.prepared.set(e, c), c;
473
584
  }
474
- function er(e, t, r, n) {
585
+ function $r(e, t, r, n) {
475
586
  if (!n.flow) return;
476
- const { current: o, templatePage: a } = n, s = Math.max(o.marginTopMm, D(a)), l = Math.max(n.startTop ?? e.topMm, s), i = (e.header === !1 ? 0 : t.headerHeightMm) + (r[0] ? z(t, r[0], n.measurer).heightMm : 0);
477
- l + i <= Q(a, o) + 1e-3 || l <= s + 1e-3 || (n.pushCurrent(), o.components = [], o.heightMm = a.heightMm, a.layout === "wide" && (o.marginTopMm = 0, o.marginBottomMm = 0), n.startTop = Math.max(o.marginTopMm, D(a)));
587
+ const { current: o, templatePage: a } = n, s = Math.max(o.marginTopMm, z(a)), c = Math.max(n.startTop ?? e.topMm, s), i = (e.header === !1 ? 0 : t.headerHeightMm) + (r[0] ? J(t, r[0], n.measurer).heightMm : 0);
588
+ c + i <= Q(a, o) + 1e-3 || c <= s + 1e-3 || (n.pushCurrent(), o.components = [], o.heightMm = a.heightMm, a.layout === "wide" && (o.marginTopMm = 0, o.marginBottomMm = 0), n.startTop = Math.max(o.marginTopMm, z(a)));
478
589
  }
479
- function* tr(e, t, r) {
480
- const n = Je(e, t, r), o = n.rows;
590
+ function* xr(e, t, r) {
591
+ const n = rt(e, t, r), o = n.rows;
481
592
  e = n.list, e.layout === "wide" && (r.current.widthMm = Math.max(r.current.widthMm, e.leftMm + e.widthMm + r.current.marginRightMm));
482
- const a = n.sources ?? te(e, o), s = we(e), l = re(s), i = { ...pe(s, r.measurer), rowHeightFloorMm: s.rowHeightMm ?? 0, ...n.treeRows ? { tree: { list: s, rows: n.treeRows } } : {} };
483
- er(s, i, o, r);
484
- const c = qt(s, i, r), d = Ut(s, o, r);
593
+ const a = n.sources ?? ne(e, o), s = ve(e), c = oe(s), i = { ...be(s, r.measurer), rowHeightFloorMm: s.rowHeightMm ?? 0, ...n.treeRows ? { tree: { list: s, rows: n.treeRows } } : {} };
594
+ $r(s, i, o, r);
595
+ const l = gr(s, i, r), d = wr(s, o, r);
485
596
  let u;
486
- for (const f of Ve(o, l)) {
597
+ for (const f of Ye(o, c)) {
487
598
  if (q(r.signal), f.kind === "row")
488
- c.placeGridRow(u ?? z(i, f.row, r.measurer), "listr", "body", a.get(f.row)), u = void 0, yield* r.takePages(), yield* Yt(s, f.row, d, r, c);
599
+ l.placeGridRow(u ?? J(i, f.row, r.measurer), "listr", "body", a.get(f.row)), u = void 0, yield* r.takePages(), yield* yr(s, f.row, d, r, l);
489
600
  else if (f.kind === "groupHeader") {
490
601
  const m = G(i, r.measurer, f.label, /* @__PURE__ */ new Map(), f.group.headerStyle ?? {}, s.columns.length);
491
- u ??= z(i, f.firstRow, r.measurer);
492
- const w = l.slice(f.depth + 1).reduce((g, h) => g + G(i, r.measurer, (h.headerTemplate ?? "{value}").replace(/\{value\}/g, he(f.firstRow[h.field])), /* @__PURE__ */ new Map(), h.headerStyle ?? {}, s.columns.length).heightMm, 0);
493
- f.group.keepWithNext !== !1 && c.keepTogether(m.heightMm + w + u.heightMm), c.placeGridRow(m, "listg", "group-header"), f.group.repeatHeader && c.setGroupHeader(f.depth, m);
602
+ u ??= J(i, f.firstRow, r.measurer);
603
+ const p = c.slice(f.depth + 1).reduce((g, h) => g + G(i, r.measurer, (h.headerTemplate ?? "{value}").replace(/\{value\}/g, he(f.firstRow[h.field])), /* @__PURE__ */ new Map(), h.headerStyle ?? {}, s.columns.length).heightMm, 0);
604
+ f.group.keepWithNext !== !1 && l.keepTogether(m.heightMm + p + u.heightMm), l.placeGridRow(m, "listg", "group-header"), f.group.repeatHeader && l.setGroupHeader(f.depth, m);
494
605
  } else if (f.kind === "subtotal") {
495
- const m = f.group.subtotal ?? [], w = f.group.aggregates ?? [], g = G(i, r.measurer, f.label, Ge(s.columns, f.rows, m, w), f.group.subtotalStyle ?? {}, De(s.columns, [...m, ...w.map((h) => h.field)]));
496
- c.placeGridRow(g, "listst", "subtotal");
497
- } else c.setGroupHeader(f.depth);
606
+ const m = f.group.subtotal ?? [], p = f.group.aggregates ?? [], g = G(i, r.measurer, f.label, Qe(s.columns, f.rows, m, p), f.group.subtotalStyle ?? {}, Ze(s.columns, [...m, ...p.map((h) => h.field)]));
607
+ l.placeGridRow(g, "listst", "subtotal");
608
+ } else l.setGroupHeader(f.depth);
498
609
  yield* r.takePages();
499
610
  }
500
- _t(s, n.totalRows ?? o, i, r, c), r.finished?.(c.bottom()), yield* r.takePages();
611
+ hr(s, n.totalRows ?? o, i, r, l), r.finished?.(l.bottom()), yield* r.takePages();
501
612
  }
502
- function ne(e) {
613
+ function ae(e) {
503
614
  return e.kind !== "list" && (e.pageAnchor !== void 0 || e.kind === "text" && typeof e.text == "string" && (e.text.includes("{page}") || e.text.includes("{totalPages}")));
504
615
  }
505
- function oe(e, t) {
616
+ function se(e, t) {
506
617
  return {
507
618
  ...e,
508
619
  ...e.text === void 0 ? {} : { text: t(e.text) },
509
620
  ...e.lines ? { lines: e.lines.map(t) } : {},
510
621
  ...e.richParagraphs ? { richParagraphs: e.richParagraphs.map((r) => ({ ...r, segments: r.segments.map((n) => ({ ...n, ...n.text === void 0 ? {} : { text: t(n.text) } })) })) } : {},
511
- ...e.grid ? { grid: { ...e.grid, cells: e.grid.cells.map((r) => r.map((n) => n ? { ...n, ...n.text === void 0 ? {} : { text: t(n.text) }, ...n.children ? { children: n.children.map((o) => oe(o, t)) } : {} } : null)) } } : {}
622
+ ...e.grid ? { grid: { ...e.grid, cells: e.grid.cells.map((r) => r.map((n) => n ? { ...n, ...n.text === void 0 ? {} : { text: t(n.text) }, ...n.children ? { children: n.children.map((o) => se(o, t)) } : {} } : null)) } } : {}
512
623
  };
513
624
  }
514
- function rr(e) {
625
+ function Sr(e) {
515
626
  let t = !1;
516
- for (const r of e.pages) for (const n of r.components) ne(n) && oe(n, (o) => (o.includes("{totalPages}") && (t = !0), o));
627
+ for (const r of e.pages) for (const n of r.components) ae(n) && se(n, (o) => (o.includes("{totalPages}") && (t = !0), o));
517
628
  return t;
518
629
  }
519
- function nr(e, t, r, n, o, a) {
630
+ function Tr(e, t, r, n, o, a) {
520
631
  const s = {
521
632
  pageWidthMm: t.widthMm,
522
633
  pageHeightMm: t.heightMm,
@@ -527,40 +638,40 @@ function nr(e, t, r, n, o, a) {
527
638
  marginRightMm: t.marginRightMm,
528
639
  components: t.components,
529
640
  ...e.meta ? { meta: e.meta } : {}
530
- }, l = (i) => {
531
- const c = i.replace(/\{page\}/g, String(n));
532
- return a === void 0 ? c : c.replace(/\{totalPages\}/g, String(a));
641
+ }, c = (i) => {
642
+ const l = i.replace(/\{page\}/g, String(n));
643
+ return a === void 0 ? l : l.replace(/\{totalPages\}/g, String(a));
533
644
  };
534
- for (const i of r) s.components.push(oe(i, l));
645
+ for (const i of r) s.components.push(se(i, c));
535
646
  if (e.layout === "wide") {
536
- const i = s.components.reduce((c, d) => Math.max(c, d.topMm + d.heightMm), 0);
647
+ const i = s.components.reduce((l, d) => Math.max(l, d.topMm + d.heightMm), 0);
537
648
  s.marginBottomMm = o ? e.marginBottomMm ?? 0 : 0, s.pageHeightMm = Math.max(1, i + s.marginBottomMm);
538
649
  }
539
650
  return s;
540
651
  }
541
- function ye(e) {
542
- return e.cells.reduce((t, r) => t + r.reduce((n, o) => n + (o ? 1 + (o.children?.reduce((a, s) => a + _e(s), 0) ?? 0) : 0), 0), 0);
652
+ function Me(e) {
653
+ return e.cells.reduce((t, r) => t + r.reduce((n, o) => n + (o ? 1 + (o.children?.reduce((a, s) => a + nt(s), 0) ?? 0) : 0), 0), 0);
543
654
  }
544
- function _e(e) {
545
- return e.grid ? ye(e.grid) : 0;
655
+ function nt(e) {
656
+ return e.grid ? Me(e.grid) : 0;
546
657
  }
547
- function be(e) {
658
+ function $e(e) {
548
659
  for (const t of ["maxPages", "maxCells", "knownTotalPages"]) if (e[t] !== void 0 && (!Number.isSafeInteger(e[t]) || e[t] < 1)) throw new RangeError(`${t} 应为正安全整数`);
549
660
  }
550
- function or(e, t) {
551
- const r = Je(e, t.datasets[e.dataset] ?? [], t), n = we(r.list), o = { ...pe(n, t.measurer), rowHeightFloorMm: n.rowHeightMm ?? 0 };
552
- return (n.header === !1 ? 0 : o.headerHeightMm) + r.rows.reduce((a, s) => a + z(o, s, t.measurer).heightMm, 0);
661
+ function Ir(e, t) {
662
+ const r = rt(e, t.datasets[e.dataset] ?? [], t), n = ve(r.list), o = { ...be(n, t.measurer), rowHeightFloorMm: n.rowHeightMm ?? 0 };
663
+ return (n.header === !1 ? 0 : o.headerHeightMm) + r.rows.reduce((a, s) => a + J(o, s, t.measurer).heightMm, 0);
553
664
  }
554
- function* ar(e) {
555
- const { templatePage: t, current: r } = e, n = new Map(t.components.map((a, s) => [a, s])), o = (a, s, l) => {
665
+ function* Pr(e) {
666
+ const { templatePage: t, current: r } = e, n = new Map(t.components.map((a, s) => [a, s])), o = (a, s, c) => {
556
667
  const i = e.datasets[a.dataset];
557
- return Array.isArray(i) || e.warnings.push(`数据集 ${a.dataset} 未提供数据,列表 ${a.id ?? ""} 输出为空`), tr(a, Array.isArray(i) ? i : [], { ...e, tableId: `${e.tableId}:${n.get(a)}`, startTop: s, finished: l, flow: !!t.flow });
668
+ return Array.isArray(i) || e.warnings.push(`数据集 ${a.dataset} 未提供数据,列表 ${a.id ?? ""} 输出为空`), xr(a, Array.isArray(i) ? i : [], { ...e, tableId: `${e.tableId}:${n.get(a)}`, startTop: s, finished: c, flow: !!t.flow });
558
669
  };
559
670
  if (t.flow) {
560
- yield* jt({
671
+ yield* Ut({
561
672
  page: t,
562
673
  active: () => q(e.signal),
563
- top: () => Math.max(r.marginTopMm, D(t)),
674
+ top: () => Math.max(r.marginTopMm, z(t)),
564
675
  bottom: () => Q(t, r),
565
676
  append: (a) => {
566
677
  r.components.push(a);
@@ -569,128 +680,128 @@ function* ar(e) {
569
680
  e.pushCurrent(), r.components = [], r.heightMm = t.heightMm, t.layout === "wide" && (r.marginTopMm = 0, r.marginBottomMm = 0);
570
681
  },
571
682
  takePages: e.takePages,
572
- height: (a) => or(a, e),
683
+ height: (a) => Ir(a, e),
573
684
  list: o
574
685
  });
575
686
  return;
576
687
  }
577
688
  for (const a of t.components)
578
- ne(a) || (a.kind === "list" ? yield* o(a) : r.components.push(a));
689
+ ae(a) || (a.kind === "list" ? yield* o(a) : r.components.push(a));
579
690
  }
580
- function* X(e, t, r, n, o, a = /* @__PURE__ */ new WeakMap()) {
581
- let s = 0, l = 0, i = 0;
582
- const c = (d) => `${d}_${(++s).toString(36)}`;
583
- for (const [d, u] of e.pages.entries()) {
691
+ function* Z(e, t, r, n, o, a = /* @__PURE__ */ new WeakMap()) {
692
+ let s = 0, c = 0, i = 0;
693
+ const l = (d) => `${d}_${(++s).toString(36)}`;
694
+ for (const { pageIndex: d, page: u } of ar(e, t, r)) {
584
695
  q(r.signal);
585
- const f = Ht(u), m = u.components.filter(ne);
586
- let w = [];
696
+ const f = sr(u), m = u.components.filter(ae);
697
+ let p = [];
587
698
  const g = (v = !1) => {
588
- if (q(r.signal), r.maxPages !== void 0 && l >= r.maxPages) throw new L(r.maxPages, l + 1);
589
- if (r.maxCells !== void 0 && (i += [...f.components, ...m].reduce((M, y) => M + _e(y), 0), i > r.maxCells))
699
+ if (q(r.signal), r.maxPages !== void 0 && c >= r.maxPages) throw new H(r.maxPages, c + 1);
700
+ if (r.maxCells !== void 0 && (i += [...f.components, ...m].reduce((M, y) => M + nt(y), 0), i > r.maxCells))
590
701
  throw new V(r.maxCells, i);
591
- w.push(nr(u, f, m, ++l, v, o));
702
+ p.push(Tr(u, f, m, ++c, v, o));
592
703
  }, h = () => {
593
- const v = w;
594
- return w = [], v;
704
+ const v = p;
705
+ return p = [], v;
595
706
  };
596
- yield* ar({
707
+ yield* Pr({
597
708
  templatePage: u,
598
709
  current: f,
599
710
  warnings: n,
600
- nextId: c,
711
+ nextId: l,
601
712
  pushCurrent: g,
602
713
  takePages: h,
603
714
  datasets: t,
604
715
  signal: r.signal,
605
716
  formula: r.formula,
606
717
  prepared: a,
607
- measurer: r.measurer ?? St,
718
+ measurer: r.measurer ?? He,
608
719
  mmPerRow: r.mmPerRow ?? 0,
609
720
  tableId: `table:${d}`
610
721
  }), g(!0), yield* h();
611
722
  }
612
723
  }
613
- function fn(e, t, r = {}) {
614
- be(r);
724
+ function Kn(e, t, r = {}) {
725
+ $e(r);
615
726
  let n = 0;
616
- for (const o of X(e, t, { ...r }, [])) n++;
727
+ for (const o of Z(e, t, { ...r, onWarning: void 0 }, [])) n++;
617
728
  return n;
618
729
  }
619
- function* sr(e, t, r = {}) {
620
- be(r);
621
- const n = rr(e), o = /* @__PURE__ */ new WeakMap();
730
+ function* kr(e, t, r = {}) {
731
+ $e(r);
732
+ const n = Sr(e), o = /* @__PURE__ */ new WeakMap();
622
733
  let a = r.knownTotalPages;
623
734
  if (n && a === void 0) {
624
735
  a = 0;
625
- for (const i of X(e, t, r, [], void 0, o)) a++;
736
+ for (const i of Z(e, t, r, [], void 0, o)) a++;
626
737
  }
627
738
  const s = [];
628
- let l = 0;
629
- for (const i of X(e, t, r, s, a, o)) {
630
- for (; l < s.length; l++) r.onWarning?.(s[l]);
739
+ let c = 0;
740
+ for (const i of Z(e, t, r, s, a, o)) {
741
+ for (; c < s.length; c++) r.onWarning?.(s[c]);
631
742
  yield i;
632
743
  }
633
744
  }
634
- function ve(e, t, r = {}) {
745
+ function xe(e, t, r = {}) {
635
746
  const n = typeof r == "number" ? { mmPerRow: r } : r;
636
- be(n);
637
- const o = [], a = [...X(e, t, n, o, n.knownTotalPages)];
638
- for (const s of a) s.components = s.components.map((l) => ne(l) ? oe(l, (i) => i.replace(/\{totalPages\}/g, String(a.length))) : l);
639
- return o.forEach((s) => n.onWarning?.(s)), { plan: { schemaVersion: Z, ...ee(e) ? { requiresRecalculation: !0 } : {}, pages: a }, warnings: o };
747
+ $e(n);
748
+ const o = [], a = [...Z(e, t, n, o, n.knownTotalPages)];
749
+ for (const s of a) s.components = s.components.map((c) => ae(c) ? se(c, (i) => i.replace(/\{totalPages\}/g, String(a.length))) : c);
750
+ return o.forEach((s) => n.onWarning?.(s)), { plan: { schemaVersion: ee, ...re(e) ? { requiresRecalculation: !0 } : {}, pages: a }, warnings: o };
640
751
  }
641
- function ir(e) {
752
+ function Rr(e) {
642
753
  const t = e.columns.find((a) => !a.hidden)?.field;
643
754
  if (!t) return { groups: 0, total: 0 };
644
- const r = re(e), n = (a = [], s = []) => a.includes(t) || s.some((l) => l.field === t), o = typeof e.grandTotal == "object" ? e.grandTotal : void 0;
755
+ const r = oe(e), n = (a = [], s = []) => a.includes(t) || s.some((c) => c.field === t), o = typeof e.grandTotal == "object" ? e.grandTotal : void 0;
645
756
  return { groups: r.filter((a) => n(a.subtotal, a.aggregates)).length, total: Number(n(o?.fields ?? r[0]?.subtotal, o?.aggregates ?? r[0]?.aggregates)) };
646
757
  }
647
- function lr(e, t, r) {
648
- qe(e);
649
- const n = He(t[e.dataset] ?? [], e.tree, r), o = e.columns.filter((s) => !s.hidden).length, a = e.header === !1 ? 0 : e.headerGrid ? ye(e.headerGrid) : o;
758
+ function Er(e, t, r) {
759
+ tt(e);
760
+ const n = ze(t[e.dataset] ?? [], e.tree, r), o = e.columns.filter((s) => !s.hidden).length, a = e.header === !1 ? 0 : e.headerGrid ? Me(e.headerGrid) : o;
650
761
  return n.length * o + a + +!!e.grandTotal * 2 * o;
651
762
  }
652
- function mn(e, t, r = {}) {
653
- if (e.tree) return lr(e, t, r.signal);
763
+ function jn(e, t, r = {}) {
764
+ if (e.tree) return Er(e, t, r.signal);
654
765
  if (e.matrix) {
655
766
  let i = t[e.dataset] ?? [];
656
- e.computed?.length && (i = Ne(i, { fields: e.computed, ...r }).rows), e.rowVisibleWhen && (i = i.filter((d) => W(d, e.rowVisibleWhen)));
657
- const c = Ct(i, e.matrix);
658
- return c.cells + c.columnCount;
767
+ e.computed?.length && (i = Ge(i, { fields: e.computed, ...r }).rows), e.rowVisibleWhen && (i = i.filter((d) => D(d, e.rowVisibleWhen)));
768
+ const l = Wt(i, e.matrix);
769
+ return l.cells + l.columnCount;
659
770
  }
660
- const n = t[e.dataset]?.length ?? 0, o = e.columns.filter((i) => !i.hidden).length, a = re(e).length, s = ir(e);
661
- let l = (n * (1 + 2 * a + s.groups) + +!!e.grandTotal * (1 + s.total)) * o;
662
- if (l += e.header === !1 ? 0 : e.headerGrid ? ye(e.headerGrid) : o, e.cardinality === "record" && n === 0 && (l += o), e.detail) {
663
- const i = t[e.detail.dataset]?.length ?? 0, c = e.detail.columns.filter((d) => !d.hidden).length;
664
- l += (i + n * (+(e.detail.header !== !1) + +!!e.detail.label)) * c;
771
+ const n = t[e.dataset]?.length ?? 0, o = e.columns.filter((i) => !i.hidden).length, a = oe(e).length, s = Rr(e);
772
+ let c = (n * (1 + 2 * a + s.groups) + +!!e.grandTotal * (1 + s.total)) * o;
773
+ if (c += e.header === !1 ? 0 : e.headerGrid ? Me(e.headerGrid) : o, e.cardinality === "record" && n === 0 && (c += o), e.detail) {
774
+ const i = t[e.detail.dataset]?.length ?? 0, l = e.detail.columns.filter((d) => !d.hidden).length;
775
+ c += (i + n * (+(e.detail.header !== !1) + +!!e.detail.label)) * l;
665
776
  }
666
- if (!Number.isSafeInteger(l)) throw new RangeError("报表单元格估算超出安全整数预算");
667
- return l;
777
+ if (!Number.isSafeInteger(c)) throw new RangeError("报表单元格估算超出安全整数预算");
778
+ return c;
668
779
  }
669
- function Ue(e) {
780
+ function ot(e) {
670
781
  return !e || typeof e != "object" ? !1 : [e.pageIndex, e.componentIndex, e.rowIndex, e.columnIndex].every((t) => Number.isInteger(t) && t >= 0);
671
782
  }
672
- function Ye(e, t, r) {
783
+ function at(e, t, r) {
673
784
  const n = e.grid;
674
785
  if (!n) return null;
675
786
  const o = n.cells[t];
676
787
  if (!o) return null;
677
- const s = me(n, e.widthMm, e.heightMm).cells.filter((i) => i.ri === t).findIndex((i) => i.ci === r), l = o[s];
678
- return l ? { cell: l, sourceColumnIndex: s } : null;
788
+ const s = pe(n, e.widthMm, e.heightMm).cells.filter((i) => i.ri === t).findIndex((i) => i.ci === r), c = o[s];
789
+ return c ? { cell: c, sourceColumnIndex: s } : null;
679
790
  }
680
- function cr(e) {
791
+ function Cr(e) {
681
792
  return e.value !== void 0 ? e.value : e.rawText ?? e.text ?? null;
682
793
  }
683
- function dr(e, t) {
794
+ function Fr(e, t) {
684
795
  return e.valueType ? e.valueType : typeof t == "number" ? "number" : typeof t == "boolean" ? "boolean" : t === null && e.numberFormat && /[0#?]/.test(e.numberFormat) ? "number" : "text";
685
796
  }
686
- function ur(e, t) {
797
+ function Ar(e, t) {
687
798
  if (e.derived) return "derived";
688
799
  if (e.editable === !1) return "cell";
689
800
  if (e.formula !== void 0) return "formula";
690
801
  if (e.children?.length) return "complex";
691
802
  if (t.table && t.table.role !== "body" && e.editable !== !0) return "structure";
692
803
  }
693
- function fr(e, t) {
804
+ function Or(e, t) {
694
805
  const r = e.table;
695
806
  if (r)
696
807
  return {
@@ -700,54 +811,54 @@ function fr(e, t) {
700
811
  columnKey: r.columnKeys[t.columnIndex]
701
812
  };
702
813
  }
703
- function mr(e, t, r) {
814
+ function Kr(e, t, r) {
704
815
  if (e.derived) return;
705
816
  if (e.source) return { ...e.source };
706
817
  const n = t.table?.source, o = t.table?.columnKeys[r.columnIndex];
707
818
  if (!(!n || n.rowKey === void 0 || o === void 0))
708
819
  return { ...n, rowKey: n.rowKey, field: o };
709
820
  }
710
- function Qe(e, t, r) {
711
- const n = cr(r), o = ur(r, e);
821
+ function st(e, t, r) {
822
+ const n = Cr(r), o = Ar(r, e);
712
823
  return {
713
824
  address: { ...t },
714
825
  cell: r,
715
826
  component: e,
716
827
  value: n,
717
- valueType: dr(r, n),
718
- table: fr(e, t),
719
- source: mr(r, e, t),
828
+ valueType: Fr(r, n),
829
+ table: Or(e, t),
830
+ source: Kr(r, e, t),
720
831
  editable: o === void 0,
721
832
  readOnlyReason: o
722
833
  };
723
834
  }
724
- function Me(e, t) {
725
- if (!Ue(t)) return null;
835
+ function Se(e, t) {
836
+ if (!ot(t)) return null;
726
837
  const r = e.pages[t.pageIndex]?.components[t.componentIndex];
727
838
  if (!r) return null;
728
- const n = Ye(r, t.rowIndex, t.columnIndex);
729
- return n ? Qe(r, t, n.cell) : null;
839
+ const n = at(r, t.rowIndex, t.columnIndex);
840
+ return n ? st(r, t, n.cell) : null;
730
841
  }
731
- function B(e) {
842
+ function W(e) {
732
843
  const t = /* @__PURE__ */ new Map();
733
844
  return (r) => {
734
- if (!Ue(r)) return null;
845
+ if (!ot(r)) return null;
735
846
  const n = e.pages[r.pageIndex]?.components[r.componentIndex];
736
847
  if (!n?.grid) return null;
737
848
  let o = t.get(n);
738
849
  if (!o) {
739
850
  const s = /* @__PURE__ */ new Map();
740
851
  o = /* @__PURE__ */ new Map();
741
- for (const l of me(n.grid, n.widthMm, n.heightMm).cells) {
742
- const i = s.get(l.ri) ?? 0;
743
- s.set(l.ri, i + 1);
744
- const c = n.grid.cells[l.ri]?.[i];
745
- c && o.set(`${l.ri}:${l.ci}`, c);
852
+ for (const c of pe(n.grid, n.widthMm, n.heightMm).cells) {
853
+ const i = s.get(c.ri) ?? 0;
854
+ s.set(c.ri, i + 1);
855
+ const l = n.grid.cells[c.ri]?.[i];
856
+ l && o.set(`${c.ri}:${c.ci}`, l);
746
857
  }
747
858
  t.set(n, o);
748
859
  }
749
860
  const a = o.get(`${r.rowIndex}:${r.columnIndex}`);
750
- return a ? Qe(n, r, a) : null;
861
+ return a ? st(n, r, a) : null;
751
862
  };
752
863
  }
753
864
  class b extends Error {
@@ -755,20 +866,20 @@ class b extends Error {
755
866
  super(`Invalid report cell edit: ${t}`), this.code = t, this.name = "ReportCellEditError";
756
867
  }
757
868
  }
758
- function gr(e, t) {
869
+ function jr(e, t) {
759
870
  let r = e.trim();
760
871
  const n = t && r.endsWith("%");
761
872
  if (n && (r = r.slice(0, -1).trim()), /^[+-]?\d{1,3}(?:,\d{3})+(?:\.\d*)?(?:[eE][+-]?\d+)?$/.test(r) && (r = r.replace(/,/g, "")), !/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/.test(r)) throw new b("number");
762
873
  return Number(r) / (n ? 100 : 1);
763
874
  }
764
- function hr(e, t) {
875
+ function Nr(e, t) {
765
876
  if (e === null || typeof e == "string" && e.trim() === "") return null;
766
877
  if (typeof e != "string" && typeof e != "number") throw new b("number");
767
- const r = typeof e == "number" ? e : gr(e, vt(t.cell.numberFormat));
878
+ const r = typeof e == "number" ? e : jr(e, Ct(t.cell.numberFormat));
768
879
  if (!Number.isFinite(r) || Number.isInteger(r) && !Number.isSafeInteger(r)) throw new b("number");
769
880
  return r;
770
881
  }
771
- function pr(e) {
882
+ function Lr(e) {
772
883
  if (e === null || typeof e == "string" && e.trim() === "") return null;
773
884
  if (typeof e == "boolean") return e;
774
885
  const t = String(e).trim().toLowerCase();
@@ -776,24 +887,24 @@ function pr(e) {
776
887
  if (["false", "no", "否", "0"].includes(t)) return !1;
777
888
  throw new b("boolean");
778
889
  }
779
- function Xe(e, t) {
780
- return e.valueType === "number" ? hr(t, e) : e.valueType === "boolean" ? pr(t) : t === null ? null : String(t);
890
+ function it(e, t) {
891
+ return e.valueType === "number" ? Nr(t, e) : e.valueType === "boolean" ? Lr(t) : t === null ? null : String(t);
781
892
  }
782
- function wr(e, t) {
893
+ function Hr(e, t) {
783
894
  const r = t.cell.text, o = [["是", "否"], ["TRUE", "FALSE"], ["True", "False"], ["true", "false"], ["1", "0"]].find((a) => a.includes(r ?? ""));
784
895
  return o ? o[e ? 0 : 1] : String(e);
785
896
  }
786
- function J(e, t) {
787
- return t === null ? "" : typeof t == "boolean" ? wr(t, e) : typeof t == "number" ? bt(t, e.cell.numberFormat) : String(t);
897
+ function _(e, t) {
898
+ return t === null ? "" : typeof t == "boolean" ? Hr(t, e) : typeof t == "number" ? Et(t, e.cell.numberFormat) : String(t);
788
899
  }
789
- function gn(e, t, r) {
790
- const n = Me(e, t);
900
+ function Nn(e, t, r) {
901
+ const n = Se(e, t);
791
902
  if (!n) throw new b("missing");
792
- return _(n, r);
903
+ return U(n, r);
793
904
  }
794
- function _(e, t) {
905
+ function U(e, t) {
795
906
  if (!e.editable) throw new b("readonly");
796
- const r = Xe(e, t);
907
+ const r = it(e, t);
797
908
  return {
798
909
  address: { ...e.address },
799
910
  table: e.table,
@@ -801,58 +912,58 @@ function _(e, t) {
801
912
  previousValue: e.value,
802
913
  previousText: e.cell.text ?? "",
803
914
  value: r,
804
- text: J(e, r)
915
+ text: _(e, r)
805
916
  };
806
917
  }
807
- function yr(e, t) {
918
+ function Br(e, t) {
808
919
  const r = e.table, n = t.table;
809
920
  return !r || !n || r.columnKey === void 0 ? !1 : r.id === n.id && r.rowIndex === n.rowIndex && r.role === n.role && r.columnKey === n.columnKey;
810
921
  }
811
- function Ze(e, t, r) {
812
- const n = e.grid, { rowIndex: o, columnIndex: a } = t.address, s = Ye(e, o, a), l = [...n.cells], i = [...l[o]], c = J(t, r.value), d = { ...s.cell, value: r.value, text: c, rawText: c };
813
- return i[s.sourceColumnIndex] = d, l[o] = i, { ...e, grid: { ...n, cells: l } };
922
+ function ct(e, t, r) {
923
+ const n = e.grid, { rowIndex: o, columnIndex: a } = t.address, s = at(e, o, a), c = [...n.cells], i = [...c[o]], l = _(t, r.value), d = { ...s.cell, value: r.value, text: l, rawText: l };
924
+ return i[s.sourceColumnIndex] = d, c[o] = i, { ...e, grid: { ...n, cells: c } };
814
925
  }
815
- function br(e, t) {
926
+ function Wr(e, t) {
816
927
  const r = e.table?.columnKeys, n = t.table?.columnKey;
817
928
  return r && n !== void 0 ? r.flatMap((o, a) => o === n ? [a] : []) : [];
818
929
  }
819
- function vr(e, t, r, n, o, a) {
820
- const s = t.table, l = o.table;
821
- if (!s || !l || s.id !== l.id || s.role !== l.role || !t.grid) return t;
822
- const i = l.rowIndex - s.rowIndex;
930
+ function Dr(e, t, r, n, o, a) {
931
+ const s = t.table, c = o.table;
932
+ if (!s || !c || s.id !== c.id || s.role !== c.role || !t.grid) return t;
933
+ const i = c.rowIndex - s.rowIndex;
823
934
  if (i < 0 || i >= t.grid.cells.length) return t;
824
- let c = t;
825
- for (const d of br(t, o)) {
826
- const u = Me(e, { pageIndex: r, componentIndex: n, rowIndex: i, columnIndex: d });
827
- u?.editable && yr(o, u) && (c = Ze(c, u, a));
935
+ let l = t;
936
+ for (const d of Wr(t, o)) {
937
+ const u = Se(e, { pageIndex: r, componentIndex: n, rowIndex: i, columnIndex: d });
938
+ u?.editable && Br(o, u) && (l = ct(l, u, a));
828
939
  }
829
- return c;
940
+ return l;
830
941
  }
831
- function Mr(e, t, r, n, o, a) {
942
+ function Vr(e, t, r, n, o, a) {
832
943
  const s = o.address;
833
- return o.table?.columnKey !== void 0 ? vr(e, t, r, n, o, a) : s.pageIndex === r && s.componentIndex === n ? Ze(t, o, a) : t;
944
+ return o.table?.columnKey !== void 0 ? Dr(e, t, r, n, o, a) : s.pageIndex === r && s.componentIndex === n ? ct(t, o, a) : t;
834
945
  }
835
- function $e(e, t) {
946
+ function Te(e, t) {
836
947
  const r = t.source;
837
948
  if (!r) return !1;
838
949
  const n = e.source;
839
950
  return !n || ["datasetId", "rowKey", "field", "revision", "sourceToken"].some((o) => !Object.is(n[o], r[o]));
840
951
  }
841
- function hn(e, t) {
842
- const r = Me(e, t.address);
952
+ function Ln(e, t) {
953
+ const r = Se(e, t.address);
843
954
  if (!r) throw new b("missing");
844
955
  if (!r.editable) throw new b("readonly");
845
- if ($e(r, t)) throw new b("conflict");
956
+ if (Te(r, t)) throw new b("conflict");
846
957
  if (!Object.is(r.value, t.previousValue) || (r.cell.text ?? "") !== t.previousText) throw new b("conflict");
847
- const n = Xe(r, t.value), o = { ...t, value: n, text: J(r, n) };
958
+ const n = it(r, t.value), o = { ...t, value: n, text: _(r, n) };
848
959
  if (Object.is(n, r.value) && o.text === r.cell.text) return e;
849
- const a = e.pages.map((s, l) => {
850
- const i = s.components.map((c, d) => Mr(e, c, l, d, r, o));
851
- return i.every((c, d) => c === s.components[d]) ? s : { ...s, components: i };
960
+ const a = e.pages.map((s, c) => {
961
+ const i = s.components.map((l, d) => Vr(e, l, c, d, r, o));
962
+ return i.every((l, d) => l === s.components[d]) ? s : { ...s, components: i };
852
963
  });
853
964
  return { ...e, pages: a };
854
965
  }
855
- function $r(e, t, r) {
966
+ function Gr(e, t, r) {
856
967
  if (!r || r.revision === void 0 && r.sourceToken === void 0) return e;
857
968
  const n = new Set(t.edits.flatMap((s) => s.source ? [s.source.datasetId] : []));
858
969
  if (!n.size) return e;
@@ -860,52 +971,52 @@ function $r(e, t, r) {
860
971
  return !s.datasetId || !n.has(s.datasetId) || (r.revision === void 0 || Object.is(r.revision, s.revision)) && (r.sourceToken === void 0 || r.sourceToken === s.sourceToken) ? s : { ...s, ...r.revision !== void 0 ? { revision: r.revision } : {}, ...r.sourceToken !== void 0 ? { sourceToken: r.sourceToken } : {} };
861
972
  }
862
973
  const a = e.pages.map((s) => {
863
- const l = s.components.map((i) => {
864
- const c = i.table?.source ? o(i.table.source) : void 0, d = i.table && c !== i.table.source ? { ...i.table, source: c } : i.table, u = i.grid?.cells.map((m) => {
865
- const w = m.map((g) => {
974
+ const c = s.components.map((i) => {
975
+ const l = i.table?.source ? o(i.table.source) : void 0, d = i.table && l !== i.table.source ? { ...i.table, source: l } : i.table, u = i.grid?.cells.map((m) => {
976
+ const p = m.map((g) => {
866
977
  if (!g?.source) return g;
867
978
  const h = o(g.source);
868
979
  return h === g.source ? g : { ...g, source: h };
869
980
  });
870
- return w.some((g, h) => g !== m[h]) ? w : m;
871
- }), f = i.grid && u?.some((m, w) => m !== i.grid.cells[w]) ? { ...i.grid, cells: u } : i.grid;
981
+ return p.some((g, h) => g !== m[h]) ? p : m;
982
+ }), f = i.grid && u?.some((m, p) => m !== i.grid.cells[p]) ? { ...i.grid, cells: u } : i.grid;
872
983
  return d !== i.table || f !== i.grid ? { ...i, table: d, grid: f } : i;
873
984
  });
874
- return l.some((i, c) => i !== s.components[c]) ? { ...s, components: l } : s;
985
+ return c.some((i, l) => i !== s.components[l]) ? { ...s, components: c } : s;
875
986
  });
876
- return a.some((s, l) => s !== e.pages[l]) ? { ...e, pages: a } : e;
987
+ return a.some((s, c) => s !== e.pages[c]) ? { ...e, pages: a } : e;
877
988
  }
878
- function xr(e) {
989
+ function zr(e) {
879
990
  return JSON.stringify([e.pageIndex, e.componentIndex, e.rowIndex, e.columnIndex]);
880
991
  }
881
- function Te(e) {
992
+ function Ee(e) {
882
993
  const t = e.table;
883
- return t?.columnKey !== void 0 ? JSON.stringify([t.id, t.role, t.rowIndex, t.columnKey]) : xr(e.address);
994
+ return t?.columnKey !== void 0 ? JSON.stringify([t.id, t.role, t.rowIndex, t.columnKey]) : zr(e.address);
884
995
  }
885
- function Sr(e, t) {
996
+ function Jr(e, t) {
886
997
  if (!t.length) return e;
887
- const r = new Map(t.map((i) => [Te(i), i])), n = new Set(t.flatMap((i) => i.table ? [i.table.id] : [])), o = new Set(t.map((i) => `${i.address.pageIndex}:${i.address.componentIndex}`)), a = B(e);
888
- function s(i, c, d) {
998
+ const r = new Map(t.map((i) => [Ee(i), i])), n = new Set(t.flatMap((i) => i.table ? [i.table.id] : [])), o = new Set(t.map((i) => `${i.address.pageIndex}:${i.address.componentIndex}`)), a = W(e);
999
+ function s(i, l, d) {
889
1000
  const u = i.grid;
890
- if (!u || !o.has(`${c}:${d}`) && !n.has(i.table?.id ?? "")) return i;
1001
+ if (!u || !o.has(`${l}:${d}`) && !n.has(i.table?.id ?? "")) return i;
891
1002
  const f = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map();
892
- for (const w of me(u, i.widthMm, i.heightMm).cells) {
893
- const g = m.get(w.ri) ?? 0;
894
- m.set(w.ri, g + 1);
895
- const h = a({ pageIndex: c, componentIndex: d, rowIndex: w.ri, columnIndex: w.ci }), v = h && r.get(Te(h));
1003
+ for (const p of pe(u, i.widthMm, i.heightMm).cells) {
1004
+ const g = m.get(p.ri) ?? 0;
1005
+ m.set(p.ri, g + 1);
1006
+ const h = a({ pageIndex: l, componentIndex: d, rowIndex: p.ri, columnIndex: p.ci }), v = h && r.get(Ee(h));
896
1007
  if (!v || !h.editable) continue;
897
- const M = f.get(w.ri) ?? [...u.cells[w.ri]], y = J(h, v.value);
898
- Object.is(h.value, v.value) && y === h.cell.text || (M[g] = { ...w.cell, value: v.value, text: y, rawText: y }, f.set(w.ri, M));
1008
+ const M = f.get(p.ri) ?? [...u.cells[p.ri]], y = _(h, v.value);
1009
+ Object.is(h.value, v.value) && y === h.cell.text || (M[g] = { ...p.cell, value: v.value, text: y, rawText: y }, f.set(p.ri, M));
899
1010
  }
900
- return f.size ? { ...i, grid: { ...u, cells: u.cells.map((w, g) => f.get(g) ?? w) } } : i;
1011
+ return f.size ? { ...i, grid: { ...u, cells: u.cells.map((p, g) => f.get(g) ?? p) } } : i;
901
1012
  }
902
- const l = e.pages.map((i, c) => {
903
- const d = i.components.map((u, f) => s(u, c, f));
1013
+ const c = e.pages.map((i, l) => {
1014
+ const d = i.components.map((u, f) => s(u, l, f));
904
1015
  return d.every((u, f) => u === i.components[f]) ? i : { ...i, components: d };
905
1016
  });
906
- return l.every((i, c) => i === e.pages[c]) ? e : { ...e, pages: l };
1017
+ return c.every((i, l) => i === e.pages[l]) ? e : { ...e, pages: c };
907
1018
  }
908
- function I(e) {
1019
+ function A(e) {
909
1020
  const t = e.source;
910
1021
  if (t) return JSON.stringify([t.datasetId, t.rowKey, t.field]);
911
1022
  const r = e.table;
@@ -913,80 +1024,80 @@ function I(e) {
913
1024
  const n = e.address;
914
1025
  return JSON.stringify([n.pageIndex, n.componentIndex, n.rowIndex, n.columnIndex]);
915
1026
  }
916
- function pn(e, t, r) {
1027
+ function Hn(e, t, r) {
917
1028
  if (typeof r != "string" || !r.trim() || !Array.isArray(t)) throw new b("missing");
918
1029
  if (t.length > 1e4) throw new b("limit");
919
- const n = /* @__PURE__ */ new Set(), o = B(e), a = t.map(({ address: s, value: l }) => {
1030
+ const n = /* @__PURE__ */ new Set(), o = W(e), a = t.map(({ address: s, value: c }) => {
920
1031
  const i = o(s);
921
1032
  if (!i) throw new b("missing");
922
- const c = _(i, l), d = I(c);
1033
+ const l = U(i, c), d = A(l);
923
1034
  if (n.has(d)) throw new b("duplicate");
924
- return n.add(d), c;
1035
+ return n.add(d), l;
925
1036
  });
926
1037
  return { requestId: r, edits: a };
927
1038
  }
928
- function wn(e, t) {
1039
+ function Bn(e, t) {
929
1040
  if (t.edits.length > 1e4) throw new b("limit");
930
- const r = B(e), n = /* @__PURE__ */ new Set(), o = t.edits.map((a) => {
1041
+ const r = W(e), n = /* @__PURE__ */ new Set(), o = t.edits.map((a) => {
931
1042
  const s = r(a.address);
932
1043
  if (!s) throw new b("missing");
933
- const l = I(a);
934
- if (n.has(l)) throw new b("duplicate");
935
- if (n.add(l), $e(s, a) || !Object.is(s.value, a.previousValue) || (s.cell.text ?? "") !== a.previousText) throw new b("conflict");
936
- return _(s, a.value);
1044
+ const c = A(a);
1045
+ if (n.has(c)) throw new b("duplicate");
1046
+ if (n.add(c), Te(s, a) || !Object.is(s.value, a.previousValue) || (s.cell.text ?? "") !== a.previousText) throw new b("conflict");
1047
+ return U(s, a.value);
937
1048
  });
938
- return Sr(e, o);
1049
+ return Jr(e, o);
939
1050
  }
940
- function yn(e) {
1051
+ function Wn(e) {
941
1052
  const t = /* @__PURE__ */ new Map();
942
1053
  for (const r of e) {
943
- const n = I(r), o = t.get(n), a = o ? { ...r, previousValue: o.previousValue, previousText: o.previousText } : { ...r };
1054
+ const n = A(r), o = t.get(n), a = o ? { ...r, previousValue: o.previousValue, previousText: o.previousText } : { ...r };
944
1055
  Object.is(a.previousValue, a.value) ? t.delete(n) : t.set(n, a);
945
1056
  }
946
1057
  return [...t.values()];
947
1058
  }
948
- function H(e, t) {
1059
+ function B(e, t) {
949
1060
  for (let r = 0; r < t.length; r++) {
950
1061
  const n = t.charCodeAt(r);
951
1062
  e.first = Math.imul(e.first ^ n, 16777619), e.second = Math.imul(e.second, 33) ^ n, e.count++;
952
1063
  }
953
1064
  }
954
- function Tr(e, t, r) {
1065
+ function qr(e, t, r) {
955
1066
  const n = Object.getOwnPropertyDescriptor(e, t);
956
1067
  if (!n || n.get || n.set) throw new b("conflict");
957
- H(r, `${t.length}:${t}`), et(n.value, r);
1068
+ B(r, `${t.length}:${t}`), lt(n.value, r);
958
1069
  }
959
- function kr(e, t) {
1070
+ function _r(e, t) {
960
1071
  if (Object.getOwnPropertyDescriptor(e, "toJSON")) throw new b("conflict");
961
1072
  if (t.active.has(e)) throw new b("conflict");
962
- if (t.active.add(e), e instanceof Date) H(t, `date:${Date.prototype.getTime.call(e)};`);
1073
+ if (t.active.add(e), e instanceof Date) B(t, `date:${Date.prototype.getTime.call(e)};`);
963
1074
  else {
964
1075
  const r = Object.getPrototypeOf(e);
965
1076
  if (!Array.isArray(e) && r !== Object.prototype && r !== null) throw new b("conflict");
966
1077
  const n = Object.keys(e);
967
- H(t, `${Array.isArray(e) ? "array" : "object"}:${Array.isArray(e) ? e.length : n.length}:{`), n.forEach((o) => Tr(e, o, t)), H(t, "}");
1078
+ B(t, `${Array.isArray(e) ? "array" : "object"}:${Array.isArray(e) ? e.length : n.length}:{`), n.forEach((o) => qr(e, o, t)), B(t, "}");
968
1079
  }
969
1080
  t.active.delete(e);
970
1081
  }
971
- function et(e, t) {
1082
+ function lt(e, t) {
972
1083
  if (++t.nodes > 1e6) throw new b("limit");
973
1084
  if (e === null) {
974
- H(t, "null;");
1085
+ B(t, "null;");
975
1086
  return;
976
1087
  }
977
1088
  if (typeof e == "object") {
978
- kr(e, t);
1089
+ _r(e, t);
979
1090
  return;
980
1091
  }
981
1092
  if (typeof e == "function" || typeof e == "symbol") throw new b("conflict");
982
1093
  const r = String(e);
983
- H(t, `${typeof e}:${r.length}:${r};`);
1094
+ B(t, `${typeof e}:${r.length}:${r};`);
984
1095
  }
985
- function ke(e) {
1096
+ function Ce(e) {
986
1097
  const t = { first: 2166136261, second: 5381, count: 0, nodes: 0, active: /* @__PURE__ */ new Set() };
987
- return et(e, t), `${t.count}:${t.first >>> 0}:${t.second >>> 0}`;
1098
+ return lt(e, t), `${t.count}:${t.first >>> 0}:${t.second >>> 0}`;
988
1099
  }
989
- function de(e, t, r) {
1100
+ function fe(e, t, r) {
990
1101
  if (++r.nodes > 1e6) throw new b("limit");
991
1102
  if (typeof e == "string" && (r.text += e.length, r.text > 32 * 1024 * 1024))
992
1103
  throw new b("limit");
@@ -994,165 +1105,165 @@ function de(e, t, r) {
994
1105
  if (t.has(e)) throw new b("conflict");
995
1106
  if (e instanceof Date) return new Date(Date.prototype.getTime.call(e));
996
1107
  t.add(e);
997
- const n = Array.isArray(e) ? e.map((o) => de(o, t, r)) : Object.fromEntries(Object.entries(e).map(([o, a]) => [o, de(a, t, r)]));
1108
+ const n = Array.isArray(e) ? e.map((o) => fe(o, t, r)) : Object.fromEntries(Object.entries(e).map(([o, a]) => [o, fe(a, t, r)]));
998
1109
  return t.delete(e), n;
999
1110
  }
1000
- function Pr(e) {
1001
- return de(e, /* @__PURE__ */ new Set(), { nodes: 0, text: 0 });
1111
+ function Ur(e) {
1112
+ return fe(e, /* @__PURE__ */ new Set(), { nodes: 0, text: 0 });
1002
1113
  }
1003
- function tt(e) {
1114
+ function dt(e) {
1004
1115
  const t = [];
1005
1116
  for (const r of e.template.pages) for (const n of r.components)
1006
1117
  n.kind === "list" && (t.push(n.tree ? { ...n, rowKey: n.tree.idField } : n), n.detail && t.push({ ...n.detail, relation: { detail: n.detail, parentRows: e.datasets[n.dataset] ?? [] } }));
1007
1118
  return t;
1008
1119
  }
1009
- function Pe(e) {
1120
+ function Fe(e) {
1010
1121
  return JSON.stringify([e.datasetId, e.rowKey]);
1011
1122
  }
1012
- function rt(e) {
1123
+ function ut(e) {
1013
1124
  const t = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Set();
1014
1125
  return e.forEach((n, o) => {
1015
- for (const a of tt(n)) {
1126
+ for (const a of dt(n)) {
1016
1127
  if (!a.rowKey) continue;
1017
- const s = a.relation, l = s ? new Set(s.parentRows.map((i) => JSON.stringify(i[s.detail.parentKey]))) : void 0;
1018
- (n.datasets[a.dataset] ?? []).forEach((i, c) => {
1019
- if (s && !l.has(JSON.stringify(i[s.detail.foreignKey]))) return;
1128
+ const s = a.relation, c = s ? new Set(s.parentRows.map((i) => JSON.stringify(i[s.detail.parentKey]))) : void 0;
1129
+ (n.datasets[a.dataset] ?? []).forEach((i, l) => {
1130
+ if (s && !c.has(JSON.stringify(i[s.detail.foreignKey]))) return;
1020
1131
  const d = i[a.rowKey];
1021
1132
  if (typeof d != "string" && typeof d != "number") return;
1022
- const u = `${o}:${a.dataset}:${c}:${a.rowKey}`;
1133
+ const u = `${o}:${a.dataset}:${l}:${a.rowKey}`;
1023
1134
  if (r.has(u)) return;
1024
1135
  r.add(u);
1025
- const f = Pe({ datasetId: a.dataset, rowKey: d }), m = t.get(f) ?? [];
1026
- m.push({ partIndex: o, dataset: a.dataset, rowIndex: c, row: i, binding: a }), t.set(f, m);
1136
+ const f = Fe({ datasetId: a.dataset, rowKey: d }), m = t.get(f) ?? [];
1137
+ m.push({ partIndex: o, dataset: a.dataset, rowIndex: l, row: i, binding: a }), t.set(f, m);
1027
1138
  });
1028
1139
  }
1029
1140
  }), (n) => {
1030
- const o = t.get(Pe(n));
1141
+ const o = t.get(Fe(n));
1031
1142
  if (!o?.length) throw new b("missing");
1032
1143
  if (new Set(o.map((a) => `${a.partIndex}:${a.dataset}`)).size !== o.length) throw new b("conflict");
1033
1144
  return o;
1034
1145
  };
1035
1146
  }
1036
- function nt(e, t) {
1147
+ function ft(e, t) {
1037
1148
  const r = e.map((o) => ({ ...o, datasets: { ...o.datasets } })), n = /* @__PURE__ */ new Set();
1038
1149
  for (const { row: o, field: a, value: s } of t) {
1039
- const l = r[o.partIndex], i = `${o.partIndex}:${o.dataset}`;
1040
- n.has(i) || (l.datasets[o.dataset] = [...l.datasets[o.dataset]], n.add(i)), l.datasets[o.dataset][o.rowIndex] = { ...l.datasets[o.dataset][o.rowIndex], [a]: s };
1150
+ const c = r[o.partIndex], i = `${o.partIndex}:${o.dataset}`;
1151
+ n.has(i) || (c.datasets[o.dataset] = [...c.datasets[o.dataset]], n.add(i)), c.datasets[o.dataset][o.rowIndex] = { ...c.datasets[o.dataset][o.rowIndex], [a]: s };
1041
1152
  }
1042
1153
  return r;
1043
1154
  }
1044
- function Rr(e, t, r) {
1155
+ function Xr(e, t, r) {
1045
1156
  const n = [], o = /* @__PURE__ */ new Set();
1046
1157
  return e.forEach((a, s) => {
1047
- for (const l of tt(a))
1048
- t.has(l.dataset) && (a.datasets[l.dataset] ?? []).forEach((i, c) => {
1049
- const d = { partIndex: s, dataset: l.dataset, rowIndex: c, row: i, binding: l };
1050
- for (const [u, f] of [[l.revisionField, r.revision], [l.sourceTokenField, r.sourceToken]]) {
1158
+ for (const c of dt(a))
1159
+ t.has(c.dataset) && (a.datasets[c.dataset] ?? []).forEach((i, l) => {
1160
+ const d = { partIndex: s, dataset: c.dataset, rowIndex: l, row: i, binding: c };
1161
+ for (const [u, f] of [[c.revisionField, r.revision], [c.sourceTokenField, r.sourceToken]]) {
1051
1162
  if (!u || f === void 0) continue;
1052
- const m = `${s}:${l.dataset}:${c}:${u}`;
1163
+ const m = `${s}:${c.dataset}:${l}:${u}`;
1053
1164
  o.has(m) || (o.add(m), n.push({ row: d, field: u, value: f }));
1054
1165
  }
1055
1166
  });
1056
1167
  }), n;
1057
1168
  }
1058
- function ot(e) {
1059
- const t = /* @__PURE__ */ new Map(), r = B(e);
1169
+ function mt(e) {
1170
+ const t = /* @__PURE__ */ new Map(), r = W(e);
1060
1171
  return e.pages.forEach((n, o) => n.components.forEach((a, s) => {
1061
1172
  if (!(!a.grid || a.table?.role !== "body"))
1062
- for (let l = 0; l < a.grid.cells.length; l++) for (let i = 0; i < a.table.columnKeys.length; i++) {
1063
- const c = r({ pageIndex: o, componentIndex: s, rowIndex: l, columnIndex: i });
1064
- c?.source && c.editable && t.set(I(c), c);
1173
+ for (let c = 0; c < a.grid.cells.length; c++) for (let i = 0; i < a.table.columnKeys.length; i++) {
1174
+ const l = r({ pageIndex: o, componentIndex: s, rowIndex: c, columnIndex: i });
1175
+ l?.source && l.editable && t.set(A(l), l);
1065
1176
  }
1066
1177
  })), t;
1067
1178
  }
1068
- function bn(e, t, r) {
1069
- const n = ot(e), o = B(e);
1179
+ function Dn(e, t, r) {
1180
+ const n = mt(e), o = W(e);
1070
1181
  return t.map((a) => {
1071
- const s = a.source ? n.get(I(a)) : o(a.address);
1072
- if (!s || I(s) !== I(a)) throw new b("missing");
1182
+ const s = a.source ? n.get(A(a)) : o(a.address);
1183
+ if (!s || A(s) !== A(a)) throw new b("missing");
1073
1184
  return { address: { ...s.address }, value: a[r] };
1074
1185
  });
1075
1186
  }
1076
- async function at(e, t, r = {}) {
1187
+ async function gt(e, t, r = {}) {
1077
1188
  const n = [], o = { ...r, knownTotalPages: void 0 };
1078
- for (const a of sr(e, t, o))
1189
+ for (const a of kr(e, t, o))
1079
1190
  n.push(a), n.length % 8 === 0 && await new Promise((s) => setTimeout(s, 0));
1080
1191
  if (r.signal?.aborted) {
1081
1192
  const a = new Error("报表重算已取消");
1082
1193
  throw a.name = "AbortError", a;
1083
1194
  }
1084
- return { schemaVersion: Z, ...ee(e) ? { requiresRecalculation: !0 } : {}, pages: n };
1195
+ return { schemaVersion: ee, ...re(e) ? { requiresRecalculation: !0 } : {}, pages: n };
1085
1196
  }
1086
- const ue = /* @__PURE__ */ new WeakMap();
1087
- function vn(e) {
1088
- return ue.get(e);
1197
+ const me = /* @__PURE__ */ new WeakMap();
1198
+ function Vn(e) {
1199
+ return me.get(e);
1089
1200
  }
1090
- function U(e) {
1201
+ function X(e) {
1091
1202
  if (e?.aborted) {
1092
1203
  const t = new Error("报表重算已取消");
1093
1204
  throw t.name = "AbortError", t;
1094
1205
  }
1095
1206
  }
1096
- function st(e, t) {
1207
+ function pt(e, t) {
1097
1208
  return e[t] === void 0 ? "" : e[t];
1098
1209
  }
1099
- function Cr(e, t) {
1210
+ function Yr(e, t) {
1100
1211
  if (t.edits.length > 1e4) throw new b("limit");
1101
- const r = B(e), n = /* @__PURE__ */ new Set(), o = [], a = t.edits.map((s) => {
1102
- const l = r(s.address);
1103
- if (!l?.source) throw new b("missing");
1104
- const i = I(s);
1212
+ const r = W(e), n = /* @__PURE__ */ new Set(), o = [], a = t.edits.map((s) => {
1213
+ const c = r(s.address);
1214
+ if (!c?.source) throw new b("missing");
1215
+ const i = A(s);
1105
1216
  if (n.has(i)) throw new b("duplicate");
1106
- if (n.add(i), $e(l, s) || !Object.is(l.value, s.previousValue) || (l.cell.text ?? "") !== s.previousText) throw new b("conflict");
1107
- return o.push(l), _(l, s.value);
1217
+ if (n.add(i), Te(c, s) || !Object.is(c.value, s.previousValue) || (c.cell.text ?? "") !== s.previousText) throw new b("conflict");
1218
+ return o.push(c), U(c, s.value);
1108
1219
  });
1109
1220
  return { batch: { requestId: t.requestId, edits: a }, contexts: o };
1110
1221
  }
1111
- function Er(e, t) {
1112
- const r = rt(e);
1222
+ function Qr(e, t) {
1223
+ const r = ut(e);
1113
1224
  return t.flatMap((n) => {
1114
1225
  if (!n.source) throw new b("missing");
1115
1226
  return r(n.source).map((o) => {
1116
- if (!Object.is(st(o.row, n.source.field), n.previousValue)) throw new b("conflict");
1227
+ if (!Object.is(pt(o.row, n.source.field), n.previousValue)) throw new b("conflict");
1117
1228
  if (o.binding.rowKey === n.source.field) throw new b("readonly");
1118
1229
  return { row: o, field: n.source.field, value: n.value };
1119
1230
  });
1120
1231
  });
1121
1232
  }
1122
- function ie(e, t, r) {
1233
+ function le(e, t, r) {
1123
1234
  const n = { ...e, value: t, source: { ...e.source, ...r?.revision === void 0 ? {} : { revision: r.revision }, ...r?.sourceToken === void 0 ? {} : { sourceToken: r.sourceToken } } };
1124
- return n.cell = { ...e.cell, value: n.value, text: J(n, n.value) }, n;
1235
+ return n.cell = { ...e.cell, value: n.value, text: _(n, n.value) }, n;
1125
1236
  }
1126
- function Fr(e, t, r) {
1237
+ function Zr(e, t, r) {
1127
1238
  if (!r || r.revision === void 0 && r.sourceToken === void 0) return [...e];
1128
1239
  const n = new Set(t.edits.flatMap((o) => o.source ? [o.source.datasetId] : []));
1129
- return nt(e, Rr(e, n, r));
1240
+ return ft(e, Xr(e, n, r));
1130
1241
  }
1131
- function it(e, t) {
1242
+ function ht(e, t) {
1132
1243
  let r = t.parts;
1133
- const n = t.rebuild, o = ke(r);
1244
+ const n = t.rebuild, o = Ce(r);
1134
1245
  let a = e, s;
1135
- const l = /* @__PURE__ */ new Map();
1246
+ const c = /* @__PURE__ */ new Map();
1136
1247
  function i(u) {
1137
1248
  if (u !== a) throw new b("conflict");
1138
1249
  if (s) return s;
1139
- if (ke(r) !== o) throw new b("conflict");
1140
- return Pr(r);
1250
+ if (Ce(r) !== o) throw new b("conflict");
1251
+ return Ur(r);
1141
1252
  }
1142
- async function c(u, f, m, w = {}) {
1143
- U(w.signal), f = { requestId: f.requestId, edits: f.edits.map((y) => ({ ...y, address: { ...y.address }, source: y.source ? { ...y.source } : void 0, table: y.table ? { ...y.table } : void 0 })) }, m = m.map((y) => ({ ...y, address: { ...y.address }, source: y.source ? { ...y.source } : void 0, table: y.table ? { ...y.table } : void 0, cell: { ...y.cell } })), await new Promise((y) => setTimeout(y, 0)), U(w.signal);
1144
- const g = i(u), h = nt(g, Er(g, f.edits)), v = await n(h, w.signal);
1145
- U(w.signal);
1253
+ async function l(u, f, m, p = {}) {
1254
+ X(p.signal), f = { requestId: f.requestId, edits: f.edits.map((y) => ({ ...y, address: { ...y.address }, source: y.source ? { ...y.source } : void 0, table: y.table ? { ...y.table } : void 0 })) }, m = m.map((y) => ({ ...y, address: { ...y.address }, source: y.source ? { ...y.source } : void 0, table: y.table ? { ...y.table } : void 0, cell: { ...y.cell } })), await new Promise((y) => setTimeout(y, 0)), X(p.signal);
1255
+ const g = i(u), h = ft(g, Qr(g, f.edits)), v = await n(h, p.signal);
1256
+ X(p.signal);
1146
1257
  let M = !1;
1147
1258
  return { plan: v, commit(y) {
1148
- if (U(w.signal), M || a !== u) throw new b("conflict");
1259
+ if (X(p.signal), M || a !== u) throw new b("conflict");
1149
1260
  if (y?.conflicts?.length) throw new b("conflict");
1150
- const j = Fr(h, f, y), A = $r(v, f, y);
1261
+ const N = Zr(h, f, y), O = Gr(v, f, y);
1151
1262
  if (y) {
1152
- const R = new Set(f.edits.map((C) => C.source.datasetId));
1153
- for (const [C, p] of l) R.has(p.source.datasetId) && l.set(C, ie(p, p.value, y));
1263
+ const k = new Set(f.edits.map((R) => R.source.datasetId));
1264
+ for (const [R, w] of c) k.has(w.source.datasetId) && c.set(R, le(w, w.value, y));
1154
1265
  }
1155
- return m.forEach((R, C) => l.set(I(R), ie(R, f.edits[C].value, y))), M = !0, s = j, r = void 0, a = A, ue.set(a, d), a;
1266
+ return m.forEach((k, R) => c.set(A(k), le(k, f.edits[R].value, y))), M = !0, s = N, r = void 0, a = O, me.set(a, d), a;
1156
1267
  } };
1157
1268
  }
1158
1269
  const d = {
@@ -1160,61 +1271,61 @@ function it(e, t) {
1160
1271
  return a;
1161
1272
  },
1162
1273
  async prepare(u, f, m) {
1163
- const w = Cr(u, f);
1164
- return c(u, w.batch, w.contexts, m);
1274
+ const p = Yr(u, f);
1275
+ return l(u, p.batch, p.contexts, m);
1165
1276
  },
1166
- async prepareHistory(u, f, m, w, g) {
1167
- if (!w.trim() || f.length > 1e4) throw new b("limit");
1168
- const h = i(u), v = rt(h), M = ot(u), y = /* @__PURE__ */ new Set(), A = f.map((p) => {
1169
- if (!p.source) throw new b("missing");
1170
- const $ = I(p);
1277
+ async prepareHistory(u, f, m, p, g) {
1278
+ if (!p.trim() || f.length > 1e4) throw new b("limit");
1279
+ const h = i(u), v = ut(h), M = mt(u), y = /* @__PURE__ */ new Set(), O = f.map((w) => {
1280
+ if (!w.source) throw new b("missing");
1281
+ const $ = A(w);
1171
1282
  if (y.has($)) throw new b("duplicate");
1172
1283
  y.add($);
1173
- const x = M.get($) ?? l.get($);
1284
+ const x = M.get($) ?? c.get($);
1174
1285
  if (!x?.source) throw new b("missing");
1175
- const k = v(x.source)[0];
1176
- return ie(x, st(k.row, x.source.field));
1177
- }).map((p, $) => ({ context: p, edit: _(p, f[$][m]) })).filter(({ edit: p }) => !Object.is(p.previousValue, p.value)), R = { requestId: w, edits: A.map(({ edit: p }) => p) }, C = A.map(({ context: p }) => p);
1178
- return { batch: R, contexts: C, prepared: await c(u, R, C, g) };
1286
+ const I = v(x.source)[0];
1287
+ return le(x, pt(I.row, x.source.field));
1288
+ }).map((w, $) => ({ context: w, edit: U(w, f[$][m]) })).filter(({ edit: w }) => !Object.is(w.previousValue, w.value)), k = { requestId: p, edits: O.map(({ edit: w }) => w) }, R = O.map(({ context: w }) => w);
1289
+ return { batch: k, contexts: R, prepared: await l(u, k, R, g) };
1179
1290
  }
1180
1291
  };
1181
- return ue.set(e, d), d;
1292
+ return me.set(e, d), d;
1182
1293
  }
1183
- function Mn(e) {
1184
- const t = ve(e.template, e.datasets, e.pagination).plan;
1185
- return it(t, { parts: [{ template: e.template, datasets: e.datasets }], rebuild: (r, n) => at(r[0].template, r[0].datasets, { ...e.pagination, signal: n }) });
1294
+ function Gn(e) {
1295
+ const t = xe(e.template, e.datasets, e.pagination).plan;
1296
+ return ht(t, { parts: [{ template: e.template, datasets: e.datasets }], rebuild: (r, n) => gt(r[0].template, r[0].datasets, { ...e.pagination, signal: n }) });
1186
1297
  }
1187
- function xe(e, t, r = {}) {
1298
+ function Ie(e, t, r = {}) {
1188
1299
  const n = /* @__PURE__ */ new Map();
1189
1300
  for (const a of e.pages) for (const s of a.components) {
1190
1301
  if (s.kind !== "list" || s.tree?.input !== "nested") continue;
1191
- const l = n.get(s.dataset);
1192
- if (l && (l.childrenField ?? "children") !== (s.tree.childrenField ?? "children")) throw new Error("同一数据集的嵌套树应使用相同 childrenField");
1302
+ const c = n.get(s.dataset);
1303
+ if (c && (c.childrenField ?? "children") !== (s.tree.childrenField ?? "children")) throw new Error("同一数据集的嵌套树应使用相同 childrenField");
1193
1304
  n.set(s.dataset, s.tree);
1194
1305
  }
1195
1306
  if (!n.size) return t;
1196
1307
  const o = { ...t };
1197
1308
  for (const [a, s] of n) {
1198
- const l = Math.min(s.maxRows ?? 1e5, r.maxRows ?? 1 / 0);
1199
- o[a] = He(t[a] ?? [], { ...s, maxRows: l }, r.signal);
1309
+ const c = Math.min(s.maxRows ?? 1e5, r.maxRows ?? 1 / 0);
1310
+ o[a] = ze(t[a] ?? [], { ...s, maxRows: c }, r.signal);
1200
1311
  }
1201
1312
  return o;
1202
1313
  }
1203
- function Ir(e, t, r = {}) {
1204
- return Object.values(xe(e, t, r)).reduce((n, o) => n + o.length, 0);
1314
+ function en(e, t, r = {}) {
1315
+ return Object.values(Ie(e, t, r)).reduce((n, o) => n + o.length, 0);
1205
1316
  }
1206
- function $n(e, t, r) {
1207
- const n = $t(r), o = e?.pages.flatMap((l) => l.components).find((l) => l.kind === "list" && l.dataset === t && l.tree?.input === "nested");
1317
+ function zn(e, t, r) {
1318
+ const n = At(r), o = e?.pages.flatMap((c) => c.components).find((c) => c.kind === "list" && c.dataset === t && c.tree?.input === "nested");
1208
1319
  if (!o || o.kind !== "list" || !o.tree) return n;
1209
1320
  const a = n.items, s = o.tree.childrenField ?? "children";
1210
1321
  return { ...n, items: { $ref: "#/$defs/treeNode" }, $defs: { treeNode: { ...a, properties: { ...a.properties, [s]: { anyOf: [{ type: "null" }, { type: "array", items: { $ref: "#/$defs/treeNode" } }] } } } } };
1211
1322
  }
1212
- function xn(e) {
1323
+ function Jn(e) {
1213
1324
  if (!("mapData" in e)) return e;
1214
1325
  const { load: t, mapData: r, ...n } = e;
1215
1326
  return { ...n, load: async (o) => {
1216
1327
  const a = await t(o);
1217
- E(o.signal);
1328
+ C(o.signal);
1218
1329
  try {
1219
1330
  return r(a, o);
1220
1331
  } catch (s) {
@@ -1227,17 +1338,17 @@ class S extends Error {
1227
1338
  super(r), this.name = "ReportSourceError", this.code = t, this.cause = n;
1228
1339
  }
1229
1340
  }
1230
- function ae(e) {
1341
+ function ie(e) {
1231
1342
  const t = new Error("报表加载已取消");
1232
1343
  return t.name = "AbortError", Object.defineProperty(t, "cause", { value: e.reason }), t;
1233
1344
  }
1234
- function E(e) {
1235
- if (e?.aborted) throw ae(e);
1345
+ function C(e) {
1346
+ if (e?.aborted) throw ie(e);
1236
1347
  }
1237
- function fe(e, t) {
1348
+ function ge(e, t) {
1238
1349
  return t ? new Promise((r, n) => {
1239
1350
  const o = () => t.removeEventListener("abort", a), a = () => {
1240
- o(), n(ae(t));
1351
+ o(), n(ie(t));
1241
1352
  };
1242
1353
  t.addEventListener("abort", a, { once: !0 }), t.aborted && a(), Promise.resolve(e).then(
1243
1354
  (s) => {
@@ -1249,68 +1360,73 @@ function fe(e, t) {
1249
1360
  );
1250
1361
  }) : Promise.resolve(e);
1251
1362
  }
1252
- function Ar(e, t) {
1363
+ function tn(e, t) {
1253
1364
  if (!e || typeof e != "object" || Array.isArray(e))
1254
1365
  throw new S("validate", `报表 ${t} 的数据集应为对象`);
1255
1366
  for (const [r, n] of Object.entries(e))
1256
1367
  if (!Array.isArray(n) || n.some((o) => !o || typeof o != "object" || Array.isArray(o)))
1257
1368
  throw new S("validate", `报表 ${t} 的数据集 ${r} 应为对象数组`);
1258
1369
  }
1259
- async function Or(e, t, r) {
1370
+ async function rn(e, t, r) {
1260
1371
  const { reportId: n, signal: o } = t;
1261
1372
  try {
1262
- const a = await fe(e(t), o);
1263
- E(o);
1264
- const s = pt(a);
1373
+ const a = await ge(e(t), o);
1374
+ C(o);
1375
+ const s = Pt(a);
1265
1376
  if (!s.ok)
1266
- throw new S("validate", `报表 ${n} 模板校验失败:${s.errors.slice(0, 3).map((l) => `${l.path}: ${l.message}`).join("; ")}`);
1267
- return r.push(...s.warnings.map((l) => `${n}: ${l.path}: ${l.message}`)), a;
1377
+ throw new S("validate", `报表 ${n} 模板校验失败:${s.errors.slice(0, 3).map((c) => `${c.path}: ${c.message}`).join("; ")}`);
1378
+ return r.push(...s.warnings.map((c) => `${n}: ${c.path}: ${c.message}`)), a;
1268
1379
  } catch (a) {
1269
- throw o?.aborted ? ae(o) : a instanceof S ? a : a instanceof wt ? new S("validate", `报表 ${n} 模板校验失败:${a.message}`, a) : new S("fetch", `报表 ${n} 模板加载失败:${a instanceof Error ? a.message : String(a)}`, a);
1380
+ throw o?.aborted ? ie(o) : a instanceof S ? a : a instanceof kt ? new S("validate", `报表 ${n} 模板校验失败:${a.message}`, a) : new S("fetch", `报表 ${n} 模板加载失败:${a instanceof Error ? a.message : String(a)}`, a);
1270
1381
  }
1271
1382
  }
1272
- async function Kr(e, t, r, n) {
1383
+ async function nn(e, t, r, n) {
1273
1384
  const o = t.signal;
1274
1385
  let a;
1275
1386
  try {
1276
- if (e.load) a = await fe(e.load(t), o);
1387
+ if (e.load) a = await ge(e.load(t), o);
1277
1388
  else if (e.provider) {
1278
- const s = await fe(e.provider.query(t), o);
1279
- E(o), jr(s, r), a = s.datasets, n?.(r, s);
1389
+ const s = await ge(e.provider.query(t), o);
1390
+ C(o), on(s, r), a = s.datasets, n?.(r, s);
1280
1391
  } else a = e.datasets ?? {};
1281
1392
  } catch (s) {
1282
- throw o?.aborted ? ae(o) : s instanceof S ? s : new S("fetch", `报表 ${r} 取数失败:${s instanceof Error ? s.message : String(s)}`, s);
1393
+ throw o?.aborted ? ie(o) : s instanceof S ? s : new S("fetch", `报表 ${r} 取数失败:${s instanceof Error ? s.message : String(s)}`, s);
1283
1394
  }
1284
- return E(o), a;
1395
+ return C(o), a;
1285
1396
  }
1286
- function jr(e, t) {
1397
+ function on(e, t) {
1287
1398
  if (!e || typeof e != "object" || Array.isArray(e)) throw new S("validate", `报表 ${t} Provider 应返回 datasets 结果对象`);
1288
1399
  for (const r of ["revision", "sourceToken"])
1289
1400
  if (e[r] !== void 0 && typeof e[r] != "string") throw new S("validate", `报表 ${t} Provider ${r} 应为字符串`);
1290
1401
  if (e.diagnostics !== void 0 && (!Array.isArray(e.diagnostics) || e.diagnostics.some((r) => !r || typeof r.code != "string" || typeof r.message != "string" || !["info", "warning", "error"].includes(r.severity))))
1291
1402
  throw new S("validate", `报表 ${t} Provider diagnostics 不符合结构化诊断契约`);
1292
1403
  }
1293
- function Nr(e, t, r, n, o) {
1404
+ function an(e, t, r, n, o) {
1294
1405
  try {
1295
- t = xe(n, t, { maxRows: e.dataValidation?.maxRows, signal: o });
1406
+ t = Ie(n, t, { maxRows: e.dataValidation?.maxRows, signal: o });
1296
1407
  } catch (a) {
1297
1408
  throw new S("validate", `报表 ${r} 树形数据无效:${a instanceof Error ? a.message : String(a)}`, a);
1298
1409
  }
1299
1410
  for (const [a, s] of Object.entries(e.dataSchema ?? {})) {
1300
- let l;
1411
+ let c;
1301
1412
  try {
1302
- l = Fe(Object.prototype.hasOwnProperty.call(t, a) ? t[a] : void 0, s, { ...e.dataValidation, path: `$.datasets.${a}` });
1413
+ c = je(Object.prototype.hasOwnProperty.call(t, a) ? t[a] : void 0, s, { ...e.dataValidation, path: `$.datasets.${a}` });
1303
1414
  } catch (i) {
1304
1415
  throw new S("config", `报表 ${r} 数据集 ${a} 字段契约配置无效`, i);
1305
1416
  }
1306
- if (!l.ok) throw new S("validate", `报表 ${r} 数据集 ${a} 不符合字段契约:${l.issues[0]?.message}`, { issues: l.issues });
1417
+ if (!c.ok) throw new S("validate", `报表 ${r} 数据集 ${a} 不符合字段契约:${c.issues[0]?.message}`, { issues: c.issues });
1307
1418
  }
1308
1419
  }
1309
- function lt(e) {
1310
- const t = (r) => r.grid?.cells.reduce((n, o) => n + o.reduce((a, s) => a + (s ? 1 + (s.children?.reduce((l, i) => l + t(i), 0) ?? 0) : 0), 0), 0) ?? 0;
1420
+ function wt(e, t) {
1421
+ if (!e.repeat) return !1;
1422
+ const r = Object.prototype.hasOwnProperty.call(t, e.repeat.dataset) ? t[e.repeat.dataset] : void 0;
1423
+ return Array.isArray(r) && r.length === 0;
1424
+ }
1425
+ function yt(e) {
1426
+ const t = (r) => r.grid?.cells.reduce((n, o) => n + o.reduce((a, s) => a + (s ? 1 + (s.children?.reduce((c, i) => c + t(i), 0) ?? 0) : 0), 0), 0) ?? 0;
1311
1427
  return e.pages.reduce((r, n) => r + n.components.reduce((o, a) => o + t(a), 0), 0);
1312
1428
  }
1313
- function ct(e, t, r, n) {
1429
+ function bt(e, t, r, n) {
1314
1430
  return {
1315
1431
  ...e,
1316
1432
  signal: n ?? e?.signal,
@@ -1318,48 +1434,48 @@ function ct(e, t, r, n) {
1318
1434
  ...r === void 0 ? {} : { maxCells: Math.max(1, Math.min(r, e?.maxCells ?? r)) }
1319
1435
  };
1320
1436
  }
1321
- function Hr(e, t, r, n, o, a) {
1322
- const s = o.maxPages === void 0 ? void 0 : o.maxPages - o.usedPages, l = o.maxCells === void 0 ? void 0 : o.maxCells - o.usedCells;
1437
+ function sn(e, t, r, n, o, a) {
1438
+ const s = o.maxPages === void 0 ? void 0 : o.maxPages - o.usedPages, c = o.maxCells === void 0 ? void 0 : o.maxCells - o.usedCells;
1323
1439
  try {
1324
- if (s !== void 0 && s < 1 && e.pages.length) throw new L(0, 1);
1325
- const i = ct(r.pagination, s, l, a), c = ve(e, t, i), d = lt(c.plan);
1326
- if (l !== void 0 && d > l) throw new V(l, d);
1327
- return { ...c, cells: d };
1440
+ if (s !== void 0 && s < 1 && e.pages.length && !wt(e, t)) throw new H(0, 1);
1441
+ const i = bt(r.pagination, s, c, a), l = xe(e, t, i), d = yt(l.plan);
1442
+ if (c !== void 0 && d > c) throw new V(c, d);
1443
+ return { ...l, cells: d };
1328
1444
  } catch (i) {
1329
- let c = i;
1330
- throw i instanceof L && o.maxPages !== void 0 && i.limit === s && (c = new L(o.maxPages, o.usedPages + i.actual)), i instanceof V && o.maxCells !== void 0 && (c = new V(o.maxCells, o.usedCells + i.actual)), new S("validate", `报表 ${n} 排版失败:${c instanceof Error ? c.message : String(c)}`, c);
1445
+ let l = i;
1446
+ throw i instanceof H && o.maxPages !== void 0 && i.limit === s && (l = new H(o.maxPages, o.usedPages + i.actual)), i instanceof V && o.maxCells !== void 0 && (l = new V(o.maxCells, o.usedCells + i.actual)), new S("validate", `报表 ${n} 排版失败:${l instanceof Error ? l.message : String(l)}`, l);
1331
1447
  }
1332
1448
  }
1333
- function dt(e, t, r, n) {
1449
+ function vt(e, t, r, n) {
1334
1450
  const o = /* @__PURE__ */ new Map(), a = (s) => {
1335
- let l = o.get(s);
1336
- return l === void 0 && (l = JSON.stringify([r, n, s]), o.set(s, l)), l;
1451
+ let c = o.get(s);
1452
+ return c === void 0 && (c = JSON.stringify([r, n, s]), o.set(s, c)), c;
1337
1453
  };
1338
1454
  for (const s of t.pages) e.push({
1339
1455
  ...s,
1340
1456
  ...s.meta ? { meta: { ...s.meta, reportScope: JSON.stringify([r, n]) } } : {},
1341
- components: s.components.map((l) => l.table ? {
1342
- ...l,
1343
- table: { ...l.table, id: a(l.table.id) }
1344
- } : l)
1457
+ components: s.components.map((c) => c.table ? {
1458
+ ...c,
1459
+ table: { ...c.table, id: a(c.table.id) }
1460
+ } : c)
1345
1461
  });
1346
1462
  }
1347
- async function Br(e, t, r, n, o) {
1463
+ async function cn(e, t, r, n, o) {
1348
1464
  const a = [];
1349
1465
  let s = 0;
1350
- for (const [c, d] of e.entries()) {
1351
- E(o);
1466
+ for (const [l, d] of e.entries()) {
1467
+ C(o);
1352
1468
  const u = n.maxPages === void 0 ? void 0 : n.maxPages - a.length, f = n.maxCells === void 0 ? void 0 : n.maxCells - s;
1353
- if (u !== void 0 && u < 1 && d.template.pages.length) throw new L(n.maxPages, a.length + 1);
1354
- const m = await at(d.template, d.datasets, ct(t[c]?.pagination, u, f, o));
1355
- if (s += lt(m), n.maxCells !== void 0 && s > n.maxCells) throw new V(n.maxCells, s);
1356
- dt(a, m, c, r[c]);
1469
+ if (u !== void 0 && u < 1 && d.template.pages.length && !wt(d.template, d.datasets)) throw new H(n.maxPages, a.length + 1);
1470
+ const m = await gt(d.template, d.datasets, bt(t[l]?.pagination, u, f, o));
1471
+ if (s += yt(m), n.maxCells !== void 0 && s > n.maxCells) throw new V(n.maxCells, s);
1472
+ vt(a, m, l, r[l]);
1357
1473
  }
1358
- const l = { schemaVersion: Z, ...e.some((c) => ee(c.template)) ? { requiresRecalculation: !0 } : {}, pages: a }, i = Ee(l);
1474
+ const c = { schemaVersion: ee, ...e.some((l) => re(l.template)) ? { requiresRecalculation: !0 } : {}, pages: a }, i = Ke(c);
1359
1475
  if (!i.ok) throw new S("validate", `重算渲染计划校验失败:${i.errors[0]?.message}`);
1360
- return l;
1476
+ return c;
1361
1477
  }
1362
- function Sn(e, t = {}) {
1478
+ function qn(e, t = {}) {
1363
1479
  if (t.maxPages !== void 0 && (!Number.isSafeInteger(t.maxPages) || t.maxPages < 1)) throw new S("config", "maxPages 应为正安全整数");
1364
1480
  if (t.maxCells !== void 0 && (!Number.isSafeInteger(t.maxCells) || t.maxCells < 1)) throw new S("config", "maxCells 应为正安全整数");
1365
1481
  function r(o) {
@@ -1367,57 +1483,57 @@ function Sn(e, t = {}) {
1367
1483
  if (!a) throw new S("config", `未注册报表 ${o}`);
1368
1484
  return a;
1369
1485
  }
1370
- return Object.assign(async ({ reportIds: o, params: a, signal: s, onWarning: l, onQueryResult: i, ...c }) => {
1371
- E(s);
1372
- const d = Mt({ ...c, signal: s }), u = [...o], f = { ...a };
1486
+ return Object.assign(async ({ reportIds: o, params: a, signal: s, onWarning: c, onQueryResult: i, ...l }) => {
1487
+ C(s);
1488
+ const d = Ft({ ...l, signal: s }), u = [...o], f = { ...a };
1373
1489
  if (u.length === 0) throw new S("config", "缺少报表 ID");
1374
- const m = u.map(r), w = d.runSync("validate", () => m.map((p) => Se(
1375
- p.params ?? (typeof p.template == "function" ? [] : p.template.params) ?? [],
1490
+ const m = u.map(r), p = d.runSync("validate", () => m.map((w) => Pe(
1491
+ w.params ?? (typeof w.template == "function" ? [] : w.template.params) ?? [],
1376
1492
  f
1377
1493
  ))), g = [], h = [];
1378
1494
  let v = 0;
1379
1495
  const M = [];
1380
- for (const [p, $] of m.entries()) {
1381
- E(s);
1382
- const x = u[p], k = { reportId: x, params: w[p], signal: s }, P = typeof $.template == "function" ? await d.run("query", () => Or($.template, k, M), x) : $.template;
1383
- k.params = d.runSync("validate", () => Se($.params ?? P.params ?? [], k.params), x);
1384
- const O = await d.run("query", () => Kr($, k, x, i), x);
1496
+ for (const [w, $] of m.entries()) {
1497
+ C(s);
1498
+ const x = u[w], I = { reportId: x, params: p[w], signal: s }, P = typeof $.template == "function" ? await d.run("query", () => rn($.template, I, M), x) : $.template;
1499
+ I.params = d.runSync("validate", () => Pe($.params ?? P.params ?? [], I.params), x);
1500
+ const K = await d.run("query", () => nn($, I, x, i), x);
1385
1501
  d.runSync("validate", () => {
1386
- Ar(O, x), t.onDatasets?.(x, O, P), Nr($, O, x, P, s);
1387
- }, x), E(s);
1388
- const se = d.runSync("layout", () => Hr(P, O, $, x, { maxPages: t.maxPages, usedPages: g.length, maxCells: t.maxCells, usedCells: v }, s), x);
1389
- v += se.cells, h.push({ template: P, datasets: O }), dt(g, se.plan, p, x), M.push(...se.warnings.map((ft) => `${x}: ${ft}`));
1502
+ tn(K, x), t.onDatasets?.(x, K, P), an($, K, x, P, s);
1503
+ }, x), C(s);
1504
+ const ce = d.runSync("layout", () => sn(P, K, $, x, { maxPages: t.maxPages, usedPages: g.length, maxCells: t.maxCells, usedCells: v }, s), x);
1505
+ v += ce.cells, h.push({ template: P, datasets: K }), vt(g, ce.plan, w, x), M.push(...ce.warnings.map(($t) => `${x}: ${$t}`));
1390
1506
  }
1391
- E(s);
1392
- const y = { schemaVersion: Z, ...h.some((p) => ee(p.template)) ? { requiresRecalculation: !0 } : {}, pages: g }, j = d.runSync("validate", () => {
1393
- const p = Ee(y);
1394
- if (!p.ok) throw new S("validate", `渲染计划校验失败:${p.errors.slice(0, 3).map(($) => `${$.path}: ${$.message}`).join("; ")}`);
1395
- return p;
1507
+ C(s);
1508
+ const y = { schemaVersion: ee, ...h.some((w) => re(w.template)) ? { requiresRecalculation: !0 } : {}, pages: g }, N = d.runSync("validate", () => {
1509
+ const w = Ke(y);
1510
+ if (!w.ok) throw new S("validate", `渲染计划校验失败:${w.errors.slice(0, 3).map(($) => `${$.path}: ${$.message}`).join("; ")}`);
1511
+ return w;
1396
1512
  });
1397
- M.push(...j.warnings.map((p) => `${p.path}: ${p.message}`));
1398
- const A = m.map((p) => ({ ...p, pagination: { ...p.pagination } })), R = { maxPages: t.maxPages, maxCells: t.maxCells };
1513
+ M.push(...N.warnings.map((w) => `${w.path}: ${w.message}`));
1514
+ const O = m.map((w) => ({ ...w, pagination: { ...w.pagination } })), k = { maxPages: t.maxPages, maxCells: t.maxCells };
1399
1515
  try {
1400
- it(y, { parts: h, rebuild: (p, $) => Br(p, A, u, R, $) });
1516
+ ht(y, { parts: h, rebuild: (w, $) => cn(w, O, u, k, $) });
1401
1517
  } catch {
1402
1518
  M.push("来源数据无法建立本地重算口径;当前预览仅支持计划内编辑,请使用可序列化模板数据启用规则重算");
1403
1519
  }
1404
- const C = l ?? t.onWarning ?? ((p) => console.warn("[mach-report]", p));
1405
- for (const p of M)
1406
- E(s), C(p);
1407
- return E(s), y;
1520
+ const R = c ?? t.onWarning ?? ((w) => console.warn("[mach-report]", w));
1521
+ for (const w of M)
1522
+ C(s), R(w);
1523
+ return C(s), y;
1408
1524
  }, {
1409
- getParamDefs: (o) => mt(e, o)
1525
+ getParamDefs: (o) => xt(e, o)
1410
1526
  });
1411
1527
  }
1412
- function Re(e) {
1528
+ function Ae(e) {
1413
1529
  if (e === void 0) return;
1414
1530
  const t = typeof e == "string" ? e : JSON.stringify(e);
1415
1531
  return t.length > 160 ? t.slice(0, 157) + "…" : t;
1416
1532
  }
1417
- function Wr(e) {
1418
- return /\.tree\.(?:idField|parentField|childrenField|labelField|input)$/.test(e) ? "binding" : /\.tree\.parentValues$/.test(e) ? "calculation" : /\.tree\.indentMm$/.test(e) ? "format" : /\.(?:computed|computeOptions|groups|groupBy|aggregates|grandTotal)(?:\.|\[|$)/.test(e) ? "calculation" : /\.(?:dataset|field|rowKey|revisionField|sourceTokenField|foreignKey|parentKey)$/.test(e) ? "binding" : /\.(?:style|headerStyle|format|rules|align|headerAlign|semanticRole|unit)(?:\.|\[|$)/.test(e) ? "format" : e.startsWith("$.template") ? "structure" : "metadata";
1533
+ function ln(e) {
1534
+ return /\.(?:repeat|binding)(?:\.|$)/.test(e) ? /\.format(?:\.|$)/.test(e) ? "format" : "binding" : /\.tree\.(?:idField|parentField|childrenField|labelField|input)$/.test(e) ? "binding" : /\.tree\.parentValues$/.test(e) ? "calculation" : /\.tree\.indentMm$/.test(e) ? "format" : /\.(?:computed|computeOptions|groups|groupBy|aggregates|grandTotal)(?:\.|\[|$)/.test(e) ? "calculation" : /\.(?:dataset|field|rowKey|revisionField|sourceTokenField|foreignKey|parentKey)$/.test(e) ? "binding" : /\.(?:style|headerStyle|format|rules|align|headerAlign|semanticRole|unit)(?:\.|\[|$)/.test(e) ? "format" : e.startsWith("$.template") ? "structure" : "metadata";
1419
1535
  }
1420
- function Ce(e) {
1536
+ function Oe(e) {
1421
1537
  const t = /* @__PURE__ */ new Map();
1422
1538
  for (const r of e) {
1423
1539
  if (!r || typeof r != "object" || !("field" in r) || typeof r.field != "string" || t.has(r.field)) return;
@@ -1425,157 +1541,166 @@ function Ce(e) {
1425
1541
  }
1426
1542
  return t;
1427
1543
  }
1428
- function Lr(e, t, r) {
1544
+ function dn(e, t, r) {
1429
1545
  return !e.startsWith("$.template.params") || t === "moved" ? !1 : /\.(?:type|required|min|max|minLength|maxLength|options|defaultValue)(?:\[|$)/.test(e) ? !0 : t !== "added" ? !1 : Array.isArray(r) ? r.some((n) => !!n && typeof n == "object" && "required" in n && n.required === !0) : !!r && typeof r == "object" && "required" in r && r.required === !0;
1430
1546
  }
1431
- function Vr(e, t, r = {}) {
1432
- const n = le(e), o = le(t), a = r.maxChanges ?? 500;
1547
+ function un(e, t, r = {}) {
1548
+ const n = de(e), o = de(t), a = r.maxChanges ?? 500;
1433
1549
  if (!Number.isSafeInteger(a) || a < 1 || a > 1e4) throw new RangeError("maxChanges must be between 1 and 10000");
1434
1550
  const s = { changes: [], totalChanges: 0, breakingChanges: 0, truncated: !1 };
1435
- function l(d, u, f, m) {
1436
- const w = Wr(u), g = d !== "moved" && (w === "binding" || u === "$.id" || d === "removed" && w === "structure" || Lr(u, d, m));
1437
- s.totalChanges++, g && s.breakingChanges++, s.changes.length < a && s.changes.push({ kind: d, category: w, path: u, before: Re(f), after: Re(m), breaking: g });
1551
+ function c(d, u, f, m) {
1552
+ const p = ln(u), g = d !== "moved" && (p === "binding" || u === "$.id" || d === "removed" && p === "structure" || dn(u, d, m));
1553
+ s.totalChanges++, g && s.breakingChanges++, s.changes.length < a && s.changes.push({ kind: d, category: p, path: u, before: Ae(f), after: Ae(m), breaking: g });
1438
1554
  }
1439
1555
  function i(d, u, f) {
1440
- const m = Ce(d), w = Ce(u);
1441
- if (!m || !w) return !1;
1556
+ const m = Oe(d), p = Oe(u);
1557
+ if (!m || !p) return !1;
1442
1558
  const g = new Map(u.map((h, v) => [h.field, v]));
1443
1559
  Array.from(m).forEach(([h, v], M) => {
1444
1560
  const y = `${f}[${JSON.stringify(h)}]`;
1445
- w.has(h) ? (g.get(h) !== M && l("moved", y, M, g.get(h)), c(v, w.get(h), y)) : l("removed", y, v, void 0);
1561
+ p.has(h) ? (g.get(h) !== M && c("moved", y, M, g.get(h)), l(v, p.get(h), y)) : c("removed", y, v, void 0);
1446
1562
  });
1447
- for (const [h, v] of w) m.has(h) || l("added", `${f}[${JSON.stringify(h)}]`, void 0, v);
1563
+ for (const [h, v] of p) m.has(h) || c("added", `${f}[${JSON.stringify(h)}]`, void 0, v);
1448
1564
  return !0;
1449
1565
  }
1450
- function c(d, u, f) {
1566
+ function l(d, u, f) {
1451
1567
  if (!(Object.is(d, u) || f === "$.revision")) {
1452
1568
  if (d === void 0 || u === void 0) {
1453
- l(d === void 0 ? "added" : "removed", f, d, u);
1569
+ c(d === void 0 ? "added" : "removed", f, d, u);
1454
1570
  return;
1455
1571
  }
1456
1572
  if (Array.isArray(d) && Array.isArray(u)) {
1457
1573
  if ((f.endsWith(".columns") || f.endsWith(".params")) && i(d, u, f)) return;
1458
- for (let m = 0; m < Math.max(d.length, u.length); m++) c(d[m], u[m], `${f}[${m}]`);
1574
+ for (let m = 0; m < Math.max(d.length, u.length); m++) l(d[m], u[m], `${f}[${m}]`);
1459
1575
  } else if (d && u && typeof d == "object" && typeof u == "object" && !Array.isArray(d) && !Array.isArray(u)) {
1460
- const m = d, w = u;
1461
- for (const g of /* @__PURE__ */ new Set([...Object.keys(m), ...Object.keys(w)])) c(m[g], w[g], `${f}.${g}`);
1462
- } else l("modified", f, d, u);
1576
+ const m = d, p = u;
1577
+ for (const g of /* @__PURE__ */ new Set([...Object.keys(m), ...Object.keys(p)])) l(m[g], p[g], `${f}.${g}`);
1578
+ } else c("modified", f, d, u);
1463
1579
  }
1464
1580
  }
1465
- return c(n, o, "$"), s.truncated = s.totalChanges > s.changes.length, s;
1581
+ return l(n, o, "$"), s.truncated = s.totalChanges > s.changes.length, s;
1466
1582
  }
1467
- function F(e) {
1583
+ function E(e) {
1468
1584
  return !!e && typeof e == "object" && !Array.isArray(e);
1469
1585
  }
1470
1586
  function T(e, t, r) {
1471
1587
  typeof e == "string" ? r.push({ field: e, path: t }) : Array.isArray(e) && e.forEach((n, o) => T(n, `${t}[${o}]`, r));
1472
1588
  }
1473
- function N(e, t, r) {
1589
+ function L(e, t, r) {
1474
1590
  if (Array.isArray(e)) {
1475
- e.forEach((n, o) => N(n, `${t}[${o}]`, r));
1591
+ e.forEach((n, o) => L(n, `${t}[${o}]`, r));
1476
1592
  return;
1477
1593
  }
1478
- if (F(e))
1594
+ if (E(e))
1479
1595
  for (const [n, o] of Object.entries(e))
1480
- ["field", "weightField"].includes(n) ? T(o, `${t}.${n}`, r) : n !== "value" && n !== "style" && N(o, `${t}.${n}`, r);
1596
+ ["field", "weightField"].includes(n) ? T(o, `${t}.${n}`, r) : n !== "value" && n !== "style" && L(o, `${t}.${n}`, r);
1481
1597
  }
1482
1598
  function Y(e, t, r) {
1483
1599
  Array.isArray(e) && e.forEach((n, o) => {
1484
- F(n) && (typeof n.field == "string" && n.valueField !== void 0 && n.valueField !== n.field && r.summaries.add(n.field), T(n.valueField ?? n.field, `${t}[${o}].valueField`, r.fields), T(n.weightField, `${t}[${o}].weightField`, r.fields));
1600
+ E(n) && (typeof n.field == "string" && n.valueField !== void 0 && n.valueField !== n.field && r.summaries.add(n.field), T(n.valueField ?? n.field, `${t}[${o}].valueField`, r.fields), T(n.weightField, `${t}[${o}].weightField`, r.fields));
1485
1601
  });
1486
1602
  }
1487
- function Gr(e, t, r) {
1603
+ function fn(e, t, r) {
1488
1604
  for (const o of ["rowKey", "revisionField", "sourceTokenField"]) T(e[o], `${t}.${o}`, r.fields);
1489
1605
  if (!e.matrix && Array.isArray(e.columns) && e.columns.forEach((o, a) => {
1490
- F(o) && (typeof o.field == "string" && r.fields.push({ field: o.field, path: `${t}.columns[${a}].field`, summary: !0 }), N(o.rules, `${t}.columns[${a}].rules`, r.fields), N(o.visibleWhen, `${t}.columns[${a}].visibleWhen`, r.fields));
1491
- }), N(e.rowVisibleWhen, `${t}.rowVisibleWhen`, r.fields), Array.isArray(e.computed) && e.computed.forEach((o, a) => {
1492
- F(o) && (typeof o.field == "string" && r.generated.add(o.field), N(o.expression, `${t}.computed[${a}].expression`, r.fields), T(o.dependsOn, `${t}.computed[${a}].dependsOn`, r.fields), T(o.groupBy, `${t}.computed[${a}].groupBy`, r.fields));
1606
+ E(o) && (typeof o.field == "string" && r.fields.push({ field: o.field, path: `${t}.columns[${a}].field`, summary: !0 }), L(o.rules, `${t}.columns[${a}].rules`, r.fields), L(o.visibleWhen, `${t}.columns[${a}].visibleWhen`, r.fields));
1607
+ }), L(e.rowVisibleWhen, `${t}.rowVisibleWhen`, r.fields), Array.isArray(e.computed) && e.computed.forEach((o, a) => {
1608
+ E(o) && (typeof o.field == "string" && r.generated.add(o.field), L(o.expression, `${t}.computed[${a}].expression`, r.fields), T(o.dependsOn, `${t}.computed[${a}].dependsOn`, r.fields), T(o.groupBy, `${t}.computed[${a}].groupBy`, r.fields));
1493
1609
  }), (Array.isArray(e.groups) ? e.groups : e.groupBy ? [e.groupBy] : []).forEach((o, a) => {
1494
- F(o) && (T(o.field, `${t}.groups[${a}].field`, r.fields), T(o.subtotal, `${t}.groups[${a}].subtotal`, r.fields), Y(o.aggregates, `${t}.groups[${a}].aggregates`, r));
1495
- }), F(e.grandTotal) && (T(e.grandTotal.fields, `${t}.grandTotal.fields`, r.fields), Y(e.grandTotal.aggregates, `${t}.grandTotal.aggregates`, r)), F(e.matrix) && (T(e.matrix.rowFields, `${t}.matrix.rowFields`, r.fields), T(e.matrix.columnFields, `${t}.matrix.columnFields`, r.fields), Y(e.matrix.measures, `${t}.matrix.measures`, r)), F(e.tree)) {
1610
+ E(o) && (T(o.field, `${t}.groups[${a}].field`, r.fields), T(o.subtotal, `${t}.groups[${a}].subtotal`, r.fields), Y(o.aggregates, `${t}.groups[${a}].aggregates`, r));
1611
+ }), E(e.grandTotal) && (T(e.grandTotal.fields, `${t}.grandTotal.fields`, r.fields), Y(e.grandTotal.aggregates, `${t}.grandTotal.aggregates`, r)), E(e.matrix) && (T(e.matrix.rowFields, `${t}.matrix.rowFields`, r.fields), T(e.matrix.columnFields, `${t}.matrix.columnFields`, r.fields), Y(e.matrix.measures, `${t}.matrix.measures`, r)), E(e.tree)) {
1496
1612
  for (const o of ["idField", "parentField", "labelField"]) T(e.tree[o], `${t}.tree.${o}`, r.fields);
1497
1613
  Y(e.tree.aggregates, `${t}.tree.aggregates`, r);
1498
1614
  }
1499
- F(e.detail) && T(e.detail.parentKey, `${t}.detail.parentKey`, r.fields);
1615
+ E(e.detail) && T(e.detail.parentKey, `${t}.detail.parentKey`, r.fields);
1500
1616
  }
1501
- function ut(e) {
1502
- const t = [];
1503
- function r(n, o) {
1504
- if (Array.isArray(n)) {
1505
- n.forEach((a, s) => r(a, `${o}[${s}]`));
1617
+ function Mt(e) {
1618
+ const t = [], r = e.repeat, n = r ? { dataset: r.dataset, path: "$.template.repeat", fields: [], generated: /* @__PURE__ */ new Set(), summaries: /* @__PURE__ */ new Set() } : void 0;
1619
+ n && r && (T(r.rowKey, "$.template.repeat.rowKey", n.fields), typeof r.copies == "object" && T(r.copies.field, "$.template.repeat.copies.field", n.fields), t.push(n));
1620
+ function o(a, s) {
1621
+ if (Array.isArray(a)) {
1622
+ a.forEach((c, i) => o(c, `${s}[${i}]`));
1506
1623
  return;
1507
1624
  }
1508
- if (F(n)) {
1509
- if (typeof n.dataset == "string" && Array.isArray(n.columns)) {
1510
- const a = { dataset: n.dataset, path: o, fields: [], generated: /* @__PURE__ */ new Set(), summaries: /* @__PURE__ */ new Set() };
1511
- Gr(n, o, a), typeof n.foreignKey == "string" && T(n.foreignKey, `${o}.foreignKey`, a.fields), t.push(a);
1625
+ if (E(a)) {
1626
+ if (n && E(a.binding) && T(a.binding.field, `${s}.binding.field`, n.fields), typeof a.dataset == "string" && Array.isArray(a.columns)) {
1627
+ const c = { dataset: a.dataset, path: s, fields: [], generated: /* @__PURE__ */ new Set(), summaries: /* @__PURE__ */ new Set() };
1628
+ fn(a, s, c), typeof a.foreignKey == "string" && T(a.foreignKey, `${s}.foreignKey`, c.fields), t.push(c);
1512
1629
  }
1513
- for (const [a, s] of Object.entries(n)) r(s, `${o}.${a}`);
1630
+ for (const [c, i] of Object.entries(a)) o(i, `${s}.${c}`);
1514
1631
  }
1515
1632
  }
1516
- return r(e, "$.template"), t;
1633
+ return o(e, "$.template"), t;
1517
1634
  }
1518
- function Dr(e, t, r) {
1519
- for (const n of ut(e)) {
1635
+ function mn(e, t, r) {
1636
+ for (const n of Mt(e)) {
1520
1637
  const o = Object.prototype.hasOwnProperty.call(t, n.dataset) ? t[n.dataset] : void 0;
1521
1638
  if (!o) {
1522
1639
  r.push({ code: "dataset", severity: "error", path: `${n.path}.dataset`, message: `未声明数据集 ${n.dataset}` });
1523
1640
  continue;
1524
1641
  }
1525
1642
  const a = new Set(o.fields.map((s) => s.field));
1526
- n.fields.forEach(({ field: s, path: l, summary: i }) => {
1527
- !a.has(s) && !n.generated.has(s) && !(i && n.summaries.has(s)) && r.push({ code: "field", severity: "error", path: l, field: s, message: `数据集 ${n.dataset} 缺少字段 ${s}` });
1643
+ n.fields.forEach(({ field: s, path: c, summary: i }) => {
1644
+ !a.has(s) && !n.generated.has(s) && !(i && n.summaries.has(s)) && r.push({ code: "field", severity: "error", path: c, field: s, message: `数据集 ${n.dataset} 缺少字段 ${s}` });
1528
1645
  });
1529
1646
  }
1530
1647
  }
1531
- function zr(e, t, r, n) {
1648
+ function gn(e, t, r, n) {
1532
1649
  const o = r.maxSampleRows ?? 1e3;
1533
1650
  let a;
1534
1651
  try {
1535
- a = xe(t, e.datasets, { maxRows: o });
1652
+ a = Ie(t, e.datasets, { maxRows: o });
1536
1653
  } catch (i) {
1537
1654
  return n.push({ code: "sample", severity: "error", path: "$.fixtures", fixture: e.name, message: i instanceof Error ? i.message : String(i) }), !1;
1538
1655
  }
1539
- const s = Object.values(a).reduce((i, c) => i + c.length, 0);
1656
+ const s = Object.values(a).reduce((i, l) => i + l.length, 0);
1540
1657
  if (s > o)
1541
1658
  return n.push({ code: "sample", severity: "error", path: "$.fixtures", fixture: e.name, message: `样例 ${s} 行超过预算 ${o},请显式选择验收样例` }), !1;
1542
- const l = new Set(ut(t).map((i) => i.dataset));
1543
- for (const [i, c] of Object.entries(r.dataSchemas ?? {}).filter(([d]) => l.has(d)))
1659
+ const c = new Set(Mt(t).map((i) => i.dataset));
1660
+ for (const [i, l] of Object.entries(r.dataSchemas ?? {}).filter(([d]) => c.has(d)))
1544
1661
  try {
1545
- const d = Fe(a[i], c, { path: `$.datasets.${i}`, maxRows: o });
1662
+ const d = je(a[i], l, { path: `$.datasets.${i}`, maxRows: o });
1546
1663
  if (n.push(...d.issues.map((u) => ({ ...u, code: "sample", severity: "error", fixture: e.name }))), !d.ok) return !1;
1547
1664
  } catch (d) {
1548
1665
  return n.push({ code: "dataset", severity: "error", path: `$.dataSchemas.${i}`, message: String(d) }), !1;
1549
1666
  }
1550
1667
  return !0;
1551
1668
  }
1552
- function qr(e, t, r) {
1553
- const n = t.pages[r.pageIndex]?.components[r.componentIndex], o = /^table:(\d+):(\d+)(?::|$)/.exec(n?.table?.id ?? "");
1554
- if (o) return { path: `$.template.pages[${o[1]}].components[${o[2]}]`, pageIndex: Number(o[1]), componentIndex: Number(o[2]) };
1555
- for (const [a, s] of e.pages.entries()) {
1556
- const l = s.components.findIndex((i) => i === n || n?.nid !== void 0 && "nid" in i && i.nid === n.nid);
1557
- if (l >= 0) return { path: `$.template.pages[${a}].components[${l}]`, pageIndex: a, componentIndex: l };
1669
+ function pn(e, t) {
1670
+ const r = e.pages[t.pageIndex]?.components[t.componentIndex]?.meta?.labelSource;
1671
+ if (r && typeof r == "object" && "pageIndex" in r && "componentIndex" in r && typeof r.pageIndex == "number" && typeof r.componentIndex == "number") return { path: `$.template.pages[${r.pageIndex}].components[${r.componentIndex}]`, pageIndex: r.pageIndex, componentIndex: r.componentIndex };
1672
+ const n = e.pages[t.pageIndex]?.meta?.record;
1673
+ if (n && typeof n == "object" && "templatePageIndex" in n && typeof n.templatePageIndex == "number") return { path: `$.template.pages[${n.templatePageIndex}].components[${t.componentIndex}]`, pageIndex: n.templatePageIndex, componentIndex: t.componentIndex };
1674
+ }
1675
+ function hn(e, t, r) {
1676
+ const n = pn(t, r);
1677
+ if (n) return n;
1678
+ const o = t.pages[r.pageIndex]?.components[r.componentIndex], a = /^table:(\d+):(\d+)(?::|$)/.exec(o?.table?.id ?? "");
1679
+ if (a) return { path: `$.template.pages[${a[1]}].components[${a[2]}]`, pageIndex: Number(a[1]), componentIndex: Number(a[2]) };
1680
+ for (const [s, c] of e.pages.entries()) {
1681
+ const i = c.components.findIndex((l) => l === o || o?.nid !== void 0 && "nid" in l && l.nid === o.nid);
1682
+ if (i >= 0) return { path: `$.template.pages[${s}].components[${i}]`, pageIndex: s, componentIndex: i };
1558
1683
  }
1559
1684
  return { path: "$.template" };
1560
1685
  }
1561
- function Jr(e, t, r, n, o) {
1562
- const a = yt(e.template.params ?? [], t.params ?? {});
1563
- if (o.issues.push(...a.issues.map((s) => ({ ...s, code: "params", severity: "error", fixture: t.name, path: s.path.replace(/^\$\.params/, `$.fixtures[${r}].params`) }))), !!a.ok && zr(t, e.template, n, o.issues))
1686
+ function wn(e, t, r, n, o) {
1687
+ const a = Rt(e.template.params ?? [], t.params ?? {});
1688
+ if (o.issues.push(...a.issues.map((s) => ({ ...s, code: "params", severity: "error", fixture: t.name, path: s.path.replace(/^\$\.params/, `$.fixtures[${r}].params`) }))), !!a.ok && gn(t, e.template, n, o.issues))
1564
1689
  try {
1565
- const { plan: s, warnings: l } = ve(e.template, t.datasets, { maxPages: n.maxPages ?? 100, maxCells: n.maxCells ?? 25e4 }), i = (n.formats ?? ["pdf", "xlsx"]).flatMap((c) => At(s, c));
1566
- o.issues.push(...l.map((c) => ({ code: "layout", severity: "warning", path: "$.template", fixture: t.name, message: c }))), o.issues.push(...i.map((c) => ({ code: "output", severity: n.strictOutputs ? "error" : "warning", ...qr(e.template, s, c), fixture: t.name, message: `${c.format}: ${c.message}` }))), o.samples.push({ name: t.name, pages: s.pages.length, rows: Ir(e.template, t.datasets), diagnostics: i });
1690
+ const { plan: s, warnings: c } = xe(e.template, t.datasets, { maxPages: n.maxPages ?? 100, maxCells: n.maxCells ?? 25e4 }), i = (n.formats ?? ["pdf", "xlsx"]).flatMap((l) => Jt(s, l));
1691
+ o.issues.push(...c.map((l) => ({ code: "layout", severity: "warning", path: "$.template", fixture: t.name, message: l }))), o.issues.push(...i.map((l) => ({ code: "output", severity: n.strictOutputs ? "error" : "warning", ...hn(e.template, s, l), fixture: t.name, message: `${l.format}: ${l.message}`, diagnostic: l }))), o.samples.push({ name: t.name, pages: s.pages.length, rows: en(e.template, t.datasets), diagnostics: i });
1567
1692
  } catch (s) {
1568
1693
  o.issues.push({ code: "layout", severity: "error", path: "$.template", fixture: t.name, message: s instanceof Error ? s.message : String(s) });
1569
1694
  }
1570
1695
  }
1571
- function Tn(e, t = {}) {
1696
+ function _n(e, t = {}) {
1572
1697
  const r = { ok: !1, issues: [], samples: [] };
1573
1698
  try {
1574
1699
  for (const [o, a] of [["maxPages", t.maxPages], ["maxCells", t.maxCells], ["maxSampleRows", t.maxSampleRows]]) if (a !== void 0 && (!Number.isSafeInteger(a) || a < 1)) throw new RangeError(`${o} must be a positive safe integer`);
1575
1700
  if ((t.fixtures?.length ?? 0) > 20) throw new RangeError("At most 20 review fixtures are allowed");
1576
- const n = le(e);
1577
- t.previous && (r.changes = Vr(t.previous, n), r.changes.breakingChanges && !t.allowBreakingChanges && r.issues.push({ code: "compatibility", severity: "error", path: "$.template", message: `${r.changes.breakingChanges} 项字段或结构变更需要明确确认兼容性` })), t.dataSchemas && Dr(n.template, t.dataSchemas, r.issues);
1578
- for (const [o, a] of (t.fixtures ?? []).entries()) Jr(n, a, o, t, r);
1701
+ const n = de(e);
1702
+ t.previous && (r.changes = un(t.previous, n), r.changes.breakingChanges && !t.allowBreakingChanges && r.issues.push({ code: "compatibility", severity: "error", path: "$.template", message: `${r.changes.breakingChanges} 项字段或结构变更需要明确确认兼容性` })), t.dataSchemas && mn(n.template, t.dataSchemas, r.issues);
1703
+ for (const [o, a] of (t.fixtures ?? []).entries()) wn(n, a, o, t, r);
1579
1704
  t.fixtures?.length || r.issues.push({ code: "sample", severity: "warning", path: "$.fixtures", message: "未提供验收样例,仅完成结构和字段检查,尚未验证排版与输出" });
1580
1705
  } catch (n) {
1581
1706
  r.issues.push({ code: "template", severity: "error", path: "$", message: n instanceof Error ? n.message : String(n) });
@@ -1583,34 +1708,35 @@ function Tn(e, t = {}) {
1583
1708
  return r.ok = r.issues.every((n) => n.severity !== "error"), r;
1584
1709
  }
1585
1710
  export {
1586
- $n as A,
1587
- Ir as B,
1711
+ zn as A,
1712
+ en as B,
1713
+ Zt as D,
1588
1714
  V as P,
1589
- b as R,
1590
- L as a,
1591
- S as b,
1592
- hn as c,
1593
- wn as d,
1594
- $r as e,
1595
- fn as f,
1596
- gn as g,
1597
- pn as h,
1598
- B as i,
1599
- Mn as j,
1600
- Sn as k,
1601
- xn as l,
1602
- Vr as m,
1603
- mn as n,
1604
- J as o,
1605
- Xe as p,
1606
- Me as q,
1607
- vn as r,
1608
- ve as s,
1609
- sr as t,
1610
- Kt as u,
1611
- it as v,
1612
- bn as w,
1613
- I as x,
1614
- Tn as y,
1615
- yn as z
1715
+ S as R,
1716
+ b as a,
1717
+ H as b,
1718
+ Ln as c,
1719
+ Jn as d,
1720
+ Bn as e,
1721
+ Gr as f,
1722
+ Kn as g,
1723
+ Nn as h,
1724
+ Hn as i,
1725
+ W as j,
1726
+ Gn as k,
1727
+ qn as l,
1728
+ un as m,
1729
+ jn as n,
1730
+ _ as o,
1731
+ it as p,
1732
+ Se as q,
1733
+ Vn as r,
1734
+ xe as s,
1735
+ kr as t,
1736
+ _t as u,
1737
+ ht as v,
1738
+ Dn as w,
1739
+ A as x,
1740
+ _n as y,
1741
+ Wn as z
1616
1742
  };