@agile-team/mach-report 2.17.0 → 2.18.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 (168) hide show
  1. package/README.md +18 -9
  2. package/dist/{ExcelBindingWizard-Bq6FYME6.cjs → ExcelBindingWizard-Czn3C2yE.cjs} +1 -1
  3. package/dist/{ExcelBindingWizard-Co1svTsw.js → ExcelBindingWizard-DMGZj6I6.js} +3 -3
  4. package/dist/ParamEditor-KzDQvbHY.js +732 -0
  5. package/dist/ParamEditor-oDfD8LgE.cjs +1 -0
  6. package/dist/{ReportBatchPanel-uQh06usx.js → ReportBatchPanel-BJK7PvZ4.js} +39 -39
  7. package/dist/ReportBatchPanel-DnmNRssu.cjs +1 -0
  8. package/dist/ReportParamPanel-mQkeN70Q.js +1020 -0
  9. package/dist/ReportParamPanel-sOANVRz-.cjs +1 -0
  10. package/dist/ReportPreview-BxWWTUL5.js +5583 -0
  11. package/dist/ReportPreview-Yf99omi3.cjs +6 -0
  12. package/dist/{ReportTemplateLibrary-TIL_Oj2l.js → ReportTemplateLibrary-BFjB08Wu.js} +1 -1
  13. package/dist/{ReportTemplateLibrary-CnP7_1pH.cjs → ReportTemplateLibrary-BO42QnWd.cjs} +1 -1
  14. package/dist/RuleEditor-CqxT1a-W.js +2337 -0
  15. package/dist/RuleEditor-D7YWigD9.cjs +1 -0
  16. package/dist/{TemplateOutlinePanel-BlLxRrfu.cjs → TemplateOutlinePanel-B0XX350V.cjs} +1 -1
  17. package/dist/{TemplateOutlinePanel-BouxsuqQ.js → TemplateOutlinePanel-zG0DrsIB.js} +2 -2
  18. package/dist/{TemplateReusePanel-yxsHSO40.cjs → TemplateReusePanel-BD0HSKp_.cjs} +1 -1
  19. package/dist/{TemplateReusePanel-BEACLPaN.js → TemplateReusePanel-Czwe5GbC.js} +2 -2
  20. package/dist/{TemplateReviewPanel-D9Cx0m2N.cjs → TemplateReviewPanel-CA5sdffM.cjs} +1 -1
  21. package/dist/{TemplateReviewPanel-B1OGRY2i.js → TemplateReviewPanel-NhmQI65C.js} +2 -2
  22. package/dist/analytics.cjs +1 -1
  23. package/dist/analytics.d.cts +100 -41
  24. package/dist/analytics.d.ts +100 -41
  25. package/dist/analytics.js +76 -141
  26. package/dist/artifact-integrity.json +108 -102
  27. package/dist/assets-2eC3mOcV.js +232 -0
  28. package/dist/assets-B0Hxn4l6.cjs +1 -0
  29. package/dist/{auto-DDHflI9v.cjs → auto-B0EZFIK1.cjs} +1 -1
  30. package/dist/{auto-BIOmtVhk.js → auto-BlchZ1b8.js} +19 -19
  31. package/dist/{batch-WzDIXJAt.js → batch-DGCt44XM.js} +1 -1
  32. package/dist/{batch-z6Aw5GEY.cjs → batch-DYcokH4v.cjs} +1 -1
  33. package/dist/charts-Dlv8j2AG.js +141 -0
  34. package/dist/charts-aCtoswXq.cjs +1 -0
  35. package/dist/codes.cjs +9 -9
  36. package/dist/codes.d.cts +54 -0
  37. package/dist/codes.d.ts +54 -0
  38. package/dist/codes.js +12097 -13668
  39. package/dist/column-visual-BpgQVWwT.js +238 -0
  40. package/dist/column-visual-CtYxnBCP.cjs +1 -0
  41. package/dist/component-tree-6TV7W6Yj.cjs +1 -0
  42. package/dist/component-tree-CvW4lzpv.js +67 -0
  43. package/dist/computed-4TnxzgIh.cjs +1 -0
  44. package/dist/computed-C8NRZQss.js +739 -0
  45. package/dist/data-bar-Ce38juRZ.cjs +1 -0
  46. package/dist/data-bar-PtjXhMgN.js +9 -0
  47. package/dist/designer--TKECSEc.cjs +2 -0
  48. package/dist/designer-d6hJS41w.js +5683 -0
  49. package/dist/designer.cjs +1 -1
  50. package/dist/designer.d.cts +710 -42
  51. package/dist/designer.d.ts +710 -42
  52. package/dist/designer.js +23 -20
  53. package/dist/{encoding-BFMFIc4r.cjs → encoding-B--eZpp1.cjs} +1 -1
  54. package/dist/{encoding-DP_Eaf0A.js → encoding-mctOLocI.js} +2 -2
  55. package/dist/{font-loader-7FWVlykp.cjs → font-loader-DBBJ5KE9.cjs} +1 -1
  56. package/dist/{font-loader-CQZowp0I.js → font-loader-DW8tIaNp.js} +1 -1
  57. package/dist/index-CPh6tqge.js +1575 -0
  58. package/dist/index-CUNw7dL9.cjs +1 -0
  59. package/dist/index.cjs +7 -7
  60. package/dist/index.d.cts +361 -15
  61. package/dist/index.d.ts +361 -15
  62. package/dist/index.js +876 -835
  63. package/dist/json-snapshot-By4ZVVUt.js +1967 -0
  64. package/dist/json-snapshot-jiXff4lc.cjs +2 -0
  65. package/dist/matrix-0hywp0-F.cjs +1 -0
  66. package/dist/matrix-Dy-tyY7E.js +381 -0
  67. package/dist/param-validation-C-8sRJLq.cjs +1 -0
  68. package/dist/param-validation-CnDEd2l-.js +333 -0
  69. package/dist/{pdf-l3ea86di.js → pdf-CKROKygt.js} +1851 -1849
  70. package/dist/{pdf-B8JouyYv.cjs → pdf-DqyxJ96U.cjs} +46 -46
  71. package/dist/pdf.cjs +1 -1
  72. package/dist/pdf.d.cts +54 -0
  73. package/dist/pdf.d.ts +54 -0
  74. package/dist/pdf.js +2 -2
  75. package/dist/{plugin-BBp74CQZ.js → plugin-ByjF2kiV.js} +5 -5
  76. package/dist/{plugin-CtFX9PFG.cjs → plugin-DM1M2wlI.cjs} +1 -1
  77. package/dist/prefill-B8H9qwE4.js +371 -0
  78. package/dist/prefill-D7EswyTI.cjs +1 -0
  79. package/dist/{prepared-CARicKYh.js → prepared-BE-4jfX5.js} +2 -2
  80. package/dist/{prepared-Ch1x_Gog.cjs → prepared-CGVphji3.cjs} +1 -1
  81. package/dist/{protocol-B5A2uom4.cjs → protocol-ByRVzzQG.cjs} +1 -1
  82. package/dist/{protocol-BaiWjq5w.js → protocol-Cr81vFSQ.js} +3 -3
  83. package/dist/{record-bindings-D4TuMzHs.js → record-bindings-DEJtmo3p.js} +67 -107
  84. package/dist/record-bindings-ehjnCDHt.cjs +1 -0
  85. package/dist/{region-binding-workflow-BNasF5kz.js → region-binding-workflow-CBg0l_tj.js} +1 -1
  86. package/dist/{region-binding-workflow-O2Cni3mF.cjs → region-binding-workflow-D05tOYn3.cjs} +1 -1
  87. package/dist/report-encoding-worker.cjs +1 -1
  88. package/dist/report-encoding-worker.js +1 -1
  89. package/dist/{report-params-B1RzkhJj.js → report-params-D9tBuM9B.js} +1 -1
  90. package/dist/{report-params-WDGrA4oP.cjs → report-params-VTg8MoCp.cjs} +1 -1
  91. package/dist/runtime-CDA6d263.cjs +1 -0
  92. package/dist/runtime-CEMvybO7.js +170 -0
  93. package/dist/sbom.cdx.json +1 -1
  94. package/dist/server/node.d.cts +75 -7
  95. package/dist/server/node.d.ts +75 -7
  96. package/dist/server-node.cjs +4 -4
  97. package/dist/server-node.js +2692 -1990
  98. package/dist/server.cjs +1 -1
  99. package/dist/server.d.cts +243 -28
  100. package/dist/server.d.ts +243 -28
  101. package/dist/server.js +28 -28
  102. package/dist/sha256-BDQ1Qk7A.js +158 -0
  103. package/dist/sha256-DgZAKXqI.cjs +1 -0
  104. package/dist/style.css +1 -1
  105. package/dist/template-bindings-Cg5oBLFT.cjs +1 -0
  106. package/dist/template-bindings-TKnXM7ll.js +62 -0
  107. package/dist/{template-catalog-wT1fNeAP.js → template-catalog-CmbWOJqy.js} +16 -16
  108. package/dist/{template-catalog-Dua8h9ZA.cjs → template-catalog-Utu4GP09.cjs} +1 -1
  109. package/dist/{template-fragments-BajTajb4.cjs → template-fragments-C_zSHJAa.cjs} +1 -1
  110. package/dist/{template-fragments-DmX5XK4N.js → template-fragments-DWgo9tlZ.js} +2 -2
  111. package/dist/{template-outline-BwRV_eRo.cjs → template-outline-DWkzZXVC.cjs} +1 -1
  112. package/dist/{template-outline-cnWfT_LK.js → template-outline-DiADphlq.js} +1 -1
  113. package/dist/{template-registry-u11fPd8D.js → template-registry-BIhIHOab.js} +319 -314
  114. package/dist/template-registry-DzWswQI5.cjs +1 -0
  115. package/dist/vue/async.d.cts +528 -33
  116. package/dist/vue/async.d.ts +528 -33
  117. package/dist/vue/index.d.cts +616 -64
  118. package/dist/vue/index.d.ts +616 -64
  119. package/dist/vue-async.cjs +1 -1
  120. package/dist/vue-async.js +3 -3
  121. package/dist/vue.cjs +1 -1
  122. package/dist/vue.js +94 -89
  123. package/dist/{workbook-session-DN5LSA5C.cjs → workbook-session-B94EwVa_.cjs} +1 -1
  124. package/dist/{workbook-session-B8pNW24X.js → workbook-session-BoScoOg-.js} +2 -2
  125. package/dist/worker.cjs +1 -1
  126. package/dist/worker.d.cts +75 -7
  127. package/dist/worker.d.ts +75 -7
  128. package/dist/worker.js +4 -4
  129. package/dist/xlsx.cjs +4 -4
  130. package/dist/xlsx.d.cts +120 -13
  131. package/dist/xlsx.d.ts +120 -13
  132. package/dist/xlsx.js +313 -279
  133. package/package.json +1 -1
  134. package/dist/ParamEditor-B5UZRgxv.cjs +0 -1
  135. package/dist/ParamEditor-DNNARyeB.js +0 -594
  136. package/dist/ReportBatchPanel-Ctvs2t_9.cjs +0 -1
  137. package/dist/ReportPreview-BdQawRh0.js +0 -4879
  138. package/dist/ReportPreview-CJC_-j2I.cjs +0 -6
  139. package/dist/RuleEditor-DkRjOLlr.js +0 -2141
  140. package/dist/RuleEditor-h5anGsDB.cjs +0 -1
  141. package/dist/assets-BIMVwjQe.js +0 -231
  142. package/dist/assets-Dfs2ElxI.cjs +0 -1
  143. package/dist/component-tree-Ca6YYfHq.js +0 -61
  144. package/dist/component-tree-DkGLEfZC.cjs +0 -1
  145. package/dist/computed-BW5a8QFk.js +0 -612
  146. package/dist/computed-C2GD3XcE.cjs +0 -1
  147. package/dist/config-Dg_o8e7m.cjs +0 -1
  148. package/dist/config-XQ4qrQ7Q.js +0 -844
  149. package/dist/designer-D9XAxqSc.js +0 -5178
  150. package/dist/designer-uCDo5XSK.cjs +0 -2
  151. package/dist/drill-ByN8COs_.cjs +0 -1
  152. package/dist/drill-CKW3Xtfa.js +0 -145
  153. package/dist/json-snapshot-D7PE1NsU.cjs +0 -2
  154. package/dist/json-snapshot-DYmEe3sO.js +0 -1779
  155. package/dist/matrix-JLAXlux-.js +0 -302
  156. package/dist/matrix-gTHpDTGm.cjs +0 -1
  157. package/dist/param-validation-C3HlcLLO.cjs +0 -1
  158. package/dist/param-validation-Do7Eg8Zv.js +0 -181
  159. package/dist/record-bindings-B86Sur_y.cjs +0 -1
  160. package/dist/runtime-DakRXui3.js +0 -170
  161. package/dist/runtime-dL5ygIfa.cjs +0 -1
  162. package/dist/sha256-BshdOkCC.cjs +0 -1
  163. package/dist/sha256-DTG-Gq8i.js +0 -157
  164. package/dist/template-bindings-C2SpvsMU.js +0 -58
  165. package/dist/template-bindings-CEtWyiLX.cjs +0 -1
  166. package/dist/template-registry-CpysHAxy.cjs +0 -1
  167. package/dist/tree-CLpxYbKa.cjs +0 -1
  168. package/dist/tree-DNJorJUf.js +0 -172
