import forEach_default from "../../../../lodash-es/forEach.js";
import filter_default from "../../../../lodash-es/filter.js";
import map_default from "../../../../lodash-es/map.js";
import has_default from "../../../../lodash-es/has.js";
import max_default from "../../../../lodash-es/max.js";
import range_default from "../../../../lodash-es/range.js";
import sortBy_default from "../../../../lodash-es/sortBy.js";
function initOrder(s) {
	var c = {}, l = filter_default(s.nodes(), function(e) {
		return !s.children(e).length;
	}), u = map_default(range_default(max_default(map_default(l, function(e) {
		return s.node(e).rank;
	})) + 1), function() {
		return [];
	});
	function d(o) {
		has_default(c, o) || (c[o] = !0, u[s.node(o).rank].push(o), forEach_default(s.successors(o), d));
	}
	return forEach_default(sortBy_default(l, function(e) {
		return s.node(e).rank;
	}), d), u;
}
export { initOrder };
