!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.d3={})}(this,function(e){"use strict";function n(e,t){return e>>1;f(e[a],t)<0?n=a+1:r=a}return n},right:function(e,t,n,r){for(null==n&&(n=0),null==r&&(r=e.length);n>>1;0>8&15|t>>4&240,t>>4&15|240&t,(15&t)<<4|15&t,1):(t=we.exec(e))?Ue(parseInt(t[1],16)):(t=xe.exec(e))?new Pe(t[1],t[2],t[3],1):(t=Me.exec(e))?new Pe(255*t[1]/100,255*t[2]/100,255*t[3]/100,1):(t=Ae.exec(e))?De(t[1],t[2],t[3],t[4]):(t=Te.exec(e))?De(255*t[1]/100,255*t[2]/100,255*t[3]/100,t[4]):(t=Ne.exec(e))?He(t[1],t[2]/100,t[3]/100,1):(t=Ce.exec(e))?He(t[1],t[2]/100,t[3]/100,t[4]):ke.hasOwnProperty(e)?Ue(ke[e]):"transparent"===e?new Pe(NaN,NaN,NaN,0):null}function Ue(e){return new Pe(e>>16&255,e>>8&255,255&e,1)}function De(e,t,n,r){return r<=0&&(e=t=n=NaN),new Pe(e,t,n,r)}function Ee(e){return e instanceof pe||(e=Se(e)),e?new Pe((e=e.rgb()).r,e.g,e.b,e.opacity):new Pe}function Fe(e,t,n,r){return 1===arguments.length?Ee(e):new Pe(e,t,n,null==r?1:r)}function Pe(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}function Ye(e){return((e=Math.max(0,Math.min(255,Math.round(e)||0)))<16?"0":"")+e.toString(16)}function He(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||1<=n?e=t=NaN:t<=0&&(e=NaN),new Le(e,t,n,r)}function Le(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}function Oe(e,t,n){return 255*(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)}he(pe,Se,{displayable:function(){return this.rgb().displayable()},hex:function(){return this.rgb().hex()},toString:function(){return this.rgb()+""}}),he(Pe,Fe,be(pe,{brighter:function(e){return e=null==e?ge:Math.pow(ge,e),new Pe(this.r*e,this.g*e,this.b*e,this.opacity)},darker:function(e){return e=null==e?.7:Math.pow(.7,e),new Pe(this.r*e,this.g*e,this.b*e,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"#"+Ye(this.r)+Ye(this.g)+Ye(this.b)},toString:function(){var e=this.opacity;return(1===(e=isNaN(e)?1:Math.max(0,Math.min(1,e)))?"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===e?")":", "+e+")")}})),he(Le,function(e,t,n,r){return 1===arguments.length?function(e){if(e instanceof Le)return new Le(e.h,e.s,e.l,e.opacity);if(e instanceof pe||(e=Se(e)),!e)return new Le;if(e instanceof Le)return e;var t=(e=e.rgb()).r/255,n=e.g/255,r=e.b/255,a=Math.min(t,n,r),f=Math.max(t,n,r),i=NaN,c=f-a,o=(f+a)/2;return c?(i=t===f?(n-r)/c+6*(nc&&(a=r.slice(c,a),u[o]?u[o]+=a:u[++o]=a),(t=t[0])===(n=n[0])?u[o]?u[o]+=n:u[++o]=n:(u[++o]=null,s.push({i:o,x:yt(t,n)})),c=_t.lastIndex;return cn._time&&(r=n._time),(e=n)._next):(t=n._next,n._next=null,e?e._next=t:Pt=t);Yt=e,Gt(r)}(),zt=0}}function Jt(){var e=Vt.now(),t=e-qt;Itnn)throw new Error("too late; already scheduled");return n}function ln(e,t){var n=hn(e,t);if(n.state>an)throw new Error("too late; already started");return n}function hn(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function bn(e,t,n){var r=e._id;return e.each(function(){var e=ln(this,r);(e.value||(e.value={}))[t]=n.apply(this,arguments)}),function(e){return hn(e,r).value[t]}}function pn(e,t){var n;return("number"==typeof t?yt:t instanceof Se?bt:(n=Se(t))?(t=n,bt):mt)(e,t)}var gn=le.prototype.constructor;var yn=0;function vn(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function _n(){return++yn}var mn=le.prototype;vn.prototype=function(e){return le().transition(e)}.prototype={constructor:vn,select:function(e){var t=this._name,n=this._id;"function"!=typeof e&&(e=M(e));for(var r=this._groups,a=r.length,f=new Array(a),i=0;ian&&n.stateTn&&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),v=a*Math.tan((Mn-Math.acos((b+d-p)/(2*g*y)))/2),_=v/y,m=v/g;Math.abs(_-1)>Tn&&(this._+="L"+(e+_*u)+","+(t+_*s)),this._+="A"+a+","+a+",0,0,"+ +(u*hTn||Math.abs(this._y1-u)>Tn)&&(this._+="L"+o+","+u),n&&(d<0&&(d=d%An+An),Nn=a?c=!0:10===(t=r.charCodeAt(f++))?o=!0:13===t&&(o=!0,10===r.charCodeAt(f)&&++f),r.slice(n+1,e-1).replace(/""/g,'"')}for(;f=(f=(p+y)/2))?p=f:y=f,(s=n>=(i=(g+v)/2))?g=i:v=i,!(h=(a=h)[d=s<<1|u]))return a[d]=b,e;if(c=+e._x.call(null,h.data),o=+e._y.call(null,h.data),t===c&&n===o)return b.next=h,a?a[d]=b:e._root=b,e;for(;a=a?a[d]=new Array(4):e._root=new Array(4),(u=t>=(f=(p+y)/2))?p=f:y=f,(s=n>=(i=(g+v)/2))?g=i:v=i,(d=s<<1|u)==(l=(i<=o)<<1|f<=c););return a[l]=h,a[d]=b,e}function jn(e,t,n,r,a){this.node=e,this.x0=t,this.y0=n,this.x1=r,this.y1=a}function In(e){return e[0]}function qn(e){return e[1]}function zn(e,t,n,r,a,f){this._x=e,this._y=t,this._x0=n,this._y0=r,this._x1=a,this._y1=f,this._root=void 0}function Xn(e){for(var t={data:e.data},n=t;e=e.next;)n=n.next={data:e.data};return t}var Vn=function(e,t,n){var r=new zn(null==t?In:t,null==n?qn:n,NaN,NaN,NaN,NaN);return null==e?r:r.addAll(e)}.prototype=zn.prototype;Vn.copy=function(){var e,t,n=new zn(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=Xn(r),n;for(e=[{source:r,target:n._root=new Array(4)}];r=e.pop();)for(var a=0;a<4;++a)(t=r.source[a])&&(t.length?e.push({source:t,target:r.target[a]=new Array(4)}):r.target[a]=Xn(t));return n},Vn.add=function(e){var t=+this._x.call(null,e),n=+this._y.call(null,e);return On(this.cover(t,n),t,n,e)},Vn.addAll=function(e){var t,n,r,a,f=e.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=(t=h)[d=s<<1|u]))return this;if(!h.length)break;(t[d+1&3]||t[d+2&3]||t[d+3&3])&&(n=t,l=d)}for(;h.data!==e;)if(!(h=(r=h).next))return this;return(a=h.next)&&delete h.next,r?a?r.next=a:delete r.next:t?(a?t[d]=a:delete t[d],(h=t[0]||t[1]||t[2]||t[3])&&h===(t[3]||t[2]||t[1]||t[0])&&!h.length&&(n?n[l]=h:this._root=h)):this._root=a,this},Vn.removeAll=function(e){for(var t=0,n=e.length;t=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function Wn(e){return new Qn(e)}function Qn(e){if(!(t=Bn.exec(e)))throw new Error("invalid format: "+e);var t;this.fill=t[1]||" ",this.align=t[2]||">",this.sign=t[3]||"-",this.symbol=t[4]||"",this.zero=!!t[5],this.width=t[6]&&+t[6],this.comma=!!t[7],this.precision=t[8]&&+t[8].slice(1),this.trim=!!t[9],this.type=t[10]||""}function Jn(e,t){var n=Rn(e,t);if(!n)return e+"";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")}Wn.prototype=Qn.prototype,Qn.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 Gn={"%":function(e,t){return(100*e).toFixed(t)},b:function(e){return Math.round(e).toString(2)},c:function(e){return e+""},d:function(e){return Math.round(e).toString(10)},e:function(e,t){return e.toExponential(t)},f:function(e,t){return e.toFixed(t)},g:function(e,t){return e.toPrecision(t)},o:function(e){return Math.round(e).toString(8)},p:function(e,t){return Jn(100*e,t)},r:Jn,s:function(e,t){var n=Rn(e,t);if(!n)return e+"";var r=n[0],a=n[1],f=a-(Zn=3*Math.max(-8,Math.min(8,Math.floor(a/3))))+1,i=r.length;return f===i?r:it));)f=c[a=(a+1)%c.length];return r.reverse().join(o)}):Kn,r=e.currency,M=e.decimal,A=e.numerals?(t=e.numerals,function(e){return e.replace(/[0-9]/g,function(e){return t[+e]})}):Kn,a=e.percent||"%";function i(e){var u=(e=Wn(e)).fill,s=e.align,d=e.sign,t=e.symbol,l=e.zero,h=e.width,b=e.comma,p=e.precision,g=e.trim,y=e.type;"n"===y?(b=!0,y="g"):Gn[y]||(null==p&&(p=12),g=!0,y="g"),(l||"0"===u&&"="===s)&&(l=!0,u="0",s="=");var v="$"===t?r[0]:"#"===t&&/[boxX]/.test(y)?"0"+y.toLowerCase():"",_="$"===t?r[1]:/[%p]/.test(y)?a:"",m=Gn[y],w=/[defgprs%]/.test(y);function n(e){var t,n,r,a=v,f=_;if("c"===y)f=m(e)+f,e="";else{var i=(e=+e)<0;if(e=m(Math.abs(e),p),g&&(e=function(e){e:for(var t,n=e.length,r=1,a=-1;r>1)+a+e+f+o.slice(c);break;default:e=o+a+e+f}return A(e)}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 e+""},n}return{format:i,formatPrefix:function(e,t){var n=i(((e=Wn(e)).type="f",e)),r=3*Math.max(-8,Math.min(8,Math.floor($n(t)/3))),a=Math.pow(10,-r),f=rr[8+r/3];return function(e){return n(a*e)+f}}}}function fr(){return new ir}function ir(){this.reset()}er=ar({decimal:".",thousands:",",grouping:[3],currency:["$",""]}),tr=er.format,nr=er.formatPrefix,ir.prototype={constructor:ir,reset:function(){this.s=this.t=0},add:function(e){or(cr,e,this.t),or(this,cr.s,this.s),this.s?this.t+=cr.t:this.s=cr.t},valueOf:function(){return this.s}};var cr=new ir;function or(e,t,n){var r=e.s=t+n,a=r-t,f=r-a;e.t=t-f+(n-a)}Math.PI,fr(),fr(),fr(),fr(),fr(),fr(),fr(),fr();var ur=Array.prototype,sr=ur.map,dr=ur.slice,lr={name:"implicit"};function hr(r){var f=Dn(),i=[],a=lr;function c(e){var t=e+"",n=f.get(t);if(!n){if(a!==lr)return a;f.set(t,n=i.push(e))}return r[(n-1)%r.length]}return r=null==r?[]:dr.call(r),c.domain=function(e){if(!arguments.length)return i.slice();i=[],f=Dn();for(var t,n,r=-1,a=e.length;++r