@agile-team/mach-report 2.20.0 → 2.21.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/README.md +6 -2
  2. package/dist/{ExcelBindingWizard-B7aeRg46.cjs → ExcelBindingWizard-Bu0LUlzl.cjs} +1 -1
  3. package/dist/{ExcelBindingWizard-Chn6ZC2-.js → ExcelBindingWizard-mnAO2qOX.js} +3 -3
  4. package/dist/{ParamEditor-BdFMa1CX.cjs → ParamEditor-38ZfNrPU.cjs} +1 -1
  5. package/dist/{ParamEditor-o-7E7WZZ.js → ParamEditor-C8l0EC8m.js} +1 -1
  6. package/dist/{ReportBatchPanel-CNJ4Useq.js → ReportBatchPanel-CfUVhvkO.js} +1 -1
  7. package/dist/{ReportBatchPanel-DVpmB7tG.cjs → ReportBatchPanel-nCC06Nfp.cjs} +1 -1
  8. package/dist/ReportLabelStudio-CaEvYuSK.cjs +1 -0
  9. package/dist/ReportLabelStudio-DQPBmh4v.js +765 -0
  10. package/dist/{ReportPreview-CGcxwkAn.js → ReportPreview-BBJNlu2U.js} +8 -8
  11. package/dist/{ReportPreview-hlwvZ1wf.cjs → ReportPreview-nf4Dk1Jc.cjs} +2 -2
  12. package/dist/{ReportTemplateLibrary-DyIJhJjX.js → ReportTemplateLibrary-B5t_EcIs.js} +1 -1
  13. package/dist/{ReportTemplateLibrary-DjjyZnZB.cjs → ReportTemplateLibrary-DVlsf72p.cjs} +1 -1
  14. package/dist/{RuleEditor-BeknHHOD.js → RuleEditor-kT1JsZ9f.js} +3 -3
  15. package/dist/RuleEditor-xFkCVlii.cjs +1 -0
  16. package/dist/{TemplateOutlinePanel-Bv8CxbXS.js → TemplateOutlinePanel-BesgGR1P.js} +1 -1
  17. package/dist/{TemplateOutlinePanel-D6TXg1aV.cjs → TemplateOutlinePanel-CDI6mfWx.cjs} +1 -1
  18. package/dist/{TemplateReusePanel-wrSbd_mr.cjs → TemplateReusePanel-BG9Or5-P.cjs} +1 -1
  19. package/dist/{TemplateReusePanel-CfousvPY.js → TemplateReusePanel-BNFU6V-W.js} +2 -2
  20. package/dist/{TemplateReviewPanel-BKFcSbTh.cjs → TemplateReviewPanel-BmBrjt6P.cjs} +1 -1
  21. package/dist/{TemplateReviewPanel-F2tqWNLO.js → TemplateReviewPanel-CwvwyCSs.js} +1 -1
  22. package/dist/artifact-integrity.json +90 -92
  23. package/dist/{assets-2eC3mOcV.js → assets-CxHunY_9.js} +2 -2
  24. package/dist/{assets-B0Hxn4l6.cjs → assets-vbjAGgk8.cjs} +1 -1
  25. package/dist/{auto-BlchZ1b8.js → auto-BkdGiNtr.js} +4 -4
  26. package/dist/{auto-B0EZFIK1.cjs → auto-Tq7ReIC1.cjs} +1 -1
  27. package/dist/{component-tree-CvW4lzpv.js → component-tree-1_QCiQJX.js} +1 -1
  28. package/dist/component-tree-BjZIp6w9.cjs +1 -0
  29. package/dist/{data-bar-PtjXhMgN.js → data-bar-8baGYEZ9.js} +1 -1
  30. package/dist/{data-bar-Ce38juRZ.cjs → data-bar-YltqGTaC.cjs} +1 -1
  31. package/dist/designer-DU3yDWgs.cjs +2 -0
  32. package/dist/designer-HQi-03R6.js +6869 -0
  33. package/dist/designer.cjs +1 -1
  34. package/dist/designer.d.cts +25 -3
  35. package/dist/designer.d.ts +25 -3
  36. package/dist/designer.js +1 -1
  37. package/dist/{encoding-B--eZpp1.cjs → encoding-B79hW4zq.cjs} +1 -1
  38. package/dist/{encoding-mctOLocI.js → encoding-BSeUwrN7.js} +2 -2
  39. package/dist/{font-loader-DBBJ5KE9.cjs → font-loader-BB372_XN.cjs} +1 -1
  40. package/dist/{font-loader-DW8tIaNp.js → font-loader-Di0lQKFf.js} +1 -1
  41. package/dist/grid-geometry-D3SJgWFv.js +136 -0
  42. package/dist/grid-geometry-D8ReblRV.cjs +1 -0
  43. package/dist/index.cjs +6 -6
  44. package/dist/index.js +194 -195
  45. package/dist/json-snapshot-I5VI84Vp.cjs +2 -0
  46. package/dist/{json-snapshot-By4ZVVUt.js → json-snapshot-Kgn459Oj.js} +895 -879
  47. package/dist/{pdf-DqyxJ96U.cjs → pdf-CARdBcuw.cjs} +45 -45
  48. package/dist/{pdf-CKROKygt.js → pdf-DmlnL5eB.js} +13 -14
  49. package/dist/pdf.cjs +1 -1
  50. package/dist/pdf.js +2 -2
  51. package/dist/{plugin-BMsIIJDh.cjs → plugin-BaRUGORD.cjs} +1 -1
  52. package/dist/{plugin-Co1oKD7T.js → plugin-D4kAxfLG.js} +1 -1
  53. package/dist/{prefill-D7EswyTI.cjs → prefill-Bpyn58AZ.cjs} +1 -1
  54. package/dist/{prefill-B8H9qwE4.js → prefill-CJSazcVY.js} +2 -2
  55. package/dist/{prepared-CGVphji3.cjs → prepared-BiSz_9vN.cjs} +1 -1
  56. package/dist/{prepared-BE-4jfX5.js → prepared-BwjwEzFz.js} +1 -1
  57. package/dist/{protocol-Cr81vFSQ.js → protocol-Bs9-ohHN.js} +3 -3
  58. package/dist/{protocol-ByRVzzQG.cjs → protocol-C8VWF9An.cjs} +1 -1
  59. package/dist/record-bindings-Ct1HkPrc.cjs +1 -0
  60. package/dist/{record-bindings-DEJtmo3p.js → record-bindings-VZGS-Qd8.js} +1 -1
  61. package/dist/{region-binding-workflow-CBg0l_tj.js → region-binding-workflow-Cy4GIOUo.js} +2 -2
  62. package/dist/{region-binding-workflow-D05tOYn3.cjs → region-binding-workflow-JNowHd0A.cjs} +1 -1
  63. package/dist/report-encoding-worker.cjs +1 -1
  64. package/dist/report-encoding-worker.js +1 -1
  65. package/dist/rich-text-layout-K48VHUoW.cjs +3 -0
  66. package/dist/{rich-text-layout-Ct5WrY1g.js → rich-text-layout-wxBhnAS7.js} +1 -1
  67. package/dist/{runtime-CEMvybO7.js → runtime-BDf5x1i1.js} +5 -5
  68. package/dist/runtime-DsJt1PIf.cjs +1 -0
  69. package/dist/sbom.cdx.json +1 -1
  70. package/dist/server-node.cjs +4 -4
  71. package/dist/server-node.js +1272 -1274
  72. package/dist/server.cjs +1 -1
  73. package/dist/server.js +8 -8
  74. package/dist/style.css +1 -1
  75. package/dist/{template-catalog-CmbWOJqy.js → template-catalog-DFwIS9aN.js} +3 -3
  76. package/dist/{template-catalog-Utu4GP09.cjs → template-catalog-D_2jdnkL.cjs} +1 -1
  77. package/dist/template-fragments-DZVUBhuB.cjs +1 -0
  78. package/dist/{template-fragments-DWgo9tlZ.js → template-fragments-Dng-AlHk.js} +11 -11
  79. package/dist/{template-registry-BIhIHOab.js → template-registry-DhBqoD7W.js} +120 -118
  80. package/dist/template-registry-DpLUSLwF.cjs +1 -0
  81. package/dist/{column-visual-BpgQVWwT.js → template-serialization-Cc3h-miv.js} +74 -65
  82. package/dist/{column-visual-CtYxnBCP.cjs → template-serialization-D1R5oAqh.cjs} +1 -1
  83. package/dist/{textwrap-BEIg2w8y.js → textwrap-CkGjRFT3.js} +1 -1
  84. package/dist/textwrap-OTOUMr4f.cjs +4 -0
  85. package/dist/vue-async.cjs +1 -1
  86. package/dist/vue-async.js +3 -3
  87. package/dist/vue.cjs +1 -1
  88. package/dist/vue.js +4 -4
  89. package/dist/{workbook-session-B94EwVa_.cjs → workbook-session-NYv01LHe.cjs} +1 -1
  90. package/dist/{workbook-session-BoScoOg-.js → workbook-session-oinxX3qo.js} +2 -2
  91. package/dist/worker.cjs +1 -1
  92. package/dist/worker.js +4 -4
  93. package/dist/xlsx.cjs +4 -4
  94. package/dist/xlsx.js +204 -205
  95. package/package.json +1 -1
  96. package/dist/ReportLabelStudio-Drsm9sAS.cjs +0 -1
  97. package/dist/ReportLabelStudio-r8VFnhGQ.js +0 -589
  98. package/dist/RuleEditor-BVuRn_OQ.cjs +0 -1
  99. package/dist/component-tree-6TV7W6Yj.cjs +0 -1
  100. package/dist/designer-B52ddmHO.js +0 -6676
  101. package/dist/designer-Dtsw_rh7.cjs +0 -2
  102. package/dist/grid-geometry-BNptEcMm.js +0 -65
  103. package/dist/grid-geometry-CZ_cYB6O.cjs +0 -1
  104. package/dist/json-snapshot-jiXff4lc.cjs +0 -2
  105. package/dist/record-bindings-ehjnCDHt.cjs +0 -1
  106. package/dist/rich-text-layout-ALlMoYOG.cjs +0 -3
  107. package/dist/runtime-CDA6d263.cjs +0 -1
  108. package/dist/style-67OqfNed.js +0 -73
  109. package/dist/style-C22Pbv3T.cjs +0 -1
  110. package/dist/template-fragments-C_zSHJAa.cjs +0 -1
  111. package/dist/template-registry-DzWswQI5.cjs +0 -1
  112. package/dist/textwrap-BI-yJ6Wt.cjs +0 -4
