@agile-team/mach-report 2.4.1 → 2.6.1

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 (84) hide show
  1. package/README.md +119 -13
  2. package/dist/ReportPreview-Dk-28QAi.js +2946 -0
  3. package/dist/ReportPreview-FSvcBLjH.cjs +6 -0
  4. package/dist/_plugin-vue_export-helper-BHFhmbuH.cjs +1 -0
  5. package/dist/_plugin-vue_export-helper-CHgC5LLL.js +9 -0
  6. package/dist/analytics.cjs +1 -0
  7. package/dist/analytics.d.cts +276 -0
  8. package/dist/analytics.d.ts +276 -0
  9. package/dist/analytics.js +223 -0
  10. package/dist/assets-66UBlhES.cjs +1 -0
  11. package/dist/assets-NVA_sftu.js +163 -0
  12. package/dist/capabilities-CNjIirfo.js +36 -0
  13. package/dist/capabilities-D4xeVYSR.cjs +1 -0
  14. package/dist/designer.cjs +1 -0
  15. package/dist/designer.d.cts +753 -0
  16. package/dist/designer.d.ts +753 -0
  17. package/dist/designer.js +372 -0
  18. package/dist/grid-geometry-BNptEcMm.js +65 -0
  19. package/dist/grid-geometry-CZ_cYB6O.cjs +1 -0
  20. package/dist/index.cjs +8 -5
  21. package/dist/index.d.cts +413 -8
  22. package/dist/index.d.ts +413 -8
  23. package/dist/index.js +1016 -1501
  24. package/dist/param-validation-BWNjLcN0.js +116 -0
  25. package/dist/param-validation-CiTxFeZ8.cjs +1 -0
  26. package/dist/pdf.cjs +48 -48
  27. package/dist/pdf.d.cts +111 -1
  28. package/dist/pdf.d.ts +111 -1
  29. package/dist/pdf.js +3931 -3868
  30. package/dist/{plugin-DwKr8oF6.cjs → plugin-BqBkn_kI.cjs} +1 -1
  31. package/dist/{plugin-CKnSVuVe.js → plugin-Ds10VnQO.js} +2 -2
  32. package/dist/render-plan-CckPEQyf.cjs +1 -0
  33. package/dist/{render-plan-CXBWRog4.js → render-plan-uzZYYSy1.js} +11 -10
  34. package/dist/report-params-B_VCihAh.js +12 -0
  35. package/dist/report-params-CjWrjPl6.cjs +1 -0
  36. package/dist/report-source-B9bENO0F.js +750 -0
  37. package/dist/report-source-BbNkkBDy.cjs +1 -0
  38. package/dist/server/node.d.cts +297 -0
  39. package/dist/server/node.d.ts +297 -0
  40. package/dist/server-node.cjs +1 -0
  41. package/dist/server-node.js +270 -0
  42. package/dist/server.cjs +1 -0
  43. package/dist/server.d.cts +643 -0
  44. package/dist/server.d.ts +643 -0
  45. package/dist/server.js +237 -0
  46. package/dist/style-CpwiOPyB.cjs +1 -0
  47. package/dist/style-Dv5o_x6b.js +67 -0
  48. package/dist/style.css +1 -1
  49. package/dist/template-registry-DWExx0gU.cjs +1 -0
  50. package/dist/template-registry-NpOakidD.js +354 -0
  51. package/dist/textwrap-CnGsEum6.cjs +4 -0
  52. package/dist/textwrap-DOl04hCQ.js +110 -0
  53. package/dist/validate-DfHPD8wX.cjs +1 -0
  54. package/dist/validate-S6CgIm5d.js +148 -0
  55. package/dist/vue/async.d.cts +694 -54
  56. package/dist/vue/async.d.ts +694 -54
  57. package/dist/vue/index.d.cts +1212 -111
  58. package/dist/vue/index.d.ts +1212 -111
  59. package/dist/vue-async.cjs +1 -1
  60. package/dist/vue-async.js +3 -3
  61. package/dist/vue.cjs +1 -1
  62. package/dist/vue.js +167 -80
  63. package/dist/worker.cjs +1 -0
  64. package/dist/worker.d.cts +302 -0
  65. package/dist/worker.d.ts +302 -0
  66. package/dist/worker.js +133 -0
  67. package/dist/xlsx/node.d.cts +47 -0
  68. package/dist/xlsx/node.d.ts +47 -0
  69. package/dist/xlsx-node.cjs +221 -0
  70. package/dist/xlsx-node.js +36409 -0
  71. package/dist/xlsx.cjs +20 -20
  72. package/dist/xlsx.d.cts +78 -1
  73. package/dist/xlsx.d.ts +78 -1
  74. package/dist/xlsx.js +5974 -5831
  75. package/package.json +62 -2
  76. package/dist/ReportPreview-BVTpw9Tb.cjs +0 -6
  77. package/dist/ReportPreview-XF8iSUG1.js +0 -1910
  78. package/dist/grid-geometry-BNIvw52m.cjs +0 -1
  79. package/dist/grid-geometry-C8hGoe9o.js +0 -130
  80. package/dist/render-plan-CCTL4F9v.cjs +0 -1
  81. package/dist/report-params-B3Fia6JO.js +0 -10
  82. package/dist/report-params-D1gZ1DME.cjs +0 -1
  83. package/dist/textwrap-nH0UYU6D.js +0 -108
  84. package/dist/textwrap-oD-t4b4B.cjs +0 -4
