import { __toESM as e } from "../../../_virtual/_rolldown/runtime.js";
import { hastToReact as t } from "../../property-information/lib/hast-to-react.js";
import { find as n } from "../../property-information/lib/find.js";
import { html as r, svg as i } from "../../property-information/index.js";
import { stringify as a } from "../../comma-separated-tokens/index.js";
import { stringify as o } from "../../space-separated-tokens/index.js";
import "../../devlop/lib/default.js";
import { pointStart as s } from "../../unist-util-position/lib/index.js";
import { name as c } from "../../estree-util-is-identifier-name/lib/index.js";
import { whitespace as l } from "../../hast-util-whitespace/lib/index.js";
import { require_cjs as u } from "../../style-to-js/cjs/index.js";
import { VFileMessage as d } from "../../vfile-message/lib/index.js";
//#region ../../node_modules/hast-util-to-jsx-runtime/lib/index.js
var f = /* @__PURE__ */ e(u(), 1), p = {}.hasOwnProperty, m = /* @__PURE__ */ new Map(), h = /[A-Z]/g, g = new Set([
	"table",
	"tbody",
	"thead",
	"tfoot",
	"tr"
]), _ = new Set(["td", "th"]), v = "https://github.com/syntax-tree/hast-util-to-jsx-runtime";
function y(e, t) {
	if (!t || t.Fragment === void 0) throw TypeError("Expected `Fragment` in options");
	let n = t.filePath || void 0, a;
	if (t.development) {
		if (typeof t.jsxDEV != "function") throw TypeError("Expected `jsxDEV` in options when `development: true`");
		a = A(n, t.jsxDEV);
	} else {
		if (typeof t.jsx != "function") throw TypeError("Expected `jsx` in production options");
		if (typeof t.jsxs != "function") throw TypeError("Expected `jsxs` in production options");
		a = k(n, t.jsx, t.jsxs);
	}
	let o = {
		Fragment: t.Fragment,
		ancestors: [],
		components: t.components || {},
		create: a,
		elementAttributeNameCase: t.elementAttributeNameCase || "react",
		evaluater: t.createEvaluater ? t.createEvaluater() : void 0,
		filePath: n,
		ignoreInvalidStyle: t.ignoreInvalidStyle || !1,
		passKeys: t.passKeys !== !1,
		passNode: t.passNode || !1,
		schema: t.space === "svg" ? i : r,
		stylePropertyNameCase: t.stylePropertyNameCase || "dom",
		tableCellAlignToStyle: t.tableCellAlignToStyle !== !1
	}, s = b(o, e, void 0);
	return s && typeof s != "string" ? s : o.create(e, o.Fragment, { children: s || void 0 }, void 0);
}
function b(e, t, n) {
	if (t.type === "element") return x(e, t, n);
	if (t.type === "mdxFlowExpression" || t.type === "mdxTextExpression") return S(e, t);
	if (t.type === "mdxJsxFlowElement" || t.type === "mdxJsxTextElement") return w(e, t, n);
	if (t.type === "mdxjsEsm") return C(e, t);
	if (t.type === "root") return T(e, t, n);
	if (t.type === "text") return E(e, t);
}
function x(e, t, n) {
	let r = e.schema, a = r;
	t.tagName.toLowerCase() === "svg" && r.space === "html" && (a = i, e.schema = a), e.ancestors.push(t);
	let o = I(e, t.tagName, !1), s = j(e, t), c = N(e, t);
	return g.has(t.tagName) && (c = c.filter(function(e) {
		return typeof e == "string" ? !l(e) : !0;
	})), D(e, s, o, t), O(s, c), e.ancestors.pop(), e.schema = r, e.create(t, o, s, n);
}
function S(e, t) {
	if (t.data && t.data.estree && e.evaluater) {
		let n = t.data.estree.body[0];
		return n.type, e.evaluater.evaluateExpression(n.expression);
	}
	L(e, t.position);
}
function C(e, t) {
	if (t.data && t.data.estree && e.evaluater) return e.evaluater.evaluateProgram(t.data.estree);
	L(e, t.position);
}
function w(e, t, n) {
	let r = e.schema, a = r;
	t.name === "svg" && r.space === "html" && (a = i, e.schema = a), e.ancestors.push(t);
	let o = t.name === null ? e.Fragment : I(e, t.name, !0), s = M(e, t), c = N(e, t);
	return D(e, s, o, t), O(s, c), e.ancestors.pop(), e.schema = r, e.create(t, o, s, n);
}
function T(e, t, n) {
	let r = {};
	return O(r, N(e, t)), e.create(t, e.Fragment, r, n);
}
function E(e, t) {
	return t.value;
}
function D(e, t, n, r) {
	typeof n != "string" && n !== e.Fragment && e.passNode && (t.node = r);
}
function O(e, t) {
	if (t.length > 0) {
		let n = t.length > 1 ? t : t[0];
		n && (e.children = n);
	}
}
function k(e, t, n) {
	return r;
	function r(e, r, i, a) {
		let o = Array.isArray(i.children) ? n : t;
		return a ? o(r, i, a) : o(r, i);
	}
}
function A(e, t) {
	return n;
	function n(n, r, i, a) {
		let o = Array.isArray(i.children), c = s(n);
		return t(r, i, a, o, {
			columnNumber: c ? c.column - 1 : void 0,
			fileName: e,
			lineNumber: c ? c.line : void 0
		}, void 0);
	}
}
function j(e, t) {
	let n = {}, r, i;
	for (i in t.properties) if (i !== "children" && p.call(t.properties, i)) {
		let a = P(e, i, t.properties[i]);
		if (a) {
			let [i, o] = a;
			e.tableCellAlignToStyle && i === "align" && typeof o == "string" && _.has(t.tagName) ? r = o : n[i] = o;
		}
	}
	if (r) {
		let t = n.style ||= {};
		t[e.stylePropertyNameCase === "css" ? "text-align" : "textAlign"] = r;
	}
	return n;
}
function M(e, t) {
	let n = {};
	for (let r of t.attributes) if (r.type === "mdxJsxExpressionAttribute") if (r.data && r.data.estree && e.evaluater) {
		let t = r.data.estree.body[0];
		t.type;
		let i = t.expression;
		i.type;
		let a = i.properties[0];
		a.type, Object.assign(n, e.evaluater.evaluateExpression(a.argument));
	} else L(e, t.position);
	else {
		let i = r.name, a;
		if (r.value && typeof r.value == "object") if (r.value.data && r.value.data.estree && e.evaluater) {
			let t = r.value.data.estree.body[0];
			t.type, a = e.evaluater.evaluateExpression(t.expression);
		} else L(e, t.position);
		else a = r.value === null ? !0 : r.value;
		n[i] = a;
	}
	return n;
}
function N(e, t) {
	let n = [], r = -1, i = e.passKeys ? /* @__PURE__ */ new Map() : m;
	for (; ++r < t.children.length;) {
		let a = t.children[r], o;
		if (e.passKeys) {
			let e = a.type === "element" ? a.tagName : a.type === "mdxJsxFlowElement" || a.type === "mdxJsxTextElement" ? a.name : void 0;
			if (e) {
				let t = i.get(e) || 0;
				o = e + "-" + t, i.set(e, t + 1);
			}
		}
		let s = b(e, a, o);
		s !== void 0 && n.push(s);
	}
	return n;
}
function P(e, r, i) {
	let s = n(e.schema, r);
	if (!(i == null || typeof i == "number" && Number.isNaN(i))) {
		if (Array.isArray(i) && (i = s.commaSeparated ? a(i) : o(i)), s.property === "style") {
			let t = typeof i == "object" ? i : F(e, String(i));
			return e.stylePropertyNameCase === "css" && (t = R(t)), ["style", t];
		}
		return [e.elementAttributeNameCase === "react" && s.space ? t[s.property] || s.property : s.attribute, i];
	}
}
function F(e, t) {
	try {
		return (0, f.default)(t, { reactCompat: !0 });
	} catch (t) {
		if (e.ignoreInvalidStyle) return {};
		let n = t, r = new d("Cannot parse `style` attribute", {
			ancestors: e.ancestors,
			cause: n,
			ruleId: "style",
			source: "hast-util-to-jsx-runtime"
		});
		throw r.file = e.filePath || void 0, r.url = v + "#cannot-parse-style-attribute", r;
	}
}
function I(e, t, n) {
	let r;
	if (!n) r = {
		type: "Literal",
		value: t
	};
	else if (t.includes(".")) {
		let e = t.split("."), n = -1, i;
		for (; ++n < e.length;) {
			let t = c(e[n]) ? {
				type: "Identifier",
				name: e[n]
			} : {
				type: "Literal",
				value: e[n]
			};
			i = i ? {
				type: "MemberExpression",
				object: i,
				property: t,
				computed: !!(n && t.type === "Literal"),
				optional: !1
			} : t;
		}
		r = i;
	} else r = c(t) && !/^[a-z]/.test(t) ? {
		type: "Identifier",
		name: t
	} : {
		type: "Literal",
		value: t
	};
	if (r.type === "Literal") {
		let t = r.value;
		return p.call(e.components, t) ? e.components[t] : t;
	}
	if (e.evaluater) return e.evaluater.evaluateExpression(r);
	L(e);
}
function L(e, t) {
	let n = new d("Cannot handle MDX estrees without `createEvaluater`", {
		ancestors: e.ancestors,
		place: t,
		ruleId: "mdx-estree",
		source: "hast-util-to-jsx-runtime"
	});
	throw n.file = e.filePath || void 0, n.url = v + "#cannot-handle-mdx-estrees-without-createevaluater", n;
}
function R(e) {
	let t = {}, n;
	for (n in e) p.call(e, n) && (t[z(n)] = e[n]);
	return t;
}
function z(e) {
	let t = e.replace(h, B);
	return t.slice(0, 3) === "ms-" && (t = "-" + t), t;
}
function B(e) {
	return "-" + e.toLowerCase();
}
//#endregion
export { y as toJsxRuntime };
