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