import "../../devlop/lib/default.js";
import { normalizeIdentifier as e } from "../../micromark-util-normalize-identifier/index.js";
//#region ../../node_modules/mdast-util-gfm-footnote/lib/index.js
u.peek = l;
function t() {
	this.buffer();
}
function n(e) {
	this.enter({
		type: "footnoteReference",
		identifier: "",
		label: ""
	}, e);
}
function r() {
	this.buffer();
}
function i(e) {
	this.enter({
		type: "footnoteDefinition",
		identifier: "",
		label: "",
		children: []
	}, e);
}
function a(t) {
	let n = this.resume(), r = this.stack[this.stack.length - 1];
	r.type, r.identifier = e(this.sliceSerialize(t)).toLowerCase(), r.label = n;
}
function o(e) {
	this.exit(e);
}
function s(t) {
	let n = this.resume(), r = this.stack[this.stack.length - 1];
	r.type, r.identifier = e(this.sliceSerialize(t)).toLowerCase(), r.label = n;
}
function c(e) {
	this.exit(e);
}
function l() {
	return "[";
}
function u(e, t, n, r) {
	let i = n.createTracker(r), a = i.move("[^"), o = n.enter("footnoteReference"), s = n.enter("reference");
	return a += i.move(n.safe(n.associationId(e), {
		after: "]",
		before: a
	})), s(), o(), a += i.move("]"), a;
}
function d() {
	return {
		enter: {
			gfmFootnoteCallString: t,
			gfmFootnoteCall: n,
			gfmFootnoteDefinitionLabelString: r,
			gfmFootnoteDefinition: i
		},
		exit: {
			gfmFootnoteCallString: a,
			gfmFootnoteCall: o,
			gfmFootnoteDefinitionLabelString: s,
			gfmFootnoteDefinition: c
		}
	};
}
function f(e) {
	let t = !1;
	return e && e.firstLineBlank && (t = !0), {
		handlers: {
			footnoteDefinition: n,
			footnoteReference: u
		},
		unsafe: [{
			character: "[",
			inConstruct: [
				"label",
				"phrasing",
				"reference"
			]
		}]
	};
	function n(e, n, r, i) {
		let a = r.createTracker(i), o = a.move("[^"), s = r.enter("footnoteDefinition"), c = r.enter("label");
		return o += a.move(r.safe(r.associationId(e), {
			before: o,
			after: "]"
		})), c(), o += a.move("]:"), e.children && e.children.length > 0 && (a.shift(4), o += a.move((t ? "\n" : " ") + r.indentLines(r.containerFlow(e, a.current()), t ? m : p))), s(), o;
	}
}
function p(e, t, n) {
	return t === 0 ? e : m(e, t, n);
}
function m(e, t, n) {
	return (n ? "" : "    ") + e;
}
//#endregion
export { d as gfmFootnoteFromMarkdown, f as gfmFootnoteToMarkdown };
