import e from "../../../../lodash-es/map.js";
import t from "../../../../lodash-es/flatten.js";
import n from "../../../../lodash-es/forEach.js";
import r from "../../../../lodash-es/sortBy.js";
import i from "../../../../lodash-es/zipObject.js";
//#region ../../node_modules/dagre-d3-es/src/dagre/order/cross-count.js
function a(e, t) {
	for (var n = 0, r = 1; r < t.length; ++r) n += o(e, t[r - 1], t[r]);
	return n;
}
function o(a, o, s) {
	for (var c = i(s, e(s, function(e, t) {
		return t;
	})), l = t(e(o, function(t) {
		return r(e(a.outEdges(t), function(e) {
			return {
				pos: c[e.w],
				weight: a.edge(e).weight
			};
		}), "pos");
	})), u = 1; u < s.length;) u <<= 1;
	var d = 2 * u - 1;
	--u;
	var f = e(Array(d), function() {
		return 0;
	}), p = 0;
	return n(l.forEach(function(e) {
		var t = e.pos + u;
		f[t] += e.weight;
		for (var n = 0; t > 0;) t % 2 && (n += f[t + 1]), t = t - 1 >> 1, f[t] += e.weight;
		p += e.weight * n;
	})), p;
}
//#endregion
export { a as crossCount };
