package.lib.svg2pdf.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of highcharts Show documentation
Show all versions of highcharts Show documentation
JavaScript charting framework
The newest version!
/**
* 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.
*/
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("jspdf")):"function"==typeof define&&define.amd?define(["exports","jspdf"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).svg2pdf={},t.jspdf)}(this,(function(t,e){"use strict";var r="default"in e?e.default:e,i=function(t,e){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)};
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */function n(t,e){function r(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}var a=function(){return(a=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}(),u=function(){function t(t){this.color=t}return t.prototype.getFillData=function(t,e){return s(this,void 0,void 0,(function(){return o(this,(function(t){return[2,void 0]}))}))},t}(),h=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 u(new l("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 l("rgb(0, 0, 0)"),e},t}(),f=function(){function t(t,e){var r,i,n;this.pdf=t,this.svg2pdfParameters=e.svg2pdfParameters,this.attributeState=e.attributeState?e.attributeState.clone():h.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}(),c={}.hasOwnProperty,p=/[ -,\.\/:-@\[-\^`\{-~]/,d=/[ -,\.\/:-@\[\]\^`\{-~]/,g=/(^|\\+)?(\\[A-F0-9]{1,6})\x20(?![a-fA-F0-9\x20])/g,m=function t(e,r){"single"!=(r=function(t,e){if(!t)return e;var r={};for(var i in e)r[i]=c.call(t,i)?t[i]:e[i];return r}(r,t.options)).quotes&&"double"!=r.quotes&&(r.quotes="single");for(var i="double"==r.quotes?'"':"'",n=r.isIdentifier,a=e.charAt(0),s="",o=0,l=e.length;o126){if(h>=55296&&h<=56319&&o=0}function N(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 E(t,e,r){if("none"===N(t.element,r.styleSheets,"display"))return!1;var i=e,n=N(t.element,r.styleSheets,"visibility");return n&&(i="hidden"!==n),i}function L(t,e,r){var i=E(t,e,r);return 0!==t.element.childNodes.length&&(t.children.forEach((function(t){t.isVisible(i,r)&&(i=!0)})),i)}var O=function(){function t(){this.markers=[]}return t.prototype.addMarker=function(t){this.markers.push(t)},t.prototype.draw=function(t){return s(this,void 0,void 0,(function(){var e,r,i,n,a,s,l;return o(this,(function(o){switch(o.label){case 0:e=0,o.label=1;case 1:return e=0?v+=(n-c*d)/2:l.indexOf("xMax")>=0&&(v+=n-c*d),l.indexOf("YMid")>=0?b+=(a-p*g)/2:l.indexOf("YMax")>=0&&(b+=a-p*g);var x=s.pdf.Matrix(1,0,0,1,v,b),S=s.pdf.Matrix(d,0,0,g,0,0);return s.pdf.matrixMult(S,x)}function Z(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=V(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=V(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=V(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=V(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 J=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"===N(this.element,t.styleSheets,"display")?[0,0,0,0]:this.getBoundingBoxCore(t)},t.prototype.computeNodeTransform=function(t){var e=this.computeNodeTransformCore(t),r=N(this.element,t.styleSheets,"transform");return r?t.pdf.matrixMult(e,Z(r,t)):e},t}(),tt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(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}(J),et=function(t){function r(e,r,i){var n=t.call(this,r,i)||this;return n.pdfGradientType=e,n.contextColor=void 0,n}return n(r,t),r.prototype.apply=function(t){return s(this,void 0,void 0,(function(){var r,i,n,a,s,l;return o(this,(function(o){return(r=this.element.getAttribute("id"))?(i=this.getStops(t.styleSheets),n=0,a=!1,i.forEach((function(t){var e=t.opacity;e&&1!==e&&(n+=e,a=!0)})),a&&(s=new e.GState({opacity:n/i.length})),l=new e.ShadingPattern(this.pdfGradientType,this.getCoordinates(),i,s),t.pdf.addShadingPattern(r,l),[2]):[2]}))}))},r.prototype.getStops=function(t){var e=this;if(this.stops)return this.stops;if(void 0===this.contextColor){this.contextColor=null;for(var i=this;i;){var n=N(i.element,t,"color");if(n){this.contextColor=R(n,null);break}i=i.getParent()}}var a=[];return this.children.forEach((function(i){if("stop"===i.element.tagName.toLowerCase()){var n=N(i.element,t,"color"),s=R(N(i.element,t,"stop-color")||"",n?R(n,null):e.contextColor),o=parseFloat(N(i.element,t,"stop-opacity")||"1");a.push({offset:r.parseGradientOffset(i.element.getAttribute("offset")||"0"),color:[s.r,s.g,s.b],opacity:o})}})),this.stops=a},r.prototype.getBoundingBoxCore=function(t){return $(this.element,t)},r.prototype.computeNodeTransformCore=function(t){return t.pdf.unitMatrix},r.prototype.isVisible=function(t,e){return L(this,t,e)},r.parseGradientOffset=function(t){var e=parseFloat(t);return!isNaN(e)&&t.indexOf("%")>=0?e/100:e},r}(tt),rt=function(t){function e(e,r){return t.call(this,"axial",e,r)||this}return n(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}(et),it=function(t){function e(e,r){return t.call(this,"radial",e,r)||this}return n(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}(et),nt=function(){function t(t,e){this.key=t,this.gradient=e}return t.prototype.getFillData=function(t,e){return s(this,void 0,void 0,(function(){var r,i,n;return o(this,(function(a){switch(a.label){case 0:return[4,e.refsHandler.getRendered(this.key,null,(function(t){return t.apply(new f(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=Z(N(this.gradient.element,e.styleSheets,"gradientTransform","transform"),e),[2,{key:this.key,matrix:e.pdf.matrixMult(n,r)}]}}))}))},t}(),at=function(t){function r(){return null!==t&&t.apply(this,arguments)||this}return n(r,t),r.prototype.apply=function(t){return s(this,void 0,void 0,(function(){var r,i,n,a,s;return o(this,(function(o){switch(o.label){case 0:if(!(r=this.element.getAttribute("id")))return[2];i=this.getBoundingBox(t),n=new e.TilingPattern([i[0],i[1],i[0]+i[2],i[1]+i[3]],i[2],i[3]),t.pdf.beginTilingPattern(n),a=0,s=this.children,o.label=1;case 1:return a=0?(a=t,!0):(t=t.toLowerCase(),!!U.hasOwnProperty(t)&&(a=t,!0))}))||(a="times"),a}(t.attributeState,C,t)}var A=N(i,t.styleSheets,"font-size");if(A){var F=t.pdf.getFontSize();t.attributeState.fontSize=D(A,F)}var T=N(i,t.styleSheets,"vertical-align")||N(i,t.styleSheets,"alignment-baseline");if(T){var P=T.match(/(baseline|text-bottom|alphabetic|ideographic|middle|central|mathematical|text-top|bottom|center|top|hanging)/);P&&(t.attributeState.alignmentBaseline=P[0])}var B=N(i,t.styleSheets,"text-anchor");B&&(t.attributeState.textAnchor=B)}function ut(t,r,i){var n=1,a=1;n*=t.attributeState.fillOpacity,n*=t.attributeState.opacity,t.attributeState.fill instanceof u&&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 u&&void 0!==t.attributeState.stroke.color.a&&(a*=t.attributeState.stroke.color.a);var s,o,l=n<1,h=a<1;if(B(i,"use")?(l=!0,h=!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?(h=!0,a*=t.attributeState.stroke?1:0):h&&!t.attributeState.stroke&&(a=0)),l||h){var f={};l&&(f.opacity=n),h&&(f["stroke-opacity"]=a),t.pdf.setGState(new e.GState(f))}if(t.attributeState.fill&&t.attributeState.fill!==r.attributeState.fill&&t.attributeState.fill instanceof u&&t.attributeState.fill.color.ok&&!B(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 u&&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=U.hasOwnProperty(t.attributeState.fontFamily)?U[t.attributeState.fontFamily]:t.attributeState.fontFamily),t.attributeState.fill&&t.attributeState.fill!==r.attributeState.fill&&t.attributeState.fill instanceof u&&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=X(t.attributeState.fontStyle,t.attributeState.fontWeight)),void 0===s&&void 0===o||(void 0===s&&(s=U.hasOwnProperty(t.attributeState.fontFamily)?U[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 ht(t,e,r){var i=_.exec(t);if(i){var n=i[1];return r.refsHandler.get(n)||void 0}}function ft(t,e,r){return s(this,void 0,void 0,(function(){var i,n;return o(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 ct=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype.render=function(t){return s(this,void 0,void 0,(function(){var e,r,i,n;return o(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),lt(e,this),r=N(this.element,e.styleSheets,"clip-path"),(i=r&&"none"!==r)?(n=ht(r,0,e))?n.isVisible(!0,e)?(e.pdf.saveGraphicsState(),[4,ft(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(),ut(e,t,this.element),[4,this.renderCore(e)];case 6:return a.sent(),e.withinClipPath||e.pdf.restoreGraphicsState(),i&&e.pdf.restoreGraphicsState(),[2]}}))}))},e}(J),pt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e}(ct),dt=function(t){function e(e,r,i){var n=t.call(this,r,i)||this;return n.cachedPath=null,n.hasMarkers=e,n}return n(e,t),e.prototype.renderCore=function(t){return s(this,void 0,void 0,(function(){var e;return o(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 s(this,void 0,void 0,(function(){return o(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 s(this,void 0,void 0,(function(){var e,r,i,n,a;return o(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"===N(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 A||i instanceof F||i instanceof T)&&i}}));var p=n&&(t===s.length-1||!(s[t]instanceof A)&&s[t+1]instanceof A),d=i&&t>0&&!(1===t&&s[t-1]instanceof A),g=s[t-1]||null;if(g instanceof A||g instanceof F||g instanceof T){if(e instanceof T)c&&a.addMarker(new I(r,[g.x,g.y],b(f?[f.x,f.y]:[g.x,g.y],[e.x1,e.y1]))),p&&a.addMarker(new I(n,[e.x,e.y],b([e.x2,e.y2],[e.x,e.y]))),d&&(l=w([g.x,g.y],[e.x1,e.y1]),l=g instanceof A?l:S(k(o,l)),a.addMarker(new I(i,[g.x,g.y],Math.atan2(l[1],l[0])))),o=w([e.x2,e.y2],[e.x,e.y]);else if(e instanceof A||e instanceof F){if(l=w([g.x,g.y],[e.x,e.y]),c){var m=f?w([f.x,f.y],[e.x,e.y]):l;a.addMarker(new I(r,[g.x,g.y],Math.atan2(m[1],m[0])))}if(p&&a.addMarker(new I(n,[e.x,e.y],Math.atan2(l[1],l[0]))),d){m=e instanceof A?o:g instanceof A?l:S(k(o,l));a.addMarker(new I(i,[g.x,g.y],Math.atan2(m[1],m[0])))}o=l}else if(e instanceof P){if(l=w([g.x,g.y],[u.x,u.y]),d){m=g instanceof A?l:S(k(o,l));a.addMarker(new I(i,[g.x,g.y],Math.atan2(m[1],m[0])))}if(p){m=S(k(l,h));a.addMarker(new I(n,[u.x,u.y],Math.atan2(m[1],m[0])))}o=l}}else{u=e instanceof A&&e;var y=s[t+1];(y instanceof A||y instanceof F||y instanceof T)&&(h=w([u.x,u.y],[y.x,y.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&&(g=t.textMeasure.measureTextWidth(d,t.attributeState),"default"===t.attributeState.xmlSpace&&c.match(/^\s/)&&(i=0),r=(h-g)/(d.length-i)||0),"visible"===f&&(m=t.attributeState.alignmentBaseline,y=kt(t.attributeState),t.pdf.text(d,a+l-e,s+u,{baseline:q(m),angle:t.transform,renderingMode:"fill"===y?void 0:y,charSpace:0===r?void 0:r}));else{for(v=[],b=new Tt(this,t.attributeState.textAnchor,a+l,s+u),v.push({type:"",chunk:b}),x=this.processTSpans(this,this.element,t,v,b,{prevText:" ",prevContext:t}),i=x?0:1,S=!0,w=v.length-1;w>=0;w--)S&&(S=v[w].chunk.rightTrimText());h>0&&(k=0,M=0,v.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)),v.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 L(this,t,e)},e.prototype.getBoundingBoxCore=function(t){return $(this.element,t)},e.prototype.computeNodeTransformCore=function(t){return t.pdf.unitMatrix},e}(pt),Bt={a:7,c:6,h:1,l:2,m:2,r:4,q:4,s:4,t:2,v:1,z:0},Nt=[5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279];function Et(t){return t>=48&&t<=57}function Lt(t){return t>=48&&t<=57||43===t||45===t||46===t}function Ot(t){this.index=0,this.path=t,this.max=t.length,this.result=[],this.param=0,this.err="",this.segmentStart=0,this.data=[]}function It(t){for(;t.index=5760&&Nt.indexOf(e)>=0);)t.index++;var e}function _t(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 Ht(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>=Bt[r]&&(t.result.push([e].concat(i.splice(0,Bt[r]))),Bt[r]););}function qt(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=Bt[t.path[t.index].toLowerCase()],t.index++,It(t),t.data=[],n){for(i=!1;;){for(a=n;a>0;a--){if(!r||3!==a&&4!==a?Ht(t):_t(t),t.err.length)return;t.data.push(t.param),It(t),i=!1,t.index=t.max)break;if(!Lt(t.path.charCodeAt(t.index)))break}}Dt(t)}else Dt(t);else t.err="SvgPath: bad command "+t.path[t.index]+" (at pos "+t.index+")"}function Vt(){if(!(this instanceof Vt))return new Vt;this.queue=[],this.cache=null}Vt.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},Vt.prototype.translate=function(t,e){return 0===t&&0===e||(this.cache=null,this.queue.push([1,0,0,1,t,e])),this},Vt.prototype.scale=function(t,e){return 1===t&&1===e||(this.cache=null,this.queue.push([t,0,0,e,0,0])),this},Vt.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},Vt.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},Vt.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},Vt.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 Yt(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 Xt=function(t,e,r,i,n,a,s,o,l){var u=Math.sin(l*Ut/360),h=Math.cos(l*Ut/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,g=f*f,m=c*p-c*g-p*d;m<0&&(m=0),m/=c*g+p*d;var y=(m=Math.sqrt(m)*(n===a?-1:1))*s/o*f,v=m*-o/s*h,b=u*y-l*v+(t+r)/2,x=l*y+u*v+(e+i)/2,S=(h-y)/s,w=(f-v)/o,k=(-h-y)/s,M=(-f-v)/o,C=zt(1,0,S,w),A=zt(S,w,k,M);return 0===a&&A>0&&(A-=Ut),1===a&&A<0&&(A+=Ut),[b,x,C,A]}(t,e,r,i,n,a,s,o,u,h),g=[],m=d[2],y=d[3],v=Math.max(Math.ceil(Math.abs(y)/(Ut/4)),1);y/=v;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},$t.prototype.isDegenerate=function(){return this.rx<1e-10*this.ry||this.ry<1e-10*this.rx};var Kt=$t;function Zt(t){if(!(this instanceof Zt))return new Zt(t);var e=function(t){var e=new Ot(t),r=e.max;for(It(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=[]}},Zt.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},Zt.prototype.translate=function(t,e){return this.__stack.push(Rt().translate(t,e||0)),this},Zt.prototype.scale=function(t,e){return this.__stack.push(Rt().scale(t,e||0===e?e:t)),this},Zt.prototype.rotate=function(t,e,r){return this.__stack.push(Rt().rotate(t,e||0,r||0)),this},Zt.prototype.skewX=function(t){return this.__stack.push(Rt().skewX(t)),this},Zt.prototype.skewY=function(t){return this.__stack.push(Rt().skewY(t)),this},Zt.prototype.matrix=function(t){return this.__stack.push(Rt().matrix(t)),this},Zt.prototype.transform=function(t){return t.trim()?(this.__stack.push(function(t){var e,r,i=new Rt;return t.split(Wt).forEach((function(t){if(t.length)if(void 0===jt[t])switch(r=t.split(Gt).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},Zt.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},Zt.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~\.\[:\)]+)/g,"a"),e(/(\.[^\s\+>~\.\[:\)]+)/g,"b"),e(/(::[^\s\+>~\.\[:]+|:first-line|:first-letter|:before|:after)/gi,"c"),e(/(:(?!not|global|local)[\w-]+\([^\)]*\))/gi,"b"),e(/(:(?!not|global|local)[^\s\+>~\.\[:]+)/g,"b"),i=(i=(i=(i=(i=(i=i.replace(/[\*\s\+>~]/g," ")).replace(/[#\.]/g," ")).replace(/:not/g," ")).replace(/:local/g," ")).replace(/:global/g," ")).replace(/[\(\)]/g," "),e(/([^\s\+>~\.\[:]+)/g,"c"),a.sort((function(t,e){return t.index-e.index})),{selector:t,specificity:"0,"+n.a.toString()+","+n.b.toString()+","+n.c.toString(),specificityArray:[0,n.a,n.b,n.c],parts:a}},ge=function(){function t(t,e){this.rootSvg=t,this.loadExternalSheets=e,this.styleSheets=[]}return t.prototype.load=function(){return s(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return[4,this.collectStyleSheetTexts()];case 1:return t=e.sent(),this.parseCssSheets(t),[2]}}))}))},t.prototype.collectStyleSheetTexts=function(){return s(this,void 0,void 0,(function(){var e,r,i,n,a;return o(this,(function(s){switch(s.label){case 0:if(e=[],this.loadExternalSheets&&this.rootSvg.ownerDocument)for(n=0;n=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;pi[n])return 1}return 0}(t.selectorText,r.selectorText)};return r.reduce((function(t,e){return 1===l(t,e)?t:e})).style.getPropertyValue(e)||void 0}},t}(),me=function(){function t(){this.measureMethods={}}return t.prototype.getTextOffset=function(t,e){var r=e.textAnchor;if("start"===r)return 0;var i=this.measureTextWidth(t,e),n=0;switch(r){case"end":n=i;break;case"middle":n=i/2}return n},t.prototype.measureTextWidth=function(t,e){if(0===t.length)return 0;var r=e.fontFamily;return this.getMeasureFunction(r).call(this,t,e.fontFamily,e.fontSize+"px",e.fontStyle,e.fontWeight)},t.prototype.getMeasurementTextNode=function(){if(!this.textMeasuringTextElement){this.textMeasuringTextElement=document.createElementNS("http://www.w3.org/2000/svg","text");var t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.appendChild(this.textMeasuringTextElement),t.style.setProperty("position","absolute"),t.style.setProperty("visibility","hidden"),document.body.appendChild(t)}return this.textMeasuringTextElement},t.prototype.canvasTextMeasure=function(t,e,r,i,n){var a=document.createElement("canvas").getContext("2d");return null!=a?(a.font=[i,n,r,e].join(" "),a.measureText(t).width):0},t.prototype.svgTextMeasure=function(t,e,r,i,n,a){void 0===a&&(a=this.getMeasurementTextNode());var s=a;return s.setAttribute("font-family",e),s.setAttribute("font-size",r),s.setAttribute("font-style",i),s.setAttribute("font-weight",n),s.setAttributeNS("http://www.w3.org/XML/1998/namespace","xml:space","preserve"),s.textContent=t,s.getBBox().width},t.prototype.getMeasureFunction=function(e){var r=this.measureMethods[e];if(!r){var i=this.canvasTextMeasure(t.testString,e,"16px","normal","normal"),n=this.svgTextMeasure(t.testString,e,"16px","normal","normal");r=Math.abs(i-n)",t.epsilon=.1,t}();function ye(t,e,r){var i,n,l;return void 0===r&&(r={}),s(this,void 0,void 0,(function(){var s,u,h,c,p,d,g,m,y,b,x;return o(this,(function(o){switch(o.label){case 0:return s=null!==(i=r.x)&&void 0!==i?i:0,u=null!==(n=r.y)&&void 0!==n?n:0,h=null!==(l=r.loadExternalStyleSheets)&&void 0!==l&&l,p=new v(c={}),[4,(d=new ge(t,h)).load()];case 1:return o.sent(),g=new vt(e.internal.pageSize.getWidth(),e.internal.pageSize.getHeight()),m=a(a({},r),{element:t}),y=new me,b=new f(e,{refsHandler:p,styleSheets:d,viewport:g,svg2pdfParameters:m,textMeasure:y}),e.advancedAPI(),e.saveGraphicsState(),e.setCurrentTransformationMatrix(e.Matrix(1,0,0,1,s,u)),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,pe(t,c).render(b)];case 2:return o.sent(),e.restoreGraphicsState(),e.compatAPI(),b.textMeasure.cleanupTextMeasuring(),[2,e]}}))}))}e.jsPDF.API.svg=function(t,e){return void 0===e&&(e={}),ye(t,this,e)},t.svg2pdf=ye,Object.defineProperty(t,"__esModule",{value:!0})}));
//# sourceMappingURL=svg2pdf.umd.min.js.map