@@ -0,0 +1,2946 @@
1
+ import { computed as z, unref as C, ref as U, onScopeDispose as Ie, getCurrentScope as Zn, watch as ne, shallowRef as fe, nextTick as je, defineComponent as Pe, openBlock as E, createElementBlock as I, createElementVNode as T, toDisplayString as R, Fragment as me, createCommentVNode as W, normalizeClass as pe, createStaticVNode as dn, createTextVNode as Ce, onMounted as fn, onUnmounted as mn, withModifiers as vn, renderSlot as St, renderList as ge, withKeys as nn, withDirectives as Yn, vModelText as Xn, inject as at, provide as pn, useCssVars as Qn, watchEffect as _n, normalizeStyle as we, createBlock as $e, isRef as ea, createVNode as ta, withCtx as na } from "vue";
2
+ import { renderPlanToImages as aa, renderPage as gn, ReportParamValidationError as ra, ReportSourceError as oa, validateReportParams as hn, summarizeReportCellEdits as sa, createReportCellEditBatch as la, ReportCellEditError as Ee, createReportCellResolver as Mt, applyReportEditResult as ia, applyReportCellEditBatch as ua, getReportCellContext as _e, parseReportClipboard as ca, formatReportClipboard as da, resolvePlanAssets as fa, paginateTemplate as ma, validateRenderPlan as an, renderPlanToCanvas as va } from "@agile-team/mach-report";
3
+ import { c as bn } from "./page-window-index-CIuT4BAv.js";
4
+ import { i as pa, b as ga } from "./render-plan-uzZYYSy1.js";
5
+ import { _ as ke } from "./_plugin-vue_export-helper-CHgC5LLL.js";
6
+ import { b as Ft, c as ha, d as ba, a as ya } from "./plugin-Ds10VnQO.js";
7
+ import { r as wa } from "./grid-geometry-BNptEcMm.js";
8
+ function yn(e) {
9
+ return e == null ? [] : Array.isArray(e) ? e.map(String).filter((t) => t !== "") : String(e).split(",").map((t) => t.trim()).filter((t) => t !== "");
10
+ }
11
+ function ss(e) {
12
+ return yn(e).join(",");
13
+ }
14
+ class kt extends Error {
15
+ constructor(t) {
16
+ super(t), this.name = "PlanLoadError";
17
+ }
18
+ }
19
+ function ls(e = {}) {
20
+ const { baseUrl: t = "", headers: a, credentials: n, timeoutMs: r = 3e4 } = e, s = t.replace(/\/+$/, "");
21
+ return async ({ url: l, method: d, params: k, signal: g }) => {
22
+ let o = `${s}${l}`;
23
+ if (k && Object.keys(k).length > 0) {
24
+ const P = o.indexOf("#"), V = P >= 0 ? o.slice(P) : "", D = P >= 0 ? o.slice(0, P) : o, c = D.indexOf("?"), v = c >= 0 ? D.slice(0, c) : D, y = new URLSearchParams(c >= 0 ? D.slice(c + 1) : "");
25
+ for (const [$, O] of Object.entries(k)) y.set($, O);
26
+ o = `${v}?${y}${V}`;
27
+ }
28
+ const u = (P, V) => {
29
+ const D = new kt(P);
30
+ return Object.defineProperty(D, "cause", { value: V, configurable: !0, writable: !0 }), D;
31
+ };
32
+ if (g?.aborted)
33
+ throw u(`请求已取消: ${l}`, g.reason);
34
+ const f = new AbortController();
35
+ let m;
36
+ const x = () => {
37
+ f.signal.aborted || (m = "external", f.abort(g?.reason));
38
+ };
39
+ g?.addEventListener("abort", x, { once: !0 });
40
+ const p = setTimeout(() => {
41
+ f.signal.aborted || (m = "timeout", f.abort());
42
+ }, r);
43
+ try {
44
+ const P = await fetch(o, {
45
+ method: d.toUpperCase(),
46
+ headers: { Accept: "application/json", ...a },
47
+ credentials: n,
48
+ signal: f.signal
49
+ });
50
+ if (!P.ok)
51
+ throw new kt(`HTTP ${P.status} ${l}`);
52
+ return await P.json();
53
+ } catch (P) {
54
+ throw m === "timeout" ? u(`请求超时(${r}ms): ${l}`, P) : m === "external" ? u(`请求已取消: ${l}`, P) : P instanceof kt ? P : u(`请求失败(${l}): ${P instanceof Error ? P.message : String(P)}`, P);
55
+ } finally {
56
+ clearTimeout(p), g?.removeEventListener("abort", x);
57
+ }
58
+ };
59
+ }
60
+ function xa(e, t, a = {}) {
61
+ const n = a.pxPerMm ?? 3.7795275590551185, r = z(() => Math.max(0, C(a.gapPx) ?? 18)), s = U(0), l = U(800), d = z(() => {
62
+ const P = e.value?.pages ?? [];
63
+ return bn(P.map((V) => V.pageHeightMm * n), r.value);
64
+ }), k = z(() => {
65
+ let P = 0;
66
+ for (const V of e.value?.pages ?? []) P = Math.max(P, V.pageWidthMm * n);
67
+ return { w: P, h: d.value.totalHeightPx };
68
+ }), g = z(() => d.value.window(
69
+ l.value / t.value,
70
+ s.value / t.value,
71
+ C(a.overscan) ?? 1
72
+ )), o = z(() => {
73
+ const P = e.value;
74
+ if (!P) return [];
75
+ const { start: V, end: D } = g.value;
76
+ return P.pages.slice(V, D + 1).map((c, v) => ({ page: c, index: V + v }));
77
+ });
78
+ let u = 0, f = !1;
79
+ function m(P) {
80
+ P && (s.value = P.scrollTop, l.value = P.clientHeight || 800);
81
+ }
82
+ function x(P, V) {
83
+ return (D) => {
84
+ u || f || (u = requestAnimationFrame(() => {
85
+ if (u = 0, f || (m(D), V.value <= 0)) return;
86
+ const c = Math.max(0, D.scrollTop + 32) / t.value;
87
+ P.value = Math.min(V.value, d.value.pageAt(c) + 1);
88
+ }));
89
+ };
90
+ }
91
+ function p() {
92
+ f = !0, u && cancelAnimationFrame(u), u = 0;
93
+ }
94
+ return Ie(p), {
95
+ contentSize: k,
96
+ windowRange: g,
97
+ visiblePages: o,
98
+ makeScrollHandler: x,
99
+ refreshViewport: m,
100
+ pageOffsetPx: (P) => d.value.offsetAt(P),
101
+ destroy: p
102
+ };
103
+ }
104
+ function Ea(e) {
105
+ const t = U(1), a = U("fit");
106
+ let n = 0;
107
+ function r() {
108
+ n && cancelAnimationFrame(n), n = 0;
109
+ }
110
+ function s() {
111
+ r(), n = requestAnimationFrame(() => {
112
+ if (n = 0, a.value !== "fit") return;
113
+ const d = e();
114
+ !d?.viewport || d.viewport.clientWidth <= 48 || !Number.isFinite(d.pageWidthPx) || (t.value = Math.min(1, (d.viewport.clientWidth - 48) / Math.max(1, d.pageWidthPx)));
115
+ });
116
+ }
117
+ function l(d) {
118
+ if (d === "fit")
119
+ a.value = "fit", s();
120
+ else {
121
+ if (!Number.isFinite(d)) return;
122
+ r(), a.value = "raw", t.value = Math.min(3, Math.max(0.3, d / 100));
123
+ }
124
+ }
125
+ return Zn() && Ie(r), { zoom: t, zoomMode: a, applyFitZoom: s, setZoom: l };
126
+ }
127
+ const rt = 8;
128
+ function ot() {
129
+ return new Promise((e) => setTimeout(e, 0));
130
+ }
131
+ function et(e) {
132
+ return `p${e.pageWidthMm}x${e.pageHeightMm}`.replace(/[.+]/g, "_");
133
+ }
134
+ function At(e) {
135
+ const t = /* @__PURE__ */ new Map();
136
+ return e.pages.forEach((r) => {
137
+ t.has(et(r)) || t.set(et(r), r);
138
+ }), `<!doctype html><html><head><meta charset="utf-8"><style>${`.mr-page{margin:0 auto;page-break-after:always;}
139
+ .mr-page tr{break-inside:avoid;page-break-inside:avoid;}
140
+ .mr-comp{break-inside:avoid;page-break-inside:avoid;}
141
+ ${[...t.values()].map(
142
+ (r) => `@page ${et(r)}{size:${r.pageWidthMm}mm ${r.pageHeightMm}mm;margin:0;}`
143
+ ).join(`
144
+ `)}
145
+ body{margin:0;background:#fff;}`}</style></head><body>`;
146
+ }
147
+ function Ot(e) {
148
+ const t = gn(e, 96, {}, document);
149
+ return t.style.page = et(e), t.outerHTML;
150
+ }
151
+ function wn(e) {
152
+ return { head: At(e), pageChunks: e.pages.map(Ot) };
153
+ }
154
+ async function is(e, t = {}) {
155
+ const a = {
156
+ schemaVersion: "mach-report-batch-print",
157
+ pages: e.flatMap((l) => l.pages)
158
+ };
159
+ if (a.pages.length === 0) return;
160
+ const n = At(a), r = document.createElement("iframe");
161
+ r.style.cssText = "position:fixed;right:0;bottom:0;width:0;height:0;border:0;visibility:hidden;", document.body.appendChild(r);
162
+ let s = !1;
163
+ try {
164
+ const l = r.contentDocument;
165
+ l.open(), l.write(n);
166
+ for (let d = 0; d < a.pages.length; d++)
167
+ l.write(Ot(a.pages[d])), d % rt === rt - 1 && (t.onProgress?.(d + 1, a.pages.length), await ot());
168
+ l.write("</body></html>"), l.close(), await ot(), t.onProgress?.(a.pages.length, a.pages.length), s = !0, r.contentWindow?.focus(), r.contentWindow?.print();
169
+ } catch (l) {
170
+ t.onError?.(l instanceof Error ? `批量打印失败: ${l.message}` : "批量打印失败");
171
+ } finally {
172
+ s ? setTimeout(() => r.remove(), 6e4) : r.remove();
173
+ }
174
+ }
175
+ function Pa(e) {
176
+ const { head: t, pageChunks: a } = wn(e);
177
+ return {
178
+ html: `${`<!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]-->${t.replace(/^<!doctype html><html><head>/, "")}`}${a.join("")}</body></html>`,
179
+ filename: "mach-report.doc"
180
+ };
181
+ }
182
+ function ka(e, t) {
183
+ let a = null, n = !1, r = !1, s = 0;
184
+ const l = /* @__PURE__ */ new Map(), d = /* @__PURE__ */ new Map();
185
+ let k = null, g = null, o = null, u = null, f = null;
186
+ function m(h, b) {
187
+ return !r && e.value === h && s === b;
188
+ }
189
+ function x() {
190
+ if (r) return;
191
+ const h = [...l.values()].reverse().find((b) => m(b.plan, b.epoch))?.format ?? null;
192
+ h !== k && (k = h, t.onBusy?.(h));
193
+ }
194
+ function p(h, b, N) {
195
+ const H = {};
196
+ return l.set(H, { plan: h, epoch: b, format: N }), x(), H;
197
+ }
198
+ function P(h) {
199
+ l.delete(h), x();
200
+ }
201
+ function V() {
202
+ for (const [h, b] of d)
203
+ m(b.plan, b.epoch) || (h.close(), d.delete(h));
204
+ }
205
+ function D() {
206
+ s++, v(), x(), V();
207
+ }
208
+ const c = ne(e, D, { flush: "sync" });
209
+ function v() {
210
+ a?.remove(), a = null;
211
+ }
212
+ function y() {
213
+ r = !0, s++, c(), v(), V(), l.clear(), t.onPrinting?.(!1);
214
+ }
215
+ function $(h, b) {
216
+ const N = URL.createObjectURL(h);
217
+ setTimeout(() => URL.revokeObjectURL(N), 1e4);
218
+ const H = document.createElement("a");
219
+ H.href = N, H.download = b, H.click();
220
+ }
221
+ async function O() {
222
+ if (n) return;
223
+ const h = e.value;
224
+ if (r || !h || h.pages.length === 0) return;
225
+ const b = s;
226
+ n = !0, t.onPrinting?.(!0), v();
227
+ const N = At(h);
228
+ a = document.createElement("iframe"), a.style.cssText = "position:fixed;right:0;bottom:0;width:0;height:0;border:0;visibility:hidden;", document.body.appendChild(a);
229
+ const H = a;
230
+ try {
231
+ const J = H.contentDocument;
232
+ J.open(), J.write(N);
233
+ for (let j = 0; j < h.pages.length; j++)
234
+ if (J.write(Ot(h.pages[j])), j % rt === rt - 1 && await ot(), H !== a) return;
235
+ if (J.write("</body></html>"), J.close(), await ot(), !m(h, b) || H !== a) return;
236
+ H.contentWindow?.focus(), H.contentWindow?.print();
237
+ } catch {
238
+ H === a && v(), m(h, b) && t.onError("调用打印失败,请改用导出 PDF", "print");
239
+ } finally {
240
+ n = !1, r || t.onPrinting?.(!1);
241
+ }
242
+ }
243
+ function B(h, b) {
244
+ if (g?.plan === h && g.epoch === b) return g.promise;
245
+ const N = Promise.resolve().then(() => {
246
+ if (!m(h, b)) throw new Error("报表已切换或卸载");
247
+ return t.getPdfExporter()(h, (H) => {
248
+ m(h, b) && t.onWarning?.(H);
249
+ });
250
+ }).finally(() => {
251
+ g?.promise === N && (g = null);
252
+ });
253
+ return g = { plan: h, epoch: b, promise: N }, N;
254
+ }
255
+ async function M() {
256
+ const h = e.value;
257
+ if (r || !h || h.pages.length === 0) return;
258
+ const b = s;
259
+ if (o?.plan === h && o.epoch === b) return o.promise;
260
+ const N = p(h, b, "PDF"), H = (async () => {
261
+ try {
262
+ const J = await B(h, b);
263
+ if (!m(h, b)) return;
264
+ $(new Blob([J], { type: "application/pdf" }), "mach-report.pdf");
265
+ } catch (J) {
266
+ m(h, b) && t.onError(J instanceof Error ? `PDF 导出失败: ${J.message}` : "PDF 导出失败", "pdf");
267
+ } finally {
268
+ P(N), o?.token === N && (o = null);
269
+ }
270
+ })();
271
+ return o = { plan: h, epoch: b, promise: H, token: N }, H;
272
+ }
273
+ async function F() {
274
+ const h = e.value;
275
+ if (r || !h || h.pages.length === 0) return;
276
+ const b = s;
277
+ if (u?.plan === h && u.epoch === b) return u.promise;
278
+ const N = { ...t.getXlsxOptions?.() }, H = p(h, b, "Excel"), J = (async () => {
279
+ try {
280
+ const { renderPlanToXlsx: j } = await import("@agile-team/mach-report/xlsx");
281
+ if (!m(h, b)) return;
282
+ const { buffer: L, warnings: le } = await j(h, N);
283
+ if (!m(h, b) || (le.length > 0 && t.onWarning?.(`Excel 导出有 ${le.length} 条提示:${le.slice(0, 2).join(";")}`), !m(h, b))) return;
284
+ $(new Blob([L], {
285
+ type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
286
+ }), "mach-report.xlsx");
287
+ } catch (j) {
288
+ m(h, b) && t.onError(j instanceof Error ? `Excel 导出失败: ${j.message}` : "Excel 导出失败", "export");
289
+ } finally {
290
+ P(H), u?.token === H && (u = null);
291
+ }
292
+ })();
293
+ return u = { plan: h, epoch: b, promise: J, token: H }, J;
294
+ }
295
+ async function A() {
296
+ const h = e.value;
297
+ if (r || !h || h.pages.length === 0) return;
298
+ const b = s;
299
+ if (f?.plan === h && f.epoch === b) return f.promise;
300
+ const N = p(h, b, "图片"), H = (async () => {
301
+ try {
302
+ const { blobs: J } = await aa(h, {
303
+ dpr: Math.min(2, typeof devicePixelRatio == "number" ? devicePixelRatio : 1)
304
+ });
305
+ if (!m(h, b)) return;
306
+ J.forEach((j, L) => {
307
+ $(j, J.length > 1 ? `mach-report-page-${L + 1}.png` : "mach-report.png");
308
+ });
309
+ } catch (J) {
310
+ m(h, b) && t.onError(
311
+ J instanceof Error ? `图片导出失败: ${J.message}` : "图片导出失败",
312
+ "export"
313
+ );
314
+ } finally {
315
+ P(N), f?.token === N && (f = null);
316
+ }
317
+ })();
318
+ return f = { plan: h, epoch: b, promise: H, token: N }, H;
319
+ }
320
+ function G() {
321
+ const h = e.value;
322
+ if (!(r || !h || h.pages.length === 0))
323
+ try {
324
+ const { html: b, filename: N } = Pa(h);
325
+ $(new Blob([b], { type: "application/msword;charset=utf-8" }), N);
326
+ } catch (b) {
327
+ t.onError(
328
+ b instanceof Error ? `Word 导出失败: ${b.message}` : "Word 导出失败",
329
+ "export"
330
+ );
331
+ }
332
+ }
333
+ async function Z(h) {
334
+ const b = e.value;
335
+ if (!(r || !b || b.pages.length === 0)) {
336
+ if (h === "pdf") {
337
+ await M();
338
+ return;
339
+ }
340
+ if (h === "xlsx" || h === "excel") {
341
+ await F();
342
+ return;
343
+ }
344
+ if (h === "png" || h === "image") {
345
+ await A();
346
+ return;
347
+ }
348
+ if (h === "word" || h === "doc") {
349
+ G();
350
+ return;
351
+ }
352
+ if (h !== "html") {
353
+ t.onError(`不支持的导出格式:${h}`, "export");
354
+ return;
355
+ }
356
+ try {
357
+ const { head: N, pageChunks: H } = wn(b), J = `${N}${H.join("")}</body></html>`;
358
+ $(new Blob([J], { type: "text/html;charset=utf-8" }), "mach-report.html");
359
+ } catch (N) {
360
+ t.onError(N instanceof Error ? `HTML 导出失败: ${N.message}` : "HTML 导出失败", "export");
361
+ }
362
+ }
363
+ }
364
+ function X() {
365
+ const h = e.value;
366
+ if (r || !h || h.pages.length === 0) return;
367
+ const b = s, N = window.open("", "_blank");
368
+ if (!N) {
369
+ t.onError("浏览器拦截了弹窗,请允许弹窗后重试", "pdf");
370
+ return;
371
+ }
372
+ d.set(N, { plan: h, epoch: b });
373
+ const H = p(h, b, "PDF");
374
+ B(h, b).then((J) => {
375
+ if (!m(h, b) || N.closed) {
376
+ d.delete(N) && N.close();
377
+ return;
378
+ }
379
+ const j = URL.createObjectURL(new Blob([J], { type: "application/pdf" }));
380
+ setTimeout(() => URL.revokeObjectURL(j), 6e4);
381
+ const L = N.document;
382
+ L.title = "PDF 预览", L.documentElement.style.height = "100%", L.body.style.cssText = "margin:0;height:100%;";
383
+ const le = L.createElement("iframe");
384
+ le.title = "PDF 预览", le.style.cssText = "display:block;width:100%;height:100%;border:0;", le.src = j, L.body.replaceChildren(le), d.delete(N);
385
+ }).catch((J) => {
386
+ N.close(), d.delete(N), m(h, b) && t.onError(J instanceof Error ? `PDF 预览失败: ${J.message}` : "PDF 预览失败", "pdf");
387
+ }).finally(() => P(H));
388
+ }
389
+ return {
390
+ print: O,
391
+ exportAs: Z,
392
+ exportImages: A,
393
+ exportWord: G,
394
+ openPdfWindow: X,
395
+ invalidatePending: D,
396
+ releasePrintFrame: v,
397
+ dispose: y
398
+ };
399
+ }
400
+ const xn = "mrp-hit";
401
+ function $a(e) {
402
+ e.querySelectorAll(`mark.${xn}`).forEach((a) => {
403
+ const n = a.parentNode;
404
+ if (n) {
405
+ for (; a.firstChild; ) n.insertBefore(a.firstChild, a);
406
+ a.remove(), n.normalize();
407
+ }
408
+ });
409
+ }
410
+ function Ca(e, t) {
411
+ const a = t.trim();
412
+ if (!a) return 0;
413
+ const n = a.toLowerCase(), r = document.createTreeWalker(e, NodeFilter.SHOW_TEXT, {
414
+ acceptNode(d) {
415
+ const k = d.parentElement;
416
+ return !k || k.closest("mark") || /^(SCRIPT|STYLE)$/.test(k.tagName) ? NodeFilter.FILTER_REJECT : (d.nodeValue ?? "").toLowerCase().includes(n) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_REJECT;
417
+ }
418
+ }), s = [];
419
+ for (let d = r.nextNode(); d; d = r.nextNode()) s.push(d);
420
+ let l = 0;
421
+ for (const d of s) {
422
+ const k = d.nodeValue ?? "", g = k.toLowerCase(), o = d.parentElement;
423
+ if (!o) continue;
424
+ const u = document.createDocumentFragment();
425
+ let f = 0, m = g.indexOf(n);
426
+ for (; m >= 0; ) {
427
+ m > f && u.appendChild(document.createTextNode(k.slice(f, m)));
428
+ const x = document.createElement("mark");
429
+ x.className = xn, x.textContent = k.slice(m, m + a.length), u.appendChild(x), l++, f = m + a.length, m = g.indexOf(n, f);
430
+ }
431
+ f < k.length && u.appendChild(document.createTextNode(k.slice(f))), o.replaceChild(u, d);
432
+ }
433
+ return l;
434
+ }
435
+ const Ia = /* @__PURE__ */ new Set(["line", "rect", "ellipse", "chart"]);
436
+ function* Ra(e) {
437
+ for (const t of e.cells ?? [])
438
+ for (const a of t ?? [])
439
+ yield a?.text ?? "", yield* a?.children ?? [];
440
+ }
441
+ function* Sa(e) {
442
+ if (ga(e))
443
+ for (const t of e.richParagraphs)
444
+ for (const a of t.segments ?? [])
445
+ yield (a.kind === "field" ? a.field : a.text) ?? "";
446
+ else e.lines?.length ? yield* e.lines : yield e.text ?? "";
447
+ }
448
+ function* Ma(e) {
449
+ const t = [e.values()];
450
+ for (; t.length > 0; ) {
451
+ const a = t[t.length - 1].next();
452
+ if (a.done) {
453
+ t.pop();
454
+ continue;
455
+ }
456
+ const n = a.value;
457
+ if (typeof n == "string") {
458
+ yield n;
459
+ continue;
460
+ }
461
+ yield "", !pa(n) && (n.kind === "text" ? t.push(Sa(n)) : n.grid ? t.push(Ra(n.grid)) : Ia.has(n.kind) || (yield n.fallbackText ?? ""));
462
+ }
463
+ }
464
+ function* Fa(e) {
465
+ for (let t = 0; t < e.pages.length; t++) {
466
+ for (const a of Ma(e.pages[t].components)) yield { text: a, pageIndex: t };
467
+ yield { text: "", pageIndex: t };
468
+ }
469
+ }
470
+ function Ta(e, t) {
471
+ const a = e.toLowerCase();
472
+ let n = 0;
473
+ for (let r = a.indexOf(t); r >= 0; r = a.indexOf(t, r + t.length)) n++;
474
+ return n;
475
+ }
476
+ function Da(e) {
477
+ const { plan: t, gotoPage: a, highlight: n, clearHighlights: r } = e, s = U(!1), l = U(""), d = U(0), k = U(0), g = U(!1);
478
+ let o = [];
479
+ const u = z(() => {
480
+ if (k.value === 0) return null;
481
+ const v = d.value;
482
+ let y = 0, $ = o.length - 1;
483
+ for (; y < $; ) {
484
+ const B = y + $ >>> 1;
485
+ o[B].cumulative <= v ? y = B + 1 : $ = B;
486
+ }
487
+ const O = o[y];
488
+ return O ? { pageIndex: O.pageIndex, occurrence: v - (o[y - 1]?.cumulative ?? 0) } : null;
489
+ });
490
+ let f = null, m = null, x = 0;
491
+ function p() {
492
+ x++, f && clearTimeout(f), m && clearTimeout(m), f = m = null, g.value = !1;
493
+ }
494
+ function P(v) {
495
+ l.value = v, d.value = 0, k.value = 0, o = [], g.value = !1;
496
+ const y = v.trim().toLowerCase(), $ = t.value;
497
+ if (!y || !$) return;
498
+ g.value = !0;
499
+ const O = x, B = Fa($), M = [];
500
+ let F = 0;
501
+ function A() {
502
+ if (m = null, O !== x || $ !== t.value) return;
503
+ const G = performance.now();
504
+ let Z = 0;
505
+ for (; Z < 5e3 && performance.now() - G < 4; ) {
506
+ const X = B.next();
507
+ if (X.done) {
508
+ o = M, k.value = F, g.value = !1, o[0] && a(o[0].pageIndex + 1);
509
+ return;
510
+ }
511
+ const h = Ta(X.value.text, y);
512
+ if (h > 0) {
513
+ F += h;
514
+ const b = M[M.length - 1];
515
+ b?.pageIndex === X.value.pageIndex ? b.cumulative = F : M.push({ pageIndex: X.value.pageIndex, cumulative: F });
516
+ }
517
+ Z++;
518
+ }
519
+ m = setTimeout(A, 0);
520
+ }
521
+ A();
522
+ }
523
+ function V(v) {
524
+ if (p(), l.value = v, d.value = k.value = 0, o = [], !v.trim()) {
525
+ P("");
526
+ return;
527
+ }
528
+ g.value = !0, f = setTimeout(() => {
529
+ f = null, P(v);
530
+ }, Math.max(0, C(e.debounceMs) ?? 200));
531
+ }
532
+ function D(v) {
533
+ const y = k.value;
534
+ if (y === 0 || g.value) return;
535
+ d.value = (d.value + v + y) % y;
536
+ const $ = u.value;
537
+ $ && a($.pageIndex + 1);
538
+ }
539
+ function c() {
540
+ p(), l.value = "", d.value = k.value = 0, o = [];
541
+ }
542
+ return ne(t, c, { flush: "sync" }), Ie(c), {
543
+ visible: s,
544
+ query: l,
545
+ matchIndex: d,
546
+ matchCount: k,
547
+ activeMatch: u,
548
+ searching: g,
549
+ toggle: () => {
550
+ s.value = !s.value;
551
+ },
552
+ onInput: V,
553
+ onNav: D,
554
+ apply: (v) => {
555
+ l.value.trim() && n(v, l.value.trim());
556
+ },
557
+ clear: (v) => {
558
+ r(v);
559
+ },
560
+ reset: c
561
+ };
562
+ }
563
+ function Aa(e, t) {
564
+ const a = z(() => {
565
+ if (e.value) return !0;
566
+ if (typeof location > "u") return !1;
567
+ try {
568
+ return new URLSearchParams(location.search).get("mrp-debug") === "1";
569
+ } catch {
570
+ return !1;
571
+ }
572
+ }), n = z(() => !a.value || !t.plan.value ? 0 : Math.round(JSON.stringify(t.plan.value).length / 1024)), r = z(() => !a.value || !t.plan.value ? null : {
573
+ pages: t.pageCount.value,
574
+ window: `${t.windowRange.value.start}-${t.windowRange.value.end}`,
575
+ zoom: `${Math.round(t.zoom.value * 100)}%`,
576
+ loadMs: `${t.loadMs.value}ms`,
577
+ planKB: n.value
578
+ });
579
+ return { enabled: a, debugStats: r };
580
+ }
581
+ function Oa(e, t) {
582
+ const { thumbsRoot: a, visible: n, renderThumbCanvas: r } = t, s = U(0), l = U(800), d = z(() => (e.value?.pages ?? []).map(
583
+ (D) => Math.round(D.pageHeightMm / D.pageWidthMm * 116)
584
+ )), k = z(() => bn(d.value.map((D) => D + 20), 8)), g = z(() => k.value.window(l.value, s.value, 1)), o = z(() => {
585
+ if (!n.value) return [];
586
+ const { start: D, end: c } = g.value;
587
+ return d.value.slice(D, c + 1).map((v, y) => ({ index: D + y, height: v }));
588
+ });
589
+ let u = 0, f = 0, m = !1;
590
+ function x() {
591
+ const D = a.value;
592
+ D && (s.value = D.scrollTop, l.value = D.clientHeight || 800);
593
+ }
594
+ function p() {
595
+ m || f || (f = requestAnimationFrame(() => {
596
+ f = 0, x();
597
+ }));
598
+ }
599
+ function P() {
600
+ if (o.value, u && cancelAnimationFrame(u), u = 0, m || !n.value || !e.value || !a.value) return;
601
+ x();
602
+ const D = o.value, c = e.value, v = a.value;
603
+ let y = 0;
604
+ function $() {
605
+ if (u = 0, !(m || !n.value || e.value !== c || a.value !== v)) {
606
+ for (let O = 0; y < D.length && O < 2; O++, y++) {
607
+ const B = D[y].index, M = v.querySelector(`[data-thumb="${B + 1}"]`);
608
+ if (!M || M.childElementCount > 0) continue;
609
+ const F = r(B);
610
+ F && (F.style.width = "100%", F.style.height = "100%", F.style.display = "block", M.appendChild(F));
611
+ }
612
+ y < D.length && (u = requestAnimationFrame($));
613
+ }
614
+ }
615
+ u = requestAnimationFrame($);
616
+ }
617
+ function V() {
618
+ m = !0, u && cancelAnimationFrame(u), f && cancelAnimationFrame(f), u = f = 0;
619
+ }
620
+ return Ie(V), { schedule: P, destroy: V, onScroll: p, windowRange: g, visibleThumbs: o };
621
+ }
622
+ function za() {
623
+ const e = fe(0);
624
+ return {
625
+ loadMs: e,
626
+ start() {
627
+ return typeof performance < "u" ? performance.now() : 0;
628
+ },
629
+ end(t) {
630
+ e.value = t ? Math.round(performance.now() - t) : 0;
631
+ }
632
+ };
633
+ }
634
+ function Ba(e) {
635
+ const t = U(null), a = U(null);
636
+ function n() {
637
+ t.value?.focus(), t.value?.select();
638
+ }
639
+ ne(e.visible, (l) => {
640
+ l && je(n);
641
+ });
642
+ function r() {
643
+ e.close(), je(() => a.value?.focus());
644
+ }
645
+ function s(l) {
646
+ l.isComposing || l.keyCode === 229 || l.key !== "Enter" && l.key !== "Escape" || (l.preventDefault(), l.stopPropagation(), l.key === "Escape" ? r() : e.navigate(l.shiftKey ? -1 : 1));
647
+ }
648
+ return { input: t, toggle: a, focus: n, close: r, onKeydown: s };
649
+ }
650
+ const La = ["aria-label"], qa = { class: "mrp-title" }, Wa = ["disabled"], Na = { class: "mrp-pageinfo" }, Ha = ["disabled"], ja = ["disabled"], Ka = {
651
+ key: 2,
652
+ class: "mrp-search"
653
+ }, Ua = ["placeholder", "aria-label", "value"], Va = {
654
+ key: 0,
655
+ class: "mrp-search-count",
656
+ role: "status"
657
+ }, Ga = ["disabled", "aria-label"], Ja = ["disabled", "aria-label"], Za = ["aria-label"], Ya = ["aria-label", "aria-pressed"], Xa = ["aria-pressed"], Qa = ["disabled"], _a = ["disabled"], er = ["disabled"], tr = ["disabled"], nr = ["disabled"], ar = ["disabled"], rr = ["disabled"], or = ["aria-label", "aria-expanded"], sr = /* @__PURE__ */ Pe({
658
+ __name: "ReportToolbar",
659
+ props: {
660
+ pageCount: {},
661
+ currentPage: {},
662
+ zoomMode: {},
663
+ zoom: {},
664
+ showExport: { type: Boolean },
665
+ showPrint: { type: Boolean },
666
+ showPdfWindow: { type: Boolean },
667
+ messages: {},
668
+ search: {},
669
+ thumbsVisible: { type: Boolean },
670
+ showImport: { type: Boolean },
671
+ showSearch: { type: Boolean },
672
+ showThumbnails: { type: Boolean },
673
+ showZoom: { type: Boolean },
674
+ exportFormats: {},
675
+ showSettings: { type: Boolean },
676
+ settingsOpen: { type: Boolean },
677
+ busy: { type: Boolean }
678
+ },
679
+ emits: ["goto", "zoom", "export", "print", "pdf-window", "search-input", "search-nav", "search-toggle", "thumbs-toggle", "import-excel", "settings-toggle"],
680
+ setup(e, { expose: t, emit: a }) {
681
+ const n = e, r = a, s = Ba({
682
+ visible: () => n.search.visible,
683
+ navigate: (g) => r("search-nav", g),
684
+ close: () => {
685
+ n.search.visible && r("search-toggle");
686
+ }
687
+ }), { input: l, toggle: d } = s;
688
+ t({ focusSearch: s.focus });
689
+ function k(g, o, u) {
690
+ return g.replace("{cur}", String(o)).replace("{total}", String(u));
691
+ }
692
+ return (g, o) => (E(), I("div", {
693
+ class: "mrp-toolbar",
694
+ role: "toolbar",
695
+ "aria-label": e.messages.title
696
+ }, [
697
+ T("span", qa, R(e.messages.title), 1),
698
+ e.pageCount > 0 ? (E(), I(me, { key: 0 }, [
699
+ T("button", {
700
+ class: "mrp-nav",
701
+ type: "button",
702
+ disabled: e.currentPage <= 1,
703
+ onClick: o[0] || (o[0] = (u) => g.$emit("goto", e.currentPage - 1))
704
+ }, R(e.messages.prevPage), 9, Wa),
705
+ T("span", Na, R(k(e.messages.pageInfo, e.currentPage, e.pageCount)), 1),
706
+ T("button", {
707
+ class: "mrp-nav",
708
+ type: "button",
709
+ disabled: e.currentPage >= e.pageCount,
710
+ onClick: o[1] || (o[1] = (u) => g.$emit("goto", e.currentPage + 1))
711
+ }, R(e.messages.nextPage), 9, Ha)
712
+ ], 64)) : W("", !0),
713
+ o[23] || (o[23] = T("span", { class: "mrp-spacer" }, null, -1)),
714
+ e.showImport ? (E(), I("button", {
715
+ key: 1,
716
+ class: "mrp-nav mrp-import-excel",
717
+ type: "button",
718
+ disabled: e.busy,
719
+ onClick: o[2] || (o[2] = (u) => g.$emit("import-excel"))
720
+ }, R(e.messages.importExcel ?? "导入 Excel 模板"), 9, ja)) : W("", !0),
721
+ e.showSearch !== !1 && e.search.visible ? (E(), I("div", Ka, [
722
+ T("input", {
723
+ ref_key: "searchInputRef",
724
+ ref: l,
725
+ class: "mrp-search-input",
726
+ type: "text",
727
+ placeholder: e.messages.searchPlaceholder,
728
+ "aria-label": e.messages.search ?? e.messages.searchPlaceholder,
729
+ value: e.search.query,
730
+ onInput: o[3] || (o[3] = (u) => g.$emit("search-input", u.target.value)),
731
+ onKeydown: o[4] || (o[4] = //@ts-ignore
732
+ (...u) => C(s).onKeydown && C(s).onKeydown(...u))
733
+ }, null, 40, Ua),
734
+ e.search.query ? (E(), I("span", Va, R(e.search.searching ? e.messages.searching ?? "搜索中…" : k(e.messages.matchInfo, e.search.matchCount > 0 ? e.search.matchIndex + 1 : 0, e.search.matchCount)), 1)) : W("", !0),
735
+ T("button", {
736
+ class: "mrp-nav",
737
+ type: "button",
738
+ disabled: e.search.matchCount === 0,
739
+ "aria-label": e.messages.prevSearchMatch,
740
+ onClick: o[5] || (o[5] = (u) => g.$emit("search-nav", -1))
741
+ }, R(e.messages.prevMatch), 9, Ga),
742
+ T("button", {
743
+ class: "mrp-nav",
744
+ type: "button",
745
+ disabled: e.search.matchCount === 0,
746
+ "aria-label": e.messages.nextSearchMatch,
747
+ onClick: o[6] || (o[6] = (u) => g.$emit("search-nav", 1))
748
+ }, R(e.messages.nextMatch), 9, Ja),
749
+ T("button", {
750
+ class: "mrp-nav mrp-search-close",
751
+ type: "button",
752
+ "aria-label": e.messages.closeSearch,
753
+ onClick: o[7] || (o[7] = //@ts-ignore
754
+ (...u) => C(s).close && C(s).close(...u))
755
+ }, "×", 8, Za)
756
+ ])) : W("", !0),
757
+ e.showSearch !== !1 ? (E(), I("button", {
758
+ key: 3,
759
+ ref_key: "searchToggleRef",
760
+ ref: d,
761
+ class: pe(["mrp-nav", { "mrp-active": e.search.visible }]),
762
+ type: "button",
763
+ title: "Ctrl+F",
764
+ "aria-label": e.messages.search ?? e.messages.searchPlaceholder,
765
+ "aria-pressed": e.search.visible,
766
+ onClick: o[8] || (o[8] = (u) => g.$emit("search-toggle"))
767
+ }, [...o[21] || (o[21] = [
768
+ T("svg", {
769
+ width: "13",
770
+ height: "13",
771
+ viewBox: "0 0 20 20",
772
+ fill: "none",
773
+ "aria-hidden": "true"
774
+ }, [
775
+ T("circle", {
776
+ cx: "8.5",
777
+ cy: "8.5",
778
+ r: "5.5",
779
+ stroke: "currentColor",
780
+ "stroke-width": "1.6"
781
+ }),
782
+ T("path", {
783
+ d: "m13 13 4 4",
784
+ stroke: "currentColor",
785
+ "stroke-width": "1.6",
786
+ "stroke-linecap": "round"
787
+ })
788
+ ], -1)
789
+ ])], 10, Ya)) : W("", !0),
790
+ e.showThumbnails !== !1 ? (E(), I("button", {
791
+ key: 4,
792
+ class: pe(["mrp-nav", { "mrp-active": e.thumbsVisible }]),
793
+ type: "button",
794
+ "aria-pressed": e.thumbsVisible,
795
+ onClick: o[9] || (o[9] = (u) => g.$emit("thumbs-toggle"))
796
+ }, " ▦ " + R(e.messages.thumbnails), 11, Xa)) : W("", !0),
797
+ e.showZoom !== !1 ? (E(), I("button", {
798
+ key: 5,
799
+ class: pe(["mrp-nav", { "mrp-active": e.zoomMode === "fit" }]),
800
+ type: "button",
801
+ onClick: o[10] || (o[10] = (u) => g.$emit("zoom", "fit"))
802
+ }, R(e.messages.fitWidth), 3)) : W("", !0),
803
+ e.showZoom !== !1 ? (E(), I("button", {
804
+ key: 6,
805
+ class: pe(["mrp-nav", { "mrp-active": e.zoomMode === "raw" && Math.round(e.zoom * 100) === 100 }]),
806
+ type: "button",
807
+ onClick: o[11] || (o[11] = (u) => g.$emit("zoom", 100))
808
+ }, " 100% ", 2)) : W("", !0),
809
+ e.showZoom !== !1 ? (E(), I("button", {
810
+ key: 7,
811
+ class: pe(["mrp-nav", { "mrp-active": e.zoomMode === "raw" && Math.round(e.zoom * 100) === 150 }]),
812
+ type: "button",
813
+ onClick: o[12] || (o[12] = (u) => g.$emit("zoom", 150))
814
+ }, " 150% ", 2)) : W("", !0),
815
+ e.showExport && (!e.exportFormats || e.exportFormats.includes("html")) ? (E(), I("button", {
816
+ key: 8,
817
+ class: "mrp-nav",
818
+ type: "button",
819
+ disabled: e.busy,
820
+ onClick: o[13] || (o[13] = (u) => g.$emit("export", "html"))
821
+ }, R(e.messages.exportHtml), 9, Qa)) : W("", !0),
822
+ e.showExport && (!e.exportFormats || e.exportFormats.includes("pdf")) ? (E(), I("button", {
823
+ key: 9,
824
+ class: "mrp-nav",
825
+ type: "button",
826
+ disabled: e.busy,
827
+ onClick: o[14] || (o[14] = (u) => g.$emit("export", "pdf"))
828
+ }, R(e.messages.exportPdf), 9, _a)) : W("", !0),
829
+ e.showExport && (!e.exportFormats || e.exportFormats.includes("xlsx")) ? (E(), I("button", {
830
+ key: 10,
831
+ class: "mrp-nav",
832
+ type: "button",
833
+ disabled: e.busy,
834
+ onClick: o[15] || (o[15] = (u) => g.$emit("export", "xlsx"))
835
+ }, R(e.messages.exportExcel), 9, er)) : W("", !0),
836
+ e.showExport && (!e.exportFormats || e.exportFormats.includes("png")) ? (E(), I("button", {
837
+ key: 11,
838
+ class: "mrp-nav",
839
+ type: "button",
840
+ disabled: e.busy,
841
+ onClick: o[16] || (o[16] = (u) => g.$emit("export", "png"))
842
+ }, R(e.messages.exportImage), 9, tr)) : W("", !0),
843
+ e.showExport && (!e.exportFormats || e.exportFormats.includes("word")) ? (E(), I("button", {
844
+ key: 12,
845
+ class: "mrp-nav",
846
+ type: "button",
847
+ disabled: e.busy,
848
+ onClick: o[17] || (o[17] = (u) => g.$emit("export", "word"))
849
+ }, R(e.messages.exportWord), 9, nr)) : W("", !0),
850
+ e.showPrint ? (E(), I("button", {
851
+ key: 13,
852
+ class: "mrp-nav",
853
+ type: "button",
854
+ disabled: e.busy,
855
+ onClick: o[18] || (o[18] = (u) => g.$emit("print"))
856
+ }, R(e.messages.print), 9, ar)) : W("", !0),
857
+ e.showPdfWindow ? (E(), I("button", {
858
+ key: 14,
859
+ class: "mrp-nav",
860
+ type: "button",
861
+ disabled: e.busy,
862
+ onClick: o[19] || (o[19] = (u) => g.$emit("pdf-window"))
863
+ }, R(e.messages.pdfWindow), 9, rr)) : W("", !0),
864
+ e.showSettings ? (E(), I("button", {
865
+ key: 15,
866
+ class: "mrp-nav mrp-settings-toggle",
867
+ type: "button",
868
+ "aria-label": e.messages.settings,
869
+ "aria-haspopup": "dialog",
870
+ "aria-expanded": !!e.settingsOpen,
871
+ onClick: o[20] || (o[20] = (u) => g.$emit("settings-toggle"))
872
+ }, [
873
+ o[22] || (o[22] = dn('<svg width="14" height="14" viewBox="0 0 20 20" fill="none" aria-hidden="true" data-v-249cf7b0><path d="M3 5h14M3 10h14M3 15h14" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" data-v-249cf7b0></path><circle cx="7" cy="5" r="2" fill="var(--mrp-toolbar-bg)" stroke="currentColor" stroke-width="1.5" data-v-249cf7b0></circle><circle cx="13" cy="10" r="2" fill="var(--mrp-toolbar-bg)" stroke="currentColor" stroke-width="1.5" data-v-249cf7b0></circle><circle cx="8" cy="15" r="2" fill="var(--mrp-toolbar-bg)" stroke="currentColor" stroke-width="1.5" data-v-249cf7b0></circle></svg>', 1)),
874
+ Ce(" " + R(e.messages.settings), 1)
875
+ ], 8, or)) : W("", !0)
876
+ ], 8, La));
877
+ }
878
+ }), lr = /* @__PURE__ */ ke(sr, [["__scopeId", "data-v-249cf7b0"]]), ir = ["aria-label"], ur = { class: "mrp-settings-header" }, cr = ["aria-label"], dr = { class: "mrp-settings-content" }, fr = { key: 0 }, mr = { class: "mrp-settings-option" }, vr = ["checked", "disabled"], pr = { class: "mrp-settings-option" }, gr = ["value", "disabled"], hr = { key: 0 }, br = ["checked", "disabled", "onChange"], yr = {
879
+ key: 1,
880
+ class: "mrp-settings-note"
881
+ }, wr = {
882
+ key: 2,
883
+ class: "mrp-settings-note"
884
+ }, xr = ["disabled"], Er = /* @__PURE__ */ Pe({
885
+ __name: "ReportSettings",
886
+ props: {
887
+ available: {},
888
+ enabled: {},
889
+ messages: {},
890
+ persistedEditing: { type: Boolean },
891
+ busy: { type: Boolean },
892
+ interaction: {}
893
+ },
894
+ emits: ["change", "reset", "close", "interaction"],
895
+ setup(e, { emit: t }) {
896
+ const a = e, n = t, r = U(null), s = U(null);
897
+ let l = null;
898
+ const d = z(() => [
899
+ { label: a.messages.settingsDisplay, tools: [
900
+ ["search", a.messages.search],
901
+ ["thumbnails", a.messages.thumbnails],
902
+ ["zoom", a.messages.zoom]
903
+ ] },
904
+ { label: a.messages.settingsExport, tools: [
905
+ ["html", a.messages.exportHtml],
906
+ ["pdf", a.messages.exportPdf],
907
+ ["xlsx", a.messages.exportExcel],
908
+ ["png", a.messages.exportImage],
909
+ ["word", a.messages.exportWord],
910
+ ["print", a.messages.print],
911
+ ["pdfWindow", a.messages.pdfWindow]
912
+ ] },
913
+ { label: a.messages.settingsData, tools: [
914
+ ["editing", a.messages.editCell],
915
+ ["import", a.messages.importExcel]
916
+ ] }
917
+ ].map((o) => ({ ...o, tools: o.tools.map(([u, f]) => ({ key: u, label: f })) })));
918
+ function k(o, u) {
919
+ const f = o.target, m = f.checked;
920
+ f.checked = a.enabled[u], n("change", u, m);
921
+ }
922
+ function g(o) {
923
+ if (o.key === "Escape") {
924
+ o.preventDefault(), n("close");
925
+ return;
926
+ }
927
+ if (o.key !== "Tab") return;
928
+ const u = r.value?.querySelectorAll("a[href],button:not(:disabled),input:not(:disabled),textarea:not(:disabled),select:not(:disabled),[tabindex='0']"), f = u?.[0], m = u?.[u.length - 1];
929
+ o.shiftKey && document.activeElement === f && (o.preventDefault(), m?.focus()), !o.shiftKey && document.activeElement === m && (o.preventDefault(), f?.focus());
930
+ }
931
+ return fn(() => {
932
+ l = document.activeElement instanceof HTMLElement ? document.activeElement : null, s.value?.focus();
933
+ }), mn(() => l?.focus()), (o, u) => (E(), I("div", {
934
+ class: "mrp-settings-backdrop",
935
+ onClick: u[4] || (u[4] = vn((f) => o.$emit("close"), ["self"])),
936
+ onKeydown: g
937
+ }, [
938
+ T("section", {
939
+ ref_key: "panel",
940
+ ref: r,
941
+ class: "mrp-settings-panel",
942
+ role: "dialog",
943
+ "aria-modal": "true",
944
+ "aria-label": e.messages.settings
945
+ }, [
946
+ T("header", ur, [
947
+ T("div", null, [
948
+ T("strong", null, R(e.messages.settings), 1),
949
+ T("p", null, R(e.messages.settingsLocal), 1)
950
+ ]),
951
+ T("button", {
952
+ ref_key: "closeButton",
953
+ ref: s,
954
+ class: "mrp-settings-close",
955
+ type: "button",
956
+ "aria-label": e.messages.settingsClose,
957
+ onClick: u[0] || (u[0] = (f) => o.$emit("close"))
958
+ }, "×", 8, cr)
959
+ ]),
960
+ T("div", dr, [
961
+ St(o.$slots, "default", {}, void 0, !0),
962
+ e.interaction ? (E(), I("fieldset", fr, [
963
+ T("legend", null, R(e.messages.settingsPanes), 1),
964
+ T("label", mr, [
965
+ T("span", null, R(e.messages.freezeHeaders), 1),
966
+ T("input", {
967
+ type: "checkbox",
968
+ checked: e.interaction.freezeHeaders,
969
+ disabled: e.busy,
970
+ onChange: u[1] || (u[1] = (f) => o.$emit("interaction", { freezeHeaders: f.target.checked }))
971
+ }, null, 40, vr)
972
+ ]),
973
+ T("label", pr, [
974
+ T("span", null, R(e.messages.frozenColumns), 1),
975
+ T("input", {
976
+ class: "mrp-frozen-count",
977
+ type: "number",
978
+ min: "0",
979
+ max: "20",
980
+ value: e.interaction.frozenColumns ?? 0,
981
+ disabled: e.busy,
982
+ onChange: u[2] || (u[2] = (f) => o.$emit("interaction", { frozenColumns: Math.max(0, Math.min(20, Number(f.target.value) || 0)) }))
983
+ }, null, 40, gr)
984
+ ])
985
+ ])) : W("", !0),
986
+ (E(!0), I(me, null, ge(d.value, (f) => (E(), I("fieldset", {
987
+ key: f.label
988
+ }, [
989
+ T("legend", null, R(f.label), 1),
990
+ (E(!0), I(me, null, ge(f.tools, (m) => (E(), I("label", {
991
+ key: m.key,
992
+ class: pe(["mrp-settings-option", { "mrp-settings-unavailable": !e.available[m.key] }])
993
+ }, [
994
+ T("span", null, [
995
+ Ce(R(m.label), 1),
996
+ e.available[m.key] ? W("", !0) : (E(), I("small", hr, R(e.messages.settingsUnavailable), 1))
997
+ ]),
998
+ T("input", {
999
+ type: "checkbox",
1000
+ checked: e.enabled[m.key],
1001
+ disabled: e.busy || !e.available[m.key],
1002
+ onChange: (x) => k(x, m.key)
1003
+ }, null, 40, br)
1004
+ ], 2))), 128))
1005
+ ]))), 128)),
1006
+ e.available.editing ? (E(), I("p", yr, R(e.persistedEditing ? e.messages.editingSaved : e.messages.editingLocal), 1)) : W("", !0),
1007
+ e.available.import ? (E(), I("p", wr, R(e.messages.importLocal), 1)) : W("", !0)
1008
+ ]),
1009
+ T("footer", null, [
1010
+ T("button", {
1011
+ type: "button",
1012
+ disabled: e.busy,
1013
+ onClick: u[3] || (u[3] = (f) => o.$emit("reset"))
1014
+ }, R(e.messages.settingsReset), 9, xr)
1015
+ ])
1016
+ ], 8, ir)
1017
+ ], 32));
1018
+ }
1019
+ }), Pr = /* @__PURE__ */ ke(Er, [["__scopeId", "data-v-b0efd4aa"]]), kr = {
1020
+ class: "mrp-empty",
1021
+ role: "status"
1022
+ }, $r = { key: 0 }, Cr = /* @__PURE__ */ Pe({
1023
+ __name: "ReportEmpty",
1024
+ props: {
1025
+ title: {},
1026
+ description: {}
1027
+ },
1028
+ setup(e) {
1029
+ return (t, a) => (E(), I("div", kr, [
1030
+ a[0] || (a[0] = dn('<svg class="mrp-empty-art" viewBox="0 0 160 112" fill="none" aria-hidden="true" data-v-07e9cb82><ellipse cx="80" cy="100" rx="54" ry="7" fill="currentColor" opacity=".05" data-v-07e9cb82></ellipse><rect x="34" y="15" width="92" height="78" rx="9" fill="currentColor" opacity=".04" data-v-07e9cb82></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-07e9cb82></rect><path d="M55 27H105M55 42H105M55 57H85M55 72H76M71 27V72M89 27V57" stroke="currentColor" stroke-opacity=".15" stroke-width="1.5" stroke-linecap="round" data-v-07e9cb82></path><circle cx="112" cy="76" r="16" fill="var(--mrp-toolbar-bg, #fff)" stroke="currentColor" stroke-opacity=".35" stroke-width="2" data-v-07e9cb82></circle><path d="M124 88L137 101M106 76H118" stroke="currentColor" stroke-opacity=".45" stroke-width="3" stroke-linecap="round" data-v-07e9cb82></path><circle cx="27" cy="38" r="3" fill="currentColor" opacity=".12" data-v-07e9cb82></circle><circle cx="132" cy="24" r="2" fill="currentColor" opacity=".2" data-v-07e9cb82></circle></svg>', 1)),
1031
+ T("strong", null, R(e.title), 1),
1032
+ e.description ? (E(), I("p", $r, R(e.description), 1)) : W("", !0)
1033
+ ]));
1034
+ }
1035
+ }), rn = /* @__PURE__ */ ke(Cr, [["__scopeId", "data-v-07e9cb82"]]);
1036
+ class ce extends Error {
1037
+ constructor(t, a, n) {
1038
+ super(a), this.name = "MachReportError", this.code = t, this.cause = n;
1039
+ }
1040
+ }
1041
+ function Ir(e) {
1042
+ return e instanceof ce ? { code: e.code, cause: e.cause } : { code: "render", cause: e };
1043
+ }
1044
+ function Rr(e) {
1045
+ if (e instanceof ce) return e;
1046
+ if (e instanceof ra) return new ce("param", e.message, e);
1047
+ if (e instanceof oa) return new ce(e.code, e.message, e.cause);
1048
+ if (e instanceof Error) {
1049
+ const t = { params: "param", config: "config", validate: "validate", fetch: "fetch" }, a = e.code;
1050
+ if (typeof a == "string" && Object.prototype.hasOwnProperty.call(t, a)) return new ce(t[a], e.message, e);
1051
+ }
1052
+ return new ce("fetch", e instanceof Error ? e.message : "预览加载失败", e);
1053
+ }
1054
+ let Sr = 0;
1055
+ function Mr() {
1056
+ return `mrp-params-${++Sr}`;
1057
+ }
1058
+ function En(e, t, a) {
1059
+ const n = (Array.isArray(t) ? t.find((r) => r?.field === e.field)?.label : void 0) ?? e.field;
1060
+ return e.code === "required" ? a.paramRequired.replace("{label}", n) : (a.paramInvalid ?? "{label}:{message}").replace("{label}", n).replace("{message}", e.message);
1061
+ }
1062
+ function Fr(e) {
1063
+ const t = U({}), a = U(!1);
1064
+ function n() {
1065
+ const d = {};
1066
+ for (const k of Array.isArray(e.defs.value) ? e.defs.value : [])
1067
+ typeof k?.field == "string" && Object.defineProperty(d, k.field, { value: e.params()[k.field] ?? k.defaultValue ?? "", writable: !0, enumerable: !0, configurable: !0 });
1068
+ t.value = d, a.value = !1;
1069
+ }
1070
+ n(), ne(e.defs, n), ne(e.reportIds, n), ne(() => JSON.stringify(e.params()), n);
1071
+ const r = z(() => hn(e.defs.value, { ...e.params(), ...t.value })), s = z(() => !a.value && r.value.issues.length > 0 && r.value.issues.every((d) => d.code === "required"));
1072
+ function l() {
1073
+ const d = r.value;
1074
+ if (!d.ok) {
1075
+ const o = d.issues[0];
1076
+ return { quiet: s.value, error: new ce(o.code === "definition" ? "config" : "param", En(o, e.defs.value, e.messages()), { issues: d.issues }) };
1077
+ }
1078
+ const k = { ...d.values }, g = new Set(e.defs.value.filter((o) => o.defaultValue !== void 0).map((o) => o.field));
1079
+ for (const [o, u] of Object.entries(k)) u === "" && !g.has(o) && delete k[o];
1080
+ return { params: k, quiet: !1 };
1081
+ }
1082
+ return { values: t, attempted: a, validation: r, pendingRequired: s, reset: n, query: l };
1083
+ }
1084
+ const Tr = { class: "mrp-params-title" }, Dr = { class: "mrp-params-grid" }, Ar = ["id"], Or = {
1085
+ key: 0,
1086
+ class: "mrp-param-star"
1087
+ }, zr = ["value", "aria-labelledby", "aria-invalid", "aria-describedby", "aria-required", "onChange"], Br = ["disabled", "hidden"], Lr = ["value"], qr = ["type", "placeholder", "value", "min", "max", "step", "aria-labelledby", "aria-invalid", "aria-describedby", "aria-required", "onInput"], Wr = ["id"], Nr = { class: "mrp-params-actions" }, Hr = /* @__PURE__ */ Pe({
1088
+ __name: "ReportParamPanel",
1089
+ props: {
1090
+ defs: {},
1091
+ modelValue: {},
1092
+ messages: {},
1093
+ attempted: { type: Boolean },
1094
+ issues: {}
1095
+ },
1096
+ emits: ["update:modelValue", "query", "reset"],
1097
+ setup(e, { expose: t, emit: a }) {
1098
+ const n = e, r = a, s = U({ ...n.modelValue }), l = U(null), d = Mr();
1099
+ ne(
1100
+ () => n.modelValue,
1101
+ (m) => {
1102
+ s.value = { ...m };
1103
+ }
1104
+ );
1105
+ const k = z(() => n.issues ?? hn(n.defs, s.value).issues), g = z(
1106
+ () => (Array.isArray(n.defs) ? n.defs : []).filter((m) => m && typeof m.field == "string").map((m, x) => ({
1107
+ def: m,
1108
+ id: `${d}-${x}`,
1109
+ label: m.label ?? m.field,
1110
+ value: s.value[m.field] ?? "",
1111
+ error: n.attempted ? k.value.find((p) => p.field === m.field) : void 0
1112
+ }))
1113
+ );
1114
+ function o(m, x) {
1115
+ s.value = { ...s.value, [m]: x }, r("update:modelValue", { ...s.value });
1116
+ }
1117
+ function u(m) {
1118
+ m.isComposing || r("query");
1119
+ }
1120
+ function f() {
1121
+ l.value?.querySelector('[aria-invalid="true"]')?.focus();
1122
+ }
1123
+ return t({ focusInvalid: f }), (m, x) => (E(), I("div", {
1124
+ ref_key: "root",
1125
+ ref: l,
1126
+ class: "mrp-params"
1127
+ }, [
1128
+ T("span", Tr, R(e.messages.paramsTitle), 1),
1129
+ T("div", Dr, [
1130
+ (E(!0), I(me, null, ge(g.value, (p) => (E(), I("label", {
1131
+ key: p.id,
1132
+ class: pe(["mrp-param", { "mrp-param-missing": !!p.error }])
1133
+ }, [
1134
+ T("span", {
1135
+ id: `${p.id}-label`,
1136
+ class: "mrp-param-label"
1137
+ }, [
1138
+ Ce(R(p.label), 1),
1139
+ p.def.required ? (E(), I("i", Or, "*")) : W("", !0)
1140
+ ], 8, Ar),
1141
+ (p.def.type ?? "text") === "select" ? (E(), I("select", {
1142
+ key: 0,
1143
+ class: "mrp-param-input",
1144
+ value: p.value,
1145
+ "aria-labelledby": `${p.id}-label`,
1146
+ "aria-invalid": p.error ? !0 : void 0,
1147
+ "aria-describedby": p.error ? `${p.id}-error` : void 0,
1148
+ "aria-required": p.def.required || void 0,
1149
+ onChange: (P) => o(p.def.field, P.target.value),
1150
+ onKeydown: nn(u, ["enter"])
1151
+ }, [
1152
+ T("option", {
1153
+ value: "",
1154
+ disabled: p.def.required,
1155
+ hidden: p.def.required
1156
+ }, R(p.def.placeholder ?? (e.messages.paramSelectPlaceholder ?? "请选择{label}").replace("{label}", p.label)), 9, Br),
1157
+ (E(!0), I(me, null, ge(p.def.options ?? [], (P) => (E(), I("option", {
1158
+ key: P.value,
1159
+ value: P.value
1160
+ }, R(P.label), 9, Lr))), 128))
1161
+ ], 40, zr)) : (E(), I("input", {
1162
+ key: 1,
1163
+ class: "mrp-param-input",
1164
+ type: p.def.type === "number" ? "number" : p.def.type === "date" ? "date" : "text",
1165
+ placeholder: p.def.placeholder ?? (e.messages.paramTextPlaceholder ?? "请输入{label}").replace("{label}", p.label),
1166
+ value: p.value,
1167
+ min: p.def.min,
1168
+ max: p.def.max,
1169
+ step: p.def.type === "number" ? "any" : void 0,
1170
+ "aria-labelledby": `${p.id}-label`,
1171
+ "aria-invalid": p.error ? !0 : void 0,
1172
+ "aria-describedby": p.error ? `${p.id}-error` : void 0,
1173
+ "aria-required": p.def.required || void 0,
1174
+ onInput: (P) => o(p.def.field, P.target.value),
1175
+ onKeydown: nn(u, ["enter"])
1176
+ }, null, 40, qr)),
1177
+ p.error ? (E(), I("small", {
1178
+ key: 2,
1179
+ id: `${p.id}-error`,
1180
+ class: "mrp-param-error",
1181
+ role: "status"
1182
+ }, R(C(En)(p.error, e.defs, e.messages)), 9, Wr)) : W("", !0)
1183
+ ], 2))), 128))
1184
+ ]),
1185
+ T("div", Nr, [
1186
+ T("button", {
1187
+ class: "mrp-nav mrp-param-query",
1188
+ type: "button",
1189
+ onClick: x[0] || (x[0] = (p) => m.$emit("query"))
1190
+ }, R(e.messages.query), 1),
1191
+ T("button", {
1192
+ class: "mrp-nav",
1193
+ type: "button",
1194
+ onClick: x[1] || (x[1] = (p) => m.$emit("reset"))
1195
+ }, R(e.messages.reset), 1)
1196
+ ])
1197
+ ], 512));
1198
+ }
1199
+ }), jr = /* @__PURE__ */ ke(Hr, [["__scopeId", "data-v-156737bc"]]), Kr = { class: "mrp-edit-bar" }, Ur = ["disabled"], Vr = ["disabled"], Gr = { class: "mrp-changes" }, Jr = ["aria-label"], Zr = { key: 0 }, Yr = { key: 1 }, Xr = ["onClick"], Qr = ["title"], _r = ["title"], eo = ["disabled"], to = {
1200
+ key: 0,
1201
+ role: "status"
1202
+ }, no = {
1203
+ key: 1,
1204
+ role: "status"
1205
+ }, ao = {
1206
+ key: 2,
1207
+ class: "mrp-conflicts",
1208
+ open: ""
1209
+ }, ro = /* @__PURE__ */ Pe({
1210
+ __name: "ReportEditBar",
1211
+ props: {
1212
+ differences: {},
1213
+ conflicts: {},
1214
+ messages: {},
1215
+ saving: { type: Boolean },
1216
+ canUndo: { type: Boolean },
1217
+ canRedo: { type: Boolean },
1218
+ busy: { type: Boolean },
1219
+ persisted: { type: Boolean }
1220
+ },
1221
+ emits: ["undo", "redo", "restore", "locate"],
1222
+ setup(e) {
1223
+ function t(a) {
1224
+ return a.source ? `${a.source.rowKey} · ${a.source.field}` : `${a.address.pageIndex + 1} / ${a.address.rowIndex + 1}:${a.address.columnIndex + 1}`;
1225
+ }
1226
+ return (a, n) => (E(), I("div", Kr, [
1227
+ T("button", {
1228
+ type: "button",
1229
+ disabled: e.busy || e.saving || !e.canUndo,
1230
+ onClick: n[0] || (n[0] = (r) => a.$emit("undo"))
1231
+ }, R(e.messages.undo), 9, Ur),
1232
+ T("button", {
1233
+ type: "button",
1234
+ disabled: e.busy || e.saving || !e.canRedo,
1235
+ onClick: n[1] || (n[1] = (r) => a.$emit("redo"))
1236
+ }, R(e.messages.redo), 9, Vr),
1237
+ T("details", Gr, [
1238
+ T("summary", null, R(e.messages.changes) + " · " + R(e.messages.changesCount?.replace("{count}", String(e.differences.length))), 1),
1239
+ T("section", {
1240
+ "aria-label": e.messages.changes
1241
+ }, [
1242
+ e.differences.length ? (E(), I("ol", Yr, [
1243
+ (E(!0), I(me, null, ge(e.differences, (r, s) => (E(), I("li", { key: s }, [
1244
+ T("button", {
1245
+ type: "button",
1246
+ onClick: (l) => a.$emit("locate", r)
1247
+ }, R(t(r)), 9, Xr),
1248
+ T("span", null, [
1249
+ T("s", {
1250
+ title: e.messages.changesBefore
1251
+ }, R(r.previousText || "∅"), 9, Qr),
1252
+ n[3] || (n[3] = Ce(" → ", -1)),
1253
+ T("strong", {
1254
+ title: e.messages.changesAfter
1255
+ }, R(r.text || "∅"), 9, _r)
1256
+ ])
1257
+ ]))), 128))
1258
+ ])) : (E(), I("p", Zr, R(e.messages.changesEmpty), 1))
1259
+ ], 8, Jr)
1260
+ ]),
1261
+ T("button", {
1262
+ type: "button",
1263
+ disabled: e.busy || e.saving || !e.differences.length,
1264
+ onClick: n[2] || (n[2] = (r) => a.$emit("restore"))
1265
+ }, R(e.messages.restoreChanges), 9, eo),
1266
+ e.saving ? (E(), I("span", to, R(e.messages.saving), 1)) : e.differences.length && !e.conflicts.length ? (E(), I("span", no, R(e.persisted ? e.messages.editSaved : e.messages.editingLocal), 1)) : W("", !0),
1267
+ e.conflicts.length ? (E(), I("details", ao, [
1268
+ T("summary", null, R(e.messages.conflicts) + " · " + R(e.conflicts.length), 1),
1269
+ T("ul", null, [
1270
+ (E(!0), I(me, null, ge(e.conflicts, (r, s) => (E(), I("li", { key: s }, R(r.message), 1))), 128))
1271
+ ])
1272
+ ])) : W("", !0)
1273
+ ]));
1274
+ }
1275
+ }), oo = /* @__PURE__ */ ke(ro, [["__scopeId", "data-v-df1c7b86"]]), so = ["aria-label"], lo = {
1276
+ key: 0,
1277
+ class: "mrp-section-tabs"
1278
+ }, io = ["disabled", "onClick"], uo = ["aria-label", "placeholder", "disabled"], co = ["disabled"], fo = /* @__PURE__ */ Pe({
1279
+ __name: "ReportNavigation",
1280
+ props: {
1281
+ sections: {},
1282
+ currentPage: {},
1283
+ messages: {},
1284
+ busy: { type: Boolean }
1285
+ },
1286
+ emits: ["goto", "locate"],
1287
+ setup(e, { emit: t }) {
1288
+ const a = t, n = U("");
1289
+ return (r, s) => (E(), I("nav", {
1290
+ class: "mrp-section-nav",
1291
+ "aria-label": e.messages.sections
1292
+ }, [
1293
+ e.sections.length > 1 ? (E(), I("div", lo, [
1294
+ (E(!0), I(me, null, ge(e.sections, (l, d) => (E(), I("button", {
1295
+ key: d,
1296
+ type: "button",
1297
+ class: pe({ active: e.currentPage >= l.pageIndex + 1 && (!e.sections[d + 1] || e.currentPage <= e.sections[d + 1].pageIndex) }),
1298
+ disabled: e.busy,
1299
+ onClick: (k) => a("goto", l.pageIndex + 1)
1300
+ }, R(l.label), 11, io))), 128))
1301
+ ])) : W("", !0),
1302
+ T("form", {
1303
+ onSubmit: s[1] || (s[1] = vn((l) => a("locate", n.value.trim()), ["prevent"]))
1304
+ }, [
1305
+ Yn(T("input", {
1306
+ "onUpdate:modelValue": s[0] || (s[0] = (l) => n.value = l),
1307
+ type: "text",
1308
+ "aria-label": e.messages.locateField,
1309
+ placeholder: e.messages.locateFieldPlaceholder,
1310
+ disabled: e.busy
1311
+ }, null, 8, uo), [
1312
+ [Xn, n.value]
1313
+ ]),
1314
+ T("button", {
1315
+ type: "submit",
1316
+ disabled: e.busy || !n.value.trim()
1317
+ }, R(e.messages.locateField), 9, co)
1318
+ ], 32)
1319
+ ], 8, so));
1320
+ }
1321
+ }), mo = /* @__PURE__ */ ke(fo, [["__scopeId", "data-v-ef8815ec"]]), vo = { class: "mrp-import-summary" }, po = { key: 0 }, go = { key: 0 }, ho = /* @__PURE__ */ Pe({
1322
+ __name: "ReportImportSummary",
1323
+ props: {
1324
+ result: {},
1325
+ messages: {}
1326
+ },
1327
+ setup(e) {
1328
+ return (t, a) => (E(), I("details", vo, [
1329
+ T("summary", null, [
1330
+ Ce(R(e.messages.importSummary) + " · " + R(e.messages.importPreserved?.replace("{sheets}", String(e.result.sheets.length))) + " ", 1),
1331
+ e.result.warnings.length ? (E(), I("span", po, " · " + R(e.result.warnings.length) + " " + R(e.messages.importWarnings), 1)) : W("", !0)
1332
+ ]),
1333
+ T("p", null, R(e.messages.importReadOnly), 1),
1334
+ T("ul", null, [
1335
+ (E(!0), I(me, null, ge(e.result.sheets, (n) => (E(), I("li", {
1336
+ key: n.index
1337
+ }, R(n.name) + " · " + R(n.range) + " · " + R(n.rowCount) + " × " + R(n.columnCount), 1))), 128))
1338
+ ]),
1339
+ e.result.warnings.length ? (E(), I("ul", go, [
1340
+ (E(!0), I(me, null, ge(e.result.warnings, (n, r) => (E(), I("li", { key: r }, R(n), 1))), 128))
1341
+ ])) : W("", !0)
1342
+ ]));
1343
+ }
1344
+ }), bo = /* @__PURE__ */ ke(ho, [["__scopeId", "data-v-54f275e8"]]), yo = {
1345
+ title: "报表预览",
1346
+ prevPage: "‹ 上一页",
1347
+ nextPage: "下一页 ›",
1348
+ pageInfo: "{cur} / {total}",
1349
+ fitWidth: "适宽",
1350
+ exportHtml: "导出 HTML",
1351
+ exportPdf: "导出 PDF",
1352
+ exportExcel: "导出 Excel",
1353
+ exportImage: "导出图片",
1354
+ exportWord: "导出 Word",
1355
+ exporting: "正在生成 {format}…",
1356
+ print: "打印",
1357
+ pdfWindow: "PDF 窗口",
1358
+ loading: "报表渲染中…",
1359
+ empty: "暂无预览数据",
1360
+ errorPrefix: "",
1361
+ retry: "重试",
1362
+ pdfFontUnavailable: "PDF 字体尚未就绪,请联系管理员检查字体配置;预览及其它导出仍可使用。",
1363
+ searchPlaceholder: "搜索报表内容",
1364
+ matchInfo: "{cur}/{total}",
1365
+ prevMatch: "‹",
1366
+ nextMatch: "›",
1367
+ thumbnails: "缩略图",
1368
+ paramsTitle: "查询条件",
1369
+ query: "查 询",
1370
+ reset: "重 置",
1371
+ paramRequired: "请填写{label}",
1372
+ paramInvalid: "{label}:{message}",
1373
+ paramPrompt: "请先完善查询条件",
1374
+ paramPromptDescription: "填写必填条件后点击查询,即可生成报表。",
1375
+ paramSelectPlaceholder: "请选择{label}",
1376
+ paramTextPlaceholder: "请输入{label}",
1377
+ searching: "搜索中…",
1378
+ importExcel: "导入 Excel 模板",
1379
+ importing: "正在导入 Excel…",
1380
+ editCell: "编辑单元格",
1381
+ editingHint: "双击单元格编辑 · Enter 确认 · Esc 取消",
1382
+ saving: "正在保存修改…",
1383
+ editInvalidNumber: "请输入有效数字;清空表示无值",
1384
+ editInvalidBoolean: "请输入 true / false、是 / 否或 1 / 0",
1385
+ editConflict: "该单元格已变化,请重新打开编辑",
1386
+ settings: "设置",
1387
+ settingsDisplay: "阅读工具",
1388
+ settingsExport: "导出与打印",
1389
+ settingsData: "数据操作",
1390
+ settingsUnavailable: "需由接入方配置启用",
1391
+ settingsReset: "恢复默认",
1392
+ settingsClose: "关闭设置",
1393
+ search: "内容搜索",
1394
+ closeSearch: "关闭搜索",
1395
+ prevSearchMatch: "上一个匹配",
1396
+ nextSearchMatch: "下一个匹配",
1397
+ zoom: "缩放工具",
1398
+ settingsLocal: "按需启用工具,仅作用于当前预览。",
1399
+ editingLocal: "修改为本地草稿;不会自动写入业务数据库。",
1400
+ editingSaved: "修改将通过接入方配置的保存回调提交。",
1401
+ importLocal: "导入仅生成本地预览,不自动替换业务数据。",
1402
+ emptyDescription: "当前查询没有明细,请调整查询条件后重试。",
1403
+ undo: "撤销",
1404
+ redo: "重做",
1405
+ restoreChanges: "恢复来源值",
1406
+ changes: "修改明细",
1407
+ changesCount: "{count} 处修改",
1408
+ changesEmpty: "尚无修改",
1409
+ changesBefore: "来源值",
1410
+ changesAfter: "当前值",
1411
+ editAtomicRequired: "批量保存需要接入方提供原子 saveBatch 回调;本次未写入任何单元格。",
1412
+ clipboardLimit: "单次最多粘贴 10000 个单元格,请分批处理。",
1413
+ preferencesError: "偏好存储不可用,设置仍在当前预览中生效。",
1414
+ freezeHeaders: "冻结表头",
1415
+ frozenColumns: "冻结前列",
1416
+ sections: "工作表与章节",
1417
+ locateField: "定位字段",
1418
+ locateFieldPlaceholder: "输入字段标识,Enter 定位",
1419
+ locateFieldMissing: "未找到该字段,请核对字段标识。",
1420
+ importSummary: "Excel 导入摘要",
1421
+ importPreserved: "已导入 {sheets} 个工作表,保留内容、合并和样式。",
1422
+ importWarnings: "兼容性提示",
1423
+ importReadOnly: "公式、日期及受保护单元格保持只读;公式不重算。",
1424
+ conflicts: "保存冲突",
1425
+ editReadOnly: "选区包含只读或无权限单元格,本次修改未应用。",
1426
+ editMissing: "选区超出报表范围或缺少业务来源,请重新选择。",
1427
+ editDuplicate: "选区包含同一业务字段的重复单元格,请缩小选区。",
1428
+ clipboardInvalid: "剪贴板内容无法识别,请使用矩形表格文本重新粘贴。",
1429
+ editSaved: "修改已通过保存回调确认",
1430
+ settingsPanes: "冻结窗格"
1431
+ }, wo = {
1432
+ shellBg: "#525659",
1433
+ shellFg: "#e8e8e8",
1434
+ toolbarBg: "#323639",
1435
+ toolbarBorder: "#22252a",
1436
+ toolbarFg: "#e8e8e8",
1437
+ btnFg: "#cfcfcf",
1438
+ btnBorder: "#4a4d52",
1439
+ btnHoverBg: "#414549",
1440
+ btnHoverFg: "#ffffff",
1441
+ btnActiveBg: "#2d5fb8"
1442
+ };
1443
+ function xo(e = {}) {
1444
+ return { ...e, defaults: e.defaults ?? {}, presets: e.presets ?? {} };
1445
+ }
1446
+ function us(e) {
1447
+ return e;
1448
+ }
1449
+ const xe = {
1450
+ showExport: !0,
1451
+ showPrint: !0,
1452
+ showPdfWindow: !0,
1453
+ showSettings: !0,
1454
+ showParams: !0,
1455
+ gapPx: 18,
1456
+ pdfFontUrl: "/simhei.ttf",
1457
+ logger: console
1458
+ }, cs = { warn: () => {
1459
+ }, info: () => {
1460
+ } };
1461
+ function tt(e, t) {
1462
+ return {
1463
+ ...e,
1464
+ ...t,
1465
+ theme: { ...e?.theme, ...t?.theme },
1466
+ messages: { ...e?.messages, ...t?.messages },
1467
+ preview: { ...e?.preview, ...t?.preview },
1468
+ xlsx: { ...e?.xlsx, ...t?.xlsx },
1469
+ toolbar: { ...e?.toolbar, ...t?.toolbar },
1470
+ interaction: { ...e?.interaction, ...t?.interaction }
1471
+ };
1472
+ }
1473
+ function Eo(e) {
1474
+ return {
1475
+ showExport: e.showExport ?? xe.showExport,
1476
+ showPrint: e.showPrint ?? xe.showPrint,
1477
+ showPdfWindow: e.showPdfWindow ?? xe.showPdfWindow,
1478
+ showSettings: e.showSettings ?? xe.showSettings,
1479
+ showParams: e.showParams ?? xe.showParams,
1480
+ gapPx: e.gapPx ?? xe.gapPx
1481
+ };
1482
+ }
1483
+ function Po(e, t) {
1484
+ const a = t ? e?.presets?.[t] : e?.defaultPreset ? e?.presets?.[e.defaultPreset] : void 0, n = tt(e?.defaults, a);
1485
+ return {
1486
+ ...Eo(n),
1487
+ pdfFontUrl: n.pdfFontUrl ?? xe.pdfFontUrl,
1488
+ theme: { ...wo, ...n.theme },
1489
+ messages: { ...yo, ...n.messages },
1490
+ logger: n.logger ?? xe.logger,
1491
+ preview: {
1492
+ overscanPages: on(n.preview?.overscanPages, 1, 10, !0),
1493
+ searchDebounceMs: on(n.preview?.searchDebounceMs, 200, 2e3)
1494
+ },
1495
+ xlsx: { ...n.xlsx },
1496
+ editable: n.editable ?? !1,
1497
+ excelImport: n.excelImport ?? !1,
1498
+ toolbar: { ...n.toolbar },
1499
+ interaction: { ...n.interaction },
1500
+ preferences: n.preferences,
1501
+ assets: n.assets
1502
+ };
1503
+ }
1504
+ function on(e, t, a, n = !1) {
1505
+ if (e == null || !Number.isFinite(e)) return t;
1506
+ const r = Math.max(0, Math.min(a, e));
1507
+ return n ? Math.floor(r) : r;
1508
+ }
1509
+ function ko(e) {
1510
+ const t = {};
1511
+ return e.shellBg != null && (t["--mrp-shell-bg"] = e.shellBg), e.shellFg != null && (t["--mrp-shell-fg"] = e.shellFg), e.toolbarBg != null && (t["--mrp-toolbar-bg"] = e.toolbarBg), e.toolbarBorder != null && (t["--mrp-toolbar-border"] = e.toolbarBorder), e.toolbarFg != null && (t["--mrp-toolbar-fg"] = e.toolbarFg), e.btnFg != null && (t["--mrp-btn-fg"] = e.btnFg), e.btnBorder != null && (t["--mrp-btn-border"] = e.btnBorder), e.btnHoverBg != null && (t["--mrp-btn-hover-bg"] = e.btnHoverBg), e.btnHoverFg != null && (t["--mrp-btn-hover-fg"] = e.btnHoverFg), e.btnActiveBg != null && (t["--mrp-btn-active-bg"] = e.btnActiveBg), t;
1512
+ }
1513
+ function ds(e) {
1514
+ const t = at(Ft, null), a = z(() => {
1515
+ const n = t?.value ?? null, r = "defaults" in e || "presets" in e || "defaultPreset" in e ? xo(e) : { defaults: e, presets: {} };
1516
+ if (!n) return r;
1517
+ const s = { ...n.presets, ...r.presets };
1518
+ for (const l of Object.keys(s))
1519
+ s[l] = tt(
1520
+ tt(n.presets[l], r.defaults),
1521
+ r.presets[l]
1522
+ );
1523
+ return {
1524
+ defaults: tt(n.defaults, r.defaults),
1525
+ presets: s,
1526
+ defaultPreset: r.defaultPreset ?? n.defaultPreset
1527
+ };
1528
+ });
1529
+ pn(Ft, a);
1530
+ }
1531
+ function $o() {
1532
+ return at(Ft, z(() => null));
1533
+ }
1534
+ const sn = /* @__PURE__ */ new Map(), Te = /* @__PURE__ */ new Map(), Co = 15e3;
1535
+ function Tt(e, t) {
1536
+ return Object.assign(new Error(e), { cause: t });
1537
+ }
1538
+ function He(e, t) {
1539
+ return `PDF 字体 ${JSON.stringify(e)}:${t}。请部署支持报表文字的字体文件,并将 pdfFontUrl 配置为可访问的字体 URL;西文报表可设为空串`;
1540
+ }
1541
+ function st(e) {
1542
+ if (e?.reason instanceof Error && e.reason.name === "AbortError") return e.reason;
1543
+ const t = Tt("PDF 字体检查已取消", e?.reason);
1544
+ return t.name = "AbortError", t;
1545
+ }
1546
+ async function Io(e, t) {
1547
+ let a = !1;
1548
+ const n = setTimeout(() => {
1549
+ a = !0, t.abort();
1550
+ }, Co);
1551
+ try {
1552
+ const r = await fetch(e, { method: "HEAD", signal: t.signal });
1553
+ if (t.signal.aborted) throw st(t.signal);
1554
+ if (r.status === 405 || r.status === 501 || r.type === "opaque")
1555
+ return {
1556
+ status: "unverified",
1557
+ fontUrl: e,
1558
+ message: `PDF 字体 ${JSON.stringify(e)} 无法通过 HEAD 检查验证;仍可尝试导出,届时会加载并校验字体`
1559
+ };
1560
+ if (!r.ok) {
1561
+ const l = new Error(`字体请求返回 HTTP ${r.status}`);
1562
+ return { status: "error", fontUrl: e, message: He(e, l.message), cause: l };
1563
+ }
1564
+ const s = r.headers.get("content-type") ?? "";
1565
+ if (/text\/html|application\/xhtml\+xml/i.test(s)) {
1566
+ const l = new Error("字体 URL 返回 HTML 页面(可能是 SPA 路由回退),不是字体文件");
1567
+ return { status: "error", fontUrl: e, message: He(e, l.message), cause: l };
1568
+ }
1569
+ if (/^text\//i.test(s) || /(?:\/|\+)json(?:\s*;|$)/i.test(s)) {
1570
+ const l = new Error(`字体 URL 返回 ${s} 文本响应,不是字体文件`);
1571
+ return { status: "error", fontUrl: e, message: He(e, l.message), cause: l };
1572
+ }
1573
+ return {
1574
+ status: "available",
1575
+ fontUrl: e,
1576
+ message: "PDF 字体资源可达;文字覆盖范围将在实际导出时校验"
1577
+ };
1578
+ } catch (r) {
1579
+ if (t.signal.aborted && !a) throw st(t.signal);
1580
+ return {
1581
+ status: "error",
1582
+ fontUrl: e,
1583
+ message: He(e, a ? "字体检查超时,请检查网络或字体服务" : "字体检查失败,请检查网络、字体服务或跨域访问配置"),
1584
+ cause: r
1585
+ };
1586
+ } finally {
1587
+ clearTimeout(n);
1588
+ }
1589
+ }
1590
+ function Ro(e, t) {
1591
+ if (t?.aborted) return Promise.reject(st(t));
1592
+ if (!e)
1593
+ return Promise.resolve({ status: "disabled", fontUrl: e, message: "已停用自定义 PDF 字体;内置字体用于西文,其他文字会在导出时校验" });
1594
+ const a = sn.get(e);
1595
+ if (a) return Promise.resolve(a);
1596
+ let n = Te.get(e);
1597
+ if (!n) {
1598
+ const s = new AbortController();
1599
+ n = { controller: s, promise: Io(e, s), subscribers: 0 };
1600
+ const l = n;
1601
+ Te.set(e, l), l.promise = l.promise.then((d) => (!s.signal.aborted && d.status === "available" && sn.set(e, d), d)).finally(() => {
1602
+ Te.get(e) === l && Te.delete(e);
1603
+ });
1604
+ }
1605
+ const r = n;
1606
+ return r.subscribers++, new Promise((s, l) => {
1607
+ let d = !1;
1608
+ const k = () => d ? !1 : (d = !0, r.subscribers--, t?.removeEventListener("abort", g), !0), g = () => {
1609
+ k() && (r.subscribers === 0 && (Te.get(e) === r && Te.delete(e), r.controller.abort()), l(st(t)));
1610
+ };
1611
+ t?.addEventListener("abort", g, { once: !0 }), r.promise.then(
1612
+ (o) => {
1613
+ k() && s(o);
1614
+ },
1615
+ (o) => {
1616
+ k() && l(o);
1617
+ }
1618
+ ), t?.aborted && g();
1619
+ });
1620
+ }
1621
+ function So(e = { fontUrl: "/simhei.ttf" }) {
1622
+ let t = null;
1623
+ const a = async (n, r) => {
1624
+ t || (t = await import("@agile-team/mach-report/pdf"));
1625
+ let s = null;
1626
+ if (e.fontUrl)
1627
+ try {
1628
+ if (s = await t.loadFontWithCache(e.fontUrl, { strict: !0 }), !s?.byteLength) throw new Error("字体文件为空或加载失败");
1629
+ } catch (u) {
1630
+ const f = u instanceof Error ? u.message : String(u);
1631
+ throw Tt(He(e.fontUrl, f), u);
1632
+ }
1633
+ let l;
1634
+ try {
1635
+ l = await t.renderPlanToPdf(n, s ? { customFontBytes: s } : {});
1636
+ } catch (u) {
1637
+ if (!s) throw u;
1638
+ const f = u instanceof Error ? u.message : String(u);
1639
+ throw Tt(`PDF 生成失败:${f}。当前字体 URL 为 ${JSON.stringify(e.fontUrl)};请确认该文件是有效字体,或重新配置 pdfFontUrl`, u);
1640
+ }
1641
+ const { bytes: d, unsupportedTextCount: k, pageErrors: g, fidelityWarnings: o } = l;
1642
+ if (k > 0)
1643
+ throw new Error(`PDF 中有 ${k} 行文字无法编码;请部署支持所用文字的字体并配置 pdfFontUrl`);
1644
+ if (g.length > 0)
1645
+ throw new Error(`PDF 有 ${g.length} 页渲染失败:${g[0]}`);
1646
+ return o.length > 0 && r?.(`PDF 有 ${o.length} 处版式降级:${o.slice(0, 2).join(";")}`), d;
1647
+ };
1648
+ return a.checkFont = (n) => Ro(e.fontUrl, n), a;
1649
+ }
1650
+ function de(e) {
1651
+ return JSON.parse(JSON.stringify(e));
1652
+ }
1653
+ class Mo extends Error {
1654
+ constructor(t) {
1655
+ super(t.map((a) => a.message).join(";")), this.conflicts = t, this.name = "ReportEditConflictError";
1656
+ }
1657
+ }
1658
+ function Fo() {
1659
+ return globalThis.crypto?.randomUUID?.() ?? `mr-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
1660
+ }
1661
+ function To(e) {
1662
+ const t = fe([]), a = fe([]), n = fe([]), r = fe([]), s = fe(!1), l = z(() => sa(t.value)), d = z(() => !!e.options.value && !s.value && !e.blocked() && a.value.length > 0), k = z(() => !!e.options.value && !s.value && !e.blocked() && n.value.length > 0);
1663
+ let g = null, o = null, u = 0, f = null;
1664
+ function m() {
1665
+ g?.abort(), g = null, s.value = !1, o = null;
1666
+ }
1667
+ function x() {
1668
+ u++, m(), f = null, t.value = [], a.value = [], n.value = [], r.value = [];
1669
+ }
1670
+ function p() {
1671
+ const M = e.options.value;
1672
+ return M ? typeof M == "object" ? M : {} : null;
1673
+ }
1674
+ function P(M, F, A) {
1675
+ if (!e.options.value || e.blocked()) throw new Ee("readonly");
1676
+ const G = Mt(M);
1677
+ for (const Z of F.edits) {
1678
+ const X = G(Z.address);
1679
+ if (!X?.editable || A.canEdit?.(X) === !1) throw new Ee("readonly");
1680
+ if (A.requireSource && !X.source) throw new Ee("missing");
1681
+ }
1682
+ }
1683
+ async function V(M, F, A) {
1684
+ if (F.saveBatch) return F.saveBatch(de(M), A);
1685
+ if (F.save && M.edits.length > 1) throw new Ee("atomic");
1686
+ if (M.edits[0]) return F.save?.(de(M.edits[0]), A);
1687
+ }
1688
+ async function D(M, F, A) {
1689
+ for (const G of M.edits) {
1690
+ const Z = await F.validate?.(de(G), A);
1691
+ if (Z) throw new Error(Z);
1692
+ if (A.signal.aborted) return;
1693
+ }
1694
+ }
1695
+ function c(M, F, A, G) {
1696
+ e.plan.value = ia(ua(M, F), F, A), t.value = [...t.value, ...F.edits], G === "edit" && (a.value = [...a.value, F.edits], n.value = []), r.value = [], f = null;
1697
+ const Z = u;
1698
+ for (const X of F.edits) {
1699
+ if (u !== Z) break;
1700
+ e.onChange(de(X));
1701
+ }
1702
+ }
1703
+ async function v(M, F) {
1704
+ const A = e.plan.value, G = p();
1705
+ if (!A || !G || e.blocked()) return !1;
1706
+ const Z = new AbortController(), X = u;
1707
+ g = Z, s.value = !0;
1708
+ const h = () => g === Z && !Z.signal.aborted && e.plan.value === A && e.options.value !== !1;
1709
+ try {
1710
+ const b = la(A, M, Fo());
1711
+ if (b.edits = b.edits.filter((j) => !Object.is(j.previousValue, j.value)), !b.edits.length) return !0;
1712
+ const N = JSON.stringify([F, b.edits]);
1713
+ f?.plan === A && f.signature === N ? b.requestId = f.requestId : f = { plan: A, signature: N, requestId: b.requestId }, P(A, b, G);
1714
+ const H = { signal: Z.signal, requestId: b.requestId, action: F };
1715
+ if (await D(b, G, H), !h()) return !1;
1716
+ P(A, b, G);
1717
+ const J = await V(b, G, H);
1718
+ if (!h()) return !1;
1719
+ if (J?.conflicts?.length)
1720
+ throw r.value = de(J.conflicts), new Mo(J.conflicts);
1721
+ return P(A, b, G), c(A, b, J, F), X === u;
1722
+ } catch (b) {
1723
+ return h() && e.onError(e.errorMessage?.(b) ?? (b instanceof Error ? b.message : "Cell edit failed"), b), !1;
1724
+ } finally {
1725
+ g === Z && (g = null, s.value = !1);
1726
+ }
1727
+ }
1728
+ async function y(M, F = "edit") {
1729
+ if (o) return o;
1730
+ const A = v(M, F);
1731
+ o = A;
1732
+ const G = await A;
1733
+ return o === A && (o = null), G;
1734
+ }
1735
+ async function $() {
1736
+ const M = u, F = a.value[a.value.length - 1];
1737
+ return !F || s.value || !await y(F.map((A) => ({ address: A.address, value: A.previousValue })), "undo") || M !== u ? !1 : (a.value = a.value.slice(0, -1), n.value = [...n.value, F], !0);
1738
+ }
1739
+ async function O() {
1740
+ const M = u, F = n.value[n.value.length - 1];
1741
+ return !F || s.value || !await y(F.map((A) => ({ address: A.address, value: A.value })), "redo") || M !== u ? !1 : (n.value = n.value.slice(0, -1), a.value = [...a.value, F], !0);
1742
+ }
1743
+ async function B() {
1744
+ const M = u;
1745
+ return !l.value.length || s.value || !await y(l.value.map((F) => ({ address: F.address, value: F.previousValue })), "restore") || M !== u ? !1 : (a.value = [], n.value = [], !0);
1746
+ }
1747
+ return { changes: t, differences: l, conflicts: r, saving: s, canUndo: d, canRedo: k, apply: y, undo: $, redo: O, restore: B, cancel: m, reset: x };
1748
+ }
1749
+ function nt(e) {
1750
+ const t = e.closest(".mrp-page-holder"), a = e.closest("[data-mr-component-index]");
1751
+ if (!t || !a) return null;
1752
+ const n = {
1753
+ pageIndex: Number(t.dataset.page) - 1,
1754
+ componentIndex: Number(a.dataset.mrComponentIndex),
1755
+ rowIndex: Number(e.dataset.mrRowIndex),
1756
+ columnIndex: Number(e.dataset.mrColumnIndex)
1757
+ };
1758
+ return Object.values(n).every((r) => Number.isInteger(r) && r >= 0) ? n : null;
1759
+ }
1760
+ function Do(e, t, a) {
1761
+ const n = e.ownerDocument.createElement("textarea");
1762
+ return n.className = "mrp-cell-editor", n.setAttribute("aria-label", t), n.value = a == null ? "" : String(a), n.style.cssText = "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 #2563eb;outline:none;background:#fff;color:#111;font:inherit;line-height:1.25;white-space:pre-wrap;", e.appendChild(n), n;
1763
+ }
1764
+ function Ao(e) {
1765
+ const t = fe(null), a = To(e), { saving: n, changes: r } = a;
1766
+ let s = null;
1767
+ function l() {
1768
+ const x = t.value;
1769
+ t.value = null, a.cancel(), s = null, x?.input.remove();
1770
+ }
1771
+ function d() {
1772
+ l(), a.reset();
1773
+ }
1774
+ function k(x) {
1775
+ return t.value === x && e.plan.value === x.plan;
1776
+ }
1777
+ async function g(x) {
1778
+ return await a.apply([{ address: x.address, value: x.input.value }]) ? (t.value = null, x.input.remove(), !0) : (t.value === x && (x.input.disabled = !1, x.input.setAttribute("aria-invalid", "true"), x.input.focus()), !1);
1779
+ }
1780
+ async function o() {
1781
+ if (s) return s;
1782
+ const x = t.value;
1783
+ if (!x) return !0;
1784
+ if (!k(x))
1785
+ return l(), !1;
1786
+ x.input.disabled = !0;
1787
+ const p = g(x);
1788
+ s = p;
1789
+ const P = await p;
1790
+ return s === p && (s = null), P;
1791
+ }
1792
+ function u(x) {
1793
+ if (x.stopPropagation(), !x.isComposing && (x.key === "Escape" && (x.preventDefault(), l()), x.key === "Enter" && !x.shiftKey || x.key === "Tab")) {
1794
+ x.preventDefault();
1795
+ const p = t.value?.address;
1796
+ o().then((P) => {
1797
+ P && p && e.onNavigate?.(p, x.key, x.shiftKey);
1798
+ });
1799
+ }
1800
+ }
1801
+ async function f(x) {
1802
+ if (!e.options.value || e.blocked() || !await o() || !x.isConnected) return;
1803
+ const p = e.plan.value, P = nt(x);
1804
+ if (!p || !P || !e.options.value || e.blocked()) return;
1805
+ const V = typeof e.options.value == "object" ? e.options.value : {};
1806
+ try {
1807
+ const D = _e(p, P);
1808
+ if (!D?.editable || V.canEdit?.(D) === !1) return;
1809
+ const c = Do(x, e.label(), D.value);
1810
+ t.value = { plan: p, address: P, input: c }, c.addEventListener("keydown", u), c.addEventListener("blur", () => {
1811
+ n.value || o();
1812
+ }), c.focus(), c.select();
1813
+ } catch (D) {
1814
+ e.onError(D instanceof Error ? D.message : "无法编辑单元格", D);
1815
+ }
1816
+ }
1817
+ async function m(x) {
1818
+ const p = x.target;
1819
+ if (!(p instanceof Element) || p.closest(".mrp-cell-editor")) return;
1820
+ const P = p.closest("td[data-mr-row-index]");
1821
+ P && await f(P);
1822
+ }
1823
+ return ne(e.options, (x, p) => {
1824
+ (!x || x !== p) && l();
1825
+ }, { flush: "sync" }), ne(e.plan, () => {
1826
+ t.value && e.plan.value !== t.value.plan && (t.value.input.remove(), t.value = null);
1827
+ }, { flush: "sync" }), Ie(d), {
1828
+ ...a,
1829
+ active: t,
1830
+ saving: n,
1831
+ changes: r,
1832
+ cancel: l,
1833
+ reset: d,
1834
+ commit: o,
1835
+ onDoubleClick: m,
1836
+ editCell: f,
1837
+ getChanges: () => de(r.value)
1838
+ };
1839
+ }
1840
+ const Dt = ["html", "pdf", "xlsx", "png", "word"], ln = ["search", "thumbnails", "zoom", ...Dt, "print", "pdfWindow", "editing", "import"];
1841
+ function fs(e) {
1842
+ return {
1843
+ load: (t) => JSON.parse(e.getItem(t) ?? "null"),
1844
+ save: (t, a) => e.setItem(t, JSON.stringify(a)),
1845
+ remove: (t) => e.removeItem(t)
1846
+ };
1847
+ }
1848
+ function Oo(e, t, a, n) {
1849
+ const r = U({});
1850
+ let s = 0, l = 0, d = Promise.resolve();
1851
+ const k = z(() => Object.fromEntries(ln.map((f) => [
1852
+ f,
1853
+ e.value[f] && (r.value[f] ?? t.value[f] ?? !0)
1854
+ ])));
1855
+ function g(f, m) {
1856
+ e.value[f] && (l++, r.value = { ...r.value, [f]: m }, o());
1857
+ }
1858
+ function o() {
1859
+ const f = a?.value;
1860
+ if (!f) return;
1861
+ const m = { ...r.value };
1862
+ d = d.then(() => f.adapter.save(f.key, m)).catch((x) => {
1863
+ n?.(x);
1864
+ });
1865
+ }
1866
+ function u() {
1867
+ l++, r.value = {}, o();
1868
+ }
1869
+ return a && ne(a, async (f) => {
1870
+ const m = ++s, x = l;
1871
+ if (r.value = {}, !!f)
1872
+ try {
1873
+ const p = await f.adapter.load(f.key);
1874
+ if (m !== s || x !== l || !p || typeof p != "object") return;
1875
+ r.value = Object.fromEntries(ln.flatMap((P) => typeof p[P] == "boolean" ? [[P, p[P]]] : []));
1876
+ } catch (p) {
1877
+ m === s && n?.(p);
1878
+ }
1879
+ }, { immediate: !0 }), Ie(() => {
1880
+ s++;
1881
+ }), { enabled: k, setEnabled: g, reset: u };
1882
+ }
1883
+ function Pn(e) {
1884
+ return e.table.role === "header" ? -Math.max(1, e.grid?.cells.length ?? 1) : e.table.rowIndex;
1885
+ }
1886
+ function ve(e, t, a = t) {
1887
+ const n = e.pages[t.pageIndex]?.components[t.componentIndex], r = n?.table, s = e.pages[a.pageIndex]?.components[a.componentIndex]?.table;
1888
+ return r && s && r.id === s.id ? {
1889
+ grid: r.id,
1890
+ row: Pn(n) + t.rowIndex,
1891
+ column: s.columnKeys.indexOf(r.columnKeys[t.columnIndex] ?? "")
1892
+ } : { grid: `${t.pageIndex}:${t.componentIndex}`, row: t.rowIndex, column: t.columnIndex };
1893
+ }
1894
+ function un(e, t) {
1895
+ const a = e.pages[t.pageIndex]?.components[t.componentIndex]?.table;
1896
+ if (!a) return (r, s) => ({ ...t, rowIndex: r, columnIndex: s });
1897
+ const n = /* @__PURE__ */ new Map();
1898
+ return e.pages.forEach((r, s) => r.components.forEach((l, d) => {
1899
+ l.table?.id !== a.id || !l.grid || l.grid.cells.forEach((k, g) => {
1900
+ const o = Pn(l) + g;
1901
+ n.set(o, [...n.get(o) ?? [], { address: { pageIndex: s, componentIndex: d, rowIndex: g, columnIndex: 0 }, keys: l.table.columnKeys }]);
1902
+ });
1903
+ })), (r, s) => {
1904
+ const l = a.columnKeys[s];
1905
+ if (l === void 0) return null;
1906
+ const d = n.get(r)?.find((k) => k.keys.includes(l));
1907
+ return d ? { ...d.address, columnIndex: d.keys.indexOf(l) } : null;
1908
+ };
1909
+ }
1910
+ function zo(e, t) {
1911
+ return e.pageIndex === t.pageIndex && e.componentIndex === t.componentIndex;
1912
+ }
1913
+ function $t(e, t) {
1914
+ return zo(e, t) && e.rowIndex === t.rowIndex && e.columnIndex === t.columnIndex;
1915
+ }
1916
+ function Ct(e) {
1917
+ 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}"]`;
1918
+ }
1919
+ function Bo(e, t, a) {
1920
+ const { anchor: n, focus: r } = a, s = ve(e, n), l = ve(e, r, n), d = ve(e, t, n);
1921
+ return d.grid === s.grid && d.row >= Math.min(s.row, l.row) && d.row <= Math.max(s.row, l.row) && d.column >= Math.min(s.column, l.column) && d.column <= Math.max(s.column, l.column);
1922
+ }
1923
+ function Lo(e) {
1924
+ const t = fe(null);
1925
+ function a() {
1926
+ const c = t.value, v = e.plan.value, y = new Set(e.differences().map(($) => JSON.stringify($.address)));
1927
+ e.root.value?.querySelectorAll("td[data-mr-row-index]").forEach(($) => {
1928
+ const O = nt($);
1929
+ if (!O) return;
1930
+ const B = !!c && !!e.plan.value && Bo(e.plan.value, O, c);
1931
+ $.closest("table")?.setAttribute("role", "grid");
1932
+ const M = v?.pages[O.pageIndex]?.components[O.componentIndex]?.table;
1933
+ $.setAttribute("role", M?.role === "header" ? "columnheader" : "gridcell"), $.classList.toggle("mrp-cell-selected", B), $.classList.toggle("mrp-cell-focus", !!c && $t(O, c.focus)), $.classList.toggle("mrp-cell-modified", y.has(JSON.stringify(O))), $.setAttribute("aria-selected", String(B)), $.tabIndex = c && $t(O, c.focus) ? 0 : -1;
1934
+ });
1935
+ }
1936
+ async function n(c, v = !1) {
1937
+ if (!e.plan.value || !_e(e.plan.value, c)) return !1;
1938
+ const y = t.value, $ = v && y && ve(e.plan.value, y.anchor).grid === ve(e.plan.value, c, y.anchor).grid;
1939
+ t.value = { anchor: $ ? y.anchor : { ...c }, focus: { ...c } }, e.root.value?.querySelector(Ct(c)) || e.gotoPage(c.pageIndex + 1), await je(), a();
1940
+ const O = e.root.value?.querySelector(Ct(c));
1941
+ return O?.focus({ preventScroll: !0 }), O?.scrollIntoView?.({ block: "nearest", inline: "nearest" }), !!O;
1942
+ }
1943
+ function r(c) {
1944
+ const v = c.target;
1945
+ if (!(v instanceof Element) || v.closest("textarea,input,button,select")) return;
1946
+ const y = v.closest("td[data-mr-row-index]"), $ = y && nt(y);
1947
+ if (!$ || e.busy() || !e.plan.value || !_e(e.plan.value, $)) return;
1948
+ const O = t.value, B = c.shiftKey && O && ve(e.plan.value, O.anchor).grid === ve(e.plan.value, $, O.anchor).grid;
1949
+ t.value = { anchor: B ? O.anchor : { ...$ }, focus: { ...$ } }, a(), y.focus({ preventScroll: !0 });
1950
+ }
1951
+ function s(c) {
1952
+ const v = e.plan.value?.pages[c.pageIndex]?.components[c.componentIndex];
1953
+ return v?.grid ? wa(v.grid, v.widthMm, v.heightMm).cells.map((y) => ({ ...c, rowIndex: y.ri, columnIndex: y.ci })) : [];
1954
+ }
1955
+ function l(c, v, y) {
1956
+ const $ = s(c), O = y ? -1 : 1;
1957
+ if (v === "Tab") return $[$.findIndex((F) => $t(F, c)) + O];
1958
+ const B = v === "ArrowUp" || v === "ArrowDown" || v === "Enter", M = v === "ArrowUp" || v === "ArrowLeft" ? -1 : O;
1959
+ return $.filter((F) => B ? F.columnIndex === c.columnIndex && (F.rowIndex - c.rowIndex) * M > 0 : F.rowIndex === c.rowIndex && (F.columnIndex - c.columnIndex) * M > 0).sort((F, A) => B ? (F.rowIndex - A.rowIndex) * M : (F.columnIndex - A.columnIndex) * M)[0];
1960
+ }
1961
+ function d(c, v, y) {
1962
+ if (v === "ArrowLeft" || v === "ArrowRight") return;
1963
+ const $ = e.plan.value;
1964
+ if (!$.pages[c.pageIndex]?.components[c.componentIndex]?.table) return;
1965
+ const B = v === "ArrowUp" || y ? -1 : 1;
1966
+ for (let M = c.pageIndex; M >= 0 && M < $.pages.length; M += B) {
1967
+ const F = $.pages[M].components, A = M === c.pageIndex ? c.componentIndex + B : B === 1 ? 0 : F.length - 1;
1968
+ for (let G = A; G >= 0 && G < F.length; G += B) {
1969
+ const Z = k(c, { ...c, pageIndex: M, componentIndex: G }, v, B);
1970
+ if (Z) return Z;
1971
+ }
1972
+ }
1973
+ }
1974
+ function k(c, v, y, $) {
1975
+ const O = e.plan.value, B = O.pages[c.pageIndex].components[c.componentIndex].table, M = O.pages[v.pageIndex].components[v.componentIndex]?.table;
1976
+ if (M?.id !== B.id || M.role === "header" && B.role !== "header" && ($ > 0 || B.rowIndex + c.rowIndex > 0)) return;
1977
+ const F = s(v), A = y === "Tab" ? F : F.filter((G) => G.columnIndex === c.columnIndex);
1978
+ return $ === 1 ? A[0] : A[A.length - 1];
1979
+ }
1980
+ function g(c, v, y = !1, $ = !1, O = !1) {
1981
+ const B = l(c, v, y) ?? d(c, v, y);
1982
+ return B ? (n(B, $), !0) : ((v !== "Tab" || !O) && n(c), !1);
1983
+ }
1984
+ function o(c) {
1985
+ const v = t.value;
1986
+ if (e.busy() || c.target instanceof Element && c.target.closest("textarea,input,select")) return !1;
1987
+ if (!v) return f(c);
1988
+ const y = c.key, $ = c.ctrlKey || c.metaKey;
1989
+ if ($ && y.toLowerCase() === "z")
1990
+ return c.preventDefault(), c.shiftKey ? e.redo() : e.undo(), !0;
1991
+ if ($ && y.toLowerCase() === "y")
1992
+ return c.preventDefault(), e.redo(), !0;
1993
+ if (u(c, v.focus)) return !0;
1994
+ if (!["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight", "Tab", "Enter"].includes(y)) return !1;
1995
+ const O = g(v.focus, y, y === "Tab" && c.shiftKey, c.shiftKey && y !== "Tab", !0);
1996
+ return y === "Tab" && !O ? !1 : (c.preventDefault(), !0);
1997
+ }
1998
+ function u(c, v) {
1999
+ if (!e.enabled() || !e.plan.value || c.key !== "F2" && !(c.key === "Enter" && _e(e.plan.value, v)?.editable)) return !1;
2000
+ const y = e.root.value?.querySelector(Ct(v));
2001
+ return y && (c.preventDefault(), e.edit(y)), !0;
2002
+ }
2003
+ function f(c) {
2004
+ if (!["ArrowDown", "ArrowRight", "ArrowUp", "ArrowLeft", "Enter"].includes(c.key)) return !1;
2005
+ const v = e.root.value?.querySelector("td[data-mr-row-index]"), y = v && nt(v);
2006
+ return y ? (c.preventDefault(), n(y), !0) : !1;
2007
+ }
2008
+ function m() {
2009
+ const c = t.value, v = e.plan.value;
2010
+ if (!c || !v) return "";
2011
+ const y = [], $ = ve(v, c.anchor), O = ve(v, c.focus, c.anchor), B = un(v, c.anchor), M = Mt(v), F = Math.min($.column, O.column), A = Math.max($.column, O.column);
2012
+ if ((Math.abs($.row - O.row) + 1) * (A - F + 1) > 1e4)
2013
+ return e.error(new Ee("limit")), "";
2014
+ for (let G = Math.min($.row, O.row); G <= Math.max($.row, O.row); G++) {
2015
+ const Z = [];
2016
+ for (let X = F; X <= A; X++) {
2017
+ const h = B(G, X);
2018
+ Z.push(h ? M(h)?.cell.text ?? "" : "");
2019
+ }
2020
+ y.push(Z);
2021
+ }
2022
+ return da(y);
2023
+ }
2024
+ function x(c) {
2025
+ !t.value || c.target instanceof Element && c.target.closest("textarea,input") || (c.clipboardData?.setData("text/plain", m()), c.preventDefault());
2026
+ }
2027
+ async function p(c) {
2028
+ const v = t.value;
2029
+ if (!v || !e.enabled() || e.busy()) return !1;
2030
+ try {
2031
+ let y;
2032
+ try {
2033
+ y = ca(c);
2034
+ } catch (A) {
2035
+ throw new Ee(A instanceof Error && A.message.includes("limit") ? "limit" : "clipboard");
2036
+ }
2037
+ const $ = e.plan.value, O = ve($, v.anchor), B = ve($, v.focus, v.anchor), M = un($, v.anchor), F = y.flatMap((A, G) => A.map((Z, X) => {
2038
+ const h = M(Math.min(O.row, B.row) + G, Math.min(O.column, B.column) + X);
2039
+ if (!h) throw new Ee("missing");
2040
+ return { address: h, value: Z };
2041
+ }));
2042
+ return await e.apply(F);
2043
+ } catch (y) {
2044
+ return e.error(y), !1;
2045
+ }
2046
+ }
2047
+ function P(c) {
2048
+ if (!t.value || !e.enabled() || c.target instanceof Element && c.target.closest("textarea,input")) return;
2049
+ const v = c.clipboardData?.getData("text/plain");
2050
+ v !== void 0 && (c.preventDefault(), p(v));
2051
+ }
2052
+ async function V(c) {
2053
+ const v = e.plan.value;
2054
+ if (!v) return !1;
2055
+ const y = Mt(v);
2056
+ for (let $ = 0; $ < v.pages.length; $++) {
2057
+ const O = v.pages[$];
2058
+ for (let B = 0; B < O.components.length; B++)
2059
+ for (const M of s({ pageIndex: $, componentIndex: B, rowIndex: 0, columnIndex: 0 })) {
2060
+ const F = y(M), A = F?.source;
2061
+ if ((A?.field ?? F?.table?.columnKey) === c.field && !(c.datasetId !== void 0 && A?.datasetId !== c.datasetId) && !(c.rowKey !== void 0 && A?.rowKey !== c.rowKey))
2062
+ return n(M);
2063
+ }
2064
+ }
2065
+ return !1;
2066
+ }
2067
+ function D() {
2068
+ t.value = null, a();
2069
+ }
2070
+ return { selection: t, refresh: a, reset: D, focusCell: n, focusField: V, navigate: g, onClick: r, onKeydown: o, onCopy: x, onPaste: P, copySelection: m, pasteSelection: p };
2071
+ }
2072
+ function qo(e) {
2073
+ let t = 0, a = !1;
2074
+ function n() {
2075
+ const s = e.viewport.value, l = e.root.value, d = e.plan.value;
2076
+ if (!s || !l || !d) return;
2077
+ const k = e.options(), g = Math.max(0, Math.min(20, Math.floor(k.frozenColumns ?? 0)));
2078
+ if (!k.freezeHeaders && g === 0 && !a) return;
2079
+ const o = e.zoom.value || 1, u = s.getBoundingClientRect();
2080
+ l.querySelectorAll("[data-mr-component-index]").forEach((f) => {
2081
+ const m = f.closest("[data-page]"), x = Number(m?.dataset.page) - 1, p = d.pages[x]?.components[Number(f.dataset.mrComponentIndex)];
2082
+ if (!p?.grid || !m) return;
2083
+ f.style.transform = "", f.style.zIndex = "";
2084
+ const P = f.getBoundingClientRect(), V = m.getBoundingClientRect().bottom, D = Math.max(0, (u.left - P.left) / o), c = k.freezeHeaders ? Math.max(0, Math.min((u.top - P.top) / o, (V - P.bottom) / o)) : 0;
2085
+ D > 0 && g > 0 && (f.style.zIndex = "1"), p.table?.role === "header" && c > 0 && (f.style.transform = `translateY(${c}px)`, f.style.zIndex = "5"), f.querySelectorAll(".mrp-cell-frozen").forEach((y) => {
2086
+ y.style.transform = "", y.style.zIndex = "", y.classList.remove("mrp-cell-frozen");
2087
+ });
2088
+ const v = Array.from({ length: g }, (y, $) => `td[data-mr-column-index="${$}"]`);
2089
+ !p.table && k.freezeHeaders && v.push('td[data-mr-row-index="0"]'), v.length && f.querySelectorAll(v.join(",")).forEach((y) => {
2090
+ const $ = Number(y.dataset.mrColumnIndex) < g, O = !p.table && Number(y.dataset.mrRowIndex) === 0 && !!k.freezeHeaders, B = $ ? D : 0, M = O ? c : 0;
2091
+ y.style.transform = B || M ? `translate(${B}px, ${M}px)` : "", y.classList.toggle("mrp-cell-frozen", !!(B || M)), y.style.zIndex = B || M ? O ? "7" : "6" : "";
2092
+ });
2093
+ }), a = !!k.freezeHeaders || g > 0;
2094
+ }
2095
+ function r() {
2096
+ t || (t = requestAnimationFrame(() => {
2097
+ t = 0, n();
2098
+ }));
2099
+ }
2100
+ return Ie(() => {
2101
+ t && cancelAnimationFrame(t);
2102
+ }), { refresh: n, schedule: r };
2103
+ }
2104
+ async function cn(e, t, a, n) {
2105
+ if (!t?.assetRenderers || !Object.keys(t.assetRenderers).length) return e;
2106
+ try {
2107
+ return (await fa(e, { ...t, signal: a, format: "dom", onDiagnostic: (s) => {
2108
+ a.aborted || (t.onDiagnostic?.(s), n(s.message));
2109
+ } })).plan;
2110
+ } catch (r) {
2111
+ throw a.aborted ? r : new ce("render", r instanceof Error ? r.message : "Report asset preparation failed", r);
2112
+ }
2113
+ }
2114
+ const Wo = {
2115
+ key: 6,
2116
+ class: "mrp-edit-hint",
2117
+ role: "status"
2118
+ }, No = {
2119
+ key: 8,
2120
+ class: "mrp-export-notice mrp-export-warning",
2121
+ role: "status"
2122
+ }, Ho = { class: "mrp-main" }, jo = {
2123
+ key: 0,
2124
+ class: "mrp-state"
2125
+ }, Ko = {
2126
+ key: 1,
2127
+ class: "mrp-state mrp-error"
2128
+ }, Uo = ["data-page"], Vo = ["aria-label", "aria-current", "onClick"], Go = ["data-thumb"], Jo = { class: "mrp-thumb-no" }, Zo = { class: "mrp-overlay" }, Yo = {
2129
+ key: 9,
2130
+ class: "mrp-debug",
2131
+ "aria-hidden": "true"
2132
+ }, Qe = 96 / 25.4, It = "mach-report:ui", Rt = "mach-report:ui:wide", Xo = /* @__PURE__ */ Pe({
2133
+ __name: "ReportPreview",
2134
+ props: {
2135
+ reportId: {
2136
+ type: [String, Array],
2137
+ default: null
2138
+ },
2139
+ params: {
2140
+ type: Object,
2141
+ default: () => ({})
2142
+ },
2143
+ height: { type: String, default: "100vh" },
2144
+ autoLoad: { type: Boolean, default: !0 },
2145
+ /** 以下显隐/间距不传时走配置中心(preset > defaults > 内置缺省) */
2146
+ showExport: { type: Boolean, default: void 0 },
2147
+ showPrint: { type: Boolean, default: void 0 },
2148
+ showPdfWindow: { type: Boolean, default: void 0 },
2149
+ showSettings: { type: Boolean, default: void 0 },
2150
+ toolbar: { type: Object, default: void 0 },
2151
+ interaction: { type: Object, default: void 0 },
2152
+ preferences: { type: Object, default: void 0 },
2153
+ assets: { type: Object, default: void 0 },
2154
+ /** 保留表头的零行业务结果;不改变计划和导出内容。 */
2155
+ emptyState: { type: [Boolean, Object], default: !1 },
2156
+ /** 页间距(px);不传走配置中心 */
2157
+ gapPx: { type: Number, default: void 0 },
2158
+ /** 工具栏/状态文案覆写(不传走配置中心 messages) */
2159
+ messages: { type: Object, default: void 0 },
2160
+ /** 启用的 preset 名(不传用配置中心 defaultPreset) */
2161
+ preset: { type: String, default: void 0 },
2162
+ /** 调试面板(也可用 URL ?mrp-debug=1 开启) */
2163
+ debug: { type: Boolean, default: !1 },
2164
+ /** 参数定义(优先级:prop > 模板 params;有定义且未关闭时显示查询面板) */
2165
+ paramDefs: {
2166
+ type: Array,
2167
+ default: void 0
2168
+ },
2169
+ /** 参数面板显隐(不传走配置中心,缺省 true;有参数定义才渲染) */
2170
+ showParams: { type: Boolean, default: void 0 },
2171
+ editable: { type: [Boolean, Object], default: void 0 },
2172
+ excelImport: { type: [Boolean, Object], default: void 0 },
2173
+ fetcher: {
2174
+ type: Function,
2175
+ default: null
2176
+ }
2177
+ },
2178
+ emits: ["loaded", "error", "warning", "cell-edit", "template-import", "preferences-change"],
2179
+ setup(e, { expose: t, emit: a }) {
2180
+ Qn((i) => ({
2181
+ v02f88d9f: F.value + "px"
2182
+ }));
2183
+ const n = e, r = a, s = fe(null), l = U(!1), d = U(""), k = fe(null), g = U(null), o = U(!1), u = fe(Object.freeze({ status: "unchecked", fontUrl: "" })), f = U(null), m = U(1), x = U(null), p = U(null), P = U(null), V = U(!1), D = U(!1), c = U(!1), v = fe(null), y = U({}), $ = U(null), O = U(null), B = za(), M = z(() => !!s.value?.pages.length && s.value.pages.every((i) => i.layout === "wide")), F = z(() => Math.max(0, Bt.value));
2184
+ let A = It;
2185
+ const G = at(ha, null), Z = at(ba, null), X = z(() => yn(n.reportId)), h = z(() => n.fetcher ?? G), b = z(() => s.value?.pages.length ?? 0), N = z(() => Object.freeze({
2186
+ loading: l.value,
2187
+ hasPlan: b.value > 0,
2188
+ pageCount: b.value,
2189
+ currentPage: m.value,
2190
+ exporting: g.value,
2191
+ printing: o.value,
2192
+ canExport: !l.value && !D.value && !q.saving.value && b.value > 0 && g.value === null,
2193
+ canPrint: !l.value && !D.value && !q.saving.value && b.value > 0 && !o.value,
2194
+ error: k.value,
2195
+ pdfFont: u.value,
2196
+ editing: q.active.value !== null,
2197
+ saving: q.saving.value,
2198
+ importing: D.value,
2199
+ dirty: q.differences.value.length > 0,
2200
+ canUndo: q.canUndo.value,
2201
+ canRedo: q.canRedo.value,
2202
+ changeCount: q.differences.value.length,
2203
+ selection: Q.selection.value ? de(Q.selection.value) : null
2204
+ }));
2205
+ function H(i, w, S) {
2206
+ k.value = Object.freeze({ message: i, code: w, cause: S }), r("error", i, { code: w, cause: S });
2207
+ }
2208
+ const J = $o(), j = z(() => Po(J.value, n.preset)), L = z(() => ({
2209
+ ...j.value.messages,
2210
+ ...n.messages
2211
+ })), le = z(() => n.showExport ?? j.value.showExport), kn = z(() => n.showPrint ?? j.value.showPrint), Ke = z(() => n.showPdfWindow ?? j.value.showPdfWindow), lt = z(() => n.showSettings ?? j.value.showSettings), Re = z(() => ({ ...j.value.toolbar, ...n.toolbar })), Ue = z(() => ({ ...j.value.interaction, ...n.interaction, ...y.value })), $n = z(() => n.preferences ?? j.value.preferences), zt = z(() => n.assets ?? j.value.assets), Bt = z(() => n.gapPx ?? (M.value ? 0 : j.value.gapPx)), Cn = z(() => n.showParams ?? j.value.showParams), De = z(() => n.editable ?? j.value.editable), Lt = z(() => n.excelImport ?? j.value.excelImport), qt = z(() => ({
2212
+ search: Re.value.search !== !1,
2213
+ thumbnails: Re.value.thumbnails !== !1,
2214
+ zoom: Re.value.zoom !== !1,
2215
+ ...Object.fromEntries(Dt.map((i) => [
2216
+ i,
2217
+ le.value && (Re.value.exportFormats?.includes(i) ?? !0)
2218
+ ])),
2219
+ print: kn.value,
2220
+ pdfWindow: Ke.value,
2221
+ editing: !!De.value,
2222
+ import: !!Lt.value
2223
+ })), it = Oo(qt, z(() => ({
2224
+ editing: Re.value.editing,
2225
+ import: Re.value.excelImport
2226
+ })), $n, () => r("warning", L.value.preferencesError ?? "Preferences storage unavailable")), ae = it.enabled, In = z(() => Dt.filter((i) => ae.value[i])), Ve = z(() => ae.value.editing ? De.value : !1), Ge = z(() => ae.value.import ? Lt.value : !1), Wt = z(() => typeof De.value == "object" && (typeof De.value.save == "function" || typeof De.value.saveBatch == "function")), ut = z(() => typeof n.emptyState == "object" ? n.emptyState : {});
2227
+ async function Rn(i, w) {
2228
+ i === "editing" && !w && !await q.commit() || (it.setEnabled(i, w), r("preferences-change", Object.freeze({ ...ae.value })));
2229
+ }
2230
+ async function Sn() {
2231
+ await q.commit() && (it.reset(), y.value = {}, r("preferences-change", Object.freeze({ ...ae.value })));
2232
+ }
2233
+ async function Mn() {
2234
+ if (c.value) {
2235
+ c.value = !1;
2236
+ return;
2237
+ }
2238
+ !await q.commit() || he || !lt.value || (c.value = !0);
2239
+ }
2240
+ function Nt(i) {
2241
+ return i instanceof Ee ? {
2242
+ number: L.value.editInvalidNumber,
2243
+ boolean: L.value.editInvalidBoolean,
2244
+ conflict: L.value.editConflict,
2245
+ atomic: L.value.editAtomicRequired,
2246
+ limit: L.value.clipboardLimit,
2247
+ readonly: L.value.editReadOnly,
2248
+ missing: L.value.editMissing,
2249
+ duplicate: L.value.editDuplicate,
2250
+ clipboard: L.value.clipboardInvalid
2251
+ }[i.code] ?? i.message : i instanceof Error ? i.message : "单元格保存失败";
2252
+ }
2253
+ const q = Ao({
2254
+ plan: s,
2255
+ options: Ve,
2256
+ blocked: () => l.value || D.value || g.value !== null || o.value,
2257
+ label: () => L.value.editCell ?? "编辑单元格",
2258
+ errorMessage: Nt,
2259
+ onChange: (i) => {
2260
+ k.value = null, f.value = null, r("cell-edit", i);
2261
+ },
2262
+ onError: (i, w) => {
2263
+ f.value = { kind: "error", message: i }, H(i, "edit", w);
2264
+ },
2265
+ onNavigate: (i, w, S) => Q.navigate(i, w, S)
2266
+ }), Q = Lo({
2267
+ plan: s,
2268
+ root: x,
2269
+ enabled: () => !!Ve.value,
2270
+ busy: () => l.value || D.value || q.saving.value || !!g.value || o.value,
2271
+ differences: () => q.differences.value,
2272
+ gotoPage: be,
2273
+ edit: q.editCell,
2274
+ apply: q.apply,
2275
+ undo: q.undo,
2276
+ redo: q.redo,
2277
+ error: (i) => {
2278
+ const w = Nt(i);
2279
+ f.value = { kind: "error", message: w }, H(w, "edit", i);
2280
+ }
2281
+ }), Fn = z(() => {
2282
+ if (v.value) return v.value.sheets.map((w) => ({ label: w.name, pageIndex: w.pageStart }));
2283
+ const i = /* @__PURE__ */ new Set();
2284
+ return s.value?.pages.flatMap((w, S) => w.components.flatMap((_) => {
2285
+ const K = _.table;
2286
+ return !K?.title || i.has(K.id) ? [] : (i.add(K.id), [{ label: K.title, pageIndex: S }]);
2287
+ })) ?? [];
2288
+ });
2289
+ async function Tn(i) {
2290
+ i && !await Q.focusField({ field: i }) && (f.value = { kind: "warning", message: L.value.locateFieldMissing ?? "Field not found" });
2291
+ }
2292
+ let Ht = null, ct = null;
2293
+ function jt() {
2294
+ if (Z) return Z;
2295
+ const i = j.value.pdfFontUrl;
2296
+ return (!ct || Ht !== i) && (Ht = i, ct = So({ fontUrl: i })), ct;
2297
+ }
2298
+ let Je = 0, Ae = null, Ze = null, he = !1;
2299
+ function dt() {
2300
+ Je++, Ae?.abort(), Ae = null;
2301
+ }
2302
+ async function ft() {
2303
+ if (he) throw new ce("config", "报表预览已卸载");
2304
+ dt();
2305
+ const i = Je, w = new AbortController();
2306
+ Ae = w;
2307
+ const S = j.value.pdfFontUrl;
2308
+ u.value = Object.freeze({ status: "checking", fontUrl: S });
2309
+ try {
2310
+ const _ = jt(), K = _.checkFont ? await _.checkFont(w.signal) : { status: "unverified", fontUrl: "", message: "自定义 PDF 导出器未提供字体预检查;字体由宿主确认" };
2311
+ return !he && i === Je && !w.signal.aborted && (u.value = Object.freeze({ ...K })), K;
2312
+ } catch (_) {
2313
+ if (w.signal.aborted) throw _;
2314
+ const K = {
2315
+ status: "error",
2316
+ fontUrl: S,
2317
+ message: _ instanceof Error ? _.message : "PDF 字体检查失败",
2318
+ cause: _
2319
+ };
2320
+ return !he && i === Je && (u.value = Object.freeze(K)), K;
2321
+ } finally {
2322
+ Ae === w && (Ae = null);
2323
+ }
2324
+ }
2325
+ function Dn() {
2326
+ ft().catch(() => {
2327
+ });
2328
+ }
2329
+ ne(
2330
+ [s, () => j.value.pdfFontUrl, le, Ke],
2331
+ () => {
2332
+ const i = u.value.fontUrl === j.value.pdfFontUrl;
2333
+ i && u.value.status === "available" || (dt(), (!i || u.value.status === "checking") && (u.value = Object.freeze({ status: "unchecked", fontUrl: j.value.pdfFontUrl })), !he && b.value > 0 && (le.value || Ke.value) && ft().catch(() => {
2334
+ }));
2335
+ },
2336
+ { immediate: !0 }
2337
+ );
2338
+ const mt = z(() => {
2339
+ try {
2340
+ return { defs: n.paramDefs ?? h.value?.getParamDefs?.(X.value) ?? [], error: null };
2341
+ } catch (i) {
2342
+ return { defs: [], error: new ce("config", i instanceof Error ? i.message : "查询参数配置无效", i) };
2343
+ }
2344
+ }), vt = z(() => mt.value.defs), Oe = Fr({ defs: vt, reportIds: X, params: () => n.params, messages: () => L.value }), { values: ze, attempted: Ye, pendingRequired: Kt } = Oe, Ut = U(null);
2345
+ function An() {
2346
+ Ye.value = !0, Oe.validation.value.ok || je(() => Ut.value?.focusInvalid()), Me();
2347
+ }
2348
+ function On() {
2349
+ Oe.reset(), d.value = "", k.value = null;
2350
+ }
2351
+ const zn = z(() => ({
2352
+ height: n.height,
2353
+ ...ko(j.value.theme)
2354
+ })), { zoom: ie, zoomMode: Be, applyFitZoom: Vt, setZoom: Le } = Ea(() => ({
2355
+ viewport: p.value,
2356
+ pageWidthPx: pt.contentSize.value.w || 210 * Qe
2357
+ })), pt = xa(s, ie, {
2358
+ pxPerMm: Qe,
2359
+ gapPx: Bt,
2360
+ overscan: z(() => j.value.preview.overscanPages)
2361
+ }), { contentSize: gt, windowRange: qe, visiblePages: ht, makeScrollHandler: Bn, refreshViewport: bt } = pt, Ln = Bn(m, b), yt = qo({ root: x, viewport: p, plan: s, zoom: ie, options: () => Ue.value });
2362
+ ne([Ue, ie], () => yt.schedule(), { flush: "post" });
2363
+ function wt(i) {
2364
+ Le(i * 100);
2365
+ }
2366
+ function Se() {
2367
+ D.value = !1, q.reset(), Q.reset(), v.value = null, Gt(), s.value = null, m.value = 1, Y.reset();
2368
+ }
2369
+ let ee = 0, ue = null;
2370
+ function qn() {
2371
+ if (mt.value.error) {
2372
+ const w = mt.value.error;
2373
+ return Se(), d.value = w.message, H(w.message, w.code, w.cause), null;
2374
+ }
2375
+ const i = Oe.query();
2376
+ return i.params ? i.params : (Se(), d.value = i.quiet ? "" : i.error.message, i.quiet || (Ye.value = !0, H(i.error.message, i.error.code, i.error.cause)), null);
2377
+ }
2378
+ async function Me() {
2379
+ if (he) return;
2380
+ const i = ++ee;
2381
+ D.value = !1, ue?.abort(), ue = null;
2382
+ const w = h.value;
2383
+ if (l.value = !1, k.value = null, X.value.length === 0) {
2384
+ d.value = "缺少报表 ID", Se(), H(d.value, "param");
2385
+ return;
2386
+ }
2387
+ if (!w) {
2388
+ d.value = "未提供渲染数据源 fetcher", Se(), H(d.value, "config");
2389
+ return;
2390
+ }
2391
+ const S = qn();
2392
+ if (!S) return;
2393
+ l.value = !0, d.value = "", f.value = null, Se();
2394
+ const _ = B.start(), K = new AbortController();
2395
+ ue = K;
2396
+ const re = /* @__PURE__ */ new Set();
2397
+ function se(te) {
2398
+ i !== ee || K.signal.aborted || re.has(te) || (re.add(te), j.value.logger.warn("[mach-report] 报表告警:", te), r("warning", te));
2399
+ }
2400
+ try {
2401
+ let te = await w({
2402
+ reportIds: X.value,
2403
+ params: S,
2404
+ signal: K.signal,
2405
+ onWarning: se
2406
+ });
2407
+ if (i !== ee) return;
2408
+ const oe = an(te);
2409
+ if (!oe.ok) {
2410
+ const Xe = oe.errors.slice(0, 3).map((tn) => `${tn.path}: ${tn.message}`).join("; ");
2411
+ throw new ce(
2412
+ "validate",
2413
+ `渲染计划校验失败(${oe.errors.length} 处): ${Xe}`
2414
+ );
2415
+ }
2416
+ if (oe.warnings.forEach((Xe) => se(`${Xe.path}: ${Xe.message}`)), i !== ee || K.signal.aborted || (te = await cn(te, zt.value, K.signal, se), i !== ee || K.signal.aborted)) return;
2417
+ s.value = te, m.value = 1, B.end(_), p.value && (p.value.scrollTop = 0, p.value.scrollLeft = 0);
2418
+ const Ne = M.value ? Rt : It;
2419
+ Ne !== A && (A = Ne, Pt()), Be.value === "fit" && Vt(), r("loaded", te.pages.length);
2420
+ } catch (te) {
2421
+ if (i !== ee) return;
2422
+ const oe = Rr(te);
2423
+ d.value = oe.message;
2424
+ const Ne = Ir(oe);
2425
+ H(oe.message, Ne.code, Ne.cause);
2426
+ } finally {
2427
+ i === ee && (l.value = !1), ue === K && (ue = null);
2428
+ }
2429
+ }
2430
+ function be(i) {
2431
+ if (he || b.value <= 0) return;
2432
+ const w = Math.max(1, Math.min(b.value, i));
2433
+ m.value = w;
2434
+ const S = p.value;
2435
+ S && (S.scrollTop = pt.pageOffsetPx(w - 1) * ie.value, bt(S));
2436
+ }
2437
+ const We = ka(s, {
2438
+ getPdfExporter: jt,
2439
+ getXlsxOptions: () => j.value.xlsx,
2440
+ onError: (i, w) => {
2441
+ f.value = { kind: "error", message: i }, H(i, w ?? "print");
2442
+ },
2443
+ onWarning: (i) => {
2444
+ f.value = { kind: "warning", message: i }, r("warning", i);
2445
+ },
2446
+ onBusy: (i) => {
2447
+ g.value = i, i ? f.value = {
2448
+ kind: "progress",
2449
+ message: L.value.exporting.replace("{format}", i)
2450
+ } : f.value?.kind === "progress" && (f.value = null);
2451
+ },
2452
+ onPrinting: (i) => {
2453
+ o.value = i;
2454
+ }
2455
+ }), { releasePrintFrame: Gt, dispose: Wn } = We;
2456
+ async function Jt() {
2457
+ l.value || D.value || q.active.value && !await q.commit() || (k.value = null, await We.print());
2458
+ }
2459
+ async function Zt(i) {
2460
+ l.value || D.value || q.active.value && !await q.commit() || (k.value = null, await We.exportAs(i));
2461
+ }
2462
+ function Yt() {
2463
+ if (l.value || D.value || q.active.value) {
2464
+ f.value = { kind: "warning", message: L.value.editingHint ?? "请先确认单元格修改" };
2465
+ return;
2466
+ }
2467
+ k.value = null, We.openPdfWindow();
2468
+ }
2469
+ async function Nn(i, w = {}) {
2470
+ he || (ze.value = { ...ze.value, ...i }, w.reload !== !1 && (Ye.value = !0, await Me()));
2471
+ }
2472
+ const Xt = {
2473
+ reload: Me,
2474
+ print: Jt,
2475
+ exportAs: Zt,
2476
+ openPdfWindow: Yt,
2477
+ gotoPage: be,
2478
+ setParams: Nn,
2479
+ checkPdfFont: ft,
2480
+ importExcel: Qt,
2481
+ getPlan: Hn,
2482
+ getChanges: q.getChanges,
2483
+ undo: q.undo,
2484
+ redo: q.redo,
2485
+ restoreChanges: q.restore,
2486
+ getDifferences: () => de(q.differences.value),
2487
+ getSelection: () => Q.selection.value ? de(Q.selection.value) : null,
2488
+ focusCell: Q.focusCell,
2489
+ focusField: Q.focusField,
2490
+ copySelection: Q.copySelection,
2491
+ pasteSelection: Q.pasteSelection,
2492
+ get state() {
2493
+ return N.value;
2494
+ }
2495
+ };
2496
+ pn(ya, Xt);
2497
+ function Hn() {
2498
+ return s.value ? de(s.value) : null;
2499
+ }
2500
+ function jn(i) {
2501
+ const w = typeof Ge.value == "object" ? Ge.value : {};
2502
+ return { ...w, ...i, limits: { ...w.limits, ...i?.limits } };
2503
+ }
2504
+ async function Qt(i, w) {
2505
+ if (he) throw new ce("config", "报表预览已卸载");
2506
+ const S = ++ee;
2507
+ ue?.abort(), ue = null, l.value = !1, q.cancel(), We.invalidatePending(), D.value = !0;
2508
+ const _ = new AbortController();
2509
+ ue = _, k.value = null, f.value = { kind: "progress", message: L.value.importing ?? "正在导入 Excel…" };
2510
+ try {
2511
+ const { importExcelTemplate: K } = await import("@agile-team/mach-report/xlsx");
2512
+ if (S !== ee) return null;
2513
+ const re = await K(i, jn(w));
2514
+ if (S !== ee) return null;
2515
+ let se = ma(de(re.template), {}).plan;
2516
+ const te = an(se);
2517
+ if (!te.ok) throw new Error(te.errors.map((oe) => oe.message).slice(0, 3).join("; "));
2518
+ se = await cn(se, zt.value, _.signal, (oe) => {
2519
+ S === ee && r("warning", oe);
2520
+ });
2521
+ for (const oe of re.warnings) {
2522
+ if (S !== ee) return null;
2523
+ r("warning", oe);
2524
+ }
2525
+ return S !== ee ? null : (q.reset(), Q.reset(), Gt(), Y.reset(), s.value = se, v.value = { sheets: de(re.sheets), warnings: [...re.warnings] }, m.value = 1, d.value = "", f.value = re.warnings.length ? { kind: "warning", message: re.warnings.join(";") } : null, p.value && (p.value.scrollTop = 0, p.value.scrollLeft = 0), A = M.value ? Rt : It, Pt(), r("template-import", re), S === ee && r("loaded", se.pages.length), re);
2526
+ } catch (K) {
2527
+ if (S !== ee) return null;
2528
+ const re = new ce("import", K instanceof Error ? K.message : "Excel 模板导入失败", K);
2529
+ throw f.value = { kind: "error", message: re.message }, H(re.message, "import", K), re;
2530
+ } finally {
2531
+ S === ee && (D.value = !1), ue === _ && (ue = null);
2532
+ }
2533
+ }
2534
+ function Kn(i) {
2535
+ const w = i.target, S = w.files?.[0];
2536
+ w.value = "", S && Qt(S).catch(() => {
2537
+ });
2538
+ }
2539
+ const Y = Da({
2540
+ plan: s,
2541
+ gotoPage: be,
2542
+ debounceMs: z(() => j.value.preview.searchDebounceMs),
2543
+ highlight: Ca,
2544
+ clearHighlights: $a
2545
+ });
2546
+ ne(() => ae.value.search, (i) => {
2547
+ i || (Y.reset(), Y.visible.value = !1);
2548
+ });
2549
+ function Un(i) {
2550
+ !i.ctrlKey || !ae.value.zoom || (i.preventDefault(), wt(ie.value * (i.deltaY < 0 ? 1.1 : 1 / 1.1)));
2551
+ }
2552
+ function Vn(i) {
2553
+ if (!Q.onKeydown(i) && !(i.target instanceof Element && i.target.closest("input,textarea,select,[contenteditable='true']"))) {
2554
+ if (ae.value.search && (i.ctrlKey || i.metaKey) && i.key.toLowerCase() === "f") {
2555
+ i.preventDefault(), Y.visible.value || Y.toggle(), je(() => O.value?.focusSearch());
2556
+ return;
2557
+ }
2558
+ switch (i.key) {
2559
+ case "PageDown":
2560
+ i.preventDefault(), be(m.value + 1);
2561
+ break;
2562
+ case "PageUp":
2563
+ i.preventDefault(), be(m.value - 1);
2564
+ break;
2565
+ case "Home":
2566
+ i.preventDefault(), be(1);
2567
+ break;
2568
+ case "End":
2569
+ i.preventDefault(), be(b.value);
2570
+ break;
2571
+ case "+":
2572
+ case "=":
2573
+ i.preventDefault(), ae.value.zoom && wt(ie.value * 1.1);
2574
+ break;
2575
+ case "-":
2576
+ i.preventDefault(), ae.value.zoom && wt(ie.value / 1.1);
2577
+ break;
2578
+ }
2579
+ }
2580
+ }
2581
+ function Gn() {
2582
+ try {
2583
+ localStorage.setItem(
2584
+ A,
2585
+ JSON.stringify({ zoomMode: Be.value === "fit" ? "fit" : Math.round(ie.value * 100) })
2586
+ );
2587
+ } catch {
2588
+ }
2589
+ }
2590
+ ne([Be, ie], Gn);
2591
+ let xt = "";
2592
+ const _t = /* @__PURE__ */ new WeakMap();
2593
+ function en(i = !1) {
2594
+ const w = Y.activeMatch.value;
2595
+ if (!M.value || !w) return;
2596
+ const S = `${Y.query.value}:${Y.matchIndex.value}:${w.pageIndex}`;
2597
+ if (!i && S === xt) return;
2598
+ const K = x.value?.querySelector(`[data-page="${w.pageIndex + 1}"]`)?.querySelectorAll("mark.mrp-hit")[w.occurrence];
2599
+ K && (K.scrollIntoView?.({ block: "nearest", inline: "nearest" }), xt = S);
2600
+ }
2601
+ ne([s, () => Y.activeMatch.value, () => Y.matchIndex.value, () => Y.query.value, ht, x], () => {
2602
+ const i = s.value;
2603
+ if (!i) return;
2604
+ const w = Y.activeMatch.value;
2605
+ Y.matchIndex.value, w || (xt = ""), ht.value;
2606
+ const S = x.value;
2607
+ if (!S) return;
2608
+ S.querySelectorAll(".mrp-page-holder").forEach((K) => {
2609
+ const re = Number(K.dataset.page ?? 0) - 1, se = i.pages[re];
2610
+ if (!se || K.childElementCount > 0 && _t.get(K) === se) {
2611
+ if (K.firstElementChild) {
2612
+ const oe = K.firstElementChild;
2613
+ Y.clear(oe), Y.apply(oe);
2614
+ }
2615
+ return;
2616
+ }
2617
+ K.style.width = `${se.pageWidthMm * Qe}px`;
2618
+ const te = gn(se, 96, {}, document);
2619
+ Y.apply(te), K.replaceChildren(te), _t.set(K, se);
2620
+ }), en(), Q.refresh(), yt.refresh();
2621
+ }, { flush: "post", immediate: !0 }), ne(() => Q.selection.value, () => {
2622
+ Q.refresh();
2623
+ }, { flush: "post" }), ne(() => Y.query.value, (i) => {
2624
+ i || x.value?.querySelectorAll(".mrp-page-holder").forEach((w) => {
2625
+ Y.clear(w);
2626
+ });
2627
+ });
2628
+ const ye = Oa(s, {
2629
+ thumbsRoot: P,
2630
+ visible: V,
2631
+ renderThumbCanvas: (i) => {
2632
+ try {
2633
+ const w = s.value.pages[i], S = Math.min(0.2, 116 / Math.max(1, w.pageWidthMm * Qe)), { canvases: _ } = va(s.value, { start: i, end: i, dpr: S });
2634
+ return _[0] ?? null;
2635
+ } catch {
2636
+ return null;
2637
+ }
2638
+ }
2639
+ });
2640
+ _n(() => {
2641
+ ye.schedule();
2642
+ }, { flush: "post" });
2643
+ const Jn = z(() => n.debug), { debugStats: Fe } = Aa(Jn, {
2644
+ plan: s,
2645
+ pageCount: b,
2646
+ windowRange: qe,
2647
+ zoom: ie,
2648
+ loadMs: B.loadMs
2649
+ });
2650
+ function Et() {
2651
+ bt(p.value), ye.schedule(), Be.value === "fit" && Vt(), en(!0);
2652
+ }
2653
+ function Pt() {
2654
+ Le(A === Rt ? 100 : "fit");
2655
+ try {
2656
+ const i = JSON.parse(localStorage.getItem(A) ?? "{}");
2657
+ i.zoomMode === "fit" ? Le("fit") : typeof i.zoomMode == "number" && Le(i.zoomMode);
2658
+ } catch {
2659
+ }
2660
+ }
2661
+ return fn(() => {
2662
+ window.addEventListener("resize", Et), typeof ResizeObserver < "u" && p.value && (Ze = new ResizeObserver(Et), Ze.observe(p.value)), bt(p.value), Pt(), n.autoLoad && Me();
2663
+ }), mn(() => {
2664
+ he = !0, q.reset(), D.value = !1, dt(), ee++, ue?.abort(), ue = null, window.removeEventListener("resize", Et), Ze?.disconnect(), Ze = null, ye.destroy(), Y.reset(), Wn();
2665
+ }), ne(
2666
+ () => [JSON.stringify(X.value), JSON.stringify(n.params), h.value],
2667
+ () => {
2668
+ if (n.autoLoad) {
2669
+ Me();
2670
+ return;
2671
+ }
2672
+ ee++, ue?.abort(), ue = null, l.value = !1, d.value = "", k.value = null, f.value = null, Se();
2673
+ }
2674
+ ), t({ ...Xt, state: N }), (i, w) => (E(), I("div", {
2675
+ class: pe(["mach-report-preview", { "mrp-wide-report": M.value }]),
2676
+ style: we(zn.value)
2677
+ }, [
2678
+ Cn.value && vt.value.length > 0 ? (E(), $e(jr, {
2679
+ key: 0,
2680
+ ref_key: "paramPanelRef",
2681
+ ref: Ut,
2682
+ defs: vt.value,
2683
+ modelValue: C(ze),
2684
+ "onUpdate:modelValue": w[0] || (w[0] = (S) => ea(ze) ? ze.value = S : null),
2685
+ messages: L.value,
2686
+ attempted: C(Ye),
2687
+ issues: C(Oe).validation.value.issues,
2688
+ onQuery: An,
2689
+ onReset: On
2690
+ }, null, 8, ["defs", "modelValue", "messages", "attempted", "issues"])) : W("", !0),
2691
+ ta(lr, {
2692
+ ref_key: "toolbarRef",
2693
+ ref: O,
2694
+ "page-count": b.value,
2695
+ "current-page": m.value,
2696
+ "zoom-mode": C(Be),
2697
+ zoom: C(ie),
2698
+ "show-export": le.value,
2699
+ "show-print": C(ae).print,
2700
+ "show-pdf-window": C(ae).pdfWindow,
2701
+ "show-search": C(ae).search,
2702
+ "show-thumbnails": C(ae).thumbnails,
2703
+ "show-zoom": C(ae).zoom,
2704
+ "export-formats": In.value,
2705
+ "show-settings": lt.value,
2706
+ "settings-open": c.value,
2707
+ messages: L.value,
2708
+ search: { visible: C(Y).visible.value, query: C(Y).query.value, matchIndex: C(Y).matchIndex.value, matchCount: C(Y).matchCount.value, searching: C(Y).searching.value },
2709
+ "thumbs-visible": V.value,
2710
+ "show-import": !!Ge.value,
2711
+ busy: l.value || D.value || C(q).saving.value,
2712
+ onGoto: be,
2713
+ onZoom: C(Le),
2714
+ onExport: w[1] || (w[1] = (S) => Zt(S)),
2715
+ onPrint: Jt,
2716
+ onPdfWindow: Yt,
2717
+ onSearchInput: C(Y).onInput,
2718
+ onSearchNav: C(Y).onNav,
2719
+ onSearchToggle: C(Y).toggle,
2720
+ onThumbsToggle: w[2] || (w[2] = (S) => V.value = !V.value),
2721
+ onImportExcel: w[3] || (w[3] = (S) => $.value?.click()),
2722
+ onSettingsToggle: Mn
2723
+ }, null, 8, ["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", "onSearchInput", "onSearchNav", "onSearchToggle"]),
2724
+ c.value && lt.value ? (E(), $e(Pr, {
2725
+ key: 1,
2726
+ available: qt.value,
2727
+ enabled: C(ae),
2728
+ messages: L.value,
2729
+ "persisted-editing": Wt.value,
2730
+ interaction: Ue.value,
2731
+ busy: l.value || D.value || C(q).saving.value || !!g.value || o.value,
2732
+ onInteraction: w[4] || (w[4] = (S) => y.value = { ...y.value, ...S }),
2733
+ onChange: Rn,
2734
+ onReset: Sn,
2735
+ onClose: w[5] || (w[5] = (S) => c.value = !1)
2736
+ }, {
2737
+ default: na(() => [
2738
+ St(i.$slots, "settings", {}, void 0, !0)
2739
+ ]),
2740
+ _: 3
2741
+ }, 8, ["available", "enabled", "messages", "persisted-editing", "interaction", "busy"])) : W("", !0),
2742
+ b.value > 0 && Ue.value.navigation !== !1 ? (E(), $e(mo, {
2743
+ key: 2,
2744
+ sections: Fn.value,
2745
+ "current-page": m.value,
2746
+ messages: L.value,
2747
+ busy: l.value || D.value || C(q).saving.value,
2748
+ onGoto: be,
2749
+ onLocate: Tn
2750
+ }, null, 8, ["sections", "current-page", "messages", "busy"])) : W("", !0),
2751
+ v.value ? (E(), $e(bo, {
2752
+ key: 3,
2753
+ result: v.value,
2754
+ messages: L.value
2755
+ }, null, 8, ["result", "messages"])) : W("", !0),
2756
+ Ve.value && b.value > 0 ? (E(), $e(oo, {
2757
+ key: 4,
2758
+ differences: C(q).differences.value,
2759
+ conflicts: C(q).conflicts.value,
2760
+ messages: L.value,
2761
+ saving: C(q).saving.value,
2762
+ "can-undo": C(q).canUndo.value,
2763
+ "can-redo": C(q).canRedo.value,
2764
+ persisted: Wt.value,
2765
+ busy: !!g.value || o.value,
2766
+ onUndo: C(q).undo,
2767
+ onRedo: C(q).redo,
2768
+ onRestore: C(q).restore,
2769
+ onLocate: w[6] || (w[6] = (S) => C(Q).focusCell(S.address))
2770
+ }, null, 8, ["differences", "conflicts", "messages", "saving", "can-undo", "can-redo", "persisted", "busy", "onUndo", "onRedo", "onRestore"])) : W("", !0),
2771
+ Ge.value ? (E(), I("input", {
2772
+ key: 5,
2773
+ ref_key: "importInputRef",
2774
+ ref: $,
2775
+ class: "mrp-import-input",
2776
+ type: "file",
2777
+ accept: ".xlsx,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
2778
+ hidden: "",
2779
+ onChange: Kn
2780
+ }, null, 544)) : W("", !0),
2781
+ Ve.value && b.value > 0 ? (E(), I("div", Wo, R(C(q).saving.value ? L.value.saving : L.value.editingHint), 1)) : W("", !0),
2782
+ f.value ? (E(), I("div", {
2783
+ key: 7,
2784
+ class: pe(["mrp-export-notice", `mrp-export-${f.value.kind}`]),
2785
+ role: "alert"
2786
+ }, R(f.value.message), 3)) : W("", !0),
2787
+ u.value.status === "error" && (le.value || Ke.value) ? (E(), I("div", No, [
2788
+ Ce(R(L.value.pdfFontUnavailable) + " ", 1),
2789
+ T("button", {
2790
+ type: "button",
2791
+ onClick: Dn
2792
+ }, R(L.value.retry), 1)
2793
+ ])) : W("", !0),
2794
+ T("div", Ho, [
2795
+ T("div", {
2796
+ ref_key: "viewportRef",
2797
+ ref: p,
2798
+ class: "mrp-body",
2799
+ tabindex: "0",
2800
+ onWheel: Un,
2801
+ onKeydown: Vn,
2802
+ onDblclick: w[7] || (w[7] = //@ts-ignore
2803
+ (...S) => C(q).onDoubleClick && C(q).onDoubleClick(...S)),
2804
+ onClick: w[8] || (w[8] = //@ts-ignore
2805
+ (...S) => C(Q).onClick && C(Q).onClick(...S)),
2806
+ onCopy: w[9] || (w[9] = //@ts-ignore
2807
+ (...S) => C(Q).onCopy && C(Q).onCopy(...S)),
2808
+ onPaste: w[10] || (w[10] = //@ts-ignore
2809
+ (...S) => C(Q).onPaste && C(Q).onPaste(...S)),
2810
+ onScrollPassive: w[11] || (w[11] = (S) => {
2811
+ C(Ln)(S.target), C(yt).schedule();
2812
+ })
2813
+ }, [
2814
+ l.value ? (E(), I("div", jo, R(L.value.loading), 1)) : d.value ? (E(), I("div", Ko, [
2815
+ Ce(R(d.value) + " ", 1),
2816
+ T("button", {
2817
+ class: "mrp-retry",
2818
+ type: "button",
2819
+ onClick: Me
2820
+ }, R(L.value.retry), 1)
2821
+ ])) : !s.value || b.value === 0 ? (E(), $e(rn, {
2822
+ key: 2,
2823
+ title: C(Kt) ? L.value.paramPrompt ?? L.value.paramsTitle : L.value.empty,
2824
+ description: C(Kt) ? L.value.paramPromptDescription : ut.value.description ?? L.value.emptyDescription
2825
+ }, null, 8, ["title", "description"])) : (E(), I("div", {
2826
+ key: 3,
2827
+ class: "mrp-scale",
2828
+ style: we({ width: `${C(gt).w * C(ie)}px`, height: `${C(gt).h * C(ie)}px` })
2829
+ }, [
2830
+ T("div", {
2831
+ ref_key: "containerRef",
2832
+ ref: x,
2833
+ class: "mrp-scale-inner",
2834
+ style: we({ transform: `scale(${C(ie)})`, transformOrigin: "top left", width: `${C(gt).w}px` })
2835
+ }, [
2836
+ C(qe).padTopPx > 0 ? (E(), I("div", {
2837
+ key: 0,
2838
+ class: "mrp-spacer-top",
2839
+ style: we({ height: `${C(qe).padTopPx}px` }),
2840
+ "aria-hidden": "true"
2841
+ }, null, 4)) : W("", !0),
2842
+ (E(!0), I(me, null, ge(C(ht), (S) => (E(), I("div", {
2843
+ key: S.index,
2844
+ class: "mrp-page-holder",
2845
+ "data-page": S.index + 1
2846
+ }, null, 8, Uo))), 128)),
2847
+ C(qe).padBottomPx > 0 ? (E(), I("div", {
2848
+ key: 1,
2849
+ class: "mrp-spacer-bottom",
2850
+ style: we({ height: `${C(qe).padBottomPx}px` }),
2851
+ "aria-hidden": "true"
2852
+ }, null, 4)) : W("", !0)
2853
+ ], 4)
2854
+ ], 4)),
2855
+ !l.value && !d.value && s.value && b.value > 0 && e.emptyState ? (E(), $e(rn, {
2856
+ key: 4,
2857
+ title: ut.value.title ?? L.value.empty,
2858
+ description: ut.value.description ?? L.value.emptyDescription
2859
+ }, null, 8, ["title", "description"])) : W("", !0)
2860
+ ], 544),
2861
+ C(ae).thumbnails && V.value && b.value > 0 ? (E(), I("aside", {
2862
+ key: 0,
2863
+ ref_key: "thumbsRef",
2864
+ ref: P,
2865
+ class: "mrp-thumbs",
2866
+ onScrollPassive: w[12] || (w[12] = //@ts-ignore
2867
+ (...S) => C(ye).onScroll && C(ye).onScroll(...S))
2868
+ }, [
2869
+ C(ye).windowRange.value.padTopPx > 0 ? (E(), I("div", {
2870
+ key: 0,
2871
+ class: "mrp-thumb-spacer",
2872
+ style: we({ height: `${C(ye).windowRange.value.padTopPx}px` }),
2873
+ "aria-hidden": "true"
2874
+ }, null, 4)) : W("", !0),
2875
+ (E(!0), I(me, null, ge(C(ye).visibleThumbs.value, (S) => (E(), I("button", {
2876
+ key: S.index,
2877
+ class: pe(["mrp-thumb", { "mrp-thumb-active": S.index + 1 === m.value }]),
2878
+ type: "button",
2879
+ "aria-label": `${L.value.thumbnails} · ${L.value.pageInfo.replace("{cur}", String(S.index + 1)).replace("{total}", String(b.value))}`,
2880
+ "aria-current": S.index + 1 === m.value ? "page" : void 0,
2881
+ style: we({ height: `${S.height + 20}px` }),
2882
+ onClick: (_) => be(S.index + 1)
2883
+ }, [
2884
+ T("span", {
2885
+ class: "mrp-thumb-box",
2886
+ "data-thumb": S.index + 1,
2887
+ style: we({ height: `${S.height}px` })
2888
+ }, null, 12, Go),
2889
+ T("span", Jo, R(S.index + 1), 1)
2890
+ ], 14, Vo))), 128)),
2891
+ C(ye).windowRange.value.padBottomPx > 0 ? (E(), I("div", {
2892
+ key: 1,
2893
+ class: "mrp-thumb-spacer",
2894
+ style: we({ height: `${C(ye).windowRange.value.padBottomPx}px` }),
2895
+ "aria-hidden": "true"
2896
+ }, null, 4)) : W("", !0)
2897
+ ], 544)) : W("", !0)
2898
+ ]),
2899
+ T("div", Zo, [
2900
+ St(i.$slots, "default", {}, void 0, !0)
2901
+ ]),
2902
+ C(Fe) ? (E(), I("div", Yo, [
2903
+ w[13] || (w[13] = T("div", null, "mach-report debug", -1)),
2904
+ T("div", null, "pages: " + R(C(Fe).pages) + " | window: [" + R(C(Fe).window) + "]", 1),
2905
+ T("div", null, "zoom: " + R(C(Fe).zoom) + " | load: " + R(C(Fe).loadMs), 1),
2906
+ T("div", null, "plan: " + R(C(Fe).planKB) + "KB", 1)
2907
+ ])) : W("", !0)
2908
+ ], 6));
2909
+ }
2910
+ }), Qo = /* @__PURE__ */ ke(Xo, [["__scopeId", "data-v-dfdeb309"]]), ms = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2911
+ __proto__: null,
2912
+ default: Qo
2913
+ }, Symbol.toStringTag, { value: "Module" }));
2914
+ export {
2915
+ yo as D,
2916
+ ce as M,
2917
+ kt as P,
2918
+ Dt as R,
2919
+ cs as S,
2920
+ wo as a,
2921
+ ln as b,
2922
+ de as c,
2923
+ jr as d,
2924
+ Qo as e,
2925
+ lr as f,
2926
+ wn as g,
2927
+ Pa as h,
2928
+ So as i,
2929
+ ls as j,
2930
+ fs as k,
2931
+ xo as l,
2932
+ us as m,
2933
+ ss as n,
2934
+ yn as o,
2935
+ Rr as p,
2936
+ is as q,
2937
+ ds as r,
2938
+ Po as s,
2939
+ ko as t,
2940
+ Ir as u,
2941
+ $o as v,
2942
+ xa as w,
2943
+ ka as x,
2944
+ Ea as y,
2945
+ ms as z
2946
+ };