@agile-team/mach-report 2.23.1 → 2.24.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 (149) hide show
  1. package/README.md +8 -2
  2. package/dist/{ExcelBindingWizard-BrTmdo7f.cjs → ExcelBindingWizard-BV12hGiK.cjs} +1 -1
  3. package/dist/{ExcelBindingWizard-CcDMLO8Q.js → ExcelBindingWizard-Cy_lPjWV.js} +3 -3
  4. package/dist/ParamEditor-DenKjvKu.cjs +1 -0
  5. package/dist/ParamEditor-PyOqHzzw.js +750 -0
  6. package/dist/{ReportBatchPanel-CJB67WNd.js → ReportBatchPanel-8EFtMrKk.js} +2 -2
  7. package/dist/{ReportBatchPanel-CHxBtG9R.cjs → ReportBatchPanel-pQ6d0yqJ.cjs} +1 -1
  8. package/dist/ReportLabelStudio-B_KF3Zc_.cjs +1 -0
  9. package/dist/{ReportLabelStudio-Tplc1TLJ.js → ReportLabelStudio-HUeo2TsU.js} +68 -68
  10. package/dist/ReportParamPanel-8xR85nz-.cjs +1 -0
  11. package/dist/{ReportParamPanel-GI43aGa0.js → ReportParamPanel-DA-YpkvC.js} +328 -298
  12. package/dist/ReportPreview-CyUXJSVX.cjs +6 -0
  13. package/dist/ReportPreview-_wTJnsG1.js +7120 -0
  14. package/dist/{ReportTemplateLibrary-BFQIX0sg.cjs → ReportTemplateLibrary-CjArKxRG.cjs} +1 -1
  15. package/dist/{ReportTemplateLibrary-KqX4E2sN.js → ReportTemplateLibrary-DH8jl9IF.js} +28 -28
  16. package/dist/RuleEditor-Bmj98oC4.cjs +1 -0
  17. package/dist/{RuleEditor-OPX1awrH.js → RuleEditor-GDydlEHz.js} +846 -834
  18. package/dist/{TemplateOutlinePanel-CVYKVLv_.cjs → TemplateOutlinePanel-B554_qk1.cjs} +1 -1
  19. package/dist/{TemplateOutlinePanel-DQS-eOs6.js → TemplateOutlinePanel-DjPqzU9h.js} +10 -10
  20. package/dist/{TemplateReusePanel-CY6O93Zk.cjs → TemplateReusePanel-D0628OYc.cjs} +1 -1
  21. package/dist/{TemplateReusePanel-DKXiFTyB.js → TemplateReusePanel-DtYbCN7U.js} +2 -2
  22. package/dist/TemplateReviewPanel-CSwvCz3f.cjs +1 -0
  23. package/dist/TemplateReviewPanel-D_FR4ISq.js +602 -0
  24. package/dist/artifact-integrity.json +94 -94
  25. package/dist/assets-B4AJIOTB.cjs +1 -0
  26. package/dist/assets-D0FbszhB.js +137 -0
  27. package/dist/{auto-BB99S802.js → auto-BksreoKc.js} +5 -5
  28. package/dist/auto-C3mGqzJ8.cjs +1 -0
  29. package/dist/capabilities-CTwlcl8q.cjs +1 -0
  30. package/dist/capabilities-lqDEZSq5.js +121 -0
  31. package/dist/data-bar-2NLRzOCQ.cjs +1 -0
  32. package/dist/{data-bar-IkI6VvMQ.js → data-bar-BnGtnJ82.js} +1 -1
  33. package/dist/designer-BNf7NWd6.js +7589 -0
  34. package/dist/designer-DWnZZ_ej.cjs +2 -0
  35. package/dist/designer.cjs +1 -1
  36. package/dist/designer.d.cts +137 -4
  37. package/dist/designer.d.ts +137 -4
  38. package/dist/designer.js +5 -5
  39. package/dist/diagnostic-collector-1sqd7DQP.js +355 -0
  40. package/dist/diagnostic-collector-D3rlvxm3.cjs +1 -0
  41. package/dist/{dom-JWrchIre.js → dom-C90cTM6Y.js} +4 -4
  42. package/dist/dom-CxOkm_Sy.cjs +1 -0
  43. package/dist/{encoding-7lquyj0w.cjs → encoding-CkziAnZI.cjs} +1 -1
  44. package/dist/{encoding-CEd-dq9A.js → encoding-DSc9zv2F.js} +2 -2
  45. package/dist/{font-loader-D8pI87fL.cjs → font-loader-D-znWNWS.cjs} +1 -1
  46. package/dist/{font-loader-CNWXomuV.js → font-loader-i7lZbqH_.js} +1 -1
  47. package/dist/{grid-strokes-EoY66L2f.js → grid-strokes-BPiV1WHe.js} +1 -1
  48. package/dist/grid-strokes-DYf-6DMl.cjs +1 -0
  49. package/dist/index.cjs +5 -5
  50. package/dist/index.d.cts +46 -7
  51. package/dist/index.d.ts +46 -7
  52. package/dist/index.js +69 -68
  53. package/dist/{json-snapshot-BRnzKudk.js → json-snapshot-BJWZNryO.js} +919 -791
  54. package/dist/json-snapshot-C7QZrRBf.cjs +2 -0
  55. package/dist/{pdf-CJToa81Z.js → pdf-0_5XiTCx.js} +2499 -2492
  56. package/dist/{pdf-DpMkW72B.cjs → pdf-DWuq6uxx.cjs} +31 -31
  57. package/dist/pdf.cjs +1 -1
  58. package/dist/pdf.d.cts +18 -0
  59. package/dist/pdf.d.ts +18 -0
  60. package/dist/pdf.js +2 -2
  61. package/dist/{plugin-_BkUVc2z.js → plugin-B1ydqEmS.js} +1 -1
  62. package/dist/{plugin-BWTp-X7b.cjs → plugin-BQBz2vLG.cjs} +1 -1
  63. package/dist/prefill-2p9wrpn9.cjs +1 -0
  64. package/dist/{prefill-CWGdnqQd.js → prefill-Cuzh1wxf.js} +13 -13
  65. package/dist/prepared-CVbgO9KR.js +128 -0
  66. package/dist/prepared-DAwe8Il2.cjs +1 -0
  67. package/dist/protocol-BOri9qJL.js +105 -0
  68. package/dist/protocol-DD5dHSz-.cjs +1 -0
  69. package/dist/record-bindings-CAyM5tGg.cjs +1 -0
  70. package/dist/{record-bindings-DatJZv_e.js → record-bindings-fhav-NLG.js} +1 -1
  71. package/dist/{region-binding-workflow-DjrXuR1q.js → region-binding-workflow-Cm4mqhih.js} +2 -2
  72. package/dist/{region-binding-workflow-l7NGfagJ.cjs → region-binding-workflow-DWCUgjZl.cjs} +1 -1
  73. package/dist/report-encoding-worker.cjs +1 -1
  74. package/dist/report-encoding-worker.js +1 -1
  75. package/dist/rich-text-layout-X9YOz1JD.cjs +3 -0
  76. package/dist/{rich-text-layout-Ciwa6D2o.js → rich-text-layout-YJHtCWQI.js} +1 -1
  77. package/dist/runtime-BpSAgOw1.js +201 -0
  78. package/dist/runtime-Cd2UTnwe.cjs +1 -0
  79. package/dist/sbom.cdx.json +1 -1
  80. package/dist/server/node.d.cts +55 -7
  81. package/dist/server/node.d.ts +55 -7
  82. package/dist/server-node.cjs +5 -5
  83. package/dist/server-node.js +2721 -2430
  84. package/dist/server.cjs +1 -1
  85. package/dist/server.d.cts +47 -12
  86. package/dist/server.d.ts +47 -12
  87. package/dist/server.js +8 -8
  88. package/dist/style.css +1 -1
  89. package/dist/{template-catalog-DtrtT1FY.cjs → template-catalog--yBX169M.cjs} +1 -1
  90. package/dist/{template-catalog-CRuZL3pi.js → template-catalog-Bu7s7ReF.js} +3 -3
  91. package/dist/template-fragments-5EzVn7bm.cjs +1 -0
  92. package/dist/{template-fragments-CPpGpQoz.js → template-fragments-Di2vDFnx.js} +2 -2
  93. package/dist/{template-registry-O0hNIOfB.js → template-registry-BCBF2b8j.js} +10 -10
  94. package/dist/template-registry-Bnh5aEYf.cjs +1 -0
  95. package/dist/textwrap-BPFxhpOw.cjs +4 -0
  96. package/dist/{textwrap-D4ZksyMK.js → textwrap-CmVkhMhx.js} +1 -1
  97. package/dist/vue/async.d.cts +97 -18
  98. package/dist/vue/async.d.ts +97 -18
  99. package/dist/vue/index.d.cts +127 -28
  100. package/dist/vue/index.d.ts +127 -28
  101. package/dist/vue-async.cjs +1 -1
  102. package/dist/vue-async.js +3 -3
  103. package/dist/vue.cjs +1 -1
  104. package/dist/vue.js +192 -162
  105. package/dist/{workbook-session-C9ZmCBwY.js → workbook-session-B6P_-5a4.js} +2 -2
  106. package/dist/{workbook-session-C6-SrnCT.cjs → workbook-session-BnPK3T58.cjs} +1 -1
  107. package/dist/worker.cjs +1 -1
  108. package/dist/worker.d.cts +55 -7
  109. package/dist/worker.d.ts +55 -7
  110. package/dist/worker.js +4 -4
  111. package/dist/xlsx.cjs +4 -4
  112. package/dist/xlsx.d.cts +18 -1
  113. package/dist/xlsx.d.ts +18 -1
  114. package/dist/xlsx.js +279 -272
  115. package/package.json +1 -1
  116. package/dist/ParamEditor-BGjovFUe.js +0 -737
  117. package/dist/ParamEditor-CeNp4_zQ.cjs +0 -1
  118. package/dist/ReportLabelStudio-g8PkqJWn.cjs +0 -1
  119. package/dist/ReportParamPanel-C7fZTllk.cjs +0 -1
  120. package/dist/ReportPreview-BoGBGyRr.cjs +0 -6
  121. package/dist/ReportPreview-QLONCyci.js +0 -6257
  122. package/dist/RuleEditor-BZUP9yvL.cjs +0 -1
  123. package/dist/TemplateReviewPanel-DbeNC8Ms.cjs +0 -1
  124. package/dist/TemplateReviewPanel-Dijwm9YE.js +0 -593
  125. package/dist/assets-D2gHc4Mz.cjs +0 -1
  126. package/dist/assets-T_gDeFaz.js +0 -132
  127. package/dist/auto-BrPWo7Xm.cjs +0 -1
  128. package/dist/capabilities-DiBj4Qgl.cjs +0 -1
  129. package/dist/capabilities-pg7j7VLT.js +0 -106
  130. package/dist/data-bar-CeZuFmYl.cjs +0 -1
  131. package/dist/designer-BZoVWTgl.js +0 -7172
  132. package/dist/designer-zS2uKJmY.cjs +0 -2
  133. package/dist/dom-ChE5D-L-.cjs +0 -1
  134. package/dist/grid-strokes-Be24LGuV.cjs +0 -1
  135. package/dist/json-snapshot-DNiIbpOr.cjs +0 -2
  136. package/dist/prefill-PaAy6wLk.cjs +0 -1
  137. package/dist/prepared-CJy_qk7d.js +0 -94
  138. package/dist/prepared-D0yCSxSO.cjs +0 -1
  139. package/dist/progress-ByiOxUD3.js +0 -250
  140. package/dist/progress-WomPRP3B.cjs +0 -1
  141. package/dist/protocol-BG16rz6D.js +0 -90
  142. package/dist/protocol-wzhl1Fim.cjs +0 -1
  143. package/dist/record-bindings-MBxbeBsi.cjs +0 -1
  144. package/dist/rich-text-layout-DK7A_a5r.cjs +0 -3
  145. package/dist/runtime-DYMOS_gz.cjs +0 -1
  146. package/dist/runtime-PiCax9zQ.js +0 -171
  147. package/dist/template-fragments-GVjpew_q.cjs +0 -1
  148. package/dist/template-registry-DI59PXVK.cjs +0 -1
  149. package/dist/textwrap-DEHqAjKZ.cjs +0 -4
