text: // https://d3js.org/d3-hierarchy/ Version 1.1.6. Copyright 2018 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 e(n,r){return n.parent===r.parent?1:2}function l(n,r){return n+r.x}function p(n,r){return Math.max(n,r.y)}function r(n){var r=0,e=n.children,t=e&&e.length;if(t)for(;0<=--t;)r+=e[t].value;else r=1;n.value=r}function t(n,r){var e,t,u,i,o,a=new s(n),f=+n.value&&(a.value=n.value),c=[a];for(null==r&&(r=h);e=c.pop();)if(f&&(e.value=+e.data.value),(u=r(e.data))&&(o=u.length))for(e.children=new Array(o),i=o-1;0<=i;--i)c.push(t=e.children[i]=new s(u[i])),t.parent=e,t.depth=e.depth+1;return a.eachBefore(d)}function h(n){return n.children}function u(n){n.data=n.data.data}function d(n){for(var r=0;n.height=r,(n=n.parent)&&n.height<++r;);}function s(n){this.data=n,this.depth=this.height=0,this.parent=null}s.prototype=t.prototype={constructor:s,count:function(){return this.eachAfter(r)},each:function(n){var r,e,t,u,i=this,o=[i];do{for(r=o.reverse(),o=[];i=r.pop();)if(n(i),e=i.children)for(t=0,u=e.length;t<u;++t)o.push(e[t])}while(o.length);return this},eachAfter: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<t;++e)i.push(r[e]);for(;u=o.pop();)n(u);return this},eachBefore:function(n){for(var r,e,t=this,u=[t];t=u.pop();)if(n(t),r=t.children)for(e=r.length-1;0<=e;--e)u.push(r[e]);return this},sum:function(u){return this.eachAfter(function(n){for(var r=+u(n.data)||0,e=n.children,t=e&&e.length;0<=--t;)r+=e[t].value;n.value=r})},sort:function(r){return this.eachBefore(function(n){n.children&&n.children.sort(r)})},path:function(n){for(var r=this,e=function(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}(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},ancestors:function(){for(var n=this,r=[n];n=n.parent;)r.push(n);return r},descendants:function(){var r=[];return this.each(function(n){r.push(n)}),r},leaves:function(){var r=[];return this.eachBefore(function(n){n.children||r.push(n)}),r},links:function(){var r=this,e=[];return r.each(function(n){n!==r&&e.push({source:n.parent,target:n})}),e},copy:function(){return t(this).eachBefore(u)}};var o=Array.prototype.slice;var v=function(n){for(var r,e,t=0,u=(n=function(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}(o.call(n))).length,i=[];t<u;)r=n[t],e&&f(e,r)?++t:(e=x(i=a(i,r)),t=0);return e};function a(n,r){var e,t;if(c(r,n))return[r];for(e=0;e<n.length;++e)if(i(r,n[e])&&c(y(n[e],r),n))return[n[e],r];for(e=0;e<n.length-1;++e)for(t=e+1;t<n.length;++t)if(i(y(n[e],n[t]),r)&&i(y(n[e],r),n[t])&&i(y(n[t],r),n[e])&&c(g(n[e],n[t],r),n))return[n[e],n[t],r];throw new Error}function i(n,r){var e=n.r-r.r,t=r.x-n.x,u=r.y-n.y;return e<0||e*e<t*t+u*u}function f(n,r){var e=n.r-r.r+1e-6,t=r.x-n.x,u=r.y-n.y;return 0<e&&t*t+u*u<e*e}function c(n,r){for(var e=0;e<r.length;++e)if(!f(n,r[e]))return!1;return!0}function x(n){switch(n.length){case 1:return{x:(r=n[0]).x,y:r.y,r:r.r};case 2:return y(n[0],n[1]);case 3:return g(n[0],n[1],n[2])}var r}function y(n,r){var e=n.x,t=n.y,u=n.r,i=r.x,o=r.y,a=r.r,f=i-e,c=o-t,h=a-u,l=Math.sqrt(f*f+c*c);return{x:(e+i+f/l*h)/2,y:(t+o+c/l*h)/2,r:(l+u+a)/2}}function g(n,r,e){var t=n.x,u=n.y,i=n.r,o=r.x,a=r.y,f=r.r,c=e.x,h=e.y,l=e.r,p=t-o,d=t-c,s=u-a,v=u-h,x=f-i,y=l-i,g=t*t+u*u-i*i,m=g-o*o-a*a+f*f,w=g-c*c-h*h+l*l,_=d*s-p*v,z=(s*w-v*m)/(2*_)-t,B=(v*x-s*y)/_,M=(d*m-p*w)/(2*_)-u,A=(p*y-d*x)/_,q=B*B+A*A-1,E=2*(i+z*B+M*A),b=z*z+M*M-i*i,S=-(q?(E+Math.sqrt(E*E-4*q*b))/(2*q):b/E);return{x:t+z+B*S,y:u+M+A*S,r:S}}function m(n,r,e){var t,u,i,o,a=n.x-r.x,f=n.y-r.y,c=a*a+f*f;c?(u=r.r+e.r,u*=u,o=n.r+e.r,(o*=o)<u?(t=(c+o-u)/(2*c),i=Math.sqrt(Math.max(0,o/c-t*t)),e.x=n.x-t*a-i*f,e.y=n.y-t*f+i*a):(t=(c+u-o)/(2*c),i=Math.sqrt(Math.max(0,u/c-t*t)),e.x=r.x+t*a-i*f,e.y=r.y+t*f+i*a)):(e.x=r.x+e.r,e.y=r.y)}function w(n,r){var e=n.r+r.r-1e-6,t=r.x-n.x,u=r.y-n.y;return 0<e&&t*t+u*u<e*e}function _(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 z(n){this._=n,this.next=null,this.previous=null}function B(n){if(!(u=n.length))return 0;var r,e,t,u,i,o,a,f,c,h,l;if((r=n[0]).x=0,r.y=0,!(1<u))return r.r;if(e=n[1],r.x=-e.r,e.x=r.r,e.y=0,!(2<u))return r.r+e.r;m(e,r,t=n[2]),r=new z(r),e=new z(e),t=new z(t),r.next=t.previous=e,e.next=r.previous=t,t.next=e.previous=r;n:for(a=3;a<u;++a){m(r._,e._,t=n[a]),t=new z(t),f=e.next,c=r.previous,h=e._.r,l=r._.r;do{if(h<=l){if(w(f._,t._)){e=f,(r.next=e).previous=r,--a;continue n}h+=f._.r,f=f.next}else{if(w(c._,t._)){((r=c).next=e).previous=r,--a;continue n}l+=c._.r,c=c.previous}}while(f!==c.next);for(t.previous=r,t.next=e,r.next=e.previous=e=t,i=_(r);(t=t.next)!==e;)(o=_(t))<i&&(r=t,i=o);e=r.next}for(r=[e._],t=e;(t=t.next)!==e;)r.push(t._);for(t=v(r),a=0;a<u;++a)(r=n[a]).x-=t.x,r.y-=t.y;return t.r}function M(n){if("function"!=typeof n)throw new Error;return n}function A(){return 0}var q=function(n){return function(){return n}};function E(n){return Math.sqrt(n.value)}function b(r){return function(n){n.children||(n.r=Math.max(0,+r(n)||0))}}function S(o,a){return function(n){if(r=n.children){var r,e,t,u=r.length,i=o(n)*a||0;if(i)for(e=0;e<u;++e)r[e].r+=i;if(t=B(r),i)for(e=0;e<u;++e)r[e].r-=i;n.r=t+i}}}function k(e){return function(n){var r=n.parent;n.r*=e,r&&(n.x=r.x+e*n.x,n.y=r.y+e*n.y)}}var I=function(n){n.x0=Math.round(n.x0),n.y0=Math.round(n.y0),n.x1=Math.round(n.x1),n.y1=Math.round(n.y1)},O=function(n,r,e,t,u){for(var i,o=n.children,a=-1,f=o.length,c=n.value&&(t-r)/n.value;++a<f;)(i=o[a]).y0=e,i.y1=u,i.x0=r,i.x1=r+=i.value*c},j="$",R={depth:-1},T={};function D(n){return n.id}function L(n){return n.parentId}function P(n,r){return n.parent===r.parent?1:2}function $(n){var r=n.children;return r?r[0]:n.t}function C(n){var r=n.children;return r?r[r.length-1]:n.t}function F(n,r){this._=n,this.parent=null,this.children=null,this.A=null,(this.a=this).z=0,this.m=0,this.c=0,this.s=0,this.t=null,this.i=r}F.prototype=Object.create(s.prototype);var G=function(n,r,e,t,u){for(var i,o=n.children,a=-1,f=o.length,c=n.value&&(u-e)/n.value;++a<f;)(i=o[a]).x0=r,i.x1=t,i.y0=e,i.y1=e+=i.value*c},H=(1+Math.sqrt(5))/2;function J(n,r,e,t,u,i){for(var o,a,f,c,h,l,p,d,s,v,x,y=[],g=r.children,m=0,w=0,_=g.length,z=r.value;m<_;){for(f=u-e,c=i-t;!(h=g[w++].value)&&w<_;);for(l=p=h,x=h*h*(v=Math.max(c/f,f/c)/(z*n)),s=Math.max(p/x,x/l);w<_;++w){if(h+=a=g[w].value,a<l&&(l=a),p<a&&(p=a),x=h*h*v,s<(d=Math.max(p/x,x/l))){h-=a;break}s=d}y.push(o={value:h,dice:f<c,children:g.slice(m,w)}),o.dice?O(o,e,t,u,z?t+=c*h/z:i):G(o,e,t,z?e+=f*h/z:u,i),z-=h,m=w}return y}var K=function r(i){function n(n,r,e,t,u){J(i,n,r,e,t,u)}return n.ratio=function(n){return r(1<(n=+n)?n:1)},n}(H),N=function r(d){function n(n,r,e,t,u){if((i=n._squarify)&&i.ratio===d)for(var i,o,a,f,c,h=-1,l=i.length,p=n.value;++h<l;){for(a=(o=i[h]).children,f=o.value=0,c=a.length;f<c;++f)o.value+=a[f].value;o.dice?O(o,r,e,t,e+=(u-e)*o.value/p):G(o,r,e,r+=(t-r)*o.value/p,u),p-=o.value}else n._squarify=i=J(d,n,r,e,t,u),i.ratio=d}return n.ratio=function(n){return r(1<(n=+n)?n:1)},n}(H);n.cluster=function(){var a=e,f=1,c=1,h=!1;function r(r){var t,u=0;r.eachAfter(function(n){var r,e=n.children;e?(n.x=(r=e).reduce(l,0)/r.length,n.y=1+e.reduce(p,0)):(n.x=t?u+=a(n,t):0,n.y=0,t=n)});var n=function(n){for(var r;r=n.children;)n=r[0];return n}(r),e=function(n){for(var r;r=n.children;)n=r[r.length-1];return n}(r),i=n.x-a(n,e)/2,o=e.x+a(e,n)/2;return r.eachAfter(h?function(n){n.x=(n.x-r.x)*f,n.y=(r.y-n.y)*c}:function(n){n.x=(n.x-i)/(o-i)*f,n.y=(1-(r.y?n.y/r.y:1))*c})}return r.separation=function(n){return arguments.length?(a=n,r):a},r.size=function(n){return arguments.length?(h=!1,f=+n[0],c=+n[1],r):h?null:[f,c]},r.nodeSize=function(n){return arguments.length?(h=!0,f=+n[0],c=+n[1],r):h?[f,c]:null},r},n.hierarchy=t,n.pack=function(){var e=null,r=1,t=1,u=A;function i(n){return n.x=r/2,n.y=t/2,e?n.eachBefore(b(e)).eachAfter(S(u,.5)).eachBefore(k(1)):n.eachBefore(b(E)).eachAfter(S(A,1)).eachAfter(S(u,n.r/Math.min(r,t))).eachBefore(k(Math.min(r,t)/(2*n.r))),n}return i.radius=function(n){return arguments.length?(e=null==(r=n)?null:M(r),i):e;var r},i.size=function(n){return arguments.length?(r=+n[0],t=+n[1],i):[r,t]},i.padding=function(n){return arguments.length?(u="function"==typeof n?n:q(+n),i):u},i},n.packSiblings=function(n){return B(n),n},n.packEnclose=v,n.partition=function(){var e=1,t=1,a=0,u=!1;function r(n){var i,o,r=n.height+1;return n.x0=n.y0=a,n.x1=e,n.y1=t/r,n.eachBefore((i=t,o=r,function(n){n.children&&O(n,n.x0,i*(n.depth+1)/o,n.x1,i*(n.depth+2)/o);var r=n.x0,e=n.y0,t=n.x1-a,u=n.y1-a;t<r&&(r=t=(r+t)/2),u<e&&(e=u=(e+u)/2),n.x0=r,n.y0=e,n.x1=t,n.y1=u})),u&&n.eachBefore(I),n}return r.round=function(n){return arguments.length?(u=!!n,r):u},r.size=function(n){return arguments.length?(e=+n[0],t=+n[1],r):[e,t]},r.padding=function(n){return arguments.length?(a=+n,r):a},r},n.stratify=function(){var l=D,p=L;function r(n){var r,e,t,u,i,o,a,f=n.length,c=new Array(f),h={};for(e=0;e<f;++e)r=n[e],i=c[e]=new s(r),null!=(o=l(r,e,n))&&(o+="")&&(h[a=j+(i.id=o)]=a in h?T:i);for(e=0;e<f;++e)if(i=c[e],null!=(o=p(n[e],e,n))&&(o+="")){if(!(u=h[j+o]))throw new Error("missing: "+o);if(u===T)throw new Error("ambiguous: "+o);u.children?u.children.push(i):u.children=[i],i.parent=u}else{if(t)throw new Error("multiple roots");t=i}if(!t)throw new Error("no root");if(t.parent=R,t.eachBefore(function(n){n.depth=n.parent.depth+1,--f}).eachBefore(d),t.parent=null,0<f)throw new Error("cycle");return t}return r.id=function(n){return arguments.length?(l=M(n),r):l},r.parentId=function(n){return arguments.length?(p=M(n),r):p},r},n.tree=function(){var m=P,c=1,h=1,l=null;function r(n){var r=function(n){for(var r,e,t,u,i,o=new F(n,0),a=[o];r=a.pop();)if(t=r._.children)for(r.children=new Array(i=t.length),u=i-1;0<=u;--u)a.push(e=r.children[u]=new F(t[u],u)),e.parent=r;return(o.parent=new F(null,0)).children=[o],o}(n);if(r.eachAfter(p),r.parent.m=-r.z,r.eachBefore(d),l)n.eachBefore(s);else{var e=n,t=n,u=n;n.eachBefore(function(n){n.x<e.x&&(e=n),n.x>t.x&&(t=n),n.depth>u.depth&&(u=n)});var i=e===t?1:m(e,t)/2,o=i-e.x,a=c/(t.x+i+o),f=h/(u.depth||1);n.eachBefore(function(n){n.x=(n.x+o)*a,n.y=n.depth*f})}return n}function p(n){var r=n.children,e=n.parent.children,t=n.i?e[n.i-1]:null;if(r){!function(n){for(var r,e=0,t=0,u=n.children,i=u.length;0<=--i;)(r=u[i]).z+=e,r.m+=e,e+=r.s+(t+=r.c)}(n);var u=(r[0].z+r[r.length-1].z)/2;t?(n.z=t.z+m(n._,t._),n.m=n.z-u):n.z=u}else t&&(n.z=t.z+m(n._,t._));n.parent.A=function(n,r,e){if(r){for(var t,u=n,i=n,o=r,a=u.parent.children[0],f=u.m,c=i.m,h=o.m,l=a.m;o=C(o),u=$(u),o&&u;)a=$(a),(i=C(i)).a=n,0<(t=o.z+h-u.z-f+m(o._,u._))&&(y=n,g=e,p=(x=o).a.parent===y.parent?x.a:g,v=(s=t)/((d=n).i-p.i),d.c-=v,d.s+=s,p.c+=v,d.z+=s,d.m+=s,f+=t,c+=t),h+=o.m,f+=u.m,l+=a.m,c+=i.m;o&&!C(i)&&(i.t=o,i.m+=h-c),u&&!$(a)&&(a.t=u,a.m+=f-l,e=n)}var p,d,s,v,x,y,g;return e}(n,t,n.parent.A||e[0])}function d(n){n._.x=n.z+n.parent.m,n.m+=n.parent.m}function s(n){n.x*=c,n.y=n.depth*h}return r.separation=function(n){return arguments.length?(m=n,r):m},r.size=function(n){return arguments.length?(l=!1,c=+n[0],h=+n[1],r):l?null:[c,h]},r.nodeSize=function(n){return arguments.length?(l=!0,c=+n[0],h=+n[1],r):l?[c,h]:null},r},n.treemap=function(){var o=K,r=!1,e=1,t=1,a=[0],f=A,c=A,h=A,l=A,p=A;function u(n){return n.x0=n.y0=0,n.x1=e,n.y1=t,n.eachBefore(i),a=[0],r&&n.eachBefore(I),n}function i(n){var r=a[n.depth],e=n.x0+r,t=n.y0+r,u=n.x1-r,i=n.y1-r;u<e&&(e=u=(e+u)/2),i<t&&(t=i=(t+i)/2),n.x0=e,n.y0=t,n.x1=u,n.y1=i,n.children&&(r=a[n.depth+1]=f(n)/2,e+=p(n)-r,t+=c(n)-r,(u-=h(n)-r)<e&&(e=u=(e+u)/2),(i-=l(n)-r)<t&&(t=i=(t+i)/2),o(n,e,t,u,i))}return u.round=function(n){return arguments.length?(r=!!n,u):r},u.size=function(n){return arguments.length?(e=+n[0],t=+n[1],u):[e,t]},u.tile=function(n){return arguments.length?(o=M(n),u):o},u.padding=function(n){return arguments.length?u.paddingInner(n).paddingOuter(n):u.paddingInner()},u.paddingInner=function(n){return arguments.length?(f="function"==typeof n?n:q(+n),u):f},u.paddingOuter=function(n){return arguments.length?u.paddingTop(n).paddingRight(n).paddingBottom(n).paddingLeft(n):u.paddingTop()},u.paddingTop=function(n){return arguments.length?(c="function"==typeof n?n:q(+n),u):c},u.paddingRight=function(n){return arguments.length?(h="function"==typeof n?n:q(+n),u):h},u.paddingBottom=function(n){return arguments.length?(l="function"==typeof n?n:q(+n),u):l},u.paddingLeft=function(n){return arguments.length?(p="function"==typeof n?n:q(+n),u):p},u},n.treemapBinary=function(n,r,e,t,u){var i,o,g=n.children,a=g.length,m=new Array(a+1);for(m[0]=o=i=0;i<a;++i)m[i+1]=o+=g[i].value;!function n(r,e,t,u,i,o,a){if(e-1<=r){var f=g[r];return f.x0=u,f.y0=i,f.x1=o,void(f.y1=a)}for(var c=m[r],h=t/2+c,l=r+1,p=e-1;l<p;){var d=l+p>>>1;m[d]<h?l=d+1:p=d}h-m[l-1]<m[l]-h&&r+1<l&&--l;var s=m[l]-c,v=t-s;if(a-i<o-u){var x=(u*v+o*s)/t;n(r,l,s,u,i,x,a),n(l,e,v,x,i,o,a)}else{var y=(i*v+a*s)/t;n(r,l,s,u,i,o,y),n(l,e,v,u,y,o,a)}}(0,a,n.value,r,e,t,u)},n.treemapDice=O,n.treemapSlice=G,n.treemapSliceDice=function(n,r,e,t,u){(1&n.depth?G:O)(n,r,e,t,u)},n.treemapSquarify=K,n.treemapResquarify=N,Object.defineProperty(n,"__esModule",{value:!0})});