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