import { required } from "../accessors.js";
import constant_default, { constantZero } from "../constant.js";
import round_default from "./round.js";
import squarify_default from "./squarify.js";
function treemap_default() {
	var a = squarify_default, o = !1, s = 1, c = 1, l = [0], u = constantZero, d = constantZero, f = constantZero, p = constantZero, m = constantZero;
	function h(e) {
		return e.x0 = e.y0 = 0, e.x1 = s, e.y1 = c, e.eachBefore(g), l = [0], o && e.eachBefore(round_default), e;
	}
	function g(e) {
		var t = l[e.depth], n = e.x0 + t, r = e.y0 + t, i = e.x1 - t, o = e.y1 - t;
		i < n && (n = i = (n + i) / 2), o < r && (r = o = (r + o) / 2), e.x0 = n, e.y0 = r, e.x1 = i, e.y1 = o, e.children && (t = l[e.depth + 1] = u(e) / 2, n += m(e) - t, r += d(e) - t, i -= f(e) - t, o -= p(e) - t, i < n && (n = i = (n + i) / 2), o < r && (r = o = (r + o) / 2), a(e, n, r, i, o));
	}
	return h.round = function(e) {
		return arguments.length ? (o = !!e, h) : o;
	}, h.size = function(e) {
		return arguments.length ? (s = +e[0], c = +e[1], h) : [s, c];
	}, h.tile = function(t) {
		return arguments.length ? (a = required(t), h) : a;
	}, h.padding = function(e) {
		return arguments.length ? h.paddingInner(e).paddingOuter(e) : h.paddingInner();
	}, h.paddingInner = function(e) {
		return arguments.length ? (u = typeof e == "function" ? e : constant_default(+e), h) : u;
	}, h.paddingOuter = function(e) {
		return arguments.length ? h.paddingTop(e).paddingRight(e).paddingBottom(e).paddingLeft(e) : h.paddingTop();
	}, h.paddingTop = function(e) {
		return arguments.length ? (d = typeof e == "function" ? e : constant_default(+e), h) : d;
	}, h.paddingRight = function(e) {
		return arguments.length ? (f = typeof e == "function" ? e : constant_default(+e), h) : f;
	}, h.paddingBottom = function(e) {
		return arguments.length ? (p = typeof e == "function" ? e : constant_default(+e), h) : p;
	}, h.paddingLeft = function(e) {
		return arguments.length ? (m = typeof e == "function" ? e : constant_default(+e), h) : m;
	}, h;
}
export { treemap_default as default };
