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