import v from "../../../../../lodash-es@4.17.22/node_modules/lodash-es/forEach.js";
function w(n) {
  var e = m(n);
  v(n.graph().dummyChains, function(r) {
    for (var i = n.node(r), l = i.edgeObj, h = d(n, e, l.v, l.w), c = h.path, o = h.lca, a = 0, t = c[a], f = !0; r !== l.w; ) {
      if (i = n.node(r), f) {
        for (; (t = c[a]) !== o && n.node(t).maxRank < i.rank; )
          a++;
        t === o && (f = !1);
      }
      if (!f) {
        for (; a < c.length - 1 && n.node(t = c[a + 1]).minRank <= i.rank; )
          a++;
        t = c[a];
      }
      n.setParent(r, t), r = n.successors(r)[0];
    }
  });
}
function d(n, e, r, i) {
  var l = [], h = [], c = Math.min(e[r].low, e[i].low), o = Math.max(e[r].lim, e[i].lim), a, t;
  a = r;
  do
    a = n.parent(a), l.push(a);
  while (a && (e[a].low > c || o > e[a].lim));
  for (t = a, a = i; (a = n.parent(a)) !== t; )
    h.push(a);
  return { path: l.concat(h.reverse()), lca: t };
}
function m(n) {
  var e = {}, r = 0;
  function i(l) {
    var h = r;
    v(n.children(l), i), e[l] = { low: h, lim: r++ };
  }
  return v(n.children(), i), e;
}
export {
  w as parentDummyChains
};
