svg-path-simplify 0.4.3 → 0.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +2 -1
  3. package/dist/svg-path-simplify.esm.js +1670 -509
  4. package/dist/svg-path-simplify.esm.min.js +2 -2
  5. package/dist/svg-path-simplify.js +1671 -508
  6. package/dist/svg-path-simplify.min.js +2 -2
  7. package/dist/svg-path-simplify.pathdata.esm.js +936 -463
  8. package/dist/svg-path-simplify.pathdata.esm.min.js +2 -2
  9. package/dist/svg-path-simplify.poly.cjs +9 -8
  10. package/index.html +60 -20
  11. package/package.json +1 -1
  12. package/src/constants.js +4 -0
  13. package/src/detect_input.js +47 -29
  14. package/src/index.js +8 -0
  15. package/src/pathData_simplify_cubic.js +46 -18
  16. package/src/pathData_simplify_revertToquadratics.js +0 -1
  17. package/src/pathSimplify-main.js +81 -20
  18. package/src/pathSimplify-only-pathdata.js +7 -2
  19. package/src/pathSimplify-presets.js +14 -4
  20. package/src/svg-getAttributes.js +5 -3
  21. package/src/svgii/convert_units.js +1 -1
  22. package/src/svgii/geometry.js +140 -2
  23. package/src/svgii/geometry_bbox_element.js +1 -1
  24. package/src/svgii/geometry_deduceRadius.js +116 -27
  25. package/src/svgii/geometry_length.js +18 -2
  26. package/src/svgii/pathData_analyze.js +18 -0
  27. package/src/svgii/pathData_convert.js +188 -88
  28. package/src/svgii/pathData_fix_directions.js +10 -18
  29. package/src/svgii/pathData_reorder.js +123 -16
  30. package/src/svgii/pathData_simplify_refineCorners.js +130 -35
  31. package/src/svgii/pathData_simplify_refine_round.js +420 -0
  32. package/src/svgii/poly_normalize.js +9 -8
  33. package/src/svgii/rounding.js +112 -80
  34. package/src/svgii/svg_cleanup.js +75 -22
  35. package/src/svgii/svg_cleanup_convertPathLength.js +27 -15
  36. package/src/svgii/svg_cleanup_normalize_transforms.js +1 -1
  37. package/src/svgii/svg_cleanup_remove_els_and_atts.js +6 -1
  38. package/src/svgii/svg_el_parse_style_props.js +13 -10
  39. package/src/svgii/svg_validate.js +220 -0
  40. package/tests/testSVG.js +14 -1
  41. package/src/svgii/pathData_refine_round.js +0 -222
