UNPKG

svg2pdf.js

Version:

A javascript-only SVG to PDF conversion utility that runs in the browser leveraging jsPDF

2 lines 86.9 kB
!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=function(t,e){return r=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])},r(t,e)};function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function i(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}var n=function(){return n=Object.assign||function(t){for(var e,r=1,i=arguments.length;r<i;r++)for(var n in e=arguments[r])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t},n.apply(this,arguments)};function a(t,e,r,i){return new(r||(r=Promise))((function(n,a){function s(t){try{l(i.next(t))}catch(t){a(t)}}function o(t){try{l(i.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,o)}l((i=i.apply(t,e||[])).next())}))}function s(t,e){var r,i,n,a,s={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return a={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function o(a){return function(o){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,i&&(n=2&a[0]?i.return:a[0]?i.throw||((n=i.return)&&n.call(i),0):i.next)&&!(n=n.call(i,a[1])).done)return n;switch(i=0,n&&(a=[2&a[0],n.value]),a[0]){case 0:case 1:n=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,i=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(n=s.trys,(n=n.length>0&&n[n.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!n||a[1]>n[0]&&a[1]<n[3])){s.label=a[1];break}if(6===a[0]&&s.label<n[1]){s.label=n[1],n=a;break}if(n&&s.label<n[2]){s.label=n[2],s.ops.push(a);break}n[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],i=0}finally{r=n=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,o])}}}var o,l,u=function(){function t(t){if(this.a=void 0,this.r=0,this.g=0,this.b=0,this.simpleColors={},this.colorDefs=[],this.ok=!1,t){for(var e in"#"==t.charAt(0)&&(t=t.substr(1,6)),t=(t=t.replace(/ /g,"")).toLowerCase(),this.simpleColors={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"00ffff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000000",blanchedalmond:"ffebcd",blue:"0000ff",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"00ffff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgrey:"a9a9a9",darkgreen:"006400",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",feldspar:"d19275",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"ff00ff",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",grey:"808080",green:"008000",greenyellow:"adff2f",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgrey:"d3d3d3",lightgreen:"90ee90",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslateblue:"8470ff",lightslategray:"778899",lightslategrey:"778899",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"00ff00",limegreen:"32cd32",linen:"faf0e6",magenta:"ff00ff",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370d8",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"d87093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",red:"ff0000",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",violetred:"d02090",wheat:"f5deb3",white:"ffffff",whitesmoke:"f5f5f5",yellow:"ffff00",yellowgreen:"9acd32"},this.simpleColors)t==e&&(t=this.simpleColors[e]);this.colorDefs=[{re:/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/,example:["rgb(123, 234, 45)","rgb(255,234,245)"],process:function(t){return[parseInt(t[1]),parseInt(t[2]),parseInt(t[3])]}},{re:/^rgb\(([0-9.]+)%,\s*([0-9.]+)%,\s*([0-9.]+)%\)$/,example:["rgb(50.5%, 25.75%, 75.5%)","rgb(100%,0%,0%)"],process:function(t){return[Math.round(2.55*parseFloat(t[1])),Math.round(2.55*parseFloat(t[2])),Math.round(2.55*parseFloat(t[3]))]}},{re:/^(\w{2})(\w{2})(\w{2})$/,example:["#00ff00","336699"],process:function(t){return[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16)]}},{re:/^(\w{1})(\w{1})(\w{1})$/,example:["#fb0","f0f"],process:function(t){return[parseInt(t[1]+t[1],16),parseInt(t[2]+t[2],16),parseInt(t[3]+t[3],16)]}}];for(var r=0;r<this.colorDefs.length;r++){var i=this.colorDefs[r].re,n=this.colorDefs[r].process,a=i.exec(t);if(a){var s=n(a);this.r=s[0],this.g=s[1],this.b=s[2],this.ok=!0}}this.r=this.r<0||isNaN(this.r)?0:this.r>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<this.colorDefs.length;r++)for(var i=this.colorDefs[r].example,n=0;n<i.length;n++)e[e.length]=i[n];for(var a in this.simpleColors)e[e.length]=a;var s=document.createElement("ul");s.setAttribute("id","rgbcolor-examples");for(r=0;r<e.length;r++)try{var o=document.createElement("li"),l=new t(e[r]),u=document.createElement("div");u.style.cssText="margin: 3px; border: 1px solid black; background:"+l.toHex()+"; color:"+l.toHex(),u.appendChild(document.createTextNode("test"));var h=document.createTextNode(" "+e[r]+" -> "+l.toRGB()+" -> "+l.toHex());o.appendChild(u),o.appendChild(h),s.appendChild(o)}catch(t){}return s},t}(),h=function(){function t(t){this.color=t}return t.prototype.getFillData=function(t,e){return a(this,void 0,void 0,(function(){return s(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,this.contextFill=null,this.contextStroke=null,this.fillRule=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.fillRule=this.fillRule,e.contextFill=this.contextFill,e.contextStroke=this.contextStroke,e},t.default=function(){var e=new t;return e.xmlSpace="default",e.fill=new h(new u("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 u("rgb(0, 0, 0)"),e.fillRule="nonzero",e.contextFill=null,e.contextStroke=null,e},t.getContextColors=function(t,e){void 0===e&&(e=!1);var r={};return t.attributeState.contextFill&&(r.contextFill=t.attributeState.contextFill),t.attributeState.contextStroke&&(r.contextStroke=t.attributeState.contextStroke),e&&t.attributeState.color&&(r.color=t.attributeState.color),r},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():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}();function p(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t} /*! https://mths.be/cssesc v3.0.0 by @mathias */var d=function(){if(l)return o;l=1;var t={}.hasOwnProperty,e=/[ -,\.\/:-@\[-\^`\{-~]/,r=/[ -,\.\/:-@\[\]\^`\{-~]/,i=/(^|\\+)?(\\[A-F0-9]{1,6})\x20(?![a-fA-F0-9\x20])/g,n=function n(a,s){"single"!=(s=function(e,r){if(!e)return r;var i={};for(var n in r)i[n]=t.call(e,n)?e[n]:r[n];return i}(s,n.options)).quotes&&"double"!=s.quotes&&(s.quotes="single");for(var o="double"==s.quotes?'"':"'",l=s.isIdentifier,u=a.charAt(0),h="",c=0,f=a.length;c<f;){var p=a.charAt(c++),d=p.charCodeAt(),g=void 0;if(d<32||d>126){if(d>=55296&&d<=56319&&c<f){var m=a.charCodeAt(c++);56320==(64512&m)?d=((1023&d)<<10)+(1023&m)+65536:c--}g="\\"+d.toString(16).toUpperCase()+" "}else g=s.escapeEverything?e.test(p)?"\\"+p:"\\"+d.toString(16).toUpperCase()+" ":/[\t\n\f\r\x0B]/.test(p)?"\\"+d.toString(16).toUpperCase()+" ":"\\"==p||!l&&('"'==p&&o==p||"'"==p&&o==p)||l&&r.test(p)?"\\"+p:p;h+=g}return l&&(/^-[-\d]/.test(h)?h="\\-"+h.slice(1):/\d/.test(u)&&(h="\\3"+u+" "+h.slice(1))),h=h.replace(i,(function(t,e,r){return e&&e.length%2?t:(e||"")+r})),!l&&s.wrap?o+h+o:h};return n.options={escapeEverything:!1,isIdentifier:!1,quotes:"single",wrap:!1},n.version="3.0.0",o=n}(),g=p(d),m=function(){function t(e){this.renderedElements={},this.idMap=e,this.idPrefix=String(t.instanceCounter++)}return t.prototype.getRendered=function(t,e,r){return a(this,void 0,void 0,(function(){var i,n;return s(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[g(t,{isIdentifier:!0})]},t.prototype.generateKey=function(t,e){var r="";return e&&(r=["color","contextFill","contextStroke"].map((function(t){var r,i;return null!==(i=null===(r=e[t])||void 0===r?void 0:r.toRGBA())&&void 0!==i?i:""})).join("|")),this.idPrefix+"|"+t+"|"+r},t.instanceCounter=0,t}();function y(t,e){return Math.atan2(e[1]-t[1],e[0]-t[0])}var v=2/3;function b(t,e){return[v*(e[0]-t[0])+t[0],v*(e[1]-t[1])+t[1]]}function x(t){var e=Math.sqrt(t[0]*t[0]+t[1]*t[1]);return[t[0]/e,t[1]/e]}function S(t,e){return x([e[0]-t[0],e[1]-t[1]])}function w(t,e){return[t[0]+e[0],t[1]+e[1]]}function k(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 M=function(){function t(){this.segments=[]}return t.prototype.moveTo=function(t,e){return this.segments.push(new C(t,e)),this},t.prototype.lineTo=function(t,e){return this.segments.push(new F(t,e)),this},t.prototype.curveTo=function(t,e,r,i,n,a){return this.segments.push(new A(t,e,r,i,n,a)),this},t.prototype.close=function(){return this.segments.push(new T),this},t.prototype.transform=function(t){this.segments.forEach((function(e){if(e instanceof C||e instanceof F||e instanceof A){var r=k([e.x,e.y],t);e.x=r[0],e.y=r[1]}if(e instanceof A){var i=k([e.x1,e.y1],t),n=k([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 C?e.moveTo(t.x,t.y):t instanceof F?e.lineTo(t.x,t.y):t instanceof A?e.curveTo(t.x1,t.y1,t.x2,t.y2,t.x,t.y):e.close()}))},t}(),C=function(t,e){this.x=t,this.y=e},F=function(t,e){this.x=t,this.y=e},A=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},T=function(){};function P(t,e){return e.split(",").indexOf((t.nodeName||t.tagName).toLowerCase())>=0}function B(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 N(t,e,r){if("none"===B(t.element,r.styleSheets,"display"))return!1;var i=e,n=B(t.element,r.styleSheets,"visibility");return n&&(i="hidden"!==n),i}function E(t,e,r){var i=N(t,e,r);return 0!==t.element.childNodes.length&&(t.children.forEach((function(t){t.isVisible(i,r)&&(i=!0)})),i)}var O,L,I=function(){function t(){this.markers=[]}return t.prototype.addMarker=function(t){this.markers.push(t)},t.prototype.draw=function(t){return a(this,void 0,void 0,(function(){var e,r,i,n,a,o,l,u;return s(this,(function(s){switch(s.label){case 0:e=0,s.label=1;case 1:return e<this.markers.length?(r=this.markers[e],i=void 0,n=r.angle,a=r.anchor,o=Math.cos(n),l=Math.sin(n),i=t.pdf.Matrix(o,l,-l,o,a[0],a[1]),i=t.pdf.matrixMult(t.pdf.Matrix(t.attributeState.strokeWidth,0,0,t.attributeState.strokeWidth,0,0),i),i=t.pdf.matrixMult(i,t.transform),t.pdf.saveGraphicsState(),u=c.getContextColors(t),[4,t.refsHandler.getRendered(r.id,u,(function(e){return e.apply(t)}))]):[3,4];case 2:s.sent(),t.pdf.doFormObject(t.refsHandler.generateKey(r.id,u),i),t.pdf.restoreGraphicsState(),s.label=3;case 3:return e++,[3,1];case 4:return[2]}}))}))},t}(),_=function(t,e,r,i){void 0===i&&(i=!1),this.id=t,this.anchor=e,this.angle=r,this.isStartMarker=i},H=/url\(["']?#([^"']+)["']?\)/,R={bottom:"bottom","text-bottom":"bottom",top:"top","text-top":"top",hanging:"hanging",middle:"middle",central:"middle",center:"middle",mathematical:"middle",ideographic:"ideographic",alphabetic:"alphabetic",baseline:"alphabetic"},D="http://www.w3.org/2000/svg";function j(t,e){var r;return(r=t&&t.toString().match(/^([\-0-9.]+)em$/))?parseFloat(r[1])*e:(r=t&&t.toString().match(/^([\-0-9.]+)(px|)$/))?parseFloat(r[1]):0}function q(t){return R[t]||"alphabetic"}function V(t){for(var e,r=[],i=/[+-]?(?:(?:\d+\.?\d*)|(?:\d*\.?\d+))(?:[eE][+-]?\d+)?/g;e=i.exec(t);)r.push(parseFloat(e[0]));return r}function W(t,e){if("transparent"===t){var r=new u("rgb(0,0,0)");return r.a=0,r}if(e&&"currentcolor"===t.toLowerCase())return e.color||new u("rgb(0,0,0)");if(e&&"context-stroke"===t.toLowerCase())return e.contextStroke||new u("rgb(0,0,0)");if(e&&"context-fill"===t.toLowerCase())return e.contextFill||new u("rgb(0,0,0)");var i=/\s*rgba\(((?:[^,\)]*,){3}[^,\)]*)\)\s*/.exec(t);if(i){var n=V(i[1]),a=new u("rgb("+n.slice(0,3).join(",")+")");return a.a=n[3],a}return new u(t)}var G=p(function(){if(L)return O;L=1;var t=/[a-z0-9_-]/i,e=/[\s\t]/,r=/[^a-z0-9_-]/i;return O={parse:function(r){for(var i,n,a=!0,s=0,o="",l=0,u=[];;){if(n=r[l],0===s){if(!n&&a)break;if(!n&&!a)throw new Error("Parse error");if('"'===n||"'"===n)i=n,s=1,a=!1;else if(e.test(n));else{if(!t.test(n))throw new Error("Parse error");s=3,a=!1,l--}}else if(1===s){if(!n)throw new Error("Parse Error");"\\"===n?s=2:n===i?(u.push(o),o="",s=4):o+=n}else if(2===s){if(n!==i&&"\\"!==n)throw new Error("Parse error");o+=n,s=1}else if(3===s){if(!n){u.push(o);break}if(t.test(n))o+=n;else if(","===n)u.push(o),o="",s=0;else{if(!e.test(n))throw new Error("Parse error");s=5}}else if(5===s){if(!n){u.push(o);break}if(t.test(n))o+=" "+n,s=3;else if(","===n)u.push(o),o="",s=0;else if(!e.test(n))throw new Error("Parse error")}else if(4===s){if(!n)break;if(","===n)s=0;else if(!e.test(n))throw new Error("Parse error")}l++}return u},stringify:function(t,e){var i=e&&e.quote||'"';if('"'!==i&&"'"!==i)throw new Error("Quote must be `'` or `\"`");for(var n=new RegExp(i,"g"),a=[],s=0;s<t.length;++s){var o=t[s];r.test(o)&&(o=i+(o=o.replace(/\\/g,"\\\\").replace(n,"\\"+i))+i),a.push(o)}return a.join(", ")}}}()),U={"sans-serif":"helvetica",verdana:"helvetica",arial:"helvetica",fixed:"courier",monospace:"courier",terminal:"courier",serif:"times",cursive:"times",fantasy:"times"};var z,Y=(z=e.jsPDF.version.split("."),2===parseFloat(z[0])&&3===parseFloat(z[1]));function X(t,e){return Y?400==e?"italic"==t?"italic":"normal":700==e&&"italic"!==t?"bold":t+""+e:400==e||"normal"===e?"italic"===t?"italic":"normal":700!=e&&"bold"!==e||"normal"!==t?(700==e?"bold":e)+""+t:"bold"}function Q(t,e){if("none"===B(e.element,t.styleSheets,"display"))return[0,0,0,0];var r=[];return e.children.forEach((function(e){var i=e.getBoundingBox(t);if(0!==i[0]||0!==i[1]||0!==i[2]||0!==i[3]){var n=e.computeNodeTransform(t);i[0]=i[0]*n.sx+n.tx,i[1]=i[1]*n.sy+n.ty,i[2]=i[2]*n.sx,i[3]=i[3]*n.sy,r=0===r.length?i:[Math.min(r[0],i[0]),Math.min(r[1],i[1]),Math.max(r[0]+r[2],i[0]+i[2])-Math.min(r[0],i[0]),Math.max(r[1]+r[3],i[1]+i[3])-Math.min(r[1],i[1])]}})),0===r.length?[0,0,0,0]:r}function $(t,e){var r=parseFloat,i=r(t.getAttribute("x1"))||r(B(t,e.styleSheets,"x"))||r(B(t,e.styleSheets,"cx"))-r(B(t,e.styleSheets,"r"))||0,n=r(t.getAttribute("x2"))||i+r(B(t,e.styleSheets,"width"))||r(B(t,e.styleSheets,"cx"))+r(B(t,e.styleSheets,"r"))||0,a=r(t.getAttribute("y1"))||r(B(t,e.styleSheets,"y"))||r(B(t,e.styleSheets,"cy"))-r(B(t,e.styleSheets,"r"))||0,s=r(t.getAttribute("y2"))||a+r(B(t,e.styleSheets,"height"))||r(B(t,e.styleSheets,"cy"))+r(B(t,e.styleSheets,"r"))||0;return[Math.min(i,n),Math.min(a,s),Math.max(i,n)-Math.min(i,n),Math.max(a,s)-Math.min(a,s)]}function K(t,e,r,i,n,a,s,o){void 0===o&&(o=!1);var l,u,h=e[0],c=e[1],f=e[2],p=e[3],d=n/f,g=a/p,m=t.getAttribute("preserveAspectRatio");if(m){var y=m.split(" ");"defer"===y[0]&&(y=y.slice(1)),l=y[0],u=y[1]||"meet"}else l="xMidYMid",u="meet";if("none"!==l&&("meet"===u?d=g=Math.min(d,g):"slice"===u&&(d=g=Math.max(d,g))),o)return s.pdf.Matrix(d,0,0,g,0,0);var v=r-h*d,b=i-c*g;l.indexOf("xMid")>=0?v+=(n-f*d)/2:l.indexOf("xMax")>=0&&(v+=n-f*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 c=n.exec(t);if(c&&(r=V(c[1]),h=e.pdf.matrixMult(e.pdf.Matrix(r[0],r[1],r[2],r[3],r[4],r[5]),h),t=t.substr(c[0].length)),c=s.exec(t)){r=V(c[1]);var f=Math.PI*r[0]/180;if(h=e.pdf.matrixMult(e.pdf.Matrix(Math.cos(f),Math.sin(f),-Math.sin(f),Math.cos(f),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(c[0].length)}(c=a.exec(t))&&(r=V(c[1]),h=e.pdf.matrixMult(e.pdf.Matrix(1,0,0,1,r[0],r[1]||0),h),t=t.substr(c[0].length)),(c=o.exec(t))&&((r=V(c[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(c[0].length)),(c=l.exec(t))&&(r=parseFloat(c[1]),r*=Math.PI/180,h=e.pdf.matrixMult(e.pdf.Matrix(1,0,Math.tan(r),1,0,0),h),t=t.substr(c[0].length)),(c=u.exec(t))&&(r=parseFloat(c[1]),r*=Math.PI/180,h=e.pdf.matrixMult(e.pdf.Matrix(1,Math.tan(r),0,1,0,0),h),t=t.substr(c[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"===B(this.element,t.styleSheets,"display")?[0,0,0,0]:this.getBoundingBoxCore(t)},t.prototype.computeNodeTransform=function(t){var e=this.computeNodeTransformCore(t),r=B(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 i(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 i(r,t),r.prototype.apply=function(t){return a(this,void 0,void 0,(function(){var r,i,n,a,o,l;return s(this,(function(s){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&&(o=new e.GState({opacity:n/i.length})),l=new e.ShadingPattern(this.pdfGradientType,this.getCoordinates(),i,o),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=B(i.element,t,"color");if(n){this.contextColor=W(n,null);break}i=i.getParent()}}var a=[];return this.children.forEach((function(i){if("stop"===i.element.tagName.toLowerCase()){var n=B(i.element,t,"color"),s=W(B(i.element,t,"stop-color")||"",n?{color:W(n,null)}:{color:e.contextColor}),o=parseFloat(B(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 E(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 i(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 i(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 a(this,void 0,void 0,(function(){var r,i,n;return s(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(B(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 i(r,t),r.prototype.apply=function(t){return a(this,void 0,void 0,(function(){var r,i,n,a,o;return s(this,(function(s){switch(s.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,o=this.children,s.label=1;case 1:return a<o.length?[4,o[a].render(new f(t.pdf,{attributeState:t.attributeState,refsHandler:t.refsHandler,styleSheets:t.styleSheets,viewport:t.viewport,svg2pdfParameters:t.svg2pdfParameters,textMeasure:t.textMeasure}))]:[3,4];case 2:s.sent(),s.label=3;case 3:return a++,[3,1];case 4:return t.pdf.endTilingPattern(r,n),[2]}}))}))},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 E(this,t,e)},r}(tt),st=function(){function t(t,e){this.key=t,this.pattern=e}return t.prototype.getFillData=function(t,e){return a(this,void 0,void 0,(function(){var r,i,n,a,o,l,u,h,c,p,d,g;return s(this,(function(s){switch(s.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 s.sent(),r={key:this.key,boundingBox:void 0,xStep:0,yStep:0,matrix:void 0},n=e.pdf.unitMatrix,this.pattern.element.hasAttribute("patternUnits")&&"objectboundingbox"!==this.pattern.element.getAttribute("patternUnits").toLowerCase()||(i=t.getBoundingBox(e),n=e.pdf.Matrix(1,0,0,1,i[0],i[1]),o=this.pattern.getBoundingBox(e),l=o[0]*i[0]||0,u=o[1]*i[1]||0,h=o[2]*i[2]||0,c=o[3]*i[3]||0,r.boundingBox=[l,u,l+h,u+c],r.xStep=h,r.yStep=c),a=e.pdf.unitMatrix,this.pattern.element.hasAttribute("patternContentUnits")&&"objectboundingbox"===this.pattern.element.getAttribute("patternContentUnits").toLowerCase()&&(i||(i=t.getBoundingBox(e)),a=e.pdf.Matrix(i[2],0,0,i[3],0,0),o=r.boundingBox||this.pattern.getBoundingBox(e),l=o[0]/i[0]||0,u=o[1]/i[1]||0,h=o[2]/i[2]||0,c=o[3]/i[3]||0,r.boundingBox=[l,u,l+h,u+c],r.xStep=h,r.yStep=c),p=e.pdf.unitMatrix,(d=B(this.pattern.element,e.styleSheets,"patternTransform","transform"))&&(p=Z(d,e)),g=a,g=e.pdf.matrixMult(g,n),g=e.pdf.matrixMult(g,p),g=e.pdf.matrixMult(g,e.transform),r.matrix=g,[2,r]}}))}))},t}();function ot(t,e){var r=H.exec(t);if(r){var i=r[1],n=e.refsHandler.get(i);return n&&(n instanceof rt||n instanceof it)?function(t,e,r){var i=e.getStops(r.styleSheets);if(0===i.length)return null;if(1===i.length){var n=i[0].color,a=new u;return a.ok=!0,a.r=n[0],a.g=n[1],a.b=n[2],a.a=i[0].opacity,new h(a)}return new nt(t,e)}(i,n,e):n&&n instanceof at?new st(i,n):new h(new u("rgb(0, 0, 0)"))}var a=W(t,e.attributeState);return a.ok?new h(a):null}function lt(t,e,r){var i=r||e.element,n=B(i,t.styleSheets,"color");if(n){var a=W(n,t.attributeState);a.ok?t.attributeState.color=a:t.attributeState.color=new u("rgb(0,0,0)")}var s=B(i,t.styleSheets,"visibility");s&&(t.attributeState.visibility=s);var o=B(i,t.styleSheets,"fill");o&&(t.attributeState.fill=ot(o,t));var l=B(i,t.styleSheets,"fill-opacity");l&&(t.attributeState.fillOpacity=parseFloat(l));var c=B(i,t.styleSheets,"stroke-opacity");c&&(t.attributeState.strokeOpacity=parseFloat(c));var f=B(i,t.styleSheets,"opacity");f&&(t.attributeState.opacity=parseFloat(f));var p=B(i,t.styleSheets,"stroke-width");void 0!==p&&""!==p&&(t.attributeState.strokeWidth=Math.abs(parseFloat(p)));var d=B(i,t.styleSheets,"stroke");if(d)if("none"===d)t.attributeState.stroke=null;else{var g=W(d,t.attributeState);g.ok&&(t.attributeState.stroke=new h(g))}d&&t.attributeState.stroke instanceof h&&(t.attributeState.contextStroke=t.attributeState.stroke.color),o&&t.attributeState.fill instanceof h&&(t.attributeState.contextFill=t.attributeState.fill.color);var m=B(i,t.styleSheets,"stroke-linecap");m&&(t.attributeState.strokeLinecap=m);var y=B(i,t.styleSheets,"stroke-linejoin");y&&(t.attributeState.strokeLinejoin=y);var v=B(i,t.styleSheets,"stroke-dasharray");if(v){var b=parseInt(B(i,t.styleSheets,"stroke-dashoffset")||"0");t.attributeState.strokeDasharray=V(v),t.attributeState.strokeDashoffset=b}var x=B(i,t.styleSheets,"stroke-miterlimit");void 0!==x&&""!==x&&(t.attributeState.strokeMiterlimit=parseFloat(x));var S=i.getAttribute("xml:space");S&&(t.attributeState.xmlSpace=S);var w=B(i,t.styleSheets,"font-weight");w&&(t.attributeState.fontWeight=w);var k=B(i,t.styleSheets,"font-style");k&&(t.attributeState.fontStyle=k);var M=B(i,t.styleSheets,"font-family");if(M){var C=G.parse(M);t.attributeState.fontFamily=function(t,e,r){var i=X(t.fontStyle,t.fontWeight),n=r.pdf.getFontList(),a="";return e.some((function(t){var e=n[t];return e&&e.indexOf(i)>=0?(a=t,!0):(t=t.toLowerCase(),!!U.hasOwnProperty(t)&&(a=t,!0))}))||(a="times"),a}(t.attributeState,C,t)}var F=B(i,t.styleSheets,"font-size");if(F){var A=t.pdf.getFontSize();t.attributeState.fontSize=j(F,A)}var T=B(i,t.styleSheets,"vertical-align")||B(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 N=B(i,t.styleSheets,"text-anchor");N&&(t.attributeState.textAnchor=N);var E=B(i,t.styleSheets,"fill-rule");E&&(t.attributeState.fillRule=E)}function ut(t,r,i){var n=1,a=1;n*=t.attributeState.fillOpacity,n*=t.attributeState.opacity,t.attributeState.fill instanceof h&&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 h&&void 0!==t.attributeState.stroke.color.a&&(a*=t.attributeState.stroke.color.a);var s,o,l=n<1,u=a<1;if(P(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 c={};l&&(c.opacity=n),u&&(c["stroke-opacity"]=a),t.pdf.setGState(new e.GState(c))}if(t.attributeState.fill&&t.attributeState.fill!==r.attributeState.fill&&t.attributeState.fill instanceof h&&t.attributeState.fill.color.ok&&!P(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 h&&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 h&&t.attributeState.fill.color.ok){var f=t.attributeState.fill.color;t.pdf.setTextColor(f.r,f.g,f.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=H.exec(t);if(i){var n=i[1];return r.refsHandler.get(n)||void 0}}function ct(t,e,r){return a(this,void 0,void 0,(function(){var i,n;return s(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 ft=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype.render=function(t){return a(this,void 0,void 0,(function(){var e,r,i,n;return s(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=B(this.element,e.styleSheets,"clip-path"),(i=r&&"none"!==r)?(n=ht(r,0,e))?n.isVisible(!0,e)?(e.pdf.saveGraphicsState(),[4,ct(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 i(e,t),e}(ft),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 i(e,t),e.prototype.renderCore=function(t){return a(this,void 0,void 0,(function(){var e;return s(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 a(this,void 0,void 0,(function(){return s(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 a(this,void 0,void 0,(function(){var e,r,i,n,a;return s(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.attributeState.fillRule,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;l<e.segments.length;l++){var u=e.segments[l];(u instanceof C||u instanceof F||u instanceof A)&&(s=u.x,o=u.y),u instanceof A?(r=Math.min(r,s,u.x1,u.x2,u.x),n=Math.max(n,s,u.x1,u.x2,u.x),i=Math.min(i,o,u.y1,u.y2,u.y),a=Math.max(a,o,u.y1,u.y2,u.y)):(r=Math.min(r,s),n=Math.max(n,s),i=Math.min(i,o),a=Math.max(a,o))}return[r,i,n-r,a-i]},e.prototype.getMarkers=function(t,e){var r=B(this.element,e.styleSheets,"marker-start"),i=B(this.element,e.styleSheets,"marker-mid"),n=B(this.element,e.styleSheets,"marker-end"),a=new I;if(r||i||n){n&&(n=gt(n)),r&&(r=gt(r)),i&&(i=gt(i));for(var s=t.segments,o=[1,0],l=void 0,u=!1,h=[1,0],c=!1,f=function(t){var e=s[t],f=r&&(1===t||!(s[t]instanceof C)&&s[t-1]instanceof C);f&&s.forEach((function(e,r){if(!c&&e instanceof T&&r>t){var i=s[r-1];c=(i instanceof C||i instanceof F||i instanceof A)&&i}}));var p=n&&(t===s.length-1||!(s[t]instanceof C)&&s[t+1]instanceof C),d=i&&t>0&&!(1===t&&s[t-1]instanceof C),g=s[t-1]||null;if(g instanceof C||g instanceof F||g instanceof A){if(e instanceof A)f&&a.addMarker(new _(r,[g.x,g.y],y(c?[c.x,c.y]:[g.x,g.y],[e.x1,e.y1]),!0)),p&&a.addMarker(new _(n,[e.x,e.y],y([e.x2,e.y2],[e.x,e.y]))),d&&(l=S([g.x,g.y],[e.x1,e.y1]),l=g instanceof C?l:x(w(o,l)),a.addMarker(new _(i,[g.x,g.y],Math.atan2(l[1],l[0])))),o=S([e.x2,e.y2],[e.x,e.y]);else if(e instanceof C||e instanceof F){if(l=S([g.x,g.y],[e.x,e.y]),f){var m=c?S([c.x,c.y],[e.x,e.y]):l;a.addMarker(new _(r,[g.x,g.y],Math.atan2(m[1],m[0]),!0))}if(p&&a.addMarker(new _(n,[e.x,e.y],Math.atan2(l[1],l[0]))),d){m=e instanceof C?o:g instanceof C?l:x(w(o,l));a.addMarker(new _(i,[g.x,g.y],Math.atan2(m[1],m[0])))}o=l}else if(e instanceof T){if(l=S([g.x,g.y],[u.x,u.y]),d){m=g instanceof C?l:x(w(o,l));a.addMarker(new _(i,[g.x,g.y],Math.atan2(m[1],m[0])))}if(p){m=x(w(l,h));a.addMarker(new _(n,[u.x,u.y],Math.atan2(m[1],m[0])))}o=l}}else{u=e instanceof C&&e;var v=s[t+1];(v instanceof C||v instanceof F||v instanceof A)&&(h=S([u.x,u.y],[v.x,v.y]))}},p=0;p<s.length;p++)f(p)}return a.markers.forEach((function(t){var r=e.refsHandler.get(t.id);if(r){var i=B(r.element,e.styleSheets,"orient");null!=i&&(t.isStartMarker&&"auto-start-reverse"===i&&(t.angle+=Math.PI),isNaN(Number(i))||(t.angle=parseFloat(i)/180*Math.PI))}})),a},e}(pt);function gt(t){var e=H.exec(t);return e&&e[1]||void 0}var mt=function(t){function e(e,r){return t.call(this,!0,e,r)||this}return i(e,t),e.prototype.getPath=function(t){if(t.withinClipPath||null===t.attributeState.stroke)return null;var e=parseFloat(this.element.getAttribute("x1")||"0"),r=parseFloat(this.element.getAttribute("y1")||"0"),i=parseFloat(this.element.getAttribute("x2")||"0"),n=parseFloat(this.element.getAttribute("y2")||"0");return e||i||r||n?(new M).moveTo(e,r).lineTo(i,n):null},e.prototype.computeNodeTransformCore=function(t){return t.pdf.unitMatrix},e.prototype.isVisible=function(t,e){return N(this,t,e)},e.prototype.fillOrStroke=function(e){return a(this,void 0,void 0,(function(){return s(this,(function(r){switch(r.label){case 0:return e.attributeState.fill=null,[4,t.prototype.fillOrStroke.call(this,e)];case 1:return r.sent(),[2]}}))}))},e}(dt),yt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype.apply=function(t){return a(this,void 0,void 0,(function(){var e,r,i,n,a;return s(this,(function(s){switch(s.label){case 0:return this.isVisible("hidden"!==t.attributeState.visibility,t)?((e=t.clone()).transform=e.pdf.unitMatrix,lt(e,this),r=B(this.element,e.styleSheets,"clip-path"),r&&"none"!==r&&(i=ht(r,0,e))?i.isVisible(!0,e)?[4,ct(this,i,e)]:[3,2]:[3,3]):[2];case 1:return s.sent(),[3,3];case 2:return[2];case 3:ut(e,t,this.element),n=0,a=this.children,s.label=4;case 4:return n<a.length?[4,a[n].render(e)]:[3,7];case 5:s.sent(),s.label=6;case 6:return n++,[3,4];case 7:return[2]}}))}))},e.prototype.getBoundingBoxCore=function(t){return Q(t,this)},e.prototype.isVisible=function(t,e){return E(this,t,e)},e.prototype.computeNodeTransformCore=function(t){var e=parseFloat(B(this.element,t.styleSheets,"x")||"0"),r=parseFloat(B(this.element,t.styleSheets,"y")||"0"),i=this.element.getAttribute("viewBox");if(i){var n=V(i),a=parseFloat(B(this.element,t.styleSheets,"width")||B(this.element.ownerSVGElement,t.styleSheets,"width")||i[2]),s=parseFloat(B(this.element,t.styleSheets,"height")||B(this.element.ownerSVGElement,t.styleSheets,"height")||i[3]);return K(this.element,n,e,r,a,s,t)}return t.pdf.Matrix(1,0,0,1,e,r)},e}(tt),vt=function(t,e){this.width=t,this.height=e},bt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype.renderCore=function(t){return a(this,void 0,void 0,(function(){var r,i,n,a,o,l,u,h,p,d,g,m,y;return s(this,(function(s){switch(s.label){case 0:return r=parseFloat,(i=this.element.getAttribute("href")||this.element.getAttribute("xlink:href"))?(n=i.substring(1),a=t.refsHandler.get(n),o=P(a.element,"symbol,svg")&&a.element.hasAttribute("viewBox"),l=r(B(this.element,t.styleSheets,"x")||"0"),u=r(B(this.element,t.styleSheets,"y")||"0"),h=void 0,p=void 0,o?(h=r(B(this.element,t.styleSheets,"width")||B(a.element,t.styleSheets,"width")||"0"),p=r(B(this.element,t.styleSheets,"height")||B(a.element,t.styleSheets,"height")||"0"),l+=r(B(a.element,t.styleSheets,"x")||"0"),u+=r(B(a.element,t.styleSheets,"y")||"0"),g=V(a.element.getAttribute("viewBox")),d=K(a.element,g,l,u,h,p,t)):d=t.pdf.Matrix(1,0,0,1,l,u),m=c.getContextColors(t,!0),y=new f(t.pdf,{refsHandler:t.refsHandler,styleSheets:t.styleSheets,withinUse:!0,viewport:o?new vt(h,p):t.viewport,svg2pdfParameters:t.svg2pdfParameters,textMeasure:t.textMeasure,attributeState:Object.assign(c.default(),m)}),[4,t.refsHandler.getRendered(n,m,(function(t){return e.renderReferencedNode(t,n,y)}))]):[2];case 1:return s.sent(),t.pdf.saveGraphicsState(),t.pdf.setCurrentTransformationMatrix(t.transform),o&&"visible"!==B(a.element,t.styleSheets,"overflow")&&(t.pdf.rect(l,u,h,p),t.pdf.clip().discardPath()),t.pdf.doFormObject(t.refsHandler.generateKey(n,m),d),t.pdf.restoreGraphicsState(),[2]}}))}))},e.renderReferencedNode=function(t,e,r){return a(this,void 0,void 0,(function(){var i;return s(this,(function(n){switch(n.label){case 0:return i=[(i=t.getBoundingBox(r))[0]-.5*i[2],i[1]-.5*i[3],2*i[2],2*i[3]],r.pdf.beginFormObject(i[0],i[1],i[2],i[3],r.pdf.unitMatrix),t instanceof yt?[4,t.apply(r)]:[3,2];case 1:return n.sent(),[3,4];case 2:return[4,t.render(r)];case 3:n.sent(),n.label=4;case 4:return r.pdf.endFormObject(r.refsHandler.generateKey(e,r.attributeState)),[2]}}))}))},e.prototype.getBoundingBoxCore=function(t){return $(this.element,t)},e.prototype.isVisible=function(t,e){return N(this,t,e)},e.prototype.computeNodeTransformCore=function(t){return t.pdf.unitMatrix},e}(pt),xt=function(t){function e(e,r){return t.call(this,!1,e,r)||this}return i(e,t),e.prototype.getPath=function(t){var e=parseFloat(B(this.element,t.styleSheets,"width")||"0"),r=parseFloat(B(this.element,t.styleSheets,"height")||"0");if(!isFinite(e)||e<=0||!isFinite(r)||r<=0)return null;var i=B(this.element,t.styleSheets,"rx"),n=B(this.element,t.styleSheets,"ry"),a=Math.min(parseFloat(i||n||"0"),.5*e),s=Math.min(parseFloat(n||i||"0"),.5*r),o=parseFloat(B(this.element,t.styleSheets,"x")||"0"),l=parseFloat(B(this.element,t.styleSheets,"y")||"0"),u=4/3*(Math.SQRT2-1);return 0===a&&0===s?(new M).moveTo(o,l).lineTo(o+e,l).lineTo(o+e,l+r).lineTo(o,l+r).close():(new M).moveTo(o+=a,l).lineTo(o+=e-2*a,l).curveTo(o+a*u,l,o+a,l+(s-s*u),o+=a,l+=s).lineTo(o,l+=r-2*s).curveTo(o,l+s*u,o-a*u,l+s,o-=a,l+=s).lineTo(o+=2*a-e,l).curveTo(o-a*u,l,o-a,l-s*u,o-=a,l-=s).lineTo(o,l+=2*s-r).curveTo(o,l-s*u,o+a*u,l-s,o+=a,l-=s).close()},e.prototype.computeNodeTransformCore=function(t){return t.pdf.unitMatrix},e.prototype.isVisible=function(t,e){return N(this,t,e)},e}(dt),St=function(t){function e(e,r){return t.call(this,!1,e,r)||this}return i(e,t),e.prototype.getPath=function(t){var e=this.getRx(t),r=this.getRy(t);if(!isFinite(e)||r<=0||!isFinite(r)||r<=0)return null;var i=parseFloat(B(this.element,t.styleSheets,"cx")||"0"),n=parseFloat(B(this.element,t.styleSheets,"cy")||"0"),a=4/3*(Math.SQRT2-1)*e,s=4/3*(Math.SQRT2-1)*r;return(new M).moveTo(i+e,n).curveTo(i+e,n-s,i+a,n-r,i,n-r).curveTo(i-a,n-r,i-e,n-s,i-e,n).curveTo(i-e,n+s,i-a,n+r,i,n+r).curveTo(i+a,n+r,i+e,n+s,i+e,n)},e.prototype.computeNodeTransformCore=function(t){return t.pdf.unitMatrix},e.prototype.isVisible=function(t,e){return N(this,t,e)},e}(dt),wt=function(t){function e(e,r){return t.call(this,e,r)||this}return i(e,t),e.prototype.getRx=function(t){return parseFloat(B(this.element,t.styleSheets,"rx")||"0")},e.prototype.getRy=function(t){return parseFloat(B(this.element,t.styleSheets,"ry")||"0")},e}(St);function kt(t){var e="invisible",r=t.stroke&&0!==t.strokeWidth,i=t.fill;return i&&r?e="fillThenStroke":i?e="fill":r&&(e="stroke"),e}function Mt(t){return t.replace(/[\n\r]/g,"")}function Ct(t){return t.replace(/[\t]/g," ")}function Ft(t){return t.replace(/ +/g," ")}function At(t,e,r){switch(B(t,r.styleSheets,"text-transform")){case"uppercase":return e.toUpperCase();case"lowercase":return e.toLowerCase();default:return e}}var Tt,Pt,Bt,Nt,Et,Ot,Lt,It,_t,Ht,Rt,Dt,jt,qt,Vt=function(){function t(t,e,r,i){this.textNode=t,this.texts=[],this.textNodes=[],this.contexts=[],this.textAnchor=e,this.originX=r,this.originY=i,this.textMeasures=[]}return t.prototype.setX=function(t){this.originX=t},t.prototype.setY=function(t){this.originY=t},t.prototype.add=function(t,e,r){this.texts.push(e),this.textNodes.push(t),this.contexts.push(r)},t.prototype.rightTrimText=function(){for(var t=this.texts.length-1;t>=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;e<this.texts.length;e++)this.textMeasures.push({width:t.textMeasure.measureTextWidth(this.texts[e],this.contexts[e].attributeState),length:this.texts[e].length})},t.prototype.put=function(e,r){var i,n,a,s,o=[],l=[],u=[],h=this.originX,c=this.originY,f=h,p=h;for(i=0;i<this.textNodes.length;i++){n=this.textNodes[i],a=this.contexts[i],s=this.textMeasures[i]||{width:e.textMeasure.measureTextWidth(this.texts[i],this.contexts[i].attributeState),length:this.texts[i].length};var d=h,g=c;if("#text"!==n.nodeName&&!o.includes(n)){o.push(n);var m=t.resolveRelativePositionAttribute(n,"dx");null!==m&&(d+=j(m,a.attributeState.fontSize));var y=t.resolveRelativePositionAttribute(n,"dy");null!==y&&(g+=j(y,a.attributeState.fontSize))}l[i]=d,u[i]=g,h=d+s.width+s.length*r,c=g,f=Math.min(f,d),p=Math.max(p,h)}var v=0;switch(this.textAnchor){case"start":v=0;break;case"middle":v=(p-f)/2;break;case"end":v=p-f}for(i=0;i<this.textNodes.length;i++)if(n=this.textNodes[i],a=this.contexts[i],"#text"===n.nodeName||"hidden"!==a.attributeState.visibility){e.pdf.saveGraphicsState(),ut(a,e,n);var b=a.attributeState.alignmentBaseline,x=kt(a.attributeState);e.pdf.text(this.texts[i],l[i]-v,u[i],{baseline:q(b),angle:e.transform,renderingMode:"fill"===x?void 0:x,charSpace:0===r?void 0:r}),e.pdf.restoreGraphicsState()}return[h,c]},t.resolveRelativePositionAttribute=function(t,e){for(var r,i=t;i&&P(i,"tspan");){if(i.hasAttribute(e))return i.getAttribute(e);if((null===(r=t.parentElement)||void 0===r?void 0:r.firstChild)!==t)break;i=i.parentElement}return null},t}(),Wt=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.boundingBox=[],e}return i(e,t),e.prototype.processTSpans=function(t,e,r,i,n,a){for(var s=r.pdf.getFontSize(),o=r.attributeState.xmlSpace,l=!0,u=!1,h=0;h<e.childNodes.length;h++){var c=e.childNodes[h];if(c.textContent){var f=c.textContent;if("#text"===c.nodeName){var p=Mt(f);p=Ct(p),"default"===o&&(p=Ft(p),l&&p.match(/^\s/)&&(u=!0),p.match(/[^\s]/)&&(l=!1),a.prevText.match(/\s$/)&&(p=p.replace(/^\s+/,"")));var d=At(e,p,r);n.add(e,d,r),a.prevText=f,a.prevContext=r}else if(P(c,"title"));else if(P(c,"tspan")){var g=c,m=g.getAttribute("x");if(null!==m){var y=j(m,s);n=new Vt(this,B(g,r.styleSheets,"text-anchor")||r.attributeState.textAnchor,y,0),i.push({type:"y",chunk:n})}var v=g.getAttribute("y");if(null!==v){var b=j(v,s);n=new Vt(this,B(g,r.styleSheets,"text-anchor")||r.attributeState.textAnchor,0,b),i.push({type:"x",chunk:n})}var x=r.clone();lt(x,t,g),this.processTSpans(t,g,x,i,n,a)}}}return u},e.prototype.renderCore=function(t){return a(this,void 0,void 0,(function(){var e,r,i,n,a,o,l,u,h,c,f,p,d,g,m,y,v,b,x,S,w,k,M;return s(this,(function(s){if(t.pdf.saveGraphicsState(),e=0,r=0,i=1,n=t.pdf.getFontSize(),a=j(this.element.getAttribute("x"),n),o=j(this.element.getAttribute("y"),n),l=j(this.element.getAttribute("dx"),n),u=j(this.element.getAttribute("dy"),n),h=parseFloat(this.element.getAttribute("textLength")||"0"),c=t.attributeState.visibility,0===this.element.childElementCount)f=this.element.textContent||"",p=function(t,e){return t=Ct(t=Mt(t)),"default"===e.xmlSpace&&(t=Ft(t=t.trim())),t}(f,t.attributeState),d=At(this.element,p,t),e=t.textMeasure.getTextOffset(d,t.attributeState),h>0&&(g=t.textMeasure.measureTextWidth(d,t.attributeState),"default"===t.attributeState.xmlSpace&&f.match(/^\s/)&&(i=0),r=(h-g)/(d.length-i)||0),"visible"===c&&(m=t.attrib