import { resolveGrammar as resolveGrammar$1 } from '../resolver.mjs';
import { validateGrammar as validateGrammar$1 } from '../checks.mjs';
import { defaultGrammarResolverErrorProvider, defaultGrammarValidatorErrorProvider } from '../../errors_public.mjs';
import defaults from '../../../../../../../../lodash-es@4.17.21/node_modules/lodash-es/defaults.mjs';
import forEach from '../../../../../../../../lodash-es@4.17.21/node_modules/lodash-es/forEach.mjs';

function resolveGrammar(options) {
    const actualOptions = defaults(options, {
        errMsgProvider: defaultGrammarResolverErrorProvider,
    });
    const topRulesTable = {};
    forEach(options.rules, (rule) => {
        topRulesTable[rule.name] = rule;
    });
    return resolveGrammar$1(topRulesTable, actualOptions.errMsgProvider);
}
function validateGrammar(options) {
    options = defaults(options, {
        errMsgProvider: defaultGrammarValidatorErrorProvider,
    });
    return validateGrammar$1(options.rules, options.tokenTypes, options.errMsgProvider, options.grammarName);
}

export { resolveGrammar, validateGrammar };
