html2canvas-pro 2.2.1 → 2.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/html2canvas-pro.esm.js +18 -4
- package/dist/html2canvas-pro.esm.js.map +1 -1
- package/dist/html2canvas-pro.js +18 -4
- package/dist/html2canvas-pro.js.map +1 -1
- package/dist/html2canvas-pro.min.js +2 -2
- package/dist/lib/render/canvas/effects-renderer.js +11 -8
- package/dist/lib/render/effects.js +15 -1
- package/dist/types/render/effects.d.ts +9 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* html2canvas-pro 2.2.
|
|
2
|
+
* html2canvas-pro 2.2.2 <https://yorickshan.github.io/html2canvas-pro/>
|
|
3
3
|
* Copyright (c) 2024-present yorickshan and html2canvas-pro contributors
|
|
4
4
|
* Released under MIT License
|
|
5
5
|
*/
|
|
@@ -8,4 +8,4 @@
|
|
|
8
8
|
content: "" !important;
|
|
9
9
|
display: none !important;
|
|
10
10
|
}`,mi=(A,e)=>{Ei(A,`.${pi}:before${Hi}
|
|
11
|
-
.${fi}:after`+Hi,e)},Ei=(A,e,t)=>{var r=A.ownerDocument;r&&((r=r.createElement("style")).textContent=e,t&&(r.nonce=t),A.appendChild(r))},yi=(A,e)=>{var t=A.ownerDocument.createElement("base"),e=(t.href=e,A.getElementsByTagName("head").item(0));e?.insertBefore(t,e?.firstChild??null)},Ii=(A,t)=>A.length===t.length&&A.some((A,e)=>A===t[e]);var v=class v{constructor(A,e){this.type=0,this.x=A,this.y=e}add(A,e){return new v(this.x+A,this.y+e)}};let bi=(A,e,t)=>new v(A.x+(e.x-A.x)*t,A.y+(e.y-A.y)*t);var Ki=class Ki{constructor(A,e,t,r){this.type=1,this.start=A,this.startControl=e,this.endControl=t,this.end=r}subdivide(A,e){var t=bi(this.start,this.startControl,A),r=bi(this.startControl,this.endControl,A),s=bi(this.endControl,this.end,A),B=bi(t,r,A),r=bi(r,s,A),A=bi(B,r,A);return e?new Ki(this.start,t,B,A):new Ki(A,r,s,this.end)}add(A,e){return new Ki(this.start.add(A,e),this.startControl.add(A,e),this.endControl.add(A,e),this.end.add(A,e))}reverse(){return new Ki(this.end,this.endControl,this.startControl,this.start)}};let D=A=>1===A.type;var xi=class{constructor(A){var e=A.styles,t=A.bounds;let[r,s]=nt(e.borderTopLeftRadius,t.width,t.height),[B,n]=nt(e.borderTopRightRadius,t.width,t.height),[i,o]=nt(e.borderBottomRightRadius,t.width,t.height),[a,l]=nt(e.borderBottomLeftRadius,t.width,t.height);var g=[],g=(g.push((r+B)/t.width),g.push((a+i)/t.width),g.push((s+l)/t.height),g.push((n+o)/t.height),Math.max(...g)),g=(1<g&&(r/=g,s/=g,B/=g,n/=g,i/=g,o/=g,a/=g,l/=g),t.width-B),c=t.height-o,w=t.width-i,Q=t.height-l,h=e.borderTopWidth,C=e.borderRightWidth,d=e.borderBottomWidth,u=e.borderLeftWidth,U=f(e.paddingTop,A.bounds.width),F=f(e.paddingRight,A.bounds.width),p=f(e.paddingBottom,A.bounds.width),e=f(e.paddingLeft,A.bounds.width);this.topLeftBorderDoubleOuterBox=0<r||0<s?S(t.left+u/3,t.top+h/3,r-u/3,s-h/3,0):new v(t.left+u/3,t.top+h/3),this.topRightBorderDoubleOuterBox=0<r||0<s?S(t.left+g,t.top+h/3,B-C/3,n-h/3,1):new v(t.left+t.width-C/3,t.top+h/3),this.bottomRightBorderDoubleOuterBox=0<i||0<o?S(t.left+w,t.top+c,i-C/3,o-d/3,2):new v(t.left+t.width-C/3,t.top+t.height-d/3),this.bottomLeftBorderDoubleOuterBox=0<a||0<l?S(t.left+u/3,t.top+Q,a-u/3,l-d/3,3):new v(t.left+u/3,t.top+t.height-d/3),this.topLeftBorderDoubleInnerBox=0<r||0<s?S(t.left+2*u/3,t.top+2*h/3,r-2*u/3,s-2*h/3,0):new v(t.left+2*u/3,t.top+2*h/3),this.topRightBorderDoubleInnerBox=0<r||0<s?S(t.left+g,t.top+2*h/3,B-2*C/3,n-2*h/3,1):new v(t.left+t.width-2*C/3,t.top+2*h/3),this.bottomRightBorderDoubleInnerBox=0<i||0<o?S(t.left+w,t.top+c,i-2*C/3,o-2*d/3,2):new v(t.left+t.width-2*C/3,t.top+t.height-2*d/3),this.bottomLeftBorderDoubleInnerBox=0<a||0<l?S(t.left+2*u/3,t.top+Q,a-2*u/3,l-2*d/3,3):new v(t.left+2*u/3,t.top+t.height-2*d/3),this.topLeftBorderStroke=0<r||0<s?S(t.left+u/2,t.top+h/2,r-u/2,s-h/2,0):new v(t.left+u/2,t.top+h/2),this.topRightBorderStroke=0<r||0<s?S(t.left+g,t.top+h/2,B-C/2,n-h/2,1):new v(t.left+t.width-C/2,t.top+h/2),this.bottomRightBorderStroke=0<i||0<o?S(t.left+w,t.top+c,i-C/2,o-d/2,2):new v(t.left+t.width-C/2,t.top+t.height-d/2),this.bottomLeftBorderStroke=0<a||0<l?S(t.left+u/2,t.top+Q,a-u/2,l-d/2,3):new v(t.left+u/2,t.top+t.height-d/2),this.topLeftBorderBox=0<r||0<s?S(t.left,t.top,r,s,0):new v(t.left,t.top),this.topRightBorderBox=0<B||0<n?S(t.left+g,t.top,B,n,1):new v(t.left+t.width,t.top),this.bottomRightBorderBox=0<i||0<o?S(t.left+w,t.top+c,i,o,2):new v(t.left+t.width,t.top+t.height),this.bottomLeftBorderBox=0<a||0<l?S(t.left,t.top+Q,a,l,3):new v(t.left,t.top+t.height),this.topLeftPaddingBox=0<r||0<s?S(t.left+u,t.top+h,Math.max(0,r-u),Math.max(0,s-h),0):new v(t.left+u,t.top+h),this.topRightPaddingBox=0<B||0<n?S(t.left+Math.min(g,t.width-C),t.top+h,g>t.width+C?0:Math.max(0,B-C),Math.max(0,n-h),1):new v(t.left+t.width-C,t.top+h),this.bottomRightPaddingBox=0<i||0<o?S(t.left+Math.min(w,t.width-u),t.top+Math.min(c,t.height-d),Math.max(0,i-C),Math.max(0,o-d),2):new v(t.left+t.width-C,t.top+t.height-d),this.bottomLeftPaddingBox=0<a||0<l?S(t.left+u,t.top+Math.min(Q,t.height-d),Math.max(0,a-u),Math.max(0,l-d),3):new v(t.left+u,t.top+t.height-d),this.topLeftContentBox=0<r||0<s?S(t.left+u+e,t.top+h+U,Math.max(0,r-(u+e)),Math.max(0,s-(h+U)),0):new v(t.left+u+e,t.top+h+U),this.topRightContentBox=0<B||0<n?S(t.left+Math.min(g,t.width+u+e),t.top+h+U,g>t.width+u+e?0:B-u+e,n-(h+U),1):new v(t.left+t.width-(C+F),t.top+h+U),this.bottomRightContentBox=0<i||0<o?S(t.left+Math.min(w,t.width-(u+e)),t.top+Math.min(c,t.height+h+U),Math.max(0,i-(C+F)),o-(d+p),2):new v(t.left+t.width-(C+F),t.top+t.height-(d+p)),this.bottomLeftContentBox=0<a||0<l?S(t.left+u+e,t.top+Q,Math.max(0,a-(u+e)),l-(d+p),3):new v(t.left+u+e,t.top+t.height-(d+p))}};let S=(A,e,t,r,s)=>{var B=(Math.sqrt(2)-1)/3*4,n=t*B,i=r*B,o=A+t,a=e+r;switch(s){case 0:return new Ki(new v(A,a),new v(A,a-i),new v(o-n,e),new v(o,e));case 1:return new Ki(new v(A,e),new v(A+n,e),new v(o,a-i),new v(o,a));case 2:return new Ki(new v(o,e),new v(o,e+i),new v(A+n,a),new v(A,a));default:return new Ki(new v(o,a),new v(o-n,a),new v(A,e+i),new v(A,e))}},Li=A=>[A.topLeftBorderBox,A.topRightBorderBox,A.bottomRightBorderBox,A.bottomLeftBorderBox],vi=A=>[A.topLeftPaddingBox,A.topRightPaddingBox,A.bottomRightPaddingBox,A.bottomLeftPaddingBox];var Di=class{constructor(A,e,t){this.offsetX=A,this.offsetY=e,this.matrix=t,this.type=0,this.target=6}},Si=class{constructor(A,e){this.path=A,this.target=e,this.type=1}},Mi=class{constructor(A){this.opacity=A,this.type=2,this.target=6}},Ti=class{constructor(A){this.applyClip=A,this.type=3,this.target=6}};let Oi={[y.NORMAL]:"source-over",[y.MULTIPLY]:"multiply",[y.SCREEN]:"screen",[y.OVERLAY]:"overlay",[y.DARKEN]:"darken",[y.LIGHTEN]:"lighten",[y.COLOR_DODGE]:"color-dodge",[y.COLOR_BURN]:"color-burn",[y.HARD_LIGHT]:"hard-light",[y.SOFT_LIGHT]:"soft-light",[y.DIFFERENCE]:"difference",[y.EXCLUSION]:"exclusion",[y.HUE]:"hue",[y.SATURATION]:"saturation",[y.COLOR]:"color",[y.LUMINOSITY]:"luminosity"};var ki=class{constructor(A){this.mixBlendMode=A,this.type=4,this.target=6,this.compositeOperation=Oi[A]}},Vi=class{constructor(A){this.filterString=A,this.type=5,this.target=6}};let Gi=A=>1===A.type;var Ri=class{constructor(A){this.element=A,this.inlineLevel=[],this.nonInlineLevel=[],this.negativeZIndex=[],this.zeroOrAutoZIndexOrTransformedOrOpacity=[],this.positiveZIndex=[],this.nonPositionedFloats=[],this.nonPositionedInlineLevel=[]}},Ni=class{constructor(A,e){var t,r;this.container=A,this.parent=e,this.effects=[],this.curves=new xi(this.container),this.container.styles.opacity<1&&this.effects.push(new Mi(this.container.styles.opacity)),null!==this.container.styles.rotate&&(A=this.container.styles.transformOrigin,e=this.container.bounds.left+f(A[0],this.container.bounds.width),A=this.container.bounds.top+f(A[1],this.container.bounds.height),r=this.container.styles.rotate*Math.PI/180,t=Math.cos(r),r=Math.sin(r),this.effects.push(new Di(e,A,[t,r,-r,t,0,0]))),null!==this.container.styles.transform&&(e=this.container.styles.transformOrigin,A=this.container.bounds.left+f(e[0],this.container.bounds.width),r=this.container.bounds.top+f(e[1],this.container.bounds.height),t=this.container.styles.transform,this.effects.push(new Di(A,r,t))),Pi(this.container.styles)&&(e=Li(this.curves),A=vi(this.curves),Ii(e,A)?this.effects.push(new Si(e,6)):(this.effects.push(new Si(e,2)),this.effects.push(new Si(A,4)))),0!==this.container.styles.clipPath.type&&(r=Ji(this.container.styles.clipPath,this.container.bounds))&&this.effects.push(r),this.container.styles.mixBlendMode!==y.NORMAL&&this.effects.push(new ki(this.container.styles.mixBlendMode)),null!==this.container.styles.filter&&this.effects.push(new Vi(this.container.styles.filter)),1!==this.container.styles.zoom&&(t=this.container.styles.transformOrigin,e=this.container.bounds.left+f(t[0],this.container.bounds.width),A=this.container.bounds.top+f(t[1],this.container.bounds.height),r=this.container.styles.zoom,this.effects.push(new Di(e,A,[r,0,0,r,0,0])))}getEffects(e){let A=-1===[2,3].indexOf(this.container.styles.position),t=this.parent;for(var r=this.effects.slice(0);t;){var s,B,n=t.effects.filter(A=>!Gi(A));!A&&0===t.container.styles.position&&t.parent||(A=-1===[2,3].indexOf(t.container.styles.position),!Pi(t.container.styles))||(s=Li(t.curves),B=vi(t.curves),Ii(s,B))||r.unshift(new Si(B,6)),r.unshift(...n),t=t.parent}return r.filter(A=>E(A.target,e))}};let Pi=A=>0!==A.overflowX||0!==A.overflowY,Xi=(A,e,t,r,s)=>"closest-side"===A?Math.min(e-t,r-e):"farthest-side"===A?Math.max(e-t,r-e):f(A,s),Ji=(A,e)=>{let{left:B,top:n,width:i,height:o}=e;switch(A.type){case 1:{var a=f(A.left,i),l=f(A.top,o);let e=B+a,t=n+l,r=Math.max(0,i-a-f(A.right,i)),s=Math.max(0,o-l-f(A.bottom,o));return new Ti(A=>{A.beginPath(),A.rect(e,t,r,s),A.clip()})}case 2:{let e=B+f(A.cx,i),t=n+f(A.cy,o),r;return r="closest-side"===A.radius?Math.min(e-B,t-n,B+i-e,n+o-t):"farthest-side"===A.radius?Math.max(e-B,t-n,B+i-e,n+o-t):f(A.radius,Math.sqrt(i*i+o*o)/Math.SQRT2),new Ti(A=>{A.beginPath(),A.arc(e,t,Math.max(0,r),0,2*Math.PI),A.clip()})}case 3:{let e=B+f(A.cx,i),t=n+f(A.cy,o),r=Xi(A.rx,e,B,B+i,i),s=Xi(A.ry,t,n,n+o,o);return new Ti(A=>{A.beginPath(),A.ellipse(e,t,Math.max(0,r),Math.max(0,s),0,0,2*Math.PI),A.clip()})}case 4:{let t=A.points.map(([A,e])=>[B+f(A,i),n+f(e,o)]);return new Ti(e=>{if(e.beginPath(),0<t.length){e.moveTo(t[0][0],t[0][1]);for(let A=1;A<t.length;A++)e.lineTo(t[A][0],t[A][1]);e.closePath()}e.clip()})}case 5:{let t=A.d,r=null;return new Ti(A=>{try{r=r||new Path2D(t);var e=A.getTransform();A.translate(B,n),A.clip(r),A.setTransform(e)}catch(A){}})}default:return null}},Wi=(n,i,o,a)=>{n.container.elements.forEach(A=>{var e=A.createsRealStackingContext,s=A.createsStackingContext,t=new Ni(A,n),r=(E(A.styles.display,2048)&&a.push(t),A.isListOwner?[]:a);if(e||s){var s=e||A.styles.isPositioned()?o:i,B=new Ri(t);if(A.styles.isPositioned()||A.styles.opacity<1||A.styles.isTransformed()){let r=A.styles.zIndex.order;if(r<0){let t=0;s.negativeZIndex.some((A,e)=>r>A.element.container.styles.zIndex.order?(t=e,!1):0<t),s.negativeZIndex.splice(t,0,B)}else if(0<r){let t=0;s.positiveZIndex.some((A,e)=>r>=A.element.container.styles.zIndex.order?(t=e+1,!1):0<t),s.positiveZIndex.splice(t,0,B)}else s.zeroOrAutoZIndexOrTransformedOrOpacity.push(B)}else(A.styles.isFloating()?s.nonPositionedFloats:s.nonPositionedInlineLevel).push(B);Wi(t,B,e?B:o,r)}else(A.styles.isInlineLevel()?i.inlineLevel:i.nonInlineLevel).push(t),Wi(t,i,o,r);A.isListOwner&&Yi(A,r)})},Yi=(A,e)=>{let t=A instanceof vn?A.start:1;var r=A instanceof vn&&A.reversed;for(let A=0;A<e.length;A++){var s=e[A];s.container instanceof Ln&&"number"==typeof s.container.value&&0!==s.container.value&&(t=s.container.value),s.listValue=ai(t,s.container.styles.listStyleType,!0),t+=r?-1:1}},Zi=A=>{var e=A.bounds,A=A.styles;return e.add(A.borderLeftWidth,A.borderTopWidth,-(A.borderRightWidth+A.borderLeftWidth),-(A.borderTopWidth+A.borderBottomWidth))},_i=A=>{var e=A.styles,A=A.bounds,t=f(e.paddingLeft,A.width),r=f(e.paddingRight,A.width),s=f(e.paddingTop,A.width),B=f(e.paddingBottom,A.width);return A.add(t+e.borderLeftWidth,s+e.borderTopWidth,-(e.borderRightWidth+e.borderLeftWidth+t+r),-(e.borderTopWidth+e.borderBottomWidth+s+B))},zi=(A,e,t)=>{r=$i(A.styles.backgroundOrigin,e),s=A;var r=0===r?s.bounds:(2===r?_i:Zi)(s),s=(s=$i(A.styles.backgroundClip,e),B=A,0===s?B.bounds:(2===s?_i:Zi)(B)),B=((A,[e,t,r],s)=>{const[B,n]=A;if(!B)return[0,0];if(u(B)&&n&&u(n))return[f(B,s.width),f(n,s.height)];const i=ji(r);if(h(B)&&(B.value==="contain"||B.value==="cover")){if(ji(r))return s.width/s.height<r!==(B.value==="cover")?[s.width,s.width/r]:[s.height*r,s.height];return[s.width,s.height]}const o=ji(e),a=ji(t),l=o||a;if(qi(B)&&(!n||qi(n))){if(o&&a)return[e,t];if(!i&&!l)return[s.width,s.height];if(l&&i)return[o?e:t*r,a?t:e/r];return[o?e:s.width,a?t:s.height]}if(i){let A=0;let e=0;if(u(B))A=f(B,s.width);else if(u(n))e=f(n,s.height);if(qi(B))A=e*r;else if(!n||qi(n))e=A/r;return[A,e]}let g=null,c=null;if(u(B))g=f(B,s.width);else if(n&&u(n))c=f(n,s.height);if(g!==null&&(!n||qi(n)))c=o&&a?g/e*t:s.height;if(c!==null&&qi(B))g=o&&a?c/t*e:s.width;if(g!==null&&c!==null)return[g,c];throw new Error(`Unable to calculate background-size for element`)})($i(A.styles.backgroundSize,e),t,r),[t,n]=B,i=nt($i(A.styles.backgroundPosition,e),r.width-t,r.height-n);return[((A,[e,t],[r,s],B,n)=>{switch(A){case 2:return[new v(Math.round(B.left),Math.round(B.top+t)),new v(Math.round(B.left+B.width),Math.round(B.top+t)),new v(Math.round(B.left+B.width),Math.round(s+B.top+t)),new v(Math.round(B.left),Math.round(s+B.top+t))];case 3:return[new v(Math.round(B.left+e),Math.round(B.top)),new v(Math.round(B.left+e+r),Math.round(B.top)),new v(Math.round(B.left+e+r),Math.round(B.height+B.top)),new v(Math.round(B.left+e),Math.round(B.height+B.top))];case 1:return[new v(Math.round(B.left+e),Math.round(B.top+t)),new v(Math.round(B.left+e+r),Math.round(B.top+t)),new v(Math.round(B.left+e+r),Math.round(B.top+t+s)),new v(Math.round(B.left+e),Math.round(B.top+t+s))];default:return[new v(Math.round(n.left),Math.round(n.top)),new v(Math.round(n.left+n.width),Math.round(n.top)),new v(Math.round(n.left+n.width),Math.round(n.height+n.top)),new v(Math.round(n.left),Math.round(n.height+n.top))]}})($i(A.styles.backgroundRepeat,e),i,B,r,s),Math.round(r.left+i[0]),Math.round(r.top+i[1]),Math.max(1,t),Math.max(1,n)]},qi=A=>h(A)&&"auto"===A.value,ji=A=>"number"==typeof A,$i=(A,e)=>{e=A[e];return void 0===e?A[0]:e},Ao="Hidden Text";var eo=class{constructor(A){this._data={},this._document=A}parseMetrics(A,e){var t=this._document.createElement("div"),r=this._document.createElement("img"),s=this._document.createElement("span"),B=this._document.body,A=(t.style.visibility="hidden",t.style.fontFamily=A,t.style.fontSize=e,t.style.margin="0",t.style.padding="0",t.style.whiteSpace="nowrap",B.appendChild(t),r.src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",r.width=1,r.height=1,r.style.margin="0",r.style.padding="0",r.style.verticalAlign="baseline",s.style.fontFamily=A,s.style.fontSize=e,s.style.margin="0",s.style.padding="0",s.appendChild(this._document.createTextNode(Ao)),t.appendChild(s),t.appendChild(r),r.offsetTop-s.offsetTop+2),e=(t.removeChild(s),t.appendChild(this._document.createTextNode(Ao)),t.style.lineHeight="normal",r.style.verticalAlign="super",r.offsetTop-t.offsetTop+2);return B.removeChild(t),{baseline:A,middle:e}}getMetrics(A,e){var t=A+" "+e;return void 0===this._data[t]&&(this._data[t]=this.parseMetrics(A,e)),this._data[t]}},to=class{constructor(A){this.ctx=A}render(t,A){this.ctx.fillStyle=p(A.textDecorationColor||A.color);let r=1,s=("number"==typeof A.textDecorationThickness?r=A.textDecorationThickness:"from-font"===A.textDecorationThickness&&(r=Math.max(1,Math.floor(.05*A.fontSize.number))),0),B=("number"==typeof A.textUnderlineOffset&&(s=A.textUnderlineOffset),A.textDecorationStyle);A.textDecorationLine.forEach(A=>{let e=0;switch(A){case 1:e=t.top+t.height-r+s;break;case 2:e=t.top;break;case 3:e=t.top+(t.height/2-r/2);break;default:return}this.draw(t.left,e,t.width,r,B)})}draw(A,e,t,r,s){switch(s){case 0:this.ctx.fillRect(A,e,t,r);break;case 1:var B=Math.max(1,r);this.ctx.fillRect(A,e,t,r),this.ctx.fillRect(A,e+r+B,t,r);break;case 2:this.drawPattern(A,e,t,r,[r,2*r]);break;case 3:this.drawPattern(A,e,t,r,[3*r,2*r]);break;case 4:this.drawWavy(A,e,t,r);break;default:this.ctx.fillRect(A,e,t,r)}}drawPattern(A,e,t,r,s){this.ctx.save(),this.ctx.beginPath(),this.ctx.setLineDash(s),this.ctx.lineWidth=r,this.ctx.strokeStyle=this.ctx.fillStyle,this.ctx.moveTo(A,e+r/2),this.ctx.lineTo(A+t,e+r/2),this.ctx.stroke(),this.ctx.restore()}drawWavy(A,e,t,r){this.ctx.save(),this.ctx.beginPath(),this.ctx.lineWidth=r,this.ctx.strokeStyle=this.ctx.fillStyle;var s=2*r,B=4*r;let n=A;for(this.ctx.moveTo(n,e+r/2);n<A+t;){var i=Math.min(n+B/2,A+t);this.ctx.quadraticCurveTo(n+B/4,e+r/2-s,i,e+r/2),(n=i)<A+t&&(i=Math.min(n+B/2,A+t),this.ctx.quadraticCurveTo(n+B/4,e+r/2+s,i,e+r/2),n=i)}this.ctx.stroke(),this.ctx.restore()}};let ro=["-apple-system","system-ui"],so=/[\u2E80-\u2FFF\u3000-\u30FF\u3400-\u4DBF\u4E00-\u9FFF\uAC00-\uD7AF\uF900-\uFAFF\uFF01-\uFFEF]/,Bo=A=>so.test(A),no=A=>{var e=(()=>{if("undefined"!=typeof navigator){var A=navigator.userAgent,e=/iPhone|iPad|iPod/.test(A),t=/Macintosh/.test(A)&&navigator.maxTouchPoints&&1<navigator.maxTouchPoints;if(e||t)for(var r of[/(?:iPhone|CPU(?:\siPhone)?)\sOS\s(\d+)[\._](\d+)/,/Version\/(\d+)\.(\d+)/]){r=A.match(r);if(r&&r[1])return parseInt(r[1],10)}}return null})();return null!==e&&15<=e&&e<17?A.map(A=>-1!==ro.indexOf(A)?'-apple-system, "Helvetica Neue", Arial, sans-serif':A):A};var io=class{constructor(A){this.ctx=A.ctx,this.options=A.options,this.decorationRenderer=new to(A.ctx)}iterateLettersWithLetterSpacing(e,t,r,s,B){if(Qs(s))this.iterateVerticalGlyphs(e,t,r,s,B);else{var n,i,s=Fn(e.text),o=e.bounds.top+r;let A=e.bounds.left;for(n of s)Bo(n)?(i=this.ctx.textBaseline,this.ctx.textBaseline="ideographic",B(n,A,o),this.ctx.textBaseline=i):B(n,A,o),A+=this.ctx.measureText(n).width+t}}iterateVerticalGlyphs(A,e,t,r,s){var B,n,i=Fn(A.text);let o=A.bounds.top;for(B of i)3===(n=r)||4===n||!Bo(B)&&0<B.trim().length?(this.ctx.save(),this.ctx.translate(A.bounds.left+t,o),this.ctx.rotate(4===r?-Math.PI/2:Math.PI/2),s(B,0,0),this.ctx.restore()):(n=this.ctx.textBaseline,Bo(B)&&(this.ctx.textBaseline="ideographic"),s(B,A.bounds.left,o+t),this.ctx.textBaseline=n),o+=this.ctx.measureText(B).width+e}renderTextWithLetterSpacing(A,e,t,r=0){this.renderFillText(A,e,t,r)}canRenderWholeText(A,e){return 0===A&&!Qs(e)}renderFillText(A,e,t,r){this.canRenderWholeText(e,r)?this.ctx.fillText(A.text,A.bounds.left,A.bounds.top+t):this.iterateLettersWithLetterSpacing(A,e,t,r,(A,e,t)=>{this.ctx.fillText(A,e,t)})}renderStrokeText(A,e,t,r){this.canRenderWholeText(e,r)?this.ctx.strokeText(A.text,A.bounds.left,A.bounds.top+t):this.iterateLettersWithLetterSpacing(A,e,t,r,(A,e,t)=>{this.ctx.strokeText(A,e,t)})}renderTextStrokeWithStyle(A,e){e.webkitTextStrokeWidth&&A.text.trim().length&&(this.ctx.strokeStyle=p(e.webkitTextStrokeColor),this.ctx.lineWidth=e.webkitTextStrokeWidth,this.ctx.lineJoin=("undefined"!=typeof window?window:void 0)?.chrome?"miter":"round",this.renderStrokeText(A,e.letterSpacing,e.fontSize.number,e.writingMode),this.ctx.strokeStyle="",this.ctx.lineWidth=0,this.ctx.lineJoin="miter")}renderTextFillWithShadows(e,t){this.ctx.fillStyle=p(t.color),this.renderTextWithLetterSpacing(e,t.letterSpacing,t.fontSize.number,t.writingMode);var A=t.textShadow;A.length&&e.text.trim().length&&(A.slice(0).reverse().forEach(A=>{this.ctx.shadowColor=p(A.color),this.ctx.shadowOffsetX=A.offsetX.number*this.options.scale,this.ctx.shadowOffsetY=A.offsetY.number*this.options.scale,this.ctx.shadowBlur=A.blur.number,this.renderTextWithLetterSpacing(e,t.letterSpacing,t.fontSize.number,t.writingMode)}),this.ctx.shadowColor="",this.ctx.shadowOffsetX=0,this.ctx.shadowOffsetY=0,this.ctx.shadowBlur=0)}renderTextBoundWithPaintOrder(e,t,A){A.forEach(A=>{switch(A){case 0:this.ctx.fillStyle=p(t.color),this.renderTextWithLetterSpacing(e,t.letterSpacing,t.fontSize.number,t.writingMode);break;case 1:this.renderTextStrokeWithStyle(e,t)}})}renderTextDecoration(A,e){this.decorationRenderer.render(A,e)}truncateTextWithEllipsis(A,t,e){let r=this.ctx.measureText("…").width,s=Fn(A);if(0===e){var B=A=>this.ctx.measureText(s.slice(0,A).join("")).width+r<=t;let A=0,e=s.length;for(;A<e;){var n=A+e+1>>1;B(n)?A=n:e=n-1}return s.slice(0,A).join("")+"…"}{let A=r;var i,o=[];for(i of s){var a=this.ctx.measureText(i).width;if(A+a>t)break;o.push(i),A+=a+e}return o.join("")+"…"}}createFontStyle(A){var e=A.fontVariant.filter(A=>"normal"===A||"small-caps"===A).join(""),t=no(A.fontFamily).join(", "),r=s(A.fontSize)?""+A.fontSize.number+A.fontSize.unit:A.fontSize.number+"px";return[[A.fontStyle,e,A.fontWeight,r,t].join(" "),t,r]}renderLineClampedText(A,e,t,r){let s=1.5*e.fontSize.number,B=[],n=[],i=A.textBounds[0].bounds.top;A.textBounds.forEach(A=>{Math.abs(A.bounds.top-i)>=.5*s?(0<n.length&&B.push(n),n=[A],i=A.bounds.top):n.push(A)}),0<n.length&&B.push(n);var o=e.webkitLineClamp;if(B.length<=o)return!1;for(let A=0;A<o-1;A++)B[A].forEach(A=>this.renderTextBoundWithPaintOrder(A,e,t));A=B[o-1];if(A?.length&&r){var a,l=A.map(A=>A.text).join(""),A=A[0],r=r.width-(A.bounds.left-r.left),g=new dn(this.truncateTextWithEllipsis(l,r,e.letterSpacing),A.bounds);for(a of t)0===a?(this.ctx.fillStyle=p(e.color),this.renderTextWithLetterSpacing(g,e.letterSpacing,e.fontSize.number,e.writingMode)):1===a&&this.renderTextStrokeWithStyle(g,e)}return!0}renderEllipsisText(A,e,t,r){let s=1.5*e.fontSize.number,B=A.textBounds[0].bounds.top;if(!A.textBounds.every(A=>Math.abs(A.bounds.top-B)<.5*s))return!1;var n=A.textBounds.map(A=>A.text).join("").replace(/\s+/g," ").trim();if(this.ctx.measureText(n).width<=r.width)return!1;var i,o=new dn(this.truncateTextWithEllipsis(n,r.width,e.letterSpacing),A.textBounds[0].bounds);for(i of t)0===i?this.renderTextFillWithShadows(o,e):1===i&&this.renderTextStrokeWithStyle(o,e);return!0}async renderTextNode(A,t,e){this.ctx.font=this.createFontStyle(t)[0],this.ctx.direction=1===t.direction?"rtl":"ltr",this.ctx.textAlign="left",this.ctx.textBaseline="alphabetic";let r=t.paintOrder;0<t.webkitLineClamp&&0!=(2&t.display)&&1===t.overflowY&&0<A.textBounds.length&&this.renderLineClampedText(A,t,r,e)||1===t.textOverflow&&e&&1===t.overflowX&&0<A.textBounds.length&&this.renderEllipsisText(A,t,r,e)||A.textBounds.forEach(e=>{r.forEach(A=>{0===A?(this.renderTextFillWithShadows(e,t),t.textDecorationLine.length&&this.renderTextDecoration(e.bounds,t)):1===A&&this.renderTextStrokeWithStyle(e,t)})})}};let oo=(r,A)=>{A.forEach((A,e)=>{var t=D(A)?A.start:A;0===e?r.moveTo(t.x,t.y):r.lineTo(t.x,t.y),D(A)&&r.bezierCurveTo(A.startControl.x,A.startControl.y,A.endControl.x,A.endControl.y,A.end.x,A.end.y)})},ao=(A,e)=>{A.beginPath(),oo(A,e),A.closePath()};var lo=class lo{static{this.PATTERN_CACHE_MAX=50}constructor(A){this.patternCache=new Map,this.ctx=A.ctx,this.context=A.context,this.canvas=A.canvas}async renderBackgroundImage(A){let e=A.styles.backgroundImage.length-1;var t,r,s=A.styles.backgroundBlendMode;let B=0;for(t of A.styles.backgroundImage.slice(0).reverse())0<B&&"normal"!==(r=s[B]??s[0]??"normal")&&(this.ctx.save(),this.ctx.globalCompositeOperation=r),0===t.type?await this.renderBackgroundURLImage(A,t,e):1===t.type?this.renderLinearGradient(A,t,e):3===t.type?this.renderRepeatingLinearGradient(A,t,e):2===t.type&&this.renderRadialGradient(A,t,e),0<B&&"normal"!==(s[B]??s[0]??"normal")&&this.ctx.restore(),e--,B++}async renderBackgroundURLImage(e,t,r){let s;t=t.url;try{s=await this.context.cache.match(t)}catch(A){this.context.logger.error("Error loading background-image "+t),this.context.onError?.(A instanceof Error?A:new Error(String(A)))}if(s){var B=isNaN(s.width)||0===s.width?1:s.width,n=isNaN(s.height)||0===s.height?1:s.height,[r,B,n,i,o]=zi(e,r,[B,n,B/n]),t=`${t}|${Math.round(i)}x${Math.round(o)}|`+e.styles.imageRendering;let A=this.lruGet(this.patternCache,t);A||(i=this.resizeImage(s,i,o,e.styles.imageRendering),A=this.ctx.createPattern(i,"repeat"),this.lruSet(this.patternCache,t,A)),this.renderRepeat(r,A,B,n)}}renderRepeatingLinearGradient(t,r,s){var[e,B,n,i,o]=zi(t,s,[null,null,null]),[i,o,a,l,g]=zt(r.angle,i,o),i=_t(r.stops,i||1),c=i[i.length-1];let w=i[0],Q=c.stop-w.stop;if(Q<=0)this.renderLinearGradient(t,r,s);else{c=a-o,t=g-l,s=Q/(Math.sqrt(c*c+t*t)||1),a=o,g=l,o=o+c*s,c=l+t*s,l=this.canvas.ownerDocument??document,t=`rlg|${r.angle}|${Math.round(Q)}|`+JSON.stringify(r.stops);let A=this.lruGet(this.patternCache,t);if(!A){s=l.createElement("canvas"),r=Math.max(1,Math.ceil(Q)),l=(s.width=r,s.height=r,s.getContext("2d"));if(!l)return;let e=l.createLinearGradient(a-B,g-n,o-B,c-n);i.forEach(A=>{e.addColorStop((A.stop-w.stop)/Q,p(A.color))}),l.fillStyle=e,l.fillRect(0,0,r,r),0<r&&(A=this.ctx.createPattern(s,"repeat"),this.lruSet(this.patternCache,t,A))}A&&this.renderRepeat(e,A,B,n)}}renderLinearGradient(A,t,e){var[A,e,r,s,B]=zi(A,e,[null,null,null]),[n,i,o,a,l]=zt(t.angle,s,B),g=`lg|${t.angle}|${Math.round(s)}x${Math.round(B)}|`+JSON.stringify(t.stops);let c=this.lruGet(this.patternCache,g);if(!c){var w=(this.canvas.ownerDocument??document).createElement("canvas"),Q=(w.width=s,w.height=B,w.getContext("2d"));if(!Q)return;let e=Q.createLinearGradient(i,a,o,l);_t(t.stops,n||1).forEach(A=>e.addColorStop(A.stop,p(A.color))),Q.fillStyle=e,Q.fillRect(0,0,s,B),0<s&&0<B&&(c=this.ctx.createPattern(w,"repeat"),this.lruSet(this.patternCache,g,c))}c&&this.renderRepeat(A,c,e,r)}renderRadialGradient(e,t,r){var[e,r,s,B,n]=zi(e,r,[null,null,null]),i=0===t.position.length?[Bt]:t.position,o=f(i[0],B),i=f(i[i.length-1],n);let[a,l]=((A,e,t,r,s)=>{let B=0,n=0;switch(A.size){case 0:0===A.shape?B=n=Math.min(Math.abs(e),Math.abs(e-r),Math.abs(t),Math.abs(t-s)):1===A.shape&&(B=Math.min(Math.abs(e),Math.abs(e-r)),n=Math.min(Math.abs(t),Math.abs(t-s)));break;case 2:0===A.shape?B=n=Math.min(m(e,t),m(e,t-s),m(e-r,t),m(e-r,t-s)):1===A.shape&&(a=Math.min(Math.abs(t),Math.abs(t-s))/Math.min(Math.abs(e),Math.abs(e-r)),[i,o]=qt(r,s,e,t,!0),B=m(i-e,(o-t)/a),n=a*B);break;case 1:0===A.shape?B=n=Math.max(Math.abs(e),Math.abs(e-r),Math.abs(t),Math.abs(t-s)):1===A.shape&&(B=Math.max(Math.abs(e),Math.abs(e-r)),n=Math.max(Math.abs(t),Math.abs(t-s)));break;case 3:var i,o,a;0===A.shape?B=n=Math.max(m(e,t),m(e,t-s),m(e-r,t),m(e-r,t-s)):1===A.shape&&(i=Math.max(Math.abs(t),Math.abs(t-s))/Math.max(Math.abs(e),Math.abs(e-r)),[o,a]=qt(r,s,e,t,!1),B=m(o-e,(a-t)/i),n=i*B)}return Array.isArray(A.size)&&(B=f(A.size[0],r),n=2===A.size.length?f(A.size[1],s):B),[B,n]})(t,o,i,B,n);if(0!==a&&0!==l||(a=Math.max(a,.01),l=Math.max(l,.01)),0<a&&0<l){B=`rg|${Math.round(o)}x${Math.round(i)}|${Math.round(a)}x${Math.round(l)}|`+JSON.stringify(t.stops);let A=this.lruGet(this.patternCache,B);if(!A){var n=this.canvas.ownerDocument??document,g=Math.ceil(2*Math.max(a,l)),n=n.createElement("canvas"),g=(n.width=g,n.height=g,n.getContext("2d"));if(g){var c=Math.max(a,l);let e=g.createRadialGradient(c,c,0,c,c,c);_t(t.stops,2*c).forEach(A=>e.addColorStop(A.stop,p(A.color))),g.fillStyle=e,a!==l&&g.scale(1,l/a),g.fillRect(0,0,2*c,2*c),A=this.ctx.createPattern(n,"no-repeat"),this.lruSet(this.patternCache,B,A)}}A&&(this.path(e),this.ctx.save(),this.ctx.clip(),this.ctx.translate(r+o-Math.max(a,l),s+i-Math.max(a,l)),this.ctx.fillStyle=A,this.ctx.fillRect(0,0,2*Math.max(a,l),2*Math.max(a,l)),this.ctx.restore())}}renderRepeat(A,e,t,r){this.path(A),this.ctx.fillStyle=e,this.ctx.translate(t,r),this.ctx.fill(),this.ctx.translate(-t,-r)}resizeImage(A,e,t,r){var s=(this.canvas.ownerDocument??document).createElement("canvas"),B=(s.width=Math.max(1,e),s.height=Math.max(1,t),s.getContext("2d"));return B?(2===r||1===r?(this.context.logger.debug("Disabling image smoothing for background image due to CSS image-rendering"),B.imageSmoothingEnabled=!1):3===r?(this.context.logger.debug("Enabling image smoothing for background image due to CSS image-rendering: smooth"),B.imageSmoothingEnabled=!0):B.imageSmoothingEnabled=this.ctx.imageSmoothingEnabled,this.ctx.imageSmoothingQuality&&(B.imageSmoothingQuality=this.ctx.imageSmoothingQuality),B.drawImage(A,0,0,A.width,A.height,0,0,e,t),s):A}path(A){ao(this.ctx,A)}lruGet(A,e){var t=A.get(e);return void 0!==t&&(A.delete(e),A.set(e,t)),t}lruSet(A,e,t){var r;A.size>=lo.PATTERN_CACHE_MAX&&(r=A.keys().next().value,A.delete(r)),A.set(e,t)}};let go=(A,e)=>{switch(e){case 0:return M(A.topLeftBorderBox,A.topLeftPaddingBox,A.topRightBorderBox,A.topRightPaddingBox);case 1:return M(A.topRightBorderBox,A.topRightPaddingBox,A.bottomRightBorderBox,A.bottomRightPaddingBox);case 2:return M(A.bottomRightBorderBox,A.bottomRightPaddingBox,A.bottomLeftBorderBox,A.bottomLeftPaddingBox);default:return M(A.bottomLeftBorderBox,A.bottomLeftPaddingBox,A.topLeftBorderBox,A.topLeftPaddingBox)}},co=(A,e)=>{var t=[];return D(A)?t.push(A.subdivide(.5,!1)):t.push(A),D(e)?t.push(e.subdivide(.5,!0)):t.push(e),t},M=(A,e,t,r)=>{var s=[];return D(A)?s.push(A.subdivide(.5,!1)):s.push(A),D(t)?s.push(t.subdivide(.5,!0)):s.push(t),D(r)?s.push(r.subdivide(.5,!0).reverse()):s.push(r),D(e)?s.push(e.subdivide(.5,!1).reverse()):s.push(e),s};var wo=class{constructor(A,e){this.ctx=A.ctx,this.pathCallbacks=e}async renderSolidBorder(A,e,t){this.pathCallbacks.path(go(t,e)),this.ctx.fillStyle=p(A),this.ctx.fill()}async renderDoubleBorder(A,e,t,r){e<3?await this.renderSolidBorder(A,t,r):(e=((A,e)=>{switch(e){case 0:return M(A.topLeftBorderBox,A.topLeftBorderDoubleOuterBox,A.topRightBorderBox,A.topRightBorderDoubleOuterBox);case 1:return M(A.topRightBorderBox,A.topRightBorderDoubleOuterBox,A.bottomRightBorderBox,A.bottomRightBorderDoubleOuterBox);case 2:return M(A.bottomRightBorderBox,A.bottomRightBorderDoubleOuterBox,A.bottomLeftBorderBox,A.bottomLeftBorderDoubleOuterBox);default:return M(A.bottomLeftBorderBox,A.bottomLeftBorderDoubleOuterBox,A.topLeftBorderBox,A.topLeftBorderDoubleOuterBox)}})(r,t),this.pathCallbacks.path(e),this.ctx.fillStyle=p(A),this.ctx.fill(),e=((A,e)=>{switch(e){case 0:return M(A.topLeftBorderDoubleInnerBox,A.topLeftPaddingBox,A.topRightBorderDoubleInnerBox,A.topRightPaddingBox);case 1:return M(A.topRightBorderDoubleInnerBox,A.topRightPaddingBox,A.bottomRightBorderDoubleInnerBox,A.bottomRightPaddingBox);case 2:return M(A.bottomRightBorderDoubleInnerBox,A.bottomRightPaddingBox,A.bottomLeftBorderDoubleInnerBox,A.bottomLeftPaddingBox);default:return M(A.bottomLeftBorderDoubleInnerBox,A.bottomLeftPaddingBox,A.topLeftBorderDoubleInnerBox,A.topLeftPaddingBox)}})(r,t),this.pathCallbacks.path(e),this.ctx.fill())}async renderDashedDottedBorder(A,e,t,r,s){this.ctx.save();var B=((A,e)=>{switch(e){case 0:return co(A.topLeftBorderStroke,A.topRightBorderStroke);case 1:return co(A.topRightBorderStroke,A.bottomRightBorderStroke);case 2:return co(A.bottomRightBorderStroke,A.bottomLeftBorderStroke);default:return co(A.bottomLeftBorderStroke,A.topLeftBorderStroke)}})(r,t),r=go(r,t);2===s&&(this.pathCallbacks.path(r),this.ctx.clip());let n,i,o,a;i=(D(r[0])?(n=r[0].start.x,r[0].start):(n=r[0].x,r[0])).y,a=(D(r[1])?(o=r[1].end.x,r[1].end):(o=r[1].x,r[1])).y;let l,g=(l=0===t||2===t?Math.abs(n-o):Math.abs(i-a),this.ctx.beginPath(),3===s?this.pathCallbacks.formatPath(B):this.pathCallbacks.formatPath(r.slice(0,2)),e<3?3*e:2*e),c=e<3?2*e:e,w=(3===s&&(g=e,c=e),!0);l<=2*g?w=!1:l<=2*g+c?(t=l/(2*g+c),g*=t,c*=t):(B=Math.floor((l+c)/(g+c)),t=(l-B*g)/(B-1),B=(l-(B+1)*g)/B,c=B<=0||Math.abs(c-t)<Math.abs(c-B)?t:B),w&&(3===s?this.ctx.setLineDash([0,g+c]):this.ctx.setLineDash([g,c])),3===s?(this.ctx.lineCap="round",this.ctx.lineWidth=e):this.ctx.lineWidth=2*e+1.1,this.ctx.strokeStyle=p(A),this.ctx.stroke(),this.ctx.setLineDash([]),2===s&&(D(r[0])&&(t=r[3],B=r[0],this.ctx.beginPath(),this.pathCallbacks.formatPath([new v(t.end.x,t.end.y),new v(B.start.x,B.start.y)]),this.ctx.stroke()),D(r[1]))&&(e=r[1],A=r[2],this.ctx.beginPath(),this.pathCallbacks.formatPath([new v(e.end.x,e.end.y),new v(A.start.x,A.start.y)]),this.ctx.stroke()),this.ctx.restore()}},Qo=class{constructor(A){this.ctx=A}renderBorderImage(A,e,t,r,s,B,n,i){var o=e.naturalWidth||e.width,a=e.naturalHeight||e.height;if(!(o<=0||a<=0)){var l=Math.min("percent"===t.unit?t.top/100*a:Math.min(t.top,a),a),g=Math.min("percent"===t.unit?t.right/100*o:Math.min(t.right,o),o),c=Math.min("percent"===t.unit?t.bottom/100*a:Math.min(t.bottom,a),a),w=Math.min("percent"===t.unit?t.left/100*o:Math.min(t.left,o),o),{left:A,top:Q,width:h,height:C}=A;if(!(h<=0||C<=0)){var d,u,s=Math.min(s,C),B=Math.min(B,h),n=Math.min(n,C-s),i=Math.min(i,h-B),r=(this.drawRegion(e,0,0,w,l,A,Q,i,s),this.drawRegion(e,o-g,0,g,l,A+h-B,Q,B,s),this.drawRegion(e,o-g,a-c,g,c,A+h-B,Q+C-n,B,n),this.drawRegion(e,0,a-c,w,c,A,Q+C-n,i,n),[{sx:w,sy:0,sw:o-w-g,sh:l,dx:A+i,dy:Q,dw:h-i-B,dh:s,repeat:r.horizontal},{sx:o-g,sy:l,sw:g,sh:a-l-c,dx:A+h-B,dy:Q+s,dw:B,dh:C-s-n,repeat:r.vertical},{sx:w,sy:a-c,sw:o-w-g,sh:c,dx:A+i,dy:Q+C-n,dw:h-i-B,dh:n,repeat:r.horizontal},{sx:0,sy:l,sw:w,sh:a-l-c,dx:A,dy:Q+s,dw:i,dh:C-s-n,repeat:r.vertical}]);for(d of r)d.sw<=0||d.sh<=0||d.dw<=0||d.dh<=0||(u=d.dw>=d.dh,0===d.repeat?this.ctx.drawImage(e,d.sx,d.sy,d.sw,d.sh,d.dx,d.dy,d.dw,d.dh):1!==d.repeat&&2!==d.repeat||this.drawRepeatedEdge(e,d,u,2===d.repeat));t.fill&&this.drawRegion(e,w,l,o-w-g,a-l-c,A+i,Q+s,h-i-B,C-s-n)}}}drawRegion(A,e,t,r,s,B,n,i,o){0<r&&0<s&&0<i&&0<o&&this.ctx.drawImage(A,e,t,r,s,B,n,i,o)}drawRepeatedEdge(r,s,B,A){var n=B?s.sw:s.sh,i=B?s.dw:s.dh;if(!(n<=0||i<=0)){let e,t;A?(t=Math.max(1,Math.round(i/n)),e=i/t):(e=n,t=Math.ceil(i/e)),this.ctx.save(),this.ctx.beginPath(),this.ctx.rect(s.dx,s.dy,s.dw,s.dh),this.ctx.clip();for(let A=0;A<t;A++){var o=A*e,a=Math.min(e,i-o);if(a<=0)break;B?this.ctx.drawImage(r,s.sx,s.sy,s.sw,s.sh,s.dx+o,s.dy,a,s.dh):this.ctx.drawImage(r,s.sx,s.sy,s.sw,s.sh,s.dx,s.dy+o,s.dw,a)}this.ctx.restore()}}},ho=class{constructor(A,e){this.activeEffects=[],this.ctx=A.ctx,this.pathCallback=e}applyEffects(A){for(;this.activeEffects.length;)this.popEffect();A.forEach(A=>this.applyEffect(A))}applyEffect(A){var e;this.ctx.save(),2===A.type?this.ctx.globalAlpha=A.opacity:0===A.type?(this.ctx.translate(A.offsetX,A.offsetY),this.ctx.transform(A.matrix[0],A.matrix[1],A.matrix[2],A.matrix[3],A.matrix[4],A.matrix[5]),this.ctx.translate(-A.offsetX,-A.offsetY)):Gi(A)?(this.pathCallback.path(A.path),this.ctx.clip()):3===A.type?A.applyClip(this.ctx):4===A.type?this.ctx.globalCompositeOperation=A.compositeOperation:5===A.type&&(e=A.filterString.replace(/drop-shadow\([^)]+\)\s*/g,"").trim(),this.ctx.filter=e||"none"),this.activeEffects.push(A)}popEffect(){this.activeEffects.pop(),this.ctx.restore()}getActiveEffectCount(){return this.activeEffects.length}hasActiveEffects(){return 0<this.activeEffects.length}};function Co(t,r,s,B,n,i){if(n instanceof Tn&&(o=Math.min(n.bounds.width,n.bounds.height),"checkbox"===n.type&&n.checked?(t.save(),B([new v(n.bounds.left+.39363*o,n.bounds.top+.79*o),new v(n.bounds.left+.16*o,n.bounds.top+.5549*o),new v(n.bounds.left+.27347*o,n.bounds.top+.44071*o),new v(n.bounds.left+.39694*o,n.bounds.top+.5649*o),new v(n.bounds.left+.72983*o,n.bounds.top+.23*o),new v(n.bounds.left+.84*o,n.bounds.top+.34085*o),new v(n.bounds.left+.39363*o,n.bounds.top+.79*o)]),t.fillStyle=p(Mn),t.fill(),t.restore()):"radio"===n.type&&n.checked&&(t.save(),t.beginPath(),t.arc(n.bounds.left+o/2,n.bounds.top+o/2,o/4,0,2*Math.PI,!0),t.fillStyle=p(Mn),t.fill(),t.restore())),(A=>{if(A instanceof kn)return true;else if(A instanceof On)return true;else if(A instanceof Tn&&A.type!=="radio"&&A.type!=="checkbox")return true;return false})(n)&&n.value.length){var[o,a,l]=s.createFontStyle(i),r=r.getMetrics(a,l).baseline,g=(t.font=o,t.fillStyle=n instanceof Tn&&n.isPlaceholder?p(1970632191):p(i.color),t.textBaseline="alphabetic",t.textAlign=(A=>{switch(A){case 1:return"center";case 2:return"right";default:return"left"}})(n.styles.textAlign),_i(n));let A=0;switch(n.styles.textAlign){case 1:A+=g.width/2;break;case 2:A+=g.width}let e=0;n instanceof Tn&&(a=f(i.fontSize,0),e=(g.height-a)/2);l=g.add(A,e,0,0);t.save(),B([new v(g.left,g.top),new v(g.left+g.width,g.top),new v(g.left+g.width,g.top+g.height),new v(g.left,g.top+g.height)]),t.clip(),s.renderTextWithLetterSpacing(new dn(n.value,l),i.letterSpacing,r,i.writingMode),t.restore(),t.textBaseline="alphabetic",t.textAlign="left"}}var uo=class uo{constructor(A,e){this.context=A,this.options=e,this.canvas=e.canvas||document.createElement("canvas");A=this.canvas.getContext("2d");if(!A)throw new Error("Failed to get 2D rendering context from canvas");this.ctx=A,e.canvas||(this.canvas.width=Math.floor(e.width*e.scale),this.canvas.height=Math.floor(e.height*e.scale),this.canvas.style.width=e.width+"px",this.canvas.style.height=e.height+"px"),this.fontMetrics=new eo(document),this.ctx.scale(this.options.scale,this.options.scale),this.ctx.translate(-e.x,-e.y),this.ctx.textBaseline="bottom",void 0!==e.imageSmoothing&&(this.ctx.imageSmoothingEnabled=e.imageSmoothing),e.imageSmoothingQuality&&(this.ctx.imageSmoothingQuality=e.imageSmoothingQuality),this.backgroundRenderer=new lo({ctx:this.ctx,context:this.context,canvas:this.canvas,options:{width:e.width,height:e.height,scale:e.scale}}),this.borderRenderer=new wo({ctx:this.ctx},{path:A=>this.path(A),formatPath:A=>this.formatPath(A)}),this.borderImageRenderer=new Qo(this.ctx),this.effectsRenderer=new ho({ctx:this.ctx},{path:A=>this.path(A)}),this.textRenderer=new io({ctx:this.ctx,context:this.context,options:{scale:e.scale}}),this.context.logger.debug(`Canvas renderer initialized (${e.width}x${e.height}) with scale `+e.scale)}async renderStack(A){A.element.container.styles.isVisible()&&await this.renderStackContent(A)}async renderNode(A){A.container.debugRender,A.container.styles.isVisible()&&(await this.renderNodeBackgroundAndBorders(A),await this.renderNodeContent(A))}renderReplacedElement(A,e,t){var r,s,B,n,i=t.naturalWidth||A.intrinsicWidth,o=t.naturalHeight||A.intrinsicHeight;t&&0<i&&0<o&&(r=_i(A),e=vi(e),{sx:e,sy:i,sw:o,sh:r,dx:A,dy:s,dw:B,dh:n}=(this.path(e),this.ctx.save(),this.ctx.clip(),((A,e,t,r,s)=>{let B=0,n=0,i=A,o=e,a=t.left,l=t.top,g=t.width,c=t.height;var w=g/c,Q=i/o,h=s?f(s[0],1):.5,s=s?f(s[1],1):.5;return 2===r?w<Q?(c=g/Q,l+=(t.height-c)*s):(g=c*Q,a+=(t.width-g)*h):4===r?w<Q?(i=o*w,B+=(A-i)*h):(o=i/w,n+=(e-o)*s):8===r?(i>g?(B+=(i-g)*h,i=g):(a+=(g-i)*h,g=i),o>c?(n+=(o-c)*s,o=c):(l+=(c-o)*s,c=o)):16===r&&((w<Q?g:c*Q)<(i>g?i:g)?w<Q?(c=g/Q,l+=(t.height-c)*s):(g=c*Q,a+=(t.width-g)*h):(i>g?(B+=(i-g)*h,i=g):(a+=(g-i)*h,g=i),o>c?(n+=(o-c)*s,o=c):(l+=(c-o)*s,c=o))),{sx:B,sy:n,sw:i,sh:o,dx:a,dy:l,dw:g,dh:c}})(i,o,r,A.styles.objectFit,A.styles.objectPosition)),this.ctx.drawImage(t,e,i,o,r,A,s,B,n),this.ctx.restore())}async renderNodeContent(A){this.effectsRenderer.applyEffects(A.getEffects(4));var e,t=A.container,r=A.curves,s=t.styles,B=_i(t);for(e of t.textNodes)await this.textRenderer.renderTextNode(e,s,B);var n=this.ctx,i=this.context,o={scale:this.options.scale,backgroundColor:this.options.backgroundColor,x:this.options.x,y:this.options.y,width:this.options.width,height:this.options.height},a=(A,e)=>new uo(A,e),l=t,g=s,c=(A,e,t)=>this.renderReplacedElement(A,e,t);if(l instanceof bn)try{var w=await i.cache.match(l.src),Q=n.imageSmoothingEnabled;2===g.imageRendering||1===g.imageRendering?n.imageSmoothingEnabled=!1:3===g.imageRendering&&(n.imageSmoothingEnabled=!0),c(l,r,w),n.imageSmoothingEnabled=Q}catch(A){i.logger.error("Error loading image "+l.src),i.onError?.(A instanceof Error?A:new Error(String(A)))}if(l instanceof Kn&&c(l,r,l.canvas),l instanceof xn)try{c(l,r,await i.cache.match(l.svg))}catch(A){i.logger.error("Error loading svg "+l.svg.substring(0,255)),i.onError?.(A instanceof Error?A:new Error(String(A)))}l instanceof Vn&&l.tree&&(g=await a(i,{scale:o.scale,backgroundColor:l.backgroundColor,x:0,y:0,width:l.width,height:l.height}).render(l.tree),l.width)&&l.height&&n.drawImage(g,0,0,l.width,l.height,l.bounds.left,l.bounds.top,l.bounds.width,l.bounds.height),await 0,Co(this.ctx,this.fontMetrics,this.textRenderer,this.path.bind(this),t,s);w=this.ctx,Q=this.context,c=this.textRenderer,r=A,a=t,i=s;if(E(a.styles.display,2048))if(null!==a.styles.listStyleImage){var h=a.styles.listStyleImage;if(0===h.type){h=h.url;try{var C=await Q.cache.match(h);w.drawImage(C,a.bounds.left-(C.width+10),a.bounds.top)}catch(A){Q.logger.error("Error loading list-style-image "+h),Q.onError?.(A instanceof Error?A:new Error(String(A)))}}}else r.listValue&&-1!==a.styles.listStyleType&&([C]=c.createFontStyle(i),w.font=C,w.fillStyle=p(i.color),w.textBaseline="middle",w.textAlign="right",h=new d(a.bounds.left,a.bounds.top+f(a.styles.paddingTop,a.bounds.width),a.bounds.width,Pr(i.lineHeight,i.fontSize.number)/2+1),c.renderTextWithLetterSpacing(new dn(r.listValue,h),i.letterSpacing,Pr(i.lineHeight,i.fontSize.number)/2+2,i.writingMode),w.textBaseline="bottom",w.textAlign="left")}async renderStackContent(A){A.element.container.debugRender;var e,t,r,s,B,n,i,o=this.options.signal;await this.renderNodeBackgroundAndBorders(A.element);for(e of A.negativeZIndex){if(o?.aborted)throw new DOMException("The operation was aborted.","AbortError");await this.renderStack(e)}if(o?.aborted)throw new DOMException("The operation was aborted.","AbortError");await this.renderNodeContent(A.element);for(t of A.nonInlineLevel)await this.renderNode(t);for(r of A.nonPositionedFloats){if(o?.aborted)throw new DOMException("The operation was aborted.","AbortError");await this.renderStack(r)}for(s of A.nonPositionedInlineLevel){if(o?.aborted)throw new DOMException("The operation was aborted.","AbortError");await this.renderStack(s)}for(B of A.inlineLevel)await this.renderNode(B);for(n of A.zeroOrAutoZIndexOrTransformedOrOpacity){if(o?.aborted)throw new DOMException("The operation was aborted.","AbortError");await this.renderStack(n)}for(i of A.positiveZIndex){if(o?.aborted)throw new DOMException("The operation was aborted.","AbortError");await this.renderStack(i)}}mask(A){this.ctx.beginPath(),this.ctx.moveTo(0,0),this.ctx.lineTo(this.options.width,0),this.ctx.lineTo(this.options.width,this.options.height),this.ctx.lineTo(0,this.options.height),this.ctx.lineTo(0,0),this.formatPath(A.slice(0).reverse()),this.ctx.closePath()}path(A){ao(this.ctx,A)}formatPath(A){oo(this.ctx,A)}async renderNodeBackgroundAndBorders(o){this.effectsRenderer.applyEffects(o.getEffects(2));var A=o.container.styles,e=!Qt(A.backgroundColor)||A.backgroundImage.length,t=[{style:A.borderTopStyle,color:A.borderTopColor,width:A.borderTopWidth},{style:A.borderRightStyle,color:A.borderRightColor,width:A.borderRightWidth},{style:A.borderBottomStyle,color:A.borderBottomColor,width:A.borderBottomWidth},{style:A.borderLeftStyle,color:A.borderLeftColor,width:A.borderLeftWidth}],r=Uo($i(A.backgroundClip,0),o.curves);if((e||A.boxShadow.length)&&(this.ctx.save(),this.path(r),this.ctx.clip(),Qt(A.backgroundColor)||(this.ctx.fillStyle=p(A.backgroundColor),this.ctx.fill()),await this.backgroundRenderer.renderBackgroundImage(o.container),this.ctx.restore(),A.boxShadow.slice(0).reverse().forEach(A=>{this.ctx.save();var t,r,s,B,e=Li(o.curves),n=A.inset?0:1e4,i=(t=-n+(A.inset?1:-1)*A.spread.number,r=(A.inset?1:-1)*A.spread.number,s=A.spread.number*(A.inset?-2:2),B=A.spread.number*(A.inset?-2:2),e.map((A,e)=>{switch(e){case 0:return A.add(t,r);case 1:return A.add(t+s,r);case 2:return A.add(t+s,r+B);case 3:return A.add(t,r+B)}return A}));A.inset?(this.path(e),this.ctx.clip(),this.mask(i)):(this.mask(e),this.ctx.clip(),this.path(i)),this.ctx.shadowOffsetX=A.offsetX.number+n,this.ctx.shadowOffsetY=A.offsetY.number,this.ctx.shadowColor=p(A.color),this.ctx.shadowBlur=A.blur.number,this.ctx.fillStyle=A.inset?p(A.color):"rgba(0,0,0,1)",this.ctx.fill(),this.ctx.restore()})),A.borderImageSource){e=A.borderImageSource;if(0===e.type){r=e.url;try{var s,B=await this.context.cache.match(r);B&&(s=o.container.bounds,this.borderImageRenderer.renderBorderImage(s,B,A.borderImageSlice,A.borderImageRepeat,Math.max(0,A.borderTopWidth),Math.max(0,A.borderRightWidth),Math.max(0,A.borderBottomWidth),Math.max(0,A.borderLeftWidth)))}catch(A){this.context.logger.error("Error loading border-image "+r)}}}else{let A=0;for(var n of t)0!==n.style&&!Qt(n.color)&&0<n.width&&(2===n.style?await this.borderRenderer.renderDashedDottedBorder(n.color,n.width,A,o.curves,2):3===n.style?await this.borderRenderer.renderDashedDottedBorder(n.color,n.width,A,o.curves,3):4===n.style?await this.borderRenderer.renderDoubleBorder(n.color,n.width,A,o.curves):await this.borderRenderer.renderSolidBorder(n.color,A,o.curves)),A++}}async render(A){this.options.backgroundColor&&(this.ctx.fillStyle=p(this.options.backgroundColor),this.ctx.fillRect(this.options.x,this.options.y,this.options.width,this.options.height));A=new Ni(A=A,null),e=new Ri(A),t=[],Wi(A,e,e,t),Yi(A.container,t);var e,t,A=e;return await this.renderStack(A),this.effectsRenderer.applyEffects([]),this.canvas}};let Uo=(A,e)=>{switch(A){case 0:return Li(e);case 2:return[e.topLeftContentBox,e.topRightContentBox,e.bottomRightContentBox,e.bottomLeftContentBox];default:return vi(e)}};var Fo=class{constructor(A,e){this.context=A,this.options=e,this.canvas=e.canvas||document.createElement("canvas");A=this.canvas.getContext("2d");if(!A)throw new Error("Failed to get 2D rendering context from canvas");this.ctx=A,this.canvas.width=Math.floor(e.width*e.scale),this.canvas.height=Math.floor(e.height*e.scale),this.canvas.style.width=e.width+"px",this.canvas.style.height=e.height+"px",this.ctx.scale(this.options.scale,this.options.scale),this.ctx.translate(-e.x,-e.y),this.context.logger.debug(`EXPERIMENTAL ForeignObject renderer initialized (${e.width}x${e.height} at ${e.x},${e.y}) with scale `+e.scale)}async render(A){if(this.options.signal?.aborted)throw new DOMException("The operation was aborted.","AbortError");A=await Cn(hn(this.options.width*this.options.scale,this.options.height*this.options.scale,this.options.scale,this.options.scale,A));return this.options.backgroundColor&&(this.ctx.fillStyle=p(this.options.backgroundColor),this.ctx.fillRect(0,0,this.options.width*this.options.scale,this.options.height*this.options.scale)),this.ctx.drawImage(A,-this.options.x*this.options.scale,-this.options.y*this.options.scale),this.canvas}},po=class{static{this.instances={}}constructor({id:A,enabled:e}){this.id=A,this.enabled=e,this.start=Date.now()}debug(...A){this.enabled&&("undefined"!=typeof window&&window.console&&"function"==typeof console.debug?console.debug(this.id,this.getTime()+"ms",...A):this.info(...A))}getTime(){return Date.now()-this.start}info(...A){this.enabled&&"undefined"!=typeof window&&window.console&&"function"==typeof console.info&&console.info(this.id,this.getTime()+"ms",...A)}warn(...A){this.enabled&&("undefined"!=typeof window&&window.console&&"function"==typeof console.warn?console.warn(this.id,this.getTime()+"ms",...A):this.info(...A))}error(...A){this.enabled&&("undefined"!=typeof window&&window.console&&"function"==typeof console.error?console.error(this.id,this.getTime()+"ms",...A):this.info(...A))}},fo=class{constructor(A,e){if(this.context=A,this._options=e,this._cache=new Map,this._pendingOperations=new Map,this.maxSize=e.maxCacheSize??100,this.maxSize<1)throw new Error("Cache maxSize must be at least 1");1e4<this.maxSize&&this.context.logger.warn(`Cache maxSize ${this.maxSize} is very large and may cause memory issues. Consider using a smaller value (recommended: 100-1000).`)}addImage(A){var e=this._pendingOperations.get(A);return e||(this.has(A)?(e=this._cache.get(A),this._cache.delete(A),this._cache.set(A,e),Promise.resolve()):Ko(A)||yo(A)?(e=this._addImageInternal(A),this._pendingOperations.set(A,e),e.finally(()=>{this._pendingOperations.delete(A)}),e):Promise.resolve())}async _addImageInternal(e){var A=this._options.imageTimeout??15e3,A=this.withTimeout(this.loadImage(e),A,`Timed out (${A}ms) loading image`);A.catch(A=>{this.context.logger.error(`Failed to load image ${e}: `+(A instanceof Error?A.message:"Unknown error"))}),this.set(e,A)}withTimeout(A,t,r){if(t<=0)return A;let s;var e=new Promise((A,e)=>{s=setTimeout(()=>e(new Error(r)),t)});return Promise.race([A,e]).finally(()=>{void 0!==s&&clearTimeout(s)})}match(A){var e=this._cache.get(A);if(e)return this._cache.delete(A),this._cache.set(A,e),e.value}set(A,e){var t;this._cache.has(A)?this._cache.delete(A):this._cache.size>=this.maxSize&&void 0!==(t=this._cache.keys().next().value)&&(this._cache.delete(t),this.context.logger.debug("Cache: Evicted LRU entry: "+t)),this._cache.set(A,{value:e})}size(){return this._cache.size}getMaxSize(){return this.maxSize}clear(){this._cache.clear()}async loadImage(A){let e=this.context.originChecker;var t=A=>e.isSameOrigin(A),t="function"==typeof this._options.customIsSameOrigin?await this._options.customIsSameOrigin(A,t):t(A);let s=!Io(A)&&!0===this._options.useCORS&&x.SUPPORT_CORS_IMAGES&&!t;var B=!Io(A)&&!t&&!Ko(A)&&"string"==typeof this._options.proxy&&x.SUPPORT_CORS_XHR&&!s;if(t||!1!==this._options.allowTaint||Io(A)||Ko(A)||B||s){let r=A;return B&&(r=await this.proxy(r)),this.context.logger.debug("Added image "+A.substring(0,256)),new Promise((A,e)=>{let t=new Image;t.onload=()=>A(t),t.onerror=e,(bo(r)||s)&&(t.crossOrigin="anonymous"),t.src=r,!0===t.complete&&setTimeout(()=>A(t),500)})}}has(A){return this._cache.has(A)}keys(){return Promise.resolve(Array.from(this._cache.keys()))}proxy(B){let n=this._options.proxy;if(!n)throw new Error("No proxy defined");let i=B.substring(0,256);return new Promise((e,t)=>{let A=x.SUPPORT_RESPONSE_TYPE?"blob":"text",r=new XMLHttpRequest;r.onload=()=>{if(200===r.status)if("text"==A)e(r.response);else{let A=new FileReader;A.addEventListener("load",()=>e(A.result),!1),A.addEventListener("error",A=>t(A),!1),A.readAsDataURL(r.response)}else t(`Failed to proxy resource ${i} with status code `+r.status)},r.onerror=t;var s=-1<n.indexOf("?")?"&":"?";if(r.open("GET",n+s+`url=${encodeURIComponent(B)}&responseType=`+A),"text"!=A&&r instanceof XMLHttpRequest&&(r.responseType=A),this._options.imageTimeout){let A=this._options.imageTimeout;r.timeout=A,r.ontimeout=()=>t(`Timed out (${A}ms) proxying `+i)}r.send()})}};let Ho=/^data:image\/svg\+xml/i,mo=/^data:image\/.*;base64,/i,Eo=/^data:image\/.*/i,yo=A=>x.SUPPORT_SVG_DRAWING||!xo(A),Io=A=>Eo.test(A),bo=A=>mo.test(A),Ko=A=>"blob"===A.substring(0,4),xo=A=>"svg"===A.slice(-3).toLowerCase()||Ho.test(A);var Lo=class{constructor(A){if(!A||!A.document)throw new Error("Valid window object required for OriginChecker");if(!A.location||!A.location.href)throw new Error("Window object must have valid location");this.link=A.document.createElement("a"),this.origin=this.getOrigin(A.location.href)}getOrigin(A){return this.link.href=A,this.link.href=this.link.href,this.link.protocol+this.link.hostname+this.link.port}isSameOrigin(A){return this.getOrigin(A)===this.origin}getContextOrigin(){return this.origin}},vo=class vo{static{this.instanceCount=1}constructor(A,e,t){this.windowBounds=e,this.instanceName="#"+vo.instanceCount++,this.config=t,this.logger=new po({id:this.instanceName,enabled:A.logging}),this.originChecker=new Lo(t.window),this.cache=A.cache??t.cache??new fo(this,A),this.onError=A.onError}};let Do=t=>{["scale","width","height","imageTimeout","x","y","windowWidth","windowHeight","scrollX","scrollY"].forEach(A=>{var e=t[A];null!=e&&"number"!=typeof e&&(e=Number(e),Number.isNaN(e)||(t[A]=e))})},So=(A,e,t)=>{var r=e.ownerDocument,s=r.documentElement?Jt(A,getComputedStyle(r.documentElement).backgroundColor):H.TRANSPARENT,B=r.body?Jt(A,getComputedStyle(r.body).backgroundColor):H.TRANSPARENT,A="string"==typeof t?Jt(A,t):null===t?H.TRANSPARENT:4294967295;return e===r.documentElement?Qt(s)?Qt(B)?A:B:s:A};t=(A,e={},t)=>(async(A,e,t)=>{if(Do(e),!e.skipValidation){var r=e.validator||V(),s=r.validateElement(A);if(!s.valid)throw new Error(s.error);s=r.validateOptions(e);if(!s.valid)throw new Error("Invalid options: "+s.error)}if(!A||"object"!=typeof A)throw new Error("Invalid element provided as first argument");r=A.ownerDocument;if(!r)throw new Error("Element is not attached to a Document");s=r.defaultView;if(!s)throw new Error("Document is not attached to a Window");var B={logging:e.logging??!0,cache:e.cache??t.cache,...{allowTaint:e.allowTaint??!1,imageTimeout:e.imageTimeout??15e3,proxy:e.proxy,useCORS:e.useCORS??!1,customIsSameOrigin:e.customIsSameOrigin,maxCacheSize:e.maxCacheSize}},n={windowWidth:e.windowWidth??s.innerWidth??800,windowHeight:e.windowHeight??s.innerHeight??600,scrollX:e.scrollX??s.pageXOffset??0,scrollY:e.scrollY??s.pageYOffset??0},i=new d(n.scrollX,n.scrollY,n.windowWidth,n.windowHeight),B=new vo(B,i,t),o=e.enablePerformanceMonitoring??e.logging??!1,a=new G(B,o),n=(a.start("total",{width:n.windowWidth,height:n.windowHeight}),e.signal);if(n?.aborted)throw new DOMException("The operation was aborted.","AbortError");var l=e.foreignObjectRendering??!1,t={allowTaint:e.allowTaint??!1,onclone:e.onclone,ignoreElements:e.ignoreElements,iframeContainer:e.iframeContainer,inlineImages:l,copyStyles:l,cspNonce:e.cspNonce??t.cspNonce},A=(B.logger.debug(`Starting document clone with size ${i.width}x${i.height} scrolled to ${-i.left},`+-i.top),a.start("clone"),new gi(B,A,t)),t=A.clonedReferenceElement;if(!t)throw new Error("Unable to find element in cloned iframe");A=await A.toIFrame(r,i);if(a.end("clone"),n?.aborted)throw(e.removeContainer??!0)&&gi.destroy(A),new DOMException("The operation was aborted.","AbortError");var{width:r,height:i,left:g,top:c}=UB(t)||dB(t)?N(t.ownerDocument):R(B,t),w=So(B,t,e.backgroundColor),s={canvas:e.canvas,backgroundColor:w,signal:n,scale:e.scale??s.devicePixelRatio??1,x:(e.x??0)+g,y:(e.y??0)+c,width:e.width??Math.ceil(r),height:e.height??Math.ceil(i),imageSmoothing:e.imageSmoothing,imageSmoothingQuality:e.imageSmoothingQuality};let Q,h;try{if(l)B.logger.debug("Document cloned, using foreign object rendering"),a.start("render-foreignobject"),Q=await new Fo(B,s).render(t),a.end("render-foreignobject");else{if(B.logger.debug(`Document cloned, element located at ${g},${c} with size ${r}x${i} using computed rendering`),B.logger.debug("Starting DOM parsing"),a.start("parse"),n?.aborted)throw new DOMException("The operation was aborted.","AbortError");if(h=Pn(B,t),a.end("parse"),w===h.styles.backgroundColor&&(h.styles.backgroundColor=H.TRANSPARENT),B.logger.debug(`Starting renderer for element at ${s.x},${s.y} with size ${s.width}x`+s.height),a.start("render"),n?.aborted)throw new DOMException("The operation was aborted.","AbortError");Q=await new uo(B,s).render(h),a.end("render")}return a.start("cleanup"),(e.removeContainer??!0)&&!gi.destroy(A)&&B.logger.error("Cannot detach cloned iframe as it is not in the DOM anymore"),a.end("cleanup"),a.end("total"),B.logger.debug("Finished rendering"),o&&a.logSummary(),Q}finally{h&&h.restoreTree()}})(A,e,t||O.fromElement(A,{cspNonce:e.cspNonce,cache:e.cache}));T.Html2CanvasConfig=O,T.PerformanceMonitor=G,T.Validator=k,T.createDefaultValidator=V,T.default=t,T.html2canvas=t}),"undefined"!=typeof window&&window.html2canvas&&window.html2canvas.default&&(window.html2canvas=window.html2canvas.default);
|
|
11
|
+
.${fi}:after`+Hi,e)},Ei=(A,e,t)=>{var r=A.ownerDocument;r&&((r=r.createElement("style")).textContent=e,t&&(r.nonce=t),A.appendChild(r))},yi=(A,e)=>{var t=A.ownerDocument.createElement("base"),e=(t.href=e,A.getElementsByTagName("head").item(0));e?.insertBefore(t,e?.firstChild??null)},Ii=(A,t)=>A.length===t.length&&A.some((A,e)=>A===t[e]);var v=class v{constructor(A,e){this.type=0,this.x=A,this.y=e}add(A,e){return new v(this.x+A,this.y+e)}};let bi=(A,e,t)=>new v(A.x+(e.x-A.x)*t,A.y+(e.y-A.y)*t);var Ki=class Ki{constructor(A,e,t,r){this.type=1,this.start=A,this.startControl=e,this.endControl=t,this.end=r}subdivide(A,e){var t=bi(this.start,this.startControl,A),r=bi(this.startControl,this.endControl,A),s=bi(this.endControl,this.end,A),B=bi(t,r,A),r=bi(r,s,A),A=bi(B,r,A);return e?new Ki(this.start,t,B,A):new Ki(A,r,s,this.end)}add(A,e){return new Ki(this.start.add(A,e),this.startControl.add(A,e),this.endControl.add(A,e),this.end.add(A,e))}reverse(){return new Ki(this.end,this.endControl,this.startControl,this.start)}};let D=A=>1===A.type;var xi=class{constructor(A){var e=A.styles,t=A.bounds;let[r,s]=nt(e.borderTopLeftRadius,t.width,t.height),[B,n]=nt(e.borderTopRightRadius,t.width,t.height),[i,o]=nt(e.borderBottomRightRadius,t.width,t.height),[a,l]=nt(e.borderBottomLeftRadius,t.width,t.height);var g=[],g=(g.push((r+B)/t.width),g.push((a+i)/t.width),g.push((s+l)/t.height),g.push((n+o)/t.height),Math.max(...g)),g=(1<g&&(r/=g,s/=g,B/=g,n/=g,i/=g,o/=g,a/=g,l/=g),t.width-B),c=t.height-o,w=t.width-i,Q=t.height-l,h=e.borderTopWidth,C=e.borderRightWidth,d=e.borderBottomWidth,u=e.borderLeftWidth,U=f(e.paddingTop,A.bounds.width),F=f(e.paddingRight,A.bounds.width),p=f(e.paddingBottom,A.bounds.width),e=f(e.paddingLeft,A.bounds.width);this.topLeftBorderDoubleOuterBox=0<r||0<s?S(t.left+u/3,t.top+h/3,r-u/3,s-h/3,0):new v(t.left+u/3,t.top+h/3),this.topRightBorderDoubleOuterBox=0<r||0<s?S(t.left+g,t.top+h/3,B-C/3,n-h/3,1):new v(t.left+t.width-C/3,t.top+h/3),this.bottomRightBorderDoubleOuterBox=0<i||0<o?S(t.left+w,t.top+c,i-C/3,o-d/3,2):new v(t.left+t.width-C/3,t.top+t.height-d/3),this.bottomLeftBorderDoubleOuterBox=0<a||0<l?S(t.left+u/3,t.top+Q,a-u/3,l-d/3,3):new v(t.left+u/3,t.top+t.height-d/3),this.topLeftBorderDoubleInnerBox=0<r||0<s?S(t.left+2*u/3,t.top+2*h/3,r-2*u/3,s-2*h/3,0):new v(t.left+2*u/3,t.top+2*h/3),this.topRightBorderDoubleInnerBox=0<r||0<s?S(t.left+g,t.top+2*h/3,B-2*C/3,n-2*h/3,1):new v(t.left+t.width-2*C/3,t.top+2*h/3),this.bottomRightBorderDoubleInnerBox=0<i||0<o?S(t.left+w,t.top+c,i-2*C/3,o-2*d/3,2):new v(t.left+t.width-2*C/3,t.top+t.height-2*d/3),this.bottomLeftBorderDoubleInnerBox=0<a||0<l?S(t.left+2*u/3,t.top+Q,a-2*u/3,l-2*d/3,3):new v(t.left+2*u/3,t.top+t.height-2*d/3),this.topLeftBorderStroke=0<r||0<s?S(t.left+u/2,t.top+h/2,r-u/2,s-h/2,0):new v(t.left+u/2,t.top+h/2),this.topRightBorderStroke=0<r||0<s?S(t.left+g,t.top+h/2,B-C/2,n-h/2,1):new v(t.left+t.width-C/2,t.top+h/2),this.bottomRightBorderStroke=0<i||0<o?S(t.left+w,t.top+c,i-C/2,o-d/2,2):new v(t.left+t.width-C/2,t.top+t.height-d/2),this.bottomLeftBorderStroke=0<a||0<l?S(t.left+u/2,t.top+Q,a-u/2,l-d/2,3):new v(t.left+u/2,t.top+t.height-d/2),this.topLeftBorderBox=0<r||0<s?S(t.left,t.top,r,s,0):new v(t.left,t.top),this.topRightBorderBox=0<B||0<n?S(t.left+g,t.top,B,n,1):new v(t.left+t.width,t.top),this.bottomRightBorderBox=0<i||0<o?S(t.left+w,t.top+c,i,o,2):new v(t.left+t.width,t.top+t.height),this.bottomLeftBorderBox=0<a||0<l?S(t.left,t.top+Q,a,l,3):new v(t.left,t.top+t.height),this.topLeftPaddingBox=0<r||0<s?S(t.left+u,t.top+h,Math.max(0,r-u),Math.max(0,s-h),0):new v(t.left+u,t.top+h),this.topRightPaddingBox=0<B||0<n?S(t.left+Math.min(g,t.width-C),t.top+h,g>t.width+C?0:Math.max(0,B-C),Math.max(0,n-h),1):new v(t.left+t.width-C,t.top+h),this.bottomRightPaddingBox=0<i||0<o?S(t.left+Math.min(w,t.width-u),t.top+Math.min(c,t.height-d),Math.max(0,i-C),Math.max(0,o-d),2):new v(t.left+t.width-C,t.top+t.height-d),this.bottomLeftPaddingBox=0<a||0<l?S(t.left+u,t.top+Math.min(Q,t.height-d),Math.max(0,a-u),Math.max(0,l-d),3):new v(t.left+u,t.top+t.height-d),this.topLeftContentBox=0<r||0<s?S(t.left+u+e,t.top+h+U,Math.max(0,r-(u+e)),Math.max(0,s-(h+U)),0):new v(t.left+u+e,t.top+h+U),this.topRightContentBox=0<B||0<n?S(t.left+Math.min(g,t.width+u+e),t.top+h+U,g>t.width+u+e?0:B-u+e,n-(h+U),1):new v(t.left+t.width-(C+F),t.top+h+U),this.bottomRightContentBox=0<i||0<o?S(t.left+Math.min(w,t.width-(u+e)),t.top+Math.min(c,t.height+h+U),Math.max(0,i-(C+F)),o-(d+p),2):new v(t.left+t.width-(C+F),t.top+t.height-(d+p)),this.bottomLeftContentBox=0<a||0<l?S(t.left+u+e,t.top+Q,Math.max(0,a-(u+e)),l-(d+p),3):new v(t.left+u+e,t.top+t.height-(d+p))}};let S=(A,e,t,r,s)=>{var B=(Math.sqrt(2)-1)/3*4,n=t*B,i=r*B,o=A+t,a=e+r;switch(s){case 0:return new Ki(new v(A,a),new v(A,a-i),new v(o-n,e),new v(o,e));case 1:return new Ki(new v(A,e),new v(A+n,e),new v(o,a-i),new v(o,a));case 2:return new Ki(new v(o,e),new v(o,e+i),new v(A+n,a),new v(A,a));default:return new Ki(new v(o,a),new v(o-n,a),new v(A,e+i),new v(A,e))}},Li=A=>[A.topLeftBorderBox,A.topRightBorderBox,A.bottomRightBorderBox,A.bottomLeftBorderBox],vi=A=>[A.topLeftPaddingBox,A.topRightPaddingBox,A.bottomRightPaddingBox,A.bottomLeftPaddingBox];var Di=class{constructor(A,e,t){this.offsetX=A,this.offsetY=e,this.matrix=t,this.type=0,this.target=6}},Si=class{constructor(A,e){this.path=A,this.target=e,this.type=1}},Mi=class{constructor(A){this.opacity=A,this.type=2,this.target=6}},Ti=class{constructor(A){this.applyClip=A,this.type=3,this.target=6}};let Oi={[y.NORMAL]:"source-over",[y.MULTIPLY]:"multiply",[y.SCREEN]:"screen",[y.OVERLAY]:"overlay",[y.DARKEN]:"darken",[y.LIGHTEN]:"lighten",[y.COLOR_DODGE]:"color-dodge",[y.COLOR_BURN]:"color-burn",[y.HARD_LIGHT]:"hard-light",[y.SOFT_LIGHT]:"soft-light",[y.DIFFERENCE]:"difference",[y.EXCLUSION]:"exclusion",[y.HUE]:"hue",[y.SATURATION]:"saturation",[y.COLOR]:"color",[y.LUMINOSITY]:"luminosity"};var ki=class{constructor(A){this.mixBlendMode=A,this.type=4,this.target=6,this.compositeOperation=Oi[A]}},Vi=class{constructor(A){this.type=5,this.target=6;var e=A.match(/drop-shadow\(\s*([\d.-]+)(px)?\s+([\d.-]+)(px)?\s+([\d.-]+)(px)?\s+(.+?)\s*\)/);e?(this.shadow={offsetX:parseFloat(e[1]),offsetY:parseFloat(e[3]),blur:parseFloat(e[5]),color:e[7].trim()},this.safeFilterString=A.replace(/drop-shadow\([^)]+\)\s*/g,"").trim()):this.safeFilterString=A}};let Gi=A=>1===A.type;var Ri=class{constructor(A){this.element=A,this.inlineLevel=[],this.nonInlineLevel=[],this.negativeZIndex=[],this.zeroOrAutoZIndexOrTransformedOrOpacity=[],this.positiveZIndex=[],this.nonPositionedFloats=[],this.nonPositionedInlineLevel=[]}},Ni=class{constructor(A,e){var t,r;this.container=A,this.parent=e,this.effects=[],this.curves=new xi(this.container),this.container.styles.opacity<1&&this.effects.push(new Mi(this.container.styles.opacity)),null!==this.container.styles.rotate&&(A=this.container.styles.transformOrigin,e=this.container.bounds.left+f(A[0],this.container.bounds.width),A=this.container.bounds.top+f(A[1],this.container.bounds.height),r=this.container.styles.rotate*Math.PI/180,t=Math.cos(r),r=Math.sin(r),this.effects.push(new Di(e,A,[t,r,-r,t,0,0]))),null!==this.container.styles.transform&&(e=this.container.styles.transformOrigin,A=this.container.bounds.left+f(e[0],this.container.bounds.width),r=this.container.bounds.top+f(e[1],this.container.bounds.height),t=this.container.styles.transform,this.effects.push(new Di(A,r,t))),Pi(this.container.styles)&&(e=Li(this.curves),A=vi(this.curves),Ii(e,A)?this.effects.push(new Si(e,6)):(this.effects.push(new Si(e,2)),this.effects.push(new Si(A,4)))),0!==this.container.styles.clipPath.type&&(r=Ji(this.container.styles.clipPath,this.container.bounds))&&this.effects.push(r),this.container.styles.mixBlendMode!==y.NORMAL&&this.effects.push(new ki(this.container.styles.mixBlendMode)),null!==this.container.styles.filter&&this.effects.push(new Vi(this.container.styles.filter)),1!==this.container.styles.zoom&&(t=this.container.styles.transformOrigin,e=this.container.bounds.left+f(t[0],this.container.bounds.width),A=this.container.bounds.top+f(t[1],this.container.bounds.height),r=this.container.styles.zoom,this.effects.push(new Di(e,A,[r,0,0,r,0,0])))}getEffects(e){let A=-1===[2,3].indexOf(this.container.styles.position),t=this.parent;for(var r=this.effects.slice(0);t;){var s,B,n=t.effects.filter(A=>!Gi(A));!A&&0===t.container.styles.position&&t.parent||(A=-1===[2,3].indexOf(t.container.styles.position),!Pi(t.container.styles))||(s=Li(t.curves),B=vi(t.curves),Ii(s,B))||r.unshift(new Si(B,6)),r.unshift(...n),t=t.parent}return r.filter(A=>E(A.target,e))}};let Pi=A=>0!==A.overflowX||0!==A.overflowY,Xi=(A,e,t,r,s)=>"closest-side"===A?Math.min(e-t,r-e):"farthest-side"===A?Math.max(e-t,r-e):f(A,s),Ji=(A,e)=>{let{left:B,top:n,width:i,height:o}=e;switch(A.type){case 1:{var a=f(A.left,i),l=f(A.top,o);let e=B+a,t=n+l,r=Math.max(0,i-a-f(A.right,i)),s=Math.max(0,o-l-f(A.bottom,o));return new Ti(A=>{A.beginPath(),A.rect(e,t,r,s),A.clip()})}case 2:{let e=B+f(A.cx,i),t=n+f(A.cy,o),r;return r="closest-side"===A.radius?Math.min(e-B,t-n,B+i-e,n+o-t):"farthest-side"===A.radius?Math.max(e-B,t-n,B+i-e,n+o-t):f(A.radius,Math.sqrt(i*i+o*o)/Math.SQRT2),new Ti(A=>{A.beginPath(),A.arc(e,t,Math.max(0,r),0,2*Math.PI),A.clip()})}case 3:{let e=B+f(A.cx,i),t=n+f(A.cy,o),r=Xi(A.rx,e,B,B+i,i),s=Xi(A.ry,t,n,n+o,o);return new Ti(A=>{A.beginPath(),A.ellipse(e,t,Math.max(0,r),Math.max(0,s),0,0,2*Math.PI),A.clip()})}case 4:{let t=A.points.map(([A,e])=>[B+f(A,i),n+f(e,o)]);return new Ti(e=>{if(e.beginPath(),0<t.length){e.moveTo(t[0][0],t[0][1]);for(let A=1;A<t.length;A++)e.lineTo(t[A][0],t[A][1]);e.closePath()}e.clip()})}case 5:{let t=A.d,r=null;return new Ti(A=>{try{r=r||new Path2D(t);var e=A.getTransform();A.translate(B,n),A.clip(r),A.setTransform(e)}catch(A){}})}default:return null}},Wi=(n,i,o,a)=>{n.container.elements.forEach(A=>{var e=A.createsRealStackingContext,s=A.createsStackingContext,t=new Ni(A,n),r=(E(A.styles.display,2048)&&a.push(t),A.isListOwner?[]:a);if(e||s){var s=e||A.styles.isPositioned()?o:i,B=new Ri(t);if(A.styles.isPositioned()||A.styles.opacity<1||A.styles.isTransformed()){let r=A.styles.zIndex.order;if(r<0){let t=0;s.negativeZIndex.some((A,e)=>r>A.element.container.styles.zIndex.order?(t=e,!1):0<t),s.negativeZIndex.splice(t,0,B)}else if(0<r){let t=0;s.positiveZIndex.some((A,e)=>r>=A.element.container.styles.zIndex.order?(t=e+1,!1):0<t),s.positiveZIndex.splice(t,0,B)}else s.zeroOrAutoZIndexOrTransformedOrOpacity.push(B)}else(A.styles.isFloating()?s.nonPositionedFloats:s.nonPositionedInlineLevel).push(B);Wi(t,B,e?B:o,r)}else(A.styles.isInlineLevel()?i.inlineLevel:i.nonInlineLevel).push(t),Wi(t,i,o,r);A.isListOwner&&Yi(A,r)})},Yi=(A,e)=>{let t=A instanceof vn?A.start:1;var r=A instanceof vn&&A.reversed;for(let A=0;A<e.length;A++){var s=e[A];s.container instanceof Ln&&"number"==typeof s.container.value&&0!==s.container.value&&(t=s.container.value),s.listValue=ai(t,s.container.styles.listStyleType,!0),t+=r?-1:1}},Zi=A=>{var e=A.bounds,A=A.styles;return e.add(A.borderLeftWidth,A.borderTopWidth,-(A.borderRightWidth+A.borderLeftWidth),-(A.borderTopWidth+A.borderBottomWidth))},_i=A=>{var e=A.styles,A=A.bounds,t=f(e.paddingLeft,A.width),r=f(e.paddingRight,A.width),s=f(e.paddingTop,A.width),B=f(e.paddingBottom,A.width);return A.add(t+e.borderLeftWidth,s+e.borderTopWidth,-(e.borderRightWidth+e.borderLeftWidth+t+r),-(e.borderTopWidth+e.borderBottomWidth+s+B))},zi=(A,e,t)=>{r=$i(A.styles.backgroundOrigin,e),s=A;var r=0===r?s.bounds:(2===r?_i:Zi)(s),s=(s=$i(A.styles.backgroundClip,e),B=A,0===s?B.bounds:(2===s?_i:Zi)(B)),B=((A,[e,t,r],s)=>{const[B,n]=A;if(!B)return[0,0];if(u(B)&&n&&u(n))return[f(B,s.width),f(n,s.height)];const i=ji(r);if(h(B)&&(B.value==="contain"||B.value==="cover")){if(ji(r))return s.width/s.height<r!==(B.value==="cover")?[s.width,s.width/r]:[s.height*r,s.height];return[s.width,s.height]}const o=ji(e),a=ji(t),l=o||a;if(qi(B)&&(!n||qi(n))){if(o&&a)return[e,t];if(!i&&!l)return[s.width,s.height];if(l&&i)return[o?e:t*r,a?t:e/r];return[o?e:s.width,a?t:s.height]}if(i){let A=0;let e=0;if(u(B))A=f(B,s.width);else if(u(n))e=f(n,s.height);if(qi(B))A=e*r;else if(!n||qi(n))e=A/r;return[A,e]}let g=null,c=null;if(u(B))g=f(B,s.width);else if(n&&u(n))c=f(n,s.height);if(g!==null&&(!n||qi(n)))c=o&&a?g/e*t:s.height;if(c!==null&&qi(B))g=o&&a?c/t*e:s.width;if(g!==null&&c!==null)return[g,c];throw new Error(`Unable to calculate background-size for element`)})($i(A.styles.backgroundSize,e),t,r),[t,n]=B,i=nt($i(A.styles.backgroundPosition,e),r.width-t,r.height-n);return[((A,[e,t],[r,s],B,n)=>{switch(A){case 2:return[new v(Math.round(B.left),Math.round(B.top+t)),new v(Math.round(B.left+B.width),Math.round(B.top+t)),new v(Math.round(B.left+B.width),Math.round(s+B.top+t)),new v(Math.round(B.left),Math.round(s+B.top+t))];case 3:return[new v(Math.round(B.left+e),Math.round(B.top)),new v(Math.round(B.left+e+r),Math.round(B.top)),new v(Math.round(B.left+e+r),Math.round(B.height+B.top)),new v(Math.round(B.left+e),Math.round(B.height+B.top))];case 1:return[new v(Math.round(B.left+e),Math.round(B.top+t)),new v(Math.round(B.left+e+r),Math.round(B.top+t)),new v(Math.round(B.left+e+r),Math.round(B.top+t+s)),new v(Math.round(B.left+e),Math.round(B.top+t+s))];default:return[new v(Math.round(n.left),Math.round(n.top)),new v(Math.round(n.left+n.width),Math.round(n.top)),new v(Math.round(n.left+n.width),Math.round(n.height+n.top)),new v(Math.round(n.left),Math.round(n.height+n.top))]}})($i(A.styles.backgroundRepeat,e),i,B,r,s),Math.round(r.left+i[0]),Math.round(r.top+i[1]),Math.max(1,t),Math.max(1,n)]},qi=A=>h(A)&&"auto"===A.value,ji=A=>"number"==typeof A,$i=(A,e)=>{e=A[e];return void 0===e?A[0]:e},Ao="Hidden Text";var eo=class{constructor(A){this._data={},this._document=A}parseMetrics(A,e){var t=this._document.createElement("div"),r=this._document.createElement("img"),s=this._document.createElement("span"),B=this._document.body,A=(t.style.visibility="hidden",t.style.fontFamily=A,t.style.fontSize=e,t.style.margin="0",t.style.padding="0",t.style.whiteSpace="nowrap",B.appendChild(t),r.src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",r.width=1,r.height=1,r.style.margin="0",r.style.padding="0",r.style.verticalAlign="baseline",s.style.fontFamily=A,s.style.fontSize=e,s.style.margin="0",s.style.padding="0",s.appendChild(this._document.createTextNode(Ao)),t.appendChild(s),t.appendChild(r),r.offsetTop-s.offsetTop+2),e=(t.removeChild(s),t.appendChild(this._document.createTextNode(Ao)),t.style.lineHeight="normal",r.style.verticalAlign="super",r.offsetTop-t.offsetTop+2);return B.removeChild(t),{baseline:A,middle:e}}getMetrics(A,e){var t=A+" "+e;return void 0===this._data[t]&&(this._data[t]=this.parseMetrics(A,e)),this._data[t]}},to=class{constructor(A){this.ctx=A}render(t,A){this.ctx.fillStyle=p(A.textDecorationColor||A.color);let r=1,s=("number"==typeof A.textDecorationThickness?r=A.textDecorationThickness:"from-font"===A.textDecorationThickness&&(r=Math.max(1,Math.floor(.05*A.fontSize.number))),0),B=("number"==typeof A.textUnderlineOffset&&(s=A.textUnderlineOffset),A.textDecorationStyle);A.textDecorationLine.forEach(A=>{let e=0;switch(A){case 1:e=t.top+t.height-r+s;break;case 2:e=t.top;break;case 3:e=t.top+(t.height/2-r/2);break;default:return}this.draw(t.left,e,t.width,r,B)})}draw(A,e,t,r,s){switch(s){case 0:this.ctx.fillRect(A,e,t,r);break;case 1:var B=Math.max(1,r);this.ctx.fillRect(A,e,t,r),this.ctx.fillRect(A,e+r+B,t,r);break;case 2:this.drawPattern(A,e,t,r,[r,2*r]);break;case 3:this.drawPattern(A,e,t,r,[3*r,2*r]);break;case 4:this.drawWavy(A,e,t,r);break;default:this.ctx.fillRect(A,e,t,r)}}drawPattern(A,e,t,r,s){this.ctx.save(),this.ctx.beginPath(),this.ctx.setLineDash(s),this.ctx.lineWidth=r,this.ctx.strokeStyle=this.ctx.fillStyle,this.ctx.moveTo(A,e+r/2),this.ctx.lineTo(A+t,e+r/2),this.ctx.stroke(),this.ctx.restore()}drawWavy(A,e,t,r){this.ctx.save(),this.ctx.beginPath(),this.ctx.lineWidth=r,this.ctx.strokeStyle=this.ctx.fillStyle;var s=2*r,B=4*r;let n=A;for(this.ctx.moveTo(n,e+r/2);n<A+t;){var i=Math.min(n+B/2,A+t);this.ctx.quadraticCurveTo(n+B/4,e+r/2-s,i,e+r/2),(n=i)<A+t&&(i=Math.min(n+B/2,A+t),this.ctx.quadraticCurveTo(n+B/4,e+r/2+s,i,e+r/2),n=i)}this.ctx.stroke(),this.ctx.restore()}};let ro=["-apple-system","system-ui"],so=/[\u2E80-\u2FFF\u3000-\u30FF\u3400-\u4DBF\u4E00-\u9FFF\uAC00-\uD7AF\uF900-\uFAFF\uFF01-\uFFEF]/,Bo=A=>so.test(A),no=A=>{var e=(()=>{if("undefined"!=typeof navigator){var A=navigator.userAgent,e=/iPhone|iPad|iPod/.test(A),t=/Macintosh/.test(A)&&navigator.maxTouchPoints&&1<navigator.maxTouchPoints;if(e||t)for(var r of[/(?:iPhone|CPU(?:\siPhone)?)\sOS\s(\d+)[\._](\d+)/,/Version\/(\d+)\.(\d+)/]){r=A.match(r);if(r&&r[1])return parseInt(r[1],10)}}return null})();return null!==e&&15<=e&&e<17?A.map(A=>-1!==ro.indexOf(A)?'-apple-system, "Helvetica Neue", Arial, sans-serif':A):A};var io=class{constructor(A){this.ctx=A.ctx,this.options=A.options,this.decorationRenderer=new to(A.ctx)}iterateLettersWithLetterSpacing(e,t,r,s,B){if(Qs(s))this.iterateVerticalGlyphs(e,t,r,s,B);else{var n,i,s=Fn(e.text),o=e.bounds.top+r;let A=e.bounds.left;for(n of s)Bo(n)?(i=this.ctx.textBaseline,this.ctx.textBaseline="ideographic",B(n,A,o),this.ctx.textBaseline=i):B(n,A,o),A+=this.ctx.measureText(n).width+t}}iterateVerticalGlyphs(A,e,t,r,s){var B,n,i=Fn(A.text);let o=A.bounds.top;for(B of i)3===(n=r)||4===n||!Bo(B)&&0<B.trim().length?(this.ctx.save(),this.ctx.translate(A.bounds.left+t,o),this.ctx.rotate(4===r?-Math.PI/2:Math.PI/2),s(B,0,0),this.ctx.restore()):(n=this.ctx.textBaseline,Bo(B)&&(this.ctx.textBaseline="ideographic"),s(B,A.bounds.left,o+t),this.ctx.textBaseline=n),o+=this.ctx.measureText(B).width+e}renderTextWithLetterSpacing(A,e,t,r=0){this.renderFillText(A,e,t,r)}canRenderWholeText(A,e){return 0===A&&!Qs(e)}renderFillText(A,e,t,r){this.canRenderWholeText(e,r)?this.ctx.fillText(A.text,A.bounds.left,A.bounds.top+t):this.iterateLettersWithLetterSpacing(A,e,t,r,(A,e,t)=>{this.ctx.fillText(A,e,t)})}renderStrokeText(A,e,t,r){this.canRenderWholeText(e,r)?this.ctx.strokeText(A.text,A.bounds.left,A.bounds.top+t):this.iterateLettersWithLetterSpacing(A,e,t,r,(A,e,t)=>{this.ctx.strokeText(A,e,t)})}renderTextStrokeWithStyle(A,e){e.webkitTextStrokeWidth&&A.text.trim().length&&(this.ctx.strokeStyle=p(e.webkitTextStrokeColor),this.ctx.lineWidth=e.webkitTextStrokeWidth,this.ctx.lineJoin=("undefined"!=typeof window?window:void 0)?.chrome?"miter":"round",this.renderStrokeText(A,e.letterSpacing,e.fontSize.number,e.writingMode),this.ctx.strokeStyle="",this.ctx.lineWidth=0,this.ctx.lineJoin="miter")}renderTextFillWithShadows(e,t){this.ctx.fillStyle=p(t.color),this.renderTextWithLetterSpacing(e,t.letterSpacing,t.fontSize.number,t.writingMode);var A=t.textShadow;A.length&&e.text.trim().length&&(A.slice(0).reverse().forEach(A=>{this.ctx.shadowColor=p(A.color),this.ctx.shadowOffsetX=A.offsetX.number*this.options.scale,this.ctx.shadowOffsetY=A.offsetY.number*this.options.scale,this.ctx.shadowBlur=A.blur.number,this.renderTextWithLetterSpacing(e,t.letterSpacing,t.fontSize.number,t.writingMode)}),this.ctx.shadowColor="",this.ctx.shadowOffsetX=0,this.ctx.shadowOffsetY=0,this.ctx.shadowBlur=0)}renderTextBoundWithPaintOrder(e,t,A){A.forEach(A=>{switch(A){case 0:this.ctx.fillStyle=p(t.color),this.renderTextWithLetterSpacing(e,t.letterSpacing,t.fontSize.number,t.writingMode);break;case 1:this.renderTextStrokeWithStyle(e,t)}})}renderTextDecoration(A,e){this.decorationRenderer.render(A,e)}truncateTextWithEllipsis(A,t,e){let r=this.ctx.measureText("…").width,s=Fn(A);if(0===e){var B=A=>this.ctx.measureText(s.slice(0,A).join("")).width+r<=t;let A=0,e=s.length;for(;A<e;){var n=A+e+1>>1;B(n)?A=n:e=n-1}return s.slice(0,A).join("")+"…"}{let A=r;var i,o=[];for(i of s){var a=this.ctx.measureText(i).width;if(A+a>t)break;o.push(i),A+=a+e}return o.join("")+"…"}}createFontStyle(A){var e=A.fontVariant.filter(A=>"normal"===A||"small-caps"===A).join(""),t=no(A.fontFamily).join(", "),r=s(A.fontSize)?""+A.fontSize.number+A.fontSize.unit:A.fontSize.number+"px";return[[A.fontStyle,e,A.fontWeight,r,t].join(" "),t,r]}renderLineClampedText(A,e,t,r){let s=1.5*e.fontSize.number,B=[],n=[],i=A.textBounds[0].bounds.top;A.textBounds.forEach(A=>{Math.abs(A.bounds.top-i)>=.5*s?(0<n.length&&B.push(n),n=[A],i=A.bounds.top):n.push(A)}),0<n.length&&B.push(n);var o=e.webkitLineClamp;if(B.length<=o)return!1;for(let A=0;A<o-1;A++)B[A].forEach(A=>this.renderTextBoundWithPaintOrder(A,e,t));A=B[o-1];if(A?.length&&r){var a,l=A.map(A=>A.text).join(""),A=A[0],r=r.width-(A.bounds.left-r.left),g=new dn(this.truncateTextWithEllipsis(l,r,e.letterSpacing),A.bounds);for(a of t)0===a?(this.ctx.fillStyle=p(e.color),this.renderTextWithLetterSpacing(g,e.letterSpacing,e.fontSize.number,e.writingMode)):1===a&&this.renderTextStrokeWithStyle(g,e)}return!0}renderEllipsisText(A,e,t,r){let s=1.5*e.fontSize.number,B=A.textBounds[0].bounds.top;if(!A.textBounds.every(A=>Math.abs(A.bounds.top-B)<.5*s))return!1;var n=A.textBounds.map(A=>A.text).join("").replace(/\s+/g," ").trim();if(this.ctx.measureText(n).width<=r.width)return!1;var i,o=new dn(this.truncateTextWithEllipsis(n,r.width,e.letterSpacing),A.textBounds[0].bounds);for(i of t)0===i?this.renderTextFillWithShadows(o,e):1===i&&this.renderTextStrokeWithStyle(o,e);return!0}async renderTextNode(A,t,e){this.ctx.font=this.createFontStyle(t)[0],this.ctx.direction=1===t.direction?"rtl":"ltr",this.ctx.textAlign="left",this.ctx.textBaseline="alphabetic";let r=t.paintOrder;0<t.webkitLineClamp&&0!=(2&t.display)&&1===t.overflowY&&0<A.textBounds.length&&this.renderLineClampedText(A,t,r,e)||1===t.textOverflow&&e&&1===t.overflowX&&0<A.textBounds.length&&this.renderEllipsisText(A,t,r,e)||A.textBounds.forEach(e=>{r.forEach(A=>{0===A?(this.renderTextFillWithShadows(e,t),t.textDecorationLine.length&&this.renderTextDecoration(e.bounds,t)):1===A&&this.renderTextStrokeWithStyle(e,t)})})}};let oo=(r,A)=>{A.forEach((A,e)=>{var t=D(A)?A.start:A;0===e?r.moveTo(t.x,t.y):r.lineTo(t.x,t.y),D(A)&&r.bezierCurveTo(A.startControl.x,A.startControl.y,A.endControl.x,A.endControl.y,A.end.x,A.end.y)})},ao=(A,e)=>{A.beginPath(),oo(A,e),A.closePath()};var lo=class lo{static{this.PATTERN_CACHE_MAX=50}constructor(A){this.patternCache=new Map,this.ctx=A.ctx,this.context=A.context,this.canvas=A.canvas}async renderBackgroundImage(A){let e=A.styles.backgroundImage.length-1;var t,r,s=A.styles.backgroundBlendMode;let B=0;for(t of A.styles.backgroundImage.slice(0).reverse())0<B&&"normal"!==(r=s[B]??s[0]??"normal")&&(this.ctx.save(),this.ctx.globalCompositeOperation=r),0===t.type?await this.renderBackgroundURLImage(A,t,e):1===t.type?this.renderLinearGradient(A,t,e):3===t.type?this.renderRepeatingLinearGradient(A,t,e):2===t.type&&this.renderRadialGradient(A,t,e),0<B&&"normal"!==(s[B]??s[0]??"normal")&&this.ctx.restore(),e--,B++}async renderBackgroundURLImage(e,t,r){let s;t=t.url;try{s=await this.context.cache.match(t)}catch(A){this.context.logger.error("Error loading background-image "+t),this.context.onError?.(A instanceof Error?A:new Error(String(A)))}if(s){var B=isNaN(s.width)||0===s.width?1:s.width,n=isNaN(s.height)||0===s.height?1:s.height,[r,B,n,i,o]=zi(e,r,[B,n,B/n]),t=`${t}|${Math.round(i)}x${Math.round(o)}|`+e.styles.imageRendering;let A=this.lruGet(this.patternCache,t);A||(i=this.resizeImage(s,i,o,e.styles.imageRendering),A=this.ctx.createPattern(i,"repeat"),this.lruSet(this.patternCache,t,A)),this.renderRepeat(r,A,B,n)}}renderRepeatingLinearGradient(t,r,s){var[e,B,n,i,o]=zi(t,s,[null,null,null]),[i,o,a,l,g]=zt(r.angle,i,o),i=_t(r.stops,i||1),c=i[i.length-1];let w=i[0],Q=c.stop-w.stop;if(Q<=0)this.renderLinearGradient(t,r,s);else{c=a-o,t=g-l,s=Q/(Math.sqrt(c*c+t*t)||1),a=o,g=l,o=o+c*s,c=l+t*s,l=this.canvas.ownerDocument??document,t=`rlg|${r.angle}|${Math.round(Q)}|`+JSON.stringify(r.stops);let A=this.lruGet(this.patternCache,t);if(!A){s=l.createElement("canvas"),r=Math.max(1,Math.ceil(Q)),l=(s.width=r,s.height=r,s.getContext("2d"));if(!l)return;let e=l.createLinearGradient(a-B,g-n,o-B,c-n);i.forEach(A=>{e.addColorStop((A.stop-w.stop)/Q,p(A.color))}),l.fillStyle=e,l.fillRect(0,0,r,r),0<r&&(A=this.ctx.createPattern(s,"repeat"),this.lruSet(this.patternCache,t,A))}A&&this.renderRepeat(e,A,B,n)}}renderLinearGradient(A,t,e){var[A,e,r,s,B]=zi(A,e,[null,null,null]),[n,i,o,a,l]=zt(t.angle,s,B),g=`lg|${t.angle}|${Math.round(s)}x${Math.round(B)}|`+JSON.stringify(t.stops);let c=this.lruGet(this.patternCache,g);if(!c){var w=(this.canvas.ownerDocument??document).createElement("canvas"),Q=(w.width=s,w.height=B,w.getContext("2d"));if(!Q)return;let e=Q.createLinearGradient(i,a,o,l);_t(t.stops,n||1).forEach(A=>e.addColorStop(A.stop,p(A.color))),Q.fillStyle=e,Q.fillRect(0,0,s,B),0<s&&0<B&&(c=this.ctx.createPattern(w,"repeat"),this.lruSet(this.patternCache,g,c))}c&&this.renderRepeat(A,c,e,r)}renderRadialGradient(e,t,r){var[e,r,s,B,n]=zi(e,r,[null,null,null]),i=0===t.position.length?[Bt]:t.position,o=f(i[0],B),i=f(i[i.length-1],n);let[a,l]=((A,e,t,r,s)=>{let B=0,n=0;switch(A.size){case 0:0===A.shape?B=n=Math.min(Math.abs(e),Math.abs(e-r),Math.abs(t),Math.abs(t-s)):1===A.shape&&(B=Math.min(Math.abs(e),Math.abs(e-r)),n=Math.min(Math.abs(t),Math.abs(t-s)));break;case 2:0===A.shape?B=n=Math.min(m(e,t),m(e,t-s),m(e-r,t),m(e-r,t-s)):1===A.shape&&(a=Math.min(Math.abs(t),Math.abs(t-s))/Math.min(Math.abs(e),Math.abs(e-r)),[i,o]=qt(r,s,e,t,!0),B=m(i-e,(o-t)/a),n=a*B);break;case 1:0===A.shape?B=n=Math.max(Math.abs(e),Math.abs(e-r),Math.abs(t),Math.abs(t-s)):1===A.shape&&(B=Math.max(Math.abs(e),Math.abs(e-r)),n=Math.max(Math.abs(t),Math.abs(t-s)));break;case 3:var i,o,a;0===A.shape?B=n=Math.max(m(e,t),m(e,t-s),m(e-r,t),m(e-r,t-s)):1===A.shape&&(i=Math.max(Math.abs(t),Math.abs(t-s))/Math.max(Math.abs(e),Math.abs(e-r)),[o,a]=qt(r,s,e,t,!1),B=m(o-e,(a-t)/i),n=i*B)}return Array.isArray(A.size)&&(B=f(A.size[0],r),n=2===A.size.length?f(A.size[1],s):B),[B,n]})(t,o,i,B,n);if(0!==a&&0!==l||(a=Math.max(a,.01),l=Math.max(l,.01)),0<a&&0<l){B=`rg|${Math.round(o)}x${Math.round(i)}|${Math.round(a)}x${Math.round(l)}|`+JSON.stringify(t.stops);let A=this.lruGet(this.patternCache,B);if(!A){var n=this.canvas.ownerDocument??document,g=Math.ceil(2*Math.max(a,l)),n=n.createElement("canvas"),g=(n.width=g,n.height=g,n.getContext("2d"));if(g){var c=Math.max(a,l);let e=g.createRadialGradient(c,c,0,c,c,c);_t(t.stops,2*c).forEach(A=>e.addColorStop(A.stop,p(A.color))),g.fillStyle=e,a!==l&&g.scale(1,l/a),g.fillRect(0,0,2*c,2*c),A=this.ctx.createPattern(n,"no-repeat"),this.lruSet(this.patternCache,B,A)}}A&&(this.path(e),this.ctx.save(),this.ctx.clip(),this.ctx.translate(r+o-Math.max(a,l),s+i-Math.max(a,l)),this.ctx.fillStyle=A,this.ctx.fillRect(0,0,2*Math.max(a,l),2*Math.max(a,l)),this.ctx.restore())}}renderRepeat(A,e,t,r){this.path(A),this.ctx.fillStyle=e,this.ctx.translate(t,r),this.ctx.fill(),this.ctx.translate(-t,-r)}resizeImage(A,e,t,r){var s=(this.canvas.ownerDocument??document).createElement("canvas"),B=(s.width=Math.max(1,e),s.height=Math.max(1,t),s.getContext("2d"));return B?(2===r||1===r?(this.context.logger.debug("Disabling image smoothing for background image due to CSS image-rendering"),B.imageSmoothingEnabled=!1):3===r?(this.context.logger.debug("Enabling image smoothing for background image due to CSS image-rendering: smooth"),B.imageSmoothingEnabled=!0):B.imageSmoothingEnabled=this.ctx.imageSmoothingEnabled,this.ctx.imageSmoothingQuality&&(B.imageSmoothingQuality=this.ctx.imageSmoothingQuality),B.drawImage(A,0,0,A.width,A.height,0,0,e,t),s):A}path(A){ao(this.ctx,A)}lruGet(A,e){var t=A.get(e);return void 0!==t&&(A.delete(e),A.set(e,t)),t}lruSet(A,e,t){var r;A.size>=lo.PATTERN_CACHE_MAX&&(r=A.keys().next().value,A.delete(r)),A.set(e,t)}};let go=(A,e)=>{switch(e){case 0:return M(A.topLeftBorderBox,A.topLeftPaddingBox,A.topRightBorderBox,A.topRightPaddingBox);case 1:return M(A.topRightBorderBox,A.topRightPaddingBox,A.bottomRightBorderBox,A.bottomRightPaddingBox);case 2:return M(A.bottomRightBorderBox,A.bottomRightPaddingBox,A.bottomLeftBorderBox,A.bottomLeftPaddingBox);default:return M(A.bottomLeftBorderBox,A.bottomLeftPaddingBox,A.topLeftBorderBox,A.topLeftPaddingBox)}},co=(A,e)=>{var t=[];return D(A)?t.push(A.subdivide(.5,!1)):t.push(A),D(e)?t.push(e.subdivide(.5,!0)):t.push(e),t},M=(A,e,t,r)=>{var s=[];return D(A)?s.push(A.subdivide(.5,!1)):s.push(A),D(t)?s.push(t.subdivide(.5,!0)):s.push(t),D(r)?s.push(r.subdivide(.5,!0).reverse()):s.push(r),D(e)?s.push(e.subdivide(.5,!1).reverse()):s.push(e),s};var wo=class{constructor(A,e){this.ctx=A.ctx,this.pathCallbacks=e}async renderSolidBorder(A,e,t){this.pathCallbacks.path(go(t,e)),this.ctx.fillStyle=p(A),this.ctx.fill()}async renderDoubleBorder(A,e,t,r){e<3?await this.renderSolidBorder(A,t,r):(e=((A,e)=>{switch(e){case 0:return M(A.topLeftBorderBox,A.topLeftBorderDoubleOuterBox,A.topRightBorderBox,A.topRightBorderDoubleOuterBox);case 1:return M(A.topRightBorderBox,A.topRightBorderDoubleOuterBox,A.bottomRightBorderBox,A.bottomRightBorderDoubleOuterBox);case 2:return M(A.bottomRightBorderBox,A.bottomRightBorderDoubleOuterBox,A.bottomLeftBorderBox,A.bottomLeftBorderDoubleOuterBox);default:return M(A.bottomLeftBorderBox,A.bottomLeftBorderDoubleOuterBox,A.topLeftBorderBox,A.topLeftBorderDoubleOuterBox)}})(r,t),this.pathCallbacks.path(e),this.ctx.fillStyle=p(A),this.ctx.fill(),e=((A,e)=>{switch(e){case 0:return M(A.topLeftBorderDoubleInnerBox,A.topLeftPaddingBox,A.topRightBorderDoubleInnerBox,A.topRightPaddingBox);case 1:return M(A.topRightBorderDoubleInnerBox,A.topRightPaddingBox,A.bottomRightBorderDoubleInnerBox,A.bottomRightPaddingBox);case 2:return M(A.bottomRightBorderDoubleInnerBox,A.bottomRightPaddingBox,A.bottomLeftBorderDoubleInnerBox,A.bottomLeftPaddingBox);default:return M(A.bottomLeftBorderDoubleInnerBox,A.bottomLeftPaddingBox,A.topLeftBorderDoubleInnerBox,A.topLeftPaddingBox)}})(r,t),this.pathCallbacks.path(e),this.ctx.fill())}async renderDashedDottedBorder(A,e,t,r,s){this.ctx.save();var B=((A,e)=>{switch(e){case 0:return co(A.topLeftBorderStroke,A.topRightBorderStroke);case 1:return co(A.topRightBorderStroke,A.bottomRightBorderStroke);case 2:return co(A.bottomRightBorderStroke,A.bottomLeftBorderStroke);default:return co(A.bottomLeftBorderStroke,A.topLeftBorderStroke)}})(r,t),r=go(r,t);2===s&&(this.pathCallbacks.path(r),this.ctx.clip());let n,i,o,a;i=(D(r[0])?(n=r[0].start.x,r[0].start):(n=r[0].x,r[0])).y,a=(D(r[1])?(o=r[1].end.x,r[1].end):(o=r[1].x,r[1])).y;let l,g=(l=0===t||2===t?Math.abs(n-o):Math.abs(i-a),this.ctx.beginPath(),3===s?this.pathCallbacks.formatPath(B):this.pathCallbacks.formatPath(r.slice(0,2)),e<3?3*e:2*e),c=e<3?2*e:e,w=(3===s&&(g=e,c=e),!0);l<=2*g?w=!1:l<=2*g+c?(t=l/(2*g+c),g*=t,c*=t):(B=Math.floor((l+c)/(g+c)),t=(l-B*g)/(B-1),B=(l-(B+1)*g)/B,c=B<=0||Math.abs(c-t)<Math.abs(c-B)?t:B),w&&(3===s?this.ctx.setLineDash([0,g+c]):this.ctx.setLineDash([g,c])),3===s?(this.ctx.lineCap="round",this.ctx.lineWidth=e):this.ctx.lineWidth=2*e+1.1,this.ctx.strokeStyle=p(A),this.ctx.stroke(),this.ctx.setLineDash([]),2===s&&(D(r[0])&&(t=r[3],B=r[0],this.ctx.beginPath(),this.pathCallbacks.formatPath([new v(t.end.x,t.end.y),new v(B.start.x,B.start.y)]),this.ctx.stroke()),D(r[1]))&&(e=r[1],A=r[2],this.ctx.beginPath(),this.pathCallbacks.formatPath([new v(e.end.x,e.end.y),new v(A.start.x,A.start.y)]),this.ctx.stroke()),this.ctx.restore()}},Qo=class{constructor(A){this.ctx=A}renderBorderImage(A,e,t,r,s,B,n,i){var o=e.naturalWidth||e.width,a=e.naturalHeight||e.height;if(!(o<=0||a<=0)){var l=Math.min("percent"===t.unit?t.top/100*a:Math.min(t.top,a),a),g=Math.min("percent"===t.unit?t.right/100*o:Math.min(t.right,o),o),c=Math.min("percent"===t.unit?t.bottom/100*a:Math.min(t.bottom,a),a),w=Math.min("percent"===t.unit?t.left/100*o:Math.min(t.left,o),o),{left:A,top:Q,width:h,height:C}=A;if(!(h<=0||C<=0)){var d,u,s=Math.min(s,C),B=Math.min(B,h),n=Math.min(n,C-s),i=Math.min(i,h-B),r=(this.drawRegion(e,0,0,w,l,A,Q,i,s),this.drawRegion(e,o-g,0,g,l,A+h-B,Q,B,s),this.drawRegion(e,o-g,a-c,g,c,A+h-B,Q+C-n,B,n),this.drawRegion(e,0,a-c,w,c,A,Q+C-n,i,n),[{sx:w,sy:0,sw:o-w-g,sh:l,dx:A+i,dy:Q,dw:h-i-B,dh:s,repeat:r.horizontal},{sx:o-g,sy:l,sw:g,sh:a-l-c,dx:A+h-B,dy:Q+s,dw:B,dh:C-s-n,repeat:r.vertical},{sx:w,sy:a-c,sw:o-w-g,sh:c,dx:A+i,dy:Q+C-n,dw:h-i-B,dh:n,repeat:r.horizontal},{sx:0,sy:l,sw:w,sh:a-l-c,dx:A,dy:Q+s,dw:i,dh:C-s-n,repeat:r.vertical}]);for(d of r)d.sw<=0||d.sh<=0||d.dw<=0||d.dh<=0||(u=d.dw>=d.dh,0===d.repeat?this.ctx.drawImage(e,d.sx,d.sy,d.sw,d.sh,d.dx,d.dy,d.dw,d.dh):1!==d.repeat&&2!==d.repeat||this.drawRepeatedEdge(e,d,u,2===d.repeat));t.fill&&this.drawRegion(e,w,l,o-w-g,a-l-c,A+i,Q+s,h-i-B,C-s-n)}}}drawRegion(A,e,t,r,s,B,n,i,o){0<r&&0<s&&0<i&&0<o&&this.ctx.drawImage(A,e,t,r,s,B,n,i,o)}drawRepeatedEdge(r,s,B,A){var n=B?s.sw:s.sh,i=B?s.dw:s.dh;if(!(n<=0||i<=0)){let e,t;A?(t=Math.max(1,Math.round(i/n)),e=i/t):(e=n,t=Math.ceil(i/e)),this.ctx.save(),this.ctx.beginPath(),this.ctx.rect(s.dx,s.dy,s.dw,s.dh),this.ctx.clip();for(let A=0;A<t;A++){var o=A*e,a=Math.min(e,i-o);if(a<=0)break;B?this.ctx.drawImage(r,s.sx,s.sy,s.sw,s.sh,s.dx+o,s.dy,a,s.dh):this.ctx.drawImage(r,s.sx,s.sy,s.sw,s.sh,s.dx,s.dy+o,s.dw,a)}this.ctx.restore()}}},ho=class{constructor(A,e){this.activeEffects=[],this.ctx=A.ctx,this.pathCallback=e}applyEffects(A){for(;this.activeEffects.length;)this.popEffect();A.forEach(A=>this.applyEffect(A))}applyEffect(A){this.ctx.save(),2===A.type?this.ctx.globalAlpha=A.opacity:0===A.type?(this.ctx.translate(A.offsetX,A.offsetY),this.ctx.transform(A.matrix[0],A.matrix[1],A.matrix[2],A.matrix[3],A.matrix[4],A.matrix[5]),this.ctx.translate(-A.offsetX,-A.offsetY)):Gi(A)?(this.pathCallback.path(A.path),this.ctx.clip()):3===A.type?A.applyClip(this.ctx):4===A.type?this.ctx.globalCompositeOperation=A.compositeOperation:5===A.type&&(this.ctx.filter=A.safeFilterString||"none",A.shadow)&&(this.ctx.shadowOffsetX=A.shadow.offsetX,this.ctx.shadowOffsetY=A.shadow.offsetY,this.ctx.shadowBlur=A.shadow.blur,this.ctx.shadowColor=A.shadow.color),this.activeEffects.push(A)}popEffect(){this.activeEffects.pop(),this.ctx.restore()}getActiveEffectCount(){return this.activeEffects.length}hasActiveEffects(){return 0<this.activeEffects.length}};function Co(t,r,s,B,n,i){if(n instanceof Tn&&(o=Math.min(n.bounds.width,n.bounds.height),"checkbox"===n.type&&n.checked?(t.save(),B([new v(n.bounds.left+.39363*o,n.bounds.top+.79*o),new v(n.bounds.left+.16*o,n.bounds.top+.5549*o),new v(n.bounds.left+.27347*o,n.bounds.top+.44071*o),new v(n.bounds.left+.39694*o,n.bounds.top+.5649*o),new v(n.bounds.left+.72983*o,n.bounds.top+.23*o),new v(n.bounds.left+.84*o,n.bounds.top+.34085*o),new v(n.bounds.left+.39363*o,n.bounds.top+.79*o)]),t.fillStyle=p(Mn),t.fill(),t.restore()):"radio"===n.type&&n.checked&&(t.save(),t.beginPath(),t.arc(n.bounds.left+o/2,n.bounds.top+o/2,o/4,0,2*Math.PI,!0),t.fillStyle=p(Mn),t.fill(),t.restore())),(A=>{if(A instanceof kn)return true;else if(A instanceof On)return true;else if(A instanceof Tn&&A.type!=="radio"&&A.type!=="checkbox")return true;return false})(n)&&n.value.length){var[o,a,l]=s.createFontStyle(i),r=r.getMetrics(a,l).baseline,g=(t.font=o,t.fillStyle=n instanceof Tn&&n.isPlaceholder?p(1970632191):p(i.color),t.textBaseline="alphabetic",t.textAlign=(A=>{switch(A){case 1:return"center";case 2:return"right";default:return"left"}})(n.styles.textAlign),_i(n));let A=0;switch(n.styles.textAlign){case 1:A+=g.width/2;break;case 2:A+=g.width}let e=0;n instanceof Tn&&(a=f(i.fontSize,0),e=(g.height-a)/2);l=g.add(A,e,0,0);t.save(),B([new v(g.left,g.top),new v(g.left+g.width,g.top),new v(g.left+g.width,g.top+g.height),new v(g.left,g.top+g.height)]),t.clip(),s.renderTextWithLetterSpacing(new dn(n.value,l),i.letterSpacing,r,i.writingMode),t.restore(),t.textBaseline="alphabetic",t.textAlign="left"}}var uo=class uo{constructor(A,e){this.context=A,this.options=e,this.canvas=e.canvas||document.createElement("canvas");A=this.canvas.getContext("2d");if(!A)throw new Error("Failed to get 2D rendering context from canvas");this.ctx=A,e.canvas||(this.canvas.width=Math.floor(e.width*e.scale),this.canvas.height=Math.floor(e.height*e.scale),this.canvas.style.width=e.width+"px",this.canvas.style.height=e.height+"px"),this.fontMetrics=new eo(document),this.ctx.scale(this.options.scale,this.options.scale),this.ctx.translate(-e.x,-e.y),this.ctx.textBaseline="bottom",void 0!==e.imageSmoothing&&(this.ctx.imageSmoothingEnabled=e.imageSmoothing),e.imageSmoothingQuality&&(this.ctx.imageSmoothingQuality=e.imageSmoothingQuality),this.backgroundRenderer=new lo({ctx:this.ctx,context:this.context,canvas:this.canvas,options:{width:e.width,height:e.height,scale:e.scale}}),this.borderRenderer=new wo({ctx:this.ctx},{path:A=>this.path(A),formatPath:A=>this.formatPath(A)}),this.borderImageRenderer=new Qo(this.ctx),this.effectsRenderer=new ho({ctx:this.ctx},{path:A=>this.path(A)}),this.textRenderer=new io({ctx:this.ctx,context:this.context,options:{scale:e.scale}}),this.context.logger.debug(`Canvas renderer initialized (${e.width}x${e.height}) with scale `+e.scale)}async renderStack(A){A.element.container.styles.isVisible()&&await this.renderStackContent(A)}async renderNode(A){A.container.debugRender,A.container.styles.isVisible()&&(await this.renderNodeBackgroundAndBorders(A),await this.renderNodeContent(A))}renderReplacedElement(A,e,t){var r,s,B,n,i=t.naturalWidth||A.intrinsicWidth,o=t.naturalHeight||A.intrinsicHeight;t&&0<i&&0<o&&(r=_i(A),e=vi(e),{sx:e,sy:i,sw:o,sh:r,dx:A,dy:s,dw:B,dh:n}=(this.path(e),this.ctx.save(),this.ctx.clip(),((A,e,t,r,s)=>{let B=0,n=0,i=A,o=e,a=t.left,l=t.top,g=t.width,c=t.height;var w=g/c,Q=i/o,h=s?f(s[0],1):.5,s=s?f(s[1],1):.5;return 2===r?w<Q?(c=g/Q,l+=(t.height-c)*s):(g=c*Q,a+=(t.width-g)*h):4===r?w<Q?(i=o*w,B+=(A-i)*h):(o=i/w,n+=(e-o)*s):8===r?(i>g?(B+=(i-g)*h,i=g):(a+=(g-i)*h,g=i),o>c?(n+=(o-c)*s,o=c):(l+=(c-o)*s,c=o)):16===r&&((w<Q?g:c*Q)<(i>g?i:g)?w<Q?(c=g/Q,l+=(t.height-c)*s):(g=c*Q,a+=(t.width-g)*h):(i>g?(B+=(i-g)*h,i=g):(a+=(g-i)*h,g=i),o>c?(n+=(o-c)*s,o=c):(l+=(c-o)*s,c=o))),{sx:B,sy:n,sw:i,sh:o,dx:a,dy:l,dw:g,dh:c}})(i,o,r,A.styles.objectFit,A.styles.objectPosition)),this.ctx.drawImage(t,e,i,o,r,A,s,B,n),this.ctx.restore())}async renderNodeContent(A){this.effectsRenderer.applyEffects(A.getEffects(4));var e,t=A.container,r=A.curves,s=t.styles,B=_i(t);for(e of t.textNodes)await this.textRenderer.renderTextNode(e,s,B);var n=this.ctx,i=this.context,o={scale:this.options.scale,backgroundColor:this.options.backgroundColor,x:this.options.x,y:this.options.y,width:this.options.width,height:this.options.height},a=(A,e)=>new uo(A,e),l=t,g=s,c=(A,e,t)=>this.renderReplacedElement(A,e,t);if(l instanceof bn)try{var w=await i.cache.match(l.src),Q=n.imageSmoothingEnabled;2===g.imageRendering||1===g.imageRendering?n.imageSmoothingEnabled=!1:3===g.imageRendering&&(n.imageSmoothingEnabled=!0),c(l,r,w),n.imageSmoothingEnabled=Q}catch(A){i.logger.error("Error loading image "+l.src),i.onError?.(A instanceof Error?A:new Error(String(A)))}if(l instanceof Kn&&c(l,r,l.canvas),l instanceof xn)try{c(l,r,await i.cache.match(l.svg))}catch(A){i.logger.error("Error loading svg "+l.svg.substring(0,255)),i.onError?.(A instanceof Error?A:new Error(String(A)))}l instanceof Vn&&l.tree&&(g=await a(i,{scale:o.scale,backgroundColor:l.backgroundColor,x:0,y:0,width:l.width,height:l.height}).render(l.tree),l.width)&&l.height&&n.drawImage(g,0,0,l.width,l.height,l.bounds.left,l.bounds.top,l.bounds.width,l.bounds.height),await 0,Co(this.ctx,this.fontMetrics,this.textRenderer,this.path.bind(this),t,s);w=this.ctx,Q=this.context,c=this.textRenderer,r=A,a=t,i=s;if(E(a.styles.display,2048))if(null!==a.styles.listStyleImage){var h=a.styles.listStyleImage;if(0===h.type){h=h.url;try{var C=await Q.cache.match(h);w.drawImage(C,a.bounds.left-(C.width+10),a.bounds.top)}catch(A){Q.logger.error("Error loading list-style-image "+h),Q.onError?.(A instanceof Error?A:new Error(String(A)))}}}else r.listValue&&-1!==a.styles.listStyleType&&([C]=c.createFontStyle(i),w.font=C,w.fillStyle=p(i.color),w.textBaseline="middle",w.textAlign="right",h=new d(a.bounds.left,a.bounds.top+f(a.styles.paddingTop,a.bounds.width),a.bounds.width,Pr(i.lineHeight,i.fontSize.number)/2+1),c.renderTextWithLetterSpacing(new dn(r.listValue,h),i.letterSpacing,Pr(i.lineHeight,i.fontSize.number)/2+2,i.writingMode),w.textBaseline="bottom",w.textAlign="left")}async renderStackContent(A){A.element.container.debugRender;var e,t,r,s,B,n,i,o=this.options.signal;await this.renderNodeBackgroundAndBorders(A.element);for(e of A.negativeZIndex){if(o?.aborted)throw new DOMException("The operation was aborted.","AbortError");await this.renderStack(e)}if(o?.aborted)throw new DOMException("The operation was aborted.","AbortError");await this.renderNodeContent(A.element);for(t of A.nonInlineLevel)await this.renderNode(t);for(r of A.nonPositionedFloats){if(o?.aborted)throw new DOMException("The operation was aborted.","AbortError");await this.renderStack(r)}for(s of A.nonPositionedInlineLevel){if(o?.aborted)throw new DOMException("The operation was aborted.","AbortError");await this.renderStack(s)}for(B of A.inlineLevel)await this.renderNode(B);for(n of A.zeroOrAutoZIndexOrTransformedOrOpacity){if(o?.aborted)throw new DOMException("The operation was aborted.","AbortError");await this.renderStack(n)}for(i of A.positiveZIndex){if(o?.aborted)throw new DOMException("The operation was aborted.","AbortError");await this.renderStack(i)}}mask(A){this.ctx.beginPath(),this.ctx.moveTo(0,0),this.ctx.lineTo(this.options.width,0),this.ctx.lineTo(this.options.width,this.options.height),this.ctx.lineTo(0,this.options.height),this.ctx.lineTo(0,0),this.formatPath(A.slice(0).reverse()),this.ctx.closePath()}path(A){ao(this.ctx,A)}formatPath(A){oo(this.ctx,A)}async renderNodeBackgroundAndBorders(o){this.effectsRenderer.applyEffects(o.getEffects(2));var A=o.container.styles,e=!Qt(A.backgroundColor)||A.backgroundImage.length,t=[{style:A.borderTopStyle,color:A.borderTopColor,width:A.borderTopWidth},{style:A.borderRightStyle,color:A.borderRightColor,width:A.borderRightWidth},{style:A.borderBottomStyle,color:A.borderBottomColor,width:A.borderBottomWidth},{style:A.borderLeftStyle,color:A.borderLeftColor,width:A.borderLeftWidth}],r=Uo($i(A.backgroundClip,0),o.curves);if((e||A.boxShadow.length)&&(this.ctx.save(),this.path(r),this.ctx.clip(),Qt(A.backgroundColor)||(this.ctx.fillStyle=p(A.backgroundColor),this.ctx.fill()),await this.backgroundRenderer.renderBackgroundImage(o.container),this.ctx.restore(),A.boxShadow.slice(0).reverse().forEach(A=>{this.ctx.save();var t,r,s,B,e=Li(o.curves),n=A.inset?0:1e4,i=(t=-n+(A.inset?1:-1)*A.spread.number,r=(A.inset?1:-1)*A.spread.number,s=A.spread.number*(A.inset?-2:2),B=A.spread.number*(A.inset?-2:2),e.map((A,e)=>{switch(e){case 0:return A.add(t,r);case 1:return A.add(t+s,r);case 2:return A.add(t+s,r+B);case 3:return A.add(t,r+B)}return A}));A.inset?(this.path(e),this.ctx.clip(),this.mask(i)):(this.mask(e),this.ctx.clip(),this.path(i)),this.ctx.shadowOffsetX=A.offsetX.number+n,this.ctx.shadowOffsetY=A.offsetY.number,this.ctx.shadowColor=p(A.color),this.ctx.shadowBlur=A.blur.number,this.ctx.fillStyle=A.inset?p(A.color):"rgba(0,0,0,1)",this.ctx.fill(),this.ctx.restore()})),A.borderImageSource){e=A.borderImageSource;if(0===e.type){r=e.url;try{var s,B=await this.context.cache.match(r);B&&(s=o.container.bounds,this.borderImageRenderer.renderBorderImage(s,B,A.borderImageSlice,A.borderImageRepeat,Math.max(0,A.borderTopWidth),Math.max(0,A.borderRightWidth),Math.max(0,A.borderBottomWidth),Math.max(0,A.borderLeftWidth)))}catch(A){this.context.logger.error("Error loading border-image "+r)}}}else{let A=0;for(var n of t)0!==n.style&&!Qt(n.color)&&0<n.width&&(2===n.style?await this.borderRenderer.renderDashedDottedBorder(n.color,n.width,A,o.curves,2):3===n.style?await this.borderRenderer.renderDashedDottedBorder(n.color,n.width,A,o.curves,3):4===n.style?await this.borderRenderer.renderDoubleBorder(n.color,n.width,A,o.curves):await this.borderRenderer.renderSolidBorder(n.color,A,o.curves)),A++}}async render(A){this.options.backgroundColor&&(this.ctx.fillStyle=p(this.options.backgroundColor),this.ctx.fillRect(this.options.x,this.options.y,this.options.width,this.options.height));A=new Ni(A=A,null),e=new Ri(A),t=[],Wi(A,e,e,t),Yi(A.container,t);var e,t,A=e;return await this.renderStack(A),this.effectsRenderer.applyEffects([]),this.canvas}};let Uo=(A,e)=>{switch(A){case 0:return Li(e);case 2:return[e.topLeftContentBox,e.topRightContentBox,e.bottomRightContentBox,e.bottomLeftContentBox];default:return vi(e)}};var Fo=class{constructor(A,e){this.context=A,this.options=e,this.canvas=e.canvas||document.createElement("canvas");A=this.canvas.getContext("2d");if(!A)throw new Error("Failed to get 2D rendering context from canvas");this.ctx=A,this.canvas.width=Math.floor(e.width*e.scale),this.canvas.height=Math.floor(e.height*e.scale),this.canvas.style.width=e.width+"px",this.canvas.style.height=e.height+"px",this.ctx.scale(this.options.scale,this.options.scale),this.ctx.translate(-e.x,-e.y),this.context.logger.debug(`EXPERIMENTAL ForeignObject renderer initialized (${e.width}x${e.height} at ${e.x},${e.y}) with scale `+e.scale)}async render(A){if(this.options.signal?.aborted)throw new DOMException("The operation was aborted.","AbortError");A=await Cn(hn(this.options.width*this.options.scale,this.options.height*this.options.scale,this.options.scale,this.options.scale,A));return this.options.backgroundColor&&(this.ctx.fillStyle=p(this.options.backgroundColor),this.ctx.fillRect(0,0,this.options.width*this.options.scale,this.options.height*this.options.scale)),this.ctx.drawImage(A,-this.options.x*this.options.scale,-this.options.y*this.options.scale),this.canvas}},po=class{static{this.instances={}}constructor({id:A,enabled:e}){this.id=A,this.enabled=e,this.start=Date.now()}debug(...A){this.enabled&&("undefined"!=typeof window&&window.console&&"function"==typeof console.debug?console.debug(this.id,this.getTime()+"ms",...A):this.info(...A))}getTime(){return Date.now()-this.start}info(...A){this.enabled&&"undefined"!=typeof window&&window.console&&"function"==typeof console.info&&console.info(this.id,this.getTime()+"ms",...A)}warn(...A){this.enabled&&("undefined"!=typeof window&&window.console&&"function"==typeof console.warn?console.warn(this.id,this.getTime()+"ms",...A):this.info(...A))}error(...A){this.enabled&&("undefined"!=typeof window&&window.console&&"function"==typeof console.error?console.error(this.id,this.getTime()+"ms",...A):this.info(...A))}},fo=class{constructor(A,e){if(this.context=A,this._options=e,this._cache=new Map,this._pendingOperations=new Map,this.maxSize=e.maxCacheSize??100,this.maxSize<1)throw new Error("Cache maxSize must be at least 1");1e4<this.maxSize&&this.context.logger.warn(`Cache maxSize ${this.maxSize} is very large and may cause memory issues. Consider using a smaller value (recommended: 100-1000).`)}addImage(A){var e=this._pendingOperations.get(A);return e||(this.has(A)?(e=this._cache.get(A),this._cache.delete(A),this._cache.set(A,e),Promise.resolve()):Ko(A)||yo(A)?(e=this._addImageInternal(A),this._pendingOperations.set(A,e),e.finally(()=>{this._pendingOperations.delete(A)}),e):Promise.resolve())}async _addImageInternal(e){var A=this._options.imageTimeout??15e3,A=this.withTimeout(this.loadImage(e),A,`Timed out (${A}ms) loading image`);A.catch(A=>{this.context.logger.error(`Failed to load image ${e}: `+(A instanceof Error?A.message:"Unknown error"))}),this.set(e,A)}withTimeout(A,t,r){if(t<=0)return A;let s;var e=new Promise((A,e)=>{s=setTimeout(()=>e(new Error(r)),t)});return Promise.race([A,e]).finally(()=>{void 0!==s&&clearTimeout(s)})}match(A){var e=this._cache.get(A);if(e)return this._cache.delete(A),this._cache.set(A,e),e.value}set(A,e){var t;this._cache.has(A)?this._cache.delete(A):this._cache.size>=this.maxSize&&void 0!==(t=this._cache.keys().next().value)&&(this._cache.delete(t),this.context.logger.debug("Cache: Evicted LRU entry: "+t)),this._cache.set(A,{value:e})}size(){return this._cache.size}getMaxSize(){return this.maxSize}clear(){this._cache.clear()}async loadImage(A){let e=this.context.originChecker;var t=A=>e.isSameOrigin(A),t="function"==typeof this._options.customIsSameOrigin?await this._options.customIsSameOrigin(A,t):t(A);let s=!Io(A)&&!0===this._options.useCORS&&x.SUPPORT_CORS_IMAGES&&!t;var B=!Io(A)&&!t&&!Ko(A)&&"string"==typeof this._options.proxy&&x.SUPPORT_CORS_XHR&&!s;if(t||!1!==this._options.allowTaint||Io(A)||Ko(A)||B||s){let r=A;return B&&(r=await this.proxy(r)),this.context.logger.debug("Added image "+A.substring(0,256)),new Promise((A,e)=>{let t=new Image;t.onload=()=>A(t),t.onerror=e,(bo(r)||s)&&(t.crossOrigin="anonymous"),t.src=r,!0===t.complete&&setTimeout(()=>A(t),500)})}}has(A){return this._cache.has(A)}keys(){return Promise.resolve(Array.from(this._cache.keys()))}proxy(B){let n=this._options.proxy;if(!n)throw new Error("No proxy defined");let i=B.substring(0,256);return new Promise((e,t)=>{let A=x.SUPPORT_RESPONSE_TYPE?"blob":"text",r=new XMLHttpRequest;r.onload=()=>{if(200===r.status)if("text"==A)e(r.response);else{let A=new FileReader;A.addEventListener("load",()=>e(A.result),!1),A.addEventListener("error",A=>t(A),!1),A.readAsDataURL(r.response)}else t(`Failed to proxy resource ${i} with status code `+r.status)},r.onerror=t;var s=-1<n.indexOf("?")?"&":"?";if(r.open("GET",n+s+`url=${encodeURIComponent(B)}&responseType=`+A),"text"!=A&&r instanceof XMLHttpRequest&&(r.responseType=A),this._options.imageTimeout){let A=this._options.imageTimeout;r.timeout=A,r.ontimeout=()=>t(`Timed out (${A}ms) proxying `+i)}r.send()})}};let Ho=/^data:image\/svg\+xml/i,mo=/^data:image\/.*;base64,/i,Eo=/^data:image\/.*/i,yo=A=>x.SUPPORT_SVG_DRAWING||!xo(A),Io=A=>Eo.test(A),bo=A=>mo.test(A),Ko=A=>"blob"===A.substring(0,4),xo=A=>"svg"===A.slice(-3).toLowerCase()||Ho.test(A);var Lo=class{constructor(A){if(!A||!A.document)throw new Error("Valid window object required for OriginChecker");if(!A.location||!A.location.href)throw new Error("Window object must have valid location");this.link=A.document.createElement("a"),this.origin=this.getOrigin(A.location.href)}getOrigin(A){return this.link.href=A,this.link.href=this.link.href,this.link.protocol+this.link.hostname+this.link.port}isSameOrigin(A){return this.getOrigin(A)===this.origin}getContextOrigin(){return this.origin}},vo=class vo{static{this.instanceCount=1}constructor(A,e,t){this.windowBounds=e,this.instanceName="#"+vo.instanceCount++,this.config=t,this.logger=new po({id:this.instanceName,enabled:A.logging}),this.originChecker=new Lo(t.window),this.cache=A.cache??t.cache??new fo(this,A),this.onError=A.onError}};let Do=t=>{["scale","width","height","imageTimeout","x","y","windowWidth","windowHeight","scrollX","scrollY"].forEach(A=>{var e=t[A];null!=e&&"number"!=typeof e&&(e=Number(e),Number.isNaN(e)||(t[A]=e))})},So=(A,e,t)=>{var r=e.ownerDocument,s=r.documentElement?Jt(A,getComputedStyle(r.documentElement).backgroundColor):H.TRANSPARENT,B=r.body?Jt(A,getComputedStyle(r.body).backgroundColor):H.TRANSPARENT,A="string"==typeof t?Jt(A,t):null===t?H.TRANSPARENT:4294967295;return e===r.documentElement?Qt(s)?Qt(B)?A:B:s:A};t=(A,e={},t)=>(async(A,e,t)=>{if(Do(e),!e.skipValidation){var r=e.validator||V(),s=r.validateElement(A);if(!s.valid)throw new Error(s.error);s=r.validateOptions(e);if(!s.valid)throw new Error("Invalid options: "+s.error)}if(!A||"object"!=typeof A)throw new Error("Invalid element provided as first argument");r=A.ownerDocument;if(!r)throw new Error("Element is not attached to a Document");s=r.defaultView;if(!s)throw new Error("Document is not attached to a Window");var B={logging:e.logging??!0,cache:e.cache??t.cache,...{allowTaint:e.allowTaint??!1,imageTimeout:e.imageTimeout??15e3,proxy:e.proxy,useCORS:e.useCORS??!1,customIsSameOrigin:e.customIsSameOrigin,maxCacheSize:e.maxCacheSize}},n={windowWidth:e.windowWidth??s.innerWidth??800,windowHeight:e.windowHeight??s.innerHeight??600,scrollX:e.scrollX??s.pageXOffset??0,scrollY:e.scrollY??s.pageYOffset??0},i=new d(n.scrollX,n.scrollY,n.windowWidth,n.windowHeight),B=new vo(B,i,t),o=e.enablePerformanceMonitoring??e.logging??!1,a=new G(B,o),n=(a.start("total",{width:n.windowWidth,height:n.windowHeight}),e.signal);if(n?.aborted)throw new DOMException("The operation was aborted.","AbortError");var l=e.foreignObjectRendering??!1,t={allowTaint:e.allowTaint??!1,onclone:e.onclone,ignoreElements:e.ignoreElements,iframeContainer:e.iframeContainer,inlineImages:l,copyStyles:l,cspNonce:e.cspNonce??t.cspNonce},A=(B.logger.debug(`Starting document clone with size ${i.width}x${i.height} scrolled to ${-i.left},`+-i.top),a.start("clone"),new gi(B,A,t)),t=A.clonedReferenceElement;if(!t)throw new Error("Unable to find element in cloned iframe");A=await A.toIFrame(r,i);if(a.end("clone"),n?.aborted)throw(e.removeContainer??!0)&&gi.destroy(A),new DOMException("The operation was aborted.","AbortError");var{width:r,height:i,left:g,top:c}=UB(t)||dB(t)?N(t.ownerDocument):R(B,t),w=So(B,t,e.backgroundColor),s={canvas:e.canvas,backgroundColor:w,signal:n,scale:e.scale??s.devicePixelRatio??1,x:(e.x??0)+g,y:(e.y??0)+c,width:e.width??Math.ceil(r),height:e.height??Math.ceil(i),imageSmoothing:e.imageSmoothing,imageSmoothingQuality:e.imageSmoothingQuality};let Q,h;try{if(l)B.logger.debug("Document cloned, using foreign object rendering"),a.start("render-foreignobject"),Q=await new Fo(B,s).render(t),a.end("render-foreignobject");else{if(B.logger.debug(`Document cloned, element located at ${g},${c} with size ${r}x${i} using computed rendering`),B.logger.debug("Starting DOM parsing"),a.start("parse"),n?.aborted)throw new DOMException("The operation was aborted.","AbortError");if(h=Pn(B,t),a.end("parse"),w===h.styles.backgroundColor&&(h.styles.backgroundColor=H.TRANSPARENT),B.logger.debug(`Starting renderer for element at ${s.x},${s.y} with size ${s.width}x`+s.height),a.start("render"),n?.aborted)throw new DOMException("The operation was aborted.","AbortError");Q=await new uo(B,s).render(h),a.end("render")}return a.start("cleanup"),(e.removeContainer??!0)&&!gi.destroy(A)&&B.logger.error("Cannot detach cloned iframe as it is not in the DOM anymore"),a.end("cleanup"),a.end("total"),B.logger.debug("Finished rendering"),o&&a.logSummary(),Q}finally{h&&h.restoreTree()}})(A,e,t||O.fromElement(A,{cspNonce:e.cspNonce,cache:e.cache}));T.Html2CanvasConfig=O,T.PerformanceMonitor=G,T.Validator=k,T.createDefaultValidator=V,T.default=t,T.html2canvas=t}),"undefined"!=typeof window&&window.html2canvas&&window.html2canvas.default&&(window.html2canvas=window.html2canvas.default);
|
|
@@ -67,14 +67,17 @@ class EffectsRenderer {
|
|
|
67
67
|
this.ctx.globalCompositeOperation = effect.compositeOperation;
|
|
68
68
|
}
|
|
69
69
|
else if ((0, effects_1.isFilterEffect)(effect)) {
|
|
70
|
-
//
|
|
71
|
-
// drop-shadow()
|
|
72
|
-
//
|
|
73
|
-
// same-origin content
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
70
|
+
// Apply all filters except drop-shadow() via ctx.filter.
|
|
71
|
+
// drop-shadow() is rendered separately through ctx.shadow*
|
|
72
|
+
// because ctx.filter="drop-shadow(...)" taints the canvas
|
|
73
|
+
// even for same-origin content (Chrome, Firefox).
|
|
74
|
+
this.ctx.filter = effect.safeFilterString || 'none';
|
|
75
|
+
if (effect.shadow) {
|
|
76
|
+
this.ctx.shadowOffsetX = effect.shadow.offsetX;
|
|
77
|
+
this.ctx.shadowOffsetY = effect.shadow.offsetY;
|
|
78
|
+
this.ctx.shadowBlur = effect.shadow.blur;
|
|
79
|
+
this.ctx.shadowColor = effect.shadow.color;
|
|
80
|
+
}
|
|
78
81
|
}
|
|
79
82
|
this.activeEffects.push(effect);
|
|
80
83
|
}
|
|
@@ -76,9 +76,23 @@ class BlendEffect {
|
|
|
76
76
|
exports.BlendEffect = BlendEffect;
|
|
77
77
|
class FilterEffect {
|
|
78
78
|
constructor(filterString) {
|
|
79
|
-
this.filterString = filterString;
|
|
80
79
|
this.type = 5 /* EffectType.FILTER */;
|
|
81
80
|
this.target = 2 /* EffectTarget.BACKGROUND_BORDERS */ | 4 /* EffectTarget.CONTENT */;
|
|
81
|
+
// Parse drop-shadow(...) out of the filter string so we can render it
|
|
82
|
+
// via ctx.shadow* instead of ctx.filter (which taints the canvas).
|
|
83
|
+
const dropShadowMatch = filterString.match(/drop-shadow\(\s*([\d.-]+)(px)?\s+([\d.-]+)(px)?\s+([\d.-]+)(px)?\s+(.+?)\s*\)/);
|
|
84
|
+
if (dropShadowMatch) {
|
|
85
|
+
this.shadow = {
|
|
86
|
+
offsetX: parseFloat(dropShadowMatch[1]),
|
|
87
|
+
offsetY: parseFloat(dropShadowMatch[3]),
|
|
88
|
+
blur: parseFloat(dropShadowMatch[5]),
|
|
89
|
+
color: dropShadowMatch[7].trim()
|
|
90
|
+
};
|
|
91
|
+
this.safeFilterString = filterString.replace(/drop-shadow\([^)]+\)\s*/g, '').trim();
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
this.safeFilterString = filterString;
|
|
95
|
+
}
|
|
82
96
|
}
|
|
83
97
|
}
|
|
84
98
|
exports.FilterEffect = FilterEffect;
|
|
@@ -57,9 +57,17 @@ export declare class BlendEffect implements IElementEffect {
|
|
|
57
57
|
constructor(mixBlendMode: MixBlendMode);
|
|
58
58
|
}
|
|
59
59
|
export declare class FilterEffect implements IElementEffect {
|
|
60
|
-
readonly filterString: string;
|
|
61
60
|
readonly type: EffectType;
|
|
62
61
|
readonly target: number;
|
|
62
|
+
/** CSS filter string with drop-shadow() stripped (safe for ctx.filter). */
|
|
63
|
+
readonly safeFilterString: string;
|
|
64
|
+
/** Shadow params for drop-shadow(), if present. */
|
|
65
|
+
readonly shadow?: {
|
|
66
|
+
offsetX: number;
|
|
67
|
+
offsetY: number;
|
|
68
|
+
blur: number;
|
|
69
|
+
color: string;
|
|
70
|
+
};
|
|
63
71
|
constructor(filterString: string);
|
|
64
72
|
}
|
|
65
73
|
export declare const isTransformEffect: (effect: IElementEffect) => effect is TransformEffect;
|