Created
April 23, 2025 11:00
-
-
Save nerik/ce5a0d3cc5cdd70170850e902d76ef62 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Bundled by jsDelivr using Rollup v2.79.1 and Terser v5.19.2. | |
| * Original file: /npm/[email protected]/index.js | |
| * | |
| * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files | |
| */ | |
| var t={a:7,c:6,h:1,l:2,m:2,r:4,q:4,s:4,t:2,v:1,z:0},e=[5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279];function r(t){return t>=48&&t<=57}function a(t){return t>=48&&t<=57||43===t||45===t||46===t}function s(t){this.index=0,this.path=t,this.max=t.length,this.result=[],this.param=0,this.err="",this.segmentStart=0,this.data=[]}function i(t){for(;t.index<t.max&&(10===(r=t.path.charCodeAt(t.index))||13===r||8232===r||8233===r||32===r||9===r||11===r||12===r||160===r||r>=5760&&e.indexOf(r)>=0);)t.index++;var r}function n(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 h(t){var e,a=t.index,s=a,i=t.max,n=!1,h=!1,o=!1,c=!1;if(s>=i)t.err="SvgPath: missed param (at pos "+s+")";else if(43!==(e=t.path.charCodeAt(s))&&45!==e||(e=++s<i?t.path.charCodeAt(s):0),r(e)||46===e){if(46!==e){if(n=48===e,e=++s<i?t.path.charCodeAt(s):0,n&&s<i&&e&&r(e))return void(t.err="SvgPath: numbers started with `0` such as `09` are illegal (at pos "+a+")");for(;s<i&&r(t.path.charCodeAt(s));)s++,h=!0;e=s<i?t.path.charCodeAt(s):0}if(46===e){for(c=!0,s++;r(t.path.charCodeAt(s));)s++,o=!0;e=s<i?t.path.charCodeAt(s):0}if(101===e||69===e){if(c&&!h&&!o)return void(t.err="SvgPath: invalid float exponent (at pos "+s+")");if(43!==(e=++s<i?t.path.charCodeAt(s):0)&&45!==e||s++,!(s<i&&r(t.path.charCodeAt(s))))return void(t.err="SvgPath: invalid float exponent (at pos "+s+")");for(;s<i&&r(t.path.charCodeAt(s));)s++}t.index=s,t.param=parseFloat(t.path.slice(a,s))+0}else t.err="SvgPath: param should start with 0..9 or `.` (at pos "+s+")"}function o(e){var r,a;a=(r=e.path[e.segmentStart]).toLowerCase();var s=e.data;if("m"===a&&s.length>2&&(e.result.push([r,s[0],s[1]]),s=s.slice(2),a="l",r="m"===r?"l":"L"),"r"===a)e.result.push([r].concat(s));else for(;s.length>=t[a]&&(e.result.push([r].concat(s.splice(0,t[a]))),t[a]););}function c(e){var r,s,c,u,f,l=e.max;if(e.segmentStart=e.index,r=e.path.charCodeAt(e.index),s=97==(32|r),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}(r))if(u=t[e.path[e.index].toLowerCase()],e.index++,i(e),e.data=[],u){for(c=!1;;){for(f=u;f>0;f--){if(!s||3!==f&&4!==f?h(e):n(e),e.err.length)return void o(e);e.data.push(e.param),i(e),c=!1,e.index<l&&44===e.path.charCodeAt(e.index)&&(e.index++,i(e),c=!0)}if(!c){if(e.index>=e.max)break;if(!a(e.path.charCodeAt(e.index)))break}}o(e)}else o(e);else e.err="SvgPath: bad command "+e.path[e.index]+" (at pos "+e.index+")"}function u(){if(!(this instanceof u))return new u;this.queue=[],this.cache=null}u.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},u.prototype.translate=function(t,e){return 0===t&&0===e||(this.cache=null,this.queue.push([1,0,0,1,t,e])),this},u.prototype.scale=function(t,e){return 1===t&&1===e||(this.cache=null,this.queue.push([t,0,0,e,0,0])),this},u.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},u.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},u.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},u.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},u.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 f=u,l=f,p={matrix:!0,scale:!0,rotate:!0,translate:!0,skewX:!0,skewY:!0},d=/\s*(matrix|translate|scale|rotate|skewX|skewY)\s*\(\s*(.+?)\s*\)[\s,]*/,v=/[\s,]+/,x=2*Math.PI;function m(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 g(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]}var _=1e-10,M=Math.PI/180;function y(t,e,r){if(!(this instanceof y))return new y(t,e,r);this.rx=t,this.ry=e,this.ax=r}y.prototype.transform=function(t){var e=Math.cos(this.ax*M),r=Math.sin(this.ax*M),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<_*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)<_&&Math.abs(c-i)<_?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},y.prototype.isDegenerate=function(){return this.rx<_*this.ry||this.ry<_*this.rx};var k=function(t){var e=new s(t),r=e.max;for(i(e);e.index<r&&!e.err.length;)c(e);return 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}},w=function(t){var e,r,a=new l;return t.split(d).forEach((function(t){if(t.length)if(void 0===p[t])switch(r=t.split(v).map((function(t){return+t||0})),e){case"matrix":return void(6===r.length&&a.matrix(r));case"scale":return void(1===r.length?a.scale(r[0],r[0]):2===r.length&&a.scale(r[0],r[1]));case"rotate":return void(1===r.length?a.rotate(r[0],0,0):3===r.length&&a.rotate(r[0],r[1],r[2]));case"translate":return void(1===r.length?a.translate(r[0],0):2===r.length&&a.translate(r[0],r[1]));case"skewX":return void(1===r.length&&a.skewX(r[0]));case"skewY":return void(1===r.length&&a.skewY(r[0]))}else e=t})),a},A=f,q=function(t,e,r,a,s,i,n,h,o){var c=Math.sin(o*x/360),u=Math.cos(o*x/360),f=u*(t-r)/2+c*(e-a)/2,l=-c*(t-r)/2+u*(e-a)/2;if(0===f&&0===l)return[];if(0===n||0===h)return[];n=Math.abs(n),h=Math.abs(h);var p=f*f/(n*n)+l*l/(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,f=-o*(t-r)/2+c*(e-a)/2,l=n*n,p=h*h,d=u*u,v=f*f,g=l*p-l*v-p*d;g<0&&(g=0),g/=l*v+p*d;var _=(g=Math.sqrt(g)*(s===i?-1:1))*n/h*f,M=g*-h/n*u,y=c*_-o*M+(t+r)/2,k=o*_+c*M+(e+a)/2,w=(u-_)/n,A=(f-M)/h,q=(-u-_)/n,C=(-f-M)/h,b=m(1,0,w,A),F=m(w,A,q,C);return 0===i&&F>0&&(F-=x),1===i&&F<0&&(F+=x),[y,k,b,F]}(t,e,r,a,s,i,n,h,c,u),v=[],_=d[2],M=d[3],y=Math.max(Math.ceil(Math.abs(M)/(x/4)),1);M/=y;for(var k=0;k<y;k++)v.push(g(_,M)),_+=M;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}))},C=y;function b(t){if(!(this instanceof b))return new b(t);var e=k(t);this.segments=e.segments,this.err=e.err,this.__stack=[]}b.from=function(t){if("string"==typeof t)return new b(t);if(t instanceof b){var e=new b("");return e.err=t.err,e.segments=t.segments.map((function(t){return t.slice()})),e.__stack=t.__stack.map((function(t){return A().matrix(t.toArray())})),e}throw new Error("SvgPath.from: invalid param type "+t)},b.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 f=t.toArray(),l=C(a[1],a[2],a[3]).transform(f);if(f[0]*f[3]-f[1]*f[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=l.isDegenerate()?["a"===a[0]?"l":"L",h[0],h[1]]:[a[0],l.rx,l.ry,l.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)},b.prototype.__evaluateStack=function(){var t,e;if(this.__stack.length){if(1===this.__stack.length)return this.__matrix(this.__stack[0]),void(this.__stack=[]);for(t=A(),e=this.__stack.length;--e>=0;)t.matrix(this.__stack[e].toArray());this.__matrix(t),this.__stack=[]}},b.prototype.toString=function(){var t="",e="",r=!1;this.__evaluateStack();for(var a=0,s=this.segments.length;a<s;a++){var i=this.segments[a],n=i[0];n!==e||"m"===n||"M"===n?("m"===n&&"z"===e&&(t+=" "),t+=n,r=!1):r=!0;for(var h=1;h<i.length;h++){var o=i[h];1===h?r&&o>=0&&(t+=" "):o>=0&&(t+=" "),t+=o}e=n}return t},b.prototype.translate=function(t,e){return this.__stack.push(A().translate(t,e||0)),this},b.prototype.scale=function(t,e){return this.__stack.push(A().scale(t,e||0===e?e:t)),this},b.prototype.rotate=function(t,e,r){return this.__stack.push(A().rotate(t,e||0,r||0)),this},b.prototype.skewX=function(t){return this.__stack.push(A().skewX(t)),this},b.prototype.skewY=function(t){return this.__stack.push(A().skewY(t)),this},b.prototype.matrix=function(t){return this.__stack.push(A().matrix(t)),this},b.prototype.transform=function(t){return t.trim()?(this.__stack.push(w(t)),this):this},b.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},b.prototype.iterate=function(t,e){var r,a,s,i=this.segments,n={},h=!1,o=0,c=0,u=0,f=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(f=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=f);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},b.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},b.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},b.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=q(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},b.prototype.unshort=function(){var t,e,r,a,s,i=this.segments;return this.iterate((function(n,h,o,c){var u,f=n[0],l=f.toUpperCase();h&&("T"===l?(u="t"===f,"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"===l&&(u="s"===f,"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};var F=b,S=F.from;export{F as default,S as from}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment