var wordRegexp = function(e) {
  return RegExp("^(?:" + e.join("|") + ")$", "i");
}, tokenBase = function(e) {
  curPunc = null;
  var o = e.next();
  if (o === '"') return e.match(/^.*?"/), "string";
  if (o === "'") return e.match(/^.*?'/), "string";
  if (/[{}\(\),\.;\[\]]/.test(o)) return curPunc = o, "punctuation";
  if (o === "/" && e.eat("/")) return e.skipToEnd(), "comment";
  if (operatorChars.test(o)) return e.eatWhile(operatorChars), null;
  if (e.eatWhile(/[_\w\d]/), e.eat(":")) return e.eatWhile(/[\w\d_\-]/), "atom";
  var s = e.current();
  return funcs.test(s) ? "builtin" : preds.test(s) ? "def" : keywords.test(s) || systemKeywords.test(s) ? "keyword" : "variable";
}, pushContext = function(e, o, s) {
  return e.context = {
    prev: e.context,
    indent: e.indent,
    col: s,
    type: o
  };
}, popContext = function(e) {
  return e.indent = e.context.indent, e.context = e.context.prev;
}, curPunc, funcs = wordRegexp(/* @__PURE__ */ "abs.acos.allShortestPaths.asin.atan.atan2.avg.ceil.coalesce.collect.cos.cot.count.degrees.e.endnode.exp.extract.filter.floor.haversin.head.id.keys.labels.last.left.length.log.log10.lower.ltrim.max.min.node.nodes.percentileCont.percentileDisc.pi.radians.rand.range.reduce.rel.relationship.relationships.replace.reverse.right.round.rtrim.shortestPath.sign.sin.size.split.sqrt.startnode.stdev.stdevp.str.substring.sum.tail.tan.timestamp.toFloat.toInt.toString.trim.type.upper".split(".")), preds = wordRegexp([
  "all",
  "and",
  "any",
  "contains",
  "exists",
  "has",
  "in",
  "none",
  "not",
  "or",
  "single",
  "xor"
]), keywords = wordRegexp(/* @__PURE__ */ "as.asc.ascending.assert.by.case.commit.constraint.create.csv.cypher.delete.desc.descending.detach.distinct.drop.else.end.ends.explain.false.fieldterminator.foreach.from.headers.in.index.is.join.limit.load.match.merge.null.on.optional.order.periodic.profile.remove.return.scan.set.skip.start.starts.then.true.union.unique.unwind.using.when.where.with.call.yield".split(".")), systemKeywords = wordRegexp(/* @__PURE__ */ "access.active.assign.all.alter.as.catalog.change.copy.create.constraint.constraints.current.database.databases.dbms.default.deny.drop.element.elements.exists.from.grant.graph.graphs.if.index.indexes.label.labels.management.match.name.names.new.node.nodes.not.of.on.or.password.populated.privileges.property.read.relationship.relationships.remove.replace.required.revoke.role.roles.set.show.start.status.stop.suspended.to.traverse.type.types.user.users.with.write".split(".")), operatorChars = /[*+\-<>=&|~%^]/;
const cypher = {
  name: "cypher",
  startState: function() {
    return {
      tokenize: tokenBase,
      context: null,
      indent: 0,
      col: 0
    };
  },
  token: function(e, o) {
    if (e.sol() && (o.context && o.context.align == null && (o.context.align = false), o.indent = e.indentation()), e.eatSpace()) return null;
    var u = o.tokenize(e, o);
    if (u !== "comment" && o.context && o.context.align == null && o.context.type !== "pattern" && (o.context.align = true), curPunc === "(") pushContext(o, ")", e.column());
    else if (curPunc === "[") pushContext(o, "]", e.column());
    else if (curPunc === "{") pushContext(o, "}", e.column());
    else if (/[\]\}\)]/.test(curPunc)) {
      for (; o.context && o.context.type === "pattern"; ) popContext(o);
      o.context && curPunc === o.context.type && popContext(o);
    } else curPunc === "." && o.context && o.context.type === "pattern" ? popContext(o) : /atom|string|variable/.test(u) && o.context && (/[\}\]]/.test(o.context.type) ? pushContext(o, "pattern", e.column()) : o.context.type === "pattern" && !o.context.align && (o.context.align = true, o.context.col = e.column()));
    return u;
  },
  indent: function(e, o, s) {
    var c = o && o.charAt(0), l = e.context;
    if (/[\]\}]/.test(c)) for (; l && l.type === "pattern"; ) l = l.prev;
    var u = l && c === l.type;
    return l ? l.type === "keywords" ? null : l.align ? l.col + (u ? 0 : 1) : l.indent + (u ? 0 : s.unit) : 0;
  }
};
export {
  cypher as t
};
