//#region ../../node_modules/hast-util-raw/node_modules/parse5/dist/parser/formatting-element-list.js
var e = 3, t;
(function(e) {
	e[e.Marker = 0] = "Marker", e[e.Element = 1] = "Element";
})(t ||= {});
var n = { type: t.Marker }, r = class {
	constructor(e) {
		this.treeAdapter = e, this.entries = [], this.bookmark = null;
	}
	_getNoahArkConditionCandidates(e, n) {
		let r = [], i = n.length, a = this.treeAdapter.getTagName(e), o = this.treeAdapter.getNamespaceURI(e);
		for (let e = 0; e < this.entries.length; e++) {
			let n = this.entries[e];
			if (n.type === t.Marker) break;
			let { element: s } = n;
			if (this.treeAdapter.getTagName(s) === a && this.treeAdapter.getNamespaceURI(s) === o) {
				let t = this.treeAdapter.getAttrList(s);
				t.length === i && r.push({
					idx: e,
					attrs: t
				});
			}
		}
		return r;
	}
	_ensureNoahArkCondition(t) {
		if (this.entries.length < e) return;
		let n = this.treeAdapter.getAttrList(t), r = this._getNoahArkConditionCandidates(t, n);
		if (r.length < e) return;
		let i = new Map(n.map((e) => [e.name, e.value])), a = 0;
		for (let t = 0; t < r.length; t++) {
			let n = r[t];
			n.attrs.every((e) => i.get(e.name) === e.value) && (a += 1, a >= e && this.entries.splice(n.idx, 1));
		}
	}
	insertMarker() {
		this.entries.unshift(n);
	}
	pushElement(e, n) {
		this._ensureNoahArkCondition(e), this.entries.unshift({
			type: t.Element,
			element: e,
			token: n
		});
	}
	insertElementAfterBookmark(e, n) {
		let r = this.entries.indexOf(this.bookmark);
		this.entries.splice(r, 0, {
			type: t.Element,
			element: e,
			token: n
		});
	}
	removeEntry(e) {
		let t = this.entries.indexOf(e);
		t !== -1 && this.entries.splice(t, 1);
	}
	clearToLastMarker() {
		let e = this.entries.indexOf(n);
		e === -1 ? this.entries.length = 0 : this.entries.splice(0, e + 1);
	}
	getElementEntryInScopeWithTagName(e) {
		let n = this.entries.find((n) => n.type === t.Marker || this.treeAdapter.getTagName(n.element) === e);
		return n && n.type === t.Element ? n : null;
	}
	getElementEntry(e) {
		return this.entries.find((n) => n.type === t.Element && n.element === e);
	}
};
//#endregion
export { t as EntryType, r as FormattingElementList };
