r.cleanThreshold&&r.runAfter(u.clean),e},fm(Ze,m),Ke.Definition={type:"Filter",metadata:{changes:!0},params:[{name:"expr",type:"expr",required:!0}]},fm(Ke,be).transform=function(t,e){function n(e){var n=s(e),r=c(e,t),a=i.get(n);r&&a?(i.delete(n),o.push(e)):r||a?l&&r&&!a&&f.push(e):(i.set(n,1),u.push(e))}var r=e.dataflow,i=this.value,a=e.fork(),o=a.add,u=a.rem,f=a.mod,c=t.expr,l=!0;return e.visit(e.REM,function(t){var e=s(t);i.has(e)?i.delete(e):u.push(t)}),e.visit(e.ADD,function(e){c(e,t)?o.push(e):i.set(s(e),1)}),e.visit(e.MOD,n),t.modified()&&(l=!1,e.visit(e.REFLOW,n)),i.empty>r.cleanThreshold&&r.runAfter(i.clean),a},tn.Definition={type:"Fold",metadata:{generates:!0,changes:!0},params:[{name:"fields",type:"field",array:!0,required:!0},{name:"as",type:"string",array:!0,length:2,default:["key","value"]}]},fm(tn,be).transform=function(t,e){function n(t){for(var e,n=i[s(t)]=Array(p),r=0;r0){for(n=[];--u>=0;)n.push(i=c(s(t))),a.push(i);o.add=o.add.length?o.materialize(o.ADD).add.concat(n):n}else r=a.slice(0,-u),o.rem=o.rem.length?o.materialize(o.REM).rem.concat(r):r,a=a.slice(-u);return o.source=this.value=a,o};var Ab={value:"value",median:function(t,e){var n,r=t.length,i=-1,a=[];if(null==e)for(;++i=n)for(r=n;++an&&(r=n)}else for(;++a=n)for(r=n;++an&&(r=n);return r},max:ib},Cb=[];an.Definition={type:"Impute",metadata:{changes:!0},params:[{name:"field",type:"field",required:!0},{name:"key",type:"field",required:!0},{name:"keyvals",array:!0},{name:"groupby",type:"field",array:!0},{name:"method",type:"enum",default:"value",values:["value","mean","median","max","min"]},{name:"value",default:0}]},fm(an,be).transform=function(t,n){var r,i,a,o,u,s,f,l,h,d,p=n.fork(n.ALL),g=on(t),v=un(t),m=e(t.field),y=e(t.key),b=(t.groupby||[]).map(e),_=sn(n.source,t.groupby,t.key,t.keyvals),x=[],w=this.value,M=_.domain.length;for(u=0,l=_.length;u1&&!o&&qv('Multi-field lookup requires explicit "as" parameter.'),o&&o.length!==d*i&&qv('The "as" parameter has too few output field names.'),o=o||f.map(e),r=function(t){for(var e,n,r=0,a=0;r=f&&(e=o[n],c[s(e)]&&r.rem.push(e),o[n]=t),++u}var r=e.fork(),i=t.modified("size"),a=t.size,o=this.value,u=this.count,f=0,c=o.reduce(function(t,e){return t[s(e)]=1,t},{});if(e.rem.length&&(e.visit(e.REM,function(t){var e=s(t);c[e]&&(c[e]=-1,r.rem.push(t)),--u}),o=o.filter(function(t){return-1!==c[s(t)]})),(e.rem.length||i)&&o.lengtha){for(var l=0,h=o.length-a;lr.cleanThreshold&&r.runAfter(a.clean),e.fork()},fm(En,be).transform=function(t,e){(!this.value||t.modified("field")||t.modified("sort")||e.changed()||t.sort&&e.modified(t.sort.fields))&&(this.value=(t.sort?e.source.slice().sort(t.sort):e.source).map(t.field))};var Db={row_number:function(){return{next:function(t){return t.index+1}}},rank:function(){var t;return{init:function(){t=1},next:function(e){var n=e.index,r=e.data;return n&&e.compare(r[n-1],r[n])?t=n+1:t}}},dense_rank:function(){var t;return{init:function(){t=1},next:function(e){var n=e.index,r=e.data;return n&&e.compare(r[n-1],r[n])?++t:t}}},percent_rank:function(){var t=Db.rank(),e=t.next;return{init:t.init,next:function(t){return(e(t)-1)/(t.data.length-1)}}},cume_dist:function(){var t;return{init:function(){t=0},next:function(e){var n=e.index,r=e.data,i=e.compare;if(t0||qv("ntile num must be greater than zero.");var n=Db.cume_dist(),r=n.next;return{init:n.init,next:function(t){return Math.ceil(e*r(t))}}},lag:function(t,e){return e=+e||1,{next:function(n){var r=n.index-e;return r>=0?t(n.data[r]):null}}},lead:function(t,e){return e=+e||1,{next:function(n){var r=n.index+e,i=n.data;return r0||qv("nth_value nth must be greater than zero."),{next:function(n){var r=n.i0+(e-1);return rthis.x2&&(this.x2=t),e>this.y2&&(this.y2=e),this},Pb.expand=function(t){return this.x1-=t,this.y1-=t,this.x2+=t,this.y2+=t,this},Pb.round=function(){return this.x1=Math.floor(this.x1),this.y1=Math.floor(this.y1),this.x2=Math.ceil(this.x2),this.y2=Math.ceil(this.y2),this},Pb.translate=function(t,e){return this.x1+=t,this.x2+=t,this.y1+=e,this.y2+=e,this},Pb.rotate=function(t,e,n){var r=Math.cos(t),i=Math.sin(t),a=e-e*r+n*i,o=n-e*i-n*r,u=this.x1,s=this.x2,f=this.y1,c=this.y2;return this.clear().add(r*u-i*f+a,i*u+r*f+o).add(r*u-i*c+a,i*u+r*c+o).add(r*s-i*f+a,i*s+r*f+o).add(r*s-i*c+a,i*s+r*c+o)},Pb.union=function(t){return t.x1this.x2&&(this.x2=t.x2),t.y2>this.y2&&(this.y2=t.y2),this},Pb.intersect=function(t){return t.x1>this.x1&&(this.x1=t.x1),t.y1>this.y1&&(this.y1=t.y1),t.x2=t.x2&&this.y1<=t.y1&&this.y2>=t.y2},Pb.alignsWith=function(t){return t&&(this.x1==t.x1||this.x2==t.x2||this.y1==t.y1||this.y2==t.y2)},Pb.intersects=function(t){return t&&!(this.x2t.x2||this.y2t.y2)},Pb.contains=function(t,e){return!(tthis.x2||ethis.y2)},Pb.width=function(){return this.x2-this.x1},Pb.height=function(){return this.y2-this.y1};var Lb=0,qb=function(t,e){var n,r=[];return n={id:"gradient_"+Lb++,x1:t?t[0]:0,y1:t?t[1]:0,x2:e?e[0]:1,y2:e?e[1]:0,stops:r,stop:function(t,e){return r.push({offset:t,color:e}),n}}};fm(Pn,Rn);var Ub;try{Ub=require("canvas")}catch(t){Ub=null}var jb=function(t,e){var n=Ln(null,"canvas");if(n&&n.getContext)n.width=t,n.height=e;else if(Ub)try{n=new Ub(t,e)}catch(t){n=null}return n},Fb="undefined"!=typeof Image?Image:Ub&&Ub.Image||null,Ib=In.prototype;Ib.pending=function(){return this._pending},Ib.sanitizeURL=function(t){var e=this;return $n(e),e._loader.sanitize(t,{context:"href"}).then(function(t){return Bn(e),t}).catch(function(){return Bn(e),null})},Ib.loadImage=function(t){var e=this;return $n(e),e._loader.sanitize(t,{context:"image"}).then(function(t){var n=t.href;if(!n||!Fb)throw{url:n};var r=new Fb;return r.onload=function(){Bn(e),r.loaded=!0},r.onerror=function(){Bn(e),r.loaded=!1},r.src=n,r}).catch(function(t){return Bn(e),{loaded:!1,width:0,height:0,src:t&&t.url||""}})},Ib.ready=function(){var t=this;return new Promise(function(e){function n(r){t.pending()?setTimeout(function(){n(!0)},10):e(r)}n(!1)})};var $b=Math.PI,Bb=2*$b,Wb=Bb-1e-6;Wn.prototype=Yn.prototype={constructor:Wn,moveTo:function(t,e){this._+="M"+(this._x0=this._x1=+t)+","+(this._y0=this._y1=+e)},closePath:function(){null!==this._x1&&(this._x1=this._x0,this._y1=this._y0,this._+="Z")},lineTo:function(t,e){this._+="L"+(this._x1=+t)+","+(this._y1=+e)},quadraticCurveTo:function(t,e,n,r){this._+="Q"+ +t+","+ +e+","+(this._x1=+n)+","+(this._y1=+r)},bezierCurveTo:function(t,e,n,r,i,a){this._+="C"+ +t+","+ +e+","+ +n+","+ +r+","+(this._x1=+i)+","+(this._y1=+a)},arcTo:function(t,e,n,r,i){t=+t,e=+e,n=+n,r=+r,i=+i;var a=this._x1,o=this._y1,u=n-t,s=r-e,f=a-t,c=o-e,l=f*f+c*c;if(i<0)throw new Error("negative radius: "+i);if(null===this._x1)this._+="M"+(this._x1=t)+","+(this._y1=e);else if(l>1e-6)if(Math.abs(c*u-s*f)>1e-6&&i){var h=n-a,d=r-o,p=u*u+s*s,g=h*h+d*d,v=Math.sqrt(p),m=Math.sqrt(l),y=i*Math.tan(($b-Math.acos((p+l-g)/(2*v*m)))/2),b=y/m,_=y/v;Math.abs(b-1)>1e-6&&(this._+="L"+(t+b*f)+","+(e+b*c)),this._+="A"+i+","+i+",0,0,"+ +(c*h>f*d)+","+(this._x1=t+_*u)+","+(this._y1=e+_*s)}else this._+="L"+(this._x1=t)+","+(this._y1=e);else;},arc:function(t,e,n,r,i,a){t=+t,e=+e;var o=(n=+n)*Math.cos(r),u=n*Math.sin(r),s=t+o,f=e+u,c=1^a,l=a?r-i:i-r;if(n<0)throw new Error("negative radius: "+n);null===this._x1?this._+="M"+s+","+f:(Math.abs(this._x1-s)>1e-6||Math.abs(this._y1-f)>1e-6)&&(this._+="L"+s+","+f),n&&(l<0&&(l=l%Bb+Bb),l>Wb?this._+="A"+n+","+n+",0,1,"+c+","+(t-o)+","+(e-u)+"A"+n+","+n+",0,1,"+c+","+(this._x1=s)+","+(this._y1=f):l>1e-6&&(this._+="A"+n+","+n+",0,"+ +(l>=$b)+","+c+","+(this._x1=t+n*Math.cos(i))+","+(this._y1=e+n*Math.sin(i))))},rect:function(t,e,n,r){this._+="M"+(this._x0=this._x1=+t)+","+(this._y0=this._y1=+e)+"h"+ +n+"v"+ +r+"h"+-n+"Z"},toString:function(){return this._}};var Yb=function(t){return function(){return t}},Hb=Math.abs,Gb=Math.atan2,Xb=Math.cos,Vb=Math.max,Jb=Math.min,Zb=Math.sin,Qb=Math.sqrt,Kb=1e-12,t_=Math.PI,e_=t_/2,n_=2*t_;er.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;default:this._context.lineTo(t,e)}}};var r_=function(t){return new er(t)},i_=function(){function t(t){var u,s,f,c=t.length,l=!1;for(null==i&&(o=a(f=Yn())),u=0;u<=c;++u)!(u=c;--l)f.point(v[l],m[l]);f.lineEnd(),f.areaEnd()}g&&(v[e]=+n(h,e,t),m[e]=+i(h,e,t),f.point(r?+r(h,e,t):v[e],a?+a(h,e,t):m[e]))}if(d)return f=null,d+""||null}function e(){return i_().defined(o).curve(s).context(u)}var n=nr,r=null,i=Yb(0),a=rr,o=Yb(!0),u=null,s=r_,f=null;return t.x=function(e){return arguments.length?(n="function"==typeof e?e:Yb(+e),r=null,t):n},t.x0=function(e){return arguments.length?(n="function"==typeof e?e:Yb(+e),t):n},t.x1=function(e){return arguments.length?(r=null==e?null:"function"==typeof e?e:Yb(+e),t):r},t.y=function(e){return arguments.length?(i="function"==typeof e?e:Yb(+e),a=null,t):i},t.y0=function(e){return arguments.length?(i="function"==typeof e?e:Yb(+e),t):i},t.y1=function(e){return arguments.length?(a=null==e?null:"function"==typeof e?e:Yb(+e),t):a},t.lineX0=t.lineY0=function(){return e().x(n).y(i)},t.lineY1=function(){return e().x(n).y(a)},t.lineX1=function(){return e().x(r).y(i)},t.defined=function(e){return arguments.length?(o="function"==typeof e?e:Yb(!!e),t):o},t.curve=function(e){return arguments.length?(s=e,null!=u&&(f=s(u)),t):s},t.context=function(e){return arguments.length?(null==e?u=f=null:f=s(u=e),t):u},t},o_={draw:function(t,e){var n=Math.sqrt(e/t_);t.moveTo(n,0),t.arc(0,0,n,0,n_)}},u_=function(){};ar.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){switch(this._point){case 3:ir(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1)}(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;break;case 2:this._point=3,this._context.lineTo((5*this._x0+this._x1)/6,(5*this._y0+this._y1)/6);default:ir(this,t,e)}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};or.prototype={areaStart:u_,areaEnd:u_,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._y0=this._y1=this._y2=this._y3=this._y4=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:this._context.moveTo(this._x2,this._y2),this._context.closePath();break;case 2:this._context.moveTo((this._x2+2*this._x3)/3,(this._y2+2*this._y3)/3),this._context.lineTo((this._x3+2*this._x2)/3,(this._y3+2*this._y2)/3),this._context.closePath();break;case 3:this.point(this._x2,this._y2),this.point(this._x3,this._y3),this.point(this._x4,this._y4)}},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._x2=t,this._y2=e;break;case 1:this._point=2,this._x3=t,this._y3=e;break;case 2:this._point=3,this._x4=t,this._y4=e,this._context.moveTo((this._x0+4*this._x1+t)/6,(this._y0+4*this._y1+e)/6);break;default:ir(this,t,e)}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};ur.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){(this._line||0!==this._line&&3===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3;var n=(this._x0+4*this._x1+t)/6,r=(this._y0+4*this._y1+e)/6;this._line?this._context.lineTo(n,r):this._context.moveTo(n,r);break;case 3:this._point=4;default:ir(this,t,e)}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};sr.prototype={lineStart:function(){this._x=[],this._y=[],this._basis.lineStart()},lineEnd:function(){var t=this._x,e=this._y,n=t.length-1;if(n>0)for(var r,i=t[0],a=e[0],o=t[n]-i,u=e[n]-a,s=-1;++s<=n;)r=s/n,this._basis.point(this._beta*t[s]+(1-this._beta)*(i+r*o),this._beta*e[s]+(1-this._beta)*(a+r*u));this._x=this._y=null,this._basis.lineEnd()},point:function(t,e){this._x.push(+t),this._y.push(+e)}};var s_=function t(e){function n(t){return 1===e?new ar(t):new sr(t,e)}return n.beta=function(e){return t(+e)},n}(.85);cr.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x2,this._y2);break;case 3:fr(this,this._x1,this._y1)}(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2,this._x1=t,this._y1=e;break;case 2:this._point=3;default:fr(this,t,e)}this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=e}};var f_=function t(e){function n(t){return new cr(t,e)}return n.tension=function(e){return t(+e)},n}(0);lr.prototype={areaStart:u_,areaEnd:u_,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._x5=this._y0=this._y1=this._y2=this._y3=this._y4=this._y5=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:this._context.moveTo(this._x3,this._y3),this._context.closePath();break;case 2:this._context.lineTo(this._x3,this._y3),this._context.closePath();break;case 3:this.point(this._x3,this._y3),this.point(this._x4,this._y4),this.point(this._x5,this._y5)}},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._x3=t,this._y3=e;break;case 1:this._point=2,this._context.moveTo(this._x4=t,this._y4=e);break;case 2:this._point=3,this._x5=t,this._y5=e;break;default:fr(this,t,e)}this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=e}};var c_=function t(e){function n(t){return new lr(t,e)}return n.tension=function(e){return t(+e)},n}(0);hr.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._point=0},lineEnd:function(){(this._line||0!==this._line&&3===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3,this._line?this._context.lineTo(this._x2,this._y2):this._context.moveTo(this._x2,this._y2);break;case 3:this._point=4;default:fr(this,t,e)}this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=e}};var l_=function t(e){function n(t){return new hr(t,e)}return n.tension=function(e){return t(+e)},n}(0);pr.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x2,this._y2);break;case 3:this.point(this._x2,this._y2)}(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){if(t=+t,e=+e,this._point){var n=this._x2-t,r=this._y2-e;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(n*n+r*r,this._alpha))}switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;break;case 2:this._point=3;default:dr(this,t,e)}this._l01_a=this._l12_a,this._l12_a=this._l23_a,this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a,this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=e}};var h_=function t(e){function n(t){return e?new pr(t,e):new cr(t,0)}return n.alpha=function(e){return t(+e)},n}(.5);gr.prototype={areaStart:u_,areaEnd:u_,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._x5=this._y0=this._y1=this._y2=this._y3=this._y4=this._y5=NaN,this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0},lineEnd:function(){switch(this._point){case 1:this._context.moveTo(this._x3,this._y3),this._context.closePath();break;case 2:this._context.lineTo(this._x3,this._y3),this._context.closePath();break;case 3:this.point(this._x3,this._y3),this.point(this._x4,this._y4),this.point(this._x5,this._y5)}},point:function(t,e){if(t=+t,e=+e,this._point){var n=this._x2-t,r=this._y2-e;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(n*n+r*r,this._alpha))}switch(this._point){case 0:this._point=1,this._x3=t,this._y3=e;break;case 1:this._point=2,this._context.moveTo(this._x4=t,this._y4=e);break;case 2:this._point=3,this._x5=t,this._y5=e;break;default:dr(this,t,e)}this._l01_a=this._l12_a,this._l12_a=this._l23_a,this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a,this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=e}};var d_=function t(e){function n(t){return e?new gr(t,e):new lr(t,0)}return n.alpha=function(e){return t(+e)},n}(.5);vr.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0},lineEnd:function(){(this._line||0!==this._line&&3===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){if(t=+t,e=+e,this._point){var n=this._x2-t,r=this._y2-e;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(n*n+r*r,this._alpha))}switch(this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3,this._line?this._context.lineTo(this._x2,this._y2):this._context.moveTo(this._x2,this._y2);break;case 3:this._point=4;default:dr(this,t,e)}this._l01_a=this._l12_a,this._l12_a=this._l23_a,this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a,this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=e}};var p_=function t(e){function n(t){return e?new vr(t,e):new hr(t,0)}return n.alpha=function(e){return t(+e)},n}(.5);mr.prototype={areaStart:u_,areaEnd:u_,lineStart:function(){this._point=0},lineEnd:function(){this._point&&this._context.closePath()},point:function(t,e){t=+t,e=+e,this._point?this._context.lineTo(t,e):(this._point=1,this._context.moveTo(t,e))}};wr.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=this._t0=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x1,this._y1);break;case 3:xr(this,this._t0,_r(this,this._t0))}(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){var n=NaN;if(t=+t,e=+e,t!==this._x1||e!==this._y1){switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;break;case 2:this._point=3,xr(this,_r(this,n=br(this,t,e)),n);break;default:xr(this,this._t0,n=br(this,t,e))}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e,this._t0=n}}},(Mr.prototype=Object.create(wr.prototype)).point=function(t,e){wr.prototype.point.call(this,e,t)},kr.prototype={moveTo:function(t,e){this._context.moveTo(e,t)},closePath:function(){this._context.closePath()},lineTo:function(t,e){this._context.lineTo(e,t)},bezierCurveTo:function(t,e,n,r,i,a){this._context.bezierCurveTo(e,t,r,n,a,i)}},Er.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=[],this._y=[]},lineEnd:function(){var t=this._x,e=this._y,n=t.length;if(n)if(this._line?this._context.lineTo(t[0],e[0]):this._context.moveTo(t[0],e[0]),2===n)this._context.lineTo(t[1],e[1]);else for(var r=Sr(t),i=Sr(e),a=0,o=1;o=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;default:if(this._t<=0)this._context.lineTo(this._x,e),this._context.lineTo(t,e);else{var n=this._x*(1-this._t)+t*this._t;this._context.lineTo(n,this._y),this._context.lineTo(n,e)}}this._x=t,this._y=e}};var g_,v_={basis:{curve:function(t){return new ar(t)}},"basis-closed":{curve:function(t){return new or(t)}},"basis-open":{curve:function(t){return new ur(t)}},bundle:{curve:s_,tension:"beta",value:.85},cardinal:{curve:f_,tension:"tension",value:0},"cardinal-open":{curve:l_,tension:"tension",value:0},"cardinal-closed":{curve:c_,tension:"tension",value:0},"catmull-rom":{curve:h_,tension:"alpha",value:.5},"catmull-rom-closed":{curve:d_,tension:"alpha",value:.5},"catmull-rom-open":{curve:p_,tension:"alpha",value:.5},linear:{curve:r_},"linear-closed":{curve:function(t){return new mr(t)}},monotone:{horizontal:function(t){return new Mr(t)},vertical:function(t){return new wr(t)}},natural:{curve:function(t){return new Er(t)}},step:{curve:function(t){return new Ar(t,.5)}},"step-after":{curve:function(t){return new Ar(t,1)}},"step-before":{curve:function(t){return new Ar(t,0)}}},m_={m:2,l:2,h:1,v:1,c:6,s:4,q:4,t:2,a:7},y_=[/([MLHVCSQTAZmlhvcsqtaz])/g,/###/,/(\d)([-+])/g,/\s|,|###/],b_=function(t){var e,n,r,i,a,o,u,s,f,c,l,h=[];for(s=0,c=(e=t.slice().replace(y_[0],"###$1").split(y_[1]).slice(1)).length;su)for(f=1,l=i.length;fh;if(s||(s=t=Yn()),lKb)if(p>n_-Kb)s.moveTo(l*Xb(h),l*Zb(h)),s.arc(0,0,l,h,d,!g),c>Kb&&(s.moveTo(c*Xb(d),c*Zb(d)),s.arc(0,0,c,d,h,g));else{var v,m,y=h,b=d,_=h,x=d,w=p,M=p,k=u.apply(this,arguments)/2,E=k>Kb&&(i?+i.apply(this,arguments):Qb(c*c+l*l)),S=Jb(Hb(l-c)/2,+r.apply(this,arguments)),A=S,C=S;if(E>Kb){var z=Gn(E/c*Zb(k)),D=Gn(E/l*Zb(k));(w-=2*z)>Kb?(z*=g?1:-1,_+=z,x-=z):(w=0,_=x=(h+d)/2),(M-=2*D)>Kb?(D*=g?1:-1,y+=D,b-=D):(M=0,y=b=(h+d)/2)}var O=l*Xb(y),N=l*Zb(y),T=c*Xb(x),R=c*Zb(x);if(S>Kb){var P=l*Xb(b),L=l*Zb(b),q=c*Xb(_),U=c*Zb(_);if(pKb?Kn(O,N,q,U,P,L,T,R):[T,R],F=O-j[0],I=N-j[1],$=P-j[0],B=L-j[1],W=1/Zb(Hn((F*$+I*B)/(Qb(F*F+I*I)*Qb($*$+B*B)))/2),Y=Qb(j[0]*j[0]+j[1]*j[1]);A=Jb(S,(c-Y)/(W-1)),C=Jb(S,(l-Y)/(W+1))}}M>Kb?C>Kb?(v=tr(q,U,O,N,l,C,g),m=tr(P,L,T,R,l,C,g),s.moveTo(v.cx+v.x01,v.cy+v.y01),CKb&&w>Kb?A>Kb?(v=tr(T,R,P,L,c,-A,g),m=tr(O,N,q,U,c,-A,g),s.lineTo(v.cx+v.x01,v.cy+v.y01),Ah&&(h=f),cp&&(p=c)}if(Math.abs(i-r)>$_)return Gr(t-n,e-n),void Gr(t+n,e+n);var u,s,f,c,l=1/0,h=-1/0,d=1/0,p=-1/0;if(o(r),o(i),i!==r)if((r%=F_)<0&&(r+=F_),(i%=F_)<0&&(i+=F_),ii;++s,u-=I_)o(u);else for(u=r-r%I_+I_,s=0;s<3&&u0&&(t.globalAlpha=n,t.fillStyle=H_(t,e,e.fill),!0)},X_=[],V_=function(t,e,n){var r=null!=(r=e.strokeWidth)?r:1;return!(r<=0)&&((n*=null==e.strokeOpacity?1:e.strokeOpacity)>0&&(t.globalAlpha=n,t.strokeStyle=H_(t,e,e.stroke),t.lineWidth=r,t.lineCap=e.strokeCap||"butt",t.lineJoin=e.strokeJoin||"miter",t.miterLimit=e.strokeMiterLimit||10,t.setLineDash&&(t.setLineDash(e.strokeDash||X_),t.lineDashOffset=e.strokeDashOffset||0),!0))},J_=function(){return!0},Z_=function(t,e){return"translate("+t+","+e+")"},Q_=function(t){return Z_(t.x||0,t.y||0)},K_=function(t,e){function n(t,n){var r=n.x||0,i=n.y||0;t.translate(r,i),t.beginPath(),e(t,n),t.translate(-r,-i)}return{type:t,tag:"path",nested:!1,attr:function(t,n){t("transform",Q_(n)),t("d",e(null,n))},bound:function(t,n){return e(Yr(t),n),j_(t,n).translate(n.x||0,n.y||0)},draw:Qr(n),pick:ri(n)}},tx=K_("arc",function(t,e){return N_.context(t)(e)}),ex=function(t,e){function n(t,n){t.beginPath(),e(t,n)}var r=ni(n);return{type:t,tag:"path",nested:!0,attr:function(t,n){var r=n.mark.items;r.length&&t("d",e(null,r))},bound:function(t,n){var r=n.items;return 0===r.length?t:(e(Yr(t),r),j_(t,r[0]))},draw:Kr(n),pick:function(t,e,n,i,a,o){var u=e.items,s=e.bounds;return!u||!u.length||s&&!s.contains(a,o)?null:(t.pixelRatio>1&&(n*=t.pixelRatio,i*=t.pixelRatio),r(t,u,n,i)?u[0]:null)}}},nx=ex("area",function(t,e){var n=e[0],r=n.interpolate||"linear";return("horizontal"===n.orient?R_:T_).curve(Cr(r,n.orient,n.tension)).context(t)(e)}),rx=1,ix=function(t,e,n){var r=t._defs,i=e.clip_id||(e.clip_id="clip"+rx++),a=r.clipping[i]||(r.clipping[i]={id:i});return a.width=n.width||0,a.height=n.height||0,"url(#"+i+")"},ax=.5,ox={type:"group",tag:"g",nested:!1,attr:function(t,e){t("transform",Q_(e))},bound:function(t,e){if(!e.clip&&e.items)for(var n=e.items,r=0,i=n.length;r