import { NonTerminal as e, Terminal as t } from "../../../../../@chevrotain/gast/lib/src/model.js";
import { isBranchingProd as n, isOptionalProd as r, isSequenceProd as i } from "../../../../../@chevrotain/gast/lib/src/helpers.js";
//#region ../../node_modules/chevrotain/lib/src/parse/grammar/first.js
function a(r) {
	/* istanbul ignore else */
	if (r instanceof e) return a(r.referencedRule);
	if (r instanceof t) return c(r);
	if (i(r)) return o(r);
	if (n(r)) return s(r);
	throw Error("non exhaustive match");
}
function o(e) {
	let t = [], n = e.definition, i = 0, o = n.length > i, s, c = !0;
	for (; o && c;) s = n[i], c = r(s), t = t.concat(a(s)), i += 1, o = n.length > i;
	return [...new Set(t)];
}
function s(e) {
	let t = e.definition.map((e) => a(e));
	return [...new Set(t.flat())];
}
function c(e) {
	return [e.terminalType];
}
//#endregion
export { a as first };
