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