function wordSet(e) {
  for (var f = {}, p = 0; p < e.length; p++) f[e[p]] = true;
  return f;
}
var keywords = wordSet(/* @__PURE__ */ "_.var.let.actor.class.enum.extension.import.protocol.struct.func.typealias.associatedtype.open.public.internal.fileprivate.private.deinit.init.new.override.self.subscript.super.convenience.dynamic.final.indirect.lazy.required.static.unowned.unowned(safe).unowned(unsafe).weak.as.is.break.case.continue.default.else.fallthrough.for.guard.if.in.repeat.switch.where.while.defer.return.inout.mutating.nonmutating.isolated.nonisolated.catch.do.rethrows.throw.throws.async.await.try.didSet.get.set.willSet.assignment.associativity.infix.left.none.operator.postfix.precedence.precedencegroup.prefix.right.Any.AnyObject.Type.dynamicType.Self.Protocol.__COLUMN__.__FILE__.__FUNCTION__.__LINE__".split(".")), definingKeywords = wordSet([
  "var",
  "let",
  "actor",
  "class",
  "enum",
  "extension",
  "import",
  "protocol",
  "struct",
  "func",
  "typealias",
  "associatedtype",
  "for"
]), atoms = wordSet([
  "true",
  "false",
  "nil",
  "self",
  "super",
  "_"
]), types = wordSet([
  "Array",
  "Bool",
  "Character",
  "Dictionary",
  "Double",
  "Float",
  "Int",
  "Int8",
  "Int16",
  "Int32",
  "Int64",
  "Never",
  "Optional",
  "Set",
  "String",
  "UInt8",
  "UInt16",
  "UInt32",
  "UInt64",
  "Void"
]), operators = "+-/*%=|&<>~^?!", punc = ":;,.(){}[]", binary = /^\-?0b[01][01_]*/, octal = /^\-?0o[0-7][0-7_]*/, hexadecimal = /^\-?0x[\dA-Fa-f][\dA-Fa-f_]*(?:(?:\.[\dA-Fa-f][\dA-Fa-f_]*)?[Pp]\-?\d[\d_]*)?/, decimal = /^\-?\d[\d_]*(?:\.\d[\d_]*)?(?:[Ee]\-?\d[\d_]*)?/, identifier = /^\$\d+|(`?)[_A-Za-z][_A-Za-z$0-9]*\1/, property = /^\.(?:\$\d+|(`?)[_A-Za-z][_A-Za-z$0-9]*\1)/, instruction = /^\#[A-Za-z]+/, attribute = /^@(?:\$\d+|(`?)[_A-Za-z][_A-Za-z$0-9]*\1)/;
function tokenBase(e, _, v) {
  if (e.sol() && (_.indented = e.indentation()), e.eatSpace()) return null;
  var y = e.peek();
  if (y == "/") {
    if (e.match("//")) return e.skipToEnd(), "comment";
    if (e.match("/*")) return _.tokenize.push(tokenComment), tokenComment(e, _);
  }
  if (e.match(instruction)) return "builtin";
  if (e.match(attribute)) return "attribute";
  if (e.match(binary) || e.match(octal) || e.match(hexadecimal) || e.match(decimal)) return "number";
  if (e.match(property)) return "property";
  if (operators.indexOf(y) > -1) return e.next(), "operator";
  if (punc.indexOf(y) > -1) return e.next(), e.match(".."), "punctuation";
  var b;
  if (b = e.match(/("""|"|')/)) {
    var x = tokenString.bind(null, b[0]);
    return _.tokenize.push(x), x(e, _);
  }
  if (e.match(identifier)) {
    var S = e.current();
    return types.hasOwnProperty(S) ? "type" : atoms.hasOwnProperty(S) ? "atom" : keywords.hasOwnProperty(S) ? (definingKeywords.hasOwnProperty(S) && (_.prev = "define"), "keyword") : v == "define" ? "def" : "variable";
  }
  return e.next(), null;
}
function tokenUntilClosingParen() {
  var e = 0;
  return function(f, p, m) {
    var h = tokenBase(f, p, m);
    if (h == "punctuation") {
      if (f.current() == "(") ++e;
      else if (f.current() == ")") {
        if (e == 0) return f.backUp(1), p.tokenize.pop(), p.tokenize[p.tokenize.length - 1](f, p);
        --e;
      }
    }
    return h;
  };
}
function tokenString(e, f, p) {
  for (var m = e.length == 1, h, g = false; h = f.peek(); ) if (g) {
    if (f.next(), h == "(") return p.tokenize.push(tokenUntilClosingParen()), "string";
    g = false;
  } else if (f.match(e)) return p.tokenize.pop(), "string";
  else f.next(), g = h == "\\";
  return m && p.tokenize.pop(), "string";
}
function tokenComment(e, f) {
  for (var p; p = e.next(); ) if (p === "/" && e.eat("*")) f.tokenize.push(tokenComment);
  else if (p === "*" && e.eat("/")) {
    f.tokenize.pop();
    break;
  }
  return "comment";
}
function Context(e, f, p) {
  this.prev = e, this.align = f, this.indented = p;
}
function pushContext(e, f) {
  var p = f.match(/^\s*($|\/[\/\*]|[)}\]])/, false) ? null : f.column() + 1;
  e.context = new Context(e.context, p, e.indented);
}
function popContext(e) {
  e.context && (e.context = (e.indented = e.context.indented, e.context.prev));
}
const swift = {
  name: "swift",
  startState: function() {
    return {
      prev: null,
      context: null,
      indented: 0,
      tokenize: []
    };
  },
  token: function(e, f) {
    var p = f.prev;
    f.prev = null;
    var m = (f.tokenize[f.tokenize.length - 1] || tokenBase)(e, f, p);
    if (!m || m == "comment" ? f.prev = p : f.prev || (f.prev = m), m == "punctuation") {
      var h = /[\(\[\{]|([\]\)\}])/.exec(e.current());
      h && (h[1] ? popContext : pushContext)(f, e);
    }
    return m;
  },
  indent: function(e, f, p) {
    var m = e.context;
    if (!m) return 0;
    var h = /^[\]\}\)]/.test(f);
    return m.align == null ? m.indented + (h ? 0 : p.unit) : m.align - (h ? 1 : 0);
  },
  languageData: {
    indentOnInput: /^\s*[\)\}\]]$/,
    commentTokens: {
      line: "//",
      block: {
        open: "/*",
        close: "*/"
      }
    },
    closeBrackets: { brackets: [
      "(",
      "[",
      "{",
      "'",
      '"',
      "`"
    ] }
  }
};
export {
  swift as t
};
