// https://d3js.org/d3-hierarchy/ Version 1.1.5. Copyright 2017 Mike Bostock. !function(n,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r(n.d3=n.d3||{})}(this,function(n){"use strict";function r(n,r){return n.parent===r.parent?1:2}function e(n){return n.reduce(t,0)/n.length}function t(n,r){return n+r.x}function u(n){return 1+n.reduce(i,0)}function i(n,r){return Math.max(n,r.y)}function o(n){for(var r;r=n.children;)n=r[0];return n}function f(n){for(var r;r=n.children;)n=r[r.length-1];return n}function a(n){var r=0,e=n.children,t=e&&e.length;if(t)for(;--t>=0;)r+=e[t].value;else r=1;n.value=r}function c(n,r){if(n===r)return n;var e=n.ancestors(),t=r.ancestors(),u=null;for(n=e.pop(),r=t.pop();n===r;)u=n,n=e.pop(),r=t.pop();return u}function h(n,r){var e,t,u,i,o,f=new v(n),a=+n.value&&(f.value=n.value),c=[f];for(null==r&&(r=p);e=c.pop();)if(a&&(e.value=+e.data.value),(u=r(e.data))&&(o=u.length))for(e.children=new Array(o),i=o-1;i>=0;--i)c.push(t=e.children[i]=new v(u[i])),t.parent=e,t.depth=e.depth+1;return f.eachBefore(s)}function l(){return h(this).eachBefore(d)}function p(n){return n.children}function d(n){n.data=n.data.data}function s(n){var r=0;do{n.height=r}while((n=n.parent)&&n.height<++r)}function v(n){this.data=n,this.depth=this.height=0,this.parent=null}function x(n){for(var r,e,t=n.length;t;)e=Math.random()*t--|0,r=n[t],n[t]=n[e],n[e]=r;return n}function y(n,r){var e,t;if(w(r,n))return[r];for(e=0;e0&&e*e>t*t+u*u}function w(n,r){for(var e=0;ee*e+t*t}function E(n){var r=n._,e=n.next._,t=r.r+e.r,u=(r.x*e.r+e.x*r.r)/t,i=(r.y*e.r+e.y*r.r)/t;return u*u+i*i}function b(n){this._=n,this.next=null,this.previous=null}function S(n){if(!(u=n.length))return 0;var r,e,t,u,i,o,f,a,c,h,l;if(r=n[0],r.x=0,r.y=0,!(u>1))return r.r;if(e=n[1],r.x=-e.r,e.x=r.r,e.y=0,!(u>2))return r.r+e.r;A(e,r,t=n[2]),r=new b(r),e=new b(e),t=new b(t),r.next=t.previous=e,e.next=r.previous=t,t.next=e.previous=r;n:for(f=3;f=0;)(r=u[i]).z+=e,r.m+=e,e+=r.s+(t+=r.c)}function J(n,r,e){return n.a.parent===r.parent?n.a:e}function K(n,r){this._=n,this.parent=null,this.children=null,this.A=null,this.a=this,this.z=0,this.m=0,this.c=0,this.s=0,this.t=null,this.i=r}function N(n){for(var r,e,t,u,i,o=new K(n,0),f=[o];r=f.pop();)if(t=r._.children)for(r.children=new Array(i=t.length),u=i-1;u>=0;--u)f.push(e=r.children[u]=new K(t[u],u)),e.parent=r;return(o.parent=new K(null,0)).children=[o],o}function Q(n,r,e,t,u,i){for(var o,f,a,c,h,l,p,d,s,v,x,y=[],g=r.children,m=0,w=0,_=g.length,z=r.value;m<_;){a=u-e,c=i-t;do{h=g[w++].value}while(!h&&w<_);for(l=p=h,x=h*h*(v=Math.max(c/a,a/c)/(z*n)),s=Math.max(p/x,x/l);w<_;++w){if(h+=f=g[w].value,fp&&(p=f),x=h*h*v,(d=Math.max(p/x,x/l))>s){h-=f;break}s=d}y.push(o={value:h,dice:a=0;--e)u.push(r[e]);return this},Y=function(n){for(var r,e,t,u=this,i=[u],o=[];u=i.pop();)if(o.push(u),r=u.children)for(e=0,t=r.length;e=0;)e+=t[u].value;r.value=e})},nn=function(n){return this.eachBefore(function(r){r.children&&r.children.sort(n)})},rn=function(n){for(var r=this,e=c(r,n),t=[r];r!==e;)r=r.parent,t.push(r);for(var u=t.length;n!==e;)t.splice(u,0,n),n=n.parent;return t},en=function(){for(var n=this,r=[n];n=n.parent;)r.push(n);return r},tn=function(){var n=[];return this.each(function(r){n.push(r)}),n},un=function(){var n=[];return this.eachBefore(function(r){r.children||n.push(r)}),n},on=function(){var n=this,r=[];return n.each(function(e){e!==n&&r.push({source:e.parent,target:e})}),r};v.prototype=h.prototype={constructor:v,count:V,each:W,eachAfter:Y,eachBefore:X,sum:Z,sort:nn,path:rn,ancestors:en,descendants:tn,leaves:un,links:on,copy:l};var fn=Array.prototype.slice,an=function(n){for(var r,e,t=0,u=(n=x(fn.call(n))).length,i=[];t0)throw new Error("cycle");return i}var r=L,e=P;return n.id=function(e){return arguments.length?(r=I(e),n):r},n.parentId=function(r){return arguments.length?(e=I(r),n):e},n};K.prototype=Object.create(v.prototype);var mn=function(){function n(n){var t=N(n);if(t.eachAfter(r),t.parent.m=-t.z,t.eachBefore(e),a)n.eachBefore(u);else{var c=n,h=n,l=n;n.eachBefore(function(n){n.xh.x&&(h=n),n.depth>l.depth&&(l=n)});var p=c===h?1:i(c,h)/2,d=p-c.x,s=o/(h.x+p+d),v=f/(l.depth||1);n.eachBefore(function(n){n.x=(n.x+d)*s,n.y=n.depth*v})}return n}function r(n){var r=n.children,e=n.parent.children,u=n.i?e[n.i-1]:null;if(r){H(n);var o=(r[0].z+r[r.length-1].z)/2;u?(n.z=u.z+i(n._,u._),n.m=n.z-o):n.z=o}else u&&(n.z=u.z+i(n._,u._));n.parent.A=t(n,u,n.parent.A||e[0])}function e(n){n._.x=n.z+n.parent.m,n.m+=n.parent.m}function t(n,r,e){if(r){for(var t,u=n,o=n,f=r,a=u.parent.children[0],c=u.m,h=o.m,l=f.m,p=a.m;f=F(f),u=C(u),f&&u;)a=C(a),(o=F(o)).a=n,(t=f.z+l-u.z-c+i(f._,u._))>0&&(G(J(f,n,e),n,t),c+=t,h+=t),l+=f.m,c+=u.m,p+=a.m,h+=o.m;f&&!F(o)&&(o.t=f,o.m+=l-h),u&&!C(a)&&(a.t=u,a.m+=c-p,e=n)}return e}function u(n){n.x*=o,n.y=n.depth*f}var i=$,o=1,f=1,a=null;return n.separation=function(r){return arguments.length?(i=r,n):i},n.size=function(r){return arguments.length?(a=!1,o=+r[0],f=+r[1],n):a?null:[o,f]},n.nodeSize=function(r){return arguments.length?(a=!0,o=+r[0],f=+r[1],n):a?[o,f]:null},n},wn=function(n,r,e,t,u){for(var i,o=n.children,f=-1,a=o.length,c=n.value&&(u-e)/n.value;++f1?r:1)},e}(_n),Bn=function(){function n(n){return n.x0=n.y0=0,n.x1=u,n.y1=i,n.eachBefore(r),o=[0],t&&n.eachBefore(pn),n}function r(n){var r=o[n.depth],t=n.x0+r,u=n.y0+r,i=n.x1-r,p=n.y1-r;i=r-1){var c=a[n];return c.x0=t,c.y0=u,c.x1=o,void(c.y1=f)}for(var l=h[n],p=e/2+l,d=n+1,s=r-1;d>>1;h[v]f-u){var g=(t*y+o*x)/e;i(n,d,x,t,u,g,f),i(d,r,y,g,u,o,f)}else{var m=(u*y+f*x)/e;i(n,d,x,t,u,o,m),i(d,r,y,t,m,o,f)}}var o,f,a=n.children,c=a.length,h=new Array(c+1);for(h[0]=f=o=0;o1?r:1)},e}(_n);n.cluster=U,n.hierarchy=h,n.pack=ln,n.packSiblings=cn,n.packEnclose=an,n.partition=sn,n.stratify=gn,n.tree=mn,n.treemap=Bn,n.treemapBinary=Mn,n.treemapDice=dn,n.treemapSlice=wn,n.treemapSliceDice=An,n.treemapSquarify=zn,n.treemapResquarify=qn,Object.defineProperty(n,"__esModule",{value:!0})});