svg-path-simplify 0.4.2 → 0.4.4

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 (61) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +7 -4
  3. package/dist/svg-path-simplify.esm.js +3593 -1279
  4. package/dist/svg-path-simplify.esm.min.js +2 -2
  5. package/dist/svg-path-simplify.js +3594 -1278
  6. package/dist/svg-path-simplify.min.js +2 -2
  7. package/dist/svg-path-simplify.pathdata.esm.js +1017 -538
  8. package/dist/svg-path-simplify.pathdata.esm.min.js +2 -2
  9. package/dist/svg-path-simplify.poly.cjs +9 -8
  10. package/docs/privacy-webapp.md +24 -0
  11. package/index.html +331 -152
  12. package/package.json +1 -1
  13. package/src/constants.js +4 -0
  14. package/src/css_parse.js +317 -0
  15. package/src/detect_input.js +76 -28
  16. package/src/index.js +8 -0
  17. package/src/pathData_simplify_cubic.js +26 -16
  18. package/src/pathData_simplify_harmonize_cpts.js +77 -1
  19. package/src/pathData_simplify_revertToquadratics.js +0 -1
  20. package/src/pathSimplify-main.js +304 -276
  21. package/src/pathSimplify-only-pathdata.js +7 -2
  22. package/src/pathSimplify-presets.js +254 -0
  23. package/src/poly-fit-curve-schneider.js +14 -7
  24. package/src/simplify_poly_RC.js +102 -0
  25. package/src/simplify_poly_RDP.js +109 -1
  26. package/src/simplify_poly_radial_distance.js +3 -3
  27. package/src/string_helpers.js +130 -4
  28. package/src/svg-getAttributes.js +4 -2
  29. package/src/svgii/convert_units.js +1 -1
  30. package/src/svgii/geometry.js +322 -5
  31. package/src/svgii/geometry_bbox_element.js +1 -1
  32. package/src/svgii/geometry_deduceRadius.js +116 -27
  33. package/src/svgii/geometry_length.js +253 -0
  34. package/src/svgii/pathData_analyze.js +18 -0
  35. package/src/svgii/pathData_convert.js +193 -89
  36. package/src/svgii/pathData_fix_directions.js +12 -14
  37. package/src/svgii/pathData_fromPoly.js +3 -3
  38. package/src/svgii/pathData_getLength.js +86 -0
  39. package/src/svgii/pathData_parse.js +2 -0
  40. package/src/svgii/pathData_parse_els.js +66 -68
  41. package/src/svgii/pathData_reorder.js +122 -16
  42. package/src/svgii/pathData_simplify_refineCorners.js +130 -35
  43. package/src/svgii/pathData_simplify_refine_round.js +420 -0
  44. package/src/svgii/pathData_split_to_groups.js +168 -0
  45. package/src/svgii/pathData_stringify.js +26 -64
  46. package/src/svgii/pathData_toPolygon.js +3 -4
  47. package/src/svgii/poly_analyze.js +61 -0
  48. package/src/svgii/poly_normalize.js +11 -2
  49. package/src/svgii/poly_to_pathdata.js +85 -24
  50. package/src/svgii/rounding.js +80 -78
  51. package/src/svgii/svg_cleanup.js +421 -619
  52. package/src/svgii/svg_cleanup_convertPathLength.js +39 -0
  53. package/src/svgii/svg_cleanup_general_svg_atts.js +97 -0
  54. package/src/svgii/svg_cleanup_normalize_transforms.js +83 -0
  55. package/src/svgii/svg_cleanup_remove_els_and_atts.js +77 -0
  56. package/src/svgii/svg_cleanup_ungroup.js +36 -0
  57. package/src/svgii/svg_el_parse_style_props.js +72 -47
  58. package/src/svgii/svg_getElementLength.js +67 -0
  59. package/src/svgii/svg_validate.js +220 -0
  60. package/tests/testSVG.js +14 -1
  61. package/src/svgii/pathData_refine_round.js +0 -222
