@agile-team/mach-report 2.21.1 → 2.22.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 (110) hide show
  1. package/README.md +16 -2
  2. package/dist/{ExcelBindingWizard-Bu0LUlzl.cjs → ExcelBindingWizard-CW79I6Gl.cjs} +1 -1
  3. package/dist/{ExcelBindingWizard-mnAO2qOX.js → ExcelBindingWizard-CZyppD7I.js} +3 -3
  4. package/dist/{ParamEditor-38ZfNrPU.cjs → ParamEditor-CiYCJI0b.cjs} +1 -1
  5. package/dist/{ParamEditor-C8l0EC8m.js → ParamEditor-DQit-Gdf.js} +2 -2
  6. package/dist/{ReportBatchPanel-CfUVhvkO.js → ReportBatchPanel-DKTpV7MU.js} +2 -2
  7. package/dist/{ReportBatchPanel-nCC06Nfp.cjs → ReportBatchPanel-Db6TAfG5.cjs} +1 -1
  8. package/dist/ReportLabelStudio-B0i9ohQj.cjs +1 -0
  9. package/dist/ReportLabelStudio-BYnRqmje.js +780 -0
  10. package/dist/{ReportParamPanel-peB-KEmm.js → ReportParamPanel-BHSKVL8k.js} +231 -224
  11. package/dist/ReportParamPanel-lngONOEz.cjs +1 -0
  12. package/dist/ReportPreview-BDgKssYR.js +5887 -0
  13. package/dist/ReportPreview-Dw-4icG6.cjs +6 -0
  14. package/dist/{ReportTemplateLibrary-B5t_EcIs.js → ReportTemplateLibrary-BZuKn0YK.js} +1 -1
  15. package/dist/{ReportTemplateLibrary-DVlsf72p.cjs → ReportTemplateLibrary-DEXH07ND.cjs} +1 -1
  16. package/dist/{RuleEditor-kT1JsZ9f.js → RuleEditor-CIQn547x.js} +3 -3
  17. package/dist/{RuleEditor-xFkCVlii.cjs → RuleEditor-zSUmPjKa.cjs} +1 -1
  18. package/dist/{TemplateOutlinePanel-CDI6mfWx.cjs → TemplateOutlinePanel-B5SfGYVN.cjs} +1 -1
  19. package/dist/{TemplateOutlinePanel-BesgGR1P.js → TemplateOutlinePanel-D0PgOSQE.js} +2 -2
  20. package/dist/{TemplateReusePanel-BNFU6V-W.js → TemplateReusePanel-BKlAEF8-.js} +2 -2
  21. package/dist/{TemplateReusePanel-BG9Or5-P.cjs → TemplateReusePanel-DAy_Hwqz.cjs} +1 -1
  22. package/dist/TemplateReviewPanel-CowmHaQQ.cjs +1 -0
  23. package/dist/{TemplateReviewPanel-CwvwyCSs.js → TemplateReviewPanel-div-EH_m.js} +2 -2
  24. package/dist/artifact-integrity.json +76 -76
  25. package/dist/{auto-Tq7ReIC1.cjs → auto-DcUHlKob.cjs} +1 -1
  26. package/dist/{auto-BkdGiNtr.js → auto-moShblh1.js} +4 -4
  27. package/dist/{designer-HQi-03R6.js → designer-B7jJeAeG.js} +1500 -1455
  28. package/dist/{designer-DU3yDWgs.cjs → designer-BWQVpJeN.cjs} +2 -2
  29. package/dist/designer.cjs +1 -1
  30. package/dist/designer.d.cts +149 -2
  31. package/dist/designer.d.ts +149 -2
  32. package/dist/designer.js +13 -12
  33. package/dist/{encoding-BSeUwrN7.js → encoding-DbnhbwI8.js} +2 -2
  34. package/dist/{encoding-B79hW4zq.cjs → encoding-ncQAvyOv.cjs} +1 -1
  35. package/dist/index.cjs +5 -5
  36. package/dist/index.d.cts +38 -0
  37. package/dist/index.d.ts +38 -0
  38. package/dist/index.js +299 -279
  39. package/dist/{json-snapshot-Kgn459Oj.js → json-snapshot-DvQbZlD7.js} +2 -2
  40. package/dist/{json-snapshot-I5VI84Vp.cjs → json-snapshot-nyV63AbB.cjs} +1 -1
  41. package/dist/{plugin-BaRUGORD.cjs → plugin-AcAQ2m9X.cjs} +1 -1
  42. package/dist/{plugin-D4kAxfLG.js → plugin-w5Nyt08U.js} +1 -1
  43. package/dist/{prefill-CJSazcVY.js → prefill-BXBxx5We.js} +1 -1
  44. package/dist/{prefill-Bpyn58AZ.cjs → prefill-DUvejVt1.cjs} +1 -1
  45. package/dist/prepared-YXy-fVLw.cjs +1 -0
  46. package/dist/{prepared-BwjwEzFz.js → prepared-rXCKqdHY.js} +35 -34
  47. package/dist/{protocol-C8VWF9An.cjs → protocol-C9ZaylID.cjs} +1 -1
  48. package/dist/{protocol-Bs9-ohHN.js → protocol-fjaeKkjf.js} +3 -3
  49. package/dist/{region-binding-workflow-JNowHd0A.cjs → region-binding-workflow-BiJQ7NU6.cjs} +1 -1
  50. package/dist/{region-binding-workflow-Cy4GIOUo.js → region-binding-workflow-aA8nxmkZ.js} +1 -1
  51. package/dist/report-encoding-worker.cjs +1 -1
  52. package/dist/report-encoding-worker.js +1 -1
  53. package/dist/{runtime-BDf5x1i1.js → runtime-BTtpjF3D.js} +4 -4
  54. package/dist/{runtime-DsJt1PIf.cjs → runtime-Dq0LUsyS.cjs} +1 -1
  55. package/dist/sbom.cdx.json +1 -1
  56. package/dist/server/node.d.cts +9 -0
  57. package/dist/server/node.d.ts +9 -0
  58. package/dist/server-node.cjs +5 -4
  59. package/dist/server-node.js +1838 -1760
  60. package/dist/server.cjs +1 -1
  61. package/dist/server.d.cts +81 -0
  62. package/dist/server.d.ts +81 -0
  63. package/dist/server.js +6 -6
  64. package/dist/style.css +1 -1
  65. package/dist/template-catalog-CLAM4w7H.cjs +1 -0
  66. package/dist/{template-catalog-DFwIS9aN.js → template-catalog-JSxSqk5y.js} +3 -3
  67. package/dist/template-fragments-Ca25Jt7e.cjs +1 -0
  68. package/dist/{template-fragments-Dng-AlHk.js → template-fragments-D2JFj7Du.js} +18 -18
  69. package/dist/{template-outline-DiADphlq.js → template-outline-CDWXptuj.js} +1 -1
  70. package/dist/template-outline-K4jGhATu.cjs +1 -0
  71. package/dist/template-registry-CWnuGqyP.cjs +1 -0
  72. package/dist/{template-registry-DhBqoD7W.js → template-registry-Do1Uav2Z.js} +333 -261
  73. package/dist/template-serialization-CU4n_Miu.js +307 -0
  74. package/dist/template-serialization-CgqBo6s-.cjs +1 -0
  75. package/dist/vue/async.d.cts +97 -2
  76. package/dist/vue/async.d.ts +97 -2
  77. package/dist/vue/index.d.cts +197 -4
  78. package/dist/vue/index.d.ts +197 -4
  79. package/dist/vue-async.cjs +1 -1
  80. package/dist/vue-async.js +3 -3
  81. package/dist/vue.cjs +1 -1
  82. package/dist/vue.js +75 -70
  83. package/dist/{workbook-session-NYv01LHe.cjs → workbook-session-BvEBRRMz.cjs} +1 -1
  84. package/dist/{workbook-session-oinxX3qo.js → workbook-session-f0wVlzst.js} +1 -1
  85. package/dist/workbook-sheets-CaPAulQ6.cjs +2 -0
  86. package/dist/workbook-sheets-D4M7XXBh.js +44 -0
  87. package/dist/worker.cjs +1 -1
  88. package/dist/worker.d.cts +9 -0
  89. package/dist/worker.d.ts +9 -0
  90. package/dist/worker.js +4 -4
  91. package/dist/xlsx.cjs +4 -4
  92. package/dist/xlsx.d.cts +39 -2
  93. package/dist/xlsx.d.ts +39 -2
  94. package/dist/xlsx.js +290 -270
  95. package/package.json +1 -1
  96. package/dist/ReportLabelStudio-CaEvYuSK.cjs +0 -1
  97. package/dist/ReportLabelStudio-DQPBmh4v.js +0 -765
  98. package/dist/ReportParamPanel-CVpK8mFc.cjs +0 -1
  99. package/dist/ReportPreview-BBJNlu2U.js +0 -5740
  100. package/dist/ReportPreview-nf4Dk1Jc.cjs +0 -6
  101. package/dist/TemplateReviewPanel-BmBrjt6P.cjs +0 -1
  102. package/dist/prepared-BiSz_9vN.cjs +0 -1
  103. package/dist/template-bindings-Cg5oBLFT.cjs +0 -1
  104. package/dist/template-bindings-TKnXM7ll.js +0 -62
  105. package/dist/template-catalog-D_2jdnkL.cjs +0 -1
  106. package/dist/template-fragments-DZVUBhuB.cjs +0 -1
  107. package/dist/template-outline-DWkzZXVC.cjs +0 -1
  108. package/dist/template-registry-DpLUSLwF.cjs +0 -1
  109. package/dist/template-serialization-Cc3h-miv.js +0 -247
  110. package/dist/template-serialization-D1R5oAqh.cjs +0 -1
