import { checkEmphasis } from "../util/check-emphasis.js";
import { encodeCharacterReference } from "../util/encode-character-reference.js";
import { encodeInfo } from "../util/encode-info.js";
emphasis.peek = emphasisPeek;
function emphasis(r, i, a, o) {
	let s = checkEmphasis(a), c = a.enter("emphasis"), l = a.createTracker(o), u = l.move(s), d = l.move(a.containerPhrasing(r, {
		after: s,
		before: u,
		...l.current()
	})), f = d.charCodeAt(0), p = encodeInfo(o.before.charCodeAt(o.before.length - 1), f, s);
	p.inside && (d = encodeCharacterReference(f) + d.slice(1));
	let m = d.charCodeAt(d.length - 1), h = encodeInfo(o.after.charCodeAt(0), m, s);
	h.inside && (d = d.slice(0, -1) + encodeCharacterReference(m));
	let g = l.move(s);
	return c(), a.attentionEncodeSurroundingInfo = {
		after: h.outside,
		before: p.outside
	}, u + d + g;
}
function emphasisPeek(e, t, n) {
	return n.options.emphasis || "*";
}
export { emphasis };
