modern-path2d 1.4.2 → 1.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +27 -2
- package/dist/index.js +2 -2
- package/dist/index.mjs +27 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -3943,6 +3943,22 @@ class Path2D extends CompositeCurve {
|
|
|
3943
3943
|
...options?.style
|
|
3944
3944
|
}
|
|
3945
3945
|
};
|
|
3946
|
+
function signedArea(pts) {
|
|
3947
|
+
let sum = 0;
|
|
3948
|
+
const len = pts.length / 2;
|
|
3949
|
+
for (let i = 0; i < len; i++) {
|
|
3950
|
+
const xi = pts[2 * i];
|
|
3951
|
+
const yi = pts[2 * i + 1];
|
|
3952
|
+
const j = (i + 1) % len;
|
|
3953
|
+
const xj = pts[2 * j];
|
|
3954
|
+
const yj = pts[2 * j + 1];
|
|
3955
|
+
sum += (xj - xi) * (yj + yi);
|
|
3956
|
+
}
|
|
3957
|
+
return sum;
|
|
3958
|
+
}
|
|
3959
|
+
function isHoleFlat(pts) {
|
|
3960
|
+
return signedArea(pts) > 0;
|
|
3961
|
+
}
|
|
3946
3962
|
const indices = _options.indices ?? [];
|
|
3947
3963
|
const vertices = _options.vertices ?? [];
|
|
3948
3964
|
const fillRule = _options.style.fillRule ?? "nonzero";
|
|
@@ -3951,13 +3967,22 @@ class Path2D extends CompositeCurve {
|
|
|
3951
3967
|
const parentMap = /* @__PURE__ */ new Map();
|
|
3952
3968
|
const parentd = /* @__PURE__ */ new Set();
|
|
3953
3969
|
for (let i = 0; i < pointArrays.length; i++) {
|
|
3970
|
+
if (!isHoleFlat(pointArrays[i])) {
|
|
3971
|
+
continue;
|
|
3972
|
+
}
|
|
3954
3973
|
const parents = [];
|
|
3955
3974
|
for (let j = 0; j < pointArrays.length; j++) {
|
|
3956
|
-
if (i === j)
|
|
3975
|
+
if (i === j || isHoleFlat(pointArrays[j]))
|
|
3957
3976
|
continue;
|
|
3958
3977
|
let flag = false;
|
|
3959
3978
|
for (let k = 0; k < pointArrays[i].length; k += 2) {
|
|
3960
|
-
flag = flag || pointInPolygonNonZero(
|
|
3979
|
+
flag = flag || pointInPolygonNonZero(
|
|
3980
|
+
[pointArrays[i][k], pointArrays[i][k + 1]],
|
|
3981
|
+
pointArrays[j]
|
|
3982
|
+
);
|
|
3983
|
+
if (flag) {
|
|
3984
|
+
break;
|
|
3985
|
+
}
|
|
3961
3986
|
}
|
|
3962
3987
|
if (flag) {
|
|
3963
3988
|
parents.push(j);
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(A,tt){typeof exports=="object"&&typeof module<"u"?tt(exports):typeof define=="function"&&define.amd?define(["exports"],tt):(A=typeof globalThis<"u"?globalThis:A||self,tt(A.modernPath2d={}))})(this,function(A){"use strict";function tt(i,t,e,s={}){const{radius:r=1}=s;i.moveTo(t,e),i.arc(t,e,r,0,Math.PI*2)}const be={arcs:"bevel",bevel:"bevel",miter:"miter","miter-clip":"miter",round:"round"};function Ct(i,t){const{fill:e="#000",stroke:s="none",strokeWidth:r=s==="none"?0:1,strokeLinecap:o="round",strokeLinejoin:n="miter",strokeMiterlimit:h=0,strokeDasharray:a=[],strokeDashoffset:c=0,shadowOffsetX:l=0,shadowOffsetY:f=0,shadowBlur:y=0,shadowColor:x="rgba(0, 0, 0, 0)"}=t;i.fillStyle=e,i.strokeStyle=s,i.lineWidth=r,i.lineCap=o,i.lineJoin=be[n],i.miterLimit=h,i.setLineDash(a),i.lineDashOffset=c,i.shadowOffsetX=l,i.shadowOffsetY=f,i.shadowBlur=y,i.shadowColor=x}class m{constructor(t=0,e=0){this.x=t,this.y=e}static get MAX(){return new m(1/0,1/0)}static get MIN(){return new m(-1/0,-1/0)}get array(){return[this.x,this.y]}finite(){return this.x=Number.isFinite(this.x)?this.x:0,this.y=Number.isFinite(this.y)?this.y:0,this}set(t,e){return this.x=t,this.y=e,this}add(t){return this.x+=t.x,this.y+=t.y,this}sub(t){return this.x-=t.x,this.y-=t.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}divide(t){return this.x/=t.x,this.y/=t.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}rotate(t,e={x:0,y:0}){const s=-t/180*Math.PI,r=this.x-e.x,o=-(this.y-e.y),n=Math.sin(s),h=Math.cos(s);return this.set(e.x+(r*h-o*n),e.y-(r*n+o*h)),this}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,s=this.y-t.y;return e*e+s*s}lengthSquared(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.lengthSquared())}scale(t,e=t,s={x:0,y:0}){const r=t<0?s.x-this.x+s.x:this.x,o=e<0?s.y-this.y+s.y:this.y;return this.x=r*Math.abs(t),this.y=o*Math.abs(e),this}skew(t,e=0,s={x:0,y:0}){const r=this.x-s.x,o=this.y-s.y;return this.x=s.x+(r+Math.tan(t)*o),this.y=s.y+(o+Math.tan(e)*r),this}min(...t){return this.x=Math.min(this.x,...t.map(e=>e.x)),this.y=Math.min(this.y,...t.map(e=>e.y)),this}max(...t){return this.x=Math.max(this.x,...t.map(e=>e.x)),this.y=Math.max(this.y,...t.map(e=>e.y)),this}normalize(){return this.scale(1/(this.length()||1))}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this}divideVectors(t,e){return this.x=t.x/e.x,this.y=t.y/e.y,this}lerpVectors(t,e,s){return this.x=t.x+(e.x-t.x)*s,this.y=t.y+(e.y-t.y)*s,this}equals(t){return this.x===t.x&&this.y===t.y}applyMatrix3(t){const e=this.x,s=this.y,r=t.elements;return this.x=r[0]*e+r[3]*s+r[6],this.y=r[1]*e+r[4]*s+r[7],this}copy(t){return this.x=t.x,this.y=t.y,this}clone(){return new m(this.x,this.y)}}class U{constructor(t=0,e=0,s=0,r=0){this.left=t,this.top=e,this.width=s,this.height=r}get x(){return this.left}set x(t){this.left=t}get y(){return this.top}set y(t){this.top=t}get right(){return this.left+this.width}get bottom(){return this.top+this.height}get center(){return new m((this.left+this.right)/2,(this.top+this.bottom)/2)}get array(){return[this.left,this.top,this.width,this.height]}static from(...t){if(t.length===0)return new U;if(t.length===1)return t[0].clone();const e=t[0],s=t.slice(1).reduce((r,o)=>(r.left=Math.min(r.left,o.left),r.top=Math.min(r.top,o.top),r.right=Math.max(r.right,o.right),r.bottom=Math.max(r.bottom,o.bottom),r),{left:e?.left??0,top:e?.top??0,right:e?.right??0,bottom:e?.bottom??0});return new U(s.left,s.top,s.right-s.left,s.bottom-s.top)}translate(t,e){return this.left+=t,this.top+=e,this}copy(t){return this.left=t.left,this.top=t.top,this.width=t.width,this.height=t.height,this}clone(){return new U(this.left,this.top,this.width,this.height)}}class R{elements=[];constructor(t=1,e=0,s=0,r=0,o=1,n=0,h=0,a=0,c=1){this.set(t,e,s,r,o,n,h,a,c)}set(t,e,s,r,o,n,h,a,c){const l=this.elements;return l[0]=t,l[1]=r,l[2]=h,l[3]=e,l[4]=o,l[5]=a,l[6]=s,l[7]=n,l[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,s=t.elements;return e[0]=s[0],e[1]=s[1],e[2]=s[2],e[3]=s[3],e[4]=s[4],e[5]=s[5],e[6]=s[6],e[7]=s[7],e[8]=s[8],this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const s=t.elements,r=e.elements,o=this.elements,n=s[0],h=s[3],a=s[6],c=s[1],l=s[4],f=s[7],y=s[2],x=s[5],u=s[8],p=r[0],d=r[3],P=r[6],b=r[1],w=r[4],v=r[7],C=r[2],S=r[5],g=r[8];return o[0]=n*p+h*b+a*C,o[3]=n*d+h*w+a*S,o[6]=n*P+h*v+a*g,o[1]=c*p+l*b+f*C,o[4]=c*d+l*w+f*S,o[7]=c*P+l*v+f*g,o[2]=y*p+x*b+u*C,o[5]=y*d+x*w+u*S,o[8]=y*P+x*v+u*g,this}invert(){const t=this.elements,e=t[0],s=t[1],r=t[2],o=t[3],n=t[4],h=t[5],a=t[6],c=t[7],l=t[8],f=l*n-h*c,y=h*a-l*o,x=c*o-n*a,u=e*f+s*y+r*x;if(u===0)return this.set(0,0,0,0,0,0,0,0,0);const p=1/u;return t[0]=f*p,t[1]=(r*c-l*s)*p,t[2]=(h*s-r*n)*p,t[3]=y*p,t[4]=(l*e-r*a)*p,t[5]=(r*o-h*e)*p,t[6]=x*p,t[7]=(s*a-c*e)*p,t[8]=(n*e-s*o)*p,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}scale(t,e){return this.premultiply(bt.makeScale(t,e)),this}rotate(t){return this.premultiply(bt.makeRotation(-t)),this}translate(t,e){return this.premultiply(bt.makeTranslation(t,e)),this}makeTranslation(t,e){return this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),s=Math.sin(t);return this.set(e,-s,0,s,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}fromArray(t,e=0){for(let s=0;s<9;s++)this.elements[s]=t[s+e];return this}clone(){return new this.constructor().fromArray(this.elements)}}const bt=new R;function Rt(i,t,e,s){const r=i*e+t*s,o=Math.sqrt(i*i+t*t)*Math.sqrt(e*e+s*s);let n=Math.acos(Math.max(-1,Math.min(1,r/o)));return i*s-t*e<0&&(n=-n),n}function zt(i,t,e,s,r,o,n,h){if(t===0||e===0){i.lineTo(h.x,h.y);return}s=s*Math.PI/180,t=Math.abs(t),e=Math.abs(e);const a=(n.x-h.x)/2,c=(n.y-h.y)/2,l=Math.cos(s)*a+Math.sin(s)*c,f=-Math.sin(s)*a+Math.cos(s)*c;let y=t*t,x=e*e;const u=l*l,p=f*f,d=u/y+p/x;if(d>1){const L=Math.sqrt(d);t=L*t,e=L*e,y=t*t,x=e*e}const P=y*p+x*u,b=(y*x-P)/P;let w=Math.sqrt(Math.max(0,b));r===o&&(w=-w);const v=w*t*f/e,C=-w*e*l/t,S=Math.cos(s)*v-Math.sin(s)*C+(n.x+h.x)/2,g=Math.sin(s)*v+Math.cos(s)*C+(n.y+h.y)/2,M=Rt(1,0,(l-v)/t,(f-C)/e),q=Rt((l-v)/t,(f-C)/e,(-l-v)/t,(-f-C)/e)%(Math.PI*2);i.ellipse(S,g,t,e,s,M,M+q,o===0)}const V={WHITESPACE:/[ \t\r\n]/,DIGIT:/\d/,SIGN:/[-+]/,POINT:/\./,COMMA:/,/,EXP:/e/i,FLAGS:/[01]/};function z(i,t,e=0){let h=0,a=!0,c="",l="";const f=[];function y(d,P,b){const w=new SyntaxError(`Unexpected character "${d}" at index ${P}.`);throw w.partial=b,w}function x(){c!==""&&(l===""?f.push(Number(c)):f.push(Number(c)*10**Number(l))),c="",l=""}let u;const p=i.length;for(let d=0;d<p;d++){if(u=i[d],Array.isArray(t)&&t.includes(f.length%e)&&V.FLAGS.test(u)){h=1,c=u,x();continue}if(h===0){if(V.WHITESPACE.test(u))continue;if(V.DIGIT.test(u)||V.SIGN.test(u)){h=1,c=u;continue}if(V.POINT.test(u)){h=2,c=u;continue}V.COMMA.test(u)&&(a&&y(u,d,f),a=!0)}if(h===1){if(V.DIGIT.test(u)){c+=u;continue}if(V.POINT.test(u)){c+=u,h=2;continue}if(V.EXP.test(u)){h=3;continue}V.SIGN.test(u)&&c.length===1&&V.SIGN.test(c[0])&&y(u,d,f)}if(h===2){if(V.DIGIT.test(u)){c+=u;continue}if(V.EXP.test(u)){h=3;continue}V.POINT.test(u)&&c[c.length-1]==="."&&y(u,d,f)}if(h===3){if(V.DIGIT.test(u)){l+=u;continue}if(V.SIGN.test(u)){if(l===""){l+=u;continue}l.length===1&&V.SIGN.test(l)&&y(u,d,f)}}V.WHITESPACE.test(u)?(x(),h=0,a=!1):V.COMMA.test(u)?(x(),h=0,a=!0):V.SIGN.test(u)?(x(),h=1,c=u):V.POINT.test(u)?(x(),h=2,c=u):y(u,d,f)}return x(),f}function et(i,t){return i-(t-i)}function At(i,t){const e=new m,s=new m;for(let r=0,o=i.length;r<o;r++){const n=i[r];if(n.type==="m"||n.type==="M")n.type==="m"?e.add(n):e.copy(n),t.moveTo(e.x,e.y),s.copy(e);else if(n.type==="h"||n.type==="H")n.type==="h"?e.x+=n.x:e.x=n.x,t.lineTo(e.x,e.y),s.copy(e);else if(n.type==="v"||n.type==="V")n.type==="v"?e.y+=n.y:e.y=n.y,t.lineTo(e.x,e.y),s.copy(e);else if(n.type==="l"||n.type==="L")n.type==="l"?e.add(n):e.copy(n),t.lineTo(e.x,e.y),s.copy(e);else if(n.type==="c"||n.type==="C")n.type==="c"?(t.bezierCurveTo(e.x+n.x1,e.y+n.y1,e.x+n.x2,e.y+n.y2,e.x+n.x,e.y+n.y),s.x=e.x+n.x2,s.y=e.y+n.y2,e.add(n)):(t.bezierCurveTo(n.x1,n.y1,n.x2,n.y2,n.x,n.y),s.x=n.x2,s.y=n.y2,e.copy(n));else if(n.type==="s"||n.type==="S")n.type==="s"?(t.bezierCurveTo(et(e.x,s.x),et(e.y,s.y),e.x+n.x2,e.y+n.y2,e.x+n.x,e.y+n.y),s.x=e.x+n.x2,s.y=e.y+n.y2,e.add(n)):(t.bezierCurveTo(et(e.x,s.x),et(e.y,s.y),n.x2,n.y2,n.x,n.y),s.x=n.x2,s.y=n.y2,e.copy(n));else if(n.type==="q"||n.type==="Q")n.type==="q"?(t.quadraticCurveTo(e.x+n.x1,e.y+n.y1,e.x+n.x,e.y+n.y),s.x=e.x+n.x1,s.y=e.y+n.y1,e.add(n)):(t.quadraticCurveTo(n.x1,n.y1,n.x,n.y),s.x=n.x1,s.y=n.y1,e.copy(n));else if(n.type==="t"||n.type==="T"){const h=et(e.x,s.x),a=et(e.y,s.y);s.x=h,s.y=a,n.type==="t"?(t.quadraticCurveTo(h,a,e.x+n.x,e.y+n.y),e.add(n)):(t.quadraticCurveTo(h,a,n.x,n.y),e.copy(n))}else if(n.type==="a"||n.type==="A"){const h=e.clone();if(n.type==="a"){if(n.x===0&&n.y===0)continue;e.add(n)}else{if(e.equals(n))continue;e.copy(n)}s.copy(e),zt(t,n.rx,n.ry,n.angle,n.largeArcFlag,n.sweepFlag,h,e)}else n.type==="z"||n.type==="Z"?(t.startPoint&&e.copy(t.startPoint),t.closePath()):console.warn("Unsupported commands",n)}}function Bt(i){let t,e;const s=[];for(let r=0,o=i.length;r<o;r++){const n=i[r];switch(n.type){case"m":case"M":if(n.x.toFixed(4)===e?.x.toFixed(4)&&n.y.toFixed(4)===e?.y.toFixed(4))continue;s.push(`${n.type} ${n.x} ${n.y}`),e={x:n.x,y:n.y},t={x:n.x,y:n.y};break;case"h":case"H":s.push(`${n.type} ${n.x}`),e={x:n.x,y:e?.y??0};break;case"v":case"V":s.push(`${n.type} ${n.y}`),e={x:e?.x??0,y:n.y};break;case"l":case"L":s.push(`${n.type} ${n.x} ${n.y}`),e={x:n.x,y:n.y};break;case"c":case"C":s.push(`${n.type} ${n.x1} ${n.y1} ${n.x2} ${n.y2} ${n.x} ${n.y}`),e={x:n.x,y:n.y};break;case"s":case"S":s.push(`${n.type} ${n.x2} ${n.y2} ${n.x} ${n.y}`),e={x:n.x,y:n.y};break;case"q":case"Q":s.push(`${n.type} ${n.x1} ${n.y1} ${n.x} ${n.y}`),e={x:n.x,y:n.y};break;case"t":case"T":s.push(`${n.type} ${n.x} ${n.y}`),e={x:n.x,y:n.y};break;case"a":case"A":s.push(`${n.type} ${n.rx} ${n.ry} ${n.angle} ${n.largeArcFlag} ${n.sweepFlag} ${n.x} ${n.y}`),e={x:n.x,y:n.y};break;case"z":case"Z":s.push(n.type),t&&(e={x:t.x,y:t.y});break}}return s.join(" ")}const Ae=/[a-df-z][^a-df-z]*/gi;function kt(i){const t=[],e=i.match(Ae);if(!e)return t;for(let s=0,r=e.length;s<r;s++){const o=e[s],n=o.charAt(0),h=o.slice(1).trim();let a;switch(n){case"m":case"M":a=z(h);for(let c=0,l=a.length;c<l;c+=2)c===0?t.push({type:n,x:a[c],y:a[c+1]}):t.push({type:n==="m"?"l":"L",x:a[c],y:a[c+1]});break;case"h":case"H":a=z(h);for(let c=0,l=a.length;c<l;c++)t.push({type:n,x:a[c]});break;case"v":case"V":a=z(h);for(let c=0,l=a.length;c<l;c++)t.push({type:n,y:a[c]});break;case"l":case"L":a=z(h);for(let c=0,l=a.length;c<l;c+=2)t.push({type:n,x:a[c],y:a[c+1]});break;case"c":case"C":a=z(h);for(let c=0,l=a.length;c<l;c+=6)t.push({type:n,x1:a[c],y1:a[c+1],x2:a[c+2],y2:a[c+3],x:a[c+4],y:a[c+5]});break;case"s":case"S":a=z(h);for(let c=0,l=a.length;c<l;c+=4)t.push({type:n,x2:a[c],y2:a[c+1],x:a[c+2],y:a[c+3]});break;case"q":case"Q":a=z(h);for(let c=0,l=a.length;c<l;c+=4)t.push({type:n,x1:a[c],y1:a[c+1],x:a[c+2],y:a[c+3]});break;case"t":case"T":a=z(h);for(let c=0,l=a.length;c<l;c+=2)t.push({type:n,x:a[c],y:a[c+1]});break;case"a":case"A":a=z(h,[3,4],7);for(let c=0,l=a.length;c<l;c+=7)t.push({type:n,rx:a[c],ry:a[c+1],angle:a[c+2],largeArcFlag:a[c+3],sweepFlag:a[c+4],x:a[c+5],y:a[c+6]});break;case"z":case"Z":t.push({type:n});break;default:console.warn(o)}}return t}const jt="data:image/svg+xml;",Zt=`${jt}base64,`,Ut=`${jt}charset=utf8,`;function Xt(i){if(typeof i=="string"){let t;i.startsWith(Zt)?(i=i.substring(Zt.length,i.length),t=atob(i)):i.startsWith(Ut)?(i=i.substring(Ut.length,i.length),t=decodeURIComponent(i)):t=i;const e=new DOMParser().parseFromString(t,"text/xml"),s=e.querySelector("parsererror");if(s)throw new Error(`${s.textContent??"parser error"}
|
|
2
|
-
${t}`);return e.documentElement}else return i}const ke="px",Ie=90,Wt=["mm","cm","in","pt","pc","px"],Gt={mm:{mm:1,cm:.1,in:1/25.4,pt:72/25.4,pc:6/25.4,px:-1},cm:{mm:10,cm:1,in:1/2.54,pt:72/2.54,pc:6/2.54,px:-1},in:{mm:25.4,cm:2.54,in:1,pt:72,pc:6,px:-1},pt:{mm:25.4/72,cm:2.54/72,in:1/72,pt:1,pc:6/72,px:-1},pc:{mm:25.4/6,cm:2.54/6,in:1/6,pt:72/6,pc:1,px:-1},px:{px:1}};function _(i){let t="px";if(typeof i=="string")for(let s=0,r=Wt.length;s<r;s++){const o=Wt[s];if(i.endsWith(o)){t=o,i=i.substring(0,i.length-o.length);break}}let e;return e=Gt[t][ke],e<0&&(e=Gt[t].in*Ie),e*Number.parseFloat(i)}const Se=new R,xt=new R,Ht=new R,Qt=new R;function Ee(i,t,e){if(!(i.hasAttribute("transform")||i.nodeName==="use"&&(i.hasAttribute("x")||i.hasAttribute("y"))))return null;const s=_e(i);return e.length>0&&s.premultiply(e[e.length-1]),t.copy(s),e.push(s),s}function _e(i){const t=new R,e=Se;if(i.nodeName==="use"&&(i.hasAttribute("x")||i.hasAttribute("y"))&&t.translate(_(i.getAttribute("x")),_(i.getAttribute("y"))),i.hasAttribute("transform")){const s=i.getAttribute("transform").split(")");for(let r=s.length-1;r>=0;r--){const o=s[r].trim();if(o==="")continue;const n=o.indexOf("("),h=o.length;if(n>0&&n<h){const a=o.slice(0,n),c=z(o.slice(n+1));switch(e.identity(),a){case"translate":if(c.length>=1){const l=c[0];let f=0;c.length>=2&&(f=c[1]),e.translate(l,f)}break;case"rotate":if(c.length>=1){let l=0,f=0,y=0;l=c[0]*Math.PI/180,c.length>=3&&(f=c[1],y=c[2]),xt.makeTranslation(-f,-y),Ht.makeRotation(l),Qt.multiplyMatrices(Ht,xt),xt.makeTranslation(f,y),e.multiplyMatrices(xt,Qt)}break;case"scale":c.length>=1&&e.scale(c[0],c[1]??c[0]);break;case"skewX":c.length===1&&e.set(1,Math.tan(c[0]*Math.PI/180),0,0,1,0,0,0,1);break;case"skewY":c.length===1&&e.set(1,0,0,Math.tan(c[0]*Math.PI/180),1,0,0,0,1);break;case"matrix":c.length===6&&e.set(c[0],c[2],c[4],c[1],c[3],c[5],0,0,1);break}}t.premultiply(e)}}return t}function $e(i){return new j().arc(_(i.getAttribute("cx")||0),_(i.getAttribute("cy")||0),_(i.getAttribute("r")||0),0,Math.PI*2)}function Le(i,t){if(!(!i.sheet||!i.sheet.cssRules||!i.sheet.cssRules.length))for(let e=0;e<i.sheet.cssRules.length;e++){const s=i.sheet.cssRules[e];if(s.type!==1)continue;const r=s.selectorText.split(/,/g).filter(Boolean).map(n=>n.trim()),o={};for(let n=s.style.length,h=0;h<n;h++){const a=s.style.item(h);o[a]=s.style.getPropertyValue(a)}for(let n=0;n<r.length;n++)t[r[n]]=Object.assign(t[r[n]]||{},{...o})}}function Fe(i){return new j().ellipse(_(i.getAttribute("cx")||0),_(i.getAttribute("cy")||0),_(i.getAttribute("rx")||0),_(i.getAttribute("ry")||0),0,0,Math.PI*2)}function Ne(i){return new j().moveTo(_(i.getAttribute("x1")||0),_(i.getAttribute("y1")||0)).lineTo(_(i.getAttribute("x2")||0),_(i.getAttribute("y2")||0))}function De(i){const t=new j,e=i.getAttribute("d");return!e||e==="none"?null:(t.addData(e),t)}const Ve=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function qe(i){const t=new j;let e=0;return i.getAttribute("points")?.replace(Ve,(s,r,o)=>{const n=_(r),h=_(o);return e===0?t.moveTo(n,h):t.lineTo(n,h),e++,s}),t.currentCurve.autoClose=!0,t}const Oe=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function Re(i){const t=new j;let e=0;return i.getAttribute("points")?.replace(Oe,(s,r,o)=>{const n=_(r),h=_(o);return e===0?t.moveTo(n,h):t.lineTo(n,h),e++,s}),t.currentCurve.autoClose=!1,t}function ze(i){const t=_(i.getAttribute("x")||0),e=_(i.getAttribute("y")||0),s=_(i.getAttribute("rx")||i.getAttribute("ry")||0),r=_(i.getAttribute("ry")||i.getAttribute("rx")||0),o=_(i.getAttribute("width")),n=_(i.getAttribute("height")),h=1-.551915024494,a=new j;return a.moveTo(t+s,e),a.lineTo(t+o-s,e),(s!==0||r!==0)&&a.bezierCurveTo(t+o-s*h,e,t+o,e+r*h,t+o,e+r),a.lineTo(t+o,e+n-r),(s!==0||r!==0)&&a.bezierCurveTo(t+o,e+n-r*h,t+o-s*h,e+n,t+o-s,e+n),a.lineTo(t+s,e+n),(s!==0||r!==0)&&a.bezierCurveTo(t+s*h,e+n,t,e+n-r*h,t,e+n-r),a.lineTo(t,e+r),(s!==0||r!==0)&&a.bezierCurveTo(t,e+r*h,t+s*h,e,t+s,e),a}function Z(i,t,e){t=Object.assign({},t);let s={};if(i.hasAttribute("class")){const c=i.getAttribute("class").split(/\s/).filter(Boolean).map(l=>l.trim());for(let l=0;l<c.length;l++)s=Object.assign(s,e[`.${c[l]}`])}i.hasAttribute("id")&&(s=Object.assign(s,e[`#${i.getAttribute("id")}`]));for(let c=i.style.length,l=0;l<c;l++){const f=i.style.item(l),y=i.style.getPropertyValue(f);t[f]=y,s[f]=y}function r(c,l,f=o){i.hasAttribute(c)&&(t[l]=f(i.getAttribute(c))),s[c]&&(t[l]=f(s[c]))}function o(c){return c.startsWith("url")&&console.warn("url access in attributes is not implemented."),c}function n(c){return Math.max(0,Math.min(1,_(c)))}function h(c){return Math.max(0,_(c))}function a(c){return c.split(" ").filter(l=>l!=="").map(l=>_(l))}return r("fill","fill"),r("fill-opacity","fillOpacity",n),r("fill-rule","fillRule"),r("opacity","opacity",n),r("stroke","stroke"),r("stroke-opacity","strokeOpacity",n),r("stroke-width","strokeWidth",h),r("stroke-linecap","strokeLinecap"),r("stroke-linejoin","strokeLinejoin"),r("stroke-miterlimit","strokeMiterlimit",h),r("stroke-dasharray","strokeDasharray",a),r("stroke-dashoffset","strokeDashoffset",_),r("visibility","visibility"),t}function It(i,t,e=[],s={}){if(i.nodeType!==1)return e;let r=!1,o=null,n={...t};switch(i.nodeName){case"svg":n=Z(i,n,s);break;case"style":Le(i,s);break;case"g":n=Z(i,n,s);break;case"path":n=Z(i,n,s),i.hasAttribute("d")&&(o=De(i));break;case"rect":n=Z(i,n,s),o=ze(i);break;case"polygon":n=Z(i,n,s),o=qe(i);break;case"polyline":n=Z(i,n,s),o=Re(i);break;case"circle":n=Z(i,n,s),o=$e(i);break;case"ellipse":n=Z(i,n,s),o=Fe(i);break;case"line":n=Z(i,n,s),o=Ne(i);break;case"defs":r=!0;break;case"use":{n=Z(i,n,s);const y=(i.getAttributeNS("http://www.w3.org/1999/xlink","href")||i.getAttribute("href")||"").substring(1),x=i.viewportElement?.getElementById(y);x?It(x,n,e,s):console.warn(`'use node' references non-existent node id: ${y}`);break}default:console.warn(i);break}if(n.display==="none")return e;const h=new R,a=[],c=Ee(i,h,a);o&&(o.applyTransform(h),e.push(o),o.style={...n});const l=i.childNodes;for(let f=0,y=l.length;f<y;f++){const x=l[f];r&&x.nodeName!=="style"&&x.nodeName!=="defs"||It(x,n,e,s)}return c&&(a.pop(),a.length>0?h.copy(a[a.length-1]):h.identity()),e}function Be(i){const t=Xt(i);return new Me(It(t,{}),t.getAttribute("viewBox")?.trim().split(" ").map(e=>Number(e)))}function St(i,t,e,s,r){const o=(s-t)*.5,n=(r-e)*.5,h=i*i,a=i*h;return(2*e-2*s+o+n)*a+(-3*e+3*s-2*o-n)*h+o*i+e}function je(i,t){const e=1-i;return e*e*e*t}function Ze(i,t){const e=1-i;return 3*e*e*i*t}function Ue(i,t){return 3*(1-i)*i*i*t}function Xe(i,t){return i*i*i*t}function Et(i,t,e,s,r){return je(i,t)+Ze(i,e)+Ue(i,s)+Xe(i,r)}function We(i,t,e=2){const s=t&&t.length,r=s?t[0]*e:i.length;let o=Yt(i,0,r,e,!0);const n=[];if(!o||o.next===o.prev)return n;let h,a,c;if(s&&(o=Je(i,t,o,e)),i.length>80*e){h=1/0,a=1/0;let l=-1/0,f=-1/0;for(let y=e;y<r;y+=e){const x=i[y],u=i[y+1];x<h&&(h=x),u<a&&(a=u),x>l&&(l=x),u>f&&(f=u)}c=Math.max(l-h,f-a),c=c!==0?32767/c:0}return it(o,n,e,h,a,c,0),n}function Yt(i,t,e,s,r){let o;if(r===as(i,t,e,s)>0)for(let n=t;n<e;n+=s)o=ee(n/s|0,i[n],i[n+1],o);else for(let n=e-s;n>=t;n-=s)o=ee(n/s|0,i[n],i[n+1],o);return o&&st(o,o.next)&&(ct(o),o=o.next),o}function W(i,t){if(!i)return i;t||(t=i);let e=i,s;do if(s=!1,!e.steiner&&(st(e,e.next)||F(e.prev,e,e.next)===0)){if(ct(e),e=t=e.prev,e===e.next)break;s=!0}else e=e.next;while(s||e!==t);return t}function it(i,t,e,s,r,o,n){if(!i)return;!n&&o&&ns(i,s,r,o);let h=i;for(;i.prev!==i.next;){const a=i.prev,c=i.next;if(o?He(i,s,r,o):Ge(i)){t.push(a.i,i.i,c.i),ct(i),i=c.next,h=c.next;continue}if(i=c,i===h){n?n===1?(i=Qe(W(i),t),it(i,t,e,s,r,o,2)):n===2&&Ye(i,t,e,s,r,o):it(W(i),t,e,s,r,o,1);break}}}function Ge(i){const t=i.prev,e=i,s=i.next;if(F(t,e,s)>=0)return!1;const r=t.x,o=e.x,n=s.x,h=t.y,a=e.y,c=s.y,l=Math.min(r,o,n),f=Math.min(h,a,c),y=Math.max(r,o,n),x=Math.max(h,a,c);let u=s.next;for(;u!==t;){if(u.x>=l&&u.x<=y&&u.y>=f&&u.y<=x&&rt(r,h,o,a,n,c,u.x,u.y)&&F(u.prev,u,u.next)>=0)return!1;u=u.next}return!0}function He(i,t,e,s){const r=i.prev,o=i,n=i.next;if(F(r,o,n)>=0)return!1;const h=r.x,a=o.x,c=n.x,l=r.y,f=o.y,y=n.y,x=Math.min(h,a,c),u=Math.min(l,f,y),p=Math.max(h,a,c),d=Math.max(l,f,y),P=_t(x,u,t,e,s),b=_t(p,d,t,e,s);let w=i.prevZ,v=i.nextZ;for(;w&&w.z>=P&&v&&v.z<=b;){if(w.x>=x&&w.x<=p&&w.y>=u&&w.y<=d&&w!==r&&w!==n&&rt(h,l,a,f,c,y,w.x,w.y)&&F(w.prev,w,w.next)>=0||(w=w.prevZ,v.x>=x&&v.x<=p&&v.y>=u&&v.y<=d&&v!==r&&v!==n&&rt(h,l,a,f,c,y,v.x,v.y)&&F(v.prev,v,v.next)>=0))return!1;v=v.nextZ}for(;w&&w.z>=P;){if(w.x>=x&&w.x<=p&&w.y>=u&&w.y<=d&&w!==r&&w!==n&&rt(h,l,a,f,c,y,w.x,w.y)&&F(w.prev,w,w.next)>=0)return!1;w=w.prevZ}for(;v&&v.z<=b;){if(v.x>=x&&v.x<=p&&v.y>=u&&v.y<=d&&v!==r&&v!==n&&rt(h,l,a,f,c,y,v.x,v.y)&&F(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function Qe(i,t){let e=i;do{const s=e.prev,r=e.next.next;!st(s,r)&&Kt(s,e,e.next,r)&&ot(s,r)&&ot(r,s)&&(t.push(s.i,e.i,r.i),ct(e),ct(e.next),e=i=r),e=e.next}while(e!==i);return W(e)}function Ye(i,t,e,s,r,o){let n=i;do{let h=n.next.next;for(;h!==n.prev;){if(n.i!==h.i&&os(n,h)){let a=te(n,h);n=W(n,n.next),a=W(a,a.next),it(n,t,e,s,r,o,0),it(a,t,e,s,r,o,0);return}h=h.next}n=n.next}while(n!==i)}function Je(i,t,e,s){const r=[];for(let o=0,n=t.length;o<n;o++){const h=t[o]*s,a=o<n-1?t[o+1]*s:i.length,c=Yt(i,h,a,s,!1);c===c.next&&(c.steiner=!0),r.push(rs(c))}r.sort(Ke);for(let o=0;o<r.length;o++)e=ts(r[o],e);return e}function Ke(i,t){let e=i.x-t.x;if(e===0&&(e=i.y-t.y,e===0)){const s=(i.next.y-i.y)/(i.next.x-i.x),r=(t.next.y-t.y)/(t.next.x-t.x);e=s-r}return e}function ts(i,t){const e=es(i,t);if(!e)return t;const s=te(e,i);return W(s,s.next),W(e,e.next)}function es(i,t){let e=t;const s=i.x,r=i.y;let o=-1/0,n;if(st(i,e))return e;do{if(st(i,e.next))return e.next;if(r<=e.y&&r>=e.next.y&&e.next.y!==e.y){const f=e.x+(r-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(f<=s&&f>o&&(o=f,n=e.x<e.next.x?e:e.next,f===s))return n}e=e.next}while(e!==t);if(!n)return null;const h=n,a=n.x,c=n.y;let l=1/0;e=n;do{if(s>=e.x&&e.x>=a&&s!==e.x&&Jt(r<c?s:o,r,a,c,r<c?o:s,r,e.x,e.y)){const f=Math.abs(r-e.y)/(s-e.x);ot(e,i)&&(f<l||f===l&&(e.x>n.x||e.x===n.x&&ss(n,e)))&&(n=e,l=f)}e=e.next}while(e!==h);return n}function ss(i,t){return F(i.prev,i,t.prev)<0&&F(t.next,i,i.next)<0}function ns(i,t,e,s){let r=i;do r.z===0&&(r.z=_t(r.x,r.y,t,e,s)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==i);r.prevZ.nextZ=null,r.prevZ=null,is(r)}function is(i){let t,e=1;do{let s=i,r;i=null;let o=null;for(t=0;s;){t++;let n=s,h=0;for(let c=0;c<e&&(h++,n=n.nextZ,!!n);c++);let a=e;for(;h>0||a>0&&n;)h!==0&&(a===0||!n||s.z<=n.z)?(r=s,s=s.nextZ,h--):(r=n,n=n.nextZ,a--),o?o.nextZ=r:i=r,r.prevZ=o,o=r;s=n}o.nextZ=null,e*=2}while(t>1);return i}function _t(i,t,e,s,r){return i=(i-e)*r|0,t=(t-s)*r|0,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,i|t<<1}function rs(i){let t=i,e=i;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==i);return e}function Jt(i,t,e,s,r,o,n,h){return(r-n)*(t-h)>=(i-n)*(o-h)&&(i-n)*(s-h)>=(e-n)*(t-h)&&(e-n)*(o-h)>=(r-n)*(s-h)}function rt(i,t,e,s,r,o,n,h){return!(i===n&&t===h)&&Jt(i,t,e,s,r,o,n,h)}function os(i,t){return i.next.i!==t.i&&i.prev.i!==t.i&&!cs(i,t)&&(ot(i,t)&&ot(t,i)&&hs(i,t)&&(F(i.prev,i,t.prev)||F(i,t.prev,t))||st(i,t)&&F(i.prev,i,i.next)>0&&F(t.prev,t,t.next)>0)}function F(i,t,e){return(t.y-i.y)*(e.x-t.x)-(t.x-i.x)*(e.y-t.y)}function st(i,t){return i.x===t.x&&i.y===t.y}function Kt(i,t,e,s){const r=gt(F(i,t,e)),o=gt(F(i,t,s)),n=gt(F(e,s,i)),h=gt(F(e,s,t));return!!(r!==o&&n!==h||r===0&&pt(i,e,t)||o===0&&pt(i,s,t)||n===0&&pt(e,i,s)||h===0&&pt(e,t,s))}function pt(i,t,e){return t.x<=Math.max(i.x,e.x)&&t.x>=Math.min(i.x,e.x)&&t.y<=Math.max(i.y,e.y)&&t.y>=Math.min(i.y,e.y)}function gt(i){return i>0?1:i<0?-1:0}function cs(i,t){let e=i;do{if(e.i!==i.i&&e.next.i!==i.i&&e.i!==t.i&&e.next.i!==t.i&&Kt(e,e.next,i,t))return!0;e=e.next}while(e!==i);return!1}function ot(i,t){return F(i.prev,i,i.next)<0?F(i,t,i.next)>=0&&F(i,i.prev,t)>=0:F(i,t,i.prev)<0||F(i,i.next,t)<0}function hs(i,t){let e=i,s=!1;const r=(i.x+t.x)/2,o=(i.y+t.y)/2;do e.y>o!=e.next.y>o&&e.next.y!==e.y&&r<(e.next.x-e.x)*(o-e.y)/(e.next.y-e.y)+e.x&&(s=!s),e=e.next;while(e!==i);return s}function te(i,t){const e=$t(i.i,i.x,i.y),s=$t(t.i,t.x,t.y),r=i.next,o=t.prev;return i.next=t,t.prev=i,e.next=r,r.prev=e,s.next=e,e.prev=s,o.next=s,s.prev=o,s}function ee(i,t,e,s){const r=$t(i,t,e);return s?(r.next=s.next,r.prev=s,s.next.prev=r,s.next=r):(r.prev=r,r.next=r),r}function ct(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function $t(i,t,e){return{i,x:t,y:e,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function as(i,t,e,s){let r=0;for(let o=t,n=e-s;o<e;o+=s)r+=(i[n]-i[o])*(i[o+1]+i[n+1]),n=o;return r}function Lt(i,t={}){let{vertices:e=[],indices:s=[],holes:r=[],verticesStride:o=2,verticesOffset:n=e.length/o,indicesOffset:h=s.length}=t;const a=We(i,r,2);if(a.length){for(let l=0;l<a.length;l+=3)s[h++]=a[l]+n,s[h++]=a[l+1]+n,s[h++]=a[l+2]+n;let c=n*o;for(let l=0;l<i.length;l+=2)e[c]=i[l],e[c+1]=i[l+1],c+=o}return{vertices:e,indices:s}}const ls=8,dt=11920929e-14,us=1;function se(i,t,e,s,r,o,n,h,a=.5,c=[]){const f=Math.min(.99,Math.max(0,a));let y=(us-f)/1;return y*=y,Ft(i,t,e,s,r,o,n,h,c,y,0),c.push(n,h),c}function Ft(i,t,e,s,r,o,n,h,a,c,l){if(l>ls)return;const f=(i+e)/2,y=(t+s)/2,x=(e+r)/2,u=(s+o)/2,p=(r+n)/2,d=(o+h)/2,P=(f+x)/2,b=(y+u)/2,w=(x+p)/2,v=(u+d)/2,C=(P+w)/2,S=(b+v)/2;if(l>0){let g=n-i,M=h-t;const q=Math.abs((e-n)*M-(s-h)*g),L=Math.abs((r-n)*M-(o-h)*g);if(q>dt&&L>dt){if((q+L)*(q+L)<=c*(g*g+M*M)){a.push(C,S);return}}else if(q>dt){if(q*q<=c*(g*g+M*M)){a.push(C,S);return}}else if(L>dt){if(L*L<=c*(g*g+M*M)){a.push(C,S);return}}else if(g=C-(i+n)/2,M=S-(t+h)/2,g*g+M*M<=c){a.push(C,S);return}}Ft(i,t,f,y,P,b,C,S,a,c,l+1),Ft(C,S,w,v,p,d,n,h,a,c,l+1)}const fs=8,ys=11920929e-14,xs=1;function ne(i,t,e,s,r,o,n=.5,h=[]){const c=Math.min(.99,Math.max(0,n));let l=(xs-c)/1;return l*=l,Nt(h,i,t,e,s,r,o,l,0),h.push(r,o),h}function Nt(i,t,e,s,r,o,n,h,a){if(a>fs)return;const c=(t+s)/2,l=(e+r)/2,f=(s+o)/2,y=(r+n)/2,x=(c+f)/2,u=(l+y)/2;let p=o-t,d=n-e;const P=Math.abs((s-o)*d-(r-n)*p);if(P>ys){if(P*P<=h*(p*p+d*d)){i.push(x,u);return}}else if(p=x-(t+o)/2,d=u-(e+n)/2,p*p+d*d<=h){i.push(x,u);return}Nt(i,t,e,c,l,x,u,h,a+1),Nt(i,x,u,f,y,o,n,h,a+1)}function ps(i){let t=0;const e=i.length;for(let s=0;s<e;s+=2){const r=i[s],o=i[s+1],n=i[(s+2)%(e-1)],h=i[(s+3)%e];t+=r*h-n*o}return t/2}function gs(i,t){let e=!1;const[s,r]=i,o=t.length/2;for(let n=0,h=o-1;n<o;h=n++){const a=t[n*2],c=t[n*2+1],l=t[h*2],f=t[h*2+1];c>r!=f>r&&s<(l-a)*(r-c)/(f-c)+a&&(e=!e)}return e}function ie(i,t){const[e,s]=i,r=t.length/2;let o=0;for(let n=0,h=r-1;n<r;h=n++){const a=t[n*2],c=t[n*2+1],l=t[h*2],f=t[h*2+1];c<=s?f>s&&re([l,f],[a,c],[e,s])>0&&o++:f<=s&&re([l,f],[a,c],[e,s])<0&&o--}return o!==0}function re(i,t,e){return(t[0]-i[0])*(e[1]-i[1])-(e[0]-i[0])*(t[1]-i[1])}function ds(i,t){const e=1-i;return e*e*t}function ms(i,t){return 2*(1-i)*i*t}function Ms(i,t){return i*i*t}function Dt(i,t,e,s){return ds(i,t)+ms(i,e)+Ms(i,s)}const ws=1e-4,oe=1e-4;function ce(i,t={}){const{vertices:e=[],indices:s=[],lineStyle:r={alignment:.5,cap:"butt",join:"miter",width:1,miterLimit:10},flipAlignment:o=!1,closed:n=!0}=t,h=ws;if(i.length===0)return{vertices:e,indices:s};const a=r;let c=a.alignment;if(r.alignment!==.5){let $=vs(i);o&&($*=-1),c=(c-.5)*$+.5}const l={x:i[0],y:i[1]},f={x:i[i.length-2],y:i[i.length-1]},y=n,x=Math.abs(l.x-f.x)<h&&Math.abs(l.y-f.y)<h;if(y){i=i.slice(),x&&(i.pop(),i.pop(),f.x=i[i.length-2],f.y=i[i.length-1]);const $=(l.x+f.x)*.5,X=(f.y+l.y)*.5;i.unshift($,X),i.push($,X)}const u=e,p=i.length/2;let d=i.length;const P=u.length/2,b=a.width/2,w=b*b,v=a.miterLimit*a.miterLimit;let C=i[0],S=i[1],g=i[2],M=i[3],q=0,L=0,k=-(S-M),I=C-g,N=0,D=0,O=Math.sqrt(k*k+I*I);k/=O,I/=O,k*=b,I*=b;const at=c,T=(1-at)*2,E=at*2;y||(a.cap==="round"?d+=G(C-k*(T-E)*.5,S-I*(T-E)*.5,C-k*T,S-I*T,C+k*E,S+I*E,u,!0)+2:a.cap==="square"&&(d+=he(C,S,k,I,T,E,!0,u))),u.push(C-k*T,S-I*T),u.push(C+k*E,S+I*E);for(let $=1;$<p-1;++$){C=i[($-1)*2],S=i[($-1)*2+1],g=i[$*2],M=i[$*2+1],q=i[($+1)*2],L=i[($+1)*2+1],k=-(S-M),I=C-g,O=Math.sqrt(k*k+I*I),k/=O,I/=O,k*=b,I*=b,N=-(M-L),D=g-q,O=Math.sqrt(N*N+D*D),N/=O,D/=O,N*=b,D*=b;const X=g-C,lt=S-M,ut=g-q,ft=L-M,ve=X*ut+lt*ft,vt=lt*ut-ft*X,yt=vt<0;if(Math.abs(vt)<.001*Math.abs(ve)){u.push(g-k*T,M-I*T),u.push(g+k*E,M+I*E),ve>=0&&(a.join==="round"?d+=G(g,M,g-k*T,M-I*T,g-N*T,M-D*T,u,!1)+4:d+=2,u.push(g-N*E,M-D*E),u.push(g+N*T,M+D*T));continue}const Pe=(-k+C)*(-I+M)-(-k+g)*(-I+S),Te=(-N+q)*(-D+M)-(-N+g)*(-D+L),Pt=(X*Te-ut*Pe)/vt,Tt=(ft*Pe-lt*Te)/vt,Ot=(Pt-g)*(Pt-g)+(Tt-M)*(Tt-M),Q=g+(Pt-g)*T,Y=M+(Tt-M)*T,J=g-(Pt-g)*E,K=M-(Tt-M)*E,Ls=Math.min(X*X+lt*lt,ut*ut+ft*ft),Ce=yt?T:E,Fs=Ls+Ce*Ce*w;Ot<=Fs?a.join==="bevel"||Ot/w>v?(yt?(u.push(Q,Y),u.push(g+k*E,M+I*E),u.push(Q,Y),u.push(g+N*E,M+D*E)):(u.push(g-k*T,M-I*T),u.push(J,K),u.push(g-N*T,M-D*T),u.push(J,K)),d+=2):a.join==="round"?yt?(u.push(Q,Y),u.push(g+k*E,M+I*E),d+=G(g,M,g+k*E,M+I*E,g+N*E,M+D*E,u,!0)+4,u.push(Q,Y),u.push(g+N*E,M+D*E)):(u.push(g-k*T,M-I*T),u.push(J,K),d+=G(g,M,g-k*T,M-I*T,g-N*T,M-D*T,u,!1)+4,u.push(g-N*T,M-D*T),u.push(J,K)):(u.push(Q,Y),u.push(J,K)):(u.push(g-k*T,M-I*T),u.push(g+k*E,M+I*E),a.join==="round"?yt?d+=G(g,M,g+k*E,M+I*E,g+N*E,M+D*E,u,!0)+2:d+=G(g,M,g-k*T,M-I*T,g-N*T,M-D*T,u,!1)+2:a.join==="miter"&&Ot/w<=v&&(yt?(u.push(J,K),u.push(J,K)):(u.push(Q,Y),u.push(Q,Y)),d+=2),u.push(g-N*T,M-D*T),u.push(g+N*E,M+D*E),d+=2)}C=i[(p-2)*2],S=i[(p-2)*2+1],g=i[(p-1)*2],M=i[(p-1)*2+1],k=-(S-M),I=C-g,O=Math.sqrt(k*k+I*I),k/=O,I/=O,k*=b,I*=b,u.push(g-k*T,M-I*T),u.push(g+k*E,M+I*E),y||(a.cap==="round"?d+=G(g-k*(T-E)*.5,M-I*(T-E)*.5,g-k*T,M-I*T,g+k*E,M+I*E,u,!1)+2:a.cap==="square"&&(d+=he(g,M,k,I,T,E,!1,u)));const $s=oe*oe;for(let $=P;$<d+P-2;++$)C=u[$*2],S=u[$*2+1],g=u[($+1)*2],M=u[($+1)*2+1],q=u[($+2)*2],L=u[($+2)*2+1],!(Math.abs(C*(M-L)+g*(L-S)+q*(S-M))<$s)&&s.push($,$+1,$+2);return{vertices:e,indices:s}}function vs(i){const t=i.length;if(t<6)return 1;let e=0;for(let s=0,r=i[t-2],o=i[t-1];s<t;s+=2){const n=i[s],h=i[s+1];e+=(n-r)*(h+o),r=n,o=h}return e<0?-1:1}function he(i,t,e,s,r,o,n,h){const a=i-e*r,c=t-s*r,l=i+e*o,f=t+s*o;let y,x;n?(y=s,x=-e):(y=-s,x=e);const u=a+y,p=c+x,d=l+y,P=f+x;return h.push(u,p),h.push(d,P),2}function G(i,t,e,s,r,o,n,h){const a=e-i,c=s-t;let l=Math.atan2(a,c),f=Math.atan2(r-i,o-t);h&&l<f?l+=Math.PI*2:!h&&l>f&&(f+=Math.PI*2);let y=l;const x=f-l,u=Math.abs(x),p=Math.sqrt(a*a+c*c),d=(15*u*Math.sqrt(p)/Math.PI>>0)+1,P=x/d;if(y+=P,h){n.push(i,t),n.push(e,s);for(let b=1,w=y;b<d;b++,w+=P)n.push(i,t),n.push(i+Math.sin(w)*p,t+Math.cos(w)*p);n.push(i,t),n.push(r,o)}else{n.push(e,s),n.push(i,t);for(let b=1,w=y;b<d;b++,w+=P)n.push(i+Math.sin(w)*p,t+Math.cos(w)*p),n.push(i,t);n.push(r,o),n.push(i,t)}return d*2}class H{arcLengthDivision=200;_arcLengths;getPointAt(t,e=new m){return this.getPoint(this.getUToTMapping(t),e)}isClockwise(){return!1}getControlPointRefs(){return[]}applyTransform(t){const e=typeof t=="function";return this.getControlPointRefs().forEach(s=>{e?t(s):s.applyMatrix3(t)}),this}getUnevenVertices(t=5,e=[]){const s=new m;for(let r=0,o=Math.max(1,t)-1;r<=o;r++)this.getPoint(r/o,s),e.push(s.x,s.y);return e}getSpacedVertices(t=5,e=[]){const s=new m;for(let r=0,o=Math.max(1,t)-1;r<=o;r++)this.getPointAt(r/o,s),e.push(s.x,s.y);return e}getAdaptiveVertices(t=[]){return this.getUnevenVertices(5,t)}_verticesToPoints(t,e=[]){for(let s=0,r=t.length;s<r;s+=2){const o=t[s],n=t[s+1];e.push(new m(o,n))}return e}getSpacedPoints(t,e=[]){const s=this.getSpacedVertices(t);return this._verticesToPoints(s,e),e}getUnevenPoints(t,e=[]){const s=this.getUnevenVertices(t);return this._verticesToPoints(s,e),e}getAdaptivePoints(t=[]){const e=this.getAdaptiveVertices();return this._verticesToPoints(e,t),t}getPoints(t,e=[]){let s;return t?s=this.getUnevenVertices(t):s=this.getAdaptiveVertices(),this._verticesToPoints(s,e),e}getLength(){const t=this.getLengths();return t[t.length-1]}getLengths(){return(!this._arcLengths||this._arcLengths.length!==this.arcLengthDivision+1)&&this.updateLengths(),this._arcLengths}updateLengths(){const t=this.arcLengthDivision,e=[0];for(let s=0,r=this.getPoint(0),o=1;o<=t;o++){const n=this.getPoint(o/t);s+=n.distanceTo(r),e.push(s),r=n}this._arcLengths=e}getUToTMapping(t,e){const s=this.getLengths(),r=s.length,o=e??t*s[r-1];if(r<2)return o/s[0];let n=0,h=0,a=r-1,c;for(;h<=a;)if(n=Math.floor(h+(a-h)/2),c=s[n]-o,c<0)h=n+1;else if(c>0)a=n-1;else{a=n;break}if(n=a,s[n]===o)return n/(r-1);const l=s[n],y=s[n+1]-l,x=(o-l)/y;return(n+x)/(r-1)}getTangent(t,e=new m){const r=Math.max(0,t-1e-4),o=Math.min(1,t+1e-4);return e.copy(this.getPoint(o).sub(this.getPoint(r)).normalize())}getTangentAt(t,e){return this.getTangent(this.getUToTMapping(t),e)}getNormal(t,e=new m){return this.getTangent(t,e),e.set(-e.y,e.x).normalize()}getNormalAt(t,e){return this.getNormal(this.getUToTMapping(t),e)}getTForPoint(t,e=.001){let s=0,r=1,o=(s+r)/2;for(;r-s>e;){o=(s+r)/2;const n=this.getPoint(o);if(n.distanceTo(t)<e)return o;n.x<t.x?s=o:r=o}return o}getMinMax(t=m.MAX,e=m.MIN){const s=this.getPoints();for(let r=0,o=s.length;r<o;r++){const n=s[r];t.min(n),e.max(n)}return{min:t.finite(),max:e.finite()}}getBoundingBox(){const{min:t,max:e}=this.getMinMax();return new U(t.x,t.y,e.x-t.x,e.y-t.y)}getFillVertices(t){return this.getAdaptiveVertices()}fillTriangulate(t){return Lt(this.getFillVertices(t),t)}strokeTriangulate(t){return ce(this.getAdaptiveVertices(),t)}toCommands(){const t=[],e=this.getPoints();for(let s=0,r=e.length;s<r;s++){const o=e[s];s===0?t.push({type:"M",x:o.x,y:o.y}):t.push({type:"L",x:o.x,y:o.y})}return t}toData(){return Bt(this.toCommands())}drawTo(t){return this.toCommands().forEach(e=>{switch(e.type){case"M":t.moveTo(e.x,e.y);break;case"L":t.lineTo(e.x,e.y);break}}),this}copy(t){return this.arcLengthDivision=t.arcLengthDivision,this}clone(){return new this.constructor().copy(this)}}const Ps=new R,ae=new R,le=new R,mt=new m;class Vt extends H{constructor(t=new m,e=new m,s=new m,r=0,o=0,n=Math.PI*2,h=!1){super(),this._center=t,this._radius=e,this._diff=s,this.rotate=r,this.startAngle=o,this.endAngle=n,this.clockwise=h}get cx(){return this._center.x}set cx(t){this._center.x=t}get cy(){return this._center.y}set cy(t){this._center.y=t}get rx(){return this._radius.x}set rx(t){this._radius.x=t}get ry(){return this._radius.y}set ry(t){this._radius.y=t}get dx(){return this._diff.x}set dx(t){this._diff.x=t}get dy(){return this._diff.y}set dy(t){this._diff.y=t}isClockwise(){return this.clockwise}_getDeltaAngle(){const t=Math.PI*2;let e=this.endAngle-this.startAngle;const s=Math.abs(e)<Number.EPSILON;return e=(e%t+t)%t,s?e=0:this.clockwise||(e=e===0?-t:e-t),e}getPoint(t,e=new m){const s=this._getDeltaAngle(),r=this.startAngle+t*s;let o=this.cx+this.rx*Math.cos(r),n=this.cy+this.ry*Math.sin(r);if(this.rotate!==0){const h=Math.cos(this.rotate),a=Math.sin(this.rotate),c=o-this.cx,l=n-this.cy;o=c*h-l*a+this.cx,n=c*a+l*h+this.cy}return e.set(o,n)}toCommands(){const{cx:t,cy:e,rx:s,ry:r,startAngle:o,endAngle:n,clockwise:h,rotate:a}=this,c=t+s*Math.cos(o)*Math.cos(a)-r*Math.sin(o)*Math.sin(a),l=e+s*Math.cos(o)*Math.sin(a)+r*Math.sin(o)*Math.cos(a),f=Math.abs(o-n),y=f>Math.PI?1:0,x=h?1:0,u=a*180/Math.PI;if(f>=2*Math.PI){const p=o+Math.PI,d=t+s*Math.cos(p)*Math.cos(a)-r*Math.sin(p)*Math.sin(a),P=e+s*Math.cos(p)*Math.sin(a)+r*Math.sin(p)*Math.cos(a);return[{type:"M",x:c,y:l},{type:"A",rx:s,ry:r,angle:u,largeArcFlag:0,sweepFlag:x,x:d,y:P},{type:"A",rx:s,ry:r,angle:u,largeArcFlag:0,sweepFlag:x,x:c,y:l}]}else{const p=t+s*Math.cos(n)*Math.cos(a)-r*Math.sin(n)*Math.sin(a),d=e+s*Math.cos(n)*Math.sin(a)+r*Math.sin(n)*Math.cos(a);return[{type:"M",x:c,y:l},{type:"A",rx:s,ry:r,angle:u,largeArcFlag:y,sweepFlag:x,x:p,y:d}]}}drawTo(t){const{cx:e,cy:s,rx:r,ry:o,rotate:n,startAngle:h,endAngle:a,clockwise:c}=this;return t.ellipse(e,s,r,o,n,h,a,!c),this}applyTransform(t){return mt.set(this.cx,this.cy),mt.applyMatrix3(t),this.cx=mt.x,this.cy=mt.y,bs(t)?Ts(this,t):Cs(this,t),this}getControlPointRefs(){return[this._center]}_getAdaptiveVerticesByArc(t=[]){const{cx:e,cy:s,rx:r,ry:o,dx:n,dy:h,startAngle:a,endAngle:c,clockwise:l,rotate:f}=this,y=!l;let x=Math.abs(a-c);(!y&&a>c||y&&c>a)&&(x=2*Math.PI-x);const u=Math.max(12,Math.floor(12*r**(1/3)*(x/Math.PI)));let p=x/u,d=a;p*=y?-1:1;const P=Math.cos(y?f:-f),b=Math.sin(y?f:-f);for(let w=0;w<u+1;w++){const v=n+Math.cos(d)*r,C=h+Math.sin(d)*o,S=v*P-C*b,g=v*b+C*P;t.push(e+S,s+g),d+=p}return t}_getAdaptiveVerticesByCircle(t=[]){const{cx:e,cy:s,rx:r,ry:o,dx:n,dy:h,rotate:a,clockwise:c}=this;if(!(r>=0&&o>=0&&n>=0&&h>=0))return t;const l=Math.ceil(2.3*Math.sqrt(r+o)),f=l*8+(n?4:0)+(h?4:0),y=[];if(f===0)return t;{const p=y.length;if(l===0)y[p]=y[p+6]=e+n,y[p+1]=y[p+3]=s+h,y[p+2]=y[p+4]=e-n,y[p+5]=y[p+7]=s-h;else{let d=p,P=p+l*4+(n?2:0)+2,b=P,w=f,v=n+r,C=h,S=e+v,g=e-v,M=s+C;if(y[d++]=S,y[d++]=M,y[--P]=M,y[--P]=g,h){const L=s-C;y[b++]=g,y[b++]=L,y[--w]=L,y[--w]=S}for(let L=1;L<l;L++){const k=Math.PI/2*(L/l),I=n+Math.cos(k)*r,N=h+Math.sin(k)*o,D=e+I,O=e-I,at=s+N,T=s-N;y[d++]=D,y[d++]=at,y[--P]=at,y[--P]=O,y[b++]=O,y[b++]=T,y[--w]=T,y[--w]=D}v=n,C=h+o,S=e+v,g=e-v,M=s+C;const q=s-C;y[d++]=S,y[d++]=M,y[--w]=q,y[--w]=S,n&&(y[d++]=g,y[d++]=M,y[--w]=q,y[--w]=g)}}const x=Math.cos(c?-a:a),u=Math.sin(c?-a:a);for(let p=0;p<y.length;p+=2){const d=y[p],P=y[p+1],b=d-e,w=P-s,v=b*x-w*u,C=b*u+w*x;t.push(e+v,s+C)}return t}getAdaptiveVertices(t=[]){return this.startAngle===0&&this.endAngle===Math.PI*2?this._getAdaptiveVerticesByCircle(t):this._getAdaptiveVerticesByArc(t)}copy(t){return super.copy(t),this.cx=t.cx,this.cy=t.cy,this.rx=t.rx,this.ry=t.ry,this.dx=t.dx,this.dy=t.dy,this.startAngle=t.startAngle,this.endAngle=t.endAngle,this.clockwise=t.clockwise,this.rotate=t.rotate,this}}function Ts(i,t){const e=i.rx,s=i.ry,r=Math.cos(i.rotate),o=Math.sin(i.rotate),n=new m(e*r,e*o),h=new m(-s*o,s*r),a=n.applyMatrix3(t),c=h.applyMatrix3(t),l=Ps.set(a.x,c.x,0,a.y,c.y,0,0,0,1),f=ae.copy(l).invert(),u=le.copy(f).transpose().multiply(f).elements,p=As(u[0],u[1],u[4]),d=Math.sqrt(p.rt1),P=Math.sqrt(p.rt2);if(i.rx=1/d,i.ry=1/P,i.rotate=Math.atan2(p.sn,p.cs),!((i.endAngle-i.startAngle)%(2*Math.PI)<Number.EPSILON)){const w=ae.set(d,0,0,0,P,0,0,0,1),v=le.set(p.cs,p.sn,0,-p.sn,p.cs,0,0,0,1),C=w.multiply(v).multiply(l),S=g=>{const{x:M,y:q}=new m(Math.cos(g),Math.sin(g)).applyMatrix3(C);return Math.atan2(q,M)};i.startAngle=S(i.startAngle),i.endAngle=S(i.endAngle),ue(t)&&(i.clockwise=!i.clockwise)}}function Cs(i,t){const e=fe(t),s=ye(t);i.rx*=e,i.ry*=s;const r=e>Number.EPSILON?Math.atan2(t.elements[1],t.elements[0]):Math.atan2(-t.elements[3],t.elements[4]);i.rotate+=r,ue(t)&&(i.startAngle*=-1,i.endAngle*=-1,i.clockwise=!i.clockwise)}function ue(i){const t=i.elements;return t[0]*t[4]-t[1]*t[3]<0}function bs(i){const t=i.elements,e=t[0]*t[3]+t[1]*t[4];if(e===0)return!1;const s=fe(i),r=ye(i);return Math.abs(e/(s*r))>Number.EPSILON}function fe(i){const t=i.elements;return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function ye(i){const t=i.elements;return Math.sqrt(t[3]*t[3]+t[4]*t[4])}function As(i,t,e){let s,r,o,n,h;const a=i+e,c=i-e,l=Math.sqrt(c*c+4*t*t);return a>0?(s=.5*(a+l),h=1/s,r=i*h*e-t*h*t):a<0?r=.5*(a-l):(s=.5*l,r=-.5*l),c>0?o=c+l:o=c-l,Math.abs(o)>2*Math.abs(t)?(h=-2*t/o,n=1/Math.sqrt(1+h*h),o=h*n):Math.abs(t)===0?(o=1,n=0):(h=-.5*o/t,o=1/Math.sqrt(1+h*h),n=h*o),c>0&&(h=o,o=-n,n=h),{rt1:s,rt2:r,cs:o,sn:n}}class xe extends Vt{constructor(t=0,e=0,s=1,r=0,o=Math.PI*2,n=!1){super(new m(t,e),new m(s,s),new m,0,r,o,n)}drawTo(t){const{cx:e,cy:s,rx:r,startAngle:o,endAngle:n,clockwise:h}=this;return t.arc(e,s,r,o,n,!h),this}getAdaptiveVertices(t=[]){const{cx:e,cy:s,rx:r,startAngle:o,endAngle:n,clockwise:h}=this;let a=Math.abs(o-n);(!h&&o>n||h&&n>o)&&(a=2*Math.PI-a);let c=Math.max(6,Math.floor(6*r**(1/3)*(a/Math.PI)));c=Math.max(c,3);let l=a/c,f=o;l*=h?1:-1;for(let y=0;y<c+1;y++){const x=Math.cos(f),u=Math.sin(f),p=e+x*r,d=s+u*r;t.push(p,d),f+=l}return t}}class B extends H{constructor(t=new m,e=new m){super(),this.p1=t,this.p2=e}static from(t,e,s,r){return new B(new m(t,e),new m(s,r))}getPoint(t,e=new m){return t===1?e.copy(this.p2):e.copy(this.p2).sub(this.p1).scale(t).add(this.p1),e}getPointAt(t,e=new m){return this.getPoint(t,e)}getTangent(t,e=new m){return e.subVectors(this.p2,this.p1).normalize()}getTangentAt(t,e=new m){return this.getTangent(t,e)}getControlPointRefs(){return[this.p1,this.p2]}getAdaptiveVertices(t=[]){return t.push(this.p1.x,this.p1.y,this.p2.x,this.p2.y),t}getMinMax(t=m.MAX,e=m.MIN){const{p1:s,p2:r}=this;return t.x=Math.min(t.x,s.x,r.x),t.y=Math.min(t.y,s.y,r.y),e.x=Math.max(e.x,s.x,r.x),e.y=Math.max(e.y,s.y,r.y),{min:t.finite(),max:e.finite()}}toCommands(){const{p1:t,p2:e}=this;return[{type:"M",x:t.x,y:t.y},{type:"L",x:e.x,y:e.y}]}getFillVertices(t={}){const e=Math.min(this.p1.x,this.p2.x),s=Math.max(this.p1.x,this.p2.x),r=Math.min(this.p1.y,this.p2.y),o=Math.max(this.p1.y,this.p2.y),n=e,h=r,a=s-e||t.style?.strokeWidth||0,c=o-r||t.style?.strokeWidth||0;return[n,h,n+a,h,n+a,h+c,n,h+c]}drawTo(t){const{p1:e,p2:s}=this;return t.lineTo(e.x,e.y),t.lineTo(s.x,s.y),this}copy(t){return super.copy(t),this.p1.copy(t.p1),this.p2.copy(t.p2),this}}class nt extends H{constructor(t=[]){super(),this.curves=t}getFlatCurves(){return this.curves.flatMap(t=>t instanceof nt?t.getFlatCurves():t)}addCurve(t){return this.curves.push(t),this}getPoint(t,e=new m){const s=t*this.getLength(),r=this.getLengths();let o=0;for(;o<r.length;){if(r[o]>=s){const n=r[o]-s,h=this.curves[o],a=h.getLength();return h.getPointAt(a===0?0:1-n/a,e)}o++}return e}updateLengths(){const t=[];for(let e=0,s=0,r=this.curves.length;e<r;e++)s+=this.curves[e].getLength(),t.push(s);this._arcLengths=t}getControlPointRefs(){return this.curves.flatMap(t=>t.getControlPointRefs())}_removeNextPointIfEqualPrevPoint(t,e){const s=[t[e-1],t[e]],r=[t[e+1],t[e+2]];return s[0]===r[0]&&s[1]===r[1]&&t.splice(e+1,2),t}getSpacedVertices(t=5,e=[]){let s;return this.curves.forEach(r=>{r.getSpacedVertices(t,e),s&&this._removeNextPointIfEqualPrevPoint(e,s),s=e.length-1}),e}getAdaptiveVertices(t=[]){let e;return this.curves.forEach(s=>{s.getAdaptiveVertices(t),e&&this._removeNextPointIfEqualPrevPoint(t,e),e=t.length-1}),t}strokeTriangulate(t){return this.curves.length===1?this.curves[0].strokeTriangulate(t):super.strokeTriangulate(t)}getFillVertices(t){if(this.curves.length===1)return this.curves[0].getFillVertices(t);{const e=[];let s;return this.curves.forEach(r=>{let o;r instanceof B?o=r.getAdaptiveVertices():o=r.getFillVertices(t),e.push(...o),s&&this._removeNextPointIfEqualPrevPoint(e,s),s=e.length-1}),e}}applyTransform(t){return this.curves.forEach(e=>e.applyTransform(t)),this}getMinMax(t=m.MAX,e=m.MIN){return this.curves.forEach(s=>s.getMinMax(t,e)),{min:t.finite(),max:e.finite()}}getBoundingBox(){const{min:t,max:e}=this.getMinMax();return new U(t.x,t.y,e.x-t.x,e.y-t.y)}toCommands(){return this.curves.flatMap(t=>t.toCommands())}drawTo(t){const e=this.curves[0]?.getPoint(0);return e&&t.moveTo(e.x,e.y),this.curves.forEach(s=>s.drawTo(t)),this}copy(t){return super.copy(t),this.curves=t.curves.map(e=>e.clone()),this}}class Mt extends H{constructor(t=new m,e=new m,s=new m,r=new m){super(),this.p1=t,this.cp1=e,this.cp2=s,this.p2=r}static from(t,e,s,r,o,n,h,a){return new Mt(new m(t,e),new m(s,r),new m(o,n),new m(h,a))}getPoint(t,e=new m){const{p1:s,cp1:r,cp2:o,p2:n}=this;return e.set(Et(t,s.x,r.x,o.x,n.x),Et(t,s.y,r.y,o.y,n.y))}getAdaptiveVertices(t=[]){return se(this.p1.x,this.p1.y,this.cp1.x,this.cp1.y,this.cp2.x,this.cp2.y,this.p2.x,this.p2.y,.5,t)}getControlPointRefs(){return[this.p1,this.cp1,this.cp2,this.p2]}_solveQuadratic(t,e,s){const r=e*e-4*t*s;if(r<0)return[];const o=Math.sqrt(r),n=(-e+o)/(2*t),h=(-e-o)/(2*t);return[n,h].filter(a=>a>=0&&a<=1)}getMinMax(t=m.MAX,e=m.MIN){const{p1:s,cp1:r,cp2:o,p2:n}=this,h=this._solveQuadratic(3*(r.x-s.x),6*(o.x-r.x),3*(n.x-o.x)),a=this._solveQuadratic(3*(r.y-s.y),6*(o.y-r.y),3*(n.y-o.y)),c=[0,1,...h,...a];return((f,y)=>{for(const x of f)for(let u=0;u<=y;u++){const p=u/y-.5,d=Math.min(1,Math.max(0,x+p)),P=this.getPoint(d);t.x=Math.min(t.x,P.x),t.y=Math.min(t.y,P.y),e.x=Math.max(e.x,P.x),e.y=Math.max(e.y,P.y)}})(c,10),{min:t.finite(),max:e.finite()}}toCommands(){const{p1:t,cp1:e,cp2:s,p2:r}=this;return[{type:"M",x:t.x,y:t.y},{type:"C",x1:e.x,y1:e.y,x2:s.x,y2:s.y,x:r.x,y:r.y}]}drawTo(t){const{p1:e,cp1:s,cp2:r,p2:o}=this;return t.lineTo(e.x,e.y),t.bezierCurveTo(s.x,s.y,r.x,r.y,o.x,o.y),this}copy(t){return super.copy(t),this.p1.copy(t.p1),this.cp1.copy(t.cp1),this.cp2.copy(t.cp2),this.p2.copy(t.p2),this}}class pe extends Vt{constructor(t=0,e=0,s=1,r=1,o=0,n=0,h=Math.PI*2,a=!1){super(new m(t,e),new m(s,r),new m,o,n,h,a)}drawTo(t){return t.ellipse(this.cx,this.cy,this.rx,this.ry,this.rotate,this.startAngle,this.endAngle,!this.clockwise),this}}class qt extends nt{}class ks extends qt{constructor(t=0,e=0,s=1,r=3){super(),this.cx=t,this.cy=e,this.radius=s,this.sideCount=r,this.update()}update(){const{cx:t,cy:e,radius:s,sideCount:r}=this,o=[];for(let h=0;h<r;h++){const a=h*2*Math.PI/r-.5*Math.PI;o.push(new m(s*Math.cos(a),s*Math.sin(a)).add({x:t,y:e}))}const n=[];for(let h=0;h<r;h++)n.push(new B(o[h],o[(h+1)%r]));return this.curves=n,this}copy(t){return super.copy(t),this.cx=t.cx,this.cy=t.cy,this.radius=t.radius,this.sideCount=t.sideCount,this.update(),this}}class wt extends H{constructor(t=new m,e=new m,s=new m){super(),this.p1=t,this.cp=e,this.p2=s}static from(t,e,s,r,o,n){return new wt(new m(t,e),new m(s,r),new m(o,n))}getPoint(t,e=new m){const{p1:s,cp:r,p2:o}=this;return e.set(Dt(t,s.x,r.x,o.x),Dt(t,s.y,r.y,o.y)),e}getControlPointRefs(){return[this.p1,this.cp,this.p2]}getAdaptiveVertices(t=[]){return ne(this.p1.x,this.p1.y,this.cp.x,this.cp.y,this.p2.x,this.p2.y,.5,t)}getMinMax(t=m.MAX,e=m.MIN){const{p1:s,cp:r,p2:o}=this,n=.5*(s.x+r.x),h=.5*(s.y+r.y),a=.5*(s.x+o.x),c=.5*(s.y+o.y);return t.x=Math.min(t.x,s.x,o.x,n,a),t.y=Math.min(t.y,s.y,o.y,h,c),e.x=Math.max(e.x,s.x,o.x,n,a),e.y=Math.max(e.y,s.y,o.y,h,c),{min:t.finite(),max:e.finite()}}toCommands(){const{p1:t,cp:e,p2:s}=this;return[{type:"M",x:t.x,y:t.y},{type:"Q",x1:e.x,y1:e.y,x:s.x,y:s.y}]}drawTo(t){const{p1:e,cp:s,p2:r}=this;return t.lineTo(e.x,e.y),t.quadraticCurveTo(s.x,s.y,r.x,r.y),this}copy(t){return super.copy(t),this.p1.copy(t.p1),this.cp.copy(t.cp),this.p2.copy(t.p2),this}}class ge extends qt{constructor(t=0,e=0,s=0,r=0){super(),this.x=t,this.y=e,this.width=s,this.height=r,this.update()}update(){const{x:t,y:e,width:s,height:r}=this,o=[new m(t,e),new m(t+s,e),new m(t+s,e+r),new m(t,e+r)];return this.curves=[new B(o[0],o[1]),new B(o[1],o[2]),new B(o[2],o[3]),new B(o[3],o[0])],this}drawTo(t){return t.rect(this.x,this.y,this.width,this.height),this}getFillVertices(t={}){const{x:e,y:s,width:r,height:o}=this;return[e,s,e+r,s,e+r,s+o,e,s+o]}copy(t){return super.copy(t),this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this.update(),this}}class de extends Vt{constructor(t=0,e=0,s=1,r=1,o=1){super(),this.x=t,this.y=e,this.width=s,this.height=r,this.radius=o,this.update()}update(){const{x:t,y:e,width:s,height:r,radius:o}=this,n=s/2,h=r/2,a=t+n,c=e+h,l=Math.max(0,Math.min(o,Math.min(n,h))),f=l;return this._center=new m(a,c),this._radius=new m(l,f),this._diff=new m(n-l,h-f),this}drawTo(t){const{x:e,y:s,width:r,height:o,radius:n}=this;return t.roundRect(e,s,r,o,n),this}copy(t){return super.copy(t),this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this.radius=t.radius,this.update(),this}}class me extends H{constructor(t=[]){super(),this.points=t}getPoint(t,e=new m){const{points:s}=this,r=(s.length-1)*t,o=Math.floor(r),n=r-o,h=s[o===0?o:o-1],a=s[o],c=s[o>s.length-2?s.length-1:o+1],l=s[o>s.length-3?s.length-1:o+2];return e.set(St(n,h.x,a.x,c.x,l.x),St(n,h.y,a.y,c.y,l.y)),e}getControlPointRefs(){return this.points}copy(t){super.copy(t),this.points=[];for(let e=0,s=t.points.length;e<s;e++)this.points.push(t.points[e].clone());return this}}class ht extends nt{startPoint;currentPoint;autoClose=!1;constructor(t){super(),t&&this.addPoints(t)}addPoints(t){this.moveTo(t[0].x,t[0].y);for(let e=1,s=t.length;e<s;e++){const{x:r,y:o}=t[e];this.lineTo(r,o)}return this}addCommands(t){return At(t,this),this}addData(t){return this.addCommands(kt(t)),this}_closeVertices(t){return this.autoClose&&t.length>=4&&t[0]!==t[t.length-2]&&t[1]!==t[t.length-1]&&t.push(t[0],t[1]),t}getUnevenVertices(t=40,e=[]){return this._closeVertices(super.getUnevenVertices(t,e))}getSpacedVertices(t=40,e=[]){return this._closeVertices(super.getSpacedVertices(t,e))}getAdaptiveVertices(t=[]){return this._closeVertices(super.getAdaptiveVertices(t))}getFillVertices(t){return this._closeVertices(super.getFillVertices(t))}_setCurrentPoint(t){return this.currentPoint=new m(t.x,t.y),this.startPoint||(this.startPoint=this.currentPoint.clone()),this}_connetLineTo(t){if(this.curves.length>0){const e=t.getPoint(0);(!this.currentPoint||!e.equals(this.currentPoint))&&this.lineTo(e.x,e.y)}return this}closePath(){const t=this.startPoint;if(t){const e=this.currentPoint;e&&!t.equals(e)&&(this.curves.push(new B(e.clone(),t.clone())),e.copy(t)),this.startPoint=void 0}return this}moveTo(t,e){return this.currentPoint=new m(t,e),this.startPoint=this.currentPoint.clone(),this}lineTo(t,e){const s=this.currentPoint;return s?.equals({x:t,y:e})||this.curves.push(B.from(s?.x??0,s?.y??0,t,e)),this._setCurrentPoint({x:t,y:e}),this}bezierCurveTo(t,e,s,r,o,n){const h=this.currentPoint;return h?.equals({x:o,y:n})||this.curves.push(Mt.from(h?.x??0,h?.y??0,t,e,s,r,o,n)),this._setCurrentPoint({x:o,y:n}),this}quadraticCurveTo(t,e,s,r){const o=this.currentPoint;return o?.equals({x:s,y:r})||this.curves.push(wt.from(o?.x??0,o?.y??0,t,e,s,r)),this._setCurrentPoint({x:s,y:r}),this}arc(t,e,s,r,o,n){const h=new xe(t,e,s,r,o,!n);return this._connetLineTo(h),this.curves.push(h),this._setCurrentPoint(h.getPoint(1)),this}relativeArc(t,e,s,r,o,n){return t+=this.currentPoint?.x??0,e+=this.currentPoint?.y??0,this.arc(t,e,s,r,o,n),this}arcTo(t,e,s,r,o){return console.warn("Method arcTo not supported yet"),this}ellipse(t,e,s,r,o,n,h,a=!0){const c=new pe(t,e,s,r,o,n,h,!a);return this._connetLineTo(c),this.curves.push(c),this._setCurrentPoint(c.getPoint(1)),this}relativeEllipse(t,e,s,r,o,n,h,a){return t+=this.currentPoint?.x??0,e+=this.currentPoint?.y??0,this.ellipse(t,e,s,r,o,n,h,a),this}rect(t,e,s,r){const o=new ge(t,e,s,r);return this._connetLineTo(o),this.curves.push(o),this._setCurrentPoint({x:t,y:e}),this}roundRect(t,e,s,r,o){const n=new de(t,e,s,r,o);return this._connetLineTo(n),this.curves.push(n),this._setCurrentPoint({x:t,y:e}),this}splineThru(t){const e=this.currentPoint??new m;return this.curves.push(new me([e].concat(t))),this._setCurrentPoint(t[t.length-1]),this}drawTo(t){const e=this.curves[0]?.getPoint(0);return e&&t.moveTo(e.x,e.y),this.curves.forEach(s=>s.drawTo(t)),this.autoClose&&t.closePath(),this}copy(t){return super.copy(t),this.autoClose=t.autoClose,this.currentPoint=t.currentPoint?.clone(),this}}function Is(i){return i.replace(/[^a-z0-9]/gi,"-").replace(/\B([A-Z])/g,"-$1").toLowerCase()}function Ss(i,t,e,s){const r=t.clone().sub(i),o=s.clone().sub(e),n=e.clone().sub(i),h=r.cross(o);if(h===0)return new m((i.x+e.x)/2,(i.y+e.y)/2);const a=n.cross(o)/h;return Math.abs(a)>1?new m((i.x+e.x)/2,(i.y+e.y)/2):new m(i.x+a*r.x,i.y+a*r.y)}class j extends nt{currentCurve=new ht;style;get startPoint(){return this.currentCurve.startPoint}get currentPoint(){return this.currentCurve.currentPoint}get strokeWidth(){return this.style.strokeWidth??((this.style.stroke??"none")==="none"?0:1)}constructor(t,e={}){super(),this.curves.push(this.currentCurve),this.style=e,t&&(t instanceof j?this.addPath(t):Array.isArray(t)?this.addCommands(t):this.addData(t))}addPath(t){const e=this.curves.findIndex(s=>s===this.currentCurve);return e>-1&&this.curves.splice(e,1),t instanceof j?this.curves.push(...t.curves.filter(s=>s.curves.length).map(s=>s.clone())):t.curves.length&&this.curves.push(t),this.curves.push(this.currentCurve),this}closePath(){const t=this.startPoint;return t&&(this.currentCurve.closePath(),this.currentCurve.curves.length&&(this.currentCurve=new ht().moveTo(t.x,t.y),this.curves.push(this.currentCurve))),this}moveTo(t,e){return this.currentCurve.currentPoint?.equals({x:t,y:e})||(this.currentCurve.curves.length&&(this.currentCurve=new ht,this.curves.push(this.currentCurve)),this.currentCurve.moveTo(t,e)),this}lineTo(t,e){return this.currentCurve.lineTo(t,e),this}bezierCurveTo(t,e,s,r,o,n){return this.currentCurve.bezierCurveTo(t,e,s,r,o,n),this}quadraticCurveTo(t,e,s,r){return this.currentCurve.quadraticCurveTo(t,e,s,r),this}arc(t,e,s,r,o,n){return this.currentCurve.arc(t,e,s,r,o,n),this}arcTo(t,e,s,r,o){return this.currentCurve.arcTo(t,e,s,r,o),this}ellipse(t,e,s,r,o,n,h,a){return this.currentCurve.ellipse(t,e,s,r,o,n,h,a),this}rect(t,e,s,r){return this.currentCurve.rect(t,e,s,r),this}roundRect(t,e,s,r,o){return this.currentCurve.roundRect(t,e,s,r,o),this}reset(){return this.currentCurve=new ht,this.curves=[this.currentCurve],this.style={},this}addCommands(t){return At(t,this),this}addData(t){return this.addCommands(kt(t)),this}splineThru(t){return this.currentCurve.splineThru(t),this}scale(t,e=t,s={x:0,y:0}){return this.getControlPointRefs().forEach(r=>{r.scale(t,e,s)}),this}skew(t,e=0,s={x:0,y:0}){return this.getControlPointRefs().forEach(r=>{r.skew(t,e,s)}),this}rotate(t,e={x:0,y:0}){return this.getControlPointRefs().forEach(s=>{s.rotate(t,e)}),this}bold(t){if(t===0)return this;const e=this.getFlatCurves(),s=[],r=[],o=[];e.forEach((h,a)=>{const c=h.getControlPointRefs(),l=h.isClockwise();o[a]=c,r[a]=l;const f=c[0],y=c[c.length-1]??f;s.push({start:l?y:f,end:l?f:y,index:a})});const n=[];return s.forEach((h,a)=>{n[a]=[],s.forEach((c,l)=>{c.start&&h.end&&l!==a&&c.start?.equals(h.end)&&n[a].push(c.index)})}),e.forEach((h,a)=>{const c=r[a];o[a].forEach(l=>{l.add(h.getNormal(h.getTForPoint(l)).scale(c?t:-t))})}),n.forEach((h,a)=>{const c=o[a];h.forEach(l=>{const f=o[l],y=Ss(c[c.length-1],c[c.length-2]??c[c.length-1],f[0],f[1]??f[0]);y&&(c[c.length-1].copy(y),f[0].copy(y))})}),this}getMinMax(t=m.MAX,e=m.MIN,s=!0){const r=this.strokeWidth;return this.curves.forEach(o=>{if(o.getMinMax(t,e),s&&r>1){const n=r/2,h=o.isClockwise(),a=[];for(let c=0;c<=1;c+=1/o.arcLengthDivision){const l=o.getPoint(c),f=o.getNormal(c),y=f.clone().scale(h?n:-n),x=f.clone().scale(h?-n:n);a.push(l.clone().add(y),l.clone().add(x),l.clone().add({x:n,y:0}),l.clone().add({x:-n,y:0}),l.clone().add({x:0,y:n}),l.clone().add({x:0,y:-n}),l.clone().add({x:n,y:n}),l.clone().add({x:-n,y:-n}))}t.min(...a),e.max(...a)}}),{min:t.finite(),max:e.finite()}}strokeTriangulate(t){const e=t?.indices??[],s=t?.vertices??[];return this.curves.forEach(r=>{r.strokeTriangulate({...t,indices:e,vertices:s,style:{...this.style}})}),{indices:e,vertices:s}}fillTriangulate(t){const e={...t,style:{...this.style,...t?.style}},s=e.indices??[],r=e.vertices??[];if((e.style.fillRule??"nonzero")==="nonzero"){const n=this.curves.map(c=>c.getFillVertices(e)),h=new Map,a=new Set;for(let c=0;c<n.length;c++){const l=[];for(let f=0;f<n.length;f++){if(c===f)continue;let y=!1;for(let x=0;x<n[c].length;x+=2)y=y||ie([n[c][x],n[c][x+1]],n[f]);y&&l.push(f)}l.length&&(l.forEach(f=>{let y=h.get(f);y||(y=new Set,h.set(f,y)),y.add(c)}),a.add(c))}n.forEach((c,l)=>{if(a.has(l)||!c.length)return;const f=c.slice(),y=[];h.get(l)?.forEach(x=>{y.push(f.length/2),f.push(...n[x])}),Lt(f,{...t,indices:s,vertices:r,holes:y,style:{...this.style}})})}else this.curves.forEach(n=>{n.fillTriangulate({...t,indices:s,vertices:r,style:{...this.style}})});return{indices:s,vertices:r}}getBoundingBox(t=!0){const{min:e,max:s}=this.getMinMax(void 0,void 0,t);return new U(e.x,e.y,s.x-e.x,s.y-e.y)}drawTo(t,e={}){e={...this.style,...e};const{fill:s="#000",stroke:r="none"}=e;return t.beginPath(),t.save(),Ct(t,e),this.curves.forEach(o=>{o.drawTo(t)}),s!=="none"&&t.fill(),r!=="none"&&t.stroke(),t.restore(),this}drawControlPointsTo(t,e={}){e={...this.style,...e};const{fill:s="#000",stroke:r="none"}=e;return t.beginPath(),t.save(),Ct(t,e),this.getControlPointRefs().forEach(o=>{tt(t,o.x,o.y,{radius:4})}),s!=="none"&&t.fill(),r!=="none"&&t.stroke(),t.restore(),this}toCommands(){return this.curves.flatMap(t=>t.toCommands())}toData(){return this.curves.filter(t=>t.curves.length).map(t=>t.toData()).join(" ")}toSvgPathString(){const t={...this.style,fill:this.style.fill??"#000",stroke:this.style.stroke??"none"},e={};for(const r in t)t[r]!==void 0&&(e[Is(r)]=t[r]);Object.assign(e,{"stroke-width":`${this.strokeWidth}px`});let s="";for(const r in e)e[r]!==void 0&&(s+=`${r}:${e[r]};`);return`<path d="${this.toData()}" style="${s}"></path>`}copy(t){return super.copy(t),this.currentCurve=t.currentCurve.clone(),this.style={...t.style},this}}class Me{constructor(t=[],e){this.paths=t,this.viewBox=e}getBoundingBox(t=!0){if(!this.paths.length)return;const e=m.MAX,s=m.MIN;return this.paths.forEach(r=>r.getMinMax(e,s,t)),new U(e.x,e.y,s.x-e.x,s.y-e.y)}toTriangulatedSvgString(t=this.paths.map(s=>s.fillTriangulate()),e=0){let s="";const r={x:-e,y:-e},o={x:e,y:e};(Array.isArray(t)?t:[t]).forEach(({vertices:a,indices:c})=>{const l=f=>{const y=a[f*2],x=a[f*2+1];return r.x=Math.min(r.x,y+e),o.x=Math.max(o.x,y+e),r.y=Math.min(r.y,x+e),o.y=Math.max(o.y,x+e),[y,x]};for(let f=0,y=c.length;f<y;f+=3){const x=l(c[f]),u=l(c[f+1]),p=l(c[f+2]);s+=`<polygon points="${x.join(",")} ${u.join(",")} ${p.join(",")}" fill="black" />`}});const h=[r.x,r.y,o.x-r.x,o.y-r.y];return`<svg width="${h[2]}" height="${h[3]}" viewBox="${h.join(" ")}" xmlns="http://www.w3.org/2000/svg">${s}</svg>`}toTriangulatedSvg(t,e){return new DOMParser().parseFromString(this.toTriangulatedSvgString(t,e),"image/svg+xml").documentElement}toSvgString(){const{x:t,y:e,width:s,height:r}=this.getBoundingBox(),o=this.paths.map(n=>n.toSvgPathString()).join("");return`<svg viewBox="${t} ${e} ${s} ${r}" width="${s}px" height="${r}px" xmlns="http://www.w3.org/2000/svg">${o}</svg>`}toSvgUrl(){return`data:image/svg+xml;base64,${btoa(this.toSvgString())}`}toSvg(){return new DOMParser().parseFromString(this.toSvgString(),"image/svg+xml").documentElement}toCanvas(t={}){const{pixelRatio:e=2,...s}=t,{left:r,top:o,width:n,height:h}=this.getBoundingBox(),a=document.createElement("canvas");a.width=n*e,a.height=h*e,a.style.width=`${n}px`,a.style.height=`${h}px`;const c=a.getContext("2d");return c&&(c.scale(e,e),c.translate(-r,-o),this.paths.forEach(l=>{l.drawTo(c,s)})),a}}class Es{constructor(t,e,s=1,r=1){this.rows=t,this.cols=e,this.width=s,this.height=r;for(let o=0;o<t;o++){this.controlPoints[o]=[];for(let n=0;n<e;n++)this.controlPoints[o][n]={x:n/(e-1)*s,y:o/(t-1)*r}}}controlPoints=[];moveControlPoint(t,e,s,r){return this.controlPoints[t][e].x+=s,this.controlPoints[t][e].y+=r,this}}function we(i){const t=[];return t[0]=(1-i)**3/6,t[1]=(3*i**3-6*i**2+4)/6,t[2]=(-3*i**3+3*i**2+3*i+1)/6,t[3]=i**3/6,t}function _s(i,t,e=t.width,s=t.height){const r=i.x/e*(t.cols-1),o=i.y/s*(t.rows-1),n=Math.floor(r),h=Math.floor(o),a=r-n,c=o-h,l=we(a),f=we(c);let y=0,x=0;for(let u=0;u<4;u++)for(let p=0;p<4;p++){const d=Math.min(Math.max(h-1+u,0),t.rows-1),P=Math.min(Math.max(n-1+p,0),t.cols-1),b=t.controlPoints[d][P],w=l[p]*f[u];y+=b.x*w,x+=b.y*w}i.set(y,x)}A.ArcCurve=xe,A.BoundingBox=U,A.CompositeCurve=nt,A.CubicBezierCurve=Mt,A.Curve=H,A.CurvePath=ht,A.EllipseCurve=pe,A.EquilateralPloygonCurve=ks,A.FFDControlGrid=Es,A.LineCurve=B,A.Matrix3=R,A.Path2D=j,A.Path2DSet=Me,A.PloygonCurve=qt,A.QuadraticBezierCurve=wt,A.RectangleCurve=ge,A.RoundRectangleCurve=de,A.SplineCurve=me,A.Vector2=m,A.applyFFD=_s,A.catmullRom=St,A.cubicBezier=Et,A.drawPoint=tt,A.fillTriangulate=Lt,A.getAdaptiveCubicBezierCurvePoints=se,A.getAdaptiveQuadraticBezierCurvePoints=ne,A.getDirectedArea=ps,A.parseArcCommand=zt,A.parsePathDataArgs=z,A.pointInPolygonEvenOdd=gs,A.pointInPolygonNonZero=ie,A.quadraticBezier=Dt,A.setCanvasContext=Ct,A.strokeTriangulate=ce,A.svgPathCommandsAddToPath2D=At,A.svgPathCommandsToData=Bt,A.svgPathDataToCommands=kt,A.svgToDom=Xt,A.svgToPath2DSet=Be,Object.defineProperty(A,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(A,tt){typeof exports=="object"&&typeof module<"u"?tt(exports):typeof define=="function"&&define.amd?define(["exports"],tt):(A=typeof globalThis<"u"?globalThis:A||self,tt(A.modernPath2d={}))})(this,function(A){"use strict";function tt(i,t,e,s={}){const{radius:r=1}=s;i.moveTo(t,e),i.arc(t,e,r,0,Math.PI*2)}const be={arcs:"bevel",bevel:"bevel",miter:"miter","miter-clip":"miter",round:"round"};function Ct(i,t){const{fill:e="#000",stroke:s="none",strokeWidth:r=s==="none"?0:1,strokeLinecap:o="round",strokeLinejoin:n="miter",strokeMiterlimit:h=0,strokeDasharray:c=[],strokeDashoffset:a=0,shadowOffsetX:l=0,shadowOffsetY:f=0,shadowBlur:y=0,shadowColor:x="rgba(0, 0, 0, 0)"}=t;i.fillStyle=e,i.strokeStyle=s,i.lineWidth=r,i.lineCap=o,i.lineJoin=be[n],i.miterLimit=h,i.setLineDash(c),i.lineDashOffset=a,i.shadowOffsetX=l,i.shadowOffsetY=f,i.shadowBlur=y,i.shadowColor=x}class m{constructor(t=0,e=0){this.x=t,this.y=e}static get MAX(){return new m(1/0,1/0)}static get MIN(){return new m(-1/0,-1/0)}get array(){return[this.x,this.y]}finite(){return this.x=Number.isFinite(this.x)?this.x:0,this.y=Number.isFinite(this.y)?this.y:0,this}set(t,e){return this.x=t,this.y=e,this}add(t){return this.x+=t.x,this.y+=t.y,this}sub(t){return this.x-=t.x,this.y-=t.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}divide(t){return this.x/=t.x,this.y/=t.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}rotate(t,e={x:0,y:0}){const s=-t/180*Math.PI,r=this.x-e.x,o=-(this.y-e.y),n=Math.sin(s),h=Math.cos(s);return this.set(e.x+(r*h-o*n),e.y-(r*n+o*h)),this}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,s=this.y-t.y;return e*e+s*s}lengthSquared(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.lengthSquared())}scale(t,e=t,s={x:0,y:0}){const r=t<0?s.x-this.x+s.x:this.x,o=e<0?s.y-this.y+s.y:this.y;return this.x=r*Math.abs(t),this.y=o*Math.abs(e),this}skew(t,e=0,s={x:0,y:0}){const r=this.x-s.x,o=this.y-s.y;return this.x=s.x+(r+Math.tan(t)*o),this.y=s.y+(o+Math.tan(e)*r),this}min(...t){return this.x=Math.min(this.x,...t.map(e=>e.x)),this.y=Math.min(this.y,...t.map(e=>e.y)),this}max(...t){return this.x=Math.max(this.x,...t.map(e=>e.x)),this.y=Math.max(this.y,...t.map(e=>e.y)),this}normalize(){return this.scale(1/(this.length()||1))}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this}divideVectors(t,e){return this.x=t.x/e.x,this.y=t.y/e.y,this}lerpVectors(t,e,s){return this.x=t.x+(e.x-t.x)*s,this.y=t.y+(e.y-t.y)*s,this}equals(t){return this.x===t.x&&this.y===t.y}applyMatrix3(t){const e=this.x,s=this.y,r=t.elements;return this.x=r[0]*e+r[3]*s+r[6],this.y=r[1]*e+r[4]*s+r[7],this}copy(t){return this.x=t.x,this.y=t.y,this}clone(){return new m(this.x,this.y)}}class U{constructor(t=0,e=0,s=0,r=0){this.left=t,this.top=e,this.width=s,this.height=r}get x(){return this.left}set x(t){this.left=t}get y(){return this.top}set y(t){this.top=t}get right(){return this.left+this.width}get bottom(){return this.top+this.height}get center(){return new m((this.left+this.right)/2,(this.top+this.bottom)/2)}get array(){return[this.left,this.top,this.width,this.height]}static from(...t){if(t.length===0)return new U;if(t.length===1)return t[0].clone();const e=t[0],s=t.slice(1).reduce((r,o)=>(r.left=Math.min(r.left,o.left),r.top=Math.min(r.top,o.top),r.right=Math.max(r.right,o.right),r.bottom=Math.max(r.bottom,o.bottom),r),{left:e?.left??0,top:e?.top??0,right:e?.right??0,bottom:e?.bottom??0});return new U(s.left,s.top,s.right-s.left,s.bottom-s.top)}translate(t,e){return this.left+=t,this.top+=e,this}copy(t){return this.left=t.left,this.top=t.top,this.width=t.width,this.height=t.height,this}clone(){return new U(this.left,this.top,this.width,this.height)}}class R{elements=[];constructor(t=1,e=0,s=0,r=0,o=1,n=0,h=0,c=0,a=1){this.set(t,e,s,r,o,n,h,c,a)}set(t,e,s,r,o,n,h,c,a){const l=this.elements;return l[0]=t,l[1]=r,l[2]=h,l[3]=e,l[4]=o,l[5]=c,l[6]=s,l[7]=n,l[8]=a,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,s=t.elements;return e[0]=s[0],e[1]=s[1],e[2]=s[2],e[3]=s[3],e[4]=s[4],e[5]=s[5],e[6]=s[6],e[7]=s[7],e[8]=s[8],this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const s=t.elements,r=e.elements,o=this.elements,n=s[0],h=s[3],c=s[6],a=s[1],l=s[4],f=s[7],y=s[2],x=s[5],u=s[8],p=r[0],g=r[3],P=r[6],b=r[1],w=r[4],v=r[7],C=r[2],S=r[5],d=r[8];return o[0]=n*p+h*b+c*C,o[3]=n*g+h*w+c*S,o[6]=n*P+h*v+c*d,o[1]=a*p+l*b+f*C,o[4]=a*g+l*w+f*S,o[7]=a*P+l*v+f*d,o[2]=y*p+x*b+u*C,o[5]=y*g+x*w+u*S,o[8]=y*P+x*v+u*d,this}invert(){const t=this.elements,e=t[0],s=t[1],r=t[2],o=t[3],n=t[4],h=t[5],c=t[6],a=t[7],l=t[8],f=l*n-h*a,y=h*c-l*o,x=a*o-n*c,u=e*f+s*y+r*x;if(u===0)return this.set(0,0,0,0,0,0,0,0,0);const p=1/u;return t[0]=f*p,t[1]=(r*a-l*s)*p,t[2]=(h*s-r*n)*p,t[3]=y*p,t[4]=(l*e-r*c)*p,t[5]=(r*o-h*e)*p,t[6]=x*p,t[7]=(s*c-a*e)*p,t[8]=(n*e-s*o)*p,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}scale(t,e){return this.premultiply(bt.makeScale(t,e)),this}rotate(t){return this.premultiply(bt.makeRotation(-t)),this}translate(t,e){return this.premultiply(bt.makeTranslation(t,e)),this}makeTranslation(t,e){return this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),s=Math.sin(t);return this.set(e,-s,0,s,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}fromArray(t,e=0){for(let s=0;s<9;s++)this.elements[s]=t[s+e];return this}clone(){return new this.constructor().fromArray(this.elements)}}const bt=new R;function Rt(i,t,e,s){const r=i*e+t*s,o=Math.sqrt(i*i+t*t)*Math.sqrt(e*e+s*s);let n=Math.acos(Math.max(-1,Math.min(1,r/o)));return i*s-t*e<0&&(n=-n),n}function zt(i,t,e,s,r,o,n,h){if(t===0||e===0){i.lineTo(h.x,h.y);return}s=s*Math.PI/180,t=Math.abs(t),e=Math.abs(e);const c=(n.x-h.x)/2,a=(n.y-h.y)/2,l=Math.cos(s)*c+Math.sin(s)*a,f=-Math.sin(s)*c+Math.cos(s)*a;let y=t*t,x=e*e;const u=l*l,p=f*f,g=u/y+p/x;if(g>1){const F=Math.sqrt(g);t=F*t,e=F*e,y=t*t,x=e*e}const P=y*p+x*u,b=(y*x-P)/P;let w=Math.sqrt(Math.max(0,b));r===o&&(w=-w);const v=w*t*f/e,C=-w*e*l/t,S=Math.cos(s)*v-Math.sin(s)*C+(n.x+h.x)/2,d=Math.sin(s)*v+Math.cos(s)*C+(n.y+h.y)/2,M=Rt(1,0,(l-v)/t,(f-C)/e),q=Rt((l-v)/t,(f-C)/e,(-l-v)/t,(-f-C)/e)%(Math.PI*2);i.ellipse(S,d,t,e,s,M,M+q,o===0)}const V={WHITESPACE:/[ \t\r\n]/,DIGIT:/\d/,SIGN:/[-+]/,POINT:/\./,COMMA:/,/,EXP:/e/i,FLAGS:/[01]/};function z(i,t,e=0){let h=0,c=!0,a="",l="";const f=[];function y(g,P,b){const w=new SyntaxError(`Unexpected character "${g}" at index ${P}.`);throw w.partial=b,w}function x(){a!==""&&(l===""?f.push(Number(a)):f.push(Number(a)*10**Number(l))),a="",l=""}let u;const p=i.length;for(let g=0;g<p;g++){if(u=i[g],Array.isArray(t)&&t.includes(f.length%e)&&V.FLAGS.test(u)){h=1,a=u,x();continue}if(h===0){if(V.WHITESPACE.test(u))continue;if(V.DIGIT.test(u)||V.SIGN.test(u)){h=1,a=u;continue}if(V.POINT.test(u)){h=2,a=u;continue}V.COMMA.test(u)&&(c&&y(u,g,f),c=!0)}if(h===1){if(V.DIGIT.test(u)){a+=u;continue}if(V.POINT.test(u)){a+=u,h=2;continue}if(V.EXP.test(u)){h=3;continue}V.SIGN.test(u)&&a.length===1&&V.SIGN.test(a[0])&&y(u,g,f)}if(h===2){if(V.DIGIT.test(u)){a+=u;continue}if(V.EXP.test(u)){h=3;continue}V.POINT.test(u)&&a[a.length-1]==="."&&y(u,g,f)}if(h===3){if(V.DIGIT.test(u)){l+=u;continue}if(V.SIGN.test(u)){if(l===""){l+=u;continue}l.length===1&&V.SIGN.test(l)&&y(u,g,f)}}V.WHITESPACE.test(u)?(x(),h=0,c=!1):V.COMMA.test(u)?(x(),h=0,c=!0):V.SIGN.test(u)?(x(),h=1,a=u):V.POINT.test(u)?(x(),h=2,a=u):y(u,g,f)}return x(),f}function et(i,t){return i-(t-i)}function At(i,t){const e=new m,s=new m;for(let r=0,o=i.length;r<o;r++){const n=i[r];if(n.type==="m"||n.type==="M")n.type==="m"?e.add(n):e.copy(n),t.moveTo(e.x,e.y),s.copy(e);else if(n.type==="h"||n.type==="H")n.type==="h"?e.x+=n.x:e.x=n.x,t.lineTo(e.x,e.y),s.copy(e);else if(n.type==="v"||n.type==="V")n.type==="v"?e.y+=n.y:e.y=n.y,t.lineTo(e.x,e.y),s.copy(e);else if(n.type==="l"||n.type==="L")n.type==="l"?e.add(n):e.copy(n),t.lineTo(e.x,e.y),s.copy(e);else if(n.type==="c"||n.type==="C")n.type==="c"?(t.bezierCurveTo(e.x+n.x1,e.y+n.y1,e.x+n.x2,e.y+n.y2,e.x+n.x,e.y+n.y),s.x=e.x+n.x2,s.y=e.y+n.y2,e.add(n)):(t.bezierCurveTo(n.x1,n.y1,n.x2,n.y2,n.x,n.y),s.x=n.x2,s.y=n.y2,e.copy(n));else if(n.type==="s"||n.type==="S")n.type==="s"?(t.bezierCurveTo(et(e.x,s.x),et(e.y,s.y),e.x+n.x2,e.y+n.y2,e.x+n.x,e.y+n.y),s.x=e.x+n.x2,s.y=e.y+n.y2,e.add(n)):(t.bezierCurveTo(et(e.x,s.x),et(e.y,s.y),n.x2,n.y2,n.x,n.y),s.x=n.x2,s.y=n.y2,e.copy(n));else if(n.type==="q"||n.type==="Q")n.type==="q"?(t.quadraticCurveTo(e.x+n.x1,e.y+n.y1,e.x+n.x,e.y+n.y),s.x=e.x+n.x1,s.y=e.y+n.y1,e.add(n)):(t.quadraticCurveTo(n.x1,n.y1,n.x,n.y),s.x=n.x1,s.y=n.y1,e.copy(n));else if(n.type==="t"||n.type==="T"){const h=et(e.x,s.x),c=et(e.y,s.y);s.x=h,s.y=c,n.type==="t"?(t.quadraticCurveTo(h,c,e.x+n.x,e.y+n.y),e.add(n)):(t.quadraticCurveTo(h,c,n.x,n.y),e.copy(n))}else if(n.type==="a"||n.type==="A"){const h=e.clone();if(n.type==="a"){if(n.x===0&&n.y===0)continue;e.add(n)}else{if(e.equals(n))continue;e.copy(n)}s.copy(e),zt(t,n.rx,n.ry,n.angle,n.largeArcFlag,n.sweepFlag,h,e)}else n.type==="z"||n.type==="Z"?(t.startPoint&&e.copy(t.startPoint),t.closePath()):console.warn("Unsupported commands",n)}}function jt(i){let t,e;const s=[];for(let r=0,o=i.length;r<o;r++){const n=i[r];switch(n.type){case"m":case"M":if(n.x.toFixed(4)===e?.x.toFixed(4)&&n.y.toFixed(4)===e?.y.toFixed(4))continue;s.push(`${n.type} ${n.x} ${n.y}`),e={x:n.x,y:n.y},t={x:n.x,y:n.y};break;case"h":case"H":s.push(`${n.type} ${n.x}`),e={x:n.x,y:e?.y??0};break;case"v":case"V":s.push(`${n.type} ${n.y}`),e={x:e?.x??0,y:n.y};break;case"l":case"L":s.push(`${n.type} ${n.x} ${n.y}`),e={x:n.x,y:n.y};break;case"c":case"C":s.push(`${n.type} ${n.x1} ${n.y1} ${n.x2} ${n.y2} ${n.x} ${n.y}`),e={x:n.x,y:n.y};break;case"s":case"S":s.push(`${n.type} ${n.x2} ${n.y2} ${n.x} ${n.y}`),e={x:n.x,y:n.y};break;case"q":case"Q":s.push(`${n.type} ${n.x1} ${n.y1} ${n.x} ${n.y}`),e={x:n.x,y:n.y};break;case"t":case"T":s.push(`${n.type} ${n.x} ${n.y}`),e={x:n.x,y:n.y};break;case"a":case"A":s.push(`${n.type} ${n.rx} ${n.ry} ${n.angle} ${n.largeArcFlag} ${n.sweepFlag} ${n.x} ${n.y}`),e={x:n.x,y:n.y};break;case"z":case"Z":s.push(n.type),t&&(e={x:t.x,y:t.y});break}}return s.join(" ")}const Ae=/[a-df-z][^a-df-z]*/gi;function kt(i){const t=[],e=i.match(Ae);if(!e)return t;for(let s=0,r=e.length;s<r;s++){const o=e[s],n=o.charAt(0),h=o.slice(1).trim();let c;switch(n){case"m":case"M":c=z(h);for(let a=0,l=c.length;a<l;a+=2)a===0?t.push({type:n,x:c[a],y:c[a+1]}):t.push({type:n==="m"?"l":"L",x:c[a],y:c[a+1]});break;case"h":case"H":c=z(h);for(let a=0,l=c.length;a<l;a++)t.push({type:n,x:c[a]});break;case"v":case"V":c=z(h);for(let a=0,l=c.length;a<l;a++)t.push({type:n,y:c[a]});break;case"l":case"L":c=z(h);for(let a=0,l=c.length;a<l;a+=2)t.push({type:n,x:c[a],y:c[a+1]});break;case"c":case"C":c=z(h);for(let a=0,l=c.length;a<l;a+=6)t.push({type:n,x1:c[a],y1:c[a+1],x2:c[a+2],y2:c[a+3],x:c[a+4],y:c[a+5]});break;case"s":case"S":c=z(h);for(let a=0,l=c.length;a<l;a+=4)t.push({type:n,x2:c[a],y2:c[a+1],x:c[a+2],y:c[a+3]});break;case"q":case"Q":c=z(h);for(let a=0,l=c.length;a<l;a+=4)t.push({type:n,x1:c[a],y1:c[a+1],x:c[a+2],y:c[a+3]});break;case"t":case"T":c=z(h);for(let a=0,l=c.length;a<l;a+=2)t.push({type:n,x:c[a],y:c[a+1]});break;case"a":case"A":c=z(h,[3,4],7);for(let a=0,l=c.length;a<l;a+=7)t.push({type:n,rx:c[a],ry:c[a+1],angle:c[a+2],largeArcFlag:c[a+3],sweepFlag:c[a+4],x:c[a+5],y:c[a+6]});break;case"z":case"Z":t.push({type:n});break;default:console.warn(o)}}return t}const Bt="data:image/svg+xml;",Zt=`${Bt}base64,`,Ut=`${Bt}charset=utf8,`;function Xt(i){if(typeof i=="string"){let t;i.startsWith(Zt)?(i=i.substring(Zt.length,i.length),t=atob(i)):i.startsWith(Ut)?(i=i.substring(Ut.length,i.length),t=decodeURIComponent(i)):t=i;const e=new DOMParser().parseFromString(t,"text/xml"),s=e.querySelector("parsererror");if(s)throw new Error(`${s.textContent??"parser error"}
|
|
2
|
+
${t}`);return e.documentElement}else return i}const ke="px",Ie=90,Wt=["mm","cm","in","pt","pc","px"],Gt={mm:{mm:1,cm:.1,in:1/25.4,pt:72/25.4,pc:6/25.4,px:-1},cm:{mm:10,cm:1,in:1/2.54,pt:72/2.54,pc:6/2.54,px:-1},in:{mm:25.4,cm:2.54,in:1,pt:72,pc:6,px:-1},pt:{mm:25.4/72,cm:2.54/72,in:1/72,pt:1,pc:6/72,px:-1},pc:{mm:25.4/6,cm:2.54/6,in:1/6,pt:72/6,pc:1,px:-1},px:{px:1}};function _(i){let t="px";if(typeof i=="string")for(let s=0,r=Wt.length;s<r;s++){const o=Wt[s];if(i.endsWith(o)){t=o,i=i.substring(0,i.length-o.length);break}}let e;return e=Gt[t][ke],e<0&&(e=Gt[t].in*Ie),e*Number.parseFloat(i)}const Se=new R,xt=new R,Ht=new R,Qt=new R;function Ee(i,t,e){if(!(i.hasAttribute("transform")||i.nodeName==="use"&&(i.hasAttribute("x")||i.hasAttribute("y"))))return null;const s=_e(i);return e.length>0&&s.premultiply(e[e.length-1]),t.copy(s),e.push(s),s}function _e(i){const t=new R,e=Se;if(i.nodeName==="use"&&(i.hasAttribute("x")||i.hasAttribute("y"))&&t.translate(_(i.getAttribute("x")),_(i.getAttribute("y"))),i.hasAttribute("transform")){const s=i.getAttribute("transform").split(")");for(let r=s.length-1;r>=0;r--){const o=s[r].trim();if(o==="")continue;const n=o.indexOf("("),h=o.length;if(n>0&&n<h){const c=o.slice(0,n),a=z(o.slice(n+1));switch(e.identity(),c){case"translate":if(a.length>=1){const l=a[0];let f=0;a.length>=2&&(f=a[1]),e.translate(l,f)}break;case"rotate":if(a.length>=1){let l=0,f=0,y=0;l=a[0]*Math.PI/180,a.length>=3&&(f=a[1],y=a[2]),xt.makeTranslation(-f,-y),Ht.makeRotation(l),Qt.multiplyMatrices(Ht,xt),xt.makeTranslation(f,y),e.multiplyMatrices(xt,Qt)}break;case"scale":a.length>=1&&e.scale(a[0],a[1]??a[0]);break;case"skewX":a.length===1&&e.set(1,Math.tan(a[0]*Math.PI/180),0,0,1,0,0,0,1);break;case"skewY":a.length===1&&e.set(1,0,0,Math.tan(a[0]*Math.PI/180),1,0,0,0,1);break;case"matrix":a.length===6&&e.set(a[0],a[2],a[4],a[1],a[3],a[5],0,0,1);break}}t.premultiply(e)}}return t}function $e(i){return new B().arc(_(i.getAttribute("cx")||0),_(i.getAttribute("cy")||0),_(i.getAttribute("r")||0),0,Math.PI*2)}function Fe(i,t){if(!(!i.sheet||!i.sheet.cssRules||!i.sheet.cssRules.length))for(let e=0;e<i.sheet.cssRules.length;e++){const s=i.sheet.cssRules[e];if(s.type!==1)continue;const r=s.selectorText.split(/,/g).filter(Boolean).map(n=>n.trim()),o={};for(let n=s.style.length,h=0;h<n;h++){const c=s.style.item(h);o[c]=s.style.getPropertyValue(c)}for(let n=0;n<r.length;n++)t[r[n]]=Object.assign(t[r[n]]||{},{...o})}}function Le(i){return new B().ellipse(_(i.getAttribute("cx")||0),_(i.getAttribute("cy")||0),_(i.getAttribute("rx")||0),_(i.getAttribute("ry")||0),0,0,Math.PI*2)}function Ne(i){return new B().moveTo(_(i.getAttribute("x1")||0),_(i.getAttribute("y1")||0)).lineTo(_(i.getAttribute("x2")||0),_(i.getAttribute("y2")||0))}function De(i){const t=new B,e=i.getAttribute("d");return!e||e==="none"?null:(t.addData(e),t)}const Ve=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function qe(i){const t=new B;let e=0;return i.getAttribute("points")?.replace(Ve,(s,r,o)=>{const n=_(r),h=_(o);return e===0?t.moveTo(n,h):t.lineTo(n,h),e++,s}),t.currentCurve.autoClose=!0,t}const Oe=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function Re(i){const t=new B;let e=0;return i.getAttribute("points")?.replace(Oe,(s,r,o)=>{const n=_(r),h=_(o);return e===0?t.moveTo(n,h):t.lineTo(n,h),e++,s}),t.currentCurve.autoClose=!1,t}function ze(i){const t=_(i.getAttribute("x")||0),e=_(i.getAttribute("y")||0),s=_(i.getAttribute("rx")||i.getAttribute("ry")||0),r=_(i.getAttribute("ry")||i.getAttribute("rx")||0),o=_(i.getAttribute("width")),n=_(i.getAttribute("height")),h=1-.551915024494,c=new B;return c.moveTo(t+s,e),c.lineTo(t+o-s,e),(s!==0||r!==0)&&c.bezierCurveTo(t+o-s*h,e,t+o,e+r*h,t+o,e+r),c.lineTo(t+o,e+n-r),(s!==0||r!==0)&&c.bezierCurveTo(t+o,e+n-r*h,t+o-s*h,e+n,t+o-s,e+n),c.lineTo(t+s,e+n),(s!==0||r!==0)&&c.bezierCurveTo(t+s*h,e+n,t,e+n-r*h,t,e+n-r),c.lineTo(t,e+r),(s!==0||r!==0)&&c.bezierCurveTo(t,e+r*h,t+s*h,e,t+s,e),c}function Z(i,t,e){t=Object.assign({},t);let s={};if(i.hasAttribute("class")){const a=i.getAttribute("class").split(/\s/).filter(Boolean).map(l=>l.trim());for(let l=0;l<a.length;l++)s=Object.assign(s,e[`.${a[l]}`])}i.hasAttribute("id")&&(s=Object.assign(s,e[`#${i.getAttribute("id")}`]));for(let a=i.style.length,l=0;l<a;l++){const f=i.style.item(l),y=i.style.getPropertyValue(f);t[f]=y,s[f]=y}function r(a,l,f=o){i.hasAttribute(a)&&(t[l]=f(i.getAttribute(a))),s[a]&&(t[l]=f(s[a]))}function o(a){return a.startsWith("url")&&console.warn("url access in attributes is not implemented."),a}function n(a){return Math.max(0,Math.min(1,_(a)))}function h(a){return Math.max(0,_(a))}function c(a){return a.split(" ").filter(l=>l!=="").map(l=>_(l))}return r("fill","fill"),r("fill-opacity","fillOpacity",n),r("fill-rule","fillRule"),r("opacity","opacity",n),r("stroke","stroke"),r("stroke-opacity","strokeOpacity",n),r("stroke-width","strokeWidth",h),r("stroke-linecap","strokeLinecap"),r("stroke-linejoin","strokeLinejoin"),r("stroke-miterlimit","strokeMiterlimit",h),r("stroke-dasharray","strokeDasharray",c),r("stroke-dashoffset","strokeDashoffset",_),r("visibility","visibility"),t}function It(i,t,e=[],s={}){if(i.nodeType!==1)return e;let r=!1,o=null,n={...t};switch(i.nodeName){case"svg":n=Z(i,n,s);break;case"style":Fe(i,s);break;case"g":n=Z(i,n,s);break;case"path":n=Z(i,n,s),i.hasAttribute("d")&&(o=De(i));break;case"rect":n=Z(i,n,s),o=ze(i);break;case"polygon":n=Z(i,n,s),o=qe(i);break;case"polyline":n=Z(i,n,s),o=Re(i);break;case"circle":n=Z(i,n,s),o=$e(i);break;case"ellipse":n=Z(i,n,s),o=Le(i);break;case"line":n=Z(i,n,s),o=Ne(i);break;case"defs":r=!0;break;case"use":{n=Z(i,n,s);const y=(i.getAttributeNS("http://www.w3.org/1999/xlink","href")||i.getAttribute("href")||"").substring(1),x=i.viewportElement?.getElementById(y);x?It(x,n,e,s):console.warn(`'use node' references non-existent node id: ${y}`);break}default:console.warn(i);break}if(n.display==="none")return e;const h=new R,c=[],a=Ee(i,h,c);o&&(o.applyTransform(h),e.push(o),o.style={...n});const l=i.childNodes;for(let f=0,y=l.length;f<y;f++){const x=l[f];r&&x.nodeName!=="style"&&x.nodeName!=="defs"||It(x,n,e,s)}return a&&(c.pop(),c.length>0?h.copy(c[c.length-1]):h.identity()),e}function je(i){const t=Xt(i);return new Me(It(t,{}),t.getAttribute("viewBox")?.trim().split(" ").map(e=>Number(e)))}function St(i,t,e,s,r){const o=(s-t)*.5,n=(r-e)*.5,h=i*i,c=i*h;return(2*e-2*s+o+n)*c+(-3*e+3*s-2*o-n)*h+o*i+e}function Be(i,t){const e=1-i;return e*e*e*t}function Ze(i,t){const e=1-i;return 3*e*e*i*t}function Ue(i,t){return 3*(1-i)*i*i*t}function Xe(i,t){return i*i*i*t}function Et(i,t,e,s,r){return Be(i,t)+Ze(i,e)+Ue(i,s)+Xe(i,r)}function We(i,t,e=2){const s=t&&t.length,r=s?t[0]*e:i.length;let o=Yt(i,0,r,e,!0);const n=[];if(!o||o.next===o.prev)return n;let h,c,a;if(s&&(o=Je(i,t,o,e)),i.length>80*e){h=1/0,c=1/0;let l=-1/0,f=-1/0;for(let y=e;y<r;y+=e){const x=i[y],u=i[y+1];x<h&&(h=x),u<c&&(c=u),x>l&&(l=x),u>f&&(f=u)}a=Math.max(l-h,f-c),a=a!==0?32767/a:0}return it(o,n,e,h,c,a,0),n}function Yt(i,t,e,s,r){let o;if(r===as(i,t,e,s)>0)for(let n=t;n<e;n+=s)o=ee(n/s|0,i[n],i[n+1],o);else for(let n=e-s;n>=t;n-=s)o=ee(n/s|0,i[n],i[n+1],o);return o&&st(o,o.next)&&(ct(o),o=o.next),o}function W(i,t){if(!i)return i;t||(t=i);let e=i,s;do if(s=!1,!e.steiner&&(st(e,e.next)||L(e.prev,e,e.next)===0)){if(ct(e),e=t=e.prev,e===e.next)break;s=!0}else e=e.next;while(s||e!==t);return t}function it(i,t,e,s,r,o,n){if(!i)return;!n&&o&&ns(i,s,r,o);let h=i;for(;i.prev!==i.next;){const c=i.prev,a=i.next;if(o?He(i,s,r,o):Ge(i)){t.push(c.i,i.i,a.i),ct(i),i=a.next,h=a.next;continue}if(i=a,i===h){n?n===1?(i=Qe(W(i),t),it(i,t,e,s,r,o,2)):n===2&&Ye(i,t,e,s,r,o):it(W(i),t,e,s,r,o,1);break}}}function Ge(i){const t=i.prev,e=i,s=i.next;if(L(t,e,s)>=0)return!1;const r=t.x,o=e.x,n=s.x,h=t.y,c=e.y,a=s.y,l=Math.min(r,o,n),f=Math.min(h,c,a),y=Math.max(r,o,n),x=Math.max(h,c,a);let u=s.next;for(;u!==t;){if(u.x>=l&&u.x<=y&&u.y>=f&&u.y<=x&&rt(r,h,o,c,n,a,u.x,u.y)&&L(u.prev,u,u.next)>=0)return!1;u=u.next}return!0}function He(i,t,e,s){const r=i.prev,o=i,n=i.next;if(L(r,o,n)>=0)return!1;const h=r.x,c=o.x,a=n.x,l=r.y,f=o.y,y=n.y,x=Math.min(h,c,a),u=Math.min(l,f,y),p=Math.max(h,c,a),g=Math.max(l,f,y),P=_t(x,u,t,e,s),b=_t(p,g,t,e,s);let w=i.prevZ,v=i.nextZ;for(;w&&w.z>=P&&v&&v.z<=b;){if(w.x>=x&&w.x<=p&&w.y>=u&&w.y<=g&&w!==r&&w!==n&&rt(h,l,c,f,a,y,w.x,w.y)&&L(w.prev,w,w.next)>=0||(w=w.prevZ,v.x>=x&&v.x<=p&&v.y>=u&&v.y<=g&&v!==r&&v!==n&&rt(h,l,c,f,a,y,v.x,v.y)&&L(v.prev,v,v.next)>=0))return!1;v=v.nextZ}for(;w&&w.z>=P;){if(w.x>=x&&w.x<=p&&w.y>=u&&w.y<=g&&w!==r&&w!==n&&rt(h,l,c,f,a,y,w.x,w.y)&&L(w.prev,w,w.next)>=0)return!1;w=w.prevZ}for(;v&&v.z<=b;){if(v.x>=x&&v.x<=p&&v.y>=u&&v.y<=g&&v!==r&&v!==n&&rt(h,l,c,f,a,y,v.x,v.y)&&L(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function Qe(i,t){let e=i;do{const s=e.prev,r=e.next.next;!st(s,r)&&Kt(s,e,e.next,r)&&ot(s,r)&&ot(r,s)&&(t.push(s.i,e.i,r.i),ct(e),ct(e.next),e=i=r),e=e.next}while(e!==i);return W(e)}function Ye(i,t,e,s,r,o){let n=i;do{let h=n.next.next;for(;h!==n.prev;){if(n.i!==h.i&&os(n,h)){let c=te(n,h);n=W(n,n.next),c=W(c,c.next),it(n,t,e,s,r,o,0),it(c,t,e,s,r,o,0);return}h=h.next}n=n.next}while(n!==i)}function Je(i,t,e,s){const r=[];for(let o=0,n=t.length;o<n;o++){const h=t[o]*s,c=o<n-1?t[o+1]*s:i.length,a=Yt(i,h,c,s,!1);a===a.next&&(a.steiner=!0),r.push(rs(a))}r.sort(Ke);for(let o=0;o<r.length;o++)e=ts(r[o],e);return e}function Ke(i,t){let e=i.x-t.x;if(e===0&&(e=i.y-t.y,e===0)){const s=(i.next.y-i.y)/(i.next.x-i.x),r=(t.next.y-t.y)/(t.next.x-t.x);e=s-r}return e}function ts(i,t){const e=es(i,t);if(!e)return t;const s=te(e,i);return W(s,s.next),W(e,e.next)}function es(i,t){let e=t;const s=i.x,r=i.y;let o=-1/0,n;if(st(i,e))return e;do{if(st(i,e.next))return e.next;if(r<=e.y&&r>=e.next.y&&e.next.y!==e.y){const f=e.x+(r-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(f<=s&&f>o&&(o=f,n=e.x<e.next.x?e:e.next,f===s))return n}e=e.next}while(e!==t);if(!n)return null;const h=n,c=n.x,a=n.y;let l=1/0;e=n;do{if(s>=e.x&&e.x>=c&&s!==e.x&&Jt(r<a?s:o,r,c,a,r<a?o:s,r,e.x,e.y)){const f=Math.abs(r-e.y)/(s-e.x);ot(e,i)&&(f<l||f===l&&(e.x>n.x||e.x===n.x&&ss(n,e)))&&(n=e,l=f)}e=e.next}while(e!==h);return n}function ss(i,t){return L(i.prev,i,t.prev)<0&&L(t.next,i,i.next)<0}function ns(i,t,e,s){let r=i;do r.z===0&&(r.z=_t(r.x,r.y,t,e,s)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==i);r.prevZ.nextZ=null,r.prevZ=null,is(r)}function is(i){let t,e=1;do{let s=i,r;i=null;let o=null;for(t=0;s;){t++;let n=s,h=0;for(let a=0;a<e&&(h++,n=n.nextZ,!!n);a++);let c=e;for(;h>0||c>0&&n;)h!==0&&(c===0||!n||s.z<=n.z)?(r=s,s=s.nextZ,h--):(r=n,n=n.nextZ,c--),o?o.nextZ=r:i=r,r.prevZ=o,o=r;s=n}o.nextZ=null,e*=2}while(t>1);return i}function _t(i,t,e,s,r){return i=(i-e)*r|0,t=(t-s)*r|0,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,i|t<<1}function rs(i){let t=i,e=i;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==i);return e}function Jt(i,t,e,s,r,o,n,h){return(r-n)*(t-h)>=(i-n)*(o-h)&&(i-n)*(s-h)>=(e-n)*(t-h)&&(e-n)*(o-h)>=(r-n)*(s-h)}function rt(i,t,e,s,r,o,n,h){return!(i===n&&t===h)&&Jt(i,t,e,s,r,o,n,h)}function os(i,t){return i.next.i!==t.i&&i.prev.i!==t.i&&!cs(i,t)&&(ot(i,t)&&ot(t,i)&&hs(i,t)&&(L(i.prev,i,t.prev)||L(i,t.prev,t))||st(i,t)&&L(i.prev,i,i.next)>0&&L(t.prev,t,t.next)>0)}function L(i,t,e){return(t.y-i.y)*(e.x-t.x)-(t.x-i.x)*(e.y-t.y)}function st(i,t){return i.x===t.x&&i.y===t.y}function Kt(i,t,e,s){const r=gt(L(i,t,e)),o=gt(L(i,t,s)),n=gt(L(e,s,i)),h=gt(L(e,s,t));return!!(r!==o&&n!==h||r===0&&pt(i,e,t)||o===0&&pt(i,s,t)||n===0&&pt(e,i,s)||h===0&&pt(e,t,s))}function pt(i,t,e){return t.x<=Math.max(i.x,e.x)&&t.x>=Math.min(i.x,e.x)&&t.y<=Math.max(i.y,e.y)&&t.y>=Math.min(i.y,e.y)}function gt(i){return i>0?1:i<0?-1:0}function cs(i,t){let e=i;do{if(e.i!==i.i&&e.next.i!==i.i&&e.i!==t.i&&e.next.i!==t.i&&Kt(e,e.next,i,t))return!0;e=e.next}while(e!==i);return!1}function ot(i,t){return L(i.prev,i,i.next)<0?L(i,t,i.next)>=0&&L(i,i.prev,t)>=0:L(i,t,i.prev)<0||L(i,i.next,t)<0}function hs(i,t){let e=i,s=!1;const r=(i.x+t.x)/2,o=(i.y+t.y)/2;do e.y>o!=e.next.y>o&&e.next.y!==e.y&&r<(e.next.x-e.x)*(o-e.y)/(e.next.y-e.y)+e.x&&(s=!s),e=e.next;while(e!==i);return s}function te(i,t){const e=$t(i.i,i.x,i.y),s=$t(t.i,t.x,t.y),r=i.next,o=t.prev;return i.next=t,t.prev=i,e.next=r,r.prev=e,s.next=e,e.prev=s,o.next=s,s.prev=o,s}function ee(i,t,e,s){const r=$t(i,t,e);return s?(r.next=s.next,r.prev=s,s.next.prev=r,s.next=r):(r.prev=r,r.next=r),r}function ct(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function $t(i,t,e){return{i,x:t,y:e,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function as(i,t,e,s){let r=0;for(let o=t,n=e-s;o<e;o+=s)r+=(i[n]-i[o])*(i[o+1]+i[n+1]),n=o;return r}function Ft(i,t={}){let{vertices:e=[],indices:s=[],holes:r=[],verticesStride:o=2,verticesOffset:n=e.length/o,indicesOffset:h=s.length}=t;const c=We(i,r,2);if(c.length){for(let l=0;l<c.length;l+=3)s[h++]=c[l]+n,s[h++]=c[l+1]+n,s[h++]=c[l+2]+n;let a=n*o;for(let l=0;l<i.length;l+=2)e[a]=i[l],e[a+1]=i[l+1],a+=o}return{vertices:e,indices:s}}const ls=8,dt=11920929e-14,us=1;function se(i,t,e,s,r,o,n,h,c=.5,a=[]){const f=Math.min(.99,Math.max(0,c));let y=(us-f)/1;return y*=y,Lt(i,t,e,s,r,o,n,h,a,y,0),a.push(n,h),a}function Lt(i,t,e,s,r,o,n,h,c,a,l){if(l>ls)return;const f=(i+e)/2,y=(t+s)/2,x=(e+r)/2,u=(s+o)/2,p=(r+n)/2,g=(o+h)/2,P=(f+x)/2,b=(y+u)/2,w=(x+p)/2,v=(u+g)/2,C=(P+w)/2,S=(b+v)/2;if(l>0){let d=n-i,M=h-t;const q=Math.abs((e-n)*M-(s-h)*d),F=Math.abs((r-n)*M-(o-h)*d);if(q>dt&&F>dt){if((q+F)*(q+F)<=a*(d*d+M*M)){c.push(C,S);return}}else if(q>dt){if(q*q<=a*(d*d+M*M)){c.push(C,S);return}}else if(F>dt){if(F*F<=a*(d*d+M*M)){c.push(C,S);return}}else if(d=C-(i+n)/2,M=S-(t+h)/2,d*d+M*M<=a){c.push(C,S);return}}Lt(i,t,f,y,P,b,C,S,c,a,l+1),Lt(C,S,w,v,p,g,n,h,c,a,l+1)}const fs=8,ys=11920929e-14,xs=1;function ne(i,t,e,s,r,o,n=.5,h=[]){const a=Math.min(.99,Math.max(0,n));let l=(xs-a)/1;return l*=l,Nt(h,i,t,e,s,r,o,l,0),h.push(r,o),h}function Nt(i,t,e,s,r,o,n,h,c){if(c>fs)return;const a=(t+s)/2,l=(e+r)/2,f=(s+o)/2,y=(r+n)/2,x=(a+f)/2,u=(l+y)/2;let p=o-t,g=n-e;const P=Math.abs((s-o)*g-(r-n)*p);if(P>ys){if(P*P<=h*(p*p+g*g)){i.push(x,u);return}}else if(p=x-(t+o)/2,g=u-(e+n)/2,p*p+g*g<=h){i.push(x,u);return}Nt(i,t,e,a,l,x,u,h,c+1),Nt(i,x,u,f,y,o,n,h,c+1)}function ps(i){let t=0;const e=i.length;for(let s=0;s<e;s+=2){const r=i[s],o=i[s+1],n=i[(s+2)%(e-1)],h=i[(s+3)%e];t+=r*h-n*o}return t/2}function gs(i,t){let e=!1;const[s,r]=i,o=t.length/2;for(let n=0,h=o-1;n<o;h=n++){const c=t[n*2],a=t[n*2+1],l=t[h*2],f=t[h*2+1];a>r!=f>r&&s<(l-c)*(r-a)/(f-a)+c&&(e=!e)}return e}function ie(i,t){const[e,s]=i,r=t.length/2;let o=0;for(let n=0,h=r-1;n<r;h=n++){const c=t[n*2],a=t[n*2+1],l=t[h*2],f=t[h*2+1];a<=s?f>s&&re([l,f],[c,a],[e,s])>0&&o++:f<=s&&re([l,f],[c,a],[e,s])<0&&o--}return o!==0}function re(i,t,e){return(t[0]-i[0])*(e[1]-i[1])-(e[0]-i[0])*(t[1]-i[1])}function ds(i,t){const e=1-i;return e*e*t}function ms(i,t){return 2*(1-i)*i*t}function Ms(i,t){return i*i*t}function Dt(i,t,e,s){return ds(i,t)+ms(i,e)+Ms(i,s)}const ws=1e-4,oe=1e-4;function ce(i,t={}){const{vertices:e=[],indices:s=[],lineStyle:r={alignment:.5,cap:"butt",join:"miter",width:1,miterLimit:10},flipAlignment:o=!1,closed:n=!0}=t,h=ws;if(i.length===0)return{vertices:e,indices:s};const c=r;let a=c.alignment;if(r.alignment!==.5){let $=vs(i);o&&($*=-1),a=(a-.5)*$+.5}const l={x:i[0],y:i[1]},f={x:i[i.length-2],y:i[i.length-1]},y=n,x=Math.abs(l.x-f.x)<h&&Math.abs(l.y-f.y)<h;if(y){i=i.slice(),x&&(i.pop(),i.pop(),f.x=i[i.length-2],f.y=i[i.length-1]);const $=(l.x+f.x)*.5,X=(f.y+l.y)*.5;i.unshift($,X),i.push($,X)}const u=e,p=i.length/2;let g=i.length;const P=u.length/2,b=c.width/2,w=b*b,v=c.miterLimit*c.miterLimit;let C=i[0],S=i[1],d=i[2],M=i[3],q=0,F=0,k=-(S-M),I=C-d,N=0,D=0,O=Math.sqrt(k*k+I*I);k/=O,I/=O,k*=b,I*=b;const at=a,T=(1-at)*2,E=at*2;y||(c.cap==="round"?g+=G(C-k*(T-E)*.5,S-I*(T-E)*.5,C-k*T,S-I*T,C+k*E,S+I*E,u,!0)+2:c.cap==="square"&&(g+=he(C,S,k,I,T,E,!0,u))),u.push(C-k*T,S-I*T),u.push(C+k*E,S+I*E);for(let $=1;$<p-1;++$){C=i[($-1)*2],S=i[($-1)*2+1],d=i[$*2],M=i[$*2+1],q=i[($+1)*2],F=i[($+1)*2+1],k=-(S-M),I=C-d,O=Math.sqrt(k*k+I*I),k/=O,I/=O,k*=b,I*=b,N=-(M-F),D=d-q,O=Math.sqrt(N*N+D*D),N/=O,D/=O,N*=b,D*=b;const X=d-C,lt=S-M,ut=d-q,ft=F-M,ve=X*ut+lt*ft,vt=lt*ut-ft*X,yt=vt<0;if(Math.abs(vt)<.001*Math.abs(ve)){u.push(d-k*T,M-I*T),u.push(d+k*E,M+I*E),ve>=0&&(c.join==="round"?g+=G(d,M,d-k*T,M-I*T,d-N*T,M-D*T,u,!1)+4:g+=2,u.push(d-N*E,M-D*E),u.push(d+N*T,M+D*T));continue}const Pe=(-k+C)*(-I+M)-(-k+d)*(-I+S),Te=(-N+q)*(-D+M)-(-N+d)*(-D+F),Pt=(X*Te-ut*Pe)/vt,Tt=(ft*Pe-lt*Te)/vt,Ot=(Pt-d)*(Pt-d)+(Tt-M)*(Tt-M),Q=d+(Pt-d)*T,Y=M+(Tt-M)*T,J=d-(Pt-d)*E,K=M-(Tt-M)*E,Fs=Math.min(X*X+lt*lt,ut*ut+ft*ft),Ce=yt?T:E,Ls=Fs+Ce*Ce*w;Ot<=Ls?c.join==="bevel"||Ot/w>v?(yt?(u.push(Q,Y),u.push(d+k*E,M+I*E),u.push(Q,Y),u.push(d+N*E,M+D*E)):(u.push(d-k*T,M-I*T),u.push(J,K),u.push(d-N*T,M-D*T),u.push(J,K)),g+=2):c.join==="round"?yt?(u.push(Q,Y),u.push(d+k*E,M+I*E),g+=G(d,M,d+k*E,M+I*E,d+N*E,M+D*E,u,!0)+4,u.push(Q,Y),u.push(d+N*E,M+D*E)):(u.push(d-k*T,M-I*T),u.push(J,K),g+=G(d,M,d-k*T,M-I*T,d-N*T,M-D*T,u,!1)+4,u.push(d-N*T,M-D*T),u.push(J,K)):(u.push(Q,Y),u.push(J,K)):(u.push(d-k*T,M-I*T),u.push(d+k*E,M+I*E),c.join==="round"?yt?g+=G(d,M,d+k*E,M+I*E,d+N*E,M+D*E,u,!0)+2:g+=G(d,M,d-k*T,M-I*T,d-N*T,M-D*T,u,!1)+2:c.join==="miter"&&Ot/w<=v&&(yt?(u.push(J,K),u.push(J,K)):(u.push(Q,Y),u.push(Q,Y)),g+=2),u.push(d-N*T,M-D*T),u.push(d+N*E,M+D*E),g+=2)}C=i[(p-2)*2],S=i[(p-2)*2+1],d=i[(p-1)*2],M=i[(p-1)*2+1],k=-(S-M),I=C-d,O=Math.sqrt(k*k+I*I),k/=O,I/=O,k*=b,I*=b,u.push(d-k*T,M-I*T),u.push(d+k*E,M+I*E),y||(c.cap==="round"?g+=G(d-k*(T-E)*.5,M-I*(T-E)*.5,d-k*T,M-I*T,d+k*E,M+I*E,u,!1)+2:c.cap==="square"&&(g+=he(d,M,k,I,T,E,!1,u)));const $s=oe*oe;for(let $=P;$<g+P-2;++$)C=u[$*2],S=u[$*2+1],d=u[($+1)*2],M=u[($+1)*2+1],q=u[($+2)*2],F=u[($+2)*2+1],!(Math.abs(C*(M-F)+d*(F-S)+q*(S-M))<$s)&&s.push($,$+1,$+2);return{vertices:e,indices:s}}function vs(i){const t=i.length;if(t<6)return 1;let e=0;for(let s=0,r=i[t-2],o=i[t-1];s<t;s+=2){const n=i[s],h=i[s+1];e+=(n-r)*(h+o),r=n,o=h}return e<0?-1:1}function he(i,t,e,s,r,o,n,h){const c=i-e*r,a=t-s*r,l=i+e*o,f=t+s*o;let y,x;n?(y=s,x=-e):(y=-s,x=e);const u=c+y,p=a+x,g=l+y,P=f+x;return h.push(u,p),h.push(g,P),2}function G(i,t,e,s,r,o,n,h){const c=e-i,a=s-t;let l=Math.atan2(c,a),f=Math.atan2(r-i,o-t);h&&l<f?l+=Math.PI*2:!h&&l>f&&(f+=Math.PI*2);let y=l;const x=f-l,u=Math.abs(x),p=Math.sqrt(c*c+a*a),g=(15*u*Math.sqrt(p)/Math.PI>>0)+1,P=x/g;if(y+=P,h){n.push(i,t),n.push(e,s);for(let b=1,w=y;b<g;b++,w+=P)n.push(i,t),n.push(i+Math.sin(w)*p,t+Math.cos(w)*p);n.push(i,t),n.push(r,o)}else{n.push(e,s),n.push(i,t);for(let b=1,w=y;b<g;b++,w+=P)n.push(i+Math.sin(w)*p,t+Math.cos(w)*p),n.push(i,t);n.push(r,o),n.push(i,t)}return g*2}class H{arcLengthDivision=200;_arcLengths;getPointAt(t,e=new m){return this.getPoint(this.getUToTMapping(t),e)}isClockwise(){return!1}getControlPointRefs(){return[]}applyTransform(t){const e=typeof t=="function";return this.getControlPointRefs().forEach(s=>{e?t(s):s.applyMatrix3(t)}),this}getUnevenVertices(t=5,e=[]){const s=new m;for(let r=0,o=Math.max(1,t)-1;r<=o;r++)this.getPoint(r/o,s),e.push(s.x,s.y);return e}getSpacedVertices(t=5,e=[]){const s=new m;for(let r=0,o=Math.max(1,t)-1;r<=o;r++)this.getPointAt(r/o,s),e.push(s.x,s.y);return e}getAdaptiveVertices(t=[]){return this.getUnevenVertices(5,t)}_verticesToPoints(t,e=[]){for(let s=0,r=t.length;s<r;s+=2){const o=t[s],n=t[s+1];e.push(new m(o,n))}return e}getSpacedPoints(t,e=[]){const s=this.getSpacedVertices(t);return this._verticesToPoints(s,e),e}getUnevenPoints(t,e=[]){const s=this.getUnevenVertices(t);return this._verticesToPoints(s,e),e}getAdaptivePoints(t=[]){const e=this.getAdaptiveVertices();return this._verticesToPoints(e,t),t}getPoints(t,e=[]){let s;return t?s=this.getUnevenVertices(t):s=this.getAdaptiveVertices(),this._verticesToPoints(s,e),e}getLength(){const t=this.getLengths();return t[t.length-1]}getLengths(){return(!this._arcLengths||this._arcLengths.length!==this.arcLengthDivision+1)&&this.updateLengths(),this._arcLengths}updateLengths(){const t=this.arcLengthDivision,e=[0];for(let s=0,r=this.getPoint(0),o=1;o<=t;o++){const n=this.getPoint(o/t);s+=n.distanceTo(r),e.push(s),r=n}this._arcLengths=e}getUToTMapping(t,e){const s=this.getLengths(),r=s.length,o=e??t*s[r-1];if(r<2)return o/s[0];let n=0,h=0,c=r-1,a;for(;h<=c;)if(n=Math.floor(h+(c-h)/2),a=s[n]-o,a<0)h=n+1;else if(a>0)c=n-1;else{c=n;break}if(n=c,s[n]===o)return n/(r-1);const l=s[n],y=s[n+1]-l,x=(o-l)/y;return(n+x)/(r-1)}getTangent(t,e=new m){const r=Math.max(0,t-1e-4),o=Math.min(1,t+1e-4);return e.copy(this.getPoint(o).sub(this.getPoint(r)).normalize())}getTangentAt(t,e){return this.getTangent(this.getUToTMapping(t),e)}getNormal(t,e=new m){return this.getTangent(t,e),e.set(-e.y,e.x).normalize()}getNormalAt(t,e){return this.getNormal(this.getUToTMapping(t),e)}getTForPoint(t,e=.001){let s=0,r=1,o=(s+r)/2;for(;r-s>e;){o=(s+r)/2;const n=this.getPoint(o);if(n.distanceTo(t)<e)return o;n.x<t.x?s=o:r=o}return o}getMinMax(t=m.MAX,e=m.MIN){const s=this.getPoints();for(let r=0,o=s.length;r<o;r++){const n=s[r];t.min(n),e.max(n)}return{min:t.finite(),max:e.finite()}}getBoundingBox(){const{min:t,max:e}=this.getMinMax();return new U(t.x,t.y,e.x-t.x,e.y-t.y)}getFillVertices(t){return this.getAdaptiveVertices()}fillTriangulate(t){return Ft(this.getFillVertices(t),t)}strokeTriangulate(t){return ce(this.getAdaptiveVertices(),t)}toCommands(){const t=[],e=this.getPoints();for(let s=0,r=e.length;s<r;s++){const o=e[s];s===0?t.push({type:"M",x:o.x,y:o.y}):t.push({type:"L",x:o.x,y:o.y})}return t}toData(){return jt(this.toCommands())}drawTo(t){return this.toCommands().forEach(e=>{switch(e.type){case"M":t.moveTo(e.x,e.y);break;case"L":t.lineTo(e.x,e.y);break}}),this}copy(t){return this.arcLengthDivision=t.arcLengthDivision,this}clone(){return new this.constructor().copy(this)}}const Ps=new R,ae=new R,le=new R,mt=new m;class Vt extends H{constructor(t=new m,e=new m,s=new m,r=0,o=0,n=Math.PI*2,h=!1){super(),this._center=t,this._radius=e,this._diff=s,this.rotate=r,this.startAngle=o,this.endAngle=n,this.clockwise=h}get cx(){return this._center.x}set cx(t){this._center.x=t}get cy(){return this._center.y}set cy(t){this._center.y=t}get rx(){return this._radius.x}set rx(t){this._radius.x=t}get ry(){return this._radius.y}set ry(t){this._radius.y=t}get dx(){return this._diff.x}set dx(t){this._diff.x=t}get dy(){return this._diff.y}set dy(t){this._diff.y=t}isClockwise(){return this.clockwise}_getDeltaAngle(){const t=Math.PI*2;let e=this.endAngle-this.startAngle;const s=Math.abs(e)<Number.EPSILON;return e=(e%t+t)%t,s?e=0:this.clockwise||(e=e===0?-t:e-t),e}getPoint(t,e=new m){const s=this._getDeltaAngle(),r=this.startAngle+t*s;let o=this.cx+this.rx*Math.cos(r),n=this.cy+this.ry*Math.sin(r);if(this.rotate!==0){const h=Math.cos(this.rotate),c=Math.sin(this.rotate),a=o-this.cx,l=n-this.cy;o=a*h-l*c+this.cx,n=a*c+l*h+this.cy}return e.set(o,n)}toCommands(){const{cx:t,cy:e,rx:s,ry:r,startAngle:o,endAngle:n,clockwise:h,rotate:c}=this,a=t+s*Math.cos(o)*Math.cos(c)-r*Math.sin(o)*Math.sin(c),l=e+s*Math.cos(o)*Math.sin(c)+r*Math.sin(o)*Math.cos(c),f=Math.abs(o-n),y=f>Math.PI?1:0,x=h?1:0,u=c*180/Math.PI;if(f>=2*Math.PI){const p=o+Math.PI,g=t+s*Math.cos(p)*Math.cos(c)-r*Math.sin(p)*Math.sin(c),P=e+s*Math.cos(p)*Math.sin(c)+r*Math.sin(p)*Math.cos(c);return[{type:"M",x:a,y:l},{type:"A",rx:s,ry:r,angle:u,largeArcFlag:0,sweepFlag:x,x:g,y:P},{type:"A",rx:s,ry:r,angle:u,largeArcFlag:0,sweepFlag:x,x:a,y:l}]}else{const p=t+s*Math.cos(n)*Math.cos(c)-r*Math.sin(n)*Math.sin(c),g=e+s*Math.cos(n)*Math.sin(c)+r*Math.sin(n)*Math.cos(c);return[{type:"M",x:a,y:l},{type:"A",rx:s,ry:r,angle:u,largeArcFlag:y,sweepFlag:x,x:p,y:g}]}}drawTo(t){const{cx:e,cy:s,rx:r,ry:o,rotate:n,startAngle:h,endAngle:c,clockwise:a}=this;return t.ellipse(e,s,r,o,n,h,c,!a),this}applyTransform(t){return mt.set(this.cx,this.cy),mt.applyMatrix3(t),this.cx=mt.x,this.cy=mt.y,bs(t)?Ts(this,t):Cs(this,t),this}getControlPointRefs(){return[this._center]}_getAdaptiveVerticesByArc(t=[]){const{cx:e,cy:s,rx:r,ry:o,dx:n,dy:h,startAngle:c,endAngle:a,clockwise:l,rotate:f}=this,y=!l;let x=Math.abs(c-a);(!y&&c>a||y&&a>c)&&(x=2*Math.PI-x);const u=Math.max(12,Math.floor(12*r**(1/3)*(x/Math.PI)));let p=x/u,g=c;p*=y?-1:1;const P=Math.cos(y?f:-f),b=Math.sin(y?f:-f);for(let w=0;w<u+1;w++){const v=n+Math.cos(g)*r,C=h+Math.sin(g)*o,S=v*P-C*b,d=v*b+C*P;t.push(e+S,s+d),g+=p}return t}_getAdaptiveVerticesByCircle(t=[]){const{cx:e,cy:s,rx:r,ry:o,dx:n,dy:h,rotate:c,clockwise:a}=this;if(!(r>=0&&o>=0&&n>=0&&h>=0))return t;const l=Math.ceil(2.3*Math.sqrt(r+o)),f=l*8+(n?4:0)+(h?4:0),y=[];if(f===0)return t;{const p=y.length;if(l===0)y[p]=y[p+6]=e+n,y[p+1]=y[p+3]=s+h,y[p+2]=y[p+4]=e-n,y[p+5]=y[p+7]=s-h;else{let g=p,P=p+l*4+(n?2:0)+2,b=P,w=f,v=n+r,C=h,S=e+v,d=e-v,M=s+C;if(y[g++]=S,y[g++]=M,y[--P]=M,y[--P]=d,h){const F=s-C;y[b++]=d,y[b++]=F,y[--w]=F,y[--w]=S}for(let F=1;F<l;F++){const k=Math.PI/2*(F/l),I=n+Math.cos(k)*r,N=h+Math.sin(k)*o,D=e+I,O=e-I,at=s+N,T=s-N;y[g++]=D,y[g++]=at,y[--P]=at,y[--P]=O,y[b++]=O,y[b++]=T,y[--w]=T,y[--w]=D}v=n,C=h+o,S=e+v,d=e-v,M=s+C;const q=s-C;y[g++]=S,y[g++]=M,y[--w]=q,y[--w]=S,n&&(y[g++]=d,y[g++]=M,y[--w]=q,y[--w]=d)}}const x=Math.cos(a?-c:c),u=Math.sin(a?-c:c);for(let p=0;p<y.length;p+=2){const g=y[p],P=y[p+1],b=g-e,w=P-s,v=b*x-w*u,C=b*u+w*x;t.push(e+v,s+C)}return t}getAdaptiveVertices(t=[]){return this.startAngle===0&&this.endAngle===Math.PI*2?this._getAdaptiveVerticesByCircle(t):this._getAdaptiveVerticesByArc(t)}copy(t){return super.copy(t),this.cx=t.cx,this.cy=t.cy,this.rx=t.rx,this.ry=t.ry,this.dx=t.dx,this.dy=t.dy,this.startAngle=t.startAngle,this.endAngle=t.endAngle,this.clockwise=t.clockwise,this.rotate=t.rotate,this}}function Ts(i,t){const e=i.rx,s=i.ry,r=Math.cos(i.rotate),o=Math.sin(i.rotate),n=new m(e*r,e*o),h=new m(-s*o,s*r),c=n.applyMatrix3(t),a=h.applyMatrix3(t),l=Ps.set(c.x,a.x,0,c.y,a.y,0,0,0,1),f=ae.copy(l).invert(),u=le.copy(f).transpose().multiply(f).elements,p=As(u[0],u[1],u[4]),g=Math.sqrt(p.rt1),P=Math.sqrt(p.rt2);if(i.rx=1/g,i.ry=1/P,i.rotate=Math.atan2(p.sn,p.cs),!((i.endAngle-i.startAngle)%(2*Math.PI)<Number.EPSILON)){const w=ae.set(g,0,0,0,P,0,0,0,1),v=le.set(p.cs,p.sn,0,-p.sn,p.cs,0,0,0,1),C=w.multiply(v).multiply(l),S=d=>{const{x:M,y:q}=new m(Math.cos(d),Math.sin(d)).applyMatrix3(C);return Math.atan2(q,M)};i.startAngle=S(i.startAngle),i.endAngle=S(i.endAngle),ue(t)&&(i.clockwise=!i.clockwise)}}function Cs(i,t){const e=fe(t),s=ye(t);i.rx*=e,i.ry*=s;const r=e>Number.EPSILON?Math.atan2(t.elements[1],t.elements[0]):Math.atan2(-t.elements[3],t.elements[4]);i.rotate+=r,ue(t)&&(i.startAngle*=-1,i.endAngle*=-1,i.clockwise=!i.clockwise)}function ue(i){const t=i.elements;return t[0]*t[4]-t[1]*t[3]<0}function bs(i){const t=i.elements,e=t[0]*t[3]+t[1]*t[4];if(e===0)return!1;const s=fe(i),r=ye(i);return Math.abs(e/(s*r))>Number.EPSILON}function fe(i){const t=i.elements;return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function ye(i){const t=i.elements;return Math.sqrt(t[3]*t[3]+t[4]*t[4])}function As(i,t,e){let s,r,o,n,h;const c=i+e,a=i-e,l=Math.sqrt(a*a+4*t*t);return c>0?(s=.5*(c+l),h=1/s,r=i*h*e-t*h*t):c<0?r=.5*(c-l):(s=.5*l,r=-.5*l),a>0?o=a+l:o=a-l,Math.abs(o)>2*Math.abs(t)?(h=-2*t/o,n=1/Math.sqrt(1+h*h),o=h*n):Math.abs(t)===0?(o=1,n=0):(h=-.5*o/t,o=1/Math.sqrt(1+h*h),n=h*o),a>0&&(h=o,o=-n,n=h),{rt1:s,rt2:r,cs:o,sn:n}}class xe extends Vt{constructor(t=0,e=0,s=1,r=0,o=Math.PI*2,n=!1){super(new m(t,e),new m(s,s),new m,0,r,o,n)}drawTo(t){const{cx:e,cy:s,rx:r,startAngle:o,endAngle:n,clockwise:h}=this;return t.arc(e,s,r,o,n,!h),this}getAdaptiveVertices(t=[]){const{cx:e,cy:s,rx:r,startAngle:o,endAngle:n,clockwise:h}=this;let c=Math.abs(o-n);(!h&&o>n||h&&n>o)&&(c=2*Math.PI-c);let a=Math.max(6,Math.floor(6*r**(1/3)*(c/Math.PI)));a=Math.max(a,3);let l=c/a,f=o;l*=h?1:-1;for(let y=0;y<a+1;y++){const x=Math.cos(f),u=Math.sin(f),p=e+x*r,g=s+u*r;t.push(p,g),f+=l}return t}}class j extends H{constructor(t=new m,e=new m){super(),this.p1=t,this.p2=e}static from(t,e,s,r){return new j(new m(t,e),new m(s,r))}getPoint(t,e=new m){return t===1?e.copy(this.p2):e.copy(this.p2).sub(this.p1).scale(t).add(this.p1),e}getPointAt(t,e=new m){return this.getPoint(t,e)}getTangent(t,e=new m){return e.subVectors(this.p2,this.p1).normalize()}getTangentAt(t,e=new m){return this.getTangent(t,e)}getControlPointRefs(){return[this.p1,this.p2]}getAdaptiveVertices(t=[]){return t.push(this.p1.x,this.p1.y,this.p2.x,this.p2.y),t}getMinMax(t=m.MAX,e=m.MIN){const{p1:s,p2:r}=this;return t.x=Math.min(t.x,s.x,r.x),t.y=Math.min(t.y,s.y,r.y),e.x=Math.max(e.x,s.x,r.x),e.y=Math.max(e.y,s.y,r.y),{min:t.finite(),max:e.finite()}}toCommands(){const{p1:t,p2:e}=this;return[{type:"M",x:t.x,y:t.y},{type:"L",x:e.x,y:e.y}]}getFillVertices(t={}){const e=Math.min(this.p1.x,this.p2.x),s=Math.max(this.p1.x,this.p2.x),r=Math.min(this.p1.y,this.p2.y),o=Math.max(this.p1.y,this.p2.y),n=e,h=r,c=s-e||t.style?.strokeWidth||0,a=o-r||t.style?.strokeWidth||0;return[n,h,n+c,h,n+c,h+a,n,h+a]}drawTo(t){const{p1:e,p2:s}=this;return t.lineTo(e.x,e.y),t.lineTo(s.x,s.y),this}copy(t){return super.copy(t),this.p1.copy(t.p1),this.p2.copy(t.p2),this}}class nt extends H{constructor(t=[]){super(),this.curves=t}getFlatCurves(){return this.curves.flatMap(t=>t instanceof nt?t.getFlatCurves():t)}addCurve(t){return this.curves.push(t),this}getPoint(t,e=new m){const s=t*this.getLength(),r=this.getLengths();let o=0;for(;o<r.length;){if(r[o]>=s){const n=r[o]-s,h=this.curves[o],c=h.getLength();return h.getPointAt(c===0?0:1-n/c,e)}o++}return e}updateLengths(){const t=[];for(let e=0,s=0,r=this.curves.length;e<r;e++)s+=this.curves[e].getLength(),t.push(s);this._arcLengths=t}getControlPointRefs(){return this.curves.flatMap(t=>t.getControlPointRefs())}_removeNextPointIfEqualPrevPoint(t,e){const s=[t[e-1],t[e]],r=[t[e+1],t[e+2]];return s[0]===r[0]&&s[1]===r[1]&&t.splice(e+1,2),t}getSpacedVertices(t=5,e=[]){let s;return this.curves.forEach(r=>{r.getSpacedVertices(t,e),s&&this._removeNextPointIfEqualPrevPoint(e,s),s=e.length-1}),e}getAdaptiveVertices(t=[]){let e;return this.curves.forEach(s=>{s.getAdaptiveVertices(t),e&&this._removeNextPointIfEqualPrevPoint(t,e),e=t.length-1}),t}strokeTriangulate(t){return this.curves.length===1?this.curves[0].strokeTriangulate(t):super.strokeTriangulate(t)}getFillVertices(t){if(this.curves.length===1)return this.curves[0].getFillVertices(t);{const e=[];let s;return this.curves.forEach(r=>{let o;r instanceof j?o=r.getAdaptiveVertices():o=r.getFillVertices(t),e.push(...o),s&&this._removeNextPointIfEqualPrevPoint(e,s),s=e.length-1}),e}}applyTransform(t){return this.curves.forEach(e=>e.applyTransform(t)),this}getMinMax(t=m.MAX,e=m.MIN){return this.curves.forEach(s=>s.getMinMax(t,e)),{min:t.finite(),max:e.finite()}}getBoundingBox(){const{min:t,max:e}=this.getMinMax();return new U(t.x,t.y,e.x-t.x,e.y-t.y)}toCommands(){return this.curves.flatMap(t=>t.toCommands())}drawTo(t){const e=this.curves[0]?.getPoint(0);return e&&t.moveTo(e.x,e.y),this.curves.forEach(s=>s.drawTo(t)),this}copy(t){return super.copy(t),this.curves=t.curves.map(e=>e.clone()),this}}class Mt extends H{constructor(t=new m,e=new m,s=new m,r=new m){super(),this.p1=t,this.cp1=e,this.cp2=s,this.p2=r}static from(t,e,s,r,o,n,h,c){return new Mt(new m(t,e),new m(s,r),new m(o,n),new m(h,c))}getPoint(t,e=new m){const{p1:s,cp1:r,cp2:o,p2:n}=this;return e.set(Et(t,s.x,r.x,o.x,n.x),Et(t,s.y,r.y,o.y,n.y))}getAdaptiveVertices(t=[]){return se(this.p1.x,this.p1.y,this.cp1.x,this.cp1.y,this.cp2.x,this.cp2.y,this.p2.x,this.p2.y,.5,t)}getControlPointRefs(){return[this.p1,this.cp1,this.cp2,this.p2]}_solveQuadratic(t,e,s){const r=e*e-4*t*s;if(r<0)return[];const o=Math.sqrt(r),n=(-e+o)/(2*t),h=(-e-o)/(2*t);return[n,h].filter(c=>c>=0&&c<=1)}getMinMax(t=m.MAX,e=m.MIN){const{p1:s,cp1:r,cp2:o,p2:n}=this,h=this._solveQuadratic(3*(r.x-s.x),6*(o.x-r.x),3*(n.x-o.x)),c=this._solveQuadratic(3*(r.y-s.y),6*(o.y-r.y),3*(n.y-o.y)),a=[0,1,...h,...c];return((f,y)=>{for(const x of f)for(let u=0;u<=y;u++){const p=u/y-.5,g=Math.min(1,Math.max(0,x+p)),P=this.getPoint(g);t.x=Math.min(t.x,P.x),t.y=Math.min(t.y,P.y),e.x=Math.max(e.x,P.x),e.y=Math.max(e.y,P.y)}})(a,10),{min:t.finite(),max:e.finite()}}toCommands(){const{p1:t,cp1:e,cp2:s,p2:r}=this;return[{type:"M",x:t.x,y:t.y},{type:"C",x1:e.x,y1:e.y,x2:s.x,y2:s.y,x:r.x,y:r.y}]}drawTo(t){const{p1:e,cp1:s,cp2:r,p2:o}=this;return t.lineTo(e.x,e.y),t.bezierCurveTo(s.x,s.y,r.x,r.y,o.x,o.y),this}copy(t){return super.copy(t),this.p1.copy(t.p1),this.cp1.copy(t.cp1),this.cp2.copy(t.cp2),this.p2.copy(t.p2),this}}class pe extends Vt{constructor(t=0,e=0,s=1,r=1,o=0,n=0,h=Math.PI*2,c=!1){super(new m(t,e),new m(s,r),new m,o,n,h,c)}drawTo(t){return t.ellipse(this.cx,this.cy,this.rx,this.ry,this.rotate,this.startAngle,this.endAngle,!this.clockwise),this}}class qt extends nt{}class ks extends qt{constructor(t=0,e=0,s=1,r=3){super(),this.cx=t,this.cy=e,this.radius=s,this.sideCount=r,this.update()}update(){const{cx:t,cy:e,radius:s,sideCount:r}=this,o=[];for(let h=0;h<r;h++){const c=h*2*Math.PI/r-.5*Math.PI;o.push(new m(s*Math.cos(c),s*Math.sin(c)).add({x:t,y:e}))}const n=[];for(let h=0;h<r;h++)n.push(new j(o[h],o[(h+1)%r]));return this.curves=n,this}copy(t){return super.copy(t),this.cx=t.cx,this.cy=t.cy,this.radius=t.radius,this.sideCount=t.sideCount,this.update(),this}}class wt extends H{constructor(t=new m,e=new m,s=new m){super(),this.p1=t,this.cp=e,this.p2=s}static from(t,e,s,r,o,n){return new wt(new m(t,e),new m(s,r),new m(o,n))}getPoint(t,e=new m){const{p1:s,cp:r,p2:o}=this;return e.set(Dt(t,s.x,r.x,o.x),Dt(t,s.y,r.y,o.y)),e}getControlPointRefs(){return[this.p1,this.cp,this.p2]}getAdaptiveVertices(t=[]){return ne(this.p1.x,this.p1.y,this.cp.x,this.cp.y,this.p2.x,this.p2.y,.5,t)}getMinMax(t=m.MAX,e=m.MIN){const{p1:s,cp:r,p2:o}=this,n=.5*(s.x+r.x),h=.5*(s.y+r.y),c=.5*(s.x+o.x),a=.5*(s.y+o.y);return t.x=Math.min(t.x,s.x,o.x,n,c),t.y=Math.min(t.y,s.y,o.y,h,a),e.x=Math.max(e.x,s.x,o.x,n,c),e.y=Math.max(e.y,s.y,o.y,h,a),{min:t.finite(),max:e.finite()}}toCommands(){const{p1:t,cp:e,p2:s}=this;return[{type:"M",x:t.x,y:t.y},{type:"Q",x1:e.x,y1:e.y,x:s.x,y:s.y}]}drawTo(t){const{p1:e,cp:s,p2:r}=this;return t.lineTo(e.x,e.y),t.quadraticCurveTo(s.x,s.y,r.x,r.y),this}copy(t){return super.copy(t),this.p1.copy(t.p1),this.cp.copy(t.cp),this.p2.copy(t.p2),this}}class ge extends qt{constructor(t=0,e=0,s=0,r=0){super(),this.x=t,this.y=e,this.width=s,this.height=r,this.update()}update(){const{x:t,y:e,width:s,height:r}=this,o=[new m(t,e),new m(t+s,e),new m(t+s,e+r),new m(t,e+r)];return this.curves=[new j(o[0],o[1]),new j(o[1],o[2]),new j(o[2],o[3]),new j(o[3],o[0])],this}drawTo(t){return t.rect(this.x,this.y,this.width,this.height),this}getFillVertices(t={}){const{x:e,y:s,width:r,height:o}=this;return[e,s,e+r,s,e+r,s+o,e,s+o]}copy(t){return super.copy(t),this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this.update(),this}}class de extends Vt{constructor(t=0,e=0,s=1,r=1,o=1){super(),this.x=t,this.y=e,this.width=s,this.height=r,this.radius=o,this.update()}update(){const{x:t,y:e,width:s,height:r,radius:o}=this,n=s/2,h=r/2,c=t+n,a=e+h,l=Math.max(0,Math.min(o,Math.min(n,h))),f=l;return this._center=new m(c,a),this._radius=new m(l,f),this._diff=new m(n-l,h-f),this}drawTo(t){const{x:e,y:s,width:r,height:o,radius:n}=this;return t.roundRect(e,s,r,o,n),this}copy(t){return super.copy(t),this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this.radius=t.radius,this.update(),this}}class me extends H{constructor(t=[]){super(),this.points=t}getPoint(t,e=new m){const{points:s}=this,r=(s.length-1)*t,o=Math.floor(r),n=r-o,h=s[o===0?o:o-1],c=s[o],a=s[o>s.length-2?s.length-1:o+1],l=s[o>s.length-3?s.length-1:o+2];return e.set(St(n,h.x,c.x,a.x,l.x),St(n,h.y,c.y,a.y,l.y)),e}getControlPointRefs(){return this.points}copy(t){super.copy(t),this.points=[];for(let e=0,s=t.points.length;e<s;e++)this.points.push(t.points[e].clone());return this}}class ht extends nt{startPoint;currentPoint;autoClose=!1;constructor(t){super(),t&&this.addPoints(t)}addPoints(t){this.moveTo(t[0].x,t[0].y);for(let e=1,s=t.length;e<s;e++){const{x:r,y:o}=t[e];this.lineTo(r,o)}return this}addCommands(t){return At(t,this),this}addData(t){return this.addCommands(kt(t)),this}_closeVertices(t){return this.autoClose&&t.length>=4&&t[0]!==t[t.length-2]&&t[1]!==t[t.length-1]&&t.push(t[0],t[1]),t}getUnevenVertices(t=40,e=[]){return this._closeVertices(super.getUnevenVertices(t,e))}getSpacedVertices(t=40,e=[]){return this._closeVertices(super.getSpacedVertices(t,e))}getAdaptiveVertices(t=[]){return this._closeVertices(super.getAdaptiveVertices(t))}getFillVertices(t){return this._closeVertices(super.getFillVertices(t))}_setCurrentPoint(t){return this.currentPoint=new m(t.x,t.y),this.startPoint||(this.startPoint=this.currentPoint.clone()),this}_connetLineTo(t){if(this.curves.length>0){const e=t.getPoint(0);(!this.currentPoint||!e.equals(this.currentPoint))&&this.lineTo(e.x,e.y)}return this}closePath(){const t=this.startPoint;if(t){const e=this.currentPoint;e&&!t.equals(e)&&(this.curves.push(new j(e.clone(),t.clone())),e.copy(t)),this.startPoint=void 0}return this}moveTo(t,e){return this.currentPoint=new m(t,e),this.startPoint=this.currentPoint.clone(),this}lineTo(t,e){const s=this.currentPoint;return s?.equals({x:t,y:e})||this.curves.push(j.from(s?.x??0,s?.y??0,t,e)),this._setCurrentPoint({x:t,y:e}),this}bezierCurveTo(t,e,s,r,o,n){const h=this.currentPoint;return h?.equals({x:o,y:n})||this.curves.push(Mt.from(h?.x??0,h?.y??0,t,e,s,r,o,n)),this._setCurrentPoint({x:o,y:n}),this}quadraticCurveTo(t,e,s,r){const o=this.currentPoint;return o?.equals({x:s,y:r})||this.curves.push(wt.from(o?.x??0,o?.y??0,t,e,s,r)),this._setCurrentPoint({x:s,y:r}),this}arc(t,e,s,r,o,n){const h=new xe(t,e,s,r,o,!n);return this._connetLineTo(h),this.curves.push(h),this._setCurrentPoint(h.getPoint(1)),this}relativeArc(t,e,s,r,o,n){return t+=this.currentPoint?.x??0,e+=this.currentPoint?.y??0,this.arc(t,e,s,r,o,n),this}arcTo(t,e,s,r,o){return console.warn("Method arcTo not supported yet"),this}ellipse(t,e,s,r,o,n,h,c=!0){const a=new pe(t,e,s,r,o,n,h,!c);return this._connetLineTo(a),this.curves.push(a),this._setCurrentPoint(a.getPoint(1)),this}relativeEllipse(t,e,s,r,o,n,h,c){return t+=this.currentPoint?.x??0,e+=this.currentPoint?.y??0,this.ellipse(t,e,s,r,o,n,h,c),this}rect(t,e,s,r){const o=new ge(t,e,s,r);return this._connetLineTo(o),this.curves.push(o),this._setCurrentPoint({x:t,y:e}),this}roundRect(t,e,s,r,o){const n=new de(t,e,s,r,o);return this._connetLineTo(n),this.curves.push(n),this._setCurrentPoint({x:t,y:e}),this}splineThru(t){const e=this.currentPoint??new m;return this.curves.push(new me([e].concat(t))),this._setCurrentPoint(t[t.length-1]),this}drawTo(t){const e=this.curves[0]?.getPoint(0);return e&&t.moveTo(e.x,e.y),this.curves.forEach(s=>s.drawTo(t)),this.autoClose&&t.closePath(),this}copy(t){return super.copy(t),this.autoClose=t.autoClose,this.currentPoint=t.currentPoint?.clone(),this}}function Is(i){return i.replace(/[^a-z0-9]/gi,"-").replace(/\B([A-Z])/g,"-$1").toLowerCase()}function Ss(i,t,e,s){const r=t.clone().sub(i),o=s.clone().sub(e),n=e.clone().sub(i),h=r.cross(o);if(h===0)return new m((i.x+e.x)/2,(i.y+e.y)/2);const c=n.cross(o)/h;return Math.abs(c)>1?new m((i.x+e.x)/2,(i.y+e.y)/2):new m(i.x+c*r.x,i.y+c*r.y)}class B extends nt{currentCurve=new ht;style;get startPoint(){return this.currentCurve.startPoint}get currentPoint(){return this.currentCurve.currentPoint}get strokeWidth(){return this.style.strokeWidth??((this.style.stroke??"none")==="none"?0:1)}constructor(t,e={}){super(),this.curves.push(this.currentCurve),this.style=e,t&&(t instanceof B?this.addPath(t):Array.isArray(t)?this.addCommands(t):this.addData(t))}addPath(t){const e=this.curves.findIndex(s=>s===this.currentCurve);return e>-1&&this.curves.splice(e,1),t instanceof B?this.curves.push(...t.curves.filter(s=>s.curves.length).map(s=>s.clone())):t.curves.length&&this.curves.push(t),this.curves.push(this.currentCurve),this}closePath(){const t=this.startPoint;return t&&(this.currentCurve.closePath(),this.currentCurve.curves.length&&(this.currentCurve=new ht().moveTo(t.x,t.y),this.curves.push(this.currentCurve))),this}moveTo(t,e){return this.currentCurve.currentPoint?.equals({x:t,y:e})||(this.currentCurve.curves.length&&(this.currentCurve=new ht,this.curves.push(this.currentCurve)),this.currentCurve.moveTo(t,e)),this}lineTo(t,e){return this.currentCurve.lineTo(t,e),this}bezierCurveTo(t,e,s,r,o,n){return this.currentCurve.bezierCurveTo(t,e,s,r,o,n),this}quadraticCurveTo(t,e,s,r){return this.currentCurve.quadraticCurveTo(t,e,s,r),this}arc(t,e,s,r,o,n){return this.currentCurve.arc(t,e,s,r,o,n),this}arcTo(t,e,s,r,o){return this.currentCurve.arcTo(t,e,s,r,o),this}ellipse(t,e,s,r,o,n,h,c){return this.currentCurve.ellipse(t,e,s,r,o,n,h,c),this}rect(t,e,s,r){return this.currentCurve.rect(t,e,s,r),this}roundRect(t,e,s,r,o){return this.currentCurve.roundRect(t,e,s,r,o),this}reset(){return this.currentCurve=new ht,this.curves=[this.currentCurve],this.style={},this}addCommands(t){return At(t,this),this}addData(t){return this.addCommands(kt(t)),this}splineThru(t){return this.currentCurve.splineThru(t),this}scale(t,e=t,s={x:0,y:0}){return this.getControlPointRefs().forEach(r=>{r.scale(t,e,s)}),this}skew(t,e=0,s={x:0,y:0}){return this.getControlPointRefs().forEach(r=>{r.skew(t,e,s)}),this}rotate(t,e={x:0,y:0}){return this.getControlPointRefs().forEach(s=>{s.rotate(t,e)}),this}bold(t){if(t===0)return this;const e=this.getFlatCurves(),s=[],r=[],o=[];e.forEach((h,c)=>{const a=h.getControlPointRefs(),l=h.isClockwise();o[c]=a,r[c]=l;const f=a[0],y=a[a.length-1]??f;s.push({start:l?y:f,end:l?f:y,index:c})});const n=[];return s.forEach((h,c)=>{n[c]=[],s.forEach((a,l)=>{a.start&&h.end&&l!==c&&a.start?.equals(h.end)&&n[c].push(a.index)})}),e.forEach((h,c)=>{const a=r[c];o[c].forEach(l=>{l.add(h.getNormal(h.getTForPoint(l)).scale(a?t:-t))})}),n.forEach((h,c)=>{const a=o[c];h.forEach(l=>{const f=o[l],y=Ss(a[a.length-1],a[a.length-2]??a[a.length-1],f[0],f[1]??f[0]);y&&(a[a.length-1].copy(y),f[0].copy(y))})}),this}getMinMax(t=m.MAX,e=m.MIN,s=!0){const r=this.strokeWidth;return this.curves.forEach(o=>{if(o.getMinMax(t,e),s&&r>1){const n=r/2,h=o.isClockwise(),c=[];for(let a=0;a<=1;a+=1/o.arcLengthDivision){const l=o.getPoint(a),f=o.getNormal(a),y=f.clone().scale(h?n:-n),x=f.clone().scale(h?-n:n);c.push(l.clone().add(y),l.clone().add(x),l.clone().add({x:n,y:0}),l.clone().add({x:-n,y:0}),l.clone().add({x:0,y:n}),l.clone().add({x:0,y:-n}),l.clone().add({x:n,y:n}),l.clone().add({x:-n,y:-n}))}t.min(...c),e.max(...c)}}),{min:t.finite(),max:e.finite()}}strokeTriangulate(t){const e=t?.indices??[],s=t?.vertices??[];return this.curves.forEach(r=>{r.strokeTriangulate({...t,indices:e,vertices:s,style:{...this.style}})}),{indices:e,vertices:s}}fillTriangulate(t){const e={...t,style:{...this.style,...t?.style}};function s(c){let a=0;const l=c.length/2;for(let f=0;f<l;f++){const y=c[2*f],x=c[2*f+1],u=(f+1)%l,p=c[2*u],g=c[2*u+1];a+=(p-y)*(g+x)}return a}function r(c){return s(c)>0}const o=e.indices??[],n=e.vertices??[];if((e.style.fillRule??"nonzero")==="nonzero"){const c=this.curves.map(f=>f.getFillVertices(e)),a=new Map,l=new Set;for(let f=0;f<c.length;f++){if(!r(c[f]))continue;const y=[];for(let x=0;x<c.length;x++){if(f===x||r(c[x]))continue;let u=!1;for(let p=0;p<c[f].length&&(u=u||ie([c[f][p],c[f][p+1]],c[x]),!u);p+=2);u&&y.push(x)}y.length&&(y.forEach(x=>{let u=a.get(x);u||(u=new Set,a.set(x,u)),u.add(f)}),l.add(f))}c.forEach((f,y)=>{if(l.has(y)||!f.length)return;const x=f.slice(),u=[];a.get(y)?.forEach(p=>{u.push(x.length/2),x.push(...c[p])}),Ft(x,{...t,indices:o,vertices:n,holes:u,style:{...this.style}})})}else this.curves.forEach(c=>{c.fillTriangulate({...t,indices:o,vertices:n,style:{...this.style}})});return{indices:o,vertices:n}}getBoundingBox(t=!0){const{min:e,max:s}=this.getMinMax(void 0,void 0,t);return new U(e.x,e.y,s.x-e.x,s.y-e.y)}drawTo(t,e={}){e={...this.style,...e};const{fill:s="#000",stroke:r="none"}=e;return t.beginPath(),t.save(),Ct(t,e),this.curves.forEach(o=>{o.drawTo(t)}),s!=="none"&&t.fill(),r!=="none"&&t.stroke(),t.restore(),this}drawControlPointsTo(t,e={}){e={...this.style,...e};const{fill:s="#000",stroke:r="none"}=e;return t.beginPath(),t.save(),Ct(t,e),this.getControlPointRefs().forEach(o=>{tt(t,o.x,o.y,{radius:4})}),s!=="none"&&t.fill(),r!=="none"&&t.stroke(),t.restore(),this}toCommands(){return this.curves.flatMap(t=>t.toCommands())}toData(){return this.curves.filter(t=>t.curves.length).map(t=>t.toData()).join(" ")}toSvgPathString(){const t={...this.style,fill:this.style.fill??"#000",stroke:this.style.stroke??"none"},e={};for(const r in t)t[r]!==void 0&&(e[Is(r)]=t[r]);Object.assign(e,{"stroke-width":`${this.strokeWidth}px`});let s="";for(const r in e)e[r]!==void 0&&(s+=`${r}:${e[r]};`);return`<path d="${this.toData()}" style="${s}"></path>`}copy(t){return super.copy(t),this.currentCurve=t.currentCurve.clone(),this.style={...t.style},this}}class Me{constructor(t=[],e){this.paths=t,this.viewBox=e}getBoundingBox(t=!0){if(!this.paths.length)return;const e=m.MAX,s=m.MIN;return this.paths.forEach(r=>r.getMinMax(e,s,t)),new U(e.x,e.y,s.x-e.x,s.y-e.y)}toTriangulatedSvgString(t=this.paths.map(s=>s.fillTriangulate()),e=0){let s="";const r={x:-e,y:-e},o={x:e,y:e};(Array.isArray(t)?t:[t]).forEach(({vertices:c,indices:a})=>{const l=f=>{const y=c[f*2],x=c[f*2+1];return r.x=Math.min(r.x,y+e),o.x=Math.max(o.x,y+e),r.y=Math.min(r.y,x+e),o.y=Math.max(o.y,x+e),[y,x]};for(let f=0,y=a.length;f<y;f+=3){const x=l(a[f]),u=l(a[f+1]),p=l(a[f+2]);s+=`<polygon points="${x.join(",")} ${u.join(",")} ${p.join(",")}" fill="black" />`}});const h=[r.x,r.y,o.x-r.x,o.y-r.y];return`<svg width="${h[2]}" height="${h[3]}" viewBox="${h.join(" ")}" xmlns="http://www.w3.org/2000/svg">${s}</svg>`}toTriangulatedSvg(t,e){return new DOMParser().parseFromString(this.toTriangulatedSvgString(t,e),"image/svg+xml").documentElement}toSvgString(){const{x:t,y:e,width:s,height:r}=this.getBoundingBox(),o=this.paths.map(n=>n.toSvgPathString()).join("");return`<svg viewBox="${t} ${e} ${s} ${r}" width="${s}px" height="${r}px" xmlns="http://www.w3.org/2000/svg">${o}</svg>`}toSvgUrl(){return`data:image/svg+xml;base64,${btoa(this.toSvgString())}`}toSvg(){return new DOMParser().parseFromString(this.toSvgString(),"image/svg+xml").documentElement}toCanvas(t={}){const{pixelRatio:e=2,...s}=t,{left:r,top:o,width:n,height:h}=this.getBoundingBox(),c=document.createElement("canvas");c.width=n*e,c.height=h*e,c.style.width=`${n}px`,c.style.height=`${h}px`;const a=c.getContext("2d");return a&&(a.scale(e,e),a.translate(-r,-o),this.paths.forEach(l=>{l.drawTo(a,s)})),c}}class Es{constructor(t,e,s=1,r=1){this.rows=t,this.cols=e,this.width=s,this.height=r;for(let o=0;o<t;o++){this.controlPoints[o]=[];for(let n=0;n<e;n++)this.controlPoints[o][n]={x:n/(e-1)*s,y:o/(t-1)*r}}}controlPoints=[];moveControlPoint(t,e,s,r){return this.controlPoints[t][e].x+=s,this.controlPoints[t][e].y+=r,this}}function we(i){const t=[];return t[0]=(1-i)**3/6,t[1]=(3*i**3-6*i**2+4)/6,t[2]=(-3*i**3+3*i**2+3*i+1)/6,t[3]=i**3/6,t}function _s(i,t,e=t.width,s=t.height){const r=i.x/e*(t.cols-1),o=i.y/s*(t.rows-1),n=Math.floor(r),h=Math.floor(o),c=r-n,a=o-h,l=we(c),f=we(a);let y=0,x=0;for(let u=0;u<4;u++)for(let p=0;p<4;p++){const g=Math.min(Math.max(h-1+u,0),t.rows-1),P=Math.min(Math.max(n-1+p,0),t.cols-1),b=t.controlPoints[g][P],w=l[p]*f[u];y+=b.x*w,x+=b.y*w}i.set(y,x)}A.ArcCurve=xe,A.BoundingBox=U,A.CompositeCurve=nt,A.CubicBezierCurve=Mt,A.Curve=H,A.CurvePath=ht,A.EllipseCurve=pe,A.EquilateralPloygonCurve=ks,A.FFDControlGrid=Es,A.LineCurve=j,A.Matrix3=R,A.Path2D=B,A.Path2DSet=Me,A.PloygonCurve=qt,A.QuadraticBezierCurve=wt,A.RectangleCurve=ge,A.RoundRectangleCurve=de,A.SplineCurve=me,A.Vector2=m,A.applyFFD=_s,A.catmullRom=St,A.cubicBezier=Et,A.drawPoint=tt,A.fillTriangulate=Ft,A.getAdaptiveCubicBezierCurvePoints=se,A.getAdaptiveQuadraticBezierCurvePoints=ne,A.getDirectedArea=ps,A.parseArcCommand=zt,A.parsePathDataArgs=z,A.pointInPolygonEvenOdd=gs,A.pointInPolygonNonZero=ie,A.quadraticBezier=Dt,A.setCanvasContext=Ct,A.strokeTriangulate=ce,A.svgPathCommandsAddToPath2D=At,A.svgPathCommandsToData=jt,A.svgPathDataToCommands=kt,A.svgToDom=Xt,A.svgToPath2DSet=je,Object.defineProperty(A,Symbol.toStringTag,{value:"Module"})});
|
package/dist/index.mjs
CHANGED
|
@@ -3937,6 +3937,22 @@ class Path2D extends CompositeCurve {
|
|
|
3937
3937
|
...options?.style
|
|
3938
3938
|
}
|
|
3939
3939
|
};
|
|
3940
|
+
function signedArea(pts) {
|
|
3941
|
+
let sum = 0;
|
|
3942
|
+
const len = pts.length / 2;
|
|
3943
|
+
for (let i = 0; i < len; i++) {
|
|
3944
|
+
const xi = pts[2 * i];
|
|
3945
|
+
const yi = pts[2 * i + 1];
|
|
3946
|
+
const j = (i + 1) % len;
|
|
3947
|
+
const xj = pts[2 * j];
|
|
3948
|
+
const yj = pts[2 * j + 1];
|
|
3949
|
+
sum += (xj - xi) * (yj + yi);
|
|
3950
|
+
}
|
|
3951
|
+
return sum;
|
|
3952
|
+
}
|
|
3953
|
+
function isHoleFlat(pts) {
|
|
3954
|
+
return signedArea(pts) > 0;
|
|
3955
|
+
}
|
|
3940
3956
|
const indices = _options.indices ?? [];
|
|
3941
3957
|
const vertices = _options.vertices ?? [];
|
|
3942
3958
|
const fillRule = _options.style.fillRule ?? "nonzero";
|
|
@@ -3945,13 +3961,22 @@ class Path2D extends CompositeCurve {
|
|
|
3945
3961
|
const parentMap = /* @__PURE__ */ new Map();
|
|
3946
3962
|
const parentd = /* @__PURE__ */ new Set();
|
|
3947
3963
|
for (let i = 0; i < pointArrays.length; i++) {
|
|
3964
|
+
if (!isHoleFlat(pointArrays[i])) {
|
|
3965
|
+
continue;
|
|
3966
|
+
}
|
|
3948
3967
|
const parents = [];
|
|
3949
3968
|
for (let j = 0; j < pointArrays.length; j++) {
|
|
3950
|
-
if (i === j)
|
|
3969
|
+
if (i === j || isHoleFlat(pointArrays[j]))
|
|
3951
3970
|
continue;
|
|
3952
3971
|
let flag = false;
|
|
3953
3972
|
for (let k = 0; k < pointArrays[i].length; k += 2) {
|
|
3954
|
-
flag = flag || pointInPolygonNonZero(
|
|
3973
|
+
flag = flag || pointInPolygonNonZero(
|
|
3974
|
+
[pointArrays[i][k], pointArrays[i][k + 1]],
|
|
3975
|
+
pointArrays[j]
|
|
3976
|
+
);
|
|
3977
|
+
if (flag) {
|
|
3978
|
+
break;
|
|
3979
|
+
}
|
|
3955
3980
|
}
|
|
3956
3981
|
if (flag) {
|
|
3957
3982
|
parents.push(j);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "modern-path2d",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.4.
|
|
4
|
+
"version": "1.4.3",
|
|
5
5
|
"packageManager": "pnpm@9.15.1",
|
|
6
6
|
"description": "A Path2D library, fully compatible with Web Path2D, with additional support for triangulate、animation、deformation etc.",
|
|
7
7
|
"author": "wxm",
|