import { defaultGrammarValidatorErrorProvider as e } from "../errors_public.js";
import { buildAlternativesLookAheadFunc as t, buildLookaheadFuncForOptionalProd as n, buildLookaheadFuncForOr as r, buildSingleAlternativeLookaheadFunction as i, getProdType as a } from "./lookahead.js";
import { validateAmbiguousAlternationAlternatives as o, validateEmptyOrAlternative as s, validateNoLeftRecursion as c, validateSomeNonEmptyLookaheadPath as l } from "./checks.js";
import { DEFAULT_PARSER_CONFIG as u } from "../parser/parser.js";
//#region ../../node_modules/chevrotain/lib/src/parse/grammar/llk_lookahead.js
var d = class {
	constructor(e) {
		this.maxLookahead = e?.maxLookahead ?? u.maxLookahead;
	}
	validate(e) {
		let t = this.validateNoLeftRecursion(e.rules);
		if (t.length === 0) {
			let n = this.validateEmptyOrAlternatives(e.rules), r = this.validateAmbiguousAlternationAlternatives(e.rules, this.maxLookahead), i = this.validateSomeNonEmptyLookaheadPath(e.rules, this.maxLookahead);
			return [
				...t,
				...n,
				...r,
				...i
			];
		}
		return t;
	}
	validateNoLeftRecursion(t) {
		return t.flatMap((t) => c(t, t, e));
	}
	validateEmptyOrAlternatives(t) {
		return t.flatMap((t) => s(t, e));
	}
	validateAmbiguousAlternationAlternatives(t, n) {
		return t.flatMap((t) => o(t, n, e));
	}
	validateSomeNonEmptyLookaheadPath(t, n) {
		return l(t, n, e);
	}
	buildLookaheadForAlternation(e) {
		return r(e.prodOccurrence, e.rule, e.maxLookahead, e.hasPredicates, e.dynamicTokensEnabled, t);
	}
	buildLookaheadForOptional(e) {
		return n(e.prodOccurrence, e.rule, e.maxLookahead, e.dynamicTokensEnabled, a(e.prodType), i);
	}
};
//#endregion
export { d as LLkLookaheadStrategy };
