import { convert as e } from "../../unist-util-is/lib/index.js";
import { color as t } from "./color.js";
//#region ../../node_modules/unist-util-visit-parents/lib/index.js
var n = [], r = "skip";
function i(r, i, o, s) {
	let c;
	typeof i == "function" && typeof o != "function" ? (s = o, o = i) : c = i;
	let l = e(c), u = s ? -1 : 1;
	d(r, void 0, [])();
	function d(e, r, c) {
		let f = e && typeof e == "object" ? e : {};
		if (typeof f.type == "string") {
			let n = typeof f.tagName == "string" ? f.tagName : typeof f.name == "string" ? f.name : void 0;
			Object.defineProperty(p, "name", { value: "node (" + t(e.type + (n ? "<" + n + ">" : "")) + ")" });
		}
		return p;
		function p() {
			let t = n, f, p, m;
			if ((!i || l(e, r, c[c.length - 1] || void 0)) && (t = a(o(e, c)), t[0] === !1)) return t;
			if ("children" in e && e.children) {
				let n = e;
				if (n.children && t[0] !== "skip") for (p = (s ? n.children.length : -1) + u, m = c.concat(n); p > -1 && p < n.children.length;) {
					let e = n.children[p];
					if (f = d(e, p, m)(), f[0] === !1) return f;
					p = typeof f[1] == "number" ? f[1] : p + u;
				}
			}
			return t;
		}
	}
}
function a(e) {
	return Array.isArray(e) ? e : typeof e == "number" ? [!0, e] : e == null ? n : [e];
}
//#endregion
export { r as SKIP, i as visitParents };
