import { NonTerminal as e, Rule as t, Terminal as n } from "../../../../@chevrotain/gast/lib/src/model.js";
import { getProductionDslName as r } from "../../../../@chevrotain/gast/lib/src/helpers.js";
import { hasTokenLabel as i, tokenLabel as a } from "../scan/tokens_public.js";
//#region ../../node_modules/chevrotain/lib/src/parse/errors_public.js
var o = {
	buildMismatchTokenMessage({ expected: e, actual: t, previous: n, ruleName: r }) {
		return `Expecting ${i(e) ? `--> ${a(e)} <--` : `token of type --> ${e.name} <--`} but found --> '${t.image}' <--`;
	},
	buildNotAllInputParsedMessage({ firstRedundant: e, ruleName: t }) {
		return "Redundant input, expecting EOF but found: " + e.image;
	},
	buildNoViableAltMessage({ expectedPathsPerAlt: e, actual: t, previous: n, customUserDescription: r, ruleName: i }) {
		let o = "\nbut found: '" + t[0].image + "'";
		return r ? "Expecting: " + r + o : `Expecting: one of these possible Token sequences:\n${e.reduce((e, t) => e.concat(t), []).map((e) => `[${e.map((e) => a(e)).join(", ")}]`).map((e, t) => `  ${t + 1}. ${e}`).join("\n")}` + o;
	},
	buildEarlyExitMessage({ expectedIterationPaths: e, actual: t, customUserDescription: n, ruleName: r }) {
		let i = "\nbut found: '" + t[0].image + "'";
		return n ? "Expecting: " + n + i : `Expecting: expecting at least one iteration which starts with one of these possible Token sequences::\n  <${e.map((e) => `[${e.map((e) => a(e)).join(",")}]`).join(" ,")}>` + i;
	}
};
Object.freeze(o);
var s = { buildRuleNotFoundError(e, t) {
	return "Invalid grammar, reference to a rule which is not defined: ->" + t.nonTerminalName + "<-\ninside top level rule: ->" + e.name + "<-";
} }, c = {
	buildDuplicateFoundError(t, i) {
		function a(t) {
			return t instanceof n ? t.terminalType.name : t instanceof e ? t.nonTerminalName : "";
		}
		let o = t.name, s = i[0], c = s.idx, l = r(s), u = a(s), d = `->${l}${c > 0 ? c : ""}<- ${u ? `with argument: ->${u}<-` : ""}
                  appears more than once (${i.length} times) in the top level rule: ->${o}<-.                  
                  For further details see: https://chevrotain.io/docs/FAQ.html#NUMERICAL_SUFFIXES 
                  `;
		return d = d.replace(/[ \t]+/g, " "), d = d.replace(/\s\s+/g, "\n"), d;
	},
	buildNamespaceConflictError(e) {
		return `Namespace conflict found in grammar.\nThe grammar has both a Terminal(Token) and a Non-Terminal(Rule) named: <${e.name}>.\nTo resolve this make sure each Terminal and Non-Terminal names are unique\nThis is easy to accomplish by using the convention that Terminal names start with an uppercase letter\nand Non-Terminal names start with a lower case letter.`;
	},
	buildAlternationPrefixAmbiguityError(e) {
		let t = e.prefixPath.map((e) => a(e)).join(", "), n = e.alternation.idx === 0 ? "" : e.alternation.idx;
		return `Ambiguous alternatives: <${e.ambiguityIndices.join(" ,")}> due to common lookahead prefix\nin <OR${n}> inside <${e.topLevelRule.name}> Rule,\n<${t}> may appears as a prefix path in all these alternatives.\nSee: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#COMMON_PREFIX\nFor Further details.`;
	},
	buildAlternationAmbiguityError(e) {
		let t = e.alternation.idx === 0 ? "" : e.alternation.idx, n = e.prefixPath.length === 0, r = `Ambiguous Alternatives Detected: <${e.ambiguityIndices.join(" ,")}> in <OR${t}> inside <${e.topLevelRule.name}> Rule,\n`;
		if (n) r += "These alternatives are all empty (match no tokens), making them indistinguishable.\nOnly the last alternative may be empty.\n";
		else {
			let t = e.prefixPath.map((e) => a(e)).join(", ");
			r += `<${t}> may appears as a prefix path in all these alternatives.\n`;
		}
		return r += "See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#AMBIGUOUS_ALTERNATIVES\nFor Further details.", r;
	},
	buildEmptyRepetitionError(e) {
		let t = r(e.repetition);
		return e.repetition.idx !== 0 && (t += e.repetition.idx), `The repetition <${t}> within Rule <${e.topLevelRule.name}> can never consume any tokens.\nThis could lead to an infinite loop.`;
	},
	buildTokenNameError(e) {
		/* istanbul ignore next */
		return "deprecated";
	},
	buildEmptyAlternationError(e) {
		return `Ambiguous empty alternative: <${e.emptyChoiceIdx + 1}> in <OR${e.alternation.idx}> inside <${e.topLevelRule.name}> Rule.\nOnly the last alternative may be an empty alternative.`;
	},
	buildTooManyAlternativesError(e) {
		return `An Alternation cannot have more than 256 alternatives:\n<OR${e.alternation.idx}> inside <${e.topLevelRule.name}> Rule.\n has ${e.alternation.definition.length + 1} alternatives.`;
	},
	buildLeftRecursionError(e) {
		let t = e.topLevelRule.name;
		return `Left Recursion found in grammar.\nrule: <${t}> can be invoked from itself (directly or indirectly)\nwithout consuming any Tokens. The grammar path that causes this is: \n ${`${t} --> ${e.leftRecursionPath.map((e) => e.name).concat([t]).join(" --> ")}`}\n To fix this refactor your grammar to remove the left recursion.\nsee: https://en.wikipedia.org/wiki/LL_parser#Left_factoring.`;
	},
	buildInvalidRuleNameError(e) {
		/* istanbul ignore next */
		return "deprecated";
	},
	buildDuplicateRuleNameError(e) {
		let n;
		return n = e.topLevelRule instanceof t ? e.topLevelRule.name : e.topLevelRule, `Duplicate definition, rule: ->${n}<- is already defined in the grammar: ->${e.grammarName}<-`;
	}
};
//#endregion
export { s as defaultGrammarResolverErrorProvider, c as defaultGrammarValidatorErrorProvider, o as defaultParserErrorProvider };
