rivescript-contrib-coffeescript
Version:
CoffeeScript object macro handler for RiveScript
3 lines • 167 kB
JavaScript
/* rivescript-contrib-coffeescript 0.0.3 -- build on 2016-05-16 12:03:01 */
!function(a){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define([],a);else{var b;b="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,b.RSCoffeeScript=a()}}(function(){var define,module,exports;return function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(require,module,exports){"use strict";var coffee=require("coffee-script"),CoffeeHandler=function(master){var self=this;self._master=master,self._objects={},self.load=function(name,code){var source;try{source='this._objects["'+name+'"] = function(rs, args) {\n'+coffee.compile(code.join("\n"),{bare:!0})+"}\n"}catch(e){return void self._master.warn("Error constructing CoffeeScript source: "+e.message)}try{eval(source)}catch(e){return void self._master.warn("Error evaluating CoffeeScript object: "+e.message)}},self.call=function(a,b,c,d){if(!self._objects[b])return self._master.errors.objectNotFound;var e=self._objects[b],f="";try{f=e.call(d,a,c)}catch(g){f="[ERR: Error when executing CoffeeScript object: "+g.message+"]"}return void 0===f&&(f=""),f}};module.exports=CoffeeHandler},{"coffee-script":2}],2:[function(a,b,c){(function(b,d){(function(){var e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w={}.hasOwnProperty,x=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};if(k=a("fs"),u=a("vm"),r=a("path"),e=a("./lexer").Lexer,q=a("./parser").parser,m=a("./helpers"),f=a("./sourcemap"),c.VERSION="1.10.0",c.FILE_EXTENSIONS=[".coffee",".litcoffee",".coffee.md"],c.helpers=m,v=function(a){return function(b,c){var d,e;null==c&&(c={});try{return a.call(this,b,c)}catch(e){if(d=e,"string"!=typeof b)throw d;throw m.updateSyntaxError(d,b,c.filename)}}},c.compile=h=v(function(a,b){var c,d,e,g,h,i,j,k,l,n,o,r,s,t,u;for(r=m.merge,g=m.extend,b=g({},b),b.sourceMap&&(o=new f),u=p.tokenize(a,b),b.referencedVars=function(){var a,b,c;for(c=[],a=0,b=u.length;b>a;a++)t=u[a],t.variable&&c.push(t[1]);return c}(),i=q.parse(u).compileToFragments(b),e=0,b.header&&(e+=1),b.shiftLine&&(e+=1),d=0,l="",k=0,n=i.length;n>k;k++)h=i[k],b.sourceMap&&(h.locationData&&!/^[;\s]*$/.test(h.code)&&o.add([h.locationData.first_line,h.locationData.first_column],[e,d],{noReplace:!0}),s=m.count(h.code,"\n"),e+=s,s?d=h.code.length-(h.code.lastIndexOf("\n")+1):d+=h.code.length),l+=h.code;return b.header&&(j="Generated by CoffeeScript "+this.VERSION,l="// "+j+"\n"+l),b.sourceMap?(c={js:l},c.sourceMap=o,c.v3SourceMap=o.generate(b,a),c):l}),c.tokens=v(function(a,b){return p.tokenize(a,b)}),c.nodes=v(function(a,b){return"string"==typeof a?q.parse(p.tokenize(a,b)):q.parse(a)}),c.run=function(c,d){var e,f,g,i;return null==d&&(d={}),g=a.main,g.filename=b.argv[1]=d.filename?k.realpathSync(d.filename):".",g.moduleCache&&(g.moduleCache={}),f=d.filename?r.dirname(k.realpathSync(d.filename)):k.realpathSync("."),g.paths=a("module")._nodeModulePaths(f),m.isCoffee(g.filename)&&!a.extensions||(e=h(c,d),c=null!=(i=e.js)?i:e),g._compile(c,g.filename)},c.eval=function(c,e){var f,g,i,j,k,l,m,n,o,p,q,s,t,v,x,y,z;if(null==e&&(e={}),c=c.trim()){if(j=null!=(s=u.Script.createContext)?s:u.createContext,l=null!=(t=u.isContext)?t:function(a){return e.sandbox instanceof j().constructor},j){if(null!=e.sandbox){if(l(e.sandbox))y=e.sandbox;else{y=j(),v=e.sandbox;for(n in v)w.call(v,n)&&(z=v[n],y[n]=z)}y.global=y.root=y.GLOBAL=y}else y=d;if(y.__filename=e.filename||"eval",y.__dirname=r.dirname(y.__filename),y===d&&!y.module&&!y.require){for(f=a("module"),y.module=g=new f(e.modulename||"eval"),y.require=i=function(a){return f._load(a,g,!0)},g.filename=y.__filename,x=Object.getOwnPropertyNames(a),k=0,o=x.length;o>k;k++)q=x[k],"paths"!==q&&"arguments"!==q&&"caller"!==q&&(i[q]=a[q]);i.paths=g.paths=f._nodeModulePaths(b.cwd()),i.resolve=function(a){return f._resolveFilename(a,g)}}}p={};for(n in e)w.call(e,n)&&(z=e[n],p[n]=z);return p.bare=!0,m=h(c,p),y===d?u.runInThisContext(m):u.runInContext(m,y)}},c.register=function(){return a("./register")},a.extensions)for(s=this.FILE_EXTENSIONS,n=0,o=s.length;o>n;n++)i=s[n],null==(g=a.extensions)[i]&&(g[i]=function(){throw new Error("Use CoffeeScript.register() or require the coffee-script/register module to require "+i+" files.")});c._compileFile=function(a,b){var c,d,e,f,g;null==b&&(b=!1),f=k.readFileSync(a,"utf8"),g=65279===f.charCodeAt(0)?f.substring(1):f;try{c=h(g,{filename:a,sourceMap:b,literate:m.isLiterate(a)})}catch(e){throw d=e,m.updateSyntaxError(d,g,a)}return c},p=new e,q.lexer={lex:function(){var a,b;return b=q.tokens[this.pos++],b?(a=b[0],this.yytext=b[1],this.yylloc=b[2],q.errorToken=b.origin||b,this.yylineno=this.yylloc.first_line):a="",a},setInput:function(a){return q.tokens=a,this.pos=0},upcomingInput:function(){return""}},q.yy=a("./nodes"),q.yy.parseError=function(a,b){var c,d,e,f,g,h;return g=b.token,f=q.errorToken,h=q.tokens,d=f[0],e=f[1],c=f[2],e=function(){switch(!1){case f!==h[h.length-1]:return"end of input";case"INDENT"!==d&&"OUTDENT"!==d:return"indentation";case"IDENTIFIER"!==d&&"NUMBER"!==d&&"STRING"!==d&&"STRING_START"!==d&&"REGEX"!==d&&"REGEX_START"!==d:return d.replace(/_START$/,"").toLowerCase();default:return m.nameWhitespaceCharacter(e)}}(),m.throwSyntaxError("unexpected "+e,c)},j=function(a,b){var c,d,e,f,g,h,i,j,k,l,m,n;return f=void 0,e="",a.isNative()?e="native":(a.isEval()?(f=a.getScriptNameOrSourceURL(),f||(e=a.getEvalOrigin()+", ")):f=a.getFileName(),f||(f="<anonymous>"),j=a.getLineNumber(),d=a.getColumnNumber(),l=b(f,j,d),e=l?f+":"+l[0]+":"+l[1]:f+":"+j+":"+d),g=a.getFunctionName(),h=a.isConstructor(),i=!(a.isToplevel()||h),i?(k=a.getMethodName(),n=a.getTypeName(),g?(m=c="",n&&g.indexOf(n)&&(m=n+"."),k&&g.indexOf("."+k)!==g.length-k.length-1&&(c=" [as "+k+"]"),""+m+g+c+" ("+e+")"):n+"."+(k||"<anonymous>")+" ("+e+")"):h?"new "+(g||"<anonymous>")+" ("+e+")":g?g+" ("+e+")":e},t={},l=function(a){var b,d;if(t[a])return t[a];if(d=null!=r?r.extname(a):void 0,!(x.call(c.FILE_EXTENSIONS,d)<0))return b=c._compileFile(a,!0),t[a]=b.sourceMap},Error.prepareStackTrace=function(a,b){var d,e,f;return f=function(a,b,c){var d,e;return e=l(a),e&&(d=e.sourceLocation([b-1,c-1])),d?[d[0]+1,d[1]+1]:null},e=function(){var a,e,g;for(g=[],a=0,e=b.length;e>a&&(d=b[a],d.getFunction()!==c.run);a++)g.push(" at "+j(d,f));return g}(),a.toString()+"\n"+e.join("\n")+"\n"}}).call(this)}).call(this,a("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./helpers":3,"./lexer":4,"./nodes":5,"./parser":6,"./register":7,"./sourcemap":10,_process:13,fs:11,module:11,path:12,vm:14}],3:[function(a,b,c){(function(a){(function(){var b,d,e,f,g,h;c.starts=function(a,b,c){return b===a.substr(c,b.length)},c.ends=function(a,b,c){var d;return d=b.length,b===a.substr(a.length-d-(c||0),d)},c.repeat=g=function(a,b){var c;for(c="";b>0;)1&b&&(c+=a),b>>>=1,a+=a;return c},c.compact=function(a){var b,c,d,e;for(e=[],b=0,d=a.length;d>b;b++)c=a[b],c&&e.push(c);return e},c.count=function(a,b){var c,d;if(c=d=0,!b.length)return 1/0;for(;d=1+a.indexOf(b,d);)c++;return c},c.merge=function(a,b){return d(d({},a),b)},d=c.extend=function(a,b){var c,d;for(c in b)d=b[c],a[c]=d;return a},c.flatten=e=function(a){var b,c,d,f;for(c=[],d=0,f=a.length;f>d;d++)b=a[d],"[object Array]"===Object.prototype.toString.call(b)?c=c.concat(e(b)):c.push(b);return c},c.del=function(a,b){var c;return c=a[b],delete a[b],c},c.some=null!=(f=Array.prototype.some)?f:function(a){var b,c,d;for(c=0,d=this.length;d>c;c++)if(b=this[c],a(b))return!0;return!1},c.invertLiterate=function(a){var b,c,d;return d=!0,c=function(){var c,e,f,g;for(f=a.split("\n"),g=[],c=0,e=f.length;e>c;c++)b=f[c],d&&/^([ ]{4}|[ ]{0,3}\t)/.test(b)?g.push(b):(d=/^\s*$/.test(b))?g.push(b):g.push("# "+b);return g}(),c.join("\n")},b=function(a,b){return b?{first_line:a.first_line,first_column:a.first_column,last_line:b.last_line,last_column:b.last_column}:a},c.addLocationDataFn=function(a,c){return function(d){return"object"==typeof d&&d.updateLocationDataIfMissing&&d.updateLocationDataIfMissing(b(a,c)),d}},c.locationDataToString=function(a){var b;return"2"in a&&"first_line"in a[2]?b=a[2]:"first_line"in a&&(b=a),b?b.first_line+1+":"+(b.first_column+1)+"-"+(b.last_line+1+":"+(b.last_column+1)):"No location data"},c.baseFileName=function(a,b,c){var d,e;return null==b&&(b=!1),null==c&&(c=!1),e=c?/\\|\//:/\//,d=a.split(e),a=d[d.length-1],b&&a.indexOf(".")>=0?(d=a.split("."),d.pop(),"coffee"===d[d.length-1]&&d.length>1&&d.pop(),d.join(".")):a},c.isCoffee=function(a){return/\.((lit)?coffee|coffee\.md)$/.test(a)},c.isLiterate=function(a){return/\.(litcoffee|coffee\.md)$/.test(a)},c.throwSyntaxError=function(a,b){var c;throw c=new SyntaxError(a),c.location=b,c.toString=h,c.stack=c.toString(),c},c.updateSyntaxError=function(a,b,c){return a.toString===h&&(a.code||(a.code=b),a.filename||(a.filename=c),a.stack=a.toString()),a},h=function(){var b,c,d,e,f,h,i,j,k,l,m,n,o,p,q;return this.code&&this.location?(m=this.location,i=m.first_line,h=m.first_column,k=m.last_line,j=m.last_column,null==k&&(k=i),null==j&&(j=h),f=this.filename||"[stdin]",b=this.code.split("\n")[i],q=h,e=i===k?j+1:b.length,l=b.slice(0,q).replace(/[^\s]/g," ")+g("^",e-q),"undefined"!=typeof a&&null!==a&&(d=(null!=(n=a.stdout)?n.isTTY:void 0)&&!(null!=(o=a.env)?o.NODE_DISABLE_COLORS:void 0)),(null!=(p=this.colorful)?p:d)&&(c=function(a){return"[1;31m"+a+"[0m"},b=b.slice(0,q)+c(b.slice(q,e))+b.slice(e),l=c(l)),f+":"+(i+1)+":"+(h+1)+": error: "+this.message+"\n"+b+"\n"+l):Error.prototype.toString.call(this)},c.nameWhitespaceCharacter=function(a){switch(a){case" ":return"space";case"\n":return"newline";case"\r":return"carriage return";case" ":return"tab";default:return a}}}).call(this)}).call(this,a("_process"))},{_process:13}],4:[function(a,b,c){(function(){var b,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,$,_,aa,ba,ca,da,ea,fa,ga,ha,ia,ja,ka,la,ma=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};ha=a("./rewriter"),Q=ha.Rewriter,w=ha.INVERSES,ia=a("./helpers"),da=ia.count,ka=ia.starts,ca=ia.compact,ja=ia.repeat,ea=ia.invertLiterate,ga=ia.locationDataToString,la=ia.throwSyntaxError,c.Lexer=E=function(){function a(){}return a.prototype.tokenize=function(a,b){var c,d,e,f;for(null==b&&(b={}),this.literate=b.literate,this.indent=0,this.baseIndent=0,this.indebt=0,this.outdebt=0,this.indents=[],this.ends=[],this.tokens=[],this.seenFor=!1,this.chunkLine=b.line||0,this.chunkColumn=b.column||0,a=this.clean(a),e=0;this.chunk=a.slice(e);)if(c=this.identifierToken()||this.commentToken()||this.whitespaceToken()||this.lineToken()||this.stringToken()||this.numberToken()||this.regexToken()||this.jsToken()||this.literalToken(),f=this.getLineAndColumnFromChunk(c),this.chunkLine=f[0],this.chunkColumn=f[1],e+=c,b.untilBalanced&&0===this.ends.length)return{tokens:this.tokens,index:e};return this.closeIndentation(),(d=this.ends.pop())&&this.error("missing "+d.tag,d.origin[2]),b.rewrite===!1?this.tokens:(new Q).rewrite(this.tokens)},a.prototype.clean=function(a){return a.charCodeAt(0)===b&&(a=a.slice(1)),a=a.replace(/\r/g,"").replace(Z,""),ba.test(a)&&(a="\n"+a,this.chunkLine--),this.literate&&(a=ea(a)),a},a.prototype.identifierToken=function(){var a,b,c,d,e,f,j,k,l,m,n,o,p,q,r,t;return(k=s.exec(this.chunk))?(j=k[0],e=k[1],b=k[2],f=e.length,l=void 0,"own"===e&&"FOR"===this.tag()?(this.token("OWN",e),e.length):"from"===e&&"YIELD"===this.tag()?(this.token("FROM",e),e.length):(n=this.tokens,m=n[n.length-1],d=b||null!=m&&("."===(o=m[0])||"?."===o||"::"===o||"?::"===o||!m.spaced&&"@"===m[0]),r="IDENTIFIER",!d&&(ma.call(z,e)>=0||ma.call(i,e)>=0)&&(r=e.toUpperCase(),"WHEN"===r&&(p=this.tag(),ma.call(B,p)>=0)?r="LEADING_WHEN":"FOR"===r?this.seenFor=!0:"UNLESS"===r?r="IF":ma.call($,r)>=0?r="UNARY":ma.call(O,r)>=0&&("INSTANCEOF"!==r&&this.seenFor?(r="FOR"+r,this.seenFor=!1):(r="RELATION","!"===this.value()&&(l=this.tokens.pop(),e="!"+e)))),ma.call(y,e)>=0&&(d?(r="IDENTIFIER",e=new String(e),e.reserved=!0):ma.call(P,e)>=0&&this.error("reserved word '"+e+"'",{length:e.length})),d||(ma.call(g,e)>=0&&(a=e,e=h[e]),r=function(){switch(e){case"!":return"UNARY";case"==":case"!=":return"COMPARE";case"&&":case"||":return"LOGIC";case"true":case"false":return"BOOL";case"break":case"continue":return"STATEMENT";default:return r}}()),t=this.token(r,e,0,f),a&&(t.origin=[r,a,t[2]]),t.variable=!d,l&&(q=[l[2].first_line,l[2].first_column],t[2].first_line=q[0],t[2].first_column=q[1]),b&&(c=j.lastIndexOf(":"),this.token(":",":",c,b.length)),j.length)):0},a.prototype.numberToken=function(){var a,b,c,d,e;return(c=I.exec(this.chunk))?(d=c[0],b=d.length,/^0[BOX]/.test(d)?this.error("radix prefix in '"+d+"' must be lowercase",{offset:1}):/E/.test(d)&&!/^0x/.test(d)?this.error("exponential notation in '"+d+"' must be indicated with a lowercase 'e'",{offset:d.indexOf("E")}):/^0\d*[89]/.test(d)?this.error("decimal literal '"+d+"' must not be prefixed with '0'",{length:b}):/^0\d+/.test(d)&&this.error("octal literal '"+d+"' must be prefixed with '0o'",{length:b}),(e=/^0o([0-7]+)/.exec(d))&&(d="0x"+parseInt(e[1],8).toString(16)),(a=/^0b([01]+)/.exec(d))&&(d="0x"+parseInt(a[1],2).toString(16)),this.token("NUMBER",d,0,b),b):0},a.prototype.stringToken=function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,q,r,s;if(k=(X.exec(this.chunk)||[])[0],!k)return 0;if(q=function(){switch(k){case"'":return W;case'"':return U;case"'''":return p;case'"""':return n}}(),f=3===k.length,l=this.matchWithInterpolations(q,k),s=l.tokens,e=l.index,a=s.length-1,c=k.charAt(0),f){for(h=null,d=function(){var a,b,c;for(c=[],g=a=0,b=s.length;b>a;g=++a)r=s[g],"NEOSTRING"===r[0]&&c.push(r[1]);return c}().join("#{}");j=o.exec(d);)b=j[1],(null===h||0<(m=b.length)&&m<h.length)&&(h=b);h&&(i=RegExp("^"+h,"gm")),this.mergeInterpolationTokens(s,{delimiter:c},function(b){return function(c,d){return c=b.formatString(c),0===d&&(c=c.replace(A,"")),d===a&&(c=c.replace(Y,"")),i&&(c=c.replace(i,"")),c}}(this))}else this.mergeInterpolationTokens(s,{delimiter:c},function(b){return function(c,d){return c=b.formatString(c),c=c.replace(S,function(b,e){return 0===d&&0===e||d===a&&e+b.length===c.length?"":" "})}}(this));return e},a.prototype.commentToken=function(){var a,b,c;return(c=this.chunk.match(j))?(a=c[0],b=c[1],b&&((c=m.exec(a))&&this.error("block comments cannot contain "+c[0],{offset:c.index,length:c[0].length}),b.indexOf("\n")>=0&&(b=b.replace(RegExp("\\n"+ja(" ",this.indent),"g"),"\n")),this.token("HERECOMMENT",b,0,a.length)),a.length):0},a.prototype.jsToken=function(){var a,b;return"`"===this.chunk.charAt(0)&&(a=x.exec(this.chunk))?(this.token("JS",(b=a[0]).slice(1,-1),0,b.length),b.length):0},a.prototype.regexToken=function(){var a,b,c,d,f,g,h,i,j,k,l,m,n;switch(!1){case!(g=N.exec(this.chunk)):this.error("regular expressions cannot begin with "+g[2],{offset:g.index+g[1].length});break;case!(g=this.matchWithInterpolations(q,"///")):n=g.tokens,f=g.index;break;case!(g=L.exec(this.chunk)):if(m=g[0],a=g[1],b=g[2],this.validateEscapes(a,{isRegex:!0,offsetInChunk:1}),f=m.length,j=this.tokens,i=j[j.length-1],i)if(i.spaced&&(k=i[0],ma.call(e,k)>=0)){if(!b||K.test(m))return 0}else if(l=i[0],ma.call(H,l)>=0)return 0;b||this.error("missing / (unclosed regex)");break;default:return 0}switch(d=M.exec(this.chunk.slice(f))[0],c=f+d.length,h=this.makeToken("REGEX",null,0,c),!1){case!!aa.test(d):this.error("invalid regular expression flags "+d,{offset:f,length:d.length});break;case!(m||1===n.length):null==a&&(a=this.formatHeregex(n[0][1])),this.token("REGEX",""+this.makeDelimitedLiteral(a,{delimiter:"/"})+d,0,c,h);break;default:this.token("REGEX_START","(",0,0,h),this.token("IDENTIFIER","RegExp",0,0),this.token("CALL_START","(",0,0),this.mergeInterpolationTokens(n,{delimiter:'"',"double":!0},this.formatHeregex),d&&(this.token(",",",",f,0),this.token("STRING",'"'+d+'"',f,d.length)),this.token(")",")",c,0),this.token("REGEX_END",")",c,0)}return c},a.prototype.lineToken=function(){var a,b,c,d,e;if(!(c=G.exec(this.chunk)))return 0;if(b=c[0],this.seenFor=!1,e=b.length-1-b.lastIndexOf("\n"),d=this.unfinished(),e-this.indebt===this.indent)return d?this.suppressNewlines():this.newlineToken(0),b.length;if(e>this.indent){if(d)return this.indebt=e-this.indent,this.suppressNewlines(),b.length;if(!this.tokens.length)return this.baseIndent=this.indent=e,b.length;a=e-this.indent+this.outdebt,this.token("INDENT",a,b.length-e,e),this.indents.push(a),this.ends.push({tag:"OUTDENT"}),this.outdebt=this.indebt=0,this.indent=e}else e<this.baseIndent?this.error("missing indentation",{offset:b.length}):(this.indebt=0,this.outdentToken(this.indent-e,d,b.length));return b.length},a.prototype.outdentToken=function(a,b,c){var d,e,f,g;for(d=this.indent-a;a>0;)f=this.indents[this.indents.length-1],f?f===this.outdebt?(a-=this.outdebt,this.outdebt=0):f<this.outdebt?(this.outdebt-=f,a-=f):(e=this.indents.pop()+this.outdebt,c&&(g=this.chunk[c],ma.call(t,g)>=0)&&(d-=e-a,a=e),this.outdebt=0,this.pair("OUTDENT"),this.token("OUTDENT",a,0,c),a-=e):a=0;for(e&&(this.outdebt-=a);";"===this.value();)this.tokens.pop();return"TERMINATOR"===this.tag()||b||this.token("TERMINATOR","\n",c,0),this.indent=d,this},a.prototype.whitespaceToken=function(){var a,b,c,d;return(a=ba.exec(this.chunk))||(b="\n"===this.chunk.charAt(0))?(d=this.tokens,c=d[d.length-1],c&&(c[a?"spaced":"newLine"]=!0),a?a[0].length:0):0},a.prototype.newlineToken=function(a){for(;";"===this.value();)this.tokens.pop();return"TERMINATOR"!==this.tag()&&this.token("TERMINATOR","\n",a,0),this},a.prototype.suppressNewlines=function(){return"\\"===this.value()&&this.tokens.pop(),this},a.prototype.literalToken=function(){var a,b,c,d,g,h,i,j,m,n;if((a=J.exec(this.chunk))?(n=a[0],f.test(n)&&this.tagParameters()):n=this.chunk.charAt(0),j=n,c=this.tokens,b=c[c.length-1],"="===n&&b&&(!b[1].reserved&&(d=b[1],ma.call(y,d)>=0)&&(b.origin&&(b=b.origin),this.error("reserved word '"+b[1]+"' can't be assigned",b[2])),"||"===(g=b[1])||"&&"===g))return b[0]="COMPOUND_ASSIGN",b[1]+="=",n.length;if(";"===n)this.seenFor=!1,j="TERMINATOR";else if(ma.call(F,n)>=0)j="MATH";else if(ma.call(k,n)>=0)j="COMPARE";else if(ma.call(l,n)>=0)j="COMPOUND_ASSIGN";else if(ma.call($,n)>=0)j="UNARY";else if(ma.call(_,n)>=0)j="UNARY_MATH";else if(ma.call(R,n)>=0)j="SHIFT";else if(ma.call(D,n)>=0||"?"===n&&(null!=b?b.spaced:void 0))j="LOGIC";else if(b&&!b.spaced)if("("===n&&(h=b[0],ma.call(e,h)>=0))"?"===b[0]&&(b[0]="FUNC_EXIST"),j="CALL_START";else if("["===n&&(i=b[0],ma.call(u,i)>=0))switch(j="INDEX_START",b[0]){case"?":b[0]="INDEX_SOAK"}switch(m=this.makeToken(j,n),n){case"(":case"{":case"[":this.ends.push({tag:w[n],origin:m});break;case")":case"}":case"]":this.pair(n)}return this.tokens.push(m),n.length},a.prototype.tagParameters=function(){var a,b,c,d;if(")"!==this.tag())return this;for(b=[],d=this.tokens,a=d.length,d[--a][0]="PARAM_END";c=d[--a];)switch(c[0]){case")":b.push(c);break;case"(":case"CALL_START":if(!b.length)return"("===c[0]?(c[0]="PARAM_START",this):this;b.pop()}return this},a.prototype.closeIndentation=function(){return this.outdentToken(this.indent)},a.prototype.matchWithInterpolations=function(b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r;if(r=[],k=c.length,this.chunk.slice(0,k)!==c)return null;for(p=this.chunk.slice(k);;){if(q=b.exec(p)[0],this.validateEscapes(q,{isRegex:"/"===c.charAt(0),offsetInChunk:k}),r.push(this.makeToken("NEOSTRING",q,k)),p=p.slice(q.length),k+=q.length,"#{"!==p.slice(0,2))break;m=this.getLineAndColumnFromChunk(k+1),i=m[0],e=m[1],n=(new a).tokenize(p.slice(1),{line:i,column:e,untilBalanced:!0}),j=n.tokens,g=n.index,g+=1,l=j[0],d=j[j.length-1],l[0]=l[1]="(",d[0]=d[1]=")",d.origin=["","end of interpolation",d[2]],"TERMINATOR"===(null!=(o=j[1])?o[0]:void 0)&&j.splice(1,1),r.push(["TOKENS",j]),p=p.slice(g),k+=g}return p.slice(0,c.length)!==c&&this.error("missing "+c,{length:c.length}),f=r[0],h=r[r.length-1],f[2].first_column-=c.length,h[2].last_column+=c.length,0===h[1].length&&(h[2].last_column-=1),{tokens:r,index:k+c.length}},a.prototype.mergeInterpolationTokens=function(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s;for(a.length>1&&(l=this.token("STRING_START","(",0,0)),f=this.tokens.length,g=h=0,j=a.length;j>h;g=++h){switch(q=a[g],p=q[0],s=q[1],p){case"TOKENS":if(2===s.length)continue;k=s[0],r=s;break;case"NEOSTRING":if(d=c(q[1],g),0===d.length){if(0!==g)continue;e=this.tokens.length}2===g&&null!=e&&this.tokens.splice(e,2),q[0]="STRING",q[1]=this.makeDelimitedLiteral(d,b),k=q,r=[q]}this.tokens.length>f&&(m=this.token("+","+"),m[2]={first_line:k[2].first_line,first_column:k[2].first_column,last_line:k[2].first_line,last_column:k[2].first_column}),(n=this.tokens).push.apply(n,r)}return l?(i=a[a.length-1],l.origin=["STRING",null,{first_line:l[2].first_line,first_column:l[2].first_column,last_line:i[2].last_line,last_column:i[2].last_column}],o=this.token("STRING_END",")"),o[2]={first_line:i[2].last_line,first_column:i[2].last_column,last_line:i[2].last_line,last_column:i[2].last_column}):void 0},a.prototype.pair=function(a){var b,c,d,e,f;return d=this.ends,c=d[d.length-1],a!==(f=null!=c?c.tag:void 0)?("OUTDENT"!==f&&this.error("unmatched "+a),e=this.indents,b=e[e.length-1],this.outdentToken(b,!0),this.pair(a)):this.ends.pop()},a.prototype.getLineAndColumnFromChunk=function(a){var b,c,d,e,f;return 0===a?[this.chunkLine,this.chunkColumn]:(f=a>=this.chunk.length?this.chunk:this.chunk.slice(0,+(a-1)+1||9e9),d=da(f,"\n"),b=this.chunkColumn,d>0?(e=f.split("\n"),c=e[e.length-1],b=c.length):b+=f.length,[this.chunkLine+d,b])},a.prototype.makeToken=function(a,b,c,d){var e,f,g,h,i;return null==c&&(c=0),null==d&&(d=b.length),f={},g=this.getLineAndColumnFromChunk(c),f.first_line=g[0],f.first_column=g[1],e=Math.max(0,d-1),h=this.getLineAndColumnFromChunk(c+e),f.last_line=h[0],f.last_column=h[1],i=[a,b,f]},a.prototype.token=function(a,b,c,d,e){var f;return f=this.makeToken(a,b,c,d),e&&(f.origin=e),this.tokens.push(f),f},a.prototype.tag=function(){var a,b;return a=this.tokens,b=a[a.length-1],null!=b?b[0]:void 0},a.prototype.value=function(){var a,b;return a=this.tokens,b=a[a.length-1],null!=b?b[1]:void 0},a.prototype.unfinished=function(){var a;return C.test(this.chunk)||"\\"===(a=this.tag())||"."===a||"?."===a||"?::"===a||"UNARY"===a||"MATH"===a||"UNARY_MATH"===a||"+"===a||"-"===a||"YIELD"===a||"**"===a||"SHIFT"===a||"RELATION"===a||"COMPARE"===a||"LOGIC"===a||"THROW"===a||"EXTENDS"===a},a.prototype.formatString=function(a){return a.replace(V,"$1")},a.prototype.formatHeregex=function(a){return a.replace(r,"$1$2")},a.prototype.validateEscapes=function(a,b){var c,d,e,f,g,h,i,j;return null==b&&(b={}),f=v.exec(a),!f||(f[0],c=f[1],h=f[2],d=f[3],j=f[4],b.isRegex&&h&&"0"!==h.charAt(0))?void 0:(g=h?"octal escape sequences are not allowed":"invalid escape sequence",e="\\"+(h||d||j),this.error(g+" "+e,{offset:(null!=(i=b.offsetInChunk)?i:0)+f.index+c.length,length:e.length}))},a.prototype.makeDelimitedLiteral=function(a,b){var c;return null==b&&(b={}),""===a&&"/"===b.delimiter&&(a="(?:)"),c=RegExp("(\\\\\\\\)|(\\\\0(?=[1-7]))|\\\\?("+b.delimiter+")|\\\\?(?:(\\n)|(\\r)|(\\u2028)|(\\u2029))|(\\\\.)","g"),a=a.replace(c,function(a,c,d,e,f,g,h,i,j){switch(!1){case!c:return b["double"]?c+c:c;case!d:return"\\x00";case!e:return"\\"+e;case!f:return"\\n";case!g:return"\\r";case!h:return"\\u2028";case!i:return"\\u2029";case!j:return b["double"]?"\\"+j:j}}),""+b.delimiter+a+b.delimiter},a.prototype.error=function(a,b){var c,d,e,f,g,h;return null==b&&(b={}),e="first_line"in b?b:(g=this.getLineAndColumnFromChunk(null!=(f=b.offset)?f:0),d=g[0],c=g[1],g,{first_line:d,first_column:c,last_column:c+(null!=(h=b.length)?h:1)-1}),la(a,e)},a}(),z=["true","false","null","this","new","delete","typeof","in","instanceof","return","throw","break","continue","debugger","yield","if","else","switch","for","while","do","try","catch","finally","class","extends","super"],i=["undefined","then","unless","until","loop","of","by","when"],h={and:"&&",or:"||",is:"==",isnt:"!=",not:"!",yes:"true",no:"false",on:"true",off:"false"},g=function(){var a;a=[];for(fa in h)a.push(fa);return a}(),i=i.concat(g),P=["case","default","function","var","void","with","const","let","enum","export","import","native","implements","interface","package","private","protected","public","static"],T=["arguments","eval","yield*"],y=z.concat(P).concat(T),c.RESERVED=P.concat(z).concat(i).concat(T),c.STRICT_PROSCRIBED=T,b=65279,s=/^(?!\d)((?:(?!\s)[$\w\x7f-\uffff])+)([^\n\S]*:(?!:))?/,I=/^0b[01]+|^0o[0-7]+|^0x[\da-f]+|^\d*\.?\d+(?:e[+-]?\d+)?/i,J=/^(?:[-=]>|[-+*\/%<>&|^!?=]=|>>>=?|([-+:])\1|([&|<>*\/%])\2=?|\?(\.|::)|\.{2,3})/,ba=/^[^\n\S]+/,j=/^###([^#][\s\S]*?)(?:###[^\n\S]*|###$)|^(?:\s*#(?!##[^#]).*)+/,f=/^[-=]>/,G=/^(?:\n[^\n\S]*)+/,x=/^`[^\\`]*(?:\\.[^\\`]*)*`/,X=/^(?:'''|"""|'|")/,W=/^(?:[^\\']|\\[\s\S])*/,U=/^(?:[^\\"#]|\\[\s\S]|\#(?!\{))*/,p=/^(?:[^\\']|\\[\s\S]|'(?!''))*/,n=/^(?:[^\\"#]|\\[\s\S]|"(?!"")|\#(?!\{))*/,V=/((?:\\\\)+)|\\[^\S\n]*\n\s*/g,S=/\s*\n\s*/g,o=/\n+([^\n\S]*)(?=\S)/g,L=/^\/(?!\/)((?:[^[\/\n\\]|\\[^\n]|\[(?:\\[^\n]|[^\]\n\\])*\])*)(\/)?/,M=/^\w*/,aa=/^(?!.*(.).*\1)[imgy]*$/,q=/^(?:[^\\\/#]|\\[\s\S]|\/(?!\/\/)|\#(?!\{))*/,r=/((?:\\\\)+)|\\(\s)|\s+(?:#.*)?/g,N=/^(\/|\/{3}\s*)(\*)/,K=/^\/=?\s/,m=/\*\//,C=/^\s*(?:,|\??\.(?![.\d])|::)/,v=/((?:^|[^\\])(?:\\\\)*)\\(?:(0[0-7]|[1-7])|(x(?![\da-fA-F]{2}).{0,2})|(u(?![\da-fA-F]{4}).{0,4}))/,A=/^[^\n\S]*\n/,Y=/\n[^\n\S]*$/,Z=/\s+$/,l=["-=","+=","/=","*=","%=","||=","&&=","?=","<<=",">>=",">>>=","&=","^=","|=","**=","//=","%%="],$=["NEW","TYPEOF","DELETE","DO"],_=["!","~"],D=["&&","||","&","|","^"],R=["<<",">>",">>>"],k=["==","!=","<",">","<=",">="],F=["*","/","%","//","%%"],O=["IN","OF","INSTANCEOF"],d=["TRUE","FALSE"],e=["IDENTIFIER",")","]","?","@","THIS","SUPER"],u=e.concat(["NUMBER","STRING","STRING_END","REGEX","REGEX_END","BOOL","NULL","UNDEFINED","}","::"]),H=u.concat(["++","--"]),B=["INDENT","OUTDENT","TERMINATOR"],t=[")","}","]"]}).call(this)},{"./helpers":3,"./rewriter":8}],5:[function(a,b,c){(function(){var b,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,$,_,aa,ba,ca,da,ea,fa,ga,ha,ia,ja,ka,la,ma,na,oa,pa,qa,ra,sa,ta,ua,va=function(a,b){function c(){this.constructor=a}for(var d in b)wa.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},wa={}.hasOwnProperty,xa=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1},ya=[].slice;Error.stackTraceLimit=1/0,Q=a("./scope").Scope,oa=a("./lexer"),L=oa.RESERVED,P=oa.STRICT_PROSCRIBED,pa=a("./helpers"),ba=pa.compact,fa=pa.flatten,ea=pa.extend,la=pa.merge,ca=pa.del,ra=pa.starts,da=pa.ends,qa=pa.some,aa=pa.addLocationDataFn,ka=pa.locationDataToString,sa=pa.throwSyntaxError,c.extend=ea,c.addLocationDataFn=aa,_=function(){return!0},F=function(){return!1},V=function(){return this},E=function(){return this.negated=!this.negated,this},c.CodeFragment=k=function(){function a(a,b){var c;this.code=""+b,this.locationData=null!=a?a.locationData:void 0,this.type=(null!=a&&null!=(c=a.constructor)?c.name:void 0)||"unknown"}return a.prototype.toString=function(){return""+this.code+(this.locationData?": "+ka(this.locationData):"")},a}(),ga=function(a){var b;return function(){var c,d,e;for(e=[],c=0,d=a.length;d>c;c++)b=a[c],e.push(b.code);return e}().join("")},c.Base=f=function(){function a(){}return a.prototype.compile=function(a,b){return ga(this.compileToFragments(a,b))},a.prototype.compileToFragments=function(a,b){var c;return a=ea({},a),b&&(a.level=b),c=this.unfoldSoak(a)||this,c.tab=a.indent,a.level!==C&&c.isStatement(a)?c.compileClosure(a):c.compileNode(a)},a.prototype.compileClosure=function(a){var c,d,e,f,i,k,l;return(f=this.jumps())&&f.error("cannot use a pure statement in an expression"),a.sharedScope=!0,e=new j([],g.wrap([this])),c=[],((d=this.contains(ia))||this.contains(ja))&&(c=[new D("this")],d?(i="apply",c.push(new D("arguments"))):i="call",e=new Z(e,[new b(new D(i))])),k=new h(e,c).compileNode(a),(e.isGenerator||(null!=(l=e.base)?l.isGenerator:void 0))&&(k.unshift(this.makeCode("(yield* ")),k.push(this.makeCode(")"))),k},a.prototype.cache=function(a,b,c){var d,f,g;return d=null!=c?c(this):this.isComplex(),d?(f=new D(a.scope.freeVariable("ref")),g=new e(f,this),b?[g.compileToFragments(a,b),[this.makeCode(f.value)]]:[g,f]):(f=b?this.compileToFragments(a,b):this,[f,f])},a.prototype.cacheToCodeFragments=function(a){return[ga(a[0]),ga(a[1])]},a.prototype.makeReturn=function(a){var b;return b=this.unwrapAll(),a?new h(new D(a+".push"),[b]):new N(b)},a.prototype.contains=function(a){var b;return b=void 0,this.traverseChildren(!1,function(c){return a(c)?(b=c,!1):void 0}),b},a.prototype.lastNonComment=function(a){var b;for(b=a.length;b--;)if(!(a[b]instanceof l))return a[b];return null},a.prototype.toString=function(a,b){var c;return null==a&&(a=""),null==b&&(b=this.constructor.name),c="\n"+a+b,this.soak&&(c+="?"),this.eachChild(function(b){return c+=b.toString(a+U)}),c},a.prototype.eachChild=function(a){var b,c,d,e,f,g,h,i;if(!this.children)return this;for(h=this.children,d=0,f=h.length;f>d;d++)if(b=h[d],this[b])for(i=fa([this[b]]),e=0,g=i.length;g>e;e++)if(c=i[e],a(c)===!1)return this;return this},a.prototype.traverseChildren=function(a,b){return this.eachChild(function(c){var d;return d=b(c),d!==!1?c.traverseChildren(a,b):void 0})},a.prototype.invert=function(){return new I("!",this)},a.prototype.unwrapAll=function(){var a;for(a=this;a!==(a=a.unwrap()););return a},a.prototype.children=[],a.prototype.isStatement=F,a.prototype.jumps=F,a.prototype.isComplex=_,a.prototype.isChainable=F,a.prototype.isAssignable=F,a.prototype.unwrap=V,a.prototype.unfoldSoak=F,a.prototype.assigns=F,a.prototype.updateLocationDataIfMissing=function(a){return this.locationData?this:(this.locationData=a,this.eachChild(function(b){return b.updateLocationDataIfMissing(a)}))},a.prototype.error=function(a){return sa(a,this.locationData)},a.prototype.makeCode=function(a){return new k(this,a)},a.prototype.wrapInBraces=function(a){return[].concat(this.makeCode("("),a,this.makeCode(")"))},a.prototype.joinFragmentArrays=function(a,b){var c,d,e,f,g;for(c=[],e=f=0,g=a.length;g>f;e=++f)d=a[e],e&&c.push(this.makeCode(b)),c=c.concat(d);return c},a}(),c.Block=g=function(a){function b(a){this.expressions=ba(fa(a||[]))}return va(b,a),b.prototype.children=["expressions"],b.prototype.push=function(a){return this.expressions.push(a),this},b.prototype.pop=function(){return this.expressions.pop()},b.prototype.unshift=function(a){return this.expressions.unshift(a),this},b.prototype.unwrap=function(){return 1===this.expressions.length?this.expressions[0]:this},b.prototype.isEmpty=function(){return!this.expressions.length},b.prototype.isStatement=function(a){var b,c,d,e;for(e=this.expressions,c=0,d=e.length;d>c;c++)if(b=e[c],b.isStatement(a))return!0;return!1},b.prototype.jumps=function(a){var b,c,d,e,f;for(f=this.expressions,c=0,e=f.length;e>c;c++)if(b=f[c],d=b.jumps(a))return d},b.prototype.makeReturn=function(a){var b,c;for(c=this.expressions.length;c--;)if(b=this.expressions[c],!(b instanceof l)){this.expressions[c]=b.makeReturn(a),b instanceof N&&!b.expression&&this.expressions.splice(c,1);break}return this},b.prototype.compileToFragments=function(a,c){return null==a&&(a={}),a.scope?b.__super__.compileToFragments.call(this,a,c):this.compileRoot(a)},b.prototype.compileNode=function(a){var c,d,e,f,g,h,i,j,k;for(this.tab=a.indent,k=a.level===C,d=[],j=this.expressions,f=g=0,h=j.length;h>g;f=++g)i=j[f],i=i.unwrapAll(),i=i.unfoldSoak(a)||i,
i instanceof b?d.push(i.compileNode(a)):k?(i.front=!0,e=i.compileToFragments(a),i.isStatement(a)||(e.unshift(this.makeCode(""+this.tab)),e.push(this.makeCode(";"))),d.push(e)):d.push(i.compileToFragments(a,z));return k?this.spaced?[].concat(this.joinFragmentArrays(d,"\n\n"),this.makeCode("\n")):this.joinFragmentArrays(d,"\n"):(c=d.length?this.joinFragmentArrays(d,", "):[this.makeCode("void 0")],d.length>1&&a.level>=z?this.wrapInBraces(c):c)},b.prototype.compileRoot=function(a){var b,c,d,e,f,g,h,i,j,k,m;for(a.indent=a.bare?"":U,a.level=C,this.spaced=!0,a.scope=new Q(null,this,null,null!=(j=a.referencedVars)?j:[]),k=a.locals||[],e=0,f=k.length;f>e;e++)g=k[e],a.scope.parameter(g);return h=[],a.bare||(i=function(){var a,c,e,f;for(e=this.expressions,f=[],d=a=0,c=e.length;c>a&&(b=e[d],b.unwrap()instanceof l);d=++a)f.push(b);return f}.call(this),m=this.expressions.slice(i.length),this.expressions=i,i.length&&(h=this.compileNode(la(a,{indent:""})),h.push(this.makeCode("\n"))),this.expressions=m),c=this.compileWithDeclarations(a),a.bare?c:[].concat(h,this.makeCode("(function() {\n"),c,this.makeCode("\n}).call(this);\n"))},b.prototype.compileWithDeclarations=function(a){var b,c,d,e,f,g,h,i,j,k,m,n,o,p;for(e=[],i=[],j=this.expressions,f=g=0,h=j.length;h>g&&(d=j[f],d=d.unwrap(),d instanceof l||d instanceof D);f=++g);return a=la(a,{level:C}),f&&(n=this.expressions.splice(f,9e9),k=[this.spaced,!1],p=k[0],this.spaced=k[1],m=[this.compileNode(a),p],e=m[0],this.spaced=m[1],this.expressions=n),i=this.compileNode(a),o=a.scope,o.expressions===this&&(c=a.scope.hasDeclarations(),b=o.hasAssignments,c||b?(f&&e.push(this.makeCode("\n")),e.push(this.makeCode(this.tab+"var ")),c&&e.push(this.makeCode(o.declaredVariables().join(", "))),b&&(c&&e.push(this.makeCode(",\n"+(this.tab+U))),e.push(this.makeCode(o.assignedVariables().join(",\n"+(this.tab+U))))),e.push(this.makeCode(";\n"+(this.spaced?"\n":"")))):e.length&&i.length&&e.push(this.makeCode("\n"))),e.concat(i)},b.wrap=function(a){return 1===a.length&&a[0]instanceof b?a[0]:new b(a)},b}(f),c.Literal=D=function(a){function b(a){this.value=a}return va(b,a),b.prototype.makeReturn=function(){return this.isStatement()?this:b.__super__.makeReturn.apply(this,arguments)},b.prototype.isAssignable=function(){return r.test(this.value)},b.prototype.isStatement=function(){var a;return"break"===(a=this.value)||"continue"===a||"debugger"===a},b.prototype.isComplex=F,b.prototype.assigns=function(a){return a===this.value},b.prototype.jumps=function(a){return("break"!==this.value||(null!=a?a.loop:void 0)||(null!=a?a.block:void 0))&&("continue"!==this.value||(null!=a?a.loop:void 0))?void 0:this},b.prototype.compileNode=function(a){var b,c,d;return c="this"===this.value?(null!=(d=a.scope.method)?d.bound:void 0)?a.scope.method.context:this.value:this.value.reserved?'"'+this.value+'"':this.value,b=this.isStatement()?""+this.tab+c+";":c,[this.makeCode(b)]},b.prototype.toString=function(){return' "'+this.value+'"'},b}(f),c.Undefined=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return va(b,a),b.prototype.isAssignable=F,b.prototype.isComplex=F,b.prototype.compileNode=function(a){return[this.makeCode(a.level>=x?"(void 0)":"void 0")]},b}(f),c.Null=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return va(b,a),b.prototype.isAssignable=F,b.prototype.isComplex=F,b.prototype.compileNode=function(){return[this.makeCode("null")]},b}(f),c.Bool=function(a){function b(a){this.val=a}return va(b,a),b.prototype.isAssignable=F,b.prototype.isComplex=F,b.prototype.compileNode=function(){return[this.makeCode(this.val)]},b}(f),c.Return=N=function(a){function b(a){this.expression=a}return va(b,a),b.prototype.children=["expression"],b.prototype.isStatement=_,b.prototype.makeReturn=V,b.prototype.jumps=V,b.prototype.compileToFragments=function(a,c){var d,e;return d=null!=(e=this.expression)?e.makeReturn():void 0,!d||d instanceof b?b.__super__.compileToFragments.call(this,a,c):d.compileToFragments(a,c)},b.prototype.compileNode=function(a){var b,c,d;return b=[],c=null!=(d=this.expression)&&"function"==typeof d.isYieldReturn?d.isYieldReturn():void 0,c||b.push(this.makeCode(this.tab+("return"+(this.expression?" ":"")))),this.expression&&(b=b.concat(this.expression.compileToFragments(a,B))),c||b.push(this.makeCode(";")),b},b}(f),c.Value=Z=function(a){function b(a,c,d){return!c&&a instanceof b?a:(this.base=a,this.properties=c||[],d&&(this[d]=!0),this)}return va(b,a),b.prototype.children=["base","properties"],b.prototype.add=function(a){return this.properties=this.properties.concat(a),this},b.prototype.hasProperties=function(){return!!this.properties.length},b.prototype.bareLiteral=function(a){return!this.properties.length&&this.base instanceof a},b.prototype.isArray=function(){return this.bareLiteral(d)},b.prototype.isRange=function(){return this.bareLiteral(M)},b.prototype.isComplex=function(){return this.hasProperties()||this.base.isComplex()},b.prototype.isAssignable=function(){return this.hasProperties()||this.base.isAssignable()},b.prototype.isSimpleNumber=function(){return this.bareLiteral(D)&&O.test(this.base.value)},b.prototype.isString=function(){return this.bareLiteral(D)&&t.test(this.base.value)},b.prototype.isRegex=function(){return this.bareLiteral(D)&&s.test(this.base.value)},b.prototype.isAtomic=function(){var a,b,c,d;for(d=this.properties.concat(this.base),a=0,b=d.length;b>a;a++)if(c=d[a],c.soak||c instanceof h)return!1;return!0},b.prototype.isNotCallable=function(){return this.isSimpleNumber()||this.isString()||this.isRegex()||this.isArray()||this.isRange()||this.isSplice()||this.isObject()},b.prototype.isStatement=function(a){return!this.properties.length&&this.base.isStatement(a)},b.prototype.assigns=function(a){return!this.properties.length&&this.base.assigns(a)},b.prototype.jumps=function(a){return!this.properties.length&&this.base.jumps(a)},b.prototype.isObject=function(a){return this.properties.length?!1:this.base instanceof H&&(!a||this.base.generated)},b.prototype.isSplice=function(){var a,b;return b=this.properties,a=b[b.length-1],a instanceof R},b.prototype.looksStatic=function(a){var b;return this.base.value===a&&1===this.properties.length&&"prototype"!==(null!=(b=this.properties[0].name)?b.value:void 0)},b.prototype.unwrap=function(){return this.properties.length?this:this.base},b.prototype.cacheReference=function(a){var c,d,f,g,h;return h=this.properties,f=h[h.length-1],this.properties.length<2&&!this.base.isComplex()&&!(null!=f?f.isComplex():void 0)?[this,this]:(c=new b(this.base,this.properties.slice(0,-1)),c.isComplex()&&(d=new D(a.scope.freeVariable("base")),c=new b(new K(new e(d,c)))),f?(f.isComplex()&&(g=new D(a.scope.freeVariable("name")),f=new w(new e(g,f.index)),g=new w(g)),[c.add(f),new b(d||c.base,[g||f])]):[c,d])},b.prototype.compileNode=function(a){var b,c,d,e,f;for(this.base.front=this.front,f=this.properties,b=this.base.compileToFragments(a,f.length?x:null),(this.base instanceof K||f.length)&&O.test(ga(b))&&b.push(this.makeCode(".")),c=0,d=f.length;d>c;c++)e=f[c],b.push.apply(b,e.compileToFragments(a));return b},b.prototype.unfoldSoak=function(a){return null!=this.unfoldedSoak?this.unfoldedSoak:this.unfoldedSoak=function(c){return function(){var d,f,g,h,i,j,k,l,n,o;if(g=c.base.unfoldSoak(a))return(l=g.body.properties).push.apply(l,c.properties),g;for(n=c.properties,f=h=0,i=n.length;i>h;f=++h)if(j=n[f],j.soak)return j.soak=!1,d=new b(c.base,c.properties.slice(0,f)),o=new b(c.base,c.properties.slice(f)),d.isComplex()&&(k=new D(a.scope.freeVariable("ref")),d=new K(new e(k,d)),o.base=k),new u(new m(d),o,{soak:!0});return!1}}(this)()},b}(f),c.Comment=l=function(a){function b(a){this.comment=a}return va(b,a),b.prototype.isStatement=_,b.prototype.makeReturn=V,b.prototype.compileNode=function(a,b){var c,d;return d=this.comment.replace(/^(\s*)#(?=\s)/gm,"$1 *"),c="/*"+ma(d,this.tab)+(xa.call(d,"\n")>=0?"\n"+this.tab:"")+" */",(b||a.level)===C&&(c=a.indent+c),[this.makeCode("\n"),this.makeCode(c)]},b}(f),c.Call=h=function(a){function c(a,b,c){this.args=null!=b?b:[],this.soak=c,this.isNew=!1,this.isSuper="super"===a,this.variable=this.isSuper?null:a,a instanceof Z&&a.isNotCallable()&&a.error("literal is not a function")}return va(c,a),c.prototype.children=["variable","args"],c.prototype.newInstance=function(){var a,b;return a=(null!=(b=this.variable)?b.base:void 0)||this.variable,a instanceof c&&!a.isNew?a.newInstance():this.isNew=!0,this},c.prototype.superReference=function(a){var c,d,f,g,h,i,j,k;return h=a.scope.namedMethod(),(null!=h?h.klass:void 0)?(g=h.klass,i=h.name,k=h.variable,g.isComplex()&&(f=new D(a.scope.parent.freeVariable("base")),d=new Z(new K(new e(f,g))),k.base=d,k.properties.splice(0,g.properties.length)),(i.isComplex()||i instanceof w&&i.index.isAssignable())&&(j=new D(a.scope.parent.freeVariable("name")),i=new w(new e(j,i.index)),k.properties.pop(),k.properties.push(i)),c=[new b(new D("__super__"))],h["static"]&&c.push(new b(new D("constructor"))),c.push(null!=j?new w(j):i),new Z(null!=f?f:g,c).compile(a)):(null!=h?h.ctor:void 0)?h.name+".__super__.constructor":this.error("cannot call super outside of an instance method.")},c.prototype.superThis=function(a){var b;return b=a.scope.method,b&&!b.klass&&b.context||"this"},c.prototype.unfoldSoak=function(a){var b,d,e,f,g,h,i,j,k;if(this.soak){if(this.variable){if(d=ta(a,this,"variable"))return d;i=new Z(this.variable).cacheReference(a),f=i[0],k=i[1]}else f=new D(this.superReference(a)),k=new Z(f);return k=new c(k,this.args),k.isNew=this.isNew,f=new D("typeof "+f.compile(a)+' === "function"'),new u(f,new Z(k),{soak:!0})}for(b=this,h=[];;)if(b.variable instanceof c)h.push(b),b=b.variable;else{if(!(b.variable instanceof Z))break;if(h.push(b),!((b=b.variable.base)instanceof c))break}for(j=h.reverse(),e=0,g=j.length;g>e;e++)b=j[e],d&&(b.variable instanceof c?b.variable=d:b.variable.base=d),d=ta(a,b,"variable");return d},c.prototype.compileNode=function(a){var b,c,d,e,f,g,h,i,j,k;if(null!=(j=this.variable)&&(j.front=this.front),e=S.compileSplattedArray(a,this.args,!0),e.length)return this.compileSplat(a,e);for(d=[],k=this.args,c=g=0,h=k.length;h>g;c=++g)b=k[c],c&&d.push(this.makeCode(", ")),d.push.apply(d,b.compileToFragments(a,z));return f=[],this.isSuper?(i=this.superReference(a)+(".call("+this.superThis(a)),d.length&&(i+=", "),f.push(this.makeCode(i))):(this.isNew&&f.push(this.makeCode("new ")),f.push.apply(f,this.variable.compileToFragments(a,x)),f.push(this.makeCode("("))),f.push.apply(f,d),f.push(this.makeCode(")")),f},c.prototype.compileSplat=function(a,b){var c,d,e,f,g,h;return this.isSuper?[].concat(this.makeCode(this.superReference(a)+".apply("+this.superThis(a)+", "),b,this.makeCode(")")):this.isNew?(f=this.tab+U,[].concat(this.makeCode("(function(func, args, ctor) {\n"+f+"ctor.prototype = func.prototype;\n"+f+"var child = new ctor, result = func.apply(child, args);\n"+f+"return Object(result) === result ? result : child;\n"+this.tab+"})("),this.variable.compileToFragments(a,z),this.makeCode(", "),b,this.makeCode(", function(){})"))):(c=[],d=new Z(this.variable),(g=d.properties.pop())&&d.isComplex()?(h=a.scope.freeVariable("ref"),c=c.concat(this.makeCode("("+h+" = "),d.compileToFragments(a,z),this.makeCode(")"),g.compileToFragments(a))):(e=d.compileToFragments(a,x),O.test(ga(e))&&(e=this.wrapInBraces(e)),g?(h=ga(e),e.push.apply(e,g.compileToFragments(a))):h="null",c=c.concat(e)),c=c.concat(this.makeCode(".apply("+h+", "),b,this.makeCode(")")))},c}(f),c.Extends=o=function(a){function b(a,b){this.child=a,this.parent=b}return va(b,a),b.prototype.children=["child","parent"],b.prototype.compileToFragments=function(a){return new h(new Z(new D(ua("extend",a))),[this.child,this.parent]).compileToFragments(a)},b}(f),c.Access=b=function(a){function b(a,b){this.name=a,this.name.asKey=!0,this.soak="soak"===b}return va(b,a),b.prototype.children=["name"],b.prototype.compileToFragments=function(a){var b;return b=this.name.compileToFragments(a),r.test(ga(b))?b.unshift(this.makeCode(".")):(b.unshift(this.makeCode("[")),b.push(this.makeCode("]"))),b},b.prototype.isComplex=F,b}(f),c.Index=w=function(a){function b(a){this.index=a}return va(b,a),b.prototype.children=["index"],b.prototype.compileToFragments=function(a){return[].concat(this.makeCode("["),this.index.compileToFragments(a,B),this.makeCode("]"))},b.prototype.isComplex=function(){return this.index.isComplex()},b}(f),c.Range=M=function(a){function b(a,b,c){this.from=a,this.to=b,this.exclusive="exclusive"===c,this.equals=this.exclusive?"":"="}return va(b,a),b.prototype.children=["from","to"],b.prototype.compileVariables=function(a){var b,c,d,e,f,g;return a=la(a,{top:!0}),b=ca(a,"isComplex"),c=this.cacheToCodeFragments(this.from.cache(a,z,b)),this.fromC=c[0],this.fromVar=c[1],d=this.cacheToCodeFragments(this.to.cache(a,z,b)),this.toC=d[0],this.toVar=d[1],(g=ca(a,"step"))&&(e=this.cacheToCodeFragments(g.cache(a,z,b)),this.step=e[0],this.stepVar=e[1]),f=[this.fromVar.match(G),this.toVar.match(G)],this.fromNum=f[0],this.toNum=f[1],this.stepVar?this.stepNum=this.stepVar.match(G):void 0},b.prototype.compileNode=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o;return this.fromVar||this.compileVariables(a),a.index?(h=this.fromNum&&this.toNum,f=ca(a,"index"),g=ca(a,"name"),j=g&&g!==f,o=f+" = "+this.fromC,this.toC!==this.toVar&&(o+=", "+this.toC),this.step!==this.stepVar&&(o+=", "+this.step),k=[f+" <"+this.equals,f+" >"+this.equals],i=k[0],e=k[1],c=this.stepNum?na(this.stepNum[0])>0?i+" "+this.toVar:e+" "+this.toVar:h?(l=[na(this.fromNum[0]),na(this.toNum[0])],d=l[0],n=l[1],l,n>=d?i+" "+n:e+" "+n):(b=this.stepVar?this.stepVar+" > 0":this.fromVar+" <= "+this.toVar,b+" ? "+i+" "+this.toVar+" : "+e+" "+this.toVar),m=this.stepVar?f+" += "+this.stepVar:h?j?n>=d?"++"+f:"--"+f:n>=d?f+"++":f+"--":j?b+" ? ++"+f+" : --"+f:b+" ? "+f+"++ : "+f+"--",j&&(o=g+" = "+o),j&&(m=g+" = "+m),[this.makeCode(o+"; "+c+"; "+m)]):this.compileArray(a)},b.prototype.compileArray=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n;return this.fromNum&&this.toNum&&Math.abs(this.fromNum-this.toNum)<=20?(j=function(){m=[];for(var a=k=+this.fromNum,b=+this.toNum;b>=k?b>=a:a>=b;b>=k?a++:a--)m.push(a);return m}.apply(this),this.exclusive&&j.pop(),[this.makeCode("["+j.join(", ")+"]")]):(g=this.tab+U,f=a.scope.freeVariable("i",{single:!0}),l=a.scope.freeVariable("results"),i="\n"+g+l+" = [];",this.fromNum&&this.toNum?(a.index=f,c=ga(this.compileNode(a))):(n=f+" = "+this.fromC+(this.toC!==this.toVar?", "+this.toC:""),d=this.fromVar+" <= "+this.toVar,c="var "+n+"; "+d+" ? "+f+" <"+this.equals+" "+this.toVar+" : "+f+" >"+this.equals+" "+this.toVar+"; "+d+" ? "+f+"++ : "+f+"--"),h="{ "+l+".push("+f+"); }\n"+g+"return "+l+";\n"+a.indent,e=function(a){return null!=a?a.contains(ia):void 0},(e(this.from)||e(this.to))&&(b=", arguments"),[this.makeCode("(function() {"+i+"\n"+g+"for ("+c+")"+h+"}).apply(this"+(null!=b?b:"")+")")])},b}(f),c.Slice=R=function(a){function b(a){this.range=a,b.__super__.constructor.call(this)}return va(b,a),b.prototype.children=["range"],b.prototype.compileNode=function(a){var b,c,d,e,f,g,h;return f=this.range,g=f.to,d=f.from,e=d&&d.compileToFragments(a,B)||[this.makeCode("0")],g&&(b=g.compileToFragments(a,B),c=ga(b),(this.range.exclusive||-1!==+c)&&(h=", "+(this.range.exclusive?c:O.test(c)?""+(+c+1):(b=g.compileToFragments(a,x),"+"+ga(b)+" + 1 || 9e9")))),[this.makeCode(".slice("+ga(e)+(h||"")+")")]},b}(f),c.Obj=H=function(a){function c(a,b){this.generated=null!=b?b:!1,this.objects=this.properties=a||[]}return va(c,a),c.prototype.children=["properties"],c.prototype.compileNode=function(a){var c,d,f,g,h,i,j,k,m,n,o,p,q,r,s,t,u,v,w,x,y;if(w=this.properties,this.generated)for(j=0,q=w.length;q>j;j++)t=w[j],t instanceof Z&&t.error("cannot have an implicit value in an implicit object");for(d=m=0,r=w.length;r>m&&(v=w[d],!((v.variable||v).base instanceof K));d=++m);for(f=d<w.length,h=a.indent+=U,p=this.lastNonComment(this.properties),c=[],f&&(u=a.scope.freeVariable("obj"),c.push(this.makeCode("(\n"+h+u+" = "))),c.push(this.makeCode("{"+(0===w.length||0===d?"}":"\n"))),g=o=0,s=w.length;s>o;g=++o)v=w[g],g===d&&(0!==g&&c.push(this.makeCode("\n"+h+"}")),c.push(this.makeCode(",\n"))),k=g===w.length-1||g===d-1?"":v===p||v instanceof l?"\n":",\n",i=v instanceof l?"":h,f&&d>g&&(i+=U),v instanceof e&&("object"!==v.context&&v.operatorToken.error("unexpected "+v.operatorToken.value),v.variable instanceof Z&&v.variable.hasProperties()&&v.variable.error("invalid object key")),v instanceof Z&&v["this"]&&(v=new e(v.properties[0].name,v,"object")),v instanceof l||(d>g?(v instanceof e||(v=new e(v,v,"object")),(v.variable.base||v.variable).asKey=!0):(v instanceof e?(n=v.variable,y=v.value):(x=v.base.cache(a),n=x[0],y=x[1]),v=new e(new Z(new D(u),[new b(n)]),y))),i&&c.push(this.makeCode(i)),c.push.apply(c,v.compileToFragments(a,C)),k&&c.push(this.makeCode(k));return f?c.push(this.makeCode(",\n"+h+u+"\n"+this.tab+")")):0!==w.length&&c.push(this.makeCode("\n"+this.tab+"}")),this.front&&!f?this.wrapInBraces(c):c},c.prototype.assigns=function(a){var b,c,d,e;for(e=this.properties,b=0,c=e.length;c>b;b++)if(d=e[b],d.assigns(a))return!0;return!1},c}(f),c.Arr=d=function(a){function b(a){this.objects=a||[]}return va(b,a),b.prototype.children=["objects"],b.prototype.compileNode=function(a){var b,c,d,e,f,g,h;if(!this.objects.length)return[this.makeCode("[]")];if(a.indent+=U,b=S.compileSplattedArray(a,this.objects),b.length)return b;for(b=[],c=function(){var b,c,d,e;for(d=this.objects,e=[],b=0,c=d.length;c>b;b++)h=d[b],e.push(h.compileToFragments(a,z));return e}.call(this),e=f=0,g=c.length;g>f;e=++f)d=c[e],e&&b.push(this.makeCode(", ")),b.push.apply(b,d);return ga(b).indexOf("\n")>=0?(b.unshift(this.makeCode("[\n"+a.indent)),b.push(this.makeCode("\n"+this.tab+"]"))):(b.unshift(this.makeCode("[")),b.push(this.makeCode("]"))),b},b.prototype.assigns=function(a){var b,c,d,e;fo