import e from "../../../lodash-es/map.js";
import t from "../../../lodash-es/min.js";
import n from "../../../lodash-es/forEach.js";
import r from "../../../lodash-es/now.js";
import i from "../../../lodash-es/has.js";
import a from "../../../lodash-es/isUndefined.js";
import o from "../../../lodash-es/max.js";
import s from "../../../lodash-es/range.js";
import c from "../../../lodash-es/uniqueId.js";
import { Graph as l } from "../graphlib/graph.js";
import "../graphlib/index.js";
//#region ../../node_modules/dagre-d3-es/src/dagre/util.js
function u(e, t, n, r) {
	var i;
	do
		i = c(r);
	while (e.hasNode(i));
	return n.dummy = t, e.setNode(i, n), i;
}
function d(e) {
	var t = new l().setGraph(e.graph());
	return n(e.nodes(), function(n) {
		t.setNode(n, e.node(n));
	}), n(e.edges(), function(n) {
		var r = t.edge(n.v, n.w) || {
			weight: 0,
			minlen: 1
		}, i = e.edge(n);
		t.setEdge(n.v, n.w, {
			weight: r.weight + i.weight,
			minlen: Math.max(r.minlen, i.minlen)
		});
	}), t;
}
function f(e) {
	var t = new l({ multigraph: e.isMultigraph() }).setGraph(e.graph());
	return n(e.nodes(), function(n) {
		e.children(n).length || t.setNode(n, e.node(n));
	}), n(e.edges(), function(n) {
		t.setEdge(n, e.edge(n));
	}), t;
}
function p(e, t) {
	var n = e.x, r = e.y, i = t.x - n, a = t.y - r, o = e.width / 2, s = e.height / 2;
	if (!i && !a) throw Error("Not possible to find intersection inside of the rectangle");
	var c, l;
	return Math.abs(a) * o > Math.abs(i) * s ? (a < 0 && (s = -s), c = s * i / a, l = s) : (i < 0 && (o = -o), c = o, l = o * a / i), {
		x: n + c,
		y: r + l
	};
}
function m(t) {
	var r = e(s(v(t) + 1), function() {
		return [];
	});
	return n(t.nodes(), function(e) {
		var n = t.node(e), i = n.rank;
		a(i) || (r[i][n.order] = e);
	}), r;
}
function h(r) {
	var a = t(e(r.nodes(), function(e) {
		return r.node(e).rank;
	}));
	n(r.nodes(), function(e) {
		var t = r.node(e);
		i(t, "rank") && (t.rank -= a);
	});
}
function g(r) {
	var i = t(e(r.nodes(), function(e) {
		return r.node(e).rank;
	})), o = [];
	n(r.nodes(), function(e) {
		var t = r.node(e).rank - i;
		o[t] || (o[t] = []), o[t].push(e);
	});
	var s = 0, c = r.graph().nodeRankFactor;
	n(o, function(e, t) {
		a(e) && t % c !== 0 ? --s : s && n(e, function(e) {
			r.node(e).rank += s;
		});
	});
}
function _(e, t, n, r) {
	var i = {
		width: 0,
		height: 0
	};
	return arguments.length >= 4 && (i.rank = n, i.order = r), u(e, "border", i, t);
}
function v(t) {
	return o(e(t.nodes(), function(e) {
		var n = t.node(e).rank;
		if (!a(n)) return n;
	}));
}
function y(e, t) {
	var r = {
		lhs: [],
		rhs: []
	};
	return n(e, function(e) {
		t(e) ? r.lhs.push(e) : r.rhs.push(e);
	}), r;
}
function b(e, t) {
	var n = r();
	try {
		return t();
	} finally {
		console.log(e + " time: " + (r() - n) + "ms");
	}
}
function x(e, t) {
	return t();
}
//#endregion
export { _ as addBorderNode, u as addDummyNode, f as asNonCompoundGraph, m as buildLayerMatrix, p as intersectRect, v as maxRank, h as normalizeRanks, x as notime, y as partition, g as removeEmptyRanks, d as simplify, b as time };
