@agile-team/mach-report 2.24.0 → 2.25.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -4
- package/dist/{ExcelBindingWizard-Cy_lPjWV.js → ExcelBindingWizard-bs3F4dD8.js} +3 -3
- package/dist/{ExcelBindingWizard-BV12hGiK.cjs → ExcelBindingWizard-jSdjBtWw.cjs} +1 -1
- package/dist/{ParamEditor-PyOqHzzw.js → ParamEditor-B7YVD28E.js} +2 -2
- package/dist/{ParamEditor-DenKjvKu.cjs → ParamEditor-CGfaweYX.cjs} +1 -1
- package/dist/{ReportBatchPanel-pQ6d0yqJ.cjs → ReportBatchPanel-BRJt0TXp.cjs} +1 -1
- package/dist/{ReportBatchPanel-8EFtMrKk.js → ReportBatchPanel-BTKHtLTW.js} +2 -2
- package/dist/{ReportLabelStudio-B_KF3Zc_.cjs → ReportLabelStudio-BvK_WBke.cjs} +1 -1
- package/dist/{ReportLabelStudio-HUeo2TsU.js → ReportLabelStudio-CZwqyO3t.js} +3 -3
- package/dist/{ReportParamPanel-8xR85nz-.cjs → ReportParamPanel-B27IGJjk.cjs} +1 -1
- package/dist/{ReportParamPanel-DA-YpkvC.js → ReportParamPanel-DGXzBzl2.js} +1 -1
- package/dist/{ReportPreview-_wTJnsG1.js → ReportPreview-CnxaDTCO.js} +2392 -2342
- package/dist/ReportPreview-DqFBcsJQ.cjs +6 -0
- package/dist/{ReportTemplateLibrary-DH8jl9IF.js → ReportTemplateLibrary-C7sB0Jay.js} +1 -1
- package/dist/{ReportTemplateLibrary-CjArKxRG.cjs → ReportTemplateLibrary-ClwxhnC0.cjs} +1 -1
- package/dist/{RuleEditor-GDydlEHz.js → RuleEditor-CsDGFaWz.js} +3 -4
- package/dist/{RuleEditor-Bmj98oC4.cjs → RuleEditor-D-OdaGdR.cjs} +1 -1
- package/dist/{TemplateOutlinePanel-DjPqzU9h.js → TemplateOutlinePanel-CXOT7d1r.js} +2 -2
- package/dist/{TemplateOutlinePanel-B554_qk1.cjs → TemplateOutlinePanel-DAqR9zQi.cjs} +1 -1
- package/dist/{TemplateReusePanel-DtYbCN7U.js → TemplateReusePanel-Dcfx3Hba.js} +2 -2
- package/dist/{TemplateReusePanel-D0628OYc.cjs → TemplateReusePanel-ygIi-Ajz.cjs} +1 -1
- package/dist/{TemplateReviewPanel-D_FR4ISq.js → TemplateReviewPanel-COU8FqPq.js} +1 -1
- package/dist/{TemplateReviewPanel-CSwvCz3f.cjs → TemplateReviewPanel-DyGULVxr.cjs} +1 -1
- package/dist/analytics.cjs +1 -1
- package/dist/analytics.d.cts +1 -1
- package/dist/analytics.d.ts +1 -1
- package/dist/analytics.js +2 -2
- package/dist/artifact-integrity.json +102 -102
- package/dist/{assets-B4AJIOTB.cjs → assets-BYdpkTIt.cjs} +1 -1
- package/dist/{assets-D0FbszhB.js → assets-C4MIvzQ4.js} +2 -2
- package/dist/{auto-BksreoKc.js → auto-D7x7QsWD.js} +10 -10
- package/dist/{auto-C3mGqzJ8.cjs → auto-mPK9W0y5.cjs} +1 -1
- package/dist/{capabilities-lqDEZSq5.js → capabilities-CN_kSVjO.js} +7 -7
- package/dist/{capabilities-CTwlcl8q.cjs → capabilities-D4nfhcvB.cjs} +1 -1
- package/dist/cell-style-B6Qffrx8.js +37 -0
- package/dist/cell-style-y_uh1pZp.cjs +1 -0
- package/dist/{data-bar-BnGtnJ82.js → data-bar-Bfh54sT4.js} +1 -1
- package/dist/{data-bar-2NLRzOCQ.cjs → data-bar-DzceAVeR.cjs} +1 -1
- package/dist/{designer-BNf7NWd6.js → designer-B597ZdC0.js} +2254 -2248
- package/dist/designer-DFIdv_n7.cjs +2 -0
- package/dist/designer.cjs +1 -1
- package/dist/designer.d.cts +6 -6
- package/dist/designer.d.ts +6 -6
- package/dist/designer.js +1 -1
- package/dist/diagnostic-collector-gB07PHy2.js +392 -0
- package/dist/diagnostic-collector-wASg6Fzs.cjs +1 -0
- package/dist/dom-CXWMmwh-.cjs +1 -0
- package/dist/{dom-C90cTM6Y.js → dom-DxdCMLzs.js} +185 -185
- package/dist/{encoding-DSc9zv2F.js → encoding-Amq3XrtU.js} +2 -2
- package/dist/{encoding-CkziAnZI.cjs → encoding-DRVXs5xm.cjs} +1 -1
- package/dist/{font-loader-i7lZbqH_.js → font-loader-D4NLIKJL.js} +1 -1
- package/dist/{font-loader-D-znWNWS.cjs → font-loader-p_SyTvqt.cjs} +1 -1
- package/dist/{grid-strokes-BPiV1WHe.js → grid-strokes-DkZEZvcI.js} +1 -1
- package/dist/{grid-strokes-DYf-6DMl.cjs → grid-strokes-RFMR91jn.cjs} +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +137 -137
- package/dist/{json-snapshot-BJWZNryO.js → json-snapshot-CBVWZvyC.js} +662 -615
- package/dist/json-snapshot-DCFEtfFw.cjs +2 -0
- package/dist/matrix-DUYPRL7t.cjs +1 -0
- package/dist/{matrix-C6e_r_vp.js → matrix-b6T291xo.js} +120 -104
- package/dist/{pdf-DWuq6uxx.cjs → pdf-C060D5UY.cjs} +2 -2
- package/dist/{pdf-0_5XiTCx.js → pdf-DU8HelKd.js} +17 -17
- package/dist/pdf.cjs +1 -1
- package/dist/pdf.js +2 -2
- package/dist/{plugin-B1ydqEmS.js → plugin-BdCplNe1.js} +1 -1
- package/dist/{plugin-BQBz2vLG.cjs → plugin-DHe8y5pD.cjs} +1 -1
- package/dist/{prefill-Cuzh1wxf.js → prefill-Buy4NJ15.js} +2 -2
- package/dist/{prefill-2p9wrpn9.cjs → prefill-Cw4ZYGXZ.cjs} +1 -1
- package/dist/{prepared-DAwe8Il2.cjs → prepared-BlNeOjoO.cjs} +1 -1
- package/dist/{prepared-CVbgO9KR.js → prepared-CBJ7BkK0.js} +2 -2
- package/dist/protocol-BU_4sXP0.cjs +1 -0
- package/dist/protocol-CB19KXGr.js +96 -0
- package/dist/record-bindings-B7djSjNs.cjs +1 -0
- package/dist/{record-bindings-fhav-NLG.js → record-bindings-Cv7lFiof.js} +47 -47
- package/dist/{region-binding-workflow-Cm4mqhih.js → region-binding-workflow-EYxvUYJ-.js} +2 -2
- package/dist/{region-binding-workflow-DWCUgjZl.cjs → region-binding-workflow-NdkMSFCh.cjs} +1 -1
- package/dist/report-encoding-worker.cjs +1 -1
- package/dist/report-encoding-worker.js +1 -1
- package/dist/{rich-text-layout-YJHtCWQI.js → rich-text-layout-Ch_N0Ubu.js} +1 -1
- package/dist/{rich-text-layout-X9YOz1JD.cjs → rich-text-layout-yJGuThtC.cjs} +1 -1
- package/dist/runtime-B5d_lQNQ.js +227 -0
- package/dist/runtime-BRx8Agqr.cjs +1 -0
- package/dist/sbom.cdx.json +1 -1
- package/dist/server-node.cjs +5 -5
- package/dist/server-node.js +1891 -1793
- package/dist/server.cjs +1 -1
- package/dist/server.d.cts +4 -4
- package/dist/server.d.ts +4 -4
- package/dist/server.js +8 -8
- package/dist/style.css +1 -1
- package/dist/{template-catalog-Bu7s7ReF.js → template-catalog-CM6U_RlD.js} +3 -3
- package/dist/{template-catalog--yBX169M.cjs → template-catalog-Cj66M84u.cjs} +1 -1
- package/dist/{template-fragments-Di2vDFnx.js → template-fragments-BDxdCuMD.js} +2 -2
- package/dist/{template-fragments-5EzVn7bm.cjs → template-fragments-DbKdxI1z.cjs} +1 -1
- package/dist/template-registry-B-AK1oam.cjs +1 -0
- package/dist/{template-registry-BCBF2b8j.js → template-registry-DeVgwEZj.js} +145 -144
- package/dist/{textwrap-CmVkhMhx.js → textwrap-BywMBMXM.js} +1 -1
- package/dist/{textwrap-BPFxhpOw.cjs → textwrap-LhJkHWb1.cjs} +1 -1
- package/dist/vue/async.d.cts +4 -4
- package/dist/vue/async.d.ts +4 -4
- package/dist/vue/index.d.cts +6 -6
- package/dist/vue/index.d.ts +6 -6
- package/dist/vue-async.cjs +1 -1
- package/dist/vue-async.js +3 -3
- package/dist/vue.cjs +1 -1
- package/dist/vue.js +7 -7
- package/dist/{workbook-session-B6P_-5a4.js → workbook-session-B6hRjTyX.js} +106 -107
- package/dist/{workbook-session-BnPK3T58.cjs → workbook-session-BclW7KKH.cjs} +3 -3
- package/dist/worker.cjs +1 -1
- package/dist/worker.js +4 -4
- package/dist/xlsx/node.d.cts +30 -1
- package/dist/xlsx/node.d.ts +30 -1
- package/dist/xlsx-node.cjs +42 -42
- package/dist/xlsx-node.js +3908 -3889
- package/dist/xlsx.cjs +2 -2
- package/dist/xlsx.d.cts +2 -2
- package/dist/xlsx.d.ts +2 -2
- package/dist/xlsx.js +151 -151
- package/package.json +1 -1
- package/dist/ReportPreview-CyUXJSVX.cjs +0 -6
- package/dist/designer-DWnZZ_ej.cjs +0 -2
- package/dist/diagnostic-collector-1sqd7DQP.js +0 -355
- package/dist/diagnostic-collector-D3rlvxm3.cjs +0 -1
- package/dist/dom-CxOkm_Sy.cjs +0 -1
- package/dist/json-snapshot-C7QZrRBf.cjs +0 -2
- package/dist/matrix-B8QWbsGM.cjs +0 -1
- package/dist/progress-BXzlVbIp.js +0 -29
- package/dist/progress-DJBd9Rb9.cjs +0 -1
- package/dist/protocol-BOri9qJL.js +0 -105
- package/dist/protocol-DD5dHSz-.cjs +0 -1
- package/dist/record-bindings-CAyM5tGg.cjs +0 -1
- package/dist/runtime-BpSAgOw1.js +0 -201
- package/dist/runtime-Cd2UTnwe.cjs +0 -1
- package/dist/template-registry-Bnh5aEYf.cjs +0 -1
package/dist/matrix-B8QWbsGM.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const g=require("./computed-DK6BruFz.cjs");function $(e,r){const l=()=>r.measures.map(i=>g.createAggregateAccumulator(i)),t=new Map,n=new Map,o=new Map,a=r.totals?l():void 0,s=(i,c)=>i?.forEach(u=>u.add(c));for(const i of e){const c=r.row(i),u=r.column(i);n.has(u.key)||n.set(u.key,u.label);let f=t.get(c.key);f||(f={label:c.label,cells:new Map,...r.totals?{totals:l()}:{}},t.set(c.key,f)),r.check(t.size,n.size);let d=f.cells.get(u.key);if(d||(d=l(),f.cells.set(u.key,d)),s(d,i),!r.totals)continue;let w=o.get(u.key);w||(w=l(),o.set(u.key,w)),s(f.totals,i),s(w,i),s(a,i)}return{groups:t,columns:n,columnTotals:o,totals:a}}function h(e,r){return JSON.stringify([e.slice(0,r.length),r.map(l=>[l===null?"null":typeof l,l])])}function S(e,r){return r.map(l=>{const t=Object.prototype.hasOwnProperty.call(e,l)?e[l]:null;if(t==null)return null;if(typeof t=="string"||typeof t=="boolean"||typeof t=="number"&&Number.isFinite(t))return t;throw new Error("矩阵维度必须是有限 JSON 标量")})}function N(e,r,l){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("矩阵层级应为对象");for(const t of[e.emptyLabel,e.subtotalLabel,e.totalLabel])if(t!==void 0&&typeof t!="string")throw new Error("矩阵层级标签应为字符串");k(e.row,r.length),k(e.column,l.length)}function k(e,r){if(e!==void 0){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("矩阵轴配置应为对象");if(e.labels!==void 0&&(!Array.isArray(e.labels)||e.labels.length!==r||e.labels.some(l=>typeof l!="string")))throw new Error("矩阵维度标签必须与维度字段一一对应");if(e.sort!==void 0&&(!Array.isArray(e.sort)||e.sort.length>r||e.sort.some(l=>!["source","asc","desc"].includes(l))))throw new Error("矩阵维度排序应为 source、asc 或 desc");if(e.subtotals!==void 0&&(!Array.isArray(e.subtotals)||new Set(e.subtotals).size!==e.subtotals.length||e.subtotals.some(l=>!Number.isInteger(l)||l<1||l>=r)))throw new Error("矩阵小计深度应唯一且位于 1 至末级之前")}}function A(e,r,l){return{fields:e,options:r??{},hierarchy:l,root:{values:[],children:new Map},leaves:0,expanded:0}}function F(e,r){const l=S(r,e.fields);let t=e.root;for(let n=1;n<=l.length;n++){const o=l.slice(0,n),a=h(e.fields,o);let s=t.children.get(a);s||(s={values:o,children:new Map},t.children.set(a,s),n===l.length?(e.leaves++,e.expanded++):e.options.subtotals?.includes(n)&&e.expanded++),t=s}}function L(e,r){if(e===r)return 0;if(e===null)return-1;if(r===null)return 1;if(typeof e=="number"&&typeof r=="number")return e-r;const l=`${typeof e}:${e}`,t=`${typeof r}:${r}`;return l<t?-1:1}function R(e,r){const l=[...e.children.values()];return r&&r!=="source"&&l.sort((t,n)=>L(t.values[t.values.length-1],n.values[n.values.length-1])*(r==="desc"?-1:1)),l}function y(e,r,l){return{key:h(e.fields,r),kind:l,depth:r.length,fields:e.fields.slice(0,r.length),values:r,labels:r.map(t=>t===null?e.hierarchy.emptyLabel??"(空)":String(t))}}function E(e,r){const l=[];function t(n){for(const o of R(n,e.options.sort?.[n.values.length]))o.children.size?(t(o),e.options.subtotals?.includes(o.values.length)&&l.push(y(e,o.values,"subtotal"))):l.push(y(e,o.values,"member"))}return t(e.root),r&&e.leaves&&l.push(y(e,[],"total")),l}function v(e,r,l){const t=S(r,e.fields),n=[h(e.fields,t),...(e.options.subtotals??[]).map(o=>h(e.fields,t.slice(0,o)))];return l&&n.push(h(e.fields,[])),n}function z(e,r,l){if(!(e.kind!=="member"&&r>e.depth))return e.kind==="total"?{key:"total",text:l.totalLabel??"合计",rowSpan:0}:e.kind==="subtotal"&&r===e.depth?{key:e.key,text:l.subtotalLabel??"小计",rowSpan:0}:{key:JSON.stringify(e.values.slice(0,r+1).map(t=>[typeof t,t])),text:e.labels[r],rowSpan:1}}function O(e,r){const l=e.columnFields.length+1,t=e.rowFields.length,n=Array.from({length:l},()=>Array(t+r.length).fill(null));for(let o=0;o<e.columnFields.length;o++){let a;r.forEach((s,i)=>{const c=z(s,o,e.hierarchy);if(!c){a=void 0;return}if(a?.key===c.key){a.cell.colSpan=(a.cell.colSpan??1)+1;return}const u={text:c.text,rowSpan:c.rowSpan||e.columnFields.length-o,editable:!1,derived:!0};n[o][t+i]=u,a={key:c.key,cell:u}})}return e.rowFields.forEach((o,a)=>{n[0][a]={text:e.hierarchy.row?.labels?.[a]??o,rowSpan:l,editable:!1,derived:!0}}),r.forEach((o,a)=>{const s=e.measures[o.measure];n[l-1][t+a]={text:s.label??`${s.field} (${s.op})`,editable:!1,derived:!0}}),{cells:n.map(o=>o.filter(a=>a!==null)),colWidthsMm:[...e.rowFields.map(()=>e.rowWidthMm??40),...r.map(()=>e.columnWidthMm??28)]}}function M(e,r,l,t){const n=+(!!r.totals&&e>0),o=l.expanded+n,a=(t.expanded+n)*r.measures.length+r.rowFields.length;if(o>(r.maxRows??1e3)||t.expanded+n>(r.maxColumns??200))throw new Error("矩阵层级展开数量超出预算(包含小计/总计)");if(o*a>(r.maxCells??2e6))throw new Error("矩阵输出超出 maxCells 预算");return{rowCount:o,columnCount:a,cells:o*a}}function x(e,r){if(!Array.isArray(e)||e.length>(r.maxInputRows??1e5))throw new Error("矩阵输入超出预算");const l=A(r.rowFields,r.hierarchy.row,r.hierarchy),t=A(r.columnFields,r.hierarchy.column,r.hierarchy);if(e.length*(1+(l.options.subtotals?.length??0)+ +!!r.totals)*(1+(t.options.subtotals?.length??0)+ +!!r.totals)*r.measures.length>(r.maxAggregateUpdates??1e7))throw new Error("矩阵聚合更新超出 maxAggregateUpdates 预算");let o=M(0,r,l,t);for(const a of e){if(!a||typeof a!="object"||Array.isArray(a))throw new Error("矩阵数据行应为对象");F(l,a),F(t,a),o=M(e.length,r,l,t)}return{row:l,column:t,shape:o}}function j(e,r){return x(e,r).shape}function p(e,r,l){const t=new Map;for(const n of e){const o=v(l.row,n,!!r.totals),a=v(l.column,n,!!r.totals);for(const s of o){let i=t.get(s);i||(i=new Map,t.set(s,i));for(const c of a){let u=i.get(c);u||(u=r.measures.map(f=>g.createAggregateAccumulator({...f,field:f.valueField??f.field})),i.set(c,u)),u.forEach(f=>f.add(n))}}}return t}function H(e,r){return e.flatMap((l,t)=>r.measures.map((n,o)=>({...l,field:l.kind==="total"?`total_${o}`:`c${t}_${o}`,measure:o,measureField:n.field,valueField:n.valueField??n.field,operation:n.op})))}function I(e,r){return e.kind==="total"?r.hierarchy.totalLabel??"合计":[...e.labels,...e.kind==="subtotal"?[r.hierarchy.subtotalLabel??"小计"]:[]].join(" / ")}function K(e,r){return[...r.rowFields.map((l,t)=>({field:`r${t}`,header:r.hierarchy.row?.labels?.[t]??l,semanticRole:"dimension"})),...e.map(l=>{const t=r.measures[l.measure];return{field:l.field,header:`${I(l,r)} · ${t.label??`${t.field} (${t.op})`}`,semanticRole:"measure",...t.digits===void 0?{}:{format:{kind:"number",digits:t.digits}}}})]}function T(e,r,l,t){return e.map(n=>{const o={};l.rowFields.forEach((a,s)=>{o[`r${s}`]=n.kind==="total"?s===0?l.hierarchy.totalLabel??"合计":null:n.labels[s]??(s===n.depth?l.hierarchy.subtotalLabel??"小计":null)});for(const a of r)o[a.field]=t.get(n.key)?.get(a.key)?.[a.measure]?.value()??(l.measures[a.measure].op==="count"?0:null);return o})}function _(e,r){const l=x(e,r),t=E(l.row,!!r.totals),n=H(E(l.column,!!r.totals),r),o=p(e,r,l);return{columns:K(n,r),rows:T(t,n,r,o),headerGrid:O(r,n),metadata:{rowFields:[...r.rowFields],rowLabels:[...r.hierarchy.row?.labels??r.rowFields],columnFields:[...r.columnFields],columnLabels:[...r.hierarchy.column?.labels??r.columnFields],rows:t,columns:n}}}function m(e,r){const l=r.map(t=>Object.prototype.hasOwnProperty.call(e,t)?e[t]:null);if(l.some(t=>t!=null&&typeof t!="string"&&typeof t!="boolean"&&!(typeof t=="number"&&Number.isFinite(t))))throw new Error("矩阵维度必须是有限 JSON 标量");return{key:JSON.stringify(l.map(t=>[typeof t,t??null])),label:l.map(t=>t==null?"":String(t)).join(" / ")}}function J(e){for(const r of["maxRows","maxColumns","maxInputRows","maxCells","maxAggregateUpdates"])if(e[r]!==void 0&&(!Number.isSafeInteger(e[r])||e[r]<1))throw new Error("矩阵预算应为正安全整数");for(const r of["columnWidthMm","rowWidthMm"])if(e[r]!==void 0&&(!Number.isFinite(e[r])||e[r]<=0))throw new Error("矩阵列宽应为正数")}function b(e){if(!e||!Array.isArray(e.rowFields)||!Array.isArray(e.columnFields)||!Array.isArray(e.measures))throw new Error("矩阵需要行维度、列维度和度量数组");for(const l of[e.rowFields,e.columnFields])if(l.some(t=>typeof t!="string"||!t.trim())||new Set(l).size!==l.length)throw new Error("矩阵维度字段应非空且唯一");if(J(e),!e.rowFields.length||!e.columnFields.length||e.rowFields.length>16||e.columnFields.length>16)throw new Error("矩阵需要 1–16 个行/列维度");if(!e.measures.length||e.measures.length>32)throw new Error("矩阵需要 1–32 个度量");if(e.measures.map(l=>{if(!l||typeof l!="object")throw new Error("矩阵度量应为对象");if(g.createAggregateAccumulator({...l,field:l.valueField??l.field}),l.label!==void 0&&typeof l.label!="string")throw new Error("矩阵度量标签应为字符串");return l.field}).some(l=>typeof l!="string"||!l.trim()))throw new Error("矩阵度量字段应非空");e.hierarchy!==void 0&&N(e.hierarchy,e.rowFields,e.columnFields)}function C(e,r){if(b(r),r.hierarchy)return j(e,r);if(!Array.isArray(e)||e.length>(r.maxInputRows??1e5))throw new Error("矩阵输入超出预算");const l=new Set,t=new Set;for(const a of e){if(!a||typeof a!="object"||Array.isArray(a))throw new Error("矩阵数据行应为对象");if(l.add(m(a,r.rowFields).key),t.add(m(a,r.columnFields).key),l.size>(r.maxRows??1e3)||t.size>(r.maxColumns??200))throw new Error("矩阵维度数量超出预算");if((l.size+ +!!r.totals)*((t.size+ +!!r.totals)*r.measures.length+1)>(r.maxCells??2e6))throw new Error("矩阵输出超出 maxCells 预算")}const n=l.size+ +(!!r.totals&&e.length>0),o=(t.size+ +!!r.totals)*r.measures.length+1;return{rowCount:n,columnCount:o,cells:n*o}}function P(e,r){if(r?.hierarchy)return b(r),_(e,r);C(e,r);const l=$(e,{row:a=>m(a,r.rowFields),column:a=>m(a,r.columnFields),measures:r.measures.map(a=>({...a,field:a.valueField??a.field})),totals:r.totals,check:()=>{}}),t=[...l.groups.values()].map(a=>({rowLabel:a.label})),n=[{field:"rowLabel",header:r.rowHeader??r.rowFields.join(" / "),semanticRole:"dimension"}],o={rowLabel:"合计"};return r.measures.forEach((a,s)=>{const i=[...l.columns.entries()].map(([c,u],f)=>({key:c,label:u,field:`c${f}_${s}`}));r.totals&&i.push({key:"",label:"合计",field:`total_${s}`});for(const c of i){const u=c.field===`total_${s}`;n.push({field:c.field,header:`${c.label} · ${a.label??`${a.field} (${a.op})`}`,semanticRole:"measure",...a.digits===void 0?{}:{format:{kind:"number",digits:a.digits}}});let f=0;for(const d of l.groups.values())t[f++][c.field]=(u?d.totals?.[s]:d.cells.get(c.key)?.[s])?.value()??(a.op==="count"?0:null);o[c.field]=(u?l.totals?.[s]:l.columnTotals.get(c.key)?.[s])?.value()??(a.op==="count"?0:null)}}),r.totals&&e.length&&t.push(o),{rows:t,columns:n}}exports.accumulatePivotRows=$;exports.createMatrixTable=P;exports.estimateMatrixTable=C;exports.validateMatrixOptions=b;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
function s(o) {
|
|
2
|
-
if (o?.aborted) throw o.reason ?? new DOMException("The operation was aborted.", "AbortError");
|
|
3
|
-
}
|
|
4
|
-
function u(o) {
|
|
5
|
-
try {
|
|
6
|
-
Promise.resolve(o()).catch(() => {
|
|
7
|
-
});
|
|
8
|
-
} catch {
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
function b(o, e) {
|
|
12
|
-
const r = Promise.resolve(o);
|
|
13
|
-
return e?.aborted ? (r.catch(() => {
|
|
14
|
-
}), Promise.reject(e.reason ?? new DOMException("The operation was aborted.", "AbortError"))) : e ? new Promise((i, c) => {
|
|
15
|
-
const t = () => e.removeEventListener("abort", n), n = () => {
|
|
16
|
-
t(), c(e.reason ?? new DOMException("The operation was aborted.", "AbortError"));
|
|
17
|
-
};
|
|
18
|
-
e.addEventListener("abort", n, { once: !0 }), r.then((a) => {
|
|
19
|
-
t(), i(a);
|
|
20
|
-
}, (a) => {
|
|
21
|
-
t(), c(a);
|
|
22
|
-
}), e.aborted && n();
|
|
23
|
-
}) : r;
|
|
24
|
-
}
|
|
25
|
-
export {
|
|
26
|
-
s as a,
|
|
27
|
-
u as o,
|
|
28
|
-
b as w
|
|
29
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";function i(e){if(e?.aborted)throw e.reason??new DOMException("The operation was aborted.","AbortError")}function s(e){try{Promise.resolve(e()).catch(()=>{})}catch{}}function b(e,t){const r=Promise.resolve(e);return t?.aborted?(r.catch(()=>{}),Promise.reject(t.reason??new DOMException("The operation was aborted.","AbortError"))):t?new Promise((a,c)=>{const o=()=>t.removeEventListener("abort",n),n=()=>{o(),c(t.reason??new DOMException("The operation was aborted.","AbortError"))};t.addEventListener("abort",n,{once:!0}),r.then(u=>{o(),a(u)},u=>{o(),c(u)}),t.aborted&&n()}):r}exports.assertOutputActive=i;exports.observeOutput=s;exports.waitForOutput=b;
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { e as m, f as g, b as y } from "./prepared-CVbgO9KR.js";
|
|
2
|
-
import { v as d } from "./json-snapshot-BJWZNryO.js";
|
|
3
|
-
import { u, F as h, E as a } from "./diagnostic-collector-1sqd7DQP.js";
|
|
4
|
-
import { b } from "./template-registry-BCBF2b8j.js";
|
|
5
|
-
const n = "mach-report-worker/1";
|
|
6
|
-
class D extends Error {
|
|
7
|
-
constructor(r) {
|
|
8
|
-
super(r.message), this.name = r.name, this.code = r.code, this.path = r.path, this.issues = r.issues, this.diagnostics = r.diagnostics, this.diagnosticSummary = r.diagnosticSummary, this.issueSummary = r.issueSummary;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
function i(t) {
|
|
12
|
-
return !!t && typeof t == "object" && !Array.isArray(t);
|
|
13
|
-
}
|
|
14
|
-
function I(t) {
|
|
15
|
-
return i(t) ? ["rows", "pages", "cells"].every((r) => typeof t[r] == "number" && Number.isSafeInteger(t[r]) && t[r] >= 0) && typeof t.durationMs == "number" && Number.isFinite(t.durationMs) && t.durationMs >= 0 : !1;
|
|
16
|
-
}
|
|
17
|
-
function S(t) {
|
|
18
|
-
return Array.isArray(t) && t.every((r) => i(r) && typeof r.code == "string" && typeof r.message == "string" && ["info", "warning", "error"].includes(r.severity) && d(r) && y(r));
|
|
19
|
-
}
|
|
20
|
-
function k(t) {
|
|
21
|
-
return i(t) && Object.values(t).every((r) => i(r) && (r.revision === void 0 || typeof r.revision == "string") && (r.sourceToken === void 0 || typeof r.sourceToken == "string"));
|
|
22
|
-
}
|
|
23
|
-
function x(t) {
|
|
24
|
-
return t === void 0 ? !0 : i(t) && ["heuristic", "provided", "font-bytes"].includes(t.textMetrics) && (t.fontFingerprint === void 0 || typeof t.fontFingerprint == "string" && /^[a-f0-9]{64}$/.test(t.fontFingerprint));
|
|
25
|
-
}
|
|
26
|
-
function E(t, r) {
|
|
27
|
-
if (!i(t) || !I(t.stats) || !S(t.diagnostics) || !k(t.revisions) || !x(t.layout) || !m(t.sources) || t.diagnosticSummary !== void 0 && !g(t.diagnosticSummary, t.diagnostics)) return !1;
|
|
28
|
-
if (r === "prepare") return b(t.plan).ok;
|
|
29
|
-
const e = t.format === "pdf" ? "application/pdf" : "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
|
|
30
|
-
return t.bytes instanceof Uint8Array && (t.format === "pdf" || t.format === "xlsx") && t.contentType === e;
|
|
31
|
-
}
|
|
32
|
-
function p(t) {
|
|
33
|
-
if (!t || typeof t != "object") return { message: String(t).slice(0, 4096) };
|
|
34
|
-
const r = {};
|
|
35
|
-
for (const e of ["code", "path", "field", "message"]) {
|
|
36
|
-
const o = t[e];
|
|
37
|
-
typeof o == "string" && (r[e] = o.slice(0, e === "code" ? 128 : 4096));
|
|
38
|
-
}
|
|
39
|
-
return r;
|
|
40
|
-
}
|
|
41
|
-
function l(t) {
|
|
42
|
-
const r = p(t);
|
|
43
|
-
if (!i(t)) return r;
|
|
44
|
-
for (const e of ["format", "severity", "kind", "nid"]) typeof t[e] == "string" && (r[e] = t[e].slice(0, 4096));
|
|
45
|
-
for (const e of ["pageIndex", "componentIndex"]) Number.isSafeInteger(t[e]) && t[e] >= 0 && (r[e] = t[e]);
|
|
46
|
-
if (d(t) && t.valueState !== void 0 && i(t.target)) {
|
|
47
|
-
r.valueState = t.valueState;
|
|
48
|
-
const e = {};
|
|
49
|
-
for (const o of ["datasetId", "field", "rowKey", "tableId", "reportScope"]) t.target[o] !== void 0 && (e[o] = t.target[o]);
|
|
50
|
-
r.target = e;
|
|
51
|
-
}
|
|
52
|
-
return i(t.extension) && typeof t.extension.id == "string" && typeof t.extension.version == "string" && (r.extension = { id: t.extension.id.slice(0, 128), version: t.extension.version.slice(0, 64) }), Array.isArray(t.componentPath) && t.componentPath.length <= 192 && t.componentPath.every((e) => Number.isSafeInteger(e) && e >= 0) && (r.componentPath = t.componentPath), r;
|
|
53
|
-
}
|
|
54
|
-
function f(t, r, e) {
|
|
55
|
-
const o = u(a);
|
|
56
|
-
if (h(e))
|
|
57
|
-
o.merge({ ...e, entries: e.entries.slice(0, a).map((s) => ({ code: i(s) && typeof s.code == "string" ? s.code : "unknown", value: s })) });
|
|
58
|
-
else for (const s of t) o.push({ code: i(s) && typeof s.code == "string" ? s.code : "unknown", value: s });
|
|
59
|
-
const c = o.snapshot();
|
|
60
|
-
return { ...c, entries: c.entries.map((s) => r(s.value)) };
|
|
61
|
-
}
|
|
62
|
-
function R(t) {
|
|
63
|
-
if (!(t instanceof Error)) return { name: "Error", message: String(t).slice(0, 8192) };
|
|
64
|
-
const r = t, e = Array.isArray(r.diagnostics) ? f(r.diagnostics, l, r.diagnosticSummary) : void 0, o = Array.isArray(r.issues) ? f(r.issues, p) : void 0;
|
|
65
|
-
return {
|
|
66
|
-
name: t.name.slice(0, 128),
|
|
67
|
-
message: t.message.slice(0, 8192),
|
|
68
|
-
...typeof r.code == "string" ? { code: r.code.slice(0, 128) } : {},
|
|
69
|
-
...typeof r.path == "string" ? { path: r.path.slice(0, 4096) } : {},
|
|
70
|
-
...o ? { issues: o.entries, ...o.omitted ? { issueSummary: o } : {} } : {},
|
|
71
|
-
...e ? { diagnostics: e.entries, ...e.omitted || r.diagnosticSummary !== void 0 ? { diagnosticSummary: e } : {} } : {}
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
function F(t) {
|
|
75
|
-
if (!t || typeof t != "object") return !1;
|
|
76
|
-
const r = t;
|
|
77
|
-
return r.protocol === n && typeof r.id == "string" && (r.operation === "prepare" || r.operation === "export" || r.operation === "exportPrepared") && !!r.input && typeof r.input == "object";
|
|
78
|
-
}
|
|
79
|
-
async function O(t, r, e) {
|
|
80
|
-
try {
|
|
81
|
-
const o = r.operation === "prepare" ? await t.prepare({ ...r.input, onEvent: e }) : r.operation === "exportPrepared" ? await t.exportPrepared({ ...r.input, onEvent: e }) : await t.export({ ...r.input, onEvent: e });
|
|
82
|
-
return { protocol: n, id: r.id, result: o };
|
|
83
|
-
} catch (o) {
|
|
84
|
-
return { protocol: n, id: r.id, error: R(o) };
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
function W(t) {
|
|
88
|
-
const r = t.result;
|
|
89
|
-
return !r || !("bytes" in r) || !(r.bytes.buffer instanceof ArrayBuffer) ? [] : [r.bytes.buffer];
|
|
90
|
-
}
|
|
91
|
-
function j(t, r) {
|
|
92
|
-
if (!i(t) || typeof t.taskId != "string" || !t.taskId || r.taskId !== void 0 && t.taskId !== r.taskId || t.correlationId !== r.correlationId || t.reportId !== void 0 && (typeof t.reportId != "string" || !("reportIds" in r && r.reportIds.includes(t.reportId))) || !["query", "validate", "layout", "assets", "encode"].includes(t.stage) || !["started", "completed", "failed"].includes(t.status)) return !1;
|
|
93
|
-
for (const e of ["completed", "total"]) if (t[e] !== void 0 && (typeof t[e] != "number" || !Number.isFinite(t[e]) || t[e] < 0)) return !1;
|
|
94
|
-
return t.completed === void 0 || t.total === void 0 || t.completed <= t.total;
|
|
95
|
-
}
|
|
96
|
-
export {
|
|
97
|
-
n as R,
|
|
98
|
-
W as a,
|
|
99
|
-
D as b,
|
|
100
|
-
E as c,
|
|
101
|
-
F as i,
|
|
102
|
-
O as r,
|
|
103
|
-
R as s,
|
|
104
|
-
j as v
|
|
105
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const a=require("./prepared-DAwe8Il2.cjs"),p=require("./json-snapshot-C7QZrRBf.cjs"),n=require("./diagnostic-collector-D3rlvxm3.cjs"),y=require("./template-registry-Bnh5aEYf.cjs"),c="mach-report-worker/1";class u extends Error{constructor(r){super(r.message),this.name=r.name,this.code=r.code,this.path=r.path,this.issues=r.issues,this.diagnostics=r.diagnostics,this.diagnosticSummary=r.diagnosticSummary,this.issueSummary=r.issueSummary}}function i(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function h(t){return i(t)?["rows","pages","cells"].every(r=>typeof t[r]=="number"&&Number.isSafeInteger(t[r])&&t[r]>=0)&&typeof t.durationMs=="number"&&Number.isFinite(t.durationMs)&&t.durationMs>=0:!1}function R(t){return Array.isArray(t)&&t.every(r=>i(r)&&typeof r.code=="string"&&typeof r.message=="string"&&["info","warning","error"].includes(r.severity)&&p.hasValidDataExplanation(r)&&a.validReportDiagnosticLocation(r))}function I(t){return i(t)&&Object.values(t).every(r=>i(r)&&(r.revision===void 0||typeof r.revision=="string")&&(r.sourceToken===void 0||typeof r.sourceToken=="string"))}function k(t){return t===void 0?!0:i(t)&&["heuristic","provided","font-bytes"].includes(t.textMetrics)&&(t.fontFingerprint===void 0||typeof t.fontFingerprint=="string"&&/^[a-f0-9]{64}$/.test(t.fontFingerprint))}function l(t,r){if(!i(t)||!h(t.stats)||!R(t.diagnostics)||!I(t.revisions)||!k(t.layout)||!a.validPreparedSources(t.sources)||t.diagnosticSummary!==void 0&&!a.matchingDiagnosticSummary(t.diagnosticSummary,t.diagnostics))return!1;if(r==="prepare")return y.validateRenderPlan(t.plan).ok;const e=t.format==="pdf"?"application/pdf":"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";return t.bytes instanceof Uint8Array&&(t.format==="pdf"||t.format==="xlsx")&&t.contentType===e}function m(t){if(!t||typeof t!="object")return{message:String(t).slice(0,4096)};const r={};for(const e of["code","path","field","message"]){const o=t[e];typeof o=="string"&&(r[e]=o.slice(0,e==="code"?128:4096))}return r}function S(t){const r=m(t);if(!i(t))return r;for(const e of["format","severity","kind","nid"])typeof t[e]=="string"&&(r[e]=t[e].slice(0,4096));for(const e of["pageIndex","componentIndex"])Number.isSafeInteger(t[e])&&t[e]>=0&&(r[e]=t[e]);if(p.hasValidDataExplanation(t)&&t.valueState!==void 0&&i(t.target)){r.valueState=t.valueState;const e={};for(const o of["datasetId","field","rowKey","tableId","reportScope"])t.target[o]!==void 0&&(e[o]=t.target[o]);r.target=e}return i(t.extension)&&typeof t.extension.id=="string"&&typeof t.extension.version=="string"&&(r.extension={id:t.extension.id.slice(0,128),version:t.extension.version.slice(0,64)}),Array.isArray(t.componentPath)&&t.componentPath.length<=192&&t.componentPath.every(e=>Number.isSafeInteger(e)&&e>=0)&&(r.componentPath=t.componentPath),r}function f(t,r,e){const o=n.createDiagnosticCollector(n.DEFAULT_DIAGNOSTIC_LIMIT);if(n.validDiagnosticSummary(e))o.merge({...e,entries:e.entries.slice(0,n.DEFAULT_DIAGNOSTIC_LIMIT).map(s=>({code:i(s)&&typeof s.code=="string"?s.code:"unknown",value:s}))});else for(const s of t)o.push({code:i(s)&&typeof s.code=="string"?s.code:"unknown",value:s});const d=o.snapshot();return{...d,entries:d.entries.map(s=>r(s.value))}}function g(t){if(!(t instanceof Error))return{name:"Error",message:String(t).slice(0,8192)};const r=t,e=Array.isArray(r.diagnostics)?f(r.diagnostics,S,r.diagnosticSummary):void 0,o=Array.isArray(r.issues)?f(r.issues,m):void 0;return{name:t.name.slice(0,128),message:t.message.slice(0,8192),...typeof r.code=="string"?{code:r.code.slice(0,128)}:{},...typeof r.path=="string"?{path:r.path.slice(0,4096)}:{},...o?{issues:o.entries,...o.omitted?{issueSummary:o}:{}}:{},...e?{diagnostics:e.entries,...e.omitted||r.diagnosticSummary!==void 0?{diagnosticSummary:e}:{}}:{}}}function b(t){if(!t||typeof t!="object")return!1;const r=t;return r.protocol===c&&typeof r.id=="string"&&(r.operation==="prepare"||r.operation==="export"||r.operation==="exportPrepared")&&!!r.input&&typeof r.input=="object"}async function x(t,r,e){try{const o=r.operation==="prepare"?await t.prepare({...r.input,onEvent:e}):r.operation==="exportPrepared"?await t.exportPrepared({...r.input,onEvent:e}):await t.export({...r.input,onEvent:e});return{protocol:c,id:r.id,result:o}}catch(o){return{protocol:c,id:r.id,error:g(o)}}}function A(t){const r=t.result;return!r||!("bytes"in r)||!(r.bytes.buffer instanceof ArrayBuffer)?[]:[r.bytes.buffer]}function T(t,r){if(!i(t)||typeof t.taskId!="string"||!t.taskId||r.taskId!==void 0&&t.taskId!==r.taskId||t.correlationId!==r.correlationId||t.reportId!==void 0&&(typeof t.reportId!="string"||!("reportIds"in r&&r.reportIds.includes(t.reportId)))||!["query","validate","layout","assets","encode"].includes(t.stage)||!["started","completed","failed"].includes(t.status))return!1;for(const e of["completed","total"])if(t[e]!==void 0&&(typeof t[e]!="number"||!Number.isFinite(t[e])||t[e]<0))return!1;return t.completed===void 0||t.total===void 0||t.completed<=t.total}exports.REPORT_WORKER_PROTOCOL=c;exports.ReportWorkerError=u;exports.isReportWorkerRequest=b;exports.reportWorkerTransferList=A;exports.runReportWorkerRequest=x;exports.serializeError=g;exports.validReportWorkerEvent=T;exports.validReportWorkerResult=l;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const l=require("./diagnostic-collector-D3rlvxm3.cjs"),y=require("./charts-Cjw5AYkg.cjs"),g=require("./computed-DK6BruFz.cjs");function C(e){if(!e||e.kind==="date")return;const t=e.digits;if(!(t!==void 0&&(!Number.isInteger(t)||t<0||t>100))){if(e.kind==="percent"){const r=t??2;return`0${r?`.${"0".repeat(r)}`:""}%`}return t===void 0?e.thousands?"#,##0.###############":void 0:`${e.thousands?"#,##0":"0"}${t?`.${"0".repeat(t)}`:""}`}}function S(e){const t=/^(\d{4})[-/](\d{1,2})[-/](\d{1,2})$/.exec(e.trim());if(t){const i=new Date(Number(t[1]),Number(t[2])-1,Number(t[3]));return Number.isNaN(i.getTime())?null:i}const r=new Date(e);return Number.isNaN(r.getTime())?null:r}function u(e,t){return e.toLocaleString("en-US",{minimumFractionDigits:t,maximumFractionDigits:t})}function x(e,t){const r=i=>String(i).padStart(2,"0");return t.replace(/YYYY/g,String(e.getFullYear())).replace(/MM/g,r(e.getMonth()+1)).replace(/DD/g,r(e.getDate())).replace(/hh/g,r(e.getHours())).replace(/mm/g,r(e.getMinutes())).replace(/ss/g,r(e.getSeconds()))}function F(e,t,r){return r!=null?t?u(e,r):e.toFixed(r):t?u(e):String(e)}function c(e){const t=typeof e=="number"?e:Number(String(e).replace(/,/g,""));return Number.isFinite(t)?t:null}function m(e,t){if(e==null||e===""||!t)return String(e??"");switch(t.kind){case"number":{if(typeof e=="string")try{return g.formatDecimal(e,t.digits,t.thousands===!0)}catch{return e}const r=c(e);return r==null?String(e):F(r,t.thousands===!0,t.digits)}case"percent":{if(typeof e=="string")try{return g.formatDecimal(e,t.digits??2,!0,!0)}catch{return e}const r=c(e);return r==null?String(e):`${u(r*100,t.digits??2)}%`}case"date":{const r=t.pattern??"YYYY-MM-DD",i=e instanceof Date?e:S(String(e));return i?x(i,r):String(e)}default:return String(e)}}function h(e,t){return g.compileReportPredicate(t)(e)}function M(e,t,r,i=e.paddingMm??1){return t.field!==e.tree.labelField?0:Math.min(r.depth*(e.tree.indentMm??3),Math.max(0,t.widthMm-i*2-4))}function L(e,t,r,i){const n=i.tree;(n.input==="nested"||[n.idField,n.parentField].includes(t.field))&&(e.editable=!1),r.hasChildren&&n.parentValues==="leaf-aggregate"&&n.aggregates?.some(a=>a.field===t.field)&&(e.derived=!0,e.editable=!1)}function T(e,t,r){return r==="identifier"||r==="dimension"||r==="date"?"center":r==="measure"?"right":r==="text"?"left":t?.kind==="number"||t?.kind==="percent"?"right":t?.kind==="date"||e instanceof Date||typeof e=="boolean"?"center":typeof e=="number"&&Number.isFinite(e)?"right":"left"}function w(e){if(e==null)return"";if(typeof e=="string"||typeof e=="number")return String(e);if(typeof e=="boolean")return e?"是":"否";if(e instanceof Date)return e.toISOString().slice(0,10);try{return JSON.stringify(e)}catch{return String(e)}}function P(e,t){let r=l.mergeComponentStyles({fontSize:e.fontSizePt??l.DEFAULT_FONT_PT,bold:e.headerBold??!0,align:"center",verticalAlign:"middle",backgroundColor:e.headerBackgroundColor},t.style);return e.headerAlign!==void 0&&(r.align=e.headerAlign),r=l.mergeComponentStyles(r,e.headerStyle),t.headerAlign!==void 0&&(r.align=t.headerAlign),l.mergeComponentStyles(r,t.headerStyle)}function A(e,t,r){(r===null||typeof r=="string"||typeof r=="boolean"||typeof r=="number"&&Number.isFinite(r))&&(e.value=r);const i=t.format?.kind==="number"||t.format?.kind==="percent";t.valueType!==void 0?e.valueType=t.valueType:i&&(e.valueType="number"),t.editable!==void 0&&(e.editable=t.editable);const n=C(t.format);(typeof e.value=="number"||e.value==null)&&n!==void 0&&(e.numberFormat=n)}function N(e,t,r){const i=!!t.visibleWhen&&!h(r,t.visibleWhen),n=i?null:r[t.field],a=t.align??t.style?.align??e.align??"left";let s=l.mergeComponentStyles({fontSize:e.fontSizePt??l.DEFAULT_FONT_PT,verticalAlign:"middle"},t.style);s.align=a==="auto"?T(n,t.format,t.semanticRole):a;const o=t.rules?.find(f=>h(r,f.when));o&&(s=l.mergeComponentStyles(s,o.style));const d={text:t.format?m(n,t.format):w(n),style:s};return A(d,t,n),e.computed?.some(f=>f.field===t.field)&&(d.derived=!0,d.editable=!1),i&&(d.editable=!1),d}function R(e,t,r){const i=N(e,t,r.row),n=M(e,t,r);return t.field===e.tree.labelField&&(i.style={...i.style,align:"left"}),n&&(i.indentMm=n),L(i,t,r,e),i}class I extends Error{constructor(t,r){super(`报表页数超出上限 ${t}(至少 ${r} 页)`),this.limit=t,this.actual=r,this.code="page-limit",this.name="PaginatePageLimitError"}}class O extends Error{constructor(t,r){super(`报表单元格数量超出上限 ${t}(至少 ${r} 格)`),this.limit=t,this.actual=r,this.code="cell-limit",this.name="PaginateCellLimitError"}}class E extends Error{constructor(t,r){super(`报表图表图元数量预计超出上限 ${t}(本次估算 ${r})`),this.limit=t,this.estimated=r,this.code="chart-component-limit",this.name="PaginateChartComponentLimitError"}}const b=5e4;function D(e=b){if(!Number.isSafeInteger(e)||e<1||e>1e6)throw new RangeError("maxChartComponents 应为 1..1000000 的安全整数")}function k(e,t,r){const i=e.chartBinding;if(e.kind!=="chart"||e.grid||e.imageData||e.binding||e.pageAnchor)throw new TypeError("绑定图表不能同时设置图片、网格、记录绑定或页眉页脚");const n=Object.prototype.hasOwnProperty.call(t,i.dataset)?t[i.dataset]:void 0;if(!Array.isArray(n))throw new TypeError(`图表数据集 ${i.dataset} 未提供`);return{...g.createReportChartData(n,i,r),type:i.type,leftMm:e.leftMm,topMm:e.topMm,widthMm:e.widthMm,heightMm:e.heightMm,title:i.title,showValues:i.showValues}}function v(e,t,r=b){D(r);let i=0;return Object.assign(a=>{if(!a.chartBinding)return[a];const s=k(a,e,t),o=i+(s.categories.length?y.chartComponentUpperBound(s):1);if(!Number.isSafeInteger(o))throw new RangeError("图表图元估算应为有限安全整数");if(o>r)throw new E(r,o);const d=s.categories.length?y.createChartComponents(s):[{kind:"text",leftMm:a.leftMm,topMm:a.topMm,widthMm:a.widthMm,heightMm:a.heightMm,text:"—",style:{align:"center",verticalAlign:"middle",color:"#94a3b8",fontSize:10}}];return i+=d.length,d},{used:()=>i})}function B(e){return typeof e=="string"&&/^data:image\/(png|jpe?g);base64,[A-Za-z0-9+/\r\n]+=*$/.test(e)}class p extends Error{constructor(t,r,i,n){super(`${t}: ${r}`),this.path=t,this.rowIndex=i,this.field=n,this.code="report-binding",this.name="ReportBindingError"}}function $(e,t,r={}){const i=r.rowIndex??0,a=`$.datasets.${r.dataset??"label"}[${i}].${t}`,s=Object.getOwnPropertyDescriptor(e,t);if(!s||s.get||s.set)throw new p(a,"字段必须是记录的自有数据字段,不能缺失、使用访问器或从原型继承",i,t);const o=s.value;if(o==null||typeof o=="string"||typeof o=="boolean"||typeof o=="number"&&Number.isFinite(o))return o;throw new p(a,"绑定值应为字符串、有限数字、布尔值或空值",i,t)}function _(e,t,r={}){const i=$(t,e.field,r);return i==null||i===""?e.emptyText??"":`${e.prefix??""}${m(i,e.format)}${e.suffix??""}`}exports.DEFAULT_CHART_COMPONENT_LIMIT=b;exports.PaginateCellLimitError=O;exports.PaginateChartComponentLimitError=E;exports.PaginatePageLimitError=I;exports.ReportBindingError=p;exports.applyListTreeMetadata=L;exports.createChartResolver=v;exports.evalStyleRule=h;exports.formatValue=m;exports.isLabelImageData=B;exports.listCellText=w;exports.listTreeIndent=M;exports.parseDateLocal=S;exports.readRecordScalar=$;exports.resolveComponentBinding=_;exports.resolveListAutoAlignment=T;exports.resolveListHeaderStyle=P;exports.resolveListSampleCell=N;exports.resolveTreeListSampleCell=R;exports.toExcelNumberFormat=C;exports.toNumber=c;exports.validateChartComponentLimit=D;
|
package/dist/runtime-BpSAgOw1.js
DELETED
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
import { E as W, u as G } from "./diagnostic-collector-1sqd7DQP.js";
|
|
2
|
-
import { d as H, m as F, s as O, a as j, g as K, h as Y, i as Z, r as ee } from "./prepared-CVbgO9KR.js";
|
|
3
|
-
import { Q as S, R as h, S as te, N as T, H as k, n as ae, J as se, M as oe, o as re } from "./json-snapshot-BJWZNryO.js";
|
|
4
|
-
import { g as M } from "./report-params-D9tBuM9B.js";
|
|
5
|
-
import { l as _, r as ne, R as ie } from "./param-validation-CnDEd2l-.js";
|
|
6
|
-
import { t as P, b as x, D as ce, v as de, c as B, R as I } from "./sha256-BDQ1Qk7A.js";
|
|
7
|
-
import { b as me } from "./template-registry-BCBF2b8j.js";
|
|
8
|
-
import { T as le } from "./template-serialization-CWmHq7lX.js";
|
|
9
|
-
import { r as A } from "./assets-D0FbszhB.js";
|
|
10
|
-
import { f as ge, P as pe, e as fe } from "./record-bindings-fhav-NLG.js";
|
|
11
|
-
function ue(e) {
|
|
12
|
-
let t = `$.pages.${e.pageIndex}`;
|
|
13
|
-
if (e.componentIndex < 0) return t;
|
|
14
|
-
t += `.components.${e.componentIndex}`;
|
|
15
|
-
const s = e.componentPath ?? [];
|
|
16
|
-
for (let n = 0; n + 1 < s.length; n += 3)
|
|
17
|
-
t += `.grid.cells.${s[n]}.${s[n + 1]}`, s[n + 2] !== void 0 && (t += `.children.${s[n + 2]}`);
|
|
18
|
-
return t;
|
|
19
|
-
}
|
|
20
|
-
function C(e = []) {
|
|
21
|
-
return e.map((t) => ({ ...t, path: ue(t) }));
|
|
22
|
-
}
|
|
23
|
-
function xe(e, t) {
|
|
24
|
-
const s = G(t ?? (e.diagnosticSummary ? W : void 0));
|
|
25
|
-
return e.diagnosticSummary ? s.merge(e.diagnosticSummary) : e.diagnostics.forEach((n) => s.push(n)), s;
|
|
26
|
-
}
|
|
27
|
-
function J(e, t) {
|
|
28
|
-
t.diagnosticSummary ? e.merge({ ...t.diagnosticSummary, entries: C(t.diagnosticSummary.entries) }) : C(t.diagnostics).forEach((s) => e.push(s));
|
|
29
|
-
}
|
|
30
|
-
function we(e) {
|
|
31
|
-
const t = e.prepared.diagnosticSummary?.counts, s = t ? !!(t["asset-render-failed"] || t["asset-budget-exceeded"]) : e.prepared.diagnostics.some((n) => n.code === "asset-render-failed" || n.code === "asset-budget-exceeded");
|
|
32
|
-
if (e.fidelity === "strict" && s) throw new h("validate", "严格输出拒绝已有资产渲染降级,请修复组件后重新准备报表。");
|
|
33
|
-
}
|
|
34
|
-
async function N(e, t, s = Date.now()) {
|
|
35
|
-
const n = e.prepared;
|
|
36
|
-
H(e, t), we(e);
|
|
37
|
-
const a = xe(n, e.diagnosticLimit), o = e.format === "pdf" ? await import("@agile-team/mach-report/pdf") : void 0;
|
|
38
|
-
P(e.signal);
|
|
39
|
-
const m = e.pdf?.customFontFaces ?? (e.pdf?.customFontBytes ? { regular: e.pdf.customFontBytes } : void 0), l = o && m ? o.createFontBytesMeasurer(m) : void 0, d = S(e), i = await d.run("encode", async () => {
|
|
40
|
-
let g;
|
|
41
|
-
const y = { fidelity: e.fidelity, diagnosticLimit: e.diagnosticLimit ?? (n.diagnosticSummary ? W : void 0), signal: e.signal, onProgress: (r, f) => d.progress("encode", r, f) };
|
|
42
|
-
if (e.format === "pdf") {
|
|
43
|
-
P(e.signal);
|
|
44
|
-
const r = await o.renderPlanToPdf(n.plan, { ...e.pdf, ...l ? { measurer: l } : {}, ...y });
|
|
45
|
-
g = r.bytes, J(a, r), F(a, "pdf-fidelity", r.fidelityWarnings, "warning", r.fidelityWarningCount), F(a, "pdf-page", r.pageErrors, "error", r.pageErrorCount), r.unsupportedTextCount && a.push({ code: "pdf-font", message: `${r.unsupportedTextCount} 段文本包含当前字体不支持的字符`, severity: "warning" });
|
|
46
|
-
} else {
|
|
47
|
-
const { renderPlanToXlsx: r } = await import("@agile-team/mach-report/xlsx");
|
|
48
|
-
P(e.signal);
|
|
49
|
-
const f = await r(n.plan, { ...e.xlsx, ...y });
|
|
50
|
-
g = new Uint8Array(f.buffer), J(a, f), F(a, "xlsx-fidelity", f.warnings, "warning", f.warningCount), f.notes?.forEach((R) => a.push({ code: "xlsx-snapshot", message: R, severity: "info" }));
|
|
51
|
-
}
|
|
52
|
-
return P(e.signal), g;
|
|
53
|
-
});
|
|
54
|
-
x(t, "maxOutputBytes", i.byteLength);
|
|
55
|
-
const { plan: w, ...u } = n;
|
|
56
|
-
return {
|
|
57
|
-
...u,
|
|
58
|
-
diagnostics: a.entries,
|
|
59
|
-
...e.diagnosticLimit === void 0 && !n.diagnosticSummary ? {} : { diagnosticSummary: a.snapshot() },
|
|
60
|
-
bytes: i,
|
|
61
|
-
format: e.format,
|
|
62
|
-
contentType: e.format === "pdf" ? "application/pdf" : "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
63
|
-
stats: { ...u.stats, durationMs: Date.now() - s, outputBytes: i.byteLength }
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
function U(e) {
|
|
67
|
-
return { ...e, reportIds: [...e.reportIds], ...e.params ? { params: { ...e.params } } : {} };
|
|
68
|
-
}
|
|
69
|
-
function Q(e, t) {
|
|
70
|
-
if (t.length === 0) throw new h("config", "缺少报表 ID");
|
|
71
|
-
return t.map((s) => {
|
|
72
|
-
if (!Object.prototype.hasOwnProperty.call(e, s)) throw new h("config", `未注册报表 ${s}`);
|
|
73
|
-
return e[s];
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
function L(e) {
|
|
77
|
-
return e.grid?.cells.reduce((t, s) => t + s.reduce((n, a) => n + (a ? 1 + (a.children?.reduce((o, m) => o + L(m), 0) ?? 0) : 0), 0), 0) ?? 0;
|
|
78
|
-
}
|
|
79
|
-
function ye(e, t, s) {
|
|
80
|
-
return e.pages.reduce((n, a) => n + a.components.reduce((o, m) => m.kind !== "list" ? o + L(m) : o + re(m, t, s), 0), 0);
|
|
81
|
-
}
|
|
82
|
-
function he(e, t = Object.keys(e)) {
|
|
83
|
-
return Q(e, t).map((s, n) => {
|
|
84
|
-
const a = t[n], o = M(e, [a]);
|
|
85
|
-
return {
|
|
86
|
-
id: a,
|
|
87
|
-
params: JSON.parse(JSON.stringify(o)),
|
|
88
|
-
paramsSchema: ne(o),
|
|
89
|
-
datasetsSchema: Object.fromEntries(Object.entries(s.dataSchema ?? {}).map(([m, l]) => [m, te(typeof s.template == "function" ? void 0 : s.template, m, l)])),
|
|
90
|
-
capabilities: {
|
|
91
|
-
save: !!s.provider?.save,
|
|
92
|
-
export: !!s.provider?.export,
|
|
93
|
-
templates: !!s.provider?.templates
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
function X(e, t) {
|
|
99
|
-
Q(e, t.reportIds);
|
|
100
|
-
const s = _(M(e, t.reportIds), t.params), n = t.reportIds.flatMap((o) => _(M(e, [o]), t.params).issues), a = new Map(n.map((o) => [JSON.stringify(o), o]));
|
|
101
|
-
return { ...s, ok: a.size === 0, issues: [...a.values()] };
|
|
102
|
-
}
|
|
103
|
-
function V(e, t) {
|
|
104
|
-
const s = me(e.plan);
|
|
105
|
-
if (!s.ok) throw new h("validate", `执行器返回无效计划:${s.errors[0]?.path}`);
|
|
106
|
-
const n = e.plan.pages.length, a = e.plan.pages.reduce((o, m) => o + m.components.reduce((l, d) => l + L(d), 0), 0);
|
|
107
|
-
return x(t, "maxRows", e.stats.rows), x(t, "maxPages", n), x(t, "maxCells", a), { ...e, stats: { ...e.stats, pages: n, cells: a } };
|
|
108
|
-
}
|
|
109
|
-
function q(e, t) {
|
|
110
|
-
const s = X(e.reports, t);
|
|
111
|
-
if (!s.ok) throw new ie(s.issues);
|
|
112
|
-
}
|
|
113
|
-
function Fe(e) {
|
|
114
|
-
const t = { ...ce, ...e.budget };
|
|
115
|
-
de(t);
|
|
116
|
-
const s = async (a, o) => {
|
|
117
|
-
const m = Date.now();
|
|
118
|
-
let l = 0, d = 0;
|
|
119
|
-
const i = G(a.diagnosticLimit), w = {}, u = [], g = Object.fromEntries(Object.entries(e.reports).map(([c, p]) => [c, {
|
|
120
|
-
...p,
|
|
121
|
-
pagination: { ...e.pagination, ...p.pagination, ...o ? { measurer: o } : {} },
|
|
122
|
-
dataValidation: {
|
|
123
|
-
...p.dataValidation,
|
|
124
|
-
maxRows: Math.min(t.maxRows ?? 1e5, p.dataValidation?.maxRows ?? 1 / 0),
|
|
125
|
-
maxCells: Math.min(t.maxCells ?? 2e6, p.dataValidation?.maxCells ?? 1 / 0)
|
|
126
|
-
}
|
|
127
|
-
}])), r = await ae(g, { maxPages: t.maxPages, maxCells: t.maxCells, maxChartComponents: t.maxChartComponents, onDatasets: (c, p, v) => {
|
|
128
|
-
try {
|
|
129
|
-
l += se(v, p, { maxRows: t.maxRows, signal: a.signal });
|
|
130
|
-
} catch (b) {
|
|
131
|
-
throw b instanceof le ? new I("budget", b.message, "$.budget.maxRows") : b;
|
|
132
|
-
}
|
|
133
|
-
x(t, "maxRows", l), d += ye(v, p, g[c]?.pagination), x(t, "maxCells", d);
|
|
134
|
-
} })({ ...a, params: a.params ?? {}, onWarning: (c) => i.push({ code: "layout", message: c, severity: "warning" }), onQueryResult: (c, p, v = 0) => {
|
|
135
|
-
const b = oe(v, c);
|
|
136
|
-
Object.defineProperty(w, c, { value: { revision: p.revision, sourceToken: p.sourceToken }, enumerable: !0, writable: !0 }), u.push({ reportId: c, reportIndex: v, reportScope: b, ...p.revision === void 0 ? {} : { revision: p.revision }, ...p.sourceToken === void 0 ? {} : { sourceToken: p.sourceToken } }), (p.diagnostics ?? []).forEach((E) => i.push({ ...E, ...E.target ? { target: {
|
|
137
|
-
...E.target,
|
|
138
|
-
reportScope: b,
|
|
139
|
-
...E.target.tableId ? { tableId: JSON.stringify([v, c, E.target.tableId]) } : {}
|
|
140
|
-
} } : {} }));
|
|
141
|
-
} }).catch((c) => {
|
|
142
|
-
throw c instanceof h && c.cause instanceof ge ? new I("budget", c.cause.message, "$.budget.maxPages") : c instanceof h && c.cause instanceof pe ? new I("budget", c.cause.message, "$.budget.maxCells") : c instanceof h && c.cause instanceof fe ? new I("budget", c.cause.message, "$.budget.maxChartComponents") : c;
|
|
143
|
-
});
|
|
144
|
-
P(a.signal);
|
|
145
|
-
const f = e.assets ? await S(a).run("assets", () => A(r, { ...e.assets, diagnosticLimit: a.diagnosticLimit, signal: a.signal })) : { plan: r, diagnostics: [] }, R = f.plan;
|
|
146
|
-
f.diagnosticSummary ? i.merge({ ...f.diagnosticSummary, entries: C(f.diagnosticSummary.entries) }) : C(f.diagnostics).forEach((c) => i.push(c));
|
|
147
|
-
const $ = R.pages.reduce((c, p) => c + p.components.reduce((v, b) => v + L(b), 0), 0);
|
|
148
|
-
x(t, "maxPages", R.pages.length), x(t, "maxCells", $);
|
|
149
|
-
const D = ee(a.pdf), z = e.pagination?.measurer || Object.values(e.reports).some((c) => c.pagination?.measurer);
|
|
150
|
-
return { plan: R, diagnostics: i.entries, ...a.diagnosticLimit === void 0 ? {} : { diagnosticSummary: i.snapshot() }, revisions: w, sources: u, layout: { textMetrics: D ? "font-bytes" : z ? "provided" : "heuristic", ...D ? { fontFingerprint: D } : {} }, stats: { rows: l, pages: R.pages.length, cells: $, durationMs: Date.now() - m } };
|
|
151
|
-
}, n = async (a) => {
|
|
152
|
-
const o = Date.now();
|
|
153
|
-
if (a.format !== "pdf" && a.format !== "xlsx") throw new h("config", "不支持的报表导出格式");
|
|
154
|
-
const m = a.format === "pdf" ? await import("@agile-team/mach-report/pdf") : void 0;
|
|
155
|
-
P(a.signal);
|
|
156
|
-
const l = a.pdf?.customFontFaces ?? (a.pdf?.customFontBytes ? { regular: a.pdf.customFontBytes } : void 0), d = m && l ? m.createFontBytesMeasurer(l) : void 0, i = await s(a, d);
|
|
157
|
-
return P(a.signal), N({ ...a, prepared: i }, t, o);
|
|
158
|
-
};
|
|
159
|
-
return {
|
|
160
|
-
describe: (a) => he(e.reports, a),
|
|
161
|
-
validate: (a) => X(e.reports, a),
|
|
162
|
-
prepare: (a) => B(a.signal, t.maxDurationMs, async (o) => {
|
|
163
|
-
const { signal: m, onEvent: l, ...d } = U(a), i = { ...d, ...d.pdf ? { pdf: O(d.pdf) } : {}, taskId: d.taskId ?? T() }, w = l ? (f) => k(l, f, o) : void 0, u = { ...i, signal: o, onEvent: w };
|
|
164
|
-
S(u).runSync("validate", () => q(e, i));
|
|
165
|
-
let g;
|
|
166
|
-
const y = i.pdf?.customFontFaces ?? (i.pdf?.customFontBytes ? { regular: i.pdf.customFontBytes } : void 0);
|
|
167
|
-
if (!e.executor && y) {
|
|
168
|
-
const f = await import("@agile-team/mach-report/pdf");
|
|
169
|
-
P(o), g = f.createFontBytesMeasurer(y);
|
|
170
|
-
}
|
|
171
|
-
const r = e.executor ? await e.executor.prepare(i, o, w) : await s(u, g);
|
|
172
|
-
return V(r, t);
|
|
173
|
-
}),
|
|
174
|
-
exportPrepared: (a) => B(a.signal, t.maxDurationMs, async (o) => {
|
|
175
|
-
const m = Date.now(), { signal: l, onEvent: d, ...i } = a, w = V(K(a.prepared, t.maxPreparedBytes ?? 64e6, o), t), u = { ...i, xlsx: j(i.xlsx), prepared: w, ...i.pdf ? { pdf: O(i.pdf) } : {}, taskId: i.taskId ?? T() };
|
|
176
|
-
if (u.format !== "pdf" && u.format !== "xlsx") throw new h("config", "不支持的报表导出格式");
|
|
177
|
-
const g = d ? (r) => k(d, r, o) : void 0;
|
|
178
|
-
if (e.executor) {
|
|
179
|
-
if (!e.executor.exportPrepared) throw new h("config", "执行器未实现 exportPrepared;请升级执行器或显式使用本地运行时");
|
|
180
|
-
const r = await e.executor.exportPrepared(u, o, g);
|
|
181
|
-
return x(t, "maxRows", r.stats.rows), x(t, "maxPages", r.stats.pages), x(t, "maxCells", r.stats.cells), x(t, "maxOutputBytes", r.bytes.byteLength), { ...r, stats: { ...r.stats, outputBytes: r.bytes.byteLength } };
|
|
182
|
-
}
|
|
183
|
-
const y = { ...u, signal: o, onEvent: g };
|
|
184
|
-
if (S(y).runSync("validate", () => Y(y)), e.assets) {
|
|
185
|
-
const r = await S(y).run("assets", () => A(w.plan, { ...e.assets, diagnosticLimit: a.diagnosticLimit, signal: o }));
|
|
186
|
-
w.plan = r.plan, Z(w, C(r.diagnostics), r.diagnosticSummary ? { ...r.diagnosticSummary, entries: C(r.diagnosticSummary.entries) } : void 0, a.diagnosticLimit);
|
|
187
|
-
}
|
|
188
|
-
return N(y, t, m);
|
|
189
|
-
}),
|
|
190
|
-
export: (a) => B(a.signal, t.maxDurationMs, async (o) => {
|
|
191
|
-
const { signal: m, onEvent: l, ...d } = U(a), i = { ...d, xlsx: j(d.xlsx), ...d.pdf ? { pdf: O(d.pdf) } : {}, taskId: d.taskId ?? T() }, w = l ? (y) => k(l, y, o) : void 0, u = { ...i, signal: o, onEvent: w };
|
|
192
|
-
if (S(u).runSync("validate", () => q(e, i)), i.format !== "pdf" && i.format !== "xlsx") throw new h("config", "不支持的报表导出格式");
|
|
193
|
-
const g = e.executor ? await e.executor.export(i, o, w) : await n(u);
|
|
194
|
-
return x(t, "maxRows", g.stats.rows), x(t, "maxPages", g.stats.pages), x(t, "maxCells", g.stats.cells), x(t, "maxOutputBytes", g.bytes.byteLength), { ...g, stats: { ...g.stats, outputBytes: g.bytes.byteLength } };
|
|
195
|
-
})
|
|
196
|
-
};
|
|
197
|
-
}
|
|
198
|
-
export {
|
|
199
|
-
Fe as c,
|
|
200
|
-
V as e
|
|
201
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var V=Object.create;var M=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var W=Object.getOwnPropertyNames;var X=Object.getPrototypeOf,z=Object.prototype.hasOwnProperty;var Q=(e,t,a,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of W(t))!z.call(e,s)&&s!==a&&M(e,s,{get:()=>t[s],enumerable:!(o=G(t,s))||o.enumerable});return e};var I=(e,t,a)=>(a=e!=null?V(X(e)):{},Q(t||!e||!e.__esModule?M(a,"default",{value:e,enumerable:!0}):a,e));const B=require("./diagnostic-collector-D3rlvxm3.cjs"),v=require("./prepared-DAwe8Il2.cjs"),d=require("./json-snapshot-C7QZrRBf.cjs"),L=require("./report-params-VTg8MoCp.cjs"),C=require("./param-validation-C-8sRJLq.cjs"),i=require("./sha256-DgZAKXqI.cjs"),H=require("./template-registry-Bnh5aEYf.cjs"),K=require("./template-serialization-CqQY4zDg.cjs"),A=require("./assets-B4AJIOTB.cjs"),k=require("./record-bindings-CAyM5tGg.cjs");function Y(e){let t=`$.pages.${e.pageIndex}`;if(e.componentIndex<0)return t;t+=`.components.${e.componentIndex}`;const a=e.componentPath??[];for(let o=0;o+1<a.length;o+=3)t+=`.grid.cells.${a[o]}.${a[o+1]}`,a[o+2]!==void 0&&(t+=`.children.${a[o+2]}`);return t}function S(e=[]){return e.map(t=>({...t,path:Y(t)}))}function Z(e,t){const a=B.createDiagnosticCollector(t??(e.diagnosticSummary?B.DEFAULT_DIAGNOSTIC_LIMIT:void 0));return e.diagnosticSummary?a.merge(e.diagnosticSummary):e.diagnostics.forEach(o=>a.push(o)),a}function $(e,t){t.diagnosticSummary?e.merge({...t.diagnosticSummary,entries:S(t.diagnosticSummary.entries)}):S(t.diagnostics).forEach(a=>e.push(a))}function ee(e){const t=e.prepared.diagnosticSummary?.counts,a=t?!!(t["asset-render-failed"]||t["asset-budget-exceeded"]):e.prepared.diagnostics.some(o=>o.code==="asset-render-failed"||o.code==="asset-budget-exceeded");if(e.fidelity==="strict"&&a)throw new d.ReportSourceError("validate","严格输出拒绝已有资产渲染降级,请修复组件后重新准备报表。")}async function q(e,t,a=Date.now()){const o=e.prepared;v.assertPreparedOutputBudget(e,t),ee(e);const s=Z(o,e.diagnosticLimit),r=e.format==="pdf"?await import("@agile-team/mach-report/pdf"):void 0;i.throwIfAborted(e.signal);const g=e.pdf?.customFontFaces??(e.pdf?.customFontBytes?{regular:e.pdf.customFontBytes}:void 0),l=r&&g?r.createFontBytesMeasurer(g):void 0,m=d.createReportTaskReporter(e),c=await m.run("encode",async()=>{let u;const y={fidelity:e.fidelity,diagnosticLimit:e.diagnosticLimit??(o.diagnosticSummary?B.DEFAULT_DIAGNOSTIC_LIMIT:void 0),signal:e.signal,onProgress:(n,x)=>m.progress("encode",n,x)};if(e.format==="pdf"){i.throwIfAborted(e.signal);const n=await r.renderPlanToPdf(o.plan,{...e.pdf,...l?{measurer:l}:{},...y});u=n.bytes,$(s,n),v.mergeDiagnosticMessages(s,"pdf-fidelity",n.fidelityWarnings,"warning",n.fidelityWarningCount),v.mergeDiagnosticMessages(s,"pdf-page",n.pageErrors,"error",n.pageErrorCount),n.unsupportedTextCount&&s.push({code:"pdf-font",message:`${n.unsupportedTextCount} 段文本包含当前字体不支持的字符`,severity:"warning"})}else{const{renderPlanToXlsx:n}=await import("@agile-team/mach-report/xlsx");i.throwIfAborted(e.signal);const x=await n(o.plan,{...e.xlsx,...y});u=new Uint8Array(x.buffer),$(s,x),v.mergeDiagnosticMessages(s,"xlsx-fidelity",x.warnings,"warning",x.warningCount),x.notes?.forEach(P=>s.push({code:"xlsx-snapshot",message:P,severity:"info"}))}return i.throwIfAborted(e.signal),u});i.assertBudget(t,"maxOutputBytes",c.byteLength);const{plan:h,...w}=o;return{...w,diagnostics:s.entries,...e.diagnosticLimit===void 0&&!o.diagnosticSummary?{}:{diagnosticSummary:s.snapshot()},bytes:c,format:e.format,contentType:e.format==="pdf"?"application/pdf":"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",stats:{...w.stats,durationMs:Date.now()-a,outputBytes:c.byteLength}}}function _(e){return{...e,reportIds:[...e.reportIds],...e.params?{params:{...e.params}}:{}}}function N(e,t){if(t.length===0)throw new d.ReportSourceError("config","缺少报表 ID");return t.map(a=>{if(!Object.prototype.hasOwnProperty.call(e,a))throw new d.ReportSourceError("config",`未注册报表 ${a}`);return e[a]})}function T(e){return e.grid?.cells.reduce((t,a)=>t+a.reduce((o,s)=>o+(s?1+(s.children?.reduce((r,g)=>r+T(g),0)??0):0),0),0)??0}function te(e,t,a){return e.pages.reduce((o,s)=>o+s.components.reduce((r,g)=>g.kind!=="list"?r+T(g):r+d.estimateListLayoutCells(g,t,a),0),0)}function se(e,t=Object.keys(e)){return N(e,t).map((a,o)=>{const s=t[o],r=L.getReportParamDefs(e,[s]);return{id:s,params:JSON.parse(JSON.stringify(r)),paramsSchema:C.reportParamsJsonSchema(r),datasetsSchema:Object.fromEntries(Object.entries(a.dataSchema??{}).map(([g,l])=>[g,d.templateDatasetJsonSchema(typeof a.template=="function"?void 0:a.template,g,l)])),capabilities:{save:!!a.provider?.save,export:!!a.provider?.export,templates:!!a.provider?.templates}}})}function J(e,t){N(e,t.reportIds);const a=C.validateReportParams(L.getReportParamDefs(e,t.reportIds),t.params),o=t.reportIds.flatMap(r=>C.validateReportParams(L.getReportParamDefs(e,[r]),t.params).issues),s=new Map(o.map(r=>[JSON.stringify(r),r]));return{...a,ok:s.size===0,issues:[...s.values()]}}function F(e,t){const a=H.validateRenderPlan(e.plan);if(!a.ok)throw new d.ReportSourceError("validate",`执行器返回无效计划:${a.errors[0]?.path}`);const o=e.plan.pages.length,s=e.plan.pages.reduce((r,g)=>r+g.components.reduce((l,m)=>l+T(m),0),0);return i.assertBudget(t,"maxRows",e.stats.rows),i.assertBudget(t,"maxPages",o),i.assertBudget(t,"maxCells",s),{...e,stats:{...e.stats,pages:o,cells:s}}}function j(e,t){const a=J(e.reports,t);if(!a.ok)throw new C.ReportParamValidationError(a.issues)}function ae(e){const t={...i.DEFAULT_REPORT_RUNTIME_BUDGET,...e.budget};i.validateBudget(t);const a=async(s,r)=>{const g=Date.now();let l=0,m=0;const c=B.createDiagnosticCollector(s.diagnosticLimit),h={},w=[],u=Object.fromEntries(Object.entries(e.reports).map(([p,f])=>[p,{...f,pagination:{...e.pagination,...f.pagination,...r?{measurer:r}:{}},dataValidation:{...f.dataValidation,maxRows:Math.min(t.maxRows??1e5,f.dataValidation?.maxRows??1/0),maxCells:Math.min(t.maxCells??2e6,f.dataValidation?.maxCells??1/0)}}])),n=await d.createReportSource(u,{maxPages:t.maxPages,maxCells:t.maxCells,maxChartComponents:t.maxChartComponents,onDatasets:(p,f,R)=>{try{l+=d.templateDatasetRowCount(R,f,{maxRows:t.maxRows,signal:s.signal})}catch(b){throw b instanceof K.TreeRowLimitError?new i.ReportRuntimeError("budget",b.message,"$.budget.maxRows"):b}i.assertBudget(t,"maxRows",l),m+=te(R,f,u[p]?.pagination),i.assertBudget(t,"maxCells",m)}})({...s,params:s.params??{},onWarning:p=>c.push({code:"layout",message:p,severity:"warning"}),onQueryResult:(p,f,R=0)=>{const b=d.reportOccurrenceScope(R,p);Object.defineProperty(h,p,{value:{revision:f.revision,sourceToken:f.sourceToken},enumerable:!0,writable:!0}),w.push({reportId:p,reportIndex:R,reportScope:b,...f.revision===void 0?{}:{revision:f.revision},...f.sourceToken===void 0?{}:{sourceToken:f.sourceToken}}),(f.diagnostics??[]).forEach(E=>c.push({...E,...E.target?{target:{...E.target,reportScope:b,...E.target.tableId?{tableId:JSON.stringify([R,p,E.target.tableId])}:{}}}:{}}))}}).catch(p=>{throw p instanceof d.ReportSourceError&&p.cause instanceof k.PaginatePageLimitError?new i.ReportRuntimeError("budget",p.cause.message,"$.budget.maxPages"):p instanceof d.ReportSourceError&&p.cause instanceof k.PaginateCellLimitError?new i.ReportRuntimeError("budget",p.cause.message,"$.budget.maxCells"):p instanceof d.ReportSourceError&&p.cause instanceof k.PaginateChartComponentLimitError?new i.ReportRuntimeError("budget",p.cause.message,"$.budget.maxChartComponents"):p});i.throwIfAborted(s.signal);const x=e.assets?await d.createReportTaskReporter(s).run("assets",()=>A.resolvePlanAssets(n,{...e.assets,diagnosticLimit:s.diagnosticLimit,signal:s.signal})):{plan:n,diagnostics:[]},P=x.plan;x.diagnosticSummary?c.merge({...x.diagnosticSummary,entries:S(x.diagnosticSummary.entries)}):S(x.diagnostics).forEach(p=>c.push(p));const O=P.pages.reduce((p,f)=>p+f.components.reduce((R,b)=>R+T(b),0),0);i.assertBudget(t,"maxPages",P.pages.length),i.assertBudget(t,"maxCells",O);const D=v.reportFontFingerprint(s.pdf),U=e.pagination?.measurer||Object.values(e.reports).some(p=>p.pagination?.measurer);return{plan:P,diagnostics:c.entries,...s.diagnosticLimit===void 0?{}:{diagnosticSummary:c.snapshot()},revisions:h,sources:w,layout:{textMetrics:D?"font-bytes":U?"provided":"heuristic",...D?{fontFingerprint:D}:{}},stats:{rows:l,pages:P.pages.length,cells:O,durationMs:Date.now()-g}}},o=async s=>{const r=Date.now();if(s.format!=="pdf"&&s.format!=="xlsx")throw new d.ReportSourceError("config","不支持的报表导出格式");const g=s.format==="pdf"?await import("@agile-team/mach-report/pdf"):void 0;i.throwIfAborted(s.signal);const l=s.pdf?.customFontFaces??(s.pdf?.customFontBytes?{regular:s.pdf.customFontBytes}:void 0),m=g&&l?g.createFontBytesMeasurer(l):void 0,c=await a(s,m);return i.throwIfAborted(s.signal),q({...s,prepared:c},t,r)};return{describe:s=>se(e.reports,s),validate:s=>J(e.reports,s),prepare:s=>i.controlled(s.signal,t.maxDurationMs,async r=>{const{signal:g,onEvent:l,...m}=_(s),c={...m,...m.pdf?{pdf:v.snapshotPdfFonts(m.pdf)}:{},taskId:m.taskId??d.reportTaskId()},h=l?x=>d.notifyReportTaskEvent(l,x,r):void 0,w={...c,signal:r,onEvent:h};d.createReportTaskReporter(w).runSync("validate",()=>j(e,c));let u;const y=c.pdf?.customFontFaces??(c.pdf?.customFontBytes?{regular:c.pdf.customFontBytes}:void 0);if(!e.executor&&y){const x=await import("@agile-team/mach-report/pdf");i.throwIfAborted(r),u=x.createFontBytesMeasurer(y)}const n=e.executor?await e.executor.prepare(c,r,h):await a(w,u);return F(n,t)}),exportPrepared:s=>i.controlled(s.signal,t.maxDurationMs,async r=>{const g=Date.now(),{signal:l,onEvent:m,...c}=s,h=F(v.snapshotPreparedReport(s.prepared,t.maxPreparedBytes??64e6,r),t),w={...c,xlsx:v.snapshotXlsxOptions(c.xlsx),prepared:h,...c.pdf?{pdf:v.snapshotPdfFonts(c.pdf)}:{},taskId:c.taskId??d.reportTaskId()};if(w.format!=="pdf"&&w.format!=="xlsx")throw new d.ReportSourceError("config","不支持的报表导出格式");const u=m?n=>d.notifyReportTaskEvent(m,n,r):void 0;if(e.executor){if(!e.executor.exportPrepared)throw new d.ReportSourceError("config","执行器未实现 exportPrepared;请升级执行器或显式使用本地运行时");const n=await e.executor.exportPrepared(w,r,u);return i.assertBudget(t,"maxRows",n.stats.rows),i.assertBudget(t,"maxPages",n.stats.pages),i.assertBudget(t,"maxCells",n.stats.cells),i.assertBudget(t,"maxOutputBytes",n.bytes.byteLength),{...n,stats:{...n.stats,outputBytes:n.bytes.byteLength}}}const y={...w,signal:r,onEvent:u};if(d.createReportTaskReporter(y).runSync("validate",()=>v.checkPreparedFont(y)),e.assets){const n=await d.createReportTaskReporter(y).run("assets",()=>A.resolvePlanAssets(h.plan,{...e.assets,diagnosticLimit:s.diagnosticLimit,signal:r}));h.plan=n.plan,v.appendPreparedDiagnostics(h,S(n.diagnostics),n.diagnosticSummary?{...n.diagnosticSummary,entries:S(n.diagnosticSummary.entries)}:void 0,s.diagnosticLimit)}return q(y,t,g)}),export:s=>i.controlled(s.signal,t.maxDurationMs,async r=>{const{signal:g,onEvent:l,...m}=_(s),c={...m,xlsx:v.snapshotXlsxOptions(m.xlsx),...m.pdf?{pdf:v.snapshotPdfFonts(m.pdf)}:{},taskId:m.taskId??d.reportTaskId()},h=l?y=>d.notifyReportTaskEvent(l,y,r):void 0,w={...c,signal:r,onEvent:h};if(d.createReportTaskReporter(w).runSync("validate",()=>j(e,c)),c.format!=="pdf"&&c.format!=="xlsx")throw new d.ReportSourceError("config","不支持的报表导出格式");const u=e.executor?await e.executor.export(c,r,h):await o(w);return i.assertBudget(t,"maxRows",u.stats.rows),i.assertBudget(t,"maxPages",u.stats.pages),i.assertBudget(t,"maxCells",u.stats.cells),i.assertBudget(t,"maxOutputBytes",u.bytes.byteLength),{...u,stats:{...u.stats,outputBytes:u.bytes.byteLength}}})}}exports.createReportRuntime=ae;exports.enforcePrepared=F;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const P=require("./computed-DK6BruFz.cjs"),re=require("./matrix-B8QWbsGM.cjs"),k=require("./diagnostic-collector-D3rlvxm3.cjs"),fe=require("./code-options-BUTChiZZ.cjs"),G=require("./param-validation-C-8sRJLq.cjs"),w=require("./template-serialization-CqQY4zDg.cjs");function de(e,i,t){e!==void 0&&(typeof e!="string"||!e.trim()||e.length>4096)&&t.push({path:i,message:"来源范围应为不超过 4096 字符的非空字符串"})}function U(e,i,t){e.editable!==void 0&&typeof e.editable!="boolean"&&t.push({path:`${i}.editable`,message:"编辑控制应为布尔值"}),e.valueType!==void 0&&!["text","number","boolean"].includes(e.valueType)&&t.push({path:`${i}.valueType`,message:"编辑类型应为 text、number 或 boolean"})}function ce(e,i,t){U(e,i,t),e.indentMm!==void 0&&(typeof e.indentMm!="number"||!Number.isFinite(e.indentMm)||e.indentMm<0)&&t.push({path:`${i}.indentMm`,message:"单元格缩进应为有限非负数"}),e.derived!==void 0&&typeof e.derived!="boolean"&&t.push({path:`${i}.derived`,message:"派生结果标记应为布尔值"}),z(e.source,`${i}.source`,t,!0),e.formula!==void 0&&typeof e.formula!="string"&&t.push({path:`${i}.formula`,message:"单元格公式应为字符串"})}function z(e,i,t,s=!1){if(e===void 0)return;if(!e||typeof e!="object"||Array.isArray(e)){t.push({path:i,message:"业务来源应为对象"});return}const n=e;de(n.sourceScope,`${i}.sourceScope`,t);for(const a of["datasetId",...s?["field"]:[]])(typeof n[a]!="string"||!n[a].trim())&&t.push({path:`${i}.${a}`,message:"业务标识应为非空字符串"});for(const a of["rowKey","revision"]){const o=n[a];o===void 0&&!(s&&a==="rowKey")||typeof o!="string"&&!(typeof o=="number"&&Number.isFinite(o))&&t.push({path:`${i}.${a}`,message:"业务键及修订号应为字符串或有限数字"})}n.sourceToken!==void 0&&typeof n.sourceToken!="string"&&t.push({path:`${i}.sourceToken`,message:"来源令牌应为字符串"})}const ue=new Set(["text","image","barcode","qrcode","chart","line","rect","ellipse"]);function p(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function R(e){return e===null?"null":typeof e=="string"?JSON.stringify(e.slice(0,120)):["number","boolean","undefined"].includes(typeof e)?String(e):`[${typeof e}]`}function he(e,i,t,s){const n=e[i];(typeof n!="number"||!Number.isFinite(n))&&s.push({path:`${t}.${i}`,message:`应为有限数字,实际 ${R(n)}`})}function me(e,i,t){if(e!==void 0){const s=`${i}.table`;if(!p(e))t.push({path:s,message:"逻辑表来源应为对象"});else{z(e.source,`${s}.source`,t),(typeof e.id!="string"||!e.id.trim())&&t.push({path:`${s}.id`,message:"逻辑表 ID 应为非空字符串"});const n=e.role;["header","body","group-header","subtotal","grand-total"].includes(n)||t.push({path:`${s}.role`,message:"未知逻辑表行角色"});const a=e.rowIndex;(typeof a!="number"||!Number.isInteger(a)||(n==="header"?a!==-1:a<0))&&t.push({path:`${s}.rowIndex`,message:"表头索引应为 -1,内容行索引应为非负整数"}),(!Array.isArray(e.columnKeys)||e.columnKeys.some(o=>typeof o!="string"))&&t.push({path:`${s}.columnKeys`,message:"逻辑列字段应为字符串数组"}),e.layout!==void 0&&e.layout!=="page"&&e.layout!=="wide"&&t.push({path:`${s}.layout`,message:"布局应为 page 或 wide"}),e.title!==void 0&&typeof e.title!="string"&&t.push({path:`${s}.title`,message:"逻辑表名称应为字符串"})}}}function ge(e,i,t,s){if(e!==void 0)if(!p(e)||!Array.isArray(e.cells))t.push({path:`${i}.grid.cells`,message:"grid.cells 应为二维数组"});else{const n=e.paddingMm;n!==void 0&&(typeof n!="number"||!Number.isFinite(n)||n<0)&&t.push({path:`${i}.grid.paddingMm`,message:"单元格内距应为有限非负数"}),e.cells.forEach((a,o)=>{if(!Array.isArray(a)){t.push({path:`${i}.grid.cells.${o}`,message:"行应为数组"});return}a.forEach((r,f)=>{if(r==null)return;const d=`${i}.grid.cells.${o}.${f}`;if(!p(r)){t.push({path:d,message:"网格单元格应为对象或 null"});return}ce(r,d,t),r.dataBar!==void 0&&!k.validDataBar(r.dataBar)&&t.push({path:`${d}.dataBar`,message:"数据条应包含 0–1 有序比例与 #RRGGBB 颜色"}),q(r.richParagraphs,d,t),Array.isArray(r.children)&&r.children.forEach((c,m)=>{B(c,`${i}.grid.cells.${o}.${f}.children.${m}`,t,s)})})})}}function T(e,i,t,s){e!==void 0&&!i.includes(e)&&s.push({path:t,message:"未知富文本属性值"})}function O(e,i,t,s,n=0){for(const a of i){const o=e[a];o!==void 0&&(typeof o!="number"||!Number.isFinite(o)||o<n)&&s.push({path:`${t}.${a}`,message:"富文本数值应为范围内有限数字"})}}function pe(e,i,t){if(e!==void 0){if(!p(e)){t.push({path:i,message:"富文本样式应为对象"});return}for(const s of["fontFamily","color","backgroundColor","lineColor","borderColor"])e[s]!==void 0&&typeof e[s]!="string"&&t.push({path:`${i}.${s}`,message:"富文本样式应为字符串"});for(const s of["bold","italic","underline","borderTop","borderRight","borderBottom","borderLeft"])e[s]!==void 0&&typeof e[s]!="boolean"&&t.push({path:`${i}.${s}`,message:"富文本样式应为布尔值"});O(e,["fontSize","fontSizePx","lineWidthPt","lineHeight","opacity"],i,t),O(e,["letterSpacing","rotateDeg"],i,t,-1/0),typeof e.opacity=="number"&&e.opacity>1&&t.push({path:`${i}.opacity`,message:"透明度不能大于1"}),T(e.align,["left","center","right","justify"],`${i}.align`,t),T(e.verticalAlign,["top","middle","bottom"],`${i}.verticalAlign`,t)}}function le(e,i,t){if(!p(e)){t.push({path:i,message:"富文本片段应为对象"});return}T(e.kind,["text","field"],`${i}.kind`,t);for(const s of["text","field"])e[s]!==void 0&&typeof e[s]!="string"&&t.push({path:`${i}.${s}`,message:"富文本内容应为字符串"});pe(e.style,`${i}.style`,t)}function q(e,i,t){if(e!==void 0){if(!Array.isArray(e)){t.push({path:`${i}.richParagraphs`,message:"richParagraphs 应为数组"});return}e.forEach((s,n)=>{const a=`${i}.richParagraphs.${n}`;if(!p(s)||!Array.isArray(s.segments)){t.push({path:a,message:"段落缺少 segments 数组"});return}T(s.align,["left","center","right","justify"],`${a}.align`,t),O(s,["lineHeight","spaceBeforeMm","spaceAfterMm","indentMm"],a,t),s.segments.forEach((o,r)=>le(o,`${a}.segments.${r}`,t))})}}function D(e,i,t,s=[]){const n=k.componentTreeIssue([e],i);if(n){t.push(n);return}B(e,i,t,s)}function B(e,i,t,s=[]){if(!p(e)){t.push({path:i,message:"组件应为对象"});return}const n=e.kind;typeof n!="string"?t.push({path:`${i}.kind`,message:"组件缺少 kind 字符串"}):ue.has(n)||s.push({path:`${i}.kind`,message:`未知组件类型 ${R(n)},将以兜底方式渲染`});for(const a of["leftMm","topMm","widthMm","heightMm"])he(e,a,i,t);typeof e.leftMm=="number"&&e.leftMm<-100&&t.push({path:`${i}.leftMm`,message:"几何数值异常(leftMm<-100)"});for(const a of["widthMm","heightMm"])typeof e[a]=="number"&&e[a]<0&&t.push({path:`${i}.${a}`,message:"组件尺寸不能为负数"});me(e.table,i,t),$e(e.code,n,i,t),ye(e,i,t),e.pageAnchor!==void 0&&!["header","footer"].includes(e.pageAnchor)&&t.push({path:`${i}.pageAnchor`,message:"页面锚点应为 header 或 footer"}),e.lineDirection!==void 0&&!["down","up"].includes(e.lineDirection)&&t.push({path:`${i}.lineDirection`,message:"线段方向应为 down 或 up"}),ge(e.grid,i,t,s),q(e.richParagraphs,i,t)}function ye(e,i,t){if(e.chartBinding!==void 0)try{if(P.validateReportChartBinding(e.chartBinding),e.kind!=="chart"||["binding","imageData","grid","pageAnchor"].some(s=>e[s]!==void 0))throw new Error("绑定图表不能设置图片、网格、记录绑定或页眉页脚");if(typeof e.widthMm!="number"||e.widthMm<45||typeof e.heightMm!="number"||e.heightMm<35)throw new Error("绑定图表至少需要 45×35mm")}catch(s){t.push({path:`${i}.chartBinding`,message:s instanceof Error?s.message:String(s)})}}function $e(e,i,t,s){if(e!==void 0)for(const n of fe.codeOptionIssues(e,i))s.push({path:`${t}.code${n.path?`.${n.path}`:""}`,message:n.message})}function X(e,i,t){if(!p(e))return;e.binding!==void 0&&t.push({path:`${i}.binding`,message:"渲染计划不允许未解析字段绑定"}),e.chartBinding!==void 0&&t.push({path:`${i}.chartBinding`,message:"渲染计划不允许未解析图表绑定"});const s=e.grid;!p(s)||!Array.isArray(s.cells)||s.cells.forEach((n,a)=>{Array.isArray(n)&&n.forEach((o,r)=>{!p(o)||!Array.isArray(o.children)||o.children.forEach((f,d)=>X(f,`${i}.grid.cells.${a}.${r}.children.${d}`,t))})})}function Y(e,i,t,s=[]){if(!p(e)){t.push({path:i,message:"页应为对象"});return}const n=e.pageWidthMm,a=e.pageHeightMm;(typeof n!="number"||!Number.isFinite(n)||n<=0)&&t.push({path:`${i}.pageWidthMm`,message:`页宽非法: ${R(n)}`}),(typeof a!="number"||!(a>0&&a<5e3))&&t.push({path:`${i}.pageHeightMm`,message:`页高非法: ${R(a)}`}),e.layout!==void 0&&e.layout!=="page"&&e.layout!=="wide"&&t.push({path:`${i}.layout`,message:"布局应为 page 或 wide"});const o=e.components;if(!Array.isArray(o))t.push({path:`${i}.components`,message:"components 应为数组"});else if(Array.isArray(o)){const r=k.componentTreeIssue(o,`${i}.components`);if(r){t.push(r);return}o.forEach((f,d)=>{B(f,`${i}.components.${d}`,t,s),X(f,`${i}.components.${d}`,t)})}}function Q(e){const i=[],t=[],s=p(e)?e.pages:void 0;if(p(e)&&e.requiresRecalculation!==void 0&&typeof e.requiresRecalculation!="boolean"&&i.push({path:"$.requiresRecalculation",message:"重算能力要求应为布尔值"}),!Array.isArray(s))i.push({path:"$.pages",message:e==null?"渲染计划为空":"渲染计划缺少 pages 数组"});else{const n=k.renderTreeIssue(s);if(n)return{ok:!1,errors:[...i,n],warnings:t};s.forEach((o,r)=>Y(o,`$.pages.${r}`,i,t)),s.length>2e3&&t.push({path:"$.pages",message:`页数异常大(${s.length} 页),渲染与打印耗时可能显著增加`});const a=s.reduce((o,r)=>o+(p(r)&&Array.isArray(r.components)?r.components.length:0),0);a>5e4&&t.push({path:"$.pages",message:`组件总数异常大(${a} 个),可能触发浏览器性能限制`})}return{ok:i.length===0,errors:i,warnings:t}}function be(e){const i=Q(e);if(!i.ok){const t=i.errors.slice(0,3).map(s=>`${s.path}: ${s.message}`).join("; ");throw new Error(`渲染计划校验失败(${i.errors.length} 处): ${t}`)}return e.pages}function V(e){return e.kind==="list"?e.id:e.nid}function Ae(e){return e.kind==="list"?!1:e.pageAnchor!==void 0||e.kind==="text"&&typeof e.text=="string"&&/\{(?:page|totalPages)\}/.test(e.text)}function we(e,i){const t=e.filter(n=>i.componentIds.includes(V(n)??""));if(t.filter(n=>n.kind==="list"&&n.cardinality!=="record").length&&t.length!==1)throw new Error("纵向重复区域必须独占流式分段,不能与静态或单记录区域并排");for(const n of t){const a=n.kind==="list"?n.topMm+(n.rowHeightMm??0):n.topMm+n.heightMm;if(n.topMm<i.topMm-.001||a>i.topMm+i.heightMm+.001)throw new Error("流式分段应完整包含其组件的原始纵向范围")}}function Me(e,i){if(!i)return e.map(s=>({components:[s]}));const t=new Map(e.map(s=>[V(s),s]));return i.bands.map(s=>({band:s,components:s.componentIds.map(n=>{const a=t.get(n);if(!a)throw new Error(`流式区域引用不存在的组件:${n}`);return a})}))}function Z(e,i){if(!i||!Array.isArray(i.bands)||!i.bands.length||i.bands.length>1e4)throw new Error("流式排版应包含 1–10000 个区域");const t=new Set,s=new Set;for(const n of e){if(Ae(n))continue;const a=V(n);if(!a||t.has(a))throw new Error("流式排版组件应具有唯一标识");t.add(a)}if(Ee(e,i,t,s),s.size!==t.size)throw new Error("流式排版必须显式包含每个非锚点组件")}function Ee(e,i,t,s){let n=-1/0;for(const a of i.bands){if(!Number.isFinite(a.topMm)||!Number.isFinite(a.heightMm)||a.topMm<0||a.heightMm<=0||a.topMm<n-.001)throw new Error("流式区域应按原始位置排序,尺寸有效且不重叠");if(!Array.isArray(a.componentIds)||!a.componentIds.length)throw new Error("流式区域不能没有组件");for(const o of a.componentIds){if(!t.has(o)||s.has(o))throw new Error(`流式区域组件缺失、重复或包含页锚点:${o}`);s.add(o)}we(e,a),n=a.topMm+a.heightMm}}const ke=new Set(["__proto__","prototype","constructor"]);function $(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function S(e){return typeof e=="string"&&!!e.trim()&&!ke.has(e)}function x(e,i,t,s){for(const n of Object.keys(e))i.includes(n)||s.push({path:`${t}.${n}`,message:"存在未知配置字段"})}function Se(e,i,t){if(e!==void 0){if(!$(e)||!["number","percent","date"].includes(String(e.kind))){t.push({path:i,message:"绑定格式应为 number、percent 或 date"});return}x(e,e.kind==="date"?["kind","pattern"]:e.kind==="number"?["kind","digits","thousands"]:["kind","digits"],i,t),e.digits!==void 0&&(!Number.isInteger(e.digits)||Number(e.digits)<0||Number(e.digits)>100)&&t.push({path:`${i}.digits`,message:"精度应为 0..100 整数"}),e.thousands!==void 0&&typeof e.thousands!="boolean"&&t.push({path:`${i}.thousands`,message:"千分位开关应为布尔值"}),e.pattern!==void 0&&typeof e.pattern!="string"&&t.push({path:`${i}.pattern`,message:"日期格式应为字符串"})}}function ve(e,i,t){const s=e.binding;if(s===void 0)return;const n=`${i}.binding`;if(!$(s)){t.push({path:n,message:"字段绑定应为对象"});return}(!["text","image","barcode","qrcode"].includes(String(e.kind))||e.grid!==void 0)&&t.push({path:n,message:"绑定仅支持独立文本、图片、条码与二维码组件"}),x(s,["field","format","prefix","suffix","emptyText"],n,t),S(s.field)||t.push({path:`${n}.field`,message:"绑定字段应为安全的非空字段名(按字面读取自有字段)"});for(const a of["prefix","suffix","emptyText"])s[a]!==void 0&&typeof s[a]!="string"&&t.push({path:`${n}.${a}`,message:"应为字符串"});Se(s.format,`${n}.format`,t),e.kind==="image"&&["format","prefix","suffix"].some(a=>s[a]!==void 0)&&t.push({path:n,message:"图片绑定直接读取 PNG/JPEG data URL,不支持文本格式或前后缀"})}function Ne(e,i){if(!$(e)){i.push({path:"$.repeat",message:"逐记录配置应为对象"});return}x(e,["dataset","rowKey","copies"],"$.repeat",i),S(e.dataset)||i.push({path:"$.repeat.dataset",message:"数据集应为安全的非空名称"}),e.rowKey!==void 0&&!S(e.rowKey)&&i.push({path:"$.repeat.rowKey",message:"业务主键应为安全的非空字段名"});const t=e.copies;t!==void 0&&($(t)?(x(t,["field"],"$.repeat.copies",i),S(t.field)||i.push({path:"$.repeat.copies.field",message:"复制数字段应为安全的非空字段名"})):(!Number.isSafeInteger(t)||Number(t)<1||Number(t)>1e3)&&i.push({path:"$.repeat.copies",message:"每条记录复制数应为 1..1000 整数"}))}function ee(e,i,t,s){if(!$(e))return;ve(e,i,s),e.binding!==void 0&&!t&&s.push({path:`${i}.binding`,message:"字段绑定需要模板 repeat 数据集;普通报表请使用列表字段"}),t&&e.kind==="list"&&s.push({path:i,message:"逐记录标签使用固定组件;动态列表请使用普通报表模板"}),e.chartBinding!==void 0&&(t||i.includes(".children."))&&s.push({path:`${i}.chartBinding`,message:"数据图表应放在普通报表的页面或流式分区,不放在逐记录标签或嵌套单元格内"});const n=e.grid;$(n)&&Array.isArray(n.cells)&&n.cells.forEach((a,o)=>{Array.isArray(a)&&a.forEach((r,f)=>{$(r)&&Array.isArray(r.children)&&r.children.forEach((d,c)=>ee(d,`${i}.grid.cells.${o}.${f}.children.${c}`,t,s))})})}function te(e,i){const t=e.repeat!==void 0;t&&Ne(e.repeat,i),Array.isArray(e.pages)&&e.pages.forEach((s,n)=>{if(!$(s))return;const a=`$.pages.${n}`;t&&(s.layout==="wide"||s.flow!==void 0)&&i.push({path:a,message:"逐记录标签仅支持固定尺寸页面,不支持宽表或流式分区"}),Array.isArray(s.components)&&s.components.forEach((o,r)=>{const f=`${a}.components.${r}`;if(ee(o,f,t,i),!t||!$(o))return;const{leftMm:d,topMm:c,widthMm:m,heightMm:l}=o;[d,c,m,l,s.widthMm,s.heightMm].every(y=>typeof y=="number"&&Number.isFinite(y))&&(Number(d)<0||Number(c)<0||Number(d)+Number(m)>Number(s.widthMm)+.001||Number(c)+Number(l)>Number(s.heightMm)+.001)&&i.push({path:f,message:"标签组件超出纸张边界,请调整位置或尺寸"})})})}function Re(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function _(e,i,t){if(e!==void 0)try{P.compileReportPredicate(e)}catch(s){t.push({path:i,message:s instanceof Error?s.message:String(s)})}}function ie(e,i,t){if(e===void 0)return;if(!Array.isArray(e)||e.length>2048){t.push({path:i,message:"聚合应为数组且最多 2048 项"});return}const s=new Set;e.forEach((n,a)=>{const o=`${i}.${a}`;if(!Re(n)){t.push({path:o,message:"聚合应为对象"});return}const r=n.field;typeof r!="string"||!r.trim()||s.has(r)?t.push({path:`${o}.field`,message:"聚合输出字段应非空且唯一"}):s.add(r),n.numeric!==void 0&&n.numeric!=="number"&&n.numeric!=="decimal"&&t.push({path:`${o}.numeric`,message:"数值模式应为 number 或 decimal"}),n.digits!==void 0&&(!Number.isInteger(n.digits)||Number(n.digits)<0||Number(n.digits)>100)&&t.push({path:`${o}.digits`,message:"小数位应为 0–100 的整数"});try{P.createAggregateAccumulator({...n,field:n.valueField??r})}catch(f){t.push({path:o,message:f instanceof Error?f.message:String(f)})}})}function Te(e,i,t){if(e===void 0)return;const s=P.validateComputedFields(e);for(const n of s.errors)t.push({path:i,message:n})}function xe(e,i,t){if(e!==void 0)try{re.validateMatrixOptions(e)}catch(s){t.push({path:i,message:s instanceof Error?s.message:String(s)})}}function Ce(e,i,t){if(e.tree===void 0)return;const s=`${i}.tree`;try{w.validateTreeOptions(e.tree);const n=e.tree;if(e.matrix||e.detail||e.groupBy||Array.isArray(e.groups)&&e.groups.length||e.rowVisibleWhen)throw new Error("树形布局不能同时配置普通分组、矩阵、主从或行可见条件");if(e.rowKey!==void 0&&e.rowKey!==n.idField)throw new Error("树形 rowKey 应与 idField 一致");if(!Array.isArray(e.columns)||!e.columns.some(a=>a&&a.field===n.labelField&&!a.hidden))throw new Error("树形布局需要可见的标签列");Array.isArray(e.computed)&&w.validateTreeComputed(n,e.computed)}catch(n){t.push({path:s,message:n instanceof Error?n.message:String(n)})}}const Pe=new Set(["__proto__","prototype","constructor"]),Fe=new Set(["text","number","boolean","date","decimal"]);function v(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function I(e){return typeof e=="string"&&!!e.trim()&&e.length<=4096&&!Pe.has(e)}function Oe(e,i,t){if(!Array.isArray(e)||!e.length||e.length>2048){t.push({path:i,message:"绑定契约应包含 1–2048 个字段"});return}const s=new Set;e.forEach((n,a)=>{const o=`${i}.${a}`;if(!v(n)||!I(n.field)||s.has(n.field)){t.push({path:o,message:"字段名应安全、非空且唯一"});return}s.add(n.field);for(const r of["label","semanticKey","unit"])n[r]!==void 0&&(typeof n[r]!="string"||String(n[r]).length>4096)&&t.push({path:`${o}.${r}`,message:"应为不超过 4096 位的字符串"});n.type!==void 0&&!Fe.has(String(n.type))&&t.push({path:`${o}.type`,message:"未知绑定字段类型"})})}function L(e,i,t){if(e===void 0)return;if(!v(e)||!v(e.datasets)){t.push({path:i,message:"模板数据契约应声明 datasets"});return}e.source!==void 0&&!I(e.source)&&t.push({path:`${i}.source`,message:"来源应为安全的非空业务标识"});const s=Object.entries(e.datasets);(!s.length||s.length>256)&&t.push({path:`${i}.datasets`,message:"应声明 1–256 个数据集"});for(const[n,a]of s){const o=`${i}.datasets.${n}`;!I(n)||!v(a)?t.push({path:o,message:"数据集应使用安全名称和字段契约"}):Oe(a.fields,`${o}.fields`,t)}}function J(e,i){return new Map(e.datasets[i]?.fields.map(t=>[t.field,t])??[])}function _e(e,i,t,s){const n=e.label||e.field;for(const[a,o,r]of[["semanticKey","semantic","业务含义"],["type","type","类型"],["unit","unit","单位"]])e[a]!==i[a]&&(e[a]!==void 0||i[a]!==void 0)&&s.push({...t,code:o,message:`字段“${n}”的${r}不兼容(${e[a]??"未声明"} → ${i[a]??"未声明"}),请重新绑定`})}function Ie(e,i){const t=[],s=[];if(L(i,"$.target",s),L(e.dataContract,"$.template.dataContract",s),s.length)return{ok:!1,issues:s.map(o=>({...o,code:"contract"}))};const n=e.dataContract;if(!n)return{ok:!1,issues:[{code:"contract",path:"$.template.dataContract",message:"模板未声明数据来源,请核对业务字段并重新绑定"}]};n.source!==i.source&&t.push({code:"source",path:"$.template.dataContract.source",message:`模板来源与当前报表不一致(${n.source??"未声明"} → ${i.source??"未声明"}),请从当前报表创建或重新绑定模板`});const a=new Set;for(const o of w.collectTemplateDatasetBindings(e)){const r=J(n,o.dataset),f=J(i,o.dataset);if(!r.size||!f.size){t.push({code:"dataset",dataset:o.dataset,path:o.path,message:`数据集“${o.dataset}”缺少来源或目标字段契约`});continue}for(const d of o.fields){if(o.generated.has(d.field)||d.summary&&o.summaries.has(d.field))continue;const c=`${o.dataset}\0${d.field}`;if(a.has(c))continue;a.add(c);const m=r.get(d.field),l=f.get(d.field),y={...d,dataset:o.dataset};!m||!l?t.push({...y,code:"field",message:`数据集“${o.dataset}”的字段“${d.field}”未声明,请重新绑定`}):_e(m,l,y,t)}}return{ok:t.length===0,issues:t}}const j="1.0";class M extends Error{constructor(i){super(`模板校验失败:${i.slice(0,3).map(t=>`${t.path}: ${t.message}`).join("; ")}`),this.errors=i,this.name="ReportTemplateError"}}const Le=new Set(["__proto__","prototype","constructor"]),De=new Set(["schemaVersion","id","name","revision","description","template"]),Be=new Set(["left","center","right","justify"]),N=2e5,Ve=64;function u(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function je(e,i,t){const s=Object.getPrototypeOf(e),n=Array.isArray(e);if(n?s!==Array.prototype:s!==Object.prototype&&s!==null)return t.push({path:i,message:"模板对象必须使用普通 JSON 对象原型"}),!1;if(n){const a=Object.keys(e);if(a.length!==e.length||a.some(o=>!/^(0|[1-9]\d*)$/.test(o)||Number(o)>=e.length))return t.push({path:i,message:"模板数组不能包含空位或额外属性"}),!1}return Object.getOwnPropertySymbols(e).length>0?(t.push({path:i,message:"模板不能包含 Symbol 键"}),!1):!0}function Ke(e,i,t,s){return Le.has(e)?(s.push({path:t,message:"模板不能包含可能污染原型的键"}),!1):i.get||i.set||!i.enumerable?(s.push({path:t,message:"模板不能包含访问器或不可枚举字段"}),!1):!0}function He(e){return e===null||typeof e=="boolean"||typeof e=="number"&&Number.isFinite(e)}function K(e,i){const t=new Set;let s=0,n=0,a=!1;const o=(r,f,d)=>{if(!a){if(++s>N){s===N+1&&i.push({path:f,message:"模板超过 JSON 节点安全上限"});return}if(d>Ve){i.push({path:f,message:"模板嵌套层级过深"});return}if(typeof r=="string"){n+=r.length,n>w.MAX_TEMPLATE_JSON_CHARACTERS&&(a=!0,i.push({path:f,message:"模板文本超过 1000 万字符的安全上限"}));return}if(!He(r)){if(!r||typeof r!="object"){i.push({path:f,message:"模板只允许 JSON 值,不允许函数、undefined 或非有限数字"});return}if(t.has(r)){i.push({path:f,message:"模板不能包含循环引用"});return}if(je(r,f,i)){t.add(r);for(const[c,m]of Object.entries(Object.getOwnPropertyDescriptors(r))){if(Array.isArray(r)&&c==="length")continue;const l=`${f}.${c}`;if(Ke(c,m,l,i)&&o(m.value,l,d+1),s>N||a)break}t.delete(r)}}}};o(e,"$",0)}function h(e,i,t,s,n=!1){const a=e[i];a===void 0&&!n||(typeof a!="string"||n&&!a.trim())&&s.push({path:`${t}.${i}`,message:n?"应为非空字符串":"应为字符串"})}function g(e,i,t,s,n=0,a=!1){const o=e[i];o===void 0&&!a||(typeof o!="number"||!Number.isFinite(o)||o<n)&&s.push({path:`${t}.${i}`,message:`应为大于等于 ${n} 的有限数字`})}function A(e,i,t,s){e[i]!==void 0&&typeof e[i]!="boolean"&&s.push({path:`${t}.${i}`,message:"应为布尔值"})}function E(e,i,t,s=!1){e!==void 0&&!Be.has(e)&&!(s&&e==="auto")&&t.push({path:i,message:`未知对齐方式${s?"(支持 auto)":""}`})}function b(e,i,t){if(e!==void 0){if(!u(e)){t.push({path:i,message:"样式应为对象"});return}E(e.align,`${i}.align`,t),e.verticalAlign!==void 0&&!["top","middle","bottom"].includes(e.verticalAlign)&&t.push({path:`${i}.verticalAlign`,message:"未知垂直对齐方式"});for(const s of["fontSize","fontSizePx","lineWidthPt","lineHeight"])g(e,s,i,t);for(const s of["letterSpacing","rotateDeg"])g(e,s,i,t,-1/0);g(e,"opacity",i,t),typeof e.opacity=="number"&&e.opacity>1&&t.push({path:`${i}.opacity`,message:"透明度不能大于 1"});for(const s of["bold","italic","underline","borderTop","borderRight","borderBottom","borderLeft"])A(e,s,i,t);for(const s of["fontFamily","color","backgroundColor","lineColor","borderColor"])h(e,s,i,t)}}function Je(e,i,t){if(e===void 0)return;if(!Array.isArray(e)){t.push({path:i,message:"参数定义应为数组"});return}const s=new Set,n=t.length;e.forEach((a,o)=>{const r=`${i}.${o}`;if(!u(a)){t.push({path:r,message:"参数定义应为对象"});return}h(a,"field",r,t,!0),typeof a.field=="string"&&(s.has(a.field)&&t.push({path:`${r}.field`,message:"参数名重复"}),s.add(a.field)),a.type!==void 0&&!["text","number","date","month","year","dateRange","select","multiSelect","cascader","numberRange"].includes(a.type)&&t.push({path:`${r}.type`,message:"未知参数类型"});for(const f of["label","defaultValue","placeholder"])h(a,f,r,t);A(a,"required",r,t);for(const f of["minLength","maxLength"]){const d=a[f];d!==void 0&&(typeof d!="number"||!Number.isSafeInteger(d)||d<0)&&t.push({path:`${r}.${f}`,message:"长度边界应为非负整数"})}We(a,r,t),a.options!==void 0&&(Array.isArray(a.options)?a.options.forEach((f,d)=>{const c=`${r}.options.${d}`;if(!u(f))t.push({path:c,message:"选项应为对象"});else for(const m of["label","value"])typeof f[m]!="string"&&t.push({path:`${c}.${m}`,message:"选项标签与值应为字符串(允许空白选项)"})}):t.push({path:`${r}.options`,message:"选项应为数组"}))}),t.length===n&&t.push(...G.validateReportParamDefinitions(e).map(a=>({path:a.path.replace("$.paramDefs",i),message:a.message})))}function We(e,i,t){for(const a of["min","max"]){const o=e[a];if(o===void 0)continue;G.isReportTemporalBound(e.type,o)||["number","numberRange"].includes(e.type)&&typeof o=="number"&&Number.isFinite(o)||t.push({path:`${i}.${a}`,message:"数字使用有限数字边界,日期/月/年使用对应规范字符串边界"})}const s=typeof e.min=="number"&&typeof e.max=="number"&&e.min>e.max,n=typeof e.min=="string"&&typeof e.max=="string"&&e.min>e.max;(s||n)&&t.push({path:i,message:"最小边界不能大于最大边界"}),typeof e.minLength=="number"&&typeof e.maxLength=="number"&&e.minLength>e.maxLength&&t.push({path:i,message:"最小长度不能大于最大长度"})}function se(e,i,t){if(!Array.isArray(e)||e.length===0){t.push({path:i,message:"列表至少需要一列"});return}e.every(s=>u(s)&&s.hidden===!0)&&t.push({path:i,message:"列表至少需要一列可见列"}),e.forEach((s,n)=>{const a=`${i}.${n}`;if(!u(s)){t.push({path:a,message:"列应为对象"});return}if(U(s,a,t),s.visual!==void 0&&!w.validColumnVisual(s.visual)&&t.push({path:`${a}.visual`,message:"列可视化配置无效,请检查类型、数值范围和颜色"}),A(s,"hidden",a,t),_(s.visibleWhen,`${a}.visibleWhen`,t),typeof s.header!="string"&&t.push({path:`${a}.header`,message:"表头应为字符串(允许空白表头)"}),h(s,"field",a,t,!0),g(s,"widthMm",a,t,Number.MIN_VALUE,!0),b(s.style,`${a}.style`,t),b(s.headerStyle,`${a}.headerStyle`,t),E(s.align,`${a}.align`,t,!0),E(s.headerAlign,`${a}.headerAlign`,t),s.semanticRole!==void 0&&!["identifier","dimension","measure","date","text"].includes(s.semanticRole)&&t.push({path:`${a}.semanticRole`,message:"未知列语义"}),s.format!==void 0)if(!u(s.format)||!["number","percent","date"].includes(s.format.kind))t.push({path:`${a}.format`,message:"未知列格式"});else{const o=s.format.digits;o!==void 0&&(typeof o!="number"||!Number.isInteger(o)||o<0||o>100)&&t.push({path:`${a}.format.digits`,message:"小数位应为 0–100 的整数"}),A(s.format,"thousands",`${a}.format`,t),h(s.format,"pattern",`${a}.format`,t)}s.rules!==void 0&&(Array.isArray(s.rules)?s.rules.forEach((o,r)=>{const f=`${a}.rules.${r}`;if(!u(o)||!u(o.when)){t.push({path:f,message:"条件格式缺少 when 对象"});return}_(o.when,`${f}.when`,t),b(o.style,`${f}.style`,t)}):t.push({path:`${a}.rules`,message:"条件格式应为数组"}))})}function ne(e,i,t){if(e!==void 0){if(!u(e)){t.push({path:i,message:"分组应为对象"});return}h(e,"field",i,t,!0);for(const s of["headerTemplate","subtotalLabel"])h(e,s,i,t);for(const s of["headerStyle","subtotalStyle"])b(e[s],`${i}.${s}`,t);A(e,"keepWithNext",i,t),A(e,"repeatHeader",i,t),ie(e.aggregates,`${i}.aggregates`,t),e.subtotal!==void 0&&(!Array.isArray(e.subtotal)||e.subtotal.some(s=>typeof s!="string"))&&t.push({path:`${i}.subtotal`,message:"小计字段应为字符串数组"})}}function Ge(e,i,t){if(!(e===void 0||typeof e=="boolean")){if(!u(e)){t.push({path:i,message:"合计应为布尔值或对象"});return}h(e,"label",i,t),ie(e.aggregates,`${i}.aggregates`,t),b(e.style,`${i}.style`,t),e.fields!==void 0&&(!Array.isArray(e.fields)||e.fields.some(s=>typeof s!="string"))&&t.push({path:`${i}.fields`,message:"合计字段应为字符串数组"})}}function Ue(e,i,t,s){const n={kind:"rect",leftMm:0,topMm:0,widthMm:1,heightMm:1,grid:e};if(D(n,t,s,[]),H(n,t,s),!u(e)||!Array.isArray(e.cells))return;const a=e.cells,o=Array.isArray(i)?i.length:0;if(a.length*o>N){s.push({path:t,message:"表头逻辑网格超过 20 万格安全上限"});return}e.cells.length||s.push({path:`${t}.cells`,message:"表头至少需要一行"}),Array.isArray(e.colWidthsMm)&&e.colWidthsMm.length!==o&&s.push({path:`${t}.colWidthsMm`,message:"表头列宽数量应与列表列数一致"}),Array.isArray(e.rowHeightsMm)&&e.rowHeightsMm.length!==e.cells.length&&s.push({path:`${t}.rowHeightsMm`,message:"表头行高数量应与行数一致"}),ze(a,o,t,s)}function ze(e,i,t,s){const n=new Set;e.forEach((a,o)=>{if(!Array.isArray(a))return;let r=0;a.forEach((f,d)=>{for(;n.has(`${o}:${r}`);)r++;const c=u(f)&&typeof f.colSpan=="number"?f.colSpan:1,m=u(f)&&typeof f.rowSpan=="number"?f.rowSpan:1;(r+c>i||o+m>e.length)&&s.push({path:`${t}.cells.${o}.${d}`,message:"表头合并区域超出表头边界"});for(let l=o;l<Math.min(e.length,o+m);l++)for(let y=r;y<Math.min(i,r+c);y++)n.has(`${l}:${y}`)&&s.push({path:`${t}.cells.${o}.${d}`,message:"表头合并区域重叠"}),n.add(`${l}:${y}`);r+=c})})}function qe(e,i,t){if(Ce(e,i,t),Te(e.computed,`${i}.computed`,t),xe(e.matrix,`${i}.matrix`,t),e.matrix&&(e.detail||e.groupBy||Array.isArray(e.groups)&&e.groups.length||e.grandTotal)&&t.push({path:`${i}.matrix`,message:"矩阵请使用自身 totals 汇总,不能同时配置普通分组、总计或主从明细"}),_(e.rowVisibleWhen,`${i}.rowVisibleWhen`,t),e.groups!==void 0&&(!Array.isArray(e.groups)||e.groups.length>16?t.push({path:`${i}.groups`,message:"分组应为数组,最多 16 级"}):e.groups.forEach((a,o)=>ne(a,`${i}.groups.${o}`,t))),e.detail===void 0)return;const s=e.detail,n=`${i}.detail`;if(!u(s)){t.push({path:n,message:"主从关联应为对象"});return}for(const a of["dataset","parentKey","foreignKey"])h(s,a,n,t,!0);for(const a of["rowKey","revisionField","sourceTokenField"])h(s,a,n,t,s[a]!==void 0);h(s,"label",n,t),A(s,"header",n,t),g(s,"rowHeightMm",n,t,Number.MIN_VALUE),se(s.columns,`${n}.columns`,t),s.unmatched!==void 0&&s.unmatched!=="error"&&s.unmatched!=="ignore"&&t.push({path:`${n}.unmatched`,message:"未关联明细策略应为 error 或 ignore"})}function Xe(e,i,t){for(const s of["leftMm","topMm"])g(e,s,i,t,-1/0,!0);g(e,"widthMm",i,t,Number.MIN_VALUE,!0),h(e,"dataset",i,t,!0),h(e,"title",i,t);for(const s of["rowKey","revisionField","sourceTokenField"])h(e,s,i,t,e[s]!==void 0);e.headerGrid!==void 0&&Ue(e.headerGrid,e.columns,`${i}.headerGrid`,t),e.layout!==void 0&&e.layout!=="page"&&e.layout!=="wide"&&t.push({path:`${i}.layout`,message:"布局应为 page 或 wide"}),se(e.columns,`${i}.columns`,t);for(const s of["fontSizePt","rowHeightMm"])g(e,s,i,t,Number.MIN_VALUE);g(e,"paddingMm",i,t);for(const s of["header","headerBold","headerEveryPage","border"])A(e,s,i,t);e.cardinality!==void 0&&e.cardinality!=="record"&&t.push({path:`${i}.cardinality`,message:"单记录区域类型应为 record"}),h(e,"headerBackgroundColor",i,t),E(e.align,`${i}.align`,t,!0),E(e.headerAlign,`${i}.headerAlign`,t),b(e.headerStyle,`${i}.headerStyle`,t),qe(e,i,t),ne(e.groupBy,`${i}.groupBy`,t),Ge(e.grandTotal,`${i}.grandTotal`,t)}function W(e,i,t){Array.isArray(e.richParagraphs)&&e.richParagraphs.forEach((s,n)=>{if(!u(s))return;const a=`${i}.richParagraphs.${n}`;E(s.align,`${a}.align`,t);for(const o of["lineHeight","spaceBeforeMm","spaceAfterMm","indentMm"])g(s,o,a,t);Array.isArray(s.segments)&&s.segments.forEach((o,r)=>{const f=`${a}.segments.${r}`;if(!u(o)){t.push({path:f,message:"富文本片段应为对象"});return}o.kind!==void 0&&o.kind!=="text"&&o.kind!=="field"&&t.push({path:`${f}.kind`,message:"未知富文本片段类型"});for(const d of["text","field"])h(o,d,f,t);b(o.style,`${f}.style`,t)})})}function H(e,i,t){b(e.style,`${i}.style`,t);for(const n of["text","rawText","imageData","fallbackText","nid","rkey"])h(e,n,i,t);if(e.lines!==void 0&&(!Array.isArray(e.lines)||e.lines.some(n=>typeof n!="string"))&&t.push({path:`${i}.lines`,message:"文本行应为字符串数组"}),W(e,i,t),!u(e.grid))return;const s=e.grid;g(s,"gapMm",`${i}.grid`,t),g(s,"paddingMm",`${i}.grid`,t);for(const n of["colWidthsMm","rowHeightsMm"]){const a=s[n];a!==void 0&&(!Array.isArray(a)||a.some(o=>typeof o!="number"||!Number.isFinite(o)||o<0))&&t.push({path:`${i}.grid.${n}`,message:"网格尺寸应为有限非负数字数组"})}Array.isArray(s.cells)&&s.cells.forEach((n,a)=>{Array.isArray(n)&&n.forEach((o,r)=>{const f=`${i}.grid.cells.${a}.${r}`;if(o!==null){if(!u(o)){t.push({path:f,message:"网格单元格应为对象或 null"});return}for(const d of["text","rawText","numberFormat"])h(o,d,f,t);for(const d of["colSpan","rowSpan"]){const c=o[d];c!==void 0&&(typeof c!="number"||!Number.isInteger(c)||c<=0)&&t.push({path:`${f}.${d}`,message:"跨度应为正整数"})}o.value!==void 0&&o.value!==null&&!["string","number","boolean"].includes(typeof o.value)&&t.push({path:`${f}.value`,message:"Excel 原始值应为字符串、数字、布尔值或 null"}),b(o.style,`${f}.style`,t),W(o,f,t),o.children!==void 0&&(Array.isArray(o.children)?o.children.forEach((d,c)=>{u(d)&&H(d,`${f}.children.${c}`,t)}):t.push({path:`${f}.children`,message:"嵌套组件应为数组"}))}})})}function Ye(e,i,t){if(!(e.flow===void 0||!Array.isArray(e.components)))try{Z(e.components,e.flow)}catch(s){t.push({path:`${i}.flow`,message:s instanceof Error?s.message:String(s)})}}function ae(e){const i=[],t=[];return K(e,i),i.length?{ok:!1,errors:i,warnings:t}:(u(e)?(e.schemaVersion!==void 0&&e.schemaVersion!==k.RENDER_PLAN_SCHEMA_VERSION&&i.push({path:"$.schemaVersion",message:"不支持的模板 schemaVersion"}),Je(e.params,"$.params",i),L(e.dataContract,"$.dataContract",i),te(e,i),!Array.isArray(e.pages)||e.pages.length===0?i.push({path:"$.pages",message:"模板至少需要一页"}):e.pages.forEach((s,n)=>{const a=`$.pages.${n}`;if(!u(s)){i.push({path:a,message:"页应为对象"});return}g(s,"widthMm",a,i,Number.MIN_VALUE,!0),g(s,"heightMm",a,i,Number.MIN_VALUE,!0),s.layout!==void 0&&s.layout!=="page"&&s.layout!=="wide"&&i.push({path:`${a}.layout`,message:"布局应为 page 或 wide"}),typeof s.heightMm=="number"&&s.heightMm>=5e3&&i.push({path:`${a}.heightMm`,message:"页高应小于 5000mm"});for(const o of["marginTopMm","marginBottomMm","marginLeftMm","marginRightMm"])g(s,o,a,i);typeof s.widthMm=="number"&&Number(s.marginLeftMm??0)+Number(s.marginRightMm??0)>=s.widthMm&&i.push({path:a,message:"横向页边距占满页面"}),typeof s.heightMm=="number"&&Number(s.marginTopMm??0)+Number(s.marginBottomMm??0)>=s.heightMm&&i.push({path:a,message:"纵向页边距占满页面"}),Array.isArray(s.components)?s.components.forEach((o,r)=>{const f=`${a}.components.${r}`;u(o)&&o.kind==="list"?Xe(o,f,i):(D(o,f,i,t),u(o)&&H(o,f,i))}):i.push({path:`${a}.components`,message:"组件应为数组"}),Ye(s,a,i)})):i.push({path:"$",message:"模板应为对象"}),{ok:i.length===0,errors:i,warnings:t})}function oe(e){const i=[],t=[];if(K(e,i),i.length)return{ok:!1,errors:i,warnings:t};if(!u(e))i.push({path:"$",message:"模板文档应为对象"});else{for(const n of Object.keys(e))De.has(n)||i.push({path:`$.${n}`,message:"模板文档存在未知字段;只保存模板与描述,不保存取数或业务数据"});e.schemaVersion!==j&&i.push({path:"$.schemaVersion",message:"不支持的模板文档版本"});for(const n of["id","name"])h(e,n,"$",i,!0);for(const n of["revision","description"])h(e,n,"$",i);const s=ae(e.template);i.push(...s.errors.map(n=>({...n,path:`$.template${n.path.slice(1)}`}))),t.push(...s.warnings.map(n=>({...n,path:`$.template${n.path.slice(1)}`})))}return{ok:i.length===0,errors:i,warnings:t}}function F(e){const i=oe(e);if(!i.ok)throw new M(i.errors)}function Qe(e){const i=[];if(K(e,i),i.length)throw new M(i);const t={...e,schemaVersion:e.schemaVersion??j};return F(t),C(t)}function Ze(e){let i=e;if(typeof e=="string"){if(e.length>w.MAX_TEMPLATE_JSON_CHARACTERS)throw new M([{path:"$",message:"模板 JSON 超过 1000 万字符的导出/导入上限"}]);try{i=JSON.parse(e)}catch{throw new M([{path:"$",message:"模板 JSON 语法无效"}])}}return F(i),C(i)}function et(e){F(e);try{return w.stringifyValidatedTemplate(e)}catch(i){throw i instanceof RangeError?new M([{path:"$",message:i.message}]):i}}function C(e){return JSON.parse(JSON.stringify(e))}function tt(e=[]){const i=new Map,t={get:s=>{const n=i.get(s);return n?C(n):void 0},list:()=>Array.from(i.values(),({template:s,...n})=>({...n})),register:(s,n={})=>{if(F(s),i.has(s.id)&&!n.replace)throw new M([{path:"$.id",message:`模板 ID ${s.id} 已注册;更新需显式 replace:true`}]);i.set(s.id,C(s))},remove:s=>i.delete(s)};for(const s of e)t.register(s);return t}exports.REPORT_TEMPLATE_DOCUMENT_VERSION=j;exports.ReportTemplateError=M;exports.assertRenderPlan=be;exports.createTemplateRegistry=tt;exports.defineReportTemplate=Qe;exports.inspectReportTemplateCompatibility=Ie;exports.parseReportTemplate=Ze;exports.reportFlowGroups=Me;exports.serializeReportTemplate=et;exports.validateComponent=D;exports.validatePage=Y;exports.validateRenderPlan=Q;exports.validateReportPageFlow=Z;exports.validateReportTemplate=ae;exports.validateReportTemplateDocument=oe;exports.validateTemplateRepeat=te;
|