@agile-team/mach-report 2.14.0 → 2.16.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.
- package/README.md +26 -16
- package/THIRD_PARTY_NOTICES.md +3 -1
- package/dist/{ExcelBindingWizard-CLT2p7P3.cjs → ExcelBindingWizard-CP6h2x1f.cjs} +1 -1
- package/dist/{ExcelBindingWizard-CvsWR8Ga.js → ExcelBindingWizard-HhB3hAJE.js} +3 -3
- package/dist/ParamEditor-CUQLgoxa.cjs +1 -0
- package/dist/ParamEditor-OKesP_nO.js +594 -0
- package/dist/{ReportBatchPanel-DkxTzBkD.cjs → ReportBatchPanel-cZCAMAwH.cjs} +1 -1
- package/dist/{ReportBatchPanel-LqVgiqp7.js → ReportBatchPanel-ruxcbfY6.js} +39 -39
- package/dist/ReportPreview-BcDKCLiK.js +4834 -0
- package/dist/ReportPreview-Bk9nLfO9.cjs +6 -0
- package/dist/{ReportTemplateLibrary-cQ1sqNYo.cjs → ReportTemplateLibrary-BDlNT8JN.cjs} +1 -1
- package/dist/{ReportTemplateLibrary-MjWEtc7X.js → ReportTemplateLibrary-DcwrH-63.js} +1 -1
- package/dist/{RuleEditor-BaR6xUiI.cjs → RuleEditor-BX5S8RSF.cjs} +1 -1
- package/dist/{RuleEditor-ChuXMlei.js → RuleEditor-CGl9XY2s.js} +5 -5
- package/dist/{TemplateOutlinePanel-BHKP89Xz.cjs → TemplateOutlinePanel-CGrT5DFN.cjs} +1 -1
- package/dist/{TemplateOutlinePanel-Dci6aRn1.js → TemplateOutlinePanel-SXCjaPKR.js} +2 -2
- package/dist/{TemplateReusePanel-CY5eO2Sh.cjs → TemplateReusePanel-6Z3wRFz8.cjs} +1 -1
- package/dist/{TemplateReusePanel-B7Gmyc1z.js → TemplateReusePanel-lHLOS9Wn.js} +2 -2
- package/dist/{TemplateReviewPanel-DjlX3xpt.js → TemplateReviewPanel-CJ9PLc48.js} +2 -2
- package/dist/{TemplateReviewPanel-JvZe9_4G.cjs → TemplateReviewPanel-Dpk7sLcF.cjs} +1 -1
- package/dist/analytics.cjs +1 -1
- package/dist/analytics.d.cts +5 -1
- package/dist/analytics.d.ts +5 -1
- package/dist/analytics.js +154 -60
- package/dist/artifact-integrity.json +143 -0
- package/dist/assets-CqIbfbTr.js +126 -0
- package/dist/assets-e4YSke8n.cjs +1 -0
- package/dist/auto-YR7a4BtF.js +240 -0
- package/dist/auto-uVBjX1j5.cjs +1 -0
- package/dist/batch-WzDIXJAt.js +220 -0
- package/dist/batch-z6Aw5GEY.cjs +1 -0
- package/dist/capabilities-DDwXr_cA.js +103 -0
- package/dist/capabilities-DNLyZdNw.cjs +1 -0
- package/dist/codes.d.cts +4 -0
- package/dist/codes.d.ts +4 -0
- package/dist/component-tree-Ca6YYfHq.js +61 -0
- package/dist/component-tree-DkGLEfZC.cjs +1 -0
- package/dist/{computed-Bvk0W15F.js → computed-C-4C2S5h.js} +3 -3
- package/dist/config-Dg_o8e7m.cjs +1 -0
- package/dist/config-XQ4qrQ7Q.js +844 -0
- package/dist/designer-BfQSahxq.js +5163 -0
- package/dist/designer-CPPdeM5_.cjs +2 -0
- package/dist/designer.cjs +1 -1
- package/dist/designer.d.cts +197 -16
- package/dist/designer.d.ts +197 -16
- package/dist/designer.js +1 -1
- package/dist/diagnostic-notification-B9K9We3h.cjs +1 -0
- package/dist/diagnostic-notification-qGAYZdkB.js +7 -0
- package/dist/drill-CsdjgkRM.cjs +1 -0
- package/dist/drill-DIGsZfyB.js +145 -0
- package/dist/encoding-BOGq4qYL.js +21 -0
- package/dist/encoding-BYF9ZTl9.cjs +1 -0
- package/dist/{font-loader-DHto6Lra.js → font-loader-CzI1GuBc.js} +1 -1
- package/dist/{font-loader-vhCT8znW.cjs → font-loader-EKLzOJxf.cjs} +1 -1
- package/dist/index.cjs +8 -9
- package/dist/index.d.cts +84 -4
- package/dist/index.d.ts +84 -4
- package/dist/index.js +829 -833
- package/dist/json-snapshot-D6ioHth9.js +1702 -0
- package/dist/json-snapshot-DknkjvxP.cjs +2 -0
- package/dist/licenses/_bwip-js_generic-4.11.4.txt +24 -0
- package/dist/licenses/_fast-csv_format-4.3.5.txt +22 -0
- package/dist/licenses/_fast-csv_parse-4.3.6.txt +22 -0
- package/dist/licenses/_pdf-lib_fontkit-1.1.1.txt +326 -0
- package/dist/licenses/_pdf-lib_standard-fonts-1.0.0.txt +22 -0
- package/dist/licenses/_pdf-lib_upng-1.0.1.txt +22 -0
- package/dist/licenses/_types_node-14.18.63.txt +22 -0
- package/dist/licenses/_types_pako-2.0.3.txt +22 -0
- package/dist/licenses/_types_pegjs-0.10.6.txt +22 -0
- package/dist/licenses/archiver-5.3.2.txt +23 -0
- package/dist/licenses/archiver-utils-2.1.0.txt +23 -0
- package/dist/licenses/archiver-utils-3.0.4.txt +23 -0
- package/dist/licenses/async-3.2.6.txt +20 -0
- package/dist/licenses/balanced-match-1.0.2.txt +22 -0
- package/dist/licenses/base64-js-1.5.1.txt +22 -0
- package/dist/licenses/big-integer-1.6.52.txt +25 -0
- package/dist/licenses/binary-0.3.0.txt +178 -0
- package/dist/licenses/bl-4.1.0.txt +14 -0
- package/dist/licenses/bluebird-3.4.7.txt +22 -0
- package/dist/licenses/brace-expansion-1.1.21.txt +22 -0
- package/dist/licenses/brace-expansion-2.1.7.txt +22 -0
- package/dist/licenses/buffer-5.7.1.txt +22 -0
- package/dist/licenses/buffer-crc32-0.2.13.txt +20 -0
- package/dist/licenses/buffer-indexof-polyfill-1.0.2.txt +23 -0
- package/dist/licenses/buffers-0.1.1.txt +140 -0
- package/dist/licenses/chainsaw-0.1.0.txt +184 -0
- package/dist/licenses/compress-commons-4.1.2.txt +23 -0
- package/dist/licenses/concat-map-0.0.1.txt +19 -0
- package/dist/licenses/core-util-is-1.0.3.txt +20 -0
- package/dist/licenses/crc-32-1.2.2.txt +202 -0
- package/dist/licenses/crc32-stream-4.0.3.txt +23 -0
- package/dist/licenses/dayjs-1.11.23.txt +22 -0
- package/dist/licenses/duplexer2-0.1.4.txt +27 -0
- package/dist/licenses/end-of-stream-1.4.5.txt +22 -0
- package/dist/licenses/exceljs-4.4.0.txt +23 -0
- package/dist/licenses/fast-csv-4.3.6.txt +22 -0
- package/dist/licenses/fast-png-6.4.0.txt +22 -0
- package/dist/licenses/fs-constants-1.0.0.txt +22 -0
- package/dist/licenses/fs.realpath-1.0.0.txt +44 -0
- package/dist/licenses/fstream-1.0.12.txt +16 -0
- package/dist/licenses/glob-7.2.3.txt +22 -0
- package/dist/licenses/graceful-fs-4.2.11.txt +16 -0
- package/dist/licenses/ieee754-1.2.1.txt +12 -0
- package/dist/licenses/immediate-3.0.6.txt +21 -0
- package/dist/licenses/inflight-1.0.6.txt +16 -0
- package/dist/licenses/inherits-2.0.4.txt +17 -0
- package/dist/licenses/iobuffer-5.4.0.txt +23 -0
- package/dist/licenses/isarray-1.0.0.txt +61 -0
- package/dist/licenses/jszip-3.10.2.txt +652 -0
- package/dist/licenses/lazystream-1.0.1.txt +24 -0
- package/dist/licenses/lie-3.3.0.txt +8 -0
- package/dist/licenses/listenercount-1.0.1.txt +6 -0
- package/dist/licenses/lodash.defaults-4.2.0.txt +48 -0
- package/dist/licenses/lodash.difference-4.5.0.txt +48 -0
- package/dist/licenses/lodash.escaperegexp-4.1.2.txt +48 -0
- package/dist/licenses/lodash.flatten-4.4.0.txt +48 -0
- package/dist/licenses/lodash.groupby-4.6.0.txt +48 -0
- package/dist/licenses/lodash.isboolean-3.0.3.txt +23 -0
- package/dist/licenses/lodash.isequal-4.5.0.txt +48 -0
- package/dist/licenses/lodash.isfunction-3.0.9.txt +48 -0
- package/dist/licenses/lodash.isnil-4.0.0.txt +23 -0
- package/dist/licenses/lodash.isplainobject-4.0.6.txt +48 -0
- package/dist/licenses/lodash.isundefined-3.0.1.txt +23 -0
- package/dist/licenses/lodash.union-4.6.0.txt +48 -0
- package/dist/licenses/lodash.uniq-4.5.0.txt +48 -0
- package/dist/licenses/minimatch-3.1.5.txt +16 -0
- package/dist/licenses/minimatch-5.1.9.txt +16 -0
- package/dist/licenses/minimist-1.2.8.txt +19 -0
- package/dist/licenses/mkdirp-0.5.6.txt +22 -0
- package/dist/licenses/node-sql-parser-5.4.0.txt +202 -0
- package/dist/licenses/normalize-path-3.0.0.txt +22 -0
- package/dist/licenses/once-1.4.0.txt +16 -0
- package/dist/licenses/pako-1.0.11.txt +22 -0
- package/dist/licenses/pako-2.2.0.txt +22 -0
- package/dist/licenses/path-is-absolute-1.0.1.txt +22 -0
- package/dist/licenses/pdf-lib-1.17.1.txt +22 -0
- package/dist/licenses/process-nextick-args-2.0.1.txt +20 -0
- package/dist/licenses/readable-stream-2.3.8.txt +48 -0
- package/dist/licenses/readable-stream-3.6.2.txt +48 -0
- package/dist/licenses/readdir-glob-1.1.3.txt +202 -0
- package/dist/licenses/rimraf-2.7.1.txt +16 -0
- package/dist/licenses/safe-buffer-5.1.2.txt +22 -0
- package/dist/licenses/safe-buffer-5.2.1.txt +22 -0
- package/dist/licenses/saxes-5.0.1.txt +397 -0
- package/dist/licenses/setimmediate-1.0.5.txt +21 -0
- package/dist/licenses/string_decoder-1.1.1.txt +49 -0
- package/dist/licenses/string_decoder-1.3.0.txt +49 -0
- package/dist/licenses/tar-stream-2.2.0.txt +22 -0
- package/dist/licenses/tmp-0.2.7.txt +22 -0
- package/dist/licenses/traverse-0.3.9.txt +25 -0
- package/dist/licenses/tslib-1.14.1.txt +13 -0
- package/dist/licenses/unzipper-0.10.14.txt +26 -0
- package/dist/licenses/util-deprecate-1.0.2.txt +25 -0
- package/dist/licenses/uuid-11.1.1.txt +10 -0
- package/dist/licenses/wrappy-1.0.2.txt +16 -0
- package/dist/licenses/xmlchars-2.2.0.txt +19 -0
- package/dist/licenses/zip-stream-4.1.1.txt +23 -0
- package/dist/matrix-CGRGkn5s.js +112 -0
- package/dist/matrix-gEO7ZM_u.cjs +1 -0
- package/dist/media-B7vnpD8k.cjs +1 -0
- package/dist/media-Y90dHK9z.js +70 -0
- package/dist/param-validation-C3HlcLLO.cjs +1 -0
- package/dist/param-validation-Do7Eg8Zv.js +181 -0
- package/dist/{pdf-AyJGb22z.cjs → pdf-ByVCb1i6.cjs} +49 -49
- package/dist/{pdf-8UPQebOE.js → pdf-DJ5S6ukC.js} +4924 -4872
- package/dist/pdf.cjs +1 -1
- package/dist/pdf.d.cts +20 -3
- package/dist/pdf.d.ts +20 -3
- package/dist/pdf.js +2 -2
- package/dist/{plugin-BGKf-Tqg.js → plugin-C2j5_mhx.js} +2 -2
- package/dist/{plugin-CktLH_Iy.cjs → plugin-Dr39GBRG.cjs} +1 -1
- package/dist/prepared-DdrjLC7L.cjs +1 -0
- package/dist/prepared-DqtpvRTn.js +87 -0
- package/dist/progress-B0ctFpKf.cjs +1 -0
- package/dist/progress-BXzlVbIp.js +29 -0
- package/dist/progress-DJBd9Rb9.cjs +1 -0
- package/dist/progress-Hc2vxoCs.js +52 -0
- package/dist/protocol-BzwMP4Vw.cjs +1 -0
- package/dist/protocol-kt4Iy6-3.js +90 -0
- package/dist/record-bindings-CZWBJ1fU.js +195 -0
- package/dist/record-bindings-DUX1VMlR.cjs +1 -0
- package/dist/{region-binding-workflow-DEJbhpCv.js → region-binding-workflow-CWNvIjkV.js} +1 -1
- package/dist/{region-binding-workflow-BzfbxRiR.cjs → region-binding-workflow-CqSMxQ4p.cjs} +1 -1
- package/dist/report-encoding-worker.cjs +1 -0
- package/dist/report-encoding-worker.d.ts +1 -0
- package/dist/report-encoding-worker.js +2 -0
- package/dist/{report-params-B44imUd4.js → report-params-B1RzkhJj.js} +1 -1
- package/dist/{report-params-SJfhKgaX.cjs → report-params-WDGrA4oP.cjs} +1 -1
- package/dist/rich-text-layout-ALlMoYOG.cjs +3 -0
- package/dist/rich-text-layout-Ct5WrY1g.js +102 -0
- package/dist/runtime-BjKBI530.js +168 -0
- package/dist/runtime-CBFEPKEs.cjs +1 -0
- package/dist/sbom.cdx.json +3982 -0
- package/dist/server/node.d.cts +106 -2
- package/dist/server/node.d.ts +106 -2
- package/dist/server-node.cjs +5 -1
- package/dist/server-node.js +4634 -539
- package/dist/server.cjs +1 -1
- package/dist/server.d.cts +780 -5
- package/dist/server.d.ts +780 -5
- package/dist/server.js +773 -691
- package/dist/sha256-BshdOkCC.cjs +1 -0
- package/dist/sha256-DTG-Gq8i.js +157 -0
- package/dist/style-67OqfNed.js +73 -0
- package/dist/style-C22Pbv3T.cjs +1 -0
- package/dist/style.css +1 -1
- package/dist/template-bindings-C2SpvsMU.js +58 -0
- package/dist/template-bindings-CEtWyiLX.cjs +1 -0
- package/dist/template-catalog-BtR2JmCL.js +414 -0
- package/dist/template-catalog-C2NLdrwB.cjs +1 -0
- package/dist/{template-fragments-DFUpq5QM.cjs → template-fragments-BVsbxs4a.cjs} +1 -1
- package/dist/{template-fragments-CLkGo6To.js → template-fragments-By0aZC1D.js} +21 -21
- package/dist/{template-outline-B3xVkzSv.cjs → template-outline-BwRV_eRo.cjs} +1 -1
- package/dist/{template-outline-CFenM1PV.js → template-outline-cnWfT_LK.js} +3 -3
- package/dist/template-registry-C62vpv4a.cjs +1 -0
- package/dist/template-registry-Cw3vRTX2.js +801 -0
- package/dist/textwrap-BEIg2w8y.js +110 -0
- package/dist/textwrap-BI-yJ6Wt.cjs +4 -0
- package/dist/{tree-CqcQ99NM.js → tree-CjVZLRw7.js} +1 -1
- package/dist/vue/async.d.cts +189 -14
- package/dist/vue/async.d.ts +189 -14
- package/dist/vue/index.d.cts +246 -22
- package/dist/vue/index.d.ts +246 -22
- package/dist/vue-async.cjs +1 -1
- package/dist/vue-async.js +3 -3
- package/dist/vue.cjs +1 -1
- package/dist/vue.js +80 -78
- package/dist/{workbook-session-BfK1yHOO.js → workbook-session-BeSO8PFB.js} +5460 -5295
- package/dist/{workbook-session-DNa2RHNG.cjs → workbook-session-Cbts-22R.cjs} +19 -19
- package/dist/worker.cjs +1 -1
- package/dist/worker.d.cts +104 -2
- package/dist/worker.d.ts +104 -2
- package/dist/worker.js +12 -156
- package/dist/xlsx-node.cjs +35 -35
- package/dist/xlsx-node.js +2138 -2137
- package/dist/xlsx.cjs +4 -4
- package/dist/xlsx.d.cts +24 -10
- package/dist/xlsx.d.ts +24 -10
- package/dist/xlsx.js +303 -277
- package/package.json +7 -4
- package/dist/ParamEditor-CflQV3eQ.js +0 -526
- package/dist/ParamEditor-vIDzvpPV.cjs +0 -1
- package/dist/ReportPreview-CvbqLUzM.cjs +0 -6
- package/dist/ReportPreview-D_ywJ_-H.js +0 -4533
- package/dist/assets-C2U-e-Sz.cjs +0 -4
- package/dist/assets-Q0wUwNrV.js +0 -217
- package/dist/batch-DzaTNLWI.js +0 -371
- package/dist/batch-xMkqYiTr.cjs +0 -1
- package/dist/capabilities-CK_7hizc.js +0 -63
- package/dist/capabilities-CsZ-pNHR.cjs +0 -1
- package/dist/config-0UIohTS7.cjs +0 -1
- package/dist/config-Dt9NtCPl.js +0 -566
- package/dist/data-explanation-BktvER5B.cjs +0 -1
- package/dist/data-explanation-C_J6jYNi.js +0 -16
- package/dist/defaults-DXhiM1ZD.js +0 -10
- package/dist/defaults-xhmcLLrf.cjs +0 -1
- package/dist/designer-Ci1LizA9.js +0 -5020
- package/dist/designer-rtmVIIdN.cjs +0 -2
- package/dist/grid-strokes-Cr7DwUux.cjs +0 -1
- package/dist/grid-strokes-DyyG1q_o.js +0 -53
- package/dist/json-snapshot-BeFT3Tso.js +0 -1952
- package/dist/json-snapshot-D1NTP2oI.cjs +0 -2
- package/dist/matrix-DVyWiYsd.cjs +0 -1
- package/dist/matrix-yZsGnldA.js +0 -227
- package/dist/page-window-index-CIuT4BAv.js +0 -43
- package/dist/page-window-index-DEjnM6IB.cjs +0 -1
- package/dist/param-validation-BlHHXs6u.js +0 -153
- package/dist/param-validation-DCK039V1.cjs +0 -1
- package/dist/progress-7OSZbFok.js +0 -39
- package/dist/progress-BnLiS5eH.cjs +0 -1
- package/dist/render-plan-7xpGrCEl.cjs +0 -1
- package/dist/render-plan-Ck6koX9L.js +0 -13
- package/dist/style-CQ1PK8ZB.js +0 -67
- package/dist/style-UgIJSA1F.cjs +0 -1
- package/dist/task-events-DQ276fn2.cjs +0 -1
- package/dist/task-events-Dpsvf_t2.js +0 -47
- package/dist/template-bindings-BJR4k7qZ.cjs +0 -1
- package/dist/template-bindings-Daui7hLF.js +0 -252
- package/dist/template-registry-COXDEJEM.js +0 -570
- package/dist/template-registry-D3SjENi6.cjs +0 -1
- package/dist/validate-BJ5HIWY8.cjs +0 -1
- package/dist/validate-CkQBWCeg.js +0 -163
package/dist/index.js
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import { D as
|
|
2
|
-
import {
|
|
3
|
-
import { R as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { v as
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import { r as
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import { R as
|
|
25
|
-
import {
|
|
26
|
-
import { c as
|
|
27
|
-
import { a as
|
|
28
|
-
import { T as
|
|
29
|
-
const
|
|
1
|
+
import { D as ne, a as U, r as z, b as _, c as Pe, d as q, e as Ae, m as le, f as ke, g as ce, p as W, P as Q } from "./style-67OqfNed.js";
|
|
2
|
+
import { C as Zn, h as Qn, i as er, j as tr, L as nr, M as rr, S as ir, k as ar, l as or } from "./style-67OqfNed.js";
|
|
3
|
+
import { R as lr, e as cr, f as dr, p as mr, b as hr, t as gr, d as fr } from "./record-bindings-CZWBJ1fU.js";
|
|
4
|
+
import { i as re, a as $e } from "./component-tree-Ca6YYfHq.js";
|
|
5
|
+
import { R as pr } from "./component-tree-Ca6YYfHq.js";
|
|
6
|
+
import { v as Ie, R as Ne, p as G, a as Qe } from "./template-registry-Cw3vRTX2.js";
|
|
7
|
+
import { b as br, c as Mr, d as vr, e as yr, s as xr, f as Sr, g as Er, h as Tr } from "./template-registry-Cw3vRTX2.js";
|
|
8
|
+
import { v as et } from "./dataset-H5pFuQGU.js";
|
|
9
|
+
import { d as Rr } from "./dataset-H5pFuQGU.js";
|
|
10
|
+
import { h as de, w as Le } from "./textwrap-BEIg2w8y.js";
|
|
11
|
+
import { c as Ar, a as kr, b as $r, m as Ir } from "./textwrap-BEIg2w8y.js";
|
|
12
|
+
import { R as me, d as tt, a as nt, p as rt, s as it } from "./json-snapshot-D6ioHth9.js";
|
|
13
|
+
import { D as Lr, P as Dr, b as Fr, c as Or, e as zr, f as Hr, g as Br, h as Wr, i as _r, j as jr, k as Ur, l as Gr, m as qr, n as Vr, o as Yr, q as Kr, r as Jr, t as Xr, u as Zr, v as Qr, w as ei, x as ti, y as ni, z as ri, A as ii, B as ai, C as oi } from "./json-snapshot-D6ioHth9.js";
|
|
14
|
+
import { r as De } from "./grid-geometry-BNptEcMm.js";
|
|
15
|
+
import { r as Fe, d as at } from "./rich-text-layout-Ct5WrY1g.js";
|
|
16
|
+
import { r as Y, O as ot } from "./capabilities-DDwXr_cA.js";
|
|
17
|
+
import { i as li } from "./capabilities-DDwXr_cA.js";
|
|
18
|
+
import { o as st } from "./progress-Hc2vxoCs.js";
|
|
19
|
+
import { n as Oe } from "./diagnostic-notification-qGAYZdkB.js";
|
|
20
|
+
import { r as he } from "./assets-CqIbfbTr.js";
|
|
21
|
+
import { O as di } from "./assets-CqIbfbTr.js";
|
|
22
|
+
import { c as lt } from "./drill-DIGsZfyB.js";
|
|
23
|
+
import { R as hi, a as gi, m as fi, r as ui, v as pi } from "./drill-DIGsZfyB.js";
|
|
24
|
+
import { R as bi, a as Mi, f as vi, i as yi, b as xi, c as Si, p as Ei, r as Ti, v as Ci, d as Ri } from "./param-validation-Do7Eg8Zv.js";
|
|
25
|
+
import { c as Ai, a as ki, d as $i, r as Ii, b as Ni } from "./template-catalog-BtR2JmCL.js";
|
|
26
|
+
import { c as Di, i as Fi, t as Oi } from "./template-outline-cnWfT_LK.js";
|
|
27
|
+
import { a as Hi, c as Bi, i as Wi, b as _i } from "./template-fragments-By0aZC1D.js";
|
|
28
|
+
import { T as Ui, c as Gi, v as qi } from "./tree-CjVZLRw7.js";
|
|
29
|
+
const ct = {
|
|
30
30
|
root: "mr-root",
|
|
31
31
|
page: "mr-page",
|
|
32
32
|
comp: "mr-comp",
|
|
@@ -43,10 +43,10 @@ const ot = {
|
|
|
43
43
|
cell: "mr-cell",
|
|
44
44
|
unknown: "mr-unknown"
|
|
45
45
|
};
|
|
46
|
-
function
|
|
47
|
-
return t?.classNames?.[e] ??
|
|
46
|
+
function E(e, t) {
|
|
47
|
+
return t?.classNames?.[e] ?? ct[e];
|
|
48
48
|
}
|
|
49
|
-
class
|
|
49
|
+
class dt {
|
|
50
50
|
constructor() {
|
|
51
51
|
this.props = [];
|
|
52
52
|
}
|
|
@@ -54,7 +54,7 @@ class st {
|
|
|
54
54
|
return n == null || n === !1 || n === "" ? this : (this.props.push([t, String(n)]), this);
|
|
55
55
|
}
|
|
56
56
|
mm(t, n, r, i = 2) {
|
|
57
|
-
return this.add(t, `${
|
|
57
|
+
return this.add(t, `${U(le(n, r), i)}px`);
|
|
58
58
|
}
|
|
59
59
|
toString() {
|
|
60
60
|
let t = "";
|
|
@@ -68,521 +68,556 @@ class st {
|
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
function v(e, t = "unset") {
|
|
71
|
-
return new
|
|
71
|
+
return new dt().add("all", t).add("display", e).add("box-sizing", "border-box");
|
|
72
72
|
}
|
|
73
|
-
function
|
|
74
|
-
e.add("color", t.color).add("font-family", t.fontFamily).add("font-weight", t.bold != null ? t.bold ? "700" : "400" : void 0).add("font-style", t.italic != null ? t.italic ? "italic" : "normal" : void 0).add("text-decoration", t.underline != null ? t.underline ? "underline" : "none" : void 0).add("letter-spacing", t.letterSpacing != null ? `${t.letterSpacing}pt` : void 0).add("line-height", String(
|
|
75
|
-
const r =
|
|
76
|
-
e.add("font-size", `${
|
|
73
|
+
function ze(e, t, n) {
|
|
74
|
+
e.add("color", t.color).add("font-family", t.fontFamily).add("font-weight", t.bold != null ? t.bold ? "700" : "400" : void 0).add("font-style", t.italic != null ? t.italic ? "italic" : "normal" : void 0).add("text-decoration", t.underline != null ? t.underline ? "underline" : "none" : void 0).add("letter-spacing", t.letterSpacing != null ? `${t.letterSpacing}pt` : void 0).add("line-height", String(_(t))).add("text-align", t.align);
|
|
75
|
+
const r = z(t, n);
|
|
76
|
+
e.add("font-size", `${U(r.fontSizePx, 2)}px`);
|
|
77
77
|
}
|
|
78
|
-
function
|
|
78
|
+
function mt(e, t, n) {
|
|
79
79
|
const r = t.style ?? {};
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
function
|
|
83
|
-
const
|
|
84
|
-
a.className =
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
for (const
|
|
90
|
-
return a.appendChild(
|
|
91
|
-
}
|
|
92
|
-
function
|
|
93
|
-
return
|
|
94
|
-
const o = `${
|
|
95
|
-
|
|
80
|
+
ze(e, r, n), e.add("background-color", r.backgroundColor).add("opacity", r.opacity != null ? String(r.opacity) : void 0).add("transform", r.rotateDeg ? `rotate(${r.rotateDeg}deg)` : void 0);
|
|
81
|
+
}
|
|
82
|
+
function ht(e, t, n, r, i, o) {
|
|
83
|
+
const l = e.cell, a = o.createElement("td");
|
|
84
|
+
a.className = E("cell", i), a.dataset.mrRowIndex = String(e.ri), a.dataset.mrColumnIndex = String(e.ci), a.setAttribute("role", t.table?.role === "header" ? "columnheader" : "cell"), l.colSpan && (a.colSpan = l.colSpan), l.rowSpan && (a.rowSpan = l.rowSpan);
|
|
85
|
+
const s = ke(t.style, l.style), c = v("block").add("position", "absolute").mm("left", e.xMm, r).mm("top", e.yMm, r).mm("width", e.widthMm, r).mm("height", e.heightMm, r).add("background-color", s.backgroundColor).add("vertical-align", s.verticalAlign ?? "middle");
|
|
86
|
+
ze(c, s, r), c.applyTo(a);
|
|
87
|
+
const d = o.createElement("div");
|
|
88
|
+
d.className = "mr-cell-content", v("flex").add("position", "absolute").mm("left", n + (l.indentMm ?? 0), r).mm("right", n, r).mm("top", n, r).mm("bottom", n, r).add("flex-direction", "column").add("justify-content", s.verticalAlign === "top" ? "flex-start" : s.verticalAlign === "bottom" ? "flex-end" : "center").add("overflow-wrap", "anywhere").add("overflow", "hidden").applyTo(d), l.richParagraphs?.length ? d.appendChild(He({ ...t, kind: "text", richParagraphs: l.richParagraphs }, r, i, o)) : l.text != null && d.append(l.text);
|
|
89
|
+
for (const h of l.children ?? []) d.appendChild(Be(h, r, i, o));
|
|
90
|
+
return a.appendChild(d), a;
|
|
91
|
+
}
|
|
92
|
+
function gt(e, t, n, r) {
|
|
93
|
+
return Fe(e, t).map((i) => {
|
|
94
|
+
const o = `${U(i.widthPt * n / 72, 2)}px solid ${i.color}`, l = r.createElement("div");
|
|
95
|
+
l.className = "mr-grid-edge", l.setAttribute("aria-hidden", "true");
|
|
96
96
|
const a = i.kind === "h";
|
|
97
|
-
return v("block").add("position", "absolute").add("pointer-events", "none").mm("left", a ? i.from : i.pos, n).mm("top", a ? i.pos : i.from, n).mm("width", a ? i.to - i.from : 0, n).mm("height", a ? 0 : i.to - i.from, n).add(a ? "border-top" : "border-left", o).applyTo(
|
|
97
|
+
return v("block").add("position", "absolute").add("pointer-events", "none").mm("left", a ? i.from : i.pos, n).mm("top", a ? i.pos : i.from, n).mm("width", a ? i.to - i.from : 0, n).mm("height", a ? 0 : i.to - i.from, n).add(a ? "border-top" : "border-left", o).applyTo(l), l;
|
|
98
98
|
});
|
|
99
99
|
}
|
|
100
|
-
function
|
|
100
|
+
function ft(e, t, n, r, i) {
|
|
101
101
|
const o = i.createElement("table");
|
|
102
|
-
o.className =
|
|
103
|
-
const
|
|
102
|
+
o.className = E("grid", r), o.setAttribute("role", "table"), v("block").add("position", "relative").add("width", "100%").add("height", "100%").applyTo(o);
|
|
103
|
+
const l = De(e, t.widthMm, t.heightMm), a = i.createElement("tbody");
|
|
104
104
|
v("contents").applyTo(a), o.appendChild(a);
|
|
105
|
-
const
|
|
106
|
-
const
|
|
107
|
-
return
|
|
105
|
+
const s = e.cells.map(() => {
|
|
106
|
+
const d = i.createElement("tr");
|
|
107
|
+
return d.className = E("row", r), d.setAttribute("role", "row"), v("contents").applyTo(d), a.appendChild(d), d;
|
|
108
108
|
});
|
|
109
|
-
for (const
|
|
110
|
-
|
|
109
|
+
for (const d of l.cells)
|
|
110
|
+
s[d.ri].appendChild(ht(d, t, e.paddingMm ?? 0.5, n, r, i));
|
|
111
111
|
const c = i.createElement("div");
|
|
112
|
-
return v("block").add("position", "relative").add("width", "100%").add("height", "100%").applyTo(c), c.append(o, ...
|
|
112
|
+
return v("block").add("position", "relative").add("width", "100%").add("height", "100%").applyTo(c), c.append(o, ...gt(l, t, n, i)), c;
|
|
113
113
|
}
|
|
114
|
-
function
|
|
114
|
+
function ut(e, t, n, r) {
|
|
115
115
|
const i = r.createElement("div");
|
|
116
|
-
i.className =
|
|
116
|
+
i.className = E("paragraph", n), v("block").add("text-align", e.align).add("line-height", e.lineHeight != null ? String(e.lineHeight) : void 0).mm("margin-top", e.spaceBeforeMm ?? 0, t).mm("margin-bottom", e.spaceAfterMm ?? 0, t).mm("text-indent", e.indentMm ?? 0, t).applyTo(i);
|
|
117
117
|
for (const o of e.segments || []) {
|
|
118
|
-
const
|
|
119
|
-
|
|
118
|
+
const l = r.createElement("span");
|
|
119
|
+
l.className = E("segment", n), l.textContent = o.kind === "field" ? o.field ?? "" : o.text ?? "";
|
|
120
120
|
const a = v("inline");
|
|
121
121
|
if (o.style) {
|
|
122
|
-
const
|
|
123
|
-
a.add("color",
|
|
122
|
+
const s = o.style;
|
|
123
|
+
a.add("color", s.color).add("background-color", s.backgroundColor).add("font-family", s.fontFamily).add("line-height", s.lineHeight).add("letter-spacing", s.letterSpacing == null ? void 0 : `${s.letterSpacing * t / 72}px`).add("font-weight", s.bold != null ? s.bold ? "700" : "400" : void 0).add("font-style", s.italic != null ? s.italic ? "italic" : "normal" : void 0).add("text-decoration", s.underline != null ? s.underline ? "underline" : "none" : void 0), (s.fontSize != null || s.fontSizePx != null) && a.add("font-size", `${U(z(s, t).fontSizePx, 2)}px`);
|
|
124
124
|
}
|
|
125
|
-
a.applyTo(
|
|
125
|
+
a.applyTo(l), i.appendChild(l);
|
|
126
126
|
}
|
|
127
127
|
return i;
|
|
128
128
|
}
|
|
129
|
-
function
|
|
129
|
+
function He(e, t, n, r) {
|
|
130
130
|
if ($e(e)) {
|
|
131
131
|
const i = r.createElement("div");
|
|
132
|
-
i.className =
|
|
133
|
-
for (const o of e.richParagraphs) i.appendChild(
|
|
132
|
+
i.className = E("rich", n), v("block").applyTo(i);
|
|
133
|
+
for (const o of e.richParagraphs) i.appendChild(ut(o, t, n, r));
|
|
134
134
|
return i;
|
|
135
135
|
}
|
|
136
136
|
if (Array.isArray(e.lines) && e.lines.length > 0) {
|
|
137
137
|
const i = r.createElement("div");
|
|
138
|
-
i.className =
|
|
138
|
+
i.className = E("lines", n), v("block").applyTo(i);
|
|
139
139
|
for (const o of e.lines) {
|
|
140
|
-
const
|
|
141
|
-
|
|
140
|
+
const l = r.createElement("div");
|
|
141
|
+
l.className = E("line", n), l.textContent = o, v("block").add("white-space", "pre").add("min-height", "1lh").applyTo(l), i.appendChild(l);
|
|
142
142
|
}
|
|
143
143
|
return i;
|
|
144
144
|
}
|
|
145
145
|
return e.text ?? "";
|
|
146
146
|
}
|
|
147
|
-
function
|
|
147
|
+
function pt(e, t, n, r) {
|
|
148
148
|
const i = r.createElement("div");
|
|
149
|
-
i.className =
|
|
149
|
+
i.className = E("text", n);
|
|
150
150
|
const o = e.style || {};
|
|
151
|
-
return v("flex").add("width", "100%").add("height", "100%").add("flex-direction", "column").add("justify-content", o.verticalAlign === "middle" ? "center" : o.verticalAlign === "bottom" ? "flex-end" : "flex-start").add("overflow-wrap", "anywhere").add("overflow", "hidden").applyTo(i), i.append(
|
|
151
|
+
return v("flex").add("width", "100%").add("height", "100%").add("flex-direction", "column").add("justify-content", o.verticalAlign === "middle" ? "center" : o.verticalAlign === "bottom" ? "flex-end" : "flex-start").add("overflow-wrap", "anywhere").add("overflow", "hidden").applyTo(i), i.append(He(e, t, n, r)), i;
|
|
152
152
|
}
|
|
153
|
-
function
|
|
153
|
+
function wt(e, t, n) {
|
|
154
154
|
const r = n.createElement("img");
|
|
155
|
-
return r.className =
|
|
155
|
+
return r.className = E("image", t), r.src = e.imageData, v("block").add("width", "100%").add("height", "100%").add("object-fit", "contain").applyTo(r), r.alt = e.kind, r;
|
|
156
156
|
}
|
|
157
|
-
function
|
|
157
|
+
function ye(e, t, n, r) {
|
|
158
158
|
const i = r.createElement("div");
|
|
159
|
-
i.className =
|
|
160
|
-
const o = e.style || {},
|
|
161
|
-
return e.grid ? c.add("position", "relative") : e.kind === "rect" ? (a.top && c.add("border-top",
|
|
159
|
+
i.className = E("shape", n);
|
|
160
|
+
const o = e.style || {}, l = q(o), a = Ae(o), s = `${U(l.widthPt * t / 72, 2)}px solid ${l.color}`, c = v("block");
|
|
161
|
+
return e.grid ? c.add("position", "relative") : e.kind === "rect" ? (a.top && c.add("border-top", s), a.right && c.add("border-right", s), a.bottom && c.add("border-bottom", s), a.left && c.add("border-left", s)) : e.kind === "ellipse" ? (a.inner && c.add("border", s).add("border-radius", "50%"), o.backgroundColor && c.add("background-color", o.backgroundColor)) : e.kind === "line" && c.add("height", "0").add("border-top", s), c.add("box-sizing", "border-box").add("width", "100%").add("height", "100%"), c.applyTo(i), i;
|
|
162
162
|
}
|
|
163
|
-
function
|
|
164
|
-
const r = n.createElementNS("http://www.w3.org/2000/svg", "svg"), i =
|
|
163
|
+
function bt(e, t, n) {
|
|
164
|
+
const r = n.createElementNS("http://www.w3.org/2000/svg", "svg"), i = le(e.widthMm, t), o = le(e.heightMm, t);
|
|
165
165
|
r.setAttribute("width", String(Math.max(1, i))), r.setAttribute("height", String(Math.max(1, o))), r.setAttribute("aria-hidden", "true"), r.style.overflow = "visible", r.style.display = "block";
|
|
166
|
-
const
|
|
167
|
-
|
|
168
|
-
const a =
|
|
169
|
-
return
|
|
166
|
+
const l = n.createElementNS("http://www.w3.org/2000/svg", "line");
|
|
167
|
+
l.setAttribute("x1", "0"), l.setAttribute("x2", String(i)), l.setAttribute("y1", e.lineDirection === "up" ? String(o) : "0"), l.setAttribute("y2", e.lineDirection === "up" ? "0" : String(o));
|
|
168
|
+
const a = q({ ...e.style, borderColor: e.style?.lineColor ?? e.style?.borderColor });
|
|
169
|
+
return l.setAttribute("stroke", a.color), l.setAttribute("stroke-width", String(a.widthPt * t / 72)), r.appendChild(l), r;
|
|
170
170
|
}
|
|
171
|
-
function
|
|
171
|
+
function Be(e, t, n, r) {
|
|
172
172
|
const i = r.createElement("div");
|
|
173
|
-
i.className = `${
|
|
173
|
+
i.className = `${E("comp", n)} mr-kind-${e.kind}`;
|
|
174
174
|
const o = v("block").add("position", "absolute").mm("left", e.leftMm, t).mm("top", e.topMm, t).mm("width", e.widthMm, t).mm("height", e.heightMm, t).add("box-sizing", "border-box");
|
|
175
|
-
if (
|
|
176
|
-
return i.appendChild(
|
|
175
|
+
if (mt(o, e, t), o.applyTo(i), re(e))
|
|
176
|
+
return i.appendChild(wt(e, n, r)), i;
|
|
177
177
|
if (e.kind === "text")
|
|
178
|
-
return i.appendChild(
|
|
178
|
+
return i.appendChild(pt(e, t, n, r)), i;
|
|
179
179
|
if (e.grid) {
|
|
180
|
-
const a =
|
|
181
|
-
return a.appendChild(
|
|
180
|
+
const a = ye(e, t, n, r);
|
|
181
|
+
return a.appendChild(ft(e.grid, e, t, n, r)), i.appendChild(a), i;
|
|
182
182
|
}
|
|
183
183
|
if (e.kind === "line" && e.lineDirection)
|
|
184
|
-
return i.appendChild(
|
|
184
|
+
return i.appendChild(bt(e, t, r)), i;
|
|
185
185
|
if (e.kind === "line" || e.kind === "rect" || e.kind === "ellipse")
|
|
186
|
-
return i.appendChild(
|
|
187
|
-
const
|
|
188
|
-
return
|
|
186
|
+
return i.appendChild(ye(e, t, n, r)), i;
|
|
187
|
+
const l = r.createElement("div");
|
|
188
|
+
return l.className = E("unknown", n), v("block").applyTo(l), l.textContent = e.fallbackText ?? `[${e.kind}]`, l.dataset.mrUnsupported = e.kind, l.setAttribute("role", "note"), i.appendChild(l), i;
|
|
189
189
|
}
|
|
190
|
-
function
|
|
190
|
+
function Mt(e, t, n, r) {
|
|
191
191
|
const i = r.createElement("div");
|
|
192
|
-
return i.className =
|
|
193
|
-
const a =
|
|
194
|
-
a.dataset.mrComponentIndex = String(
|
|
192
|
+
return i.className = E("page", n), v("block", "initial").add("position", "relative").add("font-family", ne).add("font-size", `${U(z(void 0, t).fontSizePx, 2)}px`).add("line-height", String(_(void 0))).add("white-space", "pre-wrap").add("direction", "ltr").mm("width", e.pageWidthMm, t).mm("height", e.pageHeightMm, t).add("background-color", "#fff").add("color", Pe).add("overflow", "hidden").add("box-sizing", "border-box").applyTo(i), e.components.forEach((o, l) => {
|
|
193
|
+
const a = Be(o, t, n, r);
|
|
194
|
+
a.dataset.mrComponentIndex = String(l), i.appendChild(a);
|
|
195
195
|
}), i;
|
|
196
196
|
}
|
|
197
|
-
function
|
|
197
|
+
function $n(e, t, n = {}) {
|
|
198
198
|
const r = n.dpi ?? 96;
|
|
199
|
-
|
|
199
|
+
Y(e, "dom", n);
|
|
200
200
|
const i = t.createElement("div");
|
|
201
|
-
return i.className =
|
|
202
|
-
i.appendChild(
|
|
201
|
+
return i.className = E("root", n), v("block").applyTo(i), i.dataset.schemaVersion = e.schemaVersion, e.pages.forEach((o) => {
|
|
202
|
+
i.appendChild(Mt(o, r, n, t));
|
|
203
203
|
}), i;
|
|
204
204
|
}
|
|
205
|
-
function
|
|
205
|
+
function ge(e, t, n, r, i, o, l, a = "top") {
|
|
206
|
+
e.font = `${t.italic ? "italic " : ""}${t.bold ? "bold " : ""}${t.fontSizePx}px ${l}`, "letterSpacing" in e && (e.letterSpacing = "0px"), e.fillStyle = t.color, e.textBaseline = "alphabetic";
|
|
207
|
+
const s = t.fontSizePx * t.lineHeight, c = t.text === "" ? [""] : t.text.split(`
|
|
208
|
+
`), d = c.length * s;
|
|
209
|
+
let h = r;
|
|
210
|
+
a === "middle" ? h = r + (o - d) / 2 : a === "bottom" && (h = r + o - d), c.forEach((m, g) => {
|
|
211
|
+
const f = h + g * s + t.fontSizePx * 0.8;
|
|
212
|
+
vt(e, m, t, n, f, i), t.underline && m && yt(e, m, t, n, f, i);
|
|
213
|
+
}), e.textAlign = "left";
|
|
214
|
+
}
|
|
215
|
+
function vt(e, t, n, r, i, o) {
|
|
216
|
+
const l = Array.from(t), a = n.letterSpacingPx ?? 0;
|
|
217
|
+
if (!a) {
|
|
218
|
+
e.textAlign = n.align === "center" ? "center" : n.align === "right" ? "right" : "left";
|
|
219
|
+
const h = n.align === "center" ? r + o / 2 : n.align === "right" ? r + o : r;
|
|
220
|
+
e.fillText(t, h, i);
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
const s = e.measureText(t).width + Math.max(0, l.length - 1) * a, c = n.align === "center" ? r + (o - s) / 2 : n.align === "right" ? r + o - s : r;
|
|
224
|
+
e.textAlign = "left";
|
|
225
|
+
let d = "";
|
|
226
|
+
l.forEach((h, m) => {
|
|
227
|
+
e.fillText(h, c + e.measureText(d).width + m * a, i), d += h;
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
function yt(e, t, n, r, i, o) {
|
|
231
|
+
const l = e.measureText(t).width + Math.max(0, Array.from(t).length - 1) * (n.letterSpacingPx ?? 0), a = n.align === "center" ? r + (o - l) / 2 : n.align === "right" ? r + o - l : r;
|
|
232
|
+
e.strokeStyle = n.color, e.lineWidth = Math.max(0.5, n.fontSizePx / 20), e.beginPath(), e.moveTo(a, i + 1), e.lineTo(a + l, i + 1), e.stroke();
|
|
233
|
+
}
|
|
234
|
+
function We(e, t, n, r, i) {
|
|
235
|
+
const o = r / 72, l = (a) => {
|
|
236
|
+
e.font = `${a.italic ? "italic " : ""}${a.bold ? "bold " : ""}${z(a, r).fontSizePx}px ${a.fontFamily ?? i}`, "letterSpacing" in e && (e.letterSpacing = "0px");
|
|
237
|
+
};
|
|
238
|
+
at(t, { x: n.x / o, yTop: -n.y / o, width: n.width / o, height: n.height / o }, {
|
|
239
|
+
measure(a, s) {
|
|
240
|
+
return l(s), e.measureText(a).width / o + (s.letterSpacing ?? 0);
|
|
241
|
+
},
|
|
242
|
+
draw(a, s, c, d, h) {
|
|
243
|
+
const m = z(s, r).fontSizePx, g = -d * o - m * 0.8;
|
|
244
|
+
s.backgroundColor && (e.fillStyle = s.backgroundColor, e.fillRect(c * o, g, h * o, m * _(s))), ge(e, { text: a, fontSizePx: m, bold: !!s.bold, italic: s.italic, underline: s.underline, color: ce(s), align: "left", lineHeight: _(s), letterSpacingPx: (s.letterSpacing ?? 0) * o }, c * o, g, h * o, m, s.fontFamily ?? i);
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
function k(e) {
|
|
206
249
|
if (e?.aborted) throw e.reason ?? new DOMException("The operation was aborted.", "AbortError");
|
|
207
250
|
}
|
|
208
|
-
const
|
|
251
|
+
const xt = (e, t) => (k(t), /^data:image\/(?:png|jpe?g|webp|gif|svg\+xml)[;,]/i.test(e) ? new Promise((n, r) => {
|
|
209
252
|
const i = new Image(), o = () => {
|
|
210
|
-
i.onload = null, i.onerror = null, t?.removeEventListener("abort",
|
|
211
|
-
},
|
|
253
|
+
i.onload = null, i.onerror = null, t?.removeEventListener("abort", l);
|
|
254
|
+
}, l = () => {
|
|
212
255
|
o(), i.src = "", r(t?.reason ?? new DOMException("The operation was aborted.", "AbortError"));
|
|
213
256
|
};
|
|
214
257
|
i.onload = () => {
|
|
215
258
|
o(), n(i);
|
|
216
259
|
}, i.onerror = () => {
|
|
217
260
|
o(), r(new Error("Image could not be decoded for Canvas output."));
|
|
218
|
-
}, t?.addEventListener("abort",
|
|
261
|
+
}, t?.addEventListener("abort", l, { once: !0 }), i.src = e;
|
|
219
262
|
}) : Promise.reject(new TypeError("Canvas imageData must be an image data URL; provide imageLoader for other sources.")));
|
|
220
|
-
function
|
|
221
|
-
return
|
|
263
|
+
function St(e, t, n) {
|
|
264
|
+
return k(n), n ? new Promise((r, i) => {
|
|
222
265
|
const o = () => i(n.reason ?? new DOMException("The operation was aborted.", "AbortError"));
|
|
223
266
|
n.addEventListener("abort", o, { once: !0 }), Promise.resolve().then(() => e(t, n)).then(r, i).finally(() => n.removeEventListener("abort", o));
|
|
224
267
|
}) : e(t);
|
|
225
268
|
}
|
|
226
|
-
|
|
269
|
+
function* fe(e) {
|
|
270
|
+
function* t(n, r, i, o) {
|
|
271
|
+
if (o.has(n)) throw new TypeError("Cyclic grid children cannot be rendered.");
|
|
272
|
+
re(n) && (yield { component: n, componentIndex: r, componentPath: i });
|
|
273
|
+
const l = new Set(o).add(n);
|
|
274
|
+
for (const [a, s] of (n.grid?.cells ?? []).entries()) for (const [c, d] of s.entries()) for (const [h, m] of (d?.children ?? []).entries()) yield* t(m, r, [...i, a, c, h], l);
|
|
275
|
+
}
|
|
276
|
+
for (const [n, r] of e.components.entries()) yield* t(r, n, [], /* @__PURE__ */ new Set());
|
|
277
|
+
}
|
|
278
|
+
async function Et(e, t, n) {
|
|
227
279
|
const r = /* @__PURE__ */ new Map();
|
|
228
|
-
for (const i of e
|
|
229
|
-
!re(i) || r.has(i.imageData) || r.set(i.imageData, await
|
|
230
|
-
return
|
|
231
|
-
}
|
|
232
|
-
function
|
|
233
|
-
const
|
|
234
|
-
if (a <= 0 ||
|
|
235
|
-
const c = Math.min(i / a, o /
|
|
236
|
-
e.drawImage(t, n + (i -
|
|
237
|
-
}
|
|
238
|
-
function
|
|
239
|
-
return
|
|
240
|
-
}
|
|
241
|
-
const
|
|
242
|
-
function
|
|
243
|
-
const n = t / 96 *
|
|
280
|
+
for (const { component: i } of fe(e))
|
|
281
|
+
!re(i) || r.has(i.imageData) || r.set(i.imageData, await St(t, i.imageData, n));
|
|
282
|
+
return k(n), r;
|
|
283
|
+
}
|
|
284
|
+
function Tt(e, t, n, r, i, o) {
|
|
285
|
+
const l = t, a = l.naturalWidth ?? l.width ?? i, s = l.naturalHeight ?? l.height ?? o;
|
|
286
|
+
if (a <= 0 || s <= 0) throw new RangeError("Decoded Canvas image dimensions must be positive.");
|
|
287
|
+
const c = Math.min(i / a, o / s), d = a * c, h = s * c;
|
|
288
|
+
e.drawImage(t, n + (i - d) / 2, r + (o - h) / 2, d, h);
|
|
289
|
+
}
|
|
290
|
+
function Ct(e) {
|
|
291
|
+
return lt(e.pageHeightsPx, e.gapPx).window(e.viewportHeightPx, e.scrollTopPx, e.overscan);
|
|
292
|
+
}
|
|
293
|
+
const ue = 96 / 25.4;
|
|
294
|
+
function pe(e, t = 96) {
|
|
295
|
+
const n = t / 96 * ue;
|
|
244
296
|
return {
|
|
245
297
|
widthPx: Math.max(1, Math.round(e.pageWidthMm * n)),
|
|
246
298
|
heightPx: Math.max(1, Math.round(e.pageHeightMm * n))
|
|
247
299
|
};
|
|
248
300
|
}
|
|
249
|
-
function
|
|
301
|
+
function _e(e, t, n, r = 64e6) {
|
|
250
302
|
if (!Number.isFinite(t) || t <= 0 || !Number.isFinite(n) || n <= 0) throw new RangeError("Canvas dpr and dpi must be positive finite numbers.");
|
|
251
303
|
if (!Number.isFinite(r) || r <= 0) throw new RangeError("maxCanvasPixels must be positive and finite.");
|
|
252
|
-
const i =
|
|
253
|
-
if (!Number.isSafeInteger(o) || !Number.isSafeInteger(
|
|
254
|
-
return { width: o, height:
|
|
255
|
-
}
|
|
256
|
-
function
|
|
257
|
-
const i = document.createElement("canvas"), { widthPx: o, heightPx:
|
|
258
|
-
i.width = a.width, i.height = a.height, i.style.width = `${o}px`, i.style.height = `${
|
|
259
|
-
const
|
|
260
|
-
if (!
|
|
304
|
+
const i = pe(e, n), o = Math.round(i.widthPx * t), l = Math.round(i.heightPx * t);
|
|
305
|
+
if (!Number.isSafeInteger(o) || !Number.isSafeInteger(l) || o * l > r) throw new RangeError("Canvas page exceeds maxCanvasPixels; reduce resolution or split the report.");
|
|
306
|
+
return { width: o, height: l };
|
|
307
|
+
}
|
|
308
|
+
function je(e, t, n, r) {
|
|
309
|
+
const i = document.createElement("canvas"), { widthPx: o, heightPx: l } = pe(e, n), a = _e(e, t, n, r);
|
|
310
|
+
i.width = a.width, i.height = a.height, i.style.width = `${o}px`, i.style.height = `${l}px`;
|
|
311
|
+
const s = i.getContext("2d");
|
|
312
|
+
if (!s)
|
|
261
313
|
throw new Error("当前环境不支持 Canvas 2D(测试需真浏览器,见 e2e/canvas.spec.ts)");
|
|
262
|
-
return
|
|
263
|
-
}
|
|
264
|
-
function An(e, t = 96) {
|
|
265
|
-
return U(e, t).fontSizePx;
|
|
266
|
-
}
|
|
267
|
-
function We(e, t, n, r, i, o, s, a = "top") {
|
|
268
|
-
e.font = `${t.italic ? "italic " : ""}${t.bold ? "bold " : ""}${t.fontSizePx}px ${s}`, "letterSpacing" in e && (e.letterSpacing = "0px"), e.fillStyle = t.color, e.textBaseline = "alphabetic";
|
|
269
|
-
const l = t.fontSizePx * t.lineHeight, c = t.text === "" ? [""] : t.text.split(`
|
|
270
|
-
`), m = c.length * l;
|
|
271
|
-
let d = r;
|
|
272
|
-
a === "middle" ? d = r + (o - m) / 2 : a === "bottom" && (d = r + o - m), c.forEach((h, g) => {
|
|
273
|
-
Et(e, h, t, n, d + g * l + t.fontSizePx * 0.8, i);
|
|
274
|
-
}), e.textAlign = "left";
|
|
314
|
+
return s.scale(t, t), s.fillStyle = "#ffffff", s.fillRect(0, 0, o, l), { canvas: i, ctx: s };
|
|
275
315
|
}
|
|
276
|
-
function
|
|
277
|
-
|
|
278
|
-
if (!a) {
|
|
279
|
-
e.textAlign = n.align === "center" ? "center" : n.align === "right" ? "right" : "left";
|
|
280
|
-
const d = n.align === "center" ? r + o / 2 : n.align === "right" ? r + o : r;
|
|
281
|
-
e.fillText(t, d, i);
|
|
282
|
-
return;
|
|
283
|
-
}
|
|
284
|
-
const l = e.measureText(t).width + Math.max(0, s.length - 1) * a, c = n.align === "center" ? r + (o - l) / 2 : n.align === "right" ? r + o - l : r;
|
|
285
|
-
e.textAlign = "left";
|
|
286
|
-
let m = "";
|
|
287
|
-
s.forEach((d, h) => {
|
|
288
|
-
e.fillText(d, c + e.measureText(m).width + h * a, i), m += d;
|
|
289
|
-
});
|
|
316
|
+
function In(e, t = 96) {
|
|
317
|
+
return z(e, t).fontSizePx;
|
|
290
318
|
}
|
|
291
|
-
function
|
|
292
|
-
for (const a of
|
|
293
|
-
e.strokeStyle = a.color, e.lineWidth = W(a.widthPt,
|
|
319
|
+
function Rt(e, t, n, r, i, o, l) {
|
|
320
|
+
for (const a of Fe(t, n))
|
|
321
|
+
e.strokeStyle = a.color, e.lineWidth = W(a.widthPt, l), e.beginPath(), a.kind === "v" ? (e.moveTo(r + a.pos * o, i + a.from * o), e.lineTo(r + a.pos * o, i + a.to * o)) : (e.moveTo(r + a.from * o, i + a.pos * o), e.lineTo(r + a.to * o, i + a.pos * o)), e.stroke();
|
|
294
322
|
}
|
|
295
|
-
function
|
|
323
|
+
function Pt(e, t, n, r, i, o) {
|
|
296
324
|
e.beginPath(), t.top && (e.moveTo(n, r), e.lineTo(n + i, r)), t.right && (e.moveTo(n + i, r), e.lineTo(n + i, r + o)), t.bottom && (e.moveTo(n + i, r + o), e.lineTo(n, r + o)), t.left && (e.moveTo(n, r + o), e.lineTo(n, r)), e.stroke();
|
|
297
325
|
}
|
|
298
|
-
function
|
|
299
|
-
const
|
|
300
|
-
for (const g of
|
|
326
|
+
function At(e, t, n, r, i, o, l, a, s, c, d, h) {
|
|
327
|
+
const m = De(t, o / a, l / a);
|
|
328
|
+
for (const g of m.cells) {
|
|
301
329
|
const f = g.cell.style?.backgroundColor ?? n.style?.backgroundColor;
|
|
302
330
|
f && (e.fillStyle = f, e.fillRect(r + g.xMm * a, i + g.yMm * a, g.widthMm * a, g.heightMm * a));
|
|
303
331
|
}
|
|
304
|
-
|
|
305
|
-
const
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
332
|
+
Rt(e, m, n, r, i, a, s);
|
|
333
|
+
for (const g of m.cells) kt(e, g, n, r, i, a, s, c, d, h);
|
|
334
|
+
}
|
|
335
|
+
function kt(e, t, n, r, i, o, l, a, s, c) {
|
|
336
|
+
const d = n.grid?.paddingMm ?? 0.5, h = t.cell.text ?? "", m = ke(n.style, t.cell.style), g = z(m, l), f = t.cell.indentMm ?? 0, T = Math.max(0, t.widthMm - 2 * d - f), R = Le(h, T, { fontSizePt: g.fontSizePt, bold: m.bold, italic: m.italic, fontFamily: m.fontFamily ?? a, letterSpacingPt: m.letterSpacing }, s).join(`
|
|
337
|
+
`), b = { x: r + (t.xMm + d + f) * o, y: i + (t.yMm + d) * o, width: T * o, height: Math.max(0, t.heightMm - 2 * d) * o };
|
|
338
|
+
e.save(), e.beginPath(), e.rect(b.x, b.y, b.width, b.height), e.clip(), t.cell.richParagraphs?.length ? We(e, { ...n, richParagraphs: t.cell.richParagraphs, style: { verticalAlign: "middle", ...m } }, b, l, a) : ge(
|
|
339
|
+
e,
|
|
340
|
+
{
|
|
341
|
+
text: R,
|
|
342
|
+
fontSizePx: g.fontSizePx,
|
|
343
|
+
bold: m.bold ?? !1,
|
|
344
|
+
italic: m.italic,
|
|
345
|
+
underline: m.underline,
|
|
346
|
+
color: ce(m, Pe),
|
|
347
|
+
align: m.align ?? "left",
|
|
348
|
+
lineHeight: _(m),
|
|
349
|
+
letterSpacingPx: W(m.letterSpacing ?? 0, l)
|
|
350
|
+
},
|
|
351
|
+
r + (t.xMm + d + f) * o,
|
|
352
|
+
i + (t.yMm + d) * o,
|
|
353
|
+
T * o,
|
|
354
|
+
Math.max(0, t.heightMm - 2 * d) * o,
|
|
355
|
+
m.fontFamily ?? a,
|
|
356
|
+
m.verticalAlign ?? "middle"
|
|
357
|
+
);
|
|
358
|
+
for (const y of t.cell.children ?? []) ie(e, { ...y, leftMm: y.leftMm + b.x / o, topMm: y.topMm + b.y / o }, o, l, a, s, c);
|
|
359
|
+
e.restore();
|
|
360
|
+
}
|
|
361
|
+
function $t(e, t, n, r, i, o, l, a, s) {
|
|
362
|
+
const c = t.style ?? {}, d = z(c, l);
|
|
363
|
+
if ($e(t)) {
|
|
364
|
+
We(e, t, { x: n, y: r, width: i, height: o }, l, a);
|
|
365
|
+
return;
|
|
330
366
|
}
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
const c = t.style ?? {}, m = U(c, s), d = $e(t) ? t.richParagraphs.map((h) => h.segments.map((g) => g.text ?? g.field ?? "").join("")).join(`
|
|
334
|
-
`) : t.lines?.length ? t.lines.join(`
|
|
335
|
-
`) : ke(t.text ?? "", t.widthMm, { fontSizePt: m.fontSizePt, bold: c.bold, italic: c.italic, fontFamily: c.fontFamily ?? a, letterSpacingPt: c.letterSpacing }, l).join(`
|
|
367
|
+
const h = t.lines?.length ? t.lines.join(`
|
|
368
|
+
`) : Le(t.text ?? "", t.widthMm, { fontSizePt: d.fontSizePt, bold: c.bold, italic: c.italic, fontFamily: c.fontFamily ?? a, letterSpacingPt: c.letterSpacing }, s).join(`
|
|
336
369
|
`);
|
|
337
|
-
|
|
338
|
-
text:
|
|
339
|
-
fontSizePx:
|
|
370
|
+
ge(e, {
|
|
371
|
+
text: h,
|
|
372
|
+
fontSizePx: d.fontSizePx,
|
|
340
373
|
bold: c.bold ?? !1,
|
|
341
374
|
italic: c.italic,
|
|
342
|
-
|
|
375
|
+
underline: c.underline,
|
|
376
|
+
color: ce(c),
|
|
343
377
|
align: c.align ?? "left",
|
|
344
|
-
lineHeight:
|
|
345
|
-
letterSpacingPx: W(c.letterSpacing ?? 0,
|
|
378
|
+
lineHeight: _(c),
|
|
379
|
+
letterSpacingPx: W(c.letterSpacing ?? 0, l)
|
|
346
380
|
}, n, r, i, o, c.fontFamily ?? a, c.verticalAlign);
|
|
347
381
|
}
|
|
348
|
-
function
|
|
349
|
-
const a = t.leftMm * n,
|
|
382
|
+
function ie(e, t, n, r, i, o, l) {
|
|
383
|
+
const a = t.leftMm * n, s = t.topMm * n, c = t.widthMm * n, d = t.heightMm * n, h = t.style ?? {};
|
|
350
384
|
if (re(t)) {
|
|
351
|
-
const
|
|
352
|
-
|
|
385
|
+
const m = l?.get(t.imageData);
|
|
386
|
+
m ? Tt(e, m, a, s, c, d) : xe(e, t, a, s, c, d);
|
|
353
387
|
return;
|
|
354
388
|
}
|
|
355
389
|
if (t.grid) {
|
|
356
|
-
|
|
390
|
+
At(e, t.grid, t, a, s, c, d, n, r, i, o, l);
|
|
357
391
|
return;
|
|
358
392
|
}
|
|
359
393
|
switch (t.kind) {
|
|
360
394
|
case "text": {
|
|
361
|
-
|
|
395
|
+
$t(e, t, a, s, c, d, r, i, o);
|
|
362
396
|
break;
|
|
363
397
|
}
|
|
364
398
|
case "rect": {
|
|
365
|
-
const
|
|
366
|
-
|
|
399
|
+
const m = q(h), g = Ae(h);
|
|
400
|
+
h.backgroundColor && (e.fillStyle = h.backgroundColor, e.fillRect(a, s, c, d)), g.inner && (e.strokeStyle = m.color, e.lineWidth = W(m.widthPt, r), Pt(e, g, a, s, c, d));
|
|
367
401
|
break;
|
|
368
402
|
}
|
|
369
403
|
case "line": {
|
|
370
|
-
const
|
|
371
|
-
e.strokeStyle =
|
|
372
|
-
const g = t.lineDirection === "up" ?
|
|
404
|
+
const m = q({ ...h, borderColor: h.lineColor ?? h.borderColor });
|
|
405
|
+
e.strokeStyle = m.color, e.lineWidth = W(m.widthPt, r), e.beginPath();
|
|
406
|
+
const g = t.lineDirection === "up" ? s + d : t.lineDirection === "down" ? s : s + d / 2, f = t.lineDirection === "up" ? s : t.lineDirection === "down" ? s + d : s + d / 2;
|
|
373
407
|
e.moveTo(a, g), e.lineTo(a + c, f), e.stroke();
|
|
374
408
|
break;
|
|
375
409
|
}
|
|
376
410
|
case "ellipse": {
|
|
377
|
-
const
|
|
378
|
-
e.strokeStyle =
|
|
411
|
+
const m = q(h);
|
|
412
|
+
e.strokeStyle = m.color, e.lineWidth = W(m.widthPt, r), h.backgroundColor && (e.fillStyle = h.backgroundColor, e.beginPath(), e.ellipse(a + c / 2, s + d / 2, c / 2, d / 2, 0, 0, Math.PI * 2), e.fill()), e.beginPath(), e.ellipse(a + c / 2, s + d / 2, c / 2, d / 2, 0, 0, Math.PI * 2), e.stroke();
|
|
379
413
|
break;
|
|
380
414
|
}
|
|
381
415
|
default:
|
|
382
|
-
|
|
416
|
+
xe(e, t, a, s, c, d);
|
|
383
417
|
break;
|
|
384
418
|
}
|
|
385
419
|
}
|
|
386
|
-
function
|
|
420
|
+
function xe(e, t, n, r, i, o) {
|
|
387
421
|
e.save(), e.strokeStyle = "#94a3b8", e.strokeRect(n, r, i, o), e.fillStyle = "#64748b", e.font = "12px sans-serif", e.fillText(t.fallbackText ?? `[${t.kind}]`, n + 3, r + 14), e.restore();
|
|
388
422
|
}
|
|
389
|
-
async function
|
|
423
|
+
async function Nn(e, t = {}) {
|
|
390
424
|
if (typeof document > "u")
|
|
391
425
|
throw new Error("renderPlanToImages 需要浏览器环境(SSR/Node 请在客户端钩子中调用)");
|
|
392
426
|
const { format: n = "png", quality: r = 0.92, ...i } = t;
|
|
393
427
|
if (n !== "png" && n !== "jpeg") throw new TypeError("Image format must be png or jpeg.");
|
|
394
428
|
if (!Number.isFinite(r) || r < 0 || r > 1) throw new RangeError("Image quality must be between 0 and 1.");
|
|
395
|
-
|
|
396
|
-
const o = await
|
|
429
|
+
k(t.signal);
|
|
430
|
+
const o = await he(e, { ...t, format: "canvas" });
|
|
397
431
|
e = o.plan;
|
|
398
|
-
const
|
|
399
|
-
for (let
|
|
400
|
-
|
|
401
|
-
const
|
|
432
|
+
const l = [...o.diagnostics, ...Y(e, "canvas", t)], a = n === "jpeg" ? "image/jpeg" : "image/png", s = [], c = Math.min(e.pages.length - 1, t.end ?? e.pages.length - 1);
|
|
433
|
+
for (let d = Math.max(0, t.start ?? 0); d <= c; d++) {
|
|
434
|
+
k(t.signal);
|
|
435
|
+
const h = await Ue(e.pages[d], d, i, l);
|
|
402
436
|
try {
|
|
403
|
-
|
|
437
|
+
s.push(await It(h, a, r, t.signal));
|
|
404
438
|
} finally {
|
|
405
|
-
|
|
439
|
+
h.width = 0, h.height = 0;
|
|
406
440
|
}
|
|
407
|
-
await
|
|
441
|
+
await st(t, s.length, c - Math.max(0, t.start ?? 0) + 1);
|
|
408
442
|
}
|
|
409
|
-
return
|
|
443
|
+
return k(t.signal), { blobs: s, diagnostics: l };
|
|
410
444
|
}
|
|
411
|
-
function
|
|
412
|
-
return
|
|
413
|
-
const
|
|
414
|
-
r?.addEventListener("abort",
|
|
445
|
+
function It(e, t, n, r) {
|
|
446
|
+
return k(r), new Promise((i, o) => {
|
|
447
|
+
const l = () => o(r?.reason ?? new DOMException("The operation was aborted.", "AbortError"));
|
|
448
|
+
r?.addEventListener("abort", l, { once: !0 });
|
|
415
449
|
try {
|
|
416
450
|
e.toBlob((a) => {
|
|
417
|
-
r?.removeEventListener("abort",
|
|
451
|
+
r?.removeEventListener("abort", l), a ? i(a) : o(new Error("Canvas encoding failed; no empty image was emitted."));
|
|
418
452
|
}, t, n);
|
|
419
453
|
} catch (a) {
|
|
420
|
-
r?.removeEventListener("abort",
|
|
454
|
+
r?.removeEventListener("abort", l), o(a);
|
|
421
455
|
}
|
|
422
456
|
});
|
|
423
457
|
}
|
|
424
|
-
function
|
|
425
|
-
if (
|
|
458
|
+
function Ln(e, t = {}) {
|
|
459
|
+
if (k(t.signal), typeof document > "u")
|
|
426
460
|
throw new Error("renderPlanToCanvas 需要浏览器环境(SSR 请在客户端钩子中调用)");
|
|
427
|
-
const n = t.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), r = t.dpi ?? 96, i = r / 96 *
|
|
428
|
-
for (const
|
|
429
|
-
|
|
430
|
-
if (t.fidelity === "strict" &&
|
|
431
|
-
for (let
|
|
432
|
-
|
|
433
|
-
const g = e.pages[
|
|
434
|
-
for (const
|
|
435
|
-
|
|
461
|
+
const n = t.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), r = t.dpi ?? 96, i = r / 96 * ue, o = t.fontFamily ?? ne, l = t.measurer ?? de, a = Math.max(0, t.start ?? 0), s = Math.min(e.pages.length - 1, t.end ?? e.pages.length - 1), c = [], d = Y(e, "canvas", t), h = Nt(e, a, s);
|
|
462
|
+
for (const m of h)
|
|
463
|
+
Oe(m, t), d.push(m);
|
|
464
|
+
if (t.fidelity === "strict" && h.length) throw new ot(d);
|
|
465
|
+
for (let m = a; m <= s; m++) {
|
|
466
|
+
k(t.signal);
|
|
467
|
+
const g = e.pages[m], { canvas: f, ctx: T } = je(g, n, r, t.maxCanvasPixels);
|
|
468
|
+
for (const R of g.components)
|
|
469
|
+
ie(T, R, i, r, o, l);
|
|
436
470
|
c.push(f);
|
|
437
471
|
}
|
|
438
|
-
return { canvases: c, diagnostics:
|
|
472
|
+
return { canvases: c, diagnostics: d };
|
|
439
473
|
}
|
|
440
|
-
function
|
|
441
|
-
return n < t ? [] : e.pages.slice(t, n + 1).flatMap((r, i) => r.
|
|
474
|
+
function Nt(e, t, n) {
|
|
475
|
+
return n < t ? [] : e.pages.slice(t, n + 1).flatMap((r, i) => [...fe(r)].map(({ component: o, componentIndex: l, componentPath: a }) => ({
|
|
442
476
|
code: "async-image-required",
|
|
443
477
|
severity: "warning",
|
|
444
478
|
format: "canvas",
|
|
445
479
|
pageIndex: t + i,
|
|
446
|
-
componentIndex:
|
|
480
|
+
componentIndex: l,
|
|
481
|
+
componentPath: a,
|
|
447
482
|
kind: o.kind,
|
|
448
483
|
nid: o.nid,
|
|
449
484
|
message: "Use renderPlanToCanvasAsync or renderPlanToImages to decode and include images."
|
|
450
|
-
}
|
|
485
|
+
})));
|
|
451
486
|
}
|
|
452
|
-
async function
|
|
487
|
+
async function Dn(e, t = {}) {
|
|
453
488
|
if (typeof document > "u") throw new Error("renderPlanToCanvasAsync 需要浏览器环境(Node 请使用 PDF 或 XLSX 输出)");
|
|
454
|
-
|
|
455
|
-
const n = await
|
|
489
|
+
k(t.signal);
|
|
490
|
+
const n = await he(e, { ...t, format: "canvas" });
|
|
456
491
|
e = n.plan;
|
|
457
|
-
const r = [...n.diagnostics, ...
|
|
458
|
-
for (let
|
|
459
|
-
i.push(await
|
|
492
|
+
const r = [...n.diagnostics, ...Y(e, "canvas", t)], i = [], o = Math.min(e.pages.length - 1, t.end ?? e.pages.length - 1);
|
|
493
|
+
for (let l = Math.max(0, t.start ?? 0); l <= o; l++)
|
|
494
|
+
i.push(await Ue(e.pages[l], l, t, r));
|
|
460
495
|
return { canvases: i, diagnostics: r };
|
|
461
496
|
}
|
|
462
|
-
async function
|
|
463
|
-
const i = n.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), o = n.dpi ?? 96,
|
|
464
|
-
|
|
465
|
-
const { canvas:
|
|
466
|
-
for (const
|
|
467
|
-
return
|
|
497
|
+
async function Ue(e, t, n, r) {
|
|
498
|
+
const i = n.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), o = n.dpi ?? 96, l = n.fontFamily ?? ne, a = await Ge(e, t, n, r);
|
|
499
|
+
k(n.signal);
|
|
500
|
+
const { canvas: s, ctx: c } = je(e, i, o, n.maxCanvasPixels);
|
|
501
|
+
for (const d of e.components) ie(c, d, o / 25.4, o, l, n.measurer ?? de, a);
|
|
502
|
+
return s;
|
|
468
503
|
}
|
|
469
|
-
async function
|
|
470
|
-
const i = n.imageLoader ??
|
|
471
|
-
return
|
|
504
|
+
async function Ge(e, t, n, r) {
|
|
505
|
+
const i = n.imageLoader ?? xt;
|
|
506
|
+
return Et(e, async (o, l) => {
|
|
472
507
|
try {
|
|
473
|
-
return await i(o,
|
|
508
|
+
return await i(o, l);
|
|
474
509
|
} catch (a) {
|
|
475
|
-
if (
|
|
476
|
-
const
|
|
477
|
-
throw r.push(m),
|
|
510
|
+
if (l?.aborted) throw a;
|
|
511
|
+
const s = [...fe(e)].find(({ component: g }) => g.imageData === o), { component: c, componentIndex: d, componentPath: h } = s, m = { code: "image-decode-failed", severity: "warning", format: "canvas", pageIndex: t, componentIndex: d, componentPath: h, kind: c.kind, nid: c.nid, message: "Image decoding failed; raster output was cancelled instead of omitting the image." };
|
|
512
|
+
throw r.push(m), Oe(m, n), a;
|
|
478
513
|
}
|
|
479
514
|
}, n.signal);
|
|
480
515
|
}
|
|
481
|
-
function
|
|
482
|
-
const n = t.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), r = t.dpi ?? 96, i = r / 96 *
|
|
483
|
-
let g = null, f = null,
|
|
484
|
-
const
|
|
485
|
-
function
|
|
516
|
+
function Fn(e, t = {}) {
|
|
517
|
+
const n = t.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), r = t.dpi ?? 96, i = r / 96 * ue, o = t.fontFamily ?? ne, l = t.measurer ?? de, a = t.overscan ?? 1, s = t.gapPx ?? 18, c = t.pagesPerFrame ?? 1, d = e.pages.map((u) => u.pageHeightMm * i), h = Math.max(1, ...e.pages.map((u) => u.pageWidthMm * i)), m = { start: 0, end: -1 };
|
|
518
|
+
let g = null, f = null, T = null, R = null, b = [], y = 0, P = [], H = 0, N = new AbortController();
|
|
519
|
+
const be = [];
|
|
520
|
+
function Ke() {
|
|
486
521
|
const u = g;
|
|
487
|
-
u.innerHTML = "", f = document.createElement("div"), f.style.cssText = `width:${
|
|
488
|
-
const
|
|
489
|
-
for (let
|
|
490
|
-
const
|
|
491
|
-
|
|
522
|
+
u.innerHTML = "", f = document.createElement("div"), f.style.cssText = `width:${h}px;margin:0 auto;`, T = document.createElement("div"), R = document.createElement("div"), f.appendChild(T), b = [];
|
|
523
|
+
const x = Math.min(e.pages.length, 3 + a * 2);
|
|
524
|
+
for (let F = 0; F < x; F++) {
|
|
525
|
+
const M = document.createElement("div");
|
|
526
|
+
M.style.cssText = `margin:0 auto ${s}px;box-shadow:0 2px 8px rgba(0,0,0,.35);background:#fff;`, f.appendChild(M), b.push(M);
|
|
492
527
|
}
|
|
493
|
-
f.appendChild(
|
|
528
|
+
f.appendChild(R), u.appendChild(f);
|
|
494
529
|
}
|
|
495
|
-
async function Je(u,
|
|
496
|
-
const
|
|
497
|
-
|
|
498
|
-
const
|
|
499
|
-
if (
|
|
500
|
-
const { widthPx:
|
|
501
|
-
let
|
|
502
|
-
(!
|
|
503
|
-
const
|
|
504
|
-
|
|
505
|
-
const B =
|
|
530
|
+
async function Je(u, x) {
|
|
531
|
+
const F = H, M = await he(e, { ...t, signal: N.signal, format: "canvas", start: x, end: x });
|
|
532
|
+
be.push(...M.diagnostics);
|
|
533
|
+
const C = M.plan.pages[x], X = await Ge(C, x, { ...t, signal: N.signal }, be);
|
|
534
|
+
if (F !== H || !g) return;
|
|
535
|
+
const { widthPx: oe, heightPx: se } = pe(C, r);
|
|
536
|
+
let L = u.firstElementChild;
|
|
537
|
+
(!L || L.tagName !== "CANVAS") && (L = document.createElement("canvas"), u.innerHTML = "", u.appendChild(L));
|
|
538
|
+
const ve = _e(C, n, r, t.maxCanvasPixels);
|
|
539
|
+
L.width = ve.width, L.height = ve.height, L.style.width = `${oe}px`, L.style.height = `${se}px`;
|
|
540
|
+
const B = L.getContext("2d");
|
|
506
541
|
if (B) {
|
|
507
|
-
B.setTransform(1, 0, 0, 1, 0, 0), B.scale(n, n), B.fillStyle = "#ffffff", B.fillRect(0, 0,
|
|
508
|
-
for (const
|
|
509
|
-
|
|
510
|
-
|
|
542
|
+
B.setTransform(1, 0, 0, 1, 0, 0), B.scale(n, n), B.fillStyle = "#ffffff", B.fillRect(0, 0, oe, se);
|
|
543
|
+
for (const Ze of C.components)
|
|
544
|
+
ie(B, Ze, i, r, o, l, X);
|
|
545
|
+
L.dataset.canvasPage = String(x), u.style.height = `${se}px`, u.style.width = `${oe}px`;
|
|
511
546
|
}
|
|
512
547
|
}
|
|
513
|
-
function
|
|
514
|
-
|
|
515
|
-
const
|
|
516
|
-
|
|
517
|
-
const
|
|
518
|
-
|
|
519
|
-
if (
|
|
520
|
-
|
|
521
|
-
const
|
|
522
|
-
|
|
548
|
+
function Xe(u) {
|
|
549
|
+
H++, m.start = u.start, m.end = u.end, T.style.height = `${u.start * s + d.slice(0, u.start).reduce((M, C) => M + C, 0)}px`;
|
|
550
|
+
const x = e.pages.length - 1 - u.end;
|
|
551
|
+
R.style.height = `${x * s + d.slice(u.end + 1).reduce((M, C) => M + C, 0)}px`;
|
|
552
|
+
const F = u.end - u.start + 1;
|
|
553
|
+
b.forEach((M, C) => {
|
|
554
|
+
if (C < F) {
|
|
555
|
+
M.style.display = "";
|
|
556
|
+
const X = u.start + C;
|
|
557
|
+
M.style.height = `${d[X] ?? 0}px`;
|
|
523
558
|
} else
|
|
524
|
-
|
|
525
|
-
}),
|
|
526
|
-
for (let
|
|
527
|
-
const
|
|
528
|
-
if (!
|
|
529
|
-
|
|
559
|
+
M.style.display = "none";
|
|
560
|
+
}), P = [];
|
|
561
|
+
for (let M = u.start; M <= u.end; M++) {
|
|
562
|
+
const C = b[M - u.start];
|
|
563
|
+
if (!C) continue;
|
|
564
|
+
C.firstElementChild?.dataset?.canvasPage !== String(M) && P.push(M);
|
|
530
565
|
}
|
|
531
|
-
|
|
566
|
+
ae();
|
|
532
567
|
}
|
|
533
|
-
function
|
|
534
|
-
|
|
535
|
-
|
|
568
|
+
function ae() {
|
|
569
|
+
y || P.length === 0 || (y = requestAnimationFrame(() => {
|
|
570
|
+
y = 0;
|
|
536
571
|
let u = Math.max(1, c);
|
|
537
|
-
for (;
|
|
538
|
-
const
|
|
539
|
-
|
|
572
|
+
for (; P.length > 0 && u-- > 0; ) {
|
|
573
|
+
const x = P.shift(), F = b[x - m.start];
|
|
574
|
+
F && Je(F, x).catch(() => {
|
|
540
575
|
});
|
|
541
576
|
}
|
|
542
|
-
|
|
577
|
+
P.length > 0 && ae();
|
|
543
578
|
}));
|
|
544
579
|
}
|
|
545
|
-
function
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
const u = g,
|
|
549
|
-
pageHeightsPx:
|
|
580
|
+
function K() {
|
|
581
|
+
y || (y = requestAnimationFrame(() => {
|
|
582
|
+
y = 0;
|
|
583
|
+
const u = g, x = Ct({
|
|
584
|
+
pageHeightsPx: d,
|
|
550
585
|
viewportHeightPx: u.clientHeight,
|
|
551
586
|
scrollTopPx: u.scrollTop,
|
|
552
587
|
overscan: a,
|
|
553
|
-
gapPx:
|
|
588
|
+
gapPx: s
|
|
554
589
|
});
|
|
555
|
-
|
|
590
|
+
x.start !== m.start || x.end !== m.end ? Xe(x) : ae();
|
|
556
591
|
}));
|
|
557
592
|
}
|
|
558
|
-
let
|
|
593
|
+
let J = null;
|
|
559
594
|
return {
|
|
560
595
|
attach(u) {
|
|
561
596
|
if (typeof document > "u")
|
|
562
597
|
throw new Error("createCanvasPager 需要浏览器环境(SSR 请在客户端钩子中调用 attach)");
|
|
563
|
-
|
|
598
|
+
k(t.signal), N = new AbortController(), t.signal?.addEventListener("abort", Me, { once: !0 }), Y(e, "canvas", t), g = u, Ke(), u.addEventListener("scroll", K, { passive: !0 }), typeof ResizeObserver < "u" && (J = new ResizeObserver(() => K()), J.observe(u)), K();
|
|
564
599
|
},
|
|
565
600
|
destroy() {
|
|
566
|
-
|
|
601
|
+
H++, N.abort(), t.signal?.removeEventListener("abort", Me), y && cancelAnimationFrame(y), y = 0, J?.disconnect(), J = null, g?.removeEventListener("scroll", K), P = [], f?.remove(), g = null;
|
|
567
602
|
},
|
|
568
603
|
window() {
|
|
569
|
-
return { ...
|
|
604
|
+
return { ...m };
|
|
570
605
|
}
|
|
571
606
|
};
|
|
572
|
-
function
|
|
573
|
-
|
|
607
|
+
function Me() {
|
|
608
|
+
N.abort(t.signal?.reason);
|
|
574
609
|
}
|
|
575
610
|
}
|
|
576
|
-
function
|
|
611
|
+
function qe(e, t, n) {
|
|
577
612
|
let r, i;
|
|
578
613
|
if (typeof e == "string") {
|
|
579
|
-
const o =
|
|
580
|
-
if (!o) throw new Error(`未知纸张预设 "${e}"(可用:${Object.keys(
|
|
614
|
+
const o = Q[e];
|
|
615
|
+
if (!o) throw new Error(`未知纸张预设 "${e}"(可用:${Object.keys(Q).join("/")})`);
|
|
581
616
|
r = o.widthMm, i = o.heightMm;
|
|
582
617
|
} else typeof e == "number" ? (r = e, i = t ?? 297) : (r = e.widthMm, i = e.heightMm);
|
|
583
618
|
return n ? { widthMm: i, heightMm: r } : { widthMm: r, heightMm: i };
|
|
584
619
|
}
|
|
585
|
-
class
|
|
620
|
+
class Lt {
|
|
586
621
|
constructor() {
|
|
587
622
|
this.pages = [], this.pending = null, this.templateParams = void 0;
|
|
588
623
|
}
|
|
@@ -615,18 +650,18 @@ class $t {
|
|
|
615
650
|
*/
|
|
616
651
|
page(t = "a4", n = {}, r) {
|
|
617
652
|
this.collect();
|
|
618
|
-
const o = r != null && !("margins" in r) && !("landscape" in r) && ("marginTopMm" in r || "marginBottomMm" in r || "marginLeftMm" in r || "marginRightMm" in r) ? { margins: r } : typeof n == "number" ? r ?? {} : n, { widthMm:
|
|
653
|
+
const o = r != null && !("margins" in r) && !("landscape" in r) && ("marginTopMm" in r || "marginBottomMm" in r || "marginLeftMm" in r || "marginRightMm" in r) ? { margins: r } : typeof n == "number" ? r ?? {} : n, { widthMm: l, heightMm: a } = qe(
|
|
619
654
|
t,
|
|
620
655
|
typeof n == "number" ? n : void 0,
|
|
621
656
|
o.landscape
|
|
622
|
-
),
|
|
623
|
-
return this.pending = new
|
|
624
|
-
widthMm:
|
|
657
|
+
), s = o.margins ?? {};
|
|
658
|
+
return this.pending = new Dt(this, {
|
|
659
|
+
widthMm: l,
|
|
625
660
|
heightMm: a,
|
|
626
|
-
marginTopMm:
|
|
627
|
-
marginBottomMm:
|
|
628
|
-
marginLeftMm:
|
|
629
|
-
marginRightMm:
|
|
661
|
+
marginTopMm: s.marginTopMm ?? 10,
|
|
662
|
+
marginBottomMm: s.marginBottomMm ?? 10,
|
|
663
|
+
marginLeftMm: s.marginLeftMm ?? 10,
|
|
664
|
+
marginRightMm: s.marginRightMm ?? 10
|
|
630
665
|
}), this.pending;
|
|
631
666
|
}
|
|
632
667
|
collect() {
|
|
@@ -642,7 +677,7 @@ class $t {
|
|
|
642
677
|
};
|
|
643
678
|
}
|
|
644
679
|
}
|
|
645
|
-
class
|
|
680
|
+
class Dt {
|
|
646
681
|
constructor(t, n) {
|
|
647
682
|
this.parent = t, this.page = n, this.components = [];
|
|
648
683
|
}
|
|
@@ -711,26 +746,26 @@ class kt {
|
|
|
711
746
|
return this.done().build();
|
|
712
747
|
}
|
|
713
748
|
}
|
|
714
|
-
function
|
|
715
|
-
return new
|
|
749
|
+
function On() {
|
|
750
|
+
return new Lt();
|
|
716
751
|
}
|
|
717
|
-
function
|
|
718
|
-
return
|
|
752
|
+
function zn(e, t = {}) {
|
|
753
|
+
return et([], e), e.fields.map((n) => ({
|
|
719
754
|
field: n.field,
|
|
720
755
|
header: `${n.label ?? n.field}${n.unit ? ` (${n.unit})` : ""}`,
|
|
721
756
|
semanticRole: n.semanticRole ?? (n.type === "number" || n.type === "decimal" ? "measure" : n.type === "date" ? "date" : n.enum ? "dimension" : "text"),
|
|
722
757
|
...t[n.field]
|
|
723
758
|
}));
|
|
724
759
|
}
|
|
725
|
-
function
|
|
760
|
+
function $(e, t, n = !1) {
|
|
726
761
|
if (!Number.isFinite(e) || (n ? e < 0 : e <= 0))
|
|
727
762
|
throw new Error(`${t} 必须是有限${n ? "非负" : "正"}数`);
|
|
728
763
|
}
|
|
729
|
-
function
|
|
764
|
+
function ee(e, t, n) {
|
|
730
765
|
if (e !== void 0 && !["left", "center", "right", "justify", ...n ? ["auto"] : []].includes(e))
|
|
731
766
|
throw new Error(`${t} 必须是 left/center/right/justify${n ? "/auto" : ""}`);
|
|
732
767
|
}
|
|
733
|
-
function
|
|
768
|
+
function Ft(e) {
|
|
734
769
|
const t = e.layout ?? "page";
|
|
735
770
|
if (t !== "page" && t !== "wide")
|
|
736
771
|
throw new Error("layout 必须是 page 或 wide");
|
|
@@ -739,18 +774,18 @@ function It(e) {
|
|
|
739
774
|
if (t !== "wide" && e.columnWidthMm !== void 0)
|
|
740
775
|
throw new Error('columnWidthMm 仅适用于 layout: "wide"');
|
|
741
776
|
const n = e.columnWidthMm ?? 30;
|
|
742
|
-
return
|
|
777
|
+
return $(n, "columnWidthMm"), { layout: t, columnWidthMm: n };
|
|
743
778
|
}
|
|
744
|
-
function
|
|
779
|
+
function Ot(e) {
|
|
745
780
|
const t = e.paper === void 0 ? "a4" : e.paper;
|
|
746
781
|
if (typeof t != "string" && (typeof t != "object" || t === null) || e.landscape !== void 0 && typeof e.landscape != "boolean")
|
|
747
782
|
throw new Error("paper 必须是纸张预设名或 { widthMm, heightMm } 对象,landscape 必须是布尔值");
|
|
748
|
-
if (typeof t == "string" && !Object.prototype.hasOwnProperty.call(
|
|
749
|
-
throw new Error(`未知纸张预设 "${t}"(可用:${Object.keys(
|
|
750
|
-
const n =
|
|
751
|
-
return
|
|
783
|
+
if (typeof t == "string" && !Object.prototype.hasOwnProperty.call(Q, t))
|
|
784
|
+
throw new Error(`未知纸张预设 "${t}"(可用:${Object.keys(Q).join("/")})`);
|
|
785
|
+
const n = qe(t, void 0, e.landscape), r = n.widthMm, i = n.heightMm;
|
|
786
|
+
return $(r, "纸张 widthMm"), $(i, "纸张 heightMm"), { widthMm: r, heightMm: i };
|
|
752
787
|
}
|
|
753
|
-
function
|
|
788
|
+
function zt(e) {
|
|
754
789
|
if (e.margins !== void 0 && (!e.margins || typeof e.margins != "object" || Array.isArray(e.margins)))
|
|
755
790
|
throw new Error("margins 必须是页边距对象");
|
|
756
791
|
const t = e.margins ?? {}, n = {
|
|
@@ -759,133 +794,133 @@ function Lt(e) {
|
|
|
759
794
|
marginLeftMm: t.marginLeftMm === void 0 ? 10 : t.marginLeftMm,
|
|
760
795
|
marginRightMm: t.marginRightMm === void 0 ? 10 : t.marginRightMm
|
|
761
796
|
};
|
|
762
|
-
for (const [r, i] of Object.entries(n))
|
|
797
|
+
for (const [r, i] of Object.entries(n)) $(i, r, !0);
|
|
763
798
|
return n;
|
|
764
799
|
}
|
|
765
|
-
function
|
|
800
|
+
function Ht(e, t) {
|
|
766
801
|
const n = e.dataset === void 0 ? "detail" : e.dataset;
|
|
767
802
|
if (typeof n != "string" || !n.trim())
|
|
768
803
|
throw new Error("dataset 必须是非空字符串");
|
|
769
804
|
if (e.title !== void 0 && typeof e.title != "string")
|
|
770
805
|
throw new Error("title 必须是字符串");
|
|
771
806
|
const r = e.titleHeightMm === void 0 ? 10 : e.titleHeightMm, i = e.titleGapMm === void 0 ? 4 : e.titleGapMm;
|
|
772
|
-
|
|
773
|
-
const o = e.title !== void 0 && e.title.length > 0,
|
|
774
|
-
if (
|
|
807
|
+
$(r, "titleHeightMm"), $(i, "titleGapMm", !0);
|
|
808
|
+
const o = e.title !== void 0 && e.title.length > 0, l = o ? r + i : 0;
|
|
809
|
+
if (l >= t)
|
|
775
810
|
throw new Error("标题高度与间距占满页面,必须为表格保留可用高度");
|
|
776
|
-
return { dataset: n, titleHeightMm: r, hasTitle: o, titleSpaceMm:
|
|
811
|
+
return { dataset: n, titleHeightMm: r, hasTitle: o, titleSpaceMm: l };
|
|
777
812
|
}
|
|
778
|
-
function
|
|
813
|
+
function Bt(e) {
|
|
779
814
|
if (e.listOptions !== void 0 && (!e.listOptions || typeof e.listOptions != "object" || Array.isArray(e.listOptions)))
|
|
780
815
|
throw new Error("listOptions 必须是列表配置对象");
|
|
781
816
|
const t = e.listOptions ?? {};
|
|
782
|
-
|
|
817
|
+
ee(t.align, "listOptions.align", !0), ee(t.headerAlign, "listOptions.headerAlign", !1);
|
|
783
818
|
for (const n of ["fontSizePt", "rowHeightMm", "paddingMm"]) {
|
|
784
819
|
const r = t[n];
|
|
785
|
-
r !== void 0 &&
|
|
820
|
+
r !== void 0 && $(r, `listOptions.${n}`, n === "paddingMm");
|
|
786
821
|
}
|
|
787
822
|
return t;
|
|
788
823
|
}
|
|
789
|
-
function
|
|
824
|
+
function Wt(e) {
|
|
790
825
|
let t = 0, n = 0;
|
|
791
826
|
for (const [r, i] of e.entries()) {
|
|
792
827
|
if (!i || typeof i.header != "string" || typeof i.field != "string" || !i.field.trim())
|
|
793
828
|
throw new Error(`columns[${r}] 需要字符串 header 与非空 field`);
|
|
794
|
-
|
|
829
|
+
ee(i.align, `columns[${r}].align`, !0), ee(i.headerAlign, `columns[${r}].headerAlign`, !1), i.flex !== void 0 && $(i.flex, `columns[${r}].flex`), i.widthMm !== void 0 ? ($(i.widthMm, `columns[${r}].widthMm`), t += i.widthMm) : n = Math.max(n, i.flex ?? 1);
|
|
795
830
|
}
|
|
796
831
|
return { fixedWidthMm: t, maxFlex: n };
|
|
797
832
|
}
|
|
798
|
-
function
|
|
799
|
-
const { fixedWidthMm: i, maxFlex: o } =
|
|
833
|
+
function _t(e, t, n, r) {
|
|
834
|
+
const { fixedWidthMm: i, maxFlex: o } = Wt(e.columns);
|
|
800
835
|
if (t === "page" && i > r)
|
|
801
836
|
throw new Error(`固定列宽 ${i}mm 超出页面可用宽度 ${r}mm`);
|
|
802
|
-
const
|
|
803
|
-
if (t === "page" && o > 0 &&
|
|
837
|
+
const l = r - i;
|
|
838
|
+
if (t === "page" && o > 0 && l <= 0)
|
|
804
839
|
throw new Error("固定列占满页面可用宽度,自动列需要正的剩余宽度");
|
|
805
|
-
const a = o > 0 ? e.columns.reduce((c,
|
|
806
|
-
return { columns: e.columns.map(({ widthMm: c, flex:
|
|
807
|
-
const g = c ?? (t === "wide" ? n * (
|
|
808
|
-
return
|
|
840
|
+
const a = o > 0 ? e.columns.reduce((c, d) => c + (d.widthMm === void 0 ? (d.flex ?? 1) / o : 0), 0) : 0;
|
|
841
|
+
return { columns: e.columns.map(({ widthMm: c, flex: d, ...h }, m) => {
|
|
842
|
+
const g = c ?? (t === "wide" ? n * (d ?? 1) : l * ((d ?? 1) / o) / a);
|
|
843
|
+
return $(g, `columns[${m}] 分配后的 widthMm`), { ...h, widthMm: g };
|
|
809
844
|
}), fixedWidthMm: i, maxFlex: o };
|
|
810
845
|
}
|
|
811
|
-
function
|
|
846
|
+
function Hn(e) {
|
|
812
847
|
if (!e || typeof e != "object")
|
|
813
848
|
throw new Error("标准明细模板需要 options 对象");
|
|
814
849
|
if (!Array.isArray(e.columns) || e.columns.length === 0)
|
|
815
850
|
throw new Error("columns 至少需要一列");
|
|
816
|
-
const { layout: t, columnWidthMm: n } =
|
|
851
|
+
const { layout: t, columnWidthMm: n } = Ft(e), r = Ot(e);
|
|
817
852
|
let i = r.widthMm;
|
|
818
|
-
const o = r.heightMm,
|
|
819
|
-
let a = i -
|
|
820
|
-
const
|
|
821
|
-
if (t === "page" && a <= 0 ||
|
|
853
|
+
const o = r.heightMm, l = zt(e);
|
|
854
|
+
let a = i - l.marginLeftMm - l.marginRightMm;
|
|
855
|
+
const s = o - l.marginTopMm - l.marginBottomMm;
|
|
856
|
+
if (t === "page" && a <= 0 || s <= 0)
|
|
822
857
|
throw new Error("页边距占满纸张,必须保留正的可用宽度和高度");
|
|
823
|
-
const { dataset: c, titleHeightMm:
|
|
824
|
-
t === "wide" && (a = f.reduce((
|
|
825
|
-
const
|
|
826
|
-
return
|
|
858
|
+
const { dataset: c, titleHeightMm: d, hasTitle: h, titleSpaceMm: m } = Ht(e, s), g = Bt(e), { columns: f, fixedWidthMm: T, maxFlex: R } = _t(e, t, n, a);
|
|
859
|
+
t === "wide" && (a = f.reduce((y, P) => y + P.widthMm, 0), $(a, "宽表总列宽"), i = a + l.marginLeftMm + l.marginRightMm, $(i, "宽表总宽度"));
|
|
860
|
+
const b = { widthMm: i, heightMm: o, ...l, components: [], ...t === "wide" ? { layout: t } : {} };
|
|
861
|
+
return h && b.components.push({
|
|
827
862
|
kind: "text",
|
|
828
863
|
text: e.title,
|
|
829
|
-
leftMm:
|
|
830
|
-
topMm:
|
|
864
|
+
leftMm: l.marginLeftMm,
|
|
865
|
+
topMm: l.marginTopMm,
|
|
831
866
|
widthMm: a,
|
|
832
|
-
heightMm:
|
|
867
|
+
heightMm: d,
|
|
833
868
|
style: { fontSize: 16, bold: !0, align: "center", verticalAlign: "middle", ...e.titleStyle }
|
|
834
|
-
}),
|
|
869
|
+
}), b.components.push({
|
|
835
870
|
align: "auto",
|
|
836
871
|
headerAlign: "center",
|
|
837
872
|
...g,
|
|
838
873
|
kind: "list",
|
|
839
874
|
...t === "wide" ? { layout: t } : {},
|
|
840
|
-
...
|
|
875
|
+
...h ? { title: e.title } : {},
|
|
841
876
|
dataset: c,
|
|
842
877
|
columns: f,
|
|
843
|
-
leftMm:
|
|
844
|
-
topMm:
|
|
845
|
-
widthMm: t === "wide" ||
|
|
846
|
-
}), e.params === void 0 ? { pages: [
|
|
878
|
+
leftMm: l.marginLeftMm,
|
|
879
|
+
topMm: l.marginTopMm + m,
|
|
880
|
+
widthMm: t === "wide" || R > 0 ? a : T
|
|
881
|
+
}), e.params === void 0 ? { pages: [b] } : { params: e.params, pages: [b] };
|
|
847
882
|
}
|
|
848
|
-
function
|
|
883
|
+
function Bn(e) {
|
|
849
884
|
if (e.components !== void 0 && e.pages !== void 0) throw new TypeError("标签 components 与 pages 只能选择一种");
|
|
850
|
-
const { dataset: t, rowKey: n, copies: r, params: i } = e, o = e.pages ?? [{ components: e.components ?? [] }],
|
|
885
|
+
const { dataset: t, rowKey: n, copies: r, params: i } = e, o = e.pages ?? [{ components: e.components ?? [] }], l = {
|
|
851
886
|
repeat: { dataset: t, ...n === void 0 ? {} : { rowKey: n }, ...r === void 0 ? {} : { copies: r } },
|
|
852
887
|
...i === void 0 ? {} : { params: i },
|
|
853
|
-
pages: o.map((
|
|
854
|
-
widthMm:
|
|
855
|
-
heightMm:
|
|
888
|
+
pages: o.map((s) => ({
|
|
889
|
+
widthMm: s.widthMm ?? e.widthMm ?? 80,
|
|
890
|
+
heightMm: s.heightMm ?? e.heightMm ?? 55,
|
|
856
891
|
marginTopMm: 0,
|
|
857
892
|
marginRightMm: 0,
|
|
858
893
|
marginBottomMm: 0,
|
|
859
894
|
marginLeftMm: 0,
|
|
860
|
-
components:
|
|
861
|
-
...
|
|
895
|
+
components: s.components,
|
|
896
|
+
...s.meta === void 0 ? {} : { meta: s.meta }
|
|
862
897
|
}))
|
|
863
|
-
}, a =
|
|
864
|
-
if (!a.ok) throw new
|
|
865
|
-
return JSON.parse(JSON.stringify(
|
|
898
|
+
}, a = Ie(l);
|
|
899
|
+
if (!a.ok) throw new Ne(a.errors);
|
|
900
|
+
return JSON.parse(JSON.stringify(l));
|
|
866
901
|
}
|
|
867
|
-
function
|
|
902
|
+
function jt(e) {
|
|
868
903
|
if (!e || typeof e != "object" || !e.repeat)
|
|
869
904
|
throw new me("config", "defineLabelReport 需要带 repeat 的固定标签模板");
|
|
870
|
-
const t =
|
|
871
|
-
if (!t.ok) throw new
|
|
905
|
+
const t = Ie(e);
|
|
906
|
+
if (!t.ok) throw new Ne(t.errors);
|
|
872
907
|
return e.repeat.dataset;
|
|
873
908
|
}
|
|
874
|
-
function
|
|
909
|
+
function Se(e, t) {
|
|
875
910
|
if (!Array.isArray(e)) throw new me("validate", "标签数据应为对象数组;请从业务响应中提取行数组");
|
|
876
911
|
return { [t]: e };
|
|
877
912
|
}
|
|
878
|
-
function
|
|
879
|
-
const { template: t, rows: n, load: r, dataSchema: i, params: o, pagination:
|
|
913
|
+
function Wn(e) {
|
|
914
|
+
const { template: t, rows: n, load: r, dataSchema: i, params: o, pagination: l, dataValidation: a } = e, s = jt(t);
|
|
880
915
|
if (n !== void 0 == (r !== void 0) || r !== void 0 && typeof r != "function")
|
|
881
916
|
throw new me("config", "标签报表应且只能配置 rows 或 load 其中一种数据来源");
|
|
882
|
-
const c = { template: t, params: o, pagination:
|
|
883
|
-
return r ?
|
|
917
|
+
const c = { template: t, params: o, pagination: l, dataValidation: a, ...i === void 0 ? {} : { dataSchema: { [s]: i } } };
|
|
918
|
+
return r ? tt({ ...c, load: r, mapData: (d) => Se(d, s) }) : { ...c, datasets: Se(n, s) };
|
|
884
919
|
}
|
|
885
|
-
function
|
|
920
|
+
function _n(e) {
|
|
886
921
|
return e;
|
|
887
922
|
}
|
|
888
|
-
class
|
|
923
|
+
class D extends Error {
|
|
889
924
|
constructor(t, n) {
|
|
890
925
|
super(n), this.code = t, this.name = "ReportTemplateStoreError";
|
|
891
926
|
}
|
|
@@ -898,77 +933,77 @@ function S(e) {
|
|
|
898
933
|
const t = new Error("模板操作已取消");
|
|
899
934
|
throw t.name = "AbortError", t;
|
|
900
935
|
}
|
|
901
|
-
function
|
|
936
|
+
function Ee(e) {
|
|
902
937
|
const t = e ? Number(e.revision) : 0;
|
|
903
|
-
if (!Number.isSafeInteger(t) || t < 0 || t >= Number.MAX_SAFE_INTEGER) throw new
|
|
938
|
+
if (!Number.isSafeInteger(t) || t < 0 || t >= Number.MAX_SAFE_INTEGER) throw new D("history", "修订号无效或已达上限");
|
|
904
939
|
return String(t + 1);
|
|
905
940
|
}
|
|
906
|
-
function
|
|
907
|
-
const n = async (
|
|
941
|
+
function jn(e, t = {}) {
|
|
942
|
+
const n = async (l, a) => {
|
|
908
943
|
S(a);
|
|
909
|
-
const
|
|
910
|
-
return S(a),
|
|
911
|
-
}, r = async (
|
|
912
|
-
const
|
|
913
|
-
if ((
|
|
914
|
-
return
|
|
915
|
-
}, i = async (
|
|
916
|
-
if (S(a.signal), !await e.compareAndSwap(
|
|
917
|
-
return I(
|
|
918
|
-
}, o = async (
|
|
944
|
+
const s = await e.read(l, a);
|
|
945
|
+
return S(a), s ? I(s) : void 0;
|
|
946
|
+
}, r = async (l, a) => {
|
|
947
|
+
const s = await n(l, a.signal);
|
|
948
|
+
if ((s?.revision ?? null) !== a.expectedRevision) throw new D("conflict", "模板已变化,请重新读取后提交");
|
|
949
|
+
return s;
|
|
950
|
+
}, i = async (l, a, s) => {
|
|
951
|
+
if (S(a.signal), !await e.compareAndSwap(l.id, a.expectedRevision, I(l), { signal: a.signal, ...s ? { publication: I(s) } : {} })) throw new D("conflict", "模板已被其他请求更新");
|
|
952
|
+
return I(l);
|
|
953
|
+
}, o = async (l, a, s, c) => {
|
|
919
954
|
if (t.beforePublish) {
|
|
920
|
-
S(
|
|
921
|
-
const g = await t.beforePublish({ document:
|
|
922
|
-
if (!g || g.ok !== !0) throw new
|
|
923
|
-
S(
|
|
955
|
+
S(s.signal);
|
|
956
|
+
const g = await t.beforePublish({ document: G(a), previous: l.published ? G(l.published) : void 0, signal: s.signal });
|
|
957
|
+
if (!g || g.ok !== !0) throw new D("review", g?.issues?.find((f) => f.severity === "error")?.message ?? "模板发布检查未通过");
|
|
958
|
+
S(s.signal);
|
|
924
959
|
}
|
|
925
|
-
const
|
|
926
|
-
return c !== void 0 && (
|
|
960
|
+
const d = Ee(l), h = G({ ...a, revision: d }), m = { revision: d, document: h, publishedAt: (t.now?.() ?? /* @__PURE__ */ new Date()).toISOString() };
|
|
961
|
+
return c !== void 0 && (m.restoredFrom = c), i({ id: l.id, revision: d, publishedRevision: d, published: h }, s, m);
|
|
927
962
|
};
|
|
928
963
|
return {
|
|
929
|
-
list: async (
|
|
930
|
-
S(
|
|
931
|
-
const a = await e.list(
|
|
932
|
-
return S(
|
|
964
|
+
list: async (l) => {
|
|
965
|
+
S(l);
|
|
966
|
+
const a = await e.list(l);
|
|
967
|
+
return S(l), I(a);
|
|
933
968
|
},
|
|
934
|
-
get: async (
|
|
935
|
-
const
|
|
936
|
-
return c ?
|
|
969
|
+
get: async (l, a = {}) => {
|
|
970
|
+
const s = await n(l, a.signal), c = a.draft ? s?.draft : s?.published;
|
|
971
|
+
return c ? G(c) : void 0;
|
|
937
972
|
},
|
|
938
|
-
history: async (
|
|
973
|
+
history: async (l, a) => {
|
|
939
974
|
S(a);
|
|
940
|
-
const
|
|
941
|
-
return S(a), I(
|
|
975
|
+
const s = await e.history(l, a);
|
|
976
|
+
return S(a), I(s);
|
|
942
977
|
},
|
|
943
|
-
saveDraft: async (
|
|
978
|
+
saveDraft: async (l, a) => {
|
|
944
979
|
a = { ...a }, S(a.signal);
|
|
945
|
-
const
|
|
980
|
+
const s = G(t.migrate ? await t.migrate(l) : l), c = await r(s.id, a), d = Ee(c);
|
|
946
981
|
return i({
|
|
947
|
-
id:
|
|
948
|
-
revision:
|
|
949
|
-
draft: { ...
|
|
982
|
+
id: s.id,
|
|
983
|
+
revision: d,
|
|
984
|
+
draft: { ...s, revision: d },
|
|
950
985
|
...c?.publishedRevision ? { publishedRevision: c.publishedRevision, published: c.published } : {}
|
|
951
986
|
}, a);
|
|
952
987
|
},
|
|
953
|
-
publish: async (
|
|
988
|
+
publish: async (l, a) => {
|
|
954
989
|
a = { ...a };
|
|
955
|
-
const
|
|
956
|
-
if (!
|
|
957
|
-
if (!
|
|
958
|
-
return o(
|
|
990
|
+
const s = await r(l, a);
|
|
991
|
+
if (!s) throw new D("missing", "模板不存在");
|
|
992
|
+
if (!s.draft) throw new D("draft", "没有可发布的草稿");
|
|
993
|
+
return o(s, s.draft, a);
|
|
959
994
|
},
|
|
960
|
-
rollback: async (
|
|
961
|
-
|
|
962
|
-
const c = await r(
|
|
963
|
-
if (!c) throw new
|
|
964
|
-
S(
|
|
965
|
-
const
|
|
966
|
-
if (!
|
|
967
|
-
return o(c,
|
|
995
|
+
rollback: async (l, a, s) => {
|
|
996
|
+
s = { ...s };
|
|
997
|
+
const c = await r(l, s);
|
|
998
|
+
if (!c) throw new D("missing", "模板不存在");
|
|
999
|
+
S(s.signal);
|
|
1000
|
+
const d = await e.getVersion(l, a, s.signal);
|
|
1001
|
+
if (!d) throw new D("history", "历史修订不存在");
|
|
1002
|
+
return o(c, d.document, s, a);
|
|
968
1003
|
}
|
|
969
1004
|
};
|
|
970
1005
|
}
|
|
971
|
-
function
|
|
1006
|
+
function Un() {
|
|
972
1007
|
const e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map();
|
|
973
1008
|
return {
|
|
974
1009
|
read: async (n, r) => {
|
|
@@ -985,87 +1020,42 @@ function Wn() {
|
|
|
985
1020
|
},
|
|
986
1021
|
compareAndSwap: async (n, r, i, o) => {
|
|
987
1022
|
if (S(o.signal), (e.get(n)?.revision ?? null) !== r) return !1;
|
|
988
|
-
if (i.id !== n) throw new
|
|
989
|
-
const
|
|
1023
|
+
if (i.id !== n) throw new D("history", "状态 ID 与存储 ID 不一致");
|
|
1024
|
+
const l = I(i), a = o.publication;
|
|
990
1025
|
if (a) {
|
|
991
|
-
const
|
|
992
|
-
if (
|
|
993
|
-
|
|
1026
|
+
const s = t.get(n) ?? /* @__PURE__ */ new Map();
|
|
1027
|
+
if (s.has(a.revision) || a.revision !== i.revision || a.document.id !== n) throw new D("history", "发布修订不可覆盖,且必须与状态修订和模板 ID 一致");
|
|
1028
|
+
s.set(a.revision, I(a)), t.set(n, s);
|
|
994
1029
|
}
|
|
995
|
-
return e.set(n,
|
|
996
|
-
}
|
|
997
|
-
};
|
|
998
|
-
}
|
|
999
|
-
function Bt(e, t) {
|
|
1000
|
-
const n = e.publishedRevision ?? e.published?.revision;
|
|
1001
|
-
for (const r of [e.draftRevision, n]) if (r !== void 0 && (typeof r != "string" || !r.trim())) throw new TypeError("模板生命周期修订应为非空字符串");
|
|
1002
|
-
if (e.draftRevision !== void 0 && e.draftRevision !== t.revision) throw new TypeError("可编辑文档应与草稿修订一致");
|
|
1003
|
-
if (e.published && (e.published.id !== t.id || e.published.revision !== n)) throw new TypeError("发布文档身份或修订不一致");
|
|
1004
|
-
if (!e.published && n !== void 0 && n !== t.revision) throw new TypeError("发布修订需要对应的独立文档");
|
|
1005
|
-
return { ...e.draftRevision === void 0 ? {} : { draftRevision: e.draftRevision }, ...n === void 0 ? {} : { publishedRevision: n } };
|
|
1006
|
-
}
|
|
1007
|
-
function _n(e, t) {
|
|
1008
|
-
const n = N(e);
|
|
1009
|
-
if (t.id === n.id) throw new Error("复制模板应使用新的 ID");
|
|
1010
|
-
const { revision: r, ...i } = n;
|
|
1011
|
-
return N({ ...i, id: t.id, name: t.name });
|
|
1012
|
-
}
|
|
1013
|
-
function jn(e) {
|
|
1014
|
-
if (!Array.isArray(e) || e.length > 1e3) throw new RangeError("本地模板目录最多 1000 项");
|
|
1015
|
-
const t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), r = [];
|
|
1016
|
-
for (const i of e) {
|
|
1017
|
-
const o = N(i.document);
|
|
1018
|
-
if (t.has(o.id)) throw new Error(`模板 ID 重复:${o.id}`);
|
|
1019
|
-
if (i.category !== void 0 && (typeof i.category != "string" || i.category.length > 128) || i.tags !== void 0 && (!Array.isArray(i.tags) || i.tags.length > 20 || i.tags.some((c) => typeof c != "string" || c.length > 128))) throw new TypeError("模板分类和标签无效");
|
|
1020
|
-
const s = Bt(i, o), { template: a, ...l } = o;
|
|
1021
|
-
t.set(o.id, o), i.published ? n.set(o.id, N(i.published)) : s.publishedRevision && n.set(o.id, N(o)), r.push({ ...l, ...s, ...i.category ? { category: i.category } : {}, ...i.tags ? { tags: [...i.tags] } : {} });
|
|
1022
|
-
}
|
|
1023
|
-
return r.sort((i, o) => i.id < o.id ? -1 : 1), {
|
|
1024
|
-
search: async (i) => {
|
|
1025
|
-
xe(i.signal);
|
|
1026
|
-
const o = i.limit ?? 30;
|
|
1027
|
-
if (!Number.isSafeInteger(o) || o < 1 || o > 100) throw new RangeError("模板每页数量应为 1–100");
|
|
1028
|
-
const s = i.query?.trim().toLocaleLowerCase() ?? "", a = r.filter((c) => (!i.category || c.category === i.category) && (!i.cursor || c.id > i.cursor) && (!s || [c.id, c.name, c.description, ...c.tags ?? []].some((m) => m?.toLocaleLowerCase().includes(s)))), l = /* @__PURE__ */ new Map();
|
|
1029
|
-
for (const c of r) c.category && l.set(c.category, (l.get(c.category) ?? 0) + 1);
|
|
1030
|
-
return JSON.parse(JSON.stringify({ items: a.slice(0, o), ...a.length > o ? { next: a[o - 1].id } : {}, categories: Array.from(l, ([c, m]) => ({ id: c, label: c, count: m })) }));
|
|
1031
|
-
},
|
|
1032
|
-
get: async (i, o) => {
|
|
1033
|
-
xe(o.signal);
|
|
1034
|
-
const s = o.mode === "published" ? n.get(i) : t.get(i);
|
|
1035
|
-
return s ? N(s) : void 0;
|
|
1030
|
+
return e.set(n, l), !0;
|
|
1036
1031
|
}
|
|
1037
1032
|
};
|
|
1038
1033
|
}
|
|
1039
|
-
function
|
|
1040
|
-
if (!e?.aborted) return;
|
|
1041
|
-
const t = new Error("模板目录操作已取消");
|
|
1042
|
-
throw t.name = "AbortError", t;
|
|
1043
|
-
}
|
|
1044
|
-
function Un(e) {
|
|
1034
|
+
function Gn(e) {
|
|
1045
1035
|
return e.map((t) => t.map((n) => /[\t\r\n"]/.test(n) ? `"${n.replace(/"/g, '""')}"` : n).join(" ")).join(`\r
|
|
1046
1036
|
`);
|
|
1047
1037
|
}
|
|
1048
|
-
function
|
|
1038
|
+
function Ut(e, t) {
|
|
1049
1039
|
const n = e[e.length - 1];
|
|
1050
1040
|
e.length > 1 && n?.length === 1 && n[0] === "" && /[\r\n]$/.test(t) && e.pop();
|
|
1051
1041
|
}
|
|
1052
|
-
function
|
|
1042
|
+
function qn(e, t = 1e4) {
|
|
1053
1043
|
if (e.length > 4 * 1024 * 1024) throw new Error("Clipboard text limit exceeded");
|
|
1054
1044
|
const n = [[]];
|
|
1055
|
-
let r = "", i = !1, o = !1,
|
|
1045
|
+
let r = "", i = !1, o = !1, l = 0;
|
|
1056
1046
|
function a() {
|
|
1057
|
-
if (++
|
|
1047
|
+
if (++l > t) throw new Error("Clipboard cell limit exceeded");
|
|
1058
1048
|
n[n.length - 1].push(r), r = "", o = !1;
|
|
1059
1049
|
}
|
|
1060
|
-
for (let
|
|
1061
|
-
const c = e[
|
|
1050
|
+
for (let s = 0; s < e.length; s++) {
|
|
1051
|
+
const c = e[s];
|
|
1062
1052
|
if (i) {
|
|
1063
1053
|
if (c !== '"') {
|
|
1064
1054
|
r += c;
|
|
1065
1055
|
continue;
|
|
1066
1056
|
}
|
|
1067
|
-
if (e[
|
|
1068
|
-
r += '"',
|
|
1057
|
+
if (e[s + 1] === '"') {
|
|
1058
|
+
r += '"', s++;
|
|
1069
1059
|
continue;
|
|
1070
1060
|
}
|
|
1071
1061
|
i = !1, o = !0;
|
|
@@ -1081,17 +1071,17 @@ function Gn(e, t = 1e4) {
|
|
|
1081
1071
|
}
|
|
1082
1072
|
if (c === "\r" || c === `
|
|
1083
1073
|
`) {
|
|
1084
|
-
a(), n.push([]), c === "\r" && e[
|
|
1085
|
-
` &&
|
|
1074
|
+
a(), n.push([]), c === "\r" && e[s + 1] === `
|
|
1075
|
+
` && s++;
|
|
1086
1076
|
continue;
|
|
1087
1077
|
}
|
|
1088
1078
|
if (o) throw new Error("Invalid quoted clipboard value");
|
|
1089
1079
|
r += c;
|
|
1090
1080
|
}
|
|
1091
1081
|
if (i) throw new Error("Unclosed clipboard quote");
|
|
1092
|
-
return a(),
|
|
1082
|
+
return a(), Ut(n, e), n;
|
|
1093
1083
|
}
|
|
1094
|
-
class
|
|
1084
|
+
class Gt extends Error {
|
|
1095
1085
|
constructor(t, n, r) {
|
|
1096
1086
|
const i = typeof n.label == "string" ? n.label : "单元格", o = {
|
|
1097
1087
|
definition: `${i}的编辑器配置无效`,
|
|
@@ -1108,158 +1098,158 @@ class _t extends Error {
|
|
|
1108
1098
|
}
|
|
1109
1099
|
}
|
|
1110
1100
|
function p(e, t, n) {
|
|
1111
|
-
throw new
|
|
1101
|
+
throw new Gt(t, e, n);
|
|
1112
1102
|
}
|
|
1113
|
-
function
|
|
1103
|
+
function Ve(e) {
|
|
1114
1104
|
if (typeof e != "string" || !/^\d{4}-\d{2}-\d{2}$/.test(e) || e.startsWith("0000-")) return !1;
|
|
1115
1105
|
const t = /* @__PURE__ */ new Date(`${e}T00:00:00.000Z`);
|
|
1116
1106
|
return Number.isFinite(t.getTime()) && t.toISOString().slice(0, 10) === e;
|
|
1117
1107
|
}
|
|
1118
|
-
function
|
|
1108
|
+
function qt(e) {
|
|
1119
1109
|
const [t = "", n = "0"] = String(e).toLowerCase().split("e");
|
|
1120
1110
|
return Math.max(0, (t.split(".")[1]?.length ?? 0) - Number(n));
|
|
1121
1111
|
}
|
|
1122
|
-
function
|
|
1123
|
-
e.min !== void 0 && t < e.min && p(e, "min", e.min), e.max !== void 0 && t > e.max && p(e, "max", e.max), e.precision !== void 0 &&
|
|
1112
|
+
function Vt(e, t) {
|
|
1113
|
+
e.min !== void 0 && t < e.min && p(e, "min", e.min), e.max !== void 0 && t > e.max && p(e, "max", e.max), e.precision !== void 0 && qt(t) > e.precision && p(e, "precision", e.precision);
|
|
1124
1114
|
}
|
|
1125
|
-
function
|
|
1126
|
-
|
|
1115
|
+
function Yt(e, t) {
|
|
1116
|
+
Ve(t) || p(e, "date"), e.min !== void 0 && t < e.min && p(e, "min", e.min), e.max !== void 0 && t > e.max && p(e, "max", e.max);
|
|
1127
1117
|
}
|
|
1128
|
-
function
|
|
1118
|
+
function Kt(e) {
|
|
1129
1119
|
[e.min, e.max].some((t) => t !== void 0 && !Number.isFinite(t)) && p(e, "definition"), e.min !== void 0 && e.max !== void 0 && e.min > e.max && p(e, "definition"), e.precision !== void 0 && (!Number.isInteger(e.precision) || e.precision < 0 || e.precision > 15) && p(e, "definition");
|
|
1130
1120
|
}
|
|
1131
|
-
function
|
|
1132
|
-
[e.min, e.max].some((t) => t !== void 0 && !
|
|
1121
|
+
function Jt(e) {
|
|
1122
|
+
[e.min, e.max].some((t) => t !== void 0 && !Ve(t)) && p(e, "definition"), e.min !== void 0 && e.max !== void 0 && e.min > e.max && p(e, "definition");
|
|
1133
1123
|
}
|
|
1134
|
-
function
|
|
1124
|
+
function Xt(e, t) {
|
|
1135
1125
|
(!Array.isArray(t.options) || !t.options.length) && p(t, "definition");
|
|
1136
1126
|
const n = e.valueType === "text" ? "string" : e.valueType, r = /* @__PURE__ */ new Set();
|
|
1137
1127
|
for (const i of t.options)
|
|
1138
1128
|
(!i || typeof i.value !== n || typeof i.value == "number" && !Number.isFinite(i.value)) && p(t, "definition"), i.label !== void 0 && typeof i.label != "string" && p(t, "definition"), r.has(i.value) && p(t, "definition"), r.add(i.value);
|
|
1139
1129
|
}
|
|
1140
|
-
function
|
|
1130
|
+
function Zt(e) {
|
|
1141
1131
|
e.required !== void 0 && typeof e.required != "boolean" && p(e, "definition"), [e.label, e.hint, e.unit].some((t) => t !== void 0 && typeof t != "string") && p(e, "definition"), e.type === "boolean" && [e.trueLabel, e.falseLabel].some((t) => t !== void 0 && typeof t != "string") && p(e, "definition");
|
|
1142
1132
|
}
|
|
1143
|
-
function
|
|
1144
|
-
(!t || typeof t != "object" || Array.isArray(t) || !["text", "number", "boolean", "enum", "date"].includes(t.type)) && p(t ?? { type: "text" }, "definition"),
|
|
1133
|
+
function Qt(e, t) {
|
|
1134
|
+
(!t || typeof t != "object" || Array.isArray(t) || !["text", "number", "boolean", "enum", "date"].includes(t.type)) && p(t ?? { type: "text" }, "definition"), Zt(t), (t.type === "number" || t.type === "boolean") && e.valueType !== t.type && p(t, "type"), (t.type === "text" || t.type === "date") && e.valueType !== "text" && p(t, "type"), t.type === "number" && Kt(t), t.type === "text" && t.maxLength !== void 0 && (!Number.isInteger(t.maxLength) || t.maxLength < 0) && p(t, "definition"), t.type === "date" && Jt(t), t.type === "enum" && Xt(e, t);
|
|
1145
1135
|
}
|
|
1146
1136
|
function Vn(e, t, n) {
|
|
1147
|
-
if (!e.editable) throw new
|
|
1148
|
-
n &&
|
|
1149
|
-
const r =
|
|
1150
|
-
return n ? (n.required && typeof r == "string" && !r.trim() && p(n, "required"), r === null || r === "" ? (n.required && p(n, "required"), r) : (n.type === "number" &&
|
|
1137
|
+
if (!e.editable) throw new nt("readonly");
|
|
1138
|
+
n && Qt(e, n);
|
|
1139
|
+
const r = rt(e, t);
|
|
1140
|
+
return n ? (n.required && typeof r == "string" && !r.trim() && p(n, "required"), r === null || r === "" ? (n.required && p(n, "required"), r) : (n.type === "number" && Vt(n, r), n.type === "date" && Yt(n, r), n.type === "text" && n.maxLength !== void 0 && [...String(r)].length > n.maxLength && p(n, "length", n.maxLength), n.type === "enum" && !n.options.some((i) => Object.is(i.value, r)) && p(n, "choice"), r)) : r;
|
|
1151
1141
|
}
|
|
1152
|
-
class
|
|
1142
|
+
class w extends Error {
|
|
1153
1143
|
constructor(t) {
|
|
1154
1144
|
super(`Report calculation: ${t}`), this.code = t, this.name = "ReportCalculationError";
|
|
1155
1145
|
}
|
|
1156
1146
|
}
|
|
1157
|
-
function
|
|
1147
|
+
function j(e) {
|
|
1158
1148
|
if (!e?.aborted) return;
|
|
1159
1149
|
const t = new Error("Calculation cancelled");
|
|
1160
1150
|
throw t.name = "AbortError", t;
|
|
1161
1151
|
}
|
|
1162
|
-
async function
|
|
1152
|
+
async function te(e, t = 1) {
|
|
1163
1153
|
const n = Math.floor(e.scanned / 2048);
|
|
1164
|
-
if (e.scanned += t, e.scanned > e.maxScanned) throw new
|
|
1165
|
-
|
|
1154
|
+
if (e.scanned += t, e.scanned > e.maxScanned) throw new w("limit");
|
|
1155
|
+
j(e.signal), Math.floor(e.scanned / 2048) > n && (await e.yieldToHost(), j(e.signal));
|
|
1166
1156
|
}
|
|
1167
|
-
function
|
|
1157
|
+
function we(e) {
|
|
1168
1158
|
return e.table?.role === "header" ? -Math.max(1, e.grid?.cells.length ?? 1) : e.table?.rowIndex ?? 0;
|
|
1169
1159
|
}
|
|
1170
|
-
function
|
|
1171
|
-
if (![t.pageIndex, t.componentIndex, t.rowIndex, t.columnIndex].every((a) => Number.isSafeInteger(a) && a >= 0)) throw new
|
|
1160
|
+
function Te(e, t, n) {
|
|
1161
|
+
if (![t.pageIndex, t.componentIndex, t.rowIndex, t.columnIndex].every((a) => Number.isSafeInteger(a) && a >= 0)) throw new w("selection");
|
|
1172
1162
|
const r = e.pages[t.pageIndex]?.components[t.componentIndex];
|
|
1173
|
-
if (!r?.grid || t.rowIndex >= r.grid.cells.length) throw new
|
|
1174
|
-
const i = r.grid.colWidthsMm?.length ?? r.grid.cells.reduce((a,
|
|
1175
|
-
if (t.columnIndex >= i) throw new
|
|
1176
|
-
const o = r.table,
|
|
1177
|
-
if (o &&
|
|
1178
|
-
const a =
|
|
1179
|
-
if (a < 0) throw new
|
|
1180
|
-
return { grid: o.id, row:
|
|
1163
|
+
if (!r?.grid || t.rowIndex >= r.grid.cells.length) throw new w("selection");
|
|
1164
|
+
const i = r.grid.colWidthsMm?.length ?? r.grid.cells.reduce((a, s) => Math.max(a, s.length), 1);
|
|
1165
|
+
if (t.columnIndex >= i) throw new w("selection");
|
|
1166
|
+
const o = r.table, l = e.pages[n.pageIndex]?.components[n.componentIndex]?.table;
|
|
1167
|
+
if (o && l && o.id === l.id) {
|
|
1168
|
+
const a = l.columnKeys.indexOf(o.columnKeys[t.columnIndex] ?? "");
|
|
1169
|
+
if (a < 0) throw new w("selection");
|
|
1170
|
+
return { grid: o.id, row: we(r) + t.rowIndex, column: a };
|
|
1181
1171
|
}
|
|
1182
1172
|
return { grid: `${t.pageIndex}:${t.componentIndex}`, row: t.rowIndex, column: t.columnIndex };
|
|
1183
1173
|
}
|
|
1184
|
-
function
|
|
1185
|
-
const r =
|
|
1186
|
-
if (r.grid !== i.grid) throw new
|
|
1174
|
+
function en(e, t, n) {
|
|
1175
|
+
const r = Te(e, t.anchor, t.anchor), i = Te(e, t.focus, t.anchor);
|
|
1176
|
+
if (r.grid !== i.grid) throw new w("selection");
|
|
1187
1177
|
const o = (Math.abs(r.row - i.row) + 1) * (Math.abs(r.column - i.column) + 1);
|
|
1188
|
-
if (!Number.isSafeInteger(o) || o > n) throw new
|
|
1178
|
+
if (!Number.isSafeInteger(o) || o > n) throw new w("limit");
|
|
1189
1179
|
return { grid: r.grid, rowStart: Math.min(r.row, i.row), rowEnd: Math.max(r.row, i.row), columnStart: Math.min(r.column, i.column), columnEnd: Math.max(r.column, i.column), origin: e.pages[t.anchor.pageIndex].components[t.anchor.componentIndex].table };
|
|
1190
1180
|
}
|
|
1191
|
-
function
|
|
1181
|
+
function tn(e) {
|
|
1192
1182
|
if (!e) return !1;
|
|
1193
1183
|
const t = e.replace(/"[^"]*"|\\.|\[(?![hms]+\])[^\]]*\]/gi, "");
|
|
1194
1184
|
return /[ymdhs]/i.test(t);
|
|
1195
1185
|
}
|
|
1196
|
-
function
|
|
1197
|
-
if (e.valueType === "text" || e.valueType === "boolean" ||
|
|
1186
|
+
function nn(e) {
|
|
1187
|
+
if (e.valueType === "text" || e.valueType === "boolean" || tn(e.numberFormat)) return null;
|
|
1198
1188
|
const t = e.value;
|
|
1199
1189
|
if (typeof t != "number" || !Number.isFinite(t)) return null;
|
|
1200
|
-
if (Number.isInteger(t) && !Number.isSafeInteger(t)) throw new
|
|
1190
|
+
if (Number.isInteger(t) && !Number.isSafeInteger(t)) throw new w("precision");
|
|
1201
1191
|
return t;
|
|
1202
1192
|
}
|
|
1203
|
-
function
|
|
1193
|
+
function rn(e, t, n) {
|
|
1204
1194
|
if (e.seen.has(n)) return;
|
|
1205
1195
|
e.seen.add(n), e.selected++;
|
|
1206
|
-
const r = t ?
|
|
1196
|
+
const r = t ? nn(t) : null;
|
|
1207
1197
|
r === null ? e.excluded++ : e.values.push(r);
|
|
1208
1198
|
}
|
|
1209
|
-
function
|
|
1199
|
+
function an(e, t, n, r) {
|
|
1210
1200
|
return r.origin ? e.table?.id === r.origin.id : `${t}:${n}` === r.grid;
|
|
1211
1201
|
}
|
|
1212
|
-
function
|
|
1202
|
+
function on(e, t, n) {
|
|
1213
1203
|
return n.origin ? n.origin.columnKeys.indexOf(e.table.columnKeys[t] ?? "") : t;
|
|
1214
1204
|
}
|
|
1215
|
-
function
|
|
1216
|
-
const i = r.origin ?
|
|
1205
|
+
function sn(e, t, n, r) {
|
|
1206
|
+
const i = r.origin ? we(e) + t : t, o = on(e, n, r);
|
|
1217
1207
|
return i < r.rowStart || i > r.rowEnd || o < r.columnStart || o > r.columnEnd ? null : `${r.grid}:${i}:${o}`;
|
|
1218
1208
|
}
|
|
1219
|
-
function
|
|
1220
|
-
const n = t.origin ?
|
|
1209
|
+
function ln(e, t) {
|
|
1210
|
+
const n = t.origin ? we(e) : 0, r = Math.max(0, t.rowStart - n), i = Math.min(e.grid.cells.length, t.rowEnd - n + 1);
|
|
1221
1211
|
return i > r ? i : 0;
|
|
1222
1212
|
}
|
|
1223
|
-
async function
|
|
1213
|
+
async function cn(e, t, n, r, i) {
|
|
1224
1214
|
const o = e.grid;
|
|
1225
|
-
if (t > r.maxScanned) throw new
|
|
1226
|
-
const
|
|
1227
|
-
if (
|
|
1215
|
+
if (t > r.maxScanned) throw new w("limit");
|
|
1216
|
+
const l = o.colWidthsMm?.length ?? o.cells.reduce((s, c) => Math.max(s, c.length), 1);
|
|
1217
|
+
if (l > r.maxScanned) throw new w("limit");
|
|
1228
1218
|
const a = /* @__PURE__ */ new Map();
|
|
1229
|
-
for (let
|
|
1230
|
-
|
|
1219
|
+
for (let s = 0; s < t; s++) {
|
|
1220
|
+
s > 0 && s % 2048 === 0 && (await r.yieldToHost(), j(r.signal));
|
|
1231
1221
|
let c = 0;
|
|
1232
|
-
for (const
|
|
1233
|
-
for (await
|
|
1234
|
-
if (c >=
|
|
1235
|
-
const
|
|
1236
|
-
|
|
1237
|
-
for (let f = c; f < c +
|
|
1238
|
-
const g =
|
|
1239
|
-
g &&
|
|
1222
|
+
for (const d of o.cells[s]) {
|
|
1223
|
+
for (await te(r); c < l && (a.get(c) ?? 0) > s; ) c++;
|
|
1224
|
+
if (c >= l) break;
|
|
1225
|
+
const h = Math.max(1, Math.min(d?.colSpan ?? 1, l - c)), m = Math.min(o.cells.length, s + Math.max(1, d?.rowSpan ?? 1));
|
|
1226
|
+
h > 1 && await te(r, h - 1);
|
|
1227
|
+
for (let f = c; f < c + h; f++) a.set(f, m);
|
|
1228
|
+
const g = sn(e, s, c, n);
|
|
1229
|
+
g && rn(i, d, g), c += h;
|
|
1240
1230
|
}
|
|
1241
1231
|
}
|
|
1242
1232
|
}
|
|
1243
|
-
async function
|
|
1233
|
+
async function dn(e, t, n) {
|
|
1244
1234
|
const r = { values: [], seen: /* @__PURE__ */ new Set(), excluded: 0, selected: 0 };
|
|
1245
1235
|
for (let i = 0; i < e.pages.length; i++) {
|
|
1246
|
-
await
|
|
1236
|
+
await te(n);
|
|
1247
1237
|
const o = e.pages[i];
|
|
1248
|
-
for (let
|
|
1249
|
-
await
|
|
1250
|
-
const a = o.components[
|
|
1251
|
-
if (!a.grid || !
|
|
1252
|
-
const
|
|
1253
|
-
|
|
1238
|
+
for (let l = 0; l < o.components.length; l++) {
|
|
1239
|
+
await te(n);
|
|
1240
|
+
const a = o.components[l];
|
|
1241
|
+
if (!a.grid || !an(a, i, l, t) || a.table && a.table.role !== "body") continue;
|
|
1242
|
+
const s = ln(a, t);
|
|
1243
|
+
s && await cn(a, s, t, n, r);
|
|
1254
1244
|
}
|
|
1255
1245
|
}
|
|
1256
1246
|
return r;
|
|
1257
1247
|
}
|
|
1258
1248
|
function V(e) {
|
|
1259
|
-
if (!Number.isFinite(e)) throw new
|
|
1249
|
+
if (!Number.isFinite(e)) throw new w("overflow");
|
|
1260
1250
|
return e;
|
|
1261
1251
|
}
|
|
1262
|
-
function
|
|
1252
|
+
function mn(e) {
|
|
1263
1253
|
let t = 0, n = 0;
|
|
1264
1254
|
for (const r of e) {
|
|
1265
1255
|
const i = r - n, o = V(t + i);
|
|
@@ -1267,81 +1257,81 @@ function ln(e) {
|
|
|
1267
1257
|
}
|
|
1268
1258
|
return t;
|
|
1269
1259
|
}
|
|
1270
|
-
async function
|
|
1260
|
+
async function Ce(e, t) {
|
|
1271
1261
|
let n = [...e], r = new Array(e.length);
|
|
1272
1262
|
for (let o = 1; o < e.length; o *= 2) {
|
|
1273
|
-
for (let
|
|
1274
|
-
const a = Math.min(
|
|
1275
|
-
let c =
|
|
1276
|
-
for (let
|
|
1277
|
-
r[
|
|
1263
|
+
for (let l = 0; l < e.length; l += o * 2) {
|
|
1264
|
+
const a = Math.min(l + o, e.length), s = Math.min(l + o * 2, e.length);
|
|
1265
|
+
let c = l, d = a;
|
|
1266
|
+
for (let h = l; h < s; h++)
|
|
1267
|
+
r[h] = d >= s || c < a && n[c] <= n[d] ? n[c++] : n[d++], h % 2048 === 0 && (await t.yieldToHost(), j(t.signal));
|
|
1278
1268
|
}
|
|
1279
1269
|
[n, r] = [r, n];
|
|
1280
1270
|
}
|
|
1281
1271
|
const i = Math.floor(n.length / 2);
|
|
1282
1272
|
return n.length % 2 ? n[i] : V(n[i - 1] / 2 + n[i] / 2);
|
|
1283
1273
|
}
|
|
1284
|
-
function
|
|
1285
|
-
const t =
|
|
1274
|
+
function hn(e) {
|
|
1275
|
+
const t = mn(e);
|
|
1286
1276
|
let n = 1 / 0, r = -1 / 0;
|
|
1287
1277
|
for (const i of e)
|
|
1288
1278
|
n = Math.min(n, i), r = Math.max(r, i);
|
|
1289
1279
|
return { SUM: t, AVERAGE: t / e.length, AVG: t / e.length, MIN: n, MAX: r, COUNT: e.length };
|
|
1290
1280
|
}
|
|
1291
|
-
function
|
|
1292
|
-
if (typeof e != "string" || e.length > 256) throw new
|
|
1281
|
+
function gn(e, t) {
|
|
1282
|
+
if (typeof e != "string" || e.length > 256) throw new w("expression");
|
|
1293
1283
|
const n = e.toUpperCase().match(/(?:\d+(?:\.\d*)?|\.\d+)(?:E[+-]?\d+)?|[A-Z_]+|[()+\-*/]|\S/g) ?? [];
|
|
1294
|
-
if (!n.length || n.length > 64) throw new
|
|
1284
|
+
if (!n.length || n.length > 64) throw new w("expression");
|
|
1295
1285
|
let r = 0;
|
|
1296
1286
|
function i(a) {
|
|
1297
|
-
if (a > 16) throw new
|
|
1298
|
-
const
|
|
1299
|
-
if (
|
|
1300
|
-
if (
|
|
1287
|
+
if (a > 16) throw new w("expression");
|
|
1288
|
+
const s = n[r++];
|
|
1289
|
+
if (s === "+" || s === "-") return (s === "-" ? -1 : 1) * i(a + 1);
|
|
1290
|
+
if (s === "(") {
|
|
1301
1291
|
const c = o(0, a + 1);
|
|
1302
|
-
if (n[r++] !== ")") throw new
|
|
1292
|
+
if (n[r++] !== ")") throw new w("expression");
|
|
1303
1293
|
return c;
|
|
1304
1294
|
}
|
|
1305
|
-
if (
|
|
1306
|
-
if (
|
|
1307
|
-
throw new
|
|
1295
|
+
if (s && /^(?:SUM|AVERAGE|AVG|MIN|MAX|COUNT|MEDIAN)$/.test(s) && Object.prototype.hasOwnProperty.call(t, s)) return V(t[s]);
|
|
1296
|
+
if (s && /^(?:\d+(?:\.\d*)?|\.\d+)(?:E[+-]?\d+)?$/.test(s)) return V(Number(s));
|
|
1297
|
+
throw new w("expression");
|
|
1308
1298
|
}
|
|
1309
|
-
function o(a,
|
|
1310
|
-
let c = i(
|
|
1299
|
+
function o(a, s) {
|
|
1300
|
+
let c = i(s);
|
|
1311
1301
|
for (; r < n.length; ) {
|
|
1312
|
-
const
|
|
1313
|
-
if (!
|
|
1302
|
+
const d = n[r], h = d === "+" || d === "-" ? 1 : d === "*" || d === "/" ? 2 : 0;
|
|
1303
|
+
if (!h || h < a) break;
|
|
1314
1304
|
r++;
|
|
1315
|
-
const
|
|
1316
|
-
if (
|
|
1317
|
-
c = V(
|
|
1305
|
+
const m = o(h + 1, s + 1);
|
|
1306
|
+
if (d === "/" && m === 0) throw new w("division");
|
|
1307
|
+
c = V(d === "+" ? c + m : d === "-" ? c - m : d === "*" ? c * m : c / m);
|
|
1318
1308
|
}
|
|
1319
1309
|
return c;
|
|
1320
1310
|
}
|
|
1321
|
-
const
|
|
1322
|
-
if (r !== n.length) throw new
|
|
1323
|
-
return
|
|
1311
|
+
const l = o(1, 0);
|
|
1312
|
+
if (r !== n.length) throw new w("expression");
|
|
1313
|
+
return l;
|
|
1324
1314
|
}
|
|
1325
|
-
function
|
|
1315
|
+
function fn(e) {
|
|
1326
1316
|
const t = e.maxCells ?? 1e5, n = e.maxScannedCells ?? 2e5, r = e.precision ?? 2;
|
|
1327
|
-
if (![t, n].every((i) => Number.isSafeInteger(i) && i >= 1 && i <= 2e6)) throw new
|
|
1328
|
-
if (!Number.isInteger(r) || r < 0 || r > 12) throw new
|
|
1317
|
+
if (![t, n].every((i) => Number.isSafeInteger(i) && i >= 1 && i <= 2e6)) throw new w("limit");
|
|
1318
|
+
if (!Number.isInteger(r) || r < 0 || r > 12) throw new w("precision");
|
|
1329
1319
|
return { maxCells: t, maxScanned: n, precision: r };
|
|
1330
1320
|
}
|
|
1331
|
-
async function
|
|
1332
|
-
const r =
|
|
1333
|
-
|
|
1334
|
-
const o = await
|
|
1335
|
-
if (!["sum", "average", "min", "max", "count", "median", "expression"].includes(
|
|
1321
|
+
async function Yn(e, t, n = {}) {
|
|
1322
|
+
const r = fn(n), i = { scanned: 0, maxScanned: r.maxScanned, signal: n.signal, yieldToHost: n.yieldToHost ?? (() => new Promise((s) => setTimeout(s, 0))) };
|
|
1323
|
+
j(i.signal);
|
|
1324
|
+
const o = await dn(e, en(e, t, r.maxCells), i), l = n.operation ?? "sum";
|
|
1325
|
+
if (!["sum", "average", "min", "max", "count", "median", "expression"].includes(l)) throw new w("expression");
|
|
1336
1326
|
let a = null;
|
|
1337
|
-
if (
|
|
1327
|
+
if (l === "count") a = o.values.length;
|
|
1338
1328
|
else if (o.values.length)
|
|
1339
|
-
if (
|
|
1329
|
+
if (l === "median") a = await Ce(o.values, i);
|
|
1340
1330
|
else {
|
|
1341
|
-
const
|
|
1342
|
-
|
|
1331
|
+
const s = hn(o.values);
|
|
1332
|
+
l === "expression" ? (/\bMEDIAN\b/i.test(n.expression ?? "") && (s.MEDIAN = await Ce(o.values, i)), a = gn(n.expression ?? "", s)) : a = s[l.toUpperCase()];
|
|
1343
1333
|
}
|
|
1344
|
-
if (
|
|
1334
|
+
if (j(i.signal), a !== null && Number.isInteger(a) && !Number.isSafeInteger(a)) throw new w("precision");
|
|
1345
1335
|
return { value: a, formatted: a === null ? "—" : a.toFixed(r.precision), numericCells: o.values.length, excludedCells: o.excluded, selectedCells: o.selected, precision: r.precision };
|
|
1346
1336
|
}
|
|
1347
1337
|
class A extends Error {
|
|
@@ -1349,209 +1339,215 @@ class A extends Error {
|
|
|
1349
1339
|
super(t), this.path = n, this.code = "label-sheet", this.name = "LabelSheetError";
|
|
1350
1340
|
}
|
|
1351
1341
|
}
|
|
1352
|
-
function
|
|
1342
|
+
function Z(e) {
|
|
1353
1343
|
if (e?.aborted) {
|
|
1354
1344
|
const t = new Error("标签拼版已取消");
|
|
1355
1345
|
throw t.name = "AbortError", t;
|
|
1356
1346
|
}
|
|
1357
1347
|
}
|
|
1358
|
-
function
|
|
1348
|
+
function O(e, t, n = !1) {
|
|
1359
1349
|
if (!Number.isFinite(e) || e <= 0 || n && !Number.isSafeInteger(e)) throw new A("应为正有限数字,数量应为安全整数", t);
|
|
1360
1350
|
return e;
|
|
1361
1351
|
}
|
|
1362
|
-
function
|
|
1352
|
+
function Re(e, t) {
|
|
1363
1353
|
if (!Number.isFinite(e) || e < 0) throw new A("应为非负有限数字", t);
|
|
1364
1354
|
return e;
|
|
1365
1355
|
}
|
|
1366
|
-
function
|
|
1356
|
+
function un(e) {
|
|
1367
1357
|
const t = typeof e.marginMm == "object" ? e.marginMm : { top: e.marginMm ?? 0, left: e.marginMm ?? 0, bottom: e.marginMm ?? 0, right: e.marginMm ?? 0 }, n = typeof e.gapMm == "object" ? e.gapMm : { horizontal: e.gapMm ?? 0, vertical: e.gapMm ?? 0 };
|
|
1368
|
-
for (const r of ["top", "left", "bottom", "right"])
|
|
1369
|
-
for (const r of ["horizontal", "vertical"])
|
|
1358
|
+
for (const r of ["top", "left", "bottom", "right"]) Re(t?.[r], `$.marginMm.${r}`);
|
|
1359
|
+
for (const r of ["horizontal", "vertical"]) Re(n?.[r], `$.gapMm.${r}`);
|
|
1370
1360
|
return { margin: t, gap: n };
|
|
1371
1361
|
}
|
|
1372
|
-
function
|
|
1362
|
+
function pn(e) {
|
|
1373
1363
|
const t = e.paper === void 0 || e.paper === "a4" ? { widthMm: 210, heightMm: 297 } : e.paper;
|
|
1374
|
-
|
|
1375
|
-
const n =
|
|
1364
|
+
O(t.widthMm, "$.paper.widthMm"), O(t.heightMm, "$.paper.heightMm");
|
|
1365
|
+
const n = O(e.columns, "$.columns", !0), r = O(e.rows, "$.rows", !0), i = n * r;
|
|
1376
1366
|
if (i > 1e3) throw new A("每张纸不能超过 1000 个位置", "$.columns");
|
|
1377
|
-
const { margin: o, gap:
|
|
1367
|
+
const { margin: o, gap: l } = un(e), a = e.startSlot ?? 0, s = e.offsetMm ?? { x: 0, y: 0 };
|
|
1378
1368
|
if (!Number.isSafeInteger(a) || a < 0 || a >= i) throw new A("起始位置应在首张纸的有效位置内", "$.startSlot");
|
|
1379
|
-
if (!Number.isFinite(
|
|
1380
|
-
return { paper: t, columns: n, rows: r, capacity: i, margin: o, gap:
|
|
1369
|
+
if (!Number.isFinite(s.x) || !Number.isFinite(s.y)) throw new A("校准偏移应为有限毫米值", "$.offsetMm");
|
|
1370
|
+
return { paper: t, columns: n, rows: r, capacity: i, margin: o, gap: l, startSlot: a, offset: s };
|
|
1381
1371
|
}
|
|
1382
|
-
function
|
|
1383
|
-
return 1 + (e.grid?.cells.reduce((t, n) => t + n.length + 1 + n.reduce((r, i) => r + (i?.children?.reduce((o,
|
|
1372
|
+
function Ye(e) {
|
|
1373
|
+
return 1 + (e.grid?.cells.reduce((t, n) => t + n.length + 1 + n.reduce((r, i) => r + (i?.children?.reduce((o, l) => o + Ye(l), 0) ?? 0), 0), 0) ?? 0);
|
|
1384
1374
|
}
|
|
1385
|
-
function
|
|
1386
|
-
if (!
|
|
1375
|
+
function wn(e, t, n) {
|
|
1376
|
+
if (!Qe(e).ok) throw new A("标签计划无效", "$.plan");
|
|
1387
1377
|
const r = e.pages[0];
|
|
1388
1378
|
if (!r) return;
|
|
1389
|
-
const { paper: i, columns: o, rows:
|
|
1390
|
-
if (a.left + c.x < 0 || a.top + c.y < 0 || a.left + c.x + o * r.pageWidthMm + (o - 1) *
|
|
1391
|
-
let
|
|
1392
|
-
for (const [
|
|
1393
|
-
if (
|
|
1394
|
-
if (
|
|
1395
|
-
for (const g of
|
|
1379
|
+
const { paper: i, columns: o, rows: l, margin: a, gap: s, offset: c } = n;
|
|
1380
|
+
if (a.left + c.x < 0 || a.top + c.y < 0 || a.left + c.x + o * r.pageWidthMm + (o - 1) * s.horizontal + a.right > i.widthMm + 1e-6 || a.top + c.y + l * r.pageHeightMm + (l - 1) * s.vertical + a.bottom > i.heightMm + 1e-6) throw new A("标签、间距、边距及校准偏移超过纸张尺寸;不会自动缩小标签", "$.paper");
|
|
1381
|
+
let d = 0;
|
|
1382
|
+
for (const [h, m] of e.pages.entries()) {
|
|
1383
|
+
if (Z(t.signal), m.layout === "wide" || m.pageWidthMm !== r.pageWidthMm || m.pageHeightMm !== r.pageHeightMm) throw new A("拼版需要尺寸相同的固定标签页面", `$.pages.${h}`);
|
|
1384
|
+
if (d += m.components.reduce((g, f) => g + Ye(f), 0), d > O(t.maxComponents ?? 25e4, "$.maxComponents", !0)) throw new A("拼版组件总量超过预算", "$.maxComponents");
|
|
1385
|
+
for (const g of m.components) if (g.leftMm < 0 || g.topMm < 0 || g.leftMm + g.widthMm > m.pageWidthMm + 1e-6 || g.topMm + g.heightMm > m.pageHeightMm + 1e-6) throw new A("标签内容超出标签边界", `$.pages.${h}.components`);
|
|
1396
1386
|
}
|
|
1397
1387
|
}
|
|
1398
|
-
function
|
|
1399
|
-
|
|
1400
|
-
const n =
|
|
1401
|
-
if (
|
|
1402
|
-
|
|
1403
|
-
const
|
|
1404
|
-
for (const [g, f] of
|
|
1405
|
-
|
|
1406
|
-
const
|
|
1407
|
-
|
|
1388
|
+
function Kn(e, t) {
|
|
1389
|
+
Z(t.signal);
|
|
1390
|
+
const n = pn(t), { paper: r, columns: i, capacity: o, margin: l, gap: a, startSlot: s, offset: c } = n, d = e.pages.length ? Math.ceil((s + e.pages.length) / o) : 0;
|
|
1391
|
+
if (d > O(t.maxSheets ?? 1e4, "$.maxSheets", !0)) throw new A("拼版纸张数量超过预算", "$.maxSheets");
|
|
1392
|
+
O(t.maxComponents ?? 25e4, "$.maxComponents", !0), wn(e, t, n);
|
|
1393
|
+
const h = it(e, { maxBytes: O(t.maxSnapshotBytes ?? 64e6, "$.maxSnapshotBytes", !0), check: () => Z(t.signal), error: (g, f) => new A(f, "$.maxSnapshotBytes") }), m = Array.from({ length: d }, () => ({ pageWidthMm: r.widthMm, pageHeightMm: r.heightMm, components: [], meta: { labelSheet: { columns: i, rows: n.rows, slots: [] } } }));
|
|
1394
|
+
for (const [g, f] of h.pages.entries()) {
|
|
1395
|
+
Z(t.signal);
|
|
1396
|
+
const T = s + g, R = T % o, b = m[Math.floor(T / o)], y = l.left + c.x + R % i * (f.pageWidthMm + a.horizontal), P = l.top + c.y + Math.floor(R / i) * (f.pageHeightMm + a.vertical), H = { sourcePageIndex: g, slotIndex: R, xMm: y, yMm: P, widthMm: f.pageWidthMm, heightMm: f.pageHeightMm, ...f.meta ? { sourceMeta: f.meta } : {} };
|
|
1397
|
+
b.meta.labelSheet.slots.push(H), b.components.push(...f.components.map((N) => ({ ...N, leftMm: N.leftMm + y, topMm: N.topMm + P, meta: { ...N.meta, labelSheet: H } })));
|
|
1408
1398
|
}
|
|
1409
|
-
return { ...
|
|
1399
|
+
return { ...h, pages: m };
|
|
1410
1400
|
}
|
|
1411
1401
|
export {
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1402
|
+
Zn as CSS_DPI,
|
|
1403
|
+
Qn as DEFAULT_BORDER_PT,
|
|
1404
|
+
ne as DEFAULT_FONT_FAMILY,
|
|
1405
|
+
er as DEFAULT_FONT_PT,
|
|
1406
|
+
Lr as DEFAULT_LABEL_PAGE_LIMIT,
|
|
1407
|
+
tr as DEFAULT_STROKE_COLOR,
|
|
1408
|
+
Pe as DEFAULT_TEXT_COLOR,
|
|
1409
|
+
nr as LINE_HEIGHT,
|
|
1420
1410
|
A as LabelSheetError,
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1411
|
+
rr as MM_PER_INCH,
|
|
1412
|
+
di as OutputAssetError,
|
|
1413
|
+
ot as OutputFidelityError,
|
|
1414
|
+
Q as PAPER_SIZES,
|
|
1415
|
+
Dt as PageBuilder,
|
|
1416
|
+
Dr as PaginateCellLimitError,
|
|
1417
|
+
Fr as PaginatePageLimitError,
|
|
1428
1418
|
pr as RENDER_PLAN_SCHEMA_VERSION,
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1419
|
+
br as REPORT_TEMPLATE_DOCUMENT_VERSION,
|
|
1420
|
+
lr as ReportBindingError,
|
|
1421
|
+
w as ReportCalculationError,
|
|
1422
|
+
nt as ReportCellEditError,
|
|
1423
|
+
Gt as ReportCellFieldError,
|
|
1424
|
+
hi as ReportDrillError,
|
|
1425
|
+
bi as ReportParamValidationError,
|
|
1435
1426
|
me as ReportSourceError,
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1427
|
+
Ne as ReportTemplateError,
|
|
1428
|
+
D as ReportTemplateStoreError,
|
|
1429
|
+
ir as SCHEMA_VERSION_MACH,
|
|
1430
|
+
Lt as TemplateBuilder,
|
|
1431
|
+
Ui as TreeRowLimitError,
|
|
1432
|
+
Or as applyReportCellEdit,
|
|
1433
|
+
zr as applyReportCellEditBatch,
|
|
1434
|
+
Hi as applyReportDocumentStyle,
|
|
1435
|
+
Hr as applyReportEditResult,
|
|
1436
|
+
Br as applyReportSourceMetadata,
|
|
1437
|
+
Mr as assertRenderPlan,
|
|
1438
|
+
Mi as assertReportParams,
|
|
1439
|
+
Yn as calculateReportSelection,
|
|
1440
|
+
Bi as captureTemplateFragment,
|
|
1441
|
+
Ar as charWidthEm,
|
|
1442
|
+
E as classOf,
|
|
1443
|
+
Ai as cloneReportTemplate,
|
|
1444
|
+
Di as collectTemplateOutline,
|
|
1445
|
+
zn as columnsFromContract,
|
|
1446
|
+
Ct as computePageWindow,
|
|
1447
|
+
Wr as countTemplatePages,
|
|
1448
|
+
kr as createCanvasMeasurer,
|
|
1449
|
+
Fn as createCanvasPager,
|
|
1450
|
+
$r as createHeuristicMeasurer,
|
|
1451
|
+
Bn as createLabelTemplate,
|
|
1452
|
+
ki as createLocalTemplateCatalog,
|
|
1453
|
+
Un as createMemoryTemplateStore,
|
|
1454
|
+
_n as createProviderReport,
|
|
1455
|
+
_r as createReportCellEdit,
|
|
1456
|
+
jr as createReportCellEditBatch,
|
|
1457
|
+
Ur as createReportCellResolver,
|
|
1458
|
+
gi as createReportDrillRequest,
|
|
1459
|
+
Gr as createReportEditSession,
|
|
1460
|
+
qr as createReportSource,
|
|
1461
|
+
Hn as createTableTemplate,
|
|
1462
|
+
On as createTemplate,
|
|
1463
|
+
jn as createTemplateManager,
|
|
1464
|
+
vr as createTemplateRegistry,
|
|
1465
|
+
Gi as createTreeTable,
|
|
1466
|
+
Rr as datasetJsonSchema,
|
|
1467
|
+
Wn as defineLabelReport,
|
|
1468
|
+
tt as defineReport,
|
|
1469
|
+
yr as defineReportTemplate,
|
|
1470
|
+
$i as diffReportTemplates,
|
|
1471
|
+
Vr as estimateListLayoutCells,
|
|
1472
|
+
cr as evalStyleRule,
|
|
1473
|
+
gn as evaluateReportAggregateExpression,
|
|
1474
|
+
Yr as formatReportCellEdit,
|
|
1475
|
+
Gn as formatReportClipboard,
|
|
1476
|
+
vi as formatReportDateRange,
|
|
1477
|
+
dr as formatValue,
|
|
1478
|
+
Kr as getReportCellContext,
|
|
1479
|
+
Jr as getReportEditSession,
|
|
1480
|
+
Xr as hasValidDataExplanation,
|
|
1481
|
+
de as heuristicMeasurer,
|
|
1482
|
+
Kn as imposeLabelSheets,
|
|
1483
|
+
Wi as insertTemplateFragment,
|
|
1484
|
+
li as inspectOutputCapabilities,
|
|
1485
|
+
Fi as inspectTemplateFieldUsage,
|
|
1486
|
+
_i as inspectTemplateFragmentBindings,
|
|
1494
1487
|
re as isImageBackedComponent,
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1488
|
+
Zr as isReportDataTarget,
|
|
1489
|
+
yi as isReportDate,
|
|
1490
|
+
xi as isReportMonth,
|
|
1491
|
+
Qr as isReportValueState,
|
|
1492
|
+
Si as isReportYear,
|
|
1500
1493
|
$e as isRichText,
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1494
|
+
fi as matchReportDrillActions,
|
|
1495
|
+
pe as measurePageSizePx,
|
|
1496
|
+
Ir as measureTextMm,
|
|
1497
|
+
ke as mergeComponentStyles,
|
|
1498
|
+
le as mmToPx,
|
|
1499
|
+
ar as mmToPxFactor,
|
|
1500
|
+
ei as paginateTemplate,
|
|
1501
|
+
ti as paginateTemplatePages,
|
|
1502
|
+
mr as parseDateLocal,
|
|
1509
1503
|
Vn as parseReportCellFieldInput,
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1504
|
+
rt as parseReportCellInput,
|
|
1505
|
+
qn as parseReportClipboard,
|
|
1506
|
+
Ei as parseReportDateRange,
|
|
1507
|
+
G as parseReportTemplate,
|
|
1508
|
+
In as planFontSizePx,
|
|
1509
|
+
ni as projectListColumns,
|
|
1516
1510
|
W as ptToPx,
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1511
|
+
or as pxToMm,
|
|
1512
|
+
ri as registerReportEditSession,
|
|
1513
|
+
ii as relocateReportCellEdits,
|
|
1514
|
+
Be as renderComponent,
|
|
1515
|
+
Mt as renderPage,
|
|
1516
|
+
$n as renderPlan,
|
|
1517
|
+
Ln as renderPlanToCanvas,
|
|
1518
|
+
Dn as renderPlanToCanvasAsync,
|
|
1519
|
+
Nn as renderPlanToImages,
|
|
1520
|
+
ai as reportCellEditKey,
|
|
1521
|
+
Y as reportOutputDiagnostics,
|
|
1522
|
+
Ti as reportParamsJsonSchema,
|
|
1523
|
+
Ae as resolveBoxBorders,
|
|
1524
|
+
hr as resolveComponentBinding,
|
|
1525
|
+
z as resolveFontSize,
|
|
1526
|
+
De as resolveGridLayout,
|
|
1527
|
+
_ as resolveLineHeight,
|
|
1528
|
+
qe as resolvePaper,
|
|
1529
|
+
he as resolvePlanAssets,
|
|
1530
|
+
ui as resolveReportDrillReturn,
|
|
1531
|
+
q as resolveStroke,
|
|
1532
|
+
ce as resolveTextColor,
|
|
1533
|
+
Ii as reviewReportTemplate,
|
|
1534
|
+
Ni as reviewReportTemplateAsync,
|
|
1535
|
+
U as round,
|
|
1536
|
+
xr as serializeReportTemplate,
|
|
1537
|
+
oi as summarizeReportCellEdits,
|
|
1538
|
+
Oi as templatePathLocation,
|
|
1539
|
+
gr as toExcelNumberFormat,
|
|
1540
|
+
fr as toNumber,
|
|
1541
|
+
Sr as validateComponent,
|
|
1542
|
+
et as validateDatasetRows,
|
|
1543
|
+
Er as validatePage,
|
|
1544
|
+
Qe as validateRenderPlan,
|
|
1545
|
+
Qt as validateReportCellFieldDefinition,
|
|
1546
|
+
pi as validateReportDrillActions,
|
|
1547
|
+
Ci as validateReportParamDefinitions,
|
|
1548
|
+
Ri as validateReportParams,
|
|
1549
|
+
Ie as validateReportTemplate,
|
|
1550
|
+
Tr as validateReportTemplateDocument,
|
|
1551
|
+
qi as validateTreeOptions,
|
|
1552
|
+
Le as wrapText
|
|
1557
1553
|
};
|