import "../../../../../chevrotain@11.0.3/node_modules/chevrotain/lib/src/parse/parser/parser.js";
import { Lexer as p } from "../../../../../chevrotain@11.0.3/node_modules/chevrotain/lib/src/scan/lexer_public.js";
import "../../../../../chevrotain@11.0.3/node_modules/chevrotain/lib/src/scan/tokens_public.js";
import "../../../../../chevrotain@11.0.3/node_modules/chevrotain/lib/src/parse/grammar/lookahead.js";
import "../../../../../chevrotain@11.0.3/node_modules/chevrotain/lib/src/parse/errors_public.js";
import "../../../../../chevrotain@11.0.3/node_modules/chevrotain/lib/src/parse/exceptions_public.js";
import { defaultLexerErrorProvider as a } from "../../../../../chevrotain@11.0.3/node_modules/chevrotain/lib/src/scan/lexer_errors_public.js";
class L {
  buildUnexpectedCharactersMessage(e, o, t, i, n) {
    return a.buildUnexpectedCharactersMessage(e, o, t, i, n);
  }
  buildUnableToPopLexerModeMessage(e) {
    return a.buildUnableToPopLexerModeMessage(e);
  }
}
const l = { mode: "full" };
class v {
  constructor(e) {
    this.errorMessageProvider = e.parser.LexerErrorMessageProvider, this.tokenBuilder = e.parser.TokenBuilder;
    const o = this.tokenBuilder.buildTokens(e.Grammar, {
      caseInsensitive: e.LanguageMetaData.caseInsensitive
    });
    this.tokenTypes = this.toTokenTypeDictionary(o);
    const t = d(o) ? Object.values(o) : o, i = e.LanguageMetaData.mode === "production";
    this.chevrotainLexer = new p(t, {
      positionTracking: "full",
      skipValidations: i,
      errorMessageProvider: this.errorMessageProvider
    });
  }
  get definition() {
    return this.tokenTypes;
  }
  tokenize(e, o = l) {
    var t, i, n;
    const s = this.chevrotainLexer.tokenize(e);
    return {
      tokens: s.tokens,
      errors: s.errors,
      hidden: (t = s.groups.hidden) !== null && t !== void 0 ? t : [],
      report: (n = (i = this.tokenBuilder).flushLexingReport) === null || n === void 0 ? void 0 : n.call(i, e)
    };
  }
  toTokenTypeDictionary(e) {
    if (d(e))
      return e;
    const o = u(e) ? Object.values(e.modes).flat() : e, t = {};
    return o.forEach((i) => t[i.name] = i), t;
  }
}
function c(r) {
  return Array.isArray(r) && (r.length === 0 || "name" in r[0]);
}
function u(r) {
  return r && "modes" in r && "defaultMode" in r;
}
function d(r) {
  return !c(r) && !u(r);
}
export {
  l as DEFAULT_TOKENIZE_OPTIONS,
  v as DefaultLexer,
  L as DefaultLexerErrorMessageProvider,
  u as isIMultiModeLexerDefinition,
  c as isTokenTypeArray,
  d as isTokenTypeDictionary
};