package/dist/xlsx.js CHANGED
@@ -1,114 +1,144 @@
1
- import { f as m, r as k } from "./style-67OqfNed.js";
2
- import { b as E, o as N, c as O } from "./progress-Hc2vxoCs.js";
3
- import { e as L, E as j, m as $, i as G } from "./workbook-session-B8pNW24X.js";
4
- import { a as ze, b as Be, o as Ne } from "./workbook-session-B8pNW24X.js";
5
- import { i as S } from "./component-tree-Ca6YYfHq.js";
6
- import { c as H } from "./media-Y90dHK9z.js";
7
- import { r as A } from "./grid-geometry-BNptEcMm.js";
8
- import { a as _, r as D } from "./assets-BIMVwjQe.js";
9
- import { b as Le, c as je, a as Ge, d as He, e as _e, f as De, g as Ue, h as Ke, p as Xe, i as Je, v as Ve, j as qe, k as Qe, l as Ye, m as Ze, n as et } from "./region-binding-workflow-BNasF5kz.js";
10
- function R(e, t) {
11
- return { richText: e.flatMap((o, n) => [
12
- ...n ? [{ text: `
1
+ import { c as B, b as E, o as L } from "./progress-Hc2vxoCs.js";
2
+ import { e as j } from "./index-CPh6tqge.js";
3
+ import { d as G } from "./data-bar-PtjXhMgN.js";
4
+ import { f as w, r as $ } from "./style-67OqfNed.js";
5
+ import { e as H, E as _, m as A, i as U } from "./workbook-session-BoScoOg-.js";
6
+ import { a as _e, b as Ue, o as Xe } from "./workbook-session-BoScoOg-.js";
7
+ import { i as S } from "./component-tree-CvW4lzpv.js";
8
+ import { c as X } from "./media-Y90dHK9z.js";
9
+ import { r as F } from "./grid-geometry-BNptEcMm.js";
10
+ import { a as K, r as J } from "./assets-2eC3mOcV.js";
11
+ import { b as Je, c as Ve, a as qe, d as Qe, e as Ye, f as Ze, g as et, h as tt, p as rt, i as nt, v as it, j as ot, k as at, l as st, m as lt, n as ct } from "./region-binding-workflow-CBg0l_tj.js";
12
+ function V(e) {
13
+ const t = j({ width: 1, height: 1, channels: 4, depth: 8, data: new Uint8Array([1, 3, 5].map((o) => parseInt(e.slice(o, o + 2), 16)).concat(89)) });
14
+ return `data:image/png;base64,${btoa(String.fromCharCode(...t))}`;
15
+ }
16
+ function q(e, t, o) {
17
+ const r = /* @__PURE__ */ new Map();
18
+ let i = 0;
19
+ return (a, n, s, l) => {
20
+ const c = G(n.cell.dataBar, n.widthMm, n.heightMm, l);
21
+ if (!c) return;
22
+ if (++i > t) throw new Error(`Excel 数据条超过 ${t} 个绘图预算,请缩小范围或调整 maxDataBars`);
23
+ let h = r.get(c.color);
24
+ h || (h = V(c.color), r.set(c.color, h)), i === 1 && o.push("数据条为静态半透明视觉快照,保留原始单元格值;Excel 编辑不会重算条形,绘图叠加文字的混色与预览可能略有差异。"), e.write(a, { kind: "image", leftMm: 0, topMm: 0, widthMm: c.width, heightMm: c.height, imageData: h }, s, { leftMm: n.xMm + c.x, offsetMm: c.y });
25
+ };
26
+ }
27
+ async function Q(e, t, o) {
28
+ const r = e.pages.flatMap((n) => n.components), i = B(o);
29
+ let a = 0;
30
+ for (; r.length; ) {
31
+ const n = r.pop();
32
+ for (const s of n.grid?.cells ?? []) for (const l of s) {
33
+ if (l?.dataBar && l.dataBar.end > l.dataBar.start && ++a > t) throw new Error(`Excel 数据条超过 ${t} 个绘图预算,请缩小范围或调整 maxDataBars`);
34
+ l?.children && r.push(...l.children);
35
+ const c = i();
36
+ c && await c;
37
+ }
38
+ }
39
+ }
40
+ function P(e, t) {
41
+ return { richText: e.flatMap((o, r) => [
42
+ ...r ? [{ text: `
13
43
  ` }] : [],
14
- ...o.segments.map((r) => {
15
- const a = m(t, r.style), i = a.color?.replace(/^#/, "");
16
- return { text: r.kind === "field" ? r.field ?? "" : r.text ?? "", font: { name: a.fontFamily, bold: a.bold, italic: a.italic, underline: a.underline, size: k(a).fontSizePt, .../^[a-f\d]{6}$/i.test(i ?? "") ? { color: { argb: `FF${i.toUpperCase()}` } } : {} } };
44
+ ...o.segments.map((i) => {
45
+ const a = w(t, i.style), n = a.color?.replace(/^#/, "");
46
+ return { text: i.kind === "field" ? i.field ?? "" : i.text ?? "", font: { name: a.fontFamily, bold: a.bold, italic: a.italic, underline: a.underline, size: $(a).fontSizePt, .../^[a-f\d]{6}$/i.test(n ?? "") ? { color: { argb: `FF${n.toUpperCase()}` } } : {} } };
17
47
  })
18
48
  ]) };
19
49
  }
20
- function U(e, t) {
50
+ function Y(e, t) {
21
51
  const o = e.children?.filter((a) => a.kind === "text" && !a.grid) ?? [];
22
52
  if (!e.richParagraphs?.length && !o.length) return;
23
- const n = m(t, e.style), r = e.richParagraphs?.length ? [...e.richParagraphs] : e.text ? [{ segments: [{ text: e.text }] }] : [];
53
+ const r = w(t, e.style), i = e.richParagraphs?.length ? [...e.richParagraphs] : e.text ? [{ segments: [{ text: e.text }] }] : [];
24
54
  for (const a of o) {
25
- const i = m(n, a.style), s = a.richParagraphs?.length ? a.richParagraphs : [{ segments: [{ text: a.lines?.join(`
55
+ const n = w(r, a.style), s = a.richParagraphs?.length ? a.richParagraphs : [{ segments: [{ text: a.lines?.join(`
26
56
  `) ?? a.text ?? "" }] }];
27
- for (const l of s) r.push({ ...l, segments: l.segments.map((c) => ({ ...c, style: m(i, c.style) })) });
57
+ for (const l of s) i.push({ ...l, segments: l.segments.map((c) => ({ ...c, style: w(n, c.style) })) });
28
58
  }
29
- return R(r, n);
59
+ return P(i, r);
30
60
  }
31
- function K(e, t, o) {
32
- let n = o * 72 / 25.4;
33
- if (!Number.isFinite(n) || t + Math.ceil(n / 409) - 1 > 1048576) throw new Error("Excel 图片占位超过工作表行数上限");
34
- for (; n > 0; ) {
61
+ function Z(e, t, o) {
62
+ let r = o * 72 / 25.4;
63
+ if (!Number.isFinite(r) || t + Math.ceil(r / 409) - 1 > 1048576) throw new Error("Excel 图片占位超过工作表行数上限");
64
+ for (; r > 0; ) {
35
65
  if (t > 1048576) throw new Error("Excel 图片占位超过工作表行数上限");
36
- const r = Math.min(409, n);
37
- e.getRow(t++).height = r, n -= r;
66
+ const i = Math.min(409, r);
67
+ e.getRow(t++).height = i, r -= i;
38
68
  }
39
69
  return t;
40
70
  }
41
- function X(e, t, o) {
42
- let n = Math.round(t * 36e3), r = 0;
43
- if (!Number.isSafeInteger(n)) throw new Error("Excel 图片锚点超出安全坐标范围");
44
- for (e.properties.defaultColWidth ??= 8.43; r < 16384; ) {
45
- const a = e.getColumn(r + 1).width ?? e.properties.defaultColWidth, i = Math.round(L(a) * 36e3);
46
- if (!Number.isSafeInteger(i) || i <= 0) throw new Error("Excel 图片锚点所在列宽无效");
47
- if (n < i) return { col: r + n / i, row: o - 1, nativeCol: r, nativeColOff: n, nativeRow: o - 1, nativeRowOff: 0 };
48
- n -= i, r++;
71
+ function ee(e, t, o) {
72
+ let r = Math.round(t * 36e3), i = 0;
73
+ if (!Number.isSafeInteger(r)) throw new Error("Excel 图片锚点超出安全坐标范围");
74
+ for (e.properties.defaultColWidth ??= 8.43; i < 16384; ) {
75
+ const a = e.getColumn(i + 1).width ?? e.properties.defaultColWidth, n = Math.round(H(a) * 36e3);
76
+ if (!Number.isSafeInteger(n) || n <= 0) throw new Error("Excel 图片锚点所在列宽无效");
77
+ if (r < n) return { col: i + r / n, row: o - 1, nativeCol: i, nativeColOff: r, nativeRow: o - 1, nativeRowOff: 0 };
78
+ r -= n, i++;
49
79
  }
50
80
  throw new Error("Excel 图片锚点超过16384列上限");
51
81
  }
52
- function J(e, t, o) {
53
- let n = o * 72 / 25.4;
54
- if (!Number.isFinite(n) || Math.abs(n) > 1048576 * 409) throw new Error("Excel 图片纵向偏移超过工作表范围");
55
- const r = (a) => {
56
- const i = e.getRow(a).height ?? e.properties.defaultRowHeight ?? 15;
57
- if (!Number.isFinite(i) || i <= 0) throw new Error("Excel 图片锚点所在行高无效");
58
- return i;
82
+ function te(e, t, o) {
83
+ let r = o * 72 / 25.4;
84
+ if (!Number.isFinite(r) || Math.abs(r) > 1048576 * 409) throw new Error("Excel 图片纵向偏移超过工作表范围");
85
+ const i = (a) => {
86
+ const n = e.getRow(a).height ?? e.properties.defaultRowHeight ?? 15;
87
+ if (!Number.isFinite(n) || n <= 0) throw new Error("Excel 图片锚点所在行高无效");
88
+ return n;
59
89
  };
60
- for (; n < 0 && t > 1; ) n += r(--t);
61
- for (; t <= 1048576 && n >= r(t); ) n -= r(t++);
62
- if (t > 1048576 || n < 0) throw new Error("Excel 图片移动到工作表边界之外");
63
- return { nativeRow: t - 1, nativeRowOff: Math.round(n * 25.4 / 72 * 36e3) };
64
- }
65
- function V(e, t, o) {
66
- const n = H(t), r = /* @__PURE__ */ new Map();
67
- return { write(a, i, s, l) {
68
- if (![i.widthMm, i.heightMm, i.leftMm].every(Number.isFinite) || i.widthMm < 0 || i.heightMm < 0 || i.leftMm < 0) throw new Error("Excel 图片尺寸无效");
69
- if (!i.widthMm || !i.heightMm) return s;
70
- if (!i.imageData || !/^data:image\/(png|jpe?g);base64,/i.test(i.imageData))
71
- return o.push(`${i.nid ?? i.kind}: Excel 图片仅支持 PNG/JPEG data URI,已跳过`), s;
72
- const c = n(i.imageData);
73
- let h = r.get(c.dataUrl);
74
- h === void 0 && (h = e.addImage({ base64: c.dataUrl, extension: c.extension }), r.set(c.dataUrl, h));
75
- const f = l ? s : K(a, s, i.heightMm);
90
+ for (; r < 0 && t > 1; ) r += i(--t);
91
+ for (; t <= 1048576 && r >= i(t); ) r -= i(t++);
92
+ if (t > 1048576 || r < 0) throw new Error("Excel 图片移动到工作表边界之外");
93
+ return { nativeRow: t - 1, nativeRowOff: Math.round(r * 25.4 / 72 * 36e3) };
94
+ }
95
+ function re(e, t, o) {
96
+ const r = X(t), i = /* @__PURE__ */ new Map();
97
+ return { write(a, n, s, l) {
98
+ if (![n.widthMm, n.heightMm, n.leftMm].every(Number.isFinite) || n.widthMm < 0 || n.heightMm < 0 || n.leftMm < 0) throw new Error("Excel 图片尺寸无效");
99
+ if (!n.widthMm || !n.heightMm) return s;
100
+ if (!n.imageData || !/^data:image\/(png|jpe?g);base64,/i.test(n.imageData))
101
+ return o.push(`${n.nid ?? n.kind}: Excel 图片仅支持 PNG/JPEG data URI,已跳过`), s;
102
+ const c = r(n.imageData);
103
+ let h = i.get(c.dataUrl);
104
+ h === void 0 && (h = e.addImage({ base64: c.dataUrl, extension: c.extension }), i.set(c.dataUrl, h));
105
+ const d = l ? s : Z(a, s, n.heightMm);
76
106
  return a.addImage(h, {
77
- tl: { ...X(a, l?.leftMm ?? i.leftMm, s), ...l ? J(a, s, l.offsetMm) : {} },
78
- ext: { width: i.widthMm * 96 / 25.4, height: i.heightMm * 96 / 25.4 },
107
+ tl: { ...ee(a, l?.leftMm ?? n.leftMm, s), ...l ? te(a, s, l.offsetMm) : {} },
108
+ ext: { width: n.widthMm * 96 / 25.4, height: n.heightMm * 96 / 25.4 },
79
109
  editAs: "oneCell"
80
- }), f;
110
+ }), d;
81
111
  } };
82
112
  }
83
- function F(e) {
113
+ function R(e) {
84
114
  return !!e && typeof e == "object" && !Array.isArray(e);
85
115
  }
86
- function T(e, t) {
116
+ function I(e, t) {
87
117
  const o = e.meta?.xlsxFlow;
88
118
  if (o === void 0) return;
89
- if (!F(o) || o.version !== "1.0" || !Number.isSafeInteger(o.columnStart) || Number(o.columnStart) < 0) throw new Error("Excel 多区域几何标记无效,不能按列序猜测输出");
119
+ if (!R(o) || o.version !== "1.0" || !Number.isSafeInteger(o.columnStart) || Number(o.columnStart) < 0) throw new Error("Excel 多区域几何标记无效,不能按列序猜测输出");
90
120
  if (!e.grid) throw new Error("Excel 多区域输出只接受显式网格组件");
91
- const n = o, r = e.grid.colWidthsMm;
92
- if (!r?.length || n.columnStart + r.length > t.length || r.some((a, i) => Math.abs(a - t[n.columnStart + i]) > 1e-3)) throw new Error("Excel 多区域列位置与网格列宽不一致");
93
- return n;
121
+ const r = o, i = e.grid.colWidthsMm;
122
+ if (!i?.length || r.columnStart + i.length > t.length || i.some((a, n) => Math.abs(a - t[r.columnStart + n]) > 1e-3)) throw new Error("Excel 多区域列位置与网格列宽不一致");
123
+ return r;
94
124
  }
95
- function P(e) {
125
+ function T(e) {
96
126
  const t = e.meta?.xlsxFlow;
97
127
  if (t === void 0) {
98
- if (e.components.some((n) => n.meta?.xlsxFlow !== void 0)) throw new Error("Excel 多区域页面缺少完整列几何标记");
128
+ if (e.components.some((r) => r.meta?.xlsxFlow !== void 0)) throw new Error("Excel 多区域页面缺少完整列几何标记");
99
129
  return;
100
130
  }
101
- const o = q(t, e.meta?.reportScope);
102
- for (const n of e.components) {
103
- const r = T(n, o.widths);
104
- if (!r) throw new Error("Excel 多区域页面混入没有区域几何的组件,请使用独立页面模板");
105
- const a = o.widths.slice(0, r.columnStart).reduce((s, l) => s + l, e.marginLeftMm ?? 0), i = n.grid.colWidthsMm.reduce((s, l) => s + l, 0);
106
- if (Math.abs(a - n.leftMm) > 0.01 || Math.abs(i - n.widthMm) > 0.01) throw new Error("Excel 多区域标记与真实横向位置不一致");
131
+ const o = ne(t, e.meta?.reportScope);
132
+ for (const r of e.components) {
133
+ const i = I(r, o.widths);
134
+ if (!i) throw new Error("Excel 多区域页面混入没有区域几何的组件,请使用独立页面模板");
135
+ const a = o.widths.slice(0, i.columnStart).reduce((s, l) => s + l, e.marginLeftMm ?? 0), n = r.grid.colWidthsMm.reduce((s, l) => s + l, 0);
136
+ if (Math.abs(a - r.leftMm) > 0.01 || Math.abs(n - r.widthMm) > 0.01) throw new Error("Excel 多区域标记与真实横向位置不一致");
107
137
  }
108
138
  return o;
109
139
  }
110
- function q(e, t) {
111
- if (!F(e) || e.version !== "1.0" || typeof e.sheet != "string" || !e.sheet.trim() || typeof e.templateId != "string" || !e.templateId.trim()) throw new Error("Excel 多区域工作表标识无效");
140
+ function ne(e, t) {
141
+ if (!R(e) || e.version !== "1.0" || typeof e.sheet != "string" || !e.sheet.trim() || typeof e.templateId != "string" || !e.templateId.trim()) throw new Error("Excel 多区域工作表标识无效");
112
142
  if (!Array.isArray(e.fullWidthsMm) || !e.fullWidthsMm.length || e.fullWidthsMm.length > 16384 || e.fullWidthsMm.some((o) => typeof o != "number" || !Number.isFinite(o) || o <= 0 || o > 2e3)) throw new Error("Excel 多区域完整列宽无效");
113
143
  if (t !== void 0 && (typeof t != "string" || !t.trim())) throw new Error("Excel 多区域报表命名空间无效");
114
144
  return { key: JSON.stringify([t ?? e.templateId, e.sheet]), sheet: e.sheet, widths: e.fullWidthsMm };
@@ -116,61 +146,61 @@ function q(e, t) {
116
146
  function y(e) {
117
147
  return Math.round(e * 1e6) / 1e6;
118
148
  }
119
- function Q(e, t, o, n, r) {
120
- return e.components.filter((a) => n ? a.pageAnchor === "header" ? t === 0 : a.pageAnchor === "footer" ? t === o - 1 : a.table?.role !== "header" ? !0 : r.has(a.table.id) ? !1 : (r.add(a.table.id), !0) : !0);
149
+ function ie(e, t, o, r, i) {
150
+ return e.components.filter((a) => r ? a.pageAnchor === "header" ? t === 0 : a.pageAnchor === "footer" ? t === o - 1 : a.table?.role !== "header" ? !0 : i.has(a.table.id) ? !1 : (i.add(a.table.id), !0) : !0);
121
151
  }
122
- function Y(e, t, o, n) {
123
- const r = e.components.filter((i) => !t.includes(i) && i.table?.role === "header"), a = t.filter((i) => !i.pageAnchor).reduce((i, s) => Math.max(i, s.topMm + s.heightMm), e.marginTopMm ?? 0);
124
- return t.map((i) => {
125
- let s = i.topMm;
126
- return o && i.pageAnchor === "footer" && (s = a), s -= r.filter((l) => l.topMm + l.heightMm <= s + 1e-3).reduce((l, c) => l + c.heightMm, 0), { component: i, layout: A(i.grid, i.widthMm, i.heightMm), top: s, column: T(i, n).columnStart };
152
+ function oe(e, t, o, r) {
153
+ const i = e.components.filter((n) => !t.includes(n) && n.table?.role === "header"), a = t.filter((n) => !n.pageAnchor).reduce((n, s) => Math.max(n, s.topMm + s.heightMm), e.marginTopMm ?? 0);
154
+ return t.map((n) => {
155
+ let s = n.topMm;
156
+ return o && n.pageAnchor === "footer" && (s = a), s -= i.filter((l) => l.topMm + l.heightMm <= s + 1e-3).reduce((l, c) => l + c.heightMm, 0), { component: n, layout: F(n.grid, n.widthMm, n.heightMm), top: s, column: I(n, r).columnStart };
127
157
  });
128
158
  }
129
- function Z(e, t, o) {
130
- const n = t.length - 1;
131
- if (n * o.length > 1e6) throw new Error("Excel 多区域单页超过 100 万几何单元格,请减小预览分页高度或列数");
132
- const r = new Map(t.map((s, l) => [s, l])), a = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
159
+ function ae(e, t, o) {
160
+ const r = t.length - 1;
161
+ if (r * o.length > 1e6) throw new Error("Excel 多区域单页超过 100 万几何单元格,请减小预览分页高度或列数");
162
+ const i = new Map(t.map((s, l) => [s, l])), a = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
133
163
  for (const s of e) for (const l of s.layout.cells) {
134
164
  if (!Object.keys(l.cell).length) continue;
135
- const c = r.get(y(s.top + l.yMm)), h = r.get(y(s.top + l.yMm + l.heightMm)), f = s.column + l.ci, u = f + (l.cell.colSpan ?? 1), d = `${c}:${f}`;
136
- for (let g = c; g < h; g++) for (let p = f; p < u; p++) {
137
- const x = `${g}:${p}`;
138
- if (i.has(x)) throw new Error("Excel 多区域实际单元格互相覆盖,已终止输出,未覆盖已有内容");
139
- i.set(x, d);
165
+ const c = i.get(y(s.top + l.yMm)), h = i.get(y(s.top + l.yMm + l.heightMm)), d = s.column + l.ci, u = d + (l.cell.colSpan ?? 1), f = `${c}:${d}`;
166
+ for (let g = c; g < h; g++) for (let m = d; m < u; m++) {
167
+ const x = `${g}:${m}`;
168
+ if (n.has(x)) throw new Error("Excel 多区域实际单元格互相覆盖,已终止输出,未覆盖已有内容");
169
+ n.set(x, f);
140
170
  }
141
- a.set(d, { ...l.cell, style: m(s.component.style, l.cell.style), rowSpan: h - c, colSpan: u - f });
171
+ a.set(f, { ...l.cell, style: w(s.component.style, l.cell.style), rowSpan: h - c, colSpan: u - d });
142
172
  }
143
- return Array.from({ length: n }, (s, l) => {
173
+ return Array.from({ length: r }, (s, l) => {
144
174
  const c = [];
145
175
  for (let h = 0; h < o.length; h++) {
146
- const f = `${l}:${h}`, u = a.get(f);
147
- u ? (c.push(u), h += (u.colSpan ?? 1) - 1) : i.has(f) || c.push(null);
176
+ const d = `${l}:${h}`, u = a.get(d);
177
+ u ? (c.push(u), h += (u.colSpan ?? 1) - 1) : n.has(d) || c.push(null);
148
178
  }
149
179
  return c;
150
180
  });
151
181
  }
152
- function ee(e, t) {
153
- const o = /* @__PURE__ */ new Set(), n = [];
154
- let r;
155
- for (const [a, { page: i }] of e.entries()) {
156
- const s = P(i);
157
- if (r && (s.key !== r.key || s.widths.length !== r.widths.length || s.widths.some((d, g) => Math.abs(d - r.widths[g]) > 1e-3))) throw new Error("Excel 多区域分页的工作表或列结构不一致");
158
- r ??= s;
159
- const l = Q(i, a, e.length, t, o), c = Y(i, l, t, s.widths);
182
+ function se(e, t) {
183
+ const o = /* @__PURE__ */ new Set(), r = [];
184
+ let i;
185
+ for (const [a, { page: n }] of e.entries()) {
186
+ const s = T(n);
187
+ if (i && (s.key !== i.key || s.widths.length !== i.widths.length || s.widths.some((f, g) => Math.abs(f - i.widths[g]) > 1e-3))) throw new Error("Excel 多区域分页的工作表或列结构不一致");
188
+ i ??= s;
189
+ const l = ie(n, a, e.length, t, o), c = oe(n, l, t, s.widths);
160
190
  if (!c.length) continue;
161
- const h = [...new Set(c.flatMap((d) => [...d.layout.rows.map((g) => y(d.top + g.pos)), y(d.top + d.component.heightMm)]))].sort((d, g) => d - g), f = Z(c, h, s.widths), u = h.slice(1).map((d, g) => d - h[g]);
162
- n.push({ kind: "rect", leftMm: 0, topMm: 0, widthMm: s.widths.reduce((d, g) => d + g, 0), heightMm: u.reduce((d, g) => d + g, 0), grid: { cells: f, colWidthsMm: s.widths, rowHeightsMm: u } });
191
+ const h = [...new Set(c.flatMap((f) => [...f.layout.rows.map((g) => y(f.top + g.pos)), y(f.top + f.component.heightMm)]))].sort((f, g) => f - g), d = ae(c, h, s.widths), u = h.slice(1).map((f, g) => f - h[g]);
192
+ r.push({ kind: "rect", leftMm: 0, topMm: 0, widthMm: s.widths.reduce((f, g) => f + g, 0), heightMm: u.reduce((f, g) => f + g, 0), grid: { cells: d, colWidthsMm: s.widths, rowHeightsMm: u } });
163
193
  }
164
- return n;
194
+ return r;
165
195
  }
166
- const W = 72 / 25.4, te = 32767, ne = 253;
167
- function w(e, t) {
196
+ const W = 72 / 25.4, le = 32767, ce = 253;
197
+ function p(e, t) {
168
198
  if (typeof e != "string") return;
169
- if (e.length > te)
199
+ if (e.length > le)
170
200
  throw new Error(`Excel 单元格 ${t} 最多支持 32767 个字符,无法无损导出;内容未裁剪`);
171
201
  let o = 0;
172
- for (let n = 0; n < e.length; n++)
173
- if (e.charCodeAt(n) === 10 && ++o > ne)
202
+ for (let r = 0; r < e.length; r++)
203
+ if (e.charCodeAt(r) === 10 && ++o > ce)
174
204
  throw new Error(`Excel 单元格 ${t} 最多支持 253 个换行,无法无损导出;内容未改写`);
175
205
  }
176
206
  function M(e) {
@@ -178,13 +208,13 @@ function M(e) {
178
208
  const t = e.replace("#", "");
179
209
  return /^[0-9a-fA-F]{6}$/.test(t) ? `FF${t.toUpperCase()}` : void 0;
180
210
  }
181
- function I(e, t = {}) {
211
+ function z(e, t = {}) {
182
212
  e.font = {
183
213
  name: t.fontFamily,
184
214
  bold: t.bold === !0,
185
215
  italic: t.italic === !0,
186
216
  underline: t.underline === !0,
187
- size: k(t).fontSizePt,
217
+ size: $(t).fontSizePt,
188
218
  color: M(t.color) ? { argb: M(t.color) } : void 0
189
219
  };
190
220
  }
@@ -193,133 +223,133 @@ const b = {
193
223
  a4: { width: 210, height: 297, code: 9 },
194
224
  a5: { width: 148, height: 210, code: 11 }
195
225
  };
196
- function ie(e, t, o, n) {
226
+ function he(e, t, o, r) {
197
227
  if (t && t !== "auto") return b[t].code;
198
- const r = Math.min(e.pageWidthMm, e.pageHeightMm), a = Math.max(e.pageWidthMm, e.pageHeightMm), i = Object.values(b).find((s) => Math.abs(r - s.width) <= 1 && Math.abs(a - s.height) <= 1);
199
- return i ? i.code : (n.push(`page ${o + 1}: 自定义纸张 ${e.pageWidthMm}×${e.pageHeightMm}mm 无对应 Excel 纸型,打印设置回退 A4;可显式配置 paperSize`), b.a4.code);
228
+ const i = Math.min(e.pageWidthMm, e.pageHeightMm), a = Math.max(e.pageWidthMm, e.pageHeightMm), n = Object.values(b).find((s) => Math.abs(i - s.width) <= 1 && Math.abs(a - s.height) <= 1);
229
+ return n ? n.code : (r.push(`page ${o + 1}: 自定义纸张 ${e.pageWidthMm}×${e.pageHeightMm}mm 无对应 Excel 纸型,打印设置回退 A4;可显式配置 paperSize`), b.a4.code);
200
230
  }
201
- function re(e, t, o, n) {
202
- const r = typeof t.text == "string" ? t.text : "";
231
+ function de(e, t, o, r) {
232
+ const i = typeof t.text == "string" ? t.text : "";
203
233
  if (o !== "raw" || !Object.prototype.hasOwnProperty.call(t, "value")) {
204
- w(r, e.address), e.value = r;
234
+ p(i, e.address), e.value = i;
205
235
  return;
206
236
  }
207
237
  const a = t.value;
208
238
  if (a === null || typeof a == "string" || typeof a == "boolean" || typeof a == "number" && Number.isFinite(a)) {
209
- w(a, e.address), e.value = a, t.numberFormat && (e.numFmt = t.numberFormat);
239
+ p(a, e.address), e.value = a, t.numberFormat && (e.numFmt = t.numberFormat);
210
240
  return;
211
241
  }
212
- w(r, e.address), e.value = r, n.push(`原始单元格值无效,已保留显示文本:${e.address}`);
242
+ p(i, e.address), e.value = i, r.push(`原始单元格值无效,已保留显示文本:${e.address}`);
213
243
  }
214
- function oe(e) {
215
- const t = P(e);
216
- return t ? { id: `xlsx-flow:${t.key}`, title: t.sheet, wide: !0, flow: !0 } : ae(e);
244
+ function fe(e) {
245
+ const t = T(e);
246
+ return t ? { id: `xlsx-flow:${t.key}`, title: t.sheet, wide: !0, flow: !0 } : ge(e);
217
247
  }
218
- function ae(e) {
219
- const o = e.components.filter((n) => n.table !== void 0)[0]?.table;
248
+ function ge(e) {
249
+ const o = e.components.filter((r) => r.table !== void 0)[0]?.table;
220
250
  if (!(!o || typeof o.id != "string" || !o.id.trim() || !Array.isArray(o.columnKeys) || !o.columnKeys.length)) {
221
- for (const n of e.components) {
222
- if (n.table) {
223
- if (!n.grid || n.table.id !== o.id) return;
251
+ for (const r of e.components) {
252
+ if (r.table) {
253
+ if (!r.grid || r.table.id !== o.id) return;
224
254
  continue;
225
255
  }
226
- if (n.grid || n.kind !== "text" && !S(n)) return;
256
+ if (r.grid || r.kind !== "text" && !S(r)) return;
227
257
  }
228
258
  return { id: o.id, title: o.title, wide: o.layout === "wide" || e.layout === "wide" };
229
259
  }
230
260
  }
231
- function se(e, t) {
261
+ function ue(e, t) {
232
262
  const o = /* @__PURE__ */ new Set();
233
- for (const [n, r] of e.pages.entries())
234
- if (!t[n])
235
- for (const a of r.components)
263
+ for (const [r, i] of e.pages.entries())
264
+ if (!t[r])
265
+ for (const a of i.components)
236
266
  typeof a.table?.id == "string" && o.add(a.table.id);
237
267
  return o;
238
268
  }
239
269
  function v(e) {
240
270
  return e.layout === "wide" || e.components.some((t) => t.table?.layout === "wide");
241
271
  }
242
- function le(e, t, o) {
243
- const n = [], r = e.pages.map(oe), a = se(e, r);
244
- for (const [i, s] of e.pages.entries()) {
245
- const l = r[i], c = l && !a.has(l.id), h = t === "pages" || !c ? void 0 : l;
272
+ function me(e, t, o) {
273
+ const r = [], i = e.pages.map(fe), a = ue(e, i);
274
+ for (const [n, s] of e.pages.entries()) {
275
+ const l = i[n], c = l && !a.has(l.id), h = t === "pages" || !c ? void 0 : l;
246
276
  if (t === "continuous" && !h)
247
- throw new Error(`page ${i + 1}: continuous Excel 需要完整、单一的逻辑表来源;自由布局请使用 sheetMode: 'pages'`);
248
- const f = h !== void 0 && (t === "continuous" || h.wide);
249
- !f && t !== "pages" && v(s) && o.push(`page ${i + 1}: 混合或缺少逻辑表来源,已保留独立 Sheet,未猜测合并内容`);
250
- const u = n[n.length - 1];
251
- f && u?.continuous && u.tableId === h.id ? u.pages.push({ page: s, index: i }) : n.push({ pages: [{ page: s, index: i }], continuous: f, ...f ? { tableId: h.id, title: h.title } : {}, ...l?.flow ? { flow: !0, title: l.title } : {} });
277
+ throw new Error(`page ${n + 1}: continuous Excel 需要完整、单一的逻辑表来源;自由布局请使用 sheetMode: 'pages'`);
278
+ const d = h !== void 0 && (t === "continuous" || h.wide);
279
+ !d && t !== "pages" && v(s) && o.push(`page ${n + 1}: 混合或缺少逻辑表来源,已保留独立 Sheet,未猜测合并内容`);
280
+ const u = r[r.length - 1];
281
+ d && u?.continuous && u.tableId === h.id ? u.pages.push({ page: s, index: n }) : r.push({ pages: [{ page: s, index: n }], continuous: d, ...d ? { tableId: h.id, title: h.title } : {}, ...l?.flow ? { flow: !0, title: l.title } : {} });
252
282
  }
253
- return n;
254
- }
255
- function C(e, t, o) {
256
- return !e || e.length === t.length && e.every((n, r) => o(n, t[r]));
257
- }
258
- function ce(e, t, o, n) {
259
- const r = e.table, a = t.columns.map((l) => l.size), i = C(n.keys, r.columnKeys, (l, c) => l === c), s = C(n.widths, a, (l, c) => Math.abs(l - c) <= 1e-3);
260
- if (r.columnKeys.length !== a.length || !i || !s)
261
- throw new Error(`page ${o + 1}: 连续 Excel 逻辑表 ${r.id} 的列结构或列宽不一致`);
262
- if (n.keys ??= r.columnKeys, n.widths ??= a, r.role === "header") {
263
- if (r.rowIndex !== -1) throw new Error(`page ${o + 1}: 连续 Excel 表头 rowIndex 必须为 -1`);
264
- n.headerSeen = !0;
283
+ return r;
284
+ }
285
+ function k(e, t, o) {
286
+ return !e || e.length === t.length && e.every((r, i) => o(r, t[i]));
287
+ }
288
+ function we(e, t, o, r) {
289
+ const i = e.table, a = t.columns.map((l) => l.size), n = k(r.keys, i.columnKeys, (l, c) => l === c), s = k(r.widths, a, (l, c) => Math.abs(l - c) <= 1e-3);
290
+ if (i.columnKeys.length !== a.length || !n || !s)
291
+ throw new Error(`page ${o + 1}: 连续 Excel 逻辑表 ${i.id} 的列结构或列宽不一致`);
292
+ if (r.keys ??= i.columnKeys, r.widths ??= a, i.role === "header") {
293
+ if (i.rowIndex !== -1) throw new Error(`page ${o + 1}: 连续 Excel 表头 rowIndex 必须为 -1`);
294
+ r.headerSeen = !0;
265
295
  } else {
266
- if (!["body", "group-header", "subtotal", "grand-total"].includes(r.role) || r.rowIndex !== n.expectedRow)
267
- throw new Error(`page ${o + 1}: 连续 Excel 逻辑行来源不连续或重复(期望 ${n.expectedRow})`);
268
- n.expectedRow += t.rows.length;
296
+ if (!["body", "group-header", "subtotal", "grand-total"].includes(i.role) || i.rowIndex !== r.expectedRow)
297
+ throw new Error(`page ${o + 1}: 连续 Excel 逻辑行来源不连续或重复(期望 ${r.expectedRow})`);
298
+ r.expectedRow += t.rows.length;
269
299
  }
270
300
  }
271
- function he(e, t) {
301
+ function pe(e, t) {
272
302
  const o = { expectedRow: 0, headerSeen: !1 };
273
- for (const { page: n, index: r } of e.pages)
274
- for (const a of n.components) {
275
- const i = t.get(a);
276
- a.table && i && ce(a, i, r, o);
303
+ for (const { page: r, index: i } of e.pages)
304
+ for (const a of r.components) {
305
+ const n = t.get(a);
306
+ a.table && n && we(a, n, i, o);
277
307
  }
278
308
  if (!o.headerSeen) throw new Error("连续 Excel 逻辑表缺少明确表头来源");
279
309
  }
280
- function de(e, t, o) {
281
- let n = (e?.replace(/[\\/*?:[\]]/g, " ").replace(/\s+/g, " ").trim() || `Sheet${t + 1}`).slice(0, 31).replace(/^'+|'+$/g, "").trim() || `Sheet${t + 1}`;
282
- n.toLowerCase() === "history" && (n += " 报表");
283
- let r = n, a = 1;
284
- for (; o.has(r.toLowerCase()); ) {
285
- const i = ` (${++a})`;
286
- r = n.slice(0, 31 - i.length) + i;
310
+ function xe(e, t, o) {
311
+ let r = (e?.replace(/[\\/*?:[\]]/g, " ").replace(/\s+/g, " ").trim() || `Sheet${t + 1}`).slice(0, 31).replace(/^'+|'+$/g, "").trim() || `Sheet${t + 1}`;
312
+ r.toLowerCase() === "history" && (r += " 报表");
313
+ let i = r, a = 1;
314
+ for (; o.has(i.toLowerCase()); ) {
315
+ const n = ` (${++a})`;
316
+ i = r.slice(0, 31 - n.length) + n;
287
317
  }
288
- return o.add(r.toLowerCase()), r;
318
+ return o.add(i.toLowerCase()), i;
289
319
  }
290
- function fe(e) {
320
+ function Me(e) {
291
321
  const t = /* @__PURE__ */ new Set();
292
- function o(n, r, a, i) {
293
- return n <= r ? n : (t.has(a) || (e.push(i), t.add(a)), r);
322
+ function o(r, i, a, n) {
323
+ return r <= i ? r : (t.has(a) || (e.push(n), t.add(a)), i);
294
324
  }
295
325
  return {
296
- column: (n) => o(n, 255, "column", "Excel 单列宽度上限为 255 字符,超宽列已收敛至 255;单元格值完整保留,显示范围可能受限"),
297
- row: (n) => o(n, 409, "row", "Excel 行高上限为 409pt,超高行已收敛至 409pt;单元格值完整保留,显示范围可能受限")
326
+ column: (r) => o(r, 255, "column", "Excel 单列宽度上限为 255 字符,超宽列已收敛至 255;单元格值完整保留,显示范围可能受限"),
327
+ row: (r) => o(r, 409, "row", "Excel 行高上限为 409pt,超高行已收敛至 409pt;单元格值完整保留,显示范围可能受限")
298
328
  };
299
329
  }
300
- async function ge(e, t) {
301
- const o = e.flow ? ee(e.pages, e.continuous).map((i) => ({ comp: i, pageIndex: e.pages[0].index })) : e.pages.flatMap(({ page: i, index: s }, l) => i.components.filter((c) => !e.continuous || (c.pageAnchor !== "header" || l === 0) && (c.pageAnchor !== "footer" || l === e.pages.length - 1)).map((c) => ({ comp: c, pageIndex: s }))), n = /* @__PURE__ */ new Map();
302
- let r = 1, a = 0;
303
- for (const { comp: i } of o)
304
- if (i.grid) {
305
- const s = A(i.grid, i.widthMm, i.heightMm);
306
- n.set(i, s), r = Math.max(r, s.columns.length);
330
+ async function Ee(e, t) {
331
+ const o = e.flow ? se(e.pages, e.continuous).map((n) => ({ comp: n, pageIndex: e.pages[0].index })) : e.pages.flatMap(({ page: n, index: s }, l) => n.components.filter((c) => !e.continuous || (c.pageAnchor !== "header" || l === 0) && (c.pageAnchor !== "footer" || l === e.pages.length - 1)).map((c) => ({ comp: c, pageIndex: s }))), r = /* @__PURE__ */ new Map();
332
+ let i = 1, a = 0;
333
+ for (const { comp: n } of o)
334
+ if (n.grid) {
335
+ const s = F(n.grid, n.widthMm, n.heightMm);
336
+ r.set(n, s), i = Math.max(i, s.columns.length);
307
337
  const l = t(s.cells.length);
308
338
  l && await l;
309
- } else i.kind === "text" && (a = Math.max(a, i.widthMm));
310
- if (r > 16384) throw new Error("Excel 最多支持 16384 列,无法无损导出此报表");
311
- return { components: o, grids: n, columnCount: r, textWidthMm: a };
312
- }
313
- function ue(e, t, o) {
314
- const { page: n, index: r } = e.pages[0], a = t !== void 0 && t !== "auto";
315
- return (e.continuous || v(n)) && !a ? {} : { pageSetup: {
316
- paperSize: ie(n, t, r, o),
317
- orientation: n.pageWidthMm > n.pageHeightMm ? "landscape" : "portrait",
339
+ } else n.kind === "text" && (a = Math.max(a, n.widthMm));
340
+ if (i > 16384) throw new Error("Excel 最多支持 16384 列,无法无损导出此报表");
341
+ return { components: o, grids: r, columnCount: i, textWidthMm: a };
342
+ }
343
+ function be(e, t, o) {
344
+ const { page: r, index: i } = e.pages[0], a = t !== void 0 && t !== "auto";
345
+ return (e.continuous || v(r)) && !a ? {} : { pageSetup: {
346
+ paperSize: he(r, t, i, o),
347
+ orientation: r.pageWidthMm > r.pageHeightMm ? "landscape" : "portrait",
318
348
  fitToPage: !0,
319
349
  ...e.continuous ? { fitToWidth: 1, fitToHeight: 0 } : {}
320
350
  } };
321
351
  }
322
- function me(e) {
352
+ function ye(e) {
323
353
  const t = M(e.borderColor ?? e.lineColor), o = { style: "thin", ...t ? { color: { argb: t } } : {} };
324
354
  return {
325
355
  ...e.borderTop !== !1 ? { top: o } : {},
@@ -328,80 +358,82 @@ function me(e) {
328
358
  ...e.borderRight !== !1 ? { right: o } : {}
329
359
  };
330
360
  }
331
- function we(e, t) {
361
+ function Se(e, t) {
332
362
  e.alignment = { horizontal: t.align ?? "left", vertical: t.verticalAlign ?? "middle", wrapText: !0 };
333
363
  const o = M(t.backgroundColor);
334
- o && (e.fill = { type: "pattern", pattern: "solid", fgColor: { argb: o } }), e.border = me(t), I(e, t);
364
+ o && (e.fill = { type: "pattern", pattern: "solid", fgColor: { argb: o } }), e.border = ye(t), z(e, t);
335
365
  }
336
- function pe(e, t) {
337
- for (const [o, n] of t.columns.entries()) {
338
- const r = e.sheet.getColumn(o + 1), a = e.limits.column($(n.size));
339
- (r.width == null || r.width < a) && (r.width = a);
366
+ function ve(e, t) {
367
+ for (const [o, r] of t.columns.entries()) {
368
+ const i = e.sheet.getColumn(o + 1), a = e.limits.column(A(r.size));
369
+ (i.width == null || i.width < a) && (i.width = a);
340
370
  }
341
371
  }
342
- function xe(e, t, o) {
343
- for (const [n, r] of t.rows.entries()) {
344
- const a = e.sheet.getRow(o + n), i = e.limits.row(r.size * W);
345
- (a.height == null || a.height < i) && (a.height = i);
372
+ function Ce(e, t, o) {
373
+ for (const [r, i] of t.rows.entries()) {
374
+ const a = e.sheet.getRow(o + r), n = e.limits.row(i.size * W);
375
+ (a.height == null || a.height < n) && (a.height = n);
346
376
  }
347
377
  }
348
- function Me(e, t, o, n) {
349
- const r = Math.max(1, Math.min(t.cell.colSpan ?? 1, o.columns.length - t.ci)), a = Math.max(1, Math.min(t.cell.rowSpan ?? 1, o.rows.length - t.ri));
350
- (r > 1 || a > 1) && e.mergeCells(n + t.ri, t.ci + 1, n + t.ri + a - 1, t.ci + r);
351
- }
352
- async function Ee(e, t, o, n) {
353
- if (n + o.rows.length - 1 > 1048576) throw new Error("Excel 最多支持 1048576 行,无法无损导出此报表");
354
- xe(e, o, n);
355
- for (const r of o.cells) {
356
- const a = e.sheet.getCell(n + r.ri, r.ci + 1);
357
- re(a, r.cell, e.valueMode, e.warnings);
358
- const i = U(r.cell, t.style);
359
- i && (w(i.richText.map((c) => c.text).join(""), a.address), a.value = i);
378
+ function ke(e, t, o, r) {
379
+ const i = Math.max(1, Math.min(t.cell.colSpan ?? 1, o.columns.length - t.ci)), a = Math.max(1, Math.min(t.cell.rowSpan ?? 1, o.rows.length - t.ri));
380
+ (i > 1 || a > 1) && e.mergeCells(r + t.ri, t.ci + 1, r + t.ri + a - 1, t.ci + i);
381
+ }
382
+ async function Be(e, t, o, r) {
383
+ if (r + o.rows.length - 1 > 1048576) throw new Error("Excel 最多支持 1048576 行,无法无损导出此报表");
384
+ Ce(e, o, r);
385
+ for (const i of o.cells) {
386
+ const a = e.sheet.getCell(r + i.ri, i.ci + 1);
387
+ de(a, i.cell, e.valueMode, e.warnings);
388
+ const n = Y(i.cell, t.style);
389
+ n && (p(n.richText.map((c) => c.text).join(""), a.address), a.value = n);
360
390
  const s = t.grid?.paddingMm ?? 0.5;
361
- for (const c of r.cell.children ?? [])
362
- S(c) && !c.grid && e.images.write(e.sheet, c, n + r.ri, { leftMm: r.xMm + s + (r.cell.indentMm ?? 0) + c.leftMm, offsetMm: s + c.topMm });
363
- we(a, m(t.style, r.cell.style)), r.cell.indentMm && (a.alignment = { ...a.alignment, indent: Math.min(250, Math.max(1, Math.round(r.cell.indentMm / 2.5))) }), Me(e.sheet, r, o, n);
391
+ e.dataBars(e.sheet, i, r + i.ri, s);
392
+ for (const c of i.cell.children ?? [])
393
+ S(c) && !c.grid && e.images.write(e.sheet, c, r + i.ri, { leftMm: i.xMm + s + (i.cell.indentMm ?? 0) + c.leftMm, offsetMm: s + c.topMm });
394
+ Se(a, w(t.style, i.cell.style)), i.cell.indentMm && (a.alignment = { ...a.alignment, indent: Math.min(250, Math.max(1, Math.round(i.cell.indentMm / 2.5))) }), ke(e.sheet, i, o, r);
364
395
  const l = e.schedule();
365
396
  l && await l;
366
397
  }
367
- return n + o.rows.length;
398
+ return r + o.rows.length;
368
399
  }
369
- function be(e, t, o, n) {
370
- const r = Array.isArray(t.lines) && t.lines.length > 0 ? t.lines.join(`
371
- `) : t.text ?? "", a = e.sheet.getRow(o), i = a.getCell(1);
372
- t.richParagraphs?.length || w(r, i.address), i.value = t.richParagraphs?.length ? R(t.richParagraphs, t.style) : r, typeof i.value == "object" && i.value && "richText" in i.value && w(i.value.richText.map((l) => l.text).join(""), i.address), i.alignment = { horizontal: t.style?.align ?? "left", vertical: t.style?.verticalAlign ?? "middle", wrapText: !0 };
400
+ function $e(e, t, o, r) {
401
+ const i = Array.isArray(t.lines) && t.lines.length > 0 ? t.lines.join(`
402
+ `) : t.text ?? "", a = e.sheet.getRow(o), n = a.getCell(1);
403
+ t.richParagraphs?.length || p(i, n.address), n.value = t.richParagraphs?.length ? P(t.richParagraphs, t.style) : i, typeof n.value == "object" && n.value && "richText" in n.value && p(n.value.richText.map((l) => l.text).join(""), n.address), n.alignment = { horizontal: t.style?.align ?? "left", vertical: t.style?.verticalAlign ?? "middle", wrapText: !0 };
373
404
  const s = M(t.style?.backgroundColor);
374
- return s && (i.fill = { type: "pattern", pattern: "solid", fgColor: { argb: s } }), I(i, t.style), n > 1 && e.sheet.mergeCells(o, 1, o, n), a.height = e.limits.row(t.heightMm * W), o + 1;
405
+ return s && (n.fill = { type: "pattern", pattern: "solid", fgColor: { argb: s } }), z(n, t.style), r > 1 && e.sheet.mergeCells(o, 1, o, r), a.height = e.limits.row(t.heightMm * W), o + 1;
375
406
  }
376
- function ye(e, t, o) {
377
- const n = t + o - 1;
378
- e.views = [{ state: "frozen", ySplit: n, xSplit: 0 }], e.pageSetup.printTitlesRow = `1:${n}`;
407
+ function Ae(e, t, o) {
408
+ const r = t + o - 1;
409
+ e.views = [{ state: "frozen", ySplit: r, xSplit: 0 }], e.pageSetup.printTitlesRow = `1:${r}`;
379
410
  }
380
- async function Se(e, t, o, n) {
381
- !t.grids.size && t.textWidthMm > 0 && (e.sheet.getColumn(1).width = e.limits.column($(t.textWidthMm)));
382
- for (const i of t.grids.values()) {
383
- pe(e, i);
384
- const s = e.schedule(i.columns.length);
411
+ async function Fe(e, t, o, r) {
412
+ !t.grids.size && t.textWidthMm > 0 && (e.sheet.getColumn(1).width = e.limits.column(A(t.textWidthMm)));
413
+ for (const n of t.grids.values()) {
414
+ ve(e, n);
415
+ const s = e.schedule(n.columns.length);
385
416
  s && await s;
386
417
  }
387
- let r = 1, a = !1;
388
- for (const { comp: i, pageIndex: s } of t.components) {
389
- const l = o && i.table?.role === "header";
418
+ let i = 1, a = !1;
419
+ for (const { comp: n, pageIndex: s } of t.components) {
420
+ const l = o && n.table?.role === "header";
390
421
  if (l && a) continue;
391
- if (r > 1048576) throw new Error("Excel 最多支持 1048576 行,无法无损导出此报表");
392
- const c = t.grids.get(i);
422
+ if (i > 1048576) throw new Error("Excel 最多支持 1048576 行,无法无损导出此报表");
423
+ const c = t.grids.get(n);
393
424
  if (c)
394
- l && (ye(e.sheet, r, c.rows.length), a = !0), r = await Ee(e, i, c, r);
395
- else if (i.kind === "text")
396
- r = be(e, i, r, t.columnCount);
397
- else if (S(i)) {
398
- const h = G(i, o), f = n.write(e.sheet, i, h?.row ?? r, h);
399
- h || (r = f);
425
+ l && (Ae(e.sheet, i, c.rows.length), a = !0), i = await Be(e, n, c, i);
426
+ else if (n.kind === "text")
427
+ i = $e(e, n, i, t.columnCount);
428
+ else if (S(n)) {
429
+ const h = U(n, o), d = r.write(e.sheet, n, h?.row ?? i, h);
430
+ h || (i = d);
400
431
  } else
401
- e.warnings.push(`page ${s + 1} ${i.nid ?? i.kind}: 组件类型 ${i.kind} 暂不支持 xlsx 导出,已跳过`);
432
+ e.warnings.push(`page ${s + 1} ${n.nid ?? n.kind}: 组件类型 ${n.kind} 暂不支持 xlsx 导出,已跳过`);
402
433
  }
403
434
  }
404
- function ve(e) {
435
+ function Pe(e) {
436
+ if (e.maxDataBars !== void 0 && (!Number.isSafeInteger(e.maxDataBars) || e.maxDataBars < 0 || e.maxDataBars > 1e5)) throw new Error("xlsx maxDataBars 必须是 0–100000 的整数");
405
437
  if (e.valueMode !== void 0 && e.valueMode !== "text" && e.valueMode !== "raw")
406
438
  throw new Error("xlsx valueMode 必须是 text 或 raw");
407
439
  if (e.paperSize !== void 0 && e.paperSize !== "auto" && !Object.prototype.hasOwnProperty.call(b, e.paperSize))
@@ -409,42 +441,44 @@ function ve(e) {
409
441
  if (e.sheetMode !== void 0 && !["auto", "pages", "continuous"].includes(e.sheetMode))
410
442
  throw new Error("xlsx sheetMode 必须是 auto、pages 或 continuous");
411
443
  }
412
- async function Pe(e, t = {}) {
413
- ve(t), E(t.signal);
414
- const o = t.assetRegistry || t.assetRenderers ? await _(e, { ...t, format: "xlsx" }) : { plan: e, diagnostics: [] };
444
+ async function je(e, t = {}) {
445
+ Pe(t), E(t.signal);
446
+ const o = t.assetRegistry || t.assetRenderers ? await K(e, { ...t, format: "xlsx" }) : { plan: e, diagnostics: [] };
415
447
  e = o.plan;
416
- const n = [...o.diagnostics, ...D(e, "xlsx", t)], r = new j.Workbook(), a = [], i = V(r, t, a), s = fe(a), l = le(e, t.sheetMode, a), c = /* @__PURE__ */ new Set(), h = O(t);
417
- for (const [u, d] of l.entries()) {
418
- const g = await ge(d, h);
419
- d.continuous && !d.flow && he(d, g.grids);
420
- const p = d.pages[0].page, x = t.sheetName?.(u) ?? de(d.title, u, c);
421
- c.add(x.toLowerCase());
422
- const z = r.addWorksheet(x, ue(d, t.paperSize, a)), B = t.valueMode ?? (v(p) || d.continuous || d.flow ? "raw" : "text");
423
- E(t.signal), await Se({ sheet: z, warnings: a, limits: s, valueMode: B, schedule: h, images: i }, g, d.continuous, i), await N(t, u + 1, l.length);
448
+ const r = [...o.diagnostics, ...J(e, "xlsx", t)];
449
+ await Q(e, t.maxDataBars ?? 1e4, t);
450
+ const i = new _.Workbook(), a = [], n = re(i, t, a), s = [], l = q(n, t.maxDataBars ?? 1e4, s), c = Me(a), h = me(e, t.sheetMode, a), d = /* @__PURE__ */ new Set(), u = B(t);
451
+ for (const [g, m] of h.entries()) {
452
+ const x = await Ee(m, u);
453
+ m.continuous && !m.flow && pe(m, x.grids);
454
+ const D = m.pages[0].page, C = t.sheetName?.(g) ?? xe(m.title, g, d);
455
+ d.add(C.toLowerCase());
456
+ const N = i.addWorksheet(C, be(m, t.paperSize, a)), O = t.valueMode ?? (v(D) || m.continuous || m.flow ? "raw" : "text");
457
+ E(t.signal), await Fe({ sheet: N, warnings: a, limits: c, valueMode: O, schedule: u, images: n, dataBars: l }, x, m.continuous, n), await L(t, g + 1, h.length);
424
458
  }
425
459
  E(t.signal);
426
- const f = await r.xlsx.writeBuffer();
427
- return E(t.signal), { workbook: r, buffer: f, warnings: a, diagnostics: n };
460
+ const f = await i.xlsx.writeBuffer();
461
+ return E(t.signal), { workbook: i, buffer: f, warnings: a, diagnostics: r, ...s.length ? { notes: s } : {} };
428
462
  }
429
463
  export {
430
- Le as bindExcelTemplate,
431
- je as createExcelBindingDocument,
432
- Ge as createExcelBindingSession,
433
- He as createExcelRegionBindingDocument,
434
- _e as createExcelRegionBindingSession,
435
- De as excelBindingCellRange,
436
- Ue as excelBindingRowRange,
437
- Ke as getExcelSheetWindow,
438
- ze as importExcelTemplate,
439
- Be as inspectExcelWorkbook,
440
- Ne as openExcelWorkbook,
441
- Xe as parseExcelBindingSession,
442
- Je as parseExcelRegionBindingSession,
443
- Pe as renderPlanToXlsx,
444
- Ve as validateExcelBindingFields,
445
- qe as validateExcelBindingRecipe,
446
- Qe as validateExcelBindingRegions,
447
- Ye as validateExcelRegionBindings,
448
- Ze as validateExcelRegionFields,
449
- et as validateExcelRegionGeometry
464
+ Je as bindExcelTemplate,
465
+ Ve as createExcelBindingDocument,
466
+ qe as createExcelBindingSession,
467
+ Qe as createExcelRegionBindingDocument,
468
+ Ye as createExcelRegionBindingSession,
469
+ Ze as excelBindingCellRange,
470
+ et as excelBindingRowRange,
471
+ tt as getExcelSheetWindow,
472
+ _e as importExcelTemplate,
473
+ Ue as inspectExcelWorkbook,
474
+ Xe as openExcelWorkbook,
475
+ rt as parseExcelBindingSession,
476
+ nt as parseExcelRegionBindingSession,
477
+ je as renderPlanToXlsx,
478
+ it as validateExcelBindingFields,
479
+ ot as validateExcelBindingRecipe,
480
+ at as validateExcelBindingRegions,
481
+ st as validateExcelRegionBindings,
482
+ lt as validateExcelRegionFields,
483
+ ct as validateExcelRegionGeometry
450
484
  };