import has_default from "../../../../lodash-es/has.js";
import isString_default from "../../../../lodash-es/isString.js";
import isUndefined_default from "../../../../lodash-es/isUndefined.js";
import { augmentTokenTypes, tokenStructuredMatcher } from "./tokens.js";
import { Lexer } from "./lexer_public.js";
function tokenLabel(e) {
	return hasTokenLabel(e) ? e.LABEL : e.name;
}
function hasTokenLabel(e) {
	return isString_default(e.LABEL) && e.LABEL !== "";
}
var PARENT = "parent", CATEGORIES = "categories", LABEL = "label", GROUP = "group", PUSH_MODE = "push_mode", POP_MODE = "pop_mode", LONGER_ALT = "longer_alt", LINE_BREAKS = "line_breaks", START_CHARS_HINT = "start_chars_hint";
function createToken(e) {
	return createTokenInternal(e);
}
function createTokenInternal(h) {
	let v = h.pattern, y = {};
	if (y.name = h.name, isUndefined_default(v) || (y.PATTERN = v), has_default(h, PARENT)) throw "The parent property is no longer supported.\nSee: https://github.com/chevrotain/chevrotain/issues/564#issuecomment-349062346 for details.";
	return has_default(h, CATEGORIES) && (y.CATEGORIES = h[CATEGORIES]), augmentTokenTypes([y]), has_default(h, LABEL) && (y.LABEL = h[LABEL]), has_default(h, GROUP) && (y.GROUP = h[GROUP]), has_default(h, POP_MODE) && (y.POP_MODE = h[POP_MODE]), has_default(h, PUSH_MODE) && (y.PUSH_MODE = h[PUSH_MODE]), has_default(h, LONGER_ALT) && (y.LONGER_ALT = h[LONGER_ALT]), has_default(h, LINE_BREAKS) && (y.LINE_BREAKS = h[LINE_BREAKS]), has_default(h, START_CHARS_HINT) && (y.START_CHARS_HINT = h[START_CHARS_HINT]), y;
}
const EOF = createToken({
	name: "EOF",
	pattern: Lexer.NA
});
augmentTokenTypes([EOF]);
function createTokenInstance(e, h, g, _, v, y, b, x) {
	return {
		image: h,
		startOffset: g,
		endOffset: _,
		startLine: v,
		endLine: y,
		startColumn: b,
		endColumn: x,
		tokenTypeIdx: e.tokenTypeIdx,
		tokenType: e
	};
}
function tokenMatcher(e, h) {
	return tokenStructuredMatcher(e, h);
}
export { EOF, createToken, createTokenInstance, hasTokenLabel, tokenLabel, tokenMatcher };