@@ -1,16 +1,16 @@
1
- import { r as te, a as re, L as ye, b as Wt, R as be, j as Vt, m as j, D as We } from "./progress-ByiOxUD3.js";
2
- import { w as _, h as Ve } from "./textwrap-D4ZksyMK.js";
3
- import { e as ve, n as H, b as Me, q as N, s as zt, t as Jt } from "./computed-f3pOqWLX.js";
4
- import { d as ze, R as $, f as W, k as Je, b as _t, i as qt, v as Se, c as Ut, P as Y, l as xe, t as _e, m as qe, h as Ue, n as Xt, o as Yt, D as Qt, e as fe } from "./record-bindings-DatJZv_e.js";
5
- import { c as Zt, e as er } from "./matrix-C6e_r_vp.js";
6
- import { f as Xe, d as tr, e as rr, c as Ye } from "./template-serialization-CWmHq7lX.js";
7
- import { j as nr, r as or, k as ar, b as Qe, v as sr, R as ir } from "./template-registry-O0hNIOfB.js";
8
- import { g as cr } from "./report-params-D9tBuM9B.js";
9
- import { a as Oe } from "./param-validation-CnDEd2l-.js";
10
- import { f as lr, i as dr } from "./number-format-BA_KwrZe.js";
11
- import { v as Ze, d as ur } from "./dataset-DL83majE.js";
12
- const fr = 4096, Ae = 128 * 1024;
13
- function mr(e) {
1
+ import { r as q, a as Z, L as xe, b as zt, R as Pe, j as Jt, m as H, D as ke } from "./diagnostic-collector-1sqd7DQP.js";
2
+ import { w as B, h as re } from "./textwrap-CmVkhMhx.js";
3
+ import { e as Ce, n as G, b as Te, q as D, s as _t, t as qt } from "./computed-f3pOqWLX.js";
4
+ import { d as Xe, R as F, f as U, k as Ye, b as Ut, i as Xt, v as Ee, c as Yt, P as ne, l as Re, t as Qe, m as Ze, h as et, n as Qt, o as Zt, D as er, e as pe } from "./record-bindings-fhav-NLG.js";
5
+ import { c as tr, e as rr } from "./matrix-C6e_r_vp.js";
6
+ import { f as tt, d as nr, e as or, c as rt } from "./template-serialization-CWmHq7lX.js";
7
+ import { j as ar, r as sr, k as ir, b as Ie, v as cr, R as lr } from "./template-registry-BCBF2b8j.js";
8
+ import { g as dr } from "./report-params-D9tBuM9B.js";
9
+ import { a as Be } from "./param-validation-CnDEd2l-.js";
10
+ import { f as ur, i as fr } from "./number-format-BA_KwrZe.js";
11
+ import { v as nt, d as mr } from "./dataset-DL83majE.js";
12
+ const hr = 4096, Ge = 128 * 1024;
13
+ function gr(e) {
14
14
  const t = /* @__PURE__ */ new Map();
15
15
  let r = 0;
16
16
  return { measureMm(n, o) {
@@ -18,8 +18,8 @@ function mr(e) {
18
18
  if (s !== void 0)
19
19
  return t.delete(a), t.set(a, s), s;
20
20
  const i = e.measureMm(n, o);
21
- if (Number.isFinite(i) && a.length <= Ae) {
22
- for (; t.size >= fr || r + a.length > Ae; ) {
21
+ if (Number.isFinite(i) && a.length <= Ge) {
22
+ for (; t.size >= hr || r + a.length > Ge; ) {
23
23
  const c = t.keys().next().value;
24
24
  r -= c.length, t.delete(c);
25
25
  }
@@ -28,10 +28,10 @@ function mr(e) {
28
28
  return i;
29
29
  } };
30
30
  }
31
- function hr(e, t) {
31
+ function pr(e, t) {
32
32
  return { member: "body", subtotal: "subtotal", total: "grand-total" }[e?.rows.get(t)?.kind ?? "member"];
33
33
  }
34
- function gr(e) {
34
+ function wr(e) {
35
35
  const t = e.matrix;
36
36
  if (!t.hierarchy) return t;
37
37
  const r = new Map(e.columns.map((o) => [o.field, o.header])), n = { sum: "求和", count: "计数", avg: "平均", min: "最小", max: "最大", weightedAvg: "加权平均" };
@@ -44,10 +44,10 @@ function gr(e) {
44
44
  return o.label === void 0 && a ? { ...o, label: `${a}(${n[o.op]})` } : o;
45
45
  }) };
46
46
  }
47
- function pr(e, t) {
47
+ function yr(e, t) {
48
48
  if (!e.matrix) return { list: e, rows: t };
49
49
  if (e.detail || e.groupBy || e.groups?.length || e.grandTotal) throw new Error("矩阵不能同时配置普通分组、总计或主从明细");
50
- const r = Zt(t, gr(e)), n = r.columns.map((i) => ({ ...i, widthMm: i.semanticRole === "dimension" ? e.matrix.rowWidthMm ?? 40 : e.matrix.columnWidthMm ?? 28, editable: !1, align: i.semanticRole === "dimension" ? "center" : "right" })), o = { ...e, columns: n, headerGrid: r.headerGrid, rowKey: void 0, revisionField: void 0, sourceTokenField: void 0 };
50
+ const r = tr(t, wr(e)), n = r.columns.map((i) => ({ ...i, widthMm: i.semanticRole === "dimension" ? e.matrix.rowWidthMm ?? 40 : e.matrix.columnWidthMm ?? 28, editable: !1, align: i.semanticRole === "dimension" ? "center" : "right" })), o = { ...e, columns: n, headerGrid: r.headerGrid, rowKey: void 0, revisionField: void 0, sourceTokenField: void 0 };
51
51
  e.layout === "wide" && (o.widthMm = n.reduce((i, c) => i + c.widthMm, 0));
52
52
  const a = r.metadata, s = a ? { rows: new WeakMap(r.rows.map((i, c) => [i, a.rows[c]])), header: {
53
53
  columns: a.columns,
@@ -58,18 +58,18 @@ function pr(e, t) {
58
58
  } } : void 0;
59
59
  return { list: o, rows: r.rows, ...s ? { matrix: s } : {} };
60
60
  }
61
- function wr(e, t) {
61
+ function br(e, t) {
62
62
  if (!e.matrix?.hierarchy || !e.headerGrid) return e.headerGrid;
63
- const r = e.paddingMm ?? 1, n = e.headerGrid.cells.map(() => e.rowHeightMm ?? 0), o = e.columns.map((c) => c.widthMm), a = te({ ...e.headerGrid, colWidthsMm: o }, o.reduce((c, l) => c + l, 0), n.length), s = /* @__PURE__ */ new WeakMap();
63
+ const r = e.paddingMm ?? 1, n = e.headerGrid.cells.map(() => e.rowHeightMm ?? 0), o = e.columns.map((c) => c.widthMm), a = q({ ...e.headerGrid, colWidthsMm: o }, o.reduce((c, l) => c + l, 0), n.length), s = /* @__PURE__ */ new WeakMap();
64
64
  for (const { cell: c, ci: l, ri: u, widthMm: f } of a.cells) {
65
- const d = { ...ze(e, e.columns[l]), ...c.style }, h = re(d).fontSizePt, v = (_(c.text ?? "", Math.max(1, f - r * 2), { fontSizePt: h, fontFamily: d.fontFamily, bold: d.bold, italic: d.italic, letterSpacingPt: d.letterSpacing }, t).length * h * (d.lineHeight ?? ye) * 25.4 / 72 + r * 2) / (c.rowSpan ?? 1);
66
- for (let p = u; p < u + (c.rowSpan ?? 1); p++) n[p] = Math.max(n[p] ?? 0, v);
65
+ const d = { ...Xe(e, e.columns[l]), ...c.style }, m = Z(d).fontSizePt, b = (B(c.text ?? "", Math.max(1, f - r * 2), { fontSizePt: m, fontFamily: d.fontFamily, bold: d.bold, italic: d.italic, letterSpacingPt: d.letterSpacing }, t).length * m * (d.lineHeight ?? xe) * 25.4 / 72 + r * 2) / (c.rowSpan ?? 1);
66
+ for (let w = u; w < u + (c.rowSpan ?? 1); w++) n[w] = Math.max(n[w] ?? 0, b);
67
67
  s.set(c, d);
68
68
  }
69
69
  const i = e.headerGrid.cells.map((c) => c.map((l) => l ? { ...l, style: s.get(l) } : null));
70
70
  return { ...e.headerGrid, cells: i, rowHeightsMm: n };
71
71
  }
72
- function yr(e, t, r) {
72
+ function vr(e, t, r) {
73
73
  const n = /* @__PURE__ */ new Set(), o = e.cells.map((a, s) => {
74
74
  const i = [];
75
75
  let c = 0;
@@ -77,10 +77,10 @@ function yr(e, t, r) {
77
77
  for (; n.has(`${s}:${c}`); ) c++;
78
78
  const u = l?.colSpan ?? 1, f = l?.rowSpan ?? 1;
79
79
  let d = 0;
80
- for (let h = c; h < c + u; h++) {
81
- t.has(h) && d++;
82
- for (let m = s + 1; m < s + f; m++)
83
- n.add(`${m}:${h}`);
80
+ for (let m = c; m < c + u; m++) {
81
+ t.has(m) && d++;
82
+ for (let h = s + 1; h < s + f; h++)
83
+ n.add(`${h}:${m}`);
84
84
  }
85
85
  d && i.push(l ? { ...l, colSpan: d } : null), c += u;
86
86
  }
@@ -88,7 +88,7 @@ function yr(e, t, r) {
88
88
  });
89
89
  return { ...e, cells: o, colWidthsMm: r };
90
90
  }
91
- function br(e) {
91
+ function Mr(e) {
92
92
  if (!e.columns.some((n) => n.hidden)) return e;
93
93
  const t = /* @__PURE__ */ new Set(), r = e.columns.filter((n, o) => n.hidden ? !1 : (t.add(o), !0));
94
94
  if (!r.length) throw new Error("列表至少需要一列可见列");
@@ -96,7 +96,7 @@ function br(e) {
96
96
  ...e,
97
97
  columns: r,
98
98
  ...e.headerGrid ? {
99
- headerGrid: yr(
99
+ headerGrid: vr(
100
100
  e.headerGrid,
101
101
  t,
102
102
  r.map((n) => n.widthMm)
@@ -104,11 +104,11 @@ function br(e) {
104
104
  } : {}
105
105
  };
106
106
  }
107
- function* vr(e) {
107
+ function* Sr(e) {
108
108
  const { page: t } = e;
109
- nr(t.components, t.flow);
109
+ ar(t.components, t.flow);
110
110
  let r = 0, n = 0;
111
- for (const o of or(t.components, t.flow)) {
111
+ for (const o of sr(t.components, t.flow)) {
112
112
  e.active();
113
113
  const a = o.band, s = o.components.some((u) => u.kind === "list" && u.cardinality !== "record"), i = s ? 0 : o.components.reduce((u, f) => Math.max(u, f.topMm - a.topMm + (f.kind === "list" ? e.height(f) : f.heightMm)), a.heightMm);
114
114
  let c = Math.max(e.top(), n + a.topMm - r);
@@ -124,14 +124,14 @@ function* vr(e) {
124
124
  n = l, r = a.topMm + a.heightMm;
125
125
  }
126
126
  }
127
- function Mr(e) {
127
+ function xr(e) {
128
128
  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 || t.visual));
129
129
  }
130
- function Ce(e) {
131
- return e.pages.some((t) => t.components.some((r) => r.kind === "list" ? Mr(r) : !!r.chartBinding));
130
+ function $e(e) {
131
+ return e.pages.some((t) => t.components.some((r) => r.kind === "list" ? xr(r) : !!r.chartBinding));
132
132
  }
133
- const Sr = 512, Ke = 256 * 1024;
134
- function xr() {
133
+ const Pr = 512, We = 256 * 1024;
134
+ function kr() {
135
135
  const e = /* @__PURE__ */ new Map();
136
136
  let t = 0, r;
137
137
  return (n, o, a, s) => {
@@ -139,9 +139,9 @@ function xr() {
139
139
  const i = JSON.stringify([n, o, a.fontSizePt, a.fontFamily, a.bold, a.italic, a.letterSpacingPt]), c = e.get(i);
140
140
  if (c)
141
141
  return e.delete(i), e.set(i, c), c.lines.slice();
142
- const l = _(n, o, a, s), u = i.length + l.reduce((f, d) => f + d.length, 0);
143
- if (u <= Ke) {
144
- for (; e.size >= Sr || t + u > Ke; ) {
142
+ const l = B(n, o, a, s), u = i.length + l.reduce((f, d) => f + d.length, 0);
143
+ if (u <= We) {
144
+ for (; e.size >= Pr || t + u > We; ) {
145
145
  const f = e.keys().next().value;
146
146
  t -= e.get(f).units, e.delete(f);
147
147
  }
@@ -150,98 +150,98 @@ function xr() {
150
150
  return l;
151
151
  };
152
152
  }
153
- const Cr = 1e4, je = 25e4;
154
- function ke(e) {
153
+ const Cr = 1e4, Ve = 25e4;
154
+ function Fe(e) {
155
155
  if (e?.aborted) throw e.reason ?? new DOMException("标签生成已取消", "AbortError");
156
156
  }
157
- function et(e, t, r) {
158
- const n = typeof e.copies == "object" ? Je(t, e.copies.field, r) : e.copies ?? 1;
159
- if (typeof n != "number" || !Number.isSafeInteger(n) || n < 1 || n > 1e3) throw new $(`$.datasets.${r.dataset}[${r.rowIndex}]`, "每条记录复制数必须是 1..1000 的数值型整数", r.rowIndex, typeof e.copies == "object" ? e.copies.field : void 0);
157
+ function ot(e, t, r) {
158
+ const n = typeof e.copies == "object" ? Ye(t, e.copies.field, r) : e.copies ?? 1;
159
+ 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);
160
160
  return n;
161
161
  }
162
- function tt(e, t, r) {
162
+ function at(e, t, r) {
163
163
  if (e.rowKey === void 0) return;
164
- const n = Je(t, e.rowKey, r);
164
+ const n = Ye(t, e.rowKey, r);
165
165
  if (typeof n == "string" && n.trim() || typeof n == "number" && Number.isFinite(n)) return n;
166
- throw new $(`$.datasets.${r.dataset}[${r.rowIndex}].${e.rowKey}`, "业务主键必须是非空字符串或有限数字", r.rowIndex, e.rowKey);
166
+ throw new F(`$.datasets.${r.dataset}[${r.rowIndex}].${e.rowKey}`, "业务主键必须是非空字符串或有限数字", r.rowIndex, e.rowKey);
167
167
  }
168
- function kr(e) {
168
+ function Tr(e) {
169
169
  const t = (r) => 1 + (r.grid?.cells.reduce((n, o) => n + 1 + o.length + o.reduce((a, s) => a + (s?.children?.reduce((i, c) => i + t(c), 0) ?? 0), 0), 0) ?? 0);
170
170
  return e.pages.reduce((r, n) => r + n.components.reduce((o, a) => o + t(a), 0), 0);
171
171
  }
172
- function Tr(e, t, r) {
172
+ function Er(e, t, r) {
173
173
  const n = e.repeat, o = Object.prototype.hasOwnProperty.call(t, n.dataset) ? t[n.dataset] : void 0;
174
- if (!Array.isArray(o)) throw new $(`$.datasets.${n.dataset}`, "逐记录标签数据集缺失,应提供对象数组(允许空数组)");
175
- const a = /* @__PURE__ */ new Set(), s = r.maxPages ?? Cr, i = kr(e);
174
+ if (!Array.isArray(o)) throw new F(`$.datasets.${n.dataset}`, "逐记录标签数据集缺失,应提供对象数组(允许空数组)");
175
+ const a = /* @__PURE__ */ new Set(), s = r.maxPages ?? Cr, i = Tr(e);
176
176
  let c = 0, l = 0;
177
177
  for (const [u, f] of o.entries()) {
178
- if (ke(r.signal), !f || typeof f != "object" || Array.isArray(f)) throw new $(`$.datasets.${n.dataset}[${u}]`, "标签记录应为对象", u);
179
- const d = { rowIndex: u, dataset: n.dataset }, h = tt(n, f, d);
180
- if (h !== void 0) {
181
- const v = JSON.stringify([typeof h, h]);
182
- if (a.has(v)) throw new $(`$.datasets.${n.dataset}[${u}].${n.rowKey}`, "业务主键重复;请先确认记录来源,避免重复打印标签", u, n.rowKey);
183
- a.add(v);
178
+ if (Fe(r.signal), !f || typeof f != "object" || Array.isArray(f)) throw new F(`$.datasets.${n.dataset}[${u}]`, "标签记录应为对象", u);
179
+ const d = { rowIndex: u, dataset: n.dataset }, m = at(n, f, d);
180
+ if (m !== void 0) {
181
+ const b = JSON.stringify([typeof m, m]);
182
+ if (a.has(b)) throw new F(`$.datasets.${n.dataset}[${u}].${n.rowKey}`, "业务主键重复;请先确认记录来源,避免重复打印标签", u, n.rowKey);
183
+ a.add(b);
184
184
  }
185
- const m = et(n, f, d);
186
- if (c += m * e.pages.length, l += m * i, c > s) throw new W(s, c);
187
- if (l > je) throw new $("$.repeat", `标签组件总量(含网格行、槽位及嵌套组件)超过安全预算 ${je},请分批生成`, u);
185
+ const h = ot(n, f, d);
186
+ if (c += h * e.pages.length, l += h * i, c > s) throw new U(s, c);
187
+ if (l > Ve) throw new F("$.repeat", `标签组件总量(含网格行、槽位及嵌套组件)超过安全预算 ${Ve},请分批生成`, u);
188
188
  }
189
189
  return o;
190
190
  }
191
- function Pr(e, t, r) {
191
+ function Rr(e, t, r) {
192
192
  if (!e.binding) return e;
193
- const { binding: n, ...o } = e, a = _t(n, t.row, t);
193
+ const { binding: n, ...o } = e, a = Ut(n, t.row, t);
194
194
  if (e.kind === "image") {
195
195
  if (!a) return;
196
- if (!qt(a)) throw new $(`${r}.binding`, "图片字段只接受 PNG/JPEG base64 data URL;业务 URL 应由宿主安全加载后转换", t.rowIndex, n.field);
196
+ if (!Xt(a)) throw new F(`${r}.binding`, "图片字段只接受 PNG/JPEG base64 data URL;业务 URL 应由宿主安全加载后转换", t.rowIndex, n.field);
197
197
  return { ...o, imageData: a };
198
198
  }
199
199
  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 });
200
200
  }
201
- function Er(e, t, r) {
201
+ function Ir(e, t, r) {
202
202
  if (e.kind !== "text" || e.grid || e.richParagraphs?.length) return e;
203
- const n = e.style ?? {}, o = re(n).fontSizePt, a = e.text ?? e.lines?.join(`
203
+ const n = e.style ?? {}, o = Z(n).fontSizePt, a = e.text ?? e.lines?.join(`
204
204
  `) ?? "";
205
- if (a.length > 16384) throw new $(r, "标签文本超过 16384 字符预算,请缩小字段内容", t.rowIndex);
206
- const s = t.wrapText(a, e.widthMm, { fontSizePt: o, bold: n.bold, italic: n.italic, fontFamily: n.fontFamily, letterSpacingPt: n.letterSpacing }, t.options.measurer ?? Ve), i = s.length * o * Wt(n) * 25.4 / 72;
207
- if (i > e.heightMm + 0.05) throw new $(r, `标签文字需要约 ${i.toFixed(2)}mm 高,超出 ${e.heightMm}mm;请增大文本区域、减少内容或调整字号`, t.rowIndex, e.binding?.field);
205
+ if (a.length > 16384) throw new F(r, "标签文本超过 16384 字符预算,请缩小字段内容", t.rowIndex);
206
+ const s = t.wrapText(a, e.widthMm, { fontSizePt: o, bold: n.bold, italic: n.italic, fontFamily: n.fontFamily, letterSpacingPt: n.letterSpacing }, t.options.measurer ?? re), i = s.length * o * zt(n) * 25.4 / 72;
207
+ if (i > e.heightMm + 0.05) throw new F(r, `标签文字需要约 ${i.toFixed(2)}mm 高,超出 ${e.heightMm}mm;请增大文本区域、减少内容或调整字号`, t.rowIndex, e.binding?.field);
208
208
  return { ...e, lines: s };
209
209
  }
210
- function rt(e, t, r) {
211
- ke(t.options.signal);
212
- const n = Pr(e, t, r);
210
+ function st(e, t, r) {
211
+ Fe(t.options.signal);
212
+ const n = Rr(e, t, r);
213
213
  if (!n) return;
214
214
  let o = n.grid;
215
215
  return o && (o = { ...o, cells: o.cells.map((a, s) => a.map((i, c) => i?.children?.length ? { ...i, children: i.children.flatMap((l, u) => {
216
- const f = rt(l, t, `${r}.grid.cells.${s}.${c}.children.${u}`);
216
+ const f = st(l, t, `${r}.grid.cells.${s}.${c}.children.${u}`);
217
217
  return f ? [f] : [];
218
- }) } : i)) }), Er(o === n.grid ? n : { ...n, grid: o }, t, r);
218
+ }) } : i)) }), Ir(o === n.grid ? n : { ...n, grid: o }, t, r);
219
219
  }
220
- function Rr(e, t, r, n, o, a) {
220
+ function $r(e, t, r, n, o, a) {
221
221
  return {
222
222
  ...e,
223
223
  components: e.components.flatMap((s, i) => {
224
- const c = rt(s, r, `$.pages.${t}.components.${i}`);
224
+ const c = st(s, r, `$.pages.${t}.components.${i}`);
225
225
  return c ? [{ ...c, meta: { ...c.meta, labelSource: { pageIndex: t, componentIndex: i } } }] : [];
226
226
  }),
227
227
  meta: { ...e.meta, record: { dataset: r.dataset, rowIndex: r.rowIndex, ...a === void 0 ? {} : { rowKey: a }, copyIndex: n, copyCount: o, templatePageIndex: t } }
228
228
  };
229
229
  }
230
- function* Ir(e, t, r) {
230
+ function* Fr(e, t, r) {
231
231
  const n = [];
232
- if (ar(e, n), n.length) throw new $(n[0].path, n[0].message);
232
+ if (ir(e, n), n.length) throw new F(n[0].path, n[0].message);
233
233
  if (!e.repeat) {
234
234
  for (const [i, c] of e.pages.entries()) yield { page: c, pageIndex: i };
235
235
  return;
236
236
  }
237
- const o = e.repeat, a = Tr(e, t, r), s = xr();
237
+ const o = e.repeat, a = Er(e, t, r), s = kr();
238
238
  for (const [i, c] of a.entries()) {
239
- const l = { row: c, rowIndex: i, dataset: o.dataset, options: r, wrapText: s }, u = et(o, c, l), f = tt(o, c, l);
240
- for (let d = 0; d < u; d++) for (const [h, m] of e.pages.entries())
241
- ke(r.signal), yield { page: Rr(m, h, l, d, u, f), pageIndex: h };
239
+ const l = { row: c, rowIndex: i, dataset: o.dataset, options: r, wrapText: s }, u = ot(o, c, l), f = at(o, c, l);
240
+ for (let d = 0; d < u; d++) for (const [m, h] of e.pages.entries())
241
+ Fe(r.signal), yield { page: $r(h, m, l, d, u, f), pageIndex: m };
242
242
  }
243
243
  }
244
- function $r(e) {
244
+ function Or(e) {
245
245
  return {
246
246
  widthMm: e.widthMm,
247
247
  heightMm: e.heightMm,
@@ -252,119 +252,119 @@ function $r(e) {
252
252
  components: []
253
253
  };
254
254
  }
255
- function Q(e, t) {
255
+ function oe(e, t) {
256
256
  const r = t.heightMm - (e.layout === "wide" ? t.marginBottomMm : e.marginBottomMm ?? t.marginBottomMm);
257
257
  return e.components.reduce((n, o) => o.kind !== "list" && o.pageAnchor === "footer" ? Math.min(n, o.topMm) : n, r);
258
258
  }
259
- function V(e) {
259
+ function X(e) {
260
260
  return e.components.reduce((t, r) => r.kind !== "list" && r.pageAnchor === "header" ? Math.max(t, r.topMm + r.heightMm) : t, 0);
261
261
  }
262
- function nt(e, t) {
262
+ function it(e, t) {
263
263
  let r = e.textMetrics.get(t);
264
264
  if (!r) {
265
- const n = re(t).fontSizePt;
265
+ const n = Z(t).fontSizePt;
266
266
  r = {
267
267
  measureOptions: {
268
268
  fontSizePt: n,
269
- fontFamily: t.fontFamily ?? We,
269
+ fontFamily: t.fontFamily ?? ke,
270
270
  italic: t.italic,
271
271
  bold: t.bold,
272
272
  letterSpacingPt: t.letterSpacing
273
273
  },
274
- lineMm: n * (t.lineHeight ?? ye) * 25.4 / 72
274
+ lineMm: n * (t.lineHeight ?? xe) * 25.4 / 72
275
275
  }, e.textMetrics.set(t, r);
276
276
  }
277
277
  return r;
278
278
  }
279
- function Fr(e) {
279
+ function Ar(e) {
280
280
  if (e === null || typeof e == "string" || typeof e == "boolean" || typeof e == "number" && Number.isFinite(e)) return e;
281
281
  }
282
- function Te(e, t, r = [], n) {
283
- const o = e.fontSizePt ?? Vt, a = e.paddingMm ?? 1, s = e.columns.map((w) => w.align ?? w.style?.align ?? e.align ?? "left"), i = e.columns.map((w, y) => ({
284
- ...j({
282
+ function Oe(e, t, r = [], n) {
283
+ const o = e.fontSizePt ?? Jt, a = e.paddingMm ?? 1, s = e.columns.map((y) => y.align ?? y.style?.align ?? e.align ?? "left"), i = e.columns.map((y, g) => ({
284
+ ...H({
285
285
  fontSize: o,
286
286
  verticalAlign: "middle"
287
- }, w.style),
288
- align: s[y] === "auto" ? "left" : s[y]
289
- })), c = i.map((w, y) => s[y] === "auto" ? { left: w, center: { ...w, align: "center" }, right: { ...w, align: "right" } } : void 0), l = e.columns.map((w, y) => w.rules?.map((x) => {
290
- const k = c[y];
291
- if (k) return {
292
- left: j(k.left, x.style),
293
- center: j(k.center, x.style),
294
- right: j(k.right, x.style)
287
+ }, y.style),
288
+ align: s[g] === "auto" ? "left" : s[g]
289
+ })), c = i.map((y, g) => s[g] === "auto" ? { left: y, center: { ...y, align: "center" }, right: { ...y, align: "right" } } : void 0), l = e.columns.map((y, g) => y.rules?.map((S) => {
290
+ const C = c[g];
291
+ if (C) return {
292
+ left: H(C.left, S.style),
293
+ center: H(C.center, S.style),
294
+ right: H(C.right, S.style)
295
295
  };
296
- const T = j(i[y], x.style);
296
+ const T = H(i[g], S.style);
297
297
  return { left: T, center: T, right: T };
298
- })), u = e.columns.map((w) => ze(e, w)), f = e.columns.map((w) => w.header);
298
+ })), u = e.columns.map((y) => Xe(e, y)), f = e.columns.map((y) => y.header);
299
299
  let d = e.rowHeightMm ?? 0;
300
- for (let w = 0; w < f.length; w++) {
301
- const y = u[w], x = re(y).fontSizePt, k = _(
302
- f[w],
303
- e.columns[w].widthMm - a * 2,
304
- { fontSizePt: x, fontFamily: y.fontFamily ?? We, italic: y.italic, bold: y.bold, letterSpacingPt: y.letterSpacing },
300
+ for (let y = 0; y < f.length; y++) {
301
+ const g = u[y], S = Z(g).fontSizePt, C = B(
302
+ f[y],
303
+ e.columns[y].widthMm - a * 2,
304
+ { fontSizePt: S, fontFamily: g.fontFamily ?? ke, italic: g.italic, bold: g.bold, letterSpacingPt: g.letterSpacing },
305
305
  t
306
- ), T = x * (y.lineHeight ?? ye) * 25.4 / 72;
307
- d = Math.max(d, Math.max(k.length, 1) * T + a * 2);
308
- }
309
- const h = f.map((w, y) => ({
310
- text: w,
311
- style: u[y]
312
- })), m = e.border === !1 ? { borderTop: !1, borderRight: !1, borderBottom: !1, borderLeft: !1 } : { borderBottom: !0, borderLeft: !0, borderRight: !0, borderTop: !0 }, v = e.columns.map((w) => w.widthMm), p = Or(wr(e, t), v, {
313
- cells: [h],
314
- colWidthsMm: v,
306
+ ), T = S * (g.lineHeight ?? xe) * 25.4 / 72;
307
+ d = Math.max(d, Math.max(C.length, 1) * T + a * 2);
308
+ }
309
+ const m = f.map((y, g) => ({
310
+ text: y,
311
+ style: u[g]
312
+ })), h = e.border === !1 ? { borderTop: !1, borderRight: !1, borderBottom: !1, borderLeft: !1 } : { borderBottom: !0, borderLeft: !0, borderRight: !0, borderTop: !0 }, b = e.columns.map((y) => y.widthMm), w = Kr(br(e, t), b, {
313
+ cells: [m],
314
+ colWidthsMm: b,
315
315
  rowHeightsMm: [d],
316
316
  paddingMm: a
317
317
  });
318
318
  return {
319
319
  fontSizePt: o,
320
320
  paddingMm: a,
321
- visuals: rr(e.columns, r, n),
322
- visibility: e.columns.map((w) => w.visibleWhen ? H(w.visibleWhen) : void 0),
323
- ruleReaders: e.columns.map((w) => w.rules?.map((y) => H(y.when))),
321
+ visuals: or(e.columns, r, n),
322
+ visibility: e.columns.map((y) => y.visibleWhen ? G(y.visibleWhen) : void 0),
323
+ ruleReaders: e.columns.map((y) => y.rules?.map((g) => G(g.when))),
324
324
  cellStyles: i,
325
325
  autoStyles: c,
326
326
  ruleStyles: l,
327
327
  textMetrics: /* @__PURE__ */ new WeakMap(),
328
- numberFormats: e.columns.map((w) => _e(w.format)),
329
- derivedFields: new Set(e.computed?.map((w) => w.field)),
330
- borderStyle: m,
331
- headerHeightMm: p.rowHeightsMm.reduce((w, y) => w + y, 0),
332
- headerGrid: p,
333
- colWidthsMm: v,
328
+ numberFormats: e.columns.map((y) => Qe(y.format)),
329
+ derivedFields: new Set(e.computed?.map((y) => y.field)),
330
+ borderStyle: h,
331
+ headerHeightMm: w.rowHeightsMm.reduce((y, g) => y + g, 0),
332
+ headerGrid: w,
333
+ colWidthsMm: b,
334
334
  columns: e.columns
335
335
  };
336
336
  }
337
- function Or(e, t, r) {
337
+ function Kr(e, t, r) {
338
338
  if (!e) return r;
339
339
  if (!e.cells.length) throw new Error("自定义列表表头至少需要一行");
340
340
  const n = e.rowHeightsMm ?? e.cells.map(() => r.rowHeightsMm[0]);
341
341
  if (n.length !== e.cells.length || n.some((o) => !Number.isFinite(o) || o <= 0)) throw new Error("自定义列表表头行高无效");
342
342
  return { ...e, colWidthsMm: t, rowHeightsMm: n };
343
343
  }
344
- function Ar(e, t, r) {
344
+ function Nr(e, t, r) {
345
345
  const n = t.format?.kind === "number" || t.format?.kind === "percent";
346
346
  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);
347
347
  }
348
- function z(e, t, r) {
348
+ function Y(e, t, r) {
349
349
  const n = e.columns, o = e.tree?.rows.get(t);
350
350
  let a = e.rowHeightFloorMm;
351
351
  const s = new Array(n.length);
352
352
  for (let i = 0; i < n.length; i++) {
353
- const c = n[i], l = e.visibility[i]?.(t) !== !1, u = l ? t[c.field] : null, f = e.autoStyles[i] ? qe(u, c.format, c.semanticRole) : "left";
353
+ const c = n[i], l = e.visibility[i]?.(t) !== !1, u = l ? t[c.field] : null, f = e.autoStyles[i] ? Ze(u, c.format, c.semanticRole) : "left";
354
354
  let d = e.autoStyles[i]?.[f] ?? e.cellStyles[i];
355
355
  if (c.rules) {
356
- for (let x = 0; x < c.rules.length; x++)
357
- if (e.ruleReaders[i][x](t)) {
358
- d = e.ruleStyles[i][x][f];
356
+ for (let S = 0; S < c.rules.length; S++)
357
+ if (e.ruleReaders[i][S](t)) {
358
+ d = e.ruleStyles[i][S][f];
359
359
  break;
360
360
  }
361
361
  }
362
- const h = c.format ? Ue(u, c.format) : xe(u), m = Kr(e, c, o);
363
- d = jr(e, c, d, o);
364
- const v = nt(e, d), p = _(h, Math.max(1, c.widthMm - e.paddingMm * 2 - m), v.measureOptions, r);
365
- a = Math.max(a, p.length * v.lineMm + e.paddingMm * 2);
366
- const w = Fr(u), y = { text: h, style: d };
367
- u != null && e.visuals[i]?.apply(y, t), w !== void 0 && (y.value = w), Ar(y, c, e.numberFormats[i]), Nr(y, c, e, o, m), e.derivedFields.has(c.field) && (y.derived = !0, y.editable = !1), l || (y.editable = !1), s[i] = y;
362
+ const m = c.format ? et(u, c.format) : Re(u), h = jr(e, c, o);
363
+ d = Lr(e, c, d, o);
364
+ const b = it(e, d), w = B(m, Math.max(1, c.widthMm - e.paddingMm * 2 - h), b.measureOptions, r);
365
+ a = Math.max(a, w.length * b.lineMm + e.paddingMm * 2);
366
+ const y = Ar(u), g = { text: m, style: d };
367
+ u != null && e.visuals[i]?.apply(g, t), y !== void 0 && (g.value = y), Nr(g, c, e.numberFormats[i]), Hr(g, c, e, o, h), e.derivedFields.has(c.field) && (g.derived = !0, g.editable = !1), l || (g.editable = !1), s[i] = g;
368
368
  }
369
369
  return {
370
370
  grid: { cells: [s], colWidthsMm: e.colWidthsMm, rowHeightsMm: [a], paddingMm: e.paddingMm },
@@ -372,20 +372,20 @@ function z(e, t, r) {
372
372
  ...e.matrix ? { meta: { matrix: { row: e.matrix.rows.get(t) } } } : {}
373
373
  };
374
374
  }
375
- function Kr(e, t, r) {
376
- return !r || t.field !== e.tree.list.tree.labelField ? 0 : Xt(e.tree.list, t, r, e.paddingMm);
375
+ function jr(e, t, r) {
376
+ return !r || t.field !== e.tree.list.tree.labelField ? 0 : Qt(e.tree.list, t, r, e.paddingMm);
377
377
  }
378
- function jr(e, t, r, n) {
378
+ function Lr(e, t, r, n) {
379
379
  return !n || t.field !== e.tree.list.tree.labelField || r.align === "left" ? r : { ...r, align: "left" };
380
380
  }
381
- function Nr(e, t, r, n, o = 0) {
382
- n && (o && (e.indentMm = o), Yt(e, t, n, r.tree.list));
381
+ function Hr(e, t, r, n, o = 0) {
382
+ n && (o && (e.indentMm = o), Zt(e, t, n, r.tree.list));
383
383
  }
384
- function ot(e) {
384
+ function ct(e) {
385
385
  if (e != null && typeof e != "string" && typeof e != "boolean" && !(typeof e == "number" && Number.isFinite(e))) throw new Error("分组字段应为有限 JSON 标量");
386
386
  return JSON.stringify([typeof e, e ?? null]);
387
387
  }
388
- function* at(e, t, r = 0) {
388
+ function* lt(e, t, r = 0) {
389
389
  const n = t[r];
390
390
  if (!n) {
391
391
  for (const a of e) yield { kind: "row", row: a };
@@ -393,54 +393,54 @@ function* at(e, t, r = 0) {
393
393
  }
394
394
  const o = /* @__PURE__ */ new Map();
395
395
  for (const a of e) {
396
- const s = ot(a[n.field]), i = o.get(s);
396
+ const s = ct(a[n.field]), i = o.get(s);
397
397
  i ? i.push(a) : o.set(s, [a]);
398
398
  }
399
399
  for (const a of o.values())
400
- yield { kind: "groupHeader", label: (n.headerTemplate ?? "{value}").replace(/\{value\}/g, xe(a[0][n.field])), firstRow: a[0], group: n, depth: r, rows: a }, yield* at(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 };
400
+ yield { kind: "groupHeader", label: (n.headerTemplate ?? "{value}").replace(/\{value\}/g, Re(a[0][n.field])), firstRow: a[0], group: n, depth: r, rows: a }, yield* lt(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 };
401
401
  }
402
- function st(e, t, r, n = []) {
402
+ function dt(e, t, r, n = []) {
403
403
  const o = [...r.filter((a) => !n.some((s) => s.field === a)).map((a) => ({ field: a, op: "sum" })), ...n];
404
404
  return new Map(o.map((a) => {
405
- const s = e.find((c) => c.field === a.field)?.format ?? { kind: "number", thousands: !0 }, i = Me(t, { ...a, field: a.valueField ?? a.field });
406
- return [a.field, { text: Ue(i, s), ...i === null ? {} : { value: i }, ...typeof i == "number" ? { numberFormat: _e(s) } : {} }];
405
+ const s = e.find((c) => c.field === a.field)?.format ?? { kind: "number", thousands: !0 }, i = Te(t, { ...a, field: a.valueField ?? a.field });
406
+ return [a.field, { text: et(i, s), ...i === null ? {} : { value: i }, ...typeof i == "number" ? { numberFormat: Qe(s) } : {} }];
407
407
  }));
408
408
  }
409
- function it(e, t) {
409
+ function ut(e, t) {
410
410
  const r = e.findIndex((n) => t.includes(n.field));
411
411
  return r < 0 ? 1 : r;
412
412
  }
413
- function G(e, t, r, n, o, a) {
414
- const s = [], i = Math.max(0, Math.min(a, e.columns.length)), c = j({ fontSize: e.fontSizePt }, o);
413
+ function _(e, t, r, n, o, a) {
414
+ const s = [], i = Math.max(0, Math.min(a, e.columns.length)), c = H({ fontSize: e.fontSizePt }, o);
415
415
  i && s.push({ text: r, colSpan: i, style: { bold: !0, ...c } });
416
416
  for (let d = i; d < e.columns.length; d++) {
417
- const h = e.columns[d], m = n.get(h.field), v = e.autoStyles[d]?.[qe(m?.value, h.format)] ?? e.cellStyles[d];
418
- s.push({ ...m, text: m?.text ?? "", style: j(v, o) });
417
+ const m = e.columns[d], h = n.get(m.field), b = e.autoStyles[d]?.[Ze(h?.value, m.format)] ?? e.cellStyles[d];
418
+ s.push({ ...h, text: h?.text ?? "", style: H(b, o) });
419
419
  }
420
- const l = { text: r, colSpan: e.columns.length, style: { bold: !0, ...c } }, u = i ? [s] : [[l], s], f = u.map((d) => Lr(e, d, t));
420
+ const l = { text: r, colSpan: e.columns.length, style: { bold: !0, ...c } }, u = i ? [s] : [[l], s], f = u.map((d) => Dr(e, d, t));
421
421
  return {
422
422
  grid: { cells: u, colWidthsMm: e.colWidthsMm, rowHeightsMm: f, paddingMm: e.paddingMm },
423
- heightMm: f.reduce((d, h) => d + h, 0)
423
+ heightMm: f.reduce((d, m) => d + m, 0)
424
424
  };
425
425
  }
426
- function Lr(e, t, r) {
426
+ function Dr(e, t, r) {
427
427
  let n = e.rowHeightFloorMm, o = 0;
428
428
  for (const a of t) {
429
429
  let s = 0;
430
430
  const i = o + (a.colSpan ?? 1);
431
431
  for (; o < i; o++) s += e.colWidthsMm[o] ?? 0;
432
- const c = nt(e, a.style), l = _(a.text ?? "", s - e.paddingMm * 2, c.measureOptions, r);
432
+ const c = it(e, a.style), l = B(a.text ?? "", s - e.paddingMm * 2, c.measureOptions, r);
433
433
  n = Math.max(n, l.length * c.lineMm + e.paddingMm * 2);
434
434
  }
435
435
  return n;
436
436
  }
437
- function Hr(e, t, r) {
438
- const { templatePage: n, current: o, warnings: a, nextId: s, pushCurrent: i } = r, c = () => Q(n, o), l = Math.max(o.marginTopMm, V(n)), u = n.layout === "wide" ? V(n) : l, f = {
437
+ function Br(e, t, r) {
438
+ const { templatePage: n, current: o, warnings: a, nextId: s, pushCurrent: i } = r, c = () => oe(n, o), l = Math.max(o.marginTopMm, X(n)), u = n.layout === "wide" ? X(n) : l, f = {
439
439
  id: r.tableId,
440
- columnKeys: e.columns.map((g) => g.field),
440
+ columnKeys: e.columns.map((p) => p.field),
441
441
  ...e.layout === void 0 ? {} : { layout: e.layout },
442
442
  ...e.title === void 0 ? {} : { title: e.title }
443
- }, d = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map(), m = {
443
+ }, d = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), h = {
444
444
  kind: "rect",
445
445
  leftMm: e.leftMm,
446
446
  topMm: 0,
@@ -451,53 +451,53 @@ function Hr(e, t, r) {
451
451
  table: { ...f, role: "header", rowIndex: -1 },
452
452
  style: t.borderStyle,
453
453
  ...e.meta || t.matrix ? { meta: { ...e.meta, ...t.matrix ? { matrix: t.matrix.header } : {} } } : {}
454
- }, v = (g) => o.components.push({ ...m, topMm: g });
454
+ }, b = (p) => o.components.push({ ...h, topMm: p });
455
455
  if (r.flow && e.header !== !1 && t.headerHeightMm > c() - l + 1e-3) throw new Error(`流式列表 ${e.id ?? e.dataset} 的表头高度超出单页可用范围`);
456
- let p = Math.max(r.startTop ?? e.topMm, l);
457
- e.header !== !1 && (v(p), p += t.headerHeightMm + r.mmPerRow);
458
- function w() {
459
- const g = Math.max(r.flow || n.layout === "wide" ? 0 : e.topMm, u);
460
- return (e.header !== !1 && e.headerEveryPage !== !1 ? g + t.headerHeightMm : u) + [...h.values()].reduce((S, E) => S + E.heightMm, 0);
461
- }
456
+ let w = Math.max(r.startTop ?? e.topMm, l);
457
+ e.header !== !1 && (b(w), w += t.headerHeightMm + r.mmPerRow);
462
458
  function y() {
463
- const g = n.layout === "wide" ? 0 : o.marginBottomMm;
464
- return Math.min(n.heightMm - g, Q(n, o)) - w();
459
+ const p = Math.max(r.flow || n.layout === "wide" ? 0 : e.topMm, u);
460
+ return (e.header !== !1 && e.headerEveryPage !== !1 ? p + t.headerHeightMm : u) + [...m.values()].reduce((x, R) => x + R.heightMm, 0);
461
+ }
462
+ function g() {
463
+ const p = n.layout === "wide" ? 0 : o.marginBottomMm;
464
+ return Math.min(n.heightMm - p, oe(n, o)) - y();
465
465
  }
466
- function x(g) {
467
- if (p + g <= c()) return;
466
+ function S(p) {
467
+ if (w + p <= c()) return;
468
468
  i(), o.components = [], o.heightMm = n.heightMm, n.layout === "wide" && (o.marginTopMm = 0, o.marginBottomMm = 0);
469
- const b = Math.max(r.flow || n.layout === "wide" ? 0 : e.topMm, u);
470
- e.header !== !1 && e.headerEveryPage !== !1 ? (v(b), p = b + t.headerHeightMm) : p = u;
471
- for (const S of h.values()) T(S, "listgr", "group-header");
472
- }
473
- function k(g, b, S, E) {
474
- const P = y();
475
- if (r.flow && g.heightMm > P + 1e-3) throw new Error(`流式列表 ${e.id ?? e.dataset} 的单行高度超出单页可用范围`);
476
- g.heightMm > P && a.push(`列表 ${e.id ?? e.dataset} 行高 ${g.heightMm.toFixed(2)}mm 超出单页可用高度 ${P.toFixed(2)}mm,预览与打印可能截断内容`), x(g.heightMm), T(g, b, S, E);
477
- }
478
- function T(g, b, S, E) {
479
- const P = g.table?.id ?? f.id, R = S === "header" ? -1 : d.get(P) ?? 0;
480
- S !== "header" && d.set(P, R + g.grid.cells.length), o.components.push({
469
+ const P = Math.max(r.flow || n.layout === "wide" ? 0 : e.topMm, u);
470
+ e.header !== !1 && e.headerEveryPage !== !1 ? (b(P), w = P + t.headerHeightMm) : w = u;
471
+ for (const x of m.values()) T(x, "listgr", "group-header");
472
+ }
473
+ function C(p, P, x, R) {
474
+ const v = g();
475
+ if (r.flow && p.heightMm > v + 1e-3) throw new Error(`流式列表 ${e.id ?? e.dataset} 的单行高度超出单页可用范围`);
476
+ p.heightMm > v && a.push(`列表 ${e.id ?? e.dataset} 行高 ${p.heightMm.toFixed(2)}mm 超出单页可用高度 ${v.toFixed(2)}mm,预览与打印可能截断内容`), S(p.heightMm), T(p, P, x, R);
477
+ }
478
+ function T(p, P, x, R) {
479
+ const v = p.table?.id ?? f.id, E = x === "header" ? -1 : d.get(v) ?? 0;
480
+ x !== "header" && d.set(v, E + p.grid.cells.length), o.components.push({
481
481
  kind: "rect",
482
482
  leftMm: e.leftMm,
483
- topMm: p,
483
+ topMm: w,
484
484
  widthMm: e.widthMm,
485
- heightMm: g.heightMm,
486
- grid: g.grid,
487
- nid: s(b),
488
- table: { ...f, ...g.table, role: S, rowIndex: R, ...E ? { source: E } : {} },
485
+ heightMm: p.heightMm,
486
+ grid: p.grid,
487
+ nid: s(P),
488
+ table: { ...f, ...p.table, role: x, rowIndex: E, ...R ? { source: R } : {} },
489
489
  style: t.borderStyle,
490
- ...e.meta || g.meta ? { meta: { ...e.meta, ...g.meta } } : {}
491
- }), p += g.heightMm;
490
+ ...e.meta || p.meta ? { meta: { ...e.meta, ...p.meta } } : {}
491
+ }), w += p.heightMm;
492
492
  }
493
- function O(g) {
494
- g <= y() && x(g);
493
+ function $(p) {
494
+ p <= g() && S(p);
495
495
  }
496
- return { keepTogether: O, placeGridRow: k, setGroupHeader: (g, b) => {
497
- b ? h.set(g, b) : h.delete(g);
498
- }, bottom: () => p };
496
+ return { keepTogether: $, placeGridRow: C, setGroupHeader: (p, P) => {
497
+ P ? m.set(p, P) : m.delete(p);
498
+ }, bottom: () => w };
499
499
  }
500
- function Dr(e, t) {
500
+ function Gr(e, t) {
501
501
  if (!e.rowKey) return;
502
502
  const r = t[e.rowKey];
503
503
  if ((typeof r != "string" || !r.trim()) && !(typeof r == "number" && Number.isFinite(r)))
@@ -507,56 +507,56 @@ function Dr(e, t) {
507
507
  if (o !== void 0 && typeof o != "string") throw new Error("来源令牌应为字符串");
508
508
  return { datasetId: e.dataset, rowKey: r, ...n === void 0 ? {} : { revision: n }, ...o === void 0 ? {} : { sourceToken: o } };
509
509
  }
510
- function ne(e, t) {
510
+ function ce(e, t) {
511
511
  const r = /* @__PURE__ */ new Map();
512
512
  if (!e.rowKey) return r;
513
513
  const n = /* @__PURE__ */ new Set();
514
514
  for (const o of t) {
515
- const a = Dr(e, o), s = JSON.stringify(a.rowKey);
515
+ const a = Gr(e, o), s = JSON.stringify(a.rowKey);
516
516
  if (n.has(s)) throw new Error(`数据集 ${e.dataset} 的业务主键重复:${String(a.rowKey)}`);
517
517
  n.add(s), r.set(o, a);
518
518
  }
519
519
  return r;
520
520
  }
521
- function Br(e, t, r, n, o) {
521
+ function Wr(e, t, r, n, o) {
522
522
  if (!e.grandTotal) return;
523
- const a = typeof e.grandTotal == "object" ? e.grandTotal : void 0, s = oe(e)[0], i = a?.fields ?? s?.subtotal ?? [], c = a?.aggregates ?? s?.aggregates ?? [];
523
+ const a = typeof e.grandTotal == "object" ? e.grandTotal : void 0, s = le(e)[0], i = a?.fields ?? s?.subtotal ?? [], c = a?.aggregates ?? s?.aggregates ?? [];
524
524
  if (i.length === 0 && c.length === 0) {
525
525
  n.warnings.push(`列表 ${e.id ?? ""} 配置了 grandTotal 但未提供合计字段(groupBy.subtotal 或 grandTotal.fields)`);
526
526
  return;
527
527
  }
528
- const l = G(r, n.measurer, a?.label ?? "合计", st(e.columns, t, i, c), a?.style ?? {}, it(e.columns, [...i, ...c.map((u) => u.field)]));
528
+ const l = _(r, n.measurer, a?.label ?? "合计", dt(e.columns, t, i, c), a?.style ?? {}, ut(e.columns, [...i, ...c.map((u) => u.field)]));
529
529
  o.placeGridRow(l, "listgt", "grand-total");
530
530
  }
531
- function K(e) {
531
+ function j(e) {
532
532
  if (e?.aborted) {
533
533
  const t = new Error("报表排版已取消");
534
534
  throw t.name = "AbortError", t;
535
535
  }
536
536
  }
537
- function oe(e) {
537
+ function le(e) {
538
538
  const t = e.groups ?? (e.groupBy ? [e.groupBy] : []);
539
539
  if (t.length > 16) throw new Error("列表最多支持 16 级分组");
540
540
  return t;
541
541
  }
542
- function Pe(e) {
543
- const t = br(e), r = t.columns.reduce((o, a) => o + a.widthMm, 0), n = r > t.widthMm ? t.widthMm / r : 1;
542
+ function Ae(e) {
543
+ const t = Mr(e), r = t.columns.reduce((o, a) => o + a.widthMm, 0), n = r > t.widthMm ? t.widthMm / r : 1;
544
544
  return n === 1 ? t : { ...t, columns: t.columns.map((o) => ({ ...o, widthMm: o.widthMm * n })) };
545
545
  }
546
- function Gr(e, t, r) {
546
+ function Vr(e, t, r) {
547
547
  const n = e.detail;
548
548
  if (!n) return;
549
549
  const o = /* @__PURE__ */ new Set();
550
550
  for (const l of t) {
551
- const u = me(l[n.parentKey]);
551
+ const u = we(l[n.parentKey]);
552
552
  if (o.has(u)) throw new Error("主从明细的主表关联键重复");
553
553
  o.add(u);
554
554
  }
555
555
  const a = r.datasets[n.dataset] ?? [], s = /* @__PURE__ */ new Map(), i = [];
556
556
  for (const l of a) {
557
557
  const u = l[n.foreignKey];
558
- if (!ct(u) && n.unmatched === "ignore") continue;
559
- const f = me(u);
558
+ if (!ft(u) && n.unmatched === "ignore") continue;
559
+ const f = we(u);
560
560
  if (!o.has(f)) {
561
561
  if (n.unmatched !== "ignore") throw new Error(`明细数据集 ${n.dataset} 存在未关联的业务键`);
562
562
  continue;
@@ -564,111 +564,111 @@ function Gr(e, t, r) {
564
564
  const d = s.get(f);
565
565
  d ? d.push(l) : s.set(f, [l]), i.push(l);
566
566
  }
567
- const c = Pe({ ...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 });
568
- return { list: c, inter: { ...Te(c, r.measurer, i, r.signal), rowHeightFloorMm: c.rowHeightMm ?? 0 }, rows: s, sources: ne(c, i) };
567
+ const c = Ae({ ...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 });
568
+ return { list: c, inter: { ...Oe(c, r.measurer, i, r.signal), rowHeightFloorMm: c.rowHeightMm ?? 0 }, rows: s, sources: ce(c, i) };
569
569
  }
570
- function ct(e) {
570
+ function ft(e) {
571
571
  return typeof e == "string" && !!e.trim() || typeof e == "number" && Number.isFinite(e);
572
572
  }
573
- function me(e) {
574
- if (!ct(e)) throw new Error("主从关联键必须是非空字符串或有限数字");
575
- return ot(e);
573
+ function we(e) {
574
+ if (!ft(e)) throw new Error("主从关联键必须是非空字符串或有限数字");
575
+ return ct(e);
576
576
  }
577
- function* Wr(e, t, r, n, o) {
577
+ function* zr(e, t, r, n, o) {
578
578
  if (!r) return;
579
- const a = r.rows.get(me(t[e.detail.parentKey])) ?? [];
579
+ const a = r.rows.get(we(t[e.detail.parentKey])) ?? [];
580
580
  if (!a.length) return;
581
581
  const s = { id: `${n.tableId}:detail`, columnKeys: r.list.columns.map((i) => i.field), title: e.detail.label };
582
- 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();
582
+ e.detail.label && o.placeGridRow({ ..._(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();
583
583
  for (const i of a)
584
- K(n.signal), o.placeGridRow({ ...z(r.inter, i, n.measurer), table: s }, "listdr", "body", r.sources.get(i)), yield* n.takePages();
584
+ j(n.signal), o.placeGridRow({ ...Y(r.inter, i, n.measurer), table: s }, "listdr", "body", r.sources.get(i)), yield* n.takePages();
585
585
  }
586
- function lt(e) {
586
+ function mt(e) {
587
587
  if (e.matrix || e.detail || e.groups?.length || e.groupBy || e.rowVisibleWhen) throw new Error("树形布局不能同时配置普通分组、矩阵、主从或行可见条件");
588
588
  if (e.rowKey && e.rowKey !== e.tree.idField) throw new Error("树形布局的 rowKey 应与 idField 一致");
589
589
  if (!e.columns.some((t) => t.field === e.tree.labelField && !t.hidden)) throw new Error("树形布局需要可见的标签列");
590
- tr(e.tree, e.computed);
590
+ nr(e.tree, e.computed);
591
591
  }
592
- function Vr(e, t, r) {
593
- lt(e);
594
- const n = Ye(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((c) => c.original)), s = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new WeakMap();
592
+ function Jr(e, t, r) {
593
+ mt(e);
594
+ const n = rt(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 = ce(o, n.entries.map((c) => c.original)), s = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new WeakMap();
595
595
  for (const c of n.entries)
596
596
  s.set(c.row, a.get(c.original)), i.set(c.row, c);
597
597
  return { list: o, rows: n.rows, sources: s, treeRows: i, totalRows: n.leaves };
598
598
  }
599
- function zr(e, t) {
599
+ function _r(e, t) {
600
600
  if (e.cardinality === "record") {
601
601
  if (t.length > 1) throw new Error(`单记录区域 ${e.id ?? e.dataset} 仅允许 0 或 1 行数据`);
602
602
  if (e.tree || e.matrix || e.detail || e.groups?.length || e.groupBy || e.grandTotal || e.rowVisibleWhen) throw new Error("单记录区域不能配置树、矩阵、主从、分组、总计或行过滤");
603
603
  if (!t.length) return { list: { ...e, columns: e.columns.map((r) => ({ ...r, editable: !1 })) }, rows: [{}], sources: /* @__PURE__ */ new Map() };
604
604
  }
605
605
  }
606
- function dt(e, t, r) {
606
+ function ht(e, t, r) {
607
607
  const n = r.prepared.get(e);
608
608
  if (n) return n;
609
- const o = zr(e, t);
609
+ const o = _r(e, t);
610
610
  if (o)
611
611
  return r.prepared.set(e, o), o;
612
612
  if (e.tree) {
613
- const c = Vr(e, t, r);
613
+ const c = Jr(e, t, r);
614
614
  return r.prepared.set(e, c), c;
615
615
  }
616
- let a = e.computed?.length ? ve(t, { fields: e.computed, signal: r.signal, formula: r.formula }).rows : t;
616
+ let a = e.computed?.length ? Ce(t, { fields: e.computed, signal: r.signal, formula: r.formula }).rows : t;
617
617
  const s = a === t ? void 0 : new Map(a.map((c, l) => [c, t[l]]));
618
- e.rowVisibleWhen && (a = a.filter(H(e.rowVisibleWhen)));
619
- const i = pr(e, a);
618
+ e.rowVisibleWhen && (a = a.filter(G(e.rowVisibleWhen)));
619
+ const i = yr(e, a);
620
620
  if (!e.matrix) {
621
- const c = ne(e, s ? a.map((l) => s.get(l)) : a);
621
+ const c = ce(e, s ? a.map((l) => s.get(l)) : a);
622
622
  i.sources = s ? new Map(a.map((l) => [l, c.get(s.get(l))])) : c;
623
623
  }
624
624
  return r.prepared.set(e, i), i;
625
625
  }
626
- function Jr(e, t, r, n) {
626
+ function qr(e, t, r, n) {
627
627
  if (!n.flow) return;
628
- const { current: o, templatePage: a } = n, s = Math.max(o.marginTopMm, V(a)), i = Math.max(n.startTop ?? e.topMm, s), c = (e.header === !1 ? 0 : t.headerHeightMm) + (r[0] ? z(t, r[0], n.measurer).heightMm : 0);
629
- i + c <= Q(a, o) + 1e-3 || i <= 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, V(a)));
628
+ const { current: o, templatePage: a } = n, s = Math.max(o.marginTopMm, X(a)), i = Math.max(n.startTop ?? e.topMm, s), c = (e.header === !1 ? 0 : t.headerHeightMm) + (r[0] ? Y(t, r[0], n.measurer).heightMm : 0);
629
+ i + c <= oe(a, o) + 1e-3 || i <= 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, X(a)));
630
630
  }
631
- function* _r(e, t, r) {
632
- const n = dt(e, t, r), o = n.rows;
631
+ function* Ur(e, t, r) {
632
+ const n = ht(e, t, r), o = n.rows;
633
633
  e = n.list, e.layout === "wide" && (r.current.widthMm = Math.max(r.current.widthMm, e.leftMm + e.widthMm + r.current.marginRightMm));
634
- const a = n.sources ?? ne(e, o), s = Pe(e), i = oe(s), c = { ...Te(s, r.measurer, o, r.signal), rowHeightFloorMm: s.rowHeightMm ?? 0, matrix: n.matrix, ...n.treeRows ? { tree: { list: s, rows: n.treeRows } } : {} };
635
- Jr(s, c, o, r);
636
- const l = Hr(s, c, r), u = Gr(s, o, r);
634
+ const a = n.sources ?? ce(e, o), s = Ae(e), i = le(s), c = { ...Oe(s, r.measurer, o, r.signal), rowHeightFloorMm: s.rowHeightMm ?? 0, matrix: n.matrix, ...n.treeRows ? { tree: { list: s, rows: n.treeRows } } : {} };
635
+ qr(s, c, o, r);
636
+ const l = Br(s, c, r), u = Vr(s, o, r);
637
637
  let f;
638
- for (const d of at(o, i)) {
639
- if (K(r.signal), d.kind === "row")
640
- l.placeGridRow(f ?? z(c, d.row, r.measurer), "listr", hr(n.matrix, d.row), a.get(d.row)), f = void 0, yield* r.takePages(), yield* Wr(s, d.row, u, r, l);
638
+ for (const d of lt(o, i)) {
639
+ if (j(r.signal), d.kind === "row")
640
+ l.placeGridRow(f ?? Y(c, d.row, r.measurer), "listr", pr(n.matrix, d.row), a.get(d.row)), f = void 0, yield* r.takePages(), yield* zr(s, d.row, u, r, l);
641
641
  else if (d.kind === "groupHeader") {
642
- const h = G(c, r.measurer, d.label, /* @__PURE__ */ new Map(), d.group.headerStyle ?? {}, s.columns.length);
643
- f ??= z(c, d.firstRow, r.measurer);
644
- const m = i.slice(d.depth + 1).reduce((v, p) => v + G(c, r.measurer, (p.headerTemplate ?? "{value}").replace(/\{value\}/g, xe(d.firstRow[p.field])), /* @__PURE__ */ new Map(), p.headerStyle ?? {}, s.columns.length).heightMm, 0);
645
- d.group.keepWithNext !== !1 && l.keepTogether(h.heightMm + m + f.heightMm), l.placeGridRow(h, "listg", "group-header"), d.group.repeatHeader && l.setGroupHeader(d.depth, h);
642
+ const m = _(c, r.measurer, d.label, /* @__PURE__ */ new Map(), d.group.headerStyle ?? {}, s.columns.length);
643
+ f ??= Y(c, d.firstRow, r.measurer);
644
+ const h = i.slice(d.depth + 1).reduce((b, w) => b + _(c, r.measurer, (w.headerTemplate ?? "{value}").replace(/\{value\}/g, Re(d.firstRow[w.field])), /* @__PURE__ */ new Map(), w.headerStyle ?? {}, s.columns.length).heightMm, 0);
645
+ d.group.keepWithNext !== !1 && l.keepTogether(m.heightMm + h + f.heightMm), l.placeGridRow(m, "listg", "group-header"), d.group.repeatHeader && l.setGroupHeader(d.depth, m);
646
646
  } else if (d.kind === "subtotal") {
647
- const h = d.group.subtotal ?? [], m = d.group.aggregates ?? [], v = G(c, r.measurer, d.label, st(s.columns, d.rows, h, m), d.group.subtotalStyle ?? {}, it(s.columns, [...h, ...m.map((p) => p.field)]));
648
- l.placeGridRow(v, "listst", "subtotal");
647
+ const m = d.group.subtotal ?? [], h = d.group.aggregates ?? [], b = _(c, r.measurer, d.label, dt(s.columns, d.rows, m, h), d.group.subtotalStyle ?? {}, ut(s.columns, [...m, ...h.map((w) => w.field)]));
648
+ l.placeGridRow(b, "listst", "subtotal");
649
649
  } else l.setGroupHeader(d.depth);
650
650
  yield* r.takePages();
651
651
  }
652
- Br(s, n.totalRows ?? o, c, r, l), r.finished?.(l.bottom()), yield* r.takePages();
652
+ Wr(s, n.totalRows ?? o, c, r, l), r.finished?.(l.bottom()), yield* r.takePages();
653
653
  }
654
- function ae(e) {
654
+ function de(e) {
655
655
  return e.kind !== "list" && (e.pageAnchor !== void 0 || e.kind === "text" && typeof e.text == "string" && (e.text.includes("{page}") || e.text.includes("{totalPages}")));
656
656
  }
657
- function se(e, t) {
657
+ function ue(e, t) {
658
658
  return {
659
659
  ...e,
660
660
  ...e.text === void 0 ? {} : { text: t(e.text) },
661
661
  ...e.lines ? { lines: e.lines.map(t) } : {},
662
662
  ...e.richParagraphs ? { richParagraphs: e.richParagraphs.map((r) => ({ ...r, segments: r.segments.map((n) => ({ ...n, ...n.text === void 0 ? {} : { text: t(n.text) } })) })) } : {},
663
- ...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)) } } : {}
663
+ ...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) => ue(o, t)) } : {} } : null)) } } : {}
664
664
  };
665
665
  }
666
- function qr(e) {
666
+ function Xr(e) {
667
667
  let t = !1;
668
- for (const r of e.pages) for (const n of r.components) ae(n) && se(n, (o) => (o.includes("{totalPages}") && (t = !0), o));
668
+ for (const r of e.pages) for (const n of r.components) de(n) && ue(n, (o) => (o.includes("{totalPages}") && (t = !0), o));
669
669
  return t;
670
670
  }
671
- function Ur(e, t, r, n, o, a) {
671
+ function Yr(e, t, r, n, o, a) {
672
672
  const s = {
673
673
  pageWidthMm: t.widthMm,
674
674
  pageHeightMm: t.heightMm,
@@ -683,38 +683,38 @@ function Ur(e, t, r, n, o, a) {
683
683
  const l = c.replace(/\{page\}/g, String(n));
684
684
  return a === void 0 ? l : l.replace(/\{totalPages\}/g, String(a));
685
685
  };
686
- for (const c of r) s.components.push(se(c, i));
686
+ for (const c of r) s.components.push(ue(c, i));
687
687
  if (e.layout === "wide") {
688
688
  const c = s.components.reduce((l, u) => Math.max(l, u.topMm + u.heightMm), 0);
689
689
  s.marginBottomMm = o ? e.marginBottomMm ?? 0 : 0, s.pageHeightMm = Math.max(1, c + s.marginBottomMm);
690
690
  }
691
691
  return s;
692
692
  }
693
- function Ee(e) {
694
- return e.cells.reduce((t, r) => t + r.reduce((n, o) => n + (o ? 1 + (o.children?.reduce((a, s) => a + ut(s), 0) ?? 0) : 0), 0), 0);
693
+ function Ke(e) {
694
+ return e.cells.reduce((t, r) => t + r.reduce((n, o) => n + (o ? 1 + (o.children?.reduce((a, s) => a + gt(s), 0) ?? 0) : 0), 0), 0);
695
695
  }
696
- function ut(e) {
697
- return e.grid ? Ee(e.grid) : 0;
696
+ function gt(e) {
697
+ return e.grid ? Ke(e.grid) : 0;
698
698
  }
699
- function ie(e) {
699
+ function fe(e) {
700
700
  for (const t of ["maxPages", "maxCells", "knownTotalPages"]) if (e[t] !== void 0 && (!Number.isSafeInteger(e[t]) || e[t] < 1)) throw new RangeError(`${t} 应为正安全整数`);
701
- Se(e.maxChartComponents);
701
+ Ee(e.maxChartComponents);
702
702
  }
703
- function Xr(e, t) {
704
- const r = dt(e, t.datasets[e.dataset] ?? [], t), n = Pe(r.list), o = { ...Te(n, t.measurer, r.rows, t.signal), rowHeightFloorMm: n.rowHeightMm ?? 0 };
705
- return (n.header === !1 ? 0 : o.headerHeightMm) + r.rows.reduce((a, s) => a + z(o, s, t.measurer).heightMm, 0);
703
+ function Qr(e, t) {
704
+ const r = ht(e, t.datasets[e.dataset] ?? [], t), n = Ae(r.list), o = { ...Oe(n, t.measurer, r.rows, t.signal), rowHeightFloorMm: n.rowHeightMm ?? 0 };
705
+ return (n.header === !1 ? 0 : o.headerHeightMm) + r.rows.reduce((a, s) => a + Y(o, s, t.measurer).heightMm, 0);
706
706
  }
707
- function* Yr(e) {
707
+ function* Zr(e) {
708
708
  const { templatePage: t, current: r } = e, n = new Map(t.components.map((a, s) => [a, s])), o = (a, s, i) => {
709
709
  const c = e.datasets[a.dataset];
710
- return Array.isArray(c) || e.warnings.push(`数据集 ${a.dataset} 未提供数据,列表 ${a.id ?? ""} 输出为空`), _r(a, Array.isArray(c) ? c : [], { ...e, tableId: `${e.tableId}:${n.get(a)}`, startTop: s, finished: i, flow: !!t.flow });
710
+ return Array.isArray(c) || e.warnings.push(`数据集 ${a.dataset} 未提供数据,列表 ${a.id ?? ""} 输出为空`), Ur(a, Array.isArray(c) ? c : [], { ...e, tableId: `${e.tableId}:${n.get(a)}`, startTop: s, finished: i, flow: !!t.flow });
711
711
  };
712
712
  if (t.flow) {
713
- yield* vr({
713
+ yield* Sr({
714
714
  page: t,
715
- active: () => K(e.signal),
716
- top: () => Math.max(r.marginTopMm, V(t)),
717
- bottom: () => Q(t, r),
715
+ active: () => j(e.signal),
716
+ top: () => Math.max(r.marginTopMm, X(t)),
717
+ bottom: () => oe(t, r),
718
718
  append: (a) => {
719
719
  r.components.push(...e.resolveChart(a));
720
720
  },
@@ -722,37 +722,37 @@ function* Yr(e) {
722
722
  e.pushCurrent(), r.components = [], r.heightMm = t.heightMm, t.layout === "wide" && (r.marginTopMm = 0, r.marginBottomMm = 0);
723
723
  },
724
724
  takePages: e.takePages,
725
- height: (a) => Xr(a, e),
725
+ height: (a) => Qr(a, e),
726
726
  list: o
727
727
  });
728
728
  return;
729
729
  }
730
730
  for (const a of t.components)
731
- ae(a) || (a.kind === "list" ? yield* o(a) : r.components.push(...e.resolveChart(a)));
731
+ de(a) || (a.kind === "list" ? yield* o(a) : r.components.push(...e.resolveChart(a)));
732
732
  }
733
- function* J(e, t, r, n, o, a = /* @__PURE__ */ new WeakMap(), s) {
733
+ function* Q(e, t, r, n, o, a = /* @__PURE__ */ new WeakMap(), s) {
734
734
  let i = 0, c = 0, l = 0;
735
- const u = mr(r.measurer ?? Ve), f = Ut(t, r.signal, r.maxChartComponents), d = (h) => `${h}_${(++i).toString(36)}`;
736
- for (const { pageIndex: h, page: m } of Ir(e, t, r)) {
737
- K(r.signal);
738
- const v = $r(m), p = m.components.filter(ae);
739
- let w = [];
740
- const y = (k = !1) => {
741
- if (K(r.signal), r.maxPages !== void 0 && c >= r.maxPages) throw new W(r.maxPages, c + 1);
742
- if (r.maxCells !== void 0 && (l += [...v.components, ...p].reduce((T, O) => T + ut(O), 0), l > r.maxCells))
743
- throw new Y(r.maxCells, l);
744
- w.push(Ur(m, v, p, ++c, k, o));
745
- }, x = () => {
746
- const k = w;
747
- return w = [], k;
735
+ const u = gr(r.measurer ?? re), f = Yt(t, r.signal, r.maxChartComponents), d = (m) => `${m}_${(++i).toString(36)}`;
736
+ for (const { pageIndex: m, page: h } of Fr(e, t, r)) {
737
+ j(r.signal);
738
+ const b = Or(h), w = h.components.filter(de);
739
+ let y = [];
740
+ const g = (C = !1) => {
741
+ if (j(r.signal), r.maxPages !== void 0 && c >= r.maxPages) throw new U(r.maxPages, c + 1);
742
+ if (r.maxCells !== void 0 && (l += [...b.components, ...w].reduce((T, $) => T + gt($), 0), l > r.maxCells))
743
+ throw new ne(r.maxCells, l);
744
+ y.push(Yr(h, b, w, ++c, C, o));
745
+ }, S = () => {
746
+ const C = y;
747
+ return y = [], C;
748
748
  };
749
- yield* Yr({
750
- templatePage: m,
751
- current: v,
749
+ yield* Zr({
750
+ templatePage: h,
751
+ current: b,
752
752
  warnings: n,
753
753
  nextId: d,
754
- pushCurrent: y,
755
- takePages: x,
754
+ pushCurrent: g,
755
+ takePages: S,
756
756
  datasets: t,
757
757
  resolveChart: f,
758
758
  signal: r.signal,
@@ -760,135 +760,135 @@ function* J(e, t, r, n, o, a = /* @__PURE__ */ new WeakMap(), s) {
760
760
  prepared: a,
761
761
  measurer: u,
762
762
  mmPerRow: r.mmPerRow ?? 0,
763
- tableId: `table:${h}`
764
- }), y(!0), yield* x();
763
+ tableId: `table:${m}`
764
+ }), g(!0), yield* S();
765
765
  }
766
766
  s && (s.chartComponents = f.used());
767
767
  }
768
- function lo(e, t, r = {}) {
769
- ie(r);
768
+ function xo(e, t, r = {}) {
769
+ fe(r);
770
770
  let n = 0;
771
- for (const o of J(e, t, { ...r, onWarning: void 0 }, [])) n++;
771
+ for (const o of Q(e, t, { ...r, onWarning: void 0 }, [])) n++;
772
772
  return n;
773
773
  }
774
- function* uo(e, t, r = {}) {
775
- yield* Qr(e, t, r);
774
+ function* Po(e, t, r = {}) {
775
+ yield* en(e, t, r);
776
776
  }
777
- function* Qr(e, t, r, n) {
778
- ie(r);
779
- const o = qr(e), a = /* @__PURE__ */ new WeakMap();
777
+ function* en(e, t, r, n) {
778
+ fe(r);
779
+ const o = Xr(e), a = /* @__PURE__ */ new WeakMap();
780
780
  let s = r.knownTotalPages;
781
781
  if (o && s === void 0) {
782
782
  s = 0;
783
- for (const l of J(e, t, r, [], void 0, a)) s++;
783
+ for (const l of Q(e, t, r, [], void 0, a)) s++;
784
784
  }
785
785
  const i = [];
786
786
  let c = 0;
787
- for (const l of J(e, t, r, i, s, a, n)) {
787
+ for (const l of Q(e, t, r, i, s, a, n)) {
788
788
  for (; c < i.length; c++) r.onWarning?.(i[c]);
789
789
  yield l;
790
790
  }
791
791
  }
792
- function ft(e, t, r = {}) {
792
+ function pt(e, t, r = {}) {
793
793
  const n = typeof r == "number" ? { mmPerRow: r } : r;
794
- ie(n);
795
- const o = [], a = { chartComponents: 0 }, s = [...J(e, t, n, o, n.knownTotalPages, void 0, a)];
796
- return ht(e, n, s, o, a);
794
+ fe(n);
795
+ const o = [], a = { chartComponents: 0 }, s = [...Q(e, t, n, o, n.knownTotalPages, void 0, a)];
796
+ return yt(e, n, s, o, a);
797
797
  }
798
- async function mt(e, t, r = {}) {
799
- ie(r), K(r.signal);
798
+ async function wt(e, t, r = {}) {
799
+ fe(r), j(r.signal);
800
800
  const n = [], o = [], a = { chartComponents: 0 };
801
801
  let s = performance.now(), i = 0;
802
- for (const c of J(e, t, r, n, r.knownTotalPages, void 0, a))
803
- o.push(c), (++i >= 8 || performance.now() - s >= 8) && (await new Promise((l) => setTimeout(l, 0)), K(r.signal), s = performance.now(), i = 0);
804
- return K(r.signal), ht(e, r, o, n, a);
802
+ for (const c of Q(e, t, r, n, r.knownTotalPages, void 0, a))
803
+ o.push(c), (++i >= 8 || performance.now() - s >= 8) && (await new Promise((l) => setTimeout(l, 0)), j(r.signal), s = performance.now(), i = 0);
804
+ return j(r.signal), yt(e, r, o, n, a);
805
805
  }
806
- function ht(e, t, r, n, o) {
807
- for (const a of r) a.components = a.components.map((s) => ae(s) ? se(s, (i) => i.replace(/\{totalPages\}/g, String(r.length))) : s);
808
- return n.forEach((a) => t.onWarning?.(a)), { plan: { schemaVersion: be, ...Ce(e) ? { requiresRecalculation: !0 } : {}, pages: r }, warnings: n, ...o };
806
+ function yt(e, t, r, n, o) {
807
+ for (const a of r) a.components = a.components.map((s) => de(s) ? ue(s, (i) => i.replace(/\{totalPages\}/g, String(r.length))) : s);
808
+ return n.forEach((a) => t.onWarning?.(a)), { plan: { schemaVersion: Pe, ...$e(e) ? { requiresRecalculation: !0 } : {}, pages: r }, warnings: n, ...o };
809
809
  }
810
- function Zr(e) {
810
+ function tn(e) {
811
811
  const t = e.columns.find((a) => !a.hidden)?.field;
812
812
  if (!t) return { groups: 0, total: 0 };
813
- const r = oe(e), n = (a = [], s = []) => a.includes(t) || s.some((i) => i.field === t), o = typeof e.grandTotal == "object" ? e.grandTotal : void 0;
813
+ const r = le(e), n = (a = [], s = []) => a.includes(t) || s.some((i) => i.field === t), o = typeof e.grandTotal == "object" ? e.grandTotal : void 0;
814
814
  return { groups: r.filter((a) => n(a.subtotal, a.aggregates)).length, total: Number(n(o?.fields ?? r[0]?.subtotal, o?.aggregates ?? r[0]?.aggregates)) };
815
815
  }
816
- function en(e, t, r) {
817
- lt(e);
818
- const n = Xe(t[e.dataset] ?? [], e.tree, r), o = e.columns.filter((s) => !s.hidden).length, a = e.header === !1 ? 0 : e.headerGrid ? Ee(e.headerGrid) : o;
816
+ function rn(e, t, r) {
817
+ mt(e);
818
+ const n = tt(t[e.dataset] ?? [], e.tree, r), o = e.columns.filter((s) => !s.hidden).length, a = e.header === !1 ? 0 : e.headerGrid ? Ke(e.headerGrid) : o;
819
819
  return n.length * o + a + +!!e.grandTotal * 2 * o;
820
820
  }
821
- function fo(e, t, r = {}) {
822
- if (e.tree) return en(e, t, r.signal);
821
+ function ko(e, t, r = {}) {
822
+ if (e.tree) return rn(e, t, r.signal);
823
823
  if (e.matrix) {
824
824
  let c = t[e.dataset] ?? [];
825
- e.computed?.length && (c = ve(c, { fields: e.computed, ...r }).rows), e.rowVisibleWhen && (c = c.filter(H(e.rowVisibleWhen)));
826
- const l = er(c, e.matrix);
825
+ e.computed?.length && (c = Ce(c, { fields: e.computed, ...r }).rows), e.rowVisibleWhen && (c = c.filter(G(e.rowVisibleWhen)));
826
+ const l = rr(c, e.matrix);
827
827
  return l.cells + (e.header === !1 ? 0 : l.columnCount * (e.matrix.hierarchy ? e.matrix.columnFields.length + 1 : 1));
828
828
  }
829
- const n = t[e.dataset]?.length ?? 0, o = e.columns.filter((c) => !c.hidden).length, a = oe(e).length, s = Zr(e);
829
+ const n = t[e.dataset]?.length ?? 0, o = e.columns.filter((c) => !c.hidden).length, a = le(e).length, s = tn(e);
830
830
  let i = (n * (1 + 2 * a + s.groups) + +!!e.grandTotal * (1 + s.total)) * o;
831
- if (i += e.header === !1 ? 0 : e.headerGrid ? Ee(e.headerGrid) : o, e.cardinality === "record" && n === 0 && (i += o), e.detail) {
831
+ if (i += e.header === !1 ? 0 : e.headerGrid ? Ke(e.headerGrid) : o, e.cardinality === "record" && n === 0 && (i += o), e.detail) {
832
832
  const c = t[e.detail.dataset]?.length ?? 0, l = e.detail.columns.filter((u) => !u.hidden).length;
833
833
  i += (c + n * (+(e.detail.header !== !1) + +!!e.detail.label)) * l;
834
834
  }
835
835
  if (!Number.isSafeInteger(i)) throw new RangeError("报表单元格估算超出安全整数预算");
836
836
  return i;
837
837
  }
838
- class tn extends Error {
838
+ class nn extends Error {
839
839
  constructor(t) {
840
840
  super(t.map((r) => r.message).join(";")), this.issues = t, this.name = "ReportValidationError";
841
841
  }
842
842
  }
843
- function Ne(e, t, r) {
843
+ function ze(e, t, r) {
844
844
  if (!Number.isSafeInteger(e) || e < 1 || e > r) throw new Error(`校验 ${t} 超出预算`);
845
845
  return e;
846
846
  }
847
- function rn(e) {
847
+ function on(e) {
848
848
  if (e.aggregates && e.scope !== "dataset") throw new Error("仅数据集规则允许汇总");
849
849
  if (e.aggregates && (!Array.isArray(e.aggregates) || e.aggregates.length > 64)) throw new Error("校验汇总最多 64 项");
850
850
  const t = /* @__PURE__ */ new Set();
851
851
  for (const r of e.aggregates ?? []) {
852
- if (N(r.field), t.has(r.field)) throw new Error("校验汇总字段重复");
853
- t.add(r.field), r.valueField !== void 0 && N(r.valueField), r.weightField !== void 0 && N(r.weightField), Me([], { ...r, field: r.valueField ?? r.field });
852
+ if (D(r.field), t.has(r.field)) throw new Error("校验汇总字段重复");
853
+ t.add(r.field), r.valueField !== void 0 && D(r.valueField), r.weightField !== void 0 && D(r.weightField), Te([], { ...r, field: r.valueField ?? r.field });
854
854
  }
855
855
  }
856
- function gt(e) {
856
+ function bt(e) {
857
857
  if (!Array.isArray(e) || e.length > 256 || Object.keys(e).length !== e.length) throw new Error("校验规则最多 256 条且不允许空位");
858
858
  const t = /* @__PURE__ */ new Set();
859
859
  return e.map((r) => {
860
860
  if (!r || typeof r != "object") throw new Error("校验规则应为声明式对象");
861
- if (N(r.id), t.has(r.id)) throw new Error("校验规则 id 重复");
862
- if (t.add(r.id), r.field !== void 0 && N(r.field), r.dataset !== void 0 && N(r.dataset), typeof r.message != "string" || !r.message.trim() || r.message.length > 2048) throw new Error("校验规则需要有界提示文案");
861
+ if (D(r.id), t.has(r.id)) throw new Error("校验规则 id 重复");
862
+ if (t.add(r.id), r.field !== void 0 && D(r.field), r.dataset !== void 0 && D(r.dataset), typeof r.message != "string" || !r.message.trim() || r.message.length > 2048) throw new Error("校验规则需要有界提示文案");
863
863
  if (r.severity !== void 0 && !["error", "warning"].includes(r.severity)) throw new Error("未知校验严重程度");
864
864
  if (r.scope !== void 0 && !["row", "dataset"].includes(r.scope)) throw new Error("未知校验范围");
865
- rn(r);
866
- const n = { nodes: 0 }, o = H(r.assert, n), a = r.when ? H(r.when, n) : void 0;
865
+ on(r);
866
+ const n = { nodes: 0 }, o = G(r.assert, n), a = r.when ? G(r.when, n) : void 0;
867
867
  return { rule: r, assert: o, when: a, checks: n.nodes };
868
868
  });
869
869
  }
870
- function Le(e) {
870
+ function Je(e) {
871
871
  if (e?.aborted) {
872
872
  const t = new Error("报表校验已取消");
873
873
  throw t.name = "AbortError", t;
874
874
  }
875
875
  }
876
- function nn(e, t, r, n) {
876
+ function an(e, t, r, n) {
877
877
  const o = n && Object.prototype.hasOwnProperty.call(t, n) ? t[n] : void 0;
878
878
  if (o !== void 0 && typeof o != "string" && !(typeof o == "number" && Number.isFinite(o))) throw new Error("校验定位需要稳定的文本或数值业务键");
879
879
  return { ruleId: e.id, rowIndex: r, ...o === void 0 ? {} : { rowKey: o }, field: e.field, severity: e.severity ?? "error", message: e.message };
880
880
  }
881
- function on(e, t) {
881
+ function sn(e, t) {
882
882
  const r = t.computed?.length ? { fields: t.computed, formula: t.formula, signal: t.signal } : void 0;
883
883
  if (t.tree) {
884
- const o = Ye(e, t.tree, { signal: t.signal, computed: r });
884
+ const o = rt(e, t.tree, { signal: t.signal, computed: r });
885
885
  if (o.rows.length > 1e5) throw new Error("校验展开后数据最多 100000 行");
886
886
  return { rows: o.rows, summaryRows: o.leaves, rowKey: t.tree.idField };
887
887
  }
888
- const n = r ? ve(e, r).rows : e;
888
+ const n = r ? Ce(e, r).rows : e;
889
889
  return { rows: n, summaryRows: n, rowKey: t.rowKey };
890
890
  }
891
- function an(e, t) {
891
+ function cn(e, t) {
892
892
  const r = /* @__PURE__ */ new Set();
893
893
  e.forEach((n) => {
894
894
  if (!n || typeof n != "object" || Array.isArray(n)) throw new Error("校验数据行应为对象");
@@ -899,49 +899,49 @@ function an(e, t) {
899
899
  r.add(o);
900
900
  });
901
901
  }
902
- function mo(e, t) {
903
- return pt(e, t, { checks: 0 });
902
+ function Co(e, t) {
903
+ return vt(e, t, { checks: 0 });
904
904
  }
905
- function pt(e, t, r) {
905
+ function vt(e, t, r) {
906
906
  if (!Array.isArray(e) || e.length > 1e5) throw new Error("校验数据最多 100000 行");
907
- Le(t.signal);
908
- const n = Ne(t.maxChecks ?? 2e6, "maxChecks", 1e7), o = Ne(t.maxIssues ?? 1e3, "maxIssues", 1e4);
909
- t.rowKey !== void 0 && N(t.rowKey);
910
- const a = on(e, t), { rows: s, summaryRows: i, rowKey: c } = a;
911
- an(s, c);
912
- const l = gt(t.rules), u = l.reduce((d, h) => d + (h.rule.scope === "dataset" ? h.checks + i.length * (h.rule.aggregates?.length ?? 0) : s.length * h.checks), 0);
907
+ Je(t.signal);
908
+ const n = ze(t.maxChecks ?? 2e6, "maxChecks", 1e7), o = ze(t.maxIssues ?? 1e3, "maxIssues", 1e4);
909
+ t.rowKey !== void 0 && D(t.rowKey);
910
+ const a = sn(e, t), { rows: s, summaryRows: i, rowKey: c } = a;
911
+ cn(s, c);
912
+ const l = bt(t.rules), u = l.reduce((d, m) => d + (m.rule.scope === "dataset" ? m.checks + i.length * (m.rule.aggregates?.length ?? 0) : s.length * m.checks), 0);
913
913
  if (r.checks += u, r.checks > n) throw new Error("整批校验超出 maxChecks 预算");
914
914
  const f = [];
915
915
  for (const d of l)
916
- (d.rule.scope === "dataset" ? [Object.fromEntries((d.rule.aggregates ?? []).map((m) => [m.field, Me(i, { ...m, field: m.valueField ?? m.field })]))] : s).forEach((m, v) => {
917
- if (Le(t.signal), !m || typeof m != "object" || Array.isArray(m)) throw new Error("校验数据行应为对象");
918
- if (!(d.when && !d.when(m) || d.assert(m))) {
916
+ (d.rule.scope === "dataset" ? [Object.fromEntries((d.rule.aggregates ?? []).map((h) => [h.field, Te(i, { ...h, field: h.valueField ?? h.field })]))] : s).forEach((h, b) => {
917
+ if (Je(t.signal), !h || typeof h != "object" || Array.isArray(h)) throw new Error("校验数据行应为对象");
918
+ if (!(d.when && !d.when(h) || d.assert(h))) {
919
919
  if (f.length >= o) throw new Error("校验问题超出 maxIssues 预算,请缩小范围");
920
- f.push(nn(d.rule, m, d.rule.scope === "dataset" ? void 0 : v, d.rule.scope === "dataset" ? void 0 : c));
920
+ f.push(an(d.rule, h, d.rule.scope === "dataset" ? void 0 : b, d.rule.scope === "dataset" ? void 0 : c));
921
921
  }
922
922
  });
923
923
  return f;
924
924
  }
925
- function sn(e, t = "allow") {
925
+ function ln(e, t = "allow") {
926
926
  if (!["allow", "block"].includes(t)) throw new Error("未知校验警告策略");
927
927
  if (!Array.isArray(e) || e.length > 1e4 || e.some((r) => !r || !["error", "warning"].includes(r.severity) || typeof r.ruleId != "string" || !r.ruleId.trim() || typeof r.message != "string" || !r.message.trim())) throw new Error("校验问题结构无效");
928
- if (e.some((r) => r.severity === "error" || t === "block")) throw new tn(e);
928
+ if (e.some((r) => r.severity === "error" || t === "block")) throw new nn(e);
929
929
  }
930
- function He(e, t, r) {
930
+ function _e(e, t, r) {
931
931
  const n = e.get(t);
932
932
  if (n && JSON.stringify(n) !== JSON.stringify(r)) throw new Error("同一数据集的校验计算/业务键存在歧义,请统一绑定");
933
933
  e.set(t, r);
934
934
  }
935
- function cn(e, t, r, n = []) {
936
- gt(t.rules);
935
+ function dn(e, t, r, n = []) {
936
+ bt(t.rules);
937
937
  const o = [], a = { checks: 0 };
938
938
  for (const [i, c] of e.entries()) {
939
939
  const l = /* @__PURE__ */ new Map();
940
940
  for (const u of c.template.pages) for (const f of u.components)
941
- f.kind === "list" && (He(l, f.dataset, { rowKey: f.tree?.idField ?? f.rowKey, computed: f.computed, tree: f.tree }), f.detail && He(l, f.detail.dataset, { rowKey: f.detail.rowKey }));
941
+ f.kind === "list" && (_e(l, f.dataset, { rowKey: f.tree?.idField ?? f.rowKey, computed: f.computed, tree: f.tree }), f.detail && _e(l, f.detail.dataset, { rowKey: f.detail.rowKey }));
942
942
  for (const [u, f] of l) {
943
- const d = t.rules.filter((h) => !h.dataset || h.dataset === u);
944
- if (d.length && (o.push(...pt(c.datasets[u] ?? [], { ...t, rules: d, ...f, formula: n[i], signal: r }, a).map((h) => ({ ...h, dataset: u, sourceScope: c.sourceScope }))), o.length > (t.maxIssues ?? 1e3)))
943
+ const d = t.rules.filter((m) => !m.dataset || m.dataset === u);
944
+ if (d.length && (o.push(...vt(c.datasets[u] ?? [], { ...t, rules: d, ...f, formula: n[i], signal: r }, a).map((m) => ({ ...m, dataset: u, sourceScope: c.sourceScope }))), o.length > (t.maxIssues ?? 1e3)))
945
945
  throw new Error("整批候选校验问题超出 maxIssues 预算");
946
946
  }
947
947
  }
@@ -949,31 +949,31 @@ function cn(e, t, r, n = []) {
949
949
  if (t.rules.some((i) => i.dataset && !s.has(i.dataset))) throw new Error("校验目标数据集不存在");
950
950
  return o;
951
951
  }
952
- function wt(e) {
952
+ function Mt(e) {
953
953
  return !e || typeof e != "object" ? !1 : [e.pageIndex, e.componentIndex, e.rowIndex, e.columnIndex].every((t) => Number.isInteger(t) && t >= 0);
954
954
  }
955
- function yt(e, t, r) {
955
+ function St(e, t, r) {
956
956
  const n = e.grid;
957
957
  if (!n) return null;
958
958
  const o = n.cells[t];
959
959
  if (!o) return null;
960
- const s = te(n, e.widthMm, e.heightMm).cells.filter((c) => c.ri === t).findIndex((c) => c.ci === r), i = o[s];
960
+ const s = q(n, e.widthMm, e.heightMm).cells.filter((c) => c.ri === t).findIndex((c) => c.ci === r), i = o[s];
961
961
  return i ? { cell: i, sourceColumnIndex: s } : null;
962
962
  }
963
- function ln(e) {
963
+ function un(e) {
964
964
  return e.value !== void 0 ? e.value : e.rawText ?? e.text ?? null;
965
965
  }
966
- function dn(e, t) {
966
+ function fn(e, t) {
967
967
  return e.valueType ? e.valueType : typeof t == "number" ? "number" : typeof t == "boolean" ? "boolean" : t === null && e.numberFormat && /[0#?]/.test(e.numberFormat) ? "number" : "text";
968
968
  }
969
- function un(e, t) {
969
+ function mn(e, t) {
970
970
  if (e.derived) return "derived";
971
971
  if (e.editable === !1) return "cell";
972
972
  if (e.formula !== void 0) return "formula";
973
973
  if (e.children?.length || e.richParagraphs?.length) return "complex";
974
974
  if (t.table && t.table.role !== "body" && e.editable !== !0) return "structure";
975
975
  }
976
- function fn(e, t) {
976
+ function hn(e, t) {
977
977
  const r = e.table;
978
978
  if (r)
979
979
  return {
@@ -983,75 +983,94 @@ function fn(e, t) {
983
983
  columnKey: r.columnKeys[t.columnIndex]
984
984
  };
985
985
  }
986
- function mn(e, t, r) {
986
+ function gn(e, t, r) {
987
987
  if (e.derived) return;
988
988
  if (e.source) return { ...e.source };
989
989
  const n = t.table?.source, o = t.table?.columnKeys[r.columnIndex];
990
990
  if (!(!n || n.rowKey === void 0 || o === void 0))
991
991
  return { ...n, rowKey: n.rowKey, field: o };
992
992
  }
993
- function bt(e, t, r) {
994
- const n = ln(r), o = un(r, e);
993
+ function ye(e, t, r) {
994
+ const n = un(r), o = mn(r, e);
995
995
  return {
996
996
  address: { ...t },
997
997
  cell: r,
998
998
  component: e,
999
999
  value: n,
1000
- valueType: dn(r, n),
1001
- table: fn(e, t),
1002
- source: mn(r, e, t),
1000
+ valueType: fn(r, n),
1001
+ table: hn(e, t),
1002
+ source: gn(r, e, t),
1003
1003
  editable: o === void 0,
1004
1004
  readOnlyReason: o
1005
1005
  };
1006
1006
  }
1007
- function Re(e, t) {
1008
- if (!wt(t)) return null;
1007
+ function Ne(e, t) {
1008
+ if (!Mt(t)) return null;
1009
1009
  const r = e.pages[t.pageIndex]?.components[t.componentIndex];
1010
1010
  if (!r) return null;
1011
- const n = yt(r, t.rowIndex, t.columnIndex);
1012
- return n ? bt(r, t, n.cell) : null;
1011
+ const n = St(r, t.rowIndex, t.columnIndex);
1012
+ return n ? ye(r, t, n.cell) : null;
1013
1013
  }
1014
- function D(e) {
1015
- const t = /* @__PURE__ */ new Map();
1016
- return (r) => {
1017
- if (!wt(r)) return null;
1018
- const n = e.pages[r.pageIndex]?.components[r.componentIndex];
1019
- if (!n?.grid) return null;
1020
- let o = t.get(n);
1021
- if (!o) {
1022
- const s = /* @__PURE__ */ new Map();
1023
- o = /* @__PURE__ */ new Map();
1024
- for (const i of te(n.grid, n.widthMm, n.heightMm).cells) {
1025
- const c = s.get(i.ri) ?? 0;
1026
- s.set(i.ri, c + 1);
1027
- const l = n.grid.cells[i.ri]?.[c];
1028
- l && o.set(`${i.ri}:${i.ci}`, l);
1014
+ function pn(e, t = !0) {
1015
+ const r = /* @__PURE__ */ new Map();
1016
+ function n(i) {
1017
+ if (!i.grid) return;
1018
+ let c = r.get(i);
1019
+ if (!c) {
1020
+ const l = q(i.grid, i.widthMm, i.heightMm), u = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map();
1021
+ for (const d of l.cells) {
1022
+ const m = u.get(d.ri) ?? 0;
1023
+ u.set(d.ri, m + 1);
1024
+ const h = i.grid.cells[d.ri]?.[m];
1025
+ h && f.set(`${d.ri}:${d.ci}`, h);
1029
1026
  }
1030
- t.set(n, o);
1027
+ c = { layout: t ? l : void 0, cells: f }, r.set(i, c);
1031
1028
  }
1032
- const a = o.get(`${r.rowIndex}:${r.columnIndex}`);
1033
- return a ? bt(n, r, a) : null;
1034
- };
1029
+ return c;
1030
+ }
1031
+ function o(i) {
1032
+ if (!Mt(i)) return null;
1033
+ const c = e.pages[i.pageIndex]?.components[i.componentIndex];
1034
+ if (!c) return null;
1035
+ const l = n(c)?.cells.get(`${i.rowIndex}:${i.columnIndex}`);
1036
+ return l ? ye(c, i, l) : null;
1037
+ }
1038
+ function* a(i, c) {
1039
+ const l = e.pages[i]?.components[c], u = l && n(l);
1040
+ if (u)
1041
+ for (const f of s(l).cells) {
1042
+ const d = u.cells.get(`${f.ri}:${f.ci}`);
1043
+ d && (yield ye(l, { pageIndex: i, componentIndex: c, rowIndex: f.ri, columnIndex: f.ci }, d));
1044
+ }
1045
+ }
1046
+ function s(i) {
1047
+ const c = n(i);
1048
+ return c && (c.layout ?? q(i.grid, i.widthMm, i.heightMm));
1049
+ }
1050
+ return { resolve: o, entries: a, layout: s };
1051
+ }
1052
+ function W(e) {
1053
+ return pn(e, !1).resolve;
1035
1054
  }
1036
1055
  class M extends Error {
1037
1056
  constructor(t) {
1038
1057
  super(`Invalid report cell edit: ${t}`), this.code = t, this.name = "ReportCellEditError";
1039
1058
  }
1040
1059
  }
1041
- function hn(e, t) {
1060
+ function wn(e, t) {
1042
1061
  let r = e.trim();
1043
1062
  const n = t && r.endsWith("%");
1044
1063
  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 M("number");
1045
1064
  return Number(r) / (n ? 100 : 1);
1046
1065
  }
1047
- function gn(e, t) {
1066
+ function yn(e, t) {
1048
1067
  if (e === null || typeof e == "string" && e.trim() === "") return null;
1049
1068
  if (typeof e != "string" && typeof e != "number") throw new M("number");
1050
- const r = typeof e == "number" ? e : hn(e, dr(t.cell.numberFormat));
1069
+ const r = typeof e == "number" ? e : wn(e, fr(t.cell.numberFormat));
1051
1070
  if (!Number.isFinite(r) || Number.isInteger(r) && !Number.isSafeInteger(r)) throw new M("number");
1052
1071
  return r;
1053
1072
  }
1054
- function pn(e) {
1073
+ function bn(e) {
1055
1074
  if (e === null || typeof e == "string" && e.trim() === "") return null;
1056
1075
  if (typeof e == "boolean") return e;
1057
1076
  const t = String(e).trim().toLowerCase();
@@ -1059,24 +1078,24 @@ function pn(e) {
1059
1078
  if (["false", "no", "否", "0"].includes(t)) return !1;
1060
1079
  throw new M("boolean");
1061
1080
  }
1062
- function vt(e, t) {
1063
- return e.valueType === "number" ? gn(t, e) : e.valueType === "boolean" ? pn(t) : t === null ? null : String(t);
1081
+ function xt(e, t) {
1082
+ return e.valueType === "number" ? yn(t, e) : e.valueType === "boolean" ? bn(t) : t === null ? null : String(t);
1064
1083
  }
1065
- function wn(e, t) {
1084
+ function vn(e, t) {
1066
1085
  const r = t.cell.text, o = [["是", "否"], ["TRUE", "FALSE"], ["True", "False"], ["true", "false"], ["1", "0"]].find((a) => a.includes(r ?? ""));
1067
1086
  return o ? o[e ? 0 : 1] : String(e);
1068
1087
  }
1069
- function q(e, t) {
1070
- return t === null ? "" : typeof t == "boolean" ? wn(t, e) : typeof t == "number" ? lr(t, e.cell.numberFormat) : String(t);
1088
+ function ee(e, t) {
1089
+ return t === null ? "" : typeof t == "boolean" ? vn(t, e) : typeof t == "number" ? ur(t, e.cell.numberFormat) : String(t);
1071
1090
  }
1072
- function ho(e, t, r) {
1073
- const n = Re(e, t);
1091
+ function To(e, t, r) {
1092
+ const n = Ne(e, t);
1074
1093
  if (!n) throw new M("missing");
1075
- return U(n, r);
1094
+ return te(n, r);
1076
1095
  }
1077
- function U(e, t) {
1096
+ function te(e, t) {
1078
1097
  if (!e.editable) throw new M("readonly");
1079
- const r = vt(e, t);
1098
+ const r = xt(e, t);
1080
1099
  return {
1081
1100
  address: { ...e.address },
1082
1101
  table: e.table,
@@ -1084,73 +1103,73 @@ function U(e, t) {
1084
1103
  previousValue: e.value,
1085
1104
  previousText: e.cell.text ?? "",
1086
1105
  value: r,
1087
- text: q(e, r)
1106
+ text: ee(e, r)
1088
1107
  };
1089
1108
  }
1090
- function yn(e, t) {
1109
+ function Mn(e, t) {
1091
1110
  const r = e.table, n = t.table;
1092
1111
  return !r || !n || r.columnKey === void 0 ? !1 : r.id === n.id && r.rowIndex === n.rowIndex && r.role === n.role && r.columnKey === n.columnKey;
1093
1112
  }
1094
- function Mt(e, t, r) {
1095
- const n = e.grid, { rowIndex: o, columnIndex: a } = t.address, s = yt(e, o, a), i = [...n.cells], c = [...i[o]], l = q(t, r.value), u = { ...s.cell, value: r.value, text: l, rawText: l };
1113
+ function Pt(e, t, r) {
1114
+ const n = e.grid, { rowIndex: o, columnIndex: a } = t.address, s = St(e, o, a), i = [...n.cells], c = [...i[o]], l = ee(t, r.value), u = { ...s.cell, value: r.value, text: l, rawText: l };
1096
1115
  return c[s.sourceColumnIndex] = u, i[o] = c, { ...e, grid: { ...n, cells: i } };
1097
1116
  }
1098
- function bn(e, t) {
1117
+ function Sn(e, t) {
1099
1118
  const r = e.table?.columnKeys, n = t.table?.columnKey;
1100
1119
  return r && n !== void 0 ? r.flatMap((o, a) => o === n ? [a] : []) : [];
1101
1120
  }
1102
- function vn(e, t, r, n, o, a) {
1121
+ function xn(e, t, r, n, o, a) {
1103
1122
  const s = t.table, i = o.table;
1104
1123
  if (!s || !i || s.id !== i.id || s.role !== i.role || !t.grid) return t;
1105
1124
  const c = i.rowIndex - s.rowIndex;
1106
1125
  if (c < 0 || c >= t.grid.cells.length) return t;
1107
1126
  let l = t;
1108
- for (const u of bn(t, o)) {
1109
- const f = Re(e, { pageIndex: r, componentIndex: n, rowIndex: c, columnIndex: u });
1110
- f?.editable && yn(o, f) && (l = Mt(l, f, a));
1127
+ for (const u of Sn(t, o)) {
1128
+ const f = Ne(e, { pageIndex: r, componentIndex: n, rowIndex: c, columnIndex: u });
1129
+ f?.editable && Mn(o, f) && (l = Pt(l, f, a));
1111
1130
  }
1112
1131
  return l;
1113
1132
  }
1114
- function Mn(e, t, r, n, o, a) {
1133
+ function Pn(e, t, r, n, o, a) {
1115
1134
  const s = o.address;
1116
- return o.table?.columnKey !== void 0 ? vn(e, t, r, n, o, a) : s.pageIndex === r && s.componentIndex === n ? Mt(t, o, a) : t;
1135
+ return o.table?.columnKey !== void 0 ? xn(e, t, r, n, o, a) : s.pageIndex === r && s.componentIndex === n ? Pt(t, o, a) : t;
1117
1136
  }
1118
- function Ie(e, t) {
1137
+ function je(e, t) {
1119
1138
  const r = t.source;
1120
1139
  if (!r) return !1;
1121
1140
  const n = e.source;
1122
1141
  return !n || ["sourceScope", "datasetId", "rowKey", "field", "revision", "sourceToken"].some((o) => !Object.is(n[o], r[o]));
1123
1142
  }
1124
- function go(e, t) {
1125
- const r = Re(e, t.address);
1143
+ function Eo(e, t) {
1144
+ const r = Ne(e, t.address);
1126
1145
  if (!r) throw new M("missing");
1127
1146
  if (!r.editable) throw new M("readonly");
1128
- if (Ie(r, t)) throw new M("conflict");
1147
+ if (je(r, t)) throw new M("conflict");
1129
1148
  if (!Object.is(r.value, t.previousValue) || (r.cell.text ?? "") !== t.previousText) throw new M("conflict");
1130
- const n = vt(r, t.value), o = { ...t, value: n, text: q(r, n) };
1149
+ const n = xt(r, t.value), o = { ...t, value: n, text: ee(r, n) };
1131
1150
  if (Object.is(n, r.value) && o.text === r.cell.text) return e;
1132
1151
  const a = e.pages.map((s, i) => {
1133
- const c = s.components.map((l, u) => Mn(e, l, i, u, r, o));
1152
+ const c = s.components.map((l, u) => Pn(e, l, i, u, r, o));
1134
1153
  return c.every((l, u) => l === s.components[u]) ? s : { ...s, components: c };
1135
1154
  });
1136
1155
  return { ...e, pages: a };
1137
1156
  }
1138
- function St(e) {
1157
+ function kt(e) {
1139
1158
  const t = [];
1140
1159
  for (const r of e.template.pages) for (const n of r.components)
1141
1160
  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] ?? [] } }));
1142
1161
  return t;
1143
1162
  }
1144
- function B(e) {
1163
+ function V(e) {
1145
1164
  return JSON.stringify([e.sourceScope, e.datasetId]);
1146
1165
  }
1147
- function De(e) {
1166
+ function ae(e) {
1148
1167
  return JSON.stringify([e.sourceScope, e.datasetId, e.rowKey]);
1149
1168
  }
1150
- function xt(e) {
1169
+ function Ct(e) {
1151
1170
  const t = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Set();
1152
1171
  return e.forEach((n, o) => {
1153
- for (const a of St(n)) {
1172
+ for (const a of kt(n)) {
1154
1173
  if (!a.rowKey) continue;
1155
1174
  const s = a.relation, i = s ? new Set(s.parentRows.map((c) => JSON.stringify(c[s.detail.parentKey]))) : void 0;
1156
1175
  (n.datasets[a.dataset] ?? []).forEach((c, l) => {
@@ -1160,18 +1179,18 @@ function xt(e) {
1160
1179
  const f = `${o}:${a.dataset}:${l}:${a.rowKey}`;
1161
1180
  if (r.has(f)) return;
1162
1181
  r.add(f);
1163
- const d = De({ sourceScope: n.sourceScope, datasetId: a.dataset, rowKey: u }), h = t.get(d) ?? [];
1164
- h.push({ partIndex: o, dataset: a.dataset, rowIndex: l, row: c, binding: a }), t.set(d, h);
1182
+ const d = ae({ sourceScope: n.sourceScope, datasetId: a.dataset, rowKey: u }), m = t.get(d) ?? [];
1183
+ m.push({ partIndex: o, dataset: a.dataset, rowIndex: l, row: c, binding: a }), t.set(d, m);
1165
1184
  });
1166
1185
  }
1167
1186
  }), (n) => {
1168
- const o = t.get(De(n));
1187
+ const o = t.get(ae(n));
1169
1188
  if (!o?.length) throw new M("missing");
1170
1189
  if (new Set(o.map((a) => `${a.partIndex}:${a.dataset}`)).size !== o.length) throw new M("conflict");
1171
1190
  return o;
1172
1191
  };
1173
1192
  }
1174
- function Ct(e, t) {
1193
+ function Tt(e, t) {
1175
1194
  const r = e.map((o) => ({ ...o, datasets: { ...o.datasets } })), n = /* @__PURE__ */ new Set();
1176
1195
  for (const { row: o, field: a, value: s } of t) {
1177
1196
  const i = r[o.partIndex], c = JSON.stringify([o.partIndex, o.dataset]);
@@ -1179,45 +1198,45 @@ function Ct(e, t) {
1179
1198
  }
1180
1199
  for (const o of n) {
1181
1200
  const [a, s] = JSON.parse(o);
1182
- zt(e[a].datasets[s], r[a].datasets[s]);
1201
+ _t(e[a].datasets[s], r[a].datasets[s]);
1183
1202
  }
1184
1203
  return r;
1185
1204
  }
1186
- function Sn(e, t, r) {
1205
+ function kn(e, t, r) {
1187
1206
  const n = [], o = /* @__PURE__ */ new Set();
1188
1207
  return e.forEach((a, s) => {
1189
- for (const i of St(a))
1190
- t.has(B({ sourceScope: a.sourceScope, datasetId: i.dataset })) && (a.datasets[i.dataset] ?? []).forEach((c, l) => {
1208
+ for (const i of kt(a))
1209
+ t.has(V({ sourceScope: a.sourceScope, datasetId: i.dataset })) && (a.datasets[i.dataset] ?? []).forEach((c, l) => {
1191
1210
  const u = { partIndex: s, dataset: i.dataset, rowIndex: l, row: c, binding: i };
1192
1211
  for (const [f, d] of [[i.revisionField, r.revision], [i.sourceTokenField, r.sourceToken]]) {
1193
1212
  if (!f || d === void 0) continue;
1194
- const h = `${s}:${i.dataset}:${l}:${f}`;
1195
- o.has(h) || (o.add(h), n.push({ row: u, field: f, value: d }));
1213
+ const m = `${s}:${i.dataset}:${l}:${f}`;
1214
+ o.has(m) || (o.add(m), n.push({ row: u, field: f, value: d }));
1196
1215
  }
1197
1216
  });
1198
1217
  }), n;
1199
1218
  }
1200
- function xn(e, t, r) {
1219
+ function Cn(e, t, r) {
1201
1220
  if (!r || r.revision === void 0 && r.sourceToken === void 0) return e;
1202
- const n = new Set(t.edits.flatMap((o) => o.source ? [B(o.source)] : []));
1203
- return kt(e, new Map([...n].map((o) => [o, r])));
1221
+ const n = new Set(t.edits.flatMap((o) => o.source ? [V(o.source)] : []));
1222
+ return Et(e, new Map([...n].map((o) => [o, r])));
1204
1223
  }
1205
- function kt(e, t) {
1224
+ function Et(e, t) {
1206
1225
  if (!t.size) return e;
1207
1226
  function r(a) {
1208
- const s = a.datasetId && t.get(B({ ...a, datasetId: a.datasetId }));
1227
+ const s = a.datasetId && t.get(V({ ...a, datasetId: a.datasetId }));
1209
1228
  return !s || (s.revision === void 0 || Object.is(s.revision, a.revision)) && (s.sourceToken === void 0 || s.sourceToken === a.sourceToken) ? a : { ...a, ...s.revision !== void 0 ? { revision: s.revision } : {}, ...s.sourceToken !== void 0 ? { sourceToken: s.sourceToken } : {} };
1210
1229
  }
1211
1230
  function n(a) {
1212
1231
  const s = a.map((i) => {
1213
1232
  const c = i.table?.source ? r(i.table.source) : void 0, l = i.table && c !== i.table.source ? { ...i.table, source: c } : i.table, u = i.grid?.cells.map((d) => {
1214
- const h = d.map((m) => {
1215
- if (!m) return m;
1216
- const v = m.source ? r(m.source) : void 0, p = m.children ? n(m.children) : void 0;
1217
- return v === m.source && p === m.children ? m : { ...m, source: v, children: p };
1233
+ const m = d.map((h) => {
1234
+ if (!h) return h;
1235
+ const b = h.source ? r(h.source) : void 0, w = h.children ? n(h.children) : void 0;
1236
+ return b === h.source && w === h.children ? h : { ...h, source: b, children: w };
1218
1237
  });
1219
- return h.some((m, v) => m !== d[v]) ? h : d;
1220
- }), f = i.grid && u?.some((d, h) => d !== i.grid.cells[h]) ? { ...i.grid, cells: u } : i.grid;
1238
+ return m.some((h, b) => h !== d[b]) ? m : d;
1239
+ }), f = i.grid && u?.some((d, m) => d !== i.grid.cells[m]) ? { ...i.grid, cells: u } : i.grid;
1221
1240
  return l !== i.table || f !== i.grid ? { ...i, table: l, grid: f } : i;
1222
1241
  });
1223
1242
  return s.some((i, c) => i !== a[c]) ? s : a;
@@ -1228,29 +1247,29 @@ function kt(e, t) {
1228
1247
  });
1229
1248
  return o.some((a, s) => a !== e.pages[s]) ? { ...e, pages: o } : e;
1230
1249
  }
1231
- function Cn(e) {
1250
+ function Tn(e) {
1232
1251
  return JSON.stringify([e.pageIndex, e.componentIndex, e.rowIndex, e.columnIndex]);
1233
1252
  }
1234
- function Be(e) {
1253
+ function qe(e) {
1235
1254
  const t = e.table;
1236
- return t?.columnKey !== void 0 ? JSON.stringify([t.id, t.role, t.rowIndex, t.columnKey]) : Cn(e.address);
1255
+ return t?.columnKey !== void 0 ? JSON.stringify([t.id, t.role, t.rowIndex, t.columnKey]) : Tn(e.address);
1237
1256
  }
1238
- function kn(e, t) {
1257
+ function En(e, t) {
1239
1258
  if (!t.length) return e;
1240
- const r = new Map(t.map((c) => [Be(c), c])), n = new Set(t.flatMap((c) => c.table ? [c.table.id] : [])), o = new Set(t.map((c) => `${c.address.pageIndex}:${c.address.componentIndex}`)), a = D(e);
1259
+ const r = new Map(t.map((c) => [qe(c), c])), n = new Set(t.flatMap((c) => c.table ? [c.table.id] : [])), o = new Set(t.map((c) => `${c.address.pageIndex}:${c.address.componentIndex}`)), a = W(e);
1241
1260
  function s(c, l, u) {
1242
1261
  const f = c.grid;
1243
1262
  if (!f || !o.has(`${l}:${u}`) && !n.has(c.table?.id ?? "")) return c;
1244
- const d = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map();
1245
- for (const m of te(f, c.widthMm, c.heightMm).cells) {
1246
- const v = h.get(m.ri) ?? 0;
1247
- h.set(m.ri, v + 1);
1248
- const p = a({ pageIndex: l, componentIndex: u, rowIndex: m.ri, columnIndex: m.ci }), w = p && r.get(Be(p));
1249
- if (!w || !p.editable) continue;
1250
- const y = d.get(m.ri) ?? [...f.cells[m.ri]], x = q(p, w.value);
1251
- Object.is(p.value, w.value) && x === p.cell.text || (y[v] = { ...m.cell, value: w.value, text: x, rawText: x }, d.set(m.ri, y));
1263
+ const d = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map();
1264
+ for (const h of q(f, c.widthMm, c.heightMm).cells) {
1265
+ const b = m.get(h.ri) ?? 0;
1266
+ m.set(h.ri, b + 1);
1267
+ const w = a({ pageIndex: l, componentIndex: u, rowIndex: h.ri, columnIndex: h.ci }), y = w && r.get(qe(w));
1268
+ if (!y || !w.editable) continue;
1269
+ const g = d.get(h.ri) ?? [...f.cells[h.ri]], S = ee(w, y.value);
1270
+ Object.is(w.value, y.value) && S === w.cell.text || (g[b] = { ...h.cell, value: y.value, text: S, rawText: S }, d.set(h.ri, g));
1252
1271
  }
1253
- return d.size ? { ...c, grid: { ...f, cells: f.cells.map((m, v) => d.get(v) ?? m) } } : c;
1272
+ return d.size ? { ...c, grid: { ...f, cells: f.cells.map((h, b) => d.get(b) ?? h) } } : c;
1254
1273
  }
1255
1274
  const i = e.pages.map((c, l) => {
1256
1275
  const u = c.components.map((f, d) => s(f, l, d));
@@ -1258,7 +1277,7 @@ function kn(e, t) {
1258
1277
  });
1259
1278
  return i.every((c, l) => c === e.pages[l]) ? e : { ...e, pages: i };
1260
1279
  }
1261
- function F(e) {
1280
+ function O(e) {
1262
1281
  const t = e.source;
1263
1282
  if (t) return JSON.stringify([t.sourceScope, t.datasetId, t.rowKey, t.field]);
1264
1283
  const r = e.table;
@@ -1266,65 +1285,65 @@ function F(e) {
1266
1285
  const n = e.address;
1267
1286
  return JSON.stringify([n.pageIndex, n.componentIndex, n.rowIndex, n.columnIndex]);
1268
1287
  }
1269
- function po(e, t, r) {
1288
+ function Ro(e, t, r) {
1270
1289
  if (typeof r != "string" || !r.trim() || !Array.isArray(t)) throw new M("missing");
1271
1290
  if (t.length > 1e4) throw new M("limit");
1272
- const n = /* @__PURE__ */ new Set(), o = D(e), a = t.map(({ address: s, value: i }) => {
1291
+ const n = /* @__PURE__ */ new Set(), o = W(e), a = t.map(({ address: s, value: i }) => {
1273
1292
  const c = o(s);
1274
1293
  if (!c) throw new M("missing");
1275
- const l = U(c, i), u = F(l);
1294
+ const l = te(c, i), u = O(l);
1276
1295
  if (n.has(u)) throw new M("duplicate");
1277
1296
  return n.add(u), l;
1278
1297
  });
1279
1298
  return { requestId: r, edits: a };
1280
1299
  }
1281
- function wo(e, t) {
1300
+ function Io(e, t) {
1282
1301
  if (t.edits.length > 1e4) throw new M("limit");
1283
- const r = D(e), n = /* @__PURE__ */ new Set(), o = t.edits.map((a) => {
1302
+ const r = W(e), n = /* @__PURE__ */ new Set(), o = t.edits.map((a) => {
1284
1303
  const s = r(a.address);
1285
1304
  if (!s) throw new M("missing");
1286
- const i = F(a);
1305
+ const i = O(a);
1287
1306
  if (n.has(i)) throw new M("duplicate");
1288
- if (n.add(i), Ie(s, a) || !Object.is(s.value, a.previousValue) || (s.cell.text ?? "") !== a.previousText) throw new M("conflict");
1289
- return U(s, a.value);
1307
+ if (n.add(i), je(s, a) || !Object.is(s.value, a.previousValue) || (s.cell.text ?? "") !== a.previousText) throw new M("conflict");
1308
+ return te(s, a.value);
1290
1309
  });
1291
- return kn(e, o);
1310
+ return En(e, o);
1292
1311
  }
1293
- function yo(e) {
1312
+ function $o(e) {
1294
1313
  const t = /* @__PURE__ */ new Map();
1295
1314
  for (const r of e) {
1296
- const n = F(r), o = t.get(n), a = o ? { ...r, previousValue: o.previousValue, previousText: o.previousText } : { ...r };
1315
+ const n = O(r), o = t.get(n), a = o ? { ...r, previousValue: o.previousValue, previousText: o.previousText } : { ...r };
1297
1316
  Object.is(a.previousValue, a.value) ? t.delete(n) : t.set(n, a);
1298
1317
  }
1299
1318
  return [...t.values()];
1300
1319
  }
1301
- function Tt(e) {
1302
- const t = /* @__PURE__ */ new Map(), r = D(e);
1320
+ function Rt(e) {
1321
+ const t = /* @__PURE__ */ new Map(), r = W(e);
1303
1322
  return e.pages.forEach((n, o) => n.components.forEach((a, s) => {
1304
1323
  if (!(!a.grid || a.table?.role !== "body"))
1305
1324
  for (let i = 0; i < a.grid.cells.length; i++) for (let c = 0; c < a.table.columnKeys.length; c++) {
1306
1325
  const l = r({ pageIndex: o, componentIndex: s, rowIndex: i, columnIndex: c });
1307
- l?.source && l.editable && t.set(F(l), l);
1326
+ l?.source && l.editable && t.set(O(l), l);
1308
1327
  }
1309
1328
  })), t;
1310
1329
  }
1311
- function bo(e, t, r) {
1312
- const n = Tt(e), o = D(e);
1330
+ function Fo(e, t, r) {
1331
+ const n = Rt(e), o = W(e);
1313
1332
  return t.map((a) => {
1314
- const s = a.source ? n.get(F(a)) : o(a.address);
1315
- if (!s || F(s) !== F(a)) throw new M("missing");
1333
+ const s = a.source ? n.get(O(a)) : o(a.address);
1334
+ if (!s || O(s) !== O(a)) throw new M("missing");
1316
1335
  return { address: { ...s.address }, value: a[r] };
1317
1336
  });
1318
1337
  }
1319
- function Pt(e, t) {
1338
+ function It(e, t) {
1320
1339
  if (++e.nodes > 1e6 || t > 128) throw new M("limit");
1321
1340
  }
1322
- function Z(e, t) {
1341
+ function se(e, t) {
1323
1342
  const r = Object.getOwnPropertyDescriptor(e, t);
1324
1343
  if (!r || r.get || r.set) throw new M("conflict");
1325
1344
  return r.value;
1326
1345
  }
1327
- function $e(e) {
1346
+ function Le(e) {
1328
1347
  if (Object.getOwnPropertyDescriptor(e, "toJSON")) throw new M("conflict");
1329
1348
  const t = Object.getPrototypeOf(e);
1330
1349
  if (Array.isArray(e) && (t !== Array.prototype || Object.keys(e).length !== e.length)) throw new M("conflict");
@@ -1335,114 +1354,216 @@ function $e(e) {
1335
1354
  if (e instanceof Date || Array.isArray(e) && !/^(0|[1-9]\d*)$/.test(r)) throw new M("conflict");
1336
1355
  }
1337
1356
  }
1338
- function Et(e, t, r, n, o) {
1339
- if (Pt(n, o), typeof e == "function" || typeof e == "symbol") throw new M("conflict");
1357
+ function $t(e, t, r, n, o, a) {
1358
+ if (It(n, o), typeof e == "function" || typeof e == "symbol") throw new M("conflict");
1340
1359
  if (e === null || typeof e != "object") return;
1341
- if ($e(e), r.has(e)) throw new M("conflict");
1342
- r.add(e);
1343
- const a = Object.keys(e), s = a.map((i) => Z(e, i));
1360
+ if (Le(e), r.has(e)) throw new M("conflict");
1361
+ if (a?.has(e)) return;
1362
+ a?.add(e), r.add(e);
1363
+ const s = Object.keys(e), i = s.map((c) => se(e, c));
1344
1364
  t.push({
1345
1365
  object: e,
1346
1366
  prototype: Object.getPrototypeOf(e),
1347
- keys: a,
1348
- values: s,
1367
+ keys: s,
1368
+ values: i,
1349
1369
  ...e instanceof Date ? { date: Date.prototype.getTime.call(e) } : {},
1350
1370
  ...Array.isArray(e) ? { length: e.length } : {}
1351
1371
  });
1352
- for (const i of s) Et(i, t, r, n, o + 1);
1372
+ for (const c of i) $t(c, t, r, n, o + 1, a);
1353
1373
  r.delete(e);
1354
1374
  }
1355
- function Tn(e) {
1375
+ function Rn(e) {
1356
1376
  const { object: t, keys: r, values: n } = e;
1357
- if ($e(t), Object.getPrototypeOf(t) !== e.prototype || Object.getOwnPropertyDescriptor(t, "toJSON") || e.date !== void 0 && !Object.is(Date.prototype.getTime.call(t), e.date) || e.length !== void 0 && t.length !== e.length) return !1;
1377
+ if (Le(t), Object.getPrototypeOf(t) !== e.prototype || Object.getOwnPropertyDescriptor(t, "toJSON") || e.date !== void 0 && !Object.is(Date.prototype.getTime.call(t), e.date) || e.length !== void 0 && t.length !== e.length) return !1;
1358
1378
  const o = Object.keys(t);
1359
- return o.length === r.length && r.every((a, s) => o[s] === a && Object.is(Z(t, a), n[s]));
1379
+ return o.length === r.length && r.every((a, s) => o[s] === a && Object.is(se(t, a), n[s]));
1360
1380
  }
1361
- function Pn(e) {
1362
- const t = [];
1363
- return Et(e, t, /* @__PURE__ */ new Set(), { nodes: 0 }, 0), () => {
1381
+ function In(e) {
1382
+ return Ft(e);
1383
+ }
1384
+ function $n(e) {
1385
+ return Ft(e, /* @__PURE__ */ new Set());
1386
+ }
1387
+ function Ft(e, t) {
1388
+ const r = [];
1389
+ return $t(e, r, /* @__PURE__ */ new Set(), { nodes: 0 }, 0, t), () => {
1364
1390
  try {
1365
- return t.every(Tn);
1391
+ return r.every(Rn);
1366
1392
  } catch {
1367
1393
  return !1;
1368
1394
  }
1369
1395
  };
1370
1396
  }
1371
- function ee(e, t, r, n = !1) {
1372
- if (Pt(t, r), n) {
1397
+ function ie(e, t, r, n = !1) {
1398
+ if (It(t, r), n) {
1373
1399
  if (typeof e == "function" || typeof e == "symbol") throw new M("conflict");
1374
- e !== null && typeof e == "object" && $e(e);
1400
+ e !== null && typeof e == "object" && Le(e);
1375
1401
  }
1376
1402
  if (e === null || typeof e != "object") return e;
1377
1403
  if (e instanceof Date) return new Date(Date.prototype.getTime.call(e));
1378
1404
  if (Array.isArray(e)) {
1379
1405
  const o = [];
1380
- for (let a = 0; a < e.length; a++) o[a] = ee(Z(e, String(a)), t, r + 1, n);
1406
+ for (let a = 0; a < e.length; a++) o[a] = ie(se(e, String(a)), t, r + 1, n);
1381
1407
  return o;
1382
1408
  }
1383
- return Object.fromEntries(Object.keys(e).map((o) => [o, ee(Z(e, o), t, r + 1, n)]));
1409
+ return Object.fromEntries(Object.keys(e).map((o) => [o, ie(se(e, o), t, r + 1, n)]));
1384
1410
  }
1385
- function En(e) {
1386
- return ee(e, { nodes: 0 }, 0, !0);
1411
+ function Fn(e) {
1412
+ return ie(e, { nodes: 0 }, 0, !0);
1387
1413
  }
1388
- function Rn(e) {
1389
- const t = ee(e, { nodes: 0 }, 0);
1390
- for (const r of t) for (const n of Object.values(r.datasets)) Jt(n);
1414
+ function On(e) {
1415
+ const t = ie(e, { nodes: 0 }, 0);
1416
+ for (const r of t) for (const n of Object.values(r.datasets)) qt(n);
1391
1417
  return t;
1392
1418
  }
1393
- async function In(e, t, r = {}) {
1394
- return (await Rt(e, t, r)).plan;
1419
+ async function An(e, t, r = {}) {
1420
+ return (await Ot(e, t, r)).plan;
1395
1421
  }
1396
- async function Rt(e, t, r = {}) {
1397
- return mt(e, t, { ...r, knownTotalPages: void 0 });
1422
+ async function Ot(e, t, r = {}) {
1423
+ return wt(e, t, { ...r, knownTotalPages: void 0 });
1398
1424
  }
1399
- const he = /* @__PURE__ */ new WeakMap();
1400
- function vo(e) {
1401
- return he.get(e);
1425
+ function Kn(e) {
1426
+ return e.computed || e.groupBy || e.groups || e.grandTotal || e.tree || e.matrix || e.detail || e.rowVisibleWhen || e.headerGrid ? !1 : e.columns.every((t) => !t.format && !t.rules && !t.visibleWhen && !t.visual);
1402
1427
  }
1403
- function X(e) {
1428
+ function Nn(e, t) {
1429
+ return e.length !== t.length || t.some((r) => r?.measurer || r?.formula || r?.mmPerRow || r?.knownTotalPages !== void 0) ? !1 : e.every((r) => !r.template.repeat && r.template.pages.every((n) => !n.flow && n.components.every((o) => o.kind === "list" ? Kn(o) : !o.binding && !o.chartBinding && !o.grid && !o.table && !o.richParagraphs)));
1430
+ }
1431
+ function jn(e) {
1432
+ const t = /* @__PURE__ */ new Map();
1433
+ for (const r of e) {
1434
+ if (!r.source || typeof r.value != "string" || typeof r.previousValue != "string" || r.previousText !== r.previousValue || ![r.previousValue, r.value].every((a) => a.trim().length && a.length <= 16384 && !/[\r\n]/.test(a))) return null;
1435
+ const n = ae(r.source), o = t.get(n) ?? /* @__PURE__ */ new Map();
1436
+ o.set(r.source.field, r), t.set(n, o);
1437
+ }
1438
+ return t;
1439
+ }
1440
+ function He(e) {
1441
+ return !e.source && !e.formula && !e.derived && !e.richParagraphs && !e.children && !e.dataBar && !e.numberFormat && !e.colSpan && !e.rowSpan && !e.indentMm && !e.style?.rotateDeg;
1442
+ }
1443
+ function Ln(e) {
1444
+ return e.pages.every((t) => t.components.every((r) => !r.grid || r.grid.cells.every((n) => n.every((o) => !!o && He(o)))));
1445
+ }
1446
+ function Hn(e, t, r, n) {
1447
+ if (!He(e) || e.value !== t.previousValue || e.text !== t.previousText) return !1;
1448
+ const o = r - n * 2, a = e.style, s = Z(a).fontSizePt;
1449
+ if (!Number.isFinite(o) || o < 1 || !Number.isFinite(s) || s <= 0) return !1;
1450
+ const i = { fontSizePt: s, fontFamily: a?.fontFamily ?? ke, italic: a?.italic, bold: a?.bold, letterSpacingPt: a?.letterSpacing };
1451
+ return B(t.previousText, o, i, re).length === B(t.value, o, i, re).length;
1452
+ }
1453
+ function Dn(e, t) {
1454
+ const r = e.colWidthsMm;
1455
+ if (!r || r.length !== e.cells[0].length || r.length !== t.table.columnKeys.length) return !1;
1456
+ const n = r.reduce((o, a) => o + a, 0);
1457
+ return Number.isFinite(n) && Math.abs(n - t.widthMm) <= Math.max(1e-7, n * 1e-10);
1458
+ }
1459
+ function Bn(e, t, r) {
1460
+ const n = e.table?.source;
1461
+ if (e.table?.role !== "body" || n?.rowKey === void 0) return e;
1462
+ const o = t.get(ae({ ...n, rowKey: n.rowKey }));
1463
+ if (!o) return e;
1464
+ const a = e.grid;
1465
+ if (!a || a.cells.length !== 1 || !Dn(a, e) || e.style?.rotateDeg) return null;
1466
+ const s = a.cells[0], i = [...s];
1467
+ for (let c = 0; c < s.length; c++) {
1468
+ const l = s[c];
1469
+ if (!l || !He(l)) return null;
1470
+ const u = o.get(e.table.columnKeys[c]);
1471
+ if (u) {
1472
+ if (!Hn(l, u, a.colWidthsMm[c], a.paddingMm ?? 0.5)) return null;
1473
+ i[c] = { ...l, value: u.value, text: u.value }, r.add(u);
1474
+ }
1475
+ }
1476
+ return i.some((c, l) => c !== s[l]) ? { ...e, grid: { ...a, cells: [i] } } : e;
1477
+ }
1478
+ async function Gn(e, t, r) {
1479
+ const n = jn(t);
1480
+ if (!n || !t.length) return null;
1481
+ const o = /* @__PURE__ */ new Set(), a = [];
1482
+ let s = 0;
1483
+ for (const c of e.pages) {
1484
+ const l = [];
1485
+ for (const u of c.components) {
1486
+ if (r?.aborted) return null;
1487
+ const f = Bn(u, n, o);
1488
+ if (!f) return null;
1489
+ l.push(f), ++s % 128 === 0 && await new Promise((d) => setTimeout(d, 0));
1490
+ }
1491
+ a.push(l.some((u, f) => u !== c.components[f]) ? { ...c, components: l } : c);
1492
+ }
1493
+ if (o.size !== t.length) return null;
1494
+ const i = { ...e, pages: a };
1495
+ return Ie(i).ok ? i : null;
1496
+ }
1497
+ function Wn(e, t, r) {
1498
+ let n = Nn(t, r), o = e, a;
1499
+ function s(c) {
1500
+ if (o = c, a = void 0, !!n) {
1501
+ if (!Ln(c)) {
1502
+ n = !1;
1503
+ return;
1504
+ }
1505
+ try {
1506
+ a = $n(c);
1507
+ } catch {
1508
+ n = !1;
1509
+ }
1510
+ }
1511
+ }
1512
+ s(e);
1513
+ async function i(c, l, u) {
1514
+ if (!n || c !== o || !a?.()) return null;
1515
+ const f = a, d = await Gn(c, l, u);
1516
+ return d && f() ? { plan: d, unchanged: f } : null;
1517
+ }
1518
+ return { candidate: i, publish: s };
1519
+ }
1520
+ const be = /* @__PURE__ */ new WeakMap();
1521
+ function Oo(e) {
1522
+ return be.get(e);
1523
+ }
1524
+ function J(e) {
1404
1525
  if (e?.aborted) {
1405
1526
  const t = new Error("报表重算已取消");
1406
1527
  throw t.name = "AbortError", t;
1407
1528
  }
1408
1529
  }
1409
- function It(e, t) {
1530
+ function At(e, t) {
1410
1531
  return e[t] === void 0 ? "" : e[t];
1411
1532
  }
1412
- function $n(e, t) {
1533
+ function Vn(e, t) {
1413
1534
  if (t.edits.length > 1e4) throw new M("limit");
1414
- const r = D(e), n = /* @__PURE__ */ new Set(), o = [], a = t.edits.map((s) => {
1535
+ const r = W(e), n = /* @__PURE__ */ new Set(), o = [], a = t.edits.map((s) => {
1415
1536
  const i = r(s.address);
1416
1537
  if (!i?.source) throw new M("missing");
1417
- const c = F(s);
1538
+ const c = O(s);
1418
1539
  if (n.has(c)) throw new M("duplicate");
1419
- if (n.add(c), Ie(i, s) || !Object.is(i.value, s.previousValue) || (i.cell.text ?? "") !== s.previousText) throw new M("conflict");
1420
- return o.push(i), U(i, s.value);
1540
+ if (n.add(c), je(i, s) || !Object.is(i.value, s.previousValue) || (i.cell.text ?? "") !== s.previousText) throw new M("conflict");
1541
+ return o.push(i), te(i, s.value);
1421
1542
  });
1422
1543
  return { batch: { requestId: t.requestId, edits: a }, contexts: o };
1423
1544
  }
1424
- function Fn(e, t) {
1425
- const r = xt(e);
1545
+ function zn(e, t) {
1546
+ const r = Ct(e);
1426
1547
  return t.flatMap((n) => {
1427
1548
  if (!n.source) throw new M("missing");
1428
1549
  return r(n.source).map((o) => {
1429
- if (!Object.is(It(o.row, n.source.field), n.previousValue)) throw new M("conflict");
1550
+ if (!Object.is(At(o.row, n.source.field), n.previousValue)) throw new M("conflict");
1430
1551
  if (o.binding.rowKey === n.source.field) throw new M("readonly");
1431
1552
  return { row: o, field: n.source.field, value: n.value };
1432
1553
  });
1433
1554
  });
1434
1555
  }
1435
- function de(e, t, r) {
1556
+ function he(e, t, r) {
1436
1557
  const n = { ...e, value: t, source: { ...e.source, ...r?.revision === void 0 ? {} : { revision: r.revision }, ...r?.sourceToken === void 0 ? {} : { sourceToken: r.sourceToken } } };
1437
- return n.cell = { ...e.cell, value: n.value, text: q(n, n.value) }, n;
1558
+ return n.cell = { ...e.cell, value: n.value, text: ee(n, n.value) }, n;
1438
1559
  }
1439
- function On(e, t, r) {
1560
+ function Jn(e, t, r) {
1440
1561
  if (!r || r.revision === void 0 && r.sourceToken === void 0) return [...e];
1441
- const n = new Set(t.edits.flatMap((o) => o.source ? [B(o.source)] : []));
1442
- return Ct(e, Sn(e, n, r));
1562
+ const n = new Set(t.edits.flatMap((o) => o.source ? [V(o.source)] : []));
1563
+ return Tt(e, kn(e, n, r));
1443
1564
  }
1444
- function An(e, t, r) {
1445
- const n = new Set(t.edits.map((o) => B(o.source)));
1565
+ function _n(e, t, r) {
1566
+ const n = new Set(t.edits.map((o) => V(o.source)));
1446
1567
  for (const o of n) e.set(o, {
1447
1568
  ...e.get(o),
1448
1569
  ...r.revision !== void 0 ? { revision: r.revision } : {},
@@ -1450,74 +1571,80 @@ function An(e, t, r) {
1450
1571
  });
1451
1572
  return n;
1452
1573
  }
1453
- function $t(e, t) {
1454
- let r = t.parts;
1455
- const n = t.rebuild, o = [...t.validationFormulas ?? []];
1456
- let a = Pn(r), s = e, i;
1457
- const c = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map();
1458
- function u(h) {
1459
- if (h !== s) throw new M("conflict");
1460
- if (i) return i;
1461
- if (!a?.()) throw new M("conflict");
1462
- return Rn(r);
1463
- }
1464
- async function f(h, m, v, p = {}) {
1465
- X(p.signal), m = { requestId: m.requestId, edits: m.edits.map((b) => ({ ...b, address: { ...b.address }, source: b.source ? { ...b.source } : void 0, table: b.table ? { ...b.table } : void 0 })) }, v = v.map((b) => ({ ...b, address: { ...b.address }, source: b.source ? { ...b.source } : void 0, table: b.table ? { ...b.table } : void 0, cell: { ...b.cell } })), await new Promise((b) => setTimeout(b, 0)), X(p.signal);
1466
- const w = u(h), y = Ct(w, Fn(w, m.edits)), x = kt(await n(y, p.signal), l);
1467
- X(p.signal);
1468
- let k = !1, T = [], O = "allow", A = !1;
1469
- function g(b) {
1470
- return A = !0, T = Object.freeze(cn(y, b, p.signal, o).map((S) => Object.freeze({ ...S }))), A = !1, O = b.warningPolicy ?? "allow", T;
1574
+ function Ao(e, t) {
1575
+ return De(e, t);
1576
+ }
1577
+ function De(e, t, r) {
1578
+ let n = t.parts;
1579
+ const o = t.rebuild, a = [...t.validationFormulas ?? []], s = r ? Wn(e, n, r) : void 0;
1580
+ let i = In(n), c = e, l;
1581
+ const u = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map();
1582
+ function d(b) {
1583
+ if (b !== c) throw new M("conflict");
1584
+ if (l) return l;
1585
+ if (!i?.()) throw new M("conflict");
1586
+ return On(n);
1587
+ }
1588
+ async function m(b, w, y, g = {}) {
1589
+ J(g.signal), w = { requestId: w.requestId, edits: w.edits.map((v) => ({ ...v, address: { ...v.address }, source: v.source ? { ...v.source } : void 0, table: v.table ? { ...v.table } : void 0 })) }, y = y.map((v) => ({ ...v, address: { ...v.address }, source: v.source ? { ...v.source } : void 0, table: v.table ? { ...v.table } : void 0, cell: { ...v.cell } })), await new Promise((v) => setTimeout(v, 0)), J(g.signal);
1590
+ const S = d(b), C = Tt(S, zn(S, w.edits)), T = await s?.candidate(b, w.edits, g.signal);
1591
+ J(g.signal);
1592
+ const $ = Et(T?.plan ?? await o(C, g.signal), f);
1593
+ J(g.signal);
1594
+ let N = !1, p = [], P = "allow", x = !1;
1595
+ function R(v) {
1596
+ return x = !0, p = Object.freeze(dn(C, v, g.signal, a).map((E) => Object.freeze({ ...E }))), x = !1, P = v.warningPolicy ?? "allow", p;
1471
1597
  }
1472
- return p.validation && g(p.validation), { plan: x, get validationIssues() {
1473
- return T;
1474
- }, validate: g, commit(b) {
1475
- if (X(p.signal), k || s !== h) throw new M("conflict");
1476
- if (b?.conflicts?.length) throw new M("conflict");
1477
- if (A) throw new Error("候选规则校验未完成,不能提交");
1478
- sn(T, O);
1479
- const S = On(y, m, b), E = xn(x, m, b);
1480
- if (b) {
1481
- const P = An(l, m, b);
1482
- for (const [R, L] of c) P.has(B(L.source)) && c.set(R, de(L, L.value, b));
1598
+ return g.validation && R(g.validation), { plan: $, get validationIssues() {
1599
+ return p;
1600
+ }, validate: R, commit(v) {
1601
+ if (J(g.signal), N || c !== b) throw new M("conflict");
1602
+ if (T && !T.unchanged()) throw new M("conflict");
1603
+ if (v?.conflicts?.length) throw new M("conflict");
1604
+ if (x) throw new Error("候选规则校验未完成,不能提交");
1605
+ ln(p, P);
1606
+ const E = Jn(C, w, v), A = Cn($, w, v);
1607
+ if (v) {
1608
+ const K = _n(f, w, v);
1609
+ for (const [z, L] of u) K.has(V(L.source)) && u.set(z, he(L, L.value, v));
1483
1610
  }
1484
- return v.forEach((P, R) => c.set(F(P), de(P, m.edits[R].value, b))), k = !0, i = S, r = void 0, a = void 0, s = E, he.set(s, d), s;
1611
+ return y.forEach((K, z) => u.set(O(K), he(K, w.edits[z].value, v))), N = !0, l = E, n = void 0, i = void 0, c = A, s?.publish(c), be.set(c, h), c;
1485
1612
  } };
1486
1613
  }
1487
- const d = {
1614
+ const h = {
1488
1615
  get plan() {
1489
- return s;
1616
+ return c;
1490
1617
  },
1491
- async prepare(h, m, v) {
1492
- const p = $n(h, m);
1493
- return f(h, p.batch, p.contexts, v);
1618
+ async prepare(b, w, y) {
1619
+ const g = Vn(b, w);
1620
+ return m(b, g.batch, g.contexts, y);
1494
1621
  },
1495
- async prepareHistory(h, m, v, p, w) {
1496
- if (!p.trim() || m.length > 1e4) throw new M("limit");
1497
- const y = u(h), x = xt(y), k = Tt(h), T = /* @__PURE__ */ new Set(), A = m.map((S) => {
1498
- if (!S.source) throw new M("missing");
1499
- const E = F(S);
1500
- if (T.has(E)) throw new M("duplicate");
1501
- T.add(E);
1502
- const P = k.get(E) ?? c.get(E);
1503
- if (!P?.source) throw new M("missing");
1504
- const R = x(P.source)[0];
1505
- return de(P, It(R.row, P.source.field));
1506
- }).map((S, E) => ({ context: S, edit: U(S, m[E][v]) })).filter(({ edit: S }) => !Object.is(S.previousValue, S.value)), g = { requestId: p, edits: A.map(({ edit: S }) => S) }, b = A.map(({ context: S }) => S);
1507
- return { batch: g, contexts: b, prepared: await f(h, g, b, w) };
1622
+ async prepareHistory(b, w, y, g, S) {
1623
+ if (!g.trim() || w.length > 1e4) throw new M("limit");
1624
+ const C = d(b), T = Ct(C), $ = Rt(b), N = /* @__PURE__ */ new Set(), P = w.map((v) => {
1625
+ if (!v.source) throw new M("missing");
1626
+ const E = O(v);
1627
+ if (N.has(E)) throw new M("duplicate");
1628
+ N.add(E);
1629
+ const A = $.get(E) ?? u.get(E);
1630
+ if (!A?.source) throw new M("missing");
1631
+ const K = T(A.source)[0];
1632
+ return he(A, At(K.row, A.source.field));
1633
+ }).map((v, E) => ({ context: v, edit: te(v, w[E][y]) })).filter(({ edit: v }) => !Object.is(v.previousValue, v.value)), x = { requestId: g, edits: P.map(({ edit: v }) => v) }, R = P.map(({ context: v }) => v);
1634
+ return { batch: x, contexts: R, prepared: await m(b, x, R, S) };
1508
1635
  }
1509
1636
  };
1510
- return he.set(e, d), d;
1637
+ return be.set(e, h), h;
1511
1638
  }
1512
- function Mo(e) {
1513
- const t = ft(e.template, e.datasets, e.pagination).plan;
1514
- return $t(t, { validationFormulas: [e.pagination?.formula], parts: [{ template: e.template, datasets: e.datasets }], rebuild: (r, n) => In(r[0].template, r[0].datasets, { ...e.pagination, signal: n }) });
1639
+ function Ko(e) {
1640
+ const t = pt(e.template, e.datasets, e.pagination).plan;
1641
+ return De(t, { validationFormulas: [e.pagination?.formula], parts: [{ template: e.template, datasets: e.datasets }], rebuild: (r, n) => An(r[0].template, r[0].datasets, { ...e.pagination, signal: n }) }, [e.pagination]);
1515
1642
  }
1516
- let Kn = 0;
1517
- function jn() {
1518
- return `report-${Date.now()}-${++Kn}`;
1643
+ let qn = 0;
1644
+ function Un() {
1645
+ return `report-${Date.now()}-${++qn}`;
1519
1646
  }
1520
- function Ge(e, t, r) {
1647
+ function Ue(e, t, r) {
1521
1648
  if (!r?.aborted)
1522
1649
  try {
1523
1650
  const n = e?.({ ...t });
@@ -1526,14 +1653,14 @@ function Ge(e, t, r) {
1526
1653
  } catch {
1527
1654
  }
1528
1655
  }
1529
- function Nn(e) {
1530
- const t = e.taskId ?? jn(), r = (n, o, a) => {
1531
- Ge(e.onEvent, { taskId: t, ...e.correlationId === void 0 ? {} : { correlationId: e.correlationId }, stage: n, status: o, ...a === void 0 ? {} : { reportId: a } }, e.signal);
1656
+ function Xn(e) {
1657
+ const t = e.taskId ?? Un(), r = (n, o, a) => {
1658
+ Ue(e.onEvent, { taskId: t, ...e.correlationId === void 0 ? {} : { correlationId: e.correlationId }, stage: n, status: o, ...a === void 0 ? {} : { reportId: a } }, e.signal);
1532
1659
  };
1533
1660
  return {
1534
1661
  taskId: t,
1535
1662
  progress(n, o, a) {
1536
- Ge(e.onEvent, { taskId: t, ...e.correlationId === void 0 ? {} : { correlationId: e.correlationId }, stage: n, status: "started", completed: o, total: a }, e.signal);
1663
+ Ue(e.onEvent, { taskId: t, ...e.correlationId === void 0 ? {} : { correlationId: e.correlationId }, stage: n, status: "started", completed: o, total: a }, e.signal);
1537
1664
  },
1538
1665
  async run(n, o, a) {
1539
1666
  r(n, "started", a);
@@ -1555,25 +1682,25 @@ function Nn(e) {
1555
1682
  }
1556
1683
  };
1557
1684
  }
1558
- function Ft(e) {
1685
+ function Kt(e) {
1559
1686
  if (!e || typeof e != "object" || Array.isArray(e)) return !1;
1560
1687
  const t = e, r = (n) => typeof n == "string" && n.trim().length > 0 && n.length <= 256;
1561
1688
  return !r(t.datasetId) || !r(t.field) || t.tableId !== void 0 && !r(t.tableId) || t.reportScope !== void 0 && (typeof t.reportScope != "string" || !t.reportScope.trim() || t.reportScope.length > 4096) ? !1 : t.rowKey === void 0 ? !0 : typeof t.rowKey == "string" ? t.rowKey.trim().length > 0 && t.rowKey.length <= 1024 : typeof t.rowKey == "number" && Number.isFinite(t.rowKey);
1562
1689
  }
1563
- function Ln(e) {
1690
+ function Yn(e) {
1564
1691
  return e === "missing-source" || e === "not-applicable" || e === "not-calculable";
1565
1692
  }
1566
- function Hn(e) {
1567
- return e.target !== void 0 && !Ft(e.target) ? !1 : e.valueState === void 0 || Ln(e.valueState) && e.target !== void 0;
1693
+ function Qn(e) {
1694
+ return e.target !== void 0 && !Kt(e.target) ? !1 : e.valueState === void 0 || Yn(e.valueState) && e.target !== void 0;
1568
1695
  }
1569
- function So(e, t) {
1570
- if (Ze([], e), !Ft(t)) throw new Error("数据说明目标无效");
1696
+ function No(e, t) {
1697
+ if (nt([], e), !Kt(t)) throw new Error("数据说明目标无效");
1571
1698
  const r = e.fields.find((o) => o.field === t.field);
1572
1699
  if (!r) throw new Error("数据说明字段未在契约中声明");
1573
1700
  const n = [];
1574
1701
  return r.description && n.push({ code: "field-definition", severity: "info", message: r.description, target: { ...t } }), r.calculation && n.push({ code: "field-calculation", severity: "info", message: r.calculation.description, target: { ...t } }), n;
1575
1702
  }
1576
- function Ot(e, t, r = {}) {
1703
+ function Nt(e, t, r = {}) {
1577
1704
  const n = /* @__PURE__ */ new Map();
1578
1705
  for (const a of e.pages) for (const s of a.components) {
1579
1706
  if (s.kind !== "list" || s.tree?.input !== "nested") continue;
@@ -1585,26 +1712,26 @@ function Ot(e, t, r = {}) {
1585
1712
  const o = { ...t };
1586
1713
  for (const [a, s] of n) {
1587
1714
  const i = Math.min(s.maxRows ?? 1e5, r.maxRows ?? 1 / 0);
1588
- o[a] = Xe(t[a] ?? [], { ...s, maxRows: i }, r.signal);
1715
+ o[a] = tt(t[a] ?? [], { ...s, maxRows: i }, r.signal);
1589
1716
  }
1590
1717
  return o;
1591
1718
  }
1592
- function xo(e, t, r = {}) {
1593
- return Object.values(Ot(e, t, r)).reduce((n, o) => n + o.length, 0);
1719
+ function jo(e, t, r = {}) {
1720
+ return Object.values(Nt(e, t, r)).reduce((n, o) => n + o.length, 0);
1594
1721
  }
1595
- function Co(e, t, r) {
1596
- const n = ur(r), o = e?.pages.flatMap((i) => i.components).find((i) => i.kind === "list" && i.dataset === t && i.tree?.input === "nested");
1722
+ function Lo(e, t, r) {
1723
+ const n = mr(r), o = e?.pages.flatMap((i) => i.components).find((i) => i.kind === "list" && i.dataset === t && i.tree?.input === "nested");
1597
1724
  if (!o || o.kind !== "list" || !o.tree) return n;
1598
1725
  const a = n.items, s = o.tree.childrenField ?? "children";
1599
1726
  return { ...n, items: { $ref: "#/$defs/treeNode" }, $defs: { treeNode: { ...a, properties: { ...a.properties, [s]: { anyOf: [{ type: "null" }, { type: "array", items: { $ref: "#/$defs/treeNode" } }] } } } } };
1600
1727
  }
1601
- function At(e, t) {
1728
+ function jt(e, t) {
1602
1729
  return JSON.stringify([e, t]);
1603
1730
  }
1604
- function Kt(e, t, r) {
1605
- return r === void 0 ? At(e, t) : JSON.stringify(["shared", r]);
1731
+ function Lt(e, t, r) {
1732
+ return r === void 0 ? jt(e, t) : JSON.stringify(["shared", r]);
1606
1733
  }
1607
- function jt(e, t, r) {
1734
+ function Ht(e, t, r) {
1608
1735
  return e.map((n) => {
1609
1736
  const o = n.table ? {
1610
1737
  ...n.table,
@@ -1613,7 +1740,7 @@ function jt(e, t, r) {
1613
1740
  } : void 0, a = n.grid?.cells.map((s) => s.map((i) => !i || !i.source && !i.children ? i : {
1614
1741
  ...i,
1615
1742
  ...i.source ? { source: { ...i.source, sourceScope: t } } : {},
1616
- ...i.children ? { children: jt(i.children, t, r) } : {}
1743
+ ...i.children ? { children: Ht(i.children, t, r) } : {}
1617
1744
  }));
1618
1745
  return o || a ? {
1619
1746
  ...n,
@@ -1622,46 +1749,46 @@ function jt(e, t, r) {
1622
1749
  } : n;
1623
1750
  });
1624
1751
  }
1625
- function ge(e) {
1626
- return Se(e.maxChartComponents), { maxPages: e.maxPages, maxCells: e.maxCells, maxChartComponents: e.maxChartComponents ?? Qt, usedPages: 0, usedCells: 0, usedChartComponents: 0 };
1752
+ function ve(e) {
1753
+ return Ee(e.maxChartComponents), { maxPages: e.maxPages, maxCells: e.maxCells, maxChartComponents: e.maxChartComponents ?? er, usedPages: 0, usedCells: 0, usedChartComponents: 0 };
1627
1754
  }
1628
- function Dn(e, t) {
1755
+ function Zn(e, t) {
1629
1756
  if (!e.repeat) return !1;
1630
1757
  const r = Object.prototype.hasOwnProperty.call(t, e.repeat.dataset) ? t[e.repeat.dataset] : void 0;
1631
1758
  return Array.isArray(r) && r.length === 0;
1632
1759
  }
1633
- function Bn(e) {
1760
+ function eo(e) {
1634
1761
  const t = (r) => r.grid?.cells.reduce((n, o) => n + o.reduce((a, s) => a + (s ? 1 + (s.children?.reduce((i, c) => i + t(c), 0) ?? 0) : 0), 0), 0) ?? 0;
1635
1762
  return e.pages.reduce((r, n) => r + n.components.reduce((o, a) => o + t(a), 0), 0);
1636
1763
  }
1637
- function pe(e, t) {
1764
+ function Me(e, t) {
1638
1765
  return e === void 0 ? void 0 : e - t;
1639
1766
  }
1640
- function ue(e, t) {
1767
+ function ge(e, t) {
1641
1768
  return e === void 0 ? t : Math.max(1, Math.min(e, t ?? e));
1642
1769
  }
1643
- function Nt(e, t, r, n, o) {
1644
- Se(e?.maxChartComponents);
1645
- const a = pe(t.maxPages, t.usedPages), s = t.maxChartComponents - t.usedChartComponents;
1646
- if (a !== void 0 && a < 1 && r.pages.length && !Dn(r, n)) throw new W(0, 1);
1647
- if (s < 1 && r.pages.some((i) => i.components.some((c) => c.kind !== "list" && c.chartBinding))) throw new fe(s, 1);
1770
+ function Dt(e, t, r, n, o) {
1771
+ Ee(e?.maxChartComponents);
1772
+ const a = Me(t.maxPages, t.usedPages), s = t.maxChartComponents - t.usedChartComponents;
1773
+ if (a !== void 0 && a < 1 && r.pages.length && !Zn(r, n)) throw new U(0, 1);
1774
+ if (s < 1 && r.pages.some((i) => i.components.some((c) => c.kind !== "list" && c.chartBinding))) throw new pe(s, 1);
1648
1775
  return {
1649
1776
  ...e,
1650
1777
  signal: o ?? e?.signal,
1651
- maxPages: ue(a, e?.maxPages),
1652
- maxCells: ue(pe(t.maxCells, t.usedCells), e?.maxCells),
1653
- maxChartComponents: ue(s, e?.maxChartComponents)
1778
+ maxPages: ge(a, e?.maxPages),
1779
+ maxCells: ge(Me(t.maxCells, t.usedCells), e?.maxCells),
1780
+ maxChartComponents: ge(s, e?.maxChartComponents)
1654
1781
  };
1655
1782
  }
1656
- function Lt(e, t) {
1657
- const r = Bn(t.plan), n = pe(e.maxCells, e.usedCells);
1658
- if (n !== void 0 && r > n) throw new Y(n, r);
1783
+ function Bt(e, t) {
1784
+ const r = eo(t.plan), n = Me(e.maxCells, e.usedCells);
1785
+ if (n !== void 0 && r > n) throw new ne(n, r);
1659
1786
  e.usedPages += t.plan.pages.length, e.usedCells += r, e.usedChartComponents += t.chartComponents;
1660
1787
  }
1661
- function Ht(e, t) {
1662
- return e instanceof W && t.maxPages !== void 0 && (e.limit === t.maxPages - t.usedPages || e.limit === 0) ? new W(t.maxPages, t.usedPages + e.actual) : e instanceof Y && t.maxCells !== void 0 ? new Y(t.maxCells, t.usedCells + e.actual) : e instanceof fe && e.limit === t.maxChartComponents - t.usedChartComponents ? new fe(t.maxChartComponents, t.usedChartComponents + e.estimated) : e;
1788
+ function Gt(e, t) {
1789
+ return e instanceof U && t.maxPages !== void 0 && (e.limit === t.maxPages - t.usedPages || e.limit === 0) ? new U(t.maxPages, t.usedPages + e.actual) : e instanceof ne && t.maxCells !== void 0 ? new ne(t.maxCells, t.usedCells + e.actual) : e instanceof pe && e.limit === t.maxChartComponents - t.usedChartComponents ? new pe(t.maxChartComponents, t.usedChartComponents + e.estimated) : e;
1663
1790
  }
1664
- function ko(e) {
1791
+ function Ho(e) {
1665
1792
  if (!("mapData" in e)) return e;
1666
1793
  const { load: t, mapData: r, ...n } = e;
1667
1794
  return { ...n, load: async (o) => {
@@ -1670,26 +1797,26 @@ function ko(e) {
1670
1797
  try {
1671
1798
  return r(a, o);
1672
1799
  } catch (s) {
1673
- throw new C("validate", `报表 ${o.reportId} 数据映射失败`, s);
1800
+ throw new k("validate", `报表 ${o.reportId} 数据映射失败`, s);
1674
1801
  }
1675
1802
  } };
1676
1803
  }
1677
- class C extends Error {
1804
+ class k extends Error {
1678
1805
  constructor(t, r, n) {
1679
1806
  super(r), this.name = "ReportSourceError", this.code = t, this.cause = n;
1680
1807
  }
1681
1808
  }
1682
- function ce(e) {
1809
+ function me(e) {
1683
1810
  const t = new Error("报表加载已取消");
1684
1811
  return t.name = "AbortError", Object.defineProperty(t, "cause", { value: e.reason }), t;
1685
1812
  }
1686
1813
  function I(e) {
1687
- if (e?.aborted) throw ce(e);
1814
+ if (e?.aborted) throw me(e);
1688
1815
  }
1689
- function we(e, t) {
1816
+ function Se(e, t) {
1690
1817
  return t ? new Promise((r, n) => {
1691
1818
  const o = () => t.removeEventListener("abort", a), a = () => {
1692
- o(), n(ce(t));
1819
+ o(), n(me(t));
1693
1820
  };
1694
1821
  t.addEventListener("abort", a, { once: !0 }), t.aborted && a(), Promise.resolve(e).then(
1695
1822
  (s) => {
@@ -1701,174 +1828,174 @@ function we(e, t) {
1701
1828
  );
1702
1829
  }) : Promise.resolve(e);
1703
1830
  }
1704
- function Gn(e, t) {
1831
+ function to(e, t) {
1705
1832
  if (!e || typeof e != "object" || Array.isArray(e))
1706
- throw new C("validate", `报表 ${t} 的数据集应为对象`);
1833
+ throw new k("validate", `报表 ${t} 的数据集应为对象`);
1707
1834
  for (const [r, n] of Object.entries(e))
1708
1835
  if (!Array.isArray(n) || n.some((o) => !o || typeof o != "object" || Array.isArray(o)))
1709
- throw new C("validate", `报表 ${t} 的数据集 ${r} 应为对象数组`);
1836
+ throw new k("validate", `报表 ${t} 的数据集 ${r} 应为对象数组`);
1710
1837
  }
1711
- async function Wn(e, t, r) {
1838
+ async function ro(e, t, r) {
1712
1839
  const { reportId: n, signal: o } = t;
1713
1840
  try {
1714
- const a = await we(e(t), o);
1841
+ const a = await Se(e(t), o);
1715
1842
  I(o);
1716
- const s = sr(a);
1843
+ const s = cr(a);
1717
1844
  if (!s.ok)
1718
- throw new C("validate", `报表 ${n} 模板校验失败:${s.errors.slice(0, 3).map((i) => `${i.path}: ${i.message}`).join("; ")}`);
1845
+ throw new k("validate", `报表 ${n} 模板校验失败:${s.errors.slice(0, 3).map((i) => `${i.path}: ${i.message}`).join("; ")}`);
1719
1846
  return r.push(...s.warnings.map((i) => `${n}: ${i.path}: ${i.message}`)), a;
1720
1847
  } catch (a) {
1721
- throw o?.aborted ? ce(o) : a instanceof C ? a : a instanceof ir ? new C("validate", `报表 ${n} 模板校验失败:${a.message}`, a) : new C("fetch", `报表 ${n} 模板加载失败:${a instanceof Error ? a.message : String(a)}`, a);
1848
+ throw o?.aborted ? me(o) : a instanceof k ? a : a instanceof lr ? new k("validate", `报表 ${n} 模板校验失败:${a.message}`, a) : new k("fetch", `报表 ${n} 模板加载失败:${a instanceof Error ? a.message : String(a)}`, a);
1722
1849
  }
1723
1850
  }
1724
- async function Vn(e, t, r, n) {
1851
+ async function no(e, t, r, n) {
1725
1852
  const o = t.signal;
1726
1853
  let a;
1727
1854
  try {
1728
- if (e.load) a = await we(e.load(t), o);
1855
+ if (e.load) a = await Se(e.load(t), o);
1729
1856
  else if (e.provider) {
1730
- const s = await we(e.provider.query(t), o);
1731
- I(o), zn(s, r), a = s.datasets, n?.(r, s);
1857
+ const s = await Se(e.provider.query(t), o);
1858
+ I(o), oo(s, r), a = s.datasets, n?.(r, s);
1732
1859
  } else a = e.datasets ?? {};
1733
1860
  } catch (s) {
1734
- throw o?.aborted ? ce(o) : s instanceof C ? s : new C("fetch", `报表 ${r} 取数失败:${s instanceof Error ? s.message : String(s)}`, s);
1861
+ throw o?.aborted ? me(o) : s instanceof k ? s : new k("fetch", `报表 ${r} 取数失败:${s instanceof Error ? s.message : String(s)}`, s);
1735
1862
  }
1736
1863
  return I(o), a;
1737
1864
  }
1738
- function zn(e, t) {
1739
- if (!e || typeof e != "object" || Array.isArray(e)) throw new C("validate", `报表 ${t} Provider 应返回 datasets 结果对象`);
1865
+ function oo(e, t) {
1866
+ if (!e || typeof e != "object" || Array.isArray(e)) throw new k("validate", `报表 ${t} Provider 应返回 datasets 结果对象`);
1740
1867
  for (const r of ["revision", "sourceToken"])
1741
- if (e[r] !== void 0 && typeof e[r] != "string") throw new C("validate", `报表 ${t} Provider ${r} 应为字符串`);
1868
+ if (e[r] !== void 0 && typeof e[r] != "string") throw new k("validate", `报表 ${t} Provider ${r} 应为字符串`);
1742
1869
  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))))
1743
- throw new C("validate", `报表 ${t} Provider diagnostics 不符合结构化诊断契约`);
1744
- if (e.diagnostics?.some((r) => !Hn(r)))
1745
- throw new C("validate", `报表 ${t} Provider 数据说明缺少有效的字段身份或值状态`);
1870
+ throw new k("validate", `报表 ${t} Provider diagnostics 不符合结构化诊断契约`);
1871
+ if (e.diagnostics?.some((r) => !Qn(r)))
1872
+ throw new k("validate", `报表 ${t} Provider 数据说明缺少有效的字段身份或值状态`);
1746
1873
  }
1747
- function Jn(e, t, r, n, o) {
1874
+ function ao(e, t, r, n, o) {
1748
1875
  try {
1749
- t = Ot(n, t, { maxRows: e.dataValidation?.maxRows, signal: o });
1876
+ t = Nt(n, t, { maxRows: e.dataValidation?.maxRows, signal: o });
1750
1877
  } catch (a) {
1751
- throw new C("validate", `报表 ${r} 树形数据无效:${a instanceof Error ? a.message : String(a)}`, a);
1878
+ throw new k("validate", `报表 ${r} 树形数据无效:${a instanceof Error ? a.message : String(a)}`, a);
1752
1879
  }
1753
1880
  for (const [a, s] of Object.entries(e.dataSchema ?? {})) {
1754
1881
  let i;
1755
1882
  try {
1756
- i = Ze(Object.prototype.hasOwnProperty.call(t, a) ? t[a] : void 0, s, { ...e.dataValidation, path: `$.datasets.${a}` });
1883
+ i = nt(Object.prototype.hasOwnProperty.call(t, a) ? t[a] : void 0, s, { ...e.dataValidation, path: `$.datasets.${a}` });
1757
1884
  } catch (c) {
1758
- throw new C("config", `报表 ${r} 数据集 ${a} 字段契约配置无效`, c);
1885
+ throw new k("config", `报表 ${r} 数据集 ${a} 字段契约配置无效`, c);
1759
1886
  }
1760
- if (!i.ok) throw new C("validate", `报表 ${r} 数据集 ${a} 不符合字段契约:${i.issues[0]?.message}`, { issues: i.issues });
1887
+ if (!i.ok) throw new k("validate", `报表 ${r} 数据集 ${a} 不符合字段契约:${i.issues[0]?.message}`, { issues: i.issues });
1761
1888
  }
1762
1889
  }
1763
- async function _n(e, t, r, n, o) {
1890
+ async function so(e, t, r, n, o) {
1764
1891
  try {
1765
1892
  let a;
1766
1893
  try {
1767
- a = En(e);
1894
+ a = Fn(e);
1768
1895
  } catch {
1769
1896
  }
1770
- const s = a ?? e, i = Nt(t.pagination, n, s.template, s.datasets, o), c = a ? await mt(s.template, s.datasets, i) : ft(s.template, s.datasets, i);
1771
- return Lt(n, c), { result: c, part: s };
1897
+ const s = a ?? e, i = Dt(t.pagination, n, s.template, s.datasets, o), c = a ? await wt(s.template, s.datasets, i) : pt(s.template, s.datasets, i);
1898
+ return Bt(n, c), { result: c, part: s };
1772
1899
  } catch (a) {
1773
1900
  I(o);
1774
- const s = Ht(a, n);
1775
- throw new C("validate", `报表 ${r} 排版失败:${s instanceof Error ? s.message : String(s)}`, s);
1901
+ const s = Gt(a, n);
1902
+ throw new k("validate", `报表 ${r} 排版失败:${s instanceof Error ? s.message : String(s)}`, s);
1776
1903
  }
1777
1904
  }
1778
- function Dt(e, t, r, n, o) {
1905
+ function Wt(e, t, r, n, o) {
1779
1906
  const a = /* @__PURE__ */ new Map(), s = (i) => {
1780
1907
  let c = a.get(i);
1781
1908
  return c === void 0 && (c = JSON.stringify([r, n, i]), a.set(i, c)), c;
1782
1909
  };
1783
1910
  for (const i of t.pages) e.push({
1784
1911
  ...i,
1785
- meta: { ...i.meta, reportScope: At(r, n) },
1786
- components: jt(i.components, o ?? Kt(r, n), s)
1912
+ meta: { ...i.meta, reportScope: jt(r, n) },
1913
+ components: Ht(i.components, o ?? Lt(r, n), s)
1787
1914
  });
1788
1915
  }
1789
- async function qn(e, t, r, n, o) {
1790
- const a = [], s = ge(n);
1916
+ async function io(e, t, r, n, o) {
1917
+ const a = [], s = ve(n);
1791
1918
  for (const [l, u] of e.entries()) {
1792
1919
  I(o);
1793
1920
  try {
1794
- const f = await Rt(u.template, u.datasets, Nt(t[l]?.pagination, s, u.template, u.datasets, o));
1795
- Lt(s, f), Dt(a, f.plan, l, r[l], u.sourceScope);
1921
+ const f = await Ot(u.template, u.datasets, Dt(t[l]?.pagination, s, u.template, u.datasets, o));
1922
+ Bt(s, f), Wt(a, f.plan, l, r[l], u.sourceScope);
1796
1923
  } catch (f) {
1797
- throw Ht(f, s);
1924
+ throw Gt(f, s);
1798
1925
  }
1799
1926
  }
1800
- const i = { schemaVersion: be, ...e.some((l) => Ce(l.template)) ? { requiresRecalculation: !0 } : {}, pages: a }, c = Qe(i);
1801
- if (!c.ok) throw new C("validate", `重算渲染计划校验失败:${c.errors[0]?.message}`);
1927
+ const i = { schemaVersion: Pe, ...e.some((l) => $e(l.template)) ? { requiresRecalculation: !0 } : {}, pages: a }, c = Ie(i);
1928
+ if (!c.ok) throw new k("validate", `重算渲染计划校验失败:${c.errors[0]?.message}`);
1802
1929
  return i;
1803
1930
  }
1804
- function To(e, t = {}) {
1805
- if (t.maxPages !== void 0 && (!Number.isSafeInteger(t.maxPages) || t.maxPages < 1)) throw new C("config", "maxPages 应为正安全整数");
1806
- if (t.maxCells !== void 0 && (!Number.isSafeInteger(t.maxCells) || t.maxCells < 1)) throw new C("config", "maxCells 应为正安全整数");
1931
+ function Do(e, t = {}) {
1932
+ if (t.maxPages !== void 0 && (!Number.isSafeInteger(t.maxPages) || t.maxPages < 1)) throw new k("config", "maxPages 应为正安全整数");
1933
+ if (t.maxCells !== void 0 && (!Number.isSafeInteger(t.maxCells) || t.maxCells < 1)) throw new k("config", "maxCells 应为正安全整数");
1807
1934
  try {
1808
- ge(t);
1935
+ ve(t);
1809
1936
  } catch (o) {
1810
- throw new C("config", "maxChartComponents 应为 1..1000000 的安全整数", o);
1937
+ throw new k("config", "maxChartComponents 应为 1..1000000 的安全整数", o);
1811
1938
  }
1812
1939
  function r(o) {
1813
1940
  const a = Object.prototype.hasOwnProperty.call(e, o) ? e[o] : void 0;
1814
- if (!a) throw new C("config", `未注册报表 ${o}`);
1815
- if (a.sourceScope !== void 0 && (typeof a.sourceScope != "string" || !a.sourceScope.trim() || a.sourceScope.length > 512)) throw new C("config", "sourceScope 应为不超过 512 字符的非空字符串");
1941
+ if (!a) throw new k("config", `未注册报表 ${o}`);
1942
+ if (a.sourceScope !== void 0 && (typeof a.sourceScope != "string" || !a.sourceScope.trim() || a.sourceScope.length > 512)) throw new k("config", "sourceScope 应为不超过 512 字符的非空字符串");
1816
1943
  return a;
1817
1944
  }
1818
1945
  return Object.assign(async ({ reportIds: o, params: a, signal: s, onWarning: i, onQueryResult: c, ...l }) => {
1819
1946
  I(s);
1820
- const u = Nn({ ...l, signal: s }), f = [...o], d = { ...a };
1821
- if (f.length === 0) throw new C("config", "缺少报表 ID");
1822
- const h = f.map(r), m = u.runSync("validate", () => h.map((g) => Oe(
1823
- g.params ?? (typeof g.template == "function" ? [] : g.template.params) ?? [],
1947
+ const u = Xn({ ...l, signal: s }), f = [...o], d = { ...a };
1948
+ if (f.length === 0) throw new k("config", "缺少报表 ID");
1949
+ const m = f.map(r), h = u.runSync("validate", () => m.map((p) => Be(
1950
+ p.params ?? (typeof p.template == "function" ? [] : p.template.params) ?? [],
1824
1951
  d
1825
- ))), v = [], p = [], w = ge(t), y = [];
1826
- for (const [g, b] of h.entries()) {
1952
+ ))), b = [], w = [], y = ve(t), g = [];
1953
+ for (const [p, P] of m.entries()) {
1827
1954
  I(s);
1828
- const S = f[g], E = { reportId: S, params: m[g], signal: s }, P = typeof b.template == "function" ? await u.run("query", () => Wn(b.template, E, y), S) : b.template;
1829
- E.params = u.runSync("validate", () => Oe(b.params ?? P.params ?? [], E.params), S);
1830
- const R = await u.run("query", () => Vn(b, E, S, (le, Gt) => c?.(le, Gt, g)), S);
1955
+ const x = f[p], R = { reportId: x, params: h[p], signal: s }, v = typeof P.template == "function" ? await u.run("query", () => ro(P.template, R, g), x) : P.template;
1956
+ R.params = u.runSync("validate", () => Be(P.params ?? v.params ?? [], R.params), x);
1957
+ const E = await u.run("query", () => no(P, R, x, (L, Vt) => c?.(L, Vt, p)), x);
1831
1958
  u.runSync("validate", () => {
1832
- Gn(R, S), t.onDatasets?.(S, R, P), Jn(b, R, S, P, s);
1833
- }, S), I(s);
1834
- const L = Kt(g, S, b.sourceScope), { result: Fe, part: Bt } = await u.run("layout", () => _n({ template: P, datasets: R, sourceScope: L }, b, S, w, s), S);
1835
- p.push(Bt), Dt(v, Fe.plan, g, S, L), y.push(...Fe.warnings.map((le) => `${S}: ${le}`));
1959
+ to(E, x), t.onDatasets?.(x, E, v), ao(P, E, x, v, s);
1960
+ }, x), I(s);
1961
+ const A = Lt(p, x, P.sourceScope), { result: K, part: z } = await u.run("layout", () => so({ template: v, datasets: E, sourceScope: A }, P, x, y, s), x);
1962
+ w.push(z), Wt(b, K.plan, p, x, A), g.push(...K.warnings.map((L) => `${x}: ${L}`));
1836
1963
  }
1837
1964
  I(s);
1838
- const x = { schemaVersion: be, ...p.some((g) => Ce(g.template)) ? { requiresRecalculation: !0 } : {}, pages: v }, k = u.runSync("validate", () => {
1839
- const g = Qe(x);
1840
- if (!g.ok) throw new C("validate", `渲染计划校验失败:${g.errors.slice(0, 3).map((b) => `${b.path}: ${b.message}`).join("; ")}`);
1841
- return g;
1965
+ const S = { schemaVersion: Pe, ...w.some((p) => $e(p.template)) ? { requiresRecalculation: !0 } : {}, pages: b }, C = u.runSync("validate", () => {
1966
+ const p = Ie(S);
1967
+ if (!p.ok) throw new k("validate", `渲染计划校验失败:${p.errors.slice(0, 3).map((P) => `${P.path}: ${P.message}`).join("; ")}`);
1968
+ return p;
1842
1969
  });
1843
- y.push(...k.warnings.map((g) => `${g.path}: ${g.message}`));
1844
- const T = h.map((g) => ({ ...g, pagination: { ...g.pagination } })), O = { maxPages: t.maxPages, maxCells: t.maxCells, maxChartComponents: t.maxChartComponents };
1970
+ g.push(...C.warnings.map((p) => `${p.path}: ${p.message}`));
1971
+ const T = m.map((p) => ({ ...p, pagination: { ...p.pagination } })), $ = { maxPages: t.maxPages, maxCells: t.maxCells, maxChartComponents: t.maxChartComponents };
1845
1972
  try {
1846
- $t(x, { parts: p, validationFormulas: T.map((g) => g.pagination?.formula), rebuild: (g, b) => qn(g, T, f, O, b) });
1973
+ De(S, { parts: w, validationFormulas: T.map((p) => p.pagination?.formula), rebuild: (p, P) => io(p, T, f, $, P) }, T.map((p) => p.pagination));
1847
1974
  } catch {
1848
- y.push("来源数据无法建立本地重算口径;当前预览仅支持计划内编辑,请使用可序列化模板数据启用规则重算");
1975
+ g.push("来源数据无法建立本地重算口径;当前预览仅支持计划内编辑,请使用可序列化模板数据启用规则重算");
1849
1976
  }
1850
- const A = i ?? t.onWarning ?? ((g) => console.warn("[mach-report]", g));
1851
- for (const g of y)
1852
- I(s), A(g);
1853
- return I(s), x;
1977
+ const N = i ?? t.onWarning ?? ((p) => console.warn("[mach-report]", p));
1978
+ for (const p of g)
1979
+ I(s), N(p);
1980
+ return I(s), S;
1854
1981
  }, {
1855
- getParamDefs: (o) => cr(e, o)
1982
+ getParamDefs: (o) => dr(e, o)
1856
1983
  });
1857
1984
  }
1858
- const Un = /* @__PURE__ */ new Set([8, 9, 10, 12, 13]);
1859
- function Xn(e, t) {
1985
+ const co = /* @__PURE__ */ new Set([8, 9, 10, 12, 13]);
1986
+ function lo(e, t) {
1860
1987
  const r = Array.isArray(e), n = Object.getPrototypeOf(e);
1861
1988
  if (n !== (r ? Array.prototype : Object.prototype) && !(n === null && !r) || Object.getOwnPropertySymbols(e).length) throw t("input", "快照应为普通 JSON 对象");
1862
1989
  const o = Object.getOwnPropertyNames(e).filter((a) => !(r && a === "length"));
1863
1990
  if (r && (o.length !== e.length || o.some((a, s) => a !== String(s)))) throw t("input", "快照数组应为连续数组");
1864
1991
  return { array: r, keys: o };
1865
1992
  }
1866
- function Yn(e) {
1993
+ function uo(e) {
1867
1994
  if (/^[\u0020-\u007e]*$/.test(e) && !/["\\]/.test(e)) return e.length + 2;
1868
1995
  let t = 2;
1869
1996
  for (let r = 0; r < e.length; r++) {
1870
1997
  const n = e.charCodeAt(r);
1871
- if (n < 32) t += Un.has(n) ? 2 : 6;
1998
+ if (n < 32) t += co.has(n) ? 2 : 6;
1872
1999
  else if (n === 34 || n === 92) t += 2;
1873
2000
  else if (n < 128) t++;
1874
2001
  else if (n < 2048) t += 2;
@@ -1879,92 +2006,93 @@ function Yn(e) {
1879
2006
  }
1880
2007
  return t;
1881
2008
  }
1882
- function Po(e, t) {
2009
+ function Bo(e, t) {
1883
2010
  const r = t.maxNodes ?? 1e6;
1884
2011
  if (![t.maxBytes, r].every((d) => Number.isSafeInteger(d) && d > 0)) throw t.error("budget", "快照预算应为正安全整数");
1885
2012
  let n = 0, o = 0;
1886
2013
  const a = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Map();
1887
2014
  function i(d) {
1888
2015
  if (d.length + 2 > t.maxBytes - o) throw t.error("budget", "快照超过字节预算");
1889
- const h = s.get(d);
1890
- if (h !== void 0) return h;
1891
- const m = Yn(d);
1892
- return d.length <= 256 && s.size < 4096 && s.set(d, m), m;
2016
+ const m = s.get(d);
2017
+ if (m !== void 0) return m;
2018
+ const h = uo(d);
2019
+ return d.length <= 256 && s.size < 4096 && s.set(d, h), h;
1893
2020
  }
1894
2021
  function c(d) {
1895
2022
  if (o += d, o > t.maxBytes) throw t.error("budget", "快照超过字节预算");
1896
2023
  }
1897
- function l(d, h) {
1898
- if (++n > r || h > 64) throw t.error("budget", "快照节点或深度超过预算");
2024
+ function l(d, m) {
2025
+ if (++n > r || m > 64) throw t.error("budget", "快照节点或深度超过预算");
1899
2026
  if (n % 1024 === 0 && t.check?.(), typeof d == "string")
1900
2027
  return c(i(d)), d;
1901
2028
  if (d === null || typeof d == "boolean" || typeof d == "number" && Number.isFinite(d))
1902
2029
  return c(String(d).length), typeof d == "number" && Object.is(d, -0) ? 0 : d;
1903
2030
  if (!d || typeof d != "object" || a.has(d)) throw t.error("input", "快照应为无循环的有限 JSON 值");
1904
- return u(d, h);
2031
+ return u(d, m);
1905
2032
  }
1906
- function u(d, h) {
1907
- const { array: m, keys: v } = Xn(d, t.error);
2033
+ function u(d, m) {
2034
+ const { array: h, keys: b } = lo(d, t.error);
1908
2035
  a.add(d), c(2);
1909
- const p = m ? [] : {};
1910
- let w = 0;
1911
- for (const y of v) {
1912
- const x = Object.getOwnPropertyDescriptor(d, y);
1913
- if (x.get || x.set || !x.enumerable || ["__proto__", "constructor", "prototype"].includes(y)) throw t.error("input", "快照不允许访问器或危险键");
1914
- if (x.value === void 0 && !m) continue;
1915
- c((w++ ? 1 : 0) + (m ? 0 : i(y) + 1));
1916
- const k = l(x.value === void 0 ? null : x.value, h + 1);
1917
- y in p ? Object.defineProperty(p, y, { value: k, enumerable: !0, configurable: !0, writable: !0 }) : p[y] = k;
2036
+ const w = h ? [] : {};
2037
+ let y = 0;
2038
+ for (const g of b) {
2039
+ const S = Object.getOwnPropertyDescriptor(d, g);
2040
+ if (S.get || S.set || !S.enumerable || ["__proto__", "constructor", "prototype"].includes(g)) throw t.error("input", "快照不允许访问器或危险键");
2041
+ if (S.value === void 0 && !h) continue;
2042
+ c((y++ ? 1 : 0) + (h ? 0 : i(g) + 1));
2043
+ const C = l(S.value === void 0 ? null : S.value, m + 1);
2044
+ g in w ? Object.defineProperty(w, g, { value: C, enumerable: !0, configurable: !0, writable: !0 }) : w[g] = C;
1918
2045
  }
1919
- return a.delete(d), p;
2046
+ return a.delete(d), w;
1920
2047
  }
1921
2048
  t.check?.();
1922
2049
  const f = l(e, 0);
1923
2050
  return t.check?.(), f;
1924
2051
  }
1925
2052
  export {
1926
- br as A,
1927
- $t as B,
1928
- bo as C,
2053
+ Mr as A,
2054
+ Ao as B,
2055
+ Fo as C,
1929
2056
  Cr as D,
1930
- F as E,
1931
- yo as F,
1932
- mo as G,
1933
- Ge as H,
1934
- Ot as I,
1935
- xo as J,
1936
- Kt as K,
1937
- Ie as L,
1938
- U as M,
1939
- Nn as N,
1940
- Co as O,
1941
- jn as P,
1942
- At as Q,
1943
- C as R,
2057
+ O as E,
2058
+ $o as F,
2059
+ Co as G,
2060
+ Ue as H,
2061
+ Nt as I,
2062
+ jo as J,
2063
+ pn as K,
2064
+ Lt as L,
2065
+ jt as M,
2066
+ Un as N,
2067
+ je as O,
2068
+ te as P,
2069
+ Xn as Q,
2070
+ k as R,
2071
+ Lo as S,
1944
2072
  M as a,
1945
- tn as b,
1946
- go as c,
1947
- ko as d,
1948
- wo as e,
1949
- xn as f,
1950
- kt as g,
1951
- sn as h,
1952
- lo as i,
1953
- ho as j,
1954
- po as k,
1955
- D as l,
1956
- Mo as m,
1957
- To as n,
1958
- fo as o,
1959
- vt as p,
1960
- So as q,
1961
- q as r,
1962
- Po as s,
1963
- Re as t,
1964
- vo as u,
1965
- Hn as v,
1966
- Ft as w,
1967
- Ln as x,
1968
- ft as y,
1969
- uo as z
2073
+ nn as b,
2074
+ Eo as c,
2075
+ Ho as d,
2076
+ Io as e,
2077
+ Cn as f,
2078
+ Et as g,
2079
+ ln as h,
2080
+ xo as i,
2081
+ To as j,
2082
+ Ro as k,
2083
+ W as l,
2084
+ Ko as m,
2085
+ Do as n,
2086
+ ko as o,
2087
+ xt as p,
2088
+ No as q,
2089
+ ee as r,
2090
+ Bo as s,
2091
+ Ne as t,
2092
+ Oo as u,
2093
+ Qn as v,
2094
+ Kt as w,
2095
+ Yn as x,
2096
+ pt as y,
2097
+ Po as z
1970
2098
  };