@@ -0,0 +1 @@
1
+ "use strict";const I=require("./computed-4TnxzgIh.cjs"),K=require("./matrix-0hywp0-F.cjs"),v=require("./component-tree-BjZIp6w9.cjs"),ne=require("./code-options-BUTChiZZ.cjs"),H=require("./param-validation-C-8sRJLq.cjs"),M=require("./template-serialization-D1R5oAqh.cjs");function ae(e,i,t){e!==void 0&&(typeof e!="string"||!e.trim()||e.length>4096)&&t.push({path:i,message:"来源范围应为不超过 4096 字符的非空字符串"})}function J(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 oe(e,i,t){J(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:"派生结果标记应为布尔值"}),W(e.source,`${i}.source`,t,!0),e.formula!==void 0&&typeof e.formula!="string"&&t.push({path:`${i}.formula`,message:"单元格公式应为字符串"})}function W(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;ae(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 re=new Set(["text","image","barcode","qrcode","chart","line","rect","ellipse"]);function g(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function S(e){return e===null?"null":typeof e=="string"?JSON.stringify(e.slice(0,120)):["number","boolean","undefined"].includes(typeof e)?String(e):`[${typeof e}]`}function fe(e,i,t,s){const n=e[i];(typeof n!="number"||!Number.isFinite(n))&&s.push({path:`${t}.${i}`,message:`应为有限数字,实际 ${S(n)}`})}function de(e,i,t){if(e!==void 0){const s=`${i}.table`;if(!g(e))t.push({path:s,message:"逻辑表来源应为对象"});else{W(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 ue(e,i,t,s){if(e!==void 0)if(!g(e)||!Array.isArray(e.cells))t.push({path:`${i}.grid.cells`,message:"grid.cells 应为二维数组"});else{const n=e.paddingMm;n!==void 0&&(typeof n!="number"||!Number.isFinite(n)||n<0)&&t.push({path:`${i}.grid.paddingMm`,message:"单元格内距应为有限非负数"}),e.cells.forEach((a,o)=>{if(!Array.isArray(a)){t.push({path:`${i}.grid.cells.${o}`,message:"行应为数组"});return}a.forEach((r,f)=>{if(r==null)return;const d=`${i}.grid.cells.${o}.${f}`;if(!g(r)){t.push({path:d,message:"网格单元格应为对象或 null"});return}oe(r,d,t),r.dataBar!==void 0&&!v.validDataBar(r.dataBar)&&t.push({path:`${d}.dataBar`,message:"数据条应包含 0–1 有序比例与 #RRGGBB 颜色"}),G(r.richParagraphs,d,t),Array.isArray(r.children)&&r.children.forEach((u,p)=>{C(u,`${i}.grid.cells.${o}.${f}.children.${p}`,t,s)})})})}}function R(e,i,t,s){e!==void 0&&!i.includes(e)&&s.push({path:t,message:"未知富文本属性值"})}function O(e,i,t,s,n=0){for(const a of i){const o=e[a];o!==void 0&&(typeof o!="number"||!Number.isFinite(o)||o<n)&&s.push({path:`${t}.${a}`,message:"富文本数值应为范围内有限数字"})}}function he(e,i,t){if(e!==void 0){if(!g(e)){t.push({path:i,message:"富文本样式应为对象"});return}for(const s of["fontFamily","color","backgroundColor","lineColor","borderColor"])e[s]!==void 0&&typeof e[s]!="string"&&t.push({path:`${i}.${s}`,message:"富文本样式应为字符串"});for(const s of["bold","italic","underline","borderTop","borderRight","borderBottom","borderLeft"])e[s]!==void 0&&typeof e[s]!="boolean"&&t.push({path:`${i}.${s}`,message:"富文本样式应为布尔值"});O(e,["fontSize","fontSizePx","lineWidthPt","lineHeight","opacity"],i,t),O(e,["letterSpacing","rotateDeg"],i,t,-1/0),typeof e.opacity=="number"&&e.opacity>1&&t.push({path:`${i}.opacity`,message:"透明度不能大于1"}),R(e.align,["left","center","right","justify"],`${i}.align`,t),R(e.verticalAlign,["top","middle","bottom"],`${i}.verticalAlign`,t)}}function me(e,i,t){if(!g(e)){t.push({path:i,message:"富文本片段应为对象"});return}R(e.kind,["text","field"],`${i}.kind`,t);for(const s of["text","field"])e[s]!==void 0&&typeof e[s]!="string"&&t.push({path:`${i}.${s}`,message:"富文本内容应为字符串"});he(e.style,`${i}.style`,t)}function G(e,i,t){if(e!==void 0){if(!Array.isArray(e)){t.push({path:`${i}.richParagraphs`,message:"richParagraphs 应为数组"});return}e.forEach((s,n)=>{const a=`${i}.richParagraphs.${n}`;if(!g(s)||!Array.isArray(s.segments)){t.push({path:a,message:"段落缺少 segments 数组"});return}R(s.align,["left","center","right","justify"],`${a}.align`,t),O(s,["lineHeight","spaceBeforeMm","spaceAfterMm","indentMm"],a,t),s.segments.forEach((o,r)=>me(o,`${a}.segments.${r}`,t))})}}function _(e,i,t,s=[]){const n=v.componentTreeIssue([e],i);if(n){t.push(n);return}C(e,i,t,s)}function C(e,i,t,s=[]){if(!g(e)){t.push({path:i,message:"组件应为对象"});return}const n=e.kind;typeof n!="string"?t.push({path:`${i}.kind`,message:"组件缺少 kind 字符串"}):re.has(n)||s.push({path:`${i}.kind`,message:`未知组件类型 ${S(n)},将以兜底方式渲染`});for(const a of["leftMm","topMm","widthMm","heightMm"])fe(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:"组件尺寸不能为负数"});de(e.table,i,t),ge(e.code,n,i,t),ce(e,i,t),e.pageAnchor!==void 0&&!["header","footer"].includes(e.pageAnchor)&&t.push({path:`${i}.pageAnchor`,message:"页面锚点应为 header 或 footer"}),e.lineDirection!==void 0&&!["down","up"].includes(e.lineDirection)&&t.push({path:`${i}.lineDirection`,message:"线段方向应为 down 或 up"}),ue(e.grid,i,t,s),G(e.richParagraphs,i,t)}function ce(e,i,t){if(e.chartBinding!==void 0)try{if(K.validateReportChartBinding(e.chartBinding),e.kind!=="chart"||["binding","imageData","grid","pageAnchor"].some(s=>e[s]!==void 0))throw new Error("绑定图表不能设置图片、网格、记录绑定或页眉页脚");if(typeof e.widthMm!="number"||e.widthMm<45||typeof e.heightMm!="number"||e.heightMm<35)throw new Error("绑定图表至少需要 45×35mm")}catch(s){t.push({path:`${i}.chartBinding`,message:s instanceof Error?s.message:String(s)})}}function ge(e,i,t,s){if(e!==void 0)for(const n of ne.codeOptionIssues(e,i))s.push({path:`${t}.code${n.path?`.${n.path}`:""}`,message:n.message})}function U(e,i,t){if(!g(e))return;e.binding!==void 0&&t.push({path:`${i}.binding`,message:"渲染计划不允许未解析字段绑定"}),e.chartBinding!==void 0&&t.push({path:`${i}.chartBinding`,message:"渲染计划不允许未解析图表绑定"});const s=e.grid;!g(s)||!Array.isArray(s.cells)||s.cells.forEach((n,a)=>{Array.isArray(n)&&n.forEach((o,r)=>{!g(o)||!Array.isArray(o.children)||o.children.forEach((f,d)=>U(f,`${i}.grid.cells.${a}.${r}.children.${d}`,t))})})}function q(e,i,t,s=[]){if(!g(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:`页宽非法: ${S(n)}`}),(typeof a!="number"||!(a>0&&a<5e3))&&t.push({path:`${i}.pageHeightMm`,message:`页高非法: ${S(a)}`}),e.layout!==void 0&&e.layout!=="page"&&e.layout!=="wide"&&t.push({path:`${i}.layout`,message:"布局应为 page 或 wide"});const o=e.components;if(!Array.isArray(o))t.push({path:`${i}.components`,message:"components 应为数组"});else if(Array.isArray(o)){const r=v.componentTreeIssue(o,`${i}.components`);if(r){t.push(r);return}o.forEach((f,d)=>{C(f,`${i}.components.${d}`,t,s),U(f,`${i}.components.${d}`,t)})}}function z(e){const i=[],t=[],s=g(e)?e.pages:void 0;if(g(e)&&e.requiresRecalculation!==void 0&&typeof e.requiresRecalculation!="boolean"&&i.push({path:"$.requiresRecalculation",message:"重算能力要求应为布尔值"}),!Array.isArray(s))i.push({path:"$.pages",message:e==null?"渲染计划为空":"渲染计划缺少 pages 数组"});else{const n=v.renderTreeIssue(s);if(n)return{ok:!1,errors:[...i,n],warnings:t};s.forEach((o,r)=>q(o,`$.pages.${r}`,i,t)),s.length>2e3&&t.push({path:"$.pages",message:`页数异常大(${s.length} 页),渲染与打印耗时可能显著增加`});const a=s.reduce((o,r)=>o+(g(r)&&Array.isArray(r.components)?r.components.length:0),0);a>5e4&&t.push({path:"$.pages",message:`组件总数异常大(${a} 个),可能触发浏览器性能限制`})}return{ok:i.length===0,errors:i,warnings:t}}function pe(e){const i=z(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 L(e){return e.kind==="list"?e.id:e.nid}function ye(e){return e.kind==="list"?!1:e.pageAnchor!==void 0||e.kind==="text"&&typeof e.text=="string"&&/\{(?:page|totalPages)\}/.test(e.text)}function le(e,i){const t=e.filter(n=>i.componentIds.includes(L(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 $e(e,i){if(!i)return e.map(s=>({components:[s]}));const t=new Map(e.map(s=>[L(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 X(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(ye(n))continue;const a=L(n);if(!a||t.has(a))throw new Error("流式排版组件应具有唯一标识");t.add(a)}if(be(e,i,t,s),s.size!==t.size)throw new Error("流式排版必须显式包含每个非锚点组件")}function be(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)}le(e,a),n=a.topMm+a.heightMm}}const Ae=new Set(["__proto__","prototype","constructor"]);function l(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function k(e){return typeof e=="string"&&!!e.trim()&&!Ae.has(e)}function T(e,i,t,s){for(const n of Object.keys(e))i.includes(n)||s.push({path:`${t}.${n}`,message:"存在未知配置字段"})}function we(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}T(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 Me(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:"绑定仅支持独立文本、图片、条码与二维码组件"}),T(s,["field","format","prefix","suffix","emptyText"],n,t),k(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:"应为字符串"});we(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 Ee(e,i){if(!l(e)){i.push({path:"$.repeat",message:"逐记录配置应为对象"});return}T(e,["dataset","rowKey","copies"],"$.repeat",i),k(e.dataset)||i.push({path:"$.repeat.dataset",message:"数据集应为安全的非空名称"}),e.rowKey!==void 0&&!k(e.rowKey)&&i.push({path:"$.repeat.rowKey",message:"业务主键应为安全的非空字段名"});const t=e.copies;t!==void 0&&(l(t)?(T(t,["field"],"$.repeat.copies",i),k(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 Y(e,i,t,s){if(!l(e))return;Me(e,i,s),e.binding!==void 0&&!t&&s.push({path:`${i}.binding`,message:"字段绑定需要模板 repeat 数据集;普通报表请使用列表字段"}),t&&e.kind==="list"&&s.push({path:i,message:"逐记录标签使用固定组件;动态列表请使用普通报表模板"}),e.chartBinding!==void 0&&(t||i.includes(".children."))&&s.push({path:`${i}.chartBinding`,message:"数据图表应放在普通报表的页面或流式分区,不放在逐记录标签或嵌套单元格内"});const n=e.grid;l(n)&&Array.isArray(n.cells)&&n.cells.forEach((a,o)=>{Array.isArray(a)&&a.forEach((r,f)=>{l(r)&&Array.isArray(r.children)&&r.children.forEach((d,u)=>Y(d,`${i}.grid.cells.${o}.${f}.children.${u}`,t,s))})})}function Q(e,i){const t=e.repeat!==void 0;t&&Ee(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,r)=>{const f=`${a}.components.${r}`;if(Y(o,f,t,i),!t||!l(o))return;const{leftMm:d,topMm:u,widthMm:p,heightMm:y}=o;[d,u,p,y,s.widthMm,s.heightMm].every(A=>typeof A=="number"&&Number.isFinite(A))&&(Number(d)<0||Number(u)<0||Number(d)+Number(p)>Number(s.widthMm)+.001||Number(u)+Number(y)>Number(s.heightMm)+.001)&&i.push({path:f,message:"标签组件超出纸张边界,请调整位置或尺寸"})})})}function ve(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function F(e,i,t){if(e!==void 0)try{I.compileReportPredicate(e)}catch(s){t.push({path:i,message:s instanceof Error?s.message:String(s)})}}function Z(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(!ve(n)){t.push({path:o,message:"聚合应为对象"});return}const r=n.field;typeof r!="string"||!r.trim()||s.has(r)?t.push({path:`${o}.field`,message:"聚合输出字段应非空且唯一"}):s.add(r),n.numeric!==void 0&&n.numeric!=="number"&&n.numeric!=="decimal"&&t.push({path:`${o}.numeric`,message:"数值模式应为 number 或 decimal"}),n.digits!==void 0&&(!Number.isInteger(n.digits)||Number(n.digits)<0||Number(n.digits)>100)&&t.push({path:`${o}.digits`,message:"小数位应为 0–100 的整数"});try{I.createAggregateAccumulator({...n,field:n.valueField??r})}catch(f){t.push({path:o,message:f instanceof Error?f.message:String(f)})}})}function ke(e,i,t){if(e===void 0)return;const s=I.validateComputedFields(e);for(const n of s.errors)t.push({path:i,message:n})}function Ne(e,i,t){if(e!==void 0)try{K.validateMatrixOptions(e)}catch(s){t.push({path:i,message:s instanceof Error?s.message:String(s)})}}function Se(e,i,t){if(e.tree===void 0)return;const s=`${i}.tree`;try{M.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)&&M.validateTreeComputed(n,e.computed)}catch(n){t.push({path:s,message:n instanceof Error?n.message:String(n)})}}const D="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 Re=new Set(["__proto__","prototype","constructor"]),Te=new Set(["schemaVersion","id","name","revision","description","template"]),xe=new Set(["left","center","right","justify"]),N=2e5,Pe=64;function h(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Oe(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 Fe(e,i,t,s){return Re.has(e)?(s.push({path:t,message:"模板不能包含可能污染原型的键"}),!1):i.get||i.set||!i.enumerable?(s.push({path:t,message:"模板不能包含访问器或不可枚举字段"}),!1):!0}function Ie(e){return e===null||typeof e=="boolean"||typeof e=="number"&&Number.isFinite(e)}function V(e,i){const t=new Set;let s=0,n=0,a=!1;const o=(r,f,d)=>{if(!a){if(++s>N){s===N+1&&i.push({path:f,message:"模板超过 JSON 节点安全上限"});return}if(d>Pe){i.push({path:f,message:"模板嵌套层级过深"});return}if(typeof r=="string"){n+=r.length,n>M.MAX_TEMPLATE_JSON_CHARACTERS&&(a=!0,i.push({path:f,message:"模板文本超过 1000 万字符的安全上限"}));return}if(!Ie(r)){if(!r||typeof r!="object"){i.push({path:f,message:"模板只允许 JSON 值,不允许函数、undefined 或非有限数字"});return}if(t.has(r)){i.push({path:f,message:"模板不能包含循环引用"});return}if(Oe(r,f,i)){t.add(r);for(const[u,p]of Object.entries(Object.getOwnPropertyDescriptors(r))){if(Array.isArray(r)&&u==="length")continue;const y=`${f}.${u}`;if(Fe(u,p,y,i)&&o(p.value,y,d+1),s>N||a)break}t.delete(r)}}}};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 E(e,i,t,s=!1){e!==void 0&&!xe.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}E(e.align,`${i}.align`,t),e.verticalAlign!==void 0&&!["top","middle","bottom"].includes(e.verticalAlign)&&t.push({path:`${i}.verticalAlign`,message:"未知垂直对齐方式"});for(const s of["fontSize","fontSizePx","lineWidthPt","lineHeight"])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 _e(e,i,t){if(e===void 0)return;if(!Array.isArray(e)){t.push({path:i,message:"参数定义应为数组"});return}const s=new Set,n=t.length;e.forEach((a,o)=>{const r=`${i}.${o}`;if(!h(a)){t.push({path:r,message:"参数定义应为对象"});return}m(a,"field",r,t,!0),typeof a.field=="string"&&(s.has(a.field)&&t.push({path:`${r}.field`,message:"参数名重复"}),s.add(a.field)),a.type!==void 0&&!["text","number","date","month","year","dateRange","select","multiSelect","cascader","numberRange"].includes(a.type)&&t.push({path:`${r}.type`,message:"未知参数类型"});for(const f of["label","defaultValue","placeholder"])m(a,f,r,t);b(a,"required",r,t);for(const f of["minLength","maxLength"]){const d=a[f];d!==void 0&&(typeof d!="number"||!Number.isSafeInteger(d)||d<0)&&t.push({path:`${r}.${f}`,message:"长度边界应为非负整数"})}Ce(a,r,t),a.options!==void 0&&(Array.isArray(a.options)?a.options.forEach((f,d)=>{const u=`${r}.options.${d}`;if(!h(f))t.push({path:u,message:"选项应为对象"});else for(const p of["label","value"])typeof f[p]!="string"&&t.push({path:`${u}.${p}`,message:"选项标签与值应为字符串(允许空白选项)"})}):t.push({path:`${r}.options`,message:"选项应为数组"}))}),t.length===n&&t.push(...H.validateReportParamDefinitions(e).map(a=>({path:a.path.replace("$.paramDefs",i),message:a.message})))}function Ce(e,i,t){for(const a of["min","max"]){const o=e[a];if(o===void 0)continue;H.isReportTemporalBound(e.type,o)||["number","numberRange"].includes(e.type)&&typeof o=="number"&&Number.isFinite(o)||t.push({path:`${i}.${a}`,message:"数字使用有限数字边界,日期/月/年使用对应规范字符串边界"})}const s=typeof e.min=="number"&&typeof e.max=="number"&&e.min>e.max,n=typeof e.min=="string"&&typeof e.max=="string"&&e.min>e.max;(s||n)&&t.push({path:i,message:"最小边界不能大于最大边界"}),typeof e.minLength=="number"&&typeof e.maxLength=="number"&&e.minLength>e.maxLength&&t.push({path:i,message:"最小长度不能大于最大长度"})}function ee(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(J(s,a,t),s.visual!==void 0&&!M.validColumnVisual(s.visual)&&t.push({path:`${a}.visual`,message:"列可视化配置无效,请检查类型、数值范围和颜色"}),b(s,"hidden",a,t),F(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),E(s.align,`${a}.align`,t,!0),E(s.headerAlign,`${a}.headerAlign`,t),s.semanticRole!==void 0&&!["identifier","dimension","measure","date","text"].includes(s.semanticRole)&&t.push({path:`${a}.semanticRole`,message:"未知列语义"}),s.format!==void 0)if(!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,r)=>{const f=`${a}.rules.${r}`;if(!h(o)||!h(o.when)){t.push({path:f,message:"条件格式缺少 when 对象"});return}F(o.when,`${f}.when`,t),$(o.style,`${f}.style`,t)}):t.push({path:`${a}.rules`,message:"条件格式应为数组"}))})}function te(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),Z(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 Le(e,i,t){if(!(e===void 0||typeof e=="boolean")){if(!h(e)){t.push({path:i,message:"合计应为布尔值或对象"});return}m(e,"label",i,t),Z(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 De(e,i,t,s){const n={kind:"rect",leftMm:0,topMm:0,widthMm:1,heightMm:1,grid:e};if(_(n,t,s,[]),B(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>N){s.push({path:t,message:"表头逻辑网格超过 20 万格安全上限"});return}e.cells.length||s.push({path:`${t}.cells`,message:"表头至少需要一行"}),Array.isArray(e.colWidthsMm)&&e.colWidthsMm.length!==o&&s.push({path:`${t}.colWidthsMm`,message:"表头列宽数量应与列表列数一致"}),Array.isArray(e.rowHeightsMm)&&e.rowHeightsMm.length!==e.cells.length&&s.push({path:`${t}.rowHeightsMm`,message:"表头行高数量应与行数一致"}),Ve(a,o,t,s)}function Ve(e,i,t,s){const n=new Set;e.forEach((a,o)=>{if(!Array.isArray(a))return;let r=0;a.forEach((f,d)=>{for(;n.has(`${o}:${r}`);)r++;const u=h(f)&&typeof f.colSpan=="number"?f.colSpan:1,p=h(f)&&typeof f.rowSpan=="number"?f.rowSpan:1;(r+u>i||o+p>e.length)&&s.push({path:`${t}.cells.${o}.${d}`,message:"表头合并区域超出表头边界"});for(let y=o;y<Math.min(e.length,o+p);y++)for(let A=r;A<Math.min(i,r+u);A++)n.has(`${y}:${A}`)&&s.push({path:`${t}.cells.${o}.${d}`,message:"表头合并区域重叠"}),n.add(`${y}:${A}`);r+=u})})}function Be(e,i,t){if(Se(e,i,t),ke(e.computed,`${i}.computed`,t),Ne(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 汇总,不能同时配置普通分组、总计或主从明细"}),F(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)=>te(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),ee(s.columns,`${n}.columns`,t),s.unmatched!==void 0&&s.unmatched!=="error"&&s.unmatched!=="ignore"&&t.push({path:`${n}.unmatched`,message:"未关联明细策略应为 error 或 ignore"})}function je(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&&De(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"}),ee(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),E(e.align,`${i}.align`,t,!0),E(e.headerAlign,`${i}.headerAlign`,t),$(e.headerStyle,`${i}.headerStyle`,t),Be(e,i,t),te(e.groupBy,`${i}.groupBy`,t),Le(e.grandTotal,`${i}.grandTotal`,t)}function j(e,i,t){Array.isArray(e.richParagraphs)&&e.richParagraphs.forEach((s,n)=>{if(!h(s))return;const a=`${i}.richParagraphs.${n}`;E(s.align,`${a}.align`,t);for(const o of["lineHeight","spaceBeforeMm","spaceAfterMm","indentMm"])c(s,o,a,t);Array.isArray(s.segments)&&s.segments.forEach((o,r)=>{const f=`${a}.segments.${r}`;if(!h(o)){t.push({path:f,message:"富文本片段应为对象"});return}o.kind!==void 0&&o.kind!=="text"&&o.kind!=="field"&&t.push({path:`${f}.kind`,message:"未知富文本片段类型"});for(const d of["text","field"])m(o,d,f,t);$(o.style,`${f}.style`,t)})})}function B(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:"文本行应为字符串数组"}),j(e,i,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,r)=>{const f=`${i}.grid.cells.${a}.${r}`;if(o!==null){if(!h(o)){t.push({path:f,message:"网格单元格应为对象或 null"});return}for(const d of["text","rawText","numberFormat"])m(o,d,f,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:`${f}.${d}`,message:"跨度应为正整数"})}o.value!==void 0&&o.value!==null&&!["string","number","boolean"].includes(typeof o.value)&&t.push({path:`${f}.value`,message:"Excel 原始值应为字符串、数字、布尔值或 null"}),$(o.style,`${f}.style`,t),j(o,f,t),o.children!==void 0&&(Array.isArray(o.children)?o.children.forEach((d,u)=>{h(d)&&B(d,`${f}.children.${u}`,t)}):t.push({path:`${f}.children`,message:"嵌套组件应为数组"}))}})})}function Ke(e,i,t){if(!(e.flow===void 0||!Array.isArray(e.components)))try{X(e.components,e.flow)}catch(s){t.push({path:`${i}.flow`,message:s instanceof Error?s.message:String(s)})}}function ie(e){const i=[],t=[];return V(e,i),i.length?{ok:!1,errors:i,warnings:t}:(h(e)?(e.schemaVersion!==void 0&&e.schemaVersion!==v.RENDER_PLAN_SCHEMA_VERSION&&i.push({path:"$.schemaVersion",message:"不支持的模板 schemaVersion"}),_e(e.params,"$.params",i),Q(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,r)=>{const f=`${a}.components.${r}`;h(o)&&o.kind==="list"?je(o,f,i):(_(o,f,i,t),h(o)&&B(o,f,i))}):i.push({path:`${a}.components`,message:"组件应为数组"}),Ke(s,a,i)})):i.push({path:"$",message:"模板应为对象"}),{ok:i.length===0,errors:i,warnings:t})}function se(e){const i=[],t=[];if(V(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))Te.has(n)||i.push({path:`$.${n}`,message:"模板文档存在未知字段;只保存模板与描述,不保存取数或业务数据"});e.schemaVersion!==D&&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=ie(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 P(e){const i=se(e);if(!i.ok)throw new w(i.errors)}function He(e){const i=[];if(V(e,i),i.length)throw new w(i);const t={...e,schemaVersion:e.schemaVersion??D};return P(t),x(t)}function Je(e){let i=e;if(typeof e=="string"){if(e.length>M.MAX_TEMPLATE_JSON_CHARACTERS)throw new w([{path:"$",message:"模板 JSON 超过 1000 万字符的导出/导入上限"}]);try{i=JSON.parse(e)}catch{throw new w([{path:"$",message:"模板 JSON 语法无效"}])}}return P(i),x(i)}function We(e){P(e);try{return M.stringifyValidatedTemplate(e)}catch(i){throw i instanceof RangeError?new w([{path:"$",message:i.message}]):i}}function x(e){return JSON.parse(JSON.stringify(e))}function Ge(e=[]){const i=new Map,t={get:s=>{const n=i.get(s);return n?x(n):void 0},list:()=>Array.from(i.values(),({template:s,...n})=>({...n})),register:(s,n={})=>{if(P(s),i.has(s.id)&&!n.replace)throw new w([{path:"$.id",message:`模板 ID ${s.id} 已注册;更新需显式 replace:true`}]);i.set(s.id,x(s))},remove:s=>i.delete(s)};for(const s of e)t.register(s);return t}exports.REPORT_TEMPLATE_DOCUMENT_VERSION=D;exports.ReportTemplateError=w;exports.assertRenderPlan=pe;exports.createTemplateRegistry=Ge;exports.defineReportTemplate=He;exports.parseReportTemplate=Je;exports.reportFlowGroups=$e;exports.serializeReportTemplate=We;exports.validateComponent=_;exports.validatePage=q;exports.validateRenderPlan=z;exports.validateReportPageFlow=X;exports.validateReportTemplate=ie;exports.validateReportTemplateDocument=se;exports.validateTemplateRepeat=Q;
@@ -1,5 +1,5 @@
1
- import { e as $, c as v } from "./computed-C8NRZQss.js";
2
- class T extends Error {
1
+ import { e as x, c as v } from "./computed-C8NRZQss.js";
2
+ class V extends Error {
3
3
  constructor(e) {
4
4
  super(`树节点超出行数预算 ${e}`), this.limit = e, this.code = "tree-row-limit", this.name = "TreeRowLimitError";
5
5
  }
@@ -9,7 +9,7 @@ function p(r, e, n, i) {
9
9
  if (!Number.isInteger(t) || t < 1 || t > n) throw new Error(`${i}应为 1–${n} 的整数`);
10
10
  return t;
11
11
  }
12
- function E(r) {
12
+ function y(r) {
13
13
  return { rows: p(r.maxRows, 1e5, 1e6, "树行数预算"), depth: p(r.maxDepth, 64, 256, "树深度预算"), visits: p(r.maxAggregationVisits, 1e6, 1e7, "树聚合访问预算") };
14
14
  }
15
15
  function A(r) {
@@ -18,18 +18,18 @@ function A(r) {
18
18
  function h(r) {
19
19
  return A(r) && !["__proto__", "prototype", "constructor"].includes(r);
20
20
  }
21
- function k(r) {
21
+ function M(r) {
22
22
  if (A(r) || typeof r == "number" && Number.isFinite(r)) return r;
23
23
  throw new Error("树节点业务键应为非空字符串或有限数字");
24
24
  }
25
- function M(r) {
25
+ function N(r) {
26
26
  return JSON.stringify([typeof r, r]);
27
27
  }
28
- function N(r) {
28
+ function k(r) {
29
29
  return [r.idField, ...r.input === "flat" ? [r.parentField ?? ""] : [r.childrenField ?? "children"]];
30
30
  }
31
- function S(r, e) {
32
- const n = N(r);
31
+ function O(r, e) {
32
+ const n = k(r);
33
33
  if (e?.some((i) => i.scope && i.scope !== "row" || n.includes(i.field))) throw new Error("树形布局仅支持不覆盖结构键的当前行计算");
34
34
  }
35
35
  function w(r) {
@@ -37,7 +37,7 @@ function w(r) {
37
37
  const e = new Error("树报表处理已取消");
38
38
  throw e.name = "AbortError", e;
39
39
  }
40
- function I(r) {
40
+ function $(r) {
41
41
  const e = r.aggregates ?? [];
42
42
  if (!Array.isArray(e) || e.length > 32) throw new Error("树聚合最多 32 项");
43
43
  if (r.parentValues !== "leaf-aggregate" && e.length) throw new Error("树聚合需显式选择 leaf-aggregate 父级取值策略");
@@ -46,32 +46,32 @@ function I(r) {
46
46
  for (const i of e) {
47
47
  if (!i || !h(i.field) || n.has(i.field)) throw new Error("树聚合输出字段应安全、非空且唯一");
48
48
  for (const t of [i.valueField, i.weightField]) if (t !== void 0 && !h(t)) throw new Error("树聚合来源字段应安全且非空");
49
- if ([...N(r), r.labelField].includes(i.field)) throw new Error("树聚合不能覆盖结构键或标签字段");
49
+ if ([...k(r), r.labelField].includes(i.field)) throw new Error("树聚合不能覆盖结构键或标签字段");
50
50
  n.add(i.field), v({ ...i, field: i.valueField ?? i.field });
51
51
  }
52
52
  }
53
- function O(r) {
53
+ function R(r) {
54
54
  if (!h(r.idField) || !h(r.labelField)) throw new Error("树需要安全的业务键和标签字段");
55
55
  if (r.input === "flat" && (!h(r.parentField) || r.parentField === r.idField)) throw new Error("扁平树需要独立的父键字段");
56
56
  if (r.childrenField !== void 0 && !h(r.childrenField)) throw new Error("子节点字段应安全且非空");
57
57
  if (r.input === "nested" && [r.idField, r.labelField].includes(r.childrenField ?? "children")) throw new Error("子节点字段不能覆盖业务键或标签字段");
58
58
  }
59
- function R(r) {
59
+ function I(r) {
60
60
  if (!r || typeof r != "object" || !["flat", "nested"].includes(r.input)) throw new Error("树输入应为 flat 或 nested");
61
- if (O(r), r.orphan !== void 0 && !["error", "root"].includes(r.orphan)) throw new Error("树孤儿策略应为 error 或 root");
61
+ if (R(r), r.orphan !== void 0 && !["error", "root"].includes(r.orphan)) throw new Error("树孤儿策略应为 error 或 root");
62
62
  if (r.parentValues !== void 0 && !["source", "leaf-aggregate"].includes(r.parentValues)) throw new Error("未知树父级取值策略");
63
63
  if (r.indentMm !== void 0 && (!Number.isFinite(r.indentMm) || r.indentMm < 0 || r.indentMm > 20)) throw new Error("树每级缩进应为 0–20 mm");
64
- E(r), I(r);
64
+ y(r), $(r);
65
65
  }
66
66
  function C(r, e, n, i) {
67
67
  if (!r || typeof r != "object" || Array.isArray(r)) throw new Error("树节点应为对象");
68
- if (n.size >= i.rows) throw new T(i.rows);
69
- const t = k(r[e.idField]), f = M(t);
68
+ if (n.size >= i.rows) throw new V(i.rows);
69
+ const t = M(r[e.idField]), f = N(t);
70
70
  if (n.has(f)) throw new Error(`树节点业务键重复:${String(t)}`);
71
71
  const o = { original: r, row: r, key: t, depth: 0, children: [] };
72
72
  return n.set(f, o), o;
73
73
  }
74
- function j(r, e, n, i, t) {
74
+ function _(r, e, n, i, t) {
75
75
  for (const o of r)
76
76
  w(t), C(o, e, n, i);
77
77
  const f = [];
@@ -82,7 +82,7 @@ function j(r, e, n, i, t) {
82
82
  f.push(o);
83
83
  continue;
84
84
  }
85
- const l = n.get(M(k(a)));
85
+ const l = n.get(N(M(a)));
86
86
  if (!l) {
87
87
  if (e.orphan !== "root") throw new Error(`树节点 ${String(o.key)} 的父节点不存在`);
88
88
  f.push(o);
@@ -93,7 +93,7 @@ function j(r, e, n, i, t) {
93
93
  }
94
94
  return f;
95
95
  }
96
- function _(r, e, n, i, t) {
96
+ function j(r, e, n, i, t) {
97
97
  const f = [], o = [{ rows: r, next: 0 }];
98
98
  for (; o.length; ) {
99
99
  w(t);
@@ -105,15 +105,15 @@ function _(r, e, n, i, t) {
105
105
  const l = C(a.rows[a.next++], e, n, i);
106
106
  if (l.parent = a.parent, l.depth = o.length - 1, o.length > i.depth) throw new Error(`树节点超出深度预算 ${i.depth}`);
107
107
  (a.parent?.children ?? f).push(l);
108
- const d = l.row[e.childrenField ?? "children"];
109
- if (d != null) {
110
- if (!Array.isArray(d)) throw new Error("嵌套树 children 字段应为数组");
111
- d.length && o.push({ rows: d, next: 0, parent: l });
108
+ const s = l.row[e.childrenField ?? "children"];
109
+ if (s != null) {
110
+ if (!Array.isArray(s)) throw new Error("嵌套树 children 字段应为数组");
111
+ s.length && o.push({ rows: s, next: 0, parent: l });
112
112
  }
113
113
  }
114
114
  return f;
115
115
  }
116
- function B(r, e, n, i) {
116
+ function J(r, e, n, i) {
117
117
  const t = [], f = [{ nodes: r, next: 0 }];
118
118
  for (; f.length; ) {
119
119
  w(i);
@@ -129,7 +129,7 @@ function B(r, e, n, i) {
129
129
  if (t.length !== e) throw new Error("树父子关系存在循环");
130
130
  return t;
131
131
  }
132
- function D(r, e, n, i) {
132
+ function L(r, e, n, i) {
133
133
  if (e.parentValues !== "leaf-aggregate") return;
134
134
  const t = e.aggregates, f = /* @__PURE__ */ new Map();
135
135
  for (const a of r) a.children.length && f.set(a, t.map((l) => v({ ...l, field: l.valueField ?? l.field })));
@@ -138,44 +138,44 @@ function D(r, e, n, i) {
138
138
  if (!a.children.length)
139
139
  for (let l = a.parent; l; l = l.parent) {
140
140
  if (w(i), o += t.length, o > n.visits) throw new Error(`树聚合超出访问预算 ${n.visits}`);
141
- for (const d of f.get(l)) d.add(a.row);
141
+ for (const s of f.get(l)) s.add(a.row);
142
142
  }
143
143
  for (const [a, l] of f)
144
- a.row = { ...a.row }, t.forEach((d, c) => {
145
- a.row[d.field] = l[c].value();
144
+ a.row = { ...a.row }, t.forEach((s, c) => {
145
+ a.row[s.field] = l[c].value();
146
146
  });
147
147
  }
148
- function x(r, e, n) {
149
- if (R(e), w(n), !Array.isArray(r)) throw new Error("树数据应为节点数组");
150
- const i = E(e), t = /* @__PURE__ */ new Map(), f = e.input === "flat" ? j(r, e, t, i, n) : _(r, e, t, i, n);
151
- return B(f, t.size, i, n);
148
+ function T(r, e, n) {
149
+ if (I(e), w(n), !Array.isArray(r)) throw new Error("树数据应为节点数组");
150
+ const i = y(e), t = /* @__PURE__ */ new Map(), f = e.input === "flat" ? _(r, e, t, i, n) : j(r, e, t, i, n);
151
+ return J(f, t.size, i, n);
152
152
  }
153
- function G(r, e, n) {
154
- return x(r, e, n).map((i) => i.original);
153
+ function X(r, e, n) {
154
+ return T(r, e, n).map((i) => i.original);
155
155
  }
156
- function H(r, e, n = {}) {
157
- const i = x(r, e, n.signal);
158
- if (S(e, n.computed?.fields), n.computed?.fields.length) {
159
- const t = $(i.map((f) => f.row), { ...n.computed, signal: n.signal }).rows;
156
+ function q(r, e, n = {}) {
157
+ const i = T(r, e, n.signal);
158
+ if (O(e, n.computed?.fields), n.computed?.fields.length) {
159
+ const t = x(i.map((f) => f.row), { ...n.computed, signal: n.signal }).rows;
160
160
  i.forEach((f, o) => {
161
161
  f.row = t[o];
162
162
  });
163
163
  }
164
- return D(i, e, E(e), n.signal), { rows: i.map((t) => t.row), entries: i.map((t) => ({ row: t.row, original: t.original, key: t.key, depth: t.depth, hasChildren: !!t.children.length })), leaves: i.filter((t) => !t.children.length).map((t) => t.row) };
164
+ return L(i, e, y(e), n.signal), { rows: i.map((t) => t.row), entries: i.map((t) => ({ row: t.row, original: t.original, key: t.key, depth: t.depth, hasChildren: !!t.children.length })), leaves: i.filter((t) => !t.children.length).map((t) => t.row) };
165
165
  }
166
- const L = /^#[0-9a-f]{6}$/i;
167
- function z(r) {
166
+ const B = /^#[0-9a-f]{6}$/i;
167
+ function D(r) {
168
168
  if (!r || typeof r != "object" || Array.isArray(r)) return !1;
169
169
  const e = r;
170
- return e.kind !== "colorScale" && e.kind !== "dataBar" || e.field !== void 0 && (typeof e.field != "string" || !e.field.trim()) || e.numeric !== void 0 && !["number", "decimal"].includes(e.numeric) || [e.min, e.max].some((n) => n !== void 0 && (typeof n != "number" || !Number.isFinite(n))) || e.min !== void 0 && e.max !== void 0 && e.min > e.max ? !1 : Object.entries(e).every(([n, i]) => !["color", "negativeColor", "lowColor", "highColor"].includes(n) || typeof i == "string" && L.test(i));
170
+ return e.kind !== "colorScale" && e.kind !== "dataBar" || e.field !== void 0 && (typeof e.field != "string" || !e.field.trim()) || e.numeric !== void 0 && !["number", "decimal"].includes(e.numeric) || [e.min, e.max].some((n) => n !== void 0 && (typeof n != "number" || !Number.isFinite(n))) || e.min !== void 0 && e.max !== void 0 && e.min > e.max ? !1 : Object.entries(e).every(([n, i]) => !["color", "negativeColor", "lowColor", "highColor"].includes(n) || typeof i == "string" && B.test(i));
171
171
  }
172
- function V(r, e) {
172
+ function S(r, e) {
173
173
  if (typeof r == "number") return Number.isFinite(r) ? r : void 0;
174
174
  if (e !== "decimal" || typeof r != "string" || r.length > 1024 || !/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/.test(r)) return;
175
175
  const n = Number(r);
176
176
  return Number.isFinite(n) ? n : void 0;
177
177
  }
178
- function J(r, e, n) {
178
+ function z(r, e, n) {
179
179
  let i = "#";
180
180
  for (const t of [1, 3, 5]) {
181
181
  const f = parseInt(r.slice(t, t + 2), 16), o = parseInt(e.slice(t, t + 2), 16);
@@ -183,56 +183,65 @@ function J(r, e, n) {
183
183
  }
184
184
  return i;
185
185
  }
186
- function y(r, e, n) {
186
+ function E(r, e, n) {
187
187
  if (e === n) return r < e ? 0 : r > n ? 1 : 0.5;
188
188
  if (r <= e) return 0;
189
189
  if (r >= n) return 1;
190
190
  const i = n - e;
191
191
  return Number.isFinite(i) ? (r - e) / i : (r / 2 - e / 2) / (n / 2 - e / 2);
192
192
  }
193
- function W(r, e, n, i) {
193
+ function H(r, e, n, i) {
194
194
  const t = /* @__PURE__ */ new WeakMap();
195
195
  return { apply(f, o) {
196
- const a = V(o[e], r.numeric);
196
+ const a = S(o[e], r.numeric);
197
197
  if (a === void 0) return;
198
198
  if (r.kind === "dataBar") {
199
- const s = Math.min(n, 0), g = Math.max(i, 0), m = y(0, s, g), b = s === g ? m : y(a, s, g);
199
+ const d = Math.min(n, 0), g = Math.max(i, 0), m = E(0, d, g), b = d === g ? m : E(a, d, g);
200
200
  f.dataBar = { start: Math.min(m, b), end: Math.max(m, b), color: a < 0 ? r.negativeColor ?? "#f3bcc3" : r.color ?? "#bad8fa" };
201
201
  return;
202
202
  }
203
- const l = J(r.lowColor ?? "#f0f7ff", r.highColor ?? "#8bbcf1", y(a, n, i)), d = f.style ?? {}, c = t.get(d) ?? /* @__PURE__ */ new Map();
204
- t.set(d, c);
203
+ const l = z(r.lowColor ?? "#f0f7ff", r.highColor ?? "#8bbcf1", E(a, n, i)), s = f.style ?? {}, c = t.get(s) ?? /* @__PURE__ */ new Map();
204
+ t.set(s, c);
205
205
  let u = c.get(l);
206
- u || (u = { ...d, backgroundColor: l }, c.set(l, u)), f.style = u;
206
+ u || (u = { ...s, backgroundColor: l }, c.set(l, u)), f.style = u;
207
207
  } };
208
208
  }
209
- function K(r, e, n) {
209
+ function G(r, e, n) {
210
210
  return r.map((i) => {
211
211
  F(n);
212
212
  const t = i.visual;
213
213
  if (!t) return;
214
- if (!z(t)) throw new TypeError("Invalid column visual rule");
214
+ if (!D(t)) throw new TypeError("Invalid column visual rule");
215
215
  const f = t.field ?? i.field;
216
216
  let o = 1 / 0, a = -1 / 0, l = 0;
217
217
  if (t.min === void 0 || t.max === void 0) for (const u of e) {
218
218
  (l++ & 1023) === 0 && F(n);
219
- const s = V(u[f], t.numeric);
220
- s !== void 0 && (o = Math.min(o, s), a = Math.max(a, s));
219
+ const d = S(u[f], t.numeric);
220
+ d !== void 0 && (o = Math.min(o, d), a = Math.max(a, d));
221
221
  }
222
- let d = t.min ?? o, c = t.max ?? a;
223
- if (!(!Number.isFinite(d) || !Number.isFinite(c)))
224
- return d > c && (t.min !== void 0 ? c = d : d = c), W(t, f, d, c);
222
+ let s = t.min ?? o, c = t.max ?? a;
223
+ if (!(!Number.isFinite(s) || !Number.isFinite(c)))
224
+ return s > c && (t.min !== void 0 ? c = s : s = c), H(t, f, s, c);
225
225
  });
226
226
  }
227
227
  function F(r) {
228
228
  if (r?.aborted) throw r.reason ?? new DOMException("Aborted", "AbortError");
229
229
  }
230
+ const P = 1e7;
231
+ function K(r) {
232
+ const e = JSON.stringify(r, null, 2);
233
+ if (e.length > P)
234
+ throw new RangeError("模板 JSON 超过 1000 万字符的导出/导入上限");
235
+ return e;
236
+ }
230
237
  export {
231
- T,
232
- R as a,
233
- S as b,
234
- H as c,
235
- K as d,
236
- G as f,
237
- z as v
238
+ P as M,
239
+ V as T,
240
+ I as a,
241
+ O as b,
242
+ q as c,
243
+ G as d,
244
+ X as f,
245
+ K as s,
246
+ D as v
238
247
  };
@@ -1 +1 @@
1
- "use strict";const y=require("./computed-4TnxzgIh.cjs");class A extends Error{constructor(r){super(`树节点超出行数预算 ${r}`),this.limit=r,this.code="tree-row-limit",this.name="TreeRowLimitError"}}function p(e,r,n,i){const t=e??r;if(!Number.isInteger(t)||t<1||t>n)throw new Error(`${i}应为 1–${n} 的整数`);return t}function b(e){return{rows:p(e.maxRows,1e5,1e6,"树行数预算"),depth:p(e.maxDepth,64,256,"树深度预算"),visits:p(e.maxAggregationVisits,1e6,1e7,"树聚合访问预算")}}function k(e){return typeof e=="string"&&!!e.trim()}function h(e){return k(e)&&!["__proto__","prototype","constructor"].includes(e)}function M(e){if(k(e)||typeof e=="number"&&Number.isFinite(e))return e;throw new Error("树节点业务键应为非空字符串或有限数字")}function C(e){return JSON.stringify([typeof e,e])}function N(e){return[e.idField,...e.input==="flat"?[e.parentField??""]:[e.childrenField??"children"]]}function T(e,r){const n=N(e);if(r?.some(i=>i.scope&&i.scope!=="row"||n.includes(i.field)))throw new Error("树形布局仅支持不覆盖结构键的当前行计算")}function w(e){if(!e?.aborted)return;const r=new Error("树报表处理已取消");throw r.name="AbortError",r}function S(e){const r=e.aggregates??[];if(!Array.isArray(r)||r.length>32)throw new Error("树聚合最多 32 项");if(e.parentValues!=="leaf-aggregate"&&r.length)throw new Error("树聚合需显式选择 leaf-aggregate 父级取值策略");if(e.parentValues==="leaf-aggregate"&&!r.length)throw new Error("叶子聚合策略至少需要一个聚合字段");const n=new Set;for(const i of r){if(!i||!h(i.field)||n.has(i.field))throw new Error("树聚合输出字段应安全、非空且唯一");for(const t of[i.valueField,i.weightField])if(t!==void 0&&!h(t))throw new Error("树聚合来源字段应安全且非空");if([...N(e),e.labelField].includes(i.field))throw new Error("树聚合不能覆盖结构键或标签字段");n.add(i.field),y.createAggregateAccumulator({...i,field:i.valueField??i.field})}}function R(e){if(!h(e.idField)||!h(e.labelField))throw new Error("树需要安全的业务键和标签字段");if(e.input==="flat"&&(!h(e.parentField)||e.parentField===e.idField))throw new Error("扁平树需要独立的父键字段");if(e.childrenField!==void 0&&!h(e.childrenField))throw new Error("子节点字段应安全且非空");if(e.input==="nested"&&[e.idField,e.labelField].includes(e.childrenField??"children"))throw new Error("子节点字段不能覆盖业务键或标签字段")}function V(e){if(!e||typeof e!="object"||!["flat","nested"].includes(e.input))throw new Error("树输入应为 flat 或 nested");if(R(e),e.orphan!==void 0&&!["error","root"].includes(e.orphan))throw new Error("树孤儿策略应为 error 或 root");if(e.parentValues!==void 0&&!["source","leaf-aggregate"].includes(e.parentValues))throw new Error("未知树父级取值策略");if(e.indentMm!==void 0&&(!Number.isFinite(e.indentMm)||e.indentMm<0||e.indentMm>20))throw new Error("树每级缩进应为 0–20 mm");b(e),S(e)}function x(e,r,n,i){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("树节点应为对象");if(n.size>=i.rows)throw new A(i.rows);const t=M(e[r.idField]),l=C(t);if(n.has(l))throw new Error(`树节点业务键重复:${String(t)}`);const o={original:e,row:e,key:t,depth:0,children:[]};return n.set(l,o),o}function j(e,r,n,i,t){for(const o of e)w(t),x(o,r,n,i);const l=[];for(const o of n.values()){w(t);const a=o.row[r.parentField];if(a==null){l.push(o);continue}const f=n.get(C(M(a)));if(!f){if(r.orphan!=="root")throw new Error(`树节点 ${String(o.key)} 的父节点不存在`);l.push(o);continue}if(f===o)throw new Error("树节点不能以自身为父节点");o.parent=f,f.children.push(o)}return l}function L(e,r,n,i,t){const l=[],o=[{rows:e,next:0}];for(;o.length;){w(t);const a=o[o.length-1];if(a.next>=a.rows.length){o.pop();continue}const f=x(a.rows[a.next++],r,n,i);if(f.parent=a.parent,f.depth=o.length-1,o.length>i.depth)throw new Error(`树节点超出深度预算 ${i.depth}`);(a.parent?.children??l).push(f);const c=f.row[r.childrenField??"children"];if(c!=null){if(!Array.isArray(c))throw new Error("嵌套树 children 字段应为数组");c.length&&o.push({rows:c,next:0,parent:f})}}return l}function _(e,r,n,i){const t=[],l=[{nodes:e,next:0}];for(;l.length;){w(i);const o=l[l.length-1];if(o.next>=o.nodes.length){l.pop();continue}if(l.length>n.depth)throw new Error(`树节点超出深度预算 ${n.depth}`);const a=o.nodes[o.next++];a.depth=l.length-1,t.push(a),a.children.length&&l.push({nodes:a.children,next:0})}if(t.length!==r)throw new Error("树父子关系存在循环");return t}function B(e,r,n,i){if(r.parentValues!=="leaf-aggregate")return;const t=r.aggregates,l=new Map;for(const a of e)a.children.length&&l.set(a,t.map(f=>y.createAggregateAccumulator({...f,field:f.valueField??f.field})));let o=0;for(const a of e)if(!a.children.length)for(let f=a.parent;f;f=f.parent){if(w(i),o+=t.length,o>n.visits)throw new Error(`树聚合超出访问预算 ${n.visits}`);for(const c of l.get(f))c.add(a.row)}for(const[a,f]of l)a.row={...a.row},t.forEach((c,d)=>{a.row[c.field]=f[d].value()})}function $(e,r,n){if(V(r),w(n),!Array.isArray(e))throw new Error("树数据应为节点数组");const i=b(r),t=new Map,l=r.input==="flat"?j(e,r,t,i,n):L(e,r,t,i,n);return _(l,t.size,i,n)}function D(e,r,n){return $(e,r,n).map(i=>i.original)}function z(e,r,n={}){const i=$(e,r,n.signal);if(T(r,n.computed?.fields),n.computed?.fields.length){const t=y.computeDataset(i.map(l=>l.row),{...n.computed,signal:n.signal}).rows;i.forEach((l,o)=>{l.row=t[o]})}return B(i,r,b(r),n.signal),{rows:i.map(t=>t.row),entries:i.map(t=>({row:t.row,original:t.original,key:t.key,depth:t.depth,hasChildren:!!t.children.length})),leaves:i.filter(t=>!t.children.length).map(t=>t.row)}}const q=/^#[0-9a-f]{6}$/i;function I(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;const r=e;return r.kind!=="colorScale"&&r.kind!=="dataBar"||r.field!==void 0&&(typeof r.field!="string"||!r.field.trim())||r.numeric!==void 0&&!["number","decimal"].includes(r.numeric)||[r.min,r.max].some(n=>n!==void 0&&(typeof n!="number"||!Number.isFinite(n)))||r.min!==void 0&&r.max!==void 0&&r.min>r.max?!1:Object.entries(r).every(([n,i])=>!["color","negativeColor","lowColor","highColor"].includes(n)||typeof i=="string"&&q.test(i))}function O(e,r){if(typeof e=="number")return Number.isFinite(e)?e:void 0;if(r!=="decimal"||typeof e!="string"||e.length>1024||!/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/.test(e))return;const n=Number(e);return Number.isFinite(n)?n:void 0}function J(e,r,n){let i="#";for(const t of[1,3,5]){const l=parseInt(e.slice(t,t+2),16),o=parseInt(r.slice(t,t+2),16);i+=Math.round(l+(o-l)*n).toString(16).padStart(2,"0")}return i}function E(e,r,n){if(r===n)return e<r?0:e>n?1:.5;if(e<=r)return 0;if(e>=n)return 1;const i=n-r;return Number.isFinite(i)?(e-r)/i:(e/2-r/2)/(n/2-r/2)}function W(e,r,n,i){const t=new WeakMap;return{apply(l,o){const a=O(o[r],e.numeric);if(a===void 0)return;if(e.kind==="dataBar"){const s=Math.min(n,0),g=Math.max(i,0),m=E(0,s,g),F=s===g?m:E(a,s,g);l.dataBar={start:Math.min(m,F),end:Math.max(m,F),color:a<0?e.negativeColor??"#f3bcc3":e.color??"#bad8fa"};return}const f=J(e.lowColor??"#f0f7ff",e.highColor??"#8bbcf1",E(a,n,i)),c=l.style??{},d=t.get(c)??new Map;t.set(c,d);let u=d.get(f);u||(u={...c,backgroundColor:f},d.set(f,u)),l.style=u}}}function G(e,r,n){return e.map(i=>{v(n);const t=i.visual;if(!t)return;if(!I(t))throw new TypeError("Invalid column visual rule");const l=t.field??i.field;let o=1/0,a=-1/0,f=0;if(t.min===void 0||t.max===void 0)for(const u of r){(f++&1023)===0&&v(n);const s=O(u[l],t.numeric);s!==void 0&&(o=Math.min(o,s),a=Math.max(a,s))}let c=t.min??o,d=t.max??a;if(!(!Number.isFinite(c)||!Number.isFinite(d)))return c>d&&(t.min!==void 0?d=c:c=d),W(t,l,c,d)})}function v(e){if(e?.aborted)throw e.reason??new DOMException("Aborted","AbortError")}exports.TreeRowLimitError=A;exports.createColumnVisualResolvers=G;exports.createTreeTable=z;exports.flattenTreeInput=D;exports.validColumnVisual=I;exports.validateTreeComputed=T;exports.validateTreeOptions=V;
1
+ "use strict";const y=require("./computed-4TnxzgIh.cjs");class A extends Error{constructor(r){super(`树节点超出行数预算 ${r}`),this.limit=r,this.code="tree-row-limit",this.name="TreeRowLimitError"}}function p(e,r,n,i){const t=e??r;if(!Number.isInteger(t)||t<1||t>n)throw new Error(`${i}应为 1–${n} 的整数`);return t}function b(e){return{rows:p(e.maxRows,1e5,1e6,"树行数预算"),depth:p(e.maxDepth,64,256,"树深度预算"),visits:p(e.maxAggregationVisits,1e6,1e7,"树聚合访问预算")}}function T(e){return typeof e=="string"&&!!e.trim()}function h(e){return T(e)&&!["__proto__","prototype","constructor"].includes(e)}function M(e){if(T(e)||typeof e=="number"&&Number.isFinite(e))return e;throw new Error("树节点业务键应为非空字符串或有限数字")}function C(e){return JSON.stringify([typeof e,e])}function N(e){return[e.idField,...e.input==="flat"?[e.parentField??""]:[e.childrenField??"children"]]}function k(e,r){const n=N(e);if(r?.some(i=>i.scope&&i.scope!=="row"||n.includes(i.field)))throw new Error("树形布局仅支持不覆盖结构键的当前行计算")}function w(e){if(!e?.aborted)return;const r=new Error("树报表处理已取消");throw r.name="AbortError",r}function $(e){const r=e.aggregates??[];if(!Array.isArray(r)||r.length>32)throw new Error("树聚合最多 32 项");if(e.parentValues!=="leaf-aggregate"&&r.length)throw new Error("树聚合需显式选择 leaf-aggregate 父级取值策略");if(e.parentValues==="leaf-aggregate"&&!r.length)throw new Error("叶子聚合策略至少需要一个聚合字段");const n=new Set;for(const i of r){if(!i||!h(i.field)||n.has(i.field))throw new Error("树聚合输出字段应安全、非空且唯一");for(const t of[i.valueField,i.weightField])if(t!==void 0&&!h(t))throw new Error("树聚合来源字段应安全且非空");if([...N(e),e.labelField].includes(i.field))throw new Error("树聚合不能覆盖结构键或标签字段");n.add(i.field),y.createAggregateAccumulator({...i,field:i.valueField??i.field})}}function I(e){if(!h(e.idField)||!h(e.labelField))throw new Error("树需要安全的业务键和标签字段");if(e.input==="flat"&&(!h(e.parentField)||e.parentField===e.idField))throw new Error("扁平树需要独立的父键字段");if(e.childrenField!==void 0&&!h(e.childrenField))throw new Error("子节点字段应安全且非空");if(e.input==="nested"&&[e.idField,e.labelField].includes(e.childrenField??"children"))throw new Error("子节点字段不能覆盖业务键或标签字段")}function S(e){if(!e||typeof e!="object"||!["flat","nested"].includes(e.input))throw new Error("树输入应为 flat 或 nested");if(I(e),e.orphan!==void 0&&!["error","root"].includes(e.orphan))throw new Error("树孤儿策略应为 error 或 root");if(e.parentValues!==void 0&&!["source","leaf-aggregate"].includes(e.parentValues))throw new Error("未知树父级取值策略");if(e.indentMm!==void 0&&(!Number.isFinite(e.indentMm)||e.indentMm<0||e.indentMm>20))throw new Error("树每级缩进应为 0–20 mm");b(e),$(e)}function V(e,r,n,i){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("树节点应为对象");if(n.size>=i.rows)throw new A(i.rows);const t=M(e[r.idField]),l=C(t);if(n.has(l))throw new Error(`树节点业务键重复:${String(t)}`);const o={original:e,row:e,key:t,depth:0,children:[]};return n.set(l,o),o}function L(e,r,n,i,t){for(const o of e)w(t),V(o,r,n,i);const l=[];for(const o of n.values()){w(t);const a=o.row[r.parentField];if(a==null){l.push(o);continue}const f=n.get(C(M(a)));if(!f){if(r.orphan!=="root")throw new Error(`树节点 ${String(o.key)} 的父节点不存在`);l.push(o);continue}if(f===o)throw new Error("树节点不能以自身为父节点");o.parent=f,f.children.push(o)}return l}function j(e,r,n,i,t){const l=[],o=[{rows:e,next:0}];for(;o.length;){w(t);const a=o[o.length-1];if(a.next>=a.rows.length){o.pop();continue}const f=V(a.rows[a.next++],r,n,i);if(f.parent=a.parent,f.depth=o.length-1,o.length>i.depth)throw new Error(`树节点超出深度预算 ${i.depth}`);(a.parent?.children??l).push(f);const c=f.row[r.childrenField??"children"];if(c!=null){if(!Array.isArray(c))throw new Error("嵌套树 children 字段应为数组");c.length&&o.push({rows:c,next:0,parent:f})}}return l}function J(e,r,n,i){const t=[],l=[{nodes:e,next:0}];for(;l.length;){w(i);const o=l[l.length-1];if(o.next>=o.nodes.length){l.pop();continue}if(l.length>n.depth)throw new Error(`树节点超出深度预算 ${n.depth}`);const a=o.nodes[o.next++];a.depth=l.length-1,t.push(a),a.children.length&&l.push({nodes:a.children,next:0})}if(t.length!==r)throw new Error("树父子关系存在循环");return t}function B(e,r,n,i){if(r.parentValues!=="leaf-aggregate")return;const t=r.aggregates,l=new Map;for(const a of e)a.children.length&&l.set(a,t.map(f=>y.createAggregateAccumulator({...f,field:f.valueField??f.field})));let o=0;for(const a of e)if(!a.children.length)for(let f=a.parent;f;f=f.parent){if(w(i),o+=t.length,o>n.visits)throw new Error(`树聚合超出访问预算 ${n.visits}`);for(const c of l.get(f))c.add(a.row)}for(const[a,f]of l)a.row={...a.row},t.forEach((c,d)=>{a.row[c.field]=f[d].value()})}function O(e,r,n){if(S(r),w(n),!Array.isArray(e))throw new Error("树数据应为节点数组");const i=b(r),t=new Map,l=r.input==="flat"?L(e,r,t,i,n):j(e,r,t,i,n);return J(l,t.size,i,n)}function D(e,r,n){return O(e,r,n).map(i=>i.original)}function z(e,r,n={}){const i=O(e,r,n.signal);if(k(r,n.computed?.fields),n.computed?.fields.length){const t=y.computeDataset(i.map(l=>l.row),{...n.computed,signal:n.signal}).rows;i.forEach((l,o)=>{l.row=t[o]})}return B(i,r,b(r),n.signal),{rows:i.map(t=>t.row),entries:i.map(t=>({row:t.row,original:t.original,key:t.key,depth:t.depth,hasChildren:!!t.children.length})),leaves:i.filter(t=>!t.children.length).map(t=>t.row)}}const H=/^#[0-9a-f]{6}$/i;function R(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;const r=e;return r.kind!=="colorScale"&&r.kind!=="dataBar"||r.field!==void 0&&(typeof r.field!="string"||!r.field.trim())||r.numeric!==void 0&&!["number","decimal"].includes(r.numeric)||[r.min,r.max].some(n=>n!==void 0&&(typeof n!="number"||!Number.isFinite(n)))||r.min!==void 0&&r.max!==void 0&&r.min>r.max?!1:Object.entries(r).every(([n,i])=>!["color","negativeColor","lowColor","highColor"].includes(n)||typeof i=="string"&&H.test(i))}function x(e,r){if(typeof e=="number")return Number.isFinite(e)?e:void 0;if(r!=="decimal"||typeof e!="string"||e.length>1024||!/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/.test(e))return;const n=Number(e);return Number.isFinite(n)?n:void 0}function P(e,r,n){let i="#";for(const t of[1,3,5]){const l=parseInt(e.slice(t,t+2),16),o=parseInt(r.slice(t,t+2),16);i+=Math.round(l+(o-l)*n).toString(16).padStart(2,"0")}return i}function E(e,r,n){if(r===n)return e<r?0:e>n?1:.5;if(e<=r)return 0;if(e>=n)return 1;const i=n-r;return Number.isFinite(i)?(e-r)/i:(e/2-r/2)/(n/2-r/2)}function X(e,r,n,i){const t=new WeakMap;return{apply(l,o){const a=x(o[r],e.numeric);if(a===void 0)return;if(e.kind==="dataBar"){const s=Math.min(n,0),g=Math.max(i,0),m=E(0,s,g),F=s===g?m:E(a,s,g);l.dataBar={start:Math.min(m,F),end:Math.max(m,F),color:a<0?e.negativeColor??"#f3bcc3":e.color??"#bad8fa"};return}const f=P(e.lowColor??"#f0f7ff",e.highColor??"#8bbcf1",E(a,n,i)),c=l.style??{},d=t.get(c)??new Map;t.set(c,d);let u=d.get(f);u||(u={...c,backgroundColor:f},d.set(f,u)),l.style=u}}}function q(e,r,n){return e.map(i=>{v(n);const t=i.visual;if(!t)return;if(!R(t))throw new TypeError("Invalid column visual rule");const l=t.field??i.field;let o=1/0,a=-1/0,f=0;if(t.min===void 0||t.max===void 0)for(const u of r){(f++&1023)===0&&v(n);const s=x(u[l],t.numeric);s!==void 0&&(o=Math.min(o,s),a=Math.max(a,s))}let c=t.min??o,d=t.max??a;if(!(!Number.isFinite(c)||!Number.isFinite(d)))return c>d&&(t.min!==void 0?d=c:c=d),X(t,l,c,d)})}function v(e){if(e?.aborted)throw e.reason??new DOMException("Aborted","AbortError")}const _=1e7;function W(e){const r=JSON.stringify(e,null,2);if(r.length>_)throw new RangeError("模板 JSON 超过 1000 万字符的导出/导入上限");return r}exports.MAX_TEMPLATE_JSON_CHARACTERS=_;exports.TreeRowLimitError=A;exports.createColumnVisualResolvers=q;exports.createTreeTable=z;exports.flattenTreeInput=D;exports.stringifyValidatedTemplate=W;exports.validColumnVisual=R;exports.validateTreeComputed=k;exports.validateTreeOptions=S;
@@ -1,4 +1,4 @@
1
- import { D as M } from "./style-67OqfNed.js";
1
+ import { D as M } from "./grid-geometry-D3SJgWFv.js";
2
2
  const d = /[\u3000-\u9fff\uff00-\uffef]/, s = new Uint8Array(128);
3
3
  {
4
4
  for (const t of "iljtf.,:;'`|!()[]") s[t.charCodeAt(0)] = 1;
@@ -0,0 +1,4 @@
1
+ "use strict";const g=require("./grid-geometry-D8ReblRV.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 w=[.54,.26,.95,.59,.67,.3];function d(t){const e=t.charCodeAt(0);return e<128?w[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??g.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;
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("./plugin-BMsIIJDh.cjs");function i(){return Promise.resolve().then(()=>require("./ReportPreview-hlwvZ1wf.cjs")).then(e=>e.ReportPreview$1)}const t={install(e,o={}){r.machReportPlugin.install(e,o)}};exports.MachReportPreview=r.MachReportPreview;exports.default=t;exports.machReportAsyncPlugin=t;exports.preloadMachReport=i;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("./plugin-BaRUGORD.cjs");function i(){return Promise.resolve().then(()=>require("./ReportPreview-nf4Dk1Jc.cjs")).then(e=>e.ReportPreview$1)}const t={install(e,o={}){r.machReportPlugin.install(e,o)}};exports.MachReportPreview=r.MachReportPreview;exports.default=t;exports.machReportAsyncPlugin=t;exports.preloadMachReport=i;
package/dist/vue-async.js CHANGED
@@ -1,7 +1,7 @@
1
- import { m as o } from "./plugin-Co1oKD7T.js";
2
- import { M as l } from "./plugin-Co1oKD7T.js";
1
+ import { m as o } from "./plugin-D4kAxfLG.js";
2
+ import { M as l } from "./plugin-D4kAxfLG.js";
3
3
  function a() {
4
- return import("./ReportPreview-CGcxwkAn.js").then((t) => t.v);
4
+ return import("./ReportPreview-BBJNlu2U.js").then((t) => t.v);
5
5
  }
6
6
  const n = {
7
7
  install(t, r = {}) {
package/dist/vue.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("@agile-team/mach-report"),i=require("./ReportPreview-hlwvZ1wf.cjs"),a=require("./ReportParamPanel-CVpK8mFc.cjs"),f=require("./injection-keys-Db_DyLkm.cjs"),O=require("./plugin-BMsIIJDh.cjs"),T=require("vue"),C=require("./json-snapshot-jiXff4lc.cjs"),y=require("./progress-B0ctFpKf.cjs");function v(r){const e=E.createReportSource(r),n=async t=>{if(t.reportIds.length===0)throw new i.PlanLoadError("缺少报表 ID");for(const o of t.reportIds)if(!Object.prototype.hasOwnProperty.call(r,o)||!r[o])throw new i.PlanLoadError(`本地模板 ${o} 不存在`);return e(t)};return n.getParamDefs=e.getParamDefs,n}const I=Object.freeze({loading:!1,hasPlan:!1,pageCount:0,currentPage:1,exporting:null,printing:!1,canExport:!1,canPrint:!1,error:null,pdfFont:Object.freeze({status:"unchecked",fontUrl:""})});function D(){const r=T.shallowRef(null),e=()=>r.value?.state??I,n=Object.freeze({get loading(){return e().loading},get hasPlan(){return e().hasPlan},get pageCount(){return e().pageCount},get currentPage(){return e().currentPage},get exporting(){return e().exporting},get printing(){return e().printing},get canExport(){return e().canExport},get canPrint(){return e().canPrint},get error(){return e().error},get pdfFont(){return e().pdfFont},get editing(){return e().editing??!1},get saving(){return e().saving??!1},get importing(){return e().importing??!1},get dirty(){return e().dirty??!1},get pendingLocalChanges(){return e().pendingLocalChanges??!1},get task(){return e().task??null},get diagnostics(){return e().diagnostics??[]},get reportIds(){return e().reportIds??[]},get params(){return e().params??{}},get canUndo(){return e().canUndo??!1},get canRedo(){return e().canRedo??!1},get changeCount(){return e().changeCount??0},get selection(){return e().selection??null}});function t(){if(!r.value)throw new a.MachReportError("config","报表预览尚未挂载,请在 ready 后调用控制器");return r.value}return{ref(o){const s=o;r.value=s&&typeof s.reload=="function"&&typeof s.print=="function"&&typeof s.exportAs=="function"&&typeof s.openPdfWindow=="function"&&typeof s.gotoPage=="function"&&typeof s.setParams=="function"?s:null},ready:T.computed(()=>r.value!==null),state:n,async checkPdfFont(){const o=t();return o.checkPdfFont?o.checkPdfFont():{status:"unverified",fontUrl:"",message:"旧自定义控制器未提供字体检查,请由宿主确认字体配置"}},cancelTask(){t().cancelTask?.()},async confirmDiscard(o){return await t().confirmDiscard?.(o)??!0},getOutputDiagnostics(o){return t().getOutputDiagnostics?.(o)??[]},async reload(){await t().reload()},async print(){await t().print()},async exportAs(o){await t().exportAs(o)},openPdfWindow(){t().openPdfWindow()},gotoPage(o){t().gotoPage(o)},async setParams(o,s){await t().setParams(o,s)},async importExcel(o,s){const g=t();if(!g.importExcel)throw new a.MachReportError("config","旧自定义控制器未提供 Excel 导入");return g.importExcel(o,s)},getPlan(){return t().getPlan?.()??null},getChanges(){return t().getChanges?.()??[]},getDifferences:()=>t().getDifferences?.()??[],undo:async()=>await t().undo?.()??!1,redo:async()=>await t().redo?.()??!1,restoreChanges:async()=>await t().restoreChanges?.()??!1,getSelection:()=>t().getSelection?.()??null,focusCell:async(o,s)=>await t().focusCell?.(o,s)??!1,focusField:async o=>await t().focusField?.(o)??!1,copySelection:()=>t().copySelection?.()??"",pasteSelection:async o=>await t().pasteSelection?.(o)??!1}}function L(){return T.inject(f.MACH_REPORT_CONTROLLER_KEY,null)}function h(r){return!!r&&typeof r=="object"&&!Array.isArray(r)}function F(r){return Array.isArray(r)&&r.every(e=>h(e)&&typeof e.code=="string"&&typeof e.message=="string"&&["info","warning","error"].includes(e.severity)&&(e.path===void 0||typeof e.path=="string")&&C.hasValidDataExplanation(e))}function x(r,e){return Array.isArray(r)&&r.every(n=>h(n)&&Number.isSafeInteger(n.editIndex)&&n.editIndex>=0&&n.editIndex<e&&typeof n.code=="string"&&typeof n.message=="string")}function b(r,e){let n;if(!h(r)||typeof r.revision!="string"||!r.revision.trim()?n="非空 revision(请先在适配器解包业务响应)":r.sourceToken!==void 0&&typeof r.sourceToken!="string"?n="字符串 sourceToken":r.diagnostics!==void 0&&!F(r.diagnostics)?n="结构化 diagnostics":r.conflicts!==void 0&&!x(r.conflicts,e)&&(n="有效 editIndex/code/message conflicts"),n)throw new a.MachReportError("edit",`ReportProvider.save 必须返回${n};服务器可能已提交,请重新查询确认后再编辑`)}function m(r){return typeof r=="function"?r():r}function q(r,e){const n=new Set(r.flatMap(t=>t.source?.[e]===void 0?[]:[String(t.source[e])]));return n.size===1?[...n][0]:void 0}function A(r,e,n,t){return typeof r=="function"?r():q(e,n)??t??r}function U(r){return r.requestId??globalThis.crypto?.randomUUID?.()??`mr-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}function G(r,e){if(!r.save)throw new a.MachReportError("config","ReportProvider.save 未配置,无法启用业务保存");let n="",t,o,s=0;function g(c,u,p){c.conflicts?.length||u!==n||p!==s||(t=c.revision,o=c.sourceToken)}async function _(c,u){if(u.signal.aborted)throw u.signal.reason??new DOMException("Aborted","AbortError");const p=m(e.reportId),S={...m(e.params??{})},R=JSON.stringify([p,S]),M=++s;if(R!==n&&(n=R,t=void 0,o=void 0),e.requireSource!==!1&&c.edits.some(l=>!l.source))throw new E.ReportCellEditError("missing");const d=await r.save({reportId:p,params:S,signal:u.signal,requestId:c.requestId,action:u.action,edits:i.cloneReportSnapshot(c.edits),expectedRevision:A(e.expectedRevision,c.edits,"revision",t),sourceToken:A(e.sourceToken,c.edits,"sourceToken",o)});if(u.signal.aborted)throw u.signal.reason??new DOMException("Aborted","AbortError");b(d,c.edits.length),d.diagnostics?.forEach(l=>y.observeOutput(()=>e.onDiagnostic?.(l)));const P=d.diagnostics?.filter(l=>l.severity==="error");if(P?.length)throw new a.MachReportError("edit",P.map(l=>l.message).join(";"),{diagnostics:P});const w=d.conflicts?.map(l=>({source:c.edits[l.editIndex]?.source,address:c.edits[l.editIndex]?.address,message:l.message}));return g(d,R,M),{revision:d.revision,sourceToken:d.sourceToken,conflicts:w}}return{requireSource:e.requireSource??!0,canEdit:e.canEdit,validate:e.validate,saveBatch:_,save:(c,u)=>_({requestId:U(u),edits:[i.cloneReportSnapshot(c)]},u)}}exports.PlanLoadError=i.PlanLoadError;exports.REPORT_EXPORT_FORMATS=i.REPORT_EXPORT_FORMATS;exports.REPORT_PREVIEW_TOOLS=i.REPORT_PREVIEW_TOOLS;exports.ReportDataComparisonPanel=i._sfc_main;exports.ReportPagination=i.ReportPagination;exports.ReportPrefillPanel=i._sfc_main$1;exports.ReportPreview=i.ReportPreview;exports.ReportPrintResourceError=i.ReportPrintResourceError;exports.ReportToolbar=i.ReportToolbar;exports.ReportValidationPanel=i.ReportValidationPanel;exports.buildPrintDocument=i.buildPrintDocument;exports.buildWordHtml=i.buildWordHtml;exports.createDefaultPdfExporter=i.createDefaultPdfExporter;exports.createFetchRequest=i.createFetchRequest;exports.createPrintCalibrationPlan=i.createPrintCalibrationPlan;exports.createReportStoragePreferences=i.createReportStoragePreferences;exports.joinReportIds=i.joinReportIds;exports.normalizeReportIds=i.normalizeReportIds;exports.preparePrintResources=i.preparePrintResources;exports.printPlans=i.printPlans;exports.usePageWindow=i.usePageWindow;exports.usePrintExport=i.usePrintExport;exports.useZoom=i.useZoom;exports.DEFAULT_CALCULATION_MESSAGES=a.DEFAULT_CALCULATION_MESSAGES;exports.DEFAULT_DATA_REVIEW_MESSAGES=a.DEFAULT_DATA_REVIEW_MESSAGES;exports.DEFAULT_MESSAGES=a.DEFAULT_MESSAGES;exports.DEFAULT_PRINT_MESSAGES=a.DEFAULT_PRINT_MESSAGES;exports.DEFAULT_THEME=a.DEFAULT_THEME;exports.MachReportError=a.MachReportError;exports.PARAM_OPTIONS_MESSAGES=a.PARAM_OPTIONS_MESSAGES;exports.ReportParamPanel=a.ReportParamPanel;exports.SILENT_LOGGER=a.SILENT_LOGGER;exports.defineMachReportConfig=a.defineMachReportConfig;exports.defineMachReportPreset=a.defineMachReportPreset;exports.normalizeReportLoadError=a.normalizeReportLoadError;exports.printCalibration=a.printCalibration;exports.provideMachReportConfig=a.provideMachReportConfig;exports.resolveCalculationMessages=a.resolveCalculationMessages;exports.resolveConfig=a.resolveConfig;exports.resolveDataReviewMessages=a.resolveDataReviewMessages;exports.snapshotPrintOptions=a.snapshotPrintOptions;exports.themeToCssVars=a.themeToCssVars;exports.toErrorDetail=a.toErrorDetail;exports.useMachReportConfig=a.useMachReportConfig;exports.MACH_REPORT_CONFIG_KEY=f.MACH_REPORT_CONFIG_KEY;exports.MACH_REPORT_CONTROLLER_KEY=f.MACH_REPORT_CONTROLLER_KEY;exports.MACH_REPORT_FETCHER_KEY=f.MACH_REPORT_FETCHER_KEY;exports.MACH_REPORT_PDF_EXPORTER_KEY=f.MACH_REPORT_PDF_EXPORTER_KEY;exports.MachReportPreview=O.MachReportPreview;exports.machReportPlugin=O.machReportPlugin;exports.createLocalFetcher=v;exports.createProviderEditing=G;exports.useMachReport=D;exports.useReportPreview=L;Object.keys(E).forEach(r=>{r!=="default"&&!Object.prototype.hasOwnProperty.call(exports,r)&&Object.defineProperty(exports,r,{enumerable:!0,get:()=>E[r]})});
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("@agile-team/mach-report"),i=require("./ReportPreview-nf4Dk1Jc.cjs"),a=require("./ReportParamPanel-CVpK8mFc.cjs"),f=require("./injection-keys-Db_DyLkm.cjs"),O=require("./plugin-BaRUGORD.cjs"),T=require("vue"),C=require("./json-snapshot-I5VI84Vp.cjs"),y=require("./progress-B0ctFpKf.cjs");function v(r){const e=E.createReportSource(r),n=async t=>{if(t.reportIds.length===0)throw new i.PlanLoadError("缺少报表 ID");for(const o of t.reportIds)if(!Object.prototype.hasOwnProperty.call(r,o)||!r[o])throw new i.PlanLoadError(`本地模板 ${o} 不存在`);return e(t)};return n.getParamDefs=e.getParamDefs,n}const I=Object.freeze({loading:!1,hasPlan:!1,pageCount:0,currentPage:1,exporting:null,printing:!1,canExport:!1,canPrint:!1,error:null,pdfFont:Object.freeze({status:"unchecked",fontUrl:""})});function D(){const r=T.shallowRef(null),e=()=>r.value?.state??I,n=Object.freeze({get loading(){return e().loading},get hasPlan(){return e().hasPlan},get pageCount(){return e().pageCount},get currentPage(){return e().currentPage},get exporting(){return e().exporting},get printing(){return e().printing},get canExport(){return e().canExport},get canPrint(){return e().canPrint},get error(){return e().error},get pdfFont(){return e().pdfFont},get editing(){return e().editing??!1},get saving(){return e().saving??!1},get importing(){return e().importing??!1},get dirty(){return e().dirty??!1},get pendingLocalChanges(){return e().pendingLocalChanges??!1},get task(){return e().task??null},get diagnostics(){return e().diagnostics??[]},get reportIds(){return e().reportIds??[]},get params(){return e().params??{}},get canUndo(){return e().canUndo??!1},get canRedo(){return e().canRedo??!1},get changeCount(){return e().changeCount??0},get selection(){return e().selection??null}});function t(){if(!r.value)throw new a.MachReportError("config","报表预览尚未挂载,请在 ready 后调用控制器");return r.value}return{ref(o){const s=o;r.value=s&&typeof s.reload=="function"&&typeof s.print=="function"&&typeof s.exportAs=="function"&&typeof s.openPdfWindow=="function"&&typeof s.gotoPage=="function"&&typeof s.setParams=="function"?s:null},ready:T.computed(()=>r.value!==null),state:n,async checkPdfFont(){const o=t();return o.checkPdfFont?o.checkPdfFont():{status:"unverified",fontUrl:"",message:"旧自定义控制器未提供字体检查,请由宿主确认字体配置"}},cancelTask(){t().cancelTask?.()},async confirmDiscard(o){return await t().confirmDiscard?.(o)??!0},getOutputDiagnostics(o){return t().getOutputDiagnostics?.(o)??[]},async reload(){await t().reload()},async print(){await t().print()},async exportAs(o){await t().exportAs(o)},openPdfWindow(){t().openPdfWindow()},gotoPage(o){t().gotoPage(o)},async setParams(o,s){await t().setParams(o,s)},async importExcel(o,s){const g=t();if(!g.importExcel)throw new a.MachReportError("config","旧自定义控制器未提供 Excel 导入");return g.importExcel(o,s)},getPlan(){return t().getPlan?.()??null},getChanges(){return t().getChanges?.()??[]},getDifferences:()=>t().getDifferences?.()??[],undo:async()=>await t().undo?.()??!1,redo:async()=>await t().redo?.()??!1,restoreChanges:async()=>await t().restoreChanges?.()??!1,getSelection:()=>t().getSelection?.()??null,focusCell:async(o,s)=>await t().focusCell?.(o,s)??!1,focusField:async o=>await t().focusField?.(o)??!1,copySelection:()=>t().copySelection?.()??"",pasteSelection:async o=>await t().pasteSelection?.(o)??!1}}function L(){return T.inject(f.MACH_REPORT_CONTROLLER_KEY,null)}function h(r){return!!r&&typeof r=="object"&&!Array.isArray(r)}function F(r){return Array.isArray(r)&&r.every(e=>h(e)&&typeof e.code=="string"&&typeof e.message=="string"&&["info","warning","error"].includes(e.severity)&&(e.path===void 0||typeof e.path=="string")&&C.hasValidDataExplanation(e))}function x(r,e){return Array.isArray(r)&&r.every(n=>h(n)&&Number.isSafeInteger(n.editIndex)&&n.editIndex>=0&&n.editIndex<e&&typeof n.code=="string"&&typeof n.message=="string")}function b(r,e){let n;if(!h(r)||typeof r.revision!="string"||!r.revision.trim()?n="非空 revision(请先在适配器解包业务响应)":r.sourceToken!==void 0&&typeof r.sourceToken!="string"?n="字符串 sourceToken":r.diagnostics!==void 0&&!F(r.diagnostics)?n="结构化 diagnostics":r.conflicts!==void 0&&!x(r.conflicts,e)&&(n="有效 editIndex/code/message conflicts"),n)throw new a.MachReportError("edit",`ReportProvider.save 必须返回${n};服务器可能已提交,请重新查询确认后再编辑`)}function m(r){return typeof r=="function"?r():r}function q(r,e){const n=new Set(r.flatMap(t=>t.source?.[e]===void 0?[]:[String(t.source[e])]));return n.size===1?[...n][0]:void 0}function A(r,e,n,t){return typeof r=="function"?r():q(e,n)??t??r}function U(r){return r.requestId??globalThis.crypto?.randomUUID?.()??`mr-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}function G(r,e){if(!r.save)throw new a.MachReportError("config","ReportProvider.save 未配置,无法启用业务保存");let n="",t,o,s=0;function g(c,u,p){c.conflicts?.length||u!==n||p!==s||(t=c.revision,o=c.sourceToken)}async function _(c,u){if(u.signal.aborted)throw u.signal.reason??new DOMException("Aborted","AbortError");const p=m(e.reportId),S={...m(e.params??{})},R=JSON.stringify([p,S]),M=++s;if(R!==n&&(n=R,t=void 0,o=void 0),e.requireSource!==!1&&c.edits.some(l=>!l.source))throw new E.ReportCellEditError("missing");const d=await r.save({reportId:p,params:S,signal:u.signal,requestId:c.requestId,action:u.action,edits:i.cloneReportSnapshot(c.edits),expectedRevision:A(e.expectedRevision,c.edits,"revision",t),sourceToken:A(e.sourceToken,c.edits,"sourceToken",o)});if(u.signal.aborted)throw u.signal.reason??new DOMException("Aborted","AbortError");b(d,c.edits.length),d.diagnostics?.forEach(l=>y.observeOutput(()=>e.onDiagnostic?.(l)));const P=d.diagnostics?.filter(l=>l.severity==="error");if(P?.length)throw new a.MachReportError("edit",P.map(l=>l.message).join(";"),{diagnostics:P});const w=d.conflicts?.map(l=>({source:c.edits[l.editIndex]?.source,address:c.edits[l.editIndex]?.address,message:l.message}));return g(d,R,M),{revision:d.revision,sourceToken:d.sourceToken,conflicts:w}}return{requireSource:e.requireSource??!0,canEdit:e.canEdit,validate:e.validate,saveBatch:_,save:(c,u)=>_({requestId:U(u),edits:[i.cloneReportSnapshot(c)]},u)}}exports.PlanLoadError=i.PlanLoadError;exports.REPORT_EXPORT_FORMATS=i.REPORT_EXPORT_FORMATS;exports.REPORT_PREVIEW_TOOLS=i.REPORT_PREVIEW_TOOLS;exports.ReportDataComparisonPanel=i._sfc_main;exports.ReportPagination=i.ReportPagination;exports.ReportPrefillPanel=i._sfc_main$1;exports.ReportPreview=i.ReportPreview;exports.ReportPrintResourceError=i.ReportPrintResourceError;exports.ReportToolbar=i.ReportToolbar;exports.ReportValidationPanel=i.ReportValidationPanel;exports.buildPrintDocument=i.buildPrintDocument;exports.buildWordHtml=i.buildWordHtml;exports.createDefaultPdfExporter=i.createDefaultPdfExporter;exports.createFetchRequest=i.createFetchRequest;exports.createPrintCalibrationPlan=i.createPrintCalibrationPlan;exports.createReportStoragePreferences=i.createReportStoragePreferences;exports.joinReportIds=i.joinReportIds;exports.normalizeReportIds=i.normalizeReportIds;exports.preparePrintResources=i.preparePrintResources;exports.printPlans=i.printPlans;exports.usePageWindow=i.usePageWindow;exports.usePrintExport=i.usePrintExport;exports.useZoom=i.useZoom;exports.DEFAULT_CALCULATION_MESSAGES=a.DEFAULT_CALCULATION_MESSAGES;exports.DEFAULT_DATA_REVIEW_MESSAGES=a.DEFAULT_DATA_REVIEW_MESSAGES;exports.DEFAULT_MESSAGES=a.DEFAULT_MESSAGES;exports.DEFAULT_PRINT_MESSAGES=a.DEFAULT_PRINT_MESSAGES;exports.DEFAULT_THEME=a.DEFAULT_THEME;exports.MachReportError=a.MachReportError;exports.PARAM_OPTIONS_MESSAGES=a.PARAM_OPTIONS_MESSAGES;exports.ReportParamPanel=a.ReportParamPanel;exports.SILENT_LOGGER=a.SILENT_LOGGER;exports.defineMachReportConfig=a.defineMachReportConfig;exports.defineMachReportPreset=a.defineMachReportPreset;exports.normalizeReportLoadError=a.normalizeReportLoadError;exports.printCalibration=a.printCalibration;exports.provideMachReportConfig=a.provideMachReportConfig;exports.resolveCalculationMessages=a.resolveCalculationMessages;exports.resolveConfig=a.resolveConfig;exports.resolveDataReviewMessages=a.resolveDataReviewMessages;exports.snapshotPrintOptions=a.snapshotPrintOptions;exports.themeToCssVars=a.themeToCssVars;exports.toErrorDetail=a.toErrorDetail;exports.useMachReportConfig=a.useMachReportConfig;exports.MACH_REPORT_CONFIG_KEY=f.MACH_REPORT_CONFIG_KEY;exports.MACH_REPORT_CONTROLLER_KEY=f.MACH_REPORT_CONTROLLER_KEY;exports.MACH_REPORT_FETCHER_KEY=f.MACH_REPORT_FETCHER_KEY;exports.MACH_REPORT_PDF_EXPORTER_KEY=f.MACH_REPORT_PDF_EXPORTER_KEY;exports.MachReportPreview=O.MachReportPreview;exports.machReportPlugin=O.machReportPlugin;exports.createLocalFetcher=v;exports.createProviderEditing=G;exports.useMachReport=D;exports.useReportPreview=L;Object.keys(E).forEach(r=>{r!=="default"&&!Object.prototype.hasOwnProperty.call(exports,r)&&Object.defineProperty(exports,r,{enumerable:!0,get:()=>E[r]})});
package/dist/vue.js CHANGED
@@ -1,14 +1,14 @@
1
1
  import { createReportSource as v, ReportCellEditError as A } from "@agile-team/mach-report";
2
2
  export * from "@agile-team/mach-report";
3
- import { P as R, c as h } from "./ReportPreview-CGcxwkAn.js";
4
- import { R as Z, a as Q, _ as ee, b as re, d as te, e as ne, f as oe, g as se, h as ae, i as ie, j as ce, k as fe, l as ue, m as de, n as le, o as ge, p as pe, q as Pe, r as me, u as Ee, s as Re, t as he } from "./ReportPreview-CGcxwkAn.js";
3
+ import { P as R, c as h } from "./ReportPreview-BBJNlu2U.js";
4
+ import { R as Z, a as Q, _ as ee, b as re, d as te, e as ne, f as oe, g as se, h as ae, i as ie, j as ce, k as fe, l as ue, m as de, n as le, o as ge, p as pe, q as Pe, r as me, u as Ee, s as Re, t as he } from "./ReportPreview-BBJNlu2U.js";
5
5
  import { M as u } from "./ReportParamPanel-peB-KEmm.js";
6
6
  import { D as ye, a as Se, b as Te, c as ve, d as Ae, P as xe, R as Ce, S as _e, e as Ie, f as Oe, n as Me, p as De, g as ke, r as Fe, h as Le, i as be, s as Ue, t as qe, j as je, u as Ge } from "./ReportParamPanel-peB-KEmm.js";
7
7
  import { M as x } from "./injection-keys-e85udZCp.js";
8
8
  import { a as He, b as We, c as ze } from "./injection-keys-e85udZCp.js";
9
- import { M as Ye, m as Ke } from "./plugin-Co1oKD7T.js";
9
+ import { M as Ye, m as Ke } from "./plugin-D4kAxfLG.js";
10
10
  import { shallowRef as C, computed as _, inject as I } from "vue";
11
- import { x as O } from "./json-snapshot-By4ZVVUt.js";
11
+ import { x as O } from "./json-snapshot-Kgn459Oj.js";
12
12
  import { a as M } from "./progress-Hc2vxoCs.js";
13
13
  function V(r) {
14
14
  const e = v(r), o = async (t) => {