import { markdownLineEnding } from "../../micromark-util-character/index.js";
import { factorySpace } from "../../micromark-factory-space/index.js";
const codeIndented = {
	name: "codeIndented",
	tokenize: tokenizeCodeIndented
};
var furtherStart = {
	partial: !0,
	tokenize: tokenizeFurtherStart
};
function tokenizeCodeIndented(n, i, a) {
	let o = this;
	return s;
	function s(e) {
		return n.enter("codeIndented"), factorySpace(n, c, "linePrefix", 5)(e);
	}
	function c(e) {
		let t = o.events[o.events.length - 1];
		return t && t[1].type === "linePrefix" && t[2].sliceSerialize(t[1], !0).length >= 4 ? l(e) : a(e);
	}
	function l(t) {
		return t === null ? d(t) : markdownLineEnding(t) ? n.attempt(furtherStart, l, d)(t) : (n.enter("codeFlowValue"), u(t));
	}
	function u(t) {
		return t === null || markdownLineEnding(t) ? (n.exit("codeFlowValue"), l(t)) : (n.consume(t), u);
	}
	function d(e) {
		return n.exit("codeIndented"), i(e);
	}
}
function tokenizeFurtherStart(n, r, i) {
	let a = this;
	return o;
	function o(r) {
		return a.parser.lazy[a.now().line] ? i(r) : markdownLineEnding(r) ? (n.enter("lineEnding"), n.consume(r), n.exit("lineEnding"), o) : factorySpace(n, s, "linePrefix", 5)(r);
	}
	function s(t) {
		let n = a.events[a.events.length - 1];
		return n && n[1].type === "linePrefix" && n[2].sliceSerialize(n[1], !0).length >= 4 ? r(t) : markdownLineEnding(t) ? o(t) : i(t);
	}
}
export { codeIndented };
