(function(){var t=function(){"use strict";function t(){return{LEFT:0,RIGHT:1,INTERSECTS:2,AHEAD:3,BEHIND:4,SEPARATE:5,UNDEFINED:6}}var e=Math.tan,s=Math.pow,i=Math.cos,h=Math.sin,a=Math.PI,n=Math.sqrt,l=Math.max,r=Math.min,o=Math.abs,c=Number.MAX_VALUE;class p{constructor(e,s,i,h){this.RoughSegmentRelationConst=t(),this.px1=e,this.py1=s,this.px2=i,this.py2=h,this.xi=c,this.yi=c,this.a=h-s,this.b=e-i,this.c=i*s-e*h,this._undefined=0==this.a&&0==this.b&&0==this.c}isUndefined(){return this._undefined}compare(t){if(this.isUndefined()||t.isUndefined())return this.RoughSegmentRelationConst.UNDEFINED;var e=c,s=c,i=0,h=0,a=this.a,n=this.b,p=this.c;return 1e-5=r(t.py1,t.py2)&&this.py1<=l(t.py1,t.py2)?(this.xi=this.px1,this.yi=this.py1,this.RoughSegmentRelationConst.INTERSECTS):this.py2>=r(t.py1,t.py2)&&this.py2<=l(t.py1,t.py2)?(this.xi=this.px2,this.yi=this.py2,this.RoughSegmentRelationConst.INTERSECTS):this.RoughSegmentRelationConst.SEPARATE:this.RoughSegmentRelationConst.SEPARATE:(this.xi=this.px1,this.yi=s*this.xi+h,-1e-5>(this.py1-this.yi)*(this.yi-this.py2)||-1e-5>(t.py1-this.yi)*(this.yi-t.py2)?this.RoughSegmentRelationConst.SEPARATE:1e-5>o(t.a)&&-1e-5>(t.px1-this.xi)*(this.xi-t.px2)?this.RoughSegmentRelationConst.SEPARATE:this.RoughSegmentRelationConst.INTERSECTS):s==c?(this.xi=t.px1,this.yi=e*this.xi+i,-1e-5>(t.py1-this.yi)*(this.yi-t.py2)||-1e-5>(this.py1-this.yi)*(this.yi-this.py2)?this.RoughSegmentRelationConst.SEPARATE:1e-5>o(a)&&-1e-5>(this.px1-this.xi)*(this.xi-this.px2)?this.RoughSegmentRelationConst.SEPARATE:this.RoughSegmentRelationConst.INTERSECTS):e==s?i==h?this.px1>=r(t.px1,t.px2)&&this.px1<=l(t.py1,t.py2)?(this.xi=this.px1,this.yi=this.py1,this.RoughSegmentRelationConst.INTERSECTS):this.px2>=r(t.px1,t.px2)&&this.px2<=l(t.px1,t.px2)?(this.xi=this.px2,this.yi=this.py2,this.RoughSegmentRelationConst.INTERSECTS):this.RoughSegmentRelationConst.SEPARATE:this.RoughSegmentRelationConst.SEPARATE:(this.xi=(h-i)/(e-s),this.yi=e*this.xi+i,-1e-5>(this.px1-this.xi)*(this.xi-this.px2)||-1e-5>(t.px1-this.xi)*(this.xi-t.px2)?this.RoughSegmentRelationConst.SEPARATE:this.RoughSegmentRelationConst.INTERSECTS)}getLength(){return this._getLength(this.px1,this.py1,this.px2,this.py2)}_getLength(t,e,s,i){var h=s-t,a=i-e;return n(h*h+a*a)}}class f{constructor(t,e,s,i,h,a,n,l){this.top=t,this.bottom=e,this.left=s,this.right=i,this.gap=h,this.sinAngle=a,this.tanAngle=l,1e-4>o(a)?this.pos=s+h:.9999o(this.sinAngle)){if(this.posthis.right&&s>this.right;)if(this.pos+=this.hGap,e=this.pos-this.deltaX/2,s=this.pos+this.deltaX/2,this.pos>this.right+this.deltaX)return null;let a=new p(e,i,s,h);a.compare(this.sLeft)==t().INTERSECTS&&(e=a.xi,i=a.yi),a.compare(this.sRight)==t().INTERSECTS&&(s=a.xi,h=a.yi),0d){let t=n(1-d/(this._rx*this._rx*this._ry*this._ry));this._rx=t,this._ry=t,f=0}else f=(r==c?-1:1)*n(d/(this._rx*this._rx*g*g+this._ry*this._ry*u*u));let _=f*this._rx*g/this._ry,y=-f*this._ry*u/this._rx;this._C=[0,0],this._C[0]=this._cosPhi*_-this._sinPhi*y+(t[0]+e[0])/2,this._C[1]=this._sinPhi*_+this._cosPhi*y+(t[1]+e[1])/2,this._theta=this.calculateVectorAngle(1,0,(u-_)/this._rx,(g-y)/this._ry);let x=this.calculateVectorAngle((u-_)/this._rx,(g-y)/this._ry,(-u-_)/this._rx,(-g-y)/this._ry);!c&&0x&&(x+=2*a),this._numSegs=Math.ceil(o(x/(a/2))),this._delta=x/this._numSegs,this._T=8/3*h(this._delta/4)*h(this._delta/4)/h(this._delta/2),this._from=t}getNextSegment(){var t,e,s;if(this._segIndex==this._numSegs)return null;let a=i(this._theta),n=h(this._theta),l=this._theta+this._delta,r=i(l),o=h(l);return s=[this._cosPhi*this._rx*r-this._sinPhi*this._ry*o+this._C[0],this._sinPhi*this._rx*r+this._cosPhi*this._ry*o+this._C[1]],t=[this._from[0]+this._T*(-this._cosPhi*this._rx*n-this._sinPhi*this._ry*a),this._from[1]+this._T*(-this._sinPhi*this._rx*n+this._cosPhi*this._ry*a)],e=[s[0]+this._T*(this._cosPhi*this._rx*o+this._sinPhi*this._ry*r),s[1]+this._T*(this._sinPhi*this._rx*o-this._cosPhi*this._ry*r)],this._theta=l,this._from=[s[0],s[1]],this._segIndex++,{cp1:t,cp2:e,to:s}}calculateVectorAngle(t,e,s,i){var h=Math.atan2;let n=h(e,t),l=h(i,s);return l>=n?l-n:2*a-(n-l)}}class y{constructor(t,e){this.sets=t,this.closed=e}fit(t){let e=[];for(const s of this.sets){let i=s.length,h=Math.floor(t*i);if(5>h){if(5>=i)continue;h=5}e.push(this.reduce(s,h))}let s="";for(const t of e){for(let e,i=0;ie;){let t=-1,e=-1;for(let i=1;it||ox;)x+=2*a,b+=2*a;b-x>2*a&&(x=0,b=2*a);let m=2*a/u.curveStepCount,w=r(m/2,(b-x)/2),O=this._arc(w,g,d,_,y,x,b,1,u),S=this._arc(w,g,d,_,y,x,b,1.5,u),v=O.concat(S);return p&&(f?(v=v.concat(this._doubleLine(g,d,g+_*i(x),d+y*h(x),u)),v=v.concat(this._doubleLine(g,d,g+_*i(b),d+y*h(b),u))):(v.push({op:"lineTo",data:[g,d]}),v.push({op:"lineTo",data:[g+_*i(x),d+y*h(x)]}))),{type:"path",ops:v}}hachureFillArc(t,e,s,n,l,r,c){let p=t,f=e,u=o(s/2),g=o(n/2);u+=this._getOffset(.01*-u,.01*u,c),g+=this._getOffset(.01*-g,.01*g,c);let d=l,_=r;for(;0>d;)d+=2*a,_+=2*a;_-d>2*a&&(d=0,_=2*a);let y=(_-d)/c.curveStepCount,x=[],b=[];for(let t=d;t<=_;t+=y)x.push(p+u*i(t)),b.push(f+g*h(t));return x.push(p+u*i(_)),b.push(f+g*h(_)),x.push(p),b.push(f),this.hachureFillShape(x,b,c)}solidFillShape(t,e,s){let i=[];if(t&&e&&t.length&&e.length&&t.length===e.length){let a=s.maxRandomnessOffset||0;const n=t.length;if(2_&&(_=4*n.strokeWidth),_=l(_,.1);const y=d%180*(a/180),x=i(y),b=h(y),m=e(y),w=new f(u-1,g+1,c-1,p+1,_,b,x,m);for(let e;null!=(e=w.getNextLine());){let i=this._getIntersectingLines(e,t,s);for(let t=0;t=u&&(u=4*l.strokeWidth);let g=l.fillWeight;0>g&&(g=l.strokeWidth/2);let d=e(f%180*(a/180)),_=p/c,y=n(_*d*_*d+1),x=_*d/y,b=1/y,m=u/(c*p/n(p*b*(p*b)+c*x*(c*x))/c),w=n(c*c-(t-c+m)*(t-c+m));for(var O=t-c+m;Op;p++)0===p?r.push({op:"move",data:[n.x,n.y]}):r.push({op:"move",data:[n.x+this._getOffset(-o[0],o[0],l),n.y+this._getOffset(-o[0],o[0],l)]}),c=[h+this._getOffset(-o[p],o[p],l),a+this._getOffset(-o[p],o[p],l)],r.push({op:"bcurveTo",data:[t+this._getOffset(-o[p],o[p],l),e+this._getOffset(-o[p],o[p],l),s+this._getOffset(-o[p],o[p],l),i+this._getOffset(-o[p],o[p],l),c[0],c[1]]});return n.setPosition(c[0],c[1]),r}_processSegment(t,e,s,i){let h=[];switch(e.key){case"M":case"m":{let s="m"===e.key;if(2<=e.data.length){let a=+e.data[0],n=+e.data[1];s&&(a+=t.x,n+=t.y);let l=1*(i.maxRandomnessOffset||0);a+=this._getOffset(-l,l,i),n+=this._getOffset(-l,l,i),t.setPosition(a,n),h.push({op:"move",data:[a,n]})}break}case"L":case"l":{let s="l"===e.key;if(2<=e.data.length){let a=+e.data[0],n=+e.data[1];s&&(a+=t.x,n+=t.y),h=h.concat(this._doubleLine(t.x,t.y,a,n,i)),t.setPosition(a,n)}break}case"H":case"h":{const s="h"===e.key;if(e.data.length){let a=+e.data[0];s&&(a+=t.x),h=h.concat(this._doubleLine(t.x,t.y,a,t.y,i)),t.setPosition(a,t.y)}break}case"V":case"v":{const s="v"===e.key;if(e.data.length){let a=+e.data[0];s&&(a+=t.y),h=h.concat(this._doubleLine(t.x,t.y,t.x,a,i)),t.setPosition(t.x,a)}break}case"Z":case"z":t.first&&(h=h.concat(this._doubleLine(t.x,t.y,t.first[0],t.first[1],i)),t.setPosition(t.first[0],t.first[1]),t.first=null);break;case"C":case"c":{const s="c"===e.key;if(6<=e.data.length){let a=+e.data[0],n=+e.data[1],l=+e.data[2],r=+e.data[3],o=+e.data[4],c=+e.data[5];s&&(a+=t.x,l+=t.x,o+=t.x,n+=t.y,r+=t.y,c+=t.y);let p=this._bezierTo(a,n,l,r,o,c,t,i);h=h.concat(p),t.bezierReflectionPoint=[o+(o-l),c+(c-r)]}break}case"S":case"s":{const n="s"===e.key;if(4<=e.data.length){let l=+e.data[0],r=+e.data[1],o=+e.data[2],c=+e.data[3];n&&(l+=t.x,o+=t.x,r+=t.y,c+=t.y);let p=l,f=r,u=s?s.key:"";var a=null;("c"==u||"C"==u||"s"==u||"S"==u)&&(a=t.bezierReflectionPoint),a&&(p=a[0],f=a[1]);let g=this._bezierTo(p,f,l,r,o,c,t,i);h=h.concat(g),t.bezierReflectionPoint=[o+(o-l),c+(c-r)]}break}case"Q":case"q":{const s="q"===e.key;if(4<=e.data.length){let a=+e.data[0],n=+e.data[1],l=+e.data[2],r=+e.data[3];s&&(a+=t.x,l+=t.x,n+=t.y,r+=t.y);let o=1*(1+.2*i.roughness),c=1.5*(1+.22*i.roughness);h.push({op:"move",data:[t.x+this._getOffset(-o,o,i),t.y+this._getOffset(-o,o,i)]});let p=[l+this._getOffset(-o,o,i),r+this._getOffset(-o,o,i)];h.push({op:"qcurveTo",data:[a+this._getOffset(-o,o,i),n+this._getOffset(-o,o,i),p[0],p[1]]}),h.push({op:"move",data:[t.x+this._getOffset(-c,c,i),t.y+this._getOffset(-c,c,i)]}),p=[l+this._getOffset(-c,c,i),r+this._getOffset(-c,c,i)],h.push({op:"qcurveTo",data:[a+this._getOffset(-c,c,i),n+this._getOffset(-c,c,i),p[0],p[1]]}),t.setPosition(p[0],p[1]),t.quadReflectionPoint=[l+(l-a),r+(r-n)]}break}case"T":case"t":{const n="t"===e.key;if(2<=e.data.length){let l=+e.data[0],r=+e.data[1];n&&(l+=t.x,r+=t.y);let o=l,c=r,p=s?s.key:"";a=null;("q"==p||"Q"==p||"t"==p||"T"==p)&&(a=t.quadReflectionPoint),a&&(o=a[0],c=a[1]);let f=1*(1+.2*i.roughness),u=1.5*(1+.22*i.roughness);h.push({op:"move",data:[t.x+this._getOffset(-f,f,i),t.y+this._getOffset(-f,f,i)]});let g=[l+this._getOffset(-f,f,i),r+this._getOffset(-f,f,i)];h.push({op:"qcurveTo",data:[o+this._getOffset(-f,f,i),c+this._getOffset(-f,f,i),g[0],g[1]]}),h.push({op:"move",data:[t.x+this._getOffset(-u,u,i),t.y+this._getOffset(-u,u,i)]}),g=[l+this._getOffset(-u,u,i),r+this._getOffset(-u,u,i)],h.push({op:"qcurveTo",data:[o+this._getOffset(-u,u,i),c+this._getOffset(-u,u,i),g[0],g[1]]}),t.setPosition(g[0],g[1]),t.quadReflectionPoint=[l+(l-o),r+(r-c)]}break}case"A":case"a":{const s="a"===e.key;if(7<=e.data.length){let a=+e.data[0],n=+e.data[1],l=+e.data[2],r=+e.data[3],o=+e.data[4],c=+e.data[5],p=+e.data[6];if(s&&(c+=t.x,p+=t.y),c==t.x&&p==t.y)break;if(0==a||0==n)h=h.concat(this._doubleLine(t.x,t.y,c,p,i)),t.setPosition(c,p);else{i.maxRandomnessOffset;for(let e=0;1>e;e++){let e=new _([t.x,t.y],[c,p],[a,n],l,!!r,!!o),s=e.getNextSegment();for(;s;){let a=this._bezierTo(s.cp1[0],s.cp1[1],s.cp2[0],s.cp2[1],s.to[0],s.to[1],t,i);h=h.concat(a),s=e.getNextSegment()}}}}break}}return h}_getOffset(t,e,s){return s.roughness*(Math.random()*(e-t)+t)}_affine(t,e,s,i,h,a,n){return[-s*a-i*h+s+a*t+h*e,n*(s*h-i*a)+i+-n*h*t+n*a*e]}_doubleLine(t,e,s,i,h){const a=this._line(t,e,s,i,h,!0,!1),n=this._line(t,e,s,i,h,!0,!0);return a.concat(n)}_line(t,e,i,h,a,l,r){const o=s(t-i,2)+s(e-h,2);let c=a.maxRandomnessOffset||0;c*c*100>o&&(c=n(o)/10);const p=c/2,f=.2+.2*Math.random();let u=a.bowing*a.maxRandomnessOffset*(h-e)/200,g=a.bowing*a.maxRandomnessOffset*(t-i)/200;u=this._getOffset(-u,u,a),g=this._getOffset(-g,g,a);let d=[];return l&&(r?d.push({op:"move",data:[t+this._getOffset(-p,p,a),e+this._getOffset(-p,p,a)]}):d.push({op:"move",data:[t+this._getOffset(-c,c,a),e+this._getOffset(-c,c,a)]})),r?d.push({op:"bcurveTo",data:[u+t+(i-t)*f+this._getOffset(-p,p,a),g+e+(h-e)*f+this._getOffset(-p,p,a),u+t+2*(i-t)*f+this._getOffset(-p,p,a),g+e+2*(h-e)*f+this._getOffset(-p,p,a),i+this._getOffset(-p,p,a),h+this._getOffset(-p,p,a)]}):d.push({op:"bcurveTo",data:[u+t+(i-t)*f+this._getOffset(-c,c,a),g+e+(h-e)*f+this._getOffset(-c,c,a),u+t+2*(i-t)*f+this._getOffset(-c,c,a),g+e+2*(h-e)*f+this._getOffset(-c,c,a),i+this._getOffset(-c,c,a),h+this._getOffset(-c,c,a)]}),d}_curve(t,e,s){const i=t.length;let h=[];if(3i&&(i=s.strokeWidth/2),t.save(),t.strokeStyle=s.fill,t.lineWidth=i,this._drawToContext(t,e),t.restore()}_drawToContext(t,e){t.beginPath();for(let s of e.ops){const e=s.data;switch(s.op){case"move":t.moveTo(e[0],e[1]);break;case"bcurveTo":t.bezierCurveTo(e[0],e[1],e[2],e[3],e[4],e[5]);break;case"qcurveTo":t.quadraticCurveTo(e[0],e[1],e[2],e[3]);break;case"lineTo":t.lineTo(e[0],e[1])}}"fillPath"===e.type?t.fill():t.stroke()}}class O extends w{_init(t){this.gen=new m(t,this.canvas)}async line(t,e,s,i,h){let a=await this.gen.line(t,e,s,i,h);return this.draw(a),a}async rectangle(t,e,s,i,h){let a=await this.gen.rectangle(t,e,s,i,h);return this.draw(a),a}async ellipse(t,e,s,i,h){let a=await this.gen.ellipse(t,e,s,i,h);return this.draw(a),a}async circle(t,e,s,i){let h=await this.gen.circle(t,e,s,i);return this.draw(h),h}async linearPath(t,e){let s=await this.gen.linearPath(t,e);return this.draw(s),s}async polygon(t,e){let s=await this.gen.polygon(t,e);return this.draw(s),s}async arc(t,e,s,i,h,a,n,l){let r=await this.gen.arc(t,e,s,i,h,a,n,l);return this.draw(r),r}async curve(t,e){let s=await this.gen.curve(t,e);return this.draw(s),s}async path(t,e){let s=await this.gen.path(t,e);return this.draw(s),s}}var S={canvas:(t,e)=>e&&e.async?new O(t,e):new w(t,e),createRenderer:()=>w.createRenderer(),generator:(t,e)=>t&&t.async?new m(t,e):new b(t,e)};return S}(),e=function(t){for(var e=arguments.length,s=Array(e>1?e-1:0),i=1;i