import { toFastProperties as e } from "../../../../../@chevrotain/utils/lib/src/to-fast-properties.js";
import { computeAllProdsFollows as t } from "../grammar/follow.js";
import { EOF as n, createTokenInstance as r } from "../../scan/tokens_public.js";
import { defaultGrammarValidatorErrorProvider as i, defaultParserErrorProvider as a } from "../errors_public.js";
import { validateLookahead as o } from "../grammar/checks.js";
import { resolveGrammar as s, validateGrammar as c } from "../grammar/gast/gast_resolver_public.js";
import { Recoverable as l } from "./traits/recoverable.js";
import { LooksAhead as u } from "./traits/looksahead.js";
import { TreeBuilder as d } from "./traits/tree_builder.js";
import { LexerAdapter as f } from "./traits/lexer_adapter.js";
import { RecognizerApi as p } from "./traits/recognizer_api.js";
import { RecognizerEngine as m } from "./traits/recognizer_engine.js";
import { ErrorHandler as h } from "./traits/error_handler.js";
import { GastRecorder as g } from "./traits/gast_recorder.js";
import { PerformanceTracer as _ } from "./traits/perf_tracer.js";
import { applyMixins as v } from "./utils/apply_mixins.js";
//#region ../../node_modules/chevrotain/lib/src/parse/parser/parser.js
var y = r(n, "", NaN, NaN, NaN, NaN, NaN, NaN);
Object.freeze(y);
var b = Object.freeze({
	recoveryEnabled: !1,
	maxLookahead: 3,
	dynamicTokensEnabled: !1,
	outputCst: !0,
	errorMessageProvider: a,
	nodeLocationTracking: "none",
	traceInitPerf: !1,
	skipValidations: !1
}), x = Object.freeze({
	recoveryValueFunc: () => void 0,
	resyncEnabled: !0
}), S;
(function(e) {
	e[e.INVALID_RULE_NAME = 0] = "INVALID_RULE_NAME", e[e.DUPLICATE_RULE_NAME = 1] = "DUPLICATE_RULE_NAME", e[e.INVALID_RULE_OVERRIDE = 2] = "INVALID_RULE_OVERRIDE", e[e.DUPLICATE_PRODUCTIONS = 3] = "DUPLICATE_PRODUCTIONS", e[e.UNRESOLVED_SUBRULE_REF = 4] = "UNRESOLVED_SUBRULE_REF", e[e.LEFT_RECURSION = 5] = "LEFT_RECURSION", e[e.NONE_LAST_EMPTY_ALT = 6] = "NONE_LAST_EMPTY_ALT", e[e.AMBIGUOUS_ALTS = 7] = "AMBIGUOUS_ALTS", e[e.CONFLICT_TOKENS_RULES_NAMESPACE = 8] = "CONFLICT_TOKENS_RULES_NAMESPACE", e[e.INVALID_TOKEN_NAME = 9] = "INVALID_TOKEN_NAME", e[e.NO_NON_EMPTY_LOOKAHEAD = 10] = "NO_NON_EMPTY_LOOKAHEAD", e[e.AMBIGUOUS_PREFIX_ALTS = 11] = "AMBIGUOUS_PREFIX_ALTS", e[e.TOO_MANY_ALTS = 12] = "TOO_MANY_ALTS", e[e.CUSTOM_LOOKAHEAD_VALIDATION = 13] = "CUSTOM_LOOKAHEAD_VALIDATION";
})(S ||= {});
function C(e = void 0) {
	return function() {
		return e;
	};
}
var w = class n {
	static performSelfAnalysis(e) {
		throw Error("The **static** `performSelfAnalysis` method has been deprecated.	\nUse the **instance** method with the same name instead.");
	}
	performSelfAnalysis() {
		this.TRACE_INIT("performSelfAnalysis", () => {
			let r;
			this.selfAnalysisDone = !0;
			let a = this.className;
			this.TRACE_INIT("toFastProps", () => {
				e(this);
			}), this.TRACE_INIT("Grammar Recording", () => {
				try {
					this.enableRecording(), this.definedRulesNames.forEach((e) => {
						let t = this[e].originalGrammarAction, n;
						this.TRACE_INIT(`${e} Rule`, () => {
							n = this.topLevelRuleRecord(e, t);
						}), this.gastProductionsCache[e] = n;
					});
				} finally {
					this.disableRecording();
				}
			});
			let l = [];
			if (this.TRACE_INIT("Grammar Resolving", () => {
				l = s({ rules: Object.values(this.gastProductionsCache) }), this.definitionErrors = this.definitionErrors.concat(l);
			}), this.TRACE_INIT("Grammar Validations", () => {
				if (l.length === 0 && this.skipValidations === !1) {
					let e = c({
						rules: Object.values(this.gastProductionsCache),
						tokenTypes: Object.values(this.tokensMap),
						errMsgProvider: i,
						grammarName: a
					}), t = o({
						lookaheadStrategy: this.lookaheadStrategy,
						rules: Object.values(this.gastProductionsCache),
						tokenTypes: Object.values(this.tokensMap),
						grammarName: a
					});
					this.definitionErrors = this.definitionErrors.concat(e, t);
				}
			}), this.definitionErrors.length === 0 && (this.recoveryEnabled && this.TRACE_INIT("computeAllProdsFollows", () => {
				this.resyncFollows = t(Object.values(this.gastProductionsCache));
			}), this.TRACE_INIT("ComputeLookaheadFunctions", () => {
				var e, t;
				(t = (e = this.lookaheadStrategy).initialize) == null || t.call(e, { rules: Object.values(this.gastProductionsCache) }), this.preComputeLookaheadFunctions(Object.values(this.gastProductionsCache));
			})), !n.DEFER_DEFINITION_ERRORS_HANDLING && this.definitionErrors.length !== 0) throw r = this.definitionErrors.map((e) => e.message), Error(`Parser Definition Errors detected:\n ${r.join("\n-------------------------------\n")}`);
		});
	}
	constructor(e, t) {
		this.definitionErrors = [], this.selfAnalysisDone = !1;
		let n = this;
		if (n.initErrorHandler(t), n.initLexerAdapter(), n.initLooksAhead(t), n.initRecognizerEngine(e, t), n.initRecoverable(t), n.initTreeBuilder(t), n.initGastRecorder(t), n.initPerformanceTracer(t), Object.hasOwn(t, "ignoredIssues")) throw Error("The <ignoredIssues> IParserConfig property has been deprecated.\n	Please use the <IGNORE_AMBIGUITIES> flag on the relevant DSL method instead.\n	See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#IGNORING_AMBIGUITIES\n	For further details.");
		this.skipValidations = Object.hasOwn(t, "skipValidations") ? t.skipValidations : b.skipValidations;
	}
};
w.DEFER_DEFINITION_ERRORS_HANDLING = !1, v(w, [
	l,
	u,
	d,
	f,
	m,
	p,
	h,
	g,
	_
]);
var T = class extends w {
	constructor(e, t = b) {
		let n = Object.assign({}, t);
		n.outputCst = !1, super(e, n);
	}
};
//#endregion
export { b as DEFAULT_PARSER_CONFIG, x as DEFAULT_RULE_CONFIG, C as EMPTY_ALT, y as END_OF_FILE, T as EmbeddedActionsParser, S as ParserDefinitionErrorType };
