var rfc2822=["From","Sender","Reply-To","To","Cc","Bcc","Message-ID","In-Reply-To","References","Resent-From","Resent-Sender","Resent-To","Resent-Cc","Resent-Bcc","Resent-Message-ID","Return-Path","Received"],rfc2822NoEmail=["Date","Subject","Comments","Keywords","Resent-Date"],whitespace=/^[ \t]/,separator=/^From /,rfc2822Header=new RegExp("^("+rfc2822.join("|")+"): "),rfc2822HeaderNoEmail=new RegExp("^("+rfc2822NoEmail.join("|")+"): "),header=/^[^:]+:/,email=/^[^ ]+@[^ ]+/,untilEmail=/^.*?(?=[^ ]+?@[^ ]+)/,bracketedEmail=/^<.*?>/,untilBracketedEmail=/^.*?(?=<.*>)/;function styleForHeader(e){return "Subject"===e?"header":"string"}function readToken(e,r){if(e.sol()){if(r.inSeparator=!1,r.inHeader&&e.match(whitespace))return null;if(r.inHeader=!1,r.header=null,e.match(separator))return r.inHeaders=!0,r.inSeparator=!0,"atom";var a,t=!1;return (a=e.match(rfc2822HeaderNoEmail))||(t=!0)&&(a=e.match(rfc2822Header))?(r.inHeaders=!0,r.inHeader=!0,r.emailPermitted=t,r.header=a[1],"atom"):r.inHeaders&&(a=e.match(header))?(r.inHeader=!0,r.emailPermitted=!0,r.header=a[1],"atom"):(r.inHeaders=!1,e.skipToEnd(),null)}if(r.inSeparator)return e.match(email)?"link":(e.match(untilEmail)||e.skipToEnd(),"atom");if(r.inHeader){var n=styleForHeader(r.header);if(r.emailPermitted){if(e.match(bracketedEmail))return n+" link";if(e.match(untilBracketedEmail))return n}return e.skipToEnd(),n}return e.skipToEnd(),null}const mbox={startState:function(){return {inSeparator:!1,inHeader:!1,emailPermitted:!1,header:null,inHeaders:!1}},token:readToken,blankLine:function(e){e.inHeaders=e.inSeparator=e.inHeader=!1;},languageData:{autocomplete:rfc2822.concat(rfc2822NoEmail)}};

export { mbox };
