/*
chroma.js - JavaScript library for color conversions

Copyright (c) 2011-2013, Gregor Aisch
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
   list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
   this list of conditions and the following disclaimer in the documentation
   and/or other materials provided with the distribution.

3. The name Gregor Aisch may not be used to endorse or promote products
   derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL GREGOR AISCH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

*/
(function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N;j=function(b,c,d,e){return new a(b,c,d,e)},"undefined"!=typeof module&&null!==module&&null!=module.exports&&(module.exports=j),"function"==typeof define&&define.amd?define([],function(){return j}):(J="undefined"!=typeof exports&&null!==exports?exports:this,J.chroma=j),j.color=function(b,c,d,e){return new a(b,c,d,e)},j.hsl=function(b,c,d,e){return new a(b,c,d,e,"hsl")},j.hsv=function(b,c,d,e){return new a(b,c,d,e,"hsv")},j.rgb=function(b,c,d,e){return new a(b,c,d,e,"rgb")},j.hex=function(b){return new a(b)},j.css=function(b){return new a(b)},j.lab=function(b,c,d){return new a(b,c,d,"lab")},j.lch=function(b,c,d){return new a(b,c,d,"lch")},j.hsi=function(b,c,d){return new a(b,c,d,"hsi")},j.gl=function(b,c,d,e){return new a(b,c,d,e,"gl")},j.num=function(b){return new a(b,"num")},j.random=function(){var b,c,d,e;for(c="0123456789abcdef",b="#",d=e=0;6>e;d=++e)b+=c.charAt(Math.floor(16*Math.random()));return new a(b)},j.interpolate=function(b,c,d,e){var f,g;return null==b||null==c?"#000":(("string"===(f=K(b))||"number"===f)&&(b=new a(b)),("string"===(g=K(c))||"number"===g)&&(c=new a(c)),b.interpolate(d,c,e))},j.mix=j.interpolate,j.contrast=function(b,c){var d,e,f,g;return("string"===(f=K(b))||"number"===f)&&(b=new a(b)),("string"===(g=K(c))||"number"===g)&&(c=new a(c)),d=b.luminance(),e=c.luminance(),d>e?(d+.05)/(e+.05):(e+.05)/(d+.05)},j.luminance=function(a){return j(a).luminance()},j._Color=a,a=function(){function a(){var a,b,c,d,e,f,g,h,i,j,l,m,n,s,u,v;for(f=this,c=[],h=0,d=arguments.length;d>h;h++)b=arguments[h],null!=b&&c.push(b);if(0===c.length)i=[255,0,255,1,"rgb"],s=i[0],u=i[1],v=i[2],a=i[3],e=i[4];else if("array"===K(c[0])){if(3===c[0].length)j=c[0],s=j[0],u=j[1],v=j[2],a=1;else{if(4!==c[0].length)throw"unknown input argument";l=c[0],s=l[0],u=l[1],v=l[2],a=l[3]}e=null!=(m=c[1])?m:"rgb"}else"string"===K(c[0])?(s=c[0],e="hex"):"object"===K(c[0])?(n=c[0]._rgb,s=n[0],u=n[1],v=n[2],a=n[3],e="rgb"):c.length<=2&&"number"===K(c[0])?(s=c[0],e="num"):c.length>=3&&(s=c[0],u=c[1],v=c[2]);3===c.length?(e="rgb",a=1):4===c.length?"string"===K(c[3])?(e=c[3],a=1):"number"===K(c[3])&&(e="rgb",a=c[3]):5===c.length&&(a=c[3],e=c[4]),null==a&&(a=1),"rgb"===e?f._rgb=[s,u,v,a]:"gl"===e?f._rgb=[255*s,255*u,255*v,a]:"hsl"===e?(f._rgb=q(s,u,v),f._rgb[3]=a):"hsv"===e?(f._rgb=r(s,u,v),f._rgb[3]=a):"hex"===e?f._rgb=o(s):"lab"===e?(f._rgb=t(s,u,v),f._rgb[3]=a):"lch"===e?(f._rgb=w(s,u,v),f._rgb[3]=a):"hsi"===e?(f._rgb=p(s,u,v),f._rgb[3]=a):"num"===e&&(f._rgb=A(s)),g=k(f._rgb)}return a.prototype.rgb=function(){return this._rgb.slice(0,3)},a.prototype.rgba=function(){return this._rgb},a.prototype.hex=function(){return B(this._rgb)},a.prototype.toString=function(){return this.name()},a.prototype.hsl=function(){return D(this._rgb)},a.prototype.hsv=function(){return E(this._rgb)},a.prototype.lab=function(){return F(this._rgb)},a.prototype.lch=function(){return G(this._rgb)},a.prototype.hsi=function(){return C(this._rgb)},a.prototype.gl=function(){return[this._rgb[0]/255,this._rgb[1]/255,this._rgb[2]/255,this._rgb[3]]},a.prototype.num=function(){return H(this._rgb)},a.prototype.luminance=function(b,c){var d,e,f,g;return null==c&&(c="rgb"),arguments.length?(0===b&&(this._rgb=[0,0,0,this._rgb[3]]),1===b&&(this._rgb=[255,255,255,this._rgb[3]]),d=y(this._rgb),e=1e-7,f=20,g=function(a,d){var h,i;return i=a.interpolate(.5,d,c),h=i.luminance(),Math.abs(b-h)<e||!f--?i:h>b?g(a,i):g(i,d)},this._rgb=(d>b?g(new a("black"),this):g(this,new a("white"))).rgba(),this):y(this._rgb)},a.prototype.name=function(){var a,b;a=this.hex();for(b in j.colors)if(a===j.colors[b])return b;return a},a.prototype.alpha=function(a){return arguments.length?(this._rgb[3]=a,this):this._rgb[3]},a.prototype.css=function(a){var b,c,d,e;return null==a&&(a="rgb"),c=this,d=c._rgb,3===a.length&&d[3]<1&&(a+="a"),"rgb"===a?a+"("+d.slice(0,3).map(Math.round).join(",")+")":"rgba"===a?a+"("+d.slice(0,3).map(Math.round).join(",")+","+d[3]+")":"hsl"===a||"hsla"===a?(b=c.hsl(),e=function(a){return Math.round(100*a)/100},b[0]=e(b[0]),b[1]=e(100*b[1])+"%",b[2]=e(100*b[2])+"%",4===a.length&&(b[3]=d[3]),a+"("+b.join(",")+")"):void 0},a.prototype.interpolate=function(b,c,d){var e,f,g,h,i,j,k,l,m,n,o,p,q,r;if(l=this,null==d&&(d="rgb"),"string"===K(c)&&(c=new a(c)),"hsl"===d||"hsv"===d||"lch"===d||"hsi"===d)"hsl"===d?(q=l.hsl(),r=c.hsl()):"hsv"===d?(q=l.hsv(),r=c.hsv()):"hsi"===d?(q=l.hsi(),r=c.hsi()):"lch"===d&&(q=l.lch(),r=c.lch()),"h"===d.substr(0,1)?(g=q[0],o=q[1],j=q[2],h=r[0],p=r[1],k=r[2]):(j=q[0],o=q[1],g=q[2],k=r[0],p=r[1],h=r[2]),isNaN(g)||isNaN(h)?isNaN(g)?isNaN(h)?f=Number.NaN:(f=h,1!==j&&0!==j||"hsv"===d||(n=p)):(f=g,1!==k&&0!==k||"hsv"===d||(n=o)):(e=h>g&&h-g>180?h-(g+360):g>h&&g-h>180?h+360-g:h-g,f=g+b*e),null==n&&(n=o+b*(p-o)),i=j+b*(k-j),m="h"===d.substr(0,1)?new a(f,n,i,d):new a(i,n,f,d);else if("rgb"===d)q=l._rgb,r=c._rgb,m=new a(q[0]+b*(r[0]-q[0]),q[1]+b*(r[1]-q[1]),q[2]+b*(r[2]-q[2]),d);else if("num"===d)c instanceof a||(c=new a(c,d)),q=l._rgb,r=c._rgb,m=new a((q[0]+b*(r[0]-q[0])<<16)+(q[1]+b*(r[1]-q[1])<<8)+(q[2]+b*(r[2]-q[2])&255),d);else{if("lab"!==d)throw"color mode "+d+" is not supported";q=l.lab(),r=c.lab(),m=new a(q[0]+b*(r[0]-q[0]),q[1]+b*(r[1]-q[1]),q[2]+b*(r[2]-q[2]),d)}return m.alpha(l.alpha()+b*(c.alpha()-l.alpha())),m},a.prototype.premultiply=function(){var a,b;return b=this.rgb(),a=this.alpha(),j(b[0]*a,b[1]*a,b[2]*a,a)},a.prototype.darken=function(a){var b,c;return null==a&&(a=20),c=this,b=c.lch(),b[0]-=a,j.lch(b).alpha(c.alpha())},a.prototype.darker=function(a){return this.darken(a)},a.prototype.brighten=function(a){return null==a&&(a=20),this.darken(-a)},a.prototype.brighter=function(a){return this.brighten(a)},a.prototype.saturate=function(a){var b,c;return null==a&&(a=20),c=this,b=c.lch(),b[1]+=a,j.lch(b).alpha(c.alpha())},a.prototype.desaturate=function(a){return null==a&&(a=20),this.saturate(-a)},a}(),k=function(a){var b;for(b in a)3>b?(a[b]<0&&(a[b]=0),a[b]>255&&(a[b]=255)):3===b&&(a[b]<0&&(a[b]=0),a[b]>1&&(a[b]=1));return a},n=function(a){var b,c,d,e,f,g,h,i;if(a=a.toLowerCase(),null!=j.colors&&j.colors[a])return o(j.colors[a]);if(f=a.match(/rgb\(\s*(\-?\d+),\s*(\-?\d+)\s*,\s*(\-?\d+)\s*\)/)){for(h=f.slice(1,4),e=g=0;2>=g;e=++g)h[e]=+h[e];h[3]=1}else if(f=a.match(/rgba\(\s*(\-?\d+),\s*(\-?\d+)\s*,\s*(\-?\d+)\s*,\s*([01]|[01]?\.\d+)\)/))for(h=f.slice(1,5),e=i=0;3>=i;e=++i)h[e]=+h[e];else if(f=a.match(/rgb\(\s*(\-?\d+(?:\.\d+)?)%,\s*(\-?\d+(?:\.\d+)?)%\s*,\s*(\-?\d+(?:\.\d+)?)%\s*\)/)){for(h=f.slice(1,4),e=b=0;2>=b;e=++b)h[e]=Math.round(2.55*h[e]);h[3]=1}else if(f=a.match(/rgba\(\s*(\-?\d+(?:\.\d+)?)%,\s*(\-?\d+(?:\.\d+)?)%\s*,\s*(\-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)/)){for(h=f.slice(1,5),e=c=0;2>=c;e=++c)h[e]=Math.round(2.55*h[e]);h[3]=+h[3]}else(f=a.match(/hsl\(\s*(\-?\d+(?:\.\d+)?),\s*(\-?\d+(?:\.\d+)?)%\s*,\s*(\-?\d+(?:\.\d+)?)%\s*\)/))?(d=f.slice(1,4),d[1]*=.01,d[2]*=.01,h=q(d),h[3]=1):(f=a.match(/hsla\(\s*(\-?\d+(?:\.\d+)?),\s*(\-?\d+(?:\.\d+)?)%\s*,\s*(\-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)/))&&(d=f.slice(1,4),d[1]*=.01,d[2]*=.01,h=q(d),h[3]=+f[4]);return h},o=function(a){var b,c,d,e,f,g;if(a.match(/^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/))return(4===a.length||7===a.length)&&(a=a.substr(1)),3===a.length&&(a=a.split(""),a=a[0]+a[0]+a[1]+a[1]+a[2]+a[2]),g=parseInt(a,16),e=g>>16,d=g>>8&255,c=255&g,[e,d,c,1];if(a.match(/^#?([A-Fa-f0-9]{8})$/))return 9===a.length&&(a=a.substr(1)),g=parseInt(a,16),e=g>>24&255,d=g>>16&255,c=g>>8&255,b=255&g,[e,d,c,b];if(f=n(a))return f;throw"unknown color: "+a},p=function(a,b,e){var f,g,h,i;return i=L(arguments),a=i[0],b=i[1],e=i[2],a/=360,1/3>a?(f=(1-b)/3,h=(1+b*m(d*a)/m(c-d*a))/3,g=1-(f+h)):2/3>a?(a-=1/3,h=(1-b)/3,g=(1+b*m(d*a)/m(c-d*a))/3,f=1-(h+g)):(a-=2/3,g=(1-b)/3,f=(1+b*m(d*a)/m(c-d*a))/3,h=1-(g+f)),h=x(e*h*3),g=x(e*g*3),f=x(e*f*3),[255*h,255*g,255*f]},q=function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n;if(i=L(arguments),d=i[0],k=i[1],f=i[2],0===k)h=c=a=255*f;else{for(n=[0,0,0],b=[0,0,0],m=.5>f?f*(1+k):f+k-f*k,l=2*f-m,d/=360,n[0]=d+1/3,n[1]=d,n[2]=d-1/3,e=g=0;2>=g;e=++g)n[e]<0&&(n[e]+=1),n[e]>1&&(n[e]-=1),6*n[e]<1?b[e]=l+6*(m-l)*n[e]:2*n[e]<1?b[e]=m:3*n[e]<2?b[e]=l+(m-l)*(2/3-n[e])*6:b[e]=l;j=[Math.round(255*b[0]),Math.round(255*b[1]),Math.round(255*b[2])],h=j[0],c=j[1],a=j[2]}return[h,c,a]},r=function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r;if(i=L(arguments),d=i[0],p=i[1],r=i[2],r*=255,0===p)h=c=a=r;else switch(360===d&&(d=0),d>360&&(d-=360),0>d&&(d+=360),d/=60,e=Math.floor(d),b=d-e,f=r*(1-p),g=r*(1-p*b),q=r*(1-p*(1-b)),e){case 0:j=[r,q,f],h=j[0],c=j[1],a=j[2];break;case 1:k=[g,r,f],h=k[0],c=k[1],a=k[2];break;case 2:l=[f,r,q],h=l[0],c=l[1],a=l[2];break;case 3:m=[f,g,r],h=m[0],c=m[1],a=m[2];break;case 4:n=[q,f,r],h=n[0],c=n[1],a=n[2];break;case 5:o=[r,f,g],h=o[0],c=o[1],a=o[2]}return h=Math.round(h),c=Math.round(c),a=Math.round(a),[h,c,a]},b=18,e=.95047,f=1,g=1.08883,s=function(){var a,b,c,d,e,f;return f=L(arguments),e=f[0],a=f[1],b=f[2],c=Math.sqrt(a*a+b*b),d=(Math.atan2(b,a)/Math.PI*180+360)%360,[e,c,d]},t=function(a,b,c){var d,h,i,j,k,l,m;return void 0!==a&&3===a.length&&(i=a,a=i[0],b=i[1],c=i[2]),void 0!==a&&3===a.length&&(j=a,a=j[0],b=j[1],c=j[2]),l=(a+16)/116,k=l+b/500,m=l-c/200,k=u(k)*e,l=u(l)*f,m=u(m)*g,h=N(3.2404542*k-1.5371385*l-.4985314*m),d=N(-.969266*k+1.8760108*l+.041556*m),c=N(.0556434*k-.2040259*l+1.0572252*m),[x(h,0,255),x(d,0,255),x(c,0,255),1]},u=function(a){return a>.206893034?a*a*a:(a-4/29)/7.787037},N=function(a){return Math.round(255*(.00304>=a?12.92*a:1.055*Math.pow(a,1/2.4)-.055))},v=function(){var a,b,c,d;return d=L(arguments),c=d[0],a=d[1],b=d[2],b=b*Math.PI/180,[c,Math.cos(b)*a,Math.sin(b)*a]},w=function(a,b,c){var d,e,f,g,h,i,j;return i=v(a,b,c),d=i[0],e=i[1],f=i[2],j=t(d,e,f),h=j[0],g=j[1],f=j[2],[x(h,0,255),x(g,0,255),x(f,0,255)]},y=function(a,b,c){var d;return d=L(arguments),a=d[0],b=d[1],c=d[2],a=z(a),b=z(b),c=z(c),.2126*a+.7152*b+.0722*c},z=function(a){return a/=255,.03928>=a?a/12.92:Math.pow((a+.055)/1.055,2.4)},A=function(a){var b,c,d;if("number"===K(a)&&a>=0&&16777215>=a)return d=a>>16,c=a>>8&255,b=255&a,[d,c,b,1];throw"unknown num color: "+a},B=function(){var a,b,c,d,e,f;return d=L(arguments),c=d[0],b=d[1],a=d[2],f=c<<16|b<<8|a,e="000000"+f.toString(16),"#"+e.substr(e.length-6)},C=function(){var a,b,c,d,e,f,g,h,i;return h=L(arguments),g=h[0],c=h[1],b=h[2],a=2*Math.PI,g/=255,c/=255,b/=255,f=Math.min(g,c,b),e=(g+c+b)/3,i=1-f/e,0===i?d=0:(d=(g-c+(g-b))/2,d/=Math.sqrt((g-c)*(g-c)+(g-b)*(c-b)),d=Math.acos(d),b>c&&(d=a-d),d/=a),[360*d,i,e]},D=function(a,b,c){var d,e,f,g,h,i;return void 0!==a&&a.length>=3&&(h=a,a=h[0],b=h[1],c=h[2]),a/=255,b/=255,c/=255,g=Math.min(a,b,c),f=Math.max(a,b,c),e=(f+g)/2,f===g?(i=0,d=Number.NaN):i=.5>e?(f-g)/(f+g):(f-g)/(2-f-g),a===f?d=(b-c)/(f-g):b===f?d=2+(c-a)/(f-g):c===f&&(d=4+(a-b)/(f-g)),d*=60,0>d&&(d+=360),[d,i,e]},E=function(){var a,b,c,d,e,f,g,h,i,j;return h=L(arguments),g=h[0],c=h[1],a=h[2],f=Math.min(g,c,a),e=Math.max(g,c,a),b=e-f,j=e/255,0===e?(d=Number.NaN,i=0):(i=b/e,g===e&&(d=(c-a)/b),c===e&&(d=2+(a-g)/b),a===e&&(d=4+(g-c)/b),d*=60,0>d&&(d+=360)),[d,i,j]},F=function(){var a,b,c,d,h,i,j;return d=L(arguments),c=d[0],b=d[1],a=d[2],c=I(c),b=I(b),a=I(a),h=M((.4124564*c+.3575761*b+.1804375*a)/e),i=M((.2126729*c+.7151522*b+.072175*a)/f),j=M((.0193339*c+.119192*b+.9503041*a)/g),[116*i-16,500*(h-i),200*(i-j)]},I=function(a){return(a/=255)<=.04045?a/12.92:Math.pow((a+.055)/1.055,2.4)},M=function(a){return a>.008856?Math.pow(a,1/3):7.787037*a+4/29},G=function(){var a,b,c,d,e,f,g;return f=L(arguments),e=f[0],c=f[1],b=f[2],g=F(e,c,b),d=g[0],a=g[1],b=g[2],s(d,a,b)},H=function(){var a,b,c,d;return d=L(arguments),c=d[0],b=d[1],a=d[2],(c<<16)+(b<<8)+a},j.scale=function(a,b){var c,d,e,f,g,h,i,k,l,m,n,o,p,q,r,s,t,u,v,w,x;return k="rgb",l=j("#ccc"),p=0,g=!1,f=[0,1],d=[],n=!1,o=[],i=0,h=1,e=!1,m=0,c={},v=function(a,b){var c,e,f,g,h,i,k;if(null==a&&(a=["#ddd","#222"]),null!=a&&"string"===K(a)&&null!=(null!=(g=j.brewer)?g[a]:void 0)&&(a=j.brewer[a]),"array"===K(a)){for(a=a.slice(0),c=f=0,h=a.length-1;h>=0?h>=f:f>=h;c=h>=0?++f:--f)e=a[c],"string"===K(e)&&(a[c]=j(e));if(null!=b)o=b;else for(o=[],c=k=0,i=a.length-1;i>=0?i>=k:k>=i;c=i>=0?++k:--k)o.push(c/(a.length-1))}return u(),d=a},w=function(a){return null==a&&(a=[]),f=a,i=a[0],h=a[a.length-1],u(),m=2===a.length?0:a.length-1},s=function(a){var b,c;if(null!=f){for(c=f.length-1,b=0;c>b&&a>=f[b];)b++;return b-1}return 0},x=function(a){return a},q=function(a){var b,c,d,e,g;return g=a,f.length>2&&(e=f.length-1,b=s(a),d=f[0]+(f[1]-f[0])*(0+.5*p),c=f[e-1]+(f[e]-f[e-1])*(1-.5*p),g=i+(f[b]+.5*(f[b+1]-f[b])-d)/(c-d)*(h-i)),g},t=function(a,b){var e,g,n,p,q,r,t,u,v;if(null==b&&(b=!1),isNaN(a))return l;if(b?v=a:f.length>2?(e=s(a),v=e/(m-1)):(v=n=i!==h?(a-i)/(h-i):0,v=n=(a-i)/(h-i),v=Math.min(1,Math.max(0,v))),b||(v=x(v)),q=Math.floor(1e4*v),c[q])g=c[q];else{if("array"===K(d))for(p=r=0,u=o.length-1;u>=0?u>=r:r>=u;p=u>=0?++r:--r){if(t=o[p],t>=v){g=d[p];break}if(v>=t&&p===o.length-1){g=d[p];break}if(v>t&&v<o[p+1]){v=(v-t)/(o[p+1]-t),g=j.interpolate(d[p],d[p+1],v,k);break}}else"function"===K(d)&&(g=d(v));c[q]=g}return g},u=function(){return c={}},v(a,b),r=function(a){var b;return b=t(a),n&&b[n]?b[n]():b},r.domain=function(a,b,c,d){var e;return null==c&&(c="e"),arguments.length?(null!=b&&(e=j.analyze(a,d),a=0===b?[e.min,e.max]:j.limits(e,c,b)),w(a),r):f},r.mode=function(a){return arguments.length?(k=a,u(),r):k},r.range=function(a,b){return v(a,b),r},r.out=function(a){return n=a,r},r.spread=function(a){return arguments.length?(p=a,r):p},r.correctLightness=function(a){return arguments.length?(e=a,u(),x=e?function(a){var b,c,d,e,f,g,h,i,j;for(b=t(0,!0).lab()[0],c=t(1,!0).lab()[0],h=b>c,d=t(a,!0).lab()[0],f=b+(c-b)*a,e=d-f,i=0,j=1,g=20;Math.abs(e)>.01&&g-->0;)!function(){return h&&(e*=-1),0>e?(i=a,a+=.5*(j-a)):(j=a,a+=.5*(i-a)),d=t(a,!0).lab()[0],e=d-f}();return a}:function(a){return a},r):e},r.colors=function(b){var c,d,e,g,h,i;if(null==b&&(b="hex"),a=[],h=[],f.length>2)for(c=e=1,g=f.length;g>=1?g>e:e>g;c=g>=1?++e:--e)h.push(.5*(f[c-1]+f[c]));else h=f;for(i=0,d=h.length;d>i;i++)c=h[i],a.push(r(c)[b]());return a},r},null==j.scales&&(j.scales={}),j.scales.cool=function(){return j.scale([j.hsl(180,1,.9),j.hsl(250,.7,.4)])},j.scales.hot=function(){return j.scale(["#000","#f00","#ff0","#fff"],[0,.25,.75,1]).mode("rgb")},j.analyze=function(a,b,c){var d,e,f,g,h,i,k;if(h={min:Number.MAX_VALUE,max:-1*Number.MAX_VALUE,sum:0,values:[],count:0},null==c&&(c=function(){return!0}),d=function(a){null==a||isNaN(a)||(h.values.push(a),h.sum+=a,a<h.min&&(h.min=a),a>h.max&&(h.max=a),h.count+=1)},k=function(a,e){return c(a,e)?d(null!=b&&"function"===K(b)?b(a):null!=b&&"string"===K(b)||"number"===K(b)?a[b]:a):void 0},"array"===K(a))for(g=0,f=a.length;f>g;g++)i=a[g],k(i);else for(e in a)i=a[e],k(i,e);return h.domain=[h.min,h.max],h.limits=function(a,b){return j.limits(h,a,b)},h},j.limits=function(a,b,c){var d,e,f,g,h,i,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,$,_,aa,ba,ca,da,ea,fa,ga;if(null==b&&(b="equal"),null==c&&(c=7),"array"===K(a)&&(a=j.analyze(a)),D=a.min,B=a.max,ca=a.sum,fa=a.values.sort(function(a,b){return a-b}),A=[],"c"===b.substr(0,1)&&(A.push(D),A.push(B)),"e"===b.substr(0,1)){for(A.push(D),x=J=1,O=c-1;O>=1?O>=J:J>=O;x=O>=1?++J:--J)A.push(D+x/c*(B-D));A.push(B)}else if("l"===b.substr(0,1)){if(0>=D)throw"Logarithmic scales are only possible for values > 0";for(E=Math.LOG10E*Math.log(D),C=Math.LOG10E*Math.log(B),A.push(D),x=ga=1,P=c-1;P>=1?P>=ga:ga>=P;x=P>=1?++ga:--ga)A.push(Math.pow(10,E+x/c*(C-E)));A.push(B)}else if("q"===b.substr(0,1)){for(A.push(D),x=d=1,V=c-1;V>=1?V>=d:d>=V;x=V>=1?++d:--d)L=fa.length*x/c,M=Math.floor(L),M===L?A.push(fa[M]):(N=L-M,A.push(fa[M]*N+fa[M+1]*(1-N)));A.push(B)}else if("k"===b.substr(0,1)){for(G=fa.length,r=new Array(G),v=new Array(c),ba=!0,H=0,t=null,t=[],t.push(D),x=e=1,W=c-1;W>=1?W>=e:e>=W;x=W>=1?++e:--e)t.push(D+x/c*(B-D));for(t.push(B);ba;){for(y=f=0,X=c-1;X>=0?X>=f:f>=X;y=X>=0?++f:--f)v[y]=0;for(x=g=0,Y=G-1;Y>=0?Y>=g:g>=Y;x=Y>=0?++g:--g){for(ea=fa[x],F=Number.MAX_VALUE,y=h=0,Z=c-1;Z>=0?Z>=h:h>=Z;y=Z>=0?++h:--h)w=Math.abs(t[y]-ea),F>w&&(F=w,s=y);v[s]++,r[x]=s}for(I=new Array(c),y=i=0,$=c-1;$>=0?$>=i:i>=$;y=$>=0?++i:--i)I[y]=null;for(x=k=0,_=G-1;_>=0?_>=k:k>=_;x=_>=0?++k:--k)u=r[x],null===I[u]?I[u]=fa[x]:I[u]+=fa[x];for(y=l=0,aa=c-1;aa>=0?aa>=l:l>=aa;y=aa>=0?++l:--l)I[y]*=1/v[y];for(ba=!1,y=m=0,Q=c-1;Q>=0?Q>=m:m>=Q;y=Q>=0?++m:--m)if(I[y]!==t[x]){ba=!0;break}t=I,H++,H>200&&(ba=!1)}for(z={},y=n=0,R=c-1;R>=0?R>=n:n>=R;y=R>=0?++n:--n)z[y]=[];for(x=o=0,S=G-1;S>=0?S>=o:o>=S;x=S>=0?++o:--o)u=r[x],z[u].push(fa[x]);for(da=[],y=p=0,T=c-1;T>=0?T>=p:p>=T;y=T>=0?++p:--p)da.push(z[y][0]),da.push(z[y][z[y].length-1]);for(da=da.sort(function(a,b){return a-b}),A.push(da[0]),x=q=1,U=da.length-1;U>=q;x=q+=2)isNaN(da[x])||A.push(da[x])}return A},j.brewer=i={OrRd:["#fff7ec","#fee8c8","#fdd49e","#fdbb84","#fc8d59","#ef6548","#d7301f","#b30000","#7f0000"],PuBu:["#fff7fb","#ece7f2","#d0d1e6","#a6bddb","#74a9cf","#3690c0","#0570b0","#045a8d","#023858"],BuPu:["#f7fcfd","#e0ecf4","#bfd3e6","#9ebcda","#8c96c6","#8c6bb1","#88419d","#810f7c","#4d004b"],Oranges:["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"],BuGn:["#f7fcfd","#e5f5f9","#ccece6","#99d8c9","#66c2a4","#41ae76","#238b45","#006d2c","#00441b"],YlOrBr:["#ffffe5","#fff7bc","#fee391","#fec44f","#fe9929","#ec7014","#cc4c02","#993404","#662506"],YlGn:["#ffffe5","#f7fcb9","#d9f0a3","#addd8e","#78c679","#41ab5d","#238443","#006837","#004529"],Reds:["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"],RdPu:["#fff7f3","#fde0dd","#fcc5c0","#fa9fb5","#f768a1","#dd3497","#ae017e","#7a0177","#49006a"],Greens:["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"],YlGnBu:["#ffffd9","#edf8b1","#c7e9b4","#7fcdbb","#41b6c4","#1d91c0","#225ea8","#253494","#081d58"],Purples:["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"],GnBu:["#f7fcf0","#e0f3db","#ccebc5","#a8ddb5","#7bccc4","#4eb3d3","#2b8cbe","#0868ac","#084081"],Greys:["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"],YlOrRd:["#ffffcc","#ffeda0","#fed976","#feb24c","#fd8d3c","#fc4e2a","#e31a1c","#bd0026","#800026"],PuRd:["#f7f4f9","#e7e1ef","#d4b9da","#c994c7","#df65b0","#e7298a","#ce1256","#980043","#67001f"],Blues:["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"],PuBuGn:["#fff7fb","#ece2f0","#d0d1e6","#a6bddb","#67a9cf","#3690c0","#02818a","#016c59","#014636"],Spectral:["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"],RdYlGn:["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"],RdBu:["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"],PiYG:["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"],PRGn:["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"],RdYlBu:["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"],BrBG:["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"],RdGy:["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#ffffff","#e0e0e0","#bababa","#878787","#4d4d4d","#1a1a1a"],PuOr:["#7f3b08","#b35806","#e08214","#fdb863","#fee0b6","#f7f7f7","#d8daeb","#b2abd2","#8073ac","#542788","#2d004b"],Set2:["#66c2a5","#fc8d62","#8da0cb","#e78ac3","#a6d854","#ffd92f","#e5c494","#b3b3b3"],Accent:["#7fc97f","#beaed4","#fdc086","#ffff99","#386cb0","#f0027f","#bf5b17","#666666"],Set1:["#e41a1c","#377eb8","#4daf4a","#984ea3","#ff7f00","#ffff33","#a65628","#f781bf","#999999"],Set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],Dark2:["#1b9e77","#d95f02","#7570b3","#e7298a","#66a61e","#e6ab02","#a6761d","#666666"],Paired:["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99","#e31a1c","#fdbf6f","#ff7f00","#cab2d6","#6a3d9a","#ffff99","#b15928"],Pastel2:["#b3e2cd","#fdcdac","#cbd5e8","#f4cae4","#e6f5c9","#fff2ae","#f1e2cc","#cccccc"],Pastel1:["#fbb4ae","#b3cde3","#ccebc5","#decbe4","#fed9a6","#ffffcc","#e5d8bd","#fddaec","#f2f2f2"]},j.colors=l={indigo:"#4b0082",gold:"#ffd700",hotpink:"#ff69b4",firebrick:"#b22222",indianred:"#cd5c5c",yellow:"#ffff00",mistyrose:"#ffe4e1",darkolivegreen:"#556b2f",olive:"#808000",darkseagreen:"#8fbc8f",pink:"#ffc0cb",tomato:"#ff6347",lightcoral:"#f08080",orangered:"#ff4500",navajowhite:"#ffdead",lime:"#00ff00",palegreen:"#98fb98",darkslategrey:"#2f4f4f",greenyellow:"#adff2f",burlywood:"#deb887",seashell:"#fff5ee",mediumspringgreen:"#00fa9a",fuchsia:"#ff00ff",papayawhip:"#ffefd5",blanchedalmond:"#ffebcd",chartreuse:"#7fff00",dimgray:"#696969",black:"#000000",peachpuff:"#ffdab9",springgreen:"#00ff7f",aquamarine:"#7fffd4",white:"#ffffff",orange:"#ffa500",lightsalmon:"#ffa07a",darkslategray:"#2f4f4f",brown:"#a52a2a",ivory:"#fffff0",dodgerblue:"#1e90ff",peru:"#cd853f",lawngreen:"#7cfc00",chocolate:"#d2691e",crimson:"#dc143c",forestgreen:"#228b22",darkgrey:"#a9a9a9",lightseagreen:"#20b2aa",cyan:"#00ffff",mintcream:"#f5fffa",silver:"#c0c0c0",antiquewhite:"#faebd7",mediumorchid:"#ba55d3",skyblue:"#87ceeb",gray:"#808080",darkturquoise:"#00ced1",goldenrod:"#daa520",darkgreen:"#006400",floralwhite:"#fffaf0",darkviolet:"#9400d3",darkgray:"#a9a9a9",moccasin:"#ffe4b5",saddlebrown:"#8b4513",grey:"#808080",darkslateblue:"#483d8b",lightskyblue:"#87cefa",lightpink:"#ffb6c1",mediumvioletred:"#c71585",slategrey:"#708090",red:"#ff0000",deeppink:"#ff1493",limegreen:"#32cd32",darkmagenta:"#8b008b",palegoldenrod:"#eee8aa",plum:"#dda0dd",turquoise:"#40e0d0",lightgrey:"#d3d3d3",lightgoldenrodyellow:"#fafad2",darkgoldenrod:"#b8860b",lavender:"#e6e6fa",maroon:"#800000",yellowgreen:"#9acd32",sandybrown:"#f4a460",thistle:"#d8bfd8",violet:"#ee82ee",navy:"#000080",magenta:"#ff00ff",dimgrey:"#696969",tan:"#d2b48c",rosybrown:"#bc8f8f",olivedrab:"#6b8e23",blue:"#0000ff",lightblue:"#add8e6",ghostwhite:"#f8f8ff",honeydew:"#f0fff0",cornflowerblue:"#6495ed",slateblue:"#6a5acd",linen:"#faf0e6",darkblue:"#00008b",powderblue:"#b0e0e6",seagreen:"#2e8b57",darkkhaki:"#bdb76b",snow:"#fffafa",sienna:"#a0522d",mediumblue:"#0000cd",royalblue:"#4169e1",lightcyan:"#e0ffff",green:"#008000",mediumpurple:"#9370db",midnightblue:"#191970",cornsilk:"#fff8dc",paleturquoise:"#afeeee",bisque:"#ffe4c4",slategray:"#708090",darkcyan:"#008b8b",khaki:"#f0e68c",wheat:"#f5deb3",teal:"#008080",darkorchid:"#9932cc",deepskyblue:"#00bfff",salmon:"#fa8072",darkred:"#8b0000",steelblue:"#4682b4",palevioletred:"#db7093",lightslategray:"#778899",aliceblue:"#f0f8ff",lightslategrey:"#778899",lightgreen:"#90ee90",orchid:"#da70d6",gainsboro:"#dcdcdc",mediumseagreen:"#3cb371",lightgray:"#d3d3d3",mediumturquoise:"#48d1cc",lemonchiffon:"#fffacd",cadetblue:"#5f9ea0",lightyellow:"#ffffe0",lavenderblush:"#fff0f5",coral:"#ff7f50",purple:"#800080",aqua:"#00ffff",whitesmoke:"#f5f5f5",mediumslateblue:"#7b68ee",darkorange:"#ff8c00",mediumaquamarine:"#66cdaa",darksalmon:"#e9967a",beige:"#f5f5dc",blueviolet:"#8a2be2",azure:"#f0ffff",lightsteelblue:"#b0c4de",oldlace:"#fdf5e6"},K=function(){var a,b,c,d,e;for(a={},e="Boolean Number String Function Array Date RegExp Undefined Null".split(" "),d=0,b=e.length;b>d;d++)c=e[d],a["[object "+c+"]"]=c.toLowerCase();return function(b){var c;return c=Object.prototype.toString.call(b),a[c]||"object"}}(),x=function(a,b,c){return null==b&&(b=0),null==c&&(c=1),b>a&&(a=b),a>c&&(a=c),a},L=function(a){return a.length>=3?a:a[0]},d=2*Math.PI,c=Math.PI/3,m=Math.cos,h=function(a){var b,c,d,e,f,g,i,k,l,m,n;return a=function(){var b,c,d;for(d=[],c=0,b=a.length;b>c;c++)e=a[c],d.push(j(e));return d}(),2===a.length?(l=function(){var b,c,d;for(d=[],c=0,b=a.length;b>c;c++)e=a[c],d.push(e.lab());return d}(),f=l[0],g=l[1],b=function(a){var b,c;return c=function(){var c,d;for(d=[],b=c=0;2>=c;b=++c)d.push(f[b]+a*(g[b]-f[b]));return d}(),j.lab.apply(j,c)}):3===a.length?(m=function(){var b,c,d;for(d=[],c=0,b=a.length;b>c;c++)e=a[c],d.push(e.lab());return d}(),f=m[0],g=m[1],i=m[2],b=function(a){var b,c;return c=function(){var c,d;for(d=[],b=c=0;2>=c;b=++c)d.push((1-a)*(1-a)*f[b]+2*(1-a)*a*g[b]+a*a*i[b]);return d}(),j.lab.apply(j,c)}):4===a.length?(n=function(){var b,c,d;for(d=[],c=0,b=a.length;b>c;c++)e=a[c],d.push(e.lab());return d}(),f=n[0],g=n[1],i=n[2],k=n[3],b=function(a){var b,c;return c=function(){var c,d;for(d=[],b=c=0;2>=c;b=++c)d.push((1-a)*(1-a)*(1-a)*f[b]+3*(1-a)*(1-a)*a*g[b]+3*(1-a)*a*a*i[b]+a*a*a*k[b]);return d}(),j.lab.apply(j,c)}):5===a.length&&(c=h(a.slice(0,3)),d=h(a.slice(2,5)),b=function(a){return.5>a?c(2*a):d(2*(a-.5))}),b},j.interpolate.bezier=h}).call(this);