import e from "../../../../lodash-es/forEach.js";
import t from "../../../../lodash-es/isUndefined.js";
import n from "../../../../lodash-es/uniqueId.js";
import { Graph as r } from "../../graphlib/graph.js";
import "../../graphlib/index.js";
//#region ../../node_modules/dagre-d3-es/src/dagre/order/build-layer-graph.js
function i(n, i, o) {
	var s = a(n), c = new r({ compound: !0 }).setGraph({ root: s }).setDefaultNodeLabel(function(e) {
		return n.node(e);
	});
	return e(n.nodes(), function(r) {
		var a = n.node(r), l = n.parent(r);
		(a.rank === i || a.minRank <= i && i <= a.maxRank) && (c.setNode(r), c.setParent(r, l || s), e(n[o](r), function(e) {
			var i = e.v === r ? e.w : e.v, a = c.edge(i, r), o = t(a) ? 0 : a.weight;
			c.setEdge(i, r, { weight: n.edge(e).weight + o });
		}), Object.prototype.hasOwnProperty.call(a, "minRank") && c.setNode(r, {
			borderLeft: a.borderLeft[i],
			borderRight: a.borderRight[i]
		}));
	}), c;
}
function a(e) {
	for (var t; e.hasNode(t = n("_root")););
	return t;
}
//#endregion
export { i as buildLayerGraph };
