pagyra-js 0.0.15 → 0.0.17
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/dist/browser/pagyra.min.js +10 -9
- package/dist/browser/pagyra.min.js.map +3 -3
- package/dist/src/core.d.ts +3 -0
- package/dist/src/core.js +2 -0
- package/dist/src/pdf/primitives/pdf-builder.js +9 -4
- package/dist/src/pdf/primitives/pdf-types.d.ts +1 -1
- package/dist/tests/pdf/xref-integrity.spec.d.ts +1 -0
- package/dist/tests/pdf/xref-integrity.spec.js +141 -0
- package/package.json +1 -1
|
@@ -26,20 +26,21 @@ stream
|
|
|
26
26
|
endstream`);return pe([r,e,o])}function Ss(t){let x=[];if(t.title){let e=gx(t.title);k("pdf","debug","serializing metadata title",{title:t.title.slice(0,50),encoded:e}),x.push(`/Title (${e})`)}if(t.author){let e=gx(t.author);k("pdf","debug","serializing metadata author",{author:t.author.slice(0,50),encoded:e}),x.push(`/Author (${e})`)}if(t.subject){let e=gx(t.subject);k("pdf","debug","serializing metadata subject",{subject:t.subject.slice(0,50),encoded:e}),x.push(`/Subject (${e})`)}if(t.keywords?.length){let e=t.keywords.join(", "),n=gx(e);k("pdf","debug","serializing metadata keywords",{keywords:e.slice(0,50),encoded:n}),x.push(`/Keywords (${n})`)}if(t.producer){let e=gx(t.producer);k("pdf","debug","serializing metadata producer",{producer:t.producer.slice(0,50),encoded:e}),x.push(`/Producer (${e})`)}return`<< ${x.join(" ")} >>`}function vs(t,x,e){let n=[`/Size ${t}`,`/Root ${x.objectNumber} 0 R`];return e&&n.push(`/Info ${e.objectNumber} 0 R`),`<< ${n.join(" ")} >>`}function Ls(t){return`${t.toString().padStart(10,"0")} 00000 n
|
|
27
27
|
`}function he(t){return Number.isInteger(t)?t.toString():t.toFixed(2).replace(/0+$/,"").replace(/\.$/,"")}function Cs(t){return t.replace(/[^!-~]/g,"")}function Ul(t){let x=Cs(t).toLowerCase();return x==="symbol"||x==="zapfdingbats"}function Ts(t){return!!(t.title||t.author||t.subject||t.keywords?.length||t.producer)}function Hl(t){return Number.isFinite(t)?t<=0?0:t>=1?1:t:1}var Kt=class{constructor(x={}){this.metadata=x;this.pages=[];this.refManager=new Ht;this.fontRegistry=new zt;this.imageRegistry=new Gt;this.extGStateRegistry=new jt;this.shadingRegistry=new $t;this.patternRegistry=new Vt;this.objectRegistry=new _t;this.streamRegistry=new Yt}addPage(x){this.pages.push(x)}finalize(){let x=[],e=J0(`%PDF-1.4
|
|
28
28
|
`),n=(s,d)=>{let f=this.refManager.ensureRefNumber(d??{objectNumber:0}),c;if(typeof s=="string")c=J0(s);else if(s instanceof Uint8Array)c=s;else{let l=Xt(s);c=J0(l)}return x.push({ref:f,body:c}),f};this.reserveObjectNumbers(),this.buildFonts(n),this.buildExtGStates(n),this.buildShadings(n),this.buildPatterns(n),this.buildImages(n),this.buildStreams(n),this.buildCustomObjects(n);let r=this.buildPages(n),o=this.buildPagesTree(r,n),a=this.buildCatalog(o,n),i=this.buildMetadata(n);return this.assemblePdf(e,x,a,i)}reserveObjectNumbers(){for(let x of this.streamRegistry.getAll())this.refManager.ensureRefNumber(x.ref);for(let x of this.objectRegistry.getAll())this.refManager.ensureRefNumber(x.ref);for(let x of this.patternRegistry.getAll())this.refManager.ensureRefNumber(x.ref)}buildFonts(x){for(let e of this.fontRegistry.getAll())e.objectRef=x(ws(e.baseFont),e.objectRef)}buildExtGStates(x){for(let e of this.extGStateRegistry.getAll())e.ref=x(Rs(e.alpha),e.ref)}buildShadings(x){for(let e of this.shadingRegistry.getAll())e.ref=x(e.dict,e.ref)}buildPatterns(x){for(let e of this.patternRegistry.getAll())e.ref=x(e.dict,e.ref)}buildImages(x){for(let e of this.imageRegistry.getAll()){let n=["/Type /XObject","/Subtype /Image",`/Width ${e.width}`,`/Height ${e.height}`,`/ColorSpace /${e.colorSpace}`,`/BitsPerComponent ${e.bitsPerComponent}`];e.filter&&n.push(`/Filter /${e.filter}`),e.sMask&&n.push(`/SMask ${e.sMask.objectNumber} 0 R`);let r=qt(e.data,n);e.ref=x(r,e.ref)}}buildStreams(x){for(let e of this.streamRegistry.getAll()){let n=Object.entries(e.headers).map(([o,a])=>`/${o} ${a}`),r=qt(e.data,n);e.ref=x(r,e.ref)}}buildCustomObjects(x){for(let e of this.objectRegistry.getAll())e.ref=x(e.value,e.ref)}buildPages(x){let e=[];for(let n of this.pages){let r=x(qt(n.contents)),o=this.buildPageResources(n),a=this.buildPageAnnotations(n,x),i=o.length>0?`/Resources << ${o.join(" ")} >>`:"",s=a.length>0?`/Annots [${a.map(c=>`${c.objectNumber} 0 R`).join(" ")}]`:"",d=["<<","/Type /Page",`/MediaBox [0 0 ${he(n.width)} ${he(n.height)}]`,i,s,`/Contents ${r.objectNumber} 0 R`,">>"].filter(Boolean).join(`
|
|
29
|
-
`),f=x(d);e.push(f)}return e}buildPageResources(x){let e=[],n=[];for(let[s,d]of x.resources.fonts)n.push(`/${s} ${d.objectNumber} 0 R`);n.length>0&&e.push(`/Font << ${n.join(" ")} >>`);let r=[];for(let[s,d]of x.resources.xObjects)r.push(`/${s} ${d.objectNumber} 0 R`);r.length>0&&e.push(`/XObject << ${r.join(" ")} >>`);let o=[];for(let[s,d]of x.resources.extGStates)o.push(`/${s} ${d.objectNumber} 0 R`);o.length>0&&e.push(`/ExtGState << ${o.join(" ")} >>`);let a=[];for(let[s,d]of x.resources.shadings)a.push(`/${s} ${d.objectNumber} 0 R`);a.length>0&&e.push(`/Shading << ${a.join(" ")} >>`);let i=[];if(x.resources.patterns){for(let[s,d]of x.resources.patterns)i.push(`/${s} ${d.objectNumber} 0 R`);i.length>0&&e.push(`/Pattern << ${i.join(" ")} >>`)}return e}buildPageAnnotations(x,e){let n=[];for(let r of x.annotations){let o=e(r);n.push(o)}return n}buildPagesTree(x,e){let n=x.map(r=>`${r.objectNumber} 0 R`).join(" ");return e(["<<","/Type /Pages",`/Count ${x.length}`,`/Kids [${n}]`,">>"].join(`
|
|
29
|
+
`),f=x(d);e.push(f)}return e}buildPageResources(x){let e=[],n=[];for(let[s,d]of x.resources.fonts)n.push(`/${s} ${d.objectNumber} 0 R`);n.length>0&&e.push(`/Font << ${n.join(" ")} >>`);let r=[];for(let[s,d]of x.resources.xObjects)r.push(`/${s} ${d.objectNumber} 0 R`);r.length>0&&e.push(`/XObject << ${r.join(" ")} >>`);let o=[];for(let[s,d]of x.resources.extGStates)o.push(`/${s} ${d.objectNumber} 0 R`);o.length>0&&e.push(`/ExtGState << ${o.join(" ")} >>`);let a=[];for(let[s,d]of x.resources.shadings)a.push(`/${s} ${d.objectNumber} 0 R`);a.length>0&&e.push(`/Shading << ${a.join(" ")} >>`);let i=[];if(x.resources.patterns){for(let[s,d]of x.resources.patterns)i.push(`/${s} ${d.objectNumber} 0 R`);i.length>0&&e.push(`/Pattern << ${i.join(" ")} >>`)}return e}buildPageAnnotations(x,e){let n=[];for(let r of x.annotations??[]){let o=e(r);n.push(o)}return n}buildPagesTree(x,e){let n=x.map(r=>`${r.objectNumber} 0 R`).join(" ");return e(["<<","/Type /Pages",`/Count ${x.length}`,`/Kids [${n}]`,">>"].join(`
|
|
30
30
|
`))}buildCatalog(x,e){return e(["<<","/Type /Catalog",`/Pages ${x.objectNumber} 0 R`,">>"].join(`
|
|
31
|
-
`))}buildMetadata(x){return Ts(this.metadata)?x(Ss(this.metadata)):null}assemblePdf(x,e,n,r){let o=[`0000000000
|
|
32
|
-
`
|
|
31
|
+
`))}buildMetadata(x){return Ts(this.metadata)?x(Ss(this.metadata)):null}assemblePdf(x,e,n,r){let o=[x],a=x.length,i=this.refManager.getObjectCount(),s=new Array(i).fill(`0000000000 00000 f
|
|
32
|
+
`);s[0]=`0000000000 65535 f
|
|
33
|
+
`;for(let c of e){let l=J0(`${c.ref.objectNumber} 0 obj
|
|
33
34
|
`),u=J0(`
|
|
34
35
|
endobj
|
|
35
|
-
`),p=pe([l,c.body,u]);
|
|
36
|
-
0 ${
|
|
37
|
-
${
|
|
38
|
-
${vs(
|
|
36
|
+
`),p=pe([l,c.body,u]),m=c.ref.objectNumber;m>0&&m<i&&(s[m]=Ls(a)),o.push(p),a+=p.length}let d=a,f=J0(`xref
|
|
37
|
+
0 ${i}
|
|
38
|
+
${s.join("")}trailer
|
|
39
|
+
${vs(i,n,r)}
|
|
39
40
|
startxref
|
|
40
|
-
${
|
|
41
|
+
${d}
|
|
41
42
|
%%EOF
|
|
42
|
-
`);return a.push(f),pe(a)}};var H6=class{constructor(x={}){this.builder=new Kt(x)}registerStandardFont(x){return this.builder.fontRegistry.register(x)}addPage(x){let e={fonts:x.resources?.fonts??new Map,xObjects:x.resources?.xObjects??new Map,extGStates:x.resources?.extGStates??new Map,shadings:x.resources?.shadings??new Map,patterns:x.resources?.patterns??new Map};this.builder.addPage({width:x.width,height:x.height,contents:x.contents,resources:e,annotations:x.annotations??[]})}registerImage(x){return this.builder.imageRegistry.register(x)}registerExtGState(x){return this.builder.extGStateRegistry.register(x)}registerShading(x,e){return this.builder.shadingRegistry.register(x,e)}registerPattern(x,e){return this.builder.patternRegistry.register(x,e)}register(x){return this.builder.objectRegistry.register(x)}registerStream(x,e={}){return this.builder.streamRegistry.register(x,e)}finalize(){return this.builder.finalize()}};function b7(t,x,e){return{hf:t,pageSize:x,baseBox:e}}function m7(t,x){let e=Ps(t.hf,x,"header"),n=Ps(t.hf,x,"footer"),r=Fs(e),o=Fs(n),a=Bs(e),i=Bs(n);return{headerHeightPt:r,footerHeightPt:o,headerHeightPx:a,footerHeightPx:i,layerMode:t.hf.layerMode,header:e,footer:n,clipOverflow:t.hf.clipOverflow}}function p7(t,x,e){return As(t.header,x,e)}function h7(t,x,e){return As(t.footer,x,e)}function Ps(t,x,e){let n=e==="header"?t.maxHeaderHeightPx??0:t.maxFooterHeightPx??0,r=o=>{if(o)return{content:o,maxHeightPt:x(n),maxHeightPx:n}};return e==="header"?{defaultVariant:r(t.headerHtml),firstVariant:r(t.headerFirstHtml),evenVariant:r(t.headerEvenHtml),oddVariant:r(t.headerOddHtml)}:{defaultVariant:r(t.footerHtml),firstVariant:r(t.footerFirstHtml),evenVariant:r(t.footerEvenHtml),oddVariant:r(t.footerOddHtml)}}function Fs(t){let x=[t.defaultVariant?.maxHeightPt??0,t.firstVariant?.maxHeightPt??0,t.evenVariant?.maxHeightPt??0,t.oddVariant?.maxHeightPt??0];return Math.max(...x)}function Bs(t){let x=[t.defaultVariant?.maxHeightPx??0,t.firstVariant?.maxHeightPx??0,t.evenVariant?.maxHeightPx??0,t.oddVariant?.maxHeightPx??0];return Math.max(...x)}function As(t,x,e){if(x===1&&t.firstVariant)return t.firstVariant;if(e>1){if(x%2===0&&t.evenVariant)return t.evenVariant;if(x%2===1&&t.oddVariant)return t.oddVariant}return t.defaultVariant}function g7(t,x,e={}){let n=new Map;for(let[r,o]of Object.entries(t??{}))n.set(r,o);return n.set("page",(r,o)=>String(r)),n.set("pageNumber",(r,o)=>String(r)),n.set("pages",(r,o)=>String(o)),n.set("totalPages",(r,o)=>String(o)),!n.has("title")&&e.title&&n.set("title",e.title),n.set("date",()=>new Date().toLocaleDateString()),n}function z6(t,x,e,n){let r=t.replace(/\{\{([^}]+)\}\}/g,(o,a)=>{let i=x.get(a.trim());return i===void 0?"":typeof i=="string"?i:i(e,n)});return r=r.replace(/\{([^}]+)\}/g,(o,a)=>{let i=x.get(a.trim());return i===void 0?"":typeof i=="string"?i:i(e,n)}),r}var Ms=new Map;function W(t,x){Ms.set(t,x)}function ks(t){return Ms.get(t)}function Is(t){switch(t){case"block":return"block";case"inline":return"inline";case"inline-block":return"inline-block";case"flex":return"flex";case"grid":return"grid";case"table":return"table";case"table-row":return"table-row";case"table-cell":return"table-cell";case"table-row-group":return"table-row-group";case"table-header-group":return"table-header-group";case"table-footer-group":return"table-footer-group";case"table-caption":return"table-caption";case"none":return"none";default:return}}function Ns(t){if(t)switch(t.trim().toLowerCase()){case"flex-start":return"flex-start";case"flex-end":return"flex-end";case"center":return"center";case"space-between":return"space-between";case"space-around":return"space-around";case"space-evenly":return"space-evenly";case"start":return"start";case"end":return"end";case"left":return"left";case"right":return"right";default:return}}function y7(t){if(t)switch(t.trim().toLowerCase()){case"flex-start":return"flex-start";case"flex-end":return"flex-end";case"center":return"center";case"baseline":return"baseline";case"stretch":return"stretch";default:return}}function Es(t){if(t)switch(t.trim().toLowerCase()){case"flex-start":return"flex-start";case"flex-end":return"flex-end";case"center":return"center";case"space-between":return"space-between";case"space-around":return"space-around";case"space-evenly":return"space-evenly";case"stretch":return"stretch";default:return}}function Ds(t){if(!t)return;let x=t.trim().toLowerCase();return x==="auto"?"auto":y7(x)}function Os(t){if(!t)return;let x=t.trim().toLowerCase();switch(x){case"row":case"row-reverse":case"column":case"column-reverse":return x;default:return}}function Ws(t,x){x.display=Is(t)}function Us(t,x){let e=Ns(t);e!==void 0&&(x.justifyContent=e)}function Hs(t,x){let e=y7(t);e!==void 0&&(x.alignItems=e)}function zs(t,x){let e=Es(t);e!==void 0&&(x.alignContent=e)}function Gs(t,x){let e=Ds(t);e!==void 0&&(x.alignSelf=e)}function js(t,x){let e=Os(t);e!==void 0&&(x.flexDirection=e)}function $s(t,x){let e=t.trim().toLowerCase();e==="nowrap"?x.flexWrap=!1:(e==="wrap"||e==="wrap-reverse")&&(x.flexWrap=!0)}function Vs(t,x){x.color=t}function _s(t,x){x.backgroundLayers||(x.backgroundLayers=[]),x.backgroundLayers.push({kind:"color",color:t})}function Ys(t){if(!Number.isFinite(t??NaN))return 0;let x=Number(t);return x>0?x:0}function Zt(t){return Number.isFinite(t)?t<0?0:t:0}function l6(t){let x=[],e="",n=0,r=null;for(let o of t){if(r){e+=o,o===r&&(r=null);continue}if(o==="'"||o==='"'){r=o,e+=o;continue}if(o==="("){n+=1,e+=o;continue}if(o===")"){n=Math.max(0,n-1),e+=o;continue}if(o===","&&n===0){e.trim()&&x.push(e.trim()),e="";continue}e+=o}return e.trim()&&x.push(e.trim()),x}function I0(t){let x=[],e="",n=0,r=null;for(let o of t){if(r){e+=o,o===r&&(r=null);continue}if(o==="'"||o==='"'){r=o,e+=o;continue}if(o==="("){n+=1,e+=o;continue}if(o===")"){n=Math.max(0,n-1),e+=o;continue}if(/\s/.test(o)&&n===0){e.trim()&&x.push(e.trim()),e="";continue}e+=o}return e.trim()&&x.push(e.trim()),x}var zl=new Set(["none","hidden","solid","dashed","dotted","double","groove","ridge","inset","outset"]),w7={thin:1,medium:3,thick:5},R7=w7.medium;function qs(t){let x=I0(t);if(x.length===0)return null;let e,n,r;for(let o of x){let a=o.trim();if(!a)continue;if(e===void 0){let s=u6(a);if(s!==void 0){e=s;continue}}let i=a.toLowerCase();if(!n&&zl.has(i)){n=i;continue}r===void 0&&(r=a)}return n==="none"||n==="hidden"?e=0:e===void 0&&n&&(e=R7),{width:e,style:n,color:r}}function u6(t){let x=t.trim().toLowerCase();if(x)return x in w7?w7[x]:r0(t)}function Ks(t){let x=t.trim();if(!x)return null;let[e,n]=x.split("/").map(a=>a.trim()),r=Xs(e);if(!r)return null;let o=n?Xs(n):r;return o?{topLeft:{x:r[0],y:o[0]},topRight:{x:r[1],y:o[1]},bottomRight:{x:r[2],y:o[2]},bottomLeft:{x:r[3],y:o[3]}}:null}function ge(t){let x=t.trim();if(!x)return;let[e,n]=x.split("/").map(i=>i.trim()),r=I0(e);if(r.length===0)return;let o=Qt(r[0]),a;if(n){let i=I0(n);a=Qt(i[0])}else r.length>1?a=Qt(r[1]):a=o;return{x:o,y:a}}function Qt(t){let x=r0(t);return x===void 0?0:typeof x=="number"?Ys(x):x}function Xs(t){if(!t)return null;let x=I0(t);if(x.length===0)return null;let e=x.map(n=>Qt(n));switch(e.length){case 1:return[e[0],e[0],e[0],e[0]];case 2:return[e[0],e[1],e[0],e[1]];case 3:return[e[0],e[1],e[2],e[1]];default:return[e[0],e[1],e[2],e[3]]}}function Zs(t){let x=t.trim();if(!x)return;let e=x.toLowerCase();if(e==="none"||e==="initial")return[];if(e==="inherit"||e==="revert"||e==="revert-layer")return;let n=l6(x),r=[];for(let o of n){let a=Gl(o);a&&r.push(a)}return r}function Gl(t){let x=I0(t);if(x.length===0)return null;let e=!1,n=[],r;for(let f of x){if(f.toLowerCase()==="inset"){e=!0;continue}let l=r0(f);if(l!==void 0){n.push(l);continue}if(r===void 0&&jl(f)){r=f;continue}}if(n.length<2)return null;let o=(f,c=!1)=>f===void 0?0:typeof f=="number"&&c?Zt(f):f,a=o(n[0]),i=o(n[1]),s=o(n[2],!0),d=o(n[3]);return{inset:e,offsetX:a,offsetY:i,blurRadius:s,spreadRadius:d,color:r}}function jl(t){let x=t.toLowerCase();return x.startsWith("#")||x.startsWith("rgb(")||x.startsWith("rgba(")||x.startsWith("hsl(")||x.startsWith("hsla(")?!0:["transparent","black","white","red","green","blue","yellow","gray","grey"].includes(x)}function K0(t,x,e,n){let r=qs(t);r&&(n&&n(r.style),r.style==="none"||r.style==="hidden"?x(0):r.width!==void 0?x(r.width):r.style&&x(R7),r.color!==void 0&&e(r.color))}function Qs(t,x){let e=I0(t);if(e.length===0)return;let[n]=e.length===1?[e[0],e[0],e[0],e[0]]:e.length===2?[e[0],e[1],e[0],e[1]]:e.length===3?[e[0],e[1],e[2],e[1]]:[e[0],e[1],e[2],e[3]];n&&x(n)}function Js(t,x){let e=I0(t);e.length!==0&&x(e[0]?.toLowerCase())}function ye(t){let x=I0(t);if(x.length===0)return!1;let e=x[0]?.toLowerCase();return e==="none"||e==="hidden"}function G6(t,x,e=Lx){let n=I0(t);if(n.length===0)return;let r=n.map(d=>e(d)),[o,a,i,s]=r.length===1?[r[0],r[0],r[0],r[0]]:r.length===2?[r[0],r[1],r[0],r[1]]:r.length===3?[r[0],r[1],r[2],r[1]]:[r[0],r[1],r[2],r[3]];x(o,a,i,s)}function xd(t,x){Qs(t,e=>{x.borderColor=e})}function ed(t,x){let e=Zs(t);e!==void 0&&(x.boxShadows=e)}function td(t,x){K0(t,e=>{x.borderTop=e,x.borderRight=e,x.borderBottom=e,x.borderLeft=e},e=>{x.borderColor=e??x.borderColor},e=>{if(!e)return;let n=e.toLowerCase();x.borderStyleTop=n,x.borderStyleRight=n,x.borderStyleBottom=n,x.borderStyleLeft=n})}function nd(t,x){K0(t,e=>{x.borderTop=e},e=>{x.borderColor=e??x.borderColor},e=>{e&&(x.borderStyleTop=e.toLowerCase())})}function rd(t,x){K0(t,e=>{x.borderRight=e},e=>{x.borderColor=e??x.borderColor},e=>{e&&(x.borderStyleRight=e.toLowerCase())})}function od(t,x){K0(t,e=>{x.borderBottom=e},e=>{x.borderColor=e??x.borderColor},e=>{e&&(x.borderStyleBottom=e.toLowerCase())})}function ad(t,x){K0(t,e=>{x.borderLeft=e},e=>{x.borderColor=e??x.borderColor},e=>{e&&(x.borderStyleLeft=e.toLowerCase())})}function id(t,x){let e=Ks(t);e&&(x.borderTopLeftRadiusX=e.topLeft.x,x.borderTopLeftRadiusY=e.topLeft.y,x.borderTopRightRadiusX=e.topRight.x,x.borderTopRightRadiusY=e.topRight.y,x.borderBottomRightRadiusX=e.bottomRight.x,x.borderBottomRightRadiusY=e.bottomRight.y,x.borderBottomLeftRadiusX=e.bottomLeft.x,x.borderBottomLeftRadiusY=e.bottomLeft.y)}function sd(t,x){let e=ge(t);e&&(x.borderTopLeftRadiusX=e.x,x.borderTopLeftRadiusY=e.y)}function dd(t,x){let e=ge(t);e&&(x.borderTopRightRadiusX=e.x,x.borderTopRightRadiusY=e.y)}function fd(t,x){let e=ge(t);e&&(x.borderBottomRightRadiusX=e.x,x.borderBottomRightRadiusY=e.y)}function cd(t,x){let e=ge(t);e&&(x.borderBottomLeftRadiusX=e.x,x.borderBottomLeftRadiusY=e.y)}function ld(t,x){G6(t,(e,n,r,o)=>{x.borderTop=e,x.borderRight=n,x.borderBottom=r,x.borderLeft=o},u6)}function ud(t,x){x.borderTop=u6(t)??x.borderTop}function bd(t,x){x.borderRight=u6(t)??x.borderRight}function md(t,x){x.borderBottom=u6(t)??x.borderBottom}function pd(t,x){x.borderLeft=u6(t)??x.borderLeft}function hd(t,x){t.trim()&&(x.borderColor=t.trim())}function gd(t,x){t.trim()&&(x.borderColor=t.trim())}function yd(t,x){t.trim()&&(x.borderColor=t.trim())}function wd(t,x){t.trim()&&(x.borderColor=t.trim())}function Rd(t,x){Js(t,e=>{if(!e)return;let n=e.toLowerCase();x.borderStyleTop=n,x.borderStyleRight=n,x.borderStyleBottom=n,x.borderStyleLeft=n,(n==="none"||n==="hidden")&&(x.borderTop=0,x.borderRight=0,x.borderBottom=0,x.borderLeft=0)})}function Sd(t,x){let e=t.trim().toLowerCase();e&&(x.borderStyleTop=e,ye(t)&&(x.borderTop=0))}function vd(t,x){let e=t.trim().toLowerCase();e&&(x.borderStyleRight=e,ye(t)&&(x.borderRight=0))}function Ld(t,x){let e=t.trim().toLowerCase();e&&(x.borderStyleBottom=e,ye(t)&&(x.borderBottom=0))}function Cd(t,x){let e=t.trim().toLowerCase();e&&(x.borderStyleLeft=e,ye(t)&&(x.borderLeft=0))}function Td(t,x){let e=t.trim().toLowerCase();x.borderModel=e==="collapse"?"collapse":"separate"}function Pd(t,x){K0(t,e=>{x.borderTop=e},e=>{x.borderColor=e??x.borderColor},e=>{e&&(x.borderStyleTop=e.toLowerCase())})}function Fd(t,x){K0(t,e=>{x.borderBottom=e},e=>{x.borderColor=e??x.borderColor},e=>{e&&(x.borderStyleBottom=e.toLowerCase())})}function Bd(t,x){K0(t,e=>{x.borderLeft=e},e=>{x.borderColor=e??x.borderColor},e=>{e&&(x.borderStyleLeft=e.toLowerCase())})}function Ad(t,x){K0(t,e=>{x.borderRight=e},e=>{x.borderColor=e??x.borderColor},e=>{e&&(x.borderStyleRight=e.toLowerCase())})}function Md(t,x){G6(t,(e,n,r,o)=>{x.marginTop=e,x.marginRight=n,x.marginBottom=r,x.marginLeft=o})}function kd(t,x){x.marginTop=r0(t)??x.marginTop}function Id(t,x){x.marginRight=Lx(t)??x.marginRight}function Nd(t,x){x.marginBottom=r0(t)??x.marginBottom}function Ed(t,x){x.marginLeft=Lx(t)??x.marginLeft}function Dd(t,x){x.marginTop=r0(t)??x.marginTop}function Od(t,x){x.marginBottom=r0(t)??x.marginBottom}function Wd(t,x){x.marginLeft=Lx(t)??x.marginLeft}function Ud(t,x){x.marginRight=Lx(t)??x.marginRight}function Hd(t,x){G6(t,(e,n,r,o)=>{x.paddingTop=e,x.paddingRight=n,x.paddingBottom=r,x.paddingLeft=o},r0)}function zd(t,x){x.paddingTop=r0(t)??x.paddingTop}function Gd(t,x){x.paddingRight=r0(t)??x.paddingRight}function jd(t,x){x.paddingBottom=r0(t)??x.paddingBottom}function $d(t,x){x.paddingLeft=r0(t)??x.paddingLeft}function Vd(t,x){x.paddingTop=r0(t)??x.paddingTop}function _d(t,x){x.paddingBottom=r0(t)??x.paddingBottom}function Yd(t,x){x.paddingLeft=r0(t)??x.paddingLeft}function Xd(t,x){x.paddingRight=r0(t)??x.paddingRight}var $l=/^(-?\d+(?:\.\d+)?)%$/;function j6(t){let x=r0(t);if(x!==void 0)return x;let e=$l.exec(t.trim());if(!e)return;let n=Number.parseFloat(e[1]);if(!Number.isNaN(n))return v6(n/100)}function qd(t,x){let e=j6(t);e!==void 0&&(x.width=e)}function Kd(t,x){let e=j6(t);e!==void 0&&(x.minWidth=e)}function Zd(t,x){let e=j6(t);e!==void 0&&(x.maxWidth=e)}function Qd(t,x){let e=j6(t);e!==void 0&&(x.height=e)}function Jd(t,x){let e=j6(t);e!==void 0&&(x.minHeight=e)}function xf(t,x){let e=j6(t);e!==void 0&&(x.maxHeight=e)}function ef(t,x){x.fontSize=Ue(t)??x.fontSize}function Vl(t){let x=t.trim();if(!x)return;let e=x.toLowerCase();if(e==="normal")return{kind:"normal"};if(/^[+-]?\d+(?:\.\d+)?%$/.test(e)){let r=Number.parseFloat(e.slice(0,-1));return Number.isNaN(r)?void 0:{kind:"unitless",value:r/100}}if(/^[+-]?\d+(?:\.\d+)?$/.test(e)){let r=Number.parseFloat(e);return Number.isNaN(r)?void 0:{kind:"unitless",value:r}}let n=r0(x);if(n!==void 0)return{kind:"length",value:n}}function tf(t,x){let e=Vl(t);e&&(x.lineHeight=e)}function nf(t,x){let e=t.trim();e.toLowerCase()==="auto"?x.zIndex="auto":/^-?\d+$/.test(e)&&(x.zIndex=Number.parseInt(e,10))}function rf(t,x){let e=t.trim().toLowerCase();e!=="inherit"&&(e==="normal"||e==="small-caps")&&(x.fontVariant=e)}function of(t,x){x.fontVariantNumeric=ra(t)}function af(t,x){let e=t.trim().toLowerCase();e!=="inherit"&&(e==="normal"||e==="italic"||e==="oblique"||e.startsWith("oblique "))&&(x.fontStyle=e.startsWith("oblique")?"oblique":e)}function sf(t,x,e,n){let r=ne(t,n);r!==void 0&&(x.fontWeight=r)}function df(t,x){x.fontFamily=t}var _l=/^(-?\d+(?:\.\d+)?)%$/;function Jt(t){let x=t.trim();if(!x)return;if(x.toLowerCase()==="auto")return"auto";let e=r0(x);if(e!==void 0)return e;let n=_l.exec(x);if(n){let r=Number.parseFloat(n[1]);if(!Number.isNaN(r))return v6(r/100)}}function ff(t,x){let e=t.trim().toLowerCase();switch(e){case"static":case"relative":case"absolute":case"fixed":case"sticky":x.position=e;break;default:break}}function cf(t,x){let e=Jt(t);e!==void 0&&(x.top=e)}function lf(t,x){let e=Jt(t);e!==void 0&&(x.right=e)}function uf(t,x){let e=Jt(t);e!==void 0&&(x.bottom=e)}function bf(t,x){let e=Jt(t);e!==void 0&&(x.left=e)}function S7(t){if(!t)return;let x=t.trim().toLowerCase().split(/\s+/).filter(Boolean);if(x.length===0)return;if(x.includes("none"))return"none";let e=new Set(["underline","overline","line-through"]),n=x.filter(o=>e.has(o));return n.length===0?void 0:[...new Set(n)].join(" ")}function mf(t,x){x.textAlign=t.toLowerCase()}function pf(t,x){let e=S7(t);e!==void 0&&(x.textDecorationLine=e);let n=Cf(t);n&&(x.textDecorationStyle=n);let r=Kl(t);r&&(x.textDecorationColor=r)}function hf(t,x){let e=S7(t);e!==void 0&&(x.textDecorationLine=e)}function gf(t,x){let e=t.trim();e&&(x.textDecorationColor=e)}function yf(t,x){let e=Cf(t);e&&(x.textDecorationStyle=e)}function wf(t,x){x.float=t}function Rf(t,x){let e=L6(t);e!==void 0&&(x.textIndent=e)}function Sf(t,x){let e=t.trim().toLowerCase();if(e==="initial"){x.textTransform="none";return}if(Lf.has(e))return;let n=Yl[e];n&&(x.textTransform=n)}function vf(t,x){let e=t.trim().toLowerCase();if(!e)return;if(e==="normal"){x.letterSpacing=0;return}if(Lf.has(e))return;let n=Ue(t);n!==void 0&&(x.letterSpacing=n)}var Yl={none:"none",uppercase:"uppercase",lowercase:"lowercase",capitalize:"capitalize"},Lf=new Set(["inherit","unset","revert","revert-layer"]),v7=new Set(Object.keys(s6).map(t=>t.toLowerCase()));v7.add("transparent");v7.add("currentcolor");var Xl=new Set(["underline","overline","line-through","none"]),ql=new Set(["solid","double","dotted","dashed","wavy"]);function Cf(t){if(!t)return;let x=t.trim().toLowerCase().split(/\s+/);for(let e of x)if(ql.has(e))return e}function Kl(t){if(!t)return;let x=t.match(/\b(?:rgba?|hsla?)\([^)]*\)/i);if(x)return x[0].trim();let e=t.match(/#[0-9a-f]{3,8}\b/i);if(e)return e[0];let n=t.trim().split(/\s+/);for(let r of n){let o=r.toLowerCase();if(!Xl.has(o)&&v7.has(o))return o}}function Tf(t){switch(t){case"normal":return"normal";case"anywhere":return"anywhere";case"break-word":return"break-word";default:return}}function Pf(t,x){if(!t)return;let e=Tf(t.trim().toLowerCase());e&&(x.overflowWrap=e)}function Ff(t,x){if(!t)return;let e=Tf(t.trim().toLowerCase());e&&(x.overflowWrap=e==="anywhere"?"break-word":e)}function Zl(t){let x=t.trim();if(!x)return;let e=x.toLowerCase();if(e==="none"||e==="initial")return[];if(e==="inherit"||e==="revert"||e==="revert-layer")return;let n=l6(x),r=[];for(let o of n){let a=Ql(o);a&&r.push(a)}return r}function Bf(t,x){let e=Zl(t);e!==void 0&&(x.textShadows=e)}function Ql(t){let x=I0(t);if(x.length===0)return null;let e=[],n;for(let s of x){let d=r0(s);if(d!==void 0){e.push(d);continue}if(n===void 0){let f=s.toLowerCase();if(Jl(f)){n=s;continue}}}if(e.length<2)return null;let r=(s,d=!1)=>s===void 0?0:typeof s=="number"&&d?Zt(s):s,o=r(e[0]),a=r(e[1]),i=r(e[2],!0);return{offsetX:o,offsetY:a,blurRadius:i,color:n}}function Jl(t){return t?t.startsWith("#")||t.startsWith("rgb(")||t.startsWith("rgba(")||t.startsWith("hsl(")||t.startsWith("hsla(")?!0:["transparent","black","white","red","green","blue","yellow","gray","grey"].includes(t.toLowerCase()):!1}var xu={none:"none",disc:"disc",circle:"circle",square:"square",decimal:"decimal","decimal-leading-zero":"decimal-leading-zero","lower-alpha":"lower-alpha","lower-latin":"lower-alpha","upper-alpha":"upper-alpha","upper-latin":"upper-alpha","lower-roman":"lower-roman","upper-roman":"upper-roman"},eu=new Set(["inherit","unset","revert","revert-layer"]);function Af(t,x){if(!t)return;let e=t.trim().toLowerCase();if(e){if(e==="initial"){x.listStyleType="disc";return}eu.has(e)||(x.listStyleType=xu[e]??e)}}function Mf(t,x){let e=t.trim();if(e==="none"||e==="inherit"){x.content=void 0;return}let n=tu(e);n.length>0&&(x.content=n)}function tu(t){let x=[],e=0;for(;e<t.length;){if(t[e]==='"'||t[e]==="'"){let n=t[e],r="";for(e++;e<t.length&&t[e]!==n;)if(t[e]==="\\"&&e+1<t.length){let o=t[e+1];if(o==="n")r+=`
|
|
43
|
+
`);return o.push(f),pe(o)}};var H6=class{constructor(x={}){this.builder=new Kt(x)}registerStandardFont(x){return this.builder.fontRegistry.register(x)}addPage(x){let e={fonts:x.resources?.fonts??new Map,xObjects:x.resources?.xObjects??new Map,extGStates:x.resources?.extGStates??new Map,shadings:x.resources?.shadings??new Map,patterns:x.resources?.patterns??new Map};this.builder.addPage({width:x.width,height:x.height,contents:x.contents,resources:e,annotations:x.annotations??[]})}registerImage(x){return this.builder.imageRegistry.register(x)}registerExtGState(x){return this.builder.extGStateRegistry.register(x)}registerShading(x,e){return this.builder.shadingRegistry.register(x,e)}registerPattern(x,e){return this.builder.patternRegistry.register(x,e)}register(x){return this.builder.objectRegistry.register(x)}registerStream(x,e={}){return this.builder.streamRegistry.register(x,e)}finalize(){return this.builder.finalize()}};function b7(t,x,e){return{hf:t,pageSize:x,baseBox:e}}function m7(t,x){let e=Ps(t.hf,x,"header"),n=Ps(t.hf,x,"footer"),r=Fs(e),o=Fs(n),a=Bs(e),i=Bs(n);return{headerHeightPt:r,footerHeightPt:o,headerHeightPx:a,footerHeightPx:i,layerMode:t.hf.layerMode,header:e,footer:n,clipOverflow:t.hf.clipOverflow}}function p7(t,x,e){return As(t.header,x,e)}function h7(t,x,e){return As(t.footer,x,e)}function Ps(t,x,e){let n=e==="header"?t.maxHeaderHeightPx??0:t.maxFooterHeightPx??0,r=o=>{if(o)return{content:o,maxHeightPt:x(n),maxHeightPx:n}};return e==="header"?{defaultVariant:r(t.headerHtml),firstVariant:r(t.headerFirstHtml),evenVariant:r(t.headerEvenHtml),oddVariant:r(t.headerOddHtml)}:{defaultVariant:r(t.footerHtml),firstVariant:r(t.footerFirstHtml),evenVariant:r(t.footerEvenHtml),oddVariant:r(t.footerOddHtml)}}function Fs(t){let x=[t.defaultVariant?.maxHeightPt??0,t.firstVariant?.maxHeightPt??0,t.evenVariant?.maxHeightPt??0,t.oddVariant?.maxHeightPt??0];return Math.max(...x)}function Bs(t){let x=[t.defaultVariant?.maxHeightPx??0,t.firstVariant?.maxHeightPx??0,t.evenVariant?.maxHeightPx??0,t.oddVariant?.maxHeightPx??0];return Math.max(...x)}function As(t,x,e){if(x===1&&t.firstVariant)return t.firstVariant;if(e>1){if(x%2===0&&t.evenVariant)return t.evenVariant;if(x%2===1&&t.oddVariant)return t.oddVariant}return t.defaultVariant}function g7(t,x,e={}){let n=new Map;for(let[r,o]of Object.entries(t??{}))n.set(r,o);return n.set("page",(r,o)=>String(r)),n.set("pageNumber",(r,o)=>String(r)),n.set("pages",(r,o)=>String(o)),n.set("totalPages",(r,o)=>String(o)),!n.has("title")&&e.title&&n.set("title",e.title),n.set("date",()=>new Date().toLocaleDateString()),n}function z6(t,x,e,n){let r=t.replace(/\{\{([^}]+)\}\}/g,(o,a)=>{let i=x.get(a.trim());return i===void 0?"":typeof i=="string"?i:i(e,n)});return r=r.replace(/\{([^}]+)\}/g,(o,a)=>{let i=x.get(a.trim());return i===void 0?"":typeof i=="string"?i:i(e,n)}),r}var Ms=new Map;function W(t,x){Ms.set(t,x)}function ks(t){return Ms.get(t)}function Is(t){switch(t){case"block":return"block";case"inline":return"inline";case"inline-block":return"inline-block";case"flex":return"flex";case"grid":return"grid";case"table":return"table";case"table-row":return"table-row";case"table-cell":return"table-cell";case"table-row-group":return"table-row-group";case"table-header-group":return"table-header-group";case"table-footer-group":return"table-footer-group";case"table-caption":return"table-caption";case"none":return"none";default:return}}function Ns(t){if(t)switch(t.trim().toLowerCase()){case"flex-start":return"flex-start";case"flex-end":return"flex-end";case"center":return"center";case"space-between":return"space-between";case"space-around":return"space-around";case"space-evenly":return"space-evenly";case"start":return"start";case"end":return"end";case"left":return"left";case"right":return"right";default:return}}function y7(t){if(t)switch(t.trim().toLowerCase()){case"flex-start":return"flex-start";case"flex-end":return"flex-end";case"center":return"center";case"baseline":return"baseline";case"stretch":return"stretch";default:return}}function Es(t){if(t)switch(t.trim().toLowerCase()){case"flex-start":return"flex-start";case"flex-end":return"flex-end";case"center":return"center";case"space-between":return"space-between";case"space-around":return"space-around";case"space-evenly":return"space-evenly";case"stretch":return"stretch";default:return}}function Ds(t){if(!t)return;let x=t.trim().toLowerCase();return x==="auto"?"auto":y7(x)}function Os(t){if(!t)return;let x=t.trim().toLowerCase();switch(x){case"row":case"row-reverse":case"column":case"column-reverse":return x;default:return}}function Ws(t,x){x.display=Is(t)}function Us(t,x){let e=Ns(t);e!==void 0&&(x.justifyContent=e)}function Hs(t,x){let e=y7(t);e!==void 0&&(x.alignItems=e)}function zs(t,x){let e=Es(t);e!==void 0&&(x.alignContent=e)}function Gs(t,x){let e=Ds(t);e!==void 0&&(x.alignSelf=e)}function js(t,x){let e=Os(t);e!==void 0&&(x.flexDirection=e)}function $s(t,x){let e=t.trim().toLowerCase();e==="nowrap"?x.flexWrap=!1:(e==="wrap"||e==="wrap-reverse")&&(x.flexWrap=!0)}function Vs(t,x){x.color=t}function _s(t,x){x.backgroundLayers||(x.backgroundLayers=[]),x.backgroundLayers.push({kind:"color",color:t})}function Ys(t){if(!Number.isFinite(t??NaN))return 0;let x=Number(t);return x>0?x:0}function Zt(t){return Number.isFinite(t)?t<0?0:t:0}function l6(t){let x=[],e="",n=0,r=null;for(let o of t){if(r){e+=o,o===r&&(r=null);continue}if(o==="'"||o==='"'){r=o,e+=o;continue}if(o==="("){n+=1,e+=o;continue}if(o===")"){n=Math.max(0,n-1),e+=o;continue}if(o===","&&n===0){e.trim()&&x.push(e.trim()),e="";continue}e+=o}return e.trim()&&x.push(e.trim()),x}function I0(t){let x=[],e="",n=0,r=null;for(let o of t){if(r){e+=o,o===r&&(r=null);continue}if(o==="'"||o==='"'){r=o,e+=o;continue}if(o==="("){n+=1,e+=o;continue}if(o===")"){n=Math.max(0,n-1),e+=o;continue}if(/\s/.test(o)&&n===0){e.trim()&&x.push(e.trim()),e="";continue}e+=o}return e.trim()&&x.push(e.trim()),x}var zl=new Set(["none","hidden","solid","dashed","dotted","double","groove","ridge","inset","outset"]),w7={thin:1,medium:3,thick:5},R7=w7.medium;function qs(t){let x=I0(t);if(x.length===0)return null;let e,n,r;for(let o of x){let a=o.trim();if(!a)continue;if(e===void 0){let s=u6(a);if(s!==void 0){e=s;continue}}let i=a.toLowerCase();if(!n&&zl.has(i)){n=i;continue}r===void 0&&(r=a)}return n==="none"||n==="hidden"?e=0:e===void 0&&n&&(e=R7),{width:e,style:n,color:r}}function u6(t){let x=t.trim().toLowerCase();if(x)return x in w7?w7[x]:r0(t)}function Ks(t){let x=t.trim();if(!x)return null;let[e,n]=x.split("/").map(a=>a.trim()),r=Xs(e);if(!r)return null;let o=n?Xs(n):r;return o?{topLeft:{x:r[0],y:o[0]},topRight:{x:r[1],y:o[1]},bottomRight:{x:r[2],y:o[2]},bottomLeft:{x:r[3],y:o[3]}}:null}function ge(t){let x=t.trim();if(!x)return;let[e,n]=x.split("/").map(i=>i.trim()),r=I0(e);if(r.length===0)return;let o=Qt(r[0]),a;if(n){let i=I0(n);a=Qt(i[0])}else r.length>1?a=Qt(r[1]):a=o;return{x:o,y:a}}function Qt(t){let x=r0(t);return x===void 0?0:typeof x=="number"?Ys(x):x}function Xs(t){if(!t)return null;let x=I0(t);if(x.length===0)return null;let e=x.map(n=>Qt(n));switch(e.length){case 1:return[e[0],e[0],e[0],e[0]];case 2:return[e[0],e[1],e[0],e[1]];case 3:return[e[0],e[1],e[2],e[1]];default:return[e[0],e[1],e[2],e[3]]}}function Zs(t){let x=t.trim();if(!x)return;let e=x.toLowerCase();if(e==="none"||e==="initial")return[];if(e==="inherit"||e==="revert"||e==="revert-layer")return;let n=l6(x),r=[];for(let o of n){let a=Gl(o);a&&r.push(a)}return r}function Gl(t){let x=I0(t);if(x.length===0)return null;let e=!1,n=[],r;for(let f of x){if(f.toLowerCase()==="inset"){e=!0;continue}let l=r0(f);if(l!==void 0){n.push(l);continue}if(r===void 0&&jl(f)){r=f;continue}}if(n.length<2)return null;let o=(f,c=!1)=>f===void 0?0:typeof f=="number"&&c?Zt(f):f,a=o(n[0]),i=o(n[1]),s=o(n[2],!0),d=o(n[3]);return{inset:e,offsetX:a,offsetY:i,blurRadius:s,spreadRadius:d,color:r}}function jl(t){let x=t.toLowerCase();return x.startsWith("#")||x.startsWith("rgb(")||x.startsWith("rgba(")||x.startsWith("hsl(")||x.startsWith("hsla(")?!0:["transparent","black","white","red","green","blue","yellow","gray","grey"].includes(x)}function K0(t,x,e,n){let r=qs(t);r&&(n&&n(r.style),r.style==="none"||r.style==="hidden"?x(0):r.width!==void 0?x(r.width):r.style&&x(R7),r.color!==void 0&&e(r.color))}function Qs(t,x){let e=I0(t);if(e.length===0)return;let[n]=e.length===1?[e[0],e[0],e[0],e[0]]:e.length===2?[e[0],e[1],e[0],e[1]]:e.length===3?[e[0],e[1],e[2],e[1]]:[e[0],e[1],e[2],e[3]];n&&x(n)}function Js(t,x){let e=I0(t);e.length!==0&&x(e[0]?.toLowerCase())}function ye(t){let x=I0(t);if(x.length===0)return!1;let e=x[0]?.toLowerCase();return e==="none"||e==="hidden"}function G6(t,x,e=Lx){let n=I0(t);if(n.length===0)return;let r=n.map(d=>e(d)),[o,a,i,s]=r.length===1?[r[0],r[0],r[0],r[0]]:r.length===2?[r[0],r[1],r[0],r[1]]:r.length===3?[r[0],r[1],r[2],r[1]]:[r[0],r[1],r[2],r[3]];x(o,a,i,s)}function xd(t,x){Qs(t,e=>{x.borderColor=e})}function ed(t,x){let e=Zs(t);e!==void 0&&(x.boxShadows=e)}function td(t,x){K0(t,e=>{x.borderTop=e,x.borderRight=e,x.borderBottom=e,x.borderLeft=e},e=>{x.borderColor=e??x.borderColor},e=>{if(!e)return;let n=e.toLowerCase();x.borderStyleTop=n,x.borderStyleRight=n,x.borderStyleBottom=n,x.borderStyleLeft=n})}function nd(t,x){K0(t,e=>{x.borderTop=e},e=>{x.borderColor=e??x.borderColor},e=>{e&&(x.borderStyleTop=e.toLowerCase())})}function rd(t,x){K0(t,e=>{x.borderRight=e},e=>{x.borderColor=e??x.borderColor},e=>{e&&(x.borderStyleRight=e.toLowerCase())})}function od(t,x){K0(t,e=>{x.borderBottom=e},e=>{x.borderColor=e??x.borderColor},e=>{e&&(x.borderStyleBottom=e.toLowerCase())})}function ad(t,x){K0(t,e=>{x.borderLeft=e},e=>{x.borderColor=e??x.borderColor},e=>{e&&(x.borderStyleLeft=e.toLowerCase())})}function id(t,x){let e=Ks(t);e&&(x.borderTopLeftRadiusX=e.topLeft.x,x.borderTopLeftRadiusY=e.topLeft.y,x.borderTopRightRadiusX=e.topRight.x,x.borderTopRightRadiusY=e.topRight.y,x.borderBottomRightRadiusX=e.bottomRight.x,x.borderBottomRightRadiusY=e.bottomRight.y,x.borderBottomLeftRadiusX=e.bottomLeft.x,x.borderBottomLeftRadiusY=e.bottomLeft.y)}function sd(t,x){let e=ge(t);e&&(x.borderTopLeftRadiusX=e.x,x.borderTopLeftRadiusY=e.y)}function dd(t,x){let e=ge(t);e&&(x.borderTopRightRadiusX=e.x,x.borderTopRightRadiusY=e.y)}function fd(t,x){let e=ge(t);e&&(x.borderBottomRightRadiusX=e.x,x.borderBottomRightRadiusY=e.y)}function cd(t,x){let e=ge(t);e&&(x.borderBottomLeftRadiusX=e.x,x.borderBottomLeftRadiusY=e.y)}function ld(t,x){G6(t,(e,n,r,o)=>{x.borderTop=e,x.borderRight=n,x.borderBottom=r,x.borderLeft=o},u6)}function ud(t,x){x.borderTop=u6(t)??x.borderTop}function bd(t,x){x.borderRight=u6(t)??x.borderRight}function md(t,x){x.borderBottom=u6(t)??x.borderBottom}function pd(t,x){x.borderLeft=u6(t)??x.borderLeft}function hd(t,x){t.trim()&&(x.borderColor=t.trim())}function gd(t,x){t.trim()&&(x.borderColor=t.trim())}function yd(t,x){t.trim()&&(x.borderColor=t.trim())}function wd(t,x){t.trim()&&(x.borderColor=t.trim())}function Rd(t,x){Js(t,e=>{if(!e)return;let n=e.toLowerCase();x.borderStyleTop=n,x.borderStyleRight=n,x.borderStyleBottom=n,x.borderStyleLeft=n,(n==="none"||n==="hidden")&&(x.borderTop=0,x.borderRight=0,x.borderBottom=0,x.borderLeft=0)})}function Sd(t,x){let e=t.trim().toLowerCase();e&&(x.borderStyleTop=e,ye(t)&&(x.borderTop=0))}function vd(t,x){let e=t.trim().toLowerCase();e&&(x.borderStyleRight=e,ye(t)&&(x.borderRight=0))}function Ld(t,x){let e=t.trim().toLowerCase();e&&(x.borderStyleBottom=e,ye(t)&&(x.borderBottom=0))}function Cd(t,x){let e=t.trim().toLowerCase();e&&(x.borderStyleLeft=e,ye(t)&&(x.borderLeft=0))}function Td(t,x){let e=t.trim().toLowerCase();x.borderModel=e==="collapse"?"collapse":"separate"}function Pd(t,x){K0(t,e=>{x.borderTop=e},e=>{x.borderColor=e??x.borderColor},e=>{e&&(x.borderStyleTop=e.toLowerCase())})}function Fd(t,x){K0(t,e=>{x.borderBottom=e},e=>{x.borderColor=e??x.borderColor},e=>{e&&(x.borderStyleBottom=e.toLowerCase())})}function Bd(t,x){K0(t,e=>{x.borderLeft=e},e=>{x.borderColor=e??x.borderColor},e=>{e&&(x.borderStyleLeft=e.toLowerCase())})}function Ad(t,x){K0(t,e=>{x.borderRight=e},e=>{x.borderColor=e??x.borderColor},e=>{e&&(x.borderStyleRight=e.toLowerCase())})}function Md(t,x){G6(t,(e,n,r,o)=>{x.marginTop=e,x.marginRight=n,x.marginBottom=r,x.marginLeft=o})}function kd(t,x){x.marginTop=r0(t)??x.marginTop}function Id(t,x){x.marginRight=Lx(t)??x.marginRight}function Nd(t,x){x.marginBottom=r0(t)??x.marginBottom}function Ed(t,x){x.marginLeft=Lx(t)??x.marginLeft}function Dd(t,x){x.marginTop=r0(t)??x.marginTop}function Od(t,x){x.marginBottom=r0(t)??x.marginBottom}function Wd(t,x){x.marginLeft=Lx(t)??x.marginLeft}function Ud(t,x){x.marginRight=Lx(t)??x.marginRight}function Hd(t,x){G6(t,(e,n,r,o)=>{x.paddingTop=e,x.paddingRight=n,x.paddingBottom=r,x.paddingLeft=o},r0)}function zd(t,x){x.paddingTop=r0(t)??x.paddingTop}function Gd(t,x){x.paddingRight=r0(t)??x.paddingRight}function jd(t,x){x.paddingBottom=r0(t)??x.paddingBottom}function $d(t,x){x.paddingLeft=r0(t)??x.paddingLeft}function Vd(t,x){x.paddingTop=r0(t)??x.paddingTop}function _d(t,x){x.paddingBottom=r0(t)??x.paddingBottom}function Yd(t,x){x.paddingLeft=r0(t)??x.paddingLeft}function Xd(t,x){x.paddingRight=r0(t)??x.paddingRight}var $l=/^(-?\d+(?:\.\d+)?)%$/;function j6(t){let x=r0(t);if(x!==void 0)return x;let e=$l.exec(t.trim());if(!e)return;let n=Number.parseFloat(e[1]);if(!Number.isNaN(n))return v6(n/100)}function qd(t,x){let e=j6(t);e!==void 0&&(x.width=e)}function Kd(t,x){let e=j6(t);e!==void 0&&(x.minWidth=e)}function Zd(t,x){let e=j6(t);e!==void 0&&(x.maxWidth=e)}function Qd(t,x){let e=j6(t);e!==void 0&&(x.height=e)}function Jd(t,x){let e=j6(t);e!==void 0&&(x.minHeight=e)}function xf(t,x){let e=j6(t);e!==void 0&&(x.maxHeight=e)}function ef(t,x){x.fontSize=Ue(t)??x.fontSize}function Vl(t){let x=t.trim();if(!x)return;let e=x.toLowerCase();if(e==="normal")return{kind:"normal"};if(/^[+-]?\d+(?:\.\d+)?%$/.test(e)){let r=Number.parseFloat(e.slice(0,-1));return Number.isNaN(r)?void 0:{kind:"unitless",value:r/100}}if(/^[+-]?\d+(?:\.\d+)?$/.test(e)){let r=Number.parseFloat(e);return Number.isNaN(r)?void 0:{kind:"unitless",value:r}}let n=r0(x);if(n!==void 0)return{kind:"length",value:n}}function tf(t,x){let e=Vl(t);e&&(x.lineHeight=e)}function nf(t,x){let e=t.trim();e.toLowerCase()==="auto"?x.zIndex="auto":/^-?\d+$/.test(e)&&(x.zIndex=Number.parseInt(e,10))}function rf(t,x){let e=t.trim().toLowerCase();e!=="inherit"&&(e==="normal"||e==="small-caps")&&(x.fontVariant=e)}function of(t,x){x.fontVariantNumeric=ra(t)}function af(t,x){let e=t.trim().toLowerCase();e!=="inherit"&&(e==="normal"||e==="italic"||e==="oblique"||e.startsWith("oblique "))&&(x.fontStyle=e.startsWith("oblique")?"oblique":e)}function sf(t,x,e,n){let r=ne(t,n);r!==void 0&&(x.fontWeight=r)}function df(t,x){x.fontFamily=t}var _l=/^(-?\d+(?:\.\d+)?)%$/;function Jt(t){let x=t.trim();if(!x)return;if(x.toLowerCase()==="auto")return"auto";let e=r0(x);if(e!==void 0)return e;let n=_l.exec(x);if(n){let r=Number.parseFloat(n[1]);if(!Number.isNaN(r))return v6(r/100)}}function ff(t,x){let e=t.trim().toLowerCase();switch(e){case"static":case"relative":case"absolute":case"fixed":case"sticky":x.position=e;break;default:break}}function cf(t,x){let e=Jt(t);e!==void 0&&(x.top=e)}function lf(t,x){let e=Jt(t);e!==void 0&&(x.right=e)}function uf(t,x){let e=Jt(t);e!==void 0&&(x.bottom=e)}function bf(t,x){let e=Jt(t);e!==void 0&&(x.left=e)}function S7(t){if(!t)return;let x=t.trim().toLowerCase().split(/\s+/).filter(Boolean);if(x.length===0)return;if(x.includes("none"))return"none";let e=new Set(["underline","overline","line-through"]),n=x.filter(o=>e.has(o));return n.length===0?void 0:[...new Set(n)].join(" ")}function mf(t,x){x.textAlign=t.toLowerCase()}function pf(t,x){let e=S7(t);e!==void 0&&(x.textDecorationLine=e);let n=Cf(t);n&&(x.textDecorationStyle=n);let r=Kl(t);r&&(x.textDecorationColor=r)}function hf(t,x){let e=S7(t);e!==void 0&&(x.textDecorationLine=e)}function gf(t,x){let e=t.trim();e&&(x.textDecorationColor=e)}function yf(t,x){let e=Cf(t);e&&(x.textDecorationStyle=e)}function wf(t,x){x.float=t}function Rf(t,x){let e=L6(t);e!==void 0&&(x.textIndent=e)}function Sf(t,x){let e=t.trim().toLowerCase();if(e==="initial"){x.textTransform="none";return}if(Lf.has(e))return;let n=Yl[e];n&&(x.textTransform=n)}function vf(t,x){let e=t.trim().toLowerCase();if(!e)return;if(e==="normal"){x.letterSpacing=0;return}if(Lf.has(e))return;let n=Ue(t);n!==void 0&&(x.letterSpacing=n)}var Yl={none:"none",uppercase:"uppercase",lowercase:"lowercase",capitalize:"capitalize"},Lf=new Set(["inherit","unset","revert","revert-layer"]),v7=new Set(Object.keys(s6).map(t=>t.toLowerCase()));v7.add("transparent");v7.add("currentcolor");var Xl=new Set(["underline","overline","line-through","none"]),ql=new Set(["solid","double","dotted","dashed","wavy"]);function Cf(t){if(!t)return;let x=t.trim().toLowerCase().split(/\s+/);for(let e of x)if(ql.has(e))return e}function Kl(t){if(!t)return;let x=t.match(/\b(?:rgba?|hsla?)\([^)]*\)/i);if(x)return x[0].trim();let e=t.match(/#[0-9a-f]{3,8}\b/i);if(e)return e[0];let n=t.trim().split(/\s+/);for(let r of n){let o=r.toLowerCase();if(!Xl.has(o)&&v7.has(o))return o}}function Tf(t){switch(t){case"normal":return"normal";case"anywhere":return"anywhere";case"break-word":return"break-word";default:return}}function Pf(t,x){if(!t)return;let e=Tf(t.trim().toLowerCase());e&&(x.overflowWrap=e)}function Ff(t,x){if(!t)return;let e=Tf(t.trim().toLowerCase());e&&(x.overflowWrap=e==="anywhere"?"break-word":e)}function Zl(t){let x=t.trim();if(!x)return;let e=x.toLowerCase();if(e==="none"||e==="initial")return[];if(e==="inherit"||e==="revert"||e==="revert-layer")return;let n=l6(x),r=[];for(let o of n){let a=Ql(o);a&&r.push(a)}return r}function Bf(t,x){let e=Zl(t);e!==void 0&&(x.textShadows=e)}function Ql(t){let x=I0(t);if(x.length===0)return null;let e=[],n;for(let s of x){let d=r0(s);if(d!==void 0){e.push(d);continue}if(n===void 0){let f=s.toLowerCase();if(Jl(f)){n=s;continue}}}if(e.length<2)return null;let r=(s,d=!1)=>s===void 0?0:typeof s=="number"&&d?Zt(s):s,o=r(e[0]),a=r(e[1]),i=r(e[2],!0);return{offsetX:o,offsetY:a,blurRadius:i,color:n}}function Jl(t){return t?t.startsWith("#")||t.startsWith("rgb(")||t.startsWith("rgba(")||t.startsWith("hsl(")||t.startsWith("hsla(")?!0:["transparent","black","white","red","green","blue","yellow","gray","grey"].includes(t.toLowerCase()):!1}var xu={none:"none",disc:"disc",circle:"circle",square:"square",decimal:"decimal","decimal-leading-zero":"decimal-leading-zero","lower-alpha":"lower-alpha","lower-latin":"lower-alpha","upper-alpha":"upper-alpha","upper-latin":"upper-alpha","lower-roman":"lower-roman","upper-roman":"upper-roman"},eu=new Set(["inherit","unset","revert","revert-layer"]);function Af(t,x){if(!t)return;let e=t.trim().toLowerCase();if(e){if(e==="initial"){x.listStyleType="disc";return}eu.has(e)||(x.listStyleType=xu[e]??e)}}function Mf(t,x){let e=t.trim();if(e==="none"||e==="inherit"){x.content=void 0;return}let n=tu(e);n.length>0&&(x.content=n)}function tu(t){let x=[],e=0;for(;e<t.length;){if(t[e]==='"'||t[e]==="'"){let n=t[e],r="";for(e++;e<t.length&&t[e]!==n;)if(t[e]==="\\"&&e+1<t.length){let o=t[e+1];if(o==="n")r+=`
|
|
43
44
|
`,e+=2;else if(o==="t")r+=" ",e+=2;else if(o===n)r+=n,e+=2;else if(o==="\\")r+="\\",e+=2;else{if((o==="x"||o==="u")&&e+3<t.length){let a=t.slice(e+2,e+4);if(/^[0-9A-Fa-f]{2}$/.test(a)){r+=String.fromCharCode(parseInt(a,16)),e+=4;continue}}r+=o,e+=2}}else r+=t[e],e++;e++,x.push({type:"string",value:r});continue}if(t.slice(e).startsWith("counter(")){let n=/^counter\(\s*([a-zA-Z_][a-zA-Z0-9_-]*)\s*(?:,\s*(decimal|lower-roman|upper-roman|lower-alpha|upper-alpha))?\s*\)/i.exec(t.slice(e));if(n){x.push({type:"counter",counter:n[1],style:n[2]}),e+=n[0].length;continue}}if(t.slice(e).startsWith("counters(")){let n=/^counters\(\s*([a-zA-Z_][a-zA-Z0-9_-]*)\s*,\s*(["'])(.*)\2\s*(?:,\s*(decimal|lower-roman|upper-roman|lower-alpha|upper-alpha))?\s*\)/i.exec(t.slice(e));if(n){x.push({type:"counter",counter:n[1],style:n[4]}),e+=n[0].length;continue}}if(t.slice(e).startsWith("attr(")){let n=/^attr\(\s*([a-zA-Z_][a-zA-Z0-9_-]*)\s*\)/i.exec(t.slice(e));if(n){x.push({type:"attr",attribute:n[1]}),e+=n[0].length;continue}}if(t.slice(e).startsWith("open-quote")){x.push({type:"open-quote"}),e+=10;continue}if(t.slice(e).startsWith("close-quote")){x.push({type:"close-quote"}),e+=11;continue}if(t.slice(e).startsWith("no-open-quote")){x.push({type:"no-open-quote"}),e+=14;continue}if(t.slice(e).startsWith("no-close-quote")){x.push({type:"no-close-quote"}),e+=15;continue}e++}return x}function yx(t){let x=t.trim();if(console.log("parseLinearGradient - input:",t),console.log("parseLinearGradient - trimmed:",x),!x.toLowerCase().startsWith("linear-gradient("))return console.log("parseLinearGradient - not a linear gradient, returning null"),null;let e=x.slice(16,-1);if(!e)return null;let n="to bottom",r=e,o=-1,a=0;for(let d=0;d<e.length;d++)if(e[d]==="(")a++;else if(e[d]===")")a--;else if(e[d]===","&&a===0){o=d;break}if(o!==-1){let f=e.substring(0,o).trim().toLowerCase();["to","to bottom","to right","to left","to top right","to top left","to bottom right","to bottom left"].some(u=>f===u)||f.endsWith("deg")?(n=f,r=e.substring(o+1).trim()):r=e}else{let d=e.trim().toLowerCase();d==="to"||d.startsWith("to ")||d.endsWith("deg")?(n=d,r=""):r=e}n.startsWith("to ")?(n==="to righ"?n="to right":(n==="to botto"||n==="to bott"||n==="to bot")&&(n="to bottom"),n=n.replace(/,$/,"")):n.endsWith("deg")&&(n=n.replace(/,$/,"")),n.startsWith("to ")?n=n.replace(/,$/,""):n.endsWith("deg")&&(n=n.replace(/,$/,""));let i=l6(r);console.log("Gradient parser - input value:",t),console.log("Gradient parser - content:",e),console.log("Gradient parser - direction:",n),console.log("Gradient parser - colorStopsContent:",r),console.log("Gradient parser - colorStopValues:",i);let s=[];for(let d of i){if(!d.trim())continue;let f=kf(d);f&&s.push(f)}return console.log("Gradient parser - parsed stops:",s),s.length===0&&s.push({color:"#000000"}),{type:"linear",direction:n,stops:s}}function we(t){let x=t.trim();if(!x.toLowerCase().startsWith("radial-gradient(")||!x.endsWith(")"))return null;let n=x.slice(16,-1);if(!n)return null;let r=iu(n),o=r===-1?"":n.slice(0,r).trim(),a=r===-1?n:n.slice(r+1).trim(),i=nu(o);i.hasDescriptor||(a=n);let s=[],d=l6(a);for(let f of d){if(!f.trim())continue;let c=kf(f);c&&s.push(c)}return s.length===0&&s.push({color:"#000000"}),{type:"radial",cx:.5,cy:.5,r:.5,stops:s,coordsUnits:"ratio",shape:i.shape,size:i.size,at:i.position,source:"css"}}function kf(t){let x=I0(t);if(x.length===0)return null;let e=x[0].trim();if(!e)return null;({red:!0,yellow:!0,green:!0,blue:!0,black:!0,white:!0,gray:!0,grey:!0,lime:!0})[e.toLowerCase()];let r;if(x.length>1){let o=x[1].trim(),a=parseFloat(o.slice(0,-1));if(!isNaN(a))r=a/100;else{let i=parseFloat(o);!isNaN(i)&&i>=0&&i<=1&&(r=i)}}return{color:e,position:r}}function nu(t){let x=t.trim();if(!x)return{hasDescriptor:!1};let e=x.split(/\s+/).filter(Boolean);if(e.length===0)return{hasDescriptor:!1};let n=e.findIndex(f=>f.toLowerCase()==="at"),r=n===-1?e:e.slice(0,n),o=n===-1?[]:e.slice(n+1),a,i;for(let f of r){let c=f.toLowerCase();if(c==="circle"||c==="ellipse"){a=c;continue}if(au(c)){i=c;continue}}let s=ru(o);return{shape:a,size:i,position:s,hasDescriptor:!!a||!!i||!!s}}function ru(t){if(!t||t.length===0)return;if(t.length===1){let n=t[0];return ou(n)?{x:"50%",y:xn(n,"y")}:{x:xn(n,"x"),y:"50%"}}let x=t[0],e=t[1];return{x:xn(x,"x"),y:xn(e,"y")}}function xn(t,x){let e=t.toLowerCase();if(x==="x"){if(e==="left")return"0%";if(e==="right")return"100%"}else{if(e==="top")return"0%";if(e==="bottom")return"100%"}return e==="center"?"50%":t}function ou(t){let x=t.toLowerCase();return x==="top"||x==="bottom"}function au(t){switch(t){case"closest-side":case"farthest-side":case"closest-corner":case"farthest-corner":return!0;default:return!1}}function iu(t){let x=0;for(let e=0;e<t.length;e++){let n=t[e];if(n==="(")x++;else if(n===")")x=Math.max(0,x-1);else if(n===","&&x===0)return e}return-1}function L7(t){let x=t.trim().toLowerCase();if(!x)return;let e=n=>x===n||x.startsWith(`${n} `)||x.startsWith(`${n}(`);if(e("cover"))return"cover";if(e("contain"))return"contain";if(e("auto"))return"auto"}function Ox(t){return L7(t)??t.trim()}function If(t,x){let e=t.toLowerCase(),n=`${x.toLowerCase()}(`,r=e.indexOf(n);if(r===-1)return null;let o=0;for(let a=r;a<t.length;a++){let i=t[a];if(i==="(")o++;else if(i===")"&&(o--,o===0))return{text:t.slice(r,a+1),start:r,end:a+1}}return null}function b6(t){return t.backgroundLayers||(t.backgroundLayers=[]),t.backgroundLayers}function en(t){let x=b6(t);for(let n=x.length-1;n>=0;n--)if(x[n].kind!=="color")return x[n];let e={kind:"image",url:""};return x.push(e),e}function Ef(t){let x=t.trim();if(!x)return[];let e=su(x),n=[];for(let r of e){let o=du(r);o&&n.push(o)}return n}function su(t){let x=[],e="",n=0,r=0;for(;r<t.length;){let o=t[r];o==="("?(n++,e+=o):o===")"?(n--,e+=o):o===","&&n===0?(x.push(e.trim()),e=""):e+=o,r++}return e.trim()&&x.push(e.trim()),x}function du(t){let x=t.trim();if(!x)return null;let e=If(x,"radial-gradient")??If(x,"linear-gradient");if(e){let n=fu(e.text);if(n){let r=x.slice(0,e.start).trim(),o=x.slice(e.end).trim(),a=[r,o].filter(Boolean).join(" ");if(a&&n.kind==="gradient"){let i=a.split(/\s+/).filter(Boolean);for(let s of i){let d=s.toLowerCase();C7(d)?n.repeat=d:T7(d)&&(n.origin=d)}}return n}}return uu(x)?{kind:"color",color:x}:cu(x)}function fu(t){let x=t.trim().toLowerCase(),e=x.startsWith("linear-gradient(")?yx(t):x.startsWith("radial-gradient(")?we(t):null;return e?{kind:"gradient",gradient:e}:null}function cu(t){let x=t.split(/\s+/).filter(s=>s.length>0);if(x.length===0)return null;let e="",n={x:"left",y:"top"},r="auto",o="repeat",a,i=0;for(let s=0;s<x.length;s++)if(x[s].startsWith("url(")){e=x[s],i=s+1;break}if(!e)return null;for(;i<x.length;){let s=x[i],d=s.toLowerCase();d.includes("/")?(r=lu(s),i++):bu(d)?(n=$6(d,x[i+1]),i+=n.y!=="top"?2:1):C7(d)?(o=d,i++):(T7(d)&&a===void 0&&(a=d),i++)}return{kind:"image",url:e,position:n,size:r,repeat:o,origin:a}}function lu(t){let x=t.indexOf("/");if(x===-1){let e=L7(t);if(e)return e;let n=t.trim().split(/\s+/).filter(Boolean);return n.length===1?{width:Ox(n[0]),height:"auto"}:{width:Ox(n[0]),height:Ox(n[1]??"auto")}}else{let e=t.substring(0,x).trim(),n=t.substring(x+1).trim();return{width:e?Ox(e):"auto",height:n?Ox(n):"auto"}}}var Nf=new Set(["top","bottom"]);function $6(t,x){return{x:t.toLowerCase(),y:x.toLowerCase()}}function uu(t){let x=t.toLowerCase();return!!(x in s6||x==="transparent"||x.startsWith("#")&&(x.length===4||x.length===7)||x.startsWith("rgb(")||x.startsWith("rgba(")||x.startsWith("hsl(")||x.startsWith("hsla("))}function bu(t){return["left","center","right","top","bottom"].includes(t.toLowerCase())}function C7(t){return["repeat","repeat-x","repeat-y","no-repeat","space","round"].includes(t.toLowerCase())}function T7(t){let x=t.toLowerCase();return x==="border-box"||x==="padding-box"||x==="content-box"}function Df(t,x){b6(t);let e=en(t),n=L7(x),r;if(n)r=n;else{let o=x.trim().split(/\s+/).filter(Boolean);o.length===0?r="auto":o.length===1?r={width:Ox(o[0]),height:"auto"}:r={width:Ox(o[0]),height:Ox(o[1]??"auto")}}(e.kind==="image"||e.kind==="gradient")&&(e.size=r)}function mu(t){let x=t.trim().split(/\s+/).filter(Boolean);if(x.length===0)return{x:"left",y:"top"};let e=x.map(a=>a.toLowerCase()),n=e[0];if(x.length===1)return n==="center"?$6("center","center"):Nf.has(n)?$6("center",n):$6(n,"center");let r=e[1];if(Nf.has(n)){let a=x[1]??"center";return $6(a,n)}return $6(n,r??"center")}function Of(t,x){b6(t);let e=en(t),n=mu(x);(e.kind==="image"||e.kind==="gradient")&&(e.position=n)}function Wf(t,x){b6(t);let e=x.trim().toLowerCase();if(!T7(e))return;let n=en(t);(n.kind==="image"||n.kind==="gradient")&&(n.origin=e)}function Uf(t,x){b6(t);let e=x.trim().toLowerCase();if(!C7(e))return;let n=en(t);(n.kind==="image"||n.kind==="gradient")&&(n.repeat=e)}var pu=new Set(["border-box","padding-box","content-box","text"]);function Hf(t,x){Df(x,t)}function zf(t,x){Of(x,t)}function Gf(t,x){Wf(x,t)}function jf(t,x){Uf(x,t)}function $f(t,x){let e=b6(x);if(e.length===0)return;let n=t.split(",").map(r=>r.trim().toLowerCase()).filter(r=>r.length>0);if(n.length!==0)for(let r=0;r<n.length;r++){let o=n[r];if(!pu.has(o))continue;let a=Math.min(r,e.length-1),i=e[a];i&&(i.clip=o)}}function Vf(t,x){let e=t.trim(),n=yx(t)??we(t);if(n){x.backgroundLayers||(x.backgroundLayers=[]),x.backgroundLayers.push({kind:"gradient",gradient:n});return}e.startsWith("url(")&&(x.backgroundLayers||(x.backgroundLayers=[]),x.backgroundLayers.push({kind:"image",url:e,position:{x:"left",y:"top"},size:"auto",repeat:"repeat"}))}function _f(t,x){console.log("Processing background property:",t);let e=Ef(t);console.log("Parsed background layers:",e),e.length>0&&(x.backgroundLayers||(x.backgroundLayers=[]),x.backgroundLayers.push(...e))}function Yf(t,x){let e=t.trim().toLowerCase();["contain","cover","fill","none","scale-down"].includes(e)&&(x.objectFit=e)}function qf(t,x){let e=hu(t);e&&(x.clipPath=e)}function hu(t){if(!t)return;let x=t.trim();if(x==="none")return;let e=gu(x);if(e)return e}function gu(t){let x=/^polygon\s*\((.+)\)$/i.exec(t);if(!x)return;let e=x[1].trim();if(!e)return;let n=e.includes(",")?e.split(/\s*,\s*/):yu(e.split(/\s+/)),r=[];for(let a of n){let i=a.trim().split(/\s+/).filter(Boolean);if(i.length<2)return;let s=Xf(i[0]),d=Xf(i[1]);if(!s||!d)return;r.push({x:s,y:d})}return r.length<3?void 0:{type:"polygon",points:r,referenceBox:"border-box"}}function yu(t){let x=[];for(let e=0;e<t.length;e+=2){let n=t[e],r=t[e+1];if(!n||!r)break;x.push(`${n} ${r}`)}return x}function Xf(t){let x=L6(t);if(x!==void 0){if(typeof x=="number")return{unit:"px",value:x};if(typeof x=="object"&&x.kind==="absolute"&&x.unit==="percent")return{unit:"percent",value:x.value}}}function wu(t){let x=[],e="",n=0;for(let r=0;r<t.length;r++){let o=t[r];if(o==="("){n+=1,e+=o;continue}if(o===")"){n=Math.max(0,n-1),e+=o;continue}if(/\s/.test(o)&&n===0){e&&(x.push(e.trim()),e="");continue}e+=o}return e&&x.push(e.trim()),x}function Qf(t){let x=[],e="",n=0;for(let r=0;r<t.length;r++){let o=t[r];if(o==="("){n+=1,e+=o;continue}if(o===")"){n=Math.max(0,n-1),e+=o;continue}if(o===","&&n===0){x.push(e.trim()),e="";continue}e+=o}return e&&x.push(e.trim()),x}function Kf(t){let x=t.trim().match(/^(-?\d+(?:\.\d+)?)fr$/i);if(!x)return;let e=Number.parseFloat(x[1]);return Number.isNaN(e)?void 0:e}function Zf(t){let x=t.trim().toLowerCase();if(x.startsWith("minmax(")&&x.endsWith(")")){let r=x.slice(7,-1),[o,a]=Qf(r);if(!o||!a)return;let i=r0(o);if(i===void 0)return;let s=Kf(a);if(s!==void 0)return{kind:"flex",flex:s,min:i};let d=r0(a);return d!==void 0?typeof i=="number"&&typeof d=="number"?{kind:"fixed",size:Math.max(i,d)}:{kind:"fixed",size:d}:a.trim()==="auto"?{kind:"auto",min:i}:void 0}let e=Kf(x);if(e!==void 0)return{kind:"flex",flex:e};if(x==="auto")return{kind:"auto"};let n=r0(x);if(n!==void 0)return{kind:"fixed",size:n}}function P7(t){if(!t)return;let x=wu(t.trim());if(x.length===0)return;let e=[];for(let n of x){let r=n.trim().toLowerCase();if(r.startsWith("repeat(")&&r.endsWith(")")){let a=n.trim().slice(7,-1),[i,s]=Qf(a);if(!i||!s)return;let d=Zf(s);if(!d)return;let f=i.trim().toLowerCase();if(f==="auto-fit"||f==="auto-fill"){let u={kind:"repeat-auto",mode:f,track:d};e.push(u);continue}let c=Number.parseInt(f,10);if(!Number.isFinite(c)||c<=0)return;let l={kind:"repeat",count:c,track:d};e.push(l);continue}let o=Zf(n);if(!o)return;e.push(o)}return e}function Jf(t){if(!t)return;let x=t.split(/\s+/).map(r=>r.trim()).filter(r=>r.length>0);if(x.length===0)return;let e=r0(x[0]);if(e===void 0)return;let n=x.length>1?r0(x[1]):void 0;return{row:e,column:n??e}}function xc(t,x){let e=P7(t);e&&(x.trackListColumns=e)}function ec(t,x){let e=P7(t);e&&(x.trackListRows=e)}function tc(t,x){let e=t.trim().toLowerCase();switch(e){case"row":case"column":case"row dense":case"column dense":x.autoFlow=e;break;default:break}}function nc(t,x){let e=Jf(t);e&&(x.rowGap=e.row,x.columnGap=e.column)}function rc(t,x){let e=r0(t);e!==void 0&&(x.rowGap=e)}function oc(t,x){let e=r0(t);e!==void 0&&(x.columnGap=e)}function ac(t,x){console.log(`DEBUG: parseOpacity called with value: "${t}"`);let e=t.trim().toLowerCase(),n;if(e.endsWith("%")){let r=e.slice(0,-1),o=parseFloat(r);if(isNaN(o))return;n=o/100}else if(n=parseFloat(e),isNaN(n))return;n=Math.max(0,Math.min(1,n)),x.opacity=n}var ic=!1;function sc(){ic||(ic=!0,W("display",Ws),W("justify-content",Us),W("align-items",Hs),W("align-content",zs),W("align-self",Gs),W("flex-direction",js),W("flex-wrap",$s),W("color",Vs),W("background-color",_s),W("border-color",xd),W("box-shadow",ed),W("border",td),W("border-top",nd),W("border-right",rd),W("border-bottom",od),W("border-left",ad),W("border-radius",id),W("border-top-left-radius",sd),W("border-top-right-radius",dd),W("border-bottom-right-radius",fd),W("border-bottom-left-radius",cd),W("border-width",ld),W("border-top-width",ud),W("border-right-width",bd),W("border-bottom-width",md),W("border-left-width",pd),W("border-top-color",hd),W("border-right-color",gd),W("border-bottom-color",yd),W("border-left-color",wd),W("border-style",Rd),W("border-top-style",Sd),W("border-right-style",vd),W("border-bottom-style",Ld),W("border-left-style",Cd),W("border-collapse",Td),W("border-block-start",Pd),W("border-block-end",Fd),W("border-inline-start",Bd),W("border-inline-end",Ad),W("margin",Md),W("margin-top",kd),W("margin-right",Id),W("margin-bottom",Nd),W("margin-left",Ed),W("margin-block-start",Dd),W("margin-block-end",Od),W("margin-inline-start",Wd),W("margin-inline-end",Ud),W("padding",Hd),W("padding-top",zd),W("padding-right",Gd),W("padding-bottom",jd),W("padding-left",$d),W("padding-block-start",Vd),W("padding-block-end",_d),W("padding-inline-start",Yd),W("padding-inline-end",Xd),W("width",qd),W("min-width",Kd),W("max-width",Zd),W("height",Qd),W("min-height",Jd),W("max-height",xf),W("font-size",ef),W("line-height",tf),W("z-index",nf),W("font-family",df),W("font-style",af),W("font-variant",rf),W("font-variant-numeric",of),W("font-weight",sf),W("position",ff),W("top",cf),W("right",lf),W("bottom",uf),W("left",bf),W("text-align",mf),W("text-decoration",pf),W("text-decoration-line",hf),W("text-decoration-color",gf),W("text-decoration-style",yf),W("letter-spacing",vf),W("text-indent",Rf),W("text-transform",Sf),W("float",wf),W("overflow-wrap",Pf),W("word-wrap",Ff),W("text-shadow",Bf),W("list-style-type",Af),W("content",Mf),W("transform",(t,x)=>{x.transform=t}),W("background-size",Hf),W("background-position",zf),W("background-origin",Gf),W("background-repeat",jf),W("background-clip",$f),W("background-image",Vf),W("background",_f),W("object-fit",Yf),W("clip-path",qf),W("grid-template-columns",xc),W("grid-template-rows",ec),W("grid-auto-flow",tc),W("gap",nc),W("row-gap",rc),W("column-gap",oc),W("opacity",ac))}sc();var Ru=new Set(["border","border-color","border-style","border-width","border-radius","margin","padding","background","font","text-decoration","flex","gap"]),F7=new Map;function dc(t){if(F7.has(t))return F7.get(t);let x=ks(t);return x&&F7.set(t,x),x}function fc(t,x,e,n){let r={};for(let[i,s]of Object.entries(t))r[i.toLowerCase()]=s.trim();let o=[],a=[];for(let[i,s]of Object.entries(r))Ru.has(i)?o.push([i,s]):a.push([i,s]);for(let[i,s]of o){let d=dc(i);d?d(s,x,e,n):i.startsWith("--")||console.warn(`Unsupported CSS property: ${i}`)}for(let[i,s]of a){let d=dc(i);d?d(s,x,e,n):i.startsWith("--")||console.warn(`Unsupported CSS property: ${i}`)}}function cc(t){let x={};if(!t||typeof t!="string")return x;let e=t.split(";");for(let n of e){let r=n.indexOf(":");if(r===-1)continue;let o=n.substring(0,r).trim(),a=n.substring(r+1).trim();o&&a&&(x[o]=a)}return x}var tn=class{static resolveInheritedProperties(x,e){return{color:x.color??e.color,fontSize:x.fontSize,lineHeight:j0(x.lineHeight),fontFamily:x.fontFamily??e.fontFamily,fontStyle:x.fontStyle??e.fontStyle,fontVariant:x.fontVariant??e.fontVariant,fontWeight:x.fontWeight??e.fontWeight,letterSpacing:x.letterSpacing??e.letterSpacing,textDecorationLine:x.textDecorationLine??e.textDecorationLine,textDecorationColor:x.textDecorationColor??e.textDecorationColor,textDecorationStyle:x.textDecorationStyle??e.textDecorationStyle,overflowWrap:x.overflowWrap??e.overflowWrap,textIndent:x.textIndent??e.textIndent??0,textTransform:x.textTransform??e.textTransform??"none",listStyleType:x.listStyleType??e.listStyleType??"disc"}}};var nn=class{constructor(x,e){this.fontSize=x;this.rootFontSize=e}resolveLengthInput(x){return Bo(x,this.fontSize,this.rootFontSize)}resolveNumberLike(x){return N0(x,this.fontSize,this.rootFontSize)}resolveShadowLength(x,e=!1){let n=this.resolveNumberLike(x);return n===void 0||e&&n<0?0:n}createLengthAssigner(x){return e=>{let n=this.resolveLengthInput(e);n!==void 0&&x(n)}}createNumberAssigner(x){return e=>{let n=this.resolveNumberLike(e);n!==void 0&&x(n)}}};var Re=class t{static resolveTrackSizeInputToAbsolute(x,e,n){return x.kind==="fixed"?{kind:"fixed",size:N0(x.size,e,n)??0}:x.kind==="flex"?{kind:"flex",flex:x.flex,min:N0(x.min,e,n),max:N0(x.max,e,n)}:{kind:"auto",min:N0(x.min,e,n),max:N0(x.max,e,n)}}static resolveTrackDefinitionsInput(x,e,n){if(x)return x.map(r=>r.kind==="repeat"?{kind:"repeat",count:r.count,track:t.resolveTrackSizeInputToAbsolute(r.track,e,n)}:r.kind==="repeat-auto"?{kind:"repeat-auto",mode:r.mode,track:t.resolveTrackSizeInputToAbsolute(r.track,e,n)}:t.resolveTrackSizeInputToAbsolute(r,e,n))}};function Su(t){switch(t){case"left":return"left";case"right":return"right";case"none":return"none";default:return}}function vu(t){let x;switch(t){case"span":case"a":case"strong":case"em":case"b":case"s":case"strike":case"del":case"label":case"code":case"small":case"time":case"i":case"u":case"sub":case"sup":case"mark":case"abbr":case"cite":case"dfn":case"kbd":case"q":case"tt":x="inline";break;case"table":x="table";break;case"tbody":case"thead":case"tfoot":x="table-row-group";break;case"tr":x="table-row";break;case"td":case"th":x="table-cell";break;case"caption":x="table-caption";break;case"div":case"section":case"main":case"article":case"header":case"footer":case"nav":case"p":case"ul":case"ol":case"li":case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":x="block";break;default:x="block";break}return k("style","trace","defaultDisplayForTag",{tag:t,display:x}),x}var Lu={small:.8,big:1.2};function Cu(t,x,e){let{fontSize:n,marginTop:r,marginRight:o,marginBottom:a,marginLeft:i,paddingTop:s,paddingRight:d,paddingBottom:f,paddingLeft:c,borderTop:l,borderRight:u,borderBottom:p,borderLeft:m,...h}=t,b={...h},g=y=>N0(y,x,e);return n!==void 0&&(b.fontSize=g(n)??x),r!==void 0&&(b.marginTop=g(r)),o!==void 0&&(b.marginRight=g(o)),a!==void 0&&(b.marginBottom=g(a)),i!==void 0&&(b.marginLeft=g(i)),s!==void 0&&(b.paddingTop=g(s)),d!==void 0&&(b.paddingRight=g(d)),f!==void 0&&(b.paddingBottom=g(f)),c!==void 0&&(b.paddingLeft=g(c)),l!==void 0&&(b.borderTop=g(l)),u!==void 0&&(b.borderRight=g(u)),p!==void 0&&(b.borderBottom=g(p)),m!==void 0&&(b.borderLeft=g(m)),b}function xx(t,x,e,n,r){let o=t.tagName.toLowerCase(),a=ee.getDefaultsForElement(o),i=Px.createBaseDefaults(),s=Px.mergeElementDefaults(i,a),d=tn.resolveInheritedProperties(e,s),f={},c={};for(let C of x)if(C.match(t)){k("style","debug","CSS rule matched",{selector:C.selector,declarations:C.declarations}),C.declarations.display&&k("style","debug","Display declaration found",{selector:C.selector,display:C.declarations.display});let j={};for(let[t0,Z]of Object.entries(C.declarations))t0.startsWith("--")?j[t0]=Z:j[t0.toLowerCase()]=Z;Object.assign(c,j)}let l=cc(t.getAttribute("style")??"");Object.keys(l).length>0&&k("style","debug","inline style applied",{declarations:l}),Object.assign(c,l);let u=e.customProperties?e.customProperties.clone():new Yx;u=_o(c).inherit(u),k("style","debug","custom properties",{count:u.size,keys:u.keys()});let m=Yo(c,u);fc(m,f,n,d.fontWeight??s.fontWeight);let h=s.display??vu(o),b=f.display??h;k("style","debug","computeStyleForElement display",{tagName:o,styleInitDisplay:f.display,defaultDisplay:h,finalDisplay:b}),o==="table"?b!=="table"&&(k("style","debug","Forcing table display",{tagName:o,originalDisplay:b}),b="table"):o==="thead"||o==="tbody"||o==="tfoot"?b!=="table-row-group"&&(k("style","debug","Forcing table-row-group display",{tagName:o,originalDisplay:b}),b="table-row-group"):o==="tr"?b!=="table-row"&&(k("style","debug","Forcing table-row display",{tagName:o,originalDisplay:b}),b="table-row"):(o==="td"||o==="th")&&b!=="table-cell"&&(k("style","debug","Forcing table-cell display",{tagName:o,originalDisplay:b}),b="table-cell");let g=Su(f.float),y=a.fontWeight!==void 0,w=a.fontStyle!==void 0,S=i.lineHeight??o0(),R=s.lineHeight??S,L=!Wo(R,S),T=r??e.fontSize,P=d.fontSize;if(f.fontSize!==void 0){let C=N0(f.fontSize,d.fontSize,T);C!==void 0&&(P=C)}else{let C=N0(s.fontSize,d.fontSize,T);C!==void 0&&(P=C);let j=Lu[o];j!==void 0&&(P=(d.fontSize??16)*j)}let E=Cu(s,P,T),B={customProperties:u,...E,color:d.color,fontSize:P,lineHeight:j0(L?R:d.lineHeight),fontFamily:d.fontFamily,fontStyle:w?s.fontStyle:d.fontStyle,fontWeight:y?s.fontWeight:g0(d.fontWeight),overflowWrap:d.overflowWrap,textIndent:d.textIndent??s.textIndent??0,textTransform:d.textTransform??"none",letterSpacing:d.letterSpacing??s.letterSpacing,listStyleType:d.listStyleType??s.listStyleType??"disc",display:b,float:g??"none",borderModel:f.borderModel??s.borderModel};f.lineHeight!==void 0&&(B.lineHeight=Oo(f.lineHeight,P,T));let A=new nn(P,T),F=(C,j)=>{A.createLengthAssigner(j)(C)},D=(C,j)=>{A.createNumberAssigner(j)(C)};if(f.position!==void 0&&(B.position=f.position),f.top!==void 0&&F(f.top,C=>B.top=C),f.right!==void 0&&F(f.right,C=>B.right=C),f.bottom!==void 0&&F(f.bottom,C=>B.bottom=C),f.left!==void 0&&F(f.left,C=>B.left=C),f.zIndex!==void 0&&(B.zIndex=f.zIndex),f.color!==void 0&&(B.color=f.color),f.backgroundLayers!==void 0&&(B.backgroundLayers=f.backgroundLayers),f.clipPath!==void 0&&(B.clipPath=f.clipPath),f.borderColor!==void 0&&(B.borderColor=f.borderColor),f.borderStyleTop!==void 0&&(B.borderStyleTop=f.borderStyleTop),f.borderStyleRight!==void 0&&(B.borderStyleRight=f.borderStyleRight),f.borderStyleBottom!==void 0&&(B.borderStyleBottom=f.borderStyleBottom),f.borderStyleLeft!==void 0&&(B.borderStyleLeft=f.borderStyleLeft),f.boxShadows!==void 0&&(B.boxShadows=f.boxShadows.map(C=>({inset:C.inset,offsetX:A.resolveShadowLength(C.offsetX),offsetY:A.resolveShadowLength(C.offsetY),blurRadius:A.resolveShadowLength(C.blurRadius,!0),spreadRadius:A.resolveShadowLength(C.spreadRadius),color:C.color}))),f.textShadows!==void 0&&(B.textShadows=f.textShadows.map(C=>({offsetX:A.resolveShadowLength(C.offsetX),offsetY:A.resolveShadowLength(C.offsetY),blurRadius:A.resolveShadowLength(C.blurRadius,!0),color:C.color}))),f.fontFamily!==void 0&&(B.fontFamily=f.fontFamily),f.fontStyle!==void 0&&(B.fontStyle=f.fontStyle),f.fontVariant!==void 0&&(B.fontVariant=f.fontVariant),f.fontWeight!==void 0&&(B.fontWeight=g0(f.fontWeight)),f.overflowWrap!==void 0&&(B.overflowWrap=f.overflowWrap),f.marginTop!==void 0?F(f.marginTop,C=>B.marginTop=C):B.marginTop=N0(s.marginTop,P,T),f.marginRight!==void 0?F(f.marginRight,C=>B.marginRight=C):B.marginRight=N0(s.marginRight,P,T),f.marginBottom!==void 0?F(f.marginBottom,C=>B.marginBottom=C):B.marginBottom=N0(s.marginBottom,P,T),f.marginLeft!==void 0?F(f.marginLeft,C=>B.marginLeft=C):B.marginLeft=N0(s.marginLeft,P,T),f.paddingTop!==void 0&&F(f.paddingTop,C=>B.paddingTop=C),f.paddingRight!==void 0&&F(f.paddingRight,C=>B.paddingRight=C),f.paddingBottom!==void 0&&F(f.paddingBottom,C=>B.paddingBottom=C),f.paddingLeft!==void 0&&F(f.paddingLeft,C=>B.paddingLeft=C),f.borderTop!==void 0&&F(f.borderTop,C=>B.borderTop=C),f.borderRight!==void 0&&F(f.borderRight,C=>B.borderRight=C),f.borderBottom!==void 0&&F(f.borderBottom,C=>B.borderBottom=C),f.borderLeft!==void 0&&F(f.borderLeft,C=>B.borderLeft=C),f.borderTopLeftRadiusX!==void 0&&D(f.borderTopLeftRadiusX,C=>B.borderTopLeftRadiusX=C),f.borderTopLeftRadiusY!==void 0&&D(f.borderTopLeftRadiusY,C=>B.borderTopLeftRadiusY=C),f.borderTopRightRadiusX!==void 0&&D(f.borderTopRightRadiusX,C=>B.borderTopRightRadiusX=C),f.borderTopRightRadiusY!==void 0&&D(f.borderTopRightRadiusY,C=>B.borderTopRightRadiusY=C),f.borderBottomRightRadiusX!==void 0&&D(f.borderBottomRightRadiusX,C=>B.borderBottomRightRadiusX=C),f.borderBottomRightRadiusY!==void 0&&D(f.borderBottomRightRadiusY,C=>B.borderBottomRightRadiusY=C),f.borderBottomLeftRadiusX!==void 0&&D(f.borderBottomLeftRadiusX,C=>B.borderBottomLeftRadiusX=C),f.borderBottomLeftRadiusY!==void 0&&D(f.borderBottomLeftRadiusY,C=>B.borderBottomLeftRadiusY=C),f.width!==void 0&&F(f.width,C=>B.width=C),f.minWidth!==void 0&&F(f.minWidth,C=>B.minWidth=C),f.maxWidth!==void 0&&F(f.maxWidth,C=>B.maxWidth=C),f.height!==void 0&&F(f.height,C=>B.height=C),f.minHeight!==void 0&&F(f.minHeight,C=>B.minHeight=C),f.maxHeight!==void 0&&F(f.maxHeight,C=>B.maxHeight=C),f.trackListColumns!==void 0){let C=Re.resolveTrackDefinitionsInput(f.trackListColumns,P,T);C&&(B.trackListColumns=C)}if(f.trackListRows!==void 0){let C=Re.resolveTrackDefinitionsInput(f.trackListRows,P,T);C&&(B.trackListRows=C)}f.autoFlow!==void 0&&(B.autoFlow=f.autoFlow),f.rowGap!==void 0&&D(f.rowGap,C=>B.rowGap=C),f.columnGap!==void 0&&D(f.columnGap,C=>B.columnGap=C),f.justifyContent!==void 0&&(B.justifyContent=f.justifyContent),f.alignItems!==void 0&&(B.alignItems=f.alignItems),f.alignContent!==void 0&&(B.alignContent=f.alignContent),f.alignSelf!==void 0&&(B.alignSelf=f.alignSelf),f.flexDirection!==void 0&&(B.flexDirection=f.flexDirection),f.flexWrap!==void 0&&(B.flexWrap=f.flexWrap),f.textAlign!==void 0&&(B.textAlign=f.textAlign),f.textIndent!==void 0&&F(f.textIndent,C=>B.textIndent=C),f.textTransform!==void 0&&(B.textTransform=f.textTransform),f.letterSpacing!==void 0&&D(f.letterSpacing,C=>B.letterSpacing=C),f.listStyleType!==void 0&&(B.listStyleType=f.listStyleType),f.transform!==void 0&&(B.transform=f.transform),f.objectFit!==void 0&&(B.objectFit=f.objectFit),f.opacity!==void 0&&(B.opacity=f.opacity);let O=s.textDecorationLine??"none",U=d.textDecorationLine??O;a.textDecorationLine!==void 0&&(U=a.textDecorationLine),f.textDecorationLine!==void 0&&(U=f.textDecorationLine),B.textDecorationLine=U;let Y=f.textDecorationColor!==void 0?lc(f.textDecorationColor):void 0;Y===void 0&&(Y=a.textDecorationColor!==void 0?lc(a.textDecorationColor):void 0),Y===void 0&&d.textDecorationColor!==void 0&&(Y=d.textDecorationColor),Y!==void 0&&(B.textDecorationColor=Y);let q=s.textDecorationStyle??"solid",X=d.textDecorationStyle??q;if(a.textDecorationStyle!==void 0&&(X=a.textDecorationStyle),f.textDecorationStyle!==void 0&&(X=f.textDecorationStyle),B.textDecorationStyle=X,o==="em"||o==="strong"){let C={tagName:o,elementDefaultsFontStyle:a.fontStyle,mergedFontStyle:s.fontStyle,finalFontStyle:B.fontStyle};k("style","debug","element fontStyle",C)}return new $0(B)}function lc(t){if(t===void 0)return;let x=t.trim();if(!x)return;let e=x.toLowerCase();if(e!=="inherit"){if(e==="initial")return"currentcolor";if(!(e==="unset"||e==="revert"||e==="revert-layer"))return e==="currentcolor"?"currentcolor":x}}var V6=class{static calculateDimensions(x,e,n){let r=x,o=e;if(n.scale&&n.scale>0)r=Math.max(1,Math.round(x*n.scale)),o=Math.max(1,Math.round(e*n.scale));else if(n.maxWidth||n.maxHeight){let a=Math.min(n.maxWidth?n.maxWidth/x:1/0,n.maxHeight?n.maxHeight/e:1/0);a>0&&a<1&&(r=Math.max(1,Math.round(x*a)),o=Math.max(1,Math.round(e*a)))}return{targetWidth:r,targetHeight:o}}static resizeNN(x,e,n,r,o,a){if(e===r&&n===o)return x;let i=new Uint8Array(r*o*a),s=e/r,d=n/o;for(let f=0;f<o;f++){let l=Math.min(n-1,Math.floor(f*d))*e*a,u=f*r*a;for(let p=0;p<r;p++){let m=Math.min(e-1,Math.floor(p*s)),h=l+m*a,b=u+p*a;for(let g=0;g<a;g++)i[b+g]=x[h+g]}}return i}};var rn=class t extends V6{static{this.SOI_MARKER=65496}static{this.EOI_MARKER=65497}static{this.SOF0_MARKER=65472}async decode(x,e={}){let n=new DataView(x);if(n.getUint16(0,!1)!==t.SOI_MARKER)throw new Error("Invalid JPEG: missing SOI marker");let r=2,o=0,a=0,i=3,s=8;for(;r+4<x.byteLength;){let l=n.getUint16(r,!1);if(r+=2,l===t.EOI_MARKER)break;let u=n.getUint16(r,!1);if(l===t.SOF0_MARKER){s=n.getUint8(r+2),a=n.getUint16(r+3,!1),o=n.getUint16(r+5,!1),i=n.getUint8(r+7);break}r+=u}if(o===0||a===0)throw new Error("Invalid JPEG: missing SOF0 marker");let{targetWidth:d,targetHeight:f}=t.calculateDimensions(o,a,e),c=x.slice(0);return{width:d,height:f,format:"jpeg",channels:i,bitsPerChannel:s,data:c}}};async function Tu(t){if(typeof DecompressionStream<"u"){let x=new DecompressionStream("deflate-raw"),e=new Blob([t.buffer]).stream().pipeThrough(x),n=await new Response(e).arrayBuffer();return new Uint8Array(n)}else{let{inflateRawSync:x}=await Promise.resolve().then(()=>(Jx(),Qx));return x(t)}}async function Pu(t){if(typeof DecompressionStream<"u"){let x=new DecompressionStream("deflate"),e=new Blob([t.buffer]).stream().pipeThrough(x),n=await new Response(e).arrayBuffer();return new Uint8Array(n)}else{let{inflateSync:x}=await Promise.resolve().then(()=>(Jx(),Qx));return x(t)}}function uc(t,x,e){let n=8/e,r=Math.floor(x/n),o=x%n,a=8-e*(o+1),i=(1<<e)-1;return t[r]>>a&i}function Fu(t,x){let e=(1<<x)-1;return Math.round(t/e*255)}function Bu(t,x,e){let n=t+x-e,r=Math.abs(n-t),o=Math.abs(n-x),a=Math.abs(n-e);return r<=o&&r<=a?t:o<=a?x:e}var on=class t extends V6{static{this.PNG_SIGNATURE=[137,80,78,71,13,10,26,10]}constructor(x={}){super(),this.decompression={inflateRaw:x.inflateRaw??Tu,inflateZlib:x.inflateZlib??Pu}}async decode(x,e={}){let n=new DataView(x);t.validateSignature(n);let{metadata:r,idatChunks:o}=t.parseChunks(x,n);t.validateMetadata(r);let a=await this.decompressImageData(o),i=t.decodeScanlines(a,r),{targetWidth:s,targetHeight:d}=t.calculateDimensions(r.width,r.height,e),f=t.resizeNN(i,r.width,r.height,s,d,4);return{width:s,height:d,format:"png",channels:4,bitsPerChannel:8,data:f.buffer}}static validateSignature(x){for(let e=0;e<t.PNG_SIGNATURE.length;e++)if(x.getUint8(e)!==t.PNG_SIGNATURE[e])throw new Error("Invalid PNG signature")}static parseChunks(x,e){let n=8,r=[],o={palette:null,transparency:null},a=!1,i=!1;for(;n<x.byteLength;){if(n+8>x.byteLength)throw new Error("Incomplete chunk header");let s=e.getUint32(n,!1),d=String.fromCharCode(e.getUint8(n+4),e.getUint8(n+5),e.getUint8(n+6),e.getUint8(n+7)),f=n+8;if(n+12+s>x.byteLength)throw new Error(`Chunk ${d} extends beyond file boundary`);switch(d){case"IHDR":t.parseIHDR(e,f,o);break;case"PLTE":if(a)throw new Error("PLTE chunk must appear before IDAT");t.parsePLTE(x,f,s,o);break;case"tRNS":if(a)throw new Error("tRNS chunk must appear before IDAT");t.parseTRNS(x,f,s,o);break;case"IDAT":a=!0,r.push(new Uint8Array(x,f,s));break;case"IEND":i=!0,n+=12+s;break;default:break}if(i)break;n+=12+s}if(!i)throw new Error("Missing IEND chunk");if(!a)throw new Error("Missing IDAT chunk");return{metadata:o,idatChunks:r}}static parseIHDR(x,e,n){n.width=x.getUint32(e,!1),n.height=x.getUint32(e+4,!1),n.bitDepth=x.getUint8(e+8),n.colorType=x.getUint8(e+9);let r=x.getUint8(e+10),o=x.getUint8(e+11);if(n.interlaceMethod=x.getUint8(e+12),r!==0)throw new Error("Unsupported compression method");if(o!==0)throw new Error("Unsupported filter method")}static parsePLTE(x,e,n,r){if(n%3!==0)throw new Error("Invalid PLTE chunk length");if(n/3>256)throw new Error("PLTE has too many entries");r.palette=new Uint8Array(x,e,n)}static parseTRNS(x,e,n,r){r.transparency=new Uint8Array(x,e,n)}static validateMetadata(x){if(!x.width||!x.height)throw new Error("Missing or invalid IHDR chunk");if(x.colorType===3&&!x.palette)throw new Error("Indexed color PNG missing PLTE chunk");if(x.interlaceMethod!==0)throw new Error("Interlaced PNGs are not supported");if(!{0:[1,2,4,8,16],2:[8,16],3:[1,2,4,8],4:[8,16],6:[8,16]}[x.colorType]?.includes(x.bitDepth))throw new Error(`Invalid bit depth ${x.bitDepth} for color type ${x.colorType}`)}async decompressImageData(x){let e=x.reduce((a,i)=>a+i.length,0),n=new Uint8Array(e),r=0;for(let a of x)n.set(a,r),r+=a.length;let o=(n[0]&15)===8;try{return o?await this.decompression.inflateZlib(n):await this.decompression.inflateRaw(n.slice(2,-4))}catch(a){throw new Error(`Decompression failed: ${a}`)}}static decodeScanlines(x,e){let{width:n,height:r,bitDepth:o,colorType:a}=e,i=t.getChannelCount(a),s=o*i,d=Math.ceil(s*n/8),f=Math.max(1,Math.ceil(s/8)),c=new Uint8Array(n*r*4),l=new Uint8Array(d),u=0;for(let p=0;p<r;p++){let m=x[u++],h=x.subarray(u,u+d);u+=d;let b=t.reconstructRow(h,l,m,f);t.convertRowToRGBA(b,c,p,n,e),l=b}return c}static getChannelCount(x){return{0:1,2:3,3:1,4:2,6:4}[x]}static reconstructRow(x,e,n,r){let o=new Uint8Array(x.length);for(let a=0;a<x.length;a++){let i=a>=r?o[a-r]:0,s=e[a],d=a>=r?e[a-r]:0,f;switch(n){case 0:f=x[a];break;case 1:f=x[a]+i;break;case 2:f=x[a]+s;break;case 3:f=x[a]+(i+s>>>1);break;case 4:f=x[a]+Bu(i,s,d);break;default:throw new Error(`Invalid filter type: ${n}`)}o[a]=f&255}return o}static convertRowToRGBA(x,e,n,r,o){let{colorType:a,bitDepth:i,palette:s,transparency:d}=o;switch(a){case 0:t.convertGrayscale(x,e,n,r,i,d);break;case 2:t.convertRGB(x,e,n,r,i,d);break;case 3:t.convertIndexed(x,e,n,r,i,s,d);break;case 4:t.convertGrayscaleAlpha(x,e,n,r,i);break;case 6:t.convertRGBA(x,e,n,r,i);break}}static convertGrayscale(x,e,n,r,o,a){for(let i=0;i<r;i++){let s;if(o===8)s=x[i];else if(o===16)s=x[i*2];else{let f=uc(x,i,o);s=Fu(f,o)}let d=(n*r+i)*4;e[d]=s,e[d+1]=s,e[d+2]=s,e[d+3]=a&&s===a[1]?0:255}}static convertRGB(x,e,n,r,o,a){let i=o===16?6:3,s=o===16?2:1;for(let d=0;d<r;d++){let f=d*i,c=(n*r+d)*4,l=x[f],u=x[f+s],p=x[f+s*2];e[c]=l,e[c+1]=u,e[c+2]=p;let m=a&&l===a[1]&&u===a[3]&&p===a[5];e[c+3]=m?0:255}}static convertIndexed(x,e,n,r,o,a,i){for(let s=0;s<r;s++){let d=o===8?x[s]:uc(x,s,o),f=d*3,c=(n*r+s)*4;e[c]=a[f],e[c+1]=a[f+1],e[c+2]=a[f+2],e[c+3]=i&&d<i.length?i[d]:255}}static convertGrayscaleAlpha(x,e,n,r,o){let a=o===16?4:2,i=o===16?2:1;for(let s=0;s<r;s++){let d=s*a,f=(n*r+s)*4,c=x[d],l=x[d+i];e[f]=c,e[f+1]=c,e[f+2]=c,e[f+3]=l}}static convertRGBA(x,e,n,r,o){let a=o===16?8:4,i=o===16?2:1;for(let s=0;s<r;s++){let d=s*a,f=(n*r+s)*4;e[f]=x[d],e[f+1]=x[d+i],e[f+2]=x[d+i*2],e[f+3]=x[d+i*3]}}};var an=class{validateHeader(x){if(x.getString(4)!=="RIFF")throw new Error("Invalid WebP: Missing RIFF header");if(x.getUint32(!0),x.getString(4)!=="WEBP")throw new Error("Invalid WebP: Missing WEBP signature")}parseChunks(x){let e=[];for(;x.hasMore();){let n=x.getString(4),r=x.getUint32(!0),o=x.getView(r);e.push({fourCC:n,size:r,data:o}),r%2===1&&x.hasMore()&&x.seek(x.tell()+1)}return e}};var Au=[17,18,0,1,2,3,4,5,16,6,7,8,9,10,11,12,13,14,15],Mu=5,sn=class{readHuffmanCodes(x){let e=[];for(let n=0;n<Mu;n++){let r=n===4?40:280;e[n]=this.readHuffmanCode(x,r)}return e}readHuffmanCode(x,e){if(x.readBits(1))return this.readSimpleHuffmanCode(x);let r=new Array(19).fill(0),o=4+x.readBits(4);for(let s=0;s<o;s++)r[Au[s]]=x.readBits(3);let a=this.buildHuffmanTree(r),i=this.readCodeLengths(x,a,e);return this.buildHuffmanTree(i)}readSimpleHuffmanCode(x){let e=x.readBits(1)+1,n=[],o=x.readBits(1)?8:1;return n.push(x.readBits(o)),e===2&&n.push(x.readBits(o)),this.buildSimpleHuffman(n)}readCodeLengths(x,e,n){let r=new Array(n).fill(0),o=0;for(;o<n;){let a=this.readSymbol(x,e);if(a<16)r[o++]=a;else{let i=0,s=0;a===16?(i=3+x.readBits(2),s=r[o-1]):a===17?i=3+x.readBits(3):a===18&&(i=11+x.readBits(7));for(let d=0;d<i&&o<n;d++)r[o++]=s}}return r}buildSimpleHuffman(x){return x.length===1?{codes:[{symbol:x[0],length:0,code:0}],maxLength:0}:{codes:[{symbol:x[0],length:1,code:0},{symbol:x[1],length:1,code:1}],maxLength:1}}buildHuffmanTree(x){let e=x.filter(s=>s>0&&Number.isFinite(s)),n=e.length>0?Math.max(...e):0,r=[];if(n===0)return{codes:[],maxLength:0,lookupTable:new Map};let o=new Array(n+1).fill(0),a=new Array(n+1).fill(0);for(let s of x)s>0&&Number.isFinite(s)&&o[s]++;a[1]=0;for(let s=2;s<=n;s++)a[s]=a[s-1]+o[s-1]<<1;let i=new Map;for(let s=0;s<x.length;s++){let d=x[s];if(d>0&&Number.isFinite(d)){let f=a[d];r.push({symbol:s,length:d,code:f});let c=f<<4|d;i.set(c,s),a[d]++}}return{codes:r,maxLength:n,lookupTable:i}}readSymbol(x,e){if(e.maxLength===0)return e.codes[0].symbol;if(e.lookupTable){let n=0;for(let r=0;r<e.maxLength;r++){n=n<<1|x.readBits(1);let o=n<<4|r+1,a=e.lookupTable.get(o);if(a!==void 0)return a}}for(let n of e.codes){let r=0;for(let o=0;o<n.length;o++)r=r<<1|x.readBits(1);if(r===n.code)return n.symbol}return 0}};var ku=47,dn=class{constructor(){this.huffmanDecoder=new sn}decodeVp8l(x,e,n,r){let o=new fn(x.data);if(o.readBits(8)!==ku)throw new Error("Invalid VP8L signature");let i=o.readBits(14)+1,s=o.readBits(14)+1,d=o.readBits(3);if(d!==0)throw new Error(`Unsupported VP8L version: ${d}`);let f=o.readBits(1);for(;f;){let h=o.readBits(2);if(h===0||h===1){let b=o.readBits(3)+2,g=this.subSampleSize(i,b),y=this.subSampleSize(s,b);this.skipTransformImage(o,g,y)}f=o.readBits(1)}let c=this.huffmanDecoder.readHuffmanCodes(o),l=this.decodePixelData(o,i,s,c),{targetWidth:u,targetHeight:p}=n(i,s,e),m=r(l,i,s,u,p,4);return{width:u,height:p,format:"webp",channels:4,bitsPerChannel:8,data:m.buffer}}decodePixelData(x,e,n,r){let o=new Uint8Array(e*n*4),a=0,i=e*n;for(let s=0;s<i;s++){let d=this.huffmanDecoder.readSymbol(x,r[0]);if(d<256){let f=this.huffmanDecoder.readSymbol(x,r[1]),c=this.huffmanDecoder.readSymbol(x,r[2]),l=this.huffmanDecoder.readSymbol(x,r[3]);o[a++]=f,o[a++]=d,o[a++]=c,o[a++]=l}else{let f=d-256,c=this.getLengthFromSymbol(f,x),l=this.huffmanDecoder.readSymbol(x,r[4]),u=this.getDistanceFromSymbol(l,x);for(let p=0;p<c&&s+p<i;p++){let m=a-u*4;m>=0&&(o[a++]=o[m],o[a++]=o[m+1],o[a++]=o[m+2],o[a++]=o[m+3])}s+=c-1}}return o}subSampleSize(x,e){return x+(1<<e)-1>>e}skipTransformImage(x,e,n){try{this.huffmanDecoder.readHuffmanCodes(x)}catch{let o=Math.min(e*n*4,1e4);for(let a=0;a<o&&x.hasMore();a++)x.readBits(1);return}let r=e*n;for(let o=0;o<Math.min(r*4,1e4)&&x.hasMore();o++)x.readBits(1)}getLengthFromSymbol(x,e){if(x<4)return x+1;let n=x-2>>1;return(2+(x&1)<<n)+e.readBits(n)+1}getDistanceFromSymbol(x,e){if(x<4)return x+1;let n=x-2>>1;return(2+(x&1)<<n)+e.readBits(n)+1}decodeVp8x(x,e,n,r,o){if((new Uint8Array(x.data.buffer,x.data.byteOffset,x.data.byteLength)[0]&2)!==0)throw new Error("Animated WebP is not supported");let d=e.find(c=>c.fourCC==="VP8L");if(d)return this.decodeVp8l(d,n,r,o);throw e.find(c=>c.fourCC==="VP8 ")?new Error("VP8 (lossy) WebP format is not yet supported"):new Error("No image data found in VP8X container")}};var Iu=new TextDecoder("ascii"),B7=class{constructor(x){this.offset=0;this.view=new DataView(x)}seek(x){if(x<0||x>this.view.byteLength)throw new RangeError(`Seek offset ${x} out of bounds [0, ${this.view.byteLength}]`);this.offset=x}tell(){return this.offset}hasMore(){return this.offset<this.view.byteLength}getUint8(){this.checkBounds(1);let x=this.view.getUint8(this.offset);return this.offset+=1,x}getUint16(x=!1){this.checkBounds(2);let e=this.view.getUint16(this.offset,x);return this.offset+=2,e}getUint32(x=!1){this.checkBounds(4);let e=this.view.getUint32(this.offset,x);return this.offset+=4,e}getString(x){this.checkBounds(x);let e=new Uint8Array(this.view.buffer,this.view.byteOffset+this.offset,x);return this.offset+=x,Iu.decode(e)}getView(x){this.checkBounds(x);let e=new DataView(this.view.buffer,this.view.byteOffset+this.offset,x);return this.offset+=x,e}checkBounds(x){if(this.offset+x>this.view.byteLength)throw new RangeError(`Read beyond buffer bounds: ${this.offset+x} > ${this.view.byteLength}`)}},fn=class{constructor(x){this.bytePos=0;this.bitPos=0;this.view=x}readBits(x){if(x>32)throw new Error("Cannot read more than 32 bits at once");let e=0;for(let n=0;n<x;n++){if(this.bytePos>=this.view.byteLength)return e;let o=this.view.getUint8(this.bytePos)>>this.bitPos&1;e|=o<<n,this.bitPos++,this.bitPos===8&&(this.bitPos=0,this.bytePos++)}return e}hasMore(){return this.bytePos<this.view.byteLength}peekBits(x){let e=this.bytePos,n=this.bitPos,r=this.readBits(x);return this.bytePos=e,this.bitPos=n,r}},A7=class{static calculateDimensions(x,e,n){let r=x,o=e;if(n.scale&&n.scale>0)r=Math.max(1,Math.round(x*n.scale)),o=Math.max(1,Math.round(e*n.scale));else if(n.maxWidth||n.maxHeight){let a=Math.min(n.maxWidth?n.maxWidth/x:1/0,n.maxHeight?n.maxHeight/e:1/0);a>0&&a<1&&(r=Math.max(1,Math.round(x*a)),o=Math.max(1,Math.round(e*a)))}return{targetWidth:r,targetHeight:o}}static resizeNN(x,e,n,r,o,a){if(e===r&&n===o)return x;let i=new Uint8Array(r*o*a),s=e/r,d=n/o;for(let f=0;f<o;f++){let l=Math.min(n-1,Math.floor(f*d))*e*a,u=f*r*a;for(let p=0;p<r;p++){let m=Math.min(e-1,Math.floor(p*s)),h=l+m*a,b=u+p*a;for(let g=0;g<a;g++)i[b+g]=x[h+g]}}return i}},cn=class t extends A7{constructor(){super(...arguments);this.riffParser=new an;this.vp8lDecoder=new dn}async decode(e,n={}){let r=new B7(e);this.riffParser.validateHeader(r);let o=this.riffParser.parseChunks(r),a=o.find(d=>d.fourCC==="VP8X");if(a)return this.vp8lDecoder.decodeVp8x(a,o,n,t.calculateDimensions,t.resizeNN);let i=o.find(d=>d.fourCC==="VP8L");if(i)return this.vp8lDecoder.decodeVp8l(i,n,t.calculateDimensions,t.resizeNN);throw o.find(d=>d.fourCC==="VP8 ")?new Error("VP8 (lossy) WebP format is not yet supported"):new Error("Unsupported WebP format: No recognized image chunk found")}};var M7=class{async load(x){throw new Error("NodeEnvironment is not available in browser builds")}},k7=class{async inflateRaw(x){throw new Error("NodeEnvironment compression is not available in browser builds")}},m6=class{constructor(){this.loader=new M7;this.compression=new k7}resolveLocal(){throw new Error("NodeEnvironment resolveLocal is not available in browser builds")}now(){return typeof performance<"u"?performance.now():Date.now()}getEnv(x){}fileURLToPath(){throw new Error("NodeEnvironment fileURLToPath is not available in browser builds")}pathToFileURL(){throw new Error("NodeEnvironment pathToFileURL is not available in browser builds")}pathResolve(){throw new Error("NodeEnvironment pathResolve is not available in browser builds")}pathJoin(){throw new Error("NodeEnvironment pathJoin is not available in browser builds")}pathDirname(){throw new Error("NodeEnvironment pathDirname is not available in browser builds")}pathIsAbsolute(){throw new Error("NodeEnvironment pathIsAbsolute is not available in browser builds")}};var Wx=class t{constructor(x){this.imageCache=new Map;this.jpegDecoder=new rn;this.pngDecoder=new on;this.webpDecoder=new cn;this.env=x??Nu()}static getInstance(x){return t.instance||(t.instance=new t(x)),t.instance}async loadImage(x,e){let n=this.normalizeSource(x),r=this.generateCacheKey(n,e);if(this.imageCache.has(r))return this.imageCache.get(r);try{let o=await this.env.loader.load(n),a=await this.decodeImage(o,e);return this.imageCache.set(r,a),a}catch(o){throw new Error(`Failed to load image from ${n}: ${o instanceof Error?o.message:String(o)}`)}}async decodeImage(x,e){let n=this.detectImageFormat(x);switch(n){case"jpeg":return this.jpegDecoder.decode(x,e);case"png":return this.pngDecoder.decode(x,e);case"gif":return this.decodeGif(x,e);case"webp":return this.decodeWebp(x,e);default:throw new Error(`Unsupported image format: ${n}`)}}detectImageFormat(x){let e=new DataView(x);if(x.byteLength>=3&&e.getUint8(0)===255&&e.getUint8(1)===216&&e.getUint8(2)===255)return"jpeg";if(x.byteLength>=8&&e.getUint8(0)===137&&e.getUint8(1)===80&&e.getUint8(2)===78&&e.getUint8(3)===71&&e.getUint8(4)===13&&e.getUint8(5)===10&&e.getUint8(6)===26&&e.getUint8(7)===10)return"png";if(x.byteLength>=6&&new TextDecoder().decode(x.slice(0,6)).startsWith("GIF"))return"gif";if(x.byteLength>=12&&e.getUint32(0,!1)===1380533830&&e.getUint32(8,!1)===1464156752)return"webp";throw new Error("Unknown image format")}decodeGif(x,e){let n=e?.maxWidth||100,r=e?.maxHeight||100,o=n*r,a=new ArrayBuffer(o*4);return{width:n,height:r,format:"gif",channels:4,bitsPerChannel:8,data:a}}async decodeWebp(x,e){return this.webpDecoder.decode(x,e)}generateCacheKey(x,e){let n=e?`_${e.maxWidth||0}_${e.maxHeight||0}_${e.scale||1}`:"_default";return`${x}${n}`}clearCache(){this.imageCache.clear()}normalizeSource(x){return x}};function Nu(){let t=po();if(t)return t;if(typeof process<"u"&&!!process.versions?.node)return new m6;throw new Error("Environment not provided to ImageService and no global __PAGYRA_ENV__ set")}function Ux(t){let x="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e=t.replace(/[^A-Za-z0-9+/=]/g,""),n=[],r=0,o=0;for(let a of e){if(a==="=")break;let i=x.indexOf(a);i!==-1&&(r=r<<6|i,o+=6,o>=8&&(o-=8,n.push(r>>o&255)))}return new Uint8Array(n)}function I7(t,x){let e=t.trim();if(!e||/^data:/i.test(e))return e;try{let n=new URL(e);return n.protocol==="file:",n.href}catch{}if(x.environment?.resolveLocal)return x.environment.resolveLocal(e,x.resourceBaseDir||x.assetRootDir||void 0);if(e.startsWith("/")){let n=x.assetRootDir&&x.environment?.pathResolve?x.environment.pathResolve(x.assetRootDir,`.${e}`):e;return k("image-converter","debug","resolveImageSource - resolving absolute path:",{src:t,trimmed:e,assetRootDir:x.assetRootDir,resolved:n}),n}return x.environment?.pathIsAbsolute&&x.environment.pathIsAbsolute(e)?e:x.resourceBaseDir&&x.environment?.pathResolve?x.environment.pathResolve(x.resourceBaseDir,e):e}function bc(t){return/^https?:\/\//i.test(t)}function Eu(t){if(!t)return null;try{let x=new URL(t);if(x.protocol==="http:"||x.protocol==="https:")return x}catch{}return null}function Du(t){let x=new Map,e=[t.assetRootDir,t.resourceBaseDir];for(let n of e){let r=Eu(n);if(r){let o=r.origin;x.has(o)||x.set(o,r)}}return Array.from(x.values())}function N7(t,x){if(!bc(t))return!1;try{let e=new URL(t);return e.protocol!=="http:"&&e.protocol!=="https:"?!1:Du(x).some(r=>r.origin===e.origin)}catch{return!1}}async function mc(t,x,e,n){let r=xx(t,x,e,n.units,n.rootFontSize),a=(t.getAttribute("href")??t.getAttribute("xlink:href")??t.getAttribute("src")??"")?.trim()??"",i=t.getAttribute("width"),s=t.getAttribute("height"),d=i&&Number.parseFloat(i)||void 0,f=s&&Number.parseFloat(s)||void 0;if(!a){let p=new w0(r,[],{tagName:"img"});return p.intrinsicInlineSize=d??100,p.intrinsicBlockSize=f??100,p}let c=I7(a,n),l;try{let p=Wx.getInstance(n.environment);if(bc(c)&&!N7(c,n))throw new Error(`Remote images are not supported (${c})`);if(c.startsWith("data:")){let m=c.match(/^data:image\/(.+);base64,(.+)$/);if(!m)throw new Error("Invalid data URI");let b=Ux(m[2]).slice();l=await p.decodeImage(b.buffer,{maxWidth:d,maxHeight:f})}else l=await p.loadImage(c,{maxWidth:d,maxHeight:f});k("render-tree","debug","Image loaded successfully",{src:a,resolvedSrc:c,width:l.width,height:l.height,format:l.format})}catch(p){k("render-tree","warn",`Failed to load image: ${a}. Using placeholder.`,{resolvedSrc:c,error:p instanceof Error?p.message:String(p)});let m=new w0(r,[],{tagName:"img"});return m.intrinsicInlineSize=d??100,m.intrinsicBlockSize=f??100,m}let u=new w0(r,[],{tagName:"img",customData:{image:{originalSrc:a,resolvedSrc:c,info:l}}});return u.intrinsicInlineSize=l.width,u.intrinsicBlockSize=l.height,kt.processImage(u,l),d&&f?(u.intrinsicInlineSize=d,u.intrinsicBlockSize=f):d?(u.intrinsicInlineSize=d,u.intrinsicBlockSize=Math.round(l.height/l.width*d)):f&&(u.intrinsicBlockSize=f,u.intrinsicInlineSize=Math.round(l.width/l.height*f)),u}var ln=class{constructor(){this.parsers=new Map}register(x,e){this.parsers.set(x.toLowerCase(),e)}parse(x,e){let n=x.tagName.toLowerCase(),r=this.parsers.get(n);return r?r(x,e):(e.warn(`Unsupported <${n}> element ignored.`),null)}has(x){return this.parsers.has(x.toLowerCase())}};function Ou(t){return typeof t=="object"&&t!==null&&"tagName"in t&&"getAttribute"in t&&"nodeType"in t}function pc(t){return Ou(t),t}function hc(t,x={}){let e=x.warn??(()=>{}),n=pc(t);if(n.tagName.toLowerCase()!=="svg")return e("Expected <svg> root element."),null;let r={warn:e},a=(x.registry??M0).parse(n,r);return!a||a.type!=="svg"?(e("Unable to parse <svg> element."),null):a}function Wu(t,x,e){return(e??M0).parse(pc(t),x)}function Uu(t,x){let e=un(t,"svg",x);if(!e)return null;let n=Zu(t.getAttribute("viewBox")),r=a0(t.getAttribute("width")),o=a0(t.getAttribute("height"));return{...e,type:"svg",width:r,height:o,viewBox:n}}function Hu(t,x){let e=un(t,"g",x);return e?{...e,type:"g"}:null}function zu(t,x){let e=un(t,"defs",x);return e?{...e,type:"defs"}:null}function Gu(t){return{..._0(t,"rect"),type:"rect",x:a0(t.getAttribute("x")),y:a0(t.getAttribute("y")),width:a0(t.getAttribute("width")),height:a0(t.getAttribute("height")),rx:a0(t.getAttribute("rx")),ry:a0(t.getAttribute("ry"))}}function ju(t){return{..._0(t,"circle"),type:"circle",cx:a0(t.getAttribute("cx")),cy:a0(t.getAttribute("cy")),r:a0(t.getAttribute("r"))}}function $u(t){return{..._0(t,"ellipse"),type:"ellipse",cx:a0(t.getAttribute("cx")),cy:a0(t.getAttribute("cy")),rx:a0(t.getAttribute("rx")),ry:a0(t.getAttribute("ry"))}}function Vu(t){return{..._0(t,"line"),type:"line",x1:a0(t.getAttribute("x1")),y1:a0(t.getAttribute("y1")),x2:a0(t.getAttribute("x2")),y2:a0(t.getAttribute("y2"))}}function _u(t){return{..._0(t,"path"),type:"path",d:t.getAttribute("d")??void 0}}function Yu(t){return{..._0(t,"polyline"),type:"polyline",points:wc(t.getAttribute("points"))}}function Xu(t){return{..._0(t,"polygon"),type:"polygon",points:wc(t.getAttribute("points"))}}function qu(t){let x=_0(t,"text"),n=(t.textContent??"").replace(/\s+/g," ").trim();return n?{...x,type:"text",text:n,x:a0(t.getAttribute("x")),y:a0(t.getAttribute("y")),fontSize:a0(t.getAttribute("font-size")),fontFamily:t.getAttribute("font-family")??void 0,textAnchor:Ku(t.getAttribute("text-anchor"))}:null}function Ku(t){if(!t)return;let x=t.trim().toLowerCase();if(x==="start"||x==="middle"||x==="end")return x}function un(t,x,e){let n=_0(t,x),r=[];for(let o of Array.from(t.children)){let a=Wu(o,e);a&&r.push(a)}return{...n,type:x,children:r}}function _0(t,x){let e={};if(typeof t.getAttributeNames=="function")for(let i of t.getAttributeNames()){let s=t.getAttribute(i);s!==null&&(e[i]=s)}else{let i=t.attributes??[];for(let s of Array.from(i)){let d=s.value;d!==null&&(e[s.name]=d)}}let n=t.getAttribute("class"),r=n?n.split(/\s+/).filter(Boolean):[],o=t.getAttribute("transform")??void 0,a=o&&hx(o)||void 0;return{type:x,id:t.getAttribute("id")??void 0,classes:r,attributes:e,transform:o,transformMatrix:a}}function a0(t){if(!t)return;let x=t.trim();if(x.length===0)return;let e=x.match(/^(-?\d+(\.\d+)?)([a-z%]*)$/i);if(!e)return;let n=Number.parseFloat(e[1]);if(!Number.isFinite(n))return;let r=e[3]??"";if(!(r&&r!=="px"))return n}function Zu(t){if(!t)return;let x=t.trim().split(/[\s,]+/).map(e=>Number.parseFloat(e));if(!(x.length!==4||x.some(e=>!Number.isFinite(e))))return{minX:x[0],minY:x[1],width:x[2],height:x[3]}}function Qu(t){return{..._0(t,"image"),type:"image",x:a0(t.getAttribute("x")),y:a0(t.getAttribute("y")),width:a0(t.getAttribute("width")),height:a0(t.getAttribute("height")),href:t.getAttribute("href")||t.getAttribute("xlink:href")||void 0,preserveAspectRatio:t.getAttribute("preserveAspectRatio")||void 0}}function Ju(t){return{..._0(t,"use"),type:"use",x:a0(t.getAttribute("x")),y:a0(t.getAttribute("y")),width:a0(t.getAttribute("width")),height:a0(t.getAttribute("height")),href:t.getAttribute("href")||t.getAttribute("xlink:href")||void 0}}function xb(t,x){let e=un(t,"clippath",x);if(!e)return null;let n=t.getAttribute("clipPathUnits");return{...e,type:"clippath",clipPathUnits:n==="objectBoundingBox"?"objectBoundingBox":"userSpaceOnUse"}}function eb(t,x){let e=_0(t,"lineargradient"),n=gc(t,x);return{...e,type:"lineargradient",x1:a0(t.getAttribute("x1"))??0,y1:a0(t.getAttribute("y1"))??0,x2:a0(t.getAttribute("x2"))??1,y2:a0(t.getAttribute("y2"))??0,gradientUnits:t.getAttribute("gradientUnits")==="userSpaceOnUse"?"userSpaceOnUse":"objectBoundingBox",spreadMethod:yc(t.getAttribute("spreadMethod")),stops:n}}function tb(t,x){let e=_0(t,"radialgradient"),n=gc(t,x);return{...e,type:"radialgradient",cx:a0(t.getAttribute("cx"))??.5,cy:a0(t.getAttribute("cy"))??.5,r:a0(t.getAttribute("r"))??.5,fx:a0(t.getAttribute("fx")),fy:a0(t.getAttribute("fy")),gradientUnits:t.getAttribute("gradientUnits")==="userSpaceOnUse"?"userSpaceOnUse":"objectBoundingBox",spreadMethod:yc(t.getAttribute("spreadMethod")),stops:n}}function gc(t,x){let e=[];for(let n of Array.from(t.children))if(n.tagName.toLowerCase()==="stop"){let r=nb(n.getAttribute("offset")),o=n.getAttribute("stop-color")||"#000000",a=rb(n.getAttribute("stop-opacity"));r!==void 0&&e.push({offset:r,color:o,opacity:a})}return e}function nb(t){if(!t)return;let x=t.trim();if(x.endsWith("%")){let n=Number.parseFloat(x.slice(0,-1));return Number.isFinite(n)?n/100:void 0}let e=Number.parseFloat(x);return Number.isFinite(e)?e:void 0}function rb(t){if(!t)return;let x=Number.parseFloat(t.trim());return Number.isFinite(x)&&x>=0&&x<=1?x:void 0}function yc(t){if(!t)return;let x=t.trim().toLowerCase();if(x==="pad"||x==="reflect"||x==="repeat")return x}function wc(t){if(!t)return;let x=t.trim();if(!x)return;let e=[];for(let r of x.split(/[\s,]+/)){if(!r)continue;let o=Number.parseFloat(r);if(!Number.isFinite(o))return;e.push(o)}if(e.length%2!==0)return;let n=[];for(let r=0;r<e.length;r+=2)n.push({x:e[r],y:e[r+1]});return n}var M0=new ln;M0.register("svg",Uu);M0.register("g",Hu);M0.register("defs",zu);M0.register("rect",Gu);M0.register("circle",ju);M0.register("ellipse",$u);M0.register("line",Vu);M0.register("path",_u);M0.register("polyline",Yu);M0.register("polygon",Xu);M0.register("text",qu);M0.register("image",Qu);M0.register("use",Ju);M0.register("clippath",xb);M0.register("lineargradient",eb);M0.register("radialgradient",tb);var E7=class{constructor(){this.elements=new Map;this.registerDefaults()}registerDefaults(){this.elements.set("input",{tagName:"input",isFormControl:!0,attributeExtractors:["type","value","checked","disabled","placeholder","name","id","min","max","step","accept","multiple","readonly","required"]}),this.elements.set("select",{tagName:"select",isFormControl:!0,attributeExtractors:["multiple","disabled","name","id","required"]}),this.elements.set("textarea",{tagName:"textarea",isFormControl:!0,attributeExtractors:["rows","cols","disabled","placeholder","name","id","maxlength","minlength","readonly","required","wrap"]}),this.elements.set("button",{tagName:"button",isFormControl:!0,attributeExtractors:["type","disabled","name","id","value"]})}register(x,e){this.elements.set(x.toLowerCase(),e)}getConfig(x){return this.elements.get(x.toLowerCase())}isFormElement(x){return this.getConfig(x)?.isFormControl??!1}},D7=new E7;function ob(t){let x=(t||"text").toLowerCase();return["text","password","email","number","tel","url","search","date","time","color","range","checkbox","radio","file","hidden"].includes(x)?x:"text"}function ab(t){let x=(t||"button").toLowerCase();return["submit","reset","button"].includes(x)?x:"button"}function wx(t,x){return t.hasAttribute?.(x)===!0&&t.getAttribute(x)!=="false"}function ib(t){let x=[],e=t.querySelectorAll?.("option")??[];for(let n of e)x.push({value:n.getAttribute("value")??n.textContent??"",text:n.textContent??"",selected:wx(n,"selected"),disabled:wx(n,"disabled")});return x}function Rc(t,x){if(!D7.getConfig(x))return null;let n=wx(t,"disabled"),r=t.getAttribute("name")??void 0,o=t.getAttribute("id")??void 0,a=wx(t,"required");switch(x.toLowerCase()){case"input":{let i=t.getAttribute("type"),s=ob(i),d=t.getAttribute("value")??void 0,f=t.getAttribute("placeholder")??void 0,c=s==="checkbox"||s==="radio"?wx(t,"checked"):void 0,l=t.getAttribute("min")??void 0,u=t.getAttribute("max")??void 0,p=t.getAttribute("step")??void 0,m=s==="file"?t.getAttribute("accept")??void 0:void 0,h=s==="file"?wx(t,"multiple"):void 0,b=wx(t,"readonly");return{kind:"input",inputType:s,value:d,placeholder:f,isChecked:c,isDisabled:n,isRequired:a,name:r,id:o,min:l,max:u,step:p,accept:m,multiple:h,readonly:b}}case"select":{let i=wx(t,"multiple");return{kind:"select",options:ib(t),isMultiple:i,isDisabled:n,isRequired:a,name:r,id:o}}case"textarea":{let i=parseInt(t.getAttribute("rows")||"3",10),s=parseInt(t.getAttribute("cols")||"20",10),d=t.getAttribute("value")??t.textContent??"",f=t.getAttribute("placeholder")??void 0,c=parseInt(t.getAttribute("maxlength")||"0",10)||void 0,l=parseInt(t.getAttribute("minlength")||"0",10)||void 0,u=t.getAttribute("wrap")||"soft",p=wx(t,"readonly");return{kind:"textarea",value:d,placeholder:f,rows:i,cols:s,maxlength:c,minlength:l,wrap:u,isDisabled:n,isRequired:a,name:r,id:o,readonly:p}}case"button":{let i=ab(t.getAttribute("type")),s=t.getAttribute("value")??t.textContent??"";return{kind:"button",buttonType:i,value:s,isDisabled:n,name:r,id:o}}default:return null}}function Tc(t,x){let e=t,n=x==="previous"?r=>r.previousSibling:r=>r.nextSibling;for(;e;){if(e.nodeType===e.TEXT_NODE){if((e.textContent??"").replace(/\s+/g,"").length>0)return e}else if(e.nodeType===e.ELEMENT_NODE){let r=e.tagName.toLowerCase();if(!["script","style","meta","link"].includes(r))return e}e=n(e)}return null}function sb(t){return Tc(t.previousSibling,"previous")!==null}function db(t){return Tc(t.nextSibling,"next")!==null}function fb(t){return t==="inline"||t==="inline-block"||t==="inline-flex"||t==="inline-grid"||t==="inline-table"}function Sc(t,x){if(x.whiteSpace==="pre"||x.whiteSpace==="pre-wrap")return!0;let e=t.length>0?t[t.length-1]:null;return!!e&&fb(e.style.display)}function cb(t){let x=t.trim();if(!x)return"";if(x.startsWith("url(")&&x.endsWith(")")){let e=x.slice(4,-1).trim();return(e.startsWith("'")&&e.endsWith("'")||e.startsWith('"')&&e.endsWith('"'))&&(e=e.slice(1,-1)),e}return x.startsWith("'")&&x.endsWith("'")||x.startsWith('"')&&x.endsWith('"')?x.slice(1,-1):x}function lb(t){return/^data:/i.test(t)}function ub(t){return/^https?:\/\//i.test(t)}function vc(t){if(!t)return;let x=Number.parseInt(t,10);return Number.isFinite(x)&&x>0?x:void 0}async function bb(t,x){let e=Wx.getInstance(x.environment),n=I7(t,x);if(ub(n)&&!N7(n,x))return k("dom-converter","warn",`Skipping remote background image (${n}); remote assets are not supported.`),null;try{let r;if(lb(n)){let o=n.match(/^data:image\/(.+);base64,(.+)$/);if(!o)return k("dom-converter","warn",`Unsupported data URI format for background image: ${t}`),null;let i=Ux(o[2]).slice();r=await e.decodeImage(i.buffer)}else r=await e.loadImage(n);return{info:r,resolvedSrc:n}}catch(r){return k("dom-converter","warn",`Failed to load background image ${t}:`,r instanceof Error?r.message:String(r)),null}}async function Lc(t,x){if(!(!t.backgroundLayers||t.backgroundLayers.length===0))for(let e of t.backgroundLayers){if(e.kind!=="image"||e.imageInfo)continue;let n=cb(e.url);if(!n)continue;let r=await bb(n,x);r&&(e.originalUrl=n,e.resolvedUrl=r.resolvedSrc,e.imageInfo=r.info)}}async function Se(t,x,e,n){let r=t;if(k("dom-converter","debug",`convertDomNode - entering function for node type: ${t.nodeType}, tagName: ${r.tagName||"text node"}`),t.nodeType===t.TEXT_NODE){let p=(t.textContent??"").replace(/\s+/g," ").normalize("NFC"),m=p.trim(),h=sb(t),b=db(t);if(m.length===0){if(!(h&&b))return null;k("dom-converter","debug","convertDomNode - processing text node: (single space)");let L=new $0({display:"inline",color:e.color,fontSize:e.fontSize,lineHeight:j0(e.lineHeight),fontFamily:e.fontFamily,fontWeight:e.fontWeight,fontStyle:e.fontStyle,letterSpacing:e.letterSpacing,wordSpacing:e.wordSpacing,textDecorationLine:e.textDecorationLine,textDecorationColor:e.textDecorationColor,textDecorationStyle:e.textDecorationStyle,textTransform:e.textTransform,transform:e.transform,textShadows:e.textShadows});return new w0(L,[],{textContent:" ",customData:{preserveLeadingSpace:!0,preserveTrailingSpace:!0}})}let g=m,y=p.startsWith(" ")&&h,w=p.endsWith(" ")&&b;y&&(g=" "+g),w&&(g=g+" "),k("dom-converter","debug","convertDomNode - processing text node:",g.substring(0,50)+(g.length>50?"...":""));let S=new $0({display:"inline",color:e.color,fontSize:e.fontSize,lineHeight:j0(e.lineHeight),fontFamily:e.fontFamily,fontWeight:e.fontWeight,fontStyle:e.fontStyle,letterSpacing:e.letterSpacing,wordSpacing:e.wordSpacing,textDecorationLine:e.textDecorationLine,textDecorationColor:e.textDecorationColor,textDecorationStyle:e.textDecorationStyle,textTransform:e.textTransform,transform:e.transform,textShadows:e.textShadows});return new w0(S,[],{textContent:g,customData:{preserveLeadingSpace:y,preserveTrailingSpace:w}})}if(t.nodeType!==t.ELEMENT_NODE)return null;let o=t,a=o.tagName.toLowerCase();if(k("dom-converter","debug",`convertDomNode - processing element: ${a}, with style attr: ${o.getAttribute("style")}`),a==="script"||a==="style")return null;if(a==="img")return await mc(o,x,e,n);if(a==="svg"){let u=xx(o,x,e,n.units,n.rootFontSize);k("dom-converter","debug","convertDomNode - computed style backgroundLayers:",u.backgroundLayers);let p=hc(o,{warn:h=>k("svg-parser","warn",h)});if(!p)return new w0(u,[],{tagName:a});let m=mb(p,o);return new w0(u,[],{tagName:a,intrinsicInlineSize:m.width,intrinsicBlockSize:m.height,customData:{svg:{root:p,intrinsicWidth:m.width,intrinsicHeight:m.height,resourceBaseDir:n?.resourceBaseDir,assetRootDir:n?.assetRootDir}}})}if(a==="br"){let u=new $0({display:"inline",color:e.color,fontSize:e.fontSize,lineHeight:j0(e.lineHeight),fontFamily:e.fontFamily,fontWeight:e.fontWeight,fontStyle:e.fontStyle,textTransform:e.textTransform});return new w0(u,[],{textContent:`
|
|
44
45
|
`})}if(D7.isFormElement(a)){let u=Rc(o,a);if(u){let p=xx(o,x,e,n.units,n.rootFontSize);await Lc(p,n);let m={tagName:a},h=o.getAttribute("id");return h?m.customData={id:h,formControl:u}:m.customData={formControl:u},new w0(p,[],m)}}let i=xx(o,x,e,n.units,n.rootFontSize);await Lc(i,n),k("dom-converter","debug","convertDomNode - computed style backgroundLayers:",i.backgroundLayers),o.tagName.toLowerCase()==="div"&&o.getAttribute("style")?.includes("linear-gradient")&&k("dom-converter","debug","Found div with gradient style!");let s=[],d="",f=o.childNodes;if(!f)return new w0(i,[],{tagName:a});for(let u of Array.from(f)){if(u.nodeType===u.TEXT_NODE){d+=u.textContent??"";continue}if(d){let m=d.replace(/\s+/g," ").normalize("NFC");if(m.trim().length===0&&(m=Sc(s,i)?" ":""),m){let h=m.startsWith(" "),b=m.endsWith(" ");s.push(new w0(new $0({display:"inline",color:i.color,fontSize:i.fontSize,lineHeight:j0(i.lineHeight),fontFamily:i.fontFamily,fontWeight:i.fontWeight,fontStyle:i.fontStyle,letterSpacing:i.letterSpacing,wordSpacing:i.wordSpacing,overflowWrap:i.overflowWrap,whiteSpace:i.whiteSpace,textDecorationLine:i.textDecorationLine,textDecorationColor:i.textDecorationColor,textDecorationStyle:i.textDecorationStyle,textTransform:i.textTransform,transform:i.transform,textShadows:i.textShadows}),[],{textContent:m,customData:{preserveLeadingSpace:h,preserveTrailingSpace:b}}))}d=""}let p=await Se(u,x,i,n);p&&s.push(p)}if(d){let u=d.replace(/\s+/g," ").normalize("NFC");if(u.trim().length===0&&(u=Sc(s,i)?" ":""),u){let p=u.startsWith(" "),m=u.endsWith(" ");s.push(new w0(new $0({display:"inline",color:i.color,fontSize:i.fontSize,lineHeight:j0(i.lineHeight),fontFamily:i.fontFamily,fontWeight:i.fontWeight,fontStyle:i.fontStyle,letterSpacing:i.letterSpacing,wordSpacing:i.wordSpacing,overflowWrap:i.overflowWrap,whiteSpace:i.whiteSpace,textDecorationLine:i.textDecorationLine,textDecorationColor:i.textDecorationColor,textDecorationStyle:i.textDecorationStyle,textTransform:i.textTransform,transform:i.transform,textShadows:i.textShadows}),[],{textContent:u,customData:{preserveLeadingSpace:p,preserveTrailingSpace:m}}))}}let c=o.getAttribute("id"),l={tagName:a};return(a==="td"||a==="th")&&(l.tableColSpan=vc(o.getAttribute("colspan"))??1,l.tableRowSpan=vc(o.getAttribute("rowspan"))??1),c&&(l.customData={...l.customData,id:c}),new w0(i,s,l)}function mb(t,x){let e=t.width,n=t.height;return t.viewBox&&((!e||e<=0)&&(e=t.viewBox.width),(!n||n<=0)&&(n=t.viewBox.height)),(!e||e<=0)&&(e=Cc(x.getAttribute("width"))??100),(!n||n<=0)&&(n=Cc(x.getAttribute("height"))??e),{width:Number.isFinite(e)&&e>0?e:100,height:Number.isFinite(n)&&n>0?n:100}}function Cc(t){if(!t)return;let x=Number.parseFloat(t);return Number.isFinite(x)?x:void 0}function fx(t,x,e){t&&(t.x+=x,t.y+=e)}function pb(t,x,e){t&&(t.image&&(fx(t.image.rect,x,e),fx(t.image.originRect,x,e)),t.gradient&&(fx(t.gradient.rect,x,e),fx(t.gradient.originRect,x,e)))}function bn(t,x,e,n){let r=[t];for(;r.length>0;){let o=r.pop();if(k("layout","trace","offset render tree box",{tagName:o.tagName,textContent:o.textContent,x:o.contentBox.x,y:o.contentBox.y,width:o.contentBox.width,height:o.contentBox.height}),fx(o.contentBox,x,e),fx(o.paddingBox,x,e),fx(o.borderBox,x,e),fx(o.visualOverflow,x,e),o.clipPath&&o.clipPath.points)for(let a of o.clipPath.points)a.x+=x,a.y+=e;o.markerRect&&fx(o.markerRect,x,e),pb(o.background,x,e);for(let a of o.links)fx(a.rect,x,e);for(let a of o.textRuns)a.lineMatrix&&(a.lineMatrix.e+=x,a.lineMatrix.f+=e);for(let a of o.children)r.push(a)}}function Pc(t,x){let{pageHeight:e,margins:n,headerHeightPx:r=0,footerHeightPx:o=0}=x,a=Number.isFinite(e)&&e>0?e:1,i=Number.isFinite(n.top)&&n.top>0?n.top:0,s=Number.isFinite(n.bottom)&&n.bottom>0?n.bottom:0,d=i+r,f=s+o,c=d+f,l=a-c>0?a-c:a,u=b=>{if(!Number.isFinite(b))return b;if(b<=0)return b+d;let g=Math.floor(b/l),y=b-g*l;return g*a+d+y},p=b=>{b&&(b.y=u(b.y))},m=b=>{b&&(b.image&&(p(b.image.rect),p(b.image.originRect)),b.gradient&&(p(b.gradient.rect),p(b.gradient.originRect)))},h=[t];for(;h.length>0;){let b=h.pop();if(p(b.contentBox),p(b.paddingBox),p(b.borderBox),p(b.visualOverflow),b.clipPath&&b.clipPath.points)for(let g of b.clipPath.points)g.y=u(g.y);b.markerRect&&p(b.markerRect),m(b.background);for(let g of b.links)p(g.rect);for(let g of b.textRuns)g.lineMatrix&&(g.lineMatrix.f=u(g.lineMatrix.f));for(let g of b.children)h.push(g)}}var _6=class{constructor(x){this.fontRegistry=x;this.rawTableAccessors=new WeakMap}async resolve(x,e,n){let r=await this.fontRegistry.ensureFontResource(x,e,n);return this.toUnifiedFont(r,x,e,n)??this.createFallbackFont(x,e,n)}resolveSync(x,e,n){let r=this.fontRegistry.ensureFontResourceSync(x,e,n);return this.toUnifiedFont(r,x,e,n)}createFallbackFont(x,e,n){return{metrics:{metrics:{unitsPerEm:1e3,ascender:800,descender:-200,lineGap:0,capHeight:700,xHeight:500},glyphMetrics:new Map([[0,{advanceWidth:500,leftSideBearing:0}]]),cmap:{getGlyphId:()=>0,hasCodePoint:()=>!1,unicodeMap:new Map}},program:{sourceFormat:"ttf",unitsPerEm:1e3,glyphCount:1},css:{family:x,weight:e??400,style:n??"normal"}}}toUnifiedFont(x,e,n,r){let o=x.metrics;if(!o)return;let a=this.lookupRawTableAccessor(x);return{metrics:{metrics:o.metrics,glyphMetrics:o.glyphMetrics,cmap:o.cmap,headBBox:o.headBBox,kerning:o.kerning},program:{sourceFormat:"ttf",unitsPerEm:o.metrics.unitsPerEm,glyphCount:o.glyphMetrics.size,getGlyphOutline:o.getGlyphOutline,getRawTableData:a},css:{family:e,weight:n??400,style:r??"normal"}}}lookupRawTableAccessor(x){let e=x.embedded?.subset;if(!e||e.byteLength<12)return;let n=this.rawTableAccessors.get(x);if(n)return n;let r=hb(e);return this.rawTableAccessors.set(x,r),r}};function hb(t){let x=gb(t);return e=>x.get(e)??null}function gb(t){let x=new Map;if(t.byteLength<12)return x;let e=new DataView(t.buffer,t.byteOffset,t.byteLength),n=e.getUint16(4,!1);for(let r=0;r<n;r++){let o=12+r*16;if(o+16>t.byteLength)break;let a=String.fromCharCode(t[o],t[o+1],t[o+2],t[o+3]),i=e.getUint32(o+8,!1),s=e.getUint32(o+12,!1);i+s>t.byteLength||x.set(a,t.subarray(i,i+s))}return x}function yb(t){return!Number.isFinite(t)||t<=0?0:t>=1?1:t}function Fc(t){return!Number.isFinite(t)||t<=0?0:Math.ceil(t)}function Bc(t,x){let e=t.width+x*2,n=t.height+x*2;return e<=0||n<=0?{x:t.x+t.width/2,y:t.y+t.height/2,width:0,height:0}:{x:t.x-x,y:t.y-x,width:e,height:n}}function mn(t,x){return t>x?t:x}function wb(t,x,e,n){if(t<e.x||x<e.y||t>e.x+e.width||x>e.y+e.height)return!1;let r=mn(n.topLeft.x,n.bottomLeft.x),o=mn(n.topRight.x,n.bottomRight.x),a=mn(n.topLeft.y,n.topRight.y),i=mn(n.bottomLeft.y,n.bottomRight.y);if(t>=e.x+r&&t<=e.x+e.width-o||x>=e.y+a&&x<=e.y+e.height-i)return!0;if(t<e.x+n.topLeft.x&&x<e.y+n.topLeft.y&&n.topLeft.x>0&&n.topLeft.y>0){let s=e.x+n.topLeft.x,d=e.y+n.topLeft.y,f=(t-s)/n.topLeft.x,c=(x-d)/n.topLeft.y;return f*f+c*c<=1}if(t>e.x+e.width-n.topRight.x&&x<e.y+n.topRight.y&&n.topRight.x>0&&n.topRight.y>0){let s=e.x+e.width-n.topRight.x,d=e.y+n.topRight.y,f=(t-s)/n.topRight.x,c=(x-d)/n.topRight.y;return f*f+c*c<=1}if(t>e.x+e.width-n.bottomRight.x&&x>e.y+e.height-n.bottomRight.y&&n.bottomRight.x>0&&n.bottomRight.y>0){let s=e.x+e.width-n.bottomRight.x,d=e.y+e.height-n.bottomRight.y,f=(t-s)/n.bottomRight.x,c=(x-d)/n.bottomRight.y;return f*f+c*c<=1}if(t<e.x+n.bottomLeft.x&&x>e.y+e.height-n.bottomLeft.y&&n.bottomLeft.x>0&&n.bottomLeft.y>0){let s=e.x+n.bottomLeft.x,d=e.y+e.height-n.bottomLeft.y,f=(t-s)/n.bottomLeft.x,c=(x-d)/n.bottomLeft.y;return f*f+c*c<=1}return!1}function Rb(t){let x=t>0?t:1e-4,e=Math.max(1,Math.ceil(x*3)),n=e*2+1,r=new Float32Array(n),o=1/(Math.sqrt(2*Math.PI)*x),a=2*x*x,i=0;for(let s=-e;s<=e;s++){let d=o*Math.exp(-(s*s)/a);r[s+e]=d,i+=d}return{kernel:r,radius:e,sum:i}}function Sb(t,x,e,n){if(n<=0)return t;let{kernel:r,radius:o,sum:a}=Rb(n),i=new Float32Array(x*e);for(let d=0;d<e;d++){let f=d*x;for(let c=0;c<x;c++){let l=0,u=0;for(let p=-o;p<=o;p++){let m=Math.min(x-1,Math.max(0,c+p)),h=r[p+o];l+=t[f+m]*h,u+=h}i[f+c]=l/(u||a)}}let s=new Uint8Array(x*e);for(let d=0;d<x;d++)for(let f=0;f<e;f++){let c=0,l=0;for(let p=-o;p<=o;p++){let m=Math.min(e-1,Math.max(0,f+p)),h=r[p+o];c+=i[m*x+d]*h,l+=h}let u=c/(l||a);s[f*x+d]=u<0?0:u>255?255:u}return s}function Ac(t,x,e,n,r){let o=Math.max(0,n),a=Bc(t,r),i=vb(x,r),s=Bc(a,o),d=Fc(s.width),f=Fc(s.height);if(d===0||f===0)return null;let c=new Uint8Array(d*f),l={x:a.x-s.x,y:a.y-s.y,width:a.width,height:a.height};for(let R=0;R<f;R++){let L=R+.5;for(let T=0;T<d;T++){let N=T+.5,P=wb(N,L,l,i);c[R*d+T]=P?255:0}}let u=o>0?Math.max(.5,o/2):0,p=Sb(c,d,f,u),[m,h,b]=Lb(e.r,e.g,e.b),g=yb(e.a??1),y=new Uint8Array(d*f*4),w=0;for(let R=0;R<p.length;R++){y[w++]=m,y[w++]=h,y[w++]=b;let L=Math.round(p[R]*g);y[w++]=L<0?0:L>255?255:L}return{image:{src:`internal:shadow:${Math.random().toString(36).slice(2)}`,width:d,height:f,format:"png",channels:4,bitsPerComponent:8,data:y.buffer},drawRect:s}}function vb(t,x){let e=n=>Number.isFinite(n)&&n>0?n:0;return{topLeft:{x:e(t.topLeft.x+x),y:e(t.topLeft.y+x)},topRight:{x:e(t.topRight.x+x),y:e(t.topRight.y+x)},bottomRight:{x:e(t.bottomRight.x+x),y:e(t.bottomRight.y+x)},bottomLeft:{x:e(t.bottomLeft.x+x),y:e(t.bottomLeft.y+x)}}}function O7(t){let x=Math.min(1,Math.max(0,t>1?t/255:t));return(x<=.04045?x/12.92:Math.pow((x+.055)/1.055,2.4))*255}function W7(t){let x=Math.min(1,Math.max(0,t>1?t/255:t)),e=x<=.0031308?12.92*x:1.055*Math.pow(x,1/2.4)-.055;return Math.round(Math.min(255,Math.max(0,e*255)))}function Lb(t,x,e){let n=O7(t)/255,r=O7(x)/255,o=O7(e)/255,a=Math.max(n,r,o),i=Math.min(n,r,o),s=(n+r+o)/3,d=a-i,f=Math.min(1,d*1.08),c=d>0?f/d:1,l=s+(n-s)*c,u=s+(r-s)*c,p=s+(o-s)*c;return[W7(l),W7(u),W7(p)]}function ve(t){return{topLeft:{x:t.topLeft.x,y:t.topLeft.y},topRight:{x:t.topRight.x,y:t.topRight.y},bottomRight:{x:t.bottomRight.x,y:t.bottomRight.y},bottomLeft:{x:t.bottomLeft.x,y:t.bottomLeft.y}}}function Y6(t,x,e,n,r){return{topLeft:{x:Hx(t.topLeft.x-x),y:Hx(t.topLeft.y-r)},topRight:{x:Hx(t.topRight.x-x),y:Hx(t.topRight.y-e)},bottomRight:{x:Hx(t.bottomRight.x-n),y:Hx(t.bottomRight.y-e)},bottomLeft:{x:Hx(t.bottomLeft.x-n),y:Hx(t.bottomLeft.y-r)}}}function U7(t,x){let e=ve(t);return e.topLeft.x=ex(e.topLeft.x+x),e.topLeft.y=ex(e.topLeft.y+x),e.topRight.x=ex(e.topRight.x+x),e.topRight.y=ex(e.topRight.y+x),e.bottomRight.x=ex(e.bottomRight.x+x),e.bottomRight.y=ex(e.bottomRight.y+x),e.bottomLeft.x=ex(e.bottomLeft.x+x),e.bottomLeft.y=ex(e.bottomLeft.y+x),e}function Hx(t){return Number.isFinite(t)&&t>0?t:0}function ex(t){return Number.isFinite(t)?t<0?0:t:0}function z7(t,x,e){for(let n of x)if(n.boxShadows?.length)for(let r of n.boxShadows)r.inset===e&&Cb(r)&&(e?Pb(t,n,r):Tb(t,n,r))}function Cb(t){return H7(t.color.a??1)>0}function Tb(t,x,e){let n=kc(x.borderBox,e.offsetX,e.offsetY),r=ve(x.borderRadius),o=ex(e.blur),a=e.spread;if(o>0){let i=Ac(n,r,e.color,o,a);if(i){t.drawShadowImage(i.image,i.drawRect);return}}Mc(t,{mode:"outer",baseRect:n,baseRadius:r,color:e.color,blur:o,spread:a})}function Pb(t,x,e){let n=x.paddingBox??x.contentBox;if(!n)return;let r=kc(n,e.offsetX,e.offsetY),o=Y6(ve(x.borderRadius),x.border.top,x.border.right,x.border.bottom,x.border.left),a=ex(e.blur),i=e.spread;if(a===0&&i===0){t.fillRoundedRect(r,o,e.color);return}Mc(t,{mode:"inset",baseRect:r,baseRadius:o,color:e.color,blur:a,spread:i})}function Mc(t,x){let e=Fb(x);if(e.length){if(x.mode==="outer"){Bb(t,x.baseRect,x.baseRadius,e);return}Ab(t,x.baseRect,x.baseRadius,e)}}function Fb(t){let{mode:x,color:e,blur:n,spread:r}=t,o=n>0?Math.max(2,Math.ceil(n/2)):1,a=Mb(o),i=H7(e.a??1),s=[];for(let d=0;d<o;d++){let f=o===1?0:x==="outer"?d/(o-1):(d+1)/o,c=r+n*f,l=a[d]??0;l<=0||s.push({expansion:c,color:{r:e.r,g:e.g,b:e.b,a:H7(i*l)}})}return s}function Bb(t,x,e,n){for(let r of n){let o=Ic(x,r.expansion);if(o.width<=0||o.height<=0)continue;let a=U7(e,r.expansion);t.fillRoundedRect(o,a,r.color)}}function Ab(t,x,e,n){for(let r of n){let o=Math.max(0,r.expansion),a=Ic(x,-o);if(a.width<=0||a.height<=0)continue;let i=ve(e),s=U7(e,-o);t.fillRoundedRectDifference(x,i,a,s,r.color)}}function kc(t,x,e){return{x:t.x+x,y:t.y+e,width:t.width,height:t.height}}function Ic(t,x){let e=t.width+x*2,n=t.height+x*2;return e<=0||n<=0?{x:t.x+t.width/2,y:t.y+t.height/2,width:0,height:0}:{x:t.x-x,y:t.y-x,width:e,height:n}}function Mb(t){if(t<=1)return[1];let x=[],e=0;for(let n=0;n<t;n++){let r=t-n;x.push(r),e+=r}return x.map(n=>n/e)}function H7(t){return Number.isFinite(t)?t<=0?0:t>=1?1:t:1}function Oc(t){return t?new G7(t).parse():[]}var G7=class{constructor(x){this.index=0;this.source=x}parse(){let x=[],e=null,n=0,r=0,o=0,a=0,i=null,s=null,d=null,f=null;for(;this.skipSeparators(),!this.isDone();){let c=this.peekChar();if(c!==null&&Dc(c))e=c,this.index+=1;else if(!e)break;switch(e){case"M":case"m":{let l=e==="m",u=this.readCoordinatePair();if(!u)return x;for(n=l?n+u.x:u.x,r=l?r+u.y:u.y,o=n,a=r,x.push({type:"M",x:n,y:r}),i=s=null,d=f=null;;){this.skipSeparators();let p=this.peekChar();if(p===null||Dc(p))break;let m=this.readCoordinatePair();if(!m)return x;n=l?n+m.x:m.x,r=l?r+m.y:m.y,x.push({type:"L",x:n,y:r})}break}case"L":case"l":{let l=e==="l";for(;;){let u=this.readCoordinatePair();if(!u)break;n=l?n+u.x:u.x,r=l?r+u.y:u.y,x.push({type:"L",x:n,y:r})}i=s=null,d=f=null;break}case"H":case"h":{let l=e==="h";for(;;){let u=this.readNumber();if(u===null)break;n=l?n+u:u,x.push({type:"L",x:n,y:r})}i=s=null,d=f=null;break}case"V":case"v":{let l=e==="v";for(;;){let u=this.readNumber();if(u===null)break;r=l?r+u:u,x.push({type:"L",x:n,y:r})}i=s=null,d=f=null;break}case"C":case"c":{let l=e==="c";for(;;){let u=this.readCoordinatePair(),p=this.readCoordinatePair(),m=this.readCoordinatePair();if(!u||!p||!m)break;let h=l?n+u.x:u.x,b=l?r+u.y:u.y,g=l?n+p.x:p.x,y=l?r+p.y:p.y;n=l?n+m.x:m.x,r=l?r+m.y:m.y,x.push({type:"C",x1:h,y1:b,x2:g,y2:y,x:n,y:r}),i=g,s=y,d=f=null}break}case"S":case"s":{let l=e==="s";for(;;){let u=this.readCoordinatePair(),p=this.readCoordinatePair();if(!u||!p)break;let m=n,h=r;i!==null&&s!==null&&(m=n*2-i,h=r*2-s);let b=l?n+u.x:u.x,g=l?r+u.y:u.y;n=l?n+p.x:p.x,r=l?r+p.y:p.y,x.push({type:"C",x1:m,y1:h,x2:b,y2:g,x:n,y:r}),i=b,s=g,d=f=null}break}case"Q":case"q":{let l=e==="q";for(;;){let u=this.readCoordinatePair(),p=this.readCoordinatePair();if(!u||!p)break;let m=l?n+u.x:u.x,h=l?r+u.y:u.y,b=l?n+p.x:p.x,g=l?r+p.y:p.y,y=Nc(n,r,m,h,b,g);x.push(y),n=b,r=g,i=y.x2,s=y.y2,d=m,f=h}break}case"T":case"t":{let l=e==="t";for(;;){let u=this.readCoordinatePair();if(!u)break;let p=n,m=r;d!==null&&f!==null&&(p=n*2-d,m=r*2-f);let h=l?n+u.x:u.x,b=l?r+u.y:u.y,g=Nc(n,r,p,m,h,b);x.push(g),n=h,r=b,i=g.x2,s=g.y2,d=p,f=m}break}case"A":case"a":{let l=e==="a";for(;;){let u=this.readNumber(),p=this.readNumber(),m=this.readNumber(),h=this.readFlag(),b=this.readFlag(),g=this.readCoordinatePair();if(u===null||p===null||m===null||h===null||b===null||!g)break;let y=l?n+g.x:g.x,w=l?r+g.y:g.y,S=kb(n,r,u,p,m,h===1,b===1,y,w);if(S.length===0)(n!==y||r!==w)&&x.push({type:"L",x:y,y:w});else for(let R of S)x.push({type:"C",x1:R[0],y1:R[1],x2:R[2],y2:R[3],x:R[4],y:R[5]});n=y,r=w,i=S.length>0?S[S.length-1][2]:null,s=S.length>0?S[S.length-1][3]:null,d=f=null}break}case"Z":case"z":{(n!==o||r!==a)&&x.push({type:"L",x:o,y:a}),x.push({type:"Z"}),n=o,r=a,i=s=null,d=f=null;break}default:return x}}return x}readCoordinatePair(){let x=this.readNumber(),e=this.readNumber();return x===null||e===null?null:{x,y:e}}readFlag(){if(this.skipSeparators(),this.isDone())return null;let x=this.source[this.index];if(x==="0"||x==="1")return this.index+=1,x==="1"?1:0;let e=this.readNumber();return e===null?null:e===0?0:1}readNumber(){if(this.skipSeparators(),this.isDone())return null;let e=this.source.slice(this.index).match(/^[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/);if(!e)return null;this.index+=e[0].length;let n=Number.parseFloat(e[0]);return Number.isFinite(n)?n:null}skipSeparators(){for(;!this.isDone();){let x=this.source[this.index];if(x===","||x===" "||x===" "||x===`
|
|
45
46
|
`||x==="\r"){this.index+=1;continue}break}}peekChar(){return this.isDone()?null:this.source[this.index]}isDone(){return this.index>=this.source.length}};function Nc(t,x,e,n,r,o){let a=t+.6666666666666666*(e-t),i=x+2/3*(n-x),s=r+2/3*(e-r),d=o+2/3*(n-o);return{type:"C",x1:a,y1:i,x2:s,y2:d,x:r,y:o}}function kb(t,x,e,n,r,o,a,i,s){let d=[];if(t===i&&x===s||(e=Math.abs(e),n=Math.abs(n),e===0||n===0))return d;let f=r*Math.PI/180,c=Math.cos(f),l=Math.sin(f),u=(t-i)/2,p=(x-s)/2,m=c*u+l*p,h=-l*u+c*p,b=e*e,g=n*n,y=m*m,w=h*h,S=y/b+w/g;if(S>1){let C=Math.sqrt(S);e*=C,n*=C,b=e*e,g=n*n}let R=o===a?-1:1,L=(b*g-b*w-g*y)/(b*w+g*y),T=R*Math.sqrt(Math.max(0,L)),N=T*e*h/n,P=-T*n*m/e,E=c*N-l*P+(t+i)/2,B=l*N+c*P+(x+s)/2,A=Ec(1,0,(m-N)/e,(h-P)/n),F=Ec((m-N)/e,(h-P)/n,(-m-N)/e,(-h-P)/n);!a&&F>0?F-=2*Math.PI:a&&F<0&&(F+=2*Math.PI);let D=Math.ceil(Math.abs(F)/(Math.PI/2)),O=F/D,U=4/3*Math.tan(O/4),Y=A,q=t,X=x;for(let C=0;C<D;C+=1){let j=Y+O,t0=Math.sin(Y),Z=Math.cos(Y),J=Math.sin(j),Q=Math.cos(j),x0=E+e*c*Q-n*l*J,l0=B+e*l*Q+n*c*J,F0=-e*c*t0-n*l*Z,c0=-e*l*t0+n*c*Z,K=-e*c*J-n*l*Q,e0=-e*l*J+n*c*Q,n0=q+U*F0,V=X+U*c0,s0=x0-U*K,f0=l0-U*e0;d.push([n0,V,s0,f0,x0,l0]),q=x0,X=l0,Y=j}return d}function Ec(t,x,e,n){let r=t*e+x*n,o=Math.sqrt((t*t+x*x)*(e*e+n*n)),a=Ib(-1,1,o===0?0:r/o);return(t*n-x*e<0?-1:1)*Math.acos(a)}function Dc(t){return/[a-zA-Z]/.test(t)}function Ib(t,x,e){return e<t?t:e>x?x:e}var pn=.5522847498307936;function Wc(t,x,e,n){return[{type:"M",x:t,y:x},{type:"L",x:t+e,y:x},{type:"L",x:t+e,y:x+n},{type:"L",x:t,y:x+n},{type:"Z"}]}function Uc(t,x,e,n,r,o){let a=t+e,i=x+n,s=r*pn,d=o*pn;return[{type:"M",x:t+r,y:x},{type:"L",x:a-r,y:x},{type:"C",x1:a-r+s,y1:x,x2:a,y2:x+o-d,x:a,y:x+o},{type:"L",x:a,y:i-o},{type:"C",x1:a,y1:i-o+d,x2:a-r+s,y2:i,x:a-r,y:i},{type:"L",x:t+r,y:i},{type:"C",x1:t+r-s,y1:i,x2:t,y2:i-o+d,x:t,y:i-o},{type:"L",x:t,y:x+o},{type:"C",x1:t,y1:x+o-d,x2:t+r-s,y2:x,x:t+r,y:x},{type:"Z"}]}function j7(t,x,e,n){let r=e*pn,o=n*pn;return[{type:"M",x:t,y:x-n},{type:"C",x1:t+r,y1:x-n,x2:t+e,y2:x-o,x:t+e,y:x},{type:"C",x1:t+e,y1:x+o,x2:t+r,y2:x+n,x:t,y:x+n},{type:"C",x1:t-r,y1:x+n,x2:t-e,y2:x+o,x:t-e,y:x},{type:"C",x1:t-e,y1:x-o,x2:t-r,y2:x-n,x:t,y:x-n},{type:"Z"}]}function $7(t,x){let e=[];for(let n of t){let r=v0(n.x,n.y,x);if(!r)return[];e.push(r)}return e}function Le(t,x){let e=[];for(let n of t)switch(n.type){case"M":{let r=v0(n.x,n.y,x);if(!r)return null;e.push({type:"moveTo",x:r.x,y:r.y});break}case"L":{let r=v0(n.x,n.y,x);if(!r)return null;e.push({type:"lineTo",x:r.x,y:r.y});break}case"C":{let r=v0(n.x1,n.y1,x),o=v0(n.x2,n.y2,x),a=v0(n.x,n.y,x);if(!r||!o||!a)return null;e.push({type:"curveTo",x1:r.x,y1:r.y,x2:o.x,y2:o.y,x:a.x,y:a.y});break}case"Z":e.push({type:"closePath"});break;default:return null}return e}function v0(t,x,e){if(!Number.isFinite(t)||!Number.isFinite(x))return null;let n=Nb(e,t,x);return!Number.isFinite(n.x)||!Number.isFinite(n.y)?null:n}function Nb(t,x,e){let n=d6(t.transform,x,e);return d6(t.viewportMatrix,n.x,n.y)}function tx(t,x){let e={...t},n=x.attributes??{};if(n.opacity!==void 0){let r=V7(n.opacity);r!==void 0&&(e.opacity=Ce(e.opacity*r))}if(n.fill!==void 0){let r=n.fill.trim();e.fill=!r||r==="none"?void 0:r}if(n["fill-opacity"]!==void 0){let r=V7(n["fill-opacity"]);r!==void 0&&(e.fillOpacity=Ce(r))}if(n.stroke!==void 0){let r=n.stroke.trim();e.stroke=!r||r==="none"?void 0:r}if(n["stroke-opacity"]!==void 0){let r=V7(n["stroke-opacity"]);r!==void 0&&(e.strokeOpacity=Ce(r))}if(n["stroke-width"]!==void 0){let r=hn(n["stroke-width"]);r!==void 0&&(e.strokeWidth=r)}if(n["stroke-linecap"]!==void 0){let r=Eb(n["stroke-linecap"]);r&&(e.strokeLinecap=r)}if(n["stroke-linejoin"]!==void 0){let r=Db(n["stroke-linejoin"]);r&&(e.strokeLinejoin=r)}if(n["stroke-dasharray"]!==void 0){let r=Ub(n["stroke-dasharray"]);r&&(e.strokeDashArray=r)}if(n["stroke-dashoffset"]!==void 0){let r=hn(n["stroke-dashoffset"]);r!==void 0&&(e.strokeDashOffset=r)}if(n["fill-rule"]!==void 0){let r=Ob(n["fill-rule"]);r&&(e.fillRule=r)}if(n["font-size"]!==void 0){let r=hn(n["font-size"]);r!==void 0&&(e.fontSize=r)}if(n["font-family"]!==void 0){let r=n["font-family"].trim();r&&(e.fontFamily=r)}if(n["text-anchor"]!==void 0){let r=Wb(n["text-anchor"]);r&&(e.textAnchor=r)}return e}function Hc(){return{fill:"#000000",stroke:void 0,strokeWidth:1,strokeLinecap:"butt",strokeLinejoin:"miter",strokeDashArray:void 0,strokeDashOffset:0,fillRule:"nonzero",opacity:1,fillOpacity:1,strokeOpacity:1,fontSize:16,fontFamily:void 0,textAnchor:"start"}}function zx(t,x){if(!t||t==="none")return;let e=O0(t);if(!e)return;let n=e.a??1;return{r:e.r,g:e.g,b:e.b,a:Ce(n*x)}}function V7(t){let x=hn(t);if(x!==void 0)return Ce(x)}function hn(t){if(!t)return;let x=t.trim();if(!x)return;let e=Number.parseFloat(x);if(Number.isFinite(e))return e}function Eb(t){let x=t.trim().toLowerCase();if(x==="butt"||x==="round"||x==="square")return x}function Db(t){let x=t.trim().toLowerCase();if(x==="miter"||x==="round"||x==="bevel")return x}function Ob(t){let x=t.trim().toLowerCase();if(x==="nonzero"||x==="evenodd")return x}function Wb(t){let x=t.trim().toLowerCase();if(x==="start"||x==="middle"||x==="end")return x}function Ce(t){return!Number.isFinite(t)||t<=0?0:t>=1?1:t}function Ub(t){if(!t)return;let x=t.trim();if(!x||x==="none")return;let e=x.split(/[\s,]+/).map(n=>Number.parseFloat(n)).filter(n=>Number.isFinite(n)&&n>=0);if(e.length!==0)return e}function Hb(t){if(typeof t!="object"||t===null)return!1;let x=t;return x.type==="linear"&&Array.isArray(x.stops)}function zb(t){if(typeof t!="object"||t===null)return!1;let x=t;return x.type==="radial"&&typeof x.r=="number"}function Gc(t,x,e){let n=Number.isFinite(t.width??NaN)?t.width??0:0,r=Number.isFinite(t.height??NaN)?t.height??0:0;if(n<=0||r<=0)return;let o=Number.isFinite(t.x??NaN)?t.x??0:0,a=Number.isFinite(t.y??NaN)?t.y??0:0,i=t.rx??t.ry??0,s=t.ry??t.rx??0;Number.isFinite(i)||(i=0),Number.isFinite(s)||(s=0),i=zc(i,n/2),s=zc(s,r/2);let d=i>0||s>0?Uc(o,a,n,r,i,s):Wc(o,a,n,r),f=_7(x.fill,e);if(f){let l=v0(o,a,e),u=v0(o+n,a+r,e);if(l&&u){let p={x:l.x,y:l.y,width:u.x-l.x,height:u.y-l.y};f.type==="radial"?i>0||s>0?e.painter.fillRoundedRect(p,{topLeft:{x:i,y:s},topRight:{x:i,y:s},bottomRight:{x:i,y:s},bottomLeft:{x:i,y:s}},f):e.painter.fillRect(p,f):i>0||s>0?e.painter.fillRoundedRect(p,{topLeft:{x:i,y:s},topRight:{x:i,y:s},bottomRight:{x:i,y:s},bottomLeft:{x:i,y:s}},f):e.painter.fillRect(p,f);return}}let c=Le(d,e);!c||c.length===0||gn(c,x,e,x.fillRule)}function jc(t,x,e){let n=Number.isFinite(t.r??NaN)?t.r??0:0;if(n<=0)return;let r=Number.isFinite(t.cx??NaN)?t.cx??0:0,o=Number.isFinite(t.cy??NaN)?t.cy??0:0,a=_7(x.fill,e);if(a){let d=v0(r,o,e),f=v0(r+n,o,e);if(d&&f){let c=Math.sqrt((f.x-d.x)**2+(f.y-d.y)**2),l={x:d.x-c,y:d.y-c,width:c*2,height:c*2},u={topLeft:{x:c,y:c},topRight:{x:c,y:c},bottomRight:{x:c,y:c},bottomLeft:{x:c,y:c}};a.type,e.painter.fillRoundedRect(l,u,a);return}}let i=j7(r,o,n,n),s=Le(i,e);!s||s.length===0||gn(s,x,e,x.fillRule)}function $c(t,x,e){let n=Number.isFinite(t.rx??NaN)?t.rx??0:0,r=Number.isFinite(t.ry??NaN)?t.ry??0:0;if(n<=0||r<=0)return;let o=Number.isFinite(t.cx??NaN)?t.cx??0:0,a=Number.isFinite(t.cy??NaN)?t.cy??0:0,i=j7(o,a,n,r),s=Le(i,e);!s||s.length===0||gn(s,x,e,x.fillRule)}function zc(t,x){return!Number.isFinite(t)||t<=0?0:t>x?x:t}function Vc(t,x,e){let n=t.points??[];if(n.length<2)return;let r=$7(n,e);if(r.length<2)return;let o=zx(x.fill,x.opacity*x.fillOpacity);o&&e.painter.fillPolygon(r,o,!0);let a=zx(x.stroke,x.opacity*x.strokeOpacity);a&&e.painter.strokePolyline(r,a,{...yn(x,e),close:!0})}function _c(t,x,e){let n=t.points??[];if(n.length<2)return;let r=$7(n,e);if(r.length<2)return;let o=zx(x.stroke,x.opacity*x.strokeOpacity);o&&e.painter.strokePolyline(r,o,{...yn(x,e),close:!1})}function Yc(t,x,e){let n=zx(x.stroke,x.opacity*x.strokeOpacity);if(!n)return;let r=v0(t.x1??0,t.y1??0,e),o=v0(t.x2??0,t.y2??0,e);if(!r||!o)return;let a=[r,o];e.painter.strokePolyline(a,n,{...yn(x,e),close:!1})}function Xc(t,x,e){let n=Oc(t.d);if(n.length===0)return;let r=Le(n,e);!r||r.length===0||gn(r,x,e,x.fillRule)}function gn(t,x,e,n){if(t.length===0)return;let r=_7(x.fill,e);if(r){e.painter.fillPathWithGradient(t,r,{fillRule:n});return}let o=zx(x.fill,x.opacity*x.fillOpacity);o&&e.painter.fillPath(t,o,{fillRule:n??x.fillRule});let a=zx(x.stroke,x.opacity*x.strokeOpacity);a&&e.painter.strokePath(t,a,yn(x,e))}async function qc(t,x,e){let n=zx(x.fill,x.opacity*x.fillOpacity);if(!n)return;let r=t.fontSize??x.fontSize;if(!Number.isFinite(r)||r<=0)return;let o=t.textAnchor??x.textAnchor??"start",a=W0(e.viewportMatrix,e.transform),i=Number.isFinite(t.x??NaN)?t.x??0:0,s=Number.isFinite(t.y??NaN)?t.y??0:0,d=d6(a,i,s),f={x:a.a,y:a.b},c=Gb(t.text,r),l=o==="middle"?.5:o==="end"?1:0,u=d.x,p=d.y;l!==0&&(f.x!==0||f.y!==0)&&(u-=f.x*c*l,p-=f.y*c*l);let m={r:n.r,g:n.g,b:n.b,a:i7(n.a??1)},h=t.fontFamily??x.fontFamily??"Helvetica";await e.painter.drawTextRun({text:t.text,fontFamily:h,fontSize:r,fill:m,lineMatrix:{a:a.a,b:a.b,c:a.c,d:a.d,e:u,f:p}})}function Gb(t,x){return t?t.length*x*.6:0}function _7(t,x){if(Hb(t)||zb(t))return t;if(typeof t=="string"){let n=t.trim().match(/^url\(\s*#([^)\s]+)\s*\)$/i);if(n&&x){let r=x.defs;if(r){let o=r.get(n[1]);if(o&&(o.type==="lineargradient"||o.type==="radialgradient"))return o.type==="lineargradient"?jb(o,x):$b(o,x)}}return yx(t)}return null}function jb(t,x){let e=t.x1??0,n=t.y1??0,r=t.x2??1,o=t.y2??0,a=(t.stops??[]).map(m=>({color:m.color,position:m.offset}));if((t.gradientUnits==="userSpaceOnUse"?"userSpace":"ratio")==="userSpace"&&x){let m=v0(e,n,x),h=v0(r,o,x);if(m&&h)return{type:"linear",direction:"to right",stops:a,coords:{x1:m.x,y1:m.y,x2:h.x,y2:h.y,units:"userSpace"}}}let s={x:e,y:n},d={x:r,y:o},f=t.attributes&&(t.attributes.gradientTransform??t.attributes.gradienttransform);if(f){let m=hx(f)||void 0;m&&(s=d6(m,s.x,s.y),d=d6(m,d.x,d.y))}let c=d.x-s.x,l=d.y-s.y;return{type:"linear",direction:`${(Math.atan2(l,c)*180/Math.PI).toFixed(2)}deg`,stops:a,coords:{x1:s.x,y1:s.y,x2:d.x,y2:d.y,units:"ratio"}}}function $b(t,x){let e=t.cx??.5,n=t.cy??.5,r=t.r??.5,o=t.fx,a=t.fy,i=(t.stops??[]).map(c=>({color:c.color,position:c.offset}));if((t.gradientUnits==="userSpaceOnUse"?"userSpace":"ratio")==="userSpace"&&x){let c=v0(e,n,x),l=o!==void 0&&a!==void 0?v0(o,a,x):void 0,u=(()=>{let p=v0(e+r,n,x);if(c&&p){let m=p.x-c.x,h=p.y-c.y;return Math.sqrt(m*m+h*h)}})();if(c&&u!==void 0){let p={type:"radial",cx:c.x,cy:c.y,r:u,stops:i,coordsUnits:"userSpace"};return l&&(p.fx=l.x,p.fy=l.y),p}}let d={type:"radial",cx:e,cy:n,r,stops:i};o!==void 0&&a!==void 0&&(d.fx=o,d.fy=a);let f=t.attributes&&(t.attributes.gradientTransform??t.attributes.gradienttransform);if(f){let c=hx(f)||void 0;c&&(d.transform={a:c.a,b:c.b,c:c.c,d:c.d,e:c.e,f:c.f})}return d}function yn(t,x){let e=(t.strokeWidth??1)*x.strokeScale,n={lineWidth:e>0?e:void 0,lineCap:t.strokeLinecap,lineJoin:t.strokeLinejoin};if(t.strokeDashArray&&t.strokeDashArray.length>0){let r=t.strokeDashArray.map(a=>a*x.strokeScale),o=(t.strokeDashOffset??0)*x.strokeScale;n.dash={pattern:r,phase:o}}return n}function Kc(t){let x={align:"xMidYMid",meetOrSlice:"meet"};if(!t)return x;let e=t.trim().split(/[\s,]+/).filter(Boolean);if(e.length===0)return x;let n={none:"none",xminymin:"xMinYMin",xmidymin:"xMidYMin",xmaxymin:"xMaxYMin",xminymid:"xMinYMid",xmidymid:"xMidYMid",xmaxymid:"xMaxYMid",xminymax:"xMinYMax",xmidymax:"xMidYMax",xmaxymax:"xMaxYMax"},r=0,o=e[r]?.toLowerCase()??"";o==="defer"&&(r+=1,o=e[r]?.toLowerCase()??""),r+=1;let a=n[o]??x.align;if(a==="none")return{align:"none",meetOrSlice:"meet"};let i="meet";for(;r<e.length;r+=1){let s=e[r]?.toLowerCase();if(s==="meet"){i="meet";break}if(s==="slice"){i="slice";break}}return n[o]||(a=x.align),{align:a,meetOrSlice:i}}function Zc(t){if(t==="none")return{x:0,y:0};let x=t.includes("xMid")?.5:t.includes("xMax")?1:0,e=t.includes("YMid")?.5:t.includes("YMax")?1:0;return{x,y:e}}async function Jc(t,x,e){let n=Vb(x);if(!n)return;let{root:r}=n,o=x.contentBox,a=Math.max(o.width,0),i=Math.max(o.height,0);if(a<=0||i<=0)return;let s=wn(r.viewBox?.width??n.intrinsicWidth??a),d=wn(r.viewBox?.height??n.intrinsicHeight??i),f=r.viewBox?.minX??0,c=r.viewBox?.minY??0,l=r.attributes?.preserveAspectRatio??r.attributes?.preserveaspectratio,u=Kc(typeof l=="string"?l:void 0),p=Qc(a/s),m=Qc(i/d),h=p,b=m,g=0,y=0;if(u.align!=="none"){let P=u.meetOrSlice==="slice"?Math.max(p,m):Math.min(p,m);h=P,b=P;let E=s*h,B=d*b,A=a-E,F=i-B,D=Zc(u.align);g=A*D.x,y=F*D.y}let w={a:h,b:0,c:0,d:b,e:o.x+g-f*h,f:o.y+y-c*b},S=me(),R=f7(w,S),L={painter:t,viewportMatrix:w,transform:S,strokeScale:R,environment:e},T=new Map;x2(r,T),L.defs=T,n.resourceBaseDir&&(L.resourceBaseDir=n.resourceBaseDir),n.assetRootDir&&(L.assetRootDir=n.assetRootDir);let N=Hc();await e2(r,N,L)}function x2(t,x){if(t&&(t.id&&typeof t.id=="string"&&x.set(t.id,t),"children"in t&&Array.isArray(t.children)))for(let e of t.children)x2(e,x)}function Vb(t){let x=t.customData?.svg;if(!x||typeof x!="object")return null;let e=x;return e.root?{root:e.root,intrinsicWidth:wn(e.intrinsicWidth??0),intrinsicHeight:wn(e.intrinsicHeight??0),resourceBaseDir:e.resourceBaseDir,assetRootDir:e.assetRootDir}:null}async function e2(t,x,e){let n=e,r=hx(t.transform);if(r){let o=W0(e.transform,r);n={painter:e.painter,viewportMatrix:e.viewportMatrix,transform:o,strokeScale:f7(e.viewportMatrix,o)}}switch(t.type){case"svg":case"g":{let o=tx(x,t);for(let a of t.children)await e2(a,o,n);return}case"rect":return Gc(t,tx(x,t),n);case"circle":return jc(t,tx(x,t),n);case"ellipse":return $c(t,tx(x,t),n);case"polygon":return Vc(t,tx(x,t),n);case"polyline":return _c(t,tx(x,t),n);case"line":return Yc(t,tx(x,t),n);case"text":return qc(t,tx(x,t),n);case"image":return await _b(t,tx(x,t),n);case"path":return Xc(t,tx(x,t),n);default:return}}function Qc(t){return!Number.isFinite(t)||t===0?1:t}function wn(t){return!Number.isFinite(t)||t<=0?1:t}async function _b(t,x,e){let n=t.href??t.attributes?.href??t.attributes?.["xlink:href"];if(!n||typeof n!="string")return;let r,o=n,a=Wx.getInstance(e.environment);try{if(n.startsWith("data:")){let u=n.indexOf(",");if(u<0)return;let m=n.substring(5,u).endsWith(";base64"),h=n.substring(u+1),g=(m?Ux(h):new TextEncoder().encode(decodeURIComponent(h))).slice();r=await a.decodeImage(g.buffer)}else if(/^https?:\/\//i.test(n)){console.debug("Skipping remote image in SVG:",n);return}else{if(!(typeof process<"u"&&!!process.versions?.node)){console.debug("Skipping local SVG image in non-Node environment:",n);return}let p=e.environment?.resolveLocal;if(!p){console.debug("Skipping local SVG image (no resolver in environment):",n);return}let m=n.startsWith("/")?e.assetRootDir??e.resourceBaseDir:e.resourceBaseDir??e.assetRootDir;o=p(n,m),r=await a.loadImage(o)}}catch(u){console.debug("Failed to load SVG image",n,u instanceof Error?u.message:u);return}if(!r)return;let i=Number.isFinite(t.width)?t.width:r.width,s=Number.isFinite(t.height)?t.height:r.height,d=v0(Number(t.x??0),Number(t.y??0),e),f=v0(Number(t.x??0)+i,Number(t.y??0)+s,e);if(!d||!f)return;let c={x:d.x,y:d.y,width:f.x-d.x,height:f.y-d.y},l={src:o,width:r.width,height:r.height,format:r.format,channels:r.channels,bitsPerComponent:r.bitsPerChannel,data:r.data};try{e.painter.drawImage(l,c)}catch(u){console.debug("Failed to draw image in SVG",n,u instanceof Error?u.message:u)}}function Rn(t,x){let e=Math.max(t.x,x.x),n=Math.max(t.y,x.y),r=Math.min(t.x+t.width,x.x+x.width),o=Math.min(t.y+t.height,x.y+x.height),a=r-e,i=o-n;return a<=0||i<=0?null:{x:e,y:n,width:a,height:i}}function Y7(t,x,e=.01){return!t||!x?!1:Math.abs(t.x-x.x)<e&&Math.abs(t.y-x.y)<e&&Math.abs(t.width-x.width)<e&&Math.abs(t.height-x.height)<e}function X7(t,x,e){let n=t.width,r=t.height;if(!Number.isFinite(n)||!Number.isFinite(r)||n<=0||r<=0)return[];if(e==="no-repeat"){let l=Rn(t,x);return l?[l]:[]}if(e==="space")return Yb(t,x);if(e==="round")return Xb(t,x);let o=e==="repeat"||e==="repeat-x",a=e==="repeat"||e==="repeat-y",i=[],s=o?Math.floor((x.x-t.x)/n):0,d=a?Math.floor((x.y-t.y)/r):0,f=x.x+x.width,c=x.y+x.height;for(let l=d;;l++){let u=t.y+l*r;if(u>=c||u+r<=x.y&&!a)break;for(let p=s;;p++){let m=t.x+p*n;if(m>=f||m+n<=x.x&&!o)break;let b=Rn({x:m,y:u,width:n,height:r},x);if(b&&i.push(b),!o)break}if(!a)break}return i}function Yb(t,x){let e=[],n=t.width,r=t.height,o=x.width,a=x.height,i=Math.max(1,Math.floor(o/n)),s=Math.max(1,Math.floor(a/r)),d=i>1?(o-i*n)/(i-1):0,f=s>1?(a-s*r)/(s-1):0;for(let c=0;c<s;c++){let l=x.y+c*(r+f);for(let u=0;u<i;u++){let m={x:x.x+u*(n+d),y:l,width:n,height:r},h=Rn(m,x);h&&e.push(h)}}return e}function Xb(t,x){let e=[],n=t.width,r=t.height,o=x.width,a=x.height,i=Math.max(1,Math.round(o/n)),s=Math.max(1,Math.round(a/r)),d=o/i,f=a/s;for(let c=0;c<s;c++){let l=x.y+c*f;for(let u=0;u<i;u++){let m={x:x.x+u*d,y:l,width:d,height:f},h=Rn(m,x);h&&e.push(h)}}return e}function qb(t,x){let e=Math.max(x,0);if(!Number.isFinite(e)||e<=0)return;let n=t.toLowerCase();if(n==="dashed"){let r=e;return{pattern:[3*r,3*r],phase:0}}if(n==="dotted"){let r=e;return{pattern:[r,r],phase:0}}}function t2(t,x,e,n,r){let o=[],a=t.x,i=t.y,s=t.width,d=t.height;if(!Number.isFinite(s)||!Number.isFinite(d)||s<=0||d<=0)return o;let f=i+x.top/2,c=i+d-x.bottom/2,l=a+x.left/2,u=a+s-x.right/2,p=(m,h,b,g,y)=>{if(!Number.isFinite(h)||h<=0)return;let w=b.toLowerCase();w!=="none"&&o.push({side:m,points:[g,y],color:n,lineWidth:h,dash:qb(w,h)})};return p("top",x.top,e.top,{x:l,y:f},{x:u,y:f}),p("right",x.right,e.right,{x:u,y:f},{x:u,y:c}),p("bottom",x.bottom,e.bottom,{x:u,y:c},{x:l,y:c}),p("left",x.left,e.left,{x:l,y:c},{x:l,y:f}),o}function nx(t){return t>1?t/255:t}function M(t){return Number.isFinite(t)?Number.isInteger(t)?t.toString():t.toFixed(4).replace(/0+$/,"").replace(/\.$/,""):"0"}function Rx(t,x){let e=M(nx(t.r)),n=M(nx(t.g)),r=M(nx(t.b)),o=t.a??1;return o<1&&x?`/${x.ensureFillAlphaState(o)} gs
|