@@ -1,26 +1,26 @@
1
- import { k as q, v as X, c as Y } from "./computed-C8NRZQss.js";
2
- import { d as Q, v as Z } from "./matrix-Dy-tyY7E.js";
3
- import { c as C, v as ee, r as te, R as ie } from "./component-tree-1_QCiQJX.js";
4
- import { c as se } from "./code-options-BKXXY7NI.js";
5
- import { v as ne, m as ae } from "./param-validation-CnDEd2l-.js";
6
- import { a as oe, b as fe, M as B, v as re, s as de } from "./template-serialization-Cc3h-miv.js";
7
- function he(e, i, t) {
1
+ import { k as Z, v as ee, c as te } from "./computed-C8NRZQss.js";
2
+ import { d as ie, v as se } from "./matrix-Dy-tyY7E.js";
3
+ import { c as V, v as ne, r as ae, R as oe } from "./component-tree-1_QCiQJX.js";
4
+ import { c as fe } from "./code-options-BKXXY7NI.js";
5
+ import { v as re, m as de } from "./param-validation-CnDEd2l-.js";
6
+ import { a as he, d as ce, b as ue, M as K, v as me, s as ge } from "./template-serialization-CU4n_Miu.js";
7
+ function pe(e, i, t) {
8
8
  e !== void 0 && (typeof e != "string" || !e.trim() || e.length > 4096) && t.push({ path: i, message: "来源范围应为不超过 4096 字符的非空字符串" });
9
9
  }
10
- function D(e, i, t) {
10
+ function H(e, i, t) {
11
11
  e.editable !== void 0 && typeof e.editable != "boolean" && t.push({ path: `${i}.editable`, message: "编辑控制应为布尔值" }), e.valueType !== void 0 && !["text", "number", "boolean"].includes(e.valueType) && t.push({ path: `${i}.valueType`, message: "编辑类型应为 text、number 或 boolean" });
12
12
  }
13
- function ue(e, i, t) {
14
- D(e, i, t), e.indentMm !== void 0 && (typeof e.indentMm != "number" || !Number.isFinite(e.indentMm) || e.indentMm < 0) && t.push({ path: `${i}.indentMm`, message: "单元格缩进应为有限非负数" }), e.derived !== void 0 && typeof e.derived != "boolean" && t.push({ path: `${i}.derived`, message: "派生结果标记应为布尔值" }), V(e.source, `${i}.source`, t, !0), e.formula !== void 0 && typeof e.formula != "string" && t.push({ path: `${i}.formula`, message: "单元格公式应为字符串" });
13
+ function ye(e, i, t) {
14
+ H(e, i, t), e.indentMm !== void 0 && (typeof e.indentMm != "number" || !Number.isFinite(e.indentMm) || e.indentMm < 0) && t.push({ path: `${i}.indentMm`, message: "单元格缩进应为有限非负数" }), e.derived !== void 0 && typeof e.derived != "boolean" && t.push({ path: `${i}.derived`, message: "派生结果标记应为布尔值" }), J(e.source, `${i}.source`, t, !0), e.formula !== void 0 && typeof e.formula != "string" && t.push({ path: `${i}.formula`, message: "单元格公式应为字符串" });
15
15
  }
16
- function V(e, i, t, s = !1) {
16
+ function J(e, i, t, s = !1) {
17
17
  if (e === void 0) return;
18
18
  if (!e || typeof e != "object" || Array.isArray(e)) {
19
19
  t.push({ path: i, message: "业务来源应为对象" });
20
20
  return;
21
21
  }
22
22
  const n = e;
23
- he(n.sourceScope, `${i}.sourceScope`, t);
23
+ pe(n.sourceScope, `${i}.sourceScope`, t);
24
24
  for (const a of ["datasetId", ...s ? ["field"] : []])
25
25
  (typeof n[a] != "string" || !n[a].trim()) && t.push({ path: `${i}.${a}`, message: "业务标识应为非空字符串" });
26
26
  for (const a of ["rowKey", "revision"]) {
@@ -29,7 +29,7 @@ function V(e, i, t, s = !1) {
29
29
  }
30
30
  n.sourceToken !== void 0 && typeof n.sourceToken != "string" && t.push({ path: `${i}.sourceToken`, message: "来源令牌应为字符串" });
31
31
  }
32
- const me = /* @__PURE__ */ new Set([
32
+ const le = /* @__PURE__ */ new Set([
33
33
  "text",
34
34
  "image",
35
35
  "barcode",
@@ -39,22 +39,22 @@ const me = /* @__PURE__ */ new Set([
39
39
  "rect",
40
40
  "ellipse"
41
41
  ]);
42
- function g(e) {
42
+ function p(e) {
43
43
  return typeof e == "object" && e !== null && !Array.isArray(e);
44
44
  }
45
- function k(e) {
45
+ function v(e) {
46
46
  return e === null ? "null" : typeof e == "string" ? JSON.stringify(e.slice(0, 120)) : ["number", "boolean", "undefined"].includes(typeof e) ? String(e) : `[${typeof e}]`;
47
47
  }
48
- function ce(e, i, t, s) {
48
+ function $e(e, i, t, s) {
49
49
  const n = e[i];
50
- (typeof n != "number" || !Number.isFinite(n)) && s.push({ path: `${t}.${i}`, message: `应为有限数字,实际 ${k(n)}` });
50
+ (typeof n != "number" || !Number.isFinite(n)) && s.push({ path: `${t}.${i}`, message: `应为有限数字,实际 ${v(n)}` });
51
51
  }
52
- function ge(e, i, t) {
52
+ function be(e, i, t) {
53
53
  if (e !== void 0) {
54
54
  const s = `${i}.table`;
55
- if (!g(e)) t.push({ path: s, message: "逻辑表来源应为对象" });
55
+ if (!p(e)) t.push({ path: s, message: "逻辑表来源应为对象" });
56
56
  else {
57
- V(e.source, `${s}.source`, t), (typeof e.id != "string" || !e.id.trim()) && t.push({ path: `${s}.id`, message: "逻辑表 ID 应为非空字符串" });
57
+ J(e.source, `${s}.source`, t), (typeof e.id != "string" || !e.id.trim()) && t.push({ path: `${s}.id`, message: "逻辑表 ID 应为非空字符串" });
58
58
  const n = e.role;
59
59
  ["header", "body", "group-header", "subtotal", "grand-total"].includes(n) || t.push({ path: `${s}.role`, message: "未知逻辑表行角色" });
60
60
  const a = e.rowIndex;
@@ -62,9 +62,9 @@ function ge(e, i, t) {
62
62
  }
63
63
  }
64
64
  }
65
- function pe(e, i, t, s) {
65
+ function Ae(e, i, t, s) {
66
66
  if (e !== void 0)
67
- if (!g(e) || !Array.isArray(e.cells))
67
+ if (!p(e) || !Array.isArray(e.cells))
68
68
  t.push({ path: `${i}.grid.cells`, message: "grid.cells 应为二维数组" });
69
69
  else {
70
70
  const n = e.paddingMm;
@@ -76,12 +76,12 @@ function pe(e, i, t, s) {
76
76
  a.forEach((f, r) => {
77
77
  if (f == null) return;
78
78
  const d = `${i}.grid.cells.${o}.${r}`;
79
- if (!g(f)) {
79
+ if (!p(f)) {
80
80
  t.push({ path: d, message: "网格单元格应为对象或 null" });
81
81
  return;
82
82
  }
83
- ue(f, d, t), f.dataBar !== void 0 && !ee(f.dataBar) && t.push({ path: `${d}.dataBar`, message: "数据条应包含 0–1 有序比例与 #RRGGBB 颜色" }), j(f.richParagraphs, d, t), Array.isArray(f.children) && f.children.forEach((h, p) => {
84
- I(h, `${i}.grid.cells.${o}.${r}.children.${p}`, t, s);
83
+ ye(f, d, t), f.dataBar !== void 0 && !ne(f.dataBar) && t.push({ path: `${d}.dataBar`, message: "数据条应包含 0–1 有序比例与 #RRGGBB 颜色" }), W(f.richParagraphs, d, t), Array.isArray(f.children) && f.children.forEach((h, m) => {
84
+ O(h, `${i}.grid.cells.${o}.${r}.children.${m}`, t, s);
85
85
  });
86
86
  });
87
87
  });
@@ -90,15 +90,15 @@ function pe(e, i, t, s) {
90
90
  function N(e, i, t, s) {
91
91
  e !== void 0 && !i.includes(e) && s.push({ path: t, message: "未知富文本属性值" });
92
92
  }
93
- function T(e, i, t, s, n = 0) {
93
+ function F(e, i, t, s, n = 0) {
94
94
  for (const a of i) {
95
95
  const o = e[a];
96
96
  o !== void 0 && (typeof o != "number" || !Number.isFinite(o) || o < n) && s.push({ path: `${t}.${a}`, message: "富文本数值应为范围内有限数字" });
97
97
  }
98
98
  }
99
- function ye(e, i, t) {
99
+ function we(e, i, t) {
100
100
  if (e !== void 0) {
101
- if (!g(e)) {
101
+ if (!p(e)) {
102
102
  t.push({ path: i, message: "富文本样式应为对象" });
103
103
  return;
104
104
  }
@@ -106,20 +106,20 @@ function ye(e, i, t) {
106
106
  e[s] !== void 0 && typeof e[s] != "string" && t.push({ path: `${i}.${s}`, message: "富文本样式应为字符串" });
107
107
  for (const s of ["bold", "italic", "underline", "borderTop", "borderRight", "borderBottom", "borderLeft"])
108
108
  e[s] !== void 0 && typeof e[s] != "boolean" && t.push({ path: `${i}.${s}`, message: "富文本样式应为布尔值" });
109
- T(e, ["fontSize", "fontSizePx", "lineWidthPt", "lineHeight", "opacity"], i, t), T(e, ["letterSpacing", "rotateDeg"], i, t, -1 / 0), typeof e.opacity == "number" && e.opacity > 1 && t.push({ path: `${i}.opacity`, message: "透明度不能大于1" }), N(e.align, ["left", "center", "right", "justify"], `${i}.align`, t), N(e.verticalAlign, ["top", "middle", "bottom"], `${i}.verticalAlign`, t);
109
+ F(e, ["fontSize", "fontSizePx", "lineWidthPt", "lineHeight", "opacity"], i, t), F(e, ["letterSpacing", "rotateDeg"], i, t, -1 / 0), typeof e.opacity == "number" && e.opacity > 1 && t.push({ path: `${i}.opacity`, message: "透明度不能大于1" }), N(e.align, ["left", "center", "right", "justify"], `${i}.align`, t), N(e.verticalAlign, ["top", "middle", "bottom"], `${i}.verticalAlign`, t);
110
110
  }
111
111
  }
112
- function le(e, i, t) {
113
- if (!g(e)) {
112
+ function Me(e, i, t) {
113
+ if (!p(e)) {
114
114
  t.push({ path: i, message: "富文本片段应为对象" });
115
115
  return;
116
116
  }
117
117
  N(e.kind, ["text", "field"], `${i}.kind`, t);
118
118
  for (const s of ["text", "field"])
119
119
  e[s] !== void 0 && typeof e[s] != "string" && t.push({ path: `${i}.${s}`, message: "富文本内容应为字符串" });
120
- ye(e.style, `${i}.style`, t);
120
+ we(e.style, `${i}.style`, t);
121
121
  }
122
- function j(e, i, t) {
122
+ function W(e, i, t) {
123
123
  if (e !== void 0) {
124
124
  if (!Array.isArray(e)) {
125
125
  t.push({ path: `${i}.richParagraphs`, message: "richParagraphs 应为数组" });
@@ -127,99 +127,99 @@ function j(e, i, t) {
127
127
  }
128
128
  e.forEach((s, n) => {
129
129
  const a = `${i}.richParagraphs.${n}`;
130
- if (!g(s) || !Array.isArray(s.segments)) {
130
+ if (!p(s) || !Array.isArray(s.segments)) {
131
131
  t.push({ path: a, message: "段落缺少 segments 数组" });
132
132
  return;
133
133
  }
134
- N(s.align, ["left", "center", "right", "justify"], `${a}.align`, t), T(s, ["lineHeight", "spaceBeforeMm", "spaceAfterMm", "indentMm"], a, t), s.segments.forEach((o, f) => le(o, `${a}.segments.${f}`, t));
134
+ N(s.align, ["left", "center", "right", "justify"], `${a}.align`, t), F(s, ["lineHeight", "spaceBeforeMm", "spaceAfterMm", "indentMm"], a, t), s.segments.forEach((o, f) => Me(o, `${a}.segments.${f}`, t));
135
135
  });
136
136
  }
137
137
  }
138
- function K(e, i, t, s = []) {
139
- const n = C([e], i);
138
+ function G(e, i, t, s = []) {
139
+ const n = V([e], i);
140
140
  if (n) {
141
141
  t.push(n);
142
142
  return;
143
143
  }
144
- I(e, i, t, s);
144
+ O(e, i, t, s);
145
145
  }
146
- function I(e, i, t, s = []) {
147
- if (!g(e)) {
146
+ function O(e, i, t, s = []) {
147
+ if (!p(e)) {
148
148
  t.push({ path: i, message: "组件应为对象" });
149
149
  return;
150
150
  }
151
151
  const n = e.kind;
152
- typeof n != "string" ? t.push({ path: `${i}.kind`, message: "组件缺少 kind 字符串" }) : me.has(n) || s.push({
152
+ typeof n != "string" ? t.push({ path: `${i}.kind`, message: "组件缺少 kind 字符串" }) : le.has(n) || s.push({
153
153
  path: `${i}.kind`,
154
- message: `未知组件类型 ${k(n)},将以兜底方式渲染`
154
+ message: `未知组件类型 ${v(n)},将以兜底方式渲染`
155
155
  });
156
156
  for (const a of ["leftMm", "topMm", "widthMm", "heightMm"])
157
- ce(e, a, i, t);
157
+ $e(e, a, i, t);
158
158
  typeof e.leftMm == "number" && e.leftMm < -100 && t.push({ path: `${i}.leftMm`, message: "几何数值异常(leftMm<-100)" });
159
159
  for (const a of ["widthMm", "heightMm"])
160
160
  typeof e[a] == "number" && e[a] < 0 && t.push({ path: `${i}.${a}`, message: "组件尺寸不能为负数" });
161
- ge(e.table, i, t), be(e.code, n, i, t), $e(e, i, t), e.pageAnchor !== void 0 && !["header", "footer"].includes(e.pageAnchor) && t.push({ path: `${i}.pageAnchor`, message: "页面锚点应为 header 或 footer" }), e.lineDirection !== void 0 && !["down", "up"].includes(e.lineDirection) && t.push({ path: `${i}.lineDirection`, message: "线段方向应为 down 或 up" }), pe(e.grid, i, t, s), j(e.richParagraphs, i, t);
161
+ be(e.table, i, t), Ee(e.code, n, i, t), ke(e, i, t), e.pageAnchor !== void 0 && !["header", "footer"].includes(e.pageAnchor) && t.push({ path: `${i}.pageAnchor`, message: "页面锚点应为 header 或 footer" }), e.lineDirection !== void 0 && !["down", "up"].includes(e.lineDirection) && t.push({ path: `${i}.lineDirection`, message: "线段方向应为 down 或 up" }), Ae(e.grid, i, t, s), W(e.richParagraphs, i, t);
162
162
  }
163
- function $e(e, i, t) {
163
+ function ke(e, i, t) {
164
164
  if (e.chartBinding !== void 0)
165
165
  try {
166
- if (Q(e.chartBinding), e.kind !== "chart" || ["binding", "imageData", "grid", "pageAnchor"].some((s) => e[s] !== void 0)) throw new Error("绑定图表不能设置图片、网格、记录绑定或页眉页脚");
166
+ if (ie(e.chartBinding), e.kind !== "chart" || ["binding", "imageData", "grid", "pageAnchor"].some((s) => e[s] !== void 0)) throw new Error("绑定图表不能设置图片、网格、记录绑定或页眉页脚");
167
167
  if (typeof e.widthMm != "number" || e.widthMm < 45 || typeof e.heightMm != "number" || e.heightMm < 35) throw new Error("绑定图表至少需要 45×35mm");
168
168
  } catch (s) {
169
169
  t.push({ path: `${i}.chartBinding`, message: s instanceof Error ? s.message : String(s) });
170
170
  }
171
171
  }
172
- function be(e, i, t, s) {
172
+ function Ee(e, i, t, s) {
173
173
  if (e !== void 0)
174
- for (const n of se(e, i)) s.push({ path: `${t}.code${n.path ? `.${n.path}` : ""}`, message: n.message });
174
+ for (const n of fe(e, i)) s.push({ path: `${t}.code${n.path ? `.${n.path}` : ""}`, message: n.message });
175
175
  }
176
- function H(e, i, t) {
177
- if (!g(e)) return;
176
+ function U(e, i, t) {
177
+ if (!p(e)) return;
178
178
  e.binding !== void 0 && t.push({ path: `${i}.binding`, message: "渲染计划不允许未解析字段绑定" }), e.chartBinding !== void 0 && t.push({ path: `${i}.chartBinding`, message: "渲染计划不允许未解析图表绑定" });
179
179
  const s = e.grid;
180
- !g(s) || !Array.isArray(s.cells) || s.cells.forEach((n, a) => {
180
+ !p(s) || !Array.isArray(s.cells) || s.cells.forEach((n, a) => {
181
181
  Array.isArray(n) && n.forEach((o, f) => {
182
- !g(o) || !Array.isArray(o.children) || o.children.forEach((r, d) => H(r, `${i}.grid.cells.${a}.${f}.children.${d}`, t));
182
+ !p(o) || !Array.isArray(o.children) || o.children.forEach((r, d) => U(r, `${i}.grid.cells.${a}.${f}.children.${d}`, t));
183
183
  });
184
184
  });
185
185
  }
186
- function Ae(e, i, t, s = []) {
187
- if (!g(e)) {
186
+ function Se(e, i, t, s = []) {
187
+ if (!p(e)) {
188
188
  t.push({ path: i, message: "页应为对象" });
189
189
  return;
190
190
  }
191
191
  const n = e.pageWidthMm, a = e.pageHeightMm;
192
- (typeof n != "number" || !Number.isFinite(n) || n <= 0) && t.push({ path: `${i}.pageWidthMm`, message: `页宽非法: ${k(n)}` }), (typeof a != "number" || !(a > 0 && a < 5e3)) && t.push({ path: `${i}.pageHeightMm`, message: `页高非法: ${k(a)}` }), e.layout !== void 0 && e.layout !== "page" && e.layout !== "wide" && t.push({ path: `${i}.layout`, message: "布局应为 page 或 wide" });
192
+ (typeof n != "number" || !Number.isFinite(n) || n <= 0) && t.push({ path: `${i}.pageWidthMm`, message: `页宽非法: ${v(n)}` }), (typeof a != "number" || !(a > 0 && a < 5e3)) && t.push({ path: `${i}.pageHeightMm`, message: `页高非法: ${v(a)}` }), e.layout !== void 0 && e.layout !== "page" && e.layout !== "wide" && t.push({ path: `${i}.layout`, message: "布局应为 page 或 wide" });
193
193
  const o = e.components;
194
194
  if (!Array.isArray(o))
195
195
  t.push({ path: `${i}.components`, message: "components 应为数组" });
196
196
  else if (Array.isArray(o)) {
197
- const f = C(o, `${i}.components`);
197
+ const f = V(o, `${i}.components`);
198
198
  if (f) {
199
199
  t.push(f);
200
200
  return;
201
201
  }
202
202
  o.forEach((r, d) => {
203
- I(r, `${i}.components.${d}`, t, s), H(r, `${i}.components.${d}`, t);
203
+ O(r, `${i}.components.${d}`, t, s), U(r, `${i}.components.${d}`, t);
204
204
  });
205
205
  }
206
206
  }
207
- function we(e) {
208
- const i = [], t = [], s = g(e) ? e.pages : void 0;
209
- if (g(e) && e.requiresRecalculation !== void 0 && typeof e.requiresRecalculation != "boolean" && i.push({ path: "$.requiresRecalculation", message: "重算能力要求应为布尔值" }), !Array.isArray(s))
207
+ function ve(e) {
208
+ const i = [], t = [], s = p(e) ? e.pages : void 0;
209
+ if (p(e) && e.requiresRecalculation !== void 0 && typeof e.requiresRecalculation != "boolean" && i.push({ path: "$.requiresRecalculation", message: "重算能力要求应为布尔值" }), !Array.isArray(s))
210
210
  i.push({
211
211
  path: "$.pages",
212
212
  message: e == null ? "渲染计划为空" : "渲染计划缺少 pages 数组"
213
213
  });
214
214
  else {
215
- const n = te(s);
215
+ const n = ae(s);
216
216
  if (n) return { ok: !1, errors: [...i, n], warnings: t };
217
- s.forEach((o, f) => Ae(o, `$.pages.${f}`, i, t)), s.length > 2e3 && t.push({
217
+ s.forEach((o, f) => Se(o, `$.pages.${f}`, i, t)), s.length > 2e3 && t.push({
218
218
  path: "$.pages",
219
219
  message: `页数异常大(${s.length} 页),渲染与打印耗时可能显著增加`
220
220
  });
221
221
  const a = s.reduce(
222
- (o, f) => o + (g(f) && Array.isArray(f.components) ? f.components.length : 0),
222
+ (o, f) => o + (p(f) && Array.isArray(f.components) ? f.components.length : 0),
223
223
  0
224
224
  );
225
225
  a > 5e4 && t.push({
@@ -229,49 +229,49 @@ function we(e) {
229
229
  }
230
230
  return { ok: i.length === 0, errors: i, warnings: t };
231
231
  }
232
- function nt(e) {
233
- const i = we(e);
232
+ function mt(e) {
233
+ const i = ve(e);
234
234
  if (!i.ok) {
235
235
  const t = i.errors.slice(0, 3).map((s) => `${s.path}: ${s.message}`).join("; ");
236
236
  throw new Error(`渲染计划校验失败(${i.errors.length} 处): ${t}`);
237
237
  }
238
238
  return e.pages;
239
239
  }
240
- function P(e) {
240
+ function _(e) {
241
241
  return e.kind === "list" ? e.id : e.nid;
242
242
  }
243
- function Me(e) {
243
+ function Ne(e) {
244
244
  return e.kind === "list" ? !1 : e.pageAnchor !== void 0 || e.kind === "text" && typeof e.text == "string" && /\{(?:page|totalPages)\}/.test(e.text);
245
245
  }
246
- function ve(e, i) {
247
- const t = e.filter((n) => i.componentIds.includes(P(n) ?? ""));
246
+ function xe(e, i) {
247
+ const t = e.filter((n) => i.componentIds.includes(_(n) ?? ""));
248
248
  if (t.filter((n) => n.kind === "list" && n.cardinality !== "record").length && t.length !== 1) throw new Error("纵向重复区域必须独占流式分段,不能与静态或单记录区域并排");
249
249
  for (const n of t) {
250
250
  const a = n.kind === "list" ? n.topMm + (n.rowHeightMm ?? 0) : n.topMm + n.heightMm;
251
251
  if (n.topMm < i.topMm - 1e-3 || a > i.topMm + i.heightMm + 1e-3) throw new Error("流式分段应完整包含其组件的原始纵向范围");
252
252
  }
253
253
  }
254
- function at(e, i) {
254
+ function gt(e, i) {
255
255
  if (!i) return e.map((s) => ({ components: [s] }));
256
- const t = new Map(e.map((s) => [P(s), s]));
256
+ const t = new Map(e.map((s) => [_(s), s]));
257
257
  return i.bands.map((s) => ({ band: s, components: s.componentIds.map((n) => {
258
258
  const a = t.get(n);
259
259
  if (!a) throw new Error(`流式区域引用不存在的组件:${n}`);
260
260
  return a;
261
261
  }) }));
262
262
  }
263
- function Ee(e, i) {
263
+ function Re(e, i) {
264
264
  if (!i || !Array.isArray(i.bands) || !i.bands.length || i.bands.length > 1e4) throw new Error("流式排版应包含 1–10000 个区域");
265
265
  const t = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set();
266
266
  for (const n of e) {
267
- if (Me(n)) continue;
268
- const a = P(n);
267
+ if (Ne(n)) continue;
268
+ const a = _(n);
269
269
  if (!a || t.has(a)) throw new Error("流式排版组件应具有唯一标识");
270
270
  t.add(a);
271
271
  }
272
- if (ke(e, i, t, s), s.size !== t.size) throw new Error("流式排版必须显式包含每个非锚点组件");
272
+ if (Te(e, i, t, s), s.size !== t.size) throw new Error("流式排版必须显式包含每个非锚点组件");
273
273
  }
274
- function ke(e, i, t, s) {
274
+ function Te(e, i, t, s) {
275
275
  let n = -1 / 0;
276
276
  for (const a of i.bands) {
277
277
  if (!Number.isFinite(a.topMm) || !Number.isFinite(a.heightMm) || a.topMm < 0 || a.heightMm <= 0 || a.topMm < n - 1e-3) throw new Error("流式区域应按原始位置排序,尺寸有效且不重叠");
@@ -280,84 +280,84 @@ function ke(e, i, t, s) {
280
280
  if (!t.has(o) || s.has(o)) throw new Error(`流式区域组件缺失、重复或包含页锚点:${o}`);
281
281
  s.add(o);
282
282
  }
283
- ve(e, a), n = a.topMm + a.heightMm;
283
+ xe(e, a), n = a.topMm + a.heightMm;
284
284
  }
285
285
  }
286
- const Ne = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]);
287
- function l(e) {
286
+ const Fe = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]);
287
+ function $(e) {
288
288
  return !!e && typeof e == "object" && !Array.isArray(e);
289
289
  }
290
- function v(e) {
291
- return typeof e == "string" && !!e.trim() && !Ne.has(e);
290
+ function k(e) {
291
+ return typeof e == "string" && !!e.trim() && !Fe.has(e);
292
292
  }
293
- function S(e, i, t, s) {
293
+ function x(e, i, t, s) {
294
294
  for (const n of Object.keys(e)) i.includes(n) || s.push({ path: `${t}.${n}`, message: "存在未知配置字段" });
295
295
  }
296
- function Se(e, i, t) {
296
+ function Ce(e, i, t) {
297
297
  if (e !== void 0) {
298
- if (!l(e) || !["number", "percent", "date"].includes(String(e.kind))) {
298
+ if (!$(e) || !["number", "percent", "date"].includes(String(e.kind))) {
299
299
  t.push({ path: i, message: "绑定格式应为 number、percent 或 date" });
300
300
  return;
301
301
  }
302
- S(e, e.kind === "date" ? ["kind", "pattern"] : e.kind === "number" ? ["kind", "digits", "thousands"] : ["kind", "digits"], i, t), e.digits !== void 0 && (!Number.isInteger(e.digits) || Number(e.digits) < 0 || Number(e.digits) > 100) && t.push({ path: `${i}.digits`, message: "精度应为 0..100 整数" }), e.thousands !== void 0 && typeof e.thousands != "boolean" && t.push({ path: `${i}.thousands`, message: "千分位开关应为布尔值" }), e.pattern !== void 0 && typeof e.pattern != "string" && t.push({ path: `${i}.pattern`, message: "日期格式应为字符串" });
302
+ x(e, e.kind === "date" ? ["kind", "pattern"] : e.kind === "number" ? ["kind", "digits", "thousands"] : ["kind", "digits"], i, t), e.digits !== void 0 && (!Number.isInteger(e.digits) || Number(e.digits) < 0 || Number(e.digits) > 100) && t.push({ path: `${i}.digits`, message: "精度应为 0..100 整数" }), e.thousands !== void 0 && typeof e.thousands != "boolean" && t.push({ path: `${i}.thousands`, message: "千分位开关应为布尔值" }), e.pattern !== void 0 && typeof e.pattern != "string" && t.push({ path: `${i}.pattern`, message: "日期格式应为字符串" });
303
303
  }
304
304
  }
305
- function xe(e, i, t) {
305
+ function Pe(e, i, t) {
306
306
  const s = e.binding;
307
307
  if (s === void 0) return;
308
308
  const n = `${i}.binding`;
309
- if (!l(s)) {
309
+ if (!$(s)) {
310
310
  t.push({ path: n, message: "字段绑定应为对象" });
311
311
  return;
312
312
  }
313
- (!["text", "image", "barcode", "qrcode"].includes(String(e.kind)) || e.grid !== void 0) && t.push({ path: n, message: "绑定仅支持独立文本、图片、条码与二维码组件" }), S(s, ["field", "format", "prefix", "suffix", "emptyText"], n, t), v(s.field) || t.push({ path: `${n}.field`, message: "绑定字段应为安全的非空字段名(按字面读取自有字段)" });
313
+ (!["text", "image", "barcode", "qrcode"].includes(String(e.kind)) || e.grid !== void 0) && t.push({ path: n, message: "绑定仅支持独立文本、图片、条码与二维码组件" }), x(s, ["field", "format", "prefix", "suffix", "emptyText"], n, t), k(s.field) || t.push({ path: `${n}.field`, message: "绑定字段应为安全的非空字段名(按字面读取自有字段)" });
314
314
  for (const a of ["prefix", "suffix", "emptyText"]) s[a] !== void 0 && typeof s[a] != "string" && t.push({ path: `${n}.${a}`, message: "应为字符串" });
315
- Se(s.format, `${n}.format`, t), e.kind === "image" && ["format", "prefix", "suffix"].some((a) => s[a] !== void 0) && t.push({ path: n, message: "图片绑定直接读取 PNG/JPEG data URL,不支持文本格式或前后缀" });
315
+ Ce(s.format, `${n}.format`, t), e.kind === "image" && ["format", "prefix", "suffix"].some((a) => s[a] !== void 0) && t.push({ path: n, message: "图片绑定直接读取 PNG/JPEG data URL,不支持文本格式或前后缀" });
316
316
  }
317
- function Re(e, i) {
318
- if (!l(e)) {
317
+ function Ie(e, i) {
318
+ if (!$(e)) {
319
319
  i.push({ path: "$.repeat", message: "逐记录配置应为对象" });
320
320
  return;
321
321
  }
322
- S(e, ["dataset", "rowKey", "copies"], "$.repeat", i), v(e.dataset) || i.push({ path: "$.repeat.dataset", message: "数据集应为安全的非空名称" }), e.rowKey !== void 0 && !v(e.rowKey) && i.push({ path: "$.repeat.rowKey", message: "业务主键应为安全的非空字段名" });
322
+ x(e, ["dataset", "rowKey", "copies"], "$.repeat", i), k(e.dataset) || i.push({ path: "$.repeat.dataset", message: "数据集应为安全的非空名称" }), e.rowKey !== void 0 && !k(e.rowKey) && i.push({ path: "$.repeat.rowKey", message: "业务主键应为安全的非空字段名" });
323
323
  const t = e.copies;
324
- t !== void 0 && (l(t) ? (S(t, ["field"], "$.repeat.copies", i), v(t.field) || i.push({ path: "$.repeat.copies.field", message: "复制数字段应为安全的非空字段名" })) : (!Number.isSafeInteger(t) || Number(t) < 1 || Number(t) > 1e3) && i.push({ path: "$.repeat.copies", message: "每条记录复制数应为 1..1000 整数" }));
324
+ t !== void 0 && ($(t) ? (x(t, ["field"], "$.repeat.copies", i), k(t.field) || i.push({ path: "$.repeat.copies.field", message: "复制数字段应为安全的非空字段名" })) : (!Number.isSafeInteger(t) || Number(t) < 1 || Number(t) > 1e3) && i.push({ path: "$.repeat.copies", message: "每条记录复制数应为 1..1000 整数" }));
325
325
  }
326
- function J(e, i, t, s) {
327
- if (!l(e)) return;
328
- xe(e, i, s), e.binding !== void 0 && !t && s.push({ path: `${i}.binding`, message: "字段绑定需要模板 repeat 数据集;普通报表请使用列表字段" }), t && e.kind === "list" && s.push({ path: i, message: "逐记录标签使用固定组件;动态列表请使用普通报表模板" }), e.chartBinding !== void 0 && (t || i.includes(".children.")) && s.push({ path: `${i}.chartBinding`, message: "数据图表应放在普通报表的页面或流式分区,不放在逐记录标签或嵌套单元格内" });
326
+ function z(e, i, t, s) {
327
+ if (!$(e)) return;
328
+ Pe(e, i, s), e.binding !== void 0 && !t && s.push({ path: `${i}.binding`, message: "字段绑定需要模板 repeat 数据集;普通报表请使用列表字段" }), t && e.kind === "list" && s.push({ path: i, message: "逐记录标签使用固定组件;动态列表请使用普通报表模板" }), e.chartBinding !== void 0 && (t || i.includes(".children.")) && s.push({ path: `${i}.chartBinding`, message: "数据图表应放在普通报表的页面或流式分区,不放在逐记录标签或嵌套单元格内" });
329
329
  const n = e.grid;
330
- l(n) && Array.isArray(n.cells) && n.cells.forEach((a, o) => {
330
+ $(n) && Array.isArray(n.cells) && n.cells.forEach((a, o) => {
331
331
  Array.isArray(a) && a.forEach((f, r) => {
332
- l(f) && Array.isArray(f.children) && f.children.forEach((d, h) => J(d, `${i}.grid.cells.${o}.${r}.children.${h}`, t, s));
332
+ $(f) && Array.isArray(f.children) && f.children.forEach((d, h) => z(d, `${i}.grid.cells.${o}.${r}.children.${h}`, t, s));
333
333
  });
334
334
  });
335
335
  }
336
- function Te(e, i) {
336
+ function Oe(e, i) {
337
337
  const t = e.repeat !== void 0;
338
- t && Re(e.repeat, i), Array.isArray(e.pages) && e.pages.forEach((s, n) => {
339
- if (!l(s)) return;
338
+ t && Ie(e.repeat, i), Array.isArray(e.pages) && e.pages.forEach((s, n) => {
339
+ if (!$(s)) return;
340
340
  const a = `$.pages.${n}`;
341
341
  t && (s.layout === "wide" || s.flow !== void 0) && i.push({ path: a, message: "逐记录标签仅支持固定尺寸页面,不支持宽表或流式分区" }), Array.isArray(s.components) && s.components.forEach((o, f) => {
342
342
  const r = `${a}.components.${f}`;
343
- if (J(o, r, t, i), !t || !l(o)) return;
344
- const { leftMm: d, topMm: h, widthMm: p, heightMm: y } = o;
345
- [d, h, p, y, s.widthMm, s.heightMm].every((A) => typeof A == "number" && Number.isFinite(A)) && (Number(d) < 0 || Number(h) < 0 || Number(d) + Number(p) > Number(s.widthMm) + 1e-3 || Number(h) + Number(y) > Number(s.heightMm) + 1e-3) && i.push({ path: r, message: "标签组件超出纸张边界,请调整位置或尺寸" });
343
+ if (z(o, r, t, i), !t || !$(o)) return;
344
+ const { leftMm: d, topMm: h, widthMm: m, heightMm: y } = o;
345
+ [d, h, m, y, s.widthMm, s.heightMm].every((l) => typeof l == "number" && Number.isFinite(l)) && (Number(d) < 0 || Number(h) < 0 || Number(d) + Number(m) > Number(s.widthMm) + 1e-3 || Number(h) + Number(y) > Number(s.heightMm) + 1e-3) && i.push({ path: r, message: "标签组件超出纸张边界,请调整位置或尺寸" });
346
346
  });
347
347
  });
348
348
  }
349
- function Fe(e) {
349
+ function _e(e) {
350
350
  return !!e && typeof e == "object" && !Array.isArray(e);
351
351
  }
352
- function F(e, i, t) {
352
+ function C(e, i, t) {
353
353
  if (e !== void 0)
354
354
  try {
355
- q(e);
355
+ Z(e);
356
356
  } catch (s) {
357
357
  t.push({ path: i, message: s instanceof Error ? s.message : String(s) });
358
358
  }
359
359
  }
360
- function W(e, i, t) {
360
+ function q(e, i, t) {
361
361
  if (e === void 0) return;
362
362
  if (!Array.isArray(e) || e.length > 2048) {
363
363
  t.push({ path: i, message: "聚合应为数组且最多 2048 项" });
@@ -366,7 +366,7 @@ function W(e, i, t) {
366
366
  const s = /* @__PURE__ */ new Set();
367
367
  e.forEach((n, a) => {
368
368
  const o = `${i}.${a}`;
369
- if (!Fe(n)) {
369
+ if (!_e(n)) {
370
370
  t.push({ path: o, message: "聚合应为对象" });
371
371
  return;
372
372
  }
@@ -382,7 +382,7 @@ function W(e, i, t) {
382
382
  message: "小数位应为 0–100 的整数"
383
383
  });
384
384
  try {
385
- Y({
385
+ te({
386
386
  ...n,
387
387
  field: n.valueField ?? f
388
388
  });
@@ -394,15 +394,15 @@ function W(e, i, t) {
394
394
  }
395
395
  });
396
396
  }
397
- function Ie(e, i, t) {
397
+ function Le(e, i, t) {
398
398
  if (e === void 0) return;
399
- const s = X(e);
399
+ const s = ee(e);
400
400
  for (const n of s.errors) t.push({ path: i, message: n });
401
401
  }
402
- function Pe(e, i, t) {
402
+ function je(e, i, t) {
403
403
  if (e !== void 0)
404
404
  try {
405
- Z(e);
405
+ se(e);
406
406
  } catch (s) {
407
407
  t.push({
408
408
  path: i,
@@ -410,31 +410,102 @@ function Pe(e, i, t) {
410
410
  });
411
411
  }
412
412
  }
413
- function Oe(e, i, t) {
413
+ function Be(e, i, t) {
414
414
  if (e.tree === void 0) return;
415
415
  const s = `${i}.tree`;
416
416
  try {
417
- oe(e.tree);
417
+ he(e.tree);
418
418
  const n = e.tree;
419
419
  if (e.matrix || e.detail || e.groupBy || Array.isArray(e.groups) && e.groups.length || e.rowVisibleWhen) throw new Error("树形布局不能同时配置普通分组、矩阵、主从或行可见条件");
420
420
  if (e.rowKey !== void 0 && e.rowKey !== n.idField) throw new Error("树形 rowKey 应与 idField 一致");
421
421
  if (!Array.isArray(e.columns) || !e.columns.some((a) => a && a.field === n.labelField && !a.hidden)) throw new Error("树形布局需要可见的标签列");
422
- Array.isArray(e.computed) && fe(n, e.computed);
422
+ Array.isArray(e.computed) && ce(n, e.computed);
423
423
  } catch (n) {
424
424
  t.push({ path: s, message: n instanceof Error ? n.message : String(n) });
425
425
  }
426
426
  }
427
- const G = "1.0";
427
+ const De = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]), Ve = /* @__PURE__ */ new Set(["text", "number", "boolean", "date", "decimal"]);
428
+ function E(e) {
429
+ return !!e && typeof e == "object" && !Array.isArray(e);
430
+ }
431
+ function P(e) {
432
+ return typeof e == "string" && !!e.trim() && e.length <= 4096 && !De.has(e);
433
+ }
434
+ function Ke(e, i, t) {
435
+ if (!Array.isArray(e) || !e.length || e.length > 2048) {
436
+ t.push({ path: i, message: "绑定契约应包含 1–2048 个字段" });
437
+ return;
438
+ }
439
+ const s = /* @__PURE__ */ new Set();
440
+ e.forEach((n, a) => {
441
+ const o = `${i}.${a}`;
442
+ if (!E(n) || !P(n.field) || s.has(n.field)) {
443
+ t.push({ path: o, message: "字段名应安全、非空且唯一" });
444
+ return;
445
+ }
446
+ s.add(n.field);
447
+ for (const f of ["label", "semanticKey", "unit"])
448
+ n[f] !== void 0 && (typeof n[f] != "string" || String(n[f]).length > 4096) && t.push({ path: `${o}.${f}`, message: "应为不超过 4096 位的字符串" });
449
+ n.type !== void 0 && !Ve.has(String(n.type)) && t.push({ path: `${o}.type`, message: "未知绑定字段类型" });
450
+ });
451
+ }
452
+ function I(e, i, t) {
453
+ if (e === void 0) return;
454
+ if (!E(e) || !E(e.datasets)) {
455
+ t.push({ path: i, message: "模板数据契约应声明 datasets" });
456
+ return;
457
+ }
458
+ e.source !== void 0 && !P(e.source) && t.push({ path: `${i}.source`, message: "来源应为安全的非空业务标识" });
459
+ const s = Object.entries(e.datasets);
460
+ (!s.length || s.length > 256) && t.push({ path: `${i}.datasets`, message: "应声明 1–256 个数据集" });
461
+ for (const [n, a] of s) {
462
+ const o = `${i}.datasets.${n}`;
463
+ !P(n) || !E(a) ? t.push({ path: o, message: "数据集应使用安全名称和字段契约" }) : Ke(a.fields, `${o}.fields`, t);
464
+ }
465
+ }
466
+ function B(e, i) {
467
+ return new Map(e.datasets[i]?.fields.map((t) => [t.field, t]) ?? []);
468
+ }
469
+ function He(e, i, t, s) {
470
+ const n = e.label || e.field;
471
+ for (const [a, o, f] of [["semanticKey", "semantic", "业务含义"], ["type", "type", "类型"], ["unit", "unit", "单位"]])
472
+ e[a] !== i[a] && (e[a] !== void 0 || i[a] !== void 0) && s.push({ ...t, code: o, message: `字段“${n}”的${f}不兼容(${e[a] ?? "未声明"} → ${i[a] ?? "未声明"}),请重新绑定` });
473
+ }
474
+ function pt(e, i) {
475
+ const t = [], s = [];
476
+ if (I(i, "$.target", s), I(e.dataContract, "$.template.dataContract", s), s.length) return { ok: !1, issues: s.map((o) => ({ ...o, code: "contract" })) };
477
+ const n = e.dataContract;
478
+ if (!n) return { ok: !1, issues: [{ code: "contract", path: "$.template.dataContract", message: "模板未声明数据来源,请核对业务字段并重新绑定" }] };
479
+ n.source !== i.source && t.push({ code: "source", path: "$.template.dataContract.source", message: `模板来源与当前报表不一致(${n.source ?? "未声明"} → ${i.source ?? "未声明"}),请从当前报表创建或重新绑定模板` });
480
+ const a = /* @__PURE__ */ new Set();
481
+ for (const o of ue(e)) {
482
+ const f = B(n, o.dataset), r = B(i, o.dataset);
483
+ if (!f.size || !r.size) {
484
+ t.push({ code: "dataset", dataset: o.dataset, path: o.path, message: `数据集“${o.dataset}”缺少来源或目标字段契约` });
485
+ continue;
486
+ }
487
+ for (const d of o.fields) {
488
+ if (o.generated.has(d.field) || d.summary && o.summaries.has(d.field)) continue;
489
+ const h = `${o.dataset}\0${d.field}`;
490
+ if (a.has(h)) continue;
491
+ a.add(h);
492
+ const m = f.get(d.field), y = r.get(d.field), l = { ...d, dataset: o.dataset };
493
+ !m || !y ? t.push({ ...l, code: "field", message: `数据集“${o.dataset}”的字段“${d.field}”未声明,请重新绑定` }) : He(m, y, l, t);
494
+ }
495
+ }
496
+ return { ok: t.length === 0, issues: t };
497
+ }
498
+ const X = "1.0";
428
499
  class w extends Error {
429
500
  constructor(i) {
430
501
  super(`模板校验失败:${i.slice(0, 3).map((t) => `${t.path}: ${t.message}`).join("; ")}`), this.errors = i, this.name = "ReportTemplateError";
431
502
  }
432
503
  }
433
- const Le = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]), _e = /* @__PURE__ */ new Set(["schemaVersion", "id", "name", "revision", "description", "template"]), Ce = /* @__PURE__ */ new Set(["left", "center", "right", "justify"]), E = 2e5, Be = 64;
434
- function u(e) {
504
+ const Je = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]), We = /* @__PURE__ */ new Set(["schemaVersion", "id", "name", "revision", "description", "template"]), Ge = /* @__PURE__ */ new Set(["left", "center", "right", "justify"]), S = 2e5, Ue = 64;
505
+ function c(e) {
435
506
  return !!e && typeof e == "object" && !Array.isArray(e);
436
507
  }
437
- function De(e, i, t) {
508
+ function ze(e, i, t) {
438
509
  const s = Object.getPrototypeOf(e), n = Array.isArray(e);
439
510
  if (n ? s !== Array.prototype : s !== Object.prototype && s !== null)
440
511
  return t.push({ path: i, message: "模板对象必须使用普通 JSON 对象原型" }), !1;
@@ -445,30 +516,30 @@ function De(e, i, t) {
445
516
  }
446
517
  return Object.getOwnPropertySymbols(e).length > 0 ? (t.push({ path: i, message: "模板不能包含 Symbol 键" }), !1) : !0;
447
518
  }
448
- function Ve(e, i, t, s) {
449
- return Le.has(e) ? (s.push({ path: t, message: "模板不能包含可能污染原型的键" }), !1) : i.get || i.set || !i.enumerable ? (s.push({ path: t, message: "模板不能包含访问器或不可枚举字段" }), !1) : !0;
519
+ function qe(e, i, t, s) {
520
+ return Je.has(e) ? (s.push({ path: t, message: "模板不能包含可能污染原型的键" }), !1) : i.get || i.set || !i.enumerable ? (s.push({ path: t, message: "模板不能包含访问器或不可枚举字段" }), !1) : !0;
450
521
  }
451
- function je(e) {
522
+ function Xe(e) {
452
523
  return e === null || typeof e == "boolean" || typeof e == "number" && Number.isFinite(e);
453
524
  }
454
- function O(e, i) {
525
+ function L(e, i) {
455
526
  const t = /* @__PURE__ */ new Set();
456
527
  let s = 0, n = 0, a = !1;
457
528
  const o = (f, r, d) => {
458
529
  if (!a) {
459
- if (++s > E) {
460
- s === E + 1 && i.push({ path: r, message: "模板超过 JSON 节点安全上限" });
530
+ if (++s > S) {
531
+ s === S + 1 && i.push({ path: r, message: "模板超过 JSON 节点安全上限" });
461
532
  return;
462
533
  }
463
- if (d > Be) {
534
+ if (d > Ue) {
464
535
  i.push({ path: r, message: "模板嵌套层级过深" });
465
536
  return;
466
537
  }
467
538
  if (typeof f == "string") {
468
- n += f.length, n > B && (a = !0, i.push({ path: r, message: "模板文本超过 1000 万字符的安全上限" }));
539
+ n += f.length, n > K && (a = !0, i.push({ path: r, message: "模板文本超过 1000 万字符的安全上限" }));
469
540
  return;
470
541
  }
471
- if (!je(f)) {
542
+ if (!Xe(f)) {
472
543
  if (!f || typeof f != "object") {
473
544
  i.push({ path: r, message: "模板只允许 JSON 值,不允许函数、undefined 或非有限数字" });
474
545
  return;
@@ -477,12 +548,12 @@ function O(e, i) {
477
548
  i.push({ path: r, message: "模板不能包含循环引用" });
478
549
  return;
479
550
  }
480
- if (De(f, r, i)) {
551
+ if (ze(f, r, i)) {
481
552
  t.add(f);
482
- for (const [h, p] of Object.entries(Object.getOwnPropertyDescriptors(f))) {
553
+ for (const [h, m] of Object.entries(Object.getOwnPropertyDescriptors(f))) {
483
554
  if (Array.isArray(f) && h === "length") continue;
484
555
  const y = `${r}.${h}`;
485
- if (Ve(h, p, y, i) && o(p.value, y, d + 1), s > E || a) break;
556
+ if (qe(h, m, y, i) && o(m.value, y, d + 1), s > S || a) break;
486
557
  }
487
558
  t.delete(f);
488
559
  }
@@ -491,35 +562,35 @@ function O(e, i) {
491
562
  };
492
563
  o(e, "$", 0);
493
564
  }
494
- function m(e, i, t, s, n = !1) {
565
+ function u(e, i, t, s, n = !1) {
495
566
  const a = e[i];
496
567
  a === void 0 && !n || (typeof a != "string" || n && !a.trim()) && s.push({ path: `${t}.${i}`, message: n ? "应为非空字符串" : "应为字符串" });
497
568
  }
498
- function c(e, i, t, s, n = 0, a = !1) {
569
+ function g(e, i, t, s, n = 0, a = !1) {
499
570
  const o = e[i];
500
571
  o === void 0 && !a || (typeof o != "number" || !Number.isFinite(o) || o < n) && s.push({ path: `${t}.${i}`, message: `应为大于等于 ${n} 的有限数字` });
501
572
  }
502
- function b(e, i, t, s) {
573
+ function A(e, i, t, s) {
503
574
  e[i] !== void 0 && typeof e[i] != "boolean" && s.push({ path: `${t}.${i}`, message: "应为布尔值" });
504
575
  }
505
576
  function M(e, i, t, s = !1) {
506
- e !== void 0 && !Ce.has(e) && !(s && e === "auto") && t.push({ path: i, message: `未知对齐方式${s ? "(支持 auto)" : ""}` });
577
+ e !== void 0 && !Ge.has(e) && !(s && e === "auto") && t.push({ path: i, message: `未知对齐方式${s ? "(支持 auto)" : ""}` });
507
578
  }
508
- function $(e, i, t) {
579
+ function b(e, i, t) {
509
580
  if (e !== void 0) {
510
- if (!u(e)) {
581
+ if (!c(e)) {
511
582
  t.push({ path: i, message: "样式应为对象" });
512
583
  return;
513
584
  }
514
585
  M(e.align, `${i}.align`, t), e.verticalAlign !== void 0 && !["top", "middle", "bottom"].includes(e.verticalAlign) && t.push({ path: `${i}.verticalAlign`, message: "未知垂直对齐方式" });
515
- for (const s of ["fontSize", "fontSizePx", "lineWidthPt", "lineHeight"]) c(e, s, i, t);
516
- for (const s of ["letterSpacing", "rotateDeg"]) c(e, s, i, t, -1 / 0);
517
- c(e, "opacity", i, t), typeof e.opacity == "number" && e.opacity > 1 && t.push({ path: `${i}.opacity`, message: "透明度不能大于 1" });
518
- for (const s of ["bold", "italic", "underline", "borderTop", "borderRight", "borderBottom", "borderLeft"]) b(e, s, i, t);
519
- for (const s of ["fontFamily", "color", "backgroundColor", "lineColor", "borderColor"]) m(e, s, i, t);
586
+ for (const s of ["fontSize", "fontSizePx", "lineWidthPt", "lineHeight"]) g(e, s, i, t);
587
+ for (const s of ["letterSpacing", "rotateDeg"]) g(e, s, i, t, -1 / 0);
588
+ g(e, "opacity", i, t), typeof e.opacity == "number" && e.opacity > 1 && t.push({ path: `${i}.opacity`, message: "透明度不能大于 1" });
589
+ for (const s of ["bold", "italic", "underline", "borderTop", "borderRight", "borderBottom", "borderLeft"]) A(e, s, i, t);
590
+ for (const s of ["fontFamily", "color", "backgroundColor", "lineColor", "borderColor"]) u(e, s, i, t);
520
591
  }
521
592
  }
522
- function Ke(e, i, t) {
593
+ function Ye(e, i, t) {
523
594
  if (e === void 0) return;
524
595
  if (!Array.isArray(e)) {
525
596
  t.push({ path: i, message: "参数定义应为数组" });
@@ -528,154 +599,154 @@ function Ke(e, i, t) {
528
599
  const s = /* @__PURE__ */ new Set(), n = t.length;
529
600
  e.forEach((a, o) => {
530
601
  const f = `${i}.${o}`;
531
- if (!u(a)) {
602
+ if (!c(a)) {
532
603
  t.push({ path: f, message: "参数定义应为对象" });
533
604
  return;
534
605
  }
535
- m(a, "field", f, t, !0), typeof a.field == "string" && (s.has(a.field) && t.push({ path: `${f}.field`, message: "参数名重复" }), s.add(a.field)), a.type !== void 0 && !["text", "number", "date", "month", "year", "dateRange", "select", "multiSelect", "cascader", "numberRange"].includes(a.type) && t.push({ path: `${f}.type`, message: "未知参数类型" });
536
- for (const r of ["label", "defaultValue", "placeholder"]) m(a, r, f, t);
537
- b(a, "required", f, t);
606
+ u(a, "field", f, t, !0), typeof a.field == "string" && (s.has(a.field) && t.push({ path: `${f}.field`, message: "参数名重复" }), s.add(a.field)), a.type !== void 0 && !["text", "number", "date", "month", "year", "dateRange", "select", "multiSelect", "cascader", "numberRange"].includes(a.type) && t.push({ path: `${f}.type`, message: "未知参数类型" });
607
+ for (const r of ["label", "defaultValue", "placeholder"]) u(a, r, f, t);
608
+ A(a, "required", f, t);
538
609
  for (const r of ["minLength", "maxLength"]) {
539
610
  const d = a[r];
540
611
  d !== void 0 && (typeof d != "number" || !Number.isSafeInteger(d) || d < 0) && t.push({ path: `${f}.${r}`, message: "长度边界应为非负整数" });
541
612
  }
542
- He(a, f, t), a.options !== void 0 && (Array.isArray(a.options) ? a.options.forEach((r, d) => {
613
+ Qe(a, f, t), a.options !== void 0 && (Array.isArray(a.options) ? a.options.forEach((r, d) => {
543
614
  const h = `${f}.options.${d}`;
544
- if (!u(r)) t.push({ path: h, message: "选项应为对象" });
615
+ if (!c(r)) t.push({ path: h, message: "选项应为对象" });
545
616
  else
546
- for (const p of ["label", "value"]) typeof r[p] != "string" && t.push({ path: `${h}.${p}`, message: "选项标签与值应为字符串(允许空白选项)" });
617
+ for (const m of ["label", "value"]) typeof r[m] != "string" && t.push({ path: `${h}.${m}`, message: "选项标签与值应为字符串(允许空白选项)" });
547
618
  }) : t.push({ path: `${f}.options`, message: "选项应为数组" }));
548
- }), t.length === n && t.push(...ne(e).map((a) => ({ path: a.path.replace("$.paramDefs", i), message: a.message })));
619
+ }), t.length === n && t.push(...re(e).map((a) => ({ path: a.path.replace("$.paramDefs", i), message: a.message })));
549
620
  }
550
- function He(e, i, t) {
621
+ function Qe(e, i, t) {
551
622
  for (const a of ["min", "max"]) {
552
623
  const o = e[a];
553
624
  if (o === void 0) continue;
554
- ae(e.type, o) || ["number", "numberRange"].includes(e.type) && typeof o == "number" && Number.isFinite(o) || t.push({ path: `${i}.${a}`, message: "数字使用有限数字边界,日期/月/年使用对应规范字符串边界" });
625
+ de(e.type, o) || ["number", "numberRange"].includes(e.type) && typeof o == "number" && Number.isFinite(o) || t.push({ path: `${i}.${a}`, message: "数字使用有限数字边界,日期/月/年使用对应规范字符串边界" });
555
626
  }
556
627
  const s = typeof e.min == "number" && typeof e.max == "number" && e.min > e.max, n = typeof e.min == "string" && typeof e.max == "string" && e.min > e.max;
557
628
  (s || n) && t.push({ path: i, message: "最小边界不能大于最大边界" }), typeof e.minLength == "number" && typeof e.maxLength == "number" && e.minLength > e.maxLength && t.push({ path: i, message: "最小长度不能大于最大长度" });
558
629
  }
559
- function U(e, i, t) {
630
+ function Y(e, i, t) {
560
631
  if (!Array.isArray(e) || e.length === 0) {
561
632
  t.push({ path: i, message: "列表至少需要一列" });
562
633
  return;
563
634
  }
564
- e.every((s) => u(s) && s.hidden === !0) && t.push({ path: i, message: "列表至少需要一列可见列" }), e.forEach((s, n) => {
635
+ e.every((s) => c(s) && s.hidden === !0) && t.push({ path: i, message: "列表至少需要一列可见列" }), e.forEach((s, n) => {
565
636
  const a = `${i}.${n}`;
566
- if (!u(s)) {
637
+ if (!c(s)) {
567
638
  t.push({ path: a, message: "列应为对象" });
568
639
  return;
569
640
  }
570
- if (D(s, a, t), s.visual !== void 0 && !re(s.visual) && t.push({ path: `${a}.visual`, message: "列可视化配置无效,请检查类型、数值范围和颜色" }), b(s, "hidden", a, t), F(s.visibleWhen, `${a}.visibleWhen`, t), typeof s.header != "string" && t.push({ path: `${a}.header`, message: "表头应为字符串(允许空白表头)" }), m(s, "field", a, t, !0), c(s, "widthMm", a, t, Number.MIN_VALUE, !0), $(s.style, `${a}.style`, t), $(s.headerStyle, `${a}.headerStyle`, t), M(s.align, `${a}.align`, t, !0), M(s.headerAlign, `${a}.headerAlign`, t), s.semanticRole !== void 0 && !["identifier", "dimension", "measure", "date", "text"].includes(s.semanticRole) && t.push({ path: `${a}.semanticRole`, message: "未知列语义" }), s.format !== void 0)
571
- if (!u(s.format) || !["number", "percent", "date"].includes(s.format.kind))
641
+ if (H(s, a, t), s.visual !== void 0 && !me(s.visual) && t.push({ path: `${a}.visual`, message: "列可视化配置无效,请检查类型、数值范围和颜色" }), A(s, "hidden", a, t), C(s.visibleWhen, `${a}.visibleWhen`, t), typeof s.header != "string" && t.push({ path: `${a}.header`, message: "表头应为字符串(允许空白表头)" }), u(s, "field", a, t, !0), g(s, "widthMm", a, t, Number.MIN_VALUE, !0), b(s.style, `${a}.style`, t), b(s.headerStyle, `${a}.headerStyle`, t), M(s.align, `${a}.align`, t, !0), M(s.headerAlign, `${a}.headerAlign`, t), s.semanticRole !== void 0 && !["identifier", "dimension", "measure", "date", "text"].includes(s.semanticRole) && t.push({ path: `${a}.semanticRole`, message: "未知列语义" }), s.format !== void 0)
642
+ if (!c(s.format) || !["number", "percent", "date"].includes(s.format.kind))
572
643
  t.push({ path: `${a}.format`, message: "未知列格式" });
573
644
  else {
574
645
  const o = s.format.digits;
575
- o !== void 0 && (typeof o != "number" || !Number.isInteger(o) || o < 0 || o > 100) && t.push({ path: `${a}.format.digits`, message: "小数位应为 0–100 的整数" }), b(s.format, "thousands", `${a}.format`, t), m(s.format, "pattern", `${a}.format`, t);
646
+ o !== void 0 && (typeof o != "number" || !Number.isInteger(o) || o < 0 || o > 100) && t.push({ path: `${a}.format.digits`, message: "小数位应为 0–100 的整数" }), A(s.format, "thousands", `${a}.format`, t), u(s.format, "pattern", `${a}.format`, t);
576
647
  }
577
648
  s.rules !== void 0 && (Array.isArray(s.rules) ? s.rules.forEach((o, f) => {
578
649
  const r = `${a}.rules.${f}`;
579
- if (!u(o) || !u(o.when)) {
650
+ if (!c(o) || !c(o.when)) {
580
651
  t.push({ path: r, message: "条件格式缺少 when 对象" });
581
652
  return;
582
653
  }
583
- F(o.when, `${r}.when`, t), $(o.style, `${r}.style`, t);
654
+ C(o.when, `${r}.when`, t), b(o.style, `${r}.style`, t);
584
655
  }) : t.push({ path: `${a}.rules`, message: "条件格式应为数组" }));
585
656
  });
586
657
  }
587
- function z(e, i, t) {
658
+ function Q(e, i, t) {
588
659
  if (e !== void 0) {
589
- if (!u(e)) {
660
+ if (!c(e)) {
590
661
  t.push({ path: i, message: "分组应为对象" });
591
662
  return;
592
663
  }
593
- m(e, "field", i, t, !0);
594
- for (const s of ["headerTemplate", "subtotalLabel"]) m(e, s, i, t);
595
- for (const s of ["headerStyle", "subtotalStyle"]) $(e[s], `${i}.${s}`, t);
596
- b(e, "keepWithNext", i, t), b(e, "repeatHeader", i, t), W(e.aggregates, `${i}.aggregates`, t), e.subtotal !== void 0 && (!Array.isArray(e.subtotal) || e.subtotal.some((s) => typeof s != "string")) && t.push({ path: `${i}.subtotal`, message: "小计字段应为字符串数组" });
664
+ u(e, "field", i, t, !0);
665
+ for (const s of ["headerTemplate", "subtotalLabel"]) u(e, s, i, t);
666
+ for (const s of ["headerStyle", "subtotalStyle"]) b(e[s], `${i}.${s}`, t);
667
+ A(e, "keepWithNext", i, t), A(e, "repeatHeader", i, t), q(e.aggregates, `${i}.aggregates`, t), e.subtotal !== void 0 && (!Array.isArray(e.subtotal) || e.subtotal.some((s) => typeof s != "string")) && t.push({ path: `${i}.subtotal`, message: "小计字段应为字符串数组" });
597
668
  }
598
669
  }
599
- function Je(e, i, t) {
670
+ function Ze(e, i, t) {
600
671
  if (!(e === void 0 || typeof e == "boolean")) {
601
- if (!u(e)) {
672
+ if (!c(e)) {
602
673
  t.push({ path: i, message: "合计应为布尔值或对象" });
603
674
  return;
604
675
  }
605
- m(e, "label", i, t), W(e.aggregates, `${i}.aggregates`, t), $(e.style, `${i}.style`, t), e.fields !== void 0 && (!Array.isArray(e.fields) || e.fields.some((s) => typeof s != "string")) && t.push({ path: `${i}.fields`, message: "合计字段应为字符串数组" });
676
+ u(e, "label", i, t), q(e.aggregates, `${i}.aggregates`, t), b(e.style, `${i}.style`, t), e.fields !== void 0 && (!Array.isArray(e.fields) || e.fields.some((s) => typeof s != "string")) && t.push({ path: `${i}.fields`, message: "合计字段应为字符串数组" });
606
677
  }
607
678
  }
608
- function We(e, i, t, s) {
679
+ function et(e, i, t, s) {
609
680
  const n = { kind: "rect", leftMm: 0, topMm: 0, widthMm: 1, heightMm: 1, grid: e };
610
- if (K(n, t, s, []), L(n, t, s), !u(e) || !Array.isArray(e.cells)) return;
681
+ if (G(n, t, s, []), j(n, t, s), !c(e) || !Array.isArray(e.cells)) return;
611
682
  const a = e.cells, o = Array.isArray(i) ? i.length : 0;
612
- if (a.length * o > E) {
683
+ if (a.length * o > S) {
613
684
  s.push({ path: t, message: "表头逻辑网格超过 20 万格安全上限" });
614
685
  return;
615
686
  }
616
- e.cells.length || s.push({ path: `${t}.cells`, message: "表头至少需要一行" }), Array.isArray(e.colWidthsMm) && e.colWidthsMm.length !== o && s.push({ path: `${t}.colWidthsMm`, message: "表头列宽数量应与列表列数一致" }), Array.isArray(e.rowHeightsMm) && e.rowHeightsMm.length !== e.cells.length && s.push({ path: `${t}.rowHeightsMm`, message: "表头行高数量应与行数一致" }), Ge(a, o, t, s);
687
+ e.cells.length || s.push({ path: `${t}.cells`, message: "表头至少需要一行" }), Array.isArray(e.colWidthsMm) && e.colWidthsMm.length !== o && s.push({ path: `${t}.colWidthsMm`, message: "表头列宽数量应与列表列数一致" }), Array.isArray(e.rowHeightsMm) && e.rowHeightsMm.length !== e.cells.length && s.push({ path: `${t}.rowHeightsMm`, message: "表头行高数量应与行数一致" }), tt(a, o, t, s);
617
688
  }
618
- function Ge(e, i, t, s) {
689
+ function tt(e, i, t, s) {
619
690
  const n = /* @__PURE__ */ new Set();
620
691
  e.forEach((a, o) => {
621
692
  if (!Array.isArray(a)) return;
622
693
  let f = 0;
623
694
  a.forEach((r, d) => {
624
695
  for (; n.has(`${o}:${f}`); ) f++;
625
- const h = u(r) && typeof r.colSpan == "number" ? r.colSpan : 1, p = u(r) && typeof r.rowSpan == "number" ? r.rowSpan : 1;
626
- (f + h > i || o + p > e.length) && s.push({ path: `${t}.cells.${o}.${d}`, message: "表头合并区域超出表头边界" });
627
- for (let y = o; y < Math.min(e.length, o + p); y++)
628
- for (let A = f; A < Math.min(i, f + h); A++)
629
- n.has(`${y}:${A}`) && s.push({ path: `${t}.cells.${o}.${d}`, message: "表头合并区域重叠" }), n.add(`${y}:${A}`);
696
+ const h = c(r) && typeof r.colSpan == "number" ? r.colSpan : 1, m = c(r) && typeof r.rowSpan == "number" ? r.rowSpan : 1;
697
+ (f + h > i || o + m > e.length) && s.push({ path: `${t}.cells.${o}.${d}`, message: "表头合并区域超出表头边界" });
698
+ for (let y = o; y < Math.min(e.length, o + m); y++)
699
+ for (let l = f; l < Math.min(i, f + h); l++)
700
+ n.has(`${y}:${l}`) && s.push({ path: `${t}.cells.${o}.${d}`, message: "表头合并区域重叠" }), n.add(`${y}:${l}`);
630
701
  f += h;
631
702
  });
632
703
  });
633
704
  }
634
- function Ue(e, i, t) {
635
- if (Oe(e, i, t), Ie(e.computed, `${i}.computed`, t), Pe(e.matrix, `${i}.matrix`, t), e.matrix && (e.detail || e.groupBy || Array.isArray(e.groups) && e.groups.length || e.grandTotal) && t.push({ path: `${i}.matrix`, message: "矩阵请使用自身 totals 汇总,不能同时配置普通分组、总计或主从明细" }), F(e.rowVisibleWhen, `${i}.rowVisibleWhen`, t), e.groups !== void 0 && (!Array.isArray(e.groups) || e.groups.length > 16 ? t.push({ path: `${i}.groups`, message: "分组应为数组,最多 16 级" }) : e.groups.forEach((a, o) => z(a, `${i}.groups.${o}`, t))), e.detail === void 0) return;
705
+ function it(e, i, t) {
706
+ if (Be(e, i, t), Le(e.computed, `${i}.computed`, t), je(e.matrix, `${i}.matrix`, t), e.matrix && (e.detail || e.groupBy || Array.isArray(e.groups) && e.groups.length || e.grandTotal) && t.push({ path: `${i}.matrix`, message: "矩阵请使用自身 totals 汇总,不能同时配置普通分组、总计或主从明细" }), C(e.rowVisibleWhen, `${i}.rowVisibleWhen`, t), e.groups !== void 0 && (!Array.isArray(e.groups) || e.groups.length > 16 ? t.push({ path: `${i}.groups`, message: "分组应为数组,最多 16 级" }) : e.groups.forEach((a, o) => Q(a, `${i}.groups.${o}`, t))), e.detail === void 0) return;
636
707
  const s = e.detail, n = `${i}.detail`;
637
- if (!u(s)) {
708
+ if (!c(s)) {
638
709
  t.push({ path: n, message: "主从关联应为对象" });
639
710
  return;
640
711
  }
641
- for (const a of ["dataset", "parentKey", "foreignKey"]) m(s, a, n, t, !0);
642
- for (const a of ["rowKey", "revisionField", "sourceTokenField"]) m(s, a, n, t, s[a] !== void 0);
643
- m(s, "label", n, t), b(s, "header", n, t), c(s, "rowHeightMm", n, t, Number.MIN_VALUE), U(s.columns, `${n}.columns`, t), s.unmatched !== void 0 && s.unmatched !== "error" && s.unmatched !== "ignore" && t.push({ path: `${n}.unmatched`, message: "未关联明细策略应为 error 或 ignore" });
712
+ for (const a of ["dataset", "parentKey", "foreignKey"]) u(s, a, n, t, !0);
713
+ for (const a of ["rowKey", "revisionField", "sourceTokenField"]) u(s, a, n, t, s[a] !== void 0);
714
+ u(s, "label", n, t), A(s, "header", n, t), g(s, "rowHeightMm", n, t, Number.MIN_VALUE), Y(s.columns, `${n}.columns`, t), s.unmatched !== void 0 && s.unmatched !== "error" && s.unmatched !== "ignore" && t.push({ path: `${n}.unmatched`, message: "未关联明细策略应为 error 或 ignore" });
644
715
  }
645
- function ze(e, i, t) {
646
- for (const s of ["leftMm", "topMm"]) c(e, s, i, t, -1 / 0, !0);
647
- c(e, "widthMm", i, t, Number.MIN_VALUE, !0), m(e, "dataset", i, t, !0), m(e, "title", i, t);
648
- for (const s of ["rowKey", "revisionField", "sourceTokenField"]) m(e, s, i, t, e[s] !== void 0);
649
- e.headerGrid !== void 0 && We(e.headerGrid, e.columns, `${i}.headerGrid`, t), e.layout !== void 0 && e.layout !== "page" && e.layout !== "wide" && t.push({ path: `${i}.layout`, message: "布局应为 page 或 wide" }), U(e.columns, `${i}.columns`, t);
650
- for (const s of ["fontSizePt", "rowHeightMm"]) c(e, s, i, t, Number.MIN_VALUE);
651
- c(e, "paddingMm", i, t);
652
- for (const s of ["header", "headerBold", "headerEveryPage", "border"]) b(e, s, i, t);
653
- e.cardinality !== void 0 && e.cardinality !== "record" && t.push({ path: `${i}.cardinality`, message: "单记录区域类型应为 record" }), m(e, "headerBackgroundColor", i, t), M(e.align, `${i}.align`, t, !0), M(e.headerAlign, `${i}.headerAlign`, t), $(e.headerStyle, `${i}.headerStyle`, t), Ue(e, i, t), z(e.groupBy, `${i}.groupBy`, t), Je(e.grandTotal, `${i}.grandTotal`, t);
654
- }
655
- function _(e, i, t) {
716
+ function st(e, i, t) {
717
+ for (const s of ["leftMm", "topMm"]) g(e, s, i, t, -1 / 0, !0);
718
+ g(e, "widthMm", i, t, Number.MIN_VALUE, !0), u(e, "dataset", i, t, !0), u(e, "title", i, t);
719
+ for (const s of ["rowKey", "revisionField", "sourceTokenField"]) u(e, s, i, t, e[s] !== void 0);
720
+ e.headerGrid !== void 0 && et(e.headerGrid, e.columns, `${i}.headerGrid`, t), e.layout !== void 0 && e.layout !== "page" && e.layout !== "wide" && t.push({ path: `${i}.layout`, message: "布局应为 page 或 wide" }), Y(e.columns, `${i}.columns`, t);
721
+ for (const s of ["fontSizePt", "rowHeightMm"]) g(e, s, i, t, Number.MIN_VALUE);
722
+ g(e, "paddingMm", i, t);
723
+ for (const s of ["header", "headerBold", "headerEveryPage", "border"]) A(e, s, i, t);
724
+ e.cardinality !== void 0 && e.cardinality !== "record" && t.push({ path: `${i}.cardinality`, message: "单记录区域类型应为 record" }), u(e, "headerBackgroundColor", i, t), M(e.align, `${i}.align`, t, !0), M(e.headerAlign, `${i}.headerAlign`, t), b(e.headerStyle, `${i}.headerStyle`, t), it(e, i, t), Q(e.groupBy, `${i}.groupBy`, t), Ze(e.grandTotal, `${i}.grandTotal`, t);
725
+ }
726
+ function D(e, i, t) {
656
727
  Array.isArray(e.richParagraphs) && e.richParagraphs.forEach((s, n) => {
657
- if (!u(s)) return;
728
+ if (!c(s)) return;
658
729
  const a = `${i}.richParagraphs.${n}`;
659
730
  M(s.align, `${a}.align`, t);
660
- for (const o of ["lineHeight", "spaceBeforeMm", "spaceAfterMm", "indentMm"]) c(s, o, a, t);
731
+ for (const o of ["lineHeight", "spaceBeforeMm", "spaceAfterMm", "indentMm"]) g(s, o, a, t);
661
732
  Array.isArray(s.segments) && s.segments.forEach((o, f) => {
662
733
  const r = `${a}.segments.${f}`;
663
- if (!u(o)) {
734
+ if (!c(o)) {
664
735
  t.push({ path: r, message: "富文本片段应为对象" });
665
736
  return;
666
737
  }
667
738
  o.kind !== void 0 && o.kind !== "text" && o.kind !== "field" && t.push({ path: `${r}.kind`, message: "未知富文本片段类型" });
668
- for (const d of ["text", "field"]) m(o, d, r, t);
669
- $(o.style, `${r}.style`, t);
739
+ for (const d of ["text", "field"]) u(o, d, r, t);
740
+ b(o.style, `${r}.style`, t);
670
741
  });
671
742
  });
672
743
  }
673
- function L(e, i, t) {
674
- $(e.style, `${i}.style`, t);
675
- for (const n of ["text", "rawText", "imageData", "fallbackText", "nid", "rkey"]) m(e, n, i, t);
676
- if (e.lines !== void 0 && (!Array.isArray(e.lines) || e.lines.some((n) => typeof n != "string")) && t.push({ path: `${i}.lines`, message: "文本行应为字符串数组" }), _(e, i, t), !u(e.grid)) return;
744
+ function j(e, i, t) {
745
+ b(e.style, `${i}.style`, t);
746
+ for (const n of ["text", "rawText", "imageData", "fallbackText", "nid", "rkey"]) u(e, n, i, t);
747
+ if (e.lines !== void 0 && (!Array.isArray(e.lines) || e.lines.some((n) => typeof n != "string")) && t.push({ path: `${i}.lines`, message: "文本行应为字符串数组" }), D(e, i, t), !c(e.grid)) return;
677
748
  const s = e.grid;
678
- c(s, "gapMm", `${i}.grid`, t), c(s, "paddingMm", `${i}.grid`, t);
749
+ g(s, "gapMm", `${i}.grid`, t), g(s, "paddingMm", `${i}.grid`, t);
679
750
  for (const n of ["colWidthsMm", "rowHeightsMm"]) {
680
751
  const a = s[n];
681
752
  a !== void 0 && (!Array.isArray(a) || a.some((o) => typeof o != "number" || !Number.isFinite(o) || o < 0)) && t.push({ path: `${i}.grid.${n}`, message: "网格尺寸应为有限非负数字数组" });
@@ -684,75 +755,75 @@ function L(e, i, t) {
684
755
  Array.isArray(n) && n.forEach((o, f) => {
685
756
  const r = `${i}.grid.cells.${a}.${f}`;
686
757
  if (o !== null) {
687
- if (!u(o)) {
758
+ if (!c(o)) {
688
759
  t.push({ path: r, message: "网格单元格应为对象或 null" });
689
760
  return;
690
761
  }
691
- for (const d of ["text", "rawText", "numberFormat"]) m(o, d, r, t);
762
+ for (const d of ["text", "rawText", "numberFormat"]) u(o, d, r, t);
692
763
  for (const d of ["colSpan", "rowSpan"]) {
693
764
  const h = o[d];
694
765
  h !== void 0 && (typeof h != "number" || !Number.isInteger(h) || h <= 0) && t.push({ path: `${r}.${d}`, message: "跨度应为正整数" });
695
766
  }
696
- o.value !== void 0 && o.value !== null && !["string", "number", "boolean"].includes(typeof o.value) && t.push({ path: `${r}.value`, message: "Excel 原始值应为字符串、数字、布尔值或 null" }), $(o.style, `${r}.style`, t), _(o, r, t), o.children !== void 0 && (Array.isArray(o.children) ? o.children.forEach((d, h) => {
697
- u(d) && L(d, `${r}.children.${h}`, t);
767
+ o.value !== void 0 && o.value !== null && !["string", "number", "boolean"].includes(typeof o.value) && t.push({ path: `${r}.value`, message: "Excel 原始值应为字符串、数字、布尔值或 null" }), b(o.style, `${r}.style`, t), D(o, r, t), o.children !== void 0 && (Array.isArray(o.children) ? o.children.forEach((d, h) => {
768
+ c(d) && j(d, `${r}.children.${h}`, t);
698
769
  }) : t.push({ path: `${r}.children`, message: "嵌套组件应为数组" }));
699
770
  }
700
771
  });
701
772
  });
702
773
  }
703
- function qe(e, i, t) {
774
+ function nt(e, i, t) {
704
775
  if (!(e.flow === void 0 || !Array.isArray(e.components)))
705
776
  try {
706
- Ee(e.components, e.flow);
777
+ Re(e.components, e.flow);
707
778
  } catch (s) {
708
779
  t.push({ path: `${i}.flow`, message: s instanceof Error ? s.message : String(s) });
709
780
  }
710
781
  }
711
- function Xe(e) {
782
+ function at(e) {
712
783
  const i = [], t = [];
713
- return O(e, i), i.length ? { ok: !1, errors: i, warnings: t } : (u(e) ? (e.schemaVersion !== void 0 && e.schemaVersion !== ie && i.push({ path: "$.schemaVersion", message: "不支持的模板 schemaVersion" }), Ke(e.params, "$.params", i), Te(e, i), !Array.isArray(e.pages) || e.pages.length === 0 ? i.push({ path: "$.pages", message: "模板至少需要一页" }) : e.pages.forEach((s, n) => {
784
+ return L(e, i), i.length ? { ok: !1, errors: i, warnings: t } : (c(e) ? (e.schemaVersion !== void 0 && e.schemaVersion !== oe && i.push({ path: "$.schemaVersion", message: "不支持的模板 schemaVersion" }), Ye(e.params, "$.params", i), I(e.dataContract, "$.dataContract", i), Oe(e, i), !Array.isArray(e.pages) || e.pages.length === 0 ? i.push({ path: "$.pages", message: "模板至少需要一页" }) : e.pages.forEach((s, n) => {
714
785
  const a = `$.pages.${n}`;
715
- if (!u(s)) {
786
+ if (!c(s)) {
716
787
  i.push({ path: a, message: "页应为对象" });
717
788
  return;
718
789
  }
719
- c(s, "widthMm", a, i, Number.MIN_VALUE, !0), c(s, "heightMm", a, i, Number.MIN_VALUE, !0), s.layout !== void 0 && s.layout !== "page" && s.layout !== "wide" && i.push({ path: `${a}.layout`, message: "布局应为 page 或 wide" }), typeof s.heightMm == "number" && s.heightMm >= 5e3 && i.push({ path: `${a}.heightMm`, message: "页高应小于 5000mm" });
720
- for (const o of ["marginTopMm", "marginBottomMm", "marginLeftMm", "marginRightMm"]) c(s, o, a, i);
790
+ g(s, "widthMm", a, i, Number.MIN_VALUE, !0), g(s, "heightMm", a, i, Number.MIN_VALUE, !0), s.layout !== void 0 && s.layout !== "page" && s.layout !== "wide" && i.push({ path: `${a}.layout`, message: "布局应为 page 或 wide" }), typeof s.heightMm == "number" && s.heightMm >= 5e3 && i.push({ path: `${a}.heightMm`, message: "页高应小于 5000mm" });
791
+ for (const o of ["marginTopMm", "marginBottomMm", "marginLeftMm", "marginRightMm"]) g(s, o, a, i);
721
792
  typeof s.widthMm == "number" && Number(s.marginLeftMm ?? 0) + Number(s.marginRightMm ?? 0) >= s.widthMm && i.push({ path: a, message: "横向页边距占满页面" }), typeof s.heightMm == "number" && Number(s.marginTopMm ?? 0) + Number(s.marginBottomMm ?? 0) >= s.heightMm && i.push({ path: a, message: "纵向页边距占满页面" }), Array.isArray(s.components) ? s.components.forEach((o, f) => {
722
793
  const r = `${a}.components.${f}`;
723
- u(o) && o.kind === "list" ? ze(o, r, i) : (K(o, r, i, t), u(o) && L(o, r, i));
724
- }) : i.push({ path: `${a}.components`, message: "组件应为数组" }), qe(s, a, i);
794
+ c(o) && o.kind === "list" ? st(o, r, i) : (G(o, r, i, t), c(o) && j(o, r, i));
795
+ }) : i.push({ path: `${a}.components`, message: "组件应为数组" }), nt(s, a, i);
725
796
  })) : i.push({ path: "$", message: "模板应为对象" }), { ok: i.length === 0, errors: i, warnings: t });
726
797
  }
727
- function Ye(e) {
798
+ function ot(e) {
728
799
  const i = [], t = [];
729
- if (O(e, i), i.length) return { ok: !1, errors: i, warnings: t };
730
- if (!u(e)) i.push({ path: "$", message: "模板文档应为对象" });
800
+ if (L(e, i), i.length) return { ok: !1, errors: i, warnings: t };
801
+ if (!c(e)) i.push({ path: "$", message: "模板文档应为对象" });
731
802
  else {
732
803
  for (const n of Object.keys(e))
733
- _e.has(n) || i.push({ path: `$.${n}`, message: "模板文档存在未知字段;只保存模板与描述,不保存取数或业务数据" });
734
- e.schemaVersion !== G && i.push({ path: "$.schemaVersion", message: "不支持的模板文档版本" });
735
- for (const n of ["id", "name"]) m(e, n, "$", i, !0);
736
- for (const n of ["revision", "description"]) m(e, n, "$", i);
737
- const s = Xe(e.template);
804
+ We.has(n) || i.push({ path: `$.${n}`, message: "模板文档存在未知字段;只保存模板与描述,不保存取数或业务数据" });
805
+ e.schemaVersion !== X && i.push({ path: "$.schemaVersion", message: "不支持的模板文档版本" });
806
+ for (const n of ["id", "name"]) u(e, n, "$", i, !0);
807
+ for (const n of ["revision", "description"]) u(e, n, "$", i);
808
+ const s = at(e.template);
738
809
  i.push(...s.errors.map((n) => ({ ...n, path: `$.template${n.path.slice(1)}` }))), t.push(...s.warnings.map((n) => ({ ...n, path: `$.template${n.path.slice(1)}` })));
739
810
  }
740
811
  return { ok: i.length === 0, errors: i, warnings: t };
741
812
  }
742
- function R(e) {
743
- const i = Ye(e);
813
+ function T(e) {
814
+ const i = ot(e);
744
815
  if (!i.ok) throw new w(i.errors);
745
816
  }
746
- function ot(e) {
817
+ function yt(e) {
747
818
  const i = [];
748
- if (O(e, i), i.length) throw new w(i);
749
- const t = { ...e, schemaVersion: e.schemaVersion ?? G };
750
- return R(t), x(t);
819
+ if (L(e, i), i.length) throw new w(i);
820
+ const t = { ...e, schemaVersion: e.schemaVersion ?? X };
821
+ return T(t), R(t);
751
822
  }
752
- function ft(e) {
823
+ function lt(e) {
753
824
  let i = e;
754
825
  if (typeof e == "string") {
755
- if (e.length > B)
826
+ if (e.length > K)
756
827
  throw new w([{ path: "$", message: "模板 JSON 超过 1000 万字符的导出/导入上限" }]);
757
828
  try {
758
829
  i = JSON.parse(e);
@@ -760,29 +831,29 @@ function ft(e) {
760
831
  throw new w([{ path: "$", message: "模板 JSON 语法无效" }]);
761
832
  }
762
833
  }
763
- return R(i), x(i);
834
+ return T(i), R(i);
764
835
  }
765
- function rt(e) {
766
- R(e);
836
+ function $t(e) {
837
+ T(e);
767
838
  try {
768
- return de(e);
839
+ return ge(e);
769
840
  } catch (i) {
770
841
  throw i instanceof RangeError ? new w([{ path: "$", message: i.message }]) : i;
771
842
  }
772
843
  }
773
- function x(e) {
844
+ function R(e) {
774
845
  return JSON.parse(JSON.stringify(e));
775
846
  }
776
- function dt(e = []) {
847
+ function bt(e = []) {
777
848
  const i = /* @__PURE__ */ new Map(), t = {
778
849
  get: (s) => {
779
850
  const n = i.get(s);
780
- return n ? x(n) : void 0;
851
+ return n ? R(n) : void 0;
781
852
  },
782
853
  list: () => Array.from(i.values(), ({ template: s, ...n }) => ({ ...n })),
783
854
  register: (s, n = {}) => {
784
- if (R(s), i.has(s.id) && !n.replace) throw new w([{ path: "$.id", message: `模板 ID ${s.id} 已注册;更新需显式 replace:true` }]);
785
- i.set(s.id, x(s));
855
+ if (T(s), i.has(s.id) && !n.replace) throw new w([{ path: "$.id", message: `模板 ID ${s.id} 已注册;更新需显式 replace:true` }]);
856
+ i.set(s.id, R(s));
786
857
  },
787
858
  remove: (s) => i.delete(s)
788
859
  };
@@ -791,18 +862,19 @@ function dt(e = []) {
791
862
  }
792
863
  export {
793
864
  w as R,
794
- G as a,
795
- we as b,
796
- nt as c,
797
- dt as d,
798
- ot as e,
799
- K as f,
800
- Ae as g,
801
- Ye as h,
802
- Ee as i,
803
- Te as j,
804
- ft as p,
805
- at as r,
806
- rt as s,
807
- Xe as v
865
+ X as a,
866
+ ve as b,
867
+ mt as c,
868
+ bt as d,
869
+ yt as e,
870
+ G as f,
871
+ Se as g,
872
+ ot as h,
873
+ pt as i,
874
+ Re as j,
875
+ Oe as k,
876
+ lt as p,
877
+ gt as r,
878
+ $t as s,
879
+ at as v
808
880
  };