var __rest = (this && this.__rest) || function (s, e) {
  var t = {};
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
    t[p] = s[p];
  if (s != null && typeof Object.getOwnPropertySymbols === "function")
    for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
      if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
        t[p[i]] = s[p[i]];
    }
  return t;
};
import { javascriptGrammar } from './javascript';
/**
 * Grammar definition for TypeScript syntax highlighting.
 * Extends JavaScript grammar with TypeScript-specific constructs such as
 * type annotations, generics, interfaces, enums, decorators, and access modifiers.
 *
 * Note: We destructure `keyword`, `function`, `operator`, and `punctuation` out
 * of the JS grammar and re-add them in the correct order. This ensures:
 * - `builtin` is matched before `keyword` (both contain words like void, null, etc.)
 * - `function` is matched before `operator` and `punctuation` (the function
 *   pattern uses a lookahead for `(` which must still be an unmatched string)
 */
const { 
// eslint-disable-next-line @typescript-eslint/no-unused-vars
keyword: _jsKeyword, function: jsFunction, 
// eslint-disable-next-line @typescript-eslint/no-unused-vars
operator: _jsOperator, punctuation: jsPunctuation } = javascriptGrammar, jsGrammarBase = __rest(javascriptGrammar, ["keyword", "function", "operator", "punctuation"]);
export const typescriptGrammar = Object.assign(Object.assign({}, jsGrammarBase), { 'class-name': [
    {
      pattern: /(\b(?:class|extends|implements|instanceof|interface|new|type)\s+)(?!keyof\b)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?:\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>)?/,
      lookbehind: true,
      greedy: true,
      inside: {
        punctuation: { pattern: /[<>.,]/ },
      },
    },
  ], 'builtin': {
    pattern: /\b(?:Array|Boolean|Date|Function|Map|Number|Object|Promise|RegExp|Set|String|WeakMap|WeakSet|bigint|boolean|never|null|number|string|symbol|undefined|unknown|void)\b/,
  }, 'keyword': [
    {
      pattern: /\b(?:abstract|as|asserts|async|await|break|case|catch|class|const|constructor|continue|debugger|declare|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|infer|instanceof|interface|is|keyof|let|module|namespace|new|null|of|package|private|protected|public|readonly|return|require|set|static|super|switch|this|throw|try|type|typeof|undefined|var|void|while|with|yield)\b/,
    },
  ], 'function': jsFunction, 'generic-function': {
    pattern: /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>(?=\s*\()/,
    greedy: true,
    inside: {
      function: {
        pattern: /^#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*/,
      },
      generic: {
        pattern: /<[\s\S]+/,
        inside: {
          punctuation: { pattern: /[<>(),.]/ },
          keyword: { pattern: /\b(?:extends|infer|keyof)\b/ },
          builtin: {
            pattern: /\b(?:boolean|never|null|number|string|symbol|undefined|unknown|void)\b/,
          },
        },
      },
    },
  }, 'operator': {
    pattern: /--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%|&^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]|!(?=\s*[^=])/,
  }, 'punctuation': jsPunctuation });
