const t=Math.PI,i=2*t,h=1e-6,s=i-h;function _(t){this._+=t[0];for(let i=1,h=t.length;i<h;++i)this._+=arguments[i]+t[i]}class ${constructor(t){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=null==t?_:function(t){let i=Math.floor(t);if(!(i>=0))throw new Error(`invalid digits: ${t}`);if(i>15)return _;const h=10**i;return function(t){this._+=t[0];for(let i=1,s=t.length;i<s;++i)this._+=Math.round(arguments[i]*h)/h+t[i]}}(t)}moveTo(t,i){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+i}`}closePath(){null!==this._x1&&(this._x1=this._x0,this._y1=this._y0,this._append`Z`)}lineTo(t,i){this._append`L${this._x1=+t},${this._y1=+i}`}quadraticCurveTo(t,i,h,s){this._append`Q${+t},${+i},${this._x1=+h},${this._y1=+s}`}bezierCurveTo(t,i,h,s,_,$){this._append`C${+t},${+i},${+h},${+s},${this._x1=+_},${this._y1=+$}`}arcTo(i,s,_,$,a){if(i=+i,s=+s,_=+_,$=+$,(a=+a)<0)throw new Error(`negative radius: ${a}`);let e=this._x1,n=this._y1,r=_-i,p=$-s,o=e-i,l=n-s,x=o*o+l*l;if(null===this._x1)this._append`M${this._x1=i},${this._y1=s}`;else if(x>h)if(Math.abs(l*r-p*o)>h&&a){let d=_-e,M=$-n,u=r*r+p*p,y=d*d+M*M,c=Math.sqrt(u),f=Math.sqrt(x),v=a*Math.tan((t-Math.acos((u+x-y)/(2*c*f)))/2),g=v/f,w=v/c;Math.abs(g-1)>h&&this._append`L${i+g*o},${s+g*l}`,this._append`A${a},${a},0,0,${+(l*d>o*M)},${this._x1=i+w*r},${this._y1=s+w*p}`}else this._append`L${this._x1=i},${this._y1=s}`}arc(_,$,a,e,n,r){if(_=+_,$=+$,r=!!r,(a=+a)<0)throw new Error(`negative radius: ${a}`);let p=a*Math.cos(e),o=a*Math.sin(e),l=_+p,x=$+o,d=1^r,M=r?e-n:n-e;null===this._x1?this._append`M${l},${x}`:(Math.abs(this._x1-l)>h||Math.abs(this._y1-x)>h)&&this._append`L${l},${x}`,a&&(M<0&&(M=M%i+i),M>s?this._append`A${a},${a},0,1,${d},${_-p},${$-o}A${a},${a},0,1,${d},${this._x1=l},${this._y1=x}`:M>h&&this._append`A${a},${a},0,${+(M>=t)},${d},${this._x1=_+a*Math.cos(n)},${this._y1=$+a*Math.sin(n)}`)}rect(t,i,h,s){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+i}h${h=+h}v${+s}h${-h}Z`}toString(){return this._}}export{$ as P};
