import { normalizeUri } from "../../../micromark-util-sanitize-uri/index.js";
import { revert } from "../revert.js";
function imageReference(n, r) {
	let i = String(r.identifier).toUpperCase(), a = n.definitionById.get(i);
	if (!a) return revert(n, r);
	let o = {
		src: normalizeUri(a.url || ""),
		alt: r.alt
	};
	a.title !== null && a.title !== void 0 && (o.title = a.title);
	let s = {
		type: "element",
		tagName: "img",
		properties: o,
		children: []
	};
	return n.patch(r, s), n.applyData(r, s);
}
export { imageReference };
