function e(e){var t=0,n=e.children,r=n&&n.length;if(!r)t=1;else for(;--r>=0;)t+=n[r].value;e.value=t}function t(){return this.eachAfter(e)}function n(e,t){let n=-1;for(let r of this)e.call(t,r,++n,this);return this}function r(e,t){for(var n=this,r=[n],i,a,o=-1;n=r.pop();)if(e.call(t,n,++o,this),i=n.children)for(a=i.length-1;a>=0;--a)r.push(i[a]);return this}function i(e,t){for(var n=this,r=[n],i=[],a,o,s,c=-1;n=r.pop();)if(i.push(n),a=n.children)for(o=0,s=a.length;o<s;++o)r.push(a[o]);for(;n=i.pop();)e.call(t,n,++c,this);return this}function a(e,t){let n=-1;for(let r of this)if(e.call(t,r,++n,this))return r}function o(e){return this.eachAfter(function(t){for(var n=+e(t.data)||0,r=t.children,i=r&&r.length;--i>=0;)n+=r[i].value;t.value=n})}function s(e){return this.eachBefore(function(t){t.children&&t.children.sort(e)})}function c(e){for(var t=this,n=l(t,e),r=[t];t!==n;)t=t.parent,r.push(t);for(var i=r.length;e!==n;)r.splice(i,0,e),e=e.parent;return r}function l(e,t){if(e===t)return e;var n=e.ancestors(),r=t.ancestors(),i=null;for(e=n.pop(),t=r.pop();e===t;)i=e,e=n.pop(),t=r.pop();return i}function u(){for(var e=this,t=[e];e=e.parent;)t.push(e);return t}function d(){return Array.from(this)}function f(){var e=[];return this.eachBefore(function(t){t.children||e.push(t)}),e}function p(){var e=this,t=[];return e.each(function(n){n!==e&&t.push({source:n.parent,target:n})}),t}function*m(){var e=this,t,n=[e],r,i,a;do for(t=n.reverse(),n=[];e=t.pop();)if(yield e,r=e.children)for(i=0,a=r.length;i<a;++i)n.push(r[i]);while(n.length)}function h(e,t){e instanceof Map?(e=[void 0,e],t===void 0&&(t=v)):t===void 0&&(t=_);for(var n=new x(e),r,i=[n],a,o,s,c;r=i.pop();)if((o=t(r.data))&&(c=(o=Array.from(o)).length))for(r.children=o,s=c-1;s>=0;--s)i.push(a=o[s]=new x(o[s])),a.parent=r,a.depth=r.depth+1;return n.eachBefore(b)}function g(){return h(this).eachBefore(y)}function _(e){return e.children}function v(e){return Array.isArray(e)?e[1]:null}function y(e){e.data.value!==void 0&&(e.value=e.data.value),e.data=e.data.data}function b(e){var t=0;do e.height=t;while((e=e.parent)&&e.height<++t)}function x(e){this.data=e,this.depth=this.height=0,this.parent=null}x.prototype=h.prototype={constructor:x,count:t,each:n,eachAfter:i,eachBefore:r,find:a,sum:o,sort:s,path:c,ancestors:u,descendants:d,leaves:f,links:p,copy:g,[Symbol.iterator]:m};function S(e){return e==null?null:C(e)}function C(e){if(typeof e!=`function`)throw Error();return e}function w(){return 0}function T(e){return function(){return e}}function E(e){e.x0=Math.round(e.x0),e.y0=Math.round(e.y0),e.x1=Math.round(e.x1),e.y1=Math.round(e.y1)}function D(e,t,n,r,i){for(var a=e.children,o,s=-1,c=a.length,l=e.value&&(r-t)/e.value;++s<c;)o=a[s],o.y0=n,o.y1=i,o.x0=t,o.x1=t+=o.value*l}function O(e,t,n,r,i){for(var a=e.children,o,s=-1,c=a.length,l=e.value&&(i-n)/e.value;++s<c;)o=a[s],o.x0=t,o.x1=r,o.y0=n,o.y1=n+=o.value*l}var k=(1+Math.sqrt(5))/2;function A(e,t,n,r,i,a){for(var o=[],s=t.children,c,l,u=0,d=0,f=s.length,p,m,h=t.value,g,_,v,y,b,x,S;u<f;){p=i-n,m=a-r;do g=s[d++].value;while(!g&&d<f);for(_=v=g,x=Math.max(m/p,p/m)/(h*e),S=g*g*x,b=Math.max(v/S,S/_);d<f;++d){if(g+=l=s[d].value,l<_&&(_=l),l>v&&(v=l),S=g*g*x,y=Math.max(v/S,S/_),y>b){g-=l;break}b=y}o.push(c={value:g,dice:p<m,children:s.slice(u,d)}),c.dice?D(c,n,r,i,h?r+=m*g/h:a):O(c,n,r,h?n+=p*g/h:i,a),h-=g,u=d}return o}var j=(function e(t){function n(e,n,r,i,a){A(t,e,n,r,i,a)}return n.ratio=function(t){return e((t=+t)>1?t:1)},n})(k);function M(){var e=j,t=!1,n=1,r=1,i=[0],a=w,o=w,s=w,c=w,l=w;function u(e){return e.x0=e.y0=0,e.x1=n,e.y1=r,e.eachBefore(d),i=[0],t&&e.eachBefore(E),e}function d(t){var n=i[t.depth],r=t.x0+n,u=t.y0+n,d=t.x1-n,f=t.y1-n;d<r&&(r=d=(r+d)/2),f<u&&(u=f=(u+f)/2),t.x0=r,t.y0=u,t.x1=d,t.y1=f,t.children&&(n=i[t.depth+1]=a(t)/2,r+=l(t)-n,u+=o(t)-n,d-=s(t)-n,f-=c(t)-n,d<r&&(r=d=(r+d)/2),f<u&&(u=f=(u+f)/2),e(t,r,u,d,f))}return u.round=function(e){return arguments.length?(t=!!e,u):t},u.size=function(e){return arguments.length?(n=+e[0],r=+e[1],u):[n,r]},u.tile=function(t){return arguments.length?(e=C(t),u):e},u.padding=function(e){return arguments.length?u.paddingInner(e).paddingOuter(e):u.paddingInner()},u.paddingInner=function(e){return arguments.length?(a=typeof e==`function`?e:T(+e),u):a},u.paddingOuter=function(e){return arguments.length?u.paddingTop(e).paddingRight(e).paddingBottom(e).paddingLeft(e):u.paddingTop()},u.paddingTop=function(e){return arguments.length?(o=typeof e==`function`?e:T(+e),u):o},u.paddingRight=function(e){return arguments.length?(s=typeof e==`function`?e:T(+e),u):s},u.paddingBottom=function(e){return arguments.length?(c=typeof e==`function`?e:T(+e),u):c},u.paddingLeft=function(e){return arguments.length?(l=typeof e==`function`?e:T(+e),u):l},u}export{O as a,w as c,x as d,b as f,j as i,T as l,k as n,D as o,h as p,A as r,E as s,M as t,S as u};