@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,4879 @@
1
+ import { computed as N, unref as u, ref as Z, onScopeDispose as Ie, watch as pe, getCurrentScope as ka, shallowRef as ve, nextTick as Be, defineComponent as ye, openBlock as $, createElementBlock as C, createElementVNode as p, createVNode as ne, createTextVNode as ce, toDisplayString as x, Fragment as be, renderList as he, createCommentVNode as j, withModifiers as st, withDirectives as xt, withKeys as Ea, vModelText as kt, createBlock as Ce, normalizeClass as ke, renderSlot as lt, getCurrentInstance as Xt, onMounted as Et, onUnmounted as $t, createStaticVNode as $a, isRef as zn, inject as xn, provide as Ca, watchEffect as Ia, normalizeStyle as ze, createSlots as Pa, withCtx as Nt } from "vue";
2
+ import { resolveGridLayout as Sa, createPageViewportRenderer as Ra, renderPage as Ln, renderPlanToImages as Ma, calculateReportSelection as Ta, ReportCalculationError as Oa, createReportCellResolver as bt, getReportEditSession as Yt, ReportCellEditError as Me, reportCellEditKey as Le, summarizeReportCellEdits as kn, createReportCellEditBatch as Ut, parseReportCellFieldInput as Da, applyReportEditResult as Aa, applyReportCellEditBatch as Fa, getReportCellContext as Ue, validateReportCellFieldDefinition as za, parseReportClipboard as La, formatReportClipboard as qa, inspectOutputCapabilities as Na, resolvePlanAssets as Ba, paginateTemplate as Ka, validateRenderPlan as ja, renderPlanToCanvas as Wa } from "@agile-team/mach-report";
3
+ import { c as qn, m as Ha, a as En, R as Ua } from "./drill-CKW3Xtfa.js";
4
+ import { f as Zt, b as fe, w as Te, n as $n, a as ot } from "./progress-Hc2vxoCs.js";
5
+ import { b as Va, s as Nn, p as Ga, i as Bn, M as Ge, u as Ja, g as Xa, n as Ya, h as Za, r as Qa, j as _a, t as eo, R as to } from "./config-XQ4qrQ7Q.js";
6
+ import { a as no, s as ao, c as oo } from "./prepared-CARicKYh.js";
7
+ import { t as Cn } from "./sha256-DTG-Gq8i.js";
8
+ import { i as ro, a as so } from "./component-tree-Ca6YYfHq.js";
9
+ import { a as re, _ as we } from "./_plugin-vue_export-helper-8SL1F89S.js";
10
+ import { r as Qt } from "./grid-geometry-BNptEcMm.js";
11
+ import { b as lo, c as io, M as uo } from "./injection-keys-e85udZCp.js";
12
+ function Kn(e) {
13
+ return e == null ? [] : Array.isArray(e) ? e.map(String).filter((t) => t !== "") : String(e).split(",").map((t) => t.trim()).filter((t) => t !== "");
14
+ }
15
+ function vu(e) {
16
+ return Kn(e).join(",");
17
+ }
18
+ class Bt extends Error {
19
+ constructor(t) {
20
+ super(t), this.name = "PlanLoadError";
21
+ }
22
+ }
23
+ function bu(e = {}) {
24
+ const { baseUrl: t = "", headers: n, credentials: a, timeoutMs: o = 3e4 } = e, r = t.replace(/\/+$/, "");
25
+ return async ({ url: s, method: l, params: i, signal: c }) => {
26
+ let f = `${r}${s}`;
27
+ if (i && Object.keys(i).length > 0) {
28
+ const v = f.indexOf("#"), L = v >= 0 ? f.slice(v) : "", b = v >= 0 ? f.slice(0, v) : f, R = b.indexOf("?"), A = R >= 0 ? b.slice(0, R) : b, h = new URLSearchParams(R >= 0 ? b.slice(R + 1) : "");
29
+ for (const [M, B] of Object.entries(i)) h.set(M, B);
30
+ f = `${A}?${h}${L}`;
31
+ }
32
+ const m = (v, L) => {
33
+ const b = new Bt(v);
34
+ return Object.defineProperty(b, "cause", { value: L, configurable: !0, writable: !0 }), b;
35
+ };
36
+ if (c?.aborted)
37
+ throw m(`请求已取消: ${s}`, c.reason);
38
+ const d = new AbortController();
39
+ let E;
40
+ const k = () => {
41
+ d.signal.aborted || (E = "external", d.abort(c?.reason));
42
+ };
43
+ c?.addEventListener("abort", k, { once: !0 });
44
+ const w = setTimeout(() => {
45
+ d.signal.aborted || (E = "timeout", d.abort());
46
+ }, o);
47
+ try {
48
+ const v = await fetch(f, {
49
+ method: l.toUpperCase(),
50
+ headers: { Accept: "application/json", ...n },
51
+ credentials: a,
52
+ signal: d.signal
53
+ });
54
+ if (!v.ok)
55
+ throw new Bt(`HTTP ${v.status} ${s}`);
56
+ return await v.json();
57
+ } catch (v) {
58
+ throw E === "timeout" ? m(`请求超时(${o}ms): ${s}`, v) : E === "external" ? m(`请求已取消: ${s}`, v) : v instanceof Bt ? v : m(`请求失败(${s}): ${v instanceof Error ? v.message : String(v)}`, v);
59
+ } finally {
60
+ clearTimeout(w), c?.removeEventListener("abort", k);
61
+ }
62
+ };
63
+ }
64
+ function co(e, t, n = {}) {
65
+ const a = n.pxPerMm ?? 3.7795275590551185, o = N(() => Math.max(0, u(n.gapPx) ?? 18)), r = Z(0), s = Z(800), l = N(() => {
66
+ const b = e.value?.pages ?? [];
67
+ return qn(b.map((R) => R.pageHeightMm * a), o.value);
68
+ }), i = N(() => {
69
+ let b = 0;
70
+ for (const R of e.value?.pages ?? []) b = Math.max(b, R.pageWidthMm * a);
71
+ return { w: b, h: l.value.totalHeightPx };
72
+ }), c = N(() => l.value.window(
73
+ s.value / t.value,
74
+ r.value / t.value,
75
+ u(n.overscan) ?? 1
76
+ )), f = N(() => {
77
+ const b = e.value;
78
+ if (!b) return [];
79
+ const { start: R, end: A } = c.value;
80
+ return b.pages.slice(R, A + 1).map((h, M) => ({ page: h, index: R + M }));
81
+ });
82
+ let m = 0, d = !1, E;
83
+ function k(b) {
84
+ b && (r.value = b.scrollTop, s.value = b.clientHeight || 800);
85
+ }
86
+ function w(b, R) {
87
+ b.scrollTop = l.value.offsetAt(R) * t.value, E = { top: b.scrollTop, index: R, zoom: t.value, geometry: l.value }, k(b);
88
+ }
89
+ function v(b, R) {
90
+ return (A) => {
91
+ m || d || (m = requestAnimationFrame(() => {
92
+ if (m = 0, d || (k(A), R.value <= 0)) return;
93
+ if (E && E.top === A.scrollTop && E.zoom === t.value && E.geometry === l.value) {
94
+ b.value = Math.min(R.value, E.index + 1);
95
+ return;
96
+ }
97
+ E = void 0;
98
+ const h = Math.max(0, A.scrollTop + 32) / t.value;
99
+ b.value = Math.min(R.value, l.value.pageAt(h) + 1);
100
+ }));
101
+ };
102
+ }
103
+ function L() {
104
+ d = !0, m && cancelAnimationFrame(m), m = 0;
105
+ }
106
+ return Ie(L), {
107
+ contentSize: i,
108
+ windowRange: c,
109
+ visiblePages: f,
110
+ makeScrollHandler: v,
111
+ refreshViewport: k,
112
+ scrollToPage: w,
113
+ pageOffsetPx: (b) => l.value.offsetAt(b),
114
+ destroy: L
115
+ };
116
+ }
117
+ const gt = 96 / 25.4;
118
+ function fo(e) {
119
+ const t = /* @__PURE__ */ new WeakMap(), n = Z(0);
120
+ let a, o = 0, r = 0, s = !1, l = 0;
121
+ function i() {
122
+ o++, r && cancelAnimationFrame(r), r = 0;
123
+ }
124
+ function c(h, M, B, I) {
125
+ return !s && M === o && e.plan.value === B && e.root.value === I && I.contains(h.holder) && Number(h.holder.dataset.page) === h.index + 1;
126
+ }
127
+ function f(h) {
128
+ const { holder: M, page: B } = h;
129
+ t.delete(M), M.style.width = `${B.pageWidthMm * gt}px`, M.style.height = `${B.pageHeightMm * gt}px`, M.setAttribute("aria-busy", "true");
130
+ const I = M.ownerDocument.createElement("div");
131
+ I.className = "mrp-page-loading";
132
+ const z = M.ownerDocument.createElement("span");
133
+ z.textContent = e.loading(), z.style.transform = `scale(${1 / Math.max(1e-4, e.zoom())})`, I.append(z), M.replaceChildren(I);
134
+ }
135
+ function m(h) {
136
+ const M = t.get(h.holder);
137
+ if (!M || M.page !== h.page || M.element.parentElement !== h.holder) return !1;
138
+ const B = !!M.element.querySelector(".mrp-cell-editor-host");
139
+ return M.windowed !== v(h.page) && !B ? !1 : (L(h.holder, M), M.query !== e.query() && !B && (e.clear(M.element), e.highlight(M.element), M.query = e.query()), !0);
140
+ }
141
+ function d(h, M, B, I) {
142
+ if (c(h, M, B, I))
143
+ try {
144
+ const z = v(h.page), H = z ? Ra(h.page, 96, {}, h.holder.ownerDocument) : void 0, ae = H?.element ?? Ln(h.page, 96, {}, h.holder.ownerDocument);
145
+ if (e.highlight(ae), !c(h, M, B, I)) return;
146
+ h.holder.replaceChildren(ae), h.holder.removeAttribute("aria-busy");
147
+ const oe = { page: h.page, element: ae, query: e.query(), viewport: H, windowed: z };
148
+ t.set(h.holder, oe), L(h.holder, oe), e.mounted(h.holder), e.ready();
149
+ } catch (z) {
150
+ if (!c(h, M, B, I)) return;
151
+ h.holder.removeAttribute("aria-busy");
152
+ const H = h.holder.ownerDocument.createElement("div");
153
+ H.className = "mrp-page-render-error", H.setAttribute("role", "alert"), H.textContent = z instanceof Error ? z.message : String(z), h.holder.replaceChildren(H), e.error(z);
154
+ }
155
+ }
156
+ function E(h, M, B, I) {
157
+ h.length && (r = requestAnimationFrame(() => {
158
+ if (M !== o || s) return;
159
+ r = 0;
160
+ const z = h.shift();
161
+ z && d(z, M, B, I), M === o && e.plan.value === B && e.root.value === I && E(h, M, B, I);
162
+ }));
163
+ }
164
+ function k() {
165
+ i();
166
+ const h = e.plan.value, M = e.root.value;
167
+ if (s || !h || !M) {
168
+ a = void 0;
169
+ return;
170
+ }
171
+ const B = o, I = a?.plan === h ? a.index : e.priority();
172
+ a = void 0;
173
+ const z = [];
174
+ M.querySelectorAll(".mrp-page-holder").forEach((oe) => {
175
+ const ue = Number(oe.dataset.page) - 1, g = h.pages[ue];
176
+ if (!g) return;
177
+ const T = { holder: oe, page: g, index: ue };
178
+ m(T) || (f(T), z.push(T));
179
+ });
180
+ const H = z.findIndex((oe) => oe.index === I), ae = H < 0 ? void 0 : z.splice(H, 1)[0];
181
+ ae && d(ae, B, h, M), e.ready(), E(z, B, h, M);
182
+ }
183
+ function w(h) {
184
+ s || !e.plan.value || (a = { plan: e.plan.value, index: h }, n.value++);
185
+ }
186
+ pe([e.plan, e.root, e.pages, e.priority, e.focusToken, () => e.editorToken?.(), e.query, e.zoom, e.loading, () => e.windowing?.(), n], k, { flush: "post", immediate: !0 });
187
+ function v(h) {
188
+ return !e.viewport?.value?.clientWidth || e.windowing?.() === !1 || e.query().trim() || h.layout !== "wide" ? !1 : h.components.reduce((M, B) => M + (B.grid?.cells.reduce((I, z) => I + z.length, 0) ?? 0), 0) > 1e3;
189
+ }
190
+ function L(h, M) {
191
+ const B = e.viewport?.value;
192
+ if (!B || !M.viewport) return;
193
+ const I = B.getBoundingClientRect(), z = h.getBoundingClientRect(), H = gt * e.zoom(), ae = h.querySelector(".mrp-cell-editor-host")?.closest("td[data-mr-row-index]") ?? h.ownerDocument.activeElement?.closest("td[data-mr-row-index]"), oe = ae?.closest("[data-mr-component-index]"), ue = ae && oe && h.contains(ae) ? { componentIndex: Number(oe.dataset.mrComponentIndex), rowIndex: Number(ae.dataset.mrRowIndex), columnIndex: Number(ae.dataset.mrColumnIndex) } : void 0;
194
+ M.viewport.update({
195
+ leftMm: (I.left - z.left) / H,
196
+ topMm: (I.top - z.top) / H,
197
+ widthMm: B.clientWidth / H,
198
+ heightMm: B.clientHeight / H
199
+ }, ue) && e.mounted(h);
200
+ }
201
+ function b() {
202
+ s || l || (l = requestAnimationFrame(() => {
203
+ l = 0, !s && e.root.value?.querySelectorAll(".mrp-page-holder").forEach((h) => {
204
+ const M = t.get(h);
205
+ M && L(h, M);
206
+ });
207
+ }));
208
+ }
209
+ function R(h) {
210
+ const M = e.viewport?.value, B = e.plan.value?.pages[h.pageIndex], I = e.root.value?.querySelector(`[data-page="${h.pageIndex + 1}"]`), z = B?.components[h.componentIndex];
211
+ if (!M || !I || !z?.grid) return;
212
+ const H = t.get(I);
213
+ if (!H?.viewport) return;
214
+ const ae = Sa(z.grid, z.widthMm, z.heightMm).cells.find((S) => S.ri === h.rowIndex && S.ci === h.columnIndex);
215
+ if (!ae) return;
216
+ const oe = M.getBoundingClientRect(), ue = I.getBoundingClientRect(), g = gt * e.zoom(), T = ue.left + (z.leftMm + ae.xMm) * g, y = ue.top + (z.topMm + ae.yMm) * g;
217
+ M.scrollLeft += A(T, T + ae.widthMm * g, oe.left, oe.left + M.clientWidth), M.scrollTop += A(y, y + ae.heightMm * g, oe.top, oe.top + M.clientHeight), L(I, H);
218
+ }
219
+ function A(h, M, B, I) {
220
+ return h < B + 8 ? h - B - 8 : M > I - 8 ? Math.min(h - B - 8, M - I + 8) : 0;
221
+ }
222
+ return Ie(() => {
223
+ s = !0, a = void 0, i(), l && cancelAnimationFrame(l);
224
+ }), { prioritize: w, cancel: i, refreshViewport: b, reveal: R };
225
+ }
226
+ function mo(e) {
227
+ const t = Z(1), n = Z("fit");
228
+ let a = 0;
229
+ function o() {
230
+ a && cancelAnimationFrame(a), a = 0;
231
+ }
232
+ function r() {
233
+ o(), a = requestAnimationFrame(() => {
234
+ if (a = 0, n.value !== "fit") return;
235
+ const l = e();
236
+ !l?.viewport || l.viewport.clientWidth <= 48 || !Number.isFinite(l.pageWidthPx) || (t.value = Math.min(1, (l.viewport.clientWidth - 48) / Math.max(1, l.pageWidthPx)));
237
+ });
238
+ }
239
+ function s(l) {
240
+ if (l === "fit")
241
+ n.value = "fit", r();
242
+ else {
243
+ if (!Number.isFinite(l)) return;
244
+ o(), n.value = "raw", t.value = Math.min(3, Math.max(0.3, l / 100));
245
+ }
246
+ }
247
+ return ka() && Ie(o), { zoom: t, zoomMode: n, applyFitZoom: r, setZoom: s };
248
+ }
249
+ function go(e, t) {
250
+ if (![e, t].every((s) => Number.isFinite(s) && s >= 25 && s <= 600)) throw new RangeError("Calibration paper must be between 25 and 600 mm");
251
+ const n = [], a = Math.min(10, e / 5), o = Math.min(10, t / 5), r = Math.min(50, e - a * 2, t - o * 2);
252
+ n.push({ kind: "rect", leftMm: a, topMm: o, widthMm: r, heightMm: r, style: { borderColor: "#255c8c", lineWidthPt: 0.5 } });
253
+ for (let s = 0; s <= r; s += 5)
254
+ n.push({ kind: "line", leftMm: a + s, topMm: o, widthMm: 0, heightMm: s % 10 ? 2 : 3, style: { lineColor: "#255c8c", lineWidthPt: 0.5 } }), n.push({ kind: "line", leftMm: a, topMm: o + s, widthMm: s % 10 ? 2 : 3, heightMm: 0, style: { lineColor: "#255c8c", lineWidthPt: 0.5 } });
255
+ return n.push({ kind: "text", text: `${r} x ${r} mm`, leftMm: a + 4, topMm: o + r / 2 - 2, widthMm: r - 8, heightMm: 4, style: { fontSize: 7, align: "center", color: "#255c8c" } }), { schemaVersion: "print-calibration", pages: [{ pageWidthMm: e, pageHeightMm: t, components: n }] };
256
+ }
257
+ let po = 0;
258
+ function In(e, t) {
259
+ const n = new AbortController();
260
+ let a = { taskId: `mr-output-${Date.now().toString(36)}-${++po}`, kind: e, stage: e === "print" ? "print" : "encode", status: "running", cancellable: !0 };
261
+ function o() {
262
+ try {
263
+ t?.(Object.freeze({ ...a }));
264
+ } catch {
265
+ }
266
+ }
267
+ return {
268
+ controller: n,
269
+ get task() {
270
+ return a;
271
+ },
272
+ start: o,
273
+ update(r, s, l) {
274
+ n.signal.aborted || a.status !== "running" || (a = { ...a, stage: r, completed: s, total: l }, o());
275
+ },
276
+ finish(r = "completed") {
277
+ a.status === "running" && (a = { ...a, status: r, cancellable: !1 }, o(), r === "cancelled" && n.abort());
278
+ }
279
+ };
280
+ }
281
+ class $e extends Error {
282
+ constructor(t, n = "") {
283
+ super(`Print preparation failed: ${t} ${n}`), this.kind = t, this.resource = n, this.code = "print-resource", this.name = "ReportPrintResourceError";
284
+ }
285
+ }
286
+ function jn(e, t) {
287
+ const n = { ...Va, ...t };
288
+ return e instanceof $e ? e.kind === "timeout" ? n.printPrepareTimeout : e.kind === "image" ? n.printImageFailed.replace("{index}", String(e.resource)) : e.kind === "font" ? n.printFontFailed.replace("{family}", String(e.resource)) : n.printPrepareFailed : n.printPrepareFailed;
289
+ }
290
+ function vo(e, t) {
291
+ let n;
292
+ try {
293
+ n = new URL(e, t);
294
+ } catch {
295
+ throw new $e("config");
296
+ }
297
+ if (!["http:", "https:"].includes(n.protocol) || e.length > 16384) throw new $e("config");
298
+ return n.href;
299
+ }
300
+ async function bo(e, t, n, a) {
301
+ const o = t.fonts ?? [];
302
+ if (o.length > 8) throw new $e("config");
303
+ for (const r of o) {
304
+ if (fe(n), typeof r.family != "string" || !r.family.trim() || r.family.length > 256 || typeof r.source != "string") throw new $e("config");
305
+ const s = e.defaultView?.FontFace;
306
+ if (!s || !e.fonts) throw new $e("font", r.family);
307
+ try {
308
+ const { loadFontWithCache: l } = await import("./font-loader-CQZowp0I.js"), i = await l(vo(r.source, a), { signal: n });
309
+ if (!i) throw new $e("font", r.family);
310
+ const c = new s(r.family, i, { weight: r.weight, style: r.style });
311
+ await Te(c.load(), n), e.fonts.add(c);
312
+ } catch (l) {
313
+ throw fe(n), l instanceof $e ? l : new $e("font", r.family);
314
+ }
315
+ }
316
+ e.documentElement.getBoundingClientRect(), e.fonts && await Te(e.fonts.ready, n);
317
+ }
318
+ async function ho(e, t, n) {
319
+ fe(n);
320
+ try {
321
+ if (typeof e.decode == "function" ? await Te(e.decode(), n) : e.complete || await new Promise((a, o) => {
322
+ const r = () => {
323
+ e.removeEventListener("load", s), e.removeEventListener("error", l), n.removeEventListener("abort", i);
324
+ }, s = () => {
325
+ r(), a();
326
+ }, l = () => {
327
+ r(), o(new $e("image", t));
328
+ }, i = () => {
329
+ r(), o(n.reason);
330
+ };
331
+ e.addEventListener("load", s, { once: !0 }), e.addEventListener("error", l, { once: !0 }), n.addEventListener("abort", i, { once: !0 }), n.aborted ? i() : e.complete && s();
332
+ }), fe(n), e.naturalWidth <= 0 || e.naturalHeight <= 0) throw new $e("image", t);
333
+ } catch {
334
+ throw fe(n), new $e("image", t);
335
+ }
336
+ }
337
+ async function Wn(e, t = {}, n, a = document.baseURI) {
338
+ const o = t.resourceTimeoutMs ?? 15e3;
339
+ if (!Number.isSafeInteger(o) || o < 1 || o > 12e4) throw new $e("config");
340
+ const r = new AbortController(), s = Zt(n, r), l = setTimeout(() => r.abort(new $e("timeout")), o);
341
+ try {
342
+ fe(r.signal), await bo(e, t, r.signal, a);
343
+ const i = e.querySelectorAll("img");
344
+ let c = 0;
345
+ const f = async () => {
346
+ for (; c < i.length; ) {
347
+ const m = c++;
348
+ await ho(i[m], m + 1, r.signal);
349
+ }
350
+ };
351
+ await Promise.all(Array.from({ length: Math.min(i.length, 4) }, f)), fe(r.signal);
352
+ } finally {
353
+ clearTimeout(l), s(), r.abort();
354
+ }
355
+ }
356
+ const Ve = 8;
357
+ function rt() {
358
+ return new Promise((e) => setTimeout(e, 0));
359
+ }
360
+ function pt(e) {
361
+ return `p${e.pageWidthMm}x${e.pageHeightMm}`.replace(/[.+]/g, "_");
362
+ }
363
+ function ht(e) {
364
+ const t = /* @__PURE__ */ new Map();
365
+ return e.pages.forEach((o) => {
366
+ t.has(pt(o)) || t.set(pt(o), o);
367
+ }), `<!doctype html><html><head><meta charset="utf-8"><style>${`.mr-page{margin:0 auto;page-break-after:always;}
368
+ .mr-page tr{break-inside:avoid;page-break-inside:avoid;}
369
+ .mr-comp{break-inside:avoid;page-break-inside:avoid;}
370
+ ${[...t.values()].map(
371
+ (o) => `@page ${pt(o)}{size:${o.pageWidthMm}mm ${o.pageHeightMm}mm;margin:0;}`
372
+ ).join(`
373
+ `)}
374
+ body{margin:0;background:#fff;}`}</style></head><body>`;
375
+ }
376
+ function yt(e, t) {
377
+ const n = Ln(e, 96, {}, document);
378
+ n.style.page = pt(e);
379
+ const a = Ga(t);
380
+ if (a.x || a.y) {
381
+ const o = document.createElement("div");
382
+ for (o.style.cssText = `position:absolute;inset:0;transform:translate(${a.x}mm,${a.y}mm);transform-origin:top left`; n.firstChild; ) o.appendChild(n.firstChild);
383
+ n.appendChild(o);
384
+ }
385
+ return n.outerHTML;
386
+ }
387
+ function yo(e, t) {
388
+ return { head: ht(e), pageChunks: e.pages.map((n) => yt(n, t)) };
389
+ }
390
+ async function wo(e, t = {}) {
391
+ const n = {
392
+ schemaVersion: "mach-report-batch-print",
393
+ pages: e.flatMap((l) => l.pages)
394
+ };
395
+ if (n.pages.length === 0) return;
396
+ const a = Nn(t.printOptions), o = ht(n), r = document.createElement("iframe");
397
+ r.style.cssText = "position:fixed;right:0;bottom:0;width:0;height:0;border:0;visibility:hidden;", document.body.appendChild(r);
398
+ let s = !1;
399
+ try {
400
+ const l = r.contentDocument;
401
+ l.open(), l.write(o);
402
+ for (let i = 0; i < n.pages.length; i++)
403
+ fe(t.signal), l.write(yt(n.pages[i], a)), i % Ve === Ve - 1 && ($n(t, i + 1, n.pages.length), await rt());
404
+ l.write("</body></html>"), l.close(), await rt(), await Wn(l, a, t.signal), $n(t, n.pages.length, n.pages.length), r.contentWindow?.focus(), r.contentWindow?.print(), s = !0;
405
+ } catch (l) {
406
+ throw t.signal?.aborted || ot(() => t.onError?.(jn(l, t.messages))), l;
407
+ } finally {
408
+ s ? setTimeout(() => r.remove(), 6e4) : r.remove();
409
+ }
410
+ }
411
+ function Hn(e) {
412
+ return `<!doctype html><html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40"><head><meta charset="utf-8"><!--[if gte mso 9]><xml><w:WordDocument><w:View>Print</w:View><w:Zoom>100</w:Zoom></w:WordDocument></xml><![endif]-->${e.replace(/^<!doctype html><html><head>/, "")}`;
413
+ }
414
+ function hu(e) {
415
+ const { head: t, pageChunks: n } = yo(e);
416
+ return {
417
+ html: `${Hn(t)}${n.join("")}</body></html>`,
418
+ filename: "mach-report.doc"
419
+ };
420
+ }
421
+ function xo(e, t) {
422
+ let n = null, a = !1, o = !1, r = 0, s = 0;
423
+ const l = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Map();
424
+ let c = null;
425
+ const f = /* @__PURE__ */ new Map();
426
+ let m = null, d = null, E = null, k = null, w = null;
427
+ function v(P, D) {
428
+ return !o && e.value === P && r === D;
429
+ }
430
+ function L() {
431
+ if (o) return;
432
+ const P = [...i.values()].reverse().find((D) => v(D.plan, D.epoch))?.format ?? null;
433
+ P !== m && (m = P, t.onBusy?.(P));
434
+ }
435
+ function b(P, D, J) {
436
+ const V = {};
437
+ return i.set(V, { plan: P, epoch: D, format: J, run: In("export", t.onTask) }), i.get(V).run.start(), L(), V;
438
+ }
439
+ function R(P) {
440
+ i.get(P)?.run.finish(), i.delete(P), L();
441
+ }
442
+ function A() {
443
+ for (const [P, D] of f)
444
+ v(D.plan, D.epoch) || (P.close(), f.delete(P));
445
+ }
446
+ function h(P = !0) {
447
+ if (P) {
448
+ s++;
449
+ for (const D of l) D.close();
450
+ l.clear();
451
+ }
452
+ for (const D of i.values()) D.run.finish("cancelled");
453
+ c?.finish("cancelled"), r++, B(), L(), A();
454
+ }
455
+ const M = pe(e, () => h(!1), { flush: "sync" });
456
+ function B() {
457
+ n?.remove(), n = null;
458
+ }
459
+ function I() {
460
+ h(), o = !0, r++, M(), B(), A(), i.clear(), t.onPrinting?.(!1);
461
+ }
462
+ function z(P, D) {
463
+ const J = URL.createObjectURL(P);
464
+ setTimeout(() => URL.revokeObjectURL(J), 1e4);
465
+ const V = document.createElement("a");
466
+ V.href = J, V.download = D, V.click();
467
+ }
468
+ function H(P, D, J, V, te) {
469
+ J.update("download"), v(P, D) && !J.controller.signal.aborted && z(V, te);
470
+ }
471
+ async function ae(P, D, J, V, te) {
472
+ const se = P.contentDocument;
473
+ se.open(), se.write(ht(D));
474
+ for (let me = 0; me < D.pages.length; me++)
475
+ if (V.controller.signal.aborted || (se.write(yt(D.pages[me], te)), V.update("print", me + 1, D.pages.length), me % Ve === Ve - 1 && await rt(), P !== n)) return !1;
476
+ return se.write("</body></html>"), se.close(), await rt(), await Wn(se, te, V.controller.signal), !(!v(D, J) || P !== n);
477
+ }
478
+ function oe() {
479
+ const P = s, D = (V) => V && !o && P === s, J = (V) => (!o && P === s && t.onError(V instanceof Error ? V.message : "报表修改尚未完成", "export"), !1);
480
+ try {
481
+ const V = t.beforeOutput?.() ?? !0;
482
+ return typeof V == "boolean" ? D(V) : V.then(D, J);
483
+ } catch (V) {
484
+ return J(V);
485
+ }
486
+ }
487
+ function ue(P) {
488
+ const D = oe();
489
+ return typeof D == "boolean" ? D ? P() : Promise.resolve() : D.then((J) => J ? P() : void 0);
490
+ }
491
+ function g(P, D, J, V, te) {
492
+ V.finish(V.controller.signal.aborted ? "cancelled" : "failed"), te === n && B(), v(D, J) && !V.controller.signal.aborted && t.onError(jn(P, t.getPrintMessages?.()), "print");
493
+ }
494
+ async function T() {
495
+ if (a) return;
496
+ const P = e.value;
497
+ if (o || !P || P.pages.length === 0) return;
498
+ const D = r;
499
+ a = !0;
500
+ const J = In("print", t.onTask);
501
+ c = J, J.start(), t.onPrinting?.(!0), B(), n = document.createElement("iframe"), n.style.cssText = "position:fixed;right:0;bottom:0;width:0;height:0;border:0;visibility:hidden;", document.body.appendChild(n);
502
+ const V = n;
503
+ try {
504
+ if (!v(P, D) || J.controller.signal.aborted) {
505
+ B();
506
+ return;
507
+ }
508
+ const te = Nn(t.getPrintOptions?.());
509
+ if (!await ae(V, P, D, J, te)) return;
510
+ V.contentWindow?.focus(), V.contentWindow?.print();
511
+ } catch (te) {
512
+ g(te, P, D, J, V);
513
+ } finally {
514
+ J.finish(), c === J && (c = null), a = !1, o || t.onPrinting?.(!1);
515
+ }
516
+ }
517
+ function y(P, D, J) {
518
+ return {
519
+ signal: J.controller.signal,
520
+ onDiagnostic: (V) => {
521
+ v(P, D) && !J.controller.signal.aborted && t.onDiagnostic?.(V);
522
+ },
523
+ onProgress: (V, te) => J.update("encode", V, te)
524
+ };
525
+ }
526
+ function S(P, D, J) {
527
+ if (d?.plan === P && d.epoch === D) return d.promise;
528
+ const V = Promise.resolve().then(() => {
529
+ if (!v(P, D)) throw new Error("报表已切换或卸载");
530
+ const te = (ie) => {
531
+ v(P, D) && t.onWarning?.(ie);
532
+ }, se = t.getPdfExporter(), me = J ? y(P, D, J) : void 0;
533
+ return Te(t.encoding ? t.encoding.pdf(P, se, te, me) : se(P, te, me), J?.controller.signal);
534
+ }).finally(() => {
535
+ d?.promise === V && (d = null);
536
+ });
537
+ return d = { plan: P, epoch: D, promise: V }, V;
538
+ }
539
+ async function F() {
540
+ const P = e.value;
541
+ if (o || !P || P.pages.length === 0) return;
542
+ const D = r;
543
+ if (E?.plan === P && E.epoch === D) return E.promise;
544
+ const J = b(P, D, "PDF"), V = (async () => {
545
+ try {
546
+ const te = i.get(J).run, se = await S(P, D, te);
547
+ if (!v(P, D)) return;
548
+ H(P, D, te, new Blob([se], { type: "application/pdf" }), "mach-report.pdf");
549
+ } catch (te) {
550
+ i.get(J)?.run.finish("failed"), v(P, D) && t.onError(te instanceof Error ? `PDF 导出失败: ${te.message}` : "PDF 导出失败", "pdf");
551
+ } finally {
552
+ R(J), E?.token === J && (E = null);
553
+ }
554
+ })();
555
+ return E = { plan: P, epoch: D, promise: V, token: J }, V;
556
+ }
557
+ async function q() {
558
+ const P = e.value;
559
+ if (o || !P || P.pages.length === 0) return;
560
+ const D = r;
561
+ if (k?.plan === P && k.epoch === D) return k.promise;
562
+ const J = { ...t.getXlsxOptions?.() }, V = b(P, D, "Excel"), te = (async () => {
563
+ try {
564
+ if (!v(P, D)) return;
565
+ const se = i.get(V).run, me = y(P, D, se), ie = t.encoding ? t.encoding.xlsx(P, J, me) : import("@agile-team/mach-report/xlsx").then(async ({ renderPlanToXlsx: Xe }) => {
566
+ fe(se.controller.signal);
567
+ const Ye = await Xe(P, { ...J, ...me });
568
+ return { buffer: new Uint8Array(Ye.buffer), warnings: Ye.warnings };
569
+ }), { buffer: Ke, warnings: Oe } = await Te(ie, se.controller.signal);
570
+ if (!v(P, D) || (Oe.length > 0 && t.onWarning?.(`Excel 导出有 ${Oe.length} 条提示:${Oe.slice(0, 2).join(";")}`), !v(P, D))) return;
571
+ H(P, D, se, new Blob([Ke], {
572
+ type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
573
+ }), "mach-report.xlsx");
574
+ } catch (se) {
575
+ i.get(V)?.run.finish("failed"), v(P, D) && t.onError(se instanceof Error ? `Excel 导出失败: ${se.message}` : "Excel 导出失败", "export");
576
+ } finally {
577
+ R(V), k?.token === V && (k = null);
578
+ }
579
+ })();
580
+ return k = { plan: P, epoch: D, promise: te, token: V }, te;
581
+ }
582
+ async function U() {
583
+ const P = e.value;
584
+ if (o || !P || P.pages.length === 0) return;
585
+ const D = r;
586
+ if (w?.plan === P && w.epoch === D) return w.promise;
587
+ const J = b(P, D, "图片"), V = (async () => {
588
+ try {
589
+ const te = i.get(J).run, { blobs: se } = await Te(Ma(P, {
590
+ ...y(P, D, te),
591
+ dpr: Math.min(2, typeof devicePixelRatio == "number" ? devicePixelRatio : 1)
592
+ }), te.controller.signal);
593
+ if (!v(P, D)) return;
594
+ se.forEach((me, ie) => {
595
+ H(P, D, te, me, se.length > 1 ? `mach-report-page-${ie + 1}.png` : "mach-report.png");
596
+ });
597
+ } catch (te) {
598
+ i.get(J)?.run.finish("failed"), v(P, D) && t.onError(
599
+ te instanceof Error ? `图片导出失败: ${te.message}` : "图片导出失败",
600
+ "export"
601
+ );
602
+ } finally {
603
+ R(J), w?.token === J && (w = null);
604
+ }
605
+ })();
606
+ return w = { plan: P, epoch: D, promise: V, token: J }, V;
607
+ }
608
+ async function _(P) {
609
+ const D = e.value;
610
+ if (o || !D || !D.pages.length) return;
611
+ const J = r, V = b(D, J, P === "word" ? "Word" : "HTML"), te = i.get(V).run;
612
+ try {
613
+ const se = [];
614
+ for (const [Ke, Oe] of D.pages.entries()) {
615
+ if (!v(D, J)) return;
616
+ se.push(yt(Oe)), te.update("encode", Ke + 1, D.pages.length), Ke % Ve === Ve - 1 && await rt();
617
+ }
618
+ if (!v(D, J)) return;
619
+ const me = ht(D), ie = `${P === "word" ? Hn(me) : me}${se.join("")}</body></html>`;
620
+ H(D, J, te, new Blob([ie], { type: P === "word" ? "application/msword;charset=utf-8" : "text/html;charset=utf-8" }), P === "word" ? "mach-report.doc" : "mach-report.html");
621
+ } catch (se) {
622
+ te.finish("failed"), v(D, J) && t.onError(se instanceof Error ? `导出失败: ${se.message}` : "导出失败", "export");
623
+ } finally {
624
+ R(V);
625
+ }
626
+ }
627
+ async function W() {
628
+ await _("word");
629
+ }
630
+ function Q() {
631
+ return ue(T);
632
+ }
633
+ function le() {
634
+ return ue(U);
635
+ }
636
+ function Y() {
637
+ return ue(W);
638
+ }
639
+ async function G(P) {
640
+ const D = e.value;
641
+ if (!(o || !D || D.pages.length === 0)) {
642
+ if (P === "pdf") {
643
+ await F();
644
+ return;
645
+ }
646
+ if (P === "xlsx" || P === "excel") {
647
+ await q();
648
+ return;
649
+ }
650
+ if (P === "png" || P === "image") {
651
+ await U();
652
+ return;
653
+ }
654
+ if (P === "word" || P === "doc") {
655
+ await W();
656
+ return;
657
+ }
658
+ if (P !== "html") {
659
+ t.onError(`不支持的导出格式:${P}`, "export");
660
+ return;
661
+ }
662
+ await _("html");
663
+ }
664
+ }
665
+ function Re(P) {
666
+ return ue(() => G(P));
667
+ }
668
+ function Pe(P) {
669
+ const D = e.value;
670
+ if (o || !D || !D.pages.length) {
671
+ P.close();
672
+ return;
673
+ }
674
+ const J = r;
675
+ f.set(P, { plan: D, epoch: J });
676
+ const V = b(D, J, "PDF");
677
+ S(D, J, i.get(V).run).then((te) => {
678
+ if (!v(D, J) || P.closed) {
679
+ f.delete(P) && P.close();
680
+ return;
681
+ }
682
+ const se = URL.createObjectURL(new Blob([te], { type: "application/pdf" }));
683
+ setTimeout(() => URL.revokeObjectURL(se), 6e4);
684
+ const me = P.document;
685
+ me.title = "PDF 预览", me.documentElement.style.height = "100%", me.body.style.cssText = "margin:0;height:100%;";
686
+ const ie = me.createElement("iframe");
687
+ ie.title = "PDF 预览", ie.style.cssText = "display:block;width:100%;height:100%;border:0;", ie.src = se, me.body.replaceChildren(ie), f.delete(P);
688
+ }).catch((te) => {
689
+ i.get(V)?.run.finish("failed"), P.close(), f.delete(P), v(D, J) && t.onError(te instanceof Error ? `PDF 预览失败: ${te.message}` : "PDF 预览失败", "pdf");
690
+ }).finally(() => R(V));
691
+ }
692
+ function Fe() {
693
+ if (o || !e.value?.pages.length) return;
694
+ const P = globalThis.window.open("", "_blank");
695
+ if (!P) {
696
+ t.onError("浏览器拦截了弹窗,请允许弹窗后重试", "pdf");
697
+ return;
698
+ }
699
+ const D = oe();
700
+ if (typeof D == "boolean") {
701
+ D ? Pe(P) : P.close();
702
+ return;
703
+ }
704
+ l.add(P), D.then((J) => {
705
+ const V = l.delete(P);
706
+ if (!J || !V || P.closed) {
707
+ P.close();
708
+ return;
709
+ }
710
+ Pe(P);
711
+ });
712
+ }
713
+ return {
714
+ print: Q,
715
+ exportAs: Re,
716
+ exportImages: le,
717
+ exportWord: Y,
718
+ openPdfWindow: Fe,
719
+ invalidatePending: h,
720
+ cancel: h,
721
+ releasePrintFrame: B,
722
+ dispose: I
723
+ };
724
+ }
725
+ let Kt;
726
+ function ko(e, t) {
727
+ return {
728
+ ...e,
729
+ prepared: oo(e.prepared, t?.budget?.maxPreparedBytes ?? 64e6, e.signal).forward(),
730
+ pdf: ao(e.pdf),
731
+ xlsx: no(e.xlsx)
732
+ };
733
+ }
734
+ function Eo(e) {
735
+ const t = ve(), n = /* @__PURE__ */ new Set();
736
+ let a = !1, o = 0;
737
+ const r = () => {
738
+ o++;
739
+ for (const l of n)
740
+ l.abort.abort(), l.exporter?.cancel();
741
+ }, s = () => {
742
+ a = !0, r();
743
+ for (const l of n) l.exporter?.dispose();
744
+ };
745
+ return Ie(s), {
746
+ decision: t,
747
+ async exportPrepared(l, i) {
748
+ if (a) throw new Error("报表预览已卸载");
749
+ Cn(l.signal);
750
+ const c = ++o, f = e(), m = { ...f, thresholds: { ...f?.thresholds }, budget: { ...f?.budget } }, d = { abort: new AbortController() }, E = Zt(l.signal, d.abort);
751
+ n.add(d);
752
+ try {
753
+ const k = { ...Kt ? l : ko(l, m), signal: d.abort.signal }, w = Kt ?? await Te(import("./auto-BIOmtVhk.js").then((v) => v.b).then((v) => {
754
+ const L = v.createAutoReportExporter;
755
+ return Kt = L, L;
756
+ }), d.abort.signal);
757
+ return Cn(d.abort.signal), d.exporter = w({ ...m, onDecision: (v) => {
758
+ c !== o || a || (t.value = v, ot(() => f?.onDecision?.(v)));
759
+ } }), await d.exporter.exportPrepared(k, i);
760
+ } finally {
761
+ E(), d.exporter?.dispose(), n.delete(d);
762
+ }
763
+ },
764
+ cancel: r,
765
+ dispose: s
766
+ };
767
+ }
768
+ function $o(e) {
769
+ return { plan: e, diagnostics: [], revisions: {}, stats: { rows: 0, pages: e.pages.length, cells: 0, durationMs: 0 }, layout: { textMetrics: "provided" } };
770
+ }
771
+ function Pn(e, t, n, a) {
772
+ return {
773
+ prepared: $o(e),
774
+ format: t,
775
+ layoutPolicy: "preserve",
776
+ fidelity: a,
777
+ signal: n.signal,
778
+ onEvent: (o) => {
779
+ o.stage === "encode" && o.completed !== void 0 && o.total !== void 0 && n.onProgress?.(o.completed, o.total);
780
+ }
781
+ };
782
+ }
783
+ function Co(e) {
784
+ const t = Eo(e.execution);
785
+ function n(s, l) {
786
+ fe(l.signal);
787
+ for (const i of s.diagnostics)
788
+ fe(l.signal), ot(() => e.diagnostic(i));
789
+ fe(l.signal);
790
+ }
791
+ async function a(s, l, i, c = {}) {
792
+ if (!l.prepare) return l(s, i, c);
793
+ const f = e.fidelity(), m = await l.prepare(c.signal);
794
+ fe(c.signal);
795
+ const d = await t.exportPrepared({ ...Pn(s, "pdf", c, f), pdf: m });
796
+ n(d, c);
797
+ const E = d.diagnostics.find((w) => w.code === "pdf-font" || w.code === "pdf-page");
798
+ if (E) throw new Error(E.message);
799
+ const k = d.diagnostics.filter((w) => w.severity === "warning");
800
+ return k.length && i(`PDF 有 ${k.length} 处版式降级:${k.slice(0, 2).map((w) => w.message).join(";")}`), d.bytes;
801
+ }
802
+ async function o(s, l, i) {
803
+ const { renderPlanToXlsx: c } = await import("@agile-team/mach-report/xlsx");
804
+ fe(s.signal);
805
+ const f = await c(s.prepared.plan, {
806
+ ...l,
807
+ ...s.xlsx,
808
+ fidelity: s.fidelity,
809
+ signal: s.signal,
810
+ onProgress: (m, d) => {
811
+ ot(() => l.onProgress?.(m, d)), i.onProgress?.(m, d);
812
+ },
813
+ onDiagnostic: (m) => {
814
+ ot(() => l.onDiagnostic?.(m)), i.onDiagnostic?.(m);
815
+ }
816
+ });
817
+ return fe(s.signal), {
818
+ ...s.prepared,
819
+ bytes: new Uint8Array(f.buffer),
820
+ format: "xlsx",
821
+ contentType: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
822
+ diagnostics: [...f.diagnostics ?? [], ...f.warnings.map((m) => ({ code: "xlsx-fidelity", severity: "warning", message: m }))]
823
+ };
824
+ }
825
+ async function r(s, l, i) {
826
+ const { signal: c, fidelity: f, ...m } = l, d = e.fidelity() === "strict" || f === "strict", E = Object.values(m).some((w) => typeof w == "function"), k = await t.exportPrepared(
827
+ { ...Pn(s, "xlsx", i, d ? "strict" : "warn"), xlsx: m },
828
+ E ? (w) => o(w, m, i) : void 0
829
+ );
830
+ return n(k, i), { buffer: k.bytes, warnings: k.diagnostics.filter((w) => w.severity === "warning").map((w) => w.message) };
831
+ }
832
+ return { pdf: a, xlsx: r };
833
+ }
834
+ function Io(e) {
835
+ const { plan: t, editing: n, diagnostics: a, task: o } = e, { lastError: r, notice: s, reportError: l } = e.feedback, i = Z(null), c = Z(!1), f = Z(), m = N(() => ({ ...e.defaultsPrint(), ...e.printOverrides(), calibration: f.value ?? { ...e.defaultsPrint()?.calibration, ...e.printOverrides()?.calibration } }));
836
+ pe([() => e.printOverrides(), () => e.defaultsPrint()], () => {
837
+ f.value = void 0;
838
+ });
839
+ let d;
840
+ function E(I) {
841
+ const z = t.value;
842
+ if (!z) return !1;
843
+ const H = { excel: "xlsx", image: "png", doc: "word" }[I] ?? I, ae = H === "pdf" ? "pdf" : H === "xlsx" ? "xlsx" : H === "png" ? "canvas" : "dom", oe = a.inspect(z, ae);
844
+ return t.value !== z ? !1 : oe.length && e.fidelity() === "strict" ? (s.value = { kind: "error", message: e.messages().diagnosticsStrict ?? "输出存在已知降级" }, l(s.value.message, "export", { diagnostics: oe }), !1) : !0;
845
+ }
846
+ function k(I) {
847
+ return t.value ? a.inspect(t.value, I) : [];
848
+ }
849
+ const w = xo(t, {
850
+ encoding: Co({ execution: e.execution, fidelity: e.fidelity, diagnostic: a.add }),
851
+ getPdfExporter: e.getPdfExporter,
852
+ beforeOutput: () => n.settle(),
853
+ onTask: (I) => o.receive(I, () => w.cancel()),
854
+ onDiagnostic: a.add,
855
+ getXlsxOptions: () => e.getXlsxOptions(),
856
+ getPrintOptions: () => m.value,
857
+ getPrintMessages: () => e.messages(),
858
+ onError: (I, z) => {
859
+ s.value = { kind: "error", message: I }, l(I, z ?? "print");
860
+ },
861
+ onWarning: (I) => {
862
+ s.value = { kind: "warning", message: I }, a.add({ code: "output", severity: "warning", message: I }), e.feedback.warning(I);
863
+ },
864
+ onBusy: (I) => {
865
+ i.value = I, I ? s.value = {
866
+ kind: "progress",
867
+ message: e.messages().exporting.replace("{format}", I)
868
+ } : s.value?.kind === "progress" && (s.value = null);
869
+ },
870
+ onPrinting: (I) => {
871
+ c.value = I;
872
+ }
873
+ }), { releasePrintFrame: v, dispose: L } = w, b = N(() => {
874
+ const I = t.value?.pages[0];
875
+ return !!I && !e.wide() && [I.pageWidthMm, I.pageHeightMm].every((z) => z >= 25 && z <= 600);
876
+ });
877
+ async function R() {
878
+ if (!b.value || c.value || e.busy()) return;
879
+ const I = t.value.pages[0];
880
+ c.value = !0;
881
+ const z = new AbortController();
882
+ d = z;
883
+ try {
884
+ await wo([go(I.pageWidthMm, I.pageHeightMm)], { printOptions: m.value, signal: z.signal, messages: e.messages(), onError: (H) => {
885
+ s.value = { kind: "error", message: H };
886
+ } });
887
+ } catch {
888
+ } finally {
889
+ d === z && (c.value = !1, d = void 0);
890
+ }
891
+ }
892
+ async function A() {
893
+ if (e.busy()) return;
894
+ const I = n.settle();
895
+ (typeof I == "boolean" ? I : await I) && (r.value = null, E("html") && await w.print());
896
+ }
897
+ async function h(I) {
898
+ if (e.busy()) return;
899
+ const z = n.settle();
900
+ (typeof z == "boolean" ? z : await z) && (r.value = null, E(I) && await w.exportAs(I));
901
+ }
902
+ function M() {
903
+ if (e.busy() || n.active.value || n.saving.value) {
904
+ s.value = { kind: "warning", message: e.messages().editingHint ?? "请先确认单元格修改" };
905
+ return;
906
+ }
907
+ r.value = null, E("pdf") && w.openPdfWindow();
908
+ }
909
+ function B() {
910
+ d?.abort(), v();
911
+ }
912
+ return Ie(() => {
913
+ d?.abort(), L();
914
+ }), {
915
+ exporting: i,
916
+ printing: c,
917
+ localPrintCalibration: f,
918
+ effectivePrintOptions: m,
919
+ canCalibratePrint: b,
920
+ testPrintCalibration: R,
921
+ print: A,
922
+ exportAs: h,
923
+ openPdfWindow: M,
924
+ getOutputDiagnostics: k,
925
+ invalidate: B,
926
+ invalidatePending: w.invalidatePending,
927
+ cancel: w.cancel
928
+ };
929
+ }
930
+ const Un = "mrp-hit";
931
+ function Po(e) {
932
+ e.querySelectorAll(`mark.${Un}`).forEach((n) => {
933
+ const a = n.parentNode;
934
+ if (a) {
935
+ for (; n.firstChild; ) a.insertBefore(n.firstChild, n);
936
+ n.remove(), a.normalize();
937
+ }
938
+ });
939
+ }
940
+ function So(e, t) {
941
+ const n = t.trim();
942
+ if (!n) return 0;
943
+ const a = n.toLowerCase(), o = document.createTreeWalker(e, NodeFilter.SHOW_TEXT, {
944
+ acceptNode(l) {
945
+ const i = l.parentElement;
946
+ return !i || i.closest("mark") || /^(SCRIPT|STYLE)$/.test(i.tagName) ? NodeFilter.FILTER_REJECT : (l.nodeValue ?? "").toLowerCase().includes(a) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_REJECT;
947
+ }
948
+ }), r = [];
949
+ for (let l = o.nextNode(); l; l = o.nextNode()) r.push(l);
950
+ let s = 0;
951
+ for (const l of r) {
952
+ const i = l.nodeValue ?? "", c = i.toLowerCase(), f = l.parentElement;
953
+ if (!f) continue;
954
+ const m = document.createDocumentFragment();
955
+ let d = 0, E = c.indexOf(a);
956
+ for (; E >= 0; ) {
957
+ E > d && m.appendChild(document.createTextNode(i.slice(d, E)));
958
+ const k = document.createElement("mark");
959
+ k.className = Un, k.textContent = i.slice(E, E + n.length), m.appendChild(k), s++, d = E + n.length, E = c.indexOf(a, d);
960
+ }
961
+ d < i.length && m.appendChild(document.createTextNode(i.slice(d))), f.replaceChild(m, l);
962
+ }
963
+ return s;
964
+ }
965
+ const Ro = /* @__PURE__ */ new Set(["line", "rect", "ellipse", "chart"]);
966
+ function* Mo(e) {
967
+ for (const t of e.cells ?? [])
968
+ for (const n of t ?? [])
969
+ yield n?.text ?? "", yield* n?.children ?? [];
970
+ }
971
+ function* To(e) {
972
+ if (so(e))
973
+ for (const t of e.richParagraphs)
974
+ for (const n of t.segments ?? [])
975
+ yield (n.kind === "field" ? n.field : n.text) ?? "";
976
+ else e.lines?.length ? yield* e.lines : yield e.text ?? "";
977
+ }
978
+ function* Oo(e) {
979
+ const t = [e.values()];
980
+ for (; t.length > 0; ) {
981
+ const n = t[t.length - 1].next();
982
+ if (n.done) {
983
+ t.pop();
984
+ continue;
985
+ }
986
+ const a = n.value;
987
+ if (typeof a == "string") {
988
+ yield a;
989
+ continue;
990
+ }
991
+ yield "", !ro(a) && (a.kind === "text" ? t.push(To(a)) : a.grid ? t.push(Mo(a.grid)) : Ro.has(a.kind) || (yield a.fallbackText ?? ""));
992
+ }
993
+ }
994
+ function* Do(e) {
995
+ for (let t = 0; t < e.pages.length; t++) {
996
+ for (const n of Oo(e.pages[t].components)) yield { text: n, pageIndex: t };
997
+ yield { text: "", pageIndex: t };
998
+ }
999
+ }
1000
+ function Ao(e, t) {
1001
+ const n = e.toLowerCase();
1002
+ let a = 0;
1003
+ for (let o = n.indexOf(t); o >= 0; o = n.indexOf(t, o + t.length)) a++;
1004
+ return a;
1005
+ }
1006
+ function Fo(e) {
1007
+ const { plan: t, gotoPage: n, highlight: a, clearHighlights: o } = e, r = Z(!1), s = Z(""), l = Z(0), i = Z(0), c = Z(!1);
1008
+ let f = [];
1009
+ const m = N(() => {
1010
+ if (i.value === 0) return null;
1011
+ const A = l.value;
1012
+ let h = 0, M = f.length - 1;
1013
+ for (; h < M; ) {
1014
+ const I = h + M >>> 1;
1015
+ f[I].cumulative <= A ? h = I + 1 : M = I;
1016
+ }
1017
+ const B = f[h];
1018
+ return B ? { pageIndex: B.pageIndex, occurrence: A - (f[h - 1]?.cumulative ?? 0) } : null;
1019
+ });
1020
+ let d = null, E = null, k = 0;
1021
+ function w() {
1022
+ k++, d && clearTimeout(d), E && clearTimeout(E), d = E = null, c.value = !1;
1023
+ }
1024
+ function v(A) {
1025
+ s.value = A, l.value = 0, i.value = 0, f = [], c.value = !1;
1026
+ const h = A.trim().toLowerCase(), M = t.value;
1027
+ if (!h || !M) return;
1028
+ c.value = !0;
1029
+ const B = k, I = Do(M), z = [];
1030
+ let H = 0;
1031
+ function ae() {
1032
+ if (E = null, B !== k || M !== t.value) return;
1033
+ const oe = performance.now();
1034
+ let ue = 0;
1035
+ for (; ue < 5e3 && performance.now() - oe < 4; ) {
1036
+ const g = I.next();
1037
+ if (g.done) {
1038
+ f = z, i.value = H, c.value = !1, f[0] && n(f[0].pageIndex + 1);
1039
+ return;
1040
+ }
1041
+ const T = Ao(g.value.text, h);
1042
+ if (T > 0) {
1043
+ H += T;
1044
+ const y = z[z.length - 1];
1045
+ y?.pageIndex === g.value.pageIndex ? y.cumulative = H : z.push({ pageIndex: g.value.pageIndex, cumulative: H });
1046
+ }
1047
+ ue++;
1048
+ }
1049
+ E = setTimeout(ae, 0);
1050
+ }
1051
+ ae();
1052
+ }
1053
+ function L(A) {
1054
+ if (w(), s.value = A, l.value = i.value = 0, f = [], !A.trim()) {
1055
+ v("");
1056
+ return;
1057
+ }
1058
+ c.value = !0, d = setTimeout(() => {
1059
+ d = null, v(A);
1060
+ }, Math.max(0, u(e.debounceMs) ?? 200));
1061
+ }
1062
+ function b(A) {
1063
+ const h = i.value;
1064
+ if (h === 0 || c.value) return;
1065
+ l.value = (l.value + A + h) % h;
1066
+ const M = m.value;
1067
+ M && n(M.pageIndex + 1);
1068
+ }
1069
+ function R() {
1070
+ w(), s.value = "", l.value = i.value = 0, f = [];
1071
+ }
1072
+ return pe(t, R, { flush: "sync" }), Ie(R), {
1073
+ visible: r,
1074
+ query: s,
1075
+ matchIndex: l,
1076
+ matchCount: i,
1077
+ activeMatch: m,
1078
+ searching: c,
1079
+ toggle: () => {
1080
+ r.value = !r.value;
1081
+ },
1082
+ onInput: L,
1083
+ onNav: b,
1084
+ apply: (A) => {
1085
+ s.value.trim() && a(A, s.value.trim());
1086
+ },
1087
+ clear: (A) => {
1088
+ o(A);
1089
+ },
1090
+ reset: R
1091
+ };
1092
+ }
1093
+ function zo(e, t) {
1094
+ const n = N(() => {
1095
+ if (e.value) return !0;
1096
+ if (typeof location > "u") return !1;
1097
+ try {
1098
+ return new URLSearchParams(location.search).get("mrp-debug") === "1";
1099
+ } catch {
1100
+ return !1;
1101
+ }
1102
+ }), a = N(() => !n.value || !t.plan.value ? 0 : Math.round(JSON.stringify(t.plan.value).length / 1024)), o = N(() => !n.value || !t.plan.value ? null : {
1103
+ pages: t.pageCount.value,
1104
+ window: `${t.windowRange.value.start}-${t.windowRange.value.end}`,
1105
+ zoom: `${Math.round(t.zoom.value * 100)}%`,
1106
+ loadMs: `${t.loadMs.value}ms`,
1107
+ planKB: a.value
1108
+ });
1109
+ return { enabled: n, debugStats: o };
1110
+ }
1111
+ function Lo(e, t) {
1112
+ const { thumbsRoot: n, visible: a, renderThumbCanvas: o } = t, r = Z(0), s = Z(800), l = N(() => (e.value?.pages ?? []).map(
1113
+ (b) => Math.round(b.pageHeightMm / b.pageWidthMm * 116)
1114
+ )), i = N(() => qn(l.value.map((b) => b + 20), 8)), c = N(() => i.value.window(s.value, r.value, 1)), f = N(() => {
1115
+ if (!a.value) return [];
1116
+ const { start: b, end: R } = c.value;
1117
+ return l.value.slice(b, R + 1).map((A, h) => ({ index: b + h, height: A }));
1118
+ });
1119
+ let m = 0, d = 0, E = !1;
1120
+ function k() {
1121
+ const b = n.value;
1122
+ b && (r.value = b.scrollTop, s.value = b.clientHeight || 800);
1123
+ }
1124
+ function w() {
1125
+ E || d || (d = requestAnimationFrame(() => {
1126
+ d = 0, k();
1127
+ }));
1128
+ }
1129
+ function v() {
1130
+ if (f.value, m && cancelAnimationFrame(m), m = 0, E || !a.value || !e.value || !n.value) return;
1131
+ k();
1132
+ const b = f.value, R = e.value, A = n.value;
1133
+ let h = 0;
1134
+ function M() {
1135
+ if (m = 0, !(E || !a.value || e.value !== R || n.value !== A)) {
1136
+ for (let B = 0; h < b.length && B < 2; B++, h++) {
1137
+ const I = b[h].index, z = A.querySelector(`[data-thumb="${I + 1}"]`);
1138
+ if (!z || z.childElementCount > 0) continue;
1139
+ const H = o(I);
1140
+ H && (H.style.width = "100%", H.style.height = "100%", H.style.display = "block", z.appendChild(H));
1141
+ }
1142
+ h < b.length && (m = requestAnimationFrame(M));
1143
+ }
1144
+ }
1145
+ m = requestAnimationFrame(M);
1146
+ }
1147
+ function L() {
1148
+ E = !0, m && cancelAnimationFrame(m), d && cancelAnimationFrame(d), m = d = 0;
1149
+ }
1150
+ return Ie(L), { schedule: v, destroy: L, onScroll: w, windowRange: c, visibleThumbs: f };
1151
+ }
1152
+ function qo() {
1153
+ const e = ve(0);
1154
+ return {
1155
+ loadMs: e,
1156
+ start() {
1157
+ return typeof performance < "u" ? performance.now() : 0;
1158
+ },
1159
+ end(t) {
1160
+ e.value = t ? Math.round(performance.now() - t) : 0;
1161
+ }
1162
+ };
1163
+ }
1164
+ function No(e) {
1165
+ const t = Z(null), n = Z(null);
1166
+ function a() {
1167
+ t.value?.focus(), t.value?.select();
1168
+ }
1169
+ pe(e.visible, (s) => {
1170
+ s && Be(a);
1171
+ });
1172
+ function o() {
1173
+ e.close(), Be(() => n.value?.focus());
1174
+ }
1175
+ function r(s) {
1176
+ s.isComposing || s.keyCode === 229 || s.key !== "Enter" && s.key !== "Escape" || (s.preventDefault(), s.stopPropagation(), s.key === "Escape" ? o() : e.navigate(s.shiftKey ? -1 : 1));
1177
+ }
1178
+ return { input: t, toggle: n, focus: a, close: o, onKeydown: r };
1179
+ }
1180
+ const Bo = ["disabled", "aria-expanded"], Ko = ["aria-label"], jo = ["aria-label", "disabled", "onClick"], Wo = { "aria-hidden": "true" }, Ho = /* @__PURE__ */ ye({
1181
+ __name: "ReportExportMenu",
1182
+ props: {
1183
+ messages: {},
1184
+ formats: {},
1185
+ busy: { type: Boolean }
1186
+ },
1187
+ emits: ["export"],
1188
+ setup(e, { emit: t }) {
1189
+ const n = e, a = t, { opened: o, root: r, trigger: s, panel: l, close: i, onKeydown: c } = Bn(), f = N(() => [
1190
+ { format: "xlsx", label: n.messages.exportExcel, extension: ".xlsx" },
1191
+ { format: "pdf", label: n.messages.exportPdf, extension: ".pdf" },
1192
+ { format: "png", label: n.messages.exportImage, extension: ".png" },
1193
+ { format: "word", label: n.messages.exportWord, extension: ".doc" },
1194
+ { format: "html", label: n.messages.exportHtml, extension: ".html" }
1195
+ ].filter((k) => !n.formats || n.formats.includes(k.format)));
1196
+ pe(() => n.busy, (k) => {
1197
+ k && i();
1198
+ });
1199
+ function m(k) {
1200
+ n.busy || (a("export", k), i(!0));
1201
+ }
1202
+ function d(k) {
1203
+ k.key !== "ArrowDown" && k.key !== "ArrowUp" || (k.preventDefault(), o.value = !0, k.key === "ArrowUp" && Be(() => l.value?.querySelector("button:last-child")?.focus()));
1204
+ }
1205
+ function E(k) {
1206
+ if (k.key === "Tab") {
1207
+ i();
1208
+ return;
1209
+ }
1210
+ if (!["ArrowDown", "ArrowUp", "Home", "End"].includes(k.key)) return;
1211
+ k.preventDefault(), k.stopPropagation();
1212
+ const v = [...l.value?.querySelectorAll("button:not(:disabled)") ?? []], L = v.indexOf(document.activeElement), b = k.key === "Home" ? 0 : k.key === "End" ? v.length - 1 : (L + (k.key === "ArrowDown" ? 1 : -1) + v.length) % v.length;
1213
+ v[b]?.focus();
1214
+ }
1215
+ return (k, w) => f.value.length ? ($(), C("div", {
1216
+ key: 0,
1217
+ ref_key: "root",
1218
+ ref: r,
1219
+ class: "mrp-export-menu",
1220
+ onKeydown: w[1] || (w[1] = //@ts-ignore
1221
+ (...v) => u(c) && u(c)(...v))
1222
+ }, [
1223
+ p("button", {
1224
+ ref_key: "trigger",
1225
+ ref: s,
1226
+ type: "button",
1227
+ class: "mrp-nav mrp-export-trigger",
1228
+ disabled: e.busy,
1229
+ "aria-haspopup": "menu",
1230
+ "aria-expanded": u(o),
1231
+ onClick: w[0] || (w[0] = (v) => o.value = !u(o)),
1232
+ onKeydown: d
1233
+ }, [
1234
+ ne(re, { name: "download" }),
1235
+ ce(x(e.messages.exportMenu ?? "导出"), 1),
1236
+ ne(re, {
1237
+ name: "chevron-down",
1238
+ size: 12
1239
+ })
1240
+ ], 40, Bo),
1241
+ u(o) ? ($(), C("div", {
1242
+ key: 0,
1243
+ ref_key: "panel",
1244
+ ref: l,
1245
+ class: "mrp-export-panel",
1246
+ role: "menu",
1247
+ "aria-label": e.messages.exportMenu ?? "导出",
1248
+ onKeydown: E
1249
+ }, [
1250
+ p("p", null, x(e.messages.exportMenuDescription ?? "选择文件格式"), 1),
1251
+ ($(!0), C(be, null, he(f.value, (v) => ($(), C("button", {
1252
+ key: v.format,
1253
+ type: "button",
1254
+ role: "menuitem",
1255
+ tabindex: "-1",
1256
+ "aria-label": v.label,
1257
+ disabled: e.busy,
1258
+ onClick: (L) => m(v.format)
1259
+ }, [
1260
+ ne(re, { name: "file" }),
1261
+ p("span", null, x(v.label), 1),
1262
+ p("small", Wo, x(v.extension), 1)
1263
+ ], 8, jo))), 128))
1264
+ ], 40, Ko)) : j("", !0)
1265
+ ], 544)) : j("", !0);
1266
+ }
1267
+ }), Uo = /* @__PURE__ */ we(Ho, [["__scopeId", "data-v-83a57a3c"]]), Vo = ["aria-label"], Go = {
1268
+ class: "mrp-pageinfo",
1269
+ "aria-live": "polite"
1270
+ }, Jo = { class: "mrp-page-buttons" }, Xo = ["aria-label", "title", "disabled"], Yo = ["aria-label", "title", "disabled"], Zo = ["aria-label", "title", "aria-invalid", "disabled"], Qo = ["aria-label", "disabled"], _o = {
1271
+ key: 1,
1272
+ class: "mrp-page-error",
1273
+ role: "alert"
1274
+ }, er = /* @__PURE__ */ ye({
1275
+ __name: "ReportPagination",
1276
+ props: {
1277
+ pageCount: {},
1278
+ currentPage: {},
1279
+ messages: {},
1280
+ busy: { type: Boolean }
1281
+ },
1282
+ emits: ["goto"],
1283
+ setup(e, { emit: t }) {
1284
+ const n = e, a = t, o = Z(String(n.currentPage)), r = Z(!1), s = N(() => n.messages.pageInfo.replace("{cur}", String(n.currentPage)).replace("{total}", String(n.pageCount)));
1285
+ pe(() => [n.currentPage, n.pageCount], () => {
1286
+ o.value = String(n.currentPage), r.value = !1;
1287
+ });
1288
+ function l() {
1289
+ if (n.busy) return;
1290
+ const i = o.value.trim(), c = Number(i);
1291
+ r.value = !/^\d+$/.test(i) || !Number.isSafeInteger(c) || c < 1 || c > n.pageCount, !r.value && c !== n.currentPage && a("goto", c);
1292
+ }
1293
+ return (i, c) => e.pageCount > 0 ? ($(), C("nav", {
1294
+ key: 0,
1295
+ class: "mrp-pagination",
1296
+ role: "navigation",
1297
+ "aria-label": e.messages.pagination ?? "报表分页"
1298
+ }, [
1299
+ p("span", Go, x(s.value), 1),
1300
+ p("div", Jo, [
1301
+ p("button", {
1302
+ class: "mrp-nav",
1303
+ type: "button",
1304
+ "aria-label": e.messages.prevPage,
1305
+ title: e.messages.prevPage,
1306
+ disabled: e.busy || e.currentPage <= 1,
1307
+ onClick: c[0] || (c[0] = (f) => a("goto", e.currentPage - 1))
1308
+ }, [
1309
+ ne(re, { name: "chevron-left" })
1310
+ ], 8, Xo),
1311
+ p("button", {
1312
+ class: "mrp-nav",
1313
+ type: "button",
1314
+ "aria-label": e.messages.nextPage,
1315
+ title: e.messages.nextPage,
1316
+ disabled: e.busy || e.currentPage >= e.pageCount,
1317
+ onClick: c[1] || (c[1] = (f) => a("goto", e.currentPage + 1))
1318
+ }, [
1319
+ ne(re, { name: "chevron-right" })
1320
+ ], 8, Yo)
1321
+ ]),
1322
+ e.pageCount > 1 ? ($(), C("form", {
1323
+ key: 0,
1324
+ class: "mrp-page-jump",
1325
+ onSubmit: st(l, ["prevent"])
1326
+ }, [
1327
+ p("label", null, [
1328
+ p("span", null, x(e.messages.pageJump ?? "跳至页"), 1),
1329
+ xt(p("input", {
1330
+ "onUpdate:modelValue": c[2] || (c[2] = (f) => o.value = f),
1331
+ type: "text",
1332
+ inputmode: "numeric",
1333
+ autocomplete: "off",
1334
+ "aria-label": e.messages.pageJump ?? "跳至页",
1335
+ title: e.messages.pageJumpHint ?? "Enter 跳转",
1336
+ "aria-invalid": r.value,
1337
+ disabled: e.busy,
1338
+ onInput: c[3] || (c[3] = (f) => r.value = !1),
1339
+ onKeydown: c[4] || (c[4] = Ea((f) => {
1340
+ o.value = String(e.currentPage), r.value = !1;
1341
+ }, ["esc"]))
1342
+ }, null, 40, Zo), [
1343
+ [kt, o.value]
1344
+ ])
1345
+ ]),
1346
+ p("button", {
1347
+ class: "mrp-nav",
1348
+ type: "submit",
1349
+ "aria-label": e.messages.pageJump ?? "跳至页",
1350
+ disabled: e.busy
1351
+ }, [
1352
+ ne(re, {
1353
+ name: "arrow-right",
1354
+ size: 14
1355
+ })
1356
+ ], 8, Qo)
1357
+ ], 32)) : j("", !0),
1358
+ r.value ? ($(), C("span", _o, x(e.messages.pageJumpInvalid ?? "请输入有效页码"), 1)) : j("", !0)
1359
+ ], 8, Vo)) : j("", !0);
1360
+ }
1361
+ }), Vn = /* @__PURE__ */ we(er, [["__scopeId", "data-v-0db4fbd3"]]), tr = ["aria-label"], nr = { class: "mrp-title" }, ar = ["aria-label"], or = ["aria-label", "aria-pressed"], rr = ["aria-pressed"], sr = ["aria-pressed"], lr = ["aria-label"], ir = ["aria-pressed"], ur = ["aria-pressed", "onClick"], cr = ["aria-label"], dr = ["disabled"], fr = ["disabled"], mr = ["disabled"], gr = ["aria-label", "aria-expanded"], pr = ["aria-label"], vr = ["placeholder", "aria-label", "value"], br = ["aria-label"], hr = {
1362
+ key: 1,
1363
+ class: "mrp-search-count",
1364
+ role: "status",
1365
+ "aria-live": "polite"
1366
+ }, yr = ["disabled", "aria-label"], wr = ["disabled", "aria-label"], xr = ["aria-label"], kr = {
1367
+ class: "mrp-search-hint",
1368
+ role: "status"
1369
+ }, Er = /* @__PURE__ */ ye({
1370
+ __name: "ReportToolbar",
1371
+ props: {
1372
+ pageCount: {},
1373
+ currentPage: {},
1374
+ zoomMode: {},
1375
+ zoom: {},
1376
+ showExport: { type: Boolean },
1377
+ showPrint: { type: Boolean },
1378
+ showPdfWindow: { type: Boolean },
1379
+ messages: {},
1380
+ search: {},
1381
+ thumbsVisible: { type: Boolean },
1382
+ showImport: { type: Boolean },
1383
+ showSearch: { type: Boolean, default: !0 },
1384
+ showThumbnails: { type: Boolean, default: !0 },
1385
+ showZoom: { type: Boolean, default: !0 },
1386
+ exportFormats: { default: void 0 },
1387
+ showSettings: { type: Boolean },
1388
+ settingsOpen: { type: Boolean },
1389
+ busy: { type: Boolean },
1390
+ showPagination: { type: Boolean }
1391
+ },
1392
+ emits: ["goto", "zoom", "export", "print", "pdf-window", "search-input", "search-nav", "search-toggle", "thumbs-toggle", "import-excel", "settings-toggle"],
1393
+ setup(e, { expose: t, emit: n }) {
1394
+ const a = e, o = n, r = No({
1395
+ visible: () => a.search.visible,
1396
+ navigate: (f) => {
1397
+ !a.search.searching && a.search.matchCount > 0 && o("search-nav", f);
1398
+ },
1399
+ close: () => {
1400
+ a.search.visible && o("search-toggle");
1401
+ }
1402
+ }), { input: s, toggle: l } = r;
1403
+ t({ focusSearch: r.focus });
1404
+ function i() {
1405
+ const f = a.search.matchCount > 0 ? a.search.matchIndex + 1 : 0;
1406
+ return a.messages.matchInfo.replace("{cur}", String(f)).replace("{total}", String(a.search.matchCount));
1407
+ }
1408
+ function c() {
1409
+ o("search-input", ""), r.focus();
1410
+ }
1411
+ return (f, m) => ($(), C("div", {
1412
+ class: "mrp-toolbar",
1413
+ role: "toolbar",
1414
+ "aria-label": e.messages.title
1415
+ }, [
1416
+ p("span", nr, [
1417
+ ne(re, { name: "file" }),
1418
+ ce(x(e.messages.title), 1)
1419
+ ]),
1420
+ e.showPagination ? ($(), Ce(Vn, {
1421
+ key: 0,
1422
+ "page-count": e.pageCount,
1423
+ "current-page": e.currentPage,
1424
+ messages: e.messages,
1425
+ busy: e.busy,
1426
+ onGoto: m[0] || (m[0] = (d) => o("goto", d))
1427
+ }, null, 8, ["page-count", "current-page", "messages", "busy"])) : j("", !0),
1428
+ m[15] || (m[15] = p("span", { class: "mrp-spacer" }, null, -1)),
1429
+ e.showSearch !== !1 ? ($(), C("div", {
1430
+ key: 1,
1431
+ class: "mrp-read-tools",
1432
+ role: "group",
1433
+ "aria-label": e.messages.search ?? "内容搜索"
1434
+ }, [
1435
+ p("button", {
1436
+ ref_key: "searchToggleRef",
1437
+ ref: l,
1438
+ class: ke(["mrp-nav mrp-search-toggle mrp-icon-button", { "mrp-active": e.search.visible }]),
1439
+ type: "button",
1440
+ title: "Ctrl+F",
1441
+ "aria-label": e.messages.search ?? e.messages.searchPlaceholder,
1442
+ "aria-pressed": e.search.visible,
1443
+ onClick: m[1] || (m[1] = (d) => o("search-toggle"))
1444
+ }, [
1445
+ ne(re, { name: "search" })
1446
+ ], 10, or),
1447
+ e.showThumbnails !== !1 ? ($(), C("button", {
1448
+ key: 0,
1449
+ class: ke(["mrp-nav", { "mrp-active": e.thumbsVisible }]),
1450
+ type: "button",
1451
+ "aria-pressed": e.thumbsVisible,
1452
+ onClick: m[2] || (m[2] = (d) => o("thumbs-toggle"))
1453
+ }, [
1454
+ ne(re, { name: "grid" }),
1455
+ ce(x(e.messages.thumbnails), 1)
1456
+ ], 10, rr)) : j("", !0)
1457
+ ], 8, ar)) : e.showThumbnails !== !1 ? ($(), C("button", {
1458
+ key: 2,
1459
+ class: ke(["mrp-nav", { "mrp-active": e.thumbsVisible }]),
1460
+ type: "button",
1461
+ "aria-pressed": e.thumbsVisible,
1462
+ onClick: m[3] || (m[3] = (d) => o("thumbs-toggle"))
1463
+ }, [
1464
+ ne(re, { name: "grid" }),
1465
+ ce(x(e.messages.thumbnails), 1)
1466
+ ], 10, sr)) : j("", !0),
1467
+ lt(f.$slots, "navigation", {}, void 0, !0),
1468
+ e.showZoom !== !1 ? ($(), C("div", {
1469
+ key: 3,
1470
+ class: "mrp-zoom-tools",
1471
+ role: "group",
1472
+ "aria-label": e.messages.zoom ?? "缩放工具"
1473
+ }, [
1474
+ p("button", {
1475
+ class: ke(["mrp-nav", { "mrp-active": e.zoomMode === "fit" }]),
1476
+ "aria-pressed": e.zoomMode === "fit",
1477
+ type: "button",
1478
+ onClick: m[4] || (m[4] = (d) => o("zoom", "fit"))
1479
+ }, [
1480
+ ne(re, { name: "fit" }),
1481
+ ce(x(e.messages.fitWidth), 1)
1482
+ ], 10, ir),
1483
+ ($(), C(be, null, he([100, 150], (d) => p("button", {
1484
+ key: d,
1485
+ class: ke(["mrp-nav", { "mrp-active": e.zoomMode === "raw" && Math.round(e.zoom * 100) === d }]),
1486
+ "aria-pressed": e.zoomMode === "raw" && Math.round(e.zoom * 100) === d,
1487
+ type: "button",
1488
+ onClick: (E) => o("zoom", d)
1489
+ }, x(d) + "%", 11, ur)), 64))
1490
+ ], 8, lr)) : j("", !0),
1491
+ e.showImport || e.showExport || e.showPrint || e.showPdfWindow ? ($(), C("div", {
1492
+ key: 4,
1493
+ class: "mrp-output-tools",
1494
+ role: "group",
1495
+ "aria-label": e.messages.settingsExport ?? "导出与打印"
1496
+ }, [
1497
+ e.showImport ? ($(), C("button", {
1498
+ key: 0,
1499
+ class: "mrp-nav mrp-import-excel",
1500
+ type: "button",
1501
+ disabled: e.busy,
1502
+ onClick: m[5] || (m[5] = (d) => o("import-excel"))
1503
+ }, [
1504
+ ne(re, { name: "upload" }),
1505
+ ce(x(e.messages.importExcel ?? "导入 Excel 模板"), 1)
1506
+ ], 8, dr)) : j("", !0),
1507
+ e.showExport ? ($(), Ce(Uo, {
1508
+ key: 1,
1509
+ messages: e.messages,
1510
+ formats: e.exportFormats,
1511
+ busy: e.busy,
1512
+ onExport: m[6] || (m[6] = (d) => o("export", d))
1513
+ }, null, 8, ["messages", "formats", "busy"])) : j("", !0),
1514
+ e.showPrint ? ($(), C("button", {
1515
+ key: 2,
1516
+ class: "mrp-nav",
1517
+ type: "button",
1518
+ disabled: e.busy,
1519
+ onClick: m[7] || (m[7] = (d) => o("print"))
1520
+ }, [
1521
+ ne(re, { name: "print" }),
1522
+ ce(x(e.messages.print), 1)
1523
+ ], 8, fr)) : j("", !0),
1524
+ e.showPdfWindow ? ($(), C("button", {
1525
+ key: 3,
1526
+ class: "mrp-nav",
1527
+ type: "button",
1528
+ disabled: e.busy,
1529
+ onClick: m[8] || (m[8] = (d) => o("pdf-window"))
1530
+ }, [
1531
+ ne(re, { name: "external" }),
1532
+ ce(x(e.messages.pdfWindow), 1)
1533
+ ], 8, mr)) : j("", !0)
1534
+ ], 8, cr)) : j("", !0),
1535
+ e.showSettings ? ($(), C("button", {
1536
+ key: 5,
1537
+ class: ke(["mrp-nav mrp-settings-toggle", { "mrp-active": e.settingsOpen }]),
1538
+ type: "button",
1539
+ "aria-label": e.messages.settings ?? "设置",
1540
+ "aria-haspopup": "dialog",
1541
+ "aria-expanded": !!e.settingsOpen,
1542
+ onClick: m[9] || (m[9] = (d) => o("settings-toggle"))
1543
+ }, [
1544
+ ne(re, { name: "settings" }),
1545
+ ce(x(e.messages.settings ?? "设置"), 1)
1546
+ ], 10, gr)) : j("", !0),
1547
+ e.showSearch !== !1 && e.search.visible ? ($(), C("div", {
1548
+ key: 6,
1549
+ class: "mrp-search-panel",
1550
+ role: "search",
1551
+ "aria-label": e.messages.search ?? "内容搜索"
1552
+ }, [
1553
+ p("div", {
1554
+ class: ke(["mrp-search", { "mrp-search-no-results": e.search.query && !e.search.searching && !e.search.matchCount }])
1555
+ }, [
1556
+ ne(re, { name: "search" }),
1557
+ p("input", {
1558
+ ref_key: "searchInputRef",
1559
+ ref: s,
1560
+ class: "mrp-search-input",
1561
+ type: "text",
1562
+ autocomplete: "off",
1563
+ spellcheck: "false",
1564
+ placeholder: e.messages.searchPlaceholder,
1565
+ "aria-label": e.messages.search ?? e.messages.searchPlaceholder,
1566
+ value: e.search.query,
1567
+ onInput: m[10] || (m[10] = (d) => o("search-input", d.target.value)),
1568
+ onKeydown: m[11] || (m[11] = //@ts-ignore
1569
+ (...d) => u(r).onKeydown && u(r).onKeydown(...d))
1570
+ }, null, 40, vr),
1571
+ e.search.query ? ($(), C("button", {
1572
+ key: 0,
1573
+ class: "mrp-nav mrp-search-clear mrp-icon-button",
1574
+ type: "button",
1575
+ "aria-label": e.messages.clearSearch ?? "清除搜索",
1576
+ onClick: c
1577
+ }, [
1578
+ ne(re, {
1579
+ name: "close",
1580
+ size: 13
1581
+ })
1582
+ ], 8, br)) : j("", !0),
1583
+ e.search.query ? ($(), C("span", hr, x(e.search.searching ? e.messages.searching ?? "搜索中…" : i()), 1)) : j("", !0),
1584
+ p("button", {
1585
+ class: "mrp-nav mrp-icon-button",
1586
+ type: "button",
1587
+ disabled: e.search.matchCount === 0 || e.search.searching,
1588
+ "aria-label": e.messages.prevSearchMatch ?? "上一个匹配",
1589
+ onClick: m[12] || (m[12] = (d) => o("search-nav", -1))
1590
+ }, [
1591
+ ne(re, {
1592
+ name: "chevron-up",
1593
+ size: 14
1594
+ })
1595
+ ], 8, yr),
1596
+ p("button", {
1597
+ class: "mrp-nav mrp-icon-button",
1598
+ type: "button",
1599
+ disabled: e.search.matchCount === 0 || e.search.searching,
1600
+ "aria-label": e.messages.nextSearchMatch ?? "下一个匹配",
1601
+ onClick: m[13] || (m[13] = (d) => o("search-nav", 1))
1602
+ }, [
1603
+ ne(re, {
1604
+ name: "chevron-down",
1605
+ size: 14
1606
+ })
1607
+ ], 8, wr),
1608
+ p("button", {
1609
+ class: "mrp-nav mrp-search-close mrp-icon-button",
1610
+ type: "button",
1611
+ "aria-label": e.messages.closeSearch ?? "关闭搜索",
1612
+ onClick: m[14] || (m[14] = //@ts-ignore
1613
+ (...d) => u(r).close && u(r).close(...d))
1614
+ }, [
1615
+ ne(re, {
1616
+ name: "close",
1617
+ size: 14
1618
+ })
1619
+ ], 8, xr)
1620
+ ], 2),
1621
+ p("span", kr, x(e.search.query && !e.search.searching && !e.search.matchCount ? e.messages.searchNoMatches ?? "没有匹配内容" : e.messages.searchHint ?? "Enter 下一个 · Shift+Enter 上一个"), 1)
1622
+ ], 8, pr)) : j("", !0)
1623
+ ], 8, tr));
1624
+ }
1625
+ }), $r = /* @__PURE__ */ we(Er, [["__scopeId", "data-v-5f4b04d8"]]);
1626
+ function Cr(e) {
1627
+ const t = e.meta?.record;
1628
+ if (!(!t || typeof t != "object" || typeof t.dataset != "string") && [t.rowIndex, t.copyIndex, t.templatePageIndex].every((n) => Number.isSafeInteger(n) && Number(n) >= 0) && !(t.rowKey !== void 0 && typeof t.rowKey != "string" && typeof t.rowKey != "number"))
1629
+ return t;
1630
+ }
1631
+ function Ir(e) {
1632
+ const t = [], n = [];
1633
+ let a;
1634
+ for (const [o, r] of (e?.pages ?? []).entries()) {
1635
+ const s = Cr(r);
1636
+ if (!s) {
1637
+ n.push(-1), a = void 0;
1638
+ continue;
1639
+ }
1640
+ (!a || s.dataset !== a.dataset || s.rowIndex !== a.rowIndex || s.rowKey !== a.rowKey || s.copyIndex === 0 && s.templatePageIndex === 0) && t.push({ page: o + 1, ...s.rowKey === void 0 ? {} : { rowKey: s.rowKey } }), n.push(t.length - 1), a = s;
1641
+ }
1642
+ return { entries: t, pageRecords: n };
1643
+ }
1644
+ const Pr = ["aria-label"], Sr = {
1645
+ key: 0,
1646
+ class: "mrp-record-arrows"
1647
+ }, Rr = ["aria-label", "title", "disabled"], Mr = ["aria-label", "title", "disabled"], Tr = {
1648
+ class: "mrp-record-info",
1649
+ "aria-live": "polite"
1650
+ }, Or = ["title"], Dr = ["title"], Ar = /* @__PURE__ */ ye({
1651
+ __name: "ReportRecordNavigation",
1652
+ props: {
1653
+ plan: {},
1654
+ currentPage: {},
1655
+ messages: {},
1656
+ busy: { type: Boolean }
1657
+ },
1658
+ emits: ["goto"],
1659
+ setup(e, { emit: t }) {
1660
+ const n = e, a = t, o = N(() => Ir(n.plan)), r = N(() => o.value.pageRecords[n.currentPage - 1] ?? -1), s = N(() => r.value >= 0 ? o.value.entries[r.value] : void 0), l = N(() => (n.messages.recordInfo ?? "记录 {cur} / {total}").replace("{cur}", String(r.value + 1)).replace("{total}", String(o.value.entries.length))), i = N(() => {
1661
+ const f = n.plan?.pages[n.currentPage - 1]?.meta?.title;
1662
+ return typeof f == "string" ? f : "";
1663
+ });
1664
+ function c(f) {
1665
+ const m = o.value.entries[r.value + f];
1666
+ !n.busy && r.value >= 0 && m && a("goto", m.page);
1667
+ }
1668
+ return (f, m) => s.value ? ($(), C("nav", {
1669
+ key: 0,
1670
+ class: "mrp-record-navigation",
1671
+ "aria-label": e.messages.recordNavigation ?? "标签记录"
1672
+ }, [
1673
+ o.value.entries.length > 1 ? ($(), C("div", Sr, [
1674
+ p("button", {
1675
+ type: "button",
1676
+ "aria-label": e.messages.prevRecord ?? "上一条记录",
1677
+ title: e.messages.prevRecord ?? "上一条记录",
1678
+ disabled: e.busy || r.value <= 0,
1679
+ onClick: m[0] || (m[0] = (d) => c(-1))
1680
+ }, [
1681
+ ne(re, {
1682
+ name: "chevron-left",
1683
+ size: 13
1684
+ })
1685
+ ], 8, Rr),
1686
+ p("button", {
1687
+ type: "button",
1688
+ "aria-label": e.messages.nextRecord ?? "下一条记录",
1689
+ title: e.messages.nextRecord ?? "下一条记录",
1690
+ disabled: e.busy || r.value >= o.value.entries.length - 1,
1691
+ onClick: m[1] || (m[1] = (d) => c(1))
1692
+ }, [
1693
+ ne(re, {
1694
+ name: "chevron-right",
1695
+ size: 13
1696
+ })
1697
+ ], 8, Mr)
1698
+ ])) : j("", !0),
1699
+ p("span", Tr, x(l.value), 1),
1700
+ s.value.rowKey !== void 0 ? ($(), C("code", {
1701
+ key: 1,
1702
+ title: String(s.value.rowKey)
1703
+ }, x(s.value.rowKey), 9, Or)) : j("", !0),
1704
+ i.value ? ($(), C("span", {
1705
+ key: 2,
1706
+ class: "mrp-record-face",
1707
+ title: i.value
1708
+ }, x(i.value), 9, Dr)) : j("", !0)
1709
+ ], 8, Pr)) : j("", !0);
1710
+ }
1711
+ }), Fr = /* @__PURE__ */ we(Ar, [["__scopeId", "data-v-aa94fa14"]]), zr = ["aria-label", "aria-busy"], Lr = { class: "mrp-calculation-heading" }, qr = { class: "mrp-calculation-controls" }, Nr = ["aria-label", "value", "disabled"], Br = ["value"], Kr = { class: "mrp-calculation-precision" }, jr = ["aria-label", "value", "disabled"], Wr = {
1712
+ key: 0,
1713
+ class: "mrp-calculation-expression"
1714
+ }, Hr = ["aria-label", "value", "disabled"], Ur = { class: "mrp-calculation-actions" }, Vr = {
1715
+ key: 1,
1716
+ class: "mrp-calculation-diagnostic",
1717
+ role: "alert"
1718
+ }, Gr = {
1719
+ key: 2,
1720
+ class: "mrp-calculation-result",
1721
+ role: "status",
1722
+ "aria-live": "polite"
1723
+ }, Jr = { key: 0 }, Xr = {
1724
+ key: 3,
1725
+ class: "mrp-calculation-empty"
1726
+ }, Yr = { class: "mrp-calculation-local" }, Zr = /* @__PURE__ */ ye({
1727
+ __name: "ReportCalculationPanel",
1728
+ props: {
1729
+ state: {},
1730
+ messages: {}
1731
+ },
1732
+ setup(e) {
1733
+ const t = e, n = `mrp-calculation-expression-hint-${Xt()?.uid ?? 0}`, a = N(() => [
1734
+ ["sum", t.messages.calculationSum],
1735
+ ["average", t.messages.calculationAverage],
1736
+ ["min", t.messages.calculationMin],
1737
+ ["max", t.messages.calculationMax],
1738
+ ["count", t.messages.calculationCount],
1739
+ ["median", t.messages.calculationMedian],
1740
+ ["expression", t.messages.calculationCustom]
1741
+ ]), o = N(() => {
1742
+ const r = t.state.error.value;
1743
+ if (!r) return "";
1744
+ const s = t.messages;
1745
+ return { selection: s.calculationErrorSelection, limit: s.calculationErrorLimit, expression: s.calculationErrorExpression, division: s.calculationErrorDivision, overflow: s.calculationErrorOverflow, precision: s.calculationErrorPrecision }[r];
1746
+ });
1747
+ return (r, s) => ($(), C("section", {
1748
+ class: "mrp-calculation",
1749
+ "aria-label": e.messages.calculationTitle,
1750
+ "aria-busy": e.state.busy.value
1751
+ }, [
1752
+ p("header", Lr, [
1753
+ s[5] || (s[5] = p("span", {
1754
+ class: "mrp-calculation-symbol",
1755
+ "aria-hidden": "true"
1756
+ }, "∑", -1)),
1757
+ p("div", null, [
1758
+ p("strong", null, x(e.messages.calculationTitle), 1),
1759
+ p("p", null, x(e.messages.calculationHint), 1)
1760
+ ])
1761
+ ]),
1762
+ p("div", qr, [
1763
+ p("label", null, [
1764
+ p("span", null, x(e.messages.calculationFormula), 1),
1765
+ p("select", {
1766
+ "aria-label": e.messages.calculationFormula,
1767
+ value: e.state.operation.value,
1768
+ onChange: s[0] || (s[0] = (l) => e.state.setOperation(l.target.value)),
1769
+ disabled: e.state.busy.value
1770
+ }, [
1771
+ ($(!0), C(be, null, he(a.value, ([l, i]) => ($(), C("option", {
1772
+ key: l,
1773
+ value: l
1774
+ }, x(i), 9, Br))), 128))
1775
+ ], 40, Nr)
1776
+ ]),
1777
+ p("label", Kr, [
1778
+ p("span", null, x(e.messages.calculationPrecision), 1),
1779
+ p("input", {
1780
+ "aria-label": e.messages.calculationPrecision,
1781
+ value: e.state.precision.value,
1782
+ onChange: s[1] || (s[1] = (l) => e.state.setPrecision(Number(l.target.value))),
1783
+ type: "number",
1784
+ min: "0",
1785
+ max: "12",
1786
+ step: "1",
1787
+ disabled: e.state.busy.value
1788
+ }, null, 40, jr)
1789
+ ])
1790
+ ]),
1791
+ e.state.operation.value === "expression" ? ($(), C("label", Wr, [
1792
+ p("span", null, x(e.messages.calculationExpression), 1),
1793
+ p("input", {
1794
+ "aria-label": e.messages.calculationExpression,
1795
+ "aria-describedby": n,
1796
+ value: e.state.expression.value,
1797
+ onInput: s[2] || (s[2] = (l) => e.state.setExpression(l.target.value)),
1798
+ type: "text",
1799
+ maxlength: "256",
1800
+ spellcheck: "false",
1801
+ disabled: e.state.busy.value,
1802
+ placeholder: "SUM / COUNT"
1803
+ }, null, 40, Hr),
1804
+ p("small", { id: n }, x(e.messages.calculationExpressionHint), 1)
1805
+ ])) : j("", !0),
1806
+ p("div", Ur, [
1807
+ e.state.busy.value ? ($(), C("button", {
1808
+ key: 0,
1809
+ type: "button",
1810
+ onClick: s[3] || (s[3] = (l) => e.state.cancel())
1811
+ }, x(e.messages.calculationCancel), 1)) : ($(), C("button", {
1812
+ key: 1,
1813
+ class: "mrp-calculation-run",
1814
+ type: "button",
1815
+ onClick: s[4] || (s[4] = (l) => e.state.run())
1816
+ }, x(e.messages.calculationRun), 1))
1817
+ ]),
1818
+ o.value ? ($(), C("p", Vr, x(o.value), 1)) : e.state.result.value ? ($(), C("div", Gr, [
1819
+ p("span", null, x(e.messages.calculationResult), 1),
1820
+ p("output", null, x(e.state.result.value.formatted), 1),
1821
+ p("small", null, [
1822
+ p("span", null, x(e.messages.calculationIncluded) + " " + x(e.state.result.value.numericCells), 1),
1823
+ p("span", null, x(e.messages.calculationExcluded) + " " + x(e.state.result.value.excludedCells), 1)
1824
+ ]),
1825
+ e.state.result.value.numericCells === 0 ? ($(), C("p", Jr, x(e.messages.calculationEmpty), 1)) : j("", !0)
1826
+ ])) : ($(), C("p", Xr, x(e.messages.calculationNoSelection), 1)),
1827
+ p("p", Yr, x(e.messages.calculationLocal), 1)
1828
+ ], 8, zr));
1829
+ }
1830
+ }), Qr = /* @__PURE__ */ we(Zr, [["__scopeId", "data-v-ee359251"]]);
1831
+ function _r(e) {
1832
+ const t = Z("sum"), n = Z("SUM / COUNT"), a = Z(2), o = Z(!1), r = ve(null), s = Z(null);
1833
+ let l = null, i = 0;
1834
+ function c() {
1835
+ i++, l?.abort(), l = null, o.value = !1;
1836
+ }
1837
+ function f() {
1838
+ c(), r.value = null, s.value = null;
1839
+ }
1840
+ async function m() {
1841
+ if (f(), !e.enabled()) return;
1842
+ const w = e.plan.value, v = e.selection.value;
1843
+ if (!w || !v) {
1844
+ s.value = "selection";
1845
+ return;
1846
+ }
1847
+ const L = ++i, b = new AbortController();
1848
+ l = b, o.value = !0;
1849
+ try {
1850
+ const R = await Ta(w, v, { operation: t.value, expression: n.value, precision: a.value, signal: b.signal });
1851
+ L === i && e.plan.value === w && e.selection.value === v && e.enabled() && (r.value = R);
1852
+ } catch (R) {
1853
+ L === i && !b.signal.aborted && (s.value = R instanceof Oa ? R.code : "expression");
1854
+ } finally {
1855
+ L === i && (o.value = !1, l = null);
1856
+ }
1857
+ }
1858
+ pe([e.plan, e.selection, () => e.enabled(), t, n, a], f, { flush: "sync" }), Ie(f);
1859
+ function d(w) {
1860
+ t.value = w;
1861
+ }
1862
+ function E(w) {
1863
+ n.value = w;
1864
+ }
1865
+ function k(w) {
1866
+ a.value = w;
1867
+ }
1868
+ return { operation: t, expression: n, precision: a, busy: o, result: r, error: s, run: m, cancel: c, clear: f, setOperation: d, setExpression: E, setPrecision: k };
1869
+ }
1870
+ const es = ["aria-label"], ts = { class: "mrp-settings-header" }, ns = ["aria-label"], as = ["aria-label"], os = ["id", "aria-selected", "aria-controls", "tabindex", "onClick", "onKeydown"], rs = { class: "mrp-settings-content" }, ss = ["id", "aria-labelledby", "hidden"], ls = { key: 0 }, is = { class: "mrp-settings-option" }, us = ["checked", "disabled"], cs = { class: "mrp-settings-option" }, ds = ["value", "disabled"], fs = ["id", "aria-labelledby", "hidden"], ms = { key: 0 }, gs = ["checked", "disabled", "onChange"], ps = {
1871
+ key: 0,
1872
+ class: "mrp-settings-note"
1873
+ }, vs = {
1874
+ key: 1,
1875
+ class: "mrp-settings-note"
1876
+ }, bs = ["id", "aria-labelledby", "hidden"], hs = { class: "mrp-settings-intro" }, ys = { class: "mrp-settings-option mrp-settings-feature" }, ws = ["id"], xs = ["aria-label", "aria-describedby", "checked", "disabled"], ks = ["disabled"], Es = /* @__PURE__ */ ye({
1877
+ __name: "ReportSettings",
1878
+ props: {
1879
+ available: {},
1880
+ enabled: {},
1881
+ messages: {},
1882
+ persistedEditing: { type: Boolean },
1883
+ busy: { type: Boolean },
1884
+ interaction: {},
1885
+ section: {}
1886
+ },
1887
+ emits: ["change", "reset", "close", "interaction", "section"],
1888
+ setup(e, { emit: t }) {
1889
+ const n = e, a = t, o = Z(null), r = N(() => n.section ?? "general"), s = "mrp-settings-" + Xt()?.uid, l = N(() => [
1890
+ { key: "general", label: n.messages.settingsGeneral ?? "常规" },
1891
+ { key: "tools", label: n.messages.settingsTools ?? "工具" },
1892
+ { key: "advanced", label: n.messages.settingsAdvanced ?? "高级" }
1893
+ ]);
1894
+ function i(w, v) {
1895
+ const b = { ArrowRight: (v + 1) % 3, ArrowLeft: (v + 2) % 3, Home: 0, End: 2 }[w.key];
1896
+ b !== void 0 && (w.preventDefault(), a("section", l.value[b].key), o.value?.querySelector("#" + s + "-tab-" + l.value[b].key)?.focus());
1897
+ }
1898
+ const c = Z(null);
1899
+ let f = null;
1900
+ const m = N(() => [
1901
+ { label: n.messages.settingsDisplay, tools: [
1902
+ ["search", n.messages.search],
1903
+ ["thumbnails", n.messages.thumbnails],
1904
+ ["zoom", n.messages.zoom]
1905
+ ] },
1906
+ { label: n.messages.settingsExport, tools: [
1907
+ ["html", n.messages.exportHtml],
1908
+ ["pdf", n.messages.exportPdf],
1909
+ ["xlsx", n.messages.exportExcel],
1910
+ ["png", n.messages.exportImage],
1911
+ ["word", n.messages.exportWord],
1912
+ ["print", n.messages.print],
1913
+ ["pdfWindow", n.messages.pdfWindow]
1914
+ ] },
1915
+ { label: n.messages.settingsData, tools: [
1916
+ ["editing", n.messages.editCell],
1917
+ ["import", n.messages.importExcel]
1918
+ ] }
1919
+ ].map((w) => ({ ...w, tools: w.tools.map(([v, L]) => ({ key: v, label: L })) })));
1920
+ function d(w, v) {
1921
+ const L = w.target, b = L.checked;
1922
+ L.checked = n.enabled[v], a("change", v, b);
1923
+ }
1924
+ function E(w) {
1925
+ return !o.value || w.defaultPrevented ? !1 : w.target instanceof Node && o.value.contains(w.target) ? !0 : w.target instanceof Element && w.target.closest('[role="dialog"],dialog[open]') ? !1 : !Array.from(document.querySelectorAll('[aria-modal="true"],dialog[open]')).some((v) => v !== o.value && !o.value.contains(v));
1926
+ }
1927
+ function k(w) {
1928
+ if (!E(w)) return;
1929
+ if (w.key === "Escape") {
1930
+ w.preventDefault(), w.stopPropagation(), a("close");
1931
+ return;
1932
+ }
1933
+ if (w.key !== "Tab") return;
1934
+ const v = Array.from(o.value?.querySelectorAll("a[href],button:not(:disabled),input:not(:disabled),textarea:not(:disabled),select:not(:disabled),[tabindex='0']") ?? []).filter((A) => !A.closest("[hidden]") && A.tabIndex !== -1), L = v?.[0], b = v?.[v.length - 1];
1935
+ (!o.value?.contains(document.activeElement) || w.shiftKey && document.activeElement === L || !w.shiftKey && document.activeElement === b) && (w.preventDefault(), w.stopPropagation(), (w.shiftKey ? b : L)?.focus());
1936
+ }
1937
+ return Et(() => {
1938
+ const w = o.value?.closest(".mach-report-preview")?.querySelector(".mrp-settings-toggle"), v = document.activeElement;
1939
+ f = v instanceof HTMLElement && v !== document.body && !o.value?.contains(v) ? v : w ?? null, c.value?.focus(), document.addEventListener("keydown", k);
1940
+ }), $t(() => {
1941
+ document.removeEventListener("keydown", k), f?.isConnected && f.focus();
1942
+ }), (w, v) => ($(), C("div", {
1943
+ class: "mrp-settings-backdrop",
1944
+ onClick: v[5] || (v[5] = st((L) => w.$emit("close"), ["self"]))
1945
+ }, [
1946
+ p("section", {
1947
+ ref_key: "panel",
1948
+ ref: o,
1949
+ class: "mrp-settings-panel",
1950
+ role: "dialog",
1951
+ "aria-modal": "true",
1952
+ "aria-label": e.messages.settings
1953
+ }, [
1954
+ p("header", ts, [
1955
+ p("div", null, [
1956
+ v[6] || (v[6] = p("span", { class: "mrp-settings-eyebrow" }, "MACH REPORT", -1)),
1957
+ p("strong", null, x(e.messages.settings), 1),
1958
+ p("p", null, x(e.messages.settingsLocal), 1)
1959
+ ]),
1960
+ p("button", {
1961
+ ref_key: "closeButton",
1962
+ ref: c,
1963
+ class: "mrp-settings-close",
1964
+ type: "button",
1965
+ "aria-label": e.messages.settingsClose,
1966
+ onClick: v[0] || (v[0] = (L) => w.$emit("close"))
1967
+ }, [...v[7] || (v[7] = [
1968
+ p("svg", {
1969
+ width: "16",
1970
+ height: "16",
1971
+ viewBox: "0 0 20 20",
1972
+ fill: "none",
1973
+ "aria-hidden": "true"
1974
+ }, [
1975
+ p("path", {
1976
+ d: "m5 5 10 10M15 5 5 15",
1977
+ stroke: "currentColor",
1978
+ "stroke-width": "1.6",
1979
+ "stroke-linecap": "round"
1980
+ })
1981
+ ], -1)
1982
+ ])], 8, ns)
1983
+ ]),
1984
+ p("div", {
1985
+ class: "mrp-settings-tabs",
1986
+ role: "tablist",
1987
+ "aria-label": e.messages.settings
1988
+ }, [
1989
+ ($(!0), C(be, null, he(l.value, (L, b) => ($(), C("button", {
1990
+ id: s + "-tab-" + L.key,
1991
+ key: L.key,
1992
+ type: "button",
1993
+ role: "tab",
1994
+ "aria-selected": r.value === L.key,
1995
+ "aria-controls": s + "-panel-" + L.key,
1996
+ tabindex: r.value === L.key ? 0 : -1,
1997
+ onClick: (R) => w.$emit("section", L.key),
1998
+ onKeydown: (R) => i(R, b)
1999
+ }, x(L.label), 41, os))), 128))
2000
+ ], 8, as),
2001
+ p("div", rs, [
2002
+ p("section", {
2003
+ id: s + "-panel-general",
2004
+ role: "tabpanel",
2005
+ "aria-labelledby": s + "-tab-general",
2006
+ hidden: r.value !== "general"
2007
+ }, [
2008
+ lt(w.$slots, "default", {}, void 0, !0),
2009
+ e.interaction ? ($(), C("fieldset", ls, [
2010
+ p("legend", null, x(e.messages.settingsPanes), 1),
2011
+ p("label", is, [
2012
+ p("span", null, x(e.messages.freezeHeaders), 1),
2013
+ p("input", {
2014
+ type: "checkbox",
2015
+ checked: e.interaction.freezeHeaders,
2016
+ disabled: e.busy,
2017
+ onChange: v[1] || (v[1] = (L) => w.$emit("interaction", { freezeHeaders: L.target.checked }))
2018
+ }, null, 40, us)
2019
+ ]),
2020
+ p("label", cs, [
2021
+ p("span", null, x(e.messages.frozenColumns), 1),
2022
+ p("input", {
2023
+ class: "mrp-frozen-count",
2024
+ type: "number",
2025
+ min: "0",
2026
+ max: "20",
2027
+ value: e.interaction.frozenColumns ?? 0,
2028
+ disabled: e.busy,
2029
+ onChange: v[2] || (v[2] = (L) => w.$emit("interaction", { frozenColumns: Math.max(0, Math.min(20, Number(L.target.value) || 0)) }))
2030
+ }, null, 40, ds)
2031
+ ])
2032
+ ])) : j("", !0)
2033
+ ], 8, ss),
2034
+ p("section", {
2035
+ id: s + "-panel-tools",
2036
+ role: "tabpanel",
2037
+ "aria-labelledby": s + "-tab-tools",
2038
+ hidden: r.value !== "tools"
2039
+ }, [
2040
+ ($(!0), C(be, null, he(m.value, (L) => ($(), C("fieldset", {
2041
+ key: L.label
2042
+ }, [
2043
+ p("legend", null, x(L.label), 1),
2044
+ ($(!0), C(be, null, he(L.tools, (b) => ($(), C("label", {
2045
+ key: b.key,
2046
+ class: ke(["mrp-settings-option", { "mrp-settings-unavailable": !e.available[b.key] }])
2047
+ }, [
2048
+ p("span", null, [
2049
+ ce(x(b.label), 1),
2050
+ e.available[b.key] ? j("", !0) : ($(), C("small", ms, x(e.messages.settingsUnavailable), 1))
2051
+ ]),
2052
+ p("input", {
2053
+ type: "checkbox",
2054
+ checked: e.enabled[b.key],
2055
+ disabled: e.busy || !e.available[b.key],
2056
+ onChange: (R) => d(R, b.key)
2057
+ }, null, 40, gs)
2058
+ ], 2))), 128))
2059
+ ]))), 128)),
2060
+ e.available.editing ? ($(), C("p", ps, x(e.persistedEditing ? e.messages.editingSaved : e.messages.editingLocal), 1)) : j("", !0),
2061
+ e.available.import ? ($(), C("p", vs, x(e.messages.importLocal), 1)) : j("", !0)
2062
+ ], 8, fs),
2063
+ p("section", {
2064
+ id: s + "-panel-advanced",
2065
+ role: "tabpanel",
2066
+ "aria-labelledby": s + "-tab-advanced",
2067
+ hidden: r.value !== "advanced"
2068
+ }, [
2069
+ p("p", hs, x(e.messages.settingsAdvancedDescription), 1),
2070
+ p("label", ys, [
2071
+ p("span", null, [
2072
+ ce(x(e.messages.settingsCalculations), 1),
2073
+ p("small", {
2074
+ id: s + "-calculation-description"
2075
+ }, x(e.messages.settingsCalculationsDescription), 9, ws)
2076
+ ]),
2077
+ p("input", {
2078
+ type: "checkbox",
2079
+ "aria-label": e.messages.settingsCalculations,
2080
+ "aria-describedby": s + "-calculation-description",
2081
+ checked: e.interaction?.calculations === !0,
2082
+ disabled: e.busy,
2083
+ onChange: v[3] || (v[3] = (L) => w.$emit("interaction", { calculations: L.target.checked }))
2084
+ }, null, 40, xs)
2085
+ ]),
2086
+ e.interaction?.calculations ? lt(w.$slots, "advanced", {}, void 0, !0, 0) : j("", !0)
2087
+ ], 8, bs)
2088
+ ]),
2089
+ p("footer", null, [
2090
+ p("button", {
2091
+ type: "button",
2092
+ disabled: e.busy,
2093
+ onClick: v[4] || (v[4] = (L) => w.$emit("reset"))
2094
+ }, x(e.messages.settingsReset), 9, ks),
2095
+ p("span", null, x(e.messages.settingsLocal), 1)
2096
+ ])
2097
+ ], 8, es)
2098
+ ]));
2099
+ }
2100
+ }), $s = /* @__PURE__ */ we(Es, [["__scopeId", "data-v-36723612"]]), Cs = {
2101
+ class: "mrp-empty",
2102
+ role: "status"
2103
+ }, Is = { key: 0 }, Ps = /* @__PURE__ */ ye({
2104
+ __name: "ReportEmpty",
2105
+ props: {
2106
+ title: {},
2107
+ description: {}
2108
+ },
2109
+ setup(e) {
2110
+ return (t, n) => ($(), C("div", Cs, [
2111
+ n[0] || (n[0] = $a('<svg class="mrp-empty-art" viewBox="0 0 160 112" fill="none" aria-hidden="true" data-v-3e16b87e><ellipse cx="80" cy="100" rx="54" ry="7" fill="currentColor" opacity=".05" data-v-3e16b87e></ellipse><rect x="34" y="15" width="92" height="78" rx="9" fill="currentColor" opacity=".10" data-v-3e16b87e></rect><rect x="42" y="9" width="76" height="78" rx="7" fill="var(--mrp-toolbar-bg, #fff)" stroke="currentColor" stroke-opacity=".2" stroke-width="1.5" data-v-3e16b87e></rect><path d="M55 27H105M55 42H105M55 57H85M55 72H76M71 27V72M89 27V57" stroke="currentColor" stroke-opacity=".4" stroke-width="1.5" stroke-linecap="round" data-v-3e16b87e></path><circle cx="112" cy="76" r="16" fill="var(--mrp-toolbar-bg, #fff)" stroke="currentColor" stroke-opacity=".35" stroke-width="2" data-v-3e16b87e></circle><path d="M124 88L137 101M106 76H118" stroke="currentColor" stroke-opacity=".45" stroke-width="3" stroke-linecap="round" data-v-3e16b87e></path><circle cx="27" cy="38" r="3" fill="currentColor" opacity=".12" data-v-3e16b87e></circle><circle cx="132" cy="24" r="2" fill="currentColor" opacity=".2" data-v-3e16b87e></circle></svg>', 1)),
2112
+ p("strong", null, x(e.title), 1),
2113
+ e.description ? ($(), C("p", Is, x(e.description), 1)) : j("", !0)
2114
+ ]));
2115
+ }
2116
+ }), Sn = /* @__PURE__ */ we(Ps, [["__scopeId", "data-v-3e16b87e"]]), Ss = ["aria-label"], Rs = /* @__PURE__ */ ye({
2117
+ __name: "ReportDiscardDialog",
2118
+ props: {
2119
+ messages: {}
2120
+ },
2121
+ emits: ["answer"],
2122
+ setup(e, { emit: t }) {
2123
+ const n = t, a = Z(null), o = Z(null);
2124
+ let r = null;
2125
+ function s(l) {
2126
+ l.key === "Escape" && (l.preventDefault(), n("answer", !1)), l.key === "Tab" && (l.preventDefault(), document.activeElement === a.value ? o.value?.focus() : a.value?.focus());
2127
+ }
2128
+ return Et(() => {
2129
+ r = document.activeElement instanceof HTMLElement ? document.activeElement : null, a.value?.focus();
2130
+ }), $t(() => {
2131
+ r?.isConnected && r.focus();
2132
+ }), (l, i) => ($(), C("div", {
2133
+ class: "mrp-discard-backdrop",
2134
+ onKeydown: s,
2135
+ onClick: i[2] || (i[2] = st((c) => n("answer", !1), ["self"]))
2136
+ }, [
2137
+ p("section", {
2138
+ class: "mrp-discard-dialog",
2139
+ role: "alertdialog",
2140
+ "aria-modal": "true",
2141
+ "aria-label": e.messages.discardTitle
2142
+ }, [
2143
+ p("strong", null, x(e.messages.discardTitle), 1),
2144
+ p("p", null, x(e.messages.discardDescription), 1),
2145
+ p("footer", null, [
2146
+ p("button", {
2147
+ ref_key: "keep",
2148
+ ref: a,
2149
+ type: "button",
2150
+ onClick: i[0] || (i[0] = (c) => n("answer", !1))
2151
+ }, x(e.messages.discardKeep), 513),
2152
+ p("button", {
2153
+ ref_key: "discard",
2154
+ ref: o,
2155
+ type: "button",
2156
+ onClick: i[1] || (i[1] = (c) => n("answer", !0))
2157
+ }, x(e.messages.discardProceed), 513)
2158
+ ])
2159
+ ], 8, Ss)
2160
+ ], 32));
2161
+ }
2162
+ }), Ms = /* @__PURE__ */ we(Rs, [["__scopeId", "data-v-f7590294"]]), Ts = {
2163
+ key: 0,
2164
+ class: "mrp-task-status",
2165
+ role: "status",
2166
+ "aria-live": "polite"
2167
+ }, Os = { key: 0 }, Ds = ["value", "max", "aria-label"], As = /* @__PURE__ */ ye({
2168
+ __name: "ReportTaskStatus",
2169
+ props: {
2170
+ task: {},
2171
+ messages: {}
2172
+ },
2173
+ emits: ["cancel"],
2174
+ setup(e) {
2175
+ const t = e, n = N(() => ({ query: t.messages.taskQuery, validate: t.messages.taskValidate, layout: t.messages.taskLayout, assets: t.messages.taskAssets, import: t.messages.importing, encode: t.messages.taskEncode, download: t.messages.taskDownload, print: t.messages.taskPrint })), a = N(() => t.task?.total === void 0 ? "" : `${t.task.completed ?? 0} / ${t.task.total}`);
2176
+ return (o, r) => e.task && (e.task.status === "running" || e.task.status === "cancelled") ? ($(), C("div", Ts, [
2177
+ p("span", null, [
2178
+ ce(x(e.task.status === "cancelled" ? e.messages.taskCancelled : n.value[e.task.stage]) + " ", 1),
2179
+ e.task.status === "running" ? ($(), C("small", Os, x(a.value), 1)) : j("", !0)
2180
+ ]),
2181
+ e.task.status === "running" && e.task.total !== void 0 ? ($(), C("progress", {
2182
+ key: 0,
2183
+ value: e.task.completed ?? 0,
2184
+ max: e.task.total,
2185
+ "aria-label": n.value[e.task.stage]
2186
+ }, null, 8, Ds)) : j("", !0),
2187
+ e.task.status === "running" && e.task.cancellable ? ($(), C("button", {
2188
+ key: 1,
2189
+ type: "button",
2190
+ onClick: r[0] || (r[0] = (s) => o.$emit("cancel"))
2191
+ }, x(e.messages.taskCancel), 1)) : j("", !0)
2192
+ ])) : j("", !0);
2193
+ }
2194
+ }), Fs = /* @__PURE__ */ we(As, [["__scopeId", "data-v-657ac599"]]), zs = {
2195
+ key: 0,
2196
+ class: "mrp-diagnostics"
2197
+ }, Ls = ["aria-label", "placeholder"], qs = { key: 0 }, Ns = ["onClick"], Bs = { key: 0 }, Ks = /* @__PURE__ */ ye({
2198
+ __name: "ReportDiagnostics",
2199
+ props: {
2200
+ entries: {},
2201
+ messages: {}
2202
+ },
2203
+ emits: ["locate"],
2204
+ setup(e) {
2205
+ const t = e, n = Z(""), a = N(() => ({
2206
+ "unsupported-style": t.messages.diagnosticUnsupportedStyle,
2207
+ "missing-image": t.messages.diagnosticMissingImage,
2208
+ "unsupported-component": t.messages.diagnosticUnsupported,
2209
+ "unsupported-image-format": t.messages.diagnosticImageFormat,
2210
+ "rich-text-flattened": t.messages.diagnosticRichText,
2211
+ "nested-components-omitted": t.messages.diagnosticNested,
2212
+ "async-image-required": t.messages.diagnosticImageAsync,
2213
+ "image-decode-failed": t.messages.diagnosticImageDecode,
2214
+ "asset-render-failed": t.messages.diagnosticAssetFailed,
2215
+ "asset-budget-exceeded": t.messages.diagnosticAssetBudget
2216
+ })), o = N(() => {
2217
+ const l = n.value.trim().toLocaleLowerCase();
2218
+ return l ? t.entries.filter((i) => `${i.code} ${i.message} ${a.value[i.code] ?? ""} ${i.path ?? ""} ${s(i)} ${i.format ?? ""}`.toLocaleLowerCase().includes(l)) : t.entries;
2219
+ }), r = N(() => o.value.slice(0, 100));
2220
+ function s(l) {
2221
+ return l.pageIndex === void 0 ? l.path ?? "" : (t.messages.diagnosticsLocation ?? "").replace("{page}", String(l.pageIndex + 1)).replace("{component}", String((l.componentIndex ?? 0) + 1));
2222
+ }
2223
+ return (l, i) => e.entries.length ? ($(), C("details", zs, [
2224
+ p("summary", null, [
2225
+ ce(x(e.messages.diagnosticsTitle) + " ", 1),
2226
+ p("span", null, x(e.entries.length), 1)
2227
+ ]),
2228
+ xt(p("input", {
2229
+ "onUpdate:modelValue": i[0] || (i[0] = (c) => n.value = c),
2230
+ type: "search",
2231
+ "aria-label": e.messages.diagnosticsSearch,
2232
+ placeholder: e.messages.diagnosticsSearch
2233
+ }, null, 8, Ls), [
2234
+ [kt, n.value]
2235
+ ]),
2236
+ p("ol", null, [
2237
+ ($(!0), C(be, null, he(r.value, (c, f) => ($(), C("li", { key: f }, [
2238
+ p("div", null, [
2239
+ p("b", null, x(c.format?.toUpperCase() ?? c.severity) + " · " + x(c.code), 1),
2240
+ p("p", null, x(a.value[c.code] ?? c.message), 1),
2241
+ a.value[c.code] ? ($(), C("details", qs, [
2242
+ p("summary", null, x(e.messages.diagnosticsDetails), 1),
2243
+ ce(x(c.message), 1)
2244
+ ])) : j("", !0),
2245
+ p("small", null, x(s(c)), 1)
2246
+ ]),
2247
+ c.pageIndex !== void 0 ? ($(), C("button", {
2248
+ key: 0,
2249
+ type: "button",
2250
+ onClick: (m) => l.$emit("locate", c)
2251
+ }, x(e.messages.diagnosticsLocate), 9, Ns)) : j("", !0)
2252
+ ]))), 128))
2253
+ ]),
2254
+ o.value.length > r.value.length ? ($(), C("small", Bs, x((e.messages.diagnosticsMore ?? "").replace("{count}", String(o.value.length))), 1)) : j("", !0)
2255
+ ])) : j("", !0);
2256
+ }
2257
+ }), js = /* @__PURE__ */ we(Ks, [["__scopeId", "data-v-3b7804ce"]]), Ws = {
2258
+ key: 0,
2259
+ class: "mrp-data-explanation"
2260
+ }, Hs = { class: "mrp-data-content" }, Us = ["aria-label", "placeholder"], Vs = { class: "mrp-data-state" }, Gs = ["disabled", "onClick"], Js = {
2261
+ key: 0,
2262
+ role: "status"
2263
+ }, Xs = { key: 1 }, Ys = /* @__PURE__ */ ye({
2264
+ __name: "ReportDataExplanation",
2265
+ props: {
2266
+ entries: {},
2267
+ messages: {},
2268
+ busy: { type: Boolean }
2269
+ },
2270
+ emits: ["locate"],
2271
+ setup(e, { emit: t }) {
2272
+ const n = e, a = t, o = Z(""), r = N(() => ({ "missing-source": n.messages.dataMissingSource, "not-applicable": n.messages.dataNotApplicable, "not-calculable": n.messages.dataNotCalculable })), s = N(() => {
2273
+ const i = o.value.toLocaleLowerCase().trim().split(/\s+/).filter(Boolean);
2274
+ return n.entries.filter((c) => i.every((f) => `${c.message} ${c.target?.datasetId} ${c.target?.rowKey ?? ""} ${c.target?.field} ${r.value[c.valueState] ?? ""}`.toLocaleLowerCase().includes(f)));
2275
+ }), l = N(() => s.value.slice(0, 100));
2276
+ return (i, c) => e.entries.length ? ($(), C("details", Ws, [
2277
+ p("summary", null, [
2278
+ ne(re, {
2279
+ name: "file",
2280
+ size: 14
2281
+ }),
2282
+ p("span", null, x(e.messages.dataExplanation), 1),
2283
+ p("b", null, x(e.entries.length), 1),
2284
+ p("small", null, x(e.messages.dataExplanationHint), 1),
2285
+ ne(re, {
2286
+ name: "chevron-down",
2287
+ size: 12
2288
+ })
2289
+ ]),
2290
+ p("div", Hs, [
2291
+ p("label", null, [
2292
+ ne(re, {
2293
+ name: "search",
2294
+ size: 15
2295
+ }),
2296
+ xt(p("input", {
2297
+ "onUpdate:modelValue": c[0] || (c[0] = (f) => o.value = f),
2298
+ type: "search",
2299
+ "aria-label": e.messages.dataExplanationSearch,
2300
+ placeholder: e.messages.dataExplanationSearch
2301
+ }, null, 8, Us), [
2302
+ [kt, o.value]
2303
+ ])
2304
+ ]),
2305
+ p("ul", null, [
2306
+ ($(!0), C(be, null, he(l.value, (f, m) => ($(), C("li", { key: m }, [
2307
+ p("div", null, [
2308
+ p("span", Vs, x(r.value[f.valueState]), 1),
2309
+ p("code", null, [
2310
+ ce(x(f.target?.datasetId) + " · " + x(f.target?.field) + " ", 1),
2311
+ f.target?.rowKey !== void 0 ? ($(), C(be, { key: 0 }, [
2312
+ ce(" · " + x(f.target.rowKey), 1)
2313
+ ], 64)) : j("", !0)
2314
+ ]),
2315
+ p("p", null, x(f.message), 1)
2316
+ ]),
2317
+ f.target ? ($(), C("button", {
2318
+ key: 0,
2319
+ type: "button",
2320
+ disabled: e.busy,
2321
+ onClick: (d) => a("locate", f.target)
2322
+ }, [
2323
+ ce(x(e.messages.diagnosticsLocate), 1),
2324
+ ne(re, {
2325
+ name: "arrow-right",
2326
+ size: 13
2327
+ })
2328
+ ], 8, Gs)) : j("", !0)
2329
+ ]))), 128))
2330
+ ]),
2331
+ s.value.length ? j("", !0) : ($(), C("p", Js, x(e.messages.dataExplanationEmpty), 1)),
2332
+ s.value.length > l.value.length ? ($(), C("small", Xs, x((e.messages.diagnosticsMore ?? "").replace("{count}", String(s.value.length))), 1)) : j("", !0)
2333
+ ])
2334
+ ])) : j("", !0);
2335
+ }
2336
+ }), Zs = /* @__PURE__ */ we(Ys, [["__scopeId", "data-v-cb0adb4c"]]), Qs = ["aria-label"], _s = ["disabled", "title", "onClick"], el = {
2337
+ key: 0,
2338
+ role: "status"
2339
+ }, tl = {
2340
+ key: 1,
2341
+ role: "alert"
2342
+ }, nl = {
2343
+ key: 2,
2344
+ role: "status"
2345
+ }, al = /* @__PURE__ */ ye({
2346
+ __name: "ReportDrillActions",
2347
+ props: {
2348
+ entries: {},
2349
+ pending: { type: Boolean },
2350
+ busy: { type: Boolean },
2351
+ error: {},
2352
+ messages: {}
2353
+ },
2354
+ emits: ["open"],
2355
+ setup(e, { emit: t }) {
2356
+ const n = t;
2357
+ return (a, o) => e.entries.length ? ($(), C("div", {
2358
+ key: 0,
2359
+ class: "mrp-drill-actions",
2360
+ role: "group",
2361
+ "aria-label": e.messages.drillActions
2362
+ }, [
2363
+ p("span", null, x(e.messages.drillActions), 1),
2364
+ ($(!0), C(be, null, he(e.entries, (r) => ($(), C("button", {
2365
+ key: r.action.id,
2366
+ type: "button",
2367
+ disabled: e.busy || e.pending || !!r.reason,
2368
+ title: r.reason,
2369
+ onClick: (s) => n("open", r.action.id)
2370
+ }, [
2371
+ ce(x(r.action.label), 1),
2372
+ ne(re, {
2373
+ name: "arrow-right",
2374
+ size: 13
2375
+ })
2376
+ ], 8, _s))), 128)),
2377
+ e.pending ? ($(), C("small", el, x(e.messages.drillOpening), 1)) : e.error ? ($(), C("small", tl, x(e.error), 1)) : e.entries.every((r) => r.reason) ? ($(), C("small", nl, x(e.messages.drillMissingValue), 1)) : j("", !0)
2378
+ ], 8, Qs)) : j("", !0);
2379
+ }
2380
+ }), ol = /* @__PURE__ */ we(al, [["__scopeId", "data-v-f9ff8c13"]]);
2381
+ function rl(e) {
2382
+ const t = Z(!1), n = Z("");
2383
+ let a;
2384
+ const o = N(() => {
2385
+ const l = e.plan.value, i = e.selection.value?.focus, c = e.options();
2386
+ if (!l || !i || !c) return [];
2387
+ try {
2388
+ return Ha(l, i, c.actions).map((f) => {
2389
+ try {
2390
+ return En(l, i, f, e.params()), { action: f };
2391
+ } catch {
2392
+ return { action: f, reason: e.messages().drillMissingValue };
2393
+ }
2394
+ });
2395
+ } catch {
2396
+ return [];
2397
+ }
2398
+ });
2399
+ function r() {
2400
+ a?.abort(), a = void 0, t.value = !1, n.value = "";
2401
+ }
2402
+ pe([e.plan, () => e.options()], r), Ie(r);
2403
+ async function s(l) {
2404
+ if (t.value || e.busy()) return;
2405
+ const i = e.plan.value, c = e.selection.value?.focus, f = e.options(), m = f?.actions.find((E) => E.id === l);
2406
+ if (!i || !c || !f || !m) return;
2407
+ const d = new AbortController();
2408
+ a = d, t.value = !0, n.value = "";
2409
+ try {
2410
+ const E = En(i, c, m, e.params()), k = Object.freeze(e.view());
2411
+ if (!await e.beforeOpen() || d.signal.aborted || e.plan.value !== i) return;
2412
+ await Te(f.open({ ...E, signal: d.signal, view: k }), d.signal);
2413
+ } catch (E) {
2414
+ d.signal.aborted || (n.value = E instanceof Ua ? e.messages().drillMissingValue ?? "" : e.messages().drillFailed ?? "");
2415
+ } finally {
2416
+ a === d && (t.value = !1, a = void 0);
2417
+ }
2418
+ }
2419
+ return { entries: o, pending: t, error: n, open: s };
2420
+ }
2421
+ const sl = { class: "mrp-print-settings" }, ll = ["value", "disabled"], il = ["value", "disabled"], ul = ["disabled"], cl = /* @__PURE__ */ ye({
2422
+ __name: "ReportPrintSettings",
2423
+ props: {
2424
+ value: {},
2425
+ messages: {},
2426
+ busy: { type: Boolean },
2427
+ canTest: { type: Boolean }
2428
+ },
2429
+ emits: ["change", "test"],
2430
+ setup(e, { emit: t }) {
2431
+ const n = e, a = t;
2432
+ function o(r, s) {
2433
+ const l = s.target, i = Number(l.value);
2434
+ if (!l.value.trim() || !Number.isFinite(i) || Math.abs(i) > 20) {
2435
+ l.value = String(n.value[r] ?? 0);
2436
+ return;
2437
+ }
2438
+ a("change", { ...n.value, [r]: i });
2439
+ }
2440
+ return (r, s) => ($(), C("details", sl, [
2441
+ p("summary", null, x(e.messages.printCalibration), 1),
2442
+ p("p", null, x(e.messages.printCalibrationHint), 1),
2443
+ p("div", null, [
2444
+ p("label", null, [
2445
+ ce(x(e.messages.printOffsetX) + " ", 1),
2446
+ p("input", {
2447
+ type: "number",
2448
+ min: "-20",
2449
+ max: "20",
2450
+ step: ".1",
2451
+ value: e.value.offsetXmm ?? 0,
2452
+ disabled: e.busy,
2453
+ onChange: s[0] || (s[0] = (l) => o("offsetXmm", l))
2454
+ }, null, 40, ll)
2455
+ ]),
2456
+ p("label", null, [
2457
+ ce(x(e.messages.printOffsetY) + " ", 1),
2458
+ p("input", {
2459
+ type: "number",
2460
+ min: "-20",
2461
+ max: "20",
2462
+ step: ".1",
2463
+ value: e.value.offsetYmm ?? 0,
2464
+ disabled: e.busy,
2465
+ onChange: s[1] || (s[1] = (l) => o("offsetYmm", l))
2466
+ }, null, 40, il)
2467
+ ])
2468
+ ]),
2469
+ p("button", {
2470
+ type: "button",
2471
+ disabled: e.busy || !e.canTest,
2472
+ onClick: s[2] || (s[2] = (l) => a("test"))
2473
+ }, x(e.messages.printCalibrationTest), 9, ul)
2474
+ ]));
2475
+ }
2476
+ }), dl = /* @__PURE__ */ we(cl, [["__scopeId", "data-v-35a0f5ec"]]), Rn = /* @__PURE__ */ new Map(), He = /* @__PURE__ */ new Map(), fl = 15e3;
2477
+ function _t(e, t) {
2478
+ return Object.assign(new Error(e), { cause: t });
2479
+ }
2480
+ function at(e, t) {
2481
+ return `PDF 字体 ${JSON.stringify(e)}:${t}。请部署支持报表文字的字体文件,并将 pdfFontUrl 配置为可访问的字体 URL;西文报表可设为空串`;
2482
+ }
2483
+ async function Mn(e, t, n) {
2484
+ if (fe(n), !e) return null;
2485
+ try {
2486
+ const a = await Te(t(e, { strict: !0, signal: n }), n);
2487
+ if (!a?.byteLength) throw new Error("字体文件为空或加载失败");
2488
+ return a;
2489
+ } catch (a) {
2490
+ throw fe(n), _t(at(e, a instanceof Error ? a.message : String(a)), a);
2491
+ }
2492
+ }
2493
+ function wt(e) {
2494
+ if (e?.reason instanceof Error && e.reason.name === "AbortError") return e.reason;
2495
+ const t = _t("PDF 字体检查已取消", e?.reason);
2496
+ return t.name = "AbortError", t;
2497
+ }
2498
+ async function ml(e, t) {
2499
+ let n = !1;
2500
+ const a = setTimeout(() => {
2501
+ n = !0, t.abort();
2502
+ }, fl);
2503
+ try {
2504
+ const o = await fetch(e, { method: "HEAD", signal: t.signal });
2505
+ if (t.signal.aborted) throw wt(t.signal);
2506
+ if (o.status === 405 || o.status === 501 || o.type === "opaque")
2507
+ return {
2508
+ status: "unverified",
2509
+ fontUrl: e,
2510
+ message: `PDF 字体 ${JSON.stringify(e)} 无法通过 HEAD 检查验证;仍可尝试导出,届时会加载并校验字体`
2511
+ };
2512
+ if (!o.ok) {
2513
+ const s = new Error(`字体请求返回 HTTP ${o.status}`);
2514
+ return { status: "error", fontUrl: e, message: at(e, s.message), cause: s };
2515
+ }
2516
+ const r = o.headers.get("content-type") ?? "";
2517
+ if (/text\/html|application\/xhtml\+xml/i.test(r)) {
2518
+ const s = new Error("字体 URL 返回 HTML 页面(可能是 SPA 路由回退),不是字体文件");
2519
+ return { status: "error", fontUrl: e, message: at(e, s.message), cause: s };
2520
+ }
2521
+ if (/^text\//i.test(r) || /(?:\/|\+)json(?:\s*;|$)/i.test(r)) {
2522
+ const s = new Error(`字体 URL 返回 ${r} 文本响应,不是字体文件`);
2523
+ return { status: "error", fontUrl: e, message: at(e, s.message), cause: s };
2524
+ }
2525
+ return {
2526
+ status: "available",
2527
+ fontUrl: e,
2528
+ message: "PDF 字体资源可达;文字覆盖范围将在实际导出时校验"
2529
+ };
2530
+ } catch (o) {
2531
+ if (t.signal.aborted && !n) throw wt(t.signal);
2532
+ return {
2533
+ status: "error",
2534
+ fontUrl: e,
2535
+ message: at(e, n ? "字体检查超时,请检查网络或字体服务" : "字体检查失败,请检查网络、字体服务或跨域访问配置"),
2536
+ cause: o
2537
+ };
2538
+ } finally {
2539
+ clearTimeout(a);
2540
+ }
2541
+ }
2542
+ function gl(e, t) {
2543
+ if (t?.aborted) return Promise.reject(wt(t));
2544
+ if (!e)
2545
+ return Promise.resolve({ status: "disabled", fontUrl: e, message: "已停用自定义 PDF 字体;内置字体用于西文,其他文字会在导出时校验" });
2546
+ const n = Rn.get(e);
2547
+ if (n) return Promise.resolve(n);
2548
+ let a = He.get(e);
2549
+ if (!a) {
2550
+ const r = new AbortController();
2551
+ a = { controller: r, promise: ml(e, r), subscribers: 0 };
2552
+ const s = a;
2553
+ He.set(e, s), s.promise = s.promise.then((l) => (!r.signal.aborted && l.status === "available" && Rn.set(e, l), l)).finally(() => {
2554
+ He.get(e) === s && He.delete(e);
2555
+ });
2556
+ }
2557
+ const o = a;
2558
+ return o.subscribers++, new Promise((r, s) => {
2559
+ let l = !1;
2560
+ const i = () => l ? !1 : (l = !0, o.subscribers--, t?.removeEventListener("abort", c), !0), c = () => {
2561
+ i() && (o.subscribers === 0 && (He.get(e) === o && He.delete(e), o.controller.abort()), s(wt(t)));
2562
+ };
2563
+ t?.addEventListener("abort", c, { once: !0 }), o.promise.then(
2564
+ (f) => {
2565
+ i() && r(f);
2566
+ },
2567
+ (f) => {
2568
+ i() && s(f);
2569
+ }
2570
+ ), t?.aborted && c();
2571
+ });
2572
+ }
2573
+ function pl(e = { fontUrl: "/simhei.ttf" }) {
2574
+ let t = null;
2575
+ const n = async (a, o, r = {}) => {
2576
+ fe(r.signal), t || (t = await import("@agile-team/mach-report/pdf")), fe(r.signal);
2577
+ const s = await Mn(e.fontUrl, t.loadFontWithCache, r.signal);
2578
+ let l;
2579
+ try {
2580
+ fe(r.signal), l = await t.renderPlanToPdf(a, { ...r, ...s ? { customFontBytes: s } : {} });
2581
+ } catch (d) {
2582
+ if (!s) throw d;
2583
+ const E = d instanceof Error ? d.message : String(d);
2584
+ throw _t(`PDF 生成失败:${E}。当前字体 URL 为 ${JSON.stringify(e.fontUrl)};请确认该文件是有效字体,或重新配置 pdfFontUrl`, d);
2585
+ }
2586
+ fe(r.signal), l.diagnostics?.forEach((d) => {
2587
+ try {
2588
+ r.onDiagnostic?.(d);
2589
+ } catch {
2590
+ }
2591
+ });
2592
+ const { bytes: i, unsupportedTextCount: c, pageErrors: f, fidelityWarnings: m } = l;
2593
+ if (c > 0)
2594
+ throw new Error(`PDF 中有 ${c} 行文字无法编码;请部署支持所用文字的字体并配置 pdfFontUrl`);
2595
+ if (f.length > 0)
2596
+ throw new Error(`PDF 有 ${f.length} 页渲染失败:${f[0]}`);
2597
+ return m.length > 0 && o?.(`PDF 有 ${m.length} 处版式降级:${m.slice(0, 2).join(";")}`), i;
2598
+ };
2599
+ return n.checkFont = (a) => gl(e.fontUrl, a), n.prepare = async (a) => {
2600
+ if (fe(a), !e.fontUrl) return {};
2601
+ const { loadFontWithCache: o } = await import("./font-loader-CQZowp0I.js"), r = await Mn(e.fontUrl, o, a);
2602
+ return r ? { customFontBytes: r } : {};
2603
+ }, n;
2604
+ }
2605
+ function vl(e) {
2606
+ const t = ve(Object.freeze({ status: "unchecked", fontUrl: "" }));
2607
+ let n = null, a = null, o = 0, r = null;
2608
+ function s() {
2609
+ if (e.injectedExporter) return e.injectedExporter;
2610
+ const f = e.fontUrl();
2611
+ return (!a || n !== f) && (n = f, a = pl({ fontUrl: f })), a;
2612
+ }
2613
+ function l() {
2614
+ o++, r?.abort(), r = null;
2615
+ }
2616
+ async function i() {
2617
+ if (e.destroyed()) throw new Ge("config", "报表预览已卸载");
2618
+ l();
2619
+ const f = o, m = new AbortController();
2620
+ r = m;
2621
+ const d = e.fontUrl();
2622
+ t.value = Object.freeze({ status: "checking", fontUrl: d });
2623
+ try {
2624
+ const E = s(), k = E.checkFont ? await E.checkFont(m.signal) : { status: "unverified", fontUrl: "", message: "自定义 PDF 导出器未提供字体预检查;字体由宿主确认" };
2625
+ return !e.destroyed() && f === o && !m.signal.aborted && (t.value = Object.freeze({ ...k })), k;
2626
+ } catch (E) {
2627
+ if (m.signal.aborted) throw E;
2628
+ const k = { status: "error", fontUrl: d, message: E instanceof Error ? E.message : "PDF 字体检查失败", cause: E };
2629
+ return !e.destroyed() && f === o && (t.value = Object.freeze(k)), k;
2630
+ } finally {
2631
+ r === m && (r = null);
2632
+ }
2633
+ }
2634
+ function c() {
2635
+ i().catch(() => {
2636
+ });
2637
+ }
2638
+ return pe([e.plan, N(e.fontUrl), N(e.enabled)], () => {
2639
+ const f = t.value.fontUrl === e.fontUrl();
2640
+ f && t.value.status === "available" || (l(), (!f || t.value.status === "checking") && (t.value = Object.freeze({ status: "unchecked", fontUrl: e.fontUrl() })), !e.destroyed() && e.plan.value?.pages.length && e.enabled() && c());
2641
+ }, { immediate: !0 }), { pdfFont: t, getPdfExporter: s, checkPdfFont: i, retryPdfFont: c, cancelFontCheck: l };
2642
+ }
2643
+ function Se(e) {
2644
+ return JSON.parse(JSON.stringify(e));
2645
+ }
2646
+ function Gn(e, t) {
2647
+ const n = t.fields;
2648
+ if (typeof n == "function") return n(e);
2649
+ const a = e.source?.field ?? e.table?.columnKey;
2650
+ return a === void 0 || !n || !Object.prototype.hasOwnProperty.call(n, a) ? void 0 : n[a];
2651
+ }
2652
+ function Ct(e, t) {
2653
+ if (e.requiresRecalculation && (!t || !Yt(e))) throw new Me("recalculation");
2654
+ }
2655
+ async function bl(e, t, n, a) {
2656
+ const o = t.edits.every((l) => !!l.source);
2657
+ Ct(e, o);
2658
+ const r = Yt(e);
2659
+ if (r && o) return r.prepareHistory(e, t.edits, t.value, n, { signal: a });
2660
+ const s = Je(e);
2661
+ return t.edits.map((l) => {
2662
+ const i = s(l);
2663
+ if (!i) throw new Me("missing");
2664
+ return { address: i, value: l[t.value] };
2665
+ });
2666
+ }
2667
+ function hl(e, t, n) {
2668
+ const a = t.edits.every((o) => !!o.source);
2669
+ return Ct(e, a), a ? Yt(e)?.prepare(e, t, { signal: n }) : void 0;
2670
+ }
2671
+ function yl(e, t) {
2672
+ const n = /* @__PURE__ */ new Map();
2673
+ return e.pages.forEach((a, o) => a.components.forEach((r, s) => {
2674
+ if (r.grid)
2675
+ for (const l of Qt(r.grid, r.widthMm, r.heightMm).cells) {
2676
+ const i = t({ pageIndex: o, componentIndex: s, rowIndex: l.ri, columnIndex: l.ci });
2677
+ if (!i?.source) continue;
2678
+ const c = Le(i), f = n.get(c) ?? [];
2679
+ f.push(i), n.set(c, f);
2680
+ }
2681
+ })), n;
2682
+ }
2683
+ function Je(e) {
2684
+ const t = bt(e), n = yl(e, t);
2685
+ function a(r) {
2686
+ if (r.source) return n.get(Le(r)) ?? [];
2687
+ const s = t(r.address);
2688
+ return s ? !r.table || Le(s) === Le(r) ? [s] : [] : [];
2689
+ }
2690
+ const o = (r) => {
2691
+ const s = a(r), l = s.find((i) => i.table?.id === r.table?.id) ?? s[0];
2692
+ return l ? { ...l.address } : null;
2693
+ };
2694
+ return o.all = (r) => a(r).map((s) => ({ ...s.address })), o;
2695
+ }
2696
+ class wl extends Error {
2697
+ constructor(t) {
2698
+ super(t.map((n) => n.message).join(";")), this.conflicts = t, this.name = "ReportEditConflictError";
2699
+ }
2700
+ }
2701
+ function xl() {
2702
+ return globalThis.crypto?.randomUUID?.() ?? `mr-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
2703
+ }
2704
+ function kl(e, t, n, a) {
2705
+ return Array.isArray(t) ? { batch: Ut(e, t, n) } : bl(e, t, n, a).then((o) => Array.isArray(o) ? { batch: Ut(e, o, n) } : o);
2706
+ }
2707
+ function El(e) {
2708
+ const t = ve([]), n = ve([]), a = ve([]), o = ve([]), r = ve(!1), s = ve(null), l = ve([]), i = N(() => l.value.length > 0), c = N(() => {
2709
+ const y = kn(t.value), S = e.plan.value;
2710
+ if (!S || !y.length) return y;
2711
+ const F = Je(S);
2712
+ return y.map((q) => {
2713
+ const U = F(q);
2714
+ return U ? { ...q, address: U } : q;
2715
+ });
2716
+ }), f = N(() => !!e.options.value && !r.value && !e.blocked() && n.value.length > 0), m = N(() => !!e.options.value && !r.value && !e.blocked() && a.value.length > 0);
2717
+ let d = null, E = null, k = 0, w = null;
2718
+ function v() {
2719
+ d?.abort(), d = null, r.value = !1, E = null;
2720
+ }
2721
+ function L() {
2722
+ k++, v(), w = null, t.value = [], n.value = [], a.value = [], o.value = [], l.value = [], s.value = null;
2723
+ }
2724
+ function b() {
2725
+ const y = e.options.value;
2726
+ return y ? typeof y == "object" ? y : {} : null;
2727
+ }
2728
+ function R(y, S, F, q) {
2729
+ if (!e.options.value || e.blocked()) throw new Me("readonly");
2730
+ Ct(y, S.edits.every((W) => !!W.source));
2731
+ const U = bt(y), _ = new Map(q?.map((W) => [Le(W), W]));
2732
+ for (const W of S.edits) {
2733
+ const Q = q ? _.get(Le(W)) : U(W.address);
2734
+ if (!Q?.editable || F.canEdit?.(Q) === !1) throw new Me("readonly");
2735
+ if (F.requireSource && !Q.source) throw new Me("missing");
2736
+ const le = Gn(Q, F);
2737
+ le && Da(Q, W.value, le);
2738
+ }
2739
+ }
2740
+ async function A(y, S, F) {
2741
+ if (S.saveBatch) return S.saveBatch(Se(y), F);
2742
+ if (S.save && y.edits.length > 1) throw new Me("atomic");
2743
+ if (y.edits[0]) return S.save?.(Se(y.edits[0]), F);
2744
+ }
2745
+ async function h(y, S, F) {
2746
+ for (const q of y.edits) {
2747
+ const U = await S.validate?.(Se(q), F);
2748
+ if (U) throw new Error(U);
2749
+ if (F.signal.aborted) return;
2750
+ }
2751
+ }
2752
+ function M(y, S, F, q, U, _) {
2753
+ if (e.plan.value = _ ? _.commit(F) : Aa(Fa(y, S), S, F), t.value = [...t.value, ...S.edits], U) {
2754
+ const Q = new Set(S.edits.map(Le));
2755
+ l.value = l.value.filter((le) => !Q.has(Le(le)));
2756
+ } else l.value = kn([...l.value, ...S.edits]);
2757
+ q === "edit" && (n.value = [...n.value, S.edits], a.value = []), o.value = [], w = null;
2758
+ const W = k;
2759
+ for (const Q of S.edits) {
2760
+ if (k !== W) break;
2761
+ e.onChange(Se(Q));
2762
+ }
2763
+ }
2764
+ function B(y, S, F) {
2765
+ const q = JSON.stringify([F, S.edits]);
2766
+ w?.plan === y && w.signature === q ? S.requestId = w.requestId : w = { plan: y, signature: q, requestId: S.requestId };
2767
+ }
2768
+ function I(y) {
2769
+ s.value = e.errorMessage?.(y) ?? (y instanceof Error ? y.message : "Cell edit failed"), e.onError(s.value, y);
2770
+ }
2771
+ async function z(y, S) {
2772
+ const F = e.plan.value, q = b();
2773
+ if (!F || !q || e.blocked()) return !1;
2774
+ const U = new AbortController(), _ = k;
2775
+ d = U, r.value = !0, s.value = null;
2776
+ const W = () => d === U && !U.signal.aborted && e.plan.value === F && e.options.value !== !1;
2777
+ try {
2778
+ const Q = kl(F, y, xl(), U.signal), le = Q instanceof Promise ? await Q : Q;
2779
+ if (!W()) return !1;
2780
+ const { batch: Y, contexts: G } = le;
2781
+ if (R(F, Y, q, G), Y.edits = Y.edits.filter((P) => !Object.is(P.previousValue, P.value)), !Y.edits.length) return !0;
2782
+ B(F, Y, S), R(F, Y, q, G);
2783
+ const Re = { signal: U.signal, requestId: Y.requestId, action: S };
2784
+ if (await h(Y, q, Re), !W()) return !1;
2785
+ R(F, Y, q, G);
2786
+ const Pe = le.prepared ? void 0 : hl(F, Y, U.signal);
2787
+ if (Pe && (le.prepared = await Pe), !W()) return !1;
2788
+ R(F, Y, q, G);
2789
+ const Fe = await A(Y, q, Re);
2790
+ if (!W()) return !1;
2791
+ if (Fe?.conflicts?.length)
2792
+ throw o.value = Se(Fe.conflicts), new wl(Fe.conflicts);
2793
+ return R(F, Y, q, G), M(F, Y, Fe, S, !!(q.save || q.saveBatch), le.prepared), _ === k;
2794
+ } catch (Q) {
2795
+ return W() && I(Q), !1;
2796
+ } finally {
2797
+ d === U && (d = null, r.value = !1);
2798
+ }
2799
+ }
2800
+ async function H(y, S = "edit") {
2801
+ if (E) return E;
2802
+ const F = z(y, S);
2803
+ E = F;
2804
+ const q = await F;
2805
+ return E === F && (E = null), q;
2806
+ }
2807
+ async function ae() {
2808
+ const y = k, S = n.value[n.value.length - 1];
2809
+ return !S || r.value || !await H({ edits: S, value: "previousValue" }, "undo") || y !== k ? !1 : (n.value = n.value.slice(0, -1), a.value = [...a.value, S], !0);
2810
+ }
2811
+ async function oe() {
2812
+ const y = k, S = a.value[a.value.length - 1];
2813
+ return !S || r.value || !await H({ edits: S, value: "value" }, "redo") || y !== k ? !1 : (a.value = a.value.slice(0, -1), n.value = [...n.value, S], !0);
2814
+ }
2815
+ async function ue() {
2816
+ const y = k;
2817
+ return !c.value.length || r.value || !await H({ edits: c.value, value: "previousValue" }, "restore") || y !== k ? !1 : (n.value = [], a.value = [], !0);
2818
+ }
2819
+ function g() {
2820
+ if (!E) return !r.value;
2821
+ const y = k;
2822
+ return E.then((S) => S && y === k && !r.value);
2823
+ }
2824
+ function T(y) {
2825
+ return e.plan.value ? Je(e.plan.value)(y) : null;
2826
+ }
2827
+ return { settle: g, resolveAddress: T, changes: t, differences: c, localDifferences: l, hasLocalDrafts: i, lastError: s, conflicts: o, saving: r, canUndo: f, canRedo: m, apply: H, undo: ae, redo: oe, restore: ue, cancel: v, reset: L };
2828
+ }
2829
+ let $l = 0;
2830
+ const Cl = "position:absolute;inset:0;width:100%;height:100%;min-height:20px;box-sizing:border-box;z-index:10;resize:none;margin:0;padding:2px 4px;border:2px solid var(--mrp-btn-active-bg,#2563eb);outline:none;background:var(--mrp-toolbar-bg,#fff);color:var(--mrp-toolbar-fg,#111);font:inherit;line-height:1.25;white-space:pre-wrap;";
2831
+ function Il(e) {
2832
+ return e.type === "boolean" ? [{ value: !0, label: e.trueLabel ?? "是" }, { value: !1, label: e.falseLabel ?? "否" }] : e.type === "enum" ? e.options.map((t) => ({ value: t.value, label: t.label ?? String(t.value) })) : [];
2833
+ }
2834
+ function Pl(e, t, n) {
2835
+ const a = e.createElement("select"), o = [{ value: null, label: "—" }, ...Il(t)];
2836
+ if (o.forEach((r, s) => {
2837
+ const l = e.createElement("option");
2838
+ l.value = String(s), l.textContent = r.label, (Object.is(n.value, r.value) || n.value === "" && r.value === null) && (l.selected = !0), a.append(l);
2839
+ }), !o.some((r) => Object.is(n.value, r.value) || n.value === "" && r.value === null)) {
2840
+ const r = e.createElement("option");
2841
+ r.value = "unknown", r.textContent = n.cell.text ?? String(n.value), r.selected = !0, a.append(r);
2842
+ }
2843
+ return { input: a, value: () => a.value === "unknown" ? n.value : o[Number(a.value)]?.value ?? null };
2844
+ }
2845
+ function Sl(e, t, n) {
2846
+ const a = t?.type === "number" || t?.type === "date" ? e.createElement("input") : e.createElement("textarea");
2847
+ return a.value = n.value == null ? "" : String(n.value), a instanceof HTMLInputElement && (a.type = t?.type === "date" ? "date" : "text", t?.type === "number" && (a.inputMode = "decimal"), t?.type === "date" && (t.min && (a.min = t.min), t.max && (a.max = t.max))), { input: a, value: () => t?.type === "date" && a instanceof HTMLInputElement && a.validity.badInput ? "invalid-date" : a.value };
2848
+ }
2849
+ function Rl(e) {
2850
+ if (!e) return "";
2851
+ const t = [e.hint, e.unit];
2852
+ return (e.type === "number" || e.type === "date") && (e.min !== void 0 && t.push(`≥ ${e.min}`), e.max !== void 0 && t.push(`≤ ${e.max}`)), e.type === "number" && e.precision !== void 0 && t.push(`最多 ${e.precision} 位小数`), e.type === "text" && e.maxLength !== void 0 && t.push(`最多 ${e.maxLength} 字符`), t.filter(Boolean).join(" · ");
2853
+ }
2854
+ function Ml(e, t, n, a) {
2855
+ const o = e.ownerDocument, r = a?.type === "boolean" || a?.type === "enum" ? Pl(o, a, n) : Sl(o, a, n), s = r.input, l = o.createElement("span");
2856
+ l.className = "mrp-cell-editor-host", l.style.cssText = "position:absolute;inset:0;z-index:10;", s.className = "mrp-cell-editor", s.style.cssText = Cl, s.setAttribute("aria-label", a?.label ?? t), a?.required && s.setAttribute("aria-required", "true");
2857
+ const i = o.createElement("span");
2858
+ i.id = `mrp-cell-hint-${++$l}`, i.className = "mrp-cell-editor-hint", i.style.cssText = "position:absolute;top:100%;left:0;min-width:100%;width:max-content;max-width:320px;box-sizing:border-box;padding:4px 8px;white-space:normal;border:1px solid var(--mrp-toolbar-border,#ddd);background:var(--mrp-toolbar-bg,#fff);color:var(--mrp-toolbar-fg,#111);font-size:12px;line-height:1.4;box-shadow:0 3px 10px #0002;z-index:11;";
2859
+ const c = Rl(a);
2860
+ return i.textContent = c, i.hidden = !c, s.setAttribute("aria-describedby", i.id), l.append(s, i), e.append(l), {
2861
+ input: s,
2862
+ root: l,
2863
+ initialInput: s.value,
2864
+ value: r.value,
2865
+ focus: () => {
2866
+ s.focus(), (s instanceof HTMLTextAreaElement || s instanceof HTMLInputElement && s.type !== "date") && s.select();
2867
+ },
2868
+ feedback: (f) => {
2869
+ i.textContent = f ?? c, i.hidden = !i.textContent, s.setAttribute("aria-invalid", f ? "true" : "false");
2870
+ }
2871
+ };
2872
+ }
2873
+ function Vt(e) {
2874
+ const t = e.closest(".mrp-page-holder"), n = e.closest("[data-mr-component-index]");
2875
+ if (!t || !n) return null;
2876
+ const a = {
2877
+ pageIndex: Number(t.dataset.page) - 1,
2878
+ componentIndex: Number(n.dataset.mrComponentIndex),
2879
+ rowIndex: Number(e.dataset.mrRowIndex),
2880
+ columnIndex: Number(e.dataset.mrColumnIndex)
2881
+ };
2882
+ return Object.values(a).every((o) => Number.isInteger(o) && o >= 0) ? a : null;
2883
+ }
2884
+ function Tl(e) {
2885
+ const t = ve(null), n = El(e), { saving: a, changes: o } = n, r = ve(!1), s = N(() => r.value || n.hasLocalDrafts.value);
2886
+ let l = null;
2887
+ function i() {
2888
+ const b = t.value;
2889
+ t.value = null, r.value = !1, n.cancel(), l = null, b?.editor.root.remove();
2890
+ }
2891
+ function c() {
2892
+ i(), n.reset();
2893
+ }
2894
+ function f(b) {
2895
+ return t.value === b && e.plan.value === b.plan;
2896
+ }
2897
+ async function m(b) {
2898
+ return await n.apply([{ address: b.address, value: b.editor.value() }]) ? (t.value = null, r.value = !1, b.editor.root.remove(), !0) : (t.value === b && (b.editor.input.disabled = !1, b.editor.feedback(n.lastError.value ?? void 0), b.editor.input.focus()), !1);
2899
+ }
2900
+ async function d() {
2901
+ if (l) return l;
2902
+ const b = t.value;
2903
+ if (!b) return n.settle();
2904
+ if (!f(b))
2905
+ return i(), !1;
2906
+ r.value = b.editor.input.value !== b.editor.initialInput, b.editor.input.disabled = !0;
2907
+ const R = m(b);
2908
+ l = R;
2909
+ const A = await R;
2910
+ return l === R && (l = null), A;
2911
+ }
2912
+ function E() {
2913
+ return t.value || l ? d() : n.settle();
2914
+ }
2915
+ function k(b) {
2916
+ if (b.stopPropagation(), !b.isComposing && (b.key === "Escape" && (b.preventDefault(), i()), b.key === "Enter" && !b.shiftKey || b.key === "Tab")) {
2917
+ b.preventDefault();
2918
+ const R = t.value, A = R && Ue(R.plan, R.address), h = R && A ? Ut(R.plan, [{ address: R.address, value: A.value }], "navigation").edits[0] : void 0;
2919
+ d().then((M) => {
2920
+ if (!M || !R || !e.plan.value) return;
2921
+ const B = e.plan.value === R.plan ? R.address : h && Je(e.plan.value)(h);
2922
+ B && e.onNavigate?.(B, b.key, b.shiftKey);
2923
+ });
2924
+ }
2925
+ }
2926
+ function w(b) {
2927
+ e.onError(e.errorMessage?.(b) ?? (b instanceof Error ? b.message : "无法编辑单元格"), b);
2928
+ }
2929
+ async function v(b) {
2930
+ if (!e.options.value || e.blocked() || !await d() || !b.isConnected) return;
2931
+ const R = e.plan.value, A = Vt(b);
2932
+ if (!R || !A || !e.options.value || e.blocked()) return;
2933
+ const h = typeof e.options.value == "object" ? e.options.value : {};
2934
+ try {
2935
+ const M = Ue(R, A);
2936
+ if (!M?.editable || h.canEdit?.(M) === !1) return;
2937
+ if (Ct(R, !!M.source), h.requireSource && !M.source) throw new Me("missing");
2938
+ const B = Gn(M, h);
2939
+ B && za(M, B);
2940
+ const I = Ml(b, e.label(), M, B), z = I.input;
2941
+ t.value = { plan: R, address: A, editor: I }, r.value = !1, z.addEventListener("keydown", (H) => k(H)), z.addEventListener("input", () => {
2942
+ r.value = z.value !== I.initialInput, I.feedback();
2943
+ }), z.addEventListener("change", () => {
2944
+ r.value = z.value !== I.initialInput;
2945
+ }), z.addEventListener("blur", () => {
2946
+ !a.value && !e.suspendBlur?.() && d();
2947
+ }), I.focus();
2948
+ } catch (M) {
2949
+ w(M);
2950
+ }
2951
+ }
2952
+ async function L(b) {
2953
+ const R = b.target;
2954
+ if (!(R instanceof Element) || R.closest(".mrp-cell-editor")) return;
2955
+ const A = R.closest("td[data-mr-row-index]");
2956
+ A && await v(A);
2957
+ }
2958
+ return pe(e.options, (b, R) => {
2959
+ (!b || b !== R) && i();
2960
+ }, { flush: "sync" }), pe(e.plan, () => {
2961
+ t.value && e.plan.value !== t.value.plan && (t.value.editor.root.remove(), t.value = null, r.value = !1);
2962
+ }, { flush: "sync" }), Ie(c), {
2963
+ ...n,
2964
+ active: t,
2965
+ saving: a,
2966
+ changes: o,
2967
+ pendingLocalChanges: s,
2968
+ cancel: i,
2969
+ reset: c,
2970
+ commit: d,
2971
+ settle: E,
2972
+ onDoubleClick: L,
2973
+ editCell: v,
2974
+ getChanges: () => Se(o.value)
2975
+ };
2976
+ }
2977
+ function Jn(e) {
2978
+ return e.table.role === "header" ? -Math.max(1, e.grid?.cells.length ?? 1) : e.table.rowIndex;
2979
+ }
2980
+ function Ae(e, t, n = t) {
2981
+ const a = e.pages[t.pageIndex]?.components[t.componentIndex], o = a?.table, r = e.pages[n.pageIndex]?.components[n.componentIndex]?.table;
2982
+ return o && r && o.id === r.id ? {
2983
+ grid: o.id,
2984
+ row: Jn(a) + t.rowIndex,
2985
+ column: r.columnKeys.indexOf(o.columnKeys[t.columnIndex] ?? "")
2986
+ } : { grid: `${t.pageIndex}:${t.componentIndex}`, row: t.rowIndex, column: t.columnIndex };
2987
+ }
2988
+ function Tn(e, t) {
2989
+ const n = e.pages[t.pageIndex]?.components[t.componentIndex]?.table;
2990
+ if (!n) return (o, r) => ({ ...t, rowIndex: o, columnIndex: r });
2991
+ const a = /* @__PURE__ */ new Map();
2992
+ return e.pages.forEach((o, r) => o.components.forEach((s, l) => {
2993
+ s.table?.id !== n.id || !s.grid || s.grid.cells.forEach((i, c) => {
2994
+ const f = Jn(s) + c;
2995
+ a.set(f, [...a.get(f) ?? [], { address: { pageIndex: r, componentIndex: l, rowIndex: c, columnIndex: 0 }, keys: s.table.columnKeys }]);
2996
+ });
2997
+ })), (o, r) => {
2998
+ const s = n.columnKeys[r];
2999
+ if (s === void 0) return null;
3000
+ const l = a.get(o)?.find((i) => i.keys.includes(s));
3001
+ return l ? { ...l.address, columnIndex: l.keys.indexOf(s) } : null;
3002
+ };
3003
+ }
3004
+ function Ol(e, t) {
3005
+ const n = [...e.ownerDocument.querySelectorAll("a[href],button,input,textarea,select,[tabindex]:not([tabindex='-1'])")].filter((r) => r.tabIndex >= 0 && !r.matches(":disabled,[hidden],input[type='hidden']") && !r.closest("[inert],[aria-hidden='true']") && r.getClientRects().length > 0).map((r, s) => ({ element: r, order: s })).sort((r, s) => (r.element.tabIndex || 1 / 0) - (s.element.tabIndex || 1 / 0) || r.order - s.order), a = n.findIndex(({ element: r }) => r === e);
3006
+ if (a < 0) return !1;
3007
+ const o = n[a + (t ? -1 : 1)]?.element;
3008
+ return o ? (o.focus(), e.ownerDocument.activeElement === o) : !1;
3009
+ }
3010
+ function Dl(e, t) {
3011
+ const n = e?.source;
3012
+ return !Al(e, t.field) || t.tableId !== void 0 && e?.table?.id !== t.tableId || t.datasetId !== void 0 && (n?.datasetId ?? e?.component.table?.source?.datasetId) !== t.datasetId ? !1 : t.rowKey === void 0 || n?.rowKey === t.rowKey;
3013
+ }
3014
+ function Al(e, t) {
3015
+ if ((e?.source?.field ?? e?.table?.columnKey) === t) return !0;
3016
+ if (!e || e.table?.role !== "header") return !1;
3017
+ const n = e.address.columnIndex;
3018
+ return e.component.table?.columnKeys.slice(n, n + (e.cell.colSpan ?? 1)).includes(t) ?? !1;
3019
+ }
3020
+ function Fl(e, t) {
3021
+ return e.pageIndex === t.pageIndex && e.componentIndex === t.componentIndex;
3022
+ }
3023
+ function zl(e, t) {
3024
+ return Fl(e, t) && e.rowIndex === t.rowIndex && e.columnIndex === t.columnIndex;
3025
+ }
3026
+ function jt(e) {
3027
+ return `[data-page="${e.pageIndex + 1}"] [data-mr-component-index="${e.componentIndex}"] td[data-mr-row-index="${e.rowIndex}"][data-mr-column-index="${e.columnIndex}"]`;
3028
+ }
3029
+ function Gt(e) {
3030
+ return `${e.pageIndex}:${e.componentIndex}:${e.rowIndex}:${e.columnIndex}`;
3031
+ }
3032
+ function Ll(e, t) {
3033
+ const n = Ae(e, t.anchor), a = Ae(e, t.focus, t.anchor);
3034
+ return { grid: n.grid, minRow: Math.min(n.row, a.row), maxRow: Math.max(n.row, a.row), minColumn: Math.min(n.column, a.column), maxColumn: Math.max(n.column, a.column), focusKey: Gt(t.focus), origin: e.pages[t.anchor.pageIndex]?.components[t.anchor.componentIndex]?.table };
3035
+ }
3036
+ function ql(e, t, n) {
3037
+ const a = t?.table;
3038
+ if (!a || !n.origin || a.id !== n.origin.id) return { grid: `${e.pageIndex}:${e.componentIndex}`, rowOffset: 0, missingColumn: -1 };
3039
+ const o = /* @__PURE__ */ new Map();
3040
+ return n.origin.columnKeys.forEach((r, s) => {
3041
+ o.has(r) || o.set(r, s);
3042
+ }), { grid: a.id, rowOffset: a.role === "header" ? -Math.max(1, t.grid?.cells.length ?? 1) : a.rowIndex, columns: a.columnKeys.map((r) => o.get(r) ?? -1), missingColumn: o.get("") ?? -1 };
3043
+ }
3044
+ function Nl(e, t, n) {
3045
+ if (!n || !t || t.grid !== n.grid) return !1;
3046
+ const a = t.rowOffset + e.row, o = t.columns ? t.columns[e.column] ?? t.missingColumn : e.column;
3047
+ return a >= n.minRow && a <= n.maxRow && o >= n.minColumn && o <= n.maxColumn;
3048
+ }
3049
+ function vt(e, t, n) {
3050
+ e.getAttribute(t) !== n && e.setAttribute(t, n);
3051
+ }
3052
+ function Wt(e, t, n) {
3053
+ e.classList.contains(t) !== n && e.classList.toggle(t, n);
3054
+ }
3055
+ function Bl(e, t, n, a, o, r) {
3056
+ t.role !== n && (vt(e, "role", n), t.role = n), t.selected !== a && (Wt(e, "mrp-cell-selected", a), vt(e, "aria-selected", String(a)), t.selected = a), t.focused !== o && (Wt(e, "mrp-cell-focus", o), vt(e, "tabindex", o ? "0" : "-1"), t.focused = o), t.modified !== r && (Wt(e, "mrp-cell-modified", r), t.modified = r);
3057
+ }
3058
+ function Kl(e) {
3059
+ const t = () => e.editable?.() ?? e.enabled(), n = ve(null), a = /* @__PURE__ */ new WeakMap(), o = /* @__PURE__ */ new WeakMap();
3060
+ let r = null, s = null, l = /* @__PURE__ */ new Set();
3061
+ function i(g, T) {
3062
+ const y = Ue(g, T);
3063
+ return !y || g.requiresRecalculation && !y.source ? null : { address: y.address, source: y.source, table: y.table, value: y.value, previousValue: y.value, text: y.cell.text ?? "", previousText: y.cell.text ?? "" };
3064
+ }
3065
+ pe(e.plan, (g, T) => {
3066
+ const y = n.value;
3067
+ if (!y) return;
3068
+ if (!g || !T) {
3069
+ n.value = null;
3070
+ return;
3071
+ }
3072
+ const S = i(T, y.anchor), F = i(T, y.focus), q = Je(g), U = S && q(S), _ = F && q(F);
3073
+ n.value = U && _ ? { anchor: U, focus: _ } : null;
3074
+ }, { flush: "sync" });
3075
+ function c(g = e.root.value ?? void 0) {
3076
+ if (!g) return;
3077
+ const T = n.value, y = e.plan.value, S = e.differences();
3078
+ if (S !== r || y !== s) {
3079
+ r = S, s = y;
3080
+ const q = y && S.length ? Je(y) : null;
3081
+ l = new Set(S.flatMap((U) => q ? q.all(U).map(Gt) : []));
3082
+ }
3083
+ const F = T && y ? Ll(y, T) : null;
3084
+ g instanceof HTMLTableElement && d(g, y, F);
3085
+ for (const q of g.querySelectorAll("table")) d(q, y, F);
3086
+ }
3087
+ function f(g) {
3088
+ const T = a.get(g);
3089
+ if (T) return T;
3090
+ const y = g.closest("[data-mr-component-index]"), S = y?.closest(".mrp-page-holder"), F = { pageIndex: Number(S?.dataset.page) - 1, componentIndex: Number(y?.dataset.mrComponentIndex) };
3091
+ return Object.values(F).every((q) => Number.isInteger(q) && q >= 0) ? (a.set(g, F), F) : null;
3092
+ }
3093
+ function m(g, T) {
3094
+ const y = o.get(g);
3095
+ if (y) return y;
3096
+ const S = Number(g.dataset.mrRowIndex), F = Number(g.dataset.mrColumnIndex);
3097
+ if (![S, F].every((U) => Number.isInteger(U) && U >= 0)) return null;
3098
+ const q = { row: S, column: F, key: Gt({ ...T, rowIndex: S, columnIndex: F }) };
3099
+ return o.set(g, q), q;
3100
+ }
3101
+ function d(g, T, y) {
3102
+ const S = f(g);
3103
+ if (!S) return;
3104
+ const F = T?.pages[S.pageIndex]?.components[S.componentIndex], q = F?.table?.role === "header" ? "columnheader" : "gridcell", U = y ? ql(S, F, y) : null;
3105
+ vt(g, "role", "grid");
3106
+ for (const _ of g.rows) for (const W of _.cells) {
3107
+ const Q = m(W, S);
3108
+ Q && Bl(W, Q, q, Nl(Q, U, y), y?.focusKey === Q.key, l.size > 0 && l.has(Q.key));
3109
+ }
3110
+ }
3111
+ async function E(g, T = !1) {
3112
+ if (!e.plan.value || !Ue(e.plan.value, g)) return !1;
3113
+ const y = n.value, S = T && y && Ae(e.plan.value, y.anchor).grid === Ae(e.plan.value, g, y.anchor).grid;
3114
+ n.value = { anchor: S ? y.anchor : { ...g }, focus: { ...g } }, e.root.value?.querySelector(jt(g)) || e.gotoPage(g.pageIndex + 1), await Be(), e.ensureVisible?.(g), c();
3115
+ const F = e.root.value?.querySelector(jt(g));
3116
+ return F?.focus({ preventScroll: !0 }), F?.scrollIntoView?.({ block: "nearest", inline: "nearest" }), !!F;
3117
+ }
3118
+ function k(g) {
3119
+ const T = g.target;
3120
+ if (!(T instanceof Element) || T.closest("textarea,input,button,select")) return;
3121
+ const y = T.closest("td[data-mr-row-index]"), S = y && Vt(y);
3122
+ if (!S || e.busy() || !e.plan.value || !Ue(e.plan.value, S)) return;
3123
+ const F = n.value, q = g.shiftKey && F && Ae(e.plan.value, F.anchor).grid === Ae(e.plan.value, S, F.anchor).grid;
3124
+ n.value = { anchor: q ? F.anchor : { ...S }, focus: { ...S } }, c(), y.focus({ preventScroll: !0 });
3125
+ }
3126
+ function w(g) {
3127
+ const T = e.plan.value?.pages[g.pageIndex]?.components[g.componentIndex];
3128
+ return T?.grid ? Qt(T.grid, T.widthMm, T.heightMm).cells.map((y) => ({ ...g, rowIndex: y.ri, columnIndex: y.ci })) : [];
3129
+ }
3130
+ function v(g, T, y) {
3131
+ const S = w(g), F = y ? -1 : 1;
3132
+ if (T === "Tab") return S[S.findIndex((_) => zl(_, g)) + F];
3133
+ const q = T === "ArrowUp" || T === "ArrowDown" || T === "Enter", U = T === "ArrowUp" || T === "ArrowLeft" ? -1 : F;
3134
+ return S.filter((_) => q ? _.columnIndex === g.columnIndex && (_.rowIndex - g.rowIndex) * U > 0 : _.rowIndex === g.rowIndex && (_.columnIndex - g.columnIndex) * U > 0).sort((_, W) => q ? (_.rowIndex - W.rowIndex) * U : (_.columnIndex - W.columnIndex) * U)[0];
3135
+ }
3136
+ function L(g, T, y) {
3137
+ if (T === "ArrowLeft" || T === "ArrowRight") return;
3138
+ const S = e.plan.value;
3139
+ if (!S.pages[g.pageIndex]?.components[g.componentIndex]?.table) return;
3140
+ const q = T === "ArrowUp" || y ? -1 : 1;
3141
+ for (let U = g.pageIndex; U >= 0 && U < S.pages.length; U += q) {
3142
+ const _ = S.pages[U].components, W = U === g.pageIndex ? g.componentIndex + q : q === 1 ? 0 : _.length - 1;
3143
+ for (let Q = W; Q >= 0 && Q < _.length; Q += q) {
3144
+ const le = b(g, { ...g, pageIndex: U, componentIndex: Q }, T, q);
3145
+ if (le) return le;
3146
+ }
3147
+ }
3148
+ }
3149
+ function b(g, T, y, S) {
3150
+ const F = e.plan.value, q = F.pages[g.pageIndex].components[g.componentIndex].table, U = F.pages[T.pageIndex].components[T.componentIndex]?.table;
3151
+ if (U?.id !== q.id || U.role === "header" && q.role !== "header" && (S > 0 || q.rowIndex + g.rowIndex > 0)) return;
3152
+ const _ = w(T), W = y === "Tab" ? _ : _.filter((Q) => Q.columnIndex === g.columnIndex);
3153
+ return S === 1 ? W[0] : W[W.length - 1];
3154
+ }
3155
+ function R(g, T, y = !1, S = !1, F = !1) {
3156
+ const q = v(g, T, y) ?? L(g, T, y);
3157
+ return q ? (E(q, S), !0) : ((T !== "Tab" || !F) && E(g), !1);
3158
+ }
3159
+ function A(g) {
3160
+ const T = n.value;
3161
+ if (e.busy() || g.target instanceof Element && g.target.closest("textarea,input,select,button,a[href],[contenteditable]")) return !1;
3162
+ if (!T) return B(g);
3163
+ const y = g.key;
3164
+ if (h(g) || M(g, T.focus)) return !0;
3165
+ if (!["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight", "Tab", "Enter"].includes(y)) return !1;
3166
+ const S = R(T.focus, y, y === "Tab" && g.shiftKey, g.shiftKey && y !== "Tab", !0);
3167
+ if (y === "Tab" && !S) {
3168
+ const F = e.root.value?.ownerDocument.activeElement;
3169
+ if (!(F instanceof HTMLElement) || !Ol(F, g.shiftKey)) return !1;
3170
+ }
3171
+ return g.preventDefault(), !0;
3172
+ }
3173
+ function h(g) {
3174
+ if (!t() || !(g.ctrlKey || g.metaKey)) return !1;
3175
+ const T = g.key.toLowerCase();
3176
+ return T !== "z" && T !== "y" ? !1 : (g.preventDefault(), T === "y" || g.shiftKey ? e.redo() : e.undo(), !0);
3177
+ }
3178
+ function M(g, T) {
3179
+ if (!t() || !e.plan.value || g.key !== "F2" && !(g.key === "Enter" && Ue(e.plan.value, T)?.editable)) return !1;
3180
+ const y = e.root.value?.querySelector(jt(T));
3181
+ return y && (g.preventDefault(), e.edit(y)), !0;
3182
+ }
3183
+ function B(g) {
3184
+ if (!["ArrowDown", "ArrowRight", "ArrowUp", "ArrowLeft", "Enter"].includes(g.key)) return !1;
3185
+ const T = e.root.value?.querySelector("td[data-mr-row-index]"), y = T && Vt(T);
3186
+ return y ? (g.preventDefault(), E(y), !0) : !1;
3187
+ }
3188
+ function I() {
3189
+ const g = n.value, T = e.plan.value;
3190
+ if (!g || !T) return "";
3191
+ const y = [], S = Ae(T, g.anchor), F = Ae(T, g.focus, g.anchor), q = Tn(T, g.anchor), U = bt(T), _ = Math.min(S.column, F.column), W = Math.max(S.column, F.column);
3192
+ if ((Math.abs(S.row - F.row) + 1) * (W - _ + 1) > 1e4)
3193
+ return e.error(new Me("limit")), "";
3194
+ for (let Q = Math.min(S.row, F.row); Q <= Math.max(S.row, F.row); Q++) {
3195
+ const le = [];
3196
+ for (let Y = _; Y <= W; Y++) {
3197
+ const G = q(Q, Y);
3198
+ le.push(G ? U(G)?.cell.text ?? "" : "");
3199
+ }
3200
+ y.push(le);
3201
+ }
3202
+ return qa(y);
3203
+ }
3204
+ function z(g) {
3205
+ !n.value || g.target instanceof Element && g.target.closest("textarea,input,select") || (g.clipboardData?.setData("text/plain", I()), g.preventDefault());
3206
+ }
3207
+ async function H(g) {
3208
+ const T = n.value;
3209
+ if (!T || !t() || e.busy()) return !1;
3210
+ try {
3211
+ let y;
3212
+ try {
3213
+ y = La(g);
3214
+ } catch (W) {
3215
+ throw new Me(W instanceof Error && W.message.includes("limit") ? "limit" : "clipboard");
3216
+ }
3217
+ const S = e.plan.value, F = Ae(S, T.anchor), q = Ae(S, T.focus, T.anchor), U = Tn(S, T.anchor), _ = y.flatMap((W, Q) => W.map((le, Y) => {
3218
+ const G = U(Math.min(F.row, q.row) + Q, Math.min(F.column, q.column) + Y);
3219
+ if (!G) throw new Me("missing");
3220
+ return { address: G, value: le };
3221
+ }));
3222
+ return await e.apply(_);
3223
+ } catch (y) {
3224
+ return e.error(y), !1;
3225
+ }
3226
+ }
3227
+ function ae(g) {
3228
+ if (!n.value || !t() || g.target instanceof Element && g.target.closest("textarea,input,select,button,a[href],[contenteditable]") || !g.clipboardData?.types.includes("text/plain")) return;
3229
+ const T = g.clipboardData?.getData("text/plain");
3230
+ T && (g.preventDefault(), H(T));
3231
+ }
3232
+ async function oe(g) {
3233
+ const T = e.plan.value;
3234
+ if (!T) return !1;
3235
+ const y = bt(T);
3236
+ for (let S = 0; S < T.pages.length; S++) {
3237
+ const F = T.pages[S];
3238
+ if (!(g.reportScope !== void 0 && F.meta?.reportScope !== g.reportScope))
3239
+ for (let q = 0; q < F.components.length; q++)
3240
+ for (const U of w({ pageIndex: S, componentIndex: q, rowIndex: 0, columnIndex: 0 })) {
3241
+ const _ = y(U);
3242
+ if (Dl(_, g))
3243
+ return E(U);
3244
+ }
3245
+ }
3246
+ return !1;
3247
+ }
3248
+ function ue() {
3249
+ n.value = null, c();
3250
+ }
3251
+ return { selection: n, refresh: c, reset: ue, focusCell: E, focusField: oe, navigate: R, onClick: k, onKeydown: A, onCopy: z, onPaste: ae, copySelection: I, pasteSelection: H };
3252
+ }
3253
+ function jl(e) {
3254
+ const t = ve(null), n = ve(!1);
3255
+ let a = 0, o = null;
3256
+ function r(i) {
3257
+ const c = o;
3258
+ o = null, t.value = null, n.value = !1, c?.(i);
3259
+ }
3260
+ function s() {
3261
+ a++, r(!1);
3262
+ }
3263
+ async function l(i) {
3264
+ if (s(), !e.enabled() || !e.pending()) return !0;
3265
+ const c = a, f = [...e.snapshot?.() ?? []];
3266
+ n.value = !0;
3267
+ const m = Object.freeze({ reason: i, reportIds: Object.freeze([...e.reportIds()]), pendingLocalChanges: !0 });
3268
+ try {
3269
+ const d = e.hook(), E = await new Promise((w) => {
3270
+ if (o = w, !d) {
3271
+ t.value = m;
3272
+ return;
3273
+ }
3274
+ Promise.resolve().then(() => d(m)).then((v) => {
3275
+ c === a && r(v === !0);
3276
+ }, (v) => {
3277
+ if (c === a) {
3278
+ try {
3279
+ e.error(v);
3280
+ } catch {
3281
+ }
3282
+ r(!1);
3283
+ }
3284
+ });
3285
+ }), k = e.snapshot?.() ?? [];
3286
+ return c === a && E === !0 && k.length === f.length && f.every((w, v) => Object.is(w, k[v]));
3287
+ } catch (d) {
3288
+ if (c === a) {
3289
+ try {
3290
+ e.error(d);
3291
+ } catch {
3292
+ }
3293
+ r(!1);
3294
+ }
3295
+ return !1;
3296
+ }
3297
+ }
3298
+ return { request: t, pending: n, check: l, settle: r, cancel: s };
3299
+ }
3300
+ function Wl(e) {
3301
+ function t(l) {
3302
+ if (!(l instanceof Me)) return l instanceof Error ? l.message : "单元格保存失败";
3303
+ const i = e.messages();
3304
+ return {
3305
+ number: i.editInvalidNumber,
3306
+ boolean: i.editInvalidBoolean,
3307
+ conflict: i.editConflict,
3308
+ atomic: i.editAtomicRequired,
3309
+ limit: i.clipboardLimit,
3310
+ readonly: i.editReadOnly,
3311
+ missing: i.editMissing,
3312
+ recalculation: i.editRecalculationUnavailable,
3313
+ duplicate: i.editDuplicate,
3314
+ clipboard: i.clipboardInvalid
3315
+ }[l.code] ?? l.message;
3316
+ }
3317
+ const n = Tl({
3318
+ plan: e.plan,
3319
+ options: e.options,
3320
+ blocked: () => e.busy() || o.pending.value,
3321
+ label: () => e.messages().editCell ?? "编辑单元格",
3322
+ errorMessage: t,
3323
+ suspendBlur: () => o.request.value !== null,
3324
+ onChange: e.changed,
3325
+ onError: e.failed,
3326
+ onNavigate: (l, i, c) => a.navigate(l, i, c)
3327
+ }), a = Kl({
3328
+ plan: e.plan,
3329
+ root: e.root,
3330
+ enabled: e.selectionEnabled,
3331
+ editable: () => !!e.options.value,
3332
+ busy: () => e.busy() || n.saving.value || o.pending.value,
3333
+ differences: () => n.differences.value,
3334
+ gotoPage: e.gotoPage,
3335
+ ensureVisible: e.ensureVisible,
3336
+ edit: n.editCell,
3337
+ apply: n.apply,
3338
+ undo: n.undo,
3339
+ redo: n.redo,
3340
+ error: (l) => e.failed(t(l), l)
3341
+ }), o = jl({
3342
+ ...e.guard,
3343
+ pending: () => n.pendingLocalChanges.value,
3344
+ snapshot: () => [e.plan.value, n.active.value?.editor.input.value]
3345
+ });
3346
+ function r(l = "leave") {
3347
+ return o.check(l);
3348
+ }
3349
+ function s(l) {
3350
+ !e.guard.enabled() || !n.pendingLocalChanges.value || (l.preventDefault(), l.returnValue = "");
3351
+ }
3352
+ return Et(() => window.addEventListener("beforeunload", s)), $t(() => {
3353
+ window.removeEventListener("beforeunload", s), o.cancel(), n.reset();
3354
+ }), { editing: n, cells: a, discard: o, confirmDiscard: r };
3355
+ }
3356
+ let Hl = 0;
3357
+ function Ul(e) {
3358
+ const t = ve(null), n = /* @__PURE__ */ new Set();
3359
+ let a = null;
3360
+ function o(i) {
3361
+ t.value = Object.freeze(i);
3362
+ try {
3363
+ e(t.value);
3364
+ } catch {
3365
+ }
3366
+ }
3367
+ function r(i, c, f) {
3368
+ const m = `mr-task-${Date.now().toString(36)}-${++Hl}`;
3369
+ n.add(m), a = f, o({ taskId: m, kind: i, stage: c, status: "running", cancellable: !0 });
3370
+ function d(k, w, v) {
3371
+ t.value?.taskId !== m || t.value.status !== "running" || o({ ...t.value, stage: k, completed: w, total: v });
3372
+ }
3373
+ function E(k = "completed") {
3374
+ t.value?.taskId !== m || t.value.status !== "running" || (a = null, o({ ...t.value, status: k, cancellable: !1 }));
3375
+ }
3376
+ return { taskId: m, update: d, finish: E };
3377
+ }
3378
+ function s() {
3379
+ if (t.value?.status !== "running") return;
3380
+ const i = a;
3381
+ a = null, o({ ...t.value, status: "cancelled", cancellable: !1 }), i?.();
3382
+ }
3383
+ function l(i, c) {
3384
+ t.value?.taskId !== i.taskId && (i.status !== "running" || n.has(i.taskId)) || (n.add(i.taskId), n.size > 100 && n.delete(n.values().next().value), a = i.status === "running" ? c : null, o({ ...i }));
3385
+ }
3386
+ return { state: t, start: r, cancel: s, receive: l };
3387
+ }
3388
+ function Vl(e) {
3389
+ const t = ve(Object.freeze([])), n = /* @__PURE__ */ new Set();
3390
+ let a = 0;
3391
+ function o() {
3392
+ a++, t.value = Object.freeze([]), n.clear();
3393
+ }
3394
+ function r(i) {
3395
+ const c = a, f = [];
3396
+ for (const m of i) {
3397
+ const d = JSON.stringify([m.code, m.format, m.pageIndex, m.componentIndex, m.componentPath, m.path, m.message, m.valueState, m.target]);
3398
+ if (n.has(d)) continue;
3399
+ n.add(d);
3400
+ const E = Object.freeze({ ...m, ...m.target ? { target: Object.freeze({ ...m.target }) } : {}, ...m.componentPath ? { componentPath: Object.freeze([...m.componentPath]) } : {} });
3401
+ f.push(E);
3402
+ }
3403
+ f.length && (t.value = Object.freeze([...t.value, ...f]));
3404
+ for (const m of f) {
3405
+ if (c !== a) break;
3406
+ try {
3407
+ e(m);
3408
+ } catch {
3409
+ }
3410
+ }
3411
+ }
3412
+ function s(i) {
3413
+ r([i]);
3414
+ }
3415
+ function l(i, c) {
3416
+ const f = Na(i, c);
3417
+ return r(f), f;
3418
+ }
3419
+ return { entries: t, reset: o, add: s, addMany: r, inspect: l };
3420
+ }
3421
+ const Gl = { class: "mrp-edit-bar" }, Jl = ["disabled"], Xl = ["disabled"], Yl = { class: "mrp-changes" }, Zl = ["aria-label"], Ql = { key: 0 }, _l = { key: 1 }, ei = ["onClick"], ti = ["title"], ni = ["title"], ai = ["disabled"], oi = {
3422
+ key: 0,
3423
+ role: "status"
3424
+ }, ri = {
3425
+ key: 1,
3426
+ role: "status"
3427
+ }, si = {
3428
+ key: 2,
3429
+ class: "mrp-conflicts",
3430
+ open: ""
3431
+ }, li = /* @__PURE__ */ ye({
3432
+ __name: "ReportEditBar",
3433
+ props: {
3434
+ differences: {},
3435
+ conflicts: {},
3436
+ messages: {},
3437
+ saving: { type: Boolean },
3438
+ canUndo: { type: Boolean },
3439
+ canRedo: { type: Boolean },
3440
+ busy: { type: Boolean },
3441
+ persisted: { type: Boolean }
3442
+ },
3443
+ emits: ["undo", "redo", "restore", "locate"],
3444
+ setup(e) {
3445
+ function t(n) {
3446
+ return n.source ? `${n.source.rowKey} · ${n.source.field}` : `${n.address.pageIndex + 1} / ${n.address.rowIndex + 1}:${n.address.columnIndex + 1}`;
3447
+ }
3448
+ return (n, a) => ($(), C("div", Gl, [
3449
+ p("button", {
3450
+ type: "button",
3451
+ disabled: e.busy || e.saving || !e.canUndo,
3452
+ onClick: a[0] || (a[0] = (o) => n.$emit("undo"))
3453
+ }, x(e.messages.undo), 9, Jl),
3454
+ p("button", {
3455
+ type: "button",
3456
+ disabled: e.busy || e.saving || !e.canRedo,
3457
+ onClick: a[1] || (a[1] = (o) => n.$emit("redo"))
3458
+ }, x(e.messages.redo), 9, Xl),
3459
+ p("details", Yl, [
3460
+ p("summary", null, x(e.messages.changes) + " · " + x(e.messages.changesCount?.replace("{count}", String(e.differences.length))), 1),
3461
+ p("section", {
3462
+ "aria-label": e.messages.changes
3463
+ }, [
3464
+ e.differences.length ? ($(), C("ol", _l, [
3465
+ ($(!0), C(be, null, he(e.differences, (o, r) => ($(), C("li", { key: r }, [
3466
+ p("button", {
3467
+ type: "button",
3468
+ onClick: (s) => n.$emit("locate", o)
3469
+ }, x(t(o)), 9, ei),
3470
+ p("span", null, [
3471
+ p("s", {
3472
+ title: e.messages.changesBefore
3473
+ }, x(o.previousText || "∅"), 9, ti),
3474
+ a[3] || (a[3] = ce(" → ", -1)),
3475
+ p("strong", {
3476
+ title: e.messages.changesAfter
3477
+ }, x(o.text || "∅"), 9, ni)
3478
+ ])
3479
+ ]))), 128))
3480
+ ])) : ($(), C("p", Ql, x(e.messages.changesEmpty), 1))
3481
+ ], 8, Zl)
3482
+ ]),
3483
+ p("button", {
3484
+ type: "button",
3485
+ disabled: e.busy || e.saving || !e.differences.length,
3486
+ onClick: a[2] || (a[2] = (o) => n.$emit("restore"))
3487
+ }, x(e.messages.restoreChanges), 9, ai),
3488
+ e.saving ? ($(), C("span", oi, x(e.messages.saving), 1)) : e.differences.length && !e.conflicts.length ? ($(), C("span", ri, x(e.persisted ? e.messages.editSaved : e.messages.editingLocal), 1)) : j("", !0),
3489
+ e.conflicts.length ? ($(), C("details", si, [
3490
+ p("summary", null, x(e.messages.conflicts) + " · " + x(e.conflicts.length), 1),
3491
+ p("ul", null, [
3492
+ ($(!0), C(be, null, he(e.conflicts, (o, r) => ($(), C("li", { key: r }, x(o.message), 1))), 128))
3493
+ ])
3494
+ ])) : j("", !0)
3495
+ ]));
3496
+ }
3497
+ }), ii = /* @__PURE__ */ we(li, [["__scopeId", "data-v-df1c7b86"]]);
3498
+ function ui(e) {
3499
+ const t = e.table?.columnKeys ?? [], n = t.map(() => []);
3500
+ if (!e.grid) return t;
3501
+ for (const { ci: a, cell: o } of Qt(e.grid, e.widthMm, e.heightMm).cells) {
3502
+ const r = (o.text ?? o.rawText ?? "").trim();
3503
+ if (r)
3504
+ for (let s = a; s < Math.min(t.length, a + (o.colSpan ?? 1)); s++)
3505
+ n[s].includes(r) || n[s].push(r);
3506
+ }
3507
+ return t.map((a, o) => n[o].join(" / ") || a);
3508
+ }
3509
+ function ci(e, t = []) {
3510
+ const n = /* @__PURE__ */ new Set(), a = [];
3511
+ for (const [o, r] of (e?.pages ?? []).entries())
3512
+ for (const s of r.components) {
3513
+ const l = s.table;
3514
+ if (!l || l.role !== "header" || n.has(l.id)) continue;
3515
+ n.add(l.id);
3516
+ const i = ui(s), c = t.filter((E) => E.pageIndex <= o), f = c[c.length - 1]?.label, m = l.source?.datasetId, d = [...new Set([f, l.title, m].filter(Boolean))].join(" · ") || l.id;
3517
+ l.columnKeys.forEach((E, k) => {
3518
+ E && a.push({ key: JSON.stringify([l.id, k]), field: E, label: i[k], group: d, pageIndex: o, tableId: l.id, ...m ? { datasetId: m } : {} });
3519
+ });
3520
+ }
3521
+ return a;
3522
+ }
3523
+ function di(e, t) {
3524
+ const n = t.trim().toLocaleLowerCase().split(/\s+/).filter(Boolean);
3525
+ return e.filter((a) => {
3526
+ const o = `${a.label} ${a.field} ${a.group}`.toLocaleLowerCase();
3527
+ return n.every((r) => o.includes(r));
3528
+ });
3529
+ }
3530
+ function fi(e) {
3531
+ const t = Bn(), n = Z(""), a = Z(0), o = `mrp-column-list-${Xt()?.uid ?? 0}`, r = N(() => ci(e.plan(), e.sections())), s = N(() => di(r.value, n.value)), l = N(() => s.value.slice(0, 100)), i = N(() => [...new Set(l.value.map((k) => k.group))].map((k) => ({ label: k, items: l.value.filter((w) => w.group === k) })));
3532
+ pe(n, () => {
3533
+ a.value = 0;
3534
+ }), pe(e.busy, (k) => {
3535
+ k && t.close();
3536
+ }), pe(r, () => {
3537
+ a.value = 0;
3538
+ });
3539
+ function c(k) {
3540
+ e.busy() || (e.locate(k), t.close(!0));
3541
+ }
3542
+ function f() {
3543
+ if (e.busy()) return;
3544
+ const k = l.value[a.value];
3545
+ k ? c(k) : n.value.trim() && (e.locateField(n.value.trim()), t.close(!0));
3546
+ }
3547
+ function m() {
3548
+ n.value = "", t.panel.value?.querySelector("input")?.focus();
3549
+ }
3550
+ function d(k) {
3551
+ if (!(k.isComposing || k.keyCode === 229 || !["ArrowDown", "ArrowUp", "Enter"].includes(k.key))) {
3552
+ if (k.preventDefault(), k.stopPropagation(), k.key === "Enter") {
3553
+ f();
3554
+ return;
3555
+ }
3556
+ l.value.length && (a.value = (a.value + (k.key === "ArrowDown" ? 1 : -1) + l.value.length) % l.value.length, Be(() => t.panel.value?.querySelector(`[id="${o}-${a.value}"]`)?.scrollIntoView?.({ block: "nearest" })));
3557
+ }
3558
+ }
3559
+ function E(k) {
3560
+ return l.value.findIndex((w) => w.key === k);
3561
+ }
3562
+ return { ...t, field: n, active: a, listId: o, directory: r, matches: s, candidates: l, groups: i, choose: c, submit: f, clear: m, onSearchKeydown: d, candidateIndex: E };
3563
+ }
3564
+ const mi = ["aria-label"], gi = {
3565
+ key: 0,
3566
+ class: "mrp-section-tabs"
3567
+ }, pi = ["aria-current", "disabled", "onClick"], vi = ["aria-expanded", "disabled"], bi = {
3568
+ key: 0,
3569
+ class: "mrp-column-count"
3570
+ }, hi = ["aria-label"], yi = { class: "mrp-column-heading" }, wi = ["aria-label"], xi = ["aria-label", "placeholder", "aria-controls", "aria-activedescendant", "disabled"], ki = ["aria-label"], Ei = ["id", "aria-label"], $i = {
3571
+ key: 0,
3572
+ class: "mrp-column-empty",
3573
+ role: "status"
3574
+ }, Ci = ["aria-label"], Ii = ["id", "aria-selected", "disabled", "onPointermove", "onClick"], Pi = ["title"], Si = {
3575
+ class: "mrp-column-help",
3576
+ role: "status"
3577
+ }, Ri = /* @__PURE__ */ ye({
3578
+ __name: "ReportNavigation",
3579
+ props: {
3580
+ sections: {},
3581
+ currentPage: {},
3582
+ messages: {},
3583
+ busy: { type: Boolean },
3584
+ plan: {},
3585
+ compact: { type: Boolean }
3586
+ },
3587
+ emits: ["goto", "locate", "locate-target"],
3588
+ setup(e, { emit: t }) {
3589
+ const n = e, a = t, o = fi({ plan: () => n.plan, sections: () => n.sections, busy: () => n.busy, locate: (A) => a("locate-target", A), locateField: (A) => a("locate", A) }), { root: r, trigger: s, panel: l, opened: i, field: c, active: f, directory: m, matches: d, candidates: E, groups: k, listId: w } = o, v = N(() => m.value.length > 0 || !n.plan || n.plan.pages.some((A) => A.components.some((h) => h.table?.columnKeys.length))), L = N(() => ({ columnDirectory: "字段目录", columnSearch: "搜索列名或字段", columnNoMatches: "未找到匹配字段", columnResults: "匹配字段", ...n.messages })), b = N(() => (n.messages.columnResultsMore ?? "{count} 个匹配字段,显示前 {limit} 个;继续输入可缩小范围").replace("{count}", String(d.value.length)).replace("{limit}", String(E.value.length)));
3590
+ function R(A) {
3591
+ const h = n.sections[A];
3592
+ return !!h && n.currentPage >= h.pageIndex + 1 && (!n.sections[A + 1] || n.currentPage <= n.sections[A + 1].pageIndex);
3593
+ }
3594
+ return (A, h) => e.sections.length > 1 || v.value ? ($(), C("nav", {
3595
+ key: 0,
3596
+ class: ke(["mrp-section-nav", { "mrp-compact": e.compact }]),
3597
+ "aria-label": e.messages.sections ?? "工作表与章节"
3598
+ }, [
3599
+ e.sections.length > 1 ? ($(), C("div", gi, [
3600
+ ($(!0), C(be, null, he(e.sections, (M, B) => ($(), C("button", {
3601
+ key: B,
3602
+ type: "button",
3603
+ class: ke({ active: R(B) }),
3604
+ "aria-current": R(B) ? "page" : void 0,
3605
+ disabled: e.busy,
3606
+ onClick: (I) => a("goto", M.pageIndex + 1)
3607
+ }, x(M.label), 11, pi))), 128))
3608
+ ])) : j("", !0),
3609
+ v.value ? ($(), C("div", {
3610
+ key: 1,
3611
+ ref_key: "root",
3612
+ ref: r,
3613
+ class: "mrp-column-locator",
3614
+ onKeydown: h[7] || (h[7] = //@ts-ignore
3615
+ (...M) => u(o).onKeydown && u(o).onKeydown(...M))
3616
+ }, [
3617
+ p("button", {
3618
+ ref_key: "trigger",
3619
+ ref: s,
3620
+ type: "button",
3621
+ class: ke(["mrp-directory-trigger", { active: u(i) }]),
3622
+ "aria-expanded": u(i),
3623
+ "aria-haspopup": "dialog",
3624
+ disabled: e.busy,
3625
+ onClick: h[0] || (h[0] = (M) => i.value = !u(i))
3626
+ }, [
3627
+ ne(re, { name: "columns" }),
3628
+ p("span", null, x(L.value.columnDirectory), 1),
3629
+ u(m).length ? ($(), C("span", bi, x(u(m).length), 1)) : j("", !0),
3630
+ ne(re, {
3631
+ name: "chevron-down",
3632
+ size: 12
3633
+ })
3634
+ ], 10, vi),
3635
+ u(i) ? ($(), C("div", {
3636
+ key: 0,
3637
+ ref_key: "panel",
3638
+ ref: l,
3639
+ class: "mrp-column-directory",
3640
+ role: "dialog",
3641
+ "aria-label": L.value.columnDirectory
3642
+ }, [
3643
+ p("div", yi, [
3644
+ p("span", null, [
3645
+ ne(re, { name: "columns" }),
3646
+ ce(x(L.value.columnDirectory), 1)
3647
+ ]),
3648
+ p("button", {
3649
+ type: "button",
3650
+ class: "mrp-column-close",
3651
+ "aria-label": e.messages.closeColumnDirectory ?? "关闭字段目录",
3652
+ onClick: h[1] || (h[1] = (M) => u(o).close(!0))
3653
+ }, [
3654
+ ne(re, {
3655
+ name: "close",
3656
+ size: 15
3657
+ })
3658
+ ], 8, wi)
3659
+ ]),
3660
+ p("form", {
3661
+ class: "mrp-column-search",
3662
+ onSubmit: h[5] || (h[5] = st(
3663
+ //@ts-ignore
3664
+ (...M) => u(o).submit && u(o).submit(...M),
3665
+ ["prevent"]
3666
+ ))
3667
+ }, [
3668
+ ne(re, { name: "search" }),
3669
+ xt(p("input", {
3670
+ "onUpdate:modelValue": h[2] || (h[2] = (M) => zn(c) ? c.value = M : null),
3671
+ type: "search",
3672
+ autocomplete: "off",
3673
+ spellcheck: "false",
3674
+ role: "combobox",
3675
+ "aria-label": L.value.columnSearch,
3676
+ placeholder: L.value.columnSearch,
3677
+ "aria-autocomplete": "list",
3678
+ "aria-expanded": "true",
3679
+ "aria-controls": u(w),
3680
+ "aria-activedescendant": u(E).length ? `${u(w)}-${u(f)}` : void 0,
3681
+ disabled: e.busy,
3682
+ onKeydown: h[3] || (h[3] = //@ts-ignore
3683
+ (...M) => u(o).onSearchKeydown && u(o).onSearchKeydown(...M))
3684
+ }, null, 40, xi), [
3685
+ [kt, u(c)]
3686
+ ]),
3687
+ u(c) ? ($(), C("button", {
3688
+ key: 0,
3689
+ class: "mrp-column-clear",
3690
+ type: "button",
3691
+ "aria-label": e.messages.clearSearch ?? "清除搜索",
3692
+ onClick: h[4] || (h[4] = //@ts-ignore
3693
+ (...M) => u(o).clear && u(o).clear(...M))
3694
+ }, [
3695
+ ne(re, {
3696
+ name: "close",
3697
+ size: 13
3698
+ })
3699
+ ], 8, ki)) : j("", !0)
3700
+ ], 32),
3701
+ p("div", {
3702
+ id: u(w),
3703
+ class: "mrp-column-results",
3704
+ role: "listbox",
3705
+ "aria-label": L.value.columnResults
3706
+ }, [
3707
+ u(E).length ? j("", !0) : ($(), C("p", $i, [
3708
+ ne(re, {
3709
+ name: "search",
3710
+ size: 22
3711
+ }),
3712
+ ce(x(L.value.columnNoMatches), 1)
3713
+ ])),
3714
+ ($(!0), C(be, null, he(u(k), (M) => ($(), C("section", {
3715
+ key: M.label,
3716
+ role: "group",
3717
+ "aria-label": M.label
3718
+ }, [
3719
+ p("strong", null, x(M.label), 1),
3720
+ ($(!0), C(be, null, he(M.items, (B) => ($(), C("button", {
3721
+ id: `${u(w)}-${u(o).candidateIndex(B.key)}`,
3722
+ key: B.key,
3723
+ type: "button",
3724
+ role: "option",
3725
+ tabindex: "-1",
3726
+ class: ke({ "mrp-column-active": u(o).candidateIndex(B.key) === u(f) }),
3727
+ "aria-selected": u(o).candidateIndex(B.key) === u(f),
3728
+ disabled: e.busy,
3729
+ onPointermove: (I) => f.value = u(o).candidateIndex(B.key),
3730
+ onMousedown: h[6] || (h[6] = st(() => {
3731
+ }, ["prevent"])),
3732
+ onClick: (I) => u(o).choose(B)
3733
+ }, [
3734
+ p("span", null, [
3735
+ ce(x(B.label), 1),
3736
+ p("code", {
3737
+ title: B.field
3738
+ }, x(B.field), 9, Pi)
3739
+ ]),
3740
+ ne(re, {
3741
+ name: "arrow-right",
3742
+ size: 14
3743
+ })
3744
+ ], 42, Ii))), 128))
3745
+ ], 8, Ci))), 128))
3746
+ ], 8, Ei),
3747
+ p("p", Si, x(u(d).length > u(E).length ? b.value : e.messages.columnSearchShortcut ?? "↑ ↓ 选择 · Enter 定位"), 1)
3748
+ ], 8, hi)) : j("", !0)
3749
+ ], 544)) : j("", !0)
3750
+ ], 10, mi)) : j("", !0);
3751
+ }
3752
+ }), On = /* @__PURE__ */ we(Ri, [["__scopeId", "data-v-15a41f0e"]]), Mi = { class: "mrp-import-summary" }, Ti = { key: 0 }, Oi = { key: 0 }, Di = /* @__PURE__ */ ye({
3753
+ __name: "ReportImportSummary",
3754
+ props: {
3755
+ result: {},
3756
+ messages: {}
3757
+ },
3758
+ setup(e) {
3759
+ return (t, n) => ($(), C("details", Mi, [
3760
+ p("summary", null, [
3761
+ ce(x(e.messages.importSummary) + " · " + x(e.messages.importPreserved?.replace("{sheets}", String(e.result.sheets.length))) + " ", 1),
3762
+ e.result.warnings.length ? ($(), C("span", Ti, " · " + x(e.result.warnings.length) + " " + x(e.messages.importWarnings), 1)) : j("", !0)
3763
+ ]),
3764
+ p("p", null, x(e.messages.importReadOnly), 1),
3765
+ p("ul", null, [
3766
+ ($(!0), C(be, null, he(e.result.sheets, (a) => ($(), C("li", {
3767
+ key: a.index
3768
+ }, x(a.name) + " · " + x(a.range) + " · " + x(a.rowCount) + " × " + x(a.columnCount), 1))), 128))
3769
+ ]),
3770
+ e.result.warnings.length ? ($(), C("ul", Oi, [
3771
+ ($(!0), C(be, null, he(e.result.warnings, (a, o) => ($(), C("li", { key: o }, x(a), 1))), 128))
3772
+ ])) : j("", !0)
3773
+ ]));
3774
+ }
3775
+ }), Ai = /* @__PURE__ */ we(Di, [["__scopeId", "data-v-54f275e8"]]), Jt = ["html", "pdf", "xlsx", "png", "word"], Dn = ["search", "thumbnails", "zoom", ...Jt, "print", "pdfWindow", "editing", "import"];
3776
+ function yu(e) {
3777
+ return {
3778
+ load: (t) => JSON.parse(e.getItem(t) ?? "null"),
3779
+ save: (t, n) => e.setItem(t, JSON.stringify(n)),
3780
+ remove: (t) => e.removeItem(t)
3781
+ };
3782
+ }
3783
+ function Fi(e, t, n, a) {
3784
+ const o = Z({});
3785
+ let r = 0, s = 0, l = Promise.resolve();
3786
+ const i = N(() => Object.fromEntries(Dn.map((d) => [
3787
+ d,
3788
+ e.value[d] && (o.value[d] ?? t.value[d] ?? !0)
3789
+ ])));
3790
+ function c(d, E) {
3791
+ e.value[d] && (s++, o.value = { ...o.value, [d]: E }, f());
3792
+ }
3793
+ function f() {
3794
+ const d = n?.value;
3795
+ if (!d) return;
3796
+ const E = { ...o.value };
3797
+ l = l.then(() => d.adapter.save(d.key, E)).catch((k) => {
3798
+ a?.(k);
3799
+ });
3800
+ }
3801
+ function m() {
3802
+ s++, o.value = {}, f();
3803
+ }
3804
+ return n && pe(n, async (d) => {
3805
+ const E = ++r, k = s;
3806
+ if (o.value = {}, !!d)
3807
+ try {
3808
+ const w = await d.adapter.load(d.key);
3809
+ if (E !== r || k !== s || !w || typeof w != "object") return;
3810
+ o.value = Object.fromEntries(Dn.flatMap((v) => typeof w[v] == "boolean" ? [[v, w[v]]] : []));
3811
+ } catch (w) {
3812
+ E === r && a?.(w);
3813
+ }
3814
+ }, { immediate: !0 }), Ie(() => {
3815
+ r++;
3816
+ }), { enabled: i, setEnabled: c, reset: m };
3817
+ }
3818
+ function zi(e, t, n) {
3819
+ const a = Z({}), o = Ja(), r = N(() => Xa(o.value, e.preset)), s = N(() => ({
3820
+ ...r.value.messages,
3821
+ ...e.messages
3822
+ })), l = N(() => e.showExport ?? r.value.showExport), i = N(() => e.showPrint ?? r.value.showPrint), c = N(() => e.showPdfWindow ?? r.value.showPdfWindow), f = N(() => e.showSettings ?? r.value.showSettings), m = N(() => e.guardChanges ?? r.value.guardChanges), d = N(() => ({ ...r.value.output, ...e.output })), E = N(() => ({ ...r.value.toolbar, ...e.toolbar })), k = N(() => ({ ...r.value.interaction, ...e.interaction, ...a.value })), w = N(() => e.preferences ?? r.value.preferences), v = N(() => e.assets ?? r.value.assets), L = N(() => e.gapPx ?? (t.value ? 0 : r.value.gapPx)), b = N(() => e.showParams ?? r.value.showParams), R = N(() => e.editable ?? r.value.editable), A = N(() => e.excelImport ?? r.value.excelImport), h = N(() => ({
3823
+ search: E.value.search !== !1,
3824
+ thumbnails: E.value.thumbnails !== !1,
3825
+ zoom: E.value.zoom !== !1,
3826
+ ...Object.fromEntries(Jt.map((ue) => [
3827
+ ue,
3828
+ l.value && (E.value.exportFormats?.includes(ue) ?? !0)
3829
+ ])),
3830
+ print: i.value,
3831
+ pdfWindow: c.value,
3832
+ editing: !!R.value,
3833
+ import: !!A.value
3834
+ })), M = Fi(h, N(() => ({
3835
+ editing: E.value.editing,
3836
+ import: E.value.excelImport
3837
+ })), w, () => n(s.value.preferencesError ?? "Preferences storage unavailable")), B = M.enabled, I = N(() => Jt.filter((ue) => B.value[ue])), z = N(() => B.value.editing ? R.value : !1), H = N(() => B.value.import ? A.value : !1), ae = N(() => typeof R.value == "object" && (typeof R.value.save == "function" || typeof R.value.saveBatch == "function")), oe = N(() => typeof e.emptyState == "object" ? e.emptyState : {});
3838
+ return { resolved: r, resolvedMessages: s, effectiveShowExport: l, effectiveShowPrint: i, effectiveShowPdfWindow: c, effectiveShowSettings: f, effectiveGuardChanges: m, effectiveOutput: d, effectiveInteraction: k, effectiveAssets: v, effectiveGapPx: L, effectiveShowParams: b, availableTools: h, tools: M, toolState: B, visibleExportFormats: I, effectiveEditable: z, effectiveExcelImport: H, persistedEditing: ae, emptyStateContent: oe, sessionInteraction: a };
3839
+ }
3840
+ function Li(e) {
3841
+ let t = 0, n = !1;
3842
+ function a() {
3843
+ const r = e.viewport.value, s = e.root.value, l = e.plan.value;
3844
+ if (!r || !s || !l) return;
3845
+ const i = e.options(), c = Math.max(0, Math.min(20, Math.floor(i.frozenColumns ?? 0)));
3846
+ if (!i.freezeHeaders && c === 0 && !n) return;
3847
+ const f = e.zoom.value || 1, m = r.getBoundingClientRect();
3848
+ s.querySelectorAll("[data-mr-component-index]").forEach((d) => {
3849
+ const E = d.closest("[data-page]"), k = Number(E?.dataset.page) - 1, w = l.pages[k]?.components[Number(d.dataset.mrComponentIndex)];
3850
+ if (!w?.grid || !E) return;
3851
+ d.style.transform = "", d.style.zIndex = "";
3852
+ const v = d.getBoundingClientRect(), L = E.getBoundingClientRect().bottom, b = Math.max(0, (m.left - v.left) / f), R = i.freezeHeaders ? Math.max(0, Math.min((m.top - v.top) / f, (L - v.bottom) / f)) : 0;
3853
+ b > 0 && c > 0 && (d.style.zIndex = "1"), w.table?.role === "header" && R > 0 && (d.style.transform = `translateY(${R}px)`, d.style.zIndex = "5"), d.querySelectorAll(".mrp-cell-frozen").forEach((h) => {
3854
+ h.style.transform = "", h.style.zIndex = "", h.classList.remove("mrp-cell-frozen");
3855
+ });
3856
+ const A = Array.from({ length: c }, (h, M) => `td[data-mr-column-index="${M}"]`);
3857
+ !w.table && i.freezeHeaders && A.push('td[data-mr-row-index="0"]'), A.length && d.querySelectorAll(A.join(",")).forEach((h) => {
3858
+ const M = Number(h.dataset.mrColumnIndex) < c, B = !w.table && Number(h.dataset.mrRowIndex) === 0 && !!i.freezeHeaders, I = M ? b : 0, z = B ? R : 0;
3859
+ h.style.transform = I || z ? `translate(${I}px, ${z}px)` : "", h.classList.toggle("mrp-cell-frozen", !!(I || z)), h.style.zIndex = I || z ? B ? "7" : "6" : "";
3860
+ });
3861
+ }), n = !!i.freezeHeaders || c > 0;
3862
+ }
3863
+ function o() {
3864
+ t || (t = requestAnimationFrame(() => {
3865
+ t = 0, a();
3866
+ }));
3867
+ }
3868
+ return Ie(() => {
3869
+ t && cancelAnimationFrame(t);
3870
+ }), { refresh: a, schedule: o };
3871
+ }
3872
+ function qi(e, t, n, a) {
3873
+ const o = a ?? (e.indexOf(t) === e.lastIndexOf(t) ? e.indexOf(t) : -1), r = o >= 0 && e[o] === t ? o : -1, s = JSON.stringify([r, t]);
3874
+ return n.map((l) => l.target?.reportScope ? { ...l, target: { ...l.target } } : {
3875
+ ...l,
3876
+ ...l.target ? {
3877
+ target: {
3878
+ ...l.target,
3879
+ reportScope: s,
3880
+ ...l.target.tableId ? { tableId: JSON.stringify([r, t, l.target.tableId]) } : {}
3881
+ }
3882
+ } : {}
3883
+ });
3884
+ }
3885
+ async function Xn(e, t, n, a) {
3886
+ if (!t?.assetRegistry && (!t?.assetRenderers || !Object.keys(t.assetRenderers).length)) return e;
3887
+ try {
3888
+ return (await Ba(e, { ...t, signal: n, format: "dom", onDiagnostic: (r) => {
3889
+ n.aborted || (t.onDiagnostic?.(r), a(r.message));
3890
+ } })).plan;
3891
+ } catch (o) {
3892
+ throw n.aborted ? o : new Ge("render", o instanceof Error ? o.message : "Report asset preparation failed", o);
3893
+ }
3894
+ }
3895
+ function Yn(e, t) {
3896
+ const n = ja(e);
3897
+ if (!n.ok) throw new Ge("validate", `渲染计划校验失败(${n.errors.length} 处): ${n.errors.slice(0, 3).map((a) => `${a.path}: ${a.message}`).join("; ")}`);
3898
+ n.warnings.forEach((a) => t(`${a.path}: ${a.message}`));
3899
+ }
3900
+ async function Ni(e, t, n, a) {
3901
+ const o = await Te(e(t), t.signal);
3902
+ return fe(t.signal), a("validate"), Yn(o, t.onWarning ?? (() => {
3903
+ })), fe(t.signal), a("assets"), Xn(o, n, t.signal, t.onWarning ?? (() => {
3904
+ }));
3905
+ }
3906
+ async function Bi(e, t, n, a, o, r) {
3907
+ const { importExcelTemplate: s } = await import("@agile-team/mach-report/xlsx");
3908
+ fe(a);
3909
+ const l = await Te(s(e, { ...t, signal: a }), a);
3910
+ r("layout");
3911
+ const i = Ka(Se(l.template), {}).plan;
3912
+ Yn(i, o), fe(a), r("assets");
3913
+ const c = await Xn(i, n, a, o);
3914
+ return { result: l, plan: c };
3915
+ }
3916
+ function Ki({ source: e, policy: t, feedback: n, view: a, events: o, task: r, diagnostics: s }) {
3917
+ const l = ve(null), i = Z(!1), c = Z(!1), f = ve(null), m = ve(null), { errorMessage: d, lastError: E, notice: k, reportError: w } = n, v = qo();
3918
+ let L = !1;
3919
+ function b() {
3920
+ a.invalidate(), c.value = !1, m.value = null, l.value = null, f.value = null, s.reset();
3921
+ }
3922
+ let R = 0, A = null;
3923
+ function h(g, T) {
3924
+ return g === R && !T.signal.aborted && !L;
3925
+ }
3926
+ function M(g, T) {
3927
+ for (const y of g) {
3928
+ if (T !== R) return !1;
3929
+ o.warning(y);
3930
+ }
3931
+ return T === R;
3932
+ }
3933
+ function B() {
3934
+ const g = e.readParams();
3935
+ return g.params ? g.params : (b(), d.value = g.quiet ? "" : g.error.message, g.quiet || (e.invalidParams(), w(g.error.message, g.error.code, g.error.cause)), null);
3936
+ }
3937
+ async function I() {
3938
+ if (L) return;
3939
+ const g = t.guard("reload");
3940
+ if (!(typeof g == "boolean" ? g : await g) || L) return;
3941
+ const T = ++R;
3942
+ c.value = !1, A?.abort(), A = null;
3943
+ const y = e.fetcher();
3944
+ if (i.value = !1, E.value = null, e.ids().length === 0) {
3945
+ d.value = "缺少报表 ID", b(), w(d.value, "param");
3946
+ return;
3947
+ }
3948
+ if (!y) {
3949
+ d.value = "未提供渲染数据源 fetcher", b(), w(d.value, "config");
3950
+ return;
3951
+ }
3952
+ const S = B();
3953
+ if (!S) return;
3954
+ i.value = !0, d.value = "", k.value = null, b();
3955
+ const F = v.start(), q = new AbortController();
3956
+ A = q;
3957
+ const U = r.start("query", "query", () => {
3958
+ A === q && (q.abort(), R++, A = null, i.value = !1);
3959
+ }), _ = [...e.ids()], W = Object.freeze({ ...S }), Q = /* @__PURE__ */ new Set();
3960
+ function le(Y) {
3961
+ T !== R || q.signal.aborted || Q.has(Y) || (Q.add(Y), o.logWarning(Y), s.add({ code: "layout", severity: "warning", message: Y }), o.warning(Y));
3962
+ }
3963
+ try {
3964
+ const Y = await Ni(y, {
3965
+ reportIds: _,
3966
+ params: S,
3967
+ taskId: U.taskId,
3968
+ onEvent: (G) => {
3969
+ T === R && !q.signal.aborted && U.update(G.stage, G.completed, G.total);
3970
+ },
3971
+ onQueryResult: (G, Re, Pe) => {
3972
+ T === R && !q.signal.aborted && s.addMany(qi(_, G, Re.diagnostics ?? [], Pe));
3973
+ },
3974
+ signal: q.signal,
3975
+ onWarning: le
3976
+ }, t.assets(), U.update);
3977
+ if (!h(T, q) || (l.value = Y, f.value = Object.freeze({ reportIds: Object.freeze(_), params: W }), s.inspect(Y, "dom"), !h(T, q))) return;
3978
+ U.finish(), v.end(F), a.accepted("query"), o.loaded(Y.pages.length);
3979
+ } catch (Y) {
3980
+ if (T !== R) return;
3981
+ if (q.signal.aborted) {
3982
+ U.finish("cancelled");
3983
+ return;
3984
+ }
3985
+ U.finish("failed");
3986
+ const G = Ya(Y);
3987
+ d.value = G.message;
3988
+ const Re = Za(G);
3989
+ w(G.message, Re.code, Re.cause);
3990
+ } finally {
3991
+ T === R && (i.value = !1), A === q && (A = null);
3992
+ }
3993
+ }
3994
+ function z(g) {
3995
+ const T = t.importOptions(), y = typeof T == "object" ? T : {};
3996
+ return { ...y, ...g, limits: { ...y.limits, ...g?.limits } };
3997
+ }
3998
+ function H(g, T) {
3999
+ a.invalidate(), l.value = g, f.value = null, s.reset(), m.value = { sheets: Se(T.sheets), warnings: [...T.warnings] }, d.value = "", k.value = T.warnings.length ? { kind: "warning", message: T.warnings.join(";") } : null, a.accepted("import"), s.addMany(T.warnings.map((y) => ({ code: "excel-import", severity: "warning", message: y }))), l.value === g && s.inspect(g, "dom");
4000
+ }
4001
+ async function ae(g, T) {
4002
+ if (L) throw new Ge("config", "报表预览已卸载");
4003
+ const y = t.guard("import");
4004
+ if (!(typeof y == "boolean" ? y : await y) || L) return null;
4005
+ const S = ++R;
4006
+ A?.abort(), A = null, i.value = !1, a.beforeImport(), c.value = !0;
4007
+ const F = new AbortController();
4008
+ A = F, E.value = null, k.value = { kind: "progress", message: t.importingMessage() ?? "正在导入 Excel…" };
4009
+ const q = r.start("import", "import", () => {
4010
+ A === F && (F.abort(), R++, A = null, c.value = !1, k.value = null);
4011
+ }), U = z(T), _ = Zt(U.signal, F);
4012
+ try {
4013
+ const { result: W, plan: Q } = await Bi(g, {
4014
+ ...U,
4015
+ onProgress: (le, Y) => {
4016
+ q.update("import", le, Y), U.onProgress?.(le, Y);
4017
+ }
4018
+ }, t.assets(), F.signal, (le) => {
4019
+ S === R && o.warning(le);
4020
+ }, q.update);
4021
+ return !h(S, F) || !M(W.warnings, S) || (H(Q, W), !h(S, F)) ? null : (q.finish(), o.imported(W), S === R && o.loaded(Q.pages.length), W);
4022
+ } catch (W) {
4023
+ if (S !== R) return null;
4024
+ if (F.signal.aborted)
4025
+ return q.finish("cancelled"), null;
4026
+ q.finish("failed");
4027
+ const Q = new Ge("import", W instanceof Error ? W.message : "Excel 模板导入失败", W);
4028
+ throw k.value = { kind: "error", message: Q.message }, w(Q.message, "import", W), Q;
4029
+ } finally {
4030
+ _(), S === R && (c.value = !1), A === F && (A = null);
4031
+ }
4032
+ }
4033
+ function oe() {
4034
+ R++, A?.abort(), A = null, i.value = !1, d.value = "", E.value = null, k.value = null, b();
4035
+ }
4036
+ function ue() {
4037
+ L = !0, R++, A?.abort(), A = null, i.value = !1, c.value = !1;
4038
+ }
4039
+ return Ie(ue), { plan: l, loading: i, importing: c, loadedContext: f, importedResult: m, timing: v, reload: I, importExcel: ae, invalidate: b, clear: oe };
4040
+ }
4041
+ const ji = {
4042
+ key: 7,
4043
+ class: "mrp-edit-hint",
4044
+ role: "status"
4045
+ }, Wi = {
4046
+ key: 9,
4047
+ class: "mrp-export-notice mrp-export-warning",
4048
+ role: "status"
4049
+ }, Hi = { class: "mrp-main" }, Ui = {
4050
+ key: 0,
4051
+ class: "mrp-state"
4052
+ }, Vi = {
4053
+ key: 1,
4054
+ class: "mrp-state mrp-error"
4055
+ }, Gi = ["data-page"], Ji = ["aria-label", "aria-current", "onClick"], Xi = ["data-thumb"], Yi = { class: "mrp-thumb-no" }, Zi = {
4056
+ key: 10,
4057
+ class: "mrp-footer"
4058
+ }, Qi = { class: "mrp-footer-context" }, _i = ["aria-label"], eu = { key: 0 }, tu = { class: "mrp-overlay" }, nu = {
4059
+ key: 11,
4060
+ class: "mrp-debug",
4061
+ "aria-hidden": "true"
4062
+ }, Ht = 96 / 25.4, An = "mach-report:ui", Fn = "mach-report:ui:wide", au = /* @__PURE__ */ ye({
4063
+ __name: "ReportPreview",
4064
+ props: {
4065
+ drill: { type: Object, default: void 0 },
4066
+ loadParamOptions: { type: Function, default: void 0 },
4067
+ reportId: {
4068
+ type: [String, Array],
4069
+ default: null
4070
+ },
4071
+ params: {
4072
+ type: Object,
4073
+ default: () => ({})
4074
+ },
4075
+ height: { type: String, default: "100vh" },
4076
+ autoLoad: { type: Boolean, default: !0 },
4077
+ /** 以下显隐/间距不传时走配置中心(preset > defaults > 内置缺省) */
4078
+ showExport: { type: Boolean, default: void 0 },
4079
+ showPrint: { type: Boolean, default: void 0 },
4080
+ showPdfWindow: { type: Boolean, default: void 0 },
4081
+ showSettings: { type: Boolean, default: void 0 },
4082
+ toolbar: { type: Object, default: void 0 },
4083
+ interaction: { type: Object, default: void 0 },
4084
+ preferences: { type: Object, default: void 0 },
4085
+ guardChanges: { type: Boolean, default: void 0 },
4086
+ beforeDiscard: { type: Function, default: void 0 },
4087
+ output: { type: Object, default: void 0 },
4088
+ exportExecution: { type: Object, default: void 0 },
4089
+ assets: { type: Object, default: void 0 },
4090
+ printOptions: { type: Object, default: void 0 },
4091
+ /** 保留表头的零行业务结果;不改变计划和导出内容。 */
4092
+ emptyState: { type: [Boolean, Object], default: !1 },
4093
+ /** 页间距(px);不传走配置中心 */
4094
+ gapPx: { type: Number, default: void 0 },
4095
+ /** 工具栏/状态文案覆写(不传走配置中心 messages) */
4096
+ messages: { type: Object, default: void 0 },
4097
+ /** 启用的 preset 名(不传用配置中心 defaultPreset) */
4098
+ preset: { type: String, default: void 0 },
4099
+ /** 调试面板(也可用 URL ?mrp-debug=1 开启) */
4100
+ debug: { type: Boolean, default: !1 },
4101
+ /** 参数定义(优先级:prop > 模板 params;有定义且未关闭时显示查询面板) */
4102
+ paramDefs: {
4103
+ type: Array,
4104
+ default: void 0
4105
+ },
4106
+ /** 参数面板显隐(不传走配置中心,缺省 true;有参数定义才渲染) */
4107
+ showParams: { type: Boolean, default: void 0 },
4108
+ editable: { type: [Boolean, Object], default: void 0 },
4109
+ excelImport: { type: [Boolean, Object], default: void 0 },
4110
+ fetcher: {
4111
+ type: Function,
4112
+ default: null
4113
+ }
4114
+ },
4115
+ emits: ["loaded", "task", "diagnostic", "error", "warning", "cell-edit", "template-import", "preferences-change"],
4116
+ setup(e, { expose: t, emit: n }) {
4117
+ const a = e, o = n, r = Z(""), s = ve(null), l = Z(null), i = Z(1), c = Z(null), f = Z(null), m = Z(null), d = Z(!1), E = Z(!1), k = Z("general"), w = Z(null), v = Z(null);
4118
+ let L = null, b = !1;
4119
+ const R = Ul((O) => o("task", O)), A = Vl((O) => o("diagnostic", O)), h = N(() => A.entries.value.filter((O) => O.valueState && O.target)), M = N(() => A.entries.value.filter((O) => !O.valueState)), B = Ki({
4120
+ source: { ids: () => U.value, fetcher: () => _.value, readParams: () => dt.value.error ? { error: dt.value.error, quiet: !1 } : Ze.query(), invalidParams: () => {
4121
+ dt.value.error || (ft.value = !0);
4122
+ } },
4123
+ policy: { guard: (O) => Fe.value && ee.pendingLocalChanges.value ? it.check(O) : !0, assets: () => J.value, importOptions: () => Xe.value, importingMessage: () => G.value.importing },
4124
+ feedback: { errorMessage: r, lastError: s, notice: l, reportError: le },
4125
+ task: R,
4126
+ diagnostics: A,
4127
+ view: {
4128
+ invalidate: () => {
4129
+ ee.reset(), de.reset(), Mt.invalidate(), i.value = 1, ge.reset();
4130
+ },
4131
+ beforeImport: () => {
4132
+ ee.cancel(), Mt.invalidatePending();
4133
+ },
4134
+ accepted: (O) => {
4135
+ i.value = 1, f.value && (f.value.scrollTop = 0, f.value.scrollLeft = 0);
4136
+ const K = y.value ? Fn : An;
4137
+ (O === "import" || K !== S) && (S = K, wn()), O === "query" && _e.value === "fit" && pn();
4138
+ }
4139
+ },
4140
+ events: { warning: (O) => o("warning", O), logWarning: (O) => Y.value.logger.warn("[mach-report] 报表告警:", O), loaded: (O) => o("loaded", O), imported: (O) => o("template-import", O) }
4141
+ }), { plan: I, loading: z, importing: H, importedResult: ae, loadedContext: oe, timing: ue, reload: g, importExcel: T } = B, y = N(() => !!I.value?.pages.length && I.value.pages.every((O) => O.layout === "wide"));
4142
+ let S = An;
4143
+ const F = xn(lo, null), q = xn(io, null), U = N(() => Kn(a.reportId)), _ = N(() => a.fetcher ?? F), W = N(() => I.value?.pages.length ?? 0), Q = N(() => Object.freeze({
4144
+ loading: z.value,
4145
+ hasPlan: W.value > 0,
4146
+ pageCount: W.value,
4147
+ currentPage: i.value,
4148
+ exporting: je.value,
4149
+ printing: qe.value,
4150
+ canExport: !z.value && !H.value && !ee.saving.value && W.value > 0 && je.value === null,
4151
+ canPrint: !z.value && !H.value && !ee.saving.value && W.value > 0 && !qe.value,
4152
+ error: s.value,
4153
+ pdfFont: tn.value,
4154
+ editing: ee.active.value !== null,
4155
+ saving: ee.saving.value,
4156
+ importing: H.value,
4157
+ dirty: ee.differences.value.length > 0,
4158
+ pendingLocalChanges: ee.pendingLocalChanges.value,
4159
+ task: R.state.value,
4160
+ diagnostics: A.entries.value,
4161
+ reportIds: oe.value?.reportIds ?? [],
4162
+ params: oe.value?.params ?? {},
4163
+ canUndo: ee.canUndo.value,
4164
+ canRedo: ee.canRedo.value,
4165
+ changeCount: ee.differences.value.length,
4166
+ selection: de.selection.value ? Se(de.selection.value) : null
4167
+ }));
4168
+ function le(O, K, X) {
4169
+ s.value = Object.freeze({ message: O, code: K, cause: X }), o("error", O, { code: K, cause: X });
4170
+ }
4171
+ const {
4172
+ resolved: Y,
4173
+ resolvedMessages: G,
4174
+ effectiveShowExport: Re,
4175
+ effectiveShowSettings: Pe,
4176
+ effectiveGuardChanges: Fe,
4177
+ effectiveOutput: P,
4178
+ effectiveInteraction: D,
4179
+ effectiveAssets: J,
4180
+ effectiveGapPx: V,
4181
+ effectiveShowParams: te,
4182
+ availableTools: se,
4183
+ tools: me,
4184
+ toolState: ie,
4185
+ visibleExportFormats: Ke,
4186
+ effectiveEditable: Oe,
4187
+ effectiveExcelImport: Xe,
4188
+ persistedEditing: Ye,
4189
+ emptyStateContent: It,
4190
+ sessionInteraction: Pt
4191
+ } = zi(a, y, (O) => o("warning", O)), en = N(() => ie.value.pdf || ie.value.pdfWindow), St = N(() => D.value.calculations === !0), Rt = N(() => Qa(G.value)), { pdfFont: tn, getPdfExporter: Zn, checkPdfFont: Qn, retryPdfFont: nn, cancelFontCheck: _n } = vl({
4192
+ plan: I,
4193
+ fontUrl: () => Y.value.pdfFontUrl,
4194
+ enabled: () => en.value,
4195
+ injectedExporter: q,
4196
+ destroyed: () => b
4197
+ });
4198
+ async function ea(O, K) {
4199
+ O === "editing" && !K && !await ee.settle() || (me.setEnabled(O, K), o("preferences-change", Object.freeze({ ...ie.value })));
4200
+ }
4201
+ async function ta() {
4202
+ await ee.settle() && (me.reset(), Pt.value = {}, rn.value = void 0, o("preferences-change", Object.freeze({ ...ie.value })));
4203
+ }
4204
+ async function an(O = "general") {
4205
+ if (E.value) {
4206
+ E.value = !1;
4207
+ return;
4208
+ }
4209
+ const K = ee.settle();
4210
+ !(typeof K == "boolean" ? K : await K) || b || !Pe.value || (k.value = O, E.value = !0);
4211
+ }
4212
+ const { editing: ee, cells: de, discard: it, confirmDiscard: on } = Wl({
4213
+ plan: I,
4214
+ root: c,
4215
+ options: Oe,
4216
+ selectionEnabled: () => !!Oe.value || St.value || !!(a.drill ?? Y.value.drill),
4217
+ busy: () => z.value || H.value || je.value !== null || qe.value,
4218
+ messages: () => G.value,
4219
+ gotoPage: Ee,
4220
+ ensureVisible: (O) => mt.reveal(O),
4221
+ guard: {
4222
+ reportIds: () => oe.value?.reportIds ?? U.value,
4223
+ hook: () => a.beforeDiscard ?? Y.value.beforeDiscard,
4224
+ enabled: () => Fe.value,
4225
+ error: (O) => le(O instanceof Error ? O.message : "修改保护回调失败", "config", O)
4226
+ },
4227
+ changed: (O) => {
4228
+ s.value = null, l.value = null, o("cell-edit", O);
4229
+ },
4230
+ failed: (O, K) => {
4231
+ l.value = { kind: "error", message: O }, le(O, "edit", K);
4232
+ }
4233
+ }), Mt = Io({
4234
+ plan: I,
4235
+ editing: ee,
4236
+ diagnostics: A,
4237
+ task: R,
4238
+ busy: () => z.value || H.value,
4239
+ wide: () => y.value,
4240
+ defaultsPrint: () => Y.value.printOptions,
4241
+ printOverrides: () => a.printOptions,
4242
+ messages: () => G.value,
4243
+ fidelity: () => P.value.fidelity,
4244
+ execution: () => a.exportExecution ?? Y.value.exportExecution,
4245
+ getPdfExporter: Zn,
4246
+ getXlsxOptions: () => Y.value.xlsx,
4247
+ feedback: { lastError: s, notice: l, reportError: le, warning: (O) => o("warning", O) }
4248
+ }), {
4249
+ exporting: je,
4250
+ printing: qe,
4251
+ localPrintCalibration: rn,
4252
+ effectivePrintOptions: na,
4253
+ canCalibratePrint: aa,
4254
+ testPrintCalibration: oa,
4255
+ print: sn,
4256
+ exportAs: ln,
4257
+ openPdfWindow: un,
4258
+ getOutputDiagnostics: ra
4259
+ } = Mt, Tt = _r({ plan: I, selection: de.selection, enabled: () => St.value });
4260
+ function sa() {
4261
+ an("advanced");
4262
+ }
4263
+ const ut = rl({
4264
+ plan: I,
4265
+ selection: de.selection,
4266
+ options: () => a.drill ?? Y.value.drill,
4267
+ params: () => ({ ...oe.value?.params }),
4268
+ view: () => ({ zoom: xe.value, scrollTop: c.value?.scrollTop ?? 0, scrollLeft: c.value?.scrollLeft ?? 0 }),
4269
+ messages: () => G.value,
4270
+ busy: () => z.value || H.value || ee.saving.value || !!je.value || qe.value,
4271
+ beforeOpen: () => on("leave")
4272
+ });
4273
+ function cn() {
4274
+ R.cancel();
4275
+ }
4276
+ function la(O) {
4277
+ const K = ee.resolveAddress(O);
4278
+ K && de.focusCell(K);
4279
+ }
4280
+ async function dn(O) {
4281
+ await de.focusField(O) || (l.value = { kind: "warning", message: G.value.locateFieldMissing ?? "Field not found" });
4282
+ }
4283
+ function ia(O) {
4284
+ if (O.pageIndex === void 0) return;
4285
+ Ee(O.pageIndex + 1);
4286
+ const K = O.componentPath;
4287
+ O.componentIndex !== void 0 && K && K.length === 2 && de.focusCell({ pageIndex: O.pageIndex, componentIndex: O.componentIndex, rowIndex: K[0], columnIndex: K[1] });
4288
+ }
4289
+ const ct = N(() => {
4290
+ if (ae.value) return ae.value.sheets.map((K) => ({ label: K.name, pageIndex: K.pageStart }));
4291
+ const O = /* @__PURE__ */ new Set();
4292
+ return I.value?.pages.flatMap((K, X) => K.components.flatMap((nt) => {
4293
+ const Ne = nt.table;
4294
+ return !Ne?.title || O.has(Ne.id) ? [] : (O.add(Ne.id), [{ label: Ne.title, pageIndex: X }]);
4295
+ })) ?? [];
4296
+ });
4297
+ async function fn(O) {
4298
+ O && !await de.focusField({ field: O }) && (l.value = { kind: "warning", message: G.value.locateFieldMissing ?? "Field not found" });
4299
+ }
4300
+ async function ua(O) {
4301
+ await de.focusField(O) || (l.value = { kind: "warning", message: G.value.locateFieldMissing ?? "Field not found" });
4302
+ }
4303
+ const dt = N(() => {
4304
+ try {
4305
+ return { defs: a.paramDefs ?? _.value?.getParamDefs?.(U.value) ?? [], error: null };
4306
+ } catch (O) {
4307
+ return { defs: [], error: new Ge("config", O instanceof Error ? O.message : "查询参数配置无效", O) };
4308
+ }
4309
+ }), Ot = N(() => dt.value.defs), Ze = _a({ defs: Ot, reportIds: U, params: () => a.params, messages: () => G.value }), { values: Qe, attempted: ft, pendingRequired: mn } = Ze, gn = Z(null);
4310
+ function ca() {
4311
+ ft.value = !0, Ze.validation.value.ok || Be(() => gn.value?.focusInvalid()), g();
4312
+ }
4313
+ function da() {
4314
+ Ze.reset(), r.value = "", s.value = null;
4315
+ }
4316
+ const fa = N(() => ({
4317
+ height: a.height,
4318
+ "--mrp-page-gap": `${Math.max(0, V.value)}px`,
4319
+ ...eo(Y.value.theme)
4320
+ })), { zoom: xe, zoomMode: _e, applyFitZoom: pn, setZoom: et } = mo(() => ({
4321
+ viewport: f.value,
4322
+ pageWidthPx: Dt.contentSize.value.w || 210 * Ht
4323
+ })), Dt = co(I, xe, {
4324
+ pxPerMm: Ht,
4325
+ gapPx: V,
4326
+ overscan: N(() => Y.value.preview.overscanPages)
4327
+ }), { contentSize: At, windowRange: tt, visiblePages: vn, makeScrollHandler: ma, refreshViewport: bn } = Dt, ga = ma(i, W), Ft = Li({ root: c, viewport: f, plan: I, zoom: xe, options: () => D.value });
4328
+ pe([D, xe], () => Ft.schedule(), { flush: "post" });
4329
+ function zt(O) {
4330
+ et(O * 100);
4331
+ }
4332
+ function Ee(O) {
4333
+ if (b || W.value <= 0) return;
4334
+ const K = Math.max(1, Math.min(W.value, O));
4335
+ i.value = K;
4336
+ const X = f.value;
4337
+ X && (Dt.scrollToPage(X, K - 1), mt.prioritize(K - 1));
4338
+ }
4339
+ async function pa(O, K = {}) {
4340
+ b || (Qe.value = { ...Qe.value, ...O }, K.reload !== !1 && (ft.value = !0, await g()));
4341
+ }
4342
+ const hn = {
4343
+ reload: g,
4344
+ print: sn,
4345
+ exportAs: ln,
4346
+ openPdfWindow: un,
4347
+ gotoPage: Ee,
4348
+ setParams: pa,
4349
+ checkPdfFont: Qn,
4350
+ importExcel: T,
4351
+ getPlan: va,
4352
+ cancelTask: cn,
4353
+ confirmDiscard: on,
4354
+ getOutputDiagnostics: ra,
4355
+ getChanges: ee.getChanges,
4356
+ undo: ee.undo,
4357
+ redo: ee.redo,
4358
+ restoreChanges: ee.restore,
4359
+ getDifferences: () => Se(ee.differences.value),
4360
+ getSelection: () => de.selection.value ? Se(de.selection.value) : null,
4361
+ focusCell: de.focusCell,
4362
+ focusField: de.focusField,
4363
+ copySelection: de.copySelection,
4364
+ pasteSelection: de.pasteSelection,
4365
+ get state() {
4366
+ return Q.value;
4367
+ }
4368
+ };
4369
+ Ca(uo, hn);
4370
+ function va() {
4371
+ return I.value ? Se(I.value) : null;
4372
+ }
4373
+ function ba(O) {
4374
+ const K = O.target, X = K.files?.[0];
4375
+ K.value = "", X && T(X).catch(() => {
4376
+ });
4377
+ }
4378
+ const ge = Fo({
4379
+ plan: I,
4380
+ gotoPage: Ee,
4381
+ debounceMs: N(() => Y.value.preview.searchDebounceMs),
4382
+ highlight: So,
4383
+ clearHighlights: Po
4384
+ });
4385
+ pe(() => ie.value.search, (O) => {
4386
+ O || (ge.reset(), ge.visible.value = !1);
4387
+ });
4388
+ function ha(O) {
4389
+ !O.ctrlKey || !ie.value.zoom || (O.preventDefault(), zt(xe.value * (O.deltaY < 0 ? 1.1 : 1 / 1.1)));
4390
+ }
4391
+ function ya(O) {
4392
+ if (!de.onKeydown(O) && !(O.target instanceof Element && O.target.closest("input,textarea,select,[contenteditable='true']"))) {
4393
+ if (ie.value.search && (O.ctrlKey || O.metaKey) && O.key.toLowerCase() === "f") {
4394
+ O.preventDefault(), ge.visible.value || ge.toggle(), Be(() => v.value?.focusSearch());
4395
+ return;
4396
+ }
4397
+ switch (O.key) {
4398
+ case "PageDown":
4399
+ O.preventDefault(), Ee(i.value + 1);
4400
+ break;
4401
+ case "PageUp":
4402
+ O.preventDefault(), Ee(i.value - 1);
4403
+ break;
4404
+ case "Home":
4405
+ O.preventDefault(), Ee(1);
4406
+ break;
4407
+ case "End":
4408
+ O.preventDefault(), Ee(W.value);
4409
+ break;
4410
+ case "+":
4411
+ case "=":
4412
+ O.preventDefault(), ie.value.zoom && zt(xe.value * 1.1);
4413
+ break;
4414
+ case "-":
4415
+ O.preventDefault(), ie.value.zoom && zt(xe.value / 1.1);
4416
+ break;
4417
+ }
4418
+ }
4419
+ }
4420
+ function wa() {
4421
+ try {
4422
+ localStorage.setItem(
4423
+ S,
4424
+ JSON.stringify({ zoomMode: _e.value === "fit" ? "fit" : Math.round(xe.value * 100) })
4425
+ );
4426
+ } catch {
4427
+ }
4428
+ }
4429
+ pe([_e, xe], wa);
4430
+ let Lt = "";
4431
+ function yn(O = !1) {
4432
+ const K = ge.activeMatch.value;
4433
+ if (!y.value || !K) return;
4434
+ const X = `${ge.query.value}:${ge.matchIndex.value}:${K.pageIndex}`;
4435
+ if (!O && X === Lt) return;
4436
+ const Ne = c.value?.querySelector(`[data-page="${K.pageIndex + 1}"]`)?.querySelectorAll("mark.mrp-hit")[K.occurrence];
4437
+ Ne && (Ne.scrollIntoView?.({ block: "nearest", inline: "nearest" }), Lt = X);
4438
+ }
4439
+ const mt = fo({
4440
+ plan: I,
4441
+ root: c,
4442
+ viewport: f,
4443
+ pages: () => vn.value,
4444
+ windowing: () => !D.value.freezeHeaders && !(D.value.frozenColumns ?? 0),
4445
+ priority: () => ge.activeMatch.value?.pageIndex ?? i.value - 1,
4446
+ focusToken: () => ge.activeMatch.value,
4447
+ editorToken: () => ee.active.value,
4448
+ query: () => ge.query.value,
4449
+ zoom: () => xe.value,
4450
+ loading: () => G.value.loading,
4451
+ clear: ge.clear,
4452
+ highlight: ge.apply,
4453
+ mounted: (O) => {
4454
+ de.refresh(O), Ft.schedule();
4455
+ },
4456
+ ready: () => {
4457
+ ge.activeMatch.value || (Lt = ""), yn();
4458
+ },
4459
+ error: (O) => {
4460
+ r.value = O instanceof Error ? O.message : String(O), le(r.value, "render", O);
4461
+ }
4462
+ });
4463
+ pe(() => de.selection.value, () => {
4464
+ de.refresh();
4465
+ }, { flush: "post" }), pe(() => ge.query.value, (O) => {
4466
+ O || c.value?.querySelectorAll(".mrp-page-holder").forEach((K) => {
4467
+ ge.clear(K);
4468
+ });
4469
+ });
4470
+ const De = Lo(I, {
4471
+ thumbsRoot: m,
4472
+ visible: d,
4473
+ renderThumbCanvas: (O) => {
4474
+ try {
4475
+ const K = I.value.pages[O], X = Math.min(0.2, 116 / Math.max(1, K.pageWidthMm * Ht)), { canvases: nt } = Wa(I.value, { start: O, end: O, dpr: X });
4476
+ return nt[0] ?? null;
4477
+ } catch {
4478
+ return null;
4479
+ }
4480
+ }
4481
+ });
4482
+ Ia(() => {
4483
+ De.schedule();
4484
+ }, { flush: "post" });
4485
+ const xa = N(() => a.debug), { debugStats: We } = zo(xa, {
4486
+ plan: I,
4487
+ pageCount: W,
4488
+ windowRange: tt,
4489
+ zoom: xe,
4490
+ loadMs: ue.loadMs
4491
+ });
4492
+ function qt() {
4493
+ bn(f.value), mt.refreshViewport(), De.schedule(), _e.value === "fit" && pn(), yn(!0);
4494
+ }
4495
+ function wn() {
4496
+ et(S === Fn ? 100 : "fit");
4497
+ try {
4498
+ const O = JSON.parse(localStorage.getItem(S) ?? "{}");
4499
+ O.zoomMode === "fit" ? et("fit") : typeof O.zoomMode == "number" && et(O.zoomMode);
4500
+ } catch {
4501
+ }
4502
+ }
4503
+ return Et(() => {
4504
+ window.addEventListener("resize", qt), typeof ResizeObserver < "u" && f.value && (L = new ResizeObserver(qt), L.observe(f.value)), bn(f.value), wn(), a.autoLoad && g();
4505
+ }), $t(() => {
4506
+ b = !0, R.cancel(), H.value = !1, _n(), window.removeEventListener("resize", qt), L?.disconnect(), L = null, De.destroy(), ge.reset();
4507
+ }), pe(
4508
+ () => [JSON.stringify(U.value), JSON.stringify(a.params), _.value],
4509
+ async () => {
4510
+ if (a.autoLoad) {
4511
+ g();
4512
+ return;
4513
+ }
4514
+ !await it.check("replace") || b || B.clear();
4515
+ }
4516
+ ), t({ ...hn, state: Q }), (O, K) => ($(), C("div", {
4517
+ class: ke(["mach-report-preview", { "mrp-wide-report": y.value }]),
4518
+ style: ze(fa.value)
4519
+ }, [
4520
+ u(te) && Ot.value.length > 0 ? ($(), Ce(to, {
4521
+ key: 0,
4522
+ ref_key: "paramPanelRef",
4523
+ ref: gn,
4524
+ defs: Ot.value,
4525
+ "load-options": a.loadParamOptions ?? u(Y).loadParamOptions,
4526
+ modelValue: u(Qe),
4527
+ "onUpdate:modelValue": K[0] || (K[0] = (X) => zn(Qe) ? Qe.value = X : null),
4528
+ messages: u(G),
4529
+ attempted: u(ft),
4530
+ issues: u(Ze).validation.value.issues,
4531
+ onQuery: ca,
4532
+ onReset: da
4533
+ }, null, 8, ["defs", "load-options", "modelValue", "messages", "attempted", "issues"])) : j("", !0),
4534
+ ne($r, {
4535
+ ref_key: "toolbarRef",
4536
+ ref: v,
4537
+ "page-count": W.value,
4538
+ "current-page": i.value,
4539
+ "zoom-mode": u(_e),
4540
+ zoom: u(xe),
4541
+ "show-export": u(Re),
4542
+ "show-print": u(ie).print,
4543
+ "show-pdf-window": u(ie).pdfWindow,
4544
+ "show-search": u(ie).search,
4545
+ "show-thumbnails": u(ie).thumbnails,
4546
+ "show-zoom": u(ie).zoom,
4547
+ "export-formats": u(Ke),
4548
+ "show-settings": u(Pe),
4549
+ "settings-open": E.value,
4550
+ messages: u(G),
4551
+ search: { visible: u(ge).visible.value, query: u(ge).query.value, matchIndex: u(ge).matchIndex.value, matchCount: u(ge).matchCount.value, searching: u(ge).searching.value },
4552
+ "thumbs-visible": d.value,
4553
+ "show-import": !!u(Xe),
4554
+ busy: u(z) || u(H) || u(ee).saving.value,
4555
+ onGoto: Ee,
4556
+ onZoom: u(et),
4557
+ onExport: K[1] || (K[1] = (X) => u(ln)(X)),
4558
+ onPrint: u(sn),
4559
+ onPdfWindow: u(un),
4560
+ onSearchInput: u(ge).onInput,
4561
+ onSearchNav: u(ge).onNav,
4562
+ onSearchToggle: u(ge).toggle,
4563
+ onThumbsToggle: K[2] || (K[2] = (X) => d.value = !d.value),
4564
+ onImportExcel: K[3] || (K[3] = (X) => w.value?.click()),
4565
+ onSettingsToggle: an
4566
+ }, Pa({ _: 2 }, [
4567
+ ct.value.length <= 1 ? {
4568
+ name: "navigation",
4569
+ fn: Nt(() => [
4570
+ W.value > 0 && u(D).navigation !== !1 ? ($(), Ce(On, {
4571
+ key: 0,
4572
+ plan: u(I),
4573
+ compact: "",
4574
+ sections: ct.value,
4575
+ "current-page": i.value,
4576
+ messages: u(G),
4577
+ busy: u(z) || u(H) || u(ee).saving.value,
4578
+ onLocateTarget: dn,
4579
+ onGoto: Ee,
4580
+ onLocate: fn
4581
+ }, null, 8, ["plan", "sections", "current-page", "messages", "busy"])) : j("", !0)
4582
+ ]),
4583
+ key: "0"
4584
+ } : void 0
4585
+ ]), 1032, ["page-count", "current-page", "zoom-mode", "zoom", "show-export", "show-print", "show-pdf-window", "show-search", "show-thumbnails", "show-zoom", "export-formats", "show-settings", "settings-open", "messages", "search", "thumbs-visible", "show-import", "busy", "onZoom", "onPrint", "onPdfWindow", "onSearchInput", "onSearchNav", "onSearchToggle"]),
4586
+ u(it).request.value ? ($(), Ce(Ms, {
4587
+ key: 1,
4588
+ messages: u(G),
4589
+ onAnswer: u(it).settle
4590
+ }, null, 8, ["messages", "onAnswer"])) : j("", !0),
4591
+ ne(Fs, {
4592
+ task: u(R).state.value,
4593
+ messages: u(G),
4594
+ onCancel: cn
4595
+ }, null, 8, ["task", "messages"]),
4596
+ ne(js, {
4597
+ entries: M.value,
4598
+ messages: u(G),
4599
+ onLocate: ia
4600
+ }, null, 8, ["entries", "messages"]),
4601
+ ne(Zs, {
4602
+ entries: h.value,
4603
+ messages: u(G),
4604
+ busy: u(z) || u(H) || u(ee).saving.value,
4605
+ onLocate: ua
4606
+ }, null, 8, ["entries", "messages", "busy"]),
4607
+ ne(ol, {
4608
+ entries: u(ut).entries.value,
4609
+ pending: u(ut).pending.value,
4610
+ error: u(ut).error.value,
4611
+ busy: u(z) || u(H) || u(ee).saving.value,
4612
+ messages: u(G),
4613
+ onOpen: u(ut).open
4614
+ }, null, 8, ["entries", "pending", "error", "busy", "messages", "onOpen"]),
4615
+ E.value && u(Pe) ? ($(), Ce($s, {
4616
+ key: 2,
4617
+ available: u(se),
4618
+ enabled: u(ie),
4619
+ messages: u(G),
4620
+ "persisted-editing": u(Ye),
4621
+ interaction: u(D),
4622
+ section: k.value,
4623
+ busy: u(z) || u(H) || u(ee).saving.value || !!u(je) || u(qe),
4624
+ onSection: K[5] || (K[5] = (X) => k.value = X),
4625
+ onInteraction: K[6] || (K[6] = (X) => Pt.value = { ...u(Pt), ...X }),
4626
+ onChange: ea,
4627
+ onReset: ta,
4628
+ onClose: K[7] || (K[7] = (X) => E.value = !1)
4629
+ }, {
4630
+ advanced: Nt(() => [
4631
+ ne(Qr, {
4632
+ state: u(Tt),
4633
+ messages: Rt.value
4634
+ }, null, 8, ["state", "messages"])
4635
+ ]),
4636
+ default: Nt(() => [
4637
+ lt(O.$slots, "settings", {}, void 0, !0),
4638
+ u(ie).print ? ($(), Ce(dl, {
4639
+ key: 0,
4640
+ value: u(na).calibration ?? {},
4641
+ messages: u(G),
4642
+ busy: u(qe) || u(z) || u(H) || u(ee).saving.value,
4643
+ "can-test": u(aa),
4644
+ onChange: K[4] || (K[4] = (X) => rn.value = X),
4645
+ onTest: u(oa)
4646
+ }, null, 8, ["value", "messages", "busy", "can-test", "onTest"])) : j("", !0)
4647
+ ]),
4648
+ _: 3
4649
+ }, 8, ["available", "enabled", "messages", "persisted-editing", "interaction", "section", "busy"])) : j("", !0),
4650
+ ct.value.length > 1 && W.value > 0 && u(D).navigation !== !1 ? ($(), Ce(On, {
4651
+ key: 3,
4652
+ plan: u(I),
4653
+ onLocateTarget: dn,
4654
+ sections: ct.value,
4655
+ "current-page": i.value,
4656
+ messages: u(G),
4657
+ busy: u(z) || u(H) || u(ee).saving.value,
4658
+ onGoto: Ee,
4659
+ onLocate: fn
4660
+ }, null, 8, ["plan", "sections", "current-page", "messages", "busy"])) : j("", !0),
4661
+ u(ae) ? ($(), Ce(Ai, {
4662
+ key: 4,
4663
+ result: u(ae),
4664
+ messages: u(G)
4665
+ }, null, 8, ["result", "messages"])) : j("", !0),
4666
+ u(Oe) && W.value > 0 ? ($(), Ce(ii, {
4667
+ key: 5,
4668
+ differences: u(ee).differences.value,
4669
+ conflicts: u(ee).conflicts.value,
4670
+ messages: u(G),
4671
+ saving: u(ee).saving.value,
4672
+ "can-undo": u(ee).canUndo.value,
4673
+ "can-redo": u(ee).canRedo.value,
4674
+ persisted: u(Ye),
4675
+ busy: !!u(je) || u(qe),
4676
+ onUndo: u(ee).undo,
4677
+ onRedo: u(ee).redo,
4678
+ onRestore: u(ee).restore,
4679
+ onLocate: la
4680
+ }, null, 8, ["differences", "conflicts", "messages", "saving", "can-undo", "can-redo", "persisted", "busy", "onUndo", "onRedo", "onRestore"])) : j("", !0),
4681
+ u(Xe) ? ($(), C("input", {
4682
+ key: 6,
4683
+ ref_key: "importInputRef",
4684
+ ref: w,
4685
+ class: "mrp-import-input",
4686
+ type: "file",
4687
+ accept: ".xlsx,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
4688
+ hidden: "",
4689
+ onChange: ba
4690
+ }, null, 544)) : j("", !0),
4691
+ u(Oe) && W.value > 0 ? ($(), C("div", ji, x(u(ee).saving.value ? u(G).saving : u(G).editingHint), 1)) : j("", !0),
4692
+ l.value ? ($(), C("div", {
4693
+ key: 8,
4694
+ class: ke(["mrp-export-notice", `mrp-export-${l.value.kind}`]),
4695
+ role: "alert"
4696
+ }, x(l.value.message), 3)) : j("", !0),
4697
+ u(tn).status === "error" && en.value ? ($(), C("div", Wi, [
4698
+ ce(x(u(G).pdfFontUnavailable) + " ", 1),
4699
+ p("button", {
4700
+ type: "button",
4701
+ onClick: K[8] || (K[8] = //@ts-ignore
4702
+ (...X) => u(nn) && u(nn)(...X))
4703
+ }, x(u(G).retry), 1)
4704
+ ])) : j("", !0),
4705
+ p("div", Hi, [
4706
+ p("div", {
4707
+ ref_key: "viewportRef",
4708
+ ref: f,
4709
+ class: "mrp-body",
4710
+ tabindex: "0",
4711
+ onWheel: ha,
4712
+ onKeydown: ya,
4713
+ onDblclick: K[10] || (K[10] = //@ts-ignore
4714
+ (...X) => u(ee).onDoubleClick && u(ee).onDoubleClick(...X)),
4715
+ onClick: K[11] || (K[11] = //@ts-ignore
4716
+ (...X) => u(de).onClick && u(de).onClick(...X)),
4717
+ onCopy: K[12] || (K[12] = //@ts-ignore
4718
+ (...X) => u(de).onCopy && u(de).onCopy(...X)),
4719
+ onPaste: K[13] || (K[13] = //@ts-ignore
4720
+ (...X) => u(de).onPaste && u(de).onPaste(...X)),
4721
+ onScrollPassive: K[14] || (K[14] = (X) => {
4722
+ u(ga)(X.target), u(mt).refreshViewport(), u(Ft).schedule();
4723
+ })
4724
+ }, [
4725
+ u(z) ? ($(), C("div", Ui, x(u(G).loading), 1)) : r.value ? ($(), C("div", Vi, [
4726
+ ce(x(r.value) + " ", 1),
4727
+ p("button", {
4728
+ class: "mrp-retry",
4729
+ type: "button",
4730
+ onClick: K[9] || (K[9] = //@ts-ignore
4731
+ (...X) => u(g) && u(g)(...X))
4732
+ }, x(u(G).retry), 1)
4733
+ ])) : !u(I) || W.value === 0 ? ($(), Ce(Sn, {
4734
+ key: 2,
4735
+ title: u(mn) ? u(G).paramPrompt ?? u(G).paramsTitle : u(G).empty,
4736
+ description: u(mn) ? u(G).paramPromptDescription : u(It).description ?? u(G).emptyDescription
4737
+ }, null, 8, ["title", "description"])) : ($(), C("div", {
4738
+ key: 3,
4739
+ class: "mrp-scale",
4740
+ style: ze({ width: `${u(At).w * u(xe)}px`, height: `${u(At).h * u(xe)}px` })
4741
+ }, [
4742
+ p("div", {
4743
+ ref_key: "containerRef",
4744
+ ref: c,
4745
+ class: "mrp-scale-inner",
4746
+ style: ze({ transform: `scale(${u(xe)})`, transformOrigin: "top left", width: `${u(At).w}px` })
4747
+ }, [
4748
+ u(tt).padTopPx > 0 ? ($(), C("div", {
4749
+ key: 0,
4750
+ class: "mrp-spacer-top",
4751
+ style: ze({ height: `${u(tt).padTopPx}px` }),
4752
+ "aria-hidden": "true"
4753
+ }, null, 4)) : j("", !0),
4754
+ ($(!0), C(be, null, he(u(vn), (X) => ($(), C("div", {
4755
+ key: X.index,
4756
+ class: "mrp-page-holder",
4757
+ "data-page": X.index + 1
4758
+ }, null, 8, Gi))), 128)),
4759
+ u(tt).padBottomPx > 0 ? ($(), C("div", {
4760
+ key: 1,
4761
+ class: "mrp-spacer-bottom",
4762
+ style: ze({ height: `${u(tt).padBottomPx}px` }),
4763
+ "aria-hidden": "true"
4764
+ }, null, 4)) : j("", !0)
4765
+ ], 4)
4766
+ ], 4)),
4767
+ !u(z) && !r.value && u(I) && W.value > 0 && e.emptyState ? ($(), Ce(Sn, {
4768
+ key: 4,
4769
+ title: u(It).title ?? u(G).empty,
4770
+ description: u(It).description ?? u(G).emptyDescription
4771
+ }, null, 8, ["title", "description"])) : j("", !0)
4772
+ ], 544),
4773
+ u(ie).thumbnails && d.value && W.value > 0 ? ($(), C("aside", {
4774
+ key: 0,
4775
+ ref_key: "thumbsRef",
4776
+ ref: m,
4777
+ class: "mrp-thumbs",
4778
+ onScrollPassive: K[15] || (K[15] = //@ts-ignore
4779
+ (...X) => u(De).onScroll && u(De).onScroll(...X))
4780
+ }, [
4781
+ u(De).windowRange.value.padTopPx > 0 ? ($(), C("div", {
4782
+ key: 0,
4783
+ class: "mrp-thumb-spacer",
4784
+ style: ze({ height: `${u(De).windowRange.value.padTopPx}px` }),
4785
+ "aria-hidden": "true"
4786
+ }, null, 4)) : j("", !0),
4787
+ ($(!0), C(be, null, he(u(De).visibleThumbs.value, (X) => ($(), C("button", {
4788
+ key: X.index,
4789
+ class: ke(["mrp-thumb", { "mrp-thumb-active": X.index + 1 === i.value }]),
4790
+ type: "button",
4791
+ "aria-label": `${u(G).thumbnails} · ${u(G).pageInfo.replace("{cur}", String(X.index + 1)).replace("{total}", String(W.value))}`,
4792
+ "aria-current": X.index + 1 === i.value ? "page" : void 0,
4793
+ style: ze({ height: `${X.height + 20}px` }),
4794
+ onClick: (nt) => Ee(X.index + 1)
4795
+ }, [
4796
+ p("span", {
4797
+ class: "mrp-thumb-box",
4798
+ "data-thumb": X.index + 1,
4799
+ style: ze({ height: `${X.height}px` })
4800
+ }, null, 12, Xi),
4801
+ p("span", Yi, x(X.index + 1), 1)
4802
+ ], 14, Ji))), 128)),
4803
+ u(De).windowRange.value.padBottomPx > 0 ? ($(), C("div", {
4804
+ key: 1,
4805
+ class: "mrp-thumb-spacer",
4806
+ style: ze({ height: `${u(De).windowRange.value.padBottomPx}px` }),
4807
+ "aria-hidden": "true"
4808
+ }, null, 4)) : j("", !0)
4809
+ ], 544)) : j("", !0)
4810
+ ]),
4811
+ W.value > 0 ? ($(), C("footer", Zi, [
4812
+ p("div", Qi, [
4813
+ u(D).navigation !== !1 ? ($(), Ce(Fr, {
4814
+ key: 0,
4815
+ plan: u(I),
4816
+ "current-page": i.value,
4817
+ messages: u(G),
4818
+ busy: u(z) || u(H) || u(ee).saving.value,
4819
+ onGoto: Ee
4820
+ }, null, 8, ["plan", "current-page", "messages", "busy"])) : j("", !0),
4821
+ St.value && u(Pe) ? ($(), C("button", {
4822
+ key: 1,
4823
+ class: "mrp-calculation-toggle",
4824
+ type: "button",
4825
+ "aria-label": Rt.value.calculationTitle,
4826
+ onClick: sa
4827
+ }, [
4828
+ K[16] || (K[16] = p("span", { "aria-hidden": "true" }, "∑", -1)),
4829
+ ce(x(Rt.value.calculationTitle), 1),
4830
+ u(Tt).result.value ? ($(), C("strong", eu, x(u(Tt).result.value.formatted), 1)) : j("", !0)
4831
+ ], 8, _i)) : j("", !0)
4832
+ ]),
4833
+ ne(Vn, {
4834
+ "page-count": W.value,
4835
+ "current-page": i.value,
4836
+ messages: u(G),
4837
+ busy: u(z) || u(H) || u(ee).saving.value,
4838
+ onGoto: Ee
4839
+ }, null, 8, ["page-count", "current-page", "messages", "busy"])
4840
+ ])) : j("", !0),
4841
+ p("div", tu, [
4842
+ lt(O.$slots, "default", {}, void 0, !0)
4843
+ ]),
4844
+ u(We) ? ($(), C("div", nu, [
4845
+ K[17] || (K[17] = p("div", null, "mach-report debug", -1)),
4846
+ p("div", null, "pages: " + x(u(We).pages) + " | window: [" + x(u(We).window) + "]", 1),
4847
+ p("div", null, "zoom: " + x(u(We).zoom) + " | load: " + x(u(We).loadMs), 1),
4848
+ p("div", null, "plan: " + x(u(We).planKB) + "KB", 1)
4849
+ ])) : j("", !0)
4850
+ ], 6));
4851
+ }
4852
+ }), ou = /* @__PURE__ */ we(au, [["__scopeId", "data-v-5482f760"]]), wu = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4853
+ __proto__: null,
4854
+ default: ou
4855
+ }, Symbol.toStringTag, { value: "Module" }));
4856
+ export {
4857
+ Bt as P,
4858
+ Jt as R,
4859
+ Dn as a,
4860
+ Vn as b,
4861
+ Se as c,
4862
+ ou as d,
4863
+ $e as e,
4864
+ $r as f,
4865
+ yo as g,
4866
+ hu as h,
4867
+ pl as i,
4868
+ bu as j,
4869
+ go as k,
4870
+ yu as l,
4871
+ vu as m,
4872
+ Kn as n,
4873
+ wo as o,
4874
+ Wn as p,
4875
+ xo as q,
4876
+ mo as r,
4877
+ wu as s,
4878
+ co as u
4879
+ };