@agile-team/mach-report 2.26.1 → 2.26.2
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 -5
- package/dist/ExcelBindingWizard-CnjjpYxD.cjs +1 -0
- package/dist/{ExcelBindingWizard-Bzndrp_z.js → ExcelBindingWizard-DAprCgn-.js} +4 -4
- package/dist/{ParamEditor-BrUrInJH.js → ParamEditor-CY9d8QZD.js} +3 -3
- package/dist/ParamEditor-CiVjpbc-.cjs +1 -0
- package/dist/ReportBatchPanel-0-Oymcdm.cjs +1 -0
- package/dist/{ReportBatchPanel-2mXS1uol.js → ReportBatchPanel-CDp7xRHp.js} +4 -4
- package/dist/ReportLabelStudio-CsyHqBco.cjs +1 -0
- package/dist/{ReportLabelStudio-BUKNmYUY.js → ReportLabelStudio-DtKxk9n0.js} +4 -4
- package/dist/ReportParamPanel-CoKcXzSy.cjs +1 -0
- package/dist/{ReportParamPanel-Czm3OPo_.js → ReportParamPanel-jKDJVar2.js} +2 -2
- package/dist/{ReportPreview-C9c0Rp7Y.js → ReportPreview-DJqt40zA.js} +2863 -2836
- package/dist/ReportPreview-s7c2nrfo.cjs +6 -0
- package/dist/ReportTemplateLibrary-CsUm6edm.cjs +1 -0
- package/dist/{ReportTemplateLibrary-ovj03u0F.js → ReportTemplateLibrary-qPQX0Dt_.js} +2 -2
- package/dist/RuleEditor-CJBibiLY.cjs +1 -0
- package/dist/{RuleEditor-4JTKq_N7.js → RuleEditor-Di-JZ2Lb.js} +6 -6
- package/dist/{TemplateOutlinePanel-DfFRc91I.js → TemplateOutlinePanel-D0mKfVWf.js} +3 -3
- package/dist/TemplateOutlinePanel-RiRgXnnH.cjs +1 -0
- package/dist/TemplateReusePanel-BdK91T7z.cjs +1 -0
- package/dist/{TemplateReusePanel-CmX1rq69.js → TemplateReusePanel-J6PvD2Sf.js} +3 -3
- package/dist/TemplateReviewPanel-B5yUgOgb.cjs +1 -0
- package/dist/{TemplateReviewPanel-BKMo7Qd7.js → TemplateReviewPanel-BlUbD2GY.js} +3 -3
- package/dist/analytics.cjs +1 -1
- package/dist/analytics.js +5 -5
- package/dist/artifact-integrity.json +112 -114
- package/dist/assets-CylgPA6P.cjs +1 -0
- package/dist/assets-Vt10jCtl.js +136 -0
- package/dist/auto-D3UNXBrM.cjs +1 -0
- package/dist/{auto-C7udkeAa.js → auto-Hq-xgrvS.js} +28 -25
- package/dist/{batch-DGCt44XM.js → batch-Be_NbW7U.js} +1 -1
- package/dist/{batch-DYcokH4v.cjs → batch-CI4ZpuoX.cjs} +1 -1
- package/dist/{charts-D-Vg-ak9.cjs → charts-Cy7muNWi.cjs} +1 -1
- package/dist/{charts-D48XCefN.js → charts-DLTz0OEG.js} +1 -1
- package/dist/{computed-BQgBrma-.cjs → computed-8nFyVnok.cjs} +1 -1
- package/dist/{computed-CH3NYPOW.js → computed-BR_O8uAv.js} +14 -20
- package/dist/{data-bar-DzceAVeR.cjs → data-bar--_aPWr-W.cjs} +1 -1
- package/dist/{data-bar-DjOgTLqu.js → data-bar-BVnzVbE9.js} +1 -1
- package/dist/designer-Bc5AXS38.cjs +2 -0
- package/dist/designer-CZqnLTyE.js +8350 -0
- package/dist/designer.cjs +1 -1
- package/dist/designer.d.cts +108 -1
- package/dist/designer.d.ts +108 -1
- package/dist/designer.js +1 -1
- package/dist/{diagnostic-collector-C-JBA016.js → diagnostic-collector-CZ8DV6wA.js} +208 -186
- package/dist/diagnostic-collector-DwMJWEHo.cjs +1 -0
- package/dist/{dom-DgWc-DY1.js → dom-CbOWY7KE.js} +5 -5
- package/dist/dom-VuLh_fhL.cjs +1 -0
- package/dist/{encoding-tWc2Wn89.cjs → encoding-D0ITsCCp.cjs} +1 -1
- package/dist/{encoding-D480EM2r.js → encoding-TbA3oQLr.js} +2 -2
- package/dist/{execution-result-Ba65gieT.js → execution-result-BUPPNlaS.js} +3 -3
- package/dist/{execution-result-7sG_mdcD.cjs → execution-result-BgZtqlOT.cjs} +1 -1
- package/dist/{font-loader-CHmEwkHl.js → font-loader-BSRR-a0C.js} +1 -1
- package/dist/{font-loader-BIxme_9g.cjs → font-loader-BZ4CRPys.cjs} +1 -1
- package/dist/{grid-strokes-DsoICRjZ.js → grid-strokes-CovSH3A2.js} +1 -1
- package/dist/{grid-strokes-RFMR91jn.cjs → grid-strokes-G5omPT3s.cjs} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +23 -23
- package/dist/{json-snapshot-BZ0CIQln.js → json-snapshot-DRQmh_k5.js} +718 -683
- package/dist/json-snapshot-HR8bez8j.cjs +2 -0
- package/dist/{matrix-CB9TqTEy.js → matrix-6wjFVN0Z.js} +149 -142
- package/dist/matrix-DeA6__cd.cjs +1 -0
- package/dist/media-IV_r4Sp7.cjs +1 -0
- package/dist/media-jiLdCn3i.js +208 -0
- package/dist/{pdf-DTR7fAIr.js → pdf-BqnoP1L_.js} +14 -15
- package/dist/{pdf-d9oJ6V0P.cjs → pdf-Ddm0HCuT.cjs} +48 -48
- package/dist/pdf.cjs +1 -1
- package/dist/pdf.js +2 -2
- package/dist/{plugin-B7Bi-1te.cjs → plugin-BFBLxfsq.cjs} +1 -1
- package/dist/{plugin-OKDFQFS4.js → plugin-BnRcXQzg.js} +1 -1
- package/dist/{prefill-C8fF91JB.js → prefill-BqbuktRt.js} +3 -3
- package/dist/{prefill-C_Bf_AMo.cjs → prefill-DPLV68I7.cjs} +1 -1
- package/dist/prepared-Cl7C69N7.cjs +1 -0
- package/dist/{prepared-DhgQ0d-h.js → prepared-V7tYf1qj.js} +68 -64
- package/dist/{protocol-CZ-BILne.cjs → protocol-BVhKnBmX.cjs} +1 -1
- package/dist/{protocol-DHO91-Jt.js → protocol-Bf33Gu9J.js} +3 -3
- package/dist/{record-bindings-KEs-DKCS.cjs → record-bindings-DVs_g_No.cjs} +1 -1
- package/dist/{record-bindings-DBrCu6zO.js → record-bindings-hxJqcLSK.js} +3 -3
- package/dist/{region-binding-workflow-ikpY1Kbw.cjs → region-binding-workflow-Bu31bqCr.cjs} +1 -1
- package/dist/{region-binding-workflow-FSyIZge8.js → region-binding-workflow-DRvX25XH.js} +2 -2
- package/dist/report-encoding-worker.cjs +1 -1
- package/dist/report-encoding-worker.js +1 -1
- package/dist/{rich-text-layout-BYbIc3eJ.cjs → rich-text-layout-6VphrIcj.cjs} +1 -1
- package/dist/{rich-text-layout-BtygMWZC.js → rich-text-layout-BCdxMT4m.js} +1 -1
- package/dist/{runtime-BsvAqz4a.js → runtime-ChdUbPvs.js} +9 -9
- package/dist/{runtime-B5HG8poy.cjs → runtime-D2noLfgC.cjs} +1 -1
- package/dist/sbom.cdx.json +1 -1
- package/dist/server-node.cjs +5 -5
- package/dist/server-node.js +2099 -1959
- package/dist/server.cjs +1 -1
- package/dist/server.js +17 -13
- package/dist/sha256-C26wdjDi.cjs +1 -0
- package/dist/sha256-D-msitGX.js +166 -0
- package/dist/style.css +1 -1
- package/dist/{template-catalog-BbrN9dgu.js → template-catalog-CZfnMXKc.js} +4 -4
- package/dist/template-catalog-Dv4sOYaB.cjs +1 -0
- package/dist/{template-fragments-CUTE8-_I.js → template-fragments-BO6i19kt.js} +3 -3
- package/dist/{template-fragments-cyAQu7aw.cjs → template-fragments-CTfJeHoM.cjs} +1 -1
- package/dist/{template-registry-PSuLsnyq.js → template-registry-CIaC6qBW.js} +168 -171
- package/dist/template-registry-CKo-bogM.cjs +1 -0
- package/dist/template-serialization-Cb1ospyK.js +367 -0
- package/dist/template-serialization-D4Fofl9c.cjs +1 -0
- package/dist/{textwrap-LhJkHWb1.cjs → textwrap-BYSqmGGV.cjs} +1 -1
- package/dist/{textwrap-Bt_tnI6V.js → textwrap-CGjFy7gf.js} +1 -1
- package/dist/usePopoverBounds-C3hn7F1s.js +84 -0
- package/dist/usePopoverBounds-mJhJ-VqG.cjs +1 -0
- package/dist/vue-async.cjs +1 -1
- package/dist/vue-async.js +3 -3
- package/dist/vue.cjs +1 -1
- package/dist/vue.js +13 -10
- package/dist/{workbook-session-BJfZVp4q.cjs → workbook-session-DL3uBAl8.cjs} +1 -1
- package/dist/{workbook-session-DRnMjIFK.js → workbook-session-nkvroJUE.js} +2 -2
- package/dist/worker.cjs +1 -1
- package/dist/worker.js +4 -4
- package/dist/xlsx.cjs +4 -4
- package/dist/xlsx.js +28 -29
- package/package.json +1 -1
- package/dist/ExcelBindingWizard-D1LZxm93.cjs +0 -1
- package/dist/ParamEditor-BTIx9UDt.cjs +0 -1
- package/dist/ReportBatchPanel-CU2BbpBg.cjs +0 -1
- package/dist/ReportLabelStudio-BXKE0GVs.cjs +0 -1
- package/dist/ReportParamPanel-Chxu4MTx.cjs +0 -1
- package/dist/ReportPreview-CIMR4ERo.cjs +0 -6
- package/dist/ReportTemplateLibrary-tv1sNa78.cjs +0 -1
- package/dist/RuleEditor-CvyjPyR6.cjs +0 -1
- package/dist/TemplateOutlinePanel-hb8cKkKR.cjs +0 -1
- package/dist/TemplateReusePanel-CR5jF00y.cjs +0 -1
- package/dist/TemplateReviewPanel-BU35FHwG.cjs +0 -1
- package/dist/_plugin-vue_export-helper-8SL1F89S.js +0 -53
- package/dist/_plugin-vue_export-helper-BLmdZLlg.cjs +0 -1
- package/dist/assets-BFTP-0WR.js +0 -137
- package/dist/assets-CZiZhTf2.cjs +0 -1
- package/dist/auto-CXd2E2aZ.cjs +0 -1
- package/dist/capabilities-D8UU2clQ.cjs +0 -1
- package/dist/capabilities-g0a2j9Yy.js +0 -125
- package/dist/designer-CEMTZomv.cjs +0 -2
- package/dist/designer-_IKm_n5N.js +0 -8002
- package/dist/diagnostic-collector-wASg6Fzs.cjs +0 -1
- package/dist/dom-Fk4NF-gN.cjs +0 -1
- package/dist/json-snapshot-DGFeI30h.cjs +0 -2
- package/dist/matrix-CcqYOuq_.cjs +0 -1
- package/dist/media-B7vnpD8k.cjs +0 -1
- package/dist/media-Y90dHK9z.js +0 -70
- package/dist/prepared-BLhV7vdE.cjs +0 -1
- package/dist/sha256-BDQ1Qk7A.js +0 -158
- package/dist/sha256-DgZAKXqI.cjs +0 -1
- package/dist/template-catalog-DDH-5J57.cjs +0 -1
- package/dist/template-registry-D24Z8aQf.cjs +0 -1
- package/dist/template-serialization-BOUidUlh.cjs +0 -1
- package/dist/template-serialization-BgGWYV_1.js +0 -307
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const nt='"Microsoft YaHei", sans-serif';const N="#333333",k="#000000",H="1.0.0-mach";function M(t=96){return t/25.4}function ot(t,e=96){return(t||0)*M(e)}function rt(t,e=96){return t/M(e)}function $(t,e=96){return t*e/72}function st(t,e){const n=10**e;return Math.round(t*n)/n}const it={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 ct(t,e=96,n=10.5){if(t?.fontSizePx!=null)return{fontSizePt:t.fontSizePx*72/e,fontSizePx:t.fontSizePx};const o=t?.fontSize??n;return{fontSizePt:o,fontSizePx:$(o,e)}}function at(t,e=N){return{color:t?.borderColor??t?.lineColor??e,widthPt:t?.lineWidthPt??.75}}function ut(t,e=k){return t?.color??e}function ft(t){return t?.lineHeight??1.35}function lt(t){const e=t?.borderTop!==!1,n=t?.borderRight!==!1,o=t?.borderBottom!==!1,r=t?.borderLeft!==!1;return{top:e,right:n,bottom:o,left:r,inner:e||n||o||r}}function B(t,e){const n={...t,...e};return e?.fontSize!=null&&e.fontSizePx==null&&delete n.fontSizePx,e?.fontSizePx!=null&&e.fontSize==null&&delete n.fontSize,n}function U(t,e=!1){return e||typeof t=="boolean"||t instanceof Date||typeof t=="number"&&Number.isFinite(t)?"center":"left"}function z(t){return t!==void 0&&/[0#?]/.test(t.replace(/"[^"]*"|\\.|\[[^\]]*\]/g,""))}function j(t,e){return e.style?.align??t?.align??U(e.value,e.valueType==="number"||e.valueType==="boolean"||e.value==null&&z(e.numberFormat))}function dt(t,e){const n=B(t,e.style);return n.align=j(t,e),n}function pt(t,e){const n=t.length;if(n===0)return[];const o=t.reduce((l,d)=>l+d,0),r=o>0&&e>0?e/o:1,i=[];let u=0;for(let l=0;l<n;l++){const d=Math.max(0,t[l]*r);i.push({pos:u,size:d}),u+=d}return i}function v(t,e,n){return t?.length?pt(t,e):Array.from({length:n},(o,r)=>({pos:e*r/n,size:e/n}))}function ht(t,e,n){const o=t.cells??[],r=Math.max(o.length,1),i=t.colWidthsMm?.length??o.reduce((s,c)=>Math.max(s,Array.isArray(c)?c.length:0),1),u=v(t.colWidthsMm,e,i),l=s=>s<=0?0:s>=i?u[u.length-1].pos+u[u.length-1].size:u[s].pos,d=v(t.rowHeightsMm,n,r),E=s=>s<=0?0:s>=r?d[d.length-1].pos+d[d.length-1].size:d[s].pos,_=new Set,T=(s,c)=>`${s}:${c}`,P=[],O=new Set,x=new Set,f=(s,c)=>`v${s}:${c}`,h=(s,c)=>`h${s}:${c}`;o.forEach((s,c)=>{if(!Array.isArray(s))return;let a=0;for(const m of s){for(;a<i&&_.has(T(c,a));)a++;if(a>=i)break;const tt=Math.max(1,Math.min(m?.colSpan??1,i-a)),et=Math.max(1,m?.rowSpan??1),C=Math.min(r,c+et),A=Math.min(i,a+tt);for(let g=c;g<C;g++)for(let S=a;S<A;S++)_.add(T(g,S));for(let g=a+1;g<A;g++)for(let S=c;S<C;S++)O.add(f(g,S));for(let g=c+1;g<C;g++)for(let S=a;S<A;S++)x.add(h(g,S));const L=l(a),R=E(c);P.push({ri:c,ci:a,cell:m??{},xMm:L,yMm:R,widthMm:l(A)-L,heightMm:E(C)-R}),a=A}});const p=[];for(let s=1;s<i;s++){let c=-1;for(let a=0;a<=r;a++){const m=a<r&&!O.has(f(s,a));m&&c<0&&(c=a),!m&&c>=0&&(p.push({kind:"v",pos:l(s),from:E(c),to:E(a)}),c=-1)}}for(let s=1;s<r;s++){let c=-1;for(let a=0;a<=i;a++){const m=a<i&&!x.has(h(s,a));m&&c<0&&(c=a),!m&&c>=0&&(p.push({kind:"h",pos:E(s),from:l(c),to:l(a)}),c=-1)}}return{columns:u,rows:d,cells:P,edges:p}}function mt(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;const{start:e,end:n,color:o}=t;return typeof e=="number"&&typeof n=="number"&&Number.isFinite(e)&&Number.isFinite(n)&&e>=0&&n<=1&&e<=n&&typeof o=="string"&&/^#[0-9a-f]{6}$/i.test(o)}const gt=H;function St(t){return(t.kind==="image"||t.kind==="barcode"||t.kind==="qrcode"||t.kind==="chart")&&!!t.imageData}function Et(t){return t.kind==="text"&&Array.isArray(t.richParagraphs)&&t.richParagraphs.length>0}function D(t){return!!t&&typeof t=="object"}function G(t,e,n,o,r){if(++r.nodes>1e6)return{path:e,message:"组件树超过100万个结构节点预算"};if(D(t)){if(n>64)return{path:e,message:"组件嵌套超过64层预算"};if(o.has(t))return{path:e,message:"组件树包含循环引用"};if(!(!D(t.grid)||!Array.isArray(t.grid.cells))){o.add(t);try{for(const[i,u]of t.grid.cells.entries())if(Array.isArray(u))for(const[l,d]of u.entries()){if(++r.nodes>1e6)return{path:e,message:"组件树超过100万个结构节点预算"};if(!(!D(d)||!Array.isArray(d.children)))for(const[E,_]of d.children.entries()){const T=G(_,`${e}.grid.cells.${i}.${l}.children.${E}`,n+1,o,r);if(T)return T}}}finally{o.delete(t)}}}}function V(t,e="$.components",n={nodes:0}){for(const[o,r]of t.entries()){const i=G(r,`${e}.${o}`,0,new Set,n);if(i)return i}}function K(t){const e={nodes:0};for(const[n,o]of t.entries()){if(!D(o)||!Array.isArray(o.components))continue;const r=V(o.components,`$.pages.${n}.components`,e);if(r)return r}}function Tt(t){const e=K(t.pages);if(e)throw new TypeError(`${e.path}: ${e.message}`)}function b(t){if(t?.aborted)throw t.reason??new DOMException("The operation was aborted.","AbortError")}function X(t){try{Promise.resolve(t()).catch(()=>{})}catch{}}function W(t,e,n){b(t.signal),X(()=>t.onProgress?.(e,n)),b(t.signal)}function _t(t,e){const n=Promise.resolve(t);return e?.aborted?(n.catch(()=>{}),Promise.reject(e.reason??new DOMException("The operation was aborted.","AbortError"))):e?new Promise((o,r)=>{const i=()=>e.removeEventListener("abort",u),u=()=>{i(),r(e.reason??new DOMException("The operation was aborted.","AbortError"))};e.addEventListener("abort",u,{once:!0}),n.then(l=>{i(),o(l)},l=>{i(),r(l)}),e.aborted&&u()}):n}function bt(t,e){const n=()=>e.abort(t?.reason);return t?.addEventListener("abort",n,{once:!0}),t?.aborted&&n(),()=>t?.removeEventListener("abort",n)}async function At(t,e,n){W(t,e,n),(t.signal||t.onProgress)&&await new Promise(o=>setTimeout(o,0)),b(t.signal)}function yt(t){let e=0,n=Date.now();return(o=1)=>{if(b(t.signal),e+=o,!(e<4096&&Date.now()-n<8))return e=0,new Promise(r=>setTimeout(r,0)).then(()=>{n=Date.now(),b(t.signal)})}}const Pt=200,Y=1e3,q=128,y="other",Z=new Set(["__proto__","prototype","constructor"]),Ot={"invalid-image-data":!0,"image-budget-exceeded":!0,"component-render-failed":!0,"unsupported-text":!0,"output-degraded":!0,"missing-image":!0,"unsupported-component":!0,"unsupported-image-format":!0,"unsupported-style":!0,"rich-text-flattened":!0,"nested-components-omitted":!0,"async-image-required":!0,"image-decode-failed":!0,"asset-render-failed":!0,"asset-budget-exceeded":!0},w=new Set([...Object.keys(Ot),"pdf-page","pdf-font","pdf-fidelity","xlsx-fidelity","xlsx-snapshot","prepared-layout-preserved","prepared-font-metrics","layout"]);function J(t){if(t===void 0)return 1/0;if(!Number.isInteger(t)||t<0||t>Y)throw new RangeError("diagnosticLimit must be an integer between 0 and 1000");return t}function xt(t){const e=J(t),n=[],o=[],r=Object.create(null),i=new Map,u=Object.create(null);let l=0,d=0,E=0;function _(f,h){const p=f.length<=128&&!Z.has(f)&&(r[f]!==void 0||E<q||w.has(f))?f:y;return r[p]===void 0&&E++,r[p]=(r[p]??0)+h,p}function T(f,h){if(e===1/0){n.push(f);return}const p=`${I(f)?"e":"o"}:${h}`;if(n.length<e){n.push(f),o.push(p),i.set(p,(i.get(p)??0)+1);return}if(!(!e||i.has(p)))for(let s=n.length-1;s>=0;s--){const c=o[s],a=i.get(c)??0;if(!(a<=1)){n[s]=f,o[s]=p,i.set(c,a-1),i.set(p,1);return}}}function P(f){d++;const h=_(f.code,1);I(f)&&(l++,u[h]=(u[h]??0)+1),T(f,h)}function O(f){d+=f.total;const h=new Map;for(const[s,c]of Object.entries(f.counts)){const a=_(s,c),m=f.explanations?.counts[s]??0;h.set(s,a),m&&(l+=m,u[a]=(u[a]??0)+m)}if(e===1/0){for(const s of f.entries)n.push(s);return}const p=new Map;for(const s of f.entries){const c=Q(f,s,p);c!==void 0&&T(s,h.get(c))}}function x(){return{total:d,counts:{...r},entries:n.slice(),omitted:d-n.length,...l?{explanations:{total:l,counts:{...u}}}:{}}}return{entries:n,push:P,merge:O,snapshot:x,get total(){return d}}}function Ct(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;const e=t;if(!Number.isSafeInteger(e.total)||e.total<0||!Number.isSafeInteger(e.omitted)||e.omitted<0||!Array.isArray(e.entries)||e.entries.length>Y||e.total!==e.entries.length+e.omitted||!e.counts||typeof e.counts!="object"||Array.isArray(e.counts)||Object.keys(e.counts).some(o=>o.length>128||Z.has(o)))return!1;const n=Object.values(e.counts);return n.length>q+w.size+1||n.some(o=>!Number.isSafeInteger(o)||o<=0)||n.reduce((o,r)=>o+r,0)!==e.total?!1:It(e)&&Dt(e)}function Dt(t){const e=new Map;return t.entries.every(n=>Q(t,n,e)!==void 0)}function F(t,e,n,o){const r=`${n?"e":"o"}:${e}`,i=(o.get(r)??0)+1,u=t.explanations?.counts[e]??0;return(n?u:(t.counts[e]??0)-u)<i?!1:(o.set(r,i),!0)}function Q(t,e,n){const o=e&&typeof e=="object"&&typeof e.code=="string"?e.code:"unknown",r=Object.prototype.hasOwnProperty.call(t.counts,o)?o:y,i=!!e&&typeof e=="object"&&I(e);if(F(t,r,i,n))return r;if(r!==y&&!w.has(o)&&F(t,y,i,n))return y}function I(t){return t.valueState!==void 0}function It(t){if(t.explanations===void 0)return!0;const e=t.explanations;if(!e||typeof e!="object"||Array.isArray(e)||!Number.isSafeInteger(e.total)||e.total<0||e.total>t.total||!e.counts||typeof e.counts!="object"||Array.isArray(e.counts))return!1;const n=Object.entries(e.counts);return n.every(([o,r])=>Number.isSafeInteger(r)&&r>0&&r<=(t.counts[o]??0))&&n.reduce((o,[,r])=>o+r,0)===e.total}function Mt(t,e){const n=J(t),o=[];let r=0;return{entries:o,get total(){return r},push(...i){for(const u of i)r++,o.length<n&&o.push(u),e?.(u);return r}}}exports.CSS_DPI=96;exports.DEFAULT_BORDER_PT=.75;exports.DEFAULT_DIAGNOSTIC_LIMIT=Pt;exports.DEFAULT_FONT_FAMILY=nt;exports.DEFAULT_FONT_PT=10.5;exports.DEFAULT_STROKE_COLOR=N;exports.DEFAULT_TEXT_COLOR=k;exports.LINE_HEIGHT=1.35;exports.MM_PER_INCH=25.4;exports.PAPER_SIZES=it;exports.RENDER_PLAN_SCHEMA_VERSION=gt;exports.SCHEMA_VERSION_MACH=H;exports.assertBoundedRenderTree=Tt;exports.assertOutputActive=b;exports.automaticCellAlignment=U;exports.componentTreeIssue=V;exports.createDiagnosticCollector=xt;exports.createDiagnosticMessages=Mt;exports.createOutputScheduler=yt;exports.forwardOutputAbort=bt;exports.gridCellAlignment=j;exports.hasNumericCellFormat=z;exports.isImageBackedComponent=St;exports.isRichText=Et;exports.mergeComponentStyles=B;exports.mmToPx=ot;exports.mmToPxFactor=M;exports.notifyOutputProgress=W;exports.observeOutput=X;exports.outputCheckpoint=At;exports.ptToPx=$;exports.pxToMm=rt;exports.renderTreeIssue=K;exports.resolveBoxBorders=lt;exports.resolveFontSize=ct;exports.resolveGridCellStyle=dt;exports.resolveGridLayout=ht;exports.resolveLineHeight=ft;exports.resolveStroke=at;exports.resolveTextColor=ut;exports.round=st;exports.validDataBar=mt;exports.validDiagnosticSummary=Ct;exports.waitForOutput=_t;
|
package/dist/dom-Fk4NF-gN.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const z=require("./template-serialization-BOUidUlh.cjs"),V=require("./data-bar-DzceAVeR.cjs"),D=require("./dom-cell-address-DLD1mkTB.cjs"),f=require("./diagnostic-collector-wASg6Fzs.cjs"),B=require("./grid-strokes-RFMR91jn.cjs"),R=require("./capabilities-D8UU2clQ.cjs");function F(e){const t=/\.pages\[(\d+)\](?:\.components\[(\d+)\])?/.exec(e);return t?{pageIndex:Number(t[1]),...t[2]===void 0?{}:{componentIndex:Number(t[2])}}:{}}function q(e,t,r){return z.collectTemplateDatasetBindings(e).filter(n=>n.dataset===t).flatMap(n=>n.fields.filter(o=>o.field===r).map(o=>({...o,...F(o.path),dataset:t,kind:/\.computed\[/.test(o.path)?"calculation":/\.columns\[\d+\]\.field$/.test(o.path)?"display":"binding"})))}function j(e,t){const r=e.kind==="list"?e.title||e.dataset:e.binding?.field||e.text||e.nid;return`${e.kind} · ${(r||String(t+1)).replace(/\s+/g," ").slice(0,80)}`}function K(e){const t=z.collectTemplateDatasetBindings(e),r=new Map;for(const o of t)for(const a of o.fields){const i=/^\$\.template\.pages\[\d+\]\.components\[\d+\]/.exec(a.path)?.[0];if(!i)continue;const s=r.get(i)??[];s.push({...a,dataset:o.dataset}),r.set(i,s)}const n=[];return e.pages.forEach((o,a)=>{const i=`$.template.pages[${a}]`;n.push({path:i,pageIndex:a,kind:"page",depth:0,title:typeof o.meta?.title=="string"?o.meta.title:`${a+1} · ${o.widthMm} × ${o.heightMm} mm`}),o.components.forEach((s,l)=>{const d=`${i}.components[${l}]`,h={pageIndex:a,componentIndex:l};n.push({path:d,...h,depth:1,kind:"component",title:j(s,l)}),s.kind==="list"&&(s.columns.forEach((m,p)=>n.push({path:`${d}.columns[${p}].field`,...h,depth:2,kind:"field",title:`${m.header} · ${m.field}`,field:m.field,dataset:s.dataset})),s.computed?.forEach((m,p)=>n.push({path:`${d}.computed[${p}]`,...h,depth:2,kind:"calculation",title:m.field,field:m.field,dataset:s.dataset})));const c=new Set;for(const m of r.get(d)??[])/\.columns\[\d+\]\.field$/.test(m.path)||c.has(m.path)||(c.add(m.path),n.push({...m,...h,depth:2,kind:"binding",title:m.field}))})}),n}function M(e,t,r){let n=0,o=e.length;for(;n<o;){const a=n+o>>>1;r(e[a])<t?n=a+1:o=a}return n}function G(e){if(![e.leftMm,e.topMm,e.widthMm,e.heightMm].every(Number.isFinite)||e.widthMm<0||e.heightMm<0)throw new RangeError("Preview viewport must have finite coordinates and nonnegative dimensions.");return e}function U(e){const t=e.rows.map(()=>[]);for(const r of e.cells){const n=Math.min(t.length,r.ri+(r.cell.rowSpan??1));for(let o=r.ri;o<n;o++)t[o].push(r)}for(const r of t)r.sort((n,o)=>n.xMm-o.xMm);return{cells(r){G(r);const n=new Set,o=r.topMm+r.heightMm,a=r.leftMm+r.widthMm;let i=M(e.rows,r.topMm,s=>s.pos+s.size);for(;i<t.length&&e.rows[i].pos<=o;){const s=t[i++];let l=M(s,r.leftMm,d=>d.xMm+d.widthMm);for(;l<s.length&&s[l].xMm<=a;)n.add(s[l++])}return[...n].sort((s,l)=>s.ri-l.ri||s.ci-l.ci)}}}function _(e){const t=["h","v"].map(r=>e.filter(n=>n.kind===r).sort((n,o)=>n.pos-o.pos));return r=>{const n=[];return t.forEach((o,a)=>{const i=a===0?r.topMm:r.leftMm,s=i+(a===0?r.heightMm:r.widthMm),l=a===0?r.leftMm:r.topMm,d=l+(a===0?r.widthMm:r.heightMm);let h=M(o,i,c=>c.pos);for(;h<o.length&&o[h].pos<=s;){const c=o[h++];c.to>=l&&c.from<=d&&n.push(c)}}),n}}function W(){const e=[];return{mount(t){e.push(ee(t))},update(t,r,n,o){G(t);let a=!1;for(const i of e)a=i.update(t,i.component===r?n:void 0,o)||a;return a}}}function X(e,t){const r=Math.max(8,e.widthMm/4),n=Math.max(8,e.heightMm/4);return{leftMm:e.leftMm-t.leftMm-r,topMm:e.topMm-t.topMm-n,widthMm:e.widthMm+2*r,heightMm:e.heightMm+2*n}}function Y(e,t,r){let n=t.get(r);return n||(n=e.table.ownerDocument.createElement("tr"),n.className=e.rowClass,n.setAttribute("role","row"),n.setAttribute("aria-rowindex",String(r+1)),n.style.cssText="all:unset;display:contents;box-sizing:border-box",t.set(r,n)),n}function J(e,t,r,n){const o=new Set(t),a=new Set(t.map(l=>l.ri)),i=new Map;for(const[l,d]of r)if(!o.has(l)){d.remove(),r.delete(l);const h=e.reuseKey?.(l);if(h!==void 0){const c=i.get(h)??[];c.push(d),i.set(h,c)}}for(const[l,d]of n)a.has(l)||(d.remove(),n.delete(l));for(const l of t){let d=r.get(l);if(!d){const c=e.reuseKey?.(l),m=c===void 0?void 0:i.get(c)?.pop();d=m&&e.reuseCell?.(m,l)?m:e.drawCell(l),d.setAttribute("aria-colindex",String(l.ci+1)),r.set(l,d)}const h=Y(e,n,l.ri);d.parentElement!==h&&h.appendChild(d)}const s=new Map;for(const l of t){const d=s.get(l.ri)??[];d.push(r.get(l)),s.set(l.ri,d)}for(const[l,d]of s)A(n.get(l),d);A(e.body,[...a].sort((l,d)=>l-d).map(l=>n.get(l)))}function A(e,t){let r=e.firstElementChild;for(const n of t)n===r?r=r.nextElementSibling:e.insertBefore(n,r)}function Q(e,t){return e.table?.role==="header"?e.heightMm:t.rows[0]?.size??0}function Z(e,t,r,n){const o=[e],a=n.freezeHeaders&&(r.table?.role==="header"||!r.table),i=Q(r,t);a&&o.push({...e,topMm:0,heightMm:Math.max(0,i-1e-4)});const s=Math.max(0,Math.min(20,Math.floor(n.frozenColumns??0)))||0;if(!s||!t.columns.length)return o;const l=t.columns[Math.min(s,t.columns.length)-1],d={...e,leftMm:0,widthMm:Math.max(0,l.pos+l.size-1e-4)};return o.push(d),a&&o.push({...d,topMm:0,heightMm:Math.max(0,i-1e-4)}),o}function ee(e){const t=f.resolveGridLayout(e.grid,e.component.widthMm,e.component.heightMm),r=new Map(t.cells.map(h=>[`${h.ri}:${h.ci}`,h])),n=U(t),o=new Map,a=new Map,i=_(B.resolveGridStrokes(t,e.component));e.table.setAttribute("aria-rowcount",String(t.rows.length)),e.table.setAttribute("aria-colcount",String(t.columns.length));let s="",l="";function d(h,c){const m=new Set;for(const p of Z(h,t,e.component,c??{}))for(const w of n.cells(p))m.add(w);return[...m]}return{component:e.component,update(h,c,m){const p=X(h,e.component),w=d(p,m),y=c&&r.get(`${c.rowIndex}:${c.columnIndex}`);y&&!w.includes(y)&&w.push(y),w.sort((b,$)=>b.ri-$.ri||b.ci-$.ci);const C=w.map(b=>`${b.ri}:${b.ci}`).join(";"),v=i(p),S=v.map(b=>`${b.kind}:${b.pos}:${b.from}:${b.to}`).join(";"),E=C!==s,T=S!==l;return E&&(s=C,J(e,w,o,a)),T&&(l=S,e.edgeHost.replaceChildren(...e.drawEdges(v))),E||T}}}const L=new WeakMap,te={root:"mr-root",page:"mr-page",comp:"mr-comp",text:"mr-text",lines:"mr-lines",line:"mr-line",rich:"mr-rich",paragraph:"mr-paragraph",segment:"mr-segment",image:"mr-image",shape:"mr-shape",grid:"mr-grid",row:"mr-row",cell:"mr-cell",unknown:"mr-unknown"};function g(e,t){return t?.classNames?.[e]??te[e]}class ne{constructor(){this.props=[]}add(t,r){return r==null||r===!1||r===""?this:(this.props.push([t,String(r)]),this)}mm(t,r,n,o=2){return this.add(t,`${f.round(f.mmToPx(r,n),o)}px`)}toString(){let t="";for(const[r,n]of this.props)t+=`${r}:${n};`;return t}applyTo(t){const r=this.toString();r&&(t.style.cssText=r)}}function u(e,t="unset"){return new ne().add("all",t).add("display",e).add("box-sizing","border-box")}function H(e,t,r){e.add("color",t.color).add("font-family",t.fontFamily).add("font-weight",t.bold!=null?t.bold?"700":"400":void 0).add("font-style",t.italic!=null?t.italic?"italic":"normal":void 0).add("text-decoration",t.underline!=null?t.underline?"underline":"none":void 0).add("letter-spacing",t.letterSpacing!=null?`${t.letterSpacing}pt`:void 0).add("line-height",String(f.resolveLineHeight(t))).add("text-align",t.align);const n=f.resolveFontSize(t,r);e.add("font-size",`${f.round(n.fontSizePx,2)}px`)}function re(e,t,r){const n=t.style??{};H(e,n,r);const o=!t.grid&&(t.kind==="ellipse"||t.kind==="line");e.add("background-color",o?void 0:n.backgroundColor).add("opacity",n.opacity!=null?String(n.opacity):void 0).add("transform",n.rotateDeg?`rotate(${n.rotateDeg}deg)`:void 0)}function P(e,t,r,n,o,a){const i=e.cell,s=a.createElement("td");s.className=g("cell",o),D.setDomCellAddress(s,e.ri,e.ci),s.setAttribute("role",t.table?.role==="header"?"columnheader":"cell"),i.colSpan&&(s.colSpan=i.colSpan),i.rowSpan&&(s.rowSpan=i.rowSpan);const l=f.resolveGridCellStyle(t.style,i),d=u("block").add("position","absolute").mm("left",e.xMm,n).mm("top",e.yMm,n).mm("width",e.widthMm,n).mm("height",e.heightMm,n).add("background-color",l.backgroundColor).add("vertical-align",l.verticalAlign??"middle").add("opacity",i.style?.opacity!=null?String(i.style.opacity):void 0).add("transform",i.style?.rotateDeg?`rotate(${i.style.rotateDeg}deg)`:void 0);H(d,l,n),d.applyTo(s);const h=V.dataBarBox(i.dataBar,e.widthMm,e.heightMm,r);if(h){const m=a.createElement("div");m.className="mr-cell-data-bar",m.setAttribute("aria-hidden","true"),u("block").add("position","absolute").mm("left",h.x,n).mm("top",h.y,n).mm("width",h.width,n).mm("height",h.height,n).add("background-color",h.color).add("opacity","0.35").add("pointer-events","none").applyTo(m),s.appendChild(m)}const c=a.createElement("div");c.className="mr-cell-content",u("flex").add("position","absolute").mm("left",r+(i.indentMm??0),n).mm("right",r,n).mm("top",r,n).mm("bottom",r,n).add("flex-direction","column").add("justify-content",l.verticalAlign==="top"?"flex-start":l.verticalAlign==="bottom"?"flex-end":"center").add("overflow-wrap","anywhere").add("overflow","hidden").applyTo(c),i.richParagraphs?.length?c.appendChild(I({...t,kind:"text",richParagraphs:i.richParagraphs},n,o,a)):i.text!=null&&c.append(i.text);for(const m of i.children??[])c.appendChild(x(m,n,o,a));return s.insertBefore(c,s.firstChild),s}function oe(e,t,r,n){return O(B.resolveGridStrokes(e,t),r,n)}function ie(e,t){const r=e.cell;if(!(r.children?.length||r.richParagraphs?.length||r.dataBar||(r.colSpan??1)!==1||(r.rowSpan??1)!==1))return JSON.stringify([r.style,r.indentMm,f.gridCellAlignment(t,r)])}function le(e,t,r){if(e.style.position!=="absolute"||e.style.zIndex||e.style.transform||e.children.length!==1)return!1;const n=e.firstElementChild;return!(n instanceof HTMLElement)||n.className!=="mr-cell-content"?!1:(D.setDomCellAddress(e,t.ri,t.ci),e.style.left=`${f.round(f.mmToPx(t.xMm,r),2)}px`,e.style.top=`${f.round(f.mmToPx(t.yMm,r),2)}px`,e.style.width=`${f.round(f.mmToPx(t.widthMm,r),2)}px`,e.style.height=`${f.round(f.mmToPx(t.heightMm,r),2)}px`,n.textContent=t.cell.text??"",!0)}function O(e,t,r){return e.map(n=>{const o=`${f.round(n.widthPt*t/72,2)}px solid ${n.color}`,a=r.createElement("div");a.className="mr-grid-edge",a.setAttribute("aria-hidden","true");const i=n.kind==="h";return u("block").add("position","absolute").add("pointer-events","none").mm("left",i?n.from:n.pos,t).mm("top",i?n.pos:n.from,t).mm("width",i?n.to-n.from:0,t).mm("height",i?0:n.to-n.from,t).add(i?"border-top":"border-left",o).applyTo(a),a})}function ae(e,t,r,n,o){const a=o.createElement("table");a.className=g("grid",n),a.setAttribute("role","table"),u("block").add("position","relative").add("width","100%").add("height","100%").applyTo(a);const i=o.createElement("tbody");u("contents").applyTo(i),a.appendChild(i);const s=t.style?.rotateDeg?void 0:L.get(n);if(s){const c=o.createElement("div");u("block").add("position","relative").add("width","100%").add("height","100%").applyTo(c);const m=o.createElement("div");return u("contents").applyTo(m),m.setAttribute("aria-hidden","true"),s.mount({grid:e,component:t,table:a,rowClass:g("row",n),body:i,edgeHost:m,drawCell:p=>P(p,t,e.paddingMm??.5,r,{...n},o),reuseKey:p=>ie(p,t.style),reuseCell:(p,w)=>le(p,w,r),drawEdges:p=>O(p,r,o)}),c.append(a,m),c}const l=f.resolveGridLayout(e,t.widthMm,t.heightMm),d=e.cells.map(()=>{const c=o.createElement("tr");return c.className=g("row",n),c.setAttribute("role","row"),u("contents").applyTo(c),i.appendChild(c),c});for(const c of l.cells)d[c.ri].appendChild(P(c,t,e.paddingMm??.5,r,n,o));const h=o.createElement("div");return u("block").add("position","relative").add("width","100%").add("height","100%").applyTo(h),h.append(a,...oe(l,t,r,o)),h}function se(e,t,r,n){const o=n.createElement("div");o.className=g("paragraph",r),u("block").add("text-align",e.align).add("line-height",e.lineHeight!=null?String(e.lineHeight):void 0).mm("margin-top",e.spaceBeforeMm??0,t).mm("margin-bottom",e.spaceAfterMm??0,t).mm("text-indent",e.indentMm??0,t).applyTo(o);for(const a of e.segments||[]){const i=n.createElement("span");i.className=g("segment",r),i.textContent=a.kind==="field"?a.field??"":a.text??"";const s=u("inline");if(a.style){const l=a.style;s.add("color",l.color).add("background-color",l.backgroundColor).add("font-family",l.fontFamily).add("line-height",l.lineHeight).add("letter-spacing",l.letterSpacing==null?void 0:`${l.letterSpacing*t/72}px`).add("font-weight",l.bold!=null?l.bold?"700":"400":void 0).add("font-style",l.italic!=null?l.italic?"italic":"normal":void 0).add("text-decoration",l.underline!=null?l.underline?"underline":"none":void 0),(l.fontSize!=null||l.fontSizePx!=null)&&s.add("font-size",`${f.round(f.resolveFontSize(l,t).fontSizePx,2)}px`)}s.applyTo(i),o.appendChild(i)}return o}function I(e,t,r,n){if(f.isRichText(e)){const o=n.createElement("div");o.className=g("rich",r),u("block").applyTo(o);for(const a of e.richParagraphs)o.appendChild(se(a,t,r,n));return o}if(Array.isArray(e.lines)&&e.lines.length>0){const o=n.createElement("div");o.className=g("lines",r),u("block").applyTo(o);for(const a of e.lines){const i=n.createElement("div");i.className=g("line",r),i.textContent=a,u("block").add("white-space","pre").add("min-height","1lh").applyTo(i),o.appendChild(i)}return o}return e.text??""}function de(e,t,r,n){const o=n.createElement("div");o.className=g("text",r);const a=e.style||{};return u("flex").add("width","100%").add("height","100%").add("flex-direction","column").add("justify-content",a.verticalAlign==="middle"?"center":a.verticalAlign==="bottom"?"flex-end":"flex-start").add("overflow-wrap","anywhere").add("overflow","hidden").applyTo(o),o.append(I(e,t,r,n)),o}function ce(e,t,r){const n=r.createElement("img");return n.className=g("image",t),n.src=e.imageData,u("block").add("width","100%").add("height","100%").add("object-fit","contain").applyTo(n),n.alt=e.kind,n}function N(e,t,r,n){const o=n.createElement("div");o.className=g("shape",r);const a=e.style||{},i=f.resolveStroke(a),s=f.resolveBoxBorders(a),l=`${f.round(i.widthPt*t/72,2)}px solid ${i.color}`,d=u("block");return e.grid?d.add("position","relative"):e.kind==="rect"?(s.top&&d.add("border-top",l),s.right&&d.add("border-right",l),s.bottom&&d.add("border-bottom",l),s.left&&d.add("border-left",l)):e.kind==="ellipse"?(d.add("border-radius","50%"),s.inner&&d.add("border",l),a.backgroundColor&&d.add("background-color",a.backgroundColor)):e.kind==="line"&&d.add("height","0").add("border-top",l),d.add("box-sizing","border-box").add("width","100%").add("height","100%"),d.applyTo(o),o}function he(e,t,r){const n=r.createElementNS("http://www.w3.org/2000/svg","svg"),o=f.mmToPx(e.widthMm,t),a=f.mmToPx(e.heightMm,t);n.setAttribute("width",String(Math.max(1,o))),n.setAttribute("height",String(Math.max(1,a))),n.setAttribute("aria-hidden","true"),n.style.overflow="visible",n.style.display="block";const i=r.createElementNS("http://www.w3.org/2000/svg","line");i.setAttribute("x1","0"),i.setAttribute("x2",String(o)),i.setAttribute("y1",e.lineDirection==="up"?String(a):"0"),i.setAttribute("y2",e.lineDirection==="up"?"0":String(a));const s=f.resolveStroke({...e.style,borderColor:e.style?.lineColor??e.style?.borderColor});return i.setAttribute("stroke",s.color),i.setAttribute("stroke-width",String(s.widthPt*t/72)),n.appendChild(i),n}function x(e,t,r,n){const o=n.createElement("div");o.className=`${g("comp",r)} mr-kind-${e.kind}`;const a=u("block").add("position","absolute").mm("left",e.leftMm,t).mm("top",e.topMm,t).mm("width",e.widthMm,t).mm("height",e.heightMm,t).add("box-sizing","border-box");if(re(a,e,t),a.applyTo(o),f.isImageBackedComponent(e))return o.appendChild(ce(e,r,n)),o;if(e.kind==="text")return o.appendChild(de(e,t,r,n)),o;if(e.grid){const s=N(e,t,r,n);return s.appendChild(ae(e.grid,e,t,r,n)),o.appendChild(s),o}if(e.kind==="line"&&e.lineDirection)return o.appendChild(he(e,t,n)),o;if(e.kind==="line"||e.kind==="rect"||e.kind==="ellipse")return o.appendChild(N(e,t,r,n)),o;const i=n.createElement("div");return i.className=g("unknown",r),u("block").applyTo(i),i.textContent=e.fallbackText??`[${e.kind}]`,i.dataset.mrUnsupported=e.kind,i.setAttribute("role","note"),o.appendChild(i),o}function k(e,t,r,n){const o=n.createElement("div");return o.className=g("page",r),u("block","initial").add("position","relative").add("font-family",f.DEFAULT_FONT_FAMILY).add("font-size",`${f.round(f.resolveFontSize(void 0,t).fontSizePx,2)}px`).add("line-height",String(f.resolveLineHeight(void 0))).add("white-space","pre-wrap").add("direction","ltr").mm("width",e.pageWidthMm,t).mm("height",e.pageHeightMm,t).add("background-color","#fff").add("color",f.DEFAULT_TEXT_COLOR).add("overflow","hidden").add("box-sizing","border-box").applyTo(o),e.components.forEach((a,i)=>{const s=x(a,t,r,n);s.dataset.mrComponentIndex=String(i),o.appendChild(s)}),o}function me(e,t,r={}){const n=r.dpi??96;R.reportOutputDiagnostics(e,"dom",r);const o=t.createElement("div");return o.className=g("root",r),u("block").applyTo(o),o.dataset.schemaVersion=e.schemaVersion,e.pages.forEach(a=>{o.appendChild(k(a,n,r,t))}),o}function fe(e,t,r,n){const o={...r},a=W();return L.set(o,a),{element:k(e,t,o,n),update(s,l,d){return a.update(s,l&&e.components[l.componentIndex],l,d)}}}exports.classOf=g;exports.collectTemplateOutline=K;exports.createPageViewportRenderer=fe;exports.inspectTemplateFieldUsage=q;exports.renderComponent=x;exports.renderPage=k;exports.renderPlan=me;exports.templatePathLocation=F;
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";const E=require("./diagnostic-collector-wASg6Fzs.cjs"),L=require("./textwrap-LhJkHWb1.cjs"),I=require("./computed-BQgBrma-.cjs"),M=require("./record-bindings-KEs-DKCS.cjs"),Qe=require("./matrix-CcqYOuq_.cjs"),_=require("./template-serialization-BOUidUlh.cjs"),B=require("./template-registry-D24Z8aQf.cjs"),Xt=require("./report-params-VTg8MoCp.cjs"),Ge=require("./param-validation-C-8sRJLq.cjs"),Ze=require("./number-format-CZ2T_5kF.cjs"),Ee=require("./dataset-D3OsyzG1.cjs"),Yt=4096,We=128*1024;function Qt(e){const t=new Map;let r=0;return{measureMm(n,o){const a=JSON.stringify([n,o.fontSizePt,o.fontFamily,o.bold,o.italic,o.letterSpacingPt]),s=t.get(a);if(s!==void 0)return t.delete(a),t.set(a,s),s;const i=e.measureMm(n,o);if(Number.isFinite(i)&&a.length<=We){for(;t.size>=Yt||r+a.length>We;){const c=t.keys().next().value;r-=c.length,t.delete(c)}t.set(a,i),r+=a.length}return i}}}async function ve(e,t){let r=performance.now(),n=0;try{for(;;){_e(t);const o=e.next();if(o.done)return o.value;++n<8192&&(n%64!==0||performance.now()-r<4)||(await new Promise(a=>setTimeout(a,0)),_e(t),r=performance.now(),n=0)}}finally{e.return(void 0)}}function _e(e){if(e?.aborted)throw Object.assign(new Error("报表处理已取消"),{name:"AbortError",cause:e.reason})}const te=new WeakMap;function et(e,t){return!t.formula&&!e.tree&&!e.computed?.some(r=>typeof r.expression=="string")}function Zt(e){return te.set(e,new Map),()=>{te.delete(e)}}function er(e,t,r){const n=r===t?void 0:new Map(r.map((a,s)=>[a,t[s]]));return{rows:e.rowVisibleWhen?r.filter(I.compileReportPredicate(e.rowVisibleWhen)):r,originals:n}}function tt(e,t,r,n){const o=et(e,n)?te.get(r):void 0,a=o?.get(e);if(a?.input===t)return a.prepared;const s=e.computed?.length?I.computeDataset(t,{fields:e.computed,...n}).rows:t,i=er(e,t,s);return o?.set(e,{input:t,prepared:i}),i}function*tr(e,t,r){const n=e.computed?.length?(yield*I.iterateComputedDataset(t,{fields:e.computed,...r})).rows:t,o=n===t?void 0:new Map,a=e.rowVisibleWhen?I.compileReportPredicate(e.rowVisibleWhen):void 0,s=a?[]:n;for(const[i,c]of n.entries())o?.set(c,t[i]),a?.(c)&&s.push(c),yield;return{rows:s,originals:o}}async function rr(e,t,r){const n=te.get(t);if(n)for(const o of e.pages)for(const a of o.components){if(a.kind!=="list")continue;const s=a;if(!et(s,r)||!s.computed?.length&&!s.rowVisibleWhen)continue;const i=t[s.dataset]??[],c=await ve(tr(s,i,r),r.signal);n.set(s,{input:i,prepared:c})}}function nr(e,t){return{member:"body",subtotal:"subtotal",total:"grand-total"}[e?.rows.get(t)?.kind??"member"]}function or(e){const t=e.matrix;if(!t.hierarchy)return t;const r=new Map(e.columns.map(o=>[o.field,o.header])),n={sum:"求和",count:"计数",avg:"平均",min:"最小",max:"最大",weightedAvg:"加权平均"};return{...t,hierarchy:{...t.hierarchy,row:{...t.hierarchy.row,labels:t.hierarchy.row?.labels??t.rowFields.map(o=>r.get(o)??o)},column:{...t.hierarchy.column,labels:t.hierarchy.column?.labels??t.columnFields.map(o=>r.get(o)??o)}},measures:t.measures.map(o=>{const a=r.get(o.field)??r.get(o.valueField??o.field);return o.label===void 0&&a?{...o,label:`${a}(${n[o.op]})`}:o})}}function ar(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=Qe.createMatrixTable(t,or(e)),n=r.columns.map(i=>({...i,widthMm:i.semanticRole==="dimension"?e.matrix.rowWidthMm??40:e.matrix.columnWidthMm??28,editable:!1,align:e.align??"auto"})),o={...e,columns:n,headerGrid:r.headerGrid,rowKey:void 0,revisionField:void 0,sourceTokenField:void 0};e.layout==="wide"&&(o.widthMm=n.reduce((i,c)=>i+c.widthMm,0));const a=r.metadata,s=a?{rows:new WeakMap(r.rows.map((i,c)=>[i,a.rows[c]])),header:{columns:a.columns,rowFields:a.rowFields,rowLabels:a.rowLabels,columnFields:a.columnFields,columnLabels:a.columnLabels}}:void 0;return{list:o,rows:r.rows,...s?{matrix:s}:{}}}function sr(e,t){if(!e.matrix?.hierarchy||!e.headerGrid)return e.headerGrid;const r=e.paddingMm??1,n=e.headerGrid.cells.map(()=>e.rowHeightMm??0),o=e.columns.map(c=>c.widthMm),a=E.resolveGridLayout({...e.headerGrid,colWidthsMm:o},o.reduce((c,l)=>c+l,0),n.length),s=new WeakMap;for(const{cell:c,ci:l,ri:u,widthMm:f}of a.cells){const d={...M.resolveListHeaderStyle(e,e.columns[l]),...c.style},m=E.resolveFontSize(d).fontSizePt,y=(L.wrapText(c.text??"",Math.max(1,f-r*2),{fontSizePt:m,fontFamily:d.fontFamily,bold:d.bold,italic:d.italic,letterSpacingPt:d.letterSpacing},t).length*m*(d.lineHeight??E.LINE_HEIGHT)*25.4/72+r*2)/(c.rowSpan??1);for(let w=u;w<u+(c.rowSpan??1);w++)n[w]=Math.max(n[w]??0,y);s.set(c,d)}const i=e.headerGrid.cells.map(c=>c.map(l=>l?{...l,style:s.get(l)}:null));return{...e.headerGrid,cells:i,rowHeightsMm:n}}function ir(e,t,r){const n=new Set,o=e.cells.map((a,s)=>{const i=[];let c=0;for(const l of a){for(;n.has(`${s}:${c}`);)c++;const u=l?.colSpan??1,f=l?.rowSpan??1;let d=0;for(let m=c;m<c+u;m++){t.has(m)&&d++;for(let g=s+1;g<s+f;g++)n.add(`${g}:${m}`)}d&&i.push(l?{...l,colSpan:d}:null),c+=u}return i});return{...e,cells:o,colWidthsMm:r}}function rt(e){if(!e.columns.some(n=>n.hidden))return e;const t=new Set,r=e.columns.filter((n,o)=>n.hidden?!1:(t.add(o),!0));if(!r.length)throw new Error("列表至少需要一列可见列");return{...e,columns:r,...e.headerGrid?{headerGrid:ir(e.headerGrid,t,r.map(n=>n.widthMm))}:{}}}function*cr(e){const{page:t}=e;B.validateReportPageFlow(t.components,t.flow);let r=0,n=0;for(const o of B.reportFlowGroups(t.components,t.flow)){e.active();const a=o.band,s=o.components.some(u=>u.kind==="list"&&u.cardinality!=="record"),i=s?0:o.components.reduce((u,f)=>Math.max(u,f.topMm-a.topMm+(f.kind==="list"?e.height(f):f.heightMm)),a.heightMm);let c=Math.max(e.top(),n+a.topMm-r);if(!s&&i>e.bottom()-e.top()+.001)throw new Error(`静态区域 ${a.componentIds.join(",")} 高度超出单页可用范围`);!s&&c+i>e.bottom()+.001&&(e.nextPage(),yield*e.takePages(),e.active(),c=e.top());let l=c+i;for(const u of o.components){const f=c+u.topMm-a.topMm;u.kind==="list"?(yield*e.list(u,f,d=>{l=s?d:Math.max(l,d)}),e.active()):e.append({...u,topMm:f})}n=l,r=a.topMm+a.heightMm}}function lr(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||t.visual))}function Te(e){return e.pages.some(t=>t.components.some(r=>r.kind==="list"?lr(r):!!r.chartBinding))}const ur=512,ze=256*1024;function dr(){const e=new Map;let t=0,r;return(n,o,a,s)=>{s!==r&&(e.clear(),t=0,r=s);const i=JSON.stringify([n,o,a.fontSizePt,a.fontFamily,a.bold,a.italic,a.letterSpacingPt]),c=e.get(i);if(c)return e.delete(i),e.set(i,c),c.lines.slice();const l=L.wrapText(n,o,a,s),u=i.length+l.reduce((f,d)=>f+d.length,0);if(u<=ze){for(;e.size>=ur||t+u>ze;){const f=e.keys().next().value;t-=e.get(f).units,e.delete(f)}e.set(i,{lines:l.slice(),units:u}),t+=u}return l}}const nt=1e4,Je=25e4;function ke(e){if(e?.aborted)throw e.reason??new DOMException("标签生成已取消","AbortError")}function ot(e,t,r){const n=typeof e.copies=="object"?M.readRecordScalar(t,e.copies.field,r):e.copies??1;if(typeof n!="number"||!Number.isSafeInteger(n)||n<1||n>1e3)throw new M.ReportBindingError(`$.datasets.${r.dataset}[${r.rowIndex}]`,"每条记录复制数必须是 1..1000 的数值型整数",r.rowIndex,typeof e.copies=="object"?e.copies.field:void 0);return n}function at(e,t,r){if(e.rowKey===void 0)return;const n=M.readRecordScalar(t,e.rowKey,r);if(typeof n=="string"&&n.trim()||typeof n=="number"&&Number.isFinite(n))return n;throw new M.ReportBindingError(`$.datasets.${r.dataset}[${r.rowIndex}].${e.rowKey}`,"业务主键必须是非空字符串或有限数字",r.rowIndex,e.rowKey)}function fr(e){const t=r=>1+(r.grid?.cells.reduce((n,o)=>n+1+o.length+o.reduce((a,s)=>a+(s?.children?.reduce((i,c)=>i+t(c),0)??0),0),0)??0);return e.pages.reduce((r,n)=>r+n.components.reduce((o,a)=>o+t(a),0),0)}function mr(e,t,r){const n=e.repeat,o=Object.prototype.hasOwnProperty.call(t,n.dataset)?t[n.dataset]:void 0;if(!Array.isArray(o))throw new M.ReportBindingError(`$.datasets.${n.dataset}`,"逐记录标签数据集缺失,应提供对象数组(允许空数组)");const a=new Set,s=r.maxPages??nt,i=fr(e);let c=0,l=0;for(const[u,f]of o.entries()){if(ke(r.signal),!f||typeof f!="object"||Array.isArray(f))throw new M.ReportBindingError(`$.datasets.${n.dataset}[${u}]`,"标签记录应为对象",u);const d={rowIndex:u,dataset:n.dataset},m=at(n,f,d);if(m!==void 0){const y=JSON.stringify([typeof m,m]);if(a.has(y))throw new M.ReportBindingError(`$.datasets.${n.dataset}[${u}].${n.rowKey}`,"业务主键重复;请先确认记录来源,避免重复打印标签",u,n.rowKey);a.add(y)}const g=ot(n,f,d);if(c+=g*e.pages.length,l+=g*i,c>s)throw new M.PaginatePageLimitError(s,c);if(l>Je)throw new M.ReportBindingError("$.repeat",`标签组件总量(含网格行、槽位及嵌套组件)超过安全预算 ${Je},请分批生成`,u)}return o}function gr(e,t,r){if(!e.binding)return e;const{binding:n,...o}=e,a=M.resolveComponentBinding(n,t.row,t);if(e.kind==="image"){if(!a)return;if(!M.isLabelImageData(a))throw new M.ReportBindingError(`${r}.binding`,"图片字段只接受 PNG/JPEG base64 data URL;业务 URL 应由宿主安全加载后转换",t.rowIndex,n.field);return{...o,imageData:a}}return e.kind==="barcode"||e.kind==="qrcode"?(delete o.imageData,{...o,code:{...o.code,value:a},fallbackText:a}):(delete o.lines,delete o.richParagraphs,{...o,text:a})}function hr(e,t,r){if(e.kind!=="text"||e.grid||e.richParagraphs?.length)return e;const n=e.style??{},o=E.resolveFontSize(n).fontSizePt,a=e.text??e.lines?.join(`
|
|
2
|
-
`)??"";if(a.length>16384)throw new M.ReportBindingError(r,"标签文本超过 16384 字符预算,请缩小字段内容",t.rowIndex);const s=t.wrapText(a,e.widthMm,{fontSizePt:o,bold:n.bold,italic:n.italic,fontFamily:n.fontFamily,letterSpacingPt:n.letterSpacing},t.options.measurer??L.heuristicMeasurer),i=s.length*o*E.resolveLineHeight(n)*25.4/72;if(i>e.heightMm+.05)throw new M.ReportBindingError(r,`标签文字需要约 ${i.toFixed(2)}mm 高,超出 ${e.heightMm}mm;请增大文本区域、减少内容或调整字号`,t.rowIndex,e.binding?.field);return{...e,lines:s}}function st(e,t,r){ke(t.options.signal);const n=gr(e,t,r);if(!n)return;let o=n.grid;return o&&(o={...o,cells:o.cells.map((a,s)=>a.map((i,c)=>i?.children?.length?{...i,children:i.children.flatMap((l,u)=>{const f=st(l,t,`${r}.grid.cells.${s}.${c}.children.${u}`);return f?[f]:[]})}:i))}),hr(o===n.grid?n:{...n,grid:o},t,r)}function pr(e,t,r,n,o,a){return{...e,components:e.components.flatMap((s,i)=>{const c=st(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,...a===void 0?{}:{rowKey:a},copyIndex:n,copyCount:o,templatePageIndex:t}}}}function*wr(e,t,r){const n=[];if(B.validateTemplateRepeat(e,n),n.length)throw new M.ReportBindingError(n[0].path,n[0].message);if(!e.repeat){for(const[i,c]of e.pages.entries())yield{page:c,pageIndex:i};return}const o=e.repeat,a=mr(e,t,r),s=dr();for(const[i,c]of a.entries()){const l={row:c,rowIndex:i,dataset:o.dataset,options:r,wrapText:s},u=ot(o,c,l),f=at(o,c,l);for(let d=0;d<u;d++)for(const[m,g]of e.pages.entries())ke(r.signal),yield{page:pr(g,m,l,d,u,f),pageIndex:m}}}const yr=Object.freeze({}),br=16;function vr(e){if(e===void 0)return yr;try{const t=Object.getPrototypeOf(e);if(t!==Object.prototype&&t!==null||Object.getOwnPropertySymbols(e).length)return;const r=Object.create(null);for(const n of Object.getOwnPropertyNames(e)){const o=Object.getOwnPropertyDescriptor(e,n);if(!o?.enumerable||o.get||o.set)return;const a=o.value;if(a!==null&&(typeof a=="object"||typeof a=="function"))return;r[n]=a}return r}catch{return}}function Mr(e,t){const r=Object.keys(t);return r.length===Object.keys(e).length&&r.every(n=>Object.prototype.hasOwnProperty.call(e,n)&&Object.is(e[n],t[n]))}function Sr(e){const t=[];return(r,n,o,a)=>{if(!Number.isInteger(r)||r<0||r>=br)return e(o,a);const s=vr(a);if(!s)return e(o,a);const i=t[r];if(i?.firstRow===n&&i.label===o&&Mr(i.style,s))return i.row;const c=e(o,a);return t[r]={firstRow:n,label:o,style:s,row:c},c}}function xr(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 re(e,t){const r=t.heightMm-(e.layout==="wide"?t.marginBottomMm:e.marginBottomMm??t.marginBottomMm);return e.components.reduce((n,o)=>o.kind!=="list"&&o.pageAnchor==="footer"?Math.min(n,o.topMm):n,r)}function Y(e){return e.components.reduce((t,r)=>r.kind!=="list"&&r.pageAnchor==="header"?Math.max(t,r.topMm+r.heightMm):t,0)}function it(e,t){let r=e.textMetrics.get(t);if(!r){const n=E.resolveFontSize(t).fontSizePt;r={measureOptions:{fontSizePt:n,fontFamily:t.fontFamily??E.DEFAULT_FONT_FAMILY,italic:t.italic,bold:t.bold,letterSpacingPt:t.letterSpacing},lineMm:n*(t.lineHeight??E.LINE_HEIGHT)*25.4/72},e.textMetrics.set(t,r)}return r}function Cr(e){if(e===null||typeof e=="string"||typeof e=="boolean"||typeof e=="number"&&Number.isFinite(e))return e}function Oe(e,t,r=[],n){const o=e.fontSizePt??E.DEFAULT_FONT_PT,a=e.paddingMm??1,s=e.columns.map(p=>p.align??p.style?.align??e.align??"auto"),i=e.columns.map((p,h)=>({...E.mergeComponentStyles({fontSize:o,verticalAlign:"middle"},p.style),align:s[h]==="auto"?"left":s[h]})),c=i.map((p,h)=>s[h]==="auto"?{left:p,center:{...p,align:"center"},right:{...p,align:"right"}}:void 0),l=e.columns.map((p,h)=>p.rules?.map(x=>{const O=c[h];if(O)return{left:E.mergeComponentStyles(O.left,x.style),center:E.mergeComponentStyles(O.center,x.style),right:E.mergeComponentStyles(O.right,x.style)};const $=E.mergeComponentStyles(i[h],x.style);return{left:$,center:$,right:$}})),u=e.columns.map(p=>M.resolveListHeaderStyle(e,p)),f=e.columns.map(p=>p.header);let d=e.rowHeightMm??0;for(let p=0;p<f.length;p++){const h=u[p],x=E.resolveFontSize(h).fontSizePt,O=L.wrapText(f[p],e.columns[p].widthMm-a*2,{fontSizePt:x,fontFamily:h.fontFamily??E.DEFAULT_FONT_FAMILY,italic:h.italic,bold:h.bold,letterSpacingPt:h.letterSpacing},t),$=x*(h.lineHeight??E.LINE_HEIGHT)*25.4/72;d=Math.max(d,Math.max(O.length,1)*$+a*2)}const m=f.map((p,h)=>({text:p,style:u[h]})),g=e.border===!1?{borderTop:!1,borderRight:!1,borderBottom:!1,borderLeft:!1}:{borderBottom:!0,borderLeft:!0,borderRight:!0,borderTop:!0},y=e.columns.map(p=>p.widthMm),w=Pr(sr(e,t),y,{cells:[m],colWidthsMm:y,rowHeightsMm:[d],paddingMm:a});return{fontSizePt:o,paddingMm:a,visuals:_.createColumnVisualResolvers(e.columns,r,n),visibility:e.columns.map(p=>p.visibleWhen?I.compileReportPredicate(p.visibleWhen):void 0),ruleReaders:e.columns.map(p=>p.rules?.map(h=>I.compileReportPredicate(h.when))),cellStyles:i,autoStyles:c,ruleStyles:l,textMetrics:new WeakMap,numberFormats:e.columns.map(p=>M.toExcelNumberFormat(p.format)),derivedFields:new Set(e.computed?.map(p=>p.field)),borderStyle:g,headerHeightMm:w.rowHeightsMm.reduce((p,h)=>p+h,0),headerGrid:w,colWidthsMm:y,columns:e.columns}}function Pr(e,t,r){if(!e)return r;if(!e.cells.length)throw new Error("自定义列表表头至少需要一行");const n=e.rowHeightsMm??e.cells.map(()=>r.rowHeightsMm[0]);if(n.length!==e.cells.length||n.some(o=>!Number.isFinite(o)||o<=0))throw new Error("自定义列表表头行高无效");return{...e,colWidthsMm:t,rowHeightsMm:n}}function Rr(e,t,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),(typeof e.value=="number"||e.value==null)&&r!==void 0&&(e.numberFormat=r)}function Q(e,t,r){const n=e.columns,o=e.tree?.rows.get(t);let a=e.rowHeightFloorMm;const s=new Array(n.length);for(let i=0;i<n.length;i++){const c=n[i],l=e.visibility[i]?.(t)!==!1,u=l?t[c.field]:null,f=e.autoStyles[i]?M.resolveListAutoAlignment(u,c.format,c.semanticRole,c.valueType):"left";let d=e.autoStyles[i]?.[f]??e.cellStyles[i];if(c.rules){for(let x=0;x<c.rules.length;x++)if(e.ruleReaders[i][x](t)){d=e.ruleStyles[i][x][f];break}}const m=c.format?M.formatValue(u,c.format):M.listCellText(u),g=Er(e,c,o);d=Tr(e,c,d,o);const y=it(e,d),w=L.wrapText(m,Math.max(1,c.widthMm-e.paddingMm*2-g),y.measureOptions,r);a=Math.max(a,w.length*y.lineMm+e.paddingMm*2);const p=Cr(u),h={text:m,style:d};u!=null&&e.visuals[i]?.apply(h,t),p!==void 0&&(h.value=p),Rr(h,c,e.numberFormats[i]),kr(h,c,e,o,g),e.derivedFields.has(c.field)&&(h.derived=!0,h.editable=!1),l||(h.editable=!1),s[i]=h}return{grid:{cells:[s],colWidthsMm:e.colWidthsMm,rowHeightsMm:[a],paddingMm:e.paddingMm},heightMm:a,...e.matrix?{meta:{matrix:{row:e.matrix.rows.get(t)}}}:{}}}function Er(e,t,r){return!r||t.field!==e.tree.list.tree.labelField?0:M.listTreeIndent(e.tree.list,t,r,e.paddingMm)}function Tr(e,t,r,n){return!n||t.field!==e.tree.list.tree.labelField||r.align==="left"?r:{...r,align:"left"}}function kr(e,t,r,n,o=0){n&&(o&&(e.indentMm=o),M.applyListTreeMetadata(e,t,n,r.tree.list))}function ct(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*lt(e,t,r=0){const n=t[r];if(!n){for(const a of e)yield{kind:"row",row:a};return}const o=new Map;for(const a of e){const s=ct(a[n.field]),i=o.get(s);i?i.push(a):o.set(s,[a])}for(const a of o.values())yield{kind:"groupHeader",label:(n.headerTemplate??"{value}").replace(/\{value\}/g,M.listCellText(a[0][n.field])),firstRow:a[0],group:n,depth:r,rows:a},yield*lt(a,t,r+1),(n.subtotal?.length||n.aggregates?.length)&&(yield{kind:"subtotal",label:n.subtotalLabel??"小计",rows:a,group:n,depth:r}),yield{kind:"groupEnd",depth:r}}function ut(e,t,r,n=[]){const o=[...r.filter(a=>!n.some(s=>s.field===a)).map(a=>({field:a,op:"sum"})),...n];return new Map(o.map(a=>{const s=e.find(c=>c.field===a.field)?.format??{kind:"number",thousands:!0},i=I.aggregateRows(t,{...a,field:a.valueField??a.field});return[a.field,{text:M.formatValue(i,s),...i===null?{}:{value:i},...typeof i=="number"?{numberFormat:M.toExcelNumberFormat(s)}:{}}]}))}function dt(e,t){const r=e.findIndex(n=>t.includes(n.field));return r<0?1:r}function ne(e,t,r,n,o,a){const s=[],i=Math.max(0,Math.min(a,e.columns.length)),c=E.mergeComponentStyles({fontSize:e.fontSizePt},o);i&&s.push({text:r,colSpan:i,style:{bold:!0,...c}});for(let d=i;d<e.columns.length;d++){const m=e.columns[d],g=n.get(m.field),y=e.autoStyles[d]?.[M.resolveListAutoAlignment(g?.value,m.format,m.semanticRole,m.valueType)]??e.cellStyles[d];s.push({...g,text:g?.text??"",style:E.mergeComponentStyles(y,o)})}const l={text:r,colSpan:e.columns.length,style:{bold:!0,...c}},u=i?[s]:[[l],s],f=u.map(d=>Or(e,d,t));return{grid:{cells:u,colWidthsMm:e.colWidthsMm,rowHeightsMm:f,paddingMm:e.paddingMm},heightMm:f.reduce((d,m)=>d+m,0)}}function Or(e,t,r){let n=e.rowHeightFloorMm,o=0;for(const a of t){let s=0;const i=o+(a.colSpan??1);for(;o<i;o++)s+=e.colWidthsMm[o]??0;const c=it(e,a.style),l=L.wrapText(a.text??"",s-e.paddingMm*2,c.measureOptions,r);n=Math.max(n,l.length*c.lineMm+e.paddingMm*2)}return n}function Ir(e,t,r){const{templatePage:n,current:o,warnings:a,nextId:s,pushCurrent:i}=r,c=()=>re(n,o),l=Math.max(o.marginTopMm,Y(n)),u=n.layout==="wide"?Y(n):l,f={id:r.tableId,columnKeys:e.columns.map(C=>C.field),...e.layout===void 0?{}:{layout:e.layout},...e.title===void 0?{}:{title:e.title}},d=new Map,m=new Map,g={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||t.matrix?{meta:{...e.meta,...t.matrix?{matrix:t.matrix.header}:{}}}:{}},y=C=>o.components.push({...g,topMm:C});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&&(y(w),w+=t.headerHeightMm+r.mmPerRow);function p(){const C=Math.max(r.flow||n.layout==="wide"?0:e.topMm,u);return(e.header!==!1&&e.headerEveryPage!==!1?C+t.headerHeightMm:u)+[...m.values()].reduce((P,R)=>P+R.heightMm,0)}function h(){const C=n.layout==="wide"?0:o.marginBottomMm;return Math.min(n.heightMm-C,re(n,o))-p()}function x(C){if(w+C<=c())return;i(),o.components=[],o.heightMm=n.heightMm,n.layout==="wide"&&(o.marginTopMm=0,o.marginBottomMm=0);const v=Math.max(r.flow||n.layout==="wide"?0:e.topMm,u);e.header!==!1&&e.headerEveryPage!==!1?(y(v),w=v+t.headerHeightMm):w=u;for(const P of m.values())$(P,"listgr","group-header")}function O(C,v,P,R){const k=h();if(r.flow&&C.heightMm>k+.001)throw new Error(`流式列表 ${e.id??e.dataset} 的单行高度超出单页可用范围`);C.heightMm>k&&a.push(`列表 ${e.id??e.dataset} 行高 ${C.heightMm.toFixed(2)}mm 超出单页可用高度 ${k.toFixed(2)}mm,预览与打印可能截断内容`),x(C.heightMm),$(C,v,P,R)}function $(C,v,P,R){const k=C.table?.id??f.id,S=P==="header"?-1:d.get(k)??0;P!=="header"&&d.set(k,S+C.grid.cells.length),o.components.push({kind:"rect",leftMm:e.leftMm,topMm:w,widthMm:e.widthMm,heightMm:C.heightMm,grid:C.grid,nid:s(v),table:{...f,...C.table,role:P,rowIndex:S,...R?{source:R}:{}},style:t.borderStyle,...e.meta||C.meta?{meta:{...e.meta,...C.meta}}:{}}),w+=C.heightMm}function j(C){C<=h()&&x(C)}return{keepTogether:j,placeGridRow:O,setGroupHeader:(C,v)=>{v?m.set(C,v):m.delete(C)},bottom:()=>w}}function $r(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 n=e.revisionField?t[e.revisionField]:void 0,o=e.sourceTokenField?t[e.sourceTokenField]:void 0;if(n!==void 0&&typeof n!="string"&&!(typeof n=="number"&&Number.isFinite(n)))throw new Error("业务修订号应为字符串或有限数字");if(o!==void 0&&typeof o!="string")throw new Error("来源令牌应为字符串");return{datasetId:e.dataset,rowKey:r,...n===void 0?{}:{revision:n},...o===void 0?{}:{sourceToken:o}}}function ce(e,t){const r=new Map;if(!e.rowKey)return r;const n=new Set;for(const o of t){const a=$r(e,o),s=JSON.stringify(a.rowKey);if(n.has(s))throw new Error(`数据集 ${e.dataset} 的业务主键重复:${String(a.rowKey)}`);n.add(s),r.set(o,a)}return r}function Fr(e,t,r,n,o){if(!e.grandTotal)return;const a=typeof e.grandTotal=="object"?e.grandTotal:void 0,s=le(e)[0],i=a?.fields??s?.subtotal??[],c=a?.aggregates??s?.aggregates??[];if(i.length===0&&c.length===0){n.warnings.push(`列表 ${e.id??""} 配置了 grandTotal 但未提供合计字段(groupBy.subtotal 或 grandTotal.fields)`);return}const l=ne(r,n.measurer,a?.label??"合计",ut(e.columns,t,i,c),a?.style??{},dt(e.columns,[...i,...c.map(u=>u.field)]));o.placeGridRow(l,"listgt","grand-total")}function H(e){if(e?.aborted){const t=new Error("报表排版已取消");throw t.name="AbortError",t}}function le(e){const t=e.groups??(e.groupBy?[e.groupBy]:[]);if(t.length>16)throw new Error("列表最多支持 16 级分组");return t}function Ie(e){const t=rt(e),r=t.columns.reduce((o,a)=>o+a.widthMm,0),n=r>t.widthMm?t.widthMm/r:1;return n===1?t:{...t,columns:t.columns.map(o=>({...o,widthMm:o.widthMm*n}))}}function Ar(e,t,r){const n=e.detail;if(!n)return;const o=new Set;for(const l of t){const u=Me(l[n.parentKey]);if(o.has(u))throw new Error("主从明细的主表关联键重复");o.add(u)}const a=r.datasets[n.dataset]??[],s=new Map,i=[];for(const l of a){const u=l[n.foreignKey];if(!ft(u)&&n.unmatched==="ignore")continue;const f=Me(u);if(!o.has(f)){if(n.unmatched!=="ignore")throw new Error(`明细数据集 ${n.dataset} 存在未关联的业务键`);continue}const d=s.get(f);d?d.push(l):s.set(f,[l]),i.push(l)}const c=Ie({...e,id:`${e.id??e.dataset}:detail`,dataset:n.dataset,rowKey:n.rowKey,revisionField:n.revisionField,sourceTokenField:n.sourceTokenField,computed:void 0,columns:n.columns,headerGrid:void 0,rowHeightMm:n.rowHeightMm??e.rowHeightMm,detail:void 0});return{list:c,inter:{...Oe(c,r.measurer,i,r.signal),rowHeightFloorMm:c.rowHeightMm??0},rows:s,sources:ce(c,i)}}function ft(e){return typeof e=="string"&&!!e.trim()||typeof e=="number"&&Number.isFinite(e)}function Me(e){if(!ft(e))throw new Error("主从关联键必须是非空字符串或有限数字");return ct(e)}function*Lr(e,t,r,n,o){if(!r)return;const a=r.rows.get(Me(t[e.detail.parentKey]))??[];if(!a.length)return;const s={id:`${n.tableId}:detail`,columnKeys:r.list.columns.map(i=>i.field),title:e.detail.label};e.detail.label&&o.placeGridRow({...ne(r.inter,n.measurer,e.detail.label,new Map,{},r.list.columns.length),table:s},"listdl","group-header"),e.detail.header!==!1&&o.placeGridRow({grid:r.inter.headerGrid,heightMm:r.inter.headerHeightMm,table:s},"listdh","header"),yield*n.takePages();for(const i of a)H(n.signal),o.placeGridRow({...Q(r.inter,i,n.measurer),table:s},"listdr","body",r.sources.get(i)),yield*n.takePages()}function mt(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("树形布局需要可见的标签列");_.validateTreeComputed(e.tree,e.computed)}function Nr(e,t,r){mt(e);const n=_.createTreeTable(t,e.tree,{signal:r.signal,computed:e.computed?.length?{fields:e.computed,formula:r.formula}:void 0}),o={...e,rowKey:e.tree.idField},a=ce(o,n.entries.map(c=>c.original)),s=new Map,i=new WeakMap;for(const c of n.entries)s.set(c.row,a.get(c.original)),i.set(c.row,c);return{list:o,rows:n.rows,sources:s,treeRows:i,totalRows:n.leaves}}function jr(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 gt(e,t,r){const n=r.prepared.get(e);if(n)return n;const o=jr(e,t);if(o)return r.prepared.set(e,o),o;if(e.tree){const c=Nr(e,t,r);return r.prepared.set(e,c),c}const{rows:a,originals:s}=tt(e,t,r.datasets,r),i=ar(e,a);if(!e.matrix){const c=ce(e,s?a.map(l=>s.get(l)):a);i.sources=s?new Map(a.map(l=>[l,c.get(s.get(l))])):c}return r.prepared.set(e,i),i}function Kr(e,t,r,n){if(!n.flow)return;const{current:o,templatePage:a}=n,s=Math.max(o.marginTopMm,Y(a)),i=Math.max(n.startTop??e.topMm,s),c=(e.header===!1?0:t.headerHeightMm)+(r[0]?Q(t,r[0],n.measurer).heightMm:0);i+c<=re(a,o)+.001||i<=s+.001||(n.pushCurrent(),o.components=[],o.heightMm=a.heightMm,a.layout==="wide"&&(o.marginTopMm=0,o.marginBottomMm=0),n.startTop=Math.max(o.marginTopMm,Y(a)))}function*Dr(e,t,r){const n=gt(e,t,r),o=n.rows;e=n.list,e.layout==="wide"&&(r.current.widthMm=Math.max(r.current.widthMm,e.leftMm+e.widthMm+r.current.marginRightMm));const a=n.sources??ce(e,o),s=Ie(e),i=le(s),c={...Oe(s,r.measurer,o,r.signal),rowHeightFloorMm:s.rowHeightMm??0,matrix:n.matrix,...n.treeRows?{tree:{list:s,rows:n.treeRows}}:{}};Kr(s,c,o,r);const l=Ir(s,c,r),u=Ar(s,o,r),f=Sr((m,g)=>ne(c,r.measurer,m,new Map,g??{},s.columns.length));let d;for(const m of lt(o,i)){if(H(r.signal),m.kind==="row")l.placeGridRow(d??Q(c,m.row,r.measurer),"listr",nr(n.matrix,m.row),a.get(m.row)),d=void 0,yield*r.takePages(),yield*Lr(s,m.row,u,r,l);else if(m.kind==="groupHeader"){const g=f(m.depth,m.firstRow,m.label,m.group.headerStyle);if(m.group.keepWithNext!==!1){d??=Q(c,m.firstRow,r.measurer);let y=0;for(let w=m.depth+1;w<i.length;w++){const p=i[w],h=(p.headerTemplate??"{value}").replace(/\{value\}/g,M.listCellText(m.firstRow[p.field]));y+=f(w,m.firstRow,h,p.headerStyle).heightMm}l.keepTogether(g.heightMm+y+d.heightMm)}l.placeGridRow(g,"listg","group-header"),m.group.repeatHeader&&l.setGroupHeader(m.depth,g)}else if(m.kind==="subtotal"){const g=m.group.subtotal??[],y=m.group.aggregates??[],w=ne(c,r.measurer,m.label,ut(s.columns,m.rows,g,y),m.group.subtotalStyle??{},dt(s.columns,[...g,...y.map(p=>p.field)]));l.placeGridRow(w,"listst","subtotal")}else l.setGroupHeader(m.depth);yield*r.takePages()}Fr(s,n.totalRows??o,c,r,l),r.finished?.(l.bottom()),yield*r.takePages()}function ue(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 de(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(n=>({...n,...n.text===void 0?{}:{text:t(n.text)}}))}))}:{},...e.grid?{grid:{...e.grid,cells:e.grid.cells.map(r=>r.map(n=>n?{...n,...n.text===void 0?{}:{text:t(n.text)},...n.children?{children:n.children.map(o=>de(o,t))}:{}}:null))}}:{}}}function Hr(e){let t=!1;for(const r of e.pages)for(const n of r.components)ue(n)&&de(n,o=>(o.includes("{totalPages}")&&(t=!0),o));return t}function Br(e,t,r,n,o,a){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(n));return a===void 0?l:l.replace(/\{totalPages\}/g,String(a))};for(const c of r)s.components.push(de(c,i));if(e.layout==="wide"){const c=s.components.reduce((l,u)=>Math.max(l,u.topMm+u.heightMm),0);s.marginBottomMm=o?e.marginBottomMm??0:0,s.pageHeightMm=Math.max(1,c+s.marginBottomMm)}return s}function $e(e){return e.cells.reduce((t,r)=>t+r.reduce((n,o)=>n+(o?1+(o.children?.reduce((a,s)=>a+ht(s),0)??0):0),0),0)}function ht(e){return e.grid?$e(e.grid):0}function fe(e){for(const t of["maxPages","maxCells","knownTotalPages"])if(e[t]!==void 0&&(!Number.isSafeInteger(e[t])||e[t]<1))throw new RangeError(`${t} 应为正安全整数`);M.validateChartComponentLimit(e.maxChartComponents)}function Vr(e,t){const r=gt(e,t.datasets[e.dataset]??[],t),n=Ie(r.list),o={...Oe(n,t.measurer,r.rows,t.signal),rowHeightFloorMm:n.rowHeightMm??0};return(n.header===!1?0:o.headerHeightMm)+r.rows.reduce((a,s)=>a+Q(o,s,t.measurer).heightMm,0)}function*Gr(e){const{templatePage:t,current:r}=e,n=new Map(t.components.map((a,s)=>[a,s])),o=(a,s,i)=>{const c=e.datasets[a.dataset];return Array.isArray(c)||e.warnings.push(`数据集 ${a.dataset} 未提供数据,列表 ${a.id??""} 输出为空`),Dr(a,Array.isArray(c)?c:[],{...e,tableId:`${e.tableId}:${n.get(a)}`,startTop:s,finished:i,flow:!!t.flow})};if(t.flow){yield*cr({page:t,active:()=>H(e.signal),top:()=>Math.max(r.marginTopMm,Y(t)),bottom:()=>re(t,r),append:a=>{r.components.push(...e.resolveChart(a))},nextPage:()=>{e.pushCurrent(),r.components=[],r.heightMm=t.heightMm,t.layout==="wide"&&(r.marginTopMm=0,r.marginBottomMm=0)},takePages:e.takePages,height:a=>Vr(a,e),list:o});return}for(const a of t.components)ue(a)||(a.kind==="list"?yield*o(a):r.components.push(...e.resolveChart(a)))}function*Z(e,t,r,n,o,a=new WeakMap,s){let i=0,c=0,l=0;const u=Qt(r.measurer??L.heuristicMeasurer),f=M.createChartResolver(t,r.signal,r.maxChartComponents),d=m=>`${m}_${(++i).toString(36)}`;for(const{pageIndex:m,page:g}of wr(e,t,r)){H(r.signal);const y=xr(g),w=g.components.filter(ue);let p=[];const h=(O=!1)=>{if(H(r.signal),r.maxPages!==void 0&&c>=r.maxPages)throw new M.PaginatePageLimitError(r.maxPages,c+1);if(r.maxCells!==void 0&&(l+=[...y.components,...w].reduce(($,j)=>$+ht(j),0),l>r.maxCells))throw new M.PaginateCellLimitError(r.maxCells,l);p.push(Br(g,y,w,++c,O,o))},x=()=>{const O=p;return p=[],O};yield*Gr({templatePage:g,current:y,warnings:n,nextId:d,pushCurrent:h,takePages:x,datasets:t,resolveChart:f,signal:r.signal,formula:r.formula,prepared:a,measurer:u,mmPerRow:r.mmPerRow??0,tableId:`table:${m}`}),h(!0),yield*x()}s&&(s.chartComponents=f.used())}function Wr(e,t,r={}){fe(r);let n=0;for(const o of Z(e,t,{...r,onWarning:void 0},[]))n++;return n}function*_r(e,t,r={}){yield*zr(e,t,r)}function*zr(e,t,r,n){fe(r);const o=Hr(e),a=new WeakMap;let s=r.knownTotalPages;if(o&&s===void 0){s=0;for(const l of Z(e,t,r,[],void 0,a))s++}const i=[];let c=0;for(const l of Z(e,t,r,i,s,a,n)){for(;c<i.length;c++)r.onWarning?.(i[c]);yield l}}function Fe(e,t,r={}){const n=typeof r=="number"?{mmPerRow:r}:r;fe(n);const o=[],a={chartComponents:0},s=[...Z(e,t,n,o,n.knownTotalPages,void 0,a)];return wt(e,n,s,o,a)}async function pt(e,t,r={}){fe(r),H(r.signal);const n=[],o=[],a={chartComponents:0};let s=performance.now(),i=0;for(const c of Z(e,t,r,n,r.knownTotalPages,void 0,a))o.push(c),(++i>=8||performance.now()-s>=8)&&(await new Promise(l=>setTimeout(l,0)),H(r.signal),s=performance.now(),i=0);return H(r.signal),wt(e,r,o,n,a)}function wt(e,t,r,n,o){for(const a of r)a.components=a.components.map(s=>ue(s)?de(s,i=>i.replace(/\{totalPages\}/g,String(r.length))):s);return n.forEach(a=>t.onWarning?.(a)),{plan:{schemaVersion:E.RENDER_PLAN_SCHEMA_VERSION,...Te(e)?{requiresRecalculation:!0}:{},pages:r},warnings:n,...o}}function Jr(e){const t=e.columns.find(a=>!a.hidden)?.field;if(!t)return{groups:0,total:0};const r=le(e),n=(a=[],s=[])=>a.includes(t)||s.some(i=>i.field===t),o=typeof e.grandTotal=="object"?e.grandTotal:void 0;return{groups:r.filter(a=>n(a.subtotal,a.aggregates)).length,total:Number(n(o?.fields??r[0]?.subtotal,o?.aggregates??r[0]?.aggregates))}}function qr(e,t,r){mt(e);const n=_.flattenTreeInput(t[e.dataset]??[],e.tree,r),o=e.columns.filter(s=>!s.hidden).length,a=e.header===!1?0:e.headerGrid?$e(e.headerGrid):o;return n.length*o+a+ +!!e.grandTotal*2*o}function Ur(e,t,r={}){if(e.tree)return qr(e,t,r.signal);if(e.matrix){const{rows:c}=tt(e,t[e.dataset]??[],t,r),l=Qe.estimateMatrixTable(c,e.matrix);return l.cells+(e.header===!1?0:l.columnCount*(e.matrix.hierarchy?e.matrix.columnFields.length+1:1))}const n=t[e.dataset]?.length??0,o=e.columns.filter(c=>!c.hidden).length,a=le(e).length,s=Jr(e);let i=(n*(1+2*a+s.groups)+ +!!e.grandTotal*(1+s.total))*o;if(i+=e.header===!1?0:e.headerGrid?$e(e.headerGrid):o,e.cardinality==="record"&&n===0&&(i+=o),e.detail){const c=t[e.detail.dataset]?.length??0,l=e.detail.columns.filter(u=>!u.hidden).length;i+=(c+n*(+(e.detail.header!==!1)+ +!!e.detail.label))*l}if(!Number.isSafeInteger(i))throw new RangeError("报表单元格估算超出安全整数预算");return i}class yt extends Error{constructor(t){super(t.map(r=>r.message).join(";")),this.issues=t,this.name="ReportValidationError"}}function qe(e,t,r){if(!Number.isSafeInteger(e)||e<1||e>r)throw new Error(`校验 ${t} 超出预算`);return e}function Xr(e){if(e.aggregates&&e.scope!=="dataset")throw new Error("仅数据集规则允许汇总");if(e.aggregates&&(!Array.isArray(e.aggregates)||e.aggregates.length>64))throw new Error("校验汇总最多 64 项");const t=new Set;for(const r of e.aggregates??[]){if(I.computationFieldName(r.field),t.has(r.field))throw new Error("校验汇总字段重复");t.add(r.field),r.valueField!==void 0&&I.computationFieldName(r.valueField),r.weightField!==void 0&&I.computationFieldName(r.weightField),I.aggregateRows([],{...r,field:r.valueField??r.field})}}function bt(e){if(!Array.isArray(e)||e.length>256||Object.keys(e).length!==e.length)throw new Error("校验规则最多 256 条且不允许空位");const t=new Set;return e.map(r=>{if(!r||typeof r!="object")throw new Error("校验规则应为声明式对象");if(I.computationFieldName(r.id),t.has(r.id))throw new Error("校验规则 id 重复");if(t.add(r.id),r.field!==void 0&&I.computationFieldName(r.field),r.dataset!==void 0&&I.computationFieldName(r.dataset),typeof r.message!="string"||!r.message.trim()||r.message.length>2048)throw new Error("校验规则需要有界提示文案");if(r.severity!==void 0&&!["error","warning"].includes(r.severity))throw new Error("未知校验严重程度");if(r.scope!==void 0&&!["row","dataset"].includes(r.scope))throw new Error("未知校验范围");Xr(r);const n={nodes:0},o=I.compileReportPredicate(r.assert,n),a=r.when?I.compileReportPredicate(r.when,n):void 0;return{rule:r,assert:o,when:a,checks:n.nodes}})}function Ue(e){if(e?.aborted){const t=new Error("报表校验已取消");throw t.name="AbortError",t}}function Yr(e,t,r,n){const o=n&&Object.prototype.hasOwnProperty.call(t,n)?t[n]:void 0;if(o!==void 0&&typeof o!="string"&&!(typeof o=="number"&&Number.isFinite(o)))throw new Error("校验定位需要稳定的文本或数值业务键");return{ruleId:e.id,rowIndex:r,...o===void 0?{}:{rowKey:o},field:e.field,severity:e.severity??"error",message:e.message}}function Qr(e,t){const r=t.computed?.length?{fields:t.computed,formula:t.formula,signal:t.signal}:void 0;if(t.tree){const o=_.createTreeTable(e,t.tree,{signal:t.signal,computed:r});if(o.rows.length>1e5)throw new Error("校验展开后数据最多 100000 行");return{rows:o.rows,summaryRows:o.leaves,rowKey:t.tree.idField}}const n=r?I.computeDataset(e,r).rows:e;return{rows:n,summaryRows:n,rowKey:t.rowKey}}function Zr(e,t){const r=new Set;e.forEach(n=>{if(!n||typeof n!="object"||Array.isArray(n))throw new Error("校验数据行应为对象");if(!t)return;const o=Object.prototype.hasOwnProperty.call(n,t)?n[t]:void 0;if(!(typeof o=="string"&&o.trim())&&!(typeof o=="number"&&Number.isFinite(o)))throw new Error("校验定位需要稳定业务键");if(r.has(o))throw new Error("校验业务键重复");r.add(o)})}function en(e,t){return vt(e,t,{checks:0})}function vt(e,t,r){if(!Array.isArray(e)||e.length>1e5)throw new Error("校验数据最多 100000 行");Ue(t.signal);const n=qe(t.maxChecks??2e6,"maxChecks",1e7),o=qe(t.maxIssues??1e3,"maxIssues",1e4);t.rowKey!==void 0&&I.computationFieldName(t.rowKey);const a=Qr(e,t),{rows:s,summaryRows:i,rowKey:c}=a;Zr(s,c);const l=bt(t.rules),u=l.reduce((d,m)=>d+(m.rule.scope==="dataset"?m.checks+i.length*(m.rule.aggregates?.length??0):s.length*m.checks),0);if(r.checks+=u,r.checks>n)throw new Error("整批校验超出 maxChecks 预算");const f=[];for(const d of l)(d.rule.scope==="dataset"?[Object.fromEntries((d.rule.aggregates??[]).map(g=>[g.field,I.aggregateRows(i,{...g,field:g.valueField??g.field})]))]:s).forEach((g,y)=>{if(Ue(t.signal),!g||typeof g!="object"||Array.isArray(g))throw new Error("校验数据行应为对象");if(!(d.when&&!d.when(g)||d.assert(g))){if(f.length>=o)throw new Error("校验问题超出 maxIssues 预算,请缩小范围");f.push(Yr(d.rule,g,d.rule.scope==="dataset"?void 0:y,d.rule.scope==="dataset"?void 0:c))}});return f}function Mt(e,t="allow"){if(!["allow","block"].includes(t))throw new Error("未知校验警告策略");if(!Array.isArray(e)||e.length>1e4||e.some(r=>!r||!["error","warning"].includes(r.severity)||typeof r.ruleId!="string"||!r.ruleId.trim()||typeof r.message!="string"||!r.message.trim()))throw new Error("校验问题结构无效");if(e.some(r=>r.severity==="error"||t==="block"))throw new yt(e)}function Xe(e,t,r){const n=e.get(t);if(n&&JSON.stringify(n)!==JSON.stringify(r))throw new Error("同一数据集的校验计算/业务键存在歧义,请统一绑定");e.set(t,r)}function tn(e,t,r,n=[]){bt(t.rules);const o=[],a={checks:0};for(const[i,c]of e.entries()){const l=new Map;for(const u of c.template.pages)for(const f of u.components)f.kind==="list"&&(Xe(l,f.dataset,{rowKey:f.tree?.idField??f.rowKey,computed:f.computed,tree:f.tree}),f.detail&&Xe(l,f.detail.dataset,{rowKey:f.detail.rowKey}));for(const[u,f]of l){const d=t.rules.filter(m=>!m.dataset||m.dataset===u);if(d.length&&(o.push(...vt(c.datasets[u]??[],{...t,rules:d,...f,formula:n[i],signal:r},a).map(m=>({...m,dataset:u,sourceScope:c.sourceScope}))),o.length>(t.maxIssues??1e3)))throw new Error("整批候选校验问题超出 maxIssues 预算")}}const s=new Set(e.flatMap(i=>i.template.pages.flatMap(c=>c.components.flatMap(l=>l.kind==="list"?[l.dataset,...l.detail?[l.detail.dataset]:[]]:[]))));if(t.rules.some(i=>i.dataset&&!s.has(i.dataset)))throw new Error("校验目标数据集不存在");return o}function St(e){return!e||typeof e!="object"?!1:[e.pageIndex,e.componentIndex,e.rowIndex,e.columnIndex].every(t=>Number.isInteger(t)&&t>=0)}function xt(e,t,r){const n=e.grid;if(!n)return null;const o=n.cells[t];if(!o)return null;const s=E.resolveGridLayout(n,e.widthMm,e.heightMm).cells.filter(c=>c.ri===t).findIndex(c=>c.ci===r),i=o[s];return i?{cell:i,sourceColumnIndex:s}:null}function rn(e){return e.value!==void 0?e.value:e.rawText??e.text??null}function nn(e,t){return e.valueType?e.valueType:typeof t=="number"?"number":typeof t=="boolean"?"boolean":t===null&&e.numberFormat&&/[0#?]/.test(e.numberFormat)?"number":"text"}function on(e,t){if(e.derived)return"derived";if(e.editable===!1)return"cell";if(e.formula!==void 0)return"formula";if(e.children?.length||e.richParagraphs?.length)return"complex";if(t.table&&t.table.role!=="body"&&e.editable!==!0)return"structure"}function an(e,t){const r=e.table;if(r)return{id:r.id,rowIndex:r.rowIndex+t.rowIndex,role:r.role,columnKey:r.columnKeys[t.columnIndex]}}function sn(e,t,r){if(e.derived)return;if(e.source)return{...e.source};const n=t.table?.source,o=t.table?.columnKeys[r.columnIndex];if(!(!n||n.rowKey===void 0||o===void 0))return{...n,rowKey:n.rowKey,field:o}}function Se(e,t,r){const n=rn(r),o=on(r,e);return{address:{...t},cell:r,component:e,value:n,valueType:nn(r,n),table:an(e,t),source:sn(r,e,t),editable:o===void 0,readOnlyReason:o}}function me(e,t){if(!St(t))return null;const r=e.pages[t.pageIndex]?.components[t.componentIndex];if(!r)return null;const n=xt(r,t.rowIndex,t.columnIndex);return n?Se(r,t,n.cell):null}function Ct(e,t=!0){const r=new Map;function n(i){if(!i.grid)return;let c=r.get(i);if(!c){const l=E.resolveGridLayout(i.grid,i.widthMm,i.heightMm),u=new Map,f=new Map;for(const d of l.cells){const m=u.get(d.ri)??0;u.set(d.ri,m+1);const g=i.grid.cells[d.ri]?.[m];g&&f.set(`${d.ri}:${d.ci}`,g)}c={layout:t?l:void 0,cells:f},r.set(i,c)}return c}function o(i){if(!St(i))return null;const c=e.pages[i.pageIndex]?.components[i.componentIndex];if(!c)return null;const l=n(c)?.cells.get(`${i.rowIndex}:${i.columnIndex}`);return l?Se(c,i,l):null}function*a(i,c){const l=e.pages[i]?.components[c],u=l&&n(l);if(u)for(const f of s(l).cells){const d=u.cells.get(`${f.ri}:${f.ci}`);d&&(yield Se(l,{pageIndex:i,componentIndex:c,rowIndex:f.ri,columnIndex:f.ci},d))}}function s(i){const c=n(i);return c&&(c.layout??E.resolveGridLayout(i.grid,i.widthMm,i.heightMm))}return{resolve:o,entries:a,layout:s}}function V(e){return Ct(e,!1).resolve}class b extends Error{constructor(t){super(`Invalid report cell edit: ${t}`),this.code=t,this.name="ReportCellEditError"}}function cn(e,t){let r=e.trim();const n=t&&r.endsWith("%");if(n&&(r=r.slice(0,-1).trim()),/^[+-]?\d{1,3}(?:,\d{3})+(?:\.\d*)?(?:[eE][+-]?\d+)?$/.test(r)&&(r=r.replace(/,/g,"")),!/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/.test(r))throw new b("number");return Number(r)/(n?100:1)}function ln(e,t){if(e===null||typeof e=="string"&&e.trim()==="")return null;if(typeof e!="string"&&typeof e!="number")throw new b("number");const r=typeof e=="number"?e:cn(e,Ze.isExcelPercentageFormat(t.cell.numberFormat));if(!Number.isFinite(r)||Number.isInteger(r)&&!Number.isSafeInteger(r))throw new b("number");return r}function un(e){if(e===null||typeof e=="string"&&e.trim()==="")return null;if(typeof e=="boolean")return e;const t=String(e).trim().toLowerCase();if(["true","yes","是","1"].includes(t))return!0;if(["false","no","否","0"].includes(t))return!1;throw new b("boolean")}function Ae(e,t){return e.valueType==="number"?ln(t,e):e.valueType==="boolean"?un(t):t===null?null:String(t)}function dn(e,t){const r=t.cell.text,o=[["是","否"],["TRUE","FALSE"],["True","False"],["true","false"],["1","0"]].find(a=>a.includes(r??""));return o?o[e?0:1]:String(e)}function z(e,t){return t===null?"":typeof t=="boolean"?dn(t,e):typeof t=="number"?Ze.formatExcelNumber(t,e.cell.numberFormat):String(t)}function fn(e,t,r){const n=me(e,t);if(!n)throw new b("missing");return J(n,r)}function J(e,t){if(!e.editable)throw new b("readonly");const r=Ae(e,t);return{address:{...e.address},table:e.table,source:e.source,previousValue:e.value,previousText:e.cell.text??"",value:r,text:z(e,r)}}function mn(e,t){const r=e.table,n=t.table;return!r||!n||r.columnKey===void 0?!1:r.id===n.id&&r.rowIndex===n.rowIndex&&r.role===n.role&&r.columnKey===n.columnKey}function Pt(e,t,r){const n=e.grid,{rowIndex:o,columnIndex:a}=t.address,s=xt(e,o,a),i=[...n.cells],c=[...i[o]],l=z(t,r.value),u={...s.cell,value:r.value,text:l,rawText:l};return c[s.sourceColumnIndex]=u,i[o]=c,{...e,grid:{...n,cells:i}}}function gn(e,t){const r=e.table?.columnKeys,n=t.table?.columnKey;return r&&n!==void 0?r.flatMap((o,a)=>o===n?[a]:[]):[]}function hn(e,t,r,n,o,a){const s=t.table,i=o.table;if(!s||!i||s.id!==i.id||s.role!==i.role||!t.grid)return t;const c=i.rowIndex-s.rowIndex;if(c<0||c>=t.grid.cells.length)return t;let l=t;for(const u of gn(t,o)){const f=me(e,{pageIndex:r,componentIndex:n,rowIndex:c,columnIndex:u});f?.editable&&mn(o,f)&&(l=Pt(l,f,a))}return l}function pn(e,t,r,n,o,a){const s=o.address;return o.table?.columnKey!==void 0?hn(e,t,r,n,o,a):s.pageIndex===r&&s.componentIndex===n?Pt(t,o,a):t}function ge(e,t){const r=t.source;if(!r)return!1;const n=e.source;return!n||["sourceScope","datasetId","rowKey","field","revision","sourceToken"].some(o=>!Object.is(n[o],r[o]))}function wn(e,t){const r=me(e,t.address);if(!r)throw new b("missing");if(!r.editable)throw new b("readonly");if(ge(r,t))throw new b("conflict");if(!Object.is(r.value,t.previousValue)||(r.cell.text??"")!==t.previousText)throw new b("conflict");const n=Ae(r,t.value),o={...t,value:n,text:z(r,n)};if(Object.is(n,r.value)&&o.text===r.cell.text)return e;const a=e.pages.map((s,i)=>{const c=s.components.map((l,u)=>pn(e,l,i,u,r,o));return c.every((l,u)=>l===s.components[u])?s:{...s,components:c}});return{...e,pages:a}}function Rt(e){const t=[];for(const r of e.template.pages)for(const n of r.components)n.kind==="list"&&(t.push(n.tree?{...n,rowKey:n.tree.idField}:n),n.detail&&t.push({...n.detail,relation:{detail:n.detail,parentRows:e.datasets[n.dataset]??[]}}));return t}function q(e){return JSON.stringify([e.sourceScope,e.datasetId])}function oe(e){return JSON.stringify([e.sourceScope,e.datasetId,e.rowKey])}function Et(e){const t=new Map,r=new Set;return e.forEach((n,o)=>{for(const a of Rt(n)){if(!a.rowKey)continue;const s=a.relation,i=s?new Set(s.parentRows.map(c=>JSON.stringify(c[s.detail.parentKey]))):void 0;(n.datasets[a.dataset]??[]).forEach((c,l)=>{if(s&&!i.has(JSON.stringify(c[s.detail.foreignKey])))return;const u=c[a.rowKey];if(typeof u!="string"&&typeof u!="number")return;const f=`${o}:${a.dataset}:${l}:${a.rowKey}`;if(r.has(f))return;r.add(f);const d=oe({sourceScope:n.sourceScope,datasetId:a.dataset,rowKey:u}),m=t.get(d)??[];m.push({partIndex:o,dataset:a.dataset,rowIndex:l,row:c,binding:a}),t.set(d,m)})}}),n=>{const o=t.get(oe(n));if(!o?.length)throw new b("missing");if(new Set(o.map(a=>`${a.partIndex}:${a.dataset}`)).size!==o.length)throw new b("conflict");return o}}function Tt(e,t){const r=e.map(o=>({...o,datasets:{...o.datasets}})),n=new Map;for(const{row:o,field:a,value:s}of t){const i=r[o.partIndex],c=JSON.stringify([o.partIndex,o.dataset]);let l=n.get(c);l||(i.datasets[o.dataset]=[...i.datasets[o.dataset]],n.set(c,l=new Set));const u=i.datasets[o.dataset];l.has(o.rowIndex)||(u[o.rowIndex]={...u[o.rowIndex]},l.add(o.rowIndex));const f=u[o.rowIndex];Object.prototype.hasOwnProperty.call(f,a)?f[a]=s:Object.defineProperty(f,a,{value:s,enumerable:!0,writable:!0,configurable:!0})}for(const o of n.keys()){const[a,s]=JSON.parse(o);I.forkComputedDataset(e[a].datasets[s],r[a].datasets[s])}return r}function yn(e,t,r){const n=[],o=new Set;return e.forEach((a,s)=>{for(const i of Rt(a))t.has(q({sourceScope:a.sourceScope,datasetId:i.dataset}))&&(a.datasets[i.dataset]??[]).forEach((c,l)=>{const u={partIndex:s,dataset:i.dataset,rowIndex:l,row:c,binding:i};for(const[f,d]of[[i.revisionField,r.revision],[i.sourceTokenField,r.sourceToken]]){if(!f||d===void 0)continue;const m=`${s}:${i.dataset}:${l}:${f}`;o.has(m)||(o.add(m),n.push({row:u,field:f,value:d}))}})}),n}function kt(e,t,r){if(!r||r.revision===void 0&&r.sourceToken===void 0)return e;const n=new Set(t.edits.flatMap(o=>o.source?[q(o.source)]:[]));return Le(e,new Map([...n].map(o=>[o,r])))}function Le(e,t){if(!t.size)return e;function r(a){const s=a.datasetId&&t.get(q({...a,datasetId:a.datasetId}));return!s||(s.revision===void 0||Object.is(s.revision,a.revision))&&(s.sourceToken===void 0||s.sourceToken===a.sourceToken)?a:{...a,...s.revision!==void 0?{revision:s.revision}:{},...s.sourceToken!==void 0?{sourceToken:s.sourceToken}:{}}}function n(a){const s=a.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,u=i.grid?.cells.map(d=>{const m=d.map(g=>{if(!g)return g;const y=g.source?r(g.source):void 0,w=g.children?n(g.children):void 0;return y===g.source&&w===g.children?g:{...g,source:y,children:w}});return m.some((g,y)=>g!==d[y])?m:d}),f=i.grid&&u?.some((d,m)=>d!==i.grid.cells[m])?{...i.grid,cells:u}:i.grid;return l!==i.table||f!==i.grid?{...i,table:l,grid:f}:i});return s.some((i,c)=>i!==a[c])?s:a}const o=e.pages.map(a=>{const s=n(a.components);return s!==a.components?{...a,components:s}:a});return o.some((a,s)=>a!==e.pages[s])?{...e,pages:o}:e}function bn(e){return JSON.stringify([e.pageIndex,e.componentIndex,e.rowIndex,e.columnIndex])}function Ye(e){const t=e.table;return t?.columnKey!==void 0?JSON.stringify([t.id,t.role,t.rowIndex,t.columnKey]):bn(e.address)}function vn(e,t){if(!t.length)return e;const r=new Map(t.map(c=>[Ye(c),c])),n=new Set(t.flatMap(c=>c.table?[c.table.id]:[])),o=new Set(t.map(c=>`${c.address.pageIndex}:${c.address.componentIndex}`)),a=V(e);function s(c,l,u){const f=c.grid;if(!f||!o.has(`${l}:${u}`)&&!n.has(c.table?.id??""))return c;const d=new Map,m=new Map;for(const g of E.resolveGridLayout(f,c.widthMm,c.heightMm).cells){const y=m.get(g.ri)??0;m.set(g.ri,y+1);const w=a({pageIndex:l,componentIndex:u,rowIndex:g.ri,columnIndex:g.ci}),p=w&&r.get(Ye(w));if(!p||!w.editable)continue;const h=d.get(g.ri)??[...f.cells[g.ri]],x=z(w,p.value);Object.is(w.value,p.value)&&x===w.cell.text||(h[y]={...g.cell,value:p.value,text:x,rawText:x},d.set(g.ri,h))}return d.size?{...c,grid:{...f,cells:f.cells.map((g,y)=>d.get(y)??g)}}:c}const i=e.pages.map((c,l)=>{const u=c.components.map((f,d)=>s(f,l,d));return u.every((f,d)=>f===c.components[d])?c:{...c,components:u}});return i.every((c,l)=>c===e.pages[l])?e:{...e,pages:i}}function N(e){const t=e.source;if(t)return JSON.stringify([t.sourceScope,t.datasetId,t.rowKey,t.field]);const r=e.table;if(r?.columnKey!==void 0)return JSON.stringify([r.id,r.role,r.rowIndex,r.columnKey]);const n=e.address;return JSON.stringify([n.pageIndex,n.componentIndex,n.rowIndex,n.columnIndex])}function Mn(e,t,r){if(typeof r!="string"||!r.trim()||!Array.isArray(t))throw new b("missing");if(t.length>1e4)throw new b("limit");const n=new Set,o=V(e),a=t.map(({address:s,value:i})=>{const c=o(s);if(!c)throw new b("missing");const l=J(c,i),u=N(l);if(n.has(u))throw new b("duplicate");return n.add(u),l});return{requestId:r,edits:a}}function Sn(e,t){if(t.edits.length>1e4)throw new b("limit");const r=V(e),n=new Set,o=t.edits.map(a=>{const s=r(a.address);if(!s)throw new b("missing");const i=N(a);if(n.has(i))throw new b("duplicate");if(n.add(i),ge(s,a)||!Object.is(s.value,a.previousValue)||(s.cell.text??"")!==a.previousText)throw new b("conflict");return J(s,a.value)});return vn(e,o)}function xn(e){const t=new Map;for(const r of e){const n=N(r),o=t.get(n),a=o?{...r,previousValue:o.previousValue,previousText:o.previousText}:{...r};Object.is(a.previousValue,a.value)?t.delete(n):t.set(n,a)}return[...t.values()]}function Ot(e){const t=new Map,r=V(e);return e.pages.forEach((n,o)=>n.components.forEach((a,s)=>{if(!(!a.grid||a.table?.role!=="body"))for(let i=0;i<a.grid.cells.length;i++)for(let c=0;c<a.table.columnKeys.length;c++){const l=r({pageIndex:o,componentIndex:s,rowIndex:i,columnIndex:c});l?.source&&l.editable&&t.set(N(l),l)}})),t}function Cn(e,t,r){const n=Ot(e),o=V(e);return t.map(a=>{const s=a.source?n.get(N(a)):o(a.address);if(!s||N(s)!==N(a))throw new b("missing");return{address:{...s.address},value:a[r]}})}function Pn(e){return e.stamp.date!==void 0?new Date(e.stamp.date):e.stamp.length!==void 0?e.values:Object.fromEntries(e.stamp.keys.map((t,r)=>[t,e.values[r]]))}function*Rn(e,t){const r=new Map;for(const o of t)r.set(o.object,o),yield;const n=[{stamp:r.get(e),values:[],index:0}];for(;n.length;){const o=n[n.length-1];if(o.index===o.stamp.values.length){const a=Pn(o);if(n.pop(),!n.length)return a;n[n.length-1].values.push(a)}else{const a=o.stamp.values[o.index++];a!==null&&typeof a=="object"?n.push({stamp:r.get(a),values:[],index:0}):o.values.push(a)}yield}}function It(e,t){if(++e.nodes>1e6||t>128)throw new b("limit")}function ae(e,t){const r=Object.getOwnPropertyDescriptor(e,t);if(!r||r.get||r.set)throw new b("conflict");return r.value}function $t(e){if(Object.getOwnPropertyDescriptor(e,"toJSON"))throw new b("conflict");const t=Object.getPrototypeOf(e);if(Array.isArray(e)&&(t!==Array.prototype||Object.keys(e).length!==e.length))throw new b("conflict");if(!(e instanceof Date)&&!Array.isArray(e)&&t!==Object.prototype&&t!==null)throw new b("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 b("conflict");if(e instanceof Date||Array.isArray(e)&&!/^(0|[1-9]\d*)$/.test(r))throw new b("conflict")}}function En(e,t,r){const n=Object.getPrototypeOf(e);if(t&&n!==Array.prototype||!t&&!r&&n!==Object.prototype&&n!==null)throw new b("conflict");return n}function Tn(e){const t=Array.isArray(e),r=e instanceof Date,n=En(e,t,r),o=[],a=[];for(const s of Reflect.ownKeys(e)){if(t&&s==="length")continue;const i=Object.getOwnPropertyDescriptor(e,s);if(typeof s=="symbol"||s==="toJSON"||r||!i.enumerable||i.get||i.set)throw new b("conflict");if(t&&!/^(0|[1-9]\d*)$/.test(s))throw new b("conflict");o.push(s),a.push(i.value)}if(t&&o.length!==e.length)throw new b("conflict");return{object:e,prototype:n,keys:o,values:a,...r?{date:Date.prototype.getTime.call(e)}:{},...t?{length:e.length}:{}}}function Ne(e,t,r,n,o,a){if(It(n,o),typeof e=="function"||typeof e=="symbol")throw new b("conflict");if(e===null||typeof e!="object")return;if(r.has(e))throw new b("conflict");if(a?.has(e))return;a?.add(e),r.add(e);const s=Tn(e);t.push(s);for(const i of s.values)Ne(i,t,r,n,o+1,a);r.delete(e)}function kn(e){const{object:t,keys:r,values:n}=e;if($t(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 o=Object.keys(t);return o.length===r.length&&r.every((a,s)=>o[s]===a&&Object.is(ae(t,a),n[s]))}function On(e){return Ft(e)}function se(e){return Ft(e,new Set)}function Ft(e,t){const r=[];return Ne(e,r,new Set,{nodes:0},0,t),()=>{try{return r.every(kn)}catch{return!1}}}function ee(e,t,r,n=!1,o){if(It(t,r),n){if(typeof e=="function"||typeof e=="symbol")throw new b("conflict");e!==null&&typeof e=="object"&&$t(e)}if(e===null||typeof e!="object")return e;const a=o?.get(e);if(a)return a;if(e instanceof Date){const s=new Date(Date.prototype.getTime.call(e));return o?.set(e,s),s}if(Array.isArray(e)){const s=[];o?.set(e,s);for(let i=0;i<e.length;i++)s[i]=ee(ae(e,String(i)),t,r+1,n,o);return s}return In(e,t,r,n,o)}function In(e,t,r,n,o){if(!o)return Object.fromEntries(Object.keys(e).map(s=>[s,ee(ae(e,s),t,r+1,n)]));const a={};o.set(e,a);for(const s of Object.keys(e))Object.defineProperty(a,s,{value:ee(ae(e,s),t,r+1,n,o),enumerable:!0,writable:!0,configurable:!0});return a}function $n(e){return ee(e,{nodes:0},0,!0,new WeakMap)}function Fn(e){const t=[];return Ne(e,t,new Set,{nodes:0},0),Rn(e,t)}function An(e){const t=ee(e,{nodes:0},0);for(const r of t)for(const n of Object.values(r.datasets))I.registerComputedDataset(n);return t}async function Ln(e,t,r={}){return(await At(e,t,r)).plan}async function At(e,t,r={}){return pt(e,t,{...r,knownTotalPages:void 0})}function Nn(e){return e.computed||e.groupBy||e.groups||e.grandTotal||e.tree||e.matrix||e.detail||e.rowVisibleWhen||e.headerGrid?!1:e.columns.every(t=>!t.format&&!t.rules&&!t.visibleWhen&&!t.visual)}function jn(e,t){return e.length!==t.length||t.some(r=>r?.measurer||r?.formula||r?.mmPerRow||r?.knownTotalPages!==void 0)?!1:e.every(r=>!r.template.repeat&&r.template.pages.every(n=>!n.flow&&n.components.every(o=>o.kind==="list"?Nn(o):!o.binding&&!o.chartBinding&&!o.grid&&!o.table&&!o.richParagraphs)))}function Kn(e){const t=new Map;for(const r of e){if(!r.source||typeof r.value!="string"||typeof r.previousValue!="string"||r.previousText!==r.previousValue||![r.previousValue,r.value].every(a=>a.trim().length&&a.length<=16384&&!/[\r\n]/.test(a)))return null;const n=oe(r.source),o=t.get(n)??new Map;o.set(r.source.field,r),t.set(n,o)}return t}function je(e){return!e.source&&!e.formula&&!e.derived&&!e.richParagraphs&&!e.children&&!e.dataBar&&!e.numberFormat&&!e.colSpan&&!e.rowSpan&&!e.indentMm&&!e.style?.rotateDeg}function Dn(e){return e.pages.every(t=>t.components.every(r=>!r.grid||r.grid.cells.every(n=>n.every(o=>!!o&&je(o)))))}function Hn(e,t,r,n){if(!je(e)||e.value!==t.previousValue||e.text!==t.previousText)return!1;const o=r-n*2,a=e.style,s=E.resolveFontSize(a).fontSizePt;if(!Number.isFinite(o)||o<1||!Number.isFinite(s)||s<=0)return!1;const i={fontSizePt:s,fontFamily:a?.fontFamily??E.DEFAULT_FONT_FAMILY,italic:a?.italic,bold:a?.bold,letterSpacingPt:a?.letterSpacing};return L.wrapText(t.previousText,o,i,L.heuristicMeasurer).length===L.wrapText(t.value,o,i,L.heuristicMeasurer).length}function Bn(e,t){const r=e.colWidthsMm;if(!r||r.length!==e.cells[0].length||r.length!==t.table.columnKeys.length)return!1;const n=r.reduce((o,a)=>o+a,0);return Number.isFinite(n)&&Math.abs(n-t.widthMm)<=Math.max(1e-7,n*1e-10)}function Vn(e,t,r){const n=e.table?.source;if(e.table?.role!=="body"||n?.rowKey===void 0)return e;const o=t.get(oe({...n,rowKey:n.rowKey}));if(!o)return e;const a=e.grid;if(!a||a.cells.length!==1||!Bn(a,e)||e.style?.rotateDeg)return null;const s=a.cells[0],i=[...s];for(let c=0;c<s.length;c++){const l=s[c];if(!l||!je(l))return null;const u=o.get(e.table.columnKeys[c]);if(u){if(!Hn(l,u,a.colWidthsMm[c],a.paddingMm??.5))return null;i[c]={...l,value:u.value,text:u.value},r.add(u)}}return i.some((c,l)=>c!==s[l])?{...e,grid:{...a,cells:[i]}}:e}async function Gn(e,t,r){const n=Kn(t);if(!n||!t.length)return null;const o=new Set,a=[];let s=0;for(const c of e.pages){const l=[];for(const u of c.components){if(r?.aborted)return null;const f=Vn(u,n,o);if(!f)return null;l.push(f),++s%128===0&&await new Promise(d=>setTimeout(d,0))}a.push(l.some((u,f)=>u!==c.components[f])?{...c,components:l}:c)}if(o.size!==t.length)return null;const i={...e,pages:a};return B.validateRenderPlan(i).ok?i:null}function Wn(e,t,r){let n=jn(t,r),o=e,a;function s(c){if(o=c,a=void 0,!!n){if(!Dn(c)){n=!1;return}try{a=se(c)}catch{n=!1}}}s(e);async function i(c,l,u){if(!n||c!==o||!a?.())return null;const f=a,d=await Gn(c,l,u);return d&&f()?{plan:d,unchanged:f}:null}return{candidate:i,publish:s}}function _n(e,t){const r=t?void 0:se(e);let n,o;function a(){if(r&&!r()||o&&!o())throw new b("conflict")}return{get plan(){if(!n){a();const s=$n(e),i=se(s);n=s,o=i}return n},assertUnchanged:a}}const xe=new WeakMap;function zn(e){return xe.get(e)}function X(e){if(e?.aborted){const t=new Error("报表重算已取消");throw t.name="AbortError",t}}function Lt(e,t){return e[t]===void 0?"":e[t]}function Jn(e,t){if(t.edits.length>1e4)throw new b("limit");const r=V(e),n=new Set,o=[],a=t.edits.map(s=>{const i=r(s.address);if(!i?.source)throw new b("missing");const c=N(s);if(n.has(c))throw new b("duplicate");if(n.add(c),ge(i,s)||!Object.is(i.value,s.previousValue)||(i.cell.text??"")!==s.previousText)throw new b("conflict");return o.push(i),J(i,s.value)});return{batch:{requestId:t.requestId,edits:a},contexts:o}}function qn(e,t){const r=Et(e);return t.flatMap(n=>{if(!n.source)throw new b("missing");return r(n.source).map(o=>{if(!Object.is(Lt(o.row,n.source.field),n.previousValue))throw new b("conflict");if(o.binding.rowKey===n.source.field)throw new b("readonly");return{row:o,field:n.source.field,value:n.value}})})}function ye(e,t,r){const n={...e,value:t,source:{...e.source,...r?.revision===void 0?{}:{revision:r.revision},...r?.sourceToken===void 0?{}:{sourceToken:r.sourceToken}}};return n.cell={...e.cell,value:n.value,text:z(n,n.value)},n}function Un(e,t,r){if(!r||r.revision===void 0&&r.sourceToken===void 0)return[...e];const n=new Set(t.edits.flatMap(o=>o.source?[q(o.source)]:[]));return Tt(e,yn(e,n,r))}function Xn(e,t,r){const n=new Set(t.edits.map(o=>q(o.source)));for(const o of n)e.set(o,{...e.get(o),...r.revision!==void 0?{revision:r.revision}:{},...r.sourceToken!==void 0?{sourceToken:r.sourceToken}:{}});return n}function Yn(e,t){return Ke(e,t)}function Ke(e,t,r){let n=t.parts;const o=t.rebuild,a=[...t.validationFormulas??[]],s=r?Wn(e,n,r):void 0;let i=On(n),c=e,l;const u=new Map,f=new Map;function d(y){if(y!==c)throw new b("conflict");if(l)return l;if(!i?.())throw new b("conflict");return An(n)}async function m(y,w,p,h={}){X(h.signal),w={requestId:w.requestId,edits:w.edits.map(S=>({...S,address:{...S.address},source:S.source?{...S.source}:void 0,table:S.table?{...S.table}:void 0}))},p=p.map(S=>({...S,address:{...S.address},source:S.source?{...S.source}:void 0,table:S.table?{...S.table}:void 0,cell:{...S.cell}})),await new Promise(S=>setTimeout(S,0)),X(h.signal);const x=d(y),O=Tt(x,qn(x,w.edits)),$=await s?.candidate(y,w.edits,h.signal);X(h.signal);const j=Le($?.plan??await o(O,h.signal),f);X(h.signal);const K=_n(j,r!==void 0);let C=!1,v=[],P="allow",R=!1;function k(S){return R=!0,K.assertUnchanged(),v=Object.freeze(tn(O,S,h.signal,a).map(A=>Object.freeze({...A}))),K.assertUnchanged(),R=!1,P=S.warningPolicy??"allow",v}return h.validation&&k(h.validation),{get plan(){return K.plan},get validationIssues(){return v},validate:k,commit(S){if(X(h.signal),C||c!==y)throw new b("conflict");if($&&!$.unchanged())throw new b("conflict");if(K.assertUnchanged(),S?.conflicts?.length)throw new b("conflict");if(R)throw new Error("候选规则校验未完成,不能提交");Mt(v,P);const A=Un(O,w,S),G=kt(j,w,S);if(S){const D=Xn(f,w,S);for(const[W,U]of u)D.has(q(U.source))&&u.set(W,ye(U,U.value,S))}return p.forEach((D,W)=>u.set(N(D),ye(D,w.edits[W].value,S))),C=!0,l=A,n=void 0,i=void 0,c=G,s?.publish(c),xe.set(c,g),c}}}const g={get plan(){return c},async prepare(y,w,p){const h=Jn(y,w);return m(y,h.batch,h.contexts,p)},async prepareHistory(y,w,p,h,x){if(!h.trim()||w.length>1e4)throw new b("limit");const O=d(y),$=Et(O),j=Ot(y),K=new Set,v=w.map(k=>{if(!k.source)throw new b("missing");const S=N(k);if(K.has(S))throw new b("duplicate");K.add(S);const A=j.get(S)??u.get(S);if(!A?.source)throw new b("missing");const G=$(A.source)[0];return ye(A,Lt(G.row,A.source.field))}).map((k,S)=>({context:k,edit:J(k,w[S][p])})).filter(({edit:k})=>!Object.is(k.previousValue,k.value)),P={requestId:h,edits:v.map(({edit:k})=>k)},R=v.map(({context:k})=>k);return{batch:P,contexts:R,prepared:await m(y,P,R,x)}}};return xe.set(e,g),g}function Qn(e){const t=Fe(e.template,e.datasets,e.pagination).plan;return Ke(t,{validationFormulas:[e.pagination?.formula],parts:[{template:e.template,datasets:e.datasets}],rebuild:(r,n)=>Ln(r[0].template,r[0].datasets,{...e.pagination,signal:n})},[e.pagination])}let Zn=0;function Nt(){return`report-${Date.now()}-${++Zn}`}function Ce(e,t,r){if(!r?.aborted)try{const n=e?.({...t});n&&typeof n.then=="function"&&Promise.resolve(n).catch(()=>{})}catch{}}function jt(e){const t=e.taskId??Nt(),r=(n,o,a)=>{Ce(e.onEvent,{taskId:t,...e.correlationId===void 0?{}:{correlationId:e.correlationId},stage:n,status:o,...a===void 0?{}:{reportId:a}},e.signal)};return{taskId:t,progress(n,o,a){Ce(e.onEvent,{taskId:t,...e.correlationId===void 0?{}:{correlationId:e.correlationId},stage:n,status:"started",completed:o,total:a},e.signal)},runMaybeAsync(n,o,a){r(n,"started",a);try{const s=o();return s instanceof Promise?s.then(i=>(r(n,"completed",a),i),i=>{throw r(n,"failed",a),i}):(r(n,"completed",a),s)}catch(s){throw r(n,"failed",a),s}},async run(n,o,a){r(n,"started",a);try{const s=await o();return r(n,"completed",a),s}catch(s){throw r(n,"failed",a),s}},runSync(n,o,a){r(n,"started",a);try{const s=o();return r(n,"completed",a),s}catch(s){throw r(n,"failed",a),s}}}}function De(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;const t=e,r=n=>typeof n=="string"&&n.trim().length>0&&n.length<=256;return!r(t.datasetId)||!r(t.field)||t.tableId!==void 0&&!r(t.tableId)||t.reportScope!==void 0&&(typeof t.reportScope!="string"||!t.reportScope.trim()||t.reportScope.length>4096)?!1:t.rowKey===void 0?!0:typeof t.rowKey=="string"?t.rowKey.trim().length>0&&t.rowKey.length<=1024:typeof t.rowKey=="number"&&Number.isFinite(t.rowKey)}function Kt(e){return e==="missing-source"||e==="not-applicable"||e==="not-calculable"}function Dt(e){return e.target!==void 0&&!De(e.target)?!1:e.valueState===void 0||Kt(e.valueState)&&e.target!==void 0}function eo(e,t){if(Ee.validateDatasetRows([],e),!De(t))throw new Error("数据说明目标无效");const r=e.fields.find(o=>o.field===t.field);if(!r)throw new Error("数据说明字段未在契约中声明");const n=[];return r.description&&n.push({code:"field-definition",severity:"info",message:r.description,target:{...t}}),r.calculation&&n.push({code:"field-calculation",severity:"info",message:r.calculation.description,target:{...t}}),n}function He(e,t,r={}){const n=new Map;for(const a of e.pages)for(const s of a.components){if(s.kind!=="list"||s.tree?.input!=="nested")continue;const i=n.get(s.dataset);if(i&&(i.childrenField??"children")!==(s.tree.childrenField??"children"))throw new Error("同一数据集的嵌套树应使用相同 childrenField");n.set(s.dataset,s.tree)}if(!n.size)return t;const o={...t};for(const[a,s]of n){const i=Math.min(s.maxRows??1e5,r.maxRows??1/0);o[a]=_.flattenTreeInput(t[a]??[],{...s,maxRows:i},r.signal)}return o}function to(e,t,r={}){return Object.values(He(e,t,r)).reduce((n,o)=>n+o.length,0)}function ro(e,t,r){const n=Ee.datasetJsonSchema(r),o=e?.pages.flatMap(i=>i.components).find(i=>i.kind==="list"&&i.dataset===t&&i.tree?.input==="nested");if(!o||o.kind!=="list"||!o.tree)return n;const a=n.items,s=o.tree.childrenField??"children";return{...n,items:{$ref:"#/$defs/treeNode"},$defs:{treeNode:{...a,properties:{...a.properties,[s]:{anyOf:[{type:"null"},{type:"array",items:{$ref:"#/$defs/treeNode"}}]}}}}}}function Be(e,t){return JSON.stringify([e,t])}function Ve(e,t,r){return r===void 0?Be(e,t):JSON.stringify(["shared",r])}function Ht(e,t,r){return e.map(n=>{const o=n.table?{...n.table,id:r(n.table.id),...n.table.source?{source:{...n.table.source,sourceScope:t}}:{}}:void 0,a=n.grid?.cells.map(s=>s.map(i=>!i||!i.source&&!i.children?i:{...i,...i.source?{source:{...i.source,sourceScope:t}}:{},...i.children?{children:Ht(i.children,t,r)}:{}}));return o||a?{...n,...o?{table:o}:{},...a?{grid:{...n.grid,cells:a}}:{}}:n})}function Pe(e){return M.validateChartComponentLimit(e.maxChartComponents),{maxPages:e.maxPages,maxCells:e.maxCells,maxChartComponents:e.maxChartComponents??M.DEFAULT_CHART_COMPONENT_LIMIT,usedPages:0,usedCells:0,usedChartComponents:0}}function no(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 oo(e){const t=r=>r.grid?.cells.reduce((n,o)=>n+o.reduce((a,s)=>a+(s?1+(s.children?.reduce((i,c)=>i+t(c),0)??0):0),0),0)??0;return e.pages.reduce((r,n)=>r+n.components.reduce((o,a)=>o+t(a),0),0)}function ie(e,t){return e===void 0?void 0:e-t}function be(e,t){return e===void 0?t:Math.max(1,Math.min(e,t??e))}function Bt(e,t,r,n,o){M.validateChartComponentLimit(e?.maxChartComponents);const a=ie(t.maxPages,t.usedPages),s=t.maxChartComponents-t.usedChartComponents;if(a!==void 0&&a<1&&r.pages.length&&!no(r,n))throw new M.PaginatePageLimitError(0,1);if(s<1&&r.pages.some(i=>i.components.some(c=>c.kind!=="list"&&c.chartBinding)))throw new M.PaginateChartComponentLimitError(s,1);return{...e,signal:o??e?.signal,maxPages:be(a,e?.maxPages),maxCells:be(ie(t.maxCells,t.usedCells),e?.maxCells),maxChartComponents:be(s,e?.maxChartComponents)}}function Vt(e,t){const r=ie(e.maxPages,e.usedPages),n=e.maxChartComponents-e.usedChartComponents;if(r!==void 0&&t.plan.pages.length>r)throw new M.PaginatePageLimitError(r,t.plan.pages.length);if(t.chartComponents>n)throw new M.PaginateChartComponentLimitError(n,t.chartComponents);const o=oo(t.plan),a=ie(e.maxCells,e.usedCells);if(a!==void 0&&o>a)throw new M.PaginateCellLimitError(a,o);e.usedPages+=t.plan.pages.length,e.usedCells+=o,e.usedChartComponents+=t.chartComponents}function Gt(e,t){return e instanceof M.PaginatePageLimitError&&t.maxPages!==void 0&&(e.limit===t.maxPages-t.usedPages||e.limit===0)?new M.PaginatePageLimitError(t.maxPages,t.usedPages+e.actual):e instanceof M.PaginateCellLimitError&&t.maxCells!==void 0?new M.PaginateCellLimitError(t.maxCells,t.usedCells+e.actual):e instanceof M.PaginateChartComponentLimitError&&e.limit===t.maxChartComponents-t.usedChartComponents?new M.PaginateChartComponentLimitError(t.maxChartComponents,t.usedChartComponents+e.estimated):e}function ao(e,t){const r=Object.keys(e.datasets),n=Object.keys(t.datasets);return e.template===t.template&&e.sourceScope===t.sourceScope&&r.length===n.length&&r.every((o,a)=>o===n[a]&&e.datasets[o]===t.datasets[o])}function so(){const e=[];return async(t,r,n,o)=>{if(n.formula||n.measurer||n.onWarning)return o();const a=e[t];if(a&&ao(a.part,r)&&a.unchanged())return a.result;const s=await o();if(n.signal?.aborted)return s;try{e[t]={part:r,result:s,unchanged:se(s.plan)}}catch{e[t]=void 0}return s}}const Wt=new WeakMap;function io(e,t){return Wt.set(e,t),e}function _t(e,t,r,n){Wt.get(e)?.(t,r,n)}function co(e){if(!("mapData"in e))return e;const{load:t,mapData:r,...n}=e;return{...n,load:async o=>{const a=await t(o);F(o.signal);try{return r(a,o)}catch(s){throw new T("validate",`报表 ${o.reportId} 数据映射失败`,s)}}}}class T extends Error{constructor(t,r,n){super(r),this.name="ReportSourceError",this.code=t,this.cause=n}}function he(e){const t=new Error("报表加载已取消");return t.name="AbortError",Object.defineProperty(t,"cause",{value:e.reason}),t}function F(e){if(e?.aborted)throw he(e)}function Re(e,t){return t?new Promise((r,n)=>{const o=()=>t.removeEventListener("abort",a),a=()=>{o(),n(he(t))};t.addEventListener("abort",a,{once:!0}),t.aborted&&a(),Promise.resolve(e).then(s=>{o(),r(s)},s=>{o(),n(s)})}):Promise.resolve(e)}function lo(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new T("validate",`报表 ${t} 的数据集应为对象`);for(const[r,n]of Object.entries(e))if(!Array.isArray(n)||n.some(o=>!o||typeof o!="object"||Array.isArray(o)))throw new T("validate",`报表 ${t} 的数据集 ${r} 应为对象数组`)}async function uo(e,t,r){const{reportId:n,signal:o}=t;try{const a=await Re(e(t),o);F(o);const s=B.validateReportTemplate(a);if(!s.ok)throw new T("validate",`报表 ${n} 模板校验失败:${s.errors.slice(0,3).map(i=>`${i.path}: ${i.message}`).join("; ")}`);return r.push(...s.warnings.map(i=>`${n}: ${i.path}: ${i.message}`)),a}catch(a){throw o?.aborted?he(o):a instanceof T?a:a instanceof B.ReportTemplateError?new T("validate",`报表 ${n} 模板校验失败:${a.message}`,a):new T("fetch",`报表 ${n} 模板加载失败:${a instanceof Error?a.message:String(a)}`,a)}}async function fo(e,t,r,n){const o=t.signal;let a;try{if(e.load)a=await Re(e.load(t),o);else if(e.provider){const s=await Re(e.provider.query(t),o);F(o),mo(s,r),a=s.datasets,n?.(r,s)}else a=e.datasets??{}}catch(s){throw o?.aborted?he(o):s instanceof T?s:new T("fetch",`报表 ${r} 取数失败:${s instanceof Error?s.message:String(s)}`,s)}return F(o),a}function mo(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new T("validate",`报表 ${t} Provider 应返回 datasets 结果对象`);for(const r of["revision","sourceToken"])if(e[r]!==void 0&&typeof e[r]!="string")throw new T("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 T("validate",`报表 ${t} Provider diagnostics 不符合结构化诊断契约`);if(e.diagnostics?.some(r=>!Dt(r)))throw new T("validate",`报表 ${t} Provider 数据说明缺少有效的字段身份或值状态`)}function*zt(e,t,r,n,o,a=!0){try{t=He(n,t,{maxRows:e.dataValidation?.maxRows,signal:o})}catch(s){throw new T("validate",`报表 ${r} 树形数据无效:${s instanceof Error?s.message:String(s)}`,s)}for(const[s,i]of Object.entries(e.dataSchema??{})){const c=Object.prototype.hasOwnProperty.call(t,s)?t[s]:void 0,l={...e.dataValidation,path:`$.datasets.${s}`};try{const u=yield*Ee.iterateDatasetValidation(c,i,l,a);if(!u.ok)throw new T("validate",`报表 ${r} 数据集 ${s} 不符合字段契约:${u.issues[0]?.message}`,{issues:u.issues})}catch(u){throw F(o),u instanceof T?u:new T("config",`报表 ${r} 数据集 ${s} 字段契约配置无效`,u)}}}function go(e,t,r,n,o){let a;try{a=Fn({part:e,validation:{dataSchema:t.dataSchema,dataValidation:t.dataValidation}})}catch{F(o);for(const s of zt(t,e.datasets,r,e.template,o,!1));return _t(n,r,e.datasets,e.template),{part:e,owned:!1,release:()=>{}}}return ho(a,t,r,n,o)}async function ho(e,t,r,n,o){const{part:a,validation:s}=await ve(e,o);await ve(zt({...t,...s},a.datasets,r,a.template,o),o);const i=Zt(a.datasets);try{try{await rr(a.template,a.datasets,{...t.pagination,signal:o??t.pagination?.signal})}catch(c){throw F(o),new T("validate",`报表 ${r} 排版失败:${c instanceof Error?c.message:String(c)}`,c)}return _t(n,r,a.datasets,a.template),{part:a,owned:!0,release:i}}catch(c){throw i(),c}}async function po(e,t,r,n,o,a){try{const s=Bt(r.pagination,o,e.template,e.datasets,a),i=t?await pt(e.template,e.datasets,s):Fe(e.template,e.datasets,s);return Vt(o,i),i}catch(s){F(a);const i=Gt(s,o);throw new T("validate",`报表 ${n} 排版失败:${i instanceof Error?i.message:String(i)}`,i)}}function Jt(e,t,r,n,o){const a=new Map,s=i=>{let c=a.get(i);return c===void 0&&(c=JSON.stringify([r,n,i]),a.set(i,c)),c};for(const i of t.pages)e.push({...i,meta:{...i.meta,reportScope:Be(r,n)},components:Ht(i.components,o??Ve(r,n),s)})}async function wo(e,t,r,n,o,a){const s=[],i=Pe(n);for(const[u,f]of e.entries()){F(a);try{const d=Bt(t[u]?.pagination,i,f.template,f.datasets,a);F(d.signal);const m=await o(u,f,d,()=>At(f.template,f.datasets,d));Vt(i,m),Jt(s,m.plan,u,r[u],f.sourceScope)}catch(d){throw Gt(d,i)}}const c={schemaVersion:E.RENDER_PLAN_SCHEMA_VERSION,...e.some(u=>Te(u.template))?{requiresRecalculation:!0}:{},pages:s},l=B.validateRenderPlan(c);if(!l.ok)throw new T("validate",`重算渲染计划校验失败:${l.errors[0]?.message}`);return c}function yo(e,t={}){if(t.maxPages!==void 0&&(!Number.isSafeInteger(t.maxPages)||t.maxPages<1))throw new T("config","maxPages 应为正安全整数");if(t.maxCells!==void 0&&(!Number.isSafeInteger(t.maxCells)||t.maxCells<1))throw new T("config","maxCells 应为正安全整数");try{Pe(t)}catch(o){throw new T("config","maxChartComponents 应为 1..1000000 的安全整数",o)}function r(o){const a=Object.prototype.hasOwnProperty.call(e,o)?e[o]:void 0;if(!a)throw new T("config",`未注册报表 ${o}`);if(a.sourceScope!==void 0&&(typeof a.sourceScope!="string"||!a.sourceScope.trim()||a.sourceScope.length>512))throw new T("config","sourceScope 应为不超过 512 字符的非空字符串");return a}return Object.assign(async({reportIds:o,params:a,signal:s,onWarning:i,onQueryResult:c,...l})=>{F(s);const u=jt({...l,signal:s}),f=[...o],d={...a};if(f.length===0)throw new T("config","缺少报表 ID");const m=f.map(v=>{const P=r(v);return{...P,pagination:{...P.pagination}}}),g=u.runSync("validate",()=>m.map(v=>Ge.assertReportParams(v.params??(typeof v.template=="function"?[]:v.template.params)??[],d))),y=[],w=[],p=Pe(t),h=[];for(const[v,P]of m.entries()){F(s);const R=f[v],k={reportId:R,params:g[v],signal:s},S=typeof P.template=="function"?await u.run("query",()=>uo(P.template,k,h),R):P.template;k.params=u.runSync("validate",()=>Ge.assertReportParams(P.params??S.params??[],k.params),R);const A=await u.run("query",()=>fo(P,k,R,(we,Ut)=>c?.(we,Ut,v)),R),G=Ve(v,R,P.sourceScope),D=u.runMaybeAsync("validate",()=>(lo(A,R),t.onDatasets?.(R,A,S),go({template:S,datasets:A,sourceScope:G},P,R,t,s)),R),{part:W,owned:U,release:qt}=D instanceof Promise?await D:D;let pe;try{F(s),pe=await u.run("layout",()=>po(W,U,P,R,p,s),R)}finally{qt()}w.push(W),Jt(y,pe.plan,v,R,G),h.push(...pe.warnings.map(we=>`${R}: ${we}`))}F(s);const x={schemaVersion:E.RENDER_PLAN_SCHEMA_VERSION,...w.some(v=>Te(v.template))?{requiresRecalculation:!0}:{},pages:y},O=u.runSync("validate",()=>{const v=B.validateRenderPlan(x);if(!v.ok)throw new T("validate",`渲染计划校验失败:${v.errors.slice(0,3).map(P=>`${P.path}: ${P.message}`).join("; ")}`);return v});h.push(...O.warnings.map(v=>`${v.path}: ${v.message}`));const $=m.map(v=>({...v,pagination:{...v.pagination}})),j={maxPages:t.maxPages,maxCells:t.maxCells,maxChartComponents:t.maxChartComponents},K=so();try{Ke(x,{parts:w,validationFormulas:$.map(v=>v.pagination?.formula),rebuild:(v,P)=>wo(v,$,f,j,K,P)},$.map(v=>v.pagination))}catch{h.push("来源数据无法建立本地重算口径;当前预览仅支持计划内编辑,请使用可序列化模板数据启用规则重算")}const C=i??t.onWarning??(v=>console.warn("[mach-report]",v));for(const v of h)F(s),C(v);return F(s),x},{getParamDefs:o=>Xt.getReportParamDefs(e,o)})}const bo=new Set([8,9,10,12,13]);function vo(e,t){const r=Array.isArray(e),n=Object.getPrototypeOf(e);if(n!==(r?Array.prototype:Object.prototype)&&!(n===null&&!r)||Object.getOwnPropertySymbols(e).length)throw t("input","快照应为普通 JSON 对象");const o=Object.getOwnPropertyNames(e).filter(a=>!(r&&a==="length"));if(r&&(o.length!==e.length||o.some((a,s)=>a!==String(s))))throw t("input","快照数组应为连续数组");return{array:r,keys:o}}function Mo(e){if(/^[\u0020-\u007e]*$/.test(e)&&!/["\\]/.test(e))return e.length+2;let t=2;for(let r=0;r<e.length;r++){const n=e.charCodeAt(r);if(n<32)t+=bo.has(n)?2:6;else if(n===34||n===92)t+=2;else if(n<128)t++;else if(n<2048)t+=2;else if(n>=55296&&n<=57343){const o=e.charCodeAt(r+1);n<=56319&&o>=56320&&o<=57343?(t+=4,r++):t+=6}else t+=3}return t}function So(e,t){const r=t.maxNodes??1e6;if(![t.maxBytes,r].every(d=>Number.isSafeInteger(d)&&d>0))throw t.error("budget","快照预算应为正安全整数");let n=0,o=0;const a=new Set,s=new Map;function i(d){if(d.length+2>t.maxBytes-o)throw t.error("budget","快照超过字节预算");const m=s.get(d);if(m!==void 0)return m;const g=Mo(d);return d.length<=256&&s.size<4096&&s.set(d,g),g}function c(d){if(o+=d,o>t.maxBytes)throw t.error("budget","快照超过字节预算")}function l(d,m){if(++n>r||m>64)throw t.error("budget","快照节点或深度超过预算");if(n%1024===0&&t.check?.(),typeof d=="string")return c(i(d)),d;if(d===null||typeof d=="boolean"||typeof d=="number"&&Number.isFinite(d))return c(String(d).length),typeof d=="number"&&Object.is(d,-0)?0:d;if(!d||typeof d!="object"||a.has(d))throw t.error("input","快照应为无循环的有限 JSON 值");return u(d,m)}function u(d,m){const{array:g,keys:y}=vo(d,t.error);a.add(d),c(2);const w=g?[]:{};let p=0;for(const h of y){const x=Object.getOwnPropertyDescriptor(d,h);if(x.get||x.set||!x.enumerable||["__proto__","constructor","prototype"].includes(h))throw t.error("input","快照不允许访问器或危险键");if(x.value===void 0&&!g)continue;c((p++?1:0)+(g?0:i(h)+1));const O=l(x.value===void 0?null:x.value,m+1);h in w?Object.defineProperty(w,h,{value:O,enumerable:!0,configurable:!0,writable:!0}):w[h]=O}return a.delete(d),w}t.check?.();const f=l(e,0);return t.check?.(),f}exports.DEFAULT_LABEL_PAGE_LIMIT=nt;exports.ReportCellEditError=b;exports.ReportSourceError=T;exports.ReportValidationError=yt;exports.applyReportCellEdit=wn;exports.applyReportCellEditBatch=Sn;exports.applyReportEditResult=kt;exports.applyReportSourceMetadata=Le;exports.assertReportValidation=Mt;exports.countTemplatePages=Wr;exports.createReportCellEdit=fn;exports.createReportCellEditBatch=Mn;exports.createReportCellIndex=Ct;exports.createReportCellResolver=V;exports.createReportEditSession=Qn;exports.createReportSource=yo;exports.createReportTaskReporter=jt;exports.defineReport=co;exports.editFromContext=J;exports.estimateListLayoutCells=Ur;exports.explainDatasetField=eo;exports.formatReportCellEdit=z;exports.getReportCellContext=me;exports.getReportEditSession=zn;exports.hasValidDataExplanation=Dt;exports.inspectOwnedSource=io;exports.isReportDataTarget=De;exports.isReportValueState=Kt;exports.notifyReportTaskEvent=Ce;exports.paginateTemplate=Fe;exports.paginateTemplatePages=_r;exports.parseReportCellInput=Ae;exports.projectListColumns=rt;exports.registerReportEditSession=Yn;exports.relocateReportCellEdits=Cn;exports.reportCellEditKey=N;exports.reportOccurrenceScope=Be;exports.reportSourceScope=Ve;exports.reportTaskId=Nt;exports.snapshotReportJson=So;exports.sourceChanged=ge;exports.summarizeReportCellEdits=xn;exports.templateDatasetJsonSchema=ro;exports.templateDatasetRowCount=to;exports.templateValidationDatasets=He;exports.validateReportDataset=en;
|
package/dist/matrix-CcqYOuq_.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const m=require("./computed-BQgBrma-.cjs");function M(e,r){const l=()=>r.measures.map(c=>m.createAggregateAccumulator(c)),t=new Map,a=new Map,o=new Map,n=r.totals?l():void 0,s=(c,u)=>c?.forEach(i=>i.add(u));for(const c of e){const u=r.row(c),i=r.column(c);a.has(i.key)||a.set(i.key,i.label);let f=t.get(u.key);f||(f={label:u.label,cells:new Map,...r.totals?{totals:l()}:{}},t.set(u.key,f)),r.check(t.size,a.size);let d=f.cells.get(i.key);if(d||(d=l(),f.cells.set(i.key,d)),s(d,c),!r.totals)continue;let h=o.get(i.key);h||(h=l(),o.set(i.key,h)),s(f.totals,c),s(h,c),s(n,c)}return{groups:t,columns:a,columnTotals:o,totals:n}}function $(e,r){return JSON.stringify([e.slice(0,r.length),r.map(l=>[l===null?"null":typeof l,l])])}function x(e,r){return r.map(l=>{const t=Object.prototype.hasOwnProperty.call(e,l)?e[l]:null;if(t==null)return null;if(typeof t=="string"||typeof t=="boolean"||typeof t=="number"&&Number.isFinite(t))return t;throw new Error("矩阵维度必须是有限 JSON 标量")})}function N(e,r,l){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("矩阵层级应为对象");for(const t of[e.emptyLabel,e.subtotalLabel,e.totalLabel])if(t!==void 0&&typeof t!="string")throw new Error("矩阵层级标签应为字符串");b(e.row,r.length),b(e.column,l.length)}function b(e,r){if(e!==void 0){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("矩阵轴配置应为对象");if(e.labels!==void 0&&(!Array.isArray(e.labels)||e.labels.length!==r||e.labels.some(l=>typeof l!="string")))throw new Error("矩阵维度标签必须与维度字段一一对应");if(e.sort!==void 0&&(!Array.isArray(e.sort)||e.sort.length>r||e.sort.some(l=>!["source","asc","desc"].includes(l))))throw new Error("矩阵维度排序应为 source、asc 或 desc");if(e.subtotals!==void 0&&(!Array.isArray(e.subtotals)||new Set(e.subtotals).size!==e.subtotals.length||e.subtotals.some(l=>!Number.isInteger(l)||l<1||l>=r)))throw new Error("矩阵小计深度应唯一且位于 1 至末级之前")}}function k(e,r,l){return{fields:e,options:r??{},hierarchy:l,root:{key:$(e,[]),values:[],children:new Map},leaves:0,expanded:0}}function A(e,r){const l=x(r,e.fields);let t=e.root;for(let a=1;a<=l.length;a++){const o=l[a-1];let n=t.children.get(o);if(!n){const s=l.slice(0,a);n={key:$(e.fields,s),values:s,children:new Map,parent:t},t.children.set(o,n),a===l.length?(e.leaves++,e.expanded++):e.options.subtotals?.includes(a)&&e.expanded++}t=n}}function L(e,r){if(e===r)return 0;if(e===null)return-1;if(r===null)return 1;if(typeof e=="number"&&typeof r=="number")return e-r;const l=`${typeof e}:${e}`,t=`${typeof r}:${r}`;return l<t?-1:1}function R(e,r){const l=[...e.children.values()];return r&&r!=="source"&&l.sort((t,a)=>L(t.values[t.values.length-1],a.values[a.values.length-1])*(r==="desc"?-1:1)),l}function y(e,r,l){const{key:t,values:a}=r;return{key:t,kind:l,depth:a.length,fields:e.fields.slice(0,a.length),values:a,labels:a.map(o=>o===null?e.hierarchy.emptyLabel??"(空)":String(o))}}function F(e,r){const l=[];function t(a){for(const o of R(a,e.options.sort?.[a.values.length]))o.children.size?(t(o),e.options.subtotals?.includes(o.values.length)&&l.push(y(e,o,"subtotal"))):l.push(y(e,o,"member"))}return t(e.root),r&&e.leaves&&l.push(y(e,e.root,"total")),l}function v(e,r,l){const t=x(r,e.fields);let a=e.root;for(const c of t){const u=a.children.get(c);if(!u)throw new Error("矩阵维度在预算检查后发生变化");a=u}const o=l?a.totalKeys:a.keys;if(o)return o;const n=[];for(let c=a;c;c=c.parent)n[c.values.length]=c.key;const s=[a.key,...(e.options.subtotals??[]).map(c=>n[c])];return l?(s.push(e.root.key),a.totalKeys=s):a.keys=s,s}function z(e,r,l){if(!(e.kind!=="member"&&r>e.depth))return e.kind==="total"?{key:"total",text:l.totalLabel??"合计",rowSpan:0}:e.kind==="subtotal"&&r===e.depth?{key:e.key,text:l.subtotalLabel??"小计",rowSpan:0}:{key:JSON.stringify(e.values.slice(0,r+1).map(t=>[typeof t,t])),text:e.labels[r],rowSpan:1}}function O(e,r){const l=e.columnFields.length+1,t=e.rowFields.length,a=Array.from({length:l},()=>Array(t+r.length).fill(null));for(let o=0;o<e.columnFields.length;o++){let n;r.forEach((s,c)=>{const u=z(s,o,e.hierarchy);if(!u){n=void 0;return}if(n?.key===u.key){n.cell.colSpan=(n.cell.colSpan??1)+1;return}const i={text:u.text,rowSpan:u.rowSpan||e.columnFields.length-o,editable:!1,derived:!0};a[o][t+c]=i,n={key:u.key,cell:i}})}return e.rowFields.forEach((o,n)=>{a[0][n]={text:e.hierarchy.row?.labels?.[n]??o,rowSpan:l,editable:!1,derived:!0}}),r.forEach((o,n)=>{const s=e.measures[o.measure];a[l-1][t+n]={text:s.label??`${s.field} (${s.op})`,editable:!1,derived:!0}}),{cells:a.map(o=>o.filter(n=>n!==null)),colWidthsMm:[...e.rowFields.map(()=>e.rowWidthMm??40),...r.map(()=>e.columnWidthMm??28)]}}function E(e,r,l,t){const a=+(!!r.totals&&e>0),o=l.expanded+a,n=(t.expanded+a)*r.measures.length+r.rowFields.length;if(o>(r.maxRows??1e3)||t.expanded+a>(r.maxColumns??200))throw new Error("矩阵层级展开数量超出预算(包含小计/总计)");if(o*n>(r.maxCells??2e6))throw new Error("矩阵输出超出 maxCells 预算");return{rowCount:o,columnCount:n,cells:o*n}}function S(e,r){if(!Array.isArray(e)||e.length>(r.maxInputRows??1e5))throw new Error("矩阵输入超出预算");const l=k(r.rowFields,r.hierarchy.row,r.hierarchy),t=k(r.columnFields,r.hierarchy.column,r.hierarchy);if(e.length*(1+(l.options.subtotals?.length??0)+ +!!r.totals)*(1+(t.options.subtotals?.length??0)+ +!!r.totals)*r.measures.length>(r.maxAggregateUpdates??1e7))throw new Error("矩阵聚合更新超出 maxAggregateUpdates 预算");let o=E(0,r,l,t);for(const n of e){if(!n||typeof n!="object"||Array.isArray(n))throw new Error("矩阵数据行应为对象");A(l,n),A(t,n),o=E(e.length,r,l,t)}return{row:l,column:t,shape:o}}function j(e,r){return S(e,r).shape}function p(e,r,l){const t=new Map;for(const a of e){const o=v(l.row,a,!!r.totals),n=v(l.column,a,!!r.totals);for(const s of o){let c=t.get(s);c||(c=new Map,t.set(s,c));for(const u of n){let i=c.get(u);i||(i=r.measures.map(f=>m.createAggregateAccumulator({...f,field:f.valueField??f.field})),c.set(u,i)),i.forEach(f=>f.add(a))}}}return t}function K(e,r){return e.flatMap((l,t)=>r.measures.map((a,o)=>({...l,field:l.kind==="total"?`total_${o}`:`c${t}_${o}`,measure:o,measureField:a.field,valueField:a.valueField??a.field,operation:a.op})))}function H(e,r){return e.kind==="total"?r.hierarchy.totalLabel??"合计":[...e.labels,...e.kind==="subtotal"?[r.hierarchy.subtotalLabel??"小计"]:[]].join(" / ")}function I(e,r){return[...r.rowFields.map((l,t)=>({field:`r${t}`,header:r.hierarchy.row?.labels?.[t]??l,semanticRole:"dimension"})),...e.map(l=>{const t=r.measures[l.measure];return{field:l.field,header:`${H(l,r)} · ${t.label??`${t.field} (${t.op})`}`,semanticRole:"measure",...t.digits===void 0?{}:{format:{kind:"number",digits:t.digits}}}})]}function T(e,r,l,t){return e.map(a=>{const o={};l.rowFields.forEach((n,s)=>{o[`r${s}`]=a.kind==="total"?s===0?l.hierarchy.totalLabel??"合计":null:a.labels[s]??(s===a.depth?l.hierarchy.subtotalLabel??"小计":null)});for(const n of r)o[n.field]=t.get(a.key)?.get(n.key)?.[n.measure]?.value()??(l.measures[n.measure].op==="count"?0:null);return o})}function _(e,r){const l=S(e,r),t=F(l.row,!!r.totals),a=K(F(l.column,!!r.totals),r),o=p(e,r,l);return{columns:I(a,r),rows:T(t,a,r,o),headerGrid:O(r,a),metadata:{rowFields:[...r.rowFields],rowLabels:[...r.hierarchy.row?.labels??r.rowFields],columnFields:[...r.columnFields],columnLabels:[...r.hierarchy.column?.labels??r.columnFields],rows:t,columns:a}}}function w(e,r){const l=r.map(t=>Object.prototype.hasOwnProperty.call(e,t)?e[t]:null);if(l.some(t=>t!=null&&typeof t!="string"&&typeof t!="boolean"&&!(typeof t=="number"&&Number.isFinite(t))))throw new Error("矩阵维度必须是有限 JSON 标量");return{key:JSON.stringify(l.map(t=>[typeof t,t??null])),label:l.map(t=>t==null?"":String(t)).join(" / ")}}function J(e){for(const r of["maxRows","maxColumns","maxInputRows","maxCells","maxAggregateUpdates"])if(e[r]!==void 0&&(!Number.isSafeInteger(e[r])||e[r]<1))throw new Error("矩阵预算应为正安全整数");for(const r of["columnWidthMm","rowWidthMm"])if(e[r]!==void 0&&(!Number.isFinite(e[r])||e[r]<=0))throw new Error("矩阵列宽应为正数")}function g(e){if(!e||!Array.isArray(e.rowFields)||!Array.isArray(e.columnFields)||!Array.isArray(e.measures))throw new Error("矩阵需要行维度、列维度和度量数组");for(const l of[e.rowFields,e.columnFields])if(l.some(t=>typeof t!="string"||!t.trim())||new Set(l).size!==l.length)throw new Error("矩阵维度字段应非空且唯一");if(J(e),!e.rowFields.length||!e.columnFields.length||e.rowFields.length>16||e.columnFields.length>16)throw new Error("矩阵需要 1–16 个行/列维度");if(!e.measures.length||e.measures.length>32)throw new Error("矩阵需要 1–32 个度量");if(e.measures.map(l=>{if(!l||typeof l!="object")throw new Error("矩阵度量应为对象");if(m.createAggregateAccumulator({...l,field:l.valueField??l.field}),l.label!==void 0&&typeof l.label!="string")throw new Error("矩阵度量标签应为字符串");return l.field}).some(l=>typeof l!="string"||!l.trim()))throw new Error("矩阵度量字段应非空");e.hierarchy!==void 0&&N(e.hierarchy,e.rowFields,e.columnFields)}function C(e,r){if(g(r),r.hierarchy)return j(e,r);if(!Array.isArray(e)||e.length>(r.maxInputRows??1e5))throw new Error("矩阵输入超出预算");const l=new Set,t=new Set;for(const n of e){if(!n||typeof n!="object"||Array.isArray(n))throw new Error("矩阵数据行应为对象");if(l.add(w(n,r.rowFields).key),t.add(w(n,r.columnFields).key),l.size>(r.maxRows??1e3)||t.size>(r.maxColumns??200))throw new Error("矩阵维度数量超出预算");if((l.size+ +!!r.totals)*((t.size+ +!!r.totals)*r.measures.length+1)>(r.maxCells??2e6))throw new Error("矩阵输出超出 maxCells 预算")}const a=l.size+ +(!!r.totals&&e.length>0),o=(t.size+ +!!r.totals)*r.measures.length+1;return{rowCount:a,columnCount:o,cells:a*o}}function P(e,r){if(r?.hierarchy)return g(r),_(e,r);C(e,r);const l=M(e,{row:n=>w(n,r.rowFields),column:n=>w(n,r.columnFields),measures:r.measures.map(n=>({...n,field:n.valueField??n.field})),totals:r.totals,check:()=>{}}),t=[...l.groups.values()].map(n=>({rowLabel:n.label})),a=[{field:"rowLabel",header:r.rowHeader??r.rowFields.join(" / "),semanticRole:"dimension"}],o={rowLabel:"合计"};return r.measures.forEach((n,s)=>{const c=[...l.columns.entries()].map(([u,i],f)=>({key:u,label:i,field:`c${f}_${s}`}));r.totals&&c.push({key:"",label:"合计",field:`total_${s}`});for(const u of c){const i=u.field===`total_${s}`;a.push({field:u.field,header:`${u.label} · ${n.label??`${n.field} (${n.op})`}`,semanticRole:"measure",...n.digits===void 0?{}:{format:{kind:"number",digits:n.digits}}});let f=0;for(const d of l.groups.values())t[f++][u.field]=(i?d.totals?.[s]:d.cells.get(u.key)?.[s])?.value()??(n.op==="count"?0:null);o[u.field]=(i?l.totals?.[s]:l.columnTotals.get(u.key)?.[s])?.value()??(n.op==="count"?0:null)}}),r.totals&&e.length&&t.push(o),{rows:t,columns:a}}exports.accumulatePivotRows=M;exports.createMatrixTable=P;exports.estimateMatrixTable=C;exports.validateMatrixOptions=g;
|
package/dist/media-B7vnpD8k.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";class f extends Error{constructor(e,n){super(n),this.code=e,this.name="ImageMediaError"}}const h={maxImageBytes:16*1024*1024,maxTotalImageBytes:32*1024*1024,maxImages:1e3,maxImagePixels:16e6,maxTotalImagePixels:64e6,maxImageDimension:16384};function i(t){throw new f("invalid-image-data",t)}function d(t){throw new f("image-budget-exceeded",t)}function l(t){const e={...h};for(const n of Object.keys(h)){const a=t[n]??h[n];if(!Number.isSafeInteger(a)||a<=0||a>2147483647)throw new RangeError(`${n} 图片预算须为1至2147483647的整数。`);e[n]=a}return e}function x(t){if(t.length<33||![137,80,78,71,13,10,26,10].every((n,a)=>t[a]===n))return i("图片内容与 PNG/JPEG 类型不一致。");const e=new DataView(t.buffer,t.byteOffset,t.byteLength);return e.getUint32(8)!==13||String.fromCharCode(...t.subarray(12,16))!=="IHDR"?i("PNG must begin with an IHDR header."):[e.getUint32(16),e.getUint32(20)]}const I=new Set([192,193,194,195,197,198,199,201,202,203,205,206,207]);function p(t){if(t[0]!==255||t[1]!==216)return i("图片内容与 PNG/JPEG 类型不一致。");let e=2;for(;e+3<t.length;){if(t[e++]!==255)return i("JPEG marker is malformed.");for(;t[e]===255;)e++;const n=t[e++];if(n===217||n===218)break;if(n===1||n>=208&&n<=215)continue;const a=t[e]*256+t[e+1];if(a<2||e+a>t.length)return i("JPEG segment exceeds its data boundary.");if(I.has(n))return a<8?i("JPEG frame header is incomplete."):[t[e+5]*256+t[e+6],t[e+3]*256+t[e+4]];e+=a}return i("JPEG has no supported dimension header.")}function w(t,e){if(t.length>Math.ceil(e.maxImageBytes/3)*4+64)return d("单张图片超过字节预算。");const n=/^data:image\/(png|jpe?g);base64,([A-Za-z0-9+/]+={0,2})$/i.exec(t);if(!n||n[2].length%4)return i("Image must contain valid PNG/JPEG base64 data.");const a=n[2],g=a.length/4*3-(a.endsWith("==")?2:a.endsWith("=")?1:0);if(g>e.maxImageBytes)return d("单张图片超过字节预算。");const s=n[1].toLowerCase()==="png"?"png":"jpeg",u=atob(a),o=new Uint8Array(g);for(let m=0;m<g;m++)o[m]=u.charCodeAt(m);const[r,c]=s==="png"?x(o):p(o);return!r||!c?i("Image dimensions must be positive."):r>e.maxImageDimension||c>e.maxImageDimension||r*c>e.maxImagePixels?d("Image exceeds its decoded dimension or pixel budget."):{dataUrl:`data:image/${s};base64,${a}`,bytes:o,extension:s,width:r,height:c}}function P(t={}){const e=l(t),n=new Map;let a=0,g=0;return s=>{const u=s.replace(/^data:image\/(png|jpe?g);base64,/i,(c,m)=>`data:image/${m.toLowerCase()==="png"?"png":"jpeg"};base64,`),o=n.get(u);if(o)return o;if(n.size>=e.maxImages)return d("唯一图片数量超过预算。");const r=w(s,e);return a+r.bytes.length>e.maxTotalImageBytes||g+r.width*r.height>e.maxTotalImagePixels?d("图片总字节或总像素超过预算。"):(a+=r.bytes.length,g+=r.width*r.height,n.set(u,r),r)}}exports.ImageMediaError=f;exports.createImageMediaInspector=P;
|
package/dist/media-Y90dHK9z.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
class f extends Error {
|
|
2
|
-
constructor(e, n) {
|
|
3
|
-
super(n), this.code = e, this.name = "ImageMediaError";
|
|
4
|
-
}
|
|
5
|
-
}
|
|
6
|
-
const h = { maxImageBytes: 16 * 1024 * 1024, maxTotalImageBytes: 32 * 1024 * 1024, maxImages: 1e3, maxImagePixels: 16e6, maxTotalImagePixels: 64e6, maxImageDimension: 16384 };
|
|
7
|
-
function r(t) {
|
|
8
|
-
throw new f("invalid-image-data", t);
|
|
9
|
-
}
|
|
10
|
-
function d(t) {
|
|
11
|
-
throw new f("image-budget-exceeded", t);
|
|
12
|
-
}
|
|
13
|
-
function l(t) {
|
|
14
|
-
const e = { ...h };
|
|
15
|
-
for (const n of Object.keys(h)) {
|
|
16
|
-
const a = t[n] ?? h[n];
|
|
17
|
-
if (!Number.isSafeInteger(a) || a <= 0 || a > 2147483647) throw new RangeError(`${n} 图片预算须为1至2147483647的整数。`);
|
|
18
|
-
e[n] = a;
|
|
19
|
-
}
|
|
20
|
-
return e;
|
|
21
|
-
}
|
|
22
|
-
function x(t) {
|
|
23
|
-
if (t.length < 33 || ![137, 80, 78, 71, 13, 10, 26, 10].every((n, a) => t[a] === n)) return r("图片内容与 PNG/JPEG 类型不一致。");
|
|
24
|
-
const e = new DataView(t.buffer, t.byteOffset, t.byteLength);
|
|
25
|
-
return e.getUint32(8) !== 13 || String.fromCharCode(...t.subarray(12, 16)) !== "IHDR" ? r("PNG must begin with an IHDR header.") : [e.getUint32(16), e.getUint32(20)];
|
|
26
|
-
}
|
|
27
|
-
const p = /* @__PURE__ */ new Set([192, 193, 194, 195, 197, 198, 199, 201, 202, 203, 205, 206, 207]);
|
|
28
|
-
function I(t) {
|
|
29
|
-
if (t[0] !== 255 || t[1] !== 216) return r("图片内容与 PNG/JPEG 类型不一致。");
|
|
30
|
-
let e = 2;
|
|
31
|
-
for (; e + 3 < t.length; ) {
|
|
32
|
-
if (t[e++] !== 255) return r("JPEG marker is malformed.");
|
|
33
|
-
for (; t[e] === 255; ) e++;
|
|
34
|
-
const n = t[e++];
|
|
35
|
-
if (n === 217 || n === 218) break;
|
|
36
|
-
if (n === 1 || n >= 208 && n <= 215) continue;
|
|
37
|
-
const a = t[e] * 256 + t[e + 1];
|
|
38
|
-
if (a < 2 || e + a > t.length) return r("JPEG segment exceeds its data boundary.");
|
|
39
|
-
if (p.has(n))
|
|
40
|
-
return a < 8 ? r("JPEG frame header is incomplete.") : [t[e + 5] * 256 + t[e + 6], t[e + 3] * 256 + t[e + 4]];
|
|
41
|
-
e += a;
|
|
42
|
-
}
|
|
43
|
-
return r("JPEG has no supported dimension header.");
|
|
44
|
-
}
|
|
45
|
-
function w(t, e) {
|
|
46
|
-
if (t.length > Math.ceil(e.maxImageBytes / 3) * 4 + 64) return d("单张图片超过字节预算。");
|
|
47
|
-
const n = /^data:image\/(png|jpe?g);base64,([A-Za-z0-9+/]+={0,2})$/i.exec(t);
|
|
48
|
-
if (!n || n[2].length % 4) return r("Image must contain valid PNG/JPEG base64 data.");
|
|
49
|
-
const a = n[2], g = a.length / 4 * 3 - (a.endsWith("==") ? 2 : a.endsWith("=") ? 1 : 0);
|
|
50
|
-
if (g > e.maxImageBytes) return d("单张图片超过字节预算。");
|
|
51
|
-
const s = n[1].toLowerCase() === "png" ? "png" : "jpeg", u = atob(a), o = new Uint8Array(g);
|
|
52
|
-
for (let m = 0; m < g; m++) o[m] = u.charCodeAt(m);
|
|
53
|
-
const [i, c] = s === "png" ? x(o) : I(o);
|
|
54
|
-
return !i || !c ? r("Image dimensions must be positive.") : i > e.maxImageDimension || c > e.maxImageDimension || i * c > e.maxImagePixels ? d("Image exceeds its decoded dimension or pixel budget.") : { dataUrl: `data:image/${s};base64,${a}`, bytes: o, extension: s, width: i, height: c };
|
|
55
|
-
}
|
|
56
|
-
function P(t = {}) {
|
|
57
|
-
const e = l(t), n = /* @__PURE__ */ new Map();
|
|
58
|
-
let a = 0, g = 0;
|
|
59
|
-
return (s) => {
|
|
60
|
-
const u = s.replace(/^data:image\/(png|jpe?g);base64,/i, (c, m) => `data:image/${m.toLowerCase() === "png" ? "png" : "jpeg"};base64,`), o = n.get(u);
|
|
61
|
-
if (o) return o;
|
|
62
|
-
if (n.size >= e.maxImages) return d("唯一图片数量超过预算。");
|
|
63
|
-
const i = w(s, e);
|
|
64
|
-
return a + i.bytes.length > e.maxTotalImageBytes || g + i.width * i.height > e.maxTotalImagePixels ? d("图片总字节或总像素超过预算。") : (a += i.bytes.length, g += i.width * i.height, n.set(u, i), i);
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
export {
|
|
68
|
-
f as I,
|
|
69
|
-
P as c
|
|
70
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const a=require("./json-snapshot-DGFeI30h.cjs"),c=require("./diagnostic-collector-wASg6Fzs.cjs"),s=require("./sha256-DgZAKXqI.cjs"),p=require("./workbook-sheets-CaPAulQ6.cjs");function f(e,r,t,o){if(o===void 0&&!e.diagnosticSummary&&!t){r.forEach(i=>e.diagnostics.push(i));return}const n=c.createDiagnosticCollector(o??c.DEFAULT_DIAGNOSTIC_LIMIT);e.diagnosticSummary?n.merge(e.diagnosticSummary):e.diagnostics.forEach(i=>n.push(i)),t?n.merge(t):r.forEach(i=>n.push(i)),e.diagnostics=n.entries,e.diagnosticSummary=n.snapshot()}function S(e,r){return!a.hasValidDataExplanation(e)||!l(e)||["code","message","severity","path","format","pageIndex","componentIndex","kind","nid","valueState"].some(o=>e[o]!==r[o])||e.componentPath?.length!==r.componentPath?.length||e.componentPath?.some((o,n)=>o!==r.componentPath?.[n])||["datasetId","field","rowKey","tableId","reportScope"].some(o=>e.target?.[o]!==r.target?.[o])?!1:e.extension?.id===r.extension?.id&&e.extension?.version===r.extension?.version}function m(e,r){return!c.validDiagnosticSummary(e)||e.entries.length!==r.length?!1:e.entries.every((t,o)=>!!t&&typeof t=="object"&&S(t,r[o]))}function b(e,r,t,o,n=t.length){n&&e.merge({total:n,counts:{[r]:n},entries:t.map(i=>({code:r,message:i,severity:o})),omitted:n-t.length})}function g(e,r){return e===void 0||typeof e=="number"&&Number.isSafeInteger(e)&&e>=r}function l(e){return!(e.format!==void 0&&!["dom","canvas","pdf","xlsx"].includes(e.format)||!g(e.pageIndex,0)||!g(e.componentIndex,-1)||e.componentPath!==void 0&&!x(e.componentPath)||e.extension!==void 0&&(!e.extension||typeof e.extension.id!="string"||typeof e.extension.version!="string"))}function x(e){if(!Array.isArray(e)||e.length>192)return!1;for(const r of e)if(typeof r!="number"||!Number.isSafeInteger(r)||r<0)return!1;return!0}function F(e){return e&&{...e,sheetNames:p.snapshotSheetNames(e.sheetNames),additionalSheets:p.snapshotAdditionalSheets(e.additionalSheets)}}function P(e,r){if(e.format!=="xlsx")return;const t=e.xlsx?.additionalSheets?.reduce((o,n)=>o+n.rows.reduce((i,d)=>i+d.length,0),0)??0;s.assertBudget(r,"maxCells",e.prepared.stats.cells+t)}function I(e){if(!e)return;const r=t=>{if(!(t instanceof Uint8Array)&&!(t instanceof ArrayBuffer))throw new a.ReportSourceError("validate","字体应为 Uint8Array 或 ArrayBuffer");if(t.byteLength>32e6)throw new s.ReportRuntimeError("budget","单份字体超过 32 MB","$.pdf");return new Uint8Array(t instanceof Uint8Array?t:new Uint8Array(t))};if(e.customFontFaces){const t=e.customFontFaces;return{customFontName:e.customFontName,customFontFaces:{regular:r(t.regular),...t.bold?{bold:r(t.bold)}:{},...t.italic?{italic:r(t.italic)}:{},...t.boldItalic?{boldItalic:r(t.boldItalic)}:{}}}}return{customFontName:e.customFontName,...e.customFontBytes?{customFontBytes:r(e.customFontBytes)}:{}}}function y(e){const r=e?.customFontFaces??(e?.customFontBytes?{regular:e.customFontBytes}:void 0);if(!r)return;const t=["regular","bold","italic","boldItalic"].map(o=>{const n=r[o];if(!n)return[o,null];const i=n instanceof Uint8Array?n:new Uint8Array(n);if(i.byteLength>32e6)throw new s.ReportRuntimeError("budget","单份字体超过 32 MB","$.pdf");return[o,s.portableSha256Hex(i)]});return s.portableSha256Hex(new TextEncoder().encode(JSON.stringify(t)))}const u=new WeakMap;function A(e,r,t){const o=h(e,r,t);let n=!0;return{prepared:o,forward(){if(!n)throw new Error("报表快照只能交接一次");return n=!1,u.set(o,r),o}}}function h(e,r,t){if(s.throwIfAborted(t),!Number.isSafeInteger(r)||r<=0)throw new s.ReportRuntimeError("budget","快照预算应为正安全整数","$.budget.maxPreparedBytes");const o=u.get(e);if(u.delete(e),o!==void 0&&o<=r)return e;const n=a.snapshotReportJson(e,{maxBytes:r,maxNodes:r,check:()=>s.throwIfAborted(t),error:(i,d)=>i==="budget"?new s.ReportRuntimeError("budget",d,"$.budget.maxPreparedBytes"):new a.ReportSourceError("validate",d)});return w(n),n}function v(e){if(e===void 0)return!0;if(!Array.isArray(e))return!1;const r=new Set;return e.every(t=>!t||typeof t!="object"||Array.isArray(t)||typeof t.reportId!="string"||!t.reportId.trim()||!Number.isSafeInteger(t.reportIndex)||t.reportIndex<0||r.has(t.reportIndex)||typeof t.reportScope!="string"||!t.reportScope.trim()||t.reportScope.length>4096||t.revision!==void 0&&typeof t.revision!="string"||t.sourceToken!==void 0&&typeof t.sourceToken!="string"?!1:(r.add(t.reportIndex),!0))}function w(e){if(!v(e.sources))throw new a.ReportSourceError("validate","准备结果来源清单无效");if(!e?.stats||["rows","pages","cells"].some(r=>!Number.isSafeInteger(e.stats[r])||e.stats[r]<0)||!Number.isFinite(e.stats.durationMs)||e.stats.durationMs<0)throw new a.ReportSourceError("validate","准备结果统计无效");if(!Array.isArray(e.diagnostics)||e.diagnostics.some(r=>!r||typeof r.code!="string"||typeof r.message!="string"||!["info","warning","error"].includes(r.severity)||!a.hasValidDataExplanation(r)||!l(r)))throw new a.ReportSourceError("validate","准备结果诊断无效");if(e.diagnosticSummary!==void 0&&!m(e.diagnosticSummary,e.diagnostics))throw new a.ReportSourceError("validate","准备结果诊断摘要无效");if(!e.revisions||typeof e.revisions!="object"||Array.isArray(e.revisions)||Object.values(e.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 a.ReportSourceError("validate","准备结果修订无效");if(e.layout&&(!["heuristic","provided","font-bytes"].includes(e.layout.textMetrics)||e.layout.fontFingerprint!==void 0&&!/^[a-f0-9]{64}$/.test(e.layout.fontFingerprint)))throw new a.ReportSourceError("validate","准备结果字体度量标识无效")}function E(e){if(e.layoutPolicy!==void 0&&!["verify","preserve"].includes(e.layoutPolicy))throw new a.ReportSourceError("validate","无效的 layoutPolicy");if(e.format!=="pdf")return;if(e.layoutPolicy==="preserve"&&!e.prepared.layout?.fontFingerprint){f(e.prepared,[{code:"prepared-layout-preserved",severity:"info",message:"显式保持现有分页与几何;未验证排版字体身份,实际 PDF 输出仍遵循 fidelity 校验。"}]);return}const r=e.prepared.layout?.fontFingerprint,t=y(e.pdf);if(r===t&&(r!==void 0||e.prepared.layout?.textMetrics==="heuristic"&&!t))return;const o="已准备计划的字体度量无法与本次 PDF 字体确认一致;保持现有分页,未重新查询或排版。请在 prepare 和 exportPrepared 提供相同字体字节。";if(e.fidelity==="strict")throw new a.ReportSourceError("validate",o);f(e.prepared,[{code:"prepared-font-metrics",severity:"warning",message:o}])}exports.appendPreparedDiagnostics=f;exports.assertPreparedOutputBudget=P;exports.capturePreparedHandoff=A;exports.checkPreparedFont=E;exports.matchingDiagnosticSummary=m;exports.mergeDiagnosticMessages=b;exports.reportFontFingerprint=y;exports.snapshotPdfFonts=I;exports.snapshotPreparedReport=h;exports.snapshotXlsxOptions=F;exports.validPreparedSources=v;exports.validReportDiagnosticLocation=l;exports.validatePreparedMetadata=w;
|
package/dist/sha256-BDQ1Qk7A.js
DELETED
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
const U = Object.freeze({ maxRows: 1e5, maxPages: 1e4, maxCells: 2e6, maxChartComponents: 5e4, maxOutputBytes: 1e8, maxPreparedBytes: 64e6, maxDurationMs: 12e4 });
|
|
2
|
-
class f extends Error {
|
|
3
|
-
constructor(t, n, r) {
|
|
4
|
-
super(n), this.code = t, this.path = r, this.name = "ReportRuntimeError";
|
|
5
|
-
}
|
|
6
|
-
}
|
|
7
|
-
function h(e) {
|
|
8
|
-
if (!e?.aborted) return;
|
|
9
|
-
if (e.reason instanceof f) throw e.reason;
|
|
10
|
-
const t = new Error("报表执行已取消");
|
|
11
|
-
throw t.name = "AbortError", Object.defineProperty(t, "cause", { value: e.reason }), t;
|
|
12
|
-
}
|
|
13
|
-
function C(e, t, n) {
|
|
14
|
-
if (!Number.isFinite(n) || n < 0) throw new f("budget", `${t} 的执行统计无效`, `$.budget.${t}`);
|
|
15
|
-
const r = e[t];
|
|
16
|
-
if (r !== void 0 && n > r) throw new f("budget", `${t} 超出预算 ${r}(实际 ${n})`, `$.budget.${t}`);
|
|
17
|
-
}
|
|
18
|
-
function R(e) {
|
|
19
|
-
for (const [t, n] of Object.entries(e)) {
|
|
20
|
-
if (n !== void 0 && (!Number.isFinite(n) || n <= 0)) throw new f("budget", `${t} 应为正有限数字`, `$.budget.${t}`);
|
|
21
|
-
if (t !== "maxDurationMs" && n !== void 0 && !Number.isSafeInteger(n)) throw new f("budget", `${t} 应为正安全整数`, `$.budget.${t}`);
|
|
22
|
-
if (t === "maxDurationMs" && n !== void 0 && n > 2147483647) throw new f("budget", "maxDurationMs 不能超过 2147483647", `$.budget.${t}`);
|
|
23
|
-
if (t === "maxChartComponents" && n !== void 0 && n > 1e6) throw new f("budget", "maxChartComponents 不能超过 1000000", "$.budget.maxChartComponents");
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
async function L(e, t, n) {
|
|
27
|
-
const r = new AbortController(), o = () => r.abort(e?.reason);
|
|
28
|
-
e?.addEventListener("abort", o, { once: !0 }), e?.aborted && o();
|
|
29
|
-
const a = Date.now(), i = t === void 0 ? void 0 : setTimeout(() => r.abort(new f("timeout", `报表执行超过 ${t}ms`)), t);
|
|
30
|
-
let s;
|
|
31
|
-
try {
|
|
32
|
-
h(r.signal);
|
|
33
|
-
const d = new Promise((m, u) => {
|
|
34
|
-
s = () => {
|
|
35
|
-
try {
|
|
36
|
-
h(r.signal);
|
|
37
|
-
} catch (w) {
|
|
38
|
-
u(w);
|
|
39
|
-
}
|
|
40
|
-
}, r.signal.addEventListener("abort", s, { once: !0 });
|
|
41
|
-
}), b = await Promise.race([n(r.signal), d]);
|
|
42
|
-
if (h(r.signal), t !== void 0 && Date.now() - a > t) throw new f("timeout", `报表执行超过 ${t}ms`);
|
|
43
|
-
return b;
|
|
44
|
-
} finally {
|
|
45
|
-
i !== void 0 && clearTimeout(i), s && r.signal.removeEventListener("abort", s), e?.removeEventListener("abort", o);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
const D = new Uint32Array([
|
|
49
|
-
1116352408,
|
|
50
|
-
1899447441,
|
|
51
|
-
3049323471,
|
|
52
|
-
3921009573,
|
|
53
|
-
961987163,
|
|
54
|
-
1508970993,
|
|
55
|
-
2453635748,
|
|
56
|
-
2870763221,
|
|
57
|
-
3624381080,
|
|
58
|
-
310598401,
|
|
59
|
-
607225278,
|
|
60
|
-
1426881987,
|
|
61
|
-
1925078388,
|
|
62
|
-
2162078206,
|
|
63
|
-
2614888103,
|
|
64
|
-
3248222580,
|
|
65
|
-
3835390401,
|
|
66
|
-
4022224774,
|
|
67
|
-
264347078,
|
|
68
|
-
604807628,
|
|
69
|
-
770255983,
|
|
70
|
-
1249150122,
|
|
71
|
-
1555081692,
|
|
72
|
-
1996064986,
|
|
73
|
-
2554220882,
|
|
74
|
-
2821834349,
|
|
75
|
-
2952996808,
|
|
76
|
-
3210313671,
|
|
77
|
-
3336571891,
|
|
78
|
-
3584528711,
|
|
79
|
-
113926993,
|
|
80
|
-
338241895,
|
|
81
|
-
666307205,
|
|
82
|
-
773529912,
|
|
83
|
-
1294757372,
|
|
84
|
-
1396182291,
|
|
85
|
-
1695183700,
|
|
86
|
-
1986661051,
|
|
87
|
-
2177026350,
|
|
88
|
-
2456956037,
|
|
89
|
-
2730485921,
|
|
90
|
-
2820302411,
|
|
91
|
-
3259730800,
|
|
92
|
-
3345764771,
|
|
93
|
-
3516065817,
|
|
94
|
-
3600352804,
|
|
95
|
-
4094571909,
|
|
96
|
-
275423344,
|
|
97
|
-
430227734,
|
|
98
|
-
506948616,
|
|
99
|
-
659060556,
|
|
100
|
-
883997877,
|
|
101
|
-
958139571,
|
|
102
|
-
1322822218,
|
|
103
|
-
1537002063,
|
|
104
|
-
1747873779,
|
|
105
|
-
1955562222,
|
|
106
|
-
2024104815,
|
|
107
|
-
2227730452,
|
|
108
|
-
2361852424,
|
|
109
|
-
2428436474,
|
|
110
|
-
2756734187,
|
|
111
|
-
3204031479,
|
|
112
|
-
3329325298
|
|
113
|
-
]), c = (e, t) => e >>> t | e << 32 - t;
|
|
114
|
-
function l(e, t, n) {
|
|
115
|
-
const r = new DataView(e.buffer, e.byteOffset + t, 64);
|
|
116
|
-
for (let o = 0; o < 16; o++) n[o] = r.getUint32(o * 4);
|
|
117
|
-
for (let o = 16; o < 64; o++) {
|
|
118
|
-
const a = n[o - 15], i = n[o - 2], s = c(a, 7) ^ c(a, 18) ^ a >>> 3, d = c(i, 17) ^ c(i, 19) ^ i >>> 10;
|
|
119
|
-
n[o] = n[o - 16] + s + n[o - 7] + d;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
function v(e, t) {
|
|
123
|
-
let n = e[0], r = e[1], o = e[2], a = e[3], i = e[4], s = e[5], d = e[6], b = e[7];
|
|
124
|
-
for (let m = 0; m < 64; m++) {
|
|
125
|
-
const u = c(i, 6) ^ c(i, 11) ^ c(i, 25), w = i & s ^ ~i & d, g = b + u + w + D[m] + t[m] >>> 0, p = c(n, 2) ^ c(n, 13) ^ c(n, 22), A = n & r ^ n & o ^ r & o, E = p + A >>> 0;
|
|
126
|
-
b = d, d = s, s = i, i = a + g >>> 0, a = o, o = r, r = n, n = g + E >>> 0;
|
|
127
|
-
}
|
|
128
|
-
e[0] = e[0] + n, e[1] = e[1] + r, e[2] = e[2] + o, e[3] = e[3] + a, e[4] = e[4] + i, e[5] = e[5] + s, e[6] = e[6] + d, e[7] = e[7] + b;
|
|
129
|
-
}
|
|
130
|
-
function x(e) {
|
|
131
|
-
const t = new Uint8Array(Math.ceil((e.byteLength + 9) / 64) * 64);
|
|
132
|
-
t.set(e), t[e.byteLength] = 128;
|
|
133
|
-
const n = new DataView(t.buffer);
|
|
134
|
-
return n.setUint32(t.length - 8, Math.floor(e.byteLength / 536870912)), n.setUint32(t.length - 4, e.byteLength * 8 >>> 0), t;
|
|
135
|
-
}
|
|
136
|
-
const y = () => new Uint32Array([1779033703, 3144134277, 1013904242, 2773480762, 1359893119, 2600822924, 528734635, 1541459225]), $ = (e) => Array.from(e, (t) => t.toString(16).padStart(8, "0")).join("");
|
|
137
|
-
function O(e) {
|
|
138
|
-
const t = x(e), n = y(), r = new Uint32Array(64);
|
|
139
|
-
for (let o = 0; o < t.length; o += 64)
|
|
140
|
-
l(t, o, r), v(n, r);
|
|
141
|
-
return $(n);
|
|
142
|
-
}
|
|
143
|
-
async function P(e) {
|
|
144
|
-
const t = x(e), n = y(), r = new Uint32Array(64);
|
|
145
|
-
for (let o = 0; o < t.length; o += 64)
|
|
146
|
-
o > 0 && o % 262144 === 0 && await new Promise((a) => setTimeout(a, 0)), l(t, o, r), v(n, r);
|
|
147
|
-
return $(n);
|
|
148
|
-
}
|
|
149
|
-
export {
|
|
150
|
-
U as D,
|
|
151
|
-
f as R,
|
|
152
|
-
P as a,
|
|
153
|
-
C as b,
|
|
154
|
-
L as c,
|
|
155
|
-
O as p,
|
|
156
|
-
h as t,
|
|
157
|
-
R as v
|
|
158
|
-
};
|
package/dist/sha256-DgZAKXqI.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const U=Object.freeze({maxRows:1e5,maxPages:1e4,maxCells:2e6,maxChartComponents:5e4,maxOutputBytes:1e8,maxPreparedBytes:64e6,maxDurationMs:12e4});class d extends Error{constructor(t,r,n){super(r),this.code=t,this.path=n,this.name="ReportRuntimeError"}}function m(e){if(!e?.aborted)return;if(e.reason instanceof d)throw e.reason;const t=new Error("报表执行已取消");throw t.name="AbortError",Object.defineProperty(t,"cause",{value:e.reason}),t}function R(e,t,r){if(!Number.isFinite(r)||r<0)throw new d("budget",`${t} 的执行统计无效`,`$.budget.${t}`);const n=e[t];if(n!==void 0&&r>n)throw new d("budget",`${t} 超出预算 ${n}(实际 ${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 d("budget",`${t} 应为正有限数字`,`$.budget.${t}`);if(t!=="maxDurationMs"&&r!==void 0&&!Number.isSafeInteger(r))throw new d("budget",`${t} 应为正安全整数`,`$.budget.${t}`);if(t==="maxDurationMs"&&r!==void 0&&r>2147483647)throw new d("budget","maxDurationMs 不能超过 2147483647",`$.budget.${t}`);if(t==="maxChartComponents"&&r!==void 0&&r>1e6)throw new d("budget","maxChartComponents 不能超过 1000000","$.budget.maxChartComponents")}}async function T(e,t,r){const n=new AbortController,o=()=>n.abort(e?.reason);e?.addEventListener("abort",o,{once:!0}),e?.aborted&&o();const a=Date.now(),i=t===void 0?void 0:setTimeout(()=>n.abort(new d("timeout",`报表执行超过 ${t}ms`)),t);let s;try{m(n.signal);const f=new Promise((u,l)=>{s=()=>{try{m(n.signal)}catch(h){l(h)}},n.signal.addEventListener("abort",s,{once:!0})}),b=await Promise.race([r(n.signal),f]);if(m(n.signal),t!==void 0&&Date.now()-a>t)throw new d("timeout",`报表执行超过 ${t}ms`);return b}finally{i!==void 0&&clearTimeout(i),s&&n.signal.removeEventListener("abort",s),e?.removeEventListener("abort",o)}}const C=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]),c=(e,t)=>e>>>t|e<<32-t;function g(e,t,r){const n=new DataView(e.buffer,e.byteOffset+t,64);for(let o=0;o<16;o++)r[o]=n.getUint32(o*4);for(let o=16;o<64;o++){const a=r[o-15],i=r[o-2],s=c(a,7)^c(a,18)^a>>>3,f=c(i,17)^c(i,19)^i>>>10;r[o]=r[o-16]+s+r[o-7]+f}}function v(e,t){let r=e[0],n=e[1],o=e[2],a=e[3],i=e[4],s=e[5],f=e[6],b=e[7];for(let u=0;u<64;u++){const l=c(i,6)^c(i,11)^c(i,25),h=i&s^~i&f,w=b+l+h+C[u]+t[u]>>>0,E=c(r,2)^c(r,13)^c(r,22),A=r&n^r&o^n&o,p=E+A>>>0;b=f,f=s,s=i,i=a+w>>>0,a=o,o=n,n=r,r=w+p>>>0}e[0]=e[0]+r,e[1]=e[1]+n,e[2]=e[2]+o,e[3]=e[3]+a,e[4]=e[4]+i,e[5]=e[5]+s,e[6]=e[6]+f,e[7]=e[7]+b}function x(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 y=()=>new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),$=e=>Array.from(e,t=>t.toString(16).padStart(8,"0")).join("");function L(e){const t=x(e),r=y(),n=new Uint32Array(64);for(let o=0;o<t.length;o+=64)g(t,o,n),v(r,n);return $(r)}async function B(e){const t=x(e),r=y(),n=new Uint32Array(64);for(let o=0;o<t.length;o+=64)o>0&&o%262144===0&&await new Promise(a=>setTimeout(a,0)),g(t,o,n),v(r,n);return $(r)}exports.DEFAULT_REPORT_RUNTIME_BUDGET=U;exports.ReportRuntimeError=d;exports.assertBudget=R;exports.controlled=T;exports.portableSha256Hex=L;exports.portableSha256HexAsync=B;exports.throwIfAborted=m;exports.validateBudget=D;
|