import { normalizeUri } from "../micromark-util-sanitize-uri/index.js";
import { revert } from "./lib-revert.js";
function imageReference(state, node) {
  const id = String(node.identifier).toUpperCase();
  const definition = state.definitionById.get(id);
  if (!definition) {
    return revert(state, node);
  }
  const properties = { src: normalizeUri(definition.url || ""), alt: node.alt };
  if (definition.title !== null && definition.title !== void 0) {
    properties.title = definition.title;
  }
  const result = { type: "element", tagName: "img", properties, children: [] };
  state.patch(node, result);
  return state.applyData(node, result);
}
export {
  imageReference
};
//# sourceMappingURL=lib-handlers-image-reference.js.map
