@agile-team/mach-report 2.15.0 → 2.17.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 (171) hide show
  1. package/README.md +21 -12
  2. package/dist/{ExcelBindingWizard-Bs43BGNp.cjs → ExcelBindingWizard-Bq6FYME6.cjs} +1 -1
  3. package/dist/{ExcelBindingWizard-BKH1nGNS.js → ExcelBindingWizard-Co1svTsw.js} +3 -3
  4. package/dist/{ParamEditor-Da4akw6V.cjs → ParamEditor-B5UZRgxv.cjs} +1 -1
  5. package/dist/{ParamEditor-DoAhzJsm.js → ParamEditor-DNNARyeB.js} +1 -1
  6. package/dist/{ReportBatchPanel-wP9m9Pj1.cjs → ReportBatchPanel-Ctvs2t_9.cjs} +1 -1
  7. package/dist/{ReportBatchPanel-BMf6boMA.js → ReportBatchPanel-uQh06usx.js} +3 -3
  8. package/dist/ReportPreview-BdQawRh0.js +4879 -0
  9. package/dist/ReportPreview-CJC_-j2I.cjs +6 -0
  10. package/dist/{ReportTemplateLibrary-Sxr3eD0J.cjs → ReportTemplateLibrary-CnP7_1pH.cjs} +1 -1
  11. package/dist/{ReportTemplateLibrary-C9wutIiT.js → ReportTemplateLibrary-TIL_Oj2l.js} +1 -1
  12. package/dist/RuleEditor-DkRjOLlr.js +2141 -0
  13. package/dist/RuleEditor-h5anGsDB.cjs +1 -0
  14. package/dist/{TemplateOutlinePanel-JTSR53vJ.cjs → TemplateOutlinePanel-BlLxRrfu.cjs} +1 -1
  15. package/dist/{TemplateOutlinePanel-D6Bkny59.js → TemplateOutlinePanel-BouxsuqQ.js} +1 -1
  16. package/dist/{TemplateReusePanel-rVuK1kTz.js → TemplateReusePanel-BEACLPaN.js} +2 -2
  17. package/dist/{TemplateReusePanel-Kx35S0Ql.cjs → TemplateReusePanel-yxsHSO40.cjs} +1 -1
  18. package/dist/{TemplateReviewPanel-B0ar9_zf.js → TemplateReviewPanel-B1OGRY2i.js} +1 -1
  19. package/dist/{TemplateReviewPanel-Dn6X9UmY.cjs → TemplateReviewPanel-D9Cx0m2N.cjs} +1 -1
  20. package/dist/analytics.cjs +1 -1
  21. package/dist/analytics.d.cts +65 -1
  22. package/dist/analytics.d.ts +65 -1
  23. package/dist/analytics.js +4 -4
  24. package/dist/artifact-integrity.json +105 -101
  25. package/dist/assets-BIMVwjQe.js +231 -0
  26. package/dist/assets-Dfs2ElxI.cjs +1 -0
  27. package/dist/auto-BIOmtVhk.js +240 -0
  28. package/dist/auto-DDHflI9v.cjs +1 -0
  29. package/dist/{batch-BfZHN1do.js → batch-WzDIXJAt.js} +1 -1
  30. package/dist/{batch-CLpELXBl.cjs → batch-z6Aw5GEY.cjs} +1 -1
  31. package/dist/codes.d.cts +2 -0
  32. package/dist/codes.d.ts +2 -0
  33. package/dist/component-tree-Ca6YYfHq.js +61 -0
  34. package/dist/component-tree-DkGLEfZC.cjs +1 -0
  35. package/dist/computed-BW5a8QFk.js +612 -0
  36. package/dist/computed-C2GD3XcE.cjs +1 -0
  37. package/dist/config-Dg_o8e7m.cjs +1 -0
  38. package/dist/{config-BVsJXSqS.js → config-XQ4qrQ7Q.js} +66 -64
  39. package/dist/dataset-DL83majE.js +161 -0
  40. package/dist/dataset-IrlXbUvh.cjs +1 -0
  41. package/dist/designer-D9XAxqSc.js +5178 -0
  42. package/dist/designer-uCDo5XSK.cjs +2 -0
  43. package/dist/designer.cjs +1 -1
  44. package/dist/designer.d.cts +178 -3
  45. package/dist/designer.d.ts +178 -3
  46. package/dist/designer.js +1 -1
  47. package/dist/drill-ByN8COs_.cjs +1 -0
  48. package/dist/{drill-ByJviLXS.js → drill-CKW3Xtfa.js} +5 -5
  49. package/dist/encoding-BFMFIc4r.cjs +1 -0
  50. package/dist/encoding-DP_Eaf0A.js +21 -0
  51. package/dist/{font-loader-B_UkxpzC.cjs → font-loader-7FWVlykp.cjs} +1 -1
  52. package/dist/{font-loader-Q3bQjmrI.js → font-loader-CQZowp0I.js} +1 -1
  53. package/dist/index.cjs +8 -9
  54. package/dist/index.d.cts +175 -1
  55. package/dist/index.d.ts +175 -1
  56. package/dist/index.js +1343 -915
  57. package/dist/json-snapshot-D7PE1NsU.cjs +2 -0
  58. package/dist/json-snapshot-DYmEe3sO.js +1779 -0
  59. package/dist/matrix-JLAXlux-.js +302 -0
  60. package/dist/matrix-gTHpDTGm.cjs +1 -0
  61. package/dist/{pdf-CvvrjPQg.cjs → pdf-B8JouyYv.cjs} +48 -50
  62. package/dist/{pdf-BwNyeGpt.js → pdf-l3ea86di.js} +2734 -2748
  63. package/dist/pdf.cjs +1 -1
  64. package/dist/pdf.d.cts +14 -0
  65. package/dist/pdf.d.ts +14 -0
  66. package/dist/pdf.js +2 -2
  67. package/dist/{plugin-Ca_XZG3l.js → plugin-BBp74CQZ.js} +1 -1
  68. package/dist/{plugin-DHO7X8z2.cjs → plugin-CtFX9PFG.cjs} +1 -1
  69. package/dist/prepared-CARicKYh.js +87 -0
  70. package/dist/prepared-Ch1x_Gog.cjs +1 -0
  71. package/dist/progress-BXzlVbIp.js +29 -0
  72. package/dist/progress-DJBd9Rb9.cjs +1 -0
  73. package/dist/{progress-D-OTpEav.js → progress-Hc2vxoCs.js} +2 -2
  74. package/dist/protocol-B5A2uom4.cjs +1 -0
  75. package/dist/protocol-BaiWjq5w.js +90 -0
  76. package/dist/record-bindings-B86Sur_y.cjs +1 -0
  77. package/dist/{record-bindings-Do_b3h4V.js → record-bindings-D4TuMzHs.js} +10 -11
  78. package/dist/{region-binding-workflow-BMhK_TjP.js → region-binding-workflow-BNasF5kz.js} +2 -2
  79. package/dist/{region-binding-workflow-DIYJdCUr.cjs → region-binding-workflow-O2Cni3mF.cjs} +1 -1
  80. package/dist/report-encoding-worker.cjs +1 -0
  81. package/dist/report-encoding-worker.d.ts +1 -0
  82. package/dist/report-encoding-worker.js +2 -0
  83. package/dist/rich-text-layout-ALlMoYOG.cjs +3 -0
  84. package/dist/rich-text-layout-Ct5WrY1g.js +102 -0
  85. package/dist/runtime-DakRXui3.js +170 -0
  86. package/dist/runtime-dL5ygIfa.cjs +1 -0
  87. package/dist/sbom.cdx.json +2 -2
  88. package/dist/server/node.d.cts +132 -1
  89. package/dist/server/node.d.ts +132 -1
  90. package/dist/server-node.cjs +5 -1
  91. package/dist/server-node.js +5177 -463
  92. package/dist/server.cjs +1 -1
  93. package/dist/server.d.cts +182 -2
  94. package/dist/server.d.ts +182 -2
  95. package/dist/server.js +918 -833
  96. package/dist/sha256-BshdOkCC.cjs +1 -0
  97. package/dist/sha256-DTG-Gq8i.js +157 -0
  98. package/dist/style-67OqfNed.js +73 -0
  99. package/dist/style-C22Pbv3T.cjs +1 -0
  100. package/dist/style.css +1 -1
  101. package/dist/template-catalog-Dua8h9ZA.cjs +1 -0
  102. package/dist/{template-catalog-j2B1MJlL.js → template-catalog-wT1fNeAP.js} +10 -10
  103. package/dist/{template-fragments-DcKeiylI.cjs → template-fragments-BajTajb4.cjs} +1 -1
  104. package/dist/{template-fragments-BGbQLGlV.js → template-fragments-DmX5XK4N.js} +2 -2
  105. package/dist/template-registry-CpysHAxy.cjs +1 -0
  106. package/dist/{template-registry-BtaKPELV.js → template-registry-u11fPd8D.js} +389 -321
  107. package/dist/{textwrap-DE1kgcJB.js → textwrap-BEIg2w8y.js} +1 -1
  108. package/dist/textwrap-BI-yJ6Wt.cjs +4 -0
  109. package/dist/{tree-BX380Rr7.cjs → tree-CLpxYbKa.cjs} +1 -1
  110. package/dist/{tree-CjVZLRw7.js → tree-DNJorJUf.js} +1 -1
  111. package/dist/vue/async.d.cts +174 -2
  112. package/dist/vue/async.d.ts +174 -2
  113. package/dist/vue/index.d.cts +218 -3
  114. package/dist/vue/index.d.ts +218 -3
  115. package/dist/vue-async.cjs +1 -1
  116. package/dist/vue-async.js +3 -3
  117. package/dist/vue.cjs +1 -1
  118. package/dist/vue.js +7 -7
  119. package/dist/{workbook-session-BvToI-Fd.js → workbook-session-B8pNW24X.js} +153 -140
  120. package/dist/{workbook-session-Bjv1YCRK.cjs → workbook-session-DN5LSA5C.cjs} +12 -12
  121. package/dist/worker.cjs +1 -1
  122. package/dist/worker.d.cts +84 -1
  123. package/dist/worker.d.ts +84 -1
  124. package/dist/worker.js +12 -157
  125. package/dist/xlsx-node.cjs +33 -33
  126. package/dist/xlsx-node.js +1282 -1289
  127. package/dist/xlsx.cjs +4 -3
  128. package/dist/xlsx.d.cts +90 -2
  129. package/dist/xlsx.d.ts +90 -2
  130. package/dist/xlsx.js +279 -259
  131. package/package.json +6 -3
  132. package/dist/ReportPreview-ChV19HBp.js +0 -4619
  133. package/dist/ReportPreview-DbLvvOUT.cjs +0 -6
  134. package/dist/RuleEditor-C_Clasvd.js +0 -2037
  135. package/dist/RuleEditor-XhGHK8DE.cjs +0 -1
  136. package/dist/assets-B9ImAi6_.cjs +0 -1
  137. package/dist/assets-DEaz4qsp.js +0 -124
  138. package/dist/batch-BaP6pWDE.cjs +0 -1
  139. package/dist/batch-CGyt-b2W.js +0 -273
  140. package/dist/capabilities-CAh2Nrue.cjs +0 -1
  141. package/dist/capabilities-DskCHs3V.js +0 -69
  142. package/dist/computed-C-4C2S5h.js +0 -521
  143. package/dist/computed-CGV2a809.cjs +0 -1
  144. package/dist/config-D10us76d.cjs +0 -1
  145. package/dist/data-explanation-B8MZRYVS.js +0 -16
  146. package/dist/data-explanation-DE55G30w.cjs +0 -1
  147. package/dist/dataset-BkRmwgeJ.cjs +0 -1
  148. package/dist/dataset-H5pFuQGU.js +0 -121
  149. package/dist/defaults-DXhiM1ZD.js +0 -10
  150. package/dist/defaults-xhmcLLrf.cjs +0 -1
  151. package/dist/designer-2bDlcNXQ.js +0 -5136
  152. package/dist/designer-BT7XCdbW.cjs +0 -2
  153. package/dist/drill-DYTxuL3A.cjs +0 -1
  154. package/dist/grid-strokes-Cr7DwUux.cjs +0 -1
  155. package/dist/grid-strokes-DyyG1q_o.js +0 -53
  156. package/dist/json-snapshot-DFb2eWkf.js +0 -1416
  157. package/dist/json-snapshot-WWSGlaHG.cjs +0 -2
  158. package/dist/matrix-CGRGkn5s.js +0 -112
  159. package/dist/matrix-gEO7ZM_u.cjs +0 -1
  160. package/dist/prepared-CFy9B75C.cjs +0 -1
  161. package/dist/prepared-ajM-H-9B.js +0 -69
  162. package/dist/record-bindings-By_UKZ2g.cjs +0 -1
  163. package/dist/render-plan-7xpGrCEl.cjs +0 -1
  164. package/dist/render-plan-Ck6koX9L.js +0 -13
  165. package/dist/sha256-ArEYjaTI.cjs +0 -1
  166. package/dist/sha256-DPEuJ3nh.js +0 -155
  167. package/dist/style-CQ1PK8ZB.js +0 -67
  168. package/dist/style-UgIJSA1F.cjs +0 -1
  169. package/dist/template-catalog-FJE_c9Qe.cjs +0 -1
  170. package/dist/template-registry-Co1zPq5e.cjs +0 -1
  171. package/dist/textwrap-CWHyzkBH.cjs +0 -4
