@agile-team/mach-report 2.15.0 → 2.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -9
- package/dist/{ExcelBindingWizard-Bs43BGNp.cjs → ExcelBindingWizard-CP6h2x1f.cjs} +1 -1
- package/dist/{ExcelBindingWizard-BKH1nGNS.js → ExcelBindingWizard-HhB3hAJE.js} +3 -3
- package/dist/{ParamEditor-Da4akw6V.cjs → ParamEditor-CUQLgoxa.cjs} +1 -1
- package/dist/{ParamEditor-DoAhzJsm.js → ParamEditor-OKesP_nO.js} +1 -1
- package/dist/{ReportBatchPanel-wP9m9Pj1.cjs → ReportBatchPanel-cZCAMAwH.cjs} +1 -1
- package/dist/{ReportBatchPanel-BMf6boMA.js → ReportBatchPanel-ruxcbfY6.js} +3 -3
- package/dist/ReportPreview-BcDKCLiK.js +4834 -0
- package/dist/ReportPreview-Bk9nLfO9.cjs +6 -0
- package/dist/{ReportTemplateLibrary-Sxr3eD0J.cjs → ReportTemplateLibrary-BDlNT8JN.cjs} +1 -1
- package/dist/{ReportTemplateLibrary-C9wutIiT.js → ReportTemplateLibrary-DcwrH-63.js} +1 -1
- package/dist/{RuleEditor-XhGHK8DE.cjs → RuleEditor-BX5S8RSF.cjs} +1 -1
- package/dist/{RuleEditor-C_Clasvd.js → RuleEditor-CGl9XY2s.js} +2 -2
- package/dist/{TemplateOutlinePanel-JTSR53vJ.cjs → TemplateOutlinePanel-CGrT5DFN.cjs} +1 -1
- package/dist/{TemplateOutlinePanel-D6Bkny59.js → TemplateOutlinePanel-SXCjaPKR.js} +1 -1
- package/dist/{TemplateReusePanel-Kx35S0Ql.cjs → TemplateReusePanel-6Z3wRFz8.cjs} +1 -1
- package/dist/{TemplateReusePanel-rVuK1kTz.js → TemplateReusePanel-lHLOS9Wn.js} +2 -2
- package/dist/{TemplateReviewPanel-B0ar9_zf.js → TemplateReviewPanel-CJ9PLc48.js} +1 -1
- package/dist/{TemplateReviewPanel-Dn6X9UmY.cjs → TemplateReviewPanel-Dpk7sLcF.cjs} +1 -1
- package/dist/analytics.d.cts +2 -0
- package/dist/analytics.d.ts +2 -0
- package/dist/artifact-integrity.json +99 -91
- package/dist/{assets-DEaz4qsp.js → assets-CqIbfbTr.js} +24 -22
- package/dist/assets-e4YSke8n.cjs +1 -0
- package/dist/auto-YR7a4BtF.js +240 -0
- package/dist/auto-uVBjX1j5.cjs +1 -0
- package/dist/{batch-BfZHN1do.js → batch-WzDIXJAt.js} +1 -1
- package/dist/{batch-CLpELXBl.cjs → batch-z6Aw5GEY.cjs} +1 -1
- package/dist/capabilities-DDwXr_cA.js +103 -0
- package/dist/capabilities-DNLyZdNw.cjs +1 -0
- package/dist/codes.d.cts +2 -0
- package/dist/codes.d.ts +2 -0
- package/dist/component-tree-Ca6YYfHq.js +61 -0
- package/dist/component-tree-DkGLEfZC.cjs +1 -0
- package/dist/config-Dg_o8e7m.cjs +1 -0
- package/dist/{config-BVsJXSqS.js → config-XQ4qrQ7Q.js} +66 -64
- package/dist/designer-BfQSahxq.js +5163 -0
- package/dist/designer-CPPdeM5_.cjs +2 -0
- package/dist/designer.cjs +1 -1
- package/dist/designer.d.cts +53 -0
- package/dist/designer.d.ts +53 -0
- package/dist/designer.js +1 -1
- package/dist/diagnostic-notification-B9K9We3h.cjs +1 -0
- package/dist/diagnostic-notification-qGAYZdkB.js +7 -0
- package/dist/drill-CsdjgkRM.cjs +1 -0
- package/dist/{drill-ByJviLXS.js → drill-DIGsZfyB.js} +11 -11
- package/dist/encoding-BOGq4qYL.js +21 -0
- package/dist/encoding-BYF9ZTl9.cjs +1 -0
- package/dist/{font-loader-Q3bQjmrI.js → font-loader-CzI1GuBc.js} +1 -1
- package/dist/{font-loader-B_UkxpzC.cjs → font-loader-EKLzOJxf.cjs} +1 -1
- package/dist/index.cjs +7 -8
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +865 -834
- package/dist/json-snapshot-D6ioHth9.js +1702 -0
- package/dist/json-snapshot-DknkjvxP.cjs +2 -0
- package/dist/{pdf-CvvrjPQg.cjs → pdf-ByVCb1i6.cjs} +48 -50
- package/dist/{pdf-BwNyeGpt.js → pdf-DJ5S6ukC.js} +2737 -2749
- package/dist/pdf.cjs +1 -1
- package/dist/pdf.d.cts +2 -0
- package/dist/pdf.d.ts +2 -0
- package/dist/pdf.js +2 -2
- package/dist/{plugin-Ca_XZG3l.js → plugin-C2j5_mhx.js} +1 -1
- package/dist/{plugin-DHO7X8z2.cjs → plugin-Dr39GBRG.cjs} +1 -1
- package/dist/prepared-DdrjLC7L.cjs +1 -0
- package/dist/prepared-DqtpvRTn.js +87 -0
- package/dist/progress-BXzlVbIp.js +29 -0
- package/dist/progress-DJBd9Rb9.cjs +1 -0
- package/dist/{progress-D-OTpEav.js → progress-Hc2vxoCs.js} +2 -2
- package/dist/protocol-BzwMP4Vw.cjs +1 -0
- package/dist/protocol-kt4Iy6-3.js +90 -0
- package/dist/{record-bindings-Do_b3h4V.js → record-bindings-CZWBJ1fU.js} +9 -10
- package/dist/record-bindings-DUX1VMlR.cjs +1 -0
- package/dist/{region-binding-workflow-BMhK_TjP.js → region-binding-workflow-CWNvIjkV.js} +1 -1
- package/dist/{region-binding-workflow-DIYJdCUr.cjs → region-binding-workflow-CqSMxQ4p.cjs} +1 -1
- package/dist/report-encoding-worker.cjs +1 -0
- package/dist/report-encoding-worker.d.ts +1 -0
- package/dist/report-encoding-worker.js +2 -0
- package/dist/rich-text-layout-ALlMoYOG.cjs +3 -0
- package/dist/rich-text-layout-Ct5WrY1g.js +102 -0
- package/dist/runtime-BjKBI530.js +168 -0
- package/dist/runtime-CBFEPKEs.cjs +1 -0
- package/dist/sbom.cdx.json +2 -2
- package/dist/server/node.d.cts +86 -1
- package/dist/server/node.d.ts +86 -1
- package/dist/server-node.cjs +5 -1
- package/dist/server-node.js +4558 -473
- package/dist/server.cjs +1 -1
- package/dist/server.d.cts +8 -1
- package/dist/server.d.ts +8 -1
- package/dist/server.js +634 -792
- package/dist/sha256-BshdOkCC.cjs +1 -0
- package/dist/sha256-DTG-Gq8i.js +157 -0
- package/dist/style-67OqfNed.js +73 -0
- package/dist/style-C22Pbv3T.cjs +1 -0
- package/dist/style.css +1 -1
- package/dist/{template-catalog-j2B1MJlL.js → template-catalog-BtR2JmCL.js} +9 -9
- package/dist/{template-catalog-FJE_c9Qe.cjs → template-catalog-C2NLdrwB.cjs} +1 -1
- package/dist/{template-fragments-DcKeiylI.cjs → template-fragments-BVsbxs4a.cjs} +1 -1
- package/dist/{template-fragments-BGbQLGlV.js → template-fragments-By0aZC1D.js} +2 -2
- package/dist/template-registry-C62vpv4a.cjs +1 -0
- package/dist/{template-registry-BtaKPELV.js → template-registry-Cw3vRTX2.js} +389 -321
- package/dist/{textwrap-DE1kgcJB.js → textwrap-BEIg2w8y.js} +1 -1
- package/dist/textwrap-BI-yJ6Wt.cjs +4 -0
- package/dist/vue/async.d.cts +66 -0
- package/dist/vue/async.d.ts +66 -0
- package/dist/vue/index.d.cts +89 -1
- package/dist/vue/index.d.ts +89 -1
- 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-BvToI-Fd.js → workbook-session-BeSO8PFB.js} +153 -140
- package/dist/{workbook-session-Bjv1YCRK.cjs → workbook-session-Cbts-22R.cjs} +12 -12
- package/dist/worker.cjs +1 -1
- package/dist/worker.d.cts +84 -1
- package/dist/worker.d.ts +84 -1
- package/dist/worker.js +12 -157
- package/dist/xlsx-node.cjs +33 -33
- package/dist/xlsx-node.js +1282 -1289
- package/dist/xlsx.cjs +4 -3
- package/dist/xlsx.d.cts +2 -0
- package/dist/xlsx.d.ts +2 -0
- package/dist/xlsx.js +297 -279
- package/package.json +6 -3
- package/dist/ReportPreview-ChV19HBp.js +0 -4619
- package/dist/ReportPreview-DbLvvOUT.cjs +0 -6
- package/dist/assets-B9ImAi6_.cjs +0 -1
- package/dist/batch-BaP6pWDE.cjs +0 -1
- package/dist/batch-CGyt-b2W.js +0 -273
- package/dist/capabilities-CAh2Nrue.cjs +0 -1
- package/dist/capabilities-DskCHs3V.js +0 -69
- package/dist/config-D10us76d.cjs +0 -1
- package/dist/data-explanation-B8MZRYVS.js +0 -16
- package/dist/data-explanation-DE55G30w.cjs +0 -1
- package/dist/defaults-DXhiM1ZD.js +0 -10
- package/dist/defaults-xhmcLLrf.cjs +0 -1
- package/dist/designer-2bDlcNXQ.js +0 -5136
- package/dist/designer-BT7XCdbW.cjs +0 -2
- package/dist/drill-DYTxuL3A.cjs +0 -1
- package/dist/grid-strokes-Cr7DwUux.cjs +0 -1
- package/dist/grid-strokes-DyyG1q_o.js +0 -53
- package/dist/json-snapshot-DFb2eWkf.js +0 -1416
- package/dist/json-snapshot-WWSGlaHG.cjs +0 -2
- package/dist/prepared-CFy9B75C.cjs +0 -1
- package/dist/prepared-ajM-H-9B.js +0 -69
- package/dist/record-bindings-By_UKZ2g.cjs +0 -1
- package/dist/render-plan-7xpGrCEl.cjs +0 -1
- package/dist/render-plan-Ck6koX9L.js +0 -13
- package/dist/sha256-ArEYjaTI.cjs +0 -1
- package/dist/sha256-DPEuJ3nh.js +0 -155
- package/dist/style-CQ1PK8ZB.js +0 -67
- package/dist/style-UgIJSA1F.cjs +0 -1
- package/dist/template-registry-Co1zPq5e.cjs +0 -1
- package/dist/textwrap-CWHyzkBH.cjs +0 -4
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";const z=require("./render-plan-7xpGrCEl.cjs"),K=require("./defaults-xhmcLLrf.cjs"),j=require("./textwrap-CWHyzkBH.cjs"),E=require("./record-bindings-By_UKZ2g.cjs"),de=require("./computed-CGV2a809.cjs"),Ce=require("./matrix-gEO7ZM_u.cjs"),U=require("./tree-BX380Rr7.cjs"),N=require("./template-registry-Co1zPq5e.cjs"),$=require("./style-UgIJSA1F.cjs"),lt=require("./report-params-WDGrA4oP.cjs"),Se=require("./param-validation-C3HlcLLO.cjs"),M=require("./batch-BaP6pWDE.cjs"),dt=require("./data-explanation-DE55G30w.cjs"),ke=require("./dataset-BkRmwgeJ.cjs");function ut(e,t,r){const o=new Set,a=e.cells.map((n,s)=>{const i=[];let c=0;for(const l of n){for(;o.has(`${s}:${c}`);)c++;const d=l?.colSpan??1,f=l?.rowSpan??1;let u=0;for(let g=c;g<c+d;g++){t.has(g)&&u++;for(let h=s+1;h<s+f;h++)o.add(`${h}:${g}`)}u&&i.push(l?{...l,colSpan:u}:null),c+=d}return i});return{...e,cells:a,colWidthsMm:r}}function $e(e){if(!e.columns.some(o=>o.hidden))return e;const t=new Set,r=e.columns.filter((o,a)=>o.hidden?!1:(t.add(a),!0));if(!r.length)throw new Error("列表至少需要一列可见列");return{...e,columns:r,...e.headerGrid?{headerGrid:ut(e.headerGrid,t,r.map(o=>o.widthMm))}:{}}}function*ft(e){const{page:t}=e;N.validateReportPageFlow(t.components,t.flow);let r=0,o=0;for(const a of N.reportFlowGroups(t.components,t.flow)){e.active();const n=a.band,s=a.components.some(d=>d.kind==="list"&&d.cardinality!=="record"),i=s?0:a.components.reduce((d,f)=>Math.max(d,f.topMm-n.topMm+(f.kind==="list"?e.height(f):f.heightMm)),n.heightMm);let c=Math.max(e.top(),o+n.topMm-r);if(!s&&i>e.bottom()-e.top()+.001)throw new Error(`静态区域 ${n.componentIds.join(",")} 高度超出单页可用范围`);!s&&c+i>e.bottom()+.001&&(e.nextPage(),yield*e.takePages(),e.active(),c=e.top());let l=c+i;for(const d of a.components){const f=c+d.topMm-n.topMm;d.kind==="list"?(yield*e.list(d,f,u=>{l=s?u:Math.max(l,u)}),e.active()):e.append({...d,topMm:f})}o=l,r=n.topMm+n.heightMm}}function mt(e){return!!(e.computed?.length||e.groups?.length||e.groupBy||e.grandTotal||e.rowVisibleWhen||e.matrix||e.tree||e.detail||e.columns.some(t=>t.rules?.length||t.visibleWhen))}function X(e){return e.pages.some(t=>t.components.some(r=>r.kind==="list"&&mt(r)))}const gt=512,Re=256*1024;function ht(){const e=new Map;let t=0,r;return(o,a,n,s)=>{s!==r&&(e.clear(),t=0,r=s);const i=JSON.stringify([o,a,n.fontSizePt,n.fontFamily,n.bold,n.italic,n.letterSpacingPt]),c=e.get(i);if(c)return e.delete(i),e.set(i,c),c.lines.slice();const l=j.wrapText(o,a,n,s),d=i.length+l.reduce((f,u)=>f+u.length,0);if(d<=Re){for(;e.size>=gt||t+d>Re;){const f=e.keys().next().value;t-=e.get(f).units,e.delete(f)}e.set(i,{lines:l.slice(),units:d}),t+=d}return l}}class L extends Error{constructor(t,r){super(`报表页数超出上限 ${t}(至少 ${r} 页)`),this.limit=t,this.actual=r,this.code="page-limit",this.name="PaginatePageLimitError"}}class H extends Error{constructor(t,r){super(`报表单元格数量超出上限 ${t}(至少 ${r} 格)`),this.limit=t,this.actual=r,this.code="cell-limit",this.name="PaginateCellLimitError"}}const xe=1e4,Pe=25e4;function ue(e){if(e?.aborted)throw e.reason??new DOMException("标签生成已取消","AbortError")}function Oe(e,t,r){const o=typeof e.copies=="object"?E.readRecordScalar(t,e.copies.field,r):e.copies??1;if(typeof o!="number"||!Number.isSafeInteger(o)||o<1||o>1e3)throw new E.ReportBindingError(`$.datasets.${r.dataset}[${r.rowIndex}]`,"每条记录复制数必须是 1..1000 的数值型整数",r.rowIndex,typeof e.copies=="object"?e.copies.field:void 0);return o}function Fe(e,t,r){if(e.rowKey===void 0)return;const o=E.readRecordScalar(t,e.rowKey,r);if(typeof o=="string"&&o.trim()||typeof o=="number"&&Number.isFinite(o))return o;throw new E.ReportBindingError(`$.datasets.${r.dataset}[${r.rowIndex}].${e.rowKey}`,"业务主键必须是非空字符串或有限数字",r.rowIndex,e.rowKey)}function pt(e){const t=r=>1+(r.grid?.cells.reduce((o,a)=>o+1+a.length+a.reduce((n,s)=>n+(s?.children?.reduce((i,c)=>i+t(c),0)??0),0),0)??0);return e.pages.reduce((r,o)=>r+o.components.reduce((a,n)=>a+t(n),0),0)}function wt(e,t,r){const o=e.repeat,a=Object.prototype.hasOwnProperty.call(t,o.dataset)?t[o.dataset]:void 0;if(!Array.isArray(a))throw new E.ReportBindingError(`$.datasets.${o.dataset}`,"逐记录标签数据集缺失,应提供对象数组(允许空数组)");const n=new Set,s=r.maxPages??xe,i=pt(e);let c=0,l=0;for(const[d,f]of a.entries()){if(ue(r.signal),!f||typeof f!="object"||Array.isArray(f))throw new E.ReportBindingError(`$.datasets.${o.dataset}[${d}]`,"标签记录应为对象",d);const u={rowIndex:d,dataset:o.dataset},g=Fe(o,f,u);if(g!==void 0){const m=JSON.stringify([typeof g,g]);if(n.has(m))throw new E.ReportBindingError(`$.datasets.${o.dataset}[${d}].${o.rowKey}`,"业务主键重复;请先确认记录来源,避免重复打印标签",d,o.rowKey);n.add(m)}const h=Oe(o,f,u);if(c+=h*e.pages.length,l+=h*i,c>s)throw new L(s,c);if(l>Pe)throw new E.ReportBindingError("$.repeat",`标签组件总量(含网格行、槽位及嵌套组件)超过安全预算 ${Pe},请分批生成`,d)}return a}function yt(e,t,r){if(!e.binding)return e;const{binding:o,...a}=e,n=E.resolveComponentBinding(o,t.row,t);if(e.kind==="image"){if(!n)return;if(!E.isLabelImageData(n))throw new E.ReportBindingError(`${r}.binding`,"图片字段只接受 PNG/JPEG base64 data URL;业务 URL 应由宿主安全加载后转换",t.rowIndex,o.field);return{...a,imageData:n}}return e.kind==="barcode"||e.kind==="qrcode"?(delete a.imageData,{...a,code:{...a.code,value:n},fallbackText:n}):(delete a.lines,delete a.richParagraphs,{...a,text:n})}function Mt(e,t,r){if(e.kind!=="text"||e.grid||e.richParagraphs?.length)return e;const o=e.style??{},a=$.resolveFontSize(o).fontSizePt,n=e.text??e.lines?.join(`
|
|
2
|
-
`)??"";if(n.length>16384)throw new E.ReportBindingError(r,"标签文本超过 16384 字符预算,请缩小字段内容",t.rowIndex);const s=t.wrapText(n,e.widthMm,{fontSizePt:a,bold:o.bold,italic:o.italic,fontFamily:o.fontFamily,letterSpacingPt:o.letterSpacing},t.options.measurer??j.heuristicMeasurer),i=s.length*a*$.resolveLineHeight(o)*25.4/72;if(i>e.heightMm+.05)throw new E.ReportBindingError(r,`标签文字需要约 ${i.toFixed(2)}mm 高,超出 ${e.heightMm}mm;请增大文本区域、减少内容或调整字号`,t.rowIndex,e.binding?.field);return{...e,lines:s}}function Ae(e,t,r){ue(t.options.signal);const o=yt(e,t,r);if(!o)return;let a=o.grid;return a&&(a={...a,cells:a.cells.map((n,s)=>n.map((i,c)=>i?.children?.length?{...i,children:i.children.flatMap((l,d)=>{const f=Ae(l,t,`${r}.grid.cells.${s}.${c}.children.${d}`);return f?[f]:[]})}:i))}),Mt(a===o.grid?o:{...o,grid:a},t,r)}function bt(e,t,r,o,a,n){return{...e,components:e.components.flatMap((s,i)=>{const c=Ae(s,r,`$.pages.${t}.components.${i}`);return c?[{...c,meta:{...c.meta,labelSource:{pageIndex:t,componentIndex:i}}}]:[]}),meta:{...e.meta,record:{dataset:r.dataset,rowIndex:r.rowIndex,...n===void 0?{}:{rowKey:n},copyIndex:o,copyCount:a,templatePageIndex:t}}}}function*vt(e,t,r){const o=[];if(N.validateTemplateRepeat(e,o),o.length)throw new E.ReportBindingError(o[0].path,o[0].message);if(!e.repeat){for(const[i,c]of e.pages.entries())yield{page:c,pageIndex:i};return}const a=e.repeat,n=wt(e,t,r),s=ht();for(const[i,c]of n.entries()){const l={row:c,rowIndex:i,dataset:a.dataset,options:r,wrapText:s},d=Oe(a,c,l),f=Fe(a,c,l);for(let u=0;u<d;u++)for(const[g,h]of e.pages.entries())ue(r.signal),yield{page:bt(h,g,l,u,d,f),pageIndex:g}}}function Et(e){return{widthMm:e.widthMm,heightMm:e.heightMm,marginTopMm:e.marginTopMm??0,marginBottomMm:e.marginBottomMm??0,marginLeftMm:e.marginLeftMm??0,marginRightMm:e.marginRightMm??0,components:[]}}function V(e,t){const r=t.heightMm-(e.layout==="wide"?t.marginBottomMm:e.marginBottomMm??t.marginBottomMm);return e.components.reduce((o,a)=>a.kind!=="list"&&a.pageAnchor==="footer"?Math.min(o,a.topMm):o,r)}function _(e){return e.components.reduce((t,r)=>r.kind!=="list"&&r.pageAnchor==="header"?Math.max(t,r.topMm+r.heightMm):t,0)}function Ie(e,t){let r=e.textMetrics.get(t);if(!r){const o=$.resolveFontSize(t).fontSizePt;r={measureOptions:{fontSizePt:o,fontFamily:t.fontFamily??K.DEFAULT_FONT_FAMILY,italic:t.italic,bold:t.bold,letterSpacingPt:t.letterSpacing},lineMm:o*(t.lineHeight??K.LINE_HEIGHT)*25.4/72},e.textMetrics.set(t,r)}return r}function St(e){if(e===null||typeof e=="string"||typeof e=="boolean"||typeof e=="number"&&Number.isFinite(e))return e}function fe(e,t){const r=e.fontSizePt??K.DEFAULT_FONT_PT,o=e.paddingMm??1,a=e.columns.map(m=>m.align??m.style?.align??e.align??"left"),n=e.columns.map((m,w)=>({...$.mergeComponentStyles({fontSize:r,verticalAlign:"middle"},m.style),align:a[w]==="auto"?"left":a[w]})),s=n.map((m,w)=>a[w]==="auto"?{left:m,center:{...m,align:"center"},right:{...m,align:"right"}}:void 0),i=e.columns.map((m,w)=>m.rules?.map(S=>{const R=s[w];if(R)return{left:$.mergeComponentStyles(R.left,S.style),center:$.mergeComponentStyles(R.center,S.style),right:$.mergeComponentStyles(R.right,S.style)};const T=$.mergeComponentStyles(n[w],S.style);return{left:T,center:T,right:T}})),c=e.columns.map(m=>E.resolveListHeaderStyle(e,m)),l=e.columns.map(m=>m.header);let d=e.rowHeightMm??0;for(let m=0;m<l.length;m++){const w=c[m],S=$.resolveFontSize(w).fontSizePt,R=j.wrapText(l[m],e.columns[m].widthMm-o*2,{fontSizePt:S,fontFamily:w.fontFamily??K.DEFAULT_FONT_FAMILY,italic:w.italic,bold:w.bold,letterSpacingPt:w.letterSpacing},t),T=S*(w.lineHeight??K.LINE_HEIGHT)*25.4/72;d=Math.max(d,Math.max(R.length,1)*T+o*2)}const f=l.map((m,w)=>({text:m,style:c[w]})),u=e.border===!1?{borderTop:!1,borderRight:!1,borderBottom:!1,borderLeft:!1}:{borderBottom:!0,borderLeft:!0,borderRight:!0,borderTop:!0},g=e.columns.map(m=>m.widthMm),h=Rt(e.headerGrid,g,{cells:[f],colWidthsMm:g,rowHeightsMm:[d],paddingMm:o});return{fontSizePt:r,paddingMm:o,cellStyles:n,autoStyles:s,ruleStyles:i,textMetrics:new WeakMap,numberFormats:e.columns.map(m=>E.toExcelNumberFormat(m.format)),derivedFields:new Set(e.computed?.map(m=>m.field)),borderStyle:u,headerHeightMm:h.rowHeightsMm.reduce((m,w)=>m+w,0),headerGrid:h,colWidthsMm:g,columns:e.columns}}function Rt(e,t,r){if(!e)return r;if(!e.cells.length)throw new Error("自定义列表表头至少需要一行");const o=e.rowHeightsMm??e.cells.map(()=>r.rowHeightsMm[0]);if(o.length!==e.cells.length||o.some(a=>!Number.isFinite(a)||a<=0))throw new Error("自定义列表表头行高无效");return{...e,colWidthsMm:t,rowHeightsMm:o}}function Pt(e,t,r){const o=t.format?.kind==="number"||t.format?.kind==="percent";t.valueType!==void 0?e.valueType=t.valueType:o&&(e.valueType="number"),t.editable!==void 0&&(e.editable=t.editable),(typeof e.value=="number"||e.value==null)&&r!==void 0&&(e.numberFormat=r)}function G(e,t,r){const o=e.columns,a=e.tree?.rows.get(t);let n=e.rowHeightFloorMm;const s=new Array(o.length);for(let i=0;i<o.length;i++){const c=o[i],l=c.visibleWhen&&!E.evalStyleRule(t,c.visibleWhen)?null:t[c.field],d=e.autoStyles[i]?E.resolveListAutoAlignment(l,c.format,c.semanticRole):"left";let f=e.autoStyles[i]?.[d]??e.cellStyles[i];if(c.rules)for(let R=0;R<c.rules.length;R++){const T=c.rules[R];if(E.evalStyleRule(t,T.when)){f=e.ruleStyles[i][R][d];break}}const u=c.format?E.formatValue(l,c.format):E.listCellText(l),g=Tt(e,c,a);f=Ct(e,c,f,a);const h=Ie(e,f),m=j.wrapText(u,Math.max(1,c.widthMm-e.paddingMm*2-g),h.measureOptions,r);n=Math.max(n,m.length*h.lineMm+e.paddingMm*2);const w=St(l),S={text:u,style:f};w!==void 0&&(S.value=w),Pt(S,c,e.numberFormats[i]),kt(S,c,e,a,g),e.derivedFields.has(c.field)&&(S.derived=!0,S.editable=!1),c.visibleWhen&&l===null&&!E.evalStyleRule(t,c.visibleWhen)&&(S.editable=!1),s[i]=S}return{grid:{cells:[s],colWidthsMm:e.colWidthsMm,rowHeightsMm:[n],paddingMm:e.paddingMm},heightMm:n}}function Tt(e,t,r){return!r||t.field!==e.tree.list.tree.labelField?0:E.listTreeIndent(e.tree.list,t,r,e.paddingMm)}function Ct(e,t,r,o){return!o||t.field!==e.tree.list.tree.labelField||r.align==="left"?r:{...r,align:"left"}}function kt(e,t,r,o,a=0){o&&(a&&(e.indentMm=a),E.applyListTreeMetadata(e,t,o,r.tree.list))}function Le(e){if(e!=null&&typeof e!="string"&&typeof e!="boolean"&&!(typeof e=="number"&&Number.isFinite(e)))throw new Error("分组字段应为有限 JSON 标量");return JSON.stringify([typeof e,e??null])}function*Ne(e,t,r=0){const o=t[r];if(!o){for(const n of e)yield{kind:"row",row:n};return}const a=new Map;for(const n of e){const s=Le(n[o.field]),i=a.get(s);i?i.push(n):a.set(s,[n])}for(const n of a.values())yield{kind:"groupHeader",label:(o.headerTemplate??"{value}").replace(/\{value\}/g,E.listCellText(n[0][o.field])),firstRow:n[0],group:o,depth:r,rows:n},yield*Ne(n,t,r+1),(o.subtotal?.length||o.aggregates?.length)&&(yield{kind:"subtotal",label:o.subtotalLabel??"小计",rows:n,group:o,depth:r}),yield{kind:"groupEnd",depth:r}}function He(e,t,r,o=[]){const a=[...r.filter(n=>!o.some(s=>s.field===n)).map(n=>({field:n,op:"sum"})),...o];return new Map(a.map(n=>{const s=e.find(c=>c.field===n.field)?.format??{kind:"number",thousands:!0},i=de.aggregateRows(t,{...n,field:n.valueField??n.field});return[n.field,{text:E.formatValue(i,s),...i===null?{}:{value:i},...typeof i=="number"?{numberFormat:E.toExcelNumberFormat(s)}:{}}]}))}function je(e,t){const r=e.findIndex(o=>t.includes(o.field));return r<0?1:r}function B(e,t,r,o,a,n){const s=[],i=Math.max(0,Math.min(n,e.columns.length)),c=$.mergeComponentStyles({fontSize:e.fontSizePt},a);i&&s.push({text:r,colSpan:i,style:{bold:!0,...c}});for(let u=i;u<e.columns.length;u++){const g=e.columns[u],h=o.get(g.field),m=e.autoStyles[u]?.[E.resolveListAutoAlignment(h?.value,g.format)]??e.cellStyles[u];s.push({...h,text:h?.text??"",style:$.mergeComponentStyles(m,a)})}const l={text:r,colSpan:e.columns.length,style:{bold:!0,...c}},d=i?[s]:[[l],s],f=d.map(u=>$t(e,u,t));return{grid:{cells:d,colWidthsMm:e.colWidthsMm,rowHeightsMm:f,paddingMm:e.paddingMm},heightMm:f.reduce((u,g)=>u+g,0)}}function $t(e,t,r){let o=e.rowHeightFloorMm,a=0;for(const n of t){let s=0;const i=a+(n.colSpan??1);for(;a<i;a++)s+=e.colWidthsMm[a]??0;const c=Ie(e,n.style),l=j.wrapText(n.text??"",s-e.paddingMm*2,c.measureOptions,r);o=Math.max(o,l.length*c.lineMm+e.paddingMm*2)}return o}function xt(e,t,r){const{templatePage:o,current:a,warnings:n,nextId:s,pushCurrent:i}=r,c=()=>V(o,a),l=Math.max(a.marginTopMm,_(o)),d=o.layout==="wide"?_(o):l,f={id:r.tableId,columnKeys:e.columns.map(p=>p.field),...e.layout===void 0?{}:{layout:e.layout},...e.title===void 0?{}:{title:e.title}},u=new Map,g=new Map,h={kind:"rect",leftMm:e.leftMm,topMm:0,widthMm:e.widthMm,heightMm:t.headerHeightMm,grid:t.headerGrid,nid:s("listh"),table:{...f,role:"header",rowIndex:-1},style:t.borderStyle,...e.meta?{meta:e.meta}:{}},m=p=>a.components.push({...h,topMm:p});if(r.flow&&e.header!==!1&&t.headerHeightMm>c()-l+.001)throw new Error(`流式列表 ${e.id??e.dataset} 的表头高度超出单页可用范围`);let w=Math.max(r.startTop??e.topMm,l);e.header!==!1&&(m(w),w+=t.headerHeightMm+r.mmPerRow);function S(){const p=Math.max(r.flow||o.layout==="wide"?0:e.topMm,d);return(e.header!==!1&&e.headerEveryPage!==!1?p+t.headerHeightMm:d)+[...g.values()].reduce((v,C)=>v+C.heightMm,0)}function R(){const p=o.layout==="wide"?0:a.marginBottomMm;return Math.min(o.heightMm-p,V(o,a))-S()}function T(p){if(w+p<=c())return;i(),a.components=[],a.heightMm=o.heightMm,o.layout==="wide"&&(a.marginTopMm=0,a.marginBottomMm=0);const y=Math.max(r.flow||o.layout==="wide"?0:e.topMm,d);e.header!==!1&&e.headerEveryPage!==!1?(m(y),w=y+t.headerHeightMm):w=d;for(const v of g.values())I(v,"listgr","group-header")}function b(p,y,v,C){const k=R();if(r.flow&&p.heightMm>k+.001)throw new Error(`流式列表 ${e.id??e.dataset} 的单行高度超出单页可用范围`);p.heightMm>k&&n.push(`列表 ${e.id??e.dataset} 行高 ${p.heightMm.toFixed(2)}mm 超出单页可用高度 ${k.toFixed(2)}mm,预览与打印可能截断内容`),T(p.heightMm),I(p,y,v,C)}function I(p,y,v,C){const k=p.table?.id??f.id,A=v==="header"?-1:u.get(k)??0;v!=="header"&&u.set(k,A+p.grid.cells.length),a.components.push({kind:"rect",leftMm:e.leftMm,topMm:w,widthMm:e.widthMm,heightMm:p.heightMm,grid:p.grid,nid:s(y),table:{...f,...p.table,role:v,rowIndex:A,...C?{source:C}:{}},style:t.borderStyle,...e.meta?{meta:e.meta}:{}}),w+=p.heightMm}function F(p){p<=R()&&T(p)}return{keepTogether:F,placeGridRow:b,setGroupHeader:(p,y)=>{y?g.set(p,y):g.delete(p)},bottom:()=>w}}function Ot(e,t){if(!e.rowKey)return;const r=t[e.rowKey];if((typeof r!="string"||!r.trim())&&!(typeof r=="number"&&Number.isFinite(r)))throw new Error(`数据集 ${e.dataset} 的 ${e.rowKey} 应为稳定的字符串或有限数字主键`);const o=e.revisionField?t[e.revisionField]:void 0,a=e.sourceTokenField?t[e.sourceTokenField]:void 0;if(o!==void 0&&typeof o!="string"&&!(typeof o=="number"&&Number.isFinite(o)))throw new Error("业务修订号应为字符串或有限数字");if(a!==void 0&&typeof a!="string")throw new Error("来源令牌应为字符串");return{datasetId:e.dataset,rowKey:r,...o===void 0?{}:{revision:o},...a===void 0?{}:{sourceToken:a}}}function Y(e,t){const r=new Map;if(!e.rowKey)return r;const o=new Set;for(const a of t){const n=Ot(e,a),s=JSON.stringify(n.rowKey);if(o.has(s))throw new Error(`数据集 ${e.dataset} 的业务主键重复:${String(n.rowKey)}`);o.add(s),r.set(a,n)}return r}function Ft(e,t,r,o,a){if(!e.grandTotal)return;const n=typeof e.grandTotal=="object"?e.grandTotal:void 0,s=Q(e)[0],i=n?.fields??s?.subtotal??[],c=n?.aggregates??s?.aggregates??[];if(i.length===0&&c.length===0){o.warnings.push(`列表 ${e.id??""} 配置了 grandTotal 但未提供合计字段(groupBy.subtotal 或 grandTotal.fields)`);return}const l=B(r,o.measurer,n?.label??"合计",He(e.columns,t,i,c),n?.style??{},je(e.columns,[...i,...c.map(d=>d.field)]));a.placeGridRow(l,"listgt","grand-total")}function W(e){if(e?.aborted){const t=new Error("报表排版已取消");throw t.name="AbortError",t}}function Q(e){const t=e.groups??(e.groupBy?[e.groupBy]:[]);if(t.length>16)throw new Error("列表最多支持 16 级分组");return t}function me(e){const t=$e(e),r=t.columns.reduce((a,n)=>a+n.widthMm,0),o=r>t.widthMm?t.widthMm/r:1;return o===1?t:{...t,columns:t.columns.map(a=>({...a,widthMm:a.widthMm*o}))}}function At(e,t,r){const o=e.detail;if(!o)return;const a=new Set;for(const l of t){const d=ae(l[o.parentKey]);if(a.has(d))throw new Error("主从明细的主表关联键重复");a.add(d)}const n=r.datasets[o.dataset]??[],s=new Map,i=[];for(const l of n){const d=l[o.foreignKey];if(!De(d)&&o.unmatched==="ignore")continue;const f=ae(d);if(!a.has(f)){if(o.unmatched!=="ignore")throw new Error(`明细数据集 ${o.dataset} 存在未关联的业务键`);continue}const u=s.get(f);u?u.push(l):s.set(f,[l]),i.push(l)}const c=me({...e,id:`${e.id??e.dataset}:detail`,dataset:o.dataset,rowKey:o.rowKey,revisionField:o.revisionField,sourceTokenField:o.sourceTokenField,computed:void 0,columns:o.columns,headerGrid:void 0,rowHeightMm:o.rowHeightMm??e.rowHeightMm,detail:void 0});return{list:c,inter:{...fe(c,r.measurer),rowHeightFloorMm:c.rowHeightMm??0},rows:s,sources:Y(c,i)}}function De(e){return typeof e=="string"&&!!e.trim()||typeof e=="number"&&Number.isFinite(e)}function ae(e){if(!De(e))throw new Error("主从关联键必须是非空字符串或有限数字");return Le(e)}function*It(e,t,r,o,a){if(!r)return;const n=r.rows.get(ae(t[e.detail.parentKey]))??[];if(!n.length)return;const s={id:`${o.tableId}:detail`,columnKeys:r.list.columns.map(i=>i.field),title:e.detail.label};e.detail.label&&a.placeGridRow({...B(r.inter,o.measurer,e.detail.label,new Map,{},r.list.columns.length),table:s},"listdl","group-header"),e.detail.header!==!1&&a.placeGridRow({grid:r.inter.headerGrid,heightMm:r.inter.headerHeightMm,table:s},"listdh","header"),yield*o.takePages();for(const i of n)W(o.signal),a.placeGridRow({...G(r.inter,i,o.measurer),table:s},"listdr","body",r.sources.get(i)),yield*o.takePages()}function Lt(e,t){if(!e.matrix)return{list:e,rows:t};if(e.detail||e.groupBy||e.groups?.length||e.grandTotal)throw new Error("矩阵不能同时配置普通分组、总计或主从明细");const r=Ce.createMatrixTable(t,e.matrix),o=r.columns.map((n,s)=>({...n,widthMm:s===0?e.matrix.rowWidthMm??40:e.matrix.columnWidthMm??28,editable:!1,align:s===0?"center":"right"})),a={...e,columns:o,headerGrid:void 0,rowKey:void 0,revisionField:void 0,sourceTokenField:void 0};return e.layout==="wide"&&(a.widthMm=o.reduce((n,s)=>n+s.widthMm,0)),{list:a,rows:r.rows}}function Ke(e){if(e.matrix||e.detail||e.groups?.length||e.groupBy||e.rowVisibleWhen)throw new Error("树形布局不能同时配置普通分组、矩阵、主从或行可见条件");if(e.rowKey&&e.rowKey!==e.tree.idField)throw new Error("树形布局的 rowKey 应与 idField 一致");if(!e.columns.some(t=>t.field===e.tree.labelField&&!t.hidden))throw new Error("树形布局需要可见的标签列");U.validateTreeComputed(e.tree,e.computed)}function Nt(e,t,r){Ke(e);const o=U.createTreeTable(t,e.tree,{signal:r.signal,computed:e.computed?.length?{fields:e.computed,formula:r.formula}:void 0}),a={...e,rowKey:e.tree.idField},n=Y(a,o.entries.map(c=>c.original)),s=new Map,i=new WeakMap;for(const c of o.entries)s.set(c.row,n.get(c.original)),i.set(c.row,c);return{list:a,rows:o.rows,sources:s,treeRows:i,totalRows:o.leaves}}function Ht(e,t){if(e.cardinality==="record"){if(t.length>1)throw new Error(`单记录区域 ${e.id??e.dataset} 仅允许 0 或 1 行数据`);if(e.tree||e.matrix||e.detail||e.groups?.length||e.groupBy||e.grandTotal||e.rowVisibleWhen)throw new Error("单记录区域不能配置树、矩阵、主从、分组、总计或行过滤");if(!t.length)return{list:{...e,columns:e.columns.map(r=>({...r,editable:!1}))},rows:[{}],sources:new Map}}}function Be(e,t,r){const o=r.prepared.get(e);if(o)return o;const a=Ht(e,t);if(a)return r.prepared.set(e,a),a;if(e.tree){const c=Nt(e,t,r);return r.prepared.set(e,c),c}let n=e.computed?.length?de.computeDataset(t,{fields:e.computed,signal:r.signal,formula:r.formula}).rows:t;const s=n===t?void 0:new Map(n.map((c,l)=>[c,t[l]]));e.rowVisibleWhen&&(n=n.filter(c=>E.evalStyleRule(c,e.rowVisibleWhen)));const i=Lt(e,n);if(!e.matrix){const c=Y(e,s?n.map(l=>s.get(l)):n);i.sources=s?new Map(n.map(l=>[l,c.get(s.get(l))])):c}return r.prepared.set(e,i),i}function jt(e,t,r,o){if(!o.flow)return;const{current:a,templatePage:n}=o,s=Math.max(a.marginTopMm,_(n)),i=Math.max(o.startTop??e.topMm,s),c=(e.header===!1?0:t.headerHeightMm)+(r[0]?G(t,r[0],o.measurer).heightMm:0);i+c<=V(n,a)+.001||i<=s+.001||(o.pushCurrent(),a.components=[],a.heightMm=n.heightMm,n.layout==="wide"&&(a.marginTopMm=0,a.marginBottomMm=0),o.startTop=Math.max(a.marginTopMm,_(n)))}function*Dt(e,t,r){const o=Be(e,t,r),a=o.rows;e=o.list,e.layout==="wide"&&(r.current.widthMm=Math.max(r.current.widthMm,e.leftMm+e.widthMm+r.current.marginRightMm));const n=o.sources??Y(e,a),s=me(e),i=Q(s),c={...fe(s,r.measurer),rowHeightFloorMm:s.rowHeightMm??0,...o.treeRows?{tree:{list:s,rows:o.treeRows}}:{}};jt(s,c,a,r);const l=xt(s,c,r),d=At(s,a,r);let f;for(const u of Ne(a,i)){if(W(r.signal),u.kind==="row")l.placeGridRow(f??G(c,u.row,r.measurer),"listr","body",n.get(u.row)),f=void 0,yield*r.takePages(),yield*It(s,u.row,d,r,l);else if(u.kind==="groupHeader"){const g=B(c,r.measurer,u.label,new Map,u.group.headerStyle??{},s.columns.length);f??=G(c,u.firstRow,r.measurer);const h=i.slice(u.depth+1).reduce((m,w)=>m+B(c,r.measurer,(w.headerTemplate??"{value}").replace(/\{value\}/g,E.listCellText(u.firstRow[w.field])),new Map,w.headerStyle??{},s.columns.length).heightMm,0);u.group.keepWithNext!==!1&&l.keepTogether(g.heightMm+h+f.heightMm),l.placeGridRow(g,"listg","group-header"),u.group.repeatHeader&&l.setGroupHeader(u.depth,g)}else if(u.kind==="subtotal"){const g=u.group.subtotal??[],h=u.group.aggregates??[],m=B(c,r.measurer,u.label,He(s.columns,u.rows,g,h),u.group.subtotalStyle??{},je(s.columns,[...g,...h.map(w=>w.field)]));l.placeGridRow(m,"listst","subtotal")}else l.setGroupHeader(u.depth);yield*r.takePages()}Ft(s,o.totalRows??a,c,r,l),r.finished?.(l.bottom()),yield*r.takePages()}function Z(e){return e.kind!=="list"&&(e.pageAnchor!==void 0||e.kind==="text"&&typeof e.text=="string"&&(e.text.includes("{page}")||e.text.includes("{totalPages}")))}function ee(e,t){return{...e,...e.text===void 0?{}:{text:t(e.text)},...e.lines?{lines:e.lines.map(t)}:{},...e.richParagraphs?{richParagraphs:e.richParagraphs.map(r=>({...r,segments:r.segments.map(o=>({...o,...o.text===void 0?{}:{text:t(o.text)}}))}))}:{},...e.grid?{grid:{...e.grid,cells:e.grid.cells.map(r=>r.map(o=>o?{...o,...o.text===void 0?{}:{text:t(o.text)},...o.children?{children:o.children.map(a=>ee(a,t))}:{}}:null))}}:{}}}function Kt(e){let t=!1;for(const r of e.pages)for(const o of r.components)Z(o)&&ee(o,a=>(a.includes("{totalPages}")&&(t=!0),a));return t}function Bt(e,t,r,o,a,n){const s={pageWidthMm:t.widthMm,pageHeightMm:t.heightMm,...e.layout===void 0?{}:{layout:e.layout},marginTopMm:t.marginTopMm,marginBottomMm:t.marginBottomMm,marginLeftMm:t.marginLeftMm,marginRightMm:t.marginRightMm,components:t.components,...e.meta?{meta:e.meta}:{}},i=c=>{const l=c.replace(/\{page\}/g,String(o));return n===void 0?l:l.replace(/\{totalPages\}/g,String(n))};for(const c of r)s.components.push(ee(c,i));if(e.layout==="wide"){const c=s.components.reduce((l,d)=>Math.max(l,d.topMm+d.heightMm),0);s.marginBottomMm=a?e.marginBottomMm??0:0,s.pageHeightMm=Math.max(1,c+s.marginBottomMm)}return s}function ge(e){return e.cells.reduce((t,r)=>t+r.reduce((o,a)=>o+(a?1+(a.children?.reduce((n,s)=>n+_e(s),0)??0):0),0),0)}function _e(e){return e.grid?ge(e.grid):0}function he(e){for(const t of["maxPages","maxCells","knownTotalPages"])if(e[t]!==void 0&&(!Number.isSafeInteger(e[t])||e[t]<1))throw new RangeError(`${t} 应为正安全整数`)}function _t(e,t){const r=Be(e,t.datasets[e.dataset]??[],t),o=me(r.list),a={...fe(o,t.measurer),rowHeightFloorMm:o.rowHeightMm??0};return(o.header===!1?0:a.headerHeightMm)+r.rows.reduce((n,s)=>n+G(a,s,t.measurer).heightMm,0)}function*Gt(e){const{templatePage:t,current:r}=e,o=new Map(t.components.map((n,s)=>[n,s])),a=(n,s,i)=>{const c=e.datasets[n.dataset];return Array.isArray(c)||e.warnings.push(`数据集 ${n.dataset} 未提供数据,列表 ${n.id??""} 输出为空`),Dt(n,Array.isArray(c)?c:[],{...e,tableId:`${e.tableId}:${o.get(n)}`,startTop:s,finished:i,flow:!!t.flow})};if(t.flow){yield*ft({page:t,active:()=>W(e.signal),top:()=>Math.max(r.marginTopMm,_(t)),bottom:()=>V(t,r),append:n=>{r.components.push(n)},nextPage:()=>{e.pushCurrent(),r.components=[],r.heightMm=t.heightMm,t.layout==="wide"&&(r.marginTopMm=0,r.marginBottomMm=0)},takePages:e.takePages,height:n=>_t(n,e),list:a});return}for(const n of t.components)Z(n)||(n.kind==="list"?yield*a(n):r.components.push(n))}function*J(e,t,r,o,a,n=new WeakMap){let s=0,i=0,c=0;const l=d=>`${d}_${(++s).toString(36)}`;for(const{pageIndex:d,page:f}of vt(e,t,r)){W(r.signal);const u=Et(f),g=f.components.filter(Z);let h=[];const m=(S=!1)=>{if(W(r.signal),r.maxPages!==void 0&&i>=r.maxPages)throw new L(r.maxPages,i+1);if(r.maxCells!==void 0&&(c+=[...u.components,...g].reduce((R,T)=>R+_e(T),0),c>r.maxCells))throw new H(r.maxCells,c);h.push(Bt(f,u,g,++i,S,a))},w=()=>{const S=h;return h=[],S};yield*Gt({templatePage:f,current:u,warnings:o,nextId:l,pushCurrent:m,takePages:w,datasets:t,signal:r.signal,formula:r.formula,prepared:n,measurer:r.measurer??j.heuristicMeasurer,mmPerRow:r.mmPerRow??0,tableId:`table:${d}`}),m(!0),yield*w()}}function Wt(e,t,r={}){he(r);let o=0;for(const a of J(e,t,{...r,onWarning:void 0},[]))o++;return o}function*Ge(e,t,r={}){he(r);const o=Kt(e),a=new WeakMap;let n=r.knownTotalPages;if(o&&n===void 0){n=0;for(const c of J(e,t,r,[],void 0,a))n++}const s=[];let i=0;for(const c of J(e,t,r,s,n,a)){for(;i<s.length;i++)r.onWarning?.(s[i]);yield c}}function pe(e,t,r={}){const o=typeof r=="number"?{mmPerRow:r}:r;he(o);const a=[],n=[...J(e,t,o,a,o.knownTotalPages)];for(const s of n)s.components=s.components.map(i=>Z(i)?ee(i,c=>c.replace(/\{totalPages\}/g,String(n.length))):i);return a.forEach(s=>o.onWarning?.(s)),{plan:{schemaVersion:z.RENDER_PLAN_SCHEMA_VERSION,...X(e)?{requiresRecalculation:!0}:{},pages:n},warnings:a}}function qt(e){const t=e.columns.find(n=>!n.hidden)?.field;if(!t)return{groups:0,total:0};const r=Q(e),o=(n=[],s=[])=>n.includes(t)||s.some(i=>i.field===t),a=typeof e.grandTotal=="object"?e.grandTotal:void 0;return{groups:r.filter(n=>o(n.subtotal,n.aggregates)).length,total:Number(o(a?.fields??r[0]?.subtotal,a?.aggregates??r[0]?.aggregates))}}function Vt(e,t,r){Ke(e);const o=U.flattenTreeInput(t[e.dataset]??[],e.tree,r),a=e.columns.filter(s=>!s.hidden).length,n=e.header===!1?0:e.headerGrid?ge(e.headerGrid):a;return o.length*a+n+ +!!e.grandTotal*2*a}function Jt(e,t,r={}){if(e.tree)return Vt(e,t,r.signal);if(e.matrix){let c=t[e.dataset]??[];e.computed?.length&&(c=de.computeDataset(c,{fields:e.computed,...r}).rows),e.rowVisibleWhen&&(c=c.filter(d=>E.evalStyleRule(d,e.rowVisibleWhen)));const l=Ce.estimateMatrixTable(c,e.matrix);return l.cells+l.columnCount}const o=t[e.dataset]?.length??0,a=e.columns.filter(c=>!c.hidden).length,n=Q(e).length,s=qt(e);let i=(o*(1+2*n+s.groups)+ +!!e.grandTotal*(1+s.total))*a;if(i+=e.header===!1?0:e.headerGrid?ge(e.headerGrid):a,e.cardinality==="record"&&o===0&&(i+=a),e.detail){const c=t[e.detail.dataset]?.length??0,l=e.detail.columns.filter(d=>!d.hidden).length;i+=(c+o*(+(e.detail.header!==!1)+ +!!e.detail.label))*l}if(!Number.isSafeInteger(i))throw new RangeError("报表单元格估算超出安全整数预算");return i}function We(e){const t=[];for(const r of e.template.pages)for(const o of r.components)o.kind==="list"&&(t.push(o.tree?{...o,rowKey:o.tree.idField}:o),o.detail&&t.push({...o.detail,relation:{detail:o.detail,parentRows:e.datasets[o.dataset]??[]}}));return t}function D(e){return JSON.stringify([e.sourceScope,e.datasetId])}function Te(e){return JSON.stringify([e.sourceScope,e.datasetId,e.rowKey])}function qe(e){const t=new Map,r=new Set;return e.forEach((o,a)=>{for(const n of We(o)){if(!n.rowKey)continue;const s=n.relation,i=s?new Set(s.parentRows.map(c=>JSON.stringify(c[s.detail.parentKey]))):void 0;(o.datasets[n.dataset]??[]).forEach((c,l)=>{if(s&&!i.has(JSON.stringify(c[s.detail.foreignKey])))return;const d=c[n.rowKey];if(typeof d!="string"&&typeof d!="number")return;const f=`${a}:${n.dataset}:${l}:${n.rowKey}`;if(r.has(f))return;r.add(f);const u=Te({sourceScope:o.sourceScope,datasetId:n.dataset,rowKey:d}),g=t.get(u)??[];g.push({partIndex:a,dataset:n.dataset,rowIndex:l,row:c,binding:n}),t.set(u,g)})}}),o=>{const a=t.get(Te(o));if(!a?.length)throw new M.ReportCellEditError("missing");if(new Set(a.map(n=>`${n.partIndex}:${n.dataset}`)).size!==a.length)throw new M.ReportCellEditError("conflict");return a}}function Ve(e,t){const r=e.map(a=>({...a,datasets:{...a.datasets}})),o=new Set;for(const{row:a,field:n,value:s}of t){const i=r[a.partIndex],c=`${a.partIndex}:${a.dataset}`;o.has(c)||(i.datasets[a.dataset]=[...i.datasets[a.dataset]],o.add(c)),i.datasets[a.dataset][a.rowIndex]={...i.datasets[a.dataset][a.rowIndex],[n]:s}}return r}function zt(e,t,r){const o=[],a=new Set;return e.forEach((n,s)=>{for(const i of We(n))t.has(D({sourceScope:n.sourceScope,datasetId:i.dataset}))&&(n.datasets[i.dataset]??[]).forEach((c,l)=>{const d={partIndex:s,dataset:i.dataset,rowIndex:l,row:c,binding:i};for(const[f,u]of[[i.revisionField,r.revision],[i.sourceTokenField,r.sourceToken]]){if(!f||u===void 0)continue;const g=`${s}:${i.dataset}:${l}:${f}`;a.has(g)||(a.add(g),o.push({row:d,field:f,value:u}))}})}),o}function Je(e,t,r){if(!r||r.revision===void 0&&r.sourceToken===void 0)return e;const o=new Set(t.edits.flatMap(a=>a.source?[D(a.source)]:[]));return we(e,new Map([...o].map(a=>[a,r])))}function we(e,t){if(!t.size)return e;function r(n){const s=n.datasetId&&t.get(D({...n,datasetId:n.datasetId}));return!s||(s.revision===void 0||Object.is(s.revision,n.revision))&&(s.sourceToken===void 0||s.sourceToken===n.sourceToken)?n:{...n,...s.revision!==void 0?{revision:s.revision}:{},...s.sourceToken!==void 0?{sourceToken:s.sourceToken}:{}}}function o(n){const s=n.map(i=>{const c=i.table?.source?r(i.table.source):void 0,l=i.table&&c!==i.table.source?{...i.table,source:c}:i.table,d=i.grid?.cells.map(u=>{const g=u.map(h=>{if(!h)return h;const m=h.source?r(h.source):void 0,w=h.children?o(h.children):void 0;return m===h.source&&w===h.children?h:{...h,source:m,children:w}});return g.some((h,m)=>h!==u[m])?g:u}),f=i.grid&&d?.some((u,g)=>u!==i.grid.cells[g])?{...i.grid,cells:d}:i.grid;return l!==i.table||f!==i.grid?{...i,table:l,grid:f}:i});return s.some((i,c)=>i!==n[c])?s:n}const a=e.pages.map(n=>{const s=o(n.components);return s!==n.components?{...n,components:s}:n});return a.some((n,s)=>n!==e.pages[s])?{...e,pages:a}:e}function ze(e){const t=new Map,r=M.createReportCellResolver(e);return e.pages.forEach((o,a)=>o.components.forEach((n,s)=>{if(!(!n.grid||n.table?.role!=="body"))for(let i=0;i<n.grid.cells.length;i++)for(let c=0;c<n.table.columnKeys.length;c++){const l=r({pageIndex:a,componentIndex:s,rowIndex:i,columnIndex:c});l?.source&&l.editable&&t.set(M.reportCellEditKey(l),l)}})),t}function Ut(e,t,r){const o=ze(e),a=M.createReportCellResolver(e);return t.map(n=>{const s=n.source?o.get(M.reportCellEditKey(n)):a(n.address);if(!s||M.reportCellEditKey(s)!==M.reportCellEditKey(n))throw new M.ReportCellEditError("missing");return{address:{...s.address},value:n[r]}})}function Ue(e,t){if(++e.nodes>1e6||t>128)throw new M.ReportCellEditError("limit")}function ye(e,t){const r=Object.getOwnPropertyDescriptor(e,t);if(!r||r.get||r.set)throw new M.ReportCellEditError("conflict");return r.value}function Xe(e){if(Object.getOwnPropertyDescriptor(e,"toJSON"))throw new M.ReportCellEditError("conflict");const t=Object.getPrototypeOf(e);if(!(e instanceof Date)&&!Array.isArray(e)&&t!==Object.prototype&&t!==null)throw new M.ReportCellEditError("conflict");for(const r of Reflect.ownKeys(e))if(!(Array.isArray(e)&&r==="length")){if(typeof r=="symbol"||!Object.getOwnPropertyDescriptor(e,r)?.enumerable)throw new M.ReportCellEditError("conflict");if(e instanceof Date||Array.isArray(e)&&!/^(0|[1-9]\d*)$/.test(r))throw new M.ReportCellEditError("conflict")}}function Ye(e,t,r,o,a){if(Ue(o,a),typeof e=="function"||typeof e=="symbol")throw new M.ReportCellEditError("conflict");if(e===null||typeof e!="object")return;if(Xe(e),r.has(e))throw new M.ReportCellEditError("conflict");r.add(e);const n=Object.keys(e),s=n.map(i=>ye(e,i));t.push({object:e,prototype:Object.getPrototypeOf(e),keys:n,values:s,...e instanceof Date?{date:Date.prototype.getTime.call(e)}:{},...Array.isArray(e)?{length:e.length}:{}});for(const i of s)Ye(i,t,r,o,a+1);r.delete(e)}function Xt(e){const{object:t,keys:r,values:o}=e;if(Xe(t),Object.getPrototypeOf(t)!==e.prototype||Object.getOwnPropertyDescriptor(t,"toJSON")||e.date!==void 0&&!Object.is(Date.prototype.getTime.call(t),e.date)||e.length!==void 0&&t.length!==e.length)return!1;const a=Object.keys(t);return a.length===r.length&&r.every((n,s)=>a[s]===n&&Object.is(ye(t,n),o[s]))}function Yt(e){const t=[];return Ye(e,t,new Set,{nodes:0},0),()=>{try{return t.every(Xt)}catch{return!1}}}function se(e,t,r){return Ue(t,r),e===null||typeof e!="object"?e:e instanceof Date?new Date(Date.prototype.getTime.call(e)):Array.isArray(e)?e.map(o=>se(o,t,r+1)):Object.fromEntries(Object.keys(e).map(o=>[o,se(ye(e,o),t,r+1)]))}function Qt(e){return se(e,{nodes:0},0)}async function Qe(e,t,r={}){const o=[],a={...r,knownTotalPages:void 0};for(const n of Ge(e,t,a))o.push(n),o.length%8===0&&await new Promise(s=>setTimeout(s,0));if(r.signal?.aborted){const n=new Error("报表重算已取消");throw n.name="AbortError",n}return{schemaVersion:z.RENDER_PLAN_SCHEMA_VERSION,...X(e)?{requiresRecalculation:!0}:{},pages:o}}const ie=new WeakMap;function Zt(e){return ie.get(e)}function q(e){if(e?.aborted){const t=new Error("报表重算已取消");throw t.name="AbortError",t}}function Ze(e,t){return e[t]===void 0?"":e[t]}function er(e,t){if(t.edits.length>1e4)throw new M.ReportCellEditError("limit");const r=M.createReportCellResolver(e),o=new Set,a=[],n=t.edits.map(s=>{const i=r(s.address);if(!i?.source)throw new M.ReportCellEditError("missing");const c=M.reportCellEditKey(s);if(o.has(c))throw new M.ReportCellEditError("duplicate");if(o.add(c),M.sourceChanged(i,s)||!Object.is(i.value,s.previousValue)||(i.cell.text??"")!==s.previousText)throw new M.ReportCellEditError("conflict");return a.push(i),M.editFromContext(i,s.value)});return{batch:{requestId:t.requestId,edits:n},contexts:a}}function tr(e,t){const r=qe(e);return t.flatMap(o=>{if(!o.source)throw new M.ReportCellEditError("missing");return r(o.source).map(a=>{if(!Object.is(Ze(a.row,o.source.field),o.previousValue))throw new M.ReportCellEditError("conflict");if(a.binding.rowKey===o.source.field)throw new M.ReportCellEditError("readonly");return{row:a,field:o.source.field,value:o.value}})})}function ne(e,t,r){const o={...e,value:t,source:{...e.source,...r?.revision===void 0?{}:{revision:r.revision},...r?.sourceToken===void 0?{}:{sourceToken:r.sourceToken}}};return o.cell={...e.cell,value:o.value,text:M.formatReportCellEdit(o,o.value)},o}function rr(e,t,r){if(!r||r.revision===void 0&&r.sourceToken===void 0)return[...e];const o=new Set(t.edits.flatMap(a=>a.source?[D(a.source)]:[]));return Ve(e,zt(e,o,r))}function or(e,t,r){const o=new Set(t.edits.map(a=>D(a.source)));for(const a of o)e.set(a,{...e.get(a),...r.revision!==void 0?{revision:r.revision}:{},...r.sourceToken!==void 0?{sourceToken:r.sourceToken}:{}});return o}function Me(e,t){let r=t.parts;const o=t.rebuild;let a=Yt(r),n=e,s;const i=new Map,c=new Map;function l(u){if(u!==n)throw new M.ReportCellEditError("conflict");if(s)return s;if(!a?.())throw new M.ReportCellEditError("conflict");return Qt(r)}async function d(u,g,h,m={}){q(m.signal),g={requestId:g.requestId,edits:g.edits.map(b=>({...b,address:{...b.address},source:b.source?{...b.source}:void 0,table:b.table?{...b.table}:void 0}))},h=h.map(b=>({...b,address:{...b.address},source:b.source?{...b.source}:void 0,table:b.table?{...b.table}:void 0,cell:{...b.cell}})),await new Promise(b=>setTimeout(b,0)),q(m.signal);const w=l(u),S=Ve(w,tr(w,g.edits)),R=we(await o(S,m.signal),c);q(m.signal);let T=!1;return{plan:R,commit(b){if(q(m.signal),T||n!==u)throw new M.ReportCellEditError("conflict");if(b?.conflicts?.length)throw new M.ReportCellEditError("conflict");const I=rr(S,g,b),F=Je(R,g,b);if(b){const O=or(c,g,b);for(const[p,y]of i)O.has(D(y.source))&&i.set(p,ne(y,y.value,b))}return h.forEach((O,p)=>i.set(M.reportCellEditKey(O),ne(O,g.edits[p].value,b))),T=!0,s=I,r=void 0,a=void 0,n=F,ie.set(n,f),n}}}const f={get plan(){return n},async prepare(u,g,h){const m=er(u,g);return d(u,m.batch,m.contexts,h)},async prepareHistory(u,g,h,m,w){if(!m.trim()||g.length>1e4)throw new M.ReportCellEditError("limit");const S=l(u),R=qe(S),T=ze(u),b=new Set,F=g.map(y=>{if(!y.source)throw new M.ReportCellEditError("missing");const v=M.reportCellEditKey(y);if(b.has(v))throw new M.ReportCellEditError("duplicate");b.add(v);const C=T.get(v)??i.get(v);if(!C?.source)throw new M.ReportCellEditError("missing");const k=R(C.source)[0];return ne(C,Ze(k.row,C.source.field))}).map((y,v)=>({context:y,edit:M.editFromContext(y,g[v][h])})).filter(({edit:y})=>!Object.is(y.previousValue,y.value)),O={requestId:m,edits:F.map(({edit:y})=>y)},p=F.map(({context:y})=>y);return{batch:O,contexts:p,prepared:await d(u,O,p,w)}}};return ie.set(e,f),f}function nr(e){const t=pe(e.template,e.datasets,e.pagination).plan;return Me(t,{parts:[{template:e.template,datasets:e.datasets}],rebuild:(r,o)=>Qe(r[0].template,r[0].datasets,{...e.pagination,signal:o})})}let ar=0;function et(){return`report-${Date.now()}-${++ar}`}function ce(e,t,r){if(!r?.aborted)try{const o=e?.({...t});o&&typeof o.then=="function"&&Promise.resolve(o).catch(()=>{})}catch{}}function tt(e){const t=e.taskId??et(),r=(o,a,n)=>{ce(e.onEvent,{taskId:t,...e.correlationId===void 0?{}:{correlationId:e.correlationId},stage:o,status:a,...n===void 0?{}:{reportId:n}},e.signal)};return{taskId:t,progress(o,a,n){ce(e.onEvent,{taskId:t,...e.correlationId===void 0?{}:{correlationId:e.correlationId},stage:o,status:"started",completed:a,total:n},e.signal)},async run(o,a,n){r(o,"started",n);try{const s=await a();return r(o,"completed",n),s}catch(s){throw r(o,"failed",n),s}},runSync(o,a,n){r(o,"started",n);try{const s=a();return r(o,"completed",n),s}catch(s){throw r(o,"failed",n),s}}}}function be(e,t,r={}){const o=new Map;for(const n of e.pages)for(const s of n.components){if(s.kind!=="list"||s.tree?.input!=="nested")continue;const i=o.get(s.dataset);if(i&&(i.childrenField??"children")!==(s.tree.childrenField??"children"))throw new Error("同一数据集的嵌套树应使用相同 childrenField");o.set(s.dataset,s.tree)}if(!o.size)return t;const a={...t};for(const[n,s]of o){const i=Math.min(s.maxRows??1e5,r.maxRows??1/0);a[n]=U.flattenTreeInput(t[n]??[],{...s,maxRows:i},r.signal)}return a}function sr(e,t,r={}){return Object.values(be(e,t,r)).reduce((o,a)=>o+a.length,0)}function ir(e,t,r){const o=ke.datasetJsonSchema(r),a=e?.pages.flatMap(i=>i.components).find(i=>i.kind==="list"&&i.dataset===t&&i.tree?.input==="nested");if(!a||a.kind!=="list"||!a.tree)return o;const n=o.items,s=a.tree.childrenField??"children";return{...o,items:{$ref:"#/$defs/treeNode"},$defs:{treeNode:{...n,properties:{...n.properties,[s]:{anyOf:[{type:"null"},{type:"array",items:{$ref:"#/$defs/treeNode"}}]}}}}}}function ve(e,t){return JSON.stringify([e,t])}function rt(e,t,r){return r===void 0?ve(e,t):JSON.stringify(["shared",r])}function ot(e,t,r){return e.map(o=>{const a=o.table?{...o.table,id:r(o.table.id),...o.table.source?{source:{...o.table.source,sourceScope:t}}:{}}:void 0,n=o.grid?.cells.map(s=>s.map(i=>!i||!i.source&&!i.children?i:{...i,...i.source?{source:{...i.source,sourceScope:t}}:{},...i.children?{children:ot(i.children,t,r)}:{}}));return a||n?{...o,...a?{table:a}:{},...n?{grid:{...o.grid,cells:n}}:{}}:o})}function cr(e){if(!("mapData"in e))return e;const{load:t,mapData:r,...o}=e;return{...o,load:async a=>{const n=await t(a);x(a.signal);try{return r(n,a)}catch(s){throw new P("validate",`报表 ${a.reportId} 数据映射失败`,s)}}}}class P extends Error{constructor(t,r,o){super(r),this.name="ReportSourceError",this.code=t,this.cause=o}}function te(e){const t=new Error("报表加载已取消");return t.name="AbortError",Object.defineProperty(t,"cause",{value:e.reason}),t}function x(e){if(e?.aborted)throw te(e)}function le(e,t){return t?new Promise((r,o)=>{const a=()=>t.removeEventListener("abort",n),n=()=>{a(),o(te(t))};t.addEventListener("abort",n,{once:!0}),t.aborted&&n(),Promise.resolve(e).then(s=>{a(),r(s)},s=>{a(),o(s)})}):Promise.resolve(e)}function lr(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new P("validate",`报表 ${t} 的数据集应为对象`);for(const[r,o]of Object.entries(e))if(!Array.isArray(o)||o.some(a=>!a||typeof a!="object"||Array.isArray(a)))throw new P("validate",`报表 ${t} 的数据集 ${r} 应为对象数组`)}async function dr(e,t,r){const{reportId:o,signal:a}=t;try{const n=await le(e(t),a);x(a);const s=N.validateReportTemplate(n);if(!s.ok)throw new P("validate",`报表 ${o} 模板校验失败:${s.errors.slice(0,3).map(i=>`${i.path}: ${i.message}`).join("; ")}`);return r.push(...s.warnings.map(i=>`${o}: ${i.path}: ${i.message}`)),n}catch(n){throw a?.aborted?te(a):n instanceof P?n:n instanceof N.ReportTemplateError?new P("validate",`报表 ${o} 模板校验失败:${n.message}`,n):new P("fetch",`报表 ${o} 模板加载失败:${n instanceof Error?n.message:String(n)}`,n)}}async function ur(e,t,r,o){const a=t.signal;let n;try{if(e.load)n=await le(e.load(t),a);else if(e.provider){const s=await le(e.provider.query(t),a);x(a),fr(s,r),n=s.datasets,o?.(r,s)}else n=e.datasets??{}}catch(s){throw a?.aborted?te(a):s instanceof P?s:new P("fetch",`报表 ${r} 取数失败:${s instanceof Error?s.message:String(s)}`,s)}return x(a),n}function fr(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new P("validate",`报表 ${t} Provider 应返回 datasets 结果对象`);for(const r of["revision","sourceToken"])if(e[r]!==void 0&&typeof e[r]!="string")throw new P("validate",`报表 ${t} Provider ${r} 应为字符串`);if(e.diagnostics!==void 0&&(!Array.isArray(e.diagnostics)||e.diagnostics.some(r=>!r||typeof r.code!="string"||typeof r.message!="string"||!["info","warning","error"].includes(r.severity))))throw new P("validate",`报表 ${t} Provider diagnostics 不符合结构化诊断契约`);if(e.diagnostics?.some(r=>!dt.hasValidDataExplanation(r)))throw new P("validate",`报表 ${t} Provider 数据说明缺少有效的字段身份或值状态`)}function mr(e,t,r,o,a){try{t=be(o,t,{maxRows:e.dataValidation?.maxRows,signal:a})}catch(n){throw new P("validate",`报表 ${r} 树形数据无效:${n instanceof Error?n.message:String(n)}`,n)}for(const[n,s]of Object.entries(e.dataSchema??{})){let i;try{i=ke.validateDatasetRows(Object.prototype.hasOwnProperty.call(t,n)?t[n]:void 0,s,{...e.dataValidation,path:`$.datasets.${n}`})}catch(c){throw new P("config",`报表 ${r} 数据集 ${n} 字段契约配置无效`,c)}if(!i.ok)throw new P("validate",`报表 ${r} 数据集 ${n} 不符合字段契约:${i.issues[0]?.message}`,{issues:i.issues})}}function nt(e,t){if(!e.repeat)return!1;const r=Object.prototype.hasOwnProperty.call(t,e.repeat.dataset)?t[e.repeat.dataset]:void 0;return Array.isArray(r)&&r.length===0}function at(e){const t=r=>r.grid?.cells.reduce((o,a)=>o+a.reduce((n,s)=>n+(s?1+(s.children?.reduce((i,c)=>i+t(c),0)??0):0),0),0)??0;return e.pages.reduce((r,o)=>r+o.components.reduce((a,n)=>a+t(n),0),0)}function st(e,t,r,o){return{...e,signal:o??e?.signal,...t===void 0?{}:{maxPages:Math.max(1,Math.min(t,e?.maxPages??t))},...r===void 0?{}:{maxCells:Math.max(1,Math.min(r,e?.maxCells??r))}}}function gr(e,t,r,o,a,n){const s=a.maxPages===void 0?void 0:a.maxPages-a.usedPages,i=a.maxCells===void 0?void 0:a.maxCells-a.usedCells;try{if(s!==void 0&&s<1&&e.pages.length&&!nt(e,t))throw new L(0,1);const c=st(r.pagination,s,i,n),l=pe(e,t,c),d=at(l.plan);if(i!==void 0&&d>i)throw new H(i,d);return{...l,cells:d}}catch(c){let l=c;throw c instanceof L&&a.maxPages!==void 0&&c.limit===s&&(l=new L(a.maxPages,a.usedPages+c.actual)),c instanceof H&&a.maxCells!==void 0&&(l=new H(a.maxCells,a.usedCells+c.actual)),new P("validate",`报表 ${o} 排版失败:${l instanceof Error?l.message:String(l)}`,l)}}function it(e,t,r,o,a){const n=new Map,s=i=>{let c=n.get(i);return c===void 0&&(c=JSON.stringify([r,o,i]),n.set(i,c)),c};for(const i of t.pages)e.push({...i,meta:{...i.meta,reportScope:ve(r,o)},components:ot(i.components,a??rt(r,o),s)})}async function hr(e,t,r,o,a){const n=[];let s=0;for(const[l,d]of e.entries()){x(a);const f=o.maxPages===void 0?void 0:o.maxPages-n.length,u=o.maxCells===void 0?void 0:o.maxCells-s;if(f!==void 0&&f<1&&d.template.pages.length&&!nt(d.template,d.datasets))throw new L(o.maxPages,n.length+1);const g=await Qe(d.template,d.datasets,st(t[l]?.pagination,f,u,a));if(s+=at(g),o.maxCells!==void 0&&s>o.maxCells)throw new H(o.maxCells,s);it(n,g,l,r[l],d.sourceScope)}const i={schemaVersion:z.RENDER_PLAN_SCHEMA_VERSION,...e.some(l=>X(l.template))?{requiresRecalculation:!0}:{},pages:n},c=N.validateRenderPlan(i);if(!c.ok)throw new P("validate",`重算渲染计划校验失败:${c.errors[0]?.message}`);return i}function pr(e,t={}){if(t.maxPages!==void 0&&(!Number.isSafeInteger(t.maxPages)||t.maxPages<1))throw new P("config","maxPages 应为正安全整数");if(t.maxCells!==void 0&&(!Number.isSafeInteger(t.maxCells)||t.maxCells<1))throw new P("config","maxCells 应为正安全整数");function r(a){const n=Object.prototype.hasOwnProperty.call(e,a)?e[a]:void 0;if(!n)throw new P("config",`未注册报表 ${a}`);if(n.sourceScope!==void 0&&(typeof n.sourceScope!="string"||!n.sourceScope.trim()||n.sourceScope.length>512))throw new P("config","sourceScope 应为不超过 512 字符的非空字符串");return n}return Object.assign(async({reportIds:a,params:n,signal:s,onWarning:i,onQueryResult:c,...l})=>{x(s);const d=tt({...l,signal:s}),f=[...a],u={...n};if(f.length===0)throw new P("config","缺少报表 ID");const g=f.map(r),h=d.runSync("validate",()=>g.map(p=>Se.assertReportParams(p.params??(typeof p.template=="function"?[]:p.template.params)??[],u))),m=[],w=[];let S=0;const R=[];for(const[p,y]of g.entries()){x(s);const v=f[p],C={reportId:v,params:h[p],signal:s},k=typeof y.template=="function"?await d.run("query",()=>dr(y.template,C,R),v):y.template;C.params=d.runSync("validate",()=>Se.assertReportParams(y.params??k.params??[],C.params),v);const A=await d.run("query",()=>ur(y,C,v,(oe,ct)=>c?.(oe,ct,p)),v);d.runSync("validate",()=>{lr(A,v),t.onDatasets?.(v,A,k),mr(y,A,v,k,s)},v),x(s);const re=d.runSync("layout",()=>gr(k,A,y,v,{maxPages:t.maxPages,usedPages:m.length,maxCells:t.maxCells,usedCells:S},s),v);S+=re.cells;const Ee=rt(p,v,y.sourceScope);w.push({template:k,datasets:A,sourceScope:Ee}),it(m,re.plan,p,v,Ee),R.push(...re.warnings.map(oe=>`${v}: ${oe}`))}x(s);const T={schemaVersion:z.RENDER_PLAN_SCHEMA_VERSION,...w.some(p=>X(p.template))?{requiresRecalculation:!0}:{},pages:m},b=d.runSync("validate",()=>{const p=N.validateRenderPlan(T);if(!p.ok)throw new P("validate",`渲染计划校验失败:${p.errors.slice(0,3).map(y=>`${y.path}: ${y.message}`).join("; ")}`);return p});R.push(...b.warnings.map(p=>`${p.path}: ${p.message}`));const I=g.map(p=>({...p,pagination:{...p.pagination}})),F={maxPages:t.maxPages,maxCells:t.maxCells};try{Me(T,{parts:w,rebuild:(p,y)=>hr(p,I,f,F,y)})}catch{R.push("来源数据无法建立本地重算口径;当前预览仅支持计划内编辑,请使用可序列化模板数据启用规则重算")}const O=i??t.onWarning??(p=>console.warn("[mach-report]",p));for(const p of R)x(s),O(p);return x(s),T},{getParamDefs:a=>lt.getReportParamDefs(e,a)})}function wr(e,t){let r=0,o=0;const a=new Set;function n(c,l){if(++r>1e6||l>64)throw t.error("budget","快照节点或深度超过预算");if(r%1024===0&&t.check?.(),typeof c=="string"&&(o+=c.length,o>t.maxBytes))throw t.error("budget","快照文本超过预算");if(c===null||["string","boolean"].includes(typeof c)||typeof c=="number"&&Number.isFinite(c))return c;if(!c||typeof c!="object"||a.has(c))throw t.error("input","快照应为无循环的有限 JSON 值");return s(c,l)}function s(c,l){const d=Array.isArray(c),f=Object.getPrototypeOf(c);if(f!==(d?Array.prototype:Object.prototype)&&!(f===null&&!d)||Object.getOwnPropertySymbols(c).length)throw t.error("input","快照应为普通 JSON 对象");const u=Object.getOwnPropertyNames(c).filter(h=>!(d&&h==="length"));if(d&&(u.length!==c.length||u.some((h,m)=>h!==String(m))))throw t.error("input","快照数组应为连续数组");a.add(c);const g=Object.create(null);for(const h of u){if(o+=h.length,o>t.maxBytes)throw t.error("budget","快照文本超过预算");const m=Object.getOwnPropertyDescriptor(c,h);if(m.get||m.set||!m.enumerable||["__proto__","constructor","prototype"].includes(h))throw t.error("input","快照不允许访问器或危险键");m.value!==void 0&&(g[h]=n(m.value,l+1))}return a.delete(c),d?u.map(h=>g[h]):g}t.check?.();const i=JSON.stringify(n(e,0));if(new TextEncoder().encode(i).byteLength>t.maxBytes)throw t.error("budget","快照超过字节预算");return JSON.parse(i)}exports.DEFAULT_LABEL_PAGE_LIMIT=xe;exports.PaginateCellLimitError=H;exports.PaginatePageLimitError=L;exports.ReportSourceError=P;exports.applyReportEditResult=Je;exports.applyReportSourceMetadata=we;exports.countTemplatePages=Wt;exports.createReportEditSession=nr;exports.createReportSource=pr;exports.createReportTaskReporter=tt;exports.defineReport=cr;exports.estimateListLayoutCells=Jt;exports.getReportEditSession=Zt;exports.notifyReportTaskEvent=ce;exports.paginateTemplate=pe;exports.paginateTemplatePages=Ge;exports.projectListColumns=$e;exports.registerReportEditSession=Me;exports.relocateReportCellEdits=Ut;exports.reportOccurrenceScope=ve;exports.reportTaskId=et;exports.snapshotReportJson=wr;exports.templateDatasetJsonSchema=ir;exports.templateDatasetRowCount=sr;exports.templateValidationDatasets=be;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const u=require("./data-explanation-DE55G30w.cjs"),n=require("./json-snapshot-WWSGlaHG.cjs"),a=require("./sha256-ArEYjaTI.cjs");function p(r){return r&&{...r}}function l(r){if(!r)return;const t=e=>{if(!(e instanceof Uint8Array)&&!(e instanceof ArrayBuffer))throw new n.ReportSourceError("validate","字体应为 Uint8Array 或 ArrayBuffer");if(e.byteLength>32e6)throw new a.ReportRuntimeError("budget","单份字体超过 32 MB","$.pdf");return new Uint8Array(e instanceof Uint8Array?e:new Uint8Array(e))};if(r.customFontFaces){const e=r.customFontFaces;return{customFontName:r.customFontName,customFontFaces:{regular:t(e.regular),...e.bold?{bold:t(e.bold)}:{},...e.italic?{italic:t(e.italic)}:{},...e.boldItalic?{boldItalic:t(e.boldItalic)}:{}}}}return{customFontName:r.customFontName,...r.customFontBytes?{customFontBytes:t(r.customFontBytes)}:{}}}function c(r){const t=r?.customFontFaces??(r?.customFontBytes?{regular:r.customFontBytes}:void 0);if(!t)return;const e=["regular","bold","italic","boldItalic"].map(o=>{const i=t[o];if(!i)return[o,null];const s=i instanceof Uint8Array?i:new Uint8Array(i);if(s.byteLength>32e6)throw new a.ReportRuntimeError("budget","单份字体超过 32 MB","$.pdf");return[o,a.portableSha256Hex(s)]});return a.portableSha256Hex(new TextEncoder().encode(JSON.stringify(e)))}function y(r,t,e){const o=n.snapshotReportJson(r,{maxBytes:t,check:()=>a.throwIfAborted(e),error:(i,s)=>i==="budget"?new a.ReportRuntimeError("budget",s,"$.budget.maxPreparedBytes"):new n.ReportSourceError("validate",s)});return f(o),o}function d(r){if(r===void 0)return!0;if(!Array.isArray(r))return!1;const t=new Set;return r.every(e=>!e||typeof e!="object"||Array.isArray(e)||typeof e.reportId!="string"||!e.reportId.trim()||!Number.isSafeInteger(e.reportIndex)||e.reportIndex<0||t.has(e.reportIndex)||typeof e.reportScope!="string"||!e.reportScope.trim()||e.reportScope.length>4096||e.revision!==void 0&&typeof e.revision!="string"||e.sourceToken!==void 0&&typeof e.sourceToken!="string"?!1:(t.add(e.reportIndex),!0))}function f(r){if(!d(r.sources))throw new n.ReportSourceError("validate","准备结果来源清单无效");if(!r?.stats||["rows","pages","cells"].some(t=>!Number.isSafeInteger(r.stats[t])||r.stats[t]<0)||!Number.isFinite(r.stats.durationMs)||r.stats.durationMs<0)throw new n.ReportSourceError("validate","准备结果统计无效");if(!Array.isArray(r.diagnostics)||r.diagnostics.some(t=>!t||typeof t.code!="string"||typeof t.message!="string"||!["info","warning","error"].includes(t.severity)||!u.hasValidDataExplanation(t)))throw new n.ReportSourceError("validate","准备结果诊断无效");if(!r.revisions||typeof r.revisions!="object"||Array.isArray(r.revisions)||Object.values(r.revisions).some(t=>!t||typeof t!="object"||t.revision!==void 0&&typeof t.revision!="string"||t.sourceToken!==void 0&&typeof t.sourceToken!="string"))throw new n.ReportSourceError("validate","准备结果修订无效");if(r.layout&&(!["heuristic","provided","font-bytes"].includes(r.layout.textMetrics)||r.layout.fontFingerprint!==void 0&&!/^[a-f0-9]{64}$/.test(r.layout.fontFingerprint)))throw new n.ReportSourceError("validate","准备结果字体度量标识无效")}function g(r){if(r.format!=="pdf")return;const t=r.prepared.layout?.fontFingerprint,e=c(r.pdf);if(t===e&&(t!==void 0||r.prepared.layout?.textMetrics==="heuristic"&&!e))return;const o="已准备计划的字体度量无法与本次 PDF 字体确认一致;保持现有分页,未重新查询或排版。请在 prepare 和 exportPrepared 提供相同字体字节。";if(r.fidelity==="strict")throw new n.ReportSourceError("validate",o);r.prepared.diagnostics.push({code:"prepared-font-metrics",severity:"warning",message:o})}exports.checkPreparedFont=g;exports.reportFontFingerprint=c;exports.snapshotPdfFonts=l;exports.snapshotPreparedReport=y;exports.snapshotXlsxOptions=p;exports.validPreparedSources=d;exports.validatePreparedMetadata=f;
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { h as f } from "./data-explanation-B8MZRYVS.js";
|
|
2
|
-
import { R as o, s as d } from "./json-snapshot-DFb2eWkf.js";
|
|
3
|
-
import { R as s, t as u, p as c } from "./sha256-DPEuJ3nh.js";
|
|
4
|
-
function b(t) {
|
|
5
|
-
return t && { ...t };
|
|
6
|
-
}
|
|
7
|
-
function F(t) {
|
|
8
|
-
if (!t) return;
|
|
9
|
-
const r = (e) => {
|
|
10
|
-
if (!(e instanceof Uint8Array) && !(e instanceof ArrayBuffer)) throw new o("validate", "字体应为 Uint8Array 或 ArrayBuffer");
|
|
11
|
-
if (e.byteLength > 32e6) throw new s("budget", "单份字体超过 32 MB", "$.pdf");
|
|
12
|
-
return new Uint8Array(e instanceof Uint8Array ? e : new Uint8Array(e));
|
|
13
|
-
};
|
|
14
|
-
if (t.customFontFaces) {
|
|
15
|
-
const e = t.customFontFaces;
|
|
16
|
-
return { customFontName: t.customFontName, customFontFaces: { regular: r(e.regular), ...e.bold ? { bold: r(e.bold) } : {}, ...e.italic ? { italic: r(e.italic) } : {}, ...e.boldItalic ? { boldItalic: r(e.boldItalic) } : {} } };
|
|
17
|
-
}
|
|
18
|
-
return { customFontName: t.customFontName, ...t.customFontBytes ? { customFontBytes: r(t.customFontBytes) } : {} };
|
|
19
|
-
}
|
|
20
|
-
function l(t) {
|
|
21
|
-
const r = t?.customFontFaces ?? (t?.customFontBytes ? { regular: t.customFontBytes } : void 0);
|
|
22
|
-
if (!r) return;
|
|
23
|
-
const e = ["regular", "bold", "italic", "boldItalic"].map((i) => {
|
|
24
|
-
const n = r[i];
|
|
25
|
-
if (!n) return [i, null];
|
|
26
|
-
const a = n instanceof Uint8Array ? n : new Uint8Array(n);
|
|
27
|
-
if (a.byteLength > 32e6) throw new s("budget", "单份字体超过 32 MB", "$.pdf");
|
|
28
|
-
return [i, c(a)];
|
|
29
|
-
});
|
|
30
|
-
return c(new TextEncoder().encode(JSON.stringify(e)));
|
|
31
|
-
}
|
|
32
|
-
function v(t, r, e) {
|
|
33
|
-
const i = d(t, {
|
|
34
|
-
maxBytes: r,
|
|
35
|
-
check: () => u(e),
|
|
36
|
-
error: (n, a) => n === "budget" ? new s("budget", a, "$.budget.maxPreparedBytes") : new o("validate", a)
|
|
37
|
-
});
|
|
38
|
-
return p(i), i;
|
|
39
|
-
}
|
|
40
|
-
function y(t) {
|
|
41
|
-
if (t === void 0) return !0;
|
|
42
|
-
if (!Array.isArray(t)) return !1;
|
|
43
|
-
const r = /* @__PURE__ */ new Set();
|
|
44
|
-
return t.every((e) => !e || typeof e != "object" || Array.isArray(e) || typeof e.reportId != "string" || !e.reportId.trim() || !Number.isSafeInteger(e.reportIndex) || e.reportIndex < 0 || r.has(e.reportIndex) || typeof e.reportScope != "string" || !e.reportScope.trim() || e.reportScope.length > 4096 || e.revision !== void 0 && typeof e.revision != "string" || e.sourceToken !== void 0 && typeof e.sourceToken != "string" ? !1 : (r.add(e.reportIndex), !0));
|
|
45
|
-
}
|
|
46
|
-
function p(t) {
|
|
47
|
-
if (!y(t.sources)) throw new o("validate", "准备结果来源清单无效");
|
|
48
|
-
if (!t?.stats || ["rows", "pages", "cells"].some((r) => !Number.isSafeInteger(t.stats[r]) || t.stats[r] < 0) || !Number.isFinite(t.stats.durationMs) || t.stats.durationMs < 0) throw new o("validate", "准备结果统计无效");
|
|
49
|
-
if (!Array.isArray(t.diagnostics) || t.diagnostics.some((r) => !r || typeof r.code != "string" || typeof r.message != "string" || !["info", "warning", "error"].includes(r.severity) || !f(r))) throw new o("validate", "准备结果诊断无效");
|
|
50
|
-
if (!t.revisions || typeof t.revisions != "object" || Array.isArray(t.revisions) || Object.values(t.revisions).some((r) => !r || typeof r != "object" || r.revision !== void 0 && typeof r.revision != "string" || r.sourceToken !== void 0 && typeof r.sourceToken != "string")) throw new o("validate", "准备结果修订无效");
|
|
51
|
-
if (t.layout && (!["heuristic", "provided", "font-bytes"].includes(t.layout.textMetrics) || t.layout.fontFingerprint !== void 0 && !/^[a-f0-9]{64}$/.test(t.layout.fontFingerprint))) throw new o("validate", "准备结果字体度量标识无效");
|
|
52
|
-
}
|
|
53
|
-
function A(t) {
|
|
54
|
-
if (t.format !== "pdf") return;
|
|
55
|
-
const r = t.prepared.layout?.fontFingerprint, e = l(t.pdf);
|
|
56
|
-
if (r === e && (r !== void 0 || t.prepared.layout?.textMetrics === "heuristic" && !e)) return;
|
|
57
|
-
const i = "已准备计划的字体度量无法与本次 PDF 字体确认一致;保持现有分页,未重新查询或排版。请在 prepare 和 exportPrepared 提供相同字体字节。";
|
|
58
|
-
if (t.fidelity === "strict") throw new o("validate", i);
|
|
59
|
-
t.prepared.diagnostics.push({ code: "prepared-font-metrics", severity: "warning", message: i });
|
|
60
|
-
}
|
|
61
|
-
export {
|
|
62
|
-
b as a,
|
|
63
|
-
v as b,
|
|
64
|
-
A as c,
|
|
65
|
-
y as d,
|
|
66
|
-
l as r,
|
|
67
|
-
F as s,
|
|
68
|
-
p as v
|
|
69
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const y=require("./defaults-xhmcLLrf.cjs"),d=require("./style-UgIJSA1F.cjs"),u=require("./computed-CGV2a809.cjs");function S(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 h(e){const t=/^(\d{4})[-/](\d{1,2})[-/](\d{1,2})$/.exec(e.trim());if(t){const n=new Date(Number(t[1]),Number(t[2])-1,Number(t[3]));return Number.isNaN(n.getTime())?null:n}const r=new Date(e);return Number.isNaN(r.getTime())?null:r}function c(e,t){return e.toLocaleString("en-US",{minimumFractionDigits:t,maximumFractionDigits:t})}function x(e,t){const r=n=>String(n).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 C(e,t,r){return r!=null?t?c(e,r):e.toFixed(r):t?c(e):String(e)}function g(e){const t=typeof e=="number"?e:Number(String(e).replace(/,/g,""));return Number.isFinite(t)?t:null}function b(e,t){if(e==null||e===""||!t)return String(e??"");switch(t.kind){case"number":{if(typeof e=="string")try{return u.formatDecimal(e,t.digits,t.thousands===!0)}catch{return e}const r=g(e);return r==null?String(e):C(r,t.thousands===!0,t.digits)}case"percent":{if(typeof e=="string")try{return u.formatDecimal(e,t.digits??2,!0,!0)}catch{return e}const r=g(e);return r==null?String(e):`${c(r*100,t.digits??2)}%`}case"date":{const r=t.pattern??"YYYY-MM-DD",n=e instanceof Date?e:h(String(e));return n?x(n,r):String(e)}default:return String(e)}}function p(e,t){const r=e[t.field];if(r==null||r==="")return!1;if(typeof t.value=="number"||t.numeric!==void 0){let a;try{a=u.compareDecimal(u.parseDecimal(r),u.parseDecimal(t.value))}catch{return!1}if(!Number.isFinite(a))return!1;switch(t.op){case">":return a>0;case">=":return a>=0;case"<":return a<0;case"<=":return a<=0;case"==":return a===0;case"!=":return a!==0}}const n=String(r),i=String(t.value);switch(t.op){case"==":return n===i;case"!=":return n!==i;case">":return n>i;case">=":return n>=i;case"<":return n<i;case"<=":return n<=i}return!1}function D(e,t,r,n=e.paddingMm??1){return t.field!==e.tree.labelField?0:Math.min(r.depth*(e.tree.indentMm??3),Math.max(0,t.widthMm-n*2-4))}function N(e,t,r,n){const i=n.tree;(i.input==="nested"||[i.idField,i.parentField].includes(t.field))&&(e.editable=!1),r.hasChildren&&i.parentValues==="leaf-aggregate"&&i.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 F(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 M(e,t){let r=d.mergeComponentStyles({fontSize:e.fontSizePt??y.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=d.mergeComponentStyles(r,e.headerStyle),t.headerAlign!==void 0&&(r.align=t.headerAlign),d.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 n=t.format?.kind==="number"||t.format?.kind==="percent";t.valueType!==void 0?e.valueType=t.valueType:n&&(e.valueType="number"),t.editable!==void 0&&(e.editable=t.editable);const i=S(t.format);(typeof e.value=="number"||e.value==null)&&i!==void 0&&(e.numberFormat=i)}function $(e,t,r){const n=!!t.visibleWhen&&!p(r,t.visibleWhen),i=n?null:r[t.field],a=t.align??t.style?.align??e.align??"left";let s=d.mergeComponentStyles({fontSize:e.fontSizePt??y.DEFAULT_FONT_PT,verticalAlign:"middle"},t.style);s.align=a==="auto"?T(i,t.format,t.semanticRole):a;const o=t.rules?.find(f=>p(r,f.when));o&&(s=d.mergeComponentStyles(s,o.style));const l={text:t.format?b(i,t.format):F(i),style:s};return A(l,t,i),e.computed?.some(f=>f.field===t.field)&&(l.derived=!0,l.editable=!1),n&&(l.editable=!1),l}function k(e,t,r){const n=$(e,t,r.row),i=D(e,t,r);return t.field===e.tree.labelField&&(n.style={...n.style,align:"left"}),i&&(n.indentMm=i),N(n,t,r,e),n}function w(e){return typeof e=="string"&&/^data:image\/(png|jpe?g);base64,[A-Za-z0-9+/\r\n]+=*$/.test(e)}class m extends Error{constructor(t,r,n,i){super(`${t}: ${r}`),this.path=t,this.rowIndex=n,this.field=i,this.code="report-binding",this.name="ReportBindingError"}}function L(e,t,r={}){const n=r.rowIndex??0,a=`$.datasets.${r.dataset??"label"}[${n}].${t}`,s=Object.getOwnPropertyDescriptor(e,t);if(!s||s.get||s.set)throw new m(a,"字段必须是记录的自有数据字段,不能缺失、使用访问器或从原型继承",n,t);const o=s.value;if(o==null||typeof o=="string"||typeof o=="boolean"||typeof o=="number"&&Number.isFinite(o))return o;throw new m(a,"绑定值应为字符串、有限数字、布尔值或空值",n,t)}function I(e,t,r={}){const n=L(t,e.field,r);return n==null||n===""?e.emptyText??"":`${e.prefix??""}${b(n,e.format)}${e.suffix??""}`}exports.ReportBindingError=m;exports.applyListTreeMetadata=N;exports.evalStyleRule=p;exports.formatValue=b;exports.isLabelImageData=w;exports.listCellText=F;exports.listTreeIndent=D;exports.parseDateLocal=h;exports.readRecordScalar=L;exports.resolveComponentBinding=I;exports.resolveListAutoAlignment=T;exports.resolveListHeaderStyle=M;exports.resolveListSampleCell=$;exports.resolveTreeListSampleCell=k;exports.toExcelNumberFormat=S;exports.toNumber=g;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const i=require("./defaults-xhmcLLrf.cjs"),r=i.SCHEMA_VERSION_MACH;function a(e){return(e.kind==="image"||e.kind==="barcode"||e.kind==="qrcode"||e.kind==="chart")&&!!e.imageData}function n(e){return e.kind==="text"&&Array.isArray(e.richParagraphs)&&e.richParagraphs.length>0}exports.RENDER_PLAN_SCHEMA_VERSION=r;exports.isImageBackedComponent=a;exports.isRichText=n;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { S as r } from "./defaults-DXhiM1ZD.js";
|
|
2
|
-
const n = r;
|
|
3
|
-
function t(a) {
|
|
4
|
-
return (a.kind === "image" || a.kind === "barcode" || a.kind === "qrcode" || a.kind === "chart") && !!a.imageData;
|
|
5
|
-
}
|
|
6
|
-
function e(a) {
|
|
7
|
-
return a.kind === "text" && Array.isArray(a.richParagraphs) && a.richParagraphs.length > 0;
|
|
8
|
-
}
|
|
9
|
-
export {
|
|
10
|
-
n as R,
|
|
11
|
-
e as a,
|
|
12
|
-
t as i
|
|
13
|
-
};
|
package/dist/sha256-ArEYjaTI.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";class f extends Error{constructor(t,r,o){super(r),this.code=t,this.path=o,this.name="ReportRuntimeError"}}function l(e){if(!e?.aborted)return;if(e.reason instanceof f)throw e.reason;const t=new Error("报表执行已取消");throw t.name="AbortError",Object.defineProperty(t,"cause",{value:e.reason}),t}function U(e,t,r){if(!Number.isFinite(r)||r<0)throw new f("budget",`${t} 的执行统计无效`,`$.budget.${t}`);const o=e[t];if(o!==void 0&&r>o)throw new f("budget",`${t} 超出预算 ${o}(实际 ${r})`,`$.budget.${t}`)}function D(e){for(const[t,r]of Object.entries(e)){if(r!==void 0&&(!Number.isFinite(r)||r<=0))throw new f("budget",`${t} 应为正有限数字`,`$.budget.${t}`);if(t!=="maxDurationMs"&&r!==void 0&&!Number.isSafeInteger(r))throw new f("budget",`${t} 应为正安全整数`,`$.budget.${t}`);if(t==="maxDurationMs"&&r!==void 0&&r>2147483647)throw new f("budget","maxDurationMs 不能超过 2147483647",`$.budget.${t}`)}}async function L(e,t,r){const o=new AbortController,n=()=>o.abort(e?.reason);e?.addEventListener("abort",n,{once:!0}),e?.aborted&&n();const c=Date.now(),i=t===void 0?void 0:setTimeout(()=>o.abort(new f("timeout",`报表执行超过 ${t}ms`)),t);let s;try{l(o.signal);const d=new Promise((u,w)=>{s=()=>{try{l(o.signal)}catch(g){w(g)}},o.signal.addEventListener("abort",s,{once:!0})}),b=await Promise.race([r(o.signal),d]);if(l(o.signal),t!==void 0&&Date.now()-c>t)throw new f("timeout",`报表执行超过 ${t}ms`);return b}finally{i!==void 0&&clearTimeout(i),s&&o.signal.removeEventListener("abort",s),e?.removeEventListener("abort",n)}}const S=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),a=(e,t)=>e>>>t|e<<32-t;function m(e,t,r){const o=new DataView(e.buffer,e.byteOffset+t,64);for(let n=0;n<16;n++)r[n]=o.getUint32(n*4);for(let n=16;n<64;n++){const c=r[n-15],i=r[n-2],s=a(c,7)^a(c,18)^c>>>3,d=a(i,17)^a(i,19)^i>>>10;r[n]=r[n-16]+s+r[n-7]+d}}function v(e,t){let r=e[0],o=e[1],n=e[2],c=e[3],i=e[4],s=e[5],d=e[6],b=e[7];for(let u=0;u<64;u++){const w=a(i,6)^a(i,11)^a(i,25),g=i&s^~i&d,h=b+w+g+S[u]+t[u]>>>0,x=a(r,2)^a(r,13)^a(r,22),E=r&o^r&n^o&n,p=x+E>>>0;b=d,d=s,s=i,i=c+h>>>0,c=n,n=o,o=r,r=h+p>>>0}e[0]=e[0]+r,e[1]=e[1]+o,e[2]=e[2]+n,e[3]=e[3]+c,e[4]=e[4]+i,e[5]=e[5]+s,e[6]=e[6]+d,e[7]=e[7]+b}function y(e){const t=new Uint8Array(Math.ceil((e.byteLength+9)/64)*64);t.set(e),t[e.byteLength]=128;const r=new DataView(t.buffer);return r.setUint32(t.length-8,Math.floor(e.byteLength/536870912)),r.setUint32(t.length-4,e.byteLength*8>>>0),t}const $=()=>new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),A=e=>Array.from(e,t=>t.toString(16).padStart(8,"0")).join("");function R(e){const t=y(e),r=$(),o=new Uint32Array(64);for(let n=0;n<t.length;n+=64)m(t,n,o),v(r,o);return A(r)}async function j(e){const t=y(e),r=$(),o=new Uint32Array(64);for(let n=0;n<t.length;n+=64)n>0&&n%262144===0&&await new Promise(c=>setTimeout(c,0)),m(t,n,o),v(r,o);return A(r)}exports.ReportRuntimeError=f;exports.assertBudget=U;exports.controlled=L;exports.portableSha256Hex=R;exports.portableSha256HexAsync=j;exports.throwIfAborted=l;exports.validateBudget=D;
|
package/dist/sha256-DPEuJ3nh.js
DELETED
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
class d extends Error {
|
|
2
|
-
constructor(t, n, o) {
|
|
3
|
-
super(n), this.code = t, this.path = o, this.name = "ReportRuntimeError";
|
|
4
|
-
}
|
|
5
|
-
}
|
|
6
|
-
function g(e) {
|
|
7
|
-
if (!e?.aborted) return;
|
|
8
|
-
if (e.reason instanceof d) throw e.reason;
|
|
9
|
-
const t = new Error("报表执行已取消");
|
|
10
|
-
throw t.name = "AbortError", Object.defineProperty(t, "cause", { value: e.reason }), t;
|
|
11
|
-
}
|
|
12
|
-
function D(e, t, n) {
|
|
13
|
-
if (!Number.isFinite(n) || n < 0) throw new d("budget", `${t} 的执行统计无效`, `$.budget.${t}`);
|
|
14
|
-
const o = e[t];
|
|
15
|
-
if (o !== void 0 && n > o) throw new d("budget", `${t} 超出预算 ${o}(实际 ${n})`, `$.budget.${t}`);
|
|
16
|
-
}
|
|
17
|
-
function L(e) {
|
|
18
|
-
for (const [t, n] of Object.entries(e)) {
|
|
19
|
-
if (n !== void 0 && (!Number.isFinite(n) || n <= 0)) throw new d("budget", `${t} 应为正有限数字`, `$.budget.${t}`);
|
|
20
|
-
if (t !== "maxDurationMs" && n !== void 0 && !Number.isSafeInteger(n)) throw new d("budget", `${t} 应为正安全整数`, `$.budget.${t}`);
|
|
21
|
-
if (t === "maxDurationMs" && n !== void 0 && n > 2147483647) throw new d("budget", "maxDurationMs 不能超过 2147483647", `$.budget.${t}`);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
async function R(e, t, n) {
|
|
25
|
-
const o = new AbortController(), r = () => o.abort(e?.reason);
|
|
26
|
-
e?.addEventListener("abort", r, { once: !0 }), e?.aborted && r();
|
|
27
|
-
const s = Date.now(), i = t === void 0 ? void 0 : setTimeout(() => o.abort(new d("timeout", `报表执行超过 ${t}ms`)), t);
|
|
28
|
-
let c;
|
|
29
|
-
try {
|
|
30
|
-
g(o.signal);
|
|
31
|
-
const f = new Promise((u, w) => {
|
|
32
|
-
c = () => {
|
|
33
|
-
try {
|
|
34
|
-
g(o.signal);
|
|
35
|
-
} catch (l) {
|
|
36
|
-
w(l);
|
|
37
|
-
}
|
|
38
|
-
}, o.signal.addEventListener("abort", c, { once: !0 });
|
|
39
|
-
}), b = await Promise.race([n(o.signal), f]);
|
|
40
|
-
if (g(o.signal), t !== void 0 && Date.now() - s > t) throw new d("timeout", `报表执行超过 ${t}ms`);
|
|
41
|
-
return b;
|
|
42
|
-
} finally {
|
|
43
|
-
i !== void 0 && clearTimeout(i), c && o.signal.removeEventListener("abort", c), e?.removeEventListener("abort", r);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
const p = new Uint32Array([
|
|
47
|
-
1116352408,
|
|
48
|
-
1899447441,
|
|
49
|
-
3049323471,
|
|
50
|
-
3921009573,
|
|
51
|
-
961987163,
|
|
52
|
-
1508970993,
|
|
53
|
-
2453635748,
|
|
54
|
-
2870763221,
|
|
55
|
-
3624381080,
|
|
56
|
-
310598401,
|
|
57
|
-
607225278,
|
|
58
|
-
1426881987,
|
|
59
|
-
1925078388,
|
|
60
|
-
2162078206,
|
|
61
|
-
2614888103,
|
|
62
|
-
3248222580,
|
|
63
|
-
3835390401,
|
|
64
|
-
4022224774,
|
|
65
|
-
264347078,
|
|
66
|
-
604807628,
|
|
67
|
-
770255983,
|
|
68
|
-
1249150122,
|
|
69
|
-
1555081692,
|
|
70
|
-
1996064986,
|
|
71
|
-
2554220882,
|
|
72
|
-
2821834349,
|
|
73
|
-
2952996808,
|
|
74
|
-
3210313671,
|
|
75
|
-
3336571891,
|
|
76
|
-
3584528711,
|
|
77
|
-
113926993,
|
|
78
|
-
338241895,
|
|
79
|
-
666307205,
|
|
80
|
-
773529912,
|
|
81
|
-
1294757372,
|
|
82
|
-
1396182291,
|
|
83
|
-
1695183700,
|
|
84
|
-
1986661051,
|
|
85
|
-
2177026350,
|
|
86
|
-
2456956037,
|
|
87
|
-
2730485921,
|
|
88
|
-
2820302411,
|
|
89
|
-
3259730800,
|
|
90
|
-
3345764771,
|
|
91
|
-
3516065817,
|
|
92
|
-
3600352804,
|
|
93
|
-
4094571909,
|
|
94
|
-
275423344,
|
|
95
|
-
430227734,
|
|
96
|
-
506948616,
|
|
97
|
-
659060556,
|
|
98
|
-
883997877,
|
|
99
|
-
958139571,
|
|
100
|
-
1322822218,
|
|
101
|
-
1537002063,
|
|
102
|
-
1747873779,
|
|
103
|
-
1955562222,
|
|
104
|
-
2024104815,
|
|
105
|
-
2227730452,
|
|
106
|
-
2361852424,
|
|
107
|
-
2428436474,
|
|
108
|
-
2756734187,
|
|
109
|
-
3204031479,
|
|
110
|
-
3329325298
|
|
111
|
-
]), a = (e, t) => e >>> t | e << 32 - t;
|
|
112
|
-
function m(e, t, n) {
|
|
113
|
-
const o = new DataView(e.buffer, e.byteOffset + t, 64);
|
|
114
|
-
for (let r = 0; r < 16; r++) n[r] = o.getUint32(r * 4);
|
|
115
|
-
for (let r = 16; r < 64; r++) {
|
|
116
|
-
const s = n[r - 15], i = n[r - 2], c = a(s, 7) ^ a(s, 18) ^ s >>> 3, f = a(i, 17) ^ a(i, 19) ^ i >>> 10;
|
|
117
|
-
n[r] = n[r - 16] + c + n[r - 7] + f;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
function v(e, t) {
|
|
121
|
-
let n = e[0], o = e[1], r = e[2], s = e[3], i = e[4], c = e[5], f = e[6], b = e[7];
|
|
122
|
-
for (let u = 0; u < 64; u++) {
|
|
123
|
-
const w = a(i, 6) ^ a(i, 11) ^ a(i, 25), l = i & c ^ ~i & f, h = b + w + l + p[u] + t[u] >>> 0, x = a(n, 2) ^ a(n, 13) ^ a(n, 22), E = n & o ^ n & r ^ o & r, U = x + E >>> 0;
|
|
124
|
-
b = f, f = c, c = i, i = s + h >>> 0, s = r, r = o, o = n, n = h + U >>> 0;
|
|
125
|
-
}
|
|
126
|
-
e[0] = e[0] + n, e[1] = e[1] + o, e[2] = e[2] + r, e[3] = e[3] + s, e[4] = e[4] + i, e[5] = e[5] + c, e[6] = e[6] + f, e[7] = e[7] + b;
|
|
127
|
-
}
|
|
128
|
-
function y(e) {
|
|
129
|
-
const t = new Uint8Array(Math.ceil((e.byteLength + 9) / 64) * 64);
|
|
130
|
-
t.set(e), t[e.byteLength] = 128;
|
|
131
|
-
const n = new DataView(t.buffer);
|
|
132
|
-
return n.setUint32(t.length - 8, Math.floor(e.byteLength / 536870912)), n.setUint32(t.length - 4, e.byteLength * 8 >>> 0), t;
|
|
133
|
-
}
|
|
134
|
-
const $ = () => new Uint32Array([1779033703, 3144134277, 1013904242, 2773480762, 1359893119, 2600822924, 528734635, 1541459225]), A = (e) => Array.from(e, (t) => t.toString(16).padStart(8, "0")).join("");
|
|
135
|
-
function S(e) {
|
|
136
|
-
const t = y(e), n = $(), o = new Uint32Array(64);
|
|
137
|
-
for (let r = 0; r < t.length; r += 64)
|
|
138
|
-
m(t, r, o), v(n, o);
|
|
139
|
-
return A(n);
|
|
140
|
-
}
|
|
141
|
-
async function j(e) {
|
|
142
|
-
const t = y(e), n = $(), o = new Uint32Array(64);
|
|
143
|
-
for (let r = 0; r < t.length; r += 64)
|
|
144
|
-
r > 0 && r % 262144 === 0 && await new Promise((s) => setTimeout(s, 0)), m(t, r, o), v(n, o);
|
|
145
|
-
return A(n);
|
|
146
|
-
}
|
|
147
|
-
export {
|
|
148
|
-
d as R,
|
|
149
|
-
D as a,
|
|
150
|
-
j as b,
|
|
151
|
-
R as c,
|
|
152
|
-
S as p,
|
|
153
|
-
g as t,
|
|
154
|
-
L as v
|
|
155
|
-
};
|
package/dist/style-CQ1PK8ZB.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { c as s, d as a, a as u, L as c, b as h } from "./defaults-DXhiM1ZD.js";
|
|
2
|
-
const l = 25.4, r = 96;
|
|
3
|
-
function f(t = r) {
|
|
4
|
-
return t / l;
|
|
5
|
-
}
|
|
6
|
-
function S(t, n = r) {
|
|
7
|
-
return (t || 0) * f(n);
|
|
8
|
-
}
|
|
9
|
-
function T(t, n = r) {
|
|
10
|
-
return t / f(n);
|
|
11
|
-
}
|
|
12
|
-
function m(t, n = r) {
|
|
13
|
-
return t * n / 72;
|
|
14
|
-
}
|
|
15
|
-
function d(t, n) {
|
|
16
|
-
const o = 10 ** n;
|
|
17
|
-
return Math.round(t * o) / o;
|
|
18
|
-
}
|
|
19
|
-
const x = {
|
|
20
|
-
a3: { widthMm: 297, heightMm: 420 },
|
|
21
|
-
a4: { widthMm: 210, heightMm: 297 },
|
|
22
|
-
a5: { widthMm: 148, heightMm: 210 },
|
|
23
|
-
b4: { widthMm: 250, heightMm: 353 },
|
|
24
|
-
b5: { widthMm: 176, heightMm: 250 }
|
|
25
|
-
};
|
|
26
|
-
function z(t, n = 96, o = s) {
|
|
27
|
-
if (t?.fontSizePx != null)
|
|
28
|
-
return { fontSizePt: t.fontSizePx * 72 / n, fontSizePx: t.fontSizePx };
|
|
29
|
-
const e = t?.fontSize ?? o;
|
|
30
|
-
return { fontSizePt: e, fontSizePx: m(e, n) };
|
|
31
|
-
}
|
|
32
|
-
function M(t, n = a) {
|
|
33
|
-
return {
|
|
34
|
-
color: t?.borderColor ?? t?.lineColor ?? n,
|
|
35
|
-
widthPt: t?.lineWidthPt ?? h
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
function _(t, n = u) {
|
|
39
|
-
return t?.color ?? n;
|
|
40
|
-
}
|
|
41
|
-
function g(t) {
|
|
42
|
-
return t?.lineHeight ?? c;
|
|
43
|
-
}
|
|
44
|
-
function E(t) {
|
|
45
|
-
const n = t?.borderTop !== !1, o = t?.borderRight !== !1, e = t?.borderBottom !== !1, i = t?.borderLeft !== !1;
|
|
46
|
-
return { top: n, right: o, bottom: e, left: i, inner: n || o || e || i };
|
|
47
|
-
}
|
|
48
|
-
function b(t, n) {
|
|
49
|
-
const o = { ...t, ...n };
|
|
50
|
-
return n?.fontSize != null && n.fontSizePx == null && delete o.fontSizePx, n?.fontSizePx != null && n.fontSize == null && delete o.fontSize, o;
|
|
51
|
-
}
|
|
52
|
-
export {
|
|
53
|
-
r as C,
|
|
54
|
-
l as M,
|
|
55
|
-
x as P,
|
|
56
|
-
d as a,
|
|
57
|
-
g as b,
|
|
58
|
-
M as c,
|
|
59
|
-
E as d,
|
|
60
|
-
b as e,
|
|
61
|
-
_ as f,
|
|
62
|
-
f as g,
|
|
63
|
-
T as h,
|
|
64
|
-
S as m,
|
|
65
|
-
m as p,
|
|
66
|
-
z as r
|
|
67
|
-
};
|
package/dist/style-UgIJSA1F.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const r=require("./defaults-xhmcLLrf.cjs"),l=25.4,i=96;function f(o=i){return o/l}function P(o,t=i){return(o||0)*f(t)}function c(o,t=i){return o/f(t)}function S(o,t=i){return o*t/72}function m(o,t){const e=10**t;return Math.round(o*e)/e}const s={a3:{widthMm:297,heightMm:420},a4:{widthMm:210,heightMm:297},a5:{widthMm:148,heightMm:210},b4:{widthMm:250,heightMm:353},b5:{widthMm:176,heightMm:250}};function h(o,t=96,e=r.DEFAULT_FONT_PT){if(o?.fontSizePx!=null)return{fontSizePt:o.fontSizePx*72/t,fontSizePx:o.fontSizePx};const n=o?.fontSize??e;return{fontSizePt:n,fontSizePx:S(n,t)}}function T(o,t=r.DEFAULT_STROKE_COLOR){return{color:o?.borderColor??o?.lineColor??t,widthPt:o?.lineWidthPt??r.DEFAULT_BORDER_PT}}function x(o,t=r.DEFAULT_TEXT_COLOR){return o?.color??t}function M(o){return o?.lineHeight??r.LINE_HEIGHT}function _(o){const t=o?.borderTop!==!1,e=o?.borderRight!==!1,n=o?.borderBottom!==!1,u=o?.borderLeft!==!1;return{top:t,right:e,bottom:n,left:u,inner:t||e||n||u}}function d(o,t){const e={...o,...t};return t?.fontSize!=null&&t.fontSizePx==null&&delete e.fontSizePx,t?.fontSizePx!=null&&t.fontSize==null&&delete e.fontSize,e}exports.CSS_DPI=i;exports.MM_PER_INCH=l;exports.PAPER_SIZES=s;exports.mergeComponentStyles=d;exports.mmToPx=P;exports.mmToPxFactor=f;exports.ptToPx=S;exports.pxToMm=c;exports.resolveBoxBorders=_;exports.resolveFontSize=h;exports.resolveLineHeight=M;exports.resolveStroke=T;exports.resolveTextColor=x;exports.round=m;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const Q=require("./matrix-gEO7ZM_u.cjs"),L=require("./computed-CGV2a809.cjs"),Z=require("./render-plan-7xpGrCEl.cjs"),ee=require("./code-options-BUTChiZZ.cjs"),C=require("./param-validation-C3HlcLLO.cjs"),_=require("./tree-BX380Rr7.cjs");function te(e,i,t){e!==void 0&&(typeof e!="string"||!e.trim()||e.length>4096)&&t.push({path:i,message:"来源范围应为不超过 4096 字符的非空字符串"})}function D(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 ie(e,i,t){D(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:"派生结果标记应为布尔值"}),V(e.source,`${i}.source`,t,!0),e.formula!==void 0&&typeof e.formula!="string"&&t.push({path:`${i}.formula`,message:"单元格公式应为字符串"})}function V(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;te(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 se=new Set(["text","image","barcode","qrcode","chart","line","rect","ellipse"]);function p(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ne(e,i,t,s){const n=e[i];(typeof n!="number"||!Number.isFinite(n))&&s.push({path:`${t}.${i}`,message:`应为有限数字,实际 ${JSON.stringify(n)}`})}function ae(e,i,t){if(e!==void 0){const s=`${i}.table`;if(!p(e))t.push({path:s,message:"逻辑表来源应为对象"});else{V(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 oe(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((f,r)=>{if(f==null)return;const d=`${i}.grid.cells.${o}.${r}`;if(!p(f)){t.push({path:d,message:"网格单元格应为对象或 null"});return}ie(f,d,t),Array.isArray(f.children)&&f.children.forEach((u,g)=>{v(u,`${i}.grid.cells.${o}.${r}.children.${g}`,t,s)})})})}}function fe(e,i,t){e!==void 0&&(Array.isArray(e)?e.forEach((s,n)=>{(!p(s)||!Array.isArray(s.segments))&&t.push({path:`${i}.richParagraphs.${n}`,message:"段落缺少 segments 数组"})}):t.push({path:`${i}.richParagraphs`,message:"richParagraphs 应为数组"}))}function v(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 字符串"}):se.has(n)||s.push({path:`${i}.kind`,message:`未知组件类型 ${JSON.stringify(n)},将以兜底方式渲染`});for(const a of["leftMm","topMm","widthMm","heightMm"])ne(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:"组件尺寸不能为负数"});ae(e.table,i,t),re(e.code,n,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"}),oe(e.grid,i,t,s),fe(e.richParagraphs,i,t)}function re(e,i,t,s){if(e!==void 0)for(const n of ee.codeOptionIssues(e,i))s.push({path:`${t}.code${n.path?`.${n.path}`:""}`,message:n.message})}function J(e,i,t){if(!p(e))return;e.binding!==void 0&&t.push({path:`${i}.binding`,message:"渲染计划不允许未解析字段绑定"});const s=e.grid;!p(s)||!Array.isArray(s.cells)||s.cells.forEach((n,a)=>{Array.isArray(n)&&n.forEach((o,f)=>{!p(o)||!Array.isArray(o.children)||o.children.forEach((r,d)=>J(r,`${i}.grid.cells.${a}.${f}.children.${d}`,t))})})}function j(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:`页宽非法: ${JSON.stringify(n)}`}),(typeof a!="number"||!(a>0&&a<5e3))&&t.push({path:`${i}.pageHeightMm`,message:`页高非法: ${JSON.stringify(a)}`}),e.layout!==void 0&&e.layout!=="page"&&e.layout!=="wide"&&t.push({path:`${i}.layout`,message:"布局应为 page 或 wide"});const o=e.components;Array.isArray(o)?Array.isArray(o)&&o.forEach((f,r)=>{v(f,`${i}.components.${r}`,t,s),J(f,`${i}.components.${r}`,t)}):t.push({path:`${i}.components`,message:"components 应为数组"})}function K(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{s.forEach((a,o)=>j(a,`$.pages.${o}`,i,t)),s.length>2e3&&t.push({path:"$.pages",message:`页数异常大(${s.length} 页),渲染与打印耗时可能显著增加`});const n=s.reduce((a,o)=>a+(p(o)&&Array.isArray(o.components)?o.components.length:0),0);n>5e4&&t.push({path:"$.pages",message:`组件总数异常大(${n} 个),可能触发浏览器性能限制`})}return{ok:i.length===0,errors:i,warnings:t}}function de(e){const i=K(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 T(e){return e.kind==="list"?e.id:e.nid}function ue(e){return e.kind==="list"?!1:e.pageAnchor!==void 0||e.kind==="text"&&typeof e.text=="string"&&/\{(?:page|totalPages)\}/.test(e.text)}function he(e,i){const t=e.filter(n=>i.componentIds.includes(T(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=>[T(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 H(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(ue(n))continue;const a=T(n);if(!a||t.has(a))throw new Error("流式排版组件应具有唯一标识");t.add(a)}if(ce(e,i,t,s),s.size!==t.size)throw new Error("流式排版必须显式包含每个非锚点组件")}function ce(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)}he(e,a),n=a.topMm+a.heightMm}}const ge=new Set(["__proto__","prototype","constructor"]);function l(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function N(e){return typeof e=="string"&&!!e.trim()&&!ge.has(e)}function k(e,i,t,s){for(const n of Object.keys(e))i.includes(n)||s.push({path:`${t}.${n}`,message:"存在未知配置字段"})}function pe(e,i,t){if(e!==void 0){if(!l(e)||!["number","percent","date"].includes(String(e.kind))){t.push({path:i,message:"绑定格式应为 number、percent 或 date"});return}k(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 ye(e,i,t){const s=e.binding;if(s===void 0)return;const n=`${i}.binding`;if(!l(s)){t.push({path:n,message:"字段绑定应为对象"});return}(!["text","image","barcode","qrcode"].includes(String(e.kind))||e.grid!==void 0)&&t.push({path:n,message:"绑定仅支持独立文本、图片、条码与二维码组件"}),k(s,["field","format","prefix","suffix","emptyText"],n,t),N(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:"应为字符串"});pe(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 le(e,i){if(!l(e)){i.push({path:"$.repeat",message:"逐记录配置应为对象"});return}k(e,["dataset","rowKey","copies"],"$.repeat",i),N(e.dataset)||i.push({path:"$.repeat.dataset",message:"数据集应为安全的非空名称"}),e.rowKey!==void 0&&!N(e.rowKey)&&i.push({path:"$.repeat.rowKey",message:"业务主键应为安全的非空字段名"});const t=e.copies;t!==void 0&&(l(t)?(k(t,["field"],"$.repeat.copies",i),N(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 W(e,i,t,s){if(!l(e))return;ye(e,i,s),e.binding!==void 0&&!t&&s.push({path:`${i}.binding`,message:"字段绑定需要模板 repeat 数据集;普通报表请使用列表字段"}),t&&e.kind==="list"&&s.push({path:i,message:"逐记录标签使用固定组件;动态列表请使用普通报表模板"});const n=e.grid;l(n)&&Array.isArray(n.cells)&&n.cells.forEach((a,o)=>{Array.isArray(a)&&a.forEach((f,r)=>{l(f)&&Array.isArray(f.children)&&f.children.forEach((d,u)=>W(d,`${i}.grid.cells.${o}.${r}.children.${u}`,t,s))})})}function G(e,i){const t=e.repeat!==void 0;t&&le(e.repeat,i),Array.isArray(e.pages)&&e.pages.forEach((s,n)=>{if(!l(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,f)=>{const r=`${a}.components.${f}`;if(W(o,r,t,i),!t||!l(o))return;const{leftMm:d,topMm:u,widthMm:g,heightMm:y}=o;[d,u,g,y,s.widthMm,s.heightMm].every(A=>typeof A=="number"&&Number.isFinite(A))&&(Number(d)<0||Number(u)<0||Number(d)+Number(g)>Number(s.widthMm)+.001||Number(u)+Number(y)>Number(s.heightMm)+.001)&&i.push({path:r,message:"标签组件超出纸张边界,请调整位置或尺寸"})})})}function U(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function R(e,i,t){if(e!==void 0){if(!U(e)){t.push({path:i,message:"条件应为对象"});return}(typeof e.field!="string"||!e.field.trim())&&t.push({path:`${i}.field`,message:"条件需要字段"}),e.numeric!==void 0&&e.numeric!=="number"&&e.numeric!=="decimal"&&t.push({path:`${i}.numeric`,message:"未知条件数值模式"}),[">",">=","<","<=","==","!="].includes(e.op)||t.push({path:`${i}.op`,message:"未知条件运算符"}),typeof e.value!="string"&&!(typeof e.value=="number"&&Number.isFinite(e.value))&&t.push({path:`${i}.value`,message:"条件值应为字符串或有限数字"})}}function q(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(!U(n)){t.push({path:o,message:"聚合应为对象"});return}const f=n.field;typeof f!="string"||!f.trim()||s.has(f)?t.push({path:`${o}.field`,message:"聚合输出字段应非空且唯一"}):s.add(f),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{L.createAggregateAccumulator({...n,field:n.valueField??f})}catch(r){t.push({path:o,message:r instanceof Error?r.message:String(r)})}})}function $e(e,i,t){if(e===void 0)return;const s=L.validateComputedFields(e);for(const n of s.errors)t.push({path:i,message:n})}function be(e,i,t){if(e!==void 0)try{Q.validateMatrixOptions(e)}catch(s){t.push({path:i,message:s instanceof Error?s.message:String(s)})}}function Ae(e,i,t){if(e.tree===void 0)return;const s=`${i}.tree`;try{_.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)&&_.validateTreeComputed(n,e.computed)}catch(n){t.push({path:s,message:n instanceof Error?n.message:String(n)})}}const O="1.0";class w extends Error{constructor(i){super(`模板校验失败:${i.slice(0,3).map(t=>`${t.path}: ${t.message}`).join("; ")}`),this.errors=i,this.name="ReportTemplateError"}}const we=new Set(["__proto__","prototype","constructor"]),Me=new Set(["schemaVersion","id","name","revision","description","template"]),ve=new Set(["left","center","right","justify"]),E=2e5,Ne=64,P=1e7;function h(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Ee(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 we.has(e)?(s.push({path:t,message:"模板不能包含可能污染原型的键"}),!1):i.get||i.set||!i.enumerable?(s.push({path:t,message:"模板不能包含访问器或不可枚举字段"}),!1):!0}function Se(e){return e===null||typeof e=="boolean"||typeof e=="number"&&Number.isFinite(e)}function F(e,i){const t=new Set;let s=0,n=0,a=!1;const o=(f,r,d)=>{if(!a){if(++s>E){s===E+1&&i.push({path:r,message:"模板超过 JSON 节点安全上限"});return}if(d>Ne){i.push({path:r,message:"模板嵌套层级过深"});return}if(typeof f=="string"){n+=f.length,n>P&&(a=!0,i.push({path:r,message:"模板文本超过 1000 万字符的安全上限"}));return}if(!Se(f)){if(!f||typeof f!="object"){i.push({path:r,message:"模板只允许 JSON 值,不允许函数、undefined 或非有限数字"});return}if(t.has(f)){i.push({path:r,message:"模板不能包含循环引用"});return}if(Ee(f,r,i)){t.add(f);for(const[u,g]of Object.entries(Object.getOwnPropertyDescriptors(f))){if(Array.isArray(f)&&u==="length")continue;const y=`${r}.${u}`;if(ke(u,g,y,i)&&o(g.value,y,d+1),s>E||a)break}t.delete(f)}}}};o(e,"$",0)}function m(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 c(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 b(e,i,t,s){e[i]!==void 0&&typeof e[i]!="boolean"&&s.push({path:`${t}.${i}`,message:"应为布尔值"})}function M(e,i,t,s=!1){e!==void 0&&!ve.has(e)&&!(s&&e==="auto")&&t.push({path:i,message:`未知对齐方式${s?"(支持 auto)":""}`})}function $(e,i,t){if(e!==void 0){if(!h(e)){t.push({path:i,message:"样式应为对象"});return}M(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"])c(e,s,i,t);for(const s of["letterSpacing","rotateDeg"])c(e,s,i,t,-1/0);c(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"])b(e,s,i,t);for(const s of["fontFamily","color","backgroundColor","lineColor","borderColor"])m(e,s,i,t)}}function xe(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 f=`${i}.${o}`;if(!h(a)){t.push({path:f,message:"参数定义应为对象"});return}m(a,"field",f,t,!0),typeof a.field=="string"&&(s.has(a.field)&&t.push({path:`${f}.field`,message:"参数名重复"}),s.add(a.field)),a.type!==void 0&&!["text","number","date","month","year","dateRange","select"].includes(a.type)&&t.push({path:`${f}.type`,message:"未知参数类型"});for(const r of["label","defaultValue","placeholder"])m(a,r,f,t);b(a,"required",f,t);for(const r of["minLength","maxLength"]){const d=a[r];d!==void 0&&(typeof d!="number"||!Number.isSafeInteger(d)||d<0)&&t.push({path:`${f}.${r}`,message:"长度边界应为非负整数"})}Re(a,f,t),a.options!==void 0&&(Array.isArray(a.options)?a.options.forEach((r,d)=>{const u=`${f}.options.${d}`;if(!h(r))t.push({path:u,message:"选项应为对象"});else for(const g of["label","value"])typeof r[g]!="string"&&t.push({path:`${u}.${g}`,message:"选项标签与值应为字符串(允许空白选项)"})}):t.push({path:`${f}.options`,message:"选项应为数组"}))}),t.length===n&&t.push(...C.validateReportParamDefinitions(e).map(a=>({path:a.path.replace("$.paramDefs",i),message:a.message})))}function Re(e,i,t){for(const a of["min","max"]){const o=e[a];if(o===void 0)continue;C.isReportTemporalBound(e.type,o)||e.type==="number"&&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 B(e,i,t){if(!Array.isArray(e)||e.length===0){t.push({path:i,message:"列表至少需要一列"});return}e.every(s=>h(s)&&s.hidden===!0)&&t.push({path:i,message:"列表至少需要一列可见列"}),e.forEach((s,n)=>{const a=`${i}.${n}`;if(!h(s)){t.push({path:a,message:"列应为对象"});return}if(D(s,a,t),b(s,"hidden",a,t),R(s.visibleWhen,`${a}.visibleWhen`,t),typeof s.header!="string"&&t.push({path:`${a}.header`,message:"表头应为字符串(允许空白表头)"}),m(s,"field",a,t,!0),c(s,"widthMm",a,t,Number.MIN_VALUE,!0),$(s.style,`${a}.style`,t),$(s.headerStyle,`${a}.headerStyle`,t),M(s.align,`${a}.align`,t,!0),M(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(!h(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 的整数"}),b(s.format,"thousands",`${a}.format`,t),m(s.format,"pattern",`${a}.format`,t)}s.rules!==void 0&&(Array.isArray(s.rules)?s.rules.forEach((o,f)=>{const r=`${a}.rules.${f}`;if(!h(o)||!h(o.when)){t.push({path:r,message:"条件格式缺少 when 对象"});return}R(o.when,`${r}.when`,t),m(o.when,"field",`${r}.when`,t,!0),[">",">=","<","<=","==","!="].includes(o.when.op)||t.push({path:`${r}.when.op`,message:"未知条件运算符"}),typeof o.when.value!="number"&&typeof o.when.value!="string"&&t.push({path:`${r}.when.value`,message:"条件值应为数字或字符串"}),$(o.style,`${r}.style`,t)}):t.push({path:`${a}.rules`,message:"条件格式应为数组"}))})}function z(e,i,t){if(e!==void 0){if(!h(e)){t.push({path:i,message:"分组应为对象"});return}m(e,"field",i,t,!0);for(const s of["headerTemplate","subtotalLabel"])m(e,s,i,t);for(const s of["headerStyle","subtotalStyle"])$(e[s],`${i}.${s}`,t);b(e,"keepWithNext",i,t),b(e,"repeatHeader",i,t),q(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 Te(e,i,t){if(!(e===void 0||typeof e=="boolean")){if(!h(e)){t.push({path:i,message:"合计应为布尔值或对象"});return}m(e,"label",i,t),q(e.aggregates,`${i}.aggregates`,t),$(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 Oe(e,i,t,s){const n={kind:"rect",leftMm:0,topMm:0,widthMm:1,heightMm:1,grid:e};if(v(n,t,s,[]),I(n,t,s),!h(e)||!Array.isArray(e.cells))return;const a=e.cells,o=Array.isArray(i)?i.length:0;if(a.length*o>E){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:"表头行高数量应与行数一致"}),Pe(a,o,t,s)}function Pe(e,i,t,s){const n=new Set;e.forEach((a,o)=>{if(!Array.isArray(a))return;let f=0;a.forEach((r,d)=>{for(;n.has(`${o}:${f}`);)f++;const u=h(r)&&typeof r.colSpan=="number"?r.colSpan:1,g=h(r)&&typeof r.rowSpan=="number"?r.rowSpan:1;(f+u>i||o+g>e.length)&&s.push({path:`${t}.cells.${o}.${d}`,message:"表头合并区域超出表头边界"});for(let y=o;y<Math.min(e.length,o+g);y++)for(let A=f;A<Math.min(i,f+u);A++)n.has(`${y}:${A}`)&&s.push({path:`${t}.cells.${o}.${d}`,message:"表头合并区域重叠"}),n.add(`${y}:${A}`);f+=u})})}function Fe(e,i,t){if(Ae(e,i,t),$e(e.computed,`${i}.computed`,t),be(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 汇总,不能同时配置普通分组、总计或主从明细"}),R(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)=>z(a,`${i}.groups.${o}`,t))),e.detail===void 0)return;const s=e.detail,n=`${i}.detail`;if(!h(s)){t.push({path:n,message:"主从关联应为对象"});return}for(const a of["dataset","parentKey","foreignKey"])m(s,a,n,t,!0);for(const a of["rowKey","revisionField","sourceTokenField"])m(s,a,n,t,s[a]!==void 0);m(s,"label",n,t),b(s,"header",n,t),c(s,"rowHeightMm",n,t,Number.MIN_VALUE),B(s.columns,`${n}.columns`,t),s.unmatched!==void 0&&s.unmatched!=="error"&&s.unmatched!=="ignore"&&t.push({path:`${n}.unmatched`,message:"未关联明细策略应为 error 或 ignore"})}function Ie(e,i,t){for(const s of["leftMm","topMm"])c(e,s,i,t,-1/0,!0);c(e,"widthMm",i,t,Number.MIN_VALUE,!0),m(e,"dataset",i,t,!0),m(e,"title",i,t);for(const s of["rowKey","revisionField","sourceTokenField"])m(e,s,i,t,e[s]!==void 0);e.headerGrid!==void 0&&Oe(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"}),B(e.columns,`${i}.columns`,t);for(const s of["fontSizePt","rowHeightMm"])c(e,s,i,t,Number.MIN_VALUE);c(e,"paddingMm",i,t);for(const s of["header","headerBold","headerEveryPage","border"])b(e,s,i,t);e.cardinality!==void 0&&e.cardinality!=="record"&&t.push({path:`${i}.cardinality`,message:"单记录区域类型应为 record"}),m(e,"headerBackgroundColor",i,t),M(e.align,`${i}.align`,t,!0),M(e.headerAlign,`${i}.headerAlign`,t),$(e.headerStyle,`${i}.headerStyle`,t),Fe(e,i,t),z(e.groupBy,`${i}.groupBy`,t),Te(e.grandTotal,`${i}.grandTotal`,t)}function I(e,i,t){$(e.style,`${i}.style`,t);for(const n of["text","rawText","imageData","fallbackText","nid","rkey"])m(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:"文本行应为字符串数组"}),Array.isArray(e.richParagraphs)&&e.richParagraphs.forEach((n,a)=>{if(!h(n))return;const o=`${i}.richParagraphs.${a}`;M(n.align,`${o}.align`,t);for(const f of["lineHeight","spaceBeforeMm","spaceAfterMm","indentMm"])c(n,f,o,t);Array.isArray(n.segments)&&n.segments.forEach((f,r)=>{const d=`${o}.segments.${r}`;if(!h(f)){t.push({path:d,message:"富文本片段应为对象"});return}f.kind!==void 0&&f.kind!=="text"&&f.kind!=="field"&&t.push({path:`${d}.kind`,message:"未知富文本片段类型"});for(const u of["text","field"])m(f,u,d,t);$(f.style,`${d}.style`,t)})}),!h(e.grid))return;const s=e.grid;c(s,"gapMm",`${i}.grid`,t),c(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,f)=>{const r=`${i}.grid.cells.${a}.${f}`;if(o!==null){if(!h(o)){t.push({path:r,message:"网格单元格应为对象或 null"});return}for(const d of["text","rawText","numberFormat"])m(o,d,r,t);for(const d of["colSpan","rowSpan"]){const u=o[d];u!==void 0&&(typeof u!="number"||!Number.isInteger(u)||u<=0)&&t.push({path:`${r}.${d}`,message:"跨度应为正整数"})}o.value!==void 0&&o.value!==null&&!["string","number","boolean"].includes(typeof o.value)&&t.push({path:`${r}.value`,message:"Excel 原始值应为字符串、数字、布尔值或 null"}),$(o.style,`${r}.style`,t),o.children!==void 0&&(Array.isArray(o.children)?o.children.forEach((d,u)=>{h(d)&&I(d,`${r}.children.${u}`,t)}):t.push({path:`${r}.children`,message:"嵌套组件应为数组"}))}})})}function _e(e,i,t){if(!(e.flow===void 0||!Array.isArray(e.components)))try{H(e.components,e.flow)}catch(s){t.push({path:`${i}.flow`,message:s instanceof Error?s.message:String(s)})}}function X(e){const i=[],t=[];return F(e,i),i.length?{ok:!1,errors:i,warnings:t}:(h(e)?(e.schemaVersion!==void 0&&e.schemaVersion!==Z.RENDER_PLAN_SCHEMA_VERSION&&i.push({path:"$.schemaVersion",message:"不支持的模板 schemaVersion"}),xe(e.params,"$.params",i),G(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(!h(s)){i.push({path:a,message:"页应为对象"});return}c(s,"widthMm",a,i,Number.MIN_VALUE,!0),c(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"])c(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,f)=>{const r=`${a}.components.${f}`;h(o)&&o.kind==="list"?Ie(o,r,i):(v(o,r,i,t),h(o)&&I(o,r,i))}):i.push({path:`${a}.components`,message:"组件应为数组"}),_e(s,a,i)})):i.push({path:"$",message:"模板应为对象"}),{ok:i.length===0,errors:i,warnings:t})}function Y(e){const i=[],t=[];if(F(e,i),i.length)return{ok:!1,errors:i,warnings:t};if(!h(e))i.push({path:"$",message:"模板文档应为对象"});else{for(const n of Object.keys(e))Me.has(n)||i.push({path:`$.${n}`,message:"模板文档存在未知字段;只保存模板与描述,不保存取数或业务数据"});e.schemaVersion!==O&&i.push({path:"$.schemaVersion",message:"不支持的模板文档版本"});for(const n of["id","name"])m(e,n,"$",i,!0);for(const n of["revision","description"])m(e,n,"$",i);const s=X(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 x(e){const i=Y(e);if(!i.ok)throw new w(i.errors)}function Le(e){const i=[];if(F(e,i),i.length)throw new w(i);const t={...e,schemaVersion:e.schemaVersion??O};return x(t),S(t)}function Ce(e){let i=e;if(typeof e=="string"){if(e.length>P)throw new w([{path:"$",message:"模板 JSON 超过 1000 万字符的导出/导入上限"}]);try{i=JSON.parse(e)}catch{throw new w([{path:"$",message:"模板 JSON 语法无效"}])}}return x(i),S(i)}function De(e){x(e);const i=JSON.stringify(e,null,2);if(i.length>P)throw new w([{path:"$",message:"模板 JSON 超过 1000 万字符的导出/导入上限"}]);return i}function S(e){return JSON.parse(JSON.stringify(e))}function Ve(e=[]){const i=new Map,t={get:s=>{const n=i.get(s);return n?S(n):void 0},list:()=>Array.from(i.values(),({template:s,...n})=>({...n})),register:(s,n={})=>{if(x(s),i.has(s.id)&&!n.replace)throw new w([{path:"$.id",message:`模板 ID ${s.id} 已注册;更新需显式 replace:true`}]);i.set(s.id,S(s))},remove:s=>i.delete(s)};for(const s of e)t.register(s);return t}exports.REPORT_TEMPLATE_DOCUMENT_VERSION=O;exports.ReportTemplateError=w;exports.assertRenderPlan=de;exports.createTemplateRegistry=Ve;exports.defineReportTemplate=Le;exports.parseReportTemplate=Ce;exports.reportFlowGroups=me;exports.serializeReportTemplate=De;exports.validateComponent=v;exports.validatePage=j;exports.validateRenderPlan=K;exports.validateReportPageFlow=H;exports.validateReportTemplate=X;exports.validateReportTemplateDocument=Y;exports.validateTemplateRepeat=G;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
"use strict";const w=require("./defaults-xhmcLLrf.cjs"),M=/[\u3000-\u9fff\uff00-\uffef]/,s=new Uint8Array(128);{for(const t of"iljtf.,:;'`|!()[]")s[t.charCodeAt(0)]=1;for(const t of"mwMW@")s[t.charCodeAt(0)]=2;for(let t=48;t<=57;t++)s[t]=3;for(let t=65;t<=90;t++)s[t]=4;s[32]=5}const g=[.54,.26,.95,.59,.67,.3];function d(t){const e=t.charCodeAt(0);return e<128?g[s[e]]:M.test(t)?1:/[A-Z]/.test(t)?.67:.54}const o={measureMm(t,e){const{fontSizePt:i,bold:c=!1,letterSpacingPt:u=0}=e,r=25.4/72;let n=0;for(const h of t)n+=d(h);return c&&(n*=1.04),(n*i+u*Math.max(0,Array.from(t).length-1))*r}};function p(){return o}function A(t,e){return o.measureMm(t,e)}function x(t){let e;return{measureMm(i,c){if(e===void 0&&(e=t()),!e)return o.measureMm(i,c);const u=c.fontSizePt*96/72;e.font=`${c.italic?"italic ":""}${c.bold?"bold ":""}${u}px ${c.fontFamily??w.DEFAULT_FONT_FAMILY}`,"letterSpacing"in e&&(e.letterSpacing="0px");const r=(c.letterSpacingPt??0)*Math.max(0,Array.from(i).length-1);return e.measureText(i).width*25.4/96+r*25.4/72}}}function T(t,e,i){const c=[];let u="";const r=()=>{u&&(c.push({text:u,widthMm:i.measureMm(u,e),cjk:!1}),u="")};for(const n of t){if(n===`
|
|
2
|
-
`){r(),c.push({text:`
|
|
3
|
-
`,widthMm:0,cjk:!1,br:!0});continue}if(n===" "){r(),c.push({text:n,widthMm:i.measureMm(n,e),cjk:!1,space:!0});continue}if(M.test(n)){r(),c.push({text:n,widthMm:i.measureMm(n,e),cjk:!0});continue}u+=n}return r(),c}function S(t,e,i,c=o){if(!t)return[""];t=t.replace(/\r\n?/g,`
|
|
4
|
-
`);const u=[];let r="",n=0;const h=(i.letterSpacingPt??0)*25.4/72,a=()=>{u.push(r),r="",n=0};for(const f of T(t,i,c)){if(f.br){a();continue}const m=r.length>0?h:0;if(n+m+f.widthMm<=e){r+=f.text,n+=m+f.widthMm;continue}if(f.space){a();continue}if(f.cjk){r.length>0&&a(),r=f.text,n=f.widthMm;continue}if(r.length>0&&a(),f.widthMm<=e){r=f.text,n=f.widthMm;continue}for(const l of f.text)c.measureMm(r+l,i)>e&&r.length>0&&a(),r+=l,n=c.measureMm(r,i)}return a(),u}exports.charWidthEm=d;exports.createCanvasMeasurer=x;exports.createHeuristicMeasurer=p;exports.heuristicMeasurer=o;exports.measureTextMm=A;exports.wrapText=S;
|