import e from "../../../../lodash-es/map.js";
import t from "../../../../lodash-es/filter.js";
import n from "../../../../lodash-es/forEach.js";
import r from "../../../../lodash-es/isUndefined.js";
import i from "../../../../lodash-es/pick.js";
//#region ../../node_modules/dagre-d3-es/src/dagre/order/resolve-conflicts.js
function a(e, i) {
	var a = {};
	return n(e, function(e, t) {
		var n = a[e.v] = {
			indegree: 0,
			in: [],
			out: [],
			vs: [e.v],
			i: t
		};
		r(e.barycenter) || (n.barycenter = e.barycenter, n.weight = e.weight);
	}), n(i.edges(), function(e) {
		var t = a[e.v], n = a[e.w];
		!r(t) && !r(n) && (n.indegree++, t.out.push(a[e.w]));
	}), o(t(a, function(e) {
		return !e.indegree;
	}));
}
function o(a) {
	var o = [];
	function c(e) {
		return function(t) {
			t.merged || (r(t.barycenter) || r(e.barycenter) || t.barycenter >= e.barycenter) && s(e, t);
		};
	}
	function l(e) {
		return function(t) {
			t.in.push(e), --t.indegree === 0 && a.push(t);
		};
	}
	for (; a.length;) {
		var u = a.pop();
		o.push(u), n(u.in.reverse(), c(u)), n(u.out, l(u));
	}
	return e(t(o, function(e) {
		return !e.merged;
	}), function(e) {
		return i(e, [
			"vs",
			"i",
			"barycenter",
			"weight"
		]);
	});
}
function s(e, t) {
	var n = 0, r = 0;
	e.weight && (n += e.barycenter * e.weight, r += e.weight), t.weight && (n += t.barycenter * t.weight, r += t.weight), e.vs = t.vs.concat(e.vs), e.barycenter = n / r, e.weight = r, e.i = Math.min(t.i, e.i), t.merged = !0;
}
//#endregion
export { a as resolveConflicts };
