@agile-team/mach-report 1.2.2 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/LICENSE +2 -4
  2. package/LICENSING.md +15 -0
  3. package/README.md +240 -92
  4. package/dist/ReportPreview-Dwdsyk9b.js +1558 -0
  5. package/dist/ReportPreview-VHAIfsz1.cjs +6 -0
  6. package/dist/index.cjs +5 -5
  7. package/dist/index.d.cts +738 -14
  8. package/dist/index.d.ts +738 -14
  9. package/dist/index.js +858 -805
  10. package/dist/pdf.cjs +47 -47
  11. package/dist/pdf.d.cts +155 -6
  12. package/dist/pdf.d.ts +155 -6
  13. package/dist/pdf.js +3542 -3466
  14. package/dist/plugin-Bl00j_CP.cjs +1 -0
  15. package/dist/plugin-DVScnZ4C.js +25 -0
  16. package/dist/report-params-BB85g7mg.js +10 -0
  17. package/dist/report-params-D1NeY-eR.cjs +1 -0
  18. package/dist/sql.cjs +65 -64
  19. package/dist/sql.d.cts +109 -5
  20. package/dist/sql.d.ts +109 -5
  21. package/dist/sql.js +7947 -7922
  22. package/dist/style-CFZ-HE2s.cjs +3 -0
  23. package/dist/{style-6ihHKVCM.js → style-DnmtG7Gl.js} +69 -81
  24. package/dist/style.css +1 -1
  25. package/dist/vue/async.d.cts +769 -335
  26. package/dist/vue/async.d.ts +769 -335
  27. package/dist/vue/index.d.cts +1321 -14
  28. package/dist/vue/index.d.ts +1321 -14
  29. package/dist/vue-async.cjs +1 -1
  30. package/dist/vue-async.js +11 -12
  31. package/dist/vue.cjs +1 -1
  32. package/dist/vue.js +130 -50
  33. package/dist/xlsx.cjs +20 -20
  34. package/dist/xlsx.d.cts +2292 -5
  35. package/dist/xlsx.d.ts +2292 -5
  36. package/dist/xlsx.js +5452 -5443
  37. package/package.json +7 -13
  38. package/dist/ReportPreview-CJLvkTVn.cjs +0 -6
  39. package/dist/ReportPreview-mZiGtf0L.js +0 -1231
  40. package/dist/builder/template-builder.d.ts +0 -69
  41. package/dist/compat/jh4j-template.d.ts +0 -12
  42. package/dist/defaults.d.ts +0 -27
  43. package/dist/format.d.ts +0 -48
  44. package/dist/layout/paginate.d.ts +0 -97
  45. package/dist/layout/textwrap.d.ts +0 -36
  46. package/dist/manager/api.d.ts +0 -45
  47. package/dist/manager/index.d.ts +0 -2
  48. package/dist/manager/types.d.ts +0 -50
  49. package/dist/manager.cjs +0 -1
  50. package/dist/manager.d.cts +0 -5
  51. package/dist/manager.d.ts +0 -5
  52. package/dist/manager.js +0 -104
  53. package/dist/pdf/font-loader.d.ts +0 -6
  54. package/dist/pdf/index.d.ts +0 -2
  55. package/dist/pdf/render-pdf.d.ts +0 -25
  56. package/dist/plugin-C4qpbdMJ.cjs +0 -1
  57. package/dist/plugin-DcmAPK_K.js +0 -85
  58. package/dist/render/canvas.d.ts +0 -76
  59. package/dist/render/dom.d.ts +0 -10
  60. package/dist/render/grid-geometry.d.ts +0 -41
  61. package/dist/render/style.d.ts +0 -33
  62. package/dist/render/window.d.ts +0 -23
  63. package/dist/schema/render-plan.d.ts +0 -96
  64. package/dist/schema/validate.d.ts +0 -15
  65. package/dist/sql/ast-check.d.ts +0 -14
  66. package/dist/sql/compile.d.ts +0 -31
  67. package/dist/sql/expr.d.ts +0 -21
  68. package/dist/sql/index.d.ts +0 -4
  69. package/dist/sql/tokenizer.d.ts +0 -25
  70. package/dist/style-Xq08-IsV.cjs +0 -3
  71. package/dist/units.d.ts +0 -11
  72. package/dist/vue/ReportParamPanel.d.ts +0 -19
  73. package/dist/vue/ReportPreview.d.ts +0 -209
  74. package/dist/vue/ReportToolbar.d.ts +0 -42
  75. package/dist/vue/adapters.d.ts +0 -40
  76. package/dist/vue/composables/useHighlight.d.ts +0 -8
  77. package/dist/vue/composables/usePageWindow.d.ts +0 -25
  78. package/dist/vue/composables/usePrintExport.d.ts +0 -40
  79. package/dist/vue/composables/useReportSearch.d.ts +0 -73
  80. package/dist/vue/composables/useZoom.d.ts +0 -15
  81. package/dist/vue/config.d.ts +0 -108
  82. package/dist/vue/controller.d.ts +0 -29
  83. package/dist/vue/errors.d.ts +0 -16
  84. package/dist/vue/injection-keys.d.ts +0 -14
  85. package/dist/vue/local-adapter.d.ts +0 -12
  86. package/dist/vue/pdf-exporter.d.ts +0 -13
  87. package/dist/vue/plugin.d.ts +0 -354
  88. package/dist/xlsx/render-xlsx.d.ts +0 -20
