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