function wordRegexp(e) {
  return /* @__PURE__ */ RegExp("^((" + e.join(")|(") + "))\\b");
}
var builtinArray = [
  "Clamp",
  "Constructor",
  "EnforceRange",
  "Exposed",
  "ImplicitThis",
  "Global",
  "PrimaryGlobal",
  "LegacyArrayClass",
  "LegacyUnenumerableNamedProperties",
  "LenientThis",
  "NamedConstructor",
  "NewObject",
  "NoInterfaceObject",
  "OverrideBuiltins",
  "PutForwards",
  "Replaceable",
  "SameObject",
  "TreatNonObjectAsNull",
  "TreatNullAs",
  "EmptyString",
  "Unforgeable",
  "Unscopeable"
], builtins = wordRegexp(builtinArray), typeArray = /* @__PURE__ */ "unsigned.short.long.unrestricted.float.double.boolean.byte.octet.Promise.ArrayBuffer.DataView.Int8Array.Int16Array.Int32Array.Uint8Array.Uint16Array.Uint32Array.Uint8ClampedArray.Float32Array.Float64Array.ByteString.DOMString.USVString.sequence.object.RegExp.Error.DOMException.FrozenArray.any.void".split("."), types = wordRegexp(typeArray), keywordArray = [
  "attribute",
  "callback",
  "const",
  "deleter",
  "dictionary",
  "enum",
  "getter",
  "implements",
  "inherit",
  "interface",
  "iterable",
  "legacycaller",
  "maplike",
  "partial",
  "required",
  "serializer",
  "setlike",
  "setter",
  "static",
  "stringifier",
  "typedef",
  "optional",
  "readonly",
  "or"
], keywords = wordRegexp(keywordArray), atomArray = [
  "true",
  "false",
  "Infinity",
  "NaN",
  "null"
], atoms = wordRegexp(atomArray), startDefs = wordRegexp([
  "callback",
  "dictionary",
  "enum",
  "interface"
]), endDefs = wordRegexp(["typedef"]), singleOperators = /^[:<=>?]/, integers = /^-?([1-9][0-9]*|0[Xx][0-9A-Fa-f]+|0[0-7]*)/, floats = /^-?(([0-9]+\.[0-9]*|[0-9]*\.[0-9]+)([Ee][+-]?[0-9]+)?|[0-9]+[Ee][+-]?[0-9]+)/, identifiers = /^_?[A-Za-z][0-9A-Z_a-z-]*/, identifiersEnd = /^_?[A-Za-z][0-9A-Z_a-z-]*(?=\s*;)/, strings = /^"[^"]*"/, multilineComments = /^\/\*.*?\*\//, multilineCommentsStart = /^\/\*.*/, multilineCommentsEnd = /^.*?\*\//;
function readToken(e, v) {
  if (e.eatSpace()) return null;
  if (v.inComment) return e.match(multilineCommentsEnd) ? (v.inComment = false, "comment") : (e.skipToEnd(), "comment");
  if (e.match("//")) return e.skipToEnd(), "comment";
  if (e.match(multilineComments)) return "comment";
  if (e.match(multilineCommentsStart)) return v.inComment = true, "comment";
  if (e.match(/^-?[0-9\.]/, false) && (e.match(integers) || e.match(floats))) return "number";
  if (e.match(strings)) return "string";
  if (v.startDef && e.match(identifiers)) return "def";
  if (v.endDef && e.match(identifiersEnd)) return v.endDef = false, "def";
  if (e.match(keywords)) return "keyword";
  if (e.match(types)) {
    var b = v.lastToken, x = (e.match(/^\s*(.+?)\b/, false) || [])[1];
    return b === ":" || b === "implements" || x === "implements" || x === "=" ? "builtin" : "type";
  }
  return e.match(builtins) ? "builtin" : e.match(atoms) ? "atom" : e.match(identifiers) ? "variable" : e.match(singleOperators) ? "operator" : (e.next(), null);
}
const webIDL = {
  name: "webidl",
  startState: function() {
    return {
      inComment: false,
      lastToken: "",
      startDef: false,
      endDef: false
    };
  },
  token: function(e, v) {
    var y = readToken(e, v);
    if (y) {
      var b = e.current();
      v.lastToken = b, y === "keyword" ? (v.startDef = startDefs.test(b), v.endDef = v.endDef || endDefs.test(b)) : v.startDef = false;
    }
    return y;
  },
  languageData: { autocomplete: builtinArray.concat(typeArray).concat(keywordArray).concat(atomArray) }
};
export {
  webIDL as t
};
