svg-path-simplify 0.2.2 → 0.2.3

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.
@@ -4148,27 +4148,27 @@ function pathDataRemoveColinear(pathData, {
4148
4148
  let valsL = values.slice(-2);
4149
4149
  p = type !== 'Z' ? { x: valsL[0], y: valsL[1] } : M;
4150
4150
 
4151
- /*
4152
- let area = p1 ? getPolygonArea([p0, p, p1], true) : Infinity
4153
- let distSquare = getSquareDistance(p0, p1)
4154
- let distMax = distSquare ? distSquare / 333 * tolerance : 0
4155
- */
4151
+ let area = p1 ? getPolygonArea([p0, p, p1], true) : Infinity;
4152
+ let distSquare = getSquareDistance(p0, p1);
4153
+ let distMax = distSquare ? distSquare / 333 * tolerance : 0;
4154
+
4155
+ let isFlat = area < distMax;
4156
4156
 
4157
- let isFlat = false;
4158
4157
  let isFlatBez = false;
4159
4158
 
4159
+ /*
4160
4160
  // flatness by cross product
4161
- let dx0 = Math.abs(p1.x - p0.x);
4162
- let dy0 = Math.abs(p1.y - p0.y);
4161
+ let dx0 = Math.abs(p1.x - p0.x)
4162
+ let dy0 = Math.abs(p1.y - p0.y)
4163
4163
 
4164
- let dx1 = Math.abs(p.x - p0.x);
4165
- let dy1 = Math.abs(p.y - p0.y);
4164
+ let dx1 = Math.abs(p.x - p0.x)
4165
+ let dy1 = Math.abs(p.y - p0.y)
4166
4166
 
4167
- let dx2 = Math.abs(p1.x - p.x);
4168
- let dy2 = Math.abs(p1.y - p.y);
4167
+ let dx2 = Math.abs(p1.x - p.x)
4168
+ let dy2 = Math.abs(p1.y - p.y)
4169
4169
 
4170
4170
  // zero length segments are flat
4171
- let isZeroLength = (!dy1 && !dx1) || (!dy2 && !dx2);
4171
+ let isZeroLength = (!dy1 && !dx1) || (!dy2 && !dx2)
4172
4172
  if (isZeroLength) isFlat = true;
4173
4173
 
4174
4174
  // check cross products for colinearity
@@ -4176,13 +4176,14 @@ function pathDataRemoveColinear(pathData, {
4176
4176
 
4177
4177
  let cross0 = Math.abs(dx0 * dy1 - dy0 * dx1);
4178
4178
 
4179
- let thresh = (dx0 + dy0) * 0.1;
4179
+ let thresh = (dx0 + dy0) * 0.1
4180
4180
 
4181
4181
  if ( cross0 < thresh) {
4182
4182
 
4183
- isFlat = true;
4183
+ isFlat = true
4184
4184
  }
4185
4185
  }
4186
+ */
4186
4187
 
4187
4188
  if (!flatBezierToLinetos && type === 'C') isFlat = false;
4188
4189
 
@@ -6022,6 +6023,9 @@ function cleanUpSVG(svgMarkup, {
6022
6023
  let removeEls = ['metadata', 'script'];
6023
6024
 
6024
6025
  let els = svg.querySelectorAll('*');
6026
+
6027
+ let textEls = svg.querySelectorAll('text');
6028
+ let remove = !textEls.length ? ['font-family', 'font-weight', 'font-style', 'font-size'] : [];
6025
6029
 
6026
6030
  els.forEach(el => {
6027
6031
  let name = el.nodeName;
@@ -6034,6 +6038,7 @@ function cleanUpSVG(svgMarkup, {
6034
6038
  } else {
6035
6039
  // remove BS elements
6036
6040
  removeNameSpaceAtts(el);
6041
+ removeAtts(el,remove);
6037
6042
  }
6038
6043
  });
6039
6044
 
@@ -6067,6 +6072,15 @@ function removeExcludedAttribues(el, allowed = ['viewBox', 'xmlns', 'width', 'he
6067
6072
  });
6068
6073
  }
6069
6074
 
6075
+ function removeAtts(el, remove=[]) {
6076
+ let atts = [...el.attributes].map((att) => att.name);
6077
+ atts.forEach((att) => {
6078
+ if (remove.includes(att)) {
6079
+ el.removeAttribute(att);
6080
+ }
6081
+ });
6082
+ }
6083
+
6070
6084
  function removeNameSpaceAtts(el) {
6071
6085
  let atts = [...el.attributes].map((att) => att.name);
6072
6086
  atts.forEach((att) => {
@@ -1,4 +1,4 @@
1
- function e(e,t,l="red",a="1%",n="1",r="",s=!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>${r}</title></circle>`;if(!s)return u;e.insertAdjacentHTML("beforeend",u)}function t(e,t="",l="green",a="1%",n="1",r=!0){let s=`<path d="${t}" fill="none" stroke="${l}" stroke-width="${a}" stroke-opacity="${n}" /> `;if(!r)return s;e.insertAdjacentHTML("beforeend",s)}const{abs:l,acos:a,asin:n,atan:r,atan2:s,ceil:i,cos:p,exp:u,floor:h,log:o,hypot:y,max:c,min:x,pow:f,random:g,round:d,sin:v,sqrt:m,tan:M,PI:b}=Math,{abs:A,acos:C,asin:w,atan:E,atan2:L,ceil:k,cos:P,exp:S,floor:I,log:D,max:F,min:q,pow:$,random:z,round:T,sin:Q,sqrt:B,tan:j,PI:N}=Math;function Z(e,t,l=!1){let a=L(t.y-e.y,t.x-e.x);return l&&a<0&&(a+=2*Math.PI),a}function R(e,t,l,a=!1){let n=Math.atan2(t.y-e.y,t.x-e.x),r=Math.atan2(l.y-e.y,l.x-e.x),s=r-n;s=(e=>{let t=e%(2*Math.PI);return t>Math.PI?t-=2*Math.PI:t<=-Math.PI&&(t+=2*Math.PI),t})(s),a&&(s=2*Math.PI-Math.abs(s));let i=180/Math.PI;return{startAngle:n,endAngle:r,deltaAngle:s,startAngleDeg:n*i,endAngleDeg:r*i,deltaAngleDeg:s*i}}function O(e=null,t=null,l=null,a=null,n=!0,r=!1){let s,i,p,u,h,o={};if(!(e&&t&&l&&a))return r&&console.warn("points missing"),!1;try{if(s=(a.y-l.y)*(t.x-e.x)-(a.x-l.x)*(t.y-e.y),0==s)return!1}catch{return r&&console.warn("!catch",e,t,"p3:",l,"p4:",a),!1}i=e.y-l.y,p=e.x-l.x,u=(a.x-l.x)*i-(a.y-l.y)*p,h=(t.x-e.x)*i-(t.y-e.y)*p,i=u/s,p=h/s,o={x:e.x+i*(t.x-e.x),y:e.y+i*(t.y-e.y)};let y=!1;return i>0&&i<1&&p>0&&p<1&&(y=!0),!(n&&!y)&&o}function H(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=Z(e,t),n.angle<0&&(n.angle+=2*N)),n}function U(e,t=.5,l=!1,a=!1,n=!1){let r;return Array.isArray(e[0])&&(e=e.map(e=>({x:e[0],y:e[1]})),n=!0),r=e.length>2?((e,t,l=!1)=>{let n=4===e.length,r=e[0],s=e[1],i=n?e[2]:e[1],p=e[e.length-1],u={x:0,y:0};if(l||a){let e,l,h,o,y,c=r.x===s.x&&r.y===s.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=H(r,s,t),n?(l=H(s,i,t),h=H(i,p,t),o=H(e,l,t),y=H(l,h,t),u=H(o,y,t),u.angle=Z(o,y),a&&(u.cpts=[l,h,o,y])):(l=H(r,s,t),h=H(s,p,t),u=H(l,h,t),u.angle=Z(l,h),a&&(u.cpts=[l,h]))):(u.x=p.x,u.y=p.y,u.angle=Z(i,p)):(u.x=r.x,u.y=r.y,u.angle=Z(r,s))}else{let e=1-t;u=n?{x:e**3*r.x+3*e**2*t*s.x+3*e*t**2*i.x+t**3*p.x,y:e**3*r.y+3*e**2*t*s.y+3*e*t**2*i.y+t**3*p.y}:{x:e*e*r.x+2*e*t*s.x+t**2*p.x,y:e*e*r.y+2*e*t*s.y+t**2*p.y}}return u})(e,t,l):H(e[0],e[1],t,l),l&&r.angle<0&&(r.angle+=2*N),n?[r.x,r.y]:r}function V(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}function W(e,t,l,a,n,r,s,i,p){const u=(e,t,l,a)=>L(a-t,l-e);let h={cx:0,cy:0,rx:l=A(l),ry:a=A(a),startAngle:0,endAngle:0,deltaAngle:0,clockwise:s,xAxisRotation:n,largeArc:r,sweep:s};if(0==l||0==a)throw Error("rx and ry can not be 0");if(l===a){let l=Math.abs(i-e),a=Math.abs(p-t),n=l,r=Math.min(e,i),u=Math.min(t,p),o=.5*Math.PI;if(0===l&&a||0===a&&l)return n=0===l&&a?a/2:l/2,h.rx=n,h.ry=n,0===l&&a?(h.cx=e,h.cy=u+a/2,h.startAngle=t>p?o:-o,h.endAngle=t>p?-o:o,h.deltaAngle=s?Math.PI:-Math.PI):0===a&&l&&(h.cx=r+l/2,h.cy=t,h.startAngle=e>i?Math.PI:0,h.endAngle=e>i?-Math.PI:Math.PI,h.deltaAngle=s?Math.PI:-Math.PI),h}let o,y,c=l===a?0:n*N/180,x=c?Math.sin(c):0,f=c?Math.cos(c):1,g=(e-i)/2,d=(t-p)/2,v=(e+i)/2,m=(t+p)/2,M=c?f*g+x*d:g,b=c?f*d-x*g:d,C=M*M/(l*l)+b*b/(a*a);C>1&&(l*=Math.sqrt(C),a*=Math.sqrt(C),h.rx=l,h.ry=a);let w=l*a,E=l*b,k=a*M,P=E**2+k**2;if(!P)throw Error("start point can not be same as end point");let S=Math.sqrt(Math.abs((w*w-P)/P));r==s&&(S=-S);let I=S*E/a,D=-S*k/l;o=c?f*I-x*D+v:v+I,y=c?x*I+f*D+m:m+D,h.cy=y,h.cx=o;let F=u(o,y,e,t),q=u(o,y,i,p);!s&&q>F&&(q-=2*Math.PI),s&&F>q&&(q=q<=0?q+2*Math.PI:q);let $=q-F;return h.startAngle=F,h.endAngle=q,h.deltaAngle=$,h}function J(e,t,l,a=0,n=!1){return a?(a=n?a/180*Math.PI:a,{x:t+(e.x-t)*Math.cos(a)-(e.y-l)*Math.sin(a),y:l+(e.x-t)*Math.sin(a)+(e.y-l)*Math.cos(a)}):e}function X(e,t,l,a,n,r=0,s=!0,i=!1){if(n=i?n*N/180:n,r=i?r*N/180:r,r=l!==a&&r!==2*N?r:0,s&&l!==a){let e=E(j(n=r?n-r:n)*(l/a));n=P(n)<0?e+N:e}let p=e+l*P(n),u=t+a*Q(n),h={x:p,y:u};return r&&(h.x=e+(p-e)*P(r)-(u-t)*Q(r),h.y=t+(p-e)*Q(r)+(u-t)*P(r)),h}function Y(e,t,l){if(t===l||e%N*.5==0)return e;let a=E(j(e)*(t/l));return a=P(e)<0?a+N:a,a}function G(e=null,t=[]){e||(e=t[0],t=t.slice(1,t.length));let l=t.length,a=t[l-1],n=t[0],r=3===l?t[1]:n,s=Math.min(e.y,a.y),i=Math.min(e.x,a.x),p=Math.max(e.x,a.x),u=Math.max(e.y,a.y);return!(n.y>=s&&n.y<=u&&r.y>=s&&r.y<=u&&n.x>=i&&n.x<=p&&r.x>=i&&r.x<=p)}function K(e,{addExtremes:t=!0,addSemiExtremes:l=!1}={}){let a=4===e.length?function(e,t,l,a,{addExtremes:n=!0,addSemiExtremes:r=!1}={}){const s=e=>{const t=Math.PI/4,l=Math.cos(t),a=Math.sin(t);return{x:e.x*l-e.y*a,y:e.x*a+e.y*l}};r&&(e=s(e),t=s(t),l=s(l),a=s(a));let[i,p,u,h,o,y,c,x]=[e.x,e.y,t.x,t.y,l.x,l.y,a.x,a.y],f=Math.min(e.y,a.y),g=Math.min(e.x,a.x),d=Math.max(e.x,a.x),v=Math.max(e.y,a.y);if(t.y>=f&&t.y<=v&&l.y>=f&&l.y<=v&&t.x>=g&&t.x<=d&&l.x>=g&&l.x<=d)return[];let m,M,b,A,C,w,E,L,k=[];for(let e=0;e<2;++e)if(0==e?(M=6*i-12*u+6*o,m=-3*i+9*u-9*o+3*c,b=3*u-3*i):(M=6*p-12*h+6*y,m=-3*p+9*h-9*y+3*x,b=3*h-3*p),Math.abs(m)<1e-8){if(Math.abs(M)<1e-8)continue;A=-b/M,0<A&&A<1&&k.push(A)}else E=M*M-4*b*m,E<0?Math.abs(E)<1e-8&&(A=-M/(2*m),0<A&&A<1&&k.push(A)):(L=Math.sqrt(E),C=(-M+L)/(2*m),0<C&&C<1&&k.push(C),w=(-M-L)/(2*m),0<w&&w<1&&k.push(w));let P=k.length;for(;P--;)A=k[P];return k}(e[0],e[1],e[2],e[3],{addExtremes:t,addSemiExtremes:l}):function(e,t,l,{addExtremes:a=!0,addSemiExtremes:n=!1}={}){const r=e=>{const t=-Math.PI/4,l=Math.cos(t),a=Math.sin(t);return{x:e.x*l-e.y*a,y:e.x*a+e.y*l}};n&&(e=r(e),t=r(t),l=r(l));let s,i,p,u=Math.min(e.y,l.y),h=Math.min(e.x,l.x),o=Math.max(e.x,l.x),y=Math.max(e.y,l.y);if(t.y>=u&&t.y<=y&&t.x>=h&&t.x<=o)return[];let[c,x,f,g,d,v]=[e.x,e.y,t.x,t.y,l.x,l.y],m=[];for(let e=0;e<2;++e)s=0==e?c-2*f+d:x-2*g+v,i=0==e?-2*c+2*f:-2*x+2*g,Math.abs(s)>1e-12&&(p=-i/(2*s),p>0&&p<1&&m.push(p));return m}(e[0],e[1],e[2],{addExtremes:t,addSemiExtremes:l});return a}function _(e,t){const l=(e,t,l,a,n,r)=>{var s=Math.cos(r),i=Math.sin(r),p=a*Math.cos(e),u=n*Math.sin(e);return{x:t+s*p-i*u,y:l+i*p+s*u}};let a,n,r,s,i,p=W(e.x,e.y,t[0],t[1],t[2],t[3],t[4],t[5],t[6]),{rx:u,ry:h,cx:o,cy:y,endAngle:c,deltaAngle:x}=p,f=t[2],g={x:t[5],y:t[6]},d=[g],v=f*Math.PI/180,m=Math.tan(v);i=Math.atan2(-h*m,u);let M=i,b=i+Math.PI,A=Math.atan2(h,u*m),C=A+Math.PI,w=[e.x,g.x],E=[e.y,g.y],L=Math.min(...w),k=Math.max(...w),P=Math.min(...E),S=Math.max(...E),I=l(c-.001*x,o,y,u,h,v),D=l(c-.999*x,o,y,u,h,v);return(I.x>k||D.x>k)&&(a=l(M,o,y,u,h,v),d.push(a)),(I.x<L||D.x<L)&&(n=l(b,o,y,u,h,v),d.push(n)),(I.y<P||D.y<P)&&(s=l(C,o,y,u,h,v),d.push(s)),(I.y>S||D.y>S)&&(r=l(A,o,y,u,h,v),d.push(r)),d}function ee(e=[],t=[]){let l=e.length,a=4===l;t.length||(t=[0]);let n=t.length,r=[];for(let s=0;s<n;s++){let n=t[s],i=n?[]:e.slice(0);if(n)for(let t=0;t<l;t++){let l=e[t];i.push(J(l,0,0,n))}let p=a?te(...i):le(...i);r.push(...p)}return r=[...new Set(r)].sort(),r}function te(e,t,l,a){if(!G(e,[t,l,a]))return[];let n,r,s,i,p,u,h,o,[y,c,x,f,g,d,v,m]=[e.x,e.y,t.x,t.y,l.x,l.y,a.x,a.y],M=[],b=1e-8;for(let e=0;e<2;++e)if(0==e?(r=6*y-12*x+6*g,n=-3*y+9*x-9*g+3*v,s=3*x-3*y):(r=6*c-12*f+6*d,n=-3*c+9*f-9*d+3*m,s=3*f-3*c),Math.abs(n)<b){if(Math.abs(r)<b)continue;i=-s/r,i>0&&i<1&&M.push(i)}else h=r*r-4*s*n,h<0?Math.abs(h)<b&&(i=-r/(2*n),i>0&&i<1&&M.push(i)):(o=Math.sqrt(h),p=(-r+o)/(2*n),p>0&&p<1&&M.push(p),u=(-r-o)/(2*n),u>0&&u<1&&M.push(u));let A=M.length;for(;A--;)i=M[A];return[...new Set(M)].sort()}function le(e,t,l){if(!G(e,[t,l]))return[];let a,n,r,[s,i,p,u,h,o]=[e.x,e.y,t.x,t.y,l.x,l.y],y=[];for(let e=0;e<2;++e)a=0==e?s-2*p+h:i-2*u+o,n=0==e?-2*s+2*p:-2*i+2*u,Math.abs(a)>1e-12&&(r=-n/(2*a),r>0&&r<1&&y.push(r));return[...new Set(y)].sort()}function ae(e,t=.001){let l=Math.PI/2,a=l/2;return!(Math.abs(e/l-Math.round(e/l))<t)&&Math.abs(e/a-Math.round(e/a))<t}function ne(e,t,l=!1){let a=l?t[0]-e[0]:t.x-e.x,n=l?t[1]-e[1]:t.y-e.y;return B(a*a+n*n)}function re(e,t){let l=t.x-e.x,a=t.y-e.y;return l*l+a*a}function se(e,t){return Math.abs(t.x-e.x)+Math.abs(t.y-e.y)}function ie(e,t){return.5*(Math.abs(t.x-e.x)+Math.abs(t.y-e.y))}function pe(e,t=48){if(!Array.isArray(e)||e.length<=t)return e;let l=e.length,a=l/t,n=[];for(let l=0;l<t;l++)n.push(e[Math.floor(l*a)]);let r=n.length;return n[r-1]!==e[l-1]&&(n[r-1]=e[l-1]),n}function ue(e){let t=[],l=[e[0]],a=e.length;for(let n=1;n<a;n++){let a=e[n];"M"!==a.type&&"m"!==a.type||(t.push(l),l=[]),l.push(a)}return l.length&&t.push(l),t}function he(e,t){let l,a,n,r,s,i,p=[],u=[],h=e[0],o=e[1],y=e[e.length-2],c=e[e.length-1];return 4===e.length?(l=U([h,o],t),a=U([o,y],t),n=U([y,c],t),r=U([l,a],t),s=U([a,n],t),i=U([r,s],t),p.push({x:h.x,y:h.y},{x:l.x,y:l.y},{x:r.x,y:r.y},{x:i.x,y:i.y}),u.push({x:i.x,y:i.y},{x:s.x,y:s.y},{x:n.x,y:n.y},{x:c.x,y:c.y})):3===e.length?(a=U([h,o],t),n=U([o,c],t),i=U([a,n],t),p.push({x:h.x,y:h.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=U([h,c],t),p.push({x:h.x,y:h.y},{x:a.x,y:a.y}),u.push({x:a.x,y:a.y},{x:c.x,y:c.y})),[p,u]}function oe(e,t,{tMin:l=0,tMax:a=1,addExtremes:n=!0,addSemiExtremes:r=!1}={}){let s=[],i=6===t.length?"C":"Q",p={x:t[0],y:t[1]},u="C"===i?{x:t[2],y:t[3]}:p,h={x:t[4],y:t[5]},o=0;let y="C"===i?[e,p,u,h]:[e,p,h],c=n?K(y,{addExtremes:n,addSemiExtremes:!1}):[],x=r?K(y,{addExtremes:n,addSemiExtremes:r}):[],f=Array.from(new Set([...c,...x])).sort();if(f=f.filter(e=>e>0&&e<1),f.length){let l=function(e,t,l,a=!0){let n=[];if(!l.length)return!1;let r,s,i,p=t.length,u={x:t[p-2],y:t[p-1]};2===t.length?i=[e,u]:4===t.length?(r={x:t[0],y:t[1]},i=[e,r,u]):6===t.length&&(r={x:t[0],y:t[1]},s={x:t[2],y:t[3]},i=[e,r,s,u]);if(l.length)if(1===l.length){let e=he(i,l[0]),t=e[0],a=e[1];n.push(t,a)}else{let e=l[0],t=he(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=he(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,f);s.push(...l),o+=l.length}else s.push({type:i,values:t});return{pathData:s,count:o}}function ye(e,{tMin:t=0,tMax:l=1,addExtremes:a=!0,addSemiExtremes:n=!1}={}){let r=[e[0]],s={x:e[0].values[0],y:e[0].values[1]},i={x:e[0].values[0],y:e[0].values[1]},p=e.length;for(let u=1;p&&u<p;u++){let p=e[u],{type:h,values:o}=p,y=o.slice(-2);if(y[0],y[1],"C"!==h&&"Q"!==h)r.push(p);else if((a||n)&&("C"===h||"Q"===h)){let e=oe(s,o,{tMin:t,tMax:l,addExtremes:a,addSemiExtremes:n}).pathData;r.push(...e)}s={x:y[0],y:y[1]},"z"===h.toLowerCase()?s=i:"M"===h&&(i={x:y[0],y:y[1]})}return r}function ce(e,t=-1){let l=e.map(e=>e.x),a=e.map(e=>e.y),n=Math.min(...l),r=Math.max(...l),s=Math.min(...a),i=Math.max(...a),p={x:n,left:n,right:r,y:s,top:s,bottom:i,width:r-n,height:i-s};if(t>-1)for(let e in p)p[e]=+p[e].toFixed(t);return p}function xe(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:r,values:s}=a,i={x:n.values[n.values.length-2],y:n.values[n.values.length-1]},p=s.length?{x:s[s.length-2],y:s[s.length-1]}:"",u=s.length?{x:s[0],y:s[1]}:"";switch(r){case"A":if("function"!=typeof arcToBezier){let e=ne(i,p)/2,l=H(i,p,.5),a=X(l.x,l.y,e,e,0),n=X(l.x,l.y,e,e,Math.PI);t.push(a,n,p);break}arcToBezier(i,s).forEach(e=>{let l=e.values,a={x:l[0],y:l[1]},n={x:l[2],y:l[3]},r={x:l[4],y:l[5]};t.push(a,n,r)});break;case"C":let e={x:s[2],y:s[3]};t.push(u,e);break;case"Q":t.push(u)}"z"!==r.toLowerCase()&&t.push(p)}return t}(e),l=ce(t);return l}(e);t.push(l)}),t}function fe(e,t){let[l,a,n,r,s,i]=[e.x,e.y,e.width,e.height,e.x+e.width,e.y+e.height],[p,u,h,o,y,c]=[t.x,t.y,t.width,t.height,t.x+t.width,t.y+t.height],x=!1;return n*r!=h*o&&n*r>h*o&&l<p&&s>y&&a<u&&i>c&&(x=!0),x}function ge(e,t=9){let l=0,a=[],n=ue(e),r=n.length>1,s=[];if(r){let e=xe(n);e.forEach(function(t,l){for(let l=0;l<e.length;l++){let a=e[l];if(t!=a){fe(t,a)&&s.push(l)}}})}return n.forEach((e,t)=>{a=[];let n=0,r=0,i=1,p=[];e.forEach(function(t,l){let[r,s]=[t.type,t.values],i=s.length;if(s.length){let u=(l>0?e[l-1]:e[0]).values,h=u.length,o={x:u[h-2],y:u[h-1]},y={x:s[i-2],y:s[i-1]};if("C"===r||"Q"===r){let e={x:s[0],y:s[1]};p="C"===r?[o,e,{x:s[2],y:s[3]},y]:[o,e,y];let t=Math.abs(function(e,t=!1){let l,[a,n,r,s]=[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},r={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-r.y+3*s.y)+n.x*(2*a.y-r.y-s.y)+r.x*(a.y+n.y-2*s.y)+s.x*(-3*a.y+n.y+2*r.y))/20,t?Math.abs(l):l}(p));n+=t,a.push(o,y)}else if("A"===r){let e=W(o.x,o.y,t.values[0],t.values[1],t.values[2],t.values[3],t.values[4],y.x,y.y),{cx:l,cy:r,rx:s,ry:i,startAngle:p,endAngle:u,deltaAngle:h}=e,c=Math.abs(function(e,t,l,a){const n=Math.PI*e*t;let r=(a-l+2*Math.PI)%(2*Math.PI);if(e===t)return n*(r/(2*Math.PI));const s=l=>Math.atan2(e*Math.sin(l),t*Math.cos(l));return l=s(l),a=s(a),r=(a-l+2*Math.PI)%(2*Math.PI),n*(r/(2*Math.PI))}(s,i,p,u));c-=Math.abs(de([o,{x:l,y:r},y])),a.push(o,y),n+=c}else a.push(o,y)}});let u=de(a);-1!==s.indexOf(t)&&(i=-1),r=u<0&&n<0?(Math.abs(n)-Math.abs(u))*i:(Math.abs(n)+Math.abs(u))*i,l+=r}),l}function de(e,t=!1){let l=0,a=e.length;for(let t=0;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 ve(e,t=0){t=parseFloat(t);let l=e.length,a=t>1,n=!a&&!t,r="",s=a?"\n":n?"":" ",i=n?"":" ";r=`${e[0].type}${i}${e[0].values.join(" ")}${s}`;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=n&&l.type===a.type&&"m"!==a.type.toLowerCase()||n&&"M"===l.type&&"L"===a.type?" ":a.type,n){let e="",t=!1;for(let l=0,a=u.length;l<a;l++){let a=u[l],n=a.toString(),r=n.includes(".")&&Math.abs(a)<1;r&&t&&(n=n.replace(/^0\./,".")),!(l>0)||t&&r||(e+=" "),e+=n,t=r}r+=`${p}${i}${e}${s}`}else r+=`${p}${i}${u.join(" ")}${s}`}return n&&(r=r.replace(/ 0\./g," .").replace(/ -/g,"-").replace(/-0\./g,"-.").replace(/Z/g,"z")),r}function me(l,a,n=0,r=1,s=!1){const i=(e,t,l,a,n)=>{let r=1-n;return{x:3*r*r*(t.x-e.x)+6*r*n*(l.x-t.x)+3*n*n*(a.x-l.x),y:3*r*r*(t.y-e.y)+6*r*n*(l.y-t.y)+3*n*n*(a.y-l.y)}};let p=[l,a],u=ie(l.p0,l.p)>ie(a.p0,a.p),h=JSON.parse(JSON.stringify(l)),o=JSON.parse(JSON.stringify(a)),y=O(h.p0,h.cp1,o.p,o.cp2,!1);if(!y)return p;if(u){let e={p0:{x:l.p.x,y:l.p.y},cp1:{x:l.cp2.x,y:l.cp2.y},cp2:{x:l.cp1.x,y:l.cp1.y},p:{x:l.p0.x,y:l.p0.y}};l={p0:{x:a.p.x,y:a.p.y},cp1:{x:a.cp2.x,y:a.cp2.y},cp2:{x:a.cp1.x,y:a.cp1.y},p:{x:a.p0.x,y:a.p0.y}},a=e}let c=(e,t)=>({x:e.x-t.x,y:e.y-t.y}),x=(e,t)=>({x:e.x*t,y:e.y*t}),f=(e,t)=>e.x*t.x+e.y*t.y,g=a.p0,d=i(a.p0,a.cp1,a.cp2,a.p,0),v=f(c(l.p0,g),d)/f(d,d),m=U([a.p0,a.cp1,a.cp2,a.p],v),M=i(a.p0,a.cp1,a.cp2,a.p,v);v-=f(c(m,l.p0),M)/f(M,M);let b=U([a.p0,a.cp1,a.cp2,a.p],v),A=a.p,C=i(a.p0,a.cp1,a.cp2,a.p,v),w=i(a.p0,a.cp1,a.cp2,a.p,1),E=1-v,L=(k=b,P=x(C,E/3),{x:k.x+P.x,y:k.y+P.y});var k,P;let S=c(A,x(w,E/3)),I={p0:b,cp1:L,cp2:S,p:A,t0:v};u&&(I={p0:A,cp1:S,cp2:L,p:b,t0:v});let D=.5*(1-v),F=U([I.p0,I.cp1,I.cp2,I.p],D,!1,!0),q=F.cpts[2],$=O(F,q,I.p0,y,!1),z=O(F,q,I.p,y,!1),T=H(I.p0,$,1.333),Q=H(I.p,z,1.333);if(O(h.p0,T,o.p,Q,!0))return p;s&&e(markers,F,"purple"),I.cp1=T,I.cp2=Q;let B=ie(h.p0,I.p0)+ie(o.p,I.p);if(I.p0=h.p0,I.p=o.p,I.extreme=o.extreme,I.corner=o.corner,I.dimA=o.dimA,I.directionChange=o.directionChange,I.type="C",I.values=[I.cp1.x,I.cp1.y,I.cp2.x,I.cp2.y,I.p.x,I.p.y],B<n){let e=u?1+v:Math.abs(v),a=1+Math.abs(v);if(e=u?1+v:Math.abs(v)/a,ie(U([I.p0,I.cp1,I.cp2,I.p],e),l.p)>n*r)return p;let i=ge([{type:"M",values:[h.p0.x,h.p0.y]},{type:"C",values:[h.cp1.x,h.cp1.y,h.cp2.x,h.cp2.y,h.p.x,h.p.y]},{type:"C",values:[o.cp1.x,o.cp1.y,o.cp2.x,o.cp2.y,o.p.x,o.p.y]}]),y=[{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]}],c=ge(y),x=Math.abs(c/i-1);if(I.error=5*x*r,s){let e=ve(y);t(markers,e,"orange")}x<.05*r&&(p=[I])}return p}function Me(e,{keepExtremes:t=!0,keepInflections:l=!0,keepCorners:a=!0,extrapolateDominant:n=!0,tolerance:r=1}={}){let s=[e[0]],i=e.length;for(let n=2;i&&n<=i;n++){let p=e[n-1],u=n<i?e[n]:null,h=u?.type||null,{type:o,values:y,p0:c,p:x,cp1:f=null,cp2:g=null,extreme:d=!1,directionChange:v=!1,corner:m=!1,dimA:M=0}=p;if("C"===o&&"C"===h)if(a&&m||t&&d)s.push(p);else{let h=be(p,u,{tolerance:r}),o=0;
1
+ function e(e,t,l="red",a="1%",n="1",r="",s=!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>${r}</title></circle>`;if(!s)return u;e.insertAdjacentHTML("beforeend",u)}function t(e,t="",l="green",a="1%",n="1",r=!0){let s=`<path d="${t}" fill="none" stroke="${l}" stroke-width="${a}" stroke-opacity="${n}" /> `;if(!r)return s;e.insertAdjacentHTML("beforeend",s)}const{abs:l,acos:a,asin:n,atan:r,atan2:s,ceil:i,cos:p,exp:u,floor:h,log:o,hypot:y,max:c,min:x,pow:f,random:g,round:d,sin:v,sqrt:m,tan:M,PI:b}=Math,{abs:A,acos:C,asin:w,atan:E,atan2:L,ceil:k,cos:S,exp:P,floor:I,log:D,max:F,min:q,pow:$,random:z,round:T,sin:Q,sqrt:B,tan:j,PI:N}=Math;function Z(e,t,l=!1){let a=L(t.y-e.y,t.x-e.x);return l&&a<0&&(a+=2*Math.PI),a}function R(e,t,l,a=!1){let n=Math.atan2(t.y-e.y,t.x-e.x),r=Math.atan2(l.y-e.y,l.x-e.x),s=r-n;s=(e=>{let t=e%(2*Math.PI);return t>Math.PI?t-=2*Math.PI:t<=-Math.PI&&(t+=2*Math.PI),t})(s),a&&(s=2*Math.PI-Math.abs(s));let i=180/Math.PI;return{startAngle:n,endAngle:r,deltaAngle:s,startAngleDeg:n*i,endAngleDeg:r*i,deltaAngleDeg:s*i}}function O(e=null,t=null,l=null,a=null,n=!0,r=!1){let s,i,p,u,h,o={};if(!(e&&t&&l&&a))return r&&console.warn("points missing"),!1;try{if(s=(a.y-l.y)*(t.x-e.x)-(a.x-l.x)*(t.y-e.y),0==s)return!1}catch{return r&&console.warn("!catch",e,t,"p3:",l,"p4:",a),!1}i=e.y-l.y,p=e.x-l.x,u=(a.x-l.x)*i-(a.y-l.y)*p,h=(t.x-e.x)*i-(t.y-e.y)*p,i=u/s,p=h/s,o={x:e.x+i*(t.x-e.x),y:e.y+i*(t.y-e.y)};let y=!1;return i>0&&i<1&&p>0&&p<1&&(y=!0),!(n&&!y)&&o}function H(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=Z(e,t),n.angle<0&&(n.angle+=2*N)),n}function U(e,t=.5,l=!1,a=!1,n=!1){let r;return Array.isArray(e[0])&&(e=e.map(e=>({x:e[0],y:e[1]})),n=!0),r=e.length>2?((e,t,l=!1)=>{let n=4===e.length,r=e[0],s=e[1],i=n?e[2]:e[1],p=e[e.length-1],u={x:0,y:0};if(l||a){let e,l,h,o,y,c=r.x===s.x&&r.y===s.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=H(r,s,t),n?(l=H(s,i,t),h=H(i,p,t),o=H(e,l,t),y=H(l,h,t),u=H(o,y,t),u.angle=Z(o,y),a&&(u.cpts=[l,h,o,y])):(l=H(r,s,t),h=H(s,p,t),u=H(l,h,t),u.angle=Z(l,h),a&&(u.cpts=[l,h]))):(u.x=p.x,u.y=p.y,u.angle=Z(i,p)):(u.x=r.x,u.y=r.y,u.angle=Z(r,s))}else{let e=1-t;u=n?{x:e**3*r.x+3*e**2*t*s.x+3*e*t**2*i.x+t**3*p.x,y:e**3*r.y+3*e**2*t*s.y+3*e*t**2*i.y+t**3*p.y}:{x:e*e*r.x+2*e*t*s.x+t**2*p.x,y:e*e*r.y+2*e*t*s.y+t**2*p.y}}return u})(e,t,l):H(e[0],e[1],t,l),l&&r.angle<0&&(r.angle+=2*N),n?[r.x,r.y]:r}function V(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}function W(e,t,l,a,n,r,s,i,p){const u=(e,t,l,a)=>L(a-t,l-e);let h={cx:0,cy:0,rx:l=A(l),ry:a=A(a),startAngle:0,endAngle:0,deltaAngle:0,clockwise:s,xAxisRotation:n,largeArc:r,sweep:s};if(0==l||0==a)throw Error("rx and ry can not be 0");if(l===a){let l=Math.abs(i-e),a=Math.abs(p-t),n=l,r=Math.min(e,i),u=Math.min(t,p),o=.5*Math.PI;if(0===l&&a||0===a&&l)return n=0===l&&a?a/2:l/2,h.rx=n,h.ry=n,0===l&&a?(h.cx=e,h.cy=u+a/2,h.startAngle=t>p?o:-o,h.endAngle=t>p?-o:o,h.deltaAngle=s?Math.PI:-Math.PI):0===a&&l&&(h.cx=r+l/2,h.cy=t,h.startAngle=e>i?Math.PI:0,h.endAngle=e>i?-Math.PI:Math.PI,h.deltaAngle=s?Math.PI:-Math.PI),h}let o,y,c=l===a?0:n*N/180,x=c?Math.sin(c):0,f=c?Math.cos(c):1,g=(e-i)/2,d=(t-p)/2,v=(e+i)/2,m=(t+p)/2,M=c?f*g+x*d:g,b=c?f*d-x*g:d,C=M*M/(l*l)+b*b/(a*a);C>1&&(l*=Math.sqrt(C),a*=Math.sqrt(C),h.rx=l,h.ry=a);let w=l*a,E=l*b,k=a*M,S=E**2+k**2;if(!S)throw Error("start point can not be same as end point");let P=Math.sqrt(Math.abs((w*w-S)/S));r==s&&(P=-P);let I=P*E/a,D=-P*k/l;o=c?f*I-x*D+v:v+I,y=c?x*I+f*D+m:m+D,h.cy=y,h.cx=o;let F=u(o,y,e,t),q=u(o,y,i,p);!s&&q>F&&(q-=2*Math.PI),s&&F>q&&(q=q<=0?q+2*Math.PI:q);let $=q-F;return h.startAngle=F,h.endAngle=q,h.deltaAngle=$,h}function J(e,t,l,a=0,n=!1){return a?(a=n?a/180*Math.PI:a,{x:t+(e.x-t)*Math.cos(a)-(e.y-l)*Math.sin(a),y:l+(e.x-t)*Math.sin(a)+(e.y-l)*Math.cos(a)}):e}function X(e,t,l,a,n,r=0,s=!0,i=!1){if(n=i?n*N/180:n,r=i?r*N/180:r,r=l!==a&&r!==2*N?r:0,s&&l!==a){let e=E(j(n=r?n-r:n)*(l/a));n=S(n)<0?e+N:e}let p=e+l*S(n),u=t+a*Q(n),h={x:p,y:u};return r&&(h.x=e+(p-e)*S(r)-(u-t)*Q(r),h.y=t+(p-e)*Q(r)+(u-t)*S(r)),h}function Y(e,t,l){if(t===l||e%N*.5==0)return e;let a=E(j(e)*(t/l));return a=S(e)<0?a+N:a,a}function G(e=null,t=[]){e||(e=t[0],t=t.slice(1,t.length));let l=t.length,a=t[l-1],n=t[0],r=3===l?t[1]:n,s=Math.min(e.y,a.y),i=Math.min(e.x,a.x),p=Math.max(e.x,a.x),u=Math.max(e.y,a.y);return!(n.y>=s&&n.y<=u&&r.y>=s&&r.y<=u&&n.x>=i&&n.x<=p&&r.x>=i&&r.x<=p)}function K(e,{addExtremes:t=!0,addSemiExtremes:l=!1}={}){let a=4===e.length?function(e,t,l,a,{addExtremes:n=!0,addSemiExtremes:r=!1}={}){const s=e=>{const t=Math.PI/4,l=Math.cos(t),a=Math.sin(t);return{x:e.x*l-e.y*a,y:e.x*a+e.y*l}};r&&(e=s(e),t=s(t),l=s(l),a=s(a));let[i,p,u,h,o,y,c,x]=[e.x,e.y,t.x,t.y,l.x,l.y,a.x,a.y],f=Math.min(e.y,a.y),g=Math.min(e.x,a.x),d=Math.max(e.x,a.x),v=Math.max(e.y,a.y);if(t.y>=f&&t.y<=v&&l.y>=f&&l.y<=v&&t.x>=g&&t.x<=d&&l.x>=g&&l.x<=d)return[];let m,M,b,A,C,w,E,L,k=[];for(let e=0;e<2;++e)if(0==e?(M=6*i-12*u+6*o,m=-3*i+9*u-9*o+3*c,b=3*u-3*i):(M=6*p-12*h+6*y,m=-3*p+9*h-9*y+3*x,b=3*h-3*p),Math.abs(m)<1e-8){if(Math.abs(M)<1e-8)continue;A=-b/M,0<A&&A<1&&k.push(A)}else E=M*M-4*b*m,E<0?Math.abs(E)<1e-8&&(A=-M/(2*m),0<A&&A<1&&k.push(A)):(L=Math.sqrt(E),C=(-M+L)/(2*m),0<C&&C<1&&k.push(C),w=(-M-L)/(2*m),0<w&&w<1&&k.push(w));let S=k.length;for(;S--;)A=k[S];return k}(e[0],e[1],e[2],e[3],{addExtremes:t,addSemiExtremes:l}):function(e,t,l,{addExtremes:a=!0,addSemiExtremes:n=!1}={}){const r=e=>{const t=-Math.PI/4,l=Math.cos(t),a=Math.sin(t);return{x:e.x*l-e.y*a,y:e.x*a+e.y*l}};n&&(e=r(e),t=r(t),l=r(l));let s,i,p,u=Math.min(e.y,l.y),h=Math.min(e.x,l.x),o=Math.max(e.x,l.x),y=Math.max(e.y,l.y);if(t.y>=u&&t.y<=y&&t.x>=h&&t.x<=o)return[];let[c,x,f,g,d,v]=[e.x,e.y,t.x,t.y,l.x,l.y],m=[];for(let e=0;e<2;++e)s=0==e?c-2*f+d:x-2*g+v,i=0==e?-2*c+2*f:-2*x+2*g,Math.abs(s)>1e-12&&(p=-i/(2*s),p>0&&p<1&&m.push(p));return m}(e[0],e[1],e[2],{addExtremes:t,addSemiExtremes:l});return a}function _(e,t){const l=(e,t,l,a,n,r)=>{var s=Math.cos(r),i=Math.sin(r),p=a*Math.cos(e),u=n*Math.sin(e);return{x:t+s*p-i*u,y:l+i*p+s*u}};let a,n,r,s,i,p=W(e.x,e.y,t[0],t[1],t[2],t[3],t[4],t[5],t[6]),{rx:u,ry:h,cx:o,cy:y,endAngle:c,deltaAngle:x}=p,f=t[2],g={x:t[5],y:t[6]},d=[g],v=f*Math.PI/180,m=Math.tan(v);i=Math.atan2(-h*m,u);let M=i,b=i+Math.PI,A=Math.atan2(h,u*m),C=A+Math.PI,w=[e.x,g.x],E=[e.y,g.y],L=Math.min(...w),k=Math.max(...w),S=Math.min(...E),P=Math.max(...E),I=l(c-.001*x,o,y,u,h,v),D=l(c-.999*x,o,y,u,h,v);return(I.x>k||D.x>k)&&(a=l(M,o,y,u,h,v),d.push(a)),(I.x<L||D.x<L)&&(n=l(b,o,y,u,h,v),d.push(n)),(I.y<S||D.y<S)&&(s=l(C,o,y,u,h,v),d.push(s)),(I.y>P||D.y>P)&&(r=l(A,o,y,u,h,v),d.push(r)),d}function ee(e=[],t=[]){let l=e.length,a=4===l;t.length||(t=[0]);let n=t.length,r=[];for(let s=0;s<n;s++){let n=t[s],i=n?[]:e.slice(0);if(n)for(let t=0;t<l;t++){let l=e[t];i.push(J(l,0,0,n))}let p=a?te(...i):le(...i);r.push(...p)}return r=[...new Set(r)].sort(),r}function te(e,t,l,a){if(!G(e,[t,l,a]))return[];let n,r,s,i,p,u,h,o,[y,c,x,f,g,d,v,m]=[e.x,e.y,t.x,t.y,l.x,l.y,a.x,a.y],M=[],b=1e-8;for(let e=0;e<2;++e)if(0==e?(r=6*y-12*x+6*g,n=-3*y+9*x-9*g+3*v,s=3*x-3*y):(r=6*c-12*f+6*d,n=-3*c+9*f-9*d+3*m,s=3*f-3*c),Math.abs(n)<b){if(Math.abs(r)<b)continue;i=-s/r,i>0&&i<1&&M.push(i)}else h=r*r-4*s*n,h<0?Math.abs(h)<b&&(i=-r/(2*n),i>0&&i<1&&M.push(i)):(o=Math.sqrt(h),p=(-r+o)/(2*n),p>0&&p<1&&M.push(p),u=(-r-o)/(2*n),u>0&&u<1&&M.push(u));let A=M.length;for(;A--;)i=M[A];return[...new Set(M)].sort()}function le(e,t,l){if(!G(e,[t,l]))return[];let a,n,r,[s,i,p,u,h,o]=[e.x,e.y,t.x,t.y,l.x,l.y],y=[];for(let e=0;e<2;++e)a=0==e?s-2*p+h:i-2*u+o,n=0==e?-2*s+2*p:-2*i+2*u,Math.abs(a)>1e-12&&(r=-n/(2*a),r>0&&r<1&&y.push(r));return[...new Set(y)].sort()}function ae(e,t=.001){let l=Math.PI/2,a=l/2;return!(Math.abs(e/l-Math.round(e/l))<t)&&Math.abs(e/a-Math.round(e/a))<t}function ne(e,t,l=!1){let a=l?t[0]-e[0]:t.x-e.x,n=l?t[1]-e[1]:t.y-e.y;return B(a*a+n*n)}function re(e,t){let l=t.x-e.x,a=t.y-e.y;return l*l+a*a}function se(e,t){return Math.abs(t.x-e.x)+Math.abs(t.y-e.y)}function ie(e,t){return.5*(Math.abs(t.x-e.x)+Math.abs(t.y-e.y))}function pe(e,t=48){if(!Array.isArray(e)||e.length<=t)return e;let l=e.length,a=l/t,n=[];for(let l=0;l<t;l++)n.push(e[Math.floor(l*a)]);let r=n.length;return n[r-1]!==e[l-1]&&(n[r-1]=e[l-1]),n}function ue(e){let t=[],l=[e[0]],a=e.length;for(let n=1;n<a;n++){let a=e[n];"M"!==a.type&&"m"!==a.type||(t.push(l),l=[]),l.push(a)}return l.length&&t.push(l),t}function he(e,t){let l,a,n,r,s,i,p=[],u=[],h=e[0],o=e[1],y=e[e.length-2],c=e[e.length-1];return 4===e.length?(l=U([h,o],t),a=U([o,y],t),n=U([y,c],t),r=U([l,a],t),s=U([a,n],t),i=U([r,s],t),p.push({x:h.x,y:h.y},{x:l.x,y:l.y},{x:r.x,y:r.y},{x:i.x,y:i.y}),u.push({x:i.x,y:i.y},{x:s.x,y:s.y},{x:n.x,y:n.y},{x:c.x,y:c.y})):3===e.length?(a=U([h,o],t),n=U([o,c],t),i=U([a,n],t),p.push({x:h.x,y:h.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=U([h,c],t),p.push({x:h.x,y:h.y},{x:a.x,y:a.y}),u.push({x:a.x,y:a.y},{x:c.x,y:c.y})),[p,u]}function oe(e,t,{tMin:l=0,tMax:a=1,addExtremes:n=!0,addSemiExtremes:r=!1}={}){let s=[],i=6===t.length?"C":"Q",p={x:t[0],y:t[1]},u="C"===i?{x:t[2],y:t[3]}:p,h={x:t[4],y:t[5]},o=0;let y="C"===i?[e,p,u,h]:[e,p,h],c=n?K(y,{addExtremes:n,addSemiExtremes:!1}):[],x=r?K(y,{addExtremes:n,addSemiExtremes:r}):[],f=Array.from(new Set([...c,...x])).sort();if(f=f.filter(e=>e>0&&e<1),f.length){let l=function(e,t,l,a=!0){let n=[];if(!l.length)return!1;let r,s,i,p=t.length,u={x:t[p-2],y:t[p-1]};2===t.length?i=[e,u]:4===t.length?(r={x:t[0],y:t[1]},i=[e,r,u]):6===t.length&&(r={x:t[0],y:t[1]},s={x:t[2],y:t[3]},i=[e,r,s,u]);if(l.length)if(1===l.length){let e=he(i,l[0]),t=e[0],a=e[1];n.push(t,a)}else{let e=l[0],t=he(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=he(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,f);s.push(...l),o+=l.length}else s.push({type:i,values:t});return{pathData:s,count:o}}function ye(e,{tMin:t=0,tMax:l=1,addExtremes:a=!0,addSemiExtremes:n=!1}={}){let r=[e[0]],s={x:e[0].values[0],y:e[0].values[1]},i={x:e[0].values[0],y:e[0].values[1]},p=e.length;for(let u=1;p&&u<p;u++){let p=e[u],{type:h,values:o}=p,y=o.slice(-2);if(y[0],y[1],"C"!==h&&"Q"!==h)r.push(p);else if((a||n)&&("C"===h||"Q"===h)){let e=oe(s,o,{tMin:t,tMax:l,addExtremes:a,addSemiExtremes:n}).pathData;r.push(...e)}s={x:y[0],y:y[1]},"z"===h.toLowerCase()?s=i:"M"===h&&(i={x:y[0],y:y[1]})}return r}function ce(e,t=-1){let l=e.map(e=>e.x),a=e.map(e=>e.y),n=Math.min(...l),r=Math.max(...l),s=Math.min(...a),i=Math.max(...a),p={x:n,left:n,right:r,y:s,top:s,bottom:i,width:r-n,height:i-s};if(t>-1)for(let e in p)p[e]=+p[e].toFixed(t);return p}function xe(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:r,values:s}=a,i={x:n.values[n.values.length-2],y:n.values[n.values.length-1]},p=s.length?{x:s[s.length-2],y:s[s.length-1]}:"",u=s.length?{x:s[0],y:s[1]}:"";switch(r){case"A":if("function"!=typeof arcToBezier){let e=ne(i,p)/2,l=H(i,p,.5),a=X(l.x,l.y,e,e,0),n=X(l.x,l.y,e,e,Math.PI);t.push(a,n,p);break}arcToBezier(i,s).forEach(e=>{let l=e.values,a={x:l[0],y:l[1]},n={x:l[2],y:l[3]},r={x:l[4],y:l[5]};t.push(a,n,r)});break;case"C":let e={x:s[2],y:s[3]};t.push(u,e);break;case"Q":t.push(u)}"z"!==r.toLowerCase()&&t.push(p)}return t}(e),l=ce(t);return l}(e);t.push(l)}),t}function fe(e,t){let[l,a,n,r,s,i]=[e.x,e.y,e.width,e.height,e.x+e.width,e.y+e.height],[p,u,h,o,y,c]=[t.x,t.y,t.width,t.height,t.x+t.width,t.y+t.height],x=!1;return n*r!=h*o&&n*r>h*o&&l<p&&s>y&&a<u&&i>c&&(x=!0),x}function ge(e,t=9){let l=0,a=[],n=ue(e),r=n.length>1,s=[];if(r){let e=xe(n);e.forEach(function(t,l){for(let l=0;l<e.length;l++){let a=e[l];if(t!=a){fe(t,a)&&s.push(l)}}})}return n.forEach((e,t)=>{a=[];let n=0,r=0,i=1,p=[];e.forEach(function(t,l){let[r,s]=[t.type,t.values],i=s.length;if(s.length){let u=(l>0?e[l-1]:e[0]).values,h=u.length,o={x:u[h-2],y:u[h-1]},y={x:s[i-2],y:s[i-1]};if("C"===r||"Q"===r){let e={x:s[0],y:s[1]};p="C"===r?[o,e,{x:s[2],y:s[3]},y]:[o,e,y];let t=Math.abs(function(e,t=!1){let l,[a,n,r,s]=[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},r={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-r.y+3*s.y)+n.x*(2*a.y-r.y-s.y)+r.x*(a.y+n.y-2*s.y)+s.x*(-3*a.y+n.y+2*r.y))/20,t?Math.abs(l):l}(p));n+=t,a.push(o,y)}else if("A"===r){let e=W(o.x,o.y,t.values[0],t.values[1],t.values[2],t.values[3],t.values[4],y.x,y.y),{cx:l,cy:r,rx:s,ry:i,startAngle:p,endAngle:u,deltaAngle:h}=e,c=Math.abs(function(e,t,l,a){const n=Math.PI*e*t;let r=(a-l+2*Math.PI)%(2*Math.PI);if(e===t)return n*(r/(2*Math.PI));const s=l=>Math.atan2(e*Math.sin(l),t*Math.cos(l));return l=s(l),a=s(a),r=(a-l+2*Math.PI)%(2*Math.PI),n*(r/(2*Math.PI))}(s,i,p,u));c-=Math.abs(de([o,{x:l,y:r},y])),a.push(o,y),n+=c}else a.push(o,y)}});let u=de(a);-1!==s.indexOf(t)&&(i=-1),r=u<0&&n<0?(Math.abs(n)-Math.abs(u))*i:(Math.abs(n)+Math.abs(u))*i,l+=r}),l}function de(e,t=!1){let l=0,a=e.length;for(let t=0;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 ve(e,t=0){t=parseFloat(t);let l=e.length,a=t>1,n=!a&&!t,r="",s=a?"\n":n?"":" ",i=n?"":" ";r=`${e[0].type}${i}${e[0].values.join(" ")}${s}`;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=n&&l.type===a.type&&"m"!==a.type.toLowerCase()||n&&"M"===l.type&&"L"===a.type?" ":a.type,n){let e="",t=!1;for(let l=0,a=u.length;l<a;l++){let a=u[l],n=a.toString(),r=n.includes(".")&&Math.abs(a)<1;r&&t&&(n=n.replace(/^0\./,".")),!(l>0)||t&&r||(e+=" "),e+=n,t=r}r+=`${p}${i}${e}${s}`}else r+=`${p}${i}${u.join(" ")}${s}`}return n&&(r=r.replace(/ 0\./g," .").replace(/ -/g,"-").replace(/-0\./g,"-.").replace(/Z/g,"z")),r}function me(l,a,n=0,r=1,s=!1){const i=(e,t,l,a,n)=>{let r=1-n;return{x:3*r*r*(t.x-e.x)+6*r*n*(l.x-t.x)+3*n*n*(a.x-l.x),y:3*r*r*(t.y-e.y)+6*r*n*(l.y-t.y)+3*n*n*(a.y-l.y)}};let p=[l,a],u=ie(l.p0,l.p)>ie(a.p0,a.p),h=JSON.parse(JSON.stringify(l)),o=JSON.parse(JSON.stringify(a)),y=O(h.p0,h.cp1,o.p,o.cp2,!1);if(!y)return p;if(u){let e={p0:{x:l.p.x,y:l.p.y},cp1:{x:l.cp2.x,y:l.cp2.y},cp2:{x:l.cp1.x,y:l.cp1.y},p:{x:l.p0.x,y:l.p0.y}};l={p0:{x:a.p.x,y:a.p.y},cp1:{x:a.cp2.x,y:a.cp2.y},cp2:{x:a.cp1.x,y:a.cp1.y},p:{x:a.p0.x,y:a.p0.y}},a=e}let c=(e,t)=>({x:e.x-t.x,y:e.y-t.y}),x=(e,t)=>({x:e.x*t,y:e.y*t}),f=(e,t)=>e.x*t.x+e.y*t.y,g=a.p0,d=i(a.p0,a.cp1,a.cp2,a.p,0),v=f(c(l.p0,g),d)/f(d,d),m=U([a.p0,a.cp1,a.cp2,a.p],v),M=i(a.p0,a.cp1,a.cp2,a.p,v);v-=f(c(m,l.p0),M)/f(M,M);let b=U([a.p0,a.cp1,a.cp2,a.p],v),A=a.p,C=i(a.p0,a.cp1,a.cp2,a.p,v),w=i(a.p0,a.cp1,a.cp2,a.p,1),E=1-v,L=(k=b,S=x(C,E/3),{x:k.x+S.x,y:k.y+S.y});var k,S;let P=c(A,x(w,E/3)),I={p0:b,cp1:L,cp2:P,p:A,t0:v};u&&(I={p0:A,cp1:P,cp2:L,p:b,t0:v});let D=.5*(1-v),F=U([I.p0,I.cp1,I.cp2,I.p],D,!1,!0),q=F.cpts[2],$=O(F,q,I.p0,y,!1),z=O(F,q,I.p,y,!1),T=H(I.p0,$,1.333),Q=H(I.p,z,1.333);if(O(h.p0,T,o.p,Q,!0))return p;s&&e(markers,F,"purple"),I.cp1=T,I.cp2=Q;let B=ie(h.p0,I.p0)+ie(o.p,I.p);if(I.p0=h.p0,I.p=o.p,I.extreme=o.extreme,I.corner=o.corner,I.dimA=o.dimA,I.directionChange=o.directionChange,I.type="C",I.values=[I.cp1.x,I.cp1.y,I.cp2.x,I.cp2.y,I.p.x,I.p.y],B<n){let e=u?1+v:Math.abs(v),a=1+Math.abs(v);if(e=u?1+v:Math.abs(v)/a,ie(U([I.p0,I.cp1,I.cp2,I.p],e),l.p)>n*r)return p;let i=ge([{type:"M",values:[h.p0.x,h.p0.y]},{type:"C",values:[h.cp1.x,h.cp1.y,h.cp2.x,h.cp2.y,h.p.x,h.p.y]},{type:"C",values:[o.cp1.x,o.cp1.y,o.cp2.x,o.cp2.y,o.p.x,o.p.y]}]),y=[{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]}],c=ge(y),x=Math.abs(c/i-1);if(I.error=5*x*r,s){let e=ve(y);t(markers,e,"orange")}x<.05*r&&(p=[I])}return p}function Me(e,{keepExtremes:t=!0,keepInflections:l=!0,keepCorners:a=!0,extrapolateDominant:n=!0,tolerance:r=1}={}){let s=[e[0]],i=e.length;for(let n=2;i&&n<=i;n++){let p=e[n-1],u=n<i?e[n]:null,h=u?.type||null,{type:o,values:y,p0:c,p:x,cp1:f=null,cp2:g=null,extreme:d=!1,directionChange:v=!1,corner:m=!1,dimA:M=0}=p;if("C"===o&&"C"===h)if(a&&m||t&&d)s.push(p);else{let h=be(p,u,{tolerance:r}),o=0;
2
2
  //!count simplification success or failure - just for debugging
3
3
  if(1===h.length){p=h[0];let u=1;o+=p.error;
4
4
  //!log.push(`success1: ${i} and ${i + 1}`)
@@ -6,8 +6,6 @@ for(let s=n+1;o<r&&s<i;s++){let n=e[s];if("C"!==n.type||l&&p.directionChange||a&
6
6
  //!log.push(`success2: ${i} and ${n}`)
7
7
  p=i[0]}s.push(p),n<i&&(n+=u)}else s.push(p)}else s.push(p)}return s}function be(e,t,{tolerance:l=1}={}){let a=[e,t],n=function(e,t){let l=se(e.cp2,e.p);if(0===l)return 0;let a=se(e.p,t.cp1);if(0===a)return 0;let n=se(e.cp2,t.cp1);return l/n}(e,t);if(!n)return a;let r=se(e.p0,e.p),s=se(t.p0,t.p),i=.08*Math.max(0,Math.min(r,s))*l,p=function(e,t,l=0){let{p0:a,cp1:n}=e,{p:r,cp2:s}=t;return n={x:(n.x-(1-l)*a.x)/l,y:(n.y-(1-l)*a.y)/l},s={x:(s.x-l*r.x)/(1-l),y:(s.y-l*r.y)/(1-l)},{p0:a,cp1:n,cp2:s,p:r}}(e,t,n),u=U([p.p0,p.cp1,p.cp2,p.p],n),h=se(e.p,u),o=0,y=0,c=!1,x=h;if(h<i){let l=.5*(1+n);if(o=se(U([t.p0,t.cp1,t.cp2,t.p],.5),U([p.p0,p.cp1,p.cp2,p.p],l)),x+=o,o<i){let t=.5*n;y=se(U([e.p0,e.cp1,e.cp2,e.p],.5),U([p.p0,p.cp1,p.cp2,p.p],t)),x+=y,x<i&&(c=!0)}}return c&&(p.p0=e.p0,p.p=t.p,p.dimA=se(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=x/i,a=[p]),a}function Ae(e,{tolerance:t=1,debug:l=!1}={}){let a=!1,n={flat:!0,steepness:0},r=e[0],s=e[e.length-1],i=new Set([...e.map(e=>+e.x.toFixed(8))]),p=new Set([...e.map(e=>+e.y.toFixed(8))]);if(1===i.size||1===p.size)return!l||n;let u=re(r,s),h=u/1e3*t,o=de(e,!0);return o<h&&(a=!0),l&&(n.flat=a,n.steepness=o/u*10),l?n:a}function Ce(e){let t=[];for(let l=1,a=e.length;l<a;l++){let a=e[l],{type:n,values:r,p0:s=null,p:i=null,dimA:p=0}=a;r.length&&i&&s&&(p=p||se(s,i),p&&t.push(p))}let l=t.sort(),a=Math.ceil(l.length/8);l=l.slice(0,a);let n=l.reduce((e,t)=>e+t,0)/a,r=n>112.5?0:Math.floor(75/n).toString().length;return Math.min(Math.max(0,r),8)}function we(e=0,t=3){if(!t)return Math.round(e);let l=10**t;return Math.round(e*l)/l}function Ee(e,t=-1){if(t<0)return e;let l=e.length;for(let a=0;a<l;a++){let l=e[a].values,n=l.length;if(n)for(let r=0;r<n;r++)e[a].values[r]=we(l[r],t)}return e}function Le(t=[],{detectExtremes:l=!0,detectCorners:a=!0,detectDirection:n=!0,detectSemiExtremes:r=!1,debug:s=!1,addSquareLength:i=!0,addArea:p=!0}={}){t=function(e,{addSquareLength:t=!0,addArea:l=!1,addArcParams:a=!1,addAverageDim:n=!0}={}){let r=e[0],s={x:r.values[0],y:r.values[1]},i=s,p=s;r.p0=i,r.p=p,r.idx=0,r.dimA=0;let u=e.length,h=[r];for(let a=1;a<u;a++){let n,r,u=e[a],{type:o,values:y}=u,c=y.length;if(p=c?{x:y[c-2],y:y[c-1]}:s,u.p0=i,u.p=p,u.dimA=se(i,p),"M"===o&&(s=p),"Q"===o||"C"===o)n={x:y[0],y:y[1]},r="C"===o?{x:y[2],y:y[3]}:null,u.cp1=n,r&&(u.cp2=r);else if("A"===o){let{rx:e,ry:t,cx:l,cy:a,startAngle:n,endAngle:r,deltaAngle:s}=W(i.x,i.y,...y);u.cx=l,u.cy=a,u.rx=e,u.ry=t,u.xAxisRotation=y[2]/180*Math.PI,u.largeArc=y[3],u.sweep=y[4],u.startAngle=n,u.endAngle=r,u.deltaAngle=s}if("Z"===o&&s.x!==p.x&&s.y!==p.y&&(u.closePath=!0),t&&(u.squareDist=re(i,p)),l){let e=0;"C"===o&&(e=de([i,n,r,p],!1)),"Q"===o&&(e=de([i,n,p],!1)),u.cptArea=e}u.idx=a,i=p,h.push(u)}return h}(t,{addSquareLength:i,addArea:p});let u=[],h=ce(V(t)),{left:o,right:y,top:c,bottom:x,width:f,height:g}=h;t[0].corner=!1,t[0].extreme=!1,t[0].semiExtreme=!1,t[0].directionChange=!1,t[0].closePath=!1;let d=[t[0]],v=t.length;for(let l=2;v&&l<=v;l++){let a=t[l-1],{type:n,values:i,p0:p,p:u,cp1:h=null,cp2:f=null,squareDist:g=0,cptArea:v=0,dimA:m=0}=a,M=t[l]||null;a.corner=!1,a.extreme=!1,a.semiExtreme=!1,a.directionChange=!1,a.closePath=!1;let b="C"===n||"Q"===n?"C"===n?[p,h,f,u]:[p,h,u]:[p,u],A=.1*m,C="Q"===n||"C"===n,w=M&&("Q"===M.type||"C"===M.type),E=!1;
8
8
  //!isFlat &&
9
- if(C){let e="C"===n?Math.abs(a.cp2.x-a.p.x):Math.abs(a.cp1.x-a.p.x),t="C"===n?Math.abs(a.cp2.y-a.p.y):Math.abs(a.cp1.y-a.p.y);if((0===t&&e>0||0===e&&t>0)&&(E=!0),u.x!==o&&u.y!==c&&u.x!==y&&u.y!==x||(E=!0),!E){if(G(null,b)){let e=ee(b);e.length&&e[0]>.15&&(E=!0)}}}if(E&&(a.extreme=!0),C&&w){if(r&&!a.extreme){let e=Math.abs(u.x-f.x),t=Math.abs(u.y-f.y),l=!1;if(e&&t&&e>A||t>A){let e=Z(f,u),t=Z(u,M.cp1);l=ae(Math.abs(e+t)/2)}l&&(a.semiExtreme=!0)}if((a.cptArea<0&&M.cptArea>0||a.cptArea>0&&M.cptArea<0)&&(a.directionChange=!0),!a.extreme){let e=f||h,t=M.cp1,l=de([e,u,t],!1),n=.01*re(e,t),r=Math.abs(l)<n,s=l<0&&a.cptArea>0||l>0&&a.cptArea<0;!r&&s&&(a.corner=!0)}}s&&(a.directionChange&&e(markers,a.p,"orange","1.5%","0.5"),a.corner&&e(markers,a.p,"magenta","1.5%","0.5"),a.extreme&&e(markers,a.p,"cyan","1%","0.5")),d.push(a)}return u={pathData:d,bb:h,dimA:(f+g)/2},u}function ke(e={},t={},l={},a={}){let n=H(e,t,1.5),r=H(a,l,1.5),s=.03*ie(e,a),i=ie(n,r),p=null,u={type:"C",values:[t.x,t.y,l.x,l.y,a.x,a.y]};return i&&s&&i<s&&(p=O(e,t,a,l,!1),p&&(u.type="Q",u.values=[p.x,p.y,a.x,a.y],u.p0=e,u.cp1=p,u.cp2=null,u.p=a)),u}function Pe(e,{toShorthands:t=!0,toLonghands:l=!1,toRelative:a=!0,toAbsolute:n=!1,decimals:r=3,arcToCubic:s=!1,quadraticToCubic:i=!1,hasRelatives:p=!0,hasShorthands:u=!0,hasQuadratics:h=!0,hasArcs:o=!0,testTypes:y=!1}={}){if(y){let t=Array.from(new Set(e.map(e=>e.type))).join("");/[lcqamts]/gi.test(t),h=/[qt]/gi.test(t),o=/[a]/gi.test(t),u=/[vhst]/gi.test(t),isPoly=/[mlz]/gi.test(t)}return a=!n&&a,t=!l&&t,h&&i&&(e=Ie(e)),o&&s&&(e=Se(e)),t&&(e=function(e,t=-1,l=!1){let a;if(l){let t=e.map(e=>e.type).join("");a=/[astvqmhlc]/g.test(t)}e=l&&a?Fe(e):e;let n=e.length,r=new Array(n),s=e[0];r[0]=s;let i={x:e[0].values[0],y:e[0].values[1]},p=i;for(let t=1;t<n;t++){let l=e[t];s=l;let{type:a,values:n}=l,u=n.length,h=[n[u-2],n[u-1]],o=e[t-1];p={x:h[0],y:h[1]};let y=Math.abs(p.x-i.x),c=Math.abs(p.y-i.y),x=.01*se(i,p),f=!1,g=!1,d=!1;if("C"===a&&"C"===o.type||"Q"===a&&"Q"===o.type){let e="C"===o.type?{x:o.values[2],y:o.values[3]}:{x:o.values[0],y:o.values[1]},t={x:n[0],y:n[1]},l=i.x-e.x,a=i.y-e.y;x=.05*se(e,t),f=se({x:e.x+2*l,y:e.y+2*a},t)<x}else"L"===a&&(g=0===c||c<x,d=0===y||y<x,f=d||g);switch(a){case"L":g&&(s={type:"H",values:[n[0]]}),d&&(s={type:"V",values:[n[1]]});break;case"Q":f&&(s={type:"T",values:[p.x,p.y]});break;case"C":f&&(s={type:"S",values:[n[2],n[3],p.x,p.y]});break;default:s={type:a,values:n}}i=p,r[t]=s}return r}(e)),u&&l&&(e=$e(e)),n&&(e=qe(e)),r>-1&&a&&(e=Ee(e,r)),a&&(e=function(e,t=-1){return Fe(e,!0,t)}(e)),r>-1&&(e=Ee(e,r)),e}function Se(e,{arcAccuracy:t=1}={}){let l=[e[0]];for(let a=1,n=e.length;a<n;a++){let n=e[a],r=e[a-1].values,s=r.length,i={x:r[s-2],y:r[s-1]};if("A"===n.type){Te(i,n.values,t).forEach(e=>{l.push(e)})}else l.push(n)}return l}function Ie(e){let t=[e[0]];for(let l=1,a=e.length;l<a;l++){let a=e[l],n=e[l-1].values,r=n.length,s={x:n[r-2],y:n[r-1]};"Q"===a.type?t.push(De(s,a.values)):t.push(a)}return t}function De(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 Fe(e,t=!1,l=-1){l>=0&&(e[0].values=e[0].values.map(e=>+e.toFixed(l)));let a=e.length,n=e[0].values,r=n[0],s=n[1],i=r,p=s;for(let n=1;n<a;n++){let a=e[n],{type:u,values:h}=a,o=h.length,y=u.toLowerCase(),c=u.toUpperCase(),x=t?y:c;if(u!==x)switch(a.type=x,y){case"a":h[5]=t?h[5]-r:h[5]+r,h[6]=t?h[6]-s:h[6]+s;break;case"v":h[0]=t?h[0]-s:h[0]+s;break;case"h":h[0]=t?h[0]-r:h[0]+r;break;case"m":t?(h[0]-=r,h[1]-=s):(h[0]+=r,h[1]+=s),i=t?h[0]+r:h[0],p=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:r):h[e]+(e%2?s:r)}switch(y){case"z":r=i,s=p;break;case"h":r=t?r+h[0]:h[0];break;case"v":s=t?s+h[0]:h[0];break;case"m":i=h[o-2]+(t?r:0),p=h[o-1]+(t?s:0);default:r=h[o-2]+(t?r:0),s=h[o-1]+(t?s:0)}l>=0&&(a.values=a.values.map(e=>+e.toFixed(l)))}return e}function qe(e,t=-1){return Fe(e,!1,t)}function $e(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=[],r={type:"M",values:(e=l&&a?qe(e,t):e)[0].values};n.push(r);for(let l=1,a=e.length;l<a;l++){let a,s,i,p,u,h,o,y,c=e[l],{type:x,values:f}=c,g=f.length,d=r.values,v=d.length,[m,M]=[f[g-2],f[g-1]],[b,A]=[d[v-2],d[v-1]];switch(x){case"H":r={type:"L",values:[f[0],A]};break;case"V":r={type:"L",values:[b,f[0]]};break;case"T":[a,s]=[d[0],d[1]],[b,A]=[d[v-2],d[v-1]],i=b+(b-a),p=A+(A-s),r={type:"Q",values:[i,p,m,M]};break;case"S":[a,s]=[d[0],d[1]],[b,A]=[d[v-2],d[v-1]],[o,y]=v>2&&"A"!==r.type?[d[2],d[3]]:[b,A],i=2*b-o,p=2*A-y,u=f[0],h=f[1],r={type:"C",values:[i,p,u,h,m,M]};break;default:r={type:x,values:f}}t>-1&&(r.values=r.values.map(e=>+e.toFixed(t))),n.push(r)}return n}function ze({p0:e={x:0,y:0},p:t={x:0,y:0},centroid:l={x:0,y:0},rx:a=0,ry:n=0,xAxisRotation:r=0,radToDegree:s=!1,startAngle:i=null,endAngle:p=null,deltaAngle:u=null}={}){if(!a||!n)return[];let h=[];const o=1.5707963267948966;let y=s?r:r*Math.PI/180,c=Math.cos(y),x=Math.sin(y);null!==i&&null!==p&&null!==u||({startAngle:i,endAngle:p,deltaAngle:u}=R(l,e,t));let f=a!==n?Y(i,a,n):i,g=a!==n?Y(u,a,n):u,d=Math.max(1,Math.ceil(Math.abs(g)/o)),v=g/d;for(let e=0;e<d;e++){const e=Math.abs(v)===o?.551785*Math.sign(v):4/3*Math.tan(v/4);let t=Math.cos(f),r=Math.sin(f),s=Math.cos(f+v),i=Math.sin(f+v),p=[];[{x:t-r*e,y:r+t*e},{x:s+i*e,y:i-s*e},{x:s,y:i}].forEach(e=>{let t=e.x*a,r=e.y*n;p.push(c*t-x*r+l.x,x*t+c*r+l.y)}),h.push({type:"C",values:p,cp1:{x:p[0],y:p[1]},cp2:{x:p[2],y:p[3]},p:{x:p[4],y:p[5]}}),f+=v}return h}function Te(e,t,l=1){const a=2*Math.PI;let[n,r,s,i,p,u,h]=t;if(0===n||0===r)return[];let o=s?s*a/360:0,y=o?Math.sin(o):0,c=o?Math.cos(o):1,x=c*(e.x-u)/2+y*(e.y-h)/2,f=-y*(e.x-u)/2+c*(e.y-h)/2;if(0===x&&0===f)return[];n=Math.abs(n),r=Math.abs(r);let g=x*x/(n*n)+f*f/(r*r);if(g>1){let e=Math.sqrt(g);n*=e,r*=e}let d=n*n,v=n===r?d:r*r,m=x*x,M=f*f,b=d*v-d*M-v*m;b<=0?b=0:(b/=d*M+v*m,b=Math.sqrt(b)*(i===p?-1:1));let A=b?b*n/r*f:0,C=b?b*-r/n*x:0,w=c*A-y*C+(e.x+u)/2,E=y*A+c*C+(e.y+h)/2,L=(x-A)/n,k=(f-C)/r,P=(-x-A)/n,S=(-f-C)/r;const I=(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 D=I(1,0,L,k),F=I(L,k,P,S);0===p&&F>0?F-=2*Math.PI:1===p&&F<0&&(F+=2*Math.PI);let q=(+(Math.abs(F)/(a/4)).toFixed(0)||1)*l;F/=q;let $=[];const z=1.5707963267948966,T=.551785;let Q=F===z?T:F===-z?-T:4/3*Math.tan(F/4),B=F?Math.cos(F):1,j=F?Math.sin(F):0;const N=(e,t,l,a,n)=>{let r=e!=t?Math.cos(e):a,s=e!=t?Math.sin(e):n,i=Math.cos(e+t),p=Math.sin(e+t);return[{x:r-s*l,y:s+r*l},{x:i+p*l,y:p-i*l},{x:i,y:p}]};for(let e=0;e<q;e++){let e={type:"C",values:[]};N(D,F,Q,B,j).forEach(t=>{let l=t.x*n,a=t.y*r;e.values.push(c*l-y*a+w,y*l+c*a+E)}),$.push(e),D+=F}return $}function Qe(e,{toAbsolute:t=!0,toLonghands:l=!0,quadraticToCubic:a=!1,arcToCubic:n=!1,arcAccuracy:r=4}={}){let s=Array.isArray(e),i=s&&"object"==typeof e[0]&&"function"==typeof e[0].constructor,p=s?e:function(e,t=!0){e=e.trim();let l={pathData:[],hasRelatives:!1,hasShorthands:!1,hasArcs:!1,hasQuadratics:!1,isPolygon:!1,log:[]};if(""===e)return l;let a,n=0,r=e.length,s="",i=-1,p="",u=!1,h=0,o=0,y=0,c=!1,x=new Set([]);const f=()=>{c&&("M"===s?s="L":"m"===s&&(s="l"),l.pathData.push({type:s,values:[]}),i++,o=0,c=!1)},g=(e=!1)=>{(e?h>0:""!==p)&&(t&&-1===i&&(a="Pathdata must start with M command",l.log.push(a),s="M",l.pathData.push({type:s,values:[]}),y=2,o=0,i++),"A"===s||"a"===s?(({val:p,valueIndex:o}=Re(p,o)),l.pathData[i].values.push(...p)):(t&&p[1]&&"."!==p[1]&&"0"===p[0]&&(a=`${i}. command: Leading zeros not valid: ${p}`,l.log.push(a)),l.pathData[i].values.push(+p)),o++,p="",h=0,c=o>=y)},d=()=>{if(i>0){let e=l.pathData[i].values.length;if(e&&e<y||e&&e>y||("z"===s||"Z"===s)&&e>0){a=`${i}. command of type "${s}": ${y-e} values too few - ${y} expected`,l.log[l.log.length-1]!==a&&l.log.push(a)}}};let v=!1,m=!1,M=!1,b="";for(;n<r;){b=e.charCodeAt(n);let r=b>47&&b<58;if(r||(v=101===b||69===b,m=45===b||43===b,M=46===b),r||m||M||v){if(u||45!==b&&46!==b)f();else{let e=46===b;g(e),f(),e&&h++}p+=e[n],u=v,n++}else if((b<48||b>5759)&&Ze(b))g(),n++;else{if(b>64){if(!Be.has(b)){a=`${i}. command "${e[n]}" is not a valid type`,l.log.push(a),n++;continue}""!==p&&(l.pathData[i].values.push(+p),o++,p=""),t&&d(),s=e[n],y=je[b];let r="M"===s||"m"===s,u=i>0&&("z"===l.pathData[i].type||"Z"===l.pathData[i].type);x.add(s),u&&!r&&(l.pathData.push({type:"m",values:[0,0]}),i++),l.pathData.push({type:s,values:[]}),i++,h=0,o=0,c=!1,n++;continue}r||(a=`${i}. ${e[n]} is not a valid separarator or token`,l.log.push(a),p=""),n++}}g(),t&&d();t&&l.log.length&&(a="Invalid path data:\n"+l.log.join("\n"),"log"===t?console.log(a):console.warn(a));l.pathData[0].type="M";let A=Array.from(x).join("");return l.hasRelatives=/[lcqamtsvh]/g.test(A),l.hasShorthands=/[vhst]/gi.test(A),l.hasArcs=/[a]/gi.test(A),l.hasQuadratics=/[qt]/gi.test(A),l.isPolygon=!/[cqats]/gi.test(A),l}(e),{hasRelatives:u=!0,hasShorthands:h=!0,hasQuadratics:o=!0,hasArcs:y=!0}=p,c=i?p:p.pathData;return c=function(e=[],{toAbsolute:t=!0,toLonghands:l=!0,quadraticToCubic:a=!1,arcToCubic:n=!1,arcAccuracy:r=2,hasRelatives:s=!0,hasShorthands:i=!0,hasQuadratics:p=!0,hasArcs:u=!0,testTypes:h=!1}={}){if(h){let t=Array.from(new Set(e.map(e=>e.type))).join("");s=/[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),s&&t&&(e=Fe(e,!1)),i&&l&&(e=$e(e,-1,!1)),u&&n&&(e=Se(e,r)),p&&a&&(e=Ie(e)),e}(c,{toAbsolute:t,toLonghands:l,quadraticToCubic:a,arcToCubic:n,arcAccuracy:r,hasRelatives:u,hasShorthands:h,hasQuadratics:o,hasArcs:y}),c}const Be=new Set([77,109,65,97,67,99,76,108,81,113,83,115,84,116,72,104,86,118,90,122]),je=new Uint8Array(128);je[77]=2,je[109]=2,je[65]=7,je[97]=7,je[67]=6,je[99]=6,je[76]=2,je[108]=2,je[81]=4,je[113]=4,je[83]=4,je[115]=4,je[84]=2,je[116]=2,je[72]=1,je[104]=1,je[86]=1,je[118]=1,je[90]=0,je[122]=0;const Ne=new Set([5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279]),Ze=e=>32===e||44===e||10===e||13===e||8232===e||8233===e||9===e||11===e||12===e||160===e||e>=5760&&Ne.has(e),Re=(e="",t=0)=>{let l=e.length;return 3===t&&2===l?(e=[+e[0],+e[1]],t++):4===t&&l>1?(e=[+e[0],+e.substring(1)],t++):3===t&&l>=3?(e=[+e[0],+e[1],+e.substring(2)],t+=2):e=[+e],{val:e,valueIndex:t}};function Oe(e){if("path"===e.nodeName.toLowerCase())return e;let t=function(e,t=!1){let l,a,n,r,s,i,p,u,h,o,y,c,x,f,g,d,v=[],m=e.nodeName;const M=(e,t=9)=>{const l="svg"!==e.nodeName?e.closest("svg"):e,a=e=>{if(null===e)return 0;let l=96,a=e.match(/([a-z]+)/gi);a=a?a[0]:"";let n,r=parseFloat(e);if(!a)return r;switch(a){case"in":n=l;break;case"pt":n=1/72*96;break;case"cm":n=1/2.54*96;break;case"mm":n=1/2.54*96/10;break;case"em":case"rem":n=16;break;default:n=1}return+(r*n).toFixed(t)};let n=l.getAttribute("width");n=n?a(n):300;let r=l.getAttribute("height");r=n?a(r):150;let s=l.getAttribute("viewBox");s=s?s.replace(/,/g," ").split(" ").filter(Boolean).map(e=>+e):[];let i=s.length?s[2]:n,p=s.length?s[3]:r,u=i/100,h=p/100,o=Math.sqrt((Math.pow(u,2)+Math.pow(h,2))/2),y=["x","width","x1","x2","rx","cx","r"],c=["y","height","y1","y2","ry","cy"];e.getAttributeNames().forEach(t=>{let l=e.getAttribute(t),n=l;if(y.includes(t)||c.includes(t)){let r=y.includes(t)?u:h;r="r"===t&&i!=p?o:r;let s=l.match(/([a-z|%]+)/gi);s=s?s[0]:"",n=l.includes("%")?parseFloat(l)*r:a(l),e.setAttribute(t,+n)}})};M(e);const b=t=>(l={},t.forEach(t=>{l[t]=+e.getAttribute(t)}),l);switch(m){case"path":n=e.getAttribute("d"),v=Qe(n);break;case"rect":a=["x","y","width","height","rx","ry"],({x:r,y:s,width:i,height:p,rx:h,ry:o}=b(a)),h||o?(h=h||o,o=o||h,h>i/2&&(h=i/2),o>p/2&&(o=p/2),v=[{type:"M",values:[r+h,s]},{type:"L",values:[r+i-h,s]},{type:"A",values:[h,o,0,0,1,r+i,s+o]},{type:"L",values:[r+i,s+p-o]},{type:"A",values:[h,o,0,0,1,r+i-h,s+p]},{type:"L",values:[r+h,s+p]},{type:"A",values:[h,o,0,0,1,r,s+p-o]},{type:"L",values:[r,s+o]},{type:"A",values:[h,o,0,0,1,r+h,s]},{type:"Z",values:[]}]):v=[{type:"M",values:[r,s]},{type:"L",values:[r+i,s]},{type:"L",values:[r+i,s+p]},{type:"L",values:[r,s+p]},{type:"Z",values:[]}];break;case"circle":case"ellipse":a=["cx","cy","rx","ry","r"],({cx:y,cy:c,r:u,rx:h,ry:o}=b(a));let t="circle"===m;t?(h=u,o=u):(h=h||u,o=o||u);let l=t&&u>=1?1:h,M=t&&u>=1?1:h;v=[{type:"M",values:[y+h,c]},{type:"A",values:[l,M,0,1,1,y-h,c]},{type:"A",values:[l,M,0,1,1,y+h,c]}];break;case"line":a=["x1","y1","x2","y2"],({x1:x,y1:g,x2:f,y2:d}=b(a)),v=[{type:"M",values:[x,g]},{type:"L",values:[f,d]}];break;case"polygon":case"polyline":let A=e.getAttribute("points").replaceAll(","," ").split(" ").filter(Boolean);for(let e=0;e<A.length;e+=2)v.push({type:0===e?"M":"L",values:[+A[e],+A[e+1]]});"polygon"===m&&v.push({type:"Z",values:[]})}return t?function(e){return e.map(e=>`${e.type} ${e.values.join(" ")}`).join(" ")}(v):v}(e),l=t.map(e=>`${e.type} ${e.values} `).join(" "),a=[...e.attributes].map(e=>e.name),n=document.createElementNS("http://www.w3.org/2000/svg","path");n.setAttribute("d",l);let r=["x","y","cx","cy","dx","dy","r","rx","ry","width","height","points"];return a.forEach(t=>{if(!r.includes(t)){let l=e.getAttribute(t);n.setAttribute(t,l)}}),n}function He(e,{tolerance:t=1,flatBezierToLinetos:l=!0}={}){let a=[e[0]],n={x:e[0].values[0],y:e[0].values[1]},r=n,s=n;e[e.length-1].type.toLowerCase();for(let i=1,p=e.length;i<p;i++){let u=e[i],h=e[i+1]||e[p-1],o="z"===h.type.toLowerCase()?n:{x:h.values[h.values.length-2],y:h.values[h.values.length-1]},{type:y,values:c}=u,x=c.slice(-2);s="Z"!==y?{x:x[0],y:x[1]}:n;let f=!1,g=!1,d=Math.abs(o.x-r.x),v=Math.abs(o.y-r.y),m=Math.abs(s.x-r.x),M=Math.abs(s.y-r.y),b=Math.abs(o.x-s.x),A=Math.abs(o.y-s.y);if((!M&&!m||!A&&!b)&&(f=!0),!f){
10
- //!cross0 ||
11
- Math.abs(d*M-v*m)<.1*(d+v)&&(f=!0)}if(l||"C"!==y||(f=!1),l&&("C"===y||"Q"===y)){g=Ae([r,..."C"===y?[{x:c[0],y:c[1]},{x:c[2],y:c[3]}]:"Q"===y?[{x:c[0],y:c[1]}]:[],s],{tolerance:t}),g&&i<p-1&&(y="L",u.type="L",u.values=x)}f&&i<p-1&&"A"!==h.type&&("L"===y||l&&g)||(r=s,"M"===y&&(n=s),a.push(u))}return a}function Ue(e){let t=[];for(let l=0,a=e.length;l<a;l++){let a=e[l];if(!a)continue;let{type:n=null,values:r=[]}=a,s=e[l+1]?e[l+1]:null;"M"!==n&&"m"!==n||s&&(!s||"Z"!==s.type&&"z"!==s.type)?t.push(a):s&&l++}return t}function Ve(e){let t={x:e[0].values[0],y:e[0].values[1]},l=t,a=[e[0]];for(let n=1,r=e.length;n<r;n++){let r=e[n],s=e[n-1],i=e[n+1]||null,{type:p,values:u}=r,h="m"===s.type.toLowerCase()&&!i,o=u.length;if(l={x:u[o-2],y:u[o-1]},h||"L"!==p||l.x!==t.x||l.y!==t.y){if(!h&&("l"===p||"v"===p||"h"===p)){if("l"===p?"00"===u.join(""):0===u[0])continue}a.push(r),t=l}}return a}function We(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:r}=t,s=r.length;if(s){let e={type:n,x:r[s-2],y:r[s-1],index:0};e.index=l,a.push(e)}}return a=a.sort((e,t)=>+e.y.toFixed(8)-+t.y.toFixed(8)||e.x-t.x),l=a[0].index,l?Xe(e,l):e}function Je(e,{removeFinalLineto:t=!0,autoClose:l=!0}={}){let a=[],n=e.length,r={x:+e[0].values[0].toFixed(8),y:+e[0].values[1].toFixed(8)},s="z"===e[n-1].type.toLowerCase(),i=e.filter(e=>"L"===e.type),p=e[s?n-2:n-1],u=p.type,h=p.values.slice(-2).map(e=>+e.toFixed(8)),o=h[0]===r.x&&h[1]===r.y;!s&&l&&o&&(e.push({type:"Z",values:[]}),s=!0,n++);let y="L"!==e[1].type&&(!o||"L"===p.type);if(y=!1,!s)return e;let c=0;{let t=[];for(let l=0;l<n;l++){let a=e[l],{type:n,values:r}=a;if(r.length){let a=r.slice(-2),s=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,h={type:n,x:a[0],y:a[1],dist:0,index:0,prevL:s,nextL:i,prevCom:p,nextCom:u};h.index=l,t.push(h)}}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(8)-+t.y.toFixed(8)||e.x-t.x),c=t[0].index;e=c?Xe(e,c):e}return r={x:+e[0].values[0].toFixed(8),y:+e[0].values[1].toFixed(8)},n=e.length,p=e[n-2],u=p.type,h=p.values.slice(-2).map(e=>+e.toFixed(8)),o="L"===u&&h[0]===r.x&&h[1]===r.y,t&&o&&e.splice(n-2,1),a.push(...e),a}function Xe(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,r]=[a.values[0],a.values[1]].map(e=>+e.toFixed(8)),s=l?e[t-2]:e[t-1],i=s.values.length,[p,u]=[s.values[i-2],s.values[i-1]].map(e=>+e.toFixed(8));!l||n==p&&r==u||(e.pop(),e.push({type:"L",values:[n,r]},{type:"Z",values:[]}))}(e),l=t+1<e.length-1?t+1:e.length-1-n;let r,s,i=e.slice(l),p=e.slice(0,l);return p.shift(),r=p[p.length-1].values||[],s=[r[r.length-2],r[r.length-1]],n&&(i.pop(),p.push({type:"Z",values:[]})),e=[{type:"M",values:s},...i,...p]}function Ye(e=[],t=.666){let l=e.length;for(let a=1;a<l;a++){let l=e[a],n=e[a-1],{type:r,values:s}=l;e[a+1]&&e[a+1];let i=!1;if("C"===r){let l={x:s[0],y:s[1]},r={x:s[2],y:s[3]},p=n.values.slice(-2),u={x:p[0],y:p[1]},h={x:s[4],y:s[5]},o=se(u,h),y=se(u,l),c=se(h,r),x=se(l,r),f=O(u,l,h,r,!1),g=f?O(u,l,h,r,!0):null;if(f&&!g){O(h,H(h,r,3),u,l,!0)&&(i=!0)}y/o<.3&&c/o>.4&&(l=U([u,l],1+t/2),r=U([h,r],t),e[a].values[0]=l.x,e[a].values[1]=l.y,e[a].values[2]=r.x,e[a].values[3]=r.y),(g||f&&x<o/5)&&(i=!0),i&&(l=U([u,f],t),r=U([h,f],t),e[a].values[0]=l.x,e[a].values[1]=l.y,e[a].values[2]=r.x,e[a].values[3]=r.y)}}return e}function Ge(e,t,l=!0,a=!0){if(!Array.isArray(e)||void 0!==e[0].x){if(void 0===e[0].x)throw Error("Not a valid point array");e=(e=>Array.from(e).map(e=>[e.x,e.y]))(e)}if(1===(e=e.filter(function(t,l){return 0===l||!t.every((t,a)=>t===e[l-1][a])})).length)return[];if(2===e.length)return[{type:"L",values:[e[0][0],e[0][1]]},{type:"L",values:[e[1][0],e[1][1]]}];let n,r,s=e.length,i=at(e[1],e[0]),p=at(e[s-2],e[s-1]),u=(e=>{let t=[];return e.forEach(e=>{let l=e[1],a=e[2],n=e[3],r={type:"C",values:[l[0],l[1],a[0],a[1],n[0],n[1]]};t.push(r)}),t})(_e(e,i,p,t));if(l){let t=u.length,l=u[0],i=u[t-1],p={x:e[0][0],y:e[0][1]},h={x:e[1][0],y:e[1][1]},o=e[2]?{x:e[2][0],y:e[2][1]}:null;o&&(n={x:l.values[0],y:l.values[1]},n=Ke(n,p,h,o),l.values[0]=n.x,l.values[1]=n.y);let y={x:e[s-1][0],y:e[s-1][1]},c={x:e[s-2][0],y:e[s-2][1]},x=e[s-3]?{x:e[s-3][0],y:e[s-3][1]}:null;x&&(r={x:i.values[2],y:i.values[3]},r=Ke(r,y,c,x),i.values[2]=r.x,i.values[3]=r.y),a&&(u=function(e=[],t=.666){let l=e.length;for(let a=0;a<l;a++){let l=e[a],n=e[a-1]||null,{type:r,values:s}=l;e[a+1]&&e[a+1];let i=!1;if("C"===r){let l={x:s[0],y:s[1]},r={x:s[2],y:s[3]},p=n.values.slice(-2),u={x:p[0],y:p[1]},h={x:s[4],y:s[5]},o=se(u,h);se(u,l),se(h,r);let y=se(l,r),c=O(u,l,h,r,!1);c&&(c&&O(u,l,h,r,!0)||y<o/5)&&(i=!0),i&&(l=U([u,c],t),r=U([h,c],t),e[a].values[0]=l.x,e[a].values[1]=l.y,e[a].values[2]=r.x,e[a].values[3]=r.y)}}return e}([{type:"M",values:[e[0][0],e[0][1]]},...u]),u.shift())}return u}function Ke(e,t,l,a){let n=Z(t,l),r=Z(t,a)-n;return e=J(e,t.x,t.y,-r)}let _e=(e,t,l,a)=>{let n;if(2===e.length){let a=.333*ne(e[0],e[1],!0);return n=[e[0],rt(e[0],st(t,a)),rt(e[1],st(l,a)),e[1]],[n]}let r=function(e){let t=[],l=e.length,a=e[0],n=e[1],r=0,s=0;for(let i=0;i<l;i++)n=e[i],r=s+ne(n,a,!0),t.push(r),s=r,a=n;return t=t.map(function(e){return e/s}),t}(e),s=et(e,r,r,t,l);n=s[0];let i=s[1],p=s[2];if(0===i||i<a)return[n];if(i<a*a){let s=r,u=i,h=p;for(let o=0;o<20;o++){s=tt(n,e,s);let o=et(e,r,s,t,l);if(n=o[0],i=o[1],p=o[2],i<a)return[n];if(p===h){let e=i/u;if(e>.9999&&e<1.0001)break}u=i,h=p}}let u=[],h=nt(e[p-1],e[p+1]);if(h.every(function(e){return 0===e})){h=nt(e[p-1],e[p]);let t=[-h[1],h[0]];h[0]=t[0],h[1]=t[1]}let o=function(e){let t=Math.sqrt(e[0]*e[0]+e[1]*e[1]);return 0===t?[0,0]:[e[0]/t,e[1]/t]}(h),y=st(o,-1);return u=u.concat(_e(e.slice(0,p+1),t,o,a)),u=u.concat(_e(e.slice(p),y,l,a)),u};const et=(e,t,l,a,n)=>{let r,s,i;r=((e,t,l,a)=>{let n,r,s,i,p=e[0],u=e[e.length-1],h=[p,null,null,u],o=function(e){let t=[];for(;e--;)t.push([0,0]);return t}(t.length),y=t.length;for(let e=0;e<y;e++)s=t[e],i=1-s,n=o[e],n[0]=st(l,3*s*(i*i)),n[1]=st(a,3*i*(s*s));let c=[[0,0],[0,0]],x=[0,0],f=e.length;for(let l=0;l<f;l++)s=t[l],n=o[l],c[0][0]+=it(n[0],n[0]),c[0][1]+=it(n[0],n[1]),c[1][0]+=it(n[0],n[1]),c[1][1]+=it(n[1],n[1]),r=nt(e[l],U([p,p,u,u],s)),x[0]+=it(n[0],r),x[1]+=it(n[1],r);let g=c[0][0]*c[1][1]-c[1][0]*c[0][1],d=c[0][0]*x[1]-c[1][0]*x[0],v=x[0]*c[1][1]-x[1]*c[0][1],m=0===g?0:v/g,M=0===g?0:d/g,b=ne(p,u,!0),A=1e-6*b;return m<A||M<A?(h[1]=rt(p,st(l,.333*b)),h[2]=rt(u,st(a,.333*b))):(h[1]=rt(p,st(l,m)),h[2]=rt(u,st(a,M))),h})(e,l,a,n);let p=function(e,t,l){let a,n,r,s,i,p,u;n=0,r=Math.floor(.5*e.length);let h=function(e,t){let l,a=[0],n=e[0],r=0;for(let s=1;s<=t;s++)l=U(e,s/t),r+=ne(l,n,!0),a.push(r),n=l;return a=a.map(function(e){return e/r}),a}(t,10),o=e.length;for(i=0;i<o;i++)p=e[i],u=lt(l[i],h,10),s=nt(U(t,u),p),a=s[0]*s[0]+s[1]*s[1],a>n&&(n=a,r=i);return[n,r]}(e,r,t);return s=p[0],i=p[1],[r,s,i]};function tt(e,t,l){return l.map((l,a)=>function(e,t,l){let a=U(e,l),n=a[0]-t[0],r=a[1]-t[1],s=pt(e,l),i=n*s[0]+r*s[1],p=s[0]*s[0]+s[1]*s[1],u=pt(e,l,!0),h=2*(n*u[0]+r*u[1]),o=p+h;if(Math.abs(o)<1e-10)return l;return l-i/o}(e,t[a],l))}function lt(e,t,l){if(e<0)return 0;if(e>1)return 1;let a,n,r,s,i;for(let p=1;p<=l;p++)if(e<=t[p]){s=(p-1)/l,r=p/l,n=t[p-1],a=t[p],i=(e-n)/(a-n)*(r-s)+s;break}return i}function at(e,t){let l=e[0]-t[0],a=e[1]-t[1],n=Math.sqrt(l*l+a*a);return 0===n?[0,0]:[l/n,a/n]}function nt(e,t){return[e[0]-t[0],e[1]-t[1]]}function rt(e,t){return[e[0]+t[0],e[1]+t[1]]}function st(e,t){return[e[0]*t,e[1]*t]}function it(e,t){return e[0]*t[0]+e[1]*t[1]}function pt(e,t,l=!1){let a,n,r=e[0],s=e[1],i=e[2],p=e[3],u=t,h=1-u,o=h*h,y=u*u;return l?(a=6*h*(i[0]-2*s[0]+r[0])+6*u*(p[0]-2*i[0]+s[0]),n=6*h*(i[1]-2*s[1]+r[1])+6*u*(p[1]-2*i[1]+s[1])):(a=3*o*(s[0]-r[0])+6*h*u*(i[0]-s[0])+3*y*(p[0]-i[0]),n=3*o*(s[1]-r[1])+6*h*u*(i[1]-s[1])+3*y*(p[1]-i[1])),[a,n]}function ut(e,{debug:t=!1,width:l=0,height:a=0,denoise:n=.9,keepCorners:r=!0,keepExtremes:s=!0,keepInflections:i=!1,manhattan:p=!1,absolute:u=!1,closed:h=!0,tolerance:o=1}={}){let y=s||r?function(e,{x:t=0,y:l=0,width:a=0,height:n=0,debug:r=!1}={}){let s=e.length,i=ce(e);a&&n||({x:t,y:l,width:a,height:n}=i);let p=.01*(a+n);for(let t=0;t<s;t++){let l=t>0?e[t-1]:e[s-1],a=e[t],n=de([l,a,t<s-1?e[t+1]:e[s-1]],!1);a.area=n,a.dist=se(l,a)}for(let t=0;t<s;t++){t>1?e[t-2]:e[s-1];let l=t>0?e[t-1]:e[s-1],a=e[t],n=t<s-1?e[t+1]:e[s-1],r=ce([l,n]);re(l,n);let u=Math.abs(l.area),h=Math.abs(a.area),o=Math.abs(n.area),y=!1,c=!a.area||h<p,{left:x,right:f,top:g,bottom:d}=r,v=a.x<=x||a.x>=f||a.y<=g||a.y>=d,m=a.x===i.left||a.x===i.right||a.y===i.top||a.y===i.bottom;se(a,l);let M=a.y===l.y&&a.x!==l.x,b=a.x===l.x&&a.y!==l.y;
9
+ if(C){let e="C"===n?Math.abs(a.cp2.x-a.p.x):Math.abs(a.cp1.x-a.p.x),t="C"===n?Math.abs(a.cp2.y-a.p.y):Math.abs(a.cp1.y-a.p.y);if((0===t&&e>0||0===e&&t>0)&&(E=!0),u.x!==o&&u.y!==c&&u.x!==y&&u.y!==x||(E=!0),!E){if(G(null,b)){let e=ee(b);e.length&&e[0]>.15&&(E=!0)}}}if(E&&(a.extreme=!0),C&&w){if(r&&!a.extreme){let e=Math.abs(u.x-f.x),t=Math.abs(u.y-f.y),l=!1;if(e&&t&&e>A||t>A){let e=Z(f,u),t=Z(u,M.cp1);l=ae(Math.abs(e+t)/2)}l&&(a.semiExtreme=!0)}if((a.cptArea<0&&M.cptArea>0||a.cptArea>0&&M.cptArea<0)&&(a.directionChange=!0),!a.extreme){let e=f||h,t=M.cp1,l=de([e,u,t],!1),n=.01*re(e,t),r=Math.abs(l)<n,s=l<0&&a.cptArea>0||l>0&&a.cptArea<0;!r&&s&&(a.corner=!0)}}s&&(a.directionChange&&e(markers,a.p,"orange","1.5%","0.5"),a.corner&&e(markers,a.p,"magenta","1.5%","0.5"),a.extreme&&e(markers,a.p,"cyan","1%","0.5")),d.push(a)}return u={pathData:d,bb:h,dimA:(f+g)/2},u}function ke(e={},t={},l={},a={}){let n=H(e,t,1.5),r=H(a,l,1.5),s=.03*ie(e,a),i=ie(n,r),p=null,u={type:"C",values:[t.x,t.y,l.x,l.y,a.x,a.y]};return i&&s&&i<s&&(p=O(e,t,a,l,!1),p&&(u.type="Q",u.values=[p.x,p.y,a.x,a.y],u.p0=e,u.cp1=p,u.cp2=null,u.p=a)),u}function Se(e,{toShorthands:t=!0,toLonghands:l=!1,toRelative:a=!0,toAbsolute:n=!1,decimals:r=3,arcToCubic:s=!1,quadraticToCubic:i=!1,hasRelatives:p=!0,hasShorthands:u=!0,hasQuadratics:h=!0,hasArcs:o=!0,testTypes:y=!1}={}){if(y){let t=Array.from(new Set(e.map(e=>e.type))).join("");/[lcqamts]/gi.test(t),h=/[qt]/gi.test(t),o=/[a]/gi.test(t),u=/[vhst]/gi.test(t),isPoly=/[mlz]/gi.test(t)}return a=!n&&a,t=!l&&t,h&&i&&(e=Ie(e)),o&&s&&(e=Pe(e)),t&&(e=function(e,t=-1,l=!1){let a;if(l){let t=e.map(e=>e.type).join("");a=/[astvqmhlc]/g.test(t)}e=l&&a?Fe(e):e;let n=e.length,r=new Array(n),s=e[0];r[0]=s;let i={x:e[0].values[0],y:e[0].values[1]},p=i;for(let t=1;t<n;t++){let l=e[t];s=l;let{type:a,values:n}=l,u=n.length,h=[n[u-2],n[u-1]],o=e[t-1];p={x:h[0],y:h[1]};let y=Math.abs(p.x-i.x),c=Math.abs(p.y-i.y),x=.01*se(i,p),f=!1,g=!1,d=!1;if("C"===a&&"C"===o.type||"Q"===a&&"Q"===o.type){let e="C"===o.type?{x:o.values[2],y:o.values[3]}:{x:o.values[0],y:o.values[1]},t={x:n[0],y:n[1]},l=i.x-e.x,a=i.y-e.y;x=.05*se(e,t),f=se({x:e.x+2*l,y:e.y+2*a},t)<x}else"L"===a&&(g=0===c||c<x,d=0===y||y<x,f=d||g);switch(a){case"L":g&&(s={type:"H",values:[n[0]]}),d&&(s={type:"V",values:[n[1]]});break;case"Q":f&&(s={type:"T",values:[p.x,p.y]});break;case"C":f&&(s={type:"S",values:[n[2],n[3],p.x,p.y]});break;default:s={type:a,values:n}}i=p,r[t]=s}return r}(e)),u&&l&&(e=$e(e)),n&&(e=qe(e)),r>-1&&a&&(e=Ee(e,r)),a&&(e=function(e,t=-1){return Fe(e,!0,t)}(e)),r>-1&&(e=Ee(e,r)),e}function Pe(e,{arcAccuracy:t=1}={}){let l=[e[0]];for(let a=1,n=e.length;a<n;a++){let n=e[a],r=e[a-1].values,s=r.length,i={x:r[s-2],y:r[s-1]};if("A"===n.type){Te(i,n.values,t).forEach(e=>{l.push(e)})}else l.push(n)}return l}function Ie(e){let t=[e[0]];for(let l=1,a=e.length;l<a;l++){let a=e[l],n=e[l-1].values,r=n.length,s={x:n[r-2],y:n[r-1]};"Q"===a.type?t.push(De(s,a.values)):t.push(a)}return t}function De(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 Fe(e,t=!1,l=-1){l>=0&&(e[0].values=e[0].values.map(e=>+e.toFixed(l)));let a=e.length,n=e[0].values,r=n[0],s=n[1],i=r,p=s;for(let n=1;n<a;n++){let a=e[n],{type:u,values:h}=a,o=h.length,y=u.toLowerCase(),c=u.toUpperCase(),x=t?y:c;if(u!==x)switch(a.type=x,y){case"a":h[5]=t?h[5]-r:h[5]+r,h[6]=t?h[6]-s:h[6]+s;break;case"v":h[0]=t?h[0]-s:h[0]+s;break;case"h":h[0]=t?h[0]-r:h[0]+r;break;case"m":t?(h[0]-=r,h[1]-=s):(h[0]+=r,h[1]+=s),i=t?h[0]+r:h[0],p=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:r):h[e]+(e%2?s:r)}switch(y){case"z":r=i,s=p;break;case"h":r=t?r+h[0]:h[0];break;case"v":s=t?s+h[0]:h[0];break;case"m":i=h[o-2]+(t?r:0),p=h[o-1]+(t?s:0);default:r=h[o-2]+(t?r:0),s=h[o-1]+(t?s:0)}l>=0&&(a.values=a.values.map(e=>+e.toFixed(l)))}return e}function qe(e,t=-1){return Fe(e,!1,t)}function $e(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=[],r={type:"M",values:(e=l&&a?qe(e,t):e)[0].values};n.push(r);for(let l=1,a=e.length;l<a;l++){let a,s,i,p,u,h,o,y,c=e[l],{type:x,values:f}=c,g=f.length,d=r.values,v=d.length,[m,M]=[f[g-2],f[g-1]],[b,A]=[d[v-2],d[v-1]];switch(x){case"H":r={type:"L",values:[f[0],A]};break;case"V":r={type:"L",values:[b,f[0]]};break;case"T":[a,s]=[d[0],d[1]],[b,A]=[d[v-2],d[v-1]],i=b+(b-a),p=A+(A-s),r={type:"Q",values:[i,p,m,M]};break;case"S":[a,s]=[d[0],d[1]],[b,A]=[d[v-2],d[v-1]],[o,y]=v>2&&"A"!==r.type?[d[2],d[3]]:[b,A],i=2*b-o,p=2*A-y,u=f[0],h=f[1],r={type:"C",values:[i,p,u,h,m,M]};break;default:r={type:x,values:f}}t>-1&&(r.values=r.values.map(e=>+e.toFixed(t))),n.push(r)}return n}function ze({p0:e={x:0,y:0},p:t={x:0,y:0},centroid:l={x:0,y:0},rx:a=0,ry:n=0,xAxisRotation:r=0,radToDegree:s=!1,startAngle:i=null,endAngle:p=null,deltaAngle:u=null}={}){if(!a||!n)return[];let h=[];const o=1.5707963267948966;let y=s?r:r*Math.PI/180,c=Math.cos(y),x=Math.sin(y);null!==i&&null!==p&&null!==u||({startAngle:i,endAngle:p,deltaAngle:u}=R(l,e,t));let f=a!==n?Y(i,a,n):i,g=a!==n?Y(u,a,n):u,d=Math.max(1,Math.ceil(Math.abs(g)/o)),v=g/d;for(let e=0;e<d;e++){const e=Math.abs(v)===o?.551785*Math.sign(v):4/3*Math.tan(v/4);let t=Math.cos(f),r=Math.sin(f),s=Math.cos(f+v),i=Math.sin(f+v),p=[];[{x:t-r*e,y:r+t*e},{x:s+i*e,y:i-s*e},{x:s,y:i}].forEach(e=>{let t=e.x*a,r=e.y*n;p.push(c*t-x*r+l.x,x*t+c*r+l.y)}),h.push({type:"C",values:p,cp1:{x:p[0],y:p[1]},cp2:{x:p[2],y:p[3]},p:{x:p[4],y:p[5]}}),f+=v}return h}function Te(e,t,l=1){const a=2*Math.PI;let[n,r,s,i,p,u,h]=t;if(0===n||0===r)return[];let o=s?s*a/360:0,y=o?Math.sin(o):0,c=o?Math.cos(o):1,x=c*(e.x-u)/2+y*(e.y-h)/2,f=-y*(e.x-u)/2+c*(e.y-h)/2;if(0===x&&0===f)return[];n=Math.abs(n),r=Math.abs(r);let g=x*x/(n*n)+f*f/(r*r);if(g>1){let e=Math.sqrt(g);n*=e,r*=e}let d=n*n,v=n===r?d:r*r,m=x*x,M=f*f,b=d*v-d*M-v*m;b<=0?b=0:(b/=d*M+v*m,b=Math.sqrt(b)*(i===p?-1:1));let A=b?b*n/r*f:0,C=b?b*-r/n*x:0,w=c*A-y*C+(e.x+u)/2,E=y*A+c*C+(e.y+h)/2,L=(x-A)/n,k=(f-C)/r,S=(-x-A)/n,P=(-f-C)/r;const I=(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 D=I(1,0,L,k),F=I(L,k,S,P);0===p&&F>0?F-=2*Math.PI:1===p&&F<0&&(F+=2*Math.PI);let q=(+(Math.abs(F)/(a/4)).toFixed(0)||1)*l;F/=q;let $=[];const z=1.5707963267948966,T=.551785;let Q=F===z?T:F===-z?-T:4/3*Math.tan(F/4),B=F?Math.cos(F):1,j=F?Math.sin(F):0;const N=(e,t,l,a,n)=>{let r=e!=t?Math.cos(e):a,s=e!=t?Math.sin(e):n,i=Math.cos(e+t),p=Math.sin(e+t);return[{x:r-s*l,y:s+r*l},{x:i+p*l,y:p-i*l},{x:i,y:p}]};for(let e=0;e<q;e++){let e={type:"C",values:[]};N(D,F,Q,B,j).forEach(t=>{let l=t.x*n,a=t.y*r;e.values.push(c*l-y*a+w,y*l+c*a+E)}),$.push(e),D+=F}return $}function Qe(e,{toAbsolute:t=!0,toLonghands:l=!0,quadraticToCubic:a=!1,arcToCubic:n=!1,arcAccuracy:r=4}={}){let s=Array.isArray(e),i=s&&"object"==typeof e[0]&&"function"==typeof e[0].constructor,p=s?e:function(e,t=!0){e=e.trim();let l={pathData:[],hasRelatives:!1,hasShorthands:!1,hasArcs:!1,hasQuadratics:!1,isPolygon:!1,log:[]};if(""===e)return l;let a,n=0,r=e.length,s="",i=-1,p="",u=!1,h=0,o=0,y=0,c=!1,x=new Set([]);const f=()=>{c&&("M"===s?s="L":"m"===s&&(s="l"),l.pathData.push({type:s,values:[]}),i++,o=0,c=!1)},g=(e=!1)=>{(e?h>0:""!==p)&&(t&&-1===i&&(a="Pathdata must start with M command",l.log.push(a),s="M",l.pathData.push({type:s,values:[]}),y=2,o=0,i++),"A"===s||"a"===s?(({val:p,valueIndex:o}=Re(p,o)),l.pathData[i].values.push(...p)):(t&&p[1]&&"."!==p[1]&&"0"===p[0]&&(a=`${i}. command: Leading zeros not valid: ${p}`,l.log.push(a)),l.pathData[i].values.push(+p)),o++,p="",h=0,c=o>=y)},d=()=>{if(i>0){let e=l.pathData[i].values.length;if(e&&e<y||e&&e>y||("z"===s||"Z"===s)&&e>0){a=`${i}. command of type "${s}": ${y-e} values too few - ${y} expected`,l.log[l.log.length-1]!==a&&l.log.push(a)}}};let v=!1,m=!1,M=!1,b="";for(;n<r;){b=e.charCodeAt(n);let r=b>47&&b<58;if(r||(v=101===b||69===b,m=45===b||43===b,M=46===b),r||m||M||v){if(u||45!==b&&46!==b)f();else{let e=46===b;g(e),f(),e&&h++}p+=e[n],u=v,n++}else if((b<48||b>5759)&&Ze(b))g(),n++;else{if(b>64){if(!Be.has(b)){a=`${i}. command "${e[n]}" is not a valid type`,l.log.push(a),n++;continue}""!==p&&(l.pathData[i].values.push(+p),o++,p=""),t&&d(),s=e[n],y=je[b];let r="M"===s||"m"===s,u=i>0&&("z"===l.pathData[i].type||"Z"===l.pathData[i].type);x.add(s),u&&!r&&(l.pathData.push({type:"m",values:[0,0]}),i++),l.pathData.push({type:s,values:[]}),i++,h=0,o=0,c=!1,n++;continue}r||(a=`${i}. ${e[n]} is not a valid separarator or token`,l.log.push(a),p=""),n++}}g(),t&&d();t&&l.log.length&&(a="Invalid path data:\n"+l.log.join("\n"),"log"===t?console.log(a):console.warn(a));l.pathData[0].type="M";let A=Array.from(x).join("");return l.hasRelatives=/[lcqamtsvh]/g.test(A),l.hasShorthands=/[vhst]/gi.test(A),l.hasArcs=/[a]/gi.test(A),l.hasQuadratics=/[qt]/gi.test(A),l.isPolygon=!/[cqats]/gi.test(A),l}(e),{hasRelatives:u=!0,hasShorthands:h=!0,hasQuadratics:o=!0,hasArcs:y=!0}=p,c=i?p:p.pathData;return c=function(e=[],{toAbsolute:t=!0,toLonghands:l=!0,quadraticToCubic:a=!1,arcToCubic:n=!1,arcAccuracy:r=2,hasRelatives:s=!0,hasShorthands:i=!0,hasQuadratics:p=!0,hasArcs:u=!0,testTypes:h=!1}={}){if(h){let t=Array.from(new Set(e.map(e=>e.type))).join("");s=/[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),s&&t&&(e=Fe(e,!1)),i&&l&&(e=$e(e,-1,!1)),u&&n&&(e=Pe(e,r)),p&&a&&(e=Ie(e)),e}(c,{toAbsolute:t,toLonghands:l,quadraticToCubic:a,arcToCubic:n,arcAccuracy:r,hasRelatives:u,hasShorthands:h,hasQuadratics:o,hasArcs:y}),c}const Be=new Set([77,109,65,97,67,99,76,108,81,113,83,115,84,116,72,104,86,118,90,122]),je=new Uint8Array(128);je[77]=2,je[109]=2,je[65]=7,je[97]=7,je[67]=6,je[99]=6,je[76]=2,je[108]=2,je[81]=4,je[113]=4,je[83]=4,je[115]=4,je[84]=2,je[116]=2,je[72]=1,je[104]=1,je[86]=1,je[118]=1,je[90]=0,je[122]=0;const Ne=new Set([5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279]),Ze=e=>32===e||44===e||10===e||13===e||8232===e||8233===e||9===e||11===e||12===e||160===e||e>=5760&&Ne.has(e),Re=(e="",t=0)=>{let l=e.length;return 3===t&&2===l?(e=[+e[0],+e[1]],t++):4===t&&l>1?(e=[+e[0],+e.substring(1)],t++):3===t&&l>=3?(e=[+e[0],+e[1],+e.substring(2)],t+=2):e=[+e],{val:e,valueIndex:t}};function Oe(e){if("path"===e.nodeName.toLowerCase())return e;let t=function(e,t=!1){let l,a,n,r,s,i,p,u,h,o,y,c,x,f,g,d,v=[],m=e.nodeName;const M=(e,t=9)=>{const l="svg"!==e.nodeName?e.closest("svg"):e,a=e=>{if(null===e)return 0;let l=96,a=e.match(/([a-z]+)/gi);a=a?a[0]:"";let n,r=parseFloat(e);if(!a)return r;switch(a){case"in":n=l;break;case"pt":n=1/72*96;break;case"cm":n=1/2.54*96;break;case"mm":n=1/2.54*96/10;break;case"em":case"rem":n=16;break;default:n=1}return+(r*n).toFixed(t)};let n=l.getAttribute("width");n=n?a(n):300;let r=l.getAttribute("height");r=n?a(r):150;let s=l.getAttribute("viewBox");s=s?s.replace(/,/g," ").split(" ").filter(Boolean).map(e=>+e):[];let i=s.length?s[2]:n,p=s.length?s[3]:r,u=i/100,h=p/100,o=Math.sqrt((Math.pow(u,2)+Math.pow(h,2))/2),y=["x","width","x1","x2","rx","cx","r"],c=["y","height","y1","y2","ry","cy"];e.getAttributeNames().forEach(t=>{let l=e.getAttribute(t),n=l;if(y.includes(t)||c.includes(t)){let r=y.includes(t)?u:h;r="r"===t&&i!=p?o:r;let s=l.match(/([a-z|%]+)/gi);s=s?s[0]:"",n=l.includes("%")?parseFloat(l)*r:a(l),e.setAttribute(t,+n)}})};M(e);const b=t=>(l={},t.forEach(t=>{l[t]=+e.getAttribute(t)}),l);switch(m){case"path":n=e.getAttribute("d"),v=Qe(n);break;case"rect":a=["x","y","width","height","rx","ry"],({x:r,y:s,width:i,height:p,rx:h,ry:o}=b(a)),h||o?(h=h||o,o=o||h,h>i/2&&(h=i/2),o>p/2&&(o=p/2),v=[{type:"M",values:[r+h,s]},{type:"L",values:[r+i-h,s]},{type:"A",values:[h,o,0,0,1,r+i,s+o]},{type:"L",values:[r+i,s+p-o]},{type:"A",values:[h,o,0,0,1,r+i-h,s+p]},{type:"L",values:[r+h,s+p]},{type:"A",values:[h,o,0,0,1,r,s+p-o]},{type:"L",values:[r,s+o]},{type:"A",values:[h,o,0,0,1,r+h,s]},{type:"Z",values:[]}]):v=[{type:"M",values:[r,s]},{type:"L",values:[r+i,s]},{type:"L",values:[r+i,s+p]},{type:"L",values:[r,s+p]},{type:"Z",values:[]}];break;case"circle":case"ellipse":a=["cx","cy","rx","ry","r"],({cx:y,cy:c,r:u,rx:h,ry:o}=b(a));let t="circle"===m;t?(h=u,o=u):(h=h||u,o=o||u);let l=t&&u>=1?1:h,M=t&&u>=1?1:h;v=[{type:"M",values:[y+h,c]},{type:"A",values:[l,M,0,1,1,y-h,c]},{type:"A",values:[l,M,0,1,1,y+h,c]}];break;case"line":a=["x1","y1","x2","y2"],({x1:x,y1:g,x2:f,y2:d}=b(a)),v=[{type:"M",values:[x,g]},{type:"L",values:[f,d]}];break;case"polygon":case"polyline":let A=e.getAttribute("points").replaceAll(","," ").split(" ").filter(Boolean);for(let e=0;e<A.length;e+=2)v.push({type:0===e?"M":"L",values:[+A[e],+A[e+1]]});"polygon"===m&&v.push({type:"Z",values:[]})}return t?function(e){return e.map(e=>`${e.type} ${e.values.join(" ")}`).join(" ")}(v):v}(e),l=t.map(e=>`${e.type} ${e.values} `).join(" "),a=[...e.attributes].map(e=>e.name),n=document.createElementNS("http://www.w3.org/2000/svg","path");n.setAttribute("d",l);let r=["x","y","cx","cy","dx","dy","r","rx","ry","width","height","points"];return a.forEach(t=>{if(!r.includes(t)){let l=e.getAttribute(t);n.setAttribute(t,l)}}),n}function He(e,{tolerance:t=1,flatBezierToLinetos:l=!0}={}){let a=[e[0]],n={x:e[0].values[0],y:e[0].values[1]},r=n,s=n;e[e.length-1].type.toLowerCase();for(let i=1,p=e.length;i<p;i++){let u=e[i],h=e[i+1]||e[p-1],o="z"===h.type.toLowerCase()?n:{x:h.values[h.values.length-2],y:h.values[h.values.length-1]},{type:y,values:c}=u,x=c.slice(-2);s="Z"!==y?{x:x[0],y:x[1]}:n;let f=o?de([r,s,o],!0):1/0,g=re(r,o),d=f<(g?g/333*t:0),v=!1;if(l||"C"!==y||(d=!1),l&&("C"===y||"Q"===y)){v=Ae([r,..."C"===y?[{x:c[0],y:c[1]},{x:c[2],y:c[3]}]:"Q"===y?[{x:c[0],y:c[1]}]:[],s],{tolerance:t}),v&&i<p-1&&(y="L",u.type="L",u.values=x)}d&&i<p-1&&"A"!==h.type&&("L"===y||l&&v)||(r=s,"M"===y&&(n=s),a.push(u))}return a}function Ue(e){let t=[];for(let l=0,a=e.length;l<a;l++){let a=e[l];if(!a)continue;let{type:n=null,values:r=[]}=a,s=e[l+1]?e[l+1]:null;"M"!==n&&"m"!==n||s&&(!s||"Z"!==s.type&&"z"!==s.type)?t.push(a):s&&l++}return t}function Ve(e){let t={x:e[0].values[0],y:e[0].values[1]},l=t,a=[e[0]];for(let n=1,r=e.length;n<r;n++){let r=e[n],s=e[n-1],i=e[n+1]||null,{type:p,values:u}=r,h="m"===s.type.toLowerCase()&&!i,o=u.length;if(l={x:u[o-2],y:u[o-1]},h||"L"!==p||l.x!==t.x||l.y!==t.y){if(!h&&("l"===p||"v"===p||"h"===p)){if("l"===p?"00"===u.join(""):0===u[0])continue}a.push(r),t=l}}return a}function We(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:r}=t,s=r.length;if(s){let e={type:n,x:r[s-2],y:r[s-1],index:0};e.index=l,a.push(e)}}return a=a.sort((e,t)=>+e.y.toFixed(8)-+t.y.toFixed(8)||e.x-t.x),l=a[0].index,l?Xe(e,l):e}function Je(e,{removeFinalLineto:t=!0,autoClose:l=!0}={}){let a=[],n=e.length,r={x:+e[0].values[0].toFixed(8),y:+e[0].values[1].toFixed(8)},s="z"===e[n-1].type.toLowerCase(),i=e.filter(e=>"L"===e.type),p=e[s?n-2:n-1],u=p.type,h=p.values.slice(-2).map(e=>+e.toFixed(8)),o=h[0]===r.x&&h[1]===r.y;!s&&l&&o&&(e.push({type:"Z",values:[]}),s=!0,n++);let y="L"!==e[1].type&&(!o||"L"===p.type);if(y=!1,!s)return e;let c=0;{let t=[];for(let l=0;l<n;l++){let a=e[l],{type:n,values:r}=a;if(r.length){let a=r.slice(-2),s=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,h={type:n,x:a[0],y:a[1],dist:0,index:0,prevL:s,nextL:i,prevCom:p,nextCom:u};h.index=l,t.push(h)}}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(8)-+t.y.toFixed(8)||e.x-t.x),c=t[0].index;e=c?Xe(e,c):e}return r={x:+e[0].values[0].toFixed(8),y:+e[0].values[1].toFixed(8)},n=e.length,p=e[n-2],u=p.type,h=p.values.slice(-2).map(e=>+e.toFixed(8)),o="L"===u&&h[0]===r.x&&h[1]===r.y,t&&o&&e.splice(n-2,1),a.push(...e),a}function Xe(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,r]=[a.values[0],a.values[1]].map(e=>+e.toFixed(8)),s=l?e[t-2]:e[t-1],i=s.values.length,[p,u]=[s.values[i-2],s.values[i-1]].map(e=>+e.toFixed(8));!l||n==p&&r==u||(e.pop(),e.push({type:"L",values:[n,r]},{type:"Z",values:[]}))}(e),l=t+1<e.length-1?t+1:e.length-1-n;let r,s,i=e.slice(l),p=e.slice(0,l);return p.shift(),r=p[p.length-1].values||[],s=[r[r.length-2],r[r.length-1]],n&&(i.pop(),p.push({type:"Z",values:[]})),e=[{type:"M",values:s},...i,...p]}function Ye(e=[],t=.666){let l=e.length;for(let a=1;a<l;a++){let l=e[a],n=e[a-1],{type:r,values:s}=l;e[a+1]&&e[a+1];let i=!1;if("C"===r){let l={x:s[0],y:s[1]},r={x:s[2],y:s[3]},p=n.values.slice(-2),u={x:p[0],y:p[1]},h={x:s[4],y:s[5]},o=se(u,h),y=se(u,l),c=se(h,r),x=se(l,r),f=O(u,l,h,r,!1),g=f?O(u,l,h,r,!0):null;if(f&&!g){O(h,H(h,r,3),u,l,!0)&&(i=!0)}y/o<.3&&c/o>.4&&(l=U([u,l],1+t/2),r=U([h,r],t),e[a].values[0]=l.x,e[a].values[1]=l.y,e[a].values[2]=r.x,e[a].values[3]=r.y),(g||f&&x<o/5)&&(i=!0),i&&(l=U([u,f],t),r=U([h,f],t),e[a].values[0]=l.x,e[a].values[1]=l.y,e[a].values[2]=r.x,e[a].values[3]=r.y)}}return e}function Ge(e,t,l=!0,a=!0){if(!Array.isArray(e)||void 0!==e[0].x){if(void 0===e[0].x)throw Error("Not a valid point array");e=(e=>Array.from(e).map(e=>[e.x,e.y]))(e)}if(1===(e=e.filter(function(t,l){return 0===l||!t.every((t,a)=>t===e[l-1][a])})).length)return[];if(2===e.length)return[{type:"L",values:[e[0][0],e[0][1]]},{type:"L",values:[e[1][0],e[1][1]]}];let n,r,s=e.length,i=at(e[1],e[0]),p=at(e[s-2],e[s-1]),u=(e=>{let t=[];return e.forEach(e=>{let l=e[1],a=e[2],n=e[3],r={type:"C",values:[l[0],l[1],a[0],a[1],n[0],n[1]]};t.push(r)}),t})(_e(e,i,p,t));if(l){let t=u.length,l=u[0],i=u[t-1],p={x:e[0][0],y:e[0][1]},h={x:e[1][0],y:e[1][1]},o=e[2]?{x:e[2][0],y:e[2][1]}:null;o&&(n={x:l.values[0],y:l.values[1]},n=Ke(n,p,h,o),l.values[0]=n.x,l.values[1]=n.y);let y={x:e[s-1][0],y:e[s-1][1]},c={x:e[s-2][0],y:e[s-2][1]},x=e[s-3]?{x:e[s-3][0],y:e[s-3][1]}:null;x&&(r={x:i.values[2],y:i.values[3]},r=Ke(r,y,c,x),i.values[2]=r.x,i.values[3]=r.y),a&&(u=function(e=[],t=.666){let l=e.length;for(let a=0;a<l;a++){let l=e[a],n=e[a-1]||null,{type:r,values:s}=l;e[a+1]&&e[a+1];let i=!1;if("C"===r){let l={x:s[0],y:s[1]},r={x:s[2],y:s[3]},p=n.values.slice(-2),u={x:p[0],y:p[1]},h={x:s[4],y:s[5]},o=se(u,h);se(u,l),se(h,r);let y=se(l,r),c=O(u,l,h,r,!1);c&&(c&&O(u,l,h,r,!0)||y<o/5)&&(i=!0),i&&(l=U([u,c],t),r=U([h,c],t),e[a].values[0]=l.x,e[a].values[1]=l.y,e[a].values[2]=r.x,e[a].values[3]=r.y)}}return e}([{type:"M",values:[e[0][0],e[0][1]]},...u]),u.shift())}return u}function Ke(e,t,l,a){let n=Z(t,l),r=Z(t,a)-n;return e=J(e,t.x,t.y,-r)}let _e=(e,t,l,a)=>{let n;if(2===e.length){let a=.333*ne(e[0],e[1],!0);return n=[e[0],rt(e[0],st(t,a)),rt(e[1],st(l,a)),e[1]],[n]}let r=function(e){let t=[],l=e.length,a=e[0],n=e[1],r=0,s=0;for(let i=0;i<l;i++)n=e[i],r=s+ne(n,a,!0),t.push(r),s=r,a=n;return t=t.map(function(e){return e/s}),t}(e),s=et(e,r,r,t,l);n=s[0];let i=s[1],p=s[2];if(0===i||i<a)return[n];if(i<a*a){let s=r,u=i,h=p;for(let o=0;o<20;o++){s=tt(n,e,s);let o=et(e,r,s,t,l);if(n=o[0],i=o[1],p=o[2],i<a)return[n];if(p===h){let e=i/u;if(e>.9999&&e<1.0001)break}u=i,h=p}}let u=[],h=nt(e[p-1],e[p+1]);if(h.every(function(e){return 0===e})){h=nt(e[p-1],e[p]);let t=[-h[1],h[0]];h[0]=t[0],h[1]=t[1]}let o=function(e){let t=Math.sqrt(e[0]*e[0]+e[1]*e[1]);return 0===t?[0,0]:[e[0]/t,e[1]/t]}(h),y=st(o,-1);return u=u.concat(_e(e.slice(0,p+1),t,o,a)),u=u.concat(_e(e.slice(p),y,l,a)),u};const et=(e,t,l,a,n)=>{let r,s,i;r=((e,t,l,a)=>{let n,r,s,i,p=e[0],u=e[e.length-1],h=[p,null,null,u],o=function(e){let t=[];for(;e--;)t.push([0,0]);return t}(t.length),y=t.length;for(let e=0;e<y;e++)s=t[e],i=1-s,n=o[e],n[0]=st(l,3*s*(i*i)),n[1]=st(a,3*i*(s*s));let c=[[0,0],[0,0]],x=[0,0],f=e.length;for(let l=0;l<f;l++)s=t[l],n=o[l],c[0][0]+=it(n[0],n[0]),c[0][1]+=it(n[0],n[1]),c[1][0]+=it(n[0],n[1]),c[1][1]+=it(n[1],n[1]),r=nt(e[l],U([p,p,u,u],s)),x[0]+=it(n[0],r),x[1]+=it(n[1],r);let g=c[0][0]*c[1][1]-c[1][0]*c[0][1],d=c[0][0]*x[1]-c[1][0]*x[0],v=x[0]*c[1][1]-x[1]*c[0][1],m=0===g?0:v/g,M=0===g?0:d/g,b=ne(p,u,!0),A=1e-6*b;return m<A||M<A?(h[1]=rt(p,st(l,.333*b)),h[2]=rt(u,st(a,.333*b))):(h[1]=rt(p,st(l,m)),h[2]=rt(u,st(a,M))),h})(e,l,a,n);let p=function(e,t,l){let a,n,r,s,i,p,u;n=0,r=Math.floor(.5*e.length);let h=function(e,t){let l,a=[0],n=e[0],r=0;for(let s=1;s<=t;s++)l=U(e,s/t),r+=ne(l,n,!0),a.push(r),n=l;return a=a.map(function(e){return e/r}),a}(t,10),o=e.length;for(i=0;i<o;i++)p=e[i],u=lt(l[i],h,10),s=nt(U(t,u),p),a=s[0]*s[0]+s[1]*s[1],a>n&&(n=a,r=i);return[n,r]}(e,r,t);return s=p[0],i=p[1],[r,s,i]};function tt(e,t,l){return l.map((l,a)=>function(e,t,l){let a=U(e,l),n=a[0]-t[0],r=a[1]-t[1],s=pt(e,l),i=n*s[0]+r*s[1],p=s[0]*s[0]+s[1]*s[1],u=pt(e,l,!0),h=2*(n*u[0]+r*u[1]),o=p+h;if(Math.abs(o)<1e-10)return l;return l-i/o}(e,t[a],l))}function lt(e,t,l){if(e<0)return 0;if(e>1)return 1;let a,n,r,s,i;for(let p=1;p<=l;p++)if(e<=t[p]){s=(p-1)/l,r=p/l,n=t[p-1],a=t[p],i=(e-n)/(a-n)*(r-s)+s;break}return i}function at(e,t){let l=e[0]-t[0],a=e[1]-t[1],n=Math.sqrt(l*l+a*a);return 0===n?[0,0]:[l/n,a/n]}function nt(e,t){return[e[0]-t[0],e[1]-t[1]]}function rt(e,t){return[e[0]+t[0],e[1]+t[1]]}function st(e,t){return[e[0]*t,e[1]*t]}function it(e,t){return e[0]*t[0]+e[1]*t[1]}function pt(e,t,l=!1){let a,n,r=e[0],s=e[1],i=e[2],p=e[3],u=t,h=1-u,o=h*h,y=u*u;return l?(a=6*h*(i[0]-2*s[0]+r[0])+6*u*(p[0]-2*i[0]+s[0]),n=6*h*(i[1]-2*s[1]+r[1])+6*u*(p[1]-2*i[1]+s[1])):(a=3*o*(s[0]-r[0])+6*h*u*(i[0]-s[0])+3*y*(p[0]-i[0]),n=3*o*(s[1]-r[1])+6*h*u*(i[1]-s[1])+3*y*(p[1]-i[1])),[a,n]}function ut(e,{debug:t=!1,width:l=0,height:a=0,denoise:n=.9,keepCorners:r=!0,keepExtremes:s=!0,keepInflections:i=!1,manhattan:p=!1,absolute:u=!1,closed:h=!0,tolerance:o=1}={}){let y=s||r?function(e,{x:t=0,y:l=0,width:a=0,height:n=0,debug:r=!1}={}){let s=e.length,i=ce(e);a&&n||({x:t,y:l,width:a,height:n}=i);let p=.01*(a+n);for(let t=0;t<s;t++){let l=t>0?e[t-1]:e[s-1],a=e[t],n=de([l,a,t<s-1?e[t+1]:e[s-1]],!1);a.area=n,a.dist=se(l,a)}for(let t=0;t<s;t++){t>1?e[t-2]:e[s-1];let l=t>0?e[t-1]:e[s-1],a=e[t],n=t<s-1?e[t+1]:e[s-1],r=ce([l,n]);re(l,n);let u=Math.abs(l.area),h=Math.abs(a.area),o=Math.abs(n.area),y=!1,c=!a.area||h<p,{left:x,right:f,top:g,bottom:d}=r,v=a.x<=x||a.x>=f||a.y<=g||a.y>=d,m=a.x===i.left||a.x===i.right||a.y===i.top||a.y===i.bottom;se(a,l);let M=a.y===l.y&&a.x!==l.x,b=a.x===l.x&&a.y!==l.y;
12
10
  //!isCloseExtreme &&
13
- (M||b)&&(m=!0);let A=l.area<0&&a.area>0||l.area>0&&a.area<0,C=A&&!c;if(y=C,v&&!l.isDirChange&&(m=!0),b&&l.isHorizontal&&(l.isCorner=!0,l.isExtreme=!1,m=!1),C&&(l.isDirChange||l.isExtreme)&&(C=!1,a.isDirChange=!1),l.isExtreme&&h>o&&!C&&a.isHorizontal,m||A||h>u){let e=R(a,n,l),{deltaAngleDeg:t}=e;t=Math.abs(t),y=!(t<3||t>160)}a.isCorner=y,a.isExtreme=m,a.isHorizontal=M,a.isVertical=b,a.isDirChange=C}let u=[],h=[];for(let t=0;t<e.length;t++){let l=e[t],a=e[t+1]||null,n=e[t+2]||null,r=[];if(a&&a.isExtreme&&l.isExtreme&&!l.isCorner){let e=a.dist<2*p&&!a.isCorner,s=n&&n.isExtreme&&n.dist<2*p&&!n.isCorner;if(e&&!s?r.push(l,a):s&&r.push(l,a,n),r.length){let e=r.reduce((e,t)=>e+t.x,0)/r.length,a=r.reduce((e,t)=>e+t.y,0)/r.length;l.x=e,l.y=a,t+=r.length-1}}(l.isExtreme||l.isCorner||l.isDirChange)&&h.push(u.length),u.push(l)}let o=u.length,y=u[0],c=u[o-1],x=se(y,c)<2*p;return y.isExtreme&&c.isExtreme&&x&&(c.x=y.x,c.y=y.y),u}(e,{debug:!1}):e,c=s||r?function(e,{closed:t=!0,keepCorners:l=!0,keepExtremes:a=!0,keepInflections:n=!1}={}){let r=[],s=[e[0]],i=e.length;for(let t=1;t<i;t++){t>0?e[t-1]:e[i-1];let n=e[t],p=t<i-1?e[t+1]:e[i-1];s.push(n),t>0&&(a&&p.isExtreme||l&&p.isCorner)&&(r.push(s),s=[])}return!r.length&&e.length>1&&(r=[e]),r}(y,{keepCorners:r,keepExtremes:s,keepInflections:i}):[y],x=l&&a?(l+a)/2*.004*o:2.5;x=2;let f=function(e=[],{closed:t=!0,tolerance:l=1}={}){let a=e.length,n=[{type:"M",values:[e[0][0].x,e[0][0].y]}];for(let t=0;t<a;t++){let a=e[t],r=e[t+1]?e[t+1]:null,s=[],i=a.length;a[a.length-1],r&&a.push(r[0]),i<2||2===i&&a[1].isExtreme?(a[a.length-1],s=a.map(e=>({type:"L",values:[e.x,e.y]}))):s=Ge(a,l),n.push(...s)}t&&n.push({type:"Z",values:[]});return function(e){let t=e.length;for(let l=1;l<t;l++){let t=e[l],a=e[l+1]||null,{type:n,values:r}=t;if("C"===n&&a&&"C"===a.type){let n=a.values;r[0],r[1];let s={x:r[2],y:r[3]},i={x:r[4],y:r[5]},p={x:n[0],y:n[1]};n[2],n[3];let u,h,o=Math.abs(s.x-i.x),y=Math.abs(s.y-i.y),c=Math.abs(p.x-i.x),x=Math.abs(p.y-i.y),f=.02*se(p,s),g=y<f&&o>f,d=x<f&&c>f,v=o<f&&y>f,m=c<f&&x>f;(g||v)&&(u=g?{x:t.values[2],y:i.y}:v?{x:i.x,y:t.values[3]}:{x:t.values[2],y:t.values[3]},t.values[2]=u.x,t.values[3]=u.y),(d||m)&&(h=d?{x:a.values[0],y:i.y}:m?{x:i.x,y:a.values[1]}:{x:a.values[0],y:a.values[1]},e[l+1].values[0]=h.x,e[l+1].values[1]=h.y)}}}(n),n}(c,{closed:h,tolerance:2});return f}function ht(e,{threshold:t=null,tolerance:l=1}={}){if(!t){let l=function(e){let t=1/0,l=-1/0,a=1/0,n=-1/0;const r=e=>{e.x<t&&(t=e.x),e.x>l&&(l=e.x),e.y<a&&(a=e.y),e.y>n&&(n=e.y)};for(let t=0;t<e.length;t++){let l=e[t],{type:a,values:n}=l,s=n.length,i=(e[t-1]?e[t-1]:e[t]).values,p=i.length;if(s){let e={x:i[p-2],y:i[p-1]},t={x:n[s-2],y:n[s-1]};if(r(t),"C"===a||"Q"===a){let l={x:n[0],y:n[1]},s="C"===a?{x:n[2],y:n[3]}:l,i="C"===a?[e,l,s,t]:[e,l,t];K(i).forEach(e=>{let t=U(i,e);r(t)})}else"A"===a&&_(e,n).forEach(e=>{r(e)})}}return{x:t,y:a,width:l-t,height:n-a}}(e);t=.05*(l.width+l.height)}let a=e.length;for(let n=0;n<a;n++){let a=e[n],{type:r,values:s,extreme:i,corner:p=!1,dimA:u,p0:h,p:o}=a,y=e[n+1]?e[n+1]:null,c=e[n+2]?e[n+2]:null,x=(y?se(o,y.p):1/0)<t,f=(c?se(c.p,y.p):1/0)<1*t;if(y&&c&&"C"===r&&"C"===y.type&&i&&c.extreme&&(f||x)){let a=me(y,c,t,l,!1);if(1===a.length){a=a[0],e[n+1]=null,e[n+2].values=[a.cp1.x,a.cp1.y,a.cp2.x,a.cp2.y,a.p.x,a.p.y],e[n+2].cp1=a.cp1,e[n+2].cp2=a.cp2,e[n+2].p0=a.p0,e[n+2].p=a.p,e[n+2].extreme=a.extreme,n++;continue}}if(y&&"C"===r&&"C"===y.type&&i&&x){let e=de([a.p0,a.p,y.p]),t=de([a.p0,a.cp1,a.cp2,a.p]);if(e<0&&t>0||e>0&&t<0)continue}}a=(e=e.filter(Boolean)).length;let n="z"===e[a-1].type.toLowerCase()?a-2:a-1,r=e[n],s=e[n-1]||null,i={x:e[0].values[0],y:e[0].values[1]},p=r.values.slice(-2),u=+p[0].toFixed(8)===+i.x.toFixed(8)&&+p[1].toFixed(8)===+i.y.toFixed(8),h="C"===e[1].type&&e[1].extreme?e[1]:null,o=se(r.p0,r.p)<t;if(s&&"C"===s.type&&o&&u&&h){let a=me(s,r,t,l,!1);1===a.length&&(e[n-1]=a[0],e[n]=null,e=e.filter(Boolean))}return e}function ot(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}function yt(e,{threshold:t=0,tolerance:l=1}={}){let a=e.length,n=[e[0]],r="z"===e[a-1].type.toLowerCase(),s=!!r&&(e[a-1].p.x===e[0].p0.x&&e[a-1].p.y===e[0].p0.y),i=r?2:1,p=e[a-i],u="L"===p.type,h="C"===p.type,o="L"===e[1].type,y="C"===e[1].type,c=r&&y&&(u||s);c&&(e[a-1].values=e[0].values,e[a-1].type="L",u=!0);for(let t=1;t<a;t++){let s=e[t],{type:p}=s,x=e[t+1]?e[t+1]:null;if("L"===p&&x&&"C"===x.type||"C"===p&&x&&"L"===x.type){let c="L"===p?s:null,f=null,g=[],d=0;if(1===t&&y&&u&&(g=[e[1]],c=e[a-1],f=x),!c){n.push(s);continue}r&&h&&o&&t===a-i-1&&(f=e[1],g=[e[a-i]]);for(let l=t+1;l<a;l++){let t=e[l]?e[l]:null,a=e[l-1];if("C"===a.type&&g.push(a),"L"===t.type&&"C"===a.type){f=t;break}d++}if(f){let e=se(c.p0,c.p),a=se(f.p0,f.p);g.length;let r=se(c.p,f.p0),i=de([c.p0,c.p,f.p0,f.p],!1),p=de([g[0].p0,g[0].cp1,g[0].cp2,g[0].p],!1),u=i<0&&p>0||i>0&&p<0,h=.5*r*l,o=h<e&&h<a;if(g.length&&!u&&o){let e=Math.abs(p)<=.005*re(g[0].p0,g[0].p),l=e?null:O(c.p0,c.p,f.p0,f.p,!1);if(!e&&l){let e=.75*se(U([c.p,l,f.p0],.5),1===g.length?U([g[0].p0,g[0].cp1,g[0].cp2,g[0].p],.5):g[0].p);if(h&&e>h&&e>.3*r){n.push(s);continue}{let e={type:"Q",values:[l.x,l.y,f.p0.x,f.p0.y]};e.p0=c.p,e.cp1=l,e.p=f.p0,n.push(c,e),t+=d;continue}}}}}c&&t===a-1&&"L"===p||n.push(s)}return(c||r&&"Z"!==n[n.length-1].type)&&n.push({type:"Z",values:[]}),n}function ct(e){if(e.length<3)return!1;let t=e[0],l=e[Math.floor(e.length/2)],a=e[e.length-1],n=t.x,r=t.y,s=l.x,i=l.y,p=a.x,u=a.y,h=n-s,o=r-i,y=n-p,c=r-u,x=(n*n-s*s+(r*r-i*i))/2,f=(n*n-p*p+(r*r-u*u))/2,g=h*c-o*y;if(Math.abs(g)<1e-10)return console.warn("Points are collinear or numerically unstable"),!1;let d={x:(c*x-o*f)/g,y:(-y*x+h*f)/g},v=ne(d,t),m=R(d,t,a),{deltaAngle:M,startAngle:b,endAngle:A}=m;return{centroid:d,r:v,startAngle:b,endAngle:A,deltaAngle:M}}function xt(e,{threshold:l=0,tolerance:a=1,toCubic:n=!1,debug:r=!1}={}){let s=e.length,i=[e[0]],p=[];for(let l=1;l<s;l++){let a=e[l],{type:s}=a,u=e[l-1],h=e[l+1]?e[l+1]:null,o=e[l+2]?e[l+2]:null,y=e[l+3]?e[l+3]:null,c=null;"C"===a.type||"Q"===a.type?c=a:!h||"C"!==h.type&&"Q"!==h.type||(c=h);let x,f,g,d,v,m=c?"C"===c.type?[c.p0,c.cp1,c.cp2,c.p]:[c.p0,c.cp1,c.p]:[],M=0,b=0,A=!1,C=!1,w=[];if("L"===u.type&&"L"===s&&c&&"L"===o.type&&y&&("L"===y.type||"Z"===y.type)?(x=[a.p0,a.p],f=[o.p0,o.p],g=a.p0,d=o.p,M=de(m,!1),b=de([...x,...f],!1),A=M<0&&b>0||M>0&&b<0,A||(v=U(m,.5),w=[g,v,d],C=!0)):"C"!==s&&"Q"!==s||"L"!==u.type||"C"!==h.type&&"Q"!==h.type||"L"!==o.type||(C=!0,x=[u.p0,u.p],f=[o.p0,o.p],g=u.p,d=o.p0,v=c.p,w=[g,c.p,d]),C){let e=ct(w);if(e){let s,{centroid:u,r:h,deltaAngle:o,startAngle:y,endAngle:c}=e,x=0,f=o>0?1:0,m=Math.abs(o)>Math.PI?1:0;if(ie(J(g,u.x,u.y,.5*o),v)<.05*ie(g,d)){if(s=ze({p0:g,p:d,centroid:u,rx:h,ry:h,xAxisRotation:x,sweep:f,largeArc:m,deltaAngle:o,startAngle:y,endAngle:c}),1===s.length){let e=ke(g,s[0].cp1,s[0].cp2,d);"Q"===e.type&&(n=!0),a=e}if(s.length>1&&(n=!1),n||(a.type="A",a.values=[h,h,x,m,f,d.x,d.y]),a.p0=g,a.p=d,a.extreme=!1,a.corner=!1,r){p=n?[{type:"M",values:[g.x,g.y]},...s]:[{type:"M",values:[g.x,g.y]},{type:"A",values:[h,h,x,m,f,d.x,d.y]}];let e=ve(p);t(markers,e,"orange","0.5%","0.5")}i.push(a),l++;continue}}}i.push(a)}return i}function ft(e=[],{threshold:t=0}={}){let l=e.length,a="z"===e[l-1].type.toLowerCase(),n=a?l-2:l-1,r=e[n],s=r.values.slice(-2),i={x:e[0].values[0],y:e[0].values[1]},p=ie(i,{x:s[0],y:s[1]});if(p&&p<t){let l=e[n].values.length;e[n].values[l-2]=i.x,e[n].values[l-1]=i.y;let a=e[1];if("C"===a.type&&"C"===r.type){let l=Math.abs(a.values[0]-r.values[2]),s=Math.abs(a.values[1]-r.values[3]),p=Math.abs(e[1].values[0]-a.values[0]),u=Math.abs(e[1].values[1]-a.values[1]),h=Math.abs(e[1].values[0]-r.values[2]),o=Math.abs(e[1].values[1]-r.values[3]),y=u<t&&o<t&&l;l&&l<t&&(p<t&&h<t&&s)&&(e[1].values[0]=i.x,e[n].values[2]=i.x),s&&s<t&&y&&(e[1].values[1]=i.y,e[n].values[3]=i.y)}}return e}function gt(e,t=1){let l=[];for(let a=0,n=e.length;a<n;a++){let n=e[a],{type:r,values:s}=n,i={type:r,values:[]};switch(r.toLowerCase()){case"h":case"v":i.values=[s[0]*t];break;case"a":i.values=[s[0]*t,s[1]*t,s[2],s[3],s[4],s[5]*t,s[6]*t];break;default:s.length&&(i.values=s.map((e,l)=>e*t))}l.push(i)}return l}function dt(e,{tolerance:l=1}={}){let a=[],n=[],r=e.length;for(let t=1;t<r;t++){let l=e[t],{type:r,values:s,p0:i,cp1:p=null,cp2:u=null,p:h,extreme:o=null,semiExtreme:y=null,corner:c=null,directionChange:x}=l,f=e[t+1]||null;o||c||f&&f.type!==r?(n.push(l),a.push(n),n=[]):n.push(l)}console.log("!!!chunks",a),function(e){console.log("chunks",e);let l="green";for(let a=0;a<e.length;a++){let n=e[a],r=n.length;l=a%2==0?"orange":"green";let s=n[0],i=n[r-1],p=[{type:"M",values:[s.p0.x,s.p0.y]}];for(let e=0,t=r;e<t;e++){let l=n[e];n[e+1],n[t-1],"C"===s.type&&i.type;let{type:a,values:r,p0:u,cp1:h=null,cp2:o=null,p:y=null,extreme:c,semiExtreme:x=null,corner:f=null}=l;p.push({type:a,values:r})}let u=ve(p);t(markers,u,l,"1%","0.5")}}(a);let s=a.length;for(let e=0;e<s;e++){let t=a[e],l=a[e+1]||null;1===t.length&&l&&l[0].type}a=a.filter(Boolean);let i=[e[0]];for(let e=0;e<a.length;e++){let t=a[e],l=t.length,n=t[0],r=t[l-1],s=.05*se(n.p0,r.p);for(let e=0,a=l;e<a;e++){let p=t[e];t[e+1],t[a-1];let u="C"===n.type&&"C"===r.type,{type:h,values:o,p0:y,cp1:c=null,cp2:x=null,p:f=null,extreme:g,semiExtreme:d=null,corner:v=null}=p,m=null,M=null,b=null,A=null,C=null,w=null,E=[],L=.666,k=null;if(u){let e=Math.abs(n.p0.x-n.cp1.x),t=Math.abs(n.p0.y-n.cp1.y),l=Math.abs(r.p.x-r.cp2.x),a=Math.abs(r.p.y-r.cp2.y),i=e<s&&e<t,p=l<s&&l<a,u=a<s&&l>a;t<s&&e>t&&(n.cp1.y=n.p0.y),u&&(r.cp2.y=r.p.y),i&&(n.cp1.x=n.p0.x),p&&(r.cp2.x=r.p.x)}if(ve([{type:"M",values:[p.p0.x,p.p0.y]},{type:h,values:o}]),1===l||"C"!==h)i.push(p);else{let e=t.filter(e=>e.semiExtreme),l=t.filter(e=>e.directionChange);if(e.length||l.length){if(k=e.length?e[0]:l[0],n.p0.x===n.cp1.x&&n.p0.y===n.cp1.y?n.cp1=U([n.p0,n.cp1,n.cp2,n.p],.5):r.p.x===r.cp2.x&&r.p.y===r.cp2.y&&(r.cp2=U([r.p0,r.cp1,r.cp2,r.p],.5)),m=O(k.p,k.cp2,n.p0,n.cp1,!1),M=O(k.p,k.cp2,r.p,r.cp2,!1),m&&M){b=U([n.p0,m],L),A=U([r.p,M],L),C=U([k.p,m],L),w=U([k.p,M],L),E=[{type:"M",values:[n.p0.x,n.p0.y]},{type:"C",values:[b.x,b.y,C.x,C.y,k.p.x,k.p.y]},{type:"C",values:[w.x,w.y,A.x,A.y,r.p.x,r.p.y]}],ve(E),i.push({type:"C",values:[b.x,b.y,C.x,C.y,k.p.x,k.p.y],p0:n.p0,cp1:b,cp2:C,p:k.p,dimA:se(n.p0,k.p)},{type:"C",values:[w.x,w.y,A.x,A.y,r.p.x,r.p.y],p0:k.p,cp1:w,cp2:A,p:r.p,extreme:!0,dimA:se(k.p,r.p)});break}}else i.push(p)}}}return i}function vt(e){for(let t=1,l=e.length;t<l;t++){let l=e[t],{type:a,values:n,p0:r,cp1:s=null,cp2:i=null,p:p=null}=l;if("C"===a){let a=ke(r,s,i,p);"Q"===a.type&&(a.extreme=l.extreme,a.corner=l.corner,a.dimA=l.dimA,a.squareDist=l.squareDist,e[t]=a)}}return e}function mt(e,{areaThreshold:t=2.5}={}){for(let l=0,a=e.length;l<a;l++){let a=e[l],n=e[l+1]||null,{type:r,values:s,p0:i,cp1:p=null,cp2:u=null,p:h=null}=a;if("C"===r&&n&&"C"===n.type){let a=Mt(i,p,u,h,t),r=Mt(n.p0,n.cp1,n.cp2,n.p,t);if(a.isArc&&r.isArc){let t=.01*se(i,n.p),s=Math.abs(n.p.x-i.x),p=Math.abs(n.p.y-i.y),u=p<t&&s>t,o=s<t&&p>t,{rx:y,ry:c}=a,x=de([i,h,n.p])<0?0:1;if(o||u){y=Math.min(y,r.rx),c=Math.min(c,r.ry),e[l]=null,e[l+1].type="A",e[l+1].values=[y,c,0,0,x,n.p.x,n.p.y];continue}}}}return e=e.filter(Boolean)}function Mt(e,t,l,a,n=7.5){let r,s={type:"C",values:[t.x,t.y,l.x,l.y,a.x,a.y]},i=0,p=!1,u=Z(e,t,!0),h=Z(a,l,!0),o=180*Math.abs(u-h)/Math.PI,y=0,c=0;if(Math.abs(o%180-90)<3){r=O(e,J(t,e.x,e.y,-.5*Math.PI),a,J(l,a.x,a.y,.5*Math.PI),!1);let u=O(e,t,a,l,!1);if(u){let r=ne(e,u),h=ne(a,u),o=+Math.max(r,h).toFixed(8),x=+Math.min(r,h).toFixed(8);y=x,c=o;let f=de([e,t,l,a])<0?0:1,g=Math.abs(a.x-e.x)>Math.abs(a.y-e.y);100/y*Math.abs(y-c)<5&&(y=o,c=y),g&&(y=o,c=x);let d=ge([{type:"M",values:[e.x,e.y]},{type:"C",values:[t.x,t.y,l.x,l.y,a.x,a.y]}]),v={type:"A",values:[y,c,0,0,f,a.x,a.y]};i=Math.PI*(y*c)/4,i-=Math.abs(de([e,a,u])),function(e,t){let l=Math.abs(e-t);return Math.abs(100-100/e*(e+l))}(d,i)<n&&(p=!0,s=v)}}return{com:s,isArc:p,area:i,rx:y,ry:c,centroid:r}}function bt(e,{angles:t=[],split:l=0,getPathData:a=!0,width:n=0,height:r=0}={}){let s=e.length,i={x:e[0].values[0],y:e[0].values[1]},p=i,u=[],h=[p],o=0;if(l=l||1,n&&r)o=.025*(n+r)/l;else{o=e.map(e=>e.dimA||0).filter(Boolean).sort()[0]}for(let t=1;t<s;t++){let a=e[t],n=e[t+1]||null,{type:r,values:s}=a,u=s.length,y=u?{x:s[u-2],y:s[u-1]}:i;if("C"===r||"Q"===r){let e={x:s[0],y:s[1]},t="C"===r?{x:s[2],y:s[3]}:e,n="C"===r?[p,e,t,y]:[p,e,y],i=a.dimA;l=Math.ceil(i/o);let u=[];for(let e=1;e<l;e++)u.push(1/l*e);u.forEach(e=>{let t=U(n,e);h.push(t)})}"M"===r&&(i=y),y.area=a.cptArea||0,y.isExtreme=a.extreme||!1,y.isCorner=a.corner||!1,y.isDirChange=a.directionChange||!1,h.push(y),a.extreme||a.corner||n&&n.type,p=y}return h=function(e,{quality:t=.9,width:l=0,height:a=0,absolute:n=!1,manhattan:r=!1,exclude:s=[]}={}){"string"==typeof t&&(n=!0,t=parseFloat(t));if(e.length<4||(!n&&t)>=1)return e;let i=t;if(!n){if(i=1-t,!l&&!a){let t=pe(e,12);({width:l,height:a}=ce(t))}i=r?.05*(l+a)*(1-t):(i*((l+a)/2/25))**2}let p,u=e[0],h=[u],o=e.length,y=s.length,c=0;for(let t=1;t<o;t++)p=e[t],c=r?se(u,p):re(u,p),!(c<i)||y&&s.includes(t)?(h.push(p),u=p):u=p;return u.x!==p.x&&u.y!==p.y&&h.push(p),h}(h,{quality:.5,width:n,height:r}),u=function(e,t=!0){let l=[{type:"M",values:[e[0].x,e[0].y]},...e.slice(1).map(e=>({type:"L",values:[e.x,e.y]}))];return t&&l.push({type:"Z",values:[]}),l}(h),a?u:h}function At(e="",{getObject:t=!1,toAbsolute:l=!0,toRelative:a=!0,toShorthands:n=!0,quadraticToCubic:r=!0,arcToCubic:s=!1,cubicToArc:i=!1,simplifyBezier:p=!0,optimizeOrder:u=!0,autoClose:h=!0,removeZeroLength:o=!0,refineClosing:y=!0,removeColinear:c=!0,flatBezierToLinetos:x=!0,revertToQuadratics:f=!0,refineExtremes:g=!0,simplifyCorners:d=!1,keepExtremes:v=!0,keepCorners:m=!0,extrapolateDominant:M=!0,keepInflections:b=!1,addExtremes:A=!1,addSemiExtremes:C=!1,smoothPoly:w=!1,harmonizeCpts:E=!1,toPolygon:L=!1,removeOrphanSubpaths:k=!1,simplifyRound:P=!1,scale:S=1,scaleTo:I=0,crop:D=!1,alignToOrigin:F=!1,decimals:q=3,autoAccuracy:$=!0,minifyD:z=0,tolerance:T=1,reverse:Q=!1,mergePaths:B=!1,removeHidden:j=!0,removeUnused:N=!0,shapesToPaths:Z=!0,tMin:R=0,tMax:O=1,redraw:H=!1}={}){T=Math.max(.1,T),S=Math.max(.001,S);let U=function(e){let t="string";if(Array.isArray(e))return e[0]?.type&&e[0]?.values?"pathData":"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),W="",J=0,X=0,Y=0,G={},K="",_="svgMarkup"===U?1:0,ee=[];J=e.length;let te={x:0,y:0,width:0,height:0},le={x:0,y:0,width:0,height:0},ae=[],ne=[];if(_){if(W=function(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","fill","stroke","stroke-width","stroke-linecap","stroke-linejoin"]);let r=["metadata","script"];return n.querySelectorAll("*").forEach(e=>{let t=e.nodeName,a=e.getAttribute("style")||"",n=!!a&&a.trim().includes("display:none"),s=e.getAttribute("display")&&"none"===e.getAttribute("display")||n;t.includes(":")||r.includes(t)||l&&s?e.remove():function(e){[...e.attributes].map(e=>e.name).forEach(t=>{t.includes(":")&&e.removeAttribute(t)})}(e)}),t?n:ot(n)}(e,{returnDom:!0,removeHidden:j,removeUnused:N}),Z){W.querySelectorAll("polygon, polyline, line, rect, circle, ellipse").forEach(e=>{let t=Oe(e);e.replaceWith(t)})}W.querySelectorAll("path").forEach(e=>{ee.push({d:e.getAttribute("d"),el:e})}),te=function(e=null,t=-1){const l=e=>e&&isNaN(e)?e.match(/[^\d|.]+/g)[0]:"";if(!e)return!1;let a=e.hasAttribute("width"),n=e.hasAttribute("height"),r=e.hasAttribute("viewBox"),s=a?e.getAttribute("width"):0,i=n?e.getAttribute("height"):0,p=!!a&&l(s),u=!!n&&l(s),h=s?s.includes("%")?0:parseFloat(s):300,o=i?i.includes("%")?0:parseFloat(i):150,y=r?e.getAttribute("viewBox").split(/,| /).filter(Boolean).map(Number):[0,0,h,o];return t>-1&&([h,o]=[h,o].map(e=>+e.toFixed(t)),y=y.map(e=>+e.toFixed(t))),{x:y[0],y:y[1],width:y[2],height:y[3],w:h,h:o,hasViewBox:r,hasWidth:a,hasHeight:n,widthUnit:p,heightUnit:u}}(W,q)}else{if("pathDataString"===U)K=e;else if("polyString"===U)K="M"+e;else if("pathData"===U){K=e,J=K.map(e=>`${e.type} ${e.values.join(" ")}`).join(" ").length}ee.push({d:K,el:null})}let re={toRelative:a,toShorthands:n,decimals:q},se=[];for(let e=0,t=ee.length;t&&e<t;e++){let t=ee[e],{d:a,el:n}=t,j=Qe(a,{quadraticToCubic:r,toAbsolute:l,arcToCubic:s}),N=w||L?ce(V(j)):null;if(1!==S||I){if(I)if(te.width&&!D)S=I/te.width;else{let e=j.map(e=>({type:e.type,values:e.values}));e=Pe(e,{arcToCubic:!0}),e=ye(e);let t=ce(V(e));ae.push(t.x,t.x+t.width),ne.push(t.y,t.y+t.height);let l=I/t.width;S=l}j=gt(j,S)}let Z=j.length;k&&(j=Ue(j));let U=ue(j),W=U.length,G=[];for(let e=0;e<W;e++){let t=U[e];if(L){p=!1,w=!1,E=!1,t=He(t);let e=Le(t),{bb:l,pathData:a}=e;t=a,t=bt(t,{angles:[],split:1,width:N.width,height:N.height,getPathData:!0})}if(w){let e=Array.from(new Set(t.map(e=>e.type))).join(""),l=!/[acqts]/gi.test(e),a=/[z]/gi.test(e);if(l){t=Ve(t),t=ut(V(t),{denoise:.8,tolerance:T,width:N.width,height:N.height,manhattan:!1,absolute:!1,keepCorners:m,keepExtremes:v,keepInflections:b,closed:a})}}E&&(t=Ye(t)),(c||o)&&(t=Ve(t)),H&&(A=!0,C=!0,d=!1,m=!0,v=!0,u=!0,R=0,O=0),u&&(t=We(t)),c&&(t=He(t,{tolerance:T,flatBezierToLinetos:!1})),(A||C)&&(t=ye(t,{tMin:R,tMax:O,addExtremes:A,addSemiExtremes:C,angles:[30]}));let l=Le(t,{detectSemiExtremes:C}),{pathData:a,bb:n,dimA:r}=l;if(ae.push(n.x,n.x+n.width),ne.push(n.y,n.y+n.height),y&&(a=ft(a,{threshold:.001*r})),a=p?Me(a,{simplifyBezier:p,keepInflections:b,keepExtremes:v,keepCorners:m,extrapolateDominant:M,revertToQuadratics:f,tolerance:T,reverse:Q}):a,g){a=ht(a,{threshold:.05*(n.width+n.height),tolerance:T})}if(H&&(n.width,n.height,a=dt(a,{tolerance:T,threshold:.001*r})),i&&(a=mt(a,{areaThreshold:2.5})),c&&x&&(a=He(a,{tolerance:T,flatBezierToLinetos:x})),d){a=yt(a,{threshold:.1*(n.width+n.height),tolerance:T})}P&&(a=xt(a)),f&&(a=vt(a)),u&&(a=Je(a,{autoClose:h})),G.push({pathData:a,bb:n})}let K=Math.min(...ae),_=Math.min(...ne);le={x:K,y:_,width:Math.max(...ae)-K,height:Math.max(...ne)-_};let ie=le.height>le.width;if(u&&(G=ie?G.sort((e,t)=>e.bb.y-t.bb.y||e.bb.x-t.bb.x):G.sort((e,t)=>e.bb.x-t.bb.x||e.bb.y-t.bb.y)),j=[],G.forEach(e=>{j.push(...e.pathData)}),$&&(q=Ce(j),re.decimals=q),n&&B)se.push(...j);else{j=Pe(j,re),j=Ve(j),F&&(console.log(le),j[0].values[0]=(j[0].values[0]-le.x).toFixed(q),j[0].values[1]=(j[0].values[1]-le.y).toFixed(q),le.x=0,le.y=0);let e=j.length,l=ve(j,z);X=l.length,Y=+(100/J*X).toFixed(2),t.d=l,t.report={original:Z,new:e,saved:Z-e,compression:Y,decimals:q},n&&n.setAttribute("d",l)}}if(_){if(se.length){let e=Pe(se,re);e=Ve(e);let t=ve(e,z);ee[0].el.setAttribute("d",t);for(let e=1;e<ee.length;e++){let t=ee[e].el;t&&t.remove()}!function(e){e.querySelectorAll("g, defs").forEach(e=>{e.children.length||e.remove()})}(W)}if(S){let{x:e,y:t,width:l,height:a,w:n,h:r,hasViewBox:s,hasWidth:i,hasHeight:p,widthUnit:u,heightUnit:h}=te;D&&(e=le.x,t=le.y,l=le.width,a=le.height,n=l,r=a),s&&W.setAttribute("viewBox",[e,t,l,a].map(e=>+(e*S).toFixed(q)).join(" ")),i&&W.setAttribute("width",+(n*S).toFixed(q)+u),p&&W.setAttribute("height",+(r*S).toFixed(q)+h)}W=ot(W),X=W.length,Y=+(100/J*X).toFixed(2),J=+(J/1024).toFixed(3),X=+(X/1024).toFixed(3),G={svgSize:J,svgSizeOpt:X,compression:Y,decimals:q}}else({d:K,report:G}=ee[0]);return t?{svg:W,d:K,report:G,inputType:U,mode:_}:K||W}"undefined"!=typeof window&&(window.svgPathSimplify=At);export{b as PI,l as abs,a as acos,n as asin,r as atan,s as atan2,i as ceil,p as cos,u as exp,h as floor,y as hypot,o as log,c as max,x as min,f as pow,g as random,d as round,v as sin,m as sqrt,At as svgPathSimplify,M as tan};
11
+ (M||b)&&(m=!0);let A=l.area<0&&a.area>0||l.area>0&&a.area<0,C=A&&!c;if(y=C,v&&!l.isDirChange&&(m=!0),b&&l.isHorizontal&&(l.isCorner=!0,l.isExtreme=!1,m=!1),C&&(l.isDirChange||l.isExtreme)&&(C=!1,a.isDirChange=!1),l.isExtreme&&h>o&&!C&&a.isHorizontal,m||A||h>u){let e=R(a,n,l),{deltaAngleDeg:t}=e;t=Math.abs(t),y=!(t<3||t>160)}a.isCorner=y,a.isExtreme=m,a.isHorizontal=M,a.isVertical=b,a.isDirChange=C}let u=[],h=[];for(let t=0;t<e.length;t++){let l=e[t],a=e[t+1]||null,n=e[t+2]||null,r=[];if(a&&a.isExtreme&&l.isExtreme&&!l.isCorner){let e=a.dist<2*p&&!a.isCorner,s=n&&n.isExtreme&&n.dist<2*p&&!n.isCorner;if(e&&!s?r.push(l,a):s&&r.push(l,a,n),r.length){let e=r.reduce((e,t)=>e+t.x,0)/r.length,a=r.reduce((e,t)=>e+t.y,0)/r.length;l.x=e,l.y=a,t+=r.length-1}}(l.isExtreme||l.isCorner||l.isDirChange)&&h.push(u.length),u.push(l)}let o=u.length,y=u[0],c=u[o-1],x=se(y,c)<2*p;return y.isExtreme&&c.isExtreme&&x&&(c.x=y.x,c.y=y.y),u}(e,{debug:!1}):e,c=s||r?function(e,{closed:t=!0,keepCorners:l=!0,keepExtremes:a=!0,keepInflections:n=!1}={}){let r=[],s=[e[0]],i=e.length;for(let t=1;t<i;t++){t>0?e[t-1]:e[i-1];let n=e[t],p=t<i-1?e[t+1]:e[i-1];s.push(n),t>0&&(a&&p.isExtreme||l&&p.isCorner)&&(r.push(s),s=[])}return!r.length&&e.length>1&&(r=[e]),r}(y,{keepCorners:r,keepExtremes:s,keepInflections:i}):[y],x=l&&a?(l+a)/2*.004*o:2.5;x=2;let f=function(e=[],{closed:t=!0,tolerance:l=1}={}){let a=e.length,n=[{type:"M",values:[e[0][0].x,e[0][0].y]}];for(let t=0;t<a;t++){let a=e[t],r=e[t+1]?e[t+1]:null,s=[],i=a.length;a[a.length-1],r&&a.push(r[0]),i<2||2===i&&a[1].isExtreme?(a[a.length-1],s=a.map(e=>({type:"L",values:[e.x,e.y]}))):s=Ge(a,l),n.push(...s)}t&&n.push({type:"Z",values:[]});return function(e){let t=e.length;for(let l=1;l<t;l++){let t=e[l],a=e[l+1]||null,{type:n,values:r}=t;if("C"===n&&a&&"C"===a.type){let n=a.values;r[0],r[1];let s={x:r[2],y:r[3]},i={x:r[4],y:r[5]},p={x:n[0],y:n[1]};n[2],n[3];let u,h,o=Math.abs(s.x-i.x),y=Math.abs(s.y-i.y),c=Math.abs(p.x-i.x),x=Math.abs(p.y-i.y),f=.02*se(p,s),g=y<f&&o>f,d=x<f&&c>f,v=o<f&&y>f,m=c<f&&x>f;(g||v)&&(u=g?{x:t.values[2],y:i.y}:v?{x:i.x,y:t.values[3]}:{x:t.values[2],y:t.values[3]},t.values[2]=u.x,t.values[3]=u.y),(d||m)&&(h=d?{x:a.values[0],y:i.y}:m?{x:i.x,y:a.values[1]}:{x:a.values[0],y:a.values[1]},e[l+1].values[0]=h.x,e[l+1].values[1]=h.y)}}}(n),n}(c,{closed:h,tolerance:2});return f}function ht(e,{threshold:t=null,tolerance:l=1}={}){if(!t){let l=function(e){let t=1/0,l=-1/0,a=1/0,n=-1/0;const r=e=>{e.x<t&&(t=e.x),e.x>l&&(l=e.x),e.y<a&&(a=e.y),e.y>n&&(n=e.y)};for(let t=0;t<e.length;t++){let l=e[t],{type:a,values:n}=l,s=n.length,i=(e[t-1]?e[t-1]:e[t]).values,p=i.length;if(s){let e={x:i[p-2],y:i[p-1]},t={x:n[s-2],y:n[s-1]};if(r(t),"C"===a||"Q"===a){let l={x:n[0],y:n[1]},s="C"===a?{x:n[2],y:n[3]}:l,i="C"===a?[e,l,s,t]:[e,l,t];K(i).forEach(e=>{let t=U(i,e);r(t)})}else"A"===a&&_(e,n).forEach(e=>{r(e)})}}return{x:t,y:a,width:l-t,height:n-a}}(e);t=.05*(l.width+l.height)}let a=e.length;for(let n=0;n<a;n++){let a=e[n],{type:r,values:s,extreme:i,corner:p=!1,dimA:u,p0:h,p:o}=a,y=e[n+1]?e[n+1]:null,c=e[n+2]?e[n+2]:null,x=(y?se(o,y.p):1/0)<t,f=(c?se(c.p,y.p):1/0)<1*t;if(y&&c&&"C"===r&&"C"===y.type&&i&&c.extreme&&(f||x)){let a=me(y,c,t,l,!1);if(1===a.length){a=a[0],e[n+1]=null,e[n+2].values=[a.cp1.x,a.cp1.y,a.cp2.x,a.cp2.y,a.p.x,a.p.y],e[n+2].cp1=a.cp1,e[n+2].cp2=a.cp2,e[n+2].p0=a.p0,e[n+2].p=a.p,e[n+2].extreme=a.extreme,n++;continue}}if(y&&"C"===r&&"C"===y.type&&i&&x){let e=de([a.p0,a.p,y.p]),t=de([a.p0,a.cp1,a.cp2,a.p]);if(e<0&&t>0||e>0&&t<0)continue}}a=(e=e.filter(Boolean)).length;let n="z"===e[a-1].type.toLowerCase()?a-2:a-1,r=e[n],s=e[n-1]||null,i={x:e[0].values[0],y:e[0].values[1]},p=r.values.slice(-2),u=+p[0].toFixed(8)===+i.x.toFixed(8)&&+p[1].toFixed(8)===+i.y.toFixed(8),h="C"===e[1].type&&e[1].extreme?e[1]:null,o=se(r.p0,r.p)<t;if(s&&"C"===s.type&&o&&u&&h){let a=me(s,r,t,l,!1);1===a.length&&(e[n-1]=a[0],e[n]=null,e=e.filter(Boolean))}return e}function ot(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}function yt(e,{threshold:t=0,tolerance:l=1}={}){let a=e.length,n=[e[0]],r="z"===e[a-1].type.toLowerCase(),s=!!r&&(e[a-1].p.x===e[0].p0.x&&e[a-1].p.y===e[0].p0.y),i=r?2:1,p=e[a-i],u="L"===p.type,h="C"===p.type,o="L"===e[1].type,y="C"===e[1].type,c=r&&y&&(u||s);c&&(e[a-1].values=e[0].values,e[a-1].type="L",u=!0);for(let t=1;t<a;t++){let s=e[t],{type:p}=s,x=e[t+1]?e[t+1]:null;if("L"===p&&x&&"C"===x.type||"C"===p&&x&&"L"===x.type){let c="L"===p?s:null,f=null,g=[],d=0;if(1===t&&y&&u&&(g=[e[1]],c=e[a-1],f=x),!c){n.push(s);continue}r&&h&&o&&t===a-i-1&&(f=e[1],g=[e[a-i]]);for(let l=t+1;l<a;l++){let t=e[l]?e[l]:null,a=e[l-1];if("C"===a.type&&g.push(a),"L"===t.type&&"C"===a.type){f=t;break}d++}if(f){let e=se(c.p0,c.p),a=se(f.p0,f.p);g.length;let r=se(c.p,f.p0),i=de([c.p0,c.p,f.p0,f.p],!1),p=de([g[0].p0,g[0].cp1,g[0].cp2,g[0].p],!1),u=i<0&&p>0||i>0&&p<0,h=.5*r*l,o=h<e&&h<a;if(g.length&&!u&&o){let e=Math.abs(p)<=.005*re(g[0].p0,g[0].p),l=e?null:O(c.p0,c.p,f.p0,f.p,!1);if(!e&&l){let e=.75*se(U([c.p,l,f.p0],.5),1===g.length?U([g[0].p0,g[0].cp1,g[0].cp2,g[0].p],.5):g[0].p);if(h&&e>h&&e>.3*r){n.push(s);continue}{let e={type:"Q",values:[l.x,l.y,f.p0.x,f.p0.y]};e.p0=c.p,e.cp1=l,e.p=f.p0,n.push(c,e),t+=d;continue}}}}}c&&t===a-1&&"L"===p||n.push(s)}return(c||r&&"Z"!==n[n.length-1].type)&&n.push({type:"Z",values:[]}),n}function ct(e){if(e.length<3)return!1;let t=e[0],l=e[Math.floor(e.length/2)],a=e[e.length-1],n=t.x,r=t.y,s=l.x,i=l.y,p=a.x,u=a.y,h=n-s,o=r-i,y=n-p,c=r-u,x=(n*n-s*s+(r*r-i*i))/2,f=(n*n-p*p+(r*r-u*u))/2,g=h*c-o*y;if(Math.abs(g)<1e-10)return console.warn("Points are collinear or numerically unstable"),!1;let d={x:(c*x-o*f)/g,y:(-y*x+h*f)/g},v=ne(d,t),m=R(d,t,a),{deltaAngle:M,startAngle:b,endAngle:A}=m;return{centroid:d,r:v,startAngle:b,endAngle:A,deltaAngle:M}}function xt(e,{threshold:l=0,tolerance:a=1,toCubic:n=!1,debug:r=!1}={}){let s=e.length,i=[e[0]],p=[];for(let l=1;l<s;l++){let a=e[l],{type:s}=a,u=e[l-1],h=e[l+1]?e[l+1]:null,o=e[l+2]?e[l+2]:null,y=e[l+3]?e[l+3]:null,c=null;"C"===a.type||"Q"===a.type?c=a:!h||"C"!==h.type&&"Q"!==h.type||(c=h);let x,f,g,d,v,m=c?"C"===c.type?[c.p0,c.cp1,c.cp2,c.p]:[c.p0,c.cp1,c.p]:[],M=0,b=0,A=!1,C=!1,w=[];if("L"===u.type&&"L"===s&&c&&"L"===o.type&&y&&("L"===y.type||"Z"===y.type)?(x=[a.p0,a.p],f=[o.p0,o.p],g=a.p0,d=o.p,M=de(m,!1),b=de([...x,...f],!1),A=M<0&&b>0||M>0&&b<0,A||(v=U(m,.5),w=[g,v,d],C=!0)):"C"!==s&&"Q"!==s||"L"!==u.type||"C"!==h.type&&"Q"!==h.type||"L"!==o.type||(C=!0,x=[u.p0,u.p],f=[o.p0,o.p],g=u.p,d=o.p0,v=c.p,w=[g,c.p,d]),C){let e=ct(w);if(e){let s,{centroid:u,r:h,deltaAngle:o,startAngle:y,endAngle:c}=e,x=0,f=o>0?1:0,m=Math.abs(o)>Math.PI?1:0;if(ie(J(g,u.x,u.y,.5*o),v)<.05*ie(g,d)){if(s=ze({p0:g,p:d,centroid:u,rx:h,ry:h,xAxisRotation:x,sweep:f,largeArc:m,deltaAngle:o,startAngle:y,endAngle:c}),1===s.length){let e=ke(g,s[0].cp1,s[0].cp2,d);"Q"===e.type&&(n=!0),a=e}if(s.length>1&&(n=!1),n||(a.type="A",a.values=[h,h,x,m,f,d.x,d.y]),a.p0=g,a.p=d,a.extreme=!1,a.corner=!1,r){p=n?[{type:"M",values:[g.x,g.y]},...s]:[{type:"M",values:[g.x,g.y]},{type:"A",values:[h,h,x,m,f,d.x,d.y]}];let e=ve(p);t(markers,e,"orange","0.5%","0.5")}i.push(a),l++;continue}}}i.push(a)}return i}function ft(e=[],{threshold:t=0}={}){let l=e.length,a="z"===e[l-1].type.toLowerCase(),n=a?l-2:l-1,r=e[n],s=r.values.slice(-2),i={x:e[0].values[0],y:e[0].values[1]},p=ie(i,{x:s[0],y:s[1]});if(p&&p<t){let l=e[n].values.length;e[n].values[l-2]=i.x,e[n].values[l-1]=i.y;let a=e[1];if("C"===a.type&&"C"===r.type){let l=Math.abs(a.values[0]-r.values[2]),s=Math.abs(a.values[1]-r.values[3]),p=Math.abs(e[1].values[0]-a.values[0]),u=Math.abs(e[1].values[1]-a.values[1]),h=Math.abs(e[1].values[0]-r.values[2]),o=Math.abs(e[1].values[1]-r.values[3]),y=u<t&&o<t&&l;l&&l<t&&(p<t&&h<t&&s)&&(e[1].values[0]=i.x,e[n].values[2]=i.x),s&&s<t&&y&&(e[1].values[1]=i.y,e[n].values[3]=i.y)}}return e}function gt(e,t=1){let l=[];for(let a=0,n=e.length;a<n;a++){let n=e[a],{type:r,values:s}=n,i={type:r,values:[]};switch(r.toLowerCase()){case"h":case"v":i.values=[s[0]*t];break;case"a":i.values=[s[0]*t,s[1]*t,s[2],s[3],s[4],s[5]*t,s[6]*t];break;default:s.length&&(i.values=s.map((e,l)=>e*t))}l.push(i)}return l}function dt(e,{tolerance:l=1}={}){let a=[],n=[],r=e.length;for(let t=1;t<r;t++){let l=e[t],{type:r,values:s,p0:i,cp1:p=null,cp2:u=null,p:h,extreme:o=null,semiExtreme:y=null,corner:c=null,directionChange:x}=l,f=e[t+1]||null;o||c||f&&f.type!==r?(n.push(l),a.push(n),n=[]):n.push(l)}console.log("!!!chunks",a),function(e){console.log("chunks",e);let l="green";for(let a=0;a<e.length;a++){let n=e[a],r=n.length;l=a%2==0?"orange":"green";let s=n[0],i=n[r-1],p=[{type:"M",values:[s.p0.x,s.p0.y]}];for(let e=0,t=r;e<t;e++){let l=n[e];n[e+1],n[t-1],"C"===s.type&&i.type;let{type:a,values:r,p0:u,cp1:h=null,cp2:o=null,p:y=null,extreme:c,semiExtreme:x=null,corner:f=null}=l;p.push({type:a,values:r})}let u=ve(p);t(markers,u,l,"1%","0.5")}}(a);let s=a.length;for(let e=0;e<s;e++){let t=a[e],l=a[e+1]||null;1===t.length&&l&&l[0].type}a=a.filter(Boolean);let i=[e[0]];for(let e=0;e<a.length;e++){let t=a[e],l=t.length,n=t[0],r=t[l-1],s=.05*se(n.p0,r.p);for(let e=0,a=l;e<a;e++){let p=t[e];t[e+1],t[a-1];let u="C"===n.type&&"C"===r.type,{type:h,values:o,p0:y,cp1:c=null,cp2:x=null,p:f=null,extreme:g,semiExtreme:d=null,corner:v=null}=p,m=null,M=null,b=null,A=null,C=null,w=null,E=[],L=.666,k=null;if(u){let e=Math.abs(n.p0.x-n.cp1.x),t=Math.abs(n.p0.y-n.cp1.y),l=Math.abs(r.p.x-r.cp2.x),a=Math.abs(r.p.y-r.cp2.y),i=e<s&&e<t,p=l<s&&l<a,u=a<s&&l>a;t<s&&e>t&&(n.cp1.y=n.p0.y),u&&(r.cp2.y=r.p.y),i&&(n.cp1.x=n.p0.x),p&&(r.cp2.x=r.p.x)}if(ve([{type:"M",values:[p.p0.x,p.p0.y]},{type:h,values:o}]),1===l||"C"!==h)i.push(p);else{let e=t.filter(e=>e.semiExtreme),l=t.filter(e=>e.directionChange);if(e.length||l.length){if(k=e.length?e[0]:l[0],n.p0.x===n.cp1.x&&n.p0.y===n.cp1.y?n.cp1=U([n.p0,n.cp1,n.cp2,n.p],.5):r.p.x===r.cp2.x&&r.p.y===r.cp2.y&&(r.cp2=U([r.p0,r.cp1,r.cp2,r.p],.5)),m=O(k.p,k.cp2,n.p0,n.cp1,!1),M=O(k.p,k.cp2,r.p,r.cp2,!1),m&&M){b=U([n.p0,m],L),A=U([r.p,M],L),C=U([k.p,m],L),w=U([k.p,M],L),E=[{type:"M",values:[n.p0.x,n.p0.y]},{type:"C",values:[b.x,b.y,C.x,C.y,k.p.x,k.p.y]},{type:"C",values:[w.x,w.y,A.x,A.y,r.p.x,r.p.y]}],ve(E),i.push({type:"C",values:[b.x,b.y,C.x,C.y,k.p.x,k.p.y],p0:n.p0,cp1:b,cp2:C,p:k.p,dimA:se(n.p0,k.p)},{type:"C",values:[w.x,w.y,A.x,A.y,r.p.x,r.p.y],p0:k.p,cp1:w,cp2:A,p:r.p,extreme:!0,dimA:se(k.p,r.p)});break}}else i.push(p)}}}return i}function vt(e){for(let t=1,l=e.length;t<l;t++){let l=e[t],{type:a,values:n,p0:r,cp1:s=null,cp2:i=null,p:p=null}=l;if("C"===a){let a=ke(r,s,i,p);"Q"===a.type&&(a.extreme=l.extreme,a.corner=l.corner,a.dimA=l.dimA,a.squareDist=l.squareDist,e[t]=a)}}return e}function mt(e,{areaThreshold:t=2.5}={}){for(let l=0,a=e.length;l<a;l++){let a=e[l],n=e[l+1]||null,{type:r,values:s,p0:i,cp1:p=null,cp2:u=null,p:h=null}=a;if("C"===r&&n&&"C"===n.type){let a=Mt(i,p,u,h,t),r=Mt(n.p0,n.cp1,n.cp2,n.p,t);if(a.isArc&&r.isArc){let t=.01*se(i,n.p),s=Math.abs(n.p.x-i.x),p=Math.abs(n.p.y-i.y),u=p<t&&s>t,o=s<t&&p>t,{rx:y,ry:c}=a,x=de([i,h,n.p])<0?0:1;if(o||u){y=Math.min(y,r.rx),c=Math.min(c,r.ry),e[l]=null,e[l+1].type="A",e[l+1].values=[y,c,0,0,x,n.p.x,n.p.y];continue}}}}return e=e.filter(Boolean)}function Mt(e,t,l,a,n=7.5){let r,s={type:"C",values:[t.x,t.y,l.x,l.y,a.x,a.y]},i=0,p=!1,u=Z(e,t,!0),h=Z(a,l,!0),o=180*Math.abs(u-h)/Math.PI,y=0,c=0;if(Math.abs(o%180-90)<3){r=O(e,J(t,e.x,e.y,-.5*Math.PI),a,J(l,a.x,a.y,.5*Math.PI),!1);let u=O(e,t,a,l,!1);if(u){let r=ne(e,u),h=ne(a,u),o=+Math.max(r,h).toFixed(8),x=+Math.min(r,h).toFixed(8);y=x,c=o;let f=de([e,t,l,a])<0?0:1,g=Math.abs(a.x-e.x)>Math.abs(a.y-e.y);100/y*Math.abs(y-c)<5&&(y=o,c=y),g&&(y=o,c=x);let d=ge([{type:"M",values:[e.x,e.y]},{type:"C",values:[t.x,t.y,l.x,l.y,a.x,a.y]}]),v={type:"A",values:[y,c,0,0,f,a.x,a.y]};i=Math.PI*(y*c)/4,i-=Math.abs(de([e,a,u])),function(e,t){let l=Math.abs(e-t);return Math.abs(100-100/e*(e+l))}(d,i)<n&&(p=!0,s=v)}}return{com:s,isArc:p,area:i,rx:y,ry:c,centroid:r}}function bt(e,{angles:t=[],split:l=0,getPathData:a=!0,width:n=0,height:r=0}={}){let s=e.length,i={x:e[0].values[0],y:e[0].values[1]},p=i,u=[],h=[p],o=0;if(l=l||1,n&&r)o=.025*(n+r)/l;else{o=e.map(e=>e.dimA||0).filter(Boolean).sort()[0]}for(let t=1;t<s;t++){let a=e[t],n=e[t+1]||null,{type:r,values:s}=a,u=s.length,y=u?{x:s[u-2],y:s[u-1]}:i;if("C"===r||"Q"===r){let e={x:s[0],y:s[1]},t="C"===r?{x:s[2],y:s[3]}:e,n="C"===r?[p,e,t,y]:[p,e,y],i=a.dimA;l=Math.ceil(i/o);let u=[];for(let e=1;e<l;e++)u.push(1/l*e);u.forEach(e=>{let t=U(n,e);h.push(t)})}"M"===r&&(i=y),y.area=a.cptArea||0,y.isExtreme=a.extreme||!1,y.isCorner=a.corner||!1,y.isDirChange=a.directionChange||!1,h.push(y),a.extreme||a.corner||n&&n.type,p=y}return h=function(e,{quality:t=.9,width:l=0,height:a=0,absolute:n=!1,manhattan:r=!1,exclude:s=[]}={}){"string"==typeof t&&(n=!0,t=parseFloat(t));if(e.length<4||(!n&&t)>=1)return e;let i=t;if(!n){if(i=1-t,!l&&!a){let t=pe(e,12);({width:l,height:a}=ce(t))}i=r?.05*(l+a)*(1-t):(i*((l+a)/2/25))**2}let p,u=e[0],h=[u],o=e.length,y=s.length,c=0;for(let t=1;t<o;t++)p=e[t],c=r?se(u,p):re(u,p),!(c<i)||y&&s.includes(t)?(h.push(p),u=p):u=p;return u.x!==p.x&&u.y!==p.y&&h.push(p),h}(h,{quality:.5,width:n,height:r}),u=function(e,t=!0){let l=[{type:"M",values:[e[0].x,e[0].y]},...e.slice(1).map(e=>({type:"L",values:[e.x,e.y]}))];return t&&l.push({type:"Z",values:[]}),l}(h),a?u:h}function At(e="",{getObject:t=!1,toAbsolute:l=!0,toRelative:a=!0,toShorthands:n=!0,quadraticToCubic:r=!0,arcToCubic:s=!1,cubicToArc:i=!1,simplifyBezier:p=!0,optimizeOrder:u=!0,autoClose:h=!0,removeZeroLength:o=!0,refineClosing:y=!0,removeColinear:c=!0,flatBezierToLinetos:x=!0,revertToQuadratics:f=!0,refineExtremes:g=!0,simplifyCorners:d=!1,keepExtremes:v=!0,keepCorners:m=!0,extrapolateDominant:M=!0,keepInflections:b=!1,addExtremes:A=!1,addSemiExtremes:C=!1,smoothPoly:w=!1,harmonizeCpts:E=!1,toPolygon:L=!1,removeOrphanSubpaths:k=!1,simplifyRound:S=!1,scale:P=1,scaleTo:I=0,crop:D=!1,alignToOrigin:F=!1,decimals:q=3,autoAccuracy:$=!0,minifyD:z=0,tolerance:T=1,reverse:Q=!1,mergePaths:B=!1,removeHidden:j=!0,removeUnused:N=!0,shapesToPaths:Z=!0,tMin:R=0,tMax:O=1,redraw:H=!1}={}){T=Math.max(.1,T),P=Math.max(.001,P);let U=function(e){let t="string";if(Array.isArray(e))return e[0]?.type&&e[0]?.values?"pathData":"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),W="",J=0,X=0,Y=0,G={},K="",_="svgMarkup"===U?1:0,ee=[];J=e.length;let te={x:0,y:0,width:0,height:0},le={x:0,y:0,width:0,height:0},ae=[],ne=[];if(_){if(W=function(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","fill","stroke","stroke-width","stroke-linecap","stroke-linejoin"]);let r=["metadata","script"],s=n.querySelectorAll("*"),i=n.querySelectorAll("text").length?[]:["font-family","font-weight","font-style","font-size"];return s.forEach(e=>{let t=e.nodeName,a=e.getAttribute("style")||"",n=!!a&&a.trim().includes("display:none"),s=e.getAttribute("display")&&"none"===e.getAttribute("display")||n;t.includes(":")||r.includes(t)||l&&s?e.remove():(function(e){[...e.attributes].map(e=>e.name).forEach(t=>{t.includes(":")&&e.removeAttribute(t)})}(e),function(e,t=[]){[...e.attributes].map(e=>e.name).forEach(l=>{t.includes(l)&&e.removeAttribute(l)})}(e,i))}),t?n:ot(n)}(e,{returnDom:!0,removeHidden:j,removeUnused:N}),Z){W.querySelectorAll("polygon, polyline, line, rect, circle, ellipse").forEach(e=>{let t=Oe(e);e.replaceWith(t)})}W.querySelectorAll("path").forEach(e=>{ee.push({d:e.getAttribute("d"),el:e})}),te=function(e=null,t=-1){const l=e=>e&&isNaN(e)?e.match(/[^\d|.]+/g)[0]:"";if(!e)return!1;let a=e.hasAttribute("width"),n=e.hasAttribute("height"),r=e.hasAttribute("viewBox"),s=a?e.getAttribute("width"):0,i=n?e.getAttribute("height"):0,p=!!a&&l(s),u=!!n&&l(s),h=s?s.includes("%")?0:parseFloat(s):300,o=i?i.includes("%")?0:parseFloat(i):150,y=r?e.getAttribute("viewBox").split(/,| /).filter(Boolean).map(Number):[0,0,h,o];return t>-1&&([h,o]=[h,o].map(e=>+e.toFixed(t)),y=y.map(e=>+e.toFixed(t))),{x:y[0],y:y[1],width:y[2],height:y[3],w:h,h:o,hasViewBox:r,hasWidth:a,hasHeight:n,widthUnit:p,heightUnit:u}}(W,q)}else{if("pathDataString"===U)K=e;else if("polyString"===U)K="M"+e;else if("pathData"===U){K=e,J=K.map(e=>`${e.type} ${e.values.join(" ")}`).join(" ").length}ee.push({d:K,el:null})}let re={toRelative:a,toShorthands:n,decimals:q},se=[];for(let e=0,t=ee.length;t&&e<t;e++){let t=ee[e],{d:a,el:n}=t,j=Qe(a,{quadraticToCubic:r,toAbsolute:l,arcToCubic:s}),N=w||L?ce(V(j)):null;if(1!==P||I){if(I)if(te.width&&!D)P=I/te.width;else{let e=j.map(e=>({type:e.type,values:e.values}));e=Se(e,{arcToCubic:!0}),e=ye(e);let t=ce(V(e));ae.push(t.x,t.x+t.width),ne.push(t.y,t.y+t.height);let l=I/t.width;P=l}j=gt(j,P)}let Z=j.length;k&&(j=Ue(j));let U=ue(j),W=U.length,G=[];for(let e=0;e<W;e++){let t=U[e];if(L){p=!1,w=!1,E=!1,t=He(t);let e=Le(t),{bb:l,pathData:a}=e;t=a,t=bt(t,{angles:[],split:1,width:N.width,height:N.height,getPathData:!0})}if(w){let e=Array.from(new Set(t.map(e=>e.type))).join(""),l=!/[acqts]/gi.test(e),a=/[z]/gi.test(e);if(l){t=Ve(t),t=ut(V(t),{denoise:.8,tolerance:T,width:N.width,height:N.height,manhattan:!1,absolute:!1,keepCorners:m,keepExtremes:v,keepInflections:b,closed:a})}}E&&(t=Ye(t)),(c||o)&&(t=Ve(t)),H&&(A=!0,C=!0,d=!1,m=!0,v=!0,u=!0,R=0,O=0),u&&(t=We(t)),c&&(t=He(t,{tolerance:T,flatBezierToLinetos:!1})),(A||C)&&(t=ye(t,{tMin:R,tMax:O,addExtremes:A,addSemiExtremes:C,angles:[30]}));let l=Le(t,{detectSemiExtremes:C}),{pathData:a,bb:n,dimA:r}=l;if(ae.push(n.x,n.x+n.width),ne.push(n.y,n.y+n.height),y&&(a=ft(a,{threshold:.001*r})),a=p?Me(a,{simplifyBezier:p,keepInflections:b,keepExtremes:v,keepCorners:m,extrapolateDominant:M,revertToQuadratics:f,tolerance:T,reverse:Q}):a,g){a=ht(a,{threshold:.05*(n.width+n.height),tolerance:T})}if(H&&(n.width,n.height,a=dt(a,{tolerance:T,threshold:.001*r})),i&&(a=mt(a,{areaThreshold:2.5})),c&&x&&(a=He(a,{tolerance:T,flatBezierToLinetos:x})),d){a=yt(a,{threshold:.1*(n.width+n.height),tolerance:T})}S&&(a=xt(a)),f&&(a=vt(a)),u&&(a=Je(a,{autoClose:h})),G.push({pathData:a,bb:n})}let K=Math.min(...ae),_=Math.min(...ne);le={x:K,y:_,width:Math.max(...ae)-K,height:Math.max(...ne)-_};let ie=le.height>le.width;if(u&&(G=ie?G.sort((e,t)=>e.bb.y-t.bb.y||e.bb.x-t.bb.x):G.sort((e,t)=>e.bb.x-t.bb.x||e.bb.y-t.bb.y)),j=[],G.forEach(e=>{j.push(...e.pathData)}),$&&(q=Ce(j),re.decimals=q),n&&B)se.push(...j);else{j=Se(j,re),j=Ve(j),F&&(console.log(le),j[0].values[0]=(j[0].values[0]-le.x).toFixed(q),j[0].values[1]=(j[0].values[1]-le.y).toFixed(q),le.x=0,le.y=0);let e=j.length,l=ve(j,z);X=l.length,Y=+(100/J*X).toFixed(2),t.d=l,t.report={original:Z,new:e,saved:Z-e,compression:Y,decimals:q},n&&n.setAttribute("d",l)}}if(_){if(se.length){let e=Se(se,re);e=Ve(e);let t=ve(e,z);ee[0].el.setAttribute("d",t);for(let e=1;e<ee.length;e++){let t=ee[e].el;t&&t.remove()}!function(e){e.querySelectorAll("g, defs").forEach(e=>{e.children.length||e.remove()})}(W)}if(P){let{x:e,y:t,width:l,height:a,w:n,h:r,hasViewBox:s,hasWidth:i,hasHeight:p,widthUnit:u,heightUnit:h}=te;D&&(e=le.x,t=le.y,l=le.width,a=le.height,n=l,r=a),s&&W.setAttribute("viewBox",[e,t,l,a].map(e=>+(e*P).toFixed(q)).join(" ")),i&&W.setAttribute("width",+(n*P).toFixed(q)+u),p&&W.setAttribute("height",+(r*P).toFixed(q)+h)}W=ot(W),X=W.length,Y=+(100/J*X).toFixed(2),J=+(J/1024).toFixed(3),X=+(X/1024).toFixed(3),G={svgSize:J,svgSizeOpt:X,compression:Y,decimals:q}}else({d:K,report:G}=ee[0]);return t?{svg:W,d:K,report:G,inputType:U,mode:_}:K||W}"undefined"!=typeof window&&(window.svgPathSimplify=At);export{b as PI,l as abs,a as acos,n as asin,r as atan,s as atan2,i as ceil,p as cos,u as exp,h as floor,y as hypot,o as log,c as max,x as min,f as pow,g as random,d as round,v as sin,m as sqrt,At as svgPathSimplify,M as tan};
@@ -4151,27 +4151,27 @@
4151
4151
  let valsL = values.slice(-2);
4152
4152
  p = type !== 'Z' ? { x: valsL[0], y: valsL[1] } : M;
4153
4153
 
4154
- /*
4155
- let area = p1 ? getPolygonArea([p0, p, p1], true) : Infinity
4156
- let distSquare = getSquareDistance(p0, p1)
4157
- let distMax = distSquare ? distSquare / 333 * tolerance : 0
4158
- */
4154
+ let area = p1 ? getPolygonArea([p0, p, p1], true) : Infinity;
4155
+ let distSquare = getSquareDistance(p0, p1);
4156
+ let distMax = distSquare ? distSquare / 333 * tolerance : 0;
4157
+
4158
+ let isFlat = area < distMax;
4159
4159
 
4160
- let isFlat = false;
4161
4160
  let isFlatBez = false;
4162
4161
 
4162
+ /*
4163
4163
  // flatness by cross product
4164
- let dx0 = Math.abs(p1.x - p0.x);
4165
- let dy0 = Math.abs(p1.y - p0.y);
4164
+ let dx0 = Math.abs(p1.x - p0.x)
4165
+ let dy0 = Math.abs(p1.y - p0.y)
4166
4166
 
4167
- let dx1 = Math.abs(p.x - p0.x);
4168
- let dy1 = Math.abs(p.y - p0.y);
4167
+ let dx1 = Math.abs(p.x - p0.x)
4168
+ let dy1 = Math.abs(p.y - p0.y)
4169
4169
 
4170
- let dx2 = Math.abs(p1.x - p.x);
4171
- let dy2 = Math.abs(p1.y - p.y);
4170
+ let dx2 = Math.abs(p1.x - p.x)
4171
+ let dy2 = Math.abs(p1.y - p.y)
4172
4172
 
4173
4173
  // zero length segments are flat
4174
- let isZeroLength = (!dy1 && !dx1) || (!dy2 && !dx2);
4174
+ let isZeroLength = (!dy1 && !dx1) || (!dy2 && !dx2)
4175
4175
  if (isZeroLength) isFlat = true;
4176
4176
 
4177
4177
  // check cross products for colinearity
@@ -4179,13 +4179,14 @@
4179
4179
 
4180
4180
  let cross0 = Math.abs(dx0 * dy1 - dy0 * dx1);
4181
4181
 
4182
- let thresh = (dx0 + dy0) * 0.1;
4182
+ let thresh = (dx0 + dy0) * 0.1
4183
4183
 
4184
4184
  if ( cross0 < thresh) {
4185
4185
 
4186
- isFlat = true;
4186
+ isFlat = true
4187
4187
  }
4188
4188
  }
4189
+ */
4189
4190
 
4190
4191
  if (!flatBezierToLinetos && type === 'C') isFlat = false;
4191
4192
 
@@ -6025,6 +6026,9 @@
6025
6026
  let removeEls = ['metadata', 'script'];
6026
6027
 
6027
6028
  let els = svg.querySelectorAll('*');
6029
+
6030
+ let textEls = svg.querySelectorAll('text');
6031
+ let remove = !textEls.length ? ['font-family', 'font-weight', 'font-style', 'font-size'] : [];
6028
6032
 
6029
6033
  els.forEach(el => {
6030
6034
  let name = el.nodeName;
@@ -6037,6 +6041,7 @@
6037
6041
  } else {
6038
6042
  // remove BS elements
6039
6043
  removeNameSpaceAtts(el);
6044
+ removeAtts(el,remove);
6040
6045
  }
6041
6046
  });
6042
6047
 
@@ -6070,6 +6075,15 @@
6070
6075
  });
6071
6076
  }
6072
6077
 
6078
+ function removeAtts(el, remove=[]) {
6079
+ let atts = [...el.attributes].map((att) => att.name);
6080
+ atts.forEach((att) => {
6081
+ if (remove.includes(att)) {
6082
+ el.removeAttribute(att);
6083
+ }
6084
+ });
6085
+ }
6086
+
6073
6087
  function removeNameSpaceAtts(el) {
6074
6088
  let atts = [...el.attributes].map((att) => att.name);
6075
6089
  atts.forEach((att) => {
@@ -1,4 +1,4 @@
1
- !function(e){"use strict";function t(e,t,l="red",a="1%",n="1",r="",s=!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>${r}</title></circle>`;if(!s)return u;e.insertAdjacentHTML("beforeend",u)}function l(e,t="",l="green",a="1%",n="1",r=!0){let s=`<path d="${t}" fill="none" stroke="${l}" stroke-width="${a}" stroke-opacity="${n}" /> `;if(!r)return s;e.insertAdjacentHTML("beforeend",s)}const{abs:a,acos:n,asin:r,atan:s,atan2:i,ceil:p,cos:u,exp:h,floor:o,log:y,hypot:c,max:x,min:f,pow:g,random:d,round:v,sin:m,sqrt:M,tan:b,PI:A}=Math,{abs:C,acos:w,asin:E,atan:L,atan2:k,ceil:P,cos:S,exp:I,floor:D,log:F,max:q,min:$,pow:z,random:T,round:Q,sin:B,sqrt:j,tan:N,PI:Z}=Math;function R(e,t,l=!1){let a=k(t.y-e.y,t.x-e.x);return l&&a<0&&(a+=2*Math.PI),a}function O(e,t,l,a=!1){let n=Math.atan2(t.y-e.y,t.x-e.x),r=Math.atan2(l.y-e.y,l.x-e.x),s=r-n;s=(e=>{let t=e%(2*Math.PI);return t>Math.PI?t-=2*Math.PI:t<=-Math.PI&&(t+=2*Math.PI),t})(s),a&&(s=2*Math.PI-Math.abs(s));let i=180/Math.PI;return{startAngle:n,endAngle:r,deltaAngle:s,startAngleDeg:n*i,endAngleDeg:r*i,deltaAngleDeg:s*i}}function H(e=null,t=null,l=null,a=null,n=!0,r=!1){let s,i,p,u,h,o={};if(!(e&&t&&l&&a))return r&&console.warn("points missing"),!1;try{if(s=(a.y-l.y)*(t.x-e.x)-(a.x-l.x)*(t.y-e.y),0==s)return!1}catch{return r&&console.warn("!catch",e,t,"p3:",l,"p4:",a),!1}i=e.y-l.y,p=e.x-l.x,u=(a.x-l.x)*i-(a.y-l.y)*p,h=(t.x-e.x)*i-(t.y-e.y)*p,i=u/s,p=h/s,o={x:e.x+i*(t.x-e.x),y:e.y+i*(t.y-e.y)};let y=!1;return i>0&&i<1&&p>0&&p<1&&(y=!0),!(n&&!y)&&o}function U(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=R(e,t),n.angle<0&&(n.angle+=2*Z)),n}function V(e,t=.5,l=!1,a=!1,n=!1){let r;return Array.isArray(e[0])&&(e=e.map(e=>({x:e[0],y:e[1]})),n=!0),r=e.length>2?((e,t,l=!1)=>{let n=4===e.length,r=e[0],s=e[1],i=n?e[2]:e[1],p=e[e.length-1],u={x:0,y:0};if(l||a){let e,l,h,o,y,c=r.x===s.x&&r.y===s.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=U(r,s,t),n?(l=U(s,i,t),h=U(i,p,t),o=U(e,l,t),y=U(l,h,t),u=U(o,y,t),u.angle=R(o,y),a&&(u.cpts=[l,h,o,y])):(l=U(r,s,t),h=U(s,p,t),u=U(l,h,t),u.angle=R(l,h),a&&(u.cpts=[l,h]))):(u.x=p.x,u.y=p.y,u.angle=R(i,p)):(u.x=r.x,u.y=r.y,u.angle=R(r,s))}else{let e=1-t;u=n?{x:e**3*r.x+3*e**2*t*s.x+3*e*t**2*i.x+t**3*p.x,y:e**3*r.y+3*e**2*t*s.y+3*e*t**2*i.y+t**3*p.y}:{x:e*e*r.x+2*e*t*s.x+t**2*p.x,y:e*e*r.y+2*e*t*s.y+t**2*p.y}}return u})(e,t,l):U(e[0],e[1],t,l),l&&r.angle<0&&(r.angle+=2*Z),n?[r.x,r.y]:r}function W(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}function J(e,t,l,a,n,r,s,i,p){const u=(e,t,l,a)=>k(a-t,l-e);let h={cx:0,cy:0,rx:l=C(l),ry:a=C(a),startAngle:0,endAngle:0,deltaAngle:0,clockwise:s,xAxisRotation:n,largeArc:r,sweep:s};if(0==l||0==a)throw Error("rx and ry can not be 0");if(l===a){let l=Math.abs(i-e),a=Math.abs(p-t),n=l,r=Math.min(e,i),u=Math.min(t,p),o=.5*Math.PI;if(0===l&&a||0===a&&l)return n=0===l&&a?a/2:l/2,h.rx=n,h.ry=n,0===l&&a?(h.cx=e,h.cy=u+a/2,h.startAngle=t>p?o:-o,h.endAngle=t>p?-o:o,h.deltaAngle=s?Math.PI:-Math.PI):0===a&&l&&(h.cx=r+l/2,h.cy=t,h.startAngle=e>i?Math.PI:0,h.endAngle=e>i?-Math.PI:Math.PI,h.deltaAngle=s?Math.PI:-Math.PI),h}let o,y,c=l===a?0:n*Z/180,x=c?Math.sin(c):0,f=c?Math.cos(c):1,g=(e-i)/2,d=(t-p)/2,v=(e+i)/2,m=(t+p)/2,M=c?f*g+x*d:g,b=c?f*d-x*g:d,A=M*M/(l*l)+b*b/(a*a);A>1&&(l*=Math.sqrt(A),a*=Math.sqrt(A),h.rx=l,h.ry=a);let w=l*a,E=l*b,L=a*M,P=E**2+L**2;if(!P)throw Error("start point can not be same as end point");let S=Math.sqrt(Math.abs((w*w-P)/P));r==s&&(S=-S);let I=S*E/a,D=-S*L/l;o=c?f*I-x*D+v:v+I,y=c?x*I+f*D+m:m+D,h.cy=y,h.cx=o;let F=u(o,y,e,t),q=u(o,y,i,p);!s&&q>F&&(q-=2*Math.PI),s&&F>q&&(q=q<=0?q+2*Math.PI:q);let $=q-F;return h.startAngle=F,h.endAngle=q,h.deltaAngle=$,h}function X(e,t,l,a=0,n=!1){return a?(a=n?a/180*Math.PI:a,{x:t+(e.x-t)*Math.cos(a)-(e.y-l)*Math.sin(a),y:l+(e.x-t)*Math.sin(a)+(e.y-l)*Math.cos(a)}):e}function Y(e,t,l,a,n,r=0,s=!0,i=!1){if(n=i?n*Z/180:n,r=i?r*Z/180:r,r=l!==a&&r!==2*Z?r:0,s&&l!==a){let e=L(N(n=r?n-r:n)*(l/a));n=S(n)<0?e+Z:e}let p=e+l*S(n),u=t+a*B(n),h={x:p,y:u};return r&&(h.x=e+(p-e)*S(r)-(u-t)*B(r),h.y=t+(p-e)*B(r)+(u-t)*S(r)),h}function G(e,t,l){if(t===l||e%Z*.5==0)return e;let a=L(N(e)*(t/l));return a=S(e)<0?a+Z:a,a}function K(e=null,t=[]){e||(e=t[0],t=t.slice(1,t.length));let l=t.length,a=t[l-1],n=t[0],r=3===l?t[1]:n,s=Math.min(e.y,a.y),i=Math.min(e.x,a.x),p=Math.max(e.x,a.x),u=Math.max(e.y,a.y);return!(n.y>=s&&n.y<=u&&r.y>=s&&r.y<=u&&n.x>=i&&n.x<=p&&r.x>=i&&r.x<=p)}function _(e,{addExtremes:t=!0,addSemiExtremes:l=!1}={}){let a=4===e.length?function(e,t,l,a,{addExtremes:n=!0,addSemiExtremes:r=!1}={}){const s=e=>{const t=Math.PI/4,l=Math.cos(t),a=Math.sin(t);return{x:e.x*l-e.y*a,y:e.x*a+e.y*l}};r&&(e=s(e),t=s(t),l=s(l),a=s(a));let[i,p,u,h,o,y,c,x]=[e.x,e.y,t.x,t.y,l.x,l.y,a.x,a.y],f=Math.min(e.y,a.y),g=Math.min(e.x,a.x),d=Math.max(e.x,a.x),v=Math.max(e.y,a.y);if(t.y>=f&&t.y<=v&&l.y>=f&&l.y<=v&&t.x>=g&&t.x<=d&&l.x>=g&&l.x<=d)return[];let m,M,b,A,C,w,E,L,k=[];for(let e=0;e<2;++e)if(0==e?(M=6*i-12*u+6*o,m=-3*i+9*u-9*o+3*c,b=3*u-3*i):(M=6*p-12*h+6*y,m=-3*p+9*h-9*y+3*x,b=3*h-3*p),Math.abs(m)<1e-8){if(Math.abs(M)<1e-8)continue;A=-b/M,0<A&&A<1&&k.push(A)}else E=M*M-4*b*m,E<0?Math.abs(E)<1e-8&&(A=-M/(2*m),0<A&&A<1&&k.push(A)):(L=Math.sqrt(E),C=(-M+L)/(2*m),0<C&&C<1&&k.push(C),w=(-M-L)/(2*m),0<w&&w<1&&k.push(w));let P=k.length;for(;P--;)A=k[P];return k}(e[0],e[1],e[2],e[3],{addExtremes:t,addSemiExtremes:l}):function(e,t,l,{addExtremes:a=!0,addSemiExtremes:n=!1}={}){const r=e=>{const t=-Math.PI/4,l=Math.cos(t),a=Math.sin(t);return{x:e.x*l-e.y*a,y:e.x*a+e.y*l}};n&&(e=r(e),t=r(t),l=r(l));let s,i,p,u=Math.min(e.y,l.y),h=Math.min(e.x,l.x),o=Math.max(e.x,l.x),y=Math.max(e.y,l.y);if(t.y>=u&&t.y<=y&&t.x>=h&&t.x<=o)return[];let[c,x,f,g,d,v]=[e.x,e.y,t.x,t.y,l.x,l.y],m=[];for(let e=0;e<2;++e)s=0==e?c-2*f+d:x-2*g+v,i=0==e?-2*c+2*f:-2*x+2*g,Math.abs(s)>1e-12&&(p=-i/(2*s),p>0&&p<1&&m.push(p));return m}(e[0],e[1],e[2],{addExtremes:t,addSemiExtremes:l});return a}function ee(e,t){const l=(e,t,l,a,n,r)=>{var s=Math.cos(r),i=Math.sin(r),p=a*Math.cos(e),u=n*Math.sin(e);return{x:t+s*p-i*u,y:l+i*p+s*u}};let a,n,r,s,i,p=J(e.x,e.y,t[0],t[1],t[2],t[3],t[4],t[5],t[6]),{rx:u,ry:h,cx:o,cy:y,endAngle:c,deltaAngle:x}=p,f=t[2],g={x:t[5],y:t[6]},d=[g],v=f*Math.PI/180,m=Math.tan(v);i=Math.atan2(-h*m,u);let M=i,b=i+Math.PI,A=Math.atan2(h,u*m),C=A+Math.PI,w=[e.x,g.x],E=[e.y,g.y],L=Math.min(...w),k=Math.max(...w),P=Math.min(...E),S=Math.max(...E),I=l(c-.001*x,o,y,u,h,v),D=l(c-.999*x,o,y,u,h,v);return(I.x>k||D.x>k)&&(a=l(M,o,y,u,h,v),d.push(a)),(I.x<L||D.x<L)&&(n=l(b,o,y,u,h,v),d.push(n)),(I.y<P||D.y<P)&&(s=l(C,o,y,u,h,v),d.push(s)),(I.y>S||D.y>S)&&(r=l(A,o,y,u,h,v),d.push(r)),d}function te(e=[],t=[]){let l=e.length,a=4===l;t.length||(t=[0]);let n=t.length,r=[];for(let s=0;s<n;s++){let n=t[s],i=n?[]:e.slice(0);if(n)for(let t=0;t<l;t++){let l=e[t];i.push(X(l,0,0,n))}let p=a?le(...i):ae(...i);r.push(...p)}return r=[...new Set(r)].sort(),r}function le(e,t,l,a){if(!K(e,[t,l,a]))return[];let n,r,s,i,p,u,h,o,[y,c,x,f,g,d,v,m]=[e.x,e.y,t.x,t.y,l.x,l.y,a.x,a.y],M=[],b=1e-8;for(let e=0;e<2;++e)if(0==e?(r=6*y-12*x+6*g,n=-3*y+9*x-9*g+3*v,s=3*x-3*y):(r=6*c-12*f+6*d,n=-3*c+9*f-9*d+3*m,s=3*f-3*c),Math.abs(n)<b){if(Math.abs(r)<b)continue;i=-s/r,i>0&&i<1&&M.push(i)}else h=r*r-4*s*n,h<0?Math.abs(h)<b&&(i=-r/(2*n),i>0&&i<1&&M.push(i)):(o=Math.sqrt(h),p=(-r+o)/(2*n),p>0&&p<1&&M.push(p),u=(-r-o)/(2*n),u>0&&u<1&&M.push(u));let A=M.length;for(;A--;)i=M[A];return[...new Set(M)].sort()}function ae(e,t,l){if(!K(e,[t,l]))return[];let a,n,r,[s,i,p,u,h,o]=[e.x,e.y,t.x,t.y,l.x,l.y],y=[];for(let e=0;e<2;++e)a=0==e?s-2*p+h:i-2*u+o,n=0==e?-2*s+2*p:-2*i+2*u,Math.abs(a)>1e-12&&(r=-n/(2*a),r>0&&r<1&&y.push(r));return[...new Set(y)].sort()}function ne(e,t=.001){let l=Math.PI/2,a=l/2;return!(Math.abs(e/l-Math.round(e/l))<t)&&Math.abs(e/a-Math.round(e/a))<t}function re(e,t,l=!1){let a=l?t[0]-e[0]:t.x-e.x,n=l?t[1]-e[1]:t.y-e.y;return j(a*a+n*n)}function se(e,t){let l=t.x-e.x,a=t.y-e.y;return l*l+a*a}function ie(e,t){return Math.abs(t.x-e.x)+Math.abs(t.y-e.y)}function pe(e,t){return.5*(Math.abs(t.x-e.x)+Math.abs(t.y-e.y))}function ue(e,t=48){if(!Array.isArray(e)||e.length<=t)return e;let l=e.length,a=l/t,n=[];for(let l=0;l<t;l++)n.push(e[Math.floor(l*a)]);let r=n.length;return n[r-1]!==e[l-1]&&(n[r-1]=e[l-1]),n}function he(e){let t=[],l=[e[0]],a=e.length;for(let n=1;n<a;n++){let a=e[n];"M"!==a.type&&"m"!==a.type||(t.push(l),l=[]),l.push(a)}return l.length&&t.push(l),t}function oe(e,t){let l,a,n,r,s,i,p=[],u=[],h=e[0],o=e[1],y=e[e.length-2],c=e[e.length-1];return 4===e.length?(l=V([h,o],t),a=V([o,y],t),n=V([y,c],t),r=V([l,a],t),s=V([a,n],t),i=V([r,s],t),p.push({x:h.x,y:h.y},{x:l.x,y:l.y},{x:r.x,y:r.y},{x:i.x,y:i.y}),u.push({x:i.x,y:i.y},{x:s.x,y:s.y},{x:n.x,y:n.y},{x:c.x,y:c.y})):3===e.length?(a=V([h,o],t),n=V([o,c],t),i=V([a,n],t),p.push({x:h.x,y:h.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=V([h,c],t),p.push({x:h.x,y:h.y},{x:a.x,y:a.y}),u.push({x:a.x,y:a.y},{x:c.x,y:c.y})),[p,u]}function ye(e,t,{tMin:l=0,tMax:a=1,addExtremes:n=!0,addSemiExtremes:r=!1}={}){let s=[],i=6===t.length?"C":"Q",p={x:t[0],y:t[1]},u="C"===i?{x:t[2],y:t[3]}:p,h={x:t[4],y:t[5]},o=0;let y="C"===i?[e,p,u,h]:[e,p,h],c=n?_(y,{addExtremes:n,addSemiExtremes:!1}):[],x=r?_(y,{addExtremes:n,addSemiExtremes:r}):[],f=Array.from(new Set([...c,...x])).sort();if(f=f.filter(e=>e>0&&e<1),f.length){let l=function(e,t,l,a=!0){let n=[];if(!l.length)return!1;let r,s,i,p=t.length,u={x:t[p-2],y:t[p-1]};2===t.length?i=[e,u]:4===t.length?(r={x:t[0],y:t[1]},i=[e,r,u]):6===t.length&&(r={x:t[0],y:t[1]},s={x:t[2],y:t[3]},i=[e,r,s,u]);if(l.length)if(1===l.length){let e=oe(i,l[0]),t=e[0],a=e[1];n.push(t,a)}else{let e=l[0],t=oe(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=oe(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,f);s.push(...l),o+=l.length}else s.push({type:i,values:t});return{pathData:s,count:o}}function ce(e,{tMin:t=0,tMax:l=1,addExtremes:a=!0,addSemiExtremes:n=!1}={}){let r=[e[0]],s={x:e[0].values[0],y:e[0].values[1]},i={x:e[0].values[0],y:e[0].values[1]},p=e.length;for(let u=1;p&&u<p;u++){let p=e[u],{type:h,values:o}=p,y=o.slice(-2);if(y[0],y[1],"C"!==h&&"Q"!==h)r.push(p);else if((a||n)&&("C"===h||"Q"===h)){let e=ye(s,o,{tMin:t,tMax:l,addExtremes:a,addSemiExtremes:n}).pathData;r.push(...e)}s={x:y[0],y:y[1]},"z"===h.toLowerCase()?s=i:"M"===h&&(i={x:y[0],y:y[1]})}return r}function xe(e,t=-1){let l=e.map(e=>e.x),a=e.map(e=>e.y),n=Math.min(...l),r=Math.max(...l),s=Math.min(...a),i=Math.max(...a),p={x:n,left:n,right:r,y:s,top:s,bottom:i,width:r-n,height:i-s};if(t>-1)for(let e in p)p[e]=+p[e].toFixed(t);return p}function fe(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:r,values:s}=a,i={x:n.values[n.values.length-2],y:n.values[n.values.length-1]},p=s.length?{x:s[s.length-2],y:s[s.length-1]}:"",u=s.length?{x:s[0],y:s[1]}:"";switch(r){case"A":if("function"!=typeof arcToBezier){let e=re(i,p)/2,l=U(i,p,.5),a=Y(l.x,l.y,e,e,0),n=Y(l.x,l.y,e,e,Math.PI);t.push(a,n,p);break}arcToBezier(i,s).forEach(e=>{let l=e.values,a={x:l[0],y:l[1]},n={x:l[2],y:l[3]},r={x:l[4],y:l[5]};t.push(a,n,r)});break;case"C":let e={x:s[2],y:s[3]};t.push(u,e);break;case"Q":t.push(u)}"z"!==r.toLowerCase()&&t.push(p)}return t}(e),l=xe(t);return l}(e);t.push(l)}),t}function ge(e,t){let[l,a,n,r,s,i]=[e.x,e.y,e.width,e.height,e.x+e.width,e.y+e.height],[p,u,h,o,y,c]=[t.x,t.y,t.width,t.height,t.x+t.width,t.y+t.height],x=!1;return n*r!=h*o&&n*r>h*o&&l<p&&s>y&&a<u&&i>c&&(x=!0),x}function de(e,t=9){let l=0,a=[],n=he(e),r=n.length>1,s=[];if(r){let e=fe(n);e.forEach(function(t,l){for(let l=0;l<e.length;l++){let a=e[l];if(t!=a){ge(t,a)&&s.push(l)}}})}return n.forEach((e,t)=>{a=[];let n=0,r=0,i=1,p=[];e.forEach(function(t,l){let[r,s]=[t.type,t.values],i=s.length;if(s.length){let u=(l>0?e[l-1]:e[0]).values,h=u.length,o={x:u[h-2],y:u[h-1]},y={x:s[i-2],y:s[i-1]};if("C"===r||"Q"===r){let e={x:s[0],y:s[1]};p="C"===r?[o,e,{x:s[2],y:s[3]},y]:[o,e,y];let t=Math.abs(function(e,t=!1){let l,[a,n,r,s]=[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},r={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-r.y+3*s.y)+n.x*(2*a.y-r.y-s.y)+r.x*(a.y+n.y-2*s.y)+s.x*(-3*a.y+n.y+2*r.y))/20,t?Math.abs(l):l}(p));n+=t,a.push(o,y)}else if("A"===r){let e=J(o.x,o.y,t.values[0],t.values[1],t.values[2],t.values[3],t.values[4],y.x,y.y),{cx:l,cy:r,rx:s,ry:i,startAngle:p,endAngle:u,deltaAngle:h}=e,c=Math.abs(function(e,t,l,a){const n=Math.PI*e*t;let r=(a-l+2*Math.PI)%(2*Math.PI);if(e===t)return n*(r/(2*Math.PI));const s=l=>Math.atan2(e*Math.sin(l),t*Math.cos(l));return l=s(l),a=s(a),r=(a-l+2*Math.PI)%(2*Math.PI),n*(r/(2*Math.PI))}(s,i,p,u));c-=Math.abs(ve([o,{x:l,y:r},y])),a.push(o,y),n+=c}else a.push(o,y)}});let u=ve(a);-1!==s.indexOf(t)&&(i=-1),r=u<0&&n<0?(Math.abs(n)-Math.abs(u))*i:(Math.abs(n)+Math.abs(u))*i,l+=r}),l}function ve(e,t=!1){let l=0,a=e.length;for(let t=0;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 me(e,t=0){t=parseFloat(t);let l=e.length,a=t>1,n=!a&&!t,r="",s=a?"\n":n?"":" ",i=n?"":" ";r=`${e[0].type}${i}${e[0].values.join(" ")}${s}`;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=n&&l.type===a.type&&"m"!==a.type.toLowerCase()||n&&"M"===l.type&&"L"===a.type?" ":a.type,n){let e="",t=!1;for(let l=0,a=u.length;l<a;l++){let a=u[l],n=a.toString(),r=n.includes(".")&&Math.abs(a)<1;r&&t&&(n=n.replace(/^0\./,".")),!(l>0)||t&&r||(e+=" "),e+=n,t=r}r+=`${p}${i}${e}${s}`}else r+=`${p}${i}${u.join(" ")}${s}`}return n&&(r=r.replace(/ 0\./g," .").replace(/ -/g,"-").replace(/-0\./g,"-.").replace(/Z/g,"z")),r}function Me(e,a,n=0,r=1,s=!1){const i=(e,t,l,a,n)=>{let r=1-n;return{x:3*r*r*(t.x-e.x)+6*r*n*(l.x-t.x)+3*n*n*(a.x-l.x),y:3*r*r*(t.y-e.y)+6*r*n*(l.y-t.y)+3*n*n*(a.y-l.y)}};let p=[e,a],u=pe(e.p0,e.p)>pe(a.p0,a.p),h=JSON.parse(JSON.stringify(e)),o=JSON.parse(JSON.stringify(a)),y=H(h.p0,h.cp1,o.p,o.cp2,!1);if(!y)return p;if(u){let t={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:a.p.x,y:a.p.y},cp1:{x:a.cp2.x,y:a.cp2.y},cp2:{x:a.cp1.x,y:a.cp1.y},p:{x:a.p0.x,y:a.p0.y}},a=t}let c=(e,t)=>({x:e.x-t.x,y:e.y-t.y}),x=(e,t)=>({x:e.x*t,y:e.y*t}),f=(e,t)=>e.x*t.x+e.y*t.y,g=a.p0,d=i(a.p0,a.cp1,a.cp2,a.p,0),v=f(c(e.p0,g),d)/f(d,d),m=V([a.p0,a.cp1,a.cp2,a.p],v),M=i(a.p0,a.cp1,a.cp2,a.p,v);v-=f(c(m,e.p0),M)/f(M,M);let b=V([a.p0,a.cp1,a.cp2,a.p],v),A=a.p,C=i(a.p0,a.cp1,a.cp2,a.p,v),w=i(a.p0,a.cp1,a.cp2,a.p,1),E=1-v,L=(k=b,P=x(C,E/3),{x:k.x+P.x,y:k.y+P.y});var k,P;let S=c(A,x(w,E/3)),I={p0:b,cp1:L,cp2:S,p:A,t0:v};u&&(I={p0:A,cp1:S,cp2:L,p:b,t0:v});let D=.5*(1-v),F=V([I.p0,I.cp1,I.cp2,I.p],D,!1,!0),q=F.cpts[2],$=H(F,q,I.p0,y,!1),z=H(F,q,I.p,y,!1),T=U(I.p0,$,1.333),Q=U(I.p,z,1.333);if(H(h.p0,T,o.p,Q,!0))return p;s&&t(markers,F,"purple"),I.cp1=T,I.cp2=Q;let B=pe(h.p0,I.p0)+pe(o.p,I.p);if(I.p0=h.p0,I.p=o.p,I.extreme=o.extreme,I.corner=o.corner,I.dimA=o.dimA,I.directionChange=o.directionChange,I.type="C",I.values=[I.cp1.x,I.cp1.y,I.cp2.x,I.cp2.y,I.p.x,I.p.y],B<n){let t=u?1+v:Math.abs(v),a=1+Math.abs(v);if(t=u?1+v:Math.abs(v)/a,pe(V([I.p0,I.cp1,I.cp2,I.p],t),e.p)>n*r)return p;let i=de([{type:"M",values:[h.p0.x,h.p0.y]},{type:"C",values:[h.cp1.x,h.cp1.y,h.cp2.x,h.cp2.y,h.p.x,h.p.y]},{type:"C",values:[o.cp1.x,o.cp1.y,o.cp2.x,o.cp2.y,o.p.x,o.p.y]}]),y=[{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]}],c=de(y),x=Math.abs(c/i-1);if(I.error=5*x*r,s){let e=me(y);l(markers,e,"orange")}x<.05*r&&(p=[I])}return p}function be(e,{keepExtremes:t=!0,keepInflections:l=!0,keepCorners:a=!0,extrapolateDominant:n=!0,tolerance:r=1}={}){let s=[e[0]],i=e.length;for(let n=2;i&&n<=i;n++){let p=e[n-1],u=n<i?e[n]:null,h=u?.type||null,{type:o,values:y,p0:c,p:x,cp1:f=null,cp2:g=null,extreme:d=!1,directionChange:v=!1,corner:m=!1,dimA:M=0}=p;if("C"===o&&"C"===h)if(a&&m||t&&d)s.push(p);else{let h=Ae(p,u,{tolerance:r}),o=0;
1
+ !function(e){"use strict";function t(e,t,l="red",a="1%",n="1",r="",s=!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>${r}</title></circle>`;if(!s)return u;e.insertAdjacentHTML("beforeend",u)}function l(e,t="",l="green",a="1%",n="1",r=!0){let s=`<path d="${t}" fill="none" stroke="${l}" stroke-width="${a}" stroke-opacity="${n}" /> `;if(!r)return s;e.insertAdjacentHTML("beforeend",s)}const{abs:a,acos:n,asin:r,atan:s,atan2:i,ceil:p,cos:u,exp:h,floor:o,log:y,hypot:c,max:x,min:f,pow:g,random:d,round:v,sin:m,sqrt:M,tan:b,PI:A}=Math,{abs:C,acos:w,asin:E,atan:L,atan2:k,ceil:S,cos:P,exp:I,floor:D,log:F,max:q,min:$,pow:z,random:T,round:Q,sin:B,sqrt:j,tan:N,PI:Z}=Math;function R(e,t,l=!1){let a=k(t.y-e.y,t.x-e.x);return l&&a<0&&(a+=2*Math.PI),a}function O(e,t,l,a=!1){let n=Math.atan2(t.y-e.y,t.x-e.x),r=Math.atan2(l.y-e.y,l.x-e.x),s=r-n;s=(e=>{let t=e%(2*Math.PI);return t>Math.PI?t-=2*Math.PI:t<=-Math.PI&&(t+=2*Math.PI),t})(s),a&&(s=2*Math.PI-Math.abs(s));let i=180/Math.PI;return{startAngle:n,endAngle:r,deltaAngle:s,startAngleDeg:n*i,endAngleDeg:r*i,deltaAngleDeg:s*i}}function H(e=null,t=null,l=null,a=null,n=!0,r=!1){let s,i,p,u,h,o={};if(!(e&&t&&l&&a))return r&&console.warn("points missing"),!1;try{if(s=(a.y-l.y)*(t.x-e.x)-(a.x-l.x)*(t.y-e.y),0==s)return!1}catch{return r&&console.warn("!catch",e,t,"p3:",l,"p4:",a),!1}i=e.y-l.y,p=e.x-l.x,u=(a.x-l.x)*i-(a.y-l.y)*p,h=(t.x-e.x)*i-(t.y-e.y)*p,i=u/s,p=h/s,o={x:e.x+i*(t.x-e.x),y:e.y+i*(t.y-e.y)};let y=!1;return i>0&&i<1&&p>0&&p<1&&(y=!0),!(n&&!y)&&o}function U(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=R(e,t),n.angle<0&&(n.angle+=2*Z)),n}function V(e,t=.5,l=!1,a=!1,n=!1){let r;return Array.isArray(e[0])&&(e=e.map(e=>({x:e[0],y:e[1]})),n=!0),r=e.length>2?((e,t,l=!1)=>{let n=4===e.length,r=e[0],s=e[1],i=n?e[2]:e[1],p=e[e.length-1],u={x:0,y:0};if(l||a){let e,l,h,o,y,c=r.x===s.x&&r.y===s.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=U(r,s,t),n?(l=U(s,i,t),h=U(i,p,t),o=U(e,l,t),y=U(l,h,t),u=U(o,y,t),u.angle=R(o,y),a&&(u.cpts=[l,h,o,y])):(l=U(r,s,t),h=U(s,p,t),u=U(l,h,t),u.angle=R(l,h),a&&(u.cpts=[l,h]))):(u.x=p.x,u.y=p.y,u.angle=R(i,p)):(u.x=r.x,u.y=r.y,u.angle=R(r,s))}else{let e=1-t;u=n?{x:e**3*r.x+3*e**2*t*s.x+3*e*t**2*i.x+t**3*p.x,y:e**3*r.y+3*e**2*t*s.y+3*e*t**2*i.y+t**3*p.y}:{x:e*e*r.x+2*e*t*s.x+t**2*p.x,y:e*e*r.y+2*e*t*s.y+t**2*p.y}}return u})(e,t,l):U(e[0],e[1],t,l),l&&r.angle<0&&(r.angle+=2*Z),n?[r.x,r.y]:r}function W(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}function J(e,t,l,a,n,r,s,i,p){const u=(e,t,l,a)=>k(a-t,l-e);let h={cx:0,cy:0,rx:l=C(l),ry:a=C(a),startAngle:0,endAngle:0,deltaAngle:0,clockwise:s,xAxisRotation:n,largeArc:r,sweep:s};if(0==l||0==a)throw Error("rx and ry can not be 0");if(l===a){let l=Math.abs(i-e),a=Math.abs(p-t),n=l,r=Math.min(e,i),u=Math.min(t,p),o=.5*Math.PI;if(0===l&&a||0===a&&l)return n=0===l&&a?a/2:l/2,h.rx=n,h.ry=n,0===l&&a?(h.cx=e,h.cy=u+a/2,h.startAngle=t>p?o:-o,h.endAngle=t>p?-o:o,h.deltaAngle=s?Math.PI:-Math.PI):0===a&&l&&(h.cx=r+l/2,h.cy=t,h.startAngle=e>i?Math.PI:0,h.endAngle=e>i?-Math.PI:Math.PI,h.deltaAngle=s?Math.PI:-Math.PI),h}let o,y,c=l===a?0:n*Z/180,x=c?Math.sin(c):0,f=c?Math.cos(c):1,g=(e-i)/2,d=(t-p)/2,v=(e+i)/2,m=(t+p)/2,M=c?f*g+x*d:g,b=c?f*d-x*g:d,A=M*M/(l*l)+b*b/(a*a);A>1&&(l*=Math.sqrt(A),a*=Math.sqrt(A),h.rx=l,h.ry=a);let w=l*a,E=l*b,L=a*M,S=E**2+L**2;if(!S)throw Error("start point can not be same as end point");let P=Math.sqrt(Math.abs((w*w-S)/S));r==s&&(P=-P);let I=P*E/a,D=-P*L/l;o=c?f*I-x*D+v:v+I,y=c?x*I+f*D+m:m+D,h.cy=y,h.cx=o;let F=u(o,y,e,t),q=u(o,y,i,p);!s&&q>F&&(q-=2*Math.PI),s&&F>q&&(q=q<=0?q+2*Math.PI:q);let $=q-F;return h.startAngle=F,h.endAngle=q,h.deltaAngle=$,h}function X(e,t,l,a=0,n=!1){return a?(a=n?a/180*Math.PI:a,{x:t+(e.x-t)*Math.cos(a)-(e.y-l)*Math.sin(a),y:l+(e.x-t)*Math.sin(a)+(e.y-l)*Math.cos(a)}):e}function Y(e,t,l,a,n,r=0,s=!0,i=!1){if(n=i?n*Z/180:n,r=i?r*Z/180:r,r=l!==a&&r!==2*Z?r:0,s&&l!==a){let e=L(N(n=r?n-r:n)*(l/a));n=P(n)<0?e+Z:e}let p=e+l*P(n),u=t+a*B(n),h={x:p,y:u};return r&&(h.x=e+(p-e)*P(r)-(u-t)*B(r),h.y=t+(p-e)*B(r)+(u-t)*P(r)),h}function G(e,t,l){if(t===l||e%Z*.5==0)return e;let a=L(N(e)*(t/l));return a=P(e)<0?a+Z:a,a}function K(e=null,t=[]){e||(e=t[0],t=t.slice(1,t.length));let l=t.length,a=t[l-1],n=t[0],r=3===l?t[1]:n,s=Math.min(e.y,a.y),i=Math.min(e.x,a.x),p=Math.max(e.x,a.x),u=Math.max(e.y,a.y);return!(n.y>=s&&n.y<=u&&r.y>=s&&r.y<=u&&n.x>=i&&n.x<=p&&r.x>=i&&r.x<=p)}function _(e,{addExtremes:t=!0,addSemiExtremes:l=!1}={}){let a=4===e.length?function(e,t,l,a,{addExtremes:n=!0,addSemiExtremes:r=!1}={}){const s=e=>{const t=Math.PI/4,l=Math.cos(t),a=Math.sin(t);return{x:e.x*l-e.y*a,y:e.x*a+e.y*l}};r&&(e=s(e),t=s(t),l=s(l),a=s(a));let[i,p,u,h,o,y,c,x]=[e.x,e.y,t.x,t.y,l.x,l.y,a.x,a.y],f=Math.min(e.y,a.y),g=Math.min(e.x,a.x),d=Math.max(e.x,a.x),v=Math.max(e.y,a.y);if(t.y>=f&&t.y<=v&&l.y>=f&&l.y<=v&&t.x>=g&&t.x<=d&&l.x>=g&&l.x<=d)return[];let m,M,b,A,C,w,E,L,k=[];for(let e=0;e<2;++e)if(0==e?(M=6*i-12*u+6*o,m=-3*i+9*u-9*o+3*c,b=3*u-3*i):(M=6*p-12*h+6*y,m=-3*p+9*h-9*y+3*x,b=3*h-3*p),Math.abs(m)<1e-8){if(Math.abs(M)<1e-8)continue;A=-b/M,0<A&&A<1&&k.push(A)}else E=M*M-4*b*m,E<0?Math.abs(E)<1e-8&&(A=-M/(2*m),0<A&&A<1&&k.push(A)):(L=Math.sqrt(E),C=(-M+L)/(2*m),0<C&&C<1&&k.push(C),w=(-M-L)/(2*m),0<w&&w<1&&k.push(w));let S=k.length;for(;S--;)A=k[S];return k}(e[0],e[1],e[2],e[3],{addExtremes:t,addSemiExtremes:l}):function(e,t,l,{addExtremes:a=!0,addSemiExtremes:n=!1}={}){const r=e=>{const t=-Math.PI/4,l=Math.cos(t),a=Math.sin(t);return{x:e.x*l-e.y*a,y:e.x*a+e.y*l}};n&&(e=r(e),t=r(t),l=r(l));let s,i,p,u=Math.min(e.y,l.y),h=Math.min(e.x,l.x),o=Math.max(e.x,l.x),y=Math.max(e.y,l.y);if(t.y>=u&&t.y<=y&&t.x>=h&&t.x<=o)return[];let[c,x,f,g,d,v]=[e.x,e.y,t.x,t.y,l.x,l.y],m=[];for(let e=0;e<2;++e)s=0==e?c-2*f+d:x-2*g+v,i=0==e?-2*c+2*f:-2*x+2*g,Math.abs(s)>1e-12&&(p=-i/(2*s),p>0&&p<1&&m.push(p));return m}(e[0],e[1],e[2],{addExtremes:t,addSemiExtremes:l});return a}function ee(e,t){const l=(e,t,l,a,n,r)=>{var s=Math.cos(r),i=Math.sin(r),p=a*Math.cos(e),u=n*Math.sin(e);return{x:t+s*p-i*u,y:l+i*p+s*u}};let a,n,r,s,i,p=J(e.x,e.y,t[0],t[1],t[2],t[3],t[4],t[5],t[6]),{rx:u,ry:h,cx:o,cy:y,endAngle:c,deltaAngle:x}=p,f=t[2],g={x:t[5],y:t[6]},d=[g],v=f*Math.PI/180,m=Math.tan(v);i=Math.atan2(-h*m,u);let M=i,b=i+Math.PI,A=Math.atan2(h,u*m),C=A+Math.PI,w=[e.x,g.x],E=[e.y,g.y],L=Math.min(...w),k=Math.max(...w),S=Math.min(...E),P=Math.max(...E),I=l(c-.001*x,o,y,u,h,v),D=l(c-.999*x,o,y,u,h,v);return(I.x>k||D.x>k)&&(a=l(M,o,y,u,h,v),d.push(a)),(I.x<L||D.x<L)&&(n=l(b,o,y,u,h,v),d.push(n)),(I.y<S||D.y<S)&&(s=l(C,o,y,u,h,v),d.push(s)),(I.y>P||D.y>P)&&(r=l(A,o,y,u,h,v),d.push(r)),d}function te(e=[],t=[]){let l=e.length,a=4===l;t.length||(t=[0]);let n=t.length,r=[];for(let s=0;s<n;s++){let n=t[s],i=n?[]:e.slice(0);if(n)for(let t=0;t<l;t++){let l=e[t];i.push(X(l,0,0,n))}let p=a?le(...i):ae(...i);r.push(...p)}return r=[...new Set(r)].sort(),r}function le(e,t,l,a){if(!K(e,[t,l,a]))return[];let n,r,s,i,p,u,h,o,[y,c,x,f,g,d,v,m]=[e.x,e.y,t.x,t.y,l.x,l.y,a.x,a.y],M=[],b=1e-8;for(let e=0;e<2;++e)if(0==e?(r=6*y-12*x+6*g,n=-3*y+9*x-9*g+3*v,s=3*x-3*y):(r=6*c-12*f+6*d,n=-3*c+9*f-9*d+3*m,s=3*f-3*c),Math.abs(n)<b){if(Math.abs(r)<b)continue;i=-s/r,i>0&&i<1&&M.push(i)}else h=r*r-4*s*n,h<0?Math.abs(h)<b&&(i=-r/(2*n),i>0&&i<1&&M.push(i)):(o=Math.sqrt(h),p=(-r+o)/(2*n),p>0&&p<1&&M.push(p),u=(-r-o)/(2*n),u>0&&u<1&&M.push(u));let A=M.length;for(;A--;)i=M[A];return[...new Set(M)].sort()}function ae(e,t,l){if(!K(e,[t,l]))return[];let a,n,r,[s,i,p,u,h,o]=[e.x,e.y,t.x,t.y,l.x,l.y],y=[];for(let e=0;e<2;++e)a=0==e?s-2*p+h:i-2*u+o,n=0==e?-2*s+2*p:-2*i+2*u,Math.abs(a)>1e-12&&(r=-n/(2*a),r>0&&r<1&&y.push(r));return[...new Set(y)].sort()}function ne(e,t=.001){let l=Math.PI/2,a=l/2;return!(Math.abs(e/l-Math.round(e/l))<t)&&Math.abs(e/a-Math.round(e/a))<t}function re(e,t,l=!1){let a=l?t[0]-e[0]:t.x-e.x,n=l?t[1]-e[1]:t.y-e.y;return j(a*a+n*n)}function se(e,t){let l=t.x-e.x,a=t.y-e.y;return l*l+a*a}function ie(e,t){return Math.abs(t.x-e.x)+Math.abs(t.y-e.y)}function pe(e,t){return.5*(Math.abs(t.x-e.x)+Math.abs(t.y-e.y))}function ue(e,t=48){if(!Array.isArray(e)||e.length<=t)return e;let l=e.length,a=l/t,n=[];for(let l=0;l<t;l++)n.push(e[Math.floor(l*a)]);let r=n.length;return n[r-1]!==e[l-1]&&(n[r-1]=e[l-1]),n}function he(e){let t=[],l=[e[0]],a=e.length;for(let n=1;n<a;n++){let a=e[n];"M"!==a.type&&"m"!==a.type||(t.push(l),l=[]),l.push(a)}return l.length&&t.push(l),t}function oe(e,t){let l,a,n,r,s,i,p=[],u=[],h=e[0],o=e[1],y=e[e.length-2],c=e[e.length-1];return 4===e.length?(l=V([h,o],t),a=V([o,y],t),n=V([y,c],t),r=V([l,a],t),s=V([a,n],t),i=V([r,s],t),p.push({x:h.x,y:h.y},{x:l.x,y:l.y},{x:r.x,y:r.y},{x:i.x,y:i.y}),u.push({x:i.x,y:i.y},{x:s.x,y:s.y},{x:n.x,y:n.y},{x:c.x,y:c.y})):3===e.length?(a=V([h,o],t),n=V([o,c],t),i=V([a,n],t),p.push({x:h.x,y:h.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=V([h,c],t),p.push({x:h.x,y:h.y},{x:a.x,y:a.y}),u.push({x:a.x,y:a.y},{x:c.x,y:c.y})),[p,u]}function ye(e,t,{tMin:l=0,tMax:a=1,addExtremes:n=!0,addSemiExtremes:r=!1}={}){let s=[],i=6===t.length?"C":"Q",p={x:t[0],y:t[1]},u="C"===i?{x:t[2],y:t[3]}:p,h={x:t[4],y:t[5]},o=0;let y="C"===i?[e,p,u,h]:[e,p,h],c=n?_(y,{addExtremes:n,addSemiExtremes:!1}):[],x=r?_(y,{addExtremes:n,addSemiExtremes:r}):[],f=Array.from(new Set([...c,...x])).sort();if(f=f.filter(e=>e>0&&e<1),f.length){let l=function(e,t,l,a=!0){let n=[];if(!l.length)return!1;let r,s,i,p=t.length,u={x:t[p-2],y:t[p-1]};2===t.length?i=[e,u]:4===t.length?(r={x:t[0],y:t[1]},i=[e,r,u]):6===t.length&&(r={x:t[0],y:t[1]},s={x:t[2],y:t[3]},i=[e,r,s,u]);if(l.length)if(1===l.length){let e=oe(i,l[0]),t=e[0],a=e[1];n.push(t,a)}else{let e=l[0],t=oe(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=oe(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,f);s.push(...l),o+=l.length}else s.push({type:i,values:t});return{pathData:s,count:o}}function ce(e,{tMin:t=0,tMax:l=1,addExtremes:a=!0,addSemiExtremes:n=!1}={}){let r=[e[0]],s={x:e[0].values[0],y:e[0].values[1]},i={x:e[0].values[0],y:e[0].values[1]},p=e.length;for(let u=1;p&&u<p;u++){let p=e[u],{type:h,values:o}=p,y=o.slice(-2);if(y[0],y[1],"C"!==h&&"Q"!==h)r.push(p);else if((a||n)&&("C"===h||"Q"===h)){let e=ye(s,o,{tMin:t,tMax:l,addExtremes:a,addSemiExtremes:n}).pathData;r.push(...e)}s={x:y[0],y:y[1]},"z"===h.toLowerCase()?s=i:"M"===h&&(i={x:y[0],y:y[1]})}return r}function xe(e,t=-1){let l=e.map(e=>e.x),a=e.map(e=>e.y),n=Math.min(...l),r=Math.max(...l),s=Math.min(...a),i=Math.max(...a),p={x:n,left:n,right:r,y:s,top:s,bottom:i,width:r-n,height:i-s};if(t>-1)for(let e in p)p[e]=+p[e].toFixed(t);return p}function fe(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:r,values:s}=a,i={x:n.values[n.values.length-2],y:n.values[n.values.length-1]},p=s.length?{x:s[s.length-2],y:s[s.length-1]}:"",u=s.length?{x:s[0],y:s[1]}:"";switch(r){case"A":if("function"!=typeof arcToBezier){let e=re(i,p)/2,l=U(i,p,.5),a=Y(l.x,l.y,e,e,0),n=Y(l.x,l.y,e,e,Math.PI);t.push(a,n,p);break}arcToBezier(i,s).forEach(e=>{let l=e.values,a={x:l[0],y:l[1]},n={x:l[2],y:l[3]},r={x:l[4],y:l[5]};t.push(a,n,r)});break;case"C":let e={x:s[2],y:s[3]};t.push(u,e);break;case"Q":t.push(u)}"z"!==r.toLowerCase()&&t.push(p)}return t}(e),l=xe(t);return l}(e);t.push(l)}),t}function ge(e,t){let[l,a,n,r,s,i]=[e.x,e.y,e.width,e.height,e.x+e.width,e.y+e.height],[p,u,h,o,y,c]=[t.x,t.y,t.width,t.height,t.x+t.width,t.y+t.height],x=!1;return n*r!=h*o&&n*r>h*o&&l<p&&s>y&&a<u&&i>c&&(x=!0),x}function de(e,t=9){let l=0,a=[],n=he(e),r=n.length>1,s=[];if(r){let e=fe(n);e.forEach(function(t,l){for(let l=0;l<e.length;l++){let a=e[l];if(t!=a){ge(t,a)&&s.push(l)}}})}return n.forEach((e,t)=>{a=[];let n=0,r=0,i=1,p=[];e.forEach(function(t,l){let[r,s]=[t.type,t.values],i=s.length;if(s.length){let u=(l>0?e[l-1]:e[0]).values,h=u.length,o={x:u[h-2],y:u[h-1]},y={x:s[i-2],y:s[i-1]};if("C"===r||"Q"===r){let e={x:s[0],y:s[1]};p="C"===r?[o,e,{x:s[2],y:s[3]},y]:[o,e,y];let t=Math.abs(function(e,t=!1){let l,[a,n,r,s]=[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},r={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-r.y+3*s.y)+n.x*(2*a.y-r.y-s.y)+r.x*(a.y+n.y-2*s.y)+s.x*(-3*a.y+n.y+2*r.y))/20,t?Math.abs(l):l}(p));n+=t,a.push(o,y)}else if("A"===r){let e=J(o.x,o.y,t.values[0],t.values[1],t.values[2],t.values[3],t.values[4],y.x,y.y),{cx:l,cy:r,rx:s,ry:i,startAngle:p,endAngle:u,deltaAngle:h}=e,c=Math.abs(function(e,t,l,a){const n=Math.PI*e*t;let r=(a-l+2*Math.PI)%(2*Math.PI);if(e===t)return n*(r/(2*Math.PI));const s=l=>Math.atan2(e*Math.sin(l),t*Math.cos(l));return l=s(l),a=s(a),r=(a-l+2*Math.PI)%(2*Math.PI),n*(r/(2*Math.PI))}(s,i,p,u));c-=Math.abs(ve([o,{x:l,y:r},y])),a.push(o,y),n+=c}else a.push(o,y)}});let u=ve(a);-1!==s.indexOf(t)&&(i=-1),r=u<0&&n<0?(Math.abs(n)-Math.abs(u))*i:(Math.abs(n)+Math.abs(u))*i,l+=r}),l}function ve(e,t=!1){let l=0,a=e.length;for(let t=0;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 me(e,t=0){t=parseFloat(t);let l=e.length,a=t>1,n=!a&&!t,r="",s=a?"\n":n?"":" ",i=n?"":" ";r=`${e[0].type}${i}${e[0].values.join(" ")}${s}`;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=n&&l.type===a.type&&"m"!==a.type.toLowerCase()||n&&"M"===l.type&&"L"===a.type?" ":a.type,n){let e="",t=!1;for(let l=0,a=u.length;l<a;l++){let a=u[l],n=a.toString(),r=n.includes(".")&&Math.abs(a)<1;r&&t&&(n=n.replace(/^0\./,".")),!(l>0)||t&&r||(e+=" "),e+=n,t=r}r+=`${p}${i}${e}${s}`}else r+=`${p}${i}${u.join(" ")}${s}`}return n&&(r=r.replace(/ 0\./g," .").replace(/ -/g,"-").replace(/-0\./g,"-.").replace(/Z/g,"z")),r}function Me(e,a,n=0,r=1,s=!1){const i=(e,t,l,a,n)=>{let r=1-n;return{x:3*r*r*(t.x-e.x)+6*r*n*(l.x-t.x)+3*n*n*(a.x-l.x),y:3*r*r*(t.y-e.y)+6*r*n*(l.y-t.y)+3*n*n*(a.y-l.y)}};let p=[e,a],u=pe(e.p0,e.p)>pe(a.p0,a.p),h=JSON.parse(JSON.stringify(e)),o=JSON.parse(JSON.stringify(a)),y=H(h.p0,h.cp1,o.p,o.cp2,!1);if(!y)return p;if(u){let t={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:a.p.x,y:a.p.y},cp1:{x:a.cp2.x,y:a.cp2.y},cp2:{x:a.cp1.x,y:a.cp1.y},p:{x:a.p0.x,y:a.p0.y}},a=t}let c=(e,t)=>({x:e.x-t.x,y:e.y-t.y}),x=(e,t)=>({x:e.x*t,y:e.y*t}),f=(e,t)=>e.x*t.x+e.y*t.y,g=a.p0,d=i(a.p0,a.cp1,a.cp2,a.p,0),v=f(c(e.p0,g),d)/f(d,d),m=V([a.p0,a.cp1,a.cp2,a.p],v),M=i(a.p0,a.cp1,a.cp2,a.p,v);v-=f(c(m,e.p0),M)/f(M,M);let b=V([a.p0,a.cp1,a.cp2,a.p],v),A=a.p,C=i(a.p0,a.cp1,a.cp2,a.p,v),w=i(a.p0,a.cp1,a.cp2,a.p,1),E=1-v,L=(k=b,S=x(C,E/3),{x:k.x+S.x,y:k.y+S.y});var k,S;let P=c(A,x(w,E/3)),I={p0:b,cp1:L,cp2:P,p:A,t0:v};u&&(I={p0:A,cp1:P,cp2:L,p:b,t0:v});let D=.5*(1-v),F=V([I.p0,I.cp1,I.cp2,I.p],D,!1,!0),q=F.cpts[2],$=H(F,q,I.p0,y,!1),z=H(F,q,I.p,y,!1),T=U(I.p0,$,1.333),Q=U(I.p,z,1.333);if(H(h.p0,T,o.p,Q,!0))return p;s&&t(markers,F,"purple"),I.cp1=T,I.cp2=Q;let B=pe(h.p0,I.p0)+pe(o.p,I.p);if(I.p0=h.p0,I.p=o.p,I.extreme=o.extreme,I.corner=o.corner,I.dimA=o.dimA,I.directionChange=o.directionChange,I.type="C",I.values=[I.cp1.x,I.cp1.y,I.cp2.x,I.cp2.y,I.p.x,I.p.y],B<n){let t=u?1+v:Math.abs(v),a=1+Math.abs(v);if(t=u?1+v:Math.abs(v)/a,pe(V([I.p0,I.cp1,I.cp2,I.p],t),e.p)>n*r)return p;let i=de([{type:"M",values:[h.p0.x,h.p0.y]},{type:"C",values:[h.cp1.x,h.cp1.y,h.cp2.x,h.cp2.y,h.p.x,h.p.y]},{type:"C",values:[o.cp1.x,o.cp1.y,o.cp2.x,o.cp2.y,o.p.x,o.p.y]}]),y=[{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]}],c=de(y),x=Math.abs(c/i-1);if(I.error=5*x*r,s){let e=me(y);l(markers,e,"orange")}x<.05*r&&(p=[I])}return p}function be(e,{keepExtremes:t=!0,keepInflections:l=!0,keepCorners:a=!0,extrapolateDominant:n=!0,tolerance:r=1}={}){let s=[e[0]],i=e.length;for(let n=2;i&&n<=i;n++){let p=e[n-1],u=n<i?e[n]:null,h=u?.type||null,{type:o,values:y,p0:c,p:x,cp1:f=null,cp2:g=null,extreme:d=!1,directionChange:v=!1,corner:m=!1,dimA:M=0}=p;if("C"===o&&"C"===h)if(a&&m||t&&d)s.push(p);else{let h=Ae(p,u,{tolerance:r}),o=0;
2
2
  //!count simplification success or failure - just for debugging
3
3
  if(1===h.length){p=h[0];let u=1;o+=p.error;
4
4
  //!log.push(`success1: ${i} and ${i + 1}`)
@@ -6,8 +6,6 @@ for(let s=n+1;o<r&&s<i;s++){let n=e[s];if("C"!==n.type||l&&p.directionChange||a&
6
6
  //!log.push(`success2: ${i} and ${n}`)
7
7
  p=i[0]}s.push(p),n<i&&(n+=u)}else s.push(p)}else s.push(p)}return s}function Ae(e,t,{tolerance:l=1}={}){let a=[e,t],n=function(e,t){let l=ie(e.cp2,e.p);if(0===l)return 0;let a=ie(e.p,t.cp1);if(0===a)return 0;let n=ie(e.cp2,t.cp1);return l/n}(e,t);if(!n)return a;let r=ie(e.p0,e.p),s=ie(t.p0,t.p),i=.08*Math.max(0,Math.min(r,s))*l,p=function(e,t,l=0){let{p0:a,cp1:n}=e,{p:r,cp2:s}=t;return n={x:(n.x-(1-l)*a.x)/l,y:(n.y-(1-l)*a.y)/l},s={x:(s.x-l*r.x)/(1-l),y:(s.y-l*r.y)/(1-l)},{p0:a,cp1:n,cp2:s,p:r}}(e,t,n),u=V([p.p0,p.cp1,p.cp2,p.p],n),h=ie(e.p,u),o=0,y=0,c=!1,x=h;if(h<i){let l=.5*(1+n);if(o=ie(V([t.p0,t.cp1,t.cp2,t.p],.5),V([p.p0,p.cp1,p.cp2,p.p],l)),x+=o,o<i){let t=.5*n;y=ie(V([e.p0,e.cp1,e.cp2,e.p],.5),V([p.p0,p.cp1,p.cp2,p.p],t)),x+=y,x<i&&(c=!0)}}return c&&(p.p0=e.p0,p.p=t.p,p.dimA=ie(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=x/i,a=[p]),a}function Ce(e,{tolerance:t=1,debug:l=!1}={}){let a=!1,n={flat:!0,steepness:0},r=e[0],s=e[e.length-1],i=new Set([...e.map(e=>+e.x.toFixed(8))]),p=new Set([...e.map(e=>+e.y.toFixed(8))]);if(1===i.size||1===p.size)return!l||n;let u=se(r,s),h=u/1e3*t,o=ve(e,!0);return o<h&&(a=!0),l&&(n.flat=a,n.steepness=o/u*10),l?n:a}function we(e){let t=[];for(let l=1,a=e.length;l<a;l++){let a=e[l],{type:n,values:r,p0:s=null,p:i=null,dimA:p=0}=a;r.length&&i&&s&&(p=p||ie(s,i),p&&t.push(p))}let l=t.sort(),a=Math.ceil(l.length/8);l=l.slice(0,a);let n=l.reduce((e,t)=>e+t,0)/a,r=n>112.5?0:Math.floor(75/n).toString().length;return Math.min(Math.max(0,r),8)}function Ee(e=0,t=3){if(!t)return Math.round(e);let l=10**t;return Math.round(e*l)/l}function Le(e,t=-1){if(t<0)return e;let l=e.length;for(let a=0;a<l;a++){let l=e[a].values,n=l.length;if(n)for(let r=0;r<n;r++)e[a].values[r]=Ee(l[r],t)}return e}function ke(e=[],{detectExtremes:l=!0,detectCorners:a=!0,detectDirection:n=!0,detectSemiExtremes:r=!1,debug:s=!1,addSquareLength:i=!0,addArea:p=!0}={}){e=function(e,{addSquareLength:t=!0,addArea:l=!1,addArcParams:a=!1,addAverageDim:n=!0}={}){let r=e[0],s={x:r.values[0],y:r.values[1]},i=s,p=s;r.p0=i,r.p=p,r.idx=0,r.dimA=0;let u=e.length,h=[r];for(let a=1;a<u;a++){let n,r,u=e[a],{type:o,values:y}=u,c=y.length;if(p=c?{x:y[c-2],y:y[c-1]}:s,u.p0=i,u.p=p,u.dimA=ie(i,p),"M"===o&&(s=p),"Q"===o||"C"===o)n={x:y[0],y:y[1]},r="C"===o?{x:y[2],y:y[3]}:null,u.cp1=n,r&&(u.cp2=r);else if("A"===o){let{rx:e,ry:t,cx:l,cy:a,startAngle:n,endAngle:r,deltaAngle:s}=J(i.x,i.y,...y);u.cx=l,u.cy=a,u.rx=e,u.ry=t,u.xAxisRotation=y[2]/180*Math.PI,u.largeArc=y[3],u.sweep=y[4],u.startAngle=n,u.endAngle=r,u.deltaAngle=s}if("Z"===o&&s.x!==p.x&&s.y!==p.y&&(u.closePath=!0),t&&(u.squareDist=se(i,p)),l){let e=0;"C"===o&&(e=ve([i,n,r,p],!1)),"Q"===o&&(e=ve([i,n,p],!1)),u.cptArea=e}u.idx=a,i=p,h.push(u)}return h}(e,{addSquareLength:i,addArea:p});let u=[],h=xe(W(e)),{left:o,right:y,top:c,bottom:x,width:f,height:g}=h;e[0].corner=!1,e[0].extreme=!1,e[0].semiExtreme=!1,e[0].directionChange=!1,e[0].closePath=!1;let d=[e[0]],v=e.length;for(let l=2;v&&l<=v;l++){let a=e[l-1],{type:n,values:i,p0:p,p:u,cp1:h=null,cp2:f=null,squareDist:g=0,cptArea:v=0,dimA:m=0}=a,M=e[l]||null;a.corner=!1,a.extreme=!1,a.semiExtreme=!1,a.directionChange=!1,a.closePath=!1;let b="C"===n||"Q"===n?"C"===n?[p,h,f,u]:[p,h,u]:[p,u],A=.1*m,C="Q"===n||"C"===n,w=M&&("Q"===M.type||"C"===M.type),E=!1;
8
8
  //!isFlat &&
9
- if(C){let e="C"===n?Math.abs(a.cp2.x-a.p.x):Math.abs(a.cp1.x-a.p.x),t="C"===n?Math.abs(a.cp2.y-a.p.y):Math.abs(a.cp1.y-a.p.y);if((0===t&&e>0||0===e&&t>0)&&(E=!0),u.x!==o&&u.y!==c&&u.x!==y&&u.y!==x||(E=!0),!E){if(K(null,b)){let e=te(b);e.length&&e[0]>.15&&(E=!0)}}}if(E&&(a.extreme=!0),C&&w){if(r&&!a.extreme){let e=Math.abs(u.x-f.x),t=Math.abs(u.y-f.y),l=!1;if(e&&t&&e>A||t>A){let e=R(f,u),t=R(u,M.cp1);l=ne(Math.abs(e+t)/2)}l&&(a.semiExtreme=!0)}if((a.cptArea<0&&M.cptArea>0||a.cptArea>0&&M.cptArea<0)&&(a.directionChange=!0),!a.extreme){let e=f||h,t=M.cp1,l=ve([e,u,t],!1),n=.01*se(e,t),r=Math.abs(l)<n,s=l<0&&a.cptArea>0||l>0&&a.cptArea<0;!r&&s&&(a.corner=!0)}}s&&(a.directionChange&&t(markers,a.p,"orange","1.5%","0.5"),a.corner&&t(markers,a.p,"magenta","1.5%","0.5"),a.extreme&&t(markers,a.p,"cyan","1%","0.5")),d.push(a)}return u={pathData:d,bb:h,dimA:(f+g)/2},u}function Pe(e={},t={},l={},a={}){let n=U(e,t,1.5),r=U(a,l,1.5),s=.03*pe(e,a),i=pe(n,r),p=null,u={type:"C",values:[t.x,t.y,l.x,l.y,a.x,a.y]};return i&&s&&i<s&&(p=H(e,t,a,l,!1),p&&(u.type="Q",u.values=[p.x,p.y,a.x,a.y],u.p0=e,u.cp1=p,u.cp2=null,u.p=a)),u}function Se(e,{toShorthands:t=!0,toLonghands:l=!1,toRelative:a=!0,toAbsolute:n=!1,decimals:r=3,arcToCubic:s=!1,quadraticToCubic:i=!1,hasRelatives:p=!0,hasShorthands:u=!0,hasQuadratics:h=!0,hasArcs:o=!0,testTypes:y=!1}={}){if(y){let t=Array.from(new Set(e.map(e=>e.type))).join("");/[lcqamts]/gi.test(t),h=/[qt]/gi.test(t),o=/[a]/gi.test(t),u=/[vhst]/gi.test(t),isPoly=/[mlz]/gi.test(t)}return a=!n&&a,t=!l&&t,h&&i&&(e=De(e)),o&&s&&(e=Ie(e)),t&&(e=function(e,t=-1,l=!1){let a;if(l){let t=e.map(e=>e.type).join("");a=/[astvqmhlc]/g.test(t)}e=l&&a?qe(e):e;let n=e.length,r=new Array(n),s=e[0];r[0]=s;let i={x:e[0].values[0],y:e[0].values[1]},p=i;for(let t=1;t<n;t++){let l=e[t];s=l;let{type:a,values:n}=l,u=n.length,h=[n[u-2],n[u-1]],o=e[t-1];p={x:h[0],y:h[1]};let y=Math.abs(p.x-i.x),c=Math.abs(p.y-i.y),x=.01*ie(i,p),f=!1,g=!1,d=!1;if("C"===a&&"C"===o.type||"Q"===a&&"Q"===o.type){let e="C"===o.type?{x:o.values[2],y:o.values[3]}:{x:o.values[0],y:o.values[1]},t={x:n[0],y:n[1]},l=i.x-e.x,a=i.y-e.y;x=.05*ie(e,t),f=ie({x:e.x+2*l,y:e.y+2*a},t)<x}else"L"===a&&(g=0===c||c<x,d=0===y||y<x,f=d||g);switch(a){case"L":g&&(s={type:"H",values:[n[0]]}),d&&(s={type:"V",values:[n[1]]});break;case"Q":f&&(s={type:"T",values:[p.x,p.y]});break;case"C":f&&(s={type:"S",values:[n[2],n[3],p.x,p.y]});break;default:s={type:a,values:n}}i=p,r[t]=s}return r}(e)),u&&l&&(e=ze(e)),n&&(e=$e(e)),r>-1&&a&&(e=Le(e,r)),a&&(e=function(e,t=-1){return qe(e,!0,t)}(e)),r>-1&&(e=Le(e,r)),e}function Ie(e,{arcAccuracy:t=1}={}){let l=[e[0]];for(let a=1,n=e.length;a<n;a++){let n=e[a],r=e[a-1].values,s=r.length,i={x:r[s-2],y:r[s-1]};if("A"===n.type){Qe(i,n.values,t).forEach(e=>{l.push(e)})}else l.push(n)}return l}function De(e){let t=[e[0]];for(let l=1,a=e.length;l<a;l++){let a=e[l],n=e[l-1].values,r=n.length,s={x:n[r-2],y:n[r-1]};"Q"===a.type?t.push(Fe(s,a.values)):t.push(a)}return t}function Fe(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 qe(e,t=!1,l=-1){l>=0&&(e[0].values=e[0].values.map(e=>+e.toFixed(l)));let a=e.length,n=e[0].values,r=n[0],s=n[1],i=r,p=s;for(let n=1;n<a;n++){let a=e[n],{type:u,values:h}=a,o=h.length,y=u.toLowerCase(),c=u.toUpperCase(),x=t?y:c;if(u!==x)switch(a.type=x,y){case"a":h[5]=t?h[5]-r:h[5]+r,h[6]=t?h[6]-s:h[6]+s;break;case"v":h[0]=t?h[0]-s:h[0]+s;break;case"h":h[0]=t?h[0]-r:h[0]+r;break;case"m":t?(h[0]-=r,h[1]-=s):(h[0]+=r,h[1]+=s),i=t?h[0]+r:h[0],p=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:r):h[e]+(e%2?s:r)}switch(y){case"z":r=i,s=p;break;case"h":r=t?r+h[0]:h[0];break;case"v":s=t?s+h[0]:h[0];break;case"m":i=h[o-2]+(t?r:0),p=h[o-1]+(t?s:0);default:r=h[o-2]+(t?r:0),s=h[o-1]+(t?s:0)}l>=0&&(a.values=a.values.map(e=>+e.toFixed(l)))}return e}function $e(e,t=-1){return qe(e,!1,t)}function ze(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=[],r={type:"M",values:(e=l&&a?$e(e,t):e)[0].values};n.push(r);for(let l=1,a=e.length;l<a;l++){let a,s,i,p,u,h,o,y,c=e[l],{type:x,values:f}=c,g=f.length,d=r.values,v=d.length,[m,M]=[f[g-2],f[g-1]],[b,A]=[d[v-2],d[v-1]];switch(x){case"H":r={type:"L",values:[f[0],A]};break;case"V":r={type:"L",values:[b,f[0]]};break;case"T":[a,s]=[d[0],d[1]],[b,A]=[d[v-2],d[v-1]],i=b+(b-a),p=A+(A-s),r={type:"Q",values:[i,p,m,M]};break;case"S":[a,s]=[d[0],d[1]],[b,A]=[d[v-2],d[v-1]],[o,y]=v>2&&"A"!==r.type?[d[2],d[3]]:[b,A],i=2*b-o,p=2*A-y,u=f[0],h=f[1],r={type:"C",values:[i,p,u,h,m,M]};break;default:r={type:x,values:f}}t>-1&&(r.values=r.values.map(e=>+e.toFixed(t))),n.push(r)}return n}function Te({p0:e={x:0,y:0},p:t={x:0,y:0},centroid:l={x:0,y:0},rx:a=0,ry:n=0,xAxisRotation:r=0,radToDegree:s=!1,startAngle:i=null,endAngle:p=null,deltaAngle:u=null}={}){if(!a||!n)return[];let h=[];const o=1.5707963267948966;let y=s?r:r*Math.PI/180,c=Math.cos(y),x=Math.sin(y);null!==i&&null!==p&&null!==u||({startAngle:i,endAngle:p,deltaAngle:u}=O(l,e,t));let f=a!==n?G(i,a,n):i,g=a!==n?G(u,a,n):u,d=Math.max(1,Math.ceil(Math.abs(g)/o)),v=g/d;for(let e=0;e<d;e++){const e=Math.abs(v)===o?.551785*Math.sign(v):4/3*Math.tan(v/4);let t=Math.cos(f),r=Math.sin(f),s=Math.cos(f+v),i=Math.sin(f+v),p=[];[{x:t-r*e,y:r+t*e},{x:s+i*e,y:i-s*e},{x:s,y:i}].forEach(e=>{let t=e.x*a,r=e.y*n;p.push(c*t-x*r+l.x,x*t+c*r+l.y)}),h.push({type:"C",values:p,cp1:{x:p[0],y:p[1]},cp2:{x:p[2],y:p[3]},p:{x:p[4],y:p[5]}}),f+=v}return h}function Qe(e,t,l=1){const a=2*Math.PI;let[n,r,s,i,p,u,h]=t;if(0===n||0===r)return[];let o=s?s*a/360:0,y=o?Math.sin(o):0,c=o?Math.cos(o):1,x=c*(e.x-u)/2+y*(e.y-h)/2,f=-y*(e.x-u)/2+c*(e.y-h)/2;if(0===x&&0===f)return[];n=Math.abs(n),r=Math.abs(r);let g=x*x/(n*n)+f*f/(r*r);if(g>1){let e=Math.sqrt(g);n*=e,r*=e}let d=n*n,v=n===r?d:r*r,m=x*x,M=f*f,b=d*v-d*M-v*m;b<=0?b=0:(b/=d*M+v*m,b=Math.sqrt(b)*(i===p?-1:1));let A=b?b*n/r*f:0,C=b?b*-r/n*x:0,w=c*A-y*C+(e.x+u)/2,E=y*A+c*C+(e.y+h)/2,L=(x-A)/n,k=(f-C)/r,P=(-x-A)/n,S=(-f-C)/r;const I=(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 D=I(1,0,L,k),F=I(L,k,P,S);0===p&&F>0?F-=2*Math.PI:1===p&&F<0&&(F+=2*Math.PI);let q=(+(Math.abs(F)/(a/4)).toFixed(0)||1)*l;F/=q;let $=[];const z=1.5707963267948966,T=.551785;let Q=F===z?T:F===-z?-T:4/3*Math.tan(F/4),B=F?Math.cos(F):1,j=F?Math.sin(F):0;const N=(e,t,l,a,n)=>{let r=e!=t?Math.cos(e):a,s=e!=t?Math.sin(e):n,i=Math.cos(e+t),p=Math.sin(e+t);return[{x:r-s*l,y:s+r*l},{x:i+p*l,y:p-i*l},{x:i,y:p}]};for(let e=0;e<q;e++){let e={type:"C",values:[]};N(D,F,Q,B,j).forEach(t=>{let l=t.x*n,a=t.y*r;e.values.push(c*l-y*a+w,y*l+c*a+E)}),$.push(e),D+=F}return $}function Be(e,{toAbsolute:t=!0,toLonghands:l=!0,quadraticToCubic:a=!1,arcToCubic:n=!1,arcAccuracy:r=4}={}){let s=Array.isArray(e),i=s&&"object"==typeof e[0]&&"function"==typeof e[0].constructor,p=s?e:function(e,t=!0){e=e.trim();let l={pathData:[],hasRelatives:!1,hasShorthands:!1,hasArcs:!1,hasQuadratics:!1,isPolygon:!1,log:[]};if(""===e)return l;let a,n=0,r=e.length,s="",i=-1,p="",u=!1,h=0,o=0,y=0,c=!1,x=new Set([]);const f=()=>{c&&("M"===s?s="L":"m"===s&&(s="l"),l.pathData.push({type:s,values:[]}),i++,o=0,c=!1)},g=(e=!1)=>{(e?h>0:""!==p)&&(t&&-1===i&&(a="Pathdata must start with M command",l.log.push(a),s="M",l.pathData.push({type:s,values:[]}),y=2,o=0,i++),"A"===s||"a"===s?(({val:p,valueIndex:o}=Oe(p,o)),l.pathData[i].values.push(...p)):(t&&p[1]&&"."!==p[1]&&"0"===p[0]&&(a=`${i}. command: Leading zeros not valid: ${p}`,l.log.push(a)),l.pathData[i].values.push(+p)),o++,p="",h=0,c=o>=y)},d=()=>{if(i>0){let e=l.pathData[i].values.length;if(e&&e<y||e&&e>y||("z"===s||"Z"===s)&&e>0){a=`${i}. command of type "${s}": ${y-e} values too few - ${y} expected`,l.log[l.log.length-1]!==a&&l.log.push(a)}}};let v=!1,m=!1,M=!1,b="";for(;n<r;){b=e.charCodeAt(n);let r=b>47&&b<58;if(r||(v=101===b||69===b,m=45===b||43===b,M=46===b),r||m||M||v){if(u||45!==b&&46!==b)f();else{let e=46===b;g(e),f(),e&&h++}p+=e[n],u=v,n++}else if((b<48||b>5759)&&Re(b))g(),n++;else{if(b>64){if(!je.has(b)){a=`${i}. command "${e[n]}" is not a valid type`,l.log.push(a),n++;continue}""!==p&&(l.pathData[i].values.push(+p),o++,p=""),t&&d(),s=e[n],y=Ne[b];let r="M"===s||"m"===s,u=i>0&&("z"===l.pathData[i].type||"Z"===l.pathData[i].type);x.add(s),u&&!r&&(l.pathData.push({type:"m",values:[0,0]}),i++),l.pathData.push({type:s,values:[]}),i++,h=0,o=0,c=!1,n++;continue}r||(a=`${i}. ${e[n]} is not a valid separarator or token`,l.log.push(a),p=""),n++}}g(),t&&d();t&&l.log.length&&(a="Invalid path data:\n"+l.log.join("\n"),"log"===t?console.log(a):console.warn(a));l.pathData[0].type="M";let A=Array.from(x).join("");return l.hasRelatives=/[lcqamtsvh]/g.test(A),l.hasShorthands=/[vhst]/gi.test(A),l.hasArcs=/[a]/gi.test(A),l.hasQuadratics=/[qt]/gi.test(A),l.isPolygon=!/[cqats]/gi.test(A),l}(e),{hasRelatives:u=!0,hasShorthands:h=!0,hasQuadratics:o=!0,hasArcs:y=!0}=p,c=i?p:p.pathData;return c=function(e=[],{toAbsolute:t=!0,toLonghands:l=!0,quadraticToCubic:a=!1,arcToCubic:n=!1,arcAccuracy:r=2,hasRelatives:s=!0,hasShorthands:i=!0,hasQuadratics:p=!0,hasArcs:u=!0,testTypes:h=!1}={}){if(h){let t=Array.from(new Set(e.map(e=>e.type))).join("");s=/[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),s&&t&&(e=qe(e,!1)),i&&l&&(e=ze(e,-1,!1)),u&&n&&(e=Ie(e,r)),p&&a&&(e=De(e)),e}(c,{toAbsolute:t,toLonghands:l,quadraticToCubic:a,arcToCubic:n,arcAccuracy:r,hasRelatives:u,hasShorthands:h,hasQuadratics:o,hasArcs:y}),c}const je=new Set([77,109,65,97,67,99,76,108,81,113,83,115,84,116,72,104,86,118,90,122]),Ne=new Uint8Array(128);Ne[77]=2,Ne[109]=2,Ne[65]=7,Ne[97]=7,Ne[67]=6,Ne[99]=6,Ne[76]=2,Ne[108]=2,Ne[81]=4,Ne[113]=4,Ne[83]=4,Ne[115]=4,Ne[84]=2,Ne[116]=2,Ne[72]=1,Ne[104]=1,Ne[86]=1,Ne[118]=1,Ne[90]=0,Ne[122]=0;const Ze=new Set([5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279]),Re=e=>32===e||44===e||10===e||13===e||8232===e||8233===e||9===e||11===e||12===e||160===e||e>=5760&&Ze.has(e),Oe=(e="",t=0)=>{let l=e.length;return 3===t&&2===l?(e=[+e[0],+e[1]],t++):4===t&&l>1?(e=[+e[0],+e.substring(1)],t++):3===t&&l>=3?(e=[+e[0],+e[1],+e.substring(2)],t+=2):e=[+e],{val:e,valueIndex:t}};function He(e){if("path"===e.nodeName.toLowerCase())return e;let t=function(e,t=!1){let l,a,n,r,s,i,p,u,h,o,y,c,x,f,g,d,v=[],m=e.nodeName;const M=(e,t=9)=>{const l="svg"!==e.nodeName?e.closest("svg"):e,a=e=>{if(null===e)return 0;let l=96,a=e.match(/([a-z]+)/gi);a=a?a[0]:"";let n,r=parseFloat(e);if(!a)return r;switch(a){case"in":n=l;break;case"pt":n=1/72*96;break;case"cm":n=1/2.54*96;break;case"mm":n=1/2.54*96/10;break;case"em":case"rem":n=16;break;default:n=1}return+(r*n).toFixed(t)};let n=l.getAttribute("width");n=n?a(n):300;let r=l.getAttribute("height");r=n?a(r):150;let s=l.getAttribute("viewBox");s=s?s.replace(/,/g," ").split(" ").filter(Boolean).map(e=>+e):[];let i=s.length?s[2]:n,p=s.length?s[3]:r,u=i/100,h=p/100,o=Math.sqrt((Math.pow(u,2)+Math.pow(h,2))/2),y=["x","width","x1","x2","rx","cx","r"],c=["y","height","y1","y2","ry","cy"];e.getAttributeNames().forEach(t=>{let l=e.getAttribute(t),n=l;if(y.includes(t)||c.includes(t)){let r=y.includes(t)?u:h;r="r"===t&&i!=p?o:r;let s=l.match(/([a-z|%]+)/gi);s=s?s[0]:"",n=l.includes("%")?parseFloat(l)*r:a(l),e.setAttribute(t,+n)}})};M(e);const b=t=>(l={},t.forEach(t=>{l[t]=+e.getAttribute(t)}),l);switch(m){case"path":n=e.getAttribute("d"),v=Be(n);break;case"rect":a=["x","y","width","height","rx","ry"],({x:r,y:s,width:i,height:p,rx:h,ry:o}=b(a)),h||o?(h=h||o,o=o||h,h>i/2&&(h=i/2),o>p/2&&(o=p/2),v=[{type:"M",values:[r+h,s]},{type:"L",values:[r+i-h,s]},{type:"A",values:[h,o,0,0,1,r+i,s+o]},{type:"L",values:[r+i,s+p-o]},{type:"A",values:[h,o,0,0,1,r+i-h,s+p]},{type:"L",values:[r+h,s+p]},{type:"A",values:[h,o,0,0,1,r,s+p-o]},{type:"L",values:[r,s+o]},{type:"A",values:[h,o,0,0,1,r+h,s]},{type:"Z",values:[]}]):v=[{type:"M",values:[r,s]},{type:"L",values:[r+i,s]},{type:"L",values:[r+i,s+p]},{type:"L",values:[r,s+p]},{type:"Z",values:[]}];break;case"circle":case"ellipse":a=["cx","cy","rx","ry","r"],({cx:y,cy:c,r:u,rx:h,ry:o}=b(a));let t="circle"===m;t?(h=u,o=u):(h=h||u,o=o||u);let l=t&&u>=1?1:h,M=t&&u>=1?1:h;v=[{type:"M",values:[y+h,c]},{type:"A",values:[l,M,0,1,1,y-h,c]},{type:"A",values:[l,M,0,1,1,y+h,c]}];break;case"line":a=["x1","y1","x2","y2"],({x1:x,y1:g,x2:f,y2:d}=b(a)),v=[{type:"M",values:[x,g]},{type:"L",values:[f,d]}];break;case"polygon":case"polyline":let A=e.getAttribute("points").replaceAll(","," ").split(" ").filter(Boolean);for(let e=0;e<A.length;e+=2)v.push({type:0===e?"M":"L",values:[+A[e],+A[e+1]]});"polygon"===m&&v.push({type:"Z",values:[]})}return t?function(e){return e.map(e=>`${e.type} ${e.values.join(" ")}`).join(" ")}(v):v}(e),l=t.map(e=>`${e.type} ${e.values} `).join(" "),a=[...e.attributes].map(e=>e.name),n=document.createElementNS("http://www.w3.org/2000/svg","path");n.setAttribute("d",l);let r=["x","y","cx","cy","dx","dy","r","rx","ry","width","height","points"];return a.forEach(t=>{if(!r.includes(t)){let l=e.getAttribute(t);n.setAttribute(t,l)}}),n}function Ue(e,{tolerance:t=1,flatBezierToLinetos:l=!0}={}){let a=[e[0]],n={x:e[0].values[0],y:e[0].values[1]},r=n,s=n;e[e.length-1].type.toLowerCase();for(let i=1,p=e.length;i<p;i++){let u=e[i],h=e[i+1]||e[p-1],o="z"===h.type.toLowerCase()?n:{x:h.values[h.values.length-2],y:h.values[h.values.length-1]},{type:y,values:c}=u,x=c.slice(-2);s="Z"!==y?{x:x[0],y:x[1]}:n;let f=!1,g=!1,d=Math.abs(o.x-r.x),v=Math.abs(o.y-r.y),m=Math.abs(s.x-r.x),M=Math.abs(s.y-r.y),b=Math.abs(o.x-s.x),A=Math.abs(o.y-s.y);if((!M&&!m||!A&&!b)&&(f=!0),!f){
10
- //!cross0 ||
11
- Math.abs(d*M-v*m)<.1*(d+v)&&(f=!0)}if(l||"C"!==y||(f=!1),l&&("C"===y||"Q"===y)){g=Ce([r,..."C"===y?[{x:c[0],y:c[1]},{x:c[2],y:c[3]}]:"Q"===y?[{x:c[0],y:c[1]}]:[],s],{tolerance:t}),g&&i<p-1&&(y="L",u.type="L",u.values=x)}f&&i<p-1&&"A"!==h.type&&("L"===y||l&&g)||(r=s,"M"===y&&(n=s),a.push(u))}return a}function Ve(e){let t=[];for(let l=0,a=e.length;l<a;l++){let a=e[l];if(!a)continue;let{type:n=null,values:r=[]}=a,s=e[l+1]?e[l+1]:null;"M"!==n&&"m"!==n||s&&(!s||"Z"!==s.type&&"z"!==s.type)?t.push(a):s&&l++}return t}function We(e){let t={x:e[0].values[0],y:e[0].values[1]},l=t,a=[e[0]];for(let n=1,r=e.length;n<r;n++){let r=e[n],s=e[n-1],i=e[n+1]||null,{type:p,values:u}=r,h="m"===s.type.toLowerCase()&&!i,o=u.length;if(l={x:u[o-2],y:u[o-1]},h||"L"!==p||l.x!==t.x||l.y!==t.y){if(!h&&("l"===p||"v"===p||"h"===p)){if("l"===p?"00"===u.join(""):0===u[0])continue}a.push(r),t=l}}return a}function Je(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:r}=t,s=r.length;if(s){let e={type:n,x:r[s-2],y:r[s-1],index:0};e.index=l,a.push(e)}}return a=a.sort((e,t)=>+e.y.toFixed(8)-+t.y.toFixed(8)||e.x-t.x),l=a[0].index,l?Ye(e,l):e}function Xe(e,{removeFinalLineto:t=!0,autoClose:l=!0}={}){let a=[],n=e.length,r={x:+e[0].values[0].toFixed(8),y:+e[0].values[1].toFixed(8)},s="z"===e[n-1].type.toLowerCase(),i=e.filter(e=>"L"===e.type),p=e[s?n-2:n-1],u=p.type,h=p.values.slice(-2).map(e=>+e.toFixed(8)),o=h[0]===r.x&&h[1]===r.y;!s&&l&&o&&(e.push({type:"Z",values:[]}),s=!0,n++);let y="L"!==e[1].type&&(!o||"L"===p.type);if(y=!1,!s)return e;let c=0;{let t=[];for(let l=0;l<n;l++){let a=e[l],{type:n,values:r}=a;if(r.length){let a=r.slice(-2),s=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,h={type:n,x:a[0],y:a[1],dist:0,index:0,prevL:s,nextL:i,prevCom:p,nextCom:u};h.index=l,t.push(h)}}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(8)-+t.y.toFixed(8)||e.x-t.x),c=t[0].index;e=c?Ye(e,c):e}return r={x:+e[0].values[0].toFixed(8),y:+e[0].values[1].toFixed(8)},n=e.length,p=e[n-2],u=p.type,h=p.values.slice(-2).map(e=>+e.toFixed(8)),o="L"===u&&h[0]===r.x&&h[1]===r.y,t&&o&&e.splice(n-2,1),a.push(...e),a}function Ye(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,r]=[a.values[0],a.values[1]].map(e=>+e.toFixed(8)),s=l?e[t-2]:e[t-1],i=s.values.length,[p,u]=[s.values[i-2],s.values[i-1]].map(e=>+e.toFixed(8));!l||n==p&&r==u||(e.pop(),e.push({type:"L",values:[n,r]},{type:"Z",values:[]}))}(e),l=t+1<e.length-1?t+1:e.length-1-n;let r,s,i=e.slice(l),p=e.slice(0,l);return p.shift(),r=p[p.length-1].values||[],s=[r[r.length-2],r[r.length-1]],n&&(i.pop(),p.push({type:"Z",values:[]})),e=[{type:"M",values:s},...i,...p]}function Ge(e=[],t=.666){let l=e.length;for(let a=1;a<l;a++){let l=e[a],n=e[a-1],{type:r,values:s}=l;e[a+1]&&e[a+1];let i=!1;if("C"===r){let l={x:s[0],y:s[1]},r={x:s[2],y:s[3]},p=n.values.slice(-2),u={x:p[0],y:p[1]},h={x:s[4],y:s[5]},o=ie(u,h),y=ie(u,l),c=ie(h,r),x=ie(l,r),f=H(u,l,h,r,!1),g=f?H(u,l,h,r,!0):null;if(f&&!g){H(h,U(h,r,3),u,l,!0)&&(i=!0)}y/o<.3&&c/o>.4&&(l=V([u,l],1+t/2),r=V([h,r],t),e[a].values[0]=l.x,e[a].values[1]=l.y,e[a].values[2]=r.x,e[a].values[3]=r.y),(g||f&&x<o/5)&&(i=!0),i&&(l=V([u,f],t),r=V([h,f],t),e[a].values[0]=l.x,e[a].values[1]=l.y,e[a].values[2]=r.x,e[a].values[3]=r.y)}}return e}function Ke(e,t,l=!0,a=!0){if(!Array.isArray(e)||void 0!==e[0].x){if(void 0===e[0].x)throw Error("Not a valid point array");e=(e=>Array.from(e).map(e=>[e.x,e.y]))(e)}if(1===(e=e.filter(function(t,l){return 0===l||!t.every((t,a)=>t===e[l-1][a])})).length)return[];if(2===e.length)return[{type:"L",values:[e[0][0],e[0][1]]},{type:"L",values:[e[1][0],e[1][1]]}];let n,r,s=e.length,i=nt(e[1],e[0]),p=nt(e[s-2],e[s-1]),u=(e=>{let t=[];return e.forEach(e=>{let l=e[1],a=e[2],n=e[3],r={type:"C",values:[l[0],l[1],a[0],a[1],n[0],n[1]]};t.push(r)}),t})(et(e,i,p,t));if(l){let t=u.length,l=u[0],i=u[t-1],p={x:e[0][0],y:e[0][1]},h={x:e[1][0],y:e[1][1]},o=e[2]?{x:e[2][0],y:e[2][1]}:null;o&&(n={x:l.values[0],y:l.values[1]},n=_e(n,p,h,o),l.values[0]=n.x,l.values[1]=n.y);let y={x:e[s-1][0],y:e[s-1][1]},c={x:e[s-2][0],y:e[s-2][1]},x=e[s-3]?{x:e[s-3][0],y:e[s-3][1]}:null;x&&(r={x:i.values[2],y:i.values[3]},r=_e(r,y,c,x),i.values[2]=r.x,i.values[3]=r.y),a&&(u=function(e=[],t=.666){let l=e.length;for(let a=0;a<l;a++){let l=e[a],n=e[a-1]||null,{type:r,values:s}=l;e[a+1]&&e[a+1];let i=!1;if("C"===r){let l={x:s[0],y:s[1]},r={x:s[2],y:s[3]},p=n.values.slice(-2),u={x:p[0],y:p[1]},h={x:s[4],y:s[5]},o=ie(u,h);ie(u,l),ie(h,r);let y=ie(l,r),c=H(u,l,h,r,!1);c&&(c&&H(u,l,h,r,!0)||y<o/5)&&(i=!0),i&&(l=V([u,c],t),r=V([h,c],t),e[a].values[0]=l.x,e[a].values[1]=l.y,e[a].values[2]=r.x,e[a].values[3]=r.y)}}return e}([{type:"M",values:[e[0][0],e[0][1]]},...u]),u.shift())}return u}function _e(e,t,l,a){let n=R(t,l),r=R(t,a)-n;return e=X(e,t.x,t.y,-r)}let et=(e,t,l,a)=>{let n;if(2===e.length){let a=.333*re(e[0],e[1],!0);return n=[e[0],st(e[0],it(t,a)),st(e[1],it(l,a)),e[1]],[n]}let r=function(e){let t=[],l=e.length,a=e[0],n=e[1],r=0,s=0;for(let i=0;i<l;i++)n=e[i],r=s+re(n,a,!0),t.push(r),s=r,a=n;return t=t.map(function(e){return e/s}),t}(e),s=tt(e,r,r,t,l);n=s[0];let i=s[1],p=s[2];if(0===i||i<a)return[n];if(i<a*a){let s=r,u=i,h=p;for(let o=0;o<20;o++){s=lt(n,e,s);let o=tt(e,r,s,t,l);if(n=o[0],i=o[1],p=o[2],i<a)return[n];if(p===h){let e=i/u;if(e>.9999&&e<1.0001)break}u=i,h=p}}let u=[],h=rt(e[p-1],e[p+1]);if(h.every(function(e){return 0===e})){h=rt(e[p-1],e[p]);let t=[-h[1],h[0]];h[0]=t[0],h[1]=t[1]}let o=function(e){let t=Math.sqrt(e[0]*e[0]+e[1]*e[1]);return 0===t?[0,0]:[e[0]/t,e[1]/t]}(h),y=it(o,-1);return u=u.concat(et(e.slice(0,p+1),t,o,a)),u=u.concat(et(e.slice(p),y,l,a)),u};const tt=(e,t,l,a,n)=>{let r,s,i;r=((e,t,l,a)=>{let n,r,s,i,p=e[0],u=e[e.length-1],h=[p,null,null,u],o=function(e){let t=[];for(;e--;)t.push([0,0]);return t}(t.length),y=t.length;for(let e=0;e<y;e++)s=t[e],i=1-s,n=o[e],n[0]=it(l,3*s*(i*i)),n[1]=it(a,3*i*(s*s));let c=[[0,0],[0,0]],x=[0,0],f=e.length;for(let l=0;l<f;l++)s=t[l],n=o[l],c[0][0]+=pt(n[0],n[0]),c[0][1]+=pt(n[0],n[1]),c[1][0]+=pt(n[0],n[1]),c[1][1]+=pt(n[1],n[1]),r=rt(e[l],V([p,p,u,u],s)),x[0]+=pt(n[0],r),x[1]+=pt(n[1],r);let g=c[0][0]*c[1][1]-c[1][0]*c[0][1],d=c[0][0]*x[1]-c[1][0]*x[0],v=x[0]*c[1][1]-x[1]*c[0][1],m=0===g?0:v/g,M=0===g?0:d/g,b=re(p,u,!0),A=1e-6*b;return m<A||M<A?(h[1]=st(p,it(l,.333*b)),h[2]=st(u,it(a,.333*b))):(h[1]=st(p,it(l,m)),h[2]=st(u,it(a,M))),h})(e,l,a,n);let p=function(e,t,l){let a,n,r,s,i,p,u;n=0,r=Math.floor(.5*e.length);let h=function(e,t){let l,a=[0],n=e[0],r=0;for(let s=1;s<=t;s++)l=V(e,s/t),r+=re(l,n,!0),a.push(r),n=l;return a=a.map(function(e){return e/r}),a}(t,10),o=e.length;for(i=0;i<o;i++)p=e[i],u=at(l[i],h,10),s=rt(V(t,u),p),a=s[0]*s[0]+s[1]*s[1],a>n&&(n=a,r=i);return[n,r]}(e,r,t);return s=p[0],i=p[1],[r,s,i]};function lt(e,t,l){return l.map((l,a)=>function(e,t,l){let a=V(e,l),n=a[0]-t[0],r=a[1]-t[1],s=ut(e,l),i=n*s[0]+r*s[1],p=s[0]*s[0]+s[1]*s[1],u=ut(e,l,!0),h=2*(n*u[0]+r*u[1]),o=p+h;if(Math.abs(o)<1e-10)return l;return l-i/o}(e,t[a],l))}function at(e,t,l){if(e<0)return 0;if(e>1)return 1;let a,n,r,s,i;for(let p=1;p<=l;p++)if(e<=t[p]){s=(p-1)/l,r=p/l,n=t[p-1],a=t[p],i=(e-n)/(a-n)*(r-s)+s;break}return i}function nt(e,t){let l=e[0]-t[0],a=e[1]-t[1],n=Math.sqrt(l*l+a*a);return 0===n?[0,0]:[l/n,a/n]}function rt(e,t){return[e[0]-t[0],e[1]-t[1]]}function st(e,t){return[e[0]+t[0],e[1]+t[1]]}function it(e,t){return[e[0]*t,e[1]*t]}function pt(e,t){return e[0]*t[0]+e[1]*t[1]}function ut(e,t,l=!1){let a,n,r=e[0],s=e[1],i=e[2],p=e[3],u=t,h=1-u,o=h*h,y=u*u;return l?(a=6*h*(i[0]-2*s[0]+r[0])+6*u*(p[0]-2*i[0]+s[0]),n=6*h*(i[1]-2*s[1]+r[1])+6*u*(p[1]-2*i[1]+s[1])):(a=3*o*(s[0]-r[0])+6*h*u*(i[0]-s[0])+3*y*(p[0]-i[0]),n=3*o*(s[1]-r[1])+6*h*u*(i[1]-s[1])+3*y*(p[1]-i[1])),[a,n]}function ht(e,{debug:t=!1,width:l=0,height:a=0,denoise:n=.9,keepCorners:r=!0,keepExtremes:s=!0,keepInflections:i=!1,manhattan:p=!1,absolute:u=!1,closed:h=!0,tolerance:o=1}={}){let y=s||r?function(e,{x:t=0,y:l=0,width:a=0,height:n=0,debug:r=!1}={}){let s=e.length,i=xe(e);a&&n||({x:t,y:l,width:a,height:n}=i);let p=.01*(a+n);for(let t=0;t<s;t++){let l=t>0?e[t-1]:e[s-1],a=e[t],n=ve([l,a,t<s-1?e[t+1]:e[s-1]],!1);a.area=n,a.dist=ie(l,a)}for(let t=0;t<s;t++){t>1?e[t-2]:e[s-1];let l=t>0?e[t-1]:e[s-1],a=e[t],n=t<s-1?e[t+1]:e[s-1],r=xe([l,n]);se(l,n);let u=Math.abs(l.area),h=Math.abs(a.area),o=Math.abs(n.area),y=!1,c=!a.area||h<p,{left:x,right:f,top:g,bottom:d}=r,v=a.x<=x||a.x>=f||a.y<=g||a.y>=d,m=a.x===i.left||a.x===i.right||a.y===i.top||a.y===i.bottom;ie(a,l);let M=a.y===l.y&&a.x!==l.x,b=a.x===l.x&&a.y!==l.y;
9
+ if(C){let e="C"===n?Math.abs(a.cp2.x-a.p.x):Math.abs(a.cp1.x-a.p.x),t="C"===n?Math.abs(a.cp2.y-a.p.y):Math.abs(a.cp1.y-a.p.y);if((0===t&&e>0||0===e&&t>0)&&(E=!0),u.x!==o&&u.y!==c&&u.x!==y&&u.y!==x||(E=!0),!E){if(K(null,b)){let e=te(b);e.length&&e[0]>.15&&(E=!0)}}}if(E&&(a.extreme=!0),C&&w){if(r&&!a.extreme){let e=Math.abs(u.x-f.x),t=Math.abs(u.y-f.y),l=!1;if(e&&t&&e>A||t>A){let e=R(f,u),t=R(u,M.cp1);l=ne(Math.abs(e+t)/2)}l&&(a.semiExtreme=!0)}if((a.cptArea<0&&M.cptArea>0||a.cptArea>0&&M.cptArea<0)&&(a.directionChange=!0),!a.extreme){let e=f||h,t=M.cp1,l=ve([e,u,t],!1),n=.01*se(e,t),r=Math.abs(l)<n,s=l<0&&a.cptArea>0||l>0&&a.cptArea<0;!r&&s&&(a.corner=!0)}}s&&(a.directionChange&&t(markers,a.p,"orange","1.5%","0.5"),a.corner&&t(markers,a.p,"magenta","1.5%","0.5"),a.extreme&&t(markers,a.p,"cyan","1%","0.5")),d.push(a)}return u={pathData:d,bb:h,dimA:(f+g)/2},u}function Se(e={},t={},l={},a={}){let n=U(e,t,1.5),r=U(a,l,1.5),s=.03*pe(e,a),i=pe(n,r),p=null,u={type:"C",values:[t.x,t.y,l.x,l.y,a.x,a.y]};return i&&s&&i<s&&(p=H(e,t,a,l,!1),p&&(u.type="Q",u.values=[p.x,p.y,a.x,a.y],u.p0=e,u.cp1=p,u.cp2=null,u.p=a)),u}function Pe(e,{toShorthands:t=!0,toLonghands:l=!1,toRelative:a=!0,toAbsolute:n=!1,decimals:r=3,arcToCubic:s=!1,quadraticToCubic:i=!1,hasRelatives:p=!0,hasShorthands:u=!0,hasQuadratics:h=!0,hasArcs:o=!0,testTypes:y=!1}={}){if(y){let t=Array.from(new Set(e.map(e=>e.type))).join("");/[lcqamts]/gi.test(t),h=/[qt]/gi.test(t),o=/[a]/gi.test(t),u=/[vhst]/gi.test(t),isPoly=/[mlz]/gi.test(t)}return a=!n&&a,t=!l&&t,h&&i&&(e=De(e)),o&&s&&(e=Ie(e)),t&&(e=function(e,t=-1,l=!1){let a;if(l){let t=e.map(e=>e.type).join("");a=/[astvqmhlc]/g.test(t)}e=l&&a?qe(e):e;let n=e.length,r=new Array(n),s=e[0];r[0]=s;let i={x:e[0].values[0],y:e[0].values[1]},p=i;for(let t=1;t<n;t++){let l=e[t];s=l;let{type:a,values:n}=l,u=n.length,h=[n[u-2],n[u-1]],o=e[t-1];p={x:h[0],y:h[1]};let y=Math.abs(p.x-i.x),c=Math.abs(p.y-i.y),x=.01*ie(i,p),f=!1,g=!1,d=!1;if("C"===a&&"C"===o.type||"Q"===a&&"Q"===o.type){let e="C"===o.type?{x:o.values[2],y:o.values[3]}:{x:o.values[0],y:o.values[1]},t={x:n[0],y:n[1]},l=i.x-e.x,a=i.y-e.y;x=.05*ie(e,t),f=ie({x:e.x+2*l,y:e.y+2*a},t)<x}else"L"===a&&(g=0===c||c<x,d=0===y||y<x,f=d||g);switch(a){case"L":g&&(s={type:"H",values:[n[0]]}),d&&(s={type:"V",values:[n[1]]});break;case"Q":f&&(s={type:"T",values:[p.x,p.y]});break;case"C":f&&(s={type:"S",values:[n[2],n[3],p.x,p.y]});break;default:s={type:a,values:n}}i=p,r[t]=s}return r}(e)),u&&l&&(e=ze(e)),n&&(e=$e(e)),r>-1&&a&&(e=Le(e,r)),a&&(e=function(e,t=-1){return qe(e,!0,t)}(e)),r>-1&&(e=Le(e,r)),e}function Ie(e,{arcAccuracy:t=1}={}){let l=[e[0]];for(let a=1,n=e.length;a<n;a++){let n=e[a],r=e[a-1].values,s=r.length,i={x:r[s-2],y:r[s-1]};if("A"===n.type){Qe(i,n.values,t).forEach(e=>{l.push(e)})}else l.push(n)}return l}function De(e){let t=[e[0]];for(let l=1,a=e.length;l<a;l++){let a=e[l],n=e[l-1].values,r=n.length,s={x:n[r-2],y:n[r-1]};"Q"===a.type?t.push(Fe(s,a.values)):t.push(a)}return t}function Fe(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 qe(e,t=!1,l=-1){l>=0&&(e[0].values=e[0].values.map(e=>+e.toFixed(l)));let a=e.length,n=e[0].values,r=n[0],s=n[1],i=r,p=s;for(let n=1;n<a;n++){let a=e[n],{type:u,values:h}=a,o=h.length,y=u.toLowerCase(),c=u.toUpperCase(),x=t?y:c;if(u!==x)switch(a.type=x,y){case"a":h[5]=t?h[5]-r:h[5]+r,h[6]=t?h[6]-s:h[6]+s;break;case"v":h[0]=t?h[0]-s:h[0]+s;break;case"h":h[0]=t?h[0]-r:h[0]+r;break;case"m":t?(h[0]-=r,h[1]-=s):(h[0]+=r,h[1]+=s),i=t?h[0]+r:h[0],p=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:r):h[e]+(e%2?s:r)}switch(y){case"z":r=i,s=p;break;case"h":r=t?r+h[0]:h[0];break;case"v":s=t?s+h[0]:h[0];break;case"m":i=h[o-2]+(t?r:0),p=h[o-1]+(t?s:0);default:r=h[o-2]+(t?r:0),s=h[o-1]+(t?s:0)}l>=0&&(a.values=a.values.map(e=>+e.toFixed(l)))}return e}function $e(e,t=-1){return qe(e,!1,t)}function ze(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=[],r={type:"M",values:(e=l&&a?$e(e,t):e)[0].values};n.push(r);for(let l=1,a=e.length;l<a;l++){let a,s,i,p,u,h,o,y,c=e[l],{type:x,values:f}=c,g=f.length,d=r.values,v=d.length,[m,M]=[f[g-2],f[g-1]],[b,A]=[d[v-2],d[v-1]];switch(x){case"H":r={type:"L",values:[f[0],A]};break;case"V":r={type:"L",values:[b,f[0]]};break;case"T":[a,s]=[d[0],d[1]],[b,A]=[d[v-2],d[v-1]],i=b+(b-a),p=A+(A-s),r={type:"Q",values:[i,p,m,M]};break;case"S":[a,s]=[d[0],d[1]],[b,A]=[d[v-2],d[v-1]],[o,y]=v>2&&"A"!==r.type?[d[2],d[3]]:[b,A],i=2*b-o,p=2*A-y,u=f[0],h=f[1],r={type:"C",values:[i,p,u,h,m,M]};break;default:r={type:x,values:f}}t>-1&&(r.values=r.values.map(e=>+e.toFixed(t))),n.push(r)}return n}function Te({p0:e={x:0,y:0},p:t={x:0,y:0},centroid:l={x:0,y:0},rx:a=0,ry:n=0,xAxisRotation:r=0,radToDegree:s=!1,startAngle:i=null,endAngle:p=null,deltaAngle:u=null}={}){if(!a||!n)return[];let h=[];const o=1.5707963267948966;let y=s?r:r*Math.PI/180,c=Math.cos(y),x=Math.sin(y);null!==i&&null!==p&&null!==u||({startAngle:i,endAngle:p,deltaAngle:u}=O(l,e,t));let f=a!==n?G(i,a,n):i,g=a!==n?G(u,a,n):u,d=Math.max(1,Math.ceil(Math.abs(g)/o)),v=g/d;for(let e=0;e<d;e++){const e=Math.abs(v)===o?.551785*Math.sign(v):4/3*Math.tan(v/4);let t=Math.cos(f),r=Math.sin(f),s=Math.cos(f+v),i=Math.sin(f+v),p=[];[{x:t-r*e,y:r+t*e},{x:s+i*e,y:i-s*e},{x:s,y:i}].forEach(e=>{let t=e.x*a,r=e.y*n;p.push(c*t-x*r+l.x,x*t+c*r+l.y)}),h.push({type:"C",values:p,cp1:{x:p[0],y:p[1]},cp2:{x:p[2],y:p[3]},p:{x:p[4],y:p[5]}}),f+=v}return h}function Qe(e,t,l=1){const a=2*Math.PI;let[n,r,s,i,p,u,h]=t;if(0===n||0===r)return[];let o=s?s*a/360:0,y=o?Math.sin(o):0,c=o?Math.cos(o):1,x=c*(e.x-u)/2+y*(e.y-h)/2,f=-y*(e.x-u)/2+c*(e.y-h)/2;if(0===x&&0===f)return[];n=Math.abs(n),r=Math.abs(r);let g=x*x/(n*n)+f*f/(r*r);if(g>1){let e=Math.sqrt(g);n*=e,r*=e}let d=n*n,v=n===r?d:r*r,m=x*x,M=f*f,b=d*v-d*M-v*m;b<=0?b=0:(b/=d*M+v*m,b=Math.sqrt(b)*(i===p?-1:1));let A=b?b*n/r*f:0,C=b?b*-r/n*x:0,w=c*A-y*C+(e.x+u)/2,E=y*A+c*C+(e.y+h)/2,L=(x-A)/n,k=(f-C)/r,S=(-x-A)/n,P=(-f-C)/r;const I=(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 D=I(1,0,L,k),F=I(L,k,S,P);0===p&&F>0?F-=2*Math.PI:1===p&&F<0&&(F+=2*Math.PI);let q=(+(Math.abs(F)/(a/4)).toFixed(0)||1)*l;F/=q;let $=[];const z=1.5707963267948966,T=.551785;let Q=F===z?T:F===-z?-T:4/3*Math.tan(F/4),B=F?Math.cos(F):1,j=F?Math.sin(F):0;const N=(e,t,l,a,n)=>{let r=e!=t?Math.cos(e):a,s=e!=t?Math.sin(e):n,i=Math.cos(e+t),p=Math.sin(e+t);return[{x:r-s*l,y:s+r*l},{x:i+p*l,y:p-i*l},{x:i,y:p}]};for(let e=0;e<q;e++){let e={type:"C",values:[]};N(D,F,Q,B,j).forEach(t=>{let l=t.x*n,a=t.y*r;e.values.push(c*l-y*a+w,y*l+c*a+E)}),$.push(e),D+=F}return $}function Be(e,{toAbsolute:t=!0,toLonghands:l=!0,quadraticToCubic:a=!1,arcToCubic:n=!1,arcAccuracy:r=4}={}){let s=Array.isArray(e),i=s&&"object"==typeof e[0]&&"function"==typeof e[0].constructor,p=s?e:function(e,t=!0){e=e.trim();let l={pathData:[],hasRelatives:!1,hasShorthands:!1,hasArcs:!1,hasQuadratics:!1,isPolygon:!1,log:[]};if(""===e)return l;let a,n=0,r=e.length,s="",i=-1,p="",u=!1,h=0,o=0,y=0,c=!1,x=new Set([]);const f=()=>{c&&("M"===s?s="L":"m"===s&&(s="l"),l.pathData.push({type:s,values:[]}),i++,o=0,c=!1)},g=(e=!1)=>{(e?h>0:""!==p)&&(t&&-1===i&&(a="Pathdata must start with M command",l.log.push(a),s="M",l.pathData.push({type:s,values:[]}),y=2,o=0,i++),"A"===s||"a"===s?(({val:p,valueIndex:o}=Oe(p,o)),l.pathData[i].values.push(...p)):(t&&p[1]&&"."!==p[1]&&"0"===p[0]&&(a=`${i}. command: Leading zeros not valid: ${p}`,l.log.push(a)),l.pathData[i].values.push(+p)),o++,p="",h=0,c=o>=y)},d=()=>{if(i>0){let e=l.pathData[i].values.length;if(e&&e<y||e&&e>y||("z"===s||"Z"===s)&&e>0){a=`${i}. command of type "${s}": ${y-e} values too few - ${y} expected`,l.log[l.log.length-1]!==a&&l.log.push(a)}}};let v=!1,m=!1,M=!1,b="";for(;n<r;){b=e.charCodeAt(n);let r=b>47&&b<58;if(r||(v=101===b||69===b,m=45===b||43===b,M=46===b),r||m||M||v){if(u||45!==b&&46!==b)f();else{let e=46===b;g(e),f(),e&&h++}p+=e[n],u=v,n++}else if((b<48||b>5759)&&Re(b))g(),n++;else{if(b>64){if(!je.has(b)){a=`${i}. command "${e[n]}" is not a valid type`,l.log.push(a),n++;continue}""!==p&&(l.pathData[i].values.push(+p),o++,p=""),t&&d(),s=e[n],y=Ne[b];let r="M"===s||"m"===s,u=i>0&&("z"===l.pathData[i].type||"Z"===l.pathData[i].type);x.add(s),u&&!r&&(l.pathData.push({type:"m",values:[0,0]}),i++),l.pathData.push({type:s,values:[]}),i++,h=0,o=0,c=!1,n++;continue}r||(a=`${i}. ${e[n]} is not a valid separarator or token`,l.log.push(a),p=""),n++}}g(),t&&d();t&&l.log.length&&(a="Invalid path data:\n"+l.log.join("\n"),"log"===t?console.log(a):console.warn(a));l.pathData[0].type="M";let A=Array.from(x).join("");return l.hasRelatives=/[lcqamtsvh]/g.test(A),l.hasShorthands=/[vhst]/gi.test(A),l.hasArcs=/[a]/gi.test(A),l.hasQuadratics=/[qt]/gi.test(A),l.isPolygon=!/[cqats]/gi.test(A),l}(e),{hasRelatives:u=!0,hasShorthands:h=!0,hasQuadratics:o=!0,hasArcs:y=!0}=p,c=i?p:p.pathData;return c=function(e=[],{toAbsolute:t=!0,toLonghands:l=!0,quadraticToCubic:a=!1,arcToCubic:n=!1,arcAccuracy:r=2,hasRelatives:s=!0,hasShorthands:i=!0,hasQuadratics:p=!0,hasArcs:u=!0,testTypes:h=!1}={}){if(h){let t=Array.from(new Set(e.map(e=>e.type))).join("");s=/[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),s&&t&&(e=qe(e,!1)),i&&l&&(e=ze(e,-1,!1)),u&&n&&(e=Ie(e,r)),p&&a&&(e=De(e)),e}(c,{toAbsolute:t,toLonghands:l,quadraticToCubic:a,arcToCubic:n,arcAccuracy:r,hasRelatives:u,hasShorthands:h,hasQuadratics:o,hasArcs:y}),c}const je=new Set([77,109,65,97,67,99,76,108,81,113,83,115,84,116,72,104,86,118,90,122]),Ne=new Uint8Array(128);Ne[77]=2,Ne[109]=2,Ne[65]=7,Ne[97]=7,Ne[67]=6,Ne[99]=6,Ne[76]=2,Ne[108]=2,Ne[81]=4,Ne[113]=4,Ne[83]=4,Ne[115]=4,Ne[84]=2,Ne[116]=2,Ne[72]=1,Ne[104]=1,Ne[86]=1,Ne[118]=1,Ne[90]=0,Ne[122]=0;const Ze=new Set([5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279]),Re=e=>32===e||44===e||10===e||13===e||8232===e||8233===e||9===e||11===e||12===e||160===e||e>=5760&&Ze.has(e),Oe=(e="",t=0)=>{let l=e.length;return 3===t&&2===l?(e=[+e[0],+e[1]],t++):4===t&&l>1?(e=[+e[0],+e.substring(1)],t++):3===t&&l>=3?(e=[+e[0],+e[1],+e.substring(2)],t+=2):e=[+e],{val:e,valueIndex:t}};function He(e){if("path"===e.nodeName.toLowerCase())return e;let t=function(e,t=!1){let l,a,n,r,s,i,p,u,h,o,y,c,x,f,g,d,v=[],m=e.nodeName;const M=(e,t=9)=>{const l="svg"!==e.nodeName?e.closest("svg"):e,a=e=>{if(null===e)return 0;let l=96,a=e.match(/([a-z]+)/gi);a=a?a[0]:"";let n,r=parseFloat(e);if(!a)return r;switch(a){case"in":n=l;break;case"pt":n=1/72*96;break;case"cm":n=1/2.54*96;break;case"mm":n=1/2.54*96/10;break;case"em":case"rem":n=16;break;default:n=1}return+(r*n).toFixed(t)};let n=l.getAttribute("width");n=n?a(n):300;let r=l.getAttribute("height");r=n?a(r):150;let s=l.getAttribute("viewBox");s=s?s.replace(/,/g," ").split(" ").filter(Boolean).map(e=>+e):[];let i=s.length?s[2]:n,p=s.length?s[3]:r,u=i/100,h=p/100,o=Math.sqrt((Math.pow(u,2)+Math.pow(h,2))/2),y=["x","width","x1","x2","rx","cx","r"],c=["y","height","y1","y2","ry","cy"];e.getAttributeNames().forEach(t=>{let l=e.getAttribute(t),n=l;if(y.includes(t)||c.includes(t)){let r=y.includes(t)?u:h;r="r"===t&&i!=p?o:r;let s=l.match(/([a-z|%]+)/gi);s=s?s[0]:"",n=l.includes("%")?parseFloat(l)*r:a(l),e.setAttribute(t,+n)}})};M(e);const b=t=>(l={},t.forEach(t=>{l[t]=+e.getAttribute(t)}),l);switch(m){case"path":n=e.getAttribute("d"),v=Be(n);break;case"rect":a=["x","y","width","height","rx","ry"],({x:r,y:s,width:i,height:p,rx:h,ry:o}=b(a)),h||o?(h=h||o,o=o||h,h>i/2&&(h=i/2),o>p/2&&(o=p/2),v=[{type:"M",values:[r+h,s]},{type:"L",values:[r+i-h,s]},{type:"A",values:[h,o,0,0,1,r+i,s+o]},{type:"L",values:[r+i,s+p-o]},{type:"A",values:[h,o,0,0,1,r+i-h,s+p]},{type:"L",values:[r+h,s+p]},{type:"A",values:[h,o,0,0,1,r,s+p-o]},{type:"L",values:[r,s+o]},{type:"A",values:[h,o,0,0,1,r+h,s]},{type:"Z",values:[]}]):v=[{type:"M",values:[r,s]},{type:"L",values:[r+i,s]},{type:"L",values:[r+i,s+p]},{type:"L",values:[r,s+p]},{type:"Z",values:[]}];break;case"circle":case"ellipse":a=["cx","cy","rx","ry","r"],({cx:y,cy:c,r:u,rx:h,ry:o}=b(a));let t="circle"===m;t?(h=u,o=u):(h=h||u,o=o||u);let l=t&&u>=1?1:h,M=t&&u>=1?1:h;v=[{type:"M",values:[y+h,c]},{type:"A",values:[l,M,0,1,1,y-h,c]},{type:"A",values:[l,M,0,1,1,y+h,c]}];break;case"line":a=["x1","y1","x2","y2"],({x1:x,y1:g,x2:f,y2:d}=b(a)),v=[{type:"M",values:[x,g]},{type:"L",values:[f,d]}];break;case"polygon":case"polyline":let A=e.getAttribute("points").replaceAll(","," ").split(" ").filter(Boolean);for(let e=0;e<A.length;e+=2)v.push({type:0===e?"M":"L",values:[+A[e],+A[e+1]]});"polygon"===m&&v.push({type:"Z",values:[]})}return t?function(e){return e.map(e=>`${e.type} ${e.values.join(" ")}`).join(" ")}(v):v}(e),l=t.map(e=>`${e.type} ${e.values} `).join(" "),a=[...e.attributes].map(e=>e.name),n=document.createElementNS("http://www.w3.org/2000/svg","path");n.setAttribute("d",l);let r=["x","y","cx","cy","dx","dy","r","rx","ry","width","height","points"];return a.forEach(t=>{if(!r.includes(t)){let l=e.getAttribute(t);n.setAttribute(t,l)}}),n}function Ue(e,{tolerance:t=1,flatBezierToLinetos:l=!0}={}){let a=[e[0]],n={x:e[0].values[0],y:e[0].values[1]},r=n,s=n;e[e.length-1].type.toLowerCase();for(let i=1,p=e.length;i<p;i++){let u=e[i],h=e[i+1]||e[p-1],o="z"===h.type.toLowerCase()?n:{x:h.values[h.values.length-2],y:h.values[h.values.length-1]},{type:y,values:c}=u,x=c.slice(-2);s="Z"!==y?{x:x[0],y:x[1]}:n;let f=o?ve([r,s,o],!0):1/0,g=se(r,o),d=f<(g?g/333*t:0),v=!1;if(l||"C"!==y||(d=!1),l&&("C"===y||"Q"===y)){v=Ce([r,..."C"===y?[{x:c[0],y:c[1]},{x:c[2],y:c[3]}]:"Q"===y?[{x:c[0],y:c[1]}]:[],s],{tolerance:t}),v&&i<p-1&&(y="L",u.type="L",u.values=x)}d&&i<p-1&&"A"!==h.type&&("L"===y||l&&v)||(r=s,"M"===y&&(n=s),a.push(u))}return a}function Ve(e){let t=[];for(let l=0,a=e.length;l<a;l++){let a=e[l];if(!a)continue;let{type:n=null,values:r=[]}=a,s=e[l+1]?e[l+1]:null;"M"!==n&&"m"!==n||s&&(!s||"Z"!==s.type&&"z"!==s.type)?t.push(a):s&&l++}return t}function We(e){let t={x:e[0].values[0],y:e[0].values[1]},l=t,a=[e[0]];for(let n=1,r=e.length;n<r;n++){let r=e[n],s=e[n-1],i=e[n+1]||null,{type:p,values:u}=r,h="m"===s.type.toLowerCase()&&!i,o=u.length;if(l={x:u[o-2],y:u[o-1]},h||"L"!==p||l.x!==t.x||l.y!==t.y){if(!h&&("l"===p||"v"===p||"h"===p)){if("l"===p?"00"===u.join(""):0===u[0])continue}a.push(r),t=l}}return a}function Je(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:r}=t,s=r.length;if(s){let e={type:n,x:r[s-2],y:r[s-1],index:0};e.index=l,a.push(e)}}return a=a.sort((e,t)=>+e.y.toFixed(8)-+t.y.toFixed(8)||e.x-t.x),l=a[0].index,l?Ye(e,l):e}function Xe(e,{removeFinalLineto:t=!0,autoClose:l=!0}={}){let a=[],n=e.length,r={x:+e[0].values[0].toFixed(8),y:+e[0].values[1].toFixed(8)},s="z"===e[n-1].type.toLowerCase(),i=e.filter(e=>"L"===e.type),p=e[s?n-2:n-1],u=p.type,h=p.values.slice(-2).map(e=>+e.toFixed(8)),o=h[0]===r.x&&h[1]===r.y;!s&&l&&o&&(e.push({type:"Z",values:[]}),s=!0,n++);let y="L"!==e[1].type&&(!o||"L"===p.type);if(y=!1,!s)return e;let c=0;{let t=[];for(let l=0;l<n;l++){let a=e[l],{type:n,values:r}=a;if(r.length){let a=r.slice(-2),s=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,h={type:n,x:a[0],y:a[1],dist:0,index:0,prevL:s,nextL:i,prevCom:p,nextCom:u};h.index=l,t.push(h)}}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(8)-+t.y.toFixed(8)||e.x-t.x),c=t[0].index;e=c?Ye(e,c):e}return r={x:+e[0].values[0].toFixed(8),y:+e[0].values[1].toFixed(8)},n=e.length,p=e[n-2],u=p.type,h=p.values.slice(-2).map(e=>+e.toFixed(8)),o="L"===u&&h[0]===r.x&&h[1]===r.y,t&&o&&e.splice(n-2,1),a.push(...e),a}function Ye(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,r]=[a.values[0],a.values[1]].map(e=>+e.toFixed(8)),s=l?e[t-2]:e[t-1],i=s.values.length,[p,u]=[s.values[i-2],s.values[i-1]].map(e=>+e.toFixed(8));!l||n==p&&r==u||(e.pop(),e.push({type:"L",values:[n,r]},{type:"Z",values:[]}))}(e),l=t+1<e.length-1?t+1:e.length-1-n;let r,s,i=e.slice(l),p=e.slice(0,l);return p.shift(),r=p[p.length-1].values||[],s=[r[r.length-2],r[r.length-1]],n&&(i.pop(),p.push({type:"Z",values:[]})),e=[{type:"M",values:s},...i,...p]}function Ge(e=[],t=.666){let l=e.length;for(let a=1;a<l;a++){let l=e[a],n=e[a-1],{type:r,values:s}=l;e[a+1]&&e[a+1];let i=!1;if("C"===r){let l={x:s[0],y:s[1]},r={x:s[2],y:s[3]},p=n.values.slice(-2),u={x:p[0],y:p[1]},h={x:s[4],y:s[5]},o=ie(u,h),y=ie(u,l),c=ie(h,r),x=ie(l,r),f=H(u,l,h,r,!1),g=f?H(u,l,h,r,!0):null;if(f&&!g){H(h,U(h,r,3),u,l,!0)&&(i=!0)}y/o<.3&&c/o>.4&&(l=V([u,l],1+t/2),r=V([h,r],t),e[a].values[0]=l.x,e[a].values[1]=l.y,e[a].values[2]=r.x,e[a].values[3]=r.y),(g||f&&x<o/5)&&(i=!0),i&&(l=V([u,f],t),r=V([h,f],t),e[a].values[0]=l.x,e[a].values[1]=l.y,e[a].values[2]=r.x,e[a].values[3]=r.y)}}return e}function Ke(e,t,l=!0,a=!0){if(!Array.isArray(e)||void 0!==e[0].x){if(void 0===e[0].x)throw Error("Not a valid point array");e=(e=>Array.from(e).map(e=>[e.x,e.y]))(e)}if(1===(e=e.filter(function(t,l){return 0===l||!t.every((t,a)=>t===e[l-1][a])})).length)return[];if(2===e.length)return[{type:"L",values:[e[0][0],e[0][1]]},{type:"L",values:[e[1][0],e[1][1]]}];let n,r,s=e.length,i=nt(e[1],e[0]),p=nt(e[s-2],e[s-1]),u=(e=>{let t=[];return e.forEach(e=>{let l=e[1],a=e[2],n=e[3],r={type:"C",values:[l[0],l[1],a[0],a[1],n[0],n[1]]};t.push(r)}),t})(et(e,i,p,t));if(l){let t=u.length,l=u[0],i=u[t-1],p={x:e[0][0],y:e[0][1]},h={x:e[1][0],y:e[1][1]},o=e[2]?{x:e[2][0],y:e[2][1]}:null;o&&(n={x:l.values[0],y:l.values[1]},n=_e(n,p,h,o),l.values[0]=n.x,l.values[1]=n.y);let y={x:e[s-1][0],y:e[s-1][1]},c={x:e[s-2][0],y:e[s-2][1]},x=e[s-3]?{x:e[s-3][0],y:e[s-3][1]}:null;x&&(r={x:i.values[2],y:i.values[3]},r=_e(r,y,c,x),i.values[2]=r.x,i.values[3]=r.y),a&&(u=function(e=[],t=.666){let l=e.length;for(let a=0;a<l;a++){let l=e[a],n=e[a-1]||null,{type:r,values:s}=l;e[a+1]&&e[a+1];let i=!1;if("C"===r){let l={x:s[0],y:s[1]},r={x:s[2],y:s[3]},p=n.values.slice(-2),u={x:p[0],y:p[1]},h={x:s[4],y:s[5]},o=ie(u,h);ie(u,l),ie(h,r);let y=ie(l,r),c=H(u,l,h,r,!1);c&&(c&&H(u,l,h,r,!0)||y<o/5)&&(i=!0),i&&(l=V([u,c],t),r=V([h,c],t),e[a].values[0]=l.x,e[a].values[1]=l.y,e[a].values[2]=r.x,e[a].values[3]=r.y)}}return e}([{type:"M",values:[e[0][0],e[0][1]]},...u]),u.shift())}return u}function _e(e,t,l,a){let n=R(t,l),r=R(t,a)-n;return e=X(e,t.x,t.y,-r)}let et=(e,t,l,a)=>{let n;if(2===e.length){let a=.333*re(e[0],e[1],!0);return n=[e[0],st(e[0],it(t,a)),st(e[1],it(l,a)),e[1]],[n]}let r=function(e){let t=[],l=e.length,a=e[0],n=e[1],r=0,s=0;for(let i=0;i<l;i++)n=e[i],r=s+re(n,a,!0),t.push(r),s=r,a=n;return t=t.map(function(e){return e/s}),t}(e),s=tt(e,r,r,t,l);n=s[0];let i=s[1],p=s[2];if(0===i||i<a)return[n];if(i<a*a){let s=r,u=i,h=p;for(let o=0;o<20;o++){s=lt(n,e,s);let o=tt(e,r,s,t,l);if(n=o[0],i=o[1],p=o[2],i<a)return[n];if(p===h){let e=i/u;if(e>.9999&&e<1.0001)break}u=i,h=p}}let u=[],h=rt(e[p-1],e[p+1]);if(h.every(function(e){return 0===e})){h=rt(e[p-1],e[p]);let t=[-h[1],h[0]];h[0]=t[0],h[1]=t[1]}let o=function(e){let t=Math.sqrt(e[0]*e[0]+e[1]*e[1]);return 0===t?[0,0]:[e[0]/t,e[1]/t]}(h),y=it(o,-1);return u=u.concat(et(e.slice(0,p+1),t,o,a)),u=u.concat(et(e.slice(p),y,l,a)),u};const tt=(e,t,l,a,n)=>{let r,s,i;r=((e,t,l,a)=>{let n,r,s,i,p=e[0],u=e[e.length-1],h=[p,null,null,u],o=function(e){let t=[];for(;e--;)t.push([0,0]);return t}(t.length),y=t.length;for(let e=0;e<y;e++)s=t[e],i=1-s,n=o[e],n[0]=it(l,3*s*(i*i)),n[1]=it(a,3*i*(s*s));let c=[[0,0],[0,0]],x=[0,0],f=e.length;for(let l=0;l<f;l++)s=t[l],n=o[l],c[0][0]+=pt(n[0],n[0]),c[0][1]+=pt(n[0],n[1]),c[1][0]+=pt(n[0],n[1]),c[1][1]+=pt(n[1],n[1]),r=rt(e[l],V([p,p,u,u],s)),x[0]+=pt(n[0],r),x[1]+=pt(n[1],r);let g=c[0][0]*c[1][1]-c[1][0]*c[0][1],d=c[0][0]*x[1]-c[1][0]*x[0],v=x[0]*c[1][1]-x[1]*c[0][1],m=0===g?0:v/g,M=0===g?0:d/g,b=re(p,u,!0),A=1e-6*b;return m<A||M<A?(h[1]=st(p,it(l,.333*b)),h[2]=st(u,it(a,.333*b))):(h[1]=st(p,it(l,m)),h[2]=st(u,it(a,M))),h})(e,l,a,n);let p=function(e,t,l){let a,n,r,s,i,p,u;n=0,r=Math.floor(.5*e.length);let h=function(e,t){let l,a=[0],n=e[0],r=0;for(let s=1;s<=t;s++)l=V(e,s/t),r+=re(l,n,!0),a.push(r),n=l;return a=a.map(function(e){return e/r}),a}(t,10),o=e.length;for(i=0;i<o;i++)p=e[i],u=at(l[i],h,10),s=rt(V(t,u),p),a=s[0]*s[0]+s[1]*s[1],a>n&&(n=a,r=i);return[n,r]}(e,r,t);return s=p[0],i=p[1],[r,s,i]};function lt(e,t,l){return l.map((l,a)=>function(e,t,l){let a=V(e,l),n=a[0]-t[0],r=a[1]-t[1],s=ut(e,l),i=n*s[0]+r*s[1],p=s[0]*s[0]+s[1]*s[1],u=ut(e,l,!0),h=2*(n*u[0]+r*u[1]),o=p+h;if(Math.abs(o)<1e-10)return l;return l-i/o}(e,t[a],l))}function at(e,t,l){if(e<0)return 0;if(e>1)return 1;let a,n,r,s,i;for(let p=1;p<=l;p++)if(e<=t[p]){s=(p-1)/l,r=p/l,n=t[p-1],a=t[p],i=(e-n)/(a-n)*(r-s)+s;break}return i}function nt(e,t){let l=e[0]-t[0],a=e[1]-t[1],n=Math.sqrt(l*l+a*a);return 0===n?[0,0]:[l/n,a/n]}function rt(e,t){return[e[0]-t[0],e[1]-t[1]]}function st(e,t){return[e[0]+t[0],e[1]+t[1]]}function it(e,t){return[e[0]*t,e[1]*t]}function pt(e,t){return e[0]*t[0]+e[1]*t[1]}function ut(e,t,l=!1){let a,n,r=e[0],s=e[1],i=e[2],p=e[3],u=t,h=1-u,o=h*h,y=u*u;return l?(a=6*h*(i[0]-2*s[0]+r[0])+6*u*(p[0]-2*i[0]+s[0]),n=6*h*(i[1]-2*s[1]+r[1])+6*u*(p[1]-2*i[1]+s[1])):(a=3*o*(s[0]-r[0])+6*h*u*(i[0]-s[0])+3*y*(p[0]-i[0]),n=3*o*(s[1]-r[1])+6*h*u*(i[1]-s[1])+3*y*(p[1]-i[1])),[a,n]}function ht(e,{debug:t=!1,width:l=0,height:a=0,denoise:n=.9,keepCorners:r=!0,keepExtremes:s=!0,keepInflections:i=!1,manhattan:p=!1,absolute:u=!1,closed:h=!0,tolerance:o=1}={}){let y=s||r?function(e,{x:t=0,y:l=0,width:a=0,height:n=0,debug:r=!1}={}){let s=e.length,i=xe(e);a&&n||({x:t,y:l,width:a,height:n}=i);let p=.01*(a+n);for(let t=0;t<s;t++){let l=t>0?e[t-1]:e[s-1],a=e[t],n=ve([l,a,t<s-1?e[t+1]:e[s-1]],!1);a.area=n,a.dist=ie(l,a)}for(let t=0;t<s;t++){t>1?e[t-2]:e[s-1];let l=t>0?e[t-1]:e[s-1],a=e[t],n=t<s-1?e[t+1]:e[s-1],r=xe([l,n]);se(l,n);let u=Math.abs(l.area),h=Math.abs(a.area),o=Math.abs(n.area),y=!1,c=!a.area||h<p,{left:x,right:f,top:g,bottom:d}=r,v=a.x<=x||a.x>=f||a.y<=g||a.y>=d,m=a.x===i.left||a.x===i.right||a.y===i.top||a.y===i.bottom;ie(a,l);let M=a.y===l.y&&a.x!==l.x,b=a.x===l.x&&a.y!==l.y;
12
10
  //!isCloseExtreme &&
13
- (M||b)&&(m=!0);let A=l.area<0&&a.area>0||l.area>0&&a.area<0,C=A&&!c;if(y=C,v&&!l.isDirChange&&(m=!0),b&&l.isHorizontal&&(l.isCorner=!0,l.isExtreme=!1,m=!1),C&&(l.isDirChange||l.isExtreme)&&(C=!1,a.isDirChange=!1),l.isExtreme&&h>o&&!C&&a.isHorizontal,m||A||h>u){let e=O(a,n,l),{deltaAngleDeg:t}=e;t=Math.abs(t),y=!(t<3||t>160)}a.isCorner=y,a.isExtreme=m,a.isHorizontal=M,a.isVertical=b,a.isDirChange=C}let u=[],h=[];for(let t=0;t<e.length;t++){let l=e[t],a=e[t+1]||null,n=e[t+2]||null,r=[];if(a&&a.isExtreme&&l.isExtreme&&!l.isCorner){let e=a.dist<2*p&&!a.isCorner,s=n&&n.isExtreme&&n.dist<2*p&&!n.isCorner;if(e&&!s?r.push(l,a):s&&r.push(l,a,n),r.length){let e=r.reduce((e,t)=>e+t.x,0)/r.length,a=r.reduce((e,t)=>e+t.y,0)/r.length;l.x=e,l.y=a,t+=r.length-1}}(l.isExtreme||l.isCorner||l.isDirChange)&&h.push(u.length),u.push(l)}let o=u.length,y=u[0],c=u[o-1],x=ie(y,c)<2*p;return y.isExtreme&&c.isExtreme&&x&&(c.x=y.x,c.y=y.y),u}(e,{debug:!1}):e,c=s||r?function(e,{closed:t=!0,keepCorners:l=!0,keepExtremes:a=!0,keepInflections:n=!1}={}){let r=[],s=[e[0]],i=e.length;for(let t=1;t<i;t++){t>0?e[t-1]:e[i-1];let n=e[t],p=t<i-1?e[t+1]:e[i-1];s.push(n),t>0&&(a&&p.isExtreme||l&&p.isCorner)&&(r.push(s),s=[])}return!r.length&&e.length>1&&(r=[e]),r}(y,{keepCorners:r,keepExtremes:s,keepInflections:i}):[y],x=l&&a?(l+a)/2*.004*o:2.5;x=2;let f=function(e=[],{closed:t=!0,tolerance:l=1}={}){let a=e.length,n=[{type:"M",values:[e[0][0].x,e[0][0].y]}];for(let t=0;t<a;t++){let a=e[t],r=e[t+1]?e[t+1]:null,s=[],i=a.length;a[a.length-1],r&&a.push(r[0]),i<2||2===i&&a[1].isExtreme?(a[a.length-1],s=a.map(e=>({type:"L",values:[e.x,e.y]}))):s=Ke(a,l),n.push(...s)}t&&n.push({type:"Z",values:[]});return function(e){let t=e.length;for(let l=1;l<t;l++){let t=e[l],a=e[l+1]||null,{type:n,values:r}=t;if("C"===n&&a&&"C"===a.type){let n=a.values;r[0],r[1];let s={x:r[2],y:r[3]},i={x:r[4],y:r[5]},p={x:n[0],y:n[1]};n[2],n[3];let u,h,o=Math.abs(s.x-i.x),y=Math.abs(s.y-i.y),c=Math.abs(p.x-i.x),x=Math.abs(p.y-i.y),f=.02*ie(p,s),g=y<f&&o>f,d=x<f&&c>f,v=o<f&&y>f,m=c<f&&x>f;(g||v)&&(u=g?{x:t.values[2],y:i.y}:v?{x:i.x,y:t.values[3]}:{x:t.values[2],y:t.values[3]},t.values[2]=u.x,t.values[3]=u.y),(d||m)&&(h=d?{x:a.values[0],y:i.y}:m?{x:i.x,y:a.values[1]}:{x:a.values[0],y:a.values[1]},e[l+1].values[0]=h.x,e[l+1].values[1]=h.y)}}}(n),n}(c,{closed:h,tolerance:2});return f}function ot(e,{threshold:t=null,tolerance:l=1}={}){if(!t){let l=function(e){let t=1/0,l=-1/0,a=1/0,n=-1/0;const r=e=>{e.x<t&&(t=e.x),e.x>l&&(l=e.x),e.y<a&&(a=e.y),e.y>n&&(n=e.y)};for(let t=0;t<e.length;t++){let l=e[t],{type:a,values:n}=l,s=n.length,i=(e[t-1]?e[t-1]:e[t]).values,p=i.length;if(s){let e={x:i[p-2],y:i[p-1]},t={x:n[s-2],y:n[s-1]};if(r(t),"C"===a||"Q"===a){let l={x:n[0],y:n[1]},s="C"===a?{x:n[2],y:n[3]}:l,i="C"===a?[e,l,s,t]:[e,l,t];_(i).forEach(e=>{let t=V(i,e);r(t)})}else"A"===a&&ee(e,n).forEach(e=>{r(e)})}}return{x:t,y:a,width:l-t,height:n-a}}(e);t=.05*(l.width+l.height)}let a=e.length;for(let n=0;n<a;n++){let a=e[n],{type:r,values:s,extreme:i,corner:p=!1,dimA:u,p0:h,p:o}=a,y=e[n+1]?e[n+1]:null,c=e[n+2]?e[n+2]:null,x=(y?ie(o,y.p):1/0)<t,f=(c?ie(c.p,y.p):1/0)<1*t;if(y&&c&&"C"===r&&"C"===y.type&&i&&c.extreme&&(f||x)){let a=Me(y,c,t,l,!1);if(1===a.length){a=a[0],e[n+1]=null,e[n+2].values=[a.cp1.x,a.cp1.y,a.cp2.x,a.cp2.y,a.p.x,a.p.y],e[n+2].cp1=a.cp1,e[n+2].cp2=a.cp2,e[n+2].p0=a.p0,e[n+2].p=a.p,e[n+2].extreme=a.extreme,n++;continue}}if(y&&"C"===r&&"C"===y.type&&i&&x){let e=ve([a.p0,a.p,y.p]),t=ve([a.p0,a.cp1,a.cp2,a.p]);if(e<0&&t>0||e>0&&t<0)continue}}a=(e=e.filter(Boolean)).length;let n="z"===e[a-1].type.toLowerCase()?a-2:a-1,r=e[n],s=e[n-1]||null,i={x:e[0].values[0],y:e[0].values[1]},p=r.values.slice(-2),u=+p[0].toFixed(8)===+i.x.toFixed(8)&&+p[1].toFixed(8)===+i.y.toFixed(8),h="C"===e[1].type&&e[1].extreme?e[1]:null,o=ie(r.p0,r.p)<t;if(s&&"C"===s.type&&o&&u&&h){let a=Me(s,r,t,l,!1);1===a.length&&(e[n-1]=a[0],e[n]=null,e=e.filter(Boolean))}return e}function yt(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}function ct(e,{threshold:t=0,tolerance:l=1}={}){let a=e.length,n=[e[0]],r="z"===e[a-1].type.toLowerCase(),s=!!r&&(e[a-1].p.x===e[0].p0.x&&e[a-1].p.y===e[0].p0.y),i=r?2:1,p=e[a-i],u="L"===p.type,h="C"===p.type,o="L"===e[1].type,y="C"===e[1].type,c=r&&y&&(u||s);c&&(e[a-1].values=e[0].values,e[a-1].type="L",u=!0);for(let t=1;t<a;t++){let s=e[t],{type:p}=s,x=e[t+1]?e[t+1]:null;if("L"===p&&x&&"C"===x.type||"C"===p&&x&&"L"===x.type){let c="L"===p?s:null,f=null,g=[],d=0;if(1===t&&y&&u&&(g=[e[1]],c=e[a-1],f=x),!c){n.push(s);continue}r&&h&&o&&t===a-i-1&&(f=e[1],g=[e[a-i]]);for(let l=t+1;l<a;l++){let t=e[l]?e[l]:null,a=e[l-1];if("C"===a.type&&g.push(a),"L"===t.type&&"C"===a.type){f=t;break}d++}if(f){let e=ie(c.p0,c.p),a=ie(f.p0,f.p);g.length;let r=ie(c.p,f.p0),i=ve([c.p0,c.p,f.p0,f.p],!1),p=ve([g[0].p0,g[0].cp1,g[0].cp2,g[0].p],!1),u=i<0&&p>0||i>0&&p<0,h=.5*r*l,o=h<e&&h<a;if(g.length&&!u&&o){let e=Math.abs(p)<=.005*se(g[0].p0,g[0].p),l=e?null:H(c.p0,c.p,f.p0,f.p,!1);if(!e&&l){let e=.75*ie(V([c.p,l,f.p0],.5),1===g.length?V([g[0].p0,g[0].cp1,g[0].cp2,g[0].p],.5):g[0].p);if(h&&e>h&&e>.3*r){n.push(s);continue}{let e={type:"Q",values:[l.x,l.y,f.p0.x,f.p0.y]};e.p0=c.p,e.cp1=l,e.p=f.p0,n.push(c,e),t+=d;continue}}}}}c&&t===a-1&&"L"===p||n.push(s)}return(c||r&&"Z"!==n[n.length-1].type)&&n.push({type:"Z",values:[]}),n}function xt(e){if(e.length<3)return!1;let t=e[0],l=e[Math.floor(e.length/2)],a=e[e.length-1],n=t.x,r=t.y,s=l.x,i=l.y,p=a.x,u=a.y,h=n-s,o=r-i,y=n-p,c=r-u,x=(n*n-s*s+(r*r-i*i))/2,f=(n*n-p*p+(r*r-u*u))/2,g=h*c-o*y;if(Math.abs(g)<1e-10)return console.warn("Points are collinear or numerically unstable"),!1;let d={x:(c*x-o*f)/g,y:(-y*x+h*f)/g},v=re(d,t),m=O(d,t,a),{deltaAngle:M,startAngle:b,endAngle:A}=m;return{centroid:d,r:v,startAngle:b,endAngle:A,deltaAngle:M}}function ft(e,{threshold:t=0,tolerance:a=1,toCubic:n=!1,debug:r=!1}={}){let s=e.length,i=[e[0]],p=[];for(let t=1;t<s;t++){let a=e[t],{type:s}=a,u=e[t-1],h=e[t+1]?e[t+1]:null,o=e[t+2]?e[t+2]:null,y=e[t+3]?e[t+3]:null,c=null;"C"===a.type||"Q"===a.type?c=a:!h||"C"!==h.type&&"Q"!==h.type||(c=h);let x,f,g,d,v,m=c?"C"===c.type?[c.p0,c.cp1,c.cp2,c.p]:[c.p0,c.cp1,c.p]:[],M=0,b=0,A=!1,C=!1,w=[];if("L"===u.type&&"L"===s&&c&&"L"===o.type&&y&&("L"===y.type||"Z"===y.type)?(x=[a.p0,a.p],f=[o.p0,o.p],g=a.p0,d=o.p,M=ve(m,!1),b=ve([...x,...f],!1),A=M<0&&b>0||M>0&&b<0,A||(v=V(m,.5),w=[g,v,d],C=!0)):"C"!==s&&"Q"!==s||"L"!==u.type||"C"!==h.type&&"Q"!==h.type||"L"!==o.type||(C=!0,x=[u.p0,u.p],f=[o.p0,o.p],g=u.p,d=o.p0,v=c.p,w=[g,c.p,d]),C){let e=xt(w);if(e){let s,{centroid:u,r:h,deltaAngle:o,startAngle:y,endAngle:c}=e,x=0,f=o>0?1:0,m=Math.abs(o)>Math.PI?1:0;if(pe(X(g,u.x,u.y,.5*o),v)<.05*pe(g,d)){if(s=Te({p0:g,p:d,centroid:u,rx:h,ry:h,xAxisRotation:x,sweep:f,largeArc:m,deltaAngle:o,startAngle:y,endAngle:c}),1===s.length){let e=Pe(g,s[0].cp1,s[0].cp2,d);"Q"===e.type&&(n=!0),a=e}if(s.length>1&&(n=!1),n||(a.type="A",a.values=[h,h,x,m,f,d.x,d.y]),a.p0=g,a.p=d,a.extreme=!1,a.corner=!1,r){p=n?[{type:"M",values:[g.x,g.y]},...s]:[{type:"M",values:[g.x,g.y]},{type:"A",values:[h,h,x,m,f,d.x,d.y]}];let e=me(p);l(markers,e,"orange","0.5%","0.5")}i.push(a),t++;continue}}}i.push(a)}return i}function gt(e=[],{threshold:t=0}={}){let l=e.length,a="z"===e[l-1].type.toLowerCase(),n=a?l-2:l-1,r=e[n],s=r.values.slice(-2),i={x:e[0].values[0],y:e[0].values[1]},p=pe(i,{x:s[0],y:s[1]});if(p&&p<t){let l=e[n].values.length;e[n].values[l-2]=i.x,e[n].values[l-1]=i.y;let a=e[1];if("C"===a.type&&"C"===r.type){let l=Math.abs(a.values[0]-r.values[2]),s=Math.abs(a.values[1]-r.values[3]),p=Math.abs(e[1].values[0]-a.values[0]),u=Math.abs(e[1].values[1]-a.values[1]),h=Math.abs(e[1].values[0]-r.values[2]),o=Math.abs(e[1].values[1]-r.values[3]),y=u<t&&o<t&&l;l&&l<t&&(p<t&&h<t&&s)&&(e[1].values[0]=i.x,e[n].values[2]=i.x),s&&s<t&&y&&(e[1].values[1]=i.y,e[n].values[3]=i.y)}}return e}function dt(e,t=1){let l=[];for(let a=0,n=e.length;a<n;a++){let n=e[a],{type:r,values:s}=n,i={type:r,values:[]};switch(r.toLowerCase()){case"h":case"v":i.values=[s[0]*t];break;case"a":i.values=[s[0]*t,s[1]*t,s[2],s[3],s[4],s[5]*t,s[6]*t];break;default:s.length&&(i.values=s.map((e,l)=>e*t))}l.push(i)}return l}function vt(e,{tolerance:t=1}={}){let a=[],n=[],r=e.length;for(let t=1;t<r;t++){let l=e[t],{type:r,values:s,p0:i,cp1:p=null,cp2:u=null,p:h,extreme:o=null,semiExtreme:y=null,corner:c=null,directionChange:x}=l,f=e[t+1]||null;o||c||f&&f.type!==r?(n.push(l),a.push(n),n=[]):n.push(l)}console.log("!!!chunks",a),function(e){console.log("chunks",e);let t="green";for(let a=0;a<e.length;a++){let n=e[a],r=n.length;t=a%2==0?"orange":"green";let s=n[0],i=n[r-1],p=[{type:"M",values:[s.p0.x,s.p0.y]}];for(let e=0,t=r;e<t;e++){let l=n[e];n[e+1],n[t-1],"C"===s.type&&i.type;let{type:a,values:r,p0:u,cp1:h=null,cp2:o=null,p:y=null,extreme:c,semiExtreme:x=null,corner:f=null}=l;p.push({type:a,values:r})}let u=me(p);l(markers,u,t,"1%","0.5")}}(a);let s=a.length;for(let e=0;e<s;e++){let t=a[e],l=a[e+1]||null;1===t.length&&l&&l[0].type}a=a.filter(Boolean);let i=[e[0]];for(let e=0;e<a.length;e++){let t=a[e],l=t.length,n=t[0],r=t[l-1],s=.05*ie(n.p0,r.p);for(let e=0,a=l;e<a;e++){let p=t[e];t[e+1],t[a-1];let u="C"===n.type&&"C"===r.type,{type:h,values:o,p0:y,cp1:c=null,cp2:x=null,p:f=null,extreme:g,semiExtreme:d=null,corner:v=null}=p,m=null,M=null,b=null,A=null,C=null,w=null,E=[],L=.666,k=null;if(u){let e=Math.abs(n.p0.x-n.cp1.x),t=Math.abs(n.p0.y-n.cp1.y),l=Math.abs(r.p.x-r.cp2.x),a=Math.abs(r.p.y-r.cp2.y),i=e<s&&e<t,p=l<s&&l<a,u=a<s&&l>a;t<s&&e>t&&(n.cp1.y=n.p0.y),u&&(r.cp2.y=r.p.y),i&&(n.cp1.x=n.p0.x),p&&(r.cp2.x=r.p.x)}if(me([{type:"M",values:[p.p0.x,p.p0.y]},{type:h,values:o}]),1===l||"C"!==h)i.push(p);else{let e=t.filter(e=>e.semiExtreme),l=t.filter(e=>e.directionChange);if(e.length||l.length){if(k=e.length?e[0]:l[0],n.p0.x===n.cp1.x&&n.p0.y===n.cp1.y?n.cp1=V([n.p0,n.cp1,n.cp2,n.p],.5):r.p.x===r.cp2.x&&r.p.y===r.cp2.y&&(r.cp2=V([r.p0,r.cp1,r.cp2,r.p],.5)),m=H(k.p,k.cp2,n.p0,n.cp1,!1),M=H(k.p,k.cp2,r.p,r.cp2,!1),m&&M){b=V([n.p0,m],L),A=V([r.p,M],L),C=V([k.p,m],L),w=V([k.p,M],L),E=[{type:"M",values:[n.p0.x,n.p0.y]},{type:"C",values:[b.x,b.y,C.x,C.y,k.p.x,k.p.y]},{type:"C",values:[w.x,w.y,A.x,A.y,r.p.x,r.p.y]}],me(E),i.push({type:"C",values:[b.x,b.y,C.x,C.y,k.p.x,k.p.y],p0:n.p0,cp1:b,cp2:C,p:k.p,dimA:ie(n.p0,k.p)},{type:"C",values:[w.x,w.y,A.x,A.y,r.p.x,r.p.y],p0:k.p,cp1:w,cp2:A,p:r.p,extreme:!0,dimA:ie(k.p,r.p)});break}}else i.push(p)}}}return i}function mt(e){for(let t=1,l=e.length;t<l;t++){let l=e[t],{type:a,values:n,p0:r,cp1:s=null,cp2:i=null,p:p=null}=l;if("C"===a){let a=Pe(r,s,i,p);"Q"===a.type&&(a.extreme=l.extreme,a.corner=l.corner,a.dimA=l.dimA,a.squareDist=l.squareDist,e[t]=a)}}return e}function Mt(e,{areaThreshold:t=2.5}={}){for(let l=0,a=e.length;l<a;l++){let a=e[l],n=e[l+1]||null,{type:r,values:s,p0:i,cp1:p=null,cp2:u=null,p:h=null}=a;if("C"===r&&n&&"C"===n.type){let a=bt(i,p,u,h,t),r=bt(n.p0,n.cp1,n.cp2,n.p,t);if(a.isArc&&r.isArc){let t=.01*ie(i,n.p),s=Math.abs(n.p.x-i.x),p=Math.abs(n.p.y-i.y),u=p<t&&s>t,o=s<t&&p>t,{rx:y,ry:c}=a,x=ve([i,h,n.p])<0?0:1;if(o||u){y=Math.min(y,r.rx),c=Math.min(c,r.ry),e[l]=null,e[l+1].type="A",e[l+1].values=[y,c,0,0,x,n.p.x,n.p.y];continue}}}}return e=e.filter(Boolean)}function bt(e,t,l,a,n=7.5){let r,s={type:"C",values:[t.x,t.y,l.x,l.y,a.x,a.y]},i=0,p=!1,u=R(e,t,!0),h=R(a,l,!0),o=180*Math.abs(u-h)/Math.PI,y=0,c=0;if(Math.abs(o%180-90)<3){r=H(e,X(t,e.x,e.y,-.5*Math.PI),a,X(l,a.x,a.y,.5*Math.PI),!1);let u=H(e,t,a,l,!1);if(u){let r=re(e,u),h=re(a,u),o=+Math.max(r,h).toFixed(8),x=+Math.min(r,h).toFixed(8);y=x,c=o;let f=ve([e,t,l,a])<0?0:1,g=Math.abs(a.x-e.x)>Math.abs(a.y-e.y);100/y*Math.abs(y-c)<5&&(y=o,c=y),g&&(y=o,c=x);let d=de([{type:"M",values:[e.x,e.y]},{type:"C",values:[t.x,t.y,l.x,l.y,a.x,a.y]}]),v={type:"A",values:[y,c,0,0,f,a.x,a.y]};i=Math.PI*(y*c)/4,i-=Math.abs(ve([e,a,u])),function(e,t){let l=Math.abs(e-t);return Math.abs(100-100/e*(e+l))}(d,i)<n&&(p=!0,s=v)}}return{com:s,isArc:p,area:i,rx:y,ry:c,centroid:r}}function At(e,{angles:t=[],split:l=0,getPathData:a=!0,width:n=0,height:r=0}={}){let s=e.length,i={x:e[0].values[0],y:e[0].values[1]},p=i,u=[],h=[p],o=0;if(l=l||1,n&&r)o=.025*(n+r)/l;else{o=e.map(e=>e.dimA||0).filter(Boolean).sort()[0]}for(let t=1;t<s;t++){let a=e[t],n=e[t+1]||null,{type:r,values:s}=a,u=s.length,y=u?{x:s[u-2],y:s[u-1]}:i;if("C"===r||"Q"===r){let e={x:s[0],y:s[1]},t="C"===r?{x:s[2],y:s[3]}:e,n="C"===r?[p,e,t,y]:[p,e,y],i=a.dimA;l=Math.ceil(i/o);let u=[];for(let e=1;e<l;e++)u.push(1/l*e);u.forEach(e=>{let t=V(n,e);h.push(t)})}"M"===r&&(i=y),y.area=a.cptArea||0,y.isExtreme=a.extreme||!1,y.isCorner=a.corner||!1,y.isDirChange=a.directionChange||!1,h.push(y),a.extreme||a.corner||n&&n.type,p=y}return h=function(e,{quality:t=.9,width:l=0,height:a=0,absolute:n=!1,manhattan:r=!1,exclude:s=[]}={}){"string"==typeof t&&(n=!0,t=parseFloat(t));if(e.length<4||(!n&&t)>=1)return e;let i=t;if(!n){if(i=1-t,!l&&!a){let t=ue(e,12);({width:l,height:a}=xe(t))}i=r?.05*(l+a)*(1-t):(i*((l+a)/2/25))**2}let p,u=e[0],h=[u],o=e.length,y=s.length,c=0;for(let t=1;t<o;t++)p=e[t],c=r?ie(u,p):se(u,p),!(c<i)||y&&s.includes(t)?(h.push(p),u=p):u=p;return u.x!==p.x&&u.y!==p.y&&h.push(p),h}(h,{quality:.5,width:n,height:r}),u=function(e,t=!0){let l=[{type:"M",values:[e[0].x,e[0].y]},...e.slice(1).map(e=>({type:"L",values:[e.x,e.y]}))];return t&&l.push({type:"Z",values:[]}),l}(h),a?u:h}function Ct(e="",{getObject:t=!1,toAbsolute:l=!0,toRelative:a=!0,toShorthands:n=!0,quadraticToCubic:r=!0,arcToCubic:s=!1,cubicToArc:i=!1,simplifyBezier:p=!0,optimizeOrder:u=!0,autoClose:h=!0,removeZeroLength:o=!0,refineClosing:y=!0,removeColinear:c=!0,flatBezierToLinetos:x=!0,revertToQuadratics:f=!0,refineExtremes:g=!0,simplifyCorners:d=!1,keepExtremes:v=!0,keepCorners:m=!0,extrapolateDominant:M=!0,keepInflections:b=!1,addExtremes:A=!1,addSemiExtremes:C=!1,smoothPoly:w=!1,harmonizeCpts:E=!1,toPolygon:L=!1,removeOrphanSubpaths:k=!1,simplifyRound:P=!1,scale:S=1,scaleTo:I=0,crop:D=!1,alignToOrigin:F=!1,decimals:q=3,autoAccuracy:$=!0,minifyD:z=0,tolerance:T=1,reverse:Q=!1,mergePaths:B=!1,removeHidden:j=!0,removeUnused:N=!0,shapesToPaths:Z=!0,tMin:R=0,tMax:O=1,redraw:H=!1}={}){T=Math.max(.1,T),S=Math.max(.001,S);let U=function(e){let t="string";if(Array.isArray(e))return e[0]?.type&&e[0]?.values?"pathData":"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),V="",J=0,X=0,Y=0,G={},K="",_="svgMarkup"===U?1:0,ee=[];J=e.length;let te={x:0,y:0,width:0,height:0},le={x:0,y:0,width:0,height:0},ae=[],ne=[];if(_){if(V=function(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","fill","stroke","stroke-width","stroke-linecap","stroke-linejoin"]);let r=["metadata","script"];return n.querySelectorAll("*").forEach(e=>{let t=e.nodeName,a=e.getAttribute("style")||"",n=!!a&&a.trim().includes("display:none"),s=e.getAttribute("display")&&"none"===e.getAttribute("display")||n;t.includes(":")||r.includes(t)||l&&s?e.remove():function(e){[...e.attributes].map(e=>e.name).forEach(t=>{t.includes(":")&&e.removeAttribute(t)})}(e)}),t?n:yt(n)}(e,{returnDom:!0,removeHidden:j,removeUnused:N}),Z){V.querySelectorAll("polygon, polyline, line, rect, circle, ellipse").forEach(e=>{let t=He(e);e.replaceWith(t)})}V.querySelectorAll("path").forEach(e=>{ee.push({d:e.getAttribute("d"),el:e})}),te=function(e=null,t=-1){const l=e=>e&&isNaN(e)?e.match(/[^\d|.]+/g)[0]:"";if(!e)return!1;let a=e.hasAttribute("width"),n=e.hasAttribute("height"),r=e.hasAttribute("viewBox"),s=a?e.getAttribute("width"):0,i=n?e.getAttribute("height"):0,p=!!a&&l(s),u=!!n&&l(s),h=s?s.includes("%")?0:parseFloat(s):300,o=i?i.includes("%")?0:parseFloat(i):150,y=r?e.getAttribute("viewBox").split(/,| /).filter(Boolean).map(Number):[0,0,h,o];return t>-1&&([h,o]=[h,o].map(e=>+e.toFixed(t)),y=y.map(e=>+e.toFixed(t))),{x:y[0],y:y[1],width:y[2],height:y[3],w:h,h:o,hasViewBox:r,hasWidth:a,hasHeight:n,widthUnit:p,heightUnit:u}}(V,q)}else{if("pathDataString"===U)K=e;else if("polyString"===U)K="M"+e;else if("pathData"===U){K=e,J=K.map(e=>`${e.type} ${e.values.join(" ")}`).join(" ").length}ee.push({d:K,el:null})}let re={toRelative:a,toShorthands:n,decimals:q},se=[];for(let e=0,t=ee.length;t&&e<t;e++){let t=ee[e],{d:a,el:n}=t,j=Be(a,{quadraticToCubic:r,toAbsolute:l,arcToCubic:s}),N=w||L?xe(W(j)):null;if(1!==S||I){if(I)if(te.width&&!D)S=I/te.width;else{let e=j.map(e=>({type:e.type,values:e.values}));e=Se(e,{arcToCubic:!0}),e=ce(e);let t=xe(W(e));ae.push(t.x,t.x+t.width),ne.push(t.y,t.y+t.height);let l=I/t.width;S=l}j=dt(j,S)}let Z=j.length;k&&(j=Ve(j));let U=he(j),V=U.length,G=[];for(let e=0;e<V;e++){let t=U[e];if(L){p=!1,w=!1,E=!1,t=Ue(t);let e=ke(t),{bb:l,pathData:a}=e;t=a,t=At(t,{angles:[],split:1,width:N.width,height:N.height,getPathData:!0})}if(w){let e=Array.from(new Set(t.map(e=>e.type))).join(""),l=!/[acqts]/gi.test(e),a=/[z]/gi.test(e);if(l){t=We(t),t=ht(W(t),{denoise:.8,tolerance:T,width:N.width,height:N.height,manhattan:!1,absolute:!1,keepCorners:m,keepExtremes:v,keepInflections:b,closed:a})}}E&&(t=Ge(t)),(c||o)&&(t=We(t)),H&&(A=!0,C=!0,d=!1,m=!0,v=!0,u=!0,R=0,O=0),u&&(t=Je(t)),c&&(t=Ue(t,{tolerance:T,flatBezierToLinetos:!1})),(A||C)&&(t=ce(t,{tMin:R,tMax:O,addExtremes:A,addSemiExtremes:C,angles:[30]}));let l=ke(t,{detectSemiExtremes:C}),{pathData:a,bb:n,dimA:r}=l;if(ae.push(n.x,n.x+n.width),ne.push(n.y,n.y+n.height),y&&(a=gt(a,{threshold:.001*r})),a=p?be(a,{simplifyBezier:p,keepInflections:b,keepExtremes:v,keepCorners:m,extrapolateDominant:M,revertToQuadratics:f,tolerance:T,reverse:Q}):a,g){a=ot(a,{threshold:.05*(n.width+n.height),tolerance:T})}if(H&&(n.width,n.height,a=vt(a,{tolerance:T,threshold:.001*r})),i&&(a=Mt(a,{areaThreshold:2.5})),c&&x&&(a=Ue(a,{tolerance:T,flatBezierToLinetos:x})),d){a=ct(a,{threshold:.1*(n.width+n.height),tolerance:T})}P&&(a=ft(a)),f&&(a=mt(a)),u&&(a=Xe(a,{autoClose:h})),G.push({pathData:a,bb:n})}let K=Math.min(...ae),_=Math.min(...ne);le={x:K,y:_,width:Math.max(...ae)-K,height:Math.max(...ne)-_};let ie=le.height>le.width;if(u&&(G=ie?G.sort((e,t)=>e.bb.y-t.bb.y||e.bb.x-t.bb.x):G.sort((e,t)=>e.bb.x-t.bb.x||e.bb.y-t.bb.y)),j=[],G.forEach(e=>{j.push(...e.pathData)}),$&&(q=we(j),re.decimals=q),n&&B)se.push(...j);else{j=Se(j,re),j=We(j),F&&(console.log(le),j[0].values[0]=(j[0].values[0]-le.x).toFixed(q),j[0].values[1]=(j[0].values[1]-le.y).toFixed(q),le.x=0,le.y=0);let e=j.length,l=me(j,z);X=l.length,Y=+(100/J*X).toFixed(2),t.d=l,t.report={original:Z,new:e,saved:Z-e,compression:Y,decimals:q},n&&n.setAttribute("d",l)}}if(_){if(se.length){let e=Se(se,re);e=We(e);let t=me(e,z);ee[0].el.setAttribute("d",t);for(let e=1;e<ee.length;e++){let t=ee[e].el;t&&t.remove()}!function(e){e.querySelectorAll("g, defs").forEach(e=>{e.children.length||e.remove()})}(V)}if(S){let{x:e,y:t,width:l,height:a,w:n,h:r,hasViewBox:s,hasWidth:i,hasHeight:p,widthUnit:u,heightUnit:h}=te;D&&(e=le.x,t=le.y,l=le.width,a=le.height,n=l,r=a),s&&V.setAttribute("viewBox",[e,t,l,a].map(e=>+(e*S).toFixed(q)).join(" ")),i&&V.setAttribute("width",+(n*S).toFixed(q)+u),p&&V.setAttribute("height",+(r*S).toFixed(q)+h)}V=yt(V),X=V.length,Y=+(100/J*X).toFixed(2),J=+(J/1024).toFixed(3),X=+(X/1024).toFixed(3),G={svgSize:J,svgSizeOpt:X,compression:Y,decimals:q}}else({d:K,report:G}=ee[0]);return t?{svg:V,d:K,report:G,inputType:U,mode:_}:K||V}"undefined"!=typeof window&&(window.svgPathSimplify=Ct),e.PI=A,e.abs=a,e.acos=n,e.asin=r,e.atan=s,e.atan2=i,e.ceil=p,e.cos=u,e.exp=h,e.floor=o,e.hypot=c,e.log=y,e.max=x,e.min=f,e.pow=g,e.random=d,e.round=v,e.sin=m,e.sqrt=M,e.svgPathSimplify=Ct,e.tan=b}(this["svg-path-simplify"]=this["svg-path-simplify"]||{});
11
+ (M||b)&&(m=!0);let A=l.area<0&&a.area>0||l.area>0&&a.area<0,C=A&&!c;if(y=C,v&&!l.isDirChange&&(m=!0),b&&l.isHorizontal&&(l.isCorner=!0,l.isExtreme=!1,m=!1),C&&(l.isDirChange||l.isExtreme)&&(C=!1,a.isDirChange=!1),l.isExtreme&&h>o&&!C&&a.isHorizontal,m||A||h>u){let e=O(a,n,l),{deltaAngleDeg:t}=e;t=Math.abs(t),y=!(t<3||t>160)}a.isCorner=y,a.isExtreme=m,a.isHorizontal=M,a.isVertical=b,a.isDirChange=C}let u=[],h=[];for(let t=0;t<e.length;t++){let l=e[t],a=e[t+1]||null,n=e[t+2]||null,r=[];if(a&&a.isExtreme&&l.isExtreme&&!l.isCorner){let e=a.dist<2*p&&!a.isCorner,s=n&&n.isExtreme&&n.dist<2*p&&!n.isCorner;if(e&&!s?r.push(l,a):s&&r.push(l,a,n),r.length){let e=r.reduce((e,t)=>e+t.x,0)/r.length,a=r.reduce((e,t)=>e+t.y,0)/r.length;l.x=e,l.y=a,t+=r.length-1}}(l.isExtreme||l.isCorner||l.isDirChange)&&h.push(u.length),u.push(l)}let o=u.length,y=u[0],c=u[o-1],x=ie(y,c)<2*p;return y.isExtreme&&c.isExtreme&&x&&(c.x=y.x,c.y=y.y),u}(e,{debug:!1}):e,c=s||r?function(e,{closed:t=!0,keepCorners:l=!0,keepExtremes:a=!0,keepInflections:n=!1}={}){let r=[],s=[e[0]],i=e.length;for(let t=1;t<i;t++){t>0?e[t-1]:e[i-1];let n=e[t],p=t<i-1?e[t+1]:e[i-1];s.push(n),t>0&&(a&&p.isExtreme||l&&p.isCorner)&&(r.push(s),s=[])}return!r.length&&e.length>1&&(r=[e]),r}(y,{keepCorners:r,keepExtremes:s,keepInflections:i}):[y],x=l&&a?(l+a)/2*.004*o:2.5;x=2;let f=function(e=[],{closed:t=!0,tolerance:l=1}={}){let a=e.length,n=[{type:"M",values:[e[0][0].x,e[0][0].y]}];for(let t=0;t<a;t++){let a=e[t],r=e[t+1]?e[t+1]:null,s=[],i=a.length;a[a.length-1],r&&a.push(r[0]),i<2||2===i&&a[1].isExtreme?(a[a.length-1],s=a.map(e=>({type:"L",values:[e.x,e.y]}))):s=Ke(a,l),n.push(...s)}t&&n.push({type:"Z",values:[]});return function(e){let t=e.length;for(let l=1;l<t;l++){let t=e[l],a=e[l+1]||null,{type:n,values:r}=t;if("C"===n&&a&&"C"===a.type){let n=a.values;r[0],r[1];let s={x:r[2],y:r[3]},i={x:r[4],y:r[5]},p={x:n[0],y:n[1]};n[2],n[3];let u,h,o=Math.abs(s.x-i.x),y=Math.abs(s.y-i.y),c=Math.abs(p.x-i.x),x=Math.abs(p.y-i.y),f=.02*ie(p,s),g=y<f&&o>f,d=x<f&&c>f,v=o<f&&y>f,m=c<f&&x>f;(g||v)&&(u=g?{x:t.values[2],y:i.y}:v?{x:i.x,y:t.values[3]}:{x:t.values[2],y:t.values[3]},t.values[2]=u.x,t.values[3]=u.y),(d||m)&&(h=d?{x:a.values[0],y:i.y}:m?{x:i.x,y:a.values[1]}:{x:a.values[0],y:a.values[1]},e[l+1].values[0]=h.x,e[l+1].values[1]=h.y)}}}(n),n}(c,{closed:h,tolerance:2});return f}function ot(e,{threshold:t=null,tolerance:l=1}={}){if(!t){let l=function(e){let t=1/0,l=-1/0,a=1/0,n=-1/0;const r=e=>{e.x<t&&(t=e.x),e.x>l&&(l=e.x),e.y<a&&(a=e.y),e.y>n&&(n=e.y)};for(let t=0;t<e.length;t++){let l=e[t],{type:a,values:n}=l,s=n.length,i=(e[t-1]?e[t-1]:e[t]).values,p=i.length;if(s){let e={x:i[p-2],y:i[p-1]},t={x:n[s-2],y:n[s-1]};if(r(t),"C"===a||"Q"===a){let l={x:n[0],y:n[1]},s="C"===a?{x:n[2],y:n[3]}:l,i="C"===a?[e,l,s,t]:[e,l,t];_(i).forEach(e=>{let t=V(i,e);r(t)})}else"A"===a&&ee(e,n).forEach(e=>{r(e)})}}return{x:t,y:a,width:l-t,height:n-a}}(e);t=.05*(l.width+l.height)}let a=e.length;for(let n=0;n<a;n++){let a=e[n],{type:r,values:s,extreme:i,corner:p=!1,dimA:u,p0:h,p:o}=a,y=e[n+1]?e[n+1]:null,c=e[n+2]?e[n+2]:null,x=(y?ie(o,y.p):1/0)<t,f=(c?ie(c.p,y.p):1/0)<1*t;if(y&&c&&"C"===r&&"C"===y.type&&i&&c.extreme&&(f||x)){let a=Me(y,c,t,l,!1);if(1===a.length){a=a[0],e[n+1]=null,e[n+2].values=[a.cp1.x,a.cp1.y,a.cp2.x,a.cp2.y,a.p.x,a.p.y],e[n+2].cp1=a.cp1,e[n+2].cp2=a.cp2,e[n+2].p0=a.p0,e[n+2].p=a.p,e[n+2].extreme=a.extreme,n++;continue}}if(y&&"C"===r&&"C"===y.type&&i&&x){let e=ve([a.p0,a.p,y.p]),t=ve([a.p0,a.cp1,a.cp2,a.p]);if(e<0&&t>0||e>0&&t<0)continue}}a=(e=e.filter(Boolean)).length;let n="z"===e[a-1].type.toLowerCase()?a-2:a-1,r=e[n],s=e[n-1]||null,i={x:e[0].values[0],y:e[0].values[1]},p=r.values.slice(-2),u=+p[0].toFixed(8)===+i.x.toFixed(8)&&+p[1].toFixed(8)===+i.y.toFixed(8),h="C"===e[1].type&&e[1].extreme?e[1]:null,o=ie(r.p0,r.p)<t;if(s&&"C"===s.type&&o&&u&&h){let a=Me(s,r,t,l,!1);1===a.length&&(e[n-1]=a[0],e[n]=null,e=e.filter(Boolean))}return e}function yt(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}function ct(e,{threshold:t=0,tolerance:l=1}={}){let a=e.length,n=[e[0]],r="z"===e[a-1].type.toLowerCase(),s=!!r&&(e[a-1].p.x===e[0].p0.x&&e[a-1].p.y===e[0].p0.y),i=r?2:1,p=e[a-i],u="L"===p.type,h="C"===p.type,o="L"===e[1].type,y="C"===e[1].type,c=r&&y&&(u||s);c&&(e[a-1].values=e[0].values,e[a-1].type="L",u=!0);for(let t=1;t<a;t++){let s=e[t],{type:p}=s,x=e[t+1]?e[t+1]:null;if("L"===p&&x&&"C"===x.type||"C"===p&&x&&"L"===x.type){let c="L"===p?s:null,f=null,g=[],d=0;if(1===t&&y&&u&&(g=[e[1]],c=e[a-1],f=x),!c){n.push(s);continue}r&&h&&o&&t===a-i-1&&(f=e[1],g=[e[a-i]]);for(let l=t+1;l<a;l++){let t=e[l]?e[l]:null,a=e[l-1];if("C"===a.type&&g.push(a),"L"===t.type&&"C"===a.type){f=t;break}d++}if(f){let e=ie(c.p0,c.p),a=ie(f.p0,f.p);g.length;let r=ie(c.p,f.p0),i=ve([c.p0,c.p,f.p0,f.p],!1),p=ve([g[0].p0,g[0].cp1,g[0].cp2,g[0].p],!1),u=i<0&&p>0||i>0&&p<0,h=.5*r*l,o=h<e&&h<a;if(g.length&&!u&&o){let e=Math.abs(p)<=.005*se(g[0].p0,g[0].p),l=e?null:H(c.p0,c.p,f.p0,f.p,!1);if(!e&&l){let e=.75*ie(V([c.p,l,f.p0],.5),1===g.length?V([g[0].p0,g[0].cp1,g[0].cp2,g[0].p],.5):g[0].p);if(h&&e>h&&e>.3*r){n.push(s);continue}{let e={type:"Q",values:[l.x,l.y,f.p0.x,f.p0.y]};e.p0=c.p,e.cp1=l,e.p=f.p0,n.push(c,e),t+=d;continue}}}}}c&&t===a-1&&"L"===p||n.push(s)}return(c||r&&"Z"!==n[n.length-1].type)&&n.push({type:"Z",values:[]}),n}function xt(e){if(e.length<3)return!1;let t=e[0],l=e[Math.floor(e.length/2)],a=e[e.length-1],n=t.x,r=t.y,s=l.x,i=l.y,p=a.x,u=a.y,h=n-s,o=r-i,y=n-p,c=r-u,x=(n*n-s*s+(r*r-i*i))/2,f=(n*n-p*p+(r*r-u*u))/2,g=h*c-o*y;if(Math.abs(g)<1e-10)return console.warn("Points are collinear or numerically unstable"),!1;let d={x:(c*x-o*f)/g,y:(-y*x+h*f)/g},v=re(d,t),m=O(d,t,a),{deltaAngle:M,startAngle:b,endAngle:A}=m;return{centroid:d,r:v,startAngle:b,endAngle:A,deltaAngle:M}}function ft(e,{threshold:t=0,tolerance:a=1,toCubic:n=!1,debug:r=!1}={}){let s=e.length,i=[e[0]],p=[];for(let t=1;t<s;t++){let a=e[t],{type:s}=a,u=e[t-1],h=e[t+1]?e[t+1]:null,o=e[t+2]?e[t+2]:null,y=e[t+3]?e[t+3]:null,c=null;"C"===a.type||"Q"===a.type?c=a:!h||"C"!==h.type&&"Q"!==h.type||(c=h);let x,f,g,d,v,m=c?"C"===c.type?[c.p0,c.cp1,c.cp2,c.p]:[c.p0,c.cp1,c.p]:[],M=0,b=0,A=!1,C=!1,w=[];if("L"===u.type&&"L"===s&&c&&"L"===o.type&&y&&("L"===y.type||"Z"===y.type)?(x=[a.p0,a.p],f=[o.p0,o.p],g=a.p0,d=o.p,M=ve(m,!1),b=ve([...x,...f],!1),A=M<0&&b>0||M>0&&b<0,A||(v=V(m,.5),w=[g,v,d],C=!0)):"C"!==s&&"Q"!==s||"L"!==u.type||"C"!==h.type&&"Q"!==h.type||"L"!==o.type||(C=!0,x=[u.p0,u.p],f=[o.p0,o.p],g=u.p,d=o.p0,v=c.p,w=[g,c.p,d]),C){let e=xt(w);if(e){let s,{centroid:u,r:h,deltaAngle:o,startAngle:y,endAngle:c}=e,x=0,f=o>0?1:0,m=Math.abs(o)>Math.PI?1:0;if(pe(X(g,u.x,u.y,.5*o),v)<.05*pe(g,d)){if(s=Te({p0:g,p:d,centroid:u,rx:h,ry:h,xAxisRotation:x,sweep:f,largeArc:m,deltaAngle:o,startAngle:y,endAngle:c}),1===s.length){let e=Se(g,s[0].cp1,s[0].cp2,d);"Q"===e.type&&(n=!0),a=e}if(s.length>1&&(n=!1),n||(a.type="A",a.values=[h,h,x,m,f,d.x,d.y]),a.p0=g,a.p=d,a.extreme=!1,a.corner=!1,r){p=n?[{type:"M",values:[g.x,g.y]},...s]:[{type:"M",values:[g.x,g.y]},{type:"A",values:[h,h,x,m,f,d.x,d.y]}];let e=me(p);l(markers,e,"orange","0.5%","0.5")}i.push(a),t++;continue}}}i.push(a)}return i}function gt(e=[],{threshold:t=0}={}){let l=e.length,a="z"===e[l-1].type.toLowerCase(),n=a?l-2:l-1,r=e[n],s=r.values.slice(-2),i={x:e[0].values[0],y:e[0].values[1]},p=pe(i,{x:s[0],y:s[1]});if(p&&p<t){let l=e[n].values.length;e[n].values[l-2]=i.x,e[n].values[l-1]=i.y;let a=e[1];if("C"===a.type&&"C"===r.type){let l=Math.abs(a.values[0]-r.values[2]),s=Math.abs(a.values[1]-r.values[3]),p=Math.abs(e[1].values[0]-a.values[0]),u=Math.abs(e[1].values[1]-a.values[1]),h=Math.abs(e[1].values[0]-r.values[2]),o=Math.abs(e[1].values[1]-r.values[3]),y=u<t&&o<t&&l;l&&l<t&&(p<t&&h<t&&s)&&(e[1].values[0]=i.x,e[n].values[2]=i.x),s&&s<t&&y&&(e[1].values[1]=i.y,e[n].values[3]=i.y)}}return e}function dt(e,t=1){let l=[];for(let a=0,n=e.length;a<n;a++){let n=e[a],{type:r,values:s}=n,i={type:r,values:[]};switch(r.toLowerCase()){case"h":case"v":i.values=[s[0]*t];break;case"a":i.values=[s[0]*t,s[1]*t,s[2],s[3],s[4],s[5]*t,s[6]*t];break;default:s.length&&(i.values=s.map((e,l)=>e*t))}l.push(i)}return l}function vt(e,{tolerance:t=1}={}){let a=[],n=[],r=e.length;for(let t=1;t<r;t++){let l=e[t],{type:r,values:s,p0:i,cp1:p=null,cp2:u=null,p:h,extreme:o=null,semiExtreme:y=null,corner:c=null,directionChange:x}=l,f=e[t+1]||null;o||c||f&&f.type!==r?(n.push(l),a.push(n),n=[]):n.push(l)}console.log("!!!chunks",a),function(e){console.log("chunks",e);let t="green";for(let a=0;a<e.length;a++){let n=e[a],r=n.length;t=a%2==0?"orange":"green";let s=n[0],i=n[r-1],p=[{type:"M",values:[s.p0.x,s.p0.y]}];for(let e=0,t=r;e<t;e++){let l=n[e];n[e+1],n[t-1],"C"===s.type&&i.type;let{type:a,values:r,p0:u,cp1:h=null,cp2:o=null,p:y=null,extreme:c,semiExtreme:x=null,corner:f=null}=l;p.push({type:a,values:r})}let u=me(p);l(markers,u,t,"1%","0.5")}}(a);let s=a.length;for(let e=0;e<s;e++){let t=a[e],l=a[e+1]||null;1===t.length&&l&&l[0].type}a=a.filter(Boolean);let i=[e[0]];for(let e=0;e<a.length;e++){let t=a[e],l=t.length,n=t[0],r=t[l-1],s=.05*ie(n.p0,r.p);for(let e=0,a=l;e<a;e++){let p=t[e];t[e+1],t[a-1];let u="C"===n.type&&"C"===r.type,{type:h,values:o,p0:y,cp1:c=null,cp2:x=null,p:f=null,extreme:g,semiExtreme:d=null,corner:v=null}=p,m=null,M=null,b=null,A=null,C=null,w=null,E=[],L=.666,k=null;if(u){let e=Math.abs(n.p0.x-n.cp1.x),t=Math.abs(n.p0.y-n.cp1.y),l=Math.abs(r.p.x-r.cp2.x),a=Math.abs(r.p.y-r.cp2.y),i=e<s&&e<t,p=l<s&&l<a,u=a<s&&l>a;t<s&&e>t&&(n.cp1.y=n.p0.y),u&&(r.cp2.y=r.p.y),i&&(n.cp1.x=n.p0.x),p&&(r.cp2.x=r.p.x)}if(me([{type:"M",values:[p.p0.x,p.p0.y]},{type:h,values:o}]),1===l||"C"!==h)i.push(p);else{let e=t.filter(e=>e.semiExtreme),l=t.filter(e=>e.directionChange);if(e.length||l.length){if(k=e.length?e[0]:l[0],n.p0.x===n.cp1.x&&n.p0.y===n.cp1.y?n.cp1=V([n.p0,n.cp1,n.cp2,n.p],.5):r.p.x===r.cp2.x&&r.p.y===r.cp2.y&&(r.cp2=V([r.p0,r.cp1,r.cp2,r.p],.5)),m=H(k.p,k.cp2,n.p0,n.cp1,!1),M=H(k.p,k.cp2,r.p,r.cp2,!1),m&&M){b=V([n.p0,m],L),A=V([r.p,M],L),C=V([k.p,m],L),w=V([k.p,M],L),E=[{type:"M",values:[n.p0.x,n.p0.y]},{type:"C",values:[b.x,b.y,C.x,C.y,k.p.x,k.p.y]},{type:"C",values:[w.x,w.y,A.x,A.y,r.p.x,r.p.y]}],me(E),i.push({type:"C",values:[b.x,b.y,C.x,C.y,k.p.x,k.p.y],p0:n.p0,cp1:b,cp2:C,p:k.p,dimA:ie(n.p0,k.p)},{type:"C",values:[w.x,w.y,A.x,A.y,r.p.x,r.p.y],p0:k.p,cp1:w,cp2:A,p:r.p,extreme:!0,dimA:ie(k.p,r.p)});break}}else i.push(p)}}}return i}function mt(e){for(let t=1,l=e.length;t<l;t++){let l=e[t],{type:a,values:n,p0:r,cp1:s=null,cp2:i=null,p:p=null}=l;if("C"===a){let a=Se(r,s,i,p);"Q"===a.type&&(a.extreme=l.extreme,a.corner=l.corner,a.dimA=l.dimA,a.squareDist=l.squareDist,e[t]=a)}}return e}function Mt(e,{areaThreshold:t=2.5}={}){for(let l=0,a=e.length;l<a;l++){let a=e[l],n=e[l+1]||null,{type:r,values:s,p0:i,cp1:p=null,cp2:u=null,p:h=null}=a;if("C"===r&&n&&"C"===n.type){let a=bt(i,p,u,h,t),r=bt(n.p0,n.cp1,n.cp2,n.p,t);if(a.isArc&&r.isArc){let t=.01*ie(i,n.p),s=Math.abs(n.p.x-i.x),p=Math.abs(n.p.y-i.y),u=p<t&&s>t,o=s<t&&p>t,{rx:y,ry:c}=a,x=ve([i,h,n.p])<0?0:1;if(o||u){y=Math.min(y,r.rx),c=Math.min(c,r.ry),e[l]=null,e[l+1].type="A",e[l+1].values=[y,c,0,0,x,n.p.x,n.p.y];continue}}}}return e=e.filter(Boolean)}function bt(e,t,l,a,n=7.5){let r,s={type:"C",values:[t.x,t.y,l.x,l.y,a.x,a.y]},i=0,p=!1,u=R(e,t,!0),h=R(a,l,!0),o=180*Math.abs(u-h)/Math.PI,y=0,c=0;if(Math.abs(o%180-90)<3){r=H(e,X(t,e.x,e.y,-.5*Math.PI),a,X(l,a.x,a.y,.5*Math.PI),!1);let u=H(e,t,a,l,!1);if(u){let r=re(e,u),h=re(a,u),o=+Math.max(r,h).toFixed(8),x=+Math.min(r,h).toFixed(8);y=x,c=o;let f=ve([e,t,l,a])<0?0:1,g=Math.abs(a.x-e.x)>Math.abs(a.y-e.y);100/y*Math.abs(y-c)<5&&(y=o,c=y),g&&(y=o,c=x);let d=de([{type:"M",values:[e.x,e.y]},{type:"C",values:[t.x,t.y,l.x,l.y,a.x,a.y]}]),v={type:"A",values:[y,c,0,0,f,a.x,a.y]};i=Math.PI*(y*c)/4,i-=Math.abs(ve([e,a,u])),function(e,t){let l=Math.abs(e-t);return Math.abs(100-100/e*(e+l))}(d,i)<n&&(p=!0,s=v)}}return{com:s,isArc:p,area:i,rx:y,ry:c,centroid:r}}function At(e,{angles:t=[],split:l=0,getPathData:a=!0,width:n=0,height:r=0}={}){let s=e.length,i={x:e[0].values[0],y:e[0].values[1]},p=i,u=[],h=[p],o=0;if(l=l||1,n&&r)o=.025*(n+r)/l;else{o=e.map(e=>e.dimA||0).filter(Boolean).sort()[0]}for(let t=1;t<s;t++){let a=e[t],n=e[t+1]||null,{type:r,values:s}=a,u=s.length,y=u?{x:s[u-2],y:s[u-1]}:i;if("C"===r||"Q"===r){let e={x:s[0],y:s[1]},t="C"===r?{x:s[2],y:s[3]}:e,n="C"===r?[p,e,t,y]:[p,e,y],i=a.dimA;l=Math.ceil(i/o);let u=[];for(let e=1;e<l;e++)u.push(1/l*e);u.forEach(e=>{let t=V(n,e);h.push(t)})}"M"===r&&(i=y),y.area=a.cptArea||0,y.isExtreme=a.extreme||!1,y.isCorner=a.corner||!1,y.isDirChange=a.directionChange||!1,h.push(y),a.extreme||a.corner||n&&n.type,p=y}return h=function(e,{quality:t=.9,width:l=0,height:a=0,absolute:n=!1,manhattan:r=!1,exclude:s=[]}={}){"string"==typeof t&&(n=!0,t=parseFloat(t));if(e.length<4||(!n&&t)>=1)return e;let i=t;if(!n){if(i=1-t,!l&&!a){let t=ue(e,12);({width:l,height:a}=xe(t))}i=r?.05*(l+a)*(1-t):(i*((l+a)/2/25))**2}let p,u=e[0],h=[u],o=e.length,y=s.length,c=0;for(let t=1;t<o;t++)p=e[t],c=r?ie(u,p):se(u,p),!(c<i)||y&&s.includes(t)?(h.push(p),u=p):u=p;return u.x!==p.x&&u.y!==p.y&&h.push(p),h}(h,{quality:.5,width:n,height:r}),u=function(e,t=!0){let l=[{type:"M",values:[e[0].x,e[0].y]},...e.slice(1).map(e=>({type:"L",values:[e.x,e.y]}))];return t&&l.push({type:"Z",values:[]}),l}(h),a?u:h}function Ct(e="",{getObject:t=!1,toAbsolute:l=!0,toRelative:a=!0,toShorthands:n=!0,quadraticToCubic:r=!0,arcToCubic:s=!1,cubicToArc:i=!1,simplifyBezier:p=!0,optimizeOrder:u=!0,autoClose:h=!0,removeZeroLength:o=!0,refineClosing:y=!0,removeColinear:c=!0,flatBezierToLinetos:x=!0,revertToQuadratics:f=!0,refineExtremes:g=!0,simplifyCorners:d=!1,keepExtremes:v=!0,keepCorners:m=!0,extrapolateDominant:M=!0,keepInflections:b=!1,addExtremes:A=!1,addSemiExtremes:C=!1,smoothPoly:w=!1,harmonizeCpts:E=!1,toPolygon:L=!1,removeOrphanSubpaths:k=!1,simplifyRound:S=!1,scale:P=1,scaleTo:I=0,crop:D=!1,alignToOrigin:F=!1,decimals:q=3,autoAccuracy:$=!0,minifyD:z=0,tolerance:T=1,reverse:Q=!1,mergePaths:B=!1,removeHidden:j=!0,removeUnused:N=!0,shapesToPaths:Z=!0,tMin:R=0,tMax:O=1,redraw:H=!1}={}){T=Math.max(.1,T),P=Math.max(.001,P);let U=function(e){let t="string";if(Array.isArray(e))return e[0]?.type&&e[0]?.values?"pathData":"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),V="",J=0,X=0,Y=0,G={},K="",_="svgMarkup"===U?1:0,ee=[];J=e.length;let te={x:0,y:0,width:0,height:0},le={x:0,y:0,width:0,height:0},ae=[],ne=[];if(_){if(V=function(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","fill","stroke","stroke-width","stroke-linecap","stroke-linejoin"]);let r=["metadata","script"],s=n.querySelectorAll("*"),i=n.querySelectorAll("text").length?[]:["font-family","font-weight","font-style","font-size"];return s.forEach(e=>{let t=e.nodeName,a=e.getAttribute("style")||"",n=!!a&&a.trim().includes("display:none"),s=e.getAttribute("display")&&"none"===e.getAttribute("display")||n;t.includes(":")||r.includes(t)||l&&s?e.remove():(function(e){[...e.attributes].map(e=>e.name).forEach(t=>{t.includes(":")&&e.removeAttribute(t)})}(e),function(e,t=[]){[...e.attributes].map(e=>e.name).forEach(l=>{t.includes(l)&&e.removeAttribute(l)})}(e,i))}),t?n:yt(n)}(e,{returnDom:!0,removeHidden:j,removeUnused:N}),Z){V.querySelectorAll("polygon, polyline, line, rect, circle, ellipse").forEach(e=>{let t=He(e);e.replaceWith(t)})}V.querySelectorAll("path").forEach(e=>{ee.push({d:e.getAttribute("d"),el:e})}),te=function(e=null,t=-1){const l=e=>e&&isNaN(e)?e.match(/[^\d|.]+/g)[0]:"";if(!e)return!1;let a=e.hasAttribute("width"),n=e.hasAttribute("height"),r=e.hasAttribute("viewBox"),s=a?e.getAttribute("width"):0,i=n?e.getAttribute("height"):0,p=!!a&&l(s),u=!!n&&l(s),h=s?s.includes("%")?0:parseFloat(s):300,o=i?i.includes("%")?0:parseFloat(i):150,y=r?e.getAttribute("viewBox").split(/,| /).filter(Boolean).map(Number):[0,0,h,o];return t>-1&&([h,o]=[h,o].map(e=>+e.toFixed(t)),y=y.map(e=>+e.toFixed(t))),{x:y[0],y:y[1],width:y[2],height:y[3],w:h,h:o,hasViewBox:r,hasWidth:a,hasHeight:n,widthUnit:p,heightUnit:u}}(V,q)}else{if("pathDataString"===U)K=e;else if("polyString"===U)K="M"+e;else if("pathData"===U){K=e,J=K.map(e=>`${e.type} ${e.values.join(" ")}`).join(" ").length}ee.push({d:K,el:null})}let re={toRelative:a,toShorthands:n,decimals:q},se=[];for(let e=0,t=ee.length;t&&e<t;e++){let t=ee[e],{d:a,el:n}=t,j=Be(a,{quadraticToCubic:r,toAbsolute:l,arcToCubic:s}),N=w||L?xe(W(j)):null;if(1!==P||I){if(I)if(te.width&&!D)P=I/te.width;else{let e=j.map(e=>({type:e.type,values:e.values}));e=Pe(e,{arcToCubic:!0}),e=ce(e);let t=xe(W(e));ae.push(t.x,t.x+t.width),ne.push(t.y,t.y+t.height);let l=I/t.width;P=l}j=dt(j,P)}let Z=j.length;k&&(j=Ve(j));let U=he(j),V=U.length,G=[];for(let e=0;e<V;e++){let t=U[e];if(L){p=!1,w=!1,E=!1,t=Ue(t);let e=ke(t),{bb:l,pathData:a}=e;t=a,t=At(t,{angles:[],split:1,width:N.width,height:N.height,getPathData:!0})}if(w){let e=Array.from(new Set(t.map(e=>e.type))).join(""),l=!/[acqts]/gi.test(e),a=/[z]/gi.test(e);if(l){t=We(t),t=ht(W(t),{denoise:.8,tolerance:T,width:N.width,height:N.height,manhattan:!1,absolute:!1,keepCorners:m,keepExtremes:v,keepInflections:b,closed:a})}}E&&(t=Ge(t)),(c||o)&&(t=We(t)),H&&(A=!0,C=!0,d=!1,m=!0,v=!0,u=!0,R=0,O=0),u&&(t=Je(t)),c&&(t=Ue(t,{tolerance:T,flatBezierToLinetos:!1})),(A||C)&&(t=ce(t,{tMin:R,tMax:O,addExtremes:A,addSemiExtremes:C,angles:[30]}));let l=ke(t,{detectSemiExtremes:C}),{pathData:a,bb:n,dimA:r}=l;if(ae.push(n.x,n.x+n.width),ne.push(n.y,n.y+n.height),y&&(a=gt(a,{threshold:.001*r})),a=p?be(a,{simplifyBezier:p,keepInflections:b,keepExtremes:v,keepCorners:m,extrapolateDominant:M,revertToQuadratics:f,tolerance:T,reverse:Q}):a,g){a=ot(a,{threshold:.05*(n.width+n.height),tolerance:T})}if(H&&(n.width,n.height,a=vt(a,{tolerance:T,threshold:.001*r})),i&&(a=Mt(a,{areaThreshold:2.5})),c&&x&&(a=Ue(a,{tolerance:T,flatBezierToLinetos:x})),d){a=ct(a,{threshold:.1*(n.width+n.height),tolerance:T})}S&&(a=ft(a)),f&&(a=mt(a)),u&&(a=Xe(a,{autoClose:h})),G.push({pathData:a,bb:n})}let K=Math.min(...ae),_=Math.min(...ne);le={x:K,y:_,width:Math.max(...ae)-K,height:Math.max(...ne)-_};let ie=le.height>le.width;if(u&&(G=ie?G.sort((e,t)=>e.bb.y-t.bb.y||e.bb.x-t.bb.x):G.sort((e,t)=>e.bb.x-t.bb.x||e.bb.y-t.bb.y)),j=[],G.forEach(e=>{j.push(...e.pathData)}),$&&(q=we(j),re.decimals=q),n&&B)se.push(...j);else{j=Pe(j,re),j=We(j),F&&(console.log(le),j[0].values[0]=(j[0].values[0]-le.x).toFixed(q),j[0].values[1]=(j[0].values[1]-le.y).toFixed(q),le.x=0,le.y=0);let e=j.length,l=me(j,z);X=l.length,Y=+(100/J*X).toFixed(2),t.d=l,t.report={original:Z,new:e,saved:Z-e,compression:Y,decimals:q},n&&n.setAttribute("d",l)}}if(_){if(se.length){let e=Pe(se,re);e=We(e);let t=me(e,z);ee[0].el.setAttribute("d",t);for(let e=1;e<ee.length;e++){let t=ee[e].el;t&&t.remove()}!function(e){e.querySelectorAll("g, defs").forEach(e=>{e.children.length||e.remove()})}(V)}if(P){let{x:e,y:t,width:l,height:a,w:n,h:r,hasViewBox:s,hasWidth:i,hasHeight:p,widthUnit:u,heightUnit:h}=te;D&&(e=le.x,t=le.y,l=le.width,a=le.height,n=l,r=a),s&&V.setAttribute("viewBox",[e,t,l,a].map(e=>+(e*P).toFixed(q)).join(" ")),i&&V.setAttribute("width",+(n*P).toFixed(q)+u),p&&V.setAttribute("height",+(r*P).toFixed(q)+h)}V=yt(V),X=V.length,Y=+(100/J*X).toFixed(2),J=+(J/1024).toFixed(3),X=+(X/1024).toFixed(3),G={svgSize:J,svgSizeOpt:X,compression:Y,decimals:q}}else({d:K,report:G}=ee[0]);return t?{svg:V,d:K,report:G,inputType:U,mode:_}:K||V}"undefined"!=typeof window&&(window.svgPathSimplify=Ct),e.PI=A,e.abs=a,e.acos=n,e.asin=r,e.atan=s,e.atan2=i,e.ceil=p,e.cos=u,e.exp=h,e.floor=o,e.hypot=c,e.log=y,e.max=x,e.min=f,e.pow=g,e.random=d,e.round=v,e.sin=m,e.sqrt=M,e.svgPathSimplify=Ct,e.tan=b}(this["svg-path-simplify"]=this["svg-path-simplify"]||{});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svg-path-simplify",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
 
5
5
  "type": "module",
6
6
 
@@ -30,17 +30,16 @@ export function pathDataRemoveColinear(pathData, {
30
30
  p = type !== 'Z' ? { x: valsL[0], y: valsL[1] } : M;
31
31
 
32
32
 
33
- /*
34
33
  let area = p1 ? getPolygonArea([p0, p, p1], true) : Infinity
35
34
  let distSquare = getSquareDistance(p0, p1)
36
35
  let distMax = distSquare ? distSquare / 333 * tolerance : 0
37
- */
38
36
 
39
- //let isFlat = area < distMax;
40
- let isFlat = false;
37
+ let isFlat = area < distMax;
38
+ //let isFlat = false;
41
39
  let isFlatBez = false;
42
40
 
43
41
 
42
+ /*
44
43
  // flatness by cross product
45
44
  let dx0 = Math.abs(p1.x - p0.x)
46
45
  let dy0 = Math.abs(p1.y - p0.y)
@@ -70,6 +69,7 @@ export function pathDataRemoveColinear(pathData, {
70
69
  isFlat = true
71
70
  }
72
71
  }
72
+ */
73
73
 
74
74
 
75
75
  if (!flatBezierToLinetos && type === 'C') isFlat = false;
@@ -35,6 +35,9 @@ export function cleanUpSVG(svgMarkup, {
35
35
  let removeEls = ['metadata', 'script']
36
36
 
37
37
  let els = svg.querySelectorAll('*')
38
+
39
+ let textEls = svg.querySelectorAll('text')
40
+ let remove = !textEls.length ? ['font-family', 'font-weight', 'font-style', 'font-size'] : [];
38
41
 
39
42
  els.forEach(el => {
40
43
  let name = el.nodeName;
@@ -47,6 +50,7 @@ export function cleanUpSVG(svgMarkup, {
47
50
  } else {
48
51
  // remove BS elements
49
52
  removeNameSpaceAtts(el)
53
+ removeAtts(el,remove)
50
54
  }
51
55
  })
52
56
 
@@ -88,6 +92,17 @@ function removeExcludedAttribues(el, allowed = ['viewBox', 'xmlns', 'width', 'he
88
92
  }
89
93
 
90
94
 
95
+ function removeAtts(el, remove=[]) {
96
+ let atts = [...el.attributes].map((att) => att.name);
97
+ atts.forEach((att) => {
98
+ if (remove.includes(att)) {
99
+ el.removeAttribute(att);
100
+ }
101
+ });
102
+ }
103
+
104
+
105
+
91
106
  function removeNameSpaceAtts(el) {
92
107
  let atts = [...el.attributes].map((att) => att.name);
93
108
  atts.forEach((att) => {