=a.length)return n?n.call(i,o):r?o.sort(r):o;for(var l,c,u,h,d=-1,p=o.length,g=a[s++],v=new f;++d=a.length)return t;var n=[],i=o[r++];return t.forEach(function(t,i){n.push({key:t,values:e(i,r)})}),i?n.sort(function(t,e){return i(t.key,e.key)}):n}var r,n,i={},a=[],o=[];return i.map=function(e,r){return t(r,e,0)},i.entries=function(r){return e(t(co.map,r,0),0)},i.key=function(t){return a.push(t),i},i.sortKeys=function(t){return o[a.length-1]=t,i},i.sortValues=function(t){return r=t,i},i.rollup=function(t){return n=t,i},i},co.set=function(t){var e=new b;if(t)for(var r=0,n=t.length;n>r;++r)e.add(t[r]);return e},u(b,{has:p,add:function(t){return this._[h(t+="")]=!0,t},remove:g,values:v,size:m,empty:y,forEach:function(t){for(var e in this._)t.call(this,d(e))}}),co.behavior={},co.rebind=function(t,e){for(var r,n=1,i=arguments.length;++n=0&&(n=t.slice(r+1),t=t.slice(0,r)),t)return arguments.length<2?this[t].on(n):this[t].on(n,e);if(2===arguments.length){if(null==e)for(t in this)this.hasOwnProperty(t)&&this[t].on(n,null);return this}},co.event=null,co.requote=function(t){return t.replace(To,"\\$&")};var To=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g,Eo={}.__proto__?function(t,e){t.__proto__=e}:function(t,e){for(var r in e)t[r]=e[r]},Lo=function(t,e){return e.querySelector(t)},So=function(t,e){return e.querySelectorAll(t)},Co=function(t,e){var r=t.matches||t[w(t,"matchesSelector")];return(Co=function(t,e){return r.call(t,e)})(t,e)};"function"==typeof Sizzle&&(Lo=function(t,e){return Sizzle(t,e)[0]||null},So=Sizzle,Co=Sizzle.matchesSelector),co.selection=function(){return co.select(ho.documentElement)};var zo=co.selection.prototype=[];zo.select=function(t){var e,r,n,i,a=[];t=C(t);for(var o=-1,s=this.length;++o=0&&"xmlns"!==(r=t.slice(0,e))&&(t=t.slice(e+1)),Ro.hasOwnProperty(r)?{space:Ro[r],local:t}:t}},zo.attr=function(t,e){if(arguments.length<2){if("string"==typeof t){var r=this.node();return t=co.ns.qualify(t),t.local?r.getAttributeNS(t.space,t.local):r.getAttribute(t)}for(e in t)this.each(P(e,t[e]));return this}return this.each(P(t,e))},zo.classed=function(t,e){if(arguments.length<2){if("string"==typeof t){var r=this.node(),n=(t=I(t)).length,i=-1;if(e=r.classList){for(;++ii){if("string"!=typeof t){2>i&&(e="");for(r in t)this.each(F(r,t[r],e));return this}if(2>i){var a=this.node();return n(a).getComputedStyle(a,null).getPropertyValue(t)}r=""}return this.each(F(t,e,r))},zo.property=function(t,e){if(arguments.length<2){if("string"==typeof t)return this.node()[t];for(e in t)this.each(D(e,t[e]));return this}return this.each(D(t,e))},zo.text=function(t){return arguments.length?this.each("function"==typeof t?function(){var e=t.apply(this,arguments);this.textContent=null==e?"":e}:null==t?function(){this.textContent=""}:function(){this.textContent=t}):this.node().textContent},zo.html=function(t){return arguments.length?this.each("function"==typeof t?function(){var e=t.apply(this,arguments);this.innerHTML=null==e?"":e}:null==t?function(){this.innerHTML=""}:function(){this.innerHTML=t}):this.node().innerHTML},zo.append=function(t){return t=B(t),this.select(function(){return this.appendChild(t.apply(this,arguments))})},zo.insert=function(t,e){return t=B(t),e=C(e),this.select(function(){return this.insertBefore(t.apply(this,arguments),e.apply(this,arguments)||null)})},zo.remove=function(){return this.each(U)},zo.data=function(t,e){function r(t,r){var n,i,a,o=t.length,u=r.length,h=Math.min(o,u),d=new Array(u),p=new Array(u),g=new Array(o);if(e){var v,m=new f,y=new Array(o);for(n=-1;++nn;++n)p[n]=V(r[n]);for(;o>n;++n)g[n]=t[n]}p.update=d,p.parentNode=d.parentNode=g.parentNode=t.parentNode,s.push(p),l.push(d),c.push(g)}var n,i,a=-1,o=this.length;if(!arguments.length){for(t=new Array(o=(n=this[0]).length);++aa;a++){i.push(e=[]),e.parentNode=(r=this[a]).parentNode;for(var s=0,l=r.length;l>s;s++)(n=r[s])&&t.call(n,n.__data__,s,a)&&e.push(n)}return S(i)},zo.order=function(){for(var t=-1,e=this.length;++t=0;)(r=n[i])&&(a&&a!==r.nextSibling&&a.parentNode.insertBefore(r,a),a=r);return this},zo.sort=function(t){t=H.apply(this,arguments);for(var e=-1,r=this.length;++et;t++)for(var r=this[t],n=0,i=r.length;i>n;n++){var a=r[n];if(a)return a}return null},zo.size=function(){var t=0;return G(this,function(){++t}),t};var Oo=[];co.selection.enter=Y,co.selection.enter.prototype=Oo,Oo.append=zo.append,Oo.empty=zo.empty,Oo.node=zo.node,Oo.call=zo.call,Oo.size=zo.size,Oo.select=function(t){for(var e,r,n,i,a,o=[],s=-1,l=this.length;++sn){if("string"!=typeof t){2>n&&(e=!1);for(r in t)this.each(W(r,t[r],e));return this}if(2>n)return(n=this.node()["__on"+t])&&n._;r=!1}return this.each(W(t,e,r))};var Io=co.map({mouseenter:"mouseover",mouseleave:"mouseout"});ho&&Io.forEach(function(t){"on"+t in ho&&Io.remove(t)});var No,jo=0;co.mouse=function(t){return Q(t,E())};var Fo=this.navigator&&/WebKit/.test(this.navigator.userAgent)?-1:0;co.touch=function(t,e,r){if(arguments.length<3&&(r=e,e=E().changedTouches),e)for(var n,i=0,a=e.length;a>i;++i)if((n=e[i]).identifier===r)return Q(t,n)},co.behavior.drag=function(){function t(){this.on("mousedown.drag",a).on("touchstart.drag",o)}function e(t,e,n,a,o){return function(){function s(){var t,r,n=e(h,g);n&&(t=n[0]-b[0],r=n[1]-b[1],p|=t|r,b=n,d({type:"drag",x:n[0]+c[0],y:n[1]+c[1],dx:t,dy:r}))}function l(){e(h,g)&&(m.on(a+v,null).on(o+v,null),y(p),d({type:"dragend"}))}var c,u=this,f=co.event.target.correspondingElement||co.event.target,h=u.parentNode,d=r.of(u,arguments),p=0,g=t(),v=".drag"+(null==g?"":"-"+g),m=co.select(n(f)).on(a+v,s).on(o+v,l),y=$(f),b=e(h,g);i?(c=i.apply(u,arguments),c=[c.x-b[0],c.y-b[1]]):c=[0,0],d({type:"dragstart"})}}var r=L(t,"drag","dragstart","dragend"),i=null,a=e(k,co.mouse,n,"mousemove","mouseup"),o=e(J,co.touch,x,"touchmove","touchend");return t.origin=function(e){return arguments.length?(i=e,t):i},co.rebind(t,r,"on")},co.touches=function(t,e){return arguments.length<2&&(e=E().touches),e?fo(e).map(function(e){var r=Q(t,e);return r.identifier=e.identifier,r}):[]};var Do=1e-6,Bo=Do*Do,Uo=Math.PI,Vo=2*Uo,qo=Vo-Do,Ho=Uo/2,Go=Uo/180,Yo=180/Uo,Xo=Math.SQRT2,Wo=2,Zo=4;co.interpolateZoom=function(t,e){var r,n,i=t[0],a=t[1],o=t[2],s=e[0],l=e[1],c=e[2],u=s-i,f=l-a,h=u*u+f*f;if(Bo>h)n=Math.log(c/o)/Xo,r=function(t){return[i+t*u,a+t*f,o*Math.exp(Xo*t*n)]};else{var d=Math.sqrt(h),p=(c*c-o*o+Zo*h)/(2*o*Wo*d),g=(c*c-o*o-Zo*h)/(2*c*Wo*d),v=Math.log(Math.sqrt(p*p+1)-p),m=Math.log(Math.sqrt(g*g+1)-g);n=(m-v)/Xo,r=function(t){var e=t*n,r=at(v),s=o/(Wo*d)*(r*ot(Xo*e+v)-it(v));return[i+s*u,a+s*f,o*r/at(Xo*e+v)]}}return r.duration=1e3*n,r},co.behavior.zoom=function(){function t(t){t.on(z,f).on($o+".zoom",d).on("dblclick.zoom",p).on(O,h)}function e(t){return[(t[0]-A.x)/A.k,(t[1]-A.y)/A.k]}function r(t){return[t[0]*A.k+A.x,t[1]*A.k+A.y]}function i(t){A.k=Math.max(E[0],Math.min(E[1],t))}function a(t,e){e=r(e),A.x+=t[0]-e[0],A.y+=t[1]-e[1]}function o(e,r,n,o){e.__chart__={x:A.x,y:A.y,k:A.k},i(Math.pow(2,o)),a(v=r,n),e=co.select(e),S>0&&(e=e.transition().duration(S)),e.call(t.event)}function s(){_&&_.domain(x.range().map(function(t){return(t-A.x)/A.k}).map(x.invert)),k&&k.domain(w.range().map(function(t){return(t-A.y)/A.k}).map(w.invert))}function l(t){C++||t({type:"zoomstart"})}function c(t){s(),t({type:"zoom",scale:A.k,translate:[A.x,A.y]})}function u(t){--C||(t({type:"zoomend"}),v=null)}function f(){function t(){s=1,a(co.mouse(i),h),c(o)}function r(){f.on(P,null).on(R,null),d(s),u(o)}var i=this,o=I.of(i,arguments),s=0,f=co.select(n(i)).on(P,t).on(R,r),h=e(co.mouse(i)),d=$(i);Hl.call(i),l(o)}function h(){function t(){var t=co.touches(p);return d=A.k,t.forEach(function(t){t.identifier in v&&(v[t.identifier]=e(t))}),t}function r(){var e=co.event.target;co.select(e).on(x,n).on(_,s),w.push(e);for(var r=co.event.changedTouches,i=0,a=r.length;a>i;++i)v[r[i].identifier]=null;var l=t(),c=Date.now();if(1===l.length){if(500>c-b){var u=l[0];o(p,u,v[u.identifier],Math.floor(Math.log(A.k)/Math.LN2)+1),T()}b=c}else if(l.length>1){var u=l[0],f=l[1],h=u[0]-f[0],d=u[1]-f[1];m=h*h+d*d}}function n(){var t,e,r,n,o=co.touches(p);Hl.call(p);for(var s=0,l=o.length;l>s;++s,n=null)if(r=o[s],n=v[r.identifier]){if(e)break;t=r,e=n}if(n){var u=(u=r[0]-t[0])*u+(u=r[1]-t[1])*u,f=m&&Math.sqrt(u/m);t=[(t[0]+r[0])/2,(t[1]+r[1])/2],e=[(e[0]+n[0])/2,(e[1]+n[1])/2],i(f*d)}b=null,a(t,e),c(g)}function s(){if(co.event.touches.length){for(var e=co.event.changedTouches,r=0,n=e.length;n>r;++r)delete v[e[r].identifier];for(var i in v)return void t()}co.selectAll(w).on(y,null),k.on(z,f).on(O,h),M(),u(g)}var d,p=this,g=I.of(p,arguments),v={},m=0,y=".zoom-"+co.event.changedTouches[0].identifier,x="touchmove"+y,_="touchend"+y,w=[],k=co.select(p),M=$(p);r(),l(g),k.on(z,null).on(O,r)}function d(){var t=I.of(this,arguments);y?clearTimeout(y):(Hl.call(this),g=e(v=m||co.mouse(this)),l(t)),y=setTimeout(function(){y=null,u(t)},50),T(),i(Math.pow(2,.002*Ko())*A.k),a(v,g),c(t)}function p(){var t=co.mouse(this),r=Math.log(A.k)/Math.LN2;o(this,t,e(t),co.event.shiftKey?Math.ceil(r)-1:Math.floor(r)+1)}var g,v,m,y,b,x,_,w,k,A={x:0,y:0,k:1},M=[960,500],E=Qo,S=250,C=0,z="mousedown.zoom",P="mousemove.zoom",R="mouseup.zoom",O="touchstart.zoom",I=L(t,"zoomstart","zoom","zoomend");return $o||($o="onwheel"in ho?(Ko=function(){return-co.event.deltaY*(co.event.deltaMode?120:1)},"wheel"):"onmousewheel"in ho?(Ko=function(){return co.event.wheelDelta},"mousewheel"):(Ko=function(){return-co.event.detail},"MozMousePixelScroll")),t.event=function(t){t.each(function(){var t=I.of(this,arguments),e=A;Vl?co.select(this).transition().each("start.zoom",function(){A=this.__chart__||{x:0,y:0,k:1},l(t)}).tween("zoom:zoom",function(){var r=M[0],n=M[1],i=v?v[0]:r/2,a=v?v[1]:n/2,o=co.interpolateZoom([(i-A.x)/A.k,(a-A.y)/A.k,r/A.k],[(i-e.x)/e.k,(a-e.y)/e.k,r/e.k]);return function(e){var n=o(e),s=r/n[2];this.__chart__=A={x:i-n[0]*s,y:a-n[1]*s,k:s},c(t)}}).each("interrupt.zoom",function(){u(t)}).each("end.zoom",function(){u(t)}):(this.__chart__=A,l(t),c(t),u(t))})},t.translate=function(e){return arguments.length?(A={x:+e[0],y:+e[1],k:A.k},s(),t):[A.x,A.y]},t.scale=function(e){return arguments.length?(A={x:A.x,y:A.y,k:null},i(+e),s(),t):A.k},t.scaleExtent=function(e){return arguments.length?(E=null==e?Qo:[+e[0],+e[1]],t):E},t.center=function(e){return arguments.length?(m=e&&[+e[0],+e[1]],t):m},t.size=function(e){return arguments.length?(M=e&&[+e[0],+e[1]],t):M},t.duration=function(e){return arguments.length?(S=+e,t):S},t.x=function(e){return arguments.length?(_=e,x=e.copy(),A={x:0,y:0,k:1},t):_},t.y=function(e){return arguments.length?(k=e,w=e.copy(),A={x:0,y:0,k:1},t):k},co.rebind(t,I,"on")};var Ko,$o,Qo=[0,1/0];co.color=lt,lt.prototype.toString=function(){return this.rgb()+""},co.hsl=ct;var Jo=ct.prototype=new lt;Jo.brighter=function(t){return t=Math.pow(.7,arguments.length?t:1),new ct(this.h,this.s,this.l/t)},Jo.darker=function(t){return t=Math.pow(.7,arguments.length?t:1),new ct(this.h,this.s,t*this.l)},Jo.rgb=function(){return ut(this.h,this.s,this.l)},co.hcl=ft;var ts=ft.prototype=new lt;ts.brighter=function(t){return new ft(this.h,this.c,Math.min(100,this.l+es*(arguments.length?t:1)))},ts.darker=function(t){return new ft(this.h,this.c,Math.max(0,this.l-es*(arguments.length?t:1)))},ts.rgb=function(){return ht(this.h,this.c,this.l).rgb()},co.lab=dt;var es=18,rs=.95047,ns=1,is=1.08883,as=dt.prototype=new lt;as.brighter=function(t){return new dt(Math.min(100,this.l+es*(arguments.length?t:1)),this.a,this.b)},as.darker=function(t){return new dt(Math.max(0,this.l-es*(arguments.length?t:1)),this.a,this.b)},as.rgb=function(){return pt(this.l,this.a,this.b)},co.rgb=bt;var os=bt.prototype=new lt;os.brighter=function(t){t=Math.pow(.7,arguments.length?t:1);var e=this.r,r=this.g,n=this.b,i=30;return e||r||n?(e&&i>e&&(e=i),r&&i>r&&(r=i),n&&i>n&&(n=i),new bt(Math.min(255,e/t),Math.min(255,r/t),Math.min(255,n/t))):new bt(i,i,i)},os.darker=function(t){return t=Math.pow(.7,arguments.length?t:1),new bt(t*this.r,t*this.g,t*this.b)},os.hsl=function(){return At(this.r,this.g,this.b)},os.toString=function(){return"#"+wt(this.r)+wt(this.g)+wt(this.b)};var ss=co.map({aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074});ss.forEach(function(t,e){ss.set(t,xt(e))}),co.functor=Lt,co.xhr=St(x),co.dsv=function(t,e){function r(t,r,a){arguments.length<3&&(a=r,r=null);var o=Ct(t,e,null==r?n:i(r),a);return o.row=function(t){return arguments.length?o.response(null==(r=t)?n:i(t)):r},o}function n(t){return r.parse(t.responseText)}function i(t){return function(e){return r.parse(e.responseText,t)}}function a(e){return e.map(o).join(t)}function o(t){return s.test(t)?'"'+t.replace(/\"/g,'""')+'"':t}var s=new RegExp('["'+t+"\n]"),l=t.charCodeAt(0);return r.parse=function(t,e){var n;return r.parseRows(t,function(t,r){if(n)return n(t,r-1);var i=new Function("d","return {"+t.map(function(t,e){return JSON.stringify(t)+": d["+e+"]"}).join(",")+"}");n=e?function(t,r){return e(i(t),r)}:i})},r.parseRows=function(t,e){function r(){if(u>=c)return o;if(i)return i=!1,a;var e=u;if(34===t.charCodeAt(e)){for(var r=e;r++u;){var n=t.charCodeAt(u++),s=1;if(10===n)i=!0;else if(13===n)i=!0,10===t.charCodeAt(u)&&(++u,++s);else if(n!==l)continue;return t.slice(e,u-s)}return t.slice(e)}for(var n,i,a={},o={},s=[],c=t.length,u=0,f=0;(n=r())!==o;){for(var h=[];n!==a&&n!==o;)h.push(n),n=r();e&&null==(h=e(h,f++))||s.push(h)}return s},r.format=function(e){if(Array.isArray(e[0]))return r.formatRows(e);var n=new b,i=[];return e.forEach(function(t){for(var e in t)n.has(e)||i.push(n.add(e))}),[i.map(o).join(t)].concat(e.map(function(e){return i.map(function(t){return o(e[t])}).join(t)})).join("\n")},r.formatRows=function(t){return t.map(a).join("\n")},r},co.csv=co.dsv(",","text/csv"),co.tsv=co.dsv(" ","text/tab-separated-values");var ls,cs,us,fs,hs=this[w(this,"requestAnimationFrame")]||function(t){setTimeout(t,17)};co.timer=function(){Rt.apply(this,arguments)},co.timer.flush=function(){It(),Nt()},co.round=function(t,e){return e?Math.round(t*(e=Math.pow(10,e)))/e:Math.round(t)};var ds=["y","z","a","f","p","n","\xb5","m","","k","M","G","T","P","E","Z","Y"].map(Ft);co.formatPrefix=function(t,e){var r=0;return(t=+t)&&(0>t&&(t*=-1),e&&(t=co.round(t,jt(t,e))),r=1+Math.floor(1e-12+Math.log(t)/Math.LN10),r=Math.max(-24,Math.min(24,3*Math.floor((r-1)/3)))),ds[8+r/3]};var ps=/(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i,gs=co.map({b:function(t){return t.toString(2)},c:function(t){return String.fromCharCode(t)},o:function(t){return t.toString(8)},x:function(t){return t.toString(16)},X:function(t){return t.toString(16).toUpperCase()},g:function(t,e){return t.toPrecision(e)},e:function(t,e){return t.toExponential(e)},f:function(t,e){return t.toFixed(e)},r:function(t,e){return(t=co.round(t,jt(t,e))).toFixed(Math.max(0,Math.min(20,jt(t*(1+1e-15),e))))}}),vs=co.time={},ms=Date;Ut.prototype={getDate:function(){return this._.getUTCDate()},getDay:function(){return this._.getUTCDay()},getFullYear:function(){return this._.getUTCFullYear()},getHours:function(){return this._.getUTCHours()},getMilliseconds:function(){return this._.getUTCMilliseconds()},getMinutes:function(){return this._.getUTCMinutes()},getMonth:function(){return this._.getUTCMonth()},getSeconds:function(){return this._.getUTCSeconds()},getTime:function(){return this._.getTime()},getTimezoneOffset:function(){return 0},valueOf:function(){return this._.valueOf()},setDate:function(){ys.setUTCDate.apply(this._,arguments)},setDay:function(){ys.setUTCDay.apply(this._,arguments)},setFullYear:function(){ys.setUTCFullYear.apply(this._,arguments)},setHours:function(){ys.setUTCHours.apply(this._,arguments)},setMilliseconds:function(){ys.setUTCMilliseconds.apply(this._,arguments)},setMinutes:function(){ys.setUTCMinutes.apply(this._,arguments)},setMonth:function(){ys.setUTCMonth.apply(this._,arguments)},setSeconds:function(){ys.setUTCSeconds.apply(this._,arguments)},setTime:function(){ys.setTime.apply(this._,arguments)}};var ys=Date.prototype;vs.year=Vt(function(t){return t=vs.day(t),t.setMonth(0,1),t},function(t,e){t.setFullYear(t.getFullYear()+e)},function(t){return t.getFullYear()}),vs.years=vs.year.range,vs.years.utc=vs.year.utc.range,vs.day=Vt(function(t){var e=new ms(2e3,0);return e.setFullYear(t.getFullYear(),t.getMonth(),t.getDate()),e},function(t,e){t.setDate(t.getDate()+e)},function(t){return t.getDate()-1}),vs.days=vs.day.range,vs.days.utc=vs.day.utc.range,vs.dayOfYear=function(t){var e=vs.year(t);return Math.floor((t-e-6e4*(t.getTimezoneOffset()-e.getTimezoneOffset()))/864e5)},["sunday","monday","tuesday","wednesday","thursday","friday","saturday"].forEach(function(t,e){e=7-e;var r=vs[t]=Vt(function(t){return(t=vs.day(t)).setDate(t.getDate()-(t.getDay()+e)%7),t},function(t,e){t.setDate(t.getDate()+7*Math.floor(e))},function(t){var r=vs.year(t).getDay();return Math.floor((vs.dayOfYear(t)+(r+e)%7)/7)-(r!==e)});vs[t+"s"]=r.range,vs[t+"s"].utc=r.utc.range,vs[t+"OfYear"]=function(t){var r=vs.year(t).getDay();return Math.floor((vs.dayOfYear(t)+(r+e)%7)/7)}}),vs.week=vs.sunday,vs.weeks=vs.sunday.range,vs.weeks.utc=vs.sunday.utc.range,vs.weekOfYear=vs.sundayOfYear;var bs={"-":"",_:" ",0:"0"},xs=/^\s*\d+/,_s=/^%/;co.locale=function(t){return{numberFormat:Dt(t),timeFormat:Ht(t)}};var ws=co.locale({decimal:".",thousands:",",grouping:[3],currency:["$",""],dateTime:"%a %b %e %X %Y",date:"%m/%d/%Y",time:"%H:%M:%S",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});co.format=ws.numberFormat,co.geo={},fe.prototype={s:0,t:0,add:function(t){he(t,this.t,ks),he(ks.s,this.s,this),this.s?this.t+=ks.t:this.s=ks.t},reset:function(){this.s=this.t=0},valueOf:function(){return this.s}};var ks=new fe;co.geo.stream=function(t,e){t&&As.hasOwnProperty(t.type)?As[t.type](t,e):de(t,e)};var As={Feature:function(t,e){de(t.geometry,e)},FeatureCollection:function(t,e){for(var r=t.features,n=-1,i=r.length;++nt?4*Uo+t:t,Ls.lineStart=Ls.lineEnd=Ls.point=k}};co.geo.bounds=function(){function t(t,e){b.push(x=[u=t,h=t]),f>e&&(f=e),e>d&&(d=e)}function e(e,r){var n=me([e*Go,r*Go]);if(m){var i=be(m,n),a=[i[1],-i[0],0],o=be(a,i);we(o),o=ke(o);var l=e-p,c=l>0?1:-1,g=o[0]*Yo*c,v=wo(l)>180;if(v^(g>c*p&&c*e>g)){var y=o[1]*Yo;y>d&&(d=y)}else if(g=(g+360)%360-180,v^(g>c*p&&c*e>g)){var y=-o[1]*Yo;f>y&&(f=y)}else f>r&&(f=r),r>d&&(d=r);v?p>e?s(u,e)>s(u,h)&&(h=e):s(e,h)>s(u,h)&&(u=e):h>=u?(u>e&&(u=e),e>h&&(h=e)):e>p?s(u,e)>s(u,h)&&(h=e):s(e,h)>s(u,h)&&(u=e)}else t(e,r);m=n,p=e}function r(){_.point=e}function n(){x[0]=u,x[1]=h,_.point=t,m=null}function i(t,r){if(m){var n=t-p;y+=wo(n)>180?n+(n>0?360:-360):n}else g=t,v=r;Ls.point(t,r),e(t,r)}function a(){Ls.lineStart()}function o(){i(g,v),Ls.lineEnd(),wo(y)>Do&&(u=-(h=180)),x[0]=u,x[1]=h,m=null}function s(t,e){return(e-=t)<0?e+360:e}function l(t,e){return t[0]-e[0]}function c(t,e){return e[0]<=e[1]?e[0]<=t&&t<=e[1]:tEs?(u=-(h=180),f=-(d=90)):y>Do?d=90:-Do>y&&(f=-90),x[0]=u,x[1]=h}};return function(t){d=h=-(u=f=1/0),b=[],co.geo.stream(t,_);var e=b.length;if(e){b.sort(l);for(var r,n=1,i=b[0],a=[i];e>n;++n)r=b[n],c(r[0],i)||c(r[1],i)?(s(i[0],r[1])>s(i[0],i[1])&&(i[1]=r[1]),s(r[0],i[1])>s(i[0],i[1])&&(i[0]=r[0])):a.push(i=r);for(var o,r,p=-(1/0),e=a.length-1,n=0,i=a[e];e>=n;i=r,++n)r=a[n],(o=s(i[1],r[0]))>p&&(p=o,u=r[0],h=i[1])}return b=x=null,u===1/0||f===1/0?[[NaN,NaN],[NaN,NaN]]:[[u,f],[h,d]]}}(),co.geo.centroid=function(t){Ss=Cs=zs=Ps=Rs=Os=Is=Ns=js=Fs=Ds=0,co.geo.stream(t,Bs);var e=js,r=Fs,n=Ds,i=e*e+r*r+n*n;return Bo>i&&(e=Os,r=Is,n=Ns,Do>Cs&&(e=zs,r=Ps,n=Rs),i=e*e+r*r+n*n,Bo>i)?[NaN,NaN]:[Math.atan2(r,e)*Yo,nt(n/Math.sqrt(i))*Yo]};var Ss,Cs,zs,Ps,Rs,Os,Is,Ns,js,Fs,Ds,Bs={sphere:k,point:Me,lineStart:Ee,lineEnd:Le,polygonStart:function(){Bs.lineStart=Se},polygonEnd:function(){Bs.lineStart=Ee}},Us=Ie(ze,De,Ue,[-Uo,-Uo/2]),Vs=1e9;co.geo.clipExtent=function(){var t,e,r,n,i,a,o={stream:function(t){return i&&(i.valid=!1),i=a(t),i.valid=!0,i},extent:function(s){return arguments.length?(a=Ge(t=+s[0][0],e=+s[0][1],r=+s[1][0],n=+s[1][1]),i&&(i.valid=!1,i=null),o):[[t,e],[r,n]]}};return o.extent([[0,0],[960,500]])},(co.geo.conicEqualArea=function(){return Ye(Xe)}).raw=Xe,co.geo.albers=function(){return co.geo.conicEqualArea().rotate([96,0]).center([-.6,38.7]).parallels([29.5,45.5]).scale(1070)},co.geo.albersUsa=function(){
+function t(t){var a=t[0],o=t[1];return e=null,r(a,o),e||(n(a,o),e)||i(a,o),e}var e,r,n,i,a=co.geo.albers(),o=co.geo.conicEqualArea().rotate([154,0]).center([-2,58.5]).parallels([55,65]),s=co.geo.conicEqualArea().rotate([157,0]).center([-3,19.9]).parallels([8,18]),l={point:function(t,r){e=[t,r]}};return t.invert=function(t){var e=a.scale(),r=a.translate(),n=(t[0]-r[0])/e,i=(t[1]-r[1])/e;return(i>=.12&&.234>i&&n>=-.425&&-.214>n?o:i>=.166&&.234>i&&n>=-.214&&-.115>n?s:a).invert(t)},t.stream=function(t){var e=a.stream(t),r=o.stream(t),n=s.stream(t);return{point:function(t,i){e.point(t,i),r.point(t,i),n.point(t,i)},sphere:function(){e.sphere(),r.sphere(),n.sphere()},lineStart:function(){e.lineStart(),r.lineStart(),n.lineStart()},lineEnd:function(){e.lineEnd(),r.lineEnd(),n.lineEnd()},polygonStart:function(){e.polygonStart(),r.polygonStart(),n.polygonStart()},polygonEnd:function(){e.polygonEnd(),r.polygonEnd(),n.polygonEnd()}}},t.precision=function(e){return arguments.length?(a.precision(e),o.precision(e),s.precision(e),t):a.precision()},t.scale=function(e){return arguments.length?(a.scale(e),o.scale(.35*e),s.scale(e),t.translate(a.translate())):a.scale()},t.translate=function(e){if(!arguments.length)return a.translate();var c=a.scale(),u=+e[0],f=+e[1];return r=a.translate(e).clipExtent([[u-.455*c,f-.238*c],[u+.455*c,f+.238*c]]).stream(l).point,n=o.translate([u-.307*c,f+.201*c]).clipExtent([[u-.425*c+Do,f+.12*c+Do],[u-.214*c-Do,f+.234*c-Do]]).stream(l).point,i=s.translate([u-.205*c,f+.212*c]).clipExtent([[u-.214*c+Do,f+.166*c+Do],[u-.115*c-Do,f+.234*c-Do]]).stream(l).point,t},t.scale(1070)};var qs,Hs,Gs,Ys,Xs,Ws,Zs={point:k,lineStart:k,lineEnd:k,polygonStart:function(){Hs=0,Zs.lineStart=We},polygonEnd:function(){Zs.lineStart=Zs.lineEnd=Zs.point=k,qs+=wo(Hs/2)}},Ks={point:Ze,lineStart:k,lineEnd:k,polygonStart:k,polygonEnd:k},$s={point:Qe,lineStart:Je,lineEnd:tr,polygonStart:function(){$s.lineStart=er},polygonEnd:function(){$s.point=Qe,$s.lineStart=Je,$s.lineEnd=tr}};co.geo.path=function(){function t(t){return t&&("function"==typeof s&&a.pointRadius(+s.apply(this,arguments)),o&&o.valid||(o=i(a)),co.geo.stream(t,o)),a.result()}function e(){return o=null,t}var r,n,i,a,o,s=4.5;return t.area=function(t){return qs=0,co.geo.stream(t,i(Zs)),qs},t.centroid=function(t){return zs=Ps=Rs=Os=Is=Ns=js=Fs=Ds=0,co.geo.stream(t,i($s)),Ds?[js/Ds,Fs/Ds]:Ns?[Os/Ns,Is/Ns]:Rs?[zs/Rs,Ps/Rs]:[NaN,NaN]},t.bounds=function(t){return Xs=Ws=-(Gs=Ys=1/0),co.geo.stream(t,i(Ks)),[[Gs,Ys],[Xs,Ws]]},t.projection=function(t){return arguments.length?(i=(r=t)?t.stream||ir(t):x,e()):r},t.context=function(t){return arguments.length?(a=null==(n=t)?new Ke:new rr(t),"function"!=typeof s&&a.pointRadius(s),e()):n},t.pointRadius=function(e){return arguments.length?(s="function"==typeof e?e:(a.pointRadius(+e),+e),t):s},t.projection(co.geo.albersUsa()).context(null)},co.geo.transform=function(t){return{stream:function(e){var r=new ar(e);for(var n in t)r[n]=t[n];return r}}},ar.prototype={point:function(t,e){this.stream.point(t,e)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}},co.geo.projection=sr,co.geo.projectionMutator=lr,(co.geo.equirectangular=function(){return sr(ur)}).raw=ur.invert=ur,co.geo.rotation=function(t){function e(e){return e=t(e[0]*Go,e[1]*Go),e[0]*=Yo,e[1]*=Yo,e}return t=hr(t[0]%360*Go,t[1]*Go,t.length>2?t[2]*Go:0),e.invert=function(e){return e=t.invert(e[0]*Go,e[1]*Go),e[0]*=Yo,e[1]*=Yo,e},e},fr.invert=ur,co.geo.circle=function(){function t(){var t="function"==typeof n?n.apply(this,arguments):n,e=hr(-t[0]*Go,-t[1]*Go,0).invert,i=[];return r(null,null,1,{point:function(t,r){i.push(t=e(t,r)),t[0]*=Yo,t[1]*=Yo}}),{type:"Polygon",coordinates:[i]}}var e,r,n=[0,0],i=6;return t.origin=function(e){return arguments.length?(n=e,t):n},t.angle=function(n){return arguments.length?(r=vr((e=+n)*Go,i*Go),t):e},t.precision=function(n){return arguments.length?(r=vr(e*Go,(i=+n)*Go),t):i},t.angle(90)},co.geo.distance=function(t,e){var r,n=(e[0]-t[0])*Go,i=t[1]*Go,a=e[1]*Go,o=Math.sin(n),s=Math.cos(n),l=Math.sin(i),c=Math.cos(i),u=Math.sin(a),f=Math.cos(a);return Math.atan2(Math.sqrt((r=f*o)*r+(r=c*u-l*f*s)*r),l*u+c*f*s)},co.geo.graticule=function(){function t(){return{type:"MultiLineString",coordinates:e()}}function e(){return co.range(Math.ceil(a/v)*v,i,v).map(h).concat(co.range(Math.ceil(c/m)*m,l,m).map(d)).concat(co.range(Math.ceil(n/p)*p,r,p).filter(function(t){return wo(t%v)>Do}).map(u)).concat(co.range(Math.ceil(s/g)*g,o,g).filter(function(t){return wo(t%m)>Do}).map(f))}var r,n,i,a,o,s,l,c,u,f,h,d,p=10,g=p,v=90,m=360,y=2.5;return t.lines=function(){return e().map(function(t){return{type:"LineString",coordinates:t}})},t.outline=function(){return{type:"Polygon",coordinates:[h(a).concat(d(l).slice(1),h(i).reverse().slice(1),d(c).reverse().slice(1))]}},t.extent=function(e){return arguments.length?t.majorExtent(e).minorExtent(e):t.minorExtent()},t.majorExtent=function(e){return arguments.length?(a=+e[0][0],i=+e[1][0],c=+e[0][1],l=+e[1][1],a>i&&(e=a,a=i,i=e),c>l&&(e=c,c=l,l=e),t.precision(y)):[[a,c],[i,l]]},t.minorExtent=function(e){return arguments.length?(n=+e[0][0],r=+e[1][0],s=+e[0][1],o=+e[1][1],n>r&&(e=n,n=r,r=e),s>o&&(e=s,s=o,o=e),t.precision(y)):[[n,s],[r,o]]},t.step=function(e){return arguments.length?t.majorStep(e).minorStep(e):t.minorStep()},t.majorStep=function(e){return arguments.length?(v=+e[0],m=+e[1],t):[v,m]},t.minorStep=function(e){return arguments.length?(p=+e[0],g=+e[1],t):[p,g]},t.precision=function(e){return arguments.length?(y=+e,u=yr(s,o,90),f=br(n,r,y),h=yr(c,l,90),d=br(a,i,y),t):y},t.majorExtent([[-180,-90+Do],[180,90-Do]]).minorExtent([[-180,-80-Do],[180,80+Do]])},co.geo.greatArc=function(){function t(){return{type:"LineString",coordinates:[e||n.apply(this,arguments),r||i.apply(this,arguments)]}}var e,r,n=xr,i=_r;return t.distance=function(){return co.geo.distance(e||n.apply(this,arguments),r||i.apply(this,arguments))},t.source=function(r){return arguments.length?(n=r,e="function"==typeof r?null:r,t):n},t.target=function(e){return arguments.length?(i=e,r="function"==typeof e?null:e,t):i},t.precision=function(){return arguments.length?t:0},t},co.geo.interpolate=function(t,e){return wr(t[0]*Go,t[1]*Go,e[0]*Go,e[1]*Go)},co.geo.length=function(t){return Qs=0,co.geo.stream(t,Js),Qs};var Qs,Js={sphere:k,point:k,lineStart:kr,lineEnd:k,polygonStart:k,polygonEnd:k},tl=Ar(function(t){return Math.sqrt(2/(1+t))},function(t){return 2*Math.asin(t/2)});(co.geo.azimuthalEqualArea=function(){return sr(tl)}).raw=tl;var el=Ar(function(t){var e=Math.acos(t);return e&&e/Math.sin(e)},x);(co.geo.azimuthalEquidistant=function(){return sr(el)}).raw=el,(co.geo.conicConformal=function(){return Ye(Mr)}).raw=Mr,(co.geo.conicEquidistant=function(){return Ye(Tr)}).raw=Tr;var rl=Ar(function(t){return 1/t},Math.atan);(co.geo.gnomonic=function(){return sr(rl)}).raw=rl,Er.invert=function(t,e){return[t,2*Math.atan(Math.exp(e))-Ho]},(co.geo.mercator=function(){return Lr(Er)}).raw=Er;var nl=Ar(function(){return 1},Math.asin);(co.geo.orthographic=function(){return sr(nl)}).raw=nl;var il=Ar(function(t){return 1/(1+t)},function(t){return 2*Math.atan(t)});(co.geo.stereographic=function(){return sr(il)}).raw=il,Sr.invert=function(t,e){return[-e,2*Math.atan(Math.exp(t))-Ho]},(co.geo.transverseMercator=function(){var t=Lr(Sr),e=t.center,r=t.rotate;return t.center=function(t){return t?e([-t[1],t[0]]):(t=e(),[t[1],-t[0]])},t.rotate=function(t){return t?r([t[0],t[1],t.length>2?t[2]+90:90]):(t=r(),[t[0],t[1],t[2]-90])},r([0,0,90])}).raw=Sr,co.geom={},co.geom.hull=function(t){function e(t){if(t.length<3)return[];var e,i=Lt(r),a=Lt(n),o=t.length,s=[],l=[];for(e=0;o>e;e++)s.push([+i.call(this,t[e],e),+a.call(this,t[e],e),e]);for(s.sort(Rr),e=0;o>e;e++)l.push([s[e][0],-s[e][1]]);var c=Pr(s),u=Pr(l),f=u[0]===c[0],h=u[u.length-1]===c[c.length-1],d=[];for(e=c.length-1;e>=0;--e)d.push(t[s[c[e]][2]]);for(e=+f;e=n&&c.x<=a&&c.y>=i&&c.y<=o?[[n,o],[a,o],[a,i],[n,i]]:[];u.point=t[s]}),e}function r(t){return t.map(function(t,e){return{x:Math.round(a(t,e)/Do)*Do,y:Math.round(o(t,e)/Do)*Do,i:e}})}var n=Cr,i=zr,a=n,o=i,s=dl;return t?e(t):(e.links=function(t){return cn(r(t)).edges.filter(function(t){return t.l&&t.r}).map(function(e){return{source:t[e.l.i],target:t[e.r.i]}})},e.triangles=function(t){var e=[];return cn(r(t)).cells.forEach(function(r,n){for(var i,a,o=r.site,s=r.edges.sort(Yr),l=-1,c=s.length,u=s[c-1].edge,f=u.l===o?u.r:u.l;++l=c,h=n>=u,d=h<<1|f;t.leaf=!1,t=t.nodes[d]||(t.nodes[d]=pn()),f?i=c:s=c,h?o=u:l=u,a(t,e,r,n,i,o,s,l)}var u,f,h,d,p,g,v,m,y,b=Lt(s),x=Lt(l);if(null!=e)g=e,v=r,m=n,y=i;else if(m=y=-(g=v=1/0),f=[],h=[],p=t.length,o)for(d=0;p>d;++d)u=t[d],u.xm&&(m=u.x),u.y>y&&(y=u.y),f.push(u.x),h.push(u.y);else for(d=0;p>d;++d){var _=+b(u=t[d],d),w=+x(u,d);g>_&&(g=_),v>w&&(v=w),_>m&&(m=_),w>y&&(y=w),f.push(_),h.push(w)}var k=m-g,A=y-v;k>A?y=v+k:m=g+A;var M=pn();if(M.add=function(t){a(M,t,+b(t,++d),+x(t,d),g,v,m,y)},M.visit=function(t){gn(t,M,g,v,m,y)},M.find=function(t){return vn(M,t[0],t[1],g,v,m,y)},d=-1,null==e){for(;++d=0?t.slice(0,e):t,n=e>=0?t.slice(e+1):"in";return r=ml.get(r)||vl,n=yl.get(n)||x,kn(n(r.apply(null,uo.call(arguments,1))))},co.interpolateHcl=Nn,co.interpolateHsl=jn,co.interpolateLab=Fn,co.interpolateRound=Dn,co.transform=function(t){var e=ho.createElementNS(co.ns.prefix.svg,"g");return(co.transform=function(t){if(null!=t){e.setAttribute("transform",t);var r=e.transform.baseVal.consolidate()}return new Bn(r?r.matrix:bl)})(t)},Bn.prototype.toString=function(){return"translate("+this.translate+")rotate("+this.rotate+")skewX("+this.skew+")scale("+this.scale+")"};var bl={a:1,b:0,c:0,d:1,e:0,f:0};co.interpolateTransform=Zn,co.layout={},co.layout.bundle=function(){return function(t){for(var e=[],r=-1,n=t.length;++rs*s/m){if(g>l){var c=e.charge/l;t.px-=a*c,t.py-=o*c}return!0}if(e.point&&l&&g>l){var c=e.pointCharge/l;t.px-=a*c,t.py-=o*c}}return!e.charge}}function e(t){t.px=co.event.x,t.py=co.event.y,l.resume()}var r,n,i,a,o,s,l={},c=co.dispatch("start","tick","end"),u=[1,1],f=.9,h=xl,d=_l,p=-30,g=wl,v=.1,m=.64,y=[],b=[];return l.tick=function(){if((i*=.99)<.005)return r=null,c.end({type:"end",alpha:i=0}),!0;var e,n,l,h,d,g,m,x,_,w=y.length,k=b.length;for(n=0;k>n;++n)l=b[n],h=l.source,d=l.target,x=d.x-h.x,_=d.y-h.y,(g=x*x+_*_)&&(g=i*o[n]*((g=Math.sqrt(g))-a[n])/g,x*=g,_*=g,d.x-=x*(m=h.weight+d.weight?h.weight/(h.weight+d.weight):.5),d.y-=_*m,h.x+=x*(m=1-m),h.y+=_*m);if((m=i*v)&&(x=u[0]/2,_=u[1]/2,n=-1,m))for(;++n0?i=t:(r.c=null,r.t=NaN,r=null,c.end({type:"end",alpha:i=0})):t>0&&(c.start({type:"start",alpha:i=t}),r=Rt(l.tick)),l):i},l.start=function(){function t(t,n){if(!r){for(r=new Array(i),l=0;i>l;++l)r[l]=[];for(l=0;c>l;++l){var a=b[l];r[a.source.index].push(a.target),r[a.target.index].push(a.source)}}for(var o,s=r[e],l=-1,u=s.length;++le;++e)(n=y[e]).index=e,n.weight=0;for(e=0;c>e;++e)n=b[e],"number"==typeof n.source&&(n.source=y[n.source]),"number"==typeof n.target&&(n.target=y[n.target]),++n.source.weight,++n.target.weight;for(e=0;i>e;++e)n=y[e],isNaN(n.x)&&(n.x=t("x",f)),isNaN(n.y)&&(n.y=t("y",g)),isNaN(n.px)&&(n.px=n.x),isNaN(n.py)&&(n.py=n.y);if(a=[],"function"==typeof h)for(e=0;c>e;++e)a[e]=+h.call(this,b[e],e);else for(e=0;c>e;++e)a[e]=h;if(o=[],"function"==typeof d)for(e=0;c>e;++e)o[e]=+d.call(this,b[e],e);else for(e=0;c>e;++e)o[e]=d;if(s=[],"function"==typeof p)for(e=0;i>e;++e)s[e]=+p.call(this,y[e],e);else for(e=0;i>e;++e)s[e]=p;return l.resume()},l.resume=function(){return l.alpha(.1)},l.stop=function(){return l.alpha(0)},l.drag=function(){return n||(n=co.behavior.drag().origin(x).on("dragstart.force",ei).on("drag.force",e).on("dragend.force",ri)),arguments.length?void this.on("mouseover.force",ni).on("mouseout.force",ii).call(n):n},co.rebind(l,c,"on")};var xl=20,_l=1,wl=1/0;co.layout.hierarchy=function(){function t(i){var a,o=[i],s=[];for(i.depth=0;null!=(a=o.pop());)if(s.push(a),(c=r.call(t,a,a.depth))&&(l=c.length)){for(var l,c,u;--l>=0;)o.push(u=c[l]),u.parent=a,u.depth=a.depth+1;n&&(a.value=0),a.children=c}else n&&(a.value=+n.call(t,a,a.depth)||0),delete a.children;return li(i,function(t){var r,i;e&&(r=t.children)&&r.sort(e),n&&(i=t.parent)&&(i.value+=t.value)}),s}var e=fi,r=ci,n=ui;return t.sort=function(r){return arguments.length?(e=r,t):e},t.children=function(e){return arguments.length?(r=e,t):r},t.value=function(e){return arguments.length?(n=e,t):n},t.revalue=function(e){return n&&(si(e,function(t){t.children&&(t.value=0)}),li(e,function(e){var r;e.children||(e.value=+n.call(t,e,e.depth)||0),(r=e.parent)&&(r.value+=e.value)})),e},t},co.layout.partition=function(){function t(e,r,n,i){var a=e.children;if(e.x=r,e.y=e.depth*i,e.dx=n,e.dy=i,a&&(o=a.length)){var o,s,l,c=-1;for(n=e.value?n/e.value:0;++cf?-1:1),p=co.sum(c),g=p?(f-l*d)/p:0,v=co.range(l),m=[];return null!=r&&v.sort(r===kl?function(t,e){return c[e]-c[t]}:function(t,e){return r(o[t],o[e])}),v.forEach(function(t){m[t]={data:o[t],value:s=c[t],startAngle:u,endAngle:u+=s*g+d,padAngle:h}}),m}var e=Number,r=kl,n=0,i=Vo,a=0;return t.value=function(r){return arguments.length?(e=r,t):e},t.sort=function(e){return arguments.length?(r=e,t):r},t.startAngle=function(e){return arguments.length?(n=e,t):n},t.endAngle=function(e){return arguments.length?(i=e,t):i},t.padAngle=function(e){return arguments.length?(a=e,t):a},t};var kl={};co.layout.stack=function(){function t(s,l){if(!(h=s.length))return s;var c=s.map(function(r,n){return e.call(t,r,n)}),u=c.map(function(e){return e.map(function(e,r){return[a.call(t,e,r),o.call(t,e,r)]})}),f=r.call(t,u,l);c=co.permute(c,f),u=co.permute(u,f);var h,d,p,g,v=n.call(t,u,l),m=c[0].length;for(p=0;m>p;++p)for(i.call(t,c[0][p],g=v[p],u[0][p][1]),d=1;h>d;++d)i.call(t,c[d][p],g+=u[d-1][p][1],u[d][p][1]);return s}var e=x,r=vi,n=mi,i=gi,a=di,o=pi;return t.values=function(r){return arguments.length?(e=r,t):e},t.order=function(e){return arguments.length?(r="function"==typeof e?e:Al.get(e)||vi,t):r},t.offset=function(e){return arguments.length?(n="function"==typeof e?e:Ml.get(e)||mi,t):n},t.x=function(e){return arguments.length?(a=e,t):a},t.y=function(e){return arguments.length?(o=e,t):o},t.out=function(e){return arguments.length?(i=e,t):i},t};var Al=co.map({"inside-out":function(t){var e,r,n=t.length,i=t.map(yi),a=t.map(bi),o=co.range(n).sort(function(t,e){return i[t]-i[e]}),s=0,l=0,c=[],u=[];for(e=0;n>e;++e)r=o[e],l>s?(s+=a[r],c.push(r)):(l+=a[r],u.push(r));return u.reverse().concat(c)},reverse:function(t){return co.range(t.length).reverse()},"default":vi}),Ml=co.map({silhouette:function(t){var e,r,n,i=t.length,a=t[0].length,o=[],s=0,l=[];for(r=0;a>r;++r){for(e=0,n=0;i>e;e++)n+=t[e][r][1];n>s&&(s=n),o.push(n)}for(r=0;a>r;++r)l[r]=(s-o[r])/2;return l},wiggle:function(t){var e,r,n,i,a,o,s,l,c,u=t.length,f=t[0],h=f.length,d=[];for(d[0]=l=c=0,r=1;h>r;++r){for(e=0,i=0;u>e;++e)i+=t[e][r][1];for(e=0,a=0,s=f[r][0]-f[r-1][0];u>e;++e){for(n=0,o=(t[e][r][1]-t[e][r-1][1])/(2*s);e>n;++n)o+=(t[n][r][1]-t[n][r-1][1])/s;a+=o*t[e][r][1]}d[r]=l-=i?a/i*s:0,c>l&&(c=l)}for(r=0;h>r;++r)d[r]-=c;return d},expand:function(t){var e,r,n,i=t.length,a=t[0].length,o=1/i,s=[];for(r=0;a>r;++r){for(e=0,n=0;i>e;e++)n+=t[e][r][1];if(n)for(e=0;i>e;e++)t[e][r][1]/=n;else for(e=0;i>e;e++)t[e][r][1]=o}for(r=0;a>r;++r)s[r]=0;return s},zero:mi});co.layout.histogram=function(){function t(t,a){for(var o,s,l=[],c=t.map(r,this),u=n.call(this,c,a),f=i.call(this,u,c,a),a=-1,h=c.length,d=f.length-1,p=e?1:1/h;++a0)for(a=-1;++a=u[0]&&s<=u[1]&&(o=l[co.bisect(f,s,1,d)-1],o.y+=p,o.push(t[a]));return l}var e=!0,r=Number,n=ki,i=_i;return t.value=function(e){return arguments.length?(r=e,t):r},t.range=function(e){return arguments.length?(n=Lt(e),t):n},t.bins=function(e){return arguments.length?(i="number"==typeof e?function(t){return wi(t,e)}:Lt(e),t):i},t.frequency=function(r){return arguments.length?(e=!!r,t):e},t},co.layout.pack=function(){function t(t,a){var o=r.call(this,t,a),s=o[0],l=i[0],c=i[1],u=null==e?Math.sqrt:"function"==typeof e?e:function(){return e};if(s.x=s.y=0,li(s,function(t){t.r=+u(t.value)}),li(s,Li),n){var f=n*(e?1:Math.max(2*s.r/l,2*s.r/c))/2;li(s,function(t){t.r+=f}),li(s,Li),li(s,function(t){t.r-=f})}return zi(s,l/2,c/2,e?1:1/Math.max(2*s.r/l,2*s.r/c)),o}var e,r=co.layout.hierarchy().sort(Ai),n=0,i=[1,1];return t.size=function(e){return arguments.length?(i=e,t):i},t.radius=function(r){return arguments.length?(e=null==r||"function"==typeof r?r:+r,t):e},t.padding=function(e){return arguments.length?(n=+e,t):n},oi(t,r)},co.layout.tree=function(){function t(t,i){var u=o.call(this,t,i),f=u[0],h=e(f);if(li(h,r),h.parent.m=-h.z,si(h,n),c)si(f,a);else{var d=f,p=f,g=f;si(f,function(t){t.xp.x&&(p=t),t.depth>g.depth&&(g=t)});var v=s(d,p)/2-d.x,m=l[0]/(p.x+s(p,d)/2+v),y=l[1]/(g.depth||1);si(f,function(t){t.x=(t.x+v)*m,t.y=t.depth*y})}return u}function e(t){for(var e,r={A:null,children:[t]},n=[r];null!=(e=n.pop());)for(var i,a=e.children,o=0,s=a.length;s>o;++o)n.push((a[o]=i={_:a[o],parent:e,children:(i=a[o].children)&&i.slice()||[],A:null,a:null,z:0,m:0,c:0,s:0,t:null,i:o}).a=i);return r.children[0]}function r(t){var e=t.children,r=t.parent.children,n=t.i?r[t.i-1]:null;if(e.length){ji(t);var a=(e[0].z+e[e.length-1].z)/2;n?(t.z=n.z+s(t._,n._),t.m=t.z-a):t.z=a}else n&&(t.z=n.z+s(t._,n._));t.parent.A=i(t,n,t.parent.A||r[0])}function n(t){t._.x=t.z+t.parent.m,t.m+=t.parent.m}function i(t,e,r){if(e){for(var n,i=t,a=t,o=e,l=i.parent.children[0],c=i.m,u=a.m,f=o.m,h=l.m;o=Ii(o),i=Oi(i),o&&i;)l=Oi(l),a=Ii(a),a.a=t,n=o.z+f-i.z-c+s(o._,i._),n>0&&(Ni(Fi(o,t,r),t,n),c+=n,u+=n),f+=o.m,c+=i.m,h+=l.m,u+=a.m;o&&!Ii(a)&&(a.t=o,a.m+=f-u),i&&!Oi(l)&&(l.t=i,l.m+=c-h,r=t)}return r}function a(t){t.x*=l[0],t.y=t.depth*l[1]}var o=co.layout.hierarchy().sort(null).value(null),s=Ri,l=[1,1],c=null;return t.separation=function(e){return arguments.length?(s=e,t):s},t.size=function(e){return arguments.length?(c=null==(l=e)?a:null,t):c?null:l},t.nodeSize=function(e){return arguments.length?(c=null==(l=e)?null:a,t):c?l:null},oi(t,o)},co.layout.cluster=function(){function t(t,a){var o,s=e.call(this,t,a),l=s[0],c=0;li(l,function(t){var e=t.children;e&&e.length?(t.x=Bi(e),t.y=Di(e)):(t.x=o?c+=r(t,o):0,t.y=0,o=t)});var u=Ui(l),f=Vi(l),h=u.x-r(u,f)/2,d=f.x+r(f,u)/2;return li(l,i?function(t){t.x=(t.x-l.x)*n[0],t.y=(l.y-t.y)*n[1]}:function(t){t.x=(t.x-h)/(d-h)*n[0],t.y=(1-(l.y?t.y/l.y:1))*n[1]}),s}var e=co.layout.hierarchy().sort(null).value(null),r=Ri,n=[1,1],i=!1;return t.separation=function(e){return arguments.length?(r=e,t):r},t.size=function(e){return arguments.length?(i=null==(n=e),t):i?null:n},t.nodeSize=function(e){return arguments.length?(i=null!=(n=e),t):i?n:null},oi(t,e)},co.layout.treemap=function(){function t(t,e){for(var r,n,i=-1,a=t.length;++ie?0:e),r.area=isNaN(n)||0>=n?0:n}function e(r){var a=r.children;if(a&&a.length){var o,s,l,c=f(r),u=[],h=a.slice(),p=1/0,g="slice"===d?c.dx:"dice"===d?c.dy:"slice-dice"===d?1&r.depth?c.dy:c.dx:Math.min(c.dx,c.dy);for(t(h,c.dx*c.dy/r.value),u.area=0;(l=h.length)>0;)u.push(o=h[l-1]),u.area+=o.area,"squarify"!==d||(s=n(u,g))<=p?(h.pop(),p=s):(u.area-=u.pop().area,i(u,g,c,!1),g=Math.min(c.dx,c.dy),u.length=u.area=0,p=1/0);u.length&&(i(u,g,c,!0),u.length=u.area=0),a.forEach(e)}}function r(e){var n=e.children;if(n&&n.length){var a,o=f(e),s=n.slice(),l=[];for(t(s,o.dx*o.dy/e.value),l.area=0;a=s.pop();)l.push(a),l.area+=a.area,null!=a.z&&(i(l,a.z?o.dx:o.dy,o,!s.length),l.length=l.area=0);n.forEach(r)}}function n(t,e){for(var r,n=t.area,i=0,a=1/0,o=-1,s=t.length;++or&&(a=r),r>i&&(i=r));return n*=n,e*=e,n?Math.max(e*i*p/n,n/(e*a*p)):1/0}function i(t,e,r,n){var i,a=-1,o=t.length,s=r.x,c=r.y,u=e?l(t.area/e):0;if(e==r.dx){for((n||u>r.dy)&&(u=r.dy);++ar.dx)&&(u=r.dx);++ar&&(e=1),1>r&&(t=0),function(){var r,n,i;do r=2*Math.random()-1,n=2*Math.random()-1,i=r*r+n*n;while(!i||i>1);return t+e*r*Math.sqrt(-2*Math.log(i)/i)}},logNormal:function(){var t=co.random.normal.apply(co,arguments);return function(){return Math.exp(t())}},bates:function(t){var e=co.random.irwinHall(t);return function(){return e()/t}},irwinHall:function(t){return function(){for(var e=0,r=0;t>r;r++)e+=Math.random();return e}}},co.scale={};var Tl={floor:x,ceil:x};co.scale.linear=function(){return $i([0,1],[0,1],_n,!1)};var El={s:1,g:1,p:1,r:1,e:1};co.scale.log=function(){return aa(co.scale.linear().domain([0,1]),10,!0,[1,10])};var Ll=co.format(".0e"),Sl={floor:function(t){return-Math.ceil(-t)},ceil:function(t){return-Math.floor(-t)}};co.scale.pow=function(){return oa(co.scale.linear(),1,[0,1])},co.scale.sqrt=function(){return co.scale.pow().exponent(.5)},co.scale.ordinal=function(){return la([],{t:"range",a:[[]]})},co.scale.category10=function(){return co.scale.ordinal().range(Cl)},co.scale.category20=function(){return co.scale.ordinal().range(zl)},co.scale.category20b=function(){return co.scale.ordinal().range(Pl)},co.scale.category20c=function(){return co.scale.ordinal().range(Rl)};var Cl=[2062260,16744206,2924588,14034728,9725885,9197131,14907330,8355711,12369186,1556175].map(_t),zl=[2062260,11454440,16744206,16759672,2924588,10018698,14034728,16750742,9725885,12955861,9197131,12885140,14907330,16234194,8355711,13092807,12369186,14408589,1556175,10410725].map(_t),Pl=[3750777,5395619,7040719,10264286,6519097,9216594,11915115,13556636,9202993,12426809,15186514,15190932,8666169,11356490,14049643,15177372,8077683,10834324,13528509,14589654].map(_t),Rl=[3244733,7057110,10406625,13032431,15095053,16616764,16625259,16634018,3253076,7652470,10607003,13101504,7695281,10394312,12369372,14342891,6513507,9868950,12434877,14277081].map(_t);co.scale.quantile=function(){return ca([],[])},co.scale.quantize=function(){return ua(0,1,[0,1])},co.scale.threshold=function(){return fa([.5],[0,1])},co.scale.identity=function(){return ha([0,1])},co.svg={},co.svg.arc=function(){function t(){var t=Math.max(0,+r.apply(this,arguments)),c=Math.max(0,+n.apply(this,arguments)),u=o.apply(this,arguments)-Ho,f=s.apply(this,arguments)-Ho,h=Math.abs(f-u),d=u>f?0:1;if(t>c&&(p=c,c=t,t=p),h>=qo)return e(c,d)+(t?e(t,1-d):"")+"Z";var p,g,v,m,y,b,x,_,w,k,A,M,T=0,E=0,L=[];if((m=(+l.apply(this,arguments)||0)/2)&&(v=a===Ol?Math.sqrt(t*t+c*c):+a.apply(this,arguments),d||(E*=-1),c&&(E=nt(v/c*Math.sin(m))),t&&(T=nt(v/t*Math.sin(m)))),c){y=c*Math.cos(u+E),b=c*Math.sin(u+E),x=c*Math.cos(f-E),_=c*Math.sin(f-E);var S=Math.abs(f-u-2*E)<=Uo?0:1;if(E&&ba(y,b,x,_)===d^S){var C=(u+f)/2;y=c*Math.cos(C),b=c*Math.sin(C),x=_=null}}else y=b=0;if(t){w=t*Math.cos(f-T),k=t*Math.sin(f-T),A=t*Math.cos(u+T),M=t*Math.sin(u+T);var z=Math.abs(u-f+2*T)<=Uo?0:1;if(T&&ba(w,k,A,M)===1-d^z){
+var P=(u+f)/2;w=t*Math.cos(P),k=t*Math.sin(P),A=M=null}}else w=k=0;if(h>Do&&(p=Math.min(Math.abs(c-t)/2,+i.apply(this,arguments)))>.001){g=c>t^d?0:1;var R=p,O=p;if(Uo>h){var I=null==A?[w,k]:null==x?[y,b]:Ir([y,b],[A,M],[x,_],[w,k]),N=y-I[0],j=b-I[1],F=x-I[0],D=_-I[1],B=1/Math.sin(Math.acos((N*F+j*D)/(Math.sqrt(N*N+j*j)*Math.sqrt(F*F+D*D)))/2),U=Math.sqrt(I[0]*I[0]+I[1]*I[1]);O=Math.min(p,(t-U)/(B-1)),R=Math.min(p,(c-U)/(B+1))}if(null!=x){var V=xa(null==A?[w,k]:[A,M],[y,b],c,R,d),q=xa([x,_],[w,k],c,R,d);p===R?L.push("M",V[0],"A",R,",",R," 0 0,",g," ",V[1],"A",c,",",c," 0 ",1-d^ba(V[1][0],V[1][1],q[1][0],q[1][1]),",",d," ",q[1],"A",R,",",R," 0 0,",g," ",q[0]):L.push("M",V[0],"A",R,",",R," 0 1,",g," ",q[0])}else L.push("M",y,",",b);if(null!=A){var H=xa([y,b],[A,M],t,-O,d),G=xa([w,k],null==x?[y,b]:[x,_],t,-O,d);p===O?L.push("L",G[0],"A",O,",",O," 0 0,",g," ",G[1],"A",t,",",t," 0 ",d^ba(G[1][0],G[1][1],H[1][0],H[1][1]),",",1-d," ",H[1],"A",O,",",O," 0 0,",g," ",H[0]):L.push("L",G[0],"A",O,",",O," 0 0,",g," ",H[0])}else L.push("L",w,",",k)}else L.push("M",y,",",b),null!=x&&L.push("A",c,",",c," 0 ",S,",",d," ",x,",",_),L.push("L",w,",",k),null!=A&&L.push("A",t,",",t," 0 ",z,",",1-d," ",A,",",M);return L.push("Z"),L.join("")}function e(t,e){return"M0,"+t+"A"+t+","+t+" 0 1,"+e+" 0,"+-t+"A"+t+","+t+" 0 1,"+e+" 0,"+t}var r=pa,n=ga,i=da,a=Ol,o=va,s=ma,l=ya;return t.innerRadius=function(e){return arguments.length?(r=Lt(e),t):r},t.outerRadius=function(e){return arguments.length?(n=Lt(e),t):n},t.cornerRadius=function(e){return arguments.length?(i=Lt(e),t):i},t.padRadius=function(e){return arguments.length?(a=e==Ol?Ol:Lt(e),t):a},t.startAngle=function(e){return arguments.length?(o=Lt(e),t):o},t.endAngle=function(e){return arguments.length?(s=Lt(e),t):s},t.padAngle=function(e){return arguments.length?(l=Lt(e),t):l},t.centroid=function(){var t=(+r.apply(this,arguments)+ +n.apply(this,arguments))/2,e=(+o.apply(this,arguments)+ +s.apply(this,arguments))/2-Ho;return[Math.cos(e)*t,Math.sin(e)*t]},t};var Ol="auto";co.svg.line=function(){return _a(x)};var Il=co.map({linear:wa,"linear-closed":ka,step:Aa,"step-before":Ma,"step-after":Ta,basis:Pa,"basis-open":Ra,"basis-closed":Oa,bundle:Ia,cardinal:Sa,"cardinal-open":Ea,"cardinal-closed":La,monotone:Ua});Il.forEach(function(t,e){e.key=t,e.closed=/-closed$/.test(t)});var Nl=[0,2/3,1/3,0],jl=[0,1/3,2/3,0],Fl=[0,1/6,2/3,1/6];co.svg.line.radial=function(){var t=_a(Va);return t.radius=t.x,delete t.x,t.angle=t.y,delete t.y,t},Ma.reverse=Ta,Ta.reverse=Ma,co.svg.area=function(){return qa(x)},co.svg.area.radial=function(){var t=qa(Va);return t.radius=t.x,delete t.x,t.innerRadius=t.x0,delete t.x0,t.outerRadius=t.x1,delete t.x1,t.angle=t.y,delete t.y,t.startAngle=t.y0,delete t.y0,t.endAngle=t.y1,delete t.y1,t},co.svg.chord=function(){function t(t,s){var l=e(this,a,t,s),c=e(this,o,t,s);return"M"+l.p0+n(l.r,l.p1,l.a1-l.a0)+(r(l,c)?i(l.r,l.p1,l.r,l.p0):i(l.r,l.p1,c.r,c.p0)+n(c.r,c.p1,c.a1-c.a0)+i(c.r,c.p1,l.r,l.p0))+"Z"}function e(t,e,r,n){var i=e.call(t,r,n),a=s.call(t,i,n),o=l.call(t,i,n)-Ho,u=c.call(t,i,n)-Ho;return{r:a,a0:o,a1:u,p0:[a*Math.cos(o),a*Math.sin(o)],p1:[a*Math.cos(u),a*Math.sin(u)]}}function r(t,e){return t.a0==e.a0&&t.a1==e.a1}function n(t,e,r){return"A"+t+","+t+" 0 "+ +(r>Uo)+",1 "+e}function i(t,e,r,n){return"Q 0,0 "+n}var a=xr,o=_r,s=Ha,l=va,c=ma;return t.radius=function(e){return arguments.length?(s=Lt(e),t):s},t.source=function(e){return arguments.length?(a=Lt(e),t):a},t.target=function(e){return arguments.length?(o=Lt(e),t):o},t.startAngle=function(e){return arguments.length?(l=Lt(e),t):l},t.endAngle=function(e){return arguments.length?(c=Lt(e),t):c},t},co.svg.diagonal=function(){function t(t,i){var a=e.call(this,t,i),o=r.call(this,t,i),s=(a.y+o.y)/2,l=[a,{x:a.x,y:s},{x:o.x,y:s},o];return l=l.map(n),"M"+l[0]+"C"+l[1]+" "+l[2]+" "+l[3]}var e=xr,r=_r,n=Ga;return t.source=function(r){return arguments.length?(e=Lt(r),t):e},t.target=function(e){return arguments.length?(r=Lt(e),t):r},t.projection=function(e){return arguments.length?(n=e,t):n},t},co.svg.diagonal.radial=function(){var t=co.svg.diagonal(),e=Ga,r=t.projection;return t.projection=function(t){return arguments.length?r(Ya(e=t)):e},t},co.svg.symbol=function(){function t(t,n){return(Dl.get(e.call(this,t,n))||Za)(r.call(this,t,n))}var e=Wa,r=Xa;return t.type=function(r){return arguments.length?(e=Lt(r),t):e},t.size=function(e){return arguments.length?(r=Lt(e),t):r},t};var Dl=co.map({circle:Za,cross:function(t){var e=Math.sqrt(t/5)/2;return"M"+-3*e+","+-e+"H"+-e+"V"+-3*e+"H"+e+"V"+-e+"H"+3*e+"V"+e+"H"+e+"V"+3*e+"H"+-e+"V"+e+"H"+-3*e+"Z"},diamond:function(t){var e=Math.sqrt(t/(2*Ul)),r=e*Ul;return"M0,"+-e+"L"+r+",0 0,"+e+" "+-r+",0Z"},square:function(t){var e=Math.sqrt(t)/2;return"M"+-e+","+-e+"L"+e+","+-e+" "+e+","+e+" "+-e+","+e+"Z"},"triangle-down":function(t){var e=Math.sqrt(t/Bl),r=e*Bl/2;return"M0,"+r+"L"+e+","+-r+" "+-e+","+-r+"Z"},"triangle-up":function(t){var e=Math.sqrt(t/Bl),r=e*Bl/2;return"M0,"+-r+"L"+e+","+r+" "+-e+","+r+"Z"}});co.svg.symbolTypes=Dl.keys();var Bl=Math.sqrt(3),Ul=Math.tan(30*Go);zo.transition=function(t){for(var e,r,n=Vl||++Yl,i=to(t),a=[],o=ql||{time:Date.now(),ease:Ln,delay:0,duration:250},s=-1,l=this.length;++sa;a++){i.push(e=[]);for(var r=this[a],s=0,l=r.length;l>s;s++)(n=r[s])&&t.call(n,n.__data__,s,a)&&e.push(n)}return $a(i,this.namespace,this.id)},Gl.tween=function(t,e){var r=this.id,n=this.namespace;return arguments.length<2?this.node()[n][r].tween.get(t):G(this,null==e?function(e){e[n][r].tween.remove(t)}:function(i){i[n][r].tween.set(t,e)})},Gl.attr=function(t,e){function r(){this.removeAttribute(s)}function n(){this.removeAttributeNS(s.space,s.local)}function i(t){return null==t?r:(t+="",function(){var e,r=this.getAttribute(s);return r!==t&&(e=o(r,t),function(t){this.setAttribute(s,e(t))})})}function a(t){return null==t?n:(t+="",function(){var e,r=this.getAttributeNS(s.space,s.local);return r!==t&&(e=o(r,t),function(t){this.setAttributeNS(s.space,s.local,e(t))})})}if(arguments.length<2){for(e in t)this.attr(e,t[e]);return this}var o="transform"==t?Zn:_n,s=co.ns.qualify(t);return Qa(this,"attr."+t,e,s.local?a:i)},Gl.attrTween=function(t,e){function r(t,r){var n=e.call(this,t,r,this.getAttribute(i));return n&&function(t){this.setAttribute(i,n(t))}}function n(t,r){var n=e.call(this,t,r,this.getAttributeNS(i.space,i.local));return n&&function(t){this.setAttributeNS(i.space,i.local,n(t))}}var i=co.ns.qualify(t);return this.tween("attr."+t,i.local?n:r)},Gl.style=function(t,e,r){function i(){this.style.removeProperty(t)}function a(e){return null==e?i:(e+="",function(){var i,a=n(this).getComputedStyle(this,null).getPropertyValue(t);return a!==e&&(i=_n(a,e),function(e){this.style.setProperty(t,i(e),r)})})}var o=arguments.length;if(3>o){if("string"!=typeof t){2>o&&(e="");for(r in t)this.style(r,t[r],e);return this}r=""}return Qa(this,"style."+t,e,a)},Gl.styleTween=function(t,e,r){function i(i,a){var o=e.call(this,i,a,n(this).getComputedStyle(this,null).getPropertyValue(t));return o&&function(e){this.style.setProperty(t,o(e),r)}}return arguments.length<3&&(r=""),this.tween("style."+t,i)},Gl.text=function(t){return Qa(this,"text",t,Ja)},Gl.remove=function(){var t=this.namespace;return this.each("end.transition",function(){var e;this[t].count<2&&(e=this.parentNode)&&e.removeChild(this)})},Gl.ease=function(t){var e=this.id,r=this.namespace;return arguments.length<1?this.node()[r][e].ease:("function"!=typeof t&&(t=co.ease.apply(co,arguments)),G(this,function(n){n[r][e].ease=t}))},Gl.delay=function(t){var e=this.id,r=this.namespace;return arguments.length<1?this.node()[r][e].delay:G(this,"function"==typeof t?function(n,i,a){n[r][e].delay=+t.call(n,n.__data__,i,a)}:(t=+t,function(n){n[r][e].delay=t}))},Gl.duration=function(t){var e=this.id,r=this.namespace;return arguments.length<1?this.node()[r][e].duration:G(this,"function"==typeof t?function(n,i,a){n[r][e].duration=Math.max(1,t.call(n,n.__data__,i,a))}:(t=Math.max(1,t),function(n){n[r][e].duration=t}))},Gl.each=function(t,e){var r=this.id,n=this.namespace;if(arguments.length<2){var i=ql,a=Vl;try{Vl=r,G(this,function(e,i,a){ql=e[n][r],t.call(e,e.__data__,i,a)})}finally{ql=i,Vl=a}}else G(this,function(i){var a=i[n][r];(a.event||(a.event=co.dispatch("start","end","interrupt"))).on(t,e)});return this},Gl.transition=function(){for(var t,e,r,n,i=this.id,a=++Yl,o=this.namespace,s=[],l=0,c=this.length;c>l;l++){s.push(t=[]);for(var e=this[l],u=0,f=e.length;f>u;u++)(r=e[u])&&(n=r[o][i],eo(r,u,o,a,{time:n.time,ease:n.ease,delay:n.delay+n.duration,duration:n.duration})),t.push(r)}return $a(s,o,a)},co.svg.axis=function(){function t(t){t.each(function(){var t,c=co.select(this),u=this.__chart__||r,f=this.__chart__=r.copy(),h=null==l?f.ticks?f.ticks.apply(f,s):f.domain():l,d=null==e?f.tickFormat?f.tickFormat.apply(f,s):x:e,p=c.selectAll(".tick").data(h,f),g=p.enter().insert("g",".domain").attr("class","tick").style("opacity",Do),v=co.transition(p.exit()).style("opacity",Do).remove(),m=co.transition(p.order()).style("opacity",1),y=Math.max(i,0)+o,b=Yi(f),_=c.selectAll(".domain").data([0]),w=(_.enter().append("path").attr("class","domain"),co.transition(_));g.append("line"),g.append("text");var k,A,M,T,E=g.select("line"),L=m.select("line"),S=p.select("text").text(d),C=g.select("text"),z=m.select("text"),P="top"===n||"left"===n?-1:1;if("bottom"===n||"top"===n?(t=ro,k="x",M="y",A="x2",T="y2",S.attr("dy",0>P?"0em":".71em").style("text-anchor","middle"),w.attr("d","M"+b[0]+","+P*a+"V0H"+b[1]+"V"+P*a)):(t=no,k="y",M="x",A="y2",T="x2",S.attr("dy",".32em").style("text-anchor",0>P?"end":"start"),w.attr("d","M"+P*a+","+b[0]+"H0V"+b[1]+"H"+P*a)),E.attr(T,P*i),C.attr(M,P*y),L.attr(A,0).attr(T,P*i),z.attr(k,0).attr(M,P*y),f.rangeBand){var R=f,O=R.rangeBand()/2;u=f=function(t){return R(t)+O}}else u.rangeBand?u=f:v.call(t,f,u);g.call(t,u,f),m.call(t,f,f)})}var e,r=co.scale.linear(),n=Xl,i=6,a=6,o=3,s=[10],l=null;return t.scale=function(e){return arguments.length?(r=e,t):r},t.orient=function(e){return arguments.length?(n=e in Wl?e+"":Xl,t):n},t.ticks=function(){return arguments.length?(s=fo(arguments),t):s},t.tickValues=function(e){return arguments.length?(l=e,t):l},t.tickFormat=function(r){return arguments.length?(e=r,t):e},t.tickSize=function(e){var r=arguments.length;return r?(i=+e,a=+arguments[r-1],t):i},t.innerTickSize=function(e){return arguments.length?(i=+e,t):i},t.outerTickSize=function(e){return arguments.length?(a=+e,t):a},t.tickPadding=function(e){return arguments.length?(o=+e,t):o},t.tickSubdivide=function(){return arguments.length&&t},t};var Xl="bottom",Wl={top:1,right:1,bottom:1,left:1};co.svg.brush=function(){function t(n){n.each(function(){var n=co.select(this).style("pointer-events","all").style("-webkit-tap-highlight-color","rgba(0,0,0,0)").on("mousedown.brush",a).on("touchstart.brush",a),o=n.selectAll(".background").data([0]);o.enter().append("rect").attr("class","background").style("visibility","hidden").style("cursor","crosshair"),n.selectAll(".extent").data([0]).enter().append("rect").attr("class","extent").style("cursor","move");var s=n.selectAll(".resize").data(g,x);s.exit().remove(),s.enter().append("g").attr("class",function(t){return"resize "+t}).style("cursor",function(t){return Zl[t]}).append("rect").attr("x",function(t){return/[ew]$/.test(t)?-3:null}).attr("y",function(t){return/^[ns]/.test(t)?-3:null}).attr("width",6).attr("height",6).style("visibility","hidden"),s.style("display",t.empty()?"none":null);var l,f=co.transition(n),h=co.transition(o);c&&(l=Yi(c),h.attr("x",l[0]).attr("width",l[1]-l[0]),r(f)),u&&(l=Yi(u),h.attr("y",l[0]).attr("height",l[1]-l[0]),i(f)),e(f)})}function e(t){t.selectAll(".resize").attr("transform",function(t){return"translate("+f[+/e$/.test(t)]+","+h[+/^s/.test(t)]+")"})}function r(t){t.select(".extent").attr("x",f[0]),t.selectAll(".extent,.n>rect,.s>rect").attr("width",f[1]-f[0])}function i(t){t.select(".extent").attr("y",h[0]),t.selectAll(".extent,.e>rect,.w>rect").attr("height",h[1]-h[0])}function a(){function a(){32==co.event.keyCode&&(S||(b=null,z[0]-=f[1],z[1]-=h[1],S=2),T())}function g(){32==co.event.keyCode&&2==S&&(z[0]+=f[1],z[1]+=h[1],S=0,T())}function v(){var t=co.mouse(_),n=!1;x&&(t[0]+=x[0],t[1]+=x[1]),S||(co.event.altKey?(b||(b=[(f[0]+f[1])/2,(h[0]+h[1])/2]),z[0]=f[+(t[0]u?(i=n,n=u):i=u),g[0]!=n||g[1]!=i?(r?s=null:o=null,g[0]=n,g[1]=i,!0):void 0}function y(){v(),A.style("pointer-events","all").selectAll(".resize").style("display",t.empty()?"none":null),co.select("body").style("cursor",null),P.on("mousemove.brush",null).on("mouseup.brush",null).on("touchmove.brush",null).on("touchend.brush",null).on("keydown.brush",null).on("keyup.brush",null),C(),k({type:"brushend"})}var b,x,_=this,w=co.select(co.event.target),k=l.of(_,arguments),A=co.select(_),M=w.datum(),E=!/^(n|s)$/.test(M)&&c,L=!/^(e|w)$/.test(M)&&u,S=w.classed("extent"),C=$(_),z=co.mouse(_),P=co.select(n(_)).on("keydown.brush",a).on("keyup.brush",g);if(co.event.changedTouches?P.on("touchmove.brush",v).on("touchend.brush",y):P.on("mousemove.brush",v).on("mouseup.brush",y),A.interrupt().selectAll("*").interrupt(),S)z[0]=f[0]-z[0],z[1]=h[0]-z[1];else if(M){var R=+/w$/.test(M),O=+/^n/.test(M);x=[f[1-R]-z[0],h[1-O]-z[1]],z[0]=f[R],z[1]=h[O]}else co.event.altKey&&(b=z.slice());A.style("pointer-events","none").selectAll(".resize").style("display",null),co.select("body").style("cursor",w.style("cursor")),k({type:"brushstart"}),v()}var o,s,l=L(t,"brushstart","brush","brushend"),c=null,u=null,f=[0,0],h=[0,0],d=!0,p=!0,g=Kl[0];return t.event=function(t){t.each(function(){var t=l.of(this,arguments),e={x:f,y:h,i:o,j:s},r=this.__chart__||e;this.__chart__=e,Vl?co.select(this).transition().each("start.brush",function(){o=r.i,s=r.j,f=r.x,h=r.y,t({type:"brushstart"})}).tween("brush:brush",function(){var r=wn(f,e.x),n=wn(h,e.y);return o=s=null,function(i){f=e.x=r(i),h=e.y=n(i),t({type:"brush",mode:"resize"})}}).each("end.brush",function(){o=e.i,s=e.j,t({type:"brush",mode:"resize"}),t({type:"brushend"})}):(t({type:"brushstart"}),t({type:"brush",mode:"resize"}),t({type:"brushend"}))})},t.x=function(e){return arguments.length?(c=e,g=Kl[!c<<1|!u],t):c},t.y=function(e){return arguments.length?(u=e,g=Kl[!c<<1|!u],t):u},t.clamp=function(e){return arguments.length?(c&&u?(d=!!e[0],p=!!e[1]):c?d=!!e:u&&(p=!!e),t):c&&u?[d,p]:c?d:u?p:null},t.extent=function(e){var r,n,i,a,l;return arguments.length?(c&&(r=e[0],n=e[1],u&&(r=r[0],n=n[0]),o=[r,n],c.invert&&(r=c(r),n=c(n)),r>n&&(l=r,r=n,n=l),r==f[0]&&n==f[1]||(f=[r,n])),u&&(i=e[0],a=e[1],c&&(i=i[1],a=a[1]),s=[i,a],u.invert&&(i=u(i),a=u(a)),i>a&&(l=i,i=a,a=l),i==h[0]&&a==h[1]||(h=[i,a])),t):(c&&(o?(r=o[0],n=o[1]):(r=f[0],n=f[1],c.invert&&(r=c.invert(r),n=c.invert(n)),r>n&&(l=r,r=n,n=l))),u&&(s?(i=s[0],a=s[1]):(i=h[0],a=h[1],u.invert&&(i=u.invert(i),a=u.invert(a)),i>a&&(l=i,i=a,a=l))),c&&u?[[r,i],[n,a]]:c?[r,n]:u&&[i,a])},t.clear=function(){return t.empty()||(f=[0,0],h=[0,0],o=s=null),t},t.empty=function(){return!!c&&f[0]==f[1]||!!u&&h[0]==h[1]},co.rebind(t,l,"on")};var Zl={n:"ns-resize",e:"ew-resize",s:"ns-resize",w:"ew-resize",nw:"nwse-resize",ne:"nesw-resize",se:"nwse-resize",sw:"nesw-resize"},Kl=[["n","e","s","w","nw","ne","se","sw"],["e","w"],["n","s"],[]],$l=vs.format=ws.timeFormat,Ql=$l.utc,Jl=Ql("%Y-%m-%dT%H:%M:%S.%LZ");$l.iso=Date.prototype.toISOString&&+new Date("2000-01-01T00:00:00.000Z")?io:Jl,io.parse=function(t){var e=new Date(t);return isNaN(e)?null:e},io.toString=Jl.toString,vs.second=Vt(function(t){return new ms(1e3*Math.floor(t/1e3))},function(t,e){t.setTime(t.getTime()+1e3*Math.floor(e))},function(t){return t.getSeconds()}),vs.seconds=vs.second.range,vs.seconds.utc=vs.second.utc.range,vs.minute=Vt(function(t){return new ms(6e4*Math.floor(t/6e4))},function(t,e){t.setTime(t.getTime()+6e4*Math.floor(e))},function(t){return t.getMinutes()}),vs.minutes=vs.minute.range,vs.minutes.utc=vs.minute.utc.range,vs.hour=Vt(function(t){var e=t.getTimezoneOffset()/60;return new ms(36e5*(Math.floor(t/36e5-e)+e))},function(t,e){t.setTime(t.getTime()+36e5*Math.floor(e))},function(t){return t.getHours()}),vs.hours=vs.hour.range,vs.hours.utc=vs.hour.utc.range,vs.month=Vt(function(t){return t=vs.day(t),t.setDate(1),t},function(t,e){t.setMonth(t.getMonth()+e)},function(t){return t.getMonth()}),vs.months=vs.month.range,vs.months.utc=vs.month.utc.range;var tc=[1e3,5e3,15e3,3e4,6e4,3e5,9e5,18e5,36e5,108e5,216e5,432e5,864e5,1728e5,6048e5,2592e6,7776e6,31536e6],ec=[[vs.second,1],[vs.second,5],[vs.second,15],[vs.second,30],[vs.minute,1],[vs.minute,5],[vs.minute,15],[vs.minute,30],[vs.hour,1],[vs.hour,3],[vs.hour,6],[vs.hour,12],[vs.day,1],[vs.day,2],[vs.week,1],[vs.month,1],[vs.month,3],[vs.year,1]],rc=$l.multi([[".%L",function(t){return t.getMilliseconds()}],[":%S",function(t){return t.getSeconds()}],["%I:%M",function(t){return t.getMinutes()}],["%I %p",function(t){return t.getHours()}],["%a %d",function(t){return t.getDay()&&1!=t.getDate()}],["%b %d",function(t){return 1!=t.getDate()}],["%B",function(t){return t.getMonth()}],["%Y",ze]]),nc={range:function(t,e,r){return co.range(Math.ceil(t/r)*r,+e,r).map(oo)},floor:x,ceil:x};ec.year=vs.year,vs.scale=function(){return ao(co.scale.linear(),ec,rc)};var ic=ec.map(function(t){return[t[0].utc,t[1]]}),ac=Ql.multi([[".%L",function(t){return t.getUTCMilliseconds()}],[":%S",function(t){return t.getUTCSeconds()}],["%I:%M",function(t){return t.getUTCMinutes()}],["%I %p",function(t){return t.getUTCHours()}],["%a %d",function(t){return t.getUTCDay()&&1!=t.getUTCDate()}],["%b %d",function(t){return 1!=t.getUTCDate()}],["%B",function(t){return t.getUTCMonth()}],["%Y",ze]]);ic.year=vs.year.utc,vs.scale.utc=function(){return ao(co.scale.linear(),ic,ac)},co.text=St(function(t){return t.responseText}),co.json=function(t,e){return Ct(t,"application/json",so,e)},co.html=function(t,e){return Ct(t,"text/html",lo,e)},co.xml=St(function(t){return t.responseXML}),"function"==typeof t&&t.amd?(this.d3=co,t(co)):"object"==typeof r&&r.exports?r.exports=co:this.d3=co}()},{}],114:[function(t,e,r){"use strict";function n(t,e){this.point=t,this.index=e}function i(t,e){for(var r=t.point,n=e.point,i=r.length,a=0;i>a;++a){var o=n[a]-r[a];if(o)return o}return 0}function a(t,e,r){if(1===t)return r?[[-1,0]]:[];var n=e.map(function(t,e){return[t[0],e]});n.sort(function(t,e){return t[0]-e[0]});for(var i=new Array(t-1),a=1;t>a;++a){var o=n[a-1],s=n[a];i[a-1]=[o[1],s[1]]}return r&&i.push([-1,i[0][1]],[i[t-1][1],-1]),i}function o(t,e){var r=t.length;if(0===r)return[];var o=t[0].length;if(1>o)return[];if(1===o)return a(r,t,e);for(var c=new Array(r),u=1,f=0;r>f;++f){for(var h=t[f],d=new Array(o+1),p=0,g=0;o>g;++g){var v=h[g];d[g]=v,p+=v*v}d[o]=p,c[f]=new n(d,f),u=Math.max(p,u)}l(c,i),r=c.length;for(var m=new Array(r+o+1),y=new Array(r+o+1),b=(o+1)*(o+1)*u,x=new Array(o+1),f=0;o>=f;++f)x[f]=0;x[o]=b,m[0]=x.slice(),y[0]=-1;for(var f=0;o>=f;++f){var d=x.slice();d[f]=1,m[f+1]=d,y[f+1]=-1}for(var f=0;r>f;++f){var _=c[f];m[f+o+1]=_.point,y[f+o+1]=_.index}var w=s(m,!1);if(w=e?w.filter(function(t){for(var e=0,r=0;o>=r;++r){var n=y[t[r]];if(0>n&&++e>=2)return!1;t[r]=n}return!0}):w.filter(function(t){for(var e=0;o>=e;++e){var r=y[t[e]];if(0>r)return!1;t[e]=r}return!0}),1&o)for(var f=0;f=i)return[];var a,o=new Array(i);if(r===t.length-1)for(a=0;i>a;++a)o[a]=e;else for(a=0;i>a;++a)o[a]=n(t,e,r+1);return o}function i(t,e){var r,n;for(r=new Array(t),n=0;t>n;++n)r[n]=e;return r}function a(t,e){switch("undefined"==typeof e&&(e=0),typeof t){case"number":if(t>0)return i(0|t,e);break;case"object":if("number"==typeof t.length)return n(t,e,0)}return[]}e.exports=a},{}],116:[function(e,r,n){(function(n,i){(function(){"use strict";function a(t){return"function"==typeof t||"object"==typeof t&&null!==t}function o(t){return"function"==typeof t}function s(t){Y=t}function l(t){K=t}function c(){return function(){n.nextTick(p)}}function u(){return function(){G(p)}}function f(){var t=0,e=new J(p),r=document.createTextNode("");return e.observe(r,{characterData:!0}),function(){r.data=t=++t%2}}function h(){var t=new MessageChannel;return t.port1.onmessage=p,function(){t.port2.postMessage(0)}}function d(){return function(){setTimeout(p,1)}}function p(){for(var t=0;Z>t;t+=2){var e=rt[t],r=rt[t+1];e(r),rt[t]=void 0,rt[t+1]=void 0}Z=0}function g(){try{var t=e,r=t("vertx");return G=r.runOnLoop||r.runOnContext,u()}catch(n){return d()}}function v(t,e){var r=this,n=r._state;if(n===ot&&!t||n===st&&!e)return this;var i=new this.constructor(y),a=r._result;if(n){var o=arguments[n-1];K(function(){O(n,i,o,a)})}else C(r,i,t,e);return i}function m(t){var e=this;if(t&&"object"==typeof t&&t.constructor===e)return t;var r=new e(y);return T(r,t),r}function y(){}function b(){return new TypeError("You cannot resolve a promise with itself")}function x(){return new TypeError("A promises callback cannot return that same promise.")}function _(t){try{return t.then}catch(e){return lt.error=e,lt}}function w(t,e,r,n){try{t.call(e,r,n)}catch(i){return i}}function k(t,e,r){K(function(t){var n=!1,i=w(r,e,function(r){n||(n=!0,e!==r?T(t,r):L(t,r))},function(e){n||(n=!0,S(t,e))},"Settle: "+(t._label||" unknown promise"));!n&&i&&(n=!0,S(t,i))},t)}function A(t,e){e._state===ot?L(t,e._result):e._state===st?S(t,e._result):C(e,void 0,function(e){T(t,e)},function(e){S(t,e)})}function M(t,e,r){e.constructor===t.constructor&&r===nt&&constructor.resolve===it?A(t,e):r===lt?S(t,lt.error):void 0===r?L(t,e):o(r)?k(t,e,r):L(t,e)}function T(t,e){t===e?S(t,b()):a(e)?M(t,e,_(e)):L(t,e)}function E(t){t._onerror&&t._onerror(t._result),z(t)}function L(t,e){t._state===at&&(t._result=e,t._state=ot,0!==t._subscribers.length&&K(z,t))}function S(t,e){t._state===at&&(t._state=st,t._result=e,K(E,t))}function C(t,e,r,n){var i=t._subscribers,a=i.length;t._onerror=null,i[a]=e,i[a+ot]=r,i[a+st]=n,0===a&&t._state&&K(z,t)}function z(t){var e=t._subscribers,r=t._state;if(0!==e.length){for(var n,i,a=t._result,o=0;oo;o++)C(n.resolve(t[o]),void 0,e,r);return i}function F(t){var e=this,r=new e(y);return S(r,t),r}function D(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}function B(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}function U(t){this._id=dt++,this._state=void 0,this._result=void 0,this._subscribers=[],y!==t&&("function"!=typeof t&&D(),this instanceof U?I(this,t):B())}function V(t,e){this._instanceConstructor=t,this.promise=new t(y),Array.isArray(e)?(this._input=e,this.length=e.length,this._remaining=e.length,this._result=new Array(this.length),0===this.length?L(this.promise,this._result):(this.length=this.length||0,this._enumerate(),0===this._remaining&&L(this.promise,this._result))):S(this.promise,this._validationError())}function q(){var t;if("undefined"!=typeof i)t=i;else if("undefined"!=typeof self)t=self;else try{t=Function("return this")()}catch(e){throw new Error("polyfill failed because global object is unavailable in this environment")}var r=t.Promise;r&&"[object Promise]"===Object.prototype.toString.call(r.resolve())&&!r.cast||(t.Promise=pt)}var H;H=Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)};var G,Y,X,W=H,Z=0,K=function(t,e){rt[Z]=t,rt[Z+1]=e,Z+=2,2===Z&&(Y?Y(p):X())},$="undefined"!=typeof window?window:void 0,Q=$||{},J=Q.MutationObserver||Q.WebKitMutationObserver,tt="undefined"!=typeof n&&"[object process]"==={}.toString.call(n),et="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel,rt=new Array(1e3);X=tt?c():J?f():et?h():void 0===$&&"function"==typeof e?g():d();var nt=v,it=m,at=void 0,ot=1,st=2,lt=new P,ct=new P,ut=N,ft=j,ht=F,dt=0,pt=U;U.all=ut,U.race=ft,U.resolve=it,U.reject=ht,U._setScheduler=s,U._setAsap=l,U._asap=K,U.prototype={constructor:U,then:nt,"catch":function(t){return this.then(null,t)}};var gt=V;V.prototype._validationError=function(){return new Error("Array Methods must be provided an Array")},V.prototype._enumerate=function(){for(var t=this.length,e=this._input,r=0;this._state===at&&t>r;r++)this._eachEntry(e[r],r)},V.prototype._eachEntry=function(t,e){var r=this._instanceConstructor,n=r.resolve;if(n===it){var i=_(t);if(i===nt&&t._state!==at)this._settledAt(t._state,e,t._result);else if("function"!=typeof i)this._remaining--,this._result[e]=t;else if(r===pt){var a=new r(y);M(a,t,i),this._willSettleAt(a,e)}else this._willSettleAt(new r(function(e){e(t)}),e)}else this._willSettleAt(n(t),e)},V.prototype._settledAt=function(t,e,r){var n=this.promise;n._state===at&&(this._remaining--,t===st?S(n,r):this._result[e]=r),0===this._remaining&&L(n,this._result)},V.prototype._willSettleAt=function(t,e){var r=this;C(t,void 0,function(t){r._settledAt(ot,e,t)},function(t){r._settledAt(st,e,t)})};var vt=q,mt={Promise:pt,polyfill:vt};"function"==typeof t&&t.amd?t(function(){return mt}):"undefined"!=typeof r&&r.exports?r.exports=mt:"undefined"!=typeof this&&(this.ES6Promise=mt),vt()}).call(this)}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:56}],117:[function(t,e,r){"use strict";function n(t){for(var e,r=t.length,n=0;r>n;n++)if(e=t.charCodeAt(n),(9>e||e>13)&&32!==e&&133!==e&&160!==e&&5760!==e&&6158!==e&&(8192>e||e>8205)&&8232!==e&&8233!==e&&8239!==e&&8287!==e&&8288!==e&&12288!==e&&65279!==e)return!1;return!0}e.exports=function(t){var e=typeof t;if("string"===e){var r=t;if(t=+t,0===t&&n(r))return!1}else if("number"!==e)return!1;return 1>t-t}},{}],118:[function(t,e,r){"use strict";function n(t,e,r,n,i){this.gl=t,this.type=e,this.handle=r,this.length=n,this.usage=i}function i(t,e,r,n,i,a){var o=i.length*i.BYTES_PER_ELEMENT;if(0>a)return t.bufferData(e,i,n),o;if(o+a>r)throw new Error("gl-buffer: If resizing buffer, must not specify offset");return t.bufferSubData(e,a,i),r}function a(t,e){for(var r=l.malloc(t.length,e),n=t.length,i=0;n>i;++i)r[i]=t[i];return r}function o(t,e){for(var r=1,n=e.length-1;n>=0;--n){if(e[n]!==r)return!1;r*=t[n]}return!0}function s(t,e,r,i){if(r=r||t.ARRAY_BUFFER,i=i||t.DYNAMIC_DRAW,r!==t.ARRAY_BUFFER&&r!==t.ELEMENT_ARRAY_BUFFER)throw new Error("gl-buffer: Invalid type for webgl buffer, must be either gl.ARRAY_BUFFER or gl.ELEMENT_ARRAY_BUFFER");if(i!==t.DYNAMIC_DRAW&&i!==t.STATIC_DRAW&&i!==t.STREAM_DRAW)throw new Error("gl-buffer: Invalid usage for buffer, must be either gl.DYNAMIC_DRAW, gl.STATIC_DRAW or gl.STREAM_DRAW");var a=t.createBuffer(),o=new n(t,r,a,0,i);return o.update(e),o}var l=t("typedarray-pool"),c=t("ndarray-ops"),u=t("ndarray"),f=["uint8","uint8_clamped","uint16","uint32","int8","int16","int32","float32"],h=n.prototype;h.bind=function(){this.gl.bindBuffer(this.type,this.handle)},h.unbind=function(){this.gl.bindBuffer(this.type,null)},h.dispose=function(){this.gl.deleteBuffer(this.handle)},h.update=function(t,e){if("number"!=typeof e&&(e=-1),this.bind(),"object"==typeof t&&"undefined"!=typeof t.shape){var r=t.dtype;if(f.indexOf(r)<0&&(r="float32"),this.type===this.gl.ELEMENT_ARRAY_BUFFER){var n=gl.getExtension("OES_element_index_uint");r=n&&"uint16"!==r?"uint32":"uint16"}if(r===t.dtype&&o(t.shape,t.stride))0===t.offset&&t.data.length===t.shape[0]?this.length=i(this.gl,this.type,this.length,this.usage,t.data,e):this.length=i(this.gl,this.type,this.length,this.usage,t.data.subarray(t.offset,t.shape[0]),e);else{var s=l.malloc(t.size,r),h=u(s,t.shape);c.assign(h,t),0>e?this.length=i(this.gl,this.type,this.length,this.usage,s,e):this.length=i(this.gl,this.type,this.length,this.usage,s.subarray(0,t.size),e),l.free(s)}}else if(Array.isArray(t)){var d;d=this.type===this.gl.ELEMENT_ARRAY_BUFFER?a(t,"uint16"):a(t,"float32"),0>e?this.length=i(this.gl,this.type,this.length,this.usage,d,e):this.length=i(this.gl,this.type,this.length,this.usage,d.subarray(0,t.length),e),l.free(d)}else if("object"==typeof t&&"number"==typeof t.length)this.length=i(this.gl,this.type,this.length,this.usage,t,e);else{if("number"!=typeof t&&void 0!==t)throw new Error("gl-buffer: Invalid data type");if(e>=0)throw new Error("gl-buffer: Cannot specify offset when resizing buffer");t=0|t,0>=t&&(t=1),this.gl.bufferData(this.type,0|t,this.usage),this.length=t}},e.exports=s},{ndarray:253,"ndarray-ops":252,"typedarray-pool":278}],119:[function(t,e,r){"use strict";function n(t,e,r){this.plot=t,this.shader=e,this.buffer=r,this.bounds=[1/0,1/0,-(1/0),-(1/0)],this.numPoints=0,this.color=[0,0,0,1]}function i(t,e){var r=a(t.gl,l.vertex,l.fragment),i=o(t.gl),s=new n(t,r,i);return s.update(e),t.addObject(s),s}var a=t("gl-shader"),o=t("gl-buffer"),s=t("typedarray-pool"),l=t("./lib/shaders");e.exports=i;var c=[[1,0,0,1,0,0],[1,0,0,-1,0,0],[-1,0,0,-1,0,0],[-1,0,0,-1,0,0],[-1,0,0,1,0,0],[1,0,0,1,0,0],[1,0,-1,0,0,1],[1,0,-1,0,0,-1],[1,0,1,0,0,-1],[1,0,1,0,0,-1],[1,0,1,0,0,1],[1,0,-1,0,0,1],[-1,0,-1,0,0,1],[-1,0,-1,0,0,-1],[-1,0,1,0,0,-1],[-1,0,1,0,0,-1],[-1,0,1,0,0,1],[-1,0,-1,0,0,1],[0,1,1,0,0,0],[0,1,-1,0,0,0],[0,-1,-1,0,0,0],[0,-1,-1,0,0,0],[0,1,1,0,0,0],[0,-1,1,0,0,0],[0,1,0,-1,1,0],[0,1,0,-1,-1,0],[0,1,0,1,-1,0],[0,1,0,1,1,0],[0,1,0,-1,1,0],[0,1,0,1,-1,0],[0,-1,0,-1,1,0],[0,-1,0,-1,-1,0],[0,-1,0,1,-1,0],[0,-1,0,1,1,0],[0,-1,0,-1,1,0],[0,-1,0,1,-1,0]],u=n.prototype;u.draw=function(){var t=[1,0,0,0,1,0,0,0,1],e=[1,1];return function(){var r=this.plot,n=this.shader,i=this.buffer,a=this.bounds,o=this.numPoints;if(o){var s=r.gl,l=r.dataBox,u=r.viewBox,f=r.pixelRatio,h=a[2]-a[0],d=a[3]-a[1],p=l[2]-l[0],g=l[3]-l[1];t[0]=2*h/p,t[4]=2*d/g,t[6]=2*(a[0]-l[0])/p-1,t[7]=2*(a[1]-l[1])/g-1;var v=u[2]-u[0],m=u[3]-u[1];e[0]=2*f/v,e[1]=2*f/m,i.bind(),n.bind(),n.uniforms.viewTransform=t,
+n.uniforms.pixelScale=e,n.uniforms.color=this.color,n.attributes.position.pointer(s.FLOAT,!1,16,0),n.attributes.pixelOffset.pointer(s.FLOAT,!1,16,8),s.drawArrays(s.TRIANGLES,0,o*c.length)}}}(),u.drawPick=function(t){return t},u.pick=function(t,e){return null},u.update=function(t){t=t||{};var e,r,n,i=t.positions||[],a=t.errors||[],o=1;"lineWidth"in t&&(o=+t.lineWidth);var l=5;"capSize"in t&&(l=+t.capSize),this.color=(t.color||[0,0,0,1]).slice();var u=this.bounds=[1/0,1/0,-(1/0),-(1/0)],f=this.numPoints=i.length>>1;for(e=0;f>e;++e)r=i[2*e],n=i[2*e+1],u[0]=Math.min(r,u[0]),u[1]=Math.min(n,u[1]),u[2]=Math.max(r,u[2]),u[3]=Math.max(n,u[3]);u[2]===u[0]&&(u[2]+=1),u[3]===u[1]&&(u[3]+=1);var h=1/(u[2]-u[0]),d=1/(u[3]-u[1]),p=u[0],g=u[1],v=s.mallocFloat32(f*c.length*4),m=0;for(e=0;f>e;++e){r=i[2*e],n=i[2*e+1];for(var y=a[4*e],b=a[4*e+1],x=a[4*e+2],_=a[4*e+3],w=0;wA?A*=y:A>0&&(A*=b),0>M?M*=x:M>0&&(M*=_),v[m++]=h*(r-p+A),v[m++]=d*(n-g+M),v[m++]=o*k[2]+(l+o)*k[4],v[m++]=o*k[3]+(l+o)*k[5]}}this.buffer.update(v),s.free(v)},u.dispose=function(){this.plot.removeObject(this),this.shader.dispose(),this.buffer.dispose()}},{"./lib/shaders":120,"gl-buffer":118,"gl-shader":197,"typedarray-pool":278}],120:[function(t,e,r){e.exports={vertex:"precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 position;\nattribute vec2 pixelOffset;\n\nuniform mat3 viewTransform;\nuniform vec2 pixelScale;\n\nvoid main() {\n vec3 scrPosition = viewTransform * vec3(position, 1);\n gl_Position = vec4(\n scrPosition.xy + scrPosition.z * pixelScale * pixelOffset,\n 0,\n scrPosition.z);\n}\n",fragment:"precision mediump float;\n#define GLSLIFY 1\n\nuniform vec4 color;\n\nvoid main() {\n gl_FragColor = vec4(color.rgb * color.a, color.a);\n}\n"}},{}],121:[function(t,e,r){"use strict";function n(t,e,r,n){this.gl=t,this.shader=n,this.buffer=e,this.vao=r,this.pixelRatio=1,this.bounds=[[1/0,1/0,1/0],[-(1/0),-(1/0),-(1/0)]],this.clipBounds=[[-(1/0),-(1/0),-(1/0)],[1/0,1/0,1/0]],this.lineWidth=[1,1,1],this.capSize=[10,10,10],this.lineCount=[0,0,0],this.lineOffset=[0,0,0],this.opacity=1}function i(t,e){for(var r=0;3>r;++r)t[0][r]=Math.min(t[0][r],e[r]),t[1][r]=Math.max(t[1][r],e[r])}function a(t,e,r,n){for(var i=h[n],a=0;a=1},f.isTransparent=function(){return this.opacity<1},f.drawTransparent=f.draw=function(t){var e=this.gl,r=this.shader.uniforms;this.shader.bind();var n=r.view=t.view||u,i=r.projection=t.projection||u;r.model=t.model||u,r.clipBounds=this.clipBounds,r.opacity=this.opacity;var a=n[12],o=n[13],s=n[14],l=n[15],c=this.pixelRatio*(i[3]*a+i[7]*o+i[11]*s+i[15]*l)/e.drawingBufferHeight;this.vao.bind();for(var f=0;3>f;++f)e.lineWidth(this.lineWidth[f]),r.capSize=this.capSize[f]*c,e.drawArrays(e.LINES,this.lineOffset[f],this.lineCount[f]);this.vao.unbind()};var h=function(){for(var t=new Array(3),e=0;3>e;++e){for(var r=[],n=1;2>=n;++n)for(var i=-1;1>=i;i+=2){var a=(n+e)%3,o=[0,0,0];o[a]=i,r.push(o)}t[e]=r}return t}();f.update=function(t){t=t||{},"lineWidth"in t&&(this.lineWidth=t.lineWidth,Array.isArray(this.lineWidth)||(this.lineWidth=[this.lineWidth,this.lineWidth,this.lineWidth])),"capSize"in t&&(this.capSize=t.capSize,Array.isArray(this.capSize)||(this.capSize=[this.capSize,this.capSize,this.capSize])),"opacity"in t&&(this.opacity=t.opacity);var e=t.color||[[0,0,0],[0,0,0],[0,0,0]],r=t.position,n=t.error;if(Array.isArray(e[0])||(e=[e,e,e]),r&&n){var o=[],s=r.length,l=0;this.bounds=[[1/0,1/0,1/0],[-(1/0),-(1/0),-(1/0)]],this.lineCount=[0,0,0];for(var c=0;3>c;++c){this.lineOffset[c]=l;t:for(var u=0;s>u;++u){for(var f=r[u],h=0;3>h;++h)if(isNaN(f[h])||!isFinite(f[h]))continue t;var d=n[u],p=e[c];if(Array.isArray(p[0])&&(p=e[u]),3===p.length&&(p=[p[0],p[1],p[2],1]),!isNaN(d[0][c])&&!isNaN(d[1][c])){if(d[0][c]<0){var g=f.slice();g[c]+=d[0][c],o.push(f[0],f[1],f[2],p[0],p[1],p[2],p[3],0,0,0,g[0],g[1],g[2],p[0],p[1],p[2],p[3],0,0,0),i(this.bounds,g),l+=2+a(o,g,p,c)}if(d[1][c]>0){var g=f.slice();g[c]+=d[1][c],o.push(f[0],f[1],f[2],p[0],p[1],p[2],p[3],0,0,0,g[0],g[1],g[2],p[0],p[1],p[2],p[3],0,0,0),i(this.bounds,g),l+=2+a(o,g,p,c)}}}this.lineCount[c]=l-this.lineOffset[c]}this.buffer.update(o)}},f.dispose=function(){this.shader.dispose(),this.buffer.dispose(),this.vao.dispose()}},{"./shaders/index":122,"gl-buffer":118,"gl-vao":226}],122:[function(t,e,r){"use strict";var n=t("gl-shader"),i="precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position, offset;\nattribute vec4 color;\nuniform mat4 model, view, projection;\nuniform float capSize;\nvarying vec4 fragColor;\nvarying vec3 fragPosition;\n\nvoid main() {\n vec4 worldPosition = model * vec4(position, 1.0);\n worldPosition = (worldPosition / worldPosition.w) + vec4(capSize * offset, 0.0);\n gl_Position = projection * view * worldPosition;\n fragColor = color;\n fragPosition = position;\n}",a="precision mediump float;\n#define GLSLIFY 1\nuniform vec3 clipBounds[2];\nuniform float opacity;\nvarying vec3 fragPosition;\nvarying vec4 fragColor;\n\nvoid main() {\n if(any(lessThan(fragPosition, clipBounds[0])) || any(greaterThan(fragPosition, clipBounds[1]))) {\n discard;\n }\n gl_FragColor = opacity * fragColor;\n}";e.exports=function(t){return n(t,i,a,null,[{name:"position",type:"vec3"},{name:"offset",type:"vec3"},{name:"color",type:"vec4"}])}},{"gl-shader":197}],123:[function(t,e,r){"use strict";function n(t){var e=t.getParameter(t.FRAMEBUFFER_BINDING),r=t.getParameter(t.RENDERBUFFER_BINDING),n=t.getParameter(t.TEXTURE_BINDING_2D);return[e,r,n]}function i(t,e){t.bindFramebuffer(t.FRAMEBUFFER,e[0]),t.bindRenderbuffer(t.RENDERBUFFER,e[1]),t.bindTexture(t.TEXTURE_2D,e[2])}function a(t,e){var r=t.getParameter(e.MAX_COLOR_ATTACHMENTS_WEBGL);y=new Array(r+1);for(var n=0;r>=n;++n){for(var i=new Array(r),a=0;n>a;++a)i[a]=t.COLOR_ATTACHMENT0+a;for(var a=n;r>a;++a)i[a]=t.NONE;y[n]=i}}function o(t){switch(t){case p:throw new Error("gl-fbo: Framebuffer unsupported");case g:throw new Error("gl-fbo: Framebuffer incomplete attachment");case v:throw new Error("gl-fbo: Framebuffer incomplete dimensions");case m:throw new Error("gl-fbo: Framebuffer incomplete missing attachment");default:throw new Error("gl-fbo: Framebuffer failed for unspecified reason")}}function s(t,e,r,n,i,a){if(!n)return null;var o=d(t,e,r,i,n);return o.magFilter=t.NEAREST,o.minFilter=t.NEAREST,o.mipSamples=1,o.bind(),t.framebufferTexture2D(t.FRAMEBUFFER,a,t.TEXTURE_2D,o.handle,0),o}function l(t,e,r,n,i){var a=t.createRenderbuffer();return t.bindRenderbuffer(t.RENDERBUFFER,a),t.renderbufferStorage(t.RENDERBUFFER,n,e,r),t.framebufferRenderbuffer(t.FRAMEBUFFER,i,t.RENDERBUFFER,a),a}function c(t){var e=n(t.gl),r=t.gl,a=t.handle=r.createFramebuffer(),c=t._shape[0],u=t._shape[1],f=t.color.length,h=t._ext,d=t._useStencil,p=t._useDepth,g=t._colorType;r.bindFramebuffer(r.FRAMEBUFFER,a);for(var v=0;f>v;++v)t.color[v]=s(r,c,u,g,r.RGBA,r.COLOR_ATTACHMENT0+v);0===f?(t._color_rb=l(r,c,u,r.RGBA4,r.COLOR_ATTACHMENT0),h&&h.drawBuffersWEBGL(y[0])):f>1&&h.drawBuffersWEBGL(y[f]);var m=r.getExtension("WEBGL_depth_texture");m?d?t.depth=s(r,c,u,m.UNSIGNED_INT_24_8_WEBGL,r.DEPTH_STENCIL,r.DEPTH_STENCIL_ATTACHMENT):p&&(t.depth=s(r,c,u,r.UNSIGNED_SHORT,r.DEPTH_COMPONENT,r.DEPTH_ATTACHMENT)):p&&d?t._depth_rb=l(r,c,u,r.DEPTH_STENCIL,r.DEPTH_STENCIL_ATTACHMENT):p?t._depth_rb=l(r,c,u,r.DEPTH_COMPONENT16,r.DEPTH_ATTACHMENT):d&&(t._depth_rb=l(r,c,u,r.STENCIL_INDEX,r.STENCIL_ATTACHMENT));var b=r.checkFramebufferStatus(r.FRAMEBUFFER);if(b!==r.FRAMEBUFFER_COMPLETE){t._destroyed=!0,r.bindFramebuffer(r.FRAMEBUFFER,null),r.deleteFramebuffer(t.handle),t.handle=null,t.depth&&(t.depth.dispose(),t.depth=null),t._depth_rb&&(r.deleteRenderbuffer(t._depth_rb),t._depth_rb=null);for(var v=0;vl;++l)this.color[l]=null;this._color_rb=null,this.depth=null,this._depth_rb=null,this._colorType=n,this._useDepth=a,this._useStencil=o;var u=this,f=[0|e,0|r];Object.defineProperties(f,{0:{get:function(){return u._shape[0]},set:function(t){return u.width=t}},1:{get:function(){return u._shape[1]},set:function(t){return u.height=t}}}),this._shapeVector=f,c(this)}function f(t,e,r){if(t._destroyed)throw new Error("gl-fbo: Can't resize destroyed FBO");if(t._shape[0]!==e||t._shape[1]!==r){var a=t.gl,s=a.getParameter(a.MAX_RENDERBUFFER_SIZE);if(0>e||e>s||0>r||r>s)throw new Error("gl-fbo: Can't resize FBO, invalid dimensions");t._shape[0]=e,t._shape[1]=r;for(var l=n(a),c=0;ce||e>o||0>r||r>o)throw new Error("gl-fbo: Parameters are too large for FBO");n=n||{};var s=1;if("color"in n){if(s=Math.max(0|n.color,0),0>s)throw new Error("gl-fbo: Must specify a nonnegative number of colors");if(s>1){if(!i)throw new Error("gl-fbo: Multiple draw buffer extension not supported");if(s>t.getParameter(i.MAX_COLOR_ATTACHMENTS_WEBGL))throw new Error("gl-fbo: Context does not support "+s+" draw buffers")}}var l=t.UNSIGNED_BYTE,c=t.getExtension("OES_texture_float");if(n.float&&s>0){if(!c)throw new Error("gl-fbo: Context does not support floating point textures");l=t.FLOAT}else n.preferFloat&&s>0&&c&&(l=t.FLOAT);var f=!0;"depth"in n&&(f=!!n.depth);var h=!1;return"stencil"in n&&(h=!!n.stencil),new u(t,e,r,l,s,f,h,i)}var d=t("gl-texture2d");e.exports=h;var p,g,v,m,y=null,b=u.prototype;Object.defineProperties(b,{shape:{get:function(){return this._destroyed?[0,0]:this._shapeVector},set:function(t){if(Array.isArray(t)||(t=[0|t,0|t]),2!==t.length)throw new Error("gl-fbo: Shape vector must be length 2");var e=0|t[0],r=0|t[1];return f(this,e,r),[e,r]},enumerable:!1},width:{get:function(){return this._destroyed?0:this._shape[0]},set:function(t){return t=0|t,f(this,t,this._shape[1]),t},enumerable:!1},height:{get:function(){return this._destroyed?0:this._shape[1]},set:function(t){return t=0|t,f(this,this._shape[0],t),t},enumerable:!1}}),b.bind=function(){if(!this._destroyed){var t=this.gl;t.bindFramebuffer(t.FRAMEBUFFER,this.handle),t.viewport(0,0,this._shape[0],this._shape[1])}},b.dispose=function(){if(!this._destroyed){this._destroyed=!0;var t=this.gl;t.deleteFramebuffer(this.handle),this.handle=null,this.depth&&(this.depth.dispose(),this.depth=null),this._depth_rb&&(t.deleteRenderbuffer(this._depth_rb),this._depth_rb=null);for(var e=0;e 0.25) {\n discard;\n }\n gl_FragColor = vec4(color.rgb, color.a);\n}\n",r.pickVertex="precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 a, d;\nattribute vec4 pick0, pick1;\n\nuniform mat3 matrix;\nuniform vec2 screenShape;\nuniform float width;\n\nvarying vec4 pickA, pickB;\n\nfloat inverse_1_0(float m) {\n return 1.0 / m;\n}\n\nmat2 inverse_1_0(mat2 m) {\n return mat2(m[1][1],-m[0][1],\n -m[1][0], m[0][0]) / (m[0][0]*m[1][1] - m[0][1]*m[1][0]);\n}\n\nmat3 inverse_1_0(mat3 m) {\n float a00 = m[0][0], a01 = m[0][1], a02 = m[0][2];\n float a10 = m[1][0], a11 = m[1][1], a12 = m[1][2];\n float a20 = m[2][0], a21 = m[2][1], a22 = m[2][2];\n\n float b01 = a22 * a11 - a12 * a21;\n float b11 = -a22 * a10 + a12 * a20;\n float b21 = a21 * a10 - a11 * a20;\n\n float det = a00 * b01 + a01 * b11 + a02 * b21;\n\n return mat3(b01, (-a22 * a01 + a02 * a21), (a12 * a01 - a02 * a11),\n b11, (a22 * a00 - a02 * a20), (-a12 * a00 + a02 * a10),\n b21, (-a21 * a00 + a01 * a20), (a11 * a00 - a01 * a10)) / det;\n}\n\nmat4 inverse_1_0(mat4 m) {\n float\n a00 = m[0][0], a01 = m[0][1], a02 = m[0][2], a03 = m[0][3],\n a10 = m[1][0], a11 = m[1][1], a12 = m[1][2], a13 = m[1][3],\n a20 = m[2][0], a21 = m[2][1], a22 = m[2][2], a23 = m[2][3],\n a30 = m[3][0], a31 = m[3][1], a32 = m[3][2], a33 = m[3][3],\n\n b00 = a00 * a11 - a01 * a10,\n b01 = a00 * a12 - a02 * a10,\n b02 = a00 * a13 - a03 * a10,\n b03 = a01 * a12 - a02 * a11,\n b04 = a01 * a13 - a03 * a11,\n b05 = a02 * a13 - a03 * a12,\n b06 = a20 * a31 - a21 * a30,\n b07 = a20 * a32 - a22 * a30,\n b08 = a20 * a33 - a23 * a30,\n b09 = a21 * a32 - a22 * a31,\n b10 = a21 * a33 - a23 * a31,\n b11 = a22 * a33 - a23 * a32,\n\n det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;\n\n return mat4(\n a11 * b11 - a12 * b10 + a13 * b09,\n a02 * b10 - a01 * b11 - a03 * b09,\n a31 * b05 - a32 * b04 + a33 * b03,\n a22 * b04 - a21 * b05 - a23 * b03,\n a12 * b08 - a10 * b11 - a13 * b07,\n a00 * b11 - a02 * b08 + a03 * b07,\n a32 * b02 - a30 * b05 - a33 * b01,\n a20 * b05 - a22 * b02 + a23 * b01,\n a10 * b10 - a11 * b08 + a13 * b06,\n a01 * b08 - a00 * b10 - a03 * b06,\n a30 * b04 - a31 * b02 + a33 * b00,\n a21 * b02 - a20 * b04 - a23 * b00,\n a11 * b07 - a10 * b09 - a12 * b06,\n a00 * b09 - a01 * b07 + a02 * b06,\n a31 * b01 - a30 * b03 - a32 * b00,\n a20 * b03 - a21 * b01 + a22 * b00) / det;\n}\n\n\n\nvoid main() {\n vec3 base = matrix * vec3(a, 1);\n vec2 n = width *\n normalize(screenShape.yx * vec2(d.y, -d.x)) / screenShape.xy;\n gl_Position = vec4(base.xy/base.z + n, 0, 1);\n pickA = pick0;\n pickB = pick1;\n}\n",r.pickFragment="precision mediump float;\n#define GLSLIFY 1\n\nuniform vec4 pickOffset;\n\nvarying vec4 pickA, pickB;\n\nvoid main() {\n vec4 fragId = vec4(pickA.xyz, 0.0);\n if(pickB.w > pickA.w) {\n fragId.xyz = pickB.xyz;\n }\n\n fragId += pickOffset;\n\n fragId.y += floor(fragId.x / 256.0);\n fragId.x -= floor(fragId.x / 256.0) * 256.0;\n\n fragId.z += floor(fragId.y / 256.0);\n fragId.y -= floor(fragId.y / 256.0) * 256.0;\n\n fragId.w += floor(fragId.z / 256.0);\n fragId.z -= floor(fragId.z / 256.0) * 256.0;\n\n gl_FragColor = fragId / 255.0;\n}\n",r.fillVertex="precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 a, d;\n\nuniform mat3 matrix;\nuniform vec2 projectAxis;\nuniform float projectValue;\nuniform float depth;\n\nvoid main() {\n vec3 base = matrix * vec3(a, 1);\n vec2 p = base.xy / base.z;\n if(d.y < 0.0 || (d.y == 0.0 && d.x < 0.0)) {\n if(dot(p, projectAxis) < projectValue) {\n p = p * (1.0 - abs(projectAxis)) + projectAxis * projectValue;\n }\n }\n gl_Position = vec4(p, depth, 1);\n}\n",r.fillFragment="precision mediump float;\n#define GLSLIFY 1\n\nuniform vec4 color;\n\nvoid main() {\n gl_FragColor = vec4(color.rgb * color.a, color.a);\n}\n"},{}],125:[function(t,e,r){"use strict";function n(t,e,r,n,i,a,o,s){this.plot=t,this.dashPattern=e,this.lineBuffer=r,this.pickBuffer=n,this.lineShader=i,this.mitreShader=a,this.fillShader=o,this.pickShader=s,this.usingDashes=!1,this.bounds=[1/0,1/0,-(1/0),-(1/0)],this.width=1,this.color=[0,0,1,1],this.fill=[!1,!1,!1,!1],this.fillColor=[[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1]],this.data=null,this.numPoints=0,this.vertCount=0,this.pickOffset=0,this.lodBuffer=[]}function i(t){return t.map(function(t){return t.slice()})}function a(t,e){var r=t.gl,i=s(r),a=s(r),c=l(r,[1,1]),u=o(r,f.lineVertex,f.lineFragment),h=o(r,f.mitreVertex,f.mitreFragment),d=o(r,f.fillVertex,f.fillFragment),p=o(r,f.pickVertex,f.pickFragment),g=new n(t,c,i,a,u,h,d,p);return t.addObject(g),g.update(e),g}e.exports=a;var o=t("gl-shader"),s=t("gl-buffer"),l=t("gl-texture2d"),c=t("ndarray"),u=t("typedarray-pool"),f=t("./lib/shaders"),h=n.prototype;h.draw=function(){var t=[1,0,0,0,1,0,0,0,1],e=[0,0],r=[1,0],n=[-1,0],i=[0,1],a=[0,-1];return function(){var o=this.plot,s=this.color,l=this.width,c=(this.numPoints,this.bounds),u=this.vertCount;if(u){var f=o.gl,h=o.viewBox,d=o.dataBox,p=o.pixelRatio,g=c[2]-c[0],v=c[3]-c[1],m=d[2]-d[0],y=d[3]-d[1],b=h[2]-h[0],x=h[3]-h[1];t[0]=2*g/m,t[4]=2*v/y,t[6]=2*(c[0]-d[0])/m-1,t[7]=2*(c[1]-d[1])/y-1,e[0]=b,e[1]=x;var _=this.lineBuffer;_.bind();var w=this.fill;if(w[0]||w[1]||w[2]||w[3]){var k=this.fillShader;k.bind();var A=k.uniforms;A.matrix=t,A.depth=o.nextDepthValue();var M=k.attributes;M.a.pointer(f.FLOAT,!1,16,0),M.d.pointer(f.FLOAT,!1,16,8),f.depthMask(!0),f.enable(f.DEPTH_TEST);var T=this.fillColor;w[0]&&(A.color=T[0],A.projectAxis=n,A.projectValue=1,f.drawArrays(f.TRIANGLES,0,u)),w[1]&&(A.color=T[1],A.projectAxis=a,A.projectValue=1,f.drawArrays(f.TRIANGLES,0,u)),w[2]&&(A.color=T[2],A.projectAxis=r,A.projectValue=1,f.drawArrays(f.TRIANGLES,0,u)),w[3]&&(A.color=T[3],A.projectAxis=i,A.projectValue=1,f.drawArrays(f.TRIANGLES,0,u)),f.depthMask(!1),f.disable(f.DEPTH_TEST)}var E=this.lineShader;E.bind();var L=E.uniforms;L.matrix=t,L.color=s,L.width=l*p,L.screenShape=e,L.dashPattern=this.dashPattern.bind(),L.dashLength=this.dashLength*p;var S=E.attributes;if(S.a.pointer(f.FLOAT,!1,16,0),S.d.pointer(f.FLOAT,!1,16,8),f.drawArrays(f.TRIANGLES,0,u),l>2&&!this.usingDashes){var C=this.mitreShader;C.bind();var z=C.uniforms;z.matrix=t,z.color=s,z.screenShape=e,z.radius=l*p,C.attributes.p.pointer(f.FLOAT,!1,48,0),f.drawArrays(f.POINTS,0,u/3|0)}}}}(),h.drawPick=function(){var t=[1,0,0,0,1,0,0,0,1],e=[0,0],r=[0,0,0,0];return function(n){var i=this.plot,a=this.pickShader,o=this.lineBuffer,s=this.pickBuffer,l=this.width,c=this.numPoints,u=this.bounds,f=this.vertCount,h=i.gl,d=i.viewBox,p=i.dataBox,g=i.pickPixelRatio,v=u[2]-u[0],m=u[3]-u[1],y=p[2]-p[0],b=p[3]-p[1],x=d[2]-d[0],_=d[3]-d[1];if(this.pickOffset=n,!f)return n+c;t[0]=2*v/y,t[4]=2*m/b,t[6]=2*(u[0]-p[0])/y-1,t[7]=2*(u[1]-p[1])/b-1,e[0]=x,e[1]=_,r[0]=255&n,r[1]=n>>>8&255,r[2]=n>>>16&255,r[3]=n>>>24,a.bind();var w=a.uniforms;w.matrix=t,w.width=l*g,w.pickOffset=r,w.screenShape=e;var k=a.attributes;return o.bind(),k.a.pointer(h.FLOAT,!1,16,0),k.d.pointer(h.FLOAT,!1,16,8),s.bind(),k.pick0.pointer(h.UNSIGNED_BYTE,!1,8,0),k.pick1.pointer(h.UNSIGNED_BYTE,!1,8,4),h.drawArrays(h.TRIANGLES,0,f),n+c}}(),h.pick=function(t,e,r){var n=this.pickOffset,i=this.numPoints;if(n>r||r>=n+i)return null;var a=r-n,o=this.data;return{object:this,pointId:a,dataCoord:[o[2*a],o[2*a+1]]}},h.update=function(t){t=t||{};var e=this.plot.gl;!!t.connectGaps;this.color=(t.color||[0,0,1,1]).slice(),this.width=+(t.width||1),this.fill=(t.fill||[!1,!1,!1,!1]).slice(),this.fillColor=i(t.fillColor||[[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1]]);for(var r=t.dashes||[1],n=0,a=0;a1,this.dashPattern=l(e,c(o,[n,1,4],[1,0,0])),this.dashPattern.minFilter=e.NEAREST,this.dashPattern.magFilter=e.NEAREST,this.dashLength=n,u.free(o);var d=t.positions;this.data=d;var p=this.bounds;p[0]=p[1]=1/0,p[2]=p[3]=-(1/0);var g=this.numPoints=d.length>>>1;if(0!==g){for(var a=0;g>a;++a){var v=d[2*a],m=d[2*a+1];isNaN(v)||isNaN(m)||(p[0]=Math.min(p[0],v),p[1]=Math.min(p[1],m),p[2]=Math.max(p[2],v),p[3]=Math.max(p[3],m))}p[0]===p[2]&&(p[2]+=1),p[3]===p[1]&&(p[3]+=1);for(var y=u.mallocFloat32(24*(g-1)),b=u.mallocUint32(12*(g-1)),x=y.length,_=b.length,s=g,w=0;s>1;){var k=--s,v=d[2*s],m=d[2*s+1],A=k-1,M=d[2*A],T=d[2*A+1];if(!(isNaN(v)||isNaN(m)||isNaN(M)||isNaN(T))){w+=1,v=(v-p[0])/(p[2]-p[0]),m=(m-p[1])/(p[3]-p[1]),M=(M-p[0])/(p[2]-p[0]),T=(T-p[1])/(p[3]-p[1]);var E=M-v,L=T-m,S=k|1<<24,C=k-1,z=k,P=k-1|1<<24;y[--x]=-L,y[--x]=-E,y[--x]=m,y[--x]=v,b[--_]=S,b[--_]=C,y[--x]=L,y[--x]=E,y[--x]=T,y[--x]=M,b[--_]=z,b[--_]=P,y[--x]=-L,y[--x]=-E,y[--x]=T,y[--x]=M,b[--_]=z,b[--_]=P,y[--x]=L,y[--x]=E,y[--x]=T,y[--x]=M,b[--_]=z,b[--_]=P,y[--x]=-L,y[--x]=-E,y[--x]=m,y[--x]=v,b[--_]=S,b[--_]=C,y[--x]=L,y[--x]=E,y[--x]=m,y[--x]=v,b[--_]=S,b[--_]=C}}this.vertCount=6*w,this.lineBuffer.update(y.subarray(x)),this.pickBuffer.update(b.subarray(_)),u.free(y),u.free(b)}},h.dispose=function(){this.plot.removeObject(this),this.lineBuffer.dispose(),this.pickBuffer.dispose(),this.lineShader.dispose(),this.mitreShader.dispose(),this.fillShader.dispose(),this.pickShader.dispose(),this.dashPattern.dispose()}},{"./lib/shaders":124,"gl-buffer":118,"gl-shader":197,"gl-texture2d":222,ndarray:253,"typedarray-pool":278}],126:[function(t,e,r){var n=t("gl-shader"),i="precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position, nextPosition;\nattribute float arcLength, lineWidth;\nattribute vec4 color;\n\nuniform vec2 screenShape;\nuniform float pixelRatio;\nuniform mat4 model, view, projection;\n\nvarying vec4 fragColor;\nvarying vec3 worldPosition;\nvarying float pixelArcLength;\n\nvoid main() {\n vec4 projected = projection * view * model * vec4(position, 1.0);\n vec4 tangentClip = projection * view * model * vec4(nextPosition - position, 0.0);\n vec2 tangent = normalize(screenShape * tangentClip.xy);\n vec2 offset = 0.5 * pixelRatio * lineWidth * vec2(tangent.y, -tangent.x) / screenShape;\n\n gl_Position = vec4(projected.xy + projected.w * offset, projected.zw);\n\n worldPosition = position;\n pixelArcLength = arcLength;\n fragColor = color;\n}\n",a="precision mediump float;\n#define GLSLIFY 1\n\nuniform vec3 clipBounds[2];\nuniform sampler2D dashTexture;\nuniform float dashScale;\nuniform float opacity;\n\nvarying vec3 worldPosition;\nvarying float pixelArcLength;\nvarying vec4 fragColor;\n\nvoid main() {\n if(any(lessThan(worldPosition, clipBounds[0])) || any(greaterThan(worldPosition, clipBounds[1]))) {\n discard;\n }\n float dashWeight = texture2D(dashTexture, vec2(dashScale * pixelArcLength, 0)).r;\n if(dashWeight < 0.5) {\n discard;\n }\n gl_FragColor = fragColor * opacity;\n}\n",o="precision mediump float;\n#define GLSLIFY 1\n\n#define FLOAT_MAX 1.70141184e38\n#define FLOAT_MIN 1.17549435e-38\n\nlowp vec4 encode_float_1_0(highp float v) {\n highp float av = abs(v);\n\n //Handle special cases\n if(av < FLOAT_MIN) {\n return vec4(0.0, 0.0, 0.0, 0.0);\n } else if(v > FLOAT_MAX) {\n return vec4(127.0, 128.0, 0.0, 0.0) / 255.0;\n } else if(v < -FLOAT_MAX) {\n return vec4(255.0, 128.0, 0.0, 0.0) / 255.0;\n }\n\n highp vec4 c = vec4(0,0,0,0);\n\n //Compute exponent and mantissa\n highp float e = floor(log2(av));\n highp float m = av * pow(2.0, -e) - 1.0;\n \n //Unpack mantissa\n c[1] = floor(128.0 * m);\n m -= c[1] / 128.0;\n c[2] = floor(32768.0 * m);\n m -= c[2] / 32768.0;\n c[3] = floor(8388608.0 * m);\n \n //Unpack exponent\n highp float ebias = e + 127.0;\n c[0] = floor(ebias / 2.0);\n ebias -= c[0] * 2.0;\n c[1] += floor(ebias) * 128.0; \n\n //Unpack sign bit\n c[0] += 128.0 * step(0.0, -v);\n\n //Scale back to range\n return c / 255.0;\n}\n\n\n\nuniform float pickId;\nuniform vec3 clipBounds[2];\n\nvarying vec3 worldPosition;\nvarying float pixelArcLength;\nvarying vec4 fragColor;\n\nvoid main() {\n if(any(lessThan(worldPosition, clipBounds[0])) || any(greaterThan(worldPosition, clipBounds[1]))) {\n discard;\n }\n gl_FragColor = vec4(pickId/255.0, encode_float_1_0(pixelArcLength).xyz);\n}",s=[{name:"position",type:"vec3"},{name:"nextPosition",type:"vec3"},{name:"arcLength",type:"float"},{name:"lineWidth",type:"float"},{name:"color",type:"vec4"}];r.createShader=function(t){return n(t,i,a,null,s)},r.createPickShader=function(t){return n(t,i,o,null,s)}},{"gl-shader":197}],127:[function(t,e,r){"use strict";function n(t,e){for(var r=0,n=0;3>n;++n){var i=t[n]-e[n];r+=i*i}return Math.sqrt(r)}function i(t){for(var e=[[-1e6,-1e6,-1e6],[1e6,1e6,1e6]],r=0;3>r;++r)e[0][r]=Math.max(t[0][r],e[0][r]),e[1][r]=Math.min(t[1][r],e[1][r]);return e}function a(t,e,r,n){this.arcLength=t,this.position=e,this.index=r,this.dataCoordinate=n}function o(t,e,r,n,i,a){this.gl=t,this.shader=e,this.pickShader=r,this.buffer=n,this.vao=i,this.clipBounds=[[-(1/0),-(1/0),-(1/0)],[1/0,1/0,1/0]],this.points=[],this.arcLength=[],this.vertexCount=0,this.bounds=[[0,0,0],[0,0,0]],this.pickId=0,this.lineWidth=1,this.texture=a,this.dashScale=1,this.opacity=1,this.dirty=!0,this.pixelRatio=1}function s(t){var e=t.gl||t.scene&&t.scene.gl,r=g(e);r.attributes.position.location=0,r.attributes.nextPosition.location=1,r.attributes.arcLength.location=2,r.attributes.lineWidth.location=3,r.attributes.color.location=4;var n=v(e);n.attributes.position.location=0,n.attributes.nextPosition.location=1,n.attributes.arcLength.location=2,n.attributes.lineWidth.location=3,n.attributes.color.location=4;for(var i=l(e),a=c(e,[{buffer:i,size:3,offset:0,stride:48},{buffer:i,size:3,offset:12,stride:48},{buffer:i,size:1,offset:24,stride:48},{buffer:i,size:1,offset:28,stride:48},{buffer:i,size:4,offset:32,stride:48}]),s=d(new Array(1024),[256,1,4]),f=0;1024>f;++f)s.data[f]=255;var h=u(e,s);h.wrap=e.REPEAT;var p=new o(e,r,n,i,a,h);return p.update(t),p}e.exports=s;var l=t("gl-buffer"),c=t("gl-vao"),u=t("gl-texture2d"),f=t("glsl-read-float"),h=t("binary-search-bounds"),d=t("ndarray"),p=t("./lib/shaders"),g=p.createShader,v=p.createPickShader,m=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],y=o.prototype;y.isTransparent=function(){return this.opacity<1},y.isOpaque=function(){return this.opacity>=1},y.pickSlots=1,y.setPickBase=function(t){this.pickId=t},y.drawTransparent=y.draw=function(t){var e=this.gl,r=this.shader,n=this.vao;r.bind(),r.uniforms={model:t.model||m,view:t.view||m,projection:t.projection||m,clipBounds:i(this.clipBounds),dashTexture:this.texture.bind(),dashScale:this.dashScale/this.arcLength[this.arcLength.length-1],opacity:this.opacity,screenShape:[e.drawingBufferWidth,e.drawingBufferHeight],pixelRatio:this.pixelRatio},n.bind(),n.draw(e.TRIANGLE_STRIP,this.vertexCount)},y.drawPick=function(t){var e=this.gl,r=this.pickShader,n=this.vao;r.bind(),r.uniforms={model:t.model||m,view:t.view||m,projection:t.projection||m,pickId:this.pickId,clipBounds:i(this.clipBounds),screenShape:[e.drawingBufferWidth,e.drawingBufferHeight],pixelRatio:this.pixelRatio},n.bind(),n.draw(e.TRIANGLE_STRIP,this.vertexCount)},y.update=function(t){var e,r;this.dirty=!0;var i=!!t.connectGaps;"dashScale"in t&&(this.dashScale=t.dashScale),"opacity"in t&&(this.opacity=+t.opacity);var a=t.position||t.positions;if(a){var o=t.color||t.colors||[0,0,0,1],s=t.lineWidth||1,l=[],c=[],u=[],f=0,p=0,g=[[1/0,1/0,1/0],[-(1/0),-(1/0),-(1/0)]],v=!1;t:for(e=1;er;++r){if(isNaN(m[r])||isNaN(y[r])||!isFinite(m[r])||!isFinite(y[r])){if(!i&&l.length>0){for(var b=0;24>b;++b)l.push(l[l.length-12]);p+=2,v=!0}continue t}g[0][r]=Math.min(g[0][r],m[r],y[r]),g[1][r]=Math.max(g[1][r],m[r],y[r])}
+var x,_;Array.isArray(o[0])?(x=o[e-1],_=o[e]):x=_=o,3===x.length&&(x=[x[0],x[1],x[2],1]),3===_.length&&(_=[_[0],_[1],_[2],1]);var w;w=Array.isArray(s)?s[e-1]:s;var k=f;if(f+=n(m,y),v){for(r=0;2>r;++r)l.push(m[0],m[1],m[2],y[0],y[1],y[2],k,w,x[0],x[1],x[2],x[3]);p+=2,v=!1}l.push(m[0],m[1],m[2],y[0],y[1],y[2],k,w,x[0],x[1],x[2],x[3],m[0],m[1],m[2],y[0],y[1],y[2],k,-w,x[0],x[1],x[2],x[3],y[0],y[1],y[2],m[0],m[1],m[2],f,-w,_[0],_[1],_[2],_[3],y[0],y[1],y[2],m[0],m[1],m[2],f,w,_[0],_[1],_[2],_[3]),p+=4}if(this.buffer.update(l),c.push(f),u.push(a[a.length-1].slice()),this.bounds=g,this.vertexCount=p,this.points=u,this.arcLength=c,"dashes"in t){var A=t.dashes,M=A.slice();for(M.unshift(0),e=1;ee;++e){for(r=0;4>r;++r)T.set(e,0,r,0);1&h.le(M,M[M.length-1]*e/255)?T.set(e,0,0,0):T.set(e,0,0,255)}this.texture.setPixels(T)}}},y.dispose=function(){this.shader.dispose(),this.vao.dispose(),this.buffer.dispose()},y.pick=function(t){if(!t)return null;if(t.id!==this.pickId)return null;var e=f(t.value[0],t.value[1],t.value[2],0),r=h.le(this.arcLength,e);if(0>r)return null;if(r===this.arcLength.length-1)return new a(this.arcLength[this.arcLength.length-1],this.points[this.points.length-1].slice(),r);for(var n=this.points[r],i=this.points[Math.min(r+1,this.points.length-1)],o=(e-this.arcLength[r])/(this.arcLength[r+1]-this.arcLength[r]),s=1-o,l=[0,0,0],c=0;3>c;++c)l[c]=s*n[c]+o*i[c];var u=Math.min(.5>o?r:r+1,this.points.length-1);return new a(e,l,u,this.points[u])}},{"./lib/shaders":126,"binary-search-bounds":128,"gl-buffer":118,"gl-texture2d":222,"gl-vao":226,"glsl-read-float":129,ndarray:253}],128:[function(t,e,r){arguments[4][21][0].apply(r,arguments)},{dup:21}],129:[function(t,e,r){function n(t,e,r,n){return i[0]=n,i[1]=r,i[2]=e,i[3]=t,a[0]}e.exports=n;var i=new Uint8Array(4),a=new Float32Array(i.buffer)},{}],130:[function(t,e,r){function n(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],o=e[4],s=e[5],l=e[6],c=e[7],u=e[8],f=u*o-s*c,h=-u*a+s*l,d=c*a-o*l,p=r*f+n*h+i*d;return p?(p=1/p,t[0]=f*p,t[1]=(-u*n+i*c)*p,t[2]=(s*n-i*o)*p,t[3]=h*p,t[4]=(u*r-i*l)*p,t[5]=(-s*r+i*a)*p,t[6]=d*p,t[7]=(-c*r+n*l)*p,t[8]=(o*r-n*a)*p,t):null}e.exports=n},{}],131:[function(t,e,r){function n(t){var e=new Float32Array(16);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}e.exports=n},{}],132:[function(t,e,r){function n(){var t=new Float32Array(16);return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}e.exports=n},{}],133:[function(t,e,r){function n(t){var e=t[0],r=t[1],n=t[2],i=t[3],a=t[4],o=t[5],s=t[6],l=t[7],c=t[8],u=t[9],f=t[10],h=t[11],d=t[12],p=t[13],g=t[14],v=t[15],m=e*o-r*a,y=e*s-n*a,b=e*l-i*a,x=r*s-n*o,_=r*l-i*o,w=n*l-i*s,k=c*p-u*d,A=c*g-f*d,M=c*v-h*d,T=u*g-f*p,E=u*v-h*p,L=f*v-h*g;return m*L-y*E+b*T+x*M-_*A+w*k}e.exports=n},{}],134:[function(t,e,r){function n(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],o=r+r,s=n+n,l=i+i,c=r*o,u=n*o,f=n*s,h=i*o,d=i*s,p=i*l,g=a*o,v=a*s,m=a*l;return t[0]=1-f-p,t[1]=u+m,t[2]=h-v,t[3]=0,t[4]=u-m,t[5]=1-c-p,t[6]=d+g,t[7]=0,t[8]=h+v,t[9]=d-g,t[10]=1-c-f,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}e.exports=n},{}],135:[function(t,e,r){function n(t,e,r){var n=e[0],i=e[1],a=e[2],o=e[3],s=n+n,l=i+i,c=a+a,u=n*s,f=n*l,h=n*c,d=i*l,p=i*c,g=a*c,v=o*s,m=o*l,y=o*c;return t[0]=1-(d+g),t[1]=f+y,t[2]=h-m,t[3]=0,t[4]=f-y,t[5]=1-(u+g),t[6]=p+v,t[7]=0,t[8]=h+m,t[9]=p-v,t[10]=1-(u+d),t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t}e.exports=n},{}],136:[function(t,e,r){function n(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}e.exports=n},{}],137:[function(t,e,r){function n(t,e){var r=e[0],n=e[1],i=e[2],a=e[3],o=e[4],s=e[5],l=e[6],c=e[7],u=e[8],f=e[9],h=e[10],d=e[11],p=e[12],g=e[13],v=e[14],m=e[15],y=r*s-n*o,b=r*l-i*o,x=r*c-a*o,_=n*l-i*s,w=n*c-a*s,k=i*c-a*l,A=u*g-f*p,M=u*v-h*p,T=u*m-d*p,E=f*v-h*g,L=f*m-d*g,S=h*m-d*v,C=y*S-b*L+x*E+_*T-w*M+k*A;return C?(C=1/C,t[0]=(s*S-l*L+c*E)*C,t[1]=(i*L-n*S-a*E)*C,t[2]=(g*k-v*w+m*_)*C,t[3]=(h*w-f*k-d*_)*C,t[4]=(l*T-o*S-c*M)*C,t[5]=(r*S-i*T+a*M)*C,t[6]=(v*x-p*k-m*b)*C,t[7]=(u*k-h*x+d*b)*C,t[8]=(o*L-s*T+c*A)*C,t[9]=(n*T-r*L-a*A)*C,t[10]=(p*w-g*x+m*y)*C,t[11]=(f*x-u*w-d*y)*C,t[12]=(s*M-o*E-l*A)*C,t[13]=(r*E-n*M+i*A)*C,t[14]=(g*b-p*_-v*y)*C,t[15]=(u*_-f*b+h*y)*C,t):null}e.exports=n},{}],138:[function(t,e,r){function n(t,e,r,n){var a,o,s,l,c,u,f,h,d,p,g=e[0],v=e[1],m=e[2],y=n[0],b=n[1],x=n[2],_=r[0],w=r[1],k=r[2];return Math.abs(g-_)<1e-6&&Math.abs(v-w)<1e-6&&Math.abs(m-k)<1e-6?i(t):(f=g-_,h=v-w,d=m-k,p=1/Math.sqrt(f*f+h*h+d*d),f*=p,h*=p,d*=p,a=b*d-x*h,o=x*f-y*d,s=y*h-b*f,p=Math.sqrt(a*a+o*o+s*s),p?(p=1/p,a*=p,o*=p,s*=p):(a=0,o=0,s=0),l=h*s-d*o,c=d*a-f*s,u=f*o-h*a,p=Math.sqrt(l*l+c*c+u*u),p?(p=1/p,l*=p,c*=p,u*=p):(l=0,c=0,u=0),t[0]=a,t[1]=l,t[2]=f,t[3]=0,t[4]=o,t[5]=c,t[6]=h,t[7]=0,t[8]=s,t[9]=u,t[10]=d,t[11]=0,t[12]=-(a*g+o*v+s*m),t[13]=-(l*g+c*v+u*m),t[14]=-(f*g+h*v+d*m),t[15]=1,t)}var i=t("./identity");e.exports=n},{"./identity":136}],139:[function(t,e,r){function n(t,e,r){var n=e[0],i=e[1],a=e[2],o=e[3],s=e[4],l=e[5],c=e[6],u=e[7],f=e[8],h=e[9],d=e[10],p=e[11],g=e[12],v=e[13],m=e[14],y=e[15],b=r[0],x=r[1],_=r[2],w=r[3];return t[0]=b*n+x*s+_*f+w*g,t[1]=b*i+x*l+_*h+w*v,t[2]=b*a+x*c+_*d+w*m,t[3]=b*o+x*u+_*p+w*y,b=r[4],x=r[5],_=r[6],w=r[7],t[4]=b*n+x*s+_*f+w*g,t[5]=b*i+x*l+_*h+w*v,t[6]=b*a+x*c+_*d+w*m,t[7]=b*o+x*u+_*p+w*y,b=r[8],x=r[9],_=r[10],w=r[11],t[8]=b*n+x*s+_*f+w*g,t[9]=b*i+x*l+_*h+w*v,t[10]=b*a+x*c+_*d+w*m,t[11]=b*o+x*u+_*p+w*y,b=r[12],x=r[13],_=r[14],w=r[15],t[12]=b*n+x*s+_*f+w*g,t[13]=b*i+x*l+_*h+w*v,t[14]=b*a+x*c+_*d+w*m,t[15]=b*o+x*u+_*p+w*y,t}e.exports=n},{}],140:[function(t,e,r){function n(t,e,r,n,i){var a=1/Math.tan(e/2),o=1/(n-i);return t[0]=a/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=(i+n)*o,t[11]=-1,t[12]=0,t[13]=0,t[14]=2*i*n*o,t[15]=0,t}e.exports=n},{}],141:[function(t,e,r){function n(t,e,r,n){var i,a,o,s,l,c,u,f,h,d,p,g,v,m,y,b,x,_,w,k,A,M,T,E,L=n[0],S=n[1],C=n[2],z=Math.sqrt(L*L+S*S+C*C);return Math.abs(z)<1e-6?null:(z=1/z,L*=z,S*=z,C*=z,i=Math.sin(r),a=Math.cos(r),o=1-a,s=e[0],l=e[1],c=e[2],u=e[3],f=e[4],h=e[5],d=e[6],p=e[7],g=e[8],v=e[9],m=e[10],y=e[11],b=L*L*o+a,x=S*L*o+C*i,_=C*L*o-S*i,w=L*S*o-C*i,k=S*S*o+a,A=C*S*o+L*i,M=L*C*o+S*i,T=S*C*o-L*i,E=C*C*o+a,t[0]=s*b+f*x+g*_,t[1]=l*b+h*x+v*_,t[2]=c*b+d*x+m*_,t[3]=u*b+p*x+y*_,t[4]=s*w+f*k+g*A,t[5]=l*w+h*k+v*A,t[6]=c*w+d*k+m*A,t[7]=u*w+p*k+y*A,t[8]=s*M+f*T+g*E,t[9]=l*M+h*T+v*E,t[10]=c*M+d*T+m*E,t[11]=u*M+p*T+y*E,e!==t&&(t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t)}e.exports=n},{}],142:[function(t,e,r){function n(t,e,r){var n=Math.sin(r),i=Math.cos(r),a=e[4],o=e[5],s=e[6],l=e[7],c=e[8],u=e[9],f=e[10],h=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=a*i+c*n,t[5]=o*i+u*n,t[6]=s*i+f*n,t[7]=l*i+h*n,t[8]=c*i-a*n,t[9]=u*i-o*n,t[10]=f*i-s*n,t[11]=h*i-l*n,t}e.exports=n},{}],143:[function(t,e,r){function n(t,e,r){var n=Math.sin(r),i=Math.cos(r),a=e[0],o=e[1],s=e[2],l=e[3],c=e[8],u=e[9],f=e[10],h=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=a*i-c*n,t[1]=o*i-u*n,t[2]=s*i-f*n,t[3]=l*i-h*n,t[8]=a*n+c*i,t[9]=o*n+u*i,t[10]=s*n+f*i,t[11]=l*n+h*i,t}e.exports=n},{}],144:[function(t,e,r){function n(t,e,r){var n=Math.sin(r),i=Math.cos(r),a=e[0],o=e[1],s=e[2],l=e[3],c=e[4],u=e[5],f=e[6],h=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=a*i+c*n,t[1]=o*i+u*n,t[2]=s*i+f*n,t[3]=l*i+h*n,t[4]=c*i-a*n,t[5]=u*i-o*n,t[6]=f*i-s*n,t[7]=h*i-l*n,t}e.exports=n},{}],145:[function(t,e,r){function n(t,e,r){var n=r[0],i=r[1],a=r[2];return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t[4]=e[4]*i,t[5]=e[5]*i,t[6]=e[6]*i,t[7]=e[7]*i,t[8]=e[8]*a,t[9]=e[9]*a,t[10]=e[10]*a,t[11]=e[11]*a,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}e.exports=n},{}],146:[function(t,e,r){function n(t,e,r){var n,i,a,o,s,l,c,u,f,h,d,p,g=r[0],v=r[1],m=r[2];return e===t?(t[12]=e[0]*g+e[4]*v+e[8]*m+e[12],t[13]=e[1]*g+e[5]*v+e[9]*m+e[13],t[14]=e[2]*g+e[6]*v+e[10]*m+e[14],t[15]=e[3]*g+e[7]*v+e[11]*m+e[15]):(n=e[0],i=e[1],a=e[2],o=e[3],s=e[4],l=e[5],c=e[6],u=e[7],f=e[8],h=e[9],d=e[10],p=e[11],t[0]=n,t[1]=i,t[2]=a,t[3]=o,t[4]=s,t[5]=l,t[6]=c,t[7]=u,t[8]=f,t[9]=h,t[10]=d,t[11]=p,t[12]=n*g+s*v+f*m+e[12],t[13]=i*g+l*v+h*m+e[13],t[14]=a*g+c*v+d*m+e[14],t[15]=o*g+u*v+p*m+e[15]),t}e.exports=n},{}],147:[function(t,e,r){function n(t,e){if(t===e){var r=e[1],n=e[2],i=e[3],a=e[6],o=e[7],s=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=r,t[6]=e[9],t[7]=e[13],t[8]=n,t[9]=a,t[11]=e[14],t[12]=i,t[13]=o,t[14]=s}else t[0]=e[0],t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=e[1],t[5]=e[5],t[6]=e[9],t[7]=e[13],t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=e[14],t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15];return t}e.exports=n},{}],148:[function(t,e,r){"use strict";function n(t,e){for(var r=[0,0,0,0],n=0;4>n;++n)for(var i=0;4>i;++i)r[i]+=t[4*n+i]*e[n];return r}function i(t,e,r,i,a){for(var o=n(i,n(r,n(e,[t[0],t[1],t[2],1]))),s=0;3>s;++s)o[s]/=o[3];return[.5*a[0]*(1+o[0]),.5*a[1]*(1-o[1])]}function a(t,e){if(2===t.length){for(var r=0,n=0,i=0;2>i;++i)r+=Math.pow(e[i]-t[0][i],2),n+=Math.pow(e[i]-t[1][i],2);return r=Math.sqrt(r),n=Math.sqrt(n),1e-6>r+n?[1,0]:[n/(r+n),r/(n+r)]}if(3===t.length){var a=[0,0];return c(t[0],t[1],t[2],e,a),l(t,a)}return[]}function o(t,e){for(var r=[0,0,0],n=0;no;++o)r[o]+=a*i[o];return r}function s(t,e,r,n,s,l){if(1===t.length)return[0,t[0].slice()];for(var c=new Array(t.length),u=0;up;++p)d+=Math.pow(c[u][p]-e[p],2);h>d&&(h=d,f=u)}for(var g=a(c,e),v=0,u=0;3>u;++u){if(g[u]<-.001||g[u]>1.0001)return null;v+=g[u]}return Math.abs(v-1)>.001?null:[f,o(t,g),g]}var l=t("barycentric"),c=t("polytope-closest-point/lib/closest_point_2d.js");e.exports=s},{barycentric:151,"polytope-closest-point/lib/closest_point_2d.js":153}],149:[function(t,e,r){var n="precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position, normal;\nattribute vec4 color;\nattribute vec2 uv;\n\nuniform mat4 model\n , view\n , projection;\nuniform vec3 eyePosition\n , lightPosition;\n\nvarying vec3 f_normal\n , f_lightDirection\n , f_eyeDirection\n , f_data;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n vec4 m_position = model * vec4(position, 1.0);\n vec4 t_position = view * m_position;\n gl_Position = projection * t_position;\n f_color = color;\n f_normal = normal;\n f_data = position;\n f_eyeDirection = eyePosition - position;\n f_lightDirection = lightPosition - position;\n f_uv = uv;\n}",i="precision mediump float;\n#define GLSLIFY 1\n\nfloat beckmannDistribution_2_0(float x, float roughness) {\n float NdotH = max(x, 0.0001);\n float cos2Alpha = NdotH * NdotH;\n float tan2Alpha = (cos2Alpha - 1.0) / cos2Alpha;\n float roughness2 = roughness * roughness;\n float denom = 3.141592653589793 * roughness2 * cos2Alpha * cos2Alpha;\n return exp(tan2Alpha / roughness2) / denom;\n}\n\n\n\nfloat cookTorranceSpecular_1_1(\n vec3 lightDirection,\n vec3 viewDirection,\n vec3 surfaceNormal,\n float roughness,\n float fresnel) {\n\n float VdotN = max(dot(viewDirection, surfaceNormal), 0.0);\n float LdotN = max(dot(lightDirection, surfaceNormal), 0.0);\n\n //Half angle vector\n vec3 H = normalize(lightDirection + viewDirection);\n\n //Geometric term\n float NdotH = max(dot(surfaceNormal, H), 0.0);\n float VdotH = max(dot(viewDirection, H), 0.000001);\n float LdotH = max(dot(lightDirection, H), 0.000001);\n float G1 = (2.0 * NdotH * VdotN) / VdotH;\n float G2 = (2.0 * NdotH * LdotN) / LdotH;\n float G = min(1.0, min(G1, G2));\n \n //Distribution term\n float D = beckmannDistribution_2_0(NdotH, roughness);\n\n //Fresnel term\n float F = pow(1.0 - VdotN, fresnel);\n\n //Multiply terms and done\n return G * F * D / max(3.14159265 * VdotN, 0.000001);\n}\n\n\n\nuniform vec3 clipBounds[2];\nuniform float roughness\n , fresnel\n , kambient\n , kdiffuse\n , kspecular\n , opacity;\nuniform sampler2D texture;\n\nvarying vec3 f_normal\n , f_lightDirection\n , f_eyeDirection\n , f_data;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n if(any(lessThan(f_data, clipBounds[0])) || \n any(greaterThan(f_data, clipBounds[1]))) {\n discard;\n }\n\n vec3 N = normalize(f_normal);\n vec3 L = normalize(f_lightDirection);\n vec3 V = normalize(f_eyeDirection);\n \n if(!gl_FrontFacing) {\n N = -N;\n }\n\n float specular = cookTorranceSpecular_1_1(L, V, N, roughness, fresnel);\n float diffuse = min(kambient + kdiffuse * max(dot(N, L), 0.0), 1.0);\n\n vec4 surfaceColor = f_color * texture2D(texture, f_uv);\n vec4 litColor = surfaceColor.a * vec4(diffuse * surfaceColor.rgb + kspecular * vec3(1,1,1) * specular, 1.0);\n\n gl_FragColor = litColor * opacity;\n}",a="precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 uv;\n\nuniform mat4 model, view, projection;\n\nvarying vec4 f_color;\nvarying vec3 f_data;\nvarying vec2 f_uv;\n\nvoid main() {\n gl_Position = projection * view * model * vec4(position, 1.0);\n f_color = color;\n f_data = position;\n f_uv = uv;\n}",o="precision mediump float;\n#define GLSLIFY 1\n\nuniform vec3 clipBounds[2];\nuniform sampler2D texture;\nuniform float opacity;\n\nvarying vec4 f_color;\nvarying vec3 f_data;\nvarying vec2 f_uv;\n\nvoid main() {\n if(any(lessThan(f_data, clipBounds[0])) || \n any(greaterThan(f_data, clipBounds[1]))) {\n discard;\n }\n\n gl_FragColor = f_color * texture2D(texture, f_uv) * opacity;\n}",s="precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 uv;\nattribute float pointSize;\n\nuniform mat4 model, view, projection;\nuniform vec3 clipBounds[2];\n\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n if(any(lessThan(position, clipBounds[0])) || \n any(greaterThan(position, clipBounds[1]))) {\n gl_Position = vec4(0,0,0,0);\n } else {\n gl_Position = projection * view * model * vec4(position, 1.0);\n }\n gl_PointSize = pointSize;\n f_color = color;\n f_uv = uv;\n}",l="precision mediump float;\n#define GLSLIFY 1\n\nuniform sampler2D texture;\nuniform float opacity;\n\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n vec2 pointR = gl_PointCoord.xy - vec2(0.5,0.5);\n if(dot(pointR, pointR) > 0.25) {\n discard;\n }\n gl_FragColor = f_color * texture2D(texture, f_uv) * opacity;\n}",c="precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position;\nattribute vec4 id;\n\nuniform mat4 model, view, projection;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n gl_Position = projection * view * model * vec4(position, 1.0);\n f_id = id;\n f_position = position;\n}",u="precision mediump float;\n#define GLSLIFY 1\n\nuniform vec3 clipBounds[2];\nuniform float pickId;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n if(any(lessThan(f_position, clipBounds[0])) || \n any(greaterThan(f_position, clipBounds[1]))) {\n discard;\n }\n gl_FragColor = vec4(pickId, f_id.xyz);\n}",f="precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position;\nattribute float pointSize;\nattribute vec4 id;\n\nuniform mat4 model, view, projection;\nuniform vec3 clipBounds[2];\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n if(any(lessThan(position, clipBounds[0])) || \n any(greaterThan(position, clipBounds[1]))) {\n gl_Position = vec4(0,0,0,0);\n } else {\n gl_Position = projection * view * model * vec4(position, 1.0);\n gl_PointSize = pointSize;\n }\n f_id = id;\n f_position = position;\n}",h="precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 position;\n\nuniform mat4 model, view, projection;\n\nvoid main() {\n gl_Position = projection * view * model * vec4(position, 1.0);\n}",d="precision mediump float;\n#define GLSLIFY 1\n\nuniform vec3 contourColor;\n\nvoid main() {\n gl_FragColor = vec4(contourColor,1);\n}\n";r.meshShader={vertex:n,fragment:i,attributes:[{name:"position",type:"vec3"},{name:"normal",type:"vec3"},{name:"color",type:"vec4"},{name:"uv",type:"vec2"}]},r.wireShader={vertex:a,fragment:o,attributes:[{name:"position",type:"vec3"},{name:"color",type:"vec4"},{name:"uv",type:"vec2"}]},r.pointShader={vertex:s,fragment:l,attributes:[{name:"position",type:"vec3"},{name:"color",type:"vec4"},{name:"uv",type:"vec2"},{name:"pointSize",type:"float"}]},r.pickShader={vertex:c,fragment:u,attributes:[{name:"position",type:"vec3"},{name:"id",type:"vec4"}]},r.pointPickShader={vertex:f,fragment:u,attributes:[{name:"position",type:"vec3"},{name:"pointSize",type:"float"},{name:"id",type:"vec4"}]},r.contourShader={vertex:h,fragment:d,attributes:[{name:"position",type:"vec3"}]}},{}],150:[function(t,e,r){"use strict";function n(t,e,r,n,i,a,o,s,l,c,u,f,h,d,p,g,v,m,y,b,x,_,w,k,A,M,T){this.gl=t,this.cells=[],this.positions=[],this.intensity=[],this.texture=e,this.dirty=!0,this.triShader=r,this.lineShader=n,this.pointShader=i,this.pickShader=a,this.pointPickShader=o,this.contourShader=s,this.trianglePositions=l,this.triangleColors=u,this.triangleNormals=h,this.triangleUVs=f,this.triangleIds=c,this.triangleVAO=d,this.triangleCount=0,this.lineWidth=1,this.edgePositions=p,this.edgeColors=v,this.edgeUVs=m,this.edgeIds=g,this.edgeVAO=y,this.edgeCount=0,this.pointPositions=b,this.pointColors=_,this.pointUVs=w,this.pointSizes=k,this.pointIds=x,this.pointVAO=A,this.pointCount=0,this.contourLineWidth=1,this.contourPositions=M,this.contourVAO=T,this.contourCount=0,this.contourColor=[0,0,0],this.contourEnable=!0,this.pickId=1,this.bounds=[[1/0,1/0,1/0],[-(1/0),-(1/0),-(1/0)]],this.clipBounds=[[-(1/0),-(1/0),-(1/0)],[1/0,1/0,1/0]],this.lightPosition=[1e5,1e5,0],this.ambientLight=.8,this.diffuseLight=.8,this.specularLight=2,this.roughness=.5,this.fresnel=1.5,this.opacity=1,this._model=I,this._view=I,this._projection=I,this._resolution=[1,1]}function i(t){for(var e=A({colormap:t,nshades:256,format:"rgba"}),r=new Uint8Array(1024),n=0;256>n;++n){for(var i=e[n],a=0;3>a;++a)r[4*n+a]=i[a];r[4*n+3]=255*i[3]}return k(r,[256,256,4],[4,0,1])}function a(t,e,r){for(var n=new Array(e),i=0;e>i;++i)n[i]=0;for(var a=t.length,i=0;a>i;++i)for(var o=t[i],s=0;sn;++n)r[n]=t[n][2];return r}function s(t){var e=v(t,S);return e.attributes.position.location=0,e.attributes.color.location=2,e.attributes.uv.location=3,e.attributes.normal.location=4,e}function l(t){var e=v(t,C);return e.attributes.position.location=0,e.attributes.color.location=2,e.attributes.uv.location=3,e}function c(t){var e=v(t,z);return e.attributes.position.location=0,e.attributes.color.location=2,e.attributes.uv.location=3,e.attributes.pointSize.location=4,e}function u(t){var e=v(t,P);return e.attributes.position.location=0,e.attributes.id.location=1,e}function f(t){var e=v(t,R);return e.attributes.position.location=0,e.attributes.id.location=1,e.attributes.pointSize.location=4,e}function h(t){var e=v(t,O);return e.attributes.position.location=0,e}function d(t){var e=t.gl,r=s(e),i=l(e),a=c(e),o=u(e),d=f(e),p=h(e),g=b(e,k(new Uint8Array([255,255,255,255]),[1,1,4]));g.generateMipmap(),g.minFilter=e.LINEAR_MIPMAP_LINEAR,g.magFilter=e.LINEAR;var v=m(e),x=m(e),_=m(e),w=m(e),A=m(e),M=y(e,[{buffer:v,type:e.FLOAT,size:3},{buffer:A,type:e.UNSIGNED_BYTE,size:4,normalized:!0},{buffer:x,type:e.FLOAT,size:4},{buffer:_,type:e.FLOAT,size:2},{buffer:w,type:e.FLOAT,size:3}]),T=m(e),E=m(e),L=m(e),S=m(e),C=y(e,[{buffer:T,type:e.FLOAT,size:3},{buffer:S,type:e.UNSIGNED_BYTE,size:4,normalized:!0},{buffer:E,type:e.FLOAT,size:4},{buffer:L,type:e.FLOAT,size:2}]),z=m(e),P=m(e),R=m(e),O=m(e),I=m(e),N=y(e,[{buffer:z,type:e.FLOAT,size:3},{buffer:I,type:e.UNSIGNED_BYTE,size:4,normalized:!0},{buffer:P,type:e.FLOAT,size:4},{buffer:R,type:e.FLOAT,size:2},{buffer:O,type:e.FLOAT,size:1}]),j=m(e),F=y(e,[{buffer:j,type:e.FLOAT,size:3}]),D=new n(e,g,r,i,a,o,d,p,v,A,x,_,w,M,T,S,E,L,C,z,I,P,R,O,N,j,F);return D.update(t),D}var p=1e-6,g=1e-6,v=t("gl-shader"),m=t("gl-buffer"),y=t("gl-vao"),b=t("gl-texture2d"),x=t("normals"),_=t("gl-mat4/multiply"),w=t("gl-mat4/invert"),k=t("ndarray"),A=t("colormap"),M=t("simplicial-complex-contour"),T=t("typedarray-pool"),E=t("./lib/shaders"),L=t("./lib/closest-point"),S=E.meshShader,C=E.wireShader,z=E.pointShader,P=E.pickShader,R=E.pointPickShader,O=E.contourShader,I=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],N=n.prototype;N.isOpaque=function(){return this.opacity>=1},N.isTransparent=function(){return this.opacity<1},N.pickSlots=1,N.setPickBase=function(t){this.pickId=t},N.highlight=function(t){if(!t||!this.contourEnable)return void(this.contourCount=0);for(var e=M(this.cells,this.intensity,t.intensity),r=e.cells,n=e.vertexIds,i=e.vertexWeights,a=r.length,o=T.mallocFloat32(6*a),s=0,l=0;a>l;++l)for(var c=r[l],u=0;2>u;++u){var f=c[0];2===c.length&&(f=c[u]);for(var h=n[f][0],d=n[f][1],p=i[f],g=1-p,v=this.positions[h],m=this.positions[d],y=0;3>y;++y)o[s++]=p*v[y]+g*m[y]}this.contourCount=s/3|0,this.contourPositions.update(o.subarray(0,s)),T.free(o)},N.update=function(t){t=t||{};var e=this.gl;this.dirty=!0,"contourEnable"in t&&(this.contourEnable=t.contourEnable),"contourColor"in t&&(this.contourColor=t.contourColor),"lineWidth"in t&&(this.lineWidth=t.lineWidth),"lightPosition"in t&&(this.lightPosition=t.lightPosition),"opacity"in t&&(this.opacity=t.opacity),"ambient"in t&&(this.ambientLight=t.ambient),"diffuse"in t&&(this.diffuseLight=t.diffuse),"specular"in t&&(this.specularLight=t.specular),"roughness"in t&&(this.roughness=t.roughness),"fresnel"in t&&(this.fresnel=t.fresnel),t.texture?(this.texture.dispose(),this.texture=b(e,t.texture)):t.colormap&&(this.texture.shape=[256,256],this.texture.minFilter=e.LINEAR_MIPMAP_LINEAR,this.texture.magFilter=e.LINEAR,this.texture.setPixels(i(t.colormap)),this.texture.generateMipmap());var r=t.cells,n=t.positions;if(n&&r){var s=[],l=[],c=[],u=[],f=[],h=[],d=[],v=[],m=[],y=[],_=[],w=[],k=[],A=[];this.cells=r,this.positions=n;var M=t.vertexNormals,T=t.cellNormals,E=void 0===t.vertexNormalsEpsilon?p:t.vertexNormalsEpsilon,L=void 0===t.faceNormalsEpsilon?g:t.faceNormalsEpsilon;t.useFacetNormals&&!T&&(T=x.faceNormals(r,n,L)),T||M||(M=x.vertexNormals(r,n,E));var S=t.vertexColors,C=t.cellColors,z=t.meshColor||[1,1,1,1],P=t.vertexUVs,R=t.vertexIntensity,O=t.cellUVs,I=t.cellIntensity,N=1/0,j=-(1/0);if(!P&&!O)if(R)for(var F=0;Fq;++q)!isNaN(V[q])&&isFinite(V[q])&&(this.bounds[0][q]=Math.min(this.bounds[0][q],V[q]),this.bounds[1][q]=Math.max(this.bounds[1][q],V[q]));var H=0,G=0,Y=0;t:for(var F=0;Fq;++q)if(isNaN(V[q])||!isFinite(V[q]))continue t;y.push(V[0],V[1],V[2]);var Z;Z=S?S[W]:C?C[F]:z,3===Z.length?_.push(Z[0],Z[1],Z[2],1):_.push(Z[0],Z[1],Z[2],Z[3]);var K;K=P?P[W]:R?[(R[W]-N)/(j-N),0]:O?O[F]:I?[(I[F]-N)/(j-N),0]:[(V[2]-N)/(j-N),0],w.push(K[0],K[1]),B?k.push(B[W]):k.push(U),A.push(F),Y+=1;break;case 2:for(var q=0;2>q;++q)for(var W=X[q],V=n[W],$=0;3>$;++$)if(isNaN(V[$])||!isFinite(V[$]))continue t;for(var q=0;2>q;++q){var W=X[q],V=n[W];h.push(V[0],V[1],V[2]);var Z;Z=S?S[W]:C?C[F]:z,3===Z.length?d.push(Z[0],Z[1],Z[2],1):d.push(Z[0],Z[1],Z[2],Z[3]);var K;K=P?P[W]:R?[(R[W]-N)/(j-N),0]:O?O[F]:I?[(I[F]-N)/(j-N),0]:[(V[2]-N)/(j-N),0],v.push(K[0],K[1]),m.push(F)}G+=1;break;case 3:for(var q=0;3>q;++q)for(var W=X[q],V=n[W],$=0;3>$;++$)if(isNaN(V[$])||!isFinite(V[$]))continue t;for(var q=0;3>q;++q){var W=X[q],V=n[W];s.push(V[0],V[1],V[2]);var Z;Z=S?S[W]:C?C[F]:z,3===Z.length?l.push(Z[0],Z[1],Z[2],1):l.push(Z[0],Z[1],Z[2],Z[3]);var K;K=P?P[W]:R?[(R[W]-N)/(j-N),0]:O?O[F]:I?[(I[F]-N)/(j-N),0]:[(V[2]-N)/(j-N),0],u.push(K[0],K[1]);var Q;Q=M?M[W]:T[F],c.push(Q[0],Q[1],Q[2]),f.push(F)}H+=1}}this.pointCount=Y,this.edgeCount=G,this.triangleCount=H,this.pointPositions.update(y),this.pointColors.update(_),this.pointUVs.update(w),this.pointSizes.update(k),this.pointIds.update(new Uint32Array(A)),this.edgePositions.update(h),this.edgeColors.update(d),this.edgeUVs.update(v),this.edgeIds.update(new Uint32Array(m)),this.trianglePositions.update(s),this.triangleColors.update(l),this.triangleUVs.update(u),this.triangleNormals.update(c),this.triangleIds.update(new Uint32Array(f))}},N.drawTransparent=N.draw=function(t){t=t||{};for(var e=this.gl,r=t.model||I,n=t.view||I,i=t.projection||I,a=[[-1e6,-1e6,-1e6],[1e6,1e6,1e6]],o=0;3>o;++o)a[0][o]=Math.max(a[0][o],this.clipBounds[0][o]),a[1][o]=Math.min(a[1][o],this.clipBounds[1][o]);var s={model:r,view:n,projection:i,clipBounds:a,kambient:this.ambientLight,kdiffuse:this.diffuseLight,kspecular:this.specularLight,roughness:this.roughness,fresnel:this.fresnel,eyePosition:[0,0,0],lightPosition:[0,0,0],opacity:this.opacity,contourColor:this.contourColor,texture:0};this.texture.bind(0);var l=new Array(16);_(l,s.view,s.model),_(l,s.projection,l),w(l,l);for(var o=0;3>o;++o)s.eyePosition[o]=l[12+o]/l[15];for(var c=l[15],o=0;3>o;++o)c+=this.lightPosition[o]*l[4*o+3];for(var o=0;3>o;++o){for(var u=l[12+o],f=0;3>f;++f)u+=l[4*f+o]*this.lightPosition[f];s.lightPosition[o]=u/c}if(this.triangleCount>0){var h=this.triShader;h.bind(),h.uniforms=s,this.triangleVAO.bind(),e.drawArrays(e.TRIANGLES,0,3*this.triangleCount),this.triangleVAO.unbind()}if(this.edgeCount>0&&this.lineWidth>0){var h=this.lineShader;h.bind(),h.uniforms=s,this.edgeVAO.bind(),e.lineWidth(this.lineWidth),e.drawArrays(e.LINES,0,2*this.edgeCount),this.edgeVAO.unbind()}if(this.pointCount>0){var h=this.pointShader;h.bind(),h.uniforms=s,this.pointVAO.bind(),e.drawArrays(e.POINTS,0,this.pointCount),this.pointVAO.unbind()}if(this.contourEnable&&this.contourCount>0&&this.contourLineWidth>0){var h=this.contourShader;h.bind(),h.uniforms=s,this.contourVAO.bind(),e.drawArrays(e.LINES,0,this.contourCount),this.contourVAO.unbind()}},N.drawPick=function(t){t=t||{};for(var e=this.gl,r=t.model||I,n=t.view||I,i=t.projection||I,a=[[-1e6,-1e6,-1e6],[1e6,1e6,1e6]],o=0;3>o;++o)a[0][o]=Math.max(a[0][o],this.clipBounds[0][o]),a[1][o]=Math.min(a[1][o],this.clipBounds[1][o]);this._model=[].slice.call(r),this._view=[].slice.call(n),this._projection=[].slice.call(i),this._resolution=[e.drawingBufferWidth,e.drawingBufferHeight];var s={model:r,view:n,projection:i,clipBounds:a,pickId:this.pickId/255},l=this.pickShader;if(l.bind(),l.uniforms=s,this.triangleCount>0&&(this.triangleVAO.bind(),e.drawArrays(e.TRIANGLES,0,3*this.triangleCount),this.triangleVAO.unbind()),this.edgeCount>0&&(this.edgeVAO.bind(),e.lineWidth(this.lineWidth),e.drawArrays(e.LINES,0,2*this.edgeCount),this.edgeVAO.unbind()),this.pointCount>0){var l=this.pointPickShader;l.bind(),l.uniforms=s,this.pointVAO.bind(),e.drawArrays(e.POINTS,0,this.pointCount),this.pointVAO.unbind()}},N.pick=function(t){if(!t)return null;if(t.id!==this.pickId)return null;for(var e=t.value[0]+256*t.value[1]+65536*t.value[2],r=this.cells[e],n=this.positions,i=new Array(r.length),a=0;ao;++o){for(var s=new Array(r+1),l=0;r>=l;++l)s[l]=t[l][o];i[o]=s}i[r]=new Array(r+1);for(var o=0;r>=o;++o)i[r][o]=1;for(var c=new Array(r+1),o=0;r>o;++o)c[o]=e[o];c[r]=1;var u=a(i,c),f=n(u[r+1]);0===f&&(f=1);for(var h=new Array(r+1),o=0;r>=o;++o)h[o]=n(u[o])/f;return h}e.exports=i;var a=t("robust-linear-solve")},{"robust-linear-solve":256}],152:[function(t,e,r){var n=1e-6,i=1e-6;r.vertexNormals=function(t,e,r){for(var i=e.length,a=new Array(i),o=void 0===r?n:r,s=0;i>s;++s)a[s]=[0,0,0];for(var s=0;sx;++x)v[x]=d[x]-p[x],m+=v[x]*v[x],y[x]=g[x]-p[x],b+=y[x]*y[x];if(m*b>o)for(var _=a[u],w=1/Math.sqrt(m*b),x=0;3>x;++x){var k=(x+1)%3,A=(x+2)%3;_[x]+=w*(y[k]*v[A]-y[A]*v[k])}}for(var s=0;i>s;++s){for(var _=a[s],M=0,x=0;3>x;++x)M+=_[x]*_[x];if(M>o)for(var w=1/Math.sqrt(M),x=0;3>x;++x)_[x]*=w;else for(var x=0;3>x;++x)_[x]=0}return a},r.faceNormals=function(t,e,r){for(var n=t.length,a=new Array(n),o=void 0===r?i:r,s=0;n>s;++s){for(var l=t[s],c=new Array(3),u=0;3>u;++u)c[u]=e[l[u]];for(var f=new Array(3),h=new Array(3),u=0;3>u;++u)f[u]=c[1][u]-c[0][u],h[u]=c[2][u]-c[0][u];for(var d=new Array(3),p=0,u=0;3>u;++u){var g=(u+1)%3,v=(u+2)%3;d[u]=f[g]*h[v]-f[v]*h[g],p+=d[u]*d[u]}p=p>o?1/Math.sqrt(p):0;for(var u=0;3>u;++u)d[u]*=p;a[s]=d}return a}},{}],153:[function(t,e,r){"use strict";function n(t,e,r,n,s){i.length=x+_)if(0>x)0>_&&0>h?(_=0,-h>=c?(x=1,y=c+2*h+p):(x=-h/c,y=h*x+p)):(x=0,d>=0?(_=0,y=p):-d>=f?(_=1,y=f+2*d+p):(_=-d/f,y=d*_+p));else if(0>_)_=0,h>=0?(x=0,y=p):-h>=c?(x=1,y=c+2*h+p):(x=-h/c,y=h*x+p);else{var w=1/b;x*=w,_*=w,y=x*(c*x+u*_+2*h)+_*(u*x+f*_+2*d)+p}else{var k,A,M,T;0>x?(k=u+h,A=f+d,A>k?(M=A-k,T=c-2*u+f,M>=T?(x=1,_=0,y=c+2*h+p):(x=M/T,_=1-x,y=x*(c*x+u*_+2*h)+_*(u*x+f*_+2*d)+p)):(x=0,0>=A?(_=1,y=f+2*d+p):d>=0?(_=0,y=p):(_=-d/f,y=d*_+p))):0>_?(k=u+d,A=c+h,A>k?(M=A-k,T=c-2*u+f,M>=T?(_=1,x=0,y=f+2*d+p):(_=M/T,x=1-_,y=x*(c*x+u*_+2*h)+_*(u*x+f*_+2*d)+p)):(_=0,0>=A?(x=1,y=c+2*h+p):h>=0?(x=0,y=p):(x=-h/c,y=h*x+p))):(M=f+d-u-h,0>=M?(x=0,_=1,y=f+2*d+p):(T=c-2*u+f,M>=T?(x=1,_=0,y=c+2*h+p):(x=M/T,_=1-x,y=x*(c*x+u*_+2*h)+_*(u*x+f*_+2*d)+p)))}for(var E=1-x-_,l=0;ly?0:y}var i=new Float64Array(4),a=new Float64Array(4),o=new Float64Array(4);e.exports=n},{}],154:[function(t,e,r){"use strict";function n(t){for(var e=t.length,r=0,n=0;e>n;++n)r=0|Math.max(r,t[n].length);return r-1}function i(t,e){for(var r=t.length,n=f.mallocUint8(r),i=0;r>i;++i)n[i]=t[i]o;++o)for(var s=t[o],e=s.length,l=0;e>l;++l)for(var c=0;l>c;++c){var d=s[c],p=s[l];i[a++]=0|Math.min(d,p),i[a++]=0|Math.max(d,p)}var g=a/2|0;h(u(i,[g,2]));for(var v=2,o=2;a>o;o+=2)i[o-2]===i[o]&&i[o-1]===i[o+1]||(i[v++]=i[o],i[v++]=i[o+1]);return u(i,[v/2|0,2])}function o(t,e,r,n){for(var i=t.data,a=t.shape[0],o=f.mallocDouble(a),s=0,l=0;a>l;++l){var c=i[2*l],h=i[2*l+1];if(r[c]!==r[h]){var d=e[c],p=e[h];i[2*s]=c,i[2*s+1]=h,o[s++]=(p-n)/(p-d)}}return t.shape[0]=s,u(o,[s])}function s(t,e){var r=f.mallocInt32(2*e),n=t.shape[0],i=t.data;r[0]=0;for(var a=0,o=0;n>o;++o){var s=i[2*o];if(s!==a){for(r[2*a+1]=o;++ai;++i)n[i]=[r[2*i],r[2*i+1]];return n}function c(t,e,r,c){r=r||0,"undefined"==typeof c&&(c=n(t));var u=t.length;if(0===u||1>c)return{cells:[],vertexIds:[],vertexWeights:[]};var h=i(e,+r),p=a(t,c),g=o(p,e,h,+r),v=s(p,0|e.length),m=d(c)(t,p.data,v,h),y=l(p),b=[].slice.call(g.data,0,g.shape[0]);return f.free(h),f.free(p.data),f.free(g.data),f.free(v),{cells:m,vertexIds:y,vertexWeights:b}}e.exports=c;var u=t("ndarray"),f=t("typedarray-pool"),h=t("ndarray-sort"),d=t("./lib/codegen")},{"./lib/codegen":155,ndarray:253,"ndarray-sort":158,"typedarray-pool":278}],155:[function(t,e,r){"use strict";function n(t){function e(t){if(!(t.length<=0)){c.push("R.push(");for(var e=0;e0&&c.push(","),c.push("[");for(var n=0;n0&&c.push(","),c.push("B(C,E,c[",i[0],"],c[",i[1],"])")}c.push("]")}c.push(");")}}var r=0,n=new Array(t+1);n[0]=[[]];for(var i=1;t>=i;++i)for(var s=n[i]=o(i),l=0;l>1,v=E[2*m+1];","if(v===b){return m}","if(b1;--i){t+1>i&&c.push("else "),c.push("if(l===",i,"){");for(var u=[],l=0;i>l;++l)u.push("(S[c["+l+"]]<<"+l+")");c.push("var M=",u.join("+"),";if(M===0||M===",(1<i;++i)n[i]=0,i===e&&(n[i]+=.5),i===r&&(n[i]+=.5);return n}function i(t,e){if(0===e||e===(1<=a;++a)if(e&1<=s;++s)~e&1<n;++n)r[n]=i(t,n);return r}e.exports=a;var o=t("convex-hull")},{"convex-hull":102}],157:[function(t,e,r){"use strict";function n(t){switch(t){case"uint8":return[l.mallocUint8,l.freeUint8];case"uint16":return[l.mallocUint16,l.freeUint16];case"uint32":return[l.mallocUint32,l.freeUint32];case"int8":return[l.mallocInt8,l.freeInt8];case"int16":return[l.mallocInt16,l.freeInt16];case"int32":return[l.mallocInt32,l.freeInt32];case"float32":return[l.mallocFloat,l.freeFloat];case"float64":return[l.mallocDouble,l.freeDouble];default:return null}}function i(t){for(var e=[],r=0;t>r;++r)e.push("s"+r);for(var r=0;t>r;++r)e.push("n"+r);for(var r=1;t>r;++r)e.push("d"+r);for(var r=1;t>r;++r)e.push("e"+r);for(var r=1;t>r;++r)e.push("f"+r);return e}function a(t,e){function r(t){return"generic"===e?["data.get(",t,")"].join(""):["data[",t,"]"].join("")}function a(t,r){return"generic"===e?["data.set(",t,",",r,")"].join(""):["data[",t,"]=",r].join("")}var o=["'use strict'"],s=["ndarrayInsertionSort",t.join("d"),e].join(""),l=["left","right","data","offset"].concat(i(t.length)),c=n(e),u=["i,j,cptr,ptr=left*s0+offset"];if(t.length>1){for(var f=[],h=1;h1){o.push("dptr=0;sptr=ptr");for(var h=t.length-1;h>=0;--h){var d=t[h];0!==d&&o.push(["for(i",d,"=0;i",d,"left){","dptr=0","sptr=cptr-s0");for(var h=1;hb){break __l}"].join(""));for(var h=t.length-1;h>=1;--h)o.push("sptr+=e"+h,"dptr+=f"+h,"}");o.push("dptr=cptr;sptr=cptr-s0");for(var h=t.length-1;h>=0;--h){var d=t[h];0!==d&&o.push(["for(i",d,"=0;i",d,"=0;--h){var d=t[h];0!==d&&o.push(["for(i",d,"=0;i",d,"left)&&("+r("cptr-s0")+">scratch)){",a("cptr",r("cptr-s0")),"cptr-=s0","}",a("cptr","scratch"));if(o.push("}"),t.length>1&&c&&o.push("free(scratch)"),o.push("} return "+s),c){var p=new Function("malloc","free",o.join("\n"));return p(c[0],c[1])}var p=new Function(o.join("\n"));return p()}function o(t,e,r){function a(t){return["(offset+",t,"*s0)"].join("")}function o(t){return"generic"===e?["data.get(",t,")"].join(""):["data[",t,"]"].join("")}function s(t,r){return"generic"===e?["data.set(",t,",",r,")"].join(""):["data[",t,"]=",r].join("")}function l(e,r,n){if(1===e.length)_.push("ptr0="+a(e[0]));else for(var i=0;i=0;--i){var o=t[i];0!==o&&_.push(["for(i",o,"=0;i",o,"1)for(var i=0;i1?_.push("ptr_shift+=d"+o):_.push("ptr0+=d"+o),_.push("}"))}}function u(e,r,n,i){if(1===r.length)_.push("ptr0="+a(r[0]));else{for(var o=0;o1)for(var o=0;o=1;--o)n&&_.push("pivot_ptr+=f"+o),r.length>1?_.push("ptr_shift+=e"+o):_.push("ptr0+=e"+o),_.push("}")}function f(){t.length>1&&A&&_.push("free(pivot1)","free(pivot2)")}function h(e,r){var n="el"+e,i="el"+r;if(t.length>1){var s="__l"+ ++M;u(s,[n,i],!1,["comp=",o("ptr0"),"-",o("ptr1"),"\n","if(comp>0){tmp0=",n,";",n,"=",i,";",i,"=tmp0;break ",s,"}\n","if(comp<0){break ",s,"}"].join(""))}else _.push(["if(",o(a(n)),">",o(a(i)),"){tmp0=",n,";",n,"=",i,";",i,"=tmp0}"].join(""))}function d(e,r){t.length>1?l([e,r],!1,s("ptr0",o("ptr1"))):_.push(s(a(e),o(a(r))))}function p(e,r,n){if(t.length>1){var i="__l"+ ++M;u(i,[r],!0,[e,"=",o("ptr0"),"-pivot",n,"[pivot_ptr]\n","if(",e,"!==0){break ",i,"}"].join(""))}else _.push([e,"=",o(a(r)),"-pivot",n].join(""))}function g(e,r){t.length>1?l([e,r],!1,["tmp=",o("ptr0"),"\n",s("ptr0",o("ptr1")),"\n",s("ptr1","tmp")].join("")):_.push(["ptr0=",a(e),"\n","ptr1=",a(r),"\n","tmp=",o("ptr0"),"\n",s("ptr0",o("ptr1")),"\n",s("ptr1","tmp")].join(""))}function v(e,r,n){t.length>1?(l([e,r,n],!1,["tmp=",o("ptr0"),"\n",s("ptr0",o("ptr1")),"\n",s("ptr1",o("ptr2")),"\n",s("ptr2","tmp")].join("")),_.push("++"+r,"--"+n)):_.push(["ptr0=",a(e),"\n","ptr1=",a(r),"\n","ptr2=",a(n),"\n","++",r,"\n","--",n,"\n","tmp=",o("ptr0"),"\n",s("ptr0",o("ptr1")),"\n",s("ptr1",o("ptr2")),"\n",s("ptr2","tmp")].join(""))}function m(t,e){g(t,e),_.push("--"+e)}function y(e,r,n){t.length>1?l([e,r],!0,[s("ptr0",o("ptr1")),"\n",s("ptr1",["pivot",n,"[pivot_ptr]"].join(""))].join("")):_.push(s(a(e),o(a(r))),s(a(r),"pivot"+n))}function b(e,r){_.push(["if((",r,"-",e,")<=",c,"){\n","insertionSort(",e,",",r,",data,offset,",i(t.length).join(","),")\n","}else{\n",w,"(",e,",",r,",data,offset,",i(t.length).join(","),")\n","}"].join(""))}function x(e,r,n){t.length>1?(_.push(["__l",++M,":while(true){"].join("")),l([e],!0,["if(",o("ptr0"),"!==pivot",r,"[pivot_ptr]){break __l",M,"}"].join("")),_.push(n,"}")):_.push(["while(",o(a(e)),"===pivot",r,"){",n,"}"].join(""))}var _=["'use strict'"],w=["ndarrayQuickSort",t.join("d"),e].join(""),k=["left","right","data","offset"].concat(i(t.length)),A=n(e),M=0;_.push(["function ",w,"(",k.join(","),"){"].join(""));var T=["sixth=((right-left+1)/6)|0","index1=left+sixth","index5=right-sixth","index3=(left+right)>>1","index2=index3-sixth","index4=index3+sixth","el1=index1","el2=index2","el3=index3","el4=index4","el5=index5","less=left+1","great=right-1","pivots_are_equal=true","tmp","tmp0","x","y","z","k","ptr0","ptr1","ptr2","comp_pivot1=0","comp_pivot2=0","comp=0"];if(t.length>1){for(var E=[],L=1;LL;++L)T.push("b_ptr"+L);T.push("ptr3","ptr4","ptr5","ptr6","ptr7","pivot_ptr","ptr_shift","elementSize="+E.join("*")),A?T.push("pivot1=malloc(elementSize)","pivot2=malloc(elementSize)"):T.push("pivot1=new Array(elementSize),pivot2=new Array(elementSize)")}else T.push("pivot1","pivot2");if(_.push("var "+T.join(",")),h(1,2),h(4,5),h(1,3),h(2,3),h(1,4),h(3,4),h(2,5),h(2,3),h(4,5),t.length>1?l(["el1","el2","el3","el4","el5","index1","index3","index5"],!0,["pivot1[pivot_ptr]=",o("ptr1"),"\n","pivot2[pivot_ptr]=",o("ptr3"),"\n","pivots_are_equal=pivots_are_equal&&(pivot1[pivot_ptr]===pivot2[pivot_ptr])\n","x=",o("ptr0"),"\n","y=",o("ptr2"),"\n","z=",o("ptr4"),"\n",s("ptr5","x"),"\n",s("ptr6","y"),"\n",s("ptr7","z")].join("")):_.push(["pivot1=",o(a("el2")),"\n","pivot2=",o(a("el4")),"\n","pivots_are_equal=pivot1===pivot2\n","x=",o(a("el1")),"\n","y=",o(a("el3")),"\n","z=",o(a("el5")),"\n",s(a("index1"),"x"),"\n",s(a("index3"),"y"),"\n",s(a("index5"),"z")].join("")),d("index2","left"),d("index4","right"),_.push("if(pivots_are_equal){"),_.push("for(k=less;k<=great;++k){"),p("comp","k",1),_.push("if(comp===0){continue}"),_.push("if(comp<0){"),_.push("if(k!==less){"),g("k","less"),_.push("}"),_.push("++less"),_.push("}else{"),_.push("while(true){"),p("comp","great",1),_.push("if(comp>0){"),_.push("great--"),_.push("}else if(comp<0){"),v("k","less","great"),_.push("break"),_.push("}else{"),m("k","great"),_.push("break"),_.push("}"),_.push("}"),_.push("}"),_.push("}"),_.push("}else{"),_.push("for(k=less;k<=great;++k){"),p("comp_pivot1","k",1),_.push("if(comp_pivot1<0){"),_.push("if(k!==less){"),g("k","less"),_.push("}"),_.push("++less"),_.push("}else{"),p("comp_pivot2","k",2),_.push("if(comp_pivot2>0){"),_.push("while(true){"),p("comp","great",2),_.push("if(comp>0){"),_.push("if(--greatindex5){"),x("less",1,"++less"),x("great",2,"--great"),_.push("for(k=less;k<=great;++k){"),p("comp_pivot1","k",1),_.push("if(comp_pivot1===0){"),_.push("if(k!==less){"),g("k","less"),_.push("}"),_.push("++less"),_.push("}else{"),p("comp_pivot2","k",2),_.push("if(comp_pivot2===0){"),_.push("while(true){"),p("comp","great",2),_.push("if(comp===0){"),_.push("if(--great1&&A){var S=new Function("insertionSort","malloc","free",_.join("\n"));return S(r,A[0],A[1])}var S=new Function("insertionSort",_.join("\n"));return S(r)}function s(t,e){var r=["'use strict'"],n=["ndarraySortWrapper",t.join("d"),e].join(""),s=["array"];r.push(["function ",n,"(",s.join(","),"){"].join(""));for(var l=["data=array.data,offset=array.offset|0,shape=array.shape,stride=array.stride"],u=0;u0?l.push(["d",v,"=s",v,"-d",p,"*n",p].join("")):l.push(["d",v,"=s",v].join("")),p=v);var d=t.length-1-u;0!==d&&(g>0?l.push(["e",d,"=s",d,"-e",g,"*n",g,",f",d,"=",f[d],"-f",g,"*n",g].join("")):l.push(["e",d,"=s",d,",f",d,"=",f[d]].join("")),g=d)}r.push("var "+l.join(","));var m=["0","n0-1","data","offset"].concat(i(t.length));r.push(["if(n0<=",c,"){","insertionSort(",m.join(","),")}else{","quickSort(",m.join(","),")}"].join("")),r.push("}return "+n);var y=new Function("insertionSort","quickSort",r.join("\n")),b=a(t,e),x=o(t,e,b);return y(b,x)}var l=t("typedarray-pool"),c=32;e.exports=s},{"typedarray-pool":278}],158:[function(t,e,r){"use strict";function n(t){var e=t.order,r=t.dtype,n=[e,r],o=n.join(":"),s=a[o];return s||(a[o]=s=i(e,r)),s(t),t}var i=t("./lib/compile_sort.js"),a={};e.exports=n},{"./lib/compile_sort.js":157}],159:[function(t,e,r){"use strict";function n(t,e,r){this.plot=t,this.vbo=e,this.shader=r}function i(t){var e=t.gl,r=a(e,[0,0,0,1,1,0,1,1]),i=o(e,s.boxVert,s.lineFrag);return new n(t,r,i)}e.exports=i;var a=t("gl-buffer"),o=t("gl-shader"),s=t("./shaders"),l=n.prototype;l.bind=function(){var t=this.shader;this.vbo.bind(),this.shader.bind(),t.attributes.coord.pointer(),t.uniforms.screenBox=this.plot.screenBox},l.drawBox=function(){var t=[0,0],e=[0,0];return function(r,n,i,a,o){var s=this.plot,l=this.shader,c=s.gl;t[0]=r,t[1]=n,e[0]=i,e[1]=a,l.uniforms.lo=t,l.uniforms.hi=e,l.uniforms.color=o,c.drawArrays(c.TRIANGLE_STRIP,0,4)}}(),l.dispose=function(){this.vbo.dispose(),this.shader.dispose()}},{"./shaders":162,"gl-buffer":118,"gl-shader":197}],160:[function(t,e,r){"use strict";function n(t,e,r,n){this.plot=t,this.vbo=e,this.shader=r,this.tickShader=n,this.ticks=[[],[]]}function i(t,e){return t-e}function a(t){var e=t.gl,r=o(e),i=s(e,c.gridVert,c.gridFrag),a=s(e,c.tickVert,c.gridFrag),l=new n(t,r,i,a);return l}e.exports=a;var o=t("gl-buffer"),s=t("gl-shader"),l=t("binary-search-bounds"),c=t("./shaders"),u=n.prototype;u.draw=function(){var t=[0,0],e=[0,0],r=[0,0];return function(){for(var n=this.plot,i=this.vbo,a=this.shader,o=this.ticks,s=n.gl,l=n._tickBounds,c=n.dataBox,u=n.viewBox,f=n.gridLineWidth,h=n.gridLineColor,d=n.gridLineEnable,p=n.pixelRatio,g=0;2>g;++g){var v=l[g],m=l[g+2],y=m-v,b=.5*(c[g+2]+c[g]),x=c[g+2]-c[g];e[g]=2*y/x,t[g]=2*(v-b)/x}a.bind(),i.bind(),a.attributes.dataCoord.pointer(),a.uniforms.dataShift=t,a.uniforms.dataScale=e;for(var _=0,g=0;2>g;++g){r[0]=r[1]=0,r[g]=1,a.uniforms.dataAxis=r,a.uniforms.lineWidth=f[g]/(u[g+2]-u[g])*p,a.uniforms.color=h[g];var w=6*o[g].length;d[g]&&w&&s.drawArrays(s.TRIANGLES,_,w),_+=w}}}(),u.drawTickMarks=function(){var t=[0,0],e=[0,0],r=[1,0],n=[0,1],a=[0,0],o=[0,0];return function(){for(var s=this.plot,c=this.vbo,u=this.tickShader,f=this.ticks,h=s.gl,d=s._tickBounds,p=s.dataBox,g=s.viewBox,v=s.pixelRatio,m=s.screenBox,y=m[2]-m[0],b=m[3]-m[1],x=g[2]-g[0],_=g[3]-g[1],w=0;2>w;++w){var k=d[w],A=d[w+2],M=A-k,T=.5*(p[w+2]+p[w]),E=p[w+2]-p[w];e[w]=2*M/E,t[w]=2*(k-T)/E}e[0]*=x/y,t[0]*=x/y,e[1]*=_/b,t[1]*=_/b,u.bind(),c.bind(),u.attributes.dataCoord.pointer();var L=u.uniforms;L.dataShift=t,L.dataScale=e;var S=s.tickMarkLength,C=s.tickMarkWidth,z=s.tickMarkColor,P=0,R=6*f[0].length,O=Math.min(l.ge(f[0],(p[0]-d[0])/(d[2]-d[0]),i),f[0].length),I=Math.min(l.gt(f[0],(p[2]-d[0])/(d[2]-d[0]),i),f[0].length),N=P+6*O,j=6*Math.max(0,I-O),F=Math.min(l.ge(f[1],(p[1]-d[1])/(d[3]-d[1]),i),f[1].length),D=Math.min(l.gt(f[1],(p[3]-d[1])/(d[3]-d[1]),i),f[1].length),B=R+6*F,U=6*Math.max(0,D-F);a[0]=2*(g[0]-S[1])/y-1,a[1]=(g[3]+g[1])/b-1,o[0]=S[1]*v/y,o[1]=C[1]*v/b,U&&(L.color=z[1],L.tickScale=o,L.dataAxis=n,L.screenOffset=a,h.drawArrays(h.TRIANGLES,B,U)),a[0]=(g[2]+g[0])/y-1,a[1]=2*(g[1]-S[0])/b-1,o[0]=C[0]*v/y,o[1]=S[0]*v/b,j&&(L.color=z[0],L.tickScale=o,L.dataAxis=r,L.screenOffset=a,h.drawArrays(h.TRIANGLES,N,j)),a[0]=2*(g[2]+S[3])/y-1,a[1]=(g[3]+g[1])/b-1,o[0]=S[3]*v/y,o[1]=C[3]*v/b,U&&(L.color=z[3],L.tickScale=o,L.dataAxis=n,L.screenOffset=a,h.drawArrays(h.TRIANGLES,B,U)),a[0]=(g[2]+g[0])/y-1,a[1]=2*(g[3]+S[2])/b-1,o[0]=C[2]*v/y,o[1]=S[2]*v/b,j&&(L.color=z[2],L.tickScale=o,L.dataAxis=r,L.screenOffset=a,h.drawArrays(h.TRIANGLES,N,j))}}(),u.update=function(){var t=[1,1,-1,-1,1,-1],e=[1,-1,1,1,-1,-1];return function(r){for(var n=r.ticks,i=r.bounds,a=new Float32Array(18*(n[0].length+n[1].length)),o=(this.plot.zeroLineEnable,0),s=[[],[]],l=0;2>l;++l)for(var c=s[l],u=n[l],f=i[l],h=i[l+2],d=0;dg;++g)a[o++]=p,a[o++]=t[g],a[o++]=e[g]}this.ticks=s,this.vbo.update(a)}}(),u.dispose=function(){this.vbo.dispose(),this.shader.dispose(),this.tickShader.dispose()}},{"./shaders":162,"binary-search-bounds":164,"gl-buffer":118,"gl-shader":197}],161:[function(t,e,r){"use strict";function n(t,e,r){this.plot=t,this.vbo=e,this.shader=r}function i(t){var e=t.gl,r=a(e,[-1,-1,-1,1,1,-1,1,1]),i=o(e,s.lineVert,s.lineFrag),l=new n(t,r,i);return l}e.exports=i;var a=t("gl-buffer"),o=t("gl-shader"),s=t("./shaders"),l=n.prototype;l.bind=function(){var t=this.shader;this.vbo.bind(),this.shader.bind(),t.attributes.coord.pointer(),t.uniforms.screenBox=this.plot.screenBox},l.drawLine=function(){var t=[0,0],e=[0,0];return function(r,n,i,a,o,s){var l=this.plot,c=this.shader,u=l.gl;t[0]=r,t[1]=n,e[0]=i,e[1]=a,c.uniforms.start=t,c.uniforms.end=e,c.uniforms.width=o*l.pixelRatio,c.uniforms.color=s,u.drawArrays(u.TRIANGLE_STRIP,0,4)}}(),l.dispose=function(){this.vbo.dispose(),this.shader.dispose()}},{"./shaders":162,"gl-buffer":118,"gl-shader":197}],162:[function(t,e,r){"use strict";var n="precision lowp float;\n#define GLSLIFY 1\nuniform vec4 color;\nvoid main() {\n gl_FragColor = vec4(color.xyz * color.w, color.w);\n}\n";e.exports={lineVert:"precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 coord;\n\nuniform vec4 screenBox;\nuniform vec2 start, end;\nuniform float width;\n\nvec2 perp(vec2 v) {\n return vec2(v.y, -v.x);\n}\n\nvec2 screen(vec2 v) {\n return 2.0 * (v - screenBox.xy) / (screenBox.zw - screenBox.xy) - 1.0;\n}\n\nvoid main() {\n vec2 delta = normalize(perp(start - end));\n vec2 offset = mix(start, end, 0.5 * (coord.y+1.0));\n gl_Position = vec4(screen(offset + 0.5 * width * delta * coord.x), 0, 1);\n}\n",lineFrag:n,textVert:"#define GLSLIFY 1\nattribute vec3 textCoordinate;\n\nuniform vec2 dataScale, dataShift, dataAxis, screenOffset, textScale;\nuniform float angle;\n\nvoid main() {\n float dataOffset = textCoordinate.z;\n vec2 glyphOffset = textCoordinate.xy;\n mat2 glyphMatrix = mat2(cos(angle), sin(angle), -sin(angle), cos(angle));\n vec2 screenCoordinate = dataAxis * (dataScale * dataOffset + dataShift) +\n glyphMatrix * glyphOffset * textScale + screenOffset;\n gl_Position = vec4(screenCoordinate, 0, 1);\n}\n",textFrag:n,gridVert:"precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 dataCoord;\n\nuniform vec2 dataAxis, dataShift, dataScale;\nuniform float lineWidth;\n\nvoid main() {\n vec2 pos = dataAxis * (dataScale * dataCoord.x + dataShift);\n pos += 10.0 * dataCoord.y * vec2(dataAxis.y, -dataAxis.x) + dataCoord.z * lineWidth;\n gl_Position = vec4(pos, 0, 1);\n}\n",gridFrag:n,boxVert:"precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 coord;\n\nuniform vec4 screenBox;\nuniform vec2 lo, hi;\n\nvec2 screen(vec2 v) {\n return 2.0 * (v - screenBox.xy) / (screenBox.zw - screenBox.xy) - 1.0;\n}\n\nvoid main() {\n gl_Position = vec4(screen(mix(lo, hi, coord)), 0, 1);\n}\n",tickVert:"precision mediump float;\n#define GLSLIFY 1\n\nattribute vec3 dataCoord;\n\nuniform vec2 dataAxis, dataShift, dataScale, screenOffset, tickScale;\n\nvoid main() {\n vec2 pos = dataAxis * (dataScale * dataCoord.x + dataShift);\n gl_Position = vec4(pos + tickScale*dataCoord.yz + screenOffset, 0, 1);\n}\n"}},{}],163:[function(t,e,r){"use strict";function n(t,e,r){this.plot=t,this.vbo=e,this.shader=r,this.tickOffset=[[],[]],this.tickX=[[],[]],this.labelOffset=[0,0],this.labelCount=[0,0]}function i(t){var e=t.gl,r=a(e),i=o(e,c.textVert,c.textFrag),s=new n(t,r,i);return s}e.exports=i;var a=t("gl-buffer"),o=t("gl-shader"),s=t("text-cache"),l=t("binary-search-bounds"),c=t("./shaders"),u=n.prototype;u.drawTicks=function(){var t=[0,0],e=[0,0],r=[0,0];return function(n){var i=this.plot,a=this.shader,o=this.tickX[n],s=this.tickOffset[n],c=i.gl,u=i.viewBox,f=i.dataBox,h=i.screenBox,d=i.pixelRatio,p=i.tickEnable,g=i.tickPad,v=i.tickColor,m=i.tickAngle,y=(i.tickMarkLength,i.labelEnable),b=i.labelPad,x=i.labelColor,_=i.labelAngle,w=this.labelOffset[n],k=this.labelCount[n],A=l.lt(o,f[n]),M=l.le(o,f[n+2]);t[0]=t[1]=0,t[n]=1,e[n]=(u[2+n]+u[n])/(h[2+n]-h[n])-1;var T=2/h[2+(1^n)]-h[1^n];e[1^n]=T*u[1^n]-1,p[n]&&(e[1^n]-=T*d*g[n],M>A&&s[M]>s[A]&&(a.uniforms.dataAxis=t,a.uniforms.screenOffset=e,a.uniforms.color=v[n],a.uniforms.angle=m[n],c.drawArrays(c.TRIANGLES,s[A],s[M]-s[A]))),y[n]&&k&&(e[1^n]-=T*d*b[n],a.uniforms.dataAxis=r,a.uniforms.screenOffset=e,a.uniforms.color=x[n],a.uniforms.angle=_[n],c.drawArrays(c.TRIANGLES,w,k)),e[1^n]=T*u[2+(1^n)]-1,p[n+2]&&(e[1^n]+=T*d*g[n+2],M>A&&s[M]>s[A]&&(a.uniforms.dataAxis=t,a.uniforms.screenOffset=e,a.uniforms.color=v[n+2],a.uniforms.angle=m[n+2],c.drawArrays(c.TRIANGLES,s[A],s[M]-s[A]))),y[n+2]&&k&&(e[1^n]+=T*d*b[n+2],a.uniforms.dataAxis=r,a.uniforms.screenOffset=e,a.uniforms.color=x[n+2],a.uniforms.angle=_[n+2],c.drawArrays(c.TRIANGLES,w,k))}}(),u.drawTitle=function(){var t=[0,0],e=[0,0];return function(){var r=this.plot,n=this.shader,i=r.gl,a=r.screenBox,o=r.titleCenter,s=r.titleAngle,l=r.titleColor,o=r.titleCenter,c=r.pixelRatio;if(this.titleCount){for(var u=0;2>u;++u)e[u]=2*(o[u]*c-a[u])/(a[2+u]-a[u])-1;n.bind(),n.uniforms.dataAxis=t,n.uniforms.screenOffset=e,n.uniforms.angle=s,n.uniforms.color=l,i.drawArrays(i.TRIANGLES,this.titleOffset,this.titleCount)}}}(),u.bind=function(){var t=[0,0],e=[0,0],r=[0,0];return function(){var n=this.plot,i=this.shader,a=n._tickBounds,o=n.dataBox,s=n.screenBox,l=n.viewBox;i.bind();for(var c=0;2>c;++c){var u=a[c],f=a[c+2],h=f-u,d=.5*(o[c+2]+o[c]),p=o[c+2]-o[c],g=l[c],v=l[c+2],m=v-g,y=s[c],b=s[c+2],x=b-y;e[c]=2*h/p*m/x,t[c]=2*(u-d)/p*m/x}r[1]=2*n.pixelRatio/(s[3]-s[1]),r[0]=r[1]*(s[3]-s[1])/(s[2]-s[0]),i.uniforms.dataScale=e,i.uniforms.dataShift=t,i.uniforms.textScale=r,this.vbo.bind(),i.attributes.textCoordinate.pointer()}}(),u.update=function(t){for(var e=[],r=t.ticks,n=t.bounds,i=0;2>i;++i){for(var a=[Math.floor(e.length/3)],o=[-(1/0)],l=r[i],c=0;ci;++i){this.labelOffset[i]=Math.floor(e.length/3);for(var g=s(t.labelFont[i],t.labels[i]).data,p=t.labelSize[i],c=0;cp;++p)if(f[p]&&n[p]<=0&&n[p+2]>=0){var g=e[p]-n[p]*(e[p+2]-e[p])/(n[p+2]-n[p]);0===p?o.drawLine(g,e[1],g,e[3],d[p],h[p]):o.drawLine(e[0],g,e[2],g,d[p],h[p])}}for(var p=0;pp;++p)s.drawTicks(p);this.titleEnable&&s.drawTitle();for(var b=this.overlays,p=0;pc;++c){var u=s[c].slice(0);0!==u.length&&(u.sort(a),l[c]=Math.min(l[c],u[0].x),l[c+2]=Math.max(l[c+2],u[u.length-1].x))}this.grid.update({bounds:l,ticks:s}),this.text.update({bounds:l,ticks:s,labels:t.labels||["x","y"],labelSize:t.labelSize||[12,12],labelFont:t.labelFont||["sans-serif","sans-serif"],title:t.title||"",titleSize:t.titleSize||18,titleFont:t.titleFont||"sans-serif"}),this.setDirty()},h.dispose=function(){this.box.dispose(),this.grid.dispose(),this.text.dispose(),this.line.dispose();for(var t=this.objects.length-1;t>=0;--t)this.objects[t].dispose();this.objects.length=0;for(var t=this.overlays.length-1;t>=0;--t)this.overlays[t].dispose();this.overlays.length=0,this.gl=null},h.addObject=function(t){this.objects.indexOf(t)<0&&(this.objects.push(t),this.setDirty())},h.removeObject=function(t){for(var e=this.objects,r=0;rh;++h)o=o&&l[h]===s[h],l[h]=s[h];var d=t.clientWidth===u&&t.clientHeight===f;return u=t.clientWidth,f=t.clientHeight,o?!d:(c=Math.exp(n.computedRadius[0]),!0)},lookAt:function(t,e,r){n.lookAt(n.lastT(),t,e,r)},rotate:function(t,e,r){n.rotate(n.lastT(),t,e,r)},pan:function(t,e,r){n.pan(n.lastT(),t,e,r)},translate:function(t,e,r){n.translate(n.lastT(),t,e,r)}};Object.defineProperties(h,{matrix:{get:function(){return n.computedMatrix},set:function(t){return n.setMatrix(n.lastT(),t),n.computedMatrix},enumerable:!0},mode:{get:function(){return n.getMode()},set:function(t){return n.setMode(t),n.getMode()},enumerable:!0},center:{get:function(){return n.computedCenter},set:function(t){return n.lookAt(n.lastT(),t),n.computedCenter},enumerable:!0},eye:{get:function(){return n.computedEye},set:function(t){return n.lookAt(n.lastT(),null,t),n.computedEye},enumerable:!0},up:{get:function(){return n.computedUp},set:function(t){return n.lookAt(n.lastT(),null,null,t),n.computedUp},enumerable:!0},distance:{get:function(){return c},set:function(t){return n.setDistance(n.lastT(),t),t},enumerable:!0},distanceLimits:{get:function(){return n.getDistanceLimits(r)},set:function(t){return n.setDistanceLimits(t),t},enumerable:!0}}),t.addEventListener("contextmenu",function(t){return t.preventDefault(),!1});var d=0,p=0;return o(t,function(e,r,a,o){var s=1/t.clientHeight,l=s*(r-d),u=s*(a-p),f=h.flipX?1:-1,g=h.flipY?1:-1,v=Math.PI*h.rotateSpeed,m=i();if(1&e)o.shift?n.rotate(m,0,0,-l*v):n.rotate(m,f*v*l,-g*v*u,0);else if(2&e)n.pan(m,-h.translateSpeed*l*c,h.translateSpeed*u*c,0);else if(4&e){var y=h.zoomSpeed*u/window.innerHeight*(m-n.lastT())*50;n.pan(m,0,0,c*(Math.exp(y)-1))}d=r,p=a}),s(t,function(t,e,r){var a=h.flipX?1:-1,o=h.flipY?1:-1,s=i();if(Math.abs(t)>Math.abs(e))n.rotate(s,0,0,-t*a*Math.PI*h.rotateSpeed/window.innerWidth);else{var l=h.zoomSpeed*o*e/window.innerHeight*(s-n.lastT())/100;n.pan(s,0,0,c*(Math.exp(l)-1))}},!0),h}e.exports=n;var i=t("right-now"),a=t("3d-view"),o=t("mouse-change"),s=t("mouse-wheel")},{"3d-view":39,"mouse-change":241,"mouse-wheel":245,"right-now":255}],168:[function(t,e,r){!function(){"use strict";function t(e){e.permitHostObjects___&&e.permitHostObjects___(t)}function r(t){return!(t.substr(0,d.length)==d&&"___"===t.substr(t.length-3))}function n(t){if(t!==Object(t))throw new TypeError("Not an object: "+t);var e=t[p];if(e&&e.key===t)return e;if(h(t)){e={key:t};try{return f(t,p,{value:e,writable:!1,enumerable:!1,configurable:!1}),e}catch(r){return}}}function i(t){return t.prototype=null,Object.freeze(t)}function a(){y||"undefined"==typeof console||(y=!0,console.warn("WeakMap should be invoked as new WeakMap(), not WeakMap(). This will be an error in the future."))}if("undefined"==typeof ses||!ses.ok||ses.ok()){"undefined"!=typeof ses&&(ses.weakMapPermitHostObjects=t);var o=!1;if("function"==typeof WeakMap){var s=WeakMap;if("undefined"!=typeof navigator&&/Firefox/.test(navigator.userAgent));else{var l=new s,c=Object.freeze({});if(l.set(c,1),1===l.get(c))return void(e.exports=WeakMap);o=!0}}var u=(Object.prototype.hasOwnProperty,Object.getOwnPropertyNames),f=Object.defineProperty,h=Object.isExtensible,d="weakmap:",p=d+"ident:"+Math.random()+"___";if("undefined"!=typeof crypto&&"function"==typeof crypto.getRandomValues&&"function"==typeof ArrayBuffer&&"function"==typeof Uint8Array){var g=new ArrayBuffer(25),v=new Uint8Array(g);crypto.getRandomValues(v),p=d+"rand:"+Array.prototype.map.call(v,function(t){return(t%36).toString(36)}).join("")+"___"}if(f(Object,"getOwnPropertyNames",{value:function(t){return u(t).filter(r)}}),"getPropertyNames"in Object){var m=Object.getPropertyNames;f(Object,"getPropertyNames",{value:function(t){return m(t).filter(r)}})}!function(){var t=Object.freeze;f(Object,"freeze",{value:function(e){return n(e),t(e)}});var e=Object.seal;f(Object,"seal",{value:function(t){return n(t),e(t)}});var r=Object.preventExtensions;f(Object,"preventExtensions",{value:function(t){return n(t),r(t)}})}();var y=!1,b=0,x=function(){function t(t,e){var r,i=n(t);return i?c in i?i[c]:e:(r=s.indexOf(t),r>=0?l[r]:e)}function e(t){var e=n(t);return e?c in e:s.indexOf(t)>=0}function r(t,e){var r,i=n(t);return i?i[c]=e:(r=s.indexOf(t),r>=0?l[r]=e:(r=s.length,l[r]=e,s[r]=t)),this}function o(t){var e,r,i=n(t);return i?c in i&&delete i[c]:(e=s.indexOf(t),0>e?!1:(r=s.length-1,s[e]=void 0,l[e]=l[r],s[e]=s[r],s.length=r,l.length=r,!0))}this instanceof x||a();var s=[],l=[],c=b++;return Object.create(x.prototype,{get___:{value:i(t)},has___:{value:i(e)},set___:{value:i(r)},delete___:{value:i(o)}})};x.prototype=Object.create(Object.prototype,{get:{value:function(t,e){return this.get___(t,e)},writable:!0,configurable:!0},has:{value:function(t){return this.has___(t)},writable:!0,configurable:!0},set:{value:function(t,e){return this.set___(t,e)},writable:!0,configurable:!0},"delete":{value:function(t){return this.delete___(t)},writable:!0,configurable:!0}}),"function"==typeof s?!function(){function r(){function e(t,e){return u?c.has(t)?c.get(t):u.get___(t,e):c.get(t,e)}function r(t){return c.has(t)||(u?u.has___(t):!1)}function n(t){var e=!!c.delete(t);return u?u.delete___(t)||e:e}this instanceof x||a();var l,c=new s,u=void 0,f=!1;return l=o?function(t,e){return c.set(t,e),c.has(t)||(u||(u=new x),u.set(t,e)),this}:function(t,e){if(f)try{c.set(t,e)}catch(r){u||(u=new x),u.set___(t,e)}else c.set(t,e);return this},Object.create(x.prototype,{get___:{value:i(e)},has___:{value:i(r)},set___:{value:i(l)},delete___:{value:i(n)},permitHostObjects___:{value:i(function(e){if(e!==t)throw new Error("bogus call to permitHostObjects___");f=!0})}})}o&&"undefined"!=typeof Proxy&&(Proxy=void 0),r.prototype=x.prototype,e.exports=r,Object.defineProperty(WeakMap.prototype,"constructor",{value:WeakMap,enumerable:!1,configurable:!0,writable:!0})}():("undefined"!=typeof Proxy&&(Proxy=void 0),e.exports=x)}}()},{}],169:[function(t,e,r){"use strict";function n(t){var e=s.get(t);if(!e||!t.isBuffer(e._triangleBuffer.buffer)){var r=a(t,new Float32Array([-1,-1,-1,4,4,-1]));e=o(t,[{buffer:r,type:t.FLOAT,size:2}]),e._triangleBuffer=r,s.set(t,e)}e.bind(),t.drawArrays(t.TRIANGLES,0,3),e.unbind()}var i="undefined"==typeof WeakMap?t("weak-map"):WeakMap,a=t("gl-buffer"),o=t("gl-vao"),s=new i;e.exports=n},{"gl-buffer":118,"gl-vao":226,"weak-map":168}],170:[function(t,e,r){"use strict";function n(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function i(t){this.gl=t,this.pixelRatio=1,this.bounds=[[-10,-10,-10],[10,10,10]],this.ticks=[[],[],[]],this.autoTicks=!0,this.tickSpacing=[1,1,1],this.tickEnable=[!0,!0,!0],this.tickFont=["sans-serif","sans-serif","sans-serif"],this.tickSize=[12,12,12],this.tickAngle=[0,0,0],this.tickColor=[[0,0,0,1],[0,0,0,1],[0,0,0,1]],this.tickPad=[10,10,10],this.lastCubeProps={cubeEdges:[0,0,0],axis:[0,0,0]},this.labels=["x","y","z"],this.labelEnable=[!0,!0,!0],this.labelFont="sans-serif",this.labelSize=[20,20,20],this.labelAngle=[0,0,0],this.labelColor=[[0,0,0,1],[0,0,0,1],[0,0,0,1]],this.labelPad=[10,10,10],this.lineEnable=[!0,!0,!0],this.lineMirror=[!1,!1,!1],this.lineWidth=[1,1,1],this.lineColor=[[0,0,0,1],[0,0,0,1],[0,0,0,1]],this.lineTickEnable=[!0,!0,!0],this.lineTickMirror=[!1,!1,!1],this.lineTickLength=[0,0,0],this.lineTickWidth=[1,1,1],this.lineTickColor=[[0,0,0,1],[0,0,0,1],[0,0,0,1]],this.gridEnable=[!0,!0,!0],this.gridWidth=[1,1,1],this.gridColor=[[0,0,0,1],[0,0,0,1],[0,0,0,1]],this.zeroEnable=[!0,!0,!0],this.zeroLineColor=[[0,0,0,1],[0,0,0,1],[0,0,0,1]],this.zeroLineWidth=[2,2,2],this.backgroundEnable=[!1,!1,!1],this.backgroundColor=[[.8,.8,.8,.5],[.8,.8,.8,.5],[.8,.8,.8,.5]],this._firstInit=!0,this._text=null,this._lines=null,this._background=u(t)}function a(){this.primalOffset=[0,0,0],this.primalMinor=[0,0,0],this.mirrorOffset=[0,0,0],this.mirrorMinor=[0,0,0]}function o(t,e,r,n,i){for(var a=t.primalOffset,o=t.primalMinor,s=t.mirrorOffset,l=t.mirrorMinor,c=n[e],u=0;3>u;++u)if(e!==u){var f=a,h=s,d=o,p=l;c&1<0?(d[u]=-1,p[u]=0):(d[u]=0,p[u]=1)}}function s(t,e){var r=new i(t);return r.update(e),r}e.exports=s;var l=t("./lib/text.js"),c=t("./lib/lines.js"),u=t("./lib/background.js"),f=t("./lib/cube.js"),h=t("./lib/ticks.js"),d=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),p=i.prototype;p.update=function(t){function e(e,r,n){if(n in t){var i,a=t[n],o=this[n];(e?Array.isArray(a)&&Array.isArray(a[0]):Array.isArray(a))?this[n]=i=[r(a[0]),r(a[1]),r(a[2])]:this[n]=i=[r(a),r(a),r(a)];for(var s=0;3>s;++s)if(i[s]!==o[s])return!0}return!1}t=t||{};var r,n=e.bind(this,!1,Number),i=e.bind(this,!1,Boolean),a=e.bind(this,!1,String),o=e.bind(this,!0,function(t){if(Array.isArray(t)){if(3===t.length)return[+t[0],+t[1],+t[2],1];if(4===t.length)return[+t[0],+t[1],+t[2],+t[3]]}return[0,0,0,1]}),s=!1,u=!1;if("bounds"in t)for(var f=t.bounds,d=0;2>d;++d)for(var p=0;3>p;++p)f[d][p]!==this.bounds[d][p]&&(u=!0),this.bounds[d][p]=f[d][p];if("ticks"in t){r=t.ticks,s=!0,this.autoTicks=!1;for(var d=0;3>d;++d)this.tickSpacing[d]=0}else n("tickSpacing")&&(this.autoTicks=!0,u=!0);if(this._firstInit&&("ticks"in t||"tickSpacing"in t||(this.autoTicks=!0),u=!0,s=!0,this._firstInit=!1),u&&this.autoTicks&&(r=h.create(this.bounds,this.tickSpacing),s=!0),s){for(var d=0;3>d;++d)r[d].sort(function(t,e){return t.x-e.x});h.equal(r,this.ticks)?s=!1:this.ticks=r}i("tickEnable"),a("tickFont")&&(s=!0),n("tickSize"),n("tickAngle"),n("tickPad"),o("tickColor");var g=a("labels");a("labelFont")&&(g=!0),i("labelEnable"),n("labelSize"),n("labelPad"),o("labelColor"),i("lineEnable"),i("lineMirror"),n("lineWidth"),o("lineColor"),i("lineTickEnable"),i("lineTickMirror"),n("lineTickLength"),n("lineTickWidth"),o("lineTickColor"),i("gridEnable"),n("gridWidth"),o("gridColor"),i("zeroEnable"),o("zeroLineColor"),n("zeroLineWidth"),i("backgroundEnable"),o("backgroundColor"),this._text?this._text&&(g||s)&&this._text.update(this.bounds,this.labels,this.labelFont,this.ticks,this.tickFont):this._text=l(this.gl,this.bounds,this.labels,this.labelFont,this.ticks,this.tickFont),this._lines&&s&&(this._lines.dispose(),this._lines=null),this._lines||(this._lines=c(this.gl,this.bounds,this.ticks))};var g=[new a,new a,new a],v=[0,0,0],m={model:d,view:d,projection:d};p.isOpaque=function(){return!0},p.isTransparent=function(){return!1},p.drawTransparent=function(t){};var y=[0,0,0],b=[0,0,0],x=[0,0,0];p.draw=function(t){t=t||m;for(var e=this.gl,r=t.model||d,i=t.view||d,a=t.projection||d,s=this.bounds,l=f(r,i,a,s),c=l.cubeEdges,u=l.axis,h=i[12],p=i[13],_=i[14],w=i[15],k=this.pixelRatio*(a[3]*h+a[7]*p+a[11]*_+a[15]*w)/e.drawingBufferHeight,A=0;3>A;++A)this.lastCubeProps.cubeEdges[A]=c[A],this.lastCubeProps.axis[A]=u[A];for(var M=g,A=0;3>A;++A)o(g[A],A,this.bounds,c,u);for(var e=this.gl,T=v,A=0;3>A;++A)this.backgroundEnable[A]?T[A]=u[A]:T[A]=0;this._background.draw(r,i,a,s,T,this.backgroundColor),this._lines.bind(r,i,a,this);for(var A=0;3>A;++A){var E=[0,0,0];u[A]>0?E[A]=s[1][A]:E[A]=s[0][A];for(var L=0;2>L;++L){var S=(A+1+L)%3,C=(A+1+(1^L))%3;this.gridEnable[S]&&this._lines.drawGrid(S,C,this.bounds,E,this.gridColor[S],this.gridWidth[S]*this.pixelRatio)}for(var L=0;2>L;++L){var S=(A+1+L)%3,C=(A+1+(1^L))%3;this.zeroEnable[C]&&s[0][C]<=0&&s[1][C]>=0&&this._lines.drawZero(S,C,this.bounds,E,this.zeroLineColor[C],this.zeroLineWidth[C]*this.pixelRatio)}}for(var A=0;3>A;++A){this.lineEnable[A]&&this._lines.drawAxisLine(A,this.bounds,M[A].primalOffset,this.lineColor[A],this.lineWidth[A]*this.pixelRatio),this.lineMirror[A]&&this._lines.drawAxisLine(A,this.bounds,M[A].mirrorOffset,this.lineColor[A],this.lineWidth[A]*this.pixelRatio);for(var z=n(y,M[A].primalMinor),P=n(b,M[A].mirrorMinor),R=this.lineTickLength,L=0;3>L;++L){var O=k/r[5*L];z[L]*=R[L]*O,P[L]*=R[L]*O}this.lineTickEnable[A]&&this._lines.drawAxisTicks(A,M[A].primalOffset,z,this.lineTickColor[A],this.lineTickWidth[A]*this.pixelRatio),this.lineTickMirror[A]&&this._lines.drawAxisTicks(A,M[A].mirrorOffset,P,this.lineTickColor[A],this.lineTickWidth[A]*this.pixelRatio)}this._text.bind(r,i,a,this.pixelRatio);for(var A=0;3>A;++A){for(var I=M[A].primalMinor,N=n(x,M[A].primalOffset),L=0;3>L;++L)this.lineTickEnable[A]&&(N[L]+=k*I[L]*Math.max(this.lineTickLength[L],0)/r[5*L]);if(this.tickEnable[A]){for(var L=0;3>L;++L)N[L]+=k*I[L]*this.tickPad[L]/r[5*L];this._text.drawTicks(A,this.tickSize[A],this.tickAngle[A],N,this.tickColor[A])}if(this.labelEnable[A]){for(var L=0;3>L;++L)N[L]+=k*I[L]*this.labelPad[L]/r[5*L];N[A]+=.5*(s[0][A]+s[1][A]),this._text.drawLabel(A,this.labelSize[A],this.labelAngle[A],N,this.labelColor[A])}}},p.dispose=function(){this._text.dispose(),this._lines.dispose(),this._background.dispose(),this._lines=null,this._text=null,this._background=null,this.gl=null}},{"./lib/background.js":171,"./lib/cube.js":172,"./lib/lines.js":173,"./lib/text.js":175,"./lib/ticks.js":176}],171:[function(t,e,r){"use strict";function n(t,e,r,n){this.gl=t,this.buffer=e,this.vao=r,this.shader=n}function i(t){for(var e=[],r=[],i=0,l=0;3>l;++l)for(var c=(l+1)%3,u=(l+2)%3,f=[0,0,0],h=[0,0,0],d=-1;1>=d;d+=2){r.push(i,i+2,i+1,i+1,i+2,i+3),f[l]=d,h[l]=d;for(var p=-1;1>=p;p+=2){f[c]=p;for(var g=-1;1>=g;g+=2)f[u]=g,e.push(f[0],f[1],f[2],h[0],h[1],h[2]),i+=1}var v=c;c=u,u=v}var m=a(t,new Float32Array(e)),y=a(t,new Uint16Array(r),t.ELEMENT_ARRAY_BUFFER),b=o(t,[{buffer:m,type:t.FLOAT,size:3,offset:0,stride:24},{buffer:m,type:t.FLOAT,size:3,offset:12,stride:24}],y),x=s(t);return x.attributes.position.location=0,x.attributes.normal.location=1,new n(t,m,b,x)}e.exports=i;var a=t("gl-buffer"),o=t("gl-vao"),s=t("./shaders").bg,l=n.prototype;l.draw=function(t,e,r,n,i,a){for(var o=!1,s=0;3>s;++s)o=o||i[s];if(o){var l=this.gl;l.enable(l.POLYGON_OFFSET_FILL),l.polygonOffset(1,2),this.shader.bind(),this.shader.uniforms={model:t,view:e,projection:r,bounds:n,enable:i,colors:a},this.vao.bind(),this.vao.draw(this.gl.TRIANGLES,36),l.disable(l.POLYGON_OFFSET_FILL)}},l.dispose=function(){this.vao.dispose(),this.buffer.dispose(),this.shader.dispose()}},{"./shaders":174,"gl-buffer":118,"gl-vao":226}],172:[function(t,e,r){"use strict";function n(t,e,r){for(var n=0;4>n;++n){t[n]=r[12+n];for(var i=0;3>i;++i)t[n]+=e[i]*r[4*i+n]}}function i(t){for(var e=0;eg;++g){d[2]=a[g][2];for(var b=0;2>b;++b){d[1]=a[b][1];for(var x=0;2>x;++x)d[0]=a[x][0],n(f[l],d,u),l+=1}}for(var _=-1,g=0;8>g;++g){for(var w=f[g][3],k=0;3>k;++k)h[g][k]=f[g][k]/w;0>w&&(0>_?_=g:h[g][2]_){_=0;for(var A=0;3>A;++A){for(var M=(A+2)%3,T=(A+1)%3,E=-1,L=-1,S=0;2>S;++S){var C=S<E||0>L)L>E&&(_|=1<S;++S){var C=S<E&&(_|=1<g;++g)g!==_&&g!==O&&(0>I?I=g:h[I][1]>h[g][1]&&(I=g));for(var N=-1,g=0;3>g;++g){var j=I^1<N&&(N=j);var T=h[j];T[0]g;++g){var j=I^1<