@agile-team/mach-report 2.6.1 → 2.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +59 -8
- package/dist/ReportPreview-BKKDAv8e.js +4481 -0
- package/dist/ReportPreview-E3cm67Tk.cjs +6 -0
- package/dist/{assets-NVA_sftu.js → assets-B9qJku3V.js} +54 -57
- package/dist/assets-RZan7EyL.cjs +1 -0
- package/dist/capabilities-joSutDF8.js +63 -0
- package/dist/capabilities-xGTpnPjJ.cjs +1 -0
- package/dist/designer.cjs +1 -1
- package/dist/designer.d.cts +922 -753
- package/dist/designer.d.ts +922 -753
- package/dist/designer.js +490 -234
- package/dist/index.cjs +8 -8
- package/dist/index.d.cts +128 -3
- package/dist/index.d.ts +128 -3
- package/dist/index.js +971 -699
- package/dist/pdf.cjs +30 -30
- package/dist/pdf.d.cts +11 -3
- package/dist/pdf.d.ts +11 -3
- package/dist/pdf.js +1501 -1500
- package/dist/{plugin-Ds10VnQO.js → plugin-PCgxBVB2.js} +1 -1
- package/dist/{plugin-BqBkn_kI.cjs → plugin-mAfvgSey.cjs} +1 -1
- package/dist/progress-DD964VAB.js +102 -0
- package/dist/progress-KvhwXZ1Q.cjs +1 -0
- package/dist/{report-source-B9bENO0F.js → report-source-BXHNy_AD.js} +337 -332
- package/dist/report-source-CCAvFE3t.cjs +1 -0
- package/dist/server/node.d.cts +26 -3
- package/dist/server/node.d.ts +26 -3
- package/dist/server-node.cjs +1 -1
- package/dist/server-node.js +125 -92
- package/dist/server.cjs +1 -1
- package/dist/server.d.cts +28 -3
- package/dist/server.d.ts +28 -3
- package/dist/server.js +172 -164
- package/dist/style.css +1 -1
- package/dist/task-events-DQ276fn2.cjs +1 -0
- package/dist/task-events-Dpsvf_t2.js +47 -0
- package/dist/vue/async.d.cts +1553 -2083
- package/dist/vue/async.d.ts +1553 -2083
- package/dist/vue/index.d.cts +2465 -3310
- package/dist/vue/index.d.ts +2465 -3310
- package/dist/vue-async.cjs +1 -1
- package/dist/vue-async.js +3 -3
- package/dist/vue.cjs +1 -1
- package/dist/vue.js +159 -132
- package/dist/worker.cjs +1 -1
- package/dist/worker.d.cts +26 -3
- package/dist/worker.d.ts +26 -3
- package/dist/worker.js +110 -85
- package/dist/xlsx.cjs +14 -14
- package/dist/xlsx.d.cts +11 -3
- package/dist/xlsx.d.ts +11 -3
- package/dist/xlsx.js +656 -652
- package/package.json +2 -2
- package/dist/ReportPreview-Dk-28QAi.js +0 -2946
- package/dist/ReportPreview-FSvcBLjH.cjs +0 -6
- package/dist/assets-66UBlhES.cjs +0 -1
- package/dist/capabilities-CNjIirfo.js +0 -36
- package/dist/capabilities-D4xeVYSR.cjs +0 -1
- package/dist/grid-geometry-BNptEcMm.js +0 -65
- package/dist/grid-geometry-CZ_cYB6O.cjs +0 -1
- package/dist/report-source-BbNkkBDy.cjs +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("./render-plan-CckPEQyf.cjs"),I=require("./report-source-BbNkkBDy.cjs"),m=require("./style-CpwiOPyB.cjs"),X=require("./validate-DfHPD8wX.cjs"),O=require("./textwrap-CnGsEum6.cjs"),j=require("./grid-geometry-CZ_cYB6O.cjs"),z=require("./assets-66UBlhES.cjs"),H=require("./capabilities-D4xeVYSR.cjs"),_e=require("./page-window-index-DEjnM6IB.cjs"),F=require("./template-registry-DWExx0gU.cjs"),W=require("./param-validation-CiTxFeZ8.cjs"),ve=require("./number-format-CZ2T_5kF.cjs"),ze={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 P(e,t){return t?.classNames?.[e]??ze[e]}class He{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,`${m.round(m.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 M(e,t="unset"){return new He().add("all",t).add("display",e).add("box-sizing","border-box")}function be(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(m.resolveLineHeight(t))).add("text-align",t.align);const n=m.resolveFontSize(t,r);e.add("font-size",`${m.round(n.fontSizePx,2)}px`)}function Be(e,t,r){const n=t.style??{};be(e,n,r),e.add("background-color",n.backgroundColor).add("opacity",n.opacity!=null?String(n.opacity):void 0).add("transform",n.rotateDeg?`rotate(${n.rotateDeg}deg)`:void 0)}function je(e,t,r,n,o,l){const i=e.cell,a=l.createElement("td");a.className=P("cell",o),a.dataset.mrRowIndex=String(e.ri),a.dataset.mrColumnIndex=String(e.ci),a.setAttribute("role",t.table?.role==="header"?"columnheader":"cell"),i.colSpan&&(a.colSpan=i.colSpan),i.rowSpan&&(a.rowSpan=i.rowSpan);const s=m.mergeComponentStyles(t.style,i.style),d=M("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",s.backgroundColor).add("vertical-align",s.verticalAlign??"middle");be(d,s,n),d.applyTo(a);const c=l.createElement("div");c.className="mr-cell-content",M("flex").add("position","absolute").mm("left",r,n).mm("right",r,n).mm("top",r,n).mm("bottom",r,n).add("flex-direction","column").add("justify-content",s.verticalAlign==="top"?"flex-start":s.verticalAlign==="bottom"?"flex-end":"center").add("overflow-wrap","anywhere").add("overflow","hidden").applyTo(c),i.text!=null&&c.append(i.text);for(const u of i.children??[])c.appendChild(ie(u,n,o,l));return a.appendChild(c),a}function We(e,t,r,n){return z.resolveGridStrokes(e,t).map(o=>{const l=`${m.round(o.widthPt*r/72,2)}px solid ${o.color}`,i=n.createElement("div");i.className="mr-grid-edge",i.setAttribute("aria-hidden","true");const a=o.kind==="h";return M("block").add("position","absolute").add("pointer-events","none").mm("left",a?o.from:o.pos,r).mm("top",a?o.pos:o.from,r).mm("width",a?o.to-o.from:0,r).mm("height",a?0:o.to-o.from,r).add(a?"border-top":"border-left",l).applyTo(i),i})}function Ke(e,t,r,n,o){const l=o.createElement("table");l.className=P("grid",n),l.setAttribute("role","table"),M("block").add("position","relative").add("width","100%").add("height","100%").applyTo(l);const i=j.resolveGridLayout(e,t.widthMm,t.heightMm),a=o.createElement("tbody");M("contents").applyTo(a),l.appendChild(a);const s=e.cells.map(()=>{const c=o.createElement("tr");return c.className=P("row",n),c.setAttribute("role","row"),M("contents").applyTo(c),a.appendChild(c),c});for(const c of i.cells)s[c.ri].appendChild(je(c,t,e.paddingMm??.5,r,n,o));const d=o.createElement("div");return M("block").add("position","relative").add("width","100%").add("height","100%").applyTo(d),d.append(l,...We(i,t,r,o)),d}function Ve(e,t,r,n){const o=n.createElement("div");o.className=P("paragraph",r),M("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 l of e.segments||[]){const i=n.createElement("span");i.className=P("segment",r),i.textContent=l.kind==="field"?l.field??"":l.text??"";const a=M("inline");if(l.style){const s=l.style;a.add("color",s.color).add("font-family",s.fontFamily).add("font-weight",s.bold!=null?s.bold?"700":"400":void 0).add("font-style",s.italic!=null?s.italic?"italic":"normal":void 0).add("text-decoration",s.underline!=null?s.underline?"underline":"none":void 0),(s.fontSize!=null||s.fontSizePx!=null)&&a.add("font-size",`${m.round(m.resolveFontSize(s,t).fontSizePx,2)}px`)}a.applyTo(i),o.appendChild(i)}return o}function Ge(e,t,r,n){if(b.isRichText(e)){const o=n.createElement("div");o.className=P("rich",r),M("block").applyTo(o);for(const l of e.richParagraphs)o.appendChild(Ve(l,t,r,n));return o}if(Array.isArray(e.lines)&&e.lines.length>0){const o=n.createElement("div");o.className=P("lines",r),M("block").applyTo(o);for(const l of e.lines){const i=n.createElement("div");i.className=P("line",r),i.textContent=l,M("block").add("white-space","pre").add("min-height","1lh").applyTo(i),o.appendChild(i)}return o}return e.text??""}function Ue(e,t,r,n){const o=n.createElement("div");o.className=P("text",r);const l=e.style||{};return M("flex").add("width","100%").add("height","100%").add("flex-direction","column").add("justify-content",l.verticalAlign==="middle"?"center":l.verticalAlign==="bottom"?"flex-end":"flex-start").add("overflow-wrap","anywhere").add("overflow","hidden").applyTo(o),o.append(Ge(e,t,r,n)),o}function qe(e,t,r){const n=r.createElement("img");return n.className=P("image",t),n.src=e.imageData,M("block").add("width","100%").add("height","100%").add("object-fit","contain").applyTo(n),n.alt=e.kind,n}function he(e,t,r,n){const o=n.createElement("div");o.className=P("shape",r);const l=e.style||{},i=m.resolveStroke(l),a=m.resolveBoxBorders(l),s=`${m.round(i.widthPt*t/72,2)}px solid ${i.color}`,d=M("block");return e.grid?d.add("position","relative"):e.kind==="rect"?(a.top&&d.add("border-top",s),a.right&&d.add("border-right",s),a.bottom&&d.add("border-bottom",s),a.left&&d.add("border-left",s)):e.kind==="ellipse"?(a.inner&&d.add("border",s).add("border-radius","50%"),l.backgroundColor&&d.add("background-color",l.backgroundColor)):e.kind==="line"&&d.add("height","0").add("border-top",s),d.add("box-sizing","border-box").add("width","100%").add("height","100%"),d.applyTo(o),o}function Je(e,t,r){const n=r.createElementNS("http://www.w3.org/2000/svg","svg"),o=m.mmToPx(e.widthMm,t),l=m.mmToPx(e.heightMm,t);n.setAttribute("width",String(Math.max(1,o))),n.setAttribute("height",String(Math.max(1,l))),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(l):"0"),i.setAttribute("y2",e.lineDirection==="up"?"0":String(l));const a=m.resolveStroke({...e.style,borderColor:e.style?.lineColor??e.style?.borderColor});return i.setAttribute("stroke",a.color),i.setAttribute("stroke-width",String(a.widthPt*t/72)),n.appendChild(i),n}function ie(e,t,r,n){const o=n.createElement("div");o.className=`${P("comp",r)} mr-kind-${e.kind}`;const l=M("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(Be(l,e,t),l.applyTo(o),b.isImageBackedComponent(e))return o.appendChild(qe(e,r,n)),o;if(e.kind==="text")return o.appendChild(Ue(e,t,r,n)),o;if(e.grid){const a=he(e,t,r,n);return a.appendChild(Ke(e.grid,e,t,r,n)),o.appendChild(a),o}if(e.kind==="line"&&e.lineDirection)return o.appendChild(Je(e,t,n)),o;if(e.kind==="line"||e.kind==="rect"||e.kind==="ellipse")return o.appendChild(he(e,t,r,n)),o;const i=n.createElement("div");return i.className=P("unknown",r),M("block").applyTo(i),i.textContent=e.fallbackText??`[${e.kind}]`,i.dataset.mrUnsupported=e.kind,i.setAttribute("role","note"),o.appendChild(i),o}function ye(e,t,r,n){const o=n.createElement("div");return o.className=P("page",r),M("block","initial").add("position","relative").add("font-family",b.DEFAULT_FONT_FAMILY).add("font-size",`${m.round(m.resolveFontSize(void 0,t).fontSizePx,2)}px`).add("line-height",String(m.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",b.DEFAULT_TEXT_COLOR).add("overflow","hidden").add("box-sizing","border-box").applyTo(o),e.components.forEach((l,i)=>{const a=ie(l,t,r,n);a.dataset.mrComponentIndex=String(i),o.appendChild(a)}),o}function Ye(e,t,r={}){const n=r.dpi??96;H.reportOutputDiagnostics(e,"dom",r);const o=t.createElement("div");return o.className=P("root",r),M("block").applyTo(o),o.dataset.schemaVersion=e.schemaVersion,e.pages.forEach(l=>{o.appendChild(ye(l,n,r,t))}),o}function $(e){if(e?.aborted)throw e.reason??new DOMException("The operation was aborted.","AbortError")}const Xe=(e,t)=>($(t),/^data:image\/(?:png|jpe?g|webp|gif|svg\+xml)[;,]/i.test(e)?new Promise((r,n)=>{const o=new Image,l=()=>{o.onload=null,o.onerror=null,t?.removeEventListener("abort",i)},i=()=>{l(),o.src="",n(t?.reason??new DOMException("The operation was aborted.","AbortError"))};o.onload=()=>{l(),r(o)},o.onerror=()=>{l(),n(new Error("Image could not be decoded for Canvas output."))},t?.addEventListener("abort",i,{once:!0}),o.src=e}):Promise.reject(new TypeError("Canvas imageData must be an image data URL; provide imageLoader for other sources.")));function Ze(e,t,r){return $(r),r?new Promise((n,o)=>{const l=()=>o(r.reason??new DOMException("The operation was aborted.","AbortError"));r.addEventListener("abort",l,{once:!0}),Promise.resolve().then(()=>e(t,r)).then(n,o).finally(()=>r.removeEventListener("abort",l))}):e(t)}async function Qe(e,t,r){const n=new Map;for(const o of e.components)!b.isImageBackedComponent(o)||n.has(o.imageData)||n.set(o.imageData,await Ze(t,o.imageData,r));return $(r),n}function et(e,t,r,n,o,l){const i=t,a=i.naturalWidth??i.width??o,s=i.naturalHeight??i.height??l;if(a<=0||s<=0)throw new RangeError("Decoded Canvas image dimensions must be positive.");const d=Math.min(o/a,l/s),c=a*d,u=s*d;e.drawImage(t,r+(o-c)/2,n+(l-u)/2,c,u)}function Me(e){return _e.createPageWindowIndex(e.pageHeightsPx,e.gapPx).window(e.viewportHeightPx,e.scrollTopPx,e.overscan)}const ae=96/25.4;function Z(e,t=96){const r=t/96*ae;return{widthPx:Math.max(1,Math.round(e.pageWidthMm*r)),heightPx:Math.max(1,Math.round(e.pageHeightMm*r))}}function Te(e,t,r,n=64e6){if(!Number.isFinite(t)||t<=0||!Number.isFinite(r)||r<=0)throw new RangeError("Canvas dpr and dpi must be positive finite numbers.");if(!Number.isFinite(n)||n<=0)throw new RangeError("maxCanvasPixels must be positive and finite.");const o=Z(e,r),l=Math.round(o.widthPx*t),i=Math.round(o.heightPx*t);if(!Number.isSafeInteger(l)||!Number.isSafeInteger(i)||l*i>n)throw new RangeError("Canvas page exceeds maxCanvasPixels; reduce resolution or split the report.");return{width:l,height:i}}function Ee(e,t,r,n){const o=document.createElement("canvas"),{widthPx:l,heightPx:i}=Z(e,r),a=Te(e,t,r,n);o.width=a.width,o.height=a.height,o.style.width=`${l}px`,o.style.height=`${i}px`;const s=o.getContext("2d");if(!s)throw new Error("当前环境不支持 Canvas 2D(测试需真浏览器,见 e2e/canvas.spec.ts)");return s.scale(t,t),s.fillStyle="#ffffff",s.fillRect(0,0,l,i),{canvas:o,ctx:s}}function tt(e,t=96){return m.resolveFontSize(e,t).fontSizePx}function xe(e,t,r,n,o,l,i,a="top"){e.font=`${t.italic?"italic ":""}${t.bold?"bold ":""}${t.fontSizePx}px ${i}`,"letterSpacing"in e&&(e.letterSpacing="0px"),e.fillStyle=t.color,e.textBaseline="alphabetic";const s=t.fontSizePx*t.lineHeight,d=t.text===""?[""]:t.text.split(`
|
|
2
|
-
`),c
|
|
3
|
-
`);
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const x=require("./render-plan-CckPEQyf.cjs"),F=require("./report-source-CCAvFE3t.cjs"),f=require("./style-CpwiOPyB.cjs"),ne=require("./validate-DfHPD8wX.cjs"),_=require("./textwrap-CnGsEum6.cjs"),j=require("./progress-KvhwXZ1Q.cjs"),W=require("./assets-RZan7EyL.cjs"),$=require("./capabilities-xGTpnPjJ.cjs"),Je=require("./page-window-index-DEjnM6IB.cjs"),D=require("./template-registry-DWExx0gU.cjs"),V=require("./param-validation-CiTxFeZ8.cjs"),Ce=require("./number-format-CZ2T_5kF.cjs"),Xe={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 P(e,t){return t?.classNames?.[e]??Xe[e]}class Ze{constructor(){this.props=[]}add(t,n){return n==null||n===!1||n===""?this:(this.props.push([t,String(n)]),this)}mm(t,n,r,o=2){return this.add(t,`${f.round(f.mmToPx(n,r),o)}px`)}toString(){let t="";for(const[n,r]of this.props)t+=`${n}:${r};`;return t}applyTo(t){const n=this.toString();n&&(t.style.cssText=n)}}function E(e,t="unset"){return new Ze().add("all",t).add("display",e).add("box-sizing","border-box")}function Re(e,t,n){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 r=f.resolveFontSize(t,n);e.add("font-size",`${f.round(r.fontSizePx,2)}px`)}function Qe(e,t,n){const r=t.style??{};Re(e,r,n),e.add("background-color",r.backgroundColor).add("opacity",r.opacity!=null?String(r.opacity):void 0).add("transform",r.rotateDeg?`rotate(${r.rotateDeg}deg)`:void 0)}function et(e,t,n,r,o,s){const l=e.cell,i=s.createElement("td");i.className=P("cell",o),i.dataset.mrRowIndex=String(e.ri),i.dataset.mrColumnIndex=String(e.ci),i.setAttribute("role",t.table?.role==="header"?"columnheader":"cell"),l.colSpan&&(i.colSpan=l.colSpan),l.rowSpan&&(i.rowSpan=l.rowSpan);const a=f.mergeComponentStyles(t.style,l.style),c=E("block").add("position","absolute").mm("left",e.xMm,r).mm("top",e.yMm,r).mm("width",e.widthMm,r).mm("height",e.heightMm,r).add("background-color",a.backgroundColor).add("vertical-align",a.verticalAlign??"middle");Re(c,a,r),c.applyTo(i);const d=s.createElement("div");d.className="mr-cell-content",E("flex").add("position","absolute").mm("left",n,r).mm("right",n,r).mm("top",n,r).mm("bottom",n,r).add("flex-direction","column").add("justify-content",a.verticalAlign==="top"?"flex-start":a.verticalAlign==="bottom"?"flex-end":"center").add("overflow-wrap","anywhere").add("overflow","hidden").applyTo(d),l.text!=null&&d.append(l.text);for(const u of l.children??[])d.appendChild(ue(u,r,o,s));return i.appendChild(d),i}function tt(e,t,n,r){return W.resolveGridStrokes(e,t).map(o=>{const s=`${f.round(o.widthPt*n/72,2)}px solid ${o.color}`,l=r.createElement("div");l.className="mr-grid-edge",l.setAttribute("aria-hidden","true");const i=o.kind==="h";return E("block").add("position","absolute").add("pointer-events","none").mm("left",i?o.from:o.pos,n).mm("top",i?o.pos:o.from,n).mm("width",i?o.to-o.from:0,n).mm("height",i?0:o.to-o.from,n).add(i?"border-top":"border-left",s).applyTo(l),l})}function nt(e,t,n,r,o){const s=o.createElement("table");s.className=P("grid",r),s.setAttribute("role","table"),E("block").add("position","relative").add("width","100%").add("height","100%").applyTo(s);const l=j.resolveGridLayout(e,t.widthMm,t.heightMm),i=o.createElement("tbody");E("contents").applyTo(i),s.appendChild(i);const a=e.cells.map(()=>{const d=o.createElement("tr");return d.className=P("row",r),d.setAttribute("role","row"),E("contents").applyTo(d),i.appendChild(d),d});for(const d of l.cells)a[d.ri].appendChild(et(d,t,e.paddingMm??.5,n,r,o));const c=o.createElement("div");return E("block").add("position","relative").add("width","100%").add("height","100%").applyTo(c),c.append(s,...tt(l,t,n,o)),c}function rt(e,t,n,r){const o=r.createElement("div");o.className=P("paragraph",n),E("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 s of e.segments||[]){const l=r.createElement("span");l.className=P("segment",n),l.textContent=s.kind==="field"?s.field??"":s.text??"";const i=E("inline");if(s.style){const a=s.style;i.add("color",a.color).add("font-family",a.fontFamily).add("font-weight",a.bold!=null?a.bold?"700":"400":void 0).add("font-style",a.italic!=null?a.italic?"italic":"normal":void 0).add("text-decoration",a.underline!=null?a.underline?"underline":"none":void 0),(a.fontSize!=null||a.fontSizePx!=null)&&i.add("font-size",`${f.round(f.resolveFontSize(a,t).fontSizePx,2)}px`)}i.applyTo(l),o.appendChild(l)}return o}function ot(e,t,n,r){if(x.isRichText(e)){const o=r.createElement("div");o.className=P("rich",n),E("block").applyTo(o);for(const s of e.richParagraphs)o.appendChild(rt(s,t,n,r));return o}if(Array.isArray(e.lines)&&e.lines.length>0){const o=r.createElement("div");o.className=P("lines",n),E("block").applyTo(o);for(const s of e.lines){const l=r.createElement("div");l.className=P("line",n),l.textContent=s,E("block").add("white-space","pre").add("min-height","1lh").applyTo(l),o.appendChild(l)}return o}return e.text??""}function it(e,t,n,r){const o=r.createElement("div");o.className=P("text",n);const s=e.style||{};return E("flex").add("width","100%").add("height","100%").add("flex-direction","column").add("justify-content",s.verticalAlign==="middle"?"center":s.verticalAlign==="bottom"?"flex-end":"flex-start").add("overflow-wrap","anywhere").add("overflow","hidden").applyTo(o),o.append(ot(e,t,n,r)),o}function at(e,t,n){const r=n.createElement("img");return r.className=P("image",t),r.src=e.imageData,E("block").add("width","100%").add("height","100%").add("object-fit","contain").applyTo(r),r.alt=e.kind,r}function ye(e,t,n,r){const o=r.createElement("div");o.className=P("shape",n);const s=e.style||{},l=f.resolveStroke(s),i=f.resolveBoxBorders(s),a=`${f.round(l.widthPt*t/72,2)}px solid ${l.color}`,c=E("block");return e.grid?c.add("position","relative"):e.kind==="rect"?(i.top&&c.add("border-top",a),i.right&&c.add("border-right",a),i.bottom&&c.add("border-bottom",a),i.left&&c.add("border-left",a)):e.kind==="ellipse"?(i.inner&&c.add("border",a).add("border-radius","50%"),s.backgroundColor&&c.add("background-color",s.backgroundColor)):e.kind==="line"&&c.add("height","0").add("border-top",a),c.add("box-sizing","border-box").add("width","100%").add("height","100%"),c.applyTo(o),o}function st(e,t,n){const r=n.createElementNS("http://www.w3.org/2000/svg","svg"),o=f.mmToPx(e.widthMm,t),s=f.mmToPx(e.heightMm,t);r.setAttribute("width",String(Math.max(1,o))),r.setAttribute("height",String(Math.max(1,s))),r.setAttribute("aria-hidden","true"),r.style.overflow="visible",r.style.display="block";const l=n.createElementNS("http://www.w3.org/2000/svg","line");l.setAttribute("x1","0"),l.setAttribute("x2",String(o)),l.setAttribute("y1",e.lineDirection==="up"?String(s):"0"),l.setAttribute("y2",e.lineDirection==="up"?"0":String(s));const i=f.resolveStroke({...e.style,borderColor:e.style?.lineColor??e.style?.borderColor});return l.setAttribute("stroke",i.color),l.setAttribute("stroke-width",String(i.widthPt*t/72)),r.appendChild(l),r}function ue(e,t,n,r){const o=r.createElement("div");o.className=`${P("comp",n)} mr-kind-${e.kind}`;const s=E("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(Qe(s,e,t),s.applyTo(o),x.isImageBackedComponent(e))return o.appendChild(at(e,n,r)),o;if(e.kind==="text")return o.appendChild(it(e,t,n,r)),o;if(e.grid){const i=ye(e,t,n,r);return i.appendChild(nt(e.grid,e,t,n,r)),o.appendChild(i),o}if(e.kind==="line"&&e.lineDirection)return o.appendChild(st(e,t,r)),o;if(e.kind==="line"||e.kind==="rect"||e.kind==="ellipse")return o.appendChild(ye(e,t,n,r)),o;const l=r.createElement("div");return l.className=P("unknown",n),E("block").applyTo(l),l.textContent=e.fallbackText??`[${e.kind}]`,l.dataset.mrUnsupported=e.kind,l.setAttribute("role","note"),o.appendChild(l),o}function Pe(e,t,n,r){const o=r.createElement("div");return o.className=P("page",n),E("block","initial").add("position","relative").add("font-family",x.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",x.DEFAULT_TEXT_COLOR).add("overflow","hidden").add("box-sizing","border-box").applyTo(o),e.components.forEach((s,l)=>{const i=ue(s,t,n,r);i.dataset.mrComponentIndex=String(l),o.appendChild(i)}),o}function lt(e,t,n={}){const r=n.dpi??96;$.reportOutputDiagnostics(e,"dom",n);const o=t.createElement("div");return o.className=P("root",n),E("block").applyTo(o),o.dataset.schemaVersion=e.schemaVersion,e.pages.forEach(s=>{o.appendChild(Pe(s,r,n,t))}),o}function N(e){if(e?.aborted)throw e.reason??new DOMException("The operation was aborted.","AbortError")}const ct=(e,t)=>(N(t),/^data:image\/(?:png|jpe?g|webp|gif|svg\+xml)[;,]/i.test(e)?new Promise((n,r)=>{const o=new Image,s=()=>{o.onload=null,o.onerror=null,t?.removeEventListener("abort",l)},l=()=>{s(),o.src="",r(t?.reason??new DOMException("The operation was aborted.","AbortError"))};o.onload=()=>{s(),n(o)},o.onerror=()=>{s(),r(new Error("Image could not be decoded for Canvas output."))},t?.addEventListener("abort",l,{once:!0}),o.src=e}):Promise.reject(new TypeError("Canvas imageData must be an image data URL; provide imageLoader for other sources.")));function dt(e,t,n){return N(n),n?new Promise((r,o)=>{const s=()=>o(n.reason??new DOMException("The operation was aborted.","AbortError"));n.addEventListener("abort",s,{once:!0}),Promise.resolve().then(()=>e(t,n)).then(r,o).finally(()=>n.removeEventListener("abort",s))}):e(t)}async function ut(e,t,n){const r=new Map;for(const o of e.components)!x.isImageBackedComponent(o)||r.has(o.imageData)||r.set(o.imageData,await dt(t,o.imageData,n));return N(n),r}function mt(e,t,n,r,o,s){const l=t,i=l.naturalWidth??l.width??o,a=l.naturalHeight??l.height??s;if(i<=0||a<=0)throw new RangeError("Decoded Canvas image dimensions must be positive.");const c=Math.min(o/i,s/a),d=i*c,u=a*c;e.drawImage(t,n+(o-d)/2,r+(s-u)/2,d,u)}function Ie(e){return Je.createPageWindowIndex(e.pageHeightsPx,e.gapPx).window(e.viewportHeightPx,e.scrollTopPx,e.overscan)}const me=96/25.4;function re(e,t=96){const n=t/96*me;return{widthPx:Math.max(1,Math.round(e.pageWidthMm*n)),heightPx:Math.max(1,Math.round(e.pageHeightMm*n))}}function Ae(e,t,n,r=64e6){if(!Number.isFinite(t)||t<=0||!Number.isFinite(n)||n<=0)throw new RangeError("Canvas dpr and dpi must be positive finite numbers.");if(!Number.isFinite(r)||r<=0)throw new RangeError("maxCanvasPixels must be positive and finite.");const o=re(e,n),s=Math.round(o.widthPx*t),l=Math.round(o.heightPx*t);if(!Number.isSafeInteger(s)||!Number.isSafeInteger(l)||s*l>r)throw new RangeError("Canvas page exceeds maxCanvasPixels; reduce resolution or split the report.");return{width:s,height:l}}function ke(e,t,n,r){const o=document.createElement("canvas"),{widthPx:s,heightPx:l}=re(e,n),i=Ae(e,t,n,r);o.width=i.width,o.height=i.height,o.style.width=`${s}px`,o.style.height=`${l}px`;const a=o.getContext("2d");if(!a)throw new Error("当前环境不支持 Canvas 2D(测试需真浏览器,见 e2e/canvas.spec.ts)");return a.scale(t,t),a.fillStyle="#ffffff",a.fillRect(0,0,s,l),{canvas:o,ctx:a}}function ft(e,t=96){return f.resolveFontSize(e,t).fontSizePx}function Fe(e,t,n,r,o,s,l,i="top"){e.font=`${t.italic?"italic ":""}${t.bold?"bold ":""}${t.fontSizePx}px ${l}`,"letterSpacing"in e&&(e.letterSpacing="0px"),e.fillStyle=t.color,e.textBaseline="alphabetic";const a=t.fontSizePx*t.lineHeight,c=t.text===""?[""]:t.text.split(`
|
|
2
|
+
`),d=c.length*a;let u=r;i==="middle"?u=r+(s-d)/2:i==="bottom"&&(u=r+s-d),c.forEach((m,h)=>{ht(e,m,t,n,u+h*a+t.fontSizePx*.8,o)}),e.textAlign="left"}function ht(e,t,n,r,o,s){const l=Array.from(t),i=n.letterSpacingPx??0;if(!i){e.textAlign=n.align==="center"?"center":n.align==="right"?"right":"left";const u=n.align==="center"?r+s/2:n.align==="right"?r+s:r;e.fillText(t,u,o);return}const a=e.measureText(t).width+Math.max(0,l.length-1)*i,c=n.align==="center"?r+(s-a)/2:n.align==="right"?r+s-a:r;e.textAlign="left";let d="";l.forEach((u,m)=>{e.fillText(u,c+e.measureText(d).width+m*i,o),d+=u})}function gt(e,t,n,r,o,s,l){for(const i of W.resolveGridStrokes(t,n))e.strokeStyle=i.color,e.lineWidth=f.ptToPx(i.widthPt,l),e.beginPath(),i.kind==="v"?(e.moveTo(r+i.pos*s,o+i.from*s),e.lineTo(r+i.pos*s,o+i.to*s)):(e.moveTo(r+i.from*s,o+i.pos*s),e.lineTo(r+i.to*s,o+i.pos*s)),e.stroke()}function pt(e,t,n,r,o,s){e.beginPath(),t.top&&(e.moveTo(n,r),e.lineTo(n+o,r)),t.right&&(e.moveTo(n+o,r),e.lineTo(n+o,r+s)),t.bottom&&(e.moveTo(n+o,r+s),e.lineTo(n,r+s)),t.left&&(e.moveTo(n,r+s),e.lineTo(n,r)),e.stroke()}function wt(e,t,n,r,o,s,l,i,a,c,d){const u=j.resolveGridLayout(t,s/i,l/i);for(const h of u.cells){const g=h.cell.style?.backgroundColor??n.style?.backgroundColor;g&&(e.fillStyle=g,e.fillRect(r+h.xMm*i,o+h.yMm*i,h.widthMm*i,h.heightMm*i))}gt(e,u,n,r,o,i,a);const m=t.paddingMm??.5;for(const h of u.cells){const g=h.cell.text??"";if(!g)continue;const p=f.mergeComponentStyles(n.style,h.cell.style),y=f.resolveFontSize(p,a),S=Math.max(0,h.widthMm-2*m),C=_.wrapText(g,S,{fontSizePt:y.fontSizePt,bold:p.bold,italic:p.italic,fontFamily:p.fontFamily??c,letterSpacingPt:p.letterSpacing},d).join(`
|
|
3
|
+
`);Fe(e,{text:C,fontSizePx:y.fontSizePx,bold:p.bold??!1,italic:p.italic,color:f.resolveTextColor(p,x.DEFAULT_TEXT_COLOR),align:p.align??"left",lineHeight:f.resolveLineHeight(p),letterSpacingPx:f.ptToPx(p.letterSpacing??0,a)},r+(h.xMm+m)*i,o+(h.yMm+m)*i,S*i,Math.max(0,h.heightMm-2*m)*i,p.fontFamily??c,p.verticalAlign??"middle")}}function vt(e,t,n,r,o,s,l,i,a){const c=t.style??{},d=f.resolveFontSize(c,l),u=x.isRichText(t)?t.richParagraphs.map(m=>m.segments.map(h=>h.text??h.field??"").join("")).join(`
|
|
4
4
|
`):t.lines?.length?t.lines.join(`
|
|
5
|
-
`):
|
|
6
|
-
`);xe(e,{text:u,fontSizePx:c.fontSizePx,bold:d.bold??!1,italic:d.italic,color:m.resolveTextColor(d),align:d.align??"left",lineHeight:m.resolveLineHeight(d),letterSpacingPx:m.ptToPx(d.letterSpacing??0,i)},r,n,o,l,d.fontFamily??a,d.verticalAlign)}function se(e,t,r,n,o,l,i){const a=t.leftMm*r,s=t.topMm*r,d=t.widthMm*r,c=t.heightMm*r,u=t.style??{};if(b.isImageBackedComponent(t)){const f=i?.get(t.imageData);f?et(e,f,a,s,d,c):ge(e,t,a,s,d,c);return}if(t.grid){it(e,t.grid,t,a,s,d,c,r,n,o,l);return}switch(t.kind){case"text":{at(e,t,a,s,d,c,n,o,l);break}case"rect":{const f=m.resolveStroke(u),h=m.resolveBoxBorders(u);u.backgroundColor&&(e.fillStyle=u.backgroundColor,e.fillRect(a,s,d,c)),h.inner&&(e.strokeStyle=f.color,e.lineWidth=m.ptToPx(f.widthPt,n),ot(e,h,a,s,d,c));break}case"line":{const f=m.resolveStroke({...u,borderColor:u.lineColor??u.borderColor});e.strokeStyle=f.color,e.lineWidth=m.ptToPx(f.widthPt,n),e.beginPath();const h=t.lineDirection==="up"?s+c:t.lineDirection==="down"?s:s+c/2,p=t.lineDirection==="up"?s:t.lineDirection==="down"?s+c:s+c/2;e.moveTo(a,h),e.lineTo(a+d,p),e.stroke();break}case"ellipse":{const f=m.resolveStroke(u);e.strokeStyle=f.color,e.lineWidth=m.ptToPx(f.widthPt,n),u.backgroundColor&&(e.fillStyle=u.backgroundColor,e.beginPath(),e.ellipse(a+d/2,s+c/2,d/2,c/2,0,0,Math.PI*2),e.fill()),e.beginPath(),e.ellipse(a+d/2,s+c/2,d/2,c/2,0,0,Math.PI*2),e.stroke();break}default:ge(e,t,a,s,d,c);break}}function ge(e,t,r,n,o,l){e.save(),e.strokeStyle="#94a3b8",e.strokeRect(r,n,o,l),e.fillStyle="#64748b",e.font="12px sans-serif",e.fillText(t.fallbackText??`[${t.kind}]`,r+3,n+14),e.restore()}async function st(e,t={}){if(typeof document>"u")throw new Error("renderPlanToImages 需要浏览器环境(SSR/Node 请在客户端钩子中调用)");const{format:r="png",quality:n=.92,...o}=t;if(r!=="png"&&r!=="jpeg")throw new TypeError("Image format must be png or jpeg.");if(!Number.isFinite(n)||n<0||n>1)throw new RangeError("Image quality must be between 0 and 1.");$(t.signal);const l=await z.resolvePlanAssets(e,{...t,format:"canvas"});e=l.plan;const i=[...l.diagnostics,...H.reportOutputDiagnostics(e,"canvas",t)],a=r==="jpeg"?"image/jpeg":"image/png",s=[],d=Math.min(e.pages.length-1,t.end??e.pages.length-1);for(let c=Math.max(0,t.start??0);c<=d;c++){$(t.signal);const u=await Se(e.pages[c],c,o,i);try{s.push(await lt(u,a,n,t.signal))}finally{u.width=0,u.height=0}}return $(t.signal),{blobs:s,diagnostics:i}}function lt(e,t,r,n){return $(n),new Promise((o,l)=>{const i=()=>l(n?.reason??new DOMException("The operation was aborted.","AbortError"));n?.addEventListener("abort",i,{once:!0});try{e.toBlob(a=>{n?.removeEventListener("abort",i),a?o(a):l(new Error("Canvas encoding failed; no empty image was emitted."))},t,r)}catch(a){n?.removeEventListener("abort",i),l(a)}})}function dt(e,t={}){if(typeof document>"u")throw new Error("renderPlanToCanvas 需要浏览器环境(SSR 请在客户端钩子中调用)");const r=t.dpr??(typeof devicePixelRatio=="number"?devicePixelRatio:1),n=t.dpi??96,o=n/96*ae,l=t.fontFamily??b.DEFAULT_FONT_FAMILY,i=t.measurer??O.heuristicMeasurer,a=Math.max(0,t.start??0),s=Math.min(e.pages.length-1,t.end??e.pages.length-1),d=[],c=H.reportOutputDiagnostics(e,"canvas",t);for(let u=a;u<=s;u++){const f=e.pages[u],{canvas:h,ctx:p}=Ee(f,r,n,t.maxCanvasPixels);for(const g of f.components){if(b.isImageBackedComponent(g)){const v={code:"async-image-required",severity:"warning",format:"canvas",pageIndex:u,componentIndex:f.components.indexOf(g),kind:g.kind,nid:g.nid,message:"Use renderPlanToCanvasAsync or renderPlanToImages to decode and include images."};c.push(v),t.onDiagnostic?.(v)}se(p,g,o,n,l,i)}d.push(h)}return{canvases:d,diagnostics:c}}async function ct(e,t={}){if(typeof document>"u")throw new Error("renderPlanToCanvasAsync 需要浏览器环境(Node 请使用 PDF 或 XLSX 输出)");$(t.signal);const r=await z.resolvePlanAssets(e,{...t,format:"canvas"});e=r.plan;const n=[...r.diagnostics,...H.reportOutputDiagnostics(e,"canvas",t)],o=[],l=Math.min(e.pages.length-1,t.end??e.pages.length-1);for(let i=Math.max(0,t.start??0);i<=l;i++)o.push(await Se(e.pages[i],i,t,n));return{canvases:o,diagnostics:n}}async function Se(e,t,r,n){const o=r.dpr??(typeof devicePixelRatio=="number"?devicePixelRatio:1),l=r.dpi??96,i=r.fontFamily??b.DEFAULT_FONT_FAMILY,a=await Pe(e,t,r,n);$(r.signal);const{canvas:s,ctx:d}=Ee(e,o,l,r.maxCanvasPixels);for(const c of e.components)se(d,c,l/25.4,l,i,r.measurer??O.heuristicMeasurer,a);return s}async function Pe(e,t,r,n){const o=r.imageLoader??Xe;return Qe(e,async(l,i)=>{try{return await o(l,i)}catch(a){if(i?.aborted)throw a;const s=e.components.findIndex(u=>u.imageData===l),d=e.components[s],c={code:"image-decode-failed",severity:"warning",format:"canvas",pageIndex:t,componentIndex:s,kind:d.kind,nid:d.nid,message:"Image decoding failed; raster output was cancelled instead of omitting the image."};throw n.push(c),r.onDiagnostic?.(c),a}},r.signal)}function ut(e,t={}){const r=t.dpr??(typeof devicePixelRatio=="number"?devicePixelRatio:1),n=t.dpi??96,o=n/96*ae,l=t.fontFamily??b.DEFAULT_FONT_FAMILY,i=t.measurer??O.heuristicMeasurer,a=t.overscan??1,s=t.gapPx??18,d=t.pagesPerFrame??1,c=e.pages.map(w=>w.pageHeightMm*o),u=Math.max(1,...e.pages.map(w=>w.pageWidthMm*o)),f={start:0,end:-1};let h=null,p=null,g=null,v=null,E=[],x=0,k=[],G=0,K=new AbortController;const ue=[];function Oe(){const w=h;w.innerHTML="",p=document.createElement("div"),p.style.cssText=`width:${u}px;margin:0 auto;`,g=document.createElement("div"),v=document.createElement("div"),p.appendChild(g),E=[];const S=Math.min(e.pages.length,3+a*2);for(let _=0;_<S;_++){const y=document.createElement("div");y.style.cssText=`margin:0 auto ${s}px;box-shadow:0 2px 8px rgba(0,0,0,.35);background:#fff;`,p.appendChild(y),E.push(y)}p.appendChild(v),w.appendChild(p)}async function Ne(w,S){const _=G,y=await z.resolvePlanAssets(e,{...t,signal:K.signal,format:"canvas",start:S,end:S});ue.push(...y.diagnostics);const C=y.plan.pages[S],J=await Pe(C,S,{...t,signal:K.signal},ue);if(_!==G||!h)return;const{widthPx:ne,heightPx:oe}=Z(C,n);let N=w.firstElementChild;(!N||N.tagName!=="CANVAS")&&(N=document.createElement("canvas"),w.innerHTML="",w.appendChild(N));const fe=Te(C,r,n,t.maxCanvasPixels);N.width=fe.width,N.height=fe.height,N.style.width=`${ne}px`,N.style.height=`${oe}px`;const B=N.getContext("2d");if(B){B.setTransform(1,0,0,1,0,0),B.scale(r,r),B.fillStyle="#ffffff",B.fillRect(0,0,ne,oe);for(const $e of C.components)se(B,$e,o,n,l,i,J);N.dataset.canvasPage=String(S),w.style.height=`${oe}px`,w.style.width=`${ne}px`}}function De(w){G++,f.start=w.start,f.end=w.end,g.style.height=`${w.start*s+c.slice(0,w.start).reduce((y,C)=>y+C,0)}px`;const S=e.pages.length-1-w.end;v.style.height=`${S*s+c.slice(w.end+1).reduce((y,C)=>y+C,0)}px`;const _=w.end-w.start+1;E.forEach((y,C)=>{if(C<_){y.style.display="";const J=w.start+C;y.style.height=`${c[J]??0}px`}else y.style.display="none"}),k=[];for(let y=w.start;y<=w.end;y++){const C=E[y-w.start];if(!C)continue;C.firstElementChild?.dataset?.canvasPage!==String(y)&&k.push(y)}re()}function re(){x||k.length===0||(x=requestAnimationFrame(()=>{x=0;let w=Math.max(1,d);for(;k.length>0&&w-- >0;){const S=k.shift(),_=E[S-f.start];_&&Ne(_,S).catch(()=>{})}k.length>0&&re()}))}function U(){x||(x=requestAnimationFrame(()=>{x=0;const w=h,S=Me({pageHeightsPx:c,viewportHeightPx:w.clientHeight,scrollTopPx:w.scrollTop,overscan:a,gapPx:s});S.start!==f.start||S.end!==f.end?De(S):re()}))}let q=null;return{attach(w){if(typeof document>"u")throw new Error("createCanvasPager 需要浏览器环境(SSR 请在客户端钩子中调用 attach)");$(t.signal),K=new AbortController,t.signal?.addEventListener("abort",me,{once:!0}),H.reportOutputDiagnostics(e,"canvas",t),h=w,Oe(),w.addEventListener("scroll",U,{passive:!0}),typeof ResizeObserver<"u"&&(q=new ResizeObserver(()=>U()),q.observe(w)),U()},destroy(){G++,K.abort(),t.signal?.removeEventListener("abort",me),x&&cancelAnimationFrame(x),x=0,q?.disconnect(),q=null,h?.removeEventListener("scroll",U),k=[],p?.remove(),h=null},window(){return{...f}}};function me(){K.abort(t.signal?.reason)}}function le(e,t,r){let n,o;if(typeof e=="string"){const l=m.PAPER_SIZES[e];if(!l)throw new Error(`未知纸张预设 "${e}"(可用:${Object.keys(m.PAPER_SIZES).join("/")})`);n=l.widthMm,o=l.heightMm}else typeof e=="number"?(n=e,o=t??297):(n=e.widthMm,o=e.heightMm);return r?{widthMm:o,heightMm:n}:{widthMm:n,heightMm:o}}class Ce{constructor(){this.pages=[],this.pending=null,this.templateParams=void 0}params(t){return this.templateParams=t,this}page(t="a4",r={},n){this.collect();const l=n!=null&&!("margins"in n)&&!("landscape"in n)&&("marginTopMm"in n||"marginBottomMm"in n||"marginLeftMm"in n||"marginRightMm"in n)?{margins:n}:typeof r=="number"?n??{}:r,{widthMm:i,heightMm:a}=le(t,typeof r=="number"?r:void 0,l.landscape),s=l.margins??{};return this.pending=new Re(this,{widthMm:i,heightMm:a,marginTopMm:s.marginTopMm??10,marginBottomMm:s.marginBottomMm??10,marginLeftMm:s.marginLeftMm??10,marginRightMm:s.marginRightMm??10}),this.pending}collect(){this.pending&&(this.pages.push(this.pending.buildPage()),this.pending=null)}build(){if(this.collect(),this.pages.length===0)throw new Error("模板至少需要一页:先调用 .page() 添加内容");return this.templateParams?{params:this.templateParams,pages:this.pages}:{pages:this.pages}}}class Re{constructor(t,r){this.parent=t,this.page=r,this.components=[]}text(t,r={},n={}){return this.components.push({kind:"text",leftMm:r.leftMm??0,topMm:r.topMm??0,widthMm:r.widthMm??60,heightMm:r.heightMm??8,text:t,style:n}),this}list(t,r,n,o={}){return this.components.push({kind:"list",leftMm:r.leftMm??10,topMm:r.topMm??30,widthMm:r.widthMm??180,dataset:t,columns:n,...o}),this}rect(t,r={}){return this.components.push({kind:"rect",...t,style:r}),this}line(t,r,n,o={}){return this.components.push({kind:"line",leftMm:t,topMm:r,widthMm:n,heightMm:.5,style:o}),this}barcode(t,r){return this.components.push({kind:"barcode",leftMm:r.leftMm??0,topMm:r.topMm??0,widthMm:r.widthMm??40,heightMm:r.heightMm??12,fallbackText:t}),this}qrcode(t,r,n,o){return this.components.push({kind:"qrcode",leftMm:n,topMm:o,widthMm:r,heightMm:r,fallbackText:t}),this}buildPage(){return{...this.page,components:this.components}}done(){return this.parent}build(){return this.done().build()}}function mt(){return new Ce}function ft(e,t={}){return I.validateDatasetRows([],e),e.fields.map(r=>({field:r.field,header:`${r.label??r.field}${r.unit?` (${r.unit})`:""}`,semanticRole:r.semanticRole??(r.type==="number"||r.type==="decimal"?"measure":r.type==="date"?"date":r.enum?"dimension":"text"),...t[r.field]}))}function A(e,t,r=!1){if(!Number.isFinite(e)||(r?e<0:e<=0))throw new Error(`${t} 必须是有限${r?"非负":"正"}数`)}function Y(e,t,r){if(e!==void 0&&!["left","center","right","justify",...r?["auto"]:[]].includes(e))throw new Error(`${t} 必须是 left/center/right/justify${r?"/auto":""}`)}function ht(e){const t=e.layout??"page";if(t!=="page"&&t!=="wide")throw new Error("layout 必须是 page 或 wide");if(t==="wide"&&(e.paper!==void 0||e.landscape!==void 0))throw new Error('宽表布局不能同时指定 paper 或 landscape;标准纸型请使用 layout: "page"');if(t!=="wide"&&e.columnWidthMm!==void 0)throw new Error('columnWidthMm 仅适用于 layout: "wide"');const r=e.columnWidthMm??30;return A(r,"columnWidthMm"),{layout:t,columnWidthMm:r}}function gt(e){const t=e.paper===void 0?"a4":e.paper;if(typeof t!="string"&&(typeof t!="object"||t===null)||e.landscape!==void 0&&typeof e.landscape!="boolean")throw new Error("paper 必须是纸张预设名或 { widthMm, heightMm } 对象,landscape 必须是布尔值");if(typeof t=="string"&&!Object.prototype.hasOwnProperty.call(m.PAPER_SIZES,t))throw new Error(`未知纸张预设 "${t}"(可用:${Object.keys(m.PAPER_SIZES).join("/")})`);const r=le(t,void 0,e.landscape),n=r.widthMm,o=r.heightMm;return A(n,"纸张 widthMm"),A(o,"纸张 heightMm"),{widthMm:n,heightMm:o}}function pt(e){if(e.margins!==void 0&&(!e.margins||typeof e.margins!="object"||Array.isArray(e.margins)))throw new Error("margins 必须是页边距对象");const t=e.margins??{},r={marginTopMm:t.marginTopMm===void 0?10:t.marginTopMm,marginBottomMm:t.marginBottomMm===void 0?10:t.marginBottomMm,marginLeftMm:t.marginLeftMm===void 0?10:t.marginLeftMm,marginRightMm:t.marginRightMm===void 0?10:t.marginRightMm};for(const[n,o]of Object.entries(r))A(o,n,!0);return r}function wt(e,t){const r=e.dataset===void 0?"detail":e.dataset;if(typeof r!="string"||!r.trim())throw new Error("dataset 必须是非空字符串");if(e.title!==void 0&&typeof e.title!="string")throw new Error("title 必须是字符串");const n=e.titleHeightMm===void 0?10:e.titleHeightMm,o=e.titleGapMm===void 0?4:e.titleGapMm;A(n,"titleHeightMm"),A(o,"titleGapMm",!0);const l=e.title!==void 0&&e.title.length>0,i=l?n+o:0;if(i>=t)throw new Error("标题高度与间距占满页面,必须为表格保留可用高度");return{dataset:r,titleHeightMm:n,hasTitle:l,titleSpaceMm:i}}function vt(e){if(e.listOptions!==void 0&&(!e.listOptions||typeof e.listOptions!="object"||Array.isArray(e.listOptions)))throw new Error("listOptions 必须是列表配置对象");const t=e.listOptions??{};Y(t.align,"listOptions.align",!0),Y(t.headerAlign,"listOptions.headerAlign",!1);for(const r of["fontSizePt","rowHeightMm","paddingMm"]){const n=t[r];n!==void 0&&A(n,`listOptions.${r}`,r==="paddingMm")}return t}function bt(e){let t=0,r=0;for(const[n,o]of e.entries()){if(!o||typeof o.header!="string"||typeof o.field!="string"||!o.field.trim())throw new Error(`columns[${n}] 需要字符串 header 与非空 field`);Y(o.align,`columns[${n}].align`,!0),Y(o.headerAlign,`columns[${n}].headerAlign`,!1),o.flex!==void 0&&A(o.flex,`columns[${n}].flex`),o.widthMm!==void 0?(A(o.widthMm,`columns[${n}].widthMm`),t+=o.widthMm):r=Math.max(r,o.flex??1)}return{fixedWidthMm:t,maxFlex:r}}function yt(e,t,r,n){const{fixedWidthMm:o,maxFlex:l}=bt(e.columns);if(t==="page"&&o>n)throw new Error(`固定列宽 ${o}mm 超出页面可用宽度 ${n}mm`);const i=n-o;if(t==="page"&&l>0&&i<=0)throw new Error("固定列占满页面可用宽度,自动列需要正的剩余宽度");const a=l>0?e.columns.reduce((d,c)=>d+(c.widthMm===void 0?(c.flex??1)/l:0),0):0;return{columns:e.columns.map(({widthMm:d,flex:c,...u},f)=>{const h=d??(t==="wide"?r*(c??1):i*((c??1)/l)/a);return A(h,`columns[${f}] 分配后的 widthMm`),{...u,widthMm:h}}),fixedWidthMm:o,maxFlex:l}}function Mt(e){if(!e||typeof e!="object")throw new Error("标准明细模板需要 options 对象");if(!Array.isArray(e.columns)||e.columns.length===0)throw new Error("columns 至少需要一列");const{layout:t,columnWidthMm:r}=ht(e),n=gt(e);let o=n.widthMm;const l=n.heightMm,i=pt(e);let a=o-i.marginLeftMm-i.marginRightMm;const s=l-i.marginTopMm-i.marginBottomMm;if(t==="page"&&a<=0||s<=0)throw new Error("页边距占满纸张,必须保留正的可用宽度和高度");const{dataset:d,titleHeightMm:c,hasTitle:u,titleSpaceMm:f}=wt(e,s),h=vt(e),{columns:p,fixedWidthMm:g,maxFlex:v}=yt(e,t,r,a);t==="wide"&&(a=p.reduce((x,k)=>x+k.widthMm,0),A(a,"宽表总列宽"),o=a+i.marginLeftMm+i.marginRightMm,A(o,"宽表总宽度"));const E={widthMm:o,heightMm:l,...i,components:[],...t==="wide"?{layout:t}:{}};return u&&E.components.push({kind:"text",text:e.title,leftMm:i.marginLeftMm,topMm:i.marginTopMm,widthMm:a,heightMm:c,style:{fontSize:16,bold:!0,align:"center",verticalAlign:"middle",...e.titleStyle}}),E.components.push({align:"auto",headerAlign:"center",...h,kind:"list",...t==="wide"?{layout:t}:{},...u?{title:e.title}:{},dataset:d,columns:p,leftMm:i.marginLeftMm,topMm:i.marginTopMm+f,widthMm:t==="wide"||v>0?a:g}),e.params===void 0?{pages:[E]}:{params:e.params,pages:[E]}}function Tt(e){return e}class D extends Error{constructor(t,r){super(r),this.code=t,this.name="ReportTemplateStoreError"}}function L(e){return JSON.parse(JSON.stringify(e))}function R(e){if(!e?.aborted)return;const t=new Error("模板操作已取消");throw t.name="AbortError",t}function pe(e){const t=e?Number(e.revision):0;if(!Number.isSafeInteger(t)||t<0||t>=Number.MAX_SAFE_INTEGER)throw new D("history","修订号无效或已达上限");return String(t+1)}function Et(e,t={}){const r=async(i,a)=>{R(a);const s=await e.read(i,a);return R(a),s?L(s):void 0},n=async(i,a)=>{const s=await r(i,a.signal);if((s?.revision??null)!==a.expectedRevision)throw new D("conflict","模板已变化,请重新读取后提交");return s},o=async(i,a,s)=>{if(R(a.signal),!await e.compareAndSwap(i.id,a.expectedRevision,L(i),{signal:a.signal,...s?{publication:L(s)}:{}}))throw new D("conflict","模板已被其他请求更新");return L(i)},l=(i,a,s,d)=>{const c=pe(i),u=F.parseReportTemplate({...a,revision:c}),f={revision:c,document:u,publishedAt:(t.now?.()??new Date).toISOString()};return d!==void 0&&(f.restoredFrom=d),o({id:i.id,revision:c,publishedRevision:c,published:u},s,f)};return{list:async i=>{R(i);const a=await e.list(i);return R(i),L(a)},get:async(i,a={})=>{const s=await r(i,a.signal),d=a.draft?s?.draft:s?.published;return d?F.parseReportTemplate(d):void 0},history:async(i,a)=>{R(a);const s=await e.history(i,a);return R(a),L(s)},saveDraft:async(i,a)=>{R(a.signal);const s=F.parseReportTemplate(t.migrate?await t.migrate(i):i),d=await n(s.id,a),c=pe(d);return o({id:s.id,revision:c,draft:{...s,revision:c},...d?.publishedRevision?{publishedRevision:d.publishedRevision,published:d.published}:{}},a)},publish:async(i,a)=>{const s=await n(i,a);if(!s)throw new D("missing","模板不存在");if(!s.draft)throw new D("draft","没有可发布的草稿");return l(s,s.draft,a)},rollback:async(i,a,s)=>{const d=await n(i,s);if(!d)throw new D("missing","模板不存在");R(s.signal);const c=await e.getVersion(i,a,s.signal);if(!c)throw new D("history","历史修订不存在");return l(d,c.document,s,a)}}}function xt(){const e=new Map,t=new Map;return{read:async(r,n)=>{R(n);const o=e.get(r);return o?L(o):void 0},list:async r=>(R(r),Array.from(e.values(),({id:n,revision:o,publishedRevision:l})=>({id:n,revision:o,...l?{publishedRevision:l}:{}}))),history:async(r,n)=>(R(n),Array.from(t.get(r)?.values()??[],o=>L(o))),getVersion:async(r,n,o)=>{R(o);const l=t.get(r)?.get(n);return l?L(l):void 0},compareAndSwap:async(r,n,o,l)=>{if(R(l.signal),(e.get(r)?.revision??null)!==n)return!1;if(o.id!==r)throw new D("history","状态 ID 与存储 ID 不一致");const i=L(o),a=l.publication;if(a){const s=t.get(r)??new Map;if(s.has(a.revision)||a.revision!==o.revision||a.document.id!==r)throw new D("history","发布修订不可覆盖,且必须与状态修订和模板 ID 一致");s.set(a.revision,L(a)),t.set(r,s)}return e.set(r,i),!0}}}function ke(e){return!e||typeof e!="object"?!1:[e.pageIndex,e.componentIndex,e.rowIndex,e.columnIndex].every(t=>Number.isInteger(t)&&t>=0)}function Ie(e,t,r){const n=e.grid;if(!n)return null;const o=n.cells[t];if(!o)return null;const i=j.resolveGridLayout(n,e.widthMm,e.heightMm).cells.filter(s=>s.ri===t).findIndex(s=>s.ci===r),a=o[i];return a?{cell:a,sourceColumnIndex:i}:null}function St(e){return e.value!==void 0?e.value:e.rawText??e.text??null}function Pt(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 Ct(e,t){if(e.editable===!1)return"cell";if(e.formula!==void 0)return"formula";if(e.children?.length)return"complex";if(t.table&&t.table.role!=="body"&&e.editable!==!0)return"structure"}function Rt(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 kt(e,t,r){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 Ae(e,t,r){const n=St(r),o=Ct(r,e);return{address:{...t},cell:r,component:e,value:n,valueType:Pt(r,n),table:Rt(e,t),source:kt(r,e,t),editable:o===void 0,readOnlyReason:o}}function Q(e,t){if(!ke(t))return null;const r=e.pages[t.pageIndex]?.components[t.componentIndex];if(!r)return null;const n=Ie(r,t.rowIndex,t.columnIndex);return n?Ae(r,t,n.cell):null}function ee(e){const t=new Map;return r=>{if(!ke(r))return null;const n=e.pages[r.pageIndex]?.components[r.componentIndex];if(!n?.grid)return null;let o=t.get(n);if(!o){const i=new Map;o=new Map;for(const a of j.resolveGridLayout(n.grid,n.widthMm,n.heightMm).cells){const s=i.get(a.ri)??0;i.set(a.ri,s+1);const d=n.grid.cells[a.ri]?.[s];d&&o.set(`${a.ri}:${a.ci}`,d)}t.set(n,o)}const l=o.get(`${r.rowIndex}:${r.columnIndex}`);return l?Ae(n,r,l):null}}class T extends Error{constructor(t){super(`Invalid report cell edit: ${t}`),this.code=t,this.name="ReportCellEditError"}}function It(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 T("number");return Number(r)/(n?100:1)}function At(e,t){if(e===null||typeof e=="string"&&e.trim()==="")return null;if(typeof e!="string"&&typeof e!="number")throw new T("number");const r=typeof e=="number"?e:It(e,ve.isExcelPercentageFormat(t.cell.numberFormat));if(!Number.isFinite(r)||Number.isInteger(r)&&!Number.isSafeInteger(r))throw new T("number");return r}function Lt(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 T("boolean")}function de(e,t){return e.valueType==="number"?At(t,e):e.valueType==="boolean"?Lt(t):t===null?null:String(t)}function Ft(e,t){const r=t.cell.text,o=[["是","否"],["TRUE","FALSE"],["True","False"],["true","false"],["1","0"]].find(l=>l.includes(r??""));return o?o[e?0:1]:String(e)}function V(e,t){return t===null?"":typeof t=="boolean"?Ft(t,e):typeof t=="number"?ve.formatExcelNumber(t,e.cell.numberFormat):String(t)}function Ot(e,t,r){const n=Q(e,t);if(!n)throw new T("missing");return ce(n,r)}function ce(e,t){if(!e.editable)throw new T("readonly");const r=de(e,t);return{address:{...e.address},table:e.table,source:e.source,previousValue:e.value,previousText:e.cell.text??"",value:r,text:V(e,r)}}function Nt(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 Le(e,t,r){const n=e.grid,{rowIndex:o,columnIndex:l}=t.address,i=Ie(e,o,l),a=[...n.cells],s=[...a[o]],d=V(t,r.value),c={...i.cell,value:r.value,text:d,rawText:d};return s[i.sourceColumnIndex]=c,a[o]=s,{...e,grid:{...n,cells:a}}}function Dt(e,t){const r=e.table?.columnKeys,n=t.table?.columnKey;return r&&n!==void 0?r.flatMap((o,l)=>o===n?[l]:[]):[]}function $t(e,t,r,n,o,l){const i=t.table,a=o.table;if(!i||!a||i.id!==a.id||i.role!==a.role||!t.grid)return t;const s=a.rowIndex-i.rowIndex;if(s<0||s>=t.grid.cells.length)return t;let d=t;for(const c of Dt(t,o)){const u=Q(e,{pageIndex:r,componentIndex:n,rowIndex:s,columnIndex:c});u?.editable&&Nt(o,u)&&(d=Le(d,u,l))}return d}function _t(e,t,r,n,o,l){const i=o.address;return o.table?.columnKey!==void 0?$t(e,t,r,n,o,l):i.pageIndex===r&&i.componentIndex===n?Le(t,o,l):t}function Fe(e,t){const r=t.source;if(!r)return!1;const n=e.source;return!n||["datasetId","rowKey","field","revision","sourceToken"].some(o=>!Object.is(n[o],r[o]))}function zt(e,t){const r=Q(e,t.address);if(!r)throw new T("missing");if(!r.editable)throw new T("readonly");if(Fe(r,t))throw new T("conflict");if(!Object.is(r.value,t.previousValue)||(r.cell.text??"")!==t.previousText)throw new T("conflict");const n=de(r,t.value),o={...t,value:n,text:V(r,n)};if(Object.is(n,r.value)&&o.text===r.cell.text)return e;const l=e.pages.map((i,a)=>{const s=i.components.map((d,c)=>_t(e,d,a,c,r,o));return s.every((d,c)=>d===i.components[c])?i:{...i,components:s}});return{...e,pages:l}}function Ht(e){return JSON.stringify([e.pageIndex,e.componentIndex,e.rowIndex,e.columnIndex])}function we(e){const t=e.table;return t?.columnKey!==void 0?JSON.stringify([t.id,t.role,t.rowIndex,t.columnKey]):Ht(e.address)}function Bt(e,t){if(!t.length)return e;const r=new Map(t.map(s=>[we(s),s])),n=new Set(t.flatMap(s=>s.table?[s.table.id]:[])),o=new Set(t.map(s=>`${s.address.pageIndex}:${s.address.componentIndex}`)),l=ee(e);function i(s,d,c){const u=s.grid;if(!u||!o.has(`${d}:${c}`)&&!n.has(s.table?.id??""))return s;const f=new Map,h=new Map;for(const p of j.resolveGridLayout(u,s.widthMm,s.heightMm).cells){const g=h.get(p.ri)??0;h.set(p.ri,g+1);const v=l({pageIndex:d,componentIndex:c,rowIndex:p.ri,columnIndex:p.ci}),E=v&&r.get(we(v));if(!E||!v.editable)continue;const x=f.get(p.ri)??[...u.cells[p.ri]],k=V(v,E.value);Object.is(v.value,E.value)&&k===v.cell.text||(x[g]={...p.cell,value:E.value,text:k,rawText:k},f.set(p.ri,x))}return f.size?{...s,grid:{...u,cells:u.cells.map((p,g)=>f.get(g)??p)}}:s}const a=e.pages.map((s,d)=>{const c=s.components.map((u,f)=>i(u,d,f));return c.every((u,f)=>u===s.components[f])?s:{...s,components:c}});return a.every((s,d)=>s===e.pages[d])?e:{...e,pages:a}}function te(e){const t=e.source;if(t)return JSON.stringify([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 jt(e,t,r){if(typeof r!="string"||!r.trim()||!Array.isArray(t))throw new T("missing");if(t.length>1e4)throw new T("limit");const n=new Set,o=ee(e),l=t.map(({address:i,value:a})=>{const s=o(i);if(!s)throw new T("missing");const d=ce(s,a),c=te(d);if(n.has(c))throw new T("duplicate");return n.add(c),d});return{requestId:r,edits:l}}function Wt(e,t){if(t.edits.length>1e4)throw new T("limit");const r=ee(e),n=new Set,o=t.edits.map(l=>{const i=r(l.address);if(!i)throw new T("missing");const a=te(l);if(n.has(a))throw new T("duplicate");if(n.add(a),Fe(i,l)||!Object.is(i.value,l.previousValue)||(i.cell.text??"")!==l.previousText)throw new T("conflict");return ce(i,l.value)});return Bt(e,o)}function Kt(e){const t=new Map;for(const r of e){const n=te(r),o=t.get(n),l=o?{...r,previousValue:o.previousValue,previousText:o.previousText}:{...r};Object.is(l.previousValue,l.value)?t.delete(n):t.set(n,l)}return[...t.values()]}function Vt(e){return e.map(t=>t.map(r=>/[\t\r\n"]/.test(r)?`"${r.replace(/"/g,'""')}"`:r).join(" ")).join(`\r
|
|
7
|
-
`)}function
|
|
8
|
-
`){
|
|
9
|
-
`&&s++;continue}if(l)throw new Error("Invalid quoted clipboard value");n+=d}if(o)throw new Error("Unclosed clipboard quote");return a(),Gt(r,e),r}function qt(e,t,r){if(!r||r.revision===void 0&&r.sourceToken===void 0)return e;const n=new Set(t.edits.flatMap(i=>i.source?[i.source.datasetId]:[]));if(!n.size)return e;function o(i){return!i.datasetId||!n.has(i.datasetId)||(r.revision===void 0||Object.is(r.revision,i.revision))&&(r.sourceToken===void 0||r.sourceToken===i.sourceToken)?i:{...i,...r.revision!==void 0?{revision:r.revision}:{},...r.sourceToken!==void 0?{sourceToken:r.sourceToken}:{}}}const l=e.pages.map(i=>{const a=i.components.map(s=>{const d=s.table?.source?o(s.table.source):void 0,c=s.table&&d!==s.table.source?{...s.table,source:d}:s.table,u=s.grid?.cells.map(h=>{const p=h.map(g=>{if(!g?.source)return g;const v=o(g.source);return v===g.source?g:{...g,source:v}});return p.some((g,v)=>g!==h[v])?p:h}),f=s.grid&&u?.some((h,p)=>h!==s.grid.cells[p])?{...s.grid,cells:u}:s.grid;return c!==s.table||f!==s.grid?{...s,table:c,grid:f}:s});return a.some((s,d)=>s!==i.components[d])?{...i,components:a}:i});return l.some((i,a)=>i!==e.pages[a])?{...e,pages:l}:e}exports.DEFAULT_BORDER_PT=b.DEFAULT_BORDER_PT;exports.DEFAULT_FONT_FAMILY=b.DEFAULT_FONT_FAMILY;exports.DEFAULT_FONT_PT=b.DEFAULT_FONT_PT;exports.DEFAULT_STROKE_COLOR=b.DEFAULT_STROKE_COLOR;exports.DEFAULT_TEXT_COLOR=b.DEFAULT_TEXT_COLOR;exports.LINE_HEIGHT=b.LINE_HEIGHT;exports.RENDER_PLAN_SCHEMA_VERSION=b.RENDER_PLAN_SCHEMA_VERSION;exports.SCHEMA_VERSION_MACH=b.SCHEMA_VERSION_MACH;exports.isImageBackedComponent=b.isImageBackedComponent;exports.isRichText=b.isRichText;exports.PaginatePageLimitError=I.PaginatePageLimitError;exports.ReportSourceError=I.ReportSourceError;exports.createReportSource=I.createReportSource;exports.datasetJsonSchema=I.datasetJsonSchema;exports.defineReport=I.defineReport;exports.evalStyleRule=I.evalStyleRule;exports.formatValue=I.formatValue;exports.paginateTemplate=I.paginateTemplate;exports.parseDateLocal=I.parseDateLocal;exports.toExcelNumberFormat=I.toExcelNumberFormat;exports.toNumber=I.toNumber;exports.validateDatasetRows=I.validateDatasetRows;exports.CSS_DPI=m.CSS_DPI;exports.MM_PER_INCH=m.MM_PER_INCH;exports.PAPER_SIZES=m.PAPER_SIZES;exports.mergeComponentStyles=m.mergeComponentStyles;exports.mmToPx=m.mmToPx;exports.mmToPxFactor=m.mmToPxFactor;exports.ptToPx=m.ptToPx;exports.pxToMm=m.pxToMm;exports.resolveBoxBorders=m.resolveBoxBorders;exports.resolveFontSize=m.resolveFontSize;exports.resolveLineHeight=m.resolveLineHeight;exports.resolveStroke=m.resolveStroke;exports.resolveTextColor=m.resolveTextColor;exports.round=m.round;exports.assertRenderPlan=X.assertRenderPlan;exports.validateComponent=X.validateComponent;exports.validatePage=X.validatePage;exports.validateRenderPlan=X.validateRenderPlan;exports.charWidthEm=O.charWidthEm;exports.createCanvasMeasurer=O.createCanvasMeasurer;exports.createHeuristicMeasurer=O.createHeuristicMeasurer;exports.heuristicMeasurer=O.heuristicMeasurer;exports.measureTextMm=O.measureTextMm;exports.wrapText=O.wrapText;exports.resolveGridLayout=j.resolveGridLayout;exports.OutputAssetError=z.OutputAssetError;exports.resolvePlanAssets=z.resolvePlanAssets;exports.inspectOutputCapabilities=H.inspectOutputCapabilities;exports.reportOutputDiagnostics=H.reportOutputDiagnostics;exports.REPORT_TEMPLATE_DOCUMENT_VERSION=F.REPORT_TEMPLATE_DOCUMENT_VERSION;exports.ReportTemplateError=F.ReportTemplateError;exports.createTemplateRegistry=F.createTemplateRegistry;exports.defineReportTemplate=F.defineReportTemplate;exports.parseReportTemplate=F.parseReportTemplate;exports.serializeReportTemplate=F.serializeReportTemplate;exports.validateReportTemplate=F.validateReportTemplate;exports.validateReportTemplateDocument=F.validateReportTemplateDocument;exports.ReportParamValidationError=W.ReportParamValidationError;exports.assertReportParams=W.assertReportParams;exports.isReportDate=W.isReportDate;exports.reportParamsJsonSchema=W.reportParamsJsonSchema;exports.validateReportParamDefinitions=W.validateReportParamDefinitions;exports.validateReportParams=W.validateReportParams;exports.PageBuilder=Re;exports.ReportCellEditError=T;exports.ReportTemplateStoreError=D;exports.TemplateBuilder=Ce;exports.applyReportCellEdit=zt;exports.applyReportCellEditBatch=Wt;exports.applyReportEditResult=qt;exports.classOf=P;exports.columnsFromContract=ft;exports.computePageWindow=Me;exports.createCanvasPager=ut;exports.createMemoryTemplateStore=xt;exports.createProviderReport=Tt;exports.createReportCellEdit=Ot;exports.createReportCellEditBatch=jt;exports.createReportCellResolver=ee;exports.createTableTemplate=Mt;exports.createTemplate=mt;exports.createTemplateManager=Et;exports.formatReportCellEdit=V;exports.formatReportClipboard=Vt;exports.getReportCellContext=Q;exports.measurePageSizePx=Z;exports.parseReportCellInput=de;exports.parseReportClipboard=Ut;exports.planFontSizePx=tt;exports.renderComponent=ie;exports.renderPage=ye;exports.renderPlan=Ye;exports.renderPlanToCanvas=dt;exports.renderPlanToCanvasAsync=ct;exports.renderPlanToImages=st;exports.reportCellEditKey=te;exports.resolvePaper=le;exports.summarizeReportCellEdits=Kt;
|
|
5
|
+
`):_.wrapText(t.text??"",t.widthMm,{fontSizePt:d.fontSizePt,bold:c.bold,italic:c.italic,fontFamily:c.fontFamily??i,letterSpacingPt:c.letterSpacing},a).join(`
|
|
6
|
+
`);Fe(e,{text:u,fontSizePx:d.fontSizePx,bold:c.bold??!1,italic:c.italic,color:f.resolveTextColor(c),align:c.align??"left",lineHeight:f.resolveLineHeight(c),letterSpacingPx:f.ptToPx(c.letterSpacing??0,l)},n,r,o,s,c.fontFamily??i,c.verticalAlign)}function fe(e,t,n,r,o,s,l){const i=t.leftMm*n,a=t.topMm*n,c=t.widthMm*n,d=t.heightMm*n,u=t.style??{};if(x.isImageBackedComponent(t)){const m=l?.get(t.imageData);m?mt(e,m,i,a,c,d):xe(e,t,i,a,c,d);return}if(t.grid){wt(e,t.grid,t,i,a,c,d,n,r,o,s);return}switch(t.kind){case"text":{vt(e,t,i,a,c,d,r,o,s);break}case"rect":{const m=f.resolveStroke(u),h=f.resolveBoxBorders(u);u.backgroundColor&&(e.fillStyle=u.backgroundColor,e.fillRect(i,a,c,d)),h.inner&&(e.strokeStyle=m.color,e.lineWidth=f.ptToPx(m.widthPt,r),pt(e,h,i,a,c,d));break}case"line":{const m=f.resolveStroke({...u,borderColor:u.lineColor??u.borderColor});e.strokeStyle=m.color,e.lineWidth=f.ptToPx(m.widthPt,r),e.beginPath();const h=t.lineDirection==="up"?a+d:t.lineDirection==="down"?a:a+d/2,g=t.lineDirection==="up"?a:t.lineDirection==="down"?a+d:a+d/2;e.moveTo(i,h),e.lineTo(i+c,g),e.stroke();break}case"ellipse":{const m=f.resolveStroke(u);e.strokeStyle=m.color,e.lineWidth=f.ptToPx(m.widthPt,r),u.backgroundColor&&(e.fillStyle=u.backgroundColor,e.beginPath(),e.ellipse(i+c/2,a+d/2,c/2,d/2,0,0,Math.PI*2),e.fill()),e.beginPath(),e.ellipse(i+c/2,a+d/2,c/2,d/2,0,0,Math.PI*2),e.stroke();break}default:xe(e,t,i,a,c,d);break}}function xe(e,t,n,r,o,s){e.save(),e.strokeStyle="#94a3b8",e.strokeRect(n,r,o,s),e.fillStyle="#64748b",e.font="12px sans-serif",e.fillText(t.fallbackText??`[${t.kind}]`,n+3,r+14),e.restore()}async function bt(e,t={}){if(typeof document>"u")throw new Error("renderPlanToImages 需要浏览器环境(SSR/Node 请在客户端钩子中调用)");const{format:n="png",quality:r=.92,...o}=t;if(n!=="png"&&n!=="jpeg")throw new TypeError("Image format must be png or jpeg.");if(!Number.isFinite(r)||r<0||r>1)throw new RangeError("Image quality must be between 0 and 1.");N(t.signal);const s=await W.resolvePlanAssets(e,{...t,format:"canvas"});e=s.plan;const l=[...s.diagnostics,...$.reportOutputDiagnostics(e,"canvas",t)],i=n==="jpeg"?"image/jpeg":"image/png",a=[],c=Math.min(e.pages.length-1,t.end??e.pages.length-1);for(let d=Math.max(0,t.start??0);d<=c;d++){N(t.signal);const u=await Ne(e.pages[d],d,o,l);try{a.push(await yt(u,i,r,t.signal))}finally{u.width=0,u.height=0}await j.outputCheckpoint(t,a.length,c-Math.max(0,t.start??0)+1)}return N(t.signal),{blobs:a,diagnostics:l}}function yt(e,t,n,r){return N(r),new Promise((o,s)=>{const l=()=>s(r?.reason??new DOMException("The operation was aborted.","AbortError"));r?.addEventListener("abort",l,{once:!0});try{e.toBlob(i=>{r?.removeEventListener("abort",l),i?o(i):s(new Error("Canvas encoding failed; no empty image was emitted."))},t,n)}catch(i){r?.removeEventListener("abort",l),s(i)}})}function xt(e,t={}){if(N(t.signal),typeof document>"u")throw new Error("renderPlanToCanvas 需要浏览器环境(SSR 请在客户端钩子中调用)");const n=t.dpr??(typeof devicePixelRatio=="number"?devicePixelRatio:1),r=t.dpi??96,o=r/96*me,s=t.fontFamily??x.DEFAULT_FONT_FAMILY,l=t.measurer??_.heuristicMeasurer,i=Math.max(0,t.start??0),a=Math.min(e.pages.length-1,t.end??e.pages.length-1),c=[],d=$.reportOutputDiagnostics(e,"canvas",t),u=Mt(e,i,a);for(const m of u)$.notifyOutputDiagnostic(m,t),d.push(m);if(t.fidelity==="strict"&&u.length)throw new $.OutputFidelityError(d);for(let m=i;m<=a;m++){N(t.signal);const h=e.pages[m],{canvas:g,ctx:p}=ke(h,n,r,t.maxCanvasPixels);for(const y of h.components)fe(p,y,o,r,s,l);c.push(g)}return{canvases:c,diagnostics:d}}function Mt(e,t,n){return n<t?[]:e.pages.slice(t,n+1).flatMap((r,o)=>r.components.flatMap((s,l)=>x.isImageBackedComponent(s)?[{code:"async-image-required",severity:"warning",format:"canvas",pageIndex:t+o,componentIndex:l,kind:s.kind,nid:s.nid,message:"Use renderPlanToCanvasAsync or renderPlanToImages to decode and include images."}]:[]))}async function Tt(e,t={}){if(typeof document>"u")throw new Error("renderPlanToCanvasAsync 需要浏览器环境(Node 请使用 PDF 或 XLSX 输出)");N(t.signal);const n=await W.resolvePlanAssets(e,{...t,format:"canvas"});e=n.plan;const r=[...n.diagnostics,...$.reportOutputDiagnostics(e,"canvas",t)],o=[],s=Math.min(e.pages.length-1,t.end??e.pages.length-1);for(let l=Math.max(0,t.start??0);l<=s;l++)o.push(await Ne(e.pages[l],l,t,r));return{canvases:o,diagnostics:r}}async function Ne(e,t,n,r){const o=n.dpr??(typeof devicePixelRatio=="number"?devicePixelRatio:1),s=n.dpi??96,l=n.fontFamily??x.DEFAULT_FONT_FAMILY,i=await Le(e,t,n,r);N(n.signal);const{canvas:a,ctx:c}=ke(e,o,s,n.maxCanvasPixels);for(const d of e.components)fe(c,d,s/25.4,s,l,n.measurer??_.heuristicMeasurer,i);return a}async function Le(e,t,n,r){const o=n.imageLoader??ct;return ut(e,async(s,l)=>{try{return await o(s,l)}catch(i){if(l?.aborted)throw i;const a=e.components.findIndex(u=>u.imageData===s),c=e.components[a],d={code:"image-decode-failed",severity:"warning",format:"canvas",pageIndex:t,componentIndex:a,kind:c.kind,nid:c.nid,message:"Image decoding failed; raster output was cancelled instead of omitting the image."};throw r.push(d),$.notifyOutputDiagnostic(d,n),i}},n.signal)}function Et(e,t={}){const n=t.dpr??(typeof devicePixelRatio=="number"?devicePixelRatio:1),r=t.dpi??96,o=r/96*me,s=t.fontFamily??x.DEFAULT_FONT_FAMILY,l=t.measurer??_.heuristicMeasurer,i=t.overscan??1,a=t.gapPx??18,c=t.pagesPerFrame??1,d=e.pages.map(w=>w.pageHeightMm*o),u=Math.max(1,...e.pages.map(w=>w.pageWidthMm*o)),m={start:0,end:-1};let h=null,g=null,p=null,y=null,S=[],C=0,k=[],J=0,q=new AbortController;const we=[];function Ve(){const w=h;w.innerHTML="",g=document.createElement("div"),g.style.cssText=`width:${u}px;margin:0 auto;`,p=document.createElement("div"),y=document.createElement("div"),g.appendChild(p),S=[];const R=Math.min(e.pages.length,3+i*2);for(let B=0;B<R;B++){const M=document.createElement("div");M.style.cssText=`margin:0 auto ${a}px;box-shadow:0 2px 8px rgba(0,0,0,.35);background:#fff;`,g.appendChild(M),S.push(M)}g.appendChild(y),w.appendChild(g)}async function qe(w,R){const B=J,M=await W.resolvePlanAssets(e,{...t,signal:q.signal,format:"canvas",start:R,end:R});we.push(...M.diagnostics);const I=M.plan.pages[R],Q=await Le(I,R,{...t,signal:q.signal},we);if(B!==J||!h)return;const{widthPx:ce,heightPx:de}=re(I,r);let z=w.firstElementChild;(!z||z.tagName!=="CANVAS")&&(z=document.createElement("canvas"),w.innerHTML="",w.appendChild(z));const be=Ae(I,n,r,t.maxCanvasPixels);z.width=be.width,z.height=be.height,z.style.width=`${ce}px`,z.style.height=`${de}px`;const U=z.getContext("2d");if(U){U.setTransform(1,0,0,1,0,0),U.scale(n,n),U.fillStyle="#ffffff",U.fillRect(0,0,ce,de);for(const Ye of I.components)fe(U,Ye,o,r,s,l,Q);z.dataset.canvasPage=String(R),w.style.height=`${de}px`,w.style.width=`${ce}px`}}function Ge(w){J++,m.start=w.start,m.end=w.end,p.style.height=`${w.start*a+d.slice(0,w.start).reduce((M,I)=>M+I,0)}px`;const R=e.pages.length-1-w.end;y.style.height=`${R*a+d.slice(w.end+1).reduce((M,I)=>M+I,0)}px`;const B=w.end-w.start+1;S.forEach((M,I)=>{if(I<B){M.style.display="";const Q=w.start+I;M.style.height=`${d[Q]??0}px`}else M.style.display="none"}),k=[];for(let M=w.start;M<=w.end;M++){const I=S[M-w.start];if(!I)continue;I.firstElementChild?.dataset?.canvasPage!==String(M)&&k.push(M)}le()}function le(){C||k.length===0||(C=requestAnimationFrame(()=>{C=0;let w=Math.max(1,c);for(;k.length>0&&w-- >0;){const R=k.shift(),B=S[R-m.start];B&&qe(B,R).catch(()=>{})}k.length>0&&le()}))}function X(){C||(C=requestAnimationFrame(()=>{C=0;const w=h,R=Ie({pageHeightsPx:d,viewportHeightPx:w.clientHeight,scrollTopPx:w.scrollTop,overscan:i,gapPx:a});R.start!==m.start||R.end!==m.end?Ge(R):le()}))}let Z=null;return{attach(w){if(typeof document>"u")throw new Error("createCanvasPager 需要浏览器环境(SSR 请在客户端钩子中调用 attach)");N(t.signal),q=new AbortController,t.signal?.addEventListener("abort",ve,{once:!0}),$.reportOutputDiagnostics(e,"canvas",t),h=w,Ve(),w.addEventListener("scroll",X,{passive:!0}),typeof ResizeObserver<"u"&&(Z=new ResizeObserver(()=>X()),Z.observe(w)),X()},destroy(){J++,q.abort(),t.signal?.removeEventListener("abort",ve),C&&cancelAnimationFrame(C),C=0,Z?.disconnect(),Z=null,h?.removeEventListener("scroll",X),k=[],g?.remove(),h=null},window(){return{...m}}};function ve(){q.abort(t.signal?.reason)}}function he(e,t,n){let r,o;if(typeof e=="string"){const s=f.PAPER_SIZES[e];if(!s)throw new Error(`未知纸张预设 "${e}"(可用:${Object.keys(f.PAPER_SIZES).join("/")})`);r=s.widthMm,o=s.heightMm}else typeof e=="number"?(r=e,o=t??297):(r=e.widthMm,o=e.heightMm);return n?{widthMm:o,heightMm:r}:{widthMm:r,heightMm:o}}class Oe{constructor(){this.pages=[],this.pending=null,this.templateParams=void 0}params(t){return this.templateParams=t,this}page(t="a4",n={},r){this.collect();const s=r!=null&&!("margins"in r)&&!("landscape"in r)&&("marginTopMm"in r||"marginBottomMm"in r||"marginLeftMm"in r||"marginRightMm"in r)?{margins:r}:typeof n=="number"?r??{}:n,{widthMm:l,heightMm:i}=he(t,typeof n=="number"?n:void 0,s.landscape),a=s.margins??{};return this.pending=new $e(this,{widthMm:l,heightMm:i,marginTopMm:a.marginTopMm??10,marginBottomMm:a.marginBottomMm??10,marginLeftMm:a.marginLeftMm??10,marginRightMm:a.marginRightMm??10}),this.pending}collect(){this.pending&&(this.pages.push(this.pending.buildPage()),this.pending=null)}build(){if(this.collect(),this.pages.length===0)throw new Error("模板至少需要一页:先调用 .page() 添加内容");return this.templateParams?{params:this.templateParams,pages:this.pages}:{pages:this.pages}}}class $e{constructor(t,n){this.parent=t,this.page=n,this.components=[]}text(t,n={},r={}){return this.components.push({kind:"text",leftMm:n.leftMm??0,topMm:n.topMm??0,widthMm:n.widthMm??60,heightMm:n.heightMm??8,text:t,style:r}),this}list(t,n,r,o={}){return this.components.push({kind:"list",leftMm:n.leftMm??10,topMm:n.topMm??30,widthMm:n.widthMm??180,dataset:t,columns:r,...o}),this}rect(t,n={}){return this.components.push({kind:"rect",...t,style:n}),this}line(t,n,r,o={}){return this.components.push({kind:"line",leftMm:t,topMm:n,widthMm:r,heightMm:.5,style:o}),this}barcode(t,n){return this.components.push({kind:"barcode",leftMm:n.leftMm??0,topMm:n.topMm??0,widthMm:n.widthMm??40,heightMm:n.heightMm??12,fallbackText:t}),this}qrcode(t,n,r,o){return this.components.push({kind:"qrcode",leftMm:r,topMm:o,widthMm:n,heightMm:n,fallbackText:t}),this}buildPage(){return{...this.page,components:this.components}}done(){return this.parent}build(){return this.done().build()}}function St(){return new Oe}function Ct(e,t={}){return F.validateDatasetRows([],e),e.fields.map(n=>({field:n.field,header:`${n.label??n.field}${n.unit?` (${n.unit})`:""}`,semanticRole:n.semanticRole??(n.type==="number"||n.type==="decimal"?"measure":n.type==="date"?"date":n.enum?"dimension":"text"),...t[n.field]}))}function L(e,t,n=!1){if(!Number.isFinite(e)||(n?e<0:e<=0))throw new Error(`${t} 必须是有限${n?"非负":"正"}数`)}function ee(e,t,n){if(e!==void 0&&!["left","center","right","justify",...n?["auto"]:[]].includes(e))throw new Error(`${t} 必须是 left/center/right/justify${n?"/auto":""}`)}function Rt(e){const t=e.layout??"page";if(t!=="page"&&t!=="wide")throw new Error("layout 必须是 page 或 wide");if(t==="wide"&&(e.paper!==void 0||e.landscape!==void 0))throw new Error('宽表布局不能同时指定 paper 或 landscape;标准纸型请使用 layout: "page"');if(t!=="wide"&&e.columnWidthMm!==void 0)throw new Error('columnWidthMm 仅适用于 layout: "wide"');const n=e.columnWidthMm??30;return L(n,"columnWidthMm"),{layout:t,columnWidthMm:n}}function Pt(e){const t=e.paper===void 0?"a4":e.paper;if(typeof t!="string"&&(typeof t!="object"||t===null)||e.landscape!==void 0&&typeof e.landscape!="boolean")throw new Error("paper 必须是纸张预设名或 { widthMm, heightMm } 对象,landscape 必须是布尔值");if(typeof t=="string"&&!Object.prototype.hasOwnProperty.call(f.PAPER_SIZES,t))throw new Error(`未知纸张预设 "${t}"(可用:${Object.keys(f.PAPER_SIZES).join("/")})`);const n=he(t,void 0,e.landscape),r=n.widthMm,o=n.heightMm;return L(r,"纸张 widthMm"),L(o,"纸张 heightMm"),{widthMm:r,heightMm:o}}function It(e){if(e.margins!==void 0&&(!e.margins||typeof e.margins!="object"||Array.isArray(e.margins)))throw new Error("margins 必须是页边距对象");const t=e.margins??{},n={marginTopMm:t.marginTopMm===void 0?10:t.marginTopMm,marginBottomMm:t.marginBottomMm===void 0?10:t.marginBottomMm,marginLeftMm:t.marginLeftMm===void 0?10:t.marginLeftMm,marginRightMm:t.marginRightMm===void 0?10:t.marginRightMm};for(const[r,o]of Object.entries(n))L(o,r,!0);return n}function At(e,t){const n=e.dataset===void 0?"detail":e.dataset;if(typeof n!="string"||!n.trim())throw new Error("dataset 必须是非空字符串");if(e.title!==void 0&&typeof e.title!="string")throw new Error("title 必须是字符串");const r=e.titleHeightMm===void 0?10:e.titleHeightMm,o=e.titleGapMm===void 0?4:e.titleGapMm;L(r,"titleHeightMm"),L(o,"titleGapMm",!0);const s=e.title!==void 0&&e.title.length>0,l=s?r+o:0;if(l>=t)throw new Error("标题高度与间距占满页面,必须为表格保留可用高度");return{dataset:n,titleHeightMm:r,hasTitle:s,titleSpaceMm:l}}function kt(e){if(e.listOptions!==void 0&&(!e.listOptions||typeof e.listOptions!="object"||Array.isArray(e.listOptions)))throw new Error("listOptions 必须是列表配置对象");const t=e.listOptions??{};ee(t.align,"listOptions.align",!0),ee(t.headerAlign,"listOptions.headerAlign",!1);for(const n of["fontSizePt","rowHeightMm","paddingMm"]){const r=t[n];r!==void 0&&L(r,`listOptions.${n}`,n==="paddingMm")}return t}function Ft(e){let t=0,n=0;for(const[r,o]of e.entries()){if(!o||typeof o.header!="string"||typeof o.field!="string"||!o.field.trim())throw new Error(`columns[${r}] 需要字符串 header 与非空 field`);ee(o.align,`columns[${r}].align`,!0),ee(o.headerAlign,`columns[${r}].headerAlign`,!1),o.flex!==void 0&&L(o.flex,`columns[${r}].flex`),o.widthMm!==void 0?(L(o.widthMm,`columns[${r}].widthMm`),t+=o.widthMm):n=Math.max(n,o.flex??1)}return{fixedWidthMm:t,maxFlex:n}}function Nt(e,t,n,r){const{fixedWidthMm:o,maxFlex:s}=Ft(e.columns);if(t==="page"&&o>r)throw new Error(`固定列宽 ${o}mm 超出页面可用宽度 ${r}mm`);const l=r-o;if(t==="page"&&s>0&&l<=0)throw new Error("固定列占满页面可用宽度,自动列需要正的剩余宽度");const i=s>0?e.columns.reduce((c,d)=>c+(d.widthMm===void 0?(d.flex??1)/s:0),0):0;return{columns:e.columns.map(({widthMm:c,flex:d,...u},m)=>{const h=c??(t==="wide"?n*(d??1):l*((d??1)/s)/i);return L(h,`columns[${m}] 分配后的 widthMm`),{...u,widthMm:h}}),fixedWidthMm:o,maxFlex:s}}function Lt(e){if(!e||typeof e!="object")throw new Error("标准明细模板需要 options 对象");if(!Array.isArray(e.columns)||e.columns.length===0)throw new Error("columns 至少需要一列");const{layout:t,columnWidthMm:n}=Rt(e),r=Pt(e);let o=r.widthMm;const s=r.heightMm,l=It(e);let i=o-l.marginLeftMm-l.marginRightMm;const a=s-l.marginTopMm-l.marginBottomMm;if(t==="page"&&i<=0||a<=0)throw new Error("页边距占满纸张,必须保留正的可用宽度和高度");const{dataset:c,titleHeightMm:d,hasTitle:u,titleSpaceMm:m}=At(e,a),h=kt(e),{columns:g,fixedWidthMm:p,maxFlex:y}=Nt(e,t,n,i);t==="wide"&&(i=g.reduce((C,k)=>C+k.widthMm,0),L(i,"宽表总列宽"),o=i+l.marginLeftMm+l.marginRightMm,L(o,"宽表总宽度"));const S={widthMm:o,heightMm:s,...l,components:[],...t==="wide"?{layout:t}:{}};return u&&S.components.push({kind:"text",text:e.title,leftMm:l.marginLeftMm,topMm:l.marginTopMm,widthMm:i,heightMm:d,style:{fontSize:16,bold:!0,align:"center",verticalAlign:"middle",...e.titleStyle}}),S.components.push({align:"auto",headerAlign:"center",...h,kind:"list",...t==="wide"?{layout:t}:{},...u?{title:e.title}:{},dataset:c,columns:g,leftMm:l.marginLeftMm,topMm:l.marginTopMm+m,widthMm:t==="wide"||y>0?i:p}),e.params===void 0?{pages:[S]}:{params:e.params,pages:[S]}}function Ot(e){return e}class H extends Error{constructor(t,n){super(n),this.code=t,this.name="ReportTemplateStoreError"}}function O(e){return JSON.parse(JSON.stringify(e))}function A(e){if(!e?.aborted)return;const t=new Error("模板操作已取消");throw t.name="AbortError",t}function Me(e){const t=e?Number(e.revision):0;if(!Number.isSafeInteger(t)||t<0||t>=Number.MAX_SAFE_INTEGER)throw new H("history","修订号无效或已达上限");return String(t+1)}function $t(e,t={}){const n=async(l,i)=>{A(i);const a=await e.read(l,i);return A(i),a?O(a):void 0},r=async(l,i)=>{const a=await n(l,i.signal);if((a?.revision??null)!==i.expectedRevision)throw new H("conflict","模板已变化,请重新读取后提交");return a},o=async(l,i,a)=>{if(A(i.signal),!await e.compareAndSwap(l.id,i.expectedRevision,O(l),{signal:i.signal,...a?{publication:O(a)}:{}}))throw new H("conflict","模板已被其他请求更新");return O(l)},s=(l,i,a,c)=>{const d=Me(l),u=D.parseReportTemplate({...i,revision:d}),m={revision:d,document:u,publishedAt:(t.now?.()??new Date).toISOString()};return c!==void 0&&(m.restoredFrom=c),o({id:l.id,revision:d,publishedRevision:d,published:u},a,m)};return{list:async l=>{A(l);const i=await e.list(l);return A(l),O(i)},get:async(l,i={})=>{const a=await n(l,i.signal),c=i.draft?a?.draft:a?.published;return c?D.parseReportTemplate(c):void 0},history:async(l,i)=>{A(i);const a=await e.history(l,i);return A(i),O(a)},saveDraft:async(l,i)=>{A(i.signal);const a=D.parseReportTemplate(t.migrate?await t.migrate(l):l),c=await r(a.id,i),d=Me(c);return o({id:a.id,revision:d,draft:{...a,revision:d},...c?.publishedRevision?{publishedRevision:c.publishedRevision,published:c.published}:{}},i)},publish:async(l,i)=>{const a=await r(l,i);if(!a)throw new H("missing","模板不存在");if(!a.draft)throw new H("draft","没有可发布的草稿");return s(a,a.draft,i)},rollback:async(l,i,a)=>{const c=await r(l,a);if(!c)throw new H("missing","模板不存在");A(a.signal);const d=await e.getVersion(l,i,a.signal);if(!d)throw new H("history","历史修订不存在");return s(c,d.document,a,i)}}}function Dt(){const e=new Map,t=new Map;return{read:async(n,r)=>{A(r);const o=e.get(n);return o?O(o):void 0},list:async n=>(A(n),Array.from(e.values(),({id:r,revision:o,publishedRevision:s})=>({id:r,revision:o,...s?{publishedRevision:s}:{}}))),history:async(n,r)=>(A(r),Array.from(t.get(n)?.values()??[],o=>O(o))),getVersion:async(n,r,o)=>{A(o);const s=t.get(n)?.get(r);return s?O(s):void 0},compareAndSwap:async(n,r,o,s)=>{if(A(s.signal),(e.get(n)?.revision??null)!==r)return!1;if(o.id!==n)throw new H("history","状态 ID 与存储 ID 不一致");const l=O(o),i=s.publication;if(i){const a=t.get(n)??new Map;if(a.has(i.revision)||i.revision!==o.revision||i.document.id!==n)throw new H("history","发布修订不可覆盖,且必须与状态修订和模板 ID 一致");a.set(i.revision,O(i)),t.set(n,a)}return e.set(n,l),!0}}}function De(e){return!e||typeof e!="object"?!1:[e.pageIndex,e.componentIndex,e.rowIndex,e.columnIndex].every(t=>Number.isInteger(t)&&t>=0)}function _e(e,t,n){const r=e.grid;if(!r)return null;const o=r.cells[t];if(!o)return null;const l=j.resolveGridLayout(r,e.widthMm,e.heightMm).cells.filter(a=>a.ri===t).findIndex(a=>a.ci===n),i=o[l];return i?{cell:i,sourceColumnIndex:l}:null}function _t(e){return e.value!==void 0?e.value:e.rawText??e.text??null}function zt(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 Ht(e,t){if(e.editable===!1)return"cell";if(e.formula!==void 0)return"formula";if(e.children?.length)return"complex";if(t.table&&t.table.role!=="body"&&e.editable!==!0)return"structure"}function Bt(e,t){const n=e.table;if(n)return{id:n.id,rowIndex:n.rowIndex+t.rowIndex,role:n.role,columnKey:n.columnKeys[t.columnIndex]}}function jt(e,t,n){if(e.source)return{...e.source};const r=t.table?.source,o=t.table?.columnKeys[n.columnIndex];if(!(!r||r.rowKey===void 0||o===void 0))return{...r,rowKey:r.rowKey,field:o}}function ze(e,t,n){const r=_t(n),o=Ht(n,e);return{address:{...t},cell:n,component:e,value:r,valueType:zt(n,r),table:Bt(e,t),source:jt(n,e,t),editable:o===void 0,readOnlyReason:o}}function oe(e,t){if(!De(t))return null;const n=e.pages[t.pageIndex]?.components[t.componentIndex];if(!n)return null;const r=_e(n,t.rowIndex,t.columnIndex);return r?ze(n,t,r.cell):null}function ie(e){const t=new Map;return n=>{if(!De(n))return null;const r=e.pages[n.pageIndex]?.components[n.componentIndex];if(!r?.grid)return null;let o=t.get(r);if(!o){const l=new Map;o=new Map;for(const i of j.resolveGridLayout(r.grid,r.widthMm,r.heightMm).cells){const a=l.get(i.ri)??0;l.set(i.ri,a+1);const c=r.grid.cells[i.ri]?.[a];c&&o.set(`${i.ri}:${i.ci}`,c)}t.set(r,o)}const s=o.get(`${n.rowIndex}:${n.columnIndex}`);return s?ze(r,n,s):null}}class T extends Error{constructor(t){super(`Invalid report cell edit: ${t}`),this.code=t,this.name="ReportCellEditError"}}function Wt(e,t){let n=e.trim();const r=t&&n.endsWith("%");if(r&&(n=n.slice(0,-1).trim()),/^[+-]?\d{1,3}(?:,\d{3})+(?:\.\d*)?(?:[eE][+-]?\d+)?$/.test(n)&&(n=n.replace(/,/g,"")),!/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/.test(n))throw new T("number");return Number(n)/(r?100:1)}function Ut(e,t){if(e===null||typeof e=="string"&&e.trim()==="")return null;if(typeof e!="string"&&typeof e!="number")throw new T("number");const n=typeof e=="number"?e:Wt(e,Ce.isExcelPercentageFormat(t.cell.numberFormat));if(!Number.isFinite(n)||Number.isInteger(n)&&!Number.isSafeInteger(n))throw new T("number");return n}function Kt(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 T("boolean")}function ae(e,t){return e.valueType==="number"?Ut(t,e):e.valueType==="boolean"?Kt(t):t===null?null:String(t)}function Vt(e,t){const n=t.cell.text,o=[["是","否"],["TRUE","FALSE"],["True","False"],["true","false"],["1","0"]].find(s=>s.includes(n??""));return o?o[e?0:1]:String(e)}function Y(e,t){return t===null?"":typeof t=="boolean"?Vt(t,e):typeof t=="number"?Ce.formatExcelNumber(t,e.cell.numberFormat):String(t)}function qt(e,t,n){const r=oe(e,t);if(!r)throw new T("missing");return ge(r,n)}function ge(e,t){if(!e.editable)throw new T("readonly");const n=ae(e,t);return{address:{...e.address},table:e.table,source:e.source,previousValue:e.value,previousText:e.cell.text??"",value:n,text:Y(e,n)}}function Gt(e,t){const n=e.table,r=t.table;return!n||!r||n.columnKey===void 0?!1:n.id===r.id&&n.rowIndex===r.rowIndex&&n.role===r.role&&n.columnKey===r.columnKey}function He(e,t,n){const r=e.grid,{rowIndex:o,columnIndex:s}=t.address,l=_e(e,o,s),i=[...r.cells],a=[...i[o]],c=Y(t,n.value),d={...l.cell,value:n.value,text:c,rawText:c};return a[l.sourceColumnIndex]=d,i[o]=a,{...e,grid:{...r,cells:i}}}function Yt(e,t){const n=e.table?.columnKeys,r=t.table?.columnKey;return n&&r!==void 0?n.flatMap((o,s)=>o===r?[s]:[]):[]}function Jt(e,t,n,r,o,s){const l=t.table,i=o.table;if(!l||!i||l.id!==i.id||l.role!==i.role||!t.grid)return t;const a=i.rowIndex-l.rowIndex;if(a<0||a>=t.grid.cells.length)return t;let c=t;for(const d of Yt(t,o)){const u=oe(e,{pageIndex:n,componentIndex:r,rowIndex:a,columnIndex:d});u?.editable&&Gt(o,u)&&(c=He(c,u,s))}return c}function Xt(e,t,n,r,o,s){const l=o.address;return o.table?.columnKey!==void 0?Jt(e,t,n,r,o,s):l.pageIndex===n&&l.componentIndex===r?He(t,o,s):t}function Be(e,t){const n=t.source;if(!n)return!1;const r=e.source;return!r||["datasetId","rowKey","field","revision","sourceToken"].some(o=>!Object.is(r[o],n[o]))}function Zt(e,t){const n=oe(e,t.address);if(!n)throw new T("missing");if(!n.editable)throw new T("readonly");if(Be(n,t))throw new T("conflict");if(!Object.is(n.value,t.previousValue)||(n.cell.text??"")!==t.previousText)throw new T("conflict");const r=ae(n,t.value),o={...t,value:r,text:Y(n,r)};if(Object.is(r,n.value)&&o.text===n.cell.text)return e;const s=e.pages.map((l,i)=>{const a=l.components.map((c,d)=>Xt(e,c,i,d,n,o));return a.every((c,d)=>c===l.components[d])?l:{...l,components:a}});return{...e,pages:s}}function Qt(e){return JSON.stringify([e.pageIndex,e.componentIndex,e.rowIndex,e.columnIndex])}function Te(e){const t=e.table;return t?.columnKey!==void 0?JSON.stringify([t.id,t.role,t.rowIndex,t.columnKey]):Qt(e.address)}function en(e,t){if(!t.length)return e;const n=new Map(t.map(a=>[Te(a),a])),r=new Set(t.flatMap(a=>a.table?[a.table.id]:[])),o=new Set(t.map(a=>`${a.address.pageIndex}:${a.address.componentIndex}`)),s=ie(e);function l(a,c,d){const u=a.grid;if(!u||!o.has(`${c}:${d}`)&&!r.has(a.table?.id??""))return a;const m=new Map,h=new Map;for(const g of j.resolveGridLayout(u,a.widthMm,a.heightMm).cells){const p=h.get(g.ri)??0;h.set(g.ri,p+1);const y=s({pageIndex:c,componentIndex:d,rowIndex:g.ri,columnIndex:g.ci}),S=y&&n.get(Te(y));if(!S||!y.editable)continue;const C=m.get(g.ri)??[...u.cells[g.ri]],k=Y(y,S.value);Object.is(y.value,S.value)&&k===y.cell.text||(C[p]={...g.cell,value:S.value,text:k,rawText:k},m.set(g.ri,C))}return m.size?{...a,grid:{...u,cells:u.cells.map((g,p)=>m.get(p)??g)}}:a}const i=e.pages.map((a,c)=>{const d=a.components.map((u,m)=>l(u,c,m));return d.every((u,m)=>u===a.components[m])?a:{...a,components:d}});return i.every((a,c)=>a===e.pages[c])?e:{...e,pages:i}}function se(e){const t=e.source;if(t)return JSON.stringify([t.datasetId,t.rowKey,t.field]);const n=e.table;if(n?.columnKey!==void 0)return JSON.stringify([n.id,n.role,n.rowIndex,n.columnKey]);const r=e.address;return JSON.stringify([r.pageIndex,r.componentIndex,r.rowIndex,r.columnIndex])}function tn(e,t,n){if(typeof n!="string"||!n.trim()||!Array.isArray(t))throw new T("missing");if(t.length>1e4)throw new T("limit");const r=new Set,o=ie(e),s=t.map(({address:l,value:i})=>{const a=o(l);if(!a)throw new T("missing");const c=ge(a,i),d=se(c);if(r.has(d))throw new T("duplicate");return r.add(d),c});return{requestId:n,edits:s}}function nn(e,t){if(t.edits.length>1e4)throw new T("limit");const n=ie(e),r=new Set,o=t.edits.map(s=>{const l=n(s.address);if(!l)throw new T("missing");const i=se(s);if(r.has(i))throw new T("duplicate");if(r.add(i),Be(l,s)||!Object.is(l.value,s.previousValue)||(l.cell.text??"")!==s.previousText)throw new T("conflict");return ge(l,s.value)});return en(e,o)}function rn(e){const t=new Map;for(const n of e){const r=se(n),o=t.get(r),s=o?{...n,previousValue:o.previousValue,previousText:o.previousText}:{...n};Object.is(s.previousValue,s.value)?t.delete(r):t.set(r,s)}return[...t.values()]}function on(e){return e.map(t=>t.map(n=>/[\t\r\n"]/.test(n)?`"${n.replace(/"/g,'""')}"`:n).join(" ")).join(`\r
|
|
7
|
+
`)}function an(e,t){const n=e[e.length-1];e.length>1&&n?.length===1&&n[0]===""&&/[\r\n]$/.test(t)&&e.pop()}function sn(e,t=1e4){if(e.length>4*1024*1024)throw new Error("Clipboard text limit exceeded");const n=[[]];let r="",o=!1,s=!1,l=0;function i(){if(++l>t)throw new Error("Clipboard cell limit exceeded");n[n.length-1].push(r),r="",s=!1}for(let a=0;a<e.length;a++){const c=e[a];if(o){if(c!=='"'){r+=c;continue}if(e[a+1]==='"'){r+='"',a++;continue}o=!1,s=!0;continue}if(c==='"'&&!r&&!s){o=!0;continue}if(c===" "){i();continue}if(c==="\r"||c===`
|
|
8
|
+
`){i(),n.push([]),c==="\r"&&e[a+1]===`
|
|
9
|
+
`&&a++;continue}if(s)throw new Error("Invalid quoted clipboard value");r+=c}if(o)throw new Error("Unclosed clipboard quote");return i(),an(n,e),n}function ln(e,t,n){if(!n||n.revision===void 0&&n.sourceToken===void 0)return e;const r=new Set(t.edits.flatMap(l=>l.source?[l.source.datasetId]:[]));if(!r.size)return e;function o(l){return!l.datasetId||!r.has(l.datasetId)||(n.revision===void 0||Object.is(n.revision,l.revision))&&(n.sourceToken===void 0||n.sourceToken===l.sourceToken)?l:{...l,...n.revision!==void 0?{revision:n.revision}:{},...n.sourceToken!==void 0?{sourceToken:n.sourceToken}:{}}}const s=e.pages.map(l=>{const i=l.components.map(a=>{const c=a.table?.source?o(a.table.source):void 0,d=a.table&&c!==a.table.source?{...a.table,source:c}:a.table,u=a.grid?.cells.map(h=>{const g=h.map(p=>{if(!p?.source)return p;const y=o(p.source);return y===p.source?p:{...p,source:y}});return g.some((p,y)=>p!==h[y])?g:h}),m=a.grid&&u?.some((h,g)=>h!==a.grid.cells[g])?{...a.grid,cells:u}:a.grid;return d!==a.table||m!==a.grid?{...a,table:d,grid:m}:a});return i.some((a,c)=>a!==l.components[c])?{...l,components:i}:l});return s.some((l,i)=>l!==e.pages[i])?{...e,pages:s}:e}class je extends Error{constructor(t,n,r){const o=typeof n.label=="string"?n.label:"单元格",s={definition:`${o}的编辑器配置无效`,type:`${o}的编辑器与数据类型不一致`,required:`${o}不能为空`,min:`${o}不能小于 ${r}`,max:`${o}不能大于 ${r}`,precision:`${o}最多保留 ${r} 位小数`,length:`${o}最多允许 ${r} 个字符`,choice:`${o}请选择有效选项`,date:`${o}请输入有效日期(YYYY-MM-DD)`};super(s[t]),this.code=t,this.field=n,this.expected=r,this.name="ReportCellFieldError"}}function v(e,t,n){throw new je(t,e,n)}function We(e){if(typeof e!="string"||!/^\d{4}-\d{2}-\d{2}$/.test(e)||e.startsWith("0000-"))return!1;const t=new Date(`${e}T00:00:00.000Z`);return Number.isFinite(t.getTime())&&t.toISOString().slice(0,10)===e}function cn(e){const[t="",n="0"]=String(e).toLowerCase().split("e");return Math.max(0,(t.split(".")[1]?.length??0)-Number(n))}function dn(e,t){e.min!==void 0&&t<e.min&&v(e,"min",e.min),e.max!==void 0&&t>e.max&&v(e,"max",e.max),e.precision!==void 0&&cn(t)>e.precision&&v(e,"precision",e.precision)}function un(e,t){We(t)||v(e,"date"),e.min!==void 0&&t<e.min&&v(e,"min",e.min),e.max!==void 0&&t>e.max&&v(e,"max",e.max)}function mn(e){[e.min,e.max].some(t=>t!==void 0&&!Number.isFinite(t))&&v(e,"definition"),e.min!==void 0&&e.max!==void 0&&e.min>e.max&&v(e,"definition"),e.precision!==void 0&&(!Number.isInteger(e.precision)||e.precision<0||e.precision>15)&&v(e,"definition")}function fn(e){[e.min,e.max].some(t=>t!==void 0&&!We(t))&&v(e,"definition"),e.min!==void 0&&e.max!==void 0&&e.min>e.max&&v(e,"definition")}function hn(e,t){(!Array.isArray(t.options)||!t.options.length)&&v(t,"definition");const n=e.valueType==="text"?"string":e.valueType,r=new Set;for(const o of t.options)(!o||typeof o.value!==n||typeof o.value=="number"&&!Number.isFinite(o.value))&&v(t,"definition"),o.label!==void 0&&typeof o.label!="string"&&v(t,"definition"),r.has(o.value)&&v(t,"definition"),r.add(o.value)}function gn(e){e.required!==void 0&&typeof e.required!="boolean"&&v(e,"definition"),[e.label,e.hint,e.unit].some(t=>t!==void 0&&typeof t!="string")&&v(e,"definition"),e.type==="boolean"&&[e.trueLabel,e.falseLabel].some(t=>t!==void 0&&typeof t!="string")&&v(e,"definition")}function Ue(e,t){(!t||typeof t!="object"||Array.isArray(t)||!["text","number","boolean","enum","date"].includes(t.type))&&v(t??{type:"text"},"definition"),gn(t),(t.type==="number"||t.type==="boolean")&&e.valueType!==t.type&&v(t,"type"),(t.type==="text"||t.type==="date")&&e.valueType!=="text"&&v(t,"type"),t.type==="number"&&mn(t),t.type==="text"&&t.maxLength!==void 0&&(!Number.isInteger(t.maxLength)||t.maxLength<0)&&v(t,"definition"),t.type==="date"&&fn(t),t.type==="enum"&&hn(e,t)}function pn(e,t,n){if(!e.editable)throw new T("readonly");n&&Ue(e,n);const r=ae(e,t);return n?(n.required&&typeof r=="string"&&!r.trim()&&v(n,"required"),r===null||r===""?(n.required&&v(n,"required"),r):(n.type==="number"&&dn(n,r),n.type==="date"&&un(n,r),n.type==="text"&&n.maxLength!==void 0&&[...String(r)].length>n.maxLength&&v(n,"length",n.maxLength),n.type==="enum"&&!n.options.some(o=>Object.is(o.value,r))&&v(n,"choice"),r)):r}class b extends Error{constructor(t){super(`Report calculation: ${t}`),this.code=t,this.name="ReportCalculationError"}}function K(e){if(!e?.aborted)return;const t=new Error("Calculation cancelled");throw t.name="AbortError",t}async function te(e,t=1){const n=Math.floor(e.scanned/2048);if(e.scanned+=t,e.scanned>e.maxScanned)throw new b("limit");K(e.signal),Math.floor(e.scanned/2048)>n&&(await e.yieldToHost(),K(e.signal))}function pe(e){return e.table?.role==="header"?-Math.max(1,e.grid?.cells.length??1):e.table?.rowIndex??0}function Ee(e,t,n){if(![t.pageIndex,t.componentIndex,t.rowIndex,t.columnIndex].every(i=>Number.isSafeInteger(i)&&i>=0))throw new b("selection");const r=e.pages[t.pageIndex]?.components[t.componentIndex];if(!r?.grid||t.rowIndex>=r.grid.cells.length)throw new b("selection");const o=r.grid.colWidthsMm?.length??r.grid.cells.reduce((i,a)=>Math.max(i,a.length),1);if(t.columnIndex>=o)throw new b("selection");const s=r.table,l=e.pages[n.pageIndex]?.components[n.componentIndex]?.table;if(s&&l&&s.id===l.id){const i=l.columnKeys.indexOf(s.columnKeys[t.columnIndex]??"");if(i<0)throw new b("selection");return{grid:s.id,row:pe(r)+t.rowIndex,column:i}}return{grid:`${t.pageIndex}:${t.componentIndex}`,row:t.rowIndex,column:t.columnIndex}}function wn(e,t,n){const r=Ee(e,t.anchor,t.anchor),o=Ee(e,t.focus,t.anchor);if(r.grid!==o.grid)throw new b("selection");const s=(Math.abs(r.row-o.row)+1)*(Math.abs(r.column-o.column)+1);if(!Number.isSafeInteger(s)||s>n)throw new b("limit");return{grid:r.grid,rowStart:Math.min(r.row,o.row),rowEnd:Math.max(r.row,o.row),columnStart:Math.min(r.column,o.column),columnEnd:Math.max(r.column,o.column),origin:e.pages[t.anchor.pageIndex].components[t.anchor.componentIndex].table}}function vn(e){if(!e)return!1;const t=e.replace(/"[^"]*"|\\.|\[(?![hms]+\])[^\]]*\]/gi,"");return/[ymdhs]/i.test(t)}function bn(e){if(e.valueType==="text"||e.valueType==="boolean"||vn(e.numberFormat))return null;const t=e.value;if(typeof t!="number"||!Number.isFinite(t))return null;if(Number.isInteger(t)&&!Number.isSafeInteger(t))throw new b("precision");return t}function yn(e,t,n){if(e.seen.has(n))return;e.seen.add(n),e.selected++;const r=t?bn(t):null;r===null?e.excluded++:e.values.push(r)}function xn(e,t,n,r){return r.origin?e.table?.id===r.origin.id:`${t}:${n}`===r.grid}function Mn(e,t,n){return n.origin?n.origin.columnKeys.indexOf(e.table.columnKeys[t]??""):t}function Tn(e,t,n,r){const o=r.origin?pe(e)+t:t,s=Mn(e,n,r);return o<r.rowStart||o>r.rowEnd||s<r.columnStart||s>r.columnEnd?null:`${r.grid}:${o}:${s}`}function En(e,t){const n=t.origin?pe(e):0,r=Math.max(0,t.rowStart-n),o=Math.min(e.grid.cells.length,t.rowEnd-n+1);return o>r?o:0}async function Sn(e,t,n,r,o){const s=e.grid;if(t>r.maxScanned)throw new b("limit");const l=s.colWidthsMm?.length??s.cells.reduce((a,c)=>Math.max(a,c.length),1);if(l>r.maxScanned)throw new b("limit");const i=new Map;for(let a=0;a<t;a++){a>0&&a%2048===0&&(await r.yieldToHost(),K(r.signal));let c=0;for(const d of s.cells[a]){for(await te(r);c<l&&(i.get(c)??0)>a;)c++;if(c>=l)break;const u=Math.max(1,Math.min(d?.colSpan??1,l-c)),m=Math.min(s.cells.length,a+Math.max(1,d?.rowSpan??1));u>1&&await te(r,u-1);for(let g=c;g<c+u;g++)i.set(g,m);const h=Tn(e,a,c,n);h&&yn(o,d,h),c+=u}}}async function Cn(e,t,n){const r={values:[],seen:new Set,excluded:0,selected:0};for(let o=0;o<e.pages.length;o++){await te(n);const s=e.pages[o];for(let l=0;l<s.components.length;l++){await te(n);const i=s.components[l];if(!i.grid||!xn(i,o,l,t)||i.table&&i.table.role!=="body")continue;const a=En(i,t);a&&await Sn(i,a,t,n,r)}}return r}function G(e){if(!Number.isFinite(e))throw new b("overflow");return e}function Rn(e){let t=0,n=0;for(const r of e){const o=r-n,s=G(t+o);n=s-t-o,t=s}return t}async function Se(e,t){let n=[...e],r=new Array(e.length);for(let s=1;s<e.length;s*=2){for(let l=0;l<e.length;l+=s*2){const i=Math.min(l+s,e.length),a=Math.min(l+s*2,e.length);let c=l,d=i;for(let u=l;u<a;u++)r[u]=d>=a||c<i&&n[c]<=n[d]?n[c++]:n[d++],u%2048===0&&(await t.yieldToHost(),K(t.signal))}[n,r]=[r,n]}const o=Math.floor(n.length/2);return n.length%2?n[o]:G(n[o-1]/2+n[o]/2)}function Pn(e){const t=Rn(e);let n=1/0,r=-1/0;for(const o of e)n=Math.min(n,o),r=Math.max(r,o);return{SUM:t,AVERAGE:t/e.length,AVG:t/e.length,MIN:n,MAX:r,COUNT:e.length}}function Ke(e,t){if(typeof e!="string"||e.length>256)throw new b("expression");const n=e.toUpperCase().match(/(?:\d+(?:\.\d*)?|\.\d+)(?:E[+-]?\d+)?|[A-Z_]+|[()+\-*/]|\S/g)??[];if(!n.length||n.length>64)throw new b("expression");let r=0;function o(i){if(i>16)throw new b("expression");const a=n[r++];if(a==="+"||a==="-")return(a==="-"?-1:1)*o(i+1);if(a==="("){const c=s(0,i+1);if(n[r++]!==")")throw new b("expression");return c}if(a&&/^(?:SUM|AVERAGE|AVG|MIN|MAX|COUNT|MEDIAN)$/.test(a)&&Object.prototype.hasOwnProperty.call(t,a))return G(t[a]);if(a&&/^(?:\d+(?:\.\d*)?|\.\d+)(?:E[+-]?\d+)?$/.test(a))return G(Number(a));throw new b("expression")}function s(i,a){let c=o(a);for(;r<n.length;){const d=n[r],u=d==="+"||d==="-"?1:d==="*"||d==="/"?2:0;if(!u||u<i)break;r++;const m=s(u+1,a+1);if(d==="/"&&m===0)throw new b("division");c=G(d==="+"?c+m:d==="-"?c-m:d==="*"?c*m:c/m)}return c}const l=s(1,0);if(r!==n.length)throw new b("expression");return l}function In(e){const t=e.maxCells??1e5,n=e.maxScannedCells??2e5,r=e.precision??2;if(![t,n].every(o=>Number.isSafeInteger(o)&&o>=1&&o<=2e6))throw new b("limit");if(!Number.isInteger(r)||r<0||r>12)throw new b("precision");return{maxCells:t,maxScanned:n,precision:r}}async function An(e,t,n={}){const r=In(n),o={scanned:0,maxScanned:r.maxScanned,signal:n.signal,yieldToHost:n.yieldToHost??(()=>new Promise(a=>setTimeout(a,0)))};K(o.signal);const s=await Cn(e,wn(e,t,r.maxCells),o),l=n.operation??"sum";if(!["sum","average","min","max","count","median","expression"].includes(l))throw new b("expression");let i=null;if(l==="count")i=s.values.length;else if(s.values.length)if(l==="median")i=await Se(s.values,o);else{const a=Pn(s.values);l==="expression"?(/\bMEDIAN\b/i.test(n.expression??"")&&(a.MEDIAN=await Se(s.values,o)),i=Ke(n.expression??"",a)):i=a[l.toUpperCase()]}if(K(o.signal),i!==null&&Number.isInteger(i)&&!Number.isSafeInteger(i))throw new b("precision");return{value:i,formatted:i===null?"—":i.toFixed(r.precision),numericCells:s.values.length,excludedCells:s.excluded,selectedCells:s.selected,precision:r.precision}}exports.DEFAULT_BORDER_PT=x.DEFAULT_BORDER_PT;exports.DEFAULT_FONT_FAMILY=x.DEFAULT_FONT_FAMILY;exports.DEFAULT_FONT_PT=x.DEFAULT_FONT_PT;exports.DEFAULT_STROKE_COLOR=x.DEFAULT_STROKE_COLOR;exports.DEFAULT_TEXT_COLOR=x.DEFAULT_TEXT_COLOR;exports.LINE_HEIGHT=x.LINE_HEIGHT;exports.RENDER_PLAN_SCHEMA_VERSION=x.RENDER_PLAN_SCHEMA_VERSION;exports.SCHEMA_VERSION_MACH=x.SCHEMA_VERSION_MACH;exports.isImageBackedComponent=x.isImageBackedComponent;exports.isRichText=x.isRichText;exports.PaginatePageLimitError=F.PaginatePageLimitError;exports.ReportSourceError=F.ReportSourceError;exports.createReportSource=F.createReportSource;exports.datasetJsonSchema=F.datasetJsonSchema;exports.defineReport=F.defineReport;exports.evalStyleRule=F.evalStyleRule;exports.formatValue=F.formatValue;exports.paginateTemplate=F.paginateTemplate;exports.parseDateLocal=F.parseDateLocal;exports.toExcelNumberFormat=F.toExcelNumberFormat;exports.toNumber=F.toNumber;exports.validateDatasetRows=F.validateDatasetRows;exports.CSS_DPI=f.CSS_DPI;exports.MM_PER_INCH=f.MM_PER_INCH;exports.PAPER_SIZES=f.PAPER_SIZES;exports.mergeComponentStyles=f.mergeComponentStyles;exports.mmToPx=f.mmToPx;exports.mmToPxFactor=f.mmToPxFactor;exports.ptToPx=f.ptToPx;exports.pxToMm=f.pxToMm;exports.resolveBoxBorders=f.resolveBoxBorders;exports.resolveFontSize=f.resolveFontSize;exports.resolveLineHeight=f.resolveLineHeight;exports.resolveStroke=f.resolveStroke;exports.resolveTextColor=f.resolveTextColor;exports.round=f.round;exports.assertRenderPlan=ne.assertRenderPlan;exports.validateComponent=ne.validateComponent;exports.validatePage=ne.validatePage;exports.validateRenderPlan=ne.validateRenderPlan;exports.charWidthEm=_.charWidthEm;exports.createCanvasMeasurer=_.createCanvasMeasurer;exports.createHeuristicMeasurer=_.createHeuristicMeasurer;exports.heuristicMeasurer=_.heuristicMeasurer;exports.measureTextMm=_.measureTextMm;exports.wrapText=_.wrapText;exports.resolveGridLayout=j.resolveGridLayout;exports.OutputAssetError=W.OutputAssetError;exports.resolvePlanAssets=W.resolvePlanAssets;exports.OutputFidelityError=$.OutputFidelityError;exports.inspectOutputCapabilities=$.inspectOutputCapabilities;exports.reportOutputDiagnostics=$.reportOutputDiagnostics;exports.REPORT_TEMPLATE_DOCUMENT_VERSION=D.REPORT_TEMPLATE_DOCUMENT_VERSION;exports.ReportTemplateError=D.ReportTemplateError;exports.createTemplateRegistry=D.createTemplateRegistry;exports.defineReportTemplate=D.defineReportTemplate;exports.parseReportTemplate=D.parseReportTemplate;exports.serializeReportTemplate=D.serializeReportTemplate;exports.validateReportTemplate=D.validateReportTemplate;exports.validateReportTemplateDocument=D.validateReportTemplateDocument;exports.ReportParamValidationError=V.ReportParamValidationError;exports.assertReportParams=V.assertReportParams;exports.isReportDate=V.isReportDate;exports.reportParamsJsonSchema=V.reportParamsJsonSchema;exports.validateReportParamDefinitions=V.validateReportParamDefinitions;exports.validateReportParams=V.validateReportParams;exports.PageBuilder=$e;exports.ReportCalculationError=b;exports.ReportCellEditError=T;exports.ReportCellFieldError=je;exports.ReportTemplateStoreError=H;exports.TemplateBuilder=Oe;exports.applyReportCellEdit=Zt;exports.applyReportCellEditBatch=nn;exports.applyReportEditResult=ln;exports.calculateReportSelection=An;exports.classOf=P;exports.columnsFromContract=Ct;exports.computePageWindow=Ie;exports.createCanvasPager=Et;exports.createMemoryTemplateStore=Dt;exports.createProviderReport=Ot;exports.createReportCellEdit=qt;exports.createReportCellEditBatch=tn;exports.createReportCellResolver=ie;exports.createTableTemplate=Lt;exports.createTemplate=St;exports.createTemplateManager=$t;exports.evaluateReportAggregateExpression=Ke;exports.formatReportCellEdit=Y;exports.formatReportClipboard=on;exports.getReportCellContext=oe;exports.measurePageSizePx=re;exports.parseReportCellFieldInput=pn;exports.parseReportCellInput=ae;exports.parseReportClipboard=sn;exports.planFontSizePx=ft;exports.renderComponent=ue;exports.renderPage=Pe;exports.renderPlan=lt;exports.renderPlanToCanvas=xt;exports.renderPlanToCanvasAsync=Tt;exports.renderPlanToImages=bt;exports.reportCellEditKey=se;exports.resolvePaper=he;exports.summarizeReportCellEdits=rn;exports.validateReportCellFieldDefinition=Ue;
|
package/dist/index.d.cts
CHANGED
|
@@ -45,6 +45,9 @@ export declare interface BoxBorders {
|
|
|
45
45
|
inner: boolean;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
+
/** Read-only local analysis. Never changes the plan, formulas, datasets or business persistence. */
|
|
49
|
+
export declare function calculateReportSelection(plan: RenderPlan, selection: ReportCalculationSelection, options?: ReportSelectionCalculationOptions): Promise<ReportSelectionCalculationResult>;
|
|
50
|
+
|
|
48
51
|
export declare type CanvasImageLoader = (source: string, signal?: AbortSignal) => Promise<CanvasImageSource>;
|
|
49
52
|
|
|
50
53
|
export declare interface CanvasPager {
|
|
@@ -279,6 +282,9 @@ export declare function defineReportTemplate(document: Omit<ReportTemplateDocume
|
|
|
279
282
|
*/
|
|
280
283
|
export declare function evalStyleRule(row: Record<string, unknown>, when: StyleRule["when"]): boolean;
|
|
281
284
|
|
|
285
|
+
/** A tiny arithmetic parser: no functions, property access, globals, assignments or executable source. */
|
|
286
|
+
export declare function evaluateReportAggregateExpression(expression: string, values: Readonly<Record<string, number>>): number;
|
|
287
|
+
|
|
282
288
|
/** 同步 text/raw value,所有输出后端读取同一份更新后的 RenderPlan。 */
|
|
283
289
|
export declare function formatReportCellEdit(context: ReportCellContext, value: ReportCellValue): string;
|
|
284
290
|
|
|
@@ -485,7 +491,7 @@ export declare class OutputAssetError extends Error {
|
|
|
485
491
|
}
|
|
486
492
|
|
|
487
493
|
export declare interface OutputDiagnostic {
|
|
488
|
-
code: "missing-image" | "unsupported-component" | "unsupported-image-format" | "rich-text-flattened" | "nested-components-omitted" | "async-image-required" | "image-decode-failed" | "asset-render-failed" | "asset-budget-exceeded";
|
|
494
|
+
code: "missing-image" | "unsupported-component" | "unsupported-image-format" | "unsupported-style" | "rich-text-flattened" | "nested-components-omitted" | "async-image-required" | "image-decode-failed" | "asset-render-failed" | "asset-budget-exceeded";
|
|
489
495
|
severity: "warning";
|
|
490
496
|
format: OutputFormat;
|
|
491
497
|
pageIndex: number;
|
|
@@ -497,13 +503,27 @@ export declare interface OutputDiagnostic {
|
|
|
497
503
|
message: string;
|
|
498
504
|
}
|
|
499
505
|
|
|
500
|
-
export declare interface OutputDiagnosticOptions {
|
|
506
|
+
export declare interface OutputDiagnosticOptions extends OutputTaskOptions {
|
|
501
507
|
/** Structured fidelity diagnostics; rendering never silently invents missing content. */
|
|
502
508
|
onDiagnostic?: (diagnostic: OutputDiagnostic) => void;
|
|
509
|
+
/** Reject known unsupported content before creating an incomplete file. Default warn. */
|
|
510
|
+
fidelity?: "warn" | "strict";
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
export declare class OutputFidelityError extends Error {
|
|
514
|
+
readonly diagnostics: readonly OutputDiagnostic[];
|
|
515
|
+
readonly code = "output-fidelity";
|
|
516
|
+
constructor(diagnostics: readonly OutputDiagnostic[]);
|
|
503
517
|
}
|
|
504
518
|
|
|
505
519
|
export declare type OutputFormat = "dom" | "canvas" | "pdf" | "xlsx";
|
|
506
520
|
|
|
521
|
+
/** Stage counts are exact completed units; encoding libraries may remain indeterminate. */
|
|
522
|
+
export declare interface OutputTaskOptions {
|
|
523
|
+
signal?: AbortSignal;
|
|
524
|
+
onProgress?: (completed: number, total: number) => void;
|
|
525
|
+
}
|
|
526
|
+
|
|
507
527
|
export declare class PageBuilder {
|
|
508
528
|
private readonly parent;
|
|
509
529
|
private readonly page;
|
|
@@ -579,6 +599,9 @@ export declare type PaperName = keyof typeof PAPER_SIZES;
|
|
|
579
599
|
/** 日历日字符串 → 本地 Date(不含时间的纯日期,杜绝 UTC 偏移) */
|
|
580
600
|
export declare function parseDateLocal(input: string): Date | null;
|
|
581
601
|
|
|
602
|
+
/** Core type parsing is authoritative; field controls add restrictions, never coerce IDs or bypass readonly. */
|
|
603
|
+
export declare function parseReportCellFieldInput(context: ReportCellContext, input: ReportCellValue, field?: ReportCellFieldOptions): ReportCellValue;
|
|
604
|
+
|
|
582
605
|
/** 严格解析编辑输入;文本列不隐式推断数值,清空数值/布尔列得到 null。 */
|
|
583
606
|
export declare function parseReportCellInput(context: ReportCellContext, input: ReportCellValue): ReportCellValue;
|
|
584
607
|
|
|
@@ -700,6 +723,20 @@ export declare function renderPlanToImages(plan: RenderPlan, options?: ImageRend
|
|
|
700
723
|
/** 模板存储文档版本;与渲染计划版本独立演进。 */
|
|
701
724
|
export declare const REPORT_TEMPLATE_DOCUMENT_VERSION = "1.0";
|
|
702
725
|
|
|
726
|
+
export declare class ReportCalculationError extends Error {
|
|
727
|
+
readonly code: ReportCalculationErrorCode;
|
|
728
|
+
constructor(code: ReportCalculationErrorCode);
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
export declare type ReportCalculationErrorCode = "selection" | "limit" | "expression" | "division" | "overflow" | "precision";
|
|
732
|
+
|
|
733
|
+
export declare type ReportCalculationOperation = "sum" | "average" | "min" | "max" | "count" | "median" | "expression";
|
|
734
|
+
|
|
735
|
+
export declare interface ReportCalculationSelection {
|
|
736
|
+
anchor: ReportCellAddress;
|
|
737
|
+
focus: ReportCellAddress;
|
|
738
|
+
}
|
|
739
|
+
|
|
703
740
|
/** 预览中的物理坐标;合并单元格使用左上角坐标。 */
|
|
704
741
|
export declare interface ReportCellAddress {
|
|
705
742
|
pageIndex: number;
|
|
@@ -708,6 +745,11 @@ export declare interface ReportCellAddress {
|
|
|
708
745
|
columnIndex: number;
|
|
709
746
|
}
|
|
710
747
|
|
|
748
|
+
export declare interface ReportCellChoice {
|
|
749
|
+
value: Exclude<ReportCellValue, null>;
|
|
750
|
+
label?: string;
|
|
751
|
+
}
|
|
752
|
+
|
|
711
753
|
export declare interface ReportCellContext {
|
|
712
754
|
address: ReportCellAddress;
|
|
713
755
|
cell: Readonly<GridCell>;
|
|
@@ -740,6 +782,45 @@ export declare type ReportCellEditErrorCode = "missing" | "readonly" | "number"
|
|
|
740
782
|
|
|
741
783
|
export declare function reportCellEditKey(edit: Pick<ReportCellEdit, "address" | "source" | "table">): string;
|
|
742
784
|
|
|
785
|
+
declare interface ReportCellFieldBase {
|
|
786
|
+
/** Presentation only; it never grants write permission. */
|
|
787
|
+
label?: string;
|
|
788
|
+
hint?: string;
|
|
789
|
+
unit?: string;
|
|
790
|
+
required?: boolean;
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
/** Shared structured validation for browser editors, pasted values and backend adapters. */
|
|
794
|
+
export declare class ReportCellFieldError extends Error {
|
|
795
|
+
readonly code: ReportCellFieldErrorCode;
|
|
796
|
+
readonly field: ReportCellFieldOptions;
|
|
797
|
+
readonly expected?: string | number | undefined;
|
|
798
|
+
constructor(code: ReportCellFieldErrorCode, field: ReportCellFieldOptions, expected?: string | number | undefined);
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
export declare type ReportCellFieldErrorCode = "definition" | "type" | "required" | "min" | "max" | "precision" | "length" | "choice" | "date";
|
|
802
|
+
|
|
803
|
+
export declare type ReportCellFieldOptions = ReportCellFieldBase & ({
|
|
804
|
+
type: "text";
|
|
805
|
+
maxLength?: number;
|
|
806
|
+
} | {
|
|
807
|
+
type: "number";
|
|
808
|
+
min?: number;
|
|
809
|
+
max?: number;
|
|
810
|
+
precision?: number;
|
|
811
|
+
} | {
|
|
812
|
+
type: "boolean";
|
|
813
|
+
trueLabel?: string;
|
|
814
|
+
falseLabel?: string;
|
|
815
|
+
} | {
|
|
816
|
+
type: "enum";
|
|
817
|
+
options: readonly ReportCellChoice[];
|
|
818
|
+
} | {
|
|
819
|
+
type: "date";
|
|
820
|
+
min?: string;
|
|
821
|
+
max?: string;
|
|
822
|
+
});
|
|
823
|
+
|
|
743
824
|
export declare interface ReportCellInput {
|
|
744
825
|
address: ReportCellAddress;
|
|
745
826
|
value: ReportCellValue;
|
|
@@ -824,7 +905,7 @@ export declare interface ReportFetcher {
|
|
|
824
905
|
getParamDefs?: (reportIds: string[]) => ReportParamDef[];
|
|
825
906
|
}
|
|
826
907
|
|
|
827
|
-
export declare interface ReportFetchInput {
|
|
908
|
+
export declare interface ReportFetchInput extends ReportTaskMonitoring {
|
|
828
909
|
reportIds: string[];
|
|
829
910
|
params: Record<string, string>;
|
|
830
911
|
signal?: AbortSignal;
|
|
@@ -953,6 +1034,28 @@ export declare interface ReportSaveResult {
|
|
|
953
1034
|
diagnostics?: ReportDiagnostic[];
|
|
954
1035
|
}
|
|
955
1036
|
|
|
1037
|
+
export declare interface ReportSelectionCalculationOptions {
|
|
1038
|
+
operation?: ReportCalculationOperation;
|
|
1039
|
+
/** Only aggregate names, finite numeric constants, + - * / and parentheses. No cell/Excel formulas. */
|
|
1040
|
+
expression?: string;
|
|
1041
|
+
precision?: number;
|
|
1042
|
+
maxCells?: number;
|
|
1043
|
+
maxScannedCells?: number;
|
|
1044
|
+
signal?: AbortSignal;
|
|
1045
|
+
/** Cooperative scheduler; default yields to the browser/Node event loop. */
|
|
1046
|
+
yieldToHost?: () => Promise<void>;
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1049
|
+
export declare interface ReportSelectionCalculationResult {
|
|
1050
|
+
value: number | null;
|
|
1051
|
+
formatted: string;
|
|
1052
|
+
numericCells: number;
|
|
1053
|
+
excludedCells: number;
|
|
1054
|
+
selectedCells: number;
|
|
1055
|
+
/** IEEE-754 arithmetic; presentation rounding does not change source values. */
|
|
1056
|
+
precision: number;
|
|
1057
|
+
}
|
|
1058
|
+
|
|
956
1059
|
export declare interface ReportSource extends ReportFetcher {
|
|
957
1060
|
getParamDefs(reportIds: string[]): ReportParamDef[];
|
|
958
1061
|
}
|
|
@@ -963,6 +1066,25 @@ export declare class ReportSourceError extends Error {
|
|
|
963
1066
|
constructor(code: ReportSourceError["code"], message: string, cause?: unknown);
|
|
964
1067
|
}
|
|
965
1068
|
|
|
1069
|
+
/** 阶段事件只包含可序列化值;不表示估算百分比,也不包含业务数据。 */
|
|
1070
|
+
export declare interface ReportTaskEvent {
|
|
1071
|
+
taskId: string;
|
|
1072
|
+
correlationId?: string;
|
|
1073
|
+
stage: "query" | "validate" | "layout" | "encode";
|
|
1074
|
+
status: "started" | "completed" | "failed";
|
|
1075
|
+
reportId?: string;
|
|
1076
|
+
completed?: number;
|
|
1077
|
+
total?: number;
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1080
|
+
export declare interface ReportTaskMonitoring {
|
|
1081
|
+
taskId?: string;
|
|
1082
|
+
correlationId?: string;
|
|
1083
|
+
onEvent?: ReportTaskObserver;
|
|
1084
|
+
}
|
|
1085
|
+
|
|
1086
|
+
export declare type ReportTaskObserver = (event: ReportTaskEvent) => void;
|
|
1087
|
+
|
|
966
1088
|
export declare interface ReportTemplate {
|
|
967
1089
|
schemaVersion?: string;
|
|
968
1090
|
/** 参数定义(可选;宿主也可经 ReportPreview 的 paramDefs prop 提供,prop 优先) */
|
|
@@ -1282,6 +1404,9 @@ export declare function validatePage(page: unknown, path: string, errors: Valida
|
|
|
1282
1404
|
|
|
1283
1405
|
export declare function validateRenderPlan(input: unknown): ValidationResult;
|
|
1284
1406
|
|
|
1407
|
+
/** Check configuration before opening an input, including JSON/JavaScript callers. */
|
|
1408
|
+
export declare function validateReportCellFieldDefinition(context: ReportCellContext, field: ReportCellFieldOptions): void;
|
|
1409
|
+
|
|
1285
1410
|
/** 模板参数配置错误也统一返回结构化问题,不让无效默认值或边界静默进入后端。 */
|
|
1286
1411
|
export declare function validateReportParamDefinitions(defs: readonly ReportParamDef[]): ReportParamIssue[];
|
|
1287
1412
|
|