{"size": 12810, "ext": "js", "max_stars_repo_path": "dist/index.esm.min.js", "max_stars_repo_name": "m310851010/svgpath-toolkit", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "dist/index.esm.min.js", "max_issues_repo_name": "m310851010/svgpath-toolkit", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "dist/index.esm.min.js", "max_forks_repo_name": "m310851010/svgpath-toolkit", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 4270.0, "max_line_length": 12757, "alphanum_fraction": 0.6046838407}
// SvgPath v1.0.0 | m310851010 © 2021 | MIT-License
function t(){if(!(this instanceof t))return new t;this.queue=[],this.cache=null}t.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},t.prototype.translate=function(t,e){return 0===t&&0===e||(this.cache=null,this.queue.push([1,0,0,1,t,e])),this},t.prototype.scale=function(t,e){return 1===t&&1===e||(this.cache=null,this.queue.push([t,0,0,e,0,0])),this},t.prototype.rotate=function(t,e,r){var a,s,i;return 0!==t&&(this.translate(e,r),a=t*Math.PI/180,s=Math.cos(a),i=Math.sin(a),this.queue.push([s,i,-i,s,0,0]),this.cache=null,this.translate(-e,-r)),this},t.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},t.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},t.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;t<this.queue.length;t++)this.cache=(e=this.cache,r=this.queue[t],[e[0]*r[0]+e[2]*r[1],e[1]*r[0]+e[3]*r[1],e[0]*r[2]+e[2]*r[3],e[1]*r[2]+e[3]*r[3],e[0]*r[4]+e[2]*r[5]+e[4],e[1]*r[4]+e[3]*r[5]+e[5]]);var e,r;return this.cache},t.prototype.calc=function(t,e,r){var a;return this.queue.length?(this.cache||(this.cache=this.toArray()),[t*(a=this.cache)[0]+e*a[2]+(r?0:a[4]),t*a[1]+e*a[3]+(r?0:a[5])]):[t,e]};var e={matrix:!0,scale:!0,rotate:!0,translate:!0,skewX:!0,skewY:!0},r=/\s*(matrix|translate|scale|rotate|skewX|skewY)\s*\(\s*(.+?)\s*\)[\s,]*/,a=/[\s,]+/;function s(s){var i,n,h=new t;return s.split(r).forEach((function(t){if(t.length)if(void 0===e[t])switch(n=t.split(a).map((function(t){return+t||0})),i){case"matrix":return void(6===n.length&&h.matrix(n));case"scale":return void(1===n.length?h.scale(n[0],n[0]):2===n.length&&h.scale(n[0],n[1]));case"rotate":return void(1===n.length?h.rotate(n[0],0,0):3===n.length&&h.rotate(n[0],n[1],n[2]));case"translate":return void(1===n.length?h.translate(n[0],0):2===n.length&&h.translate(n[0],n[1]));case"skewX":return void(1===n.length&&h.skewX(n[0]));case"skewY":return void(1===n.length&&h.skewY(n[0]))}else i=t})),h}var i={a:7,c:6,h:1,l:2,m:2,r:4,q:4,s:4,t:2,v:1,z:0},n=[5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279];function h(t){return t>=48&&t<=57}function o(t){return t>=48&&t<=57||43===t||45===t||46===t}function c(t){this.index=0,this.path=t,this.max=t.length,this.result=[],this.param=0,this.err="",this.segmentStart=0,this.data=[]}function u(t){for(;t.index<t.max&&(10===(e=t.path.charCodeAt(t.index))||13===e||8232===e||8233===e||32===e||9===e||11===e||12===e||160===e||e>=5760&&n.indexOf(e)>=0);)t.index++;var e}function l(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 f(t){var e,r=t.index,a=r,s=t.max,i=!1,n=!1,o=!1,c=!1;if(a>=s)t.err="Svgpath: missed param (at pos "+a+")";else if(43!==(e=t.path.charCodeAt(a))&&45!==e||(e=++a<s?t.path.charCodeAt(a):0),h(e)||46===e){if(46!==e){if(i=48===e,e=++a<s?t.path.charCodeAt(a):0,i&&a<s&&e&&h(e))return void(t.err="Svgpath: numbers started with `0` such as `09` are illegal (at pos "+r+")");for(;a<s&&h(t.path.charCodeAt(a));)a++,n=!0;e=a<s?t.path.charCodeAt(a):0}if(46===e){for(c=!0,a++;h(t.path.charCodeAt(a));)a++,o=!0;e=a<s?t.path.charCodeAt(a):0}if(101===e||69===e){if(c&&!n&&!o)return void(t.err="Svgpath: invalid float exponent (at pos "+a+")");if(43!==(e=++a<s?t.path.charCodeAt(a):0)&&45!==e||a++,!(a<s&&h(t.path.charCodeAt(a))))return void(t.err="Svgpath: invalid float exponent (at pos "+a+")");for(;a<s&&h(t.path.charCodeAt(a));)a++}t.index=a,t.param=parseFloat(t.path.slice(r,a))+0}else t.err="Svgpath: param should start with 0..9 or `.` (at pos "+a+")"}function p(t){var e,r;r=(e=t.path[t.segmentStart]).toLowerCase();var a=t.data;if("m"===r&&a.length>2&&(t.result.push([e,a[0],a[1]]),a=a.slice(2),r="l",e="m"===e?"l":"L"),"r"===r)t.result.push([e].concat(a));else for(;a.length>=i[r]&&(t.result.push([e].concat(a.splice(0,i[r]))),i[r]););}function d(t){var e,r,a,s,n,h=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(s=i[t.path[t.index].toLowerCase()],t.index++,u(t),t.data=[],s){for(a=!1;;){for(n=s;n>0;n--){if(!r||3!==n&&4!==n?f(t):l(t),t.err.length)return;t.data.push(t.param),u(t),a=!1,t.index<h&&44===t.path.charCodeAt(t.index)&&(t.index++,u(t),a=!0)}if(!a){if(t.index>=t.max)break;if(!o(t.path.charCodeAt(t.index)))break}}p(t)}else p(t);else t.err="Svgpath: bad command "+t.path[t.index]+" (at pos "+t.index+")"}function v(t){var e=new c(t),r=e.max;for(u(e);e.index<r&&!e.err.length;)d(e);return e.err.length?e.result=[]:e.result.length&&("mM".indexOf(e.result[0][0])<0?(e.err="Svgpath: string should start with `M` or `m`",e.result=[]):e.result[0][0]="M"),{err:e.err,segments:e.result}}var x=Math.PI/180;function g(t,e,r){if(!(this instanceof g))return new g(t,e,r);this.rx=t,this.ry=e,this.ax=r}g.prototype.transform=function(t){var e=Math.cos(this.ax*x),r=Math.sin(this.ax*x),a=[this.rx*(t[0]*e+t[2]*r),this.rx*(t[1]*e+t[3]*r),this.ry*(-t[0]*r+t[2]*e),this.ry*(-t[1]*r+t[3]*e)],s=a[0]*a[0]+a[2]*a[2],i=a[1]*a[1]+a[3]*a[3],n=((a[0]-a[3])*(a[0]-a[3])+(a[2]+a[1])*(a[2]+a[1]))*((a[0]+a[3])*(a[0]+a[3])+(a[2]-a[1])*(a[2]-a[1])),h=(s+i)/2;if(n<1e-10*h)return this.rx=this.ry=Math.sqrt(h),this.ax=0,this;var o=a[0]*a[1]+a[2]*a[3],c=h+(n=Math.sqrt(n))/2,u=h-n/2;return this.ax=Math.abs(o)<1e-10&&Math.abs(c-i)<1e-10?90:180*Math.atan(Math.abs(o)>Math.abs(c-i)?(c-s)/o:o/(c-i))/Math.PI,this.ax>=0?(this.rx=Math.sqrt(c),this.ry=Math.sqrt(u)):(this.ax+=90,this.rx=Math.sqrt(u),this.ry=Math.sqrt(c)),this},g.prototype.isDegenerate=function(){return this.rx<1e-10*this.ry||this.ry<1e-10*this.rx};var m=2*Math.PI;function _(t,e,r,a){var s=t*r+e*a;return s>1&&(s=1),s<-1&&(s=-1),(t*a-e*r<0?-1:1)*Math.acos(s)}function M(t,e){var r=4/3*Math.tan(e/4),a=Math.cos(t),s=Math.sin(t),i=Math.cos(t+e),n=Math.sin(t+e);return[a,s,a-s*r,s+a*r,i+n*r,n-i*r,i,n]}function y(t,e,r,a,s,i,n,h,o){var c=Math.sin(o*m/360),u=Math.cos(o*m/360),l=u*(t-r)/2+c*(e-a)/2,f=-c*(t-r)/2+u*(e-a)/2;if(0===l&&0===f)return[];if(0===n||0===h)return[];n=Math.abs(n),h=Math.abs(h);var p=l*l/(n*n)+f*f/(h*h);p>1&&(n*=Math.sqrt(p),h*=Math.sqrt(p));var d=function(t,e,r,a,s,i,n,h,o,c){var u=c*(t-r)/2+o*(e-a)/2,l=-o*(t-r)/2+c*(e-a)/2,f=n*n,p=h*h,d=u*u,v=l*l,x=f*p-f*v-p*d;x<0&&(x=0),x/=f*v+p*d;var g=(x=Math.sqrt(x)*(s===i?-1:1))*n/h*l,M=x*-h/n*u,y=c*g-o*M+(t+r)/2,k=o*g+c*M+(e+a)/2,w=(u-g)/n,q=(l-M)/h,A=(-u-g)/n,C=(-l-M)/h,b=_(1,0,w,q),F=_(w,q,A,C);return 0===i&&F>0&&(F-=m),1===i&&F<0&&(F+=m),[y,k,b,F]}(t,e,r,a,s,i,n,h,c,u),v=[],x=d[2],g=d[3],y=Math.max(Math.ceil(Math.abs(g)/(m/4)),1);g/=y;for(var k=0;k<y;k++)v.push(M(x,g)),x+=g;return v.map((function(t){for(var e=0;e<t.length;e+=2){var r=t[e+0],a=t[e+1],s=u*(r*=n)-c*(a*=h),i=c*r+u*a;t[e+0]=s+d[0],t[e+1]=i+d[1]}return t}))}function k(t){if(!(this instanceof k))return new k(t);var e=v(t);this.segments=e.segments,this.err=e.err,this.__stack=[]}k.from=function(e){if("string"==typeof e)return new k(e);if(e instanceof k){var r=new k("");return r.err=e.err,r.segments=e.segments.map((function(t){return t.slice()})),r.__stack=e.__stack.map((function(e){return t().matrix(e.toArray())})),r}throw new Error("SvgPath.from: invalid param type "+e)},k.prototype.__matrix=function(t){var e,r=this;t.queue.length&&this.iterate((function(a,s,i,n){var h,o,c,u;switch(a[0]){case"v":o=0===(h=t.calc(0,a[1],!0))[0]?["v",h[1]]:["l",h[0],h[1]];break;case"V":o=(h=t.calc(i,a[1],!1))[0]===t.calc(i,n,!1)[0]?["V",h[1]]:["L",h[0],h[1]];break;case"h":o=0===(h=t.calc(a[1],0,!0))[1]?["h",h[0]]:["l",h[0],h[1]];break;case"H":o=(h=t.calc(a[1],n,!1))[1]===t.calc(i,n,!1)[1]?["H",h[0]]:["L",h[0],h[1]];break;case"a":case"A":var l=t.toArray(),f=g(a[1],a[2],a[3]).transform(l);if(l[0]*l[3]-l[1]*l[2]<0&&(a[5]=a[5]?"0":"1"),h=t.calc(a[6],a[7],"a"===a[0]),"A"===a[0]&&a[6]===i&&a[7]===n||"a"===a[0]&&0===a[6]&&0===a[7]){o=["a"===a[0]?"l":"L",h[0],h[1]];break}o=f.isDegenerate()?["a"===a[0]?"l":"L",h[0],h[1]]:[a[0],f.rx,f.ry,f.ax,a[4],a[5],h[0],h[1]];break;case"m":u=s>0,o=["m",(h=t.calc(a[1],a[2],u))[0],h[1]];break;default:for(o=[c=a[0]],u=c.toLowerCase()===c,e=1;e<a.length;e+=2)h=t.calc(a[e],a[e+1],u),o.push(h[0],h[1])}r.segments[s]=o}),!0)},k.prototype.__evaluateStack=function(){var e,r;if(this.__stack.length){if(1===this.__stack.length)return this.__matrix(this.__stack[0]),void(this.__stack=[]);for(e=t(),r=this.__stack.length;--r>=0;)e.matrix(this.__stack[r].toArray());this.__matrix(e),this.__stack=[]}},k.prototype.toString=function(){var t,e,r=[];this.__evaluateStack();for(var a=0;a<this.segments.length;a++)e=this.segments[a][0],t=a>0&&"m"!==e&&"M"!==e&&e===this.segments[a-1][0],r=r.concat(t?this.segments[a].slice(1):this.segments[a]);return r.join(" ").replace(/ ?([achlmqrstvz]) ?/gi,"$1").replace(/ \-/g,"-").replace(/zm/g,"z m")},k.prototype.translate=function(e,r){return this.__stack.push(t().translate(e,r||0)),this},k.prototype.scale=function(e,r){return this.__stack.push(t().scale(e,r||0===r?r:e)),this},k.prototype.rotate=function(e,r,a){return this.__stack.push(t().rotate(e,r||0,a||0)),this},k.prototype.skewX=function(e){return this.__stack.push(t().skewX(e)),this},k.prototype.skewY=function(e){return this.__stack.push(t().skewY(e)),this},k.prototype.matrix=function(e){return this.__stack.push(t().matrix(e)),this},k.prototype.transform=function(t){return t.trim()?(this.__stack.push(s(t)),this):this},k.prototype.round=function(t){var e,r=0,a=0,s=0,i=0;return t=t||0,this.__evaluateStack(),this.segments.forEach((function(n){var h=n[0].toLowerCase()===n[0];switch(n[0]){case"H":case"h":return h&&(n[1]+=s),s=n[1]-n[1].toFixed(t),void(n[1]=+n[1].toFixed(t));case"V":case"v":return h&&(n[1]+=i),i=n[1]-n[1].toFixed(t),void(n[1]=+n[1].toFixed(t));case"Z":case"z":return s=r,void(i=a);case"M":case"m":return h&&(n[1]+=s,n[2]+=i),s=n[1]-n[1].toFixed(t),i=n[2]-n[2].toFixed(t),r=s,a=i,n[1]=+n[1].toFixed(t),void(n[2]=+n[2].toFixed(t));case"A":case"a":return h&&(n[6]+=s,n[7]+=i),s=n[6]-n[6].toFixed(t),i=n[7]-n[7].toFixed(t),n[1]=+n[1].toFixed(t),n[2]=+n[2].toFixed(t),n[3]=+n[3].toFixed(t+2),n[6]=+n[6].toFixed(t),void(n[7]=+n[7].toFixed(t));default:return e=n.length,h&&(n[e-2]+=s,n[e-1]+=i),s=n[e-2]-n[e-2].toFixed(t),i=n[e-1]-n[e-1].toFixed(t),void n.forEach((function(e,r){r&&(n[r]=+n[r].toFixed(t))}))}})),this},k.prototype.iterate=function(t,e){var r,a,s,i=this.segments,n={},h=!1,o=0,c=0,u=0,l=0;if(e||this.__evaluateStack(),i.forEach((function(e,r){var a=t(e,r,o,c);Array.isArray(a)&&(n[r]=a,h=!0);var s=e[0]===e[0].toLowerCase();switch(e[0]){case"m":case"M":return o=e[1]+(s?o:0),c=e[2]+(s?c:0),u=o,void(l=c);case"h":case"H":return void(o=e[1]+(s?o:0));case"v":case"V":return void(c=e[1]+(s?c:0));case"z":case"Z":return o=u,void(c=l);default:o=e[e.length-2]+(s?o:0),c=e[e.length-1]+(s?c:0)}})),!h)return this;for(s=[],r=0;r<i.length;r++)if(void 0!==n[r])for(a=0;a<n[r].length;a++)s.push(n[r][a]);else s.push(i[r]);return this.segments=s,this},k.prototype.abs=function(){return this.iterate((function(t,e,r,a){var s,i=t[0],n=i.toUpperCase();if(i!==n)switch(t[0]=n,i){case"v":return void(t[1]+=a);case"a":return t[6]+=r,void(t[7]+=a);default:for(s=1;s<t.length;s++)t[s]+=s%2?r:a}}),!0),this},k.prototype.rel=function(){return this.iterate((function(t,e,r,a){var s,i=t[0],n=i.toLowerCase();if(i!==n&&(0!==e||"M"!==i))switch(t[0]=n,i){case"V":return void(t[1]-=a);case"A":return t[6]-=r,void(t[7]-=a);default:for(s=1;s<t.length;s++)t[s]-=s%2?r:a}}),!0),this},k.prototype.unarc=function(){return this.iterate((function(t,e,r,a){var s,i,n,h=[],o=t[0];return"A"!==o&&"a"!==o?null:("a"===o?(i=r+t[6],n=a+t[7]):(i=t[6],n=t[7]),0===(s=y(r,a,i,n,t[4],t[5],t[1],t[2],t[3])).length?[["a"===t[0]?"l":"L",t[6],t[7]]]:(s.forEach((function(t){h.push(["C",t[2],t[3],t[4],t[5],t[6],t[7]])})),h))})),this},k.prototype.unshort=function(){var t,e,r,a,s,i=this.segments;return this.iterate((function(n,h,o,c){var u,l=n[0],f=l.toUpperCase();h&&("T"===f?(u="t"===l,"Q"===(r=i[h-1])[0]?(t=r[1]-o,e=r[2]-c):"q"===r[0]?(t=r[1]-r[3],e=r[2]-r[4]):(t=0,e=0),a=-t,s=-e,u||(a+=o,s+=c),i[h]=[u?"q":"Q",a,s,n[1],n[2]]):"S"===f&&(u="s"===l,"C"===(r=i[h-1])[0]?(t=r[3]-o,e=r[4]-c):"c"===r[0]?(t=r[3]-r[5],e=r[4]-r[6]):(t=0,e=0),a=-t,s=-e,u||(a+=o,s+=c),i[h]=[u?"c":"C",a,s,n[1],n[2],n[3],n[4]]))})),this};export{g as Ellipse,t as Matrix,k as SvgPath,y as a2c,v as pathParse,s as transformParse};
