var ERRORCLASS="error";function wordRegexp(e){return new RegExp("^(("+e.join(")|(")+"))\\b","i")}var singleOperators=new RegExp("^[\\+\\-\\*/%&\\\\|\\^~<>!]"),singleDelimiters=new RegExp("^[\\(\\)\\[\\]\\{\\}@,:`=;\\.]"),doubleOperators=new RegExp("^((==)|(<>)|(<=)|(>=)|(<>)|(<<)|(>>)|(//)|(\\*\\*))"),doubleDelimiters=new RegExp("^((\\+=)|(\\-=)|(\\*=)|(%=)|(/=)|(&=)|(\\|=)|(\\^=))"),tripleDelimiters=new RegExp("^((//=)|(>>=)|(<<=)|(\\*\\*=))"),identifiers=new RegExp("^[_A-Za-z][_A-Za-z0-9]*"),openingKeywords=["class","module","sub","enum","select","while","if","function","get","set","property","try","structure","synclock","using","with"],middleKeywords=["else","elseif","case","catch","finally"],endKeywords=["next","loop"],operatorKeywords=["and","andalso","or","orelse","xor","in","not","is","isnot","like"],wordOperators=wordRegexp(operatorKeywords),commonKeywords=["#const","#else","#elseif","#end","#if","#region","addhandler","addressof","alias","as","byref","byval","cbool","cbyte","cchar","cdate","cdbl","cdec","cint","clng","cobj","compare","const","continue","csbyte","cshort","csng","cstr","cuint","culng","cushort","declare","default","delegate","dim","directcast","each","erase","error","event","exit","explicit","false","for","friend","gettype","goto","handles","implements","imports","infer","inherits","interface","isfalse","istrue","lib","me","mod","mustinherit","mustoverride","my","mybase","myclass","namespace","narrowing","new","nothing","notinheritable","notoverridable","of","off","on","operator","option","optional","out","overloads","overridable","overrides","paramarray","partial","private","protected","public","raiseevent","readonly","redim","removehandler","resume","return","shadows","shared","static","step","stop","strict","then","throw","to","true","trycast","typeof","until","until","when","widening","withevents","writeonly"],commontypes=["object","boolean","char","string","byte","sbyte","short","ushort","int16","uint16","integer","uinteger","int32","uint32","long","ulong","int64","uint64","decimal","single","double","float","date","datetime","intptr","uintptr"],keywords=wordRegexp(commonKeywords),types=wordRegexp(commontypes),stringPrefixes='"',opening=wordRegexp(openingKeywords),middle=wordRegexp(middleKeywords),closing=wordRegexp(endKeywords),doubleClosing=wordRegexp(["end"]),doOpening=wordRegexp(["do"]);function indent(e,n){n.currentIndent++;}function dedent(e,n){n.currentIndent--;}function tokenBase(e,n){if(e.eatSpace())return null;if("'"===e.peek())return e.skipToEnd(),"comment";if(e.match(/^((&H)|(&O))?[0-9\.a-f]/i,!1)){var t=!1;if((e.match(/^\d*\.\d+F?/i)||e.match(/^\d+\.\d*F?/)||e.match(/^\.\d+F?/))&&(t=!0),t)return e.eat(/J/i),"number";var r=!1;if(e.match(/^&H[0-9a-f]+/i)||e.match(/^&O[0-7]+/i)?r=!0:e.match(/^[1-9]\d*F?/)?(e.eat(/J/i),r=!0):e.match(/^0(?![\dx])/i)&&(r=!0),r)return e.eat(/L/i),"number"}return e.match(stringPrefixes)?(n.tokenize=tokenStringFactory(e.current()),n.tokenize(e,n)):e.match(tripleDelimiters)||e.match(doubleDelimiters)?null:e.match(doubleOperators)||e.match(singleOperators)||e.match(wordOperators)?"operator":e.match(singleDelimiters)?null:e.match(doOpening)?(indent(e,n),n.doInCurrentLine=!0,"keyword"):e.match(opening)?(n.doInCurrentLine?n.doInCurrentLine=!1:indent(e,n),"keyword"):e.match(middle)?"keyword":e.match(doubleClosing)?(dedent(e,n),dedent(e,n),"keyword"):e.match(closing)?(dedent(e,n),"keyword"):e.match(types)||e.match(keywords)?"keyword":e.match(identifiers)?"variable":(e.next(),ERRORCLASS)}function tokenStringFactory(e){var n=1==e.length,t="string";return function(r,o){for(;!r.eol();){if(r.eatWhile(/[^'"]/),r.match(e))return o.tokenize=tokenBase,t;r.eat(/['"]/);}return n&&(o.tokenize=tokenBase),t}}function tokenLexer(e,n){var t=n.tokenize(e,n),r=e.current();if("."===r)return "variable"===(t=n.tokenize(e,n))?"variable":ERRORCLASS;var o="[({".indexOf(r);return -1!==o&&indent(e,n),-1!==(o="])}".indexOf(r))&&dedent(e,n)?ERRORCLASS:t}const vb={startState:function(){return {tokenize:tokenBase,lastToken:null,currentIndent:0,nextLineIndent:0,doInCurrentLine:!1}},token:function(e,n){e.sol()&&(n.currentIndent+=n.nextLineIndent,n.nextLineIndent=0,n.doInCurrentLine=0);var t=tokenLexer(e,n);return n.lastToken={style:t,content:e.current()},t},indent:function(e,n,t){var r=n.replace(/^\s+|\s+$/g,"");return r.match(closing)||r.match(doubleClosing)||r.match(middle)?t.unit*(e.currentIndent-1):e.currentIndent<0?0:e.currentIndent*t.unit},languageData:{closeBrackets:{brackets:["(","[","{",'"']},commentTokens:{line:"'"},autocomplete:openingKeywords.concat(middleKeywords).concat(endKeywords).concat(operatorKeywords).concat(commonKeywords).concat(commontypes)}};

export { vb };
