import { visitParents } from "../unist-util-visit-parents/lib-index.js";
import { CONTINUE, EXIT, SKIP } from "../unist-util-visit-parents/lib-index.js";
function visit(tree, testOrVisitor, visitorOrReverse, maybeReverse) {
  let reverse;
  let test;
  let visitor;
  if (typeof testOrVisitor === "function" && typeof visitorOrReverse !== "function") {
    test = void 0;
    visitor = testOrVisitor;
    reverse = visitorOrReverse;
  } else {
    test = testOrVisitor;
    visitor = visitorOrReverse;
    reverse = maybeReverse;
  }
  visitParents(tree, test, overload, reverse);
  function overload(node, parents) {
    const parent = parents[parents.length - 1];
    const index = parent ? parent.children.indexOf(node) : void 0;
    return visitor(node, index, parent);
  }
}
export {
  CONTINUE,
  EXIT,
  SKIP,
  visit
};
//# sourceMappingURL=lib-index.js.map