@@ -1,3 +1,3 @@
1
- const e=180/Math.PI,t=Math.PI/180;function l(e,t,l="red",a="1%",n="1",r="",s=!0,p="",i=""){Array.isArray(t)&&(t={x:t[0],y:t[1]});let u=`<circle class="${i}" opacity="${n}" id="${p}" cx="${t.x}" cy="${t.y}" r="${a}" fill="${l}">\n <title>${r}</title></circle>`;if(!s)return u;e.insertAdjacentHTML("beforeend",u)}function a(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:n,acos:r,asin:s,atan:p,atan2:i,ceil:u,cos:y,exp:h,floor:o,log:c,max:x,min:f,pow:g,random:d,round:v,sin:M,sqrt:m,tan:b,PI:A}=Math;function C(e,t,l=!1){let a=i(t.y-e.y,t.x-e.x);return l&&a<0&&(a+=2*Math.PI),a}function L(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 p=180/Math.PI;return{startAngle:n,endAngle:r,deltaAngle:s,startAngleDeg:n*p,endAngleDeg:r*p,deltaAngleDeg:s*p}}function w(e=null,t=null,l=null,a=null,n=!0,r=!1,s=!1){let p,i,u,y,h,o={};if(!(e&&t&&l&&a))return s&&console.warn("points missing"),!1;if(e.x===t.x&&e.y===t.y||l.x===a.x&&l.y===a.y)return!1;try{if(p=(a.y-l.y)*(t.x-e.x)-(a.x-l.x)*(t.y-e.y),0===p)return!1}catch{return s&&console.warn("!catch",e,t,"p3:",l,"p4:",a),!1}i=e.y-l.y,u=e.x-l.x,y=(a.x-l.x)*i-(a.y-l.y)*u,h=(t.x-e.x)*i-(t.y-e.y)*u,i=y/p,u=h/p,o={x:e.x+i*(t.x-e.x),y:e.y+i*(t.y-e.y)};let c=!1;return i>0&&i<1&&u>0&&u<1&&(c=!0),!n&&r&&(i>0&&u<0||i<0&&u>0)?(c=!1,!1):!(n&&!c)&&o}function S(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=C(e,t),n.angle<0&&(n.angle+=2*A)),n}function E(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],p=n?e[2]:e[1],i=e[e.length-1],u={x:0,y:0};if(l||a){let e,l,y,h,o,c=r.x===s.x&&r.y===s.y,x=i.x===p.x&&i.y===p.y;0!==t||c?1!==t||x?(c&&(t+=1e-7),x&&(t-=1e-7),e=S(r,s,t),n?(l=S(s,p,t),y=S(p,i,t),h=S(e,l,t),o=S(l,y,t),u=S(h,o,t),u.angle=C(h,o),a&&(u.cpts=[l,y,h,o])):(l=S(r,s,t),y=S(s,i,t),u=S(l,y,t),u.angle=C(l,y),a&&(u.cpts=[l,y]))):(u.x=i.x,u.y=i.y,u.angle=C(p,i)):(u.x=r.x,u.y=r.y,u.angle=C(r,s))}else{let e=1-t;u=n?{x:e**3*r.x+3*e**2*t*s.x+3*e*t**2*p.x+t**3*i.x,y:e**3*r.y+3*e**2*t*s.y+3*e*t**2*p.y+t**3*i.y}:{x:e*e*r.x+2*e*t*s.x+t**2*i.x,y:e*e*r.y+2*e*t*s.y+t**2*i.y}}return u})(e,t,l):S(e[0],e[1],t,l),l&&r.angle<0&&(r.angle+=2*A),n?[r.x,r.y]:r}function P(l,a,n,r,s,p,i,u,y,h=!0){const o=(e,t,l,a,n=!0)=>{let r=Math.atan2(a-t,l-e);return n&&r<0&&(r+=2*Math.PI),r};let c={cx:0,cy:0,rx:n=Math.abs(n),ry:r=Math.abs(r),startAngle:0,endAngle:0,deltaAngle:0,clockwise:i,xAxisRotation:s=n===r?0:s<0&&h?s+360:s,largeArc:p,sweep:i};if(0==n||0==r)throw Error("rx and ry can not be 0");let x,f,g=n===r?0:s*t,d=g?Math.sin(g):0,v=g?Math.cos(g):1,M=(l-u)/2,m=(a-y)/2,b=(l+u)/2,A=(a+y)/2,C=g?v*M+d*m:M,L=g?v*m-d*M:m,w=C*C/(n*n)+L*L/(r*r);if(w>1){let e=Math.sqrt(w);n*=e,r*=e,c.rx=n,c.ry=r}let S=n*r,E=n*L,P=r*C,I=E**2+P**2;if(!I)throw Error("start point can not be same as end point");let k=Math.sqrt(Math.abs((S*S-I)/I));p===i&&(k=-k);let D=k*E/r,Q=-k*P/n;x=g?v*D-d*Q+b:b+D,f=g?d*D+v*Q+A:A+Q,c.cy=f,c.cx=x;let $=o(x,f,l,a,h),z=o(x,f,u,y,h);i?z<$&&(z+=2*Math.PI):z>$&&(z-=2*Math.PI);let T=z-$;return c.startAngle=$,c.startAngle_deg=$*e,c.endAngle=z,c.endAngle_deg=z*e,c.deltaAngle=T,c.deltaAngle_deg=T*e,c}function I(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 k(e,t,l,a,n,r=0,s=!0,i=!1){if(n=i?n*A/180:n,r=i?r*A/180:r,r=l!==a&&r!==2*A?r:0,s&&l!==a){let e=p(b(n=r?n-r:n)*(l/a));n=y(n)<0?e+A:e}let u=e+l*y(n),h=t+a*M(n),o={x:u,y:h};return r&&(o.x=e+(u-e)*y(r)-(h-t)*M(r),o.y=t+(u-e)*M(r)+(h-t)*y(r)),o}function D(e,t,l){if(t===l||e%A*.5==0)return e;let a=p(b(e)*(t/l));return a=y(e)<0?a+A:a,a}function Q(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),p=Math.min(e.x,a.x),i=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>=p&&n.x<=i&&r.x>=p&&r.x<=i)}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[p,i,u,y,h,o,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,L,w,S,E=[];for(let e=0;e<2;++e)if(0==e?(m=6*p-12*u+6*h,M=-3*p+9*u-9*h+3*c,b=3*u-3*p):(m=6*i-12*y+6*o,M=-3*i+9*y-9*o+3*x,b=3*y-3*i),Math.abs(M)<1e-8){if(Math.abs(m)<1e-8)continue;A=-b/m,0<A&&A<1&&E.push(A)}else w=m*m-4*b*M,w<0?Math.abs(w)<1e-8&&(A=-m/(2*M),0<A&&A<1&&E.push(A)):(S=Math.sqrt(w),C=(-m+S)/(2*M),0<C&&C<1&&E.push(C),L=(-m-S)/(2*M),0<L&&L<1&&E.push(L));let P=E.length;for(;P--;)A=E[P];return E}(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,p,i,u=Math.min(e.y,l.y),y=Math.min(e.x,l.x),h=Math.max(e.x,l.x),o=Math.max(e.y,l.y);if(t.y>=u&&t.y<=o&&t.x>=y&&t.x<=h)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,p=0==e?-2*c+2*f:-2*x+2*g,Math.abs(s)>1e-12&&(i=-p/(2*s),i>0&&i<1&&M.push(i));return M}(e[0],e[1],e[2],{addExtremes:t,addSemiExtremes:l});return a}function z(e,t){const l=(e,t,l,a,n,r)=>{var s=Math.cos(r),p=Math.sin(r),i=a*Math.cos(e),u=n*Math.sin(e);return{x:t+s*i-p*u,y:l+p*i+s*u}};let a,n,r,s,p,i=P(e.x,e.y,t[0],t[1],t[2],t[3],t[4],t[5],t[6]),{rx:u,ry:y,cx:h,cy:o,endAngle:c,deltaAngle:x}=i,f=t[2],g={x:t[5],y:t[6]},d=[g],v=f*Math.PI/180,M=Math.tan(v);p=Math.atan2(-y*M,u);let m=p,b=p+Math.PI,A=Math.atan2(y,u*M),C=A+Math.PI,L=[e.x,g.x],w=[e.y,g.y],S=Math.min(...L),E=Math.max(...L),I=Math.min(...w),k=Math.max(...w),D=l(c-.001*x,h,o,u,y,v),Q=l(c-.999*x,h,o,u,y,v);return(D.x>E||Q.x>E)&&(a=l(m,h,o,u,y,v),d.push(a)),(D.x<S||Q.x<S)&&(n=l(b,h,o,u,y,v),d.push(n)),(D.y<I||Q.y<I)&&(s=l(C,h,o,u,y,v),d.push(s)),(D.y>k||Q.y>k)&&(r=l(A,h,o,u,y,v),d.push(r)),d}function T(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],p=n?[]:e.slice(0);if(n)for(let t=0;t<l;t++){let l=e[t];p.push(I(l,0,0,n))}let i=a?q(...p):F(...p);r.push(...i)}return r=[...new Set(r)].sort(),r}function q(e,t,l,a){if(!Q(e,[t,l,a]))return[];let n,r,s,p,i,u,y,h,[o,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*o-12*x+6*g,n=-3*o+9*x-9*g+3*v,s=3*x-3*o):(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;p=-s/r,p>0&&p<1&&m.push(p)}else y=r*r-4*s*n,y<0?Math.abs(y)<b&&(p=-r/(2*n),p>0&&p<1&&m.push(p)):(h=Math.sqrt(y),i=(-r+h)/(2*n),i>0&&i<1&&m.push(i),u=(-r-h)/(2*n),u>0&&u<1&&m.push(u));let A=m.length;for(;A--;)p=m[A];return[...new Set(m)].sort()}function F(e,t,l){if(!Q(e,[t,l]))return[];let a,n,r,[s,p,i,u,y,h]=[e.x,e.y,t.x,t.y,l.x,l.y],o=[];for(let e=0;e<2;++e)a=0==e?s-2*i+y:p-2*u+h,n=0==e?-2*s+2*i:-2*p+2*u,Math.abs(a)>1e-12&&(r=-n/(2*a),r>0&&r<1&&o.push(r));return[...new Set(o)].sort()}function j(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 R(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 Math.sqrt(a*a+n*n)}function Z(e,t){let l=t.x-e.x,a=t.y-e.y;return l*l+a*a}function O(e,t){return Math.abs(t.x-e.x)+Math.abs(t.y-e.y)}function B(e,t){return.5*(Math.abs(t.x-e.x)+Math.abs(t.y-e.y))}function N(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 J(e,t){let l,a,n,r,s,p,i=[],u=[],y=e[0],h=e[1],o=e[e.length-2],c=e[e.length-1];return 4===e.length?(l=E([y,h],t),a=E([h,o],t),n=E([o,c],t),r=E([l,a],t),s=E([a,n],t),p=E([r,s],t),i.push({x:y.x,y:y.y},{x:l.x,y:l.y},{x:r.x,y:r.y},{x:p.x,y:p.y}),u.push({x:p.x,y:p.y},{x:s.x,y:s.y},{x:n.x,y:n.y},{x:c.x,y:c.y})):3===e.length?(a=E([y,h],t),n=E([h,c],t),p=E([a,n],t),i.push({x:y.x,y:y.y},{x:a.x,y:a.y},{x:p.x,y:p.y}),u.push({x:p.x,y:p.y},{x:n.x,y:n.y},{x:c.x,y:c.y})):2===e.length&&(a=E([y,c],t),i.push({x:y.x,y:y.y},{x:a.x,y:a.y}),u.push({x:a.x,y:a.y},{x:c.x,y:c.y})),[i,u]}function W(e,t,{tMin:l=0,tMax:a=1,addExtremes:n=!0,addSemiExtremes:r=!1}={}){let s=[],p=6===t.length?"C":"Q",i={x:t[0],y:t[1]},u="C"===p?{x:t[2],y:t[3]}:i,y={x:t[4],y:t[5]},h=0;let o="C"===p?[e,i,u,y]:[e,i,y],c=n?$(o,{addExtremes:n,addSemiExtremes:!1}):[],x=r?$(o,{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,p,i=t.length,u={x:t[i-2],y:t[i-1]};2===t.length?p=[e,u]:4===t.length?(r={x:t[0],y:t[1]},p=[e,r,u]):6===t.length&&(r={x:t[0],y:t[1]},s={x:t[2],y:t[3]},p=[e,r,s,u]);if(l.length)if(1===l.length){let e=J(p,l[0]),t=e[0],a=e[1];n.push(t,a)}else{let e=l[0],t=J(p,e),a=t[0];n.push(a),p=t[1];for(let t=1;t<l.length;t++){e=l[t-1];let a=J(p,(l[t]-e)/(1-e));n.push(a[0]),t===l.length-1&&n.push(a[a.length-1]),p=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),h+=l.length}else s.push({type:p,values:t});return{pathData:s,count:h}}function H(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]},p={x:e[0].values[0],y:e[0].values[1]},i=e.length;for(let u=1;i&&u<i;u++){let i=e[u],{type:y,values:h}=i,o=h.slice(-2);if(o[0],o[1],"C"!==y&&"Q"!==y)r.push(i);else if((a||n)&&("C"===y||"Q"===y)){let e=W(s,h,{tMin:t,tMax:l,addExtremes:a,addSemiExtremes:n}).pathData;r.push(...e)}s={x:o[0],y:o[1]},"z"===y.toLowerCase()?s=p:"M"===y&&(p={x:o[0],y:o[1]})}return r}function U(e=0,t=3){if(t<=-1)return e;if(!t)return Math.round(e);let l=10**t;return Math.round(e*l)/l}function _(e,t=-1){if(t<0)return e;let l=e.length,a=t;for(let t=0;t<l;t++){let l=e[t],{values:n}=l,r=n.length;if(r)for(let l=0;l<r;l++)e[t].values[l]=U(n[l],a)}return e}function V(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),p=Math.max(...a),i={x:n,left:n,right:r,y:s,top:s,bottom:p,width:r-n,height:p-s};if(t>-1)for(let e in i)i[e]=+i[e].toFixed(t);return i}function G(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,p={x:n.values[n.values.length-2],y:n.values[n.values.length-1]},i=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=R(p,i)/2,l=S(p,i,.5),a=k(l.x,l.y,e,e,0),n=k(l.x,l.y,e,e,Math.PI);t.push(a,n,i);break}arcToBezier(p,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(i)}return t}(e),l=V(t);return l}(e);t.push(l)}),t}function K(e,t){let[l,a,n,r,s,p]=[e.x,e.y,e.width,e.height,e.x+e.width,e.y+e.height],[i,u,y,h,o,c]=[t.x,t.y,t.width,t.height,t.x+t.width,t.y+t.height],x=!1;return n*r!=y*h&&n*r>y*h&&l<i&&s>o&&a<u&&p>c&&(x=!0),x}function X(e,t=9){let l=0,a=[],n=N(e),r=n.length>1,s=[];if(r){let e=G(n);e.forEach(function(t,l){for(let l=0;l<e.length;l++){let a=e[l];if(t!=a){K(t,a)&&s.push(l)}}})}return n.forEach((e,t)=>{a=[];let n=0,r=0,p=1,i=[];e.forEach(function(t,l){let[r,s]=[t.type,t.values],p=s.length;if(s.length){let u=(l>0?e[l-1]:e[0]).values,y=u.length,h={x:u[y-2],y:u[y-1]},o={x:s[p-2],y:s[p-1]};if("C"===r||"Q"===r){let e={x:s[0],y:s[1]};i="C"===r?[h,e,{x:s[2],y:s[3]},o]:[h,e,o];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}(i));n+=t,a.push(h,o)}else if("A"===r){let e=P(h.x,h.y,t.values[0],t.values[1],t.values[2],t.values[3],t.values[4],o.x,o.y),{cx:l,cy:r,rx:s,ry:p,startAngle:i,endAngle:u,deltaAngle:y}=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,p,i,u));c-=Math.abs(Y([h,{x:l,y:r},o])),a.push(h,o),n+=c}else a.push(h,o)}});let u=Y(a);-1!==s.indexOf(t)&&(p=-1),r=u<0&&n<0?(Math.abs(n)-Math.abs(u))*p:(Math.abs(n)+Math.abs(u))*p,l+=r}),l}function Y(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 ee(e,t=0){t=parseFloat(t);let l=e.length,a=e[0].values.join(" "),n=t>1?"\n":t<1?"":" ",r=t>.5?" ":"",s=`${e[0].type}${r}${a}${n}`;for(let p=1;p<l;p++){let i=e[p-1],u=e[p],{type:y,values:h}=u;if(a="",t||"A"!==y&&"a"!==y||(h=[h[0],h[1],h[2],`${h[3]}${h[4]}${h[5]}`,h[6]]),y=t<1&&i.type===u.type&&"m"!==u.type.toLowerCase()||t<1&&"M"===i.type&&"L"===u.type?" ":u.type,t)a=h.join(" ");else{let e=!1;for(let t=0,l=h.length;t<l;t++){let l=h[t],n=l.toString(),r=n.includes(".")&&Math.abs(l)<1;r&&e&&(n=n.replace(/^0\./,".")),!(t>0)||e&&r||(a+=" "),a+=n,e=r}}p===l-1&&(n=""),s+=`${y}${r}${a}${n}`}return t<1&&(s=s.replace(/[A-Za-z]0(?=\.)/g,e=>e[0]).replace(/ 0\./g," .").replace(/ -/g,"-").replace(/-0\./g,"-.").replace(/Z/g,"z")),s}function te(e,t,l=0,a=1,n=!1){const r=(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 s=[e,t],p=B(e.p0,e.p)>B(t.p0,t.p),i=JSON.parse(JSON.stringify(e)),u=JSON.parse(JSON.stringify(t)),y=w(i.p0,i.cp1,u.p,u.cp2,!1);if(!y)return s;if(p){let l={p0:{x:e.p.x,y:e.p.y},cp1:{x:e.cp2.x,y:e.cp2.y},cp2:{x:e.cp1.x,y:e.cp1.y},p:{x:e.p0.x,y:e.p0.y}};e={p0:{x:t.p.x,y:t.p.y},cp1:{x:t.cp2.x,y:t.cp2.y},cp2:{x:t.cp1.x,y:t.cp1.y},p:{x:t.p0.x,y:t.p0.y}},t=l}let h=(e,t)=>({x:e.x-t.x,y:e.y-t.y}),o=(e,t)=>({x:e.x*t,y:e.y*t}),c=(e,t)=>e.x*t.x+e.y*t.y,x=t.p0,f=r(t.p0,t.cp1,t.cp2,t.p,0),g=c(h(e.p0,x),f)/c(f,f),d=E([t.p0,t.cp1,t.cp2,t.p],g),v=r(t.p0,t.cp1,t.cp2,t.p,g);g-=c(h(d,e.p0),v)/c(v,v);let M=E([t.p0,t.cp1,t.cp2,t.p],g),m=t.p,b=r(t.p0,t.cp1,t.cp2,t.p,g),A=r(t.p0,t.cp1,t.cp2,t.p,1),C=1-g,L=(P=M,I=o(b,C/3),{x:P.x+I.x,y:P.y+I.y});var P,I;let k=h(m,o(A,C/3)),D={p0:M,cp1:L,cp2:k,p:m,t0:g};p&&(D={p0:m,cp1:k,cp2:L,p:M,t0:g});let Q=.5*(1-g),$=E([D.p0,D.cp1,D.cp2,D.p],Q,!1,!0),z=$.cpts[2],T=w($,z,D.p0,y,!1),q=w($,z,D.p,y,!1),F=S(D.p0,T,1.333),j=S(D.p,q,1.333);if(w(i.p0,F,u.p,j,!0))return s;D.cp1=F,D.cp2=j;let R=B(i.p0,D.p0)+B(u.p,D.p);if(D.p0=i.p0,D.p=u.p,D.extreme=u.extreme,D.corner=u.corner,D.dimA=u.dimA,D.directionChange=u.directionChange,D.type="C",D.values=[D.cp1.x,D.cp1.y,D.cp2.x,D.cp2.y,D.p.x,D.p.y],R<l){let t=p?1+g:Math.abs(g),r=1+Math.abs(g);if(t=p?1+g:Math.abs(g)/r,B(E([D.p0,D.cp1,D.cp2,D.p],t),e.p)>l*a)return s;let y=X([{type:"M",values:[i.p0.x,i.p0.y]},{type:"C",values:[i.cp1.x,i.cp1.y,i.cp2.x,i.cp2.y,i.p.x,i.p.y]},{type:"C",values:[u.cp1.x,u.cp1.y,u.cp2.x,u.cp2.y,u.p.x,u.p.y]}]),h=[{type:"M",values:[D.p0.x,D.p0.y]},{type:"C",values:[D.cp1.x,D.cp1.y,D.cp2.x,D.cp2.y,D.p.x,D.p.y]}],o=X(h),c=Math.abs(o/y-1);D.error=5*c*a,n&&ee(h),c<.05*a&&(s=[D])}return s}function le(e,{keepExtremes:t=!0,keepInflections:l=!0,keepCorners:a=!0,extrapolateDominant:n=!0,tolerance:r=1}={}){let s=[e[0]],p=e.length;for(let n=2;p&&n<=p;n++){let i=e[n-1],u=n<p?e[n]:null,y=u?.type||null,{type:h,values:o,p0:c,p:x,cp1:f=null,cp2:g=null,extreme:d=!1,directionChange:v=!1,corner:M=!1,dimA:m=0}=i;if("C"===h&&"C"===y)if(a&&M||t&&d)s.push(i);else{let y=ae(i,u,{tolerance:r}),h=0;if(1===y.length){i=y[0];let u=1;h+=i.error;for(let s=n+1;h<r&&s<p;s++){let n=e[s];if("C"!==n.type||l&&i.directionChange||a&&i.corner||t&&i.extreme)break;let p=ae(i,n,{tolerance:r});if(p.length>1)break;h+=.5*p[0].error,u++,i=p[0]}s.push(i),n<p&&(n+=u)}else s.push(i)}else s.push(i)}return s}function ae(e,t,{tolerance:l=1}={}){let a=[e,t],n=function(e,t){let l=O(e.cp2,e.p);if(0===l)return 0;let a=O(e.p,t.cp1);if(0===a)return 0;let n=O(e.cp2,t.cp1);return l/n}(e,t);if(!n)return a;let r=O(e.p0,e.p),s=O(t.p0,t.p),p=.08*Math.max(0,Math.min(r,s))*l,i=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=E([i.p0,i.cp1,i.cp2,i.p],n),y=O(e.p,u),h=0,o=0,c=!1,x=y;if(y<p){let l=.5*(1+n);if(h=O(E([t.p0,t.cp1,t.cp2,t.p],.5),E([i.p0,i.cp1,i.cp2,i.p],l)),x+=h,h<p){let t=.5*n;o=O(E([e.p0,e.cp1,e.cp2,e.p],.5),E([i.p0,i.cp1,i.cp2,i.p],t)),x+=o,x<p&&(c=!0)}}return c&&(i.p0=e.p0,i.p=t.p,i.dimA=O(i.p0,i.p),i.type="C",i.extreme=t.extreme,i.directionChange=t.directionChange,i.corner=t.corner,i.values=[i.cp1.x,i.cp1.y,i.cp2.x,i.cp2.y,i.p.x,i.p.y],i.error=x/p,a=[i]),a}function ne(e,{tolerance:t=1,debug:l=!1}={}){let a=!1,n={flat:!0,steepness:0},r=e[0],s=e[e.length-1],p=new Set([...e.map(e=>+e.x.toFixed(8))]),i=new Set([...e.map(e=>+e.y.toFixed(8))]);if(1===p.size||1===i.size)return!l||n;let u=Z(r,s),y=u/1e3*t,h=Y(e,!0);return h<y&&(a=!0),l&&(n.flat=a,n.steepness=h/u*10),l?n:a}function re(e=[],{detectExtremes:t=!0,detectCorners:a=!0,detectDirection:n=!0,detectSemiExtremes:r=!1,debug:s=!1,addSquareLength:p=!0,addArea:i=!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]},p=s,i=s;r.p0=p,r.p=i,r.idx=0,r.dimA=0;let u=e.length,y=[r];for(let n=1;n<u;n++){let r,u,h=e[n],{type:o,values:c}=h,x=c.length;if(i=x?{x:c[x-2],y:c[x-1]}:s,h.p0=p,h.p=i,h.dimA=O(p,i),"M"===o&&(s=i),"Q"===o||"C"===o)r={x:c[0],y:c[1]},u="C"===o?{x:c[2],y:c[3]}:null,h.cp1=r,u&&(h.cp2=u);else if("A"===o&&a){let{rx:e,ry:t,cx:l,cy:a,startAngle:n,endAngle:r,deltaAngle:s}=P(p.x,p.y,...c);h.cx=l,h.cy=a,h.rx=e,h.ry=t,h.xAxisRotation=c[2]/180*Math.PI,h.largeArc=c[3],h.sweep=c[4],h.startAngle=n,h.endAngle=r,h.deltaAngle=s}if("Z"===o&&s.x!==i.x&&s.y!==i.y&&(h.closePath=!0),t&&(h.squareDist=Z(p,i)),l){let e=0;"C"===o&&(e=Y([p,r,u,i],!1)),"Q"===o&&(e=Y([p,r,i],!1)),h.cptArea=e}h.idx=n,p=i,y.push(h)}return y}(e,{addSquareLength:p,addArea:i});let u=[],y=function(e=[],t=!1,l=-1){let a=[];return e.forEach(e=>{let{type:n,values:r}=e;if(r.length)if(l>-1&&(r=r.map(e=>+e.toFixed(l))),t)for(let e=1;e<r.length;e+=2)a.push({x:r[e-1],y:r[e]});else a.push({x:r[r.length-2],y:r[r.length-1]})}),a}(e),h=V(y),{left:o,right:c,top:x,bottom:f,width:g,height:d}=h;e[0].corner=!1,e[0].extreme=!1,e[0].semiExtreme=!1,e[0].directionChange=!1,e[0].closePath=!1;let v=[e[0]],M=e.length;for(let t=2;M&&t<=M;t++){let l=e[t-1],{type:a,values:n,p0:s,p:p,cp1:i=null,cp2:u=null,squareDist:y=0,cptArea:h=0,dimA:g=0}=l,d=e[t]||null;l.corner=!1,l.extreme=!1,l.semiExtreme=!1,l.directionChange=!1,l.closePath=!1;let M="C"===a||"Q"===a?"C"===a?[s,i,u,p]:[s,i,p]:[s,p],m=.1*g,b=.01*m,A="Q"===a||"C"===a,L=d&&("Q"===d.type||"C"===d.type),w=!1;
1
+ const e=180/Math.PI,t=Math.PI/180;function l(e,t={}){let l=function(e,t={}){let l,a;e=e.trim();let n=+(e.length/1024).toFixed(3),s={totalEls:1,hasEls:!0,hasDefs:!1,geometryEls:[],useEls:0,useElsNested:0,nonsensePaths:0,isSuspicious:!1,isBillionLaugh:!1,hasScripts:!1,hasPrologue:!1,hasEntity:!1,isPathData:!1,fileSizeKB:n,hasXmlns:e.includes("http://www.w3.org/2000/svg"),isSymbolSprite:!1,isSvgFont:e.includes("<glyph>")},r=t.useElsNested?t.useElsNested:2e3;const p=(e,t=2e3)=>{let l=0;for(let n=0;n<e.length&&l<t;n++){let s=e[n],r=s.getAttribute("xlink:href")?s.getAttribute("xlink:href"):s.getAttribute("href");r=r?r.replace("#",""):"",s.setAttribute("href","#"+r);let p=a.getElementById(r).querySelectorAll("use");l+=p.length;for(let e=0;e<p.length&&l<t;e++){let t=p[e].getAttribute("href").replace("#","");l+=a.getElementById(t).querySelectorAll("use").length}}return s.useElsNested=l,l};let i=/\<\!ENTITY/gi.test(e),u=!!/\<script/gi.test(e),h=!!/\<use/gi.test(e),y=/[\<path|\<polygon|\<polyline|\<rect|\<circle|\<ellipse|\<line|\<text|\<foreignObject]/gi.test(e),o=/[\<filter|\<linearGradient|\<radialGradient|\<pattern|\<animate|\<animateMotion|\<animateTransform|\<clipPath|\<mask|\<symbol|\<marker]/gi.test(e),c=(e.startsWith("M")||e.startsWith("m"))&&!/[\<svg|\<\/svg]/gi.test(e);if(s.isPathData=c,!i&&!h&&!u&&(y||o)&&n<t.fileSizeKB)return s.hasEls=y,s.hasDefs=o,s;!1===t.hasEntity&&i&&(s.hasEntity=!0);e=e.replace(/\<\?xml.+\?\>|\<\!DOCTYPE.+]\>/g,"").replace(/(<!--.*?-->)|(<!--[\S\s]+?-->)|(<!--[\S\s]*?$)/g,"");try{l=(new DOMParser).parseFromString(e,"text/html"),a=l.querySelector("svg");let t=a.querySelectorAll('path[d="M0,0"], path[d="M0 0"]').length,n=a.querySelectorAll("use").length;if(s.totalEls=a.querySelectorAll("*").length,s.geometryEls=a.querySelectorAll("path, rect, circle, ellipse, polygon, polyline, line").length,s.hasScripts=u,s.useEls=n,s.nonsensePaths=t,s.isSuspicious=!1,s.isBillionLaugh=!1,s.hasXmlns=!!a.getAttribute("xmlns")&&"http://www.w3.org/2000/svg"===a.getAttribute("xmlns"),s.isSymbolSprite=!(!a.querySelectorAll("symbol").length||0!==a.querySelectorAll("use").length),s.isSvgFont=!!a.querySelectorAll("glyph").length,100/s.totalEls*s.useEls>75){s.isSuspicious=!0,p(a.querySelectorAll("use"),r)>=r&&(s.isBillionLaugh=!0)}return s}catch{return console.warn("svg could not be parsed"),!1}}(e,t={useElsNested:5e3,hasScripts:!1,hasEntity:!1,fileSizeKB:1e4,isSymbolSprite:!1,isSvgFont:!1,...t}),a=!0,n=[];if(l.hasEls||(n.push("no elements"),a=!1),Object.keys(l).length){!0===l.isBillionLaugh&&(n.push("suspicious: might contain billion laugh attack"),a=!1);for(let e in t){let s=t[e],r=l[e];"number"==typeof s&&r>s&&(n.push(`allowed "${e}" exceeded: ${r} / ${s} `),a=!1),!0===r&&!1===s&&(n.push(`not allowed: "${e}" `),a=!1)}}else a=!1;return{isValid:a,log:n,fileReport:l}}function a(e,t,l="red",a="1%",n="1",s="",r=!0,p="",i=""){Array.isArray(t)&&(t={x:t[0],y:t[1]});let u=`<circle class="${i}" opacity="${n}" id="${p}" cx="${t.x}" cy="${t.y}" r="${a}" fill="${l}">\n <title>${s}</title></circle>`;if(!r)return u;e.insertAdjacentHTML("beforeend",u)}const{abs:n,acos:s,asin:r,atan:p,atan2:i,ceil:u,cos:h,exp:y,floor:o,log:c,max:x,min:f,pow:g,random:d,round:m,sin:v,sqrt:M,tan:b,PI:A}=Math;function C(e,t,l=!1){let a=i(t.y-e.y,t.x-e.x);return l&&a<0&&(a+=2*Math.PI),a}function S(e,t,l,a=!1){let n=Math.atan2(t.y-e.y,t.x-e.x),s=Math.atan2(l.y-e.y,l.x-e.x),r=s-n;r=(e=>{let t=e%(2*Math.PI);return t>Math.PI?t-=2*Math.PI:t<=-Math.PI&&(t+=2*Math.PI),t})(r),a&&(r=2*Math.PI-Math.abs(r));let p=180/Math.PI;return{startAngle:n,endAngle:s,deltaAngle:r,startAngleDeg:n*p,endAngleDeg:s*p,deltaAngleDeg:r*p}}function w(e=null,t=null,l=null,a=null,n=!0,s=!1,r=!1){let p,i,u,h,y,o={};if(!(e&&t&&l&&a))return r&&console.warn("points missing"),!1;if(e.x===t.x&&e.y===t.y||l.x===a.x&&l.y===a.y)return!1;try{if(p=(a.y-l.y)*(t.x-e.x)-(a.x-l.x)*(t.y-e.y),0===p)return!1}catch{return r&&console.warn("!catch",e,t,"p3:",l,"p4:",a),!1}i=e.y-l.y,u=e.x-l.x,h=(a.x-l.x)*i-(a.y-l.y)*u,y=(t.x-e.x)*i-(t.y-e.y)*u,i=h/p,u=y/p,o={x:e.x+i*(t.x-e.x),y:e.y+i*(t.y-e.y)};let c=!1;return i>0&&i<1&&u>0&&u<1&&(c=!0),!n&&s&&(i>0&&u<0||i<0&&u>0)?(c=!1,!1):!(n&&!c)&&o}function E(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=C(e,t),n.angle<0&&(n.angle+=2*A)),n}function L(e,t=.5,l=!1,a=!1,n=!1){let s;return Array.isArray(e[0])&&(e=e.map(e=>({x:e[0],y:e[1]})),n=!0),s=e.length>2?((e,t,l=!1)=>{let n=4===e.length,s=e[0],r=e[1],p=n?e[2]:e[1],i=e[e.length-1],u={x:0,y:0};if(l||a){let e,l,h,y,o,c=s.x===r.x&&s.y===r.y,x=i.x===p.x&&i.y===p.y;0!==t||c?1!==t||x?(c&&(t+=1e-7),x&&(t-=1e-7),e=E(s,r,t),n?(l=E(r,p,t),h=E(p,i,t),y=E(e,l,t),o=E(l,h,t),u=E(y,o,t),u.angle=C(y,o),a&&(u.cpts=[l,h,y,o])):(l=E(s,r,t),h=E(r,i,t),u=E(l,h,t),u.angle=C(l,h),a&&(u.cpts=[l,h]))):(u.x=i.x,u.y=i.y,u.angle=C(p,i)):(u.x=s.x,u.y=s.y,u.angle=C(s,r))}else{let e=1-t;u=n?{x:e*e*e*s.x+3*e*e*t*r.x+3*e*t*t*p.x+t*t*t*i.x,y:e*e*e*s.y+3*e*e*t*r.y+3*e*t*t*p.y+t*t*t*i.y}:{x:e*e*s.x+2*e*t*r.x+t*t*i.x,y:e*e*s.y+2*e*t*r.y+t*t*i.y}}return u})(e,t,l):E(e[0],e[1],t,l),l&&s.angle<0&&(s.angle+=2*A),n?[s.x,s.y]:s}function P(l,a,n,s,r,p,i,u,h,y=!0){const o=(e,t,l,a,n=!0)=>{let s=Math.atan2(a-t,l-e);return n&&s<0&&(s+=2*Math.PI),s};let c={cx:0,cy:0,rx:n=Math.abs(n),ry:s=Math.abs(s),startAngle:0,endAngle:0,deltaAngle:0,clockwise:i,xAxisRotation:r=n===s?0:r<0&&y?r+360:r,largeArc:p,sweep:i};if(0==n||0==s)throw Error("rx and ry can not be 0");let x,f,g=n===s?0:r*t,d=g?Math.sin(g):0,m=g?Math.cos(g):1,v=(l-u)/2,M=(a-h)/2,b=(l+u)/2,A=(a+h)/2,C=g?m*v+d*M:v,S=g?m*M-d*v:M,w=C*C/(n*n)+S*S/(s*s);if(w>1){let e=Math.sqrt(w);n*=e,s*=e,c.rx=n,c.ry=s}let E=n*s,L=n*S,P=s*C,T=L**2+P**2;if(!T)throw Error("start point can not be same as end point");let I=Math.sqrt(Math.abs((E*E-T)/T));p===i&&(I=-I);let D=I*L/s,k=-I*P/n;x=g?m*D-d*k+b:b+D,f=g?d*D+m*k+A:A+k,c.cy=f,c.cx=x;let q=o(x,f,l,a,y),Q=o(x,f,u,h,y);i?Q<q&&(Q+=2*Math.PI):Q>q&&(Q-=2*Math.PI);let z=Q-q;return c.startAngle=q,c.startAngle_deg=q*e,c.endAngle=Q,c.endAngle_deg=Q*e,c.deltaAngle=z,c.deltaAngle_deg=z*e,c}function T(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 I(e,t,l,a,n,s=0,r=!0,i=!1){if(n=i?n*A/180:n,s=i?s*A/180:s,s=l!==a&&s!==2*A?s:0,r&&l!==a){let e=p(b(n=s?n-s:n)*(l/a));n=h(n)<0?e+A:e}let u=e+l*h(n),y=t+a*v(n),o={x:u,y:y};return s&&(o.x=e+(u-e)*h(s)-(y-t)*v(s),o.y=t+(u-e)*v(s)+(y-t)*h(s)),o}function D(e,t,l){if(t===l||e%A*.5==0)return e;let a=p(b(e)*(t/l));return a=h(e)<0?a+A: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],s=3===l?t[1]:n,r=Math.min(e.y,a.y),p=Math.min(e.x,a.x),i=Math.max(e.x,a.x),u=Math.max(e.y,a.y);return!(n.y>=r&&n.y<=u&&s.y>=r&&s.y<=u&&n.x>=p&&n.x<=i&&s.x>=p&&s.x<=i)}function q(e,{addExtremes:t=!0,addSemiExtremes:l=!1}={}){let a=4===e.length?function(e,t,l,a,{addExtremes:n=!0,addSemiExtremes:s=!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}};s&&(e=r(e),t=r(t),l=r(l),a=r(a));let[p,i,u,h,y,o,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),m=Math.max(e.y,a.y);if(t.y>=f&&t.y<=m&&l.y>=f&&l.y<=m&&t.x>=g&&t.x<=d&&l.x>=g&&l.x<=d)return[];let v,M,b,A,C,S,w,E,L=[];for(let e=0;e<2;++e)if(0==e?(M=6*p-12*u+6*y,v=-3*p+9*u-9*y+3*c,b=3*u-3*p):(M=6*i-12*h+6*o,v=-3*i+9*h-9*o+3*x,b=3*h-3*i),Math.abs(v)<1e-8){if(Math.abs(M)<1e-8)continue;A=-b/M,0<A&&A<1&&L.push(A)}else w=M*M-4*b*v,w<0?Math.abs(w)<1e-8&&(A=-M/(2*v),0<A&&A<1&&L.push(A)):(E=Math.sqrt(w),C=(-M+E)/(2*v),0<C&&C<1&&L.push(C),S=(-M-E)/(2*v),0<S&&S<1&&L.push(S));let P=L.length;for(;P--;)A=L[P];return L}(e[0],e[1],e[2],e[3],{addExtremes:t,addSemiExtremes:l}):function(e,t,l,{addExtremes:a=!0,addSemiExtremes:n=!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}};n&&(e=s(e),t=s(t),l=s(l));let r,p,i,u=Math.min(e.y,l.y),h=Math.min(e.x,l.x),y=Math.max(e.x,l.x),o=Math.max(e.y,l.y);if(t.y>=u&&t.y<=o&&t.x>=h&&t.x<=y)return[];let[c,x,f,g,d,m]=[e.x,e.y,t.x,t.y,l.x,l.y],v=[];for(let e=0;e<2;++e)r=0==e?c-2*f+d:x-2*g+m,p=0==e?-2*c+2*f:-2*x+2*g,Math.abs(r)>1e-12&&(i=-p/(2*r),i>0&&i<1&&v.push(i));return v}(e[0],e[1],e[2],{addExtremes:t,addSemiExtremes:l});return a}function Q(e,t){const l=(e,t,l,a,n,s)=>{var r=Math.cos(s),p=Math.sin(s),i=a*Math.cos(e),u=n*Math.sin(e);return{x:t+r*i-p*u,y:l+p*i+r*u}};let a,n,s,r,p,i=P(e.x,e.y,t[0],t[1],t[2],t[3],t[4],t[5],t[6]),{rx:u,ry:h,cx:y,cy:o,endAngle:c,deltaAngle:x}=i,f=t[2],g={x:t[5],y:t[6]},d=[g],m=f*Math.PI/180,v=Math.tan(m);p=Math.atan2(-h*v,u);let M=p,b=p+Math.PI,A=Math.atan2(h,u*v),C=A+Math.PI,S=[e.x,g.x],w=[e.y,g.y],E=Math.min(...S),L=Math.max(...S),T=Math.min(...w),I=Math.max(...w),D=l(c-.001*x,y,o,u,h,m),k=l(c-.999*x,y,o,u,h,m);return(D.x>L||k.x>L)&&(a=l(M,y,o,u,h,m),d.push(a)),(D.x<E||k.x<E)&&(n=l(b,y,o,u,h,m),d.push(n)),(D.y<T||k.y<T)&&(r=l(C,y,o,u,h,m),d.push(r)),(D.y>I||k.y>I)&&(s=l(A,y,o,u,h,m),d.push(s)),d}function z(e=[],t=[]){let l=e.length,a=4===l;t.length||(t=[0]);let n=t.length,s=[];for(let r=0;r<n;r++){let n=t[r],p=n?[]:e.slice(0);if(n)for(let t=0;t<l;t++){let l=e[t];p.push(T(l,0,0,n))}let i=a?$(...p):F(...p);s.push(...i)}return s=[...new Set(s)].sort(),s}function $(e,t,l,a){if(!k(e,[t,l,a]))return[];let n,s,r,p,i,u,h,y,[o,c,x,f,g,d,m,v]=[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?(s=6*o-12*x+6*g,n=-3*o+9*x-9*g+3*m,r=3*x-3*o):(s=6*c-12*f+6*d,n=-3*c+9*f-9*d+3*v,r=3*f-3*c),Math.abs(n)<b){if(Math.abs(s)<b)continue;p=-r/s,p>0&&p<1&&M.push(p)}else h=s*s-4*r*n,h<0?Math.abs(h)<b&&(p=-s/(2*n),p>0&&p<1&&M.push(p)):(y=Math.sqrt(h),i=(-s+y)/(2*n),i>0&&i<1&&M.push(i),u=(-s-y)/(2*n),u>0&&u<1&&M.push(u));let A=M.length;for(;A--;)p=M[A];return[...new Set(M)].sort()}function F(e,t,l){if(!k(e,[t,l]))return[];let a,n,s,[r,p,i,u,h,y]=[e.x,e.y,t.x,t.y,l.x,l.y],o=[];for(let e=0;e<2;++e)a=0==e?r-2*i+h:p-2*u+y,n=0==e?-2*r+2*i:-2*p+2*u,Math.abs(a)>1e-12&&(s=-n/(2*a),s>0&&s<1&&o.push(s));return[...new Set(o)].sort()}function j(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 B(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 Math.sqrt(a*a+n*n)}function R(e,t){let l=t.x-e.x,a=t.y-e.y;return l*l+a*a}function O(e,t){return Math.abs(t.x-e.x)+Math.abs(t.y-e.y)}function N(e,t){return.5*(Math.abs(t.x-e.x)+Math.abs(t.y-e.y))}function Z(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 W(e,t){let l,a,n,s,r,p,i=[],u=[],h=e[0],y=e[1],o=e[e.length-2],c=e[e.length-1];return 4===e.length?(l=L([h,y],t),a=L([y,o],t),n=L([o,c],t),s=L([l,a],t),r=L([a,n],t),p=L([s,r],t),i.push({x:h.x,y:h.y},{x:l.x,y:l.y},{x:s.x,y:s.y},{x:p.x,y:p.y}),u.push({x:p.x,y:p.y},{x:r.x,y:r.y},{x:n.x,y:n.y},{x:c.x,y:c.y})):3===e.length?(a=L([h,y],t),n=L([y,c],t),p=L([a,n],t),i.push({x:h.x,y:h.y},{x:a.x,y:a.y},{x:p.x,y:p.y}),u.push({x:p.x,y:p.y},{x:n.x,y:n.y},{x:c.x,y:c.y})):2===e.length&&(a=L([h,c],t),i.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})),[i,u]}function J(e,t,{tMin:l=0,tMax:a=1,addExtremes:n=!0,addSemiExtremes:s=!1}={}){let r=[],p=6===t.length?"C":"Q",i={x:t[0],y:t[1]},u="C"===p?{x:t[2],y:t[3]}:i,h={x:t[4],y:t[5]},y=0;let o="C"===p?[e,i,u,h]:[e,i,h],c=n?q(o,{addExtremes:n,addSemiExtremes:!1}):[],x=s?q(o,{addExtremes:n,addSemiExtremes:s}):[],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 s,r,p,i=t.length,u={x:t[i-2],y:t[i-1]};2===t.length?p=[e,u]:4===t.length?(s={x:t[0],y:t[1]},p=[e,s,u]):6===t.length&&(s={x:t[0],y:t[1]},r={x:t[2],y:t[3]},p=[e,s,r,u]);if(l.length)if(1===l.length){let e=W(p,l[0]),t=e[0],a=e[1];n.push(t,a)}else{let e=l[0],t=W(p,e),a=t[0];n.push(a),p=t[1];for(let t=1;t<l.length;t++){e=l[t-1];let a=W(p,(l[t]-e)/(1-e));n.push(a[0]),t===l.length-1&&n.push(a[a.length-1]),p=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);r.push(...l),y+=l.length}else r.push({type:p,values:t});return{pathData:r,count:y}}function V(e,{tMin:t=0,tMax:l=1,addExtremes:a=!0,addSemiExtremes:n=!1}={}){let s=[e[0]],r={x:e[0].values[0],y:e[0].values[1]},p={x:e[0].values[0],y:e[0].values[1]},i=e.length;for(let u=1;i&&u<i;u++){let i=e[u],{type:h,values:y}=i,o=y.slice(-2);if(o[0],o[1],"C"!==h&&"Q"!==h)s.push(i);else if((a||n)&&("C"===h||"Q"===h)){let e=J(r,y,{tMin:t,tMax:l,addExtremes:a,addSemiExtremes:n}).pathData;s.push(...e)}r={x:o[0],y:o[1]},"z"===h.toLowerCase()?r=p:"M"===h&&(p={x:o[0],y:o[1]})}return s}function H(e,t=-1){if(t<0)return e;let l=e.length,a=t,n=a<3?a+2:a;for(let t=0;t<l;t++){let l=e[t],{type:s,values:r}=l,p=r.length;if(!p)continue;let i="a"===s.toLowerCase();for(let l=0;l<p;l++)e[t].values[l]=K(r[l],i&&l<2?n:a)}return e}function K(e=0,t=3){if(t<0)return e;if(!t)return Math.round(e);let l=Math.floor(t);if(l!==t){let a=+(t-l).toFixed(2);a=a>.5?.5*Math.floor(a/.5):a;let n=10**-l*a;return+(Math.round(e/n)*n).toFixed(8)}let a=10**t;return Math.round(e*a)/a}function _(e,t=-1){let l=e.map(e=>e.x),a=e.map(e=>e.y),n=Math.min(...l),s=Math.max(...l),r=Math.min(...a),p=Math.max(...a),i={x:n,left:n,right:s,y:r,top:r,bottom:p,width:s-n,height:p-r};if(t>-1)for(let e in i)i[e]=+i[e].toFixed(t);return i}function G(e){let t=[];return e.forEach(e=>{let l=function(e){let t=function(e){let t=[];for(let l=0;l<e.length;l++){let a=e[l],n=l>0?e[l-1]:e[l],{type:s,values:r}=a,p={x:n.values[n.values.length-2],y:n.values[n.values.length-1]},i=r.length?{x:r[r.length-2],y:r[r.length-1]}:"",u=r.length?{x:r[0],y:r[1]}:"";switch(s){case"A":if("function"!=typeof arcToBezier){let e=B(p,i)/2,l=E(p,i,.5),a=I(l.x,l.y,e,e,0),n=I(l.x,l.y,e,e,Math.PI);t.push(a,n,i);break}arcToBezier(p,r).forEach(e=>{let l=e.values,a={x:l[0],y:l[1]},n={x:l[2],y:l[3]},s={x:l[4],y:l[5]};t.push(a,n,s)});break;case"C":let e={x:r[2],y:r[3]};t.push(u,e);break;case"Q":t.push(u)}"z"!==s.toLowerCase()&&t.push(i)}return t}(e),l=_(t);return l}(e);t.push(l)}),t}function U(e,t){let[l,a,n,s,r,p]=[e.x,e.y,e.width,e.height,e.x+e.width,e.y+e.height],[i,u,h,y,o,c]=[t.x,t.y,t.width,t.height,t.x+t.width,t.y+t.height],x=!1;return n*s!=h*y&&n*s>h*y&&l<i&&r>o&&a<u&&p>c&&(x=!0),x}function X(e,t=9){let l=0,a=[],n=Z(e),s=n.length>1,r=[];if(s){let e=G(n);e.forEach(function(t,l){for(let l=0;l<e.length;l++){let a=e[l];if(t!=a){U(t,a)&&r.push(l)}}})}return n.forEach((e,t)=>{a=[];let n=0,s=0,p=1,i=[];e.forEach(function(t,l){let[s,r]=[t.type,t.values],p=r.length;if(r.length){let u=(l>0?e[l-1]:e[0]).values,h=u.length,y={x:u[h-2],y:u[h-1]},o={x:r[p-2],y:r[p-1]};if("C"===s||"Q"===s){let e={x:r[0],y:r[1]};i="C"===s?[y,e,{x:r[2],y:r[3]},o]:[y,e,o];let t=Math.abs(function(e,t=!1){let l,[a,n,s,r]=[e[0],e[1],e[2],e[e.length-1]];if(e.length<3)return 0;3===e.length&&(n={x:1*e[0].x/3+2*e[1].x/3,y:1*e[0].y/3+2*e[1].y/3},s={x:1*e[2].x/3+2*e[1].x/3,y:1*e[2].y/3+2*e[1].y/3});return l=3*(a.x*(-2*n.y-s.y+3*r.y)+n.x*(2*a.y-s.y-r.y)+s.x*(a.y+n.y-2*r.y)+r.x*(-3*a.y+n.y+2*s.y))/20,t?Math.abs(l):l}(i));n+=t,a.push(y,o)}else if("A"===s){let e=P(y.x,y.y,t.values[0],t.values[1],t.values[2],t.values[3],t.values[4],o.x,o.y),{cx:l,cy:s,rx:r,ry:p,startAngle:i,endAngle:u,deltaAngle:h}=e,c=Math.abs(function(e,t,l,a){const n=Math.PI*e*t;let s=(a-l+2*Math.PI)%(2*Math.PI);if(e===t)return n*(s/(2*Math.PI));const r=l=>Math.atan2(e*Math.sin(l),t*Math.cos(l));return l=r(l),a=r(a),s=(a-l+2*Math.PI)%(2*Math.PI),n*(s/(2*Math.PI))}(r,p,i,u));c-=Math.abs(Y([y,{x:l,y:s},o])),a.push(y,o),n+=c}else a.push(y,o)}});let u=Y(a);-1!==r.indexOf(t)&&(p=-1),s=u<0&&n<0?(Math.abs(n)-Math.abs(u))*p:(Math.abs(n)+Math.abs(u))*p,l+=s}),l}function Y(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 ee(e,t=0){t=parseFloat(t);let l=e.length,a=e[0].values.join(" "),n=t>1?"\n":t<1?"":" ",s=t>.5?" ":"",r=`${e[0].type}${s}${a}${n}`;for(let p=1;p<l;p++){let i=e[p-1],u=e[p],{type:h,values:y}=u;if(a="",t||"A"!==h&&"a"!==h||(y=[y[0],y[1],y[2],`${y[3]}${y[4]}${y[5]}`,y[6]]),h=t<1&&i.type===u.type&&"m"!==u.type.toLowerCase()||t<1&&"M"===i.type&&"L"===u.type?" ":u.type,t)a=y.join(" ");else{let e=!1;for(let t=0,l=y.length;t<l;t++){let l=y[t],n=l.toString(),s=n.includes(".")&&Math.abs(l)<1;s&&e&&(n=n.replace(/^0\./,".")),!(t>0)||e&&s||(a+=" "),a+=n,e=s}}p===l-1&&(n=""),r+=`${h}${s}${a}${n}`}return t<1&&(r=r.replace(/[A-Za-z]0(?=\.)/g,e=>e[0]).replace(/ 0\./g," .").replace(/ -/g,"-").replace(/-0\./g,"-.").replace(/Z/g,"z")),r}function te(e,t,l=0,a=1,n=!1){const s=(e,t,l,a,n)=>{let s=1-n;return{x:3*s*s*(t.x-e.x)+6*s*n*(l.x-t.x)+3*n*n*(a.x-l.x),y:3*s*s*(t.y-e.y)+6*s*n*(l.y-t.y)+3*n*n*(a.y-l.y)}};let r=[e,t],p=N(e.p0,e.p)>N(t.p0,t.p),i=JSON.parse(JSON.stringify(e)),u=JSON.parse(JSON.stringify(t)),h=w(i.p0,i.cp1,u.p,u.cp2,!1);if(!h)return r;if(p){let l={p0:{x:e.p.x,y:e.p.y},cp1:{x:e.cp2.x,y:e.cp2.y},cp2:{x:e.cp1.x,y:e.cp1.y},p:{x:e.p0.x,y:e.p0.y}};e={p0:{x:t.p.x,y:t.p.y},cp1:{x:t.cp2.x,y:t.cp2.y},cp2:{x:t.cp1.x,y:t.cp1.y},p:{x:t.p0.x,y:t.p0.y}},t=l}let y=(e,t)=>({x:e.x-t.x,y:e.y-t.y}),o=(e,t)=>({x:e.x*t,y:e.y*t}),c=(e,t)=>e.x*t.x+e.y*t.y,x=t.p0,f=s(t.p0,t.cp1,t.cp2,t.p,0),g=c(y(e.p0,x),f)/c(f,f),d=L([t.p0,t.cp1,t.cp2,t.p],g),m=s(t.p0,t.cp1,t.cp2,t.p,g);g-=c(y(d,e.p0),m)/c(m,m);let v=L([t.p0,t.cp1,t.cp2,t.p],g),M=t.p,b=s(t.p0,t.cp1,t.cp2,t.p,g),A=s(t.p0,t.cp1,t.cp2,t.p,1),C=1-g,S=(P=v,T=o(b,C/3),{x:P.x+T.x,y:P.y+T.y});var P,T;let I=y(M,o(A,C/3)),D={p0:v,cp1:S,cp2:I,p:M,t0:g};p&&(D={p0:M,cp1:I,cp2:S,p:v,t0:g});let k=.5*(1-g),q=L([D.p0,D.cp1,D.cp2,D.p],k,!1,!0),Q=q.cpts[2],z=w(q,Q,D.p0,h,!1),$=w(q,Q,D.p,h,!1),F=E(D.p0,z,1.333),j=E(D.p,$,1.333);if(w(i.p0,F,u.p,j,!0))return r;D.cp1=F,D.cp2=j;let B=N(i.p0,D.p0)+N(u.p,D.p);if(D.p0=i.p0,D.p=u.p,D.extreme=u.extreme,D.corner=u.corner,D.dimA=u.dimA,D.directionChange=u.directionChange,D.type="C",D.values=[D.cp1.x,D.cp1.y,D.cp2.x,D.cp2.y,D.p.x,D.p.y],B<l){let t=p?1+g:Math.abs(g),s=1+Math.abs(g);if(t=p?1+g:Math.abs(g)/s,N(L([D.p0,D.cp1,D.cp2,D.p],t),e.p)>l*a)return r;let h=X([{type:"M",values:[i.p0.x,i.p0.y]},{type:"C",values:[i.cp1.x,i.cp1.y,i.cp2.x,i.cp2.y,i.p.x,i.p.y]},{type:"C",values:[u.cp1.x,u.cp1.y,u.cp2.x,u.cp2.y,u.p.x,u.p.y]}]),y=[{type:"M",values:[D.p0.x,D.p0.y]},{type:"C",values:[D.cp1.x,D.cp1.y,D.cp2.x,D.cp2.y,D.p.x,D.p.y]}],o=X(y),c=Math.abs(o/h-1);D.error=5*c*a,n&&ee(y),c<.05*a&&(r=[D])}return r}function le(e,{keepExtremes:t=!0,keepInflections:l=!0,keepCorners:a=!0,extrapolateDominant:n=!0,tolerance:s=1}={}){let r=[e[0]],p=e.length;for(let n=2;p&&n<=p;n++){let i=e[n-1],u=n<p?e[n]:null,h=u?.type||null,{type:y,values:o,p0:c,p:x,cp1:f=null,cp2:g=null,extreme:d=!1,directionChange:m=!1,corner:v=!1,dimA:M=0}=i;if("C"===y&&"C"===h)if(a&&v||t&&d)r.push(i);else{let h=ae(i,u,{tolerance:s}),y=0;if(1===h.length){i=h[0];let u=1;y+=i.error;for(let r=n+u;y<s&&r<p;r++){let n=e[r];if("C"!==n.type||l&&i.directionChange||a&&i.corner||t&&i.extreme)break;let p=ae(i,n,{tolerance:s});if(p.length>1)break;y+=.5*p[0].error,u++,i=p[0]}r.push(i),n<p&&(n+=u)}else r.push(i)}else r.push(i)}return r}function ae(e,t,{tolerance:l=1}={}){let a=[e,t],n=function(e,t){let l=O(e.cp2,e.p);if(0===l)return 0;let a=O(e.p,t.cp1);if(0===a)return 0;let n=O(e.cp2,t.cp1);return l/n}(e,t);if(!n)return a;let s=O(e.p0,e.p),r=O(t.p0,t.p),p=.08*Math.max(0,Math.min(s,r))*l,i=function(e,t,l=0){let{p0:a,cp1:n}=e,{p:s,cp2:r}=t;return n={x:(n.x-(1-l)*a.x)/l,y:(n.y-(1-l)*a.y)/l},r={x:(r.x-l*s.x)/(1-l),y:(r.y-l*s.y)/(1-l)},{p0:a,cp1:n,cp2:r,p:s}}(e,t,n),u=L([i.p0,i.cp1,i.cp2,i.p],n),h=O(e.p,u),y=0,o=0,c=!1,x=h;if(h<p){let l=.5*n;if(y=O(L([e.p0,e.cp1,e.cp2,e.p],.5),L([i.p0,i.cp1,i.cp2,i.p],l)),x+=y,y<p){let e=.5*(1+n);o=O(L([t.p0,t.cp1,t.cp2,t.p],.5),L([i.p0,i.cp1,i.cp2,i.p],e)),x+=o,x<p&&(c=!0)}}return c&&(i.p0=e.p0,i.p=t.p,i.dimA=O(i.p0,i.p),i.type="C",i.extreme=t.extreme,i.directionChange=t.directionChange,i.corner=t.corner,i.extreme||i.corner,i.values=[i.cp1.x,i.cp1.y,i.cp2.x,i.cp2.y,i.p.x,i.p.y],i.error=x/p,a=[i]),a}function ne(e,{tolerance:t=1,debug:l=!1}={}){let a=!1,n={flat:!0,steepness:0},s=e[0],r=e[e.length-1],p=new Set([...e.map(e=>+e.x.toFixed(8))]),i=new Set([...e.map(e=>+e.y.toFixed(8))]);if(1===p.size||1===i.size)return!l||n;let u=R(s,r),h=u/1e3*t,y=Y(e,!0);return y<h&&(a=!0),l&&(n.flat=a,n.steepness=y/u*10),l?n:a}function se(e=[],{detectExtremes:t=!0,detectCorners:l=!0,detectDirection:n=!0,detectSemiExtremes:s=!1,debug:r=!1,addSquareLength:p=!0,addArea:i=!0}={}){e=function(e,{addSquareLength:t=!0,addArea:l=!1,addArcParams:a=!1,addAverageDim:n=!0}={}){let s=e[0],r={x:s.values[0],y:s.values[1]},p=r,i=r;s.p0=p,s.p=i,s.idx=0,s.dimA=0;let u=e.length,h=[s];for(let n=1;n<u;n++){let s,u,y=e[n],{type:o,values:c}=y,x=c.length;if(i=x?{x:c[x-2],y:c[x-1]}:r,y.p0=p,y.p=i,y.dimA=O(p,i),"M"===o&&(r=i),"Q"===o||"C"===o)s={x:c[0],y:c[1]},u="C"===o?{x:c[2],y:c[3]}:null,y.cp1=s,u&&(y.cp2=u);else if("A"===o&&a){let{rx:e,ry:t,cx:l,cy:a,startAngle:n,endAngle:s,deltaAngle:r}=P(p.x,p.y,...c);y.cx=l,y.cy=a,y.rx=e,y.ry=t,y.xAxisRotation=c[2]/180*Math.PI,y.largeArc=c[3],y.sweep=c[4],y.startAngle=n,y.endAngle=s,y.deltaAngle=r}if("Z"===o&&r.x!==i.x&&r.y!==i.y&&(y.closePath=!0),t&&(y.squareDist=R(p,i)),l){let e=0;"C"===o&&(e=Y([p,s,u,i],!1)),"Q"===o&&(e=Y([p,s,i],!1)),y.cptArea=e}y.idx=n,p=i,h.push(y)}return h}(e,{addSquareLength:p,addArea:i});let u=[],h=function(e=[],t=!1,l=-1){let a=[];return e.forEach(e=>{let{type:n,values:s}=e;if(s.length)if(l>-1&&(s=s.map(e=>+e.toFixed(l))),t)for(let e=1;e<s.length;e+=2)a.push({x:s[e-1],y:s[e]});else a.push({x:s[s.length-2],y:s[s.length-1]})}),a}(e),y=_(h),{left:o,right:c,top:x,bottom:f,width:g,height:d}=y;e[0].corner=!1,e[0].extreme=!1,e[0].semiExtreme=!1,e[0].directionChange=!1,e[0].closePath=!1;let m=[e[0]],v=e.length;for(let t=2;v&&t<=v;t++){let l=e[t-1],{type:a,values:n,p0:r,p:p,cp1:i=null,cp2:u=null,squareDist:h=0,cptArea:y=0,dimA:g=0}=l,d=e[t-2],v=e[t]||null;l.corner=!1,l.extreme=!1,l.semiExtreme=!1,l.directionChange=!1,l.closePath=!1;let M="C"===a||"Q"===a?"C"===a?[r,i,u,p]:[r,i,p]:[r,p],b=.1*g,A=.01*b,S="Q"===a||"C"===a,w="A"===a,E=v&&("Q"===v.type||"C"===v.type),L=!1;
2
2
  //!isFlat &&
3
- if(A){let e="C"===a?Math.abs(l.cp2.x-l.p.x):Math.abs(l.cp1.x-l.p.x),t="C"===a?Math.abs(l.cp2.y-l.p.y):Math.abs(l.cp1.y-l.p.y);if(((0===t||t<=b)&&e>0||(0===e||e<=b)&&t>0)&&(w=!0),(i.x===s.x&&i.y!==s.y||i.y===s.y&&i.x!==s.x)&&(v[v.length-1].extreme=!0),p.x!==o&&p.y!==x&&p.x!==c&&p.y!==f||(w=!0),!w){if(Q(null,M)){let e=T(M);e.length&&e[0]>.2&&(w=!0)}}}if(w&&(l.extreme=!0),A&&L){if(r&&!l.extreme){let e=Math.abs(p.x-u.x),t=Math.abs(p.y-u.y),a=!1;if(e&&t&&e>m||t>m){let e=C(u,p),t=C(p,d.cp1);a=j(Math.abs(e+t)/2)}a&&(l.semiExtreme=!0)}if((l.cptArea<0&&d.cptArea>0||l.cptArea>0&&d.cptArea<0)&&(l.directionChange=!0),!l.extreme){let e=u||i,t=d.cp1,a=Y([e,p,t],!1),n=.01*Z(e,t),r=Math.abs(a)<n,s=a<0&&l.cptArea>0||a>0&&l.cptArea<0;!r&&s&&(l.corner=!0)}}v.push(l)}return s&&v.forEach(e=>{e.directionChange&&l(markers,e.p,"orange","1.5%","0.5"),e.corner&&l(markers,e.p,"magenta","1.5%","0.5"),e.extreme&&l(markers,e.p,"cyan","1%","0.5")}),u={pathData:v,bb:h,dimA:(g+d)/2},u}const se=new Set([77,109,65,97,67,99,76,108,81,113,83,115,84,116,72,104,86,118,90,122]),pe=new Uint8Array(128);pe[77]=2,pe[109]=2,pe[65]=7,pe[97]=7,pe[67]=6,pe[99]=6,pe[76]=2,pe[108]=2,pe[81]=4,pe[113]=4,pe[83]=4,pe[115]=4,pe[84]=2,pe[116]=2,pe[72]=1,pe[104]=1,pe[86]=1,pe[118]=1,pe[90]=0,pe[122]=0;const ie=new Set([5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279]),ue=e=>32===e||44===e||10===e||13===e||8232===e||8233===e||9===e||11===e||12===e||160===e||e>=5760&&ie.has(e);function ye(e,{toAbsolute:t=!0,toLonghands:l=!0,quadraticToCubic:a=!1,arcToCubic:n=!1,arcAccuracy:r=4}={}){let s=Array.isArray(e),p=s&&"object"==typeof e[0]&&"function"==typeof e[0].constructor,i=s?e:function(e,t=!0,l=0){if(!e)return[];e=e.trim(),l&&console.log("!!!limit",l);let a={pathData:[],hasRelatives:!1,hasShorthands:!1,hasArcs:!1,hasQuadratics:!1,isPolygon:!1,log:[]};if(""===e)return a;let n,r=0,s=e.length,p="",i=-1,u="",y=!1,h=0,o=0,c=0,x=!1,f=new Set([]);const g=()=>{x&&("M"===p?p="L":"m"===p&&(p="l"),a.pathData.push({type:p,values:[]}),i++,o=0,x=!1)},d=(e=!1)=>{(e?h>0:""!==u)&&(t&&-1===i&&(n="Pathdata must start with M command",a.log.push(n),p="M",a.pathData.push({type:p,values:[]}),c=2,o=0,i++),"A"===p||"a"===p?(({val:u,valueIndex:o}=((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}})(u,o)),a.pathData[i].values.push(...u)):(t&&u[1]&&"."!==u[1]&&"0"===u[0]&&(n=`${i}. command: Leading zeros not valid: ${u}`,a.log.push(n)),a.pathData[i].values.push(+u)),o++,u="",h=0,x=o>=c)},v=()=>{if(i>0){let e=a.pathData[i].values.length;(e&&e<c||e&&e>c||("z"===p||"Z"===p)&&e>0)&&(n=`${i}. command of type "${p}": ${c-e} values too few - ${c} expected`,a.log[a.log.length-1]!==n&&a.log.push(n))}};let M=!1,m=!1,b=!1,A="";for(;r<s;){A=e.charCodeAt(r);let l=A>47&&A<58;if(l||(M=101===A||69===A,m=45===A||43===A,b=46===A),l||m||b||M){if(y||45!==A&&46!==A)g();else{let e=46===A;d(e),g(),e&&h++}u+=e[r],y=M,r++}else if((A<48||A>5759)&&ue(A))d(),r++;else{if(A>64){if(!se.has(A)){n=`${i}. command "${e[r]}" is not a valid type`,a.log.push(n),r++;continue}""!==u&&(a.pathData[i].values.push(+u),o++,u=""),t&&v(),p=e[r],c=pe[A];let l="M"===p||"m"===p,s=i>0&&("z"===a.pathData[i].type||"Z"===a.pathData[i].type);f.add(p),s&&!l&&(a.pathData.push({type:"m",values:[0,0]}),i++),a.pathData.push({type:p,values:[]}),i++,h=0,o=0,x=!1,r++;continue}l||(n=`${i}. ${e[r]} is not a valid separarator or token`,a.log.push(n),u=""),r++}}d(),t&&v(),t&&a.log.length&&(n="Invalid path data:\n"+a.log.join("\n"),"log"===t||console.warn(n)),a.pathData[0].type="M";let C=Array.from(f).join("");return a.hasRelatives=/[lcqamtsvh]/g.test(C),a.hasShorthands=/[vhst]/gi.test(C),a.hasArcs=/[a]/gi.test(C),a.hasQuadratics=/[qt]/gi.test(C),a.isPolygon=!/[cqats]/gi.test(C),a}(e),{hasRelatives:u=!0,hasShorthands:y=!0,hasQuadratics:h=!0,hasArcs:o=!0}=i,c=p?i:i.pathData;return c=function(e=[],{toAbsolute:t=!0,toLonghands:l=!0,quadraticToCubic:a=!1,arcToCubic:n=!1,arcAccuracy:r=2,hasRelatives:s=!0,hasShorthands:p=!0,hasQuadratics:i=!0,hasArcs:u=!0,testTypes:y=!1}={}){return he(e,{toAbsolute:t,toLonghands:l,quadraticToCubic:a,arcToCubic:n,arcAccuracy:r,hasRelatives:s,hasShorthands:p,hasQuadratics:i,hasArcs:u,testTypes:y,decimals:-1})}(c,{toAbsolute:t,toLonghands:l,quadraticToCubic:a,arcToCubic:n,arcAccuracy:r,hasRelatives:u,hasShorthands:y,hasQuadratics:h,hasArcs:o}),c}function he(e,{toShorthands:t=!0,toLonghands:l=!1,toRelative:a=!0,toMixed:n=!1,toAbsolute:r=!1,decimals:s=3,arcToCubic:p=!1,quadraticToCubic:i=!1,hasRelatives:u=!0,hasShorthands:y=!0,hasQuadratics:h=!0,hasArcs:o=!0,isPoly:c=!1,optimizeArcs:x=!0,testTypes:f=!1}={}){let g=[];if(f){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),y=/[vhst]/gi.test(t),/[mlz]/gi.test(t)}if(a=!r&&a,t=!l&&t,r&&(e=fe(e)),y&&l&&(e=function(e,t=-1,l=!0){let a=!1;if(l){let t=e.map(e=>e.type).join(""),l=/[hstv]/gi.test(t);if(a=/[astvqmhlc]/g.test(t),!l)return e}e=l&&a?fe(e,t):e;let n=[],r={type:"M",values:e[0].values};n.push(r);for(let l=1,a=e.length;l<a;l++){let a,s,p,i,u,y,h,o,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]],p=b+(b-a),i=A+(A-s),r={type:"Q",values:[p,i,M,m]};break;case"S":[a,s]=[d[0],d[1]],[b,A]=[d[v-2],d[v-1]],[h,o]=v>2&&"A"!==r.type?[d[2],d[3]]:[b,A],p=2*b-h,i=2*A-o,u=f[0],y=f[1],r={type:"C",values:[p,i,u,y,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}(e)),x&&(e=function(e=[]){let t=[];e.forEach((l,a)=>{let{type:n,values:r}=l;if("A"===n){let[l,n,s,p,i]=[r[0],r[1],r[3],r[5],r[6]],u=e[a-1],[y,h]=[u.values[u.values.length-2],u.values[u.values.length-1]],o={x:y,y:h},c={x:p,y:i};if(0!==l&&0!==n||(e[a]=null,t.push(a)),l>=1&&(p===y||i===h)){if(Math.abs(l-n)/l<.01){let t=R(S(o,c,.5),o);Math.abs(t-l)/l<.01&&(e[a].values[0]=1,e[a].values[1]=1,e[a].values[2]=0)}}}}),t.length&&(e=e.filter(Boolean));return e}(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?xe(e):e;let n=e.length,r=new Array(n),s=e[0];r[0]=s;let p={x:e[0].values[0],y:e[0].values[1]},i=p;for(let t=1;t<n;t++){let l=e[t];s=l;let{type:a,values:n}=l,u=n.length,y=[n[u-2],n[u-1]],h=e[t-1];i={x:y[0],y:y[1]};let o=Math.abs(i.x-p.x),c=Math.abs(i.y-p.y),x=.01*O(p,i),f=!1,g=!1,d=!1;if("C"===a&&"C"===h.type||"Q"===a&&"Q"===h.type){let e="C"===h.type?{x:h.values[2],y:h.values[3]}:{x:h.values[0],y:h.values[1]},t={x:n[0],y:n[1]},l=p.x-e.x,a=p.y-e.y;x=.01*O(e,t),f=O({x:e.x+2*l,y:e.y+2*a},t)<x}else"L"===a&&(g=0===c||c<x,d=0===o||o<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:[i.x,i.y]});break;case"C":f&&(s={type:"S",values:[n[2],n[3],i.x,i.y]});break;default:s={type:a,values:n}}p=i,r[t]=s}return r}(e)),o&&p&&(e=function(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,p={x:r[s-2],y:r[s-1]};if("A"===n.type){de(p,n.values,t).forEach(e=>{l.push(e)})}else l.push(n)}return l}(e)),h&&i&&(e=function(e){let t=[e[0]];for(let l=1,a=e.length;l<a;l++){let a=e[l],n=e[l-1].values,r=n.length,s={x:n[r-2],y:n[r-1]};"Q"===a.type?t.push(ce(s,a.values)):t.push(a)}return t}(e)),n&&(a=!0),s>-1&&a&&(e=_(e,s)),n&&(g=JSON.parse(JSON.stringify(e))),a&&(e=function(e,t=-1){return xe(e,!0,t)}(e)),s>-1&&(e=_(e,s)),n)for(let t=0;t<e.length;t++){let l=e[t],a=g[t],n=[l.type,l.values.join(" ")].join("").replaceAll(" -","-").replaceAll(" 0."," ."),r=[a.type,a.values.join(" ")].join("").replaceAll(" -","-").replaceAll(" 0."," ."),s=n.length;r.length<s&&(e[t]=g[t])}return e}function oe(e={},t={},l={},a={},n=1){let r=S(e,t,1.5),s=S(a,l,1.5),p=.01*O(e,a)*n,i=O(r,s),u=null,y={type:"C",values:[t.x,t.y,l.x,l.y,a.x,a.y]};return i<p&&(u=w(e,t,a,l,!1,!0),u&&(y.type="Q",y.values=[u.x,u.y,a.x,a.y],y.p0=e,y.cp1=u,y.cp2=null,y.p=a)),y}function ce(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 xe(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],p=r,i=s;for(let n=1;n<a;n++){let a=e[n],{type:u,values:y}=a,h=y.length,o=u.toLowerCase(),c=u.toUpperCase(),x=t?o:c;if(u!==x)switch(a.type=x,o){case"a":y[5]=t?y[5]-r:y[5]+r,y[6]=t?y[6]-s:y[6]+s;break;case"v":y[0]=t?y[0]-s:y[0]+s;break;case"h":y[0]=t?y[0]-r:y[0]+r;break;case"m":t?(y[0]-=r,y[1]-=s):(y[0]+=r,y[1]+=s),p=t?y[0]+r:y[0],i=t?y[1]+s:y[1];break;default:if(y.length)for(let e=0;e<y.length;e++)y[e]=t?y[e]-(e%2?s:r):y[e]+(e%2?s:r)}switch(o){case"z":r=p,s=i;break;case"h":r=t?r+y[0]:y[0];break;case"v":s=t?s+y[0]:y[0];break;case"m":p=y[h-2]+(t?r:0),i=y[h-1]+(t?s:0);default:r=y[h-2]+(t?r:0),s=y[h-1]+(t?s:0)}l>=0&&(a.values=a.values.map(e=>+e.toFixed(l)))}return e}function fe(e,t=-1){return xe(e,!1,t)}function ge({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:p=null,endAngle:i=null,deltaAngle:u=null}={}){if(!a||!n)return[];let y=[];const h=1.5707963267948966;let o=s?r:r*Math.PI/180,c=Math.cos(o),x=Math.sin(o);null!==p&&null!==i&&null!==u||({startAngle:p,endAngle:i,deltaAngle:u}=L(l,e,t));let f=a!==n?D(p,a,n):p,g=a!==n?D(u,a,n):u,d=Math.max(1,Math.ceil(Math.abs(g)/h)),v=g/d;for(let e=0;e<d;e++){const e=Math.abs(v)===h?.551785*Math.sign(v):4/3*Math.tan(v/4);let t=Math.cos(f),r=Math.sin(f),s=Math.cos(f+v),p=Math.sin(f+v),i=[];[{x:t-r*e,y:r+t*e},{x:s+p*e,y:p-s*e},{x:s,y:p}].forEach(e=>{let t=e.x*a,r=e.y*n;i.push(c*t-x*r+l.x,x*t+c*r+l.y)}),y.push({type:"C",values:i,cp1:{x:i[0],y:i[1]},cp2:{x:i[2],y:i[3]},p:{x:i[4],y:i[5]}}),f+=v}return y}function de(e,t,l=1){const a=2*Math.PI;let[n,r,s,p,i,u,y]=t;if(0===n||0===r)return[];let h=s?s*a/360:0,o=h?Math.sin(h):0,c=h?Math.cos(h):1,x=c*(e.x-u)/2+o*(e.y-y)/2,f=-o*(e.x-u)/2+c*(e.y-y)/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)*(p===i?-1:1));let A=b?b*n/r*f:0,C=b?b*-r/n*x:0,L=c*A-o*C+(e.x+u)/2,w=o*A+c*C+(e.y+y)/2,S=(x-A)/n,E=(f-C)/r,P=(-x-A)/n,I=(-f-C)/r;const k=(e,t,l,a)=>{let n=+(e*l+t*a).toFixed(9);return 1===n||-1===n?1===n?0:Math.PI:(n=n>1?1:n<-1?-1:n,(e*a-t*l<0?-1:1)*Math.acos(n))};let D=k(1,0,S,E),Q=k(S,E,P,I);0===i&&Q>0?Q-=2*Math.PI:1===i&&Q<0&&(Q+=2*Math.PI);let $=(+(Math.abs(Q)/(a/4)).toFixed(0)||1)*l;Q/=$;let z=[];const T=1.5707963267948966,q=.551785;let F=Q===T?q:Q===-T?-q:4/3*Math.tan(Q/4),j=Q?Math.cos(Q):1,R=Q?Math.sin(Q):0;const Z=(e,t,l,a,n)=>{let r=e!=t?Math.cos(e):a,s=e!=t?Math.sin(e):n,p=Math.cos(e+t),i=Math.sin(e+t);return[{x:r-s*l,y:s+r*l},{x:p+i*l,y:i-p*l},{x:p,y:i}]};for(let e=0;e<$;e++){let e={type:"C",values:[]};Z(D,Q,F,j,R).forEach(t=>{let l=t.x*n,a=t.y*r;e.values.push(c*l-o*a+L,o*l+c*a+w)}),z.push(e),D+=Q}return z}function ve(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 p=1,i=e.length;p<i;p++){let u=e[p],y=e[p+1]||e[i-1],h="z"===y.type.toLowerCase()?n:{x:y.values[y.values.length-2],y:y.values[y.values.length-1]},{type:o,values:c}=u,x=c.slice(-2);s="Z"!==o?{x:x[0],y:x[1]}:n;let f=h?Y([r,s,h],!0):1/0,g=Z(r,h),d=f<(g?g/333*t:0),v=!1;if(l||"C"!==o||(d=!1),l&&("C"===o||"Q"===o)){v=ne([r,..."C"===o?[{x:c[0],y:c[1]},{x:c[2],y:c[3]}]:"Q"===o?[{x:c[0],y:c[1]}]:[],s],{tolerance:t}),v&&p<i-1&&(o="L",u.type="L",u.values=x)}d&&p<i-1&&"A"!==y.type&&("L"===o||l&&v)||(r=s,"M"===o&&(n=s),a.push(u))}return a}function Me(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],p=e[n+1]||null,{type:i,values:u}=r,y="m"===s.type.toLowerCase()&&!p,h=u.length;if(l={x:u[h-2],y:u[h-1]},y||"L"!==i||l.x!==t.x||l.y!==t.y){if(!y&&("l"===i||"v"===i||"h"===i)){if("l"===i?"00"===u.join(""):0===u[0])continue}a.push(r),t=l}}return a}function me(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?Ae(e,l):e}function be(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(),p=e.filter(e=>"L"===e.type),i=e[s?n-2:n-1],u=i.type,y=i.values.slice(-2).map(e=>+e.toFixed(8)),h=y[0]===r.x&&y[1]===r.y;!s&&l&&h&&(e.push({type:"Z",values:[]}),s=!0,n++);let o="L"!==e[1].type&&(!h||"L"===i.type);if(o=!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,p=e[l+1]&&"L"===e[l+1].type,i=e[l-1]?e[l-1].type.toUpperCase():null,u=e[l+1]?e[l+1].type.toUpperCase():null,y={type:n,x:a[0],y:a[1],dist:0,index:0,prevL:s,nextL:p,prevCom:i,nextCom:u};y.index=l,t.push(y)}}if(p.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?Ae(e,c):e}return r={x:+e[0].values[0].toFixed(8),y:+e[0].values[1].toFixed(8)},n=e.length,i=e[n-2],u=i.type,y=i.values.slice(-2).map(e=>+e.toFixed(8)),h="L"===u&&y[0]===r.x&&y[1]===r.y,t&&h&&e.splice(n-2,1),a.push(...e),a}function Ae(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],p=s.values.length,[i,u]=[s.values[p-2],s.values[p-1]].map(e=>+e.toFixed(8));!l||n==i&&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,p=e.slice(l),i=e.slice(0,l);return i.shift(),r=i[i.length-1].values||[],s=[r[r.length-2],r[r.length-1]],n&&(p.pop(),i.push({type:"Z",values:[]})),e=[{type:"M",values:s},...p,...i]}function Ce(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,p=(e[t-1]?e[t-1]:e[t]).values,i=p.length;if(s){let e={x:p[i-2],y:p[i-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,p="C"===a?[e,l,s,t]:[e,l,t];$(p).forEach(e=>{let t=E(p,e);r(t)})}else"A"===a&&z(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:p,corner:i=!1,dimA:u,p0:y,p:h}=a,o=e[n+1]?e[n+1]:null,c=e[n+2]?e[n+2]:null,x=(o?O(h,o.p):1/0)<t,f=(c?O(c.p,o.p):1/0)<1*t;if(o&&c&&"C"===r&&"C"===o.type&&p&&c.extreme&&(f||x)){let a=te(o,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(o&&"C"===r&&"C"===o.type&&p&&x){let e=Y([a.p0,a.p,o.p]),t=Y([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,p={x:e[0].values[0],y:e[0].values[1]},i=r.values.slice(-2),u=+i[0].toFixed(8)===+p.x.toFixed(8)&&+i[1].toFixed(8)===+p.y.toFixed(8),y="C"===e[1].type&&e[1].extreme?e[1]:null,h=O(r.p0,r.p)<t;if(s&&"C"===s.type&&h&&u&&y){let a=te(s,r,t,l,!1);1===a.length&&(e[n-1]=a[0],e[n]=null,e=e.filter(Boolean))}return e}function Le(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),p=r?2:1,i=e[a-p],u="L"===i.type,y="C"===i.type,h="L"===e[1].type,o="C"===e[1].type,c=r&&o&&(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:i}=s,x=e[t+1]?e[t+1]:null;if("L"===i&&x&&"C"===x.type||"C"===i&&x&&"L"===x.type){let c="L"===i?s:null,f=null,g=[],d=0;if(1===t&&o&&u&&(g=[e[1]],c=e[a-1],f=x),!c){n.push(s);continue}r&&y&&h&&t===a-p-1&&(f=e[1],g=[e[a-p]]);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=O(c.p0,c.p),a=O(f.p0,f.p),r=O(c.p,f.p0),p=Y([c.p0,c.p,f.p0,f.p],!1),i=Y([g[0].p0,g[0].cp1,g[0].cp2,g[0].p],!1),u=p<0&&i>0||p>0&&i<0,y=.5*r*l,h=y<e&&y<a;if(g.length&&!u&&h){let e=Math.abs(i)<.005*Z(g[0].p0,g[0].p)?null:w(c.p0,c.p,f.p,f.p0,!1,!0);if(!e){n.push(s);continue}if(e){let t=Y([c.p0,c.p,f.p0,f.p],!1),l=Math.abs(t),a=Y([c.p0,c.p,e,f.p0,f.p],!1),r=Math.abs(a),p=Math.abs(l-r)/l;if(!e||(t<0&&a>0||t>0&&a<0)||p>.5){n.push(s);continue}}let l=.75*O(E([c.p,e,f.p0],.5),1===g.length?E([g[0].p0,g[0].cp1,g[0].cp2,g[0].p],.5):g[0].p);if(y&&l>y&&l>.3*r){n.push(s);continue}{let l={type:"Q",values:[e.x,e.y,f.p0.x,f.p0.y]};l.p0=c.p,l.cp1=e,l.p=f.p0,n.push(c,l),t+=d;continue}}}}c&&t===a-1&&"L"===i||n.push(s)}return(c||r&&"Z"!==n[n.length-1].type)&&n.push({type:"Z",values:[]}),n}function we(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,p=l.y,i=a.x,u=a.y,y=n-s,h=r-p,o=n-i,c=r-u,x=(n*n-s*s+(r*r-p*p))/2,f=(n*n-i*i+(r*r-u*u))/2,g=y*c-h*o;if(Math.abs(g)<1e-10)return console.warn("Points are collinear or numerically unstable"),!1;let d={x:(c*x-h*f)/g,y:(-o*x+y*f)/g},v=R(d,t),M=L(d,t,a),{deltaAngle:m,startAngle:b,endAngle:A}=M;return{centroid:d,r:v,startAngle:b,endAngle:A,deltaAngle:m}}function Se(e,{threshold:t=0,tolerance:l=1,toCubic:n=!1,debug:r=!1}={}){let s=e.length,p=[e[0]],i=[];for(let t=1;t<s;t++){let l=e[t],{type:s}=l,u=e[t-1],y=e[t+1]?e[t+1]:null,h=e[t+2]?e[t+2]:null,o=e[t+3]?e[t+3]:null,c=null;"C"===l.type||"Q"===l.type?c=l:!y||"C"!==y.type&&"Q"!==y.type||(c=y);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,L=[];if("L"===u.type&&"L"===s&&c&&"L"===h.type&&o&&("L"===o.type||"Z"===o.type)?(x=[l.p0,l.p],f=[h.p0,h.p],g=l.p0,d=h.p,m=Y(M,!1),b=Y([...x,...f],!1),A=m<0&&b>0||m>0&&b<0,A||(v=E(M,.5),L=[g,v,d],C=!0)):"C"!==s&&"Q"!==s||"L"!==u.type||"C"!==y.type&&"Q"!==y.type||"L"!==h.type||(C=!0,x=[u.p0,u.p],f=[h.p0,h.p],g=u.p,d=h.p0,v=c.p,L=[g,c.p,d]),C){let e=we(L);if(e){let s,{centroid:u,r:y,deltaAngle:h,startAngle:o,endAngle:c}=e,x=0,f=h>0?1:0,M=Math.abs(h)>Math.PI?1:0;if(B(I(g,u.x,u.y,.5*h),v)<.05*B(g,d)){if(s=ge({p0:g,p:d,centroid:u,rx:y,ry:y,xAxisRotation:x,sweep:f,largeArc:M,deltaAngle:h,startAngle:o,endAngle:c}),1===s.length){let e=oe(g,s[0].cp1,s[0].cp2,d);"Q"===e.type&&(n=!0),l=e}if(s.length>1&&(n=!1),n||(l.type="A",l.values=[y,y,x,M,f,d.x,d.y]),l.p0=g,l.p=d,l.extreme=!1,l.corner=!1,r){i=n?[{type:"M",values:[g.x,g.y]},...s]:[{type:"M",values:[g.x,g.y]},{type:"A",values:[y,y,x,M,f,d.x,d.y]}];let e=ee(i);a(markers,e,"orange","0.5%","0.5")}p.push(l),t++;continue}}}p.push(l)}return p}function Ee(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),p={x:e[0].values[0],y:e[0].values[1]},i=B(p,{x:s[0],y:s[1]});if(i&&i<t){let l=e[n].values.length;e[n].values[l-2]=p.x,e[n].values[l-1]=p.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]),i=Math.abs(e[1].values[0]-a.values[0]),u=Math.abs(e[1].values[1]-a.values[1]),y=Math.abs(e[1].values[0]-r.values[2]),h=Math.abs(e[1].values[1]-r.values[3]),o=u<t&&h<t&&l;l&&l<t&&(i<t&&y<t&&s)&&(e[1].values[0]=p.x,e[n].values[2]=p.x),s&&s<t&&o&&(e[1].values[1]=p.y,e[n].values[3]=p.y)}}return e}function Pe(e,t=1){for(let l=1,a=e.length;l<a;l++){let a=e[l],{type:n,values:r,p0:s,cp1:p=null,cp2:i=null,p:u=null}=a;if("C"===n){let n=oe(s,p,i,u,t);"Q"===n.type&&(n.extreme=a.extreme,n.corner=a.corner,n.dimA=a.dimA,n.squareDist=a.squareDist,e[l]=n)}}return e}function Ie(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:p=null,p:i=null}=l;if("L"===a){let l=S(r,i,.333),a=S(i,r,.333);e[t].type="C",e[t].values=[l.x,l.y,a.x,a.y,i.x,i.y],e[t].cp1=l,e[t].cp2=a}}return e}function ke(e="",{toAbsolute:t=!0,toRelative:l=!0,toShorthands:a=!0,quadraticToCubic:n=!0,arcToCubic:r=!1,cubicToArc:s=!1,simplifyBezier:p=!0,optimizeOrder:i=!0,autoClose:u=!0,removeZeroLength:y=!0,refineClosing:h=!0,removeColinear:o=!0,flatBezierToLinetos:c=!0,revertToQuadratics:x=!0,refineExtremes:f=!0,simplifyCorners:g=!1,fixDirections:d=!1,keepExtremes:v=!0,keepCorners:M=!0,keepInflections:m=!1,addExtremes:b=!1,addSemiExtremes:A=!1,harmonizeCpts:C=!1,toPolygon:L=!1,removeOrphanSubpaths:w=!1,simplifyRound:S=!1,decimals:E=3,autoAccuracy:P=!0,minifyD:I=0,tolerance:k=1,lineToCubic:D=!1,getObject:Q=!1}={}){k=Math.max(.1,k);let $="",z={x:0,y:0,width:0,height:0},T=[],q=[],F=function(e){let t="string";if(Array.isArray(e)){if(Array.isArray(e[0])){if(2===e[0].length)return"polyArray";if(Array.isArray(e[0][0])&&2===e[0][0].length)return"polyComplexArray";if(void 0!==e[0][0].x&&void 0!==e[0][0].y)return"polyComplexObjectArray"}else{if(void 0!==e[0].x&&void 0!==e[0].y)return"polyObjectArray";if(e[0]?.type&&e[0]?.values)return"pathData"}return"array"}if("string"==typeof e){let l=(e=e.trim()).includes("<svg")&&e.includes("</svg"),a=e.startsWith("<symbol")&&e.includes("</symbol"),n=e.startsWith("M")||e.startsWith("m"),r=!isNaN(e.substring(0,1))&&!isNaN(e.substring(e.length-1,e.length)),s=function(e){e=e.trim();let t=/\d/.test(e),l=/[abcdfghijklmnopqrstuvwz]/gi.test(e);return!(!t||l)&&(e.startsWith("[")&&e.endsWith("]"))}(e);if(l)t="svgMarkup";else if(s)t="json";else if(a)t="symbol";else if(n)t="pathDataString";else if(r)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);if("pathDataString"===F)$=e;else if("polyString"===F)$="M"+e;else{if("pathData"!==F)return!1;$=e}let j={toRelative:l,toShorthands:a,decimals:E},R=ye($,{quadraticToCubic:n,toAbsolute:t,arcToCubic:r});R.length,w&&(R=function(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}(R));let Z=N(R),B=Z.length,J=[];for(let e=0;e<B;e++){let t=Z[e];(o||y)&&(t=Me(t)),i&&(t=me(t)),o&&(t=ve(t,{tolerance:k,flatBezierToLinetos:!1})),(b||A)&&(t=H(t,{tMin:tMin,tMax:tMax,addExtremes:b,addSemiExtremes:A,angles:[30]}));let l=re(t,{detectSemiExtremes:A}),{pathData:a,bb:n,dimA:r}=l;if(T.push(n.x,n.x+n.width),q.push(n.y,n.y+n.height),h&&(a=Ee(a,{threshold:.001*r})),a=p?le(a,{simplifyBezier:p,keepInflections:m,keepExtremes:v,keepCorners:M,revertToQuadratics:x,tolerance:k}):a,f){a=Ce(a,{threshold:.05*(n.width+n.height),tolerance:k})}if(o&&c&&(a=ve(a,{tolerance:k,flatBezierToLinetos:c})),g){a=Le(a,{threshold:.1*(n.width+n.height),tolerance:k})}S&&(a=Se(a)),x&&(a=Pe(a,k)),D&&(a=Ie(a)),i&&(a=be(a,{autoClose:u})),J.push({pathData:a,bb:n})}let W=Math.min(...T),U=Math.min(...q);z={x:W,y:U,width:Math.max(...T)-W,height:Math.max(...q)-U},i&&(J=z.height>z.width?J.sort((e,t)=>e.bb.y-t.bb.y||e.bb.x-t.bb.x):J.sort((e,t)=>e.bb.x-t.bb.x||e.bb.y-t.bb.y)),R=[],J.forEach(e=>{R.push(...e.pathData)}),P&&(E=function(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:p=null,dimA:i=0}=a;r.length&&p&&s&&(i=i||O(s,p),i&&t.push(i))}let l=t.sort(),a=Math.ceil(l.length/6);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)}(R),j.decimals=E),R=he(R,j),R=Me(R);let _=ee(R,I);return Q&&(R=R.map(e=>({type:e.type,values:e.values}))),Q?R:_}"undefined"!=typeof window&&(window.simplifyPathData=ke);export{ke as simplifyPathData};
3
+ if(S){let e="C"===a?Math.abs(l.cp2.x-l.p.x):Math.abs(l.cp1.x-l.p.x),t="C"===a?Math.abs(l.cp2.y-l.p.y):Math.abs(l.cp1.y-l.p.y);if(((0===t||t<=A)&&e>0||(0===e||e<=A)&&t>0)&&(L=!0),(i.x===r.x&&i.y!==r.y||i.y===r.y&&i.x!==r.x)&&(m[m.length-1].extreme=!0),p.x!==o&&p.y!==x&&p.x!==c&&p.y!==f||(L=!0),!L){if(k(null,M)){let e=z(M);e.length&&e[0]>.2&&(L=!0)}}}else if(w&&v&&("C"===d.type||"Q"===d.type||"C"===v.type||"Q"===v.type)){let e=v?v.dimA:0,t=l.dimA<.1*(d.dimA+e),a=l.values[0]===l.values[1]&&l.values[0]<1;if(t&&a){let e=_([d.p0,v.p]);(p.x>e.right||p.x<e.x||p.y<e.y||p.y>e.bottom)&&(L=!0)}}if(L&&(l.extreme=!0),S&&E){if(s&&!l.extreme){let e=Math.abs(p.x-u.x),t=Math.abs(p.y-u.y),a=!1;if(e&&t&&e>b||t>b){let e=C(u,p),t=C(p,v.cp1);a=j(Math.abs(e+t)/2)}a&&(l.semiExtreme=!0)}if((l.cptArea<0&&v.cptArea>0||l.cptArea>0&&v.cptArea<0)&&(l.directionChange=!0),!l.extreme){let e=u||i,t=v.cp1,a=Y([e,p,t],!1),n=.01*R(e,t),s=Math.abs(a)<n,r=a<0&&l.cptArea>0||a>0&&l.cptArea<0;!s&&r&&(l.corner=!0)}}m.push(l)}return r&&m.forEach(e=>{e.directionChange&&a(markers,e.p,"orange","1.5%","0.5"),e.corner&&a(markers,e.p,"magenta","1.5%","0.5"),e.extreme&&a(markers,e.p,"cyan","1%","0.5")}),u={pathData:m,bb:y,dimA:(g+d)/2},u}const re=new Set([77,109,65,97,67,99,76,108,81,113,83,115,84,116,72,104,86,118,90,122]),pe=new Uint8Array(128);pe[77]=2,pe[109]=2,pe[65]=7,pe[97]=7,pe[67]=6,pe[99]=6,pe[76]=2,pe[108]=2,pe[81]=4,pe[113]=4,pe[83]=4,pe[115]=4,pe[84]=2,pe[116]=2,pe[72]=1,pe[104]=1,pe[86]=1,pe[118]=1,pe[90]=0,pe[122]=0;const ie=new Set([5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279]),ue=e=>32===e||44===e||10===e||13===e||8232===e||8233===e||9===e||11===e||12===e||160===e||e>=5760&&ie.has(e);function he(e,{toShorthands:t=!0,toLonghands:l=!1,toRelative:a=!0,toMixed:n=!1,toAbsolute:s=!1,decimals:r=3,arcToCubic:p=!1,quadraticToCubic:i=!1,hasRelatives:u=!0,hasShorthands:h=!0,hasQuadratics:y=!0,hasArcs:o=!0,isPoly:c=!1,optimizeArcs:x=!0,testTypes:f=!1}={}){let g=[];if(f){let t=Array.from(new Set(e.map(e=>e.type))).join("");/[lcqamts]/gi.test(t),y=/[qt]/gi.test(t),o=/[a]/gi.test(t),h=/[vhst]/gi.test(t),/[mlz]/gi.test(t)}if(a=!s&&a,t=!l&&t,s&&(e=fe(e)),h&&l&&(e=function(e,t=-1,l=!0){let a=!1;if(l){let t=e.map(e=>e.type).join(""),l=/[hstv]/gi.test(t);if(a=/[astvqmhlc]/g.test(t),!l)return e}e=l&&a?fe(e,t):e;let n=[],s={type:"M",values:e[0].values};n.push(s);for(let l=1,a=e.length;l<a;l++){let a,r,p,i,u,h,y,o,c=e[l],{type:x,values:f}=c,g=f.length,d=s.values,m=d.length,[v,M]=[f[g-2],f[g-1]],[b,A]=[d[m-2],d[m-1]];switch(x){case"H":s={type:"L",values:[f[0],A]};break;case"V":s={type:"L",values:[b,f[0]]};break;case"T":[a,r]=[d[0],d[1]],[b,A]=[d[m-2],d[m-1]],p=b+(b-a),i=A+(A-r),s={type:"Q",values:[p,i,v,M]};break;case"S":[a,r]=[d[0],d[1]],[b,A]=[d[m-2],d[m-1]],[y,o]=m>2&&"A"!==s.type?[d[2],d[3]]:[b,A],p=2*b-y,i=2*A-o,u=f[0],h=f[1],s={type:"C",values:[p,i,u,h,v,M]};break;default:s={type:x,values:f}}t>-1&&(s.values=s.values.map(e=>+e.toFixed(t))),n.push(s)}return n}(e)),x&&(e=function(e=[]){let t=e.length,l=[];for(let a=0;a<t;a++){let t=e[a],{type:n,values:s}=t;if("A"!==n){l.push(t);continue}let[r,p,i,u,h]=[s[0],s[1],s[3],s[5],s[6]],y=e[a-1],[o,c]=[y.values[y.values.length-2],y.values[y.values.length-1]],x={x:o,y:c},f={x:u,y:h};0!==r&&0!==p||(e[a]=null);let g=r/p,d=r!==p?Math.abs(1-g):0;if(d>.01){l.push(t);continue}t.values[2]=0;let m=.001*O(x,f),v=Math.abs(u-o),M=Math.abs(h-c),b=M<m;if(b||v<m){(b?1.9*r>v:1.9*p>M)||(r=r>=1?1:r>.5?.5:r),t.values[0]=r,t.values[1]=r,l.push(t);continue}let A=.5*B(x,f);d=r/A,d<.5&&(r=A>=1?1:A>.5?.5:A),t.values[0]=r,t.values[1]=r,l.push(t)}return l}(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?xe(e):e;let n=e.length,s=new Array(n),r=e[0];s[0]=r;let p={x:e[0].values[0],y:e[0].values[1]},i=p;for(let t=1;t<n;t++){let l=e[t];r=l;let{type:a,values:n}=l,u=n.length,h=[n[u-2],n[u-1]],y=e[t-1];i={x:h[0],y:h[1]};let o=Math.abs(i.x-p.x),c=Math.abs(i.y-p.y),x=.01*O(p,i),f=!1,g=!1,d=!1;if("C"===a&&"C"===y.type||"Q"===a&&"Q"===y.type){let e="C"===y.type?{x:y.values[2],y:y.values[3]}:{x:y.values[0],y:y.values[1]},t={x:n[0],y:n[1]},l=p.x-e.x,a=p.y-e.y;x=.01*O(e,t),f=O({x:e.x+2*l,y:e.y+2*a},t)<x}else"L"===a&&(g=0===c||c<x,d=0===o||o<x,f=d||g);switch(a){case"L":g&&(r={type:"H",values:[n[0]]}),d&&(r={type:"V",values:[n[1]]});break;case"Q":f&&(r={type:"T",values:[i.x,i.y]});break;case"C":f&&(r={type:"S",values:[n[2],n[3],i.x,i.y]});break;default:r={type:a,values:n}}p=i,s[t]=r}return s}(e)),o&&p&&(e=function(e,{arcAccuracy:t=1}={}){let l=[e[0]];for(let a=1,n=e.length;a<n;a++){let n=e[a],s=e[a-1].values,r=s.length,p={x:s[r-2],y:s[r-1]};if("A"===n.type){de(p,n.values,t).forEach(e=>{l.push(e)})}else l.push(n)}return l}(e)),y&&i&&(e=function(e){let t=[e[0]];for(let l=1,a=e.length;l<a;l++){let a=e[l],n=e[l-1].values,s=n.length,r={x:n[s-2],y:n[s-1]};"Q"===a.type?t.push(ce(r,a.values)):t.push(a)}return t}(e)),n&&(a=!0),r>-1&&a&&(e=H(e,r)),n&&(g=JSON.parse(JSON.stringify(e))),a&&(e=function(e,t=-1){return xe(e,!0,t)}(e)),r>-1&&(e=H(e,r)),n)for(let t=0;t<e.length;t++){let l=e[t],a=g[t],n=[l.type,l.values.join(" ")].join("").replaceAll(" -","-").replaceAll(" 0."," ."),s=[a.type,a.values.join(" ")].join("").replaceAll(" -","-").replaceAll(" 0."," ."),r=n.length;s.length<r&&(e[t]=g[t])}return e}function ye(e,{toAbsolute:t=!0,toLonghands:l=!0,quadraticToCubic:a=!1,arcToCubic:n=!1,arcAccuracy:s=4}={}){let r=Array.isArray(e),p=r&&"object"==typeof e[0]&&"function"==typeof e[0].constructor,i=r?e:function(e,t=!0,l=0){if(!e)return[];e=e.trim(),l&&console.log("!!!limit",l);let a={pathData:[],hasRelatives:!1,hasShorthands:!1,hasArcs:!1,hasQuadratics:!1,isPolygon:!1,log:[]};if(""===e)return a;let n,s=0,r=e.length,p="",i=-1,u="",h=!1,y=0,o=0,c=0,x=!1,f=new Set([]);const g=()=>{x&&("M"===p?p="L":"m"===p&&(p="l"),a.pathData.push({type:p,values:[]}),i++,o=0,x=!1)},d=(e=!1)=>{(e?y>0:""!==u)&&(t&&-1===i&&(n="Pathdata must start with M command",a.log.push(n),p="M",a.pathData.push({type:p,values:[]}),c=2,o=0,i++),"A"===p||"a"===p?(({val:u,valueIndex:o}=((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}})(u,o)),a.pathData[i].values.push(...u)):(t&&u[1]&&"."!==u[1]&&"0"===u[0]&&(n=`${i}. command: Leading zeros not valid: ${u}`,a.log.push(n)),a.pathData[i].values.push(+u)),o++,u="",y=0,x=o>=c)},m=()=>{if(i>0){let e=a.pathData[i].values.length;(e&&e<c||e&&e>c||("z"===p||"Z"===p)&&e>0)&&(n=`${i}. command of type "${p}": ${c-e} values too few - ${c} expected`,a.log[a.log.length-1]!==n&&a.log.push(n))}};let v=!1,M=!1,b=!1,A="";for(;s<r;){A=e.charCodeAt(s);let l=A>47&&A<58;if(l||(v=101===A||69===A,M=45===A||43===A,b=46===A),l||M||b||v){if(h||45!==A&&46!==A)g();else{let e=46===A;d(e),g(),e&&y++}u+=e[s],h=v,s++}else if((A<48||A>5759)&&ue(A))d(),s++;else{if(A>64){if(!re.has(A)){n=`${i}. command "${e[s]}" is not a valid type`,a.log.push(n),s++;continue}""!==u&&(a.pathData[i].values.push(+u),o++,u=""),t&&m(),p=e[s],c=pe[A];let l="M"===p||"m"===p,r=i>0&&("z"===a.pathData[i].type||"Z"===a.pathData[i].type);f.add(p),r&&!l&&(a.pathData.push({type:"m",values:[0,0]}),i++),a.pathData.push({type:p,values:[]}),i++,y=0,o=0,x=!1,s++;continue}l||(n=`${i}. ${e[s]} is not a valid separarator or token`,a.log.push(n),u=""),s++}}d(),t&&m(),t&&a.log.length&&(n="Invalid path data:\n"+a.log.join("\n"),"log"===t||console.warn(n)),a.pathData[0].type="M";let C=Array.from(f).join("");return a.hasRelatives=/[lcqamtsvh]/g.test(C),a.hasShorthands=/[vhst]/gi.test(C),a.hasArcs=/[a]/gi.test(C),a.hasQuadratics=/[qt]/gi.test(C),a.isPolygon=!/[cqats]/gi.test(C),a}(e),{hasRelatives:u=!0,hasShorthands:h=!0,hasQuadratics:y=!0,hasArcs:o=!0}=i,c=p?i:i.pathData;return c=function(e=[],{toAbsolute:t=!0,toLonghands:l=!0,quadraticToCubic:a=!1,arcToCubic:n=!1,arcAccuracy:s=2,hasRelatives:r=!0,hasShorthands:p=!0,hasQuadratics:i=!0,hasArcs:u=!0,testTypes:h=!1}={}){return he(e,{toAbsolute:t,toLonghands:l,quadraticToCubic:a,arcToCubic:n,arcAccuracy:s,hasRelatives:r,hasShorthands:p,hasQuadratics:i,hasArcs:u,testTypes:h,decimals:-1})}(c,{toAbsolute:t,toLonghands:l,quadraticToCubic:a,arcToCubic:n,arcAccuracy:s,hasRelatives:u,hasShorthands:h,hasQuadratics:y,hasArcs:o}),c}function oe(e={},t={},l={},a={},n=1){let s=E(e,t,1.5),r=E(a,l,1.5),p=.01*O(e,a)*n,i=O(s,r),u=null,h={type:"C",values:[t.x,t.y,l.x,l.y,a.x,a.y]};return i<p&&(u=w(e,t,a,l,!1,!0),u&&(h.type="Q",h.values=[u.x,u.y,a.x,a.y],h.p0=e,h.cp1=u,h.cp2=null,h.p=a)),h}function ce(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 xe(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,s=n[0],r=n[1],p=s,i=r;for(let n=1;n<a;n++){let a=e[n],{type:u,values:h}=a,y=h.length,o=u.toLowerCase(),c=u.toUpperCase(),x=t?o:c;if(u!==x)switch(a.type=x,o){case"a":h[5]=t?h[5]-s:h[5]+s,h[6]=t?h[6]-r:h[6]+r;break;case"v":h[0]=t?h[0]-r:h[0]+r;break;case"h":h[0]=t?h[0]-s:h[0]+s;break;case"m":t?(h[0]-=s,h[1]-=r):(h[0]+=s,h[1]+=r),p=t?h[0]+s:h[0],i=t?h[1]+r:h[1];break;default:if(h.length)for(let e=0;e<h.length;e++)h[e]=t?h[e]-(e%2?r:s):h[e]+(e%2?r:s)}switch(o){case"z":s=p,r=i;break;case"h":s=t?s+h[0]:h[0];break;case"v":r=t?r+h[0]:h[0];break;case"m":p=h[y-2]+(t?s:0),i=h[y-1]+(t?r:0);default:s=h[y-2]+(t?s:0),r=h[y-1]+(t?r:0)}l>=0&&(a.values=a.values.map(e=>+e.toFixed(l)))}return e}function fe(e,t=-1){return xe(e,!1,t)}function ge({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:s=0,radToDegree:r=!1,startAngle:p=null,endAngle:i=null,deltaAngle:u=null}={}){if(!a||!n)return[];let h=[];const y=1.5707963267948966;let o=r?s:s*Math.PI/180,c=Math.cos(o),x=Math.sin(o);null!==p&&null!==i&&null!==u||({startAngle:p,endAngle:i,deltaAngle:u}=S(l,e,t));let f=a!==n?D(p,a,n):p,g=a!==n?D(u,a,n):u,d=Math.max(1,Math.ceil(Math.abs(g)/y)),m=g/d;for(let e=0;e<d;e++){const e=Math.abs(m)===y?.551785*Math.sign(m):4/3*Math.tan(m/4);let t=Math.cos(f),s=Math.sin(f),r=Math.cos(f+m),p=Math.sin(f+m),i=[];[{x:t-s*e,y:s+t*e},{x:r+p*e,y:p-r*e},{x:r,y:p}].forEach(e=>{let t=e.x*a,s=e.y*n;i.push(c*t-x*s+l.x,x*t+c*s+l.y)}),h.push({type:"C",values:i,cp1:{x:i[0],y:i[1]},cp2:{x:i[2],y:i[3]},p:{x:i[4],y:i[5]}}),f+=m}return h}function de(e,t,l=1){const a=2*Math.PI;let[n,s,r,p,i,u,h]=t;if(0===n||0===s)return[];let y=r?r*a/360:0,o=y?Math.sin(y):0,c=y?Math.cos(y):1,x=c*(e.x-u)/2+o*(e.y-h)/2,f=-o*(e.x-u)/2+c*(e.y-h)/2;if(0===x&&0===f)return[];n=Math.abs(n),s=Math.abs(s);let g=x*x/(n*n)+f*f/(s*s);if(g>1){let e=Math.sqrt(g);n*=e,s*=e}let d=n*n,m=n===s?d:s*s,v=x*x,M=f*f,b=d*m-d*M-m*v;b<=0?b=0:(b/=d*M+m*v,b=Math.sqrt(b)*(p===i?-1:1));let A=b?b*n/s*f:0,C=b?b*-s/n*x:0,S=c*A-o*C+(e.x+u)/2,w=o*A+c*C+(e.y+h)/2,E=(x-A)/n,L=(f-C)/s,P=(-x-A)/n,T=(-f-C)/s;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,E,L),k=I(E,L,P,T);0===i&&k>0?k-=2*Math.PI:1===i&&k<0&&(k+=2*Math.PI);let q=(+(Math.abs(k)/(a/4)).toFixed(0)||1)*l;k/=q;let Q=[];const z=1.5707963267948966,$=.551785;let F=k===z?$:k===-z?-$:4/3*Math.tan(k/4),j=k?Math.cos(k):1,B=k?Math.sin(k):0;const R=(e,t,l,a,n)=>{let s=e!=t?Math.cos(e):a,r=e!=t?Math.sin(e):n,p=Math.cos(e+t),i=Math.sin(e+t);return[{x:s-r*l,y:r+s*l},{x:p+i*l,y:i-p*l},{x:p,y:i}]};for(let e=0;e<q;e++){let e={type:"C",values:[]};R(D,k,F,j,B).forEach(t=>{let l=t.x*n,a=t.y*s;e.values.push(c*l-o*a+S,o*l+c*a+w)}),Q.push(e),D+=k}return Q}function me(e,{tolerance:t=1,flatBezierToLinetos:l=!0}={}){let a=[e[0]],n={x:e[0].values[0],y:e[0].values[1]},s=n,r=n;e[e.length-1].type.toLowerCase();for(let p=1,i=e.length;p<i;p++){let u=e[p],h=e[p+1]||e[i-1],y="z"===h.type.toLowerCase()?n:{x:h.values[h.values.length-2],y:h.values[h.values.length-1]},{type:o,values:c}=u,x=c.slice(-2);r="Z"!==o?{x:x[0],y:x[1]}:n;let f=y?Y([s,r,y],!0):1/0,g=R(s,y),d=f<(g?g/333*t:0),m=!1;if(l||"C"!==o||(d=!1),l&&("C"===o||"Q"===o)){m=ne([s,..."C"===o?[{x:c[0],y:c[1]},{x:c[2],y:c[3]}]:"Q"===o?[{x:c[0],y:c[1]}]:[],r],{tolerance:t}),m&&p<i-1&&(o="L",u.type="L",u.values=x)}d&&p<i-1&&"A"!==h.type&&("L"===o||l&&m)||(s=r,"M"===o&&(n=r),a.push(u))}return a}function ve(e){let t={x:e[0].values[0],y:e[0].values[1]},l=t,a=[e[0]];for(let n=1,s=e.length;n<s;n++){let s=e[n],r=e[n-1],p=e[n+1]||null,{type:i,values:u}=s,h="m"===r.type.toLowerCase()&&!p,y=u.length;if(l={x:u[y-2],y:u[y-1]},h||"L"!==i||l.x!==t.x||l.y!==t.y){if(!h&&("l"===i||"v"===i||"h"===i)){if("l"===i?"00"===u.join(""):0===u[0])continue}a.push(s),t=l}}return a}function Me(e){let t=e.length;if(!("z"===e[t-1].type.toLowerCase()))return e;let l=0,a=[];for(let l=0;l<t;l++){let t=e[l],{type:n,values:s}=t,r=s.length;if(r){let e={type:n,x:+s[r-2].toFixed(8),y:+s[r-1].toFixed(8),index:0};e.index=l,a.push(e)}}return a=a.sort((e,t)=>e.y-t.y||e.x-t.x),l=a[0].index,l?Ae(e,l):e}function be(e,{removeFinalLineto:t=!0,autoClose:l=!0}={}){let a=e,n=e.length,s={x:+e[0].values[0].toFixed(8),y:+e[0].values[1].toFixed(8)},r="z"===e[n-1].type.toLowerCase(),p=!1,i=r?n-2:n-1,u=e[i],h=u.type,y=u.values.slice(-2).map(e=>+e.toFixed(8)),o=y[0]===s.x&&y[1]===s.y,c="L"===h,x=[];for(let t=0;t<n;t++){let l=e[t],{type:a,values:n,p0:s,p:r}=l;if("L"===a&&(p=!0),n.length){n.slice(-2);let l={type:a,x:Math.min(s.x,r.x),y:Math.min(s.y,r.y),index:0,prevType:(e[t-1]?e[t-1]:e[i]).type};l.index=t,x.push(l)}}let f=1/0,g=1/0,d=null,m=x.length;for(let e=0;e<m;e++){let t=x[e],{type:l,index:a,x:n,y:s,prevType:r}=t;p&&"L"===r&&(n<f&&s<g&&(d=a-1),s<g&&(g=s),n<f&&(f=n))}return d&&(a=Ae(a,d),n=a.length,s={x:+a[0].values[0].toFixed(8),y:+a[0].values[1].toFixed(8)},i=r?n-2:n-1,u=a[i],h=u.type,y=u.values.slice(-2).map(e=>+e.toFixed(8)),c="L"===h,o=y[0]===s.x&&y[1]===s.y),t&&o&&c&&a.splice(n-2,1),l&&!r&&o&&a.push({type:"Z",values:[]}),a}function Ae(e,t){let l=0,a="z"===e[e.length-1].type.toLowerCase();if(!a||t<1||e.length<3)return e;let n=a?1:0;!function(e){let t=e.length,l="z"===e[t-1].type.toLowerCase(),a=e[0],[n,s]=[a.values[0],a.values[1]].map(e=>+e.toFixed(8)),r=l?e[t-2]:e[t-1],p=r.values.length,[i,u]=[r.values[p-2],r.values[p-1]].map(e=>+e.toFixed(8));!l||n==i&&s==u||(e.pop(),e.push({type:"L",values:[n,s]},{type:"Z",values:[]}))}(e),l=t+1<e.length-1?t+1:e.length-1-n;let s,r,p=e.slice(l),i=e.slice(0,l);return i.shift(),s=i[i.length-1].values||[],r=[s[s.length-2],s[s.length-1]],n&&(p.pop(),i.push({type:"Z",values:[]})),e=[{type:"M",values:r},...p,...i]}function Ce(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 s=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,r=n.length,p=(e[t-1]?e[t-1]:e[t]).values,i=p.length;if(r){let e={x:p[i-2],y:p[i-1]},t={x:n[r-2],y:n[r-1]};if(s(t),"C"===a||"Q"===a){let l={x:n[0],y:n[1]},r="C"===a?{x:n[2],y:n[3]}:l,p="C"===a?[e,l,r,t]:[e,l,t];q(p).forEach(e=>{let t=L(p,e);s(t)})}else"A"===a&&Q(e,n).forEach(e=>{s(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:s,values:r,extreme:p,corner:i=!1,dimA:u,p0:h,p:y}=a,o=e[n+1]?e[n+1]:null,c=e[n+2]?e[n+2]:null,x=(o?O(y,o.p):1/0)<t,f=(c?O(c.p,o.p):1/0)<1*t;if(o&&c&&"C"===s&&"C"===o.type&&p&&c.extreme&&(f||x)){let a=te(o,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(o&&"C"===s&&"C"===o.type&&p&&x){let e=Y([a.p0,a.p,o.p]),t=Y([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,s=e[n],r=e[n-1]||null,p={x:e[0].values[0],y:e[0].values[1]},i=s.values.slice(-2),u=+i[0].toFixed(8)===+p.x.toFixed(8)&&+i[1].toFixed(8)===+p.y.toFixed(8),h="C"===e[1].type&&e[1].extreme?e[1]:null,y=O(s.p0,s.p)<t;if(r&&"C"===r.type&&y&&u&&h){let a=te(r,s,t,l,!1);1===a.length&&(e[n-1]=a[0],e[n]=null,e=e.filter(Boolean))}return e}function Se(e,t=!1){if(e.length<3)return!1;let l=e.length,a=Math.floor(.333*l),n=Math.floor(.666*l),s=Math.floor(.5*l),r=e[0],p=e[s],i=e[l-1],u=we([r,p,i]),h=0,y=0,o=0,c=0,x={};if(t){if(l>3){let t=we([r,e[a],i]),l=we([r,e[n],i]);if(!t||!l)return!1;let s=O(u,p);if(O(u,t)+O(u,l)>.05*s)return!1}let t=R(u,p);for(let a=0;a<l;a++){let l=R(u,e[a]);if(Math.abs(t-l)/t>.0025)return!1}h=Math.sqrt(t),x=S(u,r,i),({deltaAngle:y,startAngle:o,endAngle:c}=x)}else h=B(u,r),x=S(u,r,i),({deltaAngle:y,startAngle:o,endAngle:c}=x);return{centroid:u,r:h,startAngle:o,endAngle:c,deltaAngle:y}}function we(e=[]){if((e=e.filter(e=>void 0!==e)).length<3)return!1;let t=e[0],l=e[Math.floor(e.length/2)],a=e[e.length-1],n=t.x,s=t.y,r=l.x,p=l.y,i=a.x,u=a.y,h=n-r,y=s-p,o=n-i,c=s-u,x=(n*n-r*r+(s*s-p*p))/2,f=(n*n-i*i+(s*s-u*u))/2,g=h*c-y*o;return!(Math.abs(g)<1e-10)&&{x:(c*x-y*f)/g,y:(-o*x+h*f)/g}}function Ee(e,{threshold:t=0,simplifyQuadraticCorners:l=!1,tolerance:a=1}={}){let n=e.length,s=[e[0]],r="z"===e[n-1].type.toLowerCase(),p=!!r&&(e[n-1].p.x===e[0].p0.x&&e[n-1].p.y===e[0].p0.y),i=r?2:1,u=e[n-i],h="L"===u.type,y="C"===u.type,o="L"===e[1].type,c="C"===e[1].type,x=null,f=r&&c&&(h||p);f&&(e[n-1].values=e[0].values,e[n-1].type="L",h=!0);for(let t=1;t<n;t++){let p=e[t],{type:u}=p,g=e[t+1]?e[t+1]:null;if("L"===u&&g&&"C"===g.type||"C"===u&&g&&"L"===g.type){let f="L"===u?p:null,d=null,m=[],v=0;if(1===t&&c&&h&&(m=[e[1]],f=e[n-1],d=g),!f){s.push(p);continue}r&&y&&o&&t===n-i-1&&(d=e[1],m=[e[n-i]]);for(let l=t+1;l<n;l++){let t=e[l]?e[l]:null,a=e[l-1];if("C"===a.type&&l>2&&m.push(a),"L"===t.type&&"C"===a.type){d=t;break}v++}if(d){let e=O(f.p0,f.p),r=O(d.p0,d.p),u=O(f.p,d.p0),h=Y([f.p0,f.p,d.p0,d.p],!1),y=Y([m[0].p0,m[0].cp1,m[0].cp2,m[0].p],!1),o=h<0&&y>0||h>0&&y<0,c=.5*u*a,g=c<e&&c<r;if(m.length&&!o&&g){let e=!1;if(1===m.length){let t=Math.abs(m[0].p.x-m[0].p0.x),l=t-Math.abs(m[0].p.y-m[0].p0.y);e=Math.abs(l/t)<.01}let a=!0;if(a=!1,a&&e){let e=L([m[0].p0,m[0].cp1,m[0].cp2,m[0].p],.5),l=Se([m[0].p0,e,m[0].p]),{r:a,centroid:n,deltaAngle:r}=l,p={type:"A",values:[a,a,0,0,r>0?1:0,m[0].p.x,m[0].p.y]};s.push(f,p),t+=v;continue}let r=.005*R(m[0].p0,m[0].p),h=Math.abs(y)<r,o=Math.abs(y)<10*r,g=h?null:w(f.p0,f.p,d.p,d.p0,!1,!0);if(!g||o&&1===m.length){s.push(p);continue}if(g){let e=Y([f.p0,f.p,d.p0,d.p],!1),t=Math.abs(e),l=Y([f.p0,f.p,g,d.p0,d.p],!1),a=Math.abs(l),n=Math.abs(t-a)/t;if(!g||(e<0&&l>0||e>0&&l<0)||n>.5){s.push(p);continue}}let M=.75*O(L([f.p,g,d.p0],.5),1===m.length?L([m[0].p0,m[0].cp1,m[0].cp2,m[0].p],.5):m[0].p);if(c&&M>c&&M>.3*u){s.push(p);continue}let b=d.p0;if(!l){let l=.1666,a=E(g,f.p,1+l);b=E(g,d.p0,1+l);let s=g.y===f.p.y,r=g.x===f.p.x,u=g.y===d.p0.y,h=g.x===d.p0.x;if(e&&p.dimA>3){let e=.5;s&&(a.x=K(a.x,e)),r&&(a.y=K(a.y,e)),u&&(b.x=K(b.x,e)),h&&(b.y=K(b.y,e))}t===n-i-1&&(x=b),f.values=[a.x,a.y],f.p=a}let A={type:"Q",values:[g.x,g.y,b.x,b.y]};A.cp1=g,A.p0=f.p,A.p=b,s.push(f,A),t+=v;continue}}}f&&t===n-1&&"L"===u||s.push(p)}return x&&(s[0].values=[x.x,x.y],s[0].p0=x),(f||r&&"Z"!==s[s.length-1].type)&&s.push({type:"Z",values:[]}),s}function Le(e=[],{threshold:t=0}={}){let l=e.length,a="z"===e[l-1].type.toLowerCase(),n=a?l-2:l-1,s=e[n],r=s.values.slice(-2),p={x:e[0].values[0],y:e[0].values[1]},i=N(p,{x:r[0],y:r[1]});if(i&&i<t){let l=e[n].values.length;e[n].values[l-2]=p.x,e[n].values[l-1]=p.y;let a=e[1];if("C"===a.type&&"C"===s.type){let l=Math.abs(a.values[0]-s.values[2]),r=Math.abs(a.values[1]-s.values[3]),i=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]-s.values[2]),y=Math.abs(e[1].values[1]-s.values[3]),o=u<t&&y<t&&l;l&&l<t&&(i<t&&h<t&&r)&&(e[1].values[0]=p.x,e[n].values[2]=p.x),r&&r<t&&o&&(e[1].values[1]=p.y,e[n].values[3]=p.y)}}return e}function Pe(e,t=1){for(let l=1,a=e.length;l<a;l++){let a=e[l],{type:n,values:s,p0:r,cp1:p=null,cp2:i=null,p:u=null}=a;if("C"===n){let n=oe(r,p,i,u,t);"Q"===n.type&&(n.extreme=a.extreme,n.corner=a.corner,n.dimA=a.dimA,n.squareDist=a.squareDist,e[l]=n)}}return e}function Te(e){for(let t=1,l=e.length;t<l;t++){let l=e[t],{type:a,values:n,p0:s,cp1:r=null,cp2:p=null,p:i=null}=l;if("L"===a){let l=E(s,i,.333),a=E(i,s,.333);e[t].type="C",e[t].values=[l.x,l.y,a.x,a.y,i.x,i.y],e[t].cp1=l,e[t].cp2=a}}return e}function Ie(e,{threshold:t=0,tolerance:l=1,toCubic:a=!1,debug:n=!1}={}){let s=e.length,r=[e[0]];for(let t=1;t<s;t++){let l=e[t],{type:n}=l,s=e[t-1],p=e[t+1]?e[t+1]:null,i=e[t+2]?e[t+2]:null,u=e[t+3]?e[t+3]:null,h=null;"C"===l.type||"Q"===l.type?h=l:!p||"C"!==p.type&&"Q"!==p.type||(h=p);let y,o,c,x,f,g=h?"C"===h.type?[h.p0,h.cp1,h.cp2,h.p]:[h.p0,h.cp1,h.p]:[],d=0,m=0,v=!1,M=!1,b=[];if(i&&u&&"L"===s.type&&"L"===n&&h&&"L"===i.type&&("L"===u.type||"Z"===u.type)?(y=[l.p0,l.p],o=[i.p0,i.p],c=l.p0,x=i.p,d=Y(g,!1),m=Y([...y,...o],!1),v=d<0&&m>0||d>0&&m<0,v||(f=L(g,.5),b=[c,f,x],M=!0)):!p||"C"!==n&&"Q"!==n||"L"!==s.type||!i||"L"!==i.type||"C"!==p.type&&"Q"!==p.type||(M=!0,y=[s.p0,s.p],o=[i.p0,i.p],c=s.p,x=i.p0,f=h.p,b=[c,h.p,x]),M){let e=Se(b);if(e){let n,{centroid:s,r:p,deltaAngle:i,startAngle:u,endAngle:h}=e,y=0,o=i>0?1:0,g=Math.abs(i)>Math.PI?1:0;if(N(T(c,s.x,s.y,.5*i),f)<.05*N(c,x)){if(n=ge({p0:c,p:x,centroid:s,rx:p,ry:p,xAxisRotation:y,sweep:o,largeArc:g,deltaAngle:i,startAngle:u,endAngle:h}),1===n.length){let e=oe(c,n[0].cp1,n[0].cp2,x);"Q"===e.type?a=!0:e=n[0],l=e}n.length>1&&(a=!1),a||(l.type="A",l.values=[p,p,y,g,o,x.x,x.y]),l.p0=c,l.p=x,l.extreme=!1,l.corner=!1,r.push(l),t++;continue}}}r.push(l)}return r}function De(e="",{toAbsolute:t=!0,toRelative:a=!0,toShorthands:n=!0,quadraticToCubic:s=!0,arcToCubic:r=!1,cubicToArc:p=!1,simplifyBezier:i=!0,optimizeOrder:u=!0,autoClose:h=!0,removeZeroLength:y=!0,refineClosing:o=!0,removeColinear:c=!0,flatBezierToLinetos:x=!0,revertToQuadratics:f=!0,refineExtremes:g=!0,simplifyCorners:d=!1,fixDirections:m=!1,keepExtremes:v=!0,keepCorners:M=!0,keepInflections:b=!1,addExtremes:A=!1,addSemiExtremes:C=!1,harmonizeCpts:S=!1,toPolygon:w=!1,removeOrphanSubpaths:E=!1,simplifyRound:L=!1,decimals:P=3,autoAccuracy:T=!0,minifyD:I=0,tolerance:D=1,lineToCubic:k=!1,getObject:q=!1}={}){D=Math.max(.1,D);let Q="",z={x:0,y:0,width:0,height:0},$=[],F=[],j=function(e){let t="",a=!0,n={inputType:"",isValid:!0,fileReport:{}};if(Array.isArray(e))return n.inputType="array",Array.isArray(e[0])?2===e[0].length?n.inputType="polyArray":Array.isArray(e[0][0])&&2===e[0][0].length?n.inputType="polyComplexArray":void 0!==e[0][0].x&&void 0!==e[0][0].y&&(n.inputType="polyComplexObjectArray"):void 0!==e[0].x&&void 0!==e[0].y?n.inputType="polyObjectArray":e[0]?.type&&e[0]?.values&&(n.inputType="pathData"),n;if("string"==typeof e){let s=(e=e.trim()).includes("<svg")&&e.includes("</svg"),r=e.startsWith("<symbol")&&e.includes("</symbol"),p=e.startsWith("M")||e.startsWith("m"),i=!isNaN(e.substring(0,1))&&!isNaN(e.substring(e.length-1,e.length)),u=function(e){e=e.trim();let t=/\d/.test(e),l=/[abcdfghijklmnopqrstuvwz]/gi.test(e);return!(!t||l)&&(e.startsWith("[")&&e.endsWith("]"))}(e);if(s){let s=l(e);({isValid:a,log:t}=s),a?n.inputType="svgMarkup":(n.inputType="invalid",n.isValid=!1,n.log=t),n.fileReport=s.fileReport}else if(u)n.inputType="json";else if(r)n.inputType="symbol";else if(p)n.inputType="pathDataString";else if(i)n.inputType="polyString";else{let t=/^(file:|https?:\/\/|\/|\.\/|\.\.\/)/.test(e),l=e.startsWith("data:image");n.inputType=t||l?"url":"string"}return n}return n.inputType=(e.constructor.name||typeof e).toLowerCase(),n}(e),{inputType:B,log:R}=j;if("pathDataString"===B)Q=e;else if("polyString"===B)Q="M"+e;else{if("pathData"!==B)return!1;Q=e}let N={toRelative:a,toShorthands:n,decimals:P},W=ye(Q,{quadraticToCubic:s,toAbsolute:t,arcToCubic:r});W.length,E&&(W=function(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:s=[]}=a,r=e[l+1]?e[l+1]:null;"M"!==n&&"m"!==n||r&&(!r||"Z"!==r.type&&"z"!==r.type)?t.push(a):r&&l++}return t}(W));let J=Z(W),H=J.length,K=[];for(let e=0;e<H;e++){let t=J[e];(c||y)&&(t=ve(t)),u&&(t=Me(t)),c&&(t=me(t,{tolerance:D,flatBezierToLinetos:!1})),(A||C)&&(t=V(t,{tMin:tMin,tMax:tMax,addExtremes:A,addSemiExtremes:C,angles:[30]}));let l=se(t,{detectSemiExtremes:C}),{pathData:a,bb:n,dimA:s}=l;if($.push(n.x,n.x+n.width),F.push(n.y,n.y+n.height),o&&(a=Le(a,{threshold:.001*s})),a=i?le(a,{simplifyBezier:i,keepInflections:b,keepExtremes:v,keepCorners:M,revertToQuadratics:f,tolerance:D}):a,g){a=Ce(a,{threshold:.05*(n.width+n.height),tolerance:D})}if(c&&x&&(a=me(a,{tolerance:D,flatBezierToLinetos:x})),d){a=Ee(a,{threshold:.1*(n.width+n.height),tolerance:D})}L&&(a=Ie(a)),f&&(a=Pe(a,D)),k&&(a=Te(a)),u&&(a=be(a,{autoClose:h})),K.push({pathData:a,bb:n})}let _=Math.min(...$),G=Math.min(...F);z={x:_,y:G,width:Math.max(...$)-_,height:Math.max(...F)-G},u&&(K=z.height>z.width?K.sort((e,t)=>e.bb.y-t.bb.y||e.bb.x-t.bb.x):K.sort((e,t)=>e.bb.x-t.bb.x||e.bb.y-t.bb.y)),W=[],K.forEach(e=>{W.push(...e.pathData)}),T&&(P=function(e){let t=[];for(let l=1,a=e.length;l<a;l++){let a=e[l],{type:n,values:s,p0:r=null,p:p=null,dimA:i=0}=a;s.length&&p&&r&&(i=i||O(r,p),i&&t.push(+i.toFixed(8)))}t=t.sort();let l=t.length,a=t[Math.floor(.5*l)],n=Math.ceil(.25*l),s=.5*(t.slice(0,n).reduce((e,t)=>e+t,0)/n+a),r=s>112.5?0:Math.floor(75/s).toString().length;return Math.min(Math.max(0,r),8)}(W),N.decimals=P),W=he(W,N),W=ve(W);let U=ee(W,I);return q&&(W=W.map(e=>({type:e.type,values:e.values}))),q?W:U}"undefined"!=typeof window&&(window.simplifyPathData=De);export{De as simplifyPathData};
@@ -1,7 +1,7 @@
1
- 'use strict';
2
-
3
- var linkedom = require('linkedom');
4
-
1
+ 'use strict';
2
+
3
+ var linkedom = require('linkedom');
4
+
5
5
  // src/node-dom.js
6
6
 
7
7
 
@@ -15,6 +15,7 @@ if (!globalThis.document) {
15
15
 
16
16
  // install globals BEFORE anything else loads
17
17
  if (!globalThis.DOMParser) {
18
+ //console.log('polyfill parser');
18
19
  globalThis.DOMParser = linkedom.DOMParser;
19
20
  }
20
21
 
@@ -31,7 +32,7 @@ class XMLSerializerPoly {
31
32
 
32
33
  if (!globalThis.XMLSerializer) {
33
34
  globalThis.XMLSerializer = XMLSerializerPoly;
34
- }
35
-
36
- exports.XMLSerializerPoly = XMLSerializerPoly;
37
- exports.document = document;
35
+ }
36
+
37
+ exports.XMLSerializerPoly = XMLSerializerPoly;
38
+ exports.document = document;
package/index.html CHANGED
@@ -15,6 +15,7 @@
15
15
  content="https://herrstrietzel.github.io/svg-path-simplify/demo/img/repository-open-graph-template.png">
16
16
 
17
17
 
18
+ <!--
18
19
  <script type="application/ld+json">
19
20
  {
20
21
  "@context": "https://schema.org",
@@ -25,6 +26,8 @@
25
26
  "description": "A JavaScript library to simplify and optimize SVG path data."
26
27
  }
27
28
  </script>
29
+ -->
30
+
28
31
 
29
32
 
30
33
  <link rel="preload" href="demo/css/IBM-Plex-Sans_static/fonts/IBM-Plex-Sans/IBMPlexSans_latin_400.woff2" as="font"
@@ -67,7 +70,11 @@
67
70
  <script src="demo/samples.js" defer></script>
68
71
 
69
72
  <!-- Md parser -->
73
+ <!--
70
74
  <script src="https://cdn.jsdelivr.net/gh/UmemotoCtrl/mdpjs@0.1.4/js/mdp.min.js" defer></script>
75
+ -->
76
+
77
+ <script src="https://cdn.jsdelivr.net/npm/mdpjs@0.0.5/dist/mdpjs.min.js"></script>
71
78
 
72
79
  <!-- Zip creation -->
73
80
  <script src="https://cdn.jsdelivr.net/npm/uzip@0.20201231.0/UZIP.min.js" async></script>
@@ -76,6 +83,8 @@
76
83
  <!-- UI helpers -->
77
84
 
78
85
 
86
+ <link rel="preload" href="demo/css/app.css" as="style" />
87
+
79
88
  <link rel="preload" href="https://cdn.jsdelivr.net/npm/enhance-inputs@0.4.1/dist/enhanceInputs.min.css"
80
89
  as="style" />
81
90
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/enhance-inputs@0.4.1/dist/enhanceInputs.min.css">
@@ -147,7 +156,7 @@
147
156
 
148
157
 
149
158
  <label>Input SVG
150
- <textarea class="inputSvg code" name="dInput" id="inputSvg" data-tools="size upload copy">m71.72 20.83 0 0c-1.76 .59-3.69 .97-5.79 1.15s-4.68 .26-7.73 .26c5.45 2.46 8.16 6.35 8.16 11.67 0 4.62-1.58 8.39-4.73 11.32s-7.46 4.39-12.9 4.39c-2.11 0-4.07-.3-5.88-.88-.71 .47-1.26 1.1-1.67 1.89s-.61 1.59-.61 2.41c0 2.52 2.02 3.77 6.05 3.77h7.37c3.1 0 5.85 .56 8.25 1.67s4.26 2.64 5.57 4.56 1.98 4.13 1.98 6.59c0 4.5-1.84 7.97-5.53 10.39s-9.07 3.65-16.14 3.65c-4.98 0-8.91-.52-11.81-1.54s-4.95-2.56-6.18-4.61-1.85-4.68-1.85-7.89h5.54 1.75c0 1.87 .35 3.34 1.05 4.43 .7 1.08 1.96 1.9 3.77 2.46s4.39 .83 7.73 .83c4.85 0 8.32-.6 10.39-1.8s3.12-3 3.12-5.4c0-2.16-.82-3.8-2.46-4.91s-3.92-1.67-6.85-1.67h-7.28c-3.92 0-6.89-.83-8.91-2.5s-3.02-3.76-3.02-6.27c0-1.53 .44-2.99 1.31-4.39s2.14-2.66 3.78-3.77c-2.69-1.41-4.67-3.15-5.92-5.23s-1.89-4.6-1.89-7.58c0-3.11 .77-5.89 2.32-8.34s3.69-4.38 6.41-5.75 5.75-2.06 9.08-2.06c3.63 .06 6.67-.08 9.13-.4s4.48-.76 6.1-1.31 3.58-1.36 5.92-2.42l0.88 2.71 .88 2.7 .61 1.87zm-30.58 5.49c-1.67 1.9-2.51 4.4-2.51 7.5 0 3.16 .85 5.69 2.55 7.59s4.1 2.85 7.2 2.85 5.57-.92 7.24-2.76 2.5-4.43 2.5-7.76c0-6.85-3.31-10.27-9.92-10.27-3.04 0-5.4 .95-7.06 2.85z
159
+ <textarea class="inputSvg code" name="dInput" id="inputSvg" data-tools="size upload copy">M13 7 13 9 13 11C13 11.57 12.79 12.07 12.43 12.43 12.07 12.79 11.57 13 11 13L10 13 9.72 13C9.55 12.7 9.3 12.45 9 12.28L9 11 9 9.72C9.6 9.38 10 8.74 10 8 10 6.9 9.1 6 8 6 7.26 6 6.62 6.41 6.28 7L5.5 7 4 7C3.43 7 2.93 6.79 2.57 6.43 2.21 6.07 2 5.57 2 5 2 4.43 2.22 3.93 2.57 3.57 2.93 3.21 3.43 3 4 3L5.5 3 6.28 3C6.62 3.6 7.26 4 8 4 9.1 4 10 3.1 10 2 10 .9 9.1 0 8 0 7.26 0 6.62 .41 6.28 1L5.5 1 4 1C2.88 1 1.88 1.44 1.16 2.16 .44 2.88 0 3.88 0 5 0 6.12 .44 7.12 1.16 7.84 1.88 8.56 2.88 9 4 9L5.5 9 6.28 9C6.45 9.3 6.7 9.55 7 9.72L7 11 7 12.28C6.7 12.45 6.45 12.7 6.28 13L5 13 3.72 13C3.38 12.4 2.74 12 2 12 .9 12 0 12.9 0 14 0 15.1 .9 16 2 16 2.74 16 3.38 15.6 3.72 15L5 15 6.28 15C6.62 15.6 7.26 16 8 16 8.74 16 9.38 15.6 9.72 15L10 15 11 15C12.12 15 13.12 14.56 13.84 13.84 14.56 13.12 15 12.12 15 11L15 9 15 7 14 7 13 7zM8 1C8.55 1 9 1.45 9 2 9 2.55 8.55 3 8 3 7.45 3 7 2.55 7 2 7 1.45 7.45 1 8 1zM2 15C1.45 15 1 14.55 1 14 1 13.45 1.45 13 2 13 2.55 13 3 13.45 3 14 3 14.55 2.55 15 2 15zM8 7C8.55 7 9 7.45 9 8 9 8.55 8.55 9 8 9 7.45 9 7 8.55 7 8 7 7.45 7.45 7 8 7zM8 15C7.45 15 7 14.55 7 14 7 13.45 7.45 13 8 13 8.55 13 9 13.45 9 14 9 14.55 8.55 15 8 15zM14 0C12.9 0 12 .9 12 2 12 3.1 12.9 4 14 4 15.1 4 16 3.1 16 2 16 .9 15.1 0 14 0zM14 3C13.45 3 13 2.55 13 2 13 1.45 13.45 1 14 1 14.55 1 15 1.45 15 2 15 2.55 14.55 3 14 3z
151
160
  </textarea>
152
161
  </label>
153
162
 
@@ -234,9 +243,6 @@
234
243
  <summary class="h3">SVG style optimization</summary>
235
244
  <p>
236
245
  <!--
237
- <label><input type="checkbox" data-type="checkbox-switch" name="convertPathLength"
238
- aria-description="Converts pathLength attribute to absolute dasharray values – many graphic apps han't handle pathLength">convertPathLength</label>
239
-
240
246
  -->
241
247
  <label><input type="checkbox" data-type="checkbox-switch" name="stylesToAttributes"
242
248
  aria-description="replaces inline styles with SVG atributes and removes obsolete attributes and styles">stylesToAttributes</label>
@@ -256,6 +262,22 @@
256
262
 
257
263
  </details>
258
264
 
265
+ <details open>
266
+ <summary class="h3">Unit conversion</summary>
267
+
268
+ <p>
269
+ <label><input type="checkbox" data-type="checkbox-switch" name="convertPathLength"
270
+ aria-description="Converts pathLength attribute to absolute dasharray values – many graphic apps han't handle pathLength">convertPathLength</label>
271
+
272
+ <label><input type="checkbox" data-type="checkbox-switch" name="toAbsoluteUnits"
273
+ aria-description="Converts relative units to absolute">toAbsoluteUnits</label>
274
+ </p>
275
+
276
+
277
+
278
+ </details>
279
+
280
+
259
281
 
260
282
  <details open class="detailsRemoveElAttributes">
261
283
  <summary class="h3">Child attributes</summary>
@@ -487,6 +509,15 @@
487
509
  <label><input type="checkbox" data-type="checkbox-switch"
488
510
  aria-description="replaces Bézier segments enclosed by linetos with single quadratic commands – handy to reduce overly complex tiny corner roundings"
489
511
  name="simplifyCorners">simplifyCorners</label>
512
+
513
+ <label><input type="checkbox" data-type="checkbox-switch"
514
+ aria-description="Will disable curve adjustment for quadratic corner roundings – usually more compact but less accurate"
515
+ name="simplifyQuadraticCorners">simplifyQuadraticCorners</label>
516
+
517
+
518
+
519
+
520
+
490
521
  <label><input type="checkbox" data-type="checkbox-switch"
491
522
  name="simplifyRound">simplifyRound</label>
492
523
  <label><input type="checkbox" data-type="checkbox-switch"
@@ -609,7 +640,7 @@
609
640
  </p>
610
641
 
611
642
  <p>
612
- <label class="wdt-100">decimals <input type="number" name="decimals" min="-1" value="1"
643
+ <label class="wdt-100">decimals <input type="number" name="decimals" min="-1" value="1" step="0.5"
613
644
  aria-description="Manual floating point rounding precision – overriden when autoAccuracy is enabled: -1 means no rounding"></label>
614
645
  </p>
615
646
  </details>
@@ -672,6 +703,10 @@
672
703
  <a href="#" class="a-dialog" data-dialog="#privacy" data-dialog-title="privacy"
673
704
  data-icon="finger-print" title="Privacy"></a>
674
705
 
706
+ <!-- file info -->
707
+ <a href="#" class="a-dialog" id="btnFileInfo" data-dialog="#fileInfo" data-dialog-title="File info"
708
+ data-icon="light-bulb" title="File info and recommendations"></a>
709
+
675
710
 
676
711
  <!-- presets -->
677
712
  <button type="button" class="btn btn-presets" title="Presets" data-icon="gear"
@@ -714,7 +749,7 @@
714
749
  <label><input type="checkbox" data-type="checkbox-switch" name="showMarkers"
715
750
  data-secondary="true" checked>showMarkers</label>
716
751
  <button type="button" class="btn btn-info btn-inline btn-menu btnConfig"
717
- title="Edit marker size" data-icon="gear" data-menu-anchor="menu1"></button>
752
+ title="Edit marker size" data-icon="ellipsis-horizontal" data-menu-anchor="menu1"></button>
718
753
 
719
754
  </span>
720
755
 
@@ -805,8 +840,7 @@
805
840
 
806
841
  <svg id="svg" class="svgO" viewBox="0 0 100 100">
807
842
 
808
- <path id="path1" class="path pathO" d="M54,40.938C68.946,36.071,72.99,30.492,72.992,27
809
- c0.004-5.928-11.632-5.845-1.367,13.938" />
843
+ <path id="path1" class="path pathO" d="M13 7 13 9 13 11C13 11.57 12.79 12.07 12.43 12.43 12.07 12.79 11.57 13 11 13L10 13 9.72 13C9.55 12.7 9.3 12.45 9 12.28L9 11 9 9.72C9.6 9.38 10 8.74 10 8 10 6.9 9.1 6 8 6 7.26 6 6.62 6.41 6.28 7L5.5 7 4 7C3.43 7 2.93 6.79 2.57 6.43 2.21 6.07 2 5.57 2 5 2 4.43 2.22 3.93 2.57 3.57 2.93 3.21 3.43 3 4 3L5.5 3 6.28 3C6.62 3.6 7.26 4 8 4 9.1 4 10 3.1 10 2 10 .9 9.1 0 8 0 7.26 0 6.62 .41 6.28 1L5.5 1 4 1C2.88 1 1.88 1.44 1.16 2.16 .44 2.88 0 3.88 0 5 0 6.12 .44 7.12 1.16 7.84 1.88 8.56 2.88 9 4 9L5.5 9 6.28 9C6.45 9.3 6.7 9.55 7 9.72L7 11 7 12.28C6.7 12.45 6.45 12.7 6.28 13L5 13 3.72 13C3.38 12.4 2.74 12 2 12 .9 12 0 12.9 0 14 0 15.1 .9 16 2 16 2.74 16 3.38 15.6 3.72 15L5 15 6.28 15C6.62 15.6 7.26 16 8 16 8.74 16 9.38 15.6 9.72 15L10 15 11 15C12.12 15 13.12 14.56 13.84 13.84 14.56 13.12 15 12.12 15 11L15 9 15 7 14 7 13 7zM8 1C8.55 1 9 1.45 9 2 9 2.55 8.55 3 8 3 7.45 3 7 2.55 7 2 7 1.45 7.45 1 8 1zM2 15C1.45 15 1 14.55 1 14 1 13.45 1.45 13 2 13 2.55 13 3 13.45 3 14 3 14.55 2.55 15 2 15zM8 7C8.55 7 9 7.45 9 8 9 8.55 8.55 9 8 9 7.45 9 7 8.55 7 8 7 7.45 7.45 7 8 7zM8 15C7.45 15 7 14.55 7 14 7 13.45 7.45 13 8 13 8.55 13 9 13.45 9 14 9 14.55 8.55 15 8 15zM14 0C12.9 0 12 .9 12 2 12 3.1 12.9 4 14 4 15.1 4 16 3.1 16 2 16 .9 15.1 0 14 0zM14 3C13.45 3 13 2.55 13 2 13 1.45 13.45 1 14 1 14.55 1 15 1.45 15 2 15 2.55 14.55 3 14 3z" />
810
844
  <path id="pathS" class="path pathS" d="" />
811
845
 
812
846
  <g id="markers"></g>
@@ -847,20 +881,9 @@
847
881
 
848
882
 
849
883
 
850
- <dialog class="--dialog sr-only" id="about">
851
- <div class="md-cnt" data-md="./docs/api.md">
852
- </div>
853
- </dialog>
854
-
855
- <dialog class="sr-only" id="privacy">
856
- <div class="md-cnt" data-md="./docs/privacy-webapp.md">
857
- </div>
858
- </dialog>
859
-
860
-
861
884
  <!-- menu presets -->
862
885
  <div class="menu menu-presets menu-right-top pdd-1em --menu-active" data-menu="menu2">
863
- <h4 class="h4">Presets</h4>
886
+ <p class="h4">Presets</p>
864
887
 
865
888
  <p>
866
889
  <label>
@@ -968,6 +991,23 @@
968
991
  </div>
969
992
 
970
993
 
994
+ <!-- dialogs -->
995
+ <dialog class="--dialog sr-only" id="about">
996
+ <div class="md-cnt" data-md="./docs/api.md">
997
+ </div>
998
+ </dialog>
999
+
1000
+ <dialog class="sr-only" id="privacy">
1001
+ <div class="md-cnt" data-md="./docs/privacy-webapp.md">
1002
+ </div>
1003
+ </dialog>
1004
+
1005
+ <dialog class="sr-only fileInfo" id="fileInfo">
1006
+ <div class="--md-cnt" id="fileInfoReport">
1007
+ </div>
1008
+ </dialog>
1009
+
1010
+
971
1011
 
972
1012
  <!-- menu marker size-->
973
1013
  <div class="menu menu-marker-size menu-top-right --menu-active" data-menu="menu1">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svg-path-simplify",
3
- "version": "0.4.3",
3
+ "version": "0.4.5",
4
4
 
5
5
  "type": "module",
6
6
 
package/src/constants.js CHANGED
@@ -7,6 +7,8 @@ export const rad2Deg = 180/Math.PI
7
7
  export const deg2rad = Math.PI/180
8
8
  export const root2 = 1.4142135623730951
9
9
  export const svgNs = 'http://www.w3.org/2000/svg'
10
+ export const dummySVG = `<svg id="svgInvalid" xmlns="${svgNs}" viewBox="0 0 1 1"><path d="M0 0 h0" /></svg>`
11
+
10
12
 
11
13
  // 1/2.54
12
14
  export const inch2cm = 0.39370078;
@@ -14,3 +16,5 @@ export const inch2cm = 0.39370078;
14
16
  // 1/72
15
17
  export const inch2pt = 0.01388889;
16
18
 
19
+
20
+