var defaultSubsetRegex = /["&'<>`]/g, surrogatePairsRegex = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g, controlCharactersRegex = /[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g, regexEscapeRegex = /[|\\{}()[\]^$+*?.]/g, subsetToRegexCache = /* @__PURE__ */ new WeakMap();
function core(i, a) {
	if (i = i.replace(a.subset ? charactersToExpressionCached(a.subset) : defaultSubsetRegex, s), a.subset || a.escapeOnly) return i;
	return i.replace(surrogatePairsRegex, o).replace(controlCharactersRegex, s);
	function o(e, n, r) {
		return a.format((e.charCodeAt(0) - 55296) * 1024 + e.charCodeAt(1) - 56320 + 65536, r.charCodeAt(n + 2), a);
	}
	function s(e, n, r) {
		return a.format(e.charCodeAt(0), r.charCodeAt(n + 1), a);
	}
}
function charactersToExpressionCached(e) {
	let n = subsetToRegexCache.get(e);
	return n || (n = charactersToExpression(e), subsetToRegexCache.set(e, n)), n;
}
function charactersToExpression(e) {
	let n = [], r = -1;
	for (; ++r < e.length;) n.push(e[r].replace(regexEscapeRegex, "\\$&"));
	return RegExp("(?:" + n.join("|") + ")", "g");
}
export { core };
