const M=Math.PI,x=2*M,$=1e-6,A=x-$;function m(n){this._+=n[0];for(let t=1,i=n.length;t<i;++t)this._+=arguments[t]+n[t]}function C(n){let t=Math.floor(n);if(!(t>=0))throw new Error(`invalid digits: ${n}`);if(t>15)return m;const i=10**t;return function(s){this._+=s[0];for(let e=1,h=s.length;e<h;++e)this._+=Math.round(arguments[e]*i)/i+s[e]}}class P{constructor(t){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=t==null?m:C(t)}moveTo(t,i){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+i}`}closePath(){this._x1!==null&&(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,s,e){this._append`Q${+t},${+i},${this._x1=+s},${this._y1=+e}`}bezierCurveTo(t,i,s,e,h,o){this._append`C${+t},${+i},${+s},${+e},${this._x1=+h},${this._y1=+o}`}arcTo(t,i,s,e,h){if(t=+t,i=+i,s=+s,e=+e,h=+h,h<0)throw new Error(`negative radius: ${h}`);let o=this._x1,p=this._y1,u=s-t,l=e-i,_=o-t,r=p-i,a=_*_+r*r;if(this._x1===null)this._append`M${this._x1=t},${this._y1=i}`;else if(a>$)if(!(Math.abs(r*u-l*_)>$)||!h)this._append`L${this._x1=t},${this._y1=i}`;else{let f=s-o,c=e-p,b=u*u+l*l,E=f*f+c*c,y=Math.sqrt(b),v=Math.sqrt(a),w=h*Math.tan((M-Math.acos((b+a-E)/(2*y*v)))/2),d=w/v,g=w/y;Math.abs(d-1)>$&&this._append`L${t+d*_},${i+d*r}`,this._append`A${h},${h},0,0,${+(r*f>_*c)},${this._x1=t+g*u},${this._y1=i+g*l}`}}arc(t,i,s,e,h,o){if(t=+t,i=+i,s=+s,o=!!o,s<0)throw new Error(`negative radius: ${s}`);let p=s*Math.cos(e),u=s*Math.sin(e),l=t+p,_=i+u,r=1^o,a=o?e-h:h-e;this._x1===null?this._append`M${l},${_}`:(Math.abs(this._x1-l)>$||Math.abs(this._y1-_)>$)&&this._append`L${l},${_}`,s&&(a<0&&(a=a%x+x),a>A?this._append`A${s},${s},0,1,${r},${t-p},${i-u}A${s},${s},0,1,${r},${this._x1=l},${this._y1=_}`:a>$&&this._append`A${s},${s},0,${+(a>=M)},${r},${this._x1=t+s*Math.cos(h)},${this._y1=i+s*Math.sin(h)}`)}rect(t,i,s,e){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+i}h${s=+s}v${+e}h${-s}Z`}toString(){return this._}}function L(n){return function(){return n}}function k(n){let t=3;return n.digits=function(i){if(!arguments.length)return t;if(i==null)t=null;else{const s=Math.floor(i);if(!(s>=0))throw new RangeError(`invalid digits: ${i}`);t=s}return n},()=>new P(t)}var q=Array.prototype.slice;function z(n){return typeof n=="object"&&"length"in n?n:Array.from(n)}function S(n){return n[0]}function N(n){return n[1]}class T{constructor(t,i){this._context=t,this._x=i}areaStart(){this._line=0}areaEnd(){this._line=NaN}lineStart(){this._point=0}lineEnd(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line}point(t,i){switch(t=+t,i=+i,this._point){case 0:{this._point=1,this._line?this._context.lineTo(t,i):this._context.moveTo(t,i);break}case 1:this._point=2;default:{this._x?this._context.bezierCurveTo(this._x0=(this._x0+t)/2,this._y0,this._x0,i,t,i):this._context.bezierCurveTo(this._x0,this._y0=(this._y0+i)/2,t,this._y0,t,i);break}}this._x0=t,this._y0=i}}function R(n){return new T(n,!0)}function Z(n){return new T(n,!1)}export{z as a,Z as b,L as c,R as d,q as s,k as w,S as x,N as y};
