!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.d3={})}(this,function(t){"use strict";function n(t,e){return t>>1;f(t[a],e)<0?n=a+1:r=a}return n},right:function(t,e,n,r){for(null==n&&(n=0),null==r&&(r=t.length);n>>1;0>8&15|e>>4&240,e>>4&15|240&e,(15&e)<<4|15&e,1):(e=_t.exec(t))?Ct(parseInt(e[1],16)):(e=vt.exec(t))?new Dt(e[1],e[2],e[3],1):(e=mt.exec(t))?new Dt(255*e[1]/100,255*e[2]/100,255*e[3]/100,1):(e=wt.exec(t))?kt(e[1],e[2],e[3],e[4]):(e=xt.exec(t))?kt(255*e[1]/100,255*e[2]/100,255*e[3]/100,e[4]):(e=Mt.exec(t))?Pt(e[1],e[2]/100,e[3]/100,1):(e=At.exec(t))?Pt(e[1],e[2]/100,e[3]/100,e[4]):Nt.hasOwnProperty(t)?Ct(Nt[t]):"transparent"===t?new Dt(NaN,NaN,NaN,0):null}function Ct(t){return new Dt(t>>16&255,t>>8&255,255&t,1)}function kt(t,e,n,r){return r<=0&&(t=e=n=NaN),new Dt(t,e,n,r)}function St(t){return t instanceof lt||(t=Tt(t)),t?new Dt((t=t.rgb()).r,t.g,t.b,t.opacity):new Dt}function Ut(t,e,n,r){return 1===arguments.length?St(t):new Dt(t,e,n,null==r?1:r)}function Dt(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}function Et(t){return((t=Math.max(0,Math.min(255,Math.round(t)||0)))<16?"0":"")+t.toString(16)}function Pt(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||1<=n?t=e=NaN:e<=0&&(t=NaN),new Ft(t,e,n,r)}function Ft(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}function Lt(t,e,n){return 255*(t<60?e+(n-e)*t/60:t<180?n:t<240?e+(n-e)*(240-t)/60:e)}st(lt,Tt,{displayable:function(){return this.rgb().displayable()},hex:function(){return this.rgb().hex()},toString:function(){return this.rgb()+""}}),st(Dt,Ut,dt(lt,{brighter:function(t){return t=null==t?ht:Math.pow(ht,t),new Dt(this.r*t,this.g*t,this.b*t,this.opacity)},darker:function(t){return t=null==t?.7:Math.pow(.7,t),new Dt(this.r*t,this.g*t,this.b*t,this.opacity)},rgb:function(){return this},displayable:function(){return 0<=this.r&&this.r<=255&&0<=this.g&&this.g<=255&&0<=this.b&&this.b<=255&&0<=this.opacity&&this.opacity<=1},hex:function(){return"#"+Et(this.r)+Et(this.g)+Et(this.b)},toString:function(){var t=this.opacity;return(1===(t=isNaN(t)?1:Math.max(0,Math.min(1,t)))?"rgb(":"rgba(")+Math.max(0,Math.min(255,Math.round(this.r)||0))+", "+Math.max(0,Math.min(255,Math.round(this.g)||0))+", "+Math.max(0,Math.min(255,Math.round(this.b)||0))+(1===t?")":", "+t+")")}})),st(Ft,function(t,e,n,r){return 1===arguments.length?function(t){if(t instanceof Ft)return new Ft(t.h,t.s,t.l,t.opacity);if(t instanceof lt||(t=Tt(t)),!t)return new Ft;if(t instanceof Ft)return t;var e=(t=t.rgb()).r/255,n=t.g/255,r=t.b/255,a=Math.min(e,n,r),f=Math.max(e,n,r),i=NaN,c=f-a,o=(f+a)/2;return c?(i=e===f?(n-r)/c+6*(nc&&(a=r.slice(c,a),u[o]?u[o]+=a:u[++o]=a),(e=e[0])===(n=n[0])?u[o]?u[o]+=n:u[++o]=n:(u[++o]=null,s.push({i:o,x:be(e,n)})),c=ge.lastIndex;return cn._time&&(r=n._time),(t=n)._next):(e=n._next,n._next=null,t?t._next=e:wn=e);xn=t,On(r)}(),kn=0}}function Hn(){var t=Un.now(),e=t-Cn;Tnzn)throw new Error("too late; already scheduled");return n}function Jn(t,e){var n=Gn(t,e);if(n.state>Xn)throw new Error("too late; already started");return n}function Gn(t,e){var n=t.__transition;if(!n||!(n=n[e]))throw new Error("transition not found");return n}function Kn(t,e,n){var r=t._id;return t.each(function(){var t=Jn(this,r);(t.value||(t.value={}))[e]=n.apply(this,arguments)}),function(t){return Gn(t,r).value[e]}}function tr(t,e){var n;return("number"==typeof e?be:e instanceof Tt?de:(n=Tt(e))?(e=n,de):ye)(t,e)}var er=mn.prototype.constructor;var nr=0;function rr(t,e,n,r){this._groups=t,this._parents=e,this._name=n,this._id=r}function ar(){return++nr}var fr=mn.prototype;rr.prototype=function(t){return mn().transition(t)}.prototype={constructor:rr,select:function(t){var e=this._name,n=this._id;"function"!=typeof t&&(t=He(t));for(var r=this._groups,a=r.length,f=new Array(a),i=0;iXn&&n.state<$n,n.state=Zn,n.timer.stop(),r&&n.on.call("interrupt",t,t.__data__,n.index,n.group),delete f[a]):i=!1;i&&delete t.__transition}}(this,t)})},mn.prototype.transition=function(t){var e,n;t=t instanceof rr?(e=t._id,t._name):(e=ar(),(n=ir).time=En(),null==t?null:t+"");for(var r=this._groups,a=r.length,f=0;fsr&&a){var l=n-f,h=r-i,b=c*c+o*o,p=l*l+h*h,g=Math.sqrt(b),y=Math.sqrt(d),_=a*Math.tan((or-Math.acos((b+d-p)/(2*g*y)))/2),v=_/y,m=_/g;Math.abs(v-1)>sr&&(this._+="L"+(t+v*u)+","+(e+v*s)),this._+="A"+a+","+a+",0,0,"+ +(u*hsr||Math.abs(this._y1-u)>sr)&&(this._+="L"+o+","+u),n&&(d<0&&(d=d%ur+ur),dr=a?c=!0:10===(e=r.charCodeAt(f++))?o=!0:13===e&&(o=!0,10===r.charCodeAt(f)&&++f),r.slice(n+1,t-1).replace(/""/g,'"')}for(;f=(f=(p+y)/2))?p=f:y=f,(s=n>=(i=(g+_)/2))?g=i:_=i,!(h=(a=h)[d=s<<1|u]))return a[d]=b,t;if(c=+t._x.call(null,h.data),o=+t._y.call(null,h.data),e===c&&n===o)return b.next=h,a?a[d]=b:t._root=b,t;for(;a=a?a[d]=new Array(4):t._root=new Array(4),(u=e>=(f=(p+y)/2))?p=f:y=f,(s=n>=(i=(g+_)/2))?g=i:_=i,(d=s<<1|u)==(l=(i<=o)<<1|f<=c););return a[l]=h,a[d]=b,t}function Ar(t,e,n,r,a){this.node=t,this.x0=e,this.y0=n,this.x1=r,this.y1=a}function Nr(t){return t[0]}function Tr(t){return t[1]}function Cr(t,e,n,r,a,f){this._x=t,this._y=e,this._x0=n,this._y0=r,this._x1=a,this._y1=f,this._root=void 0}function kr(t){for(var e={data:t.data},n=e;t=t.next;)n=n.next={data:t.data};return e}var Sr=function(t,e,n){var r=new Cr(null==e?Nr:e,null==n?Tr:n,NaN,NaN,NaN,NaN);return null==t?r:r.addAll(t)}.prototype=Cr.prototype;Sr.copy=function(){var t,e,n=new Cr(this._x,this._y,this._x0,this._y0,this._x1,this._y1),r=this._root;if(!r)return n;if(!r.length)return n._root=kr(r),n;for(t=[{source:r,target:n._root=new Array(4)}];r=t.pop();)for(var a=0;a<4;++a)(e=r.source[a])&&(e.length?t.push({source:e,target:r.target[a]=new Array(4)}):r.target[a]=kr(e));return n},Sr.add=function(t){var e=+this._x.call(null,t),n=+this._y.call(null,t);return Mr(this.cover(e,n),e,n,t)},Sr.addAll=function(t){var e,n,r,a,f=t.length,i=new Array(f),c=new Array(f),o=1/0,u=1/0,s=-1/0,d=-1/0;for(n=0;nl||(f=o.y0)>h||(i=o.x1)=(c=(b+g)/2))?b=c:g=c,(s=i>=(o=(p+y)/2))?p=o:y=o,!(h=(e=h)[d=s<<1|u]))return this;if(!h.length)break;(e[d+1&3]||e[d+2&3]||e[d+3&3])&&(n=e,l=d)}for(;h.data!==t;)if(!(h=(r=h).next))return this;return(a=h.next)&&delete h.next,r?a?r.next=a:delete r.next:e?(a?e[d]=a:delete e[d],(h=e[0]||e[1]||e[2]||e[3])&&h===(e[3]||e[2]||e[1]||e[0])&&!h.length&&(n?n[l]=h:this._root=h)):this._root=a,this},Sr.removeAll=function(t){for(var e=0,n=t.length;e=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function Fr(t){return new Lr(t)}function Lr(t){if(!(e=Pr.exec(t)))throw new Error("invalid format: "+t);var e;this.fill=e[1]||" ",this.align=e[2]||">",this.sign=e[3]||"-",this.symbol=e[4]||"",this.zero=!!e[5],this.width=e[6]&&+e[6],this.comma=!!e[7],this.precision=e[8]&&+e[8].slice(1),this.trim=!!e[9],this.type=e[10]||""}function Yr(t,e){var n=Ur(t,e);if(!n)return t+"";var r=n[0],a=n[1];return a<0?"0."+new Array(-a).join("0")+r:r.length>a+1?r.slice(0,a+1)+"."+r.slice(a+1):r+new Array(a-r.length+2).join("0")}Fr.prototype=Lr.prototype,Lr.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(null==this.width?"":Math.max(1,0|this.width))+(this.comma?",":"")+(null==this.precision?"":"."+Math.max(0,0|this.precision))+(this.trim?"~":"")+this.type};var Hr={"%":function(t,e){return(100*t).toFixed(e)},b:function(t){return Math.round(t).toString(2)},c:function(t){return t+""},d:function(t){return Math.round(t).toString(10)},e:function(t,e){return t.toExponential(e)},f:function(t,e){return t.toFixed(e)},g:function(t,e){return t.toPrecision(e)},o:function(t){return Math.round(t).toString(8)},p:function(t,e){return Yr(100*t,e)},r:Yr,s:function(t,e){var n=Ur(t,e);if(!n)return t+"";var r=n[0],a=n[1],f=a-(Er=3*Math.max(-8,Math.min(8,Math.floor(a/3))))+1,i=r.length;return f===i?r:ie));)f=c[a=(a+1)%c.length];return r.reverse().join(o)}):Or,r=t.currency,M=t.decimal,A=t.numerals?(e=t.numerals,function(t){return t.replace(/[0-9]/g,function(t){return e[+t]})}):Or,a=t.percent||"%";function i(t){var u=(t=Fr(t)).fill,s=t.align,d=t.sign,e=t.symbol,l=t.zero,h=t.width,b=t.comma,p=t.precision,g=t.trim,y=t.type;"n"===y?(b=!0,y="g"):Hr[y]||(null==p&&(p=12),g=!0,y="g"),(l||"0"===u&&"="===s)&&(l=!0,u="0",s="=");var _="$"===e?r[0]:"#"===e&&/[boxX]/.test(y)?"0"+y.toLowerCase():"",v="$"===e?r[1]:/[%p]/.test(y)?a:"",m=Hr[y],w=/[defgprs%]/.test(y);function n(t){var e,n,r,a=_,f=v;if("c"===y)f=m(t)+f,t="";else{var i=(t=+t)<0;if(t=m(Math.abs(t),p),g&&(t=function(t){t:for(var e,n=t.length,r=1,a=-1;r>1)+a+t+f+o.slice(c);break;default:t=o+a+t+f}return A(t)}return p=null==p?6:/[gprs]/.test(y)?Math.max(1,Math.min(21,p)):Math.max(0,Math.min(20,p)),n.toString=function(){return t+""},n}return{format:i,formatPrefix:function(t,e){var n=i(((t=Fr(t)).type="f",t)),r=3*Math.max(-8,Math.min(8,Math.floor(Dr(e)/3))),a=Math.pow(10,-r),f=zr[8+r/3];return function(t){return n(a*t)+f}}}}function Xr(){return new Rr}function Rr(){this.reset()}qr=Vr({decimal:".",thousands:",",grouping:[3],currency:["$",""]}),Ir=qr.format,jr=qr.formatPrefix,Rr.prototype={constructor:Rr,reset:function(){this.s=this.t=0},add:function(t){$r(Br,t,this.t),$r(this,Br.s,this.s),this.s?this.t+=Br.t:this.s=Br.t},valueOf:function(){return this.s}};var Br=new Rr;function $r(t,e,n){var r=t.s=e+n,a=r-e,f=r-a;t.t=e-f+(n-a)}Math.PI,Xr(),Xr(),Xr(),Xr(),Xr(),Xr(),Xr(),Xr();var Zr=Array.prototype,Wr=Zr.map,Qr=Zr.slice,Jr={name:"implicit"};function Gr(r){var f=gr(),i=[],a=Jr;function c(t){var e=t+"",n=f.get(e);if(!n){if(a!==Jr)return a;f.set(e,n=i.push(t))}return r[(n-1)%r.length]}return r=null==r?[]:Qr.call(r),c.domain=function(t){if(!arguments.length)return i.slice();i=[],f=gr();for(var e,n,r=-1,a=t.length;++r