import { stringifyPosition } from "../../unist-util-stringify-position/lib/index.js";
var VFileMessage = class extends Error {
	constructor(t, n, r) {
		super(), typeof n == "string" && (r = n, n = void 0);
		let i = "", a = {}, o = !1;
		if (n && (a = "line" in n && "column" in n || "start" in n && "end" in n ? { place: n } : "type" in n ? {
			ancestors: [n],
			place: n.position
		} : { ...n }), typeof t == "string" ? i = t : !a.cause && t && (o = !0, i = t.message, a.cause = t), !a.ruleId && !a.source && typeof r == "string") {
			let e = r.indexOf(":");
			e === -1 ? a.ruleId = r : (a.source = r.slice(0, e), a.ruleId = r.slice(e + 1));
		}
		if (!a.place && a.ancestors && a.ancestors) {
			let e = a.ancestors[a.ancestors.length - 1];
			e && (a.place = e.position);
		}
		let s = a.place && "start" in a.place ? a.place.start : a.place;
		this.ancestors = a.ancestors || void 0, this.cause = a.cause || void 0, this.column = s ? s.column : void 0, this.fatal = void 0, this.file = "", this.message = i, this.line = s ? s.line : void 0, this.name = stringifyPosition(a.place) || "1:1", this.place = a.place || void 0, this.reason = this.message, this.ruleId = a.ruleId || void 0, this.source = a.source || void 0, this.stack = o && a.cause && typeof a.cause.stack == "string" ? a.cause.stack : "", this.actual = void 0, this.expected = void 0, this.note = void 0, this.url = void 0;
	}
};
VFileMessage.prototype.file = "", VFileMessage.prototype.name = "", VFileMessage.prototype.reason = "", VFileMessage.prototype.message = "", VFileMessage.prototype.stack = "", VFileMessage.prototype.column = void 0, VFileMessage.prototype.line = void 0, VFileMessage.prototype.ancestors = void 0, VFileMessage.prototype.cause = void 0, VFileMessage.prototype.fatal = void 0, VFileMessage.prototype.place = void 0, VFileMessage.prototype.ruleId = void 0, VFileMessage.prototype.source = void 0;
export { VFileMessage };
