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

//# sourceMappingURL=index.js.map