import dice_default from "./dice.js";
import slice_default from "./slice.js";
var phi = (1 + Math.sqrt(5)) / 2;
function squarifyRatio(n, r, i, a, o, s) {
	for (var c = [], l = r.children, u, d, f = 0, p = 0, m = l.length, h, g, _ = r.value, v, y, b, x, S, C, w; f < m;) {
		h = o - i, g = s - a;
		do
			v = l[p++].value;
		while (!v && p < m);
		for (y = b = v, C = Math.max(g / h, h / g) / (_ * n), w = v * v * C, S = Math.max(b / w, w / y); p < m; ++p) {
			if (v += d = l[p].value, d < y && (y = d), d > b && (b = d), w = v * v * C, x = Math.max(b / w, w / y), x > S) {
				v -= d;
				break;
			}
			S = x;
		}
		c.push(u = {
			value: v,
			dice: h < g,
			children: l.slice(f, p)
		}), u.dice ? dice_default(u, i, a, o, _ ? a += g * v / _ : s) : slice_default(u, i, a, _ ? i += h * v / _ : o, s), _ -= v, f = p;
	}
	return c;
}
var squarify_default = (function e(t) {
	function n(e, n, i, a, o) {
		squarifyRatio(t, e, n, i, a, o);
	}
	return n.ratio = function(t) {
		return e((t = +t) > 1 ? t : 1);
	}, n;
})(phi);
export { squarify_default as default };