@@ -1,3 +1,3 @@
1
- function e(e,t,l="red",a="1%",n="1",r="",s=!0,p="",u=""){Array.isArray(t)&&(t={x:t[0],y:t[1]});let i=`<circle class="${u}" opacity="${n}" id="${p}" cx="${t.x}" cy="${t.y}" r="${a}" fill="${l}">\n <title>${r}</title></circle>`;if(!s)return i;e.insertAdjacentHTML("beforeend",i)}function t(e,t="",l="green",a="1%",n="1",r=!0){let s=`<path d="${t}" fill="none" stroke="${l}" stroke-width="${a}" stroke-opacity="${n}" /> `;if(!r)return s;e.insertAdjacentHTML("beforeend",s)}const{abs:l,acos:a,asin:n,atan:r,atan2:s,ceil:p,cos:u,exp:i,floor:y,log:h,max:o,min:c,pow:x,random:f,round:g,sin:d,sqrt:M,tan:v,PI:m}=Math;function b(e,t,l=!1){let a=s(t.y-e.y,t.x-e.x);return l&&a<0&&(a+=2*Math.PI),a}function A(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 C(e=null,t=null,l=null,a=null,n=!0,r=!1,s=!1){let p,u,i,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}u=e.y-l.y,i=e.x-l.x,y=(a.x-l.x)*u-(a.y-l.y)*i,h=(t.x-e.x)*u-(t.y-e.y)*i,u=y/p,i=h/p,o={x:e.x+u*(t.x-e.x),y:e.y+u*(t.y-e.y)};let c=!1;return u>0&&u<1&&i>0&&i<1&&(c=!0),!n&&r&&(u>0&&i<0||u<0&&i>0)?(c=!1,!1):!(n&&!c)&&o}function L(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=b(e,t),n.angle<0&&(n.angle+=2*m)),n}function w(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],u=e[e.length-1],i={x:0,y:0};if(l||a){let e,l,y,h,o,c=r.x===s.x&&r.y===s.y,x=u.x===p.x&&u.y===p.y;0!==t||c?1!==t||x?(c&&(t+=1e-7),x&&(t-=1e-7),e=L(r,s,t),n?(l=L(s,p,t),y=L(p,u,t),h=L(e,l,t),o=L(l,y,t),i=L(h,o,t),i.angle=b(h,o),a&&(i.cpts=[l,y,h,o])):(l=L(r,s,t),y=L(s,u,t),i=L(l,y,t),i.angle=b(l,y),a&&(i.cpts=[l,y]))):(i.x=u.x,i.y=u.y,i.angle=b(p,u)):(i.x=r.x,i.y=r.y,i.angle=b(r,s))}else{let e=1-t;i=n?{x:e**3*r.x+3*e**2*t*s.x+3*e*t**2*p.x+t**3*u.x,y:e**3*r.y+3*e**2*t*s.y+3*e*t**2*p.y+t**3*u.y}:{x:e*e*r.x+2*e*t*s.x+t**2*u.x,y:e*e*r.y+2*e*t*s.y+t**2*u.y}}return i})(e,t,l):L(e[0],e[1],t,l),l&&r.angle<0&&(r.angle+=2*m),n?[r.x,r.y]:r}function P(e,t,a,n,r,p,u,i,y){const h=(e,t,l,a)=>s(a-t,l-e);let o={cx:0,cy:0,rx:a=l(a),ry:n=l(n),startAngle:0,endAngle:0,deltaAngle:0,clockwise:u,xAxisRotation:r,largeArc:p,sweep:u};if(0==a||0==n)throw Error("rx and ry can not be 0");if(a===n){let l=Math.abs(i-e),a=Math.abs(y-t),n=l,r=Math.min(e,i),s=Math.min(t,y),p=.5*Math.PI;if(0===l&&a||0===a&&l)return n=0===l&&a?a/2:l/2,o.rx=n,o.ry=n,0===l&&a?(o.cx=e,o.cy=s+a/2,o.startAngle=t>y?p:-p,o.endAngle=t>y?-p:p,o.deltaAngle=u?Math.PI:-Math.PI):0===a&&l&&(o.cx=r+l/2,o.cy=t,o.startAngle=e>i?Math.PI:0,o.endAngle=e>i?-Math.PI:Math.PI,o.deltaAngle=u?Math.PI:-Math.PI),o}let c,x,f=a===n?0:r*m/180,g=f?Math.sin(f):0,d=f?Math.cos(f):1,M=(e-i)/2,v=(t-y)/2,b=(e+i)/2,A=(t+y)/2,C=f?d*M+g*v:M,L=f?d*v-g*M:v,w=C*C/(a*a)+L*L/(n*n);w>1&&(a*=Math.sqrt(w),n*=Math.sqrt(w),o.rx=a,o.ry=n);let P=a*n,S=a*L,E=n*C,I=S**2+E**2;if(!I)throw Error("start point can not be same as end point");let k=Math.sqrt(Math.abs((P*P-I)/I));p==u&&(k=-k);let D=k*S/n,$=-k*E/a;c=f?d*D-g*$+b:b+D,x=f?g*D+d*$+A:A+$,o.cy=x,o.cx=c;let Q=h(c,x,e,t),T=h(c,x,i,y);!u&&T>Q&&(T-=2*Math.PI),u&&Q>T&&(T=T<=0?T+2*Math.PI:T);let z=T-Q;return o.startAngle=Q,o.endAngle=T,o.deltaAngle=z,o}function S(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 E(e,t,l,a,n,s=0,p=!0,i=!1){if(n=i?n*m/180:n,s=i?s*m/180:s,s=l!==a&&s!==2*m?s:0,p&&l!==a){let e=r(v(n=s?n-s:n)*(l/a));n=u(n)<0?e+m:e}let y=e+l*u(n),h=t+a*d(n),o={x:y,y:h};return s&&(o.x=e+(y-e)*u(s)-(h-t)*d(s),o.y=t+(y-e)*d(s)+(h-t)*u(s)),o}function I(e,t,l){if(t===l||e%m*.5==0)return e;let a=r(v(e)*(t/l));return a=u(e)<0?a+m:a,a}function k(e=null,t=[]){e||(e=t[0],t=t.slice(1,t.length));let l=t.length,a=t[l-1],n=t[0],r=3===l?t[1]:n,s=Math.min(e.y,a.y),p=Math.min(e.x,a.x),u=Math.max(e.x,a.x),i=Math.max(e.y,a.y);return!(n.y>=s&&n.y<=i&&r.y>=s&&r.y<=i&&n.x>=p&&n.x<=u&&r.x>=p&&r.x<=u)}function D(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,u,i,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),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,L,w,P,S=[];for(let e=0;e<2;++e)if(0==e?(m=6*p-12*i+6*h,v=-3*p+9*i-9*h+3*c,b=3*i-3*p):(m=6*u-12*y+6*o,v=-3*u+9*y-9*o+3*x,b=3*y-3*u),Math.abs(v)<1e-8){if(Math.abs(m)<1e-8)continue;A=-b/m,0<A&&A<1&&S.push(A)}else w=m*m-4*b*v,w<0?Math.abs(w)<1e-8&&(A=-m/(2*v),0<A&&A<1&&S.push(A)):(P=Math.sqrt(w),C=(-m+P)/(2*v),0<C&&C<1&&S.push(C),L=(-m-P)/(2*v),0<L&&L<1&&S.push(L));let E=S.length;for(;E--;)A=S[E];return S}(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,u,i=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>=i&&t.y<=o&&t.x>=y&&t.x<=h)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)s=0==e?c-2*f+d:x-2*g+M,p=0==e?-2*c+2*f:-2*x+2*g,Math.abs(s)>1e-12&&(u=-p/(2*s),u>0&&u<1&&v.push(u));return v}(e[0],e[1],e[2],{addExtremes:t,addSemiExtremes:l});return a}function $(e,t){const l=(e,t,l,a,n,r)=>{var s=Math.cos(r),p=Math.sin(r),u=a*Math.cos(e),i=n*Math.sin(e);return{x:t+s*u-p*i,y:l+p*u+s*i}};let a,n,r,s,p,u=P(e.x,e.y,t[0],t[1],t[2],t[3],t[4],t[5],t[6]),{rx:i,ry:y,cx:h,cy:o,endAngle:c,deltaAngle:x}=u,f=t[2],g={x:t[5],y:t[6]},d=[g],M=f*Math.PI/180,v=Math.tan(M);p=Math.atan2(-y*v,i);let m=p,b=p+Math.PI,A=Math.atan2(y,i*v),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,i,y,M),$=l(c-.999*x,h,o,i,y,M);return(D.x>E||$.x>E)&&(a=l(m,h,o,i,y,M),d.push(a)),(D.x<S||$.x<S)&&(n=l(b,h,o,i,y,M),d.push(n)),(D.y<I||$.y<I)&&(s=l(C,h,o,i,y,M),d.push(s)),(D.y>k||$.y>k)&&(r=l(A,h,o,i,y,M),d.push(r)),d}function Q(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(S(l,0,0,n))}let u=a?T(...p):z(...p);r.push(...u)}return r=[...new Set(r)].sort(),r}function T(e,t,l,a){if(!k(e,[t,l,a]))return[];let n,r,s,p,u,i,y,h,[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?(r=6*o-12*x+6*g,n=-3*o+9*x-9*g+3*M,s=3*x-3*o):(r=6*c-12*f+6*d,n=-3*c+9*f-9*d+3*v,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),u=(-r+h)/(2*n),u>0&&u<1&&m.push(u),i=(-r-h)/(2*n),i>0&&i<1&&m.push(i));let A=m.length;for(;A--;)p=m[A];return[...new Set(m)].sort()}function z(e,t,l){if(!k(e,[t,l]))return[];let a,n,r,[s,p,u,i,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*u+y:p-2*i+h,n=0==e?-2*s+2*u:-2*p+2*i,Math.abs(a)>1e-12&&(r=-n/(2*a),r>0&&r<1&&o.push(r));return[...new Set(o)].sort()}function q(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 F(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 M(a*a+n*n)}function j(e,t){let l=t.x-e.x,a=t.y-e.y;return l*l+a*a}function R(e,t){return Math.abs(t.x-e.x)+Math.abs(t.y-e.y)}function Z(e,t){return.5*(Math.abs(t.x-e.x)+Math.abs(t.y-e.y))}function O(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 B(e,t){let l,a,n,r,s,p,u=[],i=[],y=e[0],h=e[1],o=e[e.length-2],c=e[e.length-1];return 4===e.length?(l=w([y,h],t),a=w([h,o],t),n=w([o,c],t),r=w([l,a],t),s=w([a,n],t),p=w([r,s],t),u.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}),i.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=w([y,h],t),n=w([h,c],t),p=w([a,n],t),u.push({x:y.x,y:y.y},{x:a.x,y:a.y},{x:p.x,y:p.y}),i.push({x:p.x,y:p.y},{x:n.x,y:n.y},{x:c.x,y:c.y})):2===e.length&&(a=w([y,c],t),u.push({x:y.x,y:y.y},{x:a.x,y:a.y}),i.push({x:a.x,y:a.y},{x:c.x,y:c.y})),[u,i]}function N(e,t,{tMin:l=0,tMax:a=1,addExtremes:n=!0,addSemiExtremes:r=!1}={}){let s=[],p=6===t.length?"C":"Q",u={x:t[0],y:t[1]},i="C"===p?{x:t[2],y:t[3]}:u,y={x:t[4],y:t[5]},h=0;let o="C"===p?[e,u,i,y]:[e,u,y],c=n?D(o,{addExtremes:n,addSemiExtremes:!1}):[],x=r?D(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,u=t.length,i={x:t[u-2],y:t[u-1]};2===t.length?p=[e,i]:4===t.length?(r={x:t[0],y:t[1]},p=[e,r,i]):6===t.length&&(r={x:t[0],y:t[1]},s={x:t[2],y:t[3]},p=[e,r,s,i]);if(l.length)if(1===l.length){let e=B(p,l[0]),t=e[0],a=e[1];n.push(t,a)}else{let e=l[0],t=B(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=B(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 J(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]},u=e.length;for(let i=1;u&&i<u;i++){let u=e[i],{type:y,values:h}=u,o=h.slice(-2);if(o[0],o[1],"C"!==y&&"Q"!==y)r.push(u);else if((a||n)&&("C"===y||"Q"===y)){let e=N(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 H(e=0,t=3){if(!t)return Math.round(e);let l=10**t;return Math.round(e*l)/l}function U(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]=H(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),u={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 u)u[e]=+u[e].toFixed(t);return u}function W(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]},u=s.length?{x:s[s.length-2],y:s[s.length-1]}:"",i=s.length?{x:s[0],y:s[1]}:"";switch(r){case"A":if("function"!=typeof arcToBezier){let e=F(p,u)/2,l=L(p,u,.5),a=E(l.x,l.y,e,e,0),n=E(l.x,l.y,e,e,Math.PI);t.push(a,n,u);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(i,e);break;case"Q":t.push(i)}"z"!==r.toLowerCase()&&t.push(u)}return t}(e),l=V(t);return l}(e);t.push(l)}),t}function G(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],[u,i,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<u&&s>o&&a<i&&p>c&&(x=!0),x}function K(e,t=9){let l=0,a=[],n=O(e),r=n.length>1,s=[];if(r){let e=W(n);e.forEach(function(t,l){for(let l=0;l<e.length;l++){let a=e[l];if(t!=a){G(t,a)&&s.push(l)}}})}return n.forEach((e,t)=>{a=[];let n=0,r=0,p=1,u=[];e.forEach(function(t,l){let[r,s]=[t.type,t.values],p=s.length;if(s.length){let i=(l>0?e[l-1]:e[0]).values,y=i.length,h={x:i[y-2],y:i[y-1]},o={x:s[p-2],y:s[p-1]};if("C"===r||"Q"===r){let e={x:s[0],y:s[1]};u="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}(u));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:u,endAngle:i,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,u,i));c-=Math.abs(X([h,{x:l,y:r},o])),a.push(h,o),n+=c}else a.push(h,o)}});let i=X(a);-1!==s.indexOf(t)&&(p=-1),r=i<0&&n<0?(Math.abs(n)-Math.abs(i))*p:(Math.abs(n)+Math.abs(i))*p,l+=r}),l}function X(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 Y(e,t=0){t=parseFloat(t);let l=e.length,a=t>1,n=!a&&!t,r="",s=e[0].values.join(" "),p=a?"\n":n?"":" ",u=n?"":" ";r=`${e[0].type}${u}${s}${p}`;for(let t=1;t<l;t++){let l=e[t-1],a=e[t],{type:i,values:y}=a;if(s="",!n||"A"!==i&&"a"!==i||(y=[y[0],y[1],y[2],`${y[3]}${y[4]}${y[5]}`,y[6]]),i=n&&l.type===a.type&&"m"!==a.type.toLowerCase()||n&&"M"===l.type&&"L"===a.type?" ":a.type,n){let e=!1;for(let t=0,l=y.length;t<l;t++){let l=y[t],a=l.toString(),n=a.includes(".")&&Math.abs(l)<1;n&&e&&(a=a.replace(/^0\./,".")),!(t>0)||e&&n||(s+=" "),s+=a,e=n}r+=`${i}${u}${s}${p}`}else r+=`${i}${u}${y.join(" ")}${p}`}return n&&(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 _(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=Z(e.p0,e.p)>Z(t.p0,t.p),u=JSON.parse(JSON.stringify(e)),i=JSON.parse(JSON.stringify(t)),y=C(u.p0,u.cp1,i.p,i.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=w([t.p0,t.cp1,t.cp2,t.p],g),M=r(t.p0,t.cp1,t.cp2,t.p,g);g-=c(h(d,e.p0),M)/c(M,M);let v=w([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),P=1-g,S=(E=v,I=o(b,P/3),{x:E.x+I.x,y:E.y+I.y});var E,I;let k=h(m,o(A,P/3)),D={p0:v,cp1:S,cp2:k,p:m,t0:g};p&&(D={p0:m,cp1:k,cp2:S,p:v,t0:g});let $=.5*(1-g),Q=w([D.p0,D.cp1,D.cp2,D.p],$,!1,!0),T=Q.cpts[2],z=C(Q,T,D.p0,y,!1),q=C(Q,T,D.p,y,!1),F=L(D.p0,z,1.333),j=L(D.p,q,1.333);if(C(u.p0,F,i.p,j,!0))return s;D.cp1=F,D.cp2=j;let R=Z(u.p0,D.p0)+Z(i.p,D.p);if(D.p0=u.p0,D.p=i.p,D.extreme=i.extreme,D.corner=i.corner,D.dimA=i.dimA,D.directionChange=i.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,Z(w([D.p0,D.cp1,D.cp2,D.p],t),e.p)>l*a)return s;let y=K([{type:"M",values:[u.p0.x,u.p0.y]},{type:"C",values:[u.cp1.x,u.cp1.y,u.cp2.x,u.cp2.y,u.p.x,u.p.y]},{type:"C",values:[i.cp1.x,i.cp1.y,i.cp2.x,i.cp2.y,i.p.x,i.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=K(h),c=Math.abs(o/y-1);D.error=5*c*a,n&&Y(h),c<.05*a&&(s=[D])}return s}function ee(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 u=e[n-1],i=n<p?e[n]:null,y=i?.type||null,{type:h,values:o,p0:c,p:x,cp1:f=null,cp2:g=null,extreme:d=!1,directionChange:M=!1,corner:v=!1,dimA:m=0}=u;if("C"===h&&"C"===y)if(a&&v||t&&d)s.push(u);else{let y=te(u,i,{tolerance:r}),h=0;if(1===y.length){u=y[0];let i=1;h+=u.error;for(let s=n+1;h<r&&s<p;s++){let n=e[s];if("C"!==n.type||l&&u.directionChange||a&&u.corner||t&&u.extreme)break;let p=te(u,n,{tolerance:r});if(p.length>1)break;h+=.5*p[0].error,i++,u=p[0]}s.push(u),n<p&&(n+=i)}else s.push(u)}else s.push(u)}return s}function te(e,t,{tolerance:l=1}={}){let a=[e,t],n=function(e,t){let l=R(e.cp2,e.p);if(0===l)return 0;let a=R(e.p,t.cp1);if(0===a)return 0;let n=R(e.cp2,t.cp1);return l/n}(e,t);if(!n)return a;let r=R(e.p0,e.p),s=R(t.p0,t.p),p=.08*Math.max(0,Math.min(r,s))*l,u=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),i=w([u.p0,u.cp1,u.cp2,u.p],n),y=R(e.p,i),h=0,o=0,c=!1,x=y;if(y<p){let l=.5*(1+n);if(h=R(w([t.p0,t.cp1,t.cp2,t.p],.5),w([u.p0,u.cp1,u.cp2,u.p],l)),x+=h,h<p){let t=.5*n;o=R(w([e.p0,e.cp1,e.cp2,e.p],.5),w([u.p0,u.cp1,u.cp2,u.p],t)),x+=o,x<p&&(c=!0)}}return c&&(u.p0=e.p0,u.p=t.p,u.dimA=R(u.p0,u.p),u.type="C",u.extreme=t.extreme,u.directionChange=t.directionChange,u.corner=t.corner,u.values=[u.cp1.x,u.cp1.y,u.cp2.x,u.cp2.y,u.p.x,u.p.y],u.error=x/p,a=[u]),a}function le(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))]),u=new Set([...e.map(e=>+e.y.toFixed(8))]);if(1===p.size||1===u.size)return!l||n;let i=j(r,s),y=i/1e3*t,h=X(e,!0);return h<y&&(a=!0),l&&(n.flat=a,n.steepness=h/i*10),l?n:a}function ae(t=[],{detectExtremes:l=!0,detectCorners:a=!0,detectDirection:n=!0,detectSemiExtremes:r=!1,debug:s=!1,addSquareLength:p=!0,addArea:u=!0}={}){t=function(e,{addSquareLength:t=!0,addArea:l=!1,addArcParams:a=!1,addAverageDim:n=!0}={}){let r=e[0],s={x:r.values[0],y:r.values[1]},p=s,u=s;r.p0=p,r.p=u,r.idx=0,r.dimA=0;let i=e.length,y=[r];for(let n=1;n<i;n++){let r,i,h=e[n],{type:o,values:c}=h,x=c.length;if(u=x?{x:c[x-2],y:c[x-1]}:s,h.p0=p,h.p=u,h.dimA=R(p,u),"M"===o&&(s=u),"Q"===o||"C"===o)r={x:c[0],y:c[1]},i="C"===o?{x:c[2],y:c[3]}:null,h.cp1=r,i&&(h.cp2=i);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!==u.x&&s.y!==u.y&&(h.closePath=!0),t&&(h.squareDist=j(p,u)),l){let e=0;"C"===o&&(e=X([p,r,i,u],!1)),"Q"===o&&(e=X([p,r,u],!1)),h.cptArea=e}h.idx=n,p=u,y.push(h)}return y}(t,{addSquareLength:p,addArea:u});let i=[],y=function(e){let t=[],l={x:e[0].values[0],y:e[0].values[1]};return e.forEach(e=>{let{type:a,values:n}=e;if(n.length){let e=n.length>1?{x:n[n.length-2],y:n[n.length-1]}:"V"===a?{x:l.x,y:n[0]}:{x:n[0],y:l.y};t.push(e),l=e}}),t}(t),h=V(y),{left:o,right:c,top:x,bottom:f,width:g,height:d}=h;t[0].corner=!1,t[0].extreme=!1,t[0].semiExtreme=!1,t[0].directionChange=!1,t[0].closePath=!1;let M=[t[0]],v=t.length;for(let e=2;v&&e<=v;e++){let l=t[e-1],{type:a,values:n,p0:s,p:p,cp1:u=null,cp2:i=null,squareDist:y=0,cptArea:h=0,dimA:g=0}=l,d=t[e]||null;l.corner=!1,l.extreme=!1,l.semiExtreme=!1,l.directionChange=!1,l.closePath=!1;let v="C"===a||"Q"===a?"C"===a?[s,u,i,p]:[s,u,p]:[s,p],m=.1*g,A=.01*m,C="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+1;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.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(C){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)&&(w=!0),(u.x===s.x&&u.y!==s.y||u.y===s.y&&u.x!==s.x)&&(M[M.length-1].extreme=!0),p.x!==o&&p.y!==x&&p.x!==c&&p.y!==f||(w=!0),!w){if(k(null,v)){let e=Q(v);e.length&&e[0]>.2&&(w=!0)}}}if(w&&(l.extreme=!0),C&&L){if(r&&!l.extreme){let e=Math.abs(p.x-i.x),t=Math.abs(p.y-i.y),a=!1;if(e&&t&&e>m||t>m){let e=b(i,p),t=b(p,d.cp1);a=q(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=i||u,t=d.cp1,a=X([e,p,t],!1),n=.01*j(e,t),r=Math.abs(a)<n,s=a<0&&l.cptArea>0||a>0&&l.cptArea<0;!r&&s&&(l.corner=!0)}}M.push(l)}return s&&M.forEach(t=>{t.directionChange&&e(markers,t.p,"orange","1.5%","0.5"),t.corner&&e(markers,t.p,"magenta","1.5%","0.5"),t.extreme&&e(markers,t.p,"cyan","1%","0.5")}),i={pathData:M,bb:h,dimA:(g+d)/2},i}const ne=new Set([77,109,65,97,67,99,76,108,81,113,83,115,84,116,72,104,86,118,90,122]),re=new Uint8Array(128);re[77]=2,re[109]=2,re[65]=7,re[97]=7,re[67]=6,re[99]=6,re[76]=2,re[108]=2,re[81]=4,re[113]=4,re[83]=4,re[115]=4,re[84]=2,re[116]=2,re[72]=1,re[104]=1,re[86]=1,re[118]=1,re[90]=0,re[122]=0;const se=new Set([5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279]),pe=e=>32===e||44===e||10===e||13===e||8232===e||8233===e||9===e||11===e||12===e||160===e||e>=5760&&se.has(e);function ue(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,u=s?e:function(e,t=!0,l=0){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="",u=-1,i="",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:[]}),u++,o=0,x=!1)},d=(e=!1)=>{(e?h>0:""!==i)&&(t&&-1===u&&(n="Pathdata must start with M command",a.log.push(n),p="M",a.pathData.push({type:p,values:[]}),c=2,o=0,u++),"A"===p||"a"===p?(({val:i,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}})(i,o)),a.pathData[u].values.push(...i)):(t&&i[1]&&"."!==i[1]&&"0"===i[0]&&(n=`${u}. command: Leading zeros not valid: ${i}`,a.log.push(n)),a.pathData[u].values.push(+i)),o++,i="",h=0,x=o>=c)},M=()=>{if(u>0){let e=a.pathData[u].values.length;(e&&e<c||e&&e>c||("z"===p||"Z"===p)&&e>0)&&(n=`${u}. 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(;r<s;){A=e.charCodeAt(r);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(y||45!==A&&46!==A)g();else{let e=46===A;d(e),g(),e&&h++}i+=e[r],y=v,r++}else if((A<48||A>5759)&&pe(A))d(),r++;else{if(A>64){if(!ne.has(A)){n=`${u}. command "${e[r]}" is not a valid type`,a.log.push(n),r++;continue}""!==i&&(a.pathData[u].values.push(+i),o++,i=""),t&&M(),p=e[r],c=re[A];let l="M"===p||"m"===p,s=u>0&&("z"===a.pathData[u].type||"Z"===a.pathData[u].type);f.add(p),s&&!l&&(a.pathData.push({type:"m",values:[0,0]}),u++),a.pathData.push({type:p,values:[]}),u++,h=0,o=0,x=!1,r++;continue}l||(n=`${u}. ${e[r]} is not a valid separarator or token`,a.log.push(n),i=""),r++}}d(),t&&M(),t&&a.log.length&&(n="Invalid path data:\n"+a.log.join("\n"),"log"===t?console.log(n):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:i=!0,hasShorthands:y=!0,hasQuadratics:h=!0,hasArcs:o=!0}=u,c=p?u:u.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:u=!0,hasArcs:i=!0,testTypes:y=!1}={}){return ie(e,{toAbsolute:t,toLonghands:l,quadraticToCubic:a,arcToCubic:n,arcAccuracy:r,hasRelatives:s,hasShorthands:p,hasQuadratics:u,hasArcs:i,testTypes:y,decimals:-1})}(c,{toAbsolute:t,toLonghands:l,quadraticToCubic:a,arcToCubic:n,arcAccuracy:r,hasRelatives:i,hasShorthands:y,hasQuadratics:h,hasArcs:o}),c}function ie(e,{toShorthands:t=!0,toLonghands:l=!1,toRelative:a=!0,toMixed:n=!1,toAbsolute:r=!1,decimals:s=3,arcToCubic:p=!1,quadraticToCubic:u=!1,hasRelatives:i=!0,hasShorthands:y=!0,hasQuadratics:h=!0,hasArcs:o=!0,optimizeArcs:c=!0,testTypes:x=!1}={}){let f=[];if(x){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),isPoly=/[mlz]/gi.test(t)}if(a=!r&&a,t=!l&&t,r&&(e=ce(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?ce(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,u,i,y,h,o,c=e[l],{type:x,values:f}=c,g=f.length,d=r.values,M=d.length,[v,m]=[f[g-2],f[g-1]],[b,A]=[d[M-2],d[M-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[M-2],d[M-1]],p=b+(b-a),u=A+(A-s),r={type:"Q",values:[p,u,v,m]};break;case"S":[a,s]=[d[0],d[1]],[b,A]=[d[M-2],d[M-1]],[h,o]=M>2&&"A"!==r.type?[d[2],d[3]]:[b,A],p=2*b-h,u=2*A-o,i=f[0],y=f[1],r={type:"C",values:[p,u,i,y,v,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)),c&&(e=function(e=[]){let t=[];e.forEach((l,a)=>{let{type:n,values:r}=l;if("A"===n){let[l,n,s,p,u]=[r[0],r[1],r[3],r[5],r[6]],i=e[a-1],[y,h]=[i.values[i.values.length-2],i.values[i.values.length-1]],o={x:y,y:h},c={x:p,y:u};if(0!==l&&0!==n||(e[a]=null,t.push(a)),l>=1&&(p===y||u===h)){if(Math.abs(l-n)/l<.01){let t=F(L(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?oe(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]},u=p;for(let t=1;t<n;t++){let l=e[t];s=l;let{type:a,values:n}=l,i=n.length,y=[n[i-2],n[i-1]],h=e[t-1];u={x:y[0],y:y[1]};let o=Math.abs(u.x-p.x),c=Math.abs(u.y-p.y),x=.01*R(p,u),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*R(e,t),f=R({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:[u.x,u.y]});break;case"C":f&&(s={type:"S",values:[n[2],n[3],u.x,u.y]});break;default:s={type:a,values:n}}p=u,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){fe(p,n.values,t).forEach(e=>{l.push(e)})}else l.push(n)}return l}(e)),h&&u&&(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(he(s,a.values)):t.push(a)}return t}(e)),n&&(a=!0),s>-1&&a&&(e=U(e,s)),n&&(f=JSON.parse(JSON.stringify(e))),a&&(e=function(e,t=-1){return oe(e,!0,t)}(e)),s>-1&&(e=U(e,s)),n)for(let t=0;t<e.length;t++){let l=e[t],a=f[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]=f[t])}return e}function ye(e={},t={},l={},a={},n=1){let r=L(e,t,1.5),s=L(a,l,1.5),p=.01*R(e,a)*n,u=R(r,s),i=null,y={type:"C",values:[t.x,t.y,l.x,l.y,a.x,a.y]};return u<p&&(i=C(e,t,a,l,!1,!0),i&&(y.type="Q",y.values=[i.x,i.y,a.x,a.y],y.p0=e,y.cp1=i,y.cp2=null,y.p=a)),y}function he(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 oe(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,u=s;for(let n=1;n<a;n++){let a=e[n],{type:i,values:y}=a,h=y.length,o=i.toLowerCase(),c=i.toUpperCase(),x=t?o:c;if(i!==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],u=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=u;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),u=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 ce(e,t=-1){return oe(e,!1,t)}function xe({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:u=null,deltaAngle:i=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!==u&&null!==i||({startAngle:p,endAngle:u,deltaAngle:i}=A(l,e,t));let f=a!==n?I(p,a,n):p,g=a!==n?I(i,a,n):i,d=Math.max(1,Math.ceil(Math.abs(g)/h)),M=g/d;for(let e=0;e<d;e++){const e=Math.abs(M)===h?.551785*Math.sign(M):4/3*Math.tan(M/4);let t=Math.cos(f),r=Math.sin(f),s=Math.cos(f+M),p=Math.sin(f+M),u=[];[{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;u.push(c*t-x*r+l.x,x*t+c*r+l.y)}),y.push({type:"C",values:u,cp1:{x:u[0],y:u[1]},cp2:{x:u[2],y:u[3]},p:{x:u[4],y:u[5]}}),f+=M}return y}function fe(e,t,l=1){const a=2*Math.PI;let[n,r,s,p,u,i,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-i)/2+o*(e.y-y)/2,f=-o*(e.x-i)/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,M=n===r?d:r*r,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===u?-1:1));let A=b?b*n/r*f:0,C=b?b*-r/n*x:0,L=c*A-o*C+(e.x+i)/2,w=o*A+c*C+(e.y+y)/2,P=(x-A)/n,S=(f-C)/r,E=(-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,P,S),$=k(P,S,E,I);0===u&&$>0?$-=2*Math.PI:1===u&&$<0&&($+=2*Math.PI);let Q=(+(Math.abs($)/(a/4)).toFixed(0)||1)*l;$/=Q;let T=[];const z=1.5707963267948966,q=.551785;let F=$===z?q:$===-z?-q:4/3*Math.tan($/4),j=$?Math.cos($):1,R=$?Math.sin($):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),u=Math.sin(e+t);return[{x:r-s*l,y:s+r*l},{x:p+u*l,y:u-p*l},{x:p,y:u}]};for(let e=0;e<Q;e++){let e={type:"C",values:[]};Z(D,$,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)}),T.push(e),D+=$}return T}function ge(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,u=e.length;p<u;p++){let i=e[p],y=e[p+1]||e[u-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}=i,x=c.slice(-2);s="Z"!==o?{x:x[0],y:x[1]}:n;let f=h?X([r,s,h],!0):1/0,g=j(r,h),d=f<(g?g/333*t:0),M=!1;if(l||"C"!==o||(d=!1),l&&("C"===o||"Q"===o)){M=le([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}),M&&p<u-1&&(o="L",i.type="L",i.values=x)}d&&p<u-1&&"A"!==y.type&&("L"===o||l&&M)||(r=s,"M"===o&&(n=s),a.push(i))}return a}function de(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:u,values:i}=r,y="m"===s.type.toLowerCase()&&!p,h=i.length;if(l={x:i[h-2],y:i[h-1]},y||"L"!==u||l.x!==t.x||l.y!==t.y){if(!y&&("l"===u||"v"===u||"h"===u)){if("l"===u?"00"===i.join(""):0===i[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?me(e,l):e}function ve(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),u=e[s?n-2:n-1],i=u.type,y=u.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"===u.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,u=e[l-1]?e[l-1].type.toUpperCase():null,i=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:u,nextCom:i};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"===i).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?me(e,c):e}return r={x:+e[0].values[0].toFixed(8),y:+e[0].values[1].toFixed(8)},n=e.length,u=e[n-2],i=u.type,y=u.values.slice(-2).map(e=>+e.toFixed(8)),h="L"===i&&y[0]===r.x&&y[1]===r.y,t&&h&&e.splice(n-2,1),a.push(...e),a}function me(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,[u,i]=[s.values[p-2],s.values[p-1]].map(e=>+e.toFixed(8));!l||n==u&&r==i||(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),u=e.slice(0,l);return u.shift(),r=u[u.length-1].values||[],s=[r[r.length-2],r[r.length-1]],n&&(p.pop(),u.push({type:"Z",values:[]})),e=[{type:"M",values:s},...p,...u]}function be(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,u=p.length;if(s){let e={x:p[u-2],y:p[u-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];D(p).forEach(e=>{let t=w(p,e);r(t)})}else"A"===a&&$(e,n).forEach(e=>{r(e)})}}return{x:t,y:a,width:l-t,height:n-a}}(e);t=.05*(l.width+l.height)}let a=e.length;for(let n=0;n<a;n++){let a=e[n],{type:r,values:s,extreme:p,corner:u=!1,dimA:i,p0:y,p:h}=a,o=e[n+1]?e[n+1]:null,c=e[n+2]?e[n+2]:null,x=(o?R(h,o.p):1/0)<t,f=(c?R(c.p,o.p):1/0)<1*t;if(o&&c&&"C"===r&&"C"===o.type&&p&&c.extreme&&(f||x)){let a=_(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=X([a.p0,a.p,o.p]),t=X([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]},u=r.values.slice(-2),i=+u[0].toFixed(8)===+p.x.toFixed(8)&&+u[1].toFixed(8)===+p.y.toFixed(8),y="C"===e[1].type&&e[1].extreme?e[1]:null,h=R(r.p0,r.p)<t;if(s&&"C"===s.type&&h&&i&&y){let a=_(s,r,t,l,!1);1===a.length&&(e[n-1]=a[0],e[n]=null,e=e.filter(Boolean))}return e}function Ae(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,u=e[a-p],i="L"===u.type,y="C"===u.type,h="L"===e[1].type,o="C"===e[1].type,c=r&&o&&(i||s);c&&(e[a-1].values=e[0].values,e[a-1].type="L",i=!0);for(let t=1;t<a;t++){let s=e[t],{type:u}=s,x=e[t+1]?e[t+1]:null;if("L"===u&&x&&"C"===x.type||"C"===u&&x&&"L"===x.type){let c="L"===u?s:null,f=null,g=[],d=0;if(1===t&&o&&i&&(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=R(c.p0,c.p),a=R(f.p0,f.p),r=R(c.p,f.p0),p=X([c.p0,c.p,f.p0,f.p],!1),u=X([g[0].p0,g[0].cp1,g[0].cp2,g[0].p],!1),i=p<0&&u>0||p>0&&u<0,y=.5*r*l,h=y<e&&y<a;if(g.length&&!i&&h){let e=Math.abs(u)<.005*j(g[0].p0,g[0].p)?null:C(c.p0,c.p,f.p,f.p0,!1,!0);if(!e){n.push(s);continue}if(e){let t=X([c.p0,c.p,f.p0,f.p],!1),l=Math.abs(t),a=X([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*R(w([c.p,e,f.p0],.5),1===g.length?w([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"===u||n.push(s)}return(c||r&&"Z"!==n[n.length-1].type)&&n.push({type:"Z",values:[]}),n}function Ce(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,u=a.x,i=a.y,y=n-s,h=r-p,o=n-u,c=r-i,x=(n*n-s*s+(r*r-p*p))/2,f=(n*n-u*u+(r*r-i*i))/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},M=F(d,t),v=A(d,t,a),{deltaAngle:m,startAngle:b,endAngle:C}=v;return{centroid:d,r:M,startAngle:b,endAngle:C,deltaAngle:m}}function Le(e,{threshold:l=0,tolerance:a=1,toCubic:n=!1,debug:r=!1}={}){let s=e.length,p=[e[0]],u=[];for(let l=1;l<s;l++){let a=e[l],{type:s}=a,i=e[l-1],y=e[l+1]?e[l+1]:null,h=e[l+2]?e[l+2]:null,o=e[l+3]?e[l+3]:null,c=null;"C"===a.type||"Q"===a.type?c=a:!y||"C"!==y.type&&"Q"!==y.type||(c=y);let x,f,g,d,M,v=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"===i.type&&"L"===s&&c&&"L"===h.type&&o&&("L"===o.type||"Z"===o.type)?(x=[a.p0,a.p],f=[h.p0,h.p],g=a.p0,d=h.p,m=X(v,!1),b=X([...x,...f],!1),A=m<0&&b>0||m>0&&b<0,A||(M=w(v,.5),L=[g,M,d],C=!0)):"C"!==s&&"Q"!==s||"L"!==i.type||"C"!==y.type&&"Q"!==y.type||"L"!==h.type||(C=!0,x=[i.p0,i.p],f=[h.p0,h.p],g=i.p,d=h.p0,M=c.p,L=[g,c.p,d]),C){let e=Ce(L);if(e){let s,{centroid:i,r:y,deltaAngle:h,startAngle:o,endAngle:c}=e,x=0,f=h>0?1:0,v=Math.abs(h)>Math.PI?1:0;if(Z(S(g,i.x,i.y,.5*h),M)<.05*Z(g,d)){if(s=xe({p0:g,p:d,centroid:i,rx:y,ry:y,xAxisRotation:x,sweep:f,largeArc:v,deltaAngle:h,startAngle:o,endAngle:c}),1===s.length){let e=ye(g,s[0].cp1,s[0].cp2,d);"Q"===e.type&&(n=!0),a=e}if(s.length>1&&(n=!1),n||(a.type="A",a.values=[y,y,x,v,f,d.x,d.y]),a.p0=g,a.p=d,a.extreme=!1,a.corner=!1,r){u=n?[{type:"M",values:[g.x,g.y]},...s]:[{type:"M",values:[g.x,g.y]},{type:"A",values:[y,y,x,v,f,d.x,d.y]}];let e=Y(u);t(markers,e,"orange","0.5%","0.5")}p.push(a),l++;continue}}}p.push(a)}return p}function we(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]},u=Z(p,{x:s[0],y:s[1]});if(u&&u<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]),u=Math.abs(e[1].values[0]-a.values[0]),i=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=i<t&&h<t&&l;l&&l<t&&(u<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:u=null,p:i=null}=a;if("C"===n){let n=ye(s,p,u,i,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 Se(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:u=null}=l;if("L"===a){let l=L(r,u,.333),a=L(u,r,.333);e[t].type="C",e[t].values=[l.x,l.y,a.x,a.y,u.x,u.y],e[t].cp1=l,e[t].cp2=a}}return e}function Ee(e="",{toAbsolute:t=!0,toRelative:l=!0,toShorthands:a=!0,quadraticToCubic:n=!0,arcToCubic:r=!1,cubicToArc:s=!1,simplifyBezier:p=!0,optimizeOrder:u=!0,autoClose:i=!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:M=!0,keepCorners:v=!0,keepInflections:m=!1,addExtremes:b=!1,addSemiExtremes:A=!1,harmonizeCpts:C=!1,toPolygon:L=!1,removeOrphanSubpaths:w=!1,simplifyRound:P=!1,decimals:S=3,autoAccuracy:E=!0,minifyD:I=0,tolerance:k=1,lineToCubic:D=!1,getObject:$=!1}={}){k=Math.max(.1,k);let Q="",T={x:0,y:0,width:0,height:0},z=[],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("M")||e.startsWith("m"),n=!isNaN(e.substring(0,1))&&!isNaN(e.substring(e.length-1,e.length));if(l)t="svgMarkup";else if(a)t="pathDataString";else if(n)t="polyString";else{let l=/^(file:|https?:\/\/|\/|\.\/|\.\.\/)/.test(e),a=e.startsWith("data:image");t=l||a?"url":"string"}return t}return t=typeof e,(e.constructor.name||t).toLowerCase()}(e);if("pathDataString"===F)Q=e;else if("polyString"===F)Q="M"+e;else{if("pathData"!==F)return!1;Q=e}let j={toRelative:l,toShorthands:a,decimals:S},Z=ue(Q,{quadraticToCubic:n,toAbsolute:t,arcToCubic:r});Z.length,w&&(Z=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}(Z));let B=O(Z),N=B.length,H=[];for(let e=0;e<N;e++){let t=B[e];(o||y)&&(t=de(t)),u&&(t=Me(t)),o&&(t=ge(t,{tolerance:k,flatBezierToLinetos:!1})),(b||A)&&(t=J(t,{tMin:tMin,tMax:tMax,addExtremes:b,addSemiExtremes:A,angles:[30]}));let l=ae(t,{detectSemiExtremes:A}),{pathData:a,bb:n,dimA:r}=l;if(z.push(n.x,n.x+n.width),q.push(n.y,n.y+n.height),h&&(a=we(a,{threshold:.001*r})),a=p?ee(a,{simplifyBezier:p,keepInflections:m,keepExtremes:M,keepCorners:v,revertToQuadratics:x,tolerance:k}):a,f){a=be(a,{threshold:.05*(n.width+n.height),tolerance:k})}if(o&&c&&(a=ge(a,{tolerance:k,flatBezierToLinetos:c})),g){a=Ae(a,{threshold:.1*(n.width+n.height),tolerance:k})}P&&(a=Le(a)),x&&(a=Pe(a,k)),D&&(a=Se(a)),u&&(a=ve(a,{autoClose:i})),H.push({pathData:a,bb:n})}let U=Math.min(...z),V=Math.min(...q);T={x:U,y:V,width:Math.max(...z)-U,height:Math.max(...q)-V},u&&(H=T.height>T.width?H.sort((e,t)=>e.bb.y-t.bb.y||e.bb.x-t.bb.x):H.sort((e,t)=>e.bb.x-t.bb.x||e.bb.y-t.bb.y)),Z=[],H.forEach(e=>{Z.push(...e.pathData)}),E&&(S=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:u=0}=a;r.length&&p&&s&&(u=u||R(s,p),u&&t.push(u))}let l=t.sort(),a=Math.ceil(l.length/8);l=l.slice(0,a);let n=l.reduce((e,t)=>e+t,0)/a,r=n>112.5?0:Math.floor(75/n).toString().length;return Math.min(Math.max(0,r),8)}(Z),j.decimals=S),Z=ie(Z,j),Z=de(Z);let W=Y(Z,I);return $&&(Z=Z.map(e=>({type:e.type,values:e.values}))),$?Z:W}"undefined"!=typeof window&&(window.simplifyPathData=Ee);export{Ee 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],y:s[r-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=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))}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,s=n>112.5?0:Math.floor(75/n).toString().length;return Math.min(Math.max(0,s),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;
@@ -0,0 +1,24 @@
1
+ ### Simplification
2
+
3
+ Enter your SVG pathData or complete file markup or upload SVG files.
4
+
5
+ All data is processed 100% client-side – no data is transferred or analyzed by any third-party service during simplification.
6
+
7
+ ### Sharing and editing
8
+
9
+ * Codepen – sends your current data to [codepen.io](https://codepen.io) and creates a new pen for testing purposes
10
+ * Edit – sends data to [svg-path-editor](https://yqnn.github.io/svg-path-editor) for further path node editing
11
+
12
+ ### External scripts
13
+
14
+ The webapp loads these external scripts from jsdelivr
15
+
16
+ * [linkedom](https://github.com/WebReflection/linkedom) – used for web worker based multi file processing
17
+ * [UZIP](https://github.com/photopea/UZIP.js) – for multifile zip exports
18
+ * [enhance-inputs](https://github.com/herrstrietzel/enhance-inputs) – used for GUI input styling and updating logic
19
+
20
+ ### Local Storage
21
+
22
+ Your current settings as well as your input SVG data is stored in local Storage. This provides to apply the same settings to multiple files after reloads. You can delete this settings cache via the reset settings button.
23
+
24
+ You image data is never transferred to the github server.