From a84f53ce55951d645e769d5b89421eb864466a3d Mon Sep 17 00:00:00 2001 From: Sergey Linev Date: Tue, 1 Oct 2024 14:05:54 +0200 Subject: [PATCH] Move svg2pdf compact build into libs directory --- libs/svg2pdf.mjs | 2 +- libs/svg2pdf/Readme.md | 2 +- modules/svg2pdf.mjs | 27 --------------------------- 3 files changed, 2 insertions(+), 29 deletions(-) delete mode 100644 modules/svg2pdf.mjs diff --git a/libs/svg2pdf.mjs b/libs/svg2pdf.mjs index b9d6138fc..bfb1be312 100644 --- a/libs/svg2pdf.mjs +++ b/libs/svg2pdf.mjs @@ -24,4 +24,4 @@ * SOFTWARE. */ -import t,{GState as e,ShadingPattern as r,TilingPattern as i,jsPDF as n}from"./jspdf.mjs";var a=function(t,e){return(a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(t,e)};function s(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}a(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}var o=function(){return(o=Object.assign||function(t){for(var e,r=1,i=arguments.length;r0&&n[n.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!n||a[1]>n[0]&&a[1]255?255:this.r,this.g=this.g<0||isNaN(this.g)?0:this.g>255?255:this.g,this.b=this.b<0||isNaN(this.b)?0:this.b>255?255:this.b}}return t.prototype.toRGB=function(){return"rgb("+this.r+", "+this.g+", "+this.b+")"},t.prototype.toRGBA=function(){return"rgba("+this.r+", "+this.g+", "+this.b+", "+(this.a||"1")+")"},t.prototype.toHex=function(){var t=this.r.toString(16),e=this.g.toString(16),r=this.b.toString(16);return 1==t.length&&(t="0"+t),1==e.length&&(e="0"+e),1==r.length&&(r="0"+r),"#"+t+e+r},t.prototype.getHelpXML=function(){for(var e=[],r=0;r "+l.toRGB()+" -> "+l.toHex());o.appendChild(u),o.appendChild(h),s.appendChild(o)}catch(t){}return s},t}(),f=function(){function t(t){this.color=t}return t.prototype.getFillData=function(t,e){return l(this,void 0,void 0,(function(){return u(this,(function(t){return[2,void 0]}))}))},t}(),c=function(){function t(){this.xmlSpace="",this.fill=null,this.fillOpacity=1,this.fontFamily="",this.fontSize=16,this.fontStyle="",this.fontWeight="",this.opacity=1,this.stroke=null,this.strokeDasharray=null,this.strokeDashoffset=0,this.strokeLinecap="",this.strokeLinejoin="",this.strokeMiterlimit=4,this.strokeOpacity=1,this.strokeWidth=1,this.alignmentBaseline="",this.textAnchor="",this.visibility="",this.color=null}return t.prototype.clone=function(){var e=new t;return e.xmlSpace=this.xmlSpace,e.fill=this.fill,e.fillOpacity=this.fillOpacity,e.fontFamily=this.fontFamily,e.fontSize=this.fontSize,e.fontStyle=this.fontStyle,e.fontWeight=this.fontWeight,e.opacity=this.opacity,e.stroke=this.stroke,e.strokeDasharray=this.strokeDasharray,e.strokeDashoffset=this.strokeDashoffset,e.strokeLinecap=this.strokeLinecap,e.strokeLinejoin=this.strokeLinejoin,e.strokeMiterlimit=this.strokeMiterlimit,e.strokeOpacity=this.strokeOpacity,e.strokeWidth=this.strokeWidth,e.textAnchor=this.textAnchor,e.alignmentBaseline=this.alignmentBaseline,e.visibility=this.visibility,e.color=this.color,e},t.default=function(){var e=new t;return e.xmlSpace="default",e.fill=new f(new h("rgb(0, 0, 0)")),e.fillOpacity=1,e.fontFamily="times",e.fontSize=16,e.fontStyle="normal",e.fontWeight="normal",e.opacity=1,e.stroke=null,e.strokeDasharray=null,e.strokeDashoffset=0,e.strokeLinecap="butt",e.strokeLinejoin="miter",e.strokeMiterlimit=4,e.strokeOpacity=1,e.strokeWidth=1,e.alignmentBaseline="baseline",e.textAnchor="start",e.visibility="visible",e.color=new h("rgb(0, 0, 0)"),e},t}(),p=function(){function t(t,e){var r,i,n;this.pdf=t,this.svg2pdfParameters=e.svg2pdfParameters,this.attributeState=e.attributeState?e.attributeState.clone():c.default(),this.viewport=e.viewport,this.refsHandler=e.refsHandler,this.styleSheets=e.styleSheets,this.textMeasure=e.textMeasure,this.transform=null!==(r=e.transform)&&void 0!==r?r:this.pdf.unitMatrix,this.withinClipPath=null!==(i=e.withinClipPath)&&void 0!==i&&i,this.withinUse=null!==(n=e.withinUse)&&void 0!==n&&n}return t.prototype.clone=function(e){var r,i,n,a;return void 0===e&&(e={}),new t(this.pdf,{svg2pdfParameters:this.svg2pdfParameters,attributeState:e.attributeState?e.attributeState.clone():this.attributeState.clone(),viewport:null!==(r=e.viewport)&&void 0!==r?r:this.viewport,refsHandler:this.refsHandler,styleSheets:this.styleSheets,textMeasure:this.textMeasure,transform:null!==(i=e.transform)&&void 0!==i?i:this.transform,withinClipPath:null!==(n=e.withinClipPath)&&void 0!==n?n:this.withinClipPath,withinUse:null!==(a=e.withinUse)&&void 0!==a?a:this.withinUse})},t}(),d=function(){function t(e){this.renderedElements={},this.idMap=e,this.idPrefix=String(t.instanceCounter++)}return t.prototype.getRendered=function(t,e,r){return l(this,void 0,void 0,(function(){var i,n;return u(this,(function(a){switch(a.label){case 0:return i=this.generateKey(t,e),this.renderedElements.hasOwnProperty(i)?[2,this.renderedElements[t]]:(n=this.get(t),this.renderedElements[i]=n,[4,r(n)]);case 1:return a.sent(),[2,n]}}))}))},t.prototype.get=function(t){return this.idMap[t]},t.prototype.generateKey=function(t,e){return this.idPrefix+"|"+t+"|"+(e||new h("rgb(0,0,0)")).toRGBA()},t.instanceCounter=0,t}();function m(t,e){return Math.atan2(e[1]-t[1],e[0]-t[0])}function g(t,e){return[2/3*(e[0]-t[0])+t[0],2/3*(e[1]-t[1])+t[1]]}function v(t){var e=Math.sqrt(t[0]*t[0]+t[1]*t[1]);return[t[0]/e,t[1]/e]}function y(t,e){return v([e[0]-t[0],e[1]-t[1]])}function b(t,e){return[t[0]+e[0],t[1]+e[1]]}function x(t,e){var r=t[0],i=t[1];return[e.a*r+e.c*i+e.e,e.b*r+e.d*i+e.f]}var S=function(){function t(){this.segments=[]}return t.prototype.moveTo=function(t,e){return this.segments.push(new w(t,e)),this},t.prototype.lineTo=function(t,e){return this.segments.push(new k(t,e)),this},t.prototype.curveTo=function(t,e,r,i,n,a){return this.segments.push(new M(t,e,r,i,n,a)),this},t.prototype.close=function(){return this.segments.push(new C),this},t.prototype.transform=function(t){this.segments.forEach((function(e){if(e instanceof w||e instanceof k||e instanceof M){var r=x([e.x,e.y],t);e.x=r[0],e.y=r[1]}if(e instanceof M){var i=x([e.x1,e.y1],t),n=x([e.x2,e.y2],t);e.x1=i[0],e.y1=i[1],e.x2=n[0],e.y2=n[1]}}))},t.prototype.draw=function(t){var e=t.pdf;this.segments.forEach((function(t){t instanceof w?e.moveTo(t.x,t.y):t instanceof k?e.lineTo(t.x,t.y):t instanceof M?e.curveTo(t.x1,t.y1,t.x2,t.y2,t.x,t.y):e.close()}))},t}(),w=function(t,e){this.x=t,this.y=e},k=function(t,e){this.x=t,this.y=e},M=function(t,e,r,i,n,a){this.x1=t,this.y1=e,this.x2=r,this.y2=i,this.x=n,this.y=a},C=function(){};function F(t,e){return e.split(",").indexOf((t.nodeName||t.tagName).toLowerCase())>=0}function T(t,e,r,i){var n;void 0===i&&(i=r);var a=null===(n=t.style)||void 0===n?void 0:n.getPropertyValue(i);if(a)return a;var s=e.getPropertyValue(t,i);return s||(t.hasAttribute(r)&&t.getAttribute(r)||void 0)}function A(t,e,r){if("none"===T(t.element,r.styleSheets,"display"))return!1;var i=e,n=T(t.element,r.styleSheets,"visibility");return n&&(i="hidden"!==n),i}function P(t,e,r){var i=A(t,e,r);return 0!==t.element.childNodes.length&&(t.children.forEach((function(t){t.isVisible(i,r)&&(i=!0)})),i)}var B=function(){function t(){this.markers=[]}return t.prototype.addMarker=function(t){this.markers.push(t)},t.prototype.draw=function(t){return l(this,void 0,void 0,(function(){var e,r,i,n,a,s,o;return u(this,(function(l){switch(l.label){case 0:e=0,l.label=1;case 1:return e=0?y+=(n-c*d)/2:l.indexOf("xMax")>=0&&(y+=n-c*d),l.indexOf("YMid")>=0?b+=(a-p*m)/2:l.indexOf("YMax")>=0&&(b+=a-p*m);var x=s.pdf.Matrix(1,0,0,1,y,b),S=s.pdf.Matrix(d,0,0,m,0,0);return s.pdf.matrixMult(S,x)}function X(t,e){if(!t||"none"===t)return e.pdf.unitMatrix;for(var r,i,n=/^[\s,]*matrix\(([^)]+)\)\s*/,a=/^[\s,]*translate\(([^)]+)\)\s*/,s=/^[\s,]*rotate\(([^)]+)\)\s*/,o=/^[\s,]*scale\(([^)]+)\)\s*/,l=/^[\s,]*skewX\(([^)]+)\)\s*/,u=/^[\s,]*skewY\(([^)]+)\)\s*/,h=e.pdf.unitMatrix;t.length>0&&t.length!==i;){i=t.length;var f=n.exec(t);if(f&&(r=I(f[1]),h=e.pdf.matrixMult(e.pdf.Matrix(r[0],r[1],r[2],r[3],r[4],r[5]),h),t=t.substr(f[0].length)),f=s.exec(t)){r=I(f[1]);var c=Math.PI*r[0]/180;if(h=e.pdf.matrixMult(e.pdf.Matrix(Math.cos(c),Math.sin(c),-Math.sin(c),Math.cos(c),0,0),h),r[1]||r[2]){var p=e.pdf.Matrix(1,0,0,1,r[1],r[2]),d=e.pdf.Matrix(1,0,0,1,-r[1],-r[2]);h=e.pdf.matrixMult(d,e.pdf.matrixMult(h,p))}t=t.substr(f[0].length)}(f=a.exec(t))&&(r=I(f[1]),h=e.pdf.matrixMult(e.pdf.Matrix(1,0,0,1,r[0],r[1]||0),h),t=t.substr(f[0].length)),(f=o.exec(t))&&((r=I(f[1]))[1]||(r[1]=r[0]),h=e.pdf.matrixMult(e.pdf.Matrix(r[0],0,0,r[1],0,0),h),t=t.substr(f[0].length)),(f=l.exec(t))&&(r=parseFloat(f[1]),r*=Math.PI/180,h=e.pdf.matrixMult(e.pdf.Matrix(1,0,Math.tan(r),1,0,0),h),t=t.substr(f[0].length)),(f=u.exec(t))&&(r=parseFloat(f[1]),r*=Math.PI/180,h=e.pdf.matrixMult(e.pdf.Matrix(1,Math.tan(r),0,1,0,0),h),t=t.substr(f[0].length))}return h}var Q=function(){function t(t,e){this.element=t,this.children=e,this.parent=null}return t.prototype.setParent=function(t){this.parent=t},t.prototype.getParent=function(){return this.parent},t.prototype.getBoundingBox=function(t){return"none"===T(this.element,t.styleSheets,"display")?[0,0,0,0]:this.getBoundingBoxCore(t)},t.prototype.computeNodeTransform=function(t){var e=this.computeNodeTransformCore(t),r=T(this.element,t.styleSheets,"transform");return r?t.pdf.matrixMult(e,X(r,t)):e},t}(),$=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return s(e,t),e.prototype.render=function(t){return Promise.resolve()},e.prototype.getBoundingBoxCore=function(t){return[]},e.prototype.computeNodeTransformCore=function(t){return t.pdf.unitMatrix},e}(Q),K=function(t){function i(e,r,i){var n=t.call(this,r,i)||this;return n.pdfGradientType=e,n.contextColor=void 0,n}return s(i,t),i.prototype.apply=function(t){return l(this,void 0,void 0,(function(){var i,n,a,s,o,l;return u(this,(function(u){return(i=this.element.getAttribute("id"))?(n=this.getStops(t.styleSheets),a=0,s=!1,n.forEach((function(t){var e=t.opacity;e&&1!==e&&(a+=e,s=!0)})),s&&(o=new e({opacity:a/n.length})),l=new r(this.pdfGradientType,this.getCoordinates(),n,o),t.pdf.addShadingPattern(i,l),[2]):[2]}))}))},i.prototype.getStops=function(t){var e=this;if(this.stops)return this.stops;if(void 0===this.contextColor){this.contextColor=null;for(var r=this;r;){var n=T(r.element,t,"color");if(n){this.contextColor=H(n,null);break}r=r.getParent()}}var a=[];return this.children.forEach((function(r){if("stop"===r.element.tagName.toLowerCase()){var n=T(r.element,t,"color"),s=H(T(r.element,t,"stop-color")||"",n?H(n,null):e.contextColor),o=parseFloat(T(r.element,t,"stop-opacity")||"1");a.push({offset:i.parseGradientOffset(r.element.getAttribute("offset")||"0"),color:[s.r,s.g,s.b],opacity:o})}})),this.stops=a},i.prototype.getBoundingBoxCore=function(t){return z(this.element,t)},i.prototype.computeNodeTransformCore=function(t){return t.pdf.unitMatrix},i.prototype.isVisible=function(t,e){return P(this,t,e)},i.parseGradientOffset=function(t){var e=parseFloat(t);return!isNaN(e)&&t.indexOf("%")>=0?e/100:e},i}($),Z=function(t){function e(e,r){return t.call(this,"axial",e,r)||this}return s(e,t),e.prototype.getCoordinates=function(){return[parseFloat(this.element.getAttribute("x1")||"0"),parseFloat(this.element.getAttribute("y1")||"0"),parseFloat(this.element.getAttribute("x2")||"1"),parseFloat(this.element.getAttribute("y2")||"0")]},e}(K),J=function(t){function e(e,r){return t.call(this,"radial",e,r)||this}return s(e,t),e.prototype.getCoordinates=function(){var t=this.element.getAttribute("cx"),e=this.element.getAttribute("cy"),r=this.element.getAttribute("fx"),i=this.element.getAttribute("fy");return[parseFloat(r||t||"0.5"),parseFloat(i||e||"0.5"),0,parseFloat(t||"0.5"),parseFloat(e||"0.5"),parseFloat(this.element.getAttribute("r")||"0.5")]},e}(K),tt=function(){function t(t,e){this.key=t,this.gradient=e}return t.prototype.getFillData=function(t,e){return l(this,void 0,void 0,(function(){var r,i,n;return u(this,(function(a){switch(a.label){case 0:return[4,e.refsHandler.getRendered(this.key,null,(function(t){return t.apply(new p(e.pdf,{refsHandler:e.refsHandler,textMeasure:e.textMeasure,styleSheets:e.styleSheets,viewport:e.viewport,svg2pdfParameters:e.svg2pdfParameters}))}))];case 1:return a.sent(),this.gradient.element.hasAttribute("gradientUnits")&&"objectboundingbox"!==this.gradient.element.getAttribute("gradientUnits").toLowerCase()?r=e.pdf.unitMatrix:(i=t.getBoundingBox(e),r=e.pdf.Matrix(i[2],0,0,i[3],i[0],i[1])),n=X(T(this.gradient.element,e.styleSheets,"gradientTransform","transform"),e),[2,{key:this.key,matrix:e.pdf.matrixMult(n,r)}]}}))}))},t}(),et=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return s(e,t),e.prototype.apply=function(t){return l(this,void 0,void 0,(function(){var e,r,n,a,s;return u(this,(function(o){switch(o.label){case 0:if(!(e=this.element.getAttribute("id")))return[2];r=this.getBoundingBox(t),n=new i([r[0],r[1],r[0]+r[2],r[1]+r[3]],r[2],r[3]),t.pdf.beginTilingPattern(n),a=0,s=this.children,o.label=1;case 1:return a=0?(a=t,!0):(t=t.toLowerCase(),!!W.hasOwnProperty(t)&&(a=t,!0))}))||(a="times"),a}(t.attributeState,C,t)}var F=T(i,t.styleSheets,"font-size");if(F){var A=t.pdf.getFontSize();t.attributeState.fontSize=O(F,A)}var P=T(i,t.styleSheets,"vertical-align")||T(i,t.styleSheets,"alignment-baseline");if(P){var B=P.match(/(baseline|text-bottom|alphabetic|ideographic|middle|central|mathematical|text-top|bottom|center|top|hanging)/);B&&(t.attributeState.alignmentBaseline=B[0])}var N=T(i,t.styleSheets,"text-anchor");N&&(t.attributeState.textAnchor=N)}function at(t,r,i){var n=1,a=1;n*=t.attributeState.fillOpacity,n*=t.attributeState.opacity,t.attributeState.fill instanceof f&&void 0!==t.attributeState.fill.color.a&&(n*=t.attributeState.fill.color.a),a*=t.attributeState.strokeOpacity,a*=t.attributeState.opacity,t.attributeState.stroke instanceof f&&void 0!==t.attributeState.stroke.color.a&&(a*=t.attributeState.stroke.color.a);var s,o,l=n<1,u=a<1;if(F(i,"use")?(l=!0,u=!0,n*=t.attributeState.fill?1:0,a*=t.attributeState.stroke?1:0):t.withinUse&&(t.attributeState.fill!==r.attributeState.fill?(l=!0,n*=t.attributeState.fill?1:0):l&&!t.attributeState.fill&&(n=0),t.attributeState.stroke!==r.attributeState.stroke?(u=!0,a*=t.attributeState.stroke?1:0):u&&!t.attributeState.stroke&&(a=0)),l||u){var h={};l&&(h.opacity=n),u&&(h["stroke-opacity"]=a),t.pdf.setGState(new e(h))}if(t.attributeState.fill&&t.attributeState.fill!==r.attributeState.fill&&t.attributeState.fill instanceof f&&t.attributeState.fill.color.ok&&!F(i,"text")&&t.pdf.setFillColor(t.attributeState.fill.color.r,t.attributeState.fill.color.g,t.attributeState.fill.color.b),t.attributeState.strokeWidth!==r.attributeState.strokeWidth&&t.pdf.setLineWidth(t.attributeState.strokeWidth),t.attributeState.stroke!==r.attributeState.stroke&&t.attributeState.stroke instanceof f&&t.pdf.setDrawColor(t.attributeState.stroke.color.r,t.attributeState.stroke.color.g,t.attributeState.stroke.color.b),t.attributeState.strokeLinecap!==r.attributeState.strokeLinecap&&t.pdf.setLineCap(t.attributeState.strokeLinecap),t.attributeState.strokeLinejoin!==r.attributeState.strokeLinejoin&&t.pdf.setLineJoin(t.attributeState.strokeLinejoin),t.attributeState.strokeDasharray===r.attributeState.strokeDasharray&&t.attributeState.strokeDashoffset===r.attributeState.strokeDashoffset||!t.attributeState.strokeDasharray||t.pdf.setLineDashPattern(t.attributeState.strokeDasharray,t.attributeState.strokeDashoffset),t.attributeState.strokeMiterlimit!==r.attributeState.strokeMiterlimit&&t.pdf.setLineMiterLimit(t.attributeState.strokeMiterlimit),t.attributeState.fontFamily!==r.attributeState.fontFamily&&(s=W.hasOwnProperty(t.attributeState.fontFamily)?W[t.attributeState.fontFamily]:t.attributeState.fontFamily),t.attributeState.fill&&t.attributeState.fill!==r.attributeState.fill&&t.attributeState.fill instanceof f&&t.attributeState.fill.color.ok){var c=t.attributeState.fill.color;t.pdf.setTextColor(c.r,c.g,c.b)}t.attributeState.fontWeight===r.attributeState.fontWeight&&t.attributeState.fontStyle===r.attributeState.fontStyle||(o=G(t.attributeState.fontStyle,t.attributeState.fontWeight)),void 0===s&&void 0===o||(void 0===s&&(s=W.hasOwnProperty(t.attributeState.fontFamily)?W[t.attributeState.fontFamily]:t.attributeState.fontFamily),t.pdf.setFont(s,o)),t.attributeState.fontSize!==r.attributeState.fontSize&&t.pdf.setFontSize(t.attributeState.fontSize*t.pdf.internal.scaleFactor)}function st(t,e,r){var i=E.exec(t);if(i){var n=i[1];return r.refsHandler.get(n)||void 0}}function ot(t,e,r){return l(this,void 0,void 0,(function(){var i,n;return u(this,(function(a){switch(a.label){case 0:return i=r.clone(),e.element.hasAttribute("clipPathUnits")&&"objectboundingbox"===e.element.getAttribute("clipPathUnits").toLowerCase()&&(n=t.getBoundingBox(r),i.transform=r.pdf.matrixMult(r.pdf.Matrix(n[2],0,0,n[3],n[0],n[1]),r.transform)),[4,e.apply(i)];case 1:return a.sent(),[2]}}))}))}var lt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return s(e,t),e.prototype.render=function(t){return l(this,void 0,void 0,(function(){var e,r,i,n;return u(this,(function(a){switch(a.label){case 0:return this.isVisible("hidden"!==t.attributeState.visibility,t)?((e=t.clone()).transform=e.pdf.matrixMult(this.computeNodeTransform(e),t.transform),nt(e,this),r=T(this.element,e.styleSheets,"clip-path"),(i=r&&"none"!==r)?(n=st(r,0,e))?n.isVisible(!0,e)?(e.pdf.saveGraphicsState(),[4,ot(this,n,e)]):[3,2]:[3,4]:[3,5]):[2];case 1:return a.sent(),[3,3];case 2:return[2];case 3:return[3,5];case 4:i=!1,a.label=5;case 5:return e.withinClipPath||e.pdf.saveGraphicsState(),at(e,t,this.element),[4,this.renderCore(e)];case 6:return a.sent(),e.withinClipPath||e.pdf.restoreGraphicsState(),i&&e.pdf.restoreGraphicsState(),[2]}}))}))},e}(Q),ut=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return s(e,t),e}(lt),ht=function(t){function e(e,r,i){var n=t.call(this,r,i)||this;return n.cachedPath=null,n.hasMarkers=e,n}return s(e,t),e.prototype.renderCore=function(t){return l(this,void 0,void 0,(function(){var e;return u(this,(function(r){switch(r.label){case 0:return null===(e=this.getCachedPath(t))||0===e.segments.length?[2]:(t.withinClipPath?e.transform(t.transform):t.pdf.setCurrentTransformationMatrix(t.transform),e.draw(t),[4,this.fillOrStroke(t)]);case 1:return r.sent(),this.hasMarkers?[4,this.drawMarkers(t,e)]:[3,3];case 2:r.sent(),r.label=3;case 3:return[2]}}))}))},e.prototype.getCachedPath=function(t){return this.cachedPath||(this.cachedPath=this.getPath(t))},e.prototype.drawMarkers=function(t,e){return l(this,void 0,void 0,(function(){return u(this,(function(r){switch(r.label){case 0:return[4,this.getMarkers(e,t).draw(t.clone({transform:t.pdf.unitMatrix}))];case 1:return r.sent(),[2]}}))}))},e.prototype.fillOrStroke=function(t){return l(this,void 0,void 0,(function(){var e,r,i,n,a;return u(this,(function(s){switch(s.label){case 0:return t.withinClipPath?[2]:(e=t.attributeState.fill,r=t.attributeState.stroke&&0!==t.attributeState.strokeWidth,e?[4,e.getFillData(this,t)]:[3,2]);case 1:return n=s.sent(),[3,3];case 2:n=void 0,s.label=3;case 3:return i=n,a="evenodd"===T(this.element,t.styleSheets,"fill-rule"),e&&r||t.withinUse?a?t.pdf.fillStrokeEvenOdd(i):t.pdf.fillStroke(i):e?a?t.pdf.fillEvenOdd(i):t.pdf.fill(i):r?t.pdf.stroke():t.pdf.discardPath(),[2]}}))}))},e.prototype.getBoundingBoxCore=function(t){var e=this.getCachedPath(t);if(!e||!e.segments.length)return[0,0,0,0];for(var r=Number.POSITIVE_INFINITY,i=Number.POSITIVE_INFINITY,n=Number.NEGATIVE_INFINITY,a=Number.NEGATIVE_INFINITY,s=0,o=0,l=0;lt){var i=s[r-1];f=(i instanceof w||i instanceof k||i instanceof M)&&i}}));var p=n&&(t===s.length-1||!(s[t]instanceof w)&&s[t+1]instanceof w),d=i&&t>0&&!(1===t&&s[t-1]instanceof w),g=s[t-1]||null;if(g instanceof w||g instanceof k||g instanceof M){if(e instanceof M)c&&a.addMarker(new N(r,[g.x,g.y],m(f?[f.x,f.y]:[g.x,g.y],[e.x1,e.y1]))),p&&a.addMarker(new N(n,[e.x,e.y],m([e.x2,e.y2],[e.x,e.y]))),d&&(l=y([g.x,g.y],[e.x1,e.y1]),l=g instanceof w?l:v(b(o,l)),a.addMarker(new N(i,[g.x,g.y],Math.atan2(l[1],l[0])))),o=y([e.x2,e.y2],[e.x,e.y]);else if(e instanceof w||e instanceof k){if(l=y([g.x,g.y],[e.x,e.y]),c){var x=f?y([f.x,f.y],[e.x,e.y]):l;a.addMarker(new N(r,[g.x,g.y],Math.atan2(x[1],x[0])))}if(p&&a.addMarker(new N(n,[e.x,e.y],Math.atan2(l[1],l[0]))),d){x=e instanceof w?o:g instanceof w?l:v(b(o,l));a.addMarker(new N(i,[g.x,g.y],Math.atan2(x[1],x[0])))}o=l}else if(e instanceof C){if(l=y([g.x,g.y],[u.x,u.y]),d){x=g instanceof w?l:v(b(o,l));a.addMarker(new N(i,[g.x,g.y],Math.atan2(x[1],x[0])))}if(p){x=v(b(l,h));a.addMarker(new N(n,[u.x,u.y],Math.atan2(x[1],x[0])))}o=l}}else{u=e instanceof w&&e;var S=s[t+1];(S instanceof w||S instanceof k||S instanceof M)&&(h=y([u.x,u.y],[S.x,S.y]))}},p=0;p=0;t--)if("default"===this.contexts[t].attributeState.xmlSpace&&(this.texts[t]=this.texts[t].replace(/\s+$/,"")),this.texts[t].match(/[^\s]/))return!1;return!0},t.prototype.measureText=function(t){for(var e=0;e0&&(m=t.textMeasure.measureTextWidth(d,t.attributeState),"default"===t.attributeState.xmlSpace&&c.match(/^\s/)&&(i=0),r=(h-m)/(d.length-i)||0),"visible"===f&&(g=t.attributeState.alignmentBaseline,v=bt(t.attributeState),t.pdf.text(d,a+o-e,s+l,{baseline:_(g),angle:t.transform,renderingMode:"fill"===v?void 0:v,charSpace:0===r?void 0:r}));else{for(y=[],b=new Mt(this,t.attributeState.textAnchor,a+o,s+l),y.push({type:"",chunk:b}),x=this.processTSpans(this,this.element,t,y,b,{prevText:" ",prevContext:t}),i=x?0:1,S=!0,w=y.length-1;w>=0;w--)S&&(S=y[w].chunk.rightTrimText());h>0&&(k=0,M=0,y.forEach((function(e){var r=e.chunk;r.measureText(t),r.textMeasures.forEach((function(t){var e=t.width,r=t.length;k+=e,M+=r}))})),r=(h-k)/(M-i)),y.reduce((function(e,i){var n=i.type,a=i.chunk;return"x"===n?a.setX(e[0]):"y"===n&&a.setY(e[1]),a.put(t,r)}),[0,0])}return t.pdf.restoreGraphicsState(),[2]}))}))},e.prototype.isVisible=function(t,e){return P(this,t,e)},e.prototype.getBoundingBoxCore=function(t){return z(this.element,t)},e.prototype.computeNodeTransformCore=function(t){return t.pdf.unitMatrix},e}(ut),Ft={a:7,c:6,h:1,l:2,m:2,r:4,q:4,s:4,t:2,v:1,z:0},Tt=[5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279];function At(t){return t>=48&&t<=57}function Pt(t){return t>=48&&t<=57||43===t||45===t||46===t}function Bt(t){this.index=0,this.path=t,this.max=t.length,this.result=[],this.param=0,this.err="",this.segmentStart=0,this.data=[]}function Nt(t){for(;t.index=5760&&Tt.indexOf(e)>=0);)t.index++;var e}function Et(t){var e=t.path.charCodeAt(t.index);return 48===e?(t.param=0,void t.index++):49===e?(t.param=1,void t.index++):void(t.err="SvgPath: arc flag can be 0 or 1 only (at pos "+t.index+")")}function Lt(t){var e,r=t.index,i=r,n=t.max,a=!1,s=!1,o=!1,l=!1;if(i>=n)t.err="SvgPath: missed param (at pos "+i+")";else if(43!==(e=t.path.charCodeAt(i))&&45!==e||(e=++i2&&(t.result.push([e,i[0],i[1]]),i=i.slice(2),r="l",e="m"===e?"l":"L"),"r"===r)t.result.push([e].concat(i));else for(;i.length>=Ft[r]&&(t.result.push([e].concat(i.splice(0,Ft[r]))),Ft[r]););}function _t(t){var e,r,i,n,a,s=t.max;if(t.segmentStart=t.index,e=t.path.charCodeAt(t.index),r=97==(32|e),function(t){switch(32|t){case 109:case 122:case 108:case 104:case 118:case 99:case 115:case 113:case 116:case 97:case 114:return!0}return!1}(e))if(n=Ft[t.path[t.index].toLowerCase()],t.index++,Nt(t),t.data=[],n){for(i=!1;;){for(a=n;a>0;a--){if(!r||3!==a&&4!==a?Lt(t):Et(t),t.err.length)return;t.data.push(t.param),Nt(t),i=!1,t.index=t.max)break;if(!Pt(t.path.charCodeAt(t.index)))break}}Ot(t)}else Ot(t);else t.err="SvgPath: bad command "+t.path[t.index]+" (at pos "+t.index+")"}function It(){if(!(this instanceof It))return new It;this.queue=[],this.cache=null}It.prototype.matrix=function(t){return 1===t[0]&&0===t[1]&&0===t[2]&&1===t[3]&&0===t[4]&&0===t[5]||(this.cache=null,this.queue.push(t)),this},It.prototype.translate=function(t,e){return 0===t&&0===e||(this.cache=null,this.queue.push([1,0,0,1,t,e])),this},It.prototype.scale=function(t,e){return 1===t&&1===e||(this.cache=null,this.queue.push([t,0,0,e,0,0])),this},It.prototype.rotate=function(t,e,r){var i,n,a;return 0!==t&&(this.translate(e,r),i=t*Math.PI/180,n=Math.cos(i),a=Math.sin(i),this.queue.push([n,a,-a,n,0,0]),this.cache=null,this.translate(-e,-r)),this},It.prototype.skewX=function(t){return 0!==t&&(this.cache=null,this.queue.push([1,0,Math.tan(t*Math.PI/180),1,0,0])),this},It.prototype.skewY=function(t){return 0!==t&&(this.cache=null,this.queue.push([1,Math.tan(t*Math.PI/180),0,1,0,0])),this},It.prototype.toArray=function(){if(this.cache)return this.cache;if(!this.queue.length)return this.cache=[1,0,0,1,0,0],this.cache;if(this.cache=this.queue[0],1===this.queue.length)return this.cache;for(var t=1;t1&&(n=1),n<-1&&(n=-1),(t*i-e*r<0?-1:1)*Math.acos(n)}function jt(t,e){var r=4/3*Math.tan(e/4),i=Math.cos(t),n=Math.sin(t),a=Math.cos(t+e),s=Math.sin(t+e);return[i,n,i-n*r,n+i*r,a+s*r,s-a*r,a,s]}var Gt=function(t,e,r,i,n,a,s,o,l){var u=Math.sin(l*Wt/360),h=Math.cos(l*Wt/360),f=h*(t-r)/2+u*(e-i)/2,c=-u*(t-r)/2+h*(e-i)/2;if(0===f&&0===c)return[];if(0===s||0===o)return[];s=Math.abs(s),o=Math.abs(o);var p=f*f/(s*s)+c*c/(o*o);p>1&&(s*=Math.sqrt(p),o*=Math.sqrt(p));var d=function(t,e,r,i,n,a,s,o,l,u){var h=u*(t-r)/2+l*(e-i)/2,f=-l*(t-r)/2+u*(e-i)/2,c=s*s,p=o*o,d=h*h,m=f*f,g=c*p-c*m-p*d;g<0&&(g=0),g/=c*m+p*d;var v=(g=Math.sqrt(g)*(n===a?-1:1))*s/o*f,y=g*-o/s*h,b=u*v-l*y+(t+r)/2,x=l*v+u*y+(e+i)/2,S=(h-v)/s,w=(f-y)/o,k=(-h-v)/s,M=(-f-y)/o,C=qt(1,0,S,w),F=qt(S,w,k,M);return 0===a&&F>0&&(F-=Wt),1===a&&F<0&&(F+=Wt),[b,x,C,F]}(t,e,r,i,n,a,s,o,u,h),m=[],g=d[2],v=d[3],y=Math.max(Math.ceil(Math.abs(v)/(Wt/4)),1);v/=y;for(var b=0;bMath.abs(u-a)?(u-n)/l:l/(u-a))/Math.PI,this.ax>=0?(this.rx=Math.sqrt(u),this.ry=Math.sqrt(h)):(this.ax+=90,this.rx=Math.sqrt(h),this.ry=Math.sqrt(u)),this},zt.prototype.isDegenerate=function(){return this.rx<1e-10*this.ry||this.ry<1e-10*this.rx};var Yt=zt;function Xt(t){if(!(this instanceof Xt))return new Xt(t);var e=function(t){var e=new Bt(t),r=e.max;for(Nt(e);e.index0,l=["m",(o=t.calc(i[1],i[2],h))[0],o[1]];break;default:for(l=[u=i[0]],h=u.toLowerCase()===u,e=1;e=0;)t.matrix(this.__stack[e].toArray());this.__matrix(t),this.__stack=[]}},Xt.prototype.toString=function(){var t="",e="",r=!1;this.__evaluateStack();for(var i=0,n=this.segments.length;i=0&&(t+=" "):l>=0&&(t+=" "),t+=l}e=s}return t},Xt.prototype.translate=function(t,e){return this.__stack.push(Ht().translate(t,e||0)),this},Xt.prototype.scale=function(t,e){return this.__stack.push(Ht().scale(t,e||0===e?e:t)),this},Xt.prototype.rotate=function(t,e,r){return this.__stack.push(Ht().rotate(t,e||0,r||0)),this},Xt.prototype.skewX=function(t){return this.__stack.push(Ht().skewX(t)),this},Xt.prototype.skewY=function(t){return this.__stack.push(Ht().skewY(t)),this},Xt.prototype.matrix=function(t){return this.__stack.push(Ht().matrix(t)),this},Xt.prototype.transform=function(t){return t.trim()?(this.__stack.push(function(t){var e,r,i=new Ht;return t.split(Vt).forEach((function(t){if(t.length)if(void 0===Dt[t])switch(r=t.split(Rt).map((function(t){return+t||0})),e){case"matrix":return void(6===r.length&&i.matrix(r));case"scale":return void(1===r.length?i.scale(r[0],r[0]):2===r.length&&i.scale(r[0],r[1]));case"rotate":return void(1===r.length?i.rotate(r[0],0,0):3===r.length&&i.rotate(r[0],r[1],r[2]));case"translate":return void(1===r.length?i.translate(r[0],0):2===r.length&&i.translate(r[0],r[1]));case"skewX":return void(1===r.length&&i.skewX(r[0]));case"skewY":return void(1===r.length&&i.skewY(r[0]))}else e=t})),i}(t)),this):this},Xt.prototype.round=function(t){var e,r=0,i=0,n=0,a=0;return t=t||0,this.__evaluateStack(),this.segments.forEach((function(s){var o=s[0].toLowerCase()===s[0];switch(s[0]){case"H":case"h":return o&&(s[1]+=n),n=s[1]-s[1].toFixed(t),void(s[1]=+s[1].toFixed(t));case"V":case"v":return o&&(s[1]+=a),a=s[1]-s[1].toFixed(t),void(s[1]=+s[1].toFixed(t));case"Z":case"z":return n=r,void(a=i);case"M":case"m":return o&&(s[1]+=n,s[2]+=a),n=s[1]-s[1].toFixed(t),a=s[2]-s[2].toFixed(t),r=n,i=a,s[1]=+s[1].toFixed(t),void(s[2]=+s[2].toFixed(t));case"A":case"a":return o&&(s[6]+=n,s[7]+=a),n=s[6]-s[6].toFixed(t),a=s[7]-s[7].toFixed(t),s[1]=+s[1].toFixed(t),s[2]=+s[2].toFixed(t),s[3]=+s[3].toFixed(t+2),s[6]=+s[6].toFixed(t),void(s[7]=+s[7].toFixed(t));default:return e=s.length,o&&(s[e-2]+=n,s[e-1]+=a),n=s[e-2]-s[e-2].toFixed(t),a=s[e-1]-s[e-1].toFixed(t),void s.forEach((function(e,r){r&&(s[r]=+s[r].toFixed(t))}))}})),this},Xt.prototype.iterate=function(t,e){var r,i,n,a=this.segments,s={},o=!1,l=0,u=0,h=0,f=0;if(e||this.__evaluateStack(),a.forEach((function(e,r){var i=t(e,r,l,u);Array.isArray(i)&&(s[r]=i,o=!0);var n=e[0]===e[0].toLowerCase();switch(e[0]){case"m":case"M":return l=e[1]+(n?l:0),u=e[2]+(n?u:0),h=l,void(f=u);case"h":case"H":return void(l=e[1]+(n?l:0));case"v":case"V":return void(u=e[1]+(n?u:0));case"z":case"Z":return l=h,void(u=f);default:l=e[e.length-2]+(n?l:0),u=e[e.length-1]+(n?u:0)}})),!o)return this;for(n=[],r=0;r=0;l--){var u=o.cssRules[l];if(u instanceof CSSStyleRule){var h=u;if(h.selectorText.indexOf(",")>=0){o.deleteRule(l);for(var f=h.cssText.substring(h.selectorText.length),c=t.splitSelectorAtCommas(h.selectorText),p=0;p",t.epsilon=.1,t}();function pe(t,e,r){var i,n,a;return void 0===r&&(r={}),l(this,void 0,void 0,(function(){var s,l,h,f,c,m,g,v,y,b,x;return u(this,(function(u){switch(u.label){case 0:return s=null!==(i=r.x)&&void 0!==i?i:0,l=null!==(n=r.y)&&void 0!==n?n:0,h=null!==(a=r.loadExternalStyleSheets)&&void 0!==a&&a,c=new d(f={}),[4,(m=new fe(t,h)).load()];case 1:return u.sent(),g=new dt(e.internal.pageSize.getWidth(),e.internal.pageSize.getHeight()),v=o(o({},r),{element:t}),y=new ce,b=new p(e,{refsHandler:c,styleSheets:m,viewport:g,svg2pdfParameters:v,textMeasure:y}),e.advancedAPI(),e.saveGraphicsState(),e.setCurrentTransformationMatrix(e.Matrix(1,0,0,1,s,l)),e.setLineWidth(b.attributeState.strokeWidth),x=b.attributeState.fill.color,e.setFillColor(x.r,x.g,x.b),e.setFont(b.attributeState.fontFamily),e.setFontSize(b.attributeState.fontSize*e.internal.scaleFactor),[4,he(t,f).render(b)];case 2:return u.sent(),e.restoreGraphicsState(),e.compatAPI(),b.textMeasure.cleanupTextMeasuring(),[2,e]}}))}))}n.API.svg=function(t,e){return void 0===e&&(e={}),pe(t,this,e)};export{pe as svg2pdf}; +import t,{GState as e,ShadingPattern as r,TilingPattern as i,jsPDF as n}from"./jspdf.mjs";var a=function(t,e){return(a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(t,e)};function s(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}a(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}var o=function(){return(o=Object.assign||function(t){for(var e,r=1,i=arguments.length;r0&&n[n.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!n||a[1]>n[0]&&a[1]255?255:this.r,this.g=this.g<0||isNaN(this.g)?0:this.g>255?255:this.g,this.b=this.b<0||isNaN(this.b)?0:this.b>255?255:this.b}}return t.prototype.toRGB=function(){return"rgb("+this.r+", "+this.g+", "+this.b+")"},t.prototype.toRGBA=function(){return"rgba("+this.r+", "+this.g+", "+this.b+", "+(this.a||"1")+")"},t.prototype.toHex=function(){var t=this.r.toString(16),e=this.g.toString(16),r=this.b.toString(16);return 1==t.length&&(t="0"+t),1==e.length&&(e="0"+e),1==r.length&&(r="0"+r),"#"+t+e+r},t.prototype.getHelpXML=function(){for(var e=[],r=0;r "+l.toRGB()+" -> "+l.toHex());o.appendChild(u),o.appendChild(h),s.appendChild(o)}catch(t){}return s},t}(),f=function(){function t(t){this.color=t}return t.prototype.getFillData=function(t,e){return l(this,void 0,void 0,(function(){return u(this,(function(t){return[2,void 0]}))}))},t}(),c=function(){function t(){this.xmlSpace="",this.fill=null,this.fillOpacity=1,this.fontFamily="",this.fontSize=16,this.fontStyle="",this.fontWeight="",this.opacity=1,this.stroke=null,this.strokeDasharray=null,this.strokeDashoffset=0,this.strokeLinecap="",this.strokeLinejoin="",this.strokeMiterlimit=4,this.strokeOpacity=1,this.strokeWidth=1,this.alignmentBaseline="",this.textAnchor="",this.visibility="",this.color=null}return t.prototype.clone=function(){var e=new t;return e.xmlSpace=this.xmlSpace,e.fill=this.fill,e.fillOpacity=this.fillOpacity,e.fontFamily=this.fontFamily,e.fontSize=this.fontSize,e.fontStyle=this.fontStyle,e.fontWeight=this.fontWeight,e.opacity=this.opacity,e.stroke=this.stroke,e.strokeDasharray=this.strokeDasharray,e.strokeDashoffset=this.strokeDashoffset,e.strokeLinecap=this.strokeLinecap,e.strokeLinejoin=this.strokeLinejoin,e.strokeMiterlimit=this.strokeMiterlimit,e.strokeOpacity=this.strokeOpacity,e.strokeWidth=this.strokeWidth,e.textAnchor=this.textAnchor,e.alignmentBaseline=this.alignmentBaseline,e.visibility=this.visibility,e.color=this.color,e},t.default=function(){var e=new t;return e.xmlSpace="default",e.fill=new f(new h("rgb(0, 0, 0)")),e.fillOpacity=1,e.fontFamily="times",e.fontSize=16,e.fontStyle="normal",e.fontWeight="normal",e.opacity=1,e.stroke=null,e.strokeDasharray=null,e.strokeDashoffset=0,e.strokeLinecap="butt",e.strokeLinejoin="miter",e.strokeMiterlimit=4,e.strokeOpacity=1,e.strokeWidth=1,e.alignmentBaseline="baseline",e.textAnchor="start",e.visibility="visible",e.color=new h("rgb(0, 0, 0)"),e},t}(),p=function(){function t(t,e){var r,i,n;this.pdf=t,this.svg2pdfParameters=e.svg2pdfParameters,this.attributeState=e.attributeState?e.attributeState.clone():c.default(),this.viewport=e.viewport,this.refsHandler=e.refsHandler,this.styleSheets=e.styleSheets,this.textMeasure=e.textMeasure,this.transform=null!==(r=e.transform)&&void 0!==r?r:this.pdf.unitMatrix,this.withinClipPath=null!==(i=e.withinClipPath)&&void 0!==i&&i,this.withinUse=null!==(n=e.withinUse)&&void 0!==n&&n}return t.prototype.clone=function(e){var r,i,n,a;return void 0===e&&(e={}),new t(this.pdf,{svg2pdfParameters:this.svg2pdfParameters,attributeState:e.attributeState?e.attributeState.clone():this.attributeState.clone(),viewport:null!==(r=e.viewport)&&void 0!==r?r:this.viewport,refsHandler:this.refsHandler,styleSheets:this.styleSheets,textMeasure:this.textMeasure,transform:null!==(i=e.transform)&&void 0!==i?i:this.transform,withinClipPath:null!==(n=e.withinClipPath)&&void 0!==n?n:this.withinClipPath,withinUse:null!==(a=e.withinUse)&&void 0!==a?a:this.withinUse})},t}(),d=function(){function t(e){this.renderedElements={},this.idMap=e,this.idPrefix=String(t.instanceCounter++)}return t.prototype.getRendered=function(t,e,r){return l(this,void 0,void 0,(function(){var i,n;return u(this,(function(a){switch(a.label){case 0:return i=this.generateKey(t,e),this.renderedElements.hasOwnProperty(i)?[2,this.renderedElements[t]]:(n=this.get(t),this.renderedElements[i]=n,[4,r(n)]);case 1:return a.sent(),[2,n]}}))}))},t.prototype.get=function(t){return this.idMap[t]},t.prototype.generateKey=function(t,e){return this.idPrefix+"|"+t+"|"+(e||new h("rgb(0,0,0)")).toRGBA()},t.instanceCounter=0,t}();function m(t,e){return Math.atan2(e[1]-t[1],e[0]-t[0])}function g(t,e){return[2/3*(e[0]-t[0])+t[0],2/3*(e[1]-t[1])+t[1]]}function v(t){var e=Math.sqrt(t[0]*t[0]+t[1]*t[1]);return[t[0]/e,t[1]/e]}function y(t,e){return v([e[0]-t[0],e[1]-t[1]])}function b(t,e){return[t[0]+e[0],t[1]+e[1]]}function x(t,e){var r=t[0],i=t[1];return[e.a*r+e.c*i+e.e,e.b*r+e.d*i+e.f]}var S=function(){function t(){this.segments=[]}return t.prototype.moveTo=function(t,e){return this.segments.push(new w(t,e)),this},t.prototype.lineTo=function(t,e){return this.segments.push(new k(t,e)),this},t.prototype.curveTo=function(t,e,r,i,n,a){return this.segments.push(new M(t,e,r,i,n,a)),this},t.prototype.close=function(){return this.segments.push(new C),this},t.prototype.transform=function(t){this.segments.forEach((function(e){if(e instanceof w||e instanceof k||e instanceof M){var r=x([e.x,e.y],t);e.x=r[0],e.y=r[1]}if(e instanceof M){var i=x([e.x1,e.y1],t),n=x([e.x2,e.y2],t);e.x1=i[0],e.y1=i[1],e.x2=n[0],e.y2=n[1]}}))},t.prototype.draw=function(t){var e=t.pdf;this.segments.forEach((function(t){t instanceof w?e.moveTo(t.x,t.y):t instanceof k?e.lineTo(t.x,t.y):t instanceof M?e.curveTo(t.x1,t.y1,t.x2,t.y2,t.x,t.y):e.close()}))},t}(),w=function(t,e){this.x=t,this.y=e},k=function(t,e){this.x=t,this.y=e},M=function(t,e,r,i,n,a){this.x1=t,this.y1=e,this.x2=r,this.y2=i,this.x=n,this.y=a},C=function(){};function F(t,e){return e.split(",").indexOf((t.nodeName||t.tagName).toLowerCase())>=0}function T(t,e,r,i){var n;void 0===i&&(i=r);var a=null===(n=t.style)||void 0===n?void 0:n.getPropertyValue(i);if(a)return a;var s=e.getPropertyValue(t,i);return s||(t.hasAttribute(r)&&t.getAttribute(r)||void 0)}function A(t,e,r){if("none"===T(t.element,r.styleSheets,"display"))return!1;var i=e,n=T(t.element,r.styleSheets,"visibility");return n&&(i="hidden"!==n),i}function P(t,e,r){var i=A(t,e,r);return 0!==t.element.childNodes.length&&(t.children.forEach((function(t){t.isVisible(i,r)&&(i=!0)})),i)}var B=function(){function t(){this.markers=[]}return t.prototype.addMarker=function(t){this.markers.push(t)},t.prototype.draw=function(t){return l(this,void 0,void 0,(function(){var e,r,i,n,a,s,o;return u(this,(function(l){switch(l.label){case 0:e=0,l.label=1;case 1:return e=0?y+=(n-c*d)/2:l.indexOf("xMax")>=0&&(y+=n-c*d),l.indexOf("YMid")>=0?b+=(a-p*m)/2:l.indexOf("YMax")>=0&&(b+=a-p*m);var x=s.pdf.Matrix(1,0,0,1,y,b),S=s.pdf.Matrix(d,0,0,m,0,0);return s.pdf.matrixMult(S,x)}function X(t,e){if(!t||"none"===t)return e.pdf.unitMatrix;for(var r,i,n=/^[\s,]*matrix\(([^)]+)\)\s*/,a=/^[\s,]*translate\(([^)]+)\)\s*/,s=/^[\s,]*rotate\(([^)]+)\)\s*/,o=/^[\s,]*scale\(([^)]+)\)\s*/,l=/^[\s,]*skewX\(([^)]+)\)\s*/,u=/^[\s,]*skewY\(([^)]+)\)\s*/,h=e.pdf.unitMatrix;t.length>0&&t.length!==i;){i=t.length;var f=n.exec(t);if(f&&(r=I(f[1]),h=e.pdf.matrixMult(e.pdf.Matrix(r[0],r[1],r[2],r[3],r[4],r[5]),h),t=t.substr(f[0].length)),f=s.exec(t)){r=I(f[1]);var c=Math.PI*r[0]/180;if(h=e.pdf.matrixMult(e.pdf.Matrix(Math.cos(c),Math.sin(c),-Math.sin(c),Math.cos(c),0,0),h),r[1]||r[2]){var p=e.pdf.Matrix(1,0,0,1,r[1],r[2]),d=e.pdf.Matrix(1,0,0,1,-r[1],-r[2]);h=e.pdf.matrixMult(d,e.pdf.matrixMult(h,p))}t=t.substr(f[0].length)}(f=a.exec(t))&&(r=I(f[1]),h=e.pdf.matrixMult(e.pdf.Matrix(1,0,0,1,r[0],r[1]||0),h),t=t.substr(f[0].length)),(f=o.exec(t))&&((r=I(f[1]))[1]||(r[1]=r[0]),h=e.pdf.matrixMult(e.pdf.Matrix(r[0],0,0,r[1],0,0),h),t=t.substr(f[0].length)),(f=l.exec(t))&&(r=parseFloat(f[1]),r*=Math.PI/180,h=e.pdf.matrixMult(e.pdf.Matrix(1,0,Math.tan(r),1,0,0),h),t=t.substr(f[0].length)),(f=u.exec(t))&&(r=parseFloat(f[1]),r*=Math.PI/180,h=e.pdf.matrixMult(e.pdf.Matrix(1,Math.tan(r),0,1,0,0),h),t=t.substr(f[0].length))}return h}var Q=function(){function t(t,e){this.element=t,this.children=e,this.parent=null}return t.prototype.setParent=function(t){this.parent=t},t.prototype.getParent=function(){return this.parent},t.prototype.getBoundingBox=function(t){return"none"===T(this.element,t.styleSheets,"display")?[0,0,0,0]:this.getBoundingBoxCore(t)},t.prototype.computeNodeTransform=function(t){var e=this.computeNodeTransformCore(t),r=T(this.element,t.styleSheets,"transform");return r?t.pdf.matrixMult(e,X(r,t)):e},t}(),$=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return s(e,t),e.prototype.render=function(t){return Promise.resolve()},e.prototype.getBoundingBoxCore=function(t){return[]},e.prototype.computeNodeTransformCore=function(t){return t.pdf.unitMatrix},e}(Q),K=function(t){function i(e,r,i){var n=t.call(this,r,i)||this;return n.pdfGradientType=e,n.contextColor=void 0,n}return s(i,t),i.prototype.apply=function(t){return l(this,void 0,void 0,(function(){var i,n,a,s,o,l;return u(this,(function(u){return(i=this.element.getAttribute("id"))?(n=this.getStops(t.styleSheets),a=0,s=!1,n.forEach((function(t){var e=t.opacity;e&&1!==e&&(a+=e,s=!0)})),s&&(o=new e({opacity:a/n.length})),l=new r(this.pdfGradientType,this.getCoordinates(),n,o),t.pdf.addShadingPattern(i,l),[2]):[2]}))}))},i.prototype.getStops=function(t){var e=this;if(this.stops)return this.stops;if(void 0===this.contextColor){this.contextColor=null;for(var r=this;r;){var n=T(r.element,t,"color");if(n){this.contextColor=H(n,null);break}r=r.getParent()}}var a=[];return this.children.forEach((function(r){if("stop"===r.element.tagName.toLowerCase()){var n=T(r.element,t,"color"),s=H(T(r.element,t,"stop-color")||"",n?H(n,null):e.contextColor),o=parseFloat(T(r.element,t,"stop-opacity")||"1");a.push({offset:i.parseGradientOffset(r.element.getAttribute("offset")||"0"),color:[s.r,s.g,s.b],opacity:o})}})),this.stops=a},i.prototype.getBoundingBoxCore=function(t){return U(this.element,t)},i.prototype.computeNodeTransformCore=function(t){return t.pdf.unitMatrix},i.prototype.isVisible=function(t,e){return P(this,t,e)},i.parseGradientOffset=function(t){var e=parseFloat(t);return!isNaN(e)&&t.indexOf("%")>=0?e/100:e},i}($),Z=function(t){function e(e,r){return t.call(this,"axial",e,r)||this}return s(e,t),e.prototype.getCoordinates=function(){return[parseFloat(this.element.getAttribute("x1")||"0"),parseFloat(this.element.getAttribute("y1")||"0"),parseFloat(this.element.getAttribute("x2")||"1"),parseFloat(this.element.getAttribute("y2")||"0")]},e}(K),J=function(t){function e(e,r){return t.call(this,"radial",e,r)||this}return s(e,t),e.prototype.getCoordinates=function(){var t=this.element.getAttribute("cx"),e=this.element.getAttribute("cy"),r=this.element.getAttribute("fx"),i=this.element.getAttribute("fy");return[parseFloat(r||t||"0.5"),parseFloat(i||e||"0.5"),0,parseFloat(t||"0.5"),parseFloat(e||"0.5"),parseFloat(this.element.getAttribute("r")||"0.5")]},e}(K),tt=function(){function t(t,e){this.key=t,this.gradient=e}return t.prototype.getFillData=function(t,e){return l(this,void 0,void 0,(function(){var r,i,n;return u(this,(function(a){switch(a.label){case 0:return[4,e.refsHandler.getRendered(this.key,null,(function(t){return t.apply(new p(e.pdf,{refsHandler:e.refsHandler,textMeasure:e.textMeasure,styleSheets:e.styleSheets,viewport:e.viewport,svg2pdfParameters:e.svg2pdfParameters}))}))];case 1:return a.sent(),this.gradient.element.hasAttribute("gradientUnits")&&"objectboundingbox"!==this.gradient.element.getAttribute("gradientUnits").toLowerCase()?r=e.pdf.unitMatrix:(i=t.getBoundingBox(e),r=e.pdf.Matrix(i[2],0,0,i[3],i[0],i[1])),n=X(T(this.gradient.element,e.styleSheets,"gradientTransform","transform"),e),[2,{key:this.key,matrix:e.pdf.matrixMult(n,r)}]}}))}))},t}(),et=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return s(e,t),e.prototype.apply=function(t){return l(this,void 0,void 0,(function(){var e,r,n,a,s;return u(this,(function(o){switch(o.label){case 0:if(!(e=this.element.getAttribute("id")))return[2];r=this.getBoundingBox(t),n=new i([r[0],r[1],r[0]+r[2],r[1]+r[3]],r[2],r[3]),t.pdf.beginTilingPattern(n),a=0,s=this.children,o.label=1;case 1:return a=0?(a=t,!0):(t=t.toLowerCase(),!!W.hasOwnProperty(t)&&(a=t,!0))}))||(a="times"),a}(t.attributeState,C,t)}var F=T(i,t.styleSheets,"font-size");if(F){var A=t.pdf.getFontSize();t.attributeState.fontSize=O(F,A)}var P=T(i,t.styleSheets,"vertical-align")||T(i,t.styleSheets,"alignment-baseline");if(P){var B=P.match(/(baseline|text-bottom|alphabetic|ideographic|middle|central|mathematical|text-top|bottom|center|top|hanging)/);B&&(t.attributeState.alignmentBaseline=B[0])}var N=T(i,t.styleSheets,"text-anchor");N&&(t.attributeState.textAnchor=N)}function at(t,r,i){var n=1,a=1;n*=t.attributeState.fillOpacity,n*=t.attributeState.opacity,t.attributeState.fill instanceof f&&void 0!==t.attributeState.fill.color.a&&(n*=t.attributeState.fill.color.a),a*=t.attributeState.strokeOpacity,a*=t.attributeState.opacity,t.attributeState.stroke instanceof f&&void 0!==t.attributeState.stroke.color.a&&(a*=t.attributeState.stroke.color.a);var s,o,l=n<1,u=a<1;if(F(i,"use")?(l=!0,u=!0,n*=t.attributeState.fill?1:0,a*=t.attributeState.stroke?1:0):t.withinUse&&(t.attributeState.fill!==r.attributeState.fill?(l=!0,n*=t.attributeState.fill?1:0):l&&!t.attributeState.fill&&(n=0),t.attributeState.stroke!==r.attributeState.stroke?(u=!0,a*=t.attributeState.stroke?1:0):u&&!t.attributeState.stroke&&(a=0)),l||u){var h={};l&&(h.opacity=n),u&&(h["stroke-opacity"]=a),t.pdf.setGState(new e(h))}if(t.attributeState.fill&&t.attributeState.fill!==r.attributeState.fill&&t.attributeState.fill instanceof f&&t.attributeState.fill.color.ok&&!F(i,"text")&&t.pdf.setFillColor(t.attributeState.fill.color.r,t.attributeState.fill.color.g,t.attributeState.fill.color.b),t.attributeState.strokeWidth!==r.attributeState.strokeWidth&&t.pdf.setLineWidth(t.attributeState.strokeWidth),t.attributeState.stroke!==r.attributeState.stroke&&t.attributeState.stroke instanceof f&&t.pdf.setDrawColor(t.attributeState.stroke.color.r,t.attributeState.stroke.color.g,t.attributeState.stroke.color.b),t.attributeState.strokeLinecap!==r.attributeState.strokeLinecap&&t.pdf.setLineCap(t.attributeState.strokeLinecap),t.attributeState.strokeLinejoin!==r.attributeState.strokeLinejoin&&t.pdf.setLineJoin(t.attributeState.strokeLinejoin),t.attributeState.strokeDasharray===r.attributeState.strokeDasharray&&t.attributeState.strokeDashoffset===r.attributeState.strokeDashoffset||!t.attributeState.strokeDasharray||t.pdf.setLineDashPattern(t.attributeState.strokeDasharray,t.attributeState.strokeDashoffset),t.attributeState.strokeMiterlimit!==r.attributeState.strokeMiterlimit&&t.pdf.setLineMiterLimit(t.attributeState.strokeMiterlimit),t.attributeState.fontFamily!==r.attributeState.fontFamily&&(s=W.hasOwnProperty(t.attributeState.fontFamily)?W[t.attributeState.fontFamily]:t.attributeState.fontFamily),t.attributeState.fill&&t.attributeState.fill!==r.attributeState.fill&&t.attributeState.fill instanceof f&&t.attributeState.fill.color.ok){var c=t.attributeState.fill.color;t.pdf.setTextColor(c.r,c.g,c.b)}t.attributeState.fontWeight===r.attributeState.fontWeight&&t.attributeState.fontStyle===r.attributeState.fontStyle||(o=G(t.attributeState.fontStyle,t.attributeState.fontWeight)),void 0===s&&void 0===o||(void 0===s&&(s=W.hasOwnProperty(t.attributeState.fontFamily)?W[t.attributeState.fontFamily]:t.attributeState.fontFamily),t.pdf.setFont(s,o)),t.attributeState.fontSize!==r.attributeState.fontSize&&t.pdf.setFontSize(t.attributeState.fontSize*t.pdf.internal.scaleFactor)}function st(t,e,r){var i=E.exec(t);if(i){var n=i[1];return r.refsHandler.get(n)||void 0}}function ot(t,e,r){return l(this,void 0,void 0,(function(){var i,n;return u(this,(function(a){switch(a.label){case 0:return i=r.clone(),e.element.hasAttribute("clipPathUnits")&&"objectboundingbox"===e.element.getAttribute("clipPathUnits").toLowerCase()&&(n=t.getBoundingBox(r),i.transform=r.pdf.matrixMult(r.pdf.Matrix(n[2],0,0,n[3],n[0],n[1]),r.transform)),[4,e.apply(i)];case 1:return a.sent(),[2]}}))}))}var lt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return s(e,t),e.prototype.render=function(t){return l(this,void 0,void 0,(function(){var e,r,i,n;return u(this,(function(a){switch(a.label){case 0:return this.isVisible("hidden"!==t.attributeState.visibility,t)?((e=t.clone()).transform=e.pdf.matrixMult(this.computeNodeTransform(e),t.transform),nt(e,this),r=T(this.element,e.styleSheets,"clip-path"),(i=r&&"none"!==r)?(n=st(r,0,e))?n.isVisible(!0,e)?(e.pdf.saveGraphicsState(),[4,ot(this,n,e)]):[3,2]:[3,4]:[3,5]):[2];case 1:return a.sent(),[3,3];case 2:return[2];case 3:return[3,5];case 4:i=!1,a.label=5;case 5:return e.withinClipPath||e.pdf.saveGraphicsState(),at(e,t,this.element),[4,this.renderCore(e)];case 6:return a.sent(),e.withinClipPath||e.pdf.restoreGraphicsState(),i&&e.pdf.restoreGraphicsState(),[2]}}))}))},e}(Q),ut=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return s(e,t),e}(lt),ht=function(t){function e(e,r,i){var n=t.call(this,r,i)||this;return n.cachedPath=null,n.hasMarkers=e,n}return s(e,t),e.prototype.renderCore=function(t){return l(this,void 0,void 0,(function(){var e;return u(this,(function(r){switch(r.label){case 0:return null===(e=this.getCachedPath(t))||0===e.segments.length?[2]:(t.withinClipPath?e.transform(t.transform):t.pdf.setCurrentTransformationMatrix(t.transform),e.draw(t),[4,this.fillOrStroke(t)]);case 1:return r.sent(),this.hasMarkers?[4,this.drawMarkers(t,e)]:[3,3];case 2:r.sent(),r.label=3;case 3:return[2]}}))}))},e.prototype.getCachedPath=function(t){return this.cachedPath||(this.cachedPath=this.getPath(t))},e.prototype.drawMarkers=function(t,e){return l(this,void 0,void 0,(function(){return u(this,(function(r){switch(r.label){case 0:return[4,this.getMarkers(e,t).draw(t.clone({transform:t.pdf.unitMatrix}))];case 1:return r.sent(),[2]}}))}))},e.prototype.fillOrStroke=function(t){return l(this,void 0,void 0,(function(){var e,r,i,n,a;return u(this,(function(s){switch(s.label){case 0:return t.withinClipPath?[2]:(e=t.attributeState.fill,r=t.attributeState.stroke&&0!==t.attributeState.strokeWidth,e?[4,e.getFillData(this,t)]:[3,2]);case 1:return n=s.sent(),[3,3];case 2:n=void 0,s.label=3;case 3:return i=n,a="evenodd"===T(this.element,t.styleSheets,"fill-rule"),e&&r||t.withinUse?a?t.pdf.fillStrokeEvenOdd(i):t.pdf.fillStroke(i):e?a?t.pdf.fillEvenOdd(i):t.pdf.fill(i):r?t.pdf.stroke():t.pdf.discardPath(),[2]}}))}))},e.prototype.getBoundingBoxCore=function(t){var e=this.getCachedPath(t);if(!e||!e.segments.length)return[0,0,0,0];for(var r=Number.POSITIVE_INFINITY,i=Number.POSITIVE_INFINITY,n=Number.NEGATIVE_INFINITY,a=Number.NEGATIVE_INFINITY,s=0,o=0,l=0;lt){var i=s[r-1];f=(i instanceof w||i instanceof k||i instanceof M)&&i}}));var p=n&&(t===s.length-1||!(s[t]instanceof w)&&s[t+1]instanceof w),d=i&&t>0&&!(1===t&&s[t-1]instanceof w),g=s[t-1]||null;if(g instanceof w||g instanceof k||g instanceof M){if(e instanceof M)c&&a.addMarker(new N(r,[g.x,g.y],m(f?[f.x,f.y]:[g.x,g.y],[e.x1,e.y1]))),p&&a.addMarker(new N(n,[e.x,e.y],m([e.x2,e.y2],[e.x,e.y]))),d&&(l=y([g.x,g.y],[e.x1,e.y1]),l=g instanceof w?l:v(b(o,l)),a.addMarker(new N(i,[g.x,g.y],Math.atan2(l[1],l[0])))),o=y([e.x2,e.y2],[e.x,e.y]);else if(e instanceof w||e instanceof k){if(l=y([g.x,g.y],[e.x,e.y]),c){var x=f?y([f.x,f.y],[e.x,e.y]):l;a.addMarker(new N(r,[g.x,g.y],Math.atan2(x[1],x[0])))}if(p&&a.addMarker(new N(n,[e.x,e.y],Math.atan2(l[1],l[0]))),d){x=e instanceof w?o:g instanceof w?l:v(b(o,l));a.addMarker(new N(i,[g.x,g.y],Math.atan2(x[1],x[0])))}o=l}else if(e instanceof C){if(l=y([g.x,g.y],[u.x,u.y]),d){x=g instanceof w?l:v(b(o,l));a.addMarker(new N(i,[g.x,g.y],Math.atan2(x[1],x[0])))}if(p){x=v(b(l,h));a.addMarker(new N(n,[u.x,u.y],Math.atan2(x[1],x[0])))}o=l}}else{u=e instanceof w&&e;var S=s[t+1];(S instanceof w||S instanceof k||S instanceof M)&&(h=y([u.x,u.y],[S.x,S.y]))}},p=0;p=0;t--)if("default"===this.contexts[t].attributeState.xmlSpace&&(this.texts[t]=this.texts[t].replace(/\s+$/,"")),this.texts[t].match(/[^\s]/))return!1;return!0},t.prototype.measureText=function(t){for(var e=0;e0&&(m=t.textMeasure.measureTextWidth(d,t.attributeState),"default"===t.attributeState.xmlSpace&&c.match(/^\s/)&&(i=0),r=(h-m)/(d.length-i)||0),"visible"===f&&(g=t.attributeState.alignmentBaseline,v=bt(t.attributeState),t.pdf.text(d,a+o-e,s+l,{baseline:_(g),angle:t.transform,renderingMode:"fill"===v?void 0:v,charSpace:0===r?void 0:r}),this.boundingBox=[a+o-e,s+l-n,t.textMeasure.measureTextWidth(d,t.attributeState),n],"baseline"===g&&(this.boundingBox[1]+=.2*n));else{for(y=[],b=new Mt(this,t.attributeState.textAnchor,a+o,s+l),y.push({type:"",chunk:b}),x=this.processTSpans(this,this.element,t,y,b,{prevText:" ",prevContext:t}),i=x?0:1,S=!0,w=y.length-1;w>=0;w--)S&&(S=y[w].chunk.rightTrimText());h>0&&(k=0,M=0,y.forEach((function(e){var r=e.chunk;r.measureText(t),r.textMeasures.forEach((function(t){var e=t.width,r=t.length;k+=e,M+=r}))})),r=(h-k)/(M-i)),y.reduce((function(e,i){var n=i.type,a=i.chunk;return"x"===n?a.setX(e[0]):"y"===n&&a.setY(e[1]),a.put(t,r)}),[0,0])}return t.pdf.restoreGraphicsState(),[2]}))}))},e.prototype.isVisible=function(t,e){return P(this,t,e)},e.prototype.getBoundingBoxCore=function(t){return this.boundingBox.length>0?this.boundingBox:U(this.element,t)},e.prototype.computeNodeTransformCore=function(t){return t.pdf.unitMatrix},e}(ut),Ft={a:7,c:6,h:1,l:2,m:2,r:4,q:4,s:4,t:2,v:1,z:0},Tt=[5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279];function At(t){return t>=48&&t<=57}function Pt(t){return t>=48&&t<=57||43===t||45===t||46===t}function Bt(t){this.index=0,this.path=t,this.max=t.length,this.result=[],this.param=0,this.err="",this.segmentStart=0,this.data=[]}function Nt(t){for(;t.index=5760&&Tt.indexOf(e)>=0);)t.index++;var e}function Et(t){var e=t.path.charCodeAt(t.index);return 48===e?(t.param=0,void t.index++):49===e?(t.param=1,void t.index++):void(t.err="SvgPath: arc flag can be 0 or 1 only (at pos "+t.index+")")}function Lt(t){var e,r=t.index,i=r,n=t.max,a=!1,s=!1,o=!1,l=!1;if(i>=n)t.err="SvgPath: missed param (at pos "+i+")";else if(43!==(e=t.path.charCodeAt(i))&&45!==e||(e=++i2&&(t.result.push([e,i[0],i[1]]),i=i.slice(2),r="l",e="m"===e?"l":"L"),"r"===r)t.result.push([e].concat(i));else for(;i.length>=Ft[r]&&(t.result.push([e].concat(i.splice(0,Ft[r]))),Ft[r]););}function _t(t){var e,r,i,n,a,s=t.max;if(t.segmentStart=t.index,e=t.path.charCodeAt(t.index),r=97==(32|e),function(t){switch(32|t){case 109:case 122:case 108:case 104:case 118:case 99:case 115:case 113:case 116:case 97:case 114:return!0}return!1}(e))if(n=Ft[t.path[t.index].toLowerCase()],t.index++,Nt(t),t.data=[],n){for(i=!1;;){for(a=n;a>0;a--){if(!r||3!==a&&4!==a?Lt(t):Et(t),t.err.length)return;t.data.push(t.param),Nt(t),i=!1,t.index=t.max)break;if(!Pt(t.path.charCodeAt(t.index)))break}}Ot(t)}else Ot(t);else t.err="SvgPath: bad command "+t.path[t.index]+" (at pos "+t.index+")"}function It(){if(!(this instanceof It))return new It;this.queue=[],this.cache=null}It.prototype.matrix=function(t){return 1===t[0]&&0===t[1]&&0===t[2]&&1===t[3]&&0===t[4]&&0===t[5]||(this.cache=null,this.queue.push(t)),this},It.prototype.translate=function(t,e){return 0===t&&0===e||(this.cache=null,this.queue.push([1,0,0,1,t,e])),this},It.prototype.scale=function(t,e){return 1===t&&1===e||(this.cache=null,this.queue.push([t,0,0,e,0,0])),this},It.prototype.rotate=function(t,e,r){var i,n,a;return 0!==t&&(this.translate(e,r),i=t*Math.PI/180,n=Math.cos(i),a=Math.sin(i),this.queue.push([n,a,-a,n,0,0]),this.cache=null,this.translate(-e,-r)),this},It.prototype.skewX=function(t){return 0!==t&&(this.cache=null,this.queue.push([1,0,Math.tan(t*Math.PI/180),1,0,0])),this},It.prototype.skewY=function(t){return 0!==t&&(this.cache=null,this.queue.push([1,Math.tan(t*Math.PI/180),0,1,0,0])),this},It.prototype.toArray=function(){if(this.cache)return this.cache;if(!this.queue.length)return this.cache=[1,0,0,1,0,0],this.cache;if(this.cache=this.queue[0],1===this.queue.length)return this.cache;for(var t=1;t1&&(n=1),n<-1&&(n=-1),(t*i-e*r<0?-1:1)*Math.acos(n)}function jt(t,e){var r=4/3*Math.tan(e/4),i=Math.cos(t),n=Math.sin(t),a=Math.cos(t+e),s=Math.sin(t+e);return[i,n,i-n*r,n+i*r,a+s*r,s-a*r,a,s]}var Gt=function(t,e,r,i,n,a,s,o,l){var u=Math.sin(l*Wt/360),h=Math.cos(l*Wt/360),f=h*(t-r)/2+u*(e-i)/2,c=-u*(t-r)/2+h*(e-i)/2;if(0===f&&0===c)return[];if(0===s||0===o)return[];s=Math.abs(s),o=Math.abs(o);var p=f*f/(s*s)+c*c/(o*o);p>1&&(s*=Math.sqrt(p),o*=Math.sqrt(p));var d=function(t,e,r,i,n,a,s,o,l,u){var h=u*(t-r)/2+l*(e-i)/2,f=-l*(t-r)/2+u*(e-i)/2,c=s*s,p=o*o,d=h*h,m=f*f,g=c*p-c*m-p*d;g<0&&(g=0),g/=c*m+p*d;var v=(g=Math.sqrt(g)*(n===a?-1:1))*s/o*f,y=g*-o/s*h,b=u*v-l*y+(t+r)/2,x=l*v+u*y+(e+i)/2,S=(h-v)/s,w=(f-y)/o,k=(-h-v)/s,M=(-f-y)/o,C=qt(1,0,S,w),F=qt(S,w,k,M);return 0===a&&F>0&&(F-=Wt),1===a&&F<0&&(F+=Wt),[b,x,C,F]}(t,e,r,i,n,a,s,o,u,h),m=[],g=d[2],v=d[3],y=Math.max(Math.ceil(Math.abs(v)/(Wt/4)),1);v/=y;for(var b=0;bMath.abs(u-a)?(u-n)/l:l/(u-a))/Math.PI,this.ax>=0?(this.rx=Math.sqrt(u),this.ry=Math.sqrt(h)):(this.ax+=90,this.rx=Math.sqrt(h),this.ry=Math.sqrt(u)),this},Ut.prototype.isDegenerate=function(){return this.rx<1e-10*this.ry||this.ry<1e-10*this.rx};var Yt=Ut;function Xt(t){if(!(this instanceof Xt))return new Xt(t);var e=function(t){var e=new Bt(t),r=e.max;for(Nt(e);e.index0,l=["m",(o=t.calc(i[1],i[2],h))[0],o[1]];break;default:for(l=[u=i[0]],h=u.toLowerCase()===u,e=1;e=0;)t.matrix(this.__stack[e].toArray());this.__matrix(t),this.__stack=[]}},Xt.prototype.toString=function(){var t="",e="",r=!1;this.__evaluateStack();for(var i=0,n=this.segments.length;i=0&&(t+=" "):l>=0&&(t+=" "),t+=l}e=s}return t},Xt.prototype.translate=function(t,e){return this.__stack.push(Ht().translate(t,e||0)),this},Xt.prototype.scale=function(t,e){return this.__stack.push(Ht().scale(t,e||0===e?e:t)),this},Xt.prototype.rotate=function(t,e,r){return this.__stack.push(Ht().rotate(t,e||0,r||0)),this},Xt.prototype.skewX=function(t){return this.__stack.push(Ht().skewX(t)),this},Xt.prototype.skewY=function(t){return this.__stack.push(Ht().skewY(t)),this},Xt.prototype.matrix=function(t){return this.__stack.push(Ht().matrix(t)),this},Xt.prototype.transform=function(t){return t.trim()?(this.__stack.push(function(t){var e,r,i=new Ht;return t.split(Vt).forEach((function(t){if(t.length)if(void 0===Dt[t])switch(r=t.split(Rt).map((function(t){return+t||0})),e){case"matrix":return void(6===r.length&&i.matrix(r));case"scale":return void(1===r.length?i.scale(r[0],r[0]):2===r.length&&i.scale(r[0],r[1]));case"rotate":return void(1===r.length?i.rotate(r[0],0,0):3===r.length&&i.rotate(r[0],r[1],r[2]));case"translate":return void(1===r.length?i.translate(r[0],0):2===r.length&&i.translate(r[0],r[1]));case"skewX":return void(1===r.length&&i.skewX(r[0]));case"skewY":return void(1===r.length&&i.skewY(r[0]))}else e=t})),i}(t)),this):this},Xt.prototype.round=function(t){var e,r=0,i=0,n=0,a=0;return t=t||0,this.__evaluateStack(),this.segments.forEach((function(s){var o=s[0].toLowerCase()===s[0];switch(s[0]){case"H":case"h":return o&&(s[1]+=n),n=s[1]-s[1].toFixed(t),void(s[1]=+s[1].toFixed(t));case"V":case"v":return o&&(s[1]+=a),a=s[1]-s[1].toFixed(t),void(s[1]=+s[1].toFixed(t));case"Z":case"z":return n=r,void(a=i);case"M":case"m":return o&&(s[1]+=n,s[2]+=a),n=s[1]-s[1].toFixed(t),a=s[2]-s[2].toFixed(t),r=n,i=a,s[1]=+s[1].toFixed(t),void(s[2]=+s[2].toFixed(t));case"A":case"a":return o&&(s[6]+=n,s[7]+=a),n=s[6]-s[6].toFixed(t),a=s[7]-s[7].toFixed(t),s[1]=+s[1].toFixed(t),s[2]=+s[2].toFixed(t),s[3]=+s[3].toFixed(t+2),s[6]=+s[6].toFixed(t),void(s[7]=+s[7].toFixed(t));default:return e=s.length,o&&(s[e-2]+=n,s[e-1]+=a),n=s[e-2]-s[e-2].toFixed(t),a=s[e-1]-s[e-1].toFixed(t),void s.forEach((function(e,r){r&&(s[r]=+s[r].toFixed(t))}))}})),this},Xt.prototype.iterate=function(t,e){var r,i,n,a=this.segments,s={},o=!1,l=0,u=0,h=0,f=0;if(e||this.__evaluateStack(),a.forEach((function(e,r){var i=t(e,r,l,u);Array.isArray(i)&&(s[r]=i,o=!0);var n=e[0]===e[0].toLowerCase();switch(e[0]){case"m":case"M":return l=e[1]+(n?l:0),u=e[2]+(n?u:0),h=l,void(f=u);case"h":case"H":return void(l=e[1]+(n?l:0));case"v":case"V":return void(u=e[1]+(n?u:0));case"z":case"Z":return l=h,void(u=f);default:l=e[e.length-2]+(n?l:0),u=e[e.length-1]+(n?u:0)}})),!o)return this;for(n=[],r=0;r=0;l--){var u=o.cssRules[l];if(u instanceof CSSStyleRule){var h=u;if(h.selectorText.indexOf(",")>=0){o.deleteRule(l);for(var f=h.cssText.substring(h.selectorText.length),c=t.splitSelectorAtCommas(h.selectorText),p=0;p",t.epsilon=.1,t}();function pe(t,e,r){var i,n,a;return void 0===r&&(r={}),l(this,void 0,void 0,(function(){var s,l,h,f,c,m,g,v,y,b,x;return u(this,(function(u){switch(u.label){case 0:return s=null!==(i=r.x)&&void 0!==i?i:0,l=null!==(n=r.y)&&void 0!==n?n:0,h=null!==(a=r.loadExternalStyleSheets)&&void 0!==a&&a,c=new d(f={}),[4,(m=new fe(t,h)).load()];case 1:return u.sent(),g=new dt(e.internal.pageSize.getWidth(),e.internal.pageSize.getHeight()),v=o(o({},r),{element:t}),y=new ce,b=new p(e,{refsHandler:c,styleSheets:m,viewport:g,svg2pdfParameters:v,textMeasure:y}),e.advancedAPI(),e.saveGraphicsState(),e.setCurrentTransformationMatrix(e.Matrix(1,0,0,1,s,l)),e.setLineWidth(b.attributeState.strokeWidth),x=b.attributeState.fill.color,e.setFillColor(x.r,x.g,x.b),e.setFont(b.attributeState.fontFamily),e.setFontSize(b.attributeState.fontSize*e.internal.scaleFactor),[4,he(t,f).render(b)];case 2:return u.sent(),e.restoreGraphicsState(),e.compatAPI(),b.textMeasure.cleanupTextMeasuring(),[2,e]}}))}))}n.API.svg=function(t,e){return void 0===e&&(e={}),pe(t,this,e)};export{pe as svg2pdf}; diff --git a/libs/svg2pdf/Readme.md b/libs/svg2pdf/Readme.md index 706aea40e..43334fe38 100644 --- a/libs/svg2pdf/Readme.md +++ b/libs/svg2pdf/Readme.md @@ -16,7 +16,7 @@ https://github.com/linev/svg2pdf.js/commits/jsroot/ npm install npm run build sed '$ d' ./dist/svg2pdf.es.js | sed "s/from 'jspdf'/from '.\/jspdf.mjs'/g" > ~/git/jsroot/modules/base/svg2pdf.mjs - sed '$ d' ./dist/svg2pdf.es.min.js | sed "s/from'jspdf'/from'.\/jspdf.mjs'/g" > ~/git/jsroot/modules/svg2pdf.mjs + sed '$ d' ./dist/svg2pdf.es.min.js | sed 's/from"jspdf"/from".\/jspdf.mjs"/g' > ~/git/jsroot/libs/svg2pdf.mjs Command sed '$ d' removew reference on map and modifies import diff --git a/modules/svg2pdf.mjs b/modules/svg2pdf.mjs deleted file mode 100644 index fdc5fc3bb..000000000 --- a/modules/svg2pdf.mjs +++ /dev/null @@ -1,27 +0,0 @@ -/** - * The MIT License (MIT) - * - * Copyright (c) 2015-2023 yWorks GmbH - * Copyright (c) 2013-2015 by Vitaly Puzrin - * - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -import t,{GState as e,ShadingPattern as r,TilingPattern as i,jsPDF as n}from"jspdf";var a=function(t,e){return(a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(t,e)};function s(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}a(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}var o=function(){return(o=Object.assign||function(t){for(var e,r=1,i=arguments.length;r0&&n[n.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!n||a[1]>n[0]&&a[1]255?255:this.r,this.g=this.g<0||isNaN(this.g)?0:this.g>255?255:this.g,this.b=this.b<0||isNaN(this.b)?0:this.b>255?255:this.b}}return t.prototype.toRGB=function(){return"rgb("+this.r+", "+this.g+", "+this.b+")"},t.prototype.toRGBA=function(){return"rgba("+this.r+", "+this.g+", "+this.b+", "+(this.a||"1")+")"},t.prototype.toHex=function(){var t=this.r.toString(16),e=this.g.toString(16),r=this.b.toString(16);return 1==t.length&&(t="0"+t),1==e.length&&(e="0"+e),1==r.length&&(r="0"+r),"#"+t+e+r},t.prototype.getHelpXML=function(){for(var e=[],r=0;r "+l.toRGB()+" -> "+l.toHex());o.appendChild(u),o.appendChild(h),s.appendChild(o)}catch(t){}return s},t}(),f=function(){function t(t){this.color=t}return t.prototype.getFillData=function(t,e){return l(this,void 0,void 0,(function(){return u(this,(function(t){return[2,void 0]}))}))},t}(),c=function(){function t(){this.xmlSpace="",this.fill=null,this.fillOpacity=1,this.fontFamily="",this.fontSize=16,this.fontStyle="",this.fontWeight="",this.opacity=1,this.stroke=null,this.strokeDasharray=null,this.strokeDashoffset=0,this.strokeLinecap="",this.strokeLinejoin="",this.strokeMiterlimit=4,this.strokeOpacity=1,this.strokeWidth=1,this.alignmentBaseline="",this.textAnchor="",this.visibility="",this.color=null}return t.prototype.clone=function(){var e=new t;return e.xmlSpace=this.xmlSpace,e.fill=this.fill,e.fillOpacity=this.fillOpacity,e.fontFamily=this.fontFamily,e.fontSize=this.fontSize,e.fontStyle=this.fontStyle,e.fontWeight=this.fontWeight,e.opacity=this.opacity,e.stroke=this.stroke,e.strokeDasharray=this.strokeDasharray,e.strokeDashoffset=this.strokeDashoffset,e.strokeLinecap=this.strokeLinecap,e.strokeLinejoin=this.strokeLinejoin,e.strokeMiterlimit=this.strokeMiterlimit,e.strokeOpacity=this.strokeOpacity,e.strokeWidth=this.strokeWidth,e.textAnchor=this.textAnchor,e.alignmentBaseline=this.alignmentBaseline,e.visibility=this.visibility,e.color=this.color,e},t.default=function(){var e=new t;return e.xmlSpace="default",e.fill=new f(new h("rgb(0, 0, 0)")),e.fillOpacity=1,e.fontFamily="times",e.fontSize=16,e.fontStyle="normal",e.fontWeight="normal",e.opacity=1,e.stroke=null,e.strokeDasharray=null,e.strokeDashoffset=0,e.strokeLinecap="butt",e.strokeLinejoin="miter",e.strokeMiterlimit=4,e.strokeOpacity=1,e.strokeWidth=1,e.alignmentBaseline="baseline",e.textAnchor="start",e.visibility="visible",e.color=new h("rgb(0, 0, 0)"),e},t}(),p=function(){function t(t,e){var r,i,n;this.pdf=t,this.svg2pdfParameters=e.svg2pdfParameters,this.attributeState=e.attributeState?e.attributeState.clone():c.default(),this.viewport=e.viewport,this.refsHandler=e.refsHandler,this.styleSheets=e.styleSheets,this.textMeasure=e.textMeasure,this.transform=null!==(r=e.transform)&&void 0!==r?r:this.pdf.unitMatrix,this.withinClipPath=null!==(i=e.withinClipPath)&&void 0!==i&&i,this.withinUse=null!==(n=e.withinUse)&&void 0!==n&&n}return t.prototype.clone=function(e){var r,i,n,a;return void 0===e&&(e={}),new t(this.pdf,{svg2pdfParameters:this.svg2pdfParameters,attributeState:e.attributeState?e.attributeState.clone():this.attributeState.clone(),viewport:null!==(r=e.viewport)&&void 0!==r?r:this.viewport,refsHandler:this.refsHandler,styleSheets:this.styleSheets,textMeasure:this.textMeasure,transform:null!==(i=e.transform)&&void 0!==i?i:this.transform,withinClipPath:null!==(n=e.withinClipPath)&&void 0!==n?n:this.withinClipPath,withinUse:null!==(a=e.withinUse)&&void 0!==a?a:this.withinUse})},t}(),d=function(){function t(e){this.renderedElements={},this.idMap=e,this.idPrefix=String(t.instanceCounter++)}return t.prototype.getRendered=function(t,e,r){return l(this,void 0,void 0,(function(){var i,n;return u(this,(function(a){switch(a.label){case 0:return i=this.generateKey(t,e),this.renderedElements.hasOwnProperty(i)?[2,this.renderedElements[t]]:(n=this.get(t),this.renderedElements[i]=n,[4,r(n)]);case 1:return a.sent(),[2,n]}}))}))},t.prototype.get=function(t){return this.idMap[t]},t.prototype.generateKey=function(t,e){return this.idPrefix+"|"+t+"|"+(e||new h("rgb(0,0,0)")).toRGBA()},t.instanceCounter=0,t}();function m(t,e){return Math.atan2(e[1]-t[1],e[0]-t[0])}function g(t,e){return[2/3*(e[0]-t[0])+t[0],2/3*(e[1]-t[1])+t[1]]}function v(t){var e=Math.sqrt(t[0]*t[0]+t[1]*t[1]);return[t[0]/e,t[1]/e]}function y(t,e){return v([e[0]-t[0],e[1]-t[1]])}function b(t,e){return[t[0]+e[0],t[1]+e[1]]}function x(t,e){var r=t[0],i=t[1];return[e.a*r+e.c*i+e.e,e.b*r+e.d*i+e.f]}var S=function(){function t(){this.segments=[]}return t.prototype.moveTo=function(t,e){return this.segments.push(new w(t,e)),this},t.prototype.lineTo=function(t,e){return this.segments.push(new k(t,e)),this},t.prototype.curveTo=function(t,e,r,i,n,a){return this.segments.push(new M(t,e,r,i,n,a)),this},t.prototype.close=function(){return this.segments.push(new C),this},t.prototype.transform=function(t){this.segments.forEach((function(e){if(e instanceof w||e instanceof k||e instanceof M){var r=x([e.x,e.y],t);e.x=r[0],e.y=r[1]}if(e instanceof M){var i=x([e.x1,e.y1],t),n=x([e.x2,e.y2],t);e.x1=i[0],e.y1=i[1],e.x2=n[0],e.y2=n[1]}}))},t.prototype.draw=function(t){var e=t.pdf;this.segments.forEach((function(t){t instanceof w?e.moveTo(t.x,t.y):t instanceof k?e.lineTo(t.x,t.y):t instanceof M?e.curveTo(t.x1,t.y1,t.x2,t.y2,t.x,t.y):e.close()}))},t}(),w=function(t,e){this.x=t,this.y=e},k=function(t,e){this.x=t,this.y=e},M=function(t,e,r,i,n,a){this.x1=t,this.y1=e,this.x2=r,this.y2=i,this.x=n,this.y=a},C=function(){};function F(t,e){return e.split(",").indexOf((t.nodeName||t.tagName).toLowerCase())>=0}function T(t,e,r,i){var n;void 0===i&&(i=r);var a=null===(n=t.style)||void 0===n?void 0:n.getPropertyValue(i);if(a)return a;var s=e.getPropertyValue(t,i);return s||(t.hasAttribute(r)&&t.getAttribute(r)||void 0)}function A(t,e,r){if("none"===T(t.element,r.styleSheets,"display"))return!1;var i=e,n=T(t.element,r.styleSheets,"visibility");return n&&(i="hidden"!==n),i}function P(t,e,r){var i=A(t,e,r);return 0!==t.element.childNodes.length&&(t.children.forEach((function(t){t.isVisible(i,r)&&(i=!0)})),i)}var B=function(){function t(){this.markers=[]}return t.prototype.addMarker=function(t){this.markers.push(t)},t.prototype.draw=function(t){return l(this,void 0,void 0,(function(){var e,r,i,n,a,s,o;return u(this,(function(l){switch(l.label){case 0:e=0,l.label=1;case 1:return e=0?y+=(n-c*d)/2:l.indexOf("xMax")>=0&&(y+=n-c*d),l.indexOf("YMid")>=0?b+=(a-p*m)/2:l.indexOf("YMax")>=0&&(b+=a-p*m);var x=s.pdf.Matrix(1,0,0,1,y,b),S=s.pdf.Matrix(d,0,0,m,0,0);return s.pdf.matrixMult(S,x)}function X(t,e){if(!t||"none"===t)return e.pdf.unitMatrix;for(var r,i,n=/^[\s,]*matrix\(([^)]+)\)\s*/,a=/^[\s,]*translate\(([^)]+)\)\s*/,s=/^[\s,]*rotate\(([^)]+)\)\s*/,o=/^[\s,]*scale\(([^)]+)\)\s*/,l=/^[\s,]*skewX\(([^)]+)\)\s*/,u=/^[\s,]*skewY\(([^)]+)\)\s*/,h=e.pdf.unitMatrix;t.length>0&&t.length!==i;){i=t.length;var f=n.exec(t);if(f&&(r=I(f[1]),h=e.pdf.matrixMult(e.pdf.Matrix(r[0],r[1],r[2],r[3],r[4],r[5]),h),t=t.substr(f[0].length)),f=s.exec(t)){r=I(f[1]);var c=Math.PI*r[0]/180;if(h=e.pdf.matrixMult(e.pdf.Matrix(Math.cos(c),Math.sin(c),-Math.sin(c),Math.cos(c),0,0),h),r[1]||r[2]){var p=e.pdf.Matrix(1,0,0,1,r[1],r[2]),d=e.pdf.Matrix(1,0,0,1,-r[1],-r[2]);h=e.pdf.matrixMult(d,e.pdf.matrixMult(h,p))}t=t.substr(f[0].length)}(f=a.exec(t))&&(r=I(f[1]),h=e.pdf.matrixMult(e.pdf.Matrix(1,0,0,1,r[0],r[1]||0),h),t=t.substr(f[0].length)),(f=o.exec(t))&&((r=I(f[1]))[1]||(r[1]=r[0]),h=e.pdf.matrixMult(e.pdf.Matrix(r[0],0,0,r[1],0,0),h),t=t.substr(f[0].length)),(f=l.exec(t))&&(r=parseFloat(f[1]),r*=Math.PI/180,h=e.pdf.matrixMult(e.pdf.Matrix(1,0,Math.tan(r),1,0,0),h),t=t.substr(f[0].length)),(f=u.exec(t))&&(r=parseFloat(f[1]),r*=Math.PI/180,h=e.pdf.matrixMult(e.pdf.Matrix(1,Math.tan(r),0,1,0,0),h),t=t.substr(f[0].length))}return h}var Q=function(){function t(t,e){this.element=t,this.children=e,this.parent=null}return t.prototype.setParent=function(t){this.parent=t},t.prototype.getParent=function(){return this.parent},t.prototype.getBoundingBox=function(t){return"none"===T(this.element,t.styleSheets,"display")?[0,0,0,0]:this.getBoundingBoxCore(t)},t.prototype.computeNodeTransform=function(t){var e=this.computeNodeTransformCore(t),r=T(this.element,t.styleSheets,"transform");return r?t.pdf.matrixMult(e,X(r,t)):e},t}(),$=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return s(e,t),e.prototype.render=function(t){return Promise.resolve()},e.prototype.getBoundingBoxCore=function(t){return[]},e.prototype.computeNodeTransformCore=function(t){return t.pdf.unitMatrix},e}(Q),K=function(t){function i(e,r,i){var n=t.call(this,r,i)||this;return n.pdfGradientType=e,n.contextColor=void 0,n}return s(i,t),i.prototype.apply=function(t){return l(this,void 0,void 0,(function(){var i,n,a,s,o,l;return u(this,(function(u){return(i=this.element.getAttribute("id"))?(n=this.getStops(t.styleSheets),a=0,s=!1,n.forEach((function(t){var e=t.opacity;e&&1!==e&&(a+=e,s=!0)})),s&&(o=new e({opacity:a/n.length})),l=new r(this.pdfGradientType,this.getCoordinates(),n,o),t.pdf.addShadingPattern(i,l),[2]):[2]}))}))},i.prototype.getStops=function(t){var e=this;if(this.stops)return this.stops;if(void 0===this.contextColor){this.contextColor=null;for(var r=this;r;){var n=T(r.element,t,"color");if(n){this.contextColor=H(n,null);break}r=r.getParent()}}var a=[];return this.children.forEach((function(r){if("stop"===r.element.tagName.toLowerCase()){var n=T(r.element,t,"color"),s=H(T(r.element,t,"stop-color")||"",n?H(n,null):e.contextColor),o=parseFloat(T(r.element,t,"stop-opacity")||"1");a.push({offset:i.parseGradientOffset(r.element.getAttribute("offset")||"0"),color:[s.r,s.g,s.b],opacity:o})}})),this.stops=a},i.prototype.getBoundingBoxCore=function(t){return U(this.element,t)},i.prototype.computeNodeTransformCore=function(t){return t.pdf.unitMatrix},i.prototype.isVisible=function(t,e){return P(this,t,e)},i.parseGradientOffset=function(t){var e=parseFloat(t);return!isNaN(e)&&t.indexOf("%")>=0?e/100:e},i}($),Z=function(t){function e(e,r){return t.call(this,"axial",e,r)||this}return s(e,t),e.prototype.getCoordinates=function(){return[parseFloat(this.element.getAttribute("x1")||"0"),parseFloat(this.element.getAttribute("y1")||"0"),parseFloat(this.element.getAttribute("x2")||"1"),parseFloat(this.element.getAttribute("y2")||"0")]},e}(K),J=function(t){function e(e,r){return t.call(this,"radial",e,r)||this}return s(e,t),e.prototype.getCoordinates=function(){var t=this.element.getAttribute("cx"),e=this.element.getAttribute("cy"),r=this.element.getAttribute("fx"),i=this.element.getAttribute("fy");return[parseFloat(r||t||"0.5"),parseFloat(i||e||"0.5"),0,parseFloat(t||"0.5"),parseFloat(e||"0.5"),parseFloat(this.element.getAttribute("r")||"0.5")]},e}(K),tt=function(){function t(t,e){this.key=t,this.gradient=e}return t.prototype.getFillData=function(t,e){return l(this,void 0,void 0,(function(){var r,i,n;return u(this,(function(a){switch(a.label){case 0:return[4,e.refsHandler.getRendered(this.key,null,(function(t){return t.apply(new p(e.pdf,{refsHandler:e.refsHandler,textMeasure:e.textMeasure,styleSheets:e.styleSheets,viewport:e.viewport,svg2pdfParameters:e.svg2pdfParameters}))}))];case 1:return a.sent(),this.gradient.element.hasAttribute("gradientUnits")&&"objectboundingbox"!==this.gradient.element.getAttribute("gradientUnits").toLowerCase()?r=e.pdf.unitMatrix:(i=t.getBoundingBox(e),r=e.pdf.Matrix(i[2],0,0,i[3],i[0],i[1])),n=X(T(this.gradient.element,e.styleSheets,"gradientTransform","transform"),e),[2,{key:this.key,matrix:e.pdf.matrixMult(n,r)}]}}))}))},t}(),et=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return s(e,t),e.prototype.apply=function(t){return l(this,void 0,void 0,(function(){var e,r,n,a,s;return u(this,(function(o){switch(o.label){case 0:if(!(e=this.element.getAttribute("id")))return[2];r=this.getBoundingBox(t),n=new i([r[0],r[1],r[0]+r[2],r[1]+r[3]],r[2],r[3]),t.pdf.beginTilingPattern(n),a=0,s=this.children,o.label=1;case 1:return a=0?(a=t,!0):(t=t.toLowerCase(),!!W.hasOwnProperty(t)&&(a=t,!0))}))||(a="times"),a}(t.attributeState,C,t)}var F=T(i,t.styleSheets,"font-size");if(F){var A=t.pdf.getFontSize();t.attributeState.fontSize=O(F,A)}var P=T(i,t.styleSheets,"vertical-align")||T(i,t.styleSheets,"alignment-baseline");if(P){var B=P.match(/(baseline|text-bottom|alphabetic|ideographic|middle|central|mathematical|text-top|bottom|center|top|hanging)/);B&&(t.attributeState.alignmentBaseline=B[0])}var N=T(i,t.styleSheets,"text-anchor");N&&(t.attributeState.textAnchor=N)}function at(t,r,i){var n=1,a=1;n*=t.attributeState.fillOpacity,n*=t.attributeState.opacity,t.attributeState.fill instanceof f&&void 0!==t.attributeState.fill.color.a&&(n*=t.attributeState.fill.color.a),a*=t.attributeState.strokeOpacity,a*=t.attributeState.opacity,t.attributeState.stroke instanceof f&&void 0!==t.attributeState.stroke.color.a&&(a*=t.attributeState.stroke.color.a);var s,o,l=n<1,u=a<1;if(F(i,"use")?(l=!0,u=!0,n*=t.attributeState.fill?1:0,a*=t.attributeState.stroke?1:0):t.withinUse&&(t.attributeState.fill!==r.attributeState.fill?(l=!0,n*=t.attributeState.fill?1:0):l&&!t.attributeState.fill&&(n=0),t.attributeState.stroke!==r.attributeState.stroke?(u=!0,a*=t.attributeState.stroke?1:0):u&&!t.attributeState.stroke&&(a=0)),l||u){var h={};l&&(h.opacity=n),u&&(h["stroke-opacity"]=a),t.pdf.setGState(new e(h))}if(t.attributeState.fill&&t.attributeState.fill!==r.attributeState.fill&&t.attributeState.fill instanceof f&&t.attributeState.fill.color.ok&&!F(i,"text")&&t.pdf.setFillColor(t.attributeState.fill.color.r,t.attributeState.fill.color.g,t.attributeState.fill.color.b),t.attributeState.strokeWidth!==r.attributeState.strokeWidth&&t.pdf.setLineWidth(t.attributeState.strokeWidth),t.attributeState.stroke!==r.attributeState.stroke&&t.attributeState.stroke instanceof f&&t.pdf.setDrawColor(t.attributeState.stroke.color.r,t.attributeState.stroke.color.g,t.attributeState.stroke.color.b),t.attributeState.strokeLinecap!==r.attributeState.strokeLinecap&&t.pdf.setLineCap(t.attributeState.strokeLinecap),t.attributeState.strokeLinejoin!==r.attributeState.strokeLinejoin&&t.pdf.setLineJoin(t.attributeState.strokeLinejoin),t.attributeState.strokeDasharray===r.attributeState.strokeDasharray&&t.attributeState.strokeDashoffset===r.attributeState.strokeDashoffset||!t.attributeState.strokeDasharray||t.pdf.setLineDashPattern(t.attributeState.strokeDasharray,t.attributeState.strokeDashoffset),t.attributeState.strokeMiterlimit!==r.attributeState.strokeMiterlimit&&t.pdf.setLineMiterLimit(t.attributeState.strokeMiterlimit),t.attributeState.fontFamily!==r.attributeState.fontFamily&&(s=W.hasOwnProperty(t.attributeState.fontFamily)?W[t.attributeState.fontFamily]:t.attributeState.fontFamily),t.attributeState.fill&&t.attributeState.fill!==r.attributeState.fill&&t.attributeState.fill instanceof f&&t.attributeState.fill.color.ok){var c=t.attributeState.fill.color;t.pdf.setTextColor(c.r,c.g,c.b)}t.attributeState.fontWeight===r.attributeState.fontWeight&&t.attributeState.fontStyle===r.attributeState.fontStyle||(o=G(t.attributeState.fontStyle,t.attributeState.fontWeight)),void 0===s&&void 0===o||(void 0===s&&(s=W.hasOwnProperty(t.attributeState.fontFamily)?W[t.attributeState.fontFamily]:t.attributeState.fontFamily),t.pdf.setFont(s,o)),t.attributeState.fontSize!==r.attributeState.fontSize&&t.pdf.setFontSize(t.attributeState.fontSize*t.pdf.internal.scaleFactor)}function st(t,e,r){var i=E.exec(t);if(i){var n=i[1];return r.refsHandler.get(n)||void 0}}function ot(t,e,r){return l(this,void 0,void 0,(function(){var i,n;return u(this,(function(a){switch(a.label){case 0:return i=r.clone(),e.element.hasAttribute("clipPathUnits")&&"objectboundingbox"===e.element.getAttribute("clipPathUnits").toLowerCase()&&(n=t.getBoundingBox(r),i.transform=r.pdf.matrixMult(r.pdf.Matrix(n[2],0,0,n[3],n[0],n[1]),r.transform)),[4,e.apply(i)];case 1:return a.sent(),[2]}}))}))}var lt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return s(e,t),e.prototype.render=function(t){return l(this,void 0,void 0,(function(){var e,r,i,n;return u(this,(function(a){switch(a.label){case 0:return this.isVisible("hidden"!==t.attributeState.visibility,t)?((e=t.clone()).transform=e.pdf.matrixMult(this.computeNodeTransform(e),t.transform),nt(e,this),r=T(this.element,e.styleSheets,"clip-path"),(i=r&&"none"!==r)?(n=st(r,0,e))?n.isVisible(!0,e)?(e.pdf.saveGraphicsState(),[4,ot(this,n,e)]):[3,2]:[3,4]:[3,5]):[2];case 1:return a.sent(),[3,3];case 2:return[2];case 3:return[3,5];case 4:i=!1,a.label=5;case 5:return e.withinClipPath||e.pdf.saveGraphicsState(),at(e,t,this.element),[4,this.renderCore(e)];case 6:return a.sent(),e.withinClipPath||e.pdf.restoreGraphicsState(),i&&e.pdf.restoreGraphicsState(),[2]}}))}))},e}(Q),ut=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return s(e,t),e}(lt),ht=function(t){function e(e,r,i){var n=t.call(this,r,i)||this;return n.cachedPath=null,n.hasMarkers=e,n}return s(e,t),e.prototype.renderCore=function(t){return l(this,void 0,void 0,(function(){var e;return u(this,(function(r){switch(r.label){case 0:return null===(e=this.getCachedPath(t))||0===e.segments.length?[2]:(t.withinClipPath?e.transform(t.transform):t.pdf.setCurrentTransformationMatrix(t.transform),e.draw(t),[4,this.fillOrStroke(t)]);case 1:return r.sent(),this.hasMarkers?[4,this.drawMarkers(t,e)]:[3,3];case 2:r.sent(),r.label=3;case 3:return[2]}}))}))},e.prototype.getCachedPath=function(t){return this.cachedPath||(this.cachedPath=this.getPath(t))},e.prototype.drawMarkers=function(t,e){return l(this,void 0,void 0,(function(){return u(this,(function(r){switch(r.label){case 0:return[4,this.getMarkers(e,t).draw(t.clone({transform:t.pdf.unitMatrix}))];case 1:return r.sent(),[2]}}))}))},e.prototype.fillOrStroke=function(t){return l(this,void 0,void 0,(function(){var e,r,i,n,a;return u(this,(function(s){switch(s.label){case 0:return t.withinClipPath?[2]:(e=t.attributeState.fill,r=t.attributeState.stroke&&0!==t.attributeState.strokeWidth,e?[4,e.getFillData(this,t)]:[3,2]);case 1:return n=s.sent(),[3,3];case 2:n=void 0,s.label=3;case 3:return i=n,a="evenodd"===T(this.element,t.styleSheets,"fill-rule"),e&&r||t.withinUse?a?t.pdf.fillStrokeEvenOdd(i):t.pdf.fillStroke(i):e?a?t.pdf.fillEvenOdd(i):t.pdf.fill(i):r?t.pdf.stroke():t.pdf.discardPath(),[2]}}))}))},e.prototype.getBoundingBoxCore=function(t){var e=this.getCachedPath(t);if(!e||!e.segments.length)return[0,0,0,0];for(var r=Number.POSITIVE_INFINITY,i=Number.POSITIVE_INFINITY,n=Number.NEGATIVE_INFINITY,a=Number.NEGATIVE_INFINITY,s=0,o=0,l=0;lt){var i=s[r-1];f=(i instanceof w||i instanceof k||i instanceof M)&&i}}));var p=n&&(t===s.length-1||!(s[t]instanceof w)&&s[t+1]instanceof w),d=i&&t>0&&!(1===t&&s[t-1]instanceof w),g=s[t-1]||null;if(g instanceof w||g instanceof k||g instanceof M){if(e instanceof M)c&&a.addMarker(new N(r,[g.x,g.y],m(f?[f.x,f.y]:[g.x,g.y],[e.x1,e.y1]))),p&&a.addMarker(new N(n,[e.x,e.y],m([e.x2,e.y2],[e.x,e.y]))),d&&(l=y([g.x,g.y],[e.x1,e.y1]),l=g instanceof w?l:v(b(o,l)),a.addMarker(new N(i,[g.x,g.y],Math.atan2(l[1],l[0])))),o=y([e.x2,e.y2],[e.x,e.y]);else if(e instanceof w||e instanceof k){if(l=y([g.x,g.y],[e.x,e.y]),c){var x=f?y([f.x,f.y],[e.x,e.y]):l;a.addMarker(new N(r,[g.x,g.y],Math.atan2(x[1],x[0])))}if(p&&a.addMarker(new N(n,[e.x,e.y],Math.atan2(l[1],l[0]))),d){x=e instanceof w?o:g instanceof w?l:v(b(o,l));a.addMarker(new N(i,[g.x,g.y],Math.atan2(x[1],x[0])))}o=l}else if(e instanceof C){if(l=y([g.x,g.y],[u.x,u.y]),d){x=g instanceof w?l:v(b(o,l));a.addMarker(new N(i,[g.x,g.y],Math.atan2(x[1],x[0])))}if(p){x=v(b(l,h));a.addMarker(new N(n,[u.x,u.y],Math.atan2(x[1],x[0])))}o=l}}else{u=e instanceof w&&e;var S=s[t+1];(S instanceof w||S instanceof k||S instanceof M)&&(h=y([u.x,u.y],[S.x,S.y]))}},p=0;p=0;t--)if("default"===this.contexts[t].attributeState.xmlSpace&&(this.texts[t]=this.texts[t].replace(/\s+$/,"")),this.texts[t].match(/[^\s]/))return!1;return!0},t.prototype.measureText=function(t){for(var e=0;e0&&(m=t.textMeasure.measureTextWidth(d,t.attributeState),"default"===t.attributeState.xmlSpace&&c.match(/^\s/)&&(i=0),r=(h-m)/(d.length-i)||0),"visible"===f&&(g=t.attributeState.alignmentBaseline,v=bt(t.attributeState),t.pdf.text(d,a+o-e,s+l,{baseline:_(g),angle:t.transform,renderingMode:"fill"===v?void 0:v,charSpace:0===r?void 0:r}),this.boundingBox=[a+o-e,s+l-n,t.textMeasure.measureTextWidth(d,t.attributeState),n],"baseline"===g&&(this.boundingBox[1]+=.2*n));else{for(y=[],b=new Mt(this,t.attributeState.textAnchor,a+o,s+l),y.push({type:"",chunk:b}),x=this.processTSpans(this,this.element,t,y,b,{prevText:" ",prevContext:t}),i=x?0:1,S=!0,w=y.length-1;w>=0;w--)S&&(S=y[w].chunk.rightTrimText());h>0&&(k=0,M=0,y.forEach((function(e){var r=e.chunk;r.measureText(t),r.textMeasures.forEach((function(t){var e=t.width,r=t.length;k+=e,M+=r}))})),r=(h-k)/(M-i)),y.reduce((function(e,i){var n=i.type,a=i.chunk;return"x"===n?a.setX(e[0]):"y"===n&&a.setY(e[1]),a.put(t,r)}),[0,0])}return t.pdf.restoreGraphicsState(),[2]}))}))},e.prototype.isVisible=function(t,e){return P(this,t,e)},e.prototype.getBoundingBoxCore=function(t){return this.boundingBox.length>0?this.boundingBox:U(this.element,t)},e.prototype.computeNodeTransformCore=function(t){return t.pdf.unitMatrix},e}(ut),Ft={a:7,c:6,h:1,l:2,m:2,r:4,q:4,s:4,t:2,v:1,z:0},Tt=[5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279];function At(t){return t>=48&&t<=57}function Pt(t){return t>=48&&t<=57||43===t||45===t||46===t}function Bt(t){this.index=0,this.path=t,this.max=t.length,this.result=[],this.param=0,this.err="",this.segmentStart=0,this.data=[]}function Nt(t){for(;t.index=5760&&Tt.indexOf(e)>=0);)t.index++;var e}function Et(t){var e=t.path.charCodeAt(t.index);return 48===e?(t.param=0,void t.index++):49===e?(t.param=1,void t.index++):void(t.err="SvgPath: arc flag can be 0 or 1 only (at pos "+t.index+")")}function Lt(t){var e,r=t.index,i=r,n=t.max,a=!1,s=!1,o=!1,l=!1;if(i>=n)t.err="SvgPath: missed param (at pos "+i+")";else if(43!==(e=t.path.charCodeAt(i))&&45!==e||(e=++i2&&(t.result.push([e,i[0],i[1]]),i=i.slice(2),r="l",e="m"===e?"l":"L"),"r"===r)t.result.push([e].concat(i));else for(;i.length>=Ft[r]&&(t.result.push([e].concat(i.splice(0,Ft[r]))),Ft[r]););}function _t(t){var e,r,i,n,a,s=t.max;if(t.segmentStart=t.index,e=t.path.charCodeAt(t.index),r=97==(32|e),function(t){switch(32|t){case 109:case 122:case 108:case 104:case 118:case 99:case 115:case 113:case 116:case 97:case 114:return!0}return!1}(e))if(n=Ft[t.path[t.index].toLowerCase()],t.index++,Nt(t),t.data=[],n){for(i=!1;;){for(a=n;a>0;a--){if(!r||3!==a&&4!==a?Lt(t):Et(t),t.err.length)return;t.data.push(t.param),Nt(t),i=!1,t.index=t.max)break;if(!Pt(t.path.charCodeAt(t.index)))break}}Ot(t)}else Ot(t);else t.err="SvgPath: bad command "+t.path[t.index]+" (at pos "+t.index+")"}function It(){if(!(this instanceof It))return new It;this.queue=[],this.cache=null}It.prototype.matrix=function(t){return 1===t[0]&&0===t[1]&&0===t[2]&&1===t[3]&&0===t[4]&&0===t[5]||(this.cache=null,this.queue.push(t)),this},It.prototype.translate=function(t,e){return 0===t&&0===e||(this.cache=null,this.queue.push([1,0,0,1,t,e])),this},It.prototype.scale=function(t,e){return 1===t&&1===e||(this.cache=null,this.queue.push([t,0,0,e,0,0])),this},It.prototype.rotate=function(t,e,r){var i,n,a;return 0!==t&&(this.translate(e,r),i=t*Math.PI/180,n=Math.cos(i),a=Math.sin(i),this.queue.push([n,a,-a,n,0,0]),this.cache=null,this.translate(-e,-r)),this},It.prototype.skewX=function(t){return 0!==t&&(this.cache=null,this.queue.push([1,0,Math.tan(t*Math.PI/180),1,0,0])),this},It.prototype.skewY=function(t){return 0!==t&&(this.cache=null,this.queue.push([1,Math.tan(t*Math.PI/180),0,1,0,0])),this},It.prototype.toArray=function(){if(this.cache)return this.cache;if(!this.queue.length)return this.cache=[1,0,0,1,0,0],this.cache;if(this.cache=this.queue[0],1===this.queue.length)return this.cache;for(var t=1;t1&&(n=1),n<-1&&(n=-1),(t*i-e*r<0?-1:1)*Math.acos(n)}function jt(t,e){var r=4/3*Math.tan(e/4),i=Math.cos(t),n=Math.sin(t),a=Math.cos(t+e),s=Math.sin(t+e);return[i,n,i-n*r,n+i*r,a+s*r,s-a*r,a,s]}var Gt=function(t,e,r,i,n,a,s,o,l){var u=Math.sin(l*Wt/360),h=Math.cos(l*Wt/360),f=h*(t-r)/2+u*(e-i)/2,c=-u*(t-r)/2+h*(e-i)/2;if(0===f&&0===c)return[];if(0===s||0===o)return[];s=Math.abs(s),o=Math.abs(o);var p=f*f/(s*s)+c*c/(o*o);p>1&&(s*=Math.sqrt(p),o*=Math.sqrt(p));var d=function(t,e,r,i,n,a,s,o,l,u){var h=u*(t-r)/2+l*(e-i)/2,f=-l*(t-r)/2+u*(e-i)/2,c=s*s,p=o*o,d=h*h,m=f*f,g=c*p-c*m-p*d;g<0&&(g=0),g/=c*m+p*d;var v=(g=Math.sqrt(g)*(n===a?-1:1))*s/o*f,y=g*-o/s*h,b=u*v-l*y+(t+r)/2,x=l*v+u*y+(e+i)/2,S=(h-v)/s,w=(f-y)/o,k=(-h-v)/s,M=(-f-y)/o,C=qt(1,0,S,w),F=qt(S,w,k,M);return 0===a&&F>0&&(F-=Wt),1===a&&F<0&&(F+=Wt),[b,x,C,F]}(t,e,r,i,n,a,s,o,u,h),m=[],g=d[2],v=d[3],y=Math.max(Math.ceil(Math.abs(v)/(Wt/4)),1);v/=y;for(var b=0;bMath.abs(u-a)?(u-n)/l:l/(u-a))/Math.PI,this.ax>=0?(this.rx=Math.sqrt(u),this.ry=Math.sqrt(h)):(this.ax+=90,this.rx=Math.sqrt(h),this.ry=Math.sqrt(u)),this},Ut.prototype.isDegenerate=function(){return this.rx<1e-10*this.ry||this.ry<1e-10*this.rx};var Yt=Ut;function Xt(t){if(!(this instanceof Xt))return new Xt(t);var e=function(t){var e=new Bt(t),r=e.max;for(Nt(e);e.index0,l=["m",(o=t.calc(i[1],i[2],h))[0],o[1]];break;default:for(l=[u=i[0]],h=u.toLowerCase()===u,e=1;e=0;)t.matrix(this.__stack[e].toArray());this.__matrix(t),this.__stack=[]}},Xt.prototype.toString=function(){var t="",e="",r=!1;this.__evaluateStack();for(var i=0,n=this.segments.length;i=0&&(t+=" "):l>=0&&(t+=" "),t+=l}e=s}return t},Xt.prototype.translate=function(t,e){return this.__stack.push(Ht().translate(t,e||0)),this},Xt.prototype.scale=function(t,e){return this.__stack.push(Ht().scale(t,e||0===e?e:t)),this},Xt.prototype.rotate=function(t,e,r){return this.__stack.push(Ht().rotate(t,e||0,r||0)),this},Xt.prototype.skewX=function(t){return this.__stack.push(Ht().skewX(t)),this},Xt.prototype.skewY=function(t){return this.__stack.push(Ht().skewY(t)),this},Xt.prototype.matrix=function(t){return this.__stack.push(Ht().matrix(t)),this},Xt.prototype.transform=function(t){return t.trim()?(this.__stack.push(function(t){var e,r,i=new Ht;return t.split(Vt).forEach((function(t){if(t.length)if(void 0===Dt[t])switch(r=t.split(Rt).map((function(t){return+t||0})),e){case"matrix":return void(6===r.length&&i.matrix(r));case"scale":return void(1===r.length?i.scale(r[0],r[0]):2===r.length&&i.scale(r[0],r[1]));case"rotate":return void(1===r.length?i.rotate(r[0],0,0):3===r.length&&i.rotate(r[0],r[1],r[2]));case"translate":return void(1===r.length?i.translate(r[0],0):2===r.length&&i.translate(r[0],r[1]));case"skewX":return void(1===r.length&&i.skewX(r[0]));case"skewY":return void(1===r.length&&i.skewY(r[0]))}else e=t})),i}(t)),this):this},Xt.prototype.round=function(t){var e,r=0,i=0,n=0,a=0;return t=t||0,this.__evaluateStack(),this.segments.forEach((function(s){var o=s[0].toLowerCase()===s[0];switch(s[0]){case"H":case"h":return o&&(s[1]+=n),n=s[1]-s[1].toFixed(t),void(s[1]=+s[1].toFixed(t));case"V":case"v":return o&&(s[1]+=a),a=s[1]-s[1].toFixed(t),void(s[1]=+s[1].toFixed(t));case"Z":case"z":return n=r,void(a=i);case"M":case"m":return o&&(s[1]+=n,s[2]+=a),n=s[1]-s[1].toFixed(t),a=s[2]-s[2].toFixed(t),r=n,i=a,s[1]=+s[1].toFixed(t),void(s[2]=+s[2].toFixed(t));case"A":case"a":return o&&(s[6]+=n,s[7]+=a),n=s[6]-s[6].toFixed(t),a=s[7]-s[7].toFixed(t),s[1]=+s[1].toFixed(t),s[2]=+s[2].toFixed(t),s[3]=+s[3].toFixed(t+2),s[6]=+s[6].toFixed(t),void(s[7]=+s[7].toFixed(t));default:return e=s.length,o&&(s[e-2]+=n,s[e-1]+=a),n=s[e-2]-s[e-2].toFixed(t),a=s[e-1]-s[e-1].toFixed(t),void s.forEach((function(e,r){r&&(s[r]=+s[r].toFixed(t))}))}})),this},Xt.prototype.iterate=function(t,e){var r,i,n,a=this.segments,s={},o=!1,l=0,u=0,h=0,f=0;if(e||this.__evaluateStack(),a.forEach((function(e,r){var i=t(e,r,l,u);Array.isArray(i)&&(s[r]=i,o=!0);var n=e[0]===e[0].toLowerCase();switch(e[0]){case"m":case"M":return l=e[1]+(n?l:0),u=e[2]+(n?u:0),h=l,void(f=u);case"h":case"H":return void(l=e[1]+(n?l:0));case"v":case"V":return void(u=e[1]+(n?u:0));case"z":case"Z":return l=h,void(u=f);default:l=e[e.length-2]+(n?l:0),u=e[e.length-1]+(n?u:0)}})),!o)return this;for(n=[],r=0;r=0;l--){var u=o.cssRules[l];if(u instanceof CSSStyleRule){var h=u;if(h.selectorText.indexOf(",")>=0){o.deleteRule(l);for(var f=h.cssText.substring(h.selectorText.length),c=t.splitSelectorAtCommas(h.selectorText),p=0;p",t.epsilon=.1,t}();function pe(t,e,r){var i,n,a;return void 0===r&&(r={}),l(this,void 0,void 0,(function(){var s,l,h,f,c,m,g,v,y,b,x;return u(this,(function(u){switch(u.label){case 0:return s=null!==(i=r.x)&&void 0!==i?i:0,l=null!==(n=r.y)&&void 0!==n?n:0,h=null!==(a=r.loadExternalStyleSheets)&&void 0!==a&&a,c=new d(f={}),[4,(m=new fe(t,h)).load()];case 1:return u.sent(),g=new dt(e.internal.pageSize.getWidth(),e.internal.pageSize.getHeight()),v=o(o({},r),{element:t}),y=new ce,b=new p(e,{refsHandler:c,styleSheets:m,viewport:g,svg2pdfParameters:v,textMeasure:y}),e.advancedAPI(),e.saveGraphicsState(),e.setCurrentTransformationMatrix(e.Matrix(1,0,0,1,s,l)),e.setLineWidth(b.attributeState.strokeWidth),x=b.attributeState.fill.color,e.setFillColor(x.r,x.g,x.b),e.setFont(b.attributeState.fontFamily),e.setFontSize(b.attributeState.fontSize*e.internal.scaleFactor),[4,he(t,f).render(b)];case 2:return u.sent(),e.restoreGraphicsState(),e.compatAPI(),b.textMeasure.cleanupTextMeasuring(),[2,e]}}))}))}n.API.svg=function(t,e){return void 0===e&&(e={}),pe(t,this,e)};export{pe as svg2pdf};