var headerSeparator = /^-+$/, headerLine = /^(Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)  ?\d{1,2} \d{2}:\d{2}(:\d{2})? [A-Z]{3,4} \d{4} - /, simpleEmail = /^[\w+.-]+@[\w.-]+/;
const rpmChanges = {
  name: "rpmchanges",
  token: function(u) {
    return u.sol() && (u.match(headerSeparator) || u.match(headerLine)) ? "tag" : u.match(simpleEmail) ? "string" : (u.next(), null);
  }
};
var arch = /^(i386|i586|i686|x86_64|ppc64le|ppc64|ppc|ia64|s390x|s390|sparc64|sparcv9|sparc|noarch|alphaev6|alpha|hppa|mipsel)/, preamble = /^[a-zA-Z0-9()]+:/, section = /^%(debug_package|package|description|prep|build|install|files|clean|changelog|preinstall|preun|postinstall|postun|pretrans|posttrans|pre|post|triggerin|triggerun|verifyscript|check|triggerpostun|triggerprein|trigger)/, control_flow_complex = /^%(ifnarch|ifarch|if)/, control_flow_simple = /^%(else|endif)/, operators = /^(\!|\?|\<\=|\<|\>\=|\>|\=\=|\&\&|\|\|)/;
const rpmSpec = {
  name: "rpmspec",
  startState: function() {
    return {
      controlFlow: false,
      macroParameters: false,
      section: false
    };
  },
  token: function(e, l) {
    if (e.peek() == "#") return e.skipToEnd(), "comment";
    if (e.sol()) {
      if (e.match(preamble)) return "header";
      if (e.match(section)) return "atom";
    }
    if (e.match(/^\$\w+/) || e.match(/^\$\{\w+\}/)) return "def";
    if (e.match(control_flow_simple)) return "keyword";
    if (e.match(control_flow_complex)) return l.controlFlow = true, "keyword";
    if (l.controlFlow) {
      if (e.match(operators)) return "operator";
      if (e.match(/^(\d+)/)) return "number";
      e.eol() && (l.controlFlow = false);
    }
    if (e.match(arch)) return e.eol() && (l.controlFlow = false), "number";
    if (e.match(/^%[\w]+/)) return e.match("(") && (l.macroParameters = true), "keyword";
    if (l.macroParameters) {
      if (e.match(/^\d+/)) return "number";
      if (e.match(")")) return l.macroParameters = false, "keyword";
    }
    return e.match(/^%\{\??[\w \-\:\!]+\}/) ? (e.eol() && (l.controlFlow = false), "def") : (e.next(), null);
  }
};
export {
  rpmSpec as n,
  rpmChanges as t
};
