import { checkBullet as e } from "../util/check-bullet.js";
import { checkBulletOther as t } from "../util/check-bullet-other.js";
import { checkBulletOrdered as n } from "../util/check-bullet-ordered.js";
import { checkRule as r } from "../util/check-rule.js";
//#region ../../node_modules/mdast-util-to-markdown/lib/handle/list.js
function i(i, a, o, s) {
	let c = o.enter("list"), l = o.bulletCurrent, u = i.ordered ? n(o) : e(o), d = i.ordered ? u === "." ? ")" : "." : t(o), f = a && o.bulletLastUsed ? u === o.bulletLastUsed : !1;
	if (!i.ordered) {
		let e = i.children ? i.children[0] : void 0;
		if ((u === "*" || u === "-") && e && (!e.children || !e.children[0]) && o.stack[o.stack.length - 1] === "list" && o.stack[o.stack.length - 2] === "listItem" && o.stack[o.stack.length - 3] === "list" && o.stack[o.stack.length - 4] === "listItem" && o.indexStack[o.indexStack.length - 1] === 0 && o.indexStack[o.indexStack.length - 2] === 0 && o.indexStack[o.indexStack.length - 3] === 0 && (f = !0), r(o) === u && e) {
			let e = -1;
			for (; ++e < i.children.length;) {
				let t = i.children[e];
				if (t && t.type === "listItem" && t.children && t.children[0] && t.children[0].type === "thematicBreak") {
					f = !0;
					break;
				}
			}
		}
	}
	f && (u = d), o.bulletCurrent = u;
	let p = o.containerFlow(i, s);
	return o.bulletLastUsed = u, o.bulletCurrent = l, c(), p;
}
//#endregion
export { i as list };
