coffeescript
Version:
Unfancy JavaScript
8 lines • 529 kB
JavaScript
/**
* CoffeeScript Compiler v2.7.0
* https://coffeescript.org
*
* Copyright 2011-2022, Jeremy Ashkenas
* Released under the MIT License
*/
function _get(){return _get="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(target,property,receiver){var base=_superPropBase(target,property);if(base){var desc=Object.getOwnPropertyDescriptor(base,property);return desc.get?desc.get.call(3>arguments.length?target:receiver):desc.value}},_get.apply(this,arguments)}function _superPropBase(object,property){for(;!Object.prototype.hasOwnProperty.call(object,property)&&(object=_getPrototypeOf(object),null!==object););return object}function _inherits(subClass,superClass){if("function"!=typeof superClass&&null!==superClass)throw new TypeError("Super expression must either be null or a function");subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:!0,configurable:!0}}),Object.defineProperty(subClass,"prototype",{writable:!1}),superClass&&_setPrototypeOf(subClass,superClass)}function _setPrototypeOf(o,p){return _setPrototypeOf=Object.setPrototypeOf||function(o,p){return o.__proto__=p,o},_setPrototypeOf(o,p)}function _createSuper(Derived){var hasNativeReflectConstruct=_isNativeReflectConstruct();return function(){var Super=_getPrototypeOf(Derived),result;if(hasNativeReflectConstruct){var NewTarget=_getPrototypeOf(this).constructor;result=Reflect.construct(Super,arguments,NewTarget)}else result=Super.apply(this,arguments);return _possibleConstructorReturn(this,result)}}function _possibleConstructorReturn(self,call){if(call&&("object"===_typeof(call)||"function"==typeof call))return call;if(void 0!==call)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(self)}function _assertThisInitialized(self){if(void 0===self)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return self}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}function _getPrototypeOf(o){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function(o){return o.__proto__||Object.getPrototypeOf(o)},_getPrototypeOf(o)}function _toArray(arr){return _arrayWithHoles(arr)||_iterableToArray(arr)||_unsupportedIterableToArray(arr)||_nonIterableRest()}function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_unsupportedIterableToArray(arr,i)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArrayLimit(arr,i){var _i=null==arr?null:"undefined"!=typeof Symbol&&arr[Symbol.iterator]||arr["@@iterator"];if(null!=_i){var _arr=[],_n=!0,_d=!1,_s,_e;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done)&&(_arr.push(_s.value),!(i&&_arr.length===i));_n=!0);}catch(err){_d=!0,_e=err}finally{try{_n||null==_i["return"]||_i["return"]()}finally{if(_d)throw _e}}return _arr}}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}function _defineProperties(target,props){for(var i=0,descriptor;i<props.length;i++)descriptor=props[i],descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}function _createClass(Constructor,protoProps,staticProps){return protoProps&&_defineProperties(Constructor.prototype,protoProps),staticProps&&_defineProperties(Constructor,staticProps),Object.defineProperty(Constructor,"prototype",{writable:!1}),Constructor}function _typeof(obj){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj},_typeof(obj)}function _toConsumableArray(arr){return _arrayWithoutHoles(arr)||_iterableToArray(arr)||_unsupportedIterableToArray(arr)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(o,minLen){if(o){if("string"==typeof o)return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);return"Object"===n&&o.constructor&&(n=o.constructor.name),"Map"===n||"Set"===n?Array.from(o):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(o,minLen):void 0}}function _iterableToArray(iter){if("undefined"!=typeof Symbol&&null!=iter[Symbol.iterator]||null!=iter["@@iterator"])return Array.from(iter)}function _arrayWithoutHoles(arr){if(Array.isArray(arr))return _arrayLikeToArray(arr)}function _arrayLikeToArray(arr,len){(null==len||len>arr.length)&&(len=arr.length);for(var i=0,arr2=Array(len);i<len;i++)arr2[i]=arr[i];return arr2}var CoffeeScript=function(){var _Mathabs=Math.abs,_StringfromCharCode=String.fromCharCode,_Mathfloor=Math.floor;function require(path){return require[path]}return require["../../package.json"]=function(){return{name:"coffeescript",description:"Unfancy JavaScript",keywords:["javascript","language","coffeescript","compiler"],author:"Jeremy Ashkenas",version:"2.7.0",license:"MIT",engines:{node:">=6"},directories:{lib:"./lib/coffeescript"},main:"./lib/coffeescript/index",module:"./lib/coffeescript-browser-compiler-modern/coffeescript.js",browser:"./lib/coffeescript-browser-compiler-legacy/coffeescript.js",bin:{coffee:"./bin/coffee",cake:"./bin/cake"},files:["bin","lib","register.js","repl.js"],scripts:{test:"node ./bin/cake test","test-harmony":"node --harmony ./bin/cake test"},homepage:"https://coffeescript.org",bugs:"https://github.com/jashkenas/coffeescript/issues",repository:{type:"git",url:"git://github.com/jashkenas/coffeescript.git"},devDependencies:{"@babel/core":"~7.17.8","@babel/preset-env":"~7.16.11","babel-preset-minify":"~0.5.1",codemirror:"~5.65.2",docco:"~0.9.1","highlight.js":"~11.5.0",jison:"~0.4.18","markdown-it":"~12.3.2",puppeteer:"~13.5.2",underscore:"~1.13.2",webpack:"~5.71.0"}}}(),require["./helpers"]=function(){var exports={};return function(){var indexOf=[].indexOf,UNICODE_CODE_POINT_ESCAPE,attachCommentsToNode,buildLocationData,buildLocationHash,buildTokenDataDictionary,extend,_flatten,isBoolean,isNumber,isString,ref,repeat,syntaxErrorToString,unicodeCodePointToUnicodeEscapes;exports.starts=function(string,literal,start){return literal===string.substr(start,literal.length)},exports.ends=function(string,literal,back){var len;return len=literal.length,literal===string.substr(string.length-len-(back||0),len)},exports.repeat=repeat=function(str,n){var res;for(res="";0<n;)1&n&&(res+=str),n>>>=1,str+=str;return res},exports.compact=function(array){var i,item,len1,results;for(results=[],i=0,len1=array.length;i<len1;i++)item=array[i],item&&results.push(item);return results},exports.count=function(string,substr){var num,pos;if(num=pos=0,!substr.length)return 1/0;for(;pos=1+string.indexOf(substr,pos);)num++;return num},exports.merge=function(options,overrides){return extend(extend({},options),overrides)},extend=exports.extend=function(object,properties){var key,val;for(key in properties)val=properties[key],object[key]=val;return object},exports.flatten=_flatten=function flatten(array){var element,flattened,i,len1;for(flattened=[],i=0,len1=array.length;i<len1;i++)element=array[i],"[object Array]"===Object.prototype.toString.call(element)?flattened=flattened.concat(_flatten(element)):flattened.push(element);return flattened},exports.del=function(obj,key){var val;return val=obj[key],delete obj[key],val},exports.some=null==(ref=Array.prototype.some)?function(fn){var e,i,len1,ref1;for(ref1=this,i=0,len1=ref1.length;i<len1;i++)if(e=ref1[i],fn(e))return!0;return!1}:ref,exports.invertLiterate=function(code){var blankLine,i,indented,insideComment,len1,line,listItemStart,out,ref1;for(out=[],blankLine=/^\s*$/,indented=/^[\t ]/,listItemStart=/^(?:\t?| {0,3})(?:[\*\-\+]|[0-9]{1,9}\.)[ \t]/,insideComment=!1,ref1=code.split("\n"),(i=0,len1=ref1.length);i<len1;i++)line=ref1[i],blankLine.test(line)?(insideComment=!1,out.push(line)):insideComment||listItemStart.test(line)?(insideComment=!0,out.push("# ".concat(line))):!insideComment&&indented.test(line)?out.push(line):(insideComment=!0,out.push("# ".concat(line)));return out.join("\n")},buildLocationData=function(first,last){return last?{first_line:first.first_line,first_column:first.first_column,last_line:last.last_line,last_column:last.last_column,last_line_exclusive:last.last_line_exclusive,last_column_exclusive:last.last_column_exclusive,range:[first.range[0],last.range[1]]}:first},exports.extractAllCommentTokens=function(tokens){var allCommentsObj,comment,commentKey,i,j,k,key,len1,len2,len3,ref1,results,sortedKeys,token;for(allCommentsObj={},i=0,len1=tokens.length;i<len1;i++)if(token=tokens[i],token.comments)for(ref1=token.comments,j=0,len2=ref1.length;j<len2;j++)comment=ref1[j],commentKey=comment.locationData.range[0],allCommentsObj[commentKey]=comment;for(sortedKeys=Object.keys(allCommentsObj).sort(function(a,b){return a-b}),results=[],(k=0,len3=sortedKeys.length);k<len3;k++)key=sortedKeys[k],results.push(allCommentsObj[key]);return results},buildLocationHash=function(loc){return"".concat(loc.range[0],"-").concat(loc.range[1])},exports.buildTokenDataDictionary=buildTokenDataDictionary=function(tokens){var base1,i,len1,token,tokenData,tokenHash;for(tokenData={},i=0,len1=tokens.length;i<len1;i++)if((token=tokens[i],!!token.comments)&&(tokenHash=buildLocationHash(token[2]),null==tokenData[tokenHash]&&(tokenData[tokenHash]={}),token.comments)){var _ref;(_ref=null==(base1=tokenData[tokenHash]).comments?base1.comments=[]:base1.comments).push.apply(_ref,_toConsumableArray(token.comments))}return tokenData},exports.addDataToNode=function(parserState,firstLocationData,firstValue,lastLocationData,lastValue){var forceUpdateLocation=!(5<arguments.length&&void 0!==arguments[5])||arguments[5];return function(obj){var locationData,objHash,ref1,ref2,ref3;return locationData=buildLocationData(null==(ref1=null==firstValue?void 0:firstValue.locationData)?firstLocationData:ref1,null==(ref2=null==lastValue?void 0:lastValue.locationData)?lastLocationData:ref2),null!=(null==obj?void 0:obj.updateLocationDataIfMissing)&&null!=firstLocationData?obj.updateLocationDataIfMissing(locationData,forceUpdateLocation):obj.locationData=locationData,null==parserState.tokenData&&(parserState.tokenData=buildTokenDataDictionary(parserState.parser.tokens)),null!=obj.locationData&&(objHash=buildLocationHash(obj.locationData),null!=(null==(ref3=parserState.tokenData[objHash])?void 0:ref3.comments)&&attachCommentsToNode(parserState.tokenData[objHash].comments,obj)),obj}},exports.attachCommentsToNode=attachCommentsToNode=function(comments,node){var _node$comments;if(null!=comments&&0!==comments.length)return null==node.comments&&(node.comments=[]),(_node$comments=node.comments).push.apply(_node$comments,_toConsumableArray(comments))},exports.locationDataToString=function(obj){var locationData;return"2"in obj&&"first_line"in obj[2]?locationData=obj[2]:"first_line"in obj&&(locationData=obj),locationData?"".concat(locationData.first_line+1,":").concat(locationData.first_column+1,"-")+"".concat(locationData.last_line+1,":").concat(locationData.last_column+1):"No location data"},exports.anonymousFileName=function(){var n;return n=0,function(){return"<anonymous-".concat(n++,">")}}(),exports.baseFileName=function(file){var stripExt=!!(1<arguments.length&&void 0!==arguments[1])&&arguments[1],useWinPathSep=!!(2<arguments.length&&void 0!==arguments[2])&&arguments[2],parts,pathSep;return(pathSep=useWinPathSep?/\\|\//:/\//,parts=file.split(pathSep),file=parts[parts.length-1],!(stripExt&&0<=file.indexOf(".")))?file:(parts=file.split("."),parts.pop(),"coffee"===parts[parts.length-1]&&1<parts.length&&parts.pop(),parts.join("."))},exports.isCoffee=function(file){return /\.((lit)?coffee|coffee\.md)$/.test(file)},exports.isLiterate=function(file){return /\.(litcoffee|coffee\.md)$/.test(file)},exports.throwSyntaxError=function(message,location){var error;throw error=new SyntaxError(message),error.location=location,error.toString=syntaxErrorToString,error.stack=error.toString(),error},exports.updateSyntaxError=function(error,code,filename){return error.toString===syntaxErrorToString&&(error.code||(error.code=code),error.filename||(error.filename=filename),error.stack=error.toString()),error},syntaxErrorToString=function(){var codeLine,colorize,colorsEnabled,end,filename,first_column,first_line,last_column,last_line,marker,ref1,ref2,ref3,ref4,start;if(!(this.code&&this.location))return Error.prototype.toString.call(this);var _this$location=this.location;return first_line=_this$location.first_line,first_column=_this$location.first_column,last_line=_this$location.last_line,last_column=_this$location.last_column,null==last_line&&(last_line=first_line),null==last_column&&(last_column=first_column),filename=(null==(ref1=this.filename)?void 0:ref1.startsWith("<anonymous"))?"[stdin]":this.filename||"[stdin]",codeLine=this.code.split("\n")[first_line],start=first_column,end=first_line===last_line?last_column+1:codeLine.length,marker=codeLine.slice(0,start).replace(/[^\s]/g," ")+repeat("^",end-start),"undefined"!=typeof process&&null!==process&&(colorsEnabled=(null==(ref2=process.stdout)?void 0:ref2.isTTY)&&(null==(ref3=process.env)||!ref3.NODE_DISABLE_COLORS)),(null==(ref4=this.colorful)?colorsEnabled:ref4)&&(colorize=function(str){return"\x1B[1;31m".concat(str,"\x1B[0m")},codeLine=codeLine.slice(0,start)+colorize(codeLine.slice(start,end))+codeLine.slice(end),marker=colorize(marker)),"".concat(filename,":").concat(first_line+1,":").concat(first_column+1,": error: ").concat(this.message,"\n").concat(codeLine,"\n").concat(marker)},exports.nameWhitespaceCharacter=function(string){return" "===string?"space":"\n"===string?"newline":"\r"===string?"carriage return":"\t"===string?"tab":string},exports.parseNumber=function(string){var base;return null==string?0/0:(base=function(){switch(string.charAt(1)){case"b":return 2;case"o":return 8;case"x":return 16;default:return null;}}(),null==base?parseFloat(string.replace(/_/g,"")):parseInt(string.slice(2).replace(/_/g,""),base))},exports.isFunction=function(obj){return"[object Function]"===Object.prototype.toString.call(obj)},exports.isNumber=isNumber=function(obj){return"[object Number]"===Object.prototype.toString.call(obj)},exports.isString=isString=function(obj){return"[object String]"===Object.prototype.toString.call(obj)},exports.isBoolean=isBoolean=function(obj){return!0===obj||!1===obj||"[object Boolean]"===Object.prototype.toString.call(obj)},exports.isPlainObject=function(obj){return"object"===_typeof(obj)&&!!obj&&!Array.isArray(obj)&&!isNumber(obj)&&!isString(obj)&&!isBoolean(obj)},unicodeCodePointToUnicodeEscapes=function(codePoint){var high,low,toUnicodeEscape;return(toUnicodeEscape=function(val){var str;return str=val.toString(16),"\\u".concat(repeat("0",4-str.length)).concat(str)},65536>codePoint)?toUnicodeEscape(codePoint):(high=_Mathfloor((codePoint-65536)/1024)+55296,low=(codePoint-65536)%1024+56320,"".concat(toUnicodeEscape(high)).concat(toUnicodeEscape(low)))},exports.replaceUnicodeCodePointEscapes=function(str){var _ref2=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},flags=_ref2.flags,error=_ref2.error,_ref2$delimiter=_ref2.delimiter,delimiter=void 0===_ref2$delimiter?"":_ref2$delimiter,shouldReplace;return shouldReplace=null!=flags&&0>indexOf.call(flags,"u"),str.replace(UNICODE_CODE_POINT_ESCAPE,function(match,escapedBackslash,codePointHex,offset){var codePointDecimal;return escapedBackslash?escapedBackslash:(codePointDecimal=parseInt(codePointHex,16),1114111<codePointDecimal&&error("unicode code point escapes greater than \\u{10ffff} are not allowed",{offset:offset+delimiter.length,length:codePointHex.length+4}),shouldReplace?unicodeCodePointToUnicodeEscapes(codePointDecimal):match)})},UNICODE_CODE_POINT_ESCAPE=/(\\\\)|\\u\{([\da-fA-F]+)\}/g}.call(this),{exports:exports}.exports}(),require["./rewriter"]=function(){var exports={};return function(){var indexOf=[].indexOf,hasProp={}.hasOwnProperty,_require=require("./helpers"),BALANCED_PAIRS,CALL_CLOSERS,CONTROL_IN_IMPLICIT,DISCARDED,EXPRESSION_CLOSE,EXPRESSION_END,EXPRESSION_START,IMPLICIT_CALL,IMPLICIT_END,IMPLICIT_FUNC,IMPLICIT_UNSPACED_CALL,INVERSES,LINEBREAKS,Rewriter,SINGLE_CLOSERS,SINGLE_LINERS,UNFINISHED,extractAllCommentTokens,generate,k,left,len,moveComments,right,throwSyntaxError;for(throwSyntaxError=_require.throwSyntaxError,extractAllCommentTokens=_require.extractAllCommentTokens,moveComments=function(fromToken,toToken){var comment,k,len,ref,unshiftedComments;if(fromToken.comments){if(toToken.comments&&0!==toToken.comments.length){for(unshiftedComments=[],ref=fromToken.comments,(k=0,len=ref.length);k<len;k++)comment=ref[k],comment.unshift?unshiftedComments.push(comment):toToken.comments.push(comment);toToken.comments=unshiftedComments.concat(toToken.comments)}else toToken.comments=fromToken.comments;return delete fromToken.comments}},generate=function(tag,value,origin,commentsToken){var token;return token=[tag,value],token.generated=!0,origin&&(token.origin=origin),commentsToken&&moveComments(commentsToken,token),token},exports.Rewriter=Rewriter=function(){var Rewriter=function(){function Rewriter(){_classCallCheck(this,Rewriter)}return _createClass(Rewriter,[{key:"rewrite",value:function rewrite(tokens1){var ref,ref1,t;return this.tokens=tokens1,("undefined"!=typeof process&&null!==process?null==(ref=process.env)?void 0:ref.DEBUG_TOKEN_STREAM:void 0)&&(process.env.DEBUG_REWRITTEN_TOKEN_STREAM&&console.log("Initial token stream:"),console.log(function(){var k,len,ref1,results;for(ref1=this.tokens,results=[],(k=0,len=ref1.length);k<len;k++)t=ref1[k],results.push(t[0]+"/"+t[1]+(t.comments?"*":""));return results}.call(this).join(" "))),this.removeLeadingNewlines(),this.closeOpenCalls(),this.closeOpenIndexes(),this.normalizeLines(),this.tagPostfixConditionals(),this.addImplicitBracesAndParens(),this.rescueStowawayComments(),this.addLocationDataToGeneratedTokens(),this.enforceValidJSXAttributes(),this.fixIndentationLocationData(),this.exposeTokenDataToGrammar(),("undefined"!=typeof process&&null!==process?null==(ref1=process.env)?void 0:ref1.DEBUG_REWRITTEN_TOKEN_STREAM:void 0)&&(process.env.DEBUG_TOKEN_STREAM&&console.log("Rewritten token stream:"),console.log(function(){var k,len,ref2,results;for(ref2=this.tokens,results=[],(k=0,len=ref2.length);k<len;k++)t=ref2[k],results.push(t[0]+"/"+t[1]+(t.comments?"*":""));return results}.call(this).join(" "))),this.tokens}},{key:"scanTokens",value:function scanTokens(block){var i,token,tokens;for(tokens=this.tokens,i=0;token=tokens[i];)i+=block.call(this,token,i,tokens);return!0}},{key:"detectEnd",value:function detectEnd(i,condition,action){var opts=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{},levels,ref,ref1,token,tokens;for(tokens=this.tokens,levels=0;token=tokens[i];){if(0===levels&&condition.call(this,token,i))return action.call(this,token,i);if((ref=token[0],0<=indexOf.call(EXPRESSION_START,ref))?levels+=1:(ref1=token[0],0<=indexOf.call(EXPRESSION_END,ref1))&&(levels-=1),0>levels)return opts.returnOnNegativeLevel?void 0:action.call(this,token,i);i+=1}return i-1}},{key:"removeLeadingNewlines",value:function removeLeadingNewlines(){var i,k,l,leadingNewlineToken,len,len1,ref,ref1,tag;for(ref=this.tokens,i=k=0,len=ref.length;k<len;i=++k){var _ref$i=_slicedToArray(ref[i],1);if(tag=_ref$i[0],"TERMINATOR"!==tag)break}if(0!==i){for(ref1=this.tokens.slice(0,i),l=0,len1=ref1.length;l<len1;l++)leadingNewlineToken=ref1[l],moveComments(leadingNewlineToken,this.tokens[i]);return this.tokens.splice(0,i)}}},{key:"closeOpenCalls",value:function closeOpenCalls(){var action,condition;return condition=function(token){var ref;return")"===(ref=token[0])||"CALL_END"===ref},action=function(token){return token[0]="CALL_END"},this.scanTokens(function(token,i){return"CALL_START"===token[0]&&this.detectEnd(i+1,condition,action),1})}},{key:"closeOpenIndexes",value:function closeOpenIndexes(){var action,condition,startToken;return startToken=null,condition=function(token){var ref;return"]"===(ref=token[0])||"INDEX_END"===ref},action=function(token,i){return this.tokens.length>=i&&":"===this.tokens[i+1][0]?(startToken[0]="[",token[0]="]"):token[0]="INDEX_END"},this.scanTokens(function(token,i){return"INDEX_START"===token[0]&&(startToken=token,this.detectEnd(i+1,condition,action)),1})}},{key:"indexOfTag",value:function indexOfTag(i){var fuzz,j,k,ref,ref1;fuzz=0;for(var _len=arguments.length,pattern=Array(1<_len?_len-1:0),_key=1;_key<_len;_key++)pattern[_key-1]=arguments[_key];for(j=k=0,ref=pattern.length;0<=ref?k<ref:k>ref;j=0<=ref?++k:--k)if(null!=pattern[j]&&("string"==typeof pattern[j]&&(pattern[j]=[pattern[j]]),ref1=this.tag(i+j+fuzz),0>indexOf.call(pattern[j],ref1)))return-1;return i+j+fuzz-1}},{key:"looksObjectish",value:function looksObjectish(j){var end,index;return-1!==this.indexOfTag(j,"@",null,":")||-1!==this.indexOfTag(j,null,":")||(index=this.indexOfTag(j,EXPRESSION_START),!!(-1!==index&&(end=null,this.detectEnd(index+1,function(token){var ref;return ref=token[0],0<=indexOf.call(EXPRESSION_END,ref)},function(token,i){return end=i}),":"===this.tag(end+1))))}},{key:"findTagsBackwards",value:function findTagsBackwards(i,tags){var backStack,ref,ref1,ref2,ref3,ref4,ref5;for(backStack=[];0<=i&&(backStack.length||(ref2=this.tag(i),0>indexOf.call(tags,ref2))&&((ref3=this.tag(i),0>indexOf.call(EXPRESSION_START,ref3))||this.tokens[i].generated)&&(ref4=this.tag(i),0>indexOf.call(LINEBREAKS,ref4)));)(ref=this.tag(i),0<=indexOf.call(EXPRESSION_END,ref))&&backStack.push(this.tag(i)),(ref1=this.tag(i),0<=indexOf.call(EXPRESSION_START,ref1))&&backStack.length&&backStack.pop(),i-=1;return ref5=this.tag(i),0<=indexOf.call(tags,ref5)}},{key:"addImplicitBracesAndParens",value:function addImplicitBracesAndParens(){var stack,start;return stack=[],start=null,this.scanTokens(function(token,i,tokens){var _this=this,_token=_slicedToArray(token,1),endImplicitCall,endImplicitObject,forward,implicitObjectContinues,implicitObjectIndent,inControlFlow,inImplicit,inImplicitCall,inImplicitControl,inImplicitObject,isImplicit,isImplicitCall,isImplicitObject,k,newLine,nextTag,nextToken,offset,preContinuationLineIndent,preObjectToken,prevTag,prevToken,ref,ref1,ref2,ref3,ref4,ref5,s,sameLine,stackIdx,stackItem,stackNext,stackTag,stackTop,startIdx,startImplicitCall,startImplicitObject,startIndex,startTag,startsLine,tag;tag=_token[0];var _prevToken=prevToken=0<i?tokens[i-1]:[],_prevToken2=_slicedToArray(_prevToken,1);prevTag=_prevToken2[0];var _nextToken=nextToken=i<tokens.length-1?tokens[i+1]:[],_nextToken2=_slicedToArray(_nextToken,1);if(nextTag=_nextToken2[0],stackTop=function(){return stack[stack.length-1]},startIdx=i,forward=function(n){return i-startIdx+n},isImplicit=function(stackItem){var ref;return null==stackItem||null==(ref=stackItem[2])?void 0:ref.ours},isImplicitObject=function(stackItem){return isImplicit(stackItem)&&"{"===(null==stackItem?void 0:stackItem[0])},isImplicitCall=function(stackItem){return isImplicit(stackItem)&&"("===(null==stackItem?void 0:stackItem[0])},inImplicit=function(){return isImplicit(stackTop())},inImplicitCall=function(){return isImplicitCall(stackTop())},inImplicitObject=function(){return isImplicitObject(stackTop())},inImplicitControl=function(){var ref;return inImplicit()&&"CONTROL"===(null==(ref=stackTop())?void 0:ref[0])},startImplicitCall=function(idx){return stack.push(["(",idx,{ours:!0}]),tokens.splice(idx,0,generate("CALL_START","(",["","implicit function call",token[2]],prevToken))},endImplicitCall=function(){return stack.pop(),tokens.splice(i,0,generate("CALL_END",")",["","end of input",token[2]],prevToken)),i+=1},startImplicitObject=function(idx){var _ref3=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},_ref3$startsLine=_ref3.startsLine,continuationLineIndent=_ref3.continuationLineIndent,val;return stack.push(["{",idx,{sameLine:!0,startsLine:void 0===_ref3$startsLine||_ref3$startsLine,ours:!0,continuationLineIndent:continuationLineIndent}]),val=new String("{"),val.generated=!0,tokens.splice(idx,0,generate("{",val,token,prevToken))},endImplicitObject=function(j){return j=null==j?i:j,stack.pop(),tokens.splice(j,0,generate("}","}",token,prevToken)),i+=1},implicitObjectContinues=function(j){var nextTerminatorIdx;return nextTerminatorIdx=null,_this.detectEnd(j,function(token){return"TERMINATOR"===token[0]},function(token,i){return nextTerminatorIdx=i},{returnOnNegativeLevel:!0}),null!=nextTerminatorIdx&&_this.looksObjectish(nextTerminatorIdx+1)},(inImplicitCall()||inImplicitObject())&&0<=indexOf.call(CONTROL_IN_IMPLICIT,tag)||inImplicitObject()&&":"===prevTag&&"FOR"===tag)return stack.push(["CONTROL",i,{ours:!0}]),forward(1);if("INDENT"===tag&&inImplicit()){if("=>"!==prevTag&&"->"!==prevTag&&"["!==prevTag&&"("!==prevTag&&","!==prevTag&&"{"!==prevTag&&"ELSE"!==prevTag&&"="!==prevTag)for(;inImplicitCall()||inImplicitObject()&&":"!==prevTag;)inImplicitCall()?endImplicitCall():endImplicitObject();return inImplicitControl()&&stack.pop(),stack.push([tag,i]),forward(1)}if(0<=indexOf.call(EXPRESSION_START,tag))return stack.push([tag,i]),forward(1);if(0<=indexOf.call(EXPRESSION_END,tag)){for(;inImplicit();)inImplicitCall()?endImplicitCall():inImplicitObject()?endImplicitObject():stack.pop();start=stack.pop()}if(inControlFlow=function(){var controlFlow,isFunc,seenFor,tagCurrentLine;return(seenFor=_this.findTagsBackwards(i,["FOR"])&&_this.findTagsBackwards(i,["FORIN","FOROF","FORFROM"]),controlFlow=seenFor||_this.findTagsBackwards(i,["WHILE","UNTIL","LOOP","LEADING_WHEN"]),!!controlFlow)&&(isFunc=!1,tagCurrentLine=token[2].first_line,_this.detectEnd(i,function(token){var ref;return ref=token[0],0<=indexOf.call(LINEBREAKS,ref)},function(token,i){var _ref4=tokens[i-1]||[],_ref5=_slicedToArray(_ref4,3),first_line;return prevTag=_ref5[0],first_line=_ref5[2].first_line,isFunc=tagCurrentLine===first_line&&("->"===prevTag||"=>"===prevTag)},{returnOnNegativeLevel:!0}),isFunc)},(0<=indexOf.call(IMPLICIT_FUNC,tag)&&token.spaced||"?"===tag&&0<i&&!tokens[i-1].spaced)&&(0<=indexOf.call(IMPLICIT_CALL,nextTag)||"..."===nextTag&&(ref=this.tag(i+2),0<=indexOf.call(IMPLICIT_CALL,ref))&&!this.findTagsBackwards(i,["INDEX_START","["])||0<=indexOf.call(IMPLICIT_UNSPACED_CALL,nextTag)&&!nextToken.spaced&&!nextToken.newLine)&&!inControlFlow())return"?"===tag&&(tag=token[0]="FUNC_EXIST"),startImplicitCall(i+1),forward(2);if(0<=indexOf.call(IMPLICIT_FUNC,tag)&&-1<this.indexOfTag(i+1,"INDENT")&&this.looksObjectish(i+2)&&!this.findTagsBackwards(i,["CLASS","EXTENDS","IF","CATCH","SWITCH","LEADING_WHEN","FOR","WHILE","UNTIL"])&&("{"!==(ref1=s=null==(ref2=stackTop())?void 0:ref2[0])&&"["!==ref1||isImplicit(stackTop())||!this.findTagsBackwards(i,s)))return startImplicitCall(i+1),stack.push(["INDENT",i+2]),forward(3);if(":"===tag){if(s=function(){var ref3;switch(!1){case(ref3=this.tag(i-1),0>indexOf.call(EXPRESSION_END,ref3)):var _start=start,_start2=_slicedToArray(_start,2);return startTag=_start2[0],startIndex=_start2[1],"["===startTag&&0<startIndex&&"@"===this.tag(startIndex-1)&&!tokens[startIndex-1].spaced?startIndex-1:startIndex;break;case"@"!==this.tag(i-2):return i-2;default:return i-1;}}.call(this),startsLine=0>=s||(ref3=this.tag(s-1),0<=indexOf.call(LINEBREAKS,ref3))||tokens[s-1].newLine,stackTop()){var _stackTop=stackTop(),_stackTop2=_slicedToArray(_stackTop,2);if(stackTag=_stackTop2[0],stackIdx=_stackTop2[1],stackNext=stack[stack.length-2],("{"===stackTag||"INDENT"===stackTag&&"{"===(null==stackNext?void 0:stackNext[0])&&!isImplicit(stackNext)&&this.findTagsBackwards(stackIdx-1,["{"]))&&(startsLine||","===this.tag(s-1)||"{"===this.tag(s-1))&&(ref4=this.tag(s-1),0>indexOf.call(UNFINISHED,ref4)))return forward(1)}return preObjectToken=1<i?tokens[i-2]:[],startImplicitObject(s,{startsLine:!!startsLine,continuationLineIndent:preObjectToken.continuationLineIndent}),forward(2)}if(0<=indexOf.call(LINEBREAKS,tag))for(k=stack.length-1;0<=k&&(stackItem=stack[k],!!isImplicit(stackItem));k+=-1)isImplicitObject(stackItem)&&(stackItem[2].sameLine=!1);if("TERMINATOR"===tag&&token.endsContinuationLineIndentation)for(preContinuationLineIndent=token.endsContinuationLineIndentation.preContinuationLineIndent;inImplicitObject()&&null!=(implicitObjectIndent=stackTop()[2].continuationLineIndent)&&implicitObjectIndent>preContinuationLineIndent;)endImplicitObject();if(newLine="OUTDENT"===prevTag||prevToken.newLine,0<=indexOf.call(IMPLICIT_END,tag)||0<=indexOf.call(CALL_CLOSERS,tag)&&newLine||(".."===tag||"..."===tag)&&this.findTagsBackwards(i,["INDEX_START"]))for(;inImplicit();){var _stackTop3=stackTop(),_stackTop4=_slicedToArray(_stackTop3,3);stackTag=_stackTop4[0],stackIdx=_stackTop4[1];var _stackTop4$=_stackTop4[2];if(sameLine=_stackTop4$.sameLine,startsLine=_stackTop4$.startsLine,inImplicitCall()&&","!==prevTag||","===prevTag&&"TERMINATOR"===tag&&null==nextTag)endImplicitCall();else if(inImplicitObject()&&sameLine&&"TERMINATOR"!==tag&&":"!==prevTag&&!(("POST_IF"===tag||"FOR"===tag||"WHILE"===tag||"UNTIL"===tag)&&startsLine&&implicitObjectContinues(i+1)))endImplicitObject();else if(inImplicitObject()&&"TERMINATOR"===tag&&","!==prevTag&&!(startsLine&&this.looksObjectish(i+1)))endImplicitObject();else if(inImplicitControl()&&"CLASS"===tokens[stackTop()[1]][0]&&"TERMINATOR"===tag)stack.pop();else break}if(","===tag&&!this.looksObjectish(i+1)&&inImplicitObject()&&"FOROF"!==(ref5=this.tag(i+2))&&"FORIN"!==ref5&&("TERMINATOR"!==nextTag||!this.looksObjectish(i+2)))for(offset="OUTDENT"===nextTag?1:0;inImplicitObject();)endImplicitObject(i+offset);return forward(1)})}},{key:"enforceValidJSXAttributes",value:function enforceValidJSXAttributes(){return this.scanTokens(function(token,i,tokens){var next,ref;return token.jsxColon&&(next=tokens[i+1],"STRING_START"!==(ref=next[0])&&"STRING"!==ref&&"("!==ref&&throwSyntaxError("expected wrapped or quoted JSX attribute",next[2])),1})}},{key:"rescueStowawayComments",value:function rescueStowawayComments(){var dontShiftForward,insertPlaceholder,shiftCommentsBackward,shiftCommentsForward;return insertPlaceholder=function(token,j,tokens,method){return"TERMINATOR"!==tokens[j][0]&&tokens[method](generate("TERMINATOR","\n",tokens[j])),tokens[method](generate("JS","",tokens[j],token))},dontShiftForward=function(i,tokens){var j,ref;for(j=i+1;j!==tokens.length&&(ref=tokens[j][0],0<=indexOf.call(DISCARDED,ref));){if("INTERPOLATION_END"===tokens[j][0])return!0;j++}return!1},shiftCommentsForward=function(token,i,tokens){var comment,j,k,len,ref,ref1,ref2;for(j=i;j!==tokens.length&&(ref=tokens[j][0],0<=indexOf.call(DISCARDED,ref));)j++;if(!(j===tokens.length||(ref1=tokens[j][0],0<=indexOf.call(DISCARDED,ref1)))){for(ref2=token.comments,k=0,len=ref2.length;k<len;k++)comment=ref2[k],comment.unshift=!0;return moveComments(token,tokens[j]),1}return j=tokens.length-1,insertPlaceholder(token,j,tokens,"push"),1},shiftCommentsBackward=function(token,i,tokens){var j,ref,ref1;for(j=i;-1!==j&&(ref=tokens[j][0],0<=indexOf.call(DISCARDED,ref));)j--;return-1===j||(ref1=tokens[j][0],0<=indexOf.call(DISCARDED,ref1))?(insertPlaceholder(token,0,tokens,"unshift"),3):(moveComments(token,tokens[j]),1)},this.scanTokens(function(token,i,tokens){var dummyToken,j,ref,ref1,ret;if(!token.comments)return 1;if(ret=1,ref=token[0],0<=indexOf.call(DISCARDED,ref)){for(dummyToken={comments:[]},j=token.comments.length-1;-1!==j;)!1===token.comments[j].newLine&&!1===token.comments[j].here&&(dummyToken.comments.unshift(token.comments[j]),token.comments.splice(j,1)),j--;0!==dummyToken.comments.length&&(ret=shiftCommentsBackward(dummyToken,i-1,tokens)),0!==token.comments.length&&shiftCommentsForward(token,i,tokens)}else if(!dontShiftForward(i,tokens)){for(dummyToken={comments:[]},j=token.comments.length-1;-1!==j;)!token.comments[j].newLine||token.comments[j].unshift||"JS"===token[0]&&token.generated||(dummyToken.comments.unshift(token.comments[j]),token.comments.splice(j,1)),j--;0!==dummyToken.comments.length&&(ret=shiftCommentsForward(dummyToken,i+1,tokens))}return 0===(null==(ref1=token.comments)?void 0:ref1.length)&&delete token.comments,ret})}},{key:"addLocationDataToGeneratedTokens",value:function addLocationDataToGeneratedTokens(){return this.scanTokens(function(token,i,tokens){var column,line,nextLocation,prevLocation,rangeIndex,ref,ref1;if(token[2])return 1;if(!(token.generated||token.explicit))return 1;if(token.fromThen&&"INDENT"===token[0])return token[2]=token.origin[2],1;if("{"===token[0]&&(nextLocation=null==(ref=tokens[i+1])?void 0:ref[2])){var _nextLocation=nextLocation;line=_nextLocation.first_line,column=_nextLocation.first_column;var _nextLocation$range=_slicedToArray(_nextLocation.range,1);rangeIndex=_nextLocation$range[0]}else if(prevLocation=null==(ref1=tokens[i-1])?void 0:ref1[2]){var _prevLocation=prevLocation;line=_prevLocation.last_line,column=_prevLocation.last_column;var _prevLocation$range=_slicedToArray(_prevLocation.range,2);rangeIndex=_prevLocation$range[1],column+=1}else line=column=0,rangeIndex=0;return token[2]={first_line:line,first_column:column,last_line:line,last_column:column,last_line_exclusive:line,last_column_exclusive:column,range:[rangeIndex,rangeIndex]},1})}},{key:"fixIndentationLocationData",value:function fixIndentationLocationData(){var _this2=this,findPrecedingComment;return null==this.allComments&&(this.allComments=extractAllCommentTokens(this.tokens)),findPrecedingComment=function(token,_ref6){var afterPosition=_ref6.afterPosition,indentSize=_ref6.indentSize,first=_ref6.first,indented=_ref6.indented,comment,k,l,lastMatching,matches,ref,ref1,tokenStart;if(tokenStart=token[2].range[0],matches=function(comment){return(!comment.outdented||null!=indentSize&&comment.indentSize>indentSize)&&(!indented||comment.indented)&&!!(comment.locationData.range[0]<tokenStart)&&!!(comment.locationData.range[0]>afterPosition)},first){for(lastMatching=null,ref=_this2.allComments,k=ref.length-1;0<=k;k+=-1)if(comment=ref[k],matches(comment))lastMatching=comment;else if(lastMatching)return lastMatching;return lastMatching}for(ref1=_this2.allComments,l=ref1.length-1;0<=l;l+=-1)if(comment=ref1[l],matches(comment))return comment;return null},this.scanTokens(function(token,i,tokens){var isIndent,nextToken,nextTokenIndex,precedingComment,prevLocationData,prevToken,ref,ref1,ref2,useNextToken;if("INDENT"!==(ref=token[0])&&"OUTDENT"!==ref&&(!token.generated||"CALL_END"!==token[0]||null!=(ref1=token.data)&&ref1.closingTagNameToken)&&(!token.generated||"}"!==token[0]))return 1;if(isIndent="INDENT"===token[0],prevToken=null==(ref2=token.prevToken)?tokens[i-1]:ref2,prevLocationData=prevToken[2],useNextToken=token.explicit||token.generated,useNextToken)for(nextToken=token,nextTokenIndex=i;(nextToken.explicit||nextToken.generated)&&nextTokenIndex!==tokens.length-1;)nextToken=tokens[nextTokenIndex++];return(precedingComment=findPrecedingComment(useNextToken?nextToken:token,{afterPosition:prevLocationData.range[0],indentSize:token.indentSize,first:isIndent,indented:useNextToken}),isIndent&&(null==precedingComment||!precedingComment.newLine))?1:token.generated&&"CALL_END"===token[0]&&(null==precedingComment?void 0:precedingComment.indented)?1:(null!=precedingComment&&(prevLocationData=precedingComment.locationData),token[2]={first_line:null==precedingComment?prevLocationData.last_line:prevLocationData.first_line,first_column:null==precedingComment?prevLocationData.last_column:isIndent?0:prevLocationData.first_column,last_line:prevLocationData.last_line,last_column:prevLocationData.last_column,last_line_exclusive:prevLocationData.last_line_exclusive,last_column_exclusive:prevLocationData.last_column_exclusive,range:isIndent&&null!=precedingComment?[prevLocationData.range[0]-precedingComment.indentSize,prevLocationData.range[1]]:prevLocationData.range},1)})}},{key:"normalizeLines",value:function normalizeLines(){var _this3=this,action,closeElseTag,condition,ifThens,indent,leading_if_then,leading_switch_when,outdent,starter;return starter=indent=outdent=null,leading_switch_when=null,leading_if_then=null,ifThens=[],condition=function(token,i){var ref,ref1,ref2,ref3;return";"!==token[1]&&(ref=token[0],0<=indexOf.call(SINGLE_CLOSERS,ref))&&!("TERMINATOR"===token[0]&&(ref1=this.tag(i+1),0<=indexOf.call(EXPRESSION_CLOSE,ref1)))&&!("ELSE"===token[0]&&("THEN"!==starter||leading_if_then||leading_switch_when))&&("CATCH"!==(ref2=token[0])&&"FINALLY"!==ref2||"->"!==starter&&"=>"!==starter)||(ref3=token[0],0<=indexOf.call(CALL_CLOSERS,ref3))&&(this.tokens[i-1].newLine||"OUTDENT"===this.tokens[i-1][0])},action=function(token,i){return"ELSE"===token[0]&&"THEN"===starter&&ifThens.pop(),this.tokens.splice(","===this.tag(i-1)?i-1:i,0,outdent)},closeElseTag=function(tokens,i){var lastThen,outdentElse,tlen;if(tlen=ifThens.length,!(0<tlen))return i;lastThen=ifThens.pop();var _this3$indentation=_this3.indentation(tokens[lastThen]),_this3$indentation2=_slicedToArray(_this3$indentation,2);return outdentElse=_this3$indentation2[1],outdentElse[1]=2*tlen,tokens.splice(i,0,outdentElse),outdentElse[1]=2,tokens.splice(i+1,0,outdentElse),_this3.detectEnd(i+2,function(token){var ref;return"OUTDENT"===(ref=token[0])||"TERMINATOR"===ref},function(token,i){if("OUTDENT"===this.tag(i)&&"OUTDENT"===this.tag(i+1))return tokens.splice(i,2)}),i+2},this.scanTokens(function(token,i,tokens){var _token2=_slicedToArray(token,1),conditionTag,j,k,ref,ref1,ref2,tag;if(tag=_token2[0],conditionTag=("->"===tag||"=>"===tag)&&this.findTagsBackwards(i,["IF","WHILE","FOR","UNTIL","SWITCH","WHEN","LEADING_WHEN","[","INDEX_START"])&&!this.findTagsBackwards(i,["THEN","..","..."]),"TERMINATOR"===tag){if("ELSE"===this.tag(i+1)&&"OUTDENT"!==this.tag(i-1))return tokens.splice.apply(tokens,[i,1].concat(_toConsumableArray(this.indentation()))),1;if(ref=this.tag(i+1),0<=indexOf.call(EXPRESSION_CLOSE,ref))return";"===token[1]&&"OUTDENT"===this.tag(i+1)&&(tokens[i+1].prevToken=token,moveComments(token,tokens[i+1])),tokens.splice(i,1),0}if("CATCH"===tag)for(j=k=1;2>=k;j=++k)if("OUTDENT"===(ref1=this.tag(i+j))||"TERMINATOR"===ref1||"FINALLY"===ref1)return tokens.splice.apply(tokens,[i+j,0].concat(_toConsumableArray(this.indentation()))),2+j;if(("->"===tag||"=>"===tag)&&(","===(ref2=this.tag(i+1))||"]"===ref2||"."===this.tag(i+1)&&token.newLine)){var _this$indentation=this.indentation(tokens[i]),_this$indentation2=_slicedToArray(_this$indentation,2);return indent=_this$indentation2[0],outdent=_this$indentation2[1],tokens.splice(i+1,0,indent,outdent),1}if(0<=indexOf.call(SINGLE_LINERS,tag)&&"INDENT"!==this.tag(i+1)&&("ELSE"!==tag||"IF"!==this.tag(i+1))&&!conditionTag){starter=tag;var _this$indentation3=this.indentation(tokens[i]),_this$indentation4=_slicedToArray(_this$indentation3,2);return indent=_this$indentation4[0],outdent=_this$indentation4[1],"THEN"===starter&&(indent.fromThen=!0),"THEN"===tag&&(leading_switch_when=this.findTagsBackwards(i,["LEADING_WHEN"])&&"IF"===this.tag(i+1),leading_if_then=this.findTagsBackwards(i,["IF"])&&"IF"===this.tag(i+1)),"THEN"===tag&&this.findTagsBackwards(i,["IF"])&&ifThens.push(i),"ELSE"===tag&&"OUTDENT"!==this.tag(i-1)&&(i=closeElseTag(tokens,i)),tokens.splice(i+1,0,indent),this.detectEnd(i+2,condition,action),"THEN"===tag&&tokens.splice(i,1),1}return 1})}},{key:"tagPostfixConditionals",value:function tagPostfixConditionals(){var action,condition,original;return original=null,condition=function(token,i){var _token3=_slicedToArray(token,1),prevTag,tag;tag=_token3[0];var _this$tokens=_slicedToArray(this.tokens[i-1],1);return prevTag=_this$tokens[0],"TERMINATOR"===tag||"INDENT"===tag&&0>indexOf.call(SINGLE_LINERS,prevTag)},action=function(token){if("INDENT"!==token[0]||token.generated&&!token.fromThen)return original[0]="POST_"+original[0]},this.scanTokens(function(token,i){return"IF"===token[0]?(original=token,this.detectEnd(i+1,condition,action),1):1})}},{key:"exposeTokenDataToGrammar",value:function exposeTokenDataToGrammar(){return this.scanTokens(function(token){var key,ref,ref1,val;if(token.generated||token.data&&0!==Object.keys(token.data).length){for(key in token[1]=new String(token[1]),ref1=null==(ref=token.data)?{}:ref,ref1)hasProp.call(ref1,key)&&(val=ref1[key],token[1][key]=val);token.generated&&(token[1].generated=!0)}return 1})}},{key:"indentation",value:function indentation(origin){var indent,outdent;return indent=["INDENT",2],outdent=["OUTDENT",2],origin?(indent.generated=outdent.generated=!0,indent.origin=outdent.origin=origin):indent.explicit=outdent.explicit=!0,[indent,outdent]}},{key:"tag",value:function tag(i){var ref;return null==(ref=this.tokens[i])?void 0:ref[0]}}]),Rewriter}();return Rewriter.prototype.generate=generate,Rewriter}.call(this),BALANCED_PAIRS=[["(",")"],["[","]"],["{","}"],["INDENT","OUTDENT"],["CALL_START","CALL_END"],["PARAM_START","PARAM_END"],["INDEX_START","INDEX_END"],["STRING_START","STRING_END"],["INTERPOLATION_START","INTERPOLATION_END"],["REGEX_START","REGEX_END"]],exports.INVERSES=INVERSES={},EXPRESSION_START=[],EXPRESSION_END=[],(k=0,len=BALANCED_PAIRS.length);k<len;k++){var _BALANCED_PAIRS$k=_slicedToArray(BALANCED_PAIRS[k],2);left=_BALANCED_PAIRS$k[0],right=_BALANCED_PAIRS$k[1],EXPRESSION_START.push(INVERSES[right]=left),EXPRESSION_END.push(INVERSES[left]=right)}EXPRESSION_CLOSE=["CATCH","THEN","ELSE","FINALLY"].concat(EXPRESSION_END),IMPLICIT_FUNC=["IDENTIFIER","PROPERTY","SUPER",")","CALL_END","]","INDEX_END","@","THIS"],IMPLICIT_CALL=["IDENTIFIER","JSX_TAG","PROPERTY","NUMBER","INFINITY","NAN","STRING","STRING_START","REGEX","REGEX_START","JS","NEW","PARAM_START","CLASS","IF","TRY","SWITCH","THIS","DYNAMIC_IMPORT","IMPORT_META","NEW_TARGET","UNDEFINED","NULL","BOOL","UNARY","DO","DO_IIFE","YIELD","AWAIT","UNARY_MATH","SUPER","THROW","@","->","=>","[","(","{","--","++"],IMPLICIT_UNSPACED_CALL=["+","-"],IMPLICIT_END=["POST_IF","FOR","WHILE","UNTIL","WHEN","BY","LOOP","TERMINATOR"],SINGLE_LINERS=["ELSE","->","=>","TRY","FINALLY","THEN"],SINGLE_CLOSERS=["TERMINATOR","CATCH","FINALLY","ELSE","OUTDENT","LEADING_WHEN"],LINEBREAKS=["TERMINATOR","INDENT","OUTDENT"],CALL_CLOSERS=[".","?.","::","?::"],CONTROL_IN_IMPLICIT=["IF","TRY","FINALLY","CATCH","CLASS","SWITCH"],DISCARDED=["(",")","[","]","{","}",":",".","..","...",",","=","++","--","?","AS","AWAIT","CALL_START","CALL_END","DEFAULT","DO","DO_IIFE","ELSE","EXTENDS","EXPORT","FORIN","FOROF","FORFROM","IMPORT","INDENT","INDEX_SOAK","INTERPOLATION_START","INTERPOLATION_END","LEADING_WHEN","OUTDENT","PARAM_END","REGEX_START","REGEX_END","RETURN","STRING_END","THROW","UNARY","YIELD"].concat(IMPLICIT_UNSPACED_CALL.concat(IMPLICIT_END.concat(CALL_CLOSERS.concat(CONTROL_IN_IMPLICIT)))),exports.UNFINISHED=UNFINISHED=["\\",".","?.","?::","UNARY","DO","DO_IIFE","MATH","UNARY_MATH","+","-","**","SHIFT","RELATION","COMPARE","&","^","|","&&","||","BIN?","EXTENDS"]}.call(this),{exports:exports}.exports}(),require["./lexer"]=function(){var exports={};return function(){var indexOf=[].indexOf,slice=[].slice,_require2=require("./rewriter"),BOM,BOOL,CALLABLE,CODE,COFFEE_ALIASES,COFFEE_ALIAS_MAP,COFFEE_KEYWORDS,COMMENT,COMPARABLE_LEFT_SIDE,COMPARE,COMPOUND_ASSIGN,HERECOMMENT_ILLEGAL,HEREDOC_DOUBLE,HEREDOC_INDENT,HEREDOC_SINGLE,HEREGEX,HEREGEX_COMMENT,HERE_JSTOKEN,IDENTIFIER,INDENTABLE_CLOSERS,INDEXABLE,INSIDE_JSX,INVERSES,JSTOKEN,JSX_ATTRIBUTE,JSX_FRAGMENT_IDENTIFIER,JSX_IDENTIFIER,JSX_IDENTIFIER_PART,JSX_INTERPOLATION,JS_KEYWORDS,LINE_BREAK,LINE_CONTINUER,Lexer,MATH,MULTI_DENT,NOT_REGEX,NUMBER,OPERATOR,POSSIBLY_DIVISION,REGEX,REGEX_FLAGS,REGEX_ILLEGAL,REGEX_INVALID_ESCAPE,RELATION,RESERVED,Rewriter,SHIFT,STRICT_PROSCRIBED,STRING_DOUBLE,STRING_INVALID_ESCAPE,STRING_SINGLE,STRING_START,TRAILING_SPACES,UNARY,UNARY_MATH,UNFINISHED,VALID_FLAGS,WHITESPACE,addTokenData,attachCommentsToNode,compact,count,flatten,invertLiterate,isForFrom,isUnassignable,key,locationDataToString,merge,parseNumber,repeat,replaceUnicodeCodePointEscapes,starts,throwSyntaxError;Rewriter=_require2.Rewriter,INVERSES=_require2.INVERSES,UNFINISHED=_require2.UNFINISHED;var _require3=require("./helpers");count=_require3.count,starts=_require3.starts,compact=_require3.compact,repeat=_require3.repeat,invertLiterate=_require3.invertLiterate,merge=_require3.merge,attachCommentsToNode=_require3.attachCommentsToNode,locationDataToString=_require3.locationDataToString,throwSyntaxError=_require3.throwSyntaxError,replaceUnicodeCodePointEscapes=_require3.replaceUnicodeCodePointEscapes,flatten=_require3.flatten,parseNumber=_require3.parseNumber,exports.Lexer=Lexer=function(){function Lexer(){_classCallCheck(this,Lexer),this.error=this.error.bind(this)}return _createClass(Lexer,[{key:"tokenize",value:function tokenize(code){var opts=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},consumed,end,i,ref;for(this.literate=opts.literate,this.indent=0,this.baseIndent=0,this.continuationLineAdditionalIndent=0,this.outdebt=0,this.indents=[],this.indentLiteral="",this.ends=[],this.tokens=[],this.seenFor=!1,this.seenImport=!1,this.seenExport=!1,this.importSpecifierList=!1,this.exportSpecifierList=!1,this.jsxDepth=0,this.jsxObjAttribute={},this.chunkLine=opts.line||0,this.chunkColumn=opts.column||0,this.chunkOffset=opts.offset||0,this.locationDataCompensations=opts.locationDataCompensations||{},code=this.clean(code),i=0;this.chunk=code.slice(i);){consumed=this.identifierToken()||this.commentToken()||this.whitespaceToken()||this.lineToken()||this.stringToken()||this.numberToken()||this.jsxToken()||this.regexToken()||this.jsToken()||this.literalToken();var _this$getLineAndColum=this.getLineAndColumnFromChunk(consumed),_this$getLineAndColum2=_slicedToArray(_this$getLineAndColum,3);if(this.chunkLine=_this$getLineAndColum2[0],this.chunkColumn=_this$getLineAndColum2[1],this.chunkOffset=_this$getLineAndColum2[2],i+=consumed,opts.untilBalanced&&0===this.ends.length)return{tokens:this.tokens,index:i}}return this.closeIndentation(),(end=this.ends.pop())&&this.error("missing ".concat(end.tag),(null==(ref=end.origin)?end:ref)[2]),!1===opts.rewrite?this.tokens:new Rewriter().rewrite(this.tokens)}},{key:"clean",value:function clean(code){var _this4=this,base,thusFar;return thusFar=0,code.charCodeAt(0)===BOM&&(code=code.slice(1),this.locationDataCompensations[0]=1,thusFar+=1),WHITESPACE.test(code)&&(code="\n".concat(code),this.chunkLine--,null==(base=this.locationDataCompensations)[0]&&(base[0]=0),this.locationDataCompensations[0]-=1),code=code.replace(/\r/g,function(match,offset){return _this4.locationDataCompensations[thusFar+offset]=1,""}).replace(TRAILING_SPACES,""),this.literate&&(code=invertLiterate(code)),code}},{key:"identifierToken",value:function identifierToken(){var alias,colon,colonOffset,colonToken,id,idLength,inJSXTag,input,match,poppedToken,prev,prevprev,ref,ref1,ref10,ref11,ref12,ref2,ref3,ref4,ref5,ref6,ref7,ref8,ref9,regExSuper,regex,sup,tag,tagToken,tokenData;if(inJSXTag=this.atJSXTag(),regex=inJSXTag?JSX_ATTRIBUTE:IDENTIFIER,!(match=regex.exec(this.chunk)))return 0;var _match=match,_match2=_slicedToArray(_match,3);if(input=_match2[0],id=_match2[1],colon=_match2[2],idLength=id.length,poppedToken=void 0,"own"===id&&"FOR"===this.tag())return this.token("OWN",id),id.length;if("from"===id&&"YIELD"===this.tag())return this.token("FROM",id),id.length;if("as"===id&&this.seenImport){if("*"===this.value())this.tokens[this.tokens.length-1][0]="IMPORT_ALL";else if(ref=this.value(!0),0<=indexOf.call(COFFEE_KEYWORDS,ref)){prev=this.prev();var _ref7=["IDENTIFIER",this.value(!0)];prev[0]=_ref7[0],prev[1]=_ref7[1]}if("DEFAULT"===(ref1=this.tag())||"IMPORT_ALL"===ref1||"IDENTIFIER"===ref1)return this.token("AS",id),id.length}if("as"===id&&this.seenExport){if("IDENTIFIER"===(ref2=this.tag())||"DEFAULT"===ref2)return this.token("AS",id),id.length;if(ref3=this.value(!0),0<=indexOf.call(COFFEE_KEYWORDS,ref3)){prev=this.prev();var _ref8=["IDENTIFIER",this.value(!0)];return prev[0]=_ref8[0],prev[1]=_ref8[1],this.token("AS",id),id.length}}if("default"===id&&this.seenExport&&("EXPORT"===(ref4=this.tag())||"AS"===ref4))return this.token("DEFAULT",id),id.length;if("assert"===id&&(this.seenImport||this.seenExport)&&"STRING"===this.tag())return this.token("ASSERT",id),id.length;if("do"===id&&(regExSuper=/^(\s*super)(?!\(\))/.exec(this.chunk.slice(3)))){this.token("SUPER","super"),this.token("CALL_START","("),this.token("CALL_END",")");var _regExSuper=regExSuper,_regExSuper2=_slicedToArray(_regExSuper,2);return input=_regExSuper2[0],sup=_regExSuper2[1],sup.length+3}if(prev=this.prev(),tag=colon||null!=prev&&("."===(ref5=prev[0])||"?."===ref5||"::"===ref5||"?::"===ref5||!prev.spaced&&"@"===prev[0])?"PROPERTY":"IDENTIFIER",tokenData={},"IDENTIFIER"===tag&&(0<=indexOf.call(JS_KEYWORDS,id)||0<=indexOf.call(COFFEE_KEYWORDS,id))&&!(this.exportSpecifierList&&0<=indexOf.call(COFFEE_KEYWORDS,id))?(tag=id.toUpperCase(),"WHEN"===tag&&(ref6=this.tag(),0<=indexOf.call(LINE_BREAK,ref6))?tag="LEADING_WHEN":"FOR"===tag?this.seenFor={endsLength:this.ends.length}:"UNLESS"===tag?tag="IF":"IMPORT"===tag?this.seenImport=!0:"EXPORT"===tag?this.seenExport=!0:0<=indexOf.call(UNARY,tag)?tag="UNARY":0<=indexOf.call(RELATION,tag)&&("INSTANCEOF"!==tag&&this.seenFor?(tag="FOR"+tag,this.seenFor=!1):(tag="RELATION","!"===this.value()&&(poppedToken=this.tokens.pop(),tokenData.invert=null==(ref7=null==(ref8=poppedToken.data)?void 0:ref8.original)?poppedToken[1]: