modern-path2d 1.6.1 → 1.8.0
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/README.md +55 -0
- package/dist/index.cjs +565 -74
- package/dist/index.d.cts +178 -4
- package/dist/index.d.mts +178 -4
- package/dist/index.d.ts +178 -4
- package/dist/index.js +3 -2
- package/dist/index.mjs +562 -75
- package/package.json +4 -2
package/dist/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports):typeof define==`function`&&define.amd?define([`exports`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.modernPath2d={}))})(this,function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function t(e,t,n,r={}){let{radius:i=1}=r;e.moveTo(t,n),e.arc(t,n,i,0,Math.PI*2)}var n={arcs:`bevel`,bevel:`bevel`,miter:`miter`,"miter-clip":`miter`,round:`round`};function r(e,t){let{fill:r=`#000`,stroke:i=`none`,strokeWidth:a=i===`none`?0:1,strokeLinecap:o=`round`,strokeLinejoin:s=`miter`,strokeMiterlimit:c=0,strokeDasharray:l=[],strokeDashoffset:u=0,shadowOffsetX:d=0,shadowOffsetY:f=0,shadowBlur:p=0,shadowColor:m=`rgba(0, 0, 0, 0)`}=t;e.fillStyle=r,e.strokeStyle=i,e.lineWidth=a,e.lineCap=o,e.lineJoin=n[s],e.miterLimit=c,e.setLineDash(l),e.lineDashOffset=u,e.shadowOffsetX=d,e.shadowOffsetY=f,e.shadowBlur=p,e.shadowColor=m}var i=class e{static get MAX(){return new e(1/0,1/0)}static get MIN(){return new e(-1/0,-1/0)}static lerp(t,n,r){return new e(n.x,n.y).clone().sub(t).multiply(r).add(t)}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}get left(){return this.x}set left(e){this.x=e}get top(){return this.y}set top(e){this.y=e}get x(){return this._x}set x(e){this._x!==e&&(this._x=e,this._onUpdate?.(this))}get y(){return this._y}set y(e){this._y!==e&&(this._y=e,this._onUpdate?.(this))}constructor(e=0,t=0,n){this._x=e,this._y=t,this._onUpdate=n}set(e=0,t=e){return(this._x!==e||this._y!==t)&&(this._x=e,this._y=t,this._onUpdate?.(this)),this}add(e){return this.set(this._x+e.x,this._y+e.y)}sub(e){return this.set(this._x-e.x,this._y-e.y)}subVectors(e,t){return this.set(e.x-t.x,e.y-t.y)}multiply(e=0,t=e){return this.set(this._x*e,this._y*t)}divide(e=0,t=e){return this.set(this._x/e,this._y/t)}cross(e){return this._x*e.y-this._y*e.x}dot(e){return this._x*e.x+this._y*e.y}rotate(e,t={x:0,y:0}){let{x:n,y:r}=this,i=Math.cos(e),a=Math.sin(e);return this.set((n-t.x)*i-(r-t.y)*a+t.x,(n-t.x)*a+(r-t.y)*i+t.y)}getLength(){let{x:e,y:t}=this;return Math.sqrt(e*e+t*t)}getAngle(){return Math.atan2(-this.x,-this.y)+Math.PI}distanceTo(e){return Math.hypot(e.x-this.x,e.y-this.y)}normalize(){let e=1/(this.getLength()||1);return this.set(this.x*e,this.y*e),this}copyFrom(e){return(this._x!==e.x||this._y!==e.y)&&(this._x=e.x,this._y=e.y,this._onUpdate?.(this)),this}copyTo(e){return e.set(this._x,this._y),e}equals(e){return this._x===e.x&&this._y===e.y}get array(){return[this.x,this.y]}finite(){return this.set(Number.isFinite(this._x)?this._x:0,Number.isFinite(this._y)?this._y:0)}lengthSquared(){return this._x*this._x+this._y*this._y}length(){return Math.sqrt(this.lengthSquared())}scale(e,t=e,n={x:0,y:0}){return this.set(n.x+(this._x-n.x)*e,n.y+(this._y-n.y)*t)}skew(e,t=0,n={x:0,y:0}){let r=this._x-n.x,i=this._y-n.y;return this.set(n.x+(r+Math.tan(e)*i),n.y+(i+Math.tan(t)*r))}clampMin(...e){return this.set(Math.min(this._x,...e.map(e=>e.x)),Math.min(this._y,...e.map(e=>e.y)))}clampMax(...e){return this.set(Math.max(this.x,...e.map(e=>e.x)),Math.max(this.y,...e.map(e=>e.y)))}clone(t){return new e(this._x,this._y,t??this._onUpdate)}toJSON(){return{x:this._x,y:this._y}}destroy(){this._onUpdate=void 0}},a=class e{get x(){return this.left}set x(e){this.left=e}get y(){return this.top}set y(e){this.top=e}get right(){return this.left+this.width}get bottom(){return this.top+this.height}get center(){return new i((this.left+this.right)/2,(this.top+this.bottom)/2)}get array(){return[this.left,this.top,this.width,this.height]}constructor(e=0,t=0,n=0,r=0){this.left=e,this.top=t,this.width=n,this.height=r}static from(...t){if(t.length===0)return new e;if(t.length===1)return t[0].clone();let n=t[0],r=t.slice(1).reduce((e,t)=>(e.left=Math.min(e.left,t.left),e.top=Math.min(e.top,t.top),e.right=Math.max(e.right,t.right),e.bottom=Math.max(e.bottom,t.bottom),e),{left:n?.left??0,top:n?.top??0,right:n?.right??0,bottom:n?.bottom??0});return new e(r.left,r.top,r.right-r.left,r.bottom-r.top)}translate(e,t){return this.left+=e,this.top+=t,this}copy(e){return this.left=e.left,this.top=e.top,this.width=e.width,this.height=e.height,this}clone(){return new e(this.left,this.top,this.width,this.height)}};function o(e,t,n,r,i){let a=(r-t)*.5,o=(i-n)*.5,s=e*e,c=e*s;return(2*n-2*r+a+o)*c+(-3*n+3*r-2*a-o)*s+a*e+n}var s=Math.PI,c=s*2;function l(e){return e.replace(/[^a-z0-9]/gi,`-`).replace(/\B([A-Z])/g,`-$1`).toLowerCase()}function u(e,t,n,r){let a=t.clone().sub(e),o=r.clone().sub(n),s=n.clone().sub(e),c=a.cross(o);if(c===0)return new i((e.x+n.x)/2,(e.y+n.y)/2);let l=s.cross(o)/c;return Math.abs(l)>1?new i((e.x+n.x)/2,(e.y+n.y)/2):new i(e.x+l*a.x,e.y+l*a.y)}var d=/([\w-]+)\((.+?)\)/g,f=/[^,]+/g,p=/([-e.\d]+)(.*)/;function m(e,t={}){let n=[],r;for(;(r=d.exec(e))!==null;){let[,e,i]=r;e&&n.push({name:e,args:h(e,i,t)})}return n}function h(e,t,n={}){let r=[],i,a=0;for(;(i=f.exec(t))!==null;)r.push(g(e,i[0],{...n,index:a++}));return r}function g(e,t,n={}){let{width:r=1,height:i=1,index:a=0}=n,o=t.match(p),s={unit:o?.[2]??null,value:t,intValue:Number(o?.[1]),normalizedIntValue:0,normalizedDefaultIntValue:0};switch(e){case`scale`:case`scaleX`:case`scaleY`:case`scale3d`:s.normalizedDefaultIntValue=1;break}switch(s.unit){case`%`:s.normalizedIntValue=s.intValue/100;break;case`rad`:s.normalizedIntValue=s.intValue/c;break;case`deg`:s.normalizedIntValue=s.intValue/360;break;case`px`:switch(a){case 0:s.normalizedIntValue=s.intValue/r;break;case 1:s.normalizedIntValue=s.intValue/i;break}break;default:s.normalizedIntValue=s.intValue;break}return s}function _(e,t){let n=1-e;return n*n*n*t}function v(e,t){let n=1-e;return 3*n*n*e*t}function y(e,t){return 3*(1-e)*e*e*t}function b(e,t){return e*e*e*t}function x(e,t,n,r,i){return _(e,t)+v(e,n)+y(e,r)+b(e,i)}function S(e,t,n=2){let r=t&&t.length,i=r?t[0]*n:e.length,a=C(e,0,i,n,!0),o=[];if(!a||a.next===a.prev)return o;let s,c,l;if(r&&(a=A(e,t,a,n)),e.length>80*n){s=e[0],c=e[1];let t=s,r=c;for(let a=n;a<i;a+=n){let n=e[a],i=e[a+1];n<s&&(s=n),i<c&&(c=i),n>t&&(t=n),i>r&&(r=i)}l=Math.max(t-s,r-c),l=l===0?0:32767/l}return T(a,o,n,s,c,l,0),o}function C(e,t,n,r,i){let a;if(i===fe(e,t,n,r)>0)for(let i=t;i<n;i+=r)a=ue(i/r|0,e[i],e[i+1],a);else for(let i=n-r;i>=t;i-=r)a=ue(i/r|0,e[i],e[i+1],a);return a&&z(a,a.next)&&(V(a),a=a.next),a}function w(e,t){if(!e)return e;t||=e;let n=e,r;do if(r=!1,!n.steiner&&(z(n,n.next)||R(n.prev,n,n.next)===0)){if(V(n),n=t=n.prev,n===n.next)break;r=!0}else n=n.next;while(r||n!==t);return t}function T(e,t,n,r,i,a,o){if(!e)return;!o&&a&&F(e,r,i,a);let s=e;for(;e.prev!==e.next;){let c=e.prev,l=e.next;if(a?D(e,r,i,a):E(e)){t.push(c.i,e.i,l.i),V(e),e=l.next,s=l.next;continue}if(e=l,e===s){o?o===1?(e=O(w(e),t),T(e,t,n,r,i,a,2)):o===2&&k(e,t,n,r,i,a):T(w(e),t,n,r,i,a,1);break}}}function E(e){let t=e.prev,n=e,r=e.next;if(R(t,n,r)>=0)return!1;let i=t.x,a=n.x,o=r.x,s=t.y,c=n.y,l=r.y,u=Math.min(i,a,o),d=Math.min(s,c,l),f=Math.max(i,a,o),p=Math.max(s,c,l),m=r.next;for(;m!==t;){if(m.x>=u&&m.x<=f&&m.y>=d&&m.y<=p&&L(i,s,a,c,o,l,m.x,m.y)&&R(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function D(e,t,n,r){let i=e.prev,a=e,o=e.next;if(R(i,a,o)>=0)return!1;let s=i.x,c=a.x,l=o.x,u=i.y,d=a.y,f=o.y,p=Math.min(s,c,l),m=Math.min(u,d,f),h=Math.max(s,c,l),g=Math.max(u,d,f),_=ee(p,m,t,n,r),v=ee(h,g,t,n,r),y=e.prevZ,b=e.nextZ;for(;y&&y.z>=_&&b&&b.z<=v;){if(y.x>=p&&y.x<=h&&y.y>=m&&y.y<=g&&y!==i&&y!==o&&L(s,u,c,d,l,f,y.x,y.y)&&R(y.prev,y,y.next)>=0||(y=y.prevZ,b.x>=p&&b.x<=h&&b.y>=m&&b.y<=g&&b!==i&&b!==o&&L(s,u,c,d,l,f,b.x,b.y)&&R(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;y&&y.z>=_;){if(y.x>=p&&y.x<=h&&y.y>=m&&y.y<=g&&y!==i&&y!==o&&L(s,u,c,d,l,f,y.x,y.y)&&R(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;b&&b.z<=v;){if(b.x>=p&&b.x<=h&&b.y>=m&&b.y<=g&&b!==i&&b!==o&&L(s,u,c,d,l,f,b.x,b.y)&&R(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function O(e,t){let n=e;do{let r=n.prev,i=n.next.next;!z(r,i)&&ie(r,n,n.next,i)&&B(r,i)&&B(i,r)&&(t.push(r.i,n.i,i.i),V(n),V(n.next),n=e=i),n=n.next}while(n!==e);return w(n)}function k(e,t,n,r,i,a){let o=e;do{let e=o.next.next;for(;e!==o.prev;){if(o.i!==e.i&&re(o,e)){let s=le(o,e);o=w(o,o.next),s=w(s,s.next),T(o,t,n,r,i,a,0),T(s,t,n,r,i,a,0);return}e=e.next}o=o.next}while(o!==e)}function A(e,t,n,r){let i=[];for(let n=0,a=t.length;n<a;n++){let o=C(e,t[n]*r,n<a-1?t[n+1]*r:e.length,r,!1);o===o.next&&(o.steiner=!0),i.push(te(o))}i.sort(j);for(let e=0;e<i.length;e++)n=M(i[e],n);return n}function j(e,t){let n=e.x-t.x;return n===0&&(n=e.y-t.y,n===0&&(n=(e.next.y-e.y)/(e.next.x-e.x)-(t.next.y-t.y)/(t.next.x-t.x))),n}function M(e,t){let n=N(e,t);if(!n)return t;let r=le(n,e);return w(r,r.next),w(n,n.next)}function N(e,t){let n=t,r=e.x,i=e.y,a=-1/0,o;if(z(e,n))return n;do{if(z(e,n.next))return n.next;if(i<=n.y&&i>=n.next.y&&n.next.y!==n.y){let e=n.x+(i-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(e<=r&&e>a&&(a=e,o=n.x<n.next.x?n:n.next,e===r))return o}n=n.next}while(n!==t);if(!o)return null;let s=o,c=o.x,l=o.y,u=1/0;n=o;do{if(r>=n.x&&n.x>=c&&r!==n.x&&ne(i<l?r:a,i,c,l,i<l?a:r,i,n.x,n.y)){let t=Math.abs(i-n.y)/(r-n.x);B(n,e)&&(t<u||t===u&&(n.x>o.x||n.x===o.x&&P(o,n)))&&(o=n,u=t)}n=n.next}while(n!==s);return o}function P(e,t){return R(e.prev,e,t.prev)<0&&R(t.next,e,e.next)<0}function F(e,t,n,r){let i=e;do i.z===0&&(i.z=ee(i.x,i.y,t,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,I(i)}function I(e){let t,n=1;do{let r=e,i;e=null;let a=null;for(t=0;r;){t++;let o=r,s=0;for(let e=0;e<n&&(s++,o=o.nextZ,o);e++);let c=n;for(;s>0||c>0&&o;)s!==0&&(c===0||!o||r.z<=o.z)?(i=r,r=r.nextZ,s--):(i=o,o=o.nextZ,c--),a?a.nextZ=i:e=i,i.prevZ=a,a=i;r=o}a.nextZ=null,n*=2}while(t>1);return e}function ee(e,t,n,r,i){return e=(e-n)*i|0,t=(t-r)*i|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function te(e){let t=e,n=e;do(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next;while(t!==e);return n}function ne(e,t,n,r,i,a,o,s){return(i-o)*(t-s)>=(e-o)*(a-s)&&(e-o)*(r-s)>=(n-o)*(t-s)&&(n-o)*(a-s)>=(i-o)*(r-s)}function L(e,t,n,r,i,a,o,s){return!(e===o&&t===s)&&ne(e,t,n,r,i,a,o,s)}function re(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!se(e,t)&&(B(e,t)&&B(t,e)&&ce(e,t)&&(R(e.prev,e,t.prev)||R(e,t.prev,t))||z(e,t)&&R(e.prev,e,e.next)>0&&R(t.prev,t,t.next)>0)}function R(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function z(e,t){return e.x===t.x&&e.y===t.y}function ie(e,t,n,r){let i=oe(R(e,t,n)),a=oe(R(e,t,r)),o=oe(R(n,r,e)),s=oe(R(n,r,t));return!!(i!==a&&o!==s||i===0&&ae(e,n,t)||a===0&&ae(e,r,t)||o===0&&ae(n,e,r)||s===0&&ae(n,t,r))}function ae(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function oe(e){return e>0?1:e<0?-1:0}function se(e,t){let n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&ie(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}function B(e,t){return R(e.prev,e,e.next)<0?R(e,t,e.next)>=0&&R(e,e.prev,t)>=0:R(e,t,e.prev)<0||R(e,e.next,t)<0}function ce(e,t){let n=e,r=!1,i=(e.x+t.x)/2,a=(e.y+t.y)/2;do n.y>a!=n.next.y>a&&n.next.y!==n.y&&i<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next;while(n!==e);return r}function le(e,t){let n=de(e.i,e.x,e.y),r=de(t.i,t.x,t.y),i=e.next,a=t.prev;return e.next=t,t.prev=e,n.next=i,i.prev=n,r.next=n,n.prev=r,a.next=r,r.prev=a,r}function ue(e,t,n,r){let i=de(e,t,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function V(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function de(e,t,n){return{i:e,x:t,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function fe(e,t,n,r){let i=0;for(let a=t,o=n-r;a<n;a+=r)i+=(e[o]-e[a])*(e[a+1]+e[o+1]),o=a;return i}function pe(e,t={}){let{vertices:n=[],indices:r=[],holes:i=[],verticesStride:a=2,verticesOffset:o=n.length/a,indicesOffset:s=r.length}=t,c=S(e,i,2);if(c.length){for(let e=0;e<c.length;e+=3)r[s++]=c[e]+o,r[s++]=c[e+1]+o,r[s++]=c[e+2]+o;let t=o*a;for(let r=0;r<e.length;r+=2)n[t]=e[r],n[t+1]=e[r+1],t+=a}return{vertices:n,indices:r}}var me=8,he=1.1920929e-7,ge=1,_e=.01,H=0,U=0;function ve(e,t,n,r,i,a,o,s,c=.5,l=[]){let u=(ge-Math.min(.99,Math.max(0,c)))/1;return u*=u,ye(e,t,n,r,i,a,o,s,l,u,0),l.push(o,s),l}function ye(e,t,n,r,i,a,o,s,c,l,u){if(u>me)return;let d=Math.PI,f=(e+n)/2,p=(t+r)/2,m=(n+i)/2,h=(r+a)/2,g=(i+o)/2,_=(a+s)/2,v=(f+m)/2,y=(p+h)/2,b=(m+g)/2,x=(h+_)/2,S=(v+b)/2,C=(y+x)/2;if(u>0){let u=o-e,f=s-t,p=Math.abs((n-o)*f-(r-s)*u),m=Math.abs((i-o)*f-(a-s)*u),h,g;if(p>he&&m>he){if((p+m)*(p+m)<=l*(u*u+f*f)){if(H<_e){c.push(S,C);return}let l=Math.atan2(a-r,i-n);if(h=Math.abs(l-Math.atan2(r-t,n-e)),g=Math.abs(Math.atan2(s-a,o-i)-l),h>=d&&(h=2*d-h),g>=d&&(g=2*d-g),h+g<H){c.push(S,C);return}if(U!==0){if(h>U){c.push(n,r);return}if(g>U){c.push(i,a);return}}}}else if(p>he){if(p*p<=l*(u*u+f*f)){if(H<_e){c.push(S,C);return}if(h=Math.abs(Math.atan2(a-r,i-n)-Math.atan2(r-t,n-e)),h>=d&&(h=2*d-h),h<H){c.push(n,r),c.push(i,a);return}if(U!==0&&h>U){c.push(n,r);return}}}else if(m>he){if(m*m<=l*(u*u+f*f)){if(H<_e){c.push(S,C);return}if(h=Math.abs(Math.atan2(s-a,o-i)-Math.atan2(a-r,i-n)),h>=d&&(h=2*d-h),h<H){c.push(n,r),c.push(i,a);return}if(U!==0&&h>U){c.push(i,a);return}}}else if(u=S-(e+o)/2,f=C-(t+s)/2,u*u+f*f<=l){c.push(S,C);return}}ye(e,t,f,p,v,y,S,C,c,l,u+1),ye(S,C,b,x,g,_,o,s,c,l,u+1)}var be=8,xe=1.1920929e-7,Se=1,Ce=.01,we=0;function Te(e,t,n,r,i,a,o=.5,s=[]){let c=(Se-Math.min(.99,Math.max(0,o)))/1;return c*=c,Ee(s,e,t,n,r,i,a,c,0),s.push(i,a),s}function Ee(e,t,n,r,i,a,o,s,c){if(c>be)return;let l=Math.PI,u=(t+r)/2,d=(n+i)/2,f=(r+a)/2,p=(i+o)/2,m=(u+f)/2,h=(d+p)/2,g=a-t,_=o-n,v=Math.abs((r-a)*_-(i-o)*g);if(v>xe){if(v*v<=s*(g*g+_*_)){if(we<Ce){e.push(m,h);return}let s=Math.abs(Math.atan2(o-i,a-r)-Math.atan2(i-n,r-t));if(s>=l&&(s=2*l-s),s<we){e.push(m,h);return}}}else if(g=m-(t+a)/2,_=h-(n+o)/2,g*g+_*_<=s){e.push(m,h);return}Ee(e,t,n,u,d,m,h,s,c+1),Ee(e,m,h,f,p,a,o,s,c+1)}function De(e){let t=0,n=e.length;for(let r=0;r<n;r+=2){let i=e[r],a=e[r+1],o=e[(r+2)%n],s=e[(r+3)%n];t+=i*s-o*a}return t/2}function Oe(e,t,n,r,i,a){return(n-e)*(a-t)-(r-t)*(i-e)}function ke(e,t,n){let r=n.length,i=0;for(let a=0,o=r-2;a<r;o=a,a+=2){let r=n[a],s=n[a+1],c=n[o],l=n[o+1];s<=t?l>t&&Oe(c,l,r,s,e,t)>0&&i++:l<=t&&Oe(c,l,r,s,e,t)<0&&i--}return i}function Ae(e,t){let n=t[0]-e[0],r=t[1]-e[1];return Math.sqrt(n*n+r*r)}function je(e){let t=e.map((e,t)=>({index:t})),n=e.map(e=>{let t=e.length;if(!t)return[];let n=[2**53-1,0],r=[0,2**53-1],i=[-(2**53-1),0],a=[0,-(2**53-1)];for(let o=0;o<t;o+=2){let t=e[o],s=e[o+1];n[0]>t&&(n=[t,s]),r[1]>s&&(r=[t,s]),i[0]<t&&(i=[t,s]),a[1]<s&&(a=[t,s])}let o=[(n[0]+i[0])/2,(r[1]+a[1])/2],s,c,l,u,d,f,p,m;for(let n=0;n<t;n+=2){let t=e[n],r=e[n+1],i=Math.abs(t-o[0]),a=Math.abs(r-o[1]);r<o[1]&&(!s||i<s)&&(s=i,l=[t,r]),r>o[1]&&(!c||i<c)&&(c=i,u=[t,r]),t<o[0]&&(!d||a<d)&&(d=a,p=[t,r]),t>o[0]&&(!f||a<f)&&(f=a,m=[t,r])}return[n,r,i,a,l,u,p,m].filter(Boolean)});for(let r=0,i=e.length;r<i;r++){let a=[],o=n[r];for(let t=0;t<i;t++){if(r===t)continue;let i={},s=[];for(let n=0,r=o.length;n<r;n++){let[r,a]=o[n],c=ke(r,a,e[t]);i[c]=(i[c]??0)+1,s.push(c)}s.filter(e=>e!==0).length>s.filter(e=>e===0).length&&a.push({index:r,parentIndex:t,winding:Number(Array.from(Object.entries(i)).sort((e,t)=>t[1]-e[1])?.[0]?.[0]??0),dist:Ae(n[r][0],n[t][0])})}a.reduce((e,t)=>e+t.winding,0)!==0&&(a.sort((e,t)=>e.dist-t.dist),t[r]=a[0])}return t}function Me(e,t,n,r,i,a){return(n-e)*(a-t)-(i-e)*(r-t)}function Ne(e,t,n){let r=n.length,i=0;for(let a=0;a<r;a+=2){let o=n[a],s=n[a+1],c=(a+2)%r,l=n[c],u=n[c+1];s<=t?u>t&&Me(o,s,l,u,e,t)>0&&i++:u<=t&&Me(o,s,l,u,e,t)<0&&i--}return i}function Pe(e,t,n){let r=n.length,i=0;for(let a=0;a<r;a+=2){let o=n[a],s=n[a+1],c=(a+2)%r,l=n[c],u=n[c+1];(s<=t&&u>t||s>t&&u<=t)&&e<o+(t-s)/(u-s)*(l-o)&&i++}return i}function Fe(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s,l=c===0?0:((e-n)*o+(t-r)*s)/c;l<0?l=0:l>1&&(l=1);let u=n+l*o,d=r+l*s;return Math.hypot(e-u,t-d)}function Ie(e,t,n=`nonzero`){return t.length<6?!1:n===`evenodd`?(Pe(e.x,e.y,t)&1)==1:Ne(e.x,e.y,t)!==0}function Le(e,t,n=`nonzero`){let{x:r,y:i}=e;if(n===`evenodd`){let e=0;for(let n=0,a=t.length;n<a;n++){let a=t[n];a.length>=6&&(e+=Pe(r,i,a))}return(e&1)==1}let a=0;for(let e=0,n=t.length;e<n;e++){let n=t[e];n.length>=6&&(a+=Ne(r,i,n))}return a!==0}function Re(e,t,n){return Fe(e.x,e.y,t.x,t.y,n.x,n.y)}function ze(e,t,n=!1){let r=t.length;if(r<2)return 1/0;let{x:i,y:a}=e;if(r===2)return Math.hypot(i-t[0],a-t[1]);let o=1/0;for(let e=0;e<r-2;e+=2){let n=Fe(i,a,t[e],t[e+1],t[e+2],t[e+3]);n<o&&(o=n)}if(n&&r>=6){let e=Fe(i,a,t[r-2],t[r-1],t[0],t[1]);e<o&&(o=e)}return o}function Be(e,t){let n=1-e;return n*n*t}function Ve(e,t){return 2*(1-e)*e*t}function He(e,t){return e*e*t}function Ue(e,t,n,r){return Be(e,t)+Ve(e,n)+He(e,r)}var We=1e-4,Ge=1e-4;function Ke(e,t={}){let{vertices:n=[],indices:r=[],lineStyle:i={alignment:.5,cap:`butt`,join:`miter`,width:1,miterLimit:10},flipAlignment:a=!1,closed:o=!0}=t,s=We;if(e.length===0)return{vertices:n,indices:r};let c=i,l=c.alignment;if(i.alignment!==.5){let t=qe(e);a&&(t*=-1),l=(l-.5)*t+.5}let u={x:e[0],y:e[1]},d={x:e[e.length-2],y:e[e.length-1]},f=o,p=Math.abs(u.x-d.x)<s&&Math.abs(u.y-d.y)<s;if(f){e=e.slice(),p&&(e.pop(),e.pop(),d.x=e[e.length-2],d.y=e[e.length-1]);let t=(u.x+d.x)*.5,n=(d.y+u.y)*.5;e.unshift(t,n),e.push(t,n)}let m=n,h=e.length/2,g=e.length,_=m.length/2,v=c.width/2,y=v*v,b=c.miterLimit*c.miterLimit,x=e[0],S=e[1],C=e[2],w=e[3],T=0,E=0,D=-(S-w),O=x-C,k=0,A=0,j=Math.sqrt(D*D+O*O);D/=j,O/=j,D*=v,O*=v;let M=l,N=(1-M)*2,P=M*2;f||(c.cap===`round`?g+=W(x-D*(N-P)*.5,S-O*(N-P)*.5,x-D*N,S-O*N,x+D*P,S+O*P,m,!0)+2:c.cap===`square`&&(g+=Je(x,S,D,O,N,P,!0,m))),m.push(x-D*N,S-O*N),m.push(x+D*P,S+O*P);for(let t=1;t<h-1;++t){x=e[(t-1)*2],S=e[(t-1)*2+1],C=e[t*2],w=e[t*2+1],T=e[(t+1)*2],E=e[(t+1)*2+1],D=-(S-w),O=x-C,j=Math.sqrt(D*D+O*O),D/=j,O/=j,D*=v,O*=v,k=-(w-E),A=C-T,j=Math.sqrt(k*k+A*A),k/=j,A/=j,k*=v,A*=v;let n=C-x,r=S-w,i=C-T,a=E-w,o=n*i+r*a,s=r*i-a*n,l=s<0;if(Math.abs(s)<.001*Math.abs(o)){m.push(C-D*N,w-O*N),m.push(C+D*P,w+O*P),o>=0&&(c.join===`round`?g+=W(C,w,C-D*N,w-O*N,C-k*N,w-A*N,m,!1)+4:g+=2,m.push(C-k*P,w-A*P),m.push(C+k*N,w+A*N));continue}let u=(-D+x)*(-O+w)-(-D+C)*(-O+S),d=(-k+T)*(-A+w)-(-k+C)*(-A+E),f=(n*d-i*u)/s,p=(a*u-r*d)/s,h=(f-C)*(f-C)+(p-w)*(p-w),_=C+(f-C)*N,M=w+(p-w)*N,F=C-(f-C)*P,I=w-(p-w)*P,ee=Math.min(n*n+r*r,i*i+a*a),te=l?N:P;h<=ee+te*te*y?c.join===`bevel`||h/y>b?(l?(m.push(_,M),m.push(C+D*P,w+O*P),m.push(_,M),m.push(C+k*P,w+A*P)):(m.push(C-D*N,w-O*N),m.push(F,I),m.push(C-k*N,w-A*N),m.push(F,I)),g+=2):c.join===`round`?l?(m.push(_,M),m.push(C+D*P,w+O*P),g+=W(C,w,C+D*P,w+O*P,C+k*P,w+A*P,m,!0)+4,m.push(_,M),m.push(C+k*P,w+A*P)):(m.push(C-D*N,w-O*N),m.push(F,I),g+=W(C,w,C-D*N,w-O*N,C-k*N,w-A*N,m,!1)+4,m.push(C-k*N,w-A*N),m.push(F,I)):(m.push(_,M),m.push(F,I)):(m.push(C-D*N,w-O*N),m.push(C+D*P,w+O*P),c.join===`round`?l?g+=W(C,w,C+D*P,w+O*P,C+k*P,w+A*P,m,!0)+2:g+=W(C,w,C-D*N,w-O*N,C-k*N,w-A*N,m,!1)+2:c.join===`miter`&&h/y<=b&&(l?(m.push(F,I),m.push(F,I)):(m.push(_,M),m.push(_,M)),g+=2),m.push(C-k*N,w-A*N),m.push(C+k*P,w+A*P),g+=2)}x=e[(h-2)*2],S=e[(h-2)*2+1],C=e[(h-1)*2],w=e[(h-1)*2+1],D=-(S-w),O=x-C,j=Math.sqrt(D*D+O*O),D/=j,O/=j,D*=v,O*=v,m.push(C-D*N,w-O*N),m.push(C+D*P,w+O*P),f||(c.cap===`round`?g+=W(C-D*(N-P)*.5,w-O*(N-P)*.5,C-D*N,w-O*N,C+D*P,w+O*P,m,!1)+2:c.cap===`square`&&(g+=Je(C,w,D,O,N,P,!1,m)));let F=Ge*Ge;for(let e=_;e<g+_-2;++e)x=m[e*2],S=m[e*2+1],C=m[(e+1)*2],w=m[(e+1)*2+1],T=m[(e+2)*2],E=m[(e+2)*2+1],!(Math.abs(x*(w-E)+C*(E-S)+T*(S-w))<F)&&r.push(e,e+1,e+2);return{vertices:n,indices:r}}function qe(e){let t=e.length;if(t<6)return 1;let n=0;for(let r=0,i=e[t-2],a=e[t-1];r<t;r+=2){let t=e[r],o=e[r+1];n+=(t-i)*(o+a),i=t,a=o}return n<0?-1:1}function Je(e,t,n,r,i,a,o,s){let c=e-n*i,l=t-r*i,u=e+n*a,d=t+r*a,f,p;o?(f=r,p=-n):(f=-r,p=n);let m=c+f,h=l+p,g=u+f,_=d+p;return s.push(m,h),s.push(g,_),2}function W(e,t,n,r,i,a,o,s){let c=n-e,l=r-t,u=Math.atan2(c,l),d=Math.atan2(i-e,a-t);s&&u<d?u+=Math.PI*2:!s&&u>d&&(d+=Math.PI*2);let f=u,p=d-u,m=Math.abs(p),h=Math.sqrt(c*c+l*l),g=(15*m*Math.sqrt(h)/Math.PI>>0)+1,_=p/g;if(f+=_,s){o.push(e,t),o.push(n,r);for(let n=1,r=f;n<g;n++,r+=_)o.push(e,t),o.push(e+Math.sin(r)*h,t+Math.cos(r)*h);o.push(e,t),o.push(i,a)}else{o.push(n,r),o.push(e,t);for(let n=1,r=f;n<g;n++,r+=_)o.push(e+Math.sin(r)*h,t+Math.cos(r)*h),o.push(e,t);o.push(i,a),o.push(e,t)}return g*2}var G=class e{_array;constructor(e=1,t=0,n=0,r=1,i=0,a=0){this.a=e,this.b=t,this.c=n,this.d=r,this.tx=i,this.ty=a}set(e,t,n,r,i,a){return this.a=e,this.b=t,this.c=n,this.d=r,this.tx=i,this.ty=a,this}append(e){let t=this.a,n=this.b,r=this.c,i=this.d;return this.a=e.a*t+e.b*r,this.b=e.a*n+e.b*i,this.c=e.c*t+e.d*r,this.d=e.c*n+e.d*i,this.tx=e.tx*t+e.ty*r+this.tx,this.ty=e.tx*n+e.ty*i+this.ty,this}appendFrom(e,t){let n=e.a,r=e.b,i=e.c,a=e.d,o=e.tx,s=e.ty,c=t.a,l=t.b,u=t.c,d=t.d;return this.a=n*c+r*u,this.b=n*l+r*d,this.c=i*c+a*u,this.d=i*l+a*d,this.tx=o*c+s*u+t.tx,this.ty=o*l+s*d+t.ty,this}setTransform(e,t,n,r,i,a,o,s,c){return this.a=Math.cos(o+c)*i,this.b=Math.sin(o+c)*i,this.c=-Math.sin(o-s)*a,this.d=Math.cos(o-s)*a,this.tx=e-(n*this.a+r*this.c),this.ty=t-(n*this.b+r*this.d),this}prepend(e){let t=this.tx;if(e.a!==1||e.b!==0||e.c!==0||e.d!==1){let t=this.a,n=this.c;this.a=t*e.a+this.b*e.c,this.b=t*e.b+this.b*e.d,this.c=n*e.a+this.d*e.c,this.d=n*e.b+this.d*e.d}return this.tx=t*e.a+this.ty*e.c+e.tx,this.ty=t*e.b+this.ty*e.d+e.ty,this}skewX(e){let t=Math.tan(e);return this.a+=t*this.b,this.c+=t*this.d,this.tx+=t*this.ty,this}skewY(e){let t=Math.tan(e);return this.b+=t*this.a,this.d+=t*this.c,this.ty+=t*this.tx,this}skew(e,t){let n=Math.tan(e),r=Math.tan(t),i=this.a,a=this.b,o=this.c,s=this.d,c=this.tx,l=this.ty;return this.a=i+n*a,this.b=r*i+a,this.c=o+n*s,this.d=r*o+s,this.tx=c+n*l,this.ty=r*c+l,this}translateX(e){return this.translate(e,0)}translateY(e){return this.translate(0,e)}translateZ(e){return this.translate(0,0,e)}translate3d(e,t,n){return this.translate(e,t,n)}translate(e,t,n=0){return this.tx+=e,this.ty+=t,this}scaleX(e){return this.scale(e,1)}scaleY(e){return this.scale(1,e)}scale3d(e,t,n=1){return this.scale(e,t,n)}scale(e,t,n=1){return this.a*=e,this.d*=t,this.c*=e,this.b*=t,this.tx*=e,this.ty*=t,this}rotateX(e){return this.scaleY(this._rotateToScale(e))}rotateY(e){return this.scaleX(this._rotateToScale(e))}rotateZ(e){return this.rotate(e)}rotate(e){let t=Math.cos(e),n=Math.sin(e),r=this.a,i=this.c,a=this.tx;return this.a=r*t-this.b*n,this.b=r*n+this.b*t,this.c=i*t-this.d*n,this.d=i*n+this.d*t,this.tx=a*t-this.ty*n,this.ty=a*n+this.ty*t,this}rotate3d(e,t,n,r){let[i,a,o]=this._rotate3d(e,t,n,r);return i&&this.rotateX(i),a&&this.rotateY(a),o&&this.rotateZ(o),this}_rotateToScale(e){let t=e/c;return t<=.5?t*-4+1:(t-1)*4+1}_rotate3d(e,t,n,r){if(e===1&&t===0&&n===0)return[r,0,0];if(e===0&&t===1&&n===0)return[0,r,0];if(e===0&&t===0)return[0,0,r];{let i=Math.cos(r),a=Math.sin(r),o=i+e*e*(1-i),s=e*t*(1-i)-n*a,c=e*n*(1-i)+t*a,l=i+t*t*(1-i),u=t*n*(1-i)-e*a,d=i+n*n*(1-i);return[-Math.atan2(-u,l),-Math.atan2(c,Math.sqrt(u*u+d*d)),-Math.atan2(-s,o)]}}decompose(e={x:0,y:0},t={position:{x:0,y:0},scale:{x:0,y:0},skew:{x:0,y:0},rotation:0}){let{a:n,b:r,c:i,d:a,tx:o,ty:s}=this,l=-Math.atan2(-i,a),u=Math.atan2(r,n),d=Math.abs(l+u);return d<1e-5||Math.abs(c-d)<1e-5?(t.rotation=u,t.skew.x=t.skew.y=0):(t.rotation=0,t.skew.x=l,t.skew.y=u),t.scale.x=Math.sqrt(n*n+r*r),t.scale.y=Math.sqrt(i*i+a*a),t.position.x=o+(e.x*n+e.y*i),t.position.y=s+(e.x*r+e.y*a),t}apply(e,t){t||=new i;let{x:n,y:r}=e;return t.x=this.a*n+this.c*r+this.tx,t.y=this.b*n+this.d*r+this.ty,t}affineInvert(){let e=this.a,t=this.b,n=this.c,r=this.d,i=this.tx,a=e*r-t*n;return this.a=r/a,this.b=-t/a,this.c=-n/a,this.d=e/a,this.tx=(n*this.ty-r*i)/a,this.ty=-(e*this.ty-t*i)/a,this}affineInverse(){return this.clone().affineInvert()}applyAffineInverse(e,t){t||=new i;let{a:n,b:r,c:a,d:o,tx:s,ty:c}=this,l=1/(n*o+a*-r),u=e.x,d=e.y;return t.x=o*l*u+-a*l*d+(c*a-s*o)*l,t.y=n*l*d+-r*l*u+(-c*n+s*r)*l,t}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this}isIdentity(){let{a:e,b:t,c:n,d:r,tx:i,ty:a}=this;return e===1&&t===0&&n===0&&r===1&&i===0&&a===0}copyTo(e){return e.a=this.a,e.b=this.b,e.c=this.c,e.d=this.d,e.tx=this.tx,e.ty=this.ty,e}copyFrom(e){return this.a=e.a,this.b=e.b,this.c=e.c,this.d=e.d,this.tx=e.tx,this.ty=e.ty,this}equals(e){return e.a===this.a&&e.b===this.b&&e.c===this.c&&e.d===this.d&&e.tx===this.tx&&e.ty===this.ty}prependCssTransform(t,n={}){let{width:r=1,height:i=1}=n,a=new e;return m(t,{width:r,height:i}).reverse().forEach(({name:e,args:t})=>{let n=t.map(e=>e.normalizedIntValue);switch(e){case`translateX`:a.translateX(n[0]*r);break;case`translateY`:a.translateY(n[0]*i);break;case`translateZ`:a.translateZ(n[0]);break;case`translate`:a.translate(n[0]*r,(n[1]??n[0])*i);break;case`translate3d`:a.translate3d(n[0]*r,(n[1]??n[0])*i,n[2]??n[1]??n[0]);break;case`scaleX`:a.scaleX(n[0]);break;case`scaleY`:a.scaleY(n[0]);break;case`scale`:a.scale(n[0],n[1]??n[0]);break;case`scale3d`:a.scale3d(n[0],n[1]??n[0],n[2]??n[1]??n[0]);break;case`rotateX`:a.rotateX(n[0]*c);break;case`rotateY`:a.rotateY(n[0]*c);break;case`rotateZ`:a.rotateZ(n[0]*c);break;case`rotate`:a.rotate(n[0]*c);break;case`rotate3d`:a.rotate3d(n[0]*c,(n[1]??n[0])*c,(n[2]??n[1]??n[0])*c,(n[3]??n[2]??n[1]??n[0])*c);break;case`skewX`:a.skewX(n[0]*c);break;case`skewY`:a.skewY(n[0]*c);break;case`skew`:a.skew(n[0]*c,(n[0]??n[1])*c);break;case`matrix`:a.set(n[0],n[1],n[2],n[3],n[4],n[5]);break}}),this.prepend(a),this}clone(){return new e(this.a,this.b,this.c,this.d,this.tx,this.ty)}toArray(e,t){this._array||=new Float32Array(9);let n=t||this._array;return e?(n[0]=this.a,n[1]=this.b,n[2]=0,n[3]=this.c,n[4]=this.d,n[5]=0,n[6]=this.tx,n[7]=this.ty,n[8]=1):(n[0]=this.a,n[1]=this.c,n[2]=this.tx,n[3]=this.b,n[4]=this.d,n[5]=this.ty,n[6]=0,n[7]=0,n[8]=1),n}toString(){return`[Transform2D a=${this.a} b=${this.b} c=${this.c} d=${this.d} tx=${this.tx} ty=${this.ty}]`}toJSON(){return{a:this.a,b:this.b,c:this.c,d:this.d,tx:this.tx,ty:this.ty}}destroy(){this._array=void 0}};function Ye(e,t,n,r){let i=e*n+t*r,a=Math.sqrt(e*e+t*t)*Math.sqrt(n*n+r*r),o=Math.acos(Math.max(-1,Math.min(1,i/a)));return e*r-t*n<0&&(o=-o),o}function Xe(e,t,n,r,i,a,o,s){if(t===0||n===0){e.lineTo(s.x,s.y);return}r=r*Math.PI/180,t=Math.abs(t),n=Math.abs(n);let c=(o.x-s.x)/2,l=(o.y-s.y)/2,u=Math.cos(r)*c+Math.sin(r)*l,d=-Math.sin(r)*c+Math.cos(r)*l,f=t*t,p=n*n,m=u*u,h=d*d,g=m/f+h/p;if(g>1){let e=Math.sqrt(g);t=e*t,n=e*n,f=t*t,p=n*n}let _=f*h+p*m,v=(f*p-_)/_,y=Math.sqrt(Math.max(0,v));i===a&&(y=-y);let b=y*t*d/n,x=-y*n*u/t,S=Math.cos(r)*b-Math.sin(r)*x+(o.x+s.x)/2,C=Math.sin(r)*b+Math.cos(r)*x+(o.y+s.y)/2,w=Ye(1,0,(u-b)/t,(d-x)/n),T=Ye((u-b)/t,(d-x)/n,(-u-b)/t,(-d-x)/n)%(Math.PI*2);e.ellipse(S,C,t,n,r,w,w+T,a===0)}var K={SEPARATOR:/[ \t\r\n,.\-+]/,WHITESPACE:/[ \t\r\n]/,DIGIT:/\d/,SIGN:/[-+]/,POINT:/\./,COMMA:/,/,EXP:/e/i,FLAGS:/[01]/};function q(e,t,n=0){let r=0,i=!0,a=``,o=``,s=[];function c(e,t,n){let r=SyntaxError(`Unexpected character "${e}" at index ${t}.`);throw r.partial=n,r}function l(){a!==``&&(o===``?s.push(Number(a)):s.push(Number(a)*10**Number(o))),a=``,o=``}let u,d=e.length;for(let f=0;f<d;f++){if(u=e[f],Array.isArray(t)&&t.includes(s.length%n)&&K.FLAGS.test(u)){r=1,a=u,l();continue}if(r===0){if(K.WHITESPACE.test(u))continue;if(K.DIGIT.test(u)||K.SIGN.test(u)){r=1,a=u;continue}if(K.POINT.test(u)){r=2,a=u;continue}K.COMMA.test(u)&&(i&&c(u,f,s),i=!0)}if(r===1){if(K.DIGIT.test(u)){a+=u;continue}if(K.POINT.test(u)){a+=u,r=2;continue}if(K.EXP.test(u)){r=3;continue}K.SIGN.test(u)&&a.length===1&&K.SIGN.test(a[0])&&c(u,f,s)}if(r===2){if(K.DIGIT.test(u)){a+=u;continue}if(K.EXP.test(u)){r=3;continue}K.POINT.test(u)&&a[a.length-1]===`.`&&c(u,f,s)}if(r===3){if(K.DIGIT.test(u)){o+=u;continue}if(K.SIGN.test(u)){if(o===``){o+=u;continue}o.length===1&&K.SIGN.test(o)&&c(u,f,s)}}K.WHITESPACE.test(u)?(l(),r=0,i=!1):K.COMMA.test(u)?(l(),r=0,i=!0):K.SIGN.test(u)?(l(),r=1,a=u):K.POINT.test(u)?(l(),r=2,a=u):c(u,f,s)}return l(),s}function J(e,t){return e-(t-e)}function Ze(e,t){let n=new i,r=new i,a=``;for(let i=0,o=e.length;i<o;i++){let o=e[i];if(((o.type===`s`||o.type===`S`)&&!`CcSs`.includes(a)||(o.type===`t`||o.type===`T`)&&!`QqTt`.includes(a))&&r.copyFrom(n),o.type===`m`||o.type===`M`)o.type===`m`?n.add(o):n.copyFrom(o),t.moveTo(n.x,n.y),r.copyFrom(n);else if(o.type===`h`||o.type===`H`)o.type===`h`?n.x+=o.x:n.x=o.x,t.lineTo(n.x,n.y),r.copyFrom(n);else if(o.type===`v`||o.type===`V`)o.type===`v`?n.y+=o.y:n.y=o.y,t.lineTo(n.x,n.y),r.copyFrom(n);else if(o.type===`l`||o.type===`L`)o.type===`l`?n.add(o):n.copyFrom(o),t.lineTo(n.x,n.y),r.copyFrom(n);else if(o.type===`c`||o.type===`C`)o.type===`c`?(t.bezierCurveTo(n.x+o.x1,n.y+o.y1,n.x+o.x2,n.y+o.y2,n.x+o.x,n.y+o.y),r.x=n.x+o.x2,r.y=n.y+o.y2,n.add(o)):(t.bezierCurveTo(o.x1,o.y1,o.x2,o.y2,o.x,o.y),r.x=o.x2,r.y=o.y2,n.copyFrom(o));else if(o.type===`s`||o.type===`S`)o.type===`s`?(t.bezierCurveTo(J(n.x,r.x),J(n.y,r.y),n.x+o.x2,n.y+o.y2,n.x+o.x,n.y+o.y),r.x=n.x+o.x2,r.y=n.y+o.y2,n.add(o)):(t.bezierCurveTo(J(n.x,r.x),J(n.y,r.y),o.x2,o.y2,o.x,o.y),r.x=o.x2,r.y=o.y2,n.copyFrom(o));else if(o.type===`q`||o.type===`Q`)o.type===`q`?(t.quadraticCurveTo(n.x+o.x1,n.y+o.y1,n.x+o.x,n.y+o.y),r.x=n.x+o.x1,r.y=n.y+o.y1,n.add(o)):(t.quadraticCurveTo(o.x1,o.y1,o.x,o.y),r.x=o.x1,r.y=o.y1,n.copyFrom(o));else if(o.type===`t`||o.type===`T`){let e=J(n.x,r.x),i=J(n.y,r.y);r.x=e,r.y=i,o.type===`t`?(t.quadraticCurveTo(e,i,n.x+o.x,n.y+o.y),n.add(o)):(t.quadraticCurveTo(e,i,o.x,o.y),n.copyFrom(o))}else if(o.type===`a`||o.type===`A`){let e=n.clone();if(o.type===`a`){if(o.x===0&&o.y===0)continue;n.add(o)}else{if(n.equals(o))continue;n.copyFrom(o)}r.copyFrom(n),Xe(t,o.rx,o.ry,o.angle,o.largeArcFlag,o.sweepFlag,e,n)}else o.type===`z`||o.type===`Z`?(t.startPoint&&n.copyFrom(t.startPoint),t.closePath()):console.warn(`Unsupported commands`,o);a=o.type}}function Qe(e){let t,n,r=[];for(let i=0,a=e.length;i<a;i++){let a=e[i];switch(a.type){case`m`:case`M`:if(a.x.toFixed(4)===n?.x.toFixed(4)&&a.y.toFixed(4)===n?.y.toFixed(4))continue;r.push(`${a.type} ${a.x} ${a.y}`),n={x:a.x,y:a.y},t={x:a.x,y:a.y};break;case`h`:case`H`:r.push(`${a.type} ${a.x}`),n={x:a.x,y:n?.y??0};break;case`v`:case`V`:r.push(`${a.type} ${a.y}`),n={x:n?.x??0,y:a.y};break;case`l`:case`L`:r.push(`${a.type} ${a.x} ${a.y}`),n={x:a.x,y:a.y};break;case`c`:case`C`:r.push(`${a.type} ${a.x1} ${a.y1} ${a.x2} ${a.y2} ${a.x} ${a.y}`),n={x:a.x,y:a.y};break;case`s`:case`S`:r.push(`${a.type} ${a.x2} ${a.y2} ${a.x} ${a.y}`),n={x:a.x,y:a.y};break;case`q`:case`Q`:r.push(`${a.type} ${a.x1} ${a.y1} ${a.x} ${a.y}`),n={x:a.x,y:a.y};break;case`t`:case`T`:r.push(`${a.type} ${a.x} ${a.y}`),n={x:a.x,y:a.y};break;case`a`:case`A`:r.push(`${a.type} ${a.rx} ${a.ry} ${a.angle} ${a.largeArcFlag} ${a.sweepFlag} ${a.x} ${a.y}`),n={x:a.x,y:a.y};break;case`z`:case`Z`:r.push(a.type),t&&(n={x:t.x,y:t.y});break;default:break}}return r.join(` `)}var $e=/[a-df-z][^a-df-z]*/gi;function et(e){let t=[],n=e.match($e);if(!n)return t;for(let e=0,r=n.length;e<r;e++){let r=n[e],i=r.charAt(0),a=r.slice(1).trim(),o;switch(i){case`m`:case`M`:o=q(a);for(let e=0,n=o.length;e<n;e+=2)e===0?t.push({type:i,x:o[e],y:o[e+1]}):t.push({type:i===`m`?`l`:`L`,x:o[e],y:o[e+1]});break;case`h`:case`H`:o=q(a);for(let e=0,n=o.length;e<n;e++)t.push({type:i,x:o[e]});break;case`v`:case`V`:o=q(a);for(let e=0,n=o.length;e<n;e++)t.push({type:i,y:o[e]});break;case`l`:case`L`:o=q(a);for(let e=0,n=o.length;e<n;e+=2)t.push({type:i,x:o[e],y:o[e+1]});break;case`c`:case`C`:o=q(a);for(let e=0,n=o.length;e<n;e+=6)t.push({type:i,x1:o[e],y1:o[e+1],x2:o[e+2],y2:o[e+3],x:o[e+4],y:o[e+5]});break;case`s`:case`S`:o=q(a);for(let e=0,n=o.length;e<n;e+=4)t.push({type:i,x2:o[e],y2:o[e+1],x:o[e+2],y:o[e+3]});break;case`q`:case`Q`:o=q(a);for(let e=0,n=o.length;e<n;e+=4)t.push({type:i,x1:o[e],y1:o[e+1],x:o[e+2],y:o[e+3]});break;case`t`:case`T`:o=q(a);for(let e=0,n=o.length;e<n;e+=2)t.push({type:i,x:o[e],y:o[e+1]});break;case`a`:case`A`:o=q(a,[3,4],7);for(let e=0,n=o.length;e<n;e+=7)t.push({type:i,rx:o[e],ry:o[e+1],angle:o[e+2],largeArcFlag:o[e+3],sweepFlag:o[e+4],x:o[e+5],y:o[e+6]});break;case`z`:case`Z`:t.push({type:i});break;default:console.warn(r)}}return t}var tt=`data:image/svg+xml;`,nt=`${tt}base64,`,rt=`${tt}charset=utf8,`;function it(e){if(typeof e==`string`){let t;e.startsWith(nt)?(e=e.substring(nt.length,e.length),t=atob(e)):e.startsWith(rt)?(e=e.substring(rt.length,e.length),t=decodeURIComponent(e)):t=e;let n=new DOMParser().parseFromString(t,`text/xml`),r=n.querySelector(`parsererror`);if(r)throw Error(`${r.textContent??`parser error`}\n${t}`);return n.documentElement}else return e}var at=`px`,ot=90,st=[`mm`,`cm`,`in`,`pt`,`pc`,`px`],ct={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 Y(e){let t=`px`;if(typeof e==`string`)for(let n=0,r=st.length;n<r;n++){let r=st[n];if(e.endsWith(r)){t=r,e=e.substring(0,e.length-r.length);break}}let n;return t===`px`&&at!==`px`?n=ct.in[at]/ot:(n=ct[t][at],n<0&&(n=ct[t].in*ot)),n*Number.parseFloat(e)}function lt(e,t,n){if(!(e.hasAttribute(`transform`)||e.nodeName===`use`&&(e.hasAttribute(`x`)||e.hasAttribute(`y`))))return null;let r=ut(e);return n.length>0&&r.prepend(n[n.length-1]),t.copyFrom(r),n.push(r),r}function ut(e){let t=new G;return e.nodeName===`use`&&(e.hasAttribute(`x`)||e.hasAttribute(`y`))&&t.translate(Y(e.getAttribute(`x`)),Y(e.getAttribute(`y`))),e.hasAttribute(`transform`)&&t.prependCssTransform(e.getAttribute(`transform`)),t}function dt(e){return new $().arc(Y(e.getAttribute(`cx`)||0),Y(e.getAttribute(`cy`)||0),Y(e.getAttribute(`r`)||0),0,Math.PI*2)}function ft(e,t){if(!(!e.sheet||!e.sheet.cssRules||!e.sheet.cssRules.length))for(let n=0;n<e.sheet.cssRules.length;n++){let r=e.sheet.cssRules[n];if(r.type!==1)continue;let i=r.selectorText.split(/,/g).filter(Boolean).map(e=>e.trim()),a={};for(let e=r.style.length,t=0;t<e;t++){let e=r.style.item(t);a[e]=r.style.getPropertyValue(e)}for(let e=0;e<i.length;e++)t[i[e]]=Object.assign(t[i[e]]||{},{...a})}}function pt(e){return new $().ellipse(Y(e.getAttribute(`cx`)||0),Y(e.getAttribute(`cy`)||0),Y(e.getAttribute(`rx`)||0),Y(e.getAttribute(`ry`)||0),0,0,Math.PI*2)}function mt(e){return new $().moveTo(Y(e.getAttribute(`x1`)||0),Y(e.getAttribute(`y1`)||0)).lineTo(Y(e.getAttribute(`x2`)||0),Y(e.getAttribute(`y2`)||0))}function ht(e){let t=new $,n=e.getAttribute(`d`);return!n||n===`none`?null:(t.addData(n),t)}var gt=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function _t(e){let t=new $,n=0;return e.getAttribute(`points`)?.replace(gt,(e,r,i)=>{let a=Y(r),o=Y(i);return n===0?t.moveTo(a,o):t.lineTo(a,o),n++,e}),t.currentCurve.autoClose=!0,t}var vt=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function yt(e){let t=new $,n=0;return e.getAttribute(`points`)?.replace(vt,(e,r,i)=>{let a=Y(r),o=Y(i);return n===0?t.moveTo(a,o):t.lineTo(a,o),n++,e}),t.currentCurve.autoClose=!1,t}function bt(e){let t=Y(e.getAttribute(`x`)||0),n=Y(e.getAttribute(`y`)||0),r=e.getAttribute(`rx`),i=e.getAttribute(`ry`),a=Y(r??i??0),o=Y(i??r??0),s=Y(e.getAttribute(`width`)),c=Y(e.getAttribute(`height`));a=Math.max(0,Math.min(a,s/2)),o=Math.max(0,Math.min(o,c/2));let l=.448084975506,u=new $;return u.moveTo(t+a,n),u.lineTo(t+s-a,n),(a!==0||o!==0)&&u.bezierCurveTo(t+s-a*l,n,t+s,n+o*l,t+s,n+o),u.lineTo(t+s,n+c-o),(a!==0||o!==0)&&u.bezierCurveTo(t+s,n+c-o*l,t+s-a*l,n+c,t+s-a,n+c),u.lineTo(t+a,n+c),(a!==0||o!==0)&&u.bezierCurveTo(t+a*l,n+c,t,n+c-o*l,t,n+c-o),u.lineTo(t,n+o),(a!==0||o!==0)&&u.bezierCurveTo(t,n+o*l,t+a*l,n,t+a,n),u}function X(e,t,n){t=Object.assign({},t);let r={};if(e.hasAttribute(`class`)){let t=e.getAttribute(`class`).split(/\s/).filter(Boolean).map(e=>e.trim());for(let e=0;e<t.length;e++)r=Object.assign(r,n[`.${t[e]}`])}e.hasAttribute(`id`)&&(r=Object.assign(r,n[`#${e.getAttribute(`id`)}`]));for(let n=e.style.length,i=0;i<n;i++){let n=e.style.item(i),a=e.style.getPropertyValue(n);t[n]=a,r[n]=a}function i(n,i,o=a){e.hasAttribute(n)&&(t[i]=o(e.getAttribute(n))),r[n]&&(t[i]=o(r[n]))}function a(e){return e.startsWith(`url`)&&console.warn(`url access in attributes is not implemented.`),e}function o(e){return Math.max(0,Math.min(1,Y(e)))}function s(e){return Math.max(0,Y(e))}function c(e){return e.split(` `).filter(e=>e!==``).map(e=>Y(e))}return i(`fill`,`fill`),i(`fill-opacity`,`fillOpacity`,o),i(`fill-rule`,`fillRule`),i(`opacity`,`opacity`,o),i(`stroke`,`stroke`),i(`stroke-opacity`,`strokeOpacity`,o),i(`stroke-width`,`strokeWidth`,s),i(`stroke-linecap`,`strokeLinecap`),i(`stroke-linejoin`,`strokeLinejoin`),i(`stroke-miterlimit`,`strokeMiterlimit`,s),i(`stroke-dasharray`,`strokeDasharray`,c),i(`stroke-dashoffset`,`strokeDashoffset`,Y),i(`visibility`,`visibility`),t}function xt(e,t,n=[],r={}){if(e.nodeType!==1)return n;let i=!1,a=null,o={...t};switch(e.nodeName){case`svg`:o=X(e,o,r);break;case`style`:ft(e,r);break;case`g`:o=X(e,o,r);break;case`path`:o=X(e,o,r),e.hasAttribute(`d`)&&(a=ht(e));break;case`rect`:o=X(e,o,r),a=bt(e);break;case`polygon`:o=X(e,o,r),a=_t(e);break;case`polyline`:o=X(e,o,r),a=yt(e);break;case`circle`:o=X(e,o,r),a=dt(e);break;case`ellipse`:o=X(e,o,r),a=pt(e);break;case`line`:o=X(e,o,r),a=mt(e);break;case`defs`:i=!0;break;case`use`:{o=X(e,o,r);let t=(e.getAttributeNS(`http://www.w3.org/1999/xlink`,`href`)||e.getAttribute(`href`)||``).substring(1),i=e.viewportElement?.getElementById(t);i?xt(i,o,n,r):console.warn(`'use node' references non-existent node id: ${t}`);break}default:console.warn(e);break}if(o.display===`none`)return n;let s=new G,c=[],l=lt(e,s,c);a&&(a.applyTransform(s),n.push(a),a.style={...o});let u=e.childNodes;for(let e=0,t=u.length;e<t;e++){let t=u[e];i&&t.nodeName!==`style`&&t.nodeName!==`defs`||xt(t,o,n,r)}return l&&(c.pop(),c.length>0?s.copyFrom(c[c.length-1]):s.identity()),n}function St(e){let t=it(e);return new Wt(xt(t,{}),t.getAttribute(`viewBox`)?.trim().split(` `).map(e=>Number(e)))}var Z=class{arcLengthDivision=200;_lengths=[];getPointAt(e,t=new i){return this.getPoint(this.getUToTMapping(e),t)}isClockwise(){return!1}getControlPointRefs(){return[]}applyTransform(e){let t=typeof e==`function`;return this.getControlPointRefs().forEach(n=>{t?e(n):e.apply(n,n)}),this}getUnevenVertices(e=5,t=[]){let n=new i;for(let r=0,i=Math.max(1,e)-1;r<=i;r++)this.getPoint(r/i,n),t.push(n.x,n.y);return t}getSpacedVertices(e=5,t=[]){let n=new i;for(let r=0,i=Math.max(1,e)-1;r<=i;r++)this.getPointAt(r/i,n),t.push(n.x,n.y);return t}getAdaptiveVertices(e=[]){return this.getUnevenVertices(5,e)}_verticesToPoints(e,t=[]){for(let n=0,r=e.length;n<r;n+=2){let r=e[n],a=e[n+1];t.push(new i(r,a))}return t}getSpacedPoints(e,t=[]){let n=this.getSpacedVertices(e);return this._verticesToPoints(n,t),t}getUnevenPoints(e,t=[]){let n=this.getUnevenVertices(e);return this._verticesToPoints(n,t),t}getAdaptivePoints(e=[]){let t=this.getAdaptiveVertices();return this._verticesToPoints(t,e),e}getPoints(e,t=[]){let n;return n=e?this.getUnevenVertices(e):this.getAdaptiveVertices(),this._verticesToPoints(n,t),t}getLength(){let e=this.getLengths();return e[e.length-1]??0}getLengths(){return this._lengths.length!==this.arcLengthDivision+1&&this.updateLengths(),this._lengths}updateLengths(){let e=this.arcLengthDivision,t=[0];for(let n=0,r=this.getPoint(0),i=1;i<=e;i++){let a=this.getPoint(i/e);n+=a.distanceTo(r),t.push(n),r=a}this._lengths=t}getUToTMapping(e,t){let n=this.getLengths(),r=n.length,i=t??e*n[r-1];if(r<2)return i/n[0];let a=0,o=0,s=r-1,c;for(;o<=s;)if(a=Math.floor(o+(s-o)/2),c=n[a]-i,c<0)o=a+1;else if(c>0)s=a-1;else{s=a;break}if(a=Math.max(0,s),n[a]===i)return a/(r-1);let l=n[a],u=n[a+1]-l,d=Math.max(0,(i-l)/u);return(a+d)/(r-1)}getTangent(e,t=new i){let n=1e-4,r=Math.max(0,e-n),a=Math.min(1,e+n);return t.copyFrom(this.getPoint(a).sub(this.getPoint(r)).normalize())}getTangentAt(e,t){return this.getTangent(this.getUToTMapping(e),t)}getNormal(e,t=new i){return this.getTangent(e,t),t.set(-t.y,t.x).normalize()}getNormalAt(e,t){return this.getNormal(this.getUToTMapping(e),t)}getTForPoint(e,t=.001){let n=0,r=1,i=(n+r)/2;for(;r-n>t;){i=(n+r)/2;let a=this.getPoint(i);if(a.distanceTo(e)<t)return i;a.x<e.x?n=i:r=i}return i}getMinMax(e=i.MAX,t=i.MIN){let n=this.getPoints();for(let r=0,i=n.length;r<i;r++){let i=n[r];e.clampMin(i),t.clampMax(i)}return{min:e.finite(),max:t.finite()}}getBoundingBox(){let{min:e,max:t}=this.getMinMax();return new a(e.x,e.y,t.x-e.x,t.y-e.y)}isPointInFill(e,t={}){return Ie(e,this.getAdaptiveVertices(),t.fillRule)}isPointInStroke(e,t={}){let{strokeWidth:n=1,tolerance:r=0,closed:i=!1}=t;return ze(e,this.getAdaptiveVertices(),i)<=n/2+r}contains(e,t,n={}){return this.isPointInFill({x:e,y:t},n)}getFillVertices(e){return this.getAdaptiveVertices()}fillTriangulate(e){return pe(this.getFillVertices(e),e)}strokeTriangulate(e){return Ke(this.getAdaptiveVertices(),e)}toCommands(){let e=[],t=this.getPoints();for(let n=0,r=t.length;n<r;n++){let r=t[n];n===0?e.push({type:`M`,x:r.x,y:r.y}):e.push({type:`L`,x:r.x,y:r.y})}return e}toData(){return Qe(this.toCommands())}drawTo(e){return this.toCommands().forEach(t=>{switch(t.type){case`M`:e.moveTo(t.x,t.y);break;case`L`:e.lineTo(t.x,t.y);break}}),this}copyFrom(e){return this.arcLengthDivision=e.arcLengthDivision,this}clone(){return new this.constructor().copyFrom(this)}},Ct=new G,wt=new G,Tt=new G,Et=new i,Dt=class extends Z{get cx(){return this._center.x}set cx(e){this._center.x=e}get cy(){return this._center.y}set cy(e){this._center.y=e}get rx(){return this._radius.x}set rx(e){this._radius.x=e}get ry(){return this._radius.y}set ry(e){this._radius.y=e}get dx(){return this._diff.x}set dx(e){this._diff.x=e}get dy(){return this._diff.y}set dy(e){this._diff.y=e}constructor(e=new i,t=new i,n=new i,r=0,a=0,o=Math.PI*2,s=!1){super(),this._center=e,this._radius=t,this._diff=n,this.rotate=r,this.startAngle=a,this.endAngle=o,this.clockwise=s}isClockwise(){return this.clockwise}_getDeltaAngle(){let e=Math.PI*2,t=this.endAngle-this.startAngle,n=Math.abs(t)<2**-52;return t=(t%e+e)%e,n?t=0:this.clockwise||(t=t===0?-e:t-e),t}getPoint(e,t=new i){let n=this._getDeltaAngle(),r=this.startAngle+e*n,a=this.cx+this.rx*Math.cos(r),o=this.cy+this.ry*Math.sin(r);if(this.rotate!==0){let e=Math.cos(this.rotate),t=Math.sin(this.rotate),n=a-this.cx,r=o-this.cy;a=n*e-r*t+this.cx,o=n*t+r*e+this.cy}return t.set(a,o)}toCommands(){let{cx:e,cy:t,rx:n,ry:r,startAngle:i,endAngle:a,clockwise:o,rotate:s}=this,c=e+n*Math.cos(i)*Math.cos(s)-r*Math.sin(i)*Math.sin(s),l=t+n*Math.cos(i)*Math.sin(s)+r*Math.sin(i)*Math.cos(s),u=Math.abs(i-a),d=+(u>Math.PI),f=+!!o,p=s*180/Math.PI;if(u>=2*Math.PI){let a=i+Math.PI,o=e+n*Math.cos(a)*Math.cos(s)-r*Math.sin(a)*Math.sin(s),u=t+n*Math.cos(a)*Math.sin(s)+r*Math.sin(a)*Math.cos(s);return[{type:`M`,x:c,y:l},{type:`A`,rx:n,ry:r,angle:p,largeArcFlag:0,sweepFlag:f,x:o,y:u},{type:`A`,rx:n,ry:r,angle:p,largeArcFlag:0,sweepFlag:f,x:c,y:l}]}else{let i=e+n*Math.cos(a)*Math.cos(s)-r*Math.sin(a)*Math.sin(s),o=t+n*Math.cos(a)*Math.sin(s)+r*Math.sin(a)*Math.cos(s);return[{type:`M`,x:c,y:l},{type:`A`,rx:n,ry:r,angle:p,largeArcFlag:d,sweepFlag:f,x:i,y:o}]}}drawTo(e){let{cx:t,cy:n,rx:r,ry:i,rotate:a,startAngle:o,endAngle:s,clockwise:c}=this;return e.ellipse(t,n,r,i,a,o,s,!c),this}applyTransform(e){return Et.set(this.cx,this.cy),e.apply(Et,Et),this.cx=Et.x,this.cy=Et.y,jt(e)?Ot(this,e):kt(this,e),this}getControlPointRefs(){return[this._center]}_getAdaptiveVerticesByArc(e=[]){let{cx:t,cy:n,rx:r,ry:i,dx:a,dy:o,startAngle:s,endAngle:c,clockwise:l,rotate:u}=this,d=!l,f=Math.abs(s-c);(!d&&s>c||d&&c>s)&&(f=2*Math.PI-f);let p=Math.max(12,Math.floor(12*r**(1/3)*(f/Math.PI))),m=f/p,h=s;m*=d?-1:1;let g=Math.cos(d?u:-u),_=Math.sin(d?u:-u);for(let s=0;s<p+1;s++){let s=a+Math.cos(h)*r,c=o+Math.sin(h)*i,l=s*g-c*_,u=s*_+c*g;e.push(t+l,n+u),h+=m}return e}_getAdaptiveVerticesByCircle(e=[]){let{cx:t,cy:n,rx:r,ry:i,dx:a,dy:o,rotate:s,clockwise:c}=this;if(!(r>=0&&i>=0&&a>=0&&o>=0))return e;let l=Math.ceil(2.3*Math.sqrt(r+i)),u=l*8+(a?4:0)+(o?4:0),d=[];if(u===0)return e;{let e=d.length;if(l===0)d[e]=d[e+6]=t+a,d[e+1]=d[e+3]=n+o,d[e+2]=d[e+4]=t-a,d[e+5]=d[e+7]=n-o;else{let s=e,c=e+l*4+(a?2:0)+2,f=c,p=u,m=a+r,h=o,g=t+m,_=t-m,v=n+h;if(d[s++]=g,d[s++]=v,d[--c]=v,d[--c]=_,o){let e=n-h;d[f++]=_,d[f++]=e,d[--p]=e,d[--p]=g}for(let e=1;e<l;e++){let u=Math.PI/2*(e/l),m=a+Math.cos(u)*r,h=o+Math.sin(u)*i,g=t+m,_=t-m,v=n+h,y=n-h;d[s++]=g,d[s++]=v,d[--c]=v,d[--c]=_,d[f++]=_,d[f++]=y,d[--p]=y,d[--p]=g}m=a,h=o+i,g=t+m,_=t-m,v=n+h;let y=n-h;d[s++]=g,d[s++]=v,d[--p]=y,d[--p]=g,a&&(d[s++]=_,d[s++]=v,d[--p]=y,d[--p]=_)}}let f=Math.cos(c?-s:s),p=Math.sin(c?-s:s);for(let r=0;r<d.length;r+=2){let i=d[r],a=d[r+1],o=i-t,s=a-n,c=o*f-s*p,l=o*p+s*f;e.push(t+c,n+l)}return e}getAdaptiveVertices(e=[]){return this.startAngle===0&&this.endAngle===Math.PI*2?this._getAdaptiveVerticesByCircle(e):this._getAdaptiveVerticesByArc(e)}copyFrom(e){return super.copyFrom(e),this.cx=e.cx,this.cy=e.cy,this.rx=e.rx,this.ry=e.ry,this.dx=e.dx,this.dy=e.dy,this.startAngle=e.startAngle,this.endAngle=e.endAngle,this.clockwise=e.clockwise,this.rotate=e.rotate,this}};function Ot(e,t){let n=e.rx,r=e.ry,a=Math.cos(e.rotate),o=Math.sin(e.rotate),s=new i(n*a,n*o),c=new i(-r*o,r*a),l=t.a*s.x+t.c*s.y,u=t.b*s.x+t.d*s.y,d=t.a*c.x+t.c*c.y,f=t.b*c.x+t.d*c.y,p=Ct.set(l,u,d,f,0,0),{a:m,b:h,c:g,d:_}=wt.copyFrom(p).affineInvert(),v=Mt(m*m+h*h,g*m+_*h,g*g+_*_),y=Math.sqrt(v.rt1),b=Math.sqrt(v.rt2);if(e.rx=1/y,e.ry=1/b,e.rotate=Math.atan2(v.sn,v.cs),!((e.endAngle-e.startAngle)%(2*Math.PI)<2**-52)){let n=wt.set(y,0,0,b,0,0),r=Tt.set(v.cs,v.sn,-v.sn,v.cs,0,0),i=n.append(r).append(p),a=e=>{let{x:t,y:n}=i.apply({x:Math.cos(e),y:Math.sin(e)});return Math.atan2(n,t)};e.startAngle=a(e.startAngle),e.endAngle=a(e.endAngle),At(t)&&(e.clockwise=!e.clockwise)}}function kt(e,t){let{scale:n}=t.decompose();e.rx*=n.x,e.ry*=n.y;let r=n.x>2**-52?Math.atan2(t.b,t.a):Math.atan2(-t.c,t.d);e.rotate+=r,At(t)&&(e.startAngle*=-1,e.endAngle*=-1,e.clockwise=!e.clockwise)}function At(e){return e.a*e.d-e.c*e.b<0}function jt(e){let t=e.a*e.c+e.b*e.d;if(t===0)return!1;let{scale:n}=e.decompose();return Math.abs(t/(n.x*n.y))>2**-52}function Mt(e,t,n){let r,i,a,o,s,c=e+n,l=e-n,u=Math.sqrt(l*l+4*t*t);return c>0?(r=.5*(c+u),s=1/r,i=e*s*n-t*s*t):c<0?(i=.5*(c-u),s=1/i,r=e*s*n-t*s*t):(r=.5*u,i=-.5*u),a=l>0?l+u:l-u,Math.abs(a)>2*Math.abs(t)?(s=-2*t/a,o=1/Math.sqrt(1+s*s),a=s*o):Math.abs(t)===0?(a=1,o=0):(s=-.5*a/t,a=1/Math.sqrt(1+s*s),o=s*a),l>0&&(s=a,a=-o,o=s),{rt1:r,rt2:i,cs:a,sn:o}}var Nt=class extends Dt{constructor(e=0,t=0,n=1,r=0,a=Math.PI*2,o=!1){super(new i(e,t),new i(n,n),new i,0,r,a,o)}drawTo(e){let{cx:t,cy:n,rx:r,startAngle:i,endAngle:a,clockwise:o}=this;return e.arc(t,n,r,i,a,!o),this}},Q=class e extends Z{static from(t,n,r,a){return new e(new i(t,n),new i(r,a))}constructor(e=new i,t=new i){super(),this.p1=e,this.p2=t}getPoint(e,t=new i){return e===1?t.copyFrom(this.p2):t.copyFrom(this.p2).sub(this.p1).scale(e).add(this.p1),t}getPointAt(e,t=new i){return this.getPoint(e,t)}getTangent(e,t=new i){return t.subVectors(this.p2,this.p1).normalize()}getTangentAt(e,t=new i){return this.getTangent(e,t)}getControlPointRefs(){return[this.p1,this.p2]}getAdaptiveVertices(e=[]){return e.push(this.p1.x,this.p1.y,this.p2.x,this.p2.y),e}getMinMax(e=i.MAX,t=i.MIN){let{p1:n,p2:r}=this;return e.x=Math.min(e.x,n.x,r.x),e.y=Math.min(e.y,n.y,r.y),t.x=Math.max(t.x,n.x,r.x),t.y=Math.max(t.y,n.y,r.y),{min:e.finite(),max:t.finite()}}toCommands(){let{p1:e,p2:t}=this;return[{type:`M`,x:e.x,y:e.y},{type:`L`,x:t.x,y:t.y}]}getFillVertices(e={}){let t=Math.min(this.p1.x,this.p2.x),n=Math.max(this.p1.x,this.p2.x),r=Math.min(this.p1.y,this.p2.y),i=Math.max(this.p1.y,this.p2.y),a=t,o=r,s=n-t||e.style?.strokeWidth||0,c=i-r||e.style?.strokeWidth||0;return[a,o,a+s,o,a+s,o+c,a,o+c]}drawTo(e){let{p1:t,p2:n}=this;return e.lineTo(t.x,t.y),e.lineTo(n.x,n.y),this}copyFrom(e){return super.copyFrom(e),this.p1.copyFrom(e.p1),this.p2.copyFrom(e.p2),this}},Pt=class e extends Z{constructor(e=[]){super(),this.curves=e}getFlatCurves(){return this.curves.flatMap(t=>t instanceof e?t.getFlatCurves():t)}addCurve(e){return this.curves.push(e),this}getPoint(e,t=new i){let n=e*this.getLength(),r=this.getLengths(),a=r.length;if(a===0)return t;let o=0,s=a-1;for(;o<s;){let e=o+s>>>1;r[e]<n?o=e+1:s=e}let c=r[o]-n,l=this.curves[o],u=l.getLength();return l.getPointAt(u===0?0:1-c/u,t)}getLengths(){return this._lengths.length!==this.curves.length&&this.updateLengths(),this._lengths}updateLengths(){let e=[];for(let t=0,n=0,r=this.curves.length;t<r;t++)n+=this.curves[t].getLength(),e.push(n);this._lengths=e}getControlPointRefs(){return this.curves.flatMap(e=>e.getControlPointRefs())}_removeNextPointIfEqualPrevPoint(e,t){let n=[e[t-1],e[t]],r=[e[t+1],e[t+2]];return n[0]===r[0]&&n[1]===r[1]&&e.splice(t+1,2),e}getSpacedVertices(e=5,t=[]){let n;return this.curves.forEach(r=>{r.getSpacedVertices(e,t),n&&this._removeNextPointIfEqualPrevPoint(t,n),n=t.length-1}),t}getAdaptiveVertices(e=[]){let t;return this.curves.forEach(n=>{n.getAdaptiveVertices(e),t&&this._removeNextPointIfEqualPrevPoint(e,t),t=e.length-1}),e}strokeTriangulate(e){return this.curves.length===1?this.curves[0].strokeTriangulate(e):super.strokeTriangulate(e)}getFillVertices(e){if(this.curves.length===1)return this.curves[0].getFillVertices(e);{let t=[],n;return this.curves.forEach(r=>{let i;i=r instanceof Q?r.getAdaptiveVertices():r.getFillVertices(e),t.push(...i),n&&this._removeNextPointIfEqualPrevPoint(t,n),n=t.length-1}),t}}applyTransform(e){return this.curves.forEach(t=>t.applyTransform(e)),this}getMinMax(e=i.MAX,t=i.MIN){return this.curves.forEach(n=>n.getMinMax(e,t)),{min:e.finite(),max:t.finite()}}getBoundingBox(){let{min:e,max:t}=this.getMinMax();return new a(e.x,e.y,t.x-e.x,t.y-e.y)}toCommands(){return this.curves.flatMap(e=>e.toCommands())}drawTo(e){let t=this.curves[0]?.getPoint(0);return t&&e.moveTo(t.x,t.y),this.curves.forEach(t=>t.drawTo(e)),this}copyFrom(e){return super.copyFrom(e),this.curves=e.curves.map(e=>e.clone()),this}},Ft=class e extends Z{static from(t,n,r,a,o,s,c,l){return new e(new i(t,n),new i(r,a),new i(o,s),new i(c,l))}constructor(e=new i,t=new i,n=new i,r=new i){super(),this.p1=e,this.cp1=t,this.cp2=n,this.p2=r}getPoint(e,t=new i){let{p1:n,cp1:r,cp2:a,p2:o}=this;return t.set(x(e,n.x,r.x,a.x,o.x),x(e,n.y,r.y,a.y,o.y))}getAdaptiveVertices(e=[]){return ve(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,e)}getControlPointRefs(){return[this.p1,this.cp1,this.cp2,this.p2]}_solveQuadratic(e,t,n){if(Math.abs(e)<1e-12){if(Math.abs(t)<1e-12)return[];let e=-n/t;return e>=0&&e<=1?[e]:[]}let r=t*t-4*e*n;if(r<0)return[];let i=Math.sqrt(r);return[(-t+i)/(2*e),(-t-i)/(2*e)].filter(e=>e>=0&&e<=1)}getMinMax(e=i.MAX,t=i.MIN){let{p1:n,cp1:r,cp2:a,p2:o}=this,s=this._solveQuadratic(3*(-n.x+3*r.x-3*a.x+o.x),6*(n.x-2*r.x+a.x),3*(r.x-n.x)),c=this._solveQuadratic(3*(-n.y+3*r.y-3*a.y+o.y),6*(n.y-2*r.y+a.y),3*(r.y-n.y)),l=[0,1,...s,...c];for(let n of l){let r=this.getPoint(n);e.x=Math.min(e.x,r.x),e.y=Math.min(e.y,r.y),t.x=Math.max(t.x,r.x),t.y=Math.max(t.y,r.y)}return{min:e.finite(),max:t.finite()}}toCommands(){let{p1:e,cp1:t,cp2:n,p2:r}=this;return[{type:`M`,x:e.x,y:e.y},{type:`C`,x1:t.x,y1:t.y,x2:n.x,y2:n.y,x:r.x,y:r.y}]}drawTo(e){let{p1:t,cp1:n,cp2:r,p2:i}=this;return e.lineTo(t.x,t.y),e.bezierCurveTo(n.x,n.y,r.x,r.y,i.x,i.y),this}copyFrom(e){return super.copyFrom(e),this.p1.copyFrom(e.p1),this.cp1.copyFrom(e.cp1),this.cp2.copyFrom(e.cp2),this.p2.copyFrom(e.p2),this}},It=class extends Dt{constructor(e=0,t=0,n=1,r=1,a=0,o=0,s=Math.PI*2,c=!1){super(new i(e,t),new i(n,r),new i,a,o,s,c)}drawTo(e){return e.ellipse(this.cx,this.cy,this.rx,this.ry,this.rotate,this.startAngle,this.endAngle,!this.clockwise),this}},Lt=class extends Pt{},Rt=class extends Lt{constructor(e=0,t=0,n=1,r=3){super(),this.cx=e,this.cy=t,this.radius=n,this.sideCount=r,this.update()}update(){let{cx:e,cy:t,radius:n,sideCount:r}=this,a=[];for(let o=0;o<r;o++){let s=o*2*Math.PI/r-.5*Math.PI;a.push(new i(n*Math.cos(s),n*Math.sin(s)).add({x:e,y:t}))}let o=[];for(let e=0;e<r;e++)o.push(new Q(a[e],a[(e+1)%r]));return this.curves=o,this}copyFrom(e){return super.copyFrom(e),this.cx=e.cx,this.cy=e.cy,this.radius=e.radius,this.sideCount=e.sideCount,this.update(),this}},zt=class e extends Z{static from(t,n,r,a,o,s){return new e(new i(t,n),new i(r,a),new i(o,s))}constructor(e=new i,t=new i,n=new i){super(),this.p1=e,this.cp=t,this.p2=n}getPoint(e,t=new i){let{p1:n,cp:r,p2:a}=this;return t.set(Ue(e,n.x,r.x,a.x),Ue(e,n.y,r.y,a.y)),t}getControlPointRefs(){return[this.p1,this.cp,this.p2]}getAdaptiveVertices(e=[]){return Te(this.p1.x,this.p1.y,this.cp.x,this.cp.y,this.p2.x,this.p2.y,.5,e)}getMinMax(e=i.MAX,t=i.MIN){let{p1:n,cp:r,p2:a}=this,o=(e,t,n)=>{let r=e-2*t+n;if(Math.abs(r)<1e-12)return null;let i=(e-t)/r;return i>0&&i<1?i:null},s=o(n.x,r.x,a.x),c=o(n.y,r.y,a.y),l=[n.x,a.x],u=[n.y,a.y];return s!==null&&l.push(Ue(s,n.x,r.x,a.x)),c!==null&&u.push(Ue(c,n.y,r.y,a.y)),e.x=Math.min(e.x,...l),e.y=Math.min(e.y,...u),t.x=Math.max(t.x,...l),t.y=Math.max(t.y,...u),{min:e.finite(),max:t.finite()}}toCommands(){let{p1:e,cp:t,p2:n}=this;return[{type:`M`,x:e.x,y:e.y},{type:`Q`,x1:t.x,y1:t.y,x:n.x,y:n.y}]}drawTo(e){let{p1:t,cp:n,p2:r}=this;return e.lineTo(t.x,t.y),e.quadraticCurveTo(n.x,n.y,r.x,r.y),this}copyFrom(e){return super.copyFrom(e),this.p1.copyFrom(e.p1),this.cp.copyFrom(e.cp),this.p2.copyFrom(e.p2),this}},Bt=class extends Lt{constructor(e=0,t=0,n=0,r=0){super(),this.x=e,this.y=t,this.width=n,this.height=r,this.update()}update(){let{x:e,y:t,width:n,height:r}=this,a=[new i(e,t),new i(e+n,t),new i(e+n,t+r),new i(e,t+r)];return this.curves=[new Q(a[0],a[1]),new Q(a[1],a[2]),new Q(a[2],a[3]),new Q(a[3],a[0])],this}drawTo(e){return e.rect(this.x,this.y,this.width,this.height),this}getFillVertices(e={}){let{x:t,y:n,width:r,height:i}=this;return[t,n,t+r,n,t+r,n+i,t,n+i]}copyFrom(e){return super.copyFrom(e),this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height,this.update(),this}},Vt=class extends Dt{constructor(e=0,t=0,n=1,r=1,i=1){super(),this.x=e,this.y=t,this.width=n,this.height=r,this.radius=i,this.update()}update(){let{x:e,y:t,width:n,height:r,radius:a}=this,o=n/2,s=r/2,c=e+o,l=t+s,u=Math.max(0,Math.min(a,Math.min(o,s))),d=u;return this._center=new i(c,l),this._radius=new i(u,d),this._diff=new i(o-u,s-d),this}drawTo(e){let{x:t,y:n,width:r,height:i,radius:a}=this;return e.roundRect(t,n,r,i,a),this}copyFrom(e){return super.copyFrom(e),this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height,this.radius=e.radius,this.update(),this}},Ht=class extends Z{constructor(e=[]){super(),this.points=e}getPoint(e,t=new i){let{points:n}=this,r=(n.length-1)*e,a=Math.floor(r),s=r-a,c=n[a===0?a:a-1],l=n[a],u=n[a>n.length-2?n.length-1:a+1],d=n[a>n.length-3?n.length-1:a+2];return t.set(o(s,c.x,l.x,u.x,d.x),o(s,c.y,l.y,u.y,d.y)),t}getControlPointRefs(){return this.points}copyFrom(e){super.copyFrom(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++)this.points.push(e.points[t].clone());return this}},Ut=class extends Pt{startPoint;currentPoint;autoClose=!1;constructor(e){super(),e&&this.addPoints(e)}addPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,n=e.length;t<n;t++){let{x:n,y:r}=e[t];this.lineTo(n,r)}return this}addCommands(e){return Ze(e,this),this}addData(e){return this.addCommands(et(e)),this}_closeVertices(e){return this.autoClose&&e.length>=4&&e[0]!==e[e.length-2]&&e[1]!==e[e.length-1]&&e.push(e[0],e[1]),e}getUnevenVertices(e=40,t=[]){return this._closeVertices(super.getUnevenVertices(e,t))}getSpacedVertices(e=40,t=[]){return this._closeVertices(super.getSpacedVertices(e,t))}getAdaptiveVertices(e=[]){return this._closeVertices(super.getAdaptiveVertices(e))}getFillVertices(e){return this._closeVertices(super.getFillVertices(e))}isPointInStroke(e,t={}){let{strokeWidth:n=1,tolerance:r=0}=t,i=this.getAdaptiveVertices(),a=i.length;return ze(e,i,t.closed??(this.autoClose||a>=6&&i[0]===i[a-2]&&i[1]===i[a-1]))<=n/2+r}_setCurrentPoint(e){return this.currentPoint=new i(e.x,e.y),this.startPoint||=this.currentPoint.clone(),this}_connetLineTo(e){if(this.curves.length>0){let t=e.getPoint(0);(!this.currentPoint||!t.equals(this.currentPoint))&&this.lineTo(t.x,t.y)}return this}closePath(){let e=this.startPoint;if(e){let t=this.currentPoint;t&&!e.equals(t)&&(this.curves.push(new Q(t.clone(),e.clone())),t.copyFrom(e)),this.startPoint=void 0}return this}moveTo(e,t){return this.currentPoint=new i(e,t),this.startPoint=this.currentPoint.clone(),this}lineTo(e,t){let n=this.currentPoint;return n?.equals({x:e,y:t})||this.curves.push(Q.from(n?.x??0,n?.y??0,e,t)),this._setCurrentPoint({x:e,y:t}),this}bezierCurveTo(e,t,n,r,i,a){let o=this.currentPoint;return o?.equals({x:i,y:a})||this.curves.push(Ft.from(o?.x??0,o?.y??0,e,t,n,r,i,a)),this._setCurrentPoint({x:i,y:a}),this}quadraticCurveTo(e,t,n,r){let i=this.currentPoint;return i?.equals({x:n,y:r})||this.curves.push(zt.from(i?.x??0,i?.y??0,e,t,n,r)),this._setCurrentPoint({x:n,y:r}),this}arc(e,t,n,r,i,a){let o=new Nt(e,t,n,r,i,!a);return this._connetLineTo(o),this.curves.push(o),this._setCurrentPoint(o.getPoint(1)),this}relativeArc(e,t,n,r,i,a){return e+=this.currentPoint?.x??0,t+=this.currentPoint?.y??0,this.arc(e,t,n,r,i,a),this}arcTo(e,t,n,r,i){return console.warn(`Method arcTo not supported yet`),this}ellipse(e,t,n,r,i,a,o,s=!0){let c=new It(e,t,n,r,i,a,o,!s);return this._connetLineTo(c),this.curves.push(c),this._setCurrentPoint(c.getPoint(1)),this}relativeEllipse(e,t,n,r,i,a,o,s){return e+=this.currentPoint?.x??0,t+=this.currentPoint?.y??0,this.ellipse(e,t,n,r,i,a,o,s),this}rect(e,t,n,r){let i=new Bt(e,t,n,r);return this._connetLineTo(i),this.curves.push(i),this._setCurrentPoint({x:e,y:t}),this}roundRect(e,t,n,r,i){let a=new Vt(e,t,n,r,i);return this._connetLineTo(a),this.curves.push(a),this._setCurrentPoint({x:e,y:t}),this}splineThru(e){let t=this.currentPoint??new i;return this.curves.push(new Ht([t].concat(e))),this._setCurrentPoint(e[e.length-1]),this}drawTo(e){let t=this.curves[0]?.getPoint(0);return t&&e.moveTo(t.x,t.y),this.curves.forEach(t=>t.drawTo(e)),this.autoClose&&e.closePath(),this}copyFrom(e){return super.copyFrom(e),this.autoClose=e.autoClose,this.currentPoint=e.currentPoint?.clone(),this}},$=class e extends Pt{_meta;currentCurve=new Ut;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,n={}){super(),this.curves.push(this.currentCurve),this.style=n,t&&(t instanceof e?this.addPath(t):Array.isArray(t)?this.addCommands(t):this.addData(t))}getMeta(){return this._meta}setMeta(e){return this._meta=e,this}addPath(t){let n=t instanceof e?t.curves:[t];if(n.filter(e=>e.curves.length).length===0)return this;if(!this.currentCurve.curves.length){let e=this.curves.findIndex(e=>e===this.currentCurve);e>-1&&this.curves.splice(e,1)}return this.curves.push(...n.map(e=>e.clone())),this.currentCurve=this.curves[this.curves.length-1],this}closePath(){let e=this.startPoint;return e&&this.currentCurve.curves.length&&(this.currentCurve.closePath(),this.currentCurve=new Ut().moveTo(e.x,e.y),this.curves.push(this.currentCurve)),this}moveTo(e,t){return this.currentCurve.curves.length&&(this.currentCurve=new Ut,this.curves.push(this.currentCurve)),this.currentCurve.moveTo(e,t),this}lineTo(e,t){return this.currentCurve.lineTo(e,t),this}bezierCurveTo(e,t,n,r,i,a){return this.currentCurve.bezierCurveTo(e,t,n,r,i,a),this}quadraticCurveTo(e,t,n,r){return this.currentCurve.quadraticCurveTo(e,t,n,r),this}arc(e,t,n,r,i,a){return this.currentCurve.arc(e,t,n,r,i,a),this}arcTo(e,t,n,r,i){return this.currentCurve.arcTo(e,t,n,r,i),this}ellipse(e,t,n,r,i,a,o,s){return this.currentCurve.ellipse(e,t,n,r,i,a,o,s),this}rect(e,t,n,r){return this.currentCurve.rect(e,t,n,r),this}roundRect(e,t,n,r,i){return this.currentCurve.roundRect(e,t,n,r,i),this}reset(){return this.currentCurve=new Ut,this.curves=[this.currentCurve],this.style={},this}addCommands(e){return Ze(e,this),this}addData(e){return this.addCommands(et(e)),this}splineThru(e){return this.currentCurve.splineThru(e),this}scale(e,t=e,n={x:0,y:0}){return this.getControlPointRefs().forEach(r=>{r.scale(e,t,n)}),this}skew(e,t=0,n={x:0,y:0}){return this.getControlPointRefs().forEach(r=>{r.skew(e,t,n)}),this}rotate(e,t={x:0,y:0}){return this.getControlPointRefs().forEach(n=>{n.rotate(e,t)}),this}bold(e){if(e===0)return this;let t=this.getFlatCurves(),n=[],r=[],i=[];t.forEach((e,t)=>{let a=e.getControlPointRefs(),o=e.isClockwise();i[t]=a,r[t]=o;let s=a[0],c=a[a.length-1]??s;n.push({start:o?c:s,end:o?s:c,index:t})});let a=[];return n.forEach((e,t)=>{a[t]=[],n.forEach((n,r)=>{n.start&&e.end&&r!==t&&n.start?.equals(e.end)&&a[t].push(n.index)})}),t.forEach((t,n)=>{let a=r[n];i[n].forEach(n=>{n.add(t.getNormal(t.getTForPoint(n)).scale(a?e:-e))})}),a.forEach((e,t)=>{let n=i[t];e.forEach(e=>{let t=i[e],r=u(n[n.length-1],n[n.length-2]??n[n.length-1],t[0],t[1]??t[0]);r&&(n[n.length-1].copyFrom(r),t[0].copyFrom(r))})}),this}isPointInFill(e,t={}){let n=t.fillRule??this.style.fillRule??`nonzero`;return Le(e,this.curves.map(e=>e.getAdaptiveVertices()),n)}isPointInStroke(e,t={}){let n=t.strokeWidth??this.strokeWidth,{tolerance:r=0,closed:i}=t;return this.curves.some(t=>t.isPointInStroke(e,{strokeWidth:n,tolerance:r,closed:i}))}getMinMax(e=i.MAX,t=i.MIN,n=!0){let r=this.strokeWidth;return this.curves.forEach(i=>{if(i.getMinMax(e,t),n&&r>1){let n=r/2,a=i.isClockwise(),o=[];for(let e=0;e<=1;e+=1/i.arcLengthDivision){let t=i.getPoint(e),r=i.getNormal(e),s=r.clone().scale(a?n:-n),c=r.clone().scale(a?-n:n);o.push(t.clone().add(s),t.clone().add(c),t.clone().add({x:n,y:0}),t.clone().add({x:-n,y:0}),t.clone().add({x:0,y:n}),t.clone().add({x:0,y:-n}),t.clone().add({x:n,y:n}),t.clone().add({x:-n,y:-n}))}e.clampMin(...o),t.clampMax(...o)}}),{min:e.finite(),max:t.finite()}}strokeTriangulate(e){let t=e?.indices??[],n=e?.vertices??[];return this.curves.forEach(r=>{r.strokeTriangulate({...e,indices:t,vertices:n,style:{...this.style}})}),{indices:t,vertices:n}}fillTriangulate(e){let t={...e,style:{...this.style,...e?.style}},n=t.indices??[],r=t.vertices??[];if((t.style.fillRule??`nonzero`)===`nonzero`){let i=this.curves.map(e=>e.getFillVertices(t)),a=je(i),o=a.length;for(let t=0;t<o;t++){let s=a[t],c=i[t];if(s.winding||!c.length)continue;let l=c.slice(),u=[];for(let e=0;e<o;e++){let n=a[e];n.parentIndex===t&&(u.push(l.length/2),l.push(...i[n.index]))}pe(l,{...e,indices:n,vertices:r,holes:u,style:{...this.style}})}}else this.curves.forEach(t=>{t.fillTriangulate({...e,indices:n,vertices:r,style:{...this.style}})});return{indices:n,vertices:r}}getBoundingBox(e=!0){let{min:t,max:n}=this.getMinMax(void 0,void 0,e);return new a(t.x,t.y,n.x-t.x,n.y-t.y)}drawTo(e,t={}){t={...this.style,...t};let{fill:n=`#000`,stroke:i=`none`}=t;return e.beginPath(),e.save(),r(e,t),this.curves.forEach(t=>{t.drawTo(e)}),n!==`none`&&e.fill(),i!==`none`&&e.stroke(),e.restore(),this}drawControlPointsTo(e,n={}){n={...this.style,...n};let{fill:i=`#000`,stroke:a=`none`}=n;return e.beginPath(),e.save(),r(e,n),this.getControlPointRefs().forEach(n=>{t(e,n.x,n.y,{radius:4})}),i!==`none`&&e.fill(),a!==`none`&&e.stroke(),e.restore(),this}toCommands(){return this.curves.flatMap(e=>e.toCommands())}toData(){return this.curves.filter(e=>e.curves.length).map(e=>e.toData()).join(` `)}toSvgPathString(){let e={...this.style,fill:this.style.fill??`#000`,stroke:this.style.stroke??`none`},t={};for(let n in e)e[n]!==void 0&&(t[l(n)]=e[n]);Object.assign(t,{"stroke-width":`${this.strokeWidth}px`});let n=``;for(let e in t)t[e]!==void 0&&(n+=`${e}:${t[e]};`);return`<path d="${this.toData()}" style="${n}"></path>`}copyFrom(e){return super.copyFrom(e),this.currentCurve=e.currentCurve.clone(),this.style={...e.style},this}},Wt=class{constructor(e=[],t){this.paths=e,this.viewBox=t}isPointInFill(e,t={}){return this.paths.some(n=>n.isPointInFill(e,t))}contains(e,t,n={}){return this.isPointInFill({x:e,y:t},n)}hitTest(e,t={}){let{stroke:n=!0,tolerance:r,fillRule:i}=t;for(let t=this.paths.length-1;t>=0;t--){let a=this.paths[t];if((a.style.fill??`#000`)!==`none`&&a.isPointInFill(e,{fillRule:i})||n&&(a.style.stroke??`none`)!==`none`&&a.isPointInStroke(e,{tolerance:r}))return a}}getBoundingBox(e=!0){if(!this.paths.length)return;let t=i.MAX,n=i.MIN;return this.paths.forEach(r=>r.getMinMax(t,n,e)),new a(t.x,t.y,n.x-t.x,n.y-t.y)}toTriangulatedSvgString(e=this.paths.map(e=>e.fillTriangulate()),t=0){let n=``,r=``,i={x:-t,y:-t},a={x:t,y:t};(Array.isArray(e)?e:[e]).forEach(({vertices:e,indices:o,points:s=[]})=>{let c=n=>{let r=e[n*2],o=e[n*2+1];return i.x=Math.min(i.x,r+t),a.x=Math.max(a.x,r+t),i.y=Math.min(i.y,o+t),a.y=Math.max(a.y,o+t),[r,o]};for(let e=0,t=o.length;e<t;e+=3){let t=c(o[e]),r=c(o[e+1]),i=c(o[e+2]);n+=`<polygon
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports):typeof define==`function`&&define.amd?define([`exports`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.modernPath2d={}))})(this,function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=Object.create,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.getPrototypeOf,o=Object.prototype.hasOwnProperty,s=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),c=(e,t,a,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var c=i(t),l=0,u=c.length,d;l<u;l++)d=c[l],!o.call(e,d)&&d!==a&&n(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(s=r(t,d))||s.enumerable});return e},l=(e,r,i)=>(i=e==null?{}:t(a(e)),c(r||!e||!e.__esModule?n(i,`default`,{value:e,enumerable:!0}):i,e));function u(e,t,n,r={}){let{radius:i=1}=r;e.moveTo(t,n),e.arc(t,n,i,0,Math.PI*2)}var d={arcs:`bevel`,bevel:`bevel`,miter:`miter`,"miter-clip":`miter`,round:`round`};function f(e,t){let{fill:n=`#000`,stroke:r=`none`,strokeWidth:i=r===`none`?0:1,strokeLinecap:a=`round`,strokeLinejoin:o=`miter`,strokeMiterlimit:s=0,strokeDasharray:c=[],strokeDashoffset:l=0,shadowOffsetX:u=0,shadowOffsetY:f=0,shadowBlur:p=0,shadowColor:m=`rgba(0, 0, 0, 0)`}=t;e.fillStyle=n,e.strokeStyle=r,e.lineWidth=i,e.lineCap=a,e.lineJoin=d[o],e.miterLimit=s,e.setLineDash(c),e.lineDashOffset=l,e.shadowOffsetX=u,e.shadowOffsetY=f,e.shadowBlur=p,e.shadowColor=m}var p=class e{static get MAX(){return new e(1/0,1/0)}static get MIN(){return new e(-1/0,-1/0)}static lerp(t,n,r){return new e(n.x,n.y).clone().sub(t).multiply(r).add(t)}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}get left(){return this.x}set left(e){this.x=e}get top(){return this.y}set top(e){this.y=e}get x(){return this._x}set x(e){this._x!==e&&(this._x=e,this._onUpdate?.(this))}get y(){return this._y}set y(e){this._y!==e&&(this._y=e,this._onUpdate?.(this))}constructor(e=0,t=0,n){this._x=e,this._y=t,this._onUpdate=n}set(e=0,t=e){return(this._x!==e||this._y!==t)&&(this._x=e,this._y=t,this._onUpdate?.(this)),this}add(e){return this.set(this._x+e.x,this._y+e.y)}sub(e){return this.set(this._x-e.x,this._y-e.y)}subVectors(e,t){return this.set(e.x-t.x,e.y-t.y)}multiply(e=0,t=e){return this.set(this._x*e,this._y*t)}divide(e=0,t=e){return this.set(e===0?this._x:this._x/e,t===0?this._y:this._y/t)}cross(e){return this._x*e.y-this._y*e.x}dot(e){return this._x*e.x+this._y*e.y}rotate(e,t={x:0,y:0}){let{x:n,y:r}=this,i=Math.cos(e),a=Math.sin(e);return this.set((n-t.x)*i-(r-t.y)*a+t.x,(n-t.x)*a+(r-t.y)*i+t.y)}getLength(){let{x:e,y:t}=this;return Math.sqrt(e*e+t*t)}getAngle(){return Math.atan2(-this.x,-this.y)+Math.PI}distanceTo(e){return Math.hypot(e.x-this.x,e.y-this.y)}normalize(){let e=1/(this.getLength()||1);return this.set(this.x*e,this.y*e),this}copyFrom(e){return(this._x!==e.x||this._y!==e.y)&&(this._x=e.x,this._y=e.y,this._onUpdate?.(this)),this}copyTo(e){return e.set(this._x,this._y),e}equals(e){return this._x===e.x&&this._y===e.y}get array(){return[this.x,this.y]}finite(){return this.set(Number.isFinite(this._x)?this._x:0,Number.isFinite(this._y)?this._y:0)}lengthSquared(){return this._x*this._x+this._y*this._y}length(){return Math.sqrt(this.lengthSquared())}scale(e,t=e,n={x:0,y:0}){return this.set(n.x+(this._x-n.x)*e,n.y+(this._y-n.y)*t)}skew(e,t=0,n={x:0,y:0}){let r=this._x-n.x,i=this._y-n.y;return this.set(n.x+(r+Math.tan(e)*i),n.y+(i+Math.tan(t)*r))}clampMin(...e){return this.set(Math.min(this._x,...e.map(e=>e.x)),Math.min(this._y,...e.map(e=>e.y)))}clampMax(...e){return this.set(Math.max(this.x,...e.map(e=>e.x)),Math.max(this.y,...e.map(e=>e.y)))}clone(t){return new e(this._x,this._y,t??this._onUpdate)}toJSON(){return{x:this._x,y:this._y}}destroy(){this._onUpdate=void 0}},m=class e{get x(){return this.left}set x(e){this.left=e}get y(){return this.top}set y(e){this.top=e}get right(){return this.left+this.width}get bottom(){return this.top+this.height}get center(){return new p((this.left+this.right)/2,(this.top+this.bottom)/2)}get array(){return[this.left,this.top,this.width,this.height]}constructor(e=0,t=0,n=0,r=0){this.left=e,this.top=t,this.width=n,this.height=r}static from(...t){if(t.length===0)return new e;if(t.length===1)return t[0].clone();let n=t[0],r=t.slice(1).reduce((e,t)=>(e.left=Math.min(e.left,t.left),e.top=Math.min(e.top,t.top),e.right=Math.max(e.right,t.right),e.bottom=Math.max(e.bottom,t.bottom),e),{left:n?.left??0,top:n?.top??0,right:n?.right??0,bottom:n?.bottom??0});return new e(r.left,r.top,r.right-r.left,r.bottom-r.top)}translate(e,t){return this.left+=e,this.top+=t,this}copy(e){return this.left=e.left,this.top=e.top,this.width=e.width,this.height=e.height,this}clone(){return new e(this.left,this.top,this.width,this.height)}},h=l(s(((e,t)=>{(function(n,r){typeof e==`object`&&t!==void 0?t.exports=r():typeof define==`function`&&define.amd?define(r):(n=typeof globalThis<`u`?globalThis:n||self,n.polygonClipping=r())})(e,(function(){"use strict";function e(e,t){var n={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},r,i,a,o;return o={next:s(0),throw:s(1),return:s(2)},typeof Symbol==`function`&&(o[Symbol.iterator]=function(){return this}),o;function s(e){return function(t){return c([e,t])}}function c(o){if(r)throw TypeError(`Generator is already executing.`);for(;n;)try{if(r=1,i&&(a=o[0]&2?i.return:o[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,o[1])).done)return a;switch(i=0,a&&(o=[o[0]&2,a.value]),o[0]){case 0:case 1:a=o;break;case 4:return n.label++,{value:o[1],done:!1};case 5:n.label++,i=o[1],o=[0];continue;case 7:o=n.ops.pop(),n.trys.pop();continue;default:if((a=n.trys,!(a=a.length>0&&a[a.length-1]))&&(o[0]===6||o[0]===2)){n=0;continue}if(o[0]===3&&(!a||o[1]>a[0]&&o[1]<a[3])){n.label=o[1];break}if(o[0]===6&&n.label<a[1]){n.label=a[1],a=o;break}if(a&&n.label<a[2]){n.label=a[2],n.ops.push(o);break}a[2]&&n.ops.pop(),n.trys.pop();continue}o=t.call(e,n)}catch(e){o=[6,e],i=0}finally{r=a=0}if(o[0]&5)throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}}var t=function(){function e(e,t){this.next=null,this.key=e,this.data=t,this.left=null,this.right=null}return e}();function n(e,t){return e>t?1:e<t?-1:0}function r(e,n,r){for(var i=new t(null,null),a=i,o=i;;){var s=r(e,n.key);if(s<0){if(n.left===null)break;if(r(e,n.left.key)<0){var c=n.left;if(n.left=c.right,c.right=n,n=c,n.left===null)break}o.left=n,o=n,n=n.left}else if(s>0){if(n.right===null)break;if(r(e,n.right.key)>0){var c=n.right;if(n.right=c.left,c.left=n,n=c,n.right===null)break}a.right=n,a=n,n=n.right}else break}return a.right=n.left,o.left=n.right,n.left=i.right,n.right=i.left,n}function i(e,n,i,a){var o=new t(e,n);if(i===null)return o.left=o.right=null,o;i=r(e,i,a);var s=a(e,i.key);return s<0?(o.left=i.left,o.right=i,i.left=null):s>=0&&(o.right=i.right,o.left=i,i.right=null),o}function a(e,t,n){var i=null,a=null;if(t){t=r(e,t,n);var o=n(t.key,e);o===0?(i=t.left,a=t.right):o<0?(a=t.right,t.right=null,i=t):(i=t.left,t.left=null,a=t)}return{left:i,right:a}}function o(e,t,n){return t===null?e:e===null?t:(t=r(e.key,t,n),t.left=e,t)}function s(e,t,n,r,i){if(e){r(``+t+(n?`└── `:`├── `)+i(e)+`
|
|
2
|
+
`);var a=t+(n?` `:`│ `);e.left&&s(e.left,a,!1,r,i),e.right&&s(e.right,a,!0,r,i)}}var c=function(){function c(e){e===void 0&&(e=n),this._root=null,this._size=0,this._comparator=e}return c.prototype.insert=function(e,t){return this._size++,this._root=i(e,t,this._root,this._comparator)},c.prototype.add=function(e,n){var i=new t(e,n);this._root===null&&(i.left=i.right=null,this._size++,this._root=i);var a=this._comparator,o=r(e,this._root,a),s=a(e,o.key);return s===0?this._root=o:(s<0?(i.left=o.left,i.right=o,o.left=null):s>0&&(i.right=o.right,i.left=o,o.right=null),this._size++,this._root=i),this._root},c.prototype.remove=function(e){this._root=this._remove(e,this._root,this._comparator)},c.prototype._remove=function(e,t,n){var i;return t===null?null:(t=r(e,t,n),n(e,t.key)===0?(t.left===null?i=t.right:(i=r(e,t.left,n),i.right=t.right),this._size--,i):t)},c.prototype.pop=function(){var e=this._root;if(e){for(;e.left;)e=e.left;return this._root=r(e.key,this._root,this._comparator),this._root=this._remove(e.key,this._root,this._comparator),{key:e.key,data:e.data}}return null},c.prototype.findStatic=function(e){for(var t=this._root,n=this._comparator;t;){var r=n(e,t.key);if(r===0)return t;t=r<0?t.left:t.right}return null},c.prototype.find=function(e){return this._root&&(this._root=r(e,this._root,this._comparator),this._comparator(e,this._root.key)!==0)?null:this._root},c.prototype.contains=function(e){for(var t=this._root,n=this._comparator;t;){var r=n(e,t.key);if(r===0)return!0;t=r<0?t.left:t.right}return!1},c.prototype.forEach=function(e,t){for(var n=this._root,r=[],i=!1;!i;)n===null?r.length===0?i=!0:(n=r.pop(),e.call(t,n),n=n.right):(r.push(n),n=n.left);return this},c.prototype.range=function(e,t,n,r){for(var i=[],a=this._comparator,o=this._root,s;i.length!==0||o;)if(o)i.push(o),o=o.left;else{if(o=i.pop(),s=a(o.key,t),s>0)break;if(a(o.key,e)>=0&&n.call(r,o))return this;o=o.right}return this},c.prototype.keys=function(){var e=[];return this.forEach(function(t){var n=t.key;return e.push(n)}),e},c.prototype.values=function(){var e=[];return this.forEach(function(t){var n=t.data;return e.push(n)}),e},c.prototype.min=function(){return this._root?this.minNode(this._root).key:null},c.prototype.max=function(){return this._root?this.maxNode(this._root).key:null},c.prototype.minNode=function(e){if(e===void 0&&(e=this._root),e)for(;e.left;)e=e.left;return e},c.prototype.maxNode=function(e){if(e===void 0&&(e=this._root),e)for(;e.right;)e=e.right;return e},c.prototype.at=function(e){for(var t=this._root,n=!1,r=0,i=[];!n;)if(t)i.push(t),t=t.left;else if(i.length>0){if(t=i.pop(),r===e)return t;r++,t=t.right}else n=!0;return null},c.prototype.next=function(e){var t=this._root,n=null;if(e.right){for(n=e.right;n.left;)n=n.left;return n}for(var r=this._comparator;t;){var i=r(e.key,t.key);if(i===0)break;i<0?(n=t,t=t.left):t=t.right}return n},c.prototype.prev=function(e){var t=this._root,n=null;if(e.left!==null){for(n=e.left;n.right;)n=n.right;return n}for(var r=this._comparator;t;){var i=r(e.key,t.key);if(i===0)break;i<0?t=t.left:(n=t,t=t.right)}return n},c.prototype.clear=function(){return this._root=null,this._size=0,this},c.prototype.toList=function(){return d(this._root)},c.prototype.load=function(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!1);var r=e.length,i=this._comparator;if(n&&m(e,t,0,r-1,i),this._root===null)this._root=l(e,t,0,r),this._size=r;else{var a=p(this.toList(),u(e,t),i);r=this._size+r,this._root=f({head:a},0,r)}return this},c.prototype.isEmpty=function(){return this._root===null},Object.defineProperty(c.prototype,`size`,{get:function(){return this._size},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,`root`,{get:function(){return this._root},enumerable:!0,configurable:!0}),c.prototype.toString=function(e){e===void 0&&(e=function(e){return String(e.key)});var t=[];return s(this._root,``,!0,function(e){return t.push(e)},e),t.join(``)},c.prototype.update=function(e,t,n){var r=this._comparator,s=a(e,this._root,r),c=s.left,l=s.right;r(e,t)<0?l=i(t,n,l,r):c=i(t,n,c,r),this._root=o(c,l,r)},c.prototype.split=function(e){return a(e,this._root,this._comparator)},c.prototype[Symbol.iterator]=function(){var t,n,r;return e(this,function(e){switch(e.label){case 0:t=this._root,n=[],r=!1,e.label=1;case 1:return r?[3,6]:t===null?[3,2]:(n.push(t),t=t.left,[3,5]);case 2:return n.length===0?[3,4]:(t=n.pop(),[4,t]);case 3:return e.sent(),t=t.right,[3,5];case 4:r=!0,e.label=5;case 5:return[3,1];case 6:return[2]}})},c}();function l(e,n,r,i){var a=i-r;if(a>0){var o=r+Math.floor(a/2),s=e[o],c=n[o],u=new t(s,c);return u.left=l(e,n,r,o),u.right=l(e,n,o+1,i),u}return null}function u(e,n){for(var r=new t(null,null),i=r,a=0;a<e.length;a++)i=i.next=new t(e[a],n[a]);return i.next=null,r.next}function d(e){for(var n=e,r=[],i=!1,a=new t(null,null),o=a;!i;)n?(r.push(n),n=n.left):r.length>0?(n=o=o.next=r.pop(),n=n.right):i=!0;return o.next=null,a.next}function f(e,t,n){var r=n-t;if(r>0){var i=t+Math.floor(r/2),a=f(e,t,i),o=e.head;return o.left=a,e.head=e.head.next,o.right=f(e,i+1,n),o}return null}function p(e,n,r){for(var i=new t(null,null),a=i,o=e,s=n;o!==null&&s!==null;)r(o.key,s.key)<0?(a.next=o,o=o.next):(a.next=s,s=s.next),a=a.next;return o===null?s!==null&&(a.next=s):a.next=o,i.next}function m(e,t,n,r,i){if(!(n>=r)){for(var a=e[n+r>>1],o=n-1,s=r+1;;){do o++;while(i(e[o],a)<0);do s--;while(i(e[s],a)>0);if(o>=s)break;var c=e[o];e[o]=e[s],e[s]=c,c=t[o],t[o]=t[s],t[s]=c}m(e,t,n,s,i),m(e,t,s+1,r,i)}}let h=(e,t)=>e.ll.x<=t.x&&t.x<=e.ur.x&&e.ll.y<=t.y&&t.y<=e.ur.y,g=(e,t)=>{if(t.ur.x<e.ll.x||e.ur.x<t.ll.x||t.ur.y<e.ll.y||e.ur.y<t.ll.y)return null;let n=e.ll.x<t.ll.x?t.ll.x:e.ll.x,r=e.ur.x<t.ur.x?e.ur.x:t.ur.x,i=e.ll.y<t.ll.y?t.ll.y:e.ll.y,a=e.ur.y<t.ur.y?e.ur.y:t.ur.y;return{ll:{x:n,y:i},ur:{x:r,y:a}}},_=2**-52;_===void 0&&(_=2**-52);let v=_*_,y=(e,t)=>{if(-_<e&&e<_&&-_<t&&t<_)return 0;let n=e-t;return n*n<v*e*t?0:e<t?-1:1};class b{constructor(){this.reset()}reset(){this.xRounder=new x,this.yRounder=new x}round(e,t){return{x:this.xRounder.round(e),y:this.yRounder.round(t)}}}class x{constructor(){this.tree=new c,this.round(0)}round(e){let t=this.tree.add(e),n=this.tree.prev(t);if(n!==null&&y(t.key,n.key)===0)return this.tree.remove(e),n.key;let r=this.tree.next(t);return r!==null&&y(t.key,r.key)===0?(this.tree.remove(e),r.key):e}}let S=new b,C=11102230246251565e-32,w=134217729;(3+8*C)*C;function T(e,t,n,r,i){let a,o,s,c,l=t[0],u=r[0],d=0,f=0;u>l==u>-l?(a=l,l=t[++d]):(a=u,u=r[++f]);let p=0;if(d<e&&f<n)for(u>l==u>-l?(o=l+a,s=a-(o-l),l=t[++d]):(o=u+a,s=a-(o-u),u=r[++f]),a=o,s!==0&&(i[p++]=s);d<e&&f<n;)u>l==u>-l?(o=a+l,c=o-a,s=a-(o-c)+(l-c),l=t[++d]):(o=a+u,c=o-a,s=a-(o-c)+(u-c),u=r[++f]),a=o,s!==0&&(i[p++]=s);for(;d<e;)o=a+l,c=o-a,s=a-(o-c)+(l-c),l=t[++d],a=o,s!==0&&(i[p++]=s);for(;f<n;)o=a+u,c=o-a,s=a-(o-c)+(u-c),u=r[++f],a=o,s!==0&&(i[p++]=s);return(a!==0||p===0)&&(i[p++]=a),p}function E(e,t){let n=t[0];for(let r=1;r<e;r++)n+=t[r];return n}function D(e){return new Float64Array(e)}(3+16*C)*C,(2+12*C)*C,(9+64*C)*C*C;let O=D(4),k=D(8),A=D(12),j=D(16),M=D(4);function N(e,t,n,r,i,a,o){let s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,D,N=e-i,P=n-i,F=t-a,I=r-a;b=N*I,f=w*N,p=f-(f-N),m=N-p,f=w*I,h=f-(f-I),g=I-h,x=m*g-(b-p*h-m*h-p*g),S=F*P,f=w*F,p=f-(f-F),m=F-p,f=w*P,h=f-(f-P),g=P-h,C=m*g-(S-p*h-m*h-p*g),_=x-C,d=x-_,O[0]=x-(_+d)+(d-C),v=b+_,d=v-b,y=b-(v-d)+(_-d),_=y-S,d=y-_,O[1]=y-(_+d)+(d-S),D=v+_,d=D-v,O[2]=v-(D-d)+(_-d),O[3]=D;let L=E(4,O),R=22204460492503146e-32*o;if(L>=R||-L>=R||(d=e-N,s=e-(N+d)+(d-i),d=n-P,l=n-(P+d)+(d-i),d=t-F,c=t-(F+d)+(d-a),d=r-I,u=r-(I+d)+(d-a),s===0&&c===0&&l===0&&u===0)||(R=11093356479670487e-47*o+33306690738754706e-32*Math.abs(L),L+=N*u+I*s-(F*l+P*c),L>=R||-L>=R))return L;b=s*I,f=w*s,p=f-(f-s),m=s-p,f=w*I,h=f-(f-I),g=I-h,x=m*g-(b-p*h-m*h-p*g),S=c*P,f=w*c,p=f-(f-c),m=c-p,f=w*P,h=f-(f-P),g=P-h,C=m*g-(S-p*h-m*h-p*g),_=x-C,d=x-_,M[0]=x-(_+d)+(d-C),v=b+_,d=v-b,y=b-(v-d)+(_-d),_=y-S,d=y-_,M[1]=y-(_+d)+(d-S),D=v+_,d=D-v,M[2]=v-(D-d)+(_-d),M[3]=D;let z=T(4,O,4,M,k);b=N*u,f=w*N,p=f-(f-N),m=N-p,f=w*u,h=f-(f-u),g=u-h,x=m*g-(b-p*h-m*h-p*g),S=F*l,f=w*F,p=f-(f-F),m=F-p,f=w*l,h=f-(f-l),g=l-h,C=m*g-(S-p*h-m*h-p*g),_=x-C,d=x-_,M[0]=x-(_+d)+(d-C),v=b+_,d=v-b,y=b-(v-d)+(_-d),_=y-S,d=y-_,M[1]=y-(_+d)+(d-S),D=v+_,d=D-v,M[2]=v-(D-d)+(_-d),M[3]=D;let ee=T(z,k,4,M,A);return b=s*u,f=w*s,p=f-(f-s),m=s-p,f=w*u,h=f-(f-u),g=u-h,x=m*g-(b-p*h-m*h-p*g),S=c*l,f=w*c,p=f-(f-c),m=c-p,f=w*l,h=f-(f-l),g=l-h,C=m*g-(S-p*h-m*h-p*g),_=x-C,d=x-_,M[0]=x-(_+d)+(d-C),v=b+_,d=v-b,y=b-(v-d)+(_-d),_=y-S,d=y-_,M[1]=y-(_+d)+(d-S),D=v+_,d=D-v,M[2]=v-(D-d)+(_-d),M[3]=D,j[T(ee,A,4,M,j)-1]}function P(e,t,n,r,i,a){let o=(t-a)*(n-i),s=(e-i)*(r-a),c=o-s,l=Math.abs(o+s);return Math.abs(c)>=33306690738754716e-32*l?c:-N(e,t,n,r,i,a,l)}let F=(e,t)=>e.x*t.y-e.y*t.x,I=(e,t)=>e.x*t.x+e.y*t.y,L=(e,t,n)=>{let r=P(e.x,e.y,t.x,t.y,n.x,n.y);return r>0?-1:+(r<0)},R=e=>Math.sqrt(I(e,e)),z=(e,t,n)=>{let r={x:t.x-e.x,y:t.y-e.y},i={x:n.x-e.x,y:n.y-e.y};return F(i,r)/R(i)/R(r)},ee=(e,t,n)=>{let r={x:t.x-e.x,y:t.y-e.y},i={x:n.x-e.x,y:n.y-e.y};return I(i,r)/R(i)/R(r)},te=(e,t,n)=>t.y===0?null:{x:e.x+t.x/t.y*(n-e.y),y:n},ne=(e,t,n)=>t.x===0?null:{x:n,y:e.y+t.y/t.x*(n-e.x)},re=(e,t,n,r)=>{if(t.x===0)return ne(n,r,e.x);if(r.x===0)return ne(e,t,n.x);if(t.y===0)return te(n,r,e.y);if(r.y===0)return te(e,t,n.y);let i=F(t,r);if(i==0)return null;let a={x:n.x-e.x,y:n.y-e.y},o=F(a,t)/i,s=F(a,r)/i,c=e.x+s*t.x,l=n.x+o*r.x,u=e.y+s*t.y,d=n.y+o*r.y;return{x:(c+l)/2,y:(u+d)/2}};class B{static compare(e,t){let n=B.comparePoints(e.point,t.point);return n===0?(e.point!==t.point&&e.link(t),e.isLeft===t.isLeft?V.compare(e.segment,t.segment):e.isLeft?1:-1):n}static comparePoints(e,t){return e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:+(e.y>t.y)}constructor(e,t){e.events===void 0?e.events=[this]:e.events.push(this),this.point=e,this.isLeft=t}link(e){if(e.point===this.point)throw Error(`Tried to link already linked events`);let t=e.point.events;for(let e=0,n=t.length;e<n;e++){let n=t[e];this.point.events.push(n),n.point=this.point}this.checkForConsuming()}checkForConsuming(){let e=this.point.events.length;for(let t=0;t<e;t++){let n=this.point.events[t];if(n.segment.consumedBy===void 0)for(let r=t+1;r<e;r++){let e=this.point.events[r];e.consumedBy===void 0&&n.otherSE.point.events===e.otherSE.point.events&&n.segment.consume(e.segment)}}}getAvailableLinkedEvents(){let e=[];for(let t=0,n=this.point.events.length;t<n;t++){let n=this.point.events[t];n!==this&&!n.segment.ringOut&&n.segment.isInResult()&&e.push(n)}return e}getLeftmostComparator(e){let t=new Map,n=n=>{let r=n.otherSE;t.set(n,{sine:z(this.point,e.point,r.point),cosine:ee(this.point,e.point,r.point)})};return(e,r)=>{t.has(e)||n(e),t.has(r)||n(r);let{sine:i,cosine:a}=t.get(e),{sine:o,cosine:s}=t.get(r);return i>=0&&o>=0?a<s?1:a>s?-1:0:i<0&&o<0?a<s?-1:+(a>s):o<i?-1:+(o>i)}}}let ie=0;class V{static compare(e,t){let n=e.leftSE.point.x,r=t.leftSE.point.x,i=e.rightSE.point.x,a=t.rightSE.point.x;if(a<n)return 1;if(i<r)return-1;let o=e.leftSE.point.y,s=t.leftSE.point.y,c=e.rightSE.point.y,l=t.rightSE.point.y;if(n<r){if(s<o&&s<c)return 1;if(s>o&&s>c)return-1;let n=e.comparePoint(t.leftSE.point);if(n<0)return 1;if(n>0)return-1;let r=t.comparePoint(e.rightSE.point);return r===0?-1:r}if(n>r){if(o<s&&o<l)return-1;if(o>s&&o>l)return 1;let n=t.comparePoint(e.leftSE.point);if(n!==0)return n;let r=e.comparePoint(t.rightSE.point);return r<0?1:r>0?-1:1}if(o<s)return-1;if(o>s)return 1;if(i<a){let n=t.comparePoint(e.rightSE.point);if(n!==0)return n}if(i>a){let n=e.comparePoint(t.rightSE.point);if(n<0)return 1;if(n>0)return-1}if(i!==a){let e=c-o,t=i-n,u=l-s,d=a-r;if(e>t&&u<d)return 1;if(e<t&&u>d)return-1}return i>a?1:i<a||c<l?-1:c>l?1:e.id<t.id?-1:+(e.id>t.id)}constructor(e,t,n,r){this.id=++ie,this.leftSE=e,e.segment=this,e.otherSE=t,this.rightSE=t,t.segment=this,t.otherSE=e,this.rings=n,this.windings=r}static fromRing(e,t,n){let r,i,a,o=B.comparePoints(e,t);if(o<0)r=e,i=t,a=1;else if(o>0)r=t,i=e,a=-1;else throw Error(`Tried to create degenerate segment at [${e.x}, ${e.y}]`);return new V(new B(r,!0),new B(i,!1),[n],[a])}replaceRightSE(e){this.rightSE=e,this.rightSE.segment=this,this.rightSE.otherSE=this.leftSE,this.leftSE.otherSE=this.rightSE}bbox(){let e=this.leftSE.point.y,t=this.rightSE.point.y;return{ll:{x:this.leftSE.point.x,y:e<t?e:t},ur:{x:this.rightSE.point.x,y:e>t?e:t}}}vector(){return{x:this.rightSE.point.x-this.leftSE.point.x,y:this.rightSE.point.y-this.leftSE.point.y}}isAnEndpoint(e){return e.x===this.leftSE.point.x&&e.y===this.leftSE.point.y||e.x===this.rightSE.point.x&&e.y===this.rightSE.point.y}comparePoint(e){if(this.isAnEndpoint(e))return 0;let t=this.leftSE.point,n=this.rightSE.point,r=this.vector();if(t.x===n.x)return e.x===t.x?0:e.x<t.x?1:-1;let i=(e.y-t.y)/r.y,a=t.x+i*r.x;if(e.x===a)return 0;let o=(e.x-t.x)/r.x,s=t.y+o*r.y;return e.y===s?0:e.y<s?-1:1}getIntersection(e){let t=this.bbox(),n=e.bbox(),r=g(t,n);if(r===null)return null;let i=this.leftSE.point,a=this.rightSE.point,o=e.leftSE.point,s=e.rightSE.point,c=h(t,o)&&this.comparePoint(o)===0,l=h(n,i)&&e.comparePoint(i)===0,u=h(t,s)&&this.comparePoint(s)===0,d=h(n,a)&&e.comparePoint(a)===0;if(l&&c)return d&&!u?a:!d&&u?s:null;if(l)return u&&i.x===s.x&&i.y===s.y?null:i;if(c)return d&&a.x===o.x&&a.y===o.y?null:o;if(d&&u)return null;if(d)return a;if(u)return s;let f=re(i,this.vector(),o,e.vector());return f===null||!h(r,f)?null:S.round(f.x,f.y)}split(e){let t=[],n=e.events!==void 0,r=new B(e,!0),i=new B(e,!1),a=this.rightSE;this.replaceRightSE(i),t.push(i),t.push(r);let o=new V(r,a,this.rings.slice(),this.windings.slice());return B.comparePoints(o.leftSE.point,o.rightSE.point)>0&&o.swapEvents(),B.comparePoints(this.leftSE.point,this.rightSE.point)>0&&this.swapEvents(),n&&(r.checkForConsuming(),i.checkForConsuming()),t}swapEvents(){let e=this.rightSE;this.rightSE=this.leftSE,this.leftSE=e,this.leftSE.isLeft=!0,this.rightSE.isLeft=!1;for(let e=0,t=this.windings.length;e<t;e++)this.windings[e]*=-1}consume(e){let t=this,n=e;for(;t.consumedBy;)t=t.consumedBy;for(;n.consumedBy;)n=n.consumedBy;let r=V.compare(t,n);if(r!==0){if(r>0){let e=t;t=n,n=e}if(t.prev===n){let e=t;t=n,n=e}for(let e=0,r=n.rings.length;e<r;e++){let r=n.rings[e],i=n.windings[e],a=t.rings.indexOf(r);a===-1?(t.rings.push(r),t.windings.push(i)):t.windings[a]+=i}n.rings=null,n.windings=null,n.consumedBy=t,n.leftSE.consumedBy=t.leftSE,n.rightSE.consumedBy=t.rightSE}}prevInResult(){return this._prevInResult===void 0&&(this.prev?this.prev.isInResult()?this._prevInResult=this.prev:this._prevInResult=this.prev.prevInResult():this._prevInResult=null),this._prevInResult}beforeState(){if(this._beforeState!==void 0)return this._beforeState;if(!this.prev)this._beforeState={rings:[],windings:[],multiPolys:[]};else{let e=this.prev.consumedBy||this.prev;this._beforeState=e.afterState()}return this._beforeState}afterState(){if(this._afterState!==void 0)return this._afterState;let e=this.beforeState();this._afterState={rings:e.rings.slice(0),windings:e.windings.slice(0),multiPolys:[]};let t=this._afterState.rings,n=this._afterState.windings,r=this._afterState.multiPolys;for(let e=0,r=this.rings.length;e<r;e++){let r=this.rings[e],i=this.windings[e],a=t.indexOf(r);a===-1?(t.push(r),n.push(i)):n[a]+=i}let i=[],a=[];for(let e=0,r=t.length;e<r;e++){if(n[e]===0)continue;let r=t[e],o=r.poly;if(a.indexOf(o)===-1)if(r.isExterior)i.push(o);else{a.indexOf(o)===-1&&a.push(o);let e=i.indexOf(r.poly);e!==-1&&i.splice(e,1)}}for(let e=0,t=i.length;e<t;e++){let t=i[e].multiPoly;r.indexOf(t)===-1&&r.push(t)}return this._afterState}isInResult(){if(this.consumedBy)return!1;if(this._isInResult!==void 0)return this._isInResult;let e=this.beforeState().multiPolys,t=this.afterState().multiPolys;switch(W.type){case`union`:{let n=e.length===0,r=t.length===0;this._isInResult=n!==r;break}case`intersection`:{let n,r;e.length<t.length?(n=e.length,r=t.length):(n=t.length,r=e.length),this._isInResult=r===W.numMultiPolys&&n<r;break}case`xor`:{let n=Math.abs(e.length-t.length);this._isInResult=n%2==1;break}case`difference`:{let n=e=>e.length===1&&e[0].isSubject;this._isInResult=n(e)!==n(t);break}default:throw Error(`Unrecognized operation type found ${W.type}`)}return this._isInResult}}class ae{constructor(e,t,n){if(!Array.isArray(e)||e.length===0||(this.poly=t,this.isExterior=n,this.segments=[],typeof e[0][0]!=`number`||typeof e[0][1]!=`number`))throw Error(`Input geometry is not a valid Polygon or MultiPolygon`);let r=S.round(e[0][0],e[0][1]);this.bbox={ll:{x:r.x,y:r.y},ur:{x:r.x,y:r.y}};let i=r;for(let t=1,n=e.length;t<n;t++){if(typeof e[t][0]!=`number`||typeof e[t][1]!=`number`)throw Error(`Input geometry is not a valid Polygon or MultiPolygon`);let n=S.round(e[t][0],e[t][1]);n.x===i.x&&n.y===i.y||(this.segments.push(V.fromRing(i,n,this)),n.x<this.bbox.ll.x&&(this.bbox.ll.x=n.x),n.y<this.bbox.ll.y&&(this.bbox.ll.y=n.y),n.x>this.bbox.ur.x&&(this.bbox.ur.x=n.x),n.y>this.bbox.ur.y&&(this.bbox.ur.y=n.y),i=n)}(r.x!==i.x||r.y!==i.y)&&this.segments.push(V.fromRing(i,r,this))}getSweepEvents(){let e=[];for(let t=0,n=this.segments.length;t<n;t++){let n=this.segments[t];e.push(n.leftSE),e.push(n.rightSE)}return e}}class oe{constructor(e,t){if(!Array.isArray(e))throw Error(`Input geometry is not a valid Polygon or MultiPolygon`);this.exteriorRing=new ae(e[0],this,!0),this.bbox={ll:{x:this.exteriorRing.bbox.ll.x,y:this.exteriorRing.bbox.ll.y},ur:{x:this.exteriorRing.bbox.ur.x,y:this.exteriorRing.bbox.ur.y}},this.interiorRings=[];for(let t=1,n=e.length;t<n;t++){let n=new ae(e[t],this,!1);n.bbox.ll.x<this.bbox.ll.x&&(this.bbox.ll.x=n.bbox.ll.x),n.bbox.ll.y<this.bbox.ll.y&&(this.bbox.ll.y=n.bbox.ll.y),n.bbox.ur.x>this.bbox.ur.x&&(this.bbox.ur.x=n.bbox.ur.x),n.bbox.ur.y>this.bbox.ur.y&&(this.bbox.ur.y=n.bbox.ur.y),this.interiorRings.push(n)}this.multiPoly=t}getSweepEvents(){let e=this.exteriorRing.getSweepEvents();for(let t=0,n=this.interiorRings.length;t<n;t++){let n=this.interiorRings[t].getSweepEvents();for(let t=0,r=n.length;t<r;t++)e.push(n[t])}return e}}class se{constructor(e,t){if(!Array.isArray(e))throw Error(`Input geometry is not a valid Polygon or MultiPolygon`);try{typeof e[0][0][0]==`number`&&(e=[e])}catch{}this.polys=[],this.bbox={ll:{x:1/0,y:1/0},ur:{x:-1/0,y:-1/0}};for(let t=0,n=e.length;t<n;t++){let n=new oe(e[t],this);n.bbox.ll.x<this.bbox.ll.x&&(this.bbox.ll.x=n.bbox.ll.x),n.bbox.ll.y<this.bbox.ll.y&&(this.bbox.ll.y=n.bbox.ll.y),n.bbox.ur.x>this.bbox.ur.x&&(this.bbox.ur.x=n.bbox.ur.x),n.bbox.ur.y>this.bbox.ur.y&&(this.bbox.ur.y=n.bbox.ur.y),this.polys.push(n)}this.isSubject=t}getSweepEvents(){let e=[];for(let t=0,n=this.polys.length;t<n;t++){let n=this.polys[t].getSweepEvents();for(let t=0,r=n.length;t<r;t++)e.push(n[t])}return e}}class ce{static factory(e){let t=[];for(let n=0,r=e.length;n<r;n++){let r=e[n];if(!r.isInResult()||r.ringOut)continue;let i=null,a=r.leftSE,o=r.rightSE,s=[a],c=a.point,l=[];for(;i=a,a=o,s.push(a),a.point!==c;)for(;;){let e=a.getAvailableLinkedEvents();if(e.length===0){let e=s[0].point,t=s[s.length-1].point;throw Error(`Unable to complete output ring starting at [${e.x}, ${e.y}]. Last matching segment found ends at [${t.x}, ${t.y}].`)}if(e.length===1){o=e[0].otherSE;break}let n=null;for(let e=0,t=l.length;e<t;e++)if(l[e].point===a.point){n=e;break}if(n!==null){let e=l.splice(n)[0],r=s.splice(e.index);r.unshift(r[0].otherSE),t.push(new ce(r.reverse()));continue}l.push({index:s.length,point:a.point});let r=a.getLeftmostComparator(i);o=e.sort(r)[0].otherSE;break}t.push(new ce(s))}return t}constructor(e){this.events=e;for(let t=0,n=e.length;t<n;t++)e[t].segment.ringOut=this;this.poly=null}getGeom(){let e=this.events[0].point,t=[e];for(let n=1,r=this.events.length-1;n<r;n++){let r=this.events[n].point,i=this.events[n+1].point;L(r,e,i)!==0&&(t.push(r),e=r)}if(t.length===1)return null;let n=t[0],r=t[1];L(n,e,r)===0&&t.shift(),t.push(t[0]);let i=this.isExteriorRing()?1:-1,a=this.isExteriorRing()?0:t.length-1,o=this.isExteriorRing()?t.length:-1,s=[];for(let e=a;e!=o;e+=i)s.push([t[e].x,t[e].y]);return s}isExteriorRing(){if(this._isExteriorRing===void 0){let e=this.enclosingRing();this._isExteriorRing=e?!e.isExteriorRing():!0}return this._isExteriorRing}enclosingRing(){return this._enclosingRing===void 0&&(this._enclosingRing=this._calcEnclosingRing()),this._enclosingRing}_calcEnclosingRing(){let e=this.events[0];for(let t=1,n=this.events.length;t<n;t++){let n=this.events[t];B.compare(e,n)>0&&(e=n)}let t=e.segment.prevInResult(),n=t?t.prevInResult():null;for(;;){if(!t)return null;if(!n)return t.ringOut;if(n.ringOut!==t.ringOut)return n.ringOut.enclosingRing()===t.ringOut?t.ringOut.enclosingRing():t.ringOut;t=n.prevInResult(),n=t?t.prevInResult():null}}}class le{constructor(e){this.exteriorRing=e,e.poly=this,this.interiorRings=[]}addInterior(e){this.interiorRings.push(e),e.poly=this}getGeom(){let e=[this.exteriorRing.getGeom()];if(e[0]===null)return null;for(let t=0,n=this.interiorRings.length;t<n;t++){let n=this.interiorRings[t].getGeom();n!==null&&e.push(n)}return e}}class ue{constructor(e){this.rings=e,this.polys=this._composePolys(e)}getGeom(){let e=[];for(let t=0,n=this.polys.length;t<n;t++){let n=this.polys[t].getGeom();n!==null&&e.push(n)}return e}_composePolys(e){let t=[];for(let n=0,r=e.length;n<r;n++){let r=e[n];if(!r.poly)if(r.isExteriorRing())t.push(new le(r));else{let e=r.enclosingRing();e.poly||t.push(new le(e)),e.poly.addInterior(r)}}return t}}class de{constructor(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:V.compare;this.queue=e,this.tree=new c(t),this.segments=[]}process(e){let t=e.segment,n=[];if(e.consumedBy)return e.isLeft?this.queue.remove(e.otherSE):this.tree.remove(t),n;let r=e.isLeft?this.tree.add(t):this.tree.find(t);if(!r)throw Error(`Unable to find segment #${t.id} [${t.leftSE.point.x}, ${t.leftSE.point.y}] -> [${t.rightSE.point.x}, ${t.rightSE.point.y}] in SweepLine tree.`);let i=r,a=r,o,s;for(;o===void 0;)i=this.tree.prev(i),i===null?o=null:i.key.consumedBy===void 0&&(o=i.key);for(;s===void 0;)a=this.tree.next(a),a===null?s=null:a.key.consumedBy===void 0&&(s=a.key);if(e.isLeft){let r=null;if(o){let e=o.getIntersection(t);if(e!==null&&(t.isAnEndpoint(e)||(r=e),!o.isAnEndpoint(e))){let t=this._splitSafely(o,e);for(let e=0,r=t.length;e<r;e++)n.push(t[e])}}let i=null;if(s){let e=s.getIntersection(t);if(e!==null&&(t.isAnEndpoint(e)||(i=e),!s.isAnEndpoint(e))){let t=this._splitSafely(s,e);for(let e=0,r=t.length;e<r;e++)n.push(t[e])}}if(r!==null||i!==null){let e=null;e=r===null?i:i===null||B.comparePoints(r,i)<=0?r:i,this.queue.remove(t.rightSE),n.push(t.rightSE);let a=t.split(e);for(let e=0,t=a.length;e<t;e++)n.push(a[e])}n.length>0?(this.tree.remove(t),n.push(e)):(this.segments.push(t),t.prev=o)}else{if(o&&s){let e=o.getIntersection(s);if(e!==null){if(!o.isAnEndpoint(e)){let t=this._splitSafely(o,e);for(let e=0,r=t.length;e<r;e++)n.push(t[e])}if(!s.isAnEndpoint(e)){let t=this._splitSafely(s,e);for(let e=0,r=t.length;e<r;e++)n.push(t[e])}}}this.tree.remove(t)}return n}_splitSafely(e,t){this.tree.remove(e);let n=e.rightSE;this.queue.remove(n);let r=e.split(t);return r.push(n),e.consumedBy===void 0&&this.tree.add(e),r}}let H=typeof process<`u`&&process.env.POLYGON_CLIPPING_MAX_QUEUE_SIZE||1e6,fe=typeof process<`u`&&process.env.POLYGON_CLIPPING_MAX_SWEEPLINE_SEGMENTS||1e6;class U{run(e,t,n){W.type=e,S.reset();let r=[new se(t,!0)];for(let e=0,t=n.length;e<t;e++)r.push(new se(n[e],!1));if(W.numMultiPolys=r.length,W.type===`difference`){let e=r[0],t=1;for(;t<r.length;)g(r[t].bbox,e.bbox)===null?r.splice(t,1):t++}if(W.type===`intersection`)for(let e=0,t=r.length;e<t;e++){let t=r[e];for(let n=e+1,i=r.length;n<i;n++)if(g(t.bbox,r[n].bbox)===null)return[]}let i=new c(B.compare);for(let e=0,t=r.length;e<t;e++){let t=r[e].getSweepEvents();for(let e=0,n=t.length;e<n;e++)if(i.insert(t[e]),i.size>H)throw Error(`Infinite loop when putting segment endpoints in a priority queue (queue size too big).`)}let a=new de(i),o=i.size,s=i.pop();for(;s;){let e=s.key;if(i.size===o){let t=e.segment;throw Error(`Unable to pop() ${e.isLeft?`left`:`right`} SweepEvent [${e.point.x}, ${e.point.y}] from segment #${t.id} [${t.leftSE.point.x}, ${t.leftSE.point.y}] -> [${t.rightSE.point.x}, ${t.rightSE.point.y}] from queue.`)}if(i.size>H)throw Error(`Infinite loop when passing sweep line over endpoints (queue size too big).`);if(a.segments.length>fe)throw Error(`Infinite loop when passing sweep line over endpoints (too many sweep line segments).`);let t=a.process(e);for(let e=0,n=t.length;e<n;e++){let n=t[e];n.consumedBy===void 0&&i.insert(n)}o=i.size,s=i.pop()}return S.reset(),new ue(ce.factory(a.segments)).getGeom()}}let W=new U;return{union:function(e){var t=[...arguments].slice(1);return W.run(`union`,e,t)},intersection:function(e){var t=[...arguments].slice(1);return W.run(`intersection`,e,t)},xor:function(e){var t=[...arguments].slice(1);return W.run(`xor`,e,t)},difference:function(e){var t=[...arguments].slice(1);return W.run(`difference`,e,t)}}}))}))(),1);function g(e){let t=[];for(let n=0;n<e.length;n+=2)t.push([e[n],e[n+1]]);let n=t[0],r=t[t.length-1];return n&&r&&(n[0]!==r[0]||n[1]!==r[1])&&t.push([n[0],n[1]]),t}function _(e){let t=e.filter(e=>e.length>=6).map(g);if(!t.length)return[];let n=[[t[0]]];for(let e=1;e<t.length;e++)n=h.default.xor(n,[[t[e]]]);return n}function v(e){let t=[];for(let n of e)for(let e of n){let n=[];for(let[t,r]of e)n.push(t,r);t.push(n)}return t}function y(e,t,n){let r=_(t),i=_(n),a;switch(e){case`union`:a=h.default.union(r,i);break;case`intersection`:a=h.default.intersection(r,i);break;case`difference`:a=h.default.difference(r,i);break;case`xor`:a=h.default.xor(r,i);break}return v(a)}function b(e,t,n,r,i){let a=(r-t)*.5,o=(i-n)*.5,s=e*e,c=e*s;return(2*n-2*r+a+o)*c+(-3*n+3*r-2*a-o)*s+a*e+n}var x=Math.PI,S=x*2;function C(e){return e.replace(/[^a-z0-9]/gi,`-`).replace(/\B([A-Z])/g,`-$1`).toLowerCase()}function w(e,t,n,r){let i=t.clone().sub(e),a=r.clone().sub(n),o=n.clone().sub(e),s=i.cross(a);if(s===0)return null;let c=o.cross(a)/s;return Math.abs(c)>1?null:new p(e.x+c*i.x,e.y+c*i.y)}var T=/([\w-]+)\((.+?)\)/g,E=/[^,]+/g,D=/([-e.\d]+)(.*)/;function O(e,t={}){let n=[],r;for(;(r=T.exec(e))!==null;){let[,e,i]=r;e&&n.push({name:e,args:k(e,i,t)})}return n}function k(e,t,n={}){let r=[],i,a=0;for(;(i=E.exec(t))!==null;)r.push(A(e,i[0],{...n,index:a++}));return r}function A(e,t,n={}){let{width:r=1,height:i=1,index:a=0}=n,o=t.match(D),s={unit:o?.[2]??null,value:t,intValue:Number(o?.[1]),normalizedIntValue:0,normalizedDefaultIntValue:0};switch(e){case`scale`:case`scaleX`:case`scaleY`:case`scale3d`:s.normalizedDefaultIntValue=1;break}switch(s.unit){case`%`:s.normalizedIntValue=s.intValue/100;break;case`rad`:s.normalizedIntValue=s.intValue/S;break;case`deg`:s.normalizedIntValue=s.intValue/360;break;case`px`:switch(a){case 0:s.normalizedIntValue=s.intValue/r;break;case 1:s.normalizedIntValue=s.intValue/i;break}break;default:s.normalizedIntValue=s.intValue;break}return s}function j(e,t){let n=1-e;return n*n*n*t}function M(e,t){let n=1-e;return 3*n*n*e*t}function N(e,t){return 3*(1-e)*e*e*t}function P(e,t){return e*e*e*t}function F(e,t,n,r,i){return j(e,t)+M(e,n)+N(e,r)+P(e,i)}function I(e,t,n=2){let r=t&&t.length,i=r?t[0]*n:e.length,a=L(e,0,i,n,!0),o=[];if(!a||a.next===a.prev)return o;let s,c,l;if(r&&(a=B(e,t,a,n)),e.length>80*n){s=e[0],c=e[1];let t=s,r=c;for(let a=n;a<i;a+=n){let n=e[a],i=e[a+1];n<s&&(s=n),i<c&&(c=i),n>t&&(t=n),i>r&&(r=i)}l=Math.max(t-s,r-c),l=l===0?0:32767/l}return z(a,o,n,s,c,l,0),o}function L(e,t,n,r,i){let a;if(i===Ce(e,t,n,r)>0)for(let i=t;i<n;i+=r)a=be(i/r|0,e[i],e[i+1],a);else for(let i=n-r;i>=t;i-=r)a=be(i/r|0,e[i],e[i+1],a);return a&&W(a,a.next)&&(xe(a),a=a.next),a}function R(e,t){if(!e)return e;t||=e;let n=e,r;do if(r=!1,!n.steiner&&(W(n,n.next)||U(n.prev,n,n.next)===0)){if(xe(n),n=t=n.prev,n===n.next)break;r=!0}else n=n.next;while(r||n!==t);return t}function z(e,t,n,r,i,a,o){if(!e)return;!o&&a&&se(e,r,i,a);let s=e;for(;e.prev!==e.next;){let c=e.prev,l=e.next;if(a?te(e,r,i,a):ee(e)){t.push(c.i,e.i,l.i),xe(e),e=l.next,s=l.next;continue}if(e=l,e===s){o?o===1?(e=ne(R(e),t),z(e,t,n,r,i,a,2)):o===2&&re(e,t,n,r,i,a):z(R(e),t,n,r,i,a,1);break}}}function ee(e){let t=e.prev,n=e,r=e.next;if(U(t,n,r)>=0)return!1;let i=t.x,a=n.x,o=r.x,s=t.y,c=n.y,l=r.y,u=Math.min(i,a,o),d=Math.min(s,c,l),f=Math.max(i,a,o),p=Math.max(s,c,l),m=r.next;for(;m!==t;){if(m.x>=u&&m.x<=f&&m.y>=d&&m.y<=p&&H(i,s,a,c,o,l,m.x,m.y)&&U(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function te(e,t,n,r){let i=e.prev,a=e,o=e.next;if(U(i,a,o)>=0)return!1;let s=i.x,c=a.x,l=o.x,u=i.y,d=a.y,f=o.y,p=Math.min(s,c,l),m=Math.min(u,d,f),h=Math.max(s,c,l),g=Math.max(u,d,f),_=le(p,m,t,n,r),v=le(h,g,t,n,r),y=e.prevZ,b=e.nextZ;for(;y&&y.z>=_&&b&&b.z<=v;){if(y.x>=p&&y.x<=h&&y.y>=m&&y.y<=g&&y!==i&&y!==o&&H(s,u,c,d,l,f,y.x,y.y)&&U(y.prev,y,y.next)>=0||(y=y.prevZ,b.x>=p&&b.x<=h&&b.y>=m&&b.y<=g&&b!==i&&b!==o&&H(s,u,c,d,l,f,b.x,b.y)&&U(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;y&&y.z>=_;){if(y.x>=p&&y.x<=h&&y.y>=m&&y.y<=g&&y!==i&&y!==o&&H(s,u,c,d,l,f,y.x,y.y)&&U(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;b&&b.z<=v;){if(b.x>=p&&b.x<=h&&b.y>=m&&b.y<=g&&b!==i&&b!==o&&H(s,u,c,d,l,f,b.x,b.y)&&U(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function ne(e,t){let n=e;do{let r=n.prev,i=n.next.next;!W(r,i)&&pe(r,n,n.next,i)&&_e(r,i)&&_e(i,r)&&(t.push(r.i,n.i,i.i),xe(n),xe(n.next),n=e=i),n=n.next}while(n!==e);return R(n)}function re(e,t,n,r,i,a){let o=e;do{let e=o.next.next;for(;e!==o.prev;){if(o.i!==e.i&&fe(o,e)){let s=ye(o,e);o=R(o,o.next),s=R(s,s.next),z(o,t,n,r,i,a,0),z(s,t,n,r,i,a,0);return}e=e.next}o=o.next}while(o!==e)}function B(e,t,n,r){let i=[];for(let n=0,a=t.length;n<a;n++){let o=L(e,t[n]*r,n<a-1?t[n+1]*r:e.length,r,!1);o===o.next&&(o.steiner=!0),i.push(ue(o))}i.sort(ie);for(let e=0;e<i.length;e++)n=V(i[e],n);return n}function ie(e,t){let n=e.x-t.x;return n===0&&(n=e.y-t.y,n===0&&(n=(e.next.y-e.y)/(e.next.x-e.x)-(t.next.y-t.y)/(t.next.x-t.x))),n}function V(e,t){let n=ae(e,t);if(!n)return t;let r=ye(n,e);return R(r,r.next),R(n,n.next)}function ae(e,t){let n=t,r=e.x,i=e.y,a=-1/0,o;if(W(e,n))return n;do{if(W(e,n.next))return n.next;if(i<=n.y&&i>=n.next.y&&n.next.y!==n.y){let e=n.x+(i-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(e<=r&&e>a&&(a=e,o=n.x<n.next.x?n:n.next,e===r))return o}n=n.next}while(n!==t);if(!o)return null;let s=o,c=o.x,l=o.y,u=1/0;n=o;do{if(r>=n.x&&n.x>=c&&r!==n.x&&de(i<l?r:a,i,c,l,i<l?a:r,i,n.x,n.y)){let t=Math.abs(i-n.y)/(r-n.x);_e(n,e)&&(t<u||t===u&&(n.x>o.x||n.x===o.x&&oe(o,n)))&&(o=n,u=t)}n=n.next}while(n!==s);return o}function oe(e,t){return U(e.prev,e,t.prev)<0&&U(t.next,e,e.next)<0}function se(e,t,n,r){let i=e;do i.z===0&&(i.z=le(i.x,i.y,t,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,ce(i)}function ce(e){let t,n=1;do{let r=e,i;e=null;let a=null;for(t=0;r;){t++;let o=r,s=0;for(let e=0;e<n&&(s++,o=o.nextZ,o);e++);let c=n;for(;s>0||c>0&&o;)s!==0&&(c===0||!o||r.z<=o.z)?(i=r,r=r.nextZ,s--):(i=o,o=o.nextZ,c--),a?a.nextZ=i:e=i,i.prevZ=a,a=i;r=o}a.nextZ=null,n*=2}while(t>1);return e}function le(e,t,n,r,i){return e=(e-n)*i|0,t=(t-r)*i|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function ue(e){let t=e,n=e;do(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next;while(t!==e);return n}function de(e,t,n,r,i,a,o,s){return(i-o)*(t-s)>=(e-o)*(a-s)&&(e-o)*(r-s)>=(n-o)*(t-s)&&(n-o)*(a-s)>=(i-o)*(r-s)}function H(e,t,n,r,i,a,o,s){return!(e===o&&t===s)&&de(e,t,n,r,i,a,o,s)}function fe(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!ge(e,t)&&(_e(e,t)&&_e(t,e)&&ve(e,t)&&(U(e.prev,e,t.prev)||U(e,t.prev,t))||W(e,t)&&U(e.prev,e,e.next)>0&&U(t.prev,t,t.next)>0)}function U(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function W(e,t){return e.x===t.x&&e.y===t.y}function pe(e,t,n,r){let i=he(U(e,t,n)),a=he(U(e,t,r)),o=he(U(n,r,e)),s=he(U(n,r,t));return!!(i!==a&&o!==s||i===0&&me(e,n,t)||a===0&&me(e,r,t)||o===0&&me(n,e,r)||s===0&&me(n,t,r))}function me(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function he(e){return e>0?1:e<0?-1:0}function ge(e,t){let n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&pe(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}function _e(e,t){return U(e.prev,e,e.next)<0?U(e,t,e.next)>=0&&U(e,e.prev,t)>=0:U(e,t,e.prev)<0||U(e,e.next,t)<0}function ve(e,t){let n=e,r=!1,i=(e.x+t.x)/2,a=(e.y+t.y)/2;do n.y>a!=n.next.y>a&&n.next.y!==n.y&&i<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next;while(n!==e);return r}function ye(e,t){let n=Se(e.i,e.x,e.y),r=Se(t.i,t.x,t.y),i=e.next,a=t.prev;return e.next=t,t.prev=e,n.next=i,i.prev=n,r.next=n,n.prev=r,a.next=r,r.prev=a,r}function be(e,t,n,r){let i=Se(e,t,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function xe(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function Se(e,t,n){return{i:e,x:t,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function Ce(e,t,n,r){let i=0;for(let a=t,o=n-r;a<n;a+=r)i+=(e[o]-e[a])*(e[a+1]+e[o+1]),o=a;return i}function we(e,t={}){let{vertices:n=[],indices:r=[],holes:i=[],verticesStride:a=2,verticesOffset:o=n.length/a,indicesOffset:s=r.length}=t,c=I(e,i,2);if(c.length){for(let e=0;e<c.length;e+=3)r[s++]=c[e]+o,r[s++]=c[e+1]+o,r[s++]=c[e+2]+o;let t=o*a;for(let r=0;r<e.length;r+=2)n[t]=e[r],n[t+1]=e[r+1],t+=a}return{vertices:n,indices:r}}var Te=8,Ee=1.1920929e-7,De=1,Oe=.01,ke=0,G=0;function Ae(e,t,n,r,i,a,o,s,c=.5,l=[]){let u=(De-Math.min(.99,Math.max(0,c)))/1;return u*=u,je(e,t,n,r,i,a,o,s,l,u,0),l.push(o,s),l}function je(e,t,n,r,i,a,o,s,c,l,u){if(u>Te)return;let d=Math.PI,f=(e+n)/2,p=(t+r)/2,m=(n+i)/2,h=(r+a)/2,g=(i+o)/2,_=(a+s)/2,v=(f+m)/2,y=(p+h)/2,b=(m+g)/2,x=(h+_)/2,S=(v+b)/2,C=(y+x)/2;if(u>0){let u=o-e,f=s-t,p=Math.abs((n-o)*f-(r-s)*u),m=Math.abs((i-o)*f-(a-s)*u),h,g;if(p>Ee&&m>Ee){if((p+m)*(p+m)<=l*(u*u+f*f)){if(ke<Oe){c.push(S,C);return}let l=Math.atan2(a-r,i-n);if(h=Math.abs(l-Math.atan2(r-t,n-e)),g=Math.abs(Math.atan2(s-a,o-i)-l),h>=d&&(h=2*d-h),g>=d&&(g=2*d-g),h+g<ke){c.push(S,C);return}if(G!==0){if(h>G){c.push(n,r);return}if(g>G){c.push(i,a);return}}}}else if(p>Ee){if(p*p<=l*(u*u+f*f)){if(ke<Oe){c.push(S,C);return}if(h=Math.abs(Math.atan2(a-r,i-n)-Math.atan2(r-t,n-e)),h>=d&&(h=2*d-h),h<ke){c.push(n,r),c.push(i,a);return}if(G!==0&&h>G){c.push(n,r);return}}}else if(m>Ee){if(m*m<=l*(u*u+f*f)){if(ke<Oe){c.push(S,C);return}if(h=Math.abs(Math.atan2(s-a,o-i)-Math.atan2(a-r,i-n)),h>=d&&(h=2*d-h),h<ke){c.push(n,r),c.push(i,a);return}if(G!==0&&h>G){c.push(i,a);return}}}else if(u=S-(e+o)/2,f=C-(t+s)/2,u*u+f*f<=l){c.push(S,C);return}}je(e,t,f,p,v,y,S,C,c,l,u+1),je(S,C,b,x,g,_,o,s,c,l,u+1)}var Me=8,Ne=1.1920929e-7,Pe=1,Fe=.01,Ie=0;function Le(e,t,n,r,i,a,o=.5,s=[]){let c=(Pe-Math.min(.99,Math.max(0,o)))/1;return c*=c,Re(s,e,t,n,r,i,a,c,0),s.push(i,a),s}function Re(e,t,n,r,i,a,o,s,c){if(c>Me)return;let l=Math.PI,u=(t+r)/2,d=(n+i)/2,f=(r+a)/2,p=(i+o)/2,m=(u+f)/2,h=(d+p)/2,g=a-t,_=o-n,v=Math.abs((r-a)*_-(i-o)*g);if(v>Ne){if(v*v<=s*(g*g+_*_)){if(Ie<Fe){e.push(m,h);return}let s=Math.abs(Math.atan2(o-i,a-r)-Math.atan2(i-n,r-t));if(s>=l&&(s=2*l-s),s<Ie){e.push(m,h);return}}}else if(g=m-(t+a)/2,_=h-(n+o)/2,g*g+_*_<=s){e.push(m,h);return}Re(e,t,n,u,d,m,h,s,c+1),Re(e,m,h,f,p,a,o,s,c+1)}function ze(e){let t=0,n=e.length;for(let r=0;r<n;r+=2){let i=e[r],a=e[r+1],o=e[(r+2)%n],s=e[(r+3)%n];t+=i*s-o*a}return t/2}function Be(e,t,n,r,i,a){return(n-e)*(a-t)-(r-t)*(i-e)}function Ve(e,t,n){let r=n.length,i=0;for(let a=0,o=r-2;a<r;o=a,a+=2){let r=n[a],s=n[a+1],c=n[o],l=n[o+1];s<=t?l>t&&Be(c,l,r,s,e,t)>0&&i++:l<=t&&Be(c,l,r,s,e,t)<0&&i--}return i}function He(e,t){let n=t[0]-e[0],r=t[1]-e[1];return Math.sqrt(n*n+r*r)}function Ue(e,t){return e.minX<=t.maxX&&e.maxX>=t.minX&&e.minY<=t.maxY&&e.maxY>=t.minY}function We(e){let t=e.map((e,t)=>({index:t})),n=[],r=e.map((e,t)=>{let r=e.length;if(!r)return n[t]=null,[];let i=[2**53-1,0],a=[0,2**53-1],o=[-(2**53-1),0],s=[0,-(2**53-1)];for(let t=0;t<r;t+=2){let n=e[t],r=e[t+1];i[0]>n&&(i=[n,r]),a[1]>r&&(a=[n,r]),o[0]<n&&(o=[n,r]),s[1]<r&&(s=[n,r])}n[t]={minX:i[0],minY:a[1],maxX:o[0],maxY:s[1]};let c=[(i[0]+o[0])/2,(a[1]+s[1])/2],l,u,d,f,p,m,h,g;for(let t=0;t<r;t+=2){let n=e[t],r=e[t+1],i=Math.abs(n-c[0]),a=Math.abs(r-c[1]);r<c[1]&&(!l||i<l)&&(l=i,d=[n,r]),r>c[1]&&(!u||i<u)&&(u=i,f=[n,r]),n<c[0]&&(!p||a<p)&&(p=a,h=[n,r]),n>c[0]&&(!m||a<m)&&(m=a,g=[n,r])}return[i,a,o,s,d,f,h,g].filter(Boolean)});for(let i=0,a=e.length;i<a;i++){let o=[],s=r[i],c=n[i];for(let t=0;t<a;t++){if(i===t)continue;let a=n[t];if(!c||!a||!Ue(c,a))continue;let l={},u=[];for(let n=0,r=s.length;n<r;n++){let[r,i]=s[n],a=Ve(r,i,e[t]);l[a]=(l[a]??0)+1,u.push(a)}u.filter(e=>e!==0).length>u.filter(e=>e===0).length&&o.push({index:i,parentIndex:t,winding:Number(Array.from(Object.entries(l)).sort((e,t)=>t[1]-e[1])?.[0]?.[0]??0),dist:He(r[i][0],r[t][0])})}o.reduce((e,t)=>e+t.winding,0)!==0&&(o.sort((e,t)=>e.dist-t.dist),t[i]=o[0])}return t}function Ge(e,t,n,r,i,a){return(n-e)*(a-t)-(i-e)*(r-t)}function Ke(e,t,n){let r=n.length,i=0;for(let a=0;a<r;a+=2){let o=n[a],s=n[a+1],c=(a+2)%r,l=n[c],u=n[c+1];s<=t?u>t&&Ge(o,s,l,u,e,t)>0&&i++:u<=t&&Ge(o,s,l,u,e,t)<0&&i--}return i}function qe(e,t,n){let r=n.length,i=0;for(let a=0;a<r;a+=2){let o=n[a],s=n[a+1],c=(a+2)%r,l=n[c],u=n[c+1];(s<=t&&u>t||s>t&&u<=t)&&e<o+(t-s)/(u-s)*(l-o)&&i++}return i}function Je(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s,l=c===0?0:((e-n)*o+(t-r)*s)/c;l<0?l=0:l>1&&(l=1);let u=n+l*o,d=r+l*s;return Math.hypot(e-u,t-d)}function Ye(e,t,n=`nonzero`){return t.length<6?!1:n===`evenodd`?(qe(e.x,e.y,t)&1)==1:Ke(e.x,e.y,t)!==0}function Xe(e,t,n=`nonzero`){let{x:r,y:i}=e;if(n===`evenodd`){let e=0;for(let n=0,a=t.length;n<a;n++){let a=t[n];a.length>=6&&(e+=qe(r,i,a))}return(e&1)==1}let a=0;for(let e=0,n=t.length;e<n;e++){let n=t[e];n.length>=6&&(a+=Ke(r,i,n))}return a!==0}function Ze(e,t,n){return Je(e.x,e.y,t.x,t.y,n.x,n.y)}function Qe(e,t,n=!1){let r=t.length;if(r<2)return 1/0;let{x:i,y:a}=e;if(r===2)return Math.hypot(i-t[0],a-t[1]);let o=1/0;for(let e=0;e<r-2;e+=2){let n=Je(i,a,t[e],t[e+1],t[e+2],t[e+3]);n<o&&(o=n)}if(n&&r>=6){let e=Je(i,a,t[r-2],t[r-1],t[0],t[1]);e<o&&(o=e)}return o}function $e(e,t){let n=1-e;return n*n*t}function et(e,t){return 2*(1-e)*e*t}function tt(e,t){return e*e*t}function nt(e,t,n,r){return $e(e,t)+et(e,n)+tt(e,r)}function rt(e){switch(e){case`round`:case`bevel`:case`miter`:return e;default:return`miter`}}function it(e){return{width:e?.strokeWidth??1,alignment:.5,join:rt(e?.strokeLinejoin),cap:e?.strokeLinecap??`butt`,miterLimit:e?.strokeMiterlimit??10}}var at=1e-4,ot=1e-4;function st(e,t={}){let{vertices:n=[],indices:r=[],flipAlignment:i=!1,closed:a=!0}=t,o=t.lineStyle??it(t.style),s=at;if(e.length===0)return{vertices:n,indices:r};let c=o,l=c.alignment;if(o.alignment!==.5){let t=ct(e);i&&(t*=-1),l=(l-.5)*t+.5}let u={x:e[0],y:e[1]},d={x:e[e.length-2],y:e[e.length-1]},f=a,p=Math.abs(u.x-d.x)<s&&Math.abs(u.y-d.y)<s;if(f){e=e.slice(),p&&(e.pop(),e.pop(),d.x=e[e.length-2],d.y=e[e.length-1]);let t=(u.x+d.x)*.5,n=(d.y+u.y)*.5;e.unshift(t,n),e.push(t,n)}let m=n,h=e.length/2,g=e.length,_=m.length/2,v=c.width/2,y=v*v,b=c.miterLimit*c.miterLimit,x=e[0],S=e[1],C=e[2],w=e[3],T=0,E=0,D=-(S-w),O=x-C,k=0,A=0,j=Math.sqrt(D*D+O*O);D/=j,O/=j,D*=v,O*=v;let M=l,N=(1-M)*2,P=M*2;f||(c.cap===`round`?g+=K(x-D*(N-P)*.5,S-O*(N-P)*.5,x-D*N,S-O*N,x+D*P,S+O*P,m,!0)+2:c.cap===`square`&&(g+=lt(x,S,D,O,N,P,!0,m))),m.push(x-D*N,S-O*N),m.push(x+D*P,S+O*P);for(let t=1;t<h-1;++t){x=e[(t-1)*2],S=e[(t-1)*2+1],C=e[t*2],w=e[t*2+1],T=e[(t+1)*2],E=e[(t+1)*2+1],D=-(S-w),O=x-C,j=Math.sqrt(D*D+O*O),D/=j,O/=j,D*=v,O*=v,k=-(w-E),A=C-T,j=Math.sqrt(k*k+A*A),k/=j,A/=j,k*=v,A*=v;let n=C-x,r=S-w,i=C-T,a=E-w,o=n*i+r*a,s=r*i-a*n,l=s<0;if(Math.abs(s)<.001*Math.abs(o)){m.push(C-D*N,w-O*N),m.push(C+D*P,w+O*P),o>=0&&(c.join===`round`?g+=K(C,w,C-D*N,w-O*N,C-k*N,w-A*N,m,!1)+4:g+=2,m.push(C-k*P,w-A*P),m.push(C+k*N,w+A*N));continue}let u=(-D+x)*(-O+w)-(-D+C)*(-O+S),d=(-k+T)*(-A+w)-(-k+C)*(-A+E),f=(n*d-i*u)/s,p=(a*u-r*d)/s,h=(f-C)*(f-C)+(p-w)*(p-w),_=C+(f-C)*N,M=w+(p-w)*N,F=C-(f-C)*P,I=w-(p-w)*P,L=Math.min(n*n+r*r,i*i+a*a),R=l?N:P;h<=L+R*R*y?c.join===`bevel`||h/y>b?(l?(m.push(_,M),m.push(C+D*P,w+O*P),m.push(_,M),m.push(C+k*P,w+A*P)):(m.push(C-D*N,w-O*N),m.push(F,I),m.push(C-k*N,w-A*N),m.push(F,I)),g+=2):c.join===`round`?l?(m.push(_,M),m.push(C+D*P,w+O*P),g+=K(C,w,C+D*P,w+O*P,C+k*P,w+A*P,m,!0)+4,m.push(_,M),m.push(C+k*P,w+A*P)):(m.push(C-D*N,w-O*N),m.push(F,I),g+=K(C,w,C-D*N,w-O*N,C-k*N,w-A*N,m,!1)+4,m.push(C-k*N,w-A*N),m.push(F,I)):(m.push(_,M),m.push(F,I)):(m.push(C-D*N,w-O*N),m.push(C+D*P,w+O*P),c.join===`round`?l?g+=K(C,w,C+D*P,w+O*P,C+k*P,w+A*P,m,!0)+2:g+=K(C,w,C-D*N,w-O*N,C-k*N,w-A*N,m,!1)+2:c.join===`miter`&&h/y<=b&&(l?(m.push(F,I),m.push(F,I)):(m.push(_,M),m.push(_,M)),g+=2),m.push(C-k*N,w-A*N),m.push(C+k*P,w+A*P),g+=2)}x=e[(h-2)*2],S=e[(h-2)*2+1],C=e[(h-1)*2],w=e[(h-1)*2+1],D=-(S-w),O=x-C,j=Math.sqrt(D*D+O*O),D/=j,O/=j,D*=v,O*=v,m.push(C-D*N,w-O*N),m.push(C+D*P,w+O*P),f||(c.cap===`round`?g+=K(C-D*(N-P)*.5,w-O*(N-P)*.5,C-D*N,w-O*N,C+D*P,w+O*P,m,!1)+2:c.cap===`square`&&(g+=lt(C,w,D,O,N,P,!1,m)));let F=ot*ot;for(let e=_;e<g+_-2;++e)x=m[e*2],S=m[e*2+1],C=m[(e+1)*2],w=m[(e+1)*2+1],T=m[(e+2)*2],E=m[(e+2)*2+1],!(Math.abs(x*(w-E)+C*(E-S)+T*(S-w))<F)&&r.push(e,e+1,e+2);return{vertices:n,indices:r}}function ct(e){let t=e.length;if(t<6)return 1;let n=0;for(let r=0,i=e[t-2],a=e[t-1];r<t;r+=2){let t=e[r],o=e[r+1];n+=(t-i)*(o+a),i=t,a=o}return n<0?-1:1}function lt(e,t,n,r,i,a,o,s){let c=e-n*i,l=t-r*i,u=e+n*a,d=t+r*a,f,p;o?(f=r,p=-n):(f=-r,p=n);let m=c+f,h=l+p,g=u+f,_=d+p;return s.push(m,h),s.push(g,_),2}function K(e,t,n,r,i,a,o,s){let c=n-e,l=r-t,u=Math.atan2(c,l),d=Math.atan2(i-e,a-t);s&&u<d?u+=Math.PI*2:!s&&u>d&&(d+=Math.PI*2);let f=u,p=d-u,m=Math.abs(p),h=Math.sqrt(c*c+l*l),g=(15*m*Math.sqrt(h)/Math.PI>>0)+1,_=p/g;if(f+=_,s){o.push(e,t),o.push(n,r);for(let n=1,r=f;n<g;n++,r+=_)o.push(e,t),o.push(e+Math.sin(r)*h,t+Math.cos(r)*h);o.push(e,t),o.push(i,a)}else{o.push(n,r),o.push(e,t);for(let n=1,r=f;n<g;n++,r+=_)o.push(e+Math.sin(r)*h,t+Math.cos(r)*h),o.push(e,t);o.push(i,a),o.push(e,t)}return g*2}var ut=class e{_array;constructor(e=1,t=0,n=0,r=1,i=0,a=0){this.a=e,this.b=t,this.c=n,this.d=r,this.tx=i,this.ty=a}set(e,t,n,r,i,a){return this.a=e,this.b=t,this.c=n,this.d=r,this.tx=i,this.ty=a,this}append(e){let t=this.a,n=this.b,r=this.c,i=this.d;return this.a=e.a*t+e.b*r,this.b=e.a*n+e.b*i,this.c=e.c*t+e.d*r,this.d=e.c*n+e.d*i,this.tx=e.tx*t+e.ty*r+this.tx,this.ty=e.tx*n+e.ty*i+this.ty,this}appendFrom(e,t){let n=e.a,r=e.b,i=e.c,a=e.d,o=e.tx,s=e.ty,c=t.a,l=t.b,u=t.c,d=t.d;return this.a=n*c+r*u,this.b=n*l+r*d,this.c=i*c+a*u,this.d=i*l+a*d,this.tx=o*c+s*u+t.tx,this.ty=o*l+s*d+t.ty,this}setTransform(e,t,n,r,i,a,o,s,c){return this.a=Math.cos(o+c)*i,this.b=Math.sin(o+c)*i,this.c=-Math.sin(o-s)*a,this.d=Math.cos(o-s)*a,this.tx=e-(n*this.a+r*this.c),this.ty=t-(n*this.b+r*this.d),this}prepend(e){let t=this.tx;if(e.a!==1||e.b!==0||e.c!==0||e.d!==1){let t=this.a,n=this.c;this.a=t*e.a+this.b*e.c,this.b=t*e.b+this.b*e.d,this.c=n*e.a+this.d*e.c,this.d=n*e.b+this.d*e.d}return this.tx=t*e.a+this.ty*e.c+e.tx,this.ty=t*e.b+this.ty*e.d+e.ty,this}skewX(e){let t=Math.tan(e);return this.a+=t*this.b,this.c+=t*this.d,this.tx+=t*this.ty,this}skewY(e){let t=Math.tan(e);return this.b+=t*this.a,this.d+=t*this.c,this.ty+=t*this.tx,this}skew(e,t){let n=Math.tan(e),r=Math.tan(t),i=this.a,a=this.b,o=this.c,s=this.d,c=this.tx,l=this.ty;return this.a=i+n*a,this.b=r*i+a,this.c=o+n*s,this.d=r*o+s,this.tx=c+n*l,this.ty=r*c+l,this}translateX(e){return this.translate(e,0)}translateY(e){return this.translate(0,e)}translateZ(e){return this.translate(0,0,e)}translate3d(e,t,n){return this.translate(e,t,n)}translate(e,t,n=0){return this.tx+=e,this.ty+=t,this}scaleX(e){return this.scale(e,1)}scaleY(e){return this.scale(1,e)}scale3d(e,t,n=1){return this.scale(e,t,n)}scale(e,t,n=1){return this.a*=e,this.d*=t,this.c*=e,this.b*=t,this.tx*=e,this.ty*=t,this}rotateX(e){return this.scaleY(this._rotateToScale(e))}rotateY(e){return this.scaleX(this._rotateToScale(e))}rotateZ(e){return this.rotate(e)}rotate(e){let t=Math.cos(e),n=Math.sin(e),r=this.a,i=this.c,a=this.tx;return this.a=r*t-this.b*n,this.b=r*n+this.b*t,this.c=i*t-this.d*n,this.d=i*n+this.d*t,this.tx=a*t-this.ty*n,this.ty=a*n+this.ty*t,this}rotate3d(e,t,n,r){let[i,a,o]=this._rotate3d(e,t,n,r);return i&&this.rotateX(i),a&&this.rotateY(a),o&&this.rotateZ(o),this}_rotateToScale(e){let t=e/S;return t<=.5?t*-4+1:(t-1)*4+1}_rotate3d(e,t,n,r){if(e===1&&t===0&&n===0)return[r,0,0];if(e===0&&t===1&&n===0)return[0,r,0];if(e===0&&t===0)return[0,0,r];{let i=Math.cos(r),a=Math.sin(r),o=i+e*e*(1-i),s=e*t*(1-i)-n*a,c=e*n*(1-i)+t*a,l=i+t*t*(1-i),u=t*n*(1-i)-e*a,d=i+n*n*(1-i);return[-Math.atan2(-u,l),-Math.atan2(c,Math.sqrt(u*u+d*d)),-Math.atan2(-s,o)]}}decompose(e={x:0,y:0},t={position:{x:0,y:0},scale:{x:0,y:0},skew:{x:0,y:0},rotation:0}){let{a:n,b:r,c:i,d:a,tx:o,ty:s}=this,c=-Math.atan2(-i,a),l=Math.atan2(r,n),u=Math.abs(c+l);return u<1e-5||Math.abs(S-u)<1e-5?(t.rotation=l,t.skew.x=t.skew.y=0):(t.rotation=0,t.skew.x=c,t.skew.y=l),t.scale.x=Math.sqrt(n*n+r*r),t.scale.y=Math.sqrt(i*i+a*a),t.position.x=o+(e.x*n+e.y*i),t.position.y=s+(e.x*r+e.y*a),t}apply(e,t){t||=new p;let{x:n,y:r}=e;return t.x=this.a*n+this.c*r+this.tx,t.y=this.b*n+this.d*r+this.ty,t}affineInvert(){let e=this.a,t=this.b,n=this.c,r=this.d,i=this.tx,a=e*r-t*n;return this.a=r/a,this.b=-t/a,this.c=-n/a,this.d=e/a,this.tx=(n*this.ty-r*i)/a,this.ty=-(e*this.ty-t*i)/a,this}affineInverse(){return this.clone().affineInvert()}applyAffineInverse(e,t){t||=new p;let{a:n,b:r,c:i,d:a,tx:o,ty:s}=this,c=1/(n*a+i*-r),l=e.x,u=e.y;return t.x=a*c*l+-i*c*u+(s*i-o*a)*c,t.y=n*c*u+-r*c*l+(-s*n+o*r)*c,t}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this}isIdentity(){let{a:e,b:t,c:n,d:r,tx:i,ty:a}=this;return e===1&&t===0&&n===0&&r===1&&i===0&&a===0}copyTo(e){return e.a=this.a,e.b=this.b,e.c=this.c,e.d=this.d,e.tx=this.tx,e.ty=this.ty,e}copyFrom(e){return this.a=e.a,this.b=e.b,this.c=e.c,this.d=e.d,this.tx=e.tx,this.ty=e.ty,this}equals(e){return e.a===this.a&&e.b===this.b&&e.c===this.c&&e.d===this.d&&e.tx===this.tx&&e.ty===this.ty}prependCssTransform(t,n={}){let{width:r=1,height:i=1}=n,a=new e;return O(t,{width:r,height:i}).reverse().forEach(({name:e,args:t})=>{let n=t.map(e=>e.normalizedIntValue);switch(e){case`translateX`:a.translateX(n[0]*r);break;case`translateY`:a.translateY(n[0]*i);break;case`translateZ`:a.translateZ(n[0]);break;case`translate`:a.translate(n[0]*r,(n[1]??n[0])*i);break;case`translate3d`:a.translate3d(n[0]*r,(n[1]??n[0])*i,n[2]??n[1]??n[0]);break;case`scaleX`:a.scaleX(n[0]);break;case`scaleY`:a.scaleY(n[0]);break;case`scale`:a.scale(n[0],n[1]??n[0]);break;case`scale3d`:a.scale3d(n[0],n[1]??n[0],n[2]??n[1]??n[0]);break;case`rotateX`:a.rotateX(n[0]*S);break;case`rotateY`:a.rotateY(n[0]*S);break;case`rotateZ`:a.rotateZ(n[0]*S);break;case`rotate`:a.rotate(n[0]*S);break;case`rotate3d`:a.rotate3d(n[0]*S,(n[1]??n[0])*S,(n[2]??n[1]??n[0])*S,(n[3]??n[2]??n[1]??n[0])*S);break;case`skewX`:a.skewX(n[0]*S);break;case`skewY`:a.skewY(n[0]*S);break;case`skew`:a.skew(n[0]*S,(n[0]??n[1])*S);break;case`matrix`:a.set(n[0],n[1],n[2],n[3],n[4],n[5]);break}}),this.prepend(a),this}clone(){return new e(this.a,this.b,this.c,this.d,this.tx,this.ty)}toArray(e,t){this._array||=new Float32Array(9);let n=t||this._array;return e?(n[0]=this.a,n[1]=this.b,n[2]=0,n[3]=this.c,n[4]=this.d,n[5]=0,n[6]=this.tx,n[7]=this.ty,n[8]=1):(n[0]=this.a,n[1]=this.c,n[2]=this.tx,n[3]=this.b,n[4]=this.d,n[5]=this.ty,n[6]=0,n[7]=0,n[8]=1),n}toString(){return`[Transform2D a=${this.a} b=${this.b} c=${this.c} d=${this.d} tx=${this.tx} ty=${this.ty}]`}toJSON(){return{a:this.a,b:this.b,c:this.c,d:this.d,tx:this.tx,ty:this.ty}}destroy(){this._array=void 0}};function dt(e,t,n,r){let i=e*n+t*r,a=Math.sqrt(e*e+t*t)*Math.sqrt(n*n+r*r),o=Math.acos(Math.max(-1,Math.min(1,i/a)));return e*r-t*n<0&&(o=-o),o}function ft(e,t,n,r,i,a,o,s){if(t===0||n===0){e.lineTo(s.x,s.y);return}r=r*Math.PI/180,t=Math.abs(t),n=Math.abs(n);let c=(o.x-s.x)/2,l=(o.y-s.y)/2,u=Math.cos(r)*c+Math.sin(r)*l,d=-Math.sin(r)*c+Math.cos(r)*l,f=t*t,p=n*n,m=u*u,h=d*d,g=m/f+h/p;if(g>1){let e=Math.sqrt(g);t=e*t,n=e*n,f=t*t,p=n*n}let _=f*h+p*m,v=(f*p-_)/_,y=Math.sqrt(Math.max(0,v));i===a&&(y=-y);let b=y*t*d/n,x=-y*n*u/t,S=Math.cos(r)*b-Math.sin(r)*x+(o.x+s.x)/2,C=Math.sin(r)*b+Math.cos(r)*x+(o.y+s.y)/2,w=dt(1,0,(u-b)/t,(d-x)/n),T=dt((u-b)/t,(d-x)/n,(-u-b)/t,(-d-x)/n)%(Math.PI*2);e.ellipse(S,C,t,n,r,w,w+T,a===0)}var q={SEPARATOR:/[ \t\r\n,.\-+]/,WHITESPACE:/[ \t\r\n]/,DIGIT:/\d/,SIGN:/[-+]/,POINT:/\./,COMMA:/,/,EXP:/e/i,FLAGS:/[01]/};function J(e,t,n=0){let r=0,i=!0,a=``,o=``,s=[];function c(e,t,n){let r=SyntaxError(`Unexpected character "${e}" at index ${t}.`);throw r.partial=n,r}function l(){a!==``&&(o===``?s.push(Number(a)):s.push(Number(a)*10**Number(o))),a=``,o=``}let u,d=e.length;for(let f=0;f<d;f++){if(u=e[f],Array.isArray(t)&&t.includes(s.length%n)&&q.FLAGS.test(u)){r=1,a=u,l();continue}if(r===0){if(q.WHITESPACE.test(u))continue;if(q.DIGIT.test(u)||q.SIGN.test(u)){r=1,a=u;continue}if(q.POINT.test(u)){r=2,a=u;continue}q.COMMA.test(u)&&(i&&c(u,f,s),i=!0)}if(r===1){if(q.DIGIT.test(u)){a+=u;continue}if(q.POINT.test(u)){a+=u,r=2;continue}if(q.EXP.test(u)){r=3;continue}q.SIGN.test(u)&&a.length===1&&q.SIGN.test(a[0])&&c(u,f,s)}if(r===2){if(q.DIGIT.test(u)){a+=u;continue}if(q.EXP.test(u)){r=3;continue}q.POINT.test(u)&&a[a.length-1]===`.`&&c(u,f,s)}if(r===3){if(q.DIGIT.test(u)){o+=u;continue}if(q.SIGN.test(u)){if(o===``){o+=u;continue}o.length===1&&q.SIGN.test(o)&&c(u,f,s)}}q.WHITESPACE.test(u)?(l(),r=0,i=!1):q.COMMA.test(u)?(l(),r=0,i=!0):q.SIGN.test(u)?(l(),r=1,a=u):q.POINT.test(u)?(l(),r=2,a=u):c(u,f,s)}return l(),s}function pt(e,t){return e-(t-e)}function mt(e,t){let n=new p,r=new p,i=``;for(let a=0,o=e.length;a<o;a++){let o=e[a];if(((o.type===`s`||o.type===`S`)&&!`CcSs`.includes(i)||(o.type===`t`||o.type===`T`)&&!`QqTt`.includes(i))&&r.copyFrom(n),o.type===`m`||o.type===`M`)o.type===`m`?n.add(o):n.copyFrom(o),t.moveTo(n.x,n.y),r.copyFrom(n);else if(o.type===`h`||o.type===`H`)o.type===`h`?n.x+=o.x:n.x=o.x,t.lineTo(n.x,n.y),r.copyFrom(n);else if(o.type===`v`||o.type===`V`)o.type===`v`?n.y+=o.y:n.y=o.y,t.lineTo(n.x,n.y),r.copyFrom(n);else if(o.type===`l`||o.type===`L`)o.type===`l`?n.add(o):n.copyFrom(o),t.lineTo(n.x,n.y),r.copyFrom(n);else if(o.type===`c`||o.type===`C`)o.type===`c`?(t.bezierCurveTo(n.x+o.x1,n.y+o.y1,n.x+o.x2,n.y+o.y2,n.x+o.x,n.y+o.y),r.x=n.x+o.x2,r.y=n.y+o.y2,n.add(o)):(t.bezierCurveTo(o.x1,o.y1,o.x2,o.y2,o.x,o.y),r.x=o.x2,r.y=o.y2,n.copyFrom(o));else if(o.type===`s`||o.type===`S`)o.type===`s`?(t.bezierCurveTo(pt(n.x,r.x),pt(n.y,r.y),n.x+o.x2,n.y+o.y2,n.x+o.x,n.y+o.y),r.x=n.x+o.x2,r.y=n.y+o.y2,n.add(o)):(t.bezierCurveTo(pt(n.x,r.x),pt(n.y,r.y),o.x2,o.y2,o.x,o.y),r.x=o.x2,r.y=o.y2,n.copyFrom(o));else if(o.type===`q`||o.type===`Q`)o.type===`q`?(t.quadraticCurveTo(n.x+o.x1,n.y+o.y1,n.x+o.x,n.y+o.y),r.x=n.x+o.x1,r.y=n.y+o.y1,n.add(o)):(t.quadraticCurveTo(o.x1,o.y1,o.x,o.y),r.x=o.x1,r.y=o.y1,n.copyFrom(o));else if(o.type===`t`||o.type===`T`){let e=pt(n.x,r.x),i=pt(n.y,r.y);r.x=e,r.y=i,o.type===`t`?(t.quadraticCurveTo(e,i,n.x+o.x,n.y+o.y),n.add(o)):(t.quadraticCurveTo(e,i,o.x,o.y),n.copyFrom(o))}else if(o.type===`a`||o.type===`A`){let e=n.clone();if(o.type===`a`){if(o.x===0&&o.y===0)continue;n.add(o)}else{if(n.equals(o))continue;n.copyFrom(o)}r.copyFrom(n),ft(t,o.rx,o.ry,o.angle,o.largeArcFlag,o.sweepFlag,e,n)}else o.type===`z`||o.type===`Z`?(t.startPoint&&n.copyFrom(t.startPoint),t.closePath()):console.warn(`Unsupported commands`,o);i=o.type}}function ht(e){let t,n,r=[];for(let i=0,a=e.length;i<a;i++){let a=e[i];switch(a.type){case`m`:case`M`:if(a.x.toFixed(4)===n?.x.toFixed(4)&&a.y.toFixed(4)===n?.y.toFixed(4))continue;r.push(`${a.type} ${a.x} ${a.y}`),n={x:a.x,y:a.y},t={x:a.x,y:a.y};break;case`h`:case`H`:r.push(`${a.type} ${a.x}`),n={x:a.x,y:n?.y??0};break;case`v`:case`V`:r.push(`${a.type} ${a.y}`),n={x:n?.x??0,y:a.y};break;case`l`:case`L`:r.push(`${a.type} ${a.x} ${a.y}`),n={x:a.x,y:a.y};break;case`c`:case`C`:r.push(`${a.type} ${a.x1} ${a.y1} ${a.x2} ${a.y2} ${a.x} ${a.y}`),n={x:a.x,y:a.y};break;case`s`:case`S`:r.push(`${a.type} ${a.x2} ${a.y2} ${a.x} ${a.y}`),n={x:a.x,y:a.y};break;case`q`:case`Q`:r.push(`${a.type} ${a.x1} ${a.y1} ${a.x} ${a.y}`),n={x:a.x,y:a.y};break;case`t`:case`T`:r.push(`${a.type} ${a.x} ${a.y}`),n={x:a.x,y:a.y};break;case`a`:case`A`:r.push(`${a.type} ${a.rx} ${a.ry} ${a.angle} ${a.largeArcFlag} ${a.sweepFlag} ${a.x} ${a.y}`),n={x:a.x,y:a.y};break;case`z`:case`Z`:r.push(a.type),t&&(n={x:t.x,y:t.y});break;default:break}}return r.join(` `)}var gt=/[a-df-z][^a-df-z]*/gi;function _t(e){let t=[],n=e.match(gt);if(!n)return t;for(let e=0,r=n.length;e<r;e++){let r=n[e],i=r.charAt(0),a=r.slice(1).trim(),o;switch(i){case`m`:case`M`:o=J(a);for(let e=0,n=o.length;e<n;e+=2)e===0?t.push({type:i,x:o[e],y:o[e+1]}):t.push({type:i===`m`?`l`:`L`,x:o[e],y:o[e+1]});break;case`h`:case`H`:o=J(a);for(let e=0,n=o.length;e<n;e++)t.push({type:i,x:o[e]});break;case`v`:case`V`:o=J(a);for(let e=0,n=o.length;e<n;e++)t.push({type:i,y:o[e]});break;case`l`:case`L`:o=J(a);for(let e=0,n=o.length;e<n;e+=2)t.push({type:i,x:o[e],y:o[e+1]});break;case`c`:case`C`:o=J(a);for(let e=0,n=o.length;e<n;e+=6)t.push({type:i,x1:o[e],y1:o[e+1],x2:o[e+2],y2:o[e+3],x:o[e+4],y:o[e+5]});break;case`s`:case`S`:o=J(a);for(let e=0,n=o.length;e<n;e+=4)t.push({type:i,x2:o[e],y2:o[e+1],x:o[e+2],y:o[e+3]});break;case`q`:case`Q`:o=J(a);for(let e=0,n=o.length;e<n;e+=4)t.push({type:i,x1:o[e],y1:o[e+1],x:o[e+2],y:o[e+3]});break;case`t`:case`T`:o=J(a);for(let e=0,n=o.length;e<n;e+=2)t.push({type:i,x:o[e],y:o[e+1]});break;case`a`:case`A`:o=J(a,[3,4],7);for(let e=0,n=o.length;e<n;e+=7)t.push({type:i,rx:o[e],ry:o[e+1],angle:o[e+2],largeArcFlag:o[e+3],sweepFlag:o[e+4],x:o[e+5],y:o[e+6]});break;case`z`:case`Z`:t.push({type:i});break;default:console.warn(r)}}return t}var vt=`data:image/svg+xml;`,yt=`${vt}base64,`,bt=`${vt}charset=utf8,`;function xt(e){if(typeof e==`string`){let t;e.startsWith(yt)?(e=e.substring(yt.length,e.length),t=atob(e)):e.startsWith(bt)?(e=e.substring(bt.length,e.length),t=decodeURIComponent(e)):t=e;let n=new DOMParser().parseFromString(t,`text/xml`),r=n.querySelector(`parsererror`);if(r)throw Error(`${r.textContent??`parser error`}\n${t}`);return n.documentElement}else return e}var St=`px`,Ct=90,wt=[`mm`,`cm`,`in`,`pt`,`pc`,`px`],Tt={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 Y(e){let t=`px`;if(typeof e==`string`)for(let n=0,r=wt.length;n<r;n++){let r=wt[n];if(e.endsWith(r)){t=r,e=e.substring(0,e.length-r.length);break}}let n;return t===`px`&&St!==`px`?n=Tt.in[St]/Ct:(n=Tt[t][St],n<0&&(n=Tt[t].in*Ct)),n*Number.parseFloat(e)}function Et(e,t,n){if(!(e.hasAttribute(`transform`)||e.nodeName===`use`&&(e.hasAttribute(`x`)||e.hasAttribute(`y`))))return null;let r=Dt(e);return n.length>0&&r.prepend(n[n.length-1]),t.copyFrom(r),n.push(r),r}function Dt(e){let t=new ut;return e.nodeName===`use`&&(e.hasAttribute(`x`)||e.hasAttribute(`y`))&&t.translate(Y(e.getAttribute(`x`)),Y(e.getAttribute(`y`))),e.hasAttribute(`transform`)&&t.prependCssTransform(e.getAttribute(`transform`)),t}function Ot(e){return new $().arc(Y(e.getAttribute(`cx`)||0),Y(e.getAttribute(`cy`)||0),Y(e.getAttribute(`r`)||0),0,Math.PI*2)}function kt(e,t){if(!(!e.sheet||!e.sheet.cssRules||!e.sheet.cssRules.length))for(let n=0;n<e.sheet.cssRules.length;n++){let r=e.sheet.cssRules[n];if(r.type!==1)continue;let i=r.selectorText.split(/,/g).filter(Boolean).map(e=>e.trim()),a={};for(let e=r.style.length,t=0;t<e;t++){let e=r.style.item(t);a[e]=r.style.getPropertyValue(e)}for(let e=0;e<i.length;e++)t[i[e]]=Object.assign(t[i[e]]||{},{...a})}}function At(e){return new $().ellipse(Y(e.getAttribute(`cx`)||0),Y(e.getAttribute(`cy`)||0),Y(e.getAttribute(`rx`)||0),Y(e.getAttribute(`ry`)||0),0,0,Math.PI*2)}function jt(e){return new $().moveTo(Y(e.getAttribute(`x1`)||0),Y(e.getAttribute(`y1`)||0)).lineTo(Y(e.getAttribute(`x2`)||0),Y(e.getAttribute(`y2`)||0))}function Mt(e){let t=new $,n=e.getAttribute(`d`);return!n||n===`none`?null:(t.addData(n),t)}var Nt=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function Pt(e){let t=new $,n=0;return e.getAttribute(`points`)?.replace(Nt,(e,r,i)=>{let a=Y(r),o=Y(i);return n===0?t.moveTo(a,o):t.lineTo(a,o),n++,e}),t.currentCurve.autoClose=!0,t}var Ft=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function It(e){let t=new $,n=0;return e.getAttribute(`points`)?.replace(Ft,(e,r,i)=>{let a=Y(r),o=Y(i);return n===0?t.moveTo(a,o):t.lineTo(a,o),n++,e}),t.currentCurve.autoClose=!1,t}function Lt(e){let t=Y(e.getAttribute(`x`)||0),n=Y(e.getAttribute(`y`)||0),r=e.getAttribute(`rx`),i=e.getAttribute(`ry`),a=Y(r??i??0),o=Y(i??r??0),s=Y(e.getAttribute(`width`)),c=Y(e.getAttribute(`height`));a=Math.max(0,Math.min(a,s/2)),o=Math.max(0,Math.min(o,c/2));let l=.448084975506,u=new $;return u.moveTo(t+a,n),u.lineTo(t+s-a,n),(a!==0||o!==0)&&u.bezierCurveTo(t+s-a*l,n,t+s,n+o*l,t+s,n+o),u.lineTo(t+s,n+c-o),(a!==0||o!==0)&&u.bezierCurveTo(t+s,n+c-o*l,t+s-a*l,n+c,t+s-a,n+c),u.lineTo(t+a,n+c),(a!==0||o!==0)&&u.bezierCurveTo(t+a*l,n+c,t,n+c-o*l,t,n+c-o),u.lineTo(t,n+o),(a!==0||o!==0)&&u.bezierCurveTo(t,n+o*l,t+a*l,n,t+a,n),u}function X(e,t,n){t=Object.assign({},t);let r={};if(e.hasAttribute(`class`)){let t=e.getAttribute(`class`).split(/\s/).filter(Boolean).map(e=>e.trim());for(let e=0;e<t.length;e++)r=Object.assign(r,n[`.${t[e]}`])}e.hasAttribute(`id`)&&(r=Object.assign(r,n[`#${e.getAttribute(`id`)}`]));for(let n=e.style.length,i=0;i<n;i++){let n=e.style.item(i),a=e.style.getPropertyValue(n);t[n]=a,r[n]=a}function i(n,i,o=a){e.hasAttribute(n)&&(t[i]=o(e.getAttribute(n))),r[n]&&(t[i]=o(r[n]))}function a(e){return e.startsWith(`url`)&&console.warn(`url access in attributes is not implemented.`),e}function o(e){return Math.max(0,Math.min(1,Y(e)))}function s(e){return Math.max(0,Y(e))}function c(e){return e.split(` `).filter(e=>e!==``).map(e=>Y(e))}return i(`fill`,`fill`),i(`fill-opacity`,`fillOpacity`,o),i(`fill-rule`,`fillRule`),i(`opacity`,`opacity`,o),i(`stroke`,`stroke`),i(`stroke-opacity`,`strokeOpacity`,o),i(`stroke-width`,`strokeWidth`,s),i(`stroke-linecap`,`strokeLinecap`),i(`stroke-linejoin`,`strokeLinejoin`),i(`stroke-miterlimit`,`strokeMiterlimit`,s),i(`stroke-dasharray`,`strokeDasharray`,c),i(`stroke-dashoffset`,`strokeDashoffset`,Y),i(`visibility`,`visibility`),t}function Rt(e,t,n=[],r={}){if(e.nodeType!==1)return n;let i=!1,a=null,o={...t};switch(e.nodeName){case`svg`:o=X(e,o,r);break;case`style`:kt(e,r);break;case`g`:o=X(e,o,r);break;case`path`:o=X(e,o,r),e.hasAttribute(`d`)&&(a=Mt(e));break;case`rect`:o=X(e,o,r),a=Lt(e);break;case`polygon`:o=X(e,o,r),a=Pt(e);break;case`polyline`:o=X(e,o,r),a=It(e);break;case`circle`:o=X(e,o,r),a=Ot(e);break;case`ellipse`:o=X(e,o,r),a=At(e);break;case`line`:o=X(e,o,r),a=jt(e);break;case`defs`:i=!0;break;case`use`:{o=X(e,o,r);let t=(e.getAttributeNS(`http://www.w3.org/1999/xlink`,`href`)||e.getAttribute(`href`)||``).substring(1),i=e.viewportElement?.getElementById(t);i?Rt(i,o,n,r):console.warn(`'use node' references non-existent node id: ${t}`);break}default:console.warn(e);break}if(o.display===`none`)return n;let s=new ut,c=[],l=Et(e,s,c);a&&(a.applyTransform(s),n.push(a),a.style={...o});let u=e.childNodes;for(let e=0,t=u.length;e<t;e++){let t=u[e];i&&t.nodeName!==`style`&&t.nodeName!==`defs`||Rt(t,o,n,r)}return l&&(c.pop(),c.length>0?s.copyFrom(c[c.length-1]):s.identity()),n}function zt(e){let t=xt(e);return new ln(Rt(t,{}),t.getAttribute(`viewBox`)?.trim().split(` `).map(e=>Number(e)))}var Z=class{arcLengthDivision=200;_lengths=[];_adaptiveCache;_owner;_invalidating=!1;invalidate(){return this._invalidating?this:(this._invalidating=!0,this._invalidateSelf(),this._owner?.invalidate(),this._invalidating=!1,this)}_invalidateSelf(){this._lengths.length=0,this._adaptiveCache=void 0}_getCachedAdaptiveVertices(){return this._adaptiveCache??=this.getAdaptiveVertices()}getPointAt(e,t=new p){return this.getPoint(this.getUToTMapping(e),t)}isClockwise(){return!1}getControlPointRefs(){return[]}reverse(){let e=this.getControlPointRefs(),t=e.length,n=e.map(e=>e.clone());for(let r=0;r<t;r++)e[r].copyFrom(n[t-1-r]);return this.invalidate(),this}applyTransform(e){let t=typeof e==`function`;return this.getControlPointRefs().forEach(n=>{t?e(n):e.apply(n,n)}),this.invalidate(),this}getUnevenVertices(e=5,t=[]){let n=new p;for(let r=0,i=Math.max(1,e)-1;r<=i;r++)this.getPoint(r/i,n),t.push(n.x,n.y);return t}getSpacedVertices(e=5,t=[]){let n=new p;for(let r=0,i=Math.max(1,e)-1;r<=i;r++)this.getPointAt(r/i,n),t.push(n.x,n.y);return t}getAdaptiveVertices(e=[]){return this.getUnevenVertices(5,e)}_verticesToPoints(e,t=[]){for(let n=0,r=e.length;n<r;n+=2){let r=e[n],i=e[n+1];t.push(new p(r,i))}return t}getSpacedPoints(e,t=[]){let n=this.getSpacedVertices(e);return this._verticesToPoints(n,t),t}getUnevenPoints(e,t=[]){let n=this.getUnevenVertices(e);return this._verticesToPoints(n,t),t}getAdaptivePoints(e=[]){let t=this.getAdaptiveVertices();return this._verticesToPoints(t,e),e}getPoints(e,t=[]){let n;return n=e?this.getUnevenVertices(e):this.getAdaptiveVertices(),this._verticesToPoints(n,t),t}getLength(){let e=this.getLengths();return e[e.length-1]??0}getLengths(){return this._lengths.length!==this.arcLengthDivision+1&&this.updateLengths(),this._lengths}updateLengths(){let e=this.arcLengthDivision,t=[0];for(let n=0,r=this.getPoint(0),i=1;i<=e;i++){let a=this.getPoint(i/e);n+=a.distanceTo(r),t.push(n),r=a}this._lengths=t}getUToTMapping(e,t){let n=this.getLengths(),r=n.length,i=t??e*n[r-1];if(r<2)return i/n[0];let a=0,o=0,s=r-1,c;for(;o<=s;)if(a=Math.floor(o+(s-o)/2),c=n[a]-i,c<0)o=a+1;else if(c>0)s=a-1;else{s=a;break}if(a=Math.max(0,s),n[a]===i)return a/(r-1);let l=n[a],u=n[a+1]-l,d=Math.max(0,(i-l)/u);return(a+d)/(r-1)}getTangent(e,t=new p){let n=1e-4,r=Math.max(0,e-n),i=Math.min(1,e+n);return t.copyFrom(this.getPoint(i).sub(this.getPoint(r)).normalize())}getTangentAt(e,t){return this.getTangent(this.getUToTMapping(e),t)}getPosTan(e){let t=this.getLength(),n=t>0?Math.min(Math.max(e/t,0),1):0,r=this.getUToTMapping(n),i=this.getTangent(r);return{position:this.getPoint(r),tangent:i,angle:Math.atan2(i.y,i.x)}}getNormal(e,t=new p){return this.getTangent(e,t),t.set(-t.y,t.x).normalize()}getNormalAt(e,t){return this.getNormal(this.getUToTMapping(e),t)}getTForPoint(e,t=.001){let n=0,r=1,i=(n+r)/2;for(;r-n>t;){i=(n+r)/2;let a=this.getPoint(i);if(a.distanceTo(e)<t)return i;a.x<e.x?n=i:r=i}return i}getMinMax(e=p.MAX,t=p.MIN){let n=this.getAdaptiveVertices(),r=e.x,i=e.y,a=t.x,o=t.y;for(let e=0,t=n.length;e<t;e+=2){let t=n[e],s=n[e+1];t<r&&(r=t),s<i&&(i=s),t>a&&(a=t),s>o&&(o=s)}return e.set(r,i),t.set(a,o),{min:e.finite(),max:t.finite()}}getBoundingBox(){let{min:e,max:t}=this.getMinMax();return new m(e.x,e.y,t.x-e.x,t.y-e.y)}isPointInFill(e,t={}){return Ye(e,this._getCachedAdaptiveVertices(),t.fillRule)}isPointInStroke(e,t={}){let{strokeWidth:n=1,tolerance:r=0,closed:i=!1}=t;return Qe(e,this._getCachedAdaptiveVertices(),i)<=n/2+r}contains(e,t,n={}){return this.isPointInFill({x:e,y:t},n)}getFillVertices(e){return this.getAdaptiveVertices()}fillTriangulate(e){return we(this.getFillVertices(e),e)}isClosed(){let e=this._getCachedAdaptiveVertices(),t=e.length;if(t<6)return!1;let n=1e-4;return Math.abs(e[0]-e[t-2])<n&&Math.abs(e[1]-e[t-1])<n}strokeTriangulate(e){return st(this.getAdaptiveVertices(),{...e,closed:e?.closed??this.isClosed()})}toCommands(){let e=[],t=this.getPoints();for(let n=0,r=t.length;n<r;n++){let r=t[n];n===0?e.push({type:`M`,x:r.x,y:r.y}):e.push({type:`L`,x:r.x,y:r.y})}return e}toData(){return ht(this.toCommands())}drawTo(e){return this.toCommands().forEach(t=>{switch(t.type){case`M`:e.moveTo(t.x,t.y);break;case`L`:e.lineTo(t.x,t.y);break}}),this}copyFrom(e){return this.arcLengthDivision=e.arcLengthDivision,this}clone(){return new this.constructor().copyFrom(this)}},Bt=new ut,Vt=new ut,Ht=new ut,Ut=new p,Wt=class extends Z{get cx(){return this._center.x}set cx(e){this._center.x=e}get cy(){return this._center.y}set cy(e){this._center.y=e}get rx(){return this._radius.x}set rx(e){this._radius.x=e}get ry(){return this._radius.y}set ry(e){this._radius.y=e}get dx(){return this._diff.x}set dx(e){this._diff.x=e}get dy(){return this._diff.y}set dy(e){this._diff.y=e}constructor(e=new p,t=new p,n=new p,r=0,i=0,a=Math.PI*2,o=!1){super(),this._center=e,this._radius=t,this._diff=n,this.rotate=r,this.startAngle=i,this.endAngle=a,this.clockwise=o}isClockwise(){return this.clockwise}isClosed(){return Math.abs(this.endAngle-this.startAngle)>=Math.PI*2-1e-9||super.isClosed()}reverse(){let{startAngle:e,endAngle:t}=this;return this.startAngle=t,this.endAngle=e,this.clockwise=!this.clockwise,this.invalidate(),this}_getDeltaAngle(){let e=Math.PI*2,t=this.endAngle-this.startAngle,n=Math.abs(t)<2**-52;return t=(t%e+e)%e,n?t=0:this.clockwise||(t=t===0?-e:t-e),t}getPoint(e,t=new p){let n=this._getDeltaAngle(),r=this.startAngle+e*n,i=this.cx+this.rx*Math.cos(r),a=this.cy+this.ry*Math.sin(r);if(this.rotate!==0){let e=Math.cos(this.rotate),t=Math.sin(this.rotate),n=i-this.cx,r=a-this.cy;i=n*e-r*t+this.cx,a=n*t+r*e+this.cy}return t.set(i,a)}_pointAtAngle(e,t){let n=this.cx+this.rx*Math.cos(e),r=this.cy+this.ry*Math.sin(e);if(this.rotate!==0){let e=Math.cos(this.rotate),t=Math.sin(this.rotate),i=n-this.cx,a=r-this.cy;n=i*e-a*t+this.cx,r=i*t+a*e+this.cy}return t.set(n,r)}getMinMax(e=p.MAX,t=p.MIN){let{startAngle:n,rotate:r}=this,i=this._getDeltaAngle(),a=Math.cos(r),o=Math.sin(r),s=Ut,c=e.x,l=e.y,u=t.x,d=t.y,f=e=>{this._pointAtAngle(e,s),s.x<c&&(c=s.x),s.y<l&&(l=s.y),s.x>u&&(u=s.x),s.y>d&&(d=s.y)};f(n),f(n+i);let m=Math.atan2(-this.ry*o,this.rx*a),h=Math.atan2(this.ry*a,this.rx*o),g=[m,m+Math.PI,h,h+Math.PI];for(let e=0;e<4;e++)Gt(g[e],n,i)&&f(g[e]);return e.set(c,l),t.set(u,d),{min:e.finite(),max:t.finite()}}toCommands(){let{cx:e,cy:t,rx:n,ry:r,startAngle:i,endAngle:a,clockwise:o,rotate:s}=this,c=e+n*Math.cos(i)*Math.cos(s)-r*Math.sin(i)*Math.sin(s),l=t+n*Math.cos(i)*Math.sin(s)+r*Math.sin(i)*Math.cos(s),u=Math.abs(i-a),d=+(u>Math.PI),f=+!!o,p=s*180/Math.PI;if(u>=2*Math.PI){let a=i+Math.PI,o=e+n*Math.cos(a)*Math.cos(s)-r*Math.sin(a)*Math.sin(s),u=t+n*Math.cos(a)*Math.sin(s)+r*Math.sin(a)*Math.cos(s);return[{type:`M`,x:c,y:l},{type:`A`,rx:n,ry:r,angle:p,largeArcFlag:0,sweepFlag:f,x:o,y:u},{type:`A`,rx:n,ry:r,angle:p,largeArcFlag:0,sweepFlag:f,x:c,y:l}]}else{let i=e+n*Math.cos(a)*Math.cos(s)-r*Math.sin(a)*Math.sin(s),o=t+n*Math.cos(a)*Math.sin(s)+r*Math.sin(a)*Math.cos(s);return[{type:`M`,x:c,y:l},{type:`A`,rx:n,ry:r,angle:p,largeArcFlag:d,sweepFlag:f,x:i,y:o}]}}drawTo(e){let{cx:t,cy:n,rx:r,ry:i,rotate:a,startAngle:o,endAngle:s,clockwise:c}=this;return e.ellipse(t,n,r,i,a,o,s,!c),this}applyTransform(e){return Ut.set(this.cx,this.cy),e.apply(Ut,Ut),this.cx=Ut.x,this.cy=Ut.y,Yt(e)?Kt(this,e):qt(this,e),this.invalidate(),this}getControlPointRefs(){return[this._center]}_getAdaptiveVerticesByArc(e=[]){let{cx:t,cy:n,rx:r,ry:i,dx:a,dy:o,startAngle:s,endAngle:c,clockwise:l,rotate:u}=this,d=!l,f=Math.abs(s-c);(!d&&s>c||d&&c>s)&&(f=2*Math.PI-f);let p=Math.max(12,Math.floor(12*r**(1/3)*(f/Math.PI))),m=f/p,h=s;m*=d?-1:1;let g=Math.cos(d?u:-u),_=Math.sin(d?u:-u);for(let s=0;s<p+1;s++){let s=a+Math.cos(h)*r,c=o+Math.sin(h)*i,l=s*g-c*_,u=s*_+c*g;e.push(t+l,n+u),h+=m}return e}_getAdaptiveVerticesByCircle(e=[]){let{cx:t,cy:n,rx:r,ry:i,dx:a,dy:o,rotate:s,clockwise:c}=this;if(!(r>=0&&i>=0&&a>=0&&o>=0))return e;let l=Math.ceil(2.3*Math.sqrt(r+i)),u=l*8+(a?4:0)+(o?4:0),d=[];if(u===0)return e;{let e=d.length;if(l===0)d[e]=d[e+6]=t+a,d[e+1]=d[e+3]=n+o,d[e+2]=d[e+4]=t-a,d[e+5]=d[e+7]=n-o;else{let s=e,c=e+l*4+(a?2:0)+2,f=c,p=u,m=a+r,h=o,g=t+m,_=t-m,v=n+h;if(d[s++]=g,d[s++]=v,d[--c]=v,d[--c]=_,o){let e=n-h;d[f++]=_,d[f++]=e,d[--p]=e,d[--p]=g}for(let e=1;e<l;e++){let u=Math.PI/2*(e/l),m=a+Math.cos(u)*r,h=o+Math.sin(u)*i,g=t+m,_=t-m,v=n+h,y=n-h;d[s++]=g,d[s++]=v,d[--c]=v,d[--c]=_,d[f++]=_,d[f++]=y,d[--p]=y,d[--p]=g}m=a,h=o+i,g=t+m,_=t-m,v=n+h;let y=n-h;d[s++]=g,d[s++]=v,d[--p]=y,d[--p]=g,a&&(d[s++]=_,d[s++]=v,d[--p]=y,d[--p]=_)}}let f=Math.cos(c?-s:s),p=Math.sin(c?-s:s);for(let r=0;r<d.length;r+=2){let i=d[r],a=d[r+1],o=i-t,s=a-n,c=o*f-s*p,l=o*p+s*f;e.push(t+c,n+l)}return e}getAdaptiveVertices(e=[]){let t=Math.PI*2;if(this.startAngle===0&&this.endAngle===t)return this._getAdaptiveVerticesByCircle(e);if(Math.abs(this.endAngle-this.startAngle)>=t-1e-9){let t=this._getAdaptiveVerticesByCircle([]),n=t.length/2;if(this.endAngle>this.startAngle)for(let n=0;n<t.length;n++)e.push(t[n]);else{e.push(t[0],t[1]);for(let r=n-1;r>=1;r--)e.push(t[r*2],t[r*2+1])}return e}return this._getAdaptiveVerticesByArc(e)}copyFrom(e){return super.copyFrom(e),this.cx=e.cx,this.cy=e.cy,this.rx=e.rx,this.ry=e.ry,this.dx=e.dx,this.dy=e.dy,this.startAngle=e.startAngle,this.endAngle=e.endAngle,this.clockwise=e.clockwise,this.rotate=e.rotate,this}};function Gt(e,t,n){let r=Math.PI*2,i=1e-9;if(Math.abs(n)>=r-i)return!0;let a=(e-t)%r;return n>=0?(a<-i&&(a+=r),a>=-i&&a<=n+i):(a>i&&(a-=r),a<=i&&a>=n-i)}function Kt(e,t){let n=e.rx,r=e.ry,i=Math.cos(e.rotate),a=Math.sin(e.rotate),o=new p(n*i,n*a),s=new p(-r*a,r*i),c=t.a*o.x+t.c*o.y,l=t.b*o.x+t.d*o.y,u=t.a*s.x+t.c*s.y,d=t.b*s.x+t.d*s.y,f=Bt.set(c,l,u,d,0,0),{a:m,b:h,c:g,d:_}=Vt.copyFrom(f).affineInvert(),v=Xt(m*m+h*h,g*m+_*h,g*g+_*_),y=Math.sqrt(v.rt1),b=Math.sqrt(v.rt2);if(e.rx=1/y,e.ry=1/b,e.rotate=Math.atan2(v.sn,v.cs),!((e.endAngle-e.startAngle)%(2*Math.PI)<2**-52)){let n=Vt.set(y,0,0,b,0,0),r=Ht.set(v.cs,v.sn,-v.sn,v.cs,0,0),i=n.append(r).append(f),a=e=>{let{x:t,y:n}=i.apply({x:Math.cos(e),y:Math.sin(e)});return Math.atan2(n,t)};e.startAngle=a(e.startAngle),e.endAngle=a(e.endAngle),Jt(t)&&(e.clockwise=!e.clockwise)}}function qt(e,t){let{scale:n}=t.decompose();e.rx*=n.x,e.ry*=n.y;let r=n.x>2**-52?Math.atan2(t.b,t.a):Math.atan2(-t.c,t.d);e.rotate+=r,Jt(t)&&(e.startAngle*=-1,e.endAngle*=-1,e.clockwise=!e.clockwise)}function Jt(e){return e.a*e.d-e.c*e.b<0}function Yt(e){let t=e.a*e.c+e.b*e.d;if(t===0)return!1;let{scale:n}=e.decompose();return Math.abs(t/(n.x*n.y))>2**-52}function Xt(e,t,n){let r,i,a,o,s,c=e+n,l=e-n,u=Math.sqrt(l*l+4*t*t);return c>0?(r=.5*(c+u),s=1/r,i=e*s*n-t*s*t):c<0?(i=.5*(c-u),s=1/i,r=e*s*n-t*s*t):(r=.5*u,i=-.5*u),a=l>0?l+u:l-u,Math.abs(a)>2*Math.abs(t)?(s=-2*t/a,o=1/Math.sqrt(1+s*s),a=s*o):Math.abs(t)===0?(a=1,o=0):(s=-.5*a/t,a=1/Math.sqrt(1+s*s),o=s*a),l>0&&(s=a,a=-o,o=s),{rt1:r,rt2:i,cs:a,sn:o}}var Zt=class extends Wt{constructor(e=0,t=0,n=1,r=0,i=Math.PI*2,a=!1){super(new p(e,t),new p(n,n),new p,0,r,i,a)}drawTo(e){let{cx:t,cy:n,rx:r,startAngle:i,endAngle:a,clockwise:o}=this;return e.arc(t,n,r,i,a,!o),this}},Q=class e extends Z{static from(t,n,r,i){return new e(new p(t,n),new p(r,i))}constructor(e=new p,t=new p){super(),this.p1=e,this.p2=t}getPoint(e,t=new p){return e===1?t.copyFrom(this.p2):t.copyFrom(this.p2).sub(this.p1).scale(e).add(this.p1),t}getPointAt(e,t=new p){return this.getPoint(e,t)}getTangent(e,t=new p){return t.subVectors(this.p2,this.p1).normalize()}getTangentAt(e,t=new p){return this.getTangent(e,t)}getControlPointRefs(){return[this.p1,this.p2]}reverse(){let{p1:e,p2:t}=this;return this.p1=t,this.p2=e,this.invalidate(),this}getAdaptiveVertices(e=[]){return e.push(this.p1.x,this.p1.y,this.p2.x,this.p2.y),e}getMinMax(e=p.MAX,t=p.MIN){let{p1:n,p2:r}=this;return e.x=Math.min(e.x,n.x,r.x),e.y=Math.min(e.y,n.y,r.y),t.x=Math.max(t.x,n.x,r.x),t.y=Math.max(t.y,n.y,r.y),{min:e.finite(),max:t.finite()}}toCommands(){let{p1:e,p2:t}=this;return[{type:`M`,x:e.x,y:e.y},{type:`L`,x:t.x,y:t.y}]}getFillVertices(e={}){let t=Math.min(this.p1.x,this.p2.x),n=Math.max(this.p1.x,this.p2.x),r=Math.min(this.p1.y,this.p2.y),i=Math.max(this.p1.y,this.p2.y),a=t,o=r,s=n-t||e.style?.strokeWidth||0,c=i-r||e.style?.strokeWidth||0;return[a,o,a+s,o,a+s,o+c,a,o+c]}drawTo(e){let{p1:t,p2:n}=this;return e.lineTo(t.x,t.y),e.lineTo(n.x,n.y),this}copyFrom(e){return super.copyFrom(e),this.p1.copyFrom(e.p1),this.p2.copyFrom(e.p2),this}},Qt=class e extends Z{_adaptiveCacheLen=-1;constructor(e=[]){super(),this.curves=e}_invalidateSelf(){super._invalidateSelf(),this._adaptiveCacheLen=-1,this.curves.forEach(e=>e.invalidate())}_getCachedAdaptiveVertices(){return(!this._adaptiveCache||this._adaptiveCacheLen!==this.curves.length)&&(this.curves.forEach(e=>{e._owner=this}),this._adaptiveCache=this.getAdaptiveVertices(),this._adaptiveCacheLen=this.curves.length),this._adaptiveCache}getFlatCurves(){return this.curves.flatMap(t=>t instanceof e?t.getFlatCurves():t)}addCurve(e){return this.curves.push(e),this}getPoint(e,t=new p){let n=e*this.getLength(),r=this.getLengths(),i=r.length;if(i===0)return t;let a=0,o=i-1;for(;a<o;){let e=a+o>>>1;r[e]<n?a=e+1:o=e}let s=r[a]-n,c=this.curves[a],l=c.getLength();return c.getPointAt(l===0?0:1-s/l,t)}getLengths(){return this._lengths.length!==this.curves.length&&this.updateLengths(),this._lengths}updateLengths(){let e=[];for(let t=0,n=0,r=this.curves.length;t<r;t++)this.curves[t]._owner=this,n+=this.curves[t].getLength(),e.push(n);this._lengths=e}getControlPointRefs(){return this.curves.flatMap(e=>e.getControlPointRefs())}_removeNextPointIfEqualPrevPoint(e,t){let n=[e[t-1],e[t]],r=[e[t+1],e[t+2]];return n[0]===r[0]&&n[1]===r[1]&&e.splice(t+1,2),e}getSpacedVertices(e=5,t=[]){let n;return this.curves.forEach(r=>{r.getSpacedVertices(e,t),n&&this._removeNextPointIfEqualPrevPoint(t,n),n=t.length-1}),t}getAdaptiveVertices(e=[]){let t;return this.curves.forEach(n=>{n.getAdaptiveVertices(e),t&&this._removeNextPointIfEqualPrevPoint(e,t),t=e.length-1}),e}isClosed(){return this.curves.length===1?this.curves[0].isClosed():super.isClosed()}strokeTriangulate(e){return this.curves.length===1?this.curves[0].strokeTriangulate(e):super.strokeTriangulate(e)}reverse(){return this.curves.reverse(),this.curves.forEach(e=>e.reverse()),this.invalidate(),this}getFillVertices(e){if(this.curves.length===1)return this.curves[0].getFillVertices(e);{let t=[],n;return this.curves.forEach(r=>{let i;i=r instanceof Q?r.getAdaptiveVertices():r.getFillVertices(e),t.push(...i),n&&this._removeNextPointIfEqualPrevPoint(t,n),n=t.length-1}),t}}applyTransform(e){return this._invalidating=!0,this.curves.forEach(t=>t.applyTransform(e)),this._invalidating=!1,this.invalidate(),this}getMinMax(e=p.MAX,t=p.MIN){return this.curves.forEach(n=>n.getMinMax(e,t)),{min:e.finite(),max:t.finite()}}getBoundingBox(){let{min:e,max:t}=this.getMinMax();return new m(e.x,e.y,t.x-e.x,t.y-e.y)}toCommands(){return this.curves.flatMap(e=>e.toCommands())}drawTo(e){let t=this.curves[0]?.getPoint(0);return t&&e.moveTo(t.x,t.y),this.curves.forEach(t=>t.drawTo(e)),this}copyFrom(e){return super.copyFrom(e),this.curves=e.curves.map(e=>e.clone()),this}},$t=class e extends Z{static from(t,n,r,i,a,o,s,c){return new e(new p(t,n),new p(r,i),new p(a,o),new p(s,c))}constructor(e=new p,t=new p,n=new p,r=new p){super(),this.p1=e,this.cp1=t,this.cp2=n,this.p2=r}getPoint(e,t=new p){let{p1:n,cp1:r,cp2:i,p2:a}=this;return t.set(F(e,n.x,r.x,i.x,a.x),F(e,n.y,r.y,i.y,a.y))}getAdaptiveVertices(e=[]){return Ae(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,e)}getControlPointRefs(){return[this.p1,this.cp1,this.cp2,this.p2]}reverse(){let{p1:e,cp1:t,cp2:n,p2:r}=this;return this.p1=r,this.cp1=n,this.cp2=t,this.p2=e,this.invalidate(),this}_solveQuadratic(e,t,n){if(Math.abs(e)<1e-12){if(Math.abs(t)<1e-12)return[];let e=-n/t;return e>=0&&e<=1?[e]:[]}let r=t*t-4*e*n;if(r<0)return[];let i=Math.sqrt(r);return[(-t+i)/(2*e),(-t-i)/(2*e)].filter(e=>e>=0&&e<=1)}getMinMax(e=p.MAX,t=p.MIN){let{p1:n,cp1:r,cp2:i,p2:a}=this,o=this._solveQuadratic(3*(-n.x+3*r.x-3*i.x+a.x),6*(n.x-2*r.x+i.x),3*(r.x-n.x)),s=this._solveQuadratic(3*(-n.y+3*r.y-3*i.y+a.y),6*(n.y-2*r.y+i.y),3*(r.y-n.y)),c=[0,1,...o,...s];for(let n of c){let r=this.getPoint(n);e.x=Math.min(e.x,r.x),e.y=Math.min(e.y,r.y),t.x=Math.max(t.x,r.x),t.y=Math.max(t.y,r.y)}return{min:e.finite(),max:t.finite()}}toCommands(){let{p1:e,cp1:t,cp2:n,p2:r}=this;return[{type:`M`,x:e.x,y:e.y},{type:`C`,x1:t.x,y1:t.y,x2:n.x,y2:n.y,x:r.x,y:r.y}]}drawTo(e){let{p1:t,cp1:n,cp2:r,p2:i}=this;return e.lineTo(t.x,t.y),e.bezierCurveTo(n.x,n.y,r.x,r.y,i.x,i.y),this}copyFrom(e){return super.copyFrom(e),this.p1.copyFrom(e.p1),this.cp1.copyFrom(e.cp1),this.cp2.copyFrom(e.cp2),this.p2.copyFrom(e.p2),this}},en=class extends Wt{constructor(e=0,t=0,n=1,r=1,i=0,a=0,o=Math.PI*2,s=!1){super(new p(e,t),new p(n,r),new p,i,a,o,s)}drawTo(e){return e.ellipse(this.cx,this.cy,this.rx,this.ry,this.rotate,this.startAngle,this.endAngle,!this.clockwise),this}},tn=class extends Qt{},nn=class extends tn{constructor(e=0,t=0,n=1,r=3){super(),this.cx=e,this.cy=t,this.radius=n,this.sideCount=r,this.update()}update(){let{cx:e,cy:t,radius:n,sideCount:r}=this,i=[];for(let a=0;a<r;a++){let o=a*2*Math.PI/r-.5*Math.PI;i.push(new p(n*Math.cos(o),n*Math.sin(o)).add({x:e,y:t}))}let a=[];for(let e=0;e<r;e++)a.push(new Q(i[e],i[(e+1)%r]));return this.curves=a,this}copyFrom(e){return super.copyFrom(e),this.cx=e.cx,this.cy=e.cy,this.radius=e.radius,this.sideCount=e.sideCount,this.update(),this}},rn=class e extends Z{static from(t,n,r,i,a,o){return new e(new p(t,n),new p(r,i),new p(a,o))}constructor(e=new p,t=new p,n=new p){super(),this.p1=e,this.cp=t,this.p2=n}getPoint(e,t=new p){let{p1:n,cp:r,p2:i}=this;return t.set(nt(e,n.x,r.x,i.x),nt(e,n.y,r.y,i.y)),t}getControlPointRefs(){return[this.p1,this.cp,this.p2]}reverse(){let{p1:e,p2:t}=this;return this.p1=t,this.p2=e,this.invalidate(),this}getAdaptiveVertices(e=[]){return Le(this.p1.x,this.p1.y,this.cp.x,this.cp.y,this.p2.x,this.p2.y,.5,e)}getMinMax(e=p.MAX,t=p.MIN){let{p1:n,cp:r,p2:i}=this,a=(e,t,n)=>{let r=e-2*t+n;if(Math.abs(r)<1e-12)return null;let i=(e-t)/r;return i>0&&i<1?i:null},o=a(n.x,r.x,i.x),s=a(n.y,r.y,i.y),c=[n.x,i.x],l=[n.y,i.y];return o!==null&&c.push(nt(o,n.x,r.x,i.x)),s!==null&&l.push(nt(s,n.y,r.y,i.y)),e.x=Math.min(e.x,...c),e.y=Math.min(e.y,...l),t.x=Math.max(t.x,...c),t.y=Math.max(t.y,...l),{min:e.finite(),max:t.finite()}}toCommands(){let{p1:e,cp:t,p2:n}=this;return[{type:`M`,x:e.x,y:e.y},{type:`Q`,x1:t.x,y1:t.y,x:n.x,y:n.y}]}drawTo(e){let{p1:t,cp:n,p2:r}=this;return e.lineTo(t.x,t.y),e.quadraticCurveTo(n.x,n.y,r.x,r.y),this}copyFrom(e){return super.copyFrom(e),this.p1.copyFrom(e.p1),this.cp.copyFrom(e.cp),this.p2.copyFrom(e.p2),this}},an=class extends tn{constructor(e=0,t=0,n=0,r=0){super(),this.x=e,this.y=t,this.width=n,this.height=r,this.update()}update(){let{x:e,y:t,width:n,height:r}=this,i=[new p(e,t),new p(e+n,t),new p(e+n,t+r),new p(e,t+r)];return this.curves=[new Q(i[0],i[1]),new Q(i[1],i[2]),new Q(i[2],i[3]),new Q(i[3],i[0])],this}drawTo(e){return e.rect(this.x,this.y,this.width,this.height),this}getFillVertices(e={}){let{x:t,y:n,width:r,height:i}=this;return[t,n,t+r,n,t+r,n+i,t,n+i]}copyFrom(e){return super.copyFrom(e),this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height,this.update(),this}},on=class extends Qt{constructor(e=0,t=0,n=1,r=1,i=1){super(),this.x=e,this.y=t,this.width=n,this.height=r,this.radius=i,this.update()}update(){let{x:e,y:t,width:n,height:r}=this,i=Math.max(0,Math.min(this.radius,Math.abs(n)/2,Math.abs(r)/2)),a=e,o=e+i,s=e+n-i,c=e+n,l=t,u=t+i,d=t+r-i,f=t+r;if(i<=0)this.curves=[Q.from(a,l,c,l),Q.from(c,l,c,f),Q.from(c,f,a,f),Q.from(a,f,a,l)];else{let e=Math.PI/2;this.curves=[Q.from(o,l,s,l),new Zt(s,u,i,-e,0,!0),Q.from(c,u,c,d),new Zt(s,d,i,0,e,!0),Q.from(s,f,o,f),new Zt(o,d,i,e,Math.PI,!0),Q.from(a,d,a,u),new Zt(o,u,i,Math.PI,Math.PI*1.5,!0)]}return this.invalidate(),this}drawTo(e){return e.roundRect(this.x,this.y,this.width,this.height,this.radius),this}copyFrom(e){return this.arcLengthDivision=e.arcLengthDivision,this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height,this.radius=e.radius,this.update(),this}},sn=class extends Z{constructor(e=[]){super(),this.points=e}getPoint(e,t=new p){let{points:n}=this,r=(n.length-1)*e,i=Math.floor(r),a=r-i,o=n[i===0?i:i-1],s=n[i],c=n[i>n.length-2?n.length-1:i+1],l=n[i>n.length-3?n.length-1:i+2];return t.set(b(a,o.x,s.x,c.x,l.x),b(a,o.y,s.y,c.y,l.y)),t}getControlPointRefs(){return this.points}reverse(){return this.points.reverse(),this.invalidate(),this}copyFrom(e){super.copyFrom(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++)this.points.push(e.points[t].clone());return this}},cn=class extends Qt{startPoint;currentPoint;autoClose=!1;constructor(e){super(),e&&this.addPoints(e)}addPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,n=e.length;t<n;t++){let{x:n,y:r}=e[t];this.lineTo(n,r)}return this}addCommands(e){return mt(e,this),this}addData(e){return this.addCommands(_t(e)),this}isClosed(){return this.autoClose||super.isClosed()}reverse(){return super.reverse(),this.curves.length&&(this.startPoint=this.getPoint(0),this.currentPoint=this.getPoint(1)),this}_closeVertices(e){return this.autoClose&&e.length>=4&&e[0]!==e[e.length-2]&&e[1]!==e[e.length-1]&&e.push(e[0],e[1]),e}getUnevenVertices(e=40,t=[]){return this._closeVertices(super.getUnevenVertices(e,t))}getSpacedVertices(e=40,t=[]){return this._closeVertices(super.getSpacedVertices(e,t))}getAdaptiveVertices(e=[]){return this._closeVertices(super.getAdaptiveVertices(e))}getFillVertices(e){return this._closeVertices(super.getFillVertices(e))}isPointInStroke(e,t={}){let{strokeWidth:n=1,tolerance:r=0}=t,i=this._getCachedAdaptiveVertices(),a=i.length;return Qe(e,i,t.closed??(this.autoClose||a>=6&&i[0]===i[a-2]&&i[1]===i[a-1]))<=n/2+r}_setCurrentPoint(e){return this.currentPoint=new p(e.x,e.y),this.startPoint||=this.currentPoint.clone(),this}_connetLineTo(e){if(this.curves.length>0){let t=e.getPoint(0);(!this.currentPoint||!t.equals(this.currentPoint))&&this.lineTo(t.x,t.y)}return this}closePath(){let e=this.startPoint;if(e){let t=this.currentPoint;t&&!e.equals(t)&&(this.curves.push(new Q(t.clone(),e.clone())),t.copyFrom(e)),this.startPoint=void 0}return this}moveTo(e,t){return this.currentPoint=new p(e,t),this.startPoint=this.currentPoint.clone(),this}lineTo(e,t){let n=this.currentPoint;return n?.equals({x:e,y:t})||this.curves.push(Q.from(n?.x??0,n?.y??0,e,t)),this._setCurrentPoint({x:e,y:t}),this}bezierCurveTo(e,t,n,r,i,a){let o=this.currentPoint;return o?.equals({x:i,y:a})||this.curves.push($t.from(o?.x??0,o?.y??0,e,t,n,r,i,a)),this._setCurrentPoint({x:i,y:a}),this}quadraticCurveTo(e,t,n,r){let i=this.currentPoint;return i?.equals({x:n,y:r})||this.curves.push(rn.from(i?.x??0,i?.y??0,e,t,n,r)),this._setCurrentPoint({x:n,y:r}),this}arc(e,t,n,r,i,a){let o=new Zt(e,t,n,r,i,!a);return this._connetLineTo(o),this.curves.push(o),this._setCurrentPoint(o.getPoint(1)),this}relativeArc(e,t,n,r,i,a){return e+=this.currentPoint?.x??0,t+=this.currentPoint?.y??0,this.arc(e,t,n,r,i,a),this}arcTo(e,t,n,r,i){return console.warn(`Method arcTo not supported yet`),this}ellipse(e,t,n,r,i,a,o,s=!0){let c=new en(e,t,n,r,i,a,o,!s);return this._connetLineTo(c),this.curves.push(c),this._setCurrentPoint(c.getPoint(1)),this}relativeEllipse(e,t,n,r,i,a,o,s){return e+=this.currentPoint?.x??0,t+=this.currentPoint?.y??0,this.ellipse(e,t,n,r,i,a,o,s),this}rect(e,t,n,r){let i=new an(e,t,n,r);return this._connetLineTo(i),this.curves.push(i),this._setCurrentPoint({x:e,y:t}),this}roundRect(e,t,n,r,i){let a=new on(e,t,n,r,i);return this._connetLineTo(a),this.curves.push(a),this._setCurrentPoint({x:e,y:t}),this}splineThru(e){let t=this.currentPoint??new p;return this.curves.push(new sn([t].concat(e))),this._setCurrentPoint(e[e.length-1]),this}drawTo(e){let t=this.curves[0]?.getPoint(0);return t&&e.moveTo(t.x,t.y),this.curves.forEach(t=>t.drawTo(e)),this.autoClose&&e.closePath(),this}copyFrom(e){return super.copyFrom(e),this.autoClose=e.autoClose,this.currentPoint=e.currentPoint?.clone(),this}},$=class e extends Qt{_meta;_ringsCache;_ringsCacheLen=-1;currentCurve=new cn;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,n={}){super(),this.curves.push(this.currentCurve),this.style=n,t&&(t instanceof e?this.addPath(t):Array.isArray(t)?this.addCommands(t):this.addData(t))}getMeta(){return this._meta}setMeta(e){return this._meta=e,this}addPath(t){let n=t instanceof e?t.curves:[t];if(n.filter(e=>e.curves.length).length===0)return this;if(!this.currentCurve.curves.length){let e=this.curves.findIndex(e=>e===this.currentCurve);e>-1&&this.curves.splice(e,1)}return this.curves.push(...n.map(e=>e.clone())),this.currentCurve=this.curves[this.curves.length-1],this}closePath(){let e=this.startPoint;return e&&this.currentCurve.curves.length&&(this.currentCurve.closePath(),this.currentCurve=new cn().moveTo(e.x,e.y),this.curves.push(this.currentCurve)),this}moveTo(e,t){return this.currentCurve.curves.length&&(this.currentCurve=new cn,this.curves.push(this.currentCurve)),this.currentCurve.moveTo(e,t),this}lineTo(e,t){return this.currentCurve.lineTo(e,t),this}bezierCurveTo(e,t,n,r,i,a){return this.currentCurve.bezierCurveTo(e,t,n,r,i,a),this}quadraticCurveTo(e,t,n,r){return this.currentCurve.quadraticCurveTo(e,t,n,r),this}arc(e,t,n,r,i,a){return this.currentCurve.arc(e,t,n,r,i,a),this}arcTo(e,t,n,r,i){return this.currentCurve.arcTo(e,t,n,r,i),this}ellipse(e,t,n,r,i,a,o,s){return this.currentCurve.ellipse(e,t,n,r,i,a,o,s),this}rect(e,t,n,r){return this.currentCurve.rect(e,t,n,r),this}roundRect(e,t,n,r,i){return this.currentCurve.roundRect(e,t,n,r,i),this}reset(){return this.currentCurve=new cn,this.curves=[this.currentCurve],this.style={},this}addCommands(e){return mt(e,this),this}addData(e){return this.addCommands(_t(e)),this}splineThru(e){return this.currentCurve.splineThru(e),this}scale(e,t=e,n={x:0,y:0}){return this.getControlPointRefs().forEach(r=>{r.scale(e,t,n)}),this.invalidate(),this}skew(e,t=0,n={x:0,y:0}){return this.getControlPointRefs().forEach(r=>{r.skew(e,t,n)}),this.invalidate(),this}rotate(e,t={x:0,y:0}){return this.getControlPointRefs().forEach(n=>{n.rotate(e,t)}),this.invalidate(),this}bold(e){if(e===0)return this;let t=this.getFlatCurves(),n=[],r=[],i=[];t.forEach((e,t)=>{let a=e.getControlPointRefs(),o=e.isClockwise();i[t]=a,r[t]=o;let s=a[0],c=a[a.length-1]??s;n.push({start:o?c:s,end:o?s:c,index:t})});let a=[];return n.forEach((e,t)=>{a[t]=[],n.forEach((n,r)=>{n.start&&e.end&&r!==t&&n.start?.equals(e.end)&&a[t].push(n.index)})}),t.forEach((t,n)=>{let a=r[n];i[n].forEach(n=>{n.add(t.getNormal(t.getTForPoint(n)).scale(a?e:-e))})}),a.forEach((e,t)=>{let n=i[t];e.forEach(e=>{let t=i[e],r=w(n[n.length-1],n[n.length-2]??n[n.length-1],t[0],t[1]??t[0]);r&&(n[n.length-1].copyFrom(r),t[0].copyFrom(r))})}),this.invalidate(),this}_invalidateSelf(){super._invalidateSelf(),this._ringsCache=void 0,this._ringsCacheLen=-1}_getRings(){return(!this._ringsCache||this._ringsCacheLen!==this.curves.length)&&(this._ringsCache=this.curves.map(e=>(e._owner=this,e.getAdaptiveVertices())),this._ringsCacheLen=this.curves.length),this._ringsCache}isPointInFill(e,t={}){let n=t.fillRule??this.style.fillRule??`nonzero`;return Xe(e,this._getRings(),n)}static fromRings(t,n={}){let r=new e(void 0,n);for(let e of t){if(e.length<6)continue;let t=e.length;e[0]===e[t-2]&&e[1]===e[t-1]&&(t-=2),r.moveTo(e[0],e[1]);for(let n=2;n<t;n+=2)r.lineTo(e[n],e[n+1]);r.closePath()}return r}booleanOp(t,n,r){let i=y(t,this._getRings(),n._getRings());return e.fromRings(i,{...this.style,...r})}union(e,t){return this.booleanOp(`union`,e,t)}intersection(e,t){return this.booleanOp(`intersection`,e,t)}difference(e,t){return this.booleanOp(`difference`,e,t)}xor(e,t){return this.booleanOp(`xor`,e,t)}isPointInStroke(e,t={}){let n=t.strokeWidth??this.strokeWidth,{tolerance:r=0,closed:i}=t;return this.curves.some(t=>t.isPointInStroke(e,{strokeWidth:n,tolerance:r,closed:i}))}getMinMax(e=p.MAX,t=p.MIN,n=!0){if(this.curves.forEach(n=>{n.getMinMax(e,t)}),n){let n=this.strokeWidth;if(n>1&&Number.isFinite(e.x)){let r=n/2;e.set(e.x-r,e.y-r),t.set(t.x+r,t.y+r)}}return{min:e.finite(),max:t.finite()}}strokeTriangulate(e){let t=e?.indices??[],n=e?.vertices??[];return this.curves.forEach(r=>{r.strokeTriangulate({...e,indices:t,vertices:n,style:{...this.style}})}),{indices:t,vertices:n}}fillTriangulate(e){let t={...e,style:{...this.style,...e?.style}},n=t.indices??[],r=t.vertices??[];if((t.style.fillRule??`nonzero`)===`nonzero`){let i=this.curves.map(e=>e.getFillVertices(t)),a=We(i),o=a.length;for(let t=0;t<o;t++){let s=a[t],c=i[t];if(s.winding||!c.length)continue;let l=c.slice(),u=[];for(let e=0;e<o;e++){let n=a[e];n.parentIndex===t&&(u.push(l.length/2),l.push(...i[n.index]))}we(l,{...e,indices:n,vertices:r,holes:u,style:{...this.style}})}}else this.curves.forEach(t=>{t.fillTriangulate({...e,indices:n,vertices:r,style:{...this.style}})});return{indices:n,vertices:r}}getBoundingBox(e=!0){let{min:t,max:n}=this.getMinMax(void 0,void 0,e);return new m(t.x,t.y,n.x-t.x,n.y-t.y)}drawTo(e,t={}){t={...this.style,...t};let{fill:n=`#000`,stroke:r=`none`,fillRule:i=`nonzero`}=t;return e.beginPath(),e.save(),f(e,t),this.curves.forEach(t=>{t.drawTo(e)}),n!==`none`&&e.fill(i),r!==`none`&&e.stroke(),e.restore(),this}drawControlPointsTo(e,t={}){t={...this.style,...t};let{fill:n=`#000`,stroke:r=`none`}=t;return e.beginPath(),e.save(),f(e,t),this.getControlPointRefs().forEach(t=>{u(e,t.x,t.y,{radius:4})}),n!==`none`&&e.fill(),r!==`none`&&e.stroke(),e.restore(),this}toCommands(){return this.curves.flatMap(e=>e.toCommands())}toData(){return this.curves.filter(e=>e.curves.length).map(e=>e.toData()).join(` `)}toSvgPathString(){let e={...this.style,fill:this.style.fill??`#000`,stroke:this.style.stroke??`none`},t={};for(let n in e)e[n]!==void 0&&(t[C(n)]=e[n]);Object.assign(t,{"stroke-width":`${this.strokeWidth}px`});let n=``;for(let e in t)t[e]!==void 0&&(n+=`${e}:${t[e]};`);return`<path d="${this.toData()}" style="${n}"></path>`}copyFrom(e){return super.copyFrom(e),this.currentCurve=e.currentCurve.clone(),this.style={...e.style},this}},ln=class{constructor(e=[],t){this.paths=e,this.viewBox=t}isPointInFill(e,t={}){return this.paths.some(n=>n.isPointInFill(e,t))}contains(e,t,n={}){return this.isPointInFill({x:e,y:t},n)}hitTest(e,t={}){let{stroke:n=!0,tolerance:r,fillRule:i}=t;for(let t=this.paths.length-1;t>=0;t--){let a=this.paths[t];if((a.style.fill??`#000`)!==`none`&&a.isPointInFill(e,{fillRule:i})||n&&(a.style.stroke??`none`)!==`none`&&a.isPointInStroke(e,{tolerance:r}))return a}}getBoundingBox(e=!0){if(!this.paths.length)return;let t=p.MAX,n=p.MIN;return this.paths.forEach(r=>r.getMinMax(t,n,e)),new m(t.x,t.y,n.x-t.x,n.y-t.y)}toTriangulatedSvgString(e=this.paths.map(e=>e.fillTriangulate()),t=0){let n=``,r=``,i={x:-t,y:-t},a={x:t,y:t};(Array.isArray(e)?e:[e]).forEach(({vertices:e,indices:o,points:s=[]})=>{let c=n=>{let r=e[n*2],o=e[n*2+1];return i.x=Math.min(i.x,r+t),a.x=Math.max(a.x,r+t),i.y=Math.min(i.y,o+t),a.y=Math.max(a.y,o+t),[r,o]};for(let e=0,t=o.length;e<t;e+=3){let t=c(o[e]),r=c(o[e+1]),i=c(o[e+2]);n+=`<polygon
|
|
2
3
|
points="${t.join(`,`)} ${r.join(`,`)} ${i.join(`,`)}"
|
|
3
4
|
stroke="#28a745"
|
|
4
5
|
stroke-width="#stroke-width"
|
|
@@ -25,4 +26,4 @@
|
|
|
25
26
|
xmlns="http://www.w3.org/2000/svg"
|
|
26
27
|
>
|
|
27
28
|
${this.paths.map(e=>e.toSvgPathString()).join(``)}
|
|
28
|
-
</svg>`}toSvgUrl(){return`data:image/svg+xml;base64,${btoa(this.toSvgString())}`}toSvg(){return new DOMParser().parseFromString(this.toSvgString(),`image/svg+xml`).documentElement}toCanvas(e={}){let{pixelRatio:t=2,...n}=e,{left:r,top:i,width:a,height:o}=this.getBoundingBox(),s=document.createElement(`canvas`);s.width=a*t,s.height=o*t,s.style.width=`${a}px`,s.style.height=`${o}px`;let c=s.getContext(`2d`);return c&&(c.scale(t,t),c.translate(-r,-i),this.paths.forEach(e=>{e.drawTo(c,n)})),s}},
|
|
29
|
+
</svg>`}toSvgUrl(){return`data:image/svg+xml;base64,${btoa(this.toSvgString())}`}toSvg(){return new DOMParser().parseFromString(this.toSvgString(),`image/svg+xml`).documentElement}toCanvas(e={}){let{pixelRatio:t=2,...n}=e,{left:r,top:i,width:a,height:o}=this.getBoundingBox(),s=document.createElement(`canvas`);s.width=a*t,s.height=o*t,s.style.width=`${a}px`,s.style.height=`${o}px`;let c=s.getContext(`2d`);return c&&(c.scale(t,t),c.translate(-r,-i),this.paths.forEach(e=>{e.drawTo(c,n)})),s}},un=class{constructor(e){this.curve=e}getLength(){return this.curve.getLength()}isClosed(){return this.curve.isClosed()}getPosTan(e){return this.curve.getPosTan(e)}getPosition(e){return this.curve.getPosTan(e).position}getPosTanAtProgress(e){return this.curve.getPosTan(this.getLength()*e)}sample(e=100){let t=this.getLength(),n=[];for(let r=0;r<=e;r++)n.push(this.curve.getPosTan(t*r/e));return n}},dn=class{controlPoints=[];constructor(e,t,n=1,r=1){this.rows=e,this.cols=t,this.width=n,this.height=r;for(let i=0;i<e;i++){this.controlPoints[i]=[];for(let a=0;a<t;a++)this.controlPoints[i][a]={x:a/(t-1)*n,y:i/(e-1)*r}}}moveControlPoint(e,t,n,r){return this.controlPoints[e][t].x+=n,this.controlPoints[e][t].y+=r,this}};function fn(e){let t=[];return t[0]=(1-e)**3/6,t[1]=(3*e**3-6*e**2+4)/6,t[2]=(-3*e**3+3*e**2+3*e+1)/6,t[3]=e**3/6,t}function pn(e,t,n=t.width,r=t.height){let i=e.x/n*(t.cols-1),a=e.y/r*(t.rows-1),o=Math.floor(i),s=Math.floor(a),c=i-o,l=a-s,u=fn(c),d=fn(l),f=0,p=0;for(let e=0;e<4;e++)for(let n=0;n<4;n++){let r=Math.min(Math.max(s-1+e,0),t.rows-1),i=Math.min(Math.max(o-1+n,0),t.cols-1),a=t.controlPoints[r][i],c=u[n]*d[e];f+=a.x*c,p+=a.y*c}e.set(f,p)}e.ArcCurve=Zt,e.BoundingBox=m,e.CompositeCurve=Qt,e.CubicBezierCurve=$t,e.Curve=Z,e.CurvePath=cn,e.EllipseCurve=en,e.EquilateralPolygonCurve=nn,e.FFDControlGrid=dn,e.LineCurve=Q,e.PI=x,e.PI_2=S,e.Path2D=$,e.Path2DSet=ln,e.PathMeasure=un,e.PolygonCurve=tn,e.QuadraticBezierCurve=rn,e.RectangleCurve=an,e.RoundRectangleCurve=on,e.SplineCurve=sn,e.Transform2D=ut,e.Vector2=p,e.applyFFD=pn,e.catmullRom=b,e.cubicBezier=F,e.drawPoint=u,e.fillTriangulate=we,e.getAdaptiveCubicBezierCurvePoints=Ae,e.getAdaptiveQuadraticBezierCurvePoints=Le,e.getDirectedArea=ze,e.getIntersectionPoint=w,e.nonzeroFillRule=We,e.parseArcCommand=ft,e.parseCssArg=A,e.parseCssArgs=k,e.parseCssFunctions=O,e.parsePathDataArgs=J,e.pointInPolygon=Ye,e.pointInPolygons=Xe,e.pointToPolylineDistance=Qe,e.pointToSegmentDistance=Ze,e.polygonBoolean=y,e.quadraticBezier=nt,e.resolveLineStyle=it,e.setCanvasContext=f,e.strokeTriangulate=st,e.svgPathCommandsAddToPath2D=mt,e.svgPathCommandsToData=ht,e.svgPathDataToCommands=_t,e.svgToDom=xt,e.svgToPath2DSet=zt,e.toKebabCase=C});
|