@@ -0,0 +1,302 @@
1
+ import { c as g } from "./computed-BW5a8QFk.js";
2
+ function x(e, r) {
3
+ const l = () => r.measures.map((i) => g(i)), t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), a = r.totals ? l() : void 0, s = (i, c) => i?.forEach((u) => u.add(c));
4
+ for (const i of e) {
5
+ const c = r.row(i), u = r.column(i);
6
+ n.has(u.key) || n.set(u.key, u.label);
7
+ let f = t.get(c.key);
8
+ f || (f = { label: c.label, cells: /* @__PURE__ */ new Map(), ...r.totals ? { totals: l() } : {} }, t.set(c.key, f)), r.check(t.size, n.size);
9
+ let d = f.cells.get(u.key);
10
+ if (d || (d = l(), f.cells.set(u.key, d)), s(d, i), !r.totals) continue;
11
+ let w = o.get(u.key);
12
+ w || (w = l(), o.set(u.key, w)), s(f.totals, i), s(w, i), s(a, i);
13
+ }
14
+ return { groups: t, columns: n, columnTotals: o, totals: a };
15
+ }
16
+ function h(e, r) {
17
+ return JSON.stringify([e.slice(0, r.length), r.map((l) => [l === null ? "null" : typeof l, l])]);
18
+ }
19
+ function M(e, r) {
20
+ return r.map((l) => {
21
+ const t = Object.prototype.hasOwnProperty.call(e, l) ? e[l] : null;
22
+ if (t == null) return null;
23
+ if (typeof t == "string" || typeof t == "boolean" || typeof t == "number" && Number.isFinite(t)) return t;
24
+ throw new Error("矩阵维度必须是有限 JSON 标量");
25
+ });
26
+ }
27
+ function C(e, r, l) {
28
+ if (!e || typeof e != "object" || Array.isArray(e)) throw new Error("矩阵层级应为对象");
29
+ for (const t of [e.emptyLabel, e.subtotalLabel, e.totalLabel]) if (t !== void 0 && typeof t != "string") throw new Error("矩阵层级标签应为字符串");
30
+ b(e.row, r.length), b(e.column, l.length);
31
+ }
32
+ function b(e, r) {
33
+ if (e !== void 0) {
34
+ if (!e || typeof e != "object" || Array.isArray(e)) throw new Error("矩阵轴配置应为对象");
35
+ if (e.labels !== void 0 && (!Array.isArray(e.labels) || e.labels.length !== r || e.labels.some((l) => typeof l != "string"))) throw new Error("矩阵维度标签必须与维度字段一一对应");
36
+ if (e.sort !== void 0 && (!Array.isArray(e.sort) || e.sort.length > r || e.sort.some((l) => !["source", "asc", "desc"].includes(l)))) throw new Error("矩阵维度排序应为 source、asc 或 desc");
37
+ if (e.subtotals !== void 0 && (!Array.isArray(e.subtotals) || new Set(e.subtotals).size !== e.subtotals.length || e.subtotals.some((l) => !Number.isInteger(l) || l < 1 || l >= r))) throw new Error("矩阵小计深度应唯一且位于 1 至末级之前");
38
+ }
39
+ }
40
+ function k(e, r, l) {
41
+ return { fields: e, options: r ?? {}, hierarchy: l, root: { values: [], children: /* @__PURE__ */ new Map() }, leaves: 0, expanded: 0 };
42
+ }
43
+ function F(e, r) {
44
+ const l = M(r, e.fields);
45
+ let t = e.root;
46
+ for (let n = 1; n <= l.length; n++) {
47
+ const o = l.slice(0, n), a = h(e.fields, o);
48
+ let s = t.children.get(a);
49
+ s || (s = { values: o, children: /* @__PURE__ */ new Map() }, t.children.set(a, s), n === l.length ? (e.leaves++, e.expanded++) : e.options.subtotals?.includes(n) && e.expanded++), t = s;
50
+ }
51
+ }
52
+ function N(e, r) {
53
+ if (e === r) return 0;
54
+ if (e === null) return -1;
55
+ if (r === null) return 1;
56
+ if (typeof e == "number" && typeof r == "number") return e - r;
57
+ const l = `${typeof e}:${e}`, t = `${typeof r}:${r}`;
58
+ return l < t ? -1 : 1;
59
+ }
60
+ function L(e, r) {
61
+ const l = [...e.children.values()];
62
+ return r && r !== "source" && l.sort((t, n) => N(t.values[t.values.length - 1], n.values[n.values.length - 1]) * (r === "desc" ? -1 : 1)), l;
63
+ }
64
+ function y(e, r, l) {
65
+ return {
66
+ key: h(e.fields, r),
67
+ kind: l,
68
+ depth: r.length,
69
+ fields: e.fields.slice(0, r.length),
70
+ values: r,
71
+ labels: r.map((t) => t === null ? e.hierarchy.emptyLabel ?? "(空)" : String(t))
72
+ };
73
+ }
74
+ function A(e, r) {
75
+ const l = [];
76
+ function t(n) {
77
+ for (const o of L(n, e.options.sort?.[n.values.length]))
78
+ o.children.size ? (t(o), e.options.subtotals?.includes(o.values.length) && l.push(y(e, o.values, "subtotal"))) : l.push(y(e, o.values, "member"));
79
+ }
80
+ return t(e.root), r && e.leaves && l.push(y(e, [], "total")), l;
81
+ }
82
+ function E(e, r, l) {
83
+ const t = M(r, e.fields), n = [h(e.fields, t), ...(e.options.subtotals ?? []).map((o) => h(e.fields, t.slice(0, o)))];
84
+ return l && n.push(h(e.fields, [])), n;
85
+ }
86
+ function R(e, r, l) {
87
+ if (!(e.kind !== "member" && r > e.depth))
88
+ return e.kind === "total" ? { key: "total", text: l.totalLabel ?? "合计", rowSpan: 0 } : e.kind === "subtotal" && r === e.depth ? { key: e.key, text: l.subtotalLabel ?? "小计", rowSpan: 0 } : { key: JSON.stringify(e.values.slice(0, r + 1).map((t) => [typeof t, t])), text: e.labels[r], rowSpan: 1 };
89
+ }
90
+ function z(e, r) {
91
+ const l = e.columnFields.length + 1, t = e.rowFields.length, n = Array.from({ length: l }, () => Array(t + r.length).fill(null));
92
+ for (let o = 0; o < e.columnFields.length; o++) {
93
+ let a;
94
+ r.forEach((s, i) => {
95
+ const c = R(s, o, e.hierarchy);
96
+ if (!c) {
97
+ a = void 0;
98
+ return;
99
+ }
100
+ if (a?.key === c.key) {
101
+ a.cell.colSpan = (a.cell.colSpan ?? 1) + 1;
102
+ return;
103
+ }
104
+ const u = { text: c.text, rowSpan: c.rowSpan || e.columnFields.length - o, editable: !1, derived: !0 };
105
+ n[o][t + i] = u, a = { key: c.key, cell: u };
106
+ });
107
+ }
108
+ return e.rowFields.forEach((o, a) => {
109
+ n[0][a] = { text: e.hierarchy.row?.labels?.[a] ?? o, rowSpan: l, editable: !1, derived: !0 };
110
+ }), r.forEach((o, a) => {
111
+ const s = e.measures[o.measure];
112
+ n[l - 1][t + a] = { text: s.label ?? `${s.field} (${s.op})`, editable: !1, derived: !0 };
113
+ }), {
114
+ cells: n.map((o) => o.filter((a) => a !== null)),
115
+ colWidthsMm: [...e.rowFields.map(() => e.rowWidthMm ?? 40), ...r.map(() => e.columnWidthMm ?? 28)]
116
+ };
117
+ }
118
+ function v(e, r, l, t) {
119
+ const n = +(!!r.totals && e > 0), o = l.expanded + n, a = (t.expanded + n) * r.measures.length + r.rowFields.length;
120
+ if (o > (r.maxRows ?? 1e3) || t.expanded + n > (r.maxColumns ?? 200)) throw new Error("矩阵层级展开数量超出预算(包含小计/总计)");
121
+ if (o * a > (r.maxCells ?? 2e6)) throw new Error("矩阵输出超出 maxCells 预算");
122
+ return { rowCount: o, columnCount: a, cells: o * a };
123
+ }
124
+ function $(e, r) {
125
+ if (!Array.isArray(e) || e.length > (r.maxInputRows ?? 1e5)) throw new Error("矩阵输入超出预算");
126
+ const l = k(r.rowFields, r.hierarchy.row, r.hierarchy), t = k(r.columnFields, r.hierarchy.column, r.hierarchy);
127
+ if (e.length * (1 + (l.options.subtotals?.length ?? 0) + +!!r.totals) * (1 + (t.options.subtotals?.length ?? 0) + +!!r.totals) * r.measures.length > (r.maxAggregateUpdates ?? 1e7)) throw new Error("矩阵聚合更新超出 maxAggregateUpdates 预算");
128
+ let o = v(0, r, l, t);
129
+ for (const a of e) {
130
+ if (!a || typeof a != "object" || Array.isArray(a)) throw new Error("矩阵数据行应为对象");
131
+ F(l, a), F(t, a), o = v(e.length, r, l, t);
132
+ }
133
+ return { row: l, column: t, shape: o };
134
+ }
135
+ function j(e, r) {
136
+ return $(e, r).shape;
137
+ }
138
+ function O(e, r, l) {
139
+ const t = /* @__PURE__ */ new Map();
140
+ for (const n of e) {
141
+ const o = E(l.row, n, !!r.totals), a = E(l.column, n, !!r.totals);
142
+ for (const s of o) {
143
+ let i = t.get(s);
144
+ i || (i = /* @__PURE__ */ new Map(), t.set(s, i));
145
+ for (const c of a) {
146
+ let u = i.get(c);
147
+ u || (u = r.measures.map((f) => g({ ...f, field: f.valueField ?? f.field })), i.set(c, u)), u.forEach((f) => f.add(n));
148
+ }
149
+ }
150
+ }
151
+ return t;
152
+ }
153
+ function p(e, r) {
154
+ return e.flatMap((l, t) => r.measures.map((n, o) => ({
155
+ ...l,
156
+ field: l.kind === "total" ? `total_${o}` : `c${t}_${o}`,
157
+ measure: o,
158
+ measureField: n.field,
159
+ valueField: n.valueField ?? n.field,
160
+ operation: n.op
161
+ })));
162
+ }
163
+ function H(e, r) {
164
+ return e.kind === "total" ? r.hierarchy.totalLabel ?? "合计" : [...e.labels, ...e.kind === "subtotal" ? [r.hierarchy.subtotalLabel ?? "小计"] : []].join(" / ");
165
+ }
166
+ function I(e, r) {
167
+ return [
168
+ ...r.rowFields.map((l, t) => ({ field: `r${t}`, header: r.hierarchy.row?.labels?.[t] ?? l, semanticRole: "dimension" })),
169
+ ...e.map((l) => {
170
+ const t = r.measures[l.measure];
171
+ return {
172
+ field: l.field,
173
+ header: `${H(l, r)} · ${t.label ?? `${t.field} (${t.op})`}`,
174
+ semanticRole: "measure",
175
+ ...t.digits === void 0 ? {} : { format: { kind: "number", digits: t.digits } }
176
+ };
177
+ })
178
+ ];
179
+ }
180
+ function K(e, r, l, t) {
181
+ return e.map((n) => {
182
+ const o = {};
183
+ l.rowFields.forEach((a, s) => {
184
+ o[`r${s}`] = n.kind === "total" ? s === 0 ? l.hierarchy.totalLabel ?? "合计" : null : n.labels[s] ?? (s === n.depth ? l.hierarchy.subtotalLabel ?? "小计" : null);
185
+ });
186
+ for (const a of r) o[a.field] = t.get(n.key)?.get(a.key)?.[a.measure]?.value() ?? (l.measures[a.measure].op === "count" ? 0 : null);
187
+ return o;
188
+ });
189
+ }
190
+ function _(e, r) {
191
+ const l = $(e, r), t = A(l.row, !!r.totals), n = p(A(l.column, !!r.totals), r), o = O(e, r, l);
192
+ return { columns: I(n, r), rows: K(t, n, r, o), headerGrid: z(r, n), metadata: {
193
+ rowFields: [...r.rowFields],
194
+ rowLabels: [...r.hierarchy.row?.labels ?? r.rowFields],
195
+ columnFields: [...r.columnFields],
196
+ columnLabels: [...r.hierarchy.column?.labels ?? r.columnFields],
197
+ rows: t,
198
+ columns: n
199
+ } };
200
+ }
201
+ function m(e, r) {
202
+ const l = r.map(
203
+ (t) => Object.prototype.hasOwnProperty.call(e, t) ? e[t] : null
204
+ );
205
+ if (l.some(
206
+ (t) => t != null && typeof t != "string" && typeof t != "boolean" && !(typeof t == "number" && Number.isFinite(t))
207
+ ))
208
+ throw new Error("矩阵维度必须是有限 JSON 标量");
209
+ return {
210
+ key: JSON.stringify(l.map((t) => [typeof t, t ?? null])),
211
+ label: l.map((t) => t == null ? "" : String(t)).join(" / ")
212
+ };
213
+ }
214
+ function J(e) {
215
+ for (const r of [
216
+ "maxRows",
217
+ "maxColumns",
218
+ "maxInputRows",
219
+ "maxCells",
220
+ "maxAggregateUpdates"
221
+ ])
222
+ if (e[r] !== void 0 && (!Number.isSafeInteger(e[r]) || e[r] < 1))
223
+ throw new Error("矩阵预算应为正安全整数");
224
+ for (const r of ["columnWidthMm", "rowWidthMm"])
225
+ if (e[r] !== void 0 && (!Number.isFinite(e[r]) || e[r] <= 0))
226
+ throw new Error("矩阵列宽应为正数");
227
+ }
228
+ function S(e) {
229
+ if (!e || !Array.isArray(e.rowFields) || !Array.isArray(e.columnFields) || !Array.isArray(e.measures))
230
+ throw new Error("矩阵需要行维度、列维度和度量数组");
231
+ for (const l of [e.rowFields, e.columnFields])
232
+ if (l.some((t) => typeof t != "string" || !t.trim()) || new Set(l).size !== l.length)
233
+ throw new Error("矩阵维度字段应非空且唯一");
234
+ if (J(e), !e.rowFields.length || !e.columnFields.length || e.rowFields.length > 16 || e.columnFields.length > 16)
235
+ throw new Error("矩阵需要 1–16 个行/列维度");
236
+ if (!e.measures.length || e.measures.length > 32)
237
+ throw new Error("矩阵需要 1–32 个度量");
238
+ if (e.measures.map((l) => {
239
+ if (!l || typeof l != "object") throw new Error("矩阵度量应为对象");
240
+ if (g({
241
+ ...l,
242
+ field: l.valueField ?? l.field
243
+ }), l.label !== void 0 && typeof l.label != "string")
244
+ throw new Error("矩阵度量标签应为字符串");
245
+ return l.field;
246
+ }).some((l) => typeof l != "string" || !l.trim()))
247
+ throw new Error("矩阵度量字段应非空");
248
+ e.hierarchy !== void 0 && C(e.hierarchy, e.rowFields, e.columnFields);
249
+ }
250
+ function W(e, r) {
251
+ if (S(r), r.hierarchy) return j(e, r);
252
+ if (!Array.isArray(e) || e.length > (r.maxInputRows ?? 1e5))
253
+ throw new Error("矩阵输入超出预算");
254
+ const l = /* @__PURE__ */ new Set(), t = /* @__PURE__ */ new Set();
255
+ for (const a of e) {
256
+ if (!a || typeof a != "object" || Array.isArray(a))
257
+ throw new Error("矩阵数据行应为对象");
258
+ if (l.add(m(a, r.rowFields).key), t.add(m(a, r.columnFields).key), l.size > (r.maxRows ?? 1e3) || t.size > (r.maxColumns ?? 200))
259
+ throw new Error("矩阵维度数量超出预算");
260
+ if ((l.size + +!!r.totals) * ((t.size + +!!r.totals) * r.measures.length + 1) > (r.maxCells ?? 2e6))
261
+ throw new Error("矩阵输出超出 maxCells 预算");
262
+ }
263
+ const n = l.size + +(!!r.totals && e.length > 0), o = (t.size + +!!r.totals) * r.measures.length + 1;
264
+ return { rowCount: n, columnCount: o, cells: n * o };
265
+ }
266
+ function T(e, r) {
267
+ if (r?.hierarchy)
268
+ return S(r), _(e, r);
269
+ W(e, r);
270
+ const l = x(e, {
271
+ row: (a) => m(a, r.rowFields),
272
+ column: (a) => m(a, r.columnFields),
273
+ measures: r.measures.map((a) => ({ ...a, field: a.valueField ?? a.field })),
274
+ totals: r.totals,
275
+ check: () => {
276
+ }
277
+ // Cardinality/budgets were checked before allocating accumulators.
278
+ }), t = [...l.groups.values()].map((a) => ({ rowLabel: a.label })), n = [{ field: "rowLabel", header: r.rowHeader ?? r.rowFields.join(" / "), semanticRole: "dimension" }], o = { rowLabel: "合计" };
279
+ return r.measures.forEach((a, s) => {
280
+ const i = [...l.columns.entries()].map(([c, u], f) => ({ key: c, label: u, field: `c${f}_${s}` }));
281
+ r.totals && i.push({ key: "", label: "合计", field: `total_${s}` });
282
+ for (const c of i) {
283
+ const u = c.field === `total_${s}`;
284
+ n.push({
285
+ field: c.field,
286
+ header: `${c.label} · ${a.label ?? `${a.field} (${a.op})`}`,
287
+ semanticRole: "measure",
288
+ ...a.digits === void 0 ? {} : { format: { kind: "number", digits: a.digits } }
289
+ });
290
+ let f = 0;
291
+ for (const d of l.groups.values())
292
+ t[f++][c.field] = (u ? d.totals?.[s] : d.cells.get(c.key)?.[s])?.value() ?? (a.op === "count" ? 0 : null);
293
+ o[c.field] = (u ? l.totals?.[s] : l.columnTotals.get(c.key)?.[s])?.value() ?? (a.op === "count" ? 0 : null);
294
+ }
295
+ }), r.totals && e.length && t.push(o), { rows: t, columns: n };
296
+ }
297
+ export {
298
+ x as a,
299
+ T as c,
300
+ W as e,
301
+ S as v
302
+ };
@@ -0,0 +1 @@
1
+ "use strict";const g=require("./computed-C2GD3XcE.cjs");function $(e,r){const l=()=>r.measures.map(i=>g.createAggregateAccumulator(i)),t=new Map,n=new Map,o=new Map,a=r.totals?l():void 0,s=(i,c)=>i?.forEach(u=>u.add(c));for(const i of e){const c=r.row(i),u=r.column(i);n.has(u.key)||n.set(u.key,u.label);let f=t.get(c.key);f||(f={label:c.label,cells:new Map,...r.totals?{totals:l()}:{}},t.set(c.key,f)),r.check(t.size,n.size);let d=f.cells.get(u.key);if(d||(d=l(),f.cells.set(u.key,d)),s(d,i),!r.totals)continue;let w=o.get(u.key);w||(w=l(),o.set(u.key,w)),s(f.totals,i),s(w,i),s(a,i)}return{groups:t,columns:n,columnTotals:o,totals:a}}function h(e,r){return JSON.stringify([e.slice(0,r.length),r.map(l=>[l===null?"null":typeof l,l])])}function S(e,r){return r.map(l=>{const t=Object.prototype.hasOwnProperty.call(e,l)?e[l]:null;if(t==null)return null;if(typeof t=="string"||typeof t=="boolean"||typeof t=="number"&&Number.isFinite(t))return t;throw new Error("矩阵维度必须是有限 JSON 标量")})}function N(e,r,l){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("矩阵层级应为对象");for(const t of[e.emptyLabel,e.subtotalLabel,e.totalLabel])if(t!==void 0&&typeof t!="string")throw new Error("矩阵层级标签应为字符串");k(e.row,r.length),k(e.column,l.length)}function k(e,r){if(e!==void 0){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("矩阵轴配置应为对象");if(e.labels!==void 0&&(!Array.isArray(e.labels)||e.labels.length!==r||e.labels.some(l=>typeof l!="string")))throw new Error("矩阵维度标签必须与维度字段一一对应");if(e.sort!==void 0&&(!Array.isArray(e.sort)||e.sort.length>r||e.sort.some(l=>!["source","asc","desc"].includes(l))))throw new Error("矩阵维度排序应为 source、asc 或 desc");if(e.subtotals!==void 0&&(!Array.isArray(e.subtotals)||new Set(e.subtotals).size!==e.subtotals.length||e.subtotals.some(l=>!Number.isInteger(l)||l<1||l>=r)))throw new Error("矩阵小计深度应唯一且位于 1 至末级之前")}}function A(e,r,l){return{fields:e,options:r??{},hierarchy:l,root:{values:[],children:new Map},leaves:0,expanded:0}}function F(e,r){const l=S(r,e.fields);let t=e.root;for(let n=1;n<=l.length;n++){const o=l.slice(0,n),a=h(e.fields,o);let s=t.children.get(a);s||(s={values:o,children:new Map},t.children.set(a,s),n===l.length?(e.leaves++,e.expanded++):e.options.subtotals?.includes(n)&&e.expanded++),t=s}}function L(e,r){if(e===r)return 0;if(e===null)return-1;if(r===null)return 1;if(typeof e=="number"&&typeof r=="number")return e-r;const l=`${typeof e}:${e}`,t=`${typeof r}:${r}`;return l<t?-1:1}function R(e,r){const l=[...e.children.values()];return r&&r!=="source"&&l.sort((t,n)=>L(t.values[t.values.length-1],n.values[n.values.length-1])*(r==="desc"?-1:1)),l}function y(e,r,l){return{key:h(e.fields,r),kind:l,depth:r.length,fields:e.fields.slice(0,r.length),values:r,labels:r.map(t=>t===null?e.hierarchy.emptyLabel??"(空)":String(t))}}function E(e,r){const l=[];function t(n){for(const o of R(n,e.options.sort?.[n.values.length]))o.children.size?(t(o),e.options.subtotals?.includes(o.values.length)&&l.push(y(e,o.values,"subtotal"))):l.push(y(e,o.values,"member"))}return t(e.root),r&&e.leaves&&l.push(y(e,[],"total")),l}function v(e,r,l){const t=S(r,e.fields),n=[h(e.fields,t),...(e.options.subtotals??[]).map(o=>h(e.fields,t.slice(0,o)))];return l&&n.push(h(e.fields,[])),n}function z(e,r,l){if(!(e.kind!=="member"&&r>e.depth))return e.kind==="total"?{key:"total",text:l.totalLabel??"合计",rowSpan:0}:e.kind==="subtotal"&&r===e.depth?{key:e.key,text:l.subtotalLabel??"小计",rowSpan:0}:{key:JSON.stringify(e.values.slice(0,r+1).map(t=>[typeof t,t])),text:e.labels[r],rowSpan:1}}function O(e,r){const l=e.columnFields.length+1,t=e.rowFields.length,n=Array.from({length:l},()=>Array(t+r.length).fill(null));for(let o=0;o<e.columnFields.length;o++){let a;r.forEach((s,i)=>{const c=z(s,o,e.hierarchy);if(!c){a=void 0;return}if(a?.key===c.key){a.cell.colSpan=(a.cell.colSpan??1)+1;return}const u={text:c.text,rowSpan:c.rowSpan||e.columnFields.length-o,editable:!1,derived:!0};n[o][t+i]=u,a={key:c.key,cell:u}})}return e.rowFields.forEach((o,a)=>{n[0][a]={text:e.hierarchy.row?.labels?.[a]??o,rowSpan:l,editable:!1,derived:!0}}),r.forEach((o,a)=>{const s=e.measures[o.measure];n[l-1][t+a]={text:s.label??`${s.field} (${s.op})`,editable:!1,derived:!0}}),{cells:n.map(o=>o.filter(a=>a!==null)),colWidthsMm:[...e.rowFields.map(()=>e.rowWidthMm??40),...r.map(()=>e.columnWidthMm??28)]}}function M(e,r,l,t){const n=+(!!r.totals&&e>0),o=l.expanded+n,a=(t.expanded+n)*r.measures.length+r.rowFields.length;if(o>(r.maxRows??1e3)||t.expanded+n>(r.maxColumns??200))throw new Error("矩阵层级展开数量超出预算(包含小计/总计)");if(o*a>(r.maxCells??2e6))throw new Error("矩阵输出超出 maxCells 预算");return{rowCount:o,columnCount:a,cells:o*a}}function x(e,r){if(!Array.isArray(e)||e.length>(r.maxInputRows??1e5))throw new Error("矩阵输入超出预算");const l=A(r.rowFields,r.hierarchy.row,r.hierarchy),t=A(r.columnFields,r.hierarchy.column,r.hierarchy);if(e.length*(1+(l.options.subtotals?.length??0)+ +!!r.totals)*(1+(t.options.subtotals?.length??0)+ +!!r.totals)*r.measures.length>(r.maxAggregateUpdates??1e7))throw new Error("矩阵聚合更新超出 maxAggregateUpdates 预算");let o=M(0,r,l,t);for(const a of e){if(!a||typeof a!="object"||Array.isArray(a))throw new Error("矩阵数据行应为对象");F(l,a),F(t,a),o=M(e.length,r,l,t)}return{row:l,column:t,shape:o}}function j(e,r){return x(e,r).shape}function p(e,r,l){const t=new Map;for(const n of e){const o=v(l.row,n,!!r.totals),a=v(l.column,n,!!r.totals);for(const s of o){let i=t.get(s);i||(i=new Map,t.set(s,i));for(const c of a){let u=i.get(c);u||(u=r.measures.map(f=>g.createAggregateAccumulator({...f,field:f.valueField??f.field})),i.set(c,u)),u.forEach(f=>f.add(n))}}}return t}function H(e,r){return e.flatMap((l,t)=>r.measures.map((n,o)=>({...l,field:l.kind==="total"?`total_${o}`:`c${t}_${o}`,measure:o,measureField:n.field,valueField:n.valueField??n.field,operation:n.op})))}function I(e,r){return e.kind==="total"?r.hierarchy.totalLabel??"合计":[...e.labels,...e.kind==="subtotal"?[r.hierarchy.subtotalLabel??"小计"]:[]].join(" / ")}function K(e,r){return[...r.rowFields.map((l,t)=>({field:`r${t}`,header:r.hierarchy.row?.labels?.[t]??l,semanticRole:"dimension"})),...e.map(l=>{const t=r.measures[l.measure];return{field:l.field,header:`${I(l,r)} · ${t.label??`${t.field} (${t.op})`}`,semanticRole:"measure",...t.digits===void 0?{}:{format:{kind:"number",digits:t.digits}}}})]}function T(e,r,l,t){return e.map(n=>{const o={};l.rowFields.forEach((a,s)=>{o[`r${s}`]=n.kind==="total"?s===0?l.hierarchy.totalLabel??"合计":null:n.labels[s]??(s===n.depth?l.hierarchy.subtotalLabel??"小计":null)});for(const a of r)o[a.field]=t.get(n.key)?.get(a.key)?.[a.measure]?.value()??(l.measures[a.measure].op==="count"?0:null);return o})}function _(e,r){const l=x(e,r),t=E(l.row,!!r.totals),n=H(E(l.column,!!r.totals),r),o=p(e,r,l);return{columns:K(n,r),rows:T(t,n,r,o),headerGrid:O(r,n),metadata:{rowFields:[...r.rowFields],rowLabels:[...r.hierarchy.row?.labels??r.rowFields],columnFields:[...r.columnFields],columnLabels:[...r.hierarchy.column?.labels??r.columnFields],rows:t,columns:n}}}function m(e,r){const l=r.map(t=>Object.prototype.hasOwnProperty.call(e,t)?e[t]:null);if(l.some(t=>t!=null&&typeof t!="string"&&typeof t!="boolean"&&!(typeof t=="number"&&Number.isFinite(t))))throw new Error("矩阵维度必须是有限 JSON 标量");return{key:JSON.stringify(l.map(t=>[typeof t,t??null])),label:l.map(t=>t==null?"":String(t)).join(" / ")}}function J(e){for(const r of["maxRows","maxColumns","maxInputRows","maxCells","maxAggregateUpdates"])if(e[r]!==void 0&&(!Number.isSafeInteger(e[r])||e[r]<1))throw new Error("矩阵预算应为正安全整数");for(const r of["columnWidthMm","rowWidthMm"])if(e[r]!==void 0&&(!Number.isFinite(e[r])||e[r]<=0))throw new Error("矩阵列宽应为正数")}function b(e){if(!e||!Array.isArray(e.rowFields)||!Array.isArray(e.columnFields)||!Array.isArray(e.measures))throw new Error("矩阵需要行维度、列维度和度量数组");for(const l of[e.rowFields,e.columnFields])if(l.some(t=>typeof t!="string"||!t.trim())||new Set(l).size!==l.length)throw new Error("矩阵维度字段应非空且唯一");if(J(e),!e.rowFields.length||!e.columnFields.length||e.rowFields.length>16||e.columnFields.length>16)throw new Error("矩阵需要 1–16 个行/列维度");if(!e.measures.length||e.measures.length>32)throw new Error("矩阵需要 1–32 个度量");if(e.measures.map(l=>{if(!l||typeof l!="object")throw new Error("矩阵度量应为对象");if(g.createAggregateAccumulator({...l,field:l.valueField??l.field}),l.label!==void 0&&typeof l.label!="string")throw new Error("矩阵度量标签应为字符串");return l.field}).some(l=>typeof l!="string"||!l.trim()))throw new Error("矩阵度量字段应非空");e.hierarchy!==void 0&&N(e.hierarchy,e.rowFields,e.columnFields)}function C(e,r){if(b(r),r.hierarchy)return j(e,r);if(!Array.isArray(e)||e.length>(r.maxInputRows??1e5))throw new Error("矩阵输入超出预算");const l=new Set,t=new Set;for(const a of e){if(!a||typeof a!="object"||Array.isArray(a))throw new Error("矩阵数据行应为对象");if(l.add(m(a,r.rowFields).key),t.add(m(a,r.columnFields).key),l.size>(r.maxRows??1e3)||t.size>(r.maxColumns??200))throw new Error("矩阵维度数量超出预算");if((l.size+ +!!r.totals)*((t.size+ +!!r.totals)*r.measures.length+1)>(r.maxCells??2e6))throw new Error("矩阵输出超出 maxCells 预算")}const n=l.size+ +(!!r.totals&&e.length>0),o=(t.size+ +!!r.totals)*r.measures.length+1;return{rowCount:n,columnCount:o,cells:n*o}}function P(e,r){if(r?.hierarchy)return b(r),_(e,r);C(e,r);const l=$(e,{row:a=>m(a,r.rowFields),column:a=>m(a,r.columnFields),measures:r.measures.map(a=>({...a,field:a.valueField??a.field})),totals:r.totals,check:()=>{}}),t=[...l.groups.values()].map(a=>({rowLabel:a.label})),n=[{field:"rowLabel",header:r.rowHeader??r.rowFields.join(" / "),semanticRole:"dimension"}],o={rowLabel:"合计"};return r.measures.forEach((a,s)=>{const i=[...l.columns.entries()].map(([c,u],f)=>({key:c,label:u,field:`c${f}_${s}`}));r.totals&&i.push({key:"",label:"合计",field:`total_${s}`});for(const c of i){const u=c.field===`total_${s}`;n.push({field:c.field,header:`${c.label} · ${a.label??`${a.field} (${a.op})`}`,semanticRole:"measure",...a.digits===void 0?{}:{format:{kind:"number",digits:a.digits}}});let f=0;for(const d of l.groups.values())t[f++][c.field]=(u?d.totals?.[s]:d.cells.get(c.key)?.[s])?.value()??(a.op==="count"?0:null);o[c.field]=(u?l.totals?.[s]:l.columnTotals.get(c.key)?.[s])?.value()??(a.op==="count"?0:null)}}),r.totals&&e.length&&t.push(o),{rows:t,columns:n}}exports.accumulatePivotRows=$;exports.createMatrixTable=P;exports.estimateMatrixTable=C;exports.validateMatrixOptions=b;