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