This repository has been archived by the owner on Jan 1, 2025. It is now read-only.
forked from jondot/graphene
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgraphene.min.js
5 lines (5 loc) · 155 KB
/
graphene.min.js
1
2
3
4
5
(function(){var a,b=this,c=b.Backbone;a="undefined"!=typeof exports?exports:b.Backbone={},a.VERSION="0.5.3";var d=b._;d||"undefined"==typeof require||(d=require("underscore")._);var e=b.jQuery||b.Zepto;a.noConflict=function(){return b.Backbone=c,this},a.emulateHTTP=!1,a.emulateJSON=!1,a.Events={bind:function(a,b,c){var d=this._callbacks||(this._callbacks={}),e=d[a]||(d[a]=[]);return e.push([b,c]),this},unbind:function(a,b){var c;if(a){if(c=this._callbacks)if(b){var d=c[a];if(!d)return this;for(var e=0,f=d.length;f>e;e++)if(d[e]&&b===d[e][0]){d[e]=null;break}}else c[a]=[]}else this._callbacks={};return this},trigger:function(a){var b,c,d,e,f,g=2;if(!(c=this._callbacks))return this;for(;g--;)if(d=g?a:"all",b=c[d])for(var h=0,i=b.length;i>h;h++)(e=b[h])?(f=g?Array.prototype.slice.call(arguments,1):arguments,e[0].apply(e[1]||this,f)):(b.splice(h,1),h--,i--);return this}},a.Model=function(a,b){var c;a||(a={}),(c=this.defaults)&&(d.isFunction(c)&&(c=c.call(this)),a=d.extend({},c,a)),this.attributes={},this._escapedAttributes={},this.cid=d.uniqueId("c"),this.set(a,{silent:!0}),this._changed=!1,this._previousAttributes=d.clone(this.attributes),b&&b.collection&&(this.collection=b.collection),this.initialize(a,b)},d.extend(a.Model.prototype,a.Events,{_previousAttributes:null,_changed:!1,idAttribute:"id",initialize:function(){},toJSON:function(){return d.clone(this.attributes)},get:function(a){return this.attributes[a]},escape:function(a){var b;if(b=this._escapedAttributes[a])return b;var c=this.attributes[a];return this._escapedAttributes[a]=w(null==c?"":""+c)},has:function(a){return null!=this.attributes[a]},set:function(a,b){if(b||(b={}),!a)return this;a.attributes&&(a=a.attributes);var c=this.attributes,e=this._escapedAttributes;if(!b.silent&&this.validate&&!this._performValidation(a,b))return!1;this.idAttribute in a&&(this.id=a[this.idAttribute]);var f=this._changing;this._changing=!0;for(var g in a){var h=a[g];d.isEqual(c[g],h)||(c[g]=h,delete e[g],this._changed=!0,b.silent||this.trigger("change:"+g,this,h,b))}return f||b.silent||!this._changed||this.change(b),this._changing=!1,this},unset:function(a,b){if(!(a in this.attributes))return this;b||(b={});var c=(this.attributes[a],{});return c[a]=void 0,b.silent||!this.validate||this._performValidation(c,b)?(delete this.attributes[a],delete this._escapedAttributes[a],a==this.idAttribute&&delete this.id,this._changed=!0,b.silent||(this.trigger("change:"+a,this,void 0,b),this.change(b)),this):!1},clear:function(a){a||(a={});var b,c=this.attributes,d={};for(b in c)d[b]=void 0;if(!a.silent&&this.validate&&!this._performValidation(d,a))return!1;if(this.attributes={},this._escapedAttributes={},this._changed=!0,!a.silent){for(b in c)this.trigger("change:"+b,this,void 0,a);this.change(a)}return this},fetch:function(b){b||(b={});var c=this,d=b.success;return b.success=function(a,e,f){return c.set(c.parse(a,f),b)?void(d&&d(c,a)):!1},b.error=v(b.error,c,b),(this.sync||a.sync).call(this,"read",this,b)},save:function(b,c){if(c||(c={}),b&&!this.set(b,c))return!1;var d=this,e=c.success;c.success=function(a,b,f){return d.set(d.parse(a,f),c)?void(e&&e(d,a,f)):!1},c.error=v(c.error,d,c);var f=this.isNew()?"create":"update";return(this.sync||a.sync).call(this,f,this,c)},destroy:function(b){if(b||(b={}),this.isNew())return this.trigger("destroy",this,this.collection,b);var c=this,d=b.success;return b.success=function(a){c.trigger("destroy",c,c.collection,b),d&&d(c,a)},b.error=v(b.error,c,b),(this.sync||a.sync).call(this,"delete",this,b)},url:function(){var a=t(this.collection)||this.urlRoot||u();return this.isNew()?a:a+("/"==a.charAt(a.length-1)?"":"/")+encodeURIComponent(this.id)},parse:function(a,b){return a},clone:function(){return new this.constructor(this)},isNew:function(){return null==this.id},change:function(a){this.trigger("change",this,a),this._previousAttributes=d.clone(this.attributes),this._changed=!1},hasChanged:function(a){return a?this._previousAttributes[a]!=this.attributes[a]:this._changed},changedAttributes:function(a){a||(a=this.attributes);var b=this._previousAttributes,c=!1;for(var e in a)d.isEqual(b[e],a[e])||(c=c||{},c[e]=a[e]);return c},previous:function(a){return a&&this._previousAttributes?this._previousAttributes[a]:null},previousAttributes:function(){return d.clone(this._previousAttributes)},_performValidation:function(a,b){var c=this.validate(a);return c?(b.error?b.error(this,c,b):this.trigger("error",this,c,b),!1):!0}}),a.Collection=function(a,b){b||(b={}),b.comparator&&(this.comparator=b.comparator),d.bindAll(this,"_onModelEvent","_removeReference"),this._reset(),a&&this.reset(a,{silent:!0}),this.initialize.apply(this,arguments)},d.extend(a.Collection.prototype,a.Events,{model:a.Model,initialize:function(){},toJSON:function(){return this.map(function(a){return a.toJSON()})},add:function(a,b){if(d.isArray(a))for(var c=0,e=a.length;e>c;c++)this._add(a[c],b);else this._add(a,b);return this},remove:function(a,b){if(d.isArray(a))for(var c=0,e=a.length;e>c;c++)this._remove(a[c],b);else this._remove(a,b);return this},get:function(a){return null==a?null:this._byId[null!=a.id?a.id:a]},getByCid:function(a){return a&&this._byCid[a.cid||a]},at:function(a){return this.models[a]},sort:function(a){if(a||(a={}),!this.comparator)throw new Error("Cannot sort a set without a comparator");return this.models=this.sortBy(this.comparator),a.silent||this.trigger("reset",this,a),this},pluck:function(a){return d.map(this.models,function(b){return b.get(a)})},reset:function(a,b){return a||(a=[]),b||(b={}),this.each(this._removeReference),this._reset(),this.add(a,{silent:!0}),b.silent||this.trigger("reset",this,b),this},fetch:function(b){b||(b={});var c=this,d=b.success;return b.success=function(a,e,f){c[b.add?"add":"reset"](c.parse(a,f),b),d&&d(c,a)},b.error=v(b.error,c,b),(this.sync||a.sync).call(this,"read",this,b)},create:function(a,b){var c=this;if(b||(b={}),a=this._prepareModel(a,b),!a)return!1;var d=b.success;return b.success=function(a,e,f){c.add(a,b),d&&d(a,e,f)},a.save(null,b),a},parse:function(a,b){return a},chain:function(){return d(this.models).chain()},_reset:function(a){this.length=0,this.models=[],this._byId={},this._byCid={}},_prepareModel:function(b,c){if(b instanceof a.Model)b.collection||(b.collection=this);else{var d=b;b=new this.model(d,{collection:this}),b.validate&&!b._performValidation(d,c)&&(b=!1)}return b},_add:function(a,b){if(b||(b={}),a=this._prepareModel(a,b),!a)return!1;var c=this.getByCid(a);if(c)throw new Error(["Can't add the same model to a set twice",c.id]);this._byId[a.id]=a,this._byCid[a.cid]=a;var d=null!=b.at?b.at:this.comparator?this.sortedIndex(a,this.comparator):this.length;return this.models.splice(d,0,a),a.bind("all",this._onModelEvent),this.length++,b.silent||a.trigger("add",a,this,b),a},_remove:function(a,b){return b||(b={}),(a=this.getByCid(a)||this.get(a))?(delete this._byId[a.id],delete this._byCid[a.cid],this.models.splice(this.indexOf(a),1),this.length--,b.silent||a.trigger("remove",a,this,b),this._removeReference(a),a):null},_removeReference:function(a){this==a.collection&&delete a.collection,a.unbind("all",this._onModelEvent)},_onModelEvent:function(a,b,c,d){("add"!=a&&"remove"!=a||c==this)&&("destroy"==a&&this._remove(b,d),b&&a==="change:"+b.idAttribute&&(delete this._byId[b.previous(b.idAttribute)],this._byId[b.id]=b),this.trigger.apply(this,arguments))}});var f=["forEach","each","map","reduce","reduceRight","find","detect","filter","select","reject","every","all","some","any","include","contains","invoke","max","min","sortBy","sortedIndex","toArray","size","first","rest","last","without","indexOf","lastIndexOf","isEmpty","groupBy"];d.each(f,function(b){a.Collection.prototype[b]=function(){return d[b].apply(d,[this.models].concat(d.toArray(arguments)))}}),a.Router=function(a){a||(a={}),a.routes&&(this.routes=a.routes),this._bindRoutes(),this.initialize.apply(this,arguments)};var g=/:([\w\d]+)/g,h=/\*([\w\d]+)/g,i=/[-[\]{}()+?.,\\^$|#\s]/g;d.extend(a.Router.prototype,a.Events,{initialize:function(){},route:function(b,c,e){a.history||(a.history=new a.History),d.isRegExp(b)||(b=this._routeToRegExp(b)),a.history.route(b,d.bind(function(a){var d=this._extractParameters(b,a);e.apply(this,d),this.trigger.apply(this,["route:"+c].concat(d))},this))},navigate:function(b,c){a.history.navigate(b,c)},_bindRoutes:function(){if(this.routes){var a=[];for(var b in this.routes)a.unshift([b,this.routes[b]]);for(var c=0,d=a.length;d>c;c++)this.route(a[c][0],a[c][1],this[a[c][1]])}},_routeToRegExp:function(a){return a=a.replace(i,"\\$&").replace(g,"([^/]*)").replace(h,"(.*?)"),new RegExp("^"+a+"$")},_extractParameters:function(a,b){return a.exec(b).slice(1)}}),a.History=function(){this.handlers=[],d.bindAll(this,"checkUrl")};var j=/^#*/,k=/msie [\w.]+/,l=!1;d.extend(a.History.prototype,{interval:50,getFragment:function(a,b){if(null==a)if(this._hasPushState||b){a=window.location.pathname;var c=window.location.search;c&&(a+=c),0==a.indexOf(this.options.root)&&(a=a.substr(this.options.root.length))}else a=window.location.hash;return decodeURIComponent(a.replace(j,""))},start:function(a){if(l)throw new Error("Backbone.history has already been started");this.options=d.extend({},{root:"/"},this.options,a),this._wantsPushState=!!this.options.pushState,this._hasPushState=!!(this.options.pushState&&window.history&&window.history.pushState);var b=this.getFragment(),c=document.documentMode,f=k.exec(navigator.userAgent.toLowerCase())&&(!c||7>=c);f&&(this.iframe=e('<iframe src="javascript:0" tabindex="-1" />').hide().appendTo("body")[0].contentWindow,this.navigate(b)),this._hasPushState?e(window).bind("popstate",this.checkUrl):"onhashchange"in window&&!f?e(window).bind("hashchange",this.checkUrl):setInterval(this.checkUrl,this.interval),this.fragment=b,l=!0;var g=window.location,h=g.pathname==this.options.root;return!this._wantsPushState||this._hasPushState||h?(this._wantsPushState&&this._hasPushState&&h&&g.hash&&(this.fragment=g.hash.replace(j,""),window.history.replaceState({},document.title,g.protocol+"//"+g.host+this.options.root+this.fragment)),this.options.silent?void 0:this.loadUrl()):(this.fragment=this.getFragment(null,!0),window.location.replace(this.options.root+"#"+this.fragment),!0)},route:function(a,b){this.handlers.unshift({route:a,callback:b})},checkUrl:function(a){var b=this.getFragment();return b==this.fragment&&this.iframe&&(b=this.getFragment(this.iframe.location.hash)),b==this.fragment||b==decodeURIComponent(this.fragment)?!1:(this.iframe&&this.navigate(b),void(this.loadUrl()||this.loadUrl(window.location.hash)))},loadUrl:function(a){var b=this.fragment=this.getFragment(a),c=d.any(this.handlers,function(a){return a.route.test(b)?(a.callback(b),!0):void 0});return c},navigate:function(a,b){var c=(a||"").replace(j,"");if(this.fragment!=c&&this.fragment!=decodeURIComponent(c)){if(this._hasPushState){var d=window.location;0!=c.indexOf(this.options.root)&&(c=this.options.root+c),this.fragment=c,window.history.pushState({},document.title,d.protocol+"//"+d.host+c)}else window.location.hash=this.fragment=c,this.iframe&&c!=this.getFragment(this.iframe.location.hash)&&(this.iframe.document.open().close(),this.iframe.location.hash=c);b&&this.loadUrl(a)}}}),a.View=function(a){this.cid=d.uniqueId("view"),this._configure(a||{}),this._ensureElement(),this.delegateEvents(),this.initialize.apply(this,arguments)};var m=function(a){return e(a,this.el)},n=/^(\S+)\s*(.*)$/,o=["model","collection","el","id","attributes","className","tagName"];d.extend(a.View.prototype,a.Events,{tagName:"div",$:m,initialize:function(){},render:function(){return this},remove:function(){return e(this.el).remove(),this},make:function(a,b,c){var d=document.createElement(a);return b&&e(d).attr(b),c&&e(d).html(c),d},delegateEvents:function(a){if(a||(a=this.events)){d.isFunction(a)&&(a=a.call(this)),e(this.el).unbind(".delegateEvents"+this.cid);for(var b in a){var c=this[a[b]];if(!c)throw new Error('Event "'+a[b]+'" does not exist');var f=b.match(n),g=f[1],h=f[2];c=d.bind(c,this),g+=".delegateEvents"+this.cid,""===h?e(this.el).bind(g,c):e(this.el).delegate(h,g,c)}}},_configure:function(a){this.options&&(a=d.extend({},this.options,a));for(var b=0,c=o.length;c>b;b++){var e=o[b];a[e]&&(this[e]=a[e])}this.options=a},_ensureElement:function(){if(this.el)d.isString(this.el)&&(this.el=e(this.el).get(0));else{var a=this.attributes||{};this.id&&(a.id=this.id),this.className&&(a["class"]=this.className),this.el=this.make(this.tagName,a)}}});var p=function(a,b){var c=s(this,a,b);return c.extend=this.extend,c};a.Model.extend=a.Collection.extend=a.Router.extend=a.View.extend=p;var q={create:"POST",update:"PUT","delete":"DELETE",read:"GET"};a.sync=function(b,c,f){var g=q[b],h=d.extend({type:g,dataType:"json"},f);return h.url||(h.url=t(c)||u()),h.data||!c||"create"!=b&&"update"!=b||(h.contentType="application/json",h.data=JSON.stringify(c.toJSON())),a.emulateJSON&&(h.contentType="application/x-www-form-urlencoded",h.data=h.data?{model:h.data}:{}),a.emulateHTTP&&("PUT"===g||"DELETE"===g)&&(a.emulateJSON&&(h.data._method=g),h.type="POST",h.beforeSend=function(a){a.setRequestHeader("X-HTTP-Method-Override",g)}),"GET"===h.type||a.emulateJSON||(h.processData=!1),e.ajax(h)};var r=function(){},s=function(a,b,c){var e;return e=b&&b.hasOwnProperty("constructor")?b.constructor:function(){return a.apply(this,arguments)},d.extend(e,a),r.prototype=a.prototype,e.prototype=new r,b&&d.extend(e.prototype,b),c&&d.extend(e,c),e.prototype.constructor=e,e.__super__=a.prototype,e},t=function(a){return a&&a.url?d.isFunction(a.url)?a.url():a.url:null},u=function(){throw new Error('A "url" property or function must be specified')},v=function(a,b,c){return function(d){a?a(b,d,c):b.trigger("error",b,d,c)}},w=function(a){return a.replace(/&(?!\w+;|#\d+;|#x[\da-f]+;)/gi,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'").replace(/\//g,"/")}}).call(this),function(){function a(a,b){try{for(var c in b)Object.defineProperty(a.prototype,c,{value:b[c],enumerable:!1})}catch(d){a.prototype=b}}function b(a){for(var b=-1,c=a.length,d=[];++b<c;)d.push(a[b]);return d}function c(a){return Array.prototype.slice.call(a)}function d(){}function e(a){return a}function f(){return this}function g(){return!0}function h(a){return"function"==typeof a?a:function(){return a}}function i(a,b,c){return function(){var d=c.apply(b,arguments);return arguments.length?a:d}}function j(a){return null!=a&&!isNaN(a)}function k(a){return a.length}function l(a){return null==a}function m(a){return a.trim().replace(/\s+/g," ")}function n(a){for(var b=1;a*b%1;)b*=10;return b}function o(){}function p(a){function b(){for(var b,d=c,e=-1,f=d.length;++e<f;)(b=d[e].on)&&b.apply(this,arguments);return a}var c=[],e=new d;return b.on=function(b,d){var f,g=e.get(b);return arguments.length<2?g&&g.on:(g&&(g.on=null,c=c.slice(0,f=c.indexOf(g)).concat(c.slice(f+1)),e.remove(b)),d&&c.push(e.set(b,{on:d})),a)},b}function q(a,b){return b-(a?1+Math.floor(Math.log(a+Math.pow(10,1+Math.floor(Math.log(a)/Math.LN10)-b))/Math.LN10):1)}function r(a){return a+""}function s(a){for(var b=a.lastIndexOf("."),c=b>=0?a.substring(b):(b=a.length,""),d=[];b>0;)d.push(a.substring(b-=3,b+3));return d.reverse().join(",")+c}function t(a,b){var c=Math.pow(10,3*Math.abs(8-b));return{scale:b>8?function(a){return a/c}:function(a){return a*c},symbol:a}}function u(a){return function(b){return 0>=b?0:b>=1?1:a(b)}}function v(a){return function(b){return 1-a(1-b)}}function w(a){return function(b){return.5*(.5>b?a(2*b):2-a(2-2*b))}}function x(a){return a}function y(a){return function(b){return Math.pow(b,a)}}function z(a){return 1-Math.cos(a*Math.PI/2)}function A(a){return Math.pow(2,10*(a-1))}function B(a){return 1-Math.sqrt(1-a*a)}function C(a,b){var c;return arguments.length<2&&(b=.45),arguments.length<1?(a=1,c=b/4):c=b/(2*Math.PI)*Math.asin(1/a),function(d){return 1+a*Math.pow(2,10*-d)*Math.sin(2*(d-c)*Math.PI/b)}}function D(a){return a||(a=1.70158),function(b){return b*b*((a+1)*b-a)}}function E(a){return 1/2.75>a?7.5625*a*a:2/2.75>a?7.5625*(a-=1.5/2.75)*a+.75:2.5/2.75>a?7.5625*(a-=2.25/2.75)*a+.9375:7.5625*(a-=2.625/2.75)*a+.984375}function F(){d3.event.stopPropagation(),d3.event.preventDefault()}function G(){for(var a,b=d3.event;a=b.sourceEvent;)b=a;return b}function H(a){for(var b=new o,c=0,d=arguments.length;++c<d;)b[arguments[c]]=p(b);return b.of=function(c,d){return function(e){try{var f=e.sourceEvent=d3.event;e.target=a,d3.event=e,b[e.type].apply(c,d)}finally{d3.event=f}}},b}function I(a){var b=[a.a,a.b],c=[a.c,a.d],d=K(b),e=J(b,c),f=K(L(c,b,-e))||0;b[0]*c[1]<c[0]*b[1]&&(b[0]*=-1,b[1]*=-1,d*=-1,e*=-1),this.rotate=(d?Math.atan2(b[1],b[0]):Math.atan2(-c[0],c[1]))*fe,this.translate=[a.e,a.f],this.scale=[d,f],this.skew=f?Math.atan2(e,f)*fe:0}function J(a,b){return a[0]*b[0]+a[1]*b[1]}function K(a){var b=Math.sqrt(J(a,a));return b&&(a[0]/=b,a[1]/=b),b}function L(a,b,c){return a[0]+=c*b[0],a[1]+=c*b[1],a}function M(a){return"transform"==a?d3.interpolateTransform:d3.interpolate}function N(a,b){return b=b-(a=+a)?1/(b-a):0,function(c){return(c-a)*b}}function O(a,b){return b=b-(a=+a)?1/(b-a):0,function(c){return Math.max(0,Math.min(1,(c-a)*b))}}function P(a,b,c){return new Q(a,b,c)}function Q(a,b,c){this.r=a,this.g=b,this.b=c}function R(a){return 16>a?"0"+Math.max(0,a).toString(16):Math.min(255,a).toString(16)}function S(a,b,c){var d,e,f,g=0,h=0,i=0;if(d=/([a-z]+)\((.*)\)/i.exec(a))switch(e=d[2].split(","),d[1]){case"hsl":return c(parseFloat(e[0]),parseFloat(e[1])/100,parseFloat(e[2])/100);case"rgb":return b(W(e[0]),W(e[1]),W(e[2]))}return(f=ie.get(a))?b(f.r,f.g,f.b):(null!=a&&"#"===a.charAt(0)&&(4===a.length?(g=a.charAt(1),g+=g,h=a.charAt(2),h+=h,i=a.charAt(3),i+=i):7===a.length&&(g=a.substring(1,3),h=a.substring(3,5),i=a.substring(5,7)),g=parseInt(g,16),h=parseInt(h,16),i=parseInt(i,16)),b(g,h,i))}function T(a,b,c){var d,e,f=Math.min(a/=255,b/=255,c/=255),g=Math.max(a,b,c),h=g-f,i=(g+f)/2;return h?(e=.5>i?h/(g+f):h/(2-g-f),d=a==g?(b-c)/h+(c>b?6:0):b==g?(c-a)/h+2:(a-b)/h+4,d*=60):e=d=0,X(d,e,i)}function U(a,b,c){a=V(a),b=V(b),c=V(c);var d=ga((.4124564*a+.3575761*b+.1804375*c)/ke),e=ga((.2126729*a+.7151522*b+.072175*c)/le),f=ga((.0193339*a+.119192*b+.9503041*c)/me);return ba(116*e-16,500*(d-e),200*(e-f))}function V(a){return(a/=255)<=.04045?a/12.92:Math.pow((a+.055)/1.055,2.4)}function W(a){var b=parseFloat(a);return"%"===a.charAt(a.length-1)?Math.round(2.55*b):b}function X(a,b,c){return new Y(a,b,c)}function Y(a,b,c){this.h=a,this.s=b,this.l=c}function Z(a,b,c){function d(a){return a>360?a-=360:0>a&&(a+=360),60>a?f+(g-f)*a/60:180>a?g:240>a?f+(g-f)*(240-a)/60:f}function e(a){return Math.round(255*d(a))}var f,g;return a%=360,0>a&&(a+=360),b=0>b?0:b>1?1:b,c=0>c?0:c>1?1:c,g=.5>=c?c*(1+b):c+b-c*b,f=2*c-g,P(e(a+120),e(a),e(a-120))}function $(a,b,c){return new _(a,b,c)}function _(a,b,c){this.h=a,this.c=b,this.l=c}function aa(a,b,c){return ba(c,Math.cos(a*=Math.PI/180)*b,Math.sin(a)*b)}function ba(a,b,c){return new ca(a,b,c)}function ca(a,b,c){this.l=a,this.a=b,this.b=c}function da(a,b,c){var d=(a+16)/116,e=d+b/500,f=d-c/200;return e=fa(e)*ke,d=fa(d)*le,f=fa(f)*me,P(ha(3.2404542*e-1.5371385*d-.4985314*f),ha(-.969266*e+1.8760108*d+.041556*f),ha(.0556434*e-.2040259*d+1.0572252*f))}function ea(a,b,c){return $(Math.atan2(c,b)/Math.PI*180,Math.sqrt(b*b+c*c),a)}function fa(a){return a>.206893034?a*a*a:(a-4/29)/7.787037}function ga(a){return a>.008856?Math.pow(a,1/3):7.787037*a+4/29}function ha(a){return Math.round(255*(.00304>=a?12.92*a:1.055*Math.pow(a,1/2.4)-.055))}function ia(a){return Td(a,se),a}function ja(a){return function(){return ne(a,this)}}function ka(a){return function(){return oe(a,this)}}function la(a,b){function c(){this.removeAttribute(a)}function d(){this.removeAttributeNS(a.space,a.local)}function e(){this.setAttribute(a,b)}function f(){this.setAttributeNS(a.space,a.local,b)}function g(){var c=b.apply(this,arguments);null==c?this.removeAttribute(a):this.setAttribute(a,c)}function h(){var c=b.apply(this,arguments);null==c?this.removeAttributeNS(a.space,a.local):this.setAttributeNS(a.space,a.local,c)}return a=d3.ns.qualify(a),null==b?a.local?d:c:"function"==typeof b?a.local?h:g:a.local?f:e}function ma(a){return new RegExp("(?:^|\\s+)"+d3.requote(a)+"(?:\\s+|$)","g")}function na(a,b){function c(){for(var c=-1;++c<e;)a[c](this,b)}function d(){for(var c=-1,d=b.apply(this,arguments);++c<e;)a[c](this,d)}a=a.trim().split(/\s+/).map(oa);var e=a.length;return"function"==typeof b?d:c}function oa(a){var b=ma(a);return function(c,d){if(e=c.classList)return d?e.add(a):e.remove(a);var e=c.className,f=null!=e.baseVal,g=f?e.baseVal:e;d?(b.lastIndex=0,b.test(g)||(g=m(g+" "+a),f?e.baseVal=g:c.className=g)):g&&(g=m(g.replace(b," ")),f?e.baseVal=g:c.className=g)}}function pa(a,b,c){function d(){this.style.removeProperty(a)}function e(){this.style.setProperty(a,b,c)}function f(){var d=b.apply(this,arguments);null==d?this.style.removeProperty(a):this.style.setProperty(a,d,c)}return null==b?d:"function"==typeof b?f:e}function qa(a,b){function c(){delete this[a]}function d(){this[a]=b}function e(){var c=b.apply(this,arguments);null==c?delete this[a]:this[a]=c}return null==b?c:"function"==typeof b?e:d}function ra(a){return{__data__:a}}function sa(a){return function(){return re(this,a)}}function ta(a){return arguments.length||(a=d3.ascending),function(b,c){return a(b&&b.__data__,c&&c.__data__)}}function ua(a,b,c){function d(){var b=this[f];b&&(this.removeEventListener(a,b,b.$),delete this[f])}function e(){function e(a){var c=d3.event;d3.event=a,h[0]=g.__data__;try{b.apply(g,h)}finally{d3.event=c}}var g=this,h=arguments;d.call(this),this.addEventListener(a,this[f]=e,e.$=c),e._=b}var f="__on"+a,g=a.indexOf(".");return g>0&&(a=a.substring(0,g)),b?e:d}function va(a,b){for(var c=0,d=a.length;d>c;c++)for(var e,f=a[c],g=0,h=f.length;h>g;g++)(e=f[g])&&b(e,g,c);return a}function wa(a){return Td(a,ue),a}function xa(a,b,c){Td(a,ve);var e=new d,f=d3.dispatch("start","end"),g=De;return a.id=b,a.time=c,a.tween=function(b,c){return arguments.length<2?e.get(b):(null==c?e.remove(b):e.set(b,c),a)},a.ease=function(b){return arguments.length?(g="function"==typeof b?b:d3.ease.apply(d3,arguments),a):g},a.each=function(b,c){return arguments.length<2?ya.call(a,b):(f.on(b,c),a)},d3.timer(function(d){return va(a,function(a,h,i){function j(d){return p.active>b?l():(p.active=b,e.forEach(function(b,c){(c=c.call(a,q,h))&&m.push(c)}),f.start.call(a,q,h),k(d)||d3.timer(k,0,c),1)}function k(c){if(p.active!==b)return l();for(var d=(c-n)/o,e=g(d),i=m.length;i>0;)m[--i].call(a,e);return d>=1?(l(),xe=b,f.end.call(a,q,h),xe=0,1):void 0}function l(){return--p.count||delete a.__transition__,1}var m=[],n=a.delay,o=a.duration,p=(a=a.node).__transition__||(a.__transition__={active:0,count:0}),q=a.__data__;++p.count,d>=n?j(d):d3.timer(j,n,c)})},0,c),a}function ya(a){var b=xe,c=De,d=Be,e=Ce;return xe=this.id,De=this.ease(),va(this,function(b,c,d){Be=b.delay,Ce=b.duration,a.call(b=b.node,b.__data__,c,d)}),xe=b,De=c,Be=d,Ce=e,this}function za(a,b,c){return""!=c&&Ge}function Aa(a,b){return d3.tween(a,M(b))}function Ba(){for(var a,b=Date.now(),c=He;c;)a=b-c.then,a>=c.delay&&(c.flush=c.callback(a)),c=c.next;var d=Ca()-b;d>24?(isFinite(d)&&(clearTimeout(Fe),Fe=setTimeout(Ba,d)),Ee=0):(Ee=1,Ie(Ba))}function Ca(){for(var a=null,b=He,c=1/0;b;)b.flush?b=a?a.next=b.next:He=b.next:(c=Math.min(c,b.then+b.delay),b=(a=b).next);return c}function Da(a,b){var c=a.ownerSVGElement||a;if(c.createSVGPoint){var d=c.createSVGPoint();if(0>Je&&(window.scrollX||window.scrollY)){c=d3.select(document.body).append("svg").style("position","absolute").style("top",0).style("left",0);var e=c[0][0].getScreenCTM();Je=!e.f&&!e.e,c.remove()}return Je?(d.x=b.pageX,d.y=b.pageY):(d.x=b.clientX,d.y=b.clientY),d=d.matrixTransform(a.getScreenCTM().inverse()),[d.x,d.y]}var f=a.getBoundingClientRect();return[b.clientX-f.left-a.clientLeft,b.clientY-f.top-a.clientTop]}function Ea(a){var b=a[0],c=a[a.length-1];return c>b?[b,c]:[c,b]}function Fa(a){return a.rangeExtent?a.rangeExtent():Ea(a.range())}function Ga(a,b){var c,d=0,e=a.length-1,f=a[d],g=a[e];return f>g&&(c=d,d=e,e=c,c=f,f=g,g=c),(b=b(g-f))&&(a[d]=b.floor(f),a[e]=b.ceil(g)),a}function Ha(){return Math}function Ia(a,b,c,d){function e(){var e=Math.min(a.length,b.length)>2?Pa:Oa,i=d?O:N;return g=e(a,b,i,c),h=e(b,a,i,d3.interpolate),f}function f(a){return g(a)}var g,h;return f.invert=function(a){return h(a)},f.domain=function(b){return arguments.length?(a=b.map(Number),e()):a},f.range=function(a){return arguments.length?(b=a,e()):b},f.rangeRound=function(a){return f.range(a).interpolate(d3.interpolateRound)},f.clamp=function(a){return arguments.length?(d=a,e()):d},f.interpolate=function(a){return arguments.length?(c=a,e()):c},f.ticks=function(b){return Ma(a,b)},f.tickFormat=function(b){return Na(a,b)},f.nice=function(){return Ga(a,Ka),e()},f.copy=function(){return Ia(a,b,c,d)},e()}function Ja(a,b){return d3.rebind(a,b,"range","rangeRound","interpolate","clamp")}function Ka(a){return a=Math.pow(10,Math.round(Math.log(a)/Math.LN10)-1),a&&{floor:function(b){return Math.floor(b/a)*a},ceil:function(b){return Math.ceil(b/a)*a}}}function La(a,b){var c=Ea(a),d=c[1]-c[0],e=Math.pow(10,Math.floor(Math.log(d/b)/Math.LN10)),f=b/d*e;return.15>=f?e*=10:.35>=f?e*=5:.75>=f&&(e*=2),c[0]=Math.ceil(c[0]/e)*e,c[1]=Math.floor(c[1]/e)*e+.5*e,c[2]=e,c}function Ma(a,b){return d3.range.apply(d3,La(a,b))}function Na(a,b){return d3.format(",."+Math.max(0,-Math.floor(Math.log(La(a,b)[2])/Math.LN10+.01))+"f")}function Oa(a,b,c,d){var e=c(a[0],a[1]),f=d(b[0],b[1]);return function(a){return f(e(a))}}function Pa(a,b,c,d){var e=[],f=[],g=0,h=Math.min(a.length,b.length)-1;for(a[h]<a[0]&&(a=a.slice().reverse(),b=b.slice().reverse());++g<=h;)e.push(c(a[g-1],a[g])),f.push(d(b[g-1],b[g]));return function(b){var c=d3.bisect(a,b,1,h)-1;return f[c](e[c](b))}}function Qa(a,b){function c(c){return a(b(c))}var d=b.pow;return c.invert=function(b){return d(a.invert(b))},c.domain=function(e){return arguments.length?(b=e[0]<0?Sa:Ra,d=b.pow,a.domain(e.map(b)),c):a.domain().map(d)},c.nice=function(){return a.domain(Ga(a.domain(),Ha)),c},c.ticks=function(){var c=Ea(a.domain()),e=[];if(c.every(isFinite)){var f=Math.floor(c[0]),g=Math.ceil(c[1]),h=d(c[0]),i=d(c[1]);if(b===Sa)for(e.push(d(f));f++<g;)for(var j=9;j>0;j--)e.push(d(f)*j);else{for(;g>f;f++)for(var j=1;10>j;j++)e.push(d(f)*j);e.push(d(f))}for(f=0;e[f]<h;f++);for(g=e.length;e[g-1]>i;g--);e=e.slice(f,g)}return e},c.tickFormat=function(a,e){if(arguments.length<2&&(e=Ke),arguments.length<1)return e;var f,g=Math.max(.1,a/c.ticks().length),h=b===Sa?(f=-1e-12,Math.floor):(f=1e-12,Math.ceil);return function(a){return a/d(h(b(a)+f))<=g?e(a):""}},c.copy=function(){return Qa(a.copy(),b)},Ja(c,a)}function Ra(a){return Math.log(0>a?0:a)/Math.LN10}function Sa(a){return-Math.log(a>0?0:-a)/Math.LN10}function Ta(a,b){function c(b){return a(d(b))}var d=Ua(b),e=Ua(1/b);return c.invert=function(b){return e(a.invert(b))},c.domain=function(b){return arguments.length?(a.domain(b.map(d)),c):a.domain().map(e)},c.ticks=function(a){return Ma(c.domain(),a)},c.tickFormat=function(a){return Na(c.domain(),a)},c.nice=function(){return c.domain(Ga(c.domain(),Ka))},c.exponent=function(a){if(!arguments.length)return b;var f=c.domain();return d=Ua(b=a),e=Ua(1/b),c.domain(f)},c.copy=function(){return Ta(a.copy(),b)},Ja(c,a)}function Ua(a){return function(b){return 0>b?-Math.pow(-b,a):Math.pow(b,a)}}function Va(a,b){function c(b){return g[((f.get(b)||f.set(b,a.push(b)))-1)%g.length]}function e(b,c){return d3.range(a.length).map(function(a){return b+c*a})}var f,g,h;return c.domain=function(e){if(!arguments.length)return a;a=[],f=new d;for(var g,h=-1,i=e.length;++h<i;)f.has(g=e[h])||f.set(g,a.push(g));return c[b.t].apply(c,b.a)},c.range=function(a){return arguments.length?(g=a,h=0,b={t:"range",a:arguments},c):g},c.rangePoints=function(d,f){arguments.length<2&&(f=0);var i=d[0],j=d[1],k=(j-i)/(a.length-1+f);return g=e(a.length<2?(i+j)/2:i+k*f/2,k),h=0,b={t:"rangePoints",a:arguments},c},c.rangeBands=function(d,f,i){arguments.length<2&&(f=0),arguments.length<3&&(i=f);var j=d[1]<d[0],k=d[j-0],l=d[1-j],m=(l-k)/(a.length-f+2*i);return g=e(k+m*i,m),j&&g.reverse(),h=m*(1-f),b={t:"rangeBands",a:arguments},c},c.rangeRoundBands=function(d,f,i){arguments.length<2&&(f=0),arguments.length<3&&(i=f);var j=d[1]<d[0],k=d[j-0],l=d[1-j],m=Math.floor((l-k)/(a.length-f+2*i)),n=l-k-(a.length-f)*m;return g=e(k+Math.round(n/2),m),j&&g.reverse(),h=Math.round(m*(1-f)),b={t:"rangeRoundBands",a:arguments},c},c.rangeBand=function(){return h},c.rangeExtent=function(){return Ea(b.a[0])},c.copy=function(){return Va(a,b)},c.domain(a)}function Wa(a,b){function c(){var c=0,f=(a.length,b.length);for(e=[];++c<f;)e[c-1]=d3.quantile(a,c/f);return d}function d(a){return isNaN(a=+a)?NaN:b[d3.bisect(e,a)]}var e;return d.domain=function(b){return arguments.length?(a=b.filter(function(a){return!isNaN(a)}).sort(d3.ascending),c()):a},d.range=function(a){return arguments.length?(b=a,c()):b},d.quantiles=function(){return e},d.copy=function(){return Wa(a,b)},c()}function Xa(a,b,c){function d(b){return c[Math.max(0,Math.min(g,Math.floor(f*(b-a))))]}function e(){return f=c.length/(b-a),g=c.length-1,d}var f,g;return d.domain=function(c){return arguments.length?(a=+c[0],b=+c[c.length-1],e()):[a,b]},d.range=function(a){return arguments.length?(c=a,e()):c},d.copy=function(){return Xa(a,b,c)},e()}function Ya(a,b){function c(c){return b[d3.bisect(a,c)]}return c.domain=function(b){return arguments.length?(a=b,c):a},c.range=function(a){return arguments.length?(b=a,c):b},c.copy=function(){return Ya(a,b)},c}function Za(a){function b(a){return+a}return b.invert=b,b.domain=b.range=function(c){return arguments.length?(a=c.map(b),b):a},b.ticks=function(b){return Ma(a,b)},b.tickFormat=function(b){return Na(a,b)},b.copy=function(){return Za(a)},b}function $a(a){return a.innerRadius}function _a(a){return a.outerRadius}function ab(a){return a.startAngle}function bb(a){return a.endAngle}function cb(a){function b(b){function g(){k.push("M",f(a(l),j))}for(var i,k=[],l=[],m=-1,n=b.length,o=h(c),p=h(d);++m<n;)e.call(this,i=b[m],m)?l.push([+o.call(this,i,m),+p.call(this,i,m)]):l.length&&(g(),l=[]);return l.length&&g(),k.length?k.join(""):null}var c=db,d=eb,e=g,f=fb,i=f.key,j=.7;return b.x=function(a){return arguments.length?(c=a,b):c},b.y=function(a){return arguments.length?(d=a,b):d},b.defined=function(a){return arguments.length?(e=a,b):e},b.interpolate=function(a){return arguments.length?(i="function"==typeof a?f=a:(f=Re.get(a)||fb).key,b):i},b.tension=function(a){return arguments.length?(j=a,b):j},b}function db(a){return a[0]}function eb(a){return a[1]}function fb(a){return a.join("L")}function gb(a){return fb(a)+"Z"}function hb(a){for(var b=0,c=a.length,d=a[0],e=[d[0],",",d[1]];++b<c;)e.push("V",(d=a[b])[1],"H",d[0]);return e.join("")}function ib(a){for(var b=0,c=a.length,d=a[0],e=[d[0],",",d[1]];++b<c;)e.push("H",(d=a[b])[0],"V",d[1]);return e.join("")}function jb(a,b){return a.length<4?fb(a):a[1]+mb(a.slice(1,a.length-1),nb(a,b))}function kb(a,b){return a.length<3?fb(a):a[0]+mb((a.push(a[0]),a),nb([a[a.length-2]].concat(a,[a[1]]),b))}function lb(a,b,c){return a.length<3?fb(a):a[0]+mb(a,nb(a,b))}function mb(a,b){if(b.length<1||a.length!=b.length&&a.length!=b.length+2)return fb(a);var c=a.length!=b.length,d="",e=a[0],f=a[1],g=b[0],h=g,i=1;if(c&&(d+="Q"+(f[0]-2*g[0]/3)+","+(f[1]-2*g[1]/3)+","+f[0]+","+f[1],e=a[1],i=2),b.length>1){h=b[1],f=a[i],i++,d+="C"+(e[0]+g[0])+","+(e[1]+g[1])+","+(f[0]-h[0])+","+(f[1]-h[1])+","+f[0]+","+f[1];for(var j=2;j<b.length;j++,i++)f=a[i],h=b[j],d+="S"+(f[0]-h[0])+","+(f[1]-h[1])+","+f[0]+","+f[1]}if(c){var k=a[i];d+="Q"+(f[0]+2*h[0]/3)+","+(f[1]+2*h[1]/3)+","+k[0]+","+k[1]}return d}function nb(a,b){for(var c,d=[],e=(1-b)/2,f=a[0],g=a[1],h=1,i=a.length;++h<i;)c=f,f=g,g=a[h],d.push([e*(g[0]-c[0]),e*(g[1]-c[1])]);return d}function ob(a){if(a.length<3)return fb(a);var b=1,c=a.length,d=a[0],e=d[0],f=d[1],g=[e,e,e,(d=a[1])[0]],h=[f,f,f,d[1]],i=[e,",",f];
for(tb(i,g,h);++b<c;)d=a[b],g.shift(),g.push(d[0]),h.shift(),h.push(d[1]),tb(i,g,h);for(b=-1;++b<2;)g.shift(),g.push(d[0]),h.shift(),h.push(d[1]),tb(i,g,h);return i.join("")}function pb(a){if(a.length<4)return fb(a);for(var b,c=[],d=-1,e=a.length,f=[0],g=[0];++d<3;)b=a[d],f.push(b[0]),g.push(b[1]);for(c.push(sb(Ue,f)+","+sb(Ue,g)),--d;++d<e;)b=a[d],f.shift(),f.push(b[0]),g.shift(),g.push(b[1]),tb(c,f,g);return c.join("")}function qb(a){for(var b,c,d=-1,e=a.length,f=e+4,g=[],h=[];++d<4;)c=a[d%e],g.push(c[0]),h.push(c[1]);for(b=[sb(Ue,g),",",sb(Ue,h)],--d;++d<f;)c=a[d%e],g.shift(),g.push(c[0]),h.shift(),h.push(c[1]),tb(b,g,h);return b.join("")}function rb(a,b){var c=a.length-1;if(c)for(var d,e,f=a[0][0],g=a[0][1],h=a[c][0]-f,i=a[c][1]-g,j=-1;++j<=c;)d=a[j],e=j/c,d[0]=b*d[0]+(1-b)*(f+e*h),d[1]=b*d[1]+(1-b)*(g+e*i);return ob(a)}function sb(a,b){return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]+a[3]*b[3]}function tb(a,b,c){a.push("C",sb(Se,b),",",sb(Se,c),",",sb(Te,b),",",sb(Te,c),",",sb(Ue,b),",",sb(Ue,c))}function ub(a,b){return(b[1]-a[1])/(b[0]-a[0])}function vb(a){for(var b=0,c=a.length-1,d=[],e=a[0],f=a[1],g=d[0]=ub(e,f);++b<c;)d[b]=(g+(g=ub(e=f,f=a[b+1])))/2;return d[b]=g,d}function wb(a){for(var b,c,d,e,f=[],g=vb(a),h=-1,i=a.length-1;++h<i;)b=ub(a[h],a[h+1]),Math.abs(b)<1e-6?g[h]=g[h+1]=0:(c=g[h]/b,d=g[h+1]/b,e=c*c+d*d,e>9&&(e=3*b/Math.sqrt(e),g[h]=e*c,g[h+1]=e*d));for(h=-1;++h<=i;)e=(a[Math.min(i,h+1)][0]-a[Math.max(0,h-1)][0])/(6*(1+g[h]*g[h])),f.push([e||0,g[h]*e||0]);return f}function xb(a){return a.length<3?fb(a):a[0]+mb(a,wb(a))}function yb(a){for(var b,c,d,e=-1,f=a.length;++e<f;)b=a[e],c=b[0],d=b[1]+Pe,b[0]=c*Math.cos(d),b[1]=c*Math.sin(d);return a}function zb(a){function b(b){function g(){q.push("M",j(a(s),n),m,l(a(r.reverse()),n),"Z")}for(var k,o,p,q=[],r=[],s=[],t=-1,u=b.length,v=h(c),w=h(e),x=c===d?function(){return o}:h(d),y=e===f?function(){return p}:h(f);++t<u;)i.call(this,k=b[t],t)?(r.push([o=+v.call(this,k,t),p=+w.call(this,k,t)]),s.push([+x.call(this,k,t),+y.call(this,k,t)])):r.length&&(g(),r=[],s=[]);return r.length&&g(),q.length?q.join(""):null}var c=db,d=db,e=0,f=eb,i=g,j=fb,k=j.key,l=j,m="L",n=.7;return b.x=function(a){return arguments.length?(c=d=a,b):d},b.x0=function(a){return arguments.length?(c=a,b):c},b.x1=function(a){return arguments.length?(d=a,b):d},b.y=function(a){return arguments.length?(e=f=a,b):f},b.y0=function(a){return arguments.length?(e=a,b):e},b.y1=function(a){return arguments.length?(f=a,b):f},b.defined=function(a){return arguments.length?(i=a,b):i},b.interpolate=function(a){return arguments.length?(k="function"==typeof a?j=a:(j=Re.get(a)||fb).key,l=j.reverse||j,m=j.closed?"M":"L",b):k},b.tension=function(a){return arguments.length?(n=a,b):n},b}function Ab(a){return a.source}function Bb(a){return a.target}function Cb(a){return a.radius}function Db(a){return[a.x,a.y]}function Eb(a){return function(){var b=a.apply(this,arguments),c=b[0],d=b[1]+Pe;return[c*Math.cos(d),c*Math.sin(d)]}}function Fb(){return 64}function Gb(){return"circle"}function Hb(a){var b=Math.sqrt(a/Math.PI);return"M0,"+b+"A"+b+","+b+" 0 1,1 0,"+-b+"A"+b+","+b+" 0 1,1 0,"+b+"Z"}function Ib(a,b){a.attr("transform",function(a){return"translate("+b(a)+",0)"})}function Jb(a,b){a.attr("transform",function(a){return"translate(0,"+b(a)+")"})}function Kb(a,b,c){if(d=[],c&&b.length>1){for(var d,e,f,g=Ea(a.domain()),h=-1,i=b.length,j=(b[1]-b[0])/++c;++h<i;)for(e=c;--e>0;)(f=+b[h]-e*j)>=g[0]&&d.push(f);for(--h,e=0;++e<c&&(f=+b[h]+e*j)<g[1];)d.push(f)}return d}function Lb(){$e||($e=d3.select("body").append("div").style("visibility","hidden").style("top",0).style("height",0).style("width",0).style("overflow-y","scroll").append("div").style("height","2000px").node().parentNode);var a,b=d3.event;try{$e.scrollTop=1e3,$e.dispatchEvent(b),a=1e3-$e.scrollTop}catch(c){a=b.wheelDelta||5*-b.detail}return a}function Mb(a){for(var b=a.source,c=a.target,d=Ob(b,c),e=[b];b!==d;)b=b.parent,e.push(b);for(var f=e.length;c!==d;)e.splice(f,0,c),c=c.parent;return e}function Nb(a){for(var b=[],c=a.parent;null!=c;)b.push(a),a=c,c=c.parent;return b.push(a),b}function Ob(a,b){if(a===b)return a;for(var c=Nb(a),d=Nb(b),e=c.pop(),f=d.pop(),g=null;e===f;)g=e,e=c.pop(),f=d.pop();return g}function Pb(a){a.fixed|=2}function Qb(a){a!==bf&&(a.fixed&=1)}function Rb(){bf.fixed&=1,af=bf=null}function Sb(){bf.px=d3.event.x,bf.py=d3.event.y,af.resume()}function Tb(a,b,c){var d=0,e=0;if(a.charge=0,!a.leaf)for(var f,g=a.nodes,h=g.length,i=-1;++i<h;)f=g[i],null!=f&&(Tb(f,b,c),a.charge+=f.charge,d+=f.charge*f.cx,e+=f.charge*f.cy);if(a.point){a.leaf||(a.point.x+=Math.random()-.5,a.point.y+=Math.random()-.5);var j=b*c[a.point.index];a.charge+=a.pointCharge=j,d+=j*a.point.x,e+=j*a.point.y}a.cx=d/a.charge,a.cy=e/a.charge}function Ub(a){return 20}function Vb(a){return 1}function Wb(a){return a.x}function Xb(a){return a.y}function Yb(a,b,c){a.y0=b,a.y=c}function Zb(a){return d3.range(a.length)}function $b(a){for(var b=-1,c=a[0].length,d=[];++b<c;)d[b]=0;return d}function _b(a){for(var b,c=1,d=0,e=a[0][1],f=a.length;f>c;++c)(b=a[c][1])>e&&(d=c,e=b);return d}function ac(a){return a.reduce(bc,0)}function bc(a,b){return a+b[1]}function cc(a,b){return dc(a,Math.ceil(Math.log(b.length)/Math.LN2+1))}function dc(a,b){for(var c=-1,d=+a[0],e=(a[1]-d)/b,f=[];++c<=b;)f[c]=e*c+d;return f}function ec(a){return[d3.min(a),d3.max(a)]}function fc(a,b){return d3.rebind(a,b,"sort","children","value"),a.links=jc,a.nodes=function(b){return ff=!0,(a.nodes=a)(b)},a}function gc(a){return a.children}function hc(a){return a.value}function ic(a,b){return b.value-a.value}function jc(a){return d3.merge(a.map(function(a){return(a.children||[]).map(function(b){return{source:a,target:b}})}))}function kc(a,b){return a.value-b.value}function lc(a,b){var c=a._pack_next;a._pack_next=b,b._pack_prev=a,b._pack_next=c,c._pack_prev=b}function mc(a,b){a._pack_next=b,b._pack_prev=a}function nc(a,b){var c=b.x-a.x,d=b.y-a.y,e=a.r+b.r;return e*e-c*c-d*d>.001}function oc(a){function b(a){k=Math.min(a.x-a.r,k),l=Math.max(a.x+a.r,l),m=Math.min(a.y-a.r,m),n=Math.max(a.y+a.r,n)}if((c=a.children)&&(j=c.length)){var c,d,e,f,g,h,i,j,k=1/0,l=-(1/0),m=1/0,n=-(1/0);if(c.forEach(pc),d=c[0],d.x=-d.r,d.y=0,b(d),j>1&&(e=c[1],e.x=e.r,e.y=0,b(e),j>2))for(f=c[2],sc(d,e,f),b(f),lc(d,f),d._pack_prev=f,lc(f,e),e=d._pack_next,g=3;j>g;g++){sc(d,e,f=c[g]);var o=0,p=1,q=1;for(h=e._pack_next;h!==e;h=h._pack_next,p++)if(nc(h,f)){o=1;break}if(1==o)for(i=d._pack_prev;i!==h._pack_prev&&!nc(i,f);i=i._pack_prev,q++);o?(q>p||p==q&&e.r<d.r?mc(d,e=h):mc(d=i,e),g--):(lc(d,f),e=f,b(f))}var r=(k+l)/2,s=(m+n)/2,t=0;for(g=0;j>g;g++)f=c[g],f.x-=r,f.y-=s,t=Math.max(t,f.r+Math.sqrt(f.x*f.x+f.y*f.y));a.r=t,c.forEach(qc)}}function pc(a){a._pack_next=a._pack_prev=a}function qc(a){delete a._pack_next,delete a._pack_prev}function rc(a,b,c,d){var e=a.children;if(a.x=b+=d*a.x,a.y=c+=d*a.y,a.r*=d,e)for(var f=-1,g=e.length;++f<g;)rc(e[f],b,c,d)}function sc(a,b,c){var d=a.r+c.r,e=b.x-a.x,f=b.y-a.y;if(d&&(e||f)){var g=b.r+c.r,h=e*e+f*f;g*=g,d*=d;var i=.5+(d-g)/(2*h),j=Math.sqrt(Math.max(0,2*g*(d+h)-(d-=h)*d-g*g))/(2*h);c.x=a.x+i*e+j*f,c.y=a.y+i*f-j*e}else c.x=a.x+d,c.y=a.y}function tc(a){return 1+d3.max(a,function(a){return a.y})}function uc(a){return a.reduce(function(a,b){return a+b.x},0)/a.length}function vc(a){var b=a.children;return b&&b.length?vc(b[0]):a}function wc(a){var b,c=a.children;return c&&(b=c.length)?wc(c[b-1]):a}function xc(a,b){return a.parent==b.parent?1:2}function yc(a){var b=a.children;return b&&b.length?b[0]:a._tree.thread}function zc(a){var b,c=a.children;return c&&(b=c.length)?c[b-1]:a._tree.thread}function Ac(a,b){var c=a.children;if(c&&(e=c.length))for(var d,e,f=-1;++f<e;)b(d=Ac(c[f],b),a)>0&&(a=d);return a}function Bc(a,b){return a.x-b.x}function Cc(a,b){return b.x-a.x}function Dc(a,b){return a.depth-b.depth}function Ec(a,b){function c(a,d){var e=a.children;if(e&&(g=e.length))for(var f,g,h=null,i=-1;++i<g;)f=e[i],c(f,h),h=f;b(a,d)}c(a,null)}function Fc(a){for(var b,c=0,d=0,e=a.children,f=e.length;--f>=0;)b=e[f]._tree,b.prelim+=c,b.mod+=c,c+=b.shift+(d+=b.change)}function Gc(a,b,c){a=a._tree,b=b._tree;var d=c/(b.number-a.number);a.change+=d,b.change-=d,b.shift+=c,b.prelim+=c,b.mod+=c}function Hc(a,b,c){return a._tree.ancestor.parent==b.parent?a._tree.ancestor:c}function Ic(a){return{x:a.x,y:a.y,dx:a.dx,dy:a.dy}}function Jc(a,b){var c=a.x+b[3],d=a.y+b[0],e=a.dx-b[1]-b[3],f=a.dy-b[0]-b[2];return 0>e&&(c+=e/2,e=0),0>f&&(d+=f/2,f=0),{x:c,y:d,dx:e,dy:f}}function Kc(a,b){function c(a,d){d3.text(a,b,function(a){d(a&&c.parse(a))})}function d(b){return b.map(e).join(a)}function e(a){return g.test(a)?'"'+a.replace(/\"/g,'""')+'"':a}var f=new RegExp("\r\n|["+a+"\r\n]","g"),g=new RegExp('["'+a+"\n]"),h=a.charCodeAt(0);return c.parse=function(a){var b;return c.parseRows(a,function(a,c){if(c){for(var d={},e=-1,f=b.length;++e<f;)d[b[e]]=a[e];return d}return b=a,null})},c.parseRows=function(a,b){function c(){if(f.lastIndex>=a.length)return i;if(e)return e=!1,g;var b=f.lastIndex;if(34===a.charCodeAt(b)){for(var c=b;c++<a.length;)if(34===a.charCodeAt(c)){if(34!==a.charCodeAt(c+1))break;c++}f.lastIndex=c+2;var d=a.charCodeAt(c+1);return 13===d?(e=!0,10===a.charCodeAt(c+2)&&f.lastIndex++):10===d&&(e=!0),a.substring(b+1,c).replace(/""/g,'"')}var j=f.exec(a);return j?(e=j[0].charCodeAt(0)!==h,a.substring(b,j.index)):(f.lastIndex=a.length,a.substring(b))}var d,e,g={},i={},j=[],k=0;for(f.lastIndex=0;(d=c())!==i;){for(var l=[];d!==g&&d!==i;)l.push(d),d=c();(!b||(l=b(l,k++)))&&j.push(l)}return j},c.format=function(a){return a.map(d).join("\n")},c}function Lc(a,b){return function(c){return c&&a.hasOwnProperty(c.type)?a[c.type](c):b}}function Mc(a){return"m0,"+a+"a"+a+","+a+" 0 1,1 0,"+-2*a+"a"+a+","+a+" 0 1,1 0,"+2*a+"z"}function Nc(a,b){hf.hasOwnProperty(a.type)&&hf[a.type](a,b)}function Oc(a,b){Nc(a.geometry,b)}function Pc(a,b){for(var c=a.features,d=0,e=c.length;e>d;d++)Nc(c[d].geometry,b)}function Qc(a,b){for(var c=a.geometries,d=0,e=c.length;e>d;d++)Nc(c[d],b)}function Rc(a,b){for(var c=a.coordinates,d=0,e=c.length;e>d;d++)b.apply(null,c[d])}function Sc(a,b){for(var c=a.coordinates,d=0,e=c.length;e>d;d++)for(var f=c[d],g=0,h=f.length;h>g;g++)b.apply(null,f[g])}function Tc(a,b){for(var c=a.coordinates,d=0,e=c.length;e>d;d++)for(var f=c[d][0],g=0,h=f.length;h>g;g++)b.apply(null,f[g])}function Uc(a,b){b.apply(null,a.coordinates)}function Vc(a,b){for(var c=a.coordinates[0],d=0,e=c.length;e>d;d++)b.apply(null,c[d])}function Wc(a){return a.source}function Xc(a){return a.target}function Yc(){function a(a){var b=Math.sin(a*=n)*o,c=Math.sin(n-a)*o,d=c*f+b*l,h=c*g+b*m,i=c*e+b*k;return[Math.atan2(h,d)/gf,Math.atan2(i,Math.sqrt(d*d+h*h))/gf]}var b,c,d,e,f,g,h,i,j,k,l,m,n,o;return a.distance=function(){return null==n&&(o=1/Math.sin(n=Math.acos(Math.max(-1,Math.min(1,e*k+d*j*Math.cos(h-b)))))),n},a.source=function(h){var i=Math.cos(b=h[0]*gf),j=Math.sin(b);return d=Math.cos(c=h[1]*gf),e=Math.sin(c),f=d*i,g=d*j,n=null,a},a.target=function(b){var c=Math.cos(h=b[0]*gf),d=Math.sin(h);return j=Math.cos(i=b[1]*gf),k=Math.sin(i),l=j*c,m=j*d,n=null,a},a}function Zc(a,b){var c=Yc().source(a).target(b);return c.distance(),c}function $c(a){for(var b=0,c=0;;){if(a(b,c))return[b,c];0===b?(b=c+1,c=0):(b-=1,c+=1)}}function _c(a,b,c,d){var e,f,g,h,i,j,k;return e=d[a],f=e[0],g=e[1],e=d[b],h=e[0],i=e[1],e=d[c],j=e[0],k=e[1],(k-g)*(h-f)-(i-g)*(j-f)>0}function ad(a,b,c){return(c[0]-b[0])*(a[1]-b[1])<(c[1]-b[1])*(a[0]-b[0])}function bd(a,b,c,d){var e=a[0],f=b[0],g=c[0],h=d[0],i=a[1],j=b[1],k=c[1],l=d[1],m=e-g,n=f-e,o=h-g,p=i-k,q=j-i,r=l-k,s=(o*p-r*m)/(r*n-o*q);return[e+s*n,i+s*q]}function cd(a,b){var c={list:a.map(function(a,b){return{index:b,x:a[0],y:a[1]}}).sort(function(a,b){return a.y<b.y?-1:a.y>b.y?1:a.x<b.x?-1:a.x>b.x?1:0}),bottomSite:null},d={list:[],leftEnd:null,rightEnd:null,init:function(){d.leftEnd=d.createHalfEdge(null,"l"),d.rightEnd=d.createHalfEdge(null,"l"),d.leftEnd.r=d.rightEnd,d.rightEnd.l=d.leftEnd,d.list.unshift(d.leftEnd,d.rightEnd)},createHalfEdge:function(a,b){return{edge:a,side:b,vertex:null,l:null,r:null}},insert:function(a,b){b.l=a,b.r=a.r,a.r.l=b,a.r=b},leftBound:function(a){var b=d.leftEnd;do b=b.r;while(b!=d.rightEnd&&e.rightOf(b,a));return b=b.l},del:function(a){a.l.r=a.r,a.r.l=a.l,a.edge=null},right:function(a){return a.r},left:function(a){return a.l},leftRegion:function(a){return null==a.edge?c.bottomSite:a.edge.region[a.side]},rightRegion:function(a){return null==a.edge?c.bottomSite:a.edge.region[lf[a.side]]}},e={bisect:function(a,b){var c={region:{l:a,r:b},ep:{l:null,r:null}},d=b.x-a.x,e=b.y-a.y,f=d>0?d:-d,g=e>0?e:-e;return c.c=a.x*d+a.y*e+.5*(d*d+e*e),f>g?(c.a=1,c.b=e/d,c.c/=d):(c.b=1,c.a=d/e,c.c/=e),c},intersect:function(a,b){var c=a.edge,d=b.edge;if(!c||!d||c.region.r==d.region.r)return null;var e=c.a*d.b-c.b*d.a;if(Math.abs(e)<1e-10)return null;var f,g,h=(c.c*d.b-d.c*c.b)/e,i=(d.c*c.a-c.c*d.a)/e,j=c.region.r,k=d.region.r;j.y<k.y||j.y==k.y&&j.x<k.x?(f=a,g=c):(f=b,g=d);var l=h>=g.region.r.x;return l&&"l"===f.side||!l&&"r"===f.side?null:{x:h,y:i}},rightOf:function(a,b){var c=a.edge,d=c.region.r,e=b.x>d.x;if(e&&"l"===a.side)return 1;if(!e&&"r"===a.side)return 0;if(1===c.a){var f=b.y-d.y,g=b.x-d.x,h=0,i=0;if(!e&&c.b<0||e&&c.b>=0?i=h=f>=c.b*g:(i=b.x+b.y*c.b>c.c,c.b<0&&(i=!i),i||(h=1)),!h){var j=d.x-c.region.l.x;i=c.b*(g*g-f*f)<j*f*(1+2*g/j+c.b*c.b),c.b<0&&(i=!i)}}else{var k=c.c-c.a*b.x,l=b.y-k,m=b.x-d.x,n=k-d.y;i=l*l>m*m+n*n}return"l"===a.side?i:!i},endPoint:function(a,c,d){a.ep[c]=d,a.ep[lf[c]]&&b(a)},distance:function(a,b){var c=a.x-b.x,d=a.y-b.y;return Math.sqrt(c*c+d*d)}},f={list:[],insert:function(a,b,c){a.vertex=b,a.ystar=b.y+c;for(var d=0,e=f.list,g=e.length;g>d;d++){var h=e[d];if(!(a.ystar>h.ystar||a.ystar==h.ystar&&b.x>h.vertex.x))break}e.splice(d,0,a)},del:function(a){for(var b=0,c=f.list,d=c.length;d>b&&c[b]!=a;++b);c.splice(b,1)},empty:function(){return 0===f.list.length},nextEvent:function(a){for(var b=0,c=f.list,d=c.length;d>b;++b)if(c[b]==a)return c[b+1];return null},min:function(){var a=f.list[0];return{x:a.vertex.x,y:a.ystar}},extractMin:function(){return f.list.shift()}};d.init(),c.bottomSite=c.list.shift();for(var g,h,i,j,k,l,m,n,o,p,q,r,s,t=c.list.shift();;)if(f.empty()||(g=f.min()),t&&(f.empty()||t.y<g.y||t.y==g.y&&t.x<g.x))h=d.leftBound(t),i=d.right(h),m=d.rightRegion(h),r=e.bisect(m,t),l=d.createHalfEdge(r,"l"),d.insert(h,l),p=e.intersect(h,l),p&&(f.del(h),f.insert(h,p,e.distance(p,t))),h=l,l=d.createHalfEdge(r,"r"),d.insert(h,l),p=e.intersect(l,i),p&&f.insert(l,p,e.distance(p,t)),t=c.list.shift();else{if(f.empty())break;h=f.extractMin(),j=d.left(h),i=d.right(h),k=d.right(i),m=d.leftRegion(h),n=d.rightRegion(i),q=h.vertex,e.endPoint(h.edge,h.side,q),e.endPoint(i.edge,i.side,q),d.del(h),f.del(i),d.del(i),s="l",m.y>n.y&&(o=m,m=n,n=o,s="r"),r=e.bisect(m,n),l=d.createHalfEdge(r,s),d.insert(j,l),e.endPoint(r,lf[s],q),p=e.intersect(j,l),p&&(f.del(j),f.insert(j,p,e.distance(p,m))),p=e.intersect(l,k),p&&f.insert(l,p,e.distance(p,m))}for(h=d.right(d.leftEnd);h!=d.rightEnd;h=d.right(h))b(h.edge)}function dd(){return{leaf:!0,nodes:[],point:null}}function ed(a,b,c,d,e,f){if(!a(b,c,d,e,f)){var g=.5*(c+e),h=.5*(d+f),i=b.nodes;i[0]&&ed(a,i[0],c,d,g,h),i[1]&&ed(a,i[1],g,d,e,h),i[2]&&ed(a,i[2],c,h,g,f),i[3]&&ed(a,i[3],g,h,e,f)}}function fd(a){return{x:a[0],y:a[1]}}function gd(){this._=new Date(arguments.length>1?Date.UTC.apply(this,arguments):arguments[0])}function hd(a){return a.substring(0,3)}function id(a,b,c,d){for(var e,f,g=0,h=b.length,i=c.length;h>g;){if(d>=i)return-1;if(e=b.charCodeAt(g++),37==e){if(f=Hf[b.charAt(g++)],!f||(d=f(a,c,d))<0)return-1}else if(e!=c.charCodeAt(d++))return-1}return d}function jd(a){return new RegExp("^(?:"+a.map(d3.requote).join("|")+")","i")}function kd(a){for(var b=new d,c=-1,e=a.length;++c<e;)b.set(a[c].toLowerCase(),c);return b}function ld(a,b,c){Bf.lastIndex=0;var d=Bf.exec(b.substring(c));return d?c+=d[0].length:-1}function md(a,b,c){Af.lastIndex=0;var d=Af.exec(b.substring(c));return d?c+=d[0].length:-1}function nd(a,b,c){Ef.lastIndex=0;var d=Ef.exec(b.substring(c));return d?(a.m=Ff.get(d[0].toLowerCase()),c+=d[0].length):-1}function od(a,b,c){Cf.lastIndex=0;var d=Cf.exec(b.substring(c));return d?(a.m=Df.get(d[0].toLowerCase()),c+=d[0].length):-1}function pd(a,b,c){return id(a,Gf.c.toString(),b,c)}function qd(a,b,c){return id(a,Gf.x.toString(),b,c)}function rd(a,b,c){return id(a,Gf.X.toString(),b,c)}function sd(a,b,c){If.lastIndex=0;var d=If.exec(b.substring(c,c+4));return d?(a.y=+d[0],c+=d[0].length):-1}function td(a,b,c){If.lastIndex=0;var d=If.exec(b.substring(c,c+2));return d?(a.y=ud(+d[0]),c+=d[0].length):-1}function ud(a){return a+(a>68?1900:2e3)}function vd(a,b,c){If.lastIndex=0;var d=If.exec(b.substring(c,c+2));return d?(a.m=d[0]-1,c+=d[0].length):-1}function wd(a,b,c){If.lastIndex=0;var d=If.exec(b.substring(c,c+2));return d?(a.d=+d[0],c+=d[0].length):-1}function xd(a,b,c){If.lastIndex=0;var d=If.exec(b.substring(c,c+2));return d?(a.H=+d[0],c+=d[0].length):-1}function yd(a,b,c){If.lastIndex=0;var d=If.exec(b.substring(c,c+2));return d?(a.M=+d[0],c+=d[0].length):-1}function zd(a,b,c){If.lastIndex=0;var d=If.exec(b.substring(c,c+2));return d?(a.S=+d[0],c+=d[0].length):-1}function Ad(a,b,c){If.lastIndex=0;var d=If.exec(b.substring(c,c+3));return d?(a.L=+d[0],c+=d[0].length):-1}function Bd(a,b,c){var d=Jf.get(b.substring(c,c+=2).toLowerCase());return null==d?-1:(a.p=d,c)}function Cd(a){var b=a.getTimezoneOffset(),c=b>0?"-":"+",d=~~(Math.abs(b)/60),e=Math.abs(b)%60;return c+wf(d)+wf(e)}function Dd(a){return a.toISOString()}function Ed(a,b,c){function d(b){var c=a(b),d=f(c,1);return d-b>b-c?c:d}function e(c){return b(c=a(new mf(c-1)),1),c}function f(a,c){return b(a=new mf(+a),c),a}function g(a,d,f){var g=e(a),h=[];if(f>1)for(;d>g;)c(g)%f||h.push(new Date(+g)),b(g,1);else for(;d>g;)h.push(new Date(+g)),b(g,1);return h}function h(a,b,c){try{mf=gd;var d=new gd;return d._=a,g(d,b,c)}finally{mf=Date}}a.floor=a,a.round=d,a.ceil=e,a.offset=f,a.range=g;var i=a.utc=Fd(a);return i.floor=i,i.round=Fd(d),i.ceil=Fd(e),i.offset=Fd(f),i.range=h,a}function Fd(a){return function(b,c){try{mf=gd;var d=new gd;return d._=b,a(d,c)._}finally{mf=Date}}}function Gd(a,b,c){function d(b){return a(b)}return d.invert=function(b){return Id(a.invert(b))},d.domain=function(b){return arguments.length?(a.domain(b),d):a.domain().map(Id)},d.nice=function(a){return d.domain(Ga(d.domain(),function(){return a}))},d.ticks=function(c,e){var f=Hd(d.domain());if("function"!=typeof c){var g=f[1]-f[0],h=g/c,i=d3.bisect(Lf,h);if(i==Lf.length)return b.year(f,c);if(!i)return a.ticks(c).map(Id);Math.log(h/Lf[i-1])<Math.log(Lf[i]/h)&&--i,c=b[i],e=c[1],c=c[0].range}return c(f[0],new Date(+f[1]+1),e)},d.tickFormat=function(){return c},d.copy=function(){return Gd(a.copy(),b,c)},d3.rebind(d,a,"range","rangeRound","interpolate","clamp")}function Hd(a){var b=a[0],c=a[a.length-1];return c>b?[b,c]:[c,b]}function Id(a){return new Date(a)}function Jd(a){return function(b){for(var c=a.length-1,d=a[c];!d[1](b);)d=a[--c];return d[0](b)}}function Kd(a){var b=new Date(a,0,1);return b.setFullYear(a),b}function Ld(a){var b=a.getFullYear(),c=Kd(b),d=Kd(b+1);return b+(a-c)/(d-c)}function Md(a){var b=new Date(Date.UTC(a,0,1));return b.setUTCFullYear(a),b}function Nd(a){var b=a.getUTCFullYear(),c=Md(b),d=Md(b+1);return b+(a-c)/(d-c)}Date.now||(Date.now=function(){return+new Date});try{document.createElement("div").style.setProperty("opacity",0,"")}catch(Od){var Pd=CSSStyleDeclaration.prototype,Qd=Pd.setProperty;Pd.setProperty=function(a,b,c){Qd.call(this,a,b+"",c)}}d3={version:"2.10.0"};var Rd=c;try{Rd(document.documentElement.childNodes)[0].nodeType}catch(Sd){Rd=b}var Td=[].__proto__?function(a,b){a.__proto__=b}:function(a,b){for(var c in b)a[c]=b[c]};d3.map=function(a){var b=new d;for(var c in a)b.set(c,a[c]);return b},a(d,{has:function(a){return Ud+a in this},get:function(a){return this[Ud+a]},set:function(a,b){return this[Ud+a]=b},remove:function(a){return a=Ud+a,a in this&&delete this[a]},keys:function(){var a=[];return this.forEach(function(b){a.push(b)}),a},values:function(){var a=[];return this.forEach(function(b,c){a.push(c)}),a},entries:function(){var a=[];return this.forEach(function(b,c){a.push({key:b,value:c})}),a},forEach:function(a){for(var b in this)b.charCodeAt(0)===Vd&&a.call(this,b.substring(1),this[b])}});var Ud="\x00",Vd=Ud.charCodeAt(0);d3.functor=h,d3.rebind=function(a,b){for(var c,d=1,e=arguments.length;++d<e;)a[c=arguments[d]]=i(a,b,b[c]);return a},d3.ascending=function(a,b){return b>a?-1:a>b?1:a>=b?0:NaN},d3.descending=function(a,b){return a>b?-1:b>a?1:b>=a?0:NaN},d3.mean=function(a,b){var c,d=a.length,e=0,f=-1,g=0;if(1===arguments.length)for(;++f<d;)j(c=a[f])&&(e+=(c-e)/++g);else for(;++f<d;)j(c=b.call(a,a[f],f))&&(e+=(c-e)/++g);return g?e:void 0},d3.median=function(a,b){return arguments.length>1&&(a=a.map(b)),a=a.filter(j),a.length?d3.quantile(a.sort(d3.ascending),.5):void 0},d3.min=function(a,b){var c,d,e=-1,f=a.length;if(1===arguments.length){for(;++e<f&&(null==(c=a[e])||c!=c);)c=void 0;for(;++e<f;)null!=(d=a[e])&&c>d&&(c=d)}else{for(;++e<f&&(null==(c=b.call(a,a[e],e))||c!=c);)c=void 0;for(;++e<f;)null!=(d=b.call(a,a[e],e))&&c>d&&(c=d)}return c},d3.max=function(a,b){var c,d,e=-1,f=a.length;if(1===arguments.length){for(;++e<f&&(null==(c=a[e])||c!=c);)c=void 0;for(;++e<f;)null!=(d=a[e])&&d>c&&(c=d)}else{for(;++e<f&&(null==(c=b.call(a,a[e],e))||c!=c);)c=void 0;for(;++e<f;)null!=(d=b.call(a,a[e],e))&&d>c&&(c=d)}return c},d3.extent=function(a,b){var c,d,e,f=-1,g=a.length;if(1===arguments.length){for(;++f<g&&(null==(c=e=a[f])||c!=c);)c=e=void 0;for(;++f<g;)null!=(d=a[f])&&(c>d&&(c=d),d>e&&(e=d))}else{for(;++f<g&&(null==(c=e=b.call(a,a[f],f))||c!=c);)c=void 0;for(;++f<g;)null!=(d=b.call(a,a[f],f))&&(c>d&&(c=d),d>e&&(e=d))}return[c,e]},d3.random={normal:function(a,b){var c=arguments.length;return 2>c&&(b=1),1>c&&(a=0),function(){var c,d,e;do c=2*Math.random()-1,d=2*Math.random()-1,e=c*c+d*d;while(!e||e>1);return a+b*c*Math.sqrt(-2*Math.log(e)/e)}},logNormal:function(a,b){var c=arguments.length;2>c&&(b=1),1>c&&(a=0);var d=d3.random.normal();return function(){return Math.exp(a+b*d())}},irwinHall:function(a){return function(){for(var b=0,c=0;a>c;c++)b+=Math.random();return b/a}}},d3.sum=function(a,b){var c,d=0,e=a.length,f=-1;if(1===arguments.length)for(;++f<e;)isNaN(c=+a[f])||(d+=c);else for(;++f<e;)isNaN(c=+b.call(a,a[f],f))||(d+=c);return d},d3.quantile=function(a,b){var c=(a.length-1)*b+1,d=Math.floor(c),e=a[d-1],f=c-d;return f?e+f*(a[d]-e):e},d3.transpose=function(a){return d3.zip.apply(d3,a)},d3.zip=function(){if(!(d=arguments.length))return[];for(var a=-1,b=d3.min(arguments,k),c=new Array(b);++a<b;)for(var d,e=-1,f=c[a]=new Array(d);++e<d;)f[e]=arguments[e][a];return c},d3.bisector=function(a){return{left:function(b,c,d,e){for(arguments.length<3&&(d=0),arguments.length<4&&(e=b.length);e>d;){var f=d+e>>>1;a.call(b,b[f],f)<c?d=f+1:e=f}return d},right:function(b,c,d,e){for(arguments.length<3&&(d=0),arguments.length<4&&(e=b.length);e>d;){var f=d+e>>>1;c<a.call(b,b[f],f)?e=f:d=f+1}return d}}};var Wd=d3.bisector(function(a){return a});d3.bisectLeft=Wd.left,d3.bisect=d3.bisectRight=Wd.right,d3.first=function(a,b){var c,d=0,e=a.length,f=a[0];for(1===arguments.length&&(b=d3.ascending);++d<e;)b.call(a,f,c=a[d])>0&&(f=c);return f},d3.last=function(a,b){var c,d=0,e=a.length,f=a[0];for(1===arguments.length&&(b=d3.ascending);++d<e;)b.call(a,f,c=a[d])<=0&&(f=c);return f},d3.nest=function(){function a(b,h){if(h>=g.length)return e?e.call(f,b):c?b.sort(c):b;for(var i,j,k,l=-1,m=b.length,n=g[h++],o=new d,p={};++l<m;)(k=o.get(i=n(j=b[l])))?k.push(j):o.set(i,[j]);return o.forEach(function(b){p[b]=a(o.get(b),h)}),p}function b(a,c){if(c>=g.length)return a;var d,e=[],f=h[c++];for(d in a)e.push({key:d,values:b(a[d],c)});return f&&e.sort(function(a,b){return f(a.key,b.key)}),e}var c,e,f={},g=[],h=[];return f.map=function(b){return a(b,0)},f.entries=function(c){return b(a(c,0),0)},f.key=function(a){return g.push(a),f},f.sortKeys=function(a){return h[g.length-1]=a,f},f.sortValues=function(a){return c=a,f},f.rollup=function(a){return e=a,f},f},d3.keys=function(a){var b=[];for(var c in a)b.push(c);return b},d3.values=function(a){var b=[];for(var c in a)b.push(a[c]);return b},d3.entries=function(a){var b=[];for(var c in a)b.push({key:c,value:a[c]});return b},d3.permute=function(a,b){for(var c=[],d=-1,e=b.length;++d<e;)c[d]=a[b[d]];return c},d3.merge=function(a){return Array.prototype.concat.apply([],a)},d3.split=function(a,b){var c,d=[],e=[],f=-1,g=a.length;for(arguments.length<2&&(b=l);++f<g;)b.call(e,c=a[f],f)?e=[]:(e.length||d.push(e),e.push(c));return d},d3.range=function(a,b,c){if(arguments.length<3&&(c=1,arguments.length<2&&(b=a,a=0)),(b-a)/c===1/0)throw new Error("infinite range");var d,e=[],f=n(Math.abs(c)),g=-1;if(a*=f,b*=f,c*=f,0>c)for(;(d=a+c*++g)>b;)e.push(d/f);else for(;(d=a+c*++g)<b;)e.push(d/f);return e},d3.requote=function(a){return a.replace(Xd,"\\$&")};var Xd=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g;d3.round=function(a,b){return b?Math.round(a*(b=Math.pow(10,b)))/b:Math.round(a)},d3.xhr=function(a,b,c){var d=new XMLHttpRequest;arguments.length<3?(c=b,b=null):b&&d.overrideMimeType&&d.overrideMimeType(b),d.open("GET",a,!0),b&&d.setRequestHeader("Accept",b),d.onreadystatechange=function(){if(4===d.readyState){var a=d.status;c(!a&&d.response||a>=200&&300>a||304===a?d:null)}},d.send(null)},d3.text=function(a,b,c){function d(a){c(a&&a.responseText)}arguments.length<3&&(c=b,b=null),d3.xhr(a,b,d)},d3.json=function(a,b){d3.text(a,"application/json",function(a){b(a?JSON.parse(a):null)})},d3.html=function(a,b){d3.text(a,"text/html",function(a){if(null!=a){var c=document.createRange();c.selectNode(document.body),a=c.createContextualFragment(a)}b(a)})},d3.xml=function(a,b,c){function d(a){c(a&&a.responseXML)}arguments.length<3&&(c=b,b=null),d3.xhr(a,b,d)};var Yd={svg:"http://www.w3.org/2000/svg",xhtml:"http://www.w3.org/1999/xhtml",xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};d3.ns={prefix:Yd,qualify:function(a){var b=a.indexOf(":"),c=a;return b>=0&&(c=a.substring(0,b),a=a.substring(b+1)),Yd.hasOwnProperty(c)?{space:Yd[c],local:a}:a}},d3.dispatch=function(){for(var a=new o,b=-1,c=arguments.length;++b<c;)a[arguments[b]]=p(a);return a},o.prototype.on=function(a,b){var c=a.indexOf("."),d="";return c>0&&(d=a.substring(c+1),a=a.substring(0,c)),arguments.length<2?this[a].on(d):this[a].on(d,b)},d3.format=function(a){var b=Zd.exec(a),c=b[1]||" ",d=b[3]||"",e=b[5],f=+b[6],g=b[7],h=b[8],i=b[9],j=1,k="",l=!1;switch(h&&(h=+h.substring(1)),e&&(c="0",g&&(f-=Math.floor((f-1)/4))),i){case"n":g=!0,i="g";break;case"%":j=100,k="%",i="f";break;case"p":j=100,k="%",i="r";break;case"d":l=!0,h=0;break;case"s":j=-1,i="r"}return"r"==i&&!h&&(i="g"),i=$d.get(i)||r,function(a){if(l&&a%1)return"";var b=0>a&&(a=-a)?"-":d;if(0>j){var m=d3.formatPrefix(a,h);a=m.scale(a),k=m.symbol}else a*=j;if(a=i(a,h),e){var n=a.length+b.length;f>n&&(a=new Array(f-n+1).join(c)+a),g&&(a=s(a)),a=b+a}else{g&&(a=s(a)),a=b+a;var n=a.length;f>n&&(a=new Array(f-n+1).join(c)+a)}return a+k}};var Zd=/(?:([^{])?([<>=^]))?([+\- ])?(#)?(0)?([0-9]+)?(,)?(\.[0-9]+)?([a-zA-Z%])?/,$d=d3.map({g:function(a,b){return a.toPrecision(b)},e:function(a,b){return a.toExponential(b)},f:function(a,b){return a.toFixed(b)},r:function(a,b){return d3.round(a,b=q(a,b)).toFixed(Math.max(0,Math.min(20,b)))}}),_d=["y","z","a","f","p","n","μ","m","","k","M","G","T","P","E","Z","Y"].map(t);d3.formatPrefix=function(a,b){var c=0;return a&&(0>a&&(a*=-1),b&&(a=d3.round(a,q(a,b))),c=1+Math.floor(1e-12+Math.log(a)/Math.LN10),c=Math.max(-24,Math.min(24,3*Math.floor((0>=c?c+1:c-1)/3)))),_d[8+c/3]};var ae=y(2),be=y(3),ce=function(){return x},de=d3.map({linear:ce,poly:y,quad:function(){return ae},cubic:function(){return be},sin:function(){return z},exp:function(){return A},circle:function(){return B},elastic:C,back:D,bounce:function(){return E}}),ee=d3.map({"in":x,out:v,"in-out":w,"out-in":function(a){return w(v(a))}});d3.ease=function(a){var b=a.indexOf("-"),c=b>=0?a.substring(0,b):a,d=b>=0?a.substring(b+1):"in";return c=de.get(c)||ce,d=ee.get(d)||x,u(d(c.apply(null,Array.prototype.slice.call(arguments,1))))},d3.event=null,d3.transform=function(a){var b=document.createElementNS(d3.ns.prefix.svg,"g");return(d3.transform=function(a){b.setAttribute("transform",a);var c=b.transform.baseVal.consolidate();return new I(c?c.matrix:ge)})(a)},I.prototype.toString=function(){return"translate("+this.translate+")rotate("+this.rotate+")skewX("+this.skew+")scale("+this.scale+")"};var fe=180/Math.PI,ge={a:1,b:0,c:0,d:1,e:0,f:0};d3.interpolate=function(a,b){for(var c,d=d3.interpolators.length;--d>=0&&!(c=d3.interpolators[d](a,b)););return c},d3.interpolateNumber=function(a,b){return b-=a,function(c){return a+b*c}},d3.interpolateRound=function(a,b){return b-=a,function(c){return Math.round(a+b*c)}},d3.interpolateString=function(a,b){var c,d,e,f,g,h=0,i=0,j=[],k=[];for(he.lastIndex=0,d=0;c=he.exec(b);++d)c.index&&j.push(b.substring(h,i=c.index)),k.push({i:j.length,x:c[0]}),j.push(null),h=he.lastIndex;for(h<b.length&&j.push(b.substring(h)),d=0,f=k.length;(c=he.exec(a))&&f>d;++d)if(g=k[d],g.x==c[0]){if(g.i)if(null==j[g.i+1])for(j[g.i-1]+=g.x,j.splice(g.i,1),e=d+1;f>e;++e)k[e].i--;else for(j[g.i-1]+=g.x+j[g.i+1],j.splice(g.i,2),e=d+1;f>e;++e)k[e].i-=2;else if(null==j[g.i+1])j[g.i]=g.x;else for(j[g.i]=g.x+j[g.i+1],j.splice(g.i+1,1),e=d+1;f>e;++e)k[e].i--;k.splice(d,1),f--,d--}else g.x=d3.interpolateNumber(parseFloat(c[0]),parseFloat(g.x));for(;f>d;)g=k.pop(),null==j[g.i+1]?j[g.i]=g.x:(j[g.i]=g.x+j[g.i+1],j.splice(g.i+1,1)),f--;return 1===j.length?null==j[0]?k[0].x:function(){return b}:function(a){for(d=0;f>d;++d)j[(g=k[d]).i]=g.x(a);return j.join("")}},d3.interpolateTransform=function(a,b){var c,d=[],e=[],f=d3.transform(a),g=d3.transform(b),h=f.translate,i=g.translate,j=f.rotate,k=g.rotate,l=f.skew,m=g.skew,n=f.scale,o=g.scale;return h[0]!=i[0]||h[1]!=i[1]?(d.push("translate(",null,",",null,")"),e.push({i:1,x:d3.interpolateNumber(h[0],i[0])},{i:3,x:d3.interpolateNumber(h[1],i[1])})):i[0]||i[1]?d.push("translate("+i+")"):d.push(""),j!=k?(j-k>180?k+=360:k-j>180&&(j+=360),e.push({i:d.push(d.pop()+"rotate(",null,")")-2,x:d3.interpolateNumber(j,k)})):k&&d.push(d.pop()+"rotate("+k+")"),l!=m?e.push({i:d.push(d.pop()+"skewX(",null,")")-2,x:d3.interpolateNumber(l,m)}):m&&d.push(d.pop()+"skewX("+m+")"),n[0]!=o[0]||n[1]!=o[1]?(c=d.push(d.pop()+"scale(",null,",",null,")"),e.push({i:c-4,x:d3.interpolateNumber(n[0],o[0])},{i:c-2,x:d3.interpolateNumber(n[1],o[1])})):(1!=o[0]||1!=o[1])&&d.push(d.pop()+"scale("+o+")"),c=e.length,function(a){for(var b,f=-1;++f<c;)d[(b=e[f]).i]=b.x(a);return d.join("")}},d3.interpolateRgb=function(a,b){a=d3.rgb(a),b=d3.rgb(b);var c=a.r,d=a.g,e=a.b,f=b.r-c,g=b.g-d,h=b.b-e;return function(a){return"#"+R(Math.round(c+f*a))+R(Math.round(d+g*a))+R(Math.round(e+h*a))}},d3.interpolateHsl=function(a,b){a=d3.hsl(a),b=d3.hsl(b);var c=a.h,d=a.s,e=a.l,f=b.h-c,g=b.s-d,h=b.l-e;return f>180?f-=360:-180>f&&(f+=360),function(a){return Z(c+f*a,d+g*a,e+h*a)+""}},d3.interpolateLab=function(a,b){a=d3.lab(a),b=d3.lab(b);var c=a.l,d=a.a,e=a.b,f=b.l-c,g=b.a-d,h=b.b-e;return function(a){return da(c+f*a,d+g*a,e+h*a)+""}},d3.interpolateHcl=function(a,b){a=d3.hcl(a),b=d3.hcl(b);var c=a.h,d=a.c,e=a.l,f=b.h-c,g=b.c-d,h=b.l-e;return f>180?f-=360:-180>f&&(f+=360),function(a){return aa(c+f*a,d+g*a,e+h*a)+""}},d3.interpolateArray=function(a,b){var c,d=[],e=[],f=a.length,g=b.length,h=Math.min(a.length,b.length);for(c=0;h>c;++c)d.push(d3.interpolate(a[c],b[c]));for(;f>c;++c)e[c]=a[c];for(;g>c;++c)e[c]=b[c];return function(a){for(c=0;h>c;++c)e[c]=d[c](a);return e}},d3.interpolateObject=function(a,b){var c,d={},e={};for(c in a)c in b?d[c]=M(c)(a[c],b[c]):e[c]=a[c];for(c in b)c in a||(e[c]=b[c]);return function(a){for(c in d)e[c]=d[c](a);return e}};var he=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g;d3.interpolators=[d3.interpolateObject,function(a,b){
return b instanceof Array&&d3.interpolateArray(a,b)},function(a,b){return("string"==typeof a||"string"==typeof b)&&d3.interpolateString(a+"",b+"")},function(a,b){return("string"==typeof b?ie.has(b)||/^(#|rgb\(|hsl\()/.test(b):b instanceof Q||b instanceof Y)&&d3.interpolateRgb(a,b)},function(a,b){return!isNaN(a=+a)&&!isNaN(b=+b)&&d3.interpolateNumber(a,b)}],d3.rgb=function(a,b,c){return 1===arguments.length?a instanceof Q?P(a.r,a.g,a.b):S(""+a,P,Z):P(~~a,~~b,~~c)},Q.prototype.brighter=function(a){a=Math.pow(.7,arguments.length?a:1);var b=this.r,c=this.g,d=this.b,e=30;return b||c||d?(b&&e>b&&(b=e),c&&e>c&&(c=e),d&&e>d&&(d=e),P(Math.min(255,Math.floor(b/a)),Math.min(255,Math.floor(c/a)),Math.min(255,Math.floor(d/a)))):P(e,e,e)},Q.prototype.darker=function(a){return a=Math.pow(.7,arguments.length?a:1),P(Math.floor(a*this.r),Math.floor(a*this.g),Math.floor(a*this.b))},Q.prototype.hsl=function(){return T(this.r,this.g,this.b)},Q.prototype.toString=function(){return"#"+R(this.r)+R(this.g)+R(this.b)};var ie=d3.map({aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"});ie.forEach(function(a,b){ie.set(a,S(b,P,Z))}),d3.hsl=function(a,b,c){return 1===arguments.length?a instanceof Y?X(a.h,a.s,a.l):S(""+a,T,X):X(+a,+b,+c)},Y.prototype.brighter=function(a){return a=Math.pow(.7,arguments.length?a:1),X(this.h,this.s,this.l/a)},Y.prototype.darker=function(a){return a=Math.pow(.7,arguments.length?a:1),X(this.h,this.s,a*this.l)},Y.prototype.rgb=function(){return Z(this.h,this.s,this.l)},Y.prototype.toString=function(){return this.rgb().toString()},d3.hcl=function(a,b,c){return 1===arguments.length?a instanceof _?$(a.h,a.c,a.l):a instanceof ca?ea(a.l,a.a,a.b):ea((a=U((a=d3.rgb(a)).r,a.g,a.b)).l,a.a,a.b):$(+a,+b,+c)},_.prototype.brighter=function(a){return $(this.h,this.c,Math.min(100,this.l+je*(arguments.length?a:1)))},_.prototype.darker=function(a){return $(this.h,this.c,Math.max(0,this.l-je*(arguments.length?a:1)))},_.prototype.rgb=function(){return aa(this.h,this.c,this.l).rgb()},_.prototype.toString=function(){return this.rgb()+""},d3.lab=function(a,b,c){return 1===arguments.length?a instanceof ca?ba(a.l,a.a,a.b):a instanceof _?aa(a.l,a.c,a.h):U((a=d3.rgb(a)).r,a.g,a.b):ba(+a,+b,+c)};var je=18,ke=.95047,le=1,me=1.08883;ca.prototype.brighter=function(a){return ba(Math.min(100,this.l+je*(arguments.length?a:1)),this.a,this.b)},ca.prototype.darker=function(a){return ba(Math.max(0,this.l-je*(arguments.length?a:1)),this.a,this.b)},ca.prototype.rgb=function(){return da(this.l,this.a,this.b)},ca.prototype.toString=function(){return this.rgb()+""};var ne=function(a,b){return b.querySelector(a)},oe=function(a,b){return b.querySelectorAll(a)},pe=document.documentElement,qe=pe.matchesSelector||pe.webkitMatchesSelector||pe.mozMatchesSelector||pe.msMatchesSelector||pe.oMatchesSelector,re=function(a,b){return qe.call(a,b)};"function"==typeof Sizzle&&(ne=function(a,b){return Sizzle(a,b)[0]||null},oe=function(a,b){return Sizzle.uniqueSort(Sizzle(a,b))},re=Sizzle.matchesSelector);var se=[];d3.selection=function(){return te},d3.selection.prototype=se,se.select=function(a){var b,c,d,e,f=[];"function"!=typeof a&&(a=ja(a));for(var g=-1,h=this.length;++g<h;){f.push(b=[]),b.parentNode=(d=this[g]).parentNode;for(var i=-1,j=d.length;++i<j;)(e=d[i])?(b.push(c=a.call(e,e.__data__,i)),c&&"__data__"in e&&(c.__data__=e.__data__)):b.push(null)}return ia(f)},se.selectAll=function(a){var b,c,d=[];"function"!=typeof a&&(a=ka(a));for(var e=-1,f=this.length;++e<f;)for(var g=this[e],h=-1,i=g.length;++h<i;)(c=g[h])&&(d.push(b=Rd(a.call(c,c.__data__,h))),b.parentNode=c);return ia(d)},se.attr=function(a,b){if(arguments.length<2){if("string"==typeof a){var c=this.node();return a=d3.ns.qualify(a),a.local?c.getAttributeNS(a.space,a.local):c.getAttribute(a)}for(b in a)this.each(la(b,a[b]));return this}return this.each(la(a,b))},se.classed=function(a,b){if(arguments.length<2){if("string"==typeof a){var c=this.node(),d=(a=a.trim().split(/^|\s+/g)).length,e=-1;if(b=c.classList){for(;++e<d;)if(!b.contains(a[e]))return!1}else for(b=c.className,null!=b.baseVal&&(b=b.baseVal);++e<d;)if(!ma(a[e]).test(b))return!1;return!0}for(b in a)this.each(na(b,a[b]));return this}return this.each(na(a,b))},se.style=function(a,b,c){var d=arguments.length;if(3>d){if("string"!=typeof a){2>d&&(b="");for(c in a)this.each(pa(c,a[c],b));return this}if(2>d)return window.getComputedStyle(this.node(),null).getPropertyValue(a);c=""}return this.each(pa(a,b,c))},se.property=function(a,b){if(arguments.length<2){if("string"==typeof a)return this.node()[a];for(b in a)this.each(qa(b,a[b]));return this}return this.each(qa(a,b))},se.text=function(a){return arguments.length<1?this.node().textContent:this.each("function"==typeof a?function(){var b=a.apply(this,arguments);this.textContent=null==b?"":b}:null==a?function(){this.textContent=""}:function(){this.textContent=a})},se.html=function(a){return arguments.length<1?this.node().innerHTML:this.each("function"==typeof a?function(){var b=a.apply(this,arguments);this.innerHTML=null==b?"":b}:null==a?function(){this.innerHTML=""}:function(){this.innerHTML=a})},se.append=function(a){function b(){return this.appendChild(document.createElementNS(this.namespaceURI,a))}function c(){return this.appendChild(document.createElementNS(a.space,a.local))}return a=d3.ns.qualify(a),this.select(a.local?c:b)},se.insert=function(a,b){function c(){return this.insertBefore(document.createElementNS(this.namespaceURI,a),ne(b,this))}function d(){return this.insertBefore(document.createElementNS(a.space,a.local),ne(b,this))}return a=d3.ns.qualify(a),this.select(a.local?d:c)},se.remove=function(){return this.each(function(){var a=this.parentNode;a&&a.removeChild(this)})},se.data=function(a,b){function c(a,c){var e,f,g,h=a.length,l=c.length,m=Math.min(h,l),n=Math.max(h,l),o=[],p=[],q=[];if(b){var r,s=new d,t=[],u=c.length;for(e=-1;++e<h;)r=b.call(f=a[e],f.__data__,e),s.has(r)?q[u++]=f:s.set(r,f),t.push(r);for(e=-1;++e<l;)r=b.call(c,g=c[e],e),s.has(r)?(o[e]=f=s.get(r),f.__data__=g,p[e]=q[e]=null):(p[e]=ra(g),o[e]=q[e]=null),s.remove(r);for(e=-1;++e<h;)s.has(t[e])&&(q[e]=a[e])}else{for(e=-1;++e<m;)f=a[e],g=c[e],f?(f.__data__=g,o[e]=f,p[e]=q[e]=null):(p[e]=ra(g),o[e]=q[e]=null);for(;l>e;++e)p[e]=ra(c[e]),o[e]=q[e]=null;for(;n>e;++e)q[e]=a[e],p[e]=o[e]=null}p.update=o,p.parentNode=o.parentNode=q.parentNode=a.parentNode,i.push(p),j.push(o),k.push(q)}var e,f,g=-1,h=this.length;if(!arguments.length){for(a=new Array(h=(e=this[0]).length);++g<h;)(f=e[g])&&(a[g]=f.__data__);return a}var i=wa([]),j=ia([]),k=ia([]);if("function"==typeof a)for(;++g<h;)c(e=this[g],a.call(e,e.parentNode.__data__,g));else for(;++g<h;)c(e=this[g],a);return j.enter=function(){return i},j.exit=function(){return k},j},se.datum=se.map=function(a){return arguments.length<1?this.property("__data__"):this.property("__data__",a)},se.filter=function(a){var b,c,d,e=[];"function"!=typeof a&&(a=sa(a));for(var f=0,g=this.length;g>f;f++){e.push(b=[]),b.parentNode=(c=this[f]).parentNode;for(var h=0,i=c.length;i>h;h++)(d=c[h])&&a.call(d,d.__data__,h)&&b.push(d)}return ia(e)},se.order=function(){for(var a=-1,b=this.length;++a<b;)for(var c,d=this[a],e=d.length-1,f=d[e];--e>=0;)(c=d[e])&&(f&&f!==c.nextSibling&&f.parentNode.insertBefore(c,f),f=c);return this},se.sort=function(a){a=ta.apply(this,arguments);for(var b=-1,c=this.length;++b<c;)this[b].sort(a);return this.order()},se.on=function(a,b,c){var d=arguments.length;if(3>d){if("string"!=typeof a){2>d&&(b=!1);for(c in a)this.each(ua(c,a[c],b));return this}if(2>d)return(d=this.node()["__on"+a])&&d._;c=!1}return this.each(ua(a,b,c))},se.each=function(a){return va(this,function(b,c,d){a.call(b,b.__data__,c,d)})},se.call=function(a){return a.apply(this,(arguments[0]=this,arguments)),this},se.empty=function(){return!this.node()},se.node=function(a){for(var b=0,c=this.length;c>b;b++)for(var d=this[b],e=0,f=d.length;f>e;e++){var g=d[e];if(g)return g}return null},se.transition=function(){for(var a,b,c=[],d=-1,e=this.length;++d<e;){c.push(a=[]);for(var f=this[d],g=-1,h=f.length;++g<h;)a.push((b=f[g])?{node:b,delay:Be,duration:Ce}:null)}return xa(c,xe||++we,Date.now())};var te=ia([[document]]);te[0].parentNode=pe,d3.select=function(a){return"string"==typeof a?te.select(a):ia([[a]])},d3.selectAll=function(a){return"string"==typeof a?te.selectAll(a):ia([Rd(a)])};var ue=[];d3.selection.enter=wa,d3.selection.enter.prototype=ue,ue.append=se.append,ue.insert=se.insert,ue.empty=se.empty,ue.node=se.node,ue.select=function(a){for(var b,c,d,e,f,g=[],h=-1,i=this.length;++h<i;){d=(e=this[h]).update,g.push(b=[]),b.parentNode=e.parentNode;for(var j=-1,k=e.length;++j<k;)(f=e[j])?(b.push(d[j]=c=a.call(e.parentNode,f.__data__,j)),c.__data__=f.__data__):b.push(null)}return ia(g)};var ve=[],we=0,xe=0,ye=0,ze=250,Ae=d3.ease("cubic-in-out"),Be=ye,Ce=ze,De=Ae;ve.call=se.call,d3.transition=function(a){return arguments.length?xe?a.transition():a:te.transition()},d3.transition.prototype=ve,ve.select=function(a){var b,c,d,e=[];"function"!=typeof a&&(a=ja(a));for(var f=-1,g=this.length;++f<g;){e.push(b=[]);for(var h=this[f],i=-1,j=h.length;++i<j;)(d=h[i])&&(c=a.call(d.node,d.node.__data__,i))?("__data__"in d.node&&(c.__data__=d.node.__data__),b.push({node:c,delay:d.delay,duration:d.duration})):b.push(null)}return xa(e,this.id,this.time).ease(this.ease())},ve.selectAll=function(a){var b,c,d,e=[];"function"!=typeof a&&(a=ka(a));for(var f=-1,g=this.length;++f<g;)for(var h=this[f],i=-1,j=h.length;++i<j;)if(d=h[i]){c=a.call(d.node,d.node.__data__,i),e.push(b=[]);for(var k=-1,l=c.length;++k<l;)b.push({node:c[k],delay:d.delay,duration:d.duration})}return xa(e,this.id,this.time).ease(this.ease())},ve.filter=function(a){var b,c,d,e=[];"function"!=typeof a&&(a=sa(a));for(var f=0,g=this.length;g>f;f++){e.push(b=[]);for(var c=this[f],h=0,i=c.length;i>h;h++)(d=c[h])&&a.call(d.node,d.node.__data__,h)&&b.push(d)}return xa(e,this.id,this.time).ease(this.ease())},ve.attr=function(a,b){if(arguments.length<2){for(b in a)this.attrTween(b,Aa(a[b],b));return this}return this.attrTween(a,Aa(b,a))},ve.attrTween=function(a,b){function c(a,c){var d=b.call(this,a,c,this.getAttribute(e));return d===Ge?(this.removeAttribute(e),null):d&&function(a){this.setAttribute(e,d(a))}}function d(a,c){var d=b.call(this,a,c,this.getAttributeNS(e.space,e.local));return d===Ge?(this.removeAttributeNS(e.space,e.local),null):d&&function(a){this.setAttributeNS(e.space,e.local,d(a))}}var e=d3.ns.qualify(a);return this.tween("attr."+a,e.local?d:c)},ve.style=function(a,b,c){var d=arguments.length;if(3>d){if("string"!=typeof a){2>d&&(b="");for(c in a)this.styleTween(c,Aa(a[c],c),b);return this}c=""}return this.styleTween(a,Aa(b,a),c)},ve.styleTween=function(a,b,c){return arguments.length<3&&(c=""),this.tween("style."+a,function(d,e){var f=b.call(this,d,e,window.getComputedStyle(this,null).getPropertyValue(a));return f===Ge?(this.style.removeProperty(a),null):f&&function(b){this.style.setProperty(a,f(b),c)}})},ve.text=function(a){return this.tween("text",function(b,c){this.textContent="function"==typeof a?a.call(this,b,c):a})},ve.remove=function(){return this.each("end.transition",function(){var a;!this.__transition__&&(a=this.parentNode)&&a.removeChild(this)})},ve.delay=function(a){return va(this,"function"==typeof a?function(b,c,d){b.delay=0|a.call(b=b.node,b.__data__,c,d)}:(a|=0,function(b){b.delay=a}))},ve.duration=function(a){return va(this,"function"==typeof a?function(b,c,d){b.duration=Math.max(1,0|a.call(b=b.node,b.__data__,c,d))}:(a=Math.max(1,0|a),function(b){b.duration=a}))},ve.transition=function(){return this.select(f)},d3.tween=function(a,b){function c(c,d,e){var f=a.call(this,c,d);return null==f?""!=e&&Ge:e!=f&&b(e,f)}function d(c,d,e){return e!=a&&b(e,a)}return"function"==typeof a?c:null==a?za:(a+="",d)};var Ee,Fe,Ge={},He=null;d3.timer=function(a,b,c){var d,e=!1,f=He;if(arguments.length<3){if(arguments.length<2)b=0;else if(!isFinite(b))return;c=Date.now()}for(;f;){if(f.callback===a){f.then=c,f.delay=b,e=!0;break}d=f,f=f.next}e||(He={callback:a,then:c,delay:b,next:He}),Ee||(Fe=clearTimeout(Fe),Ee=1,Ie(Ba))},d3.timer.flush=function(){for(var a,b=Date.now(),c=He;c;)a=b-c.then,c.delay||(c.flush=c.callback(a)),c=c.next;Ca()};var Ie=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(a){setTimeout(a,17)};d3.mouse=function(a){return Da(a,G())};var Je=/WebKit/.test(navigator.userAgent)?-1:0;d3.touches=function(a,b){return arguments.length<2&&(b=G().touches),b?Rd(b).map(function(b){var c=Da(a,b);return c.identifier=b.identifier,c}):[]},d3.scale={},d3.scale.linear=function(){return Ia([0,1],[0,1],d3.interpolate,!1)},d3.scale.log=function(){return Qa(d3.scale.linear(),Ra)};var Ke=d3.format(".0e");Ra.pow=function(a){return Math.pow(10,a)},Sa.pow=function(a){return-Math.pow(10,-a)},d3.scale.pow=function(){return Ta(d3.scale.linear(),1)},d3.scale.sqrt=function(){return d3.scale.pow().exponent(.5)},d3.scale.ordinal=function(){return Va([],{t:"range",a:[[]]})},d3.scale.category10=function(){return d3.scale.ordinal().range(Le)},d3.scale.category20=function(){return d3.scale.ordinal().range(Me)},d3.scale.category20b=function(){return d3.scale.ordinal().range(Ne)},d3.scale.category20c=function(){return d3.scale.ordinal().range(Oe)};var Le=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],Me=["#1f77b4","#aec7e8","#ff7f0e","#ffbb78","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5","#8c564b","#c49c94","#e377c2","#f7b6d2","#7f7f7f","#c7c7c7","#bcbd22","#dbdb8d","#17becf","#9edae5"],Ne=["#393b79","#5254a3","#6b6ecf","#9c9ede","#637939","#8ca252","#b5cf6b","#cedb9c","#8c6d31","#bd9e39","#e7ba52","#e7cb94","#843c39","#ad494a","#d6616b","#e7969c","#7b4173","#a55194","#ce6dbd","#de9ed6"],Oe=["#3182bd","#6baed6","#9ecae1","#c6dbef","#e6550d","#fd8d3c","#fdae6b","#fdd0a2","#31a354","#74c476","#a1d99b","#c7e9c0","#756bb1","#9e9ac8","#bcbddc","#dadaeb","#636363","#969696","#bdbdbd","#d9d9d9"];d3.scale.quantile=function(){return Wa([],[])},d3.scale.quantize=function(){return Xa(0,1,[0,1])},d3.scale.threshold=function(){return Ya([.5],[0,1])},d3.scale.identity=function(){return Za([0,1])},d3.svg={},d3.svg.arc=function(){function a(){var a=b.apply(this,arguments),f=c.apply(this,arguments),g=d.apply(this,arguments)+Pe,h=e.apply(this,arguments)+Pe,i=(g>h&&(i=g,g=h,h=i),h-g),j=i<Math.PI?"0":"1",k=Math.cos(g),l=Math.sin(g),m=Math.cos(h),n=Math.sin(h);return i>=Qe?a?"M0,"+f+"A"+f+","+f+" 0 1,1 0,"+-f+"A"+f+","+f+" 0 1,1 0,"+f+"M0,"+a+"A"+a+","+a+" 0 1,0 0,"+-a+"A"+a+","+a+" 0 1,0 0,"+a+"Z":"M0,"+f+"A"+f+","+f+" 0 1,1 0,"+-f+"A"+f+","+f+" 0 1,1 0,"+f+"Z":a?"M"+f*k+","+f*l+"A"+f+","+f+" 0 "+j+",1 "+f*m+","+f*n+"L"+a*m+","+a*n+"A"+a+","+a+" 0 "+j+",0 "+a*k+","+a*l+"Z":"M"+f*k+","+f*l+"A"+f+","+f+" 0 "+j+",1 "+f*m+","+f*n+"L0,0Z"}var b=$a,c=_a,d=ab,e=bb;return a.innerRadius=function(c){return arguments.length?(b=h(c),a):b},a.outerRadius=function(b){return arguments.length?(c=h(b),a):c},a.startAngle=function(b){return arguments.length?(d=h(b),a):d},a.endAngle=function(b){return arguments.length?(e=h(b),a):e},a.centroid=function(){var a=(b.apply(this,arguments)+c.apply(this,arguments))/2,f=(d.apply(this,arguments)+e.apply(this,arguments))/2+Pe;return[Math.cos(f)*a,Math.sin(f)*a]},a};var Pe=-Math.PI/2,Qe=2*Math.PI-1e-6;d3.svg.line=function(){return cb(e)};var Re=d3.map({linear:fb,"linear-closed":gb,"step-before":hb,"step-after":ib,basis:ob,"basis-open":pb,"basis-closed":qb,bundle:rb,cardinal:lb,"cardinal-open":jb,"cardinal-closed":kb,monotone:xb});Re.forEach(function(a,b){b.key=a,b.closed=/-closed$/.test(a)});var Se=[0,2/3,1/3,0],Te=[0,1/3,2/3,0],Ue=[0,1/6,2/3,1/6];d3.svg.line.radial=function(){var a=cb(yb);return a.radius=a.x,delete a.x,a.angle=a.y,delete a.y,a},hb.reverse=ib,ib.reverse=hb,d3.svg.area=function(){return zb(e)},d3.svg.area.radial=function(){var a=zb(yb);return a.radius=a.x,delete a.x,a.innerRadius=a.x0,delete a.x0,a.outerRadius=a.x1,delete a.x1,a.angle=a.y,delete a.y,a.startAngle=a.y0,delete a.y0,a.endAngle=a.y1,delete a.y1,a},d3.svg.chord=function(){function a(a,h){var i=b(this,f,a,h),j=b(this,g,a,h);return"M"+i.p0+d(i.r,i.p1,i.a1-i.a0)+(c(i,j)?e(i.r,i.p1,i.r,i.p0):e(i.r,i.p1,j.r,j.p0)+d(j.r,j.p1,j.a1-j.a0)+e(j.r,j.p1,i.r,i.p0))+"Z"}function b(a,b,c,d){var e=b.call(a,c,d),f=i.call(a,e,d),g=j.call(a,e,d)+Pe,h=k.call(a,e,d)+Pe;return{r:f,a0:g,a1:h,p0:[f*Math.cos(g),f*Math.sin(g)],p1:[f*Math.cos(h),f*Math.sin(h)]}}function c(a,b){return a.a0==b.a0&&a.a1==b.a1}function d(a,b,c){return"A"+a+","+a+" 0 "+ +(c>Math.PI)+",1 "+b}function e(a,b,c,d){return"Q 0,0 "+d}var f=Ab,g=Bb,i=Cb,j=ab,k=bb;return a.radius=function(b){return arguments.length?(i=h(b),a):i},a.source=function(b){return arguments.length?(f=h(b),a):f},a.target=function(b){return arguments.length?(g=h(b),a):g},a.startAngle=function(b){return arguments.length?(j=h(b),a):j},a.endAngle=function(b){return arguments.length?(k=h(b),a):k},a},d3.svg.diagonal=function(){function a(a,e){var f=b.call(this,a,e),g=c.call(this,a,e),h=(f.y+g.y)/2,i=[f,{x:f.x,y:h},{x:g.x,y:h},g];return i=i.map(d),"M"+i[0]+"C"+i[1]+" "+i[2]+" "+i[3]}var b=Ab,c=Bb,d=Db;return a.source=function(c){return arguments.length?(b=h(c),a):b},a.target=function(b){return arguments.length?(c=h(b),a):c},a.projection=function(b){return arguments.length?(d=b,a):d},a},d3.svg.diagonal.radial=function(){var a=d3.svg.diagonal(),b=Db,c=a.projection;return a.projection=function(a){return arguments.length?c(Eb(b=a)):b},a},d3.svg.mouse=d3.mouse,d3.svg.touches=d3.touches,d3.svg.symbol=function(){function a(a,d){return(Ve.get(b.call(this,a,d))||Hb)(c.call(this,a,d))}var b=Gb,c=Fb;return a.type=function(c){return arguments.length?(b=h(c),a):b},a.size=function(b){return arguments.length?(c=h(b),a):c},a};var Ve=d3.map({circle:Hb,cross:function(a){var b=Math.sqrt(a/5)/2;return"M"+-3*b+","+-b+"H"+-b+"V"+-3*b+"H"+b+"V"+-b+"H"+3*b+"V"+b+"H"+b+"V"+3*b+"H"+-b+"V"+b+"H"+-3*b+"Z"},diamond:function(a){var b=Math.sqrt(a/(2*Xe)),c=b*Xe;return"M0,"+-b+"L"+c+",0 0,"+b+" "+-c+",0Z"},square:function(a){var b=Math.sqrt(a)/2;return"M"+-b+","+-b+"L"+b+","+-b+" "+b+","+b+" "+-b+","+b+"Z"},"triangle-down":function(a){var b=Math.sqrt(a/We),c=b*We/2;return"M0,"+c+"L"+b+","+-c+" "+-b+","+-c+"Z"},"triangle-up":function(a){var b=Math.sqrt(a/We),c=b*We/2;return"M0,"+-c+"L"+b+","+c+" "+-b+","+c+"Z"}});d3.svg.symbolTypes=Ve.keys();var We=Math.sqrt(3),Xe=Math.tan(30*Math.PI/180);d3.svg.axis=function(){function a(a){a.each(function(){var a,l=d3.select(this),m=null==j?c.ticks?c.ticks.apply(c,i):c.domain():j,n=null==b?c.tickFormat?c.tickFormat.apply(c,i):String:b,o=Kb(c,m,k),p=l.selectAll(".minor").data(o,String),q=p.enter().insert("line","g").attr("class","tick minor").style("opacity",1e-6),r=d3.transition(p.exit()).style("opacity",1e-6).remove(),s=d3.transition(p).style("opacity",1),t=l.selectAll("g").data(m,String),u=t.enter().insert("g","path").style("opacity",1e-6),v=d3.transition(t.exit()).style("opacity",1e-6).remove(),w=d3.transition(t).style("opacity",1),x=Fa(c),y=l.selectAll(".domain").data([0]),z=(y.enter().append("path").attr("class","domain"),d3.transition(y)),A=c.copy(),B=this.__chart__||A;this.__chart__=A,u.append("line").attr("class","tick"),u.append("text");var C=u.select("line"),D=w.select("line"),E=t.select("text").text(n),F=u.select("text"),G=w.select("text");switch(d){case"bottom":a=Ib,q.attr("y2",f),s.attr("x2",0).attr("y2",f),C.attr("y2",e),F.attr("y",Math.max(e,0)+h),D.attr("x2",0).attr("y2",e),G.attr("x",0).attr("y",Math.max(e,0)+h),E.attr("dy",".71em").attr("text-anchor","middle"),z.attr("d","M"+x[0]+","+g+"V0H"+x[1]+"V"+g);break;case"top":a=Ib,q.attr("y2",-f),s.attr("x2",0).attr("y2",-f),C.attr("y2",-e),F.attr("y",-(Math.max(e,0)+h)),D.attr("x2",0).attr("y2",-e),G.attr("x",0).attr("y",-(Math.max(e,0)+h)),E.attr("dy","0em").attr("text-anchor","middle"),z.attr("d","M"+x[0]+","+-g+"V0H"+x[1]+"V"+-g);break;case"left":a=Jb,q.attr("x2",-f),s.attr("x2",-f).attr("y2",0),C.attr("x2",-e),F.attr("x",-(Math.max(e,0)+h)),D.attr("x2",-e).attr("y2",0),G.attr("x",-(Math.max(e,0)+h)).attr("y",0),E.attr("dy",".32em").attr("text-anchor","end"),z.attr("d","M"+-g+","+x[0]+"H0V"+x[1]+"H"+-g);break;case"right":a=Jb,q.attr("x2",f),s.attr("x2",f).attr("y2",0),C.attr("x2",e),F.attr("x",Math.max(e,0)+h),D.attr("x2",e).attr("y2",0),G.attr("x",Math.max(e,0)+h).attr("y",0),E.attr("dy",".32em").attr("text-anchor","start"),z.attr("d","M"+g+","+x[0]+"H0V"+x[1]+"H"+g)}if(c.ticks)u.call(a,B),w.call(a,A),v.call(a,A),q.call(a,B),s.call(a,A),r.call(a,A);else{var H=A.rangeBand()/2,I=function(a){return A(a)+H};u.call(a,I),w.call(a,I)}})}var b,c=d3.scale.linear(),d="bottom",e=6,f=6,g=6,h=3,i=[10],j=null,k=0;return a.scale=function(b){return arguments.length?(c=b,a):c},a.orient=function(b){return arguments.length?(d=b,a):d},a.ticks=function(){return arguments.length?(i=arguments,a):i},a.tickValues=function(b){return arguments.length?(j=b,a):j},a.tickFormat=function(c){return arguments.length?(b=c,a):b},a.tickSize=function(b,c,d){if(!arguments.length)return e;var h=arguments.length-1;return e=+b,f=h>1?+c:e,g=h>0?+arguments[h]:e,a},a.tickPadding=function(b){return arguments.length?(h=+b,a):h},a.tickSubdivide=function(b){return arguments.length?(k=+b,a):k},a},d3.svg.brush=function(){function a(f){f.each(function(){var f,g=d3.select(this),k=g.selectAll(".background").data([0]),l=g.selectAll(".extent").data([0]),m=g.selectAll(".resize").data(j,String);g.style("pointer-events","all").on("mousedown.brush",e).on("touchstart.brush",e),k.enter().append("rect").attr("class","background").style("visibility","hidden").style("cursor","crosshair"),l.enter().append("rect").attr("class","extent").style("cursor","move"),m.enter().append("g").attr("class",function(a){return"resize "+a}).style("cursor",function(a){return Ye[a]}).append("rect").attr("x",function(a){return/[ew]$/.test(a)?-3:null}).attr("y",function(a){return/^[ns]/.test(a)?-3:null}).attr("width",6).attr("height",6).style("visibility","hidden"),m.style("display",a.empty()?"none":null),m.exit().remove(),h&&(f=Fa(h),k.attr("x",f[0]).attr("width",f[1]-f[0]),c(g)),i&&(f=Fa(i),k.attr("y",f[0]).attr("height",f[1]-f[0]),d(g)),b(g)})}function b(a){a.selectAll(".resize").attr("transform",function(a){return"translate("+k[+/e$/.test(a)][0]+","+k[+/^s/.test(a)][1]+")"})}function c(a){a.select(".extent").attr("x",k[0][0]),a.selectAll(".extent,.n>rect,.s>rect").attr("width",k[1][0]-k[0][0])}function d(a){a.select(".extent").attr("y",k[0][1]),a.selectAll(".extent,.e>rect,.w>rect").attr("height",k[1][1]-k[0][1])}function e(){function e(){var a=d3.event.changedTouches;return a?d3.touches(r,a)[0]:d3.mouse(r)}function j(){32==d3.event.keyCode&&(y||(p=null,z[0]-=k[1][0],z[1]-=k[1][1],y=2),F())}function l(){32==d3.event.keyCode&&2==y&&(z[0]+=k[1][0],z[1]+=k[1][1],y=0,F())}function m(){var a=e(),f=!1;q&&(a[0]+=q[0],a[1]+=q[1]),y||(d3.event.altKey?(p||(p=[(k[0][0]+k[1][0])/2,(k[0][1]+k[1][1])/2]),z[0]=k[+(a[0]<p[0])][0],z[1]=k[+(a[1]<p[1])][1]):p=null),w&&n(a,h,0)&&(c(u),f=!0),x&&n(a,i,1)&&(d(u),f=!0),f&&(b(u),t({type:"brush",mode:y?"move":"resize"}))}function n(a,b,c){var d,e,g=Fa(b),h=g[0],i=g[1],j=z[c],l=k[1][c]-k[0][c];return y&&(h-=j,i-=l+j),d=Math.max(h,Math.min(i,a[c])),y?e=(d+=j)+l:(p&&(j=Math.max(h,Math.min(i,2*p[c]-d))),d>j?(e=d,d=j):e=j),k[0][c]!==d||k[1][c]!==e?(f=null,k[0][c]=d,k[1][c]=e,!0):void 0}function o(){m(),u.style("pointer-events","all").selectAll(".resize").style("display",a.empty()?"none":null),d3.select("body").style("cursor",null),A.on("mousemove.brush",null).on("mouseup.brush",null).on("touchmove.brush",null).on("touchend.brush",null).on("keydown.brush",null).on("keyup.brush",null),t({type:"brushend"}),F()}var p,q,r=this,s=d3.select(d3.event.target),t=g.of(r,arguments),u=d3.select(r),v=s.datum(),w=!/^(n|s)$/.test(v)&&h,x=!/^(e|w)$/.test(v)&&i,y=s.classed("extent"),z=e(),A=d3.select(window).on("mousemove.brush",m).on("mouseup.brush",o).on("touchmove.brush",m).on("touchend.brush",o).on("keydown.brush",j).on("keyup.brush",l);if(y)z[0]=k[0][0]-z[0],z[1]=k[0][1]-z[1];else if(v){var B=+/w$/.test(v),C=+/^n/.test(v);q=[k[1-B][0]-z[0],k[1-C][1]-z[1]],z[0]=k[B][0],z[1]=k[C][1]}else d3.event.altKey&&(p=z.slice());u.style("pointer-events","none").selectAll(".resize").style("display",null),d3.select("body").style("cursor",s.style("cursor")),t({type:"brushstart"}),m(),F()}var f,g=H(a,"brushstart","brush","brushend"),h=null,i=null,j=Ze[0],k=[[0,0],[0,0]];return a.x=function(b){return arguments.length?(h=b,j=Ze[!h<<1|!i],a):h},a.y=function(b){return arguments.length?(i=b,j=Ze[!h<<1|!i],a):i},a.extent=function(b){var c,d,e,g,j;return arguments.length?(f=[[0,0],[0,0]],h&&(c=b[0],d=b[1],i&&(c=c[0],d=d[0]),f[0][0]=c,f[1][0]=d,h.invert&&(c=h(c),d=h(d)),c>d&&(j=c,c=d,d=j),k[0][0]=0|c,k[1][0]=0|d),i&&(e=b[0],g=b[1],h&&(e=e[1],g=g[1]),f[0][1]=e,f[1][1]=g,i.invert&&(e=i(e),g=i(g)),e>g&&(j=e,e=g,g=j),k[0][1]=0|e,k[1][1]=0|g),a):(b=f||k,h&&(c=b[0][0],d=b[1][0],f||(c=k[0][0],d=k[1][0],h.invert&&(c=h.invert(c),d=h.invert(d)),c>d&&(j=c,c=d,d=j))),i&&(e=b[0][1],g=b[1][1],f||(e=k[0][1],g=k[1][1],i.invert&&(e=i.invert(e),g=i.invert(g)),e>g&&(j=e,e=g,g=j))),h&&i?[[c,e],[d,g]]:h?[c,d]:i&&[e,g])},a.clear=function(){return f=null,k[0][0]=k[0][1]=k[1][0]=k[1][1]=0,a},a.empty=function(){return h&&k[0][0]===k[1][0]||i&&k[0][1]===k[1][1]},d3.rebind(a,g,"on")};var Ye={n:"ns-resize",e:"ew-resize",s:"ns-resize",w:"ew-resize",nw:"nwse-resize",ne:"nesw-resize",se:"nwse-resize",sw:"nesw-resize"},Ze=[["n","e","s","w","nw","ne","se","sw"],["e","w"],["n","s"],[]];d3.behavior={},d3.behavior.drag=function(){function a(){this.on("mousedown.drag",b).on("touchstart.drag",b)}function b(){function a(){var a=h.parentNode,b=d3.event.changedTouches;return b?d3.touches(a,b)[0]:d3.mouse(a)}function b(){if(!h.parentNode)return e();var b=a(),c=b[0]-k[0],d=b[1]-k[1];l|=c|d,k=b,F(),i({type:"drag",x:b[0]+g[0],y:b[1]+g[1],dx:c,dy:d})}function e(){i({type:"dragend"}),l&&(F(),d3.event.target===j&&m.on("click.drag",f,!0)),m.on("mousemove.drag",null).on("touchmove.drag",null).on("mouseup.drag",null).on("touchend.drag",null)}function f(){F(),m.on("click.drag",null)}var g,h=this,i=c.of(h,arguments),j=d3.event.target,k=a(),l=0,m=d3.select(window).on("mousemove.drag",b).on("touchmove.drag",b).on("mouseup.drag",e,!0).on("touchend.drag",e,!0);d?(g=d.apply(h,arguments),g=[g.x-k[0],g.y-k[1]]):g=[0,0],F(),i({type:"dragstart"})}var c=H(a,"drag","dragstart","dragend"),d=null;return a.origin=function(b){return arguments.length?(d=b,a):d},d3.rebind(a,c,"on")},d3.behavior.zoom=function(){function a(){this.on("mousedown.zoom",g).on("mousewheel.zoom",h).on("mousemove.zoom",i).on("DOMMouseScroll.zoom",h).on("dblclick.zoom",j).on("touchstart.zoom",k).on("touchmove.zoom",l).on("touchend.zoom",k)}function b(a){return[(a[0]-t[0])/u,(a[1]-t[1])/u]}function c(a){return[a[0]*u+t[0],a[1]*u+t[1]]}function d(a){u=Math.max(v[0],Math.min(v[1],a))}function e(a,b){b=c(b),t[0]+=a[0]-b[0],t[1]+=a[1]-b[1]}function f(a){p&&p.domain(o.range().map(function(a){return(a-t[0])/u}).map(o.invert)),r&&r.domain(q.range().map(function(a){return(a-t[1])/u}).map(q.invert)),d3.event.preventDefault(),a({type:"zoom",scale:u,translate:t})}function g(){function a(){j=1,e(d3.mouse(g),l),f(h)}function c(){j&&F(),k.on("mousemove.zoom",null).on("mouseup.zoom",null),j&&d3.event.target===i&&k.on("click.zoom",d,!0)}function d(){F(),k.on("click.zoom",null)}var g=this,h=w.of(g,arguments),i=d3.event.target,j=0,k=d3.select(window).on("mousemove.zoom",a).on("mouseup.zoom",c),l=b(d3.mouse(g));window.focus(),F()}function h(){m||(m=b(d3.mouse(this))),d(Math.pow(2,.002*Lb())*u),e(d3.mouse(this),m),f(w.of(this,arguments))}function i(){m=null}function j(){var a=d3.mouse(this),c=b(a);d(d3.event.shiftKey?u/2:2*u),e(a,c),f(w.of(this,arguments))}function k(){var a=d3.touches(this),c=Date.now();if(n=u,m={},a.forEach(function(a){m[a.identifier]=b(a)}),F(),1===a.length){if(500>c-s){var g=a[0],h=b(a[0]);d(2*u),e(g,h),f(w.of(this,arguments))}s=c}}function l(){var a=d3.touches(this),b=a[0],c=m[b.identifier];if(g=a[1]){var g,h=m[g.identifier];b=[(b[0]+g[0])/2,(b[1]+g[1])/2],c=[(c[0]+h[0])/2,(c[1]+h[1])/2],d(d3.event.scale*n)}e(b,c),s=null,f(w.of(this,arguments))}var m,n,o,p,q,r,s,t=[0,0],u=1,v=_e,w=H(a,"zoom");return a.translate=function(b){return arguments.length?(t=b.map(Number),a):t},a.scale=function(b){return arguments.length?(u=+b,a):u},a.scaleExtent=function(b){return arguments.length?(v=null==b?_e:b.map(Number),a):v},a.x=function(b){return arguments.length?(p=b,o=b.copy(),a):p},a.y=function(b){return arguments.length?(r=b,q=b.copy(),a):r},d3.rebind(a,w,"on")};var $e,_e=[0,1/0];d3.layout={},d3.layout.bundle=function(){return function(a){for(var b=[],c=-1,d=a.length;++c<d;)b.push(Mb(a[c]));return b}},d3.layout.chord=function(){function a(){var a,j,l,m,n,o={},p=[],q=d3.range(f),r=[];for(c=[],d=[],a=0,m=-1;++m<f;){for(j=0,n=-1;++n<f;)j+=e[m][n];p.push(j),r.push(d3.range(f)),a+=j}for(g&&q.sort(function(a,b){return g(p[a],p[b])}),h&&r.forEach(function(a,b){a.sort(function(a,c){return h(e[b][a],e[b][c])})}),a=(2*Math.PI-k*f)/a,
j=0,m=-1;++m<f;){for(l=j,n=-1;++n<f;){var s=q[m],t=r[s][n],u=e[s][t],v=j,w=j+=u*a;o[s+"-"+t]={index:s,subindex:t,startAngle:v,endAngle:w,value:u}}d[s]={index:s,startAngle:l,endAngle:j,value:(j-l)/a},j+=k}for(m=-1;++m<f;)for(n=m-1;++n<f;){var x=o[m+"-"+n],y=o[n+"-"+m];(x.value||y.value)&&c.push(x.value<y.value?{source:y,target:x}:{source:x,target:y})}i&&b()}function b(){c.sort(function(a,b){return i((a.source.value+a.target.value)/2,(b.source.value+b.target.value)/2)})}var c,d,e,f,g,h,i,j={},k=0;return j.matrix=function(a){return arguments.length?(f=(e=a)&&e.length,c=d=null,j):e},j.padding=function(a){return arguments.length?(k=a,c=d=null,j):k},j.sortGroups=function(a){return arguments.length?(g=a,c=d=null,j):g},j.sortSubgroups=function(a){return arguments.length?(h=a,c=null,j):h},j.sortChords=function(a){return arguments.length?(i=a,c&&b(),j):i},j.chords=function(){return c||a(),c},j.groups=function(){return d||a(),d},j},d3.layout.force=function(){function a(a){return function(b,c,d,e,f){if(b.point!==a){var g=b.cx-a.x,h=b.cy-a.y,i=1/Math.sqrt(g*g+h*h);if(r>(e-c)*i){var j=b.charge*i*i;return a.px-=g*j,a.py-=h*j,!0}if(b.point&&isFinite(i)){var j=b.pointCharge*i*i;a.px-=g*j,a.py-=h*j}}return!b.charge}}function b(a){Pb(bf=a),af=j}var c,d,f,g,i,j={},k=d3.dispatch("start","tick","end"),l=[1,1],m=.9,n=Ub,o=Vb,p=-30,q=.1,r=.8,s=[],t=[];return j.tick=function(){if((d*=.99)<.005)return k.end({type:"end",alpha:d=0}),!0;var b,c,e,h,j,n,o,r,u,v=s.length,w=t.length;for(c=0;w>c;++c)e=t[c],h=e.source,j=e.target,r=j.x-h.x,u=j.y-h.y,(n=r*r+u*u)&&(n=d*g[c]*((n=Math.sqrt(n))-f[c])/n,r*=n,u*=n,j.x-=r*(o=h.weight/(j.weight+h.weight)),j.y-=u*o,h.x+=r*(o=1-o),h.y+=u*o);if((o=d*q)&&(r=l[0]/2,u=l[1]/2,c=-1,o))for(;++c<v;)e=s[c],e.x+=(r-e.x)*o,e.y+=(u-e.y)*o;if(p)for(Tb(b=d3.geom.quadtree(s),d,i),c=-1;++c<v;)(e=s[c]).fixed||b.visit(a(e));for(c=-1;++c<v;)e=s[c],e.fixed?(e.x=e.px,e.y=e.py):(e.x-=(e.px-(e.px=e.x))*m,e.y-=(e.py-(e.py=e.y))*m);k.tick({type:"tick",alpha:d})},j.nodes=function(a){return arguments.length?(s=a,j):s},j.links=function(a){return arguments.length?(t=a,j):t},j.size=function(a){return arguments.length?(l=a,j):l},j.linkDistance=function(a){return arguments.length?(n=h(a),j):n},j.distance=j.linkDistance,j.linkStrength=function(a){return arguments.length?(o=h(a),j):o},j.friction=function(a){return arguments.length?(m=a,j):m},j.charge=function(a){return arguments.length?(p="function"==typeof a?a:+a,j):p},j.gravity=function(a){return arguments.length?(q=a,j):q},j.theta=function(a){return arguments.length?(r=a,j):r},j.alpha=function(a){return arguments.length?(d?d=a>0?a:0:a>0&&(k.start({type:"start",alpha:d=a}),d3.timer(j.tick)),j):d},j.start=function(){function a(a,d){for(var e,f=b(c),g=-1,h=f.length;++g<h;)if(!isNaN(e=f[g][a]))return e;return Math.random()*d}function b(){if(!e){for(e=[],d=0;k>d;++d)e[d]=[];for(d=0;m>d;++d){var a=t[d];e[a.source.index].push(a.target),e[a.target.index].push(a.source)}}return e[c]}var c,d,e,h,k=s.length,m=t.length,q=l[0],r=l[1];for(c=0;k>c;++c)(h=s[c]).index=c,h.weight=0;for(f=[],g=[],c=0;m>c;++c)h=t[c],"number"==typeof h.source&&(h.source=s[h.source]),"number"==typeof h.target&&(h.target=s[h.target]),f[c]=n.call(this,h,c),g[c]=o.call(this,h,c),++h.source.weight,++h.target.weight;for(c=0;k>c;++c)h=s[c],isNaN(h.x)&&(h.x=a("x",q)),isNaN(h.y)&&(h.y=a("y",r)),isNaN(h.px)&&(h.px=h.x),isNaN(h.py)&&(h.py=h.y);if(i=[],"function"==typeof p)for(c=0;k>c;++c)i[c]=+p.call(this,s[c],c);else for(c=0;k>c;++c)i[c]=p;return j.resume()},j.resume=function(){return j.alpha(.1)},j.stop=function(){return j.alpha(0)},j.drag=function(){c||(c=d3.behavior.drag().origin(e).on("dragstart",b).on("drag",Sb).on("dragend",Rb)),this.on("mouseover.force",Pb).on("mouseout.force",Qb).call(c)},d3.rebind(j,k,"on")};var af,bf;d3.layout.partition=function(){function a(b,c,d,e){var f=b.children;if(b.x=c,b.y=b.depth*e,b.dx=d,b.dy=e,f&&(g=f.length)){var g,h,i,j=-1;for(d=b.value?d/b.value:0;++j<g;)a(h=f[j],c,i=h.value*d,e),c+=i}}function b(a){var c=a.children,d=0;if(c&&(e=c.length))for(var e,f=-1;++f<e;)d=Math.max(d,b(c[f]));return 1+d}function c(c,f){var g=d.call(this,c,f);return a(g[0],0,e[0],e[1]/b(g[0])),g}var d=d3.layout.hierarchy(),e=[1,1];return c.size=function(a){return arguments.length?(e=a,c):e},fc(c,d)},d3.layout.pie=function(){function a(f,g){var h=f.map(function(c,d){return+b.call(a,c,d)}),i=+("function"==typeof d?d.apply(this,arguments):d),j=(("function"==typeof e?e.apply(this,arguments):e)-d)/d3.sum(h),k=d3.range(f.length);null!=c&&k.sort(c===cf?function(a,b){return h[b]-h[a]}:function(a,b){return c(f[a],f[b])});var l=[];return k.forEach(function(a){var b;l[a]={data:f[a],value:b=h[a],startAngle:i,endAngle:i+=b*j}}),l}var b=Number,c=cf,d=0,e=2*Math.PI;return a.value=function(c){return arguments.length?(b=c,a):b},a.sort=function(b){return arguments.length?(c=b,a):c},a.startAngle=function(b){return arguments.length?(d=b,a):d},a.endAngle=function(b){return arguments.length?(e=b,a):e},a};var cf={};d3.layout.stack=function(){function a(e,i){var j=e.map(function(c,d){return b.call(a,c,d)}),k=j.map(function(b,c){return b.map(function(b,c){return[g.call(a,b,c),h.call(a,b,c)]})}),l=c.call(a,k,i);j=d3.permute(j,l),k=d3.permute(k,l);var m,n,o,p=d.call(a,k,i),q=j.length,r=j[0].length;for(n=0;r>n;++n)for(f.call(a,j[0][n],o=p[n],k[0][n][1]),m=1;q>m;++m)f.call(a,j[m][n],o+=k[m-1][n][1],k[m][n][1]);return e}var b=e,c=Zb,d=$b,f=Yb,g=Wb,h=Xb;return a.values=function(c){return arguments.length?(b=c,a):b},a.order=function(b){return arguments.length?(c="function"==typeof b?b:df.get(b)||Zb,a):c},a.offset=function(b){return arguments.length?(d="function"==typeof b?b:ef.get(b)||$b,a):d},a.x=function(b){return arguments.length?(g=b,a):g},a.y=function(b){return arguments.length?(h=b,a):h},a.out=function(b){return arguments.length?(f=b,a):f},a};var df=d3.map({"inside-out":function(a){var b,c,d=a.length,e=a.map(_b),f=a.map(ac),g=d3.range(d).sort(function(a,b){return e[a]-e[b]}),h=0,i=0,j=[],k=[];for(b=0;d>b;++b)c=g[b],i>h?(h+=f[c],j.push(c)):(i+=f[c],k.push(c));return k.reverse().concat(j)},reverse:function(a){return d3.range(a.length).reverse()},"default":Zb}),ef=d3.map({silhouette:function(a){var b,c,d,e=a.length,f=a[0].length,g=[],h=0,i=[];for(c=0;f>c;++c){for(b=0,d=0;e>b;b++)d+=a[b][c][1];d>h&&(h=d),g.push(d)}for(c=0;f>c;++c)i[c]=(h-g[c])/2;return i},wiggle:function(a){var b,c,d,e,f,g,h,i,j,k=a.length,l=a[0],m=l.length,n=[];for(n[0]=i=j=0,c=1;m>c;++c){for(b=0,e=0;k>b;++b)e+=a[b][c][1];for(b=0,f=0,h=l[c][0]-l[c-1][0];k>b;++b){for(d=0,g=(a[b][c][1]-a[b][c-1][1])/(2*h);b>d;++d)g+=(a[d][c][1]-a[d][c-1][1])/h;f+=g*a[b][c][1]}n[c]=i-=e?f/e*h:0,j>i&&(j=i)}for(c=0;m>c;++c)n[c]-=j;return n},expand:function(a){var b,c,d,e=a.length,f=a[0].length,g=1/e,h=[];for(c=0;f>c;++c){for(b=0,d=0;e>b;b++)d+=a[b][c][1];if(d)for(b=0;e>b;b++)a[b][c][1]/=d;else for(b=0;e>b;b++)a[b][c][1]=g}for(c=0;f>c;++c)h[c]=0;return h},zero:$b});d3.layout.histogram=function(){function a(a,f){for(var g,h,i=[],j=a.map(c,this),k=d.call(this,j,f),l=e.call(this,k,j,f),f=-1,m=j.length,n=l.length-1,o=b?1:1/m;++f<n;)g=i[f]=[],g.dx=l[f+1]-(g.x=l[f]),g.y=0;if(n>0)for(f=-1;++f<m;)h=j[f],h>=k[0]&&h<=k[1]&&(g=i[d3.bisect(l,h,1,n)-1],g.y+=o,g.push(a[f]));return i}var b=!0,c=Number,d=ec,e=cc;return a.value=function(b){return arguments.length?(c=b,a):c},a.range=function(b){return arguments.length?(d=h(b),a):d},a.bins=function(b){return arguments.length?(e="number"==typeof b?function(a){return dc(a,b)}:h(b),a):e},a.frequency=function(c){return arguments.length?(b=!!c,a):b},a},d3.layout.hierarchy=function(){function a(b,g,h){var i=e.call(c,b,g),j=ff?b:{data:b};if(j.depth=g,h.push(j),i&&(k=i.length)){for(var k,l,m=-1,n=j.children=[],o=0,p=g+1;++m<k;)l=a(i[m],p,h),l.parent=j,n.push(l),o+=l.value;d&&n.sort(d),f&&(j.value=o)}else f&&(j.value=+f.call(c,b,g)||0);return j}function b(a,d){var e=a.children,g=0;if(e&&(h=e.length))for(var h,i=-1,j=d+1;++i<h;)g+=b(e[i],j);else f&&(g=+f.call(c,ff?a:a.data,d)||0);return f&&(a.value=g),g}function c(b){var c=[];return a(b,0,c),c}var d=ic,e=gc,f=hc;return c.sort=function(a){return arguments.length?(d=a,c):d},c.children=function(a){return arguments.length?(e=a,c):e},c.value=function(a){return arguments.length?(f=a,c):f},c.revalue=function(a){return b(a,0),a},c};var ff=!1;d3.layout.pack=function(){function a(a,e){var f=b.call(this,a,e),g=f[0];g.x=0,g.y=0,Ec(g,function(a){a.r=Math.sqrt(a.value)}),Ec(g,oc);var h=d[0],i=d[1],j=Math.max(2*g.r/h,2*g.r/i);if(c>0){var k=c*j/2;Ec(g,function(a){a.r+=k}),Ec(g,oc),Ec(g,function(a){a.r-=k}),j=Math.max(2*g.r/h,2*g.r/i)}return rc(g,h/2,i/2,1/j),f}var b=d3.layout.hierarchy().sort(kc),c=0,d=[1,1];return a.size=function(b){return arguments.length?(d=b,a):d},a.padding=function(b){return arguments.length?(c=+b,a):c},fc(a,b)},d3.layout.cluster=function(){function a(a,e){var f,g=b.call(this,a,e),h=g[0],i=0;Ec(h,function(a){var b=a.children;b&&b.length?(a.x=uc(b),a.y=tc(b)):(a.x=f?i+=c(a,f):0,a.y=0,f=a)});var j=vc(h),k=wc(h),l=j.x-c(j,k)/2,m=k.x+c(k,j)/2;return Ec(h,function(a){a.x=(a.x-l)/(m-l)*d[0],a.y=(1-(h.y?a.y/h.y:1))*d[1]}),g}var b=d3.layout.hierarchy().sort(null).value(null),c=xc,d=[1,1];return a.separation=function(b){return arguments.length?(c=b,a):c},a.size=function(b){return arguments.length?(d=b,a):d},fc(a,b)},d3.layout.tree=function(){function a(a,e){function f(a,b){var d=a.children,e=a._tree;if(d&&(g=d.length)){for(var g,i,j,k=d[0],l=k,m=-1;++m<g;)j=d[m],f(j,i),l=h(j,i,l),i=j;Fc(a);var n=.5*(k._tree.prelim+j._tree.prelim);b?(e.prelim=b._tree.prelim+c(a,b),e.mod=e.prelim-n):e.prelim=n}else b&&(e.prelim=b._tree.prelim+c(a,b))}function g(a,b){a.x=a._tree.prelim+b;var c=a.children;if(c&&(d=c.length)){var d,e=-1;for(b+=a._tree.mod;++e<d;)g(c[e],b)}}function h(a,b,d){if(b){for(var e,f=a,g=a,h=b,i=a.parent.children[0],j=f._tree.mod,k=g._tree.mod,l=h._tree.mod,m=i._tree.mod;h=zc(h),f=yc(f),h&&f;)i=yc(i),g=zc(g),g._tree.ancestor=a,e=h._tree.prelim+l-f._tree.prelim-j+c(h,f),e>0&&(Gc(Hc(h,a,d),a,e),j+=e,k+=e),l+=h._tree.mod,j+=f._tree.mod,m+=i._tree.mod,k+=g._tree.mod;h&&!zc(g)&&(g._tree.thread=h,g._tree.mod+=l-k),f&&!yc(i)&&(i._tree.thread=f,i._tree.mod+=j-m,d=a)}return d}var i=b.call(this,a,e),j=i[0];Ec(j,function(a,b){a._tree={ancestor:a,prelim:0,mod:0,change:0,shift:0,number:b?b._tree.number+1:0}}),f(j),g(j,-j._tree.prelim);var k=Ac(j,Cc),l=Ac(j,Bc),m=Ac(j,Dc),n=k.x-c(k,l)/2,o=l.x+c(l,k)/2,p=m.depth||1;return Ec(j,function(a){a.x=(a.x-n)/(o-n)*d[0],a.y=a.depth/p*d[1],delete a._tree}),i}var b=d3.layout.hierarchy().sort(null).value(null),c=xc,d=[1,1];return a.separation=function(b){return arguments.length?(c=b,a):c},a.size=function(b){return arguments.length?(d=b,a):d},fc(a,b)},d3.layout.treemap=function(){function a(a,b){for(var c,d,e=-1,f=a.length;++e<f;)d=(c=a[e]).value*(0>b?0:b),c.area=isNaN(d)||0>=d?0:d}function b(c){var f=c.children;if(f&&f.length){var g,h,i,j=l(c),k=[],m=f.slice(),n=1/0,o=Math.min(j.dx,j.dy);for(a(m,j.dx*j.dy/c.value),k.area=0;(i=m.length)>0;)k.push(g=m[i-1]),k.area+=g.area,(h=d(k,o))<=n?(m.pop(),n=h):(k.area-=k.pop().area,e(k,o,j,!1),o=Math.min(j.dx,j.dy),k.length=k.area=0,n=1/0);k.length&&(e(k,o,j,!0),k.length=k.area=0),f.forEach(b)}}function c(b){var d=b.children;if(d&&d.length){var f,g=l(b),h=d.slice(),i=[];for(a(h,g.dx*g.dy/b.value),i.area=0;f=h.pop();)i.push(f),i.area+=f.area,null!=f.z&&(e(i,f.z?g.dx:g.dy,g,!h.length),i.length=i.area=0);d.forEach(c)}}function d(a,b){for(var c,d=a.area,e=0,f=1/0,g=-1,h=a.length;++g<h;)(c=a[g].area)&&(f>c&&(f=c),c>e&&(e=c));return d*=d,b*=b,d?Math.max(b*e*n/d,d/(b*f*n)):1/0}function e(a,b,c,d){var e,f=-1,g=a.length,h=c.x,j=c.y,k=b?i(a.area/b):0;if(b==c.dx){for((d||k>c.dy)&&(k=c.dy);++f<g;)e=a[f],e.x=h,e.y=j,e.dy=k,h+=e.dx=Math.min(c.x+c.dx-h,k?i(e.area/k):0);e.z=!0,e.dx+=c.x+c.dx-h,c.y+=k,c.dy-=k}else{for((d||k>c.dx)&&(k=c.dx);++f<g;)e=a[f],e.x=h,e.y=j,e.dx=k,j+=e.dy=Math.min(c.y+c.dy-j,k?i(e.area/k):0);e.z=!1,e.dy+=c.y+c.dy-j,c.x+=k,c.dx-=k}}function f(d){var e=g||h(d),f=e[0];return f.x=0,f.y=0,f.dx=j[0],f.dy=j[1],g&&h.revalue(f),a([f],f.dx*f.dy/f.value),(g?c:b)(f),m&&(g=e),e}var g,h=d3.layout.hierarchy(),i=Math.round,j=[1,1],k=null,l=Ic,m=!1,n=.5*(1+Math.sqrt(5));return f.size=function(a){return arguments.length?(j=a,f):j},f.padding=function(a){function b(b){var c=a.call(f,b,b.depth);return null==c?Ic(b):Jc(b,"number"==typeof c?[c,c,c,c]:c)}function c(b){return Jc(b,a)}if(!arguments.length)return k;var d;return l=null==(k=a)?Ic:"function"==(d=typeof a)?b:"number"===d?(a=[a,a,a,a],c):c,f},f.round=function(a){return arguments.length?(i=a?Math.round:Number,f):i!=Number},f.sticky=function(a){return arguments.length?(m=a,g=null,f):m},f.ratio=function(a){return arguments.length?(n=a,f):n},fc(f,h)},d3.csv=Kc(",","text/csv"),d3.tsv=Kc(" ","text/tab-separated-values"),d3.geo={};var gf=Math.PI/180;d3.geo.azimuthal=function(){function a(a){var b,d=a[0]*gf-c,j=a[1]*gf,k=Math.cos(d),l=Math.sin(d),m=Math.cos(j),n=Math.sin(j),o="orthographic"!==g?f*n+e*m*k:null,p="stereographic"===g?1/(1+o):"gnomonic"===g?1/o:"equidistant"===g?(b=Math.acos(o),b?b/Math.sin(b):0):"equalarea"===g?Math.sqrt(2/(1+o)):1,q=p*m*l,r=p*(f*m*k-e*n);return[h*q+i[0],h*r+i[1]]}var b,c,d,e,f,g="orthographic",h=200,i=[480,250];return a.invert=function(a){var b=(a[0]-i[0])/h,d=(a[1]-i[1])/h,j=Math.sqrt(b*b+d*d),k="stereographic"===g?2*Math.atan(j):"gnomonic"===g?Math.atan(j):"equidistant"===g?j:"equalarea"===g?2*Math.asin(.5*j):Math.asin(j),l=Math.sin(k),m=Math.cos(k);return[(c+Math.atan2(b*l,j*e*m+d*f*l))/gf,Math.asin(m*f-(j?d*l*e/j:0))/gf]},a.mode=function(b){return arguments.length?(g=b+"",a):g},a.origin=function(g){return arguments.length?(b=g,c=b[0]*gf,d=b[1]*gf,e=Math.cos(d),f=Math.sin(d),a):b},a.scale=function(b){return arguments.length?(h=+b,a):h},a.translate=function(b){return arguments.length?(i=[+b[0],+b[1]],a):i},a.origin([0,0])},d3.geo.albers=function(){function a(a){var b=d*(gf*a[0]-c),g=Math.sqrt(e-2*d*Math.sin(gf*a[1]))/d;return[i*g*Math.sin(b)+j[0],i*(g*Math.cos(b)-f)+j[1]]}function b(){var b=gf*h[0],i=gf*h[1],j=gf*g[1],k=Math.sin(b),l=Math.cos(b);return c=gf*g[0],d=.5*(k+Math.sin(i)),e=l*l+2*d*k,f=Math.sqrt(e-2*d*Math.sin(j))/d,a}var c,d,e,f,g=[-98,38],h=[29.5,45.5],i=1e3,j=[480,250];return a.invert=function(a){var b=(a[0]-j[0])/i,g=(a[1]-j[1])/i,h=f+g,k=Math.atan2(b,h),l=Math.sqrt(b*b+h*h);return[(c+k/d)/gf,Math.asin((e-l*l*d*d)/(2*d))/gf]},a.origin=function(a){return arguments.length?(g=[+a[0],+a[1]],b()):g},a.parallels=function(a){return arguments.length?(h=[+a[0],+a[1]],b()):h},a.scale=function(b){return arguments.length?(i=+b,a):i},a.translate=function(b){return arguments.length?(j=[+b[0],+b[1]],a):j},b()},d3.geo.albersUsa=function(){function a(a){var f=a[0],g=a[1];return(g>50?c:-140>f?d:21>g?e:b)(a)}var b=d3.geo.albers(),c=d3.geo.albers().origin([-160,60]).parallels([55,65]),d=d3.geo.albers().origin([-160,20]).parallels([8,18]),e=d3.geo.albers().origin([-60,10]).parallels([8,18]);return a.scale=function(f){return arguments.length?(b.scale(f),c.scale(.6*f),d.scale(f),e.scale(1.5*f),a.translate(b.translate())):b.scale()},a.translate=function(f){if(!arguments.length)return b.translate();var g=b.scale()/1e3,h=f[0],i=f[1];return b.translate(f),c.translate([h-400*g,i+170*g]),d.translate([h-190*g,i+200*g]),e.translate([h+580*g,i+430*g]),a},a.scale(b.scale())},d3.geo.bonne=function(){function a(a){var h=a[0]*gf-b,i=a[1]*gf-c;if(d){var j=e+d-i,k=h*Math.cos(i)/j;h=j*Math.sin(k),i=j*Math.cos(k)-e}else h*=Math.cos(i),i*=-1;return[f*h+g[0],f*i+g[1]]}var b,c,d,e,f=200,g=[480,250];return a.invert=function(a){var c=(a[0]-g[0])/f,h=(a[1]-g[1])/f;if(d){var i=e+h,j=Math.sqrt(c*c+i*i);h=e+d-j,c=b+j*Math.atan2(c,i)/Math.cos(h)}else h*=-1,c/=Math.cos(h);return[c/gf,h/gf]},a.parallel=function(b){return arguments.length?(e=1/Math.tan(d=b*gf),a):d/gf},a.origin=function(d){return arguments.length?(b=d[0]*gf,c=d[1]*gf,a):[b/gf,c/gf]},a.scale=function(b){return arguments.length?(f=+b,a):f},a.translate=function(b){return arguments.length?(g=[+b[0],+b[1]],a):g},a.origin([0,0]).parallel(45)},d3.geo.equirectangular=function(){function a(a){var d=a[0]/360,e=-a[1]/360;return[b*d+c[0],b*e+c[1]]}var b=500,c=[480,250];return a.invert=function(a){var d=(a[0]-c[0])/b,e=(a[1]-c[1])/b;return[360*d,-360*e]},a.scale=function(c){return arguments.length?(b=+c,a):b},a.translate=function(b){return arguments.length?(c=[+b[0],+b[1]],a):c},a},d3.geo.mercator=function(){function a(a){var d=a[0]/360,e=-(Math.log(Math.tan(Math.PI/4+a[1]*gf/2))/gf)/360;return[b*d+c[0],b*Math.max(-.5,Math.min(.5,e))+c[1]]}var b=500,c=[480,250];return a.invert=function(a){var d=(a[0]-c[0])/b,e=(a[1]-c[1])/b;return[360*d,2*Math.atan(Math.exp(-360*e*gf))/gf-90]},a.scale=function(c){return arguments.length?(b=+c,a):b},a.translate=function(b){return arguments.length?(c=[+b[0],+b[1]],a):c},a},d3.geo.path=function(){function a(a,b){"function"==typeof f&&(g=Mc(f.apply(this,arguments))),j(a);var c=i.length?i.join(""):null;return i=[],c}function b(a){return h(a).join(",")}function c(a){for(var b=e(a[0]),c=0,d=a.length;++c<d;)b-=e(a[c]);return b}function d(a){for(var b=d3.geom.polygon(a[0].map(h)),c=b.area(),d=b.centroid(0>c?(c*=-1,1):-1),e=d[0],f=d[1],g=c,i=0,j=a.length;++i<j;)b=d3.geom.polygon(a[i].map(h)),c=b.area(),d=b.centroid(0>c?(c*=-1,1):-1),e-=d[0],f-=d[1],g-=c;return[e,f,6*g]}function e(a){return Math.abs(d3.geom.polygon(a.map(h)).area())}var f=4.5,g=Mc(f),h=d3.geo.albersUsa(),i=[],j=Lc({FeatureCollection:function(a){for(var b=a.features,c=-1,d=b.length;++c<d;)i.push(j(b[c].geometry))},Feature:function(a){j(a.geometry)},Point:function(a){i.push("M",b(a.coordinates),g)},MultiPoint:function(a){for(var c=a.coordinates,d=-1,e=c.length;++d<e;)i.push("M",b(c[d]),g)},LineString:function(a){var c=a.coordinates,d=-1,e=c.length;for(i.push("M");++d<e;)i.push(b(c[d]),"L");i.pop()},MultiLineString:function(a){for(var c,d,e,f=a.coordinates,g=-1,h=f.length;++g<h;){for(c=f[g],d=-1,e=c.length,i.push("M");++d<e;)i.push(b(c[d]),"L");i.pop()}},Polygon:function(a){for(var c,d,e,f=a.coordinates,g=-1,h=f.length;++g<h;)if(c=f[g],d=-1,(e=c.length-1)>0){for(i.push("M");++d<e;)i.push(b(c[d]),"L");i[i.length-1]="Z"}},MultiPolygon:function(a){for(var c,d,e,f,g,h,j=a.coordinates,k=-1,l=j.length;++k<l;)for(c=j[k],d=-1,e=c.length;++d<e;)if(f=c[d],g=-1,(h=f.length-1)>0){for(i.push("M");++g<h;)i.push(b(f[g]),"L");i[i.length-1]="Z"}},GeometryCollection:function(a){for(var b=a.geometries,c=-1,d=b.length;++c<d;)i.push(j(b[c]))}}),k=a.area=Lc({FeatureCollection:function(a){for(var b=0,c=a.features,d=-1,e=c.length;++d<e;)b+=k(c[d]);return b},Feature:function(a){return k(a.geometry)},Polygon:function(a){return c(a.coordinates)},MultiPolygon:function(a){for(var b=0,d=a.coordinates,e=-1,f=d.length;++e<f;)b+=c(d[e]);return b},GeometryCollection:function(a){for(var b=0,c=a.geometries,d=-1,e=c.length;++d<e;)b+=k(c[d]);return b}},0),l=a.centroid=Lc({Feature:function(a){return l(a.geometry)},Polygon:function(a){var b=d(a.coordinates);return[b[0]/b[2],b[1]/b[2]]},MultiPolygon:function(a){for(var b,c=a.coordinates,e=0,f=0,g=0,h=-1,i=c.length;++h<i;)b=d(c[h]),e+=b[0],f+=b[1],g+=b[2];return[e/g,f/g]}});return a.projection=function(b){return h=b,a},a.pointRadius=function(b){return"function"==typeof b?f=b:(f=+b,g=Mc(f)),a},a},d3.geo.bounds=function(a){var b=1/0,c=1/0,d=-(1/0),e=-(1/0);return Nc(a,function(a,f){b>a&&(b=a),a>d&&(d=a),c>f&&(c=f),f>e&&(e=f)}),[[b,c],[d,e]]};var hf={Feature:Oc,FeatureCollection:Pc,GeometryCollection:Qc,LineString:Rc,MultiLineString:Sc,MultiPoint:Rc,MultiPolygon:Tc,Point:Uc,Polygon:Vc};d3.geo.circle=function(){function a(){}function b(a){return i.distance(a)<h}function c(a){for(var b,c,e,f,g,j=-1,k=a.length,l=[];++j<k;)g=i.distance(e=a[j]),h>g?(c&&l.push(Zc(c,e)((f-h)/(f-g))),l.push(e),b=c=null):(c=e,!b&&l.length&&(l.push(Zc(l[l.length-1],c)((h-f)/(g-f))),b=c)),f=g;return b=a[0],c=l[0],c&&e[0]===b[0]&&e[1]===b[1]&&(e[0]!==c[0]||e[1]!==c[1])&&l.push(c),d(l)}function d(a){for(var b,c,d,e=0,f=a.length,g=f?[a[0]]:a,h=i.source();++e<f;)for(d=i.source(a[e-1])(a[e]).coordinates,b=0,c=d.length;++b<c;)g.push(d[b]);return i.source(h),g}var f=[0,0],g=89.99,h=g*gf,i=d3.geo.greatArc().source(f).target(e);a.clip=function(a){return"function"==typeof f&&i.source(f.apply(this,arguments)),j(a)||null};var j=Lc({FeatureCollection:function(a){var b=a.features.map(j).filter(e);return b&&(a=Object.create(a),a.features=b,a)},Feature:function(a){var b=j(a.geometry);return b&&(a=Object.create(a),a.geometry=b,a)},Point:function(a){return b(a.coordinates)&&a},MultiPoint:function(a){var c=a.coordinates.filter(b);return c.length&&{type:a.type,coordinates:c}},LineString:function(a){var b=c(a.coordinates);return b.length&&(a=Object.create(a),a.coordinates=b,a)},MultiLineString:function(a){var b=a.coordinates.map(c).filter(function(a){return a.length});return b.length&&(a=Object.create(a),a.coordinates=b,a)},Polygon:function(a){var b=a.coordinates.map(c);return b[0].length&&(a=Object.create(a),a.coordinates=b,a)},MultiPolygon:function(a){var b=a.coordinates.map(function(a){return a.map(c)}).filter(function(a){return a[0].length});return b.length&&(a=Object.create(a),a.coordinates=b,a)},GeometryCollection:function(a){var b=a.geometries.map(j).filter(e);return b.length&&(a=Object.create(a),a.geometries=b,a)}});return a.origin=function(b){return arguments.length?(f=b,"function"!=typeof f&&i.source(f),a):f},a.angle=function(b){return arguments.length?(h=(g=+b)*gf,a):g},d3.rebind(a,i,"precision")},d3.geo.greatArc=function(){function a(){for(var d=a.distance.apply(this,arguments),e=0,h=f/d,i=[b];(e+=h)<1;)i.push(g(e));return i.push(c),{type:"LineString",coordinates:i}}var b,c,d=Wc,e=Xc,f=6*gf,g=Yc();return a.distance=function(){return"function"==typeof d&&g.source(b=d.apply(this,arguments)),"function"==typeof e&&g.target(c=e.apply(this,arguments)),g.distance()},a.source=function(c){return arguments.length?(d=c,"function"!=typeof d&&g.source(b=d),a):d},a.target=function(b){return arguments.length?(e=b,"function"!=typeof e&&g.target(c=e),a):e},a.precision=function(b){return arguments.length?(f=b*gf,a):f/gf},a},d3.geo.greatCircle=d3.geo.circle,d3.geom={},d3.geom.contour=function(a,b){var c=b||$c(a),d=[],e=c[0],f=c[1],g=0,h=0,i=NaN,j=NaN,k=0;do k=0,a(e-1,f-1)&&(k+=1),a(e,f-1)&&(k+=2),a(e-1,f)&&(k+=4),a(e,f)&&(k+=8),6===k?(g=-1===j?-1:1,h=0):9===k?(g=0,h=1===i?-1:1):(g=jf[k],h=kf[k]),g!=i&&h!=j&&(d.push([e,f]),i=g,j=h),e+=g,f+=h;while(c[0]!=e||c[1]!=f);return d};var jf=[1,0,1,1,-1,0,-1,1,0,0,0,0,-1,0,-1,NaN],kf=[0,-1,0,0,0,-1,0,0,1,-1,1,1,0,-1,0,NaN];d3.geom.hull=function(a){if(a.length<3)return[];var b,c,d,e,f,g,h,i,j,k,l=a.length,m=l-1,n=[],o=[],p=0;for(b=1;l>b;++b)a[b][1]<a[p][1]?p=b:a[b][1]==a[p][1]&&(p=a[b][0]<a[p][0]?b:p);for(b=0;l>b;++b)b!==p&&(e=a[b][1]-a[p][1],d=a[b][0]-a[p][0],n.push({angle:Math.atan2(e,d),index:b}));for(n.sort(function(a,b){return a.angle-b.angle}),j=n[0].angle,i=n[0].index,h=0,b=1;m>b;++b)c=n[b].index,j==n[b].angle?(d=a[i][0]-a[p][0],e=a[i][1]-a[p][1],f=a[c][0]-a[p][0],g=a[c][1]-a[p][1],d*d+e*e>=f*f+g*g?n[b].index=-1:(n[h].index=-1,j=n[b].angle,h=b,i=c)):(j=n[b].angle,h=b,i=c);for(o.push(p),b=0,c=0;2>b;++c)-1!==n[c].index&&(o.push(n[c].index),b++);for(k=o.length;m>c;++c)if(-1!==n[c].index){for(;!_c(o[k-2],o[k-1],n[c].index,a);)--k;o[k++]=n[c].index}var q=[];for(b=0;k>b;++b)q.push(a[o[b]]);return q},d3.geom.polygon=function(a){return a.area=function(){for(var b=0,c=a.length,d=a[c-1][0]*a[0][1],e=a[c-1][1]*a[0][0];++b<c;)d+=a[b-1][0]*a[b][1],e+=a[b-1][1]*a[b][0];return.5*(e-d)},a.centroid=function(b){var c,d,e=-1,f=a.length,g=0,h=0,i=a[f-1];for(arguments.length||(b=-1/(6*a.area()));++e<f;)c=i,i=a[e],d=c[0]*i[1]-i[0]*c[1],g+=(c[0]+i[0])*d,h+=(c[1]+i[1])*d;return[g*b,h*b]},a.clip=function(b){for(var c,d,e,f,g,h,i=-1,j=a.length,k=a[j-1];++i<j;){for(c=b.slice(),b.length=0,f=a[i],g=c[(e=c.length)-1],d=-1;++d<e;)h=c[d],ad(h,k,f)?(ad(g,k,f)||b.push(bd(g,h,k,f)),b.push(h)):ad(g,k,f)&&b.push(bd(g,h,k,f)),g=h;k=f}return b},a},d3.geom.voronoi=function(a){var b=a.map(function(){return[]});return cd(a,function(a){var c,d,e,f,g,h;1===a.a&&a.b>=0?(c=a.ep.r,d=a.ep.l):(c=a.ep.l,d=a.ep.r),1===a.a?(g=c?c.y:-1e6,e=a.c-a.b*g,h=d?d.y:1e6,f=a.c-a.b*h):(e=c?c.x:-1e6,g=a.c-a.a*e,f=d?d.x:1e6,h=a.c-a.a*f);var i=[e,g],j=[f,h];b[a.region.l.index].push(i,j),b[a.region.r.index].push(i,j)}),b.map(function(b,c){var d=a[c][0],e=a[c][1];return b.forEach(function(a){a.angle=Math.atan2(a[0]-d,a[1]-e)}),b.sort(function(a,b){return a.angle-b.angle}).filter(function(a,c){return!c||a.angle-b[c-1].angle>1e-10})})};var lf={l:"r",r:"l"};d3.geom.delaunay=function(a){var b=a.map(function(){return[]}),c=[];return cd(a,function(c){b[c.region.l.index].push(a[c.region.r.index])}),b.forEach(function(b,d){var e=a[d],f=e[0],g=e[1];b.forEach(function(a){a.angle=Math.atan2(a[0]-f,a[1]-g)}),b.sort(function(a,b){return a.angle-b.angle});for(var h=0,i=b.length-1;i>h;h++)c.push([e,b[h],b[h+1]])}),c},d3.geom.quadtree=function(a,b,c,d,e){function f(a,b,c,d,e,f){if(!isNaN(b.x)&&!isNaN(b.y))if(a.leaf){var h=a.point;h?Math.abs(h.x-b.x)+Math.abs(h.y-b.y)<.01?g(a,b,c,d,e,f):(a.point=null,g(a,h,c,d,e,f),g(a,b,c,d,e,f)):a.point=b}else g(a,b,c,d,e,f)}function g(a,b,c,d,e,g){var h=.5*(c+e),i=.5*(d+g),j=b.x>=h,k=b.y>=i,l=(k<<1)+j;a.leaf=!1,a=a.nodes[l]||(a.nodes[l]=dd()),j?c=h:e=h,k?d=i:g=i,f(a,b,c,d,e,g)}var h,i=-1,j=a.length;if(j&&isNaN(a[0].x)&&(a=a.map(fd)),arguments.length<5)if(3===arguments.length)e=d=c,c=b;else{for(b=c=1/0,d=e=-(1/0);++i<j;)h=a[i],h.x<b&&(b=h.x),h.y<c&&(c=h.y),h.x>d&&(d=h.x),h.y>e&&(e=h.y);var k=d-b,l=e-c;k>l?e=c+k:d=b+l}var m=dd();return m.add=function(a){f(m,a,b,c,d,e)},m.visit=function(a){ed(a,m,b,c,d,e)},a.forEach(m.add),m},d3.time={};var mf=Date,nf=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];gd.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(){of.setUTCDate.apply(this._,arguments)},setDay:function(){of.setUTCDay.apply(this._,arguments)},setFullYear:function(){of.setUTCFullYear.apply(this._,arguments)},setHours:function(){of.setUTCHours.apply(this._,arguments)},setMilliseconds:function(){of.setUTCMilliseconds.apply(this._,arguments)},setMinutes:function(){of.setUTCMinutes.apply(this._,arguments)},setMonth:function(){of.setUTCMonth.apply(this._,arguments)},setSeconds:function(){of.setUTCSeconds.apply(this._,arguments)},setTime:function(){of.setTime.apply(this._,arguments)}};var of=Date.prototype,pf="%a %b %e %H:%M:%S %Y",qf="%m/%d/%y",rf="%H:%M:%S",sf=nf,tf=sf.map(hd),uf=["January","February","March","April","May","June","July","August","September","October","November","December"],vf=uf.map(hd);d3.time.format=function(a){function b(b){for(var d,e,f=[],g=-1,h=0;++g<c;)37==a.charCodeAt(g)&&(f.push(a.substring(h,g),(e=Gf[d=a.charAt(++g)])?e(b):d),h=g+1);return f.push(a.substring(h,g)),f.join("")}var c=a.length;return b.parse=function(b){var c={y:1900,m:0,d:1,H:0,M:0,S:0,L:0},d=id(c,a,b,0);if(d!=b.length)return null;"p"in c&&(c.H=c.H%12+12*c.p);var e=new mf;return e.setFullYear(c.y,c.m,c.d),e.setHours(c.H,c.M,c.S,c.L),e},b.toString=function(){return a},b};var wf=d3.format("02d"),xf=d3.format("03d"),yf=d3.format("04d"),zf=d3.format("2d"),Af=jd(sf),Bf=jd(tf),Cf=jd(uf),Df=kd(uf),Ef=jd(vf),Ff=kd(vf),Gf={a:function(a){return tf[a.getDay()]},A:function(a){return sf[a.getDay()]},b:function(a){return vf[a.getMonth()]},B:function(a){return uf[a.getMonth()]},c:d3.time.format(pf),d:function(a){return wf(a.getDate())},e:function(a){return zf(a.getDate())},H:function(a){return wf(a.getHours())},I:function(a){return wf(a.getHours()%12||12)},j:function(a){return xf(1+d3.time.dayOfYear(a))},L:function(a){return xf(a.getMilliseconds())},m:function(a){return wf(a.getMonth()+1)},M:function(a){return wf(a.getMinutes())},p:function(a){return a.getHours()>=12?"PM":"AM"},S:function(a){return wf(a.getSeconds())},U:function(a){return wf(d3.time.sundayOfYear(a))},w:function(a){return a.getDay()},W:function(a){return wf(d3.time.mondayOfYear(a))},x:d3.time.format(qf),X:d3.time.format(rf),y:function(a){return wf(a.getFullYear()%100)},Y:function(a){return yf(a.getFullYear()%1e4)},Z:Cd,"%":function(a){return"%"}},Hf={a:ld,A:md,b:nd,B:od,c:pd,d:wd,e:wd,H:xd,I:xd,L:Ad,m:vd,M:yd,p:Bd,S:zd,x:qd,X:rd,y:td,Y:sd},If=/^\s*\d+/,Jf=d3.map({am:0,pm:1});d3.time.format.utc=function(a){function b(a){try{mf=gd;var b=new mf;return b._=a,c(b)}finally{mf=Date}}var c=d3.time.format(a);return b.parse=function(a){try{mf=gd;var b=c.parse(a);return b&&b._}finally{mf=Date}},b.toString=c.toString,b};var Kf=d3.time.format.utc("%Y-%m-%dT%H:%M:%S.%LZ");d3.time.format.iso=Date.prototype.toISOString?Dd:Kf,Dd.parse=function(a){var b=new Date(a);return isNaN(b)?null:b},Dd.toString=Kf.toString,d3.time.second=Ed(function(a){return new mf(1e3*Math.floor(a/1e3))},function(a,b){a.setTime(a.getTime()+1e3*Math.floor(b))},function(a){return a.getSeconds()}),d3.time.seconds=d3.time.second.range,d3.time.seconds.utc=d3.time.second.utc.range,d3.time.minute=Ed(function(a){return new mf(6e4*Math.floor(a/6e4))},function(a,b){a.setTime(a.getTime()+6e4*Math.floor(b))},function(a){return a.getMinutes()}),d3.time.minutes=d3.time.minute.range,d3.time.minutes.utc=d3.time.minute.utc.range,d3.time.hour=Ed(function(a){var b=a.getTimezoneOffset()/60;return new mf(36e5*(Math.floor(a/36e5-b)+b))},function(a,b){a.setTime(a.getTime()+36e5*Math.floor(b))},function(a){return a.getHours()}),d3.time.hours=d3.time.hour.range,d3.time.hours.utc=d3.time.hour.utc.range,d3.time.day=Ed(function(a){var b=new mf(0,a.getMonth(),a.getDate());return b.setFullYear(a.getFullYear()),b},function(a,b){a.setDate(a.getDate()+b)},function(a){return a.getDate()-1}),d3.time.days=d3.time.day.range,d3.time.days.utc=d3.time.day.utc.range,d3.time.dayOfYear=function(a){var b=d3.time.year(a);return Math.floor((a-b-6e4*(a.getTimezoneOffset()-b.getTimezoneOffset()))/864e5)},nf.forEach(function(a,b){a=a.toLowerCase(),b=7-b;var c=d3.time[a]=Ed(function(a){return(a=d3.time.day(a)).setDate(a.getDate()-(a.getDay()+b)%7),a},function(a,b){a.setDate(a.getDate()+7*Math.floor(b))},function(a){var c=d3.time.year(a).getDay();return Math.floor((d3.time.dayOfYear(a)+(c+b)%7)/7)-(c!==b)});d3.time[a+"s"]=c.range,d3.time[a+"s"].utc=c.utc.range,d3.time[a+"OfYear"]=function(a){var c=d3.time.year(a).getDay();return Math.floor((d3.time.dayOfYear(a)+(c+b)%7)/7)}}),d3.time.week=d3.time.sunday,d3.time.weeks=d3.time.sunday.range,d3.time.weeks.utc=d3.time.sunday.utc.range,d3.time.weekOfYear=d3.time.sundayOfYear,d3.time.month=Ed(function(a){return a=d3.time.day(a),a.setDate(1),a},function(a,b){a.setMonth(a.getMonth()+b)},function(a){return a.getMonth()}),d3.time.months=d3.time.month.range,d3.time.months.utc=d3.time.month.utc.range,d3.time.year=Ed(function(a){return a=d3.time.day(a),a.setMonth(0,1),a},function(a,b){a.setFullYear(a.getFullYear()+b)},function(a){return a.getFullYear()}),d3.time.years=d3.time.year.range,d3.time.years.utc=d3.time.year.utc.range;var Lf=[1e3,5e3,15e3,3e4,6e4,3e5,9e5,18e5,36e5,108e5,216e5,432e5,864e5,1728e5,6048e5,2592e6,7776e6,31536e6],Mf=[[d3.time.second,1],[d3.time.second,5],[d3.time.second,15],[d3.time.second,30],[d3.time.minute,1],[d3.time.minute,5],[d3.time.minute,15],[d3.time.minute,30],[d3.time.hour,1],[d3.time.hour,3],[d3.time.hour,6],[d3.time.hour,12],[d3.time.day,1],[d3.time.day,2],[d3.time.week,1],[d3.time.month,1],[d3.time.month,3],[d3.time.year,1]],Nf=[[d3.time.format("%Y"),function(a){return!0}],[d3.time.format("%B"),function(a){return a.getMonth()}],[d3.time.format("%b %d"),function(a){return 1!=a.getDate()}],[d3.time.format("%a %d"),function(a){return a.getDay()&&1!=a.getDate()}],[d3.time.format("%I %p"),function(a){
return a.getHours()}],[d3.time.format("%I:%M"),function(a){return a.getMinutes()}],[d3.time.format(":%S"),function(a){return a.getSeconds()}],[d3.time.format(".%L"),function(a){return a.getMilliseconds()}]],Of=d3.scale.linear(),Pf=Jd(Nf);Mf.year=function(a,b){return Of.domain(a.map(Ld)).ticks(b).map(Kd)},d3.time.scale=function(){return Gd(d3.scale.linear(),Mf,Pf)};var Qf=Mf.map(function(a){return[a[0].utc,a[1]]}),Rf=[[d3.time.format.utc("%Y"),function(a){return!0}],[d3.time.format.utc("%B"),function(a){return a.getUTCMonth()}],[d3.time.format.utc("%b %d"),function(a){return 1!=a.getUTCDate()}],[d3.time.format.utc("%a %d"),function(a){return a.getUTCDay()&&1!=a.getUTCDate()}],[d3.time.format.utc("%I %p"),function(a){return a.getUTCHours()}],[d3.time.format.utc("%I:%M"),function(a){return a.getUTCMinutes()}],[d3.time.format.utc(":%S"),function(a){return a.getUTCSeconds()}],[d3.time.format.utc(".%L"),function(a){return a.getUTCMilliseconds()}]],Sf=Jd(Rf);Qf.year=function(a,b){return Of.domain(a.map(Nd)).ticks(b).map(Md)},d3.time.scale.utc=function(){return Gd(d3.scale.linear(),Qf,Sf)}}();var Gauge;Gauge=function(a,b){var c;this.placeholderName=a,c=this,this.configure=function(a){this.config=a,this.config.size=.9*this.config.size,this.config.raduis=.97*this.config.size/2,this.config.cx=this.config.size/2,this.config.cy=this.config.size/2,this.config.min=a.min||0,this.config.max=a.max||100,this.config.range=this.config.max-this.config.min,this.config.majorTicks=a.majorTicks||5,this.config.minorTicks=a.minorTicks||2,this.config.greenColor=a.greenColor||"#109618",this.config.yellowColor=a.yellowColor||"#FF9900",this.config.redColor=a.redColor||"#DC3912"},this.render=function(){var a,b,d,e,e,d,e,f,g,h,i,j,b,a,k;this.body=d3.select("#"+this.placeholderName).append("svg:svg").attr("class","gauge").attr("width",this.config.size).attr("height",this.config.size),this.body.append("svg:circle").attr("class","outer").attr("cx",this.config.cx).attr("cy",this.config.cy).attr("r",this.config.raduis),this.body.append("svg:circle").attr("class","inner").attr("cx",this.config.cx).attr("cy",this.config.cy).attr("r",.9*this.config.raduis);for(e in this.config.greenZones)this.drawBand(this.config.greenZones[e].from,this.config.greenZones[e].to,c.config.greenColor);for(e in this.config.yellowZones)this.drawBand(this.config.yellowZones[e].from,this.config.yellowZones[e].to,c.config.yellowColor);for(e in this.config.redZones)this.drawBand(this.config.redZones[e].from,this.config.redZones[e].to,c.config.redColor);for(void 0!==this.config.label&&(d=Math.round(this.config.size/9),this.body.append("svg:text").attr("class","label").attr("x",this.config.cx).attr("y",this.config.cy/2+d/2).attr("dy",d/2).attr("text-anchor","middle").text(this.config.label).style("font-size",d+"px")),d=Math.round(this.config.size/16),g=this.config.range/(this.config.majorTicks-1),f=this.config.min;f<=this.config.max;){for(i=g/this.config.minorTicks,h=f+i;h<Math.min(f+g,this.config.max);)b=this.valueToPoint(h,.75),a=this.valueToPoint(h,.85),this.body.append("svg:line").attr("class","small-tick").attr("x1",b.x).attr("y1",b.y).attr("x2",a.x).attr("y2",a.y),h+=i;b=this.valueToPoint(f,.7),a=this.valueToPoint(f,.85),this.body.append("svg:line").attr("class","big-tick").attr("x1",b.x).attr("y1",b.y).attr("x2",a.x).attr("y2",a.y),(f===this.config.min||f===this.config.max)&&(j=this.valueToPoint(f,.63),this.body.append("svg:text").attr("class","limit").attr("x",j.x).attr("y",j.y).attr("dy",d/3).attr("text-anchor",f===this.config.min?"start":"end").text(f).style("font-size",d+"px")),f+=g}k=this.body.append("svg:g").attr("class","pointerContainer"),this.drawPointer(0),k.append("svg:circle").attr("class","pointer-circle").attr("cx",this.config.cx).attr("cy",this.config.cy).attr("r",.12*this.config.raduis)},this.redraw=function(a,b){this.drawPointer(a,b)},this.drawBand=function(a,b,d){0>=b-a||this.body.append("svg:path").style("fill",d).attr("class","band").attr("d",d3.svg.arc().startAngle(this.valueToRadians(a)).endAngle(this.valueToRadians(b)).innerRadius(.8*this.config.raduis).outerRadius(.85*this.config.raduis)).attr("transform",function(){return"translate("+c.config.cx+", "+c.config.cy+") rotate(270)"})},this.drawPointer=function(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o;d=this.config.range/13,f=this.valueToPoint(a,.85),g=this.valueToPoint(a-d,.12),h=this.valueToPoint(a+d,.12),o=a-1*this.config.range/.75/2,l=this.valueToPoint(o,.28),m=this.valueToPoint(o-d,.12),n=this.valueToPoint(o+d,.12),c=[f,g,n,l,m,h,f],i=d3.svg.line().x(function(a){return a.x}).y(function(a){return a.y}).interpolate("basis"),k=this.body.select(".pointerContainer"),j=k.selectAll("path").data([c]),j.enter().append("svg:path").attr("class","pointer").attr("d",i),j.transition().attr("d",i),e=Math.round(this.config.size/10),k.selectAll("text").data([a]).text(d3.format(b)(a)).enter().append("svg:text").attr("class","value").attr("x",this.config.cx).attr("y",this.config.size-this.config.cy/4-e).attr("dy",e/2).attr("text-anchor","middle").text(d3.format(b)(a)).style("font-size",e+"px")},this.valueToDegrees=function(a){return a/this.config.range*270-45},this.valueToRadians=function(a){return this.valueToDegrees(a)*Math.PI/180},this.valueToPoint=function(a,b){var c;return c={x:this.config.cx-this.config.raduis*b*Math.cos(this.valueToRadians(a)),y:this.config.cy-this.config.raduis*b*Math.sin(this.valueToRadians(a))}},this.configure(b)};var postRenderTimeSeriesView,toggleHighlight;toggleHighlight=function(a,b){var c;return c=function(a,b,c){return c.replace(new RegExp(a,"g"),b)},-1!==a.indexOf(b)?c("highlight","",a):a+" "+b},postRenderTimeSeriesView=function(a){var b;return b=a,b.selectAll("a.l").forEach(function(a){return a.forEach(function(a){var c;return c=a.getAttribute("id"),a.addEventListener("mouseenter",function(){return b.selectAll("path#l-"+c).forEach(function(a){return a.forEach(function(a){return a.setAttribute("class",toggleHighlight(a.getAttribute("class"),"line-highlight"))})}),b.selectAll("path#a-"+c).forEach(function(a){return a.forEach(function(a){return a.setAttribute("class",toggleHighlight(a.getAttribute("class"),"area-highlight"))})})}),a.addEventListener("mouseleave",function(){return b.selectAll("path#l-"+c).forEach(function(a){return a.forEach(function(a){return a.setAttribute("class",toggleHighlight(a.getAttribute("class"),"line-highlight"))})}),b.selectAll("path#a-"+c).forEach(function(a){return a.forEach(function(a){return a.setAttribute("class",toggleHighlight(a.getAttribute("class"),"area-highlight"))})})})})})};var Graphene,bind=function(a,b){return function(){return a.apply(b,arguments)}},extend=function(a,b){function c(){this.constructor=a}for(var d in b)hasProp.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},hasProp={}.hasOwnProperty;Graphene=function(){function Graphene(){this.stop=bind(this.stop,this),this.build=bind(this.build,this),this.models={},this.is_silent=!1,this.is_demo=!1}return Graphene.prototype.demo=function(){return this.is_demo=!0},Graphene.prototype.silent=function(){return this.is_silent=!0},Graphene.prototype.build=function(json){return _.each(_.keys(json),function(_this){return function(k){var model,model_opts,ts;return _this.is_silent||console.log("building ["+k+"]"),model=_this.is_demo?Graphene.DemoTimeSeries:Graphene.TimeSeries,model_opts={source:json[k].source},model_opts.silent=_this.is_silent,delete json[k].source,json[k].refresh_interval&&(model_opts.refresh_interval=json[k].refresh_interval,delete json[k].refresh_interval),ts=new model(model_opts),_this.models[k]=ts,_.each(json[k],function(opts,view){var params;return view=eval("Graphene."+view+"View"),params=_.extend({model:ts,silent:_this.is_silent,ymin:_this.getUrlParam(model_opts.source,"yMin"),ymax:_this.getUrlParam(model_opts.source,"yMax")},opts),new view(params),ts.start()})}}(this))},Graphene.prototype.stop=function(){return _.each(this.models,function(a){return function(b){return a.is_silent||console.log("stop polling"),b.stop()}}(this))},Graphene.prototype.discover=function(a,b,c,d){return $.getJSON(a+"/dashboard/load/"+b,function(b){var e,f;return f=0,e={},_.each(b.state.graphs,function(b){var d,g,h;return g=b[2],d=b[1],h=d.title?d.title:"n/a",e["Graph "+f]={source:""+a+g+"&format=json",TimeSeries:{title:h,ymin:d.yMin,parent:c(f,a)}},f++}),d(e)})},Graphene.prototype.getUrlParam=function(a,b){var c,d,e;return d="",(c=a.split("?")[1])?(e=c.split("&"),e&&e.length>0?(_.each(e,function(a){var c;return c=a.split("="),decodeURIComponent(c[0])===b?d=decodeURIComponent(c[1]):void 0}),d):d):d},Graphene}(),this.Graphene=Graphene,Graphene.GraphiteModel=function(a){function b(){return this.process_data=bind(this.process_data,this),this.refresh=bind(this.refresh,this),this.stop=bind(this.stop,this),this.start=bind(this.start,this),b.__super__.constructor.apply(this,arguments)}return extend(b,a),b.prototype.defaults={source:"",data:null,ymin:0,ymax:0,refresh_interval:1e4,silent:!1},b.prototype.debug=function(){return this.get("silent")?void 0:console.log(""+this.get("refresh_interval"))},b.prototype.start=function(){return this.refresh(),this.get("silent")||console.log("Starting to poll at "+this.get("refresh_interval")),this.t_index=setInterval(this.refresh,this.get("refresh_interval"))},b.prototype.stop=function(){return clearInterval(this.t_index)},b.prototype.refresh=function(){var a,b;return b=this.get("source"),-1===b.indexOf("&jsonp=?")&&(b+="&jsonp=?"),a={url:b,dataType:"json",jsonp:"jsonp",success:function(a){return function(b){return a.get("silent")||console.log("got data."),a.process_data(b)}}(this)},$.ajax(a)},b.prototype.process_data=function(){return null},b}(Backbone.Model);var bind=function(a,b){return function(){return a.apply(b,arguments)}},extend=function(a,b){function c(){this.constructor=a}for(var d in b)hasProp.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},hasProp={}.hasOwnProperty;Graphene.BarChart=function(a){function b(){return this.process_data=bind(this.process_data,this),b.__super__.constructor.apply(this,arguments)}return extend(b,a),b.prototype.process_data=function(a){var b;return console.log("process data barchart"),b=_.map(a,function(a){var b,c;return c=d3.min(a.datapoints,function(a){return a[0]}),void 0===c?null:(b=d3.max(a.datapoints,function(a){return a[0]}),void 0===b?null:(_.each(a.datapoints,function(a){return a[1]=new Date(1e3*a[1])}),{points:_.reject(a.datapoints,function(a){return null===a[0]}),ymin:c,ymax:b,label:a.target}))}),b=_.reject(b,function(a){return null===a}),this.set({data:b})},b}(Graphene.GraphiteModel);var bind=function(a,b){return function(){return a.apply(b,arguments)}},extend=function(a,b){function c(){this.constructor=a}for(var d in b)hasProp.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},hasProp={}.hasOwnProperty;Graphene.DemoTimeSeries=function(a){function b(){return this.add_points=bind(this.add_points,this),this.refresh=bind(this.refresh,this),this.stop=bind(this.stop,this),this.start=bind(this.start,this),b.__super__.constructor.apply(this,arguments)}return extend(b,a),b.prototype.defaults={range:[0,1e3],num_points:100,num_new_points:1,num_series:2,refresh_interval:3e3},b.prototype.debug=function(){return this.get("silent")?void 0:console.log(""+this.get("refresh_interval"))},b.prototype.start=function(){return this.get("silent")||console.log("Starting to poll at "+this.get("refresh_interval")),this.data=[],_.each(_.range(this.get("num_series")),function(a){return function(b){return a.data.push({label:"Series "+b,ymin:0,ymax:0,points:[]})}}(this)),this.point_interval=this.get("refresh_interval")/this.get("num_new_points"),_.each(this.data,function(a){return function(b){return a.add_points(new Date,a.get("range"),a.get("num_points"),a.point_interval,b)}}(this)),this.set({data:this.data}),this.t_index=setInterval(this.refresh,this.get("refresh_interval"))},b.prototype.stop=function(){return clearInterval(this.t_index)},b.prototype.refresh=function(){var a,b,c;return this.data=_.map(this.data,function(a){return a=_.clone(a),a.points=_.map(a.points,function(a){return[a[0],a[1]]}),a}),a=this.data[0].points.pop(),this.data[0].points.push(a),c=a[1],b=this.get("num_new_points"),_.each(this.data,function(a){return function(d){return a.add_points(c,a.get("range"),b,a.point_interval,d)}}(this)),this.set({data:this.data})},b.prototype.add_points=function(a,b,c,d,e){return _.each(_.range(c),function(c){return function(f){var g;return g=[b[0]+Math.random()*(b[1]-b[0]),new Date(a.getTime()+(f+1)*d)],e.points.push(g),e.points.length>c.get("num_points")?e.points.shift():void 0}}(this)),e.ymin=d3.min(e.points,function(a){return a[0]}),e.ymax=d3.max(e.points,function(a){return a[0]})},b}(Backbone.Model);var bind=function(a,b){return function(){return a.apply(b,arguments)}},extend=function(a,b){function c(){this.constructor=a}for(var d in b)hasProp.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},hasProp={}.hasOwnProperty;Graphene.TimeSeries=function(a){function b(){return this.process_data=bind(this.process_data,this),b.__super__.constructor.apply(this,arguments)}return extend(b,a),b.prototype.process_data=function(a){var b;return b=_.map(a,function(a){var b,c,d,e;return d=d3.min(a.datapoints,function(a){return a[0]}),void 0===d?null:(c=d3.max(a.datapoints,function(a){return a[0]}),void 0===c?null:(b=null!=(e=_.last(a.datapoints)[0])?e:0,void 0===b?null:(_.each(a.datapoints,function(a){return a[1]=new Date(1e3*a[1])}),{points:_.reject(a.datapoints,function(a){return null===a[0]}),ymin:d,ymax:c,last:b,label:a.target})))}),b=_.reject(b,function(a){return null===a}),this.set({data:b})},b}(Graphene.GraphiteModel);var bind=function(a,b){return function(){return a.apply(b,arguments)}},extend=function(a,b){function c(){this.constructor=a}for(var d in b)hasProp.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},hasProp={}.hasOwnProperty;Graphene.BarChartView=function(a){function b(){return this.render=bind(this.render,this),b.__super__.constructor.apply(this,arguments)}return extend(b,a),b.prototype.tagName="div",b.prototype.initialize=function(){return this.silent=this.options.silent||!1,this.line_height=this.options.line_height||16,this.animate_ms=this.options.animate_ms||500,this.num_labels=this.options.num_labels||3,this.sort_labels=this.options.labels_sort||"desc",this.display_verticals=this.options.display_verticals||!1,this.width=this.options.width||400,this.height=this.options.height||100,this.padding=this.options.padding||[2*this.line_height,32,this.line_height*(3+this.num_labels),32],this.title=this.options.title,this.label_formatter=this.options.label_formatter||function(a){return a},this.firstrun=!0,this.parent=this.options.parent||"#parent",this.null_value=0,this.value_format=this.options.value_format||".3s",this.value_format=d3.format(this.value_format),this.vis=d3.select(this.parent).append("svg").attr("class","tsview").attr("width",this.width+(this.padding[1]+this.padding[3])).attr("height",this.height+(this.padding[0]+this.padding[2])).append("g").attr("transform","translate("+this.padding[3]+","+this.padding[0]+")"),this.model.bind("change",this.render)},b.prototype.render=function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A;return this.silent||console.log("rendering bar chart."),h=this.model.get("data"),j=_.max(h,function(a){return a.ymax}),k=_.min(h,function(a){return a.ymin}),h=_.sortBy(h,function(a){return 1*a.ymax}),r=_.map(h,function(a){return a.points}),t=_.flatten(_.map(r,function(a){return _.map(a,function(a){return a[1]})})),p=_.min(t),o=_.max(t),q=_.uniq(_.sortBy(t,function(a){return a}),!0,function(a){return a.getTime()}),i=[],_.each(q,function(a,b,c){return void 0!==c[b+1]?i.push(c[b+1]-a):void 0}),s=_.min(i),w=d3.time.scale().domain([p,o+s]).range([0,this.width]),z=d3.scale.linear().domain([k.ymin,j.ymax]).range([this.height,0]).nice(),e=(o-p)/s+1,f=r.length,g=e*f,a=_.max([this.width/g-2,.1]),b=function(b,c,d){return w(b[1])+d*(a+2)},c=function(a){return z(a[0])},y=this.display_verticals?-this.height:0,x=d3.svg.axis().scale(w).ticks(_.min([4,e])).tickSize(y).tickSubdivide(!0),A=d3.svg.axis().scale(z).ticks(4).tickSize(-this.width).orient("left").tickFormat(d3.format("s")),v=this.vis,d=this.height,this.firstrun&&(this.firstrun=!1,v.append("svg:g").attr("class","x axis").attr("transform","translate(0,"+this.height+")").transition().duration(this.animate_ms).call(x),v.append("svg:g").attr("class","y axis").call(A),this.title&&(u=v.append("svg:text").attr("class","title").attr("transform","translate(0, -"+this.line_height+")").text(this.title)),this.legend=v.append("svg:g").attr("transform","translate(0, "+(this.height+2*this.line_height)+")").attr("class","legend")),l=this.legend.selectAll("g.l").data(_.first(h,this.num_labels),function(a){return Math.random()}),l.exit().remove(),m=l.enter().append("svg:g").attr("transform",function(a){return function(b,c){return"translate(0, "+c*a.line_height+")"}}(this)).attr("class","l"),m.append("svg:rect").attr("width",5).attr("height",5).attr("class",function(a,b){return"ts-color h-col-"+(b+1)}),n=m.append("svg:text").attr("dx",10).attr("dy",6).attr("class","ts-text").text(function(a){return function(b){return a.label_formatter(b.label)}}(this)),n.append("svg:tspan").attr("class","min-tag").attr("dx",10).text(function(a){return function(b){return a.value_format(b.ymin)+"min"}}(this)),n.append("svg:tspan").attr("class","max-tag").attr("dx",2).text(function(a){return function(b){return a.value_format(b.ymax)+"max"}}(this)),_.each(r,function(c,e){var f;return f="h-col-"+(e+1),v.selectAll("rect.area."+f).data(c).enter().append("rect").attr("class",f+" area").attr("x",function(a,c){return b(a,c,e)}).attr("y",d).attr("width",a)}),_.each(r,function(e,f){var g;return g="h-col-"+(f+1),v.selectAll("rect.area."+g).data(e).transition().ease("linear").duration(this.animate_ms).attr("x",function(a,c){return b(a,c,f)}).attr("y",function(a,b){return c(a)}).attr("width",a).attr("height",function(a,b){return d-c(a)}).attr("class",g+" area")}),v.transition().ease("linear").duration(this.animate_ms).select(".x.axis").call(x),v.select(".y.axis").call(A),this.silent?void 0:console.log("done drawing barchart")},b}(Backbone.View);var bind=function(a,b){return function(){return a.apply(b,arguments)}},extend=function(a,b){function c(){this.constructor=a}for(var d in b)hasProp.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},hasProp={}.hasOwnProperty;Graphene.GaugeGadgetView=function(a){function b(){return this.render=bind(this.render,this),this.by_type=bind(this.by_type,this),b.__super__.constructor.apply(this,arguments)}return extend(b,a),b.prototype.className="gauge-gadget-view",b.prototype.tagName="div",b.prototype.initialize=function(){var a;return this.silent=this.options.silent||!1,this.title=this.options.title,this.type=this.options.type,this.parent=this.options.parent||"#parent",this.value_format=this.options.value_format||".3s",this.null_value=0,this.from=this.options.from||0,this.to=this.options.to||100,this.observer=this.options.observer,this.vis=d3.select(this.parent).append("div").attr("class","ggview").attr("id",this.title+"GaugeContainer"),a={size:this.options.size||120,label:this.title,minorTicks:5,min:this.from,max:this.to},a.redZones=[],a.redZones.push({from:this.options.red_from||.9*this.to,to:this.options.red_to||this.to}),a.yellowZones=[],a.yellowZones.push({from:this.options.yellow_from||.75*this.to,to:this.options.yellow_to||.9*this.to}),this.gauge=new Gauge(this.title+"GaugeContainer",a),this.gauge.render(),this.model.bind("change",this.render),this.silent?void 0:console.log("GaugeGadget view ")},b.prototype.by_type=function(a){switch(this.type){case"min":return a.ymin;case"max":return a.ymax;case"current":return a.last;default:return a.points[0][0]}},b.prototype.render=function(){var a,b;return this.silent||console.log("GaugeGadget rendering."),a=this.model.get("data"),b=a&&a.length>0?a[0]:{ymax:this.null_value,ymin:this.null_value,points:[[this.null_value,0]]},this.observer&&this.observer(this.by_type(b)),this.gauge.redraw(this.by_type(b),this.value_format)},b}(Backbone.View);var bind=function(a,b){return function(){return a.apply(b,arguments)}},extend=function(a,b){function c(){this.constructor=a}for(var d in b)hasProp.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},hasProp={}.hasOwnProperty;Graphene.GaugeLabelView=function(a){function b(){return this.render=bind(this.render,this),this.by_type=bind(this.by_type,this),b.__super__.constructor.apply(this,arguments)}return extend(b,a),b.prototype.className="gauge-label-view",b.prototype.tagName="div",b.prototype.initialize=function(){return this.silent=this.options.silent||!1,this.unit=this.options.unit,this.title=this.options.title,this.type=this.options.type,this.parent=this.options.parent||"#parent",this.value_format=this.options.value_format||".3s",this.value_format=d3.format(this.value_format),this.null_value=0,this.observer=this.options.observer,this.vis=d3.select(this.parent).append("div").attr("class","glview"),this.title&&this.vis.append("div").attr("class","label").text(this.title),this.model.bind("change",this.render),this.silent?void 0:console.log("GaugeLabel view ")},b.prototype.by_type=function(a){switch(this.type){case"min":return a.ymin;case"max":return a.ymax;case"current":return a.last;default:return a.points[0][0]}},b.prototype.render=function(){var a,b,c,d,e;return a=this.model.get("data"),this.silent||console.log("GaugeLabel",a),b=a&&a.length>0?a[0]:{ymax:this.null_value,ymin:this.null_value,points:[[this.null_value,0]]},this.observer&&this.observer(this.by_type(b)),e=this.vis,d=e.selectAll("div.metric").data([b],function(a){return function(b){return a.by_type(b)}}(this)),d.exit().remove(),c=d.enter().insert("div",":first-child").attr("class","metric"+(this.type?" "+this.type:"")),c.append("span").attr("class","value").text(function(a){return function(b){return a.value_format(a.by_type(b))}}(this)),this.unit?c.append("span").attr("class","unit").text(this.unit):void 0},b}(Backbone.View);var bind=function(a,b){return function(){return a.apply(b,arguments)}},extend=function(a,b){function c(){this.constructor=a}for(var d in b)hasProp.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},hasProp={}.hasOwnProperty;Graphene.ProgressBarGadgetView=function(a){function b(){return this.render=bind(this.render,this),this.by_type=bind(this.by_type,this),b.__super__.constructor.apply(this,arguments)}return extend(b,a),b.prototype.className="progressbar-gadget-view",b.prototype.tagName="div",b.prototype.initialize=function(){return this.silent=this.options.silent||!1,this.unit=this.options.unit,this.title=this.options.title,this.type=this.options.type,this.parent=this.options.parent||"#parent",this.value_format=this.options.value_format||".3s",this.value_format=d3.format(this.value_format),this.null_value=0,this.observer=this.options.observer,this.to=this.options.to||1,this.multiplier=100/this.to,this.vis=d3.select(this.parent).append("div").attr("class","pbview"),this.area=this.vis.append("div").attr("class","progress").append("div").attr("class","bar").attr("style","width: 50%"),this.title&&this.area.append("div").attr("class","label").text(this.title),this.model.bind("change",this.render),this.silent?void 0:console.log("ProgressBAr view ")},b.prototype.by_type=function(a){switch(this.type){case"min":return a.ymin;case"max":return a.ymax;case"current":return a.last;default:return a.points[0][0]*this.multiplier}},b.prototype.render=function(){var a,b,c,d,e;return b=this.model.get("data"),this.silent||console.log("ProgressBar data",b),c=b&&b.length>0?b[0]:{ymax:this.null_value,ymin:this.null_value,points:[[this.null_value,0]]},this.observer&&this.observer(this.by_type(c)),a=this.area,e=a.selectAll("div.metric").data([c],function(a){return function(b){return a.by_type(b)}}(this)),e.exit().remove(),d=e.enter().insert("div",":first-child").attr("class","metric"+(this.type?" "+this.type:"")),this.area.attr("style","width: "+this.by_type(c)+"%"),d.text(this.title),d.append("span").attr("class","value").text(function(a){return function(b){return" "+a.value_format(a.by_type(b))}}(this)),this.unit?d.append("span").attr("class","unit").text(this.unit):void 0},b}(Backbone.View);var bind=function(a,b){return function(){return a.apply(b,arguments)}},extend=function(a,b){function c(){this.constructor=a}for(var d in b)hasProp.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},hasProp={}.hasOwnProperty;Graphene.TimeSeriesView=function(a){function b(){return this.render=bind(this.render,this),b.__super__.constructor.apply(this,arguments)}return extend(b,a),b.prototype.tagName="div",b.prototype.initialize=function(){return this.silent=this.options.silent||!1,this.name=this.options.name||"g-"+parseInt(1e6*Math.random()),this.line_height=this.options.line_height||16,this.x_ticks=this.options.x_ticks||4,this.y_ticks=this.options.y_ticks||4,this.animate_ms=this.options.animate_ms||500,this.label_offset=this.options.label_offset||0,this.label_columns=this.options.label_columns||1,this.label_href=this.options.label_href||function(a){return"#"},this.label_formatter=this.options.label_formatter||function(a){return a},this.num_labels=this.options.num_labels||3,this.sort_labels=this.options.labels_sort,this.display_verticals=this.options.display_verticals||!1,this.width=this.options.width||400,this.height=this.options.height||100,this.padding=this.options.padding||[2*this.line_height,32,this.line_height*(3+this.num_labels/this.label_columns),32],this.title=this.options.title,this.firstrun=!0,this.parent=this.options.parent||"#parent",this.null_value=0,this.show_current=this.options.show_current||!1,this.observer=this.options.observer,this.postrender=this.options.post_render||postRenderTimeSeriesView,this.vis=d3.select(this.parent).append("svg").attr("class","tsview").attr("width",this.width+(this.padding[1]+this.padding[3])).attr("height",this.height+(this.padding[0]+this.padding[2])).append("g").attr("transform","translate("+this.padding[3]+","+this.padding[0]+")"),this.value_format=this.options.value_format||".3s",this.value_format=d3.format(this.value_format),this.model.bind("change",this.render),this.silent?void 0:console.log("TS view: "+this.name+" "+this.width+"x"+this.height+" padding:"+this.padding+" animate: "+this.animate_ms+" labels: "+this.num_labels)},b.prototype.render=function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y;return this.silent||console.log("rendering."),c=this.model.get("data"),c=c&&c.length>0?c:[{ymax:this.null_value,ymin:this.null_value,points:[[this.null_value,0],[this.null_value,0]]}],d=_.max(c,function(a){return a.ymax}),d.ymax_graph=this.options.ymax||d.ymax,e=_.min(c,function(a){return a.ymin}),e.ymin_graph=null!=(n=this.options.ymin)?n:e.ymin,v=_.flatten(function(){var a,d,e;for(e=[],a=0,d=c.length;d>a;a++)b=c[a],e.push(b.points.map(function(a){return a[1]}));return e}()),u=_.min(v,function(a){return a.valueOf()}),t=_.max(v,function(a){return a.valueOf()}),r=d3.time.scale().domain([u,t]).range([0,this.width]),x=d3.scale.linear().domain([e.ymin_graph,d.ymax_graph]).range([this.height,0]).nice(),w=this.display_verticals?-this.height:0,s=d3.svg.axis().scale(r).ticks(this.x_ticks).tickSize(w).tickSubdivide(!0),y=d3.svg.axis().scale(x).ticks(this.y_ticks).tickSize(-this.width).orient("left").tickFormat(d3.format("s")),p=this.vis,h=d3.svg.line().x(function(a){return r(a[1])}).y(function(a){return x(a[0])}),a=d3.svg.area().x(function(a){return r(a[1])}).y0(this.height-1).y1(function(a){return x(a[0])}),this.sort_labels&&(l="desc"===this.sort_labels?-1:1,c=_.sortBy(c,function(a){return l*a.ymax})),this.observer&&this.observer(c),m=_.map(c,function(a){return a.points}),this.firstrun&&(this.firstrun=!1,p.append("svg:g").attr("class","x axis").attr("transform","translate(0,"+this.height+")").transition().duration(this.animate_ms).call(s),p.append("svg:g").attr("class","y axis").call(y),p.selectAll("path.line").data(m).enter().append("path").attr("d",h).attr("class",function(a,b){return"line h-col-"+(b+1)}),p.selectAll("path.area").data(m).enter().append("path").attr("d",a).attr("class",function(a,b){return"area h-col-"+(b+1)}),this.options.warn&&d.ymax_graph>this.options.warn&&(q=[[[this.options.warn,u],[this.options.warn,t]]],p.selectAll("path.line-warn").data(q).enter().append("path").attr("d",h).attr("stroke-dasharray","10,10").attr("class","line-warn")),this.options.error&&d.ymax_graph>this.options.error&&(f=[[[this.options.error,u],[this.options.error,t]]],p.selectAll("path.line-error").data(f).enter().append("path").attr("d",h).attr("stroke-dasharray","10,10").attr("class","line-error")),this.title&&(o=p.append("svg:text").attr("class","title").attr("transform","translate(0, -"+this.line_height+")").text(this.title)),this.legend=p.append("svg:g").attr("transform","translate(0, "+(this.height+2*this.line_height)+")").attr("class","legend")),g=this.legend.selectAll("g.l").data(_.first(c,this.num_labels),function(a){return Math.random()}),g.exit().remove(),i=g.enter().append("svg:g").attr("transform",function(a){return function(b,c){return"translate("+c%a.label_columns*a.label_offset+", "+parseInt(c/a.label_columns)*a.line_height+")"}}(this)).attr("class","l"),i.append("svg:rect").attr("width",5).attr("height",5).attr("class",function(a,b){return"ts-color h-col-"+(b+1)}),j=i.append("svg:a").attr("xlink:href",function(a){return function(b){return a.label_href(b.label)}}(this)).attr("class","l").attr("id",function(a){return function(b,c){return a.name+"-"+c}}(this)),k=j.append("svg:text").attr("dx",10).attr("dy",6).attr("class","ts-text").text(function(a){return function(b){return a.label_formatter(b.label)}}(this)),k.append("svg:tspan").attr("class","min-tag").attr("dx",10).text(function(a){return function(b){return a.value_format(b.ymin)+"min"}}(this)),k.append("svg:tspan").attr("class","max-tag").attr("dx",2).text(function(a){return function(b){return a.value_format(b.ymax)+"max"}}(this)),this.show_current===!0&&k.append("svg:tspan").attr("class","last-tag").attr("dx",2).text(function(a){return function(b){return a.value_format(b.last)+"last"}}(this)),p.transition().ease("linear").duration(this.animate_ms).select(".x.axis").call(s),p.select(".y.axis").call(y),p.selectAll("path.area").data(m).attr("d",a).attr("id",function(a){return function(b,c){return"a-"+a.name+"-"+c}}(this)).transition().ease("linear").duration(this.animate_ms),p.selectAll("path.line").data(m).attr("d",h).attr("id",function(a){return function(b,c){return"l-"+a.name+"-"+c}}(this)).transition().ease("linear").duration(this.animate_ms),this.postrender(this.vis)},b}(Backbone.View);