svg-path-simplify 0.2.4 → 0.2.6
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.
- package/dist/svg-path-simplify.esm.js +4 -4
- package/dist/svg-path-simplify.esm.min.js +1 -1
- package/dist/svg-path-simplify.js +4 -4
- package/dist/svg-path-simplify.min.js +1 -1
- package/dist/svg-path-simplify.min.js.gz +0 -0
- package/package.json +1 -1
- package/src/pathData_simplify_revertToquadratics.js +2 -2
- package/src/pathSimplify-main.js +1 -1
- package/tests/testSVG.js +1 -0
|
@@ -7688,14 +7688,14 @@ function renderChunks(chunks) {
|
|
|
7688
7688
|
}
|
|
7689
7689
|
}
|
|
7690
7690
|
|
|
7691
|
-
function pathDataRevertCubicToQuadratic(pathData) {
|
|
7691
|
+
function pathDataRevertCubicToQuadratic(pathData, tolerance=1) {
|
|
7692
7692
|
|
|
7693
7693
|
for (let c = 1, l = pathData.length; c < l; c++) {
|
|
7694
7694
|
let com = pathData[c];
|
|
7695
7695
|
let { type, values, p0, cp1 = null, cp2 = null, p = null } = com;
|
|
7696
7696
|
if (type === 'C') {
|
|
7697
7697
|
|
|
7698
|
-
let comQ = revertCubicQuadratic(p0, cp1, cp2, p);
|
|
7698
|
+
let comQ = revertCubicQuadratic(p0, cp1, cp2, p, tolerance);
|
|
7699
7699
|
if (comQ.type === 'Q') {
|
|
7700
7700
|
comQ.extreme = com.extreme;
|
|
7701
7701
|
comQ.corner = com.corner;
|
|
@@ -8679,12 +8679,12 @@ function svgPathSimplify(input = '', {
|
|
|
8679
8679
|
let threshold = (bb.width + bb.height) * 0.1;
|
|
8680
8680
|
pathData = refineRoundedCorners(pathData, { threshold, tolerance });
|
|
8681
8681
|
}
|
|
8682
|
-
|
|
8682
|
+
|
|
8683
8683
|
// refine round segment sequences
|
|
8684
8684
|
if (simplifyRound) pathData = refineRoundSegments(pathData);
|
|
8685
8685
|
|
|
8686
8686
|
// simplify to quadratics
|
|
8687
|
-
if (revertToQuadratics) pathData = pathDataRevertCubicToQuadratic(pathData);
|
|
8687
|
+
if (revertToQuadratics) pathData = pathDataRevertCubicToQuadratic(pathData, tolerance);
|
|
8688
8688
|
|
|
8689
8689
|
// optimize close path
|
|
8690
8690
|
if (optimizeOrder) pathData = optimizeClosePath(pathData, { autoClose });
|
|
@@ -8,4 +8,4 @@ o=i[0]}s.push(o),n<i&&(n+=p)}else s.push(o)}else s.push(o)}return s}function be(
|
|
|
8
8
|
//!isFlat &&
|
|
9
9
|
if(C){let e="C"===n?Math.abs(l.cp2.x-l.p.x):Math.abs(l.cp1.x-l.p.x),t="C"===n?Math.abs(l.cp2.y-l.p.y):Math.abs(l.cp1.y-l.p.y);if((0===t&&e>0||0===e&&t>0)&&(k=!0),p.x!==h&&p.y!==c&&p.x!==y&&p.y!==x||(k=!0),!k){if(Y(null,b)){let e=ee(b);e.length&&e[0]>.15&&(k=!0)}}}if(k&&(l.extreme=!0),C&&w){if(r&&!l.extreme){let e=Math.abs(p.x-f.x),t=Math.abs(p.y-f.y),a=!1;if(e&&t&&e>A||t>A){let e=G(f,p),t=G(p,M.cp1);a=le(Math.abs(e+t)/2)}a&&(l.semiExtreme=!0)}if((l.cptArea<0&&M.cptArea>0||l.cptArea>0&&M.cptArea<0)&&(l.directionChange=!0),!l.extreme){let e=f||u,t=M.cp1,a=me([e,p,t],!1),n=.01*re(e,t),r=Math.abs(a)<n,s=a<0&&l.cptArea>0||a>0&&l.cptArea<0;!r&&s&&(l.corner=!0)}}s&&(l.directionChange&&e(markers,l.p,"orange","1.5%","0.5"),l.corner&&e(markers,l.p,"magenta","1.5%","0.5"),l.extreme&&e(markers,l.p,"cyan","1%","0.5")),m.push(l)}return p={pathData:m,bb:u,dimA:(f+g)/2},p}function Le(e={},t={},a={},l={},n=1){let r=Z(e,t,1.5),s=Z(l,a,1.5),i=.01*se(e,l)*n,o=se(r,s),p=null,u={type:"C",values:[t.x,t.y,a.x,a.y,l.x,l.y]};return o<i&&(p=U(e,t,l,a,!1),p&&(u.type="Q",u.values=[p.x,p.y,l.x,l.y],u.p0=e,u.cp1=p,u.cp2=null,u.p=l)),u}function Pe(e,{toShorthands:t=!0,toLonghands:a=!1,toRelative:l=!0,toAbsolute:n=!1,decimals:r=3,arcToCubic:s=!1,quadraticToCubic:i=!1,hasRelatives:o=!0,hasShorthands:p=!0,hasQuadratics:u=!0,hasArcs:h=!0,testTypes:y=!1}={}){if(y){let t=Array.from(new Set(e.map(e=>e.type))).join("");/[lcqamts]/gi.test(t),u=/[qt]/gi.test(t),h=/[a]/gi.test(t),p=/[vhst]/gi.test(t),isPoly=/[mlz]/gi.test(t)}return l=!n&&l,t=!a&&t,u&&i&&(e=Te(e)),h&&s&&(e=Se(e)),t&&(e=function(e,t=-1,a=!1){let l;if(a){let t=e.map(e=>e.type).join("");l=/[astvqmhlc]/g.test(t)}e=a&&l?Fe(e):e;let n=e.length,r=new Array(n),s=e[0];r[0]=s;let i={x:e[0].values[0],y:e[0].values[1]},o=i;for(let t=1;t<n;t++){let a=e[t];s=a;let{type:l,values:n}=a,p=n.length,u=[n[p-2],n[p-1]],h=e[t-1];o={x:u[0],y:u[1]};let y=Math.abs(o.x-i.x),c=Math.abs(o.y-i.y),x=.01*se(i,o),f=!1,g=!1,m=!1;if("C"===l&&"C"===h.type||"Q"===l&&"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]},a=i.x-e.x,l=i.y-e.y;x=.05*se(e,t),f=se({x:e.x+2*a,y:e.y+2*l},t)<x}else"L"===l&&(g=0===c||c<x,m=0===y||y<x,f=m||g);switch(l){case"L":g&&(s={type:"H",values:[n[0]]}),m&&(s={type:"V",values:[n[1]]});break;case"Q":f&&(s={type:"T",values:[o.x,o.y]});break;case"C":f&&(s={type:"S",values:[n[2],n[3],o.x,o.y]});break;default:s={type:l,values:n}}i=o,r[t]=s}return r}(e)),p&&a&&(e=$e(e)),n&&(e=De(e)),r>-1&&l&&(e=ke(e,r)),l&&(e=function(e,t=-1){return Fe(e,!0,t)}(e)),r>-1&&(e=ke(e,r)),e}function Se(e,{arcAccuracy:t=1}={}){let a=[e[0]];for(let l=1,n=e.length;l<n;l++){let n=e[l],r=e[l-1].values,s=r.length,i={x:r[s-2],y:r[s-1]};if("A"===n.type){qe(i,n.values,t).forEach(e=>{a.push(e)})}else a.push(n)}return a}function Te(e){let t=[e[0]];for(let a=1,l=e.length;a<l;a++){let l=e[a],n=e[a-1].values,r=n.length,s={x:n[r-2],y:n[r-1]};"Q"===l.type?t.push(Ie(s,l.values)):t.push(l)}return t}function Ie(e,t){Array.isArray(e)&&(e={x:e[0],y:e[1]});let a={x:e.x+2/3*(t[0]-e.x),y:e.y+2/3*(t[1]-e.y)},l={x:t[2]+2/3*(t[0]-t[2]),y:t[3]+2/3*(t[1]-t[3])};return{type:"C",values:[a.x,a.y,l.x,l.y,t[2],t[3]]}}function Fe(e,t=!1,a=-1){a>=0&&(e[0].values=e[0].values.map(e=>+e.toFixed(a)));let l=e.length,n=e[0].values,r=n[0],s=n[1],i=r,o=s;for(let n=1;n<l;n++){let l=e[n],{type:p,values:u}=l,h=u.length,y=p.toLowerCase(),c=p.toUpperCase(),x=t?y:c;if(p!==x)switch(l.type=x,y){case"a":u[5]=t?u[5]-r:u[5]+r,u[6]=t?u[6]-s:u[6]+s;break;case"v":u[0]=t?u[0]-s:u[0]+s;break;case"h":u[0]=t?u[0]-r:u[0]+r;break;case"m":t?(u[0]-=r,u[1]-=s):(u[0]+=r,u[1]+=s),i=t?u[0]+r:u[0],o=t?u[1]+s:u[1];break;default:if(u.length)for(let e=0;e<u.length;e++)u[e]=t?u[e]-(e%2?s:r):u[e]+(e%2?s:r)}switch(y){case"z":r=i,s=o;break;case"h":r=t?r+u[0]:u[0];break;case"v":s=t?s+u[0]:u[0];break;case"m":i=u[h-2]+(t?r:0),o=u[h-1]+(t?s:0);default:r=u[h-2]+(t?r:0),s=u[h-1]+(t?s:0)}a>=0&&(l.values=l.values.map(e=>+e.toFixed(a)))}return e}function De(e,t=-1){return Fe(e,!1,t)}function $e(e,t=-1,a=!0){let l=!1;if(a){let t=e.map(e=>e.type).join(""),a=/[hstv]/gi.test(t);if(l=/[astvqmhlc]/g.test(t),!a)return e}let n=[],r={type:"M",values:(e=a&&l?De(e,t):e)[0].values};n.push(r);for(let a=1,l=e.length;a<l;a++){let l,s,i,o,p,u,h,y,c=e[a],{type:x,values:f}=c,g=f.length,m=r.values,d=m.length,[v,M]=[f[g-2],f[g-1]],[b,A]=[m[d-2],m[d-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":[l,s]=[m[0],m[1]],[b,A]=[m[d-2],m[d-1]],i=b+(b-l),o=A+(A-s),r={type:"Q",values:[i,o,v,M]};break;case"S":[l,s]=[m[0],m[1]],[b,A]=[m[d-2],m[d-1]],[h,y]=d>2&&"A"!==r.type?[m[2],m[3]]:[b,A],i=2*b-h,o=2*A-y,p=f[0],u=f[1],r={type:"C",values:[i,o,p,u,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}function ze({p0:e={x:0,y:0},p:t={x:0,y:0},centroid:a={x:0,y:0},rx:l=0,ry:n=0,xAxisRotation:r=0,radToDegree:s=!1,startAngle:i=null,endAngle:o=null,deltaAngle:p=null}={}){if(!l||!n)return[];let u=[];const h=1.5707963267948966;let y=s?r:r*Math.PI/180,c=Math.cos(y),x=Math.sin(y);null!==i&&null!==o&&null!==p||({startAngle:i,endAngle:o,deltaAngle:p}=O(a,e,t));let f=l!==n?X(i,l,n):i,g=l!==n?X(p,l,n):p,m=Math.max(1,Math.ceil(Math.abs(g)/h)),d=g/m;for(let e=0;e<m;e++){const e=Math.abs(d)===h?.551785*Math.sign(d):4/3*Math.tan(d/4);let t=Math.cos(f),r=Math.sin(f),s=Math.cos(f+d),i=Math.sin(f+d),o=[];[{x:t-r*e,y:r+t*e},{x:s+i*e,y:i-s*e},{x:s,y:i}].forEach(e=>{let t=e.x*l,r=e.y*n;o.push(c*t-x*r+a.x,x*t+c*r+a.y)}),u.push({type:"C",values:o,cp1:{x:o[0],y:o[1]},cp2:{x:o[2],y:o[3]},p:{x:o[4],y:o[5]}}),f+=d}return u}function qe(e,t,a=1){const l=2*Math.PI;let[n,r,s,i,o,p,u]=t;if(0===n||0===r)return[];let h=s?s*l/360:0,y=h?Math.sin(h):0,c=h?Math.cos(h):1,x=c*(e.x-p)/2+y*(e.y-u)/2,f=-y*(e.x-p)/2+c*(e.y-u)/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 m=n*n,d=n===r?m:r*r,v=x*x,M=f*f,b=m*d-m*M-d*v;b<=0?b=0:(b/=m*M+d*v,b=Math.sqrt(b)*(i===o?-1:1));let A=b?b*n/r*f:0,C=b?b*-r/n*x:0,w=c*A-y*C+(e.x+p)/2,k=y*A+c*C+(e.y+u)/2,E=(x-A)/n,L=(f-C)/r,P=(-x-A)/n,S=(-f-C)/r;const T=(e,t,a,l)=>{let n=+(e*a+t*l).toFixed(9);return 1===n||-1===n?1===n?0:Math.PI:(n=n>1?1:n<-1?-1:n,(e*l-t*a<0?-1:1)*Math.acos(n))};let I=T(1,0,E,L),F=T(E,L,P,S);0===o&&F>0?F-=2*Math.PI:1===o&&F<0&&(F+=2*Math.PI);let D=(+(Math.abs(F)/(l/4)).toFixed(0)||1)*a;F/=D;let $=[];const z=1.5707963267948966,q=.551785;let j=F===z?q:F===-z?-q:4/3*Math.tan(F/4),Q=F?Math.cos(F):1,B=F?Math.sin(F):0;const N=(e,t,a,l,n)=>{let r=e!=t?Math.cos(e):l,s=e!=t?Math.sin(e):n,i=Math.cos(e+t),o=Math.sin(e+t);return[{x:r-s*a,y:s+r*a},{x:i+o*a,y:o-i*a},{x:i,y:o}]};for(let e=0;e<D;e++){let e={type:"C",values:[]};N(I,F,j,Q,B).forEach(t=>{let a=t.x*n,l=t.y*r;e.values.push(c*a-y*l+w,y*a+c*l+k)}),$.push(e),I+=F}return $}function je(e,{toAbsolute:t=!0,toLonghands:a=!0,quadraticToCubic:l=!1,arcToCubic:n=!1,arcAccuracy:r=4}={}){let s=Array.isArray(e),i=s&&"object"==typeof e[0]&&"function"==typeof e[0].constructor,o=s?e:Ue(e),{hasRelatives:p=!0,hasShorthands:u=!0,hasQuadratics:h=!0,hasArcs:y=!0}=o,c=i?o:o.pathData;return c=function(e=[],{toAbsolute:t=!0,toLonghands:a=!0,quadraticToCubic:l=!1,arcToCubic:n=!1,arcAccuracy:r=2,hasRelatives:s=!0,hasShorthands:i=!0,hasQuadratics:o=!0,hasArcs:p=!0,testTypes:u=!1}={}){if(u){let t=Array.from(new Set(e.map(e=>e.type))).join("");s=/[lcqamts]/gi.test(t),o=/[qt]/gi.test(t),p=/[a]/gi.test(t),i=/[vhst]/gi.test(t),isPoly=/[mlz]/gi.test(t)}return(o&&l||p&&n)&&(a=!0,t=!0),s&&t&&(e=Fe(e,!1)),i&&a&&(e=$e(e,-1,!1)),p&&n&&(e=Se(e,r)),o&&l&&(e=Te(e)),e}(c,{toAbsolute:t,toLonghands:a,quadraticToCubic:l,arcToCubic:n,arcAccuracy:r,hasRelatives:p,hasShorthands:u,hasQuadratics:h,hasArcs:y}),c}const Qe=new Set([77,109,65,97,67,99,76,108,81,113,83,115,84,116,72,104,86,118,90,122]),Be=new Uint8Array(128);Be[77]=2,Be[109]=2,Be[65]=7,Be[97]=7,Be[67]=6,Be[99]=6,Be[76]=2,Be[108]=2,Be[81]=4,Be[113]=4,Be[83]=4,Be[115]=4,Be[84]=2,Be[116]=2,Be[72]=1,Be[104]=1,Be[86]=1,Be[118]=1,Be[90]=0,Be[122]=0;const Ne=new Set([5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279]),Ge=e=>32===e||44===e||10===e||13===e||8232===e||8233===e||9===e||11===e||12===e||160===e||e>=5760&&Ne.has(e),Oe=(e="",t=0)=>{let a=e.length;return 3===t&&2===a?(e=[+e[0],+e[1]],t++):4===t&&a>1?(e=[+e[0],+e.substring(1)],t++):3===t&&a>=3?(e=[+e[0],+e[1],+e.substring(2)],t+=2):e=[+e],{val:e,valueIndex:t}};function Ue(e,t=!0,a=0){e=e.trim(),a&&console.log("!!!limit",a);let l={pathData:[],hasRelatives:!1,hasShorthands:!1,hasArcs:!1,hasQuadratics:!1,isPolygon:!1,log:[]};if(""===e)return l;let n,r=0,s=e.length,i="",o=-1,p="",u=!1,h=0,y=0,c=0,x=!1,f=new Set([]);const g=()=>{x&&("M"===i?i="L":"m"===i&&(i="l"),l.pathData.push({type:i,values:[]}),o++,y=0,x=!1)},m=(e=!1)=>{(e?h>0:""!==p)&&(t&&-1===o&&(n="Pathdata must start with M command",l.log.push(n),i="M",l.pathData.push({type:i,values:[]}),c=2,y=0,o++),"A"===i||"a"===i?(({val:p,valueIndex:y}=Oe(p,y)),l.pathData[o].values.push(...p)):(t&&p[1]&&"."!==p[1]&&"0"===p[0]&&(n=`${o}. command: Leading zeros not valid: ${p}`,l.log.push(n)),l.pathData[o].values.push(+p)),y++,p="",h=0,x=y>=c)},d=()=>{if(o>0){let e=l.pathData[o].values.length;if(e&&e<c||e&&e>c||("z"===i||"Z"===i)&&e>0){n=`${o}. command of type "${i}": ${c-e} values too few - ${c} expected`,l.log[l.log.length-1]!==n&&l.log.push(n)}}};let v=!1,M=!1,b=!1,A="";for(;r<s;){A=e.charCodeAt(r);let a=A>47&&A<58;if(a||(v=101===A||69===A,M=45===A||43===A,b=46===A),a||M||b||v){if(u||45!==A&&46!==A)g();else{let e=46===A;m(e),g(),e&&h++}p+=e[r],u=v,r++}else if((A<48||A>5759)&&Ge(A))m(),r++;else{if(A>64){if(!Qe.has(A)){n=`${o}. command "${e[r]}" is not a valid type`,l.log.push(n),r++;continue}""!==p&&(l.pathData[o].values.push(+p),y++,p=""),t&&d(),i=e[r],c=Be[A];let a="M"===i||"m"===i,s=o>0&&("z"===l.pathData[o].type||"Z"===l.pathData[o].type);f.add(i),s&&!a&&(l.pathData.push({type:"m",values:[0,0]}),o++),l.pathData.push({type:i,values:[]}),o++,h=0,y=0,x=!1,r++;continue}a||(n=`${o}. ${e[r]} is not a valid separarator or token`,l.log.push(n),p=""),r++}}m(),t&&d(),t&&l.log.length&&(n="Invalid path data:\n"+l.log.join("\n"),"log"===t?console.log(n):console.warn(n)),l.pathData[0].type="M";let C=Array.from(f).join("");return l.hasRelatives=/[lcqamtsvh]/g.test(C),l.hasShorthands=/[vhst]/gi.test(C),l.hasArcs=/[a]/gi.test(C),l.hasQuadratics=/[qt]/gi.test(C),l.isPolygon=!/[cqats]/gi.test(C),l}function Ze(e){if("path"===e.nodeName.toLowerCase())return e;let t=function(e,t=!1){let a,l,n,r,s,i,o,p,u,h,y,c,x,f,g,m,d=[],v=e.nodeName;const M=(e,t=9)=>{const a="svg"!==e.nodeName?e.closest("svg"):e,l=e=>{if(null===e)return 0;let a=96,l=e.match(/([a-z]+)/gi);l=l?l[0]:"";let n,r=parseFloat(e);if(!l)return r;switch(l){case"in":n=a;break;case"pt":n=1/72*96;break;case"cm":n=1/2.54*96;break;case"mm":n=1/2.54*96/10;break;case"em":case"rem":n=16;break;default:n=1}return+(r*n).toFixed(t)};let n=a.getAttribute("width");n=n?l(n):300;let r=a.getAttribute("height");r=n?l(r):150;let s=a.getAttribute("viewBox");s=s?s.replace(/,/g," ").split(" ").filter(Boolean).map(e=>+e):[];let i=s.length?s[2]:n,o=s.length?s[3]:r,p=i/100,u=o/100,h=Math.sqrt((Math.pow(p,2)+Math.pow(u,2))/2),y=["x","width","x1","x2","rx","cx","r"],c=["y","height","y1","y2","ry","cy"];e.getAttributeNames().forEach(t=>{let a=e.getAttribute(t),n=a;if(y.includes(t)||c.includes(t)){let r=y.includes(t)?p:u;r="r"===t&&i!=o?h:r;let s=a.match(/([a-z|%]+)/gi);s=s?s[0]:"",n=a.includes("%")?parseFloat(a)*r:l(a),e.setAttribute(t,+n)}})};M(e);const b=t=>(a={},t.forEach(t=>{a[t]=+e.getAttribute(t)}),a);switch(v){case"path":n=e.getAttribute("d"),d=je(n);break;case"rect":l=["x","y","width","height","rx","ry"],({x:r,y:s,width:i,height:o,rx:u,ry:h}=b(l)),u||h?(u=u||h,h=h||u,u>i/2&&(u=i/2),h>o/2&&(h=o/2),d=[{type:"M",values:[r+u,s]},{type:"L",values:[r+i-u,s]},{type:"A",values:[u,h,0,0,1,r+i,s+h]},{type:"L",values:[r+i,s+o-h]},{type:"A",values:[u,h,0,0,1,r+i-u,s+o]},{type:"L",values:[r+u,s+o]},{type:"A",values:[u,h,0,0,1,r,s+o-h]},{type:"L",values:[r,s+h]},{type:"A",values:[u,h,0,0,1,r+u,s]},{type:"Z",values:[]}]):d=[{type:"M",values:[r,s]},{type:"L",values:[r+i,s]},{type:"L",values:[r+i,s+o]},{type:"L",values:[r,s+o]},{type:"Z",values:[]}];break;case"circle":case"ellipse":l=["cx","cy","rx","ry","r"],({cx:y,cy:c,r:p,rx:u,ry:h}=b(l));let t="circle"===v;t?(u=p,h=p):(u=u||p,h=h||p);let a=t&&p>=1?1:u,M=t&&p>=1?1:u;d=[{type:"M",values:[y+u,c]},{type:"A",values:[a,M,0,1,1,y-u,c]},{type:"A",values:[a,M,0,1,1,y+u,c]}];break;case"line":l=["x1","y1","x2","y2"],({x1:x,y1:g,x2:f,y2:m}=b(l)),d=[{type:"M",values:[x,g]},{type:"L",values:[f,m]}];break;case"polygon":case"polyline":let A=e.getAttribute("points").replaceAll(","," ").split(" ").filter(Boolean);for(let e=0;e<A.length;e+=2)d.push({type:0===e?"M":"L",values:[+A[e],+A[e+1]]});"polygon"===v&&d.push({type:"Z",values:[]})}return t?function(e){return e.map(e=>`${e.type} ${e.values.join(" ")}`).join(" ")}(d):d}(e),a=t.map(e=>`${e.type} ${e.values} `).join(" "),l=[...e.attributes].map(e=>e.name),n=document.createElementNS("http://www.w3.org/2000/svg","path");n.setAttribute("d",a);let r=["x","y","cx","cy","dx","dy","r","rx","ry","width","height","points"];return l.forEach(t=>{if(!r.includes(t)){let a=e.getAttribute(t);n.setAttribute(t,a)}}),n}function He(e,{tolerance:t=1,flatBezierToLinetos:a=!0}={}){let l=[e[0]],n={x:e[0].values[0],y:e[0].values[1]},r=n,s=n;e[e.length-1].type.toLowerCase();for(let i=1,o=e.length;i<o;i++){let p=e[i],u=e[i+1]||e[o-1],h="z"===u.type.toLowerCase()?n:{x:u.values[u.values.length-2],y:u.values[u.values.length-1]},{type:y,values:c}=p,x=c.slice(-2);s="Z"!==y?{x:x[0],y:x[1]}:n;let f=h?me([r,s,h],!0):1/0,g=re(r,h),m=f<(g?g/333*t:0),d=!1;if(a||"C"!==y||(m=!1),a&&("C"===y||"Q"===y)){d=Ae([r,..."C"===y?[{x:c[0],y:c[1]},{x:c[2],y:c[3]}]:"Q"===y?[{x:c[0],y:c[1]}]:[],s],{tolerance:t}),d&&i<o-1&&(y="L",p.type="L",p.values=x)}m&&i<o-1&&"A"!==u.type&&("L"===y||a&&d)||(r=s,"M"===y&&(n=s),l.push(p))}return l}function Re(e){let t=[];for(let a=0,l=e.length;a<l;a++){let l=e[a];if(!l)continue;let{type:n=null,values:r=[]}=l,s=e[a+1]?e[a+1]:null;"M"!==n&&"m"!==n||s&&(!s||"Z"!==s.type&&"z"!==s.type)?t.push(l):s&&a++}return t}function Ve(e){let t={x:e[0].values[0],y:e[0].values[1]},a=t,l=[e[0]];for(let n=1,r=e.length;n<r;n++){let r=e[n],s=e[n-1],i=e[n+1]||null,{type:o,values:p}=r,u="m"===s.type.toLowerCase()&&!i,h=p.length;if(a={x:p[h-2],y:p[h-1]},u||"L"!==o||a.x!==t.x||a.y!==t.y){if(!u&&("l"===o||"v"===o||"h"===o)){if("l"===o?"00"===p.join(""):0===p[0])continue}l.push(r),t=a}}return l}function We(e){let t=e.length;if(!("z"===e[t-1].type.toLowerCase()))return e;let a=0,l=[];for(let a=0;a<t;a++){let t=e[a],{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=a,l.push(e)}}return l=l.sort((e,t)=>+e.y.toFixed(8)-+t.y.toFixed(8)||e.x-t.x),a=l[0].index,a?Xe(e,a):e}function Je(e,{removeFinalLineto:t=!0,autoClose:a=!0}={}){let l=[],n=e.length,r={x:+e[0].values[0].toFixed(8),y:+e[0].values[1].toFixed(8)},s="z"===e[n-1].type.toLowerCase(),i=e.filter(e=>"L"===e.type),o=e[s?n-2:n-1],p=o.type,u=o.values.slice(-2).map(e=>+e.toFixed(8)),h=u[0]===r.x&&u[1]===r.y;!s&&a&&h&&(e.push({type:"Z",values:[]}),s=!0,n++);let y="L"!==e[1].type&&(!h||"L"===o.type);if(y=!1,!s)return e;let c=0;{let t=[];for(let a=0;a<n;a++){let l=e[a],{type:n,values:r}=l;if(r.length){let l=r.slice(-2),s=e[a-1]&&"L"===e[a-1].type,i=e[a+1]&&"L"===e[a+1].type,o=e[a-1]?e[a-1].type.toUpperCase():null,p=e[a+1]?e[a+1].type.toUpperCase():null,u={type:n,x:l[0],y:l[1],dist:0,index:0,prevL:s,nextL:i,prevCom:o,nextCom:p};u.index=a,t.push(u)}}if(i.length){let e=t.filter(e=>"L"!==e.type&&"M"!==e.type&&e.prevCom&&"L"===e.prevCom||"M"===e.prevCom&&"L"===p).sort((e,t)=>e.y-t.y||e.x-t.x)[0];c=e?e.index-1:0}else t=t.sort((e,t)=>+e.y.toFixed(8)-+t.y.toFixed(8)||e.x-t.x),c=t[0].index;e=c?Xe(e,c):e}return r={x:+e[0].values[0].toFixed(8),y:+e[0].values[1].toFixed(8)},n=e.length,o=e[n-2],p=o.type,u=o.values.slice(-2).map(e=>+e.toFixed(8)),h="L"===p&&u[0]===r.x&&u[1]===r.y,t&&h&&e.splice(n-2,1),l.push(...e),l}function Xe(e,t){let a=0,l="z"===e[e.length-1].type.toLowerCase();if(!l||t<1||e.length<3)return e;let n=l?1:0;!function(e){let t=e.length,a="z"===e[t-1].type.toLowerCase(),l=e[0],[n,r]=[l.values[0],l.values[1]].map(e=>+e.toFixed(8)),s=a?e[t-2]:e[t-1],i=s.values.length,[o,p]=[s.values[i-2],s.values[i-1]].map(e=>+e.toFixed(8));!a||n==o&&r==p||(e.pop(),e.push({type:"L",values:[n,r]},{type:"Z",values:[]}))}(e),a=t+1<e.length-1?t+1:e.length-1-n;let r,s,i=e.slice(a),o=e.slice(0,a);return o.shift(),r=o[o.length-1].values||[],s=[r[r.length-2],r[r.length-1]],n&&(i.pop(),o.push({type:"Z",values:[]})),e=[{type:"M",values:s},...i,...o]}function Ye(e=[],t=.666){let a=e.length;for(let l=1;l<a;l++){let a=e[l],n=e[l-1],{type:r,values:s}=a;e[l+1]&&e[l+1];let i=!1;if("C"===r){let a={x:s[0],y:s[1]},r={x:s[2],y:s[3]},o=n.values.slice(-2),p={x:o[0],y:o[1]},u={x:s[4],y:s[5]},h=se(p,u),y=se(p,a),c=se(u,r),x=se(a,r),f=U(p,a,u,r,!1),g=f?U(p,a,u,r,!0):null;if(f&&!g){U(u,Z(u,r,3),p,a,!0)&&(i=!0)}y/h<.3&&c/h>.4&&(a=H([p,a],1+t/2),r=H([u,r],t),e[l].values[0]=a.x,e[l].values[1]=a.y,e[l].values[2]=r.x,e[l].values[3]=r.y),(g||f&&x<h/5)&&(i=!0),i&&(a=H([p,f],t),r=H([u,f],t),e[l].values[0]=a.x,e[l].values[1]=a.y,e[l].values[2]=r.x,e[l].values[3]=r.y)}}return e}function _e(e,t,a=!0,l=!0){if(!Array.isArray(e)||void 0!==e[0].x){if(void 0===e[0].x)throw Error("Not a valid point array");e=(e=>Array.from(e).map(e=>[e.x,e.y]))(e)}if(1===(e=e.filter(function(t,a){return 0===a||!t.every((t,l)=>t===e[a-1][l])})).length)return[];if(2===e.length)return[{type:"L",values:[e[0][0],e[0][1]]},{type:"L",values:[e[1][0],e[1][1]]}];let n,r,s=e.length,i=nt(e[1],e[0]),o=nt(e[s-2],e[s-1]),p=(e=>{let t=[];return e.forEach(e=>{let a=e[1],l=e[2],n=e[3],r={type:"C",values:[a[0],a[1],l[0],l[1],n[0],n[1]]};t.push(r)}),t})(et(e,i,o,t));if(a){let t=p.length,a=p[0],i=p[t-1],o={x:e[0][0],y:e[0][1]},u={x:e[1][0],y:e[1][1]},h=e[2]?{x:e[2][0],y:e[2][1]}:null;h&&(n={x:a.values[0],y:a.values[1]},n=Ke(n,o,u,h),a.values[0]=n.x,a.values[1]=n.y);let y={x:e[s-1][0],y:e[s-1][1]},c={x:e[s-2][0],y:e[s-2][1]},x=e[s-3]?{x:e[s-3][0],y:e[s-3][1]}:null;x&&(r={x:i.values[2],y:i.values[3]},r=Ke(r,y,c,x),i.values[2]=r.x,i.values[3]=r.y),l&&(p=function(e=[],t=.666){let a=e.length;for(let l=0;l<a;l++){let a=e[l],n=e[l-1]||null,{type:r,values:s}=a;e[l+1]&&e[l+1];let i=!1;if("C"===r){let a={x:s[0],y:s[1]},r={x:s[2],y:s[3]},o=n.values.slice(-2),p={x:o[0],y:o[1]},u={x:s[4],y:s[5]},h=se(p,u);se(p,a),se(u,r);let y=se(a,r),c=U(p,a,u,r,!1);c&&(c&&U(p,a,u,r,!0)||y<h/5)&&(i=!0),i&&(a=H([p,c],t),r=H([u,c],t),e[l].values[0]=a.x,e[l].values[1]=a.y,e[l].values[2]=r.x,e[l].values[3]=r.y)}}return e}([{type:"M",values:[e[0][0],e[0][1]]},...p]),p.shift())}return p}function Ke(e,t,a,l){let n=G(t,a),r=G(t,l)-n;return e=W(e,t.x,t.y,-r)}let et=(e,t,a,l)=>{let n;if(2===e.length){let l=.333*ne(e[0],e[1],!0);return n=[e[0],st(e[0],it(t,l)),st(e[1],it(a,l)),e[1]],[n]}let r=function(e){let t=[],a=e.length,l=e[0],n=e[1],r=0,s=0;for(let i=0;i<a;i++)n=e[i],r=s+ne(n,l,!0),t.push(r),s=r,l=n;return t=t.map(function(e){return e/s}),t}(e),s=tt(e,r,r,t,a);n=s[0];let i=s[1],o=s[2];if(0===i||i<l)return[n];if(i<l*l){let s=r,p=i,u=o;for(let h=0;h<20;h++){s=at(n,e,s);let h=tt(e,r,s,t,a);if(n=h[0],i=h[1],o=h[2],i<l)return[n];if(o===u){let e=i/p;if(e>.9999&&e<1.0001)break}p=i,u=o}}let p=[],u=rt(e[o-1],e[o+1]);if(u.every(function(e){return 0===e})){u=rt(e[o-1],e[o]);let t=[-u[1],u[0]];u[0]=t[0],u[1]=t[1]}let h=function(e){let t=Math.sqrt(e[0]*e[0]+e[1]*e[1]);return 0===t?[0,0]:[e[0]/t,e[1]/t]}(u),y=it(h,-1);return p=p.concat(et(e.slice(0,o+1),t,h,l)),p=p.concat(et(e.slice(o),y,a,l)),p};const tt=(e,t,a,l,n)=>{let r,s,i;r=((e,t,a,l)=>{let n,r,s,i,o=e[0],p=e[e.length-1],u=[o,null,null,p],h=function(e){let t=[];for(;e--;)t.push([0,0]);return t}(t.length),y=t.length;for(let e=0;e<y;e++)s=t[e],i=1-s,n=h[e],n[0]=it(a,3*s*(i*i)),n[1]=it(l,3*i*(s*s));let c=[[0,0],[0,0]],x=[0,0],f=e.length;for(let a=0;a<f;a++)s=t[a],n=h[a],c[0][0]+=ot(n[0],n[0]),c[0][1]+=ot(n[0],n[1]),c[1][0]+=ot(n[0],n[1]),c[1][1]+=ot(n[1],n[1]),r=rt(e[a],H([o,o,p,p],s)),x[0]+=ot(n[0],r),x[1]+=ot(n[1],r);let g=c[0][0]*c[1][1]-c[1][0]*c[0][1],m=c[0][0]*x[1]-c[1][0]*x[0],d=x[0]*c[1][1]-x[1]*c[0][1],v=0===g?0:d/g,M=0===g?0:m/g,b=ne(o,p,!0),A=1e-6*b;return v<A||M<A?(u[1]=st(o,it(a,.333*b)),u[2]=st(p,it(l,.333*b))):(u[1]=st(o,it(a,v)),u[2]=st(p,it(l,M))),u})(e,a,l,n);let o=function(e,t,a){let l,n,r,s,i,o,p;n=0,r=Math.floor(.5*e.length);let u=function(e,t){let a,l=[0],n=e[0],r=0;for(let s=1;s<=t;s++)a=H(e,s/t),r+=ne(a,n,!0),l.push(r),n=a;return l=l.map(function(e){return e/r}),l}(t,10),h=e.length;for(i=0;i<h;i++)o=e[i],p=lt(a[i],u,10),s=rt(H(t,p),o),l=s[0]*s[0]+s[1]*s[1],l>n&&(n=l,r=i);return[n,r]}(e,r,t);return s=o[0],i=o[1],[r,s,i]};function at(e,t,a){return a.map((a,l)=>function(e,t,a){let l=H(e,a),n=l[0]-t[0],r=l[1]-t[1],s=pt(e,a),i=n*s[0]+r*s[1],o=s[0]*s[0]+s[1]*s[1],p=pt(e,a,!0),u=2*(n*p[0]+r*p[1]),h=o+u;if(Math.abs(h)<1e-10)return a;return a-i/h}(e,t[l],a))}function lt(e,t,a){if(e<0)return 0;if(e>1)return 1;let l,n,r,s,i;for(let o=1;o<=a;o++)if(e<=t[o]){s=(o-1)/a,r=o/a,n=t[o-1],l=t[o],i=(e-n)/(l-n)*(r-s)+s;break}return i}function nt(e,t){let a=e[0]-t[0],l=e[1]-t[1],n=Math.sqrt(a*a+l*l);return 0===n?[0,0]:[a/n,l/n]}function rt(e,t){return[e[0]-t[0],e[1]-t[1]]}function st(e,t){return[e[0]+t[0],e[1]+t[1]]}function it(e,t){return[e[0]*t,e[1]*t]}function ot(e,t){return e[0]*t[0]+e[1]*t[1]}function pt(e,t,a=!1){let l,n,r=e[0],s=e[1],i=e[2],o=e[3],p=t,u=1-p,h=u*u,y=p*p;return a?(l=6*u*(i[0]-2*s[0]+r[0])+6*p*(o[0]-2*i[0]+s[0]),n=6*u*(i[1]-2*s[1]+r[1])+6*p*(o[1]-2*i[1]+s[1])):(l=3*h*(s[0]-r[0])+6*u*p*(i[0]-s[0])+3*y*(o[0]-i[0]),n=3*h*(s[1]-r[1])+6*u*p*(i[1]-s[1])+3*y*(o[1]-i[1])),[l,n]}function ut(e,{debug:t=!1,width:a=0,height:l=0,denoise:n=.9,keepCorners:r=!0,keepExtremes:s=!0,keepInflections:i=!1,manhattan:o=!1,absolute:p=!1,closed:u=!0,tolerance:h=1}={}){let y=s||r?function(e,{x:t=0,y:a=0,width:l=0,height:n=0,debug:r=!1}={}){let s=e.length,i=ce(e);l&&n||({x:t,y:a,width:l,height:n}=i);let o=.01*(l+n);for(let t=0;t<s;t++){let a=t>0?e[t-1]:e[s-1],l=e[t],n=me([a,l,t<s-1?e[t+1]:e[s-1]],!1);l.area=n,l.dist=se(a,l)}for(let t=0;t<s;t++){t>1?e[t-2]:e[s-1];let a=t>0?e[t-1]:e[s-1],l=e[t],n=t<s-1?e[t+1]:e[s-1],r=ce([a,n]);re(a,n);let p=Math.abs(a.area),u=Math.abs(l.area),h=Math.abs(n.area),y=!1,c=!l.area||u<o,{left:x,right:f,top:g,bottom:m}=r,d=l.x<=x||l.x>=f||l.y<=g||l.y>=m,v=l.x===i.left||l.x===i.right||l.y===i.top||l.y===i.bottom;se(l,a);let M=l.y===a.y&&l.x!==a.x,b=l.x===a.x&&l.y!==a.y;
|
|
10
10
|
//!isCloseExtreme &&
|
|
11
|
-
(M||b)&&(v=!0);let A=a.area<0&&l.area>0||a.area>0&&l.area<0,C=A&&!c;if(y=C,d&&!a.isDirChange&&(v=!0),b&&a.isHorizontal&&(a.isCorner=!0,a.isExtreme=!1,v=!1),C&&(a.isDirChange||a.isExtreme)&&(C=!1,l.isDirChange=!1),a.isExtreme&&u>h&&!C&&l.isHorizontal,v||A||u>p){let e=O(l,n,a),{deltaAngleDeg:t}=e;t=Math.abs(t),y=!(t<3||t>160)}l.isCorner=y,l.isExtreme=v,l.isHorizontal=M,l.isVertical=b,l.isDirChange=C}let p=[],u=[];for(let t=0;t<e.length;t++){let a=e[t],l=e[t+1]||null,n=e[t+2]||null,r=[];if(l&&l.isExtreme&&a.isExtreme&&!a.isCorner){let e=l.dist<2*o&&!l.isCorner,s=n&&n.isExtreme&&n.dist<2*o&&!n.isCorner;if(e&&!s?r.push(a,l):s&&r.push(a,l,n),r.length){let e=r.reduce((e,t)=>e+t.x,0)/r.length,l=r.reduce((e,t)=>e+t.y,0)/r.length;a.x=e,a.y=l,t+=r.length-1}}(a.isExtreme||a.isCorner||a.isDirChange)&&u.push(p.length),p.push(a)}let h=p.length,y=p[0],c=p[h-1],x=se(y,c)<2*o;return y.isExtreme&&c.isExtreme&&x&&(c.x=y.x,c.y=y.y),p}(e,{debug:!1}):e,c=s||r?function(e,{closed:t=!0,keepCorners:a=!0,keepExtremes:l=!0,keepInflections:n=!1}={}){let r=[],s=[e[0]],i=e.length;for(let t=1;t<i;t++){t>0?e[t-1]:e[i-1];let n=e[t],o=t<i-1?e[t+1]:e[i-1];s.push(n),t>0&&(l&&o.isExtreme||a&&o.isCorner)&&(r.push(s),s=[])}return!r.length&&e.length>1&&(r=[e]),r}(y,{keepCorners:r,keepExtremes:s,keepInflections:i}):[y],x=a&&l?(a+l)/2*.004*h:2.5;x=2;let f=function(e=[],{closed:t=!0,tolerance:a=1}={}){let l=e.length,n=[{type:"M",values:[e[0][0].x,e[0][0].y]}];for(let t=0;t<l;t++){let l=e[t],r=e[t+1]?e[t+1]:null,s=[],i=l.length;l[l.length-1],r&&l.push(r[0]),i<2||2===i&&l[1].isExtreme?(l[l.length-1],s=l.map(e=>({type:"L",values:[e.x,e.y]}))):s=_e(l,a),n.push(...s)}t&&n.push({type:"Z",values:[]});return function(e){let t=e.length;for(let a=1;a<t;a++){let t=e[a],l=e[a+1]||null,{type:n,values:r}=t;if("C"===n&&l&&"C"===l.type){let n=l.values;r[0],r[1];let s={x:r[2],y:r[3]},i={x:r[4],y:r[5]},o={x:n[0],y:n[1]};n[2],n[3];let p,u,h=Math.abs(s.x-i.x),y=Math.abs(s.y-i.y),c=Math.abs(o.x-i.x),x=Math.abs(o.y-i.y),f=.02*se(o,s),g=y<f&&h>f,m=x<f&&c>f,d=h<f&&y>f,v=c<f&&x>f;(g||d)&&(p=g?{x:t.values[2],y:i.y}:d?{x:i.x,y:t.values[3]}:{x:t.values[2],y:t.values[3]},t.values[2]=p.x,t.values[3]=p.y),(m||v)&&(u=m?{x:l.values[0],y:i.y}:v?{x:i.x,y:l.values[1]}:{x:l.values[0],y:l.values[1]},e[a+1].values[0]=u.x,e[a+1].values[1]=u.y)}}}(n),n}(c,{closed:u,tolerance:2});return f}function ht(e,{threshold:t=null,tolerance:a=1}={}){if(!t){let a=function(e){let t=1/0,a=-1/0,l=1/0,n=-1/0;const r=e=>{e.x<t&&(t=e.x),e.x>a&&(a=e.x),e.y<l&&(l=e.y),e.y>n&&(n=e.y)};for(let t=0;t<e.length;t++){let a=e[t],{type:l,values:n}=a,s=n.length,i=(e[t-1]?e[t-1]:e[t]).values,o=i.length;if(s){let e={x:i[o-2],y:i[o-1]},t={x:n[s-2],y:n[s-1]};if(r(t),"C"===l||"Q"===l){let a={x:n[0],y:n[1]},s="C"===l?{x:n[2],y:n[3]}:a,i="C"===l?[e,a,s,t]:[e,a,t];_(i).forEach(e=>{let t=H(i,e);r(t)})}else"A"===l&&K(e,n).forEach(e=>{r(e)})}}return{x:t,y:l,width:a-t,height:n-l}}(e);t=.05*(a.width+a.height)}let l=e.length;for(let n=0;n<l;n++){let l=e[n],{type:r,values:s,extreme:i,corner:o=!1,dimA:p,p0:u,p:h}=l,y=e[n+1]?e[n+1]:null,c=e[n+2]?e[n+2]:null,x=(y?se(h,y.p):1/0)<t,f=(c?se(c.p,y.p):1/0)<1*t;if(y&&c&&"C"===r&&"C"===y.type&&i&&c.extreme&&(f||x)){let l=ve(y,c,t,a,!1);if(1===l.length){l=l[0],e[n+1]=null,e[n+2].values=[l.cp1.x,l.cp1.y,l.cp2.x,l.cp2.y,l.p.x,l.p.y],e[n+2].cp1=l.cp1,e[n+2].cp2=l.cp2,e[n+2].p0=l.p0,e[n+2].p=l.p,e[n+2].extreme=l.extreme,n++;continue}}if(y&&"C"===r&&"C"===y.type&&i&&x){let e=me([l.p0,l.p,y.p]),t=me([l.p0,l.cp1,l.cp2,l.p]);if(e<0&&t>0||e>0&&t<0)continue}}l=(e=e.filter(Boolean)).length;let n="z"===e[l-1].type.toLowerCase()?l-2:l-1,r=e[n],s=e[n-1]||null,i={x:e[0].values[0],y:e[0].values[1]},o=r.values.slice(-2),p=+o[0].toFixed(8)===+i.x.toFixed(8)&&+o[1].toFixed(8)===+i.y.toFixed(8),u="C"===e[1].type&&e[1].extreme?e[1]:null,h=se(r.p0,r.p)<t;if(s&&"C"===s.type&&h&&p&&u){let l=ve(s,r,t,a,!1);1===l.length&&(e[n-1]=l[0],e[n]=null,e=e.filter(Boolean))}return e}function yt({transforms:e=[],transformOrigin:t={x:0,y:0}}={}){let a=function(e=[],t={x:0,y:0}){const a=(e,t)=>({a:e.a*t.a+e.c*t.b,b:e.b*t.a+e.d*t.b,c:e.a*t.c+e.c*t.d,d:e.b*t.c+e.d*t.d,e:e.a*t.e+e.c*t.f+e.e,f:e.b*t.e+e.d*t.f+e.f}),l=(e,t)=>({a:1,b:0,c:0,d:1,e:e,f:t}),n=(e,t)=>({a:e,b:0,c:0,d:t,e:0,f:0}),r=(e,t)=>{const a=e=>e*Math.PI/180;let[l,n]=e.map(e=>a(e)),r={};if("rot"===t){let e=Math.cos(l),t=Math.sin(l);r={a:e,b:t,c:-t,d:e,e:0,f:0}}else if("skew"===t){let e=Math.tan(l);r={a:1,b:Math.tan(n),c:e,d:1,e:0,f:0}}return r};let s={a:1,b:0,c:0,d:1,e:0,f:0};0===t.x&&0===t.y||(s=a(s,l(t.x,t.y)));const i={translate:[0,0],scale:[1,1],skew:[0,0],rotate:[0],matrix:[1,0,0,1,0,0]};for(const t of e){const e=Object.keys(t)[0],o=t[e]||i[e];let[p,u=i[e][1]]=o;switch("rotate"===e&&3===o.length&&(p=o[2]),e){case"matrix":let t=["a","b","c","d","e","f"];s=a(s,Object.fromEntries(t.map((e,t)=>[e,o[t]])));break;case"translate":(p||u)&&(s=a(s,l(p,u)));break;case"skew":(p||u)&&(s=a(s,r([p,u],"skew")));break;case"rotate":p&&(s=a(s,r([p],"rot")));break;case"scale":1===p&&1===u||(s=a(s,n(p,u)));break;default:throw new Error(`Unknown transformation type: ${e}`)}}0===t.x&&0===t.y||(s=a(s,l(-t.x,-t.y)));return s}(e,t);return a}const ct=["path","polygon","polyline","line","rect","circle","ellipse"],xt=["textPath","text","tspan"],ft={atts:{id:"*",class:"*",viewBox:["symbol","svg"],preserveAspectRatio:["symbol","svg"],width:["svg","rect","use","image"],height:["svg","rect","use","image"],d:["path"],points:["polygon","polyline"],x:["image","rect","text","textPath","tspan","use","mask"],y:["image","rect","text","textPath","tspan","use","mask"],x1:["line","linearGradient"],x2:["line","linearGradient"],y1:["line","linearGradient"],y2:["line","linearGradient"],r:["circle","radialGradient"],rx:["rect","ellipse"],ry:["rect","ellipse"],cx:["circle","ellipse","radialGradient"],cy:["circle","ellipse","radialGradient"],refX:["symbol","markers"],refY:["symbol","markers"],transform:["svg","g","use",...ct,...xt],"transform-origin":["svg","g","use",...ct,...xt],fill:["svg","g","use",...ct,...xt,"animate","animateMotion"],"fill-opacity":["svg","g","use",...ct,...xt],opacity:["svg","g","use",...ct,...xt],stroke:["svg","g","use",...ct,...xt],"stroke-width":["svg","g","use",...ct,...xt,"mask"],"stroke-opacity":["svg","g","use",...ct,...xt,"mask"],"stroke-miterlimit":["svg","g","use",...ct,...xt,"mask"],"stroke-linejoin":["svg","g","use",...ct,...xt,"mask"],"stroke-linecap":["svg","g","use",...ct,...xt,"mask"],"stroke-dashoffset":["svg","g","use",...ct,...xt,"mask"],"stroke-dasharray":["svg","g","use",...ct,...xt,"mask"],"clip-path":["svg","g","use",...ct,...xt],"clip-rule":["path","polygon"],clipPathUnits:["clipPath"],mask:["svg","g","use",...ct,...xt],maskContentUnits:["mask"],maskUnits:["mask"],"font-family":["svg","g",...xt],"font-size":["svg","g",...xt],"font-style":["svg","g",...xt],"font-weight":["svg","g",...xt],"font-stretch":["svg","g",...xt],"dominant-baseline":[...xt],lengthAdjust:[...xt],"text-anchor":["text"],textLength:["text","textPath","tspan"],dx:["text","tspan"],dy:["text","tspan"],method:["textPath"],spacing:["textPath"],startOffset:["textPath"],rotate:["text","tspan","animateMotion"],side:["textPath"],"white-space":["svg","g",...xt],color:["svg","g",...xt],playbackorder:["svg"],timelinebegin:["svg"],dur:["animate","animateTransform","animateMotion"],end:["animate","animateTransform","animateMotion"],from:["animate","animateTransform","animateMotion"],to:["animate","animateTransform","animateMotion"],type:["animateTransform"],values:["animate","animateTransform","animateMotion"],accumulate:["animate","animateTransform","animateMotion"],additive:["animate","animateTransform","animateMotion"],attributeName:["animate","animateTransform"],begin:["animate","animateTransform","animateMotion"],by:["animate","animateTransform","animateMotion"],calcMode:["animate","animateTransform","animateMotion"],keyPoints:["animateMotion"],keySplines:["animate","animateTransform","animateMotion"],keyTimes:["animate","animateTransform","animateMotion"],max:["animate","animateTransform","animateMotion"],min:["animate","animateTransform","animateMotion"],origin:["animateMotion"],repeatCount:["animate","animateTransform","animateMotion"],repeatDur:["animate","animateTransform","animateMotion"],restart:["animate","animateTransform","animateMotion"],gradientUnits:["linearGradient","radialGradient"],gradientTransform:["linearGradient","radialGradient"],fr:["radialGradient"],fx:["radialGradient"],fy:["radialGradient"],offset:["stop"],"stop-color":["stop"],"stop-opacity":["stop"],spreadMethod:["linearGradient","radialGradient"],href:["pattern","textPath","linearGradient","radialGradient","use","animate","animateTransform","animateMotion","image"],pathLength:[...ct]},defaults:{transform:["none","matrix(1, 0, 0, 1, 0, 0)"],"transform-origin":["0px, 0px","0 0"],rx:["0","0px"],ry:["0","0px"],x:["0","0px"],y:["0","0px"],fill:["black","rgb(0, 0, 0)","rgba(0, 0, 0, 0)","#000","#000000"],color:["black","rgb(0, 0, 0)","rgba(0, 0, 0, 0)","#000","#000000"],stroke:["none"],"stroke-width":["1","1px"],opacity:["1"],"fill-opacity":["1"],"stroke-opacity":["1"],"stroke-linecap":["butt"],"stroke-miterlimit":["4"],"stroke-linejoin":["miter"],"stroke-dasharray":["none"],"stroke-dashoffset":["0","0px","none"],pathLength:["none"],"font-family":["serif"],"font-weight":["normal","400"],"font-stretch":["normal"],"font-width":["normal"],"letter-spacing":["auto","normal","0"],lengthAdjust:["spacing"],"text-anchor":["start"],"dominant-baseline":["auto"],spacing:["auto"],"white-space":["normal"],"stop-opacity":["1"],gradientUnits:["objectBoundingBox"],patternUnits:["objectBoundingBox"],"clip-path":["none"],"clip-rule":["nonzero"],"fill-rule":["nonzero"],clipPathUnits:["userSpaceOnUse"],mask:["none"],maskUnits:["objectBoundingBox"]}};function gt(e,{removeNameSpaced:t=!0,decimals:a=-1}={}){let l=e.nodeName.toLowerCase(),n=function(e){let t={},a=[...e.attributes].map(e=>e.name),l=a.length;if(!l)return t;for(let n=0;n<l;n++){let l=a[n],r=e.getAttribute(l);t[l]=r}return t}(e),r=function(e){let t=e.getAttribute("style"),a=t?function(e=""){let t={};if(!e)return t;let a=e.split(";").filter(Boolean).map(e=>e.trim()),l=a.length;if(!l)return t;for(let e=0;l&&e<l;e++){let l=a[e],[n,r]=l.split(":").filter(Boolean);t[n]=r}return t}(t):{};return a}(e),s={...n,...r},i={},o=r.transform;if(o){let e=yt(function(e,t={x:0,y:0}){let a,l={transforms:[],transformOrigin:t},n=/(\w+)\(([^)]+)\)/g;function r(e){if("string"==typeof e){if(e.includes("rad"))return parseFloat(e)*(180/Math.PI);if(e.includes("turn"))return 360*parseFloat(e)}return parseFloat(e)}for(;null!==(a=n.exec(e));){let e=a[1],t=a[2].split(/,\s*/).map(e=>r(e));switch(e){case"translate":l.transforms.push({translate:[t[0]||0,t[1]||0]});break;case"translateX":l.transforms.push({translate:[t[0]||0,0,0]});break;case"translateY":l.transforms.push({translate:[0,t[0]||0,0]});break;case"scale":l.transforms.push({scale:[t[0]||0,t[1]||0]});break;case"skew":l.transforms.push({skew:[t[0]||0,t[1]||0]});break;case"skewX":l.transforms.push({skew:[t[0]||0,0]});break;case"skewY":l.transforms.push({skew:[0,t[0]||0]});break;case"rotate":l.transforms.push({rotate:[0,0,t[0]||0]});break;case"matrix":l.transforms.push({matrix:t})}}return e.split(/;\s*/).forEach(e=>{let[t,a]=e.split(":").map(e=>e.trim());if("transform-origin"===t||"perspective-origin"===t){let[e,n]=a.split(/\s+/).map(parseFloat);"transform-origin"===t&&(l.transformOrigin={x:e||0,y:n||0})}}),l}(`${o}`));s.transform=`matrix(${Object.values(e).join(",")})`}let p=["inline-size"],u=[];for(let a in s){let n=s[a];n&&a.startsWith("--")||p.includes(a)||!t&&a.startsWith("-")?u.push(`${a}:${n}`):(n&&ft.atts[a]&&("*"===ft.atts[a]||ft.atts[a].includes(l)||!t&&a.includes(":"))&&(i[a]=n),e.removeAttribute(a))}for(let t in i){let a=i[t];e.setAttribute(t,a)}return u.length&&e.setAttribute("style",u.join(";")),i}function mt(e,{returnDom:t=!1,removeHidden:a=!0,removeUnused:l=!0,stylesToAttributes:n=!0,removePrologue:r=!0,fixHref:s=!0,mergePaths:i=!1,cleanupSVGAtts:o=!0,removeNameSpaced:p=!0,attributesToGroup:u=!0,decimals:h=-1,excludedEls:y=[]}={}){e=e.replace(/<\?xml[\s\S]*?\?>/gi,"").replace(/<!DOCTYPE[\s\S]*?>/gi,"").replace(/<!--[\s\S]*?-->/g,"").trim(),s&&(e=e.replaceAll("xlink:href=","href="));let c=(new DOMParser).parseFromString(e,"text/html").querySelector("svg");if(o){!function(e,t=["viewBox","xmlns","width","height","id","class"]){[...e.attributes].map(e=>e.name).forEach(a=>{t.includes(a)||e.removeAttribute(a)})}(c,["viewBox","xmlns","width","height","id","class","fill","stroke","stroke-width","stroke-linecap","stroke-linejoin"])}let x=["metadata","script",...y],f=c.querySelectorAll("*"),g=[];for(let e=0;e<f.length;e++){let t=f[e],l=t.nodeName.toLowerCase(),r=t.getAttribute("style")||"",s=!!r&&r.trim().includes("display:none"),o=t.getAttribute("display")&&"none"===t.getAttribute("display")||s;if(l.includes(":")||x.includes(l)||a&&o)t.remove();else if(n||u||i){let a=gt(t,{removeNameSpaced:p,decimals:h});"path"===l&&g.push({el:t,name:l,idx:e,propsFiltered:a})}}return(u||i)&&function(e=[],t=!0){let a=[[e[0]]],l=0,n="";for(let t=0;t<e.length;t++){let r=e[t],s=r.propsFiltered,i=[];for(let e in s)"d"!==e&&"id"!==e&&i.push(`${e}:${s[e]}`);i=i.join("_"),r.propstr=i,i===n?a[l].push(r):a[l].length&&(a.push([]),l++),n=i}for(let e=0;e<a.length;e++){let l=a[e];if(l.length>1){let e=l[0].el,a=l[0].propsFiltered,n=e.parentNode.closest("g")?e.parentNode.closest("g"):null;n||(n=document.createElementNS("http://www.w3.org/2000/svg","g"),e.parentNode.insertBefore(n,e),l.forEach(e=>{n.append(e.el)}));let r=[...n.children];for(let e in a){if("d"!==e&&"id"!==e){let t=a[e];n.setAttribute(e,t),r.forEach(a=>{a.getAttribute(e)===t&&a.removeAttribute(e)})}if(t){let e=l[0].el,t=l[0].propsFiltered.d;for(let e=1;e<l.length;e++){let a=l[e],n=a.el,r=a.propsFiltered.d;t+=r.startsWith("M")?r:Ue(r).pathData.map(e=>`${e.type} ${e.values.join(" ")}`).join(" "),n.remove()}e.setAttribute("d",t)}}}}}(g,i),t?c:dt(c)}function dt(e){let t=(new XMLSerializer).serializeToString(e);return t=t.replace(/\t/g,"").replace(/[\n\r|]/g,"\n").replace(/\n\s*\n/g,"\n").replace(/ +/g," "),t}function vt(e,{threshold:t=0,tolerance:a=1}={}){let l=e.length,n=[e[0]],r="z"===e[l-1].type.toLowerCase(),s=!!r&&(e[l-1].p.x===e[0].p0.x&&e[l-1].p.y===e[0].p0.y),i=r?2:1,o=e[l-i],p="L"===o.type,u="C"===o.type,h="L"===e[1].type,y="C"===e[1].type,c=r&&y&&(p||s);c&&(e[l-1].values=e[0].values,e[l-1].type="L",p=!0);for(let t=1;t<l;t++){let s=e[t],{type:o}=s,x=e[t+1]?e[t+1]:null;if("L"===o&&x&&"C"===x.type||"C"===o&&x&&"L"===x.type){let c="L"===o?s:null,f=null,g=[],m=0;if(1===t&&y&&p&&(g=[e[1]],c=e[l-1],f=x),!c){n.push(s);continue}r&&u&&h&&t===l-i-1&&(f=e[1],g=[e[l-i]]);for(let a=t+1;a<l;a++){let t=e[a]?e[a]:null,l=e[a-1];if("C"===l.type&&g.push(l),"L"===t.type&&"C"===l.type){f=t;break}m++}if(f){let e=se(c.p0,c.p),l=se(f.p0,f.p);g.length;let r=se(c.p,f.p0),i=me([c.p0,c.p,f.p0,f.p],!1),o=me([g[0].p0,g[0].cp1,g[0].cp2,g[0].p],!1),p=i<0&&o>0||i>0&&o<0,u=.5*r*a,h=u<e&&u<l;if(g.length&&!p&&h){let e=Math.abs(o)<=.005*re(g[0].p0,g[0].p),a=e?null:U(c.p0,c.p,f.p0,f.p,!1);if(!e&&a){let e=.75*se(H([c.p,a,f.p0],.5),1===g.length?H([g[0].p0,g[0].cp1,g[0].cp2,g[0].p],.5):g[0].p);if(u&&e>u&&e>.3*r){n.push(s);continue}{let e={type:"Q",values:[a.x,a.y,f.p0.x,f.p0.y]};e.p0=c.p,e.cp1=a,e.p=f.p0,n.push(c,e),t+=m;continue}}}}}c&&t===l-1&&"L"===o||n.push(s)}return(c||r&&"Z"!==n[n.length-1].type)&&n.push({type:"Z",values:[]}),n}function Mt(e){if(e.length<3)return!1;let t=e[0],a=e[Math.floor(e.length/2)],l=e[e.length-1],n=t.x,r=t.y,s=a.x,i=a.y,o=l.x,p=l.y,u=n-s,h=r-i,y=n-o,c=r-p,x=(n*n-s*s+(r*r-i*i))/2,f=(n*n-o*o+(r*r-p*p))/2,g=u*c-h*y;if(Math.abs(g)<1e-10)return console.warn("Points are collinear or numerically unstable"),!1;let m={x:(c*x-h*f)/g,y:(-y*x+u*f)/g},d=ne(m,t),v=O(m,t,l),{deltaAngle:M,startAngle:b,endAngle:A}=v;return{centroid:m,r:d,startAngle:b,endAngle:A,deltaAngle:M}}function bt(e,{threshold:a=0,tolerance:l=1,toCubic:n=!1,debug:r=!1}={}){let s=e.length,i=[e[0]],o=[];for(let a=1;a<s;a++){let l=e[a],{type:s}=l,p=e[a-1],u=e[a+1]?e[a+1]:null,h=e[a+2]?e[a+2]:null,y=e[a+3]?e[a+3]:null,c=null;"C"===l.type||"Q"===l.type?c=l:!u||"C"!==u.type&&"Q"!==u.type||(c=u);let x,f,g,m,d,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,w=[];if("L"===p.type&&"L"===s&&c&&"L"===h.type&&y&&("L"===y.type||"Z"===y.type)?(x=[l.p0,l.p],f=[h.p0,h.p],g=l.p0,m=h.p,M=me(v,!1),b=me([...x,...f],!1),A=M<0&&b>0||M>0&&b<0,A||(d=H(v,.5),w=[g,d,m],C=!0)):"C"!==s&&"Q"!==s||"L"!==p.type||"C"!==u.type&&"Q"!==u.type||"L"!==h.type||(C=!0,x=[p.p0,p.p],f=[h.p0,h.p],g=p.p,m=h.p0,d=c.p,w=[g,c.p,m]),C){let e=Mt(w);if(e){let s,{centroid:p,r:u,deltaAngle:h,startAngle:y,endAngle:c}=e,x=0,f=h>0?1:0,v=Math.abs(h)>Math.PI?1:0;if(ie(W(g,p.x,p.y,.5*h),d)<.05*ie(g,m)){if(s=ze({p0:g,p:m,centroid:p,rx:u,ry:u,xAxisRotation:x,sweep:f,largeArc:v,deltaAngle:h,startAngle:y,endAngle:c}),1===s.length){let e=Le(g,s[0].cp1,s[0].cp2,m);"Q"===e.type&&(n=!0),l=e}if(s.length>1&&(n=!1),n||(l.type="A",l.values=[u,u,x,v,f,m.x,m.y]),l.p0=g,l.p=m,l.extreme=!1,l.corner=!1,r){o=n?[{type:"M",values:[g.x,g.y]},...s]:[{type:"M",values:[g.x,g.y]},{type:"A",values:[u,u,x,v,f,m.x,m.y]}];let e=de(o);t(markers,e,"orange","0.5%","0.5")}i.push(l),a++;continue}}}i.push(l)}return i}function At(e=[],{threshold:t=0}={}){let a=e.length,l="z"===e[a-1].type.toLowerCase(),n=l?a-2:a-1,r=e[n],s=r.values.slice(-2),i={x:e[0].values[0],y:e[0].values[1]},o=ie(i,{x:s[0],y:s[1]});if(o&&o<t){let a=e[n].values.length;e[n].values[a-2]=i.x,e[n].values[a-1]=i.y;let l=e[1];if("C"===l.type&&"C"===r.type){let a=Math.abs(l.values[0]-r.values[2]),s=Math.abs(l.values[1]-r.values[3]),o=Math.abs(e[1].values[0]-l.values[0]),p=Math.abs(e[1].values[1]-l.values[1]),u=Math.abs(e[1].values[0]-r.values[2]),h=Math.abs(e[1].values[1]-r.values[3]),y=p<t&&h<t&&a;a&&a<t&&(o<t&&u<t&&s)&&(e[1].values[0]=i.x,e[n].values[2]=i.x),s&&s<t&&y&&(e[1].values[1]=i.y,e[n].values[3]=i.y)}}return e}function Ct(e,t=1){let a=[];for(let l=0,n=e.length;l<n;l++){let n=e[l],{type:r,values:s}=n,i={type:r,values:[]};switch(r.toLowerCase()){case"h":case"v":i.values=[s[0]*t];break;case"a":i.values=[s[0]*t,s[1]*t,s[2],s[3],s[4],s[5]*t,s[6]*t];break;default:s.length&&(i.values=s.map((e,a)=>e*t))}a.push(i)}return a}function wt(e,{tolerance:a=1}={}){let l=[],n=[],r=e.length;for(let t=1;t<r;t++){let a=e[t],{type:r,values:s,p0:i,cp1:o=null,cp2:p=null,p:u,extreme:h=null,semiExtreme:y=null,corner:c=null,directionChange:x}=a,f=e[t+1]||null;h||c||f&&f.type!==r?(n.push(a),l.push(n),n=[]):n.push(a)}console.log("!!!chunks",l),function(e){console.log("chunks",e);let a="green";for(let l=0;l<e.length;l++){let n=e[l],r=n.length;a=l%2==0?"orange":"green";let s=n[0],i=n[r-1],o=[{type:"M",values:[s.p0.x,s.p0.y]}];for(let e=0,t=r;e<t;e++){let a=n[e];n[e+1],n[t-1],"C"===s.type&&i.type;let{type:l,values:r,p0:p,cp1:u=null,cp2:h=null,p:y=null,extreme:c,semiExtreme:x=null,corner:f=null}=a;o.push({type:l,values:r})}let p=de(o);t(markers,p,a,"1%","0.5")}}(l);let s=l.length;for(let e=0;e<s;e++){let t=l[e],a=l[e+1]||null;1===t.length&&a&&a[0].type}l=l.filter(Boolean);let i=[e[0]];for(let e=0;e<l.length;e++){let t=l[e],a=t.length,n=t[0],r=t[a-1],s=.05*se(n.p0,r.p);for(let e=0,l=a;e<l;e++){let o=t[e];t[e+1],t[l-1];let p="C"===n.type&&"C"===r.type,{type:u,values:h,p0:y,cp1:c=null,cp2:x=null,p:f=null,extreme:g,semiExtreme:m=null,corner:d=null}=o,v=null,M=null,b=null,A=null,C=null,w=null,k=[],E=.666,L=null;if(p){let e=Math.abs(n.p0.x-n.cp1.x),t=Math.abs(n.p0.y-n.cp1.y),a=Math.abs(r.p.x-r.cp2.x),l=Math.abs(r.p.y-r.cp2.y),i=e<s&&e<t,o=a<s&&a<l,p=l<s&&a>l;t<s&&e>t&&(n.cp1.y=n.p0.y),p&&(r.cp2.y=r.p.y),i&&(n.cp1.x=n.p0.x),o&&(r.cp2.x=r.p.x)}if(de([{type:"M",values:[o.p0.x,o.p0.y]},{type:u,values:h}]),1===a||"C"!==u)i.push(o);else{let e=t.filter(e=>e.semiExtreme),a=t.filter(e=>e.directionChange);if(e.length||a.length){if(L=e.length?e[0]:a[0],n.p0.x===n.cp1.x&&n.p0.y===n.cp1.y?n.cp1=H([n.p0,n.cp1,n.cp2,n.p],.5):r.p.x===r.cp2.x&&r.p.y===r.cp2.y&&(r.cp2=H([r.p0,r.cp1,r.cp2,r.p],.5)),v=U(L.p,L.cp2,n.p0,n.cp1,!1),M=U(L.p,L.cp2,r.p,r.cp2,!1),v&&M){b=H([n.p0,v],E),A=H([r.p,M],E),C=H([L.p,v],E),w=H([L.p,M],E),k=[{type:"M",values:[n.p0.x,n.p0.y]},{type:"C",values:[b.x,b.y,C.x,C.y,L.p.x,L.p.y]},{type:"C",values:[w.x,w.y,A.x,A.y,r.p.x,r.p.y]}],de(k),i.push({type:"C",values:[b.x,b.y,C.x,C.y,L.p.x,L.p.y],p0:n.p0,cp1:b,cp2:C,p:L.p,dimA:se(n.p0,L.p)},{type:"C",values:[w.x,w.y,A.x,A.y,r.p.x,r.p.y],p0:L.p,cp1:w,cp2:A,p:r.p,extreme:!0,dimA:se(L.p,r.p)});break}}else i.push(o)}}}return i}function kt(e){for(let t=1,a=e.length;t<a;t++){let a=e[t],{type:l,values:n,p0:r,cp1:s=null,cp2:i=null,p:o=null}=a;if("C"===l){let l=Le(r,s,i,o);"Q"===l.type&&(l.extreme=a.extreme,l.corner=a.corner,l.dimA=a.dimA,l.squareDist=a.squareDist,e[t]=l)}}return e}function Et(e,{areaThreshold:t=2.5}={}){for(let a=0,l=e.length;a<l;a++){let l=e[a],n=e[a+1]||null,{type:r,values:s,p0:i,cp1:o=null,cp2:p=null,p:u=null}=l;if("C"===r&&n&&"C"===n.type){let l=Lt(i,o,p,u,t),r=Lt(n.p0,n.cp1,n.cp2,n.p,t);if(l.isArc&&r.isArc){let t=.01*se(i,n.p),s=Math.abs(n.p.x-i.x),o=Math.abs(n.p.y-i.y),p=o<t&&s>t,h=s<t&&o>t,{rx:y,ry:c}=l,x=me([i,u,n.p])<0?0:1;if(h||p){y=Math.min(y,r.rx),c=Math.min(c,r.ry),e[a]=null,e[a+1].type="A",e[a+1].values=[y,c,0,0,x,n.p.x,n.p.y];continue}}}}return e=e.filter(Boolean)}function Lt(e,t,a,l,n=7.5){let r,s={type:"C",values:[t.x,t.y,a.x,a.y,l.x,l.y]},i=0,o=!1,p=G(e,t,!0),u=G(l,a,!0),h=180*Math.abs(p-u)/Math.PI,y=0,c=0;if(Math.abs(h%180-90)<3){r=U(e,W(t,e.x,e.y,-.5*Math.PI),l,W(a,l.x,l.y,.5*Math.PI),!1);let p=U(e,t,l,a,!1);if(p){let r=ne(e,p),u=ne(l,p),h=+Math.max(r,u).toFixed(8),x=+Math.min(r,u).toFixed(8);y=x,c=h;let f=me([e,t,a,l])<0?0:1,g=Math.abs(l.x-e.x)>Math.abs(l.y-e.y);100/y*Math.abs(y-c)<5&&(y=h,c=y),g&&(y=h,c=x);let m=ge([{type:"M",values:[e.x,e.y]},{type:"C",values:[t.x,t.y,a.x,a.y,l.x,l.y]}]),d={type:"A",values:[y,c,0,0,f,l.x,l.y]};i=Math.PI*(y*c)/4,i-=Math.abs(me([e,l,p])),function(e,t){let a=Math.abs(e-t);return Math.abs(100-100/e*(e+a))}(m,i)<n&&(o=!0,s=d)}}return{com:s,isArc:o,area:i,rx:y,ry:c,centroid:r}}function Pt(e,{angles:t=[],split:a=0,getPathData:l=!0,width:n=0,height:r=0}={}){let s=e.length,i={x:e[0].values[0],y:e[0].values[1]},o=i,p=[],u=[o],h=0;if(a=a||1,n&&r)h=.025*(n+r)/a;else{h=e.map(e=>e.dimA||0).filter(Boolean).sort()[0]}for(let t=1;t<s;t++){let l=e[t],n=e[t+1]||null,{type:r,values:s}=l,p=s.length,y=p?{x:s[p-2],y:s[p-1]}:i;if("C"===r||"Q"===r){let e={x:s[0],y:s[1]},t="C"===r?{x:s[2],y:s[3]}:e,n="C"===r?[o,e,t,y]:[o,e,y],i=l.dimA;a=Math.ceil(i/h);let p=[];for(let e=1;e<a;e++)p.push(1/a*e);p.forEach(e=>{let t=H(n,e);u.push(t)})}"M"===r&&(i=y),y.area=l.cptArea||0,y.isExtreme=l.extreme||!1,y.isCorner=l.corner||!1,y.isDirChange=l.directionChange||!1,u.push(y),l.extreme||l.corner||n&&n.type,o=y}return u=function(e,{quality:t=.9,width:a=0,height:l=0,absolute:n=!1,manhattan:r=!1,exclude:s=[]}={}){"string"==typeof t&&(n=!0,t=parseFloat(t));if(e.length<4||(!n&&t)>=1)return e;let i=t;if(!n){if(i=1-t,!a&&!l){let t=oe(e,12);({width:a,height:l}=ce(t))}i=r?.05*(a+l)*(1-t):(i*((a+l)/2/25))**2}let o,p=e[0],u=[p],h=e.length,y=s.length,c=0;for(let t=1;t<h;t++)o=e[t],c=r?se(p,o):re(p,o),!(c<i)||y&&s.includes(t)?(u.push(o),p=o):p=o;return p.x!==o.x&&p.y!==o.y&&u.push(o),u}(u,{quality:.5,width:n,height:r}),p=function(e,t=!0){let a=[{type:"M",values:[e[0].x,e[0].y]},...e.slice(1).map(e=>({type:"L",values:[e.x,e.y]}))];return t&&a.push({type:"Z",values:[]}),a}(u),l?p:u}function St(e="",{getObject:t=!1,toAbsolute:a=!0,toRelative:l=!0,toShorthands:n=!0,quadraticToCubic:r=!0,arcToCubic:s=!1,cubicToArc:i=!1,simplifyBezier:o=!0,optimizeOrder:p=!0,autoClose:u=!0,removeZeroLength:h=!0,refineClosing:y=!0,removeColinear:c=!0,flatBezierToLinetos:x=!0,revertToQuadratics:f=!0,refineExtremes:g=!0,simplifyCorners:m=!1,keepExtremes:d=!0,keepCorners:v=!0,extrapolateDominant:M=!0,keepInflections:b=!1,addExtremes:A=!1,addSemiExtremes:C=!1,smoothPoly:w=!1,harmonizeCpts:k=!1,toPolygon:E=!1,removeOrphanSubpaths:L=!1,simplifyRound:P=!1,scale:S=1,scaleTo:T=0,crop:I=!1,alignToOrigin:F=!1,decimals:D=3,autoAccuracy:$=!0,minifyD:z=0,tolerance:q=1,reverse:j=!1,cleanupSVGAtts:Q=!0,removePrologue:B=!0,stylesToAttributes:N=!0,fixHref:G=!0,removeNameSpaced:O=!0,attributesToGroup:U=!1,mergePaths:Z=!1,removeHidden:H=!0,removeUnused:V=!0,shapesToPaths:W=!0,tMin:J=0,tMax:X=1,redraw:Y=!1}={}){q=Math.max(.1,q),S=Math.max(.001,S);let _=function(e){let t="string";if(Array.isArray(e))return e[0]?.type&&e[0]?.values?"pathData":"array";if("string"==typeof e){let a=(e=e.trim()).includes("<svg")&&e.includes("</svg"),l=e.startsWith("M")||e.startsWith("m"),n=!isNaN(e.substring(0,1))&&!isNaN(e.substring(e.length-1,e.length));if(a)t="svgMarkup";else if(l)t="pathDataString";else if(n)t="polyString";else{let a=/^(file:|https?:\/\/|\/|\.\/|\.\.\/)/.test(e),l=e.startsWith("data:image");t=a||l?"url":"string"}return t}return t=typeof e,(e.constructor.name||t).toLowerCase()}(e),K="",ee=0,te=0,ae=0,le={},ne="",re="svgMarkup"===_?1:0,se=[];ee=e.length;let ie={x:0,y:0,width:0,height:0},oe={x:0,y:0,width:0,height:0},ue=[],he=[];if(re){if(K=mt(e,{cleanupSVGAtts:Q,returnDom:!0,removeHidden:H,removeUnused:V,removeNameSpaced:O,attributesToGroup:U,stylesToAttributes:N,removePrologue:B,fixHref:G,mergePaths:Z}),W){K.querySelectorAll("polygon, polyline, line, rect, circle, ellipse").forEach(e=>{let t=Ze(e);e.replaceWith(t)})}K.querySelectorAll("path").forEach(e=>{se.push({d:e.getAttribute("d"),el:e})}),ie=function(e=null,t=-1){const a=e=>e&&isNaN(e)?e.match(/[^\d|.]+/g)[0]:"";if(!e)return!1;let l=e.hasAttribute("width"),n=e.hasAttribute("height"),r=e.hasAttribute("viewBox"),s=l?e.getAttribute("width"):0,i=n?e.getAttribute("height"):0,o=!!l&&a(s),p=!!n&&a(s),u=s?s.includes("%")?0:parseFloat(s):300,h=i?i.includes("%")?0:parseFloat(i):150,y=r?e.getAttribute("viewBox").split(/,| /).filter(Boolean).map(Number):[0,0,u,h];return t>-1&&([u,h]=[u,h].map(e=>+e.toFixed(t)),y=y.map(e=>+e.toFixed(t))),{x:y[0],y:y[1],width:y[2],height:y[3],w:u,h:h,hasViewBox:r,hasWidth:l,hasHeight:n,widthUnit:o,heightUnit:p}}(K,D)}else{if("pathDataString"===_)ne=e;else if("polyString"===_)ne="M"+e;else if("pathData"===_){ne=e,ee=ne.map(e=>`${e.type} ${e.values.join(" ")}`).join(" ").length}se.push({d:ne,el:null})}let xe={toRelative:l,toShorthands:n,decimals:D},fe=[];for(let e=0,t=se.length;t&&e<t;e++){let t=se[e],{d:l,el:n}=t,Q=je(l,{quadraticToCubic:r,toAbsolute:a,arcToCubic:s}),B=w||E?ce(R(Q)):null;if(1!==S||T){if(T)if(ie.width&&!I)S=T/ie.width;else{let e=Q.map(e=>({type:e.type,values:e.values}));e=Pe(e,{arcToCubic:!0}),e=ye(e);let t=ce(R(e));ue.push(t.x,t.x+t.width),he.push(t.y,t.y+t.height);let a=T/t.width;S=a}Q=Ct(Q,S)}let N=Q.length;L&&(Q=Re(Q));let G=pe(Q),O=G.length,U=[];for(let e=0;e<O;e++){let t=G[e];if(E){o=!1,w=!1,k=!1,t=He(t);let e=Ee(t),{bb:a,pathData:l}=e;t=l,t=Pt(t,{angles:[],split:1,width:B.width,height:B.height,getPathData:!0})}if(w){let e=Array.from(new Set(t.map(e=>e.type))).join(""),a=!/[acqts]/gi.test(e),l=/[z]/gi.test(e);if(a){t=Ve(t),t=ut(R(t),{denoise:.8,tolerance:q,width:B.width,height:B.height,manhattan:!1,absolute:!1,keepCorners:v,keepExtremes:d,keepInflections:b,closed:l})}}k&&(t=Ye(t)),(c||h)&&(t=Ve(t)),Y&&(A=!0,C=!0,m=!1,v=!0,d=!0,p=!0,J=0,X=0),p&&(t=We(t)),c&&(t=He(t,{tolerance:q,flatBezierToLinetos:!1})),(A||C)&&(t=ye(t,{tMin:J,tMax:X,addExtremes:A,addSemiExtremes:C,angles:[30]}));let a=Ee(t,{detectSemiExtremes:C}),{pathData:l,bb:n,dimA:r}=a;if(ue.push(n.x,n.x+n.width),he.push(n.y,n.y+n.height),y&&(l=At(l,{threshold:.001*r})),l=o?Me(l,{simplifyBezier:o,keepInflections:b,keepExtremes:d,keepCorners:v,extrapolateDominant:M,revertToQuadratics:f,tolerance:q,reverse:j}):l,g){l=ht(l,{threshold:.05*(n.width+n.height),tolerance:q})}if(Y&&(n.width,n.height,l=wt(l,{tolerance:q,threshold:.001*r})),i&&(l=Et(l,{areaThreshold:2.5})),c&&x&&(l=He(l,{tolerance:q,flatBezierToLinetos:x})),m){l=vt(l,{threshold:.1*(n.width+n.height),tolerance:q})}P&&(l=bt(l)),f&&(l=kt(l)),p&&(l=Je(l,{autoClose:u})),U.push({pathData:l,bb:n})}let H=Math.min(...ue),V=Math.min(...he);oe={x:H,y:V,width:Math.max(...ue)-H,height:Math.max(...he)-V};let W=oe.height>oe.width;if(p&&(U=W?U.sort((e,t)=>e.bb.y-t.bb.y||e.bb.x-t.bb.x):U.sort((e,t)=>e.bb.x-t.bb.x||e.bb.y-t.bb.y)),Q=[],U.forEach(e=>{Q.push(...e.pathData)}),$&&(D=Ce(Q),xe.decimals=D),Z=!1,n&&Z)fe.push(...Q);else{Q=Pe(Q,xe),Q=Ve(Q),F&&(console.log(oe),Q[0].values[0]=(Q[0].values[0]-oe.x).toFixed(D),Q[0].values[1]=(Q[0].values[1]-oe.y).toFixed(D),oe.x=0,oe.y=0);let e=Q.length,a=de(Q,z);te=a.length,ae=+(100/ee*te).toFixed(2),t.d=a,t.report={original:N,new:e,saved:N-e,compression:ae,decimals:D},n&&n.setAttribute("d",a)}}if(re){if(fe.length){let e=Pe(fe,xe);e=Ve(e);let t=de(e,z);se[0].el.setAttribute("d",t);for(let e=1;e<se.length;e++){let t=se[e].el;t&&t.remove()}!function(e){e.querySelectorAll("g, defs").forEach(e=>{e.children.length||e.remove()})}(K)}if(S){let{x:e,y:t,width:a,height:l,w:n,h:r,hasViewBox:s,hasWidth:i,hasHeight:o,widthUnit:p,heightUnit:u}=ie;I&&(e=oe.x,t=oe.y,a=oe.width,l=oe.height,n=a,r=l),s&&K.setAttribute("viewBox",[e,t,a,l].map(e=>+(e*S).toFixed(D)).join(" ")),i&&K.setAttribute("width",+(n*S).toFixed(D)+p),o&&K.setAttribute("height",+(r*S).toFixed(D)+u)}K=dt(K),te=K.length,ae=+(100/ee*te).toFixed(2),ee=+(ee/1024).toFixed(3),te=+(te/1024).toFixed(3),le={svgSize:ee,svgSizeOpt:te,compression:ae,decimals:D}}else({d:ne,report:le}=se[0]);return t?{svg:K,d:ne,report:le,inputType:_,mode:re}:ne||K}"undefined"!=typeof window&&(window.svgPathSimplify=St);export{b as PI,a as abs,l as acos,n as asin,r as atan,s as atan2,i as ceil,o as cos,p as exp,u as floor,y as hypot,h as log,c as max,x as min,f as pow,g as random,m as round,d as sin,v as sqrt,St as svgPathSimplify,M as tan};
|
|
11
|
+
(M||b)&&(v=!0);let A=a.area<0&&l.area>0||a.area>0&&l.area<0,C=A&&!c;if(y=C,d&&!a.isDirChange&&(v=!0),b&&a.isHorizontal&&(a.isCorner=!0,a.isExtreme=!1,v=!1),C&&(a.isDirChange||a.isExtreme)&&(C=!1,l.isDirChange=!1),a.isExtreme&&u>h&&!C&&l.isHorizontal,v||A||u>p){let e=O(l,n,a),{deltaAngleDeg:t}=e;t=Math.abs(t),y=!(t<3||t>160)}l.isCorner=y,l.isExtreme=v,l.isHorizontal=M,l.isVertical=b,l.isDirChange=C}let p=[],u=[];for(let t=0;t<e.length;t++){let a=e[t],l=e[t+1]||null,n=e[t+2]||null,r=[];if(l&&l.isExtreme&&a.isExtreme&&!a.isCorner){let e=l.dist<2*o&&!l.isCorner,s=n&&n.isExtreme&&n.dist<2*o&&!n.isCorner;if(e&&!s?r.push(a,l):s&&r.push(a,l,n),r.length){let e=r.reduce((e,t)=>e+t.x,0)/r.length,l=r.reduce((e,t)=>e+t.y,0)/r.length;a.x=e,a.y=l,t+=r.length-1}}(a.isExtreme||a.isCorner||a.isDirChange)&&u.push(p.length),p.push(a)}let h=p.length,y=p[0],c=p[h-1],x=se(y,c)<2*o;return y.isExtreme&&c.isExtreme&&x&&(c.x=y.x,c.y=y.y),p}(e,{debug:!1}):e,c=s||r?function(e,{closed:t=!0,keepCorners:a=!0,keepExtremes:l=!0,keepInflections:n=!1}={}){let r=[],s=[e[0]],i=e.length;for(let t=1;t<i;t++){t>0?e[t-1]:e[i-1];let n=e[t],o=t<i-1?e[t+1]:e[i-1];s.push(n),t>0&&(l&&o.isExtreme||a&&o.isCorner)&&(r.push(s),s=[])}return!r.length&&e.length>1&&(r=[e]),r}(y,{keepCorners:r,keepExtremes:s,keepInflections:i}):[y],x=a&&l?(a+l)/2*.004*h:2.5;x=2;let f=function(e=[],{closed:t=!0,tolerance:a=1}={}){let l=e.length,n=[{type:"M",values:[e[0][0].x,e[0][0].y]}];for(let t=0;t<l;t++){let l=e[t],r=e[t+1]?e[t+1]:null,s=[],i=l.length;l[l.length-1],r&&l.push(r[0]),i<2||2===i&&l[1].isExtreme?(l[l.length-1],s=l.map(e=>({type:"L",values:[e.x,e.y]}))):s=_e(l,a),n.push(...s)}t&&n.push({type:"Z",values:[]});return function(e){let t=e.length;for(let a=1;a<t;a++){let t=e[a],l=e[a+1]||null,{type:n,values:r}=t;if("C"===n&&l&&"C"===l.type){let n=l.values;r[0],r[1];let s={x:r[2],y:r[3]},i={x:r[4],y:r[5]},o={x:n[0],y:n[1]};n[2],n[3];let p,u,h=Math.abs(s.x-i.x),y=Math.abs(s.y-i.y),c=Math.abs(o.x-i.x),x=Math.abs(o.y-i.y),f=.02*se(o,s),g=y<f&&h>f,m=x<f&&c>f,d=h<f&&y>f,v=c<f&&x>f;(g||d)&&(p=g?{x:t.values[2],y:i.y}:d?{x:i.x,y:t.values[3]}:{x:t.values[2],y:t.values[3]},t.values[2]=p.x,t.values[3]=p.y),(m||v)&&(u=m?{x:l.values[0],y:i.y}:v?{x:i.x,y:l.values[1]}:{x:l.values[0],y:l.values[1]},e[a+1].values[0]=u.x,e[a+1].values[1]=u.y)}}}(n),n}(c,{closed:u,tolerance:2});return f}function ht(e,{threshold:t=null,tolerance:a=1}={}){if(!t){let a=function(e){let t=1/0,a=-1/0,l=1/0,n=-1/0;const r=e=>{e.x<t&&(t=e.x),e.x>a&&(a=e.x),e.y<l&&(l=e.y),e.y>n&&(n=e.y)};for(let t=0;t<e.length;t++){let a=e[t],{type:l,values:n}=a,s=n.length,i=(e[t-1]?e[t-1]:e[t]).values,o=i.length;if(s){let e={x:i[o-2],y:i[o-1]},t={x:n[s-2],y:n[s-1]};if(r(t),"C"===l||"Q"===l){let a={x:n[0],y:n[1]},s="C"===l?{x:n[2],y:n[3]}:a,i="C"===l?[e,a,s,t]:[e,a,t];_(i).forEach(e=>{let t=H(i,e);r(t)})}else"A"===l&&K(e,n).forEach(e=>{r(e)})}}return{x:t,y:l,width:a-t,height:n-l}}(e);t=.05*(a.width+a.height)}let l=e.length;for(let n=0;n<l;n++){let l=e[n],{type:r,values:s,extreme:i,corner:o=!1,dimA:p,p0:u,p:h}=l,y=e[n+1]?e[n+1]:null,c=e[n+2]?e[n+2]:null,x=(y?se(h,y.p):1/0)<t,f=(c?se(c.p,y.p):1/0)<1*t;if(y&&c&&"C"===r&&"C"===y.type&&i&&c.extreme&&(f||x)){let l=ve(y,c,t,a,!1);if(1===l.length){l=l[0],e[n+1]=null,e[n+2].values=[l.cp1.x,l.cp1.y,l.cp2.x,l.cp2.y,l.p.x,l.p.y],e[n+2].cp1=l.cp1,e[n+2].cp2=l.cp2,e[n+2].p0=l.p0,e[n+2].p=l.p,e[n+2].extreme=l.extreme,n++;continue}}if(y&&"C"===r&&"C"===y.type&&i&&x){let e=me([l.p0,l.p,y.p]),t=me([l.p0,l.cp1,l.cp2,l.p]);if(e<0&&t>0||e>0&&t<0)continue}}l=(e=e.filter(Boolean)).length;let n="z"===e[l-1].type.toLowerCase()?l-2:l-1,r=e[n],s=e[n-1]||null,i={x:e[0].values[0],y:e[0].values[1]},o=r.values.slice(-2),p=+o[0].toFixed(8)===+i.x.toFixed(8)&&+o[1].toFixed(8)===+i.y.toFixed(8),u="C"===e[1].type&&e[1].extreme?e[1]:null,h=se(r.p0,r.p)<t;if(s&&"C"===s.type&&h&&p&&u){let l=ve(s,r,t,a,!1);1===l.length&&(e[n-1]=l[0],e[n]=null,e=e.filter(Boolean))}return e}function yt({transforms:e=[],transformOrigin:t={x:0,y:0}}={}){let a=function(e=[],t={x:0,y:0}){const a=(e,t)=>({a:e.a*t.a+e.c*t.b,b:e.b*t.a+e.d*t.b,c:e.a*t.c+e.c*t.d,d:e.b*t.c+e.d*t.d,e:e.a*t.e+e.c*t.f+e.e,f:e.b*t.e+e.d*t.f+e.f}),l=(e,t)=>({a:1,b:0,c:0,d:1,e:e,f:t}),n=(e,t)=>({a:e,b:0,c:0,d:t,e:0,f:0}),r=(e,t)=>{const a=e=>e*Math.PI/180;let[l,n]=e.map(e=>a(e)),r={};if("rot"===t){let e=Math.cos(l),t=Math.sin(l);r={a:e,b:t,c:-t,d:e,e:0,f:0}}else if("skew"===t){let e=Math.tan(l);r={a:1,b:Math.tan(n),c:e,d:1,e:0,f:0}}return r};let s={a:1,b:0,c:0,d:1,e:0,f:0};0===t.x&&0===t.y||(s=a(s,l(t.x,t.y)));const i={translate:[0,0],scale:[1,1],skew:[0,0],rotate:[0],matrix:[1,0,0,1,0,0]};for(const t of e){const e=Object.keys(t)[0],o=t[e]||i[e];let[p,u=i[e][1]]=o;switch("rotate"===e&&3===o.length&&(p=o[2]),e){case"matrix":let t=["a","b","c","d","e","f"];s=a(s,Object.fromEntries(t.map((e,t)=>[e,o[t]])));break;case"translate":(p||u)&&(s=a(s,l(p,u)));break;case"skew":(p||u)&&(s=a(s,r([p,u],"skew")));break;case"rotate":p&&(s=a(s,r([p],"rot")));break;case"scale":1===p&&1===u||(s=a(s,n(p,u)));break;default:throw new Error(`Unknown transformation type: ${e}`)}}0===t.x&&0===t.y||(s=a(s,l(-t.x,-t.y)));return s}(e,t);return a}const ct=["path","polygon","polyline","line","rect","circle","ellipse"],xt=["textPath","text","tspan"],ft={atts:{id:"*",class:"*",viewBox:["symbol","svg"],preserveAspectRatio:["symbol","svg"],width:["svg","rect","use","image"],height:["svg","rect","use","image"],d:["path"],points:["polygon","polyline"],x:["image","rect","text","textPath","tspan","use","mask"],y:["image","rect","text","textPath","tspan","use","mask"],x1:["line","linearGradient"],x2:["line","linearGradient"],y1:["line","linearGradient"],y2:["line","linearGradient"],r:["circle","radialGradient"],rx:["rect","ellipse"],ry:["rect","ellipse"],cx:["circle","ellipse","radialGradient"],cy:["circle","ellipse","radialGradient"],refX:["symbol","markers"],refY:["symbol","markers"],transform:["svg","g","use",...ct,...xt],"transform-origin":["svg","g","use",...ct,...xt],fill:["svg","g","use",...ct,...xt,"animate","animateMotion"],"fill-opacity":["svg","g","use",...ct,...xt],opacity:["svg","g","use",...ct,...xt],stroke:["svg","g","use",...ct,...xt],"stroke-width":["svg","g","use",...ct,...xt,"mask"],"stroke-opacity":["svg","g","use",...ct,...xt,"mask"],"stroke-miterlimit":["svg","g","use",...ct,...xt,"mask"],"stroke-linejoin":["svg","g","use",...ct,...xt,"mask"],"stroke-linecap":["svg","g","use",...ct,...xt,"mask"],"stroke-dashoffset":["svg","g","use",...ct,...xt,"mask"],"stroke-dasharray":["svg","g","use",...ct,...xt,"mask"],"clip-path":["svg","g","use",...ct,...xt],"clip-rule":["path","polygon"],clipPathUnits:["clipPath"],mask:["svg","g","use",...ct,...xt],maskContentUnits:["mask"],maskUnits:["mask"],"font-family":["svg","g",...xt],"font-size":["svg","g",...xt],"font-style":["svg","g",...xt],"font-weight":["svg","g",...xt],"font-stretch":["svg","g",...xt],"dominant-baseline":[...xt],lengthAdjust:[...xt],"text-anchor":["text"],textLength:["text","textPath","tspan"],dx:["text","tspan"],dy:["text","tspan"],method:["textPath"],spacing:["textPath"],startOffset:["textPath"],rotate:["text","tspan","animateMotion"],side:["textPath"],"white-space":["svg","g",...xt],color:["svg","g",...xt],playbackorder:["svg"],timelinebegin:["svg"],dur:["animate","animateTransform","animateMotion"],end:["animate","animateTransform","animateMotion"],from:["animate","animateTransform","animateMotion"],to:["animate","animateTransform","animateMotion"],type:["animateTransform"],values:["animate","animateTransform","animateMotion"],accumulate:["animate","animateTransform","animateMotion"],additive:["animate","animateTransform","animateMotion"],attributeName:["animate","animateTransform"],begin:["animate","animateTransform","animateMotion"],by:["animate","animateTransform","animateMotion"],calcMode:["animate","animateTransform","animateMotion"],keyPoints:["animateMotion"],keySplines:["animate","animateTransform","animateMotion"],keyTimes:["animate","animateTransform","animateMotion"],max:["animate","animateTransform","animateMotion"],min:["animate","animateTransform","animateMotion"],origin:["animateMotion"],repeatCount:["animate","animateTransform","animateMotion"],repeatDur:["animate","animateTransform","animateMotion"],restart:["animate","animateTransform","animateMotion"],gradientUnits:["linearGradient","radialGradient"],gradientTransform:["linearGradient","radialGradient"],fr:["radialGradient"],fx:["radialGradient"],fy:["radialGradient"],offset:["stop"],"stop-color":["stop"],"stop-opacity":["stop"],spreadMethod:["linearGradient","radialGradient"],href:["pattern","textPath","linearGradient","radialGradient","use","animate","animateTransform","animateMotion","image"],pathLength:[...ct]},defaults:{transform:["none","matrix(1, 0, 0, 1, 0, 0)"],"transform-origin":["0px, 0px","0 0"],rx:["0","0px"],ry:["0","0px"],x:["0","0px"],y:["0","0px"],fill:["black","rgb(0, 0, 0)","rgba(0, 0, 0, 0)","#000","#000000"],color:["black","rgb(0, 0, 0)","rgba(0, 0, 0, 0)","#000","#000000"],stroke:["none"],"stroke-width":["1","1px"],opacity:["1"],"fill-opacity":["1"],"stroke-opacity":["1"],"stroke-linecap":["butt"],"stroke-miterlimit":["4"],"stroke-linejoin":["miter"],"stroke-dasharray":["none"],"stroke-dashoffset":["0","0px","none"],pathLength:["none"],"font-family":["serif"],"font-weight":["normal","400"],"font-stretch":["normal"],"font-width":["normal"],"letter-spacing":["auto","normal","0"],lengthAdjust:["spacing"],"text-anchor":["start"],"dominant-baseline":["auto"],spacing:["auto"],"white-space":["normal"],"stop-opacity":["1"],gradientUnits:["objectBoundingBox"],patternUnits:["objectBoundingBox"],"clip-path":["none"],"clip-rule":["nonzero"],"fill-rule":["nonzero"],clipPathUnits:["userSpaceOnUse"],mask:["none"],maskUnits:["objectBoundingBox"]}};function gt(e,{removeNameSpaced:t=!0,decimals:a=-1}={}){let l=e.nodeName.toLowerCase(),n=function(e){let t={},a=[...e.attributes].map(e=>e.name),l=a.length;if(!l)return t;for(let n=0;n<l;n++){let l=a[n],r=e.getAttribute(l);t[l]=r}return t}(e),r=function(e){let t=e.getAttribute("style"),a=t?function(e=""){let t={};if(!e)return t;let a=e.split(";").filter(Boolean).map(e=>e.trim()),l=a.length;if(!l)return t;for(let e=0;l&&e<l;e++){let l=a[e],[n,r]=l.split(":").filter(Boolean);t[n]=r}return t}(t):{};return a}(e),s={...n,...r},i={},o=r.transform;if(o){let e=yt(function(e,t={x:0,y:0}){let a,l={transforms:[],transformOrigin:t},n=/(\w+)\(([^)]+)\)/g;function r(e){if("string"==typeof e){if(e.includes("rad"))return parseFloat(e)*(180/Math.PI);if(e.includes("turn"))return 360*parseFloat(e)}return parseFloat(e)}for(;null!==(a=n.exec(e));){let e=a[1],t=a[2].split(/,\s*/).map(e=>r(e));switch(e){case"translate":l.transforms.push({translate:[t[0]||0,t[1]||0]});break;case"translateX":l.transforms.push({translate:[t[0]||0,0,0]});break;case"translateY":l.transforms.push({translate:[0,t[0]||0,0]});break;case"scale":l.transforms.push({scale:[t[0]||0,t[1]||0]});break;case"skew":l.transforms.push({skew:[t[0]||0,t[1]||0]});break;case"skewX":l.transforms.push({skew:[t[0]||0,0]});break;case"skewY":l.transforms.push({skew:[0,t[0]||0]});break;case"rotate":l.transforms.push({rotate:[0,0,t[0]||0]});break;case"matrix":l.transforms.push({matrix:t})}}return e.split(/;\s*/).forEach(e=>{let[t,a]=e.split(":").map(e=>e.trim());if("transform-origin"===t||"perspective-origin"===t){let[e,n]=a.split(/\s+/).map(parseFloat);"transform-origin"===t&&(l.transformOrigin={x:e||0,y:n||0})}}),l}(`${o}`));s.transform=`matrix(${Object.values(e).join(",")})`}let p=["inline-size"],u=[];for(let a in s){let n=s[a];n&&a.startsWith("--")||p.includes(a)||!t&&a.startsWith("-")?u.push(`${a}:${n}`):(n&&ft.atts[a]&&("*"===ft.atts[a]||ft.atts[a].includes(l)||!t&&a.includes(":"))&&(i[a]=n),e.removeAttribute(a))}for(let t in i){let a=i[t];e.setAttribute(t,a)}return u.length&&e.setAttribute("style",u.join(";")),i}function mt(e,{returnDom:t=!1,removeHidden:a=!0,removeUnused:l=!0,stylesToAttributes:n=!0,removePrologue:r=!0,fixHref:s=!0,mergePaths:i=!1,cleanupSVGAtts:o=!0,removeNameSpaced:p=!0,attributesToGroup:u=!0,decimals:h=-1,excludedEls:y=[]}={}){e=e.replace(/<\?xml[\s\S]*?\?>/gi,"").replace(/<!DOCTYPE[\s\S]*?>/gi,"").replace(/<!--[\s\S]*?-->/g,"").trim(),s&&(e=e.replaceAll("xlink:href=","href="));let c=(new DOMParser).parseFromString(e,"text/html").querySelector("svg");if(o){!function(e,t=["viewBox","xmlns","width","height","id","class"]){[...e.attributes].map(e=>e.name).forEach(a=>{t.includes(a)||e.removeAttribute(a)})}(c,["viewBox","xmlns","width","height","id","class","fill","stroke","stroke-width","stroke-linecap","stroke-linejoin"])}let x=["metadata","script",...y],f=c.querySelectorAll("*"),g=[];for(let e=0;e<f.length;e++){let t=f[e],l=t.nodeName.toLowerCase(),r=t.getAttribute("style")||"",s=!!r&&r.trim().includes("display:none"),o=t.getAttribute("display")&&"none"===t.getAttribute("display")||s;if(l.includes(":")||x.includes(l)||a&&o)t.remove();else if(n||u||i){let a=gt(t,{removeNameSpaced:p,decimals:h});"path"===l&&g.push({el:t,name:l,idx:e,propsFiltered:a})}}return(u||i)&&function(e=[],t=!0){let a=[[e[0]]],l=0,n="";for(let t=0;t<e.length;t++){let r=e[t],s=r.propsFiltered,i=[];for(let e in s)"d"!==e&&"id"!==e&&i.push(`${e}:${s[e]}`);i=i.join("_"),r.propstr=i,i===n?a[l].push(r):a[l].length&&(a.push([]),l++),n=i}for(let e=0;e<a.length;e++){let l=a[e];if(l.length>1){let e=l[0].el,a=l[0].propsFiltered,n=e.parentNode.closest("g")?e.parentNode.closest("g"):null;n||(n=document.createElementNS("http://www.w3.org/2000/svg","g"),e.parentNode.insertBefore(n,e),l.forEach(e=>{n.append(e.el)}));let r=[...n.children];for(let e in a){if("d"!==e&&"id"!==e){let t=a[e];n.setAttribute(e,t),r.forEach(a=>{a.getAttribute(e)===t&&a.removeAttribute(e)})}if(t){let e=l[0].el,t=l[0].propsFiltered.d;for(let e=1;e<l.length;e++){let a=l[e],n=a.el,r=a.propsFiltered.d;t+=r.startsWith("M")?r:Ue(r).pathData.map(e=>`${e.type} ${e.values.join(" ")}`).join(" "),n.remove()}e.setAttribute("d",t)}}}}}(g,i),t?c:dt(c)}function dt(e){let t=(new XMLSerializer).serializeToString(e);return t=t.replace(/\t/g,"").replace(/[\n\r|]/g,"\n").replace(/\n\s*\n/g,"\n").replace(/ +/g," "),t}function vt(e,{threshold:t=0,tolerance:a=1}={}){let l=e.length,n=[e[0]],r="z"===e[l-1].type.toLowerCase(),s=!!r&&(e[l-1].p.x===e[0].p0.x&&e[l-1].p.y===e[0].p0.y),i=r?2:1,o=e[l-i],p="L"===o.type,u="C"===o.type,h="L"===e[1].type,y="C"===e[1].type,c=r&&y&&(p||s);c&&(e[l-1].values=e[0].values,e[l-1].type="L",p=!0);for(let t=1;t<l;t++){let s=e[t],{type:o}=s,x=e[t+1]?e[t+1]:null;if("L"===o&&x&&"C"===x.type||"C"===o&&x&&"L"===x.type){let c="L"===o?s:null,f=null,g=[],m=0;if(1===t&&y&&p&&(g=[e[1]],c=e[l-1],f=x),!c){n.push(s);continue}r&&u&&h&&t===l-i-1&&(f=e[1],g=[e[l-i]]);for(let a=t+1;a<l;a++){let t=e[a]?e[a]:null,l=e[a-1];if("C"===l.type&&g.push(l),"L"===t.type&&"C"===l.type){f=t;break}m++}if(f){let e=se(c.p0,c.p),l=se(f.p0,f.p);g.length;let r=se(c.p,f.p0),i=me([c.p0,c.p,f.p0,f.p],!1),o=me([g[0].p0,g[0].cp1,g[0].cp2,g[0].p],!1),p=i<0&&o>0||i>0&&o<0,u=.5*r*a,h=u<e&&u<l;if(g.length&&!p&&h){let e=Math.abs(o)<=.005*re(g[0].p0,g[0].p),a=e?null:U(c.p0,c.p,f.p0,f.p,!1);if(!e&&a){let e=.75*se(H([c.p,a,f.p0],.5),1===g.length?H([g[0].p0,g[0].cp1,g[0].cp2,g[0].p],.5):g[0].p);if(u&&e>u&&e>.3*r){n.push(s);continue}{let e={type:"Q",values:[a.x,a.y,f.p0.x,f.p0.y]};e.p0=c.p,e.cp1=a,e.p=f.p0,n.push(c,e),t+=m;continue}}}}}c&&t===l-1&&"L"===o||n.push(s)}return(c||r&&"Z"!==n[n.length-1].type)&&n.push({type:"Z",values:[]}),n}function Mt(e){if(e.length<3)return!1;let t=e[0],a=e[Math.floor(e.length/2)],l=e[e.length-1],n=t.x,r=t.y,s=a.x,i=a.y,o=l.x,p=l.y,u=n-s,h=r-i,y=n-o,c=r-p,x=(n*n-s*s+(r*r-i*i))/2,f=(n*n-o*o+(r*r-p*p))/2,g=u*c-h*y;if(Math.abs(g)<1e-10)return console.warn("Points are collinear or numerically unstable"),!1;let m={x:(c*x-h*f)/g,y:(-y*x+u*f)/g},d=ne(m,t),v=O(m,t,l),{deltaAngle:M,startAngle:b,endAngle:A}=v;return{centroid:m,r:d,startAngle:b,endAngle:A,deltaAngle:M}}function bt(e,{threshold:a=0,tolerance:l=1,toCubic:n=!1,debug:r=!1}={}){let s=e.length,i=[e[0]],o=[];for(let a=1;a<s;a++){let l=e[a],{type:s}=l,p=e[a-1],u=e[a+1]?e[a+1]:null,h=e[a+2]?e[a+2]:null,y=e[a+3]?e[a+3]:null,c=null;"C"===l.type||"Q"===l.type?c=l:!u||"C"!==u.type&&"Q"!==u.type||(c=u);let x,f,g,m,d,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,w=[];if("L"===p.type&&"L"===s&&c&&"L"===h.type&&y&&("L"===y.type||"Z"===y.type)?(x=[l.p0,l.p],f=[h.p0,h.p],g=l.p0,m=h.p,M=me(v,!1),b=me([...x,...f],!1),A=M<0&&b>0||M>0&&b<0,A||(d=H(v,.5),w=[g,d,m],C=!0)):"C"!==s&&"Q"!==s||"L"!==p.type||"C"!==u.type&&"Q"!==u.type||"L"!==h.type||(C=!0,x=[p.p0,p.p],f=[h.p0,h.p],g=p.p,m=h.p0,d=c.p,w=[g,c.p,m]),C){let e=Mt(w);if(e){let s,{centroid:p,r:u,deltaAngle:h,startAngle:y,endAngle:c}=e,x=0,f=h>0?1:0,v=Math.abs(h)>Math.PI?1:0;if(ie(W(g,p.x,p.y,.5*h),d)<.05*ie(g,m)){if(s=ze({p0:g,p:m,centroid:p,rx:u,ry:u,xAxisRotation:x,sweep:f,largeArc:v,deltaAngle:h,startAngle:y,endAngle:c}),1===s.length){let e=Le(g,s[0].cp1,s[0].cp2,m);"Q"===e.type&&(n=!0),l=e}if(s.length>1&&(n=!1),n||(l.type="A",l.values=[u,u,x,v,f,m.x,m.y]),l.p0=g,l.p=m,l.extreme=!1,l.corner=!1,r){o=n?[{type:"M",values:[g.x,g.y]},...s]:[{type:"M",values:[g.x,g.y]},{type:"A",values:[u,u,x,v,f,m.x,m.y]}];let e=de(o);t(markers,e,"orange","0.5%","0.5")}i.push(l),a++;continue}}}i.push(l)}return i}function At(e=[],{threshold:t=0}={}){let a=e.length,l="z"===e[a-1].type.toLowerCase(),n=l?a-2:a-1,r=e[n],s=r.values.slice(-2),i={x:e[0].values[0],y:e[0].values[1]},o=ie(i,{x:s[0],y:s[1]});if(o&&o<t){let a=e[n].values.length;e[n].values[a-2]=i.x,e[n].values[a-1]=i.y;let l=e[1];if("C"===l.type&&"C"===r.type){let a=Math.abs(l.values[0]-r.values[2]),s=Math.abs(l.values[1]-r.values[3]),o=Math.abs(e[1].values[0]-l.values[0]),p=Math.abs(e[1].values[1]-l.values[1]),u=Math.abs(e[1].values[0]-r.values[2]),h=Math.abs(e[1].values[1]-r.values[3]),y=p<t&&h<t&&a;a&&a<t&&(o<t&&u<t&&s)&&(e[1].values[0]=i.x,e[n].values[2]=i.x),s&&s<t&&y&&(e[1].values[1]=i.y,e[n].values[3]=i.y)}}return e}function Ct(e,t=1){let a=[];for(let l=0,n=e.length;l<n;l++){let n=e[l],{type:r,values:s}=n,i={type:r,values:[]};switch(r.toLowerCase()){case"h":case"v":i.values=[s[0]*t];break;case"a":i.values=[s[0]*t,s[1]*t,s[2],s[3],s[4],s[5]*t,s[6]*t];break;default:s.length&&(i.values=s.map((e,a)=>e*t))}a.push(i)}return a}function wt(e,{tolerance:a=1}={}){let l=[],n=[],r=e.length;for(let t=1;t<r;t++){let a=e[t],{type:r,values:s,p0:i,cp1:o=null,cp2:p=null,p:u,extreme:h=null,semiExtreme:y=null,corner:c=null,directionChange:x}=a,f=e[t+1]||null;h||c||f&&f.type!==r?(n.push(a),l.push(n),n=[]):n.push(a)}console.log("!!!chunks",l),function(e){console.log("chunks",e);let a="green";for(let l=0;l<e.length;l++){let n=e[l],r=n.length;a=l%2==0?"orange":"green";let s=n[0],i=n[r-1],o=[{type:"M",values:[s.p0.x,s.p0.y]}];for(let e=0,t=r;e<t;e++){let a=n[e];n[e+1],n[t-1],"C"===s.type&&i.type;let{type:l,values:r,p0:p,cp1:u=null,cp2:h=null,p:y=null,extreme:c,semiExtreme:x=null,corner:f=null}=a;o.push({type:l,values:r})}let p=de(o);t(markers,p,a,"1%","0.5")}}(l);let s=l.length;for(let e=0;e<s;e++){let t=l[e],a=l[e+1]||null;1===t.length&&a&&a[0].type}l=l.filter(Boolean);let i=[e[0]];for(let e=0;e<l.length;e++){let t=l[e],a=t.length,n=t[0],r=t[a-1],s=.05*se(n.p0,r.p);for(let e=0,l=a;e<l;e++){let o=t[e];t[e+1],t[l-1];let p="C"===n.type&&"C"===r.type,{type:u,values:h,p0:y,cp1:c=null,cp2:x=null,p:f=null,extreme:g,semiExtreme:m=null,corner:d=null}=o,v=null,M=null,b=null,A=null,C=null,w=null,k=[],E=.666,L=null;if(p){let e=Math.abs(n.p0.x-n.cp1.x),t=Math.abs(n.p0.y-n.cp1.y),a=Math.abs(r.p.x-r.cp2.x),l=Math.abs(r.p.y-r.cp2.y),i=e<s&&e<t,o=a<s&&a<l,p=l<s&&a>l;t<s&&e>t&&(n.cp1.y=n.p0.y),p&&(r.cp2.y=r.p.y),i&&(n.cp1.x=n.p0.x),o&&(r.cp2.x=r.p.x)}if(de([{type:"M",values:[o.p0.x,o.p0.y]},{type:u,values:h}]),1===a||"C"!==u)i.push(o);else{let e=t.filter(e=>e.semiExtreme),a=t.filter(e=>e.directionChange);if(e.length||a.length){if(L=e.length?e[0]:a[0],n.p0.x===n.cp1.x&&n.p0.y===n.cp1.y?n.cp1=H([n.p0,n.cp1,n.cp2,n.p],.5):r.p.x===r.cp2.x&&r.p.y===r.cp2.y&&(r.cp2=H([r.p0,r.cp1,r.cp2,r.p],.5)),v=U(L.p,L.cp2,n.p0,n.cp1,!1),M=U(L.p,L.cp2,r.p,r.cp2,!1),v&&M){b=H([n.p0,v],E),A=H([r.p,M],E),C=H([L.p,v],E),w=H([L.p,M],E),k=[{type:"M",values:[n.p0.x,n.p0.y]},{type:"C",values:[b.x,b.y,C.x,C.y,L.p.x,L.p.y]},{type:"C",values:[w.x,w.y,A.x,A.y,r.p.x,r.p.y]}],de(k),i.push({type:"C",values:[b.x,b.y,C.x,C.y,L.p.x,L.p.y],p0:n.p0,cp1:b,cp2:C,p:L.p,dimA:se(n.p0,L.p)},{type:"C",values:[w.x,w.y,A.x,A.y,r.p.x,r.p.y],p0:L.p,cp1:w,cp2:A,p:r.p,extreme:!0,dimA:se(L.p,r.p)});break}}else i.push(o)}}}return i}function kt(e,t=1){for(let a=1,l=e.length;a<l;a++){let l=e[a],{type:n,values:r,p0:s,cp1:i=null,cp2:o=null,p:p=null}=l;if("C"===n){let n=Le(s,i,o,p,t);"Q"===n.type&&(n.extreme=l.extreme,n.corner=l.corner,n.dimA=l.dimA,n.squareDist=l.squareDist,e[a]=n)}}return e}function Et(e,{areaThreshold:t=2.5}={}){for(let a=0,l=e.length;a<l;a++){let l=e[a],n=e[a+1]||null,{type:r,values:s,p0:i,cp1:o=null,cp2:p=null,p:u=null}=l;if("C"===r&&n&&"C"===n.type){let l=Lt(i,o,p,u,t),r=Lt(n.p0,n.cp1,n.cp2,n.p,t);if(l.isArc&&r.isArc){let t=.01*se(i,n.p),s=Math.abs(n.p.x-i.x),o=Math.abs(n.p.y-i.y),p=o<t&&s>t,h=s<t&&o>t,{rx:y,ry:c}=l,x=me([i,u,n.p])<0?0:1;if(h||p){y=Math.min(y,r.rx),c=Math.min(c,r.ry),e[a]=null,e[a+1].type="A",e[a+1].values=[y,c,0,0,x,n.p.x,n.p.y];continue}}}}return e=e.filter(Boolean)}function Lt(e,t,a,l,n=7.5){let r,s={type:"C",values:[t.x,t.y,a.x,a.y,l.x,l.y]},i=0,o=!1,p=G(e,t,!0),u=G(l,a,!0),h=180*Math.abs(p-u)/Math.PI,y=0,c=0;if(Math.abs(h%180-90)<3){r=U(e,W(t,e.x,e.y,-.5*Math.PI),l,W(a,l.x,l.y,.5*Math.PI),!1);let p=U(e,t,l,a,!1);if(p){let r=ne(e,p),u=ne(l,p),h=+Math.max(r,u).toFixed(8),x=+Math.min(r,u).toFixed(8);y=x,c=h;let f=me([e,t,a,l])<0?0:1,g=Math.abs(l.x-e.x)>Math.abs(l.y-e.y);100/y*Math.abs(y-c)<5&&(y=h,c=y),g&&(y=h,c=x);let m=ge([{type:"M",values:[e.x,e.y]},{type:"C",values:[t.x,t.y,a.x,a.y,l.x,l.y]}]),d={type:"A",values:[y,c,0,0,f,l.x,l.y]};i=Math.PI*(y*c)/4,i-=Math.abs(me([e,l,p])),function(e,t){let a=Math.abs(e-t);return Math.abs(100-100/e*(e+a))}(m,i)<n&&(o=!0,s=d)}}return{com:s,isArc:o,area:i,rx:y,ry:c,centroid:r}}function Pt(e,{angles:t=[],split:a=0,getPathData:l=!0,width:n=0,height:r=0}={}){let s=e.length,i={x:e[0].values[0],y:e[0].values[1]},o=i,p=[],u=[o],h=0;if(a=a||1,n&&r)h=.025*(n+r)/a;else{h=e.map(e=>e.dimA||0).filter(Boolean).sort()[0]}for(let t=1;t<s;t++){let l=e[t],n=e[t+1]||null,{type:r,values:s}=l,p=s.length,y=p?{x:s[p-2],y:s[p-1]}:i;if("C"===r||"Q"===r){let e={x:s[0],y:s[1]},t="C"===r?{x:s[2],y:s[3]}:e,n="C"===r?[o,e,t,y]:[o,e,y],i=l.dimA;a=Math.ceil(i/h);let p=[];for(let e=1;e<a;e++)p.push(1/a*e);p.forEach(e=>{let t=H(n,e);u.push(t)})}"M"===r&&(i=y),y.area=l.cptArea||0,y.isExtreme=l.extreme||!1,y.isCorner=l.corner||!1,y.isDirChange=l.directionChange||!1,u.push(y),l.extreme||l.corner||n&&n.type,o=y}return u=function(e,{quality:t=.9,width:a=0,height:l=0,absolute:n=!1,manhattan:r=!1,exclude:s=[]}={}){"string"==typeof t&&(n=!0,t=parseFloat(t));if(e.length<4||(!n&&t)>=1)return e;let i=t;if(!n){if(i=1-t,!a&&!l){let t=oe(e,12);({width:a,height:l}=ce(t))}i=r?.05*(a+l)*(1-t):(i*((a+l)/2/25))**2}let o,p=e[0],u=[p],h=e.length,y=s.length,c=0;for(let t=1;t<h;t++)o=e[t],c=r?se(p,o):re(p,o),!(c<i)||y&&s.includes(t)?(u.push(o),p=o):p=o;return p.x!==o.x&&p.y!==o.y&&u.push(o),u}(u,{quality:.5,width:n,height:r}),p=function(e,t=!0){let a=[{type:"M",values:[e[0].x,e[0].y]},...e.slice(1).map(e=>({type:"L",values:[e.x,e.y]}))];return t&&a.push({type:"Z",values:[]}),a}(u),l?p:u}function St(e="",{getObject:t=!1,toAbsolute:a=!0,toRelative:l=!0,toShorthands:n=!0,quadraticToCubic:r=!0,arcToCubic:s=!1,cubicToArc:i=!1,simplifyBezier:o=!0,optimizeOrder:p=!0,autoClose:u=!0,removeZeroLength:h=!0,refineClosing:y=!0,removeColinear:c=!0,flatBezierToLinetos:x=!0,revertToQuadratics:f=!0,refineExtremes:g=!0,simplifyCorners:m=!1,keepExtremes:d=!0,keepCorners:v=!0,extrapolateDominant:M=!0,keepInflections:b=!1,addExtremes:A=!1,addSemiExtremes:C=!1,smoothPoly:w=!1,harmonizeCpts:k=!1,toPolygon:E=!1,removeOrphanSubpaths:L=!1,simplifyRound:P=!1,scale:S=1,scaleTo:T=0,crop:I=!1,alignToOrigin:F=!1,decimals:D=3,autoAccuracy:$=!0,minifyD:z=0,tolerance:q=1,reverse:j=!1,cleanupSVGAtts:Q=!0,removePrologue:B=!0,stylesToAttributes:N=!0,fixHref:G=!0,removeNameSpaced:O=!0,attributesToGroup:U=!1,mergePaths:Z=!1,removeHidden:H=!0,removeUnused:V=!0,shapesToPaths:W=!0,tMin:J=0,tMax:X=1,redraw:Y=!1}={}){q=Math.max(.1,q),S=Math.max(.001,S);let _=function(e){let t="string";if(Array.isArray(e))return e[0]?.type&&e[0]?.values?"pathData":"array";if("string"==typeof e){let a=(e=e.trim()).includes("<svg")&&e.includes("</svg"),l=e.startsWith("M")||e.startsWith("m"),n=!isNaN(e.substring(0,1))&&!isNaN(e.substring(e.length-1,e.length));if(a)t="svgMarkup";else if(l)t="pathDataString";else if(n)t="polyString";else{let a=/^(file:|https?:\/\/|\/|\.\/|\.\.\/)/.test(e),l=e.startsWith("data:image");t=a||l?"url":"string"}return t}return t=typeof e,(e.constructor.name||t).toLowerCase()}(e),K="",ee=0,te=0,ae=0,le={},ne="",re="svgMarkup"===_?1:0,se=[];ee=e.length;let ie={x:0,y:0,width:0,height:0},oe={x:0,y:0,width:0,height:0},ue=[],he=[];if(re){if(K=mt(e,{cleanupSVGAtts:Q,returnDom:!0,removeHidden:H,removeUnused:V,removeNameSpaced:O,attributesToGroup:U,stylesToAttributes:N,removePrologue:B,fixHref:G,mergePaths:Z}),W){K.querySelectorAll("polygon, polyline, line, rect, circle, ellipse").forEach(e=>{let t=Ze(e);e.replaceWith(t)})}K.querySelectorAll("path").forEach(e=>{se.push({d:e.getAttribute("d"),el:e})}),ie=function(e=null,t=-1){const a=e=>e&&isNaN(e)?e.match(/[^\d|.]+/g)[0]:"";if(!e)return!1;let l=e.hasAttribute("width"),n=e.hasAttribute("height"),r=e.hasAttribute("viewBox"),s=l?e.getAttribute("width"):0,i=n?e.getAttribute("height"):0,o=!!l&&a(s),p=!!n&&a(s),u=s?s.includes("%")?0:parseFloat(s):300,h=i?i.includes("%")?0:parseFloat(i):150,y=r?e.getAttribute("viewBox").split(/,| /).filter(Boolean).map(Number):[0,0,u,h];return t>-1&&([u,h]=[u,h].map(e=>+e.toFixed(t)),y=y.map(e=>+e.toFixed(t))),{x:y[0],y:y[1],width:y[2],height:y[3],w:u,h:h,hasViewBox:r,hasWidth:l,hasHeight:n,widthUnit:o,heightUnit:p}}(K,D)}else{if("pathDataString"===_)ne=e;else if("polyString"===_)ne="M"+e;else if("pathData"===_){ne=e,ee=ne.map(e=>`${e.type} ${e.values.join(" ")}`).join(" ").length}se.push({d:ne,el:null})}let xe={toRelative:l,toShorthands:n,decimals:D},fe=[];for(let e=0,t=se.length;t&&e<t;e++){let t=se[e],{d:l,el:n}=t,Q=je(l,{quadraticToCubic:r,toAbsolute:a,arcToCubic:s}),B=w||E?ce(R(Q)):null;if(1!==S||T){if(T)if(ie.width&&!I)S=T/ie.width;else{let e=Q.map(e=>({type:e.type,values:e.values}));e=Pe(e,{arcToCubic:!0}),e=ye(e);let t=ce(R(e));ue.push(t.x,t.x+t.width),he.push(t.y,t.y+t.height);let a=T/t.width;S=a}Q=Ct(Q,S)}let N=Q.length;L&&(Q=Re(Q));let G=pe(Q),O=G.length,U=[];for(let e=0;e<O;e++){let t=G[e];if(E){o=!1,w=!1,k=!1,t=He(t);let e=Ee(t),{bb:a,pathData:l}=e;t=l,t=Pt(t,{angles:[],split:1,width:B.width,height:B.height,getPathData:!0})}if(w){let e=Array.from(new Set(t.map(e=>e.type))).join(""),a=!/[acqts]/gi.test(e),l=/[z]/gi.test(e);if(a){t=Ve(t),t=ut(R(t),{denoise:.8,tolerance:q,width:B.width,height:B.height,manhattan:!1,absolute:!1,keepCorners:v,keepExtremes:d,keepInflections:b,closed:l})}}k&&(t=Ye(t)),(c||h)&&(t=Ve(t)),Y&&(A=!0,C=!0,m=!1,v=!0,d=!0,p=!0,J=0,X=0),p&&(t=We(t)),c&&(t=He(t,{tolerance:q,flatBezierToLinetos:!1})),(A||C)&&(t=ye(t,{tMin:J,tMax:X,addExtremes:A,addSemiExtremes:C,angles:[30]}));let a=Ee(t,{detectSemiExtremes:C}),{pathData:l,bb:n,dimA:r}=a;if(ue.push(n.x,n.x+n.width),he.push(n.y,n.y+n.height),y&&(l=At(l,{threshold:.001*r})),l=o?Me(l,{simplifyBezier:o,keepInflections:b,keepExtremes:d,keepCorners:v,extrapolateDominant:M,revertToQuadratics:f,tolerance:q,reverse:j}):l,g){l=ht(l,{threshold:.05*(n.width+n.height),tolerance:q})}if(Y&&(n.width,n.height,l=wt(l,{tolerance:q,threshold:.001*r})),i&&(l=Et(l,{areaThreshold:2.5})),c&&x&&(l=He(l,{tolerance:q,flatBezierToLinetos:x})),m){l=vt(l,{threshold:.1*(n.width+n.height),tolerance:q})}P&&(l=bt(l)),f&&(l=kt(l,q)),p&&(l=Je(l,{autoClose:u})),U.push({pathData:l,bb:n})}let H=Math.min(...ue),V=Math.min(...he);oe={x:H,y:V,width:Math.max(...ue)-H,height:Math.max(...he)-V};let W=oe.height>oe.width;if(p&&(U=W?U.sort((e,t)=>e.bb.y-t.bb.y||e.bb.x-t.bb.x):U.sort((e,t)=>e.bb.x-t.bb.x||e.bb.y-t.bb.y)),Q=[],U.forEach(e=>{Q.push(...e.pathData)}),$&&(D=Ce(Q),xe.decimals=D),Z=!1,n&&Z)fe.push(...Q);else{Q=Pe(Q,xe),Q=Ve(Q),F&&(console.log(oe),Q[0].values[0]=(Q[0].values[0]-oe.x).toFixed(D),Q[0].values[1]=(Q[0].values[1]-oe.y).toFixed(D),oe.x=0,oe.y=0);let e=Q.length,a=de(Q,z);te=a.length,ae=+(100/ee*te).toFixed(2),t.d=a,t.report={original:N,new:e,saved:N-e,compression:ae,decimals:D},n&&n.setAttribute("d",a)}}if(re){if(fe.length){let e=Pe(fe,xe);e=Ve(e);let t=de(e,z);se[0].el.setAttribute("d",t);for(let e=1;e<se.length;e++){let t=se[e].el;t&&t.remove()}!function(e){e.querySelectorAll("g, defs").forEach(e=>{e.children.length||e.remove()})}(K)}if(S){let{x:e,y:t,width:a,height:l,w:n,h:r,hasViewBox:s,hasWidth:i,hasHeight:o,widthUnit:p,heightUnit:u}=ie;I&&(e=oe.x,t=oe.y,a=oe.width,l=oe.height,n=a,r=l),s&&K.setAttribute("viewBox",[e,t,a,l].map(e=>+(e*S).toFixed(D)).join(" ")),i&&K.setAttribute("width",+(n*S).toFixed(D)+p),o&&K.setAttribute("height",+(r*S).toFixed(D)+u)}K=dt(K),te=K.length,ae=+(100/ee*te).toFixed(2),ee=+(ee/1024).toFixed(3),te=+(te/1024).toFixed(3),le={svgSize:ee,svgSizeOpt:te,compression:ae,decimals:D}}else({d:ne,report:le}=se[0]);return t?{svg:K,d:ne,report:le,inputType:_,mode:re}:ne||K}"undefined"!=typeof window&&(window.svgPathSimplify=St);export{b as PI,a as abs,l as acos,n as asin,r as atan,s as atan2,i as ceil,o as cos,p as exp,u as floor,y as hypot,h as log,c as max,x as min,f as pow,g as random,m as round,d as sin,v as sqrt,St as svgPathSimplify,M as tan};
|
|
@@ -7691,14 +7691,14 @@
|
|
|
7691
7691
|
}
|
|
7692
7692
|
}
|
|
7693
7693
|
|
|
7694
|
-
function pathDataRevertCubicToQuadratic(pathData) {
|
|
7694
|
+
function pathDataRevertCubicToQuadratic(pathData, tolerance=1) {
|
|
7695
7695
|
|
|
7696
7696
|
for (let c = 1, l = pathData.length; c < l; c++) {
|
|
7697
7697
|
let com = pathData[c];
|
|
7698
7698
|
let { type, values, p0, cp1 = null, cp2 = null, p = null } = com;
|
|
7699
7699
|
if (type === 'C') {
|
|
7700
7700
|
|
|
7701
|
-
let comQ = revertCubicQuadratic(p0, cp1, cp2, p);
|
|
7701
|
+
let comQ = revertCubicQuadratic(p0, cp1, cp2, p, tolerance);
|
|
7702
7702
|
if (comQ.type === 'Q') {
|
|
7703
7703
|
comQ.extreme = com.extreme;
|
|
7704
7704
|
comQ.corner = com.corner;
|
|
@@ -8682,12 +8682,12 @@
|
|
|
8682
8682
|
let threshold = (bb.width + bb.height) * 0.1;
|
|
8683
8683
|
pathData = refineRoundedCorners(pathData, { threshold, tolerance });
|
|
8684
8684
|
}
|
|
8685
|
-
|
|
8685
|
+
|
|
8686
8686
|
// refine round segment sequences
|
|
8687
8687
|
if (simplifyRound) pathData = refineRoundSegments(pathData);
|
|
8688
8688
|
|
|
8689
8689
|
// simplify to quadratics
|
|
8690
|
-
if (revertToQuadratics) pathData = pathDataRevertCubicToQuadratic(pathData);
|
|
8690
|
+
if (revertToQuadratics) pathData = pathDataRevertCubicToQuadratic(pathData, tolerance);
|
|
8691
8691
|
|
|
8692
8692
|
// optimize close path
|
|
8693
8693
|
if (optimizeOrder) pathData = optimizeClosePath(pathData, { autoClose });
|
|
@@ -8,4 +8,4 @@ o=i[0]}s.push(o),n<i&&(n+=p)}else s.push(o)}else s.push(o)}return s}function Ae(
|
|
|
8
8
|
//!isFlat &&
|
|
9
9
|
if(C){let e="C"===n?Math.abs(l.cp2.x-l.p.x):Math.abs(l.cp1.x-l.p.x),t="C"===n?Math.abs(l.cp2.y-l.p.y):Math.abs(l.cp1.y-l.p.y);if((0===t&&e>0||0===e&&t>0)&&(k=!0),p.x!==h&&p.y!==c&&p.x!==y&&p.y!==x||(k=!0),!k){if(_(null,b)){let e=te(b);e.length&&e[0]>.15&&(k=!0)}}}if(k&&(l.extreme=!0),C&&w){if(r&&!l.extreme){let e=Math.abs(p.x-f.x),t=Math.abs(p.y-f.y),a=!1;if(e&&t&&e>A||t>A){let e=O(f,p),t=O(p,M.cp1);a=ne(Math.abs(e+t)/2)}a&&(l.semiExtreme=!0)}if((l.cptArea<0&&M.cptArea>0||l.cptArea>0&&M.cptArea<0)&&(l.directionChange=!0),!l.extreme){let e=f||u,t=M.cp1,a=de([e,p,t],!1),n=.01*se(e,t),r=Math.abs(a)<n,s=a<0&&l.cptArea>0||a>0&&l.cptArea<0;!r&&s&&(l.corner=!0)}}s&&(l.directionChange&&t(markers,l.p,"orange","1.5%","0.5"),l.corner&&t(markers,l.p,"magenta","1.5%","0.5"),l.extreme&&t(markers,l.p,"cyan","1%","0.5")),m.push(l)}return p={pathData:m,bb:u,dimA:(f+g)/2},p}function Pe(e={},t={},a={},l={},n=1){let r=H(e,t,1.5),s=H(l,a,1.5),i=.01*ie(e,l)*n,o=ie(r,s),p=null,u={type:"C",values:[t.x,t.y,a.x,a.y,l.x,l.y]};return o<i&&(p=Z(e,t,l,a,!1),p&&(u.type="Q",u.values=[p.x,p.y,l.x,l.y],u.p0=e,u.cp1=p,u.cp2=null,u.p=l)),u}function Se(e,{toShorthands:t=!0,toLonghands:a=!1,toRelative:l=!0,toAbsolute:n=!1,decimals:r=3,arcToCubic:s=!1,quadraticToCubic:i=!1,hasRelatives:o=!0,hasShorthands:p=!0,hasQuadratics:u=!0,hasArcs:h=!0,testTypes:y=!1}={}){if(y){let t=Array.from(new Set(e.map(e=>e.type))).join("");/[lcqamts]/gi.test(t),u=/[qt]/gi.test(t),h=/[a]/gi.test(t),p=/[vhst]/gi.test(t),isPoly=/[mlz]/gi.test(t)}return l=!n&&l,t=!a&&t,u&&i&&(e=Ie(e)),h&&s&&(e=Te(e)),t&&(e=function(e,t=-1,a=!1){let l;if(a){let t=e.map(e=>e.type).join("");l=/[astvqmhlc]/g.test(t)}e=a&&l?De(e):e;let n=e.length,r=new Array(n),s=e[0];r[0]=s;let i={x:e[0].values[0],y:e[0].values[1]},o=i;for(let t=1;t<n;t++){let a=e[t];s=a;let{type:l,values:n}=a,p=n.length,u=[n[p-2],n[p-1]],h=e[t-1];o={x:u[0],y:u[1]};let y=Math.abs(o.x-i.x),c=Math.abs(o.y-i.y),x=.01*ie(i,o),f=!1,g=!1,m=!1;if("C"===l&&"C"===h.type||"Q"===l&&"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]},a=i.x-e.x,l=i.y-e.y;x=.05*ie(e,t),f=ie({x:e.x+2*a,y:e.y+2*l},t)<x}else"L"===l&&(g=0===c||c<x,m=0===y||y<x,f=m||g);switch(l){case"L":g&&(s={type:"H",values:[n[0]]}),m&&(s={type:"V",values:[n[1]]});break;case"Q":f&&(s={type:"T",values:[o.x,o.y]});break;case"C":f&&(s={type:"S",values:[n[2],n[3],o.x,o.y]});break;default:s={type:l,values:n}}i=o,r[t]=s}return r}(e)),p&&a&&(e=ze(e)),n&&(e=$e(e)),r>-1&&l&&(e=Ee(e,r)),l&&(e=function(e,t=-1){return De(e,!0,t)}(e)),r>-1&&(e=Ee(e,r)),e}function Te(e,{arcAccuracy:t=1}={}){let a=[e[0]];for(let l=1,n=e.length;l<n;l++){let n=e[l],r=e[l-1].values,s=r.length,i={x:r[s-2],y:r[s-1]};if("A"===n.type){je(i,n.values,t).forEach(e=>{a.push(e)})}else a.push(n)}return a}function Ie(e){let t=[e[0]];for(let a=1,l=e.length;a<l;a++){let l=e[a],n=e[a-1].values,r=n.length,s={x:n[r-2],y:n[r-1]};"Q"===l.type?t.push(Fe(s,l.values)):t.push(l)}return t}function Fe(e,t){Array.isArray(e)&&(e={x:e[0],y:e[1]});let a={x:e.x+2/3*(t[0]-e.x),y:e.y+2/3*(t[1]-e.y)},l={x:t[2]+2/3*(t[0]-t[2]),y:t[3]+2/3*(t[1]-t[3])};return{type:"C",values:[a.x,a.y,l.x,l.y,t[2],t[3]]}}function De(e,t=!1,a=-1){a>=0&&(e[0].values=e[0].values.map(e=>+e.toFixed(a)));let l=e.length,n=e[0].values,r=n[0],s=n[1],i=r,o=s;for(let n=1;n<l;n++){let l=e[n],{type:p,values:u}=l,h=u.length,y=p.toLowerCase(),c=p.toUpperCase(),x=t?y:c;if(p!==x)switch(l.type=x,y){case"a":u[5]=t?u[5]-r:u[5]+r,u[6]=t?u[6]-s:u[6]+s;break;case"v":u[0]=t?u[0]-s:u[0]+s;break;case"h":u[0]=t?u[0]-r:u[0]+r;break;case"m":t?(u[0]-=r,u[1]-=s):(u[0]+=r,u[1]+=s),i=t?u[0]+r:u[0],o=t?u[1]+s:u[1];break;default:if(u.length)for(let e=0;e<u.length;e++)u[e]=t?u[e]-(e%2?s:r):u[e]+(e%2?s:r)}switch(y){case"z":r=i,s=o;break;case"h":r=t?r+u[0]:u[0];break;case"v":s=t?s+u[0]:u[0];break;case"m":i=u[h-2]+(t?r:0),o=u[h-1]+(t?s:0);default:r=u[h-2]+(t?r:0),s=u[h-1]+(t?s:0)}a>=0&&(l.values=l.values.map(e=>+e.toFixed(a)))}return e}function $e(e,t=-1){return De(e,!1,t)}function ze(e,t=-1,a=!0){let l=!1;if(a){let t=e.map(e=>e.type).join(""),a=/[hstv]/gi.test(t);if(l=/[astvqmhlc]/g.test(t),!a)return e}let n=[],r={type:"M",values:(e=a&&l?$e(e,t):e)[0].values};n.push(r);for(let a=1,l=e.length;a<l;a++){let l,s,i,o,p,u,h,y,c=e[a],{type:x,values:f}=c,g=f.length,m=r.values,d=m.length,[v,M]=[f[g-2],f[g-1]],[b,A]=[m[d-2],m[d-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":[l,s]=[m[0],m[1]],[b,A]=[m[d-2],m[d-1]],i=b+(b-l),o=A+(A-s),r={type:"Q",values:[i,o,v,M]};break;case"S":[l,s]=[m[0],m[1]],[b,A]=[m[d-2],m[d-1]],[h,y]=d>2&&"A"!==r.type?[m[2],m[3]]:[b,A],i=2*b-h,o=2*A-y,p=f[0],u=f[1],r={type:"C",values:[i,o,p,u,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}function qe({p0:e={x:0,y:0},p:t={x:0,y:0},centroid:a={x:0,y:0},rx:l=0,ry:n=0,xAxisRotation:r=0,radToDegree:s=!1,startAngle:i=null,endAngle:o=null,deltaAngle:p=null}={}){if(!l||!n)return[];let u=[];const h=1.5707963267948966;let y=s?r:r*Math.PI/180,c=Math.cos(y),x=Math.sin(y);null!==i&&null!==o&&null!==p||({startAngle:i,endAngle:o,deltaAngle:p}=U(a,e,t));let f=l!==n?Y(i,l,n):i,g=l!==n?Y(p,l,n):p,m=Math.max(1,Math.ceil(Math.abs(g)/h)),d=g/m;for(let e=0;e<m;e++){const e=Math.abs(d)===h?.551785*Math.sign(d):4/3*Math.tan(d/4);let t=Math.cos(f),r=Math.sin(f),s=Math.cos(f+d),i=Math.sin(f+d),o=[];[{x:t-r*e,y:r+t*e},{x:s+i*e,y:i-s*e},{x:s,y:i}].forEach(e=>{let t=e.x*l,r=e.y*n;o.push(c*t-x*r+a.x,x*t+c*r+a.y)}),u.push({type:"C",values:o,cp1:{x:o[0],y:o[1]},cp2:{x:o[2],y:o[3]},p:{x:o[4],y:o[5]}}),f+=d}return u}function je(e,t,a=1){const l=2*Math.PI;let[n,r,s,i,o,p,u]=t;if(0===n||0===r)return[];let h=s?s*l/360:0,y=h?Math.sin(h):0,c=h?Math.cos(h):1,x=c*(e.x-p)/2+y*(e.y-u)/2,f=-y*(e.x-p)/2+c*(e.y-u)/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 m=n*n,d=n===r?m:r*r,v=x*x,M=f*f,b=m*d-m*M-d*v;b<=0?b=0:(b/=m*M+d*v,b=Math.sqrt(b)*(i===o?-1:1));let A=b?b*n/r*f:0,C=b?b*-r/n*x:0,w=c*A-y*C+(e.x+p)/2,k=y*A+c*C+(e.y+u)/2,E=(x-A)/n,L=(f-C)/r,P=(-x-A)/n,S=(-f-C)/r;const T=(e,t,a,l)=>{let n=+(e*a+t*l).toFixed(9);return 1===n||-1===n?1===n?0:Math.PI:(n=n>1?1:n<-1?-1:n,(e*l-t*a<0?-1:1)*Math.acos(n))};let I=T(1,0,E,L),F=T(E,L,P,S);0===o&&F>0?F-=2*Math.PI:1===o&&F<0&&(F+=2*Math.PI);let D=(+(Math.abs(F)/(l/4)).toFixed(0)||1)*a;F/=D;let $=[];const z=1.5707963267948966,q=.551785;let j=F===z?q:F===-z?-q:4/3*Math.tan(F/4),Q=F?Math.cos(F):1,B=F?Math.sin(F):0;const N=(e,t,a,l,n)=>{let r=e!=t?Math.cos(e):l,s=e!=t?Math.sin(e):n,i=Math.cos(e+t),o=Math.sin(e+t);return[{x:r-s*a,y:s+r*a},{x:i+o*a,y:o-i*a},{x:i,y:o}]};for(let e=0;e<D;e++){let e={type:"C",values:[]};N(I,F,j,Q,B).forEach(t=>{let a=t.x*n,l=t.y*r;e.values.push(c*a-y*l+w,y*a+c*l+k)}),$.push(e),I+=F}return $}function Qe(e,{toAbsolute:t=!0,toLonghands:a=!0,quadraticToCubic:l=!1,arcToCubic:n=!1,arcAccuracy:r=4}={}){let s=Array.isArray(e),i=s&&"object"==typeof e[0]&&"function"==typeof e[0].constructor,o=s?e:Ze(e),{hasRelatives:p=!0,hasShorthands:u=!0,hasQuadratics:h=!0,hasArcs:y=!0}=o,c=i?o:o.pathData;return c=function(e=[],{toAbsolute:t=!0,toLonghands:a=!0,quadraticToCubic:l=!1,arcToCubic:n=!1,arcAccuracy:r=2,hasRelatives:s=!0,hasShorthands:i=!0,hasQuadratics:o=!0,hasArcs:p=!0,testTypes:u=!1}={}){if(u){let t=Array.from(new Set(e.map(e=>e.type))).join("");s=/[lcqamts]/gi.test(t),o=/[qt]/gi.test(t),p=/[a]/gi.test(t),i=/[vhst]/gi.test(t),isPoly=/[mlz]/gi.test(t)}return(o&&l||p&&n)&&(a=!0,t=!0),s&&t&&(e=De(e,!1)),i&&a&&(e=ze(e,-1,!1)),p&&n&&(e=Te(e,r)),o&&l&&(e=Ie(e)),e}(c,{toAbsolute:t,toLonghands:a,quadraticToCubic:l,arcToCubic:n,arcAccuracy:r,hasRelatives:p,hasShorthands:u,hasQuadratics:h,hasArcs:y}),c}const Be=new Set([77,109,65,97,67,99,76,108,81,113,83,115,84,116,72,104,86,118,90,122]),Ne=new Uint8Array(128);Ne[77]=2,Ne[109]=2,Ne[65]=7,Ne[97]=7,Ne[67]=6,Ne[99]=6,Ne[76]=2,Ne[108]=2,Ne[81]=4,Ne[113]=4,Ne[83]=4,Ne[115]=4,Ne[84]=2,Ne[116]=2,Ne[72]=1,Ne[104]=1,Ne[86]=1,Ne[118]=1,Ne[90]=0,Ne[122]=0;const Ge=new Set([5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279]),Oe=e=>32===e||44===e||10===e||13===e||8232===e||8233===e||9===e||11===e||12===e||160===e||e>=5760&&Ge.has(e),Ue=(e="",t=0)=>{let a=e.length;return 3===t&&2===a?(e=[+e[0],+e[1]],t++):4===t&&a>1?(e=[+e[0],+e.substring(1)],t++):3===t&&a>=3?(e=[+e[0],+e[1],+e.substring(2)],t+=2):e=[+e],{val:e,valueIndex:t}};function Ze(e,t=!0,a=0){e=e.trim(),a&&console.log("!!!limit",a);let l={pathData:[],hasRelatives:!1,hasShorthands:!1,hasArcs:!1,hasQuadratics:!1,isPolygon:!1,log:[]};if(""===e)return l;let n,r=0,s=e.length,i="",o=-1,p="",u=!1,h=0,y=0,c=0,x=!1,f=new Set([]);const g=()=>{x&&("M"===i?i="L":"m"===i&&(i="l"),l.pathData.push({type:i,values:[]}),o++,y=0,x=!1)},m=(e=!1)=>{(e?h>0:""!==p)&&(t&&-1===o&&(n="Pathdata must start with M command",l.log.push(n),i="M",l.pathData.push({type:i,values:[]}),c=2,y=0,o++),"A"===i||"a"===i?(({val:p,valueIndex:y}=Ue(p,y)),l.pathData[o].values.push(...p)):(t&&p[1]&&"."!==p[1]&&"0"===p[0]&&(n=`${o}. command: Leading zeros not valid: ${p}`,l.log.push(n)),l.pathData[o].values.push(+p)),y++,p="",h=0,x=y>=c)},d=()=>{if(o>0){let e=l.pathData[o].values.length;if(e&&e<c||e&&e>c||("z"===i||"Z"===i)&&e>0){n=`${o}. command of type "${i}": ${c-e} values too few - ${c} expected`,l.log[l.log.length-1]!==n&&l.log.push(n)}}};let v=!1,M=!1,b=!1,A="";for(;r<s;){A=e.charCodeAt(r);let a=A>47&&A<58;if(a||(v=101===A||69===A,M=45===A||43===A,b=46===A),a||M||b||v){if(u||45!==A&&46!==A)g();else{let e=46===A;m(e),g(),e&&h++}p+=e[r],u=v,r++}else if((A<48||A>5759)&&Oe(A))m(),r++;else{if(A>64){if(!Be.has(A)){n=`${o}. command "${e[r]}" is not a valid type`,l.log.push(n),r++;continue}""!==p&&(l.pathData[o].values.push(+p),y++,p=""),t&&d(),i=e[r],c=Ne[A];let a="M"===i||"m"===i,s=o>0&&("z"===l.pathData[o].type||"Z"===l.pathData[o].type);f.add(i),s&&!a&&(l.pathData.push({type:"m",values:[0,0]}),o++),l.pathData.push({type:i,values:[]}),o++,h=0,y=0,x=!1,r++;continue}a||(n=`${o}. ${e[r]} is not a valid separarator or token`,l.log.push(n),p=""),r++}}m(),t&&d(),t&&l.log.length&&(n="Invalid path data:\n"+l.log.join("\n"),"log"===t?console.log(n):console.warn(n)),l.pathData[0].type="M";let C=Array.from(f).join("");return l.hasRelatives=/[lcqamtsvh]/g.test(C),l.hasShorthands=/[vhst]/gi.test(C),l.hasArcs=/[a]/gi.test(C),l.hasQuadratics=/[qt]/gi.test(C),l.isPolygon=!/[cqats]/gi.test(C),l}function He(e){if("path"===e.nodeName.toLowerCase())return e;let t=function(e,t=!1){let a,l,n,r,s,i,o,p,u,h,y,c,x,f,g,m,d=[],v=e.nodeName;const M=(e,t=9)=>{const a="svg"!==e.nodeName?e.closest("svg"):e,l=e=>{if(null===e)return 0;let a=96,l=e.match(/([a-z]+)/gi);l=l?l[0]:"";let n,r=parseFloat(e);if(!l)return r;switch(l){case"in":n=a;break;case"pt":n=1/72*96;break;case"cm":n=1/2.54*96;break;case"mm":n=1/2.54*96/10;break;case"em":case"rem":n=16;break;default:n=1}return+(r*n).toFixed(t)};let n=a.getAttribute("width");n=n?l(n):300;let r=a.getAttribute("height");r=n?l(r):150;let s=a.getAttribute("viewBox");s=s?s.replace(/,/g," ").split(" ").filter(Boolean).map(e=>+e):[];let i=s.length?s[2]:n,o=s.length?s[3]:r,p=i/100,u=o/100,h=Math.sqrt((Math.pow(p,2)+Math.pow(u,2))/2),y=["x","width","x1","x2","rx","cx","r"],c=["y","height","y1","y2","ry","cy"];e.getAttributeNames().forEach(t=>{let a=e.getAttribute(t),n=a;if(y.includes(t)||c.includes(t)){let r=y.includes(t)?p:u;r="r"===t&&i!=o?h:r;let s=a.match(/([a-z|%]+)/gi);s=s?s[0]:"",n=a.includes("%")?parseFloat(a)*r:l(a),e.setAttribute(t,+n)}})};M(e);const b=t=>(a={},t.forEach(t=>{a[t]=+e.getAttribute(t)}),a);switch(v){case"path":n=e.getAttribute("d"),d=Qe(n);break;case"rect":l=["x","y","width","height","rx","ry"],({x:r,y:s,width:i,height:o,rx:u,ry:h}=b(l)),u||h?(u=u||h,h=h||u,u>i/2&&(u=i/2),h>o/2&&(h=o/2),d=[{type:"M",values:[r+u,s]},{type:"L",values:[r+i-u,s]},{type:"A",values:[u,h,0,0,1,r+i,s+h]},{type:"L",values:[r+i,s+o-h]},{type:"A",values:[u,h,0,0,1,r+i-u,s+o]},{type:"L",values:[r+u,s+o]},{type:"A",values:[u,h,0,0,1,r,s+o-h]},{type:"L",values:[r,s+h]},{type:"A",values:[u,h,0,0,1,r+u,s]},{type:"Z",values:[]}]):d=[{type:"M",values:[r,s]},{type:"L",values:[r+i,s]},{type:"L",values:[r+i,s+o]},{type:"L",values:[r,s+o]},{type:"Z",values:[]}];break;case"circle":case"ellipse":l=["cx","cy","rx","ry","r"],({cx:y,cy:c,r:p,rx:u,ry:h}=b(l));let t="circle"===v;t?(u=p,h=p):(u=u||p,h=h||p);let a=t&&p>=1?1:u,M=t&&p>=1?1:u;d=[{type:"M",values:[y+u,c]},{type:"A",values:[a,M,0,1,1,y-u,c]},{type:"A",values:[a,M,0,1,1,y+u,c]}];break;case"line":l=["x1","y1","x2","y2"],({x1:x,y1:g,x2:f,y2:m}=b(l)),d=[{type:"M",values:[x,g]},{type:"L",values:[f,m]}];break;case"polygon":case"polyline":let A=e.getAttribute("points").replaceAll(","," ").split(" ").filter(Boolean);for(let e=0;e<A.length;e+=2)d.push({type:0===e?"M":"L",values:[+A[e],+A[e+1]]});"polygon"===v&&d.push({type:"Z",values:[]})}return t?function(e){return e.map(e=>`${e.type} ${e.values.join(" ")}`).join(" ")}(d):d}(e),a=t.map(e=>`${e.type} ${e.values} `).join(" "),l=[...e.attributes].map(e=>e.name),n=document.createElementNS("http://www.w3.org/2000/svg","path");n.setAttribute("d",a);let r=["x","y","cx","cy","dx","dy","r","rx","ry","width","height","points"];return l.forEach(t=>{if(!r.includes(t)){let a=e.getAttribute(t);n.setAttribute(t,a)}}),n}function Re(e,{tolerance:t=1,flatBezierToLinetos:a=!0}={}){let l=[e[0]],n={x:e[0].values[0],y:e[0].values[1]},r=n,s=n;e[e.length-1].type.toLowerCase();for(let i=1,o=e.length;i<o;i++){let p=e[i],u=e[i+1]||e[o-1],h="z"===u.type.toLowerCase()?n:{x:u.values[u.values.length-2],y:u.values[u.values.length-1]},{type:y,values:c}=p,x=c.slice(-2);s="Z"!==y?{x:x[0],y:x[1]}:n;let f=h?de([r,s,h],!0):1/0,g=se(r,h),m=f<(g?g/333*t:0),d=!1;if(a||"C"!==y||(m=!1),a&&("C"===y||"Q"===y)){d=Ce([r,..."C"===y?[{x:c[0],y:c[1]},{x:c[2],y:c[3]}]:"Q"===y?[{x:c[0],y:c[1]}]:[],s],{tolerance:t}),d&&i<o-1&&(y="L",p.type="L",p.values=x)}m&&i<o-1&&"A"!==u.type&&("L"===y||a&&d)||(r=s,"M"===y&&(n=s),l.push(p))}return l}function Ve(e){let t=[];for(let a=0,l=e.length;a<l;a++){let l=e[a];if(!l)continue;let{type:n=null,values:r=[]}=l,s=e[a+1]?e[a+1]:null;"M"!==n&&"m"!==n||s&&(!s||"Z"!==s.type&&"z"!==s.type)?t.push(l):s&&a++}return t}function We(e){let t={x:e[0].values[0],y:e[0].values[1]},a=t,l=[e[0]];for(let n=1,r=e.length;n<r;n++){let r=e[n],s=e[n-1],i=e[n+1]||null,{type:o,values:p}=r,u="m"===s.type.toLowerCase()&&!i,h=p.length;if(a={x:p[h-2],y:p[h-1]},u||"L"!==o||a.x!==t.x||a.y!==t.y){if(!u&&("l"===o||"v"===o||"h"===o)){if("l"===o?"00"===p.join(""):0===p[0])continue}l.push(r),t=a}}return l}function Je(e){let t=e.length;if(!("z"===e[t-1].type.toLowerCase()))return e;let a=0,l=[];for(let a=0;a<t;a++){let t=e[a],{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=a,l.push(e)}}return l=l.sort((e,t)=>+e.y.toFixed(8)-+t.y.toFixed(8)||e.x-t.x),a=l[0].index,a?Ye(e,a):e}function Xe(e,{removeFinalLineto:t=!0,autoClose:a=!0}={}){let l=[],n=e.length,r={x:+e[0].values[0].toFixed(8),y:+e[0].values[1].toFixed(8)},s="z"===e[n-1].type.toLowerCase(),i=e.filter(e=>"L"===e.type),o=e[s?n-2:n-1],p=o.type,u=o.values.slice(-2).map(e=>+e.toFixed(8)),h=u[0]===r.x&&u[1]===r.y;!s&&a&&h&&(e.push({type:"Z",values:[]}),s=!0,n++);let y="L"!==e[1].type&&(!h||"L"===o.type);if(y=!1,!s)return e;let c=0;{let t=[];for(let a=0;a<n;a++){let l=e[a],{type:n,values:r}=l;if(r.length){let l=r.slice(-2),s=e[a-1]&&"L"===e[a-1].type,i=e[a+1]&&"L"===e[a+1].type,o=e[a-1]?e[a-1].type.toUpperCase():null,p=e[a+1]?e[a+1].type.toUpperCase():null,u={type:n,x:l[0],y:l[1],dist:0,index:0,prevL:s,nextL:i,prevCom:o,nextCom:p};u.index=a,t.push(u)}}if(i.length){let e=t.filter(e=>"L"!==e.type&&"M"!==e.type&&e.prevCom&&"L"===e.prevCom||"M"===e.prevCom&&"L"===p).sort((e,t)=>e.y-t.y||e.x-t.x)[0];c=e?e.index-1:0}else t=t.sort((e,t)=>+e.y.toFixed(8)-+t.y.toFixed(8)||e.x-t.x),c=t[0].index;e=c?Ye(e,c):e}return r={x:+e[0].values[0].toFixed(8),y:+e[0].values[1].toFixed(8)},n=e.length,o=e[n-2],p=o.type,u=o.values.slice(-2).map(e=>+e.toFixed(8)),h="L"===p&&u[0]===r.x&&u[1]===r.y,t&&h&&e.splice(n-2,1),l.push(...e),l}function Ye(e,t){let a=0,l="z"===e[e.length-1].type.toLowerCase();if(!l||t<1||e.length<3)return e;let n=l?1:0;!function(e){let t=e.length,a="z"===e[t-1].type.toLowerCase(),l=e[0],[n,r]=[l.values[0],l.values[1]].map(e=>+e.toFixed(8)),s=a?e[t-2]:e[t-1],i=s.values.length,[o,p]=[s.values[i-2],s.values[i-1]].map(e=>+e.toFixed(8));!a||n==o&&r==p||(e.pop(),e.push({type:"L",values:[n,r]},{type:"Z",values:[]}))}(e),a=t+1<e.length-1?t+1:e.length-1-n;let r,s,i=e.slice(a),o=e.slice(0,a);return o.shift(),r=o[o.length-1].values||[],s=[r[r.length-2],r[r.length-1]],n&&(i.pop(),o.push({type:"Z",values:[]})),e=[{type:"M",values:s},...i,...o]}function _e(e=[],t=.666){let a=e.length;for(let l=1;l<a;l++){let a=e[l],n=e[l-1],{type:r,values:s}=a;e[l+1]&&e[l+1];let i=!1;if("C"===r){let a={x:s[0],y:s[1]},r={x:s[2],y:s[3]},o=n.values.slice(-2),p={x:o[0],y:o[1]},u={x:s[4],y:s[5]},h=ie(p,u),y=ie(p,a),c=ie(u,r),x=ie(a,r),f=Z(p,a,u,r,!1),g=f?Z(p,a,u,r,!0):null;if(f&&!g){Z(u,H(u,r,3),p,a,!0)&&(i=!0)}y/h<.3&&c/h>.4&&(a=R([p,a],1+t/2),r=R([u,r],t),e[l].values[0]=a.x,e[l].values[1]=a.y,e[l].values[2]=r.x,e[l].values[3]=r.y),(g||f&&x<h/5)&&(i=!0),i&&(a=R([p,f],t),r=R([u,f],t),e[l].values[0]=a.x,e[l].values[1]=a.y,e[l].values[2]=r.x,e[l].values[3]=r.y)}}return e}function Ke(e,t,a=!0,l=!0){if(!Array.isArray(e)||void 0!==e[0].x){if(void 0===e[0].x)throw Error("Not a valid point array");e=(e=>Array.from(e).map(e=>[e.x,e.y]))(e)}if(1===(e=e.filter(function(t,a){return 0===a||!t.every((t,l)=>t===e[a-1][l])})).length)return[];if(2===e.length)return[{type:"L",values:[e[0][0],e[0][1]]},{type:"L",values:[e[1][0],e[1][1]]}];let n,r,s=e.length,i=rt(e[1],e[0]),o=rt(e[s-2],e[s-1]),p=(e=>{let t=[];return e.forEach(e=>{let a=e[1],l=e[2],n=e[3],r={type:"C",values:[a[0],a[1],l[0],l[1],n[0],n[1]]};t.push(r)}),t})(tt(e,i,o,t));if(a){let t=p.length,a=p[0],i=p[t-1],o={x:e[0][0],y:e[0][1]},u={x:e[1][0],y:e[1][1]},h=e[2]?{x:e[2][0],y:e[2][1]}:null;h&&(n={x:a.values[0],y:a.values[1]},n=et(n,o,u,h),a.values[0]=n.x,a.values[1]=n.y);let y={x:e[s-1][0],y:e[s-1][1]},c={x:e[s-2][0],y:e[s-2][1]},x=e[s-3]?{x:e[s-3][0],y:e[s-3][1]}:null;x&&(r={x:i.values[2],y:i.values[3]},r=et(r,y,c,x),i.values[2]=r.x,i.values[3]=r.y),l&&(p=function(e=[],t=.666){let a=e.length;for(let l=0;l<a;l++){let a=e[l],n=e[l-1]||null,{type:r,values:s}=a;e[l+1]&&e[l+1];let i=!1;if("C"===r){let a={x:s[0],y:s[1]},r={x:s[2],y:s[3]},o=n.values.slice(-2),p={x:o[0],y:o[1]},u={x:s[4],y:s[5]},h=ie(p,u);ie(p,a),ie(u,r);let y=ie(a,r),c=Z(p,a,u,r,!1);c&&(c&&Z(p,a,u,r,!0)||y<h/5)&&(i=!0),i&&(a=R([p,c],t),r=R([u,c],t),e[l].values[0]=a.x,e[l].values[1]=a.y,e[l].values[2]=r.x,e[l].values[3]=r.y)}}return e}([{type:"M",values:[e[0][0],e[0][1]]},...p]),p.shift())}return p}function et(e,t,a,l){let n=O(t,a),r=O(t,l)-n;return e=J(e,t.x,t.y,-r)}let tt=(e,t,a,l)=>{let n;if(2===e.length){let l=.333*re(e[0],e[1],!0);return n=[e[0],it(e[0],ot(t,l)),it(e[1],ot(a,l)),e[1]],[n]}let r=function(e){let t=[],a=e.length,l=e[0],n=e[1],r=0,s=0;for(let i=0;i<a;i++)n=e[i],r=s+re(n,l,!0),t.push(r),s=r,l=n;return t=t.map(function(e){return e/s}),t}(e),s=at(e,r,r,t,a);n=s[0];let i=s[1],o=s[2];if(0===i||i<l)return[n];if(i<l*l){let s=r,p=i,u=o;for(let h=0;h<20;h++){s=lt(n,e,s);let h=at(e,r,s,t,a);if(n=h[0],i=h[1],o=h[2],i<l)return[n];if(o===u){let e=i/p;if(e>.9999&&e<1.0001)break}p=i,u=o}}let p=[],u=st(e[o-1],e[o+1]);if(u.every(function(e){return 0===e})){u=st(e[o-1],e[o]);let t=[-u[1],u[0]];u[0]=t[0],u[1]=t[1]}let h=function(e){let t=Math.sqrt(e[0]*e[0]+e[1]*e[1]);return 0===t?[0,0]:[e[0]/t,e[1]/t]}(u),y=ot(h,-1);return p=p.concat(tt(e.slice(0,o+1),t,h,l)),p=p.concat(tt(e.slice(o),y,a,l)),p};const at=(e,t,a,l,n)=>{let r,s,i;r=((e,t,a,l)=>{let n,r,s,i,o=e[0],p=e[e.length-1],u=[o,null,null,p],h=function(e){let t=[];for(;e--;)t.push([0,0]);return t}(t.length),y=t.length;for(let e=0;e<y;e++)s=t[e],i=1-s,n=h[e],n[0]=ot(a,3*s*(i*i)),n[1]=ot(l,3*i*(s*s));let c=[[0,0],[0,0]],x=[0,0],f=e.length;for(let a=0;a<f;a++)s=t[a],n=h[a],c[0][0]+=pt(n[0],n[0]),c[0][1]+=pt(n[0],n[1]),c[1][0]+=pt(n[0],n[1]),c[1][1]+=pt(n[1],n[1]),r=st(e[a],R([o,o,p,p],s)),x[0]+=pt(n[0],r),x[1]+=pt(n[1],r);let g=c[0][0]*c[1][1]-c[1][0]*c[0][1],m=c[0][0]*x[1]-c[1][0]*x[0],d=x[0]*c[1][1]-x[1]*c[0][1],v=0===g?0:d/g,M=0===g?0:m/g,b=re(o,p,!0),A=1e-6*b;return v<A||M<A?(u[1]=it(o,ot(a,.333*b)),u[2]=it(p,ot(l,.333*b))):(u[1]=it(o,ot(a,v)),u[2]=it(p,ot(l,M))),u})(e,a,l,n);let o=function(e,t,a){let l,n,r,s,i,o,p;n=0,r=Math.floor(.5*e.length);let u=function(e,t){let a,l=[0],n=e[0],r=0;for(let s=1;s<=t;s++)a=R(e,s/t),r+=re(a,n,!0),l.push(r),n=a;return l=l.map(function(e){return e/r}),l}(t,10),h=e.length;for(i=0;i<h;i++)o=e[i],p=nt(a[i],u,10),s=st(R(t,p),o),l=s[0]*s[0]+s[1]*s[1],l>n&&(n=l,r=i);return[n,r]}(e,r,t);return s=o[0],i=o[1],[r,s,i]};function lt(e,t,a){return a.map((a,l)=>function(e,t,a){let l=R(e,a),n=l[0]-t[0],r=l[1]-t[1],s=ut(e,a),i=n*s[0]+r*s[1],o=s[0]*s[0]+s[1]*s[1],p=ut(e,a,!0),u=2*(n*p[0]+r*p[1]),h=o+u;if(Math.abs(h)<1e-10)return a;return a-i/h}(e,t[l],a))}function nt(e,t,a){if(e<0)return 0;if(e>1)return 1;let l,n,r,s,i;for(let o=1;o<=a;o++)if(e<=t[o]){s=(o-1)/a,r=o/a,n=t[o-1],l=t[o],i=(e-n)/(l-n)*(r-s)+s;break}return i}function rt(e,t){let a=e[0]-t[0],l=e[1]-t[1],n=Math.sqrt(a*a+l*l);return 0===n?[0,0]:[a/n,l/n]}function st(e,t){return[e[0]-t[0],e[1]-t[1]]}function it(e,t){return[e[0]+t[0],e[1]+t[1]]}function ot(e,t){return[e[0]*t,e[1]*t]}function pt(e,t){return e[0]*t[0]+e[1]*t[1]}function ut(e,t,a=!1){let l,n,r=e[0],s=e[1],i=e[2],o=e[3],p=t,u=1-p,h=u*u,y=p*p;return a?(l=6*u*(i[0]-2*s[0]+r[0])+6*p*(o[0]-2*i[0]+s[0]),n=6*u*(i[1]-2*s[1]+r[1])+6*p*(o[1]-2*i[1]+s[1])):(l=3*h*(s[0]-r[0])+6*u*p*(i[0]-s[0])+3*y*(o[0]-i[0]),n=3*h*(s[1]-r[1])+6*u*p*(i[1]-s[1])+3*y*(o[1]-i[1])),[l,n]}function ht(e,{debug:t=!1,width:a=0,height:l=0,denoise:n=.9,keepCorners:r=!0,keepExtremes:s=!0,keepInflections:i=!1,manhattan:o=!1,absolute:p=!1,closed:u=!0,tolerance:h=1}={}){let y=s||r?function(e,{x:t=0,y:a=0,width:l=0,height:n=0,debug:r=!1}={}){let s=e.length,i=xe(e);l&&n||({x:t,y:a,width:l,height:n}=i);let o=.01*(l+n);for(let t=0;t<s;t++){let a=t>0?e[t-1]:e[s-1],l=e[t],n=de([a,l,t<s-1?e[t+1]:e[s-1]],!1);l.area=n,l.dist=ie(a,l)}for(let t=0;t<s;t++){t>1?e[t-2]:e[s-1];let a=t>0?e[t-1]:e[s-1],l=e[t],n=t<s-1?e[t+1]:e[s-1],r=xe([a,n]);se(a,n);let p=Math.abs(a.area),u=Math.abs(l.area),h=Math.abs(n.area),y=!1,c=!l.area||u<o,{left:x,right:f,top:g,bottom:m}=r,d=l.x<=x||l.x>=f||l.y<=g||l.y>=m,v=l.x===i.left||l.x===i.right||l.y===i.top||l.y===i.bottom;ie(l,a);let M=l.y===a.y&&l.x!==a.x,b=l.x===a.x&&l.y!==a.y;
|
|
10
10
|
//!isCloseExtreme &&
|
|
11
|
-
(M||b)&&(v=!0);let A=a.area<0&&l.area>0||a.area>0&&l.area<0,C=A&&!c;if(y=C,d&&!a.isDirChange&&(v=!0),b&&a.isHorizontal&&(a.isCorner=!0,a.isExtreme=!1,v=!1),C&&(a.isDirChange||a.isExtreme)&&(C=!1,l.isDirChange=!1),a.isExtreme&&u>h&&!C&&l.isHorizontal,v||A||u>p){let e=U(l,n,a),{deltaAngleDeg:t}=e;t=Math.abs(t),y=!(t<3||t>160)}l.isCorner=y,l.isExtreme=v,l.isHorizontal=M,l.isVertical=b,l.isDirChange=C}let p=[],u=[];for(let t=0;t<e.length;t++){let a=e[t],l=e[t+1]||null,n=e[t+2]||null,r=[];if(l&&l.isExtreme&&a.isExtreme&&!a.isCorner){let e=l.dist<2*o&&!l.isCorner,s=n&&n.isExtreme&&n.dist<2*o&&!n.isCorner;if(e&&!s?r.push(a,l):s&&r.push(a,l,n),r.length){let e=r.reduce((e,t)=>e+t.x,0)/r.length,l=r.reduce((e,t)=>e+t.y,0)/r.length;a.x=e,a.y=l,t+=r.length-1}}(a.isExtreme||a.isCorner||a.isDirChange)&&u.push(p.length),p.push(a)}let h=p.length,y=p[0],c=p[h-1],x=ie(y,c)<2*o;return y.isExtreme&&c.isExtreme&&x&&(c.x=y.x,c.y=y.y),p}(e,{debug:!1}):e,c=s||r?function(e,{closed:t=!0,keepCorners:a=!0,keepExtremes:l=!0,keepInflections:n=!1}={}){let r=[],s=[e[0]],i=e.length;for(let t=1;t<i;t++){t>0?e[t-1]:e[i-1];let n=e[t],o=t<i-1?e[t+1]:e[i-1];s.push(n),t>0&&(l&&o.isExtreme||a&&o.isCorner)&&(r.push(s),s=[])}return!r.length&&e.length>1&&(r=[e]),r}(y,{keepCorners:r,keepExtremes:s,keepInflections:i}):[y],x=a&&l?(a+l)/2*.004*h:2.5;x=2;let f=function(e=[],{closed:t=!0,tolerance:a=1}={}){let l=e.length,n=[{type:"M",values:[e[0][0].x,e[0][0].y]}];for(let t=0;t<l;t++){let l=e[t],r=e[t+1]?e[t+1]:null,s=[],i=l.length;l[l.length-1],r&&l.push(r[0]),i<2||2===i&&l[1].isExtreme?(l[l.length-1],s=l.map(e=>({type:"L",values:[e.x,e.y]}))):s=Ke(l,a),n.push(...s)}t&&n.push({type:"Z",values:[]});return function(e){let t=e.length;for(let a=1;a<t;a++){let t=e[a],l=e[a+1]||null,{type:n,values:r}=t;if("C"===n&&l&&"C"===l.type){let n=l.values;r[0],r[1];let s={x:r[2],y:r[3]},i={x:r[4],y:r[5]},o={x:n[0],y:n[1]};n[2],n[3];let p,u,h=Math.abs(s.x-i.x),y=Math.abs(s.y-i.y),c=Math.abs(o.x-i.x),x=Math.abs(o.y-i.y),f=.02*ie(o,s),g=y<f&&h>f,m=x<f&&c>f,d=h<f&&y>f,v=c<f&&x>f;(g||d)&&(p=g?{x:t.values[2],y:i.y}:d?{x:i.x,y:t.values[3]}:{x:t.values[2],y:t.values[3]},t.values[2]=p.x,t.values[3]=p.y),(m||v)&&(u=m?{x:l.values[0],y:i.y}:v?{x:i.x,y:l.values[1]}:{x:l.values[0],y:l.values[1]},e[a+1].values[0]=u.x,e[a+1].values[1]=u.y)}}}(n),n}(c,{closed:u,tolerance:2});return f}function yt(e,{threshold:t=null,tolerance:a=1}={}){if(!t){let a=function(e){let t=1/0,a=-1/0,l=1/0,n=-1/0;const r=e=>{e.x<t&&(t=e.x),e.x>a&&(a=e.x),e.y<l&&(l=e.y),e.y>n&&(n=e.y)};for(let t=0;t<e.length;t++){let a=e[t],{type:l,values:n}=a,s=n.length,i=(e[t-1]?e[t-1]:e[t]).values,o=i.length;if(s){let e={x:i[o-2],y:i[o-1]},t={x:n[s-2],y:n[s-1]};if(r(t),"C"===l||"Q"===l){let a={x:n[0],y:n[1]},s="C"===l?{x:n[2],y:n[3]}:a,i="C"===l?[e,a,s,t]:[e,a,t];K(i).forEach(e=>{let t=R(i,e);r(t)})}else"A"===l&&ee(e,n).forEach(e=>{r(e)})}}return{x:t,y:l,width:a-t,height:n-l}}(e);t=.05*(a.width+a.height)}let l=e.length;for(let n=0;n<l;n++){let l=e[n],{type:r,values:s,extreme:i,corner:o=!1,dimA:p,p0:u,p:h}=l,y=e[n+1]?e[n+1]:null,c=e[n+2]?e[n+2]:null,x=(y?ie(h,y.p):1/0)<t,f=(c?ie(c.p,y.p):1/0)<1*t;if(y&&c&&"C"===r&&"C"===y.type&&i&&c.extreme&&(f||x)){let l=Me(y,c,t,a,!1);if(1===l.length){l=l[0],e[n+1]=null,e[n+2].values=[l.cp1.x,l.cp1.y,l.cp2.x,l.cp2.y,l.p.x,l.p.y],e[n+2].cp1=l.cp1,e[n+2].cp2=l.cp2,e[n+2].p0=l.p0,e[n+2].p=l.p,e[n+2].extreme=l.extreme,n++;continue}}if(y&&"C"===r&&"C"===y.type&&i&&x){let e=de([l.p0,l.p,y.p]),t=de([l.p0,l.cp1,l.cp2,l.p]);if(e<0&&t>0||e>0&&t<0)continue}}l=(e=e.filter(Boolean)).length;let n="z"===e[l-1].type.toLowerCase()?l-2:l-1,r=e[n],s=e[n-1]||null,i={x:e[0].values[0],y:e[0].values[1]},o=r.values.slice(-2),p=+o[0].toFixed(8)===+i.x.toFixed(8)&&+o[1].toFixed(8)===+i.y.toFixed(8),u="C"===e[1].type&&e[1].extreme?e[1]:null,h=ie(r.p0,r.p)<t;if(s&&"C"===s.type&&h&&p&&u){let l=Me(s,r,t,a,!1);1===l.length&&(e[n-1]=l[0],e[n]=null,e=e.filter(Boolean))}return e}function ct({transforms:e=[],transformOrigin:t={x:0,y:0}}={}){let a=function(e=[],t={x:0,y:0}){const a=(e,t)=>({a:e.a*t.a+e.c*t.b,b:e.b*t.a+e.d*t.b,c:e.a*t.c+e.c*t.d,d:e.b*t.c+e.d*t.d,e:e.a*t.e+e.c*t.f+e.e,f:e.b*t.e+e.d*t.f+e.f}),l=(e,t)=>({a:1,b:0,c:0,d:1,e:e,f:t}),n=(e,t)=>({a:e,b:0,c:0,d:t,e:0,f:0}),r=(e,t)=>{const a=e=>e*Math.PI/180;let[l,n]=e.map(e=>a(e)),r={};if("rot"===t){let e=Math.cos(l),t=Math.sin(l);r={a:e,b:t,c:-t,d:e,e:0,f:0}}else if("skew"===t){let e=Math.tan(l);r={a:1,b:Math.tan(n),c:e,d:1,e:0,f:0}}return r};let s={a:1,b:0,c:0,d:1,e:0,f:0};0===t.x&&0===t.y||(s=a(s,l(t.x,t.y)));const i={translate:[0,0],scale:[1,1],skew:[0,0],rotate:[0],matrix:[1,0,0,1,0,0]};for(const t of e){const e=Object.keys(t)[0],o=t[e]||i[e];let[p,u=i[e][1]]=o;switch("rotate"===e&&3===o.length&&(p=o[2]),e){case"matrix":let t=["a","b","c","d","e","f"];s=a(s,Object.fromEntries(t.map((e,t)=>[e,o[t]])));break;case"translate":(p||u)&&(s=a(s,l(p,u)));break;case"skew":(p||u)&&(s=a(s,r([p,u],"skew")));break;case"rotate":p&&(s=a(s,r([p],"rot")));break;case"scale":1===p&&1===u||(s=a(s,n(p,u)));break;default:throw new Error(`Unknown transformation type: ${e}`)}}0===t.x&&0===t.y||(s=a(s,l(-t.x,-t.y)));return s}(e,t);return a}const xt=["path","polygon","polyline","line","rect","circle","ellipse"],ft=["textPath","text","tspan"],gt={atts:{id:"*",class:"*",viewBox:["symbol","svg"],preserveAspectRatio:["symbol","svg"],width:["svg","rect","use","image"],height:["svg","rect","use","image"],d:["path"],points:["polygon","polyline"],x:["image","rect","text","textPath","tspan","use","mask"],y:["image","rect","text","textPath","tspan","use","mask"],x1:["line","linearGradient"],x2:["line","linearGradient"],y1:["line","linearGradient"],y2:["line","linearGradient"],r:["circle","radialGradient"],rx:["rect","ellipse"],ry:["rect","ellipse"],cx:["circle","ellipse","radialGradient"],cy:["circle","ellipse","radialGradient"],refX:["symbol","markers"],refY:["symbol","markers"],transform:["svg","g","use",...xt,...ft],"transform-origin":["svg","g","use",...xt,...ft],fill:["svg","g","use",...xt,...ft,"animate","animateMotion"],"fill-opacity":["svg","g","use",...xt,...ft],opacity:["svg","g","use",...xt,...ft],stroke:["svg","g","use",...xt,...ft],"stroke-width":["svg","g","use",...xt,...ft,"mask"],"stroke-opacity":["svg","g","use",...xt,...ft,"mask"],"stroke-miterlimit":["svg","g","use",...xt,...ft,"mask"],"stroke-linejoin":["svg","g","use",...xt,...ft,"mask"],"stroke-linecap":["svg","g","use",...xt,...ft,"mask"],"stroke-dashoffset":["svg","g","use",...xt,...ft,"mask"],"stroke-dasharray":["svg","g","use",...xt,...ft,"mask"],"clip-path":["svg","g","use",...xt,...ft],"clip-rule":["path","polygon"],clipPathUnits:["clipPath"],mask:["svg","g","use",...xt,...ft],maskContentUnits:["mask"],maskUnits:["mask"],"font-family":["svg","g",...ft],"font-size":["svg","g",...ft],"font-style":["svg","g",...ft],"font-weight":["svg","g",...ft],"font-stretch":["svg","g",...ft],"dominant-baseline":[...ft],lengthAdjust:[...ft],"text-anchor":["text"],textLength:["text","textPath","tspan"],dx:["text","tspan"],dy:["text","tspan"],method:["textPath"],spacing:["textPath"],startOffset:["textPath"],rotate:["text","tspan","animateMotion"],side:["textPath"],"white-space":["svg","g",...ft],color:["svg","g",...ft],playbackorder:["svg"],timelinebegin:["svg"],dur:["animate","animateTransform","animateMotion"],end:["animate","animateTransform","animateMotion"],from:["animate","animateTransform","animateMotion"],to:["animate","animateTransform","animateMotion"],type:["animateTransform"],values:["animate","animateTransform","animateMotion"],accumulate:["animate","animateTransform","animateMotion"],additive:["animate","animateTransform","animateMotion"],attributeName:["animate","animateTransform"],begin:["animate","animateTransform","animateMotion"],by:["animate","animateTransform","animateMotion"],calcMode:["animate","animateTransform","animateMotion"],keyPoints:["animateMotion"],keySplines:["animate","animateTransform","animateMotion"],keyTimes:["animate","animateTransform","animateMotion"],max:["animate","animateTransform","animateMotion"],min:["animate","animateTransform","animateMotion"],origin:["animateMotion"],repeatCount:["animate","animateTransform","animateMotion"],repeatDur:["animate","animateTransform","animateMotion"],restart:["animate","animateTransform","animateMotion"],gradientUnits:["linearGradient","radialGradient"],gradientTransform:["linearGradient","radialGradient"],fr:["radialGradient"],fx:["radialGradient"],fy:["radialGradient"],offset:["stop"],"stop-color":["stop"],"stop-opacity":["stop"],spreadMethod:["linearGradient","radialGradient"],href:["pattern","textPath","linearGradient","radialGradient","use","animate","animateTransform","animateMotion","image"],pathLength:[...xt]},defaults:{transform:["none","matrix(1, 0, 0, 1, 0, 0)"],"transform-origin":["0px, 0px","0 0"],rx:["0","0px"],ry:["0","0px"],x:["0","0px"],y:["0","0px"],fill:["black","rgb(0, 0, 0)","rgba(0, 0, 0, 0)","#000","#000000"],color:["black","rgb(0, 0, 0)","rgba(0, 0, 0, 0)","#000","#000000"],stroke:["none"],"stroke-width":["1","1px"],opacity:["1"],"fill-opacity":["1"],"stroke-opacity":["1"],"stroke-linecap":["butt"],"stroke-miterlimit":["4"],"stroke-linejoin":["miter"],"stroke-dasharray":["none"],"stroke-dashoffset":["0","0px","none"],pathLength:["none"],"font-family":["serif"],"font-weight":["normal","400"],"font-stretch":["normal"],"font-width":["normal"],"letter-spacing":["auto","normal","0"],lengthAdjust:["spacing"],"text-anchor":["start"],"dominant-baseline":["auto"],spacing:["auto"],"white-space":["normal"],"stop-opacity":["1"],gradientUnits:["objectBoundingBox"],patternUnits:["objectBoundingBox"],"clip-path":["none"],"clip-rule":["nonzero"],"fill-rule":["nonzero"],clipPathUnits:["userSpaceOnUse"],mask:["none"],maskUnits:["objectBoundingBox"]}};function mt(e,{removeNameSpaced:t=!0,decimals:a=-1}={}){let l=e.nodeName.toLowerCase(),n=function(e){let t={},a=[...e.attributes].map(e=>e.name),l=a.length;if(!l)return t;for(let n=0;n<l;n++){let l=a[n],r=e.getAttribute(l);t[l]=r}return t}(e),r=function(e){let t=e.getAttribute("style"),a=t?function(e=""){let t={};if(!e)return t;let a=e.split(";").filter(Boolean).map(e=>e.trim()),l=a.length;if(!l)return t;for(let e=0;l&&e<l;e++){let l=a[e],[n,r]=l.split(":").filter(Boolean);t[n]=r}return t}(t):{};return a}(e),s={...n,...r},i={},o=r.transform;if(o){let e=ct(function(e,t={x:0,y:0}){let a,l={transforms:[],transformOrigin:t},n=/(\w+)\(([^)]+)\)/g;function r(e){if("string"==typeof e){if(e.includes("rad"))return parseFloat(e)*(180/Math.PI);if(e.includes("turn"))return 360*parseFloat(e)}return parseFloat(e)}for(;null!==(a=n.exec(e));){let e=a[1],t=a[2].split(/,\s*/).map(e=>r(e));switch(e){case"translate":l.transforms.push({translate:[t[0]||0,t[1]||0]});break;case"translateX":l.transforms.push({translate:[t[0]||0,0,0]});break;case"translateY":l.transforms.push({translate:[0,t[0]||0,0]});break;case"scale":l.transforms.push({scale:[t[0]||0,t[1]||0]});break;case"skew":l.transforms.push({skew:[t[0]||0,t[1]||0]});break;case"skewX":l.transforms.push({skew:[t[0]||0,0]});break;case"skewY":l.transforms.push({skew:[0,t[0]||0]});break;case"rotate":l.transforms.push({rotate:[0,0,t[0]||0]});break;case"matrix":l.transforms.push({matrix:t})}}return e.split(/;\s*/).forEach(e=>{let[t,a]=e.split(":").map(e=>e.trim());if("transform-origin"===t||"perspective-origin"===t){let[e,n]=a.split(/\s+/).map(parseFloat);"transform-origin"===t&&(l.transformOrigin={x:e||0,y:n||0})}}),l}(`${o}`));s.transform=`matrix(${Object.values(e).join(",")})`}let p=["inline-size"],u=[];for(let a in s){let n=s[a];n&&a.startsWith("--")||p.includes(a)||!t&&a.startsWith("-")?u.push(`${a}:${n}`):(n&>.atts[a]&&("*"===gt.atts[a]||gt.atts[a].includes(l)||!t&&a.includes(":"))&&(i[a]=n),e.removeAttribute(a))}for(let t in i){let a=i[t];e.setAttribute(t,a)}return u.length&&e.setAttribute("style",u.join(";")),i}function dt(e,{returnDom:t=!1,removeHidden:a=!0,removeUnused:l=!0,stylesToAttributes:n=!0,removePrologue:r=!0,fixHref:s=!0,mergePaths:i=!1,cleanupSVGAtts:o=!0,removeNameSpaced:p=!0,attributesToGroup:u=!0,decimals:h=-1,excludedEls:y=[]}={}){e=e.replace(/<\?xml[\s\S]*?\?>/gi,"").replace(/<!DOCTYPE[\s\S]*?>/gi,"").replace(/<!--[\s\S]*?-->/g,"").trim(),s&&(e=e.replaceAll("xlink:href=","href="));let c=(new DOMParser).parseFromString(e,"text/html").querySelector("svg");if(o){!function(e,t=["viewBox","xmlns","width","height","id","class"]){[...e.attributes].map(e=>e.name).forEach(a=>{t.includes(a)||e.removeAttribute(a)})}(c,["viewBox","xmlns","width","height","id","class","fill","stroke","stroke-width","stroke-linecap","stroke-linejoin"])}let x=["metadata","script",...y],f=c.querySelectorAll("*"),g=[];for(let e=0;e<f.length;e++){let t=f[e],l=t.nodeName.toLowerCase(),r=t.getAttribute("style")||"",s=!!r&&r.trim().includes("display:none"),o=t.getAttribute("display")&&"none"===t.getAttribute("display")||s;if(l.includes(":")||x.includes(l)||a&&o)t.remove();else if(n||u||i){let a=mt(t,{removeNameSpaced:p,decimals:h});"path"===l&&g.push({el:t,name:l,idx:e,propsFiltered:a})}}return(u||i)&&function(e=[],t=!0){let a=[[e[0]]],l=0,n="";for(let t=0;t<e.length;t++){let r=e[t],s=r.propsFiltered,i=[];for(let e in s)"d"!==e&&"id"!==e&&i.push(`${e}:${s[e]}`);i=i.join("_"),r.propstr=i,i===n?a[l].push(r):a[l].length&&(a.push([]),l++),n=i}for(let e=0;e<a.length;e++){let l=a[e];if(l.length>1){let e=l[0].el,a=l[0].propsFiltered,n=e.parentNode.closest("g")?e.parentNode.closest("g"):null;n||(n=document.createElementNS("http://www.w3.org/2000/svg","g"),e.parentNode.insertBefore(n,e),l.forEach(e=>{n.append(e.el)}));let r=[...n.children];for(let e in a){if("d"!==e&&"id"!==e){let t=a[e];n.setAttribute(e,t),r.forEach(a=>{a.getAttribute(e)===t&&a.removeAttribute(e)})}if(t){let e=l[0].el,t=l[0].propsFiltered.d;for(let e=1;e<l.length;e++){let a=l[e],n=a.el,r=a.propsFiltered.d;t+=r.startsWith("M")?r:Ze(r).pathData.map(e=>`${e.type} ${e.values.join(" ")}`).join(" "),n.remove()}e.setAttribute("d",t)}}}}}(g,i),t?c:vt(c)}function vt(e){let t=(new XMLSerializer).serializeToString(e);return t=t.replace(/\t/g,"").replace(/[\n\r|]/g,"\n").replace(/\n\s*\n/g,"\n").replace(/ +/g," "),t}function Mt(e,{threshold:t=0,tolerance:a=1}={}){let l=e.length,n=[e[0]],r="z"===e[l-1].type.toLowerCase(),s=!!r&&(e[l-1].p.x===e[0].p0.x&&e[l-1].p.y===e[0].p0.y),i=r?2:1,o=e[l-i],p="L"===o.type,u="C"===o.type,h="L"===e[1].type,y="C"===e[1].type,c=r&&y&&(p||s);c&&(e[l-1].values=e[0].values,e[l-1].type="L",p=!0);for(let t=1;t<l;t++){let s=e[t],{type:o}=s,x=e[t+1]?e[t+1]:null;if("L"===o&&x&&"C"===x.type||"C"===o&&x&&"L"===x.type){let c="L"===o?s:null,f=null,g=[],m=0;if(1===t&&y&&p&&(g=[e[1]],c=e[l-1],f=x),!c){n.push(s);continue}r&&u&&h&&t===l-i-1&&(f=e[1],g=[e[l-i]]);for(let a=t+1;a<l;a++){let t=e[a]?e[a]:null,l=e[a-1];if("C"===l.type&&g.push(l),"L"===t.type&&"C"===l.type){f=t;break}m++}if(f){let e=ie(c.p0,c.p),l=ie(f.p0,f.p);g.length;let r=ie(c.p,f.p0),i=de([c.p0,c.p,f.p0,f.p],!1),o=de([g[0].p0,g[0].cp1,g[0].cp2,g[0].p],!1),p=i<0&&o>0||i>0&&o<0,u=.5*r*a,h=u<e&&u<l;if(g.length&&!p&&h){let e=Math.abs(o)<=.005*se(g[0].p0,g[0].p),a=e?null:Z(c.p0,c.p,f.p0,f.p,!1);if(!e&&a){let e=.75*ie(R([c.p,a,f.p0],.5),1===g.length?R([g[0].p0,g[0].cp1,g[0].cp2,g[0].p],.5):g[0].p);if(u&&e>u&&e>.3*r){n.push(s);continue}{let e={type:"Q",values:[a.x,a.y,f.p0.x,f.p0.y]};e.p0=c.p,e.cp1=a,e.p=f.p0,n.push(c,e),t+=m;continue}}}}}c&&t===l-1&&"L"===o||n.push(s)}return(c||r&&"Z"!==n[n.length-1].type)&&n.push({type:"Z",values:[]}),n}function bt(e){if(e.length<3)return!1;let t=e[0],a=e[Math.floor(e.length/2)],l=e[e.length-1],n=t.x,r=t.y,s=a.x,i=a.y,o=l.x,p=l.y,u=n-s,h=r-i,y=n-o,c=r-p,x=(n*n-s*s+(r*r-i*i))/2,f=(n*n-o*o+(r*r-p*p))/2,g=u*c-h*y;if(Math.abs(g)<1e-10)return console.warn("Points are collinear or numerically unstable"),!1;let m={x:(c*x-h*f)/g,y:(-y*x+u*f)/g},d=re(m,t),v=U(m,t,l),{deltaAngle:M,startAngle:b,endAngle:A}=v;return{centroid:m,r:d,startAngle:b,endAngle:A,deltaAngle:M}}function At(e,{threshold:t=0,tolerance:l=1,toCubic:n=!1,debug:r=!1}={}){let s=e.length,i=[e[0]],o=[];for(let t=1;t<s;t++){let l=e[t],{type:s}=l,p=e[t-1],u=e[t+1]?e[t+1]:null,h=e[t+2]?e[t+2]:null,y=e[t+3]?e[t+3]:null,c=null;"C"===l.type||"Q"===l.type?c=l:!u||"C"!==u.type&&"Q"!==u.type||(c=u);let x,f,g,m,d,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,w=[];if("L"===p.type&&"L"===s&&c&&"L"===h.type&&y&&("L"===y.type||"Z"===y.type)?(x=[l.p0,l.p],f=[h.p0,h.p],g=l.p0,m=h.p,M=de(v,!1),b=de([...x,...f],!1),A=M<0&&b>0||M>0&&b<0,A||(d=R(v,.5),w=[g,d,m],C=!0)):"C"!==s&&"Q"!==s||"L"!==p.type||"C"!==u.type&&"Q"!==u.type||"L"!==h.type||(C=!0,x=[p.p0,p.p],f=[h.p0,h.p],g=p.p,m=h.p0,d=c.p,w=[g,c.p,m]),C){let e=bt(w);if(e){let s,{centroid:p,r:u,deltaAngle:h,startAngle:y,endAngle:c}=e,x=0,f=h>0?1:0,v=Math.abs(h)>Math.PI?1:0;if(oe(J(g,p.x,p.y,.5*h),d)<.05*oe(g,m)){if(s=qe({p0:g,p:m,centroid:p,rx:u,ry:u,xAxisRotation:x,sweep:f,largeArc:v,deltaAngle:h,startAngle:y,endAngle:c}),1===s.length){let e=Pe(g,s[0].cp1,s[0].cp2,m);"Q"===e.type&&(n=!0),l=e}if(s.length>1&&(n=!1),n||(l.type="A",l.values=[u,u,x,v,f,m.x,m.y]),l.p0=g,l.p=m,l.extreme=!1,l.corner=!1,r){o=n?[{type:"M",values:[g.x,g.y]},...s]:[{type:"M",values:[g.x,g.y]},{type:"A",values:[u,u,x,v,f,m.x,m.y]}];let e=ve(o);a(markers,e,"orange","0.5%","0.5")}i.push(l),t++;continue}}}i.push(l)}return i}function Ct(e=[],{threshold:t=0}={}){let a=e.length,l="z"===e[a-1].type.toLowerCase(),n=l?a-2:a-1,r=e[n],s=r.values.slice(-2),i={x:e[0].values[0],y:e[0].values[1]},o=oe(i,{x:s[0],y:s[1]});if(o&&o<t){let a=e[n].values.length;e[n].values[a-2]=i.x,e[n].values[a-1]=i.y;let l=e[1];if("C"===l.type&&"C"===r.type){let a=Math.abs(l.values[0]-r.values[2]),s=Math.abs(l.values[1]-r.values[3]),o=Math.abs(e[1].values[0]-l.values[0]),p=Math.abs(e[1].values[1]-l.values[1]),u=Math.abs(e[1].values[0]-r.values[2]),h=Math.abs(e[1].values[1]-r.values[3]),y=p<t&&h<t&&a;a&&a<t&&(o<t&&u<t&&s)&&(e[1].values[0]=i.x,e[n].values[2]=i.x),s&&s<t&&y&&(e[1].values[1]=i.y,e[n].values[3]=i.y)}}return e}function wt(e,t=1){let a=[];for(let l=0,n=e.length;l<n;l++){let n=e[l],{type:r,values:s}=n,i={type:r,values:[]};switch(r.toLowerCase()){case"h":case"v":i.values=[s[0]*t];break;case"a":i.values=[s[0]*t,s[1]*t,s[2],s[3],s[4],s[5]*t,s[6]*t];break;default:s.length&&(i.values=s.map((e,a)=>e*t))}a.push(i)}return a}function kt(e,{tolerance:t=1}={}){let l=[],n=[],r=e.length;for(let t=1;t<r;t++){let a=e[t],{type:r,values:s,p0:i,cp1:o=null,cp2:p=null,p:u,extreme:h=null,semiExtreme:y=null,corner:c=null,directionChange:x}=a,f=e[t+1]||null;h||c||f&&f.type!==r?(n.push(a),l.push(n),n=[]):n.push(a)}console.log("!!!chunks",l),function(e){console.log("chunks",e);let t="green";for(let l=0;l<e.length;l++){let n=e[l],r=n.length;t=l%2==0?"orange":"green";let s=n[0],i=n[r-1],o=[{type:"M",values:[s.p0.x,s.p0.y]}];for(let e=0,t=r;e<t;e++){let a=n[e];n[e+1],n[t-1],"C"===s.type&&i.type;let{type:l,values:r,p0:p,cp1:u=null,cp2:h=null,p:y=null,extreme:c,semiExtreme:x=null,corner:f=null}=a;o.push({type:l,values:r})}let p=ve(o);a(markers,p,t,"1%","0.5")}}(l);let s=l.length;for(let e=0;e<s;e++){let t=l[e],a=l[e+1]||null;1===t.length&&a&&a[0].type}l=l.filter(Boolean);let i=[e[0]];for(let e=0;e<l.length;e++){let t=l[e],a=t.length,n=t[0],r=t[a-1],s=.05*ie(n.p0,r.p);for(let e=0,l=a;e<l;e++){let o=t[e];t[e+1],t[l-1];let p="C"===n.type&&"C"===r.type,{type:u,values:h,p0:y,cp1:c=null,cp2:x=null,p:f=null,extreme:g,semiExtreme:m=null,corner:d=null}=o,v=null,M=null,b=null,A=null,C=null,w=null,k=[],E=.666,L=null;if(p){let e=Math.abs(n.p0.x-n.cp1.x),t=Math.abs(n.p0.y-n.cp1.y),a=Math.abs(r.p.x-r.cp2.x),l=Math.abs(r.p.y-r.cp2.y),i=e<s&&e<t,o=a<s&&a<l,p=l<s&&a>l;t<s&&e>t&&(n.cp1.y=n.p0.y),p&&(r.cp2.y=r.p.y),i&&(n.cp1.x=n.p0.x),o&&(r.cp2.x=r.p.x)}if(ve([{type:"M",values:[o.p0.x,o.p0.y]},{type:u,values:h}]),1===a||"C"!==u)i.push(o);else{let e=t.filter(e=>e.semiExtreme),a=t.filter(e=>e.directionChange);if(e.length||a.length){if(L=e.length?e[0]:a[0],n.p0.x===n.cp1.x&&n.p0.y===n.cp1.y?n.cp1=R([n.p0,n.cp1,n.cp2,n.p],.5):r.p.x===r.cp2.x&&r.p.y===r.cp2.y&&(r.cp2=R([r.p0,r.cp1,r.cp2,r.p],.5)),v=Z(L.p,L.cp2,n.p0,n.cp1,!1),M=Z(L.p,L.cp2,r.p,r.cp2,!1),v&&M){b=R([n.p0,v],E),A=R([r.p,M],E),C=R([L.p,v],E),w=R([L.p,M],E),k=[{type:"M",values:[n.p0.x,n.p0.y]},{type:"C",values:[b.x,b.y,C.x,C.y,L.p.x,L.p.y]},{type:"C",values:[w.x,w.y,A.x,A.y,r.p.x,r.p.y]}],ve(k),i.push({type:"C",values:[b.x,b.y,C.x,C.y,L.p.x,L.p.y],p0:n.p0,cp1:b,cp2:C,p:L.p,dimA:ie(n.p0,L.p)},{type:"C",values:[w.x,w.y,A.x,A.y,r.p.x,r.p.y],p0:L.p,cp1:w,cp2:A,p:r.p,extreme:!0,dimA:ie(L.p,r.p)});break}}else i.push(o)}}}return i}function Et(e){for(let t=1,a=e.length;t<a;t++){let a=e[t],{type:l,values:n,p0:r,cp1:s=null,cp2:i=null,p:o=null}=a;if("C"===l){let l=Pe(r,s,i,o);"Q"===l.type&&(l.extreme=a.extreme,l.corner=a.corner,l.dimA=a.dimA,l.squareDist=a.squareDist,e[t]=l)}}return e}function Lt(e,{areaThreshold:t=2.5}={}){for(let a=0,l=e.length;a<l;a++){let l=e[a],n=e[a+1]||null,{type:r,values:s,p0:i,cp1:o=null,cp2:p=null,p:u=null}=l;if("C"===r&&n&&"C"===n.type){let l=Pt(i,o,p,u,t),r=Pt(n.p0,n.cp1,n.cp2,n.p,t);if(l.isArc&&r.isArc){let t=.01*ie(i,n.p),s=Math.abs(n.p.x-i.x),o=Math.abs(n.p.y-i.y),p=o<t&&s>t,h=s<t&&o>t,{rx:y,ry:c}=l,x=de([i,u,n.p])<0?0:1;if(h||p){y=Math.min(y,r.rx),c=Math.min(c,r.ry),e[a]=null,e[a+1].type="A",e[a+1].values=[y,c,0,0,x,n.p.x,n.p.y];continue}}}}return e=e.filter(Boolean)}function Pt(e,t,a,l,n=7.5){let r,s={type:"C",values:[t.x,t.y,a.x,a.y,l.x,l.y]},i=0,o=!1,p=O(e,t,!0),u=O(l,a,!0),h=180*Math.abs(p-u)/Math.PI,y=0,c=0;if(Math.abs(h%180-90)<3){r=Z(e,J(t,e.x,e.y,-.5*Math.PI),l,J(a,l.x,l.y,.5*Math.PI),!1);let p=Z(e,t,l,a,!1);if(p){let r=re(e,p),u=re(l,p),h=+Math.max(r,u).toFixed(8),x=+Math.min(r,u).toFixed(8);y=x,c=h;let f=de([e,t,a,l])<0?0:1,g=Math.abs(l.x-e.x)>Math.abs(l.y-e.y);100/y*Math.abs(y-c)<5&&(y=h,c=y),g&&(y=h,c=x);let m=me([{type:"M",values:[e.x,e.y]},{type:"C",values:[t.x,t.y,a.x,a.y,l.x,l.y]}]),d={type:"A",values:[y,c,0,0,f,l.x,l.y]};i=Math.PI*(y*c)/4,i-=Math.abs(de([e,l,p])),function(e,t){let a=Math.abs(e-t);return Math.abs(100-100/e*(e+a))}(m,i)<n&&(o=!0,s=d)}}return{com:s,isArc:o,area:i,rx:y,ry:c,centroid:r}}function St(e,{angles:t=[],split:a=0,getPathData:l=!0,width:n=0,height:r=0}={}){let s=e.length,i={x:e[0].values[0],y:e[0].values[1]},o=i,p=[],u=[o],h=0;if(a=a||1,n&&r)h=.025*(n+r)/a;else{h=e.map(e=>e.dimA||0).filter(Boolean).sort()[0]}for(let t=1;t<s;t++){let l=e[t],n=e[t+1]||null,{type:r,values:s}=l,p=s.length,y=p?{x:s[p-2],y:s[p-1]}:i;if("C"===r||"Q"===r){let e={x:s[0],y:s[1]},t="C"===r?{x:s[2],y:s[3]}:e,n="C"===r?[o,e,t,y]:[o,e,y],i=l.dimA;a=Math.ceil(i/h);let p=[];for(let e=1;e<a;e++)p.push(1/a*e);p.forEach(e=>{let t=R(n,e);u.push(t)})}"M"===r&&(i=y),y.area=l.cptArea||0,y.isExtreme=l.extreme||!1,y.isCorner=l.corner||!1,y.isDirChange=l.directionChange||!1,u.push(y),l.extreme||l.corner||n&&n.type,o=y}return u=function(e,{quality:t=.9,width:a=0,height:l=0,absolute:n=!1,manhattan:r=!1,exclude:s=[]}={}){"string"==typeof t&&(n=!0,t=parseFloat(t));if(e.length<4||(!n&&t)>=1)return e;let i=t;if(!n){if(i=1-t,!a&&!l){let t=pe(e,12);({width:a,height:l}=xe(t))}i=r?.05*(a+l)*(1-t):(i*((a+l)/2/25))**2}let o,p=e[0],u=[p],h=e.length,y=s.length,c=0;for(let t=1;t<h;t++)o=e[t],c=r?ie(p,o):se(p,o),!(c<i)||y&&s.includes(t)?(u.push(o),p=o):p=o;return p.x!==o.x&&p.y!==o.y&&u.push(o),u}(u,{quality:.5,width:n,height:r}),p=function(e,t=!0){let a=[{type:"M",values:[e[0].x,e[0].y]},...e.slice(1).map(e=>({type:"L",values:[e.x,e.y]}))];return t&&a.push({type:"Z",values:[]}),a}(u),l?p:u}function Tt(e="",{getObject:t=!1,toAbsolute:a=!0,toRelative:l=!0,toShorthands:n=!0,quadraticToCubic:r=!0,arcToCubic:s=!1,cubicToArc:i=!1,simplifyBezier:o=!0,optimizeOrder:p=!0,autoClose:u=!0,removeZeroLength:h=!0,refineClosing:y=!0,removeColinear:c=!0,flatBezierToLinetos:x=!0,revertToQuadratics:f=!0,refineExtremes:g=!0,simplifyCorners:m=!1,keepExtremes:d=!0,keepCorners:v=!0,extrapolateDominant:M=!0,keepInflections:b=!1,addExtremes:A=!1,addSemiExtremes:C=!1,smoothPoly:w=!1,harmonizeCpts:k=!1,toPolygon:E=!1,removeOrphanSubpaths:L=!1,simplifyRound:P=!1,scale:S=1,scaleTo:T=0,crop:I=!1,alignToOrigin:F=!1,decimals:D=3,autoAccuracy:$=!0,minifyD:z=0,tolerance:q=1,reverse:j=!1,cleanupSVGAtts:Q=!0,removePrologue:B=!0,stylesToAttributes:N=!0,fixHref:G=!0,removeNameSpaced:O=!0,attributesToGroup:U=!1,mergePaths:Z=!1,removeHidden:H=!0,removeUnused:R=!0,shapesToPaths:W=!0,tMin:J=0,tMax:X=1,redraw:Y=!1}={}){q=Math.max(.1,q),S=Math.max(.001,S);let _=function(e){let t="string";if(Array.isArray(e))return e[0]?.type&&e[0]?.values?"pathData":"array";if("string"==typeof e){let a=(e=e.trim()).includes("<svg")&&e.includes("</svg"),l=e.startsWith("M")||e.startsWith("m"),n=!isNaN(e.substring(0,1))&&!isNaN(e.substring(e.length-1,e.length));if(a)t="svgMarkup";else if(l)t="pathDataString";else if(n)t="polyString";else{let a=/^(file:|https?:\/\/|\/|\.\/|\.\.\/)/.test(e),l=e.startsWith("data:image");t=a||l?"url":"string"}return t}return t=typeof e,(e.constructor.name||t).toLowerCase()}(e),K="",ee=0,te=0,ae=0,le={},ne="",re="svgMarkup"===_?1:0,se=[];ee=e.length;let ie={x:0,y:0,width:0,height:0},oe={x:0,y:0,width:0,height:0},pe=[],he=[];if(re){if(K=dt(e,{cleanupSVGAtts:Q,returnDom:!0,removeHidden:H,removeUnused:R,removeNameSpaced:O,attributesToGroup:U,stylesToAttributes:N,removePrologue:B,fixHref:G,mergePaths:Z}),W){K.querySelectorAll("polygon, polyline, line, rect, circle, ellipse").forEach(e=>{let t=He(e);e.replaceWith(t)})}K.querySelectorAll("path").forEach(e=>{se.push({d:e.getAttribute("d"),el:e})}),ie=function(e=null,t=-1){const a=e=>e&&isNaN(e)?e.match(/[^\d|.]+/g)[0]:"";if(!e)return!1;let l=e.hasAttribute("width"),n=e.hasAttribute("height"),r=e.hasAttribute("viewBox"),s=l?e.getAttribute("width"):0,i=n?e.getAttribute("height"):0,o=!!l&&a(s),p=!!n&&a(s),u=s?s.includes("%")?0:parseFloat(s):300,h=i?i.includes("%")?0:parseFloat(i):150,y=r?e.getAttribute("viewBox").split(/,| /).filter(Boolean).map(Number):[0,0,u,h];return t>-1&&([u,h]=[u,h].map(e=>+e.toFixed(t)),y=y.map(e=>+e.toFixed(t))),{x:y[0],y:y[1],width:y[2],height:y[3],w:u,h:h,hasViewBox:r,hasWidth:l,hasHeight:n,widthUnit:o,heightUnit:p}}(K,D)}else{if("pathDataString"===_)ne=e;else if("polyString"===_)ne="M"+e;else if("pathData"===_){ne=e,ee=ne.map(e=>`${e.type} ${e.values.join(" ")}`).join(" ").length}se.push({d:ne,el:null})}let ye={toRelative:l,toShorthands:n,decimals:D},fe=[];for(let e=0,t=se.length;t&&e<t;e++){let t=se[e],{d:l,el:n}=t,Q=Qe(l,{quadraticToCubic:r,toAbsolute:a,arcToCubic:s}),B=w||E?xe(V(Q)):null;if(1!==S||T){if(T)if(ie.width&&!I)S=T/ie.width;else{let e=Q.map(e=>({type:e.type,values:e.values}));e=Se(e,{arcToCubic:!0}),e=ce(e);let t=xe(V(e));pe.push(t.x,t.x+t.width),he.push(t.y,t.y+t.height);let a=T/t.width;S=a}Q=wt(Q,S)}let N=Q.length;L&&(Q=Ve(Q));let G=ue(Q),O=G.length,U=[];for(let e=0;e<O;e++){let t=G[e];if(E){o=!1,w=!1,k=!1,t=Re(t);let e=Le(t),{bb:a,pathData:l}=e;t=l,t=St(t,{angles:[],split:1,width:B.width,height:B.height,getPathData:!0})}if(w){let e=Array.from(new Set(t.map(e=>e.type))).join(""),a=!/[acqts]/gi.test(e),l=/[z]/gi.test(e);if(a){t=We(t),t=ht(V(t),{denoise:.8,tolerance:q,width:B.width,height:B.height,manhattan:!1,absolute:!1,keepCorners:v,keepExtremes:d,keepInflections:b,closed:l})}}k&&(t=_e(t)),(c||h)&&(t=We(t)),Y&&(A=!0,C=!0,m=!1,v=!0,d=!0,p=!0,J=0,X=0),p&&(t=Je(t)),c&&(t=Re(t,{tolerance:q,flatBezierToLinetos:!1})),(A||C)&&(t=ce(t,{tMin:J,tMax:X,addExtremes:A,addSemiExtremes:C,angles:[30]}));let a=Le(t,{detectSemiExtremes:C}),{pathData:l,bb:n,dimA:r}=a;if(pe.push(n.x,n.x+n.width),he.push(n.y,n.y+n.height),y&&(l=Ct(l,{threshold:.001*r})),l=o?be(l,{simplifyBezier:o,keepInflections:b,keepExtremes:d,keepCorners:v,extrapolateDominant:M,revertToQuadratics:f,tolerance:q,reverse:j}):l,g){l=yt(l,{threshold:.05*(n.width+n.height),tolerance:q})}if(Y&&(n.width,n.height,l=kt(l,{tolerance:q,threshold:.001*r})),i&&(l=Lt(l,{areaThreshold:2.5})),c&&x&&(l=Re(l,{tolerance:q,flatBezierToLinetos:x})),m){l=Mt(l,{threshold:.1*(n.width+n.height),tolerance:q})}P&&(l=At(l)),f&&(l=Et(l)),p&&(l=Xe(l,{autoClose:u})),U.push({pathData:l,bb:n})}let H=Math.min(...pe),R=Math.min(...he);oe={x:H,y:R,width:Math.max(...pe)-H,height:Math.max(...he)-R};let W=oe.height>oe.width;if(p&&(U=W?U.sort((e,t)=>e.bb.y-t.bb.y||e.bb.x-t.bb.x):U.sort((e,t)=>e.bb.x-t.bb.x||e.bb.y-t.bb.y)),Q=[],U.forEach(e=>{Q.push(...e.pathData)}),$&&(D=we(Q),ye.decimals=D),Z=!1,n&&Z)fe.push(...Q);else{Q=Se(Q,ye),Q=We(Q),F&&(console.log(oe),Q[0].values[0]=(Q[0].values[0]-oe.x).toFixed(D),Q[0].values[1]=(Q[0].values[1]-oe.y).toFixed(D),oe.x=0,oe.y=0);let e=Q.length,a=ve(Q,z);te=a.length,ae=+(100/ee*te).toFixed(2),t.d=a,t.report={original:N,new:e,saved:N-e,compression:ae,decimals:D},n&&n.setAttribute("d",a)}}if(re){if(fe.length){let e=Se(fe,ye);e=We(e);let t=ve(e,z);se[0].el.setAttribute("d",t);for(let e=1;e<se.length;e++){let t=se[e].el;t&&t.remove()}!function(e){e.querySelectorAll("g, defs").forEach(e=>{e.children.length||e.remove()})}(K)}if(S){let{x:e,y:t,width:a,height:l,w:n,h:r,hasViewBox:s,hasWidth:i,hasHeight:o,widthUnit:p,heightUnit:u}=ie;I&&(e=oe.x,t=oe.y,a=oe.width,l=oe.height,n=a,r=l),s&&K.setAttribute("viewBox",[e,t,a,l].map(e=>+(e*S).toFixed(D)).join(" ")),i&&K.setAttribute("width",+(n*S).toFixed(D)+p),o&&K.setAttribute("height",+(r*S).toFixed(D)+u)}K=vt(K),te=K.length,ae=+(100/ee*te).toFixed(2),ee=+(ee/1024).toFixed(3),te=+(te/1024).toFixed(3),le={svgSize:ee,svgSizeOpt:te,compression:ae,decimals:D}}else({d:ne,report:le}=se[0]);return t?{svg:K,d:ne,report:le,inputType:_,mode:re}:ne||K}"undefined"!=typeof window&&(window.svgPathSimplify=Tt),e.PI=A,e.abs=l,e.acos=n,e.asin=r,e.atan=s,e.atan2=i,e.ceil=o,e.cos=p,e.exp=u,e.floor=h,e.hypot=c,e.log=y,e.max=x,e.min=f,e.pow=g,e.random=m,e.round=d,e.sin=v,e.sqrt=M,e.svgPathSimplify=Tt,e.tan=b}(this["svg-path-simplify"]=this["svg-path-simplify"]||{});
|
|
11
|
+
(M||b)&&(v=!0);let A=a.area<0&&l.area>0||a.area>0&&l.area<0,C=A&&!c;if(y=C,d&&!a.isDirChange&&(v=!0),b&&a.isHorizontal&&(a.isCorner=!0,a.isExtreme=!1,v=!1),C&&(a.isDirChange||a.isExtreme)&&(C=!1,l.isDirChange=!1),a.isExtreme&&u>h&&!C&&l.isHorizontal,v||A||u>p){let e=U(l,n,a),{deltaAngleDeg:t}=e;t=Math.abs(t),y=!(t<3||t>160)}l.isCorner=y,l.isExtreme=v,l.isHorizontal=M,l.isVertical=b,l.isDirChange=C}let p=[],u=[];for(let t=0;t<e.length;t++){let a=e[t],l=e[t+1]||null,n=e[t+2]||null,r=[];if(l&&l.isExtreme&&a.isExtreme&&!a.isCorner){let e=l.dist<2*o&&!l.isCorner,s=n&&n.isExtreme&&n.dist<2*o&&!n.isCorner;if(e&&!s?r.push(a,l):s&&r.push(a,l,n),r.length){let e=r.reduce((e,t)=>e+t.x,0)/r.length,l=r.reduce((e,t)=>e+t.y,0)/r.length;a.x=e,a.y=l,t+=r.length-1}}(a.isExtreme||a.isCorner||a.isDirChange)&&u.push(p.length),p.push(a)}let h=p.length,y=p[0],c=p[h-1],x=ie(y,c)<2*o;return y.isExtreme&&c.isExtreme&&x&&(c.x=y.x,c.y=y.y),p}(e,{debug:!1}):e,c=s||r?function(e,{closed:t=!0,keepCorners:a=!0,keepExtremes:l=!0,keepInflections:n=!1}={}){let r=[],s=[e[0]],i=e.length;for(let t=1;t<i;t++){t>0?e[t-1]:e[i-1];let n=e[t],o=t<i-1?e[t+1]:e[i-1];s.push(n),t>0&&(l&&o.isExtreme||a&&o.isCorner)&&(r.push(s),s=[])}return!r.length&&e.length>1&&(r=[e]),r}(y,{keepCorners:r,keepExtremes:s,keepInflections:i}):[y],x=a&&l?(a+l)/2*.004*h:2.5;x=2;let f=function(e=[],{closed:t=!0,tolerance:a=1}={}){let l=e.length,n=[{type:"M",values:[e[0][0].x,e[0][0].y]}];for(let t=0;t<l;t++){let l=e[t],r=e[t+1]?e[t+1]:null,s=[],i=l.length;l[l.length-1],r&&l.push(r[0]),i<2||2===i&&l[1].isExtreme?(l[l.length-1],s=l.map(e=>({type:"L",values:[e.x,e.y]}))):s=Ke(l,a),n.push(...s)}t&&n.push({type:"Z",values:[]});return function(e){let t=e.length;for(let a=1;a<t;a++){let t=e[a],l=e[a+1]||null,{type:n,values:r}=t;if("C"===n&&l&&"C"===l.type){let n=l.values;r[0],r[1];let s={x:r[2],y:r[3]},i={x:r[4],y:r[5]},o={x:n[0],y:n[1]};n[2],n[3];let p,u,h=Math.abs(s.x-i.x),y=Math.abs(s.y-i.y),c=Math.abs(o.x-i.x),x=Math.abs(o.y-i.y),f=.02*ie(o,s),g=y<f&&h>f,m=x<f&&c>f,d=h<f&&y>f,v=c<f&&x>f;(g||d)&&(p=g?{x:t.values[2],y:i.y}:d?{x:i.x,y:t.values[3]}:{x:t.values[2],y:t.values[3]},t.values[2]=p.x,t.values[3]=p.y),(m||v)&&(u=m?{x:l.values[0],y:i.y}:v?{x:i.x,y:l.values[1]}:{x:l.values[0],y:l.values[1]},e[a+1].values[0]=u.x,e[a+1].values[1]=u.y)}}}(n),n}(c,{closed:u,tolerance:2});return f}function yt(e,{threshold:t=null,tolerance:a=1}={}){if(!t){let a=function(e){let t=1/0,a=-1/0,l=1/0,n=-1/0;const r=e=>{e.x<t&&(t=e.x),e.x>a&&(a=e.x),e.y<l&&(l=e.y),e.y>n&&(n=e.y)};for(let t=0;t<e.length;t++){let a=e[t],{type:l,values:n}=a,s=n.length,i=(e[t-1]?e[t-1]:e[t]).values,o=i.length;if(s){let e={x:i[o-2],y:i[o-1]},t={x:n[s-2],y:n[s-1]};if(r(t),"C"===l||"Q"===l){let a={x:n[0],y:n[1]},s="C"===l?{x:n[2],y:n[3]}:a,i="C"===l?[e,a,s,t]:[e,a,t];K(i).forEach(e=>{let t=R(i,e);r(t)})}else"A"===l&&ee(e,n).forEach(e=>{r(e)})}}return{x:t,y:l,width:a-t,height:n-l}}(e);t=.05*(a.width+a.height)}let l=e.length;for(let n=0;n<l;n++){let l=e[n],{type:r,values:s,extreme:i,corner:o=!1,dimA:p,p0:u,p:h}=l,y=e[n+1]?e[n+1]:null,c=e[n+2]?e[n+2]:null,x=(y?ie(h,y.p):1/0)<t,f=(c?ie(c.p,y.p):1/0)<1*t;if(y&&c&&"C"===r&&"C"===y.type&&i&&c.extreme&&(f||x)){let l=Me(y,c,t,a,!1);if(1===l.length){l=l[0],e[n+1]=null,e[n+2].values=[l.cp1.x,l.cp1.y,l.cp2.x,l.cp2.y,l.p.x,l.p.y],e[n+2].cp1=l.cp1,e[n+2].cp2=l.cp2,e[n+2].p0=l.p0,e[n+2].p=l.p,e[n+2].extreme=l.extreme,n++;continue}}if(y&&"C"===r&&"C"===y.type&&i&&x){let e=de([l.p0,l.p,y.p]),t=de([l.p0,l.cp1,l.cp2,l.p]);if(e<0&&t>0||e>0&&t<0)continue}}l=(e=e.filter(Boolean)).length;let n="z"===e[l-1].type.toLowerCase()?l-2:l-1,r=e[n],s=e[n-1]||null,i={x:e[0].values[0],y:e[0].values[1]},o=r.values.slice(-2),p=+o[0].toFixed(8)===+i.x.toFixed(8)&&+o[1].toFixed(8)===+i.y.toFixed(8),u="C"===e[1].type&&e[1].extreme?e[1]:null,h=ie(r.p0,r.p)<t;if(s&&"C"===s.type&&h&&p&&u){let l=Me(s,r,t,a,!1);1===l.length&&(e[n-1]=l[0],e[n]=null,e=e.filter(Boolean))}return e}function ct({transforms:e=[],transformOrigin:t={x:0,y:0}}={}){let a=function(e=[],t={x:0,y:0}){const a=(e,t)=>({a:e.a*t.a+e.c*t.b,b:e.b*t.a+e.d*t.b,c:e.a*t.c+e.c*t.d,d:e.b*t.c+e.d*t.d,e:e.a*t.e+e.c*t.f+e.e,f:e.b*t.e+e.d*t.f+e.f}),l=(e,t)=>({a:1,b:0,c:0,d:1,e:e,f:t}),n=(e,t)=>({a:e,b:0,c:0,d:t,e:0,f:0}),r=(e,t)=>{const a=e=>e*Math.PI/180;let[l,n]=e.map(e=>a(e)),r={};if("rot"===t){let e=Math.cos(l),t=Math.sin(l);r={a:e,b:t,c:-t,d:e,e:0,f:0}}else if("skew"===t){let e=Math.tan(l);r={a:1,b:Math.tan(n),c:e,d:1,e:0,f:0}}return r};let s={a:1,b:0,c:0,d:1,e:0,f:0};0===t.x&&0===t.y||(s=a(s,l(t.x,t.y)));const i={translate:[0,0],scale:[1,1],skew:[0,0],rotate:[0],matrix:[1,0,0,1,0,0]};for(const t of e){const e=Object.keys(t)[0],o=t[e]||i[e];let[p,u=i[e][1]]=o;switch("rotate"===e&&3===o.length&&(p=o[2]),e){case"matrix":let t=["a","b","c","d","e","f"];s=a(s,Object.fromEntries(t.map((e,t)=>[e,o[t]])));break;case"translate":(p||u)&&(s=a(s,l(p,u)));break;case"skew":(p||u)&&(s=a(s,r([p,u],"skew")));break;case"rotate":p&&(s=a(s,r([p],"rot")));break;case"scale":1===p&&1===u||(s=a(s,n(p,u)));break;default:throw new Error(`Unknown transformation type: ${e}`)}}0===t.x&&0===t.y||(s=a(s,l(-t.x,-t.y)));return s}(e,t);return a}const xt=["path","polygon","polyline","line","rect","circle","ellipse"],ft=["textPath","text","tspan"],gt={atts:{id:"*",class:"*",viewBox:["symbol","svg"],preserveAspectRatio:["symbol","svg"],width:["svg","rect","use","image"],height:["svg","rect","use","image"],d:["path"],points:["polygon","polyline"],x:["image","rect","text","textPath","tspan","use","mask"],y:["image","rect","text","textPath","tspan","use","mask"],x1:["line","linearGradient"],x2:["line","linearGradient"],y1:["line","linearGradient"],y2:["line","linearGradient"],r:["circle","radialGradient"],rx:["rect","ellipse"],ry:["rect","ellipse"],cx:["circle","ellipse","radialGradient"],cy:["circle","ellipse","radialGradient"],refX:["symbol","markers"],refY:["symbol","markers"],transform:["svg","g","use",...xt,...ft],"transform-origin":["svg","g","use",...xt,...ft],fill:["svg","g","use",...xt,...ft,"animate","animateMotion"],"fill-opacity":["svg","g","use",...xt,...ft],opacity:["svg","g","use",...xt,...ft],stroke:["svg","g","use",...xt,...ft],"stroke-width":["svg","g","use",...xt,...ft,"mask"],"stroke-opacity":["svg","g","use",...xt,...ft,"mask"],"stroke-miterlimit":["svg","g","use",...xt,...ft,"mask"],"stroke-linejoin":["svg","g","use",...xt,...ft,"mask"],"stroke-linecap":["svg","g","use",...xt,...ft,"mask"],"stroke-dashoffset":["svg","g","use",...xt,...ft,"mask"],"stroke-dasharray":["svg","g","use",...xt,...ft,"mask"],"clip-path":["svg","g","use",...xt,...ft],"clip-rule":["path","polygon"],clipPathUnits:["clipPath"],mask:["svg","g","use",...xt,...ft],maskContentUnits:["mask"],maskUnits:["mask"],"font-family":["svg","g",...ft],"font-size":["svg","g",...ft],"font-style":["svg","g",...ft],"font-weight":["svg","g",...ft],"font-stretch":["svg","g",...ft],"dominant-baseline":[...ft],lengthAdjust:[...ft],"text-anchor":["text"],textLength:["text","textPath","tspan"],dx:["text","tspan"],dy:["text","tspan"],method:["textPath"],spacing:["textPath"],startOffset:["textPath"],rotate:["text","tspan","animateMotion"],side:["textPath"],"white-space":["svg","g",...ft],color:["svg","g",...ft],playbackorder:["svg"],timelinebegin:["svg"],dur:["animate","animateTransform","animateMotion"],end:["animate","animateTransform","animateMotion"],from:["animate","animateTransform","animateMotion"],to:["animate","animateTransform","animateMotion"],type:["animateTransform"],values:["animate","animateTransform","animateMotion"],accumulate:["animate","animateTransform","animateMotion"],additive:["animate","animateTransform","animateMotion"],attributeName:["animate","animateTransform"],begin:["animate","animateTransform","animateMotion"],by:["animate","animateTransform","animateMotion"],calcMode:["animate","animateTransform","animateMotion"],keyPoints:["animateMotion"],keySplines:["animate","animateTransform","animateMotion"],keyTimes:["animate","animateTransform","animateMotion"],max:["animate","animateTransform","animateMotion"],min:["animate","animateTransform","animateMotion"],origin:["animateMotion"],repeatCount:["animate","animateTransform","animateMotion"],repeatDur:["animate","animateTransform","animateMotion"],restart:["animate","animateTransform","animateMotion"],gradientUnits:["linearGradient","radialGradient"],gradientTransform:["linearGradient","radialGradient"],fr:["radialGradient"],fx:["radialGradient"],fy:["radialGradient"],offset:["stop"],"stop-color":["stop"],"stop-opacity":["stop"],spreadMethod:["linearGradient","radialGradient"],href:["pattern","textPath","linearGradient","radialGradient","use","animate","animateTransform","animateMotion","image"],pathLength:[...xt]},defaults:{transform:["none","matrix(1, 0, 0, 1, 0, 0)"],"transform-origin":["0px, 0px","0 0"],rx:["0","0px"],ry:["0","0px"],x:["0","0px"],y:["0","0px"],fill:["black","rgb(0, 0, 0)","rgba(0, 0, 0, 0)","#000","#000000"],color:["black","rgb(0, 0, 0)","rgba(0, 0, 0, 0)","#000","#000000"],stroke:["none"],"stroke-width":["1","1px"],opacity:["1"],"fill-opacity":["1"],"stroke-opacity":["1"],"stroke-linecap":["butt"],"stroke-miterlimit":["4"],"stroke-linejoin":["miter"],"stroke-dasharray":["none"],"stroke-dashoffset":["0","0px","none"],pathLength:["none"],"font-family":["serif"],"font-weight":["normal","400"],"font-stretch":["normal"],"font-width":["normal"],"letter-spacing":["auto","normal","0"],lengthAdjust:["spacing"],"text-anchor":["start"],"dominant-baseline":["auto"],spacing:["auto"],"white-space":["normal"],"stop-opacity":["1"],gradientUnits:["objectBoundingBox"],patternUnits:["objectBoundingBox"],"clip-path":["none"],"clip-rule":["nonzero"],"fill-rule":["nonzero"],clipPathUnits:["userSpaceOnUse"],mask:["none"],maskUnits:["objectBoundingBox"]}};function mt(e,{removeNameSpaced:t=!0,decimals:a=-1}={}){let l=e.nodeName.toLowerCase(),n=function(e){let t={},a=[...e.attributes].map(e=>e.name),l=a.length;if(!l)return t;for(let n=0;n<l;n++){let l=a[n],r=e.getAttribute(l);t[l]=r}return t}(e),r=function(e){let t=e.getAttribute("style"),a=t?function(e=""){let t={};if(!e)return t;let a=e.split(";").filter(Boolean).map(e=>e.trim()),l=a.length;if(!l)return t;for(let e=0;l&&e<l;e++){let l=a[e],[n,r]=l.split(":").filter(Boolean);t[n]=r}return t}(t):{};return a}(e),s={...n,...r},i={},o=r.transform;if(o){let e=ct(function(e,t={x:0,y:0}){let a,l={transforms:[],transformOrigin:t},n=/(\w+)\(([^)]+)\)/g;function r(e){if("string"==typeof e){if(e.includes("rad"))return parseFloat(e)*(180/Math.PI);if(e.includes("turn"))return 360*parseFloat(e)}return parseFloat(e)}for(;null!==(a=n.exec(e));){let e=a[1],t=a[2].split(/,\s*/).map(e=>r(e));switch(e){case"translate":l.transforms.push({translate:[t[0]||0,t[1]||0]});break;case"translateX":l.transforms.push({translate:[t[0]||0,0,0]});break;case"translateY":l.transforms.push({translate:[0,t[0]||0,0]});break;case"scale":l.transforms.push({scale:[t[0]||0,t[1]||0]});break;case"skew":l.transforms.push({skew:[t[0]||0,t[1]||0]});break;case"skewX":l.transforms.push({skew:[t[0]||0,0]});break;case"skewY":l.transforms.push({skew:[0,t[0]||0]});break;case"rotate":l.transforms.push({rotate:[0,0,t[0]||0]});break;case"matrix":l.transforms.push({matrix:t})}}return e.split(/;\s*/).forEach(e=>{let[t,a]=e.split(":").map(e=>e.trim());if("transform-origin"===t||"perspective-origin"===t){let[e,n]=a.split(/\s+/).map(parseFloat);"transform-origin"===t&&(l.transformOrigin={x:e||0,y:n||0})}}),l}(`${o}`));s.transform=`matrix(${Object.values(e).join(",")})`}let p=["inline-size"],u=[];for(let a in s){let n=s[a];n&&a.startsWith("--")||p.includes(a)||!t&&a.startsWith("-")?u.push(`${a}:${n}`):(n&>.atts[a]&&("*"===gt.atts[a]||gt.atts[a].includes(l)||!t&&a.includes(":"))&&(i[a]=n),e.removeAttribute(a))}for(let t in i){let a=i[t];e.setAttribute(t,a)}return u.length&&e.setAttribute("style",u.join(";")),i}function dt(e,{returnDom:t=!1,removeHidden:a=!0,removeUnused:l=!0,stylesToAttributes:n=!0,removePrologue:r=!0,fixHref:s=!0,mergePaths:i=!1,cleanupSVGAtts:o=!0,removeNameSpaced:p=!0,attributesToGroup:u=!0,decimals:h=-1,excludedEls:y=[]}={}){e=e.replace(/<\?xml[\s\S]*?\?>/gi,"").replace(/<!DOCTYPE[\s\S]*?>/gi,"").replace(/<!--[\s\S]*?-->/g,"").trim(),s&&(e=e.replaceAll("xlink:href=","href="));let c=(new DOMParser).parseFromString(e,"text/html").querySelector("svg");if(o){!function(e,t=["viewBox","xmlns","width","height","id","class"]){[...e.attributes].map(e=>e.name).forEach(a=>{t.includes(a)||e.removeAttribute(a)})}(c,["viewBox","xmlns","width","height","id","class","fill","stroke","stroke-width","stroke-linecap","stroke-linejoin"])}let x=["metadata","script",...y],f=c.querySelectorAll("*"),g=[];for(let e=0;e<f.length;e++){let t=f[e],l=t.nodeName.toLowerCase(),r=t.getAttribute("style")||"",s=!!r&&r.trim().includes("display:none"),o=t.getAttribute("display")&&"none"===t.getAttribute("display")||s;if(l.includes(":")||x.includes(l)||a&&o)t.remove();else if(n||u||i){let a=mt(t,{removeNameSpaced:p,decimals:h});"path"===l&&g.push({el:t,name:l,idx:e,propsFiltered:a})}}return(u||i)&&function(e=[],t=!0){let a=[[e[0]]],l=0,n="";for(let t=0;t<e.length;t++){let r=e[t],s=r.propsFiltered,i=[];for(let e in s)"d"!==e&&"id"!==e&&i.push(`${e}:${s[e]}`);i=i.join("_"),r.propstr=i,i===n?a[l].push(r):a[l].length&&(a.push([]),l++),n=i}for(let e=0;e<a.length;e++){let l=a[e];if(l.length>1){let e=l[0].el,a=l[0].propsFiltered,n=e.parentNode.closest("g")?e.parentNode.closest("g"):null;n||(n=document.createElementNS("http://www.w3.org/2000/svg","g"),e.parentNode.insertBefore(n,e),l.forEach(e=>{n.append(e.el)}));let r=[...n.children];for(let e in a){if("d"!==e&&"id"!==e){let t=a[e];n.setAttribute(e,t),r.forEach(a=>{a.getAttribute(e)===t&&a.removeAttribute(e)})}if(t){let e=l[0].el,t=l[0].propsFiltered.d;for(let e=1;e<l.length;e++){let a=l[e],n=a.el,r=a.propsFiltered.d;t+=r.startsWith("M")?r:Ze(r).pathData.map(e=>`${e.type} ${e.values.join(" ")}`).join(" "),n.remove()}e.setAttribute("d",t)}}}}}(g,i),t?c:vt(c)}function vt(e){let t=(new XMLSerializer).serializeToString(e);return t=t.replace(/\t/g,"").replace(/[\n\r|]/g,"\n").replace(/\n\s*\n/g,"\n").replace(/ +/g," "),t}function Mt(e,{threshold:t=0,tolerance:a=1}={}){let l=e.length,n=[e[0]],r="z"===e[l-1].type.toLowerCase(),s=!!r&&(e[l-1].p.x===e[0].p0.x&&e[l-1].p.y===e[0].p0.y),i=r?2:1,o=e[l-i],p="L"===o.type,u="C"===o.type,h="L"===e[1].type,y="C"===e[1].type,c=r&&y&&(p||s);c&&(e[l-1].values=e[0].values,e[l-1].type="L",p=!0);for(let t=1;t<l;t++){let s=e[t],{type:o}=s,x=e[t+1]?e[t+1]:null;if("L"===o&&x&&"C"===x.type||"C"===o&&x&&"L"===x.type){let c="L"===o?s:null,f=null,g=[],m=0;if(1===t&&y&&p&&(g=[e[1]],c=e[l-1],f=x),!c){n.push(s);continue}r&&u&&h&&t===l-i-1&&(f=e[1],g=[e[l-i]]);for(let a=t+1;a<l;a++){let t=e[a]?e[a]:null,l=e[a-1];if("C"===l.type&&g.push(l),"L"===t.type&&"C"===l.type){f=t;break}m++}if(f){let e=ie(c.p0,c.p),l=ie(f.p0,f.p);g.length;let r=ie(c.p,f.p0),i=de([c.p0,c.p,f.p0,f.p],!1),o=de([g[0].p0,g[0].cp1,g[0].cp2,g[0].p],!1),p=i<0&&o>0||i>0&&o<0,u=.5*r*a,h=u<e&&u<l;if(g.length&&!p&&h){let e=Math.abs(o)<=.005*se(g[0].p0,g[0].p),a=e?null:Z(c.p0,c.p,f.p0,f.p,!1);if(!e&&a){let e=.75*ie(R([c.p,a,f.p0],.5),1===g.length?R([g[0].p0,g[0].cp1,g[0].cp2,g[0].p],.5):g[0].p);if(u&&e>u&&e>.3*r){n.push(s);continue}{let e={type:"Q",values:[a.x,a.y,f.p0.x,f.p0.y]};e.p0=c.p,e.cp1=a,e.p=f.p0,n.push(c,e),t+=m;continue}}}}}c&&t===l-1&&"L"===o||n.push(s)}return(c||r&&"Z"!==n[n.length-1].type)&&n.push({type:"Z",values:[]}),n}function bt(e){if(e.length<3)return!1;let t=e[0],a=e[Math.floor(e.length/2)],l=e[e.length-1],n=t.x,r=t.y,s=a.x,i=a.y,o=l.x,p=l.y,u=n-s,h=r-i,y=n-o,c=r-p,x=(n*n-s*s+(r*r-i*i))/2,f=(n*n-o*o+(r*r-p*p))/2,g=u*c-h*y;if(Math.abs(g)<1e-10)return console.warn("Points are collinear or numerically unstable"),!1;let m={x:(c*x-h*f)/g,y:(-y*x+u*f)/g},d=re(m,t),v=U(m,t,l),{deltaAngle:M,startAngle:b,endAngle:A}=v;return{centroid:m,r:d,startAngle:b,endAngle:A,deltaAngle:M}}function At(e,{threshold:t=0,tolerance:l=1,toCubic:n=!1,debug:r=!1}={}){let s=e.length,i=[e[0]],o=[];for(let t=1;t<s;t++){let l=e[t],{type:s}=l,p=e[t-1],u=e[t+1]?e[t+1]:null,h=e[t+2]?e[t+2]:null,y=e[t+3]?e[t+3]:null,c=null;"C"===l.type||"Q"===l.type?c=l:!u||"C"!==u.type&&"Q"!==u.type||(c=u);let x,f,g,m,d,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,w=[];if("L"===p.type&&"L"===s&&c&&"L"===h.type&&y&&("L"===y.type||"Z"===y.type)?(x=[l.p0,l.p],f=[h.p0,h.p],g=l.p0,m=h.p,M=de(v,!1),b=de([...x,...f],!1),A=M<0&&b>0||M>0&&b<0,A||(d=R(v,.5),w=[g,d,m],C=!0)):"C"!==s&&"Q"!==s||"L"!==p.type||"C"!==u.type&&"Q"!==u.type||"L"!==h.type||(C=!0,x=[p.p0,p.p],f=[h.p0,h.p],g=p.p,m=h.p0,d=c.p,w=[g,c.p,m]),C){let e=bt(w);if(e){let s,{centroid:p,r:u,deltaAngle:h,startAngle:y,endAngle:c}=e,x=0,f=h>0?1:0,v=Math.abs(h)>Math.PI?1:0;if(oe(J(g,p.x,p.y,.5*h),d)<.05*oe(g,m)){if(s=qe({p0:g,p:m,centroid:p,rx:u,ry:u,xAxisRotation:x,sweep:f,largeArc:v,deltaAngle:h,startAngle:y,endAngle:c}),1===s.length){let e=Pe(g,s[0].cp1,s[0].cp2,m);"Q"===e.type&&(n=!0),l=e}if(s.length>1&&(n=!1),n||(l.type="A",l.values=[u,u,x,v,f,m.x,m.y]),l.p0=g,l.p=m,l.extreme=!1,l.corner=!1,r){o=n?[{type:"M",values:[g.x,g.y]},...s]:[{type:"M",values:[g.x,g.y]},{type:"A",values:[u,u,x,v,f,m.x,m.y]}];let e=ve(o);a(markers,e,"orange","0.5%","0.5")}i.push(l),t++;continue}}}i.push(l)}return i}function Ct(e=[],{threshold:t=0}={}){let a=e.length,l="z"===e[a-1].type.toLowerCase(),n=l?a-2:a-1,r=e[n],s=r.values.slice(-2),i={x:e[0].values[0],y:e[0].values[1]},o=oe(i,{x:s[0],y:s[1]});if(o&&o<t){let a=e[n].values.length;e[n].values[a-2]=i.x,e[n].values[a-1]=i.y;let l=e[1];if("C"===l.type&&"C"===r.type){let a=Math.abs(l.values[0]-r.values[2]),s=Math.abs(l.values[1]-r.values[3]),o=Math.abs(e[1].values[0]-l.values[0]),p=Math.abs(e[1].values[1]-l.values[1]),u=Math.abs(e[1].values[0]-r.values[2]),h=Math.abs(e[1].values[1]-r.values[3]),y=p<t&&h<t&&a;a&&a<t&&(o<t&&u<t&&s)&&(e[1].values[0]=i.x,e[n].values[2]=i.x),s&&s<t&&y&&(e[1].values[1]=i.y,e[n].values[3]=i.y)}}return e}function wt(e,t=1){let a=[];for(let l=0,n=e.length;l<n;l++){let n=e[l],{type:r,values:s}=n,i={type:r,values:[]};switch(r.toLowerCase()){case"h":case"v":i.values=[s[0]*t];break;case"a":i.values=[s[0]*t,s[1]*t,s[2],s[3],s[4],s[5]*t,s[6]*t];break;default:s.length&&(i.values=s.map((e,a)=>e*t))}a.push(i)}return a}function kt(e,{tolerance:t=1}={}){let l=[],n=[],r=e.length;for(let t=1;t<r;t++){let a=e[t],{type:r,values:s,p0:i,cp1:o=null,cp2:p=null,p:u,extreme:h=null,semiExtreme:y=null,corner:c=null,directionChange:x}=a,f=e[t+1]||null;h||c||f&&f.type!==r?(n.push(a),l.push(n),n=[]):n.push(a)}console.log("!!!chunks",l),function(e){console.log("chunks",e);let t="green";for(let l=0;l<e.length;l++){let n=e[l],r=n.length;t=l%2==0?"orange":"green";let s=n[0],i=n[r-1],o=[{type:"M",values:[s.p0.x,s.p0.y]}];for(let e=0,t=r;e<t;e++){let a=n[e];n[e+1],n[t-1],"C"===s.type&&i.type;let{type:l,values:r,p0:p,cp1:u=null,cp2:h=null,p:y=null,extreme:c,semiExtreme:x=null,corner:f=null}=a;o.push({type:l,values:r})}let p=ve(o);a(markers,p,t,"1%","0.5")}}(l);let s=l.length;for(let e=0;e<s;e++){let t=l[e],a=l[e+1]||null;1===t.length&&a&&a[0].type}l=l.filter(Boolean);let i=[e[0]];for(let e=0;e<l.length;e++){let t=l[e],a=t.length,n=t[0],r=t[a-1],s=.05*ie(n.p0,r.p);for(let e=0,l=a;e<l;e++){let o=t[e];t[e+1],t[l-1];let p="C"===n.type&&"C"===r.type,{type:u,values:h,p0:y,cp1:c=null,cp2:x=null,p:f=null,extreme:g,semiExtreme:m=null,corner:d=null}=o,v=null,M=null,b=null,A=null,C=null,w=null,k=[],E=.666,L=null;if(p){let e=Math.abs(n.p0.x-n.cp1.x),t=Math.abs(n.p0.y-n.cp1.y),a=Math.abs(r.p.x-r.cp2.x),l=Math.abs(r.p.y-r.cp2.y),i=e<s&&e<t,o=a<s&&a<l,p=l<s&&a>l;t<s&&e>t&&(n.cp1.y=n.p0.y),p&&(r.cp2.y=r.p.y),i&&(n.cp1.x=n.p0.x),o&&(r.cp2.x=r.p.x)}if(ve([{type:"M",values:[o.p0.x,o.p0.y]},{type:u,values:h}]),1===a||"C"!==u)i.push(o);else{let e=t.filter(e=>e.semiExtreme),a=t.filter(e=>e.directionChange);if(e.length||a.length){if(L=e.length?e[0]:a[0],n.p0.x===n.cp1.x&&n.p0.y===n.cp1.y?n.cp1=R([n.p0,n.cp1,n.cp2,n.p],.5):r.p.x===r.cp2.x&&r.p.y===r.cp2.y&&(r.cp2=R([r.p0,r.cp1,r.cp2,r.p],.5)),v=Z(L.p,L.cp2,n.p0,n.cp1,!1),M=Z(L.p,L.cp2,r.p,r.cp2,!1),v&&M){b=R([n.p0,v],E),A=R([r.p,M],E),C=R([L.p,v],E),w=R([L.p,M],E),k=[{type:"M",values:[n.p0.x,n.p0.y]},{type:"C",values:[b.x,b.y,C.x,C.y,L.p.x,L.p.y]},{type:"C",values:[w.x,w.y,A.x,A.y,r.p.x,r.p.y]}],ve(k),i.push({type:"C",values:[b.x,b.y,C.x,C.y,L.p.x,L.p.y],p0:n.p0,cp1:b,cp2:C,p:L.p,dimA:ie(n.p0,L.p)},{type:"C",values:[w.x,w.y,A.x,A.y,r.p.x,r.p.y],p0:L.p,cp1:w,cp2:A,p:r.p,extreme:!0,dimA:ie(L.p,r.p)});break}}else i.push(o)}}}return i}function Et(e,t=1){for(let a=1,l=e.length;a<l;a++){let l=e[a],{type:n,values:r,p0:s,cp1:i=null,cp2:o=null,p:p=null}=l;if("C"===n){let n=Pe(s,i,o,p,t);"Q"===n.type&&(n.extreme=l.extreme,n.corner=l.corner,n.dimA=l.dimA,n.squareDist=l.squareDist,e[a]=n)}}return e}function Lt(e,{areaThreshold:t=2.5}={}){for(let a=0,l=e.length;a<l;a++){let l=e[a],n=e[a+1]||null,{type:r,values:s,p0:i,cp1:o=null,cp2:p=null,p:u=null}=l;if("C"===r&&n&&"C"===n.type){let l=Pt(i,o,p,u,t),r=Pt(n.p0,n.cp1,n.cp2,n.p,t);if(l.isArc&&r.isArc){let t=.01*ie(i,n.p),s=Math.abs(n.p.x-i.x),o=Math.abs(n.p.y-i.y),p=o<t&&s>t,h=s<t&&o>t,{rx:y,ry:c}=l,x=de([i,u,n.p])<0?0:1;if(h||p){y=Math.min(y,r.rx),c=Math.min(c,r.ry),e[a]=null,e[a+1].type="A",e[a+1].values=[y,c,0,0,x,n.p.x,n.p.y];continue}}}}return e=e.filter(Boolean)}function Pt(e,t,a,l,n=7.5){let r,s={type:"C",values:[t.x,t.y,a.x,a.y,l.x,l.y]},i=0,o=!1,p=O(e,t,!0),u=O(l,a,!0),h=180*Math.abs(p-u)/Math.PI,y=0,c=0;if(Math.abs(h%180-90)<3){r=Z(e,J(t,e.x,e.y,-.5*Math.PI),l,J(a,l.x,l.y,.5*Math.PI),!1);let p=Z(e,t,l,a,!1);if(p){let r=re(e,p),u=re(l,p),h=+Math.max(r,u).toFixed(8),x=+Math.min(r,u).toFixed(8);y=x,c=h;let f=de([e,t,a,l])<0?0:1,g=Math.abs(l.x-e.x)>Math.abs(l.y-e.y);100/y*Math.abs(y-c)<5&&(y=h,c=y),g&&(y=h,c=x);let m=me([{type:"M",values:[e.x,e.y]},{type:"C",values:[t.x,t.y,a.x,a.y,l.x,l.y]}]),d={type:"A",values:[y,c,0,0,f,l.x,l.y]};i=Math.PI*(y*c)/4,i-=Math.abs(de([e,l,p])),function(e,t){let a=Math.abs(e-t);return Math.abs(100-100/e*(e+a))}(m,i)<n&&(o=!0,s=d)}}return{com:s,isArc:o,area:i,rx:y,ry:c,centroid:r}}function St(e,{angles:t=[],split:a=0,getPathData:l=!0,width:n=0,height:r=0}={}){let s=e.length,i={x:e[0].values[0],y:e[0].values[1]},o=i,p=[],u=[o],h=0;if(a=a||1,n&&r)h=.025*(n+r)/a;else{h=e.map(e=>e.dimA||0).filter(Boolean).sort()[0]}for(let t=1;t<s;t++){let l=e[t],n=e[t+1]||null,{type:r,values:s}=l,p=s.length,y=p?{x:s[p-2],y:s[p-1]}:i;if("C"===r||"Q"===r){let e={x:s[0],y:s[1]},t="C"===r?{x:s[2],y:s[3]}:e,n="C"===r?[o,e,t,y]:[o,e,y],i=l.dimA;a=Math.ceil(i/h);let p=[];for(let e=1;e<a;e++)p.push(1/a*e);p.forEach(e=>{let t=R(n,e);u.push(t)})}"M"===r&&(i=y),y.area=l.cptArea||0,y.isExtreme=l.extreme||!1,y.isCorner=l.corner||!1,y.isDirChange=l.directionChange||!1,u.push(y),l.extreme||l.corner||n&&n.type,o=y}return u=function(e,{quality:t=.9,width:a=0,height:l=0,absolute:n=!1,manhattan:r=!1,exclude:s=[]}={}){"string"==typeof t&&(n=!0,t=parseFloat(t));if(e.length<4||(!n&&t)>=1)return e;let i=t;if(!n){if(i=1-t,!a&&!l){let t=pe(e,12);({width:a,height:l}=xe(t))}i=r?.05*(a+l)*(1-t):(i*((a+l)/2/25))**2}let o,p=e[0],u=[p],h=e.length,y=s.length,c=0;for(let t=1;t<h;t++)o=e[t],c=r?ie(p,o):se(p,o),!(c<i)||y&&s.includes(t)?(u.push(o),p=o):p=o;return p.x!==o.x&&p.y!==o.y&&u.push(o),u}(u,{quality:.5,width:n,height:r}),p=function(e,t=!0){let a=[{type:"M",values:[e[0].x,e[0].y]},...e.slice(1).map(e=>({type:"L",values:[e.x,e.y]}))];return t&&a.push({type:"Z",values:[]}),a}(u),l?p:u}function Tt(e="",{getObject:t=!1,toAbsolute:a=!0,toRelative:l=!0,toShorthands:n=!0,quadraticToCubic:r=!0,arcToCubic:s=!1,cubicToArc:i=!1,simplifyBezier:o=!0,optimizeOrder:p=!0,autoClose:u=!0,removeZeroLength:h=!0,refineClosing:y=!0,removeColinear:c=!0,flatBezierToLinetos:x=!0,revertToQuadratics:f=!0,refineExtremes:g=!0,simplifyCorners:m=!1,keepExtremes:d=!0,keepCorners:v=!0,extrapolateDominant:M=!0,keepInflections:b=!1,addExtremes:A=!1,addSemiExtremes:C=!1,smoothPoly:w=!1,harmonizeCpts:k=!1,toPolygon:E=!1,removeOrphanSubpaths:L=!1,simplifyRound:P=!1,scale:S=1,scaleTo:T=0,crop:I=!1,alignToOrigin:F=!1,decimals:D=3,autoAccuracy:$=!0,minifyD:z=0,tolerance:q=1,reverse:j=!1,cleanupSVGAtts:Q=!0,removePrologue:B=!0,stylesToAttributes:N=!0,fixHref:G=!0,removeNameSpaced:O=!0,attributesToGroup:U=!1,mergePaths:Z=!1,removeHidden:H=!0,removeUnused:R=!0,shapesToPaths:W=!0,tMin:J=0,tMax:X=1,redraw:Y=!1}={}){q=Math.max(.1,q),S=Math.max(.001,S);let _=function(e){let t="string";if(Array.isArray(e))return e[0]?.type&&e[0]?.values?"pathData":"array";if("string"==typeof e){let a=(e=e.trim()).includes("<svg")&&e.includes("</svg"),l=e.startsWith("M")||e.startsWith("m"),n=!isNaN(e.substring(0,1))&&!isNaN(e.substring(e.length-1,e.length));if(a)t="svgMarkup";else if(l)t="pathDataString";else if(n)t="polyString";else{let a=/^(file:|https?:\/\/|\/|\.\/|\.\.\/)/.test(e),l=e.startsWith("data:image");t=a||l?"url":"string"}return t}return t=typeof e,(e.constructor.name||t).toLowerCase()}(e),K="",ee=0,te=0,ae=0,le={},ne="",re="svgMarkup"===_?1:0,se=[];ee=e.length;let ie={x:0,y:0,width:0,height:0},oe={x:0,y:0,width:0,height:0},pe=[],he=[];if(re){if(K=dt(e,{cleanupSVGAtts:Q,returnDom:!0,removeHidden:H,removeUnused:R,removeNameSpaced:O,attributesToGroup:U,stylesToAttributes:N,removePrologue:B,fixHref:G,mergePaths:Z}),W){K.querySelectorAll("polygon, polyline, line, rect, circle, ellipse").forEach(e=>{let t=He(e);e.replaceWith(t)})}K.querySelectorAll("path").forEach(e=>{se.push({d:e.getAttribute("d"),el:e})}),ie=function(e=null,t=-1){const a=e=>e&&isNaN(e)?e.match(/[^\d|.]+/g)[0]:"";if(!e)return!1;let l=e.hasAttribute("width"),n=e.hasAttribute("height"),r=e.hasAttribute("viewBox"),s=l?e.getAttribute("width"):0,i=n?e.getAttribute("height"):0,o=!!l&&a(s),p=!!n&&a(s),u=s?s.includes("%")?0:parseFloat(s):300,h=i?i.includes("%")?0:parseFloat(i):150,y=r?e.getAttribute("viewBox").split(/,| /).filter(Boolean).map(Number):[0,0,u,h];return t>-1&&([u,h]=[u,h].map(e=>+e.toFixed(t)),y=y.map(e=>+e.toFixed(t))),{x:y[0],y:y[1],width:y[2],height:y[3],w:u,h:h,hasViewBox:r,hasWidth:l,hasHeight:n,widthUnit:o,heightUnit:p}}(K,D)}else{if("pathDataString"===_)ne=e;else if("polyString"===_)ne="M"+e;else if("pathData"===_){ne=e,ee=ne.map(e=>`${e.type} ${e.values.join(" ")}`).join(" ").length}se.push({d:ne,el:null})}let ye={toRelative:l,toShorthands:n,decimals:D},fe=[];for(let e=0,t=se.length;t&&e<t;e++){let t=se[e],{d:l,el:n}=t,Q=Qe(l,{quadraticToCubic:r,toAbsolute:a,arcToCubic:s}),B=w||E?xe(V(Q)):null;if(1!==S||T){if(T)if(ie.width&&!I)S=T/ie.width;else{let e=Q.map(e=>({type:e.type,values:e.values}));e=Se(e,{arcToCubic:!0}),e=ce(e);let t=xe(V(e));pe.push(t.x,t.x+t.width),he.push(t.y,t.y+t.height);let a=T/t.width;S=a}Q=wt(Q,S)}let N=Q.length;L&&(Q=Ve(Q));let G=ue(Q),O=G.length,U=[];for(let e=0;e<O;e++){let t=G[e];if(E){o=!1,w=!1,k=!1,t=Re(t);let e=Le(t),{bb:a,pathData:l}=e;t=l,t=St(t,{angles:[],split:1,width:B.width,height:B.height,getPathData:!0})}if(w){let e=Array.from(new Set(t.map(e=>e.type))).join(""),a=!/[acqts]/gi.test(e),l=/[z]/gi.test(e);if(a){t=We(t),t=ht(V(t),{denoise:.8,tolerance:q,width:B.width,height:B.height,manhattan:!1,absolute:!1,keepCorners:v,keepExtremes:d,keepInflections:b,closed:l})}}k&&(t=_e(t)),(c||h)&&(t=We(t)),Y&&(A=!0,C=!0,m=!1,v=!0,d=!0,p=!0,J=0,X=0),p&&(t=Je(t)),c&&(t=Re(t,{tolerance:q,flatBezierToLinetos:!1})),(A||C)&&(t=ce(t,{tMin:J,tMax:X,addExtremes:A,addSemiExtremes:C,angles:[30]}));let a=Le(t,{detectSemiExtremes:C}),{pathData:l,bb:n,dimA:r}=a;if(pe.push(n.x,n.x+n.width),he.push(n.y,n.y+n.height),y&&(l=Ct(l,{threshold:.001*r})),l=o?be(l,{simplifyBezier:o,keepInflections:b,keepExtremes:d,keepCorners:v,extrapolateDominant:M,revertToQuadratics:f,tolerance:q,reverse:j}):l,g){l=yt(l,{threshold:.05*(n.width+n.height),tolerance:q})}if(Y&&(n.width,n.height,l=kt(l,{tolerance:q,threshold:.001*r})),i&&(l=Lt(l,{areaThreshold:2.5})),c&&x&&(l=Re(l,{tolerance:q,flatBezierToLinetos:x})),m){l=Mt(l,{threshold:.1*(n.width+n.height),tolerance:q})}P&&(l=At(l)),f&&(l=Et(l,q)),p&&(l=Xe(l,{autoClose:u})),U.push({pathData:l,bb:n})}let H=Math.min(...pe),R=Math.min(...he);oe={x:H,y:R,width:Math.max(...pe)-H,height:Math.max(...he)-R};let W=oe.height>oe.width;if(p&&(U=W?U.sort((e,t)=>e.bb.y-t.bb.y||e.bb.x-t.bb.x):U.sort((e,t)=>e.bb.x-t.bb.x||e.bb.y-t.bb.y)),Q=[],U.forEach(e=>{Q.push(...e.pathData)}),$&&(D=we(Q),ye.decimals=D),Z=!1,n&&Z)fe.push(...Q);else{Q=Se(Q,ye),Q=We(Q),F&&(console.log(oe),Q[0].values[0]=(Q[0].values[0]-oe.x).toFixed(D),Q[0].values[1]=(Q[0].values[1]-oe.y).toFixed(D),oe.x=0,oe.y=0);let e=Q.length,a=ve(Q,z);te=a.length,ae=+(100/ee*te).toFixed(2),t.d=a,t.report={original:N,new:e,saved:N-e,compression:ae,decimals:D},n&&n.setAttribute("d",a)}}if(re){if(fe.length){let e=Se(fe,ye);e=We(e);let t=ve(e,z);se[0].el.setAttribute("d",t);for(let e=1;e<se.length;e++){let t=se[e].el;t&&t.remove()}!function(e){e.querySelectorAll("g, defs").forEach(e=>{e.children.length||e.remove()})}(K)}if(S){let{x:e,y:t,width:a,height:l,w:n,h:r,hasViewBox:s,hasWidth:i,hasHeight:o,widthUnit:p,heightUnit:u}=ie;I&&(e=oe.x,t=oe.y,a=oe.width,l=oe.height,n=a,r=l),s&&K.setAttribute("viewBox",[e,t,a,l].map(e=>+(e*S).toFixed(D)).join(" ")),i&&K.setAttribute("width",+(n*S).toFixed(D)+p),o&&K.setAttribute("height",+(r*S).toFixed(D)+u)}K=vt(K),te=K.length,ae=+(100/ee*te).toFixed(2),ee=+(ee/1024).toFixed(3),te=+(te/1024).toFixed(3),le={svgSize:ee,svgSizeOpt:te,compression:ae,decimals:D}}else({d:ne,report:le}=se[0]);return t?{svg:K,d:ne,report:le,inputType:_,mode:re}:ne||K}"undefined"!=typeof window&&(window.svgPathSimplify=Tt),e.PI=A,e.abs=l,e.acos=n,e.asin=r,e.atan=s,e.atan2=i,e.ceil=o,e.cos=p,e.exp=u,e.floor=h,e.hypot=c,e.log=y,e.max=x,e.min=f,e.pow=g,e.random=m,e.round=d,e.sin=v,e.sqrt=M,e.svgPathSimplify=Tt,e.tan=b}(this["svg-path-simplify"]=this["svg-path-simplify"]||{});
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { revertCubicQuadratic } from "./svgii/pathData_convert";
|
|
2
2
|
|
|
3
|
-
export function pathDataRevertCubicToQuadratic(pathData) {
|
|
3
|
+
export function pathDataRevertCubicToQuadratic(pathData, tolerance=1) {
|
|
4
4
|
|
|
5
5
|
for (let c = 1, l = pathData.length; c < l; c++) {
|
|
6
6
|
let com = pathData[c]
|
|
7
7
|
let { type, values, p0, cp1 = null, cp2 = null, p = null } = com;
|
|
8
8
|
if (type === 'C') {
|
|
9
9
|
//console.log(com);
|
|
10
|
-
let comQ = revertCubicQuadratic(p0, cp1, cp2, p)
|
|
10
|
+
let comQ = revertCubicQuadratic(p0, cp1, cp2, p, tolerance)
|
|
11
11
|
if (comQ.type === 'Q') {
|
|
12
12
|
comQ.extreme = com.extreme
|
|
13
13
|
comQ.corner = com.corner
|
package/src/pathSimplify-main.js
CHANGED
|
@@ -464,7 +464,7 @@ export function svgPathSimplify(input = '', {
|
|
|
464
464
|
let threshold = (bb.width + bb.height) * 0.1
|
|
465
465
|
pathData = refineRoundedCorners(pathData, { threshold, tolerance })
|
|
466
466
|
}
|
|
467
|
-
|
|
467
|
+
|
|
468
468
|
// refine round segment sequences
|
|
469
469
|
if (simplifyRound) pathData = refineRoundSegments(pathData);
|
|
470
470
|
|
package/tests/testSVG.js
CHANGED
|
@@ -7,6 +7,7 @@ import 'svg-path-simplify/node';
|
|
|
7
7
|
import { svgPathSimplify } from 'svg-path-simplify';
|
|
8
8
|
|
|
9
9
|
|
|
10
|
+
|
|
10
11
|
let svgMarkup =
|
|
11
12
|
`<?xml version="1.0" encoding="utf-8"?>
|
|
12
13
|
<!-- Generator: Super Adobe Illustrator 33.0.0 Turbo, SVG Export Plug-In . SVG Version: 123.00 Build 0) -->
|