@@ -0,0 +1,1558 @@
1
+ import { computed as R, unref as F, ref as D, watch as Q, shallowRef as Fe, defineComponent as Je, nextTick as St, openBlock as w, createElementBlock as E, createElementVNode as $, toDisplayString as y, Fragment as xe, createCommentVNode as H, normalizeClass as oe, renderList as Se, createTextVNode as Ve, withKeys as ot, inject as Be, provide as ut, useCssVars as Bt, watchEffect as at, onMounted as Dt, onUnmounted as Wt, normalizeStyle as me, createBlock as Ot, createVNode as Lt, renderSlot as It } from "vue";
2
+ import { computePageWindow as Ht, renderPlanToImages as zt, renderPage as ct, validateRenderPlan as At, ReportSourceError as Nt, renderPlanToCanvas as qt } from "@agile-team/mach-report";
3
+ import { b as Ke, c as jt, d as Ut, a as Vt } from "./plugin-DVScnZ4C.js";
4
+ function dt(e) {
5
+ return e == null ? [] : Array.isArray(e) ? e.map(String).filter((t) => t !== "") : String(e).split(",").map((t) => t.trim()).filter((t) => t !== "");
6
+ }
7
+ function tr(e) {
8
+ return dt(e).join(",");
9
+ }
10
+ class Ue extends Error {
11
+ constructor(t) {
12
+ super(t), this.name = "PlanLoadError";
13
+ }
14
+ }
15
+ function nr(e = {}) {
16
+ const { baseUrl: t = "", headers: s, credentials: a, timeoutMs: r = 3e4 } = e, n = t.replace(/\/+$/, "");
17
+ return async ({ url: o, method: f, params: m, signal: d }) => {
18
+ let u = `${n}${o}`;
19
+ if (m && Object.keys(m).length > 0) {
20
+ const P = u.indexOf("#"), z = P >= 0 ? u.slice(P) : "", L = P >= 0 ? u.slice(0, P) : u, T = L.indexOf("?"), I = T >= 0 ? L.slice(0, T) : L, N = new URLSearchParams(T >= 0 ? L.slice(T + 1) : "");
21
+ for (const [Z, J] of Object.entries(m)) N.set(Z, J);
22
+ u = `${I}?${N}${z}`;
23
+ }
24
+ const c = (P, z) => {
25
+ const L = new Ue(P);
26
+ return Object.defineProperty(L, "cause", { value: z, configurable: !0, writable: !0 }), L;
27
+ };
28
+ if (d?.aborted)
29
+ throw c(`请求已取消: ${o}`, d.reason);
30
+ const g = new AbortController();
31
+ let v;
32
+ const S = () => {
33
+ g.signal.aborted || (v = "external", g.abort(d?.reason));
34
+ };
35
+ d?.addEventListener("abort", S, { once: !0 });
36
+ const B = setTimeout(() => {
37
+ g.signal.aborted || (v = "timeout", g.abort());
38
+ }, r);
39
+ try {
40
+ const P = await fetch(u, {
41
+ method: f.toUpperCase(),
42
+ headers: { Accept: "application/json", ...s },
43
+ credentials: a,
44
+ signal: g.signal
45
+ });
46
+ if (!P.ok)
47
+ throw new Ue(`HTTP ${P.status} ${o}`);
48
+ return await P.json();
49
+ } catch (P) {
50
+ throw v === "timeout" ? c(`请求超时(${r}ms): ${o}`, P) : v === "external" ? c(`请求已取消: ${o}`, P) : P instanceof Ue ? P : c(`请求失败(${o}): ${P instanceof Error ? P.message : String(P)}`, P);
51
+ } finally {
52
+ clearTimeout(B), d?.removeEventListener("abort", S);
53
+ }
54
+ };
55
+ }
56
+ function Kt(e, t, s = {}) {
57
+ const a = s.pxPerMm ?? 3.7795275590551185, r = R(() => Math.max(0, F(s.gapPx) ?? 18)), n = D(0), o = D(800), f = R(
58
+ () => (e.value?.pages ?? []).map((g) => g.pageHeightMm * a)
59
+ ), m = R(() => {
60
+ const g = e.value?.pages ?? [];
61
+ let v = 0, S = 0;
62
+ for (const B of g)
63
+ v += B.pageHeightMm * a + r.value, S = Math.max(S, B.pageWidthMm * a);
64
+ return { w: S, h: v };
65
+ }), d = R(
66
+ () => Ht({
67
+ pageHeightsPx: f.value,
68
+ viewportHeightPx: o.value / t.value,
69
+ scrollTopPx: n.value / t.value,
70
+ overscan: 1,
71
+ gapPx: r.value
72
+ })
73
+ ), u = R(() => {
74
+ const g = e.value;
75
+ if (!g) return [];
76
+ const { start: v, end: S } = d.value;
77
+ return S < v ? [] : g.pages.slice(v, S + 1).map((B, P) => ({ page: B, index: v + P }));
78
+ });
79
+ function c(g, v) {
80
+ let S = 0;
81
+ return (B) => {
82
+ S || (S = requestAnimationFrame(() => {
83
+ if (S = 0, n.value = B.scrollTop, o.value = B.clientHeight || 800, v.value <= 0) return;
84
+ const P = B.querySelectorAll(".mrp-page-holder");
85
+ if (!P.length) return;
86
+ const z = B.getBoundingClientRect().top + 56;
87
+ let L = 1;
88
+ P.forEach((T) => {
89
+ T.getBoundingClientRect().top <= z && (L = Number(T.dataset.page ?? 1));
90
+ }), g.value = Math.max(1, Math.min(v.value, L));
91
+ }));
92
+ };
93
+ }
94
+ return {
95
+ contentSize: m,
96
+ windowRange: d,
97
+ visiblePages: u,
98
+ makeScrollHandler: c,
99
+ refreshViewport(g) {
100
+ g && (o.value = g.clientHeight || 800);
101
+ }
102
+ };
103
+ }
104
+ function Zt(e) {
105
+ const t = D(1), s = D("fit");
106
+ function a() {
107
+ requestAnimationFrame(() => {
108
+ const n = e();
109
+ !n || !n.viewport || (t.value = Math.min(
110
+ 1,
111
+ Math.max(0.3, (n.viewport.clientWidth - 48) / Math.max(1, n.pageWidthPx))
112
+ ));
113
+ });
114
+ }
115
+ function r(n) {
116
+ n === "fit" ? (s.value = "fit", a()) : (s.value = "raw", t.value = n / 100);
117
+ }
118
+ return { zoom: t, zoomMode: s, applyFitZoom: a, setZoom: r };
119
+ }
120
+ const De = 8;
121
+ function We() {
122
+ return new Promise((e) => setTimeout(e, 0));
123
+ }
124
+ function Re(e) {
125
+ return `p${Math.round(e.pageWidthMm)}x${Math.round(e.pageHeightMm)}`;
126
+ }
127
+ function Ge(e) {
128
+ const t = /* @__PURE__ */ new Map();
129
+ return e.pages.forEach((r) => {
130
+ t.has(Re(r)) || t.set(Re(r), r);
131
+ }), `<!doctype html><html><head><meta charset="utf-8"><style>${`.mr-page{margin:0 auto;page-break-after:always;}
132
+ .mr-page tr{break-inside:avoid;page-break-inside:avoid;}
133
+ .mr-comp{break-inside:avoid;page-break-inside:avoid;}
134
+ ${[...t.values()].map(
135
+ (r) => `@page ${Re(r)}{size:${Math.round(r.pageWidthMm)}mm ${Math.round(r.pageHeightMm)}mm;margin:0;}`
136
+ ).join(`
137
+ `)}
138
+ body{margin:0;background:#fff;}`}</style></head><body>`;
139
+ }
140
+ function Ye(e) {
141
+ const t = ct(e, 96, {}, document);
142
+ return t.style.page = Re(e), t.outerHTML;
143
+ }
144
+ function ft(e) {
145
+ return { head: Ge(e), pageChunks: e.pages.map(Ye) };
146
+ }
147
+ async function rr(e, t = {}) {
148
+ const s = {
149
+ schemaVersion: "mach-report-batch-print",
150
+ pages: e.flatMap((o) => o.pages)
151
+ };
152
+ if (s.pages.length === 0) return;
153
+ const a = Ge(s), r = document.createElement("iframe");
154
+ r.style.cssText = "position:fixed;right:0;bottom:0;width:0;height:0;border:0;visibility:hidden;", document.body.appendChild(r);
155
+ let n = !1;
156
+ try {
157
+ const o = r.contentDocument;
158
+ o.open(), o.write(a);
159
+ for (let f = 0; f < s.pages.length; f++)
160
+ o.write(Ye(s.pages[f])), f % De === De - 1 && (t.onProgress?.(f + 1, s.pages.length), await We());
161
+ o.write("</body></html>"), o.close(), await We(), t.onProgress?.(s.pages.length, s.pages.length), n = !0, r.contentWindow?.focus(), r.contentWindow?.print();
162
+ } catch (o) {
163
+ t.onError?.(o instanceof Error ? `批量打印失败: ${o.message}` : "批量打印失败");
164
+ } finally {
165
+ n ? setTimeout(() => r.remove(), 6e4) : r.remove();
166
+ }
167
+ }
168
+ function Jt(e) {
169
+ const { head: t, pageChunks: s } = ft(e);
170
+ return {
171
+ 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>/, "")}`}${s.join("")}</body></html>`,
172
+ filename: "mach-report.doc"
173
+ };
174
+ }
175
+ function Gt(e, t) {
176
+ let s = null, a = !1, r = !1, n = 0;
177
+ const o = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map();
178
+ let m = null, d = null, u = null, c = null, g = null;
179
+ function v(l, p) {
180
+ return !r && e.value === l && n === p;
181
+ }
182
+ function S() {
183
+ if (r) return;
184
+ const l = [...o.values()].reverse().find((p) => v(p.plan, p.epoch))?.format ?? null;
185
+ l !== m && (m = l, t.onBusy?.(l));
186
+ }
187
+ function B(l, p, h) {
188
+ const k = {};
189
+ return o.set(k, { plan: l, epoch: p, format: h }), S(), k;
190
+ }
191
+ function P(l) {
192
+ o.delete(l), S();
193
+ }
194
+ function z() {
195
+ for (const [l, p] of f)
196
+ v(p.plan, p.epoch) || (l.close(), f.delete(l));
197
+ }
198
+ const L = Q(e, () => {
199
+ n++, S(), z();
200
+ }, { flush: "sync" });
201
+ function T() {
202
+ s?.remove(), s = null;
203
+ }
204
+ function I() {
205
+ r = !0, n++, L(), T(), z(), o.clear(), t.onPrinting?.(!1);
206
+ }
207
+ function N(l, p) {
208
+ const h = URL.createObjectURL(l);
209
+ setTimeout(() => URL.revokeObjectURL(h), 1e4);
210
+ const k = document.createElement("a");
211
+ k.href = h, k.download = p, k.click();
212
+ }
213
+ async function Z() {
214
+ if (a) return;
215
+ const l = e.value;
216
+ if (r || !l || l.pages.length === 0) return;
217
+ const p = n;
218
+ a = !0, t.onPrinting?.(!0), T();
219
+ const h = Ge(l);
220
+ s = document.createElement("iframe"), s.style.cssText = "position:fixed;right:0;bottom:0;width:0;height:0;border:0;visibility:hidden;", document.body.appendChild(s);
221
+ const k = s;
222
+ try {
223
+ const C = k.contentDocument;
224
+ C.open(), C.write(h);
225
+ for (let V = 0; V < l.pages.length; V++)
226
+ if (C.write(Ye(l.pages[V])), V % De === De - 1 && await We(), k !== s) return;
227
+ if (C.write("</body></html>"), C.close(), await We(), !v(l, p) || k !== s) return;
228
+ k.contentWindow?.focus(), k.contentWindow?.print();
229
+ } catch {
230
+ k === s && T(), v(l, p) && t.onError("调用打印失败,请改用导出 PDF", "print");
231
+ } finally {
232
+ a = !1, r || t.onPrinting?.(!1);
233
+ }
234
+ }
235
+ function J(l, p) {
236
+ if (d?.plan === l && d.epoch === p) return d.promise;
237
+ const h = Promise.resolve().then(() => {
238
+ if (!v(l, p)) throw new Error("报表已切换或卸载");
239
+ return t.getPdfExporter()(l, (k) => {
240
+ v(l, p) && t.onWarning?.(k);
241
+ });
242
+ }).finally(() => {
243
+ d?.promise === h && (d = null);
244
+ });
245
+ return d = { plan: l, epoch: p, promise: h }, h;
246
+ }
247
+ async function W() {
248
+ const l = e.value;
249
+ if (r || !l || l.pages.length === 0) return;
250
+ const p = n;
251
+ if (u?.plan === l && u.epoch === p) return u.promise;
252
+ const h = B(l, p, "PDF"), k = (async () => {
253
+ try {
254
+ const C = await J(l, p);
255
+ if (!v(l, p)) return;
256
+ N(new Blob([C], { type: "application/pdf" }), "mach-report.pdf");
257
+ } catch (C) {
258
+ v(l, p) && t.onError(C instanceof Error ? `PDF 导出失败: ${C.message}` : "PDF 导出失败", "pdf");
259
+ } finally {
260
+ P(h), u?.token === h && (u = null);
261
+ }
262
+ })();
263
+ return u = { plan: l, epoch: p, promise: k, token: h }, k;
264
+ }
265
+ async function _() {
266
+ const l = e.value;
267
+ if (r || !l || l.pages.length === 0) return;
268
+ const p = n;
269
+ if (c?.plan === l && c.epoch === p) return c.promise;
270
+ const h = B(l, p, "Excel"), k = (async () => {
271
+ try {
272
+ const { renderPlanToXlsx: C } = await import("@agile-team/mach-report/xlsx");
273
+ if (!v(l, p)) return;
274
+ const { buffer: V, warnings: j } = await C(l);
275
+ if (!v(l, p) || (j.length > 0 && t.onWarning?.(`Excel 有 ${j.length} 处内容未导出:${j.slice(0, 2).join(";")}`), !v(l, p))) return;
276
+ N(new Blob([V], {
277
+ type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
278
+ }), "mach-report.xlsx");
279
+ } catch (C) {
280
+ v(l, p) && t.onError(C instanceof Error ? `Excel 导出失败: ${C.message}` : "Excel 导出失败", "export");
281
+ } finally {
282
+ P(h), c?.token === h && (c = null);
283
+ }
284
+ })();
285
+ return c = { plan: l, epoch: p, promise: k, token: h }, k;
286
+ }
287
+ async function G() {
288
+ const l = e.value;
289
+ if (r || !l || l.pages.length === 0) return;
290
+ const p = n;
291
+ if (g?.plan === l && g.epoch === p) return g.promise;
292
+ const h = B(l, p, "图片"), k = (async () => {
293
+ try {
294
+ const { blobs: C } = await zt(l, {
295
+ dpr: Math.min(2, typeof devicePixelRatio == "number" ? devicePixelRatio : 1)
296
+ });
297
+ if (!v(l, p)) return;
298
+ C.forEach((V, j) => {
299
+ N(V, C.length > 1 ? `mach-report-page-${j + 1}.png` : "mach-report.png");
300
+ });
301
+ } catch (C) {
302
+ v(l, p) && t.onError(
303
+ C instanceof Error ? `图片导出失败: ${C.message}` : "图片导出失败",
304
+ "export"
305
+ );
306
+ } finally {
307
+ P(h), g?.token === h && (g = null);
308
+ }
309
+ })();
310
+ return g = { plan: l, epoch: p, promise: k, token: h }, k;
311
+ }
312
+ function ae() {
313
+ const l = e.value;
314
+ if (!(r || !l || l.pages.length === 0))
315
+ try {
316
+ const { html: p, filename: h } = Jt(l);
317
+ N(new Blob([p], { type: "application/msword;charset=utf-8" }), h);
318
+ } catch (p) {
319
+ t.onError(
320
+ p instanceof Error ? `Word 导出失败: ${p.message}` : "Word 导出失败",
321
+ "export"
322
+ );
323
+ }
324
+ }
325
+ async function q(l) {
326
+ const p = e.value;
327
+ if (!(r || !p || p.pages.length === 0)) {
328
+ if (l === "pdf") {
329
+ await W();
330
+ return;
331
+ }
332
+ if (l === "xlsx" || l === "excel") {
333
+ await _();
334
+ return;
335
+ }
336
+ if (l === "png" || l === "image") {
337
+ await G();
338
+ return;
339
+ }
340
+ if (l === "word" || l === "doc") {
341
+ ae();
342
+ return;
343
+ }
344
+ if (l !== "html") {
345
+ t.onError(`不支持的导出格式:${l}`, "export");
346
+ return;
347
+ }
348
+ try {
349
+ const { head: h, pageChunks: k } = ft(p), C = `${h}${k.join("")}</body></html>`;
350
+ N(new Blob([C], { type: "text/html;charset=utf-8" }), "mach-report.html");
351
+ } catch (h) {
352
+ t.onError(h instanceof Error ? `HTML 导出失败: ${h.message}` : "HTML 导出失败", "export");
353
+ }
354
+ }
355
+ }
356
+ function Y() {
357
+ const l = e.value;
358
+ if (r || !l || l.pages.length === 0) return;
359
+ const p = n, h = window.open("", "_blank");
360
+ if (!h) {
361
+ t.onError("浏览器拦截了弹窗,请允许弹窗后重试", "pdf");
362
+ return;
363
+ }
364
+ f.set(h, { plan: l, epoch: p });
365
+ const k = B(l, p, "PDF");
366
+ J(l, p).then((C) => {
367
+ if (!v(l, p) || h.closed) {
368
+ f.delete(h) && h.close();
369
+ return;
370
+ }
371
+ const V = URL.createObjectURL(new Blob([C], { type: "application/pdf" }));
372
+ setTimeout(() => URL.revokeObjectURL(V), 6e4);
373
+ const j = h.document;
374
+ j.title = "PDF 预览", j.documentElement.style.height = "100%", j.body.style.cssText = "margin:0;height:100%;";
375
+ const se = j.createElement("iframe");
376
+ se.title = "PDF 预览", se.style.cssText = "display:block;width:100%;height:100%;border:0;", se.src = V, j.body.replaceChildren(se), f.delete(h);
377
+ }).catch((C) => {
378
+ h.close(), f.delete(h), v(l, p) && t.onError(C instanceof Error ? `PDF 预览失败: ${C.message}` : "PDF 预览失败", "pdf");
379
+ }).finally(() => P(k));
380
+ }
381
+ return {
382
+ print: Z,
383
+ exportAs: q,
384
+ exportImages: G,
385
+ exportWord: ae,
386
+ openPdfWindow: Y,
387
+ releasePrintFrame: T,
388
+ dispose: I
389
+ };
390
+ }
391
+ const pt = "mrp-hit";
392
+ function Yt(e) {
393
+ e.querySelectorAll(`mark.${pt}`).forEach((s) => {
394
+ const a = s.parentNode;
395
+ if (a) {
396
+ for (; s.firstChild; ) a.insertBefore(s.firstChild, s);
397
+ s.remove(), a.normalize();
398
+ }
399
+ });
400
+ }
401
+ function Xt(e, t) {
402
+ const s = t.trim();
403
+ if (!s) return 0;
404
+ const a = s.toLowerCase(), r = document.createTreeWalker(e, NodeFilter.SHOW_TEXT, {
405
+ acceptNode(f) {
406
+ const m = f.parentElement;
407
+ return !m || m.closest("mark") || /^(SCRIPT|STYLE)$/.test(m.tagName) ? NodeFilter.FILTER_REJECT : (f.nodeValue ?? "").toLowerCase().includes(a) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_REJECT;
408
+ }
409
+ }), n = [];
410
+ for (let f = r.nextNode(); f; f = r.nextNode()) n.push(f);
411
+ let o = 0;
412
+ for (const f of n) {
413
+ const m = f.nodeValue ?? "", d = m.toLowerCase(), u = f.parentElement;
414
+ if (!u) continue;
415
+ const c = document.createDocumentFragment();
416
+ let g = 0, v = d.indexOf(a);
417
+ for (; v >= 0; ) {
418
+ v > g && c.appendChild(document.createTextNode(m.slice(g, v)));
419
+ const S = document.createElement("mark");
420
+ S.className = pt, S.textContent = m.slice(v, v + s.length), c.appendChild(S), o++, g = v + s.length, v = d.indexOf(a, g);
421
+ }
422
+ g < m.length && c.appendChild(document.createTextNode(m.slice(g))), u.replaceChild(c, f);
423
+ }
424
+ return o;
425
+ }
426
+ function st(e, t) {
427
+ let s = 0, a = e.toLowerCase().indexOf(t);
428
+ for (; a >= 0; )
429
+ s++, a = e.toLowerCase().indexOf(t, a + t.length);
430
+ return s;
431
+ }
432
+ function Qt(e) {
433
+ const { plan: t, gotoPage: s, highlight: a, clearHighlights: r } = e, n = e.debounceMs ?? 200, o = D(!1), f = D(""), m = D(""), d = D(0);
434
+ let u = null;
435
+ const c = R(() => {
436
+ const T = f.value.trim().toLowerCase(), I = t.value;
437
+ if (!T || !I) return [];
438
+ const N = [];
439
+ return I.pages.forEach((Z, J) => {
440
+ for (const W of Z.components)
441
+ if (W.grid) {
442
+ for (const _ of W.grid.cells ?? [])
443
+ for (const G of _ ?? [])
444
+ if (typeof G?.text == "string")
445
+ for (let ae = 0; ae < st(G.text, T); ae++) N.push(J);
446
+ } else if (W.kind === "text" && typeof W.text == "string")
447
+ for (let _ = 0; _ < st(W.text, T); _++) N.push(J);
448
+ }), N;
449
+ }), g = R(() => c.value.length);
450
+ function v(T) {
451
+ if (m.value = T, u && clearTimeout(u), T.trim() === "") {
452
+ u = null, f.value = "", d.value = 0;
453
+ return;
454
+ }
455
+ u = setTimeout(() => {
456
+ u = null, f.value = m.value, d.value = 0;
457
+ const I = c.value[0];
458
+ I != null && s(I + 1);
459
+ }, n);
460
+ }
461
+ function S(T) {
462
+ const I = c.value.length;
463
+ I !== 0 && (d.value = (d.value + T + I) % I, s(c.value[d.value] + 1));
464
+ }
465
+ function B() {
466
+ o.value = !o.value;
467
+ }
468
+ function P(T) {
469
+ const I = f.value.trim();
470
+ I && a(T, I);
471
+ }
472
+ function z(T) {
473
+ r(T);
474
+ }
475
+ function L() {
476
+ m.value = "", f.value = "", d.value = 0, u && clearTimeout(u), u = null;
477
+ }
478
+ return {
479
+ visible: o,
480
+ query: f,
481
+ matchIndex: d,
482
+ matchCount: g,
483
+ toggle: B,
484
+ onInput: v,
485
+ onNav: S,
486
+ apply: P,
487
+ clear: z,
488
+ reset: L
489
+ };
490
+ }
491
+ function _t(e, t) {
492
+ const s = R(() => {
493
+ if (e.value) return !0;
494
+ if (typeof location > "u") return !1;
495
+ try {
496
+ return new URLSearchParams(location.search).get("mrp-debug") === "1";
497
+ } catch {
498
+ return !1;
499
+ }
500
+ }), a = R(() => !s.value || !t.plan.value ? 0 : Math.round(JSON.stringify(t.plan.value).length / 1024)), r = R(() => !s.value || !t.plan.value ? null : {
501
+ pages: t.pageCount.value,
502
+ window: `${t.windowRange.value.start}-${t.windowRange.value.end}`,
503
+ zoom: `${Math.round(t.zoom.value * 100)}%`,
504
+ loadMs: `${t.loadMs.value}ms`,
505
+ planKB: a.value
506
+ });
507
+ return { enabled: s, debugStats: r };
508
+ }
509
+ function en(e, t) {
510
+ const { thumbsRoot: s, visible: a, renderThumbCanvas: r } = t;
511
+ let n = null;
512
+ function o(d, u) {
513
+ if (!e.value || d.childElementCount > 0) return;
514
+ const c = r(u);
515
+ c && (c.style.width = "100%", c.style.height = "100%", c.style.display = "block", d.appendChild(c));
516
+ }
517
+ return { schedule: () => {
518
+ !a.value || !e.value || !s.value || typeof IntersectionObserver > "u" || (n?.disconnect(), n = new IntersectionObserver(
519
+ (d) => {
520
+ for (const u of d) {
521
+ if (!u.isIntersecting) continue;
522
+ const c = u.target;
523
+ o(c, Number(c.dataset.thumb ?? 1) - 1), n?.unobserve(c);
524
+ }
525
+ },
526
+ { root: s.value, rootMargin: "200px" }
527
+ ), s.value.querySelectorAll("[data-thumb]").forEach((d) => {
528
+ n.observe(d);
529
+ }));
530
+ }, destroy: () => {
531
+ n?.disconnect(), n = null;
532
+ } };
533
+ }
534
+ function tn() {
535
+ const e = Fe(0);
536
+ return {
537
+ loadMs: e,
538
+ start() {
539
+ return typeof performance < "u" ? performance.now() : 0;
540
+ },
541
+ end(t) {
542
+ e.value = t ? Math.round(performance.now() - t) : 0;
543
+ }
544
+ };
545
+ }
546
+ const nn = { class: "mrp-toolbar" }, rn = { class: "mrp-title" }, on = ["disabled"], an = { class: "mrp-pageinfo" }, sn = ["disabled"], ln = {
547
+ key: 1,
548
+ class: "mrp-search"
549
+ }, un = ["placeholder", "value"], cn = {
550
+ key: 0,
551
+ class: "mrp-search-count"
552
+ }, dn = ["disabled"], fn = ["disabled"], pn = /* @__PURE__ */ Je({
553
+ __name: "ReportToolbar",
554
+ props: {
555
+ pageCount: {},
556
+ currentPage: {},
557
+ zoomMode: {},
558
+ zoom: {},
559
+ showExport: { type: Boolean },
560
+ showPrint: { type: Boolean },
561
+ showPdfWindow: { type: Boolean },
562
+ messages: {},
563
+ search: {},
564
+ thumbsVisible: { type: Boolean }
565
+ },
566
+ emits: ["goto", "zoom", "export", "print", "pdf-window", "search-input", "search-nav", "search-toggle", "thumbs-toggle"],
567
+ setup(e) {
568
+ const t = e, s = D(null);
569
+ Q(
570
+ () => t.search.visible,
571
+ (r) => {
572
+ r && St(() => s.value?.focus());
573
+ }
574
+ );
575
+ function a(r, n, o) {
576
+ return r.replace("{cur}", String(n)).replace("{total}", String(o));
577
+ }
578
+ return (r, n) => (w(), E("div", nn, [
579
+ $("span", rn, y(e.messages.title), 1),
580
+ e.pageCount > 0 ? (w(), E(xe, { key: 0 }, [
581
+ $("button", {
582
+ class: "mrp-nav",
583
+ type: "button",
584
+ disabled: e.currentPage <= 1,
585
+ onClick: n[0] || (n[0] = (o) => r.$emit("goto", e.currentPage - 1))
586
+ }, y(e.messages.prevPage), 9, on),
587
+ $("span", an, y(a(e.messages.pageInfo, e.currentPage, e.pageCount)), 1),
588
+ $("button", {
589
+ class: "mrp-nav",
590
+ type: "button",
591
+ disabled: e.currentPage >= e.pageCount,
592
+ onClick: n[1] || (n[1] = (o) => r.$emit("goto", e.currentPage + 1))
593
+ }, y(e.messages.nextPage), 9, sn)
594
+ ], 64)) : H("", !0),
595
+ n[17] || (n[17] = $("span", { class: "mrp-spacer" }, null, -1)),
596
+ e.search.visible ? (w(), E("div", ln, [
597
+ $("input", {
598
+ ref_key: "searchInputRef",
599
+ ref: s,
600
+ class: "mrp-search-input",
601
+ type: "text",
602
+ placeholder: e.messages.searchPlaceholder,
603
+ value: e.search.query,
604
+ onInput: n[2] || (n[2] = (o) => r.$emit("search-input", o.target.value))
605
+ }, null, 40, un),
606
+ e.search.query ? (w(), E("span", cn, y(a(e.messages.matchInfo, e.search.matchIndex + 1, e.search.matchCount)), 1)) : H("", !0),
607
+ $("button", {
608
+ class: "mrp-nav",
609
+ type: "button",
610
+ disabled: e.search.matchCount === 0,
611
+ onClick: n[3] || (n[3] = (o) => r.$emit("search-nav", -1))
612
+ }, y(e.messages.prevMatch), 9, dn),
613
+ $("button", {
614
+ class: "mrp-nav",
615
+ type: "button",
616
+ disabled: e.search.matchCount === 0,
617
+ onClick: n[4] || (n[4] = (o) => r.$emit("search-nav", 1))
618
+ }, y(e.messages.nextMatch), 9, fn)
619
+ ])) : H("", !0),
620
+ $("button", {
621
+ class: oe(["mrp-nav", { "mrp-active": e.search.visible }]),
622
+ type: "button",
623
+ title: "Ctrl+F",
624
+ onClick: n[5] || (n[5] = (o) => r.$emit("search-toggle"))
625
+ }, " 🔍 ", 2),
626
+ $("button", {
627
+ class: oe(["mrp-nav", { "mrp-active": e.thumbsVisible }]),
628
+ type: "button",
629
+ onClick: n[6] || (n[6] = (o) => r.$emit("thumbs-toggle"))
630
+ }, " ▦ " + y(e.messages.thumbnails), 3),
631
+ $("button", {
632
+ class: oe(["mrp-nav", { "mrp-active": e.zoomMode === "fit" }]),
633
+ type: "button",
634
+ onClick: n[7] || (n[7] = (o) => r.$emit("zoom", "fit"))
635
+ }, y(e.messages.fitWidth), 3),
636
+ $("button", {
637
+ class: oe(["mrp-nav", { "mrp-active": e.zoomMode === "raw" && Math.round(e.zoom * 100) === 100 }]),
638
+ type: "button",
639
+ onClick: n[8] || (n[8] = (o) => r.$emit("zoom", 100))
640
+ }, " 100% ", 2),
641
+ $("button", {
642
+ class: oe(["mrp-nav", { "mrp-active": e.zoomMode === "raw" && Math.round(e.zoom * 100) === 150 }]),
643
+ type: "button",
644
+ onClick: n[9] || (n[9] = (o) => r.$emit("zoom", 150))
645
+ }, " 150% ", 2),
646
+ e.showExport ? (w(), E("button", {
647
+ key: 2,
648
+ class: "mrp-nav",
649
+ type: "button",
650
+ onClick: n[10] || (n[10] = (o) => r.$emit("export", "html"))
651
+ }, y(e.messages.exportHtml), 1)) : H("", !0),
652
+ e.showExport ? (w(), E("button", {
653
+ key: 3,
654
+ class: "mrp-nav",
655
+ type: "button",
656
+ onClick: n[11] || (n[11] = (o) => r.$emit("export", "pdf"))
657
+ }, y(e.messages.exportPdf), 1)) : H("", !0),
658
+ e.showExport ? (w(), E("button", {
659
+ key: 4,
660
+ class: "mrp-nav",
661
+ type: "button",
662
+ onClick: n[12] || (n[12] = (o) => r.$emit("export", "xlsx"))
663
+ }, y(e.messages.exportExcel), 1)) : H("", !0),
664
+ e.showExport ? (w(), E("button", {
665
+ key: 5,
666
+ class: "mrp-nav",
667
+ type: "button",
668
+ onClick: n[13] || (n[13] = (o) => r.$emit("export", "png"))
669
+ }, y(e.messages.exportImage), 1)) : H("", !0),
670
+ e.showExport ? (w(), E("button", {
671
+ key: 6,
672
+ class: "mrp-nav",
673
+ type: "button",
674
+ onClick: n[14] || (n[14] = (o) => r.$emit("export", "word"))
675
+ }, y(e.messages.exportWord), 1)) : H("", !0),
676
+ e.showPrint ? (w(), E("button", {
677
+ key: 7,
678
+ class: "mrp-nav",
679
+ type: "button",
680
+ onClick: n[15] || (n[15] = (o) => r.$emit("print"))
681
+ }, y(e.messages.print), 1)) : H("", !0),
682
+ e.showPdfWindow ? (w(), E("button", {
683
+ key: 8,
684
+ class: "mrp-nav",
685
+ type: "button",
686
+ onClick: n[16] || (n[16] = (o) => r.$emit("pdf-window"))
687
+ }, y(e.messages.pdfWindow), 1)) : H("", !0)
688
+ ]));
689
+ }
690
+ }), Xe = (e, t) => {
691
+ const s = e.__vccOpts || e;
692
+ for (const [a, r] of t)
693
+ s[a] = r;
694
+ return s;
695
+ }, mn = /* @__PURE__ */ Xe(pn, [["__scopeId", "data-v-48cc0980"]]), vn = { class: "mrp-params" }, gn = { class: "mrp-params-title" }, hn = { class: "mrp-params-grid" }, bn = { class: "mrp-param-label" }, wn = {
696
+ key: 0,
697
+ class: "mrp-param-star"
698
+ }, yn = ["value", "onChange"], Pn = {
699
+ value: "",
700
+ disabled: "",
701
+ hidden: ""
702
+ }, xn = ["value"], En = ["type", "placeholder", "value", "onInput"], $n = { class: "mrp-params-actions" }, kn = /* @__PURE__ */ Je({
703
+ __name: "ReportParamPanel",
704
+ props: {
705
+ defs: {},
706
+ modelValue: {},
707
+ messages: {},
708
+ attempted: { type: Boolean }
709
+ },
710
+ emits: ["update:modelValue", "query", "reset"],
711
+ setup(e, { emit: t }) {
712
+ const s = e, a = t, r = D({ ...s.modelValue });
713
+ Q(
714
+ () => s.modelValue,
715
+ (m) => {
716
+ r.value = { ...m };
717
+ }
718
+ );
719
+ const n = R(
720
+ () => s.defs.map((m) => ({
721
+ def: m,
722
+ label: m.label ?? m.field,
723
+ value: r.value[m.field] ?? ""
724
+ }))
725
+ );
726
+ function o(m, d) {
727
+ r.value = { ...r.value, [m]: d }, a("update:modelValue", { ...r.value });
728
+ }
729
+ function f(m) {
730
+ const d = s.defs.find((u) => u.field === m);
731
+ return s.attempted && d?.required === !0 && !(r.value[m] ?? "").trim();
732
+ }
733
+ return (m, d) => (w(), E("div", vn, [
734
+ $("span", gn, y(e.messages.paramsTitle), 1),
735
+ $("div", hn, [
736
+ (w(!0), E(xe, null, Se(n.value, (u) => (w(), E("label", {
737
+ key: u.def.field,
738
+ class: oe(["mrp-param", { "mrp-param-missing": f(u.def.field) }])
739
+ }, [
740
+ $("span", bn, [
741
+ Ve(y(u.label), 1),
742
+ u.def.required ? (w(), E("i", wn, "*")) : H("", !0)
743
+ ]),
744
+ (u.def.type ?? "text") === "select" ? (w(), E("select", {
745
+ key: 0,
746
+ class: "mrp-param-input",
747
+ value: u.value,
748
+ onChange: (c) => o(u.def.field, c.target.value),
749
+ onKeydown: d[0] || (d[0] = ot((c) => m.$emit("query"), ["enter"]))
750
+ }, [
751
+ $("option", Pn, y(u.def.placeholder ?? `请选择${u.label}`), 1),
752
+ (w(!0), E(xe, null, Se(u.def.options ?? [], (c) => (w(), E("option", {
753
+ key: c.value,
754
+ value: c.value
755
+ }, y(c.label), 9, xn))), 128))
756
+ ], 40, yn)) : (w(), E("input", {
757
+ key: 1,
758
+ class: "mrp-param-input",
759
+ type: u.def.type === "number" ? "number" : u.def.type === "date" ? "date" : "text",
760
+ placeholder: u.def.placeholder ?? `请输入${u.label}`,
761
+ value: u.value,
762
+ onInput: (c) => o(u.def.field, c.target.value),
763
+ onKeydown: d[1] || (d[1] = ot((c) => m.$emit("query"), ["enter"]))
764
+ }, null, 40, En))
765
+ ], 2))), 128))
766
+ ]),
767
+ $("div", $n, [
768
+ $("button", {
769
+ class: "mrp-nav mrp-param-query",
770
+ type: "button",
771
+ onClick: d[2] || (d[2] = (u) => m.$emit("query"))
772
+ }, y(e.messages.query), 1),
773
+ $("button", {
774
+ class: "mrp-nav",
775
+ type: "button",
776
+ onClick: d[3] || (d[3] = (u) => m.$emit("reset"))
777
+ }, y(e.messages.reset), 1)
778
+ ])
779
+ ]));
780
+ }
781
+ }), Cn = /* @__PURE__ */ Xe(kn, [["__scopeId", "data-v-aafce92d"]]), Mn = {
782
+ title: "报表预览",
783
+ prevPage: "‹ 上一页",
784
+ nextPage: "下一页 ›",
785
+ pageInfo: "{cur} / {total}",
786
+ fitWidth: "适宽",
787
+ exportHtml: "导出 HTML",
788
+ exportPdf: "导出 PDF",
789
+ exportExcel: "导出 Excel",
790
+ exportImage: "导出图片",
791
+ exportWord: "导出 Word",
792
+ exporting: "正在生成 {format}…",
793
+ print: "打印",
794
+ pdfWindow: "PDF 窗口",
795
+ loading: "报表渲染中…",
796
+ empty: "暂无预览数据",
797
+ errorPrefix: "",
798
+ retry: "重试",
799
+ pdfFontUnavailable: "PDF 字体尚未就绪,请联系管理员检查字体配置;预览及其它导出仍可使用。",
800
+ searchPlaceholder: "搜索报表内容",
801
+ matchInfo: "{cur}/{total}",
802
+ prevMatch: "‹",
803
+ nextMatch: "›",
804
+ thumbnails: "缩略图",
805
+ paramsTitle: "查询条件",
806
+ query: "查 询",
807
+ reset: "重 置",
808
+ paramRequired: "请填写{label}"
809
+ }, Fn = {
810
+ shellBg: "#525659",
811
+ shellFg: "#e8e8e8",
812
+ toolbarBg: "#323639",
813
+ toolbarBorder: "#22252a",
814
+ toolbarFg: "#e8e8e8",
815
+ btnFg: "#cfcfcf",
816
+ btnBorder: "#4a4d52",
817
+ btnHoverBg: "#414549",
818
+ btnHoverFg: "#ffffff",
819
+ btnActiveBg: "#2d5fb8"
820
+ };
821
+ function Rn(e = {}) {
822
+ return { ...e, defaults: e.defaults ?? {}, presets: e.presets ?? {} };
823
+ }
824
+ function or(e) {
825
+ return e;
826
+ }
827
+ const ce = {
828
+ showExport: !0,
829
+ showPrint: !0,
830
+ showPdfWindow: !0,
831
+ showParams: !0,
832
+ gapPx: 18,
833
+ pdfFontUrl: "/simhei.ttf",
834
+ logger: console
835
+ }, ar = { warn: () => {
836
+ }, info: () => {
837
+ } };
838
+ function Te(e, t) {
839
+ return {
840
+ ...e,
841
+ ...t,
842
+ theme: { ...e?.theme, ...t?.theme },
843
+ messages: { ...e?.messages, ...t?.messages }
844
+ };
845
+ }
846
+ function Tn(e, t) {
847
+ const s = t ? e?.presets?.[t] : e?.defaultPreset ? e?.presets?.[e.defaultPreset] : void 0, a = Te(e?.defaults, s);
848
+ return {
849
+ showExport: a.showExport ?? ce.showExport,
850
+ showPrint: a.showPrint ?? ce.showPrint,
851
+ showPdfWindow: a.showPdfWindow ?? ce.showPdfWindow,
852
+ showParams: a.showParams ?? ce.showParams,
853
+ gapPx: a.gapPx ?? ce.gapPx,
854
+ pdfFontUrl: a.pdfFontUrl ?? ce.pdfFontUrl,
855
+ theme: { ...Fn, ...a.theme },
856
+ messages: { ...Mn, ...a.messages },
857
+ logger: a.logger ?? ce.logger
858
+ };
859
+ }
860
+ function Sn(e) {
861
+ const t = {};
862
+ 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;
863
+ }
864
+ function sr(e) {
865
+ const t = Be(Ke, null), s = R(() => {
866
+ const a = t?.value ?? null, r = "defaults" in e || "presets" in e || "defaultPreset" in e ? Rn(e) : { defaults: e, presets: {} };
867
+ if (!a) return r;
868
+ const n = { ...a.presets, ...r.presets };
869
+ for (const o of Object.keys(n))
870
+ n[o] = Te(
871
+ Te(a.presets[o], r.defaults),
872
+ r.presets[o]
873
+ );
874
+ return {
875
+ defaults: Te(a.defaults, r.defaults),
876
+ presets: n,
877
+ defaultPreset: r.defaultPreset ?? a.defaultPreset
878
+ };
879
+ });
880
+ ut(Ke, s);
881
+ }
882
+ function Bn() {
883
+ return Be(Ke, R(() => null));
884
+ }
885
+ const lt = /* @__PURE__ */ new Map(), ve = /* @__PURE__ */ new Map(), Dn = 15e3;
886
+ function Ze(e, t) {
887
+ return Object.assign(new Error(e), { cause: t });
888
+ }
889
+ function Pe(e, t) {
890
+ return `PDF 字体 ${JSON.stringify(e)}:${t}。请部署支持报表文字的字体文件,并将 pdfFontUrl 配置为可访问的字体 URL;西文报表可设为空串`;
891
+ }
892
+ function Oe(e) {
893
+ if (e?.reason instanceof Error && e.reason.name === "AbortError") return e.reason;
894
+ const t = Ze("PDF 字体检查已取消", e?.reason);
895
+ return t.name = "AbortError", t;
896
+ }
897
+ async function Wn(e, t) {
898
+ let s = !1;
899
+ const a = setTimeout(() => {
900
+ s = !0, t.abort();
901
+ }, Dn);
902
+ try {
903
+ const r = await fetch(e, { method: "HEAD", signal: t.signal });
904
+ if (t.signal.aborted) throw Oe(t.signal);
905
+ if (r.status === 405 || r.status === 501 || r.type === "opaque")
906
+ return {
907
+ status: "unverified",
908
+ fontUrl: e,
909
+ message: `PDF 字体 ${JSON.stringify(e)} 无法通过 HEAD 检查验证;仍可尝试导出,届时会加载并校验字体`
910
+ };
911
+ if (!r.ok) {
912
+ const o = new Error(`字体请求返回 HTTP ${r.status}`);
913
+ return { status: "error", fontUrl: e, message: Pe(e, o.message), cause: o };
914
+ }
915
+ const n = r.headers.get("content-type") ?? "";
916
+ if (/text\/html|application\/xhtml\+xml/i.test(n)) {
917
+ const o = new Error("字体 URL 返回 HTML 页面(可能是 SPA 路由回退),不是字体文件");
918
+ return { status: "error", fontUrl: e, message: Pe(e, o.message), cause: o };
919
+ }
920
+ if (/^text\//i.test(n) || /(?:\/|\+)json(?:\s*;|$)/i.test(n)) {
921
+ const o = new Error(`字体 URL 返回 ${n} 文本响应,不是字体文件`);
922
+ return { status: "error", fontUrl: e, message: Pe(e, o.message), cause: o };
923
+ }
924
+ return {
925
+ status: "available",
926
+ fontUrl: e,
927
+ message: "PDF 字体资源可达;文字覆盖范围将在实际导出时校验"
928
+ };
929
+ } catch (r) {
930
+ if (t.signal.aborted && !s) throw Oe(t.signal);
931
+ return {
932
+ status: "error",
933
+ fontUrl: e,
934
+ message: Pe(e, s ? "字体检查超时,请检查网络或字体服务" : "字体检查失败,请检查网络、字体服务或跨域访问配置"),
935
+ cause: r
936
+ };
937
+ } finally {
938
+ clearTimeout(a);
939
+ }
940
+ }
941
+ function On(e, t) {
942
+ if (t?.aborted) return Promise.reject(Oe(t));
943
+ if (!e)
944
+ return Promise.resolve({ status: "disabled", fontUrl: e, message: "已停用自定义 PDF 字体;内置字体用于西文,其他文字会在导出时校验" });
945
+ const s = lt.get(e);
946
+ if (s) return Promise.resolve(s);
947
+ let a = ve.get(e);
948
+ if (!a) {
949
+ const n = new AbortController();
950
+ a = { controller: n, promise: Wn(e, n), subscribers: 0 };
951
+ const o = a;
952
+ ve.set(e, o), o.promise = o.promise.then((f) => (!n.signal.aborted && f.status === "available" && lt.set(e, f), f)).finally(() => {
953
+ ve.get(e) === o && ve.delete(e);
954
+ });
955
+ }
956
+ const r = a;
957
+ return r.subscribers++, new Promise((n, o) => {
958
+ let f = !1;
959
+ const m = () => f ? !1 : (f = !0, r.subscribers--, t?.removeEventListener("abort", d), !0), d = () => {
960
+ m() && (r.subscribers === 0 && (ve.get(e) === r && ve.delete(e), r.controller.abort()), o(Oe(t)));
961
+ };
962
+ t?.addEventListener("abort", d, { once: !0 }), r.promise.then(
963
+ (u) => {
964
+ m() && n(u);
965
+ },
966
+ (u) => {
967
+ m() && o(u);
968
+ }
969
+ ), t?.aborted && d();
970
+ });
971
+ }
972
+ function Ln(e = { fontUrl: "/simhei.ttf" }) {
973
+ let t = null;
974
+ const s = async (a, r) => {
975
+ t || (t = await import("@agile-team/mach-report/pdf"));
976
+ let n = null;
977
+ if (e.fontUrl)
978
+ try {
979
+ if (n = await t.loadFontWithCache(e.fontUrl, { strict: !0 }), !n?.byteLength) throw new Error("字体文件为空或加载失败");
980
+ } catch (c) {
981
+ const g = c instanceof Error ? c.message : String(c);
982
+ throw Ze(Pe(e.fontUrl, g), c);
983
+ }
984
+ let o;
985
+ try {
986
+ o = await t.renderPlanToPdf(a, n ? { customFontBytes: n } : {});
987
+ } catch (c) {
988
+ if (!n) throw c;
989
+ const g = c instanceof Error ? c.message : String(c);
990
+ throw Ze(`PDF 生成失败:${g}。当前字体 URL 为 ${JSON.stringify(e.fontUrl)};请确认该文件是有效字体,或重新配置 pdfFontUrl`, c);
991
+ }
992
+ const { bytes: f, unsupportedTextCount: m, pageErrors: d, fidelityWarnings: u } = o;
993
+ if (m > 0)
994
+ throw new Error(`PDF 中有 ${m} 行文字无法编码;请部署支持所用文字的字体并配置 pdfFontUrl`);
995
+ if (d.length > 0)
996
+ throw new Error(`PDF 有 ${d.length} 页渲染失败:${d[0]}`);
997
+ return u.length > 0 && r?.(`PDF 有 ${u.length} 处版式降级:${u.slice(0, 2).join(";")}`), f;
998
+ };
999
+ return s.checkFont = (a) => On(e.fontUrl, a), s;
1000
+ }
1001
+ class ge extends Error {
1002
+ constructor(t, s, a) {
1003
+ super(s), this.name = "MachReportError", this.code = t, this.cause = a;
1004
+ }
1005
+ }
1006
+ function In(e) {
1007
+ return e instanceof ge ? { code: e.code, cause: e.cause } : { code: "render", cause: e };
1008
+ }
1009
+ const Hn = {
1010
+ key: 2,
1011
+ class: "mrp-export-notice mrp-export-warning",
1012
+ role: "status"
1013
+ }, zn = { class: "mrp-main" }, An = {
1014
+ key: 0,
1015
+ class: "mrp-state"
1016
+ }, Nn = {
1017
+ key: 1,
1018
+ class: "mrp-state mrp-error"
1019
+ }, qn = {
1020
+ key: 2,
1021
+ class: "mrp-state"
1022
+ }, jn = ["data-page"], Un = ["onClick"], Vn = ["data-thumb"], Kn = { class: "mrp-thumb-no" }, Zn = { class: "mrp-overlay" }, Jn = {
1023
+ key: 3,
1024
+ class: "mrp-debug",
1025
+ "aria-hidden": "true"
1026
+ }, Me = 96 / 25.4, it = "mach-report:ui", Gn = /* @__PURE__ */ Je({
1027
+ __name: "ReportPreview",
1028
+ props: {
1029
+ reportId: {
1030
+ type: [String, Array],
1031
+ default: null
1032
+ },
1033
+ params: {
1034
+ type: Object,
1035
+ default: () => ({})
1036
+ },
1037
+ height: { type: String, default: "100vh" },
1038
+ autoLoad: { type: Boolean, default: !0 },
1039
+ /** 以下显隐/间距不传时走配置中心(preset > defaults > 内置缺省) */
1040
+ showExport: { type: Boolean, default: void 0 },
1041
+ showPrint: { type: Boolean, default: void 0 },
1042
+ showPdfWindow: { type: Boolean, default: void 0 },
1043
+ /** 页间距(px);不传走配置中心 */
1044
+ gapPx: { type: Number, default: void 0 },
1045
+ /** 工具栏/状态文案覆写(不传走配置中心 messages) */
1046
+ messages: { type: Object, default: void 0 },
1047
+ /** 启用的 preset 名(不传用配置中心 defaultPreset) */
1048
+ preset: { type: String, default: void 0 },
1049
+ /** 调试面板(也可用 URL ?mrp-debug=1 开启) */
1050
+ debug: { type: Boolean, default: !1 },
1051
+ /** 参数定义(优先级:prop > 模板 params;有定义且未关闭时显示查询面板) */
1052
+ paramDefs: {
1053
+ type: Array,
1054
+ default: void 0
1055
+ },
1056
+ /** 参数面板显隐(不传走配置中心,缺省 true;有参数定义才渲染) */
1057
+ showParams: { type: Boolean, default: void 0 },
1058
+ fetcher: {
1059
+ type: Function,
1060
+ default: null
1061
+ }
1062
+ },
1063
+ emits: ["loaded", "error", "warning"],
1064
+ setup(e, { expose: t, emit: s }) {
1065
+ Bt((i) => ({
1066
+ v45530c0c: T.value + "px"
1067
+ }));
1068
+ const a = e, r = s, n = Fe(null), o = D(!1), f = D(""), m = Fe(null), d = D(null), u = D(!1), c = Fe(Object.freeze({ status: "unchecked", fontUrl: "" })), g = D(null), v = D(1), S = D(null), B = D(null), P = D(null), z = D(!1), L = tn(), T = R(() => Math.max(0, k.value)), I = Be(jt, null), N = Be(Ut, null), Z = R(() => dt(a.reportId)), J = R(() => a.fetcher ?? I), W = R(() => n.value?.pages.length ?? 0), _ = R(() => Object.freeze({
1069
+ loading: o.value,
1070
+ hasPlan: W.value > 0,
1071
+ pageCount: W.value,
1072
+ currentPage: v.value,
1073
+ exporting: d.value,
1074
+ printing: u.value,
1075
+ canExport: !o.value && W.value > 0 && d.value === null,
1076
+ canPrint: !o.value && W.value > 0 && !u.value,
1077
+ error: m.value,
1078
+ pdfFont: c.value
1079
+ }));
1080
+ function G(i, b, x) {
1081
+ m.value = Object.freeze({ message: i, code: b, cause: x }), r("error", i, { code: b, cause: x });
1082
+ }
1083
+ const ae = Bn(), q = R(() => Tn(ae.value, a.preset)), Y = R(() => ({
1084
+ ...q.value.messages,
1085
+ ...a.messages
1086
+ })), l = R(() => a.showExport ?? q.value.showExport), p = R(() => a.showPrint ?? q.value.showPrint), h = R(() => a.showPdfWindow ?? q.value.showPdfWindow), k = R(() => a.gapPx ?? q.value.gapPx), C = R(() => a.showParams ?? q.value.showParams);
1087
+ let V = null, j = null;
1088
+ function se() {
1089
+ if (N) return N;
1090
+ const i = q.value.pdfFontUrl;
1091
+ return (!j || V !== i) && (V = i, j = Ln({ fontUrl: i })), j;
1092
+ }
1093
+ let Ee = 0, he = null, be = !1;
1094
+ function Le() {
1095
+ Ee++, he?.abort(), he = null;
1096
+ }
1097
+ async function $e() {
1098
+ if (be) throw new ge("config", "报表预览已卸载");
1099
+ Le();
1100
+ const i = Ee, b = new AbortController();
1101
+ he = b;
1102
+ const x = q.value.pdfFontUrl;
1103
+ c.value = Object.freeze({ status: "checking", fontUrl: x });
1104
+ try {
1105
+ const M = se(), U = M.checkFont ? await M.checkFont(b.signal) : { status: "unverified", fontUrl: "", message: "自定义 PDF 导出器未提供字体预检查;字体由宿主确认" };
1106
+ return !be && i === Ee && !b.signal.aborted && (c.value = Object.freeze({ ...U })), U;
1107
+ } catch (M) {
1108
+ if (b.signal.aborted) throw M;
1109
+ const U = {
1110
+ status: "error",
1111
+ fontUrl: x,
1112
+ message: M instanceof Error ? M.message : "PDF 字体检查失败",
1113
+ cause: M
1114
+ };
1115
+ return !be && i === Ee && (c.value = Object.freeze(U)), U;
1116
+ } finally {
1117
+ he === b && (he = null);
1118
+ }
1119
+ }
1120
+ function mt() {
1121
+ $e().catch(() => {
1122
+ });
1123
+ }
1124
+ Q(
1125
+ [n, () => q.value.pdfFontUrl, l, h],
1126
+ () => {
1127
+ const i = c.value.fontUrl === q.value.pdfFontUrl;
1128
+ Le(), (!i || c.value.status === "checking") && (c.value = Object.freeze({ status: "unchecked", fontUrl: q.value.pdfFontUrl })), !be && W.value > 0 && (l.value || h.value) && $e().catch(() => {
1129
+ });
1130
+ },
1131
+ { immediate: !0 }
1132
+ );
1133
+ const ne = R(
1134
+ () => a.paramDefs ?? J.value?.getParamDefs?.(Z.value) ?? []
1135
+ ), le = D({}), Ie = D(!1);
1136
+ function we(i) {
1137
+ const b = {};
1138
+ for (const x of i)
1139
+ b[x.field] = a.params[x.field] ?? x.defaultValue ?? "";
1140
+ le.value = b, Ie.value = !1;
1141
+ }
1142
+ we(ne.value), Q(ne, (i) => we(i)), Q(Z, () => we(ne.value)), Q(() => JSON.stringify(a.params), () => we(ne.value));
1143
+ const vt = R(() => {
1144
+ const i = { ...a.params };
1145
+ for (const [b, x] of Object.entries(le.value))
1146
+ x === "" ? delete i[b] : i[b] = x;
1147
+ return i;
1148
+ });
1149
+ function gt() {
1150
+ return ne.value.filter(
1151
+ (i) => i.required === !0 && !(le.value[i.field] ?? "").trim()
1152
+ );
1153
+ }
1154
+ function ht() {
1155
+ Ie.value = !0;
1156
+ const i = gt();
1157
+ if (i.length > 0) {
1158
+ const b = i[0].label ?? i[0].field, x = Y.value.paramRequired.replace("{label}", b);
1159
+ f.value = x, G(x, "param");
1160
+ return;
1161
+ }
1162
+ ie();
1163
+ }
1164
+ function bt() {
1165
+ we(ne.value);
1166
+ }
1167
+ const wt = R(() => ({
1168
+ height: a.height,
1169
+ ...Sn(q.value.theme)
1170
+ })), { zoom: K, zoomMode: de, applyFitZoom: Qe, setZoom: He } = Zt(() => ({
1171
+ viewport: B.value,
1172
+ pageWidthPx: (n.value?.pages[0]?.pageWidthMm ?? 210) * Me
1173
+ })), yt = Kt(n, K, {
1174
+ pxPerMm: Me,
1175
+ gapPx: k
1176
+ }), { contentSize: ze, windowRange: ye, visiblePages: Pt, makeScrollHandler: xt, refreshViewport: _e } = yt, Et = xt(v, W);
1177
+ function Ae(i) {
1178
+ de.value = "raw", K.value = Math.min(3, Math.max(0.3, i));
1179
+ }
1180
+ function ke() {
1181
+ $t(), n.value = null, v.value = 1, A.reset();
1182
+ }
1183
+ let re = 0, ee = null;
1184
+ async function ie() {
1185
+ const i = ++re;
1186
+ ee?.abort(), ee = null;
1187
+ const b = J.value;
1188
+ if (o.value = !1, m.value = null, Z.value.length === 0) {
1189
+ f.value = "缺少报表 ID", ke(), G(f.value, "param");
1190
+ return;
1191
+ }
1192
+ if (!b) {
1193
+ f.value = "未提供渲染数据源 fetcher", ke(), G(f.value, "config");
1194
+ return;
1195
+ }
1196
+ o.value = !0, f.value = "", g.value = null, ke();
1197
+ const x = L.start(), M = new AbortController();
1198
+ ee = M;
1199
+ const U = /* @__PURE__ */ new Set();
1200
+ function pe(O) {
1201
+ i !== re || M.signal.aborted || U.has(O) || (U.add(O), q.value.logger.warn("[mach-report] 报表告警:", O), r("warning", O));
1202
+ }
1203
+ try {
1204
+ const O = await b({
1205
+ reportIds: Z.value,
1206
+ params: { ...vt.value },
1207
+ signal: M.signal,
1208
+ onWarning: pe
1209
+ });
1210
+ if (i !== re) return;
1211
+ const X = At(O);
1212
+ if (!X.ok) {
1213
+ const ue = X.errors.slice(0, 3).map((rt) => `${rt.path}: ${rt.message}`).join("; ");
1214
+ throw new ge(
1215
+ "validate",
1216
+ `渲染计划校验失败(${X.errors.length} 处): ${ue}`
1217
+ );
1218
+ }
1219
+ if (X.warnings.forEach((ue) => pe(`${ue.path}: ${ue.message}`)), i !== re || M.signal.aborted) return;
1220
+ n.value = O, v.value = 1, L.end(x), B.value && (B.value.scrollTop = 0), de.value === "fit" && Qe(), r("loaded", O.pages.length);
1221
+ } catch (O) {
1222
+ if (i !== re) return;
1223
+ const X = O instanceof ge ? O : O instanceof Nt ? new ge(O.code, O.message, O.cause) : new ge(
1224
+ "fetch",
1225
+ O instanceof Error ? O.message : "预览加载失败",
1226
+ O
1227
+ );
1228
+ f.value = X.message;
1229
+ const ue = In(X);
1230
+ G(X.message, ue.code, ue.cause);
1231
+ } finally {
1232
+ i === re && (o.value = !1), ee === M && (ee = null);
1233
+ }
1234
+ }
1235
+ function te(i) {
1236
+ if (W.value <= 0) return;
1237
+ const b = Math.max(1, Math.min(W.value, i));
1238
+ v.value = b;
1239
+ const x = B.value;
1240
+ if (!x) return;
1241
+ let M = 0;
1242
+ for (let U = 0; U < b - 1; U++)
1243
+ M += (n.value?.pages[U]?.pageHeightMm ?? 0) * Me + T.value;
1244
+ x.scrollTop = M * K.value;
1245
+ }
1246
+ const Ce = Gt(n, {
1247
+ getPdfExporter: se,
1248
+ onError: (i, b) => {
1249
+ g.value = { kind: "error", message: i }, G(i, b ?? "print");
1250
+ },
1251
+ onWarning: (i) => {
1252
+ g.value = { kind: "warning", message: i }, r("warning", i);
1253
+ },
1254
+ onBusy: (i) => {
1255
+ d.value = i, i ? g.value = {
1256
+ kind: "progress",
1257
+ message: Y.value.exporting.replace("{format}", i)
1258
+ } : g.value?.kind === "progress" && (g.value = null);
1259
+ },
1260
+ onPrinting: (i) => {
1261
+ u.value = i;
1262
+ }
1263
+ }), { releasePrintFrame: $t, dispose: kt } = Ce;
1264
+ async function Ne() {
1265
+ m.value = null, await Ce.print();
1266
+ }
1267
+ async function qe(i) {
1268
+ m.value = null, await Ce.exportAs(i);
1269
+ }
1270
+ function je() {
1271
+ m.value = null, Ce.openPdfWindow();
1272
+ }
1273
+ async function et(i, b = {}) {
1274
+ le.value = { ...le.value, ...i }, b.reload !== !1 && await ie();
1275
+ }
1276
+ ut(Vt, {
1277
+ reload: ie,
1278
+ print: Ne,
1279
+ exportAs: qe,
1280
+ openPdfWindow: je,
1281
+ gotoPage: te,
1282
+ setParams: et,
1283
+ checkPdfFont: $e,
1284
+ get state() {
1285
+ return _.value;
1286
+ }
1287
+ });
1288
+ const A = Qt({
1289
+ plan: n,
1290
+ gotoPage: te,
1291
+ highlight: Xt,
1292
+ clearHighlights: Yt
1293
+ });
1294
+ function Ct(i) {
1295
+ i.ctrlKey && (i.preventDefault(), Ae(K.value * (i.deltaY < 0 ? 1.1 : 1 / 1.1)));
1296
+ }
1297
+ function Mt(i) {
1298
+ if ((i.ctrlKey || i.metaKey) && i.key.toLowerCase() === "f") {
1299
+ i.preventDefault(), A.visible.value || A.toggle();
1300
+ return;
1301
+ }
1302
+ switch (i.key) {
1303
+ case "PageDown":
1304
+ i.preventDefault(), te(v.value + 1);
1305
+ break;
1306
+ case "PageUp":
1307
+ i.preventDefault(), te(v.value - 1);
1308
+ break;
1309
+ case "Home":
1310
+ i.preventDefault(), te(1);
1311
+ break;
1312
+ case "End":
1313
+ i.preventDefault(), te(W.value);
1314
+ break;
1315
+ case "+":
1316
+ case "=":
1317
+ i.preventDefault(), Ae(K.value * 1.1);
1318
+ break;
1319
+ case "-":
1320
+ i.preventDefault(), Ae(K.value / 1.1);
1321
+ break;
1322
+ }
1323
+ }
1324
+ function Ft() {
1325
+ try {
1326
+ localStorage.setItem(
1327
+ it,
1328
+ JSON.stringify({ zoomMode: de.value === "fit" ? "fit" : Math.round(K.value * 100) })
1329
+ );
1330
+ } catch {
1331
+ }
1332
+ }
1333
+ Q([de, K], Ft), at(() => {
1334
+ const i = n.value;
1335
+ if (!i) return;
1336
+ const b = S.value;
1337
+ if (!b) return;
1338
+ b.querySelectorAll(".mrp-page-holder").forEach((M) => {
1339
+ const U = Number(M.dataset.page ?? 0) - 1, pe = i.pages[U];
1340
+ if (!pe || M.childElementCount > 0) {
1341
+ if (M.firstElementChild) {
1342
+ const X = M.firstElementChild;
1343
+ A.clear(X), A.apply(X);
1344
+ }
1345
+ return;
1346
+ }
1347
+ M.style.width = `${pe.pageWidthMm * Me}px`;
1348
+ const O = ct(pe, 96, {}, document);
1349
+ A.apply(O), M.appendChild(O);
1350
+ });
1351
+ }, { flush: "post" }), Q(() => A.query.value, (i) => {
1352
+ i || S.value?.querySelectorAll(".mrp-page-holder").forEach((b) => {
1353
+ A.clear(b);
1354
+ });
1355
+ });
1356
+ const tt = en(n, {
1357
+ thumbsRoot: P,
1358
+ visible: z,
1359
+ renderThumbCanvas: (i) => {
1360
+ try {
1361
+ const { canvases: b } = qt(n.value, { start: i, end: i, dpr: 0.2 });
1362
+ return b[0] ?? null;
1363
+ } catch {
1364
+ return null;
1365
+ }
1366
+ }
1367
+ });
1368
+ at(() => {
1369
+ tt.schedule();
1370
+ }, { flush: "post" });
1371
+ const Rt = R(() => a.debug), { debugStats: fe } = _t(Rt, {
1372
+ plan: n,
1373
+ pageCount: W,
1374
+ windowRange: ye,
1375
+ zoom: K,
1376
+ loadMs: L.loadMs
1377
+ });
1378
+ function nt() {
1379
+ _e(B.value), de.value === "fit" && Qe();
1380
+ }
1381
+ function Tt() {
1382
+ try {
1383
+ const i = JSON.parse(localStorage.getItem(it) ?? "{}");
1384
+ i.zoomMode === "fit" ? He("fit") : typeof i.zoomMode == "number" && He(i.zoomMode);
1385
+ } catch {
1386
+ }
1387
+ }
1388
+ return Dt(() => {
1389
+ window.addEventListener("resize", nt), _e(B.value), Tt(), a.autoLoad && ie();
1390
+ }), Wt(() => {
1391
+ be = !0, Le(), re++, ee?.abort(), ee = null, window.removeEventListener("resize", nt), tt.destroy(), A.reset(), kt();
1392
+ }), Q(
1393
+ () => [JSON.stringify(Z.value), JSON.stringify(a.params), J.value],
1394
+ () => {
1395
+ if (a.autoLoad) {
1396
+ ie();
1397
+ return;
1398
+ }
1399
+ re++, ee?.abort(), ee = null, o.value = !1, f.value = "", m.value = null, g.value = null, ke();
1400
+ }
1401
+ ), t({ reload: ie, print: Ne, exportAs: qe, openPdfWindow: je, gotoPage: te, setParams: et, checkPdfFont: $e, state: _ }), (i, b) => (w(), E("div", {
1402
+ class: "mach-report-preview",
1403
+ style: me(wt.value)
1404
+ }, [
1405
+ C.value && ne.value.length > 0 ? (w(), Ot(Cn, {
1406
+ key: 0,
1407
+ defs: ne.value,
1408
+ modelValue: le.value,
1409
+ "onUpdate:modelValue": b[0] || (b[0] = (x) => le.value = x),
1410
+ messages: Y.value,
1411
+ attempted: Ie.value,
1412
+ onQuery: ht,
1413
+ onReset: bt
1414
+ }, null, 8, ["defs", "modelValue", "messages", "attempted"])) : H("", !0),
1415
+ Lt(mn, {
1416
+ "page-count": W.value,
1417
+ "current-page": v.value,
1418
+ "zoom-mode": F(de),
1419
+ zoom: F(K),
1420
+ "show-export": l.value,
1421
+ "show-print": p.value,
1422
+ "show-pdf-window": h.value,
1423
+ messages: Y.value,
1424
+ search: { visible: F(A).visible.value, query: F(A).query.value, matchIndex: F(A).matchIndex.value, matchCount: F(A).matchCount.value },
1425
+ "thumbs-visible": z.value,
1426
+ onGoto: te,
1427
+ onZoom: F(He),
1428
+ onExport: b[1] || (b[1] = (x) => qe(x)),
1429
+ onPrint: Ne,
1430
+ onPdfWindow: je,
1431
+ onSearchInput: F(A).onInput,
1432
+ onSearchNav: F(A).onNav,
1433
+ onSearchToggle: F(A).toggle,
1434
+ onThumbsToggle: b[2] || (b[2] = (x) => z.value = !z.value)
1435
+ }, null, 8, ["page-count", "current-page", "zoom-mode", "zoom", "show-export", "show-print", "show-pdf-window", "messages", "search", "thumbs-visible", "onZoom", "onSearchInput", "onSearchNav", "onSearchToggle"]),
1436
+ g.value ? (w(), E("div", {
1437
+ key: 1,
1438
+ class: oe(["mrp-export-notice", `mrp-export-${g.value.kind}`]),
1439
+ role: "alert"
1440
+ }, y(g.value.message), 3)) : H("", !0),
1441
+ c.value.status === "error" && (l.value || h.value) ? (w(), E("div", Hn, [
1442
+ Ve(y(Y.value.pdfFontUnavailable) + " ", 1),
1443
+ $("button", {
1444
+ type: "button",
1445
+ onClick: mt
1446
+ }, y(Y.value.retry), 1)
1447
+ ])) : H("", !0),
1448
+ $("div", zn, [
1449
+ $("div", {
1450
+ ref_key: "viewportRef",
1451
+ ref: B,
1452
+ class: "mrp-body",
1453
+ tabindex: "0",
1454
+ onWheel: Ct,
1455
+ onKeydown: Mt,
1456
+ onScrollPassive: b[3] || (b[3] = (x) => F(Et)(x.target))
1457
+ }, [
1458
+ o.value ? (w(), E("div", An, y(Y.value.loading), 1)) : f.value ? (w(), E("div", Nn, [
1459
+ Ve(y(f.value) + " ", 1),
1460
+ $("button", {
1461
+ class: "mrp-retry",
1462
+ type: "button",
1463
+ onClick: ie
1464
+ }, y(Y.value.retry), 1)
1465
+ ])) : !n.value || W.value === 0 ? (w(), E("div", qn, y(Y.value.empty), 1)) : (w(), E("div", {
1466
+ key: 3,
1467
+ class: "mrp-scale",
1468
+ style: me({ width: `${F(ze).w * F(K)}px`, height: `${F(ze).h * F(K)}px` })
1469
+ }, [
1470
+ $("div", {
1471
+ ref_key: "containerRef",
1472
+ ref: S,
1473
+ class: "mrp-scale-inner",
1474
+ style: me({ transform: `scale(${F(K)})`, transformOrigin: "top left", width: `${F(ze).w}px` })
1475
+ }, [
1476
+ F(ye).padTopPx > 0 ? (w(), E("div", {
1477
+ key: 0,
1478
+ class: "mrp-spacer-top",
1479
+ style: me({ height: `${F(ye).padTopPx}px` }),
1480
+ "aria-hidden": "true"
1481
+ }, null, 4)) : H("", !0),
1482
+ (w(!0), E(xe, null, Se(F(Pt), (x) => (w(), E("div", {
1483
+ key: x.index,
1484
+ class: "mrp-page-holder",
1485
+ "data-page": x.index + 1
1486
+ }, null, 8, jn))), 128)),
1487
+ F(ye).padBottomPx > 0 ? (w(), E("div", {
1488
+ key: 1,
1489
+ class: "mrp-spacer-bottom",
1490
+ style: me({ height: `${F(ye).padBottomPx}px` }),
1491
+ "aria-hidden": "true"
1492
+ }, null, 4)) : H("", !0)
1493
+ ], 4)
1494
+ ], 4))
1495
+ ], 544),
1496
+ z.value && W.value > 0 ? (w(), E("aside", {
1497
+ key: 0,
1498
+ ref_key: "thumbsRef",
1499
+ ref: P,
1500
+ class: "mrp-thumbs"
1501
+ }, [
1502
+ (w(!0), E(xe, null, Se(n.value?.pages ?? [], (x, M) => (w(), E("div", {
1503
+ key: M,
1504
+ class: oe(["mrp-thumb", { "mrp-thumb-active": M + 1 === v.value }]),
1505
+ onClick: (U) => te(M + 1)
1506
+ }, [
1507
+ $("div", {
1508
+ class: "mrp-thumb-box",
1509
+ "data-thumb": M + 1,
1510
+ style: me({ height: `${Math.round(x.pageHeightMm / x.pageWidthMm * 116)}px` })
1511
+ }, null, 12, Vn),
1512
+ $("span", Kn, y(M + 1), 1)
1513
+ ], 10, Un))), 128))
1514
+ ], 512)) : H("", !0)
1515
+ ]),
1516
+ $("div", Zn, [
1517
+ It(i.$slots, "default", {}, void 0, !0)
1518
+ ]),
1519
+ F(fe) ? (w(), E("div", Jn, [
1520
+ b[4] || (b[4] = $("div", null, "mach-report debug", -1)),
1521
+ $("div", null, "pages: " + y(F(fe).pages) + " | window: [" + y(F(fe).window) + "]", 1),
1522
+ $("div", null, "zoom: " + y(F(fe).zoom) + " | load: " + y(F(fe).loadMs), 1),
1523
+ $("div", null, "plan: " + y(F(fe).planKB) + "KB", 1)
1524
+ ])) : H("", !0)
1525
+ ], 4));
1526
+ }
1527
+ }), Yn = /* @__PURE__ */ Xe(Gn, [["__scopeId", "data-v-28af6d98"]]), lr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1528
+ __proto__: null,
1529
+ default: Yn
1530
+ }, Symbol.toStringTag, { value: "Module" }));
1531
+ export {
1532
+ Mn as D,
1533
+ ge as M,
1534
+ Ue as P,
1535
+ Cn as R,
1536
+ ar as S,
1537
+ Fn as a,
1538
+ Yn as b,
1539
+ mn as c,
1540
+ ft as d,
1541
+ Jt as e,
1542
+ Ln as f,
1543
+ nr as g,
1544
+ Rn as h,
1545
+ or as i,
1546
+ tr as j,
1547
+ sr as k,
1548
+ In as l,
1549
+ Kt as m,
1550
+ dt as n,
1551
+ Gt as o,
1552
+ rr as p,
1553
+ Zt as q,
1554
+ Tn as r,
1555
+ lr as s,
1556
+ Sn as t,
1557
+ Bn as u
1558
+ };