import { Dt as e, J as t, K as n, Nt as r, Ot as i, Tt as a, W as o, Y as s, dt as c, et as l, ft as u, it as d, pt as f, q as p, st as m, wt as h, xt as g } from "./dist-DgSmYkuV.js";
//#region node_modules/@codemirror/lint/dist/index.js
var _ = class {
	constructor(e, t, n) {
		this.from = e, this.to = t, this.diagnostic = n;
	}
}, v = class e {
	constructor(e, t, n) {
		this.diagnostics = e, this.panel = t, this.selected = n;
	}
	static init(t, n, r) {
		let i = r.facet(j).markerFilter;
		i && (t = i(t, r));
		let s = t.slice().sort((e, t) => e.from - t.from || e.to - t.to), c = new a(), l = [], u = 0, d = r.doc.iter(), f = 0, p = r.doc.length;
		for (let e = 0;;) {
			let t = e == s.length ? null : s[e];
			if (!t && !l.length) break;
			let n, r;
			if (l.length) n = u, r = l.reduce((e, t) => Math.min(e, t.to), t && t.from > n ? t.from : 1e8);
			else {
				if (n = t.from, n > p) break;
				r = t.to, l.push(t), e++;
			}
			for (; e < s.length;) {
				let t = s[e];
				if (t.from == n && (t.to > t.from || t.to == n)) l.push(t), e++, r = Math.min(t.to, r);
				else {
					r = Math.min(t.from, r);
					break;
				}
			}
			r = Math.min(r, p);
			let i = !1;
			if (l.some((e) => e.from == n && (e.to == r || r == p)) && (i = n == r, !i && r - n < 10)) {
				let e = n - (f + d.value.length);
				e > 0 && (d.next(e), f = n);
				for (let e = n;;) {
					if (e >= r) {
						i = !0;
						break;
					}
					if (!d.lineBreak && f + d.value.length > e) break;
					e = f + d.value.length, f += d.value.length, d.next();
				}
			}
			let a = U(l);
			if (i) c.add(n, n, o.widget({
				widget: new I(a),
				diagnostics: l.slice()
			}));
			else {
				let e = l.reduce((e, t) => t.markClass ? e + " " + t.markClass : e, "");
				c.add(n, r, o.mark({
					class: "cm-lintRange cm-lintRange-" + a + e,
					diagnostics: l.slice(),
					inclusiveEnd: l.some((e) => e.to > r)
				}));
			}
			if (u = r, u == p) break;
			for (let e = 0; e < l.length; e++) l[e].to <= u && l.splice(e--, 1);
		}
		let m = c.finish();
		return new e(m, n, y(m));
	}
};
function y(e, t = null, n = 0) {
	let r = null;
	return e.between(n, 1e9, (e, n, { spec: i }) => {
		if (!(t && i.diagnostics.indexOf(t) < 0)) if (!r) r = new _(e, n, t || i.diagnostics[0]);
		else if (i.diagnostics.indexOf(r.diagnostic) < 0) return !1;
		else r = new _(r.from, n, r.diagnostic);
	}), r;
}
function b(e, t) {
	let n = t.pos, r = t.end || n, i = e.state.facet(j).hideOn(e, n, r);
	if (i != null) return i;
	let a = e.startState.doc.lineAt(t.pos);
	return !!(e.effects.some((e) => e.is(C)) || e.changes.touchesRange(a.from, Math.max(a.to, r)));
}
function x(t, n) {
	return t.field(E, !1) ? n : n.concat(e.appendConfig.of(Q));
}
function S(e, t) {
	return { effects: x(e, [C.of(t)]) };
}
var C = /* @__PURE__ */ e.define(), w = /* @__PURE__ */ e.define(), T = /* @__PURE__ */ e.define(), E = /* @__PURE__ */ i.define({
	create() {
		return new v(o.none, null, null);
	},
	update(e, t) {
		if (t.docChanged && e.diagnostics.size) {
			let n = e.diagnostics.map(t.changes), r = null, i = e.panel;
			if (e.selected) {
				let i = t.changes.mapPos(e.selected.from, 1);
				r = y(n, e.selected.diagnostic, i) || y(n, null, i);
			}
			!n.size && i && t.state.facet(j).autoPanel && (i = null), e = new v(n, i, r);
		}
		for (let n of t.effects) if (n.is(C)) {
			let r = t.state.facet(j).autoPanel ? n.value.length ? R.open : null : e.panel;
			e = v.init(n.value, r, t.state);
		} else n.is(w) ? e = new v(e.diagnostics, n.value ? R.open : null, e.selected) : n.is(T) && (e = new v(e.diagnostics, e.panel, n.value));
		return e;
	},
	provide: (e) => [c.from(e, (e) => e.panel), n.decorations.from(e, (e) => e.diagnostics)]
}), ee = /* @__PURE__ */ o.mark({ class: "cm-lintRange cm-lintRange-active" });
function te(e, t, n) {
	let { diagnostics: r } = e.state.field(E), i, a = -1, o = -1;
	r.between(t - (n < 0 ? 1 : 0), t + (n > 0 ? 1 : 0), (e, r, { spec: s }) => {
		if (t >= e && t <= r && (e == r || (t > e || n > 0) && (t < r || n < 0))) return i = s.diagnostics, a = e, o = r, !1;
	});
	let s = e.state.facet(j).tooltipFilter;
	return i && s && (i = s(i, e.state)), i ? {
		pos: a,
		end: o,
		above: e.state.doc.lineAt(a).to < o,
		create() {
			return { dom: D(e, i) };
		}
	} : null;
}
function D(e, t) {
	return f("ul", { class: "cm-tooltip-lint" }, t.map((t) => F(e, t, !1)));
}
var O = (e) => {
	let t = e.state.field(E, !1);
	return !t || !t.panel ? !1 : (e.dispatch({ effects: w.of(!1) }), !0);
}, k = /* @__PURE__ */ t.fromClass(class {
	constructor(e) {
		this.view = e, this.timeout = -1, this.set = !0;
		let { delay: t } = e.state.facet(j);
		this.lintTime = Date.now() + t, this.run = this.run.bind(this), this.timeout = setTimeout(this.run, t);
	}
	run() {
		clearTimeout(this.timeout);
		let e = Date.now();
		if (e < this.lintTime - 10) this.timeout = setTimeout(this.run, this.lintTime - e);
		else {
			this.set = !1;
			let { state: e } = this.view, { sources: t } = e.facet(j);
			t.length && A(t.map((e) => Promise.resolve(e(this.view))), (t) => {
				this.view.state.doc == e.doc && this.view.dispatch(S(this.view.state, t.reduce((e, t) => e.concat(t))));
			}, (e) => {
				m(this.view.state, e);
			});
		}
	}
	update(e) {
		let t = e.state.facet(j);
		(e.docChanged || t != e.startState.facet(j) || t.needsRefresh && t.needsRefresh(e)) && (this.lintTime = Date.now() + t.delay, this.set || (this.set = !0, this.timeout = setTimeout(this.run, t.delay)));
	}
	force() {
		this.set && (this.lintTime = Date.now(), this.run());
	}
	destroy() {
		clearTimeout(this.timeout);
	}
});
function A(e, t, n) {
	let r = [], i = -1;
	for (let a of e) a.then((n) => {
		r.push(n), clearTimeout(i), r.length == e.length ? t(r) : i = setTimeout(() => t(r), 200);
	}, n);
}
var j = /* @__PURE__ */ g.define({ combine(e) {
	return {
		sources: e.map((e) => e.source).filter((e) => e != null),
		...r(e.map((e) => e.config), {
			delay: 750,
			markerFilter: null,
			tooltipFilter: null,
			needsRefresh: null,
			hideOn: () => null
		}, {
			delay: Math.max,
			markerFilter: M,
			tooltipFilter: M,
			needsRefresh: (e, t) => e ? t ? (n) => e(n) || t(n) : e : t,
			hideOn: (e, t) => e ? t ? (n, r, i) => e(n, r, i) || t(n, r, i) : e : t,
			autoPanel: (e, t) => e || t
		})
	};
} });
function M(e, t) {
	return e ? t ? (n, r) => t(e(n, r), r) : e : t;
}
function N(e, t = {}) {
	return [
		j.of({
			source: e,
			config: t
		}),
		k,
		Q
	];
}
function P(e) {
	let t = [];
	if (e) actions: for (let { name: n } of e) {
		for (let e = 0; e < n.length; e++) {
			let r = n[e];
			if (/[a-zA-Z]/.test(r) && !t.some((e) => e.toLowerCase() == r.toLowerCase())) {
				t.push(r);
				continue actions;
			}
		}
		t.push("");
	}
	return t;
}
function F(e, t, n) {
	let r = n ? P(t.actions) : [];
	return f("li", { class: "cm-diagnostic cm-diagnostic-" + t.severity }, f("span", { class: "cm-diagnosticText" }, t.renderMessage ? t.renderMessage(e) : t.message), t.actions?.map((n, i) => {
		let a = !1, o = (r) => {
			if (r.preventDefault(), a) return;
			a = !0;
			let i = y(e.state.field(E).diagnostics, t);
			i && n.apply(e, i.from, i.to);
		}, { name: s } = n, c = r[i] ? s.indexOf(r[i]) : -1, l = c < 0 ? s : [
			s.slice(0, c),
			f("u", s.slice(c, c + 1)),
			s.slice(c + 1)
		];
		return f("button", {
			type: "button",
			class: "cm-diagnosticAction" + (n.markClass ? " " + n.markClass : ""),
			onclick: o,
			onmousedown: o,
			"aria-label": ` Action: ${s}${c < 0 ? "" : ` (access key "${r[i]})"`}.`
		}, l);
	}), t.source && f("div", { class: "cm-diagnosticSource" }, t.source));
}
var I = class extends s {
	constructor(e) {
		super(), this.sev = e;
	}
	eq(e) {
		return e.sev == this.sev;
	}
	toDOM() {
		return f("span", { class: "cm-lintPoint cm-lintPoint-" + this.sev });
	}
}, L = class {
	constructor(e, t) {
		this.diagnostic = t, this.id = "item_" + Math.floor(Math.random() * 4294967295).toString(16), this.dom = F(e, t, !0), this.dom.id = this.id, this.dom.setAttribute("role", "option");
	}
}, R = class e {
	constructor(e) {
		this.view = e, this.items = [];
		let t = (t) => {
			if (!(t.ctrlKey || t.altKey || t.metaKey)) {
				if (t.keyCode == 27) O(this.view), this.view.focus();
				else if (t.keyCode == 38 || t.keyCode == 33) this.moveSelection((this.selectedIndex - 1 + this.items.length) % this.items.length);
				else if (t.keyCode == 40 || t.keyCode == 34) this.moveSelection((this.selectedIndex + 1) % this.items.length);
				else if (t.keyCode == 36) this.moveSelection(0);
				else if (t.keyCode == 35) this.moveSelection(this.items.length - 1);
				else if (t.keyCode == 13) this.view.focus();
				else if (t.keyCode >= 65 && t.keyCode <= 90 && this.selectedIndex >= 0) {
					let { diagnostic: n } = this.items[this.selectedIndex], r = P(n.actions);
					for (let i = 0; i < r.length; i++) if (r[i].toUpperCase().charCodeAt(0) == t.keyCode) {
						let t = y(this.view.state.field(E).diagnostics, n);
						t && n.actions[i].apply(e, t.from, t.to);
					}
				} else return;
				t.preventDefault();
			}
		}, n = (e) => {
			for (let t = 0; t < this.items.length; t++) this.items[t].dom.contains(e.target) && this.moveSelection(t);
		};
		this.list = f("ul", {
			tabIndex: 0,
			role: "listbox",
			"aria-label": this.view.state.phrase("Diagnostics"),
			onkeydown: t,
			onclick: n
		}), this.dom = f("div", { class: "cm-panel-lint" }, this.list, f("button", {
			type: "button",
			name: "close",
			"aria-label": this.view.state.phrase("close"),
			onclick: () => O(this.view)
		}, "×")), this.update();
	}
	get selectedIndex() {
		let e = this.view.state.field(E).selected;
		if (!e) return -1;
		for (let t = 0; t < this.items.length; t++) if (this.items[t].diagnostic == e.diagnostic) return t;
		return -1;
	}
	update() {
		let { diagnostics: e, selected: t } = this.view.state.field(E), n = 0, r = !1, i = null, a = /* @__PURE__ */ new Set();
		for (e.between(0, this.view.state.doc.length, (e, o, { spec: s }) => {
			for (let e of s.diagnostics) {
				if (a.has(e)) continue;
				a.add(e);
				let o = -1, s;
				for (let t = n; t < this.items.length; t++) if (this.items[t].diagnostic == e) {
					o = t;
					break;
				}
				o < 0 ? (s = new L(this.view, e), this.items.splice(n, 0, s), r = !0) : (s = this.items[o], o > n && (this.items.splice(n, o - n), r = !0)), t && s.diagnostic == t.diagnostic ? s.dom.hasAttribute("aria-selected") || (s.dom.setAttribute("aria-selected", "true"), i = s) : s.dom.hasAttribute("aria-selected") && s.dom.removeAttribute("aria-selected"), n++;
			}
		}); n < this.items.length && !(this.items.length == 1 && this.items[0].diagnostic.from < 0);) r = !0, this.items.pop();
		this.items.length == 0 && (this.items.push(new L(this.view, {
			from: -1,
			to: -1,
			severity: "info",
			message: this.view.state.phrase("No diagnostics")
		})), r = !0), i ? (this.list.setAttribute("aria-activedescendant", i.id), this.view.requestMeasure({
			key: this,
			read: () => ({
				sel: i.dom.getBoundingClientRect(),
				panel: this.list.getBoundingClientRect()
			}),
			write: ({ sel: e, panel: t }) => {
				let n = t.height / this.list.offsetHeight;
				e.top < t.top ? this.list.scrollTop -= (t.top - e.top) / n : e.bottom > t.bottom && (this.list.scrollTop += (e.bottom - t.bottom) / n);
			}
		})) : this.selectedIndex < 0 && this.list.removeAttribute("aria-activedescendant"), r && this.sync();
	}
	sync() {
		let e = this.list.firstChild;
		function t() {
			let t = e;
			e = t.nextSibling, t.remove();
		}
		for (let n of this.items) if (n.dom.parentNode == this.list) {
			for (; e != n.dom;) t();
			e = n.dom.nextSibling;
		} else this.list.insertBefore(n.dom, e);
		for (; e;) t();
	}
	moveSelection(e) {
		if (this.selectedIndex < 0) return;
		let t = y(this.view.state.field(E).diagnostics, this.items[e].diagnostic);
		t && this.view.dispatch({
			selection: {
				anchor: t.from,
				head: t.to
			},
			scrollIntoView: !0,
			effects: T.of(t)
		});
	}
	static open(t) {
		return new e(t);
	}
};
function z(e, t = "viewBox=\"0 0 40 40\"") {
	return `url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${t}>${encodeURIComponent(e)}</svg>')`;
}
function B(e) {
	return z(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${e}" fill="none" stroke-width=".7"/>`, "width=\"6\" height=\"3\"");
}
var V = /* @__PURE__ */ n.baseTheme({
	".cm-diagnostic": {
		padding: "3px 6px 3px 8px",
		marginLeft: "-1px",
		display: "block",
		whiteSpace: "pre-wrap"
	},
	".cm-diagnostic-error": { borderLeft: "5px solid #d11" },
	".cm-diagnostic-warning": { borderLeft: "5px solid orange" },
	".cm-diagnostic-info": { borderLeft: "5px solid #999" },
	".cm-diagnostic-hint": { borderLeft: "5px solid #66d" },
	".cm-diagnosticAction": {
		font: "inherit",
		border: "none",
		padding: "2px 4px",
		backgroundColor: "#444",
		color: "white",
		borderRadius: "3px",
		marginLeft: "8px",
		cursor: "pointer"
	},
	".cm-diagnosticSource": {
		fontSize: "70%",
		opacity: .7
	},
	".cm-lintRange": {
		backgroundPosition: "left bottom",
		backgroundRepeat: "repeat-x",
		paddingBottom: "0.7px"
	},
	".cm-lintRange-error": { backgroundImage: /* @__PURE__ */ B("#d11") },
	".cm-lintRange-warning": { backgroundImage: /* @__PURE__ */ B("orange") },
	".cm-lintRange-info": { backgroundImage: /* @__PURE__ */ B("#999") },
	".cm-lintRange-hint": { backgroundImage: /* @__PURE__ */ B("#66d") },
	".cm-lintRange-active": { backgroundColor: "#ffdd9980" },
	".cm-tooltip-lint": {
		padding: 0,
		margin: 0
	},
	".cm-lintPoint": {
		position: "relative",
		"&:after": {
			content: "\"\"",
			position: "absolute",
			bottom: 0,
			left: "-2px",
			borderLeft: "3px solid transparent",
			borderRight: "3px solid transparent",
			borderBottom: "4px solid #d11"
		}
	},
	".cm-lintPoint-warning": { "&:after": { borderBottomColor: "orange" } },
	".cm-lintPoint-info": { "&:after": { borderBottomColor: "#999" } },
	".cm-lintPoint-hint": { "&:after": { borderBottomColor: "#66d" } },
	".cm-panel.cm-panel-lint": {
		position: "relative",
		"& ul": {
			maxHeight: "100px",
			overflowY: "auto",
			"& [aria-selected]": {
				backgroundColor: "#ddd",
				"& u": { textDecoration: "underline" }
			},
			"&:focus [aria-selected]": {
				background_fallback: "#bdf",
				backgroundColor: "Highlight",
				color_fallback: "white",
				color: "HighlightText"
			},
			"& u": { textDecoration: "none" },
			padding: 0,
			margin: 0
		},
		"& [name=close]": {
			position: "absolute",
			top: "0",
			right: "2px",
			background: "inherit",
			border: "none",
			font: "inherit",
			padding: 0,
			margin: 0
		}
	},
	"&dark .cm-lintRange-active": { backgroundColor: "#86714a80" },
	"&dark .cm-panel.cm-panel-lint ul": { "& [aria-selected]": { backgroundColor: "#2e343e" } }
});
function H(e) {
	return e == "error" ? 4 : e == "warning" ? 3 : e == "info" ? 2 : 1;
}
function U(e) {
	let t = "hint", n = 1;
	for (let r of e) {
		let e = H(r.severity);
		e > n && (n = e, t = r.severity);
	}
	return t;
}
var W = class extends p {
	constructor(e) {
		super(), this.diagnostics = e, this.severity = U(e);
	}
	toDOM(e) {
		let t = document.createElement("div");
		t.className = "cm-lint-marker cm-lint-marker-" + this.severity;
		let n = this.diagnostics, r = e.state.facet($).tooltipFilter;
		return r && (n = r(n, e.state)), n.length && (t.onmouseover = () => K(e, t, n)), t;
	}
};
function G(e, t) {
	let n = (r) => {
		let i = t.getBoundingClientRect();
		if (!(r.clientX > i.left - 10 && r.clientX < i.right + 10 && r.clientY > i.top - 10 && r.clientY < i.bottom + 10)) {
			for (let e = r.target; e; e = e.parentNode) if (e.nodeType == 1 && e.classList.contains("cm-tooltip-lint")) return;
			window.removeEventListener("mousemove", n), e.state.field(Z) && e.dispatch({ effects: X.of(null) });
		}
	};
	window.addEventListener("mousemove", n);
}
function K(e, t, n) {
	function r() {
		let r = e.elementAtHeight(t.getBoundingClientRect().top + 5 - e.documentTop);
		e.coordsAtPos(r.from) && e.dispatch({ effects: X.of({
			pos: r.from,
			above: !1,
			clip: !1,
			create() {
				return {
					dom: D(e, n),
					getCoords: () => t.getBoundingClientRect()
				};
			}
		}) }), t.onmouseout = t.onmousemove = null, G(e, t);
	}
	let { hoverTime: i } = e.state.facet($), a = setTimeout(r, i);
	t.onmouseout = () => {
		clearTimeout(a), t.onmouseout = t.onmousemove = null;
	}, t.onmousemove = () => {
		clearTimeout(a), a = setTimeout(r, i);
	};
}
function q(e, t) {
	let n = Object.create(null);
	for (let r of t) {
		let t = e.lineAt(r.from);
		(n[t.from] || (n[t.from] = [])).push(r);
	}
	let r = [];
	for (let e in n) r.push(new W(n[e]).range(+e));
	return h.of(r, !0);
}
var J = /* @__PURE__ */ l({
	class: "cm-gutter-lint",
	markers: (e) => e.state.field(Y),
	widgetMarker: (e, t, n) => {
		let r = [];
		return e.state.field(Y).between(n.from, n.to, (e, t, i) => {
			e > n.from && e < n.to && r.push(...i.diagnostics);
		}), r.length ? new W(r) : null;
	}
}), Y = /* @__PURE__ */ i.define({
	create() {
		return h.empty;
	},
	update(e, t) {
		e = e.map(t.changes);
		let n = t.state.facet($).markerFilter;
		for (let r of t.effects) if (r.is(C)) {
			let i = r.value;
			n && (i = n(i || [], t.state)), e = q(t.state.doc, i.slice(0));
		}
		return e;
	}
}), X = /* @__PURE__ */ e.define(), Z = /* @__PURE__ */ i.define({
	create() {
		return null;
	},
	update(e, t) {
		return e && t.docChanged && (e = b(t, e) ? null : {
			...e,
			pos: t.changes.mapPos(e.pos)
		}), t.effects.reduce((e, t) => t.is(X) ? t.value : e, e);
	},
	provide: (e) => u.from(e)
}), ne = /* @__PURE__ */ n.baseTheme({
	".cm-gutter-lint": {
		width: "1.4em",
		"& .cm-gutterElement": { padding: ".2em" }
	},
	".cm-lint-marker": {
		width: "1em",
		height: "1em"
	},
	".cm-lint-marker-info": { content: /* @__PURE__ */ z("<path fill=\"#aaf\" stroke=\"#77e\" stroke-width=\"6\" stroke-linejoin=\"round\" d=\"M5 5L35 5L35 35L5 35Z\"/>") },
	".cm-lint-marker-warning": { content: /* @__PURE__ */ z("<path fill=\"#fe8\" stroke=\"#fd7\" stroke-width=\"6\" stroke-linejoin=\"round\" d=\"M20 6L37 35L3 35Z\"/>") },
	".cm-lint-marker-error": { content: /* @__PURE__ */ z("<circle cx=\"20\" cy=\"20\" r=\"15\" fill=\"#f87\" stroke=\"#f43\" stroke-width=\"6\"/>") }
}), Q = [
	E,
	/* @__PURE__ */ n.decorations.compute([E], (e) => {
		let { selected: t, panel: n } = e.field(E);
		return !t || !n || t.from == t.to ? o.none : o.set([ee.range(t.from, t.to)]);
	}),
	/* @__PURE__ */ d(te, { hideOn: b }),
	V
], $ = /* @__PURE__ */ g.define({ combine(e) {
	return r(e, {
		hoverTime: 300,
		markerFilter: null,
		tooltipFilter: null
	});
} });
function re(e = {}) {
	return [
		$.of(e),
		Y,
		J,
		ne,
		Z
	];
}
//#endregion
export { N as n, re as t };

//# sourceMappingURL=dist-CYSk5SkB.js.map