svg-path-simplify 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3607,12 +3607,98 @@ function pathDataToTopLeft(pathData) {
3607
3607
  }
3608
3608
 
3609
3609
  // reorder to top left most
3610
- indices = indices.sort((a, b) => +a.y.toFixed(3) - +b.y.toFixed(3) || a.x - b.x);
3610
+
3611
+ indices = indices.sort((a, b) => +a.y.toFixed(3) - +b.y.toFixed(3) );
3611
3612
  newIndex = indices[0].index;
3612
3613
 
3613
3614
  return newIndex ? shiftSvgStartingPoint(pathData, newIndex) : pathData;
3614
3615
  }
3615
3616
 
3617
+ function optimizeClosePath(pathData, removeFinalLineto = true, reorder = true) {
3618
+
3619
+ let pathDataNew = [];
3620
+ let len = pathData.length;
3621
+ let M = { x: +pathData[0].values[0].toFixed(8), y: +pathData[0].values[1].toFixed(8) };
3622
+ let isClosed = pathData[len - 1].type.toLowerCase() === 'z';
3623
+
3624
+ let linetos = pathData.filter(com => com.type === 'L');
3625
+
3626
+ // check if order is ideal
3627
+ let penultimateCom = pathData[len - 2];
3628
+ let penultimateType = penultimateCom.type;
3629
+ let penultimateComCoords = penultimateCom.values.slice(-2).map(val => +val.toFixed(8));
3630
+
3631
+ // last L command ends at M
3632
+ let isClosingCommand = penultimateComCoords[0] === M.x && penultimateComCoords[1] === M.y;
3633
+
3634
+ // if last segment is not closing or a lineto
3635
+ let skipReorder = pathData[1].type !== 'L' && (!isClosingCommand || penultimateType === 'L');
3636
+ skipReorder = false;
3637
+
3638
+ // we can't change starting point for non closed paths
3639
+ if (!isClosed) {
3640
+ return pathData
3641
+ }
3642
+
3643
+ let newIndex = 0;
3644
+
3645
+ if (!skipReorder) {
3646
+
3647
+ let indices = [];
3648
+ for (let i = 0, len = pathData.length; i < len; i++) {
3649
+ let com = pathData[i];
3650
+ let { type, values } = com;
3651
+ if (values.length) {
3652
+ let valsL = values.slice(-2);
3653
+ let prevL = pathData[i - 1] && pathData[i - 1].type === 'L';
3654
+ let nextL = pathData[i + 1] && pathData[i + 1].type === 'L';
3655
+ let prevCom = pathData[i - 1] ? pathData[i - 1].type.toUpperCase() : null;
3656
+ let nextCom = pathData[i + 1] ? pathData[i + 1].type.toUpperCase() : null;
3657
+ let p = { type: type, x: valsL[0], y: valsL[1], dist: 0, index: 0, prevL, nextL, prevCom, nextCom };
3658
+ p.index = i;
3659
+ indices.push(p);
3660
+ }
3661
+ }
3662
+
3663
+ // find top most lineto
3664
+
3665
+ if (linetos.length) {
3666
+ let curveAfterLine = indices.filter(com => (com.type !== 'L' && com.type !== 'M') && com.prevCom &&
3667
+ com.prevCom === 'L' || com.prevCom === 'M' && penultimateType === 'L').sort((a, b) => a.y - b.y || a.x - b.x)[0];
3668
+
3669
+ newIndex = curveAfterLine ? curveAfterLine.index - 1 : 0;
3670
+
3671
+ }
3672
+ // use top most command
3673
+ else {
3674
+ indices = indices.sort((a, b) => +a.y.toFixed(1) - +b.y.toFixed(1) || a.x - b.x);
3675
+ newIndex = indices[0].index;
3676
+ }
3677
+
3678
+ // reorder
3679
+ pathData = newIndex ? shiftSvgStartingPoint(pathData, newIndex) : pathData;
3680
+ }
3681
+
3682
+ M = { x: +pathData[0].values[0].toFixed(8), y: +pathData[0].values[1].toFixed(7) };
3683
+
3684
+ len = pathData.length;
3685
+
3686
+ // remove last lineto
3687
+ penultimateCom = pathData[len - 2];
3688
+ penultimateType = penultimateCom.type;
3689
+ penultimateComCoords = penultimateCom.values.slice(-2).map(val=>+val.toFixed(8));
3690
+
3691
+ isClosingCommand = penultimateType === 'L' && penultimateComCoords[0] === M.x && penultimateComCoords[1] === M.y;
3692
+
3693
+ if (removeFinalLineto && isClosingCommand) {
3694
+ pathData.splice(len - 2, 1);
3695
+ }
3696
+
3697
+ pathDataNew.push(...pathData);
3698
+
3699
+ return pathDataNew
3700
+ }
3701
+
3616
3702
  /**
3617
3703
  * shift starting point
3618
3704
  */
@@ -4080,10 +4166,14 @@ function svgPathSimplify(input = '', {
4080
4166
  });
4081
4167
  }
4082
4168
 
4169
+ // optimize close path
4170
+ if(optimizeOrder) pathData=optimizeClosePath(pathData);
4171
+
4083
4172
  // update
4084
4173
  pathDataArrN.push(pathData);
4085
4174
  }
4086
4175
 
4176
+
4087
4177
  // flatten compound paths
4088
4178
  pathData = pathDataArrN.flat();
4089
4179
 
@@ -1 +1 @@
1
- const{abs:e,acos:t,asin:l,atan:a,atan2:n,ceil:s,cos:r,exp:i,floor:u,log:p,max:h,min:y,pow:o,random:c,round:x,sin:f,sqrt:g,tan:v,PI:d}=Math;function m(e,t,l=!1){let a=n(t.y-e.y,t.x-e.x);return l&&a<0&&(a+=2*Math.PI),a}function M(e,t,l,a,n=!0){let s,r,i,u,p,h={};try{if(s=(a.y-l.y)*(t.x-e.x)-(a.x-l.x)*(t.y-e.y),0==s)return!1}catch{console.log("!catch",e,t,"p3:",l,a)}r=e.y-l.y,i=e.x-l.x,u=(a.x-l.x)*r-(a.y-l.y)*i,p=(t.x-e.x)*r-(t.y-e.y)*i,r=u/s,i=p/s,h={x:e.x+r*(t.x-e.x),y:e.y+r*(t.y-e.y)};let y=!1;return r>0&&r<1&&i>0&&i<1&&(y=!0),!(n&&!y)&&h}function b(e,t){return g((t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y))}function A(e,t){return(t.x-e.x)**2+(t.y-e.y)**2}function C(e,t,l,a=!1){let n={x:(t.x-e.x)*l+e.x,y:(t.y-e.y)*l+e.y};return a&&(n.angle=m(e,t),n.angle<0&&(n.angle+=2*d)),n}function w(e,t=.5,l=!1,a=!1){let n;return n=e.length>2?((e,t,l=!1)=>{let n=4===e.length,s=e[0],r=e[1],i=n?e[2]:e[1],u=e[e.length-1],p={x:0,y:0};if(l||a){let e,l,h,y,o,c=s.x===r.x&&s.y===r.y,x=u.x===i.x&&u.y===i.y;0!==t||c?1!==t||x?(c&&(t+=1e-7),x&&(t-=1e-7),e=C(s,r,t),n?(l=C(r,i,t),h=C(i,u,t),y=C(e,l,t),o=C(l,h,t),p=C(y,o,t),p.angle=m(y,o),a&&(p.cpts=[l,h,y,o])):(l=C(s,r,t),h=C(r,u,t),p=C(l,h,t),p.angle=m(l,h),a&&(p.cpts=[l,h]))):(p.x=u.x,p.y=u.y,p.angle=m(i,u)):(p.x=s.x,p.y=s.y,p.angle=m(s,r))}else{let e=1-t;p=n?{x:e**3*s.x+3*e**2*t*r.x+3*e*t**2*i.x+t**3*u.x,y:e**3*s.y+3*e**2*t*r.y+3*e*t**2*i.y+t**3*u.y}:{x:e*e*s.x+2*e*t*r.x+t**2*u.x,y:e*e*s.y+2*e*t*r.y+t**2*u.y}}return p})(e,t,l):C(e[0],e[1],t,l),l&&n.angle<0&&(n.angle+=2*d),n}function P(e,t,l,n,s,i=0,u=!0,p=!1){if(s=p?s*d/180:s,i=p?i*d/180:i,i=l!==n&&i!==2*d?i:0,u&&l!==n){let e=a(v(s=i?s-i:s)*(l/n));s=r(s)<0?e+d:e}let h=e+l*r(s),y=t+n*f(s),o={x:h,y:y};return i&&(o.x=e+(h-e)*r(i)-(y-t)*f(i),o.y=t+(h-e)*f(i)+(y-t)*r(i)),o}function S(e,t=[],l=.05){let a=3===t.length,n=t[0]||null,s=a?t[1]:null,r=a?t[2]:t[1],i=.5*Math.PI,u=!1,p=!1,h=n?m(r,n,!0):null;if(u=Math.abs(h%i)<l||Math.abs(h%i-i)<l,a){let e=s?m(s,r,!0):0;p=Math.abs(e%i)<=l||Math.abs(e%i-i)<=l}return u||p}function L(e){return 4===e.length?function(e,t,l,a){let[n,s,r,i,u,p,h,y]=[e.x,e.y,t.x,t.y,l.x,l.y,a.x,a.y],o=Math.min(e.y,a.y),c=Math.min(e.x,a.x),x=Math.max(e.x,a.x),f=Math.max(e.y,a.y);if(t.y>=o&&t.y<=f&&l.y>=o&&l.y<=f&&t.x>=c&&t.x<=x&&l.x>=c&&l.x<=x)return[];let g,v,d,m,M,b,A,C,w=[];for(let e=0;e<2;++e)if(0==e?(v=6*n-12*r+6*u,g=-3*n+9*r-9*u+3*h,d=3*r-3*n):(v=6*s-12*i+6*p,g=-3*s+9*i-9*p+3*y,d=3*i-3*s),Math.abs(g)<1e-12){if(Math.abs(v)<1e-12)continue;m=-d/v,0<m&&m<1&&w.push(m)}else A=v*v-4*d*g,A<0?Math.abs(A)<1e-12&&(m=-v/(2*g),0<m&&m<1&&w.push(m)):(C=Math.sqrt(A),M=(-v+C)/(2*g),0<M&&M<1&&w.push(M),b=(-v-C)/(2*g),0<b&&b<1&&w.push(b));let P=w.length;for(;P--;)m=w[P];return w}(e[0],e[1],e[2],e[3]):function(e,t,l){let a,n,s,r=Math.min(e.y,l.y),i=Math.min(e.x,l.x),u=Math.max(e.x,l.x),p=Math.max(e.y,l.y);if(t.y>=r&&t.y<=p&&t.x>=i&&t.x<=u)return[];let[h,y,o,c,x,f]=[e.x,e.y,t.x,t.y,l.x,l.y],g=[];for(let e=0;e<2;++e)a=0==e?h-2*o+x:y-2*c+f,n=0==e?-2*h+2*o:-2*y+2*c,Math.abs(a)>1e-12&&(s=-n/(2*a),s>0&&s<1&&g.push(s));return g}(e[0],e[1],e[2])}function I(e,t=.025){let l=e[0],a=e[e.length-1],n=e.map(e=>e.x),s=e.map(e=>e.y),r=Math.min(...n),i=Math.max(...n),u=Math.min(...s),p=i-r,h=Math.max(...s)-u;if(e.length<3||0===p||0===h)return{area:0,flat:!0,thresh:1e-4,ratio:0};let y=A(l,a),o=A(l,e[0]),c=(o+(e.length>3?A(a,e[1]):o))/2;let x=.5*(p+h)*.5,f=0;for(let t=0,l=e.length;t<l;t++){f+=e[t].x*e[t===e.length-1?0:t+1].y*.5-e[t===e.length-1?0:t+1].x*e[t].y*.5}f=+Math.abs(f).toFixed(9);return{area:f,flat:0===f||f<c/1e3,thresh:x,ratio:f/c,squareDist:y,areaThresh:y/1e3}}function k(e,t,l){let a=!1,n=2===t.length,s=t[0],r=n?t[1]:s;if(e.x===s.x&&e.y===s.y&&l.x===r.x&&l.y===r.y)return!0;let i=s.x-e.x,u=s.y-e.y,p=l.x-r.x,h=l.y-r.y,y=Math.abs(i*h-u*p);if(!y)return!0;let o=l.x-e.x,c=l.y-e.y,x=Math.abs(o*u-c*i);return!x||(x/y<1.1&&(a=!0),a)}function $(e,t){return(Math.abs(t.x-e.x)+Math.abs(t.y-e.y))/2}function z(e){let t=[];try{e.map((e,t)=>"m"===e.type.toLowerCase()?t:-1).filter(e=>-1!==e)}catch{console.log("catch",e)}let l=e.map((e,t)=>"m"===e.type.toLowerCase()?t:-1).filter(e=>-1!==e);return 1===l.length?[e]:(l.forEach((a,n)=>{t.push(e.slice(a,l[n+1]))}),t)}function E(e,t){let l,a,n,s,r,i,u=[],p=[],h=e[0],y=e[1],o=e[e.length-2],c=e[e.length-1];return 4===e.length?(l=w([h,y],t),a=w([y,o],t),n=w([o,c],t),s=w([l,a],t),r=w([a,n],t),i=w([s,r],t),u.push({x:h.x,y:h.y},{x:l.x,y:l.y},{x:s.x,y:s.y},{x:i.x,y:i.y}),p.push({x:i.x,y:i.y},{x:r.x,y:r.y},{x:n.x,y:n.y},{x:c.x,y:c.y})):3===e.length?(a=w([h,y],t),n=w([y,c],t),i=w([a,n],t),u.push({x:h.x,y:h.y},{x:a.x,y:a.y},{x:i.x,y:i.y}),p.push({x:i.x,y:i.y},{x:n.x,y:n.y},{x:c.x,y:c.y})):2===e.length&&(a=w([h,c],t),u.push({x:h.x,y:h.y},{x:a.x,y:a.y}),p.push({x:a.x,y:a.y},{x:c.x,y:c.y})),[u,p]}function T(e,t,l=0,a=1){let n=[],s=6===t.length?"C":"Q",r={x:t[0],y:t[1]},i="C"===s?{x:t[2],y:t[3]}:r,u={x:t[4],y:t[5]},p=Math.max(u.x,e.x),h=Math.min(u.x,e.x),y=Math.max(u.y,e.y),o=Math.min(u.y,e.y),c=0;if(r.x<h||r.x>p||r.y<o||r.y>y||i.x<h||i.x>p||i.y<o||i.y>y){let p=L("C"===s?[e,r,i,u]:[e,r,u]).sort();if(p=p.filter(e=>e>l&&e<a),p.length){let l=function(e,t,l,a=!0){let n=[];if(!l.length)return!1;let s,r,i,u=t.length,p={x:t[u-2],y:t[u-1]};2===t.length?i=[e,p]:4===t.length?(s={x:t[0],y:t[1]},i=[e,s,p]):6===t.length&&(s={x:t[0],y:t[1]},r={x:t[2],y:t[3]},i=[e,s,r,p]);if(l.length)if(1===l.length){let e=E(i,l[0]),t=e[0],a=e[1];n.push(t,a)}else{let e=l[0],t=E(i,e),a=t[0];n.push(a),i=t[1];for(let t=1;t<l.length;t++){e=l[t-1];let a=E(i,(l[t]-e)/(1-e));n.push(a[0]),t===l.length-1&&n.push(a[a.length-1]),i=a[1]}}if(a){let e,t,l=[];return n.forEach(a=>{e={type:"",values:[]},a.shift(),t=a.map(e=>Object.values(e)).flat(),e.values=t,3===a.length?e.type="C":2===a.length?e.type="Q":1===a.length&&(e.type="L"),l.push(e)}),l}return n}(e,t,p);n.push(...l),c+=l.length}else n.push({type:s,values:t})}else n.push({type:s,values:t});return{pathData:n,count:c}}function Q(e,t=0,l=1){let a=[e[0]],n={x:e[0].values[0],y:e[0].values[1]},s={x:e[0].values[0],y:e[0].values[1]},r=e.length;for(let i=1;r&&i<r;i++){let r=e[i],{type:u,values:p}=r,h=p.slice(-2);if(h[0],h[1],"C"!==u&&"Q"!==u)a.push(r);else if("C"===u||"Q"===u){let e=T(n,p,t,l).pathData;a.push(...e)}n={x:h[0],y:h[1]},"z"===u.toLowerCase()?n=s:"M"===u&&(s={x:h[0],y:h[1]})}return a}function F(e,t=-1){let l=e.map(e=>e.x),a=e.map(e=>e.y),n=Math.min(...l),s=Math.max(...l),r=Math.min(...a),i=Math.max(...a),u={x:n,left:n,right:s,y:r,top:r,bottom:i,width:s-n,height:i-r};if(t>-1)for(let e in u)u[e]=+u[e].toFixed(t);return u}function q(e){let t=[];return e.forEach(e=>{let l=function(e){let t=function(e){let t=[];for(let l=0;l<e.length;l++){let a=e[l],n=l>0?e[l-1]:e[l],{type:s,values:r}=a,i={x:n.values[n.values.length-2],y:n.values[n.values.length-1]},u=r.length?{x:r[r.length-2],y:r[r.length-1]}:"",p=r.length?{x:r[0],y:r[1]}:"";switch(s){case"A":if("function"!=typeof arcToBezier){let e=b(i,u)/2,l=C(i,u,.5),a=P(l.x,l.y,e,e,0),n=P(l.x,l.y,e,e,Math.PI);t.push(a,n,u);break}arcToBezier(i,r).forEach(e=>{let l=e.values,a={x:l[0],y:l[1]},n={x:l[2],y:l[3]},s={x:l[4],y:l[5]};t.push(a,n,s)});break;case"C":let e={x:r[2],y:r[3]};t.push(p,e);break;case"Q":t.push(p)}"z"!==s.toLowerCase()&&t.push(u)}return t}(e),l=F(t);return l}(e);t.push(l)}),t}function D(e,t){let[l,a,n,s,r,i]=[e.x,e.y,e.width,e.height,e.x+e.width,e.y+e.height],[u,p,h,y,o,c]=[t.x,t.y,t.width,t.height,t.x+t.width,t.y+t.height],x=!1;return n*s!=h*y&&n*s>h*y&&l<u&&r>o&&a<p&&i>c&&(x=!0),x}function B(t,l=9){let a=0,s=[],i=z(t),u=i.length>1,p=[];if(u){let e=q(i);e.forEach(function(t,l){for(let l=0;l<e.length;l++){let a=e[l];if(t!=a){D(t,a)&&p.push(l)}}})}return i.forEach((t,l)=>{s=[];let i=0,u=0,h=1,y=[];t.forEach(function(l,a){let[u,p]=[l.type,l.values],h=p.length;if(p.length){let o=(a>0?t[a-1]:t[0]).values,c=o.length,x={x:o[c-2],y:o[c-1]},v={x:p[h-2],y:p[h-1]};if("C"===u||"Q"===u){let e={x:p[0],y:p[1]};y="C"===u?[x,e,{x:p[2],y:p[3]},v]:[x,e,v];let t=Math.abs(function(e,t=!1){let l,[a,n,s,r]=[e[0],e[1],e[2],e[e.length-1]];if(e.length<3)return 0;3===e.length&&(n={x:1*e[0].x/3+2*e[1].x/3,y:1*e[0].y/3+2*e[1].y/3},s={x:1*e[2].x/3+2*e[1].x/3,y:1*e[2].y/3+2*e[1].y/3});return l=3*(a.x*(-2*n.y-s.y+3*r.y)+n.x*(2*a.y-s.y-r.y)+s.x*(a.y+n.y-2*r.y)+r.x*(-3*a.y+n.y+2*s.y))/20,t?Math.abs(l):l}(y));i+=t,s.push(x,v)}else if("A"===u){let t=function(t,l,a,s,i,u,p,h,y){const o=(e,t,l,a)=>n(a-t,l-e);let c={cx:0,cy:0,rx:a=e(a),ry:s=e(s),startAngle:0,endAngle:0,deltaAngle:0,clockwise:p,xAxisRotation:i,largeArc:u,sweep:p};if(0==a||0==s)throw Error("rx and ry can not be 0");if(a===s){let e=Math.abs(h-t),a=Math.abs(y-l),n=e,s=Math.min(t,h),r=Math.min(l,y),i=.5*Math.PI;if(0===e&&a||0===a&&e)return n=0===e&&a?a/2:e/2,c.rx=n,c.ry=n,0===e&&a?(c.cx=t,c.cy=r+a/2,c.startAngle=l>y?i:-i,c.endAngle=l>y?-i:i,c.deltaAngle=p?Math.PI:-Math.PI):0===a&&e&&(c.cx=s+e/2,c.cy=l,c.startAngle=t>h?Math.PI:0,c.endAngle=t>h?-Math.PI:Math.PI,c.deltaAngle=p?Math.PI:-Math.PI),c}let x,v,m=a===s?0:i*d/180,M=m?f(m):0,b=m?r(m):1,A=(t-h)/2,C=(l-y)/2,w=(t+h)/2,P=(l+y)/2,S=m?b*A+M*C:A,L=m?b*C-M*A:C,I=S*S/(a*a)+L*L/(s*s);I>1&&(a*=g(I),s*=g(I),c.rx=a,c.ry=s);let k=a*s,$=a*L,z=s*S,E=$**2+z**2;if(!E)throw Error("start point can not be same as end point");let T=g(e((k*k-E)/E));u==p&&(T=-T);let Q=T*$/s,F=-T*z/a;x=m?b*Q-M*F+w:w+Q,v=m?M*Q+b*F+P:P+F,c.cy=v,c.cx=x;let q=o(x,v,t,l),D=o(x,v,h,y);!p&&D>q&&(D-=2*Math.PI),p&&q>D&&(D=D<=0?D+2*Math.PI:D);let B=D-q;return c.startAngle=q,c.endAngle=D,c.deltaAngle=B,c}(x.x,x.y,l.values[0],l.values[1],l.values[2],l.values[3],l.values[4],v.x,v.y),{cx:a,cy:u,rx:p,ry:h,startAngle:y,endAngle:o,deltaAngle:c}=t,m=Math.abs(function(e,t,l,a){const n=Math.PI*e*t;let s=(a-l+2*Math.PI)%(2*Math.PI);if(e===t)return n*(s/(2*Math.PI));const r=l=>Math.atan2(e*Math.sin(l),t*Math.cos(l));return l=r(l),a=r(a),s=(a-l+2*Math.PI)%(2*Math.PI),n*(s/(2*Math.PI))}(p,h,y,o));m-=Math.abs(O([x,{x:a,y:u},v])),s.push(x,v),i+=m}else s.push(x,v)}});let o=O(s);-1!==p.indexOf(l)&&(h=-1),u=o<0&&i<0?(Math.abs(i)-Math.abs(o))*h:(Math.abs(i)+Math.abs(o))*h,a+=u}),a}function O(e,t=!1){let l=0;for(let t=0,a=e.length;a&&t<a;t++){l+=e[t].x*e[t===e.length-1?0:t+1].y*.5-e[t===e.length-1?0:t+1].x*e[t].y*.5}return t&&(l=Math.abs(l)),l}function j(e,t=0){t=parseFloat(t);let l=e.length,a=t>1,n=!a&&!t,s="",r=a?"\n":n?"":" ",i=n?"":" ";s=`${e[0].type}${i}${e[0].values.join(" ")}${r}`;for(let t=1;t<l;t++){let l=e[t-1],a=e[t],{type:u,values:p}=a;if(!n||"A"!==u&&"a"!==u||(p=[p[0],p[1],p[2],`${p[3]}${p[4]}${p[5]}`,p[6]]),u=l.type===a.type&&"m"!==a.type.toLowerCase()&&n||"M"===l.type&&"L"===a.type&&n?" ":a.type,n){let e="",t=!1;for(let l=0,a=p.length;l<a;l++){let a=p[l],n=a.toString(),s=n.includes(".")&&Math.abs(a)<1;s&&t&&(n=n.replace(/^0\./,".")),!(l>0)||t&&s||(e+=" "),e+=n,t=s}s+=`${u}${i}${e}${r}`}else s+=`${u}${i}${p.join(" ")}${r}`}return n&&(s=s.replace(/ 0\./g," .").replace(/ -/g,"-").replace(/-0\./g,"-.").replace(/Z/g,"z")),s}function N(e,t,l=!1,a=1){let n=[e,t],s=function(e,t){let l=M(e.p0,e.cp1,t.cp2,t.p,!1),a=M(l,t.p,t.p0,t.cp1,!1),n=b(l,t.p),s=b(a,t.p),r=1-s/n,i=b(e.cp2,e.p),u=b(e.cp2,t.cp1);return r=Math.min(i)/u,r}(e,t),r=$(e.p0,e.p),i=$(t.p0,t.p),u=.05*Math.min(r,i)*a,p=function(e,t,l=0,a=0){let{p0:n,cp1:s}=e,{p:r,cp2:i}=t,u={x:(s.x-(1-l)*n.x)/l,y:(s.y-(1-l)*n.y)/l},p={x:(i.x-a*r.x)/(1-a),y:(i.y-a*r.y)/(1-a)},h={p0:n,cp1:u,cp2:p,p:r};return h}(e,t,s,s),h=w([p.p0,p.cp1,p.cp2,p.p],s),y=$(e.p,h),o=0,c=0,x=!1,f=y;if(y<u){let l=.5*(1+s);if(o=$(w([t.p0,t.cp1,t.cp2,t.p],.5),w([p.p0,p.cp1,p.cp2,p.p],l)),f+=o,o<u){let t=.5*s;c=$(w([e.p0,e.cp1,e.cp2,e.p],.5),w([p.p0,p.cp1,p.cp2,p.p],t)),o+c<u&&(x=!0),f+=c}}if(l&&!x){let l=function(e,t,l=0,a=1){const n=(e,t,l,a,n)=>{let s=1-n;return{x:3*s*s*(t.x-e.x)+6*s*n*(l.x-t.x)+3*n*n*(a.x-l.x),y:3*s*s*(t.y-e.y)+6*s*n*(l.y-t.y)+3*n*n*(a.y-l.y)}};let s=[e,t],r=A(e.p0,e.p)>A(t.p0,t.p),i=JSON.parse(JSON.stringify(e)),u=JSON.parse(JSON.stringify(t)),p=M(i.p0,i.cp1,u.p,u.cp2,!1);if(!p)return s;if(r){let l={p0:{x:e.p.x,y:e.p.y},cp1:{x:e.cp2.x,y:e.cp2.y},cp2:{x:e.cp1.x,y:e.cp1.y},p:{x:e.p0.x,y:e.p0.y}};e={p0:{x:t.p.x,y:t.p.y},cp1:{x:t.cp2.x,y:t.cp2.y},cp2:{x:t.cp1.x,y:t.cp1.y},p:{x:t.p0.x,y:t.p0.y}},t=l}let h=(e,t)=>({x:e.x-t.x,y:e.y-t.y}),y=(e,t)=>({x:e.x*t,y:e.y*t}),o=(e,t)=>e.x*t.x+e.y*t.y,c=t.p0,x=n(t.p0,t.cp1,t.cp2,t.p,0),f=o(h(e.p0,c),x)/o(x,x),g=w([t.p0,t.cp1,t.cp2,t.p],f),v=n(t.p0,t.cp1,t.cp2,t.p,f);f-=o(h(g,e.p0),v)/o(v,v);let d=w([t.p0,t.cp1,t.cp2,t.p],f),m=t.p,b=n(t.p0,t.cp1,t.cp2,t.p,f),P=n(t.p0,t.cp1,t.cp2,t.p,1),S=1-f,L=(I=d,k=y(b,S/3),{x:I.x+k.x,y:I.y+k.y});var I,k;let z=h(m,y(P,S/3)),E={p0:d,cp1:L,cp2:z,p:m};r&&(E={p0:m,cp1:z,cp2:L,p:d});let T=w([E.p0,E.cp1,E.cp2,E.p],.5,!1,!0),Q=T.cpts[2],F=M(T,Q,E.p0,p,!1),q=M(T,Q,E.p,p,!1),D=C(E.p0,F,1.333),O=C(E.p,q,1.333);if(M(i.p0,D,u.p,O,!0))return s;E.cp1=D,E.cp2=O;let N=$(i.p0,E.p0)+$(u.p,E.p);if(E.p0=i.p0,E.p=u.p,E.extreme=u.extreme,E.corner=u.corner,E.dimA=u.dimA,E.directionChange=u.directionChange,E.values=[E.cp1.x,E.cp1.y,E.cp2.x,E.cp2.y,E.p.x,E.p.y],N<l){let e=B([{type:"M",values:[i.p0.x,i.p0.y]},{type:"C",values:[i.cp1.x,i.cp1.y,i.cp2.x,i.cp2.y,i.p.x,i.p.y]},{type:"C",values:[u.cp1.x,u.cp1.y,u.cp2.x,u.cp2.y,u.p.x,u.p.y]}]),t=[{type:"M",values:[E.p0.x,E.p0.y]},{type:"C",values:[E.cp1.x,E.cp1.y,E.cp2.x,E.cp2.y,E.p.x,E.p.y]}],l=B(t),n=Math.abs(l/e-1);E.error=10*n*a,j(t),n<.01&&(s=[E])}return s}(e,t,u,a);1===l.length&&(x=!0,p=l[0],f=p.error)}return x&&(p.p0=e.p0,p.p=t.p,p.dimA=$(p.p0,p.p),p.type="C",p.extreme=t.extreme,p.directionChange=t.directionChange,p.corner=t.corner,p.values=[p.cp1.x,p.cp1.y,p.cp2.x,p.cp2.y,p.p.x,p.p.y],p.error=f/u,n=[p]),n}function H(e=[]){let t,l=[],a=function(e){let t=[],l={x:e[0].values[0],y:e[0].values[1]};return e.forEach(e=>{let{type:a,values:n}=e;if(n.length){let e=n.length>1?{x:n[n.length-2],y:n[n.length-1]}:"V"===a?{x:l.x,y:n[0]}:{x:n[0],y:l.y};t.push(e),l=e}}),t}(e),n=F(a),{left:s,right:r,top:i,bottom:u,width:p,height:h}=n,y=e[0].values[0],o=e[0].values[1],c={x:e[0].values[0],y:e[0].values[1]},x={x:e[0].values[0],y:e[0].values[1]};e[0].idx=0,e[0].p0=c,e[0].p=c,e[0].lineto=!1,e[0].corner=!1,e[0].extreme=!1,e[0].directionChange=!1,e[0].closePath=!1,e[0].dimA=0;let f=[e[0]],g=0,v=e.length;for(let l=2;v&&l<=v;l++){let a=e[l-1],{type:n,values:p}=a,h=p.slice(-2),v=[x],d=!1;a.idx=l-1,a.lineto=!1,a.corner=!1,a.extreme=!1,a.directionChange=!1,a.closePath=!1,a.dimA=0;let M,b,C,w,P,L,k,z=.05;t=h.length?{x:h[0],y:h[1]}:c,"M"===n?(c=t,x=t):"z"===n.toLowerCase()&&(t=c),a.p0=x,a.p=t;let E=$(x,t);if(a.dimA=E,"L"===n&&(a.lineto=!0),"Z"===n&&(a.closePath=!0,c.x!==y&&c.y!==o&&(a.lineto=!0)),"Q"!==n&&"C"!==n||(M={x:p[0],y:p[1]},b="C"===n?{x:p[2],y:p[3]}:null,a.cp1=M,b&&(a.cp2=b)),p.length>2){"Q"!==n&&"C"!==n||v.push(M),"C"===n&&v.push(b),v.push(t),d=I(v).flat,a.flat=d,d&&(a.extreme=!1)}d||"L"===n||t.x!==s&&t.y!==i&&t.x!==r&&t.y!==u||(a.extreme=!0);let T=e[l]?e[l]:null,Q=T?T.values.slice(-2):null;L=T?T.type:null,!T||"Q"!==T.type&&"C"!==T.type||(P=T?{x:Q[0],y:Q[1]}:null,C={x:T.values[0],y:T.values[1]},w="C"===T.type?{x:T.values[2],y:T.values[3]}:null),k=O(v);let F=g<0&&k>0||g>0&&k<0;if(g=k,F&&(a.directionChange=!0),("Q"===n||"C"===n)&&("Q"===n&&"Q"===L||"C"===n&&"C"===L)){let e=v.slice(1),l=I("C"===n?[t,C,w,P]:[t,C,P],((P?Math.abs(P.x-x.x):0)+(P?Math.abs(P.y-x.y):0))/2*.1).flat;if((!d||!l)&&(!!a.extreme||S(0,e,z)))a.extreme=!0;else{let e=b?[b,t]:[M,t],l=[t,C],n=m(...e,!0),s=m(...l,!0),r=180*Math.abs(n-s)/Math.PI,i=A(...e),u=A(...l);r>10&&i&&u&&(a.corner=!0)}}f.push(a),x=t}return l={pathData:f,bb:n,dimA:(p+h)/2},l}function V(e,t=-1){let l=!("auto"!=t||!e[0].hasOwnProperty("decimals"));for(let a=0,n=e.length;a<n;a++){let n=e[a];(t>-1||l)&&(t=l?n.decimals:t,e[a].values=n.values.map(e=>e?+e.toFixed(t):e))}return e}function Z(e={},t={},l={},a={}){let n=C(e,t,1.5),s=C(a,l,1.5),r=.01*$(e,a),i=$(n,s),u=null,p="C",h=[t.x,t.y,l.x,l.y,a.x,a.y];return i<r&&(u=M(e,t,a,l,!1),u&&(p="Q",h=[u.x,u.y,a.x,a.y])),{type:p,values:h}}function R(e,{toShorthands:t=!0,toRelative:l=!0,decimals:a=3}={}){return t&&(e=function(e,t=-1,l=!0){let a;if(l){let t=e.map(e=>e.type).join("");a=/[astvqmhlc]/g.test(t)}e=l&&a?W(e,t):e;let n={type:"M",values:e[0].values};e[0].decimals&&(n.decimals=e[0].decimals);let s,r=[n],i={x:e[0].values[0],y:e[0].values[1]},u=.01;for(let l=1,a=e.length;l<a;l++){let a=e[l],{type:p,values:h}=a,y=h.slice(-2),o=e[l-1],c=o.type;s={x:y[0],y:y[1]};let x,f,g,v,d={x:h[0],y:h[1]},m=Math.abs(s.x-i.x),M=Math.abs(s.y-i.y),b=(m+M)/2*u;switch(p){case"L":n=0===M||M<b&&m>b?{type:"H",values:[h[0]]}:0===m||M>b&&m<b?{type:"V",values:[h[1]]}:a;break;case"Q":if("Q"!==c){i={x:y[0],y:y[1]},r.push(a);continue}let e={x:o.values[0],y:o.values[1]};v={x:2*i.x-e.x,y:2*i.y-e.y},x=Math.abs(d.x-v.x),f=Math.abs(d.y-v.y),g=(x+f)/2,n=g<b?{type:"T",values:[s.x,s.y]}:a;break;case"C":let t={x:h[2],y:h[3]};if("C"!==c){r.push(a),i={x:y[0],y:y[1]};continue}let l={x:o.values[2],y:o.values[3]};v={x:2*i.x-l.x,y:2*i.y-l.y},x=Math.abs(d.x-v.x),f=Math.abs(d.y-v.y),g=(x+f)/2,n=g<b?{type:"S",values:[t.x,t.y,s.x,s.y]}:a;break;default:n={type:p,values:h}}(a.decimals||0===a.decimals)&&(n.decimals=a.decimals),t>-1&&(n.values=n.values.map(e=>+e.toFixed(t))),i={x:y[0],y:y[1]},r.push(n)}return r}(e)),e=V(e,a),l&&(e=function(e,t=-1){return U(e,!0,t)}(e)),a>-1&&(e=V(e,a)),e}function J(e,t){Array.isArray(e)&&(e={x:e[0],y:e[1]});let l={x:e.x+2/3*(t[0]-e.x),y:e.y+2/3*(t[1]-e.y)},a={x:t[2]+2/3*(t[0]-t[2]),y:t[3]+2/3*(t[1]-t[3])};return{type:"C",values:[l.x,l.y,a.x,a.y,t[2],t[3]]}}function U(e,t=!1,l=-1){l>=0&&(e[0].values=e[0].values.map(e=>+e.toFixed(l)));let a=e[0].values,n=a[0],s=a[1],r=n,i=s;for(let a=1,u=e.length;a<u;a++){let u=e[a],{type:p,values:h}=u,y=t?p.toLowerCase():p.toUpperCase();if(p!==y)switch(p=y,u.type=p,p){case"a":case"A":h[5]=t?h[5]-n:h[5]+n,h[6]=t?h[6]-s:h[6]+s;break;case"v":case"V":h[0]=t?h[0]-s:h[0]+s;break;case"h":case"H":h[0]=t?h[0]-n:h[0]+n;break;case"m":case"M":t?(h[0]-=n,h[1]-=s):(h[0]+=n,h[1]+=s),r=t?h[0]+n:h[0],i=t?h[1]+s:h[1];break;default:if(h.length)for(let e=0;e<h.length;e++)h[e]=t?h[e]-(e%2?s:n):h[e]+(e%2?s:n)}let o=h.length;switch(p){case"z":case"Z":n=r,s=i;break;case"h":case"H":n=t?n+h[0]:h[0];break;case"v":case"V":s=t?s+h[0]:h[0];break;case"m":case"M":r=h[o-2]+(t?n:0),i=h[o-1]+(t?s:0);default:n=h[o-2]+(t?n:0),s=h[o-1]+(t?s:0)}l>=0&&(u.values=u.values.map(e=>+e.toFixed(l)))}return e}function W(e,t=-1){return U(e,!1,t)}function X(e,t,l=1){const a=2*Math.PI;let[n,s,r,i,u,p,h]=t;if(0===n||0===s)return[];let y=r?r*a/360:0,o=y?Math.sin(y):0,c=y?Math.cos(y):1,x=c*(e.x-p)/2+o*(e.y-h)/2,f=-o*(e.x-p)/2+c*(e.y-h)/2;if(0===x&&0===f)return[];n=Math.abs(n),s=Math.abs(s);let g=x*x/(n*n)+f*f/(s*s);if(g>1){let e=Math.sqrt(g);n*=e,s*=e}let v=n*n,d=n===s?v:s*s,m=x*x,M=f*f,b=v*d-v*M-d*m;b<=0?b=0:(b/=v*M+d*m,b=Math.sqrt(b)*(i===u?-1:1));let A=b?b*n/s*f:0,C=b?b*-s/n*x:0,w=c*A-o*C+(e.x+p)/2,P=o*A+c*C+(e.y+h)/2,S=(x-A)/n,L=(f-C)/s,I=(-x-A)/n,k=(-f-C)/s;const $=(e,t,l,a)=>{let n=+(e*l+t*a).toFixed(9);return 1===n||-1===n?1===n?0:Math.PI:(n=n>1?1:n<-1?-1:n,(e*a-t*l<0?-1:1)*Math.acos(n))};let z=$(1,0,S,L),E=$(S,L,I,k);0===u&&E>0?E-=2*Math.PI:1===u&&E<0&&(E+=2*Math.PI);let T=(+(Math.abs(E)/(a/4)).toFixed(0)||1)*l;E/=T;let Q=[];const F=1.5707963267948966,q=.551785;let D=E===F?q:E===-F?-q:4/3*Math.tan(E/4),B=E?Math.cos(E):1,O=E?Math.sin(E):0;const j=(e,t,l,a,n)=>{let s=e!=t?Math.cos(e):a,r=e!=t?Math.sin(e):n,i=Math.cos(e+t),u=Math.sin(e+t);return[{x:s-r*l,y:r+s*l},{x:i+u*l,y:u-i*l},{x:i,y:u}]};for(let e=0;e<T;e++){let e={type:"C",values:[]};j(z,E,D,B,O).forEach(t=>{let l=t.x*n,a=t.y*s;e.values.push(c*l-o*a+w,o*l+c*a+P)}),Q.push(e),z+=E}return Q}function G(e,t,l,a,n=7.5){let s={type:"C",values:[t.x,t.y,l.x,l.y,a.x,a.y]},r=0,i=!1,u=m(e,t,!0),p=m(a,l,!0),h=180*Math.abs(u-p)/Math.PI;if(Math.abs(h%180-90)<3){let u=M(e,t,a,l,!1);if(u){let p=b(e,u),h=b(a,u),y=+Math.max(p,h).toFixed(8),o=+Math.min(p,h).toFixed(8),c=o,x=y,f=O([e,t,l,a])<0?0:1,g=Math.abs(a.x-e.x)>Math.abs(a.y-e.y);100/c*Math.abs(c-x)<5&&(c=y,x=c),g&&(c=y,x=o);let v=B([{type:"M",values:[e.x,e.y]},{type:"C",values:[t.x,t.y,l.x,l.y,a.x,a.y]}]),d={type:"A",values:[c,x,0,0,f,a.x,a.y]};r=Math.PI*(c*x)/4,r-=Math.abs(O([e,a,u])),function(e,t){let l=Math.abs(e-t);return Math.abs(100-100/e*(e+l))}(v,r)<n&&(i=!0,s=d)}}return{com:s,isArc:i,area:r}}function Y(e){let t,l=[[]],a=0,n=[[]],s={x:e[0].values[0],y:e[0].values[1]};for(let r=0,i=e.length;r<i;r++){let i=e[r],{type:u,values:p}=i;if("A"===u){let u=e[r-1].values.slice(-2);s={x:u[0],y:u[1]};let[h,y,o,c,x,f,g]=p,v=100/h*Math.abs(h-y)<5;t={x:p[5],y:p[6]},i.p0=s,i.p=t,i.circular=v;let d=e[r+1];if(!l[a].length&&d&&"A"===d.type&&(l[a].push(i),n[a].push(r)),d&&"A"===d.type){let[e,i,u,p,o,c,x]=d.values,f=h!=e?100/h*Math.abs(h-e):0,g=y!=i?100/y*Math.abs(y-i):0;t={x:d.values[5],y:d.values[6]},d.p0=s,d.p=t,f<5&&g<5?(l[a].push(d),n[a].push(r+1)):(l.push([]),n.push([]),a++)}else l.push([]),n.push([]),a++}}if(!n.length)return e;l=l.filter(e=>e.length),n=n.filter(e=>e.length);for(let t=l.length-1;t>=0;t--){const a=l[t],s=n[t][0],r=a.length;let i=0,u=0;a.forEach(({values:e})=>{const[t,l]=e;i+=t,u+=l}),i/=r,u/=r;let p=100/i*Math.abs(i-u)<5;p&&(i=(i+u)/2,u=i);let h=e[s-1].values.slice(-2);if(h[0],h[1],4===r){let[t,l,n,h,y,o,c]=a[1].values,[,,,,,x,f]=a[3].values;p&&(i=1,u=1);let g={type:"A",values:[i,u,n,h,y,o,c]},v={type:"A",values:[i,u,n,h,y,x,f]};e.splice(s,r,g,v)}else if(3===r){let[t,l,n,p,h,y,o]=a[0].values,[c,x,,,,f,g]=a[2].values;p=1;let v={type:"A",values:[i,u,n,p,h,f,g]};e.splice(s,r,v)}else if(2===r){let[t,l,n,h,y,o,c]=a[0].values,[x,f,,,,g,v]=a[1].values;p&&(i=1,u=1,n=0);let{p0:d,p:m}=a[0],[M,b]=[a[1].p0,a[1].p];if(d.x!==b.x||d.y!==b.y){let t={type:"A",values:[i,u,n,h,y,g,v]};e.splice(s,r,t)}}}return e}function K(e=[],{toAbsolute:t=!0,toLonghands:l=!0,quadraticToCubic:a=!1,arcToCubic:n=!1,arcAccuracy:s=2}={},{hasRelatives:r=!0,hasShorthands:i=!0,hasQuadratics:u=!0,hasArcs:p=!0,testTypes:h=!1}={}){if(h){let t=Array.from(new Set(e.map(e=>e.type))).join("");r=/[lcqamts]/gi.test(t),u=/[qt]/gi.test(t),p=/[a]/gi.test(t),i=/[vhst]/gi.test(t),isPoly=/[mlz]/gi.test(t)}return(u&&a||p&&n)&&(l=!0,t=!0),r&&t&&(e=U(e,!1)),i&&l&&(e=function(e,t=-1,l=!0){let a=!1;if(l){let t=e.map(e=>e.type).join(""),l=/[hstv]/gi.test(t);if(a=/[astvqmhlc]/g.test(t),!l)return e}let n=[],s={type:"M",values:(e=l&&a?W(e,t):e)[0].values};n.push(s);for(let l=1,a=e.length;l<a;l++){let a,r,i,u,p,h,y,o,c=e[l],{type:x,values:f}=c,g=f.length,v=s.values,d=v.length,[m,M]=[f[g-2],f[g-1]],[b,A]=[v[d-2],v[d-1]];switch(x){case"H":s={type:"L",values:[f[0],A]};break;case"V":s={type:"L",values:[b,f[0]]};break;case"T":[a,r]=[v[0],v[1]],[b,A]=[v[d-2],v[d-1]],i=b+(b-a),u=A+(A-r),s={type:"Q",values:[i,u,m,M]};break;case"S":[a,r]=[v[0],v[1]],[b,A]=[v[d-2],v[d-1]],[y,o]=d>2&&"A"!==s.type?[v[2],v[3]]:[b,A],i=2*b-y,u=2*A-o,p=f[0],h=f[1],s={type:"C",values:[i,u,p,h,m,M]};break;default:s={type:x,values:f}}t>-1&&(s.values=s.values.map(e=>+e.toFixed(t))),n.push(s)}return n}(e,-1,!1)),p&&n&&(e=function(e,{arcAccuracy:t=1}={}){let l=[e[0]];for(let a=1,n=e.length;a<n;a++){let n=e[a],s=e[a-1].values,r=s.length,i={x:s[r-2],y:s[r-1]};"A"===n.type?X(i,n.values,t).forEach(e=>{l.push(e)}):l.push(n)}return l}(e,s)),u&&a&&(e=function(e){let t=[e[0]];for(let l=1,a=e.length;l<a;l++){let a=e[l],n=e[l-1].values,s=n.length,r={x:n[s-2],y:n[s-1]};"Q"===a.type?t.push(J(r,a.values)):t.push(a)}return t}(e)),e}function _(e,{toAbsolute:t=!0,toLonghands:l=!0,quadraticToCubic:a=!1,arcToCubic:n=!1,arcAccuracy:s=4}={}){let r=function(e,t=!0){if(e=e.trim(),""===e)return{pathData:[],hasRelatives:!1,hasShorthands:!1,hasQuadratics:!1,hasArcs:!1};const l=new Set([5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279]),a=e=>32===e||44===e||10===e||13===e||8232===e||8233===e||9===e||11===e||12===e||160===e||e>=5760&&l.has(e);let n,s=0,r=e.length,i="",u=[],p=-1,h="",y=!1,o=0,c=0,x=0,f=!1,g=new Set([]),v=[];const d=()=>{f&&("M"===i?i="L":"m"===i&&(i="l"),u.push({type:i,values:[]}),p++,c=0,f=!1)},m=(e=!1)=>{(e?o>0:""!==h)&&(t&&-1===p&&(n="Pathdata must start with M command",v.push(n),i="M",u.push({type:i,values:[]}),x=2,c=0,p++),"A"===i||"a"===i?(h=M(),u[p].values.push(...h)):(t&&h[1]&&"."!==h[1]&&"0"===h[0]&&(n=`${p}. command: Leading zeros not valid: ${h}`,v.push(n)),u[p].values.push(+h)),c++,h="",o=0,f=c>=x)},M=()=>{let e=h.length,t=!1;return 3===c&&2===e||4===c&&e>1?(h=[+h[0],+h[1]],t=!0,c++):3===c&&e>=3&&(h=[+h[0],+h[1],+h.substring(2)],t=!0,c+=2),t?h:[+h]},b=()=>{if(p>0){let e=u[p].values.length;if(e&&e<x||e&&e>x||("z"===i||"Z"===i)&&e>0){n=`${p}. command of type "${i}": ${x-e} values too few - ${x} expected`,v[v.length-1]!==n&&v.push(n)}}};let A=!1,C=!1,w=!1;for(;s<r;){let l=e.charCodeAt(s),r=l>47&&l<58;if(r||(A=101===l||69===l,C=45===l||43===l,w=46===l),r||C||w||A){if(y||45!==l&&46!==l)d();else{let e=46===l;m(e),d(),e&&o++}h+=e[s],y=A,s++}else if((l<48||l>5759)&&a(l))m(),s++;else{if(l>64){if(!ee.has(l)){n=`${p}. command "${e[s]}" is not a valid type`,v.push(n),s++;continue}""!==h&&(u[p].values.push(+h),c++,h=""),t&&b(),i=e[s],x=te[l];let a="M"===i||"m"===i,r=p>0&&("z"===u[p].type||"Z"===u[p].type);g.add(i),r&&!a&&(u.push({type:"m",values:[0,0]}),p++),u.push({type:i,values:[]}),p++,o=0,c=0,f=!1,s++;continue}r||(n=`${p}. ${e[s]} is not a valid separarator or token`,v.push(n),h=""),s++}}m(),t&&b();if(t&&v.length){if(n="Invalid path data:\n"+v.join("\n"),"log"!==t)throw new Error(n);console.log(n)}u[0].type="M";let P=Array.from(g).join(""),S=/[lcqamts]/g.test(P),L=/[vhst]/gi.test(P),I=/[a]/gi.test(P),k=/[qt]/gi.test(P);return{pathData:u,hasRelatives:S,hasShorthands:L,hasQuadratics:k,hasArcs:I}}(e),{hasRelatives:i,hasShorthands:u,hasQuadratics:p,hasArcs:h}=r,y=r.pathData;return y=K(y,{toAbsolute:t,toLonghands:l,quadraticToCubic:a,arcToCubic:n,arcAccuracy:s},{hasRelatives:i,hasShorthands:u,hasQuadratics:p,hasArcs:h}),y}const ee=new Set([77,109,65,97,67,99,76,108,81,113,83,115,84,116,72,104,86,118,90,122]),te=new Uint8Array(128);function le(e,t=1,l=!0){let a=[e[0]],n={x:e[0].values[0],y:e[0].values[1]},s=n,r=n;e[e.length-1].type.toLowerCase();for(let i=1,u=e.length;i<u;i++){let p=e[i-1],h=e[i],y=e[i+1]||e[u-1],o="z"===y.type.toLowerCase()?n:{x:y.values[y.values.length-2],y:y.values[y.values.length-1]},{type:c,values:x}=h,f=x.slice(-2);r="Z"!==c?{x:f[0],y:f[1]}:n;let g=O([s,r,o],!0)<A(s,o)/100*t,v=!1;if(l||"C"!==c||(g=!1),l&&("C"===c||"Q"===c)){v=k(s,"C"===c?[{x:x[0],y:x[1]},{x:x[2],y:x[3]}]:"Q"===c?[{x:x[0],y:x[1]}]:[],r),v&&i<u-1&&"C"!==p.type&&(c="L",h.type="L",h.values=f)}s=r,g&&i<u-1&&("L"===c||l&&v)||("M"===c?(n=r,s=n):"Z"===c&&(s=n),a.push(h))}return a}function ae(e){let t={x:e[0].values[0],y:e[0].values[1]},l=t,a=[e[0]];for(let n=1,s=e.length;n<s;n++){let s=e[n],{type:r,values:i}=s,u=i.slice(-2);l={x:u[0],y:u[1]},"L"===r&&l.x===t.x&&l.y===t.y||(a.push(s),t=l)}return a}function ne(e){let t=e.length;if(!("z"===e[t-1].type.toLowerCase()))return e;let l=0,a=[];for(let l=0;l<t;l++){let t=e[l],{type:n,values:s}=t,r=s.length;if(r){let e={type:n,x:s[r-2],y:s[r-1],index:0};e.index=l,a.push(e)}}return a=a.sort((e,t)=>+e.y.toFixed(3)-+t.y.toFixed(3)||e.x-t.x),l=a[0].index,l?function(e,t){let l=e.length,a=0,n=e[l-1].type,s="z"===n.toLowerCase();if(!s||t<1||e.length<3)return e;let r=s?1:0;(function(e){let t=e.length,l="z"===e[t-1].type.toLowerCase(),a=e[0],[n,s]=[a.values[0],a.values[1]].map(e=>+e.toFixed(8)),r=l?e[t-2]:e[t-1],i=r.values.length,[u,p]=[r.values[i-2],r.values[i-1]].map(e=>+e.toFixed(8));!l||n==u&&s==p||(e.pop(),e.push({type:"L",values:[n,s]},{type:"Z",values:[]}))})(e),a=t+1<e.length-1?t+1:e.length-1-r;let i=e.slice(a),u=e.slice(0,a);u.shift();let p,h,y=u.length;p=u[y-1].values||[],h=[p[p.length-2],p[p.length-1]],r&&(i.pop(),u.push({type:"Z",values:[]}));return e=[{type:"M",values:h},...i,...u],e}(e,l):e}function se(e,{arcToCubic:t=!1,quadraticToCubic:l=!1,toClockwise:a=!1,returnD:n=!1}={}){const s=(e,t)=>{let l=[],a=[];if("A"!==e){for(let e=0;e<t.length;e+=2)l.push([t[e],t[e+1]]);a=l.pop(),l.reverse()}else{let e=0==t[4]?1:0;l=[t[0],t[1],t[2],t[3],e],a=[t[5],t[6]]}return{controlPoints:l,endPoints:a}};let r=[],i="z"===e[e.length-1].type.toLowerCase();i&&(e=(e=>{let t="z"===e[e.length-1].type.toLowerCase(),l=e[0],[a,n]=[l.values[0],l.values[1]],s=t?e[e.length-2]:e[e.length-1],[r,i]=[s.values[s.values.length-2],s.values[s.values.length-1]];return!t||a==r&&n==i||(e.pop(),e.push({type:"L",values:[a,n]},{type:"Z",values:[]})),e})(e),e.pop());let u=e[e.length-1].values,p=u.length,h=i?e[0]:{type:"M",values:[u[p-2],u[p-1]]};r.push(h),e.reverse();for(let t=1;t<e.length;t++){let l=e[t],a=l.type,n=l.values,i=e[t-1],u=i.type,p=[];p=[s(u,i.values).controlPoints,s(a,n).endPoints].flat(),r.push({type:u,values:p.flat()})}return i&&r.push({type:"z",values:[]}),r}function re(e,{returnDom:t=!1,removeHidden:l=!0,removeUnused:a=!0}={}){e=(e=e.replace(/<\?xml[\s\S]*?\?>/gi,"").replace(/<!DOCTYPE[\s\S]*?>/gi,"").replace(/<!--[\s\S]*?-->/g,"").trim()).replaceAll("xlink:href=","href=");let n=(new DOMParser).parseFromString(e,"text/html").querySelector("svg");!function(e,t=["viewBox","xmlns","width","height","id","class"]){[...e.attributes].map(e=>e.name).forEach(l=>{t.includes(l)||e.removeAttribute(l)})}(n,["viewBox","xmlns","width","height","id","class"]);let s=["metadata","script"];if(n.querySelectorAll("*").forEach(e=>{let t=e.nodeName,a=e.getAttribute("style")||"",n=!!a&&a.trim().includes("display:none"),r=e.getAttribute("display")&&"none"===e.getAttribute("display")||n;t.includes(":")||s.includes(t)||l&&r?e.remove():function(e){let t=[...e.attributes].map(e=>e.name);t.forEach(t=>{t.includes(":")&&e.removeAttribute(t)})}(e)}),t)return n;let r=function(e){let t=(new XMLSerializer).serializeToString(e);return t=t.replace(/\t/g,"").replace(/[\n\r|]/g,"\n").replace(/\n\s*\n/g,"\n").replace(/ +/g," "),t}(n);return console.log(r),r}function ie(e="",{toAbsolute:t=!0,toRelative:l=!0,toShorthands:a=!0,decimals:n=3,quadraticToCubic:s=!0,arcToCubic:r=!1,cubicToArc:i=!1,arcAccuracy:u=4,keepExtremes:p=!0,keepCorners:h=!0,keepInflections:y=!0,extrapolateDominant:o=!1,addExtremes:c=!1,optimizeOrder:x=!0,removeColinear:f=!0,simplifyBezier:g=!0,autoAccuracy:v=!0,flatBezierToLinetos:d=!0,revertToQuadratics:m=!0,minifyD:M=0,tolerance:b=1,reverse:A=!1,removeHidden:C=!0,removeUnused:w=!0,getObject:P=!1}={}){b=Math.max(.1,b);let S=function(e){let t="string";if(e instanceof HTMLImageElement)return"img";if(e instanceof SVGElement)return"svg";if(e instanceof HTMLCanvasElement)return"canvas";if(e instanceof File)return"file";if(e instanceof ArrayBuffer)return"buffer";if(e instanceof Blob)return"blob";if(Array.isArray(e))return"array";if("string"==typeof e){let l=(e=e.trim()).includes("<svg")&&e.includes("</svg"),a=e.startsWith("M")||e.startsWith("m"),n=!isNaN(e.substring(0,1))&&!isNaN(e.substring(e.length-1,e.length));if(l)t="svgMarkup";else if(a)t="pathDataString";else if(n)t="polyString";else{let l=/^(file:|https?:\/\/|\/|\.\/|\.\.\/)/.test(e),a=e.startsWith("data:image");t=l||a?"url":"string"}return t}return t=typeof e,(e.constructor.name||t).toLowerCase()}(e),L="",I=0,k=0,E=0,T={},F="",q="svgMarkup"===S?1:0,D=[];if(I=new Blob([e]).size,q){L=re(e,{returnDom:!0,removeHidden:C,removeUnused:w}),L.querySelectorAll("path").forEach(e=>{D.push({d:e.getAttribute("d"),el:e})})}else"pathDataString"===S?F=e:"polyString"===S&&(F="M"+e),D.push({d:F,el:null});return D.forEach(e=>{let{d:u,el:C}=e,w=_(u,{quadraticToCubic:s,toAbsolute:t,arcToCubic:r}),P=JSON.parse(JSON.stringify(w)),S=w.length,L=z(P),T=[];for(let e=0,t=L.length;e<t;e++){let t=L[e];A&&(t=se(t)),f&&(t=ae(t)),c&&(t=Q(t,0,1)),x&&(t=ne(t)),f&&(t=le(t,b,d));let l=H(t),{pathData:a,bb:n,dimA:s}=l;if(a=g?ue(a,{simplifyBezier:g,keepInflections:y,keepExtremes:p,keepCorners:h,extrapolateDominant:o,revertToQuadratics:m,tolerance:b,reverse:A}):a,i){let e=3;a.forEach((t,l)=>{let{type:n,values:s,p0:r,cp1:i=null,cp2:u=null,p:p=null}=t;if("C"===n){let t=G(r,i,u,p,e);t.isArc&&(a[l]=t.com)}}),a=Y(a)}m&&a.forEach((e,t)=>{let{type:l,values:n,p0:s,cp1:r=null,cp2:i=null,p:u=null}=e;if("C"===l){let e=Z(s,r,i,u);"Q"===e.type&&(a[t]=e)}}),T.push(a)}P=T.flat(),v&&(n=function(e){let t={x:e[0].values[0],y:e[0].values[1]},l=t,a=t;e[0].decimals=0;let n=new Set;for(let s=0,r=e.length;s<r;s++){let r=e[s],{type:i,values:u}=r,p=u.length?u.slice(-2):[t.x,t.y];a={x:p[0],y:p[1]};let h=r.dimA?+r.dimA.toFixed(8):"M"!==i?+$(l,a).toFixed(8):0;h&&n.add(h),"M"===i&&(t=a),l=a}let s=Array.from(n).sort(),r=Math.ceil(s.length/8);s=s.slice(0,r);let i=s.reduce((e,t)=>e+t,0)/r,u=i>50?0:Math.floor(50/i).toString().length;return Math.min(Math.max(0,u),8)}(P)),P=R(P,{toRelative:l,toShorthands:a,decimals:n});let F=[];P.forEach((e,t)=>{let{type:l,values:a}=e;if("l"===l||"v"===l||"h"===l){("l"===l?"00"!==a.join(""):0!==a[0])&&F.push(e)}else F.push(e)}),P=F;let q=P.length,D=j(P,M);k=new Blob([D]).size,E=+(100/I*k).toFixed(2),e.d=D,e.report={original:S,new:q,saved:S-q,compression:E,decimals:n},C&&C.setAttribute("d",D)}),q?(L=(new XMLSerializer).serializeToString(L),k=new Blob([L]).size,E=+(100/I*k).toFixed(2),I=+(I/1024).toFixed(3),k=+(k/1024).toFixed(3),T={svgSize:I,svgSizeOpt:k,compression:E}):({d:F,report:T}=D[0]),P?{svg:L,d:F,report:T,inputType:S,mode:q}:F||L}function ue(e,{keepExtremes:t=!0,keepInflections:l=!0,keepCorners:a=!0,extrapolateDominant:n=!0,tolerance:s=1,reverse:r=!1}={}){let i=[e[0]];for(let r=2,u=e.length;u&&r<=u;r++){let p=e[r-1],h=r<u?e[r]:null,y=h?.type||null,o=p?.directionChange||null,c=h?.directionChange||null,{type:x,values:f,p0:g,p:v,cp1:d=null,cp2:m=null,extreme:M=!1,corner:b=!1,dimA:A=0}=p;if("C"===x&&"C"===y)if(l&&c||a&&b||!o&&t&&M)i.push(p);else{let y=N(p,h,n,s),o=0;if(1===y.length){p=y[0];let h=1;o+=p.error;for(let i=r+1;o<s&&i<u;i++){let r=e[i];if("C"!==r.type||l&&r.directionChange||a&&p.corner||t&&p.extreme)break;let u=N(p,r,n,s);1===u.length&&h++,p=u[0]}i.push(p),r<u&&(r+=h)}else i.push(p)}else i.push(p)}return r&&(i=se(i)),i}function pe(e=null,t=!1){if(!e)return{x:0,y:0,width:300,height:150};let l=window.getComputedStyle(e),a=e.hasAttribute("width")?e.width.baseVal.value:parseFloat(l.width)||300,n=e.hasAttribute("height")?e.height.baseVal.value:parseFloat(l.height)||150,s=e.getAttribute("viewBox")?e.viewBox.baseVal:{x:0,y:0,width:a,height:n},{x:r,y:i,width:u,height:p}=s;if(s={x:r,y:i,width:u,height:p},t)for(let e in s)s[e]=Math.ceil(s[e]);return s}te[77]=2,te[109]=2,te[65]=7,te[97]=7,te[67]=6,te[99]=6,te[76]=2,te[108]=2,te[81]=4,te[113]=4,te[83]=4,te[115]=4,te[84]=2,te[116]=2,te[72]=1,te[104]=1,te[86]=1,te[118]=1,te[90]=0,te[122]=0;const{abs:he,acos:ye,asin:oe,atan:ce,atan2:xe,ceil:fe,cos:ge,exp:ve,floor:de,log:me,hypot:Me,max:be,min:Ae,pow:Ce,random:we,round:Pe,sin:Se,sqrt:Le,tan:Ie,PI:ke}=Math;"undefined"!=typeof window&&(window.svgPathSimplify=ie,window.getViewBox=pe,window.renderPoint=function(e,t,l="red",a="1%",n="1",s="",r=!0,i="",u=""){Array.isArray(t)&&(t={x:t[0],y:t[1]});let p=`<circle class="${u}" opacity="${n}" id="${i}" cx="${t.x}" cy="${t.y}" r="${a}" fill="${l}">\n <title>${s}</title></circle>`;if(!r)return p;e.insertAdjacentHTML("beforeend",p)});export{ke as PI,he as abs,ye as acos,oe as asin,ce as atan,xe as atan2,fe as ceil,ge as cos,ve as exp,de as floor,pe as getViewBox,Me as hypot,me as log,be as max,Ae as min,Ce as pow,we as random,Pe as round,Se as sin,Le as sqrt,ie as svgPathSimplify,Ie as tan};
1
+ const{abs:e,acos:t,asin:l,atan:a,atan2:n,ceil:s,cos:r,exp:i,floor:u,log:p,max:y,min:h,pow:o,random:c,round:x,sin:f,sqrt:g,tan:v,PI:d}=Math;function m(e,t,l=!1){let a=n(t.y-e.y,t.x-e.x);return l&&a<0&&(a+=2*Math.PI),a}function M(e,t,l,a,n=!0){let s,r,i,u,p,y={};try{if(s=(a.y-l.y)*(t.x-e.x)-(a.x-l.x)*(t.y-e.y),0==s)return!1}catch{console.log("!catch",e,t,"p3:",l,a)}r=e.y-l.y,i=e.x-l.x,u=(a.x-l.x)*r-(a.y-l.y)*i,p=(t.x-e.x)*r-(t.y-e.y)*i,r=u/s,i=p/s,y={x:e.x+r*(t.x-e.x),y:e.y+r*(t.y-e.y)};let h=!1;return r>0&&r<1&&i>0&&i<1&&(h=!0),!(n&&!h)&&y}function b(e,t){return g((t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y))}function C(e,t){return(t.x-e.x)**2+(t.y-e.y)**2}function A(e,t,l,a=!1){let n={x:(t.x-e.x)*l+e.x,y:(t.y-e.y)*l+e.y};return a&&(n.angle=m(e,t),n.angle<0&&(n.angle+=2*d)),n}function w(e,t=.5,l=!1,a=!1){let n;return n=e.length>2?((e,t,l=!1)=>{let n=4===e.length,s=e[0],r=e[1],i=n?e[2]:e[1],u=e[e.length-1],p={x:0,y:0};if(l||a){let e,l,y,h,o,c=s.x===r.x&&s.y===r.y,x=u.x===i.x&&u.y===i.y;0!==t||c?1!==t||x?(c&&(t+=1e-7),x&&(t-=1e-7),e=A(s,r,t),n?(l=A(r,i,t),y=A(i,u,t),h=A(e,l,t),o=A(l,y,t),p=A(h,o,t),p.angle=m(h,o),a&&(p.cpts=[l,y,h,o])):(l=A(s,r,t),y=A(r,u,t),p=A(l,y,t),p.angle=m(l,y),a&&(p.cpts=[l,y]))):(p.x=u.x,p.y=u.y,p.angle=m(i,u)):(p.x=s.x,p.y=s.y,p.angle=m(s,r))}else{let e=1-t;p=n?{x:e**3*s.x+3*e**2*t*r.x+3*e*t**2*i.x+t**3*u.x,y:e**3*s.y+3*e**2*t*r.y+3*e*t**2*i.y+t**3*u.y}:{x:e*e*s.x+2*e*t*r.x+t**2*u.x,y:e*e*s.y+2*e*t*r.y+t**2*u.y}}return p})(e,t,l):A(e[0],e[1],t,l),l&&n.angle<0&&(n.angle+=2*d),n}function L(e,t,l,n,s,i=0,u=!0,p=!1){if(s=p?s*d/180:s,i=p?i*d/180:i,i=l!==n&&i!==2*d?i:0,u&&l!==n){let e=a(v(s=i?s-i:s)*(l/n));s=r(s)<0?e+d:e}let y=e+l*r(s),h=t+n*f(s),o={x:y,y:h};return i&&(o.x=e+(y-e)*r(i)-(h-t)*f(i),o.y=t+(y-e)*f(i)+(h-t)*r(i)),o}function P(e,t=[],l=.05){let a=3===t.length,n=t[0]||null,s=a?t[1]:null,r=a?t[2]:t[1],i=.5*Math.PI,u=!1,p=!1,y=n?m(r,n,!0):null;if(u=Math.abs(y%i)<l||Math.abs(y%i-i)<l,a){let e=s?m(s,r,!0):0;p=Math.abs(e%i)<=l||Math.abs(e%i-i)<=l}return u||p}function S(e){return 4===e.length?function(e,t,l,a){let[n,s,r,i,u,p,y,h]=[e.x,e.y,t.x,t.y,l.x,l.y,a.x,a.y],o=Math.min(e.y,a.y),c=Math.min(e.x,a.x),x=Math.max(e.x,a.x),f=Math.max(e.y,a.y);if(t.y>=o&&t.y<=f&&l.y>=o&&l.y<=f&&t.x>=c&&t.x<=x&&l.x>=c&&l.x<=x)return[];let g,v,d,m,M,b,C,A,w=[];for(let e=0;e<2;++e)if(0==e?(v=6*n-12*r+6*u,g=-3*n+9*r-9*u+3*y,d=3*r-3*n):(v=6*s-12*i+6*p,g=-3*s+9*i-9*p+3*h,d=3*i-3*s),Math.abs(g)<1e-12){if(Math.abs(v)<1e-12)continue;m=-d/v,0<m&&m<1&&w.push(m)}else C=v*v-4*d*g,C<0?Math.abs(C)<1e-12&&(m=-v/(2*g),0<m&&m<1&&w.push(m)):(A=Math.sqrt(C),M=(-v+A)/(2*g),0<M&&M<1&&w.push(M),b=(-v-A)/(2*g),0<b&&b<1&&w.push(b));let L=w.length;for(;L--;)m=w[L];return w}(e[0],e[1],e[2],e[3]):function(e,t,l){let a,n,s,r=Math.min(e.y,l.y),i=Math.min(e.x,l.x),u=Math.max(e.x,l.x),p=Math.max(e.y,l.y);if(t.y>=r&&t.y<=p&&t.x>=i&&t.x<=u)return[];let[y,h,o,c,x,f]=[e.x,e.y,t.x,t.y,l.x,l.y],g=[];for(let e=0;e<2;++e)a=0==e?y-2*o+x:h-2*c+f,n=0==e?-2*y+2*o:-2*h+2*c,Math.abs(a)>1e-12&&(s=-n/(2*a),s>0&&s<1&&g.push(s));return g}(e[0],e[1],e[2])}function F(e,t=.025){let l=e[0],a=e[e.length-1],n=e.map(e=>e.x),s=e.map(e=>e.y),r=Math.min(...n),i=Math.max(...n),u=Math.min(...s),p=i-r,y=Math.max(...s)-u;if(e.length<3||0===p||0===y)return{area:0,flat:!0,thresh:1e-4,ratio:0};let h=C(l,a),o=C(l,e[0]),c=(o+(e.length>3?C(a,e[1]):o))/2;let x=.5*(p+y)*.5,f=0;for(let t=0,l=e.length;t<l;t++){f+=e[t].x*e[t===e.length-1?0:t+1].y*.5-e[t===e.length-1?0:t+1].x*e[t].y*.5}f=+Math.abs(f).toFixed(9);return{area:f,flat:0===f||f<c/1e3,thresh:x,ratio:f/c,squareDist:h,areaThresh:h/1e3}}function I(e,t,l){let a=!1,n=2===t.length,s=t[0],r=n?t[1]:s;if(e.x===s.x&&e.y===s.y&&l.x===r.x&&l.y===r.y)return!0;let i=s.x-e.x,u=s.y-e.y,p=l.x-r.x,y=l.y-r.y,h=Math.abs(i*y-u*p);if(!h)return!0;let o=l.x-e.x,c=l.y-e.y,x=Math.abs(o*u-c*i);return!x||(x/h<1.1&&(a=!0),a)}function k(e,t){return(Math.abs(t.x-e.x)+Math.abs(t.y-e.y))/2}function $(e){let t=[];try{e.map((e,t)=>"m"===e.type.toLowerCase()?t:-1).filter(e=>-1!==e)}catch{console.log("catch",e)}let l=e.map((e,t)=>"m"===e.type.toLowerCase()?t:-1).filter(e=>-1!==e);return 1===l.length?[e]:(l.forEach((a,n)=>{t.push(e.slice(a,l[n+1]))}),t)}function z(e,t){let l,a,n,s,r,i,u=[],p=[],y=e[0],h=e[1],o=e[e.length-2],c=e[e.length-1];return 4===e.length?(l=w([y,h],t),a=w([h,o],t),n=w([o,c],t),s=w([l,a],t),r=w([a,n],t),i=w([s,r],t),u.push({x:y.x,y:y.y},{x:l.x,y:l.y},{x:s.x,y:s.y},{x:i.x,y:i.y}),p.push({x:i.x,y:i.y},{x:r.x,y:r.y},{x:n.x,y:n.y},{x:c.x,y:c.y})):3===e.length?(a=w([y,h],t),n=w([h,c],t),i=w([a,n],t),u.push({x:y.x,y:y.y},{x:a.x,y:a.y},{x:i.x,y:i.y}),p.push({x:i.x,y:i.y},{x:n.x,y:n.y},{x:c.x,y:c.y})):2===e.length&&(a=w([y,c],t),u.push({x:y.x,y:y.y},{x:a.x,y:a.y}),p.push({x:a.x,y:a.y},{x:c.x,y:c.y})),[u,p]}function E(e,t,l=0,a=1){let n=[],s=6===t.length?"C":"Q",r={x:t[0],y:t[1]},i="C"===s?{x:t[2],y:t[3]}:r,u={x:t[4],y:t[5]},p=Math.max(u.x,e.x),y=Math.min(u.x,e.x),h=Math.max(u.y,e.y),o=Math.min(u.y,e.y),c=0;if(r.x<y||r.x>p||r.y<o||r.y>h||i.x<y||i.x>p||i.y<o||i.y>h){let p=S("C"===s?[e,r,i,u]:[e,r,u]).sort();if(p=p.filter(e=>e>l&&e<a),p.length){let l=function(e,t,l,a=!0){let n=[];if(!l.length)return!1;let s,r,i,u=t.length,p={x:t[u-2],y:t[u-1]};2===t.length?i=[e,p]:4===t.length?(s={x:t[0],y:t[1]},i=[e,s,p]):6===t.length&&(s={x:t[0],y:t[1]},r={x:t[2],y:t[3]},i=[e,s,r,p]);if(l.length)if(1===l.length){let e=z(i,l[0]),t=e[0],a=e[1];n.push(t,a)}else{let e=l[0],t=z(i,e),a=t[0];n.push(a),i=t[1];for(let t=1;t<l.length;t++){e=l[t-1];let a=z(i,(l[t]-e)/(1-e));n.push(a[0]),t===l.length-1&&n.push(a[a.length-1]),i=a[1]}}if(a){let e,t,l=[];return n.forEach(a=>{e={type:"",values:[]},a.shift(),t=a.map(e=>Object.values(e)).flat(),e.values=t,3===a.length?e.type="C":2===a.length?e.type="Q":1===a.length&&(e.type="L"),l.push(e)}),l}return n}(e,t,p);n.push(...l),c+=l.length}else n.push({type:s,values:t})}else n.push({type:s,values:t});return{pathData:n,count:c}}function T(e,t=0,l=1){let a=[e[0]],n={x:e[0].values[0],y:e[0].values[1]},s={x:e[0].values[0],y:e[0].values[1]},r=e.length;for(let i=1;r&&i<r;i++){let r=e[i],{type:u,values:p}=r,y=p.slice(-2);if(y[0],y[1],"C"!==u&&"Q"!==u)a.push(r);else if("C"===u||"Q"===u){let e=E(n,p,t,l).pathData;a.push(...e)}n={x:y[0],y:y[1]},"z"===u.toLowerCase()?n=s:"M"===u&&(s={x:y[0],y:y[1]})}return a}function Q(e,t=-1){let l=e.map(e=>e.x),a=e.map(e=>e.y),n=Math.min(...l),s=Math.max(...l),r=Math.min(...a),i=Math.max(...a),u={x:n,left:n,right:s,y:r,top:r,bottom:i,width:s-n,height:i-r};if(t>-1)for(let e in u)u[e]=+u[e].toFixed(t);return u}function q(e){let t=[];return e.forEach(e=>{let l=function(e){let t=function(e){let t=[];for(let l=0;l<e.length;l++){let a=e[l],n=l>0?e[l-1]:e[l],{type:s,values:r}=a,i={x:n.values[n.values.length-2],y:n.values[n.values.length-1]},u=r.length?{x:r[r.length-2],y:r[r.length-1]}:"",p=r.length?{x:r[0],y:r[1]}:"";switch(s){case"A":if("function"!=typeof arcToBezier){let e=b(i,u)/2,l=A(i,u,.5),a=L(l.x,l.y,e,e,0),n=L(l.x,l.y,e,e,Math.PI);t.push(a,n,u);break}arcToBezier(i,r).forEach(e=>{let l=e.values,a={x:l[0],y:l[1]},n={x:l[2],y:l[3]},s={x:l[4],y:l[5]};t.push(a,n,s)});break;case"C":let e={x:r[2],y:r[3]};t.push(p,e);break;case"Q":t.push(p)}"z"!==s.toLowerCase()&&t.push(u)}return t}(e),l=Q(t);return l}(e);t.push(l)}),t}function D(e,t){let[l,a,n,s,r,i]=[e.x,e.y,e.width,e.height,e.x+e.width,e.y+e.height],[u,p,y,h,o,c]=[t.x,t.y,t.width,t.height,t.x+t.width,t.y+t.height],x=!1;return n*s!=y*h&&n*s>y*h&&l<u&&r>o&&a<p&&i>c&&(x=!0),x}function B(t,l=9){let a=0,s=[],i=$(t),u=i.length>1,p=[];if(u){let e=q(i);e.forEach(function(t,l){for(let l=0;l<e.length;l++){let a=e[l];if(t!=a){D(t,a)&&p.push(l)}}})}return i.forEach((t,l)=>{s=[];let i=0,u=0,y=1,h=[];t.forEach(function(l,a){let[u,p]=[l.type,l.values],y=p.length;if(p.length){let o=(a>0?t[a-1]:t[0]).values,c=o.length,x={x:o[c-2],y:o[c-1]},v={x:p[y-2],y:p[y-1]};if("C"===u||"Q"===u){let e={x:p[0],y:p[1]};h="C"===u?[x,e,{x:p[2],y:p[3]},v]:[x,e,v];let t=Math.abs(function(e,t=!1){let l,[a,n,s,r]=[e[0],e[1],e[2],e[e.length-1]];if(e.length<3)return 0;3===e.length&&(n={x:1*e[0].x/3+2*e[1].x/3,y:1*e[0].y/3+2*e[1].y/3},s={x:1*e[2].x/3+2*e[1].x/3,y:1*e[2].y/3+2*e[1].y/3});return l=3*(a.x*(-2*n.y-s.y+3*r.y)+n.x*(2*a.y-s.y-r.y)+s.x*(a.y+n.y-2*r.y)+r.x*(-3*a.y+n.y+2*s.y))/20,t?Math.abs(l):l}(h));i+=t,s.push(x,v)}else if("A"===u){let t=function(t,l,a,s,i,u,p,y,h){const o=(e,t,l,a)=>n(a-t,l-e);let c={cx:0,cy:0,rx:a=e(a),ry:s=e(s),startAngle:0,endAngle:0,deltaAngle:0,clockwise:p,xAxisRotation:i,largeArc:u,sweep:p};if(0==a||0==s)throw Error("rx and ry can not be 0");if(a===s){let e=Math.abs(y-t),a=Math.abs(h-l),n=e,s=Math.min(t,y),r=Math.min(l,h),i=.5*Math.PI;if(0===e&&a||0===a&&e)return n=0===e&&a?a/2:e/2,c.rx=n,c.ry=n,0===e&&a?(c.cx=t,c.cy=r+a/2,c.startAngle=l>h?i:-i,c.endAngle=l>h?-i:i,c.deltaAngle=p?Math.PI:-Math.PI):0===a&&e&&(c.cx=s+e/2,c.cy=l,c.startAngle=t>y?Math.PI:0,c.endAngle=t>y?-Math.PI:Math.PI,c.deltaAngle=p?Math.PI:-Math.PI),c}let x,v,m=a===s?0:i*d/180,M=m?f(m):0,b=m?r(m):1,C=(t-y)/2,A=(l-h)/2,w=(t+y)/2,L=(l+h)/2,P=m?b*C+M*A:C,S=m?b*A-M*C:A,F=P*P/(a*a)+S*S/(s*s);F>1&&(a*=g(F),s*=g(F),c.rx=a,c.ry=s);let I=a*s,k=a*S,$=s*P,z=k**2+$**2;if(!z)throw Error("start point can not be same as end point");let E=g(e((I*I-z)/z));u==p&&(E=-E);let T=E*k/s,Q=-E*$/a;x=m?b*T-M*Q+w:w+T,v=m?M*T+b*Q+L:L+Q,c.cy=v,c.cx=x;let q=o(x,v,t,l),D=o(x,v,y,h);!p&&D>q&&(D-=2*Math.PI),p&&q>D&&(D=D<=0?D+2*Math.PI:D);let B=D-q;return c.startAngle=q,c.endAngle=D,c.deltaAngle=B,c}(x.x,x.y,l.values[0],l.values[1],l.values[2],l.values[3],l.values[4],v.x,v.y),{cx:a,cy:u,rx:p,ry:y,startAngle:h,endAngle:o,deltaAngle:c}=t,m=Math.abs(function(e,t,l,a){const n=Math.PI*e*t;let s=(a-l+2*Math.PI)%(2*Math.PI);if(e===t)return n*(s/(2*Math.PI));const r=l=>Math.atan2(e*Math.sin(l),t*Math.cos(l));return l=r(l),a=r(a),s=(a-l+2*Math.PI)%(2*Math.PI),n*(s/(2*Math.PI))}(p,y,h,o));m-=Math.abs(O([x,{x:a,y:u},v])),s.push(x,v),i+=m}else s.push(x,v)}});let o=O(s);-1!==p.indexOf(l)&&(y=-1),u=o<0&&i<0?(Math.abs(i)-Math.abs(o))*y:(Math.abs(i)+Math.abs(o))*y,a+=u}),a}function O(e,t=!1){let l=0;for(let t=0,a=e.length;a&&t<a;t++){l+=e[t].x*e[t===e.length-1?0:t+1].y*.5-e[t===e.length-1?0:t+1].x*e[t].y*.5}return t&&(l=Math.abs(l)),l}function j(e,t=0){t=parseFloat(t);let l=e.length,a=t>1,n=!a&&!t,s="",r=a?"\n":n?"":" ",i=n?"":" ";s=`${e[0].type}${i}${e[0].values.join(" ")}${r}`;for(let t=1;t<l;t++){let l=e[t-1],a=e[t],{type:u,values:p}=a;if(!n||"A"!==u&&"a"!==u||(p=[p[0],p[1],p[2],`${p[3]}${p[4]}${p[5]}`,p[6]]),u=l.type===a.type&&"m"!==a.type.toLowerCase()&&n||"M"===l.type&&"L"===a.type&&n?" ":a.type,n){let e="",t=!1;for(let l=0,a=p.length;l<a;l++){let a=p[l],n=a.toString(),s=n.includes(".")&&Math.abs(a)<1;s&&t&&(n=n.replace(/^0\./,".")),!(l>0)||t&&s||(e+=" "),e+=n,t=s}s+=`${u}${i}${e}${r}`}else s+=`${u}${i}${p.join(" ")}${r}`}return n&&(s=s.replace(/ 0\./g," .").replace(/ -/g,"-").replace(/-0\./g,"-.").replace(/Z/g,"z")),s}function N(e,t,l=!1,a=1){let n=[e,t],s=function(e,t){let l=M(e.p0,e.cp1,t.cp2,t.p,!1),a=M(l,t.p,t.p0,t.cp1,!1),n=b(l,t.p),s=b(a,t.p),r=1-s/n,i=b(e.cp2,e.p),u=b(e.cp2,t.cp1);return r=Math.min(i)/u,r}(e,t),r=k(e.p0,e.p),i=k(t.p0,t.p),u=.05*Math.min(r,i)*a,p=function(e,t,l=0,a=0){let{p0:n,cp1:s}=e,{p:r,cp2:i}=t,u={x:(s.x-(1-l)*n.x)/l,y:(s.y-(1-l)*n.y)/l},p={x:(i.x-a*r.x)/(1-a),y:(i.y-a*r.y)/(1-a)},y={p0:n,cp1:u,cp2:p,p:r};return y}(e,t,s,s),y=w([p.p0,p.cp1,p.cp2,p.p],s),h=k(e.p,y),o=0,c=0,x=!1,f=h;if(h<u){let l=.5*(1+s);if(o=k(w([t.p0,t.cp1,t.cp2,t.p],.5),w([p.p0,p.cp1,p.cp2,p.p],l)),f+=o,o<u){let t=.5*s;c=k(w([e.p0,e.cp1,e.cp2,e.p],.5),w([p.p0,p.cp1,p.cp2,p.p],t)),o+c<u&&(x=!0),f+=c}}if(l&&!x){let l=function(e,t,l=0,a=1){const n=(e,t,l,a,n)=>{let s=1-n;return{x:3*s*s*(t.x-e.x)+6*s*n*(l.x-t.x)+3*n*n*(a.x-l.x),y:3*s*s*(t.y-e.y)+6*s*n*(l.y-t.y)+3*n*n*(a.y-l.y)}};let s=[e,t],r=C(e.p0,e.p)>C(t.p0,t.p),i=JSON.parse(JSON.stringify(e)),u=JSON.parse(JSON.stringify(t)),p=M(i.p0,i.cp1,u.p,u.cp2,!1);if(!p)return s;if(r){let l={p0:{x:e.p.x,y:e.p.y},cp1:{x:e.cp2.x,y:e.cp2.y},cp2:{x:e.cp1.x,y:e.cp1.y},p:{x:e.p0.x,y:e.p0.y}};e={p0:{x:t.p.x,y:t.p.y},cp1:{x:t.cp2.x,y:t.cp2.y},cp2:{x:t.cp1.x,y:t.cp1.y},p:{x:t.p0.x,y:t.p0.y}},t=l}let y=(e,t)=>({x:e.x-t.x,y:e.y-t.y}),h=(e,t)=>({x:e.x*t,y:e.y*t}),o=(e,t)=>e.x*t.x+e.y*t.y,c=t.p0,x=n(t.p0,t.cp1,t.cp2,t.p,0),f=o(y(e.p0,c),x)/o(x,x),g=w([t.p0,t.cp1,t.cp2,t.p],f),v=n(t.p0,t.cp1,t.cp2,t.p,f);f-=o(y(g,e.p0),v)/o(v,v);let d=w([t.p0,t.cp1,t.cp2,t.p],f),m=t.p,b=n(t.p0,t.cp1,t.cp2,t.p,f),L=n(t.p0,t.cp1,t.cp2,t.p,1),P=1-f,S=(F=d,I=h(b,P/3),{x:F.x+I.x,y:F.y+I.y});var F,I;let $=y(m,h(L,P/3)),z={p0:d,cp1:S,cp2:$,p:m};r&&(z={p0:m,cp1:$,cp2:S,p:d});let E=w([z.p0,z.cp1,z.cp2,z.p],.5,!1,!0),T=E.cpts[2],Q=M(E,T,z.p0,p,!1),q=M(E,T,z.p,p,!1),D=A(z.p0,Q,1.333),O=A(z.p,q,1.333);if(M(i.p0,D,u.p,O,!0))return s;z.cp1=D,z.cp2=O;let N=k(i.p0,z.p0)+k(u.p,z.p);if(z.p0=i.p0,z.p=u.p,z.extreme=u.extreme,z.corner=u.corner,z.dimA=u.dimA,z.directionChange=u.directionChange,z.values=[z.cp1.x,z.cp1.y,z.cp2.x,z.cp2.y,z.p.x,z.p.y],N<l){let e=B([{type:"M",values:[i.p0.x,i.p0.y]},{type:"C",values:[i.cp1.x,i.cp1.y,i.cp2.x,i.cp2.y,i.p.x,i.p.y]},{type:"C",values:[u.cp1.x,u.cp1.y,u.cp2.x,u.cp2.y,u.p.x,u.p.y]}]),t=[{type:"M",values:[z.p0.x,z.p0.y]},{type:"C",values:[z.cp1.x,z.cp1.y,z.cp2.x,z.cp2.y,z.p.x,z.p.y]}],l=B(t),n=Math.abs(l/e-1);z.error=10*n*a,j(t),n<.01&&(s=[z])}return s}(e,t,u,a);1===l.length&&(x=!0,p=l[0],f=p.error)}return x&&(p.p0=e.p0,p.p=t.p,p.dimA=k(p.p0,p.p),p.type="C",p.extreme=t.extreme,p.directionChange=t.directionChange,p.corner=t.corner,p.values=[p.cp1.x,p.cp1.y,p.cp2.x,p.cp2.y,p.p.x,p.p.y],p.error=f/u,n=[p]),n}function H(e=[]){let t,l=[],a=function(e){let t=[],l={x:e[0].values[0],y:e[0].values[1]};return e.forEach(e=>{let{type:a,values:n}=e;if(n.length){let e=n.length>1?{x:n[n.length-2],y:n[n.length-1]}:"V"===a?{x:l.x,y:n[0]}:{x:n[0],y:l.y};t.push(e),l=e}}),t}(e),n=Q(a),{left:s,right:r,top:i,bottom:u,width:p,height:y}=n,h=e[0].values[0],o=e[0].values[1],c={x:e[0].values[0],y:e[0].values[1]},x={x:e[0].values[0],y:e[0].values[1]};e[0].idx=0,e[0].p0=c,e[0].p=c,e[0].lineto=!1,e[0].corner=!1,e[0].extreme=!1,e[0].directionChange=!1,e[0].closePath=!1,e[0].dimA=0;let f=[e[0]],g=0,v=e.length;for(let l=2;v&&l<=v;l++){let a=e[l-1],{type:n,values:p}=a,y=p.slice(-2),v=[x],d=!1;a.idx=l-1,a.lineto=!1,a.corner=!1,a.extreme=!1,a.directionChange=!1,a.closePath=!1,a.dimA=0;let M,b,A,w,L,S,I,$=.05;t=y.length?{x:y[0],y:y[1]}:c,"M"===n?(c=t,x=t):"z"===n.toLowerCase()&&(t=c),a.p0=x,a.p=t;let z=k(x,t);if(a.dimA=z,"L"===n&&(a.lineto=!0),"Z"===n&&(a.closePath=!0,c.x!==h&&c.y!==o&&(a.lineto=!0)),"Q"!==n&&"C"!==n||(M={x:p[0],y:p[1]},b="C"===n?{x:p[2],y:p[3]}:null,a.cp1=M,b&&(a.cp2=b)),p.length>2){"Q"!==n&&"C"!==n||v.push(M),"C"===n&&v.push(b),v.push(t),d=F(v).flat,a.flat=d,d&&(a.extreme=!1)}d||"L"===n||t.x!==s&&t.y!==i&&t.x!==r&&t.y!==u||(a.extreme=!0);let E=e[l]?e[l]:null,T=E?E.values.slice(-2):null;S=E?E.type:null,!E||"Q"!==E.type&&"C"!==E.type||(L=E?{x:T[0],y:T[1]}:null,A={x:E.values[0],y:E.values[1]},w="C"===E.type?{x:E.values[2],y:E.values[3]}:null),I=O(v);let Q=g<0&&I>0||g>0&&I<0;if(g=I,Q&&(a.directionChange=!0),("Q"===n||"C"===n)&&("Q"===n&&"Q"===S||"C"===n&&"C"===S)){let e=v.slice(1),l=F("C"===n?[t,A,w,L]:[t,A,L],((L?Math.abs(L.x-x.x):0)+(L?Math.abs(L.y-x.y):0))/2*.1).flat;if((!d||!l)&&(!!a.extreme||P(0,e,$)))a.extreme=!0;else{let e=b?[b,t]:[M,t],l=[t,A],n=m(...e,!0),s=m(...l,!0),r=180*Math.abs(n-s)/Math.PI,i=C(...e),u=C(...l);r>10&&i&&u&&(a.corner=!0)}}f.push(a),x=t}return l={pathData:f,bb:n,dimA:(p+y)/2},l}function V(e,t=-1){let l=!("auto"!=t||!e[0].hasOwnProperty("decimals"));for(let a=0,n=e.length;a<n;a++){let n=e[a];(t>-1||l)&&(t=l?n.decimals:t,e[a].values=n.values.map(e=>e?+e.toFixed(t):e))}return e}function Z(e={},t={},l={},a={}){let n=A(e,t,1.5),s=A(a,l,1.5),r=.01*k(e,a),i=k(n,s),u=null,p="C",y=[t.x,t.y,l.x,l.y,a.x,a.y];return i<r&&(u=M(e,t,a,l,!1),u&&(p="Q",y=[u.x,u.y,a.x,a.y])),{type:p,values:y}}function R(e,{toShorthands:t=!0,toRelative:l=!0,decimals:a=3}={}){return t&&(e=function(e,t=-1,l=!0){let a;if(l){let t=e.map(e=>e.type).join("");a=/[astvqmhlc]/g.test(t)}e=l&&a?W(e,t):e;let n={type:"M",values:e[0].values};e[0].decimals&&(n.decimals=e[0].decimals);let s,r=[n],i={x:e[0].values[0],y:e[0].values[1]},u=.01;for(let l=1,a=e.length;l<a;l++){let a=e[l],{type:p,values:y}=a,h=y.slice(-2),o=e[l-1],c=o.type;s={x:h[0],y:h[1]};let x,f,g,v,d={x:y[0],y:y[1]},m=Math.abs(s.x-i.x),M=Math.abs(s.y-i.y),b=(m+M)/2*u;switch(p){case"L":n=0===M||M<b&&m>b?{type:"H",values:[y[0]]}:0===m||M>b&&m<b?{type:"V",values:[y[1]]}:a;break;case"Q":if("Q"!==c){i={x:h[0],y:h[1]},r.push(a);continue}let e={x:o.values[0],y:o.values[1]};v={x:2*i.x-e.x,y:2*i.y-e.y},x=Math.abs(d.x-v.x),f=Math.abs(d.y-v.y),g=(x+f)/2,n=g<b?{type:"T",values:[s.x,s.y]}:a;break;case"C":let t={x:y[2],y:y[3]};if("C"!==c){r.push(a),i={x:h[0],y:h[1]};continue}let l={x:o.values[2],y:o.values[3]};v={x:2*i.x-l.x,y:2*i.y-l.y},x=Math.abs(d.x-v.x),f=Math.abs(d.y-v.y),g=(x+f)/2,n=g<b?{type:"S",values:[t.x,t.y,s.x,s.y]}:a;break;default:n={type:p,values:y}}(a.decimals||0===a.decimals)&&(n.decimals=a.decimals),t>-1&&(n.values=n.values.map(e=>+e.toFixed(t))),i={x:h[0],y:h[1]},r.push(n)}return r}(e)),e=V(e,a),l&&(e=function(e,t=-1){return J(e,!0,t)}(e)),a>-1&&(e=V(e,a)),e}function U(e,t){Array.isArray(e)&&(e={x:e[0],y:e[1]});let l={x:e.x+2/3*(t[0]-e.x),y:e.y+2/3*(t[1]-e.y)},a={x:t[2]+2/3*(t[0]-t[2]),y:t[3]+2/3*(t[1]-t[3])};return{type:"C",values:[l.x,l.y,a.x,a.y,t[2],t[3]]}}function J(e,t=!1,l=-1){l>=0&&(e[0].values=e[0].values.map(e=>+e.toFixed(l)));let a=e[0].values,n=a[0],s=a[1],r=n,i=s;for(let a=1,u=e.length;a<u;a++){let u=e[a],{type:p,values:y}=u,h=t?p.toLowerCase():p.toUpperCase();if(p!==h)switch(p=h,u.type=p,p){case"a":case"A":y[5]=t?y[5]-n:y[5]+n,y[6]=t?y[6]-s:y[6]+s;break;case"v":case"V":y[0]=t?y[0]-s:y[0]+s;break;case"h":case"H":y[0]=t?y[0]-n:y[0]+n;break;case"m":case"M":t?(y[0]-=n,y[1]-=s):(y[0]+=n,y[1]+=s),r=t?y[0]+n:y[0],i=t?y[1]+s:y[1];break;default:if(y.length)for(let e=0;e<y.length;e++)y[e]=t?y[e]-(e%2?s:n):y[e]+(e%2?s:n)}let o=y.length;switch(p){case"z":case"Z":n=r,s=i;break;case"h":case"H":n=t?n+y[0]:y[0];break;case"v":case"V":s=t?s+y[0]:y[0];break;case"m":case"M":r=y[o-2]+(t?n:0),i=y[o-1]+(t?s:0);default:n=y[o-2]+(t?n:0),s=y[o-1]+(t?s:0)}l>=0&&(u.values=u.values.map(e=>+e.toFixed(l)))}return e}function W(e,t=-1){return J(e,!1,t)}function X(e,t,l=1){const a=2*Math.PI;let[n,s,r,i,u,p,y]=t;if(0===n||0===s)return[];let h=r?r*a/360:0,o=h?Math.sin(h):0,c=h?Math.cos(h):1,x=c*(e.x-p)/2+o*(e.y-y)/2,f=-o*(e.x-p)/2+c*(e.y-y)/2;if(0===x&&0===f)return[];n=Math.abs(n),s=Math.abs(s);let g=x*x/(n*n)+f*f/(s*s);if(g>1){let e=Math.sqrt(g);n*=e,s*=e}let v=n*n,d=n===s?v:s*s,m=x*x,M=f*f,b=v*d-v*M-d*m;b<=0?b=0:(b/=v*M+d*m,b=Math.sqrt(b)*(i===u?-1:1));let C=b?b*n/s*f:0,A=b?b*-s/n*x:0,w=c*C-o*A+(e.x+p)/2,L=o*C+c*A+(e.y+y)/2,P=(x-C)/n,S=(f-A)/s,F=(-x-C)/n,I=(-f-A)/s;const k=(e,t,l,a)=>{let n=+(e*l+t*a).toFixed(9);return 1===n||-1===n?1===n?0:Math.PI:(n=n>1?1:n<-1?-1:n,(e*a-t*l<0?-1:1)*Math.acos(n))};let $=k(1,0,P,S),z=k(P,S,F,I);0===u&&z>0?z-=2*Math.PI:1===u&&z<0&&(z+=2*Math.PI);let E=(+(Math.abs(z)/(a/4)).toFixed(0)||1)*l;z/=E;let T=[];const Q=1.5707963267948966,q=.551785;let D=z===Q?q:z===-Q?-q:4/3*Math.tan(z/4),B=z?Math.cos(z):1,O=z?Math.sin(z):0;const j=(e,t,l,a,n)=>{let s=e!=t?Math.cos(e):a,r=e!=t?Math.sin(e):n,i=Math.cos(e+t),u=Math.sin(e+t);return[{x:s-r*l,y:r+s*l},{x:i+u*l,y:u-i*l},{x:i,y:u}]};for(let e=0;e<E;e++){let e={type:"C",values:[]};j($,z,D,B,O).forEach(t=>{let l=t.x*n,a=t.y*s;e.values.push(c*l-o*a+w,o*l+c*a+L)}),T.push(e),$+=z}return T}function G(e,t,l,a,n=7.5){let s={type:"C",values:[t.x,t.y,l.x,l.y,a.x,a.y]},r=0,i=!1,u=m(e,t,!0),p=m(a,l,!0),y=180*Math.abs(u-p)/Math.PI;if(Math.abs(y%180-90)<3){let u=M(e,t,a,l,!1);if(u){let p=b(e,u),y=b(a,u),h=+Math.max(p,y).toFixed(8),o=+Math.min(p,y).toFixed(8),c=o,x=h,f=O([e,t,l,a])<0?0:1,g=Math.abs(a.x-e.x)>Math.abs(a.y-e.y);100/c*Math.abs(c-x)<5&&(c=h,x=c),g&&(c=h,x=o);let v=B([{type:"M",values:[e.x,e.y]},{type:"C",values:[t.x,t.y,l.x,l.y,a.x,a.y]}]),d={type:"A",values:[c,x,0,0,f,a.x,a.y]};r=Math.PI*(c*x)/4,r-=Math.abs(O([e,a,u])),function(e,t){let l=Math.abs(e-t);return Math.abs(100-100/e*(e+l))}(v,r)<n&&(i=!0,s=d)}}return{com:s,isArc:i,area:r}}function Y(e){let t,l=[[]],a=0,n=[[]],s={x:e[0].values[0],y:e[0].values[1]};for(let r=0,i=e.length;r<i;r++){let i=e[r],{type:u,values:p}=i;if("A"===u){let u=e[r-1].values.slice(-2);s={x:u[0],y:u[1]};let[y,h,o,c,x,f,g]=p,v=100/y*Math.abs(y-h)<5;t={x:p[5],y:p[6]},i.p0=s,i.p=t,i.circular=v;let d=e[r+1];if(!l[a].length&&d&&"A"===d.type&&(l[a].push(i),n[a].push(r)),d&&"A"===d.type){let[e,i,u,p,o,c,x]=d.values,f=y!=e?100/y*Math.abs(y-e):0,g=h!=i?100/h*Math.abs(h-i):0;t={x:d.values[5],y:d.values[6]},d.p0=s,d.p=t,f<5&&g<5?(l[a].push(d),n[a].push(r+1)):(l.push([]),n.push([]),a++)}else l.push([]),n.push([]),a++}}if(!n.length)return e;l=l.filter(e=>e.length),n=n.filter(e=>e.length);for(let t=l.length-1;t>=0;t--){const a=l[t],s=n[t][0],r=a.length;let i=0,u=0;a.forEach(({values:e})=>{const[t,l]=e;i+=t,u+=l}),i/=r,u/=r;let p=100/i*Math.abs(i-u)<5;p&&(i=(i+u)/2,u=i);let y=e[s-1].values.slice(-2);if(y[0],y[1],4===r){let[t,l,n,y,h,o,c]=a[1].values,[,,,,,x,f]=a[3].values;p&&(i=1,u=1);let g={type:"A",values:[i,u,n,y,h,o,c]},v={type:"A",values:[i,u,n,y,h,x,f]};e.splice(s,r,g,v)}else if(3===r){let[t,l,n,p,y,h,o]=a[0].values,[c,x,,,,f,g]=a[2].values;p=1;let v={type:"A",values:[i,u,n,p,y,f,g]};e.splice(s,r,v)}else if(2===r){let[t,l,n,y,h,o,c]=a[0].values,[x,f,,,,g,v]=a[1].values;p&&(i=1,u=1,n=0);let{p0:d,p:m}=a[0],[M,b]=[a[1].p0,a[1].p];if(d.x!==b.x||d.y!==b.y){let t={type:"A",values:[i,u,n,y,h,g,v]};e.splice(s,r,t)}}}return e}function K(e=[],{toAbsolute:t=!0,toLonghands:l=!0,quadraticToCubic:a=!1,arcToCubic:n=!1,arcAccuracy:s=2}={},{hasRelatives:r=!0,hasShorthands:i=!0,hasQuadratics:u=!0,hasArcs:p=!0,testTypes:y=!1}={}){if(y){let t=Array.from(new Set(e.map(e=>e.type))).join("");r=/[lcqamts]/gi.test(t),u=/[qt]/gi.test(t),p=/[a]/gi.test(t),i=/[vhst]/gi.test(t),isPoly=/[mlz]/gi.test(t)}return(u&&a||p&&n)&&(l=!0,t=!0),r&&t&&(e=J(e,!1)),i&&l&&(e=function(e,t=-1,l=!0){let a=!1;if(l){let t=e.map(e=>e.type).join(""),l=/[hstv]/gi.test(t);if(a=/[astvqmhlc]/g.test(t),!l)return e}let n=[],s={type:"M",values:(e=l&&a?W(e,t):e)[0].values};n.push(s);for(let l=1,a=e.length;l<a;l++){let a,r,i,u,p,y,h,o,c=e[l],{type:x,values:f}=c,g=f.length,v=s.values,d=v.length,[m,M]=[f[g-2],f[g-1]],[b,C]=[v[d-2],v[d-1]];switch(x){case"H":s={type:"L",values:[f[0],C]};break;case"V":s={type:"L",values:[b,f[0]]};break;case"T":[a,r]=[v[0],v[1]],[b,C]=[v[d-2],v[d-1]],i=b+(b-a),u=C+(C-r),s={type:"Q",values:[i,u,m,M]};break;case"S":[a,r]=[v[0],v[1]],[b,C]=[v[d-2],v[d-1]],[h,o]=d>2&&"A"!==s.type?[v[2],v[3]]:[b,C],i=2*b-h,u=2*C-o,p=f[0],y=f[1],s={type:"C",values:[i,u,p,y,m,M]};break;default:s={type:x,values:f}}t>-1&&(s.values=s.values.map(e=>+e.toFixed(t))),n.push(s)}return n}(e,-1,!1)),p&&n&&(e=function(e,{arcAccuracy:t=1}={}){let l=[e[0]];for(let a=1,n=e.length;a<n;a++){let n=e[a],s=e[a-1].values,r=s.length,i={x:s[r-2],y:s[r-1]};"A"===n.type?X(i,n.values,t).forEach(e=>{l.push(e)}):l.push(n)}return l}(e,s)),u&&a&&(e=function(e){let t=[e[0]];for(let l=1,a=e.length;l<a;l++){let a=e[l],n=e[l-1].values,s=n.length,r={x:n[s-2],y:n[s-1]};"Q"===a.type?t.push(U(r,a.values)):t.push(a)}return t}(e)),e}function _(e,{toAbsolute:t=!0,toLonghands:l=!0,quadraticToCubic:a=!1,arcToCubic:n=!1,arcAccuracy:s=4}={}){let r=function(e,t=!0){if(e=e.trim(),""===e)return{pathData:[],hasRelatives:!1,hasShorthands:!1,hasQuadratics:!1,hasArcs:!1};const l=new Set([5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279]),a=e=>32===e||44===e||10===e||13===e||8232===e||8233===e||9===e||11===e||12===e||160===e||e>=5760&&l.has(e);let n,s=0,r=e.length,i="",u=[],p=-1,y="",h=!1,o=0,c=0,x=0,f=!1,g=new Set([]),v=[];const d=()=>{f&&("M"===i?i="L":"m"===i&&(i="l"),u.push({type:i,values:[]}),p++,c=0,f=!1)},m=(e=!1)=>{(e?o>0:""!==y)&&(t&&-1===p&&(n="Pathdata must start with M command",v.push(n),i="M",u.push({type:i,values:[]}),x=2,c=0,p++),"A"===i||"a"===i?(y=M(),u[p].values.push(...y)):(t&&y[1]&&"."!==y[1]&&"0"===y[0]&&(n=`${p}. command: Leading zeros not valid: ${y}`,v.push(n)),u[p].values.push(+y)),c++,y="",o=0,f=c>=x)},M=()=>{let e=y.length,t=!1;return 3===c&&2===e||4===c&&e>1?(y=[+y[0],+y[1]],t=!0,c++):3===c&&e>=3&&(y=[+y[0],+y[1],+y.substring(2)],t=!0,c+=2),t?y:[+y]},b=()=>{if(p>0){let e=u[p].values.length;if(e&&e<x||e&&e>x||("z"===i||"Z"===i)&&e>0){n=`${p}. command of type "${i}": ${x-e} values too few - ${x} expected`,v[v.length-1]!==n&&v.push(n)}}};let C=!1,A=!1,w=!1;for(;s<r;){let l=e.charCodeAt(s),r=l>47&&l<58;if(r||(C=101===l||69===l,A=45===l||43===l,w=46===l),r||A||w||C){if(h||45!==l&&46!==l)d();else{let e=46===l;m(e),d(),e&&o++}y+=e[s],h=C,s++}else if((l<48||l>5759)&&a(l))m(),s++;else{if(l>64){if(!ee.has(l)){n=`${p}. command "${e[s]}" is not a valid type`,v.push(n),s++;continue}""!==y&&(u[p].values.push(+y),c++,y=""),t&&b(),i=e[s],x=te[l];let a="M"===i||"m"===i,r=p>0&&("z"===u[p].type||"Z"===u[p].type);g.add(i),r&&!a&&(u.push({type:"m",values:[0,0]}),p++),u.push({type:i,values:[]}),p++,o=0,c=0,f=!1,s++;continue}r||(n=`${p}. ${e[s]} is not a valid separarator or token`,v.push(n),y=""),s++}}m(),t&&b();if(t&&v.length){if(n="Invalid path data:\n"+v.join("\n"),"log"!==t)throw new Error(n);console.log(n)}u[0].type="M";let L=Array.from(g).join(""),P=/[lcqamts]/g.test(L),S=/[vhst]/gi.test(L),F=/[a]/gi.test(L),I=/[qt]/gi.test(L);return{pathData:u,hasRelatives:P,hasShorthands:S,hasQuadratics:I,hasArcs:F}}(e),{hasRelatives:i,hasShorthands:u,hasQuadratics:p,hasArcs:y}=r,h=r.pathData;return h=K(h,{toAbsolute:t,toLonghands:l,quadraticToCubic:a,arcToCubic:n,arcAccuracy:s},{hasRelatives:i,hasShorthands:u,hasQuadratics:p,hasArcs:y}),h}const ee=new Set([77,109,65,97,67,99,76,108,81,113,83,115,84,116,72,104,86,118,90,122]),te=new Uint8Array(128);function le(e,t=1,l=!0){let a=[e[0]],n={x:e[0].values[0],y:e[0].values[1]},s=n,r=n;e[e.length-1].type.toLowerCase();for(let i=1,u=e.length;i<u;i++){let p=e[i-1],y=e[i],h=e[i+1]||e[u-1],o="z"===h.type.toLowerCase()?n:{x:h.values[h.values.length-2],y:h.values[h.values.length-1]},{type:c,values:x}=y,f=x.slice(-2);r="Z"!==c?{x:f[0],y:f[1]}:n;let g=O([s,r,o],!0)<C(s,o)/100*t,v=!1;if(l||"C"!==c||(g=!1),l&&("C"===c||"Q"===c)){v=I(s,"C"===c?[{x:x[0],y:x[1]},{x:x[2],y:x[3]}]:"Q"===c?[{x:x[0],y:x[1]}]:[],r),v&&i<u-1&&"C"!==p.type&&(c="L",y.type="L",y.values=f)}s=r,g&&i<u-1&&("L"===c||l&&v)||("M"===c?(n=r,s=n):"Z"===c&&(s=n),a.push(y))}return a}function ae(e){let t={x:e[0].values[0],y:e[0].values[1]},l=t,a=[e[0]];for(let n=1,s=e.length;n<s;n++){let s=e[n],{type:r,values:i}=s,u=i.slice(-2);l={x:u[0],y:u[1]},"L"===r&&l.x===t.x&&l.y===t.y||(a.push(s),t=l)}return a}function ne(e){let t=e.length;if(!("z"===e[t-1].type.toLowerCase()))return e;let l=0,a=[];for(let l=0;l<t;l++){let t=e[l],{type:n,values:s}=t,r=s.length;if(r){let e={type:n,x:s[r-2],y:s[r-1],index:0};e.index=l,a.push(e)}}return a=a.sort((e,t)=>+e.y.toFixed(3)-+t.y.toFixed(3)),l=a[0].index,l?re(e,l):e}function se(e,t=!0,l=!0){let a=[],n=e.length,s={x:+e[0].values[0].toFixed(8),y:+e[0].values[1].toFixed(8)},r="z"===e[n-1].type.toLowerCase(),i=e.filter(e=>"L"===e.type),u=e[n-2],p=u.type,y=u.values.slice(-2).map(e=>+e.toFixed(8)),h=y[0]===s.x&&y[1]===s.y,o="L"!==e[1].type&&(!h||"L"===p);if(o=!1,!r)return e;let c=0;{let t=[];for(let l=0,a=e.length;l<a;l++){let a=e[l],{type:n,values:s}=a;if(s.length){let a=s.slice(-2),r=e[l-1]&&"L"===e[l-1].type,i=e[l+1]&&"L"===e[l+1].type,u=e[l-1]?e[l-1].type.toUpperCase():null,p=e[l+1]?e[l+1].type.toUpperCase():null,y={type:n,x:a[0],y:a[1],dist:0,index:0,prevL:r,nextL:i,prevCom:u,nextCom:p};y.index=l,t.push(y)}}if(i.length){let e=t.filter(e=>"L"!==e.type&&"M"!==e.type&&e.prevCom&&"L"===e.prevCom||"M"===e.prevCom&&"L"===p).sort((e,t)=>e.y-t.y||e.x-t.x)[0];c=e?e.index-1:0}else t=t.sort((e,t)=>+e.y.toFixed(1)-+t.y.toFixed(1)||e.x-t.x),c=t[0].index;e=c?re(e,c):e}return s={x:+e[0].values[0].toFixed(8),y:+e[0].values[1].toFixed(7)},n=e.length,u=e[n-2],p=u.type,y=u.values.slice(-2).map(e=>+e.toFixed(8)),h="L"===p&&y[0]===s.x&&y[1]===s.y,t&&h&&e.splice(n-2,1),a.push(...e),a}function re(e,t){let l=0,a="z"===e[e.length-1].type.toLowerCase();if(!a||t<1||e.length<3)return e;let n=a?1:0;!function(e){let t=e.length,l="z"===e[t-1].type.toLowerCase(),a=e[0],[n,s]=[a.values[0],a.values[1]].map(e=>+e.toFixed(8)),r=l?e[t-2]:e[t-1],i=r.values.length,[u,p]=[r.values[i-2],r.values[i-1]].map(e=>+e.toFixed(8));!l||n==u&&s==p||(e.pop(),e.push({type:"L",values:[n,s]},{type:"Z",values:[]}))}(e),l=t+1<e.length-1?t+1:e.length-1-n;let s,r,i=e.slice(l),u=e.slice(0,l);return u.shift(),s=u[u.length-1].values||[],r=[s[s.length-2],s[s.length-1]],n&&(i.pop(),u.push({type:"Z",values:[]})),e=[{type:"M",values:r},...i,...u]}function ie(e,{arcToCubic:t=!1,quadraticToCubic:l=!1,toClockwise:a=!1,returnD:n=!1}={}){const s=(e,t)=>{let l=[],a=[];if("A"!==e){for(let e=0;e<t.length;e+=2)l.push([t[e],t[e+1]]);a=l.pop(),l.reverse()}else{let e=0==t[4]?1:0;l=[t[0],t[1],t[2],t[3],e],a=[t[5],t[6]]}return{controlPoints:l,endPoints:a}};let r=[],i="z"===e[e.length-1].type.toLowerCase();i&&(e=(e=>{let t="z"===e[e.length-1].type.toLowerCase(),l=e[0],[a,n]=[l.values[0],l.values[1]],s=t?e[e.length-2]:e[e.length-1],[r,i]=[s.values[s.values.length-2],s.values[s.values.length-1]];return!t||a==r&&n==i||(e.pop(),e.push({type:"L",values:[a,n]},{type:"Z",values:[]})),e})(e),e.pop());let u=e[e.length-1].values,p=u.length,y=i?e[0]:{type:"M",values:[u[p-2],u[p-1]]};r.push(y),e.reverse();for(let t=1;t<e.length;t++){let l=e[t],a=l.type,n=l.values,i=e[t-1],u=i.type,p=[];p=[s(u,i.values).controlPoints,s(a,n).endPoints].flat(),r.push({type:u,values:p.flat()})}return i&&r.push({type:"z",values:[]}),r}function ue(e,{returnDom:t=!1,removeHidden:l=!0,removeUnused:a=!0}={}){e=(e=e.replace(/<\?xml[\s\S]*?\?>/gi,"").replace(/<!DOCTYPE[\s\S]*?>/gi,"").replace(/<!--[\s\S]*?-->/g,"").trim()).replaceAll("xlink:href=","href=");let n=(new DOMParser).parseFromString(e,"text/html").querySelector("svg");!function(e,t=["viewBox","xmlns","width","height","id","class"]){[...e.attributes].map(e=>e.name).forEach(l=>{t.includes(l)||e.removeAttribute(l)})}(n,["viewBox","xmlns","width","height","id","class"]);let s=["metadata","script"];if(n.querySelectorAll("*").forEach(e=>{let t=e.nodeName,a=e.getAttribute("style")||"",n=!!a&&a.trim().includes("display:none"),r=e.getAttribute("display")&&"none"===e.getAttribute("display")||n;t.includes(":")||s.includes(t)||l&&r?e.remove():function(e){let t=[...e.attributes].map(e=>e.name);t.forEach(t=>{t.includes(":")&&e.removeAttribute(t)})}(e)}),t)return n;let r=function(e){let t=(new XMLSerializer).serializeToString(e);return t=t.replace(/\t/g,"").replace(/[\n\r|]/g,"\n").replace(/\n\s*\n/g,"\n").replace(/ +/g," "),t}(n);return console.log(r),r}function pe(e="",{toAbsolute:t=!0,toRelative:l=!0,toShorthands:a=!0,decimals:n=3,quadraticToCubic:s=!0,arcToCubic:r=!1,cubicToArc:i=!1,arcAccuracy:u=4,keepExtremes:p=!0,keepCorners:y=!0,keepInflections:h=!0,extrapolateDominant:o=!1,addExtremes:c=!1,optimizeOrder:x=!0,removeColinear:f=!0,simplifyBezier:g=!0,autoAccuracy:v=!0,flatBezierToLinetos:d=!0,revertToQuadratics:m=!0,minifyD:M=0,tolerance:b=1,reverse:C=!1,removeHidden:A=!0,removeUnused:w=!0,getObject:L=!1}={}){b=Math.max(.1,b);let P=function(e){let t="string";if(e instanceof HTMLImageElement)return"img";if(e instanceof SVGElement)return"svg";if(e instanceof HTMLCanvasElement)return"canvas";if(e instanceof File)return"file";if(e instanceof ArrayBuffer)return"buffer";if(e instanceof Blob)return"blob";if(Array.isArray(e))return"array";if("string"==typeof e){let l=(e=e.trim()).includes("<svg")&&e.includes("</svg"),a=e.startsWith("M")||e.startsWith("m"),n=!isNaN(e.substring(0,1))&&!isNaN(e.substring(e.length-1,e.length));if(l)t="svgMarkup";else if(a)t="pathDataString";else if(n)t="polyString";else{let l=/^(file:|https?:\/\/|\/|\.\/|\.\.\/)/.test(e),a=e.startsWith("data:image");t=l||a?"url":"string"}return t}return t=typeof e,(e.constructor.name||t).toLowerCase()}(e),S="",F=0,I=0,z=0,E={},Q="",q="svgMarkup"===P?1:0,D=[];if(F=new Blob([e]).size,q){S=ue(e,{returnDom:!0,removeHidden:A,removeUnused:w}),S.querySelectorAll("path").forEach(e=>{D.push({d:e.getAttribute("d"),el:e})})}else"pathDataString"===P?Q=e:"polyString"===P&&(Q="M"+e),D.push({d:Q,el:null});return D.forEach(e=>{let{d:u,el:A}=e,w=_(u,{quadraticToCubic:s,toAbsolute:t,arcToCubic:r}),L=JSON.parse(JSON.stringify(w)),P=w.length,S=$(L),E=[];for(let e=0,t=S.length;e<t;e++){let t=S[e];C&&(t=ie(t)),f&&(t=ae(t)),c&&(t=T(t,0,1)),x&&(t=ne(t)),f&&(t=le(t,b,d));let l=H(t),{pathData:a,bb:n,dimA:s}=l;if(a=g?ye(a,{simplifyBezier:g,keepInflections:h,keepExtremes:p,keepCorners:y,extrapolateDominant:o,revertToQuadratics:m,tolerance:b,reverse:C}):a,i){let e=3;a.forEach((t,l)=>{let{type:n,values:s,p0:r,cp1:i=null,cp2:u=null,p:p=null}=t;if("C"===n){let t=G(r,i,u,p,e);t.isArc&&(a[l]=t.com)}}),a=Y(a)}m&&a.forEach((e,t)=>{let{type:l,values:n,p0:s,cp1:r=null,cp2:i=null,p:u=null}=e;if("C"===l){let e=Z(s,r,i,u);"Q"===e.type&&(a[t]=e)}}),x&&(a=se(a)),E.push(a)}L=E.flat(),v&&(n=function(e){let t={x:e[0].values[0],y:e[0].values[1]},l=t,a=t;e[0].decimals=0;let n=new Set;for(let s=0,r=e.length;s<r;s++){let r=e[s],{type:i,values:u}=r,p=u.length?u.slice(-2):[t.x,t.y];a={x:p[0],y:p[1]};let y=r.dimA?+r.dimA.toFixed(8):"M"!==i?+k(l,a).toFixed(8):0;y&&n.add(y),"M"===i&&(t=a),l=a}let s=Array.from(n).sort(),r=Math.ceil(s.length/8);s=s.slice(0,r);let i=s.reduce((e,t)=>e+t,0)/r,u=i>50?0:Math.floor(50/i).toString().length;return Math.min(Math.max(0,u),8)}(L)),L=R(L,{toRelative:l,toShorthands:a,decimals:n});let Q=[];L.forEach((e,t)=>{let{type:l,values:a}=e;if("l"===l||"v"===l||"h"===l){("l"===l?"00"!==a.join(""):0!==a[0])&&Q.push(e)}else Q.push(e)}),L=Q;let q=L.length,D=j(L,M);I=new Blob([D]).size,z=+(100/F*I).toFixed(2),e.d=D,e.report={original:P,new:q,saved:P-q,compression:z,decimals:n},A&&A.setAttribute("d",D)}),q?(S=(new XMLSerializer).serializeToString(S),I=new Blob([S]).size,z=+(100/F*I).toFixed(2),F=+(F/1024).toFixed(3),I=+(I/1024).toFixed(3),E={svgSize:F,svgSizeOpt:I,compression:z}):({d:Q,report:E}=D[0]),L?{svg:S,d:Q,report:E,inputType:P,mode:q}:Q||S}function ye(e,{keepExtremes:t=!0,keepInflections:l=!0,keepCorners:a=!0,extrapolateDominant:n=!0,tolerance:s=1,reverse:r=!1}={}){let i=[e[0]];for(let r=2,u=e.length;u&&r<=u;r++){let p=e[r-1],y=r<u?e[r]:null,h=y?.type||null,o=p?.directionChange||null,c=y?.directionChange||null,{type:x,values:f,p0:g,p:v,cp1:d=null,cp2:m=null,extreme:M=!1,corner:b=!1,dimA:C=0}=p;if("C"===x&&"C"===h)if(l&&c||a&&b||!o&&t&&M)i.push(p);else{let h=N(p,y,n,s),o=0;if(1===h.length){p=h[0];let y=1;o+=p.error;for(let i=r+1;o<s&&i<u;i++){let r=e[i];if("C"!==r.type||l&&r.directionChange||a&&p.corner||t&&p.extreme)break;let u=N(p,r,n,s);1===u.length&&y++,p=u[0]}i.push(p),r<u&&(r+=y)}else i.push(p)}else i.push(p)}return r&&(i=ie(i)),i}function he(e=null,t=!1){if(!e)return{x:0,y:0,width:300,height:150};let l=window.getComputedStyle(e),a=e.hasAttribute("width")?e.width.baseVal.value:parseFloat(l.width)||300,n=e.hasAttribute("height")?e.height.baseVal.value:parseFloat(l.height)||150,s=e.getAttribute("viewBox")?e.viewBox.baseVal:{x:0,y:0,width:a,height:n},{x:r,y:i,width:u,height:p}=s;if(s={x:r,y:i,width:u,height:p},t)for(let e in s)s[e]=Math.ceil(s[e]);return s}te[77]=2,te[109]=2,te[65]=7,te[97]=7,te[67]=6,te[99]=6,te[76]=2,te[108]=2,te[81]=4,te[113]=4,te[83]=4,te[115]=4,te[84]=2,te[116]=2,te[72]=1,te[104]=1,te[86]=1,te[118]=1,te[90]=0,te[122]=0;const{abs:oe,acos:ce,asin:xe,atan:fe,atan2:ge,ceil:ve,cos:de,exp:me,floor:Me,log:be,hypot:Ce,max:Ae,min:we,pow:Le,random:Pe,round:Se,sin:Fe,sqrt:Ie,tan:ke,PI:$e}=Math;"undefined"!=typeof window&&(window.svgPathSimplify=pe,window.getViewBox=he,window.renderPoint=function(e,t,l="red",a="1%",n="1",s="",r=!0,i="",u=""){Array.isArray(t)&&(t={x:t[0],y:t[1]});let p=`<circle class="${u}" opacity="${n}" id="${i}" cx="${t.x}" cy="${t.y}" r="${a}" fill="${l}">\n <title>${s}</title></circle>`;if(!r)return p;e.insertAdjacentHTML("beforeend",p)});export{$e as PI,oe as abs,ce as acos,xe as asin,fe as atan,ge as atan2,ve as ceil,de as cos,me as exp,Me as floor,he as getViewBox,Ce as hypot,be as log,Ae as max,we as min,Le as pow,Pe as random,Se as round,Fe as sin,Ie as sqrt,pe as svgPathSimplify,ke as tan};
@@ -3610,12 +3610,98 @@
3610
3610
  }
3611
3611
 
3612
3612
  // reorder to top left most
3613
- indices = indices.sort((a, b) => +a.y.toFixed(3) - +b.y.toFixed(3) || a.x - b.x);
3613
+
3614
+ indices = indices.sort((a, b) => +a.y.toFixed(3) - +b.y.toFixed(3) );
3614
3615
  newIndex = indices[0].index;
3615
3616
 
3616
3617
  return newIndex ? shiftSvgStartingPoint(pathData, newIndex) : pathData;
3617
3618
  }
3618
3619
 
3620
+ function optimizeClosePath(pathData, removeFinalLineto = true, reorder = true) {
3621
+
3622
+ let pathDataNew = [];
3623
+ let len = pathData.length;
3624
+ let M = { x: +pathData[0].values[0].toFixed(8), y: +pathData[0].values[1].toFixed(8) };
3625
+ let isClosed = pathData[len - 1].type.toLowerCase() === 'z';
3626
+
3627
+ let linetos = pathData.filter(com => com.type === 'L');
3628
+
3629
+ // check if order is ideal
3630
+ let penultimateCom = pathData[len - 2];
3631
+ let penultimateType = penultimateCom.type;
3632
+ let penultimateComCoords = penultimateCom.values.slice(-2).map(val => +val.toFixed(8));
3633
+
3634
+ // last L command ends at M
3635
+ let isClosingCommand = penultimateComCoords[0] === M.x && penultimateComCoords[1] === M.y;
3636
+
3637
+ // if last segment is not closing or a lineto
3638
+ let skipReorder = pathData[1].type !== 'L' && (!isClosingCommand || penultimateType === 'L');
3639
+ skipReorder = false;
3640
+
3641
+ // we can't change starting point for non closed paths
3642
+ if (!isClosed) {
3643
+ return pathData
3644
+ }
3645
+
3646
+ let newIndex = 0;
3647
+
3648
+ if (!skipReorder) {
3649
+
3650
+ let indices = [];
3651
+ for (let i = 0, len = pathData.length; i < len; i++) {
3652
+ let com = pathData[i];
3653
+ let { type, values } = com;
3654
+ if (values.length) {
3655
+ let valsL = values.slice(-2);
3656
+ let prevL = pathData[i - 1] && pathData[i - 1].type === 'L';
3657
+ let nextL = pathData[i + 1] && pathData[i + 1].type === 'L';
3658
+ let prevCom = pathData[i - 1] ? pathData[i - 1].type.toUpperCase() : null;
3659
+ let nextCom = pathData[i + 1] ? pathData[i + 1].type.toUpperCase() : null;
3660
+ let p = { type: type, x: valsL[0], y: valsL[1], dist: 0, index: 0, prevL, nextL, prevCom, nextCom };
3661
+ p.index = i;
3662
+ indices.push(p);
3663
+ }
3664
+ }
3665
+
3666
+ // find top most lineto
3667
+
3668
+ if (linetos.length) {
3669
+ let curveAfterLine = indices.filter(com => (com.type !== 'L' && com.type !== 'M') && com.prevCom &&
3670
+ com.prevCom === 'L' || com.prevCom === 'M' && penultimateType === 'L').sort((a, b) => a.y - b.y || a.x - b.x)[0];
3671
+
3672
+ newIndex = curveAfterLine ? curveAfterLine.index - 1 : 0;
3673
+
3674
+ }
3675
+ // use top most command
3676
+ else {
3677
+ indices = indices.sort((a, b) => +a.y.toFixed(1) - +b.y.toFixed(1) || a.x - b.x);
3678
+ newIndex = indices[0].index;
3679
+ }
3680
+
3681
+ // reorder
3682
+ pathData = newIndex ? shiftSvgStartingPoint(pathData, newIndex) : pathData;
3683
+ }
3684
+
3685
+ M = { x: +pathData[0].values[0].toFixed(8), y: +pathData[0].values[1].toFixed(7) };
3686
+
3687
+ len = pathData.length;
3688
+
3689
+ // remove last lineto
3690
+ penultimateCom = pathData[len - 2];
3691
+ penultimateType = penultimateCom.type;
3692
+ penultimateComCoords = penultimateCom.values.slice(-2).map(val=>+val.toFixed(8));
3693
+
3694
+ isClosingCommand = penultimateType === 'L' && penultimateComCoords[0] === M.x && penultimateComCoords[1] === M.y;
3695
+
3696
+ if (removeFinalLineto && isClosingCommand) {
3697
+ pathData.splice(len - 2, 1);
3698
+ }
3699
+
3700
+ pathDataNew.push(...pathData);
3701
+
3702
+ return pathDataNew
3703
+ }
3704
+
3619
3705
  /**
3620
3706
  * shift starting point
3621
3707
  */
@@ -4083,10 +4169,14 @@
4083
4169
  });
4084
4170
  }
4085
4171
 
4172
+ // optimize close path
4173
+ if(optimizeOrder) pathData=optimizeClosePath(pathData);
4174
+
4086
4175
  // update
4087
4176
  pathDataArrN.push(pathData);
4088
4177
  }
4089
4178
 
4179
+
4090
4180
  // flatten compound paths
4091
4181
  pathData = pathDataArrN.flat();
4092
4182
 
@@ -1 +1 @@
1
- !function(e){"use strict";const{abs:t,acos:l,asin:a,atan:n,atan2:s,ceil:r,cos:i,exp:u,floor:p,log:h,max:y,min:o,pow:c,random:x,round:f,sin:g,sqrt:v,tan:d,PI:m}=Math;function M(e,t,l=!1){let a=s(t.y-e.y,t.x-e.x);return l&&a<0&&(a+=2*Math.PI),a}function b(e,t,l,a,n=!0){let s,r,i,u,p,h={};try{if(s=(a.y-l.y)*(t.x-e.x)-(a.x-l.x)*(t.y-e.y),0==s)return!1}catch{console.log("!catch",e,t,"p3:",l,a)}r=e.y-l.y,i=e.x-l.x,u=(a.x-l.x)*r-(a.y-l.y)*i,p=(t.x-e.x)*r-(t.y-e.y)*i,r=u/s,i=p/s,h={x:e.x+r*(t.x-e.x),y:e.y+r*(t.y-e.y)};let y=!1;return r>0&&r<1&&i>0&&i<1&&(y=!0),!(n&&!y)&&h}function A(e,t){return v((t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y))}function C(e,t){return(t.x-e.x)**2+(t.y-e.y)**2}function w(e,t,l,a=!1){let n={x:(t.x-e.x)*l+e.x,y:(t.y-e.y)*l+e.y};return a&&(n.angle=M(e,t),n.angle<0&&(n.angle+=2*m)),n}function P(e,t=.5,l=!1,a=!1){let n;return n=e.length>2?((e,t,l=!1)=>{let n=4===e.length,s=e[0],r=e[1],i=n?e[2]:e[1],u=e[e.length-1],p={x:0,y:0};if(l||a){let e,l,h,y,o,c=s.x===r.x&&s.y===r.y,x=u.x===i.x&&u.y===i.y;0!==t||c?1!==t||x?(c&&(t+=1e-7),x&&(t-=1e-7),e=w(s,r,t),n?(l=w(r,i,t),h=w(i,u,t),y=w(e,l,t),o=w(l,h,t),p=w(y,o,t),p.angle=M(y,o),a&&(p.cpts=[l,h,y,o])):(l=w(s,r,t),h=w(r,u,t),p=w(l,h,t),p.angle=M(l,h),a&&(p.cpts=[l,h]))):(p.x=u.x,p.y=u.y,p.angle=M(i,u)):(p.x=s.x,p.y=s.y,p.angle=M(s,r))}else{let e=1-t;p=n?{x:e**3*s.x+3*e**2*t*r.x+3*e*t**2*i.x+t**3*u.x,y:e**3*s.y+3*e**2*t*r.y+3*e*t**2*i.y+t**3*u.y}:{x:e*e*s.x+2*e*t*r.x+t**2*u.x,y:e*e*s.y+2*e*t*r.y+t**2*u.y}}return p})(e,t,l):w(e[0],e[1],t,l),l&&n.angle<0&&(n.angle+=2*m),n}function S(e,t,l,a,s,r=0,u=!0,p=!1){if(s=p?s*m/180:s,r=p?r*m/180:r,r=l!==a&&r!==2*m?r:0,u&&l!==a){let e=n(d(s=r?s-r:s)*(l/a));s=i(s)<0?e+m:e}let h=e+l*i(s),y=t+a*g(s),o={x:h,y:y};return r&&(o.x=e+(h-e)*i(r)-(y-t)*g(r),o.y=t+(h-e)*g(r)+(y-t)*i(r)),o}function L(e,t=[],l=.05){let a=3===t.length,n=t[0]||null,s=a?t[1]:null,r=a?t[2]:t[1],i=.5*Math.PI,u=!1,p=!1,h=n?M(r,n,!0):null;if(u=Math.abs(h%i)<l||Math.abs(h%i-i)<l,a){let e=s?M(s,r,!0):0;p=Math.abs(e%i)<=l||Math.abs(e%i-i)<=l}return u||p}function I(e){return 4===e.length?function(e,t,l,a){let[n,s,r,i,u,p,h,y]=[e.x,e.y,t.x,t.y,l.x,l.y,a.x,a.y],o=Math.min(e.y,a.y),c=Math.min(e.x,a.x),x=Math.max(e.x,a.x),f=Math.max(e.y,a.y);if(t.y>=o&&t.y<=f&&l.y>=o&&l.y<=f&&t.x>=c&&t.x<=x&&l.x>=c&&l.x<=x)return[];let g,v,d,m,M,b,A,C,w=[];for(let e=0;e<2;++e)if(0==e?(v=6*n-12*r+6*u,g=-3*n+9*r-9*u+3*h,d=3*r-3*n):(v=6*s-12*i+6*p,g=-3*s+9*i-9*p+3*y,d=3*i-3*s),Math.abs(g)<1e-12){if(Math.abs(v)<1e-12)continue;m=-d/v,0<m&&m<1&&w.push(m)}else A=v*v-4*d*g,A<0?Math.abs(A)<1e-12&&(m=-v/(2*g),0<m&&m<1&&w.push(m)):(C=Math.sqrt(A),M=(-v+C)/(2*g),0<M&&M<1&&w.push(M),b=(-v-C)/(2*g),0<b&&b<1&&w.push(b));let P=w.length;for(;P--;)m=w[P];return w}(e[0],e[1],e[2],e[3]):function(e,t,l){let a,n,s,r=Math.min(e.y,l.y),i=Math.min(e.x,l.x),u=Math.max(e.x,l.x),p=Math.max(e.y,l.y);if(t.y>=r&&t.y<=p&&t.x>=i&&t.x<=u)return[];let[h,y,o,c,x,f]=[e.x,e.y,t.x,t.y,l.x,l.y],g=[];for(let e=0;e<2;++e)a=0==e?h-2*o+x:y-2*c+f,n=0==e?-2*h+2*o:-2*y+2*c,Math.abs(a)>1e-12&&(s=-n/(2*a),s>0&&s<1&&g.push(s));return g}(e[0],e[1],e[2])}function k(e,t=.025){let l=e[0],a=e[e.length-1],n=e.map(e=>e.x),s=e.map(e=>e.y),r=Math.min(...n),i=Math.max(...n),u=Math.min(...s),p=i-r,h=Math.max(...s)-u;if(e.length<3||0===p||0===h)return{area:0,flat:!0,thresh:1e-4,ratio:0};let y=C(l,a),o=C(l,e[0]),c=(o+(e.length>3?C(a,e[1]):o))/2;let x=.5*(p+h)*.5,f=0;for(let t=0,l=e.length;t<l;t++){f+=e[t].x*e[t===e.length-1?0:t+1].y*.5-e[t===e.length-1?0:t+1].x*e[t].y*.5}f=+Math.abs(f).toFixed(9);return{area:f,flat:0===f||f<c/1e3,thresh:x,ratio:f/c,squareDist:y,areaThresh:y/1e3}}function $(e,t,l){let a=!1,n=2===t.length,s=t[0],r=n?t[1]:s;if(e.x===s.x&&e.y===s.y&&l.x===r.x&&l.y===r.y)return!0;let i=s.x-e.x,u=s.y-e.y,p=l.x-r.x,h=l.y-r.y,y=Math.abs(i*h-u*p);if(!y)return!0;let o=l.x-e.x,c=l.y-e.y,x=Math.abs(o*u-c*i);return!x||(x/y<1.1&&(a=!0),a)}function z(e,t){return(Math.abs(t.x-e.x)+Math.abs(t.y-e.y))/2}function E(e){let t=[];try{e.map((e,t)=>"m"===e.type.toLowerCase()?t:-1).filter(e=>-1!==e)}catch{console.log("catch",e)}let l=e.map((e,t)=>"m"===e.type.toLowerCase()?t:-1).filter(e=>-1!==e);return 1===l.length?[e]:(l.forEach((a,n)=>{t.push(e.slice(a,l[n+1]))}),t)}function T(e,t){let l,a,n,s,r,i,u=[],p=[],h=e[0],y=e[1],o=e[e.length-2],c=e[e.length-1];return 4===e.length?(l=P([h,y],t),a=P([y,o],t),n=P([o,c],t),s=P([l,a],t),r=P([a,n],t),i=P([s,r],t),u.push({x:h.x,y:h.y},{x:l.x,y:l.y},{x:s.x,y:s.y},{x:i.x,y:i.y}),p.push({x:i.x,y:i.y},{x:r.x,y:r.y},{x:n.x,y:n.y},{x:c.x,y:c.y})):3===e.length?(a=P([h,y],t),n=P([y,c],t),i=P([a,n],t),u.push({x:h.x,y:h.y},{x:a.x,y:a.y},{x:i.x,y:i.y}),p.push({x:i.x,y:i.y},{x:n.x,y:n.y},{x:c.x,y:c.y})):2===e.length&&(a=P([h,c],t),u.push({x:h.x,y:h.y},{x:a.x,y:a.y}),p.push({x:a.x,y:a.y},{x:c.x,y:c.y})),[u,p]}function Q(e,t,l=0,a=1){let n=[],s=6===t.length?"C":"Q",r={x:t[0],y:t[1]},i="C"===s?{x:t[2],y:t[3]}:r,u={x:t[4],y:t[5]},p=Math.max(u.x,e.x),h=Math.min(u.x,e.x),y=Math.max(u.y,e.y),o=Math.min(u.y,e.y),c=0;if(r.x<h||r.x>p||r.y<o||r.y>y||i.x<h||i.x>p||i.y<o||i.y>y){let p=I("C"===s?[e,r,i,u]:[e,r,u]).sort();if(p=p.filter(e=>e>l&&e<a),p.length){let l=function(e,t,l,a=!0){let n=[];if(!l.length)return!1;let s,r,i,u=t.length,p={x:t[u-2],y:t[u-1]};2===t.length?i=[e,p]:4===t.length?(s={x:t[0],y:t[1]},i=[e,s,p]):6===t.length&&(s={x:t[0],y:t[1]},r={x:t[2],y:t[3]},i=[e,s,r,p]);if(l.length)if(1===l.length){let e=T(i,l[0]),t=e[0],a=e[1];n.push(t,a)}else{let e=l[0],t=T(i,e),a=t[0];n.push(a),i=t[1];for(let t=1;t<l.length;t++){e=l[t-1];let a=T(i,(l[t]-e)/(1-e));n.push(a[0]),t===l.length-1&&n.push(a[a.length-1]),i=a[1]}}if(a){let e,t,l=[];return n.forEach(a=>{e={type:"",values:[]},a.shift(),t=a.map(e=>Object.values(e)).flat(),e.values=t,3===a.length?e.type="C":2===a.length?e.type="Q":1===a.length&&(e.type="L"),l.push(e)}),l}return n}(e,t,p);n.push(...l),c+=l.length}else n.push({type:s,values:t})}else n.push({type:s,values:t});return{pathData:n,count:c}}function F(e,t=0,l=1){let a=[e[0]],n={x:e[0].values[0],y:e[0].values[1]},s={x:e[0].values[0],y:e[0].values[1]},r=e.length;for(let i=1;r&&i<r;i++){let r=e[i],{type:u,values:p}=r,h=p.slice(-2);if(h[0],h[1],"C"!==u&&"Q"!==u)a.push(r);else if("C"===u||"Q"===u){let e=Q(n,p,t,l).pathData;a.push(...e)}n={x:h[0],y:h[1]},"z"===u.toLowerCase()?n=s:"M"===u&&(s={x:h[0],y:h[1]})}return a}function q(e,t=-1){let l=e.map(e=>e.x),a=e.map(e=>e.y),n=Math.min(...l),s=Math.max(...l),r=Math.min(...a),i=Math.max(...a),u={x:n,left:n,right:s,y:r,top:r,bottom:i,width:s-n,height:i-r};if(t>-1)for(let e in u)u[e]=+u[e].toFixed(t);return u}function D(e){let t=[];return e.forEach(e=>{let l=function(e){let t=function(e){let t=[];for(let l=0;l<e.length;l++){let a=e[l],n=l>0?e[l-1]:e[l],{type:s,values:r}=a,i={x:n.values[n.values.length-2],y:n.values[n.values.length-1]},u=r.length?{x:r[r.length-2],y:r[r.length-1]}:"",p=r.length?{x:r[0],y:r[1]}:"";switch(s){case"A":if("function"!=typeof arcToBezier){let e=A(i,u)/2,l=w(i,u,.5),a=S(l.x,l.y,e,e,0),n=S(l.x,l.y,e,e,Math.PI);t.push(a,n,u);break}arcToBezier(i,r).forEach(e=>{let l=e.values,a={x:l[0],y:l[1]},n={x:l[2],y:l[3]},s={x:l[4],y:l[5]};t.push(a,n,s)});break;case"C":let e={x:r[2],y:r[3]};t.push(p,e);break;case"Q":t.push(p)}"z"!==s.toLowerCase()&&t.push(u)}return t}(e),l=q(t);return l}(e);t.push(l)}),t}function B(e,t){let[l,a,n,s,r,i]=[e.x,e.y,e.width,e.height,e.x+e.width,e.y+e.height],[u,p,h,y,o,c]=[t.x,t.y,t.width,t.height,t.x+t.width,t.y+t.height],x=!1;return n*s!=h*y&&n*s>h*y&&l<u&&r>o&&a<p&&i>c&&(x=!0),x}function O(e,l=9){let a=0,n=[],r=E(e),u=r.length>1,p=[];if(u){let e=D(r);e.forEach(function(t,l){for(let l=0;l<e.length;l++){let a=e[l];if(t!=a){B(t,a)&&p.push(l)}}})}return r.forEach((e,l)=>{n=[];let r=0,u=0,h=1,y=[];e.forEach(function(l,a){let[u,p]=[l.type,l.values],h=p.length;if(p.length){let o=(a>0?e[a-1]:e[0]).values,c=o.length,x={x:o[c-2],y:o[c-1]},f={x:p[h-2],y:p[h-1]};if("C"===u||"Q"===u){let e={x:p[0],y:p[1]};y="C"===u?[x,e,{x:p[2],y:p[3]},f]:[x,e,f];let t=Math.abs(function(e,t=!1){let l,[a,n,s,r]=[e[0],e[1],e[2],e[e.length-1]];if(e.length<3)return 0;3===e.length&&(n={x:1*e[0].x/3+2*e[1].x/3,y:1*e[0].y/3+2*e[1].y/3},s={x:1*e[2].x/3+2*e[1].x/3,y:1*e[2].y/3+2*e[1].y/3});return l=3*(a.x*(-2*n.y-s.y+3*r.y)+n.x*(2*a.y-s.y-r.y)+s.x*(a.y+n.y-2*r.y)+r.x*(-3*a.y+n.y+2*s.y))/20,t?Math.abs(l):l}(y));r+=t,n.push(x,f)}else if("A"===u){let e=function(e,l,a,n,r,u,p,h,y){const o=(e,t,l,a)=>s(a-t,l-e);let c={cx:0,cy:0,rx:a=t(a),ry:n=t(n),startAngle:0,endAngle:0,deltaAngle:0,clockwise:p,xAxisRotation:r,largeArc:u,sweep:p};if(0==a||0==n)throw Error("rx and ry can not be 0");if(a===n){let t=Math.abs(h-e),a=Math.abs(y-l),n=t,s=Math.min(e,h),r=Math.min(l,y),i=.5*Math.PI;if(0===t&&a||0===a&&t)return n=0===t&&a?a/2:t/2,c.rx=n,c.ry=n,0===t&&a?(c.cx=e,c.cy=r+a/2,c.startAngle=l>y?i:-i,c.endAngle=l>y?-i:i,c.deltaAngle=p?Math.PI:-Math.PI):0===a&&t&&(c.cx=s+t/2,c.cy=l,c.startAngle=e>h?Math.PI:0,c.endAngle=e>h?-Math.PI:Math.PI,c.deltaAngle=p?Math.PI:-Math.PI),c}let x,f,d=a===n?0:r*m/180,M=d?g(d):0,b=d?i(d):1,A=(e-h)/2,C=(l-y)/2,w=(e+h)/2,P=(l+y)/2,S=d?b*A+M*C:A,L=d?b*C-M*A:C,I=S*S/(a*a)+L*L/(n*n);I>1&&(a*=v(I),n*=v(I),c.rx=a,c.ry=n);let k=a*n,$=a*L,z=n*S,E=$**2+z**2;if(!E)throw Error("start point can not be same as end point");let T=v(t((k*k-E)/E));u==p&&(T=-T);let Q=T*$/n,F=-T*z/a;x=d?b*Q-M*F+w:w+Q,f=d?M*Q+b*F+P:P+F,c.cy=f,c.cx=x;let q=o(x,f,e,l),D=o(x,f,h,y);!p&&D>q&&(D-=2*Math.PI),p&&q>D&&(D=D<=0?D+2*Math.PI:D);let B=D-q;return c.startAngle=q,c.endAngle=D,c.deltaAngle=B,c}(x.x,x.y,l.values[0],l.values[1],l.values[2],l.values[3],l.values[4],f.x,f.y),{cx:a,cy:u,rx:p,ry:h,startAngle:y,endAngle:o,deltaAngle:c}=e,d=Math.abs(function(e,t,l,a){const n=Math.PI*e*t;let s=(a-l+2*Math.PI)%(2*Math.PI);if(e===t)return n*(s/(2*Math.PI));const r=l=>Math.atan2(e*Math.sin(l),t*Math.cos(l));return l=r(l),a=r(a),s=(a-l+2*Math.PI)%(2*Math.PI),n*(s/(2*Math.PI))}(p,h,y,o));d-=Math.abs(j([x,{x:a,y:u},f])),n.push(x,f),r+=d}else n.push(x,f)}});let o=j(n);-1!==p.indexOf(l)&&(h=-1),u=o<0&&r<0?(Math.abs(r)-Math.abs(o))*h:(Math.abs(r)+Math.abs(o))*h,a+=u}),a}function j(e,t=!1){let l=0;for(let t=0,a=e.length;a&&t<a;t++){l+=e[t].x*e[t===e.length-1?0:t+1].y*.5-e[t===e.length-1?0:t+1].x*e[t].y*.5}return t&&(l=Math.abs(l)),l}function N(e,t=0){t=parseFloat(t);let l=e.length,a=t>1,n=!a&&!t,s="",r=a?"\n":n?"":" ",i=n?"":" ";s=`${e[0].type}${i}${e[0].values.join(" ")}${r}`;for(let t=1;t<l;t++){let l=e[t-1],a=e[t],{type:u,values:p}=a;if(!n||"A"!==u&&"a"!==u||(p=[p[0],p[1],p[2],`${p[3]}${p[4]}${p[5]}`,p[6]]),u=l.type===a.type&&"m"!==a.type.toLowerCase()&&n||"M"===l.type&&"L"===a.type&&n?" ":a.type,n){let e="",t=!1;for(let l=0,a=p.length;l<a;l++){let a=p[l],n=a.toString(),s=n.includes(".")&&Math.abs(a)<1;s&&t&&(n=n.replace(/^0\./,".")),!(l>0)||t&&s||(e+=" "),e+=n,t=s}s+=`${u}${i}${e}${r}`}else s+=`${u}${i}${p.join(" ")}${r}`}return n&&(s=s.replace(/ 0\./g," .").replace(/ -/g,"-").replace(/-0\./g,"-.").replace(/Z/g,"z")),s}function V(e,t,l=!1,a=1){let n=[e,t],s=function(e,t){let l=b(e.p0,e.cp1,t.cp2,t.p,!1),a=b(l,t.p,t.p0,t.cp1,!1),n=A(l,t.p),s=A(a,t.p),r=1-s/n,i=A(e.cp2,e.p),u=A(e.cp2,t.cp1);return r=Math.min(i)/u,r}(e,t),r=z(e.p0,e.p),i=z(t.p0,t.p),u=.05*Math.min(r,i)*a,p=function(e,t,l=0,a=0){let{p0:n,cp1:s}=e,{p:r,cp2:i}=t,u={x:(s.x-(1-l)*n.x)/l,y:(s.y-(1-l)*n.y)/l},p={x:(i.x-a*r.x)/(1-a),y:(i.y-a*r.y)/(1-a)},h={p0:n,cp1:u,cp2:p,p:r};return h}(e,t,s,s),h=P([p.p0,p.cp1,p.cp2,p.p],s),y=z(e.p,h),o=0,c=0,x=!1,f=y;if(y<u){let l=.5*(1+s);if(o=z(P([t.p0,t.cp1,t.cp2,t.p],.5),P([p.p0,p.cp1,p.cp2,p.p],l)),f+=o,o<u){let t=.5*s;c=z(P([e.p0,e.cp1,e.cp2,e.p],.5),P([p.p0,p.cp1,p.cp2,p.p],t)),o+c<u&&(x=!0),f+=c}}if(l&&!x){let l=function(e,t,l=0,a=1){const n=(e,t,l,a,n)=>{let s=1-n;return{x:3*s*s*(t.x-e.x)+6*s*n*(l.x-t.x)+3*n*n*(a.x-l.x),y:3*s*s*(t.y-e.y)+6*s*n*(l.y-t.y)+3*n*n*(a.y-l.y)}};let s=[e,t],r=C(e.p0,e.p)>C(t.p0,t.p),i=JSON.parse(JSON.stringify(e)),u=JSON.parse(JSON.stringify(t)),p=b(i.p0,i.cp1,u.p,u.cp2,!1);if(!p)return s;if(r){let l={p0:{x:e.p.x,y:e.p.y},cp1:{x:e.cp2.x,y:e.cp2.y},cp2:{x:e.cp1.x,y:e.cp1.y},p:{x:e.p0.x,y:e.p0.y}};e={p0:{x:t.p.x,y:t.p.y},cp1:{x:t.cp2.x,y:t.cp2.y},cp2:{x:t.cp1.x,y:t.cp1.y},p:{x:t.p0.x,y:t.p0.y}},t=l}let h=(e,t)=>({x:e.x-t.x,y:e.y-t.y}),y=(e,t)=>({x:e.x*t,y:e.y*t}),o=(e,t)=>e.x*t.x+e.y*t.y,c=t.p0,x=n(t.p0,t.cp1,t.cp2,t.p,0),f=o(h(e.p0,c),x)/o(x,x),g=P([t.p0,t.cp1,t.cp2,t.p],f),v=n(t.p0,t.cp1,t.cp2,t.p,f);f-=o(h(g,e.p0),v)/o(v,v);let d=P([t.p0,t.cp1,t.cp2,t.p],f),m=t.p,M=n(t.p0,t.cp1,t.cp2,t.p,f),A=n(t.p0,t.cp1,t.cp2,t.p,1),S=1-f,L=(I=d,k=y(M,S/3),{x:I.x+k.x,y:I.y+k.y});var I,k;let $=h(m,y(A,S/3)),E={p0:d,cp1:L,cp2:$,p:m};r&&(E={p0:m,cp1:$,cp2:L,p:d});let T=P([E.p0,E.cp1,E.cp2,E.p],.5,!1,!0),Q=T.cpts[2],F=b(T,Q,E.p0,p,!1),q=b(T,Q,E.p,p,!1),D=w(E.p0,F,1.333),B=w(E.p,q,1.333);if(b(i.p0,D,u.p,B,!0))return s;E.cp1=D,E.cp2=B;let j=z(i.p0,E.p0)+z(u.p,E.p);if(E.p0=i.p0,E.p=u.p,E.extreme=u.extreme,E.corner=u.corner,E.dimA=u.dimA,E.directionChange=u.directionChange,E.values=[E.cp1.x,E.cp1.y,E.cp2.x,E.cp2.y,E.p.x,E.p.y],j<l){let e=O([{type:"M",values:[i.p0.x,i.p0.y]},{type:"C",values:[i.cp1.x,i.cp1.y,i.cp2.x,i.cp2.y,i.p.x,i.p.y]},{type:"C",values:[u.cp1.x,u.cp1.y,u.cp2.x,u.cp2.y,u.p.x,u.p.y]}]),t=[{type:"M",values:[E.p0.x,E.p0.y]},{type:"C",values:[E.cp1.x,E.cp1.y,E.cp2.x,E.cp2.y,E.p.x,E.p.y]}],l=O(t),n=Math.abs(l/e-1);E.error=10*n*a,N(t),n<.01&&(s=[E])}return s}(e,t,u,a);1===l.length&&(x=!0,p=l[0],f=p.error)}return x&&(p.p0=e.p0,p.p=t.p,p.dimA=z(p.p0,p.p),p.type="C",p.extreme=t.extreme,p.directionChange=t.directionChange,p.corner=t.corner,p.values=[p.cp1.x,p.cp1.y,p.cp2.x,p.cp2.y,p.p.x,p.p.y],p.error=f/u,n=[p]),n}function H(e=[]){let t,l=[],a=function(e){let t=[],l={x:e[0].values[0],y:e[0].values[1]};return e.forEach(e=>{let{type:a,values:n}=e;if(n.length){let e=n.length>1?{x:n[n.length-2],y:n[n.length-1]}:"V"===a?{x:l.x,y:n[0]}:{x:n[0],y:l.y};t.push(e),l=e}}),t}(e),n=q(a),{left:s,right:r,top:i,bottom:u,width:p,height:h}=n,y=e[0].values[0],o=e[0].values[1],c={x:e[0].values[0],y:e[0].values[1]},x={x:e[0].values[0],y:e[0].values[1]};e[0].idx=0,e[0].p0=c,e[0].p=c,e[0].lineto=!1,e[0].corner=!1,e[0].extreme=!1,e[0].directionChange=!1,e[0].closePath=!1,e[0].dimA=0;let f=[e[0]],g=0,v=e.length;for(let l=2;v&&l<=v;l++){let a=e[l-1],{type:n,values:p}=a,h=p.slice(-2),v=[x],d=!1;a.idx=l-1,a.lineto=!1,a.corner=!1,a.extreme=!1,a.directionChange=!1,a.closePath=!1,a.dimA=0;let m,b,A,w,P,S,I,$=.05;t=h.length?{x:h[0],y:h[1]}:c,"M"===n?(c=t,x=t):"z"===n.toLowerCase()&&(t=c),a.p0=x,a.p=t;let E=z(x,t);if(a.dimA=E,"L"===n&&(a.lineto=!0),"Z"===n&&(a.closePath=!0,c.x!==y&&c.y!==o&&(a.lineto=!0)),"Q"!==n&&"C"!==n||(m={x:p[0],y:p[1]},b="C"===n?{x:p[2],y:p[3]}:null,a.cp1=m,b&&(a.cp2=b)),p.length>2){"Q"!==n&&"C"!==n||v.push(m),"C"===n&&v.push(b),v.push(t),d=k(v).flat,a.flat=d,d&&(a.extreme=!1)}d||"L"===n||t.x!==s&&t.y!==i&&t.x!==r&&t.y!==u||(a.extreme=!0);let T=e[l]?e[l]:null,Q=T?T.values.slice(-2):null;S=T?T.type:null,!T||"Q"!==T.type&&"C"!==T.type||(P=T?{x:Q[0],y:Q[1]}:null,A={x:T.values[0],y:T.values[1]},w="C"===T.type?{x:T.values[2],y:T.values[3]}:null),I=j(v);let F=g<0&&I>0||g>0&&I<0;if(g=I,F&&(a.directionChange=!0),("Q"===n||"C"===n)&&("Q"===n&&"Q"===S||"C"===n&&"C"===S)){let e=v.slice(1),l=k("C"===n?[t,A,w,P]:[t,A,P],((P?Math.abs(P.x-x.x):0)+(P?Math.abs(P.y-x.y):0))/2*.1).flat;if((!d||!l)&&(!!a.extreme||L(0,e,$)))a.extreme=!0;else{let e=b?[b,t]:[m,t],l=[t,A],n=M(...e,!0),s=M(...l,!0),r=180*Math.abs(n-s)/Math.PI,i=C(...e),u=C(...l);r>10&&i&&u&&(a.corner=!0)}}f.push(a),x=t}return l={pathData:f,bb:n,dimA:(p+h)/2},l}function Z(e,t=-1){let l=!("auto"!=t||!e[0].hasOwnProperty("decimals"));for(let a=0,n=e.length;a<n;a++){let n=e[a];(t>-1||l)&&(t=l?n.decimals:t,e[a].values=n.values.map(e=>e?+e.toFixed(t):e))}return e}function R(e={},t={},l={},a={}){let n=w(e,t,1.5),s=w(a,l,1.5),r=.01*z(e,a),i=z(n,s),u=null,p="C",h=[t.x,t.y,l.x,l.y,a.x,a.y];return i<r&&(u=b(e,t,a,l,!1),u&&(p="Q",h=[u.x,u.y,a.x,a.y])),{type:p,values:h}}function J(e,{toShorthands:t=!0,toRelative:l=!0,decimals:a=3}={}){return t&&(e=function(e,t=-1,l=!0){let a;if(l){let t=e.map(e=>e.type).join("");a=/[astvqmhlc]/g.test(t)}e=l&&a?X(e,t):e;let n={type:"M",values:e[0].values};e[0].decimals&&(n.decimals=e[0].decimals);let s,r=[n],i={x:e[0].values[0],y:e[0].values[1]},u=.01;for(let l=1,a=e.length;l<a;l++){let a=e[l],{type:p,values:h}=a,y=h.slice(-2),o=e[l-1],c=o.type;s={x:y[0],y:y[1]};let x,f,g,v,d={x:h[0],y:h[1]},m=Math.abs(s.x-i.x),M=Math.abs(s.y-i.y),b=(m+M)/2*u;switch(p){case"L":n=0===M||M<b&&m>b?{type:"H",values:[h[0]]}:0===m||M>b&&m<b?{type:"V",values:[h[1]]}:a;break;case"Q":if("Q"!==c){i={x:y[0],y:y[1]},r.push(a);continue}let e={x:o.values[0],y:o.values[1]};v={x:2*i.x-e.x,y:2*i.y-e.y},x=Math.abs(d.x-v.x),f=Math.abs(d.y-v.y),g=(x+f)/2,n=g<b?{type:"T",values:[s.x,s.y]}:a;break;case"C":let t={x:h[2],y:h[3]};if("C"!==c){r.push(a),i={x:y[0],y:y[1]};continue}let l={x:o.values[2],y:o.values[3]};v={x:2*i.x-l.x,y:2*i.y-l.y},x=Math.abs(d.x-v.x),f=Math.abs(d.y-v.y),g=(x+f)/2,n=g<b?{type:"S",values:[t.x,t.y,s.x,s.y]}:a;break;default:n={type:p,values:h}}(a.decimals||0===a.decimals)&&(n.decimals=a.decimals),t>-1&&(n.values=n.values.map(e=>+e.toFixed(t))),i={x:y[0],y:y[1]},r.push(n)}return r}(e)),e=Z(e,a),l&&(e=function(e,t=-1){return W(e,!0,t)}(e)),a>-1&&(e=Z(e,a)),e}function U(e,t){Array.isArray(e)&&(e={x:e[0],y:e[1]});let l={x:e.x+2/3*(t[0]-e.x),y:e.y+2/3*(t[1]-e.y)},a={x:t[2]+2/3*(t[0]-t[2]),y:t[3]+2/3*(t[1]-t[3])};return{type:"C",values:[l.x,l.y,a.x,a.y,t[2],t[3]]}}function W(e,t=!1,l=-1){l>=0&&(e[0].values=e[0].values.map(e=>+e.toFixed(l)));let a=e[0].values,n=a[0],s=a[1],r=n,i=s;for(let a=1,u=e.length;a<u;a++){let u=e[a],{type:p,values:h}=u,y=t?p.toLowerCase():p.toUpperCase();if(p!==y)switch(p=y,u.type=p,p){case"a":case"A":h[5]=t?h[5]-n:h[5]+n,h[6]=t?h[6]-s:h[6]+s;break;case"v":case"V":h[0]=t?h[0]-s:h[0]+s;break;case"h":case"H":h[0]=t?h[0]-n:h[0]+n;break;case"m":case"M":t?(h[0]-=n,h[1]-=s):(h[0]+=n,h[1]+=s),r=t?h[0]+n:h[0],i=t?h[1]+s:h[1];break;default:if(h.length)for(let e=0;e<h.length;e++)h[e]=t?h[e]-(e%2?s:n):h[e]+(e%2?s:n)}let o=h.length;switch(p){case"z":case"Z":n=r,s=i;break;case"h":case"H":n=t?n+h[0]:h[0];break;case"v":case"V":s=t?s+h[0]:h[0];break;case"m":case"M":r=h[o-2]+(t?n:0),i=h[o-1]+(t?s:0);default:n=h[o-2]+(t?n:0),s=h[o-1]+(t?s:0)}l>=0&&(u.values=u.values.map(e=>+e.toFixed(l)))}return e}function X(e,t=-1){return W(e,!1,t)}function G(e,t,l=1){const a=2*Math.PI;let[n,s,r,i,u,p,h]=t;if(0===n||0===s)return[];let y=r?r*a/360:0,o=y?Math.sin(y):0,c=y?Math.cos(y):1,x=c*(e.x-p)/2+o*(e.y-h)/2,f=-o*(e.x-p)/2+c*(e.y-h)/2;if(0===x&&0===f)return[];n=Math.abs(n),s=Math.abs(s);let g=x*x/(n*n)+f*f/(s*s);if(g>1){let e=Math.sqrt(g);n*=e,s*=e}let v=n*n,d=n===s?v:s*s,m=x*x,M=f*f,b=v*d-v*M-d*m;b<=0?b=0:(b/=v*M+d*m,b=Math.sqrt(b)*(i===u?-1:1));let A=b?b*n/s*f:0,C=b?b*-s/n*x:0,w=c*A-o*C+(e.x+p)/2,P=o*A+c*C+(e.y+h)/2,S=(x-A)/n,L=(f-C)/s,I=(-x-A)/n,k=(-f-C)/s;const $=(e,t,l,a)=>{let n=+(e*l+t*a).toFixed(9);return 1===n||-1===n?1===n?0:Math.PI:(n=n>1?1:n<-1?-1:n,(e*a-t*l<0?-1:1)*Math.acos(n))};let z=$(1,0,S,L),E=$(S,L,I,k);0===u&&E>0?E-=2*Math.PI:1===u&&E<0&&(E+=2*Math.PI);let T=(+(Math.abs(E)/(a/4)).toFixed(0)||1)*l;E/=T;let Q=[];const F=1.5707963267948966,q=.551785;let D=E===F?q:E===-F?-q:4/3*Math.tan(E/4),B=E?Math.cos(E):1,O=E?Math.sin(E):0;const j=(e,t,l,a,n)=>{let s=e!=t?Math.cos(e):a,r=e!=t?Math.sin(e):n,i=Math.cos(e+t),u=Math.sin(e+t);return[{x:s-r*l,y:r+s*l},{x:i+u*l,y:u-i*l},{x:i,y:u}]};for(let e=0;e<T;e++){let e={type:"C",values:[]};j(z,E,D,B,O).forEach(t=>{let l=t.x*n,a=t.y*s;e.values.push(c*l-o*a+w,o*l+c*a+P)}),Q.push(e),z+=E}return Q}function Y(e,t,l,a,n=7.5){let s={type:"C",values:[t.x,t.y,l.x,l.y,a.x,a.y]},r=0,i=!1,u=M(e,t,!0),p=M(a,l,!0),h=180*Math.abs(u-p)/Math.PI;if(Math.abs(h%180-90)<3){let u=b(e,t,a,l,!1);if(u){let p=A(e,u),h=A(a,u),y=+Math.max(p,h).toFixed(8),o=+Math.min(p,h).toFixed(8),c=o,x=y,f=j([e,t,l,a])<0?0:1,g=Math.abs(a.x-e.x)>Math.abs(a.y-e.y);100/c*Math.abs(c-x)<5&&(c=y,x=c),g&&(c=y,x=o);let v=O([{type:"M",values:[e.x,e.y]},{type:"C",values:[t.x,t.y,l.x,l.y,a.x,a.y]}]),d={type:"A",values:[c,x,0,0,f,a.x,a.y]};r=Math.PI*(c*x)/4,r-=Math.abs(j([e,a,u])),function(e,t){let l=Math.abs(e-t);return Math.abs(100-100/e*(e+l))}(v,r)<n&&(i=!0,s=d)}}return{com:s,isArc:i,area:r}}function K(e){let t,l=[[]],a=0,n=[[]],s={x:e[0].values[0],y:e[0].values[1]};for(let r=0,i=e.length;r<i;r++){let i=e[r],{type:u,values:p}=i;if("A"===u){let u=e[r-1].values.slice(-2);s={x:u[0],y:u[1]};let[h,y,o,c,x,f,g]=p,v=100/h*Math.abs(h-y)<5;t={x:p[5],y:p[6]},i.p0=s,i.p=t,i.circular=v;let d=e[r+1];if(!l[a].length&&d&&"A"===d.type&&(l[a].push(i),n[a].push(r)),d&&"A"===d.type){let[e,i,u,p,o,c,x]=d.values,f=h!=e?100/h*Math.abs(h-e):0,g=y!=i?100/y*Math.abs(y-i):0;t={x:d.values[5],y:d.values[6]},d.p0=s,d.p=t,f<5&&g<5?(l[a].push(d),n[a].push(r+1)):(l.push([]),n.push([]),a++)}else l.push([]),n.push([]),a++}}if(!n.length)return e;l=l.filter(e=>e.length),n=n.filter(e=>e.length);for(let t=l.length-1;t>=0;t--){const a=l[t],s=n[t][0],r=a.length;let i=0,u=0;a.forEach(({values:e})=>{const[t,l]=e;i+=t,u+=l}),i/=r,u/=r;let p=100/i*Math.abs(i-u)<5;p&&(i=(i+u)/2,u=i);let h=e[s-1].values.slice(-2);if(h[0],h[1],4===r){let[t,l,n,h,y,o,c]=a[1].values,[,,,,,x,f]=a[3].values;p&&(i=1,u=1);let g={type:"A",values:[i,u,n,h,y,o,c]},v={type:"A",values:[i,u,n,h,y,x,f]};e.splice(s,r,g,v)}else if(3===r){let[t,l,n,p,h,y,o]=a[0].values,[c,x,,,,f,g]=a[2].values;p=1;let v={type:"A",values:[i,u,n,p,h,f,g]};e.splice(s,r,v)}else if(2===r){let[t,l,n,h,y,o,c]=a[0].values,[x,f,,,,g,v]=a[1].values;p&&(i=1,u=1,n=0);let{p0:d,p:m}=a[0],[M,b]=[a[1].p0,a[1].p];if(d.x!==b.x||d.y!==b.y){let t={type:"A",values:[i,u,n,h,y,g,v]};e.splice(s,r,t)}}}return e}function _(e=[],{toAbsolute:t=!0,toLonghands:l=!0,quadraticToCubic:a=!1,arcToCubic:n=!1,arcAccuracy:s=2}={},{hasRelatives:r=!0,hasShorthands:i=!0,hasQuadratics:u=!0,hasArcs:p=!0,testTypes:h=!1}={}){if(h){let t=Array.from(new Set(e.map(e=>e.type))).join("");r=/[lcqamts]/gi.test(t),u=/[qt]/gi.test(t),p=/[a]/gi.test(t),i=/[vhst]/gi.test(t),isPoly=/[mlz]/gi.test(t)}return(u&&a||p&&n)&&(l=!0,t=!0),r&&t&&(e=W(e,!1)),i&&l&&(e=function(e,t=-1,l=!0){let a=!1;if(l){let t=e.map(e=>e.type).join(""),l=/[hstv]/gi.test(t);if(a=/[astvqmhlc]/g.test(t),!l)return e}let n=[],s={type:"M",values:(e=l&&a?X(e,t):e)[0].values};n.push(s);for(let l=1,a=e.length;l<a;l++){let a,r,i,u,p,h,y,o,c=e[l],{type:x,values:f}=c,g=f.length,v=s.values,d=v.length,[m,M]=[f[g-2],f[g-1]],[b,A]=[v[d-2],v[d-1]];switch(x){case"H":s={type:"L",values:[f[0],A]};break;case"V":s={type:"L",values:[b,f[0]]};break;case"T":[a,r]=[v[0],v[1]],[b,A]=[v[d-2],v[d-1]],i=b+(b-a),u=A+(A-r),s={type:"Q",values:[i,u,m,M]};break;case"S":[a,r]=[v[0],v[1]],[b,A]=[v[d-2],v[d-1]],[y,o]=d>2&&"A"!==s.type?[v[2],v[3]]:[b,A],i=2*b-y,u=2*A-o,p=f[0],h=f[1],s={type:"C",values:[i,u,p,h,m,M]};break;default:s={type:x,values:f}}t>-1&&(s.values=s.values.map(e=>+e.toFixed(t))),n.push(s)}return n}(e,-1,!1)),p&&n&&(e=function(e,{arcAccuracy:t=1}={}){let l=[e[0]];for(let a=1,n=e.length;a<n;a++){let n=e[a],s=e[a-1].values,r=s.length,i={x:s[r-2],y:s[r-1]};"A"===n.type?G(i,n.values,t).forEach(e=>{l.push(e)}):l.push(n)}return l}(e,s)),u&&a&&(e=function(e){let t=[e[0]];for(let l=1,a=e.length;l<a;l++){let a=e[l],n=e[l-1].values,s=n.length,r={x:n[s-2],y:n[s-1]};"Q"===a.type?t.push(U(r,a.values)):t.push(a)}return t}(e)),e}function ee(e,{toAbsolute:t=!0,toLonghands:l=!0,quadraticToCubic:a=!1,arcToCubic:n=!1,arcAccuracy:s=4}={}){let r=function(e,t=!0){if(e=e.trim(),""===e)return{pathData:[],hasRelatives:!1,hasShorthands:!1,hasQuadratics:!1,hasArcs:!1};const l=new Set([5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279]),a=e=>32===e||44===e||10===e||13===e||8232===e||8233===e||9===e||11===e||12===e||160===e||e>=5760&&l.has(e);let n,s=0,r=e.length,i="",u=[],p=-1,h="",y=!1,o=0,c=0,x=0,f=!1,g=new Set([]),v=[];const d=()=>{f&&("M"===i?i="L":"m"===i&&(i="l"),u.push({type:i,values:[]}),p++,c=0,f=!1)},m=(e=!1)=>{(e?o>0:""!==h)&&(t&&-1===p&&(n="Pathdata must start with M command",v.push(n),i="M",u.push({type:i,values:[]}),x=2,c=0,p++),"A"===i||"a"===i?(h=M(),u[p].values.push(...h)):(t&&h[1]&&"."!==h[1]&&"0"===h[0]&&(n=`${p}. command: Leading zeros not valid: ${h}`,v.push(n)),u[p].values.push(+h)),c++,h="",o=0,f=c>=x)},M=()=>{let e=h.length,t=!1;return 3===c&&2===e||4===c&&e>1?(h=[+h[0],+h[1]],t=!0,c++):3===c&&e>=3&&(h=[+h[0],+h[1],+h.substring(2)],t=!0,c+=2),t?h:[+h]},b=()=>{if(p>0){let e=u[p].values.length;if(e&&e<x||e&&e>x||("z"===i||"Z"===i)&&e>0){n=`${p}. command of type "${i}": ${x-e} values too few - ${x} expected`,v[v.length-1]!==n&&v.push(n)}}};let A=!1,C=!1,w=!1;for(;s<r;){let l=e.charCodeAt(s),r=l>47&&l<58;if(r||(A=101===l||69===l,C=45===l||43===l,w=46===l),r||C||w||A){if(y||45!==l&&46!==l)d();else{let e=46===l;m(e),d(),e&&o++}h+=e[s],y=A,s++}else if((l<48||l>5759)&&a(l))m(),s++;else{if(l>64){if(!te.has(l)){n=`${p}. command "${e[s]}" is not a valid type`,v.push(n),s++;continue}""!==h&&(u[p].values.push(+h),c++,h=""),t&&b(),i=e[s],x=le[l];let a="M"===i||"m"===i,r=p>0&&("z"===u[p].type||"Z"===u[p].type);g.add(i),r&&!a&&(u.push({type:"m",values:[0,0]}),p++),u.push({type:i,values:[]}),p++,o=0,c=0,f=!1,s++;continue}r||(n=`${p}. ${e[s]} is not a valid separarator or token`,v.push(n),h=""),s++}}m(),t&&b();if(t&&v.length){if(n="Invalid path data:\n"+v.join("\n"),"log"!==t)throw new Error(n);console.log(n)}u[0].type="M";let P=Array.from(g).join(""),S=/[lcqamts]/g.test(P),L=/[vhst]/gi.test(P),I=/[a]/gi.test(P),k=/[qt]/gi.test(P);return{pathData:u,hasRelatives:S,hasShorthands:L,hasQuadratics:k,hasArcs:I}}(e),{hasRelatives:i,hasShorthands:u,hasQuadratics:p,hasArcs:h}=r,y=r.pathData;return y=_(y,{toAbsolute:t,toLonghands:l,quadraticToCubic:a,arcToCubic:n,arcAccuracy:s},{hasRelatives:i,hasShorthands:u,hasQuadratics:p,hasArcs:h}),y}const te=new Set([77,109,65,97,67,99,76,108,81,113,83,115,84,116,72,104,86,118,90,122]),le=new Uint8Array(128);function ae(e,t=1,l=!0){let a=[e[0]],n={x:e[0].values[0],y:e[0].values[1]},s=n,r=n;e[e.length-1].type.toLowerCase();for(let i=1,u=e.length;i<u;i++){let p=e[i-1],h=e[i],y=e[i+1]||e[u-1],o="z"===y.type.toLowerCase()?n:{x:y.values[y.values.length-2],y:y.values[y.values.length-1]},{type:c,values:x}=h,f=x.slice(-2);r="Z"!==c?{x:f[0],y:f[1]}:n;let g=j([s,r,o],!0)<C(s,o)/100*t,v=!1;if(l||"C"!==c||(g=!1),l&&("C"===c||"Q"===c)){v=$(s,"C"===c?[{x:x[0],y:x[1]},{x:x[2],y:x[3]}]:"Q"===c?[{x:x[0],y:x[1]}]:[],r),v&&i<u-1&&"C"!==p.type&&(c="L",h.type="L",h.values=f)}s=r,g&&i<u-1&&("L"===c||l&&v)||("M"===c?(n=r,s=n):"Z"===c&&(s=n),a.push(h))}return a}function ne(e){let t={x:e[0].values[0],y:e[0].values[1]},l=t,a=[e[0]];for(let n=1,s=e.length;n<s;n++){let s=e[n],{type:r,values:i}=s,u=i.slice(-2);l={x:u[0],y:u[1]},"L"===r&&l.x===t.x&&l.y===t.y||(a.push(s),t=l)}return a}function se(e){let t=e.length;if(!("z"===e[t-1].type.toLowerCase()))return e;let l=0,a=[];for(let l=0;l<t;l++){let t=e[l],{type:n,values:s}=t,r=s.length;if(r){let e={type:n,x:s[r-2],y:s[r-1],index:0};e.index=l,a.push(e)}}return a=a.sort((e,t)=>+e.y.toFixed(3)-+t.y.toFixed(3)||e.x-t.x),l=a[0].index,l?function(e,t){let l=e.length,a=0,n=e[l-1].type,s="z"===n.toLowerCase();if(!s||t<1||e.length<3)return e;let r=s?1:0;(function(e){let t=e.length,l="z"===e[t-1].type.toLowerCase(),a=e[0],[n,s]=[a.values[0],a.values[1]].map(e=>+e.toFixed(8)),r=l?e[t-2]:e[t-1],i=r.values.length,[u,p]=[r.values[i-2],r.values[i-1]].map(e=>+e.toFixed(8));!l||n==u&&s==p||(e.pop(),e.push({type:"L",values:[n,s]},{type:"Z",values:[]}))})(e),a=t+1<e.length-1?t+1:e.length-1-r;let i=e.slice(a),u=e.slice(0,a);u.shift();let p,h,y=u.length;p=u[y-1].values||[],h=[p[p.length-2],p[p.length-1]],r&&(i.pop(),u.push({type:"Z",values:[]}));return e=[{type:"M",values:h},...i,...u],e}(e,l):e}function re(e,{arcToCubic:t=!1,quadraticToCubic:l=!1,toClockwise:a=!1,returnD:n=!1}={}){const s=(e,t)=>{let l=[],a=[];if("A"!==e){for(let e=0;e<t.length;e+=2)l.push([t[e],t[e+1]]);a=l.pop(),l.reverse()}else{let e=0==t[4]?1:0;l=[t[0],t[1],t[2],t[3],e],a=[t[5],t[6]]}return{controlPoints:l,endPoints:a}};let r=[],i="z"===e[e.length-1].type.toLowerCase();i&&(e=(e=>{let t="z"===e[e.length-1].type.toLowerCase(),l=e[0],[a,n]=[l.values[0],l.values[1]],s=t?e[e.length-2]:e[e.length-1],[r,i]=[s.values[s.values.length-2],s.values[s.values.length-1]];return!t||a==r&&n==i||(e.pop(),e.push({type:"L",values:[a,n]},{type:"Z",values:[]})),e})(e),e.pop());let u=e[e.length-1].values,p=u.length,h=i?e[0]:{type:"M",values:[u[p-2],u[p-1]]};r.push(h),e.reverse();for(let t=1;t<e.length;t++){let l=e[t],a=l.type,n=l.values,i=e[t-1],u=i.type,p=[];p=[s(u,i.values).controlPoints,s(a,n).endPoints].flat(),r.push({type:u,values:p.flat()})}return i&&r.push({type:"z",values:[]}),r}function ie(e,{returnDom:t=!1,removeHidden:l=!0,removeUnused:a=!0}={}){e=(e=e.replace(/<\?xml[\s\S]*?\?>/gi,"").replace(/<!DOCTYPE[\s\S]*?>/gi,"").replace(/<!--[\s\S]*?-->/g,"").trim()).replaceAll("xlink:href=","href=");let n=(new DOMParser).parseFromString(e,"text/html").querySelector("svg");!function(e,t=["viewBox","xmlns","width","height","id","class"]){[...e.attributes].map(e=>e.name).forEach(l=>{t.includes(l)||e.removeAttribute(l)})}(n,["viewBox","xmlns","width","height","id","class"]);let s=["metadata","script"];if(n.querySelectorAll("*").forEach(e=>{let t=e.nodeName,a=e.getAttribute("style")||"",n=!!a&&a.trim().includes("display:none"),r=e.getAttribute("display")&&"none"===e.getAttribute("display")||n;t.includes(":")||s.includes(t)||l&&r?e.remove():function(e){let t=[...e.attributes].map(e=>e.name);t.forEach(t=>{t.includes(":")&&e.removeAttribute(t)})}(e)}),t)return n;let r=function(e){let t=(new XMLSerializer).serializeToString(e);return t=t.replace(/\t/g,"").replace(/[\n\r|]/g,"\n").replace(/\n\s*\n/g,"\n").replace(/ +/g," "),t}(n);return console.log(r),r}function ue(e="",{toAbsolute:t=!0,toRelative:l=!0,toShorthands:a=!0,decimals:n=3,quadraticToCubic:s=!0,arcToCubic:r=!1,cubicToArc:i=!1,arcAccuracy:u=4,keepExtremes:p=!0,keepCorners:h=!0,keepInflections:y=!0,extrapolateDominant:o=!1,addExtremes:c=!1,optimizeOrder:x=!0,removeColinear:f=!0,simplifyBezier:g=!0,autoAccuracy:v=!0,flatBezierToLinetos:d=!0,revertToQuadratics:m=!0,minifyD:M=0,tolerance:b=1,reverse:A=!1,removeHidden:C=!0,removeUnused:w=!0,getObject:P=!1}={}){b=Math.max(.1,b);let S=function(e){let t="string";if(e instanceof HTMLImageElement)return"img";if(e instanceof SVGElement)return"svg";if(e instanceof HTMLCanvasElement)return"canvas";if(e instanceof File)return"file";if(e instanceof ArrayBuffer)return"buffer";if(e instanceof Blob)return"blob";if(Array.isArray(e))return"array";if("string"==typeof e){let l=(e=e.trim()).includes("<svg")&&e.includes("</svg"),a=e.startsWith("M")||e.startsWith("m"),n=!isNaN(e.substring(0,1))&&!isNaN(e.substring(e.length-1,e.length));if(l)t="svgMarkup";else if(a)t="pathDataString";else if(n)t="polyString";else{let l=/^(file:|https?:\/\/|\/|\.\/|\.\.\/)/.test(e),a=e.startsWith("data:image");t=l||a?"url":"string"}return t}return t=typeof e,(e.constructor.name||t).toLowerCase()}(e),L="",I=0,k=0,$=0,T={},Q="",q="svgMarkup"===S?1:0,D=[];if(I=new Blob([e]).size,q){L=ie(e,{returnDom:!0,removeHidden:C,removeUnused:w}),L.querySelectorAll("path").forEach(e=>{D.push({d:e.getAttribute("d"),el:e})})}else"pathDataString"===S?Q=e:"polyString"===S&&(Q="M"+e),D.push({d:Q,el:null});return D.forEach(e=>{let{d:u,el:C}=e,w=ee(u,{quadraticToCubic:s,toAbsolute:t,arcToCubic:r}),P=JSON.parse(JSON.stringify(w)),S=w.length,L=E(P),T=[];for(let e=0,t=L.length;e<t;e++){let t=L[e];A&&(t=re(t)),f&&(t=ne(t)),c&&(t=F(t,0,1)),x&&(t=se(t)),f&&(t=ae(t,b,d));let l=H(t),{pathData:a,bb:n,dimA:s}=l;if(a=g?pe(a,{simplifyBezier:g,keepInflections:y,keepExtremes:p,keepCorners:h,extrapolateDominant:o,revertToQuadratics:m,tolerance:b,reverse:A}):a,i){let e=3;a.forEach((t,l)=>{let{type:n,values:s,p0:r,cp1:i=null,cp2:u=null,p:p=null}=t;if("C"===n){let t=Y(r,i,u,p,e);t.isArc&&(a[l]=t.com)}}),a=K(a)}m&&a.forEach((e,t)=>{let{type:l,values:n,p0:s,cp1:r=null,cp2:i=null,p:u=null}=e;if("C"===l){let e=R(s,r,i,u);"Q"===e.type&&(a[t]=e)}}),T.push(a)}P=T.flat(),v&&(n=function(e){let t={x:e[0].values[0],y:e[0].values[1]},l=t,a=t;e[0].decimals=0;let n=new Set;for(let s=0,r=e.length;s<r;s++){let r=e[s],{type:i,values:u}=r,p=u.length?u.slice(-2):[t.x,t.y];a={x:p[0],y:p[1]};let h=r.dimA?+r.dimA.toFixed(8):"M"!==i?+z(l,a).toFixed(8):0;h&&n.add(h),"M"===i&&(t=a),l=a}let s=Array.from(n).sort(),r=Math.ceil(s.length/8);s=s.slice(0,r);let i=s.reduce((e,t)=>e+t,0)/r,u=i>50?0:Math.floor(50/i).toString().length;return Math.min(Math.max(0,u),8)}(P)),P=J(P,{toRelative:l,toShorthands:a,decimals:n});let Q=[];P.forEach((e,t)=>{let{type:l,values:a}=e;if("l"===l||"v"===l||"h"===l){("l"===l?"00"!==a.join(""):0!==a[0])&&Q.push(e)}else Q.push(e)}),P=Q;let q=P.length,D=N(P,M);k=new Blob([D]).size,$=+(100/I*k).toFixed(2),e.d=D,e.report={original:S,new:q,saved:S-q,compression:$,decimals:n},C&&C.setAttribute("d",D)}),q?(L=(new XMLSerializer).serializeToString(L),k=new Blob([L]).size,$=+(100/I*k).toFixed(2),I=+(I/1024).toFixed(3),k=+(k/1024).toFixed(3),T={svgSize:I,svgSizeOpt:k,compression:$}):({d:Q,report:T}=D[0]),P?{svg:L,d:Q,report:T,inputType:S,mode:q}:Q||L}function pe(e,{keepExtremes:t=!0,keepInflections:l=!0,keepCorners:a=!0,extrapolateDominant:n=!0,tolerance:s=1,reverse:r=!1}={}){let i=[e[0]];for(let r=2,u=e.length;u&&r<=u;r++){let p=e[r-1],h=r<u?e[r]:null,y=h?.type||null,o=p?.directionChange||null,c=h?.directionChange||null,{type:x,values:f,p0:g,p:v,cp1:d=null,cp2:m=null,extreme:M=!1,corner:b=!1,dimA:A=0}=p;if("C"===x&&"C"===y)if(l&&c||a&&b||!o&&t&&M)i.push(p);else{let y=V(p,h,n,s),o=0;if(1===y.length){p=y[0];let h=1;o+=p.error;for(let i=r+1;o<s&&i<u;i++){let r=e[i];if("C"!==r.type||l&&r.directionChange||a&&p.corner||t&&p.extreme)break;let u=V(p,r,n,s);1===u.length&&h++,p=u[0]}i.push(p),r<u&&(r+=h)}else i.push(p)}else i.push(p)}return r&&(i=re(i)),i}function he(e=null,t=!1){if(!e)return{x:0,y:0,width:300,height:150};let l=window.getComputedStyle(e),a=e.hasAttribute("width")?e.width.baseVal.value:parseFloat(l.width)||300,n=e.hasAttribute("height")?e.height.baseVal.value:parseFloat(l.height)||150,s=e.getAttribute("viewBox")?e.viewBox.baseVal:{x:0,y:0,width:a,height:n},{x:r,y:i,width:u,height:p}=s;if(s={x:r,y:i,width:u,height:p},t)for(let e in s)s[e]=Math.ceil(s[e]);return s}le[77]=2,le[109]=2,le[65]=7,le[97]=7,le[67]=6,le[99]=6,le[76]=2,le[108]=2,le[81]=4,le[113]=4,le[83]=4,le[115]=4,le[84]=2,le[116]=2,le[72]=1,le[104]=1,le[86]=1,le[118]=1,le[90]=0,le[122]=0;const{abs:ye,acos:oe,asin:ce,atan:xe,atan2:fe,ceil:ge,cos:ve,exp:de,floor:me,log:Me,hypot:be,max:Ae,min:Ce,pow:we,random:Pe,round:Se,sin:Le,sqrt:Ie,tan:ke,PI:$e}=Math;"undefined"!=typeof window&&(window.svgPathSimplify=ue,window.getViewBox=he,window.renderPoint=function(e,t,l="red",a="1%",n="1",s="",r=!0,i="",u=""){Array.isArray(t)&&(t={x:t[0],y:t[1]});let p=`<circle class="${u}" opacity="${n}" id="${i}" cx="${t.x}" cy="${t.y}" r="${a}" fill="${l}">\n <title>${s}</title></circle>`;if(!r)return p;e.insertAdjacentHTML("beforeend",p)}),e.PI=$e,e.abs=ye,e.acos=oe,e.asin=ce,e.atan=xe,e.atan2=fe,e.ceil=ge,e.cos=ve,e.exp=de,e.floor=me,e.getViewBox=he,e.hypot=be,e.log=Me,e.max=Ae,e.min=Ce,e.pow=we,e.random=Pe,e.round=Se,e.sin=Le,e.sqrt=Ie,e.svgPathSimplify=ue,e.tan=ke}(this["svg-path-simplify"]=this["svg-path-simplify"]||{});
1
+ !function(e){"use strict";const{abs:t,acos:l,asin:a,atan:n,atan2:s,ceil:r,cos:i,exp:u,floor:p,log:y,max:h,min:o,pow:c,random:x,round:f,sin:g,sqrt:v,tan:d,PI:m}=Math;function M(e,t,l=!1){let a=s(t.y-e.y,t.x-e.x);return l&&a<0&&(a+=2*Math.PI),a}function b(e,t,l,a,n=!0){let s,r,i,u,p,y={};try{if(s=(a.y-l.y)*(t.x-e.x)-(a.x-l.x)*(t.y-e.y),0==s)return!1}catch{console.log("!catch",e,t,"p3:",l,a)}r=e.y-l.y,i=e.x-l.x,u=(a.x-l.x)*r-(a.y-l.y)*i,p=(t.x-e.x)*r-(t.y-e.y)*i,r=u/s,i=p/s,y={x:e.x+r*(t.x-e.x),y:e.y+r*(t.y-e.y)};let h=!1;return r>0&&r<1&&i>0&&i<1&&(h=!0),!(n&&!h)&&y}function C(e,t){return v((t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y))}function A(e,t){return(t.x-e.x)**2+(t.y-e.y)**2}function w(e,t,l,a=!1){let n={x:(t.x-e.x)*l+e.x,y:(t.y-e.y)*l+e.y};return a&&(n.angle=M(e,t),n.angle<0&&(n.angle+=2*m)),n}function L(e,t=.5,l=!1,a=!1){let n;return n=e.length>2?((e,t,l=!1)=>{let n=4===e.length,s=e[0],r=e[1],i=n?e[2]:e[1],u=e[e.length-1],p={x:0,y:0};if(l||a){let e,l,y,h,o,c=s.x===r.x&&s.y===r.y,x=u.x===i.x&&u.y===i.y;0!==t||c?1!==t||x?(c&&(t+=1e-7),x&&(t-=1e-7),e=w(s,r,t),n?(l=w(r,i,t),y=w(i,u,t),h=w(e,l,t),o=w(l,y,t),p=w(h,o,t),p.angle=M(h,o),a&&(p.cpts=[l,y,h,o])):(l=w(s,r,t),y=w(r,u,t),p=w(l,y,t),p.angle=M(l,y),a&&(p.cpts=[l,y]))):(p.x=u.x,p.y=u.y,p.angle=M(i,u)):(p.x=s.x,p.y=s.y,p.angle=M(s,r))}else{let e=1-t;p=n?{x:e**3*s.x+3*e**2*t*r.x+3*e*t**2*i.x+t**3*u.x,y:e**3*s.y+3*e**2*t*r.y+3*e*t**2*i.y+t**3*u.y}:{x:e*e*s.x+2*e*t*r.x+t**2*u.x,y:e*e*s.y+2*e*t*r.y+t**2*u.y}}return p})(e,t,l):w(e[0],e[1],t,l),l&&n.angle<0&&(n.angle+=2*m),n}function P(e,t,l,a,s,r=0,u=!0,p=!1){if(s=p?s*m/180:s,r=p?r*m/180:r,r=l!==a&&r!==2*m?r:0,u&&l!==a){let e=n(d(s=r?s-r:s)*(l/a));s=i(s)<0?e+m:e}let y=e+l*i(s),h=t+a*g(s),o={x:y,y:h};return r&&(o.x=e+(y-e)*i(r)-(h-t)*g(r),o.y=t+(y-e)*g(r)+(h-t)*i(r)),o}function S(e,t=[],l=.05){let a=3===t.length,n=t[0]||null,s=a?t[1]:null,r=a?t[2]:t[1],i=.5*Math.PI,u=!1,p=!1,y=n?M(r,n,!0):null;if(u=Math.abs(y%i)<l||Math.abs(y%i-i)<l,a){let e=s?M(s,r,!0):0;p=Math.abs(e%i)<=l||Math.abs(e%i-i)<=l}return u||p}function I(e){return 4===e.length?function(e,t,l,a){let[n,s,r,i,u,p,y,h]=[e.x,e.y,t.x,t.y,l.x,l.y,a.x,a.y],o=Math.min(e.y,a.y),c=Math.min(e.x,a.x),x=Math.max(e.x,a.x),f=Math.max(e.y,a.y);if(t.y>=o&&t.y<=f&&l.y>=o&&l.y<=f&&t.x>=c&&t.x<=x&&l.x>=c&&l.x<=x)return[];let g,v,d,m,M,b,C,A,w=[];for(let e=0;e<2;++e)if(0==e?(v=6*n-12*r+6*u,g=-3*n+9*r-9*u+3*y,d=3*r-3*n):(v=6*s-12*i+6*p,g=-3*s+9*i-9*p+3*h,d=3*i-3*s),Math.abs(g)<1e-12){if(Math.abs(v)<1e-12)continue;m=-d/v,0<m&&m<1&&w.push(m)}else C=v*v-4*d*g,C<0?Math.abs(C)<1e-12&&(m=-v/(2*g),0<m&&m<1&&w.push(m)):(A=Math.sqrt(C),M=(-v+A)/(2*g),0<M&&M<1&&w.push(M),b=(-v-A)/(2*g),0<b&&b<1&&w.push(b));let L=w.length;for(;L--;)m=w[L];return w}(e[0],e[1],e[2],e[3]):function(e,t,l){let a,n,s,r=Math.min(e.y,l.y),i=Math.min(e.x,l.x),u=Math.max(e.x,l.x),p=Math.max(e.y,l.y);if(t.y>=r&&t.y<=p&&t.x>=i&&t.x<=u)return[];let[y,h,o,c,x,f]=[e.x,e.y,t.x,t.y,l.x,l.y],g=[];for(let e=0;e<2;++e)a=0==e?y-2*o+x:h-2*c+f,n=0==e?-2*y+2*o:-2*h+2*c,Math.abs(a)>1e-12&&(s=-n/(2*a),s>0&&s<1&&g.push(s));return g}(e[0],e[1],e[2])}function F(e,t=.025){let l=e[0],a=e[e.length-1],n=e.map(e=>e.x),s=e.map(e=>e.y),r=Math.min(...n),i=Math.max(...n),u=Math.min(...s),p=i-r,y=Math.max(...s)-u;if(e.length<3||0===p||0===y)return{area:0,flat:!0,thresh:1e-4,ratio:0};let h=A(l,a),o=A(l,e[0]),c=(o+(e.length>3?A(a,e[1]):o))/2;let x=.5*(p+y)*.5,f=0;for(let t=0,l=e.length;t<l;t++){f+=e[t].x*e[t===e.length-1?0:t+1].y*.5-e[t===e.length-1?0:t+1].x*e[t].y*.5}f=+Math.abs(f).toFixed(9);return{area:f,flat:0===f||f<c/1e3,thresh:x,ratio:f/c,squareDist:h,areaThresh:h/1e3}}function k(e,t,l){let a=!1,n=2===t.length,s=t[0],r=n?t[1]:s;if(e.x===s.x&&e.y===s.y&&l.x===r.x&&l.y===r.y)return!0;let i=s.x-e.x,u=s.y-e.y,p=l.x-r.x,y=l.y-r.y,h=Math.abs(i*y-u*p);if(!h)return!0;let o=l.x-e.x,c=l.y-e.y,x=Math.abs(o*u-c*i);return!x||(x/h<1.1&&(a=!0),a)}function $(e,t){return(Math.abs(t.x-e.x)+Math.abs(t.y-e.y))/2}function z(e){let t=[];try{e.map((e,t)=>"m"===e.type.toLowerCase()?t:-1).filter(e=>-1!==e)}catch{console.log("catch",e)}let l=e.map((e,t)=>"m"===e.type.toLowerCase()?t:-1).filter(e=>-1!==e);return 1===l.length?[e]:(l.forEach((a,n)=>{t.push(e.slice(a,l[n+1]))}),t)}function E(e,t){let l,a,n,s,r,i,u=[],p=[],y=e[0],h=e[1],o=e[e.length-2],c=e[e.length-1];return 4===e.length?(l=L([y,h],t),a=L([h,o],t),n=L([o,c],t),s=L([l,a],t),r=L([a,n],t),i=L([s,r],t),u.push({x:y.x,y:y.y},{x:l.x,y:l.y},{x:s.x,y:s.y},{x:i.x,y:i.y}),p.push({x:i.x,y:i.y},{x:r.x,y:r.y},{x:n.x,y:n.y},{x:c.x,y:c.y})):3===e.length?(a=L([y,h],t),n=L([h,c],t),i=L([a,n],t),u.push({x:y.x,y:y.y},{x:a.x,y:a.y},{x:i.x,y:i.y}),p.push({x:i.x,y:i.y},{x:n.x,y:n.y},{x:c.x,y:c.y})):2===e.length&&(a=L([y,c],t),u.push({x:y.x,y:y.y},{x:a.x,y:a.y}),p.push({x:a.x,y:a.y},{x:c.x,y:c.y})),[u,p]}function T(e,t,l=0,a=1){let n=[],s=6===t.length?"C":"Q",r={x:t[0],y:t[1]},i="C"===s?{x:t[2],y:t[3]}:r,u={x:t[4],y:t[5]},p=Math.max(u.x,e.x),y=Math.min(u.x,e.x),h=Math.max(u.y,e.y),o=Math.min(u.y,e.y),c=0;if(r.x<y||r.x>p||r.y<o||r.y>h||i.x<y||i.x>p||i.y<o||i.y>h){let p=I("C"===s?[e,r,i,u]:[e,r,u]).sort();if(p=p.filter(e=>e>l&&e<a),p.length){let l=function(e,t,l,a=!0){let n=[];if(!l.length)return!1;let s,r,i,u=t.length,p={x:t[u-2],y:t[u-1]};2===t.length?i=[e,p]:4===t.length?(s={x:t[0],y:t[1]},i=[e,s,p]):6===t.length&&(s={x:t[0],y:t[1]},r={x:t[2],y:t[3]},i=[e,s,r,p]);if(l.length)if(1===l.length){let e=E(i,l[0]),t=e[0],a=e[1];n.push(t,a)}else{let e=l[0],t=E(i,e),a=t[0];n.push(a),i=t[1];for(let t=1;t<l.length;t++){e=l[t-1];let a=E(i,(l[t]-e)/(1-e));n.push(a[0]),t===l.length-1&&n.push(a[a.length-1]),i=a[1]}}if(a){let e,t,l=[];return n.forEach(a=>{e={type:"",values:[]},a.shift(),t=a.map(e=>Object.values(e)).flat(),e.values=t,3===a.length?e.type="C":2===a.length?e.type="Q":1===a.length&&(e.type="L"),l.push(e)}),l}return n}(e,t,p);n.push(...l),c+=l.length}else n.push({type:s,values:t})}else n.push({type:s,values:t});return{pathData:n,count:c}}function Q(e,t=0,l=1){let a=[e[0]],n={x:e[0].values[0],y:e[0].values[1]},s={x:e[0].values[0],y:e[0].values[1]},r=e.length;for(let i=1;r&&i<r;i++){let r=e[i],{type:u,values:p}=r,y=p.slice(-2);if(y[0],y[1],"C"!==u&&"Q"!==u)a.push(r);else if("C"===u||"Q"===u){let e=T(n,p,t,l).pathData;a.push(...e)}n={x:y[0],y:y[1]},"z"===u.toLowerCase()?n=s:"M"===u&&(s={x:y[0],y:y[1]})}return a}function q(e,t=-1){let l=e.map(e=>e.x),a=e.map(e=>e.y),n=Math.min(...l),s=Math.max(...l),r=Math.min(...a),i=Math.max(...a),u={x:n,left:n,right:s,y:r,top:r,bottom:i,width:s-n,height:i-r};if(t>-1)for(let e in u)u[e]=+u[e].toFixed(t);return u}function D(e){let t=[];return e.forEach(e=>{let l=function(e){let t=function(e){let t=[];for(let l=0;l<e.length;l++){let a=e[l],n=l>0?e[l-1]:e[l],{type:s,values:r}=a,i={x:n.values[n.values.length-2],y:n.values[n.values.length-1]},u=r.length?{x:r[r.length-2],y:r[r.length-1]}:"",p=r.length?{x:r[0],y:r[1]}:"";switch(s){case"A":if("function"!=typeof arcToBezier){let e=C(i,u)/2,l=w(i,u,.5),a=P(l.x,l.y,e,e,0),n=P(l.x,l.y,e,e,Math.PI);t.push(a,n,u);break}arcToBezier(i,r).forEach(e=>{let l=e.values,a={x:l[0],y:l[1]},n={x:l[2],y:l[3]},s={x:l[4],y:l[5]};t.push(a,n,s)});break;case"C":let e={x:r[2],y:r[3]};t.push(p,e);break;case"Q":t.push(p)}"z"!==s.toLowerCase()&&t.push(u)}return t}(e),l=q(t);return l}(e);t.push(l)}),t}function B(e,t){let[l,a,n,s,r,i]=[e.x,e.y,e.width,e.height,e.x+e.width,e.y+e.height],[u,p,y,h,o,c]=[t.x,t.y,t.width,t.height,t.x+t.width,t.y+t.height],x=!1;return n*s!=y*h&&n*s>y*h&&l<u&&r>o&&a<p&&i>c&&(x=!0),x}function O(e,l=9){let a=0,n=[],r=z(e),u=r.length>1,p=[];if(u){let e=D(r);e.forEach(function(t,l){for(let l=0;l<e.length;l++){let a=e[l];if(t!=a){B(t,a)&&p.push(l)}}})}return r.forEach((e,l)=>{n=[];let r=0,u=0,y=1,h=[];e.forEach(function(l,a){let[u,p]=[l.type,l.values],y=p.length;if(p.length){let o=(a>0?e[a-1]:e[0]).values,c=o.length,x={x:o[c-2],y:o[c-1]},f={x:p[y-2],y:p[y-1]};if("C"===u||"Q"===u){let e={x:p[0],y:p[1]};h="C"===u?[x,e,{x:p[2],y:p[3]},f]:[x,e,f];let t=Math.abs(function(e,t=!1){let l,[a,n,s,r]=[e[0],e[1],e[2],e[e.length-1]];if(e.length<3)return 0;3===e.length&&(n={x:1*e[0].x/3+2*e[1].x/3,y:1*e[0].y/3+2*e[1].y/3},s={x:1*e[2].x/3+2*e[1].x/3,y:1*e[2].y/3+2*e[1].y/3});return l=3*(a.x*(-2*n.y-s.y+3*r.y)+n.x*(2*a.y-s.y-r.y)+s.x*(a.y+n.y-2*r.y)+r.x*(-3*a.y+n.y+2*s.y))/20,t?Math.abs(l):l}(h));r+=t,n.push(x,f)}else if("A"===u){let e=function(e,l,a,n,r,u,p,y,h){const o=(e,t,l,a)=>s(a-t,l-e);let c={cx:0,cy:0,rx:a=t(a),ry:n=t(n),startAngle:0,endAngle:0,deltaAngle:0,clockwise:p,xAxisRotation:r,largeArc:u,sweep:p};if(0==a||0==n)throw Error("rx and ry can not be 0");if(a===n){let t=Math.abs(y-e),a=Math.abs(h-l),n=t,s=Math.min(e,y),r=Math.min(l,h),i=.5*Math.PI;if(0===t&&a||0===a&&t)return n=0===t&&a?a/2:t/2,c.rx=n,c.ry=n,0===t&&a?(c.cx=e,c.cy=r+a/2,c.startAngle=l>h?i:-i,c.endAngle=l>h?-i:i,c.deltaAngle=p?Math.PI:-Math.PI):0===a&&t&&(c.cx=s+t/2,c.cy=l,c.startAngle=e>y?Math.PI:0,c.endAngle=e>y?-Math.PI:Math.PI,c.deltaAngle=p?Math.PI:-Math.PI),c}let x,f,d=a===n?0:r*m/180,M=d?g(d):0,b=d?i(d):1,C=(e-y)/2,A=(l-h)/2,w=(e+y)/2,L=(l+h)/2,P=d?b*C+M*A:C,S=d?b*A-M*C:A,I=P*P/(a*a)+S*S/(n*n);I>1&&(a*=v(I),n*=v(I),c.rx=a,c.ry=n);let F=a*n,k=a*S,$=n*P,z=k**2+$**2;if(!z)throw Error("start point can not be same as end point");let E=v(t((F*F-z)/z));u==p&&(E=-E);let T=E*k/n,Q=-E*$/a;x=d?b*T-M*Q+w:w+T,f=d?M*T+b*Q+L:L+Q,c.cy=f,c.cx=x;let q=o(x,f,e,l),D=o(x,f,y,h);!p&&D>q&&(D-=2*Math.PI),p&&q>D&&(D=D<=0?D+2*Math.PI:D);let B=D-q;return c.startAngle=q,c.endAngle=D,c.deltaAngle=B,c}(x.x,x.y,l.values[0],l.values[1],l.values[2],l.values[3],l.values[4],f.x,f.y),{cx:a,cy:u,rx:p,ry:y,startAngle:h,endAngle:o,deltaAngle:c}=e,d=Math.abs(function(e,t,l,a){const n=Math.PI*e*t;let s=(a-l+2*Math.PI)%(2*Math.PI);if(e===t)return n*(s/(2*Math.PI));const r=l=>Math.atan2(e*Math.sin(l),t*Math.cos(l));return l=r(l),a=r(a),s=(a-l+2*Math.PI)%(2*Math.PI),n*(s/(2*Math.PI))}(p,y,h,o));d-=Math.abs(j([x,{x:a,y:u},f])),n.push(x,f),r+=d}else n.push(x,f)}});let o=j(n);-1!==p.indexOf(l)&&(y=-1),u=o<0&&r<0?(Math.abs(r)-Math.abs(o))*y:(Math.abs(r)+Math.abs(o))*y,a+=u}),a}function j(e,t=!1){let l=0;for(let t=0,a=e.length;a&&t<a;t++){l+=e[t].x*e[t===e.length-1?0:t+1].y*.5-e[t===e.length-1?0:t+1].x*e[t].y*.5}return t&&(l=Math.abs(l)),l}function N(e,t=0){t=parseFloat(t);let l=e.length,a=t>1,n=!a&&!t,s="",r=a?"\n":n?"":" ",i=n?"":" ";s=`${e[0].type}${i}${e[0].values.join(" ")}${r}`;for(let t=1;t<l;t++){let l=e[t-1],a=e[t],{type:u,values:p}=a;if(!n||"A"!==u&&"a"!==u||(p=[p[0],p[1],p[2],`${p[3]}${p[4]}${p[5]}`,p[6]]),u=l.type===a.type&&"m"!==a.type.toLowerCase()&&n||"M"===l.type&&"L"===a.type&&n?" ":a.type,n){let e="",t=!1;for(let l=0,a=p.length;l<a;l++){let a=p[l],n=a.toString(),s=n.includes(".")&&Math.abs(a)<1;s&&t&&(n=n.replace(/^0\./,".")),!(l>0)||t&&s||(e+=" "),e+=n,t=s}s+=`${u}${i}${e}${r}`}else s+=`${u}${i}${p.join(" ")}${r}`}return n&&(s=s.replace(/ 0\./g," .").replace(/ -/g,"-").replace(/-0\./g,"-.").replace(/Z/g,"z")),s}function V(e,t,l=!1,a=1){let n=[e,t],s=function(e,t){let l=b(e.p0,e.cp1,t.cp2,t.p,!1),a=b(l,t.p,t.p0,t.cp1,!1),n=C(l,t.p),s=C(a,t.p),r=1-s/n,i=C(e.cp2,e.p),u=C(e.cp2,t.cp1);return r=Math.min(i)/u,r}(e,t),r=$(e.p0,e.p),i=$(t.p0,t.p),u=.05*Math.min(r,i)*a,p=function(e,t,l=0,a=0){let{p0:n,cp1:s}=e,{p:r,cp2:i}=t,u={x:(s.x-(1-l)*n.x)/l,y:(s.y-(1-l)*n.y)/l},p={x:(i.x-a*r.x)/(1-a),y:(i.y-a*r.y)/(1-a)},y={p0:n,cp1:u,cp2:p,p:r};return y}(e,t,s,s),y=L([p.p0,p.cp1,p.cp2,p.p],s),h=$(e.p,y),o=0,c=0,x=!1,f=h;if(h<u){let l=.5*(1+s);if(o=$(L([t.p0,t.cp1,t.cp2,t.p],.5),L([p.p0,p.cp1,p.cp2,p.p],l)),f+=o,o<u){let t=.5*s;c=$(L([e.p0,e.cp1,e.cp2,e.p],.5),L([p.p0,p.cp1,p.cp2,p.p],t)),o+c<u&&(x=!0),f+=c}}if(l&&!x){let l=function(e,t,l=0,a=1){const n=(e,t,l,a,n)=>{let s=1-n;return{x:3*s*s*(t.x-e.x)+6*s*n*(l.x-t.x)+3*n*n*(a.x-l.x),y:3*s*s*(t.y-e.y)+6*s*n*(l.y-t.y)+3*n*n*(a.y-l.y)}};let s=[e,t],r=A(e.p0,e.p)>A(t.p0,t.p),i=JSON.parse(JSON.stringify(e)),u=JSON.parse(JSON.stringify(t)),p=b(i.p0,i.cp1,u.p,u.cp2,!1);if(!p)return s;if(r){let l={p0:{x:e.p.x,y:e.p.y},cp1:{x:e.cp2.x,y:e.cp2.y},cp2:{x:e.cp1.x,y:e.cp1.y},p:{x:e.p0.x,y:e.p0.y}};e={p0:{x:t.p.x,y:t.p.y},cp1:{x:t.cp2.x,y:t.cp2.y},cp2:{x:t.cp1.x,y:t.cp1.y},p:{x:t.p0.x,y:t.p0.y}},t=l}let y=(e,t)=>({x:e.x-t.x,y:e.y-t.y}),h=(e,t)=>({x:e.x*t,y:e.y*t}),o=(e,t)=>e.x*t.x+e.y*t.y,c=t.p0,x=n(t.p0,t.cp1,t.cp2,t.p,0),f=o(y(e.p0,c),x)/o(x,x),g=L([t.p0,t.cp1,t.cp2,t.p],f),v=n(t.p0,t.cp1,t.cp2,t.p,f);f-=o(y(g,e.p0),v)/o(v,v);let d=L([t.p0,t.cp1,t.cp2,t.p],f),m=t.p,M=n(t.p0,t.cp1,t.cp2,t.p,f),C=n(t.p0,t.cp1,t.cp2,t.p,1),P=1-f,S=(I=d,F=h(M,P/3),{x:I.x+F.x,y:I.y+F.y});var I,F;let k=y(m,h(C,P/3)),z={p0:d,cp1:S,cp2:k,p:m};r&&(z={p0:m,cp1:k,cp2:S,p:d});let E=L([z.p0,z.cp1,z.cp2,z.p],.5,!1,!0),T=E.cpts[2],Q=b(E,T,z.p0,p,!1),q=b(E,T,z.p,p,!1),D=w(z.p0,Q,1.333),B=w(z.p,q,1.333);if(b(i.p0,D,u.p,B,!0))return s;z.cp1=D,z.cp2=B;let j=$(i.p0,z.p0)+$(u.p,z.p);if(z.p0=i.p0,z.p=u.p,z.extreme=u.extreme,z.corner=u.corner,z.dimA=u.dimA,z.directionChange=u.directionChange,z.values=[z.cp1.x,z.cp1.y,z.cp2.x,z.cp2.y,z.p.x,z.p.y],j<l){let e=O([{type:"M",values:[i.p0.x,i.p0.y]},{type:"C",values:[i.cp1.x,i.cp1.y,i.cp2.x,i.cp2.y,i.p.x,i.p.y]},{type:"C",values:[u.cp1.x,u.cp1.y,u.cp2.x,u.cp2.y,u.p.x,u.p.y]}]),t=[{type:"M",values:[z.p0.x,z.p0.y]},{type:"C",values:[z.cp1.x,z.cp1.y,z.cp2.x,z.cp2.y,z.p.x,z.p.y]}],l=O(t),n=Math.abs(l/e-1);z.error=10*n*a,N(t),n<.01&&(s=[z])}return s}(e,t,u,a);1===l.length&&(x=!0,p=l[0],f=p.error)}return x&&(p.p0=e.p0,p.p=t.p,p.dimA=$(p.p0,p.p),p.type="C",p.extreme=t.extreme,p.directionChange=t.directionChange,p.corner=t.corner,p.values=[p.cp1.x,p.cp1.y,p.cp2.x,p.cp2.y,p.p.x,p.p.y],p.error=f/u,n=[p]),n}function H(e=[]){let t,l=[],a=function(e){let t=[],l={x:e[0].values[0],y:e[0].values[1]};return e.forEach(e=>{let{type:a,values:n}=e;if(n.length){let e=n.length>1?{x:n[n.length-2],y:n[n.length-1]}:"V"===a?{x:l.x,y:n[0]}:{x:n[0],y:l.y};t.push(e),l=e}}),t}(e),n=q(a),{left:s,right:r,top:i,bottom:u,width:p,height:y}=n,h=e[0].values[0],o=e[0].values[1],c={x:e[0].values[0],y:e[0].values[1]},x={x:e[0].values[0],y:e[0].values[1]};e[0].idx=0,e[0].p0=c,e[0].p=c,e[0].lineto=!1,e[0].corner=!1,e[0].extreme=!1,e[0].directionChange=!1,e[0].closePath=!1,e[0].dimA=0;let f=[e[0]],g=0,v=e.length;for(let l=2;v&&l<=v;l++){let a=e[l-1],{type:n,values:p}=a,y=p.slice(-2),v=[x],d=!1;a.idx=l-1,a.lineto=!1,a.corner=!1,a.extreme=!1,a.directionChange=!1,a.closePath=!1,a.dimA=0;let m,b,C,w,L,P,I,k=.05;t=y.length?{x:y[0],y:y[1]}:c,"M"===n?(c=t,x=t):"z"===n.toLowerCase()&&(t=c),a.p0=x,a.p=t;let z=$(x,t);if(a.dimA=z,"L"===n&&(a.lineto=!0),"Z"===n&&(a.closePath=!0,c.x!==h&&c.y!==o&&(a.lineto=!0)),"Q"!==n&&"C"!==n||(m={x:p[0],y:p[1]},b="C"===n?{x:p[2],y:p[3]}:null,a.cp1=m,b&&(a.cp2=b)),p.length>2){"Q"!==n&&"C"!==n||v.push(m),"C"===n&&v.push(b),v.push(t),d=F(v).flat,a.flat=d,d&&(a.extreme=!1)}d||"L"===n||t.x!==s&&t.y!==i&&t.x!==r&&t.y!==u||(a.extreme=!0);let E=e[l]?e[l]:null,T=E?E.values.slice(-2):null;P=E?E.type:null,!E||"Q"!==E.type&&"C"!==E.type||(L=E?{x:T[0],y:T[1]}:null,C={x:E.values[0],y:E.values[1]},w="C"===E.type?{x:E.values[2],y:E.values[3]}:null),I=j(v);let Q=g<0&&I>0||g>0&&I<0;if(g=I,Q&&(a.directionChange=!0),("Q"===n||"C"===n)&&("Q"===n&&"Q"===P||"C"===n&&"C"===P)){let e=v.slice(1),l=F("C"===n?[t,C,w,L]:[t,C,L],((L?Math.abs(L.x-x.x):0)+(L?Math.abs(L.y-x.y):0))/2*.1).flat;if((!d||!l)&&(!!a.extreme||S(0,e,k)))a.extreme=!0;else{let e=b?[b,t]:[m,t],l=[t,C],n=M(...e,!0),s=M(...l,!0),r=180*Math.abs(n-s)/Math.PI,i=A(...e),u=A(...l);r>10&&i&&u&&(a.corner=!0)}}f.push(a),x=t}return l={pathData:f,bb:n,dimA:(p+y)/2},l}function Z(e,t=-1){let l=!("auto"!=t||!e[0].hasOwnProperty("decimals"));for(let a=0,n=e.length;a<n;a++){let n=e[a];(t>-1||l)&&(t=l?n.decimals:t,e[a].values=n.values.map(e=>e?+e.toFixed(t):e))}return e}function R(e={},t={},l={},a={}){let n=w(e,t,1.5),s=w(a,l,1.5),r=.01*$(e,a),i=$(n,s),u=null,p="C",y=[t.x,t.y,l.x,l.y,a.x,a.y];return i<r&&(u=b(e,t,a,l,!1),u&&(p="Q",y=[u.x,u.y,a.x,a.y])),{type:p,values:y}}function U(e,{toShorthands:t=!0,toRelative:l=!0,decimals:a=3}={}){return t&&(e=function(e,t=-1,l=!0){let a;if(l){let t=e.map(e=>e.type).join("");a=/[astvqmhlc]/g.test(t)}e=l&&a?X(e,t):e;let n={type:"M",values:e[0].values};e[0].decimals&&(n.decimals=e[0].decimals);let s,r=[n],i={x:e[0].values[0],y:e[0].values[1]},u=.01;for(let l=1,a=e.length;l<a;l++){let a=e[l],{type:p,values:y}=a,h=y.slice(-2),o=e[l-1],c=o.type;s={x:h[0],y:h[1]};let x,f,g,v,d={x:y[0],y:y[1]},m=Math.abs(s.x-i.x),M=Math.abs(s.y-i.y),b=(m+M)/2*u;switch(p){case"L":n=0===M||M<b&&m>b?{type:"H",values:[y[0]]}:0===m||M>b&&m<b?{type:"V",values:[y[1]]}:a;break;case"Q":if("Q"!==c){i={x:h[0],y:h[1]},r.push(a);continue}let e={x:o.values[0],y:o.values[1]};v={x:2*i.x-e.x,y:2*i.y-e.y},x=Math.abs(d.x-v.x),f=Math.abs(d.y-v.y),g=(x+f)/2,n=g<b?{type:"T",values:[s.x,s.y]}:a;break;case"C":let t={x:y[2],y:y[3]};if("C"!==c){r.push(a),i={x:h[0],y:h[1]};continue}let l={x:o.values[2],y:o.values[3]};v={x:2*i.x-l.x,y:2*i.y-l.y},x=Math.abs(d.x-v.x),f=Math.abs(d.y-v.y),g=(x+f)/2,n=g<b?{type:"S",values:[t.x,t.y,s.x,s.y]}:a;break;default:n={type:p,values:y}}(a.decimals||0===a.decimals)&&(n.decimals=a.decimals),t>-1&&(n.values=n.values.map(e=>+e.toFixed(t))),i={x:h[0],y:h[1]},r.push(n)}return r}(e)),e=Z(e,a),l&&(e=function(e,t=-1){return W(e,!0,t)}(e)),a>-1&&(e=Z(e,a)),e}function J(e,t){Array.isArray(e)&&(e={x:e[0],y:e[1]});let l={x:e.x+2/3*(t[0]-e.x),y:e.y+2/3*(t[1]-e.y)},a={x:t[2]+2/3*(t[0]-t[2]),y:t[3]+2/3*(t[1]-t[3])};return{type:"C",values:[l.x,l.y,a.x,a.y,t[2],t[3]]}}function W(e,t=!1,l=-1){l>=0&&(e[0].values=e[0].values.map(e=>+e.toFixed(l)));let a=e[0].values,n=a[0],s=a[1],r=n,i=s;for(let a=1,u=e.length;a<u;a++){let u=e[a],{type:p,values:y}=u,h=t?p.toLowerCase():p.toUpperCase();if(p!==h)switch(p=h,u.type=p,p){case"a":case"A":y[5]=t?y[5]-n:y[5]+n,y[6]=t?y[6]-s:y[6]+s;break;case"v":case"V":y[0]=t?y[0]-s:y[0]+s;break;case"h":case"H":y[0]=t?y[0]-n:y[0]+n;break;case"m":case"M":t?(y[0]-=n,y[1]-=s):(y[0]+=n,y[1]+=s),r=t?y[0]+n:y[0],i=t?y[1]+s:y[1];break;default:if(y.length)for(let e=0;e<y.length;e++)y[e]=t?y[e]-(e%2?s:n):y[e]+(e%2?s:n)}let o=y.length;switch(p){case"z":case"Z":n=r,s=i;break;case"h":case"H":n=t?n+y[0]:y[0];break;case"v":case"V":s=t?s+y[0]:y[0];break;case"m":case"M":r=y[o-2]+(t?n:0),i=y[o-1]+(t?s:0);default:n=y[o-2]+(t?n:0),s=y[o-1]+(t?s:0)}l>=0&&(u.values=u.values.map(e=>+e.toFixed(l)))}return e}function X(e,t=-1){return W(e,!1,t)}function G(e,t,l=1){const a=2*Math.PI;let[n,s,r,i,u,p,y]=t;if(0===n||0===s)return[];let h=r?r*a/360:0,o=h?Math.sin(h):0,c=h?Math.cos(h):1,x=c*(e.x-p)/2+o*(e.y-y)/2,f=-o*(e.x-p)/2+c*(e.y-y)/2;if(0===x&&0===f)return[];n=Math.abs(n),s=Math.abs(s);let g=x*x/(n*n)+f*f/(s*s);if(g>1){let e=Math.sqrt(g);n*=e,s*=e}let v=n*n,d=n===s?v:s*s,m=x*x,M=f*f,b=v*d-v*M-d*m;b<=0?b=0:(b/=v*M+d*m,b=Math.sqrt(b)*(i===u?-1:1));let C=b?b*n/s*f:0,A=b?b*-s/n*x:0,w=c*C-o*A+(e.x+p)/2,L=o*C+c*A+(e.y+y)/2,P=(x-C)/n,S=(f-A)/s,I=(-x-C)/n,F=(-f-A)/s;const k=(e,t,l,a)=>{let n=+(e*l+t*a).toFixed(9);return 1===n||-1===n?1===n?0:Math.PI:(n=n>1?1:n<-1?-1:n,(e*a-t*l<0?-1:1)*Math.acos(n))};let $=k(1,0,P,S),z=k(P,S,I,F);0===u&&z>0?z-=2*Math.PI:1===u&&z<0&&(z+=2*Math.PI);let E=(+(Math.abs(z)/(a/4)).toFixed(0)||1)*l;z/=E;let T=[];const Q=1.5707963267948966,q=.551785;let D=z===Q?q:z===-Q?-q:4/3*Math.tan(z/4),B=z?Math.cos(z):1,O=z?Math.sin(z):0;const j=(e,t,l,a,n)=>{let s=e!=t?Math.cos(e):a,r=e!=t?Math.sin(e):n,i=Math.cos(e+t),u=Math.sin(e+t);return[{x:s-r*l,y:r+s*l},{x:i+u*l,y:u-i*l},{x:i,y:u}]};for(let e=0;e<E;e++){let e={type:"C",values:[]};j($,z,D,B,O).forEach(t=>{let l=t.x*n,a=t.y*s;e.values.push(c*l-o*a+w,o*l+c*a+L)}),T.push(e),$+=z}return T}function Y(e,t,l,a,n=7.5){let s={type:"C",values:[t.x,t.y,l.x,l.y,a.x,a.y]},r=0,i=!1,u=M(e,t,!0),p=M(a,l,!0),y=180*Math.abs(u-p)/Math.PI;if(Math.abs(y%180-90)<3){let u=b(e,t,a,l,!1);if(u){let p=C(e,u),y=C(a,u),h=+Math.max(p,y).toFixed(8),o=+Math.min(p,y).toFixed(8),c=o,x=h,f=j([e,t,l,a])<0?0:1,g=Math.abs(a.x-e.x)>Math.abs(a.y-e.y);100/c*Math.abs(c-x)<5&&(c=h,x=c),g&&(c=h,x=o);let v=O([{type:"M",values:[e.x,e.y]},{type:"C",values:[t.x,t.y,l.x,l.y,a.x,a.y]}]),d={type:"A",values:[c,x,0,0,f,a.x,a.y]};r=Math.PI*(c*x)/4,r-=Math.abs(j([e,a,u])),function(e,t){let l=Math.abs(e-t);return Math.abs(100-100/e*(e+l))}(v,r)<n&&(i=!0,s=d)}}return{com:s,isArc:i,area:r}}function K(e){let t,l=[[]],a=0,n=[[]],s={x:e[0].values[0],y:e[0].values[1]};for(let r=0,i=e.length;r<i;r++){let i=e[r],{type:u,values:p}=i;if("A"===u){let u=e[r-1].values.slice(-2);s={x:u[0],y:u[1]};let[y,h,o,c,x,f,g]=p,v=100/y*Math.abs(y-h)<5;t={x:p[5],y:p[6]},i.p0=s,i.p=t,i.circular=v;let d=e[r+1];if(!l[a].length&&d&&"A"===d.type&&(l[a].push(i),n[a].push(r)),d&&"A"===d.type){let[e,i,u,p,o,c,x]=d.values,f=y!=e?100/y*Math.abs(y-e):0,g=h!=i?100/h*Math.abs(h-i):0;t={x:d.values[5],y:d.values[6]},d.p0=s,d.p=t,f<5&&g<5?(l[a].push(d),n[a].push(r+1)):(l.push([]),n.push([]),a++)}else l.push([]),n.push([]),a++}}if(!n.length)return e;l=l.filter(e=>e.length),n=n.filter(e=>e.length);for(let t=l.length-1;t>=0;t--){const a=l[t],s=n[t][0],r=a.length;let i=0,u=0;a.forEach(({values:e})=>{const[t,l]=e;i+=t,u+=l}),i/=r,u/=r;let p=100/i*Math.abs(i-u)<5;p&&(i=(i+u)/2,u=i);let y=e[s-1].values.slice(-2);if(y[0],y[1],4===r){let[t,l,n,y,h,o,c]=a[1].values,[,,,,,x,f]=a[3].values;p&&(i=1,u=1);let g={type:"A",values:[i,u,n,y,h,o,c]},v={type:"A",values:[i,u,n,y,h,x,f]};e.splice(s,r,g,v)}else if(3===r){let[t,l,n,p,y,h,o]=a[0].values,[c,x,,,,f,g]=a[2].values;p=1;let v={type:"A",values:[i,u,n,p,y,f,g]};e.splice(s,r,v)}else if(2===r){let[t,l,n,y,h,o,c]=a[0].values,[x,f,,,,g,v]=a[1].values;p&&(i=1,u=1,n=0);let{p0:d,p:m}=a[0],[M,b]=[a[1].p0,a[1].p];if(d.x!==b.x||d.y!==b.y){let t={type:"A",values:[i,u,n,y,h,g,v]};e.splice(s,r,t)}}}return e}function _(e=[],{toAbsolute:t=!0,toLonghands:l=!0,quadraticToCubic:a=!1,arcToCubic:n=!1,arcAccuracy:s=2}={},{hasRelatives:r=!0,hasShorthands:i=!0,hasQuadratics:u=!0,hasArcs:p=!0,testTypes:y=!1}={}){if(y){let t=Array.from(new Set(e.map(e=>e.type))).join("");r=/[lcqamts]/gi.test(t),u=/[qt]/gi.test(t),p=/[a]/gi.test(t),i=/[vhst]/gi.test(t),isPoly=/[mlz]/gi.test(t)}return(u&&a||p&&n)&&(l=!0,t=!0),r&&t&&(e=W(e,!1)),i&&l&&(e=function(e,t=-1,l=!0){let a=!1;if(l){let t=e.map(e=>e.type).join(""),l=/[hstv]/gi.test(t);if(a=/[astvqmhlc]/g.test(t),!l)return e}let n=[],s={type:"M",values:(e=l&&a?X(e,t):e)[0].values};n.push(s);for(let l=1,a=e.length;l<a;l++){let a,r,i,u,p,y,h,o,c=e[l],{type:x,values:f}=c,g=f.length,v=s.values,d=v.length,[m,M]=[f[g-2],f[g-1]],[b,C]=[v[d-2],v[d-1]];switch(x){case"H":s={type:"L",values:[f[0],C]};break;case"V":s={type:"L",values:[b,f[0]]};break;case"T":[a,r]=[v[0],v[1]],[b,C]=[v[d-2],v[d-1]],i=b+(b-a),u=C+(C-r),s={type:"Q",values:[i,u,m,M]};break;case"S":[a,r]=[v[0],v[1]],[b,C]=[v[d-2],v[d-1]],[h,o]=d>2&&"A"!==s.type?[v[2],v[3]]:[b,C],i=2*b-h,u=2*C-o,p=f[0],y=f[1],s={type:"C",values:[i,u,p,y,m,M]};break;default:s={type:x,values:f}}t>-1&&(s.values=s.values.map(e=>+e.toFixed(t))),n.push(s)}return n}(e,-1,!1)),p&&n&&(e=function(e,{arcAccuracy:t=1}={}){let l=[e[0]];for(let a=1,n=e.length;a<n;a++){let n=e[a],s=e[a-1].values,r=s.length,i={x:s[r-2],y:s[r-1]};"A"===n.type?G(i,n.values,t).forEach(e=>{l.push(e)}):l.push(n)}return l}(e,s)),u&&a&&(e=function(e){let t=[e[0]];for(let l=1,a=e.length;l<a;l++){let a=e[l],n=e[l-1].values,s=n.length,r={x:n[s-2],y:n[s-1]};"Q"===a.type?t.push(J(r,a.values)):t.push(a)}return t}(e)),e}function ee(e,{toAbsolute:t=!0,toLonghands:l=!0,quadraticToCubic:a=!1,arcToCubic:n=!1,arcAccuracy:s=4}={}){let r=function(e,t=!0){if(e=e.trim(),""===e)return{pathData:[],hasRelatives:!1,hasShorthands:!1,hasQuadratics:!1,hasArcs:!1};const l=new Set([5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279]),a=e=>32===e||44===e||10===e||13===e||8232===e||8233===e||9===e||11===e||12===e||160===e||e>=5760&&l.has(e);let n,s=0,r=e.length,i="",u=[],p=-1,y="",h=!1,o=0,c=0,x=0,f=!1,g=new Set([]),v=[];const d=()=>{f&&("M"===i?i="L":"m"===i&&(i="l"),u.push({type:i,values:[]}),p++,c=0,f=!1)},m=(e=!1)=>{(e?o>0:""!==y)&&(t&&-1===p&&(n="Pathdata must start with M command",v.push(n),i="M",u.push({type:i,values:[]}),x=2,c=0,p++),"A"===i||"a"===i?(y=M(),u[p].values.push(...y)):(t&&y[1]&&"."!==y[1]&&"0"===y[0]&&(n=`${p}. command: Leading zeros not valid: ${y}`,v.push(n)),u[p].values.push(+y)),c++,y="",o=0,f=c>=x)},M=()=>{let e=y.length,t=!1;return 3===c&&2===e||4===c&&e>1?(y=[+y[0],+y[1]],t=!0,c++):3===c&&e>=3&&(y=[+y[0],+y[1],+y.substring(2)],t=!0,c+=2),t?y:[+y]},b=()=>{if(p>0){let e=u[p].values.length;if(e&&e<x||e&&e>x||("z"===i||"Z"===i)&&e>0){n=`${p}. command of type "${i}": ${x-e} values too few - ${x} expected`,v[v.length-1]!==n&&v.push(n)}}};let C=!1,A=!1,w=!1;for(;s<r;){let l=e.charCodeAt(s),r=l>47&&l<58;if(r||(C=101===l||69===l,A=45===l||43===l,w=46===l),r||A||w||C){if(h||45!==l&&46!==l)d();else{let e=46===l;m(e),d(),e&&o++}y+=e[s],h=C,s++}else if((l<48||l>5759)&&a(l))m(),s++;else{if(l>64){if(!te.has(l)){n=`${p}. command "${e[s]}" is not a valid type`,v.push(n),s++;continue}""!==y&&(u[p].values.push(+y),c++,y=""),t&&b(),i=e[s],x=le[l];let a="M"===i||"m"===i,r=p>0&&("z"===u[p].type||"Z"===u[p].type);g.add(i),r&&!a&&(u.push({type:"m",values:[0,0]}),p++),u.push({type:i,values:[]}),p++,o=0,c=0,f=!1,s++;continue}r||(n=`${p}. ${e[s]} is not a valid separarator or token`,v.push(n),y=""),s++}}m(),t&&b();if(t&&v.length){if(n="Invalid path data:\n"+v.join("\n"),"log"!==t)throw new Error(n);console.log(n)}u[0].type="M";let L=Array.from(g).join(""),P=/[lcqamts]/g.test(L),S=/[vhst]/gi.test(L),I=/[a]/gi.test(L),F=/[qt]/gi.test(L);return{pathData:u,hasRelatives:P,hasShorthands:S,hasQuadratics:F,hasArcs:I}}(e),{hasRelatives:i,hasShorthands:u,hasQuadratics:p,hasArcs:y}=r,h=r.pathData;return h=_(h,{toAbsolute:t,toLonghands:l,quadraticToCubic:a,arcToCubic:n,arcAccuracy:s},{hasRelatives:i,hasShorthands:u,hasQuadratics:p,hasArcs:y}),h}const te=new Set([77,109,65,97,67,99,76,108,81,113,83,115,84,116,72,104,86,118,90,122]),le=new Uint8Array(128);function ae(e,t=1,l=!0){let a=[e[0]],n={x:e[0].values[0],y:e[0].values[1]},s=n,r=n;e[e.length-1].type.toLowerCase();for(let i=1,u=e.length;i<u;i++){let p=e[i-1],y=e[i],h=e[i+1]||e[u-1],o="z"===h.type.toLowerCase()?n:{x:h.values[h.values.length-2],y:h.values[h.values.length-1]},{type:c,values:x}=y,f=x.slice(-2);r="Z"!==c?{x:f[0],y:f[1]}:n;let g=j([s,r,o],!0)<A(s,o)/100*t,v=!1;if(l||"C"!==c||(g=!1),l&&("C"===c||"Q"===c)){v=k(s,"C"===c?[{x:x[0],y:x[1]},{x:x[2],y:x[3]}]:"Q"===c?[{x:x[0],y:x[1]}]:[],r),v&&i<u-1&&"C"!==p.type&&(c="L",y.type="L",y.values=f)}s=r,g&&i<u-1&&("L"===c||l&&v)||("M"===c?(n=r,s=n):"Z"===c&&(s=n),a.push(y))}return a}function ne(e){let t={x:e[0].values[0],y:e[0].values[1]},l=t,a=[e[0]];for(let n=1,s=e.length;n<s;n++){let s=e[n],{type:r,values:i}=s,u=i.slice(-2);l={x:u[0],y:u[1]},"L"===r&&l.x===t.x&&l.y===t.y||(a.push(s),t=l)}return a}function se(e){let t=e.length;if(!("z"===e[t-1].type.toLowerCase()))return e;let l=0,a=[];for(let l=0;l<t;l++){let t=e[l],{type:n,values:s}=t,r=s.length;if(r){let e={type:n,x:s[r-2],y:s[r-1],index:0};e.index=l,a.push(e)}}return a=a.sort((e,t)=>+e.y.toFixed(3)-+t.y.toFixed(3)),l=a[0].index,l?ie(e,l):e}function re(e,t=!0,l=!0){let a=[],n=e.length,s={x:+e[0].values[0].toFixed(8),y:+e[0].values[1].toFixed(8)},r="z"===e[n-1].type.toLowerCase(),i=e.filter(e=>"L"===e.type),u=e[n-2],p=u.type,y=u.values.slice(-2).map(e=>+e.toFixed(8)),h=y[0]===s.x&&y[1]===s.y,o="L"!==e[1].type&&(!h||"L"===p);if(o=!1,!r)return e;let c=0;{let t=[];for(let l=0,a=e.length;l<a;l++){let a=e[l],{type:n,values:s}=a;if(s.length){let a=s.slice(-2),r=e[l-1]&&"L"===e[l-1].type,i=e[l+1]&&"L"===e[l+1].type,u=e[l-1]?e[l-1].type.toUpperCase():null,p=e[l+1]?e[l+1].type.toUpperCase():null,y={type:n,x:a[0],y:a[1],dist:0,index:0,prevL:r,nextL:i,prevCom:u,nextCom:p};y.index=l,t.push(y)}}if(i.length){let e=t.filter(e=>"L"!==e.type&&"M"!==e.type&&e.prevCom&&"L"===e.prevCom||"M"===e.prevCom&&"L"===p).sort((e,t)=>e.y-t.y||e.x-t.x)[0];c=e?e.index-1:0}else t=t.sort((e,t)=>+e.y.toFixed(1)-+t.y.toFixed(1)||e.x-t.x),c=t[0].index;e=c?ie(e,c):e}return s={x:+e[0].values[0].toFixed(8),y:+e[0].values[1].toFixed(7)},n=e.length,u=e[n-2],p=u.type,y=u.values.slice(-2).map(e=>+e.toFixed(8)),h="L"===p&&y[0]===s.x&&y[1]===s.y,t&&h&&e.splice(n-2,1),a.push(...e),a}function ie(e,t){let l=0,a="z"===e[e.length-1].type.toLowerCase();if(!a||t<1||e.length<3)return e;let n=a?1:0;!function(e){let t=e.length,l="z"===e[t-1].type.toLowerCase(),a=e[0],[n,s]=[a.values[0],a.values[1]].map(e=>+e.toFixed(8)),r=l?e[t-2]:e[t-1],i=r.values.length,[u,p]=[r.values[i-2],r.values[i-1]].map(e=>+e.toFixed(8));!l||n==u&&s==p||(e.pop(),e.push({type:"L",values:[n,s]},{type:"Z",values:[]}))}(e),l=t+1<e.length-1?t+1:e.length-1-n;let s,r,i=e.slice(l),u=e.slice(0,l);return u.shift(),s=u[u.length-1].values||[],r=[s[s.length-2],s[s.length-1]],n&&(i.pop(),u.push({type:"Z",values:[]})),e=[{type:"M",values:r},...i,...u]}function ue(e,{arcToCubic:t=!1,quadraticToCubic:l=!1,toClockwise:a=!1,returnD:n=!1}={}){const s=(e,t)=>{let l=[],a=[];if("A"!==e){for(let e=0;e<t.length;e+=2)l.push([t[e],t[e+1]]);a=l.pop(),l.reverse()}else{let e=0==t[4]?1:0;l=[t[0],t[1],t[2],t[3],e],a=[t[5],t[6]]}return{controlPoints:l,endPoints:a}};let r=[],i="z"===e[e.length-1].type.toLowerCase();i&&(e=(e=>{let t="z"===e[e.length-1].type.toLowerCase(),l=e[0],[a,n]=[l.values[0],l.values[1]],s=t?e[e.length-2]:e[e.length-1],[r,i]=[s.values[s.values.length-2],s.values[s.values.length-1]];return!t||a==r&&n==i||(e.pop(),e.push({type:"L",values:[a,n]},{type:"Z",values:[]})),e})(e),e.pop());let u=e[e.length-1].values,p=u.length,y=i?e[0]:{type:"M",values:[u[p-2],u[p-1]]};r.push(y),e.reverse();for(let t=1;t<e.length;t++){let l=e[t],a=l.type,n=l.values,i=e[t-1],u=i.type,p=[];p=[s(u,i.values).controlPoints,s(a,n).endPoints].flat(),r.push({type:u,values:p.flat()})}return i&&r.push({type:"z",values:[]}),r}function pe(e,{returnDom:t=!1,removeHidden:l=!0,removeUnused:a=!0}={}){e=(e=e.replace(/<\?xml[\s\S]*?\?>/gi,"").replace(/<!DOCTYPE[\s\S]*?>/gi,"").replace(/<!--[\s\S]*?-->/g,"").trim()).replaceAll("xlink:href=","href=");let n=(new DOMParser).parseFromString(e,"text/html").querySelector("svg");!function(e,t=["viewBox","xmlns","width","height","id","class"]){[...e.attributes].map(e=>e.name).forEach(l=>{t.includes(l)||e.removeAttribute(l)})}(n,["viewBox","xmlns","width","height","id","class"]);let s=["metadata","script"];if(n.querySelectorAll("*").forEach(e=>{let t=e.nodeName,a=e.getAttribute("style")||"",n=!!a&&a.trim().includes("display:none"),r=e.getAttribute("display")&&"none"===e.getAttribute("display")||n;t.includes(":")||s.includes(t)||l&&r?e.remove():function(e){let t=[...e.attributes].map(e=>e.name);t.forEach(t=>{t.includes(":")&&e.removeAttribute(t)})}(e)}),t)return n;let r=function(e){let t=(new XMLSerializer).serializeToString(e);return t=t.replace(/\t/g,"").replace(/[\n\r|]/g,"\n").replace(/\n\s*\n/g,"\n").replace(/ +/g," "),t}(n);return console.log(r),r}function ye(e="",{toAbsolute:t=!0,toRelative:l=!0,toShorthands:a=!0,decimals:n=3,quadraticToCubic:s=!0,arcToCubic:r=!1,cubicToArc:i=!1,arcAccuracy:u=4,keepExtremes:p=!0,keepCorners:y=!0,keepInflections:h=!0,extrapolateDominant:o=!1,addExtremes:c=!1,optimizeOrder:x=!0,removeColinear:f=!0,simplifyBezier:g=!0,autoAccuracy:v=!0,flatBezierToLinetos:d=!0,revertToQuadratics:m=!0,minifyD:M=0,tolerance:b=1,reverse:C=!1,removeHidden:A=!0,removeUnused:w=!0,getObject:L=!1}={}){b=Math.max(.1,b);let P=function(e){let t="string";if(e instanceof HTMLImageElement)return"img";if(e instanceof SVGElement)return"svg";if(e instanceof HTMLCanvasElement)return"canvas";if(e instanceof File)return"file";if(e instanceof ArrayBuffer)return"buffer";if(e instanceof Blob)return"blob";if(Array.isArray(e))return"array";if("string"==typeof e){let l=(e=e.trim()).includes("<svg")&&e.includes("</svg"),a=e.startsWith("M")||e.startsWith("m"),n=!isNaN(e.substring(0,1))&&!isNaN(e.substring(e.length-1,e.length));if(l)t="svgMarkup";else if(a)t="pathDataString";else if(n)t="polyString";else{let l=/^(file:|https?:\/\/|\/|\.\/|\.\.\/)/.test(e),a=e.startsWith("data:image");t=l||a?"url":"string"}return t}return t=typeof e,(e.constructor.name||t).toLowerCase()}(e),S="",I=0,F=0,k=0,E={},T="",q="svgMarkup"===P?1:0,D=[];if(I=new Blob([e]).size,q){S=pe(e,{returnDom:!0,removeHidden:A,removeUnused:w}),S.querySelectorAll("path").forEach(e=>{D.push({d:e.getAttribute("d"),el:e})})}else"pathDataString"===P?T=e:"polyString"===P&&(T="M"+e),D.push({d:T,el:null});return D.forEach(e=>{let{d:u,el:A}=e,w=ee(u,{quadraticToCubic:s,toAbsolute:t,arcToCubic:r}),L=JSON.parse(JSON.stringify(w)),P=w.length,S=z(L),E=[];for(let e=0,t=S.length;e<t;e++){let t=S[e];C&&(t=ue(t)),f&&(t=ne(t)),c&&(t=Q(t,0,1)),x&&(t=se(t)),f&&(t=ae(t,b,d));let l=H(t),{pathData:a,bb:n,dimA:s}=l;if(a=g?he(a,{simplifyBezier:g,keepInflections:h,keepExtremes:p,keepCorners:y,extrapolateDominant:o,revertToQuadratics:m,tolerance:b,reverse:C}):a,i){let e=3;a.forEach((t,l)=>{let{type:n,values:s,p0:r,cp1:i=null,cp2:u=null,p:p=null}=t;if("C"===n){let t=Y(r,i,u,p,e);t.isArc&&(a[l]=t.com)}}),a=K(a)}m&&a.forEach((e,t)=>{let{type:l,values:n,p0:s,cp1:r=null,cp2:i=null,p:u=null}=e;if("C"===l){let e=R(s,r,i,u);"Q"===e.type&&(a[t]=e)}}),x&&(a=re(a)),E.push(a)}L=E.flat(),v&&(n=function(e){let t={x:e[0].values[0],y:e[0].values[1]},l=t,a=t;e[0].decimals=0;let n=new Set;for(let s=0,r=e.length;s<r;s++){let r=e[s],{type:i,values:u}=r,p=u.length?u.slice(-2):[t.x,t.y];a={x:p[0],y:p[1]};let y=r.dimA?+r.dimA.toFixed(8):"M"!==i?+$(l,a).toFixed(8):0;y&&n.add(y),"M"===i&&(t=a),l=a}let s=Array.from(n).sort(),r=Math.ceil(s.length/8);s=s.slice(0,r);let i=s.reduce((e,t)=>e+t,0)/r,u=i>50?0:Math.floor(50/i).toString().length;return Math.min(Math.max(0,u),8)}(L)),L=U(L,{toRelative:l,toShorthands:a,decimals:n});let T=[];L.forEach((e,t)=>{let{type:l,values:a}=e;if("l"===l||"v"===l||"h"===l){("l"===l?"00"!==a.join(""):0!==a[0])&&T.push(e)}else T.push(e)}),L=T;let q=L.length,D=N(L,M);F=new Blob([D]).size,k=+(100/I*F).toFixed(2),e.d=D,e.report={original:P,new:q,saved:P-q,compression:k,decimals:n},A&&A.setAttribute("d",D)}),q?(S=(new XMLSerializer).serializeToString(S),F=new Blob([S]).size,k=+(100/I*F).toFixed(2),I=+(I/1024).toFixed(3),F=+(F/1024).toFixed(3),E={svgSize:I,svgSizeOpt:F,compression:k}):({d:T,report:E}=D[0]),L?{svg:S,d:T,report:E,inputType:P,mode:q}:T||S}function he(e,{keepExtremes:t=!0,keepInflections:l=!0,keepCorners:a=!0,extrapolateDominant:n=!0,tolerance:s=1,reverse:r=!1}={}){let i=[e[0]];for(let r=2,u=e.length;u&&r<=u;r++){let p=e[r-1],y=r<u?e[r]:null,h=y?.type||null,o=p?.directionChange||null,c=y?.directionChange||null,{type:x,values:f,p0:g,p:v,cp1:d=null,cp2:m=null,extreme:M=!1,corner:b=!1,dimA:C=0}=p;if("C"===x&&"C"===h)if(l&&c||a&&b||!o&&t&&M)i.push(p);else{let h=V(p,y,n,s),o=0;if(1===h.length){p=h[0];let y=1;o+=p.error;for(let i=r+1;o<s&&i<u;i++){let r=e[i];if("C"!==r.type||l&&r.directionChange||a&&p.corner||t&&p.extreme)break;let u=V(p,r,n,s);1===u.length&&y++,p=u[0]}i.push(p),r<u&&(r+=y)}else i.push(p)}else i.push(p)}return r&&(i=ue(i)),i}function oe(e=null,t=!1){if(!e)return{x:0,y:0,width:300,height:150};let l=window.getComputedStyle(e),a=e.hasAttribute("width")?e.width.baseVal.value:parseFloat(l.width)||300,n=e.hasAttribute("height")?e.height.baseVal.value:parseFloat(l.height)||150,s=e.getAttribute("viewBox")?e.viewBox.baseVal:{x:0,y:0,width:a,height:n},{x:r,y:i,width:u,height:p}=s;if(s={x:r,y:i,width:u,height:p},t)for(let e in s)s[e]=Math.ceil(s[e]);return s}le[77]=2,le[109]=2,le[65]=7,le[97]=7,le[67]=6,le[99]=6,le[76]=2,le[108]=2,le[81]=4,le[113]=4,le[83]=4,le[115]=4,le[84]=2,le[116]=2,le[72]=1,le[104]=1,le[86]=1,le[118]=1,le[90]=0,le[122]=0;const{abs:ce,acos:xe,asin:fe,atan:ge,atan2:ve,ceil:de,cos:me,exp:Me,floor:be,log:Ce,hypot:Ae,max:we,min:Le,pow:Pe,random:Se,round:Ie,sin:Fe,sqrt:ke,tan:$e,PI:ze}=Math;"undefined"!=typeof window&&(window.svgPathSimplify=ye,window.getViewBox=oe,window.renderPoint=function(e,t,l="red",a="1%",n="1",s="",r=!0,i="",u=""){Array.isArray(t)&&(t={x:t[0],y:t[1]});let p=`<circle class="${u}" opacity="${n}" id="${i}" cx="${t.x}" cy="${t.y}" r="${a}" fill="${l}">\n <title>${s}</title></circle>`;if(!r)return p;e.insertAdjacentHTML("beforeend",p)}),e.PI=ze,e.abs=ce,e.acos=xe,e.asin=fe,e.atan=ge,e.atan2=ve,e.ceil=de,e.cos=me,e.exp=Me,e.floor=be,e.getViewBox=oe,e.hypot=Ae,e.log=Ce,e.max=we,e.min=Le,e.pow=Pe,e.random=Se,e.round=Ie,e.sin=Fe,e.sqrt=ke,e.svgPathSimplify=ye,e.tan=$e}(this["svg-path-simplify"]=this["svg-path-simplify"]||{});
@@ -3609,12 +3609,98 @@ function pathDataToTopLeft(pathData) {
3609
3609
  }
3610
3610
 
3611
3611
  // reorder to top left most
3612
- indices = indices.sort((a, b) => +a.y.toFixed(3) - +b.y.toFixed(3) || a.x - b.x);
3612
+
3613
+ indices = indices.sort((a, b) => +a.y.toFixed(3) - +b.y.toFixed(3) );
3613
3614
  newIndex = indices[0].index;
3614
3615
 
3615
3616
  return newIndex ? shiftSvgStartingPoint(pathData, newIndex) : pathData;
3616
3617
  }
3617
3618
 
3619
+ function optimizeClosePath(pathData, removeFinalLineto = true, reorder = true) {
3620
+
3621
+ let pathDataNew = [];
3622
+ let len = pathData.length;
3623
+ let M = { x: +pathData[0].values[0].toFixed(8), y: +pathData[0].values[1].toFixed(8) };
3624
+ let isClosed = pathData[len - 1].type.toLowerCase() === 'z';
3625
+
3626
+ let linetos = pathData.filter(com => com.type === 'L');
3627
+
3628
+ // check if order is ideal
3629
+ let penultimateCom = pathData[len - 2];
3630
+ let penultimateType = penultimateCom.type;
3631
+ let penultimateComCoords = penultimateCom.values.slice(-2).map(val => +val.toFixed(8));
3632
+
3633
+ // last L command ends at M
3634
+ let isClosingCommand = penultimateComCoords[0] === M.x && penultimateComCoords[1] === M.y;
3635
+
3636
+ // if last segment is not closing or a lineto
3637
+ let skipReorder = pathData[1].type !== 'L' && (!isClosingCommand || penultimateType === 'L');
3638
+ skipReorder = false;
3639
+
3640
+ // we can't change starting point for non closed paths
3641
+ if (!isClosed) {
3642
+ return pathData
3643
+ }
3644
+
3645
+ let newIndex = 0;
3646
+
3647
+ if (!skipReorder) {
3648
+
3649
+ let indices = [];
3650
+ for (let i = 0, len = pathData.length; i < len; i++) {
3651
+ let com = pathData[i];
3652
+ let { type, values } = com;
3653
+ if (values.length) {
3654
+ let valsL = values.slice(-2);
3655
+ let prevL = pathData[i - 1] && pathData[i - 1].type === 'L';
3656
+ let nextL = pathData[i + 1] && pathData[i + 1].type === 'L';
3657
+ let prevCom = pathData[i - 1] ? pathData[i - 1].type.toUpperCase() : null;
3658
+ let nextCom = pathData[i + 1] ? pathData[i + 1].type.toUpperCase() : null;
3659
+ let p = { type: type, x: valsL[0], y: valsL[1], dist: 0, index: 0, prevL, nextL, prevCom, nextCom };
3660
+ p.index = i;
3661
+ indices.push(p);
3662
+ }
3663
+ }
3664
+
3665
+ // find top most lineto
3666
+
3667
+ if (linetos.length) {
3668
+ let curveAfterLine = indices.filter(com => (com.type !== 'L' && com.type !== 'M') && com.prevCom &&
3669
+ com.prevCom === 'L' || com.prevCom === 'M' && penultimateType === 'L').sort((a, b) => a.y - b.y || a.x - b.x)[0];
3670
+
3671
+ newIndex = curveAfterLine ? curveAfterLine.index - 1 : 0;
3672
+
3673
+ }
3674
+ // use top most command
3675
+ else {
3676
+ indices = indices.sort((a, b) => +a.y.toFixed(1) - +b.y.toFixed(1) || a.x - b.x);
3677
+ newIndex = indices[0].index;
3678
+ }
3679
+
3680
+ // reorder
3681
+ pathData = newIndex ? shiftSvgStartingPoint(pathData, newIndex) : pathData;
3682
+ }
3683
+
3684
+ M = { x: +pathData[0].values[0].toFixed(8), y: +pathData[0].values[1].toFixed(7) };
3685
+
3686
+ len = pathData.length;
3687
+
3688
+ // remove last lineto
3689
+ penultimateCom = pathData[len - 2];
3690
+ penultimateType = penultimateCom.type;
3691
+ penultimateComCoords = penultimateCom.values.slice(-2).map(val=>+val.toFixed(8));
3692
+
3693
+ isClosingCommand = penultimateType === 'L' && penultimateComCoords[0] === M.x && penultimateComCoords[1] === M.y;
3694
+
3695
+ if (removeFinalLineto && isClosingCommand) {
3696
+ pathData.splice(len - 2, 1);
3697
+ }
3698
+
3699
+ pathDataNew.push(...pathData);
3700
+
3701
+ return pathDataNew
3702
+ }
3703
+
3618
3704
  /**
3619
3705
  * shift starting point
3620
3706
  */
@@ -4082,10 +4168,14 @@ function svgPathSimplify(input = '', {
4082
4168
  });
4083
4169
  }
4084
4170
 
4171
+ // optimize close path
4172
+ if(optimizeOrder) pathData=optimizeClosePath(pathData);
4173
+
4085
4174
  // update
4086
4175
  pathDataArrN.push(pathData);
4087
4176
  }
4088
4177
 
4178
+
4089
4179
  // flatten compound paths
4090
4180
  pathData = pathDataArrN.flat();
4091
4181
 
@@ -1 +1 @@
1
- "use strict";const{abs:e,acos:t,asin:l,atan:a,atan2:n,ceil:s,cos:r,exp:i,floor:u,log:p,max:h,min:o,pow:y,random:c,round:x,sin:f,sqrt:g,tan:v,PI:d}=Math;function m(e,t,l=!1){let a=n(t.y-e.y,t.x-e.x);return l&&a<0&&(a+=2*Math.PI),a}function M(e,t,l,a,n=!0){let s,r,i,u,p,h={};try{if(s=(a.y-l.y)*(t.x-e.x)-(a.x-l.x)*(t.y-e.y),0==s)return!1}catch{console.log("!catch",e,t,"p3:",l,a)}r=e.y-l.y,i=e.x-l.x,u=(a.x-l.x)*r-(a.y-l.y)*i,p=(t.x-e.x)*r-(t.y-e.y)*i,r=u/s,i=p/s,h={x:e.x+r*(t.x-e.x),y:e.y+r*(t.y-e.y)};let o=!1;return r>0&&r<1&&i>0&&i<1&&(o=!0),!(n&&!o)&&h}function b(e,t){return g((t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y))}function A(e,t){return(t.x-e.x)**2+(t.y-e.y)**2}function C(e,t,l,a=!1){let n={x:(t.x-e.x)*l+e.x,y:(t.y-e.y)*l+e.y};return a&&(n.angle=m(e,t),n.angle<0&&(n.angle+=2*d)),n}function w(e,t=.5,l=!1,a=!1){let n;return n=e.length>2?((e,t,l=!1)=>{let n=4===e.length,s=e[0],r=e[1],i=n?e[2]:e[1],u=e[e.length-1],p={x:0,y:0};if(l||a){let e,l,h,o,y,c=s.x===r.x&&s.y===r.y,x=u.x===i.x&&u.y===i.y;0!==t||c?1!==t||x?(c&&(t+=1e-7),x&&(t-=1e-7),e=C(s,r,t),n?(l=C(r,i,t),h=C(i,u,t),o=C(e,l,t),y=C(l,h,t),p=C(o,y,t),p.angle=m(o,y),a&&(p.cpts=[l,h,o,y])):(l=C(s,r,t),h=C(r,u,t),p=C(l,h,t),p.angle=m(l,h),a&&(p.cpts=[l,h]))):(p.x=u.x,p.y=u.y,p.angle=m(i,u)):(p.x=s.x,p.y=s.y,p.angle=m(s,r))}else{let e=1-t;p=n?{x:e**3*s.x+3*e**2*t*r.x+3*e*t**2*i.x+t**3*u.x,y:e**3*s.y+3*e**2*t*r.y+3*e*t**2*i.y+t**3*u.y}:{x:e*e*s.x+2*e*t*r.x+t**2*u.x,y:e*e*s.y+2*e*t*r.y+t**2*u.y}}return p})(e,t,l):C(e[0],e[1],t,l),l&&n.angle<0&&(n.angle+=2*d),n}function P(e,t,l,n,s,i=0,u=!0,p=!1){if(s=p?s*d/180:s,i=p?i*d/180:i,i=l!==n&&i!==2*d?i:0,u&&l!==n){let e=a(v(s=i?s-i:s)*(l/n));s=r(s)<0?e+d:e}let h=e+l*r(s),o=t+n*f(s),y={x:h,y:o};return i&&(y.x=e+(h-e)*r(i)-(o-t)*f(i),y.y=t+(h-e)*f(i)+(o-t)*r(i)),y}function S(e,t=[],l=.05){let a=3===t.length,n=t[0]||null,s=a?t[1]:null,r=a?t[2]:t[1],i=.5*Math.PI,u=!1,p=!1,h=n?m(r,n,!0):null;if(u=Math.abs(h%i)<l||Math.abs(h%i-i)<l,a){let e=s?m(s,r,!0):0;p=Math.abs(e%i)<=l||Math.abs(e%i-i)<=l}return u||p}function L(e){return 4===e.length?function(e,t,l,a){let[n,s,r,i,u,p,h,o]=[e.x,e.y,t.x,t.y,l.x,l.y,a.x,a.y],y=Math.min(e.y,a.y),c=Math.min(e.x,a.x),x=Math.max(e.x,a.x),f=Math.max(e.y,a.y);if(t.y>=y&&t.y<=f&&l.y>=y&&l.y<=f&&t.x>=c&&t.x<=x&&l.x>=c&&l.x<=x)return[];let g,v,d,m,M,b,A,C,w=[];for(let e=0;e<2;++e)if(0==e?(v=6*n-12*r+6*u,g=-3*n+9*r-9*u+3*h,d=3*r-3*n):(v=6*s-12*i+6*p,g=-3*s+9*i-9*p+3*o,d=3*i-3*s),Math.abs(g)<1e-12){if(Math.abs(v)<1e-12)continue;m=-d/v,0<m&&m<1&&w.push(m)}else A=v*v-4*d*g,A<0?Math.abs(A)<1e-12&&(m=-v/(2*g),0<m&&m<1&&w.push(m)):(C=Math.sqrt(A),M=(-v+C)/(2*g),0<M&&M<1&&w.push(M),b=(-v-C)/(2*g),0<b&&b<1&&w.push(b));let P=w.length;for(;P--;)m=w[P];return w}(e[0],e[1],e[2],e[3]):function(e,t,l){let a,n,s,r=Math.min(e.y,l.y),i=Math.min(e.x,l.x),u=Math.max(e.x,l.x),p=Math.max(e.y,l.y);if(t.y>=r&&t.y<=p&&t.x>=i&&t.x<=u)return[];let[h,o,y,c,x,f]=[e.x,e.y,t.x,t.y,l.x,l.y],g=[];for(let e=0;e<2;++e)a=0==e?h-2*y+x:o-2*c+f,n=0==e?-2*h+2*y:-2*o+2*c,Math.abs(a)>1e-12&&(s=-n/(2*a),s>0&&s<1&&g.push(s));return g}(e[0],e[1],e[2])}function I(e,t=.025){let l=e[0],a=e[e.length-1],n=e.map(e=>e.x),s=e.map(e=>e.y),r=Math.min(...n),i=Math.max(...n),u=Math.min(...s),p=i-r,h=Math.max(...s)-u;if(e.length<3||0===p||0===h)return{area:0,flat:!0,thresh:1e-4,ratio:0};let o=A(l,a),y=A(l,e[0]),c=(y+(e.length>3?A(a,e[1]):y))/2;let x=.5*(p+h)*.5,f=0;for(let t=0,l=e.length;t<l;t++){f+=e[t].x*e[t===e.length-1?0:t+1].y*.5-e[t===e.length-1?0:t+1].x*e[t].y*.5}f=+Math.abs(f).toFixed(9);return{area:f,flat:0===f||f<c/1e3,thresh:x,ratio:f/c,squareDist:o,areaThresh:o/1e3}}function k(e,t,l){let a=!1,n=2===t.length,s=t[0],r=n?t[1]:s;if(e.x===s.x&&e.y===s.y&&l.x===r.x&&l.y===r.y)return!0;let i=s.x-e.x,u=s.y-e.y,p=l.x-r.x,h=l.y-r.y,o=Math.abs(i*h-u*p);if(!o)return!0;let y=l.x-e.x,c=l.y-e.y,x=Math.abs(y*u-c*i);return!x||(x/o<1.1&&(a=!0),a)}function $(e,t){return(Math.abs(t.x-e.x)+Math.abs(t.y-e.y))/2}function z(e){let t=[];try{e.map((e,t)=>"m"===e.type.toLowerCase()?t:-1).filter(e=>-1!==e)}catch{console.log("catch",e)}let l=e.map((e,t)=>"m"===e.type.toLowerCase()?t:-1).filter(e=>-1!==e);return 1===l.length?[e]:(l.forEach((a,n)=>{t.push(e.slice(a,l[n+1]))}),t)}function E(e,t){let l,a,n,s,r,i,u=[],p=[],h=e[0],o=e[1],y=e[e.length-2],c=e[e.length-1];return 4===e.length?(l=w([h,o],t),a=w([o,y],t),n=w([y,c],t),s=w([l,a],t),r=w([a,n],t),i=w([s,r],t),u.push({x:h.x,y:h.y},{x:l.x,y:l.y},{x:s.x,y:s.y},{x:i.x,y:i.y}),p.push({x:i.x,y:i.y},{x:r.x,y:r.y},{x:n.x,y:n.y},{x:c.x,y:c.y})):3===e.length?(a=w([h,o],t),n=w([o,c],t),i=w([a,n],t),u.push({x:h.x,y:h.y},{x:a.x,y:a.y},{x:i.x,y:i.y}),p.push({x:i.x,y:i.y},{x:n.x,y:n.y},{x:c.x,y:c.y})):2===e.length&&(a=w([h,c],t),u.push({x:h.x,y:h.y},{x:a.x,y:a.y}),p.push({x:a.x,y:a.y},{x:c.x,y:c.y})),[u,p]}function T(e,t,l=0,a=1){let n=[],s=6===t.length?"C":"Q",r={x:t[0],y:t[1]},i="C"===s?{x:t[2],y:t[3]}:r,u={x:t[4],y:t[5]},p=Math.max(u.x,e.x),h=Math.min(u.x,e.x),o=Math.max(u.y,e.y),y=Math.min(u.y,e.y),c=0;if(r.x<h||r.x>p||r.y<y||r.y>o||i.x<h||i.x>p||i.y<y||i.y>o){let p=L("C"===s?[e,r,i,u]:[e,r,u]).sort();if(p=p.filter(e=>e>l&&e<a),p.length){let l=function(e,t,l,a=!0){let n=[];if(!l.length)return!1;let s,r,i,u=t.length,p={x:t[u-2],y:t[u-1]};2===t.length?i=[e,p]:4===t.length?(s={x:t[0],y:t[1]},i=[e,s,p]):6===t.length&&(s={x:t[0],y:t[1]},r={x:t[2],y:t[3]},i=[e,s,r,p]);if(l.length)if(1===l.length){let e=E(i,l[0]),t=e[0],a=e[1];n.push(t,a)}else{let e=l[0],t=E(i,e),a=t[0];n.push(a),i=t[1];for(let t=1;t<l.length;t++){e=l[t-1];let a=E(i,(l[t]-e)/(1-e));n.push(a[0]),t===l.length-1&&n.push(a[a.length-1]),i=a[1]}}if(a){let e,t,l=[];return n.forEach(a=>{e={type:"",values:[]},a.shift(),t=a.map(e=>Object.values(e)).flat(),e.values=t,3===a.length?e.type="C":2===a.length?e.type="Q":1===a.length&&(e.type="L"),l.push(e)}),l}return n}(e,t,p);n.push(...l),c+=l.length}else n.push({type:s,values:t})}else n.push({type:s,values:t});return{pathData:n,count:c}}function Q(e,t=0,l=1){let a=[e[0]],n={x:e[0].values[0],y:e[0].values[1]},s={x:e[0].values[0],y:e[0].values[1]},r=e.length;for(let i=1;r&&i<r;i++){let r=e[i],{type:u,values:p}=r,h=p.slice(-2);if(h[0],h[1],"C"!==u&&"Q"!==u)a.push(r);else if("C"===u||"Q"===u){let e=T(n,p,t,l).pathData;a.push(...e)}n={x:h[0],y:h[1]},"z"===u.toLowerCase()?n=s:"M"===u&&(s={x:h[0],y:h[1]})}return a}function F(e,t=-1){let l=e.map(e=>e.x),a=e.map(e=>e.y),n=Math.min(...l),s=Math.max(...l),r=Math.min(...a),i=Math.max(...a),u={x:n,left:n,right:s,y:r,top:r,bottom:i,width:s-n,height:i-r};if(t>-1)for(let e in u)u[e]=+u[e].toFixed(t);return u}function q(e){let t=[];return e.forEach(e=>{let l=function(e){let t=function(e){let t=[];for(let l=0;l<e.length;l++){let a=e[l],n=l>0?e[l-1]:e[l],{type:s,values:r}=a,i={x:n.values[n.values.length-2],y:n.values[n.values.length-1]},u=r.length?{x:r[r.length-2],y:r[r.length-1]}:"",p=r.length?{x:r[0],y:r[1]}:"";switch(s){case"A":if("function"!=typeof arcToBezier){let e=b(i,u)/2,l=C(i,u,.5),a=P(l.x,l.y,e,e,0),n=P(l.x,l.y,e,e,Math.PI);t.push(a,n,u);break}arcToBezier(i,r).forEach(e=>{let l=e.values,a={x:l[0],y:l[1]},n={x:l[2],y:l[3]},s={x:l[4],y:l[5]};t.push(a,n,s)});break;case"C":let e={x:r[2],y:r[3]};t.push(p,e);break;case"Q":t.push(p)}"z"!==s.toLowerCase()&&t.push(u)}return t}(e),l=F(t);return l}(e);t.push(l)}),t}function D(e,t){let[l,a,n,s,r,i]=[e.x,e.y,e.width,e.height,e.x+e.width,e.y+e.height],[u,p,h,o,y,c]=[t.x,t.y,t.width,t.height,t.x+t.width,t.y+t.height],x=!1;return n*s!=h*o&&n*s>h*o&&l<u&&r>y&&a<p&&i>c&&(x=!0),x}function B(t,l=9){let a=0,s=[],i=z(t),u=i.length>1,p=[];if(u){let e=q(i);e.forEach(function(t,l){for(let l=0;l<e.length;l++){let a=e[l];if(t!=a){D(t,a)&&p.push(l)}}})}return i.forEach((t,l)=>{s=[];let i=0,u=0,h=1,o=[];t.forEach(function(l,a){let[u,p]=[l.type,l.values],h=p.length;if(p.length){let y=(a>0?t[a-1]:t[0]).values,c=y.length,x={x:y[c-2],y:y[c-1]},v={x:p[h-2],y:p[h-1]};if("C"===u||"Q"===u){let e={x:p[0],y:p[1]};o="C"===u?[x,e,{x:p[2],y:p[3]},v]:[x,e,v];let t=Math.abs(function(e,t=!1){let l,[a,n,s,r]=[e[0],e[1],e[2],e[e.length-1]];if(e.length<3)return 0;3===e.length&&(n={x:1*e[0].x/3+2*e[1].x/3,y:1*e[0].y/3+2*e[1].y/3},s={x:1*e[2].x/3+2*e[1].x/3,y:1*e[2].y/3+2*e[1].y/3});return l=3*(a.x*(-2*n.y-s.y+3*r.y)+n.x*(2*a.y-s.y-r.y)+s.x*(a.y+n.y-2*r.y)+r.x*(-3*a.y+n.y+2*s.y))/20,t?Math.abs(l):l}(o));i+=t,s.push(x,v)}else if("A"===u){let t=function(t,l,a,s,i,u,p,h,o){const y=(e,t,l,a)=>n(a-t,l-e);let c={cx:0,cy:0,rx:a=e(a),ry:s=e(s),startAngle:0,endAngle:0,deltaAngle:0,clockwise:p,xAxisRotation:i,largeArc:u,sweep:p};if(0==a||0==s)throw Error("rx and ry can not be 0");if(a===s){let e=Math.abs(h-t),a=Math.abs(o-l),n=e,s=Math.min(t,h),r=Math.min(l,o),i=.5*Math.PI;if(0===e&&a||0===a&&e)return n=0===e&&a?a/2:e/2,c.rx=n,c.ry=n,0===e&&a?(c.cx=t,c.cy=r+a/2,c.startAngle=l>o?i:-i,c.endAngle=l>o?-i:i,c.deltaAngle=p?Math.PI:-Math.PI):0===a&&e&&(c.cx=s+e/2,c.cy=l,c.startAngle=t>h?Math.PI:0,c.endAngle=t>h?-Math.PI:Math.PI,c.deltaAngle=p?Math.PI:-Math.PI),c}let x,v,m=a===s?0:i*d/180,M=m?f(m):0,b=m?r(m):1,A=(t-h)/2,C=(l-o)/2,w=(t+h)/2,P=(l+o)/2,S=m?b*A+M*C:A,L=m?b*C-M*A:C,I=S*S/(a*a)+L*L/(s*s);I>1&&(a*=g(I),s*=g(I),c.rx=a,c.ry=s);let k=a*s,$=a*L,z=s*S,E=$**2+z**2;if(!E)throw Error("start point can not be same as end point");let T=g(e((k*k-E)/E));u==p&&(T=-T);let Q=T*$/s,F=-T*z/a;x=m?b*Q-M*F+w:w+Q,v=m?M*Q+b*F+P:P+F,c.cy=v,c.cx=x;let q=y(x,v,t,l),D=y(x,v,h,o);!p&&D>q&&(D-=2*Math.PI),p&&q>D&&(D=D<=0?D+2*Math.PI:D);let B=D-q;return c.startAngle=q,c.endAngle=D,c.deltaAngle=B,c}(x.x,x.y,l.values[0],l.values[1],l.values[2],l.values[3],l.values[4],v.x,v.y),{cx:a,cy:u,rx:p,ry:h,startAngle:o,endAngle:y,deltaAngle:c}=t,m=Math.abs(function(e,t,l,a){const n=Math.PI*e*t;let s=(a-l+2*Math.PI)%(2*Math.PI);if(e===t)return n*(s/(2*Math.PI));const r=l=>Math.atan2(e*Math.sin(l),t*Math.cos(l));return l=r(l),a=r(a),s=(a-l+2*Math.PI)%(2*Math.PI),n*(s/(2*Math.PI))}(p,h,o,y));m-=Math.abs(O([x,{x:a,y:u},v])),s.push(x,v),i+=m}else s.push(x,v)}});let y=O(s);-1!==p.indexOf(l)&&(h=-1),u=y<0&&i<0?(Math.abs(i)-Math.abs(y))*h:(Math.abs(i)+Math.abs(y))*h,a+=u}),a}function O(e,t=!1){let l=0;for(let t=0,a=e.length;a&&t<a;t++){l+=e[t].x*e[t===e.length-1?0:t+1].y*.5-e[t===e.length-1?0:t+1].x*e[t].y*.5}return t&&(l=Math.abs(l)),l}function j(e,t=0){t=parseFloat(t);let l=e.length,a=t>1,n=!a&&!t,s="",r=a?"\n":n?"":" ",i=n?"":" ";s=`${e[0].type}${i}${e[0].values.join(" ")}${r}`;for(let t=1;t<l;t++){let l=e[t-1],a=e[t],{type:u,values:p}=a;if(!n||"A"!==u&&"a"!==u||(p=[p[0],p[1],p[2],`${p[3]}${p[4]}${p[5]}`,p[6]]),u=l.type===a.type&&"m"!==a.type.toLowerCase()&&n||"M"===l.type&&"L"===a.type&&n?" ":a.type,n){let e="",t=!1;for(let l=0,a=p.length;l<a;l++){let a=p[l],n=a.toString(),s=n.includes(".")&&Math.abs(a)<1;s&&t&&(n=n.replace(/^0\./,".")),!(l>0)||t&&s||(e+=" "),e+=n,t=s}s+=`${u}${i}${e}${r}`}else s+=`${u}${i}${p.join(" ")}${r}`}return n&&(s=s.replace(/ 0\./g," .").replace(/ -/g,"-").replace(/-0\./g,"-.").replace(/Z/g,"z")),s}function N(e,t,l=!1,a=1){let n=[e,t],s=function(e,t){let l=M(e.p0,e.cp1,t.cp2,t.p,!1),a=M(l,t.p,t.p0,t.cp1,!1),n=b(l,t.p),s=b(a,t.p),r=1-s/n,i=b(e.cp2,e.p),u=b(e.cp2,t.cp1);return r=Math.min(i)/u,r}(e,t),r=$(e.p0,e.p),i=$(t.p0,t.p),u=.05*Math.min(r,i)*a,p=function(e,t,l=0,a=0){let{p0:n,cp1:s}=e,{p:r,cp2:i}=t,u={x:(s.x-(1-l)*n.x)/l,y:(s.y-(1-l)*n.y)/l},p={x:(i.x-a*r.x)/(1-a),y:(i.y-a*r.y)/(1-a)},h={p0:n,cp1:u,cp2:p,p:r};return h}(e,t,s,s),h=w([p.p0,p.cp1,p.cp2,p.p],s),o=$(e.p,h),y=0,c=0,x=!1,f=o;if(o<u){let l=.5*(1+s);if(y=$(w([t.p0,t.cp1,t.cp2,t.p],.5),w([p.p0,p.cp1,p.cp2,p.p],l)),f+=y,y<u){let t=.5*s;c=$(w([e.p0,e.cp1,e.cp2,e.p],.5),w([p.p0,p.cp1,p.cp2,p.p],t)),y+c<u&&(x=!0),f+=c}}if(l&&!x){let l=function(e,t,l=0,a=1){const n=(e,t,l,a,n)=>{let s=1-n;return{x:3*s*s*(t.x-e.x)+6*s*n*(l.x-t.x)+3*n*n*(a.x-l.x),y:3*s*s*(t.y-e.y)+6*s*n*(l.y-t.y)+3*n*n*(a.y-l.y)}};let s=[e,t],r=A(e.p0,e.p)>A(t.p0,t.p),i=JSON.parse(JSON.stringify(e)),u=JSON.parse(JSON.stringify(t)),p=M(i.p0,i.cp1,u.p,u.cp2,!1);if(!p)return s;if(r){let l={p0:{x:e.p.x,y:e.p.y},cp1:{x:e.cp2.x,y:e.cp2.y},cp2:{x:e.cp1.x,y:e.cp1.y},p:{x:e.p0.x,y:e.p0.y}};e={p0:{x:t.p.x,y:t.p.y},cp1:{x:t.cp2.x,y:t.cp2.y},cp2:{x:t.cp1.x,y:t.cp1.y},p:{x:t.p0.x,y:t.p0.y}},t=l}let h=(e,t)=>({x:e.x-t.x,y:e.y-t.y}),o=(e,t)=>({x:e.x*t,y:e.y*t}),y=(e,t)=>e.x*t.x+e.y*t.y,c=t.p0,x=n(t.p0,t.cp1,t.cp2,t.p,0),f=y(h(e.p0,c),x)/y(x,x),g=w([t.p0,t.cp1,t.cp2,t.p],f),v=n(t.p0,t.cp1,t.cp2,t.p,f);f-=y(h(g,e.p0),v)/y(v,v);let d=w([t.p0,t.cp1,t.cp2,t.p],f),m=t.p,b=n(t.p0,t.cp1,t.cp2,t.p,f),P=n(t.p0,t.cp1,t.cp2,t.p,1),S=1-f,L=(I=d,k=o(b,S/3),{x:I.x+k.x,y:I.y+k.y});var I,k;let z=h(m,o(P,S/3)),E={p0:d,cp1:L,cp2:z,p:m};r&&(E={p0:m,cp1:z,cp2:L,p:d});let T=w([E.p0,E.cp1,E.cp2,E.p],.5,!1,!0),Q=T.cpts[2],F=M(T,Q,E.p0,p,!1),q=M(T,Q,E.p,p,!1),D=C(E.p0,F,1.333),O=C(E.p,q,1.333);if(M(i.p0,D,u.p,O,!0))return s;E.cp1=D,E.cp2=O;let N=$(i.p0,E.p0)+$(u.p,E.p);if(E.p0=i.p0,E.p=u.p,E.extreme=u.extreme,E.corner=u.corner,E.dimA=u.dimA,E.directionChange=u.directionChange,E.values=[E.cp1.x,E.cp1.y,E.cp2.x,E.cp2.y,E.p.x,E.p.y],N<l){let e=B([{type:"M",values:[i.p0.x,i.p0.y]},{type:"C",values:[i.cp1.x,i.cp1.y,i.cp2.x,i.cp2.y,i.p.x,i.p.y]},{type:"C",values:[u.cp1.x,u.cp1.y,u.cp2.x,u.cp2.y,u.p.x,u.p.y]}]),t=[{type:"M",values:[E.p0.x,E.p0.y]},{type:"C",values:[E.cp1.x,E.cp1.y,E.cp2.x,E.cp2.y,E.p.x,E.p.y]}],l=B(t),n=Math.abs(l/e-1);E.error=10*n*a,j(t),n<.01&&(s=[E])}return s}(e,t,u,a);1===l.length&&(x=!0,p=l[0],f=p.error)}return x&&(p.p0=e.p0,p.p=t.p,p.dimA=$(p.p0,p.p),p.type="C",p.extreme=t.extreme,p.directionChange=t.directionChange,p.corner=t.corner,p.values=[p.cp1.x,p.cp1.y,p.cp2.x,p.cp2.y,p.p.x,p.p.y],p.error=f/u,n=[p]),n}function V(e=[]){let t,l=[],a=function(e){let t=[],l={x:e[0].values[0],y:e[0].values[1]};return e.forEach(e=>{let{type:a,values:n}=e;if(n.length){let e=n.length>1?{x:n[n.length-2],y:n[n.length-1]}:"V"===a?{x:l.x,y:n[0]}:{x:n[0],y:l.y};t.push(e),l=e}}),t}(e),n=F(a),{left:s,right:r,top:i,bottom:u,width:p,height:h}=n,o=e[0].values[0],y=e[0].values[1],c={x:e[0].values[0],y:e[0].values[1]},x={x:e[0].values[0],y:e[0].values[1]};e[0].idx=0,e[0].p0=c,e[0].p=c,e[0].lineto=!1,e[0].corner=!1,e[0].extreme=!1,e[0].directionChange=!1,e[0].closePath=!1,e[0].dimA=0;let f=[e[0]],g=0,v=e.length;for(let l=2;v&&l<=v;l++){let a=e[l-1],{type:n,values:p}=a,h=p.slice(-2),v=[x],d=!1;a.idx=l-1,a.lineto=!1,a.corner=!1,a.extreme=!1,a.directionChange=!1,a.closePath=!1,a.dimA=0;let M,b,C,w,P,L,k,z=.05;t=h.length?{x:h[0],y:h[1]}:c,"M"===n?(c=t,x=t):"z"===n.toLowerCase()&&(t=c),a.p0=x,a.p=t;let E=$(x,t);if(a.dimA=E,"L"===n&&(a.lineto=!0),"Z"===n&&(a.closePath=!0,c.x!==o&&c.y!==y&&(a.lineto=!0)),"Q"!==n&&"C"!==n||(M={x:p[0],y:p[1]},b="C"===n?{x:p[2],y:p[3]}:null,a.cp1=M,b&&(a.cp2=b)),p.length>2){"Q"!==n&&"C"!==n||v.push(M),"C"===n&&v.push(b),v.push(t),d=I(v).flat,a.flat=d,d&&(a.extreme=!1)}d||"L"===n||t.x!==s&&t.y!==i&&t.x!==r&&t.y!==u||(a.extreme=!0);let T=e[l]?e[l]:null,Q=T?T.values.slice(-2):null;L=T?T.type:null,!T||"Q"!==T.type&&"C"!==T.type||(P=T?{x:Q[0],y:Q[1]}:null,C={x:T.values[0],y:T.values[1]},w="C"===T.type?{x:T.values[2],y:T.values[3]}:null),k=O(v);let F=g<0&&k>0||g>0&&k<0;if(g=k,F&&(a.directionChange=!0),("Q"===n||"C"===n)&&("Q"===n&&"Q"===L||"C"===n&&"C"===L)){let e=v.slice(1),l=I("C"===n?[t,C,w,P]:[t,C,P],((P?Math.abs(P.x-x.x):0)+(P?Math.abs(P.y-x.y):0))/2*.1).flat;if((!d||!l)&&(!!a.extreme||S(0,e,z)))a.extreme=!0;else{let e=b?[b,t]:[M,t],l=[t,C],n=m(...e,!0),s=m(...l,!0),r=180*Math.abs(n-s)/Math.PI,i=A(...e),u=A(...l);r>10&&i&&u&&(a.corner=!0)}}f.push(a),x=t}return l={pathData:f,bb:n,dimA:(p+h)/2},l}function H(e,t=-1){let l=!("auto"!=t||!e[0].hasOwnProperty("decimals"));for(let a=0,n=e.length;a<n;a++){let n=e[a];(t>-1||l)&&(t=l?n.decimals:t,e[a].values=n.values.map(e=>e?+e.toFixed(t):e))}return e}function Z(e={},t={},l={},a={}){let n=C(e,t,1.5),s=C(a,l,1.5),r=.01*$(e,a),i=$(n,s),u=null,p="C",h=[t.x,t.y,l.x,l.y,a.x,a.y];return i<r&&(u=M(e,t,a,l,!1),u&&(p="Q",h=[u.x,u.y,a.x,a.y])),{type:p,values:h}}function R(e,{toShorthands:t=!0,toRelative:l=!0,decimals:a=3}={}){return t&&(e=function(e,t=-1,l=!0){let a;if(l){let t=e.map(e=>e.type).join("");a=/[astvqmhlc]/g.test(t)}e=l&&a?W(e,t):e;let n={type:"M",values:e[0].values};e[0].decimals&&(n.decimals=e[0].decimals);let s,r=[n],i={x:e[0].values[0],y:e[0].values[1]},u=.01;for(let l=1,a=e.length;l<a;l++){let a=e[l],{type:p,values:h}=a,o=h.slice(-2),y=e[l-1],c=y.type;s={x:o[0],y:o[1]};let x,f,g,v,d={x:h[0],y:h[1]},m=Math.abs(s.x-i.x),M=Math.abs(s.y-i.y),b=(m+M)/2*u;switch(p){case"L":n=0===M||M<b&&m>b?{type:"H",values:[h[0]]}:0===m||M>b&&m<b?{type:"V",values:[h[1]]}:a;break;case"Q":if("Q"!==c){i={x:o[0],y:o[1]},r.push(a);continue}let e={x:y.values[0],y:y.values[1]};v={x:2*i.x-e.x,y:2*i.y-e.y},x=Math.abs(d.x-v.x),f=Math.abs(d.y-v.y),g=(x+f)/2,n=g<b?{type:"T",values:[s.x,s.y]}:a;break;case"C":let t={x:h[2],y:h[3]};if("C"!==c){r.push(a),i={x:o[0],y:o[1]};continue}let l={x:y.values[2],y:y.values[3]};v={x:2*i.x-l.x,y:2*i.y-l.y},x=Math.abs(d.x-v.x),f=Math.abs(d.y-v.y),g=(x+f)/2,n=g<b?{type:"S",values:[t.x,t.y,s.x,s.y]}:a;break;default:n={type:p,values:h}}(a.decimals||0===a.decimals)&&(n.decimals=a.decimals),t>-1&&(n.values=n.values.map(e=>+e.toFixed(t))),i={x:o[0],y:o[1]},r.push(n)}return r}(e)),e=H(e,a),l&&(e=function(e,t=-1){return U(e,!0,t)}(e)),a>-1&&(e=H(e,a)),e}function J(e,t){Array.isArray(e)&&(e={x:e[0],y:e[1]});let l={x:e.x+2/3*(t[0]-e.x),y:e.y+2/3*(t[1]-e.y)},a={x:t[2]+2/3*(t[0]-t[2]),y:t[3]+2/3*(t[1]-t[3])};return{type:"C",values:[l.x,l.y,a.x,a.y,t[2],t[3]]}}function U(e,t=!1,l=-1){l>=0&&(e[0].values=e[0].values.map(e=>+e.toFixed(l)));let a=e[0].values,n=a[0],s=a[1],r=n,i=s;for(let a=1,u=e.length;a<u;a++){let u=e[a],{type:p,values:h}=u,o=t?p.toLowerCase():p.toUpperCase();if(p!==o)switch(p=o,u.type=p,p){case"a":case"A":h[5]=t?h[5]-n:h[5]+n,h[6]=t?h[6]-s:h[6]+s;break;case"v":case"V":h[0]=t?h[0]-s:h[0]+s;break;case"h":case"H":h[0]=t?h[0]-n:h[0]+n;break;case"m":case"M":t?(h[0]-=n,h[1]-=s):(h[0]+=n,h[1]+=s),r=t?h[0]+n:h[0],i=t?h[1]+s:h[1];break;default:if(h.length)for(let e=0;e<h.length;e++)h[e]=t?h[e]-(e%2?s:n):h[e]+(e%2?s:n)}let y=h.length;switch(p){case"z":case"Z":n=r,s=i;break;case"h":case"H":n=t?n+h[0]:h[0];break;case"v":case"V":s=t?s+h[0]:h[0];break;case"m":case"M":r=h[y-2]+(t?n:0),i=h[y-1]+(t?s:0);default:n=h[y-2]+(t?n:0),s=h[y-1]+(t?s:0)}l>=0&&(u.values=u.values.map(e=>+e.toFixed(l)))}return e}function W(e,t=-1){return U(e,!1,t)}function X(e,t,l=1){const a=2*Math.PI;let[n,s,r,i,u,p,h]=t;if(0===n||0===s)return[];let o=r?r*a/360:0,y=o?Math.sin(o):0,c=o?Math.cos(o):1,x=c*(e.x-p)/2+y*(e.y-h)/2,f=-y*(e.x-p)/2+c*(e.y-h)/2;if(0===x&&0===f)return[];n=Math.abs(n),s=Math.abs(s);let g=x*x/(n*n)+f*f/(s*s);if(g>1){let e=Math.sqrt(g);n*=e,s*=e}let v=n*n,d=n===s?v:s*s,m=x*x,M=f*f,b=v*d-v*M-d*m;b<=0?b=0:(b/=v*M+d*m,b=Math.sqrt(b)*(i===u?-1:1));let A=b?b*n/s*f:0,C=b?b*-s/n*x:0,w=c*A-y*C+(e.x+p)/2,P=y*A+c*C+(e.y+h)/2,S=(x-A)/n,L=(f-C)/s,I=(-x-A)/n,k=(-f-C)/s;const $=(e,t,l,a)=>{let n=+(e*l+t*a).toFixed(9);return 1===n||-1===n?1===n?0:Math.PI:(n=n>1?1:n<-1?-1:n,(e*a-t*l<0?-1:1)*Math.acos(n))};let z=$(1,0,S,L),E=$(S,L,I,k);0===u&&E>0?E-=2*Math.PI:1===u&&E<0&&(E+=2*Math.PI);let T=(+(Math.abs(E)/(a/4)).toFixed(0)||1)*l;E/=T;let Q=[];const F=1.5707963267948966,q=.551785;let D=E===F?q:E===-F?-q:4/3*Math.tan(E/4),B=E?Math.cos(E):1,O=E?Math.sin(E):0;const j=(e,t,l,a,n)=>{let s=e!=t?Math.cos(e):a,r=e!=t?Math.sin(e):n,i=Math.cos(e+t),u=Math.sin(e+t);return[{x:s-r*l,y:r+s*l},{x:i+u*l,y:u-i*l},{x:i,y:u}]};for(let e=0;e<T;e++){let e={type:"C",values:[]};j(z,E,D,B,O).forEach(t=>{let l=t.x*n,a=t.y*s;e.values.push(c*l-y*a+w,y*l+c*a+P)}),Q.push(e),z+=E}return Q}function G(e,t,l,a,n=7.5){let s={type:"C",values:[t.x,t.y,l.x,l.y,a.x,a.y]},r=0,i=!1,u=m(e,t,!0),p=m(a,l,!0),h=180*Math.abs(u-p)/Math.PI;if(Math.abs(h%180-90)<3){let u=M(e,t,a,l,!1);if(u){let p=b(e,u),h=b(a,u),o=+Math.max(p,h).toFixed(8),y=+Math.min(p,h).toFixed(8),c=y,x=o,f=O([e,t,l,a])<0?0:1,g=Math.abs(a.x-e.x)>Math.abs(a.y-e.y);100/c*Math.abs(c-x)<5&&(c=o,x=c),g&&(c=o,x=y);let v=B([{type:"M",values:[e.x,e.y]},{type:"C",values:[t.x,t.y,l.x,l.y,a.x,a.y]}]),d={type:"A",values:[c,x,0,0,f,a.x,a.y]};r=Math.PI*(c*x)/4,r-=Math.abs(O([e,a,u])),function(e,t){let l=Math.abs(e-t);return Math.abs(100-100/e*(e+l))}(v,r)<n&&(i=!0,s=d)}}return{com:s,isArc:i,area:r}}function Y(e){let t,l=[[]],a=0,n=[[]],s={x:e[0].values[0],y:e[0].values[1]};for(let r=0,i=e.length;r<i;r++){let i=e[r],{type:u,values:p}=i;if("A"===u){let u=e[r-1].values.slice(-2);s={x:u[0],y:u[1]};let[h,o,y,c,x,f,g]=p,v=100/h*Math.abs(h-o)<5;t={x:p[5],y:p[6]},i.p0=s,i.p=t,i.circular=v;let d=e[r+1];if(!l[a].length&&d&&"A"===d.type&&(l[a].push(i),n[a].push(r)),d&&"A"===d.type){let[e,i,u,p,y,c,x]=d.values,f=h!=e?100/h*Math.abs(h-e):0,g=o!=i?100/o*Math.abs(o-i):0;t={x:d.values[5],y:d.values[6]},d.p0=s,d.p=t,f<5&&g<5?(l[a].push(d),n[a].push(r+1)):(l.push([]),n.push([]),a++)}else l.push([]),n.push([]),a++}}if(!n.length)return e;l=l.filter(e=>e.length),n=n.filter(e=>e.length);for(let t=l.length-1;t>=0;t--){const a=l[t],s=n[t][0],r=a.length;let i=0,u=0;a.forEach(({values:e})=>{const[t,l]=e;i+=t,u+=l}),i/=r,u/=r;let p=100/i*Math.abs(i-u)<5;p&&(i=(i+u)/2,u=i);let h=e[s-1].values.slice(-2);if(h[0],h[1],4===r){let[t,l,n,h,o,y,c]=a[1].values,[,,,,,x,f]=a[3].values;p&&(i=1,u=1);let g={type:"A",values:[i,u,n,h,o,y,c]},v={type:"A",values:[i,u,n,h,o,x,f]};e.splice(s,r,g,v)}else if(3===r){let[t,l,n,p,h,o,y]=a[0].values,[c,x,,,,f,g]=a[2].values;p=1;let v={type:"A",values:[i,u,n,p,h,f,g]};e.splice(s,r,v)}else if(2===r){let[t,l,n,h,o,y,c]=a[0].values,[x,f,,,,g,v]=a[1].values;p&&(i=1,u=1,n=0);let{p0:d,p:m}=a[0],[M,b]=[a[1].p0,a[1].p];if(d.x!==b.x||d.y!==b.y){let t={type:"A",values:[i,u,n,h,o,g,v]};e.splice(s,r,t)}}}return e}function K(e=[],{toAbsolute:t=!0,toLonghands:l=!0,quadraticToCubic:a=!1,arcToCubic:n=!1,arcAccuracy:s=2}={},{hasRelatives:r=!0,hasShorthands:i=!0,hasQuadratics:u=!0,hasArcs:p=!0,testTypes:h=!1}={}){if(h){let t=Array.from(new Set(e.map(e=>e.type))).join("");r=/[lcqamts]/gi.test(t),u=/[qt]/gi.test(t),p=/[a]/gi.test(t),i=/[vhst]/gi.test(t),isPoly=/[mlz]/gi.test(t)}return(u&&a||p&&n)&&(l=!0,t=!0),r&&t&&(e=U(e,!1)),i&&l&&(e=function(e,t=-1,l=!0){let a=!1;if(l){let t=e.map(e=>e.type).join(""),l=/[hstv]/gi.test(t);if(a=/[astvqmhlc]/g.test(t),!l)return e}let n=[],s={type:"M",values:(e=l&&a?W(e,t):e)[0].values};n.push(s);for(let l=1,a=e.length;l<a;l++){let a,r,i,u,p,h,o,y,c=e[l],{type:x,values:f}=c,g=f.length,v=s.values,d=v.length,[m,M]=[f[g-2],f[g-1]],[b,A]=[v[d-2],v[d-1]];switch(x){case"H":s={type:"L",values:[f[0],A]};break;case"V":s={type:"L",values:[b,f[0]]};break;case"T":[a,r]=[v[0],v[1]],[b,A]=[v[d-2],v[d-1]],i=b+(b-a),u=A+(A-r),s={type:"Q",values:[i,u,m,M]};break;case"S":[a,r]=[v[0],v[1]],[b,A]=[v[d-2],v[d-1]],[o,y]=d>2&&"A"!==s.type?[v[2],v[3]]:[b,A],i=2*b-o,u=2*A-y,p=f[0],h=f[1],s={type:"C",values:[i,u,p,h,m,M]};break;default:s={type:x,values:f}}t>-1&&(s.values=s.values.map(e=>+e.toFixed(t))),n.push(s)}return n}(e,-1,!1)),p&&n&&(e=function(e,{arcAccuracy:t=1}={}){let l=[e[0]];for(let a=1,n=e.length;a<n;a++){let n=e[a],s=e[a-1].values,r=s.length,i={x:s[r-2],y:s[r-1]};"A"===n.type?X(i,n.values,t).forEach(e=>{l.push(e)}):l.push(n)}return l}(e,s)),u&&a&&(e=function(e){let t=[e[0]];for(let l=1,a=e.length;l<a;l++){let a=e[l],n=e[l-1].values,s=n.length,r={x:n[s-2],y:n[s-1]};"Q"===a.type?t.push(J(r,a.values)):t.push(a)}return t}(e)),e}function _(e,{toAbsolute:t=!0,toLonghands:l=!0,quadraticToCubic:a=!1,arcToCubic:n=!1,arcAccuracy:s=4}={}){let r=function(e,t=!0){if(e=e.trim(),""===e)return{pathData:[],hasRelatives:!1,hasShorthands:!1,hasQuadratics:!1,hasArcs:!1};const l=new Set([5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279]),a=e=>32===e||44===e||10===e||13===e||8232===e||8233===e||9===e||11===e||12===e||160===e||e>=5760&&l.has(e);let n,s=0,r=e.length,i="",u=[],p=-1,h="",o=!1,y=0,c=0,x=0,f=!1,g=new Set([]),v=[];const d=()=>{f&&("M"===i?i="L":"m"===i&&(i="l"),u.push({type:i,values:[]}),p++,c=0,f=!1)},m=(e=!1)=>{(e?y>0:""!==h)&&(t&&-1===p&&(n="Pathdata must start with M command",v.push(n),i="M",u.push({type:i,values:[]}),x=2,c=0,p++),"A"===i||"a"===i?(h=M(),u[p].values.push(...h)):(t&&h[1]&&"."!==h[1]&&"0"===h[0]&&(n=`${p}. command: Leading zeros not valid: ${h}`,v.push(n)),u[p].values.push(+h)),c++,h="",y=0,f=c>=x)},M=()=>{let e=h.length,t=!1;return 3===c&&2===e||4===c&&e>1?(h=[+h[0],+h[1]],t=!0,c++):3===c&&e>=3&&(h=[+h[0],+h[1],+h.substring(2)],t=!0,c+=2),t?h:[+h]},b=()=>{if(p>0){let e=u[p].values.length;if(e&&e<x||e&&e>x||("z"===i||"Z"===i)&&e>0){n=`${p}. command of type "${i}": ${x-e} values too few - ${x} expected`,v[v.length-1]!==n&&v.push(n)}}};let A=!1,C=!1,w=!1;for(;s<r;){let l=e.charCodeAt(s),r=l>47&&l<58;if(r||(A=101===l||69===l,C=45===l||43===l,w=46===l),r||C||w||A){if(o||45!==l&&46!==l)d();else{let e=46===l;m(e),d(),e&&y++}h+=e[s],o=A,s++}else if((l<48||l>5759)&&a(l))m(),s++;else{if(l>64){if(!ee.has(l)){n=`${p}. command "${e[s]}" is not a valid type`,v.push(n),s++;continue}""!==h&&(u[p].values.push(+h),c++,h=""),t&&b(),i=e[s],x=te[l];let a="M"===i||"m"===i,r=p>0&&("z"===u[p].type||"Z"===u[p].type);g.add(i),r&&!a&&(u.push({type:"m",values:[0,0]}),p++),u.push({type:i,values:[]}),p++,y=0,c=0,f=!1,s++;continue}r||(n=`${p}. ${e[s]} is not a valid separarator or token`,v.push(n),h=""),s++}}m(),t&&b();if(t&&v.length){if(n="Invalid path data:\n"+v.join("\n"),"log"!==t)throw new Error(n);console.log(n)}u[0].type="M";let P=Array.from(g).join(""),S=/[lcqamts]/g.test(P),L=/[vhst]/gi.test(P),I=/[a]/gi.test(P),k=/[qt]/gi.test(P);return{pathData:u,hasRelatives:S,hasShorthands:L,hasQuadratics:k,hasArcs:I}}(e),{hasRelatives:i,hasShorthands:u,hasQuadratics:p,hasArcs:h}=r,o=r.pathData;return o=K(o,{toAbsolute:t,toLonghands:l,quadraticToCubic:a,arcToCubic:n,arcAccuracy:s},{hasRelatives:i,hasShorthands:u,hasQuadratics:p,hasArcs:h}),o}const ee=new Set([77,109,65,97,67,99,76,108,81,113,83,115,84,116,72,104,86,118,90,122]),te=new Uint8Array(128);function le(e,t=1,l=!0){let a=[e[0]],n={x:e[0].values[0],y:e[0].values[1]},s=n,r=n;e[e.length-1].type.toLowerCase();for(let i=1,u=e.length;i<u;i++){let p=e[i-1],h=e[i],o=e[i+1]||e[u-1],y="z"===o.type.toLowerCase()?n:{x:o.values[o.values.length-2],y:o.values[o.values.length-1]},{type:c,values:x}=h,f=x.slice(-2);r="Z"!==c?{x:f[0],y:f[1]}:n;let g=O([s,r,y],!0)<A(s,y)/100*t,v=!1;if(l||"C"!==c||(g=!1),l&&("C"===c||"Q"===c)){v=k(s,"C"===c?[{x:x[0],y:x[1]},{x:x[2],y:x[3]}]:"Q"===c?[{x:x[0],y:x[1]}]:[],r),v&&i<u-1&&"C"!==p.type&&(c="L",h.type="L",h.values=f)}s=r,g&&i<u-1&&("L"===c||l&&v)||("M"===c?(n=r,s=n):"Z"===c&&(s=n),a.push(h))}return a}function ae(e){let t={x:e[0].values[0],y:e[0].values[1]},l=t,a=[e[0]];for(let n=1,s=e.length;n<s;n++){let s=e[n],{type:r,values:i}=s,u=i.slice(-2);l={x:u[0],y:u[1]},"L"===r&&l.x===t.x&&l.y===t.y||(a.push(s),t=l)}return a}function ne(e){let t=e.length;if(!("z"===e[t-1].type.toLowerCase()))return e;let l=0,a=[];for(let l=0;l<t;l++){let t=e[l],{type:n,values:s}=t,r=s.length;if(r){let e={type:n,x:s[r-2],y:s[r-1],index:0};e.index=l,a.push(e)}}return a=a.sort((e,t)=>+e.y.toFixed(3)-+t.y.toFixed(3)||e.x-t.x),l=a[0].index,l?function(e,t){let l=e.length,a=0,n=e[l-1].type,s="z"===n.toLowerCase();if(!s||t<1||e.length<3)return e;let r=s?1:0;(function(e){let t=e.length,l="z"===e[t-1].type.toLowerCase(),a=e[0],[n,s]=[a.values[0],a.values[1]].map(e=>+e.toFixed(8)),r=l?e[t-2]:e[t-1],i=r.values.length,[u,p]=[r.values[i-2],r.values[i-1]].map(e=>+e.toFixed(8));!l||n==u&&s==p||(e.pop(),e.push({type:"L",values:[n,s]},{type:"Z",values:[]}))})(e),a=t+1<e.length-1?t+1:e.length-1-r;let i=e.slice(a),u=e.slice(0,a);u.shift();let p,h,o=u.length;p=u[o-1].values||[],h=[p[p.length-2],p[p.length-1]],r&&(i.pop(),u.push({type:"Z",values:[]}));return e=[{type:"M",values:h},...i,...u],e}(e,l):e}function se(e,{arcToCubic:t=!1,quadraticToCubic:l=!1,toClockwise:a=!1,returnD:n=!1}={}){const s=(e,t)=>{let l=[],a=[];if("A"!==e){for(let e=0;e<t.length;e+=2)l.push([t[e],t[e+1]]);a=l.pop(),l.reverse()}else{let e=0==t[4]?1:0;l=[t[0],t[1],t[2],t[3],e],a=[t[5],t[6]]}return{controlPoints:l,endPoints:a}};let r=[],i="z"===e[e.length-1].type.toLowerCase();i&&(e=(e=>{let t="z"===e[e.length-1].type.toLowerCase(),l=e[0],[a,n]=[l.values[0],l.values[1]],s=t?e[e.length-2]:e[e.length-1],[r,i]=[s.values[s.values.length-2],s.values[s.values.length-1]];return!t||a==r&&n==i||(e.pop(),e.push({type:"L",values:[a,n]},{type:"Z",values:[]})),e})(e),e.pop());let u=e[e.length-1].values,p=u.length,h=i?e[0]:{type:"M",values:[u[p-2],u[p-1]]};r.push(h),e.reverse();for(let t=1;t<e.length;t++){let l=e[t],a=l.type,n=l.values,i=e[t-1],u=i.type,p=[];p=[s(u,i.values).controlPoints,s(a,n).endPoints].flat(),r.push({type:u,values:p.flat()})}return i&&r.push({type:"z",values:[]}),r}function re(e,{returnDom:t=!1,removeHidden:l=!0,removeUnused:a=!0}={}){e=(e=e.replace(/<\?xml[\s\S]*?\?>/gi,"").replace(/<!DOCTYPE[\s\S]*?>/gi,"").replace(/<!--[\s\S]*?-->/g,"").trim()).replaceAll("xlink:href=","href=");let n=(new DOMParser).parseFromString(e,"text/html").querySelector("svg");!function(e,t=["viewBox","xmlns","width","height","id","class"]){[...e.attributes].map(e=>e.name).forEach(l=>{t.includes(l)||e.removeAttribute(l)})}(n,["viewBox","xmlns","width","height","id","class"]);let s=["metadata","script"];if(n.querySelectorAll("*").forEach(e=>{let t=e.nodeName,a=e.getAttribute("style")||"",n=!!a&&a.trim().includes("display:none"),r=e.getAttribute("display")&&"none"===e.getAttribute("display")||n;t.includes(":")||s.includes(t)||l&&r?e.remove():function(e){let t=[...e.attributes].map(e=>e.name);t.forEach(t=>{t.includes(":")&&e.removeAttribute(t)})}(e)}),t)return n;let r=function(e){let t=(new XMLSerializer).serializeToString(e);return t=t.replace(/\t/g,"").replace(/[\n\r|]/g,"\n").replace(/\n\s*\n/g,"\n").replace(/ +/g," "),t}(n);return console.log(r),r}function ie(e="",{toAbsolute:t=!0,toRelative:l=!0,toShorthands:a=!0,decimals:n=3,quadraticToCubic:s=!0,arcToCubic:r=!1,cubicToArc:i=!1,arcAccuracy:u=4,keepExtremes:p=!0,keepCorners:h=!0,keepInflections:o=!0,extrapolateDominant:y=!1,addExtremes:c=!1,optimizeOrder:x=!0,removeColinear:f=!0,simplifyBezier:g=!0,autoAccuracy:v=!0,flatBezierToLinetos:d=!0,revertToQuadratics:m=!0,minifyD:M=0,tolerance:b=1,reverse:A=!1,removeHidden:C=!0,removeUnused:w=!0,getObject:P=!1}={}){b=Math.max(.1,b);let S=function(e){let t="string";if(e instanceof HTMLImageElement)return"img";if(e instanceof SVGElement)return"svg";if(e instanceof HTMLCanvasElement)return"canvas";if(e instanceof File)return"file";if(e instanceof ArrayBuffer)return"buffer";if(e instanceof Blob)return"blob";if(Array.isArray(e))return"array";if("string"==typeof e){let l=(e=e.trim()).includes("<svg")&&e.includes("</svg"),a=e.startsWith("M")||e.startsWith("m"),n=!isNaN(e.substring(0,1))&&!isNaN(e.substring(e.length-1,e.length));if(l)t="svgMarkup";else if(a)t="pathDataString";else if(n)t="polyString";else{let l=/^(file:|https?:\/\/|\/|\.\/|\.\.\/)/.test(e),a=e.startsWith("data:image");t=l||a?"url":"string"}return t}return t=typeof e,(e.constructor.name||t).toLowerCase()}(e),L="",I=0,k=0,E=0,T={},F="",q="svgMarkup"===S?1:0,D=[];if(I=new Blob([e]).size,q){L=re(e,{returnDom:!0,removeHidden:C,removeUnused:w}),L.querySelectorAll("path").forEach(e=>{D.push({d:e.getAttribute("d"),el:e})})}else"pathDataString"===S?F=e:"polyString"===S&&(F="M"+e),D.push({d:F,el:null});return D.forEach(e=>{let{d:u,el:C}=e,w=_(u,{quadraticToCubic:s,toAbsolute:t,arcToCubic:r}),P=JSON.parse(JSON.stringify(w)),S=w.length,L=z(P),T=[];for(let e=0,t=L.length;e<t;e++){let t=L[e];A&&(t=se(t)),f&&(t=ae(t)),c&&(t=Q(t,0,1)),x&&(t=ne(t)),f&&(t=le(t,b,d));let l=V(t),{pathData:a,bb:n,dimA:s}=l;if(a=g?ue(a,{simplifyBezier:g,keepInflections:o,keepExtremes:p,keepCorners:h,extrapolateDominant:y,revertToQuadratics:m,tolerance:b,reverse:A}):a,i){let e=3;a.forEach((t,l)=>{let{type:n,values:s,p0:r,cp1:i=null,cp2:u=null,p:p=null}=t;if("C"===n){let t=G(r,i,u,p,e);t.isArc&&(a[l]=t.com)}}),a=Y(a)}m&&a.forEach((e,t)=>{let{type:l,values:n,p0:s,cp1:r=null,cp2:i=null,p:u=null}=e;if("C"===l){let e=Z(s,r,i,u);"Q"===e.type&&(a[t]=e)}}),T.push(a)}P=T.flat(),v&&(n=function(e){let t={x:e[0].values[0],y:e[0].values[1]},l=t,a=t;e[0].decimals=0;let n=new Set;for(let s=0,r=e.length;s<r;s++){let r=e[s],{type:i,values:u}=r,p=u.length?u.slice(-2):[t.x,t.y];a={x:p[0],y:p[1]};let h=r.dimA?+r.dimA.toFixed(8):"M"!==i?+$(l,a).toFixed(8):0;h&&n.add(h),"M"===i&&(t=a),l=a}let s=Array.from(n).sort(),r=Math.ceil(s.length/8);s=s.slice(0,r);let i=s.reduce((e,t)=>e+t,0)/r,u=i>50?0:Math.floor(50/i).toString().length;return Math.min(Math.max(0,u),8)}(P)),P=R(P,{toRelative:l,toShorthands:a,decimals:n});let F=[];P.forEach((e,t)=>{let{type:l,values:a}=e;if("l"===l||"v"===l||"h"===l){("l"===l?"00"!==a.join(""):0!==a[0])&&F.push(e)}else F.push(e)}),P=F;let q=P.length,D=j(P,M);k=new Blob([D]).size,E=+(100/I*k).toFixed(2),e.d=D,e.report={original:S,new:q,saved:S-q,compression:E,decimals:n},C&&C.setAttribute("d",D)}),q?(L=(new XMLSerializer).serializeToString(L),k=new Blob([L]).size,E=+(100/I*k).toFixed(2),I=+(I/1024).toFixed(3),k=+(k/1024).toFixed(3),T={svgSize:I,svgSizeOpt:k,compression:E}):({d:F,report:T}=D[0]),P?{svg:L,d:F,report:T,inputType:S,mode:q}:F||L}function ue(e,{keepExtremes:t=!0,keepInflections:l=!0,keepCorners:a=!0,extrapolateDominant:n=!0,tolerance:s=1,reverse:r=!1}={}){let i=[e[0]];for(let r=2,u=e.length;u&&r<=u;r++){let p=e[r-1],h=r<u?e[r]:null,o=h?.type||null,y=p?.directionChange||null,c=h?.directionChange||null,{type:x,values:f,p0:g,p:v,cp1:d=null,cp2:m=null,extreme:M=!1,corner:b=!1,dimA:A=0}=p;if("C"===x&&"C"===o)if(l&&c||a&&b||!y&&t&&M)i.push(p);else{let o=N(p,h,n,s),y=0;if(1===o.length){p=o[0];let h=1;y+=p.error;for(let i=r+1;y<s&&i<u;i++){let r=e[i];if("C"!==r.type||l&&r.directionChange||a&&p.corner||t&&p.extreme)break;let u=N(p,r,n,s);1===u.length&&h++,p=u[0]}i.push(p),r<u&&(r+=h)}else i.push(p)}else i.push(p)}return r&&(i=se(i)),i}function pe(e=null,t=!1){if(!e)return{x:0,y:0,width:300,height:150};let l=window.getComputedStyle(e),a=e.hasAttribute("width")?e.width.baseVal.value:parseFloat(l.width)||300,n=e.hasAttribute("height")?e.height.baseVal.value:parseFloat(l.height)||150,s=e.getAttribute("viewBox")?e.viewBox.baseVal:{x:0,y:0,width:a,height:n},{x:r,y:i,width:u,height:p}=s;if(s={x:r,y:i,width:u,height:p},t)for(let e in s)s[e]=Math.ceil(s[e]);return s}te[77]=2,te[109]=2,te[65]=7,te[97]=7,te[67]=6,te[99]=6,te[76]=2,te[108]=2,te[81]=4,te[113]=4,te[83]=4,te[115]=4,te[84]=2,te[116]=2,te[72]=1,te[104]=1,te[86]=1,te[118]=1,te[90]=0,te[122]=0;const{abs:he,acos:oe,asin:ye,atan:ce,atan2:xe,ceil:fe,cos:ge,exp:ve,floor:de,log:me,hypot:Me,max:be,min:Ae,pow:Ce,random:we,round:Pe,sin:Se,sqrt:Le,tan:Ie,PI:ke}=Math;"undefined"!=typeof window&&(window.svgPathSimplify=ie,window.getViewBox=pe,window.renderPoint=function(e,t,l="red",a="1%",n="1",s="",r=!0,i="",u=""){Array.isArray(t)&&(t={x:t[0],y:t[1]});let p=`<circle class="${u}" opacity="${n}" id="${i}" cx="${t.x}" cy="${t.y}" r="${a}" fill="${l}">\n <title>${s}</title></circle>`;if(!r)return p;e.insertAdjacentHTML("beforeend",p)}),exports.PI=ke,exports.abs=he,exports.acos=oe,exports.asin=ye,exports.atan=ce,exports.atan2=xe,exports.ceil=fe,exports.cos=ge,exports.exp=ve,exports.floor=de,exports.getViewBox=pe,exports.hypot=Me,exports.log=me,exports.max=be,exports.min=Ae,exports.pow=Ce,exports.random=we,exports.round=Pe,exports.sin=Se,exports.sqrt=Le,exports.svgPathSimplify=ie,exports.tan=Ie;
1
+ "use strict";const{abs:e,acos:t,asin:l,atan:a,atan2:n,ceil:s,cos:r,exp:i,floor:p,log:u,max:y,min:o,pow:h,random:c,round:x,sin:f,sqrt:g,tan:v,PI:d}=Math;function m(e,t,l=!1){let a=n(t.y-e.y,t.x-e.x);return l&&a<0&&(a+=2*Math.PI),a}function M(e,t,l,a,n=!0){let s,r,i,p,u,y={};try{if(s=(a.y-l.y)*(t.x-e.x)-(a.x-l.x)*(t.y-e.y),0==s)return!1}catch{console.log("!catch",e,t,"p3:",l,a)}r=e.y-l.y,i=e.x-l.x,p=(a.x-l.x)*r-(a.y-l.y)*i,u=(t.x-e.x)*r-(t.y-e.y)*i,r=p/s,i=u/s,y={x:e.x+r*(t.x-e.x),y:e.y+r*(t.y-e.y)};let o=!1;return r>0&&r<1&&i>0&&i<1&&(o=!0),!(n&&!o)&&y}function b(e,t){return g((t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y))}function C(e,t){return(t.x-e.x)**2+(t.y-e.y)**2}function A(e,t,l,a=!1){let n={x:(t.x-e.x)*l+e.x,y:(t.y-e.y)*l+e.y};return a&&(n.angle=m(e,t),n.angle<0&&(n.angle+=2*d)),n}function w(e,t=.5,l=!1,a=!1){let n;return n=e.length>2?((e,t,l=!1)=>{let n=4===e.length,s=e[0],r=e[1],i=n?e[2]:e[1],p=e[e.length-1],u={x:0,y:0};if(l||a){let e,l,y,o,h,c=s.x===r.x&&s.y===r.y,x=p.x===i.x&&p.y===i.y;0!==t||c?1!==t||x?(c&&(t+=1e-7),x&&(t-=1e-7),e=A(s,r,t),n?(l=A(r,i,t),y=A(i,p,t),o=A(e,l,t),h=A(l,y,t),u=A(o,h,t),u.angle=m(o,h),a&&(u.cpts=[l,y,o,h])):(l=A(s,r,t),y=A(r,p,t),u=A(l,y,t),u.angle=m(l,y),a&&(u.cpts=[l,y]))):(u.x=p.x,u.y=p.y,u.angle=m(i,p)):(u.x=s.x,u.y=s.y,u.angle=m(s,r))}else{let e=1-t;u=n?{x:e**3*s.x+3*e**2*t*r.x+3*e*t**2*i.x+t**3*p.x,y:e**3*s.y+3*e**2*t*r.y+3*e*t**2*i.y+t**3*p.y}:{x:e*e*s.x+2*e*t*r.x+t**2*p.x,y:e*e*s.y+2*e*t*r.y+t**2*p.y}}return u})(e,t,l):A(e[0],e[1],t,l),l&&n.angle<0&&(n.angle+=2*d),n}function L(e,t,l,n,s,i=0,p=!0,u=!1){if(s=u?s*d/180:s,i=u?i*d/180:i,i=l!==n&&i!==2*d?i:0,p&&l!==n){let e=a(v(s=i?s-i:s)*(l/n));s=r(s)<0?e+d:e}let y=e+l*r(s),o=t+n*f(s),h={x:y,y:o};return i&&(h.x=e+(y-e)*r(i)-(o-t)*f(i),h.y=t+(y-e)*f(i)+(o-t)*r(i)),h}function P(e,t=[],l=.05){let a=3===t.length,n=t[0]||null,s=a?t[1]:null,r=a?t[2]:t[1],i=.5*Math.PI,p=!1,u=!1,y=n?m(r,n,!0):null;if(p=Math.abs(y%i)<l||Math.abs(y%i-i)<l,a){let e=s?m(s,r,!0):0;u=Math.abs(e%i)<=l||Math.abs(e%i-i)<=l}return p||u}function S(e){return 4===e.length?function(e,t,l,a){let[n,s,r,i,p,u,y,o]=[e.x,e.y,t.x,t.y,l.x,l.y,a.x,a.y],h=Math.min(e.y,a.y),c=Math.min(e.x,a.x),x=Math.max(e.x,a.x),f=Math.max(e.y,a.y);if(t.y>=h&&t.y<=f&&l.y>=h&&l.y<=f&&t.x>=c&&t.x<=x&&l.x>=c&&l.x<=x)return[];let g,v,d,m,M,b,C,A,w=[];for(let e=0;e<2;++e)if(0==e?(v=6*n-12*r+6*p,g=-3*n+9*r-9*p+3*y,d=3*r-3*n):(v=6*s-12*i+6*u,g=-3*s+9*i-9*u+3*o,d=3*i-3*s),Math.abs(g)<1e-12){if(Math.abs(v)<1e-12)continue;m=-d/v,0<m&&m<1&&w.push(m)}else C=v*v-4*d*g,C<0?Math.abs(C)<1e-12&&(m=-v/(2*g),0<m&&m<1&&w.push(m)):(A=Math.sqrt(C),M=(-v+A)/(2*g),0<M&&M<1&&w.push(M),b=(-v-A)/(2*g),0<b&&b<1&&w.push(b));let L=w.length;for(;L--;)m=w[L];return w}(e[0],e[1],e[2],e[3]):function(e,t,l){let a,n,s,r=Math.min(e.y,l.y),i=Math.min(e.x,l.x),p=Math.max(e.x,l.x),u=Math.max(e.y,l.y);if(t.y>=r&&t.y<=u&&t.x>=i&&t.x<=p)return[];let[y,o,h,c,x,f]=[e.x,e.y,t.x,t.y,l.x,l.y],g=[];for(let e=0;e<2;++e)a=0==e?y-2*h+x:o-2*c+f,n=0==e?-2*y+2*h:-2*o+2*c,Math.abs(a)>1e-12&&(s=-n/(2*a),s>0&&s<1&&g.push(s));return g}(e[0],e[1],e[2])}function I(e,t=.025){let l=e[0],a=e[e.length-1],n=e.map(e=>e.x),s=e.map(e=>e.y),r=Math.min(...n),i=Math.max(...n),p=Math.min(...s),u=i-r,y=Math.max(...s)-p;if(e.length<3||0===u||0===y)return{area:0,flat:!0,thresh:1e-4,ratio:0};let o=C(l,a),h=C(l,e[0]),c=(h+(e.length>3?C(a,e[1]):h))/2;let x=.5*(u+y)*.5,f=0;for(let t=0,l=e.length;t<l;t++){f+=e[t].x*e[t===e.length-1?0:t+1].y*.5-e[t===e.length-1?0:t+1].x*e[t].y*.5}f=+Math.abs(f).toFixed(9);return{area:f,flat:0===f||f<c/1e3,thresh:x,ratio:f/c,squareDist:o,areaThresh:o/1e3}}function F(e,t,l){let a=!1,n=2===t.length,s=t[0],r=n?t[1]:s;if(e.x===s.x&&e.y===s.y&&l.x===r.x&&l.y===r.y)return!0;let i=s.x-e.x,p=s.y-e.y,u=l.x-r.x,y=l.y-r.y,o=Math.abs(i*y-p*u);if(!o)return!0;let h=l.x-e.x,c=l.y-e.y,x=Math.abs(h*p-c*i);return!x||(x/o<1.1&&(a=!0),a)}function k(e,t){return(Math.abs(t.x-e.x)+Math.abs(t.y-e.y))/2}function $(e){let t=[];try{e.map((e,t)=>"m"===e.type.toLowerCase()?t:-1).filter(e=>-1!==e)}catch{console.log("catch",e)}let l=e.map((e,t)=>"m"===e.type.toLowerCase()?t:-1).filter(e=>-1!==e);return 1===l.length?[e]:(l.forEach((a,n)=>{t.push(e.slice(a,l[n+1]))}),t)}function z(e,t){let l,a,n,s,r,i,p=[],u=[],y=e[0],o=e[1],h=e[e.length-2],c=e[e.length-1];return 4===e.length?(l=w([y,o],t),a=w([o,h],t),n=w([h,c],t),s=w([l,a],t),r=w([a,n],t),i=w([s,r],t),p.push({x:y.x,y:y.y},{x:l.x,y:l.y},{x:s.x,y:s.y},{x:i.x,y:i.y}),u.push({x:i.x,y:i.y},{x:r.x,y:r.y},{x:n.x,y:n.y},{x:c.x,y:c.y})):3===e.length?(a=w([y,o],t),n=w([o,c],t),i=w([a,n],t),p.push({x:y.x,y:y.y},{x:a.x,y:a.y},{x:i.x,y:i.y}),u.push({x:i.x,y:i.y},{x:n.x,y:n.y},{x:c.x,y:c.y})):2===e.length&&(a=w([y,c],t),p.push({x:y.x,y:y.y},{x:a.x,y:a.y}),u.push({x:a.x,y:a.y},{x:c.x,y:c.y})),[p,u]}function E(e,t,l=0,a=1){let n=[],s=6===t.length?"C":"Q",r={x:t[0],y:t[1]},i="C"===s?{x:t[2],y:t[3]}:r,p={x:t[4],y:t[5]},u=Math.max(p.x,e.x),y=Math.min(p.x,e.x),o=Math.max(p.y,e.y),h=Math.min(p.y,e.y),c=0;if(r.x<y||r.x>u||r.y<h||r.y>o||i.x<y||i.x>u||i.y<h||i.y>o){let u=S("C"===s?[e,r,i,p]:[e,r,p]).sort();if(u=u.filter(e=>e>l&&e<a),u.length){let l=function(e,t,l,a=!0){let n=[];if(!l.length)return!1;let s,r,i,p=t.length,u={x:t[p-2],y:t[p-1]};2===t.length?i=[e,u]:4===t.length?(s={x:t[0],y:t[1]},i=[e,s,u]):6===t.length&&(s={x:t[0],y:t[1]},r={x:t[2],y:t[3]},i=[e,s,r,u]);if(l.length)if(1===l.length){let e=z(i,l[0]),t=e[0],a=e[1];n.push(t,a)}else{let e=l[0],t=z(i,e),a=t[0];n.push(a),i=t[1];for(let t=1;t<l.length;t++){e=l[t-1];let a=z(i,(l[t]-e)/(1-e));n.push(a[0]),t===l.length-1&&n.push(a[a.length-1]),i=a[1]}}if(a){let e,t,l=[];return n.forEach(a=>{e={type:"",values:[]},a.shift(),t=a.map(e=>Object.values(e)).flat(),e.values=t,3===a.length?e.type="C":2===a.length?e.type="Q":1===a.length&&(e.type="L"),l.push(e)}),l}return n}(e,t,u);n.push(...l),c+=l.length}else n.push({type:s,values:t})}else n.push({type:s,values:t});return{pathData:n,count:c}}function T(e,t=0,l=1){let a=[e[0]],n={x:e[0].values[0],y:e[0].values[1]},s={x:e[0].values[0],y:e[0].values[1]},r=e.length;for(let i=1;r&&i<r;i++){let r=e[i],{type:p,values:u}=r,y=u.slice(-2);if(y[0],y[1],"C"!==p&&"Q"!==p)a.push(r);else if("C"===p||"Q"===p){let e=E(n,u,t,l).pathData;a.push(...e)}n={x:y[0],y:y[1]},"z"===p.toLowerCase()?n=s:"M"===p&&(s={x:y[0],y:y[1]})}return a}function Q(e,t=-1){let l=e.map(e=>e.x),a=e.map(e=>e.y),n=Math.min(...l),s=Math.max(...l),r=Math.min(...a),i=Math.max(...a),p={x:n,left:n,right:s,y:r,top:r,bottom:i,width:s-n,height:i-r};if(t>-1)for(let e in p)p[e]=+p[e].toFixed(t);return p}function q(e){let t=[];return e.forEach(e=>{let l=function(e){let t=function(e){let t=[];for(let l=0;l<e.length;l++){let a=e[l],n=l>0?e[l-1]:e[l],{type:s,values:r}=a,i={x:n.values[n.values.length-2],y:n.values[n.values.length-1]},p=r.length?{x:r[r.length-2],y:r[r.length-1]}:"",u=r.length?{x:r[0],y:r[1]}:"";switch(s){case"A":if("function"!=typeof arcToBezier){let e=b(i,p)/2,l=A(i,p,.5),a=L(l.x,l.y,e,e,0),n=L(l.x,l.y,e,e,Math.PI);t.push(a,n,p);break}arcToBezier(i,r).forEach(e=>{let l=e.values,a={x:l[0],y:l[1]},n={x:l[2],y:l[3]},s={x:l[4],y:l[5]};t.push(a,n,s)});break;case"C":let e={x:r[2],y:r[3]};t.push(u,e);break;case"Q":t.push(u)}"z"!==s.toLowerCase()&&t.push(p)}return t}(e),l=Q(t);return l}(e);t.push(l)}),t}function D(e,t){let[l,a,n,s,r,i]=[e.x,e.y,e.width,e.height,e.x+e.width,e.y+e.height],[p,u,y,o,h,c]=[t.x,t.y,t.width,t.height,t.x+t.width,t.y+t.height],x=!1;return n*s!=y*o&&n*s>y*o&&l<p&&r>h&&a<u&&i>c&&(x=!0),x}function B(t,l=9){let a=0,s=[],i=$(t),p=i.length>1,u=[];if(p){let e=q(i);e.forEach(function(t,l){for(let l=0;l<e.length;l++){let a=e[l];if(t!=a){D(t,a)&&u.push(l)}}})}return i.forEach((t,l)=>{s=[];let i=0,p=0,y=1,o=[];t.forEach(function(l,a){let[p,u]=[l.type,l.values],y=u.length;if(u.length){let h=(a>0?t[a-1]:t[0]).values,c=h.length,x={x:h[c-2],y:h[c-1]},v={x:u[y-2],y:u[y-1]};if("C"===p||"Q"===p){let e={x:u[0],y:u[1]};o="C"===p?[x,e,{x:u[2],y:u[3]},v]:[x,e,v];let t=Math.abs(function(e,t=!1){let l,[a,n,s,r]=[e[0],e[1],e[2],e[e.length-1]];if(e.length<3)return 0;3===e.length&&(n={x:1*e[0].x/3+2*e[1].x/3,y:1*e[0].y/3+2*e[1].y/3},s={x:1*e[2].x/3+2*e[1].x/3,y:1*e[2].y/3+2*e[1].y/3});return l=3*(a.x*(-2*n.y-s.y+3*r.y)+n.x*(2*a.y-s.y-r.y)+s.x*(a.y+n.y-2*r.y)+r.x*(-3*a.y+n.y+2*s.y))/20,t?Math.abs(l):l}(o));i+=t,s.push(x,v)}else if("A"===p){let t=function(t,l,a,s,i,p,u,y,o){const h=(e,t,l,a)=>n(a-t,l-e);let c={cx:0,cy:0,rx:a=e(a),ry:s=e(s),startAngle:0,endAngle:0,deltaAngle:0,clockwise:u,xAxisRotation:i,largeArc:p,sweep:u};if(0==a||0==s)throw Error("rx and ry can not be 0");if(a===s){let e=Math.abs(y-t),a=Math.abs(o-l),n=e,s=Math.min(t,y),r=Math.min(l,o),i=.5*Math.PI;if(0===e&&a||0===a&&e)return n=0===e&&a?a/2:e/2,c.rx=n,c.ry=n,0===e&&a?(c.cx=t,c.cy=r+a/2,c.startAngle=l>o?i:-i,c.endAngle=l>o?-i:i,c.deltaAngle=u?Math.PI:-Math.PI):0===a&&e&&(c.cx=s+e/2,c.cy=l,c.startAngle=t>y?Math.PI:0,c.endAngle=t>y?-Math.PI:Math.PI,c.deltaAngle=u?Math.PI:-Math.PI),c}let x,v,m=a===s?0:i*d/180,M=m?f(m):0,b=m?r(m):1,C=(t-y)/2,A=(l-o)/2,w=(t+y)/2,L=(l+o)/2,P=m?b*C+M*A:C,S=m?b*A-M*C:A,I=P*P/(a*a)+S*S/(s*s);I>1&&(a*=g(I),s*=g(I),c.rx=a,c.ry=s);let F=a*s,k=a*S,$=s*P,z=k**2+$**2;if(!z)throw Error("start point can not be same as end point");let E=g(e((F*F-z)/z));p==u&&(E=-E);let T=E*k/s,Q=-E*$/a;x=m?b*T-M*Q+w:w+T,v=m?M*T+b*Q+L:L+Q,c.cy=v,c.cx=x;let q=h(x,v,t,l),D=h(x,v,y,o);!u&&D>q&&(D-=2*Math.PI),u&&q>D&&(D=D<=0?D+2*Math.PI:D);let B=D-q;return c.startAngle=q,c.endAngle=D,c.deltaAngle=B,c}(x.x,x.y,l.values[0],l.values[1],l.values[2],l.values[3],l.values[4],v.x,v.y),{cx:a,cy:p,rx:u,ry:y,startAngle:o,endAngle:h,deltaAngle:c}=t,m=Math.abs(function(e,t,l,a){const n=Math.PI*e*t;let s=(a-l+2*Math.PI)%(2*Math.PI);if(e===t)return n*(s/(2*Math.PI));const r=l=>Math.atan2(e*Math.sin(l),t*Math.cos(l));return l=r(l),a=r(a),s=(a-l+2*Math.PI)%(2*Math.PI),n*(s/(2*Math.PI))}(u,y,o,h));m-=Math.abs(O([x,{x:a,y:p},v])),s.push(x,v),i+=m}else s.push(x,v)}});let h=O(s);-1!==u.indexOf(l)&&(y=-1),p=h<0&&i<0?(Math.abs(i)-Math.abs(h))*y:(Math.abs(i)+Math.abs(h))*y,a+=p}),a}function O(e,t=!1){let l=0;for(let t=0,a=e.length;a&&t<a;t++){l+=e[t].x*e[t===e.length-1?0:t+1].y*.5-e[t===e.length-1?0:t+1].x*e[t].y*.5}return t&&(l=Math.abs(l)),l}function j(e,t=0){t=parseFloat(t);let l=e.length,a=t>1,n=!a&&!t,s="",r=a?"\n":n?"":" ",i=n?"":" ";s=`${e[0].type}${i}${e[0].values.join(" ")}${r}`;for(let t=1;t<l;t++){let l=e[t-1],a=e[t],{type:p,values:u}=a;if(!n||"A"!==p&&"a"!==p||(u=[u[0],u[1],u[2],`${u[3]}${u[4]}${u[5]}`,u[6]]),p=l.type===a.type&&"m"!==a.type.toLowerCase()&&n||"M"===l.type&&"L"===a.type&&n?" ":a.type,n){let e="",t=!1;for(let l=0,a=u.length;l<a;l++){let a=u[l],n=a.toString(),s=n.includes(".")&&Math.abs(a)<1;s&&t&&(n=n.replace(/^0\./,".")),!(l>0)||t&&s||(e+=" "),e+=n,t=s}s+=`${p}${i}${e}${r}`}else s+=`${p}${i}${u.join(" ")}${r}`}return n&&(s=s.replace(/ 0\./g," .").replace(/ -/g,"-").replace(/-0\./g,"-.").replace(/Z/g,"z")),s}function N(e,t,l=!1,a=1){let n=[e,t],s=function(e,t){let l=M(e.p0,e.cp1,t.cp2,t.p,!1),a=M(l,t.p,t.p0,t.cp1,!1),n=b(l,t.p),s=b(a,t.p),r=1-s/n,i=b(e.cp2,e.p),p=b(e.cp2,t.cp1);return r=Math.min(i)/p,r}(e,t),r=k(e.p0,e.p),i=k(t.p0,t.p),p=.05*Math.min(r,i)*a,u=function(e,t,l=0,a=0){let{p0:n,cp1:s}=e,{p:r,cp2:i}=t,p={x:(s.x-(1-l)*n.x)/l,y:(s.y-(1-l)*n.y)/l},u={x:(i.x-a*r.x)/(1-a),y:(i.y-a*r.y)/(1-a)},y={p0:n,cp1:p,cp2:u,p:r};return y}(e,t,s,s),y=w([u.p0,u.cp1,u.cp2,u.p],s),o=k(e.p,y),h=0,c=0,x=!1,f=o;if(o<p){let l=.5*(1+s);if(h=k(w([t.p0,t.cp1,t.cp2,t.p],.5),w([u.p0,u.cp1,u.cp2,u.p],l)),f+=h,h<p){let t=.5*s;c=k(w([e.p0,e.cp1,e.cp2,e.p],.5),w([u.p0,u.cp1,u.cp2,u.p],t)),h+c<p&&(x=!0),f+=c}}if(l&&!x){let l=function(e,t,l=0,a=1){const n=(e,t,l,a,n)=>{let s=1-n;return{x:3*s*s*(t.x-e.x)+6*s*n*(l.x-t.x)+3*n*n*(a.x-l.x),y:3*s*s*(t.y-e.y)+6*s*n*(l.y-t.y)+3*n*n*(a.y-l.y)}};let s=[e,t],r=C(e.p0,e.p)>C(t.p0,t.p),i=JSON.parse(JSON.stringify(e)),p=JSON.parse(JSON.stringify(t)),u=M(i.p0,i.cp1,p.p,p.cp2,!1);if(!u)return s;if(r){let l={p0:{x:e.p.x,y:e.p.y},cp1:{x:e.cp2.x,y:e.cp2.y},cp2:{x:e.cp1.x,y:e.cp1.y},p:{x:e.p0.x,y:e.p0.y}};e={p0:{x:t.p.x,y:t.p.y},cp1:{x:t.cp2.x,y:t.cp2.y},cp2:{x:t.cp1.x,y:t.cp1.y},p:{x:t.p0.x,y:t.p0.y}},t=l}let y=(e,t)=>({x:e.x-t.x,y:e.y-t.y}),o=(e,t)=>({x:e.x*t,y:e.y*t}),h=(e,t)=>e.x*t.x+e.y*t.y,c=t.p0,x=n(t.p0,t.cp1,t.cp2,t.p,0),f=h(y(e.p0,c),x)/h(x,x),g=w([t.p0,t.cp1,t.cp2,t.p],f),v=n(t.p0,t.cp1,t.cp2,t.p,f);f-=h(y(g,e.p0),v)/h(v,v);let d=w([t.p0,t.cp1,t.cp2,t.p],f),m=t.p,b=n(t.p0,t.cp1,t.cp2,t.p,f),L=n(t.p0,t.cp1,t.cp2,t.p,1),P=1-f,S=(I=d,F=o(b,P/3),{x:I.x+F.x,y:I.y+F.y});var I,F;let $=y(m,o(L,P/3)),z={p0:d,cp1:S,cp2:$,p:m};r&&(z={p0:m,cp1:$,cp2:S,p:d});let E=w([z.p0,z.cp1,z.cp2,z.p],.5,!1,!0),T=E.cpts[2],Q=M(E,T,z.p0,u,!1),q=M(E,T,z.p,u,!1),D=A(z.p0,Q,1.333),O=A(z.p,q,1.333);if(M(i.p0,D,p.p,O,!0))return s;z.cp1=D,z.cp2=O;let N=k(i.p0,z.p0)+k(p.p,z.p);if(z.p0=i.p0,z.p=p.p,z.extreme=p.extreme,z.corner=p.corner,z.dimA=p.dimA,z.directionChange=p.directionChange,z.values=[z.cp1.x,z.cp1.y,z.cp2.x,z.cp2.y,z.p.x,z.p.y],N<l){let e=B([{type:"M",values:[i.p0.x,i.p0.y]},{type:"C",values:[i.cp1.x,i.cp1.y,i.cp2.x,i.cp2.y,i.p.x,i.p.y]},{type:"C",values:[p.cp1.x,p.cp1.y,p.cp2.x,p.cp2.y,p.p.x,p.p.y]}]),t=[{type:"M",values:[z.p0.x,z.p0.y]},{type:"C",values:[z.cp1.x,z.cp1.y,z.cp2.x,z.cp2.y,z.p.x,z.p.y]}],l=B(t),n=Math.abs(l/e-1);z.error=10*n*a,j(t),n<.01&&(s=[z])}return s}(e,t,p,a);1===l.length&&(x=!0,u=l[0],f=u.error)}return x&&(u.p0=e.p0,u.p=t.p,u.dimA=k(u.p0,u.p),u.type="C",u.extreme=t.extreme,u.directionChange=t.directionChange,u.corner=t.corner,u.values=[u.cp1.x,u.cp1.y,u.cp2.x,u.cp2.y,u.p.x,u.p.y],u.error=f/p,n=[u]),n}function V(e=[]){let t,l=[],a=function(e){let t=[],l={x:e[0].values[0],y:e[0].values[1]};return e.forEach(e=>{let{type:a,values:n}=e;if(n.length){let e=n.length>1?{x:n[n.length-2],y:n[n.length-1]}:"V"===a?{x:l.x,y:n[0]}:{x:n[0],y:l.y};t.push(e),l=e}}),t}(e),n=Q(a),{left:s,right:r,top:i,bottom:p,width:u,height:y}=n,o=e[0].values[0],h=e[0].values[1],c={x:e[0].values[0],y:e[0].values[1]},x={x:e[0].values[0],y:e[0].values[1]};e[0].idx=0,e[0].p0=c,e[0].p=c,e[0].lineto=!1,e[0].corner=!1,e[0].extreme=!1,e[0].directionChange=!1,e[0].closePath=!1,e[0].dimA=0;let f=[e[0]],g=0,v=e.length;for(let l=2;v&&l<=v;l++){let a=e[l-1],{type:n,values:u}=a,y=u.slice(-2),v=[x],d=!1;a.idx=l-1,a.lineto=!1,a.corner=!1,a.extreme=!1,a.directionChange=!1,a.closePath=!1,a.dimA=0;let M,b,A,w,L,S,F,$=.05;t=y.length?{x:y[0],y:y[1]}:c,"M"===n?(c=t,x=t):"z"===n.toLowerCase()&&(t=c),a.p0=x,a.p=t;let z=k(x,t);if(a.dimA=z,"L"===n&&(a.lineto=!0),"Z"===n&&(a.closePath=!0,c.x!==o&&c.y!==h&&(a.lineto=!0)),"Q"!==n&&"C"!==n||(M={x:u[0],y:u[1]},b="C"===n?{x:u[2],y:u[3]}:null,a.cp1=M,b&&(a.cp2=b)),u.length>2){"Q"!==n&&"C"!==n||v.push(M),"C"===n&&v.push(b),v.push(t),d=I(v).flat,a.flat=d,d&&(a.extreme=!1)}d||"L"===n||t.x!==s&&t.y!==i&&t.x!==r&&t.y!==p||(a.extreme=!0);let E=e[l]?e[l]:null,T=E?E.values.slice(-2):null;S=E?E.type:null,!E||"Q"!==E.type&&"C"!==E.type||(L=E?{x:T[0],y:T[1]}:null,A={x:E.values[0],y:E.values[1]},w="C"===E.type?{x:E.values[2],y:E.values[3]}:null),F=O(v);let Q=g<0&&F>0||g>0&&F<0;if(g=F,Q&&(a.directionChange=!0),("Q"===n||"C"===n)&&("Q"===n&&"Q"===S||"C"===n&&"C"===S)){let e=v.slice(1),l=I("C"===n?[t,A,w,L]:[t,A,L],((L?Math.abs(L.x-x.x):0)+(L?Math.abs(L.y-x.y):0))/2*.1).flat;if((!d||!l)&&(!!a.extreme||P(0,e,$)))a.extreme=!0;else{let e=b?[b,t]:[M,t],l=[t,A],n=m(...e,!0),s=m(...l,!0),r=180*Math.abs(n-s)/Math.PI,i=C(...e),p=C(...l);r>10&&i&&p&&(a.corner=!0)}}f.push(a),x=t}return l={pathData:f,bb:n,dimA:(u+y)/2},l}function H(e,t=-1){let l=!("auto"!=t||!e[0].hasOwnProperty("decimals"));for(let a=0,n=e.length;a<n;a++){let n=e[a];(t>-1||l)&&(t=l?n.decimals:t,e[a].values=n.values.map(e=>e?+e.toFixed(t):e))}return e}function Z(e={},t={},l={},a={}){let n=A(e,t,1.5),s=A(a,l,1.5),r=.01*k(e,a),i=k(n,s),p=null,u="C",y=[t.x,t.y,l.x,l.y,a.x,a.y];return i<r&&(p=M(e,t,a,l,!1),p&&(u="Q",y=[p.x,p.y,a.x,a.y])),{type:u,values:y}}function R(e,{toShorthands:t=!0,toRelative:l=!0,decimals:a=3}={}){return t&&(e=function(e,t=-1,l=!0){let a;if(l){let t=e.map(e=>e.type).join("");a=/[astvqmhlc]/g.test(t)}e=l&&a?W(e,t):e;let n={type:"M",values:e[0].values};e[0].decimals&&(n.decimals=e[0].decimals);let s,r=[n],i={x:e[0].values[0],y:e[0].values[1]},p=.01;for(let l=1,a=e.length;l<a;l++){let a=e[l],{type:u,values:y}=a,o=y.slice(-2),h=e[l-1],c=h.type;s={x:o[0],y:o[1]};let x,f,g,v,d={x:y[0],y:y[1]},m=Math.abs(s.x-i.x),M=Math.abs(s.y-i.y),b=(m+M)/2*p;switch(u){case"L":n=0===M||M<b&&m>b?{type:"H",values:[y[0]]}:0===m||M>b&&m<b?{type:"V",values:[y[1]]}:a;break;case"Q":if("Q"!==c){i={x:o[0],y:o[1]},r.push(a);continue}let e={x:h.values[0],y:h.values[1]};v={x:2*i.x-e.x,y:2*i.y-e.y},x=Math.abs(d.x-v.x),f=Math.abs(d.y-v.y),g=(x+f)/2,n=g<b?{type:"T",values:[s.x,s.y]}:a;break;case"C":let t={x:y[2],y:y[3]};if("C"!==c){r.push(a),i={x:o[0],y:o[1]};continue}let l={x:h.values[2],y:h.values[3]};v={x:2*i.x-l.x,y:2*i.y-l.y},x=Math.abs(d.x-v.x),f=Math.abs(d.y-v.y),g=(x+f)/2,n=g<b?{type:"S",values:[t.x,t.y,s.x,s.y]}:a;break;default:n={type:u,values:y}}(a.decimals||0===a.decimals)&&(n.decimals=a.decimals),t>-1&&(n.values=n.values.map(e=>+e.toFixed(t))),i={x:o[0],y:o[1]},r.push(n)}return r}(e)),e=H(e,a),l&&(e=function(e,t=-1){return J(e,!0,t)}(e)),a>-1&&(e=H(e,a)),e}function U(e,t){Array.isArray(e)&&(e={x:e[0],y:e[1]});let l={x:e.x+2/3*(t[0]-e.x),y:e.y+2/3*(t[1]-e.y)},a={x:t[2]+2/3*(t[0]-t[2]),y:t[3]+2/3*(t[1]-t[3])};return{type:"C",values:[l.x,l.y,a.x,a.y,t[2],t[3]]}}function J(e,t=!1,l=-1){l>=0&&(e[0].values=e[0].values.map(e=>+e.toFixed(l)));let a=e[0].values,n=a[0],s=a[1],r=n,i=s;for(let a=1,p=e.length;a<p;a++){let p=e[a],{type:u,values:y}=p,o=t?u.toLowerCase():u.toUpperCase();if(u!==o)switch(u=o,p.type=u,u){case"a":case"A":y[5]=t?y[5]-n:y[5]+n,y[6]=t?y[6]-s:y[6]+s;break;case"v":case"V":y[0]=t?y[0]-s:y[0]+s;break;case"h":case"H":y[0]=t?y[0]-n:y[0]+n;break;case"m":case"M":t?(y[0]-=n,y[1]-=s):(y[0]+=n,y[1]+=s),r=t?y[0]+n:y[0],i=t?y[1]+s:y[1];break;default:if(y.length)for(let e=0;e<y.length;e++)y[e]=t?y[e]-(e%2?s:n):y[e]+(e%2?s:n)}let h=y.length;switch(u){case"z":case"Z":n=r,s=i;break;case"h":case"H":n=t?n+y[0]:y[0];break;case"v":case"V":s=t?s+y[0]:y[0];break;case"m":case"M":r=y[h-2]+(t?n:0),i=y[h-1]+(t?s:0);default:n=y[h-2]+(t?n:0),s=y[h-1]+(t?s:0)}l>=0&&(p.values=p.values.map(e=>+e.toFixed(l)))}return e}function W(e,t=-1){return J(e,!1,t)}function X(e,t,l=1){const a=2*Math.PI;let[n,s,r,i,p,u,y]=t;if(0===n||0===s)return[];let o=r?r*a/360:0,h=o?Math.sin(o):0,c=o?Math.cos(o):1,x=c*(e.x-u)/2+h*(e.y-y)/2,f=-h*(e.x-u)/2+c*(e.y-y)/2;if(0===x&&0===f)return[];n=Math.abs(n),s=Math.abs(s);let g=x*x/(n*n)+f*f/(s*s);if(g>1){let e=Math.sqrt(g);n*=e,s*=e}let v=n*n,d=n===s?v:s*s,m=x*x,M=f*f,b=v*d-v*M-d*m;b<=0?b=0:(b/=v*M+d*m,b=Math.sqrt(b)*(i===p?-1:1));let C=b?b*n/s*f:0,A=b?b*-s/n*x:0,w=c*C-h*A+(e.x+u)/2,L=h*C+c*A+(e.y+y)/2,P=(x-C)/n,S=(f-A)/s,I=(-x-C)/n,F=(-f-A)/s;const k=(e,t,l,a)=>{let n=+(e*l+t*a).toFixed(9);return 1===n||-1===n?1===n?0:Math.PI:(n=n>1?1:n<-1?-1:n,(e*a-t*l<0?-1:1)*Math.acos(n))};let $=k(1,0,P,S),z=k(P,S,I,F);0===p&&z>0?z-=2*Math.PI:1===p&&z<0&&(z+=2*Math.PI);let E=(+(Math.abs(z)/(a/4)).toFixed(0)||1)*l;z/=E;let T=[];const Q=1.5707963267948966,q=.551785;let D=z===Q?q:z===-Q?-q:4/3*Math.tan(z/4),B=z?Math.cos(z):1,O=z?Math.sin(z):0;const j=(e,t,l,a,n)=>{let s=e!=t?Math.cos(e):a,r=e!=t?Math.sin(e):n,i=Math.cos(e+t),p=Math.sin(e+t);return[{x:s-r*l,y:r+s*l},{x:i+p*l,y:p-i*l},{x:i,y:p}]};for(let e=0;e<E;e++){let e={type:"C",values:[]};j($,z,D,B,O).forEach(t=>{let l=t.x*n,a=t.y*s;e.values.push(c*l-h*a+w,h*l+c*a+L)}),T.push(e),$+=z}return T}function G(e,t,l,a,n=7.5){let s={type:"C",values:[t.x,t.y,l.x,l.y,a.x,a.y]},r=0,i=!1,p=m(e,t,!0),u=m(a,l,!0),y=180*Math.abs(p-u)/Math.PI;if(Math.abs(y%180-90)<3){let p=M(e,t,a,l,!1);if(p){let u=b(e,p),y=b(a,p),o=+Math.max(u,y).toFixed(8),h=+Math.min(u,y).toFixed(8),c=h,x=o,f=O([e,t,l,a])<0?0:1,g=Math.abs(a.x-e.x)>Math.abs(a.y-e.y);100/c*Math.abs(c-x)<5&&(c=o,x=c),g&&(c=o,x=h);let v=B([{type:"M",values:[e.x,e.y]},{type:"C",values:[t.x,t.y,l.x,l.y,a.x,a.y]}]),d={type:"A",values:[c,x,0,0,f,a.x,a.y]};r=Math.PI*(c*x)/4,r-=Math.abs(O([e,a,p])),function(e,t){let l=Math.abs(e-t);return Math.abs(100-100/e*(e+l))}(v,r)<n&&(i=!0,s=d)}}return{com:s,isArc:i,area:r}}function Y(e){let t,l=[[]],a=0,n=[[]],s={x:e[0].values[0],y:e[0].values[1]};for(let r=0,i=e.length;r<i;r++){let i=e[r],{type:p,values:u}=i;if("A"===p){let p=e[r-1].values.slice(-2);s={x:p[0],y:p[1]};let[y,o,h,c,x,f,g]=u,v=100/y*Math.abs(y-o)<5;t={x:u[5],y:u[6]},i.p0=s,i.p=t,i.circular=v;let d=e[r+1];if(!l[a].length&&d&&"A"===d.type&&(l[a].push(i),n[a].push(r)),d&&"A"===d.type){let[e,i,p,u,h,c,x]=d.values,f=y!=e?100/y*Math.abs(y-e):0,g=o!=i?100/o*Math.abs(o-i):0;t={x:d.values[5],y:d.values[6]},d.p0=s,d.p=t,f<5&&g<5?(l[a].push(d),n[a].push(r+1)):(l.push([]),n.push([]),a++)}else l.push([]),n.push([]),a++}}if(!n.length)return e;l=l.filter(e=>e.length),n=n.filter(e=>e.length);for(let t=l.length-1;t>=0;t--){const a=l[t],s=n[t][0],r=a.length;let i=0,p=0;a.forEach(({values:e})=>{const[t,l]=e;i+=t,p+=l}),i/=r,p/=r;let u=100/i*Math.abs(i-p)<5;u&&(i=(i+p)/2,p=i);let y=e[s-1].values.slice(-2);if(y[0],y[1],4===r){let[t,l,n,y,o,h,c]=a[1].values,[,,,,,x,f]=a[3].values;u&&(i=1,p=1);let g={type:"A",values:[i,p,n,y,o,h,c]},v={type:"A",values:[i,p,n,y,o,x,f]};e.splice(s,r,g,v)}else if(3===r){let[t,l,n,u,y,o,h]=a[0].values,[c,x,,,,f,g]=a[2].values;u=1;let v={type:"A",values:[i,p,n,u,y,f,g]};e.splice(s,r,v)}else if(2===r){let[t,l,n,y,o,h,c]=a[0].values,[x,f,,,,g,v]=a[1].values;u&&(i=1,p=1,n=0);let{p0:d,p:m}=a[0],[M,b]=[a[1].p0,a[1].p];if(d.x!==b.x||d.y!==b.y){let t={type:"A",values:[i,p,n,y,o,g,v]};e.splice(s,r,t)}}}return e}function K(e=[],{toAbsolute:t=!0,toLonghands:l=!0,quadraticToCubic:a=!1,arcToCubic:n=!1,arcAccuracy:s=2}={},{hasRelatives:r=!0,hasShorthands:i=!0,hasQuadratics:p=!0,hasArcs:u=!0,testTypes:y=!1}={}){if(y){let t=Array.from(new Set(e.map(e=>e.type))).join("");r=/[lcqamts]/gi.test(t),p=/[qt]/gi.test(t),u=/[a]/gi.test(t),i=/[vhst]/gi.test(t),isPoly=/[mlz]/gi.test(t)}return(p&&a||u&&n)&&(l=!0,t=!0),r&&t&&(e=J(e,!1)),i&&l&&(e=function(e,t=-1,l=!0){let a=!1;if(l){let t=e.map(e=>e.type).join(""),l=/[hstv]/gi.test(t);if(a=/[astvqmhlc]/g.test(t),!l)return e}let n=[],s={type:"M",values:(e=l&&a?W(e,t):e)[0].values};n.push(s);for(let l=1,a=e.length;l<a;l++){let a,r,i,p,u,y,o,h,c=e[l],{type:x,values:f}=c,g=f.length,v=s.values,d=v.length,[m,M]=[f[g-2],f[g-1]],[b,C]=[v[d-2],v[d-1]];switch(x){case"H":s={type:"L",values:[f[0],C]};break;case"V":s={type:"L",values:[b,f[0]]};break;case"T":[a,r]=[v[0],v[1]],[b,C]=[v[d-2],v[d-1]],i=b+(b-a),p=C+(C-r),s={type:"Q",values:[i,p,m,M]};break;case"S":[a,r]=[v[0],v[1]],[b,C]=[v[d-2],v[d-1]],[o,h]=d>2&&"A"!==s.type?[v[2],v[3]]:[b,C],i=2*b-o,p=2*C-h,u=f[0],y=f[1],s={type:"C",values:[i,p,u,y,m,M]};break;default:s={type:x,values:f}}t>-1&&(s.values=s.values.map(e=>+e.toFixed(t))),n.push(s)}return n}(e,-1,!1)),u&&n&&(e=function(e,{arcAccuracy:t=1}={}){let l=[e[0]];for(let a=1,n=e.length;a<n;a++){let n=e[a],s=e[a-1].values,r=s.length,i={x:s[r-2],y:s[r-1]};"A"===n.type?X(i,n.values,t).forEach(e=>{l.push(e)}):l.push(n)}return l}(e,s)),p&&a&&(e=function(e){let t=[e[0]];for(let l=1,a=e.length;l<a;l++){let a=e[l],n=e[l-1].values,s=n.length,r={x:n[s-2],y:n[s-1]};"Q"===a.type?t.push(U(r,a.values)):t.push(a)}return t}(e)),e}function _(e,{toAbsolute:t=!0,toLonghands:l=!0,quadraticToCubic:a=!1,arcToCubic:n=!1,arcAccuracy:s=4}={}){let r=function(e,t=!0){if(e=e.trim(),""===e)return{pathData:[],hasRelatives:!1,hasShorthands:!1,hasQuadratics:!1,hasArcs:!1};const l=new Set([5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279]),a=e=>32===e||44===e||10===e||13===e||8232===e||8233===e||9===e||11===e||12===e||160===e||e>=5760&&l.has(e);let n,s=0,r=e.length,i="",p=[],u=-1,y="",o=!1,h=0,c=0,x=0,f=!1,g=new Set([]),v=[];const d=()=>{f&&("M"===i?i="L":"m"===i&&(i="l"),p.push({type:i,values:[]}),u++,c=0,f=!1)},m=(e=!1)=>{(e?h>0:""!==y)&&(t&&-1===u&&(n="Pathdata must start with M command",v.push(n),i="M",p.push({type:i,values:[]}),x=2,c=0,u++),"A"===i||"a"===i?(y=M(),p[u].values.push(...y)):(t&&y[1]&&"."!==y[1]&&"0"===y[0]&&(n=`${u}. command: Leading zeros not valid: ${y}`,v.push(n)),p[u].values.push(+y)),c++,y="",h=0,f=c>=x)},M=()=>{let e=y.length,t=!1;return 3===c&&2===e||4===c&&e>1?(y=[+y[0],+y[1]],t=!0,c++):3===c&&e>=3&&(y=[+y[0],+y[1],+y.substring(2)],t=!0,c+=2),t?y:[+y]},b=()=>{if(u>0){let e=p[u].values.length;if(e&&e<x||e&&e>x||("z"===i||"Z"===i)&&e>0){n=`${u}. command of type "${i}": ${x-e} values too few - ${x} expected`,v[v.length-1]!==n&&v.push(n)}}};let C=!1,A=!1,w=!1;for(;s<r;){let l=e.charCodeAt(s),r=l>47&&l<58;if(r||(C=101===l||69===l,A=45===l||43===l,w=46===l),r||A||w||C){if(o||45!==l&&46!==l)d();else{let e=46===l;m(e),d(),e&&h++}y+=e[s],o=C,s++}else if((l<48||l>5759)&&a(l))m(),s++;else{if(l>64){if(!ee.has(l)){n=`${u}. command "${e[s]}" is not a valid type`,v.push(n),s++;continue}""!==y&&(p[u].values.push(+y),c++,y=""),t&&b(),i=e[s],x=te[l];let a="M"===i||"m"===i,r=u>0&&("z"===p[u].type||"Z"===p[u].type);g.add(i),r&&!a&&(p.push({type:"m",values:[0,0]}),u++),p.push({type:i,values:[]}),u++,h=0,c=0,f=!1,s++;continue}r||(n=`${u}. ${e[s]} is not a valid separarator or token`,v.push(n),y=""),s++}}m(),t&&b();if(t&&v.length){if(n="Invalid path data:\n"+v.join("\n"),"log"!==t)throw new Error(n);console.log(n)}p[0].type="M";let L=Array.from(g).join(""),P=/[lcqamts]/g.test(L),S=/[vhst]/gi.test(L),I=/[a]/gi.test(L),F=/[qt]/gi.test(L);return{pathData:p,hasRelatives:P,hasShorthands:S,hasQuadratics:F,hasArcs:I}}(e),{hasRelatives:i,hasShorthands:p,hasQuadratics:u,hasArcs:y}=r,o=r.pathData;return o=K(o,{toAbsolute:t,toLonghands:l,quadraticToCubic:a,arcToCubic:n,arcAccuracy:s},{hasRelatives:i,hasShorthands:p,hasQuadratics:u,hasArcs:y}),o}const ee=new Set([77,109,65,97,67,99,76,108,81,113,83,115,84,116,72,104,86,118,90,122]),te=new Uint8Array(128);function le(e,t=1,l=!0){let a=[e[0]],n={x:e[0].values[0],y:e[0].values[1]},s=n,r=n;e[e.length-1].type.toLowerCase();for(let i=1,p=e.length;i<p;i++){let u=e[i-1],y=e[i],o=e[i+1]||e[p-1],h="z"===o.type.toLowerCase()?n:{x:o.values[o.values.length-2],y:o.values[o.values.length-1]},{type:c,values:x}=y,f=x.slice(-2);r="Z"!==c?{x:f[0],y:f[1]}:n;let g=O([s,r,h],!0)<C(s,h)/100*t,v=!1;if(l||"C"!==c||(g=!1),l&&("C"===c||"Q"===c)){v=F(s,"C"===c?[{x:x[0],y:x[1]},{x:x[2],y:x[3]}]:"Q"===c?[{x:x[0],y:x[1]}]:[],r),v&&i<p-1&&"C"!==u.type&&(c="L",y.type="L",y.values=f)}s=r,g&&i<p-1&&("L"===c||l&&v)||("M"===c?(n=r,s=n):"Z"===c&&(s=n),a.push(y))}return a}function ae(e){let t={x:e[0].values[0],y:e[0].values[1]},l=t,a=[e[0]];for(let n=1,s=e.length;n<s;n++){let s=e[n],{type:r,values:i}=s,p=i.slice(-2);l={x:p[0],y:p[1]},"L"===r&&l.x===t.x&&l.y===t.y||(a.push(s),t=l)}return a}function ne(e){let t=e.length;if(!("z"===e[t-1].type.toLowerCase()))return e;let l=0,a=[];for(let l=0;l<t;l++){let t=e[l],{type:n,values:s}=t,r=s.length;if(r){let e={type:n,x:s[r-2],y:s[r-1],index:0};e.index=l,a.push(e)}}return a=a.sort((e,t)=>+e.y.toFixed(3)-+t.y.toFixed(3)),l=a[0].index,l?re(e,l):e}function se(e,t=!0,l=!0){let a=[],n=e.length,s={x:+e[0].values[0].toFixed(8),y:+e[0].values[1].toFixed(8)},r="z"===e[n-1].type.toLowerCase(),i=e.filter(e=>"L"===e.type),p=e[n-2],u=p.type,y=p.values.slice(-2).map(e=>+e.toFixed(8)),o=y[0]===s.x&&y[1]===s.y,h="L"!==e[1].type&&(!o||"L"===u);if(h=!1,!r)return e;let c=0;{let t=[];for(let l=0,a=e.length;l<a;l++){let a=e[l],{type:n,values:s}=a;if(s.length){let a=s.slice(-2),r=e[l-1]&&"L"===e[l-1].type,i=e[l+1]&&"L"===e[l+1].type,p=e[l-1]?e[l-1].type.toUpperCase():null,u=e[l+1]?e[l+1].type.toUpperCase():null,y={type:n,x:a[0],y:a[1],dist:0,index:0,prevL:r,nextL:i,prevCom:p,nextCom:u};y.index=l,t.push(y)}}if(i.length){let e=t.filter(e=>"L"!==e.type&&"M"!==e.type&&e.prevCom&&"L"===e.prevCom||"M"===e.prevCom&&"L"===u).sort((e,t)=>e.y-t.y||e.x-t.x)[0];c=e?e.index-1:0}else t=t.sort((e,t)=>+e.y.toFixed(1)-+t.y.toFixed(1)||e.x-t.x),c=t[0].index;e=c?re(e,c):e}return s={x:+e[0].values[0].toFixed(8),y:+e[0].values[1].toFixed(7)},n=e.length,p=e[n-2],u=p.type,y=p.values.slice(-2).map(e=>+e.toFixed(8)),o="L"===u&&y[0]===s.x&&y[1]===s.y,t&&o&&e.splice(n-2,1),a.push(...e),a}function re(e,t){let l=0,a="z"===e[e.length-1].type.toLowerCase();if(!a||t<1||e.length<3)return e;let n=a?1:0;!function(e){let t=e.length,l="z"===e[t-1].type.toLowerCase(),a=e[0],[n,s]=[a.values[0],a.values[1]].map(e=>+e.toFixed(8)),r=l?e[t-2]:e[t-1],i=r.values.length,[p,u]=[r.values[i-2],r.values[i-1]].map(e=>+e.toFixed(8));!l||n==p&&s==u||(e.pop(),e.push({type:"L",values:[n,s]},{type:"Z",values:[]}))}(e),l=t+1<e.length-1?t+1:e.length-1-n;let s,r,i=e.slice(l),p=e.slice(0,l);return p.shift(),s=p[p.length-1].values||[],r=[s[s.length-2],s[s.length-1]],n&&(i.pop(),p.push({type:"Z",values:[]})),e=[{type:"M",values:r},...i,...p]}function ie(e,{arcToCubic:t=!1,quadraticToCubic:l=!1,toClockwise:a=!1,returnD:n=!1}={}){const s=(e,t)=>{let l=[],a=[];if("A"!==e){for(let e=0;e<t.length;e+=2)l.push([t[e],t[e+1]]);a=l.pop(),l.reverse()}else{let e=0==t[4]?1:0;l=[t[0],t[1],t[2],t[3],e],a=[t[5],t[6]]}return{controlPoints:l,endPoints:a}};let r=[],i="z"===e[e.length-1].type.toLowerCase();i&&(e=(e=>{let t="z"===e[e.length-1].type.toLowerCase(),l=e[0],[a,n]=[l.values[0],l.values[1]],s=t?e[e.length-2]:e[e.length-1],[r,i]=[s.values[s.values.length-2],s.values[s.values.length-1]];return!t||a==r&&n==i||(e.pop(),e.push({type:"L",values:[a,n]},{type:"Z",values:[]})),e})(e),e.pop());let p=e[e.length-1].values,u=p.length,y=i?e[0]:{type:"M",values:[p[u-2],p[u-1]]};r.push(y),e.reverse();for(let t=1;t<e.length;t++){let l=e[t],a=l.type,n=l.values,i=e[t-1],p=i.type,u=[];u=[s(p,i.values).controlPoints,s(a,n).endPoints].flat(),r.push({type:p,values:u.flat()})}return i&&r.push({type:"z",values:[]}),r}function pe(e,{returnDom:t=!1,removeHidden:l=!0,removeUnused:a=!0}={}){e=(e=e.replace(/<\?xml[\s\S]*?\?>/gi,"").replace(/<!DOCTYPE[\s\S]*?>/gi,"").replace(/<!--[\s\S]*?-->/g,"").trim()).replaceAll("xlink:href=","href=");let n=(new DOMParser).parseFromString(e,"text/html").querySelector("svg");!function(e,t=["viewBox","xmlns","width","height","id","class"]){[...e.attributes].map(e=>e.name).forEach(l=>{t.includes(l)||e.removeAttribute(l)})}(n,["viewBox","xmlns","width","height","id","class"]);let s=["metadata","script"];if(n.querySelectorAll("*").forEach(e=>{let t=e.nodeName,a=e.getAttribute("style")||"",n=!!a&&a.trim().includes("display:none"),r=e.getAttribute("display")&&"none"===e.getAttribute("display")||n;t.includes(":")||s.includes(t)||l&&r?e.remove():function(e){let t=[...e.attributes].map(e=>e.name);t.forEach(t=>{t.includes(":")&&e.removeAttribute(t)})}(e)}),t)return n;let r=function(e){let t=(new XMLSerializer).serializeToString(e);return t=t.replace(/\t/g,"").replace(/[\n\r|]/g,"\n").replace(/\n\s*\n/g,"\n").replace(/ +/g," "),t}(n);return console.log(r),r}function ue(e="",{toAbsolute:t=!0,toRelative:l=!0,toShorthands:a=!0,decimals:n=3,quadraticToCubic:s=!0,arcToCubic:r=!1,cubicToArc:i=!1,arcAccuracy:p=4,keepExtremes:u=!0,keepCorners:y=!0,keepInflections:o=!0,extrapolateDominant:h=!1,addExtremes:c=!1,optimizeOrder:x=!0,removeColinear:f=!0,simplifyBezier:g=!0,autoAccuracy:v=!0,flatBezierToLinetos:d=!0,revertToQuadratics:m=!0,minifyD:M=0,tolerance:b=1,reverse:C=!1,removeHidden:A=!0,removeUnused:w=!0,getObject:L=!1}={}){b=Math.max(.1,b);let P=function(e){let t="string";if(e instanceof HTMLImageElement)return"img";if(e instanceof SVGElement)return"svg";if(e instanceof HTMLCanvasElement)return"canvas";if(e instanceof File)return"file";if(e instanceof ArrayBuffer)return"buffer";if(e instanceof Blob)return"blob";if(Array.isArray(e))return"array";if("string"==typeof e){let l=(e=e.trim()).includes("<svg")&&e.includes("</svg"),a=e.startsWith("M")||e.startsWith("m"),n=!isNaN(e.substring(0,1))&&!isNaN(e.substring(e.length-1,e.length));if(l)t="svgMarkup";else if(a)t="pathDataString";else if(n)t="polyString";else{let l=/^(file:|https?:\/\/|\/|\.\/|\.\.\/)/.test(e),a=e.startsWith("data:image");t=l||a?"url":"string"}return t}return t=typeof e,(e.constructor.name||t).toLowerCase()}(e),S="",I=0,F=0,z=0,E={},Q="",q="svgMarkup"===P?1:0,D=[];if(I=new Blob([e]).size,q){S=pe(e,{returnDom:!0,removeHidden:A,removeUnused:w}),S.querySelectorAll("path").forEach(e=>{D.push({d:e.getAttribute("d"),el:e})})}else"pathDataString"===P?Q=e:"polyString"===P&&(Q="M"+e),D.push({d:Q,el:null});return D.forEach(e=>{let{d:p,el:A}=e,w=_(p,{quadraticToCubic:s,toAbsolute:t,arcToCubic:r}),L=JSON.parse(JSON.stringify(w)),P=w.length,S=$(L),E=[];for(let e=0,t=S.length;e<t;e++){let t=S[e];C&&(t=ie(t)),f&&(t=ae(t)),c&&(t=T(t,0,1)),x&&(t=ne(t)),f&&(t=le(t,b,d));let l=V(t),{pathData:a,bb:n,dimA:s}=l;if(a=g?ye(a,{simplifyBezier:g,keepInflections:o,keepExtremes:u,keepCorners:y,extrapolateDominant:h,revertToQuadratics:m,tolerance:b,reverse:C}):a,i){let e=3;a.forEach((t,l)=>{let{type:n,values:s,p0:r,cp1:i=null,cp2:p=null,p:u=null}=t;if("C"===n){let t=G(r,i,p,u,e);t.isArc&&(a[l]=t.com)}}),a=Y(a)}m&&a.forEach((e,t)=>{let{type:l,values:n,p0:s,cp1:r=null,cp2:i=null,p:p=null}=e;if("C"===l){let e=Z(s,r,i,p);"Q"===e.type&&(a[t]=e)}}),x&&(a=se(a)),E.push(a)}L=E.flat(),v&&(n=function(e){let t={x:e[0].values[0],y:e[0].values[1]},l=t,a=t;e[0].decimals=0;let n=new Set;for(let s=0,r=e.length;s<r;s++){let r=e[s],{type:i,values:p}=r,u=p.length?p.slice(-2):[t.x,t.y];a={x:u[0],y:u[1]};let y=r.dimA?+r.dimA.toFixed(8):"M"!==i?+k(l,a).toFixed(8):0;y&&n.add(y),"M"===i&&(t=a),l=a}let s=Array.from(n).sort(),r=Math.ceil(s.length/8);s=s.slice(0,r);let i=s.reduce((e,t)=>e+t,0)/r,p=i>50?0:Math.floor(50/i).toString().length;return Math.min(Math.max(0,p),8)}(L)),L=R(L,{toRelative:l,toShorthands:a,decimals:n});let Q=[];L.forEach((e,t)=>{let{type:l,values:a}=e;if("l"===l||"v"===l||"h"===l){("l"===l?"00"!==a.join(""):0!==a[0])&&Q.push(e)}else Q.push(e)}),L=Q;let q=L.length,D=j(L,M);F=new Blob([D]).size,z=+(100/I*F).toFixed(2),e.d=D,e.report={original:P,new:q,saved:P-q,compression:z,decimals:n},A&&A.setAttribute("d",D)}),q?(S=(new XMLSerializer).serializeToString(S),F=new Blob([S]).size,z=+(100/I*F).toFixed(2),I=+(I/1024).toFixed(3),F=+(F/1024).toFixed(3),E={svgSize:I,svgSizeOpt:F,compression:z}):({d:Q,report:E}=D[0]),L?{svg:S,d:Q,report:E,inputType:P,mode:q}:Q||S}function ye(e,{keepExtremes:t=!0,keepInflections:l=!0,keepCorners:a=!0,extrapolateDominant:n=!0,tolerance:s=1,reverse:r=!1}={}){let i=[e[0]];for(let r=2,p=e.length;p&&r<=p;r++){let u=e[r-1],y=r<p?e[r]:null,o=y?.type||null,h=u?.directionChange||null,c=y?.directionChange||null,{type:x,values:f,p0:g,p:v,cp1:d=null,cp2:m=null,extreme:M=!1,corner:b=!1,dimA:C=0}=u;if("C"===x&&"C"===o)if(l&&c||a&&b||!h&&t&&M)i.push(u);else{let o=N(u,y,n,s),h=0;if(1===o.length){u=o[0];let y=1;h+=u.error;for(let i=r+1;h<s&&i<p;i++){let r=e[i];if("C"!==r.type||l&&r.directionChange||a&&u.corner||t&&u.extreme)break;let p=N(u,r,n,s);1===p.length&&y++,u=p[0]}i.push(u),r<p&&(r+=y)}else i.push(u)}else i.push(u)}return r&&(i=ie(i)),i}function oe(e=null,t=!1){if(!e)return{x:0,y:0,width:300,height:150};let l=window.getComputedStyle(e),a=e.hasAttribute("width")?e.width.baseVal.value:parseFloat(l.width)||300,n=e.hasAttribute("height")?e.height.baseVal.value:parseFloat(l.height)||150,s=e.getAttribute("viewBox")?e.viewBox.baseVal:{x:0,y:0,width:a,height:n},{x:r,y:i,width:p,height:u}=s;if(s={x:r,y:i,width:p,height:u},t)for(let e in s)s[e]=Math.ceil(s[e]);return s}te[77]=2,te[109]=2,te[65]=7,te[97]=7,te[67]=6,te[99]=6,te[76]=2,te[108]=2,te[81]=4,te[113]=4,te[83]=4,te[115]=4,te[84]=2,te[116]=2,te[72]=1,te[104]=1,te[86]=1,te[118]=1,te[90]=0,te[122]=0;const{abs:he,acos:ce,asin:xe,atan:fe,atan2:ge,ceil:ve,cos:de,exp:me,floor:Me,log:be,hypot:Ce,max:Ae,min:we,pow:Le,random:Pe,round:Se,sin:Ie,sqrt:Fe,tan:ke,PI:$e}=Math;"undefined"!=typeof window&&(window.svgPathSimplify=ue,window.getViewBox=oe,window.renderPoint=function(e,t,l="red",a="1%",n="1",s="",r=!0,i="",p=""){Array.isArray(t)&&(t={x:t[0],y:t[1]});let u=`<circle class="${p}" opacity="${n}" id="${i}" cx="${t.x}" cy="${t.y}" r="${a}" fill="${l}">\n <title>${s}</title></circle>`;if(!r)return u;e.insertAdjacentHTML("beforeend",u)}),exports.PI=$e,exports.abs=he,exports.acos=ce,exports.asin=xe,exports.atan=fe,exports.atan2=ge,exports.ceil=ve,exports.cos=de,exports.exp=me,exports.floor=Me,exports.getViewBox=oe,exports.hypot=Ce,exports.log=be,exports.max=Ae,exports.min=we,exports.pow=Le,exports.random=Pe,exports.round=Se,exports.sin=Ie,exports.sqrt=Fe,exports.svgPathSimplify=ue,exports.tan=ke;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svg-path-simplify",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "main": "./dist/svg-path-simplify.node.js",
5
5
  "module": "./dist/svg-path-simplify.esm.js",
6
6
  "browser": "./dist/svg-path-simplify.js",
@@ -7,7 +7,7 @@ import { combineArcs, convertPathData, cubicCommandToArc, revertCubicQuadratic }
7
7
  import { parsePathDataNormalized } from './svgii/pathData_parse';
8
8
  import { pathDataRemoveColinear } from './svgii/pathData_remove_collinear';
9
9
  import { removeZeroLengthLinetos } from './svgii/pathData_remove_zerolength';
10
- import { pathDataToTopLeft } from './svgii/pathData_reorder';
10
+ import { optimizeClosePath, pathDataToTopLeft } from './svgii/pathData_reorder';
11
11
  import { reversePathData } from './svgii/pathData_reverse';
12
12
  import { addExtremePoints, splitSubpaths } from './svgii/pathData_split';
13
13
  import { pathDataToD } from './svgii/pathData_stringify';
@@ -201,12 +201,14 @@ export function svgPathSimplify(input = '', {
201
201
  })
202
202
  }
203
203
 
204
+ // optimize close path
205
+ if(optimizeOrder) pathData=optimizeClosePath(pathData)
204
206
 
205
207
  // update
206
208
  pathDataArrN.push(pathData)
207
209
  }
208
210
 
209
-
211
+
210
212
  // flatten compound paths
211
213
  pathData = pathDataArrN.flat();
212
214
 
@@ -33,7 +33,8 @@ export function pathDataToTopLeft(pathData) {
33
33
  }
34
34
 
35
35
  // reorder to top left most
36
- indices = indices.sort((a, b) => +a.y.toFixed(3) - +b.y.toFixed(3) || a.x - b.x);
36
+ //|| a.x - b.x
37
+ indices = indices.sort((a, b) => +a.y.toFixed(3) - +b.y.toFixed(3) );
37
38
  newIndex = indices[0].index
38
39
 
39
40
  return newIndex ? shiftSvgStartingPoint(pathData, newIndex) : pathData;
@@ -42,11 +43,11 @@ export function pathDataToTopLeft(pathData) {
42
43
 
43
44
 
44
45
 
45
- export function optimizeClosePath(pathData, removeFinalLineto = false, reorder = true) {
46
+ export function optimizeClosePath(pathData, removeFinalLineto = true, reorder = true) {
46
47
 
47
48
  let pathDataNew = [];
48
49
  let len = pathData.length;
49
- let M = { x: pathData[0].values[0], y: pathData[0].values[1] }
50
+ let M = { x: +pathData[0].values[0].toFixed(8), y: +pathData[0].values[1].toFixed(8) }
50
51
  let isClosed = pathData[len - 1].type.toLowerCase() === 'z'
51
52
 
52
53
  let linetos = pathData.filter(com => com.type === 'L')
@@ -113,15 +114,19 @@ export function optimizeClosePath(pathData, removeFinalLineto = false, reorder =
113
114
  }
114
115
 
115
116
 
117
+ M = { x: +pathData[0].values[0].toFixed(8), y: +pathData[0].values[1].toFixed(7) }
118
+
116
119
  len = pathData.length
117
120
 
118
121
  // remove last lineto
119
122
  penultimateCom = pathData[len - 2];
120
123
  penultimateType = penultimateCom.type;
121
- penultimateComCoords = penultimateCom.values.slice(-2)
124
+ penultimateComCoords = penultimateCom.values.slice(-2).map(val=>+val.toFixed(8))
122
125
 
123
126
  isClosingCommand = penultimateType === 'L' && penultimateComCoords[0] === M.x && penultimateComCoords[1] === M.y
124
127
 
128
+ //console.log('penultimateCom', isClosingCommand, penultimateCom.values, M);
129
+
125
130
  if (removeFinalLineto && isClosingCommand) {
126
131
  pathData.splice(len - 2, 1)
127
132
  }