import { decodeNamedCharacterReference } from "../decode-named-character-reference/index.dom.js";
import { decodeNumericCharacterReference } from "../micromark-util-decode-numeric-character-reference/index.js";
var characterEscapeOrReference = /\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;
function decodeString(e) {
	return e.replace(characterEscapeOrReference, decode);
}
function decode(n, r, i) {
	if (r) return r;
	if (i.charCodeAt(0) === 35) {
		let e = i.charCodeAt(1), n = e === 120 || e === 88;
		return decodeNumericCharacterReference(i.slice(n ? 2 : 1), n ? 16 : 10);
	}
	return decodeNamedCharacterReference(i) || n;
}
export { decodeString };
