/* esm.sh - roughjs@4.6.4/bin/rough */
import{hachureLines as st}from"../../../hachure-fill@^0.5.2?target=es2022";function S(r,e){var s;let t=e.hachureAngle+90,n=e.hachureGap;n<0&&(n=e.strokeWidth*4),n=Math.max(n,.1);let i=1;return e.roughness>=1&&(((s=e.randomizer)===null||s===void 0?void 0:s.next())||Math.random())>.7&&(i=n),st(r,n,t,i||1)}var L=class{constructor(e){this.helper=e}fillPolygons(e,s){return this._fillPolygons(e,s)}_fillPolygons(e,s){let t=S(e,s);return{type:"fillSketch",ops:this.renderLines(t,s)}}renderLines(e,s){let t=[];for(let n of e)t.push(...this.helper.doubleLineOps(n[0][0],n[0][1],n[1][0],n[1][1],s));return t}};function _(r){let e=r[0],s=r[1];return Math.sqrt(Math.pow(e[0]-s[0],2)+Math.pow(e[1]-s[1],2))}var A=class extends L{fillPolygons(e,s){let t=s.hachureGap;t<0&&(t=s.strokeWidth*4),t=Math.max(t,.1);let n=Object.assign({},s,{hachureGap:t}),i=S(e,n),o=Math.PI/180*s.hachureAngle,a=[],h=t*.5*Math.cos(o),l=t*.5*Math.sin(o);for(let[u,f]of i)_([u,f])&&a.push([[u[0]-h,u[1]+l],[...f]],[[u[0]+h,u[1]-l],[...f]]);return{type:"fillSketch",ops:this.renderLines(a,s)}}};var W=class extends L{fillPolygons(e,s){let t=this._fillPolygons(e,s),n=Object.assign({},s,{hachureAngle:s.hachureAngle+90}),i=this._fillPolygons(e,n);return t.ops=t.ops.concat(i.ops),t}};var y=class{constructor(e){this.helper=e}fillPolygons(e,s){s=Object.assign({},s,{hachureAngle:0});let t=S(e,s);return this.dotsOnLines(t,s)}dotsOnLines(e,s){let t=[],n=s.hachureGap;n<0&&(n=s.strokeWidth*4),n=Math.max(n,.1);let i=s.fillWeight;i<0&&(i=s.strokeWidth/2);let o=n/4;for(let a of e){let h=_(a),l=h/n,c=Math.ceil(l)-1,u=h-c*n,f=(a[0][0]+a[1][0])/2-n/4,p=Math.min(a[0][1],a[1][1]);for(let g=0;g<c;g++){let m=p+u+g*n,k=f-o+Math.random()*2*o,M=m-o+Math.random()*2*o,O=this.helper.ellipse(k,M,i,i,s);t.push(...O.ops)}}return{type:"fillSketch",ops:t}}};var G=class{constructor(e){this.helper=e}fillPolygons(e,s){let t=S(e,s);return{type:"fillSketch",ops:this.dashedLine(t,s)}}dashedLine(e,s){let t=s.dashOffset<0?s.hachureGap<0?s.strokeWidth*4:s.hachureGap:s.dashOffset,n=s.dashGap<0?s.hachureGap<0?s.strokeWidth*4:s.hachureGap:s.dashGap,i=[];return e.forEach(o=>{let a=_(o),h=Math.floor(a/(t+n)),l=(a+n-h*(t+n))/2,c=o[0],u=o[1];c[0]>u[0]&&(c=o[1],u=o[0]);let f=Math.atan((u[1]-c[1])/(u[0]-c[0]));for(let p=0;p<h;p++){let g=p*(t+n),m=g+t,k=[c[0]+g*Math.cos(f)+l*Math.cos(f),c[1]+g*Math.sin(f)+l*Math.sin(f)],M=[c[0]+m*Math.cos(f)+l*Math.cos(f),c[1]+m*Math.sin(f)+l*Math.sin(f)];i.push(...this.helper.doubleLineOps(k[0],k[1],M[0],M[1],s))}}),i}};var I=class{constructor(e){this.helper=e}fillPolygons(e,s){let t=s.hachureGap<0?s.strokeWidth*4:s.hachureGap,n=s.zigzagOffset<0?t:s.zigzagOffset;s=Object.assign({},s,{hachureGap:t+n});let i=S(e,s);return{type:"fillSketch",ops:this.zigzagLines(i,n,s)}}zigzagLines(e,s,t){let n=[];return e.forEach(i=>{let o=_(i),a=Math.round(o/(2*s)),h=i[0],l=i[1];h[0]>l[0]&&(h=i[1],l=i[0]);let c=Math.atan((l[1]-h[1])/(l[0]-h[0]));for(let u=0;u<a;u++){let f=u*2*s,p=(u+1)*2*s,g=Math.sqrt(2*Math.pow(s,2)),m=[h[0]+f*Math.cos(c),h[1]+f*Math.sin(c)],k=[h[0]+p*Math.cos(c),h[1]+p*Math.sin(c)],M=[m[0]+g*Math.cos(c+Math.PI/4),m[1]+g*Math.sin(c+Math.PI/4)];n.push(...this.helper.doubleLineOps(m[0],m[1],M[0],M[1],t),...this.helper.doubleLineOps(M[0],M[1],k[0],k[1],t))}}),n}};var b={};function Y(r,e){let s=r.fillStyle||"hachure";if(!b[s])switch(s){case"zigzag":b[s]||(b[s]=new A(e));break;case"cross-hatch":b[s]||(b[s]=new W(e));break;case"dots":b[s]||(b[s]=new y(e));break;case"dashed":b[s]||(b[s]=new G(e));break;case"zigzag-line":b[s]||(b[s]=new I(e));break;case"hachure":default:s="hachure",b[s]||(b[s]=new L(e));break}return b[s]}function Z(){return Math.floor(Math.random()*2**31)}var F=class{constructor(e){this.seed=e}next(){return this.seed?(2**31-1&(this.seed=Math.imul(48271,this.seed)))/2**31:Math.random()}};import{parsePath as nt,normalize as rt,absolutize as it}from"../../../path-data-parser@^0.1.0?target=es2022";var ot={randOffset:lt,randOffsetWithRange:ct,ellipse:ht,doubleLineOps:ut};function q(r,e,s,t,n){return{type:"path",ops:v(r,e,s,t,n)}}function D(r,e,s){let t=(r||[]).length;if(t>2){let n=[];for(let i=0;i<t-1;i++)n.push(...v(r[i][0],r[i][1],r[i+1][0],r[i+1][1],s));return e&&n.push(...v(r[t-1][0],r[t-1][1],r[0][0],r[0][1],s)),{type:"path",ops:n}}else if(t===2)return q(r[0][0],r[0][1],r[1][0],r[1][1],s);return{type:"path",ops:[]}}function at(r,e){return D(r,!0,e)}function U(r,e,s,t,n){let i=[[r,e],[r+s,e],[r+s,e+t],[r,e+t]];return at(i,n)}function N(r,e){let s=J(r,1*(1+e.roughness*.2),e);if(!e.disableMultiStroke){let t=J(r,1.5*(1+e.roughness*.22),ft(e));s=s.concat(t)}return{type:"path",ops:s}}function ht(r,e,s,t,n){let i=V(s,t,n);return j(r,e,n,i).opset}function V(r,e,s){let t=Math.sqrt(Math.PI*2*Math.sqrt((Math.pow(r/2,2)+Math.pow(e/2,2))/2)),n=Math.ceil(Math.max(s.curveStepCount,s.curveStepCount/Math.sqrt(200)*t)),i=Math.PI*2/n,o=Math.abs(r/2),a=Math.abs(e/2),h=1-s.curveFitting;return o+=d(o*h,s),a+=d(a*h,s),{increment:i,rx:o,ry:a}}function j(r,e,s,t){let[n,i]=K(t.increment,r,e,t.rx,t.ry,1,t.increment*R(.1,R(.4,1,s),s),s),o=C(n,null,s);if(!s.disableMultiStroke&&s.roughness!==0){let[a]=K(t.increment,r,e,t.rx,t.ry,1.5,0,s),h=C(a,null,s);o=o.concat(h)}return{estimatedPoints:i,opset:{type:"path",ops:o}}}function x(r,e,s,t,n,i,o,a,h){let l=r,c=e,u=Math.abs(s/2),f=Math.abs(t/2);u+=d(u*.01,h),f+=d(f*.01,h);let p=n,g=i;for(;p<0;)p+=Math.PI*2,g+=Math.PI*2;g-p>Math.PI*2&&(p=0,g=Math.PI*2);let m=Math.PI*2/h.curveStepCount,k=Math.min(m/2,(g-p)/2),M=Q(k,l,c,u,f,p,g,1,h);if(!h.disableMultiStroke){let O=Q(k,l,c,u,f,p,g,1.5,h);M.push(...O)}return o&&(a?M.push(...v(l,c,l+u*Math.cos(p),c+f*Math.sin(p),h),...v(l,c,l+u*Math.cos(g),c+f*Math.sin(g),h)):M.push({op:"lineTo",data:[l,c]},{op:"lineTo",data:[l+u*Math.cos(p),c+f*Math.sin(p)]})),{type:"path",ops:M}}function B(r,e){let s=rt(it(nt(r))),t=[],n=[0,0],i=[0,0];for(let{key:o,data:a}of s)switch(o){case"M":{i=[a[0],a[1]],n=[a[0],a[1]];break}case"L":t.push(...v(i[0],i[1],a[0],a[1],e)),i=[a[0],a[1]];break;case"C":{let[h,l,c,u,f,p]=a;t.push(...pt(h,l,c,u,f,p,i,e)),i=[f,p];break}case"Z":t.push(...v(i[0],i[1],n[0],n[1],e)),i=[n[0],n[1]];break}return{type:"path",ops:t}}function $(r,e){let s=[];for(let t of r)if(t.length){let n=e.maxRandomnessOffset||0,i=t.length;if(i>2){s.push({op:"move",data:[t[0][0]+d(n,e),t[0][1]+d(n,e)]});for(let o=1;o<i;o++)s.push({op:"lineTo",data:[t[o][0]+d(n,e),t[o][1]+d(n,e)]})}}return{type:"fillPath",ops:s}}function T(r,e){return Y(e,ot).fillPolygons(r,e)}function tt(r,e,s,t,n,i,o){let a=r,h=e,l=Math.abs(s/2),c=Math.abs(t/2);l+=d(l*.01,o),c+=d(c*.01,o);let u=n,f=i;for(;u<0;)u+=Math.PI*2,f+=Math.PI*2;f-u>Math.PI*2&&(u=0,f=Math.PI*2);let p=(f-u)/o.curveStepCount,g=[];for(let m=u;m<=f;m=m+p)g.push([a+l*Math.cos(m),h+c*Math.sin(m)]);return g.push([a+l*Math.cos(f),h+c*Math.sin(f)]),g.push([a,h]),T([g],o)}function lt(r,e){return d(r,e)}function ct(r,e,s){return R(r,e,s)}function ut(r,e,s,t,n){return v(r,e,s,t,n,!0)}function ft(r){let e=Object.assign({},r);return e.randomizer=void 0,r.seed&&(e.seed=r.seed+1),e}function et(r){return r.randomizer||(r.randomizer=new F(r.seed||0)),r.randomizer.next()}function R(r,e,s,t=1){return s.roughness*t*(et(s)*(e-r)+r)}function d(r,e,s=1){return R(-r,r,e,s)}function v(r,e,s,t,n,i=!1){let o=i?n.disableMultiStrokeFill:n.disableMultiStroke,a=X(r,e,s,t,n,!0,!1);if(o)return a;let h=X(r,e,s,t,n,!0,!0);return a.concat(h)}function X(r,e,s,t,n,i,o){let a=Math.pow(r-s,2)+Math.pow(e-t,2),h=Math.sqrt(a),l=1;h<200?l=1:h>500?l=.4:l=-.0016668*h+1.233334;let c=n.maxRandomnessOffset||0;c*c*100>a&&(c=h/10);let u=c/2,f=.2+et(n)*.2,p=n.bowing*n.maxRandomnessOffset*(t-e)/200,g=n.bowing*n.maxRandomnessOffset*(r-s)/200;p=d(p,n,l),g=d(g,n,l);let m=[],k=()=>d(u,n,l),M=()=>d(c,n,l),O=n.preserveVertices;return i&&(o?m.push({op:"move",data:[r+(O?0:k()),e+(O?0:k())]}):m.push({op:"move",data:[r+(O?0:d(c,n,l)),e+(O?0:d(c,n,l))]})),o?m.push({op:"bcurveTo",data:[p+r+(s-r)*f+k(),g+e+(t-e)*f+k(),p+r+2*(s-r)*f+k(),g+e+2*(t-e)*f+k(),s+(O?0:k()),t+(O?0:k())]}):m.push({op:"bcurveTo",data:[p+r+(s-r)*f+M(),g+e+(t-e)*f+M(),p+r+2*(s-r)*f+M(),g+e+2*(t-e)*f+M(),s+(O?0:M()),t+(O?0:M())]}),m}function J(r,e,s){let t=[];t.push([r[0][0]+d(e,s),r[0][1]+d(e,s)]),t.push([r[0][0]+d(e,s),r[0][1]+d(e,s)]);for(let n=1;n<r.length;n++)t.push([r[n][0]+d(e,s),r[n][1]+d(e,s)]),n===r.length-1&&t.push([r[n][0]+d(e,s),r[n][1]+d(e,s)]);return C(t,null,s)}function C(r,e,s){let t=r.length,n=[];if(t>3){let i=[],o=1-s.curveTightness;n.push({op:"move",data:[r[1][0],r[1][1]]});for(let a=1;a+2<t;a++){let h=r[a];i[0]=[h[0],h[1]],i[1]=[h[0]+(o*r[a+1][0]-o*r[a-1][0])/6,h[1]+(o*r[a+1][1]-o*r[a-1][1])/6],i[2]=[r[a+1][0]+(o*r[a][0]-o*r[a+2][0])/6,r[a+1][1]+(o*r[a][1]-o*r[a+2][1])/6],i[3]=[r[a+1][0],r[a+1][1]],n.push({op:"bcurveTo",data:[i[1][0],i[1][1],i[2][0],i[2][1],i[3][0],i[3][1]]})}if(e&&e.length===2){let a=s.maxRandomnessOffset;n.push({op:"lineTo",data:[e[0]+d(a,s),e[1]+d(a,s)]})}}else t===3?(n.push({op:"move",data:[r[1][0],r[1][1]]}),n.push({op:"bcurveTo",data:[r[1][0],r[1][1],r[2][0],r[2][1],r[2][0],r[2][1]]})):t===2&&n.push(...v(r[0][0],r[0][1],r[1][0],r[1][1],s));return n}function K(r,e,s,t,n,i,o,a){let h=a.roughness===0,l=[],c=[];if(h){r=r/4,c.push([e+t*Math.cos(-r),s+n*Math.sin(-r)]);for(let u=0;u<=Math.PI*2;u=u+r){let f=[e+t*Math.cos(u),s+n*Math.sin(u)];l.push(f),c.push(f)}c.push([e+t*Math.cos(0),s+n*Math.sin(0)]),c.push([e+t*Math.cos(r),s+n*Math.sin(r)])}else{let u=d(.5,a)-Math.PI/2;c.push([d(i,a)+e+.9*t*Math.cos(u-r),d(i,a)+s+.9*n*Math.sin(u-r)]);let f=Math.PI*2+u-.01;for(let p=u;p<f;p=p+r){let g=[d(i,a)+e+t*Math.cos(p),d(i,a)+s+n*Math.sin(p)];l.push(g),c.push(g)}c.push([d(i,a)+e+t*Math.cos(u+Math.PI*2+o*.5),d(i,a)+s+n*Math.sin(u+Math.PI*2+o*.5)]),c.push([d(i,a)+e+.98*t*Math.cos(u+o),d(i,a)+s+.98*n*Math.sin(u+o)]),c.push([d(i,a)+e+.9*t*Math.cos(u+o*.5),d(i,a)+s+.9*n*Math.sin(u+o*.5)])}return[c,l]}function Q(r,e,s,t,n,i,o,a,h){let l=i+d(.1,h),c=[];c.push([d(a,h)+e+.9*t*Math.cos(l-r),d(a,h)+s+.9*n*Math.sin(l-r)]);for(let u=l;u<=o;u=u+r)c.push([d(a,h)+e+t*Math.cos(u),d(a,h)+s+n*Math.sin(u)]);return c.push([e+t*Math.cos(o),s+n*Math.sin(o)]),c.push([e+t*Math.cos(o),s+n*Math.sin(o)]),C(c,null,h)}function pt(r,e,s,t,n,i,o,a){let h=[],l=[a.maxRandomnessOffset||1,(a.maxRandomnessOffset||1)+.3],c=[0,0],u=a.disableMultiStroke?1:2,f=a.preserveVertices;for(let p=0;p<u;p++)p===0?h.push({op:"move",data:[o[0],o[1]]}):h.push({op:"move",data:[o[0]+(f?0:d(l[0],a)),o[1]+(f?0:d(l[0],a))]}),c=f?[n,i]:[n+d(l[p],a),i+d(l[p],a)],h.push({op:"bcurveTo",data:[r+d(l[p],a),e+d(l[p],a),s+d(l[p],a),t+d(l[p],a),c[0],c[1]]});return h}import{curveToBezier as dt}from"../../../points-on-curve@^0.2.0/lib/curve-to-bezier?target=es2022";import{pointsOnBezierCurves as gt}from"../../../points-on-curve@^0.2.0?target=es2022";import{pointsOnPath as mt}from"../../../points-on-path@^0.2.1?target=es2022";var P="none",w=class{constructor(e){this.defaultOptions={maxRandomnessOffset:2,roughness:1,bowing:1,stroke:"#000",strokeWidth:1,curveTightness:0,curveFitting:.95,curveStepCount:9,fillStyle:"hachure",fillWeight:-1,hachureAngle:-41,hachureGap:-1,dashOffset:-1,dashGap:-1,zigzagOffset:-1,seed:0,disableMultiStroke:!1,disableMultiStrokeFill:!1,preserveVertices:!1,fillShapeRoughnessGain:.8},this.config=e||{},this.config.options&&(this.defaultOptions=this._o(this.config.options))}static newSeed(){return Z()}_o(e){return e?Object.assign({},this.defaultOptions,e):this.defaultOptions}_d(e,s,t){return{shape:e,sets:s||[],options:t||this.defaultOptions}}line(e,s,t,n,i){let o=this._o(i);return this._d("line",[q(e,s,t,n,o)],o)}rectangle(e,s,t,n,i){let o=this._o(i),a=[],h=U(e,s,t,n,o);if(o.fill){let l=[[e,s],[e+t,s],[e+t,s+n],[e,s+n]];o.fillStyle==="solid"?a.push($([l],o)):a.push(T([l],o))}return o.stroke!==P&&a.push(h),this._d("rectangle",a,o)}ellipse(e,s,t,n,i){let o=this._o(i),a=[],h=V(t,n,o),l=j(e,s,o,h);if(o.fill)if(o.fillStyle==="solid"){let c=j(e,s,o,h).opset;c.type="fillPath",a.push(c)}else a.push(T([l.estimatedPoints],o));return o.stroke!==P&&a.push(l.opset),this._d("ellipse",a,o)}circle(e,s,t,n){let i=this.ellipse(e,s,t,t,n);return i.shape="circle",i}linearPath(e,s){let t=this._o(s);return this._d("linearPath",[D(e,!1,t)],t)}arc(e,s,t,n,i,o,a=!1,h){let l=this._o(h),c=[],u=x(e,s,t,n,i,o,a,!0,l);if(a&&l.fill)if(l.fillStyle==="solid"){let f=Object.assign({},l);f.disableMultiStroke=!0;let p=x(e,s,t,n,i,o,!0,!1,f);p.type="fillPath",c.push(p)}else c.push(tt(e,s,t,n,i,o,l));return l.stroke!==P&&c.push(u),this._d("arc",c,l)}curve(e,s){let t=this._o(s),n=[],i=N(e,t);if(t.fill&&t.fill!==P&&e.length>=3)if(t.fillStyle==="solid"){let o=N(e,Object.assign(Object.assign({},t),{disableMultiStroke:!0,roughness:t.roughness?t.roughness+t.fillShapeRoughnessGain:0}));n.push({type:"fillPath",ops:this._mergedShape(o.ops)})}else{let o=dt(e),a=gt(o,10,(1+t.roughness)/2);n.push(T([a],t))}return t.stroke!==P&&n.push(i),this._d("curve",n,t)}polygon(e,s){let t=this._o(s),n=[],i=D(e,!0,t);return t.fill&&(t.fillStyle==="solid"?n.push($([e],t)):n.push(T([e],t))),t.stroke!==P&&n.push(i),this._d("polygon",n,t)}path(e,s){let t=this._o(s),n=[];if(!e)return this._d("path",n,t);e=(e||"").replace(/\n/g," ").replace(/(-\s)/g,"-").replace("/(ss)/g"," ");let i=t.fill&&t.fill!=="transparent"&&t.fill!==P,o=t.stroke!==P,a=!!(t.simplification&&t.simplification<1),h=a?4-4*(t.simplification||1):(1+t.roughness)/2,l=mt(e,1,h),c=B(e,t);if(i)if(t.fillStyle==="solid")if(l.length===1){let u=B(e,Object.assign(Object.assign({},t),{disableMultiStroke:!0,roughness:t.roughness?t.roughness+t.fillShapeRoughnessGain:0}));n.push({type:"fillPath",ops:this._mergedShape(u.ops)})}else n.push($(l,t));else n.push(T(l,t));return o&&(a?l.forEach(u=>{n.push(D(u,!1,t))}):n.push(c)),this._d("path",n,t)}opsToPath(e,s){let t="";for(let n of e.ops){let i=typeof s=="number"&&s>=0?n.data.map(o=>+o.toFixed(s)):n.data;switch(n.op){case"move":t+=`M${i[0]} ${i[1]} `;break;case"bcurveTo":t+=`C${i[0]} ${i[1]}, ${i[2]} ${i[3]}, ${i[4]} ${i[5]} `;break;case"lineTo":t+=`L${i[0]} ${i[1]} `;break}}return t.trim()}toPaths(e){let s=e.sets||[],t=e.options||this.defaultOptions,n=[];for(let i of s){let o=null;switch(i.type){case"path":o={d:this.opsToPath(i),stroke:t.stroke,strokeWidth:t.strokeWidth,fill:P};break;case"fillPath":o={d:this.opsToPath(i),stroke:P,strokeWidth:0,fill:t.fill||P};break;case"fillSketch":o=this.fillSketch(i,t);break}o&&n.push(o)}return n}fillSketch(e,s){let t=s.fillWeight;return t<0&&(t=s.strokeWidth/2),{d:this.opsToPath(e),stroke:s.fill||P,strokeWidth:t,fill:P}}_mergedShape(e){return e.filter((s,t)=>t===0?!0:s.op!=="move")}};var E=class{constructor(e,s){this.canvas=e,this.ctx=this.canvas.getContext("2d"),this.gen=new w(s)}draw(e){let s=e.sets||[],t=e.options||this.getDefaultOptions(),n=this.ctx,i=e.options.fixedDecimalPlaceDigits;for(let o of s)switch(o.type){case"path":n.save(),n.strokeStyle=t.stroke==="none"?"transparent":t.stroke,n.lineWidth=t.strokeWidth,t.strokeLineDash&&n.setLineDash(t.strokeLineDash),t.strokeLineDashOffset&&(n.lineDashOffset=t.strokeLineDashOffset),this._drawToContext(n,o,i),n.restore();break;case"fillPath":{n.save(),n.fillStyle=t.fill||"";let a=e.shape==="curve"||e.shape==="polygon"||e.shape==="path"?"evenodd":"nonzero";this._drawToContext(n,o,i,a),n.restore();break}case"fillSketch":this.fillSketch(n,o,t);break}}fillSketch(e,s,t){let n=t.fillWeight;n<0&&(n=t.strokeWidth/2),e.save(),t.fillLineDash&&e.setLineDash(t.fillLineDash),t.fillLineDashOffset&&(e.lineDashOffset=t.fillLineDashOffset),e.strokeStyle=t.fill||"",e.lineWidth=n,this._drawToContext(e,s,t.fixedDecimalPlaceDigits),e.restore()}_drawToContext(e,s,t,n="nonzero"){e.beginPath();for(let i of s.ops){let o=typeof t=="number"&&t>=0?i.data.map(a=>+a.toFixed(t)):i.data;switch(i.op){case"move":e.moveTo(o[0],o[1]);break;case"bcurveTo":e.bezierCurveTo(o[0],o[1],o[2],o[3],o[4],o[5]);break;case"lineTo":e.lineTo(o[0],o[1]);break}}s.type==="fillPath"?e.fill(n):e.stroke()}get generator(){return this.gen}getDefaultOptions(){return this.gen.defaultOptions}line(e,s,t,n,i){let o=this.gen.line(e,s,t,n,i);return this.draw(o),o}rectangle(e,s,t,n,i){let o=this.gen.rectangle(e,s,t,n,i);return this.draw(o),o}ellipse(e,s,t,n,i){let o=this.gen.ellipse(e,s,t,n,i);return this.draw(o),o}circle(e,s,t,n){let i=this.gen.circle(e,s,t,n);return this.draw(i),i}linearPath(e,s){let t=this.gen.linearPath(e,s);return this.draw(t),t}polygon(e,s){let t=this.gen.polygon(e,s);return this.draw(t),t}arc(e,s,t,n,i,o,a=!1,h){let l=this.gen.arc(e,s,t,n,i,o,a,h);return this.draw(l),l}curve(e,s){let t=this.gen.curve(e,s);return this.draw(t),t}path(e,s){let t=this.gen.path(e,s);return this.draw(t),t}};var z="http://www.w3.org/2000/svg";var H=class{constructor(e,s){this.svg=e,this.gen=new w(s)}draw(e){let s=e.sets||[],t=e.options||this.getDefaultOptions(),n=this.svg.ownerDocument||window.document,i=n.createElementNS(z,"g"),o=e.options.fixedDecimalPlaceDigits;for(let a of s){let h=null;switch(a.type){case"path":{h=n.createElementNS(z,"path"),h.setAttribute("d",this.opsToPath(a,o)),h.setAttribute("stroke",t.stroke),h.setAttribute("stroke-width",t.strokeWidth+""),h.setAttribute("fill","none"),t.strokeLineDash&&h.setAttribute("stroke-dasharray",t.strokeLineDash.join(" ").trim()),t.strokeLineDashOffset&&h.setAttribute("stroke-dashoffset",`${t.strokeLineDashOffset}`);break}case"fillPath":{h=n.createElementNS(z,"path"),h.setAttribute("d",this.opsToPath(a,o)),h.setAttribute("stroke","none"),h.setAttribute("stroke-width","0"),h.setAttribute("fill",t.fill||""),(e.shape==="curve"||e.shape==="polygon")&&h.setAttribute("fill-rule","evenodd");break}case"fillSketch":{h=this.fillSketch(n,a,t);break}}h&&i.appendChild(h)}return i}fillSketch(e,s,t){let n=t.fillWeight;n<0&&(n=t.strokeWidth/2);let i=e.createElementNS(z,"path");return i.setAttribute("d",this.opsToPath(s,t.fixedDecimalPlaceDigits)),i.setAttribute("stroke",t.fill||""),i.setAttribute("stroke-width",n+""),i.setAttribute("fill","none"),t.fillLineDash&&i.setAttribute("stroke-dasharray",t.fillLineDash.join(" ").trim()),t.fillLineDashOffset&&i.setAttribute("stroke-dashoffset",`${t.fillLineDashOffset}`),i}get generator(){return this.gen}getDefaultOptions(){return this.gen.defaultOptions}opsToPath(e,s){return this.gen.opsToPath(e,s)}line(e,s,t,n,i){let o=this.gen.line(e,s,t,n,i);return this.draw(o)}rectangle(e,s,t,n,i){let o=this.gen.rectangle(e,s,t,n,i);return this.draw(o)}ellipse(e,s,t,n,i){let o=this.gen.ellipse(e,s,t,n,i);return this.draw(o)}circle(e,s,t,n){let i=this.gen.circle(e,s,t,n);return this.draw(i)}linearPath(e,s){let t=this.gen.linearPath(e,s);return this.draw(t)}polygon(e,s){let t=this.gen.polygon(e,s);return this.draw(t)}arc(e,s,t,n,i,o,a=!1,h){let l=this.gen.arc(e,s,t,n,i,o,a,h);return this.draw(l)}curve(e,s){let t=this.gen.curve(e,s);return this.draw(t)}path(e,s){let t=this.gen.path(e,s);return this.draw(t)}};var ce={canvas(r,e){return new E(r,e)},svg(r,e){return new H(r,e)},generator(r){return new w(r)},newSeed(){return w.newSeed()}};export{ce as default};
//# sourceMappingURL=rough.mjs.map