import { normalizeUri as e } from "../../../micromark-util-sanitize-uri/index.js";
import { revert as t } from "../revert.js";
//#region ../../node_modules/mdast-util-to-hast/lib/handlers/link-reference.js
function n(n, r) {
	let i = String(r.identifier).toUpperCase(), a = n.definitionById.get(i);
	if (!a) return t(n, r);
	let o = { href: e(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);
}
//#endregion
export { n as linkReference };
