wisp
Version:
Homoiconic JS with clojure syntax, s-expressions & macros
1 lines • 195 kB
JavaScript
require=function o(a,s,c){function u(t,e){if(!s[t]){if(!a[t]){var n="function"==typeof require&&require;if(!e&&n)return n(t,!0);if(l)return l(t,!0);var r=new Error("Cannot find module '"+t+"'");throw r.code="MODULE_NOT_FOUND",r}var i=s[t]={exports:{}};a[t][0].call(i.exports,function(e){return u(a[t][1][e]||e)},i,i.exports,o,a,s,c)}return s[t].exports}for(var l="function"==typeof require&&require,e=0;e<c.length;e++)u(c[e]);return u}({1:[function(require,module,exports){var _ns_={id:"wisp.backend.escodegen.generator",doc:void 0},wisp_reader=require("./../../reader"),readString=wisp_reader.readFromString,read_=wisp_reader.read_,wisp_ast=require("./../../ast"),meta=wisp_ast.meta,withMeta=wisp_ast.withMeta,isSymbol=wisp_ast.isSymbol,symbol=wisp_ast.symbol,isKeyword=wisp_ast.isKeyword,keyword=wisp_ast.keyword,namespace=wisp_ast.namespace,isUnquote=wisp_ast.isUnquote,isUnquoteSplicing=wisp_ast.isUnquoteSplicing,isQuote=wisp_ast.isQuote,isSyntaxQuote=wisp_ast.isSyntaxQuote,name=wisp_ast.name,gensym=wisp_ast.gensym,prStr=wisp_ast.prStr,wisp_sequence=require("./../../sequence"),isEmpty=wisp_sequence.isEmpty,count=wisp_sequence.count,isList=wisp_sequence.isList,list=wisp_sequence.list,first=wisp_sequence.first,second=wisp_sequence.second,third=wisp_sequence.third,rest=wisp_sequence.rest,cons=wisp_sequence.cons,conj=wisp_sequence.conj,butlast=wisp_sequence.butlast,reverse=wisp_sequence.reverse,reduce=wisp_sequence.reduce,vec=wisp_sequence.vec,last=wisp_sequence.last,map=wisp_sequence.map,filter=wisp_sequence.filter,take=wisp_sequence.take,concat=wisp_sequence.concat,partition=wisp_sequence.partition,repeat=wisp_sequence.repeat,interleave=wisp_sequence.interleave,wisp_runtime=require("./../../runtime"),isOdd=wisp_runtime.isOdd,isDictionary=wisp_runtime.isDictionary,dictionary=wisp_runtime.dictionary,merge=wisp_runtime.merge,keys=wisp_runtime.keys,vals=wisp_runtime.vals,isContainsVector=wisp_runtime.isContainsVector,mapDictionary=wisp_runtime.mapDictionary,isString=wisp_runtime.isString,isNumber=wisp_runtime.isNumber,isVector=wisp_runtime.isVector,isBoolean=wisp_runtime.isBoolean,subs=wisp_runtime.subs,reFind=wisp_runtime.reFind,isTrue=wisp_runtime.isTrue,isFalse=wisp_runtime.isFalse,isNil=wisp_runtime.isNil,isRePattern=wisp_runtime.isRePattern,inc=wisp_runtime.inc,dec=wisp_runtime.dec,str=wisp_runtime.str,char=wisp_runtime.char,int=wisp_runtime.int,isEqual=wisp_runtime.isEqual,isStrictEqual=wisp_runtime.isStrictEqual,wisp_string=require("./../../string"),split=wisp_string.split,join=wisp_string.join,upperCase=wisp_string.upperCase,replace=wisp_string.replace,wisp_expander=require("./../../expander"),installMacro=wisp_expander.installMacro,wisp_analyzer=require("./../../analyzer"),emptyEnv=wisp_analyzer.emptyEnv,analyze=wisp_analyzer.analyze,analyze_=wisp_analyzer.analyze_,wisp_backend_escodegen_writer=require("./writer"),write=wisp_backend_escodegen_writer.write,compile=wisp_backend_escodegen_writer.compile,write_=wisp_backend_escodegen_writer.write_,escodegen=require("escodegen"),generate_=escodegen.generate,base64Encode=require("base64-encode"),btoa=base64Encode,fs=require("fs"),readFileSync=fs.readFileSync,writeFileSync=fs.writeFileSync,path=require("path"),basename=path.basename,dirname=path.dirname,joinPath=path.join,generate=exports.generate=function(n){var r=Array.prototype.slice.call(arguments,1);return function(){var e=write_.apply(void 0,r),t=generate_(e,{file:(n||0)["output-uri"],sourceContent:(n||0).source,sourceMap:(n||0)["source-uri"],sourceMapRoot:(n||0)["source-root"],sourceMapWithCode:!0});return(t||0).map.setSourceContent((n||0)["source-uri"],(n||0).source),{code:(n||0)["no-map"]?(t||0).code:(t||0).code+"\n//# sourceMappingURL=data:application/json;base64,"+btoa(""+(t||0).map)+"\n","source-map":(t||0).map,"js-ast":e}}.call(this)},expandDefmacro=exports.expandDefmacro=function expandDefmacro(_andForm,id){var body=Array.prototype.slice.call(arguments,2);return function(){var fnø1=withMeta(list.apply(void 0,[symbol(void 0,"defn")].concat([id],vec(body))),meta(_andForm)),formø1=list.apply(void 0,[symbol(void 0,"do")].concat([fnø1],[id])),astø1=analyze(formø1),codeø1=compile(astø1),macroø1=eval(codeø1);installMacro(id,macroø1)}.call(this)};installMacro(symbol(void 0,"defmacro"),withMeta(expandDefmacro,{implicit:["&form"]}))},{"./../../analyzer":"wisp/analyzer","./../../ast":"wisp/ast","./../../expander":"wisp/expander","./../../reader":"wisp/reader","./../../runtime":"wisp/runtime","./../../sequence":"wisp/sequence","./../../string":"wisp/string","./writer":2,"base64-encode":5,escodegen:9,fs:7,path:16}],2:[function(e,t,n){e("./../../reader").readFromString;var r=e("./../../ast"),a=r.meta,u=r.withMeta,l=(r.isSymbol,r.symbol),i=r.isKeyword,o=r.keyword,c=r.namespace,p=(r.isUnquote,r.isUnquoteSplicing,r.isQuote,r.isSyntaxQuote,r.name),s=(r.gensym,r.prStr),f=e("./../../sequence"),d=f.isEmpty,h=f.count,v=f.isList,m=f.list,y=f.first,g=f.second,w=(f.third,f.rest),b=f.cons,S=f.conj,_=f.butlast,x=(f.reverse,f.reduce),E=f.vec,C=f.last,A=f.map,q=f.mapv,k=(f.filter,f.take,f.concat),I=f.partition,L=f.repeat,M=f.interleave,R=f.assoc,O=e("./../../runtime"),j=(O.isOdd,O.isDictionary,O.dictionary,O.merge,O.keys,O.vals,O.isContainsVector,O.mapDictionary,O.isString),B=O.isNumber,T=O.isVector,D=(O.isBoolean,O.subs),P=(O.reFind,O.isTrue,O.isFalse,O.isNil),F=(O.isRePattern,O.inc),z=O.dec,N=(O.str,O.char,O.int,O.isEqual),U=(O.isStrictEqual,O.get),W=e("./../../string"),V=W.split,$=W.join,G=W.upperCase,Q=(W.replace,W.triml),K=e("./../../expander").installMacro,H=e("escodegen").generate,Y=n.__uniqueChar__="ø",J=n.toCamelJoin=function(e,t){return""+e+(d(e)||d(t)?t:""+G((t||0)[0])+D(t,1))},X=n.toPrivatePrefix=function(r){return function(){var e=$(" ",V(r,/-/)),t=Q(e),n=h(r)-h(t);return 0<n?""+$("_",L(F(n),""))+D(r,n):r}.call(this)},Z=n.translateIdentifierWord=function(e){var t=p(e);return t=$("_",V(t="*"===t?"multiply":"/"===t?"divide":"+"===t?"sum":"-"===t?"subtract":"="===t?"equal?":"=="===t?"strict-equal?":"<="===t?"not-greater-than":">="===t?"not-less-than":">"===t?"greater-than":"<"===t?"less-than":"->"===t?"thread-first":t,"*")),t=$("_",V(t,".")),t="->"===D(t,0,2)?D($("-to-",V(t,"->")),1):$("-to-",V(t,"->")),t=$(V(t,"!")),t=$("$",V(t,"%")),t=$("-equal-",V(t,"=")),t=$("-plus-",V(t,"+")),t=$("-and-",V(t,"&")),t="?"===C(t)?"is-"+D(t,0,z(h(t))):t,t=X(t),t=x(J,"",V(t,"-"))},ee=n.translateIdentifier=function(t){return function(){var e=c(t);return(e&&!N(e,"js")?Z(c(t))+".":"")+$(".",A(Z,V(p(t),".")))}.call(this)},te=n.errorArgCount=function(e,t){return function(){throw SyntaxError("Wrong number of arguments ("+t+") passed to: "+e)}()},ne=n.inheritLocation=function(n){return function(){var e=((y(n)||0).loc||0).start,t=((C(n)||0).loc||0).end;return P(e)||P(t)?void 0:{start:e,end:t}}.call(this)},re=n.writeLocation=function(i,o){return function(){var e=a(i),t=a(o),n=(i||0).start||(e||0).start||(t||0).start,r=(i||0).end||(e||0).end||(t||0).end;return P(n)?{}:{loc:{start:{line:F(U.apply(void 0,[n,"line",-1])),column:U.apply(void 0,[n,"column",-1])},end:{line:F(U.apply(void 0,[r,"line",-1])),column:U.apply(void 0,[r,"column",-1])}}}}.call(this)},ie=n.__writers__={},oe=n.installWriter=function(e,t){return ie[e]=t},ae=n.writeOp=function(t,n){return function(){var e=ie[t];return e||function(){throw Error("Assert failed: Unsupported operation: "+t+"writer")}(),S(re((n||0).form,(n||0)["original-form"]),e(n))}.call(this)},se=n.__specials__={},ce=n.installSpecial=function(e,t){return se[p(e)]=t},ue=n.writeSpecial=function(e,t){return S(re((t||0).form,(t||0)["original-form"]),e.apply(void 0,(t||0).params))},le=n.writeNil=function(){return{type:"UnaryExpression",operator:"void",argument:{type:"Literal",value:0},prefix:!0}};oe("nil",le);var pe=n.writeLiteral=function(e){return{type:"Literal",value:e}};oe("list",n.writeList=function(e){return{type:"CallExpression",callee:We({op:"var",form:l(void 0,"list")}),arguments:A(We,(e||0).items)}}),oe("symbol",n.writeSymbol=function(e){return{type:"CallExpression",callee:We({op:"var",form:l(void 0,"symbol")}),arguments:[fe((e||0).namespace),fe((e||0).name)]}});var fe=n.writeConstant=function(e){return P(e)?le(e):i(e)?pe(c(e)?c(e)+"/"+p(e):p(e)):B(e)?he(e.valueOf()):j(e)?de(e):pe(e)};oe("constant",function(e){return fe((e||0).form)});var de=n.writeString=function(e){return{type:"Literal",value:""+e}},he=n.writeNumber=function e(t){return t<0?{type:"UnaryExpression",operator:"-",prefix:!0,argument:e(-1*t)}:pe(t)};oe("keyword",n.writeKeyword=function(e){return{type:"Literal",value:(e||0).form}});var ve=n.toIdentifier=function(e){return{type:"Identifier",name:ee(e)}},me=n.writeBindingVar=function(n){return function(){var e=(n||0).id,t=(n||0).shadow?l(void 0,ee(e)+Y+(n||0).depth):e;return S(ve(t),re(e))}.call(this)},ye=n.writeVar=function(e){return N("binding",((e||0).binding||0).type)?S(me((e||0).binding),re((e||0).form)):S(re((e||0).form),ve((e||0).form))};oe("var",ye),oe("param",ye),oe("invoke",n.writeInvoke=function(e){return{type:"CallExpression",callee:We((e||0).callee),arguments:A(We,(e||0).params)}}),oe("vector",n.writeVector=function(e){return{type:"ArrayExpression",elements:A(We,(e||0).items)}}),oe("dictionary",n.writeDictionary=function(t){return function(){var e=I(2,M((t||0).keys,(t||0).values));return{type:"ObjectExpression",properties:A(function(n){return function(){var e=y(n),t=g(n);return{kind:"init",type:"Property",key:N("symbol",(e||0).op)?fe(""+(e||0).form):We(e),value:We(t)}}.call(this)},e)}}.call(this)});var ge=n.writeExport=function(e){return We({op:"set!",target:{op:"member-expression",computed:!1,target:{op:"var",form:u(l(void 0,"exports"),a(((e||0).id||0).form))},property:(e||0).id,form:((e||0).id||0).form},value:(e||0).init,form:((e||0).id||0).form})};oe("def",n.writeDef=function(e){return S({type:"VariableDeclaration",kind:"var",declarations:[S({type:"VariableDeclarator",id:We((e||0).id),init:S((e||0).export?ge(e):We((e||0).init))},re(((e||0).id||0).form))]},re((e||0).form,(e||0)["original-form"]))}),oe("binding",n.writeBinding=function(n){return function(){var e=me(n),t=We((n||0).init);return{type:"VariableDeclaration",kind:"var",loc:ne([e,t]),declarations:[{type:"VariableDeclarator",id:e,init:t}]}}.call(this)}),oe("throw",n.writeThrow=function(e){return Ce(S({type:"ThrowStatement",argument:We((e||0).throw)},re((e||0).form,(e||0)["original-form"])))}),oe("new",n.writeNew=function(e){return{type:"NewExpression",callee:We((e||0).constructor),arguments:A(We,(e||0).params)}}),oe("set!",n.writeSet=function(e){return{type:"AssignmentExpression",operator:"=",left:We((e||0).target),right:We((e||0).value)}}),oe("member-expression",n.writeAget=function(e){return{type:"MemberExpression",computed:(e||0).computed,object:We((e||0).target),property:We((e||0).property)}});var we=n.__statements__={EmptyStatement:!0,BlockStatement:!0,ExpressionStatement:!0,IfStatement:!0,LabeledStatement:!0,BreakStatement:!0,ContinueStatement:!0,SwitchStatement:!0,ReturnStatement:!0,ThrowStatement:!0,TryStatement:!0,WhileStatement:!0,DoWhileStatement:!0,ForStatement:!0,ForInStatement:!0,ForOfStatement:!0,LetStatement:!0,VariableDeclaration:!0,FunctionDeclaration:!0},be=n.writeStatement=function(e){return Se(We(e))},Se=n.toStatement=function(e){return we[(e||0).type]?e:{type:"ExpressionStatement",expression:e,loc:(e||0).loc}},_e=n.toReturn=function(e){return S({type:"ReturnStatement",argument:We(e)},re((e||0).form,(e||0)["original-form"]))},xe=n.writeBody=function(n){return function(){var e=A(be,(n||0).statements||[]),t=(n||0).result?_e((n||0).result):void 0;return t?S(e,t):e}.call(this)},Ee=n.toBlock=function(e){return T(e)?{type:"BlockStatement",body:e,loc:ne(e)}:{type:"BlockStatement",body:[e],loc:(e||0).loc}},Ce=n.toExpression=function(){var e=Array.prototype.slice.call(arguments,0);return{type:"CallExpression",arguments:[],loc:ne(e),callee:qe([{type:"FunctionExpression",id:void 0,params:[],defaults:[],expression:!1,generator:!1,rest:void 0,body:Ee(e)}])}};oe("do",n.writeDo=function(e){return(a(y((e||0).form))||0).block?Ee(xe(S(e,{result:void 0,statements:S((e||0).statements,(e||0).result)}))):Ce.apply(void 0,xe(e))}),oe("if",n.writeIf=function(e){return{type:"ConditionalExpression",test:We((e||0).test),consequent:We((e||0).consequent),alternate:We((e||0).alternate)}}),oe("try",n.writeTry=function(n){return function(){var e=(n||0).handler,t=(n||0).finalizer;return Ce(S({type:"TryStatement",guardedHandlers:[],block:Ee(xe((n||0).body)),handlers:e?[{type:"CatchClause",param:We((e||0).name),body:Ee(xe(e))}]:[],finalizer:t?Ee(xe(t)):e?void 0:Ee([])},re((n||0).form,(n||0)["original-form"])))}.call(this)});n.writeBinding=function(e){return We({op:"def",var:e,init:(e||0).init,form:e})};oe("let",n.writeLet=function(t){return function(){var e=S(t,{statements:E(k((t||0).bindings,(t||0).statements))});return ke(Ee(xe(e)))}.call(this)});var Ae=n.toRebind=function(i){return function e(){for(var t=e,n=[],r=(i||0).bindings;t=d(r)?n:(e[0]=S(n,{type:"AssignmentExpression",operator:"=",left:me(y(r)),right:{type:"MemberExpression",computed:!0,object:{type:"Identifier",name:"loop"},property:{type:"Literal",value:h(n)}}}),e[1]=w(r),e),n=e[0],r=e[1],t===e;);return t}.call(this)},qe=n.toSequence=function(e){return{type:"SequenceExpression",expressions:e}},ke=n.toIife=function(e,t){return{type:"CallExpression",arguments:[{type:"ThisExpression"}],callee:{type:"MemberExpression",computed:!1,object:{type:"FunctionExpression",id:t,params:[],defaults:[],expression:!1,generator:!1,rest:void 0,body:e},property:{type:"Identifier",name:"call"}}}},Ie=n.toLoopInit=function(){return{type:"VariableDeclaration",kind:"var",declarations:[{type:"VariableDeclarator",id:{type:"Identifier",name:"recur"},init:{type:"Identifier",name:"loop"}}]}},Le=n.toDoWhile=function(e,t){return{type:"DoWhileStatement",body:e,test:t}},Me=n.toSetRecur=function(e){return{type:"AssignmentExpression",operator:"=",left:{type:"Identifier",name:"recur"},right:We(e)}},Re=n.toLoop=function(e){return qe(S(Ae(e),{type:"BinaryExpression",operator:"===",left:{type:"Identifier",name:"recur"},right:{type:"Identifier",name:"loop"}}))};oe("loop",n.writeLoop=function(i){return function(){var e=(i||0).result,t=(i||0).bindings,n=S(A(be,(i||0).statements),Se(Me(e))),r=k([Ie()],A(We,t),[Le(Ee(E(n)),Re(i))],[{type:"ReturnStatement",argument:{type:"Identifier",name:"recur"}}]);return ke(Ee(E(r)),l(void 0,"loop"))}.call(this)});var Oe=n.toRecur=function(i){return function e(){for(var t=e,n=[],r=(i||0).params;t=d(r)?n:(e[0]=S(n,{type:"AssignmentExpression",operator:"=",right:We(y(r)),left:{type:"MemberExpression",computed:!0,object:{type:"Identifier",name:"loop"},property:{type:"Literal",value:h(n)}}}),e[1]=w(r),e),n=e[0],r=e[1],t===e;);return t}.call(this)};oe("recur",n.writeRecur=function(e){return qe(S(Oe(e),{type:"Identifier",name:"loop"}))});var je=n.fallbackOverload=function(){return{type:"SwitchCase",test:void 0,consequent:[{type:"ThrowStatement",argument:{type:"CallExpression",callee:{type:"Identifier",name:"RangeError"},arguments:[{type:"Literal",value:"Wrong number of arguments passed"}]}}]}},Be=n.spliceBinding=function(e){return{op:"def",id:C((e||0).params),init:{op:"invoke",callee:{op:"var",form:l(void 0,"Array.prototype.slice.call")},params:[{op:"var",form:l(void 0,"arguments")},{op:"constant",form:(e||0).arity,type:"number"}]}}},Te=n.writeOverloadingParams=function(e){return x(function(e,t){return S(e,{op:"def",id:t,init:{op:"member-expression",computed:!0,target:{op:"var",form:l(void 0,"arguments")},property:{op:"constant",type:"number",form:h(e)}}})},[],e)},De=n.writeOverloadingFn=function(t){return function(){var e=A(Pe,(t||0).methods);return{params:[],body:Ee({type:"SwitchStatement",discriminant:{type:"MemberExpression",computed:!1,object:{type:"Identifier",name:"arguments"},property:{type:"Identifier",name:"length"}},cases:(t||0).variadic?e:S(e,je())})}}.call(this)},Pe=n.writeFnOverload=function(r){return function(){var e=(r||0).params,t=(r||0).variadic?S(Te(_(e)),Be(r)):Te(e),n=E(k(t,(r||0).statements));return{type:"SwitchCase",test:(r||0).variadic?void 0:{type:"Literal",value:(r||0).arity},consequent:xe(S(r,{statements:n}))}}.call(this)},Fe=n.writeSimpleFn=function(r){return function(){var e=y((r||0).methods),t=(e||0).variadic?_((e||0).params):(e||0).params,n=(e||0).variadic?S(e,{statements:E(b(Be(e),(e||0).statements))}):e;return{params:A(ye,t),body:Ee(xe(n))}}.call(this)},ze=n.resolve=function(e,t){return function(){var i=V(p(e),"."),o=V(p(t),".");return!(p(e)===p(t))&&y(i)===y(o)?function e(){for(var t=e,n=i,r=o;t=y(n)===y(r)?(e[0]=w(n),e[1]=w(r),e):$("/",k(["."],L(z(h(n)),".."),r)),n=e[0],r=e[1],t===e;);return t}.call(this):$("/",o)}.call(this)},Ne=n.idToNs=function(e){return l(void 0,$("*",V(p(e),".")))},Ue=n.writeRequire=function(r,i){return function(){var n={op:"def",id:{op:"var",type:"identifier",form:Ne((r||0).ns)},init:{op:"invoke",callee:{op:"var",type:"identifier",form:l(void 0,"require")},params:[{op:"constant",form:ze(i,(r||0).ns)}]}},e=(r||0).alias?{op:"def",id:{op:"var",type:"identifier",form:Ne((r||0).alias)},init:n.id}:void 0,t=x(function(e,t){return S(e,{op:"def",id:{op:"var",type:"identifier",form:(t||0).rename||(t||0).name},init:{op:"member-expression",computed:!1,target:n.id,property:{op:"var",type:"identifier",form:(t||0).name}}})},[],(r||0).refer);return E(b(n,e?b(e,t):t))}.call(this)};oe("ns",n.writeNs=function(i){return function(){var e=(i||0).form,t=(i||0).name,n={op:"def","original-form":e,id:{op:"var",type:"identifier","original-form":y(e),form:l(void 0,"*ns*")},init:{op:"dictionary",form:e,keys:[{op:"var",type:"identifier","original-form":e,form:l(void 0,"id")},{op:"var",type:"identifier","original-form":e,form:l(void 0,"doc")}],values:[{op:"constant",type:"identifier","original-form":(i||0).name,form:p((i||0).name)},{op:"constant","original-form":e,form:(i||0).doc}]}},r=E(k.apply(void 0,A(function(e){return Ue(e,t)},(i||0).require)));return Ee(A(We,E(b(n,r))))}.call(this)}),oe("fn",n.writeFn=function(t){return function(){var e=1<h((t||0).methods)?De(t):Fe(t);return S(e,{type:"FunctionExpression",id:(t||0).id?ye((t||0).id):void 0,defaults:void 0,rest:void 0,generator:!1,expression:!1})}.call(this)});var We=n.write=function(t){return function(){var e=N("invoke",(t||0).op)&&N("var",((t||0).callee||0).op)&&se[p(((t||0).callee||0).form)];return e?ue(e,t):ae((t||0).op,t)}.call(this)},Ve=n.write_=function(){var t=Array.prototype.slice.call(arguments,0);return function(){var e=A(be,t);return{type:"Program",body:e,loc:ne(e)}}.call(this)};n.compile=function e(t){switch(arguments.length){case 1:return e({},t);default:var n=t,r=Array.prototype.slice.call(arguments,1);return H(Ve.apply(void 0,r),n)}};K("get",n.getMacro=function(e,t,n){switch(arguments.length){case 2:var r=e,i=t;return m.apply(void 0,[l(void 0,"aget")].concat([m.apply(void 0,[l(void 0,"or")].concat([r],[0]))],[i]));case 3:r=e,i=t;var o=n;return void 0===o?m.apply(void 0,[l(void 0,"get")].concat([r],[i])):m.apply(void 0,[l(void 0,"apply")].concat([l(void 0,"get")],[[r,i,o]]));default:throw RangeError("Wrong number of arguments passed")}});var $e=n.installLogicalOperator=function(e,n,r){return ce(e,function(){var t=Array.prototype.slice.call(arguments,0);return function(){var e=h(t);return N(e,0)?fe(r):N(e,1)?We(y(t)):x(function(e,t){return{type:"LogicalExpression",operator:n,left:e,right:We(t)}},We(y(t)),w(t))}.call(this)})};$e("or","||",void 0),$e("and","&&",!0);var Ge=n.installUnaryOperator=function(t,n,r){return ce(t,function(){var e=Array.prototype.slice.call(arguments,0);return 1===h(e)?{type:"UnaryExpression",operator:n,argument:We(y(e)),prefix:r}:te(t,h(e))})};Ge("not","!"),Ge("bit-not","~");var Qe=n.installBinaryOperator=function(t,n){return ce(t,function(){var e=Array.prototype.slice.call(arguments,0);return h(e)<2?te(t,h(e)):x(function(e,t){return{type:"BinaryExpression",operator:n,left:e,right:We(t)}},We(y(e)),w(e))})};Qe("bit-and","&"),Qe("bit-or","|"),Qe("bit-xor","^"),Qe("bit-shift-left","<<"),Qe("bit-shift-right",">>"),Qe("bit-shift-right-zero-fil",">>>");var Ke=n.installArithmeticOperator=function(n,r,i,o){function a(e,t){return{type:"BinaryExpression",operator:p(r),left:e,right:We(t)}}return ce(n,function(){var t=Array.prototype.slice.call(arguments,0);return function(){var e=h(t);return i&&!i(e)?te(p(n),e):0==e?pe(o):1==e?x(a,pe(o),t):x(a,We(y(t)),w(t))}.call(this)})};Ke("+","+",void 0,0),Ke("-","-",function(e){return 1<=e},0),Ke("*","*",void 0,1),Ke(o("/"),o("/"),function(e){return 1<=e},1),Ke("rem",o("%"),function(e){return 2==e},1);var He=n.installComparisonOperator=function(a,s,c){return ce(a,function e(t,n){switch(arguments.length){case 0:return te(a,0);case 1:return qe([We(t),pe(c)]);case 2:var r=n;return{type:"BinaryExpression",operator:s,left:We(i=t),right:We(r)};default:var i=t,o=(r=n,Array.prototype.slice.call(arguments,2));return x(function(e,t){return{type:"LogicalExpression",operator:"&&",left:e,right:{type:"BinaryExpression",operator:s,left:N("LogicalExpression",(e||0).type)?((e||0).right||0).right:(e||0).right,right:We(t)}}},e(i,r),o)}})};He("==","==",!0),He(">",">",!0),He(">=",">=",!0),He("<","<",!0),He("<=","<=",!0);var Ye=n.isWriteIdentical=function(){var e=Array.prototype.slice.call(arguments,0);return 2===h(e)?{type:"BinaryExpression",operator:"===",left:We(y(e)),right:We(g(e))}:te("identical?",h(e))};ce("identical?",Ye);var Je=n.isWriteInstance=function(){var n=Array.prototype.slice.call(arguments,0);return function(){var e=y(n),t=g(n);return h(n)<1?te("instance?",h(n)):{type:"BinaryExpression",operator:"instanceof",left:t?We(t):fe(t),right:We(e)}}.call(this)};ce("instance?",Je),K("apply",n.expandApply=function(t){var n=Array.prototype.slice.call(arguments,1);return function(){var e=E(_(n));return d(e)?m.apply(void 0,[l(void 0,".apply")].concat([t],[void 0],E(n))):m.apply(void 0,[l(void 0,".apply")].concat([t],[void 0],[m.apply(void 0,[l(void 0,".concat")].concat([e],[C(n)]))]))}.call(this)});var Xe=n.expandPrint=function(t){var n=Array.prototype.slice.call(arguments,1);return function(){var e=u(l(void 0,"console.log"),a(t));return m.apply(void 0,[e].concat(E(n)))}.call(this)};K("print",u(Xe,{implicit:["&form"]})),K("str",n.expandStr=function(){var e=Array.prototype.slice.call(arguments,0);return m.apply(void 0,[l(void 0,"+")].concat([""],E(e)))}),K("debugger!",n.expandDebug=function(){return l(void 0,"debugger")}),K("assert",n.expandAssert=function e(t,n){switch(arguments.length){case 1:return e(r=t,"");case 2:var r=t,i=n;return function(){var e=s(r);return m.apply(void 0,[l(void 0,"if")].concat([m.apply(void 0,[l(void 0,"not")].concat([r]))],[m.apply(void 0,[l(void 0,"throw")].concat([m.apply(void 0,[l(void 0,"Error")].concat([m.apply(void 0,[l(void 0,"str")].concat(["Assert failed: "],[i],[e]))]))]))]))}.call(this);default:throw RangeError("Wrong number of arguments passed")}});var Ze=n.expandTypestr=function(e){return function(){return m.apply(void 0,[l(void 0,"->")].concat([m.apply(void 0,[l(void 0,".call")].concat([l(void 0,"Object.prototype.to-string")],[e]))],[m.apply(void 0,[l(void 0,".slice")].concat([h("[object ")],[0-h("]")]))]))}.call(this)},et=n.expandDefprotocol=function(a,s){var c=Array.prototype.slice.call(arguments,2);return function(){var i=p(((a||0).ns||0).name),o=p(s),e=(j(y(c))?y(c):void 0)?w(c):c,t=q(function(r){return function(){var e,t=y(r),n=Ne(i+"$"+o+"$"+p(t));return{id:t,fn:m.apply(void 0,[l(void 0,"fn")].concat([n],[[l(void 0,"self")].concat()],[m.apply(void 0,[l(void 0,".apply")].concat([m.apply(void 0,[l(void 0,"or")].concat([m.apply(void 0,[l(void 0,"if")].concat([m.apply(void 0,[l(void 0,"or")].concat([m.apply(void 0,[l(void 0,"identical?")].concat([l(void 0,"self")],[l(void 0,"null")]))],[m.apply(void 0,[l(void 0,"identical?")].concat([l(void 0,"self")],[void 0]))]))],[m.apply(void 0,[l(void 0,".-nil")].concat([n]))],[m.apply(void 0,[l(void 0,"or")].concat([m.apply(void 0,[l(void 0,"aget")].concat([l(void 0,"self")],[m.apply(void 0,[l(void 0,"quote")].concat([n]))]))],[m.apply(void 0,[l(void 0,"aget")].concat([n],[Ze(l(void 0,"self"))]))],[m.apply(void 0,[l(void 0,".-_")].concat([n]))]))]))],[(e=p(n),m.apply(void 0,[l(void 0,"fn")].concat([[l(void 0,"%1")].concat()],[m.apply(void 0,[l(void 0,"throw")].concat([m.apply(void 0,[l(void 0,"str")].concat(["No protocol method "+o+"."+e+" defined for type "],[Ze(l(void 0,"%1"))],[": "],[l(void 0,"%1")]))]))])))]))],[l(void 0,"self")],[l(void 0,"arguments")]))]))}}.call(this)},e),n=A(function(e){return m.apply(void 0,[l(void 0,"def")].concat([(e||0).id],[m.apply(void 0,[l(void 0,"aget")].concat([s],[m.apply(void 0,[l(void 0,"quote")].concat([(e||0).id]))]))]))},t),r=x(function(e,t){return R(e,(t||0).id,(t||0).fn)},{wisp_core$IProtocol$id:i+"/"+o},t);return m.apply(void 0,[u(l(void 0,"do"),{block:!0})].concat([m.apply(void 0,[l(void 0,"def")].concat([s],[r]))],E(n),[s]))}.call(this)};K("defprotocol",u(et,{implicit:["&env"]}));var tt=n.expandDeftype=function(s,r){var i=Array.prototype.slice.call(arguments,2);return function(){var e=A(function(e){return m.apply(void 0,[l(void 0,"set!")].concat([m.apply(void 0,[l(void 0,"aget")].concat([l(void 0,"this")],[m.apply(void 0,[l(void 0,"quote")].concat([e]))]))],[e]))},r),t=S(e,l(void 0,"this")),a=A(function(e){return m.apply(void 0,[l(void 0,"def")].concat([e],[m.apply(void 0,[l(void 0,"aget")].concat([l(void 0,"this")],[m.apply(void 0,[l(void 0,"quote")].concat([e]))]))]))},r),n=(x(function(e,t){return v(t)?S(e,{body:S((e||0).body,function(i,o){return function(){var e=y(o),t=g(o),n=w(w(o)),r=N(p(i),"Object")?m.apply(void 0,[l(void 0,"quote")].concat([e])):m.apply(void 0,[l(void 0,".-name")].concat([m.apply(void 0,[l(void 0,"aget")].concat([i],[m.apply(void 0,[l(void 0,"quote")].concat([e]))]))]));return m.apply(void 0,[l(void 0,"set!")].concat([m.apply(void 0,[l(void 0,"aget")].concat([m.apply(void 0,[l(void 0,".-prototype")].concat([s]))],[r]))],[m.apply(void 0,[l(void 0,"fn")].concat([t],E(a),E(n)))]))}.call(this)}((e||0).protocol,t))}):S(e,{protocol:t,body:S((e||0).body,(n=t,m.apply(void 0,[l(void 0,"set!")].concat([m.apply(void 0,[l(void 0,"aget")].concat([m.apply(void 0,[l(void 0,".-prototype")].concat([s]))],[m.apply(void 0,[l(void 0,".-wisp_core$IProtocol$id")].concat([n]))]))],[!0]))))});var n},{protocol:void 0,body:[]},i)||0).body;return m.apply(void 0,[l(void 0,"def")].concat([s],[m.apply(void 0,[l(void 0,"do")].concat([m.apply(void 0,[l(void 0,"defn-")].concat([s],[r],E(t)))],E(n),[s]))]))}.call(this)};K("deftype",tt),K("defrecord",tt),K("extend-type",n.expandExtendType=function(s){var t=Array.prototype.slice.call(arguments,1);return function(){N(s,l(void 0,"default")),P(s);var a=P(s)?l("nil"):N(s,l(void 0,"default"))?l(void 0,"_"):N(s,l(void 0,"number"))?l(void 0,"Number"):N(s,l(void 0,"string"))?l(void 0,"String"):N(s,l(void 0,"boolean"))?l(void 0,"Boolean"):N(s,l(void 0,"vector"))?l(void 0,"Array"):N(s,l(void 0,"function"))?l(void 0,"Function"):N(s,l(void 0,"re-pattern"))?l(void 0,"RegExp"):N(c(s),"js")?s:void 0,e=(x(function(e,t){return v(t)?S(e,{methods:S((e||0).methods,function(i,o){return function(){var e=y(o),t=g(o),n=w(w(o)),r=a?m.apply(void 0,[l(void 0,"aget")].concat([m.apply(void 0,[l(void 0,"aget")].concat([i],[m.apply(void 0,[l(void 0,"quote")].concat([e]))]))],[m.apply(void 0,[l(void 0,"quote")].concat([a]))])):m.apply(void 0,[l(void 0,"aget")].concat([m.apply(void 0,[l(void 0,".-prototype")].concat([s]))],[m.apply(void 0,[l(void 0,".-name")].concat([m.apply(void 0,[l(void 0,"aget")].concat([i],[m.apply(void 0,[l(void 0,"quote")].concat([e]))]))]))]));return m.apply(void 0,[l(void 0,"set!")].concat([r],[m.apply(void 0,[l(void 0,"fn")].concat([t],E(n)))]))}.call(this)}((e||0).protocol,t))}):S(e,{protocol:t,methods:S((e||0).methods,(n=t,a?m.apply(void 0,[l(void 0,"set!")].concat([m.apply(void 0,[l(void 0,"aget")].concat([n],[m.apply(void 0,[l(void 0,"quote")].concat([l("wisp_core$IProtocol$"+p(a))]))]))],[!0])):m.apply(void 0,[l(void 0,"set!")].concat([m.apply(void 0,[l(void 0,"aget")].concat([m.apply(void 0,[l(void 0,".-prototype")].concat([s]))],[m.apply(void 0,[l(void 0,".-wisp_core$IProtocol$id")].concat([n]))]))],[!0]))))});var n},{protocol:void 0,methods:[]},t)||0).methods;return m.apply(void 0,[l(void 0,"do")].concat(E(e),[void 0]))}.call(this)}),K("extend-protocol",n.expandExtendProtocol=function(n){var r=Array.prototype.slice.call(arguments,1);return function(){var e=x(function(e,t){return v(t)?b({type:(y(e)||0).type,methods:S((y(e)||0).methods,t)},w(e)):b({type:t,methods:[]},e)},void 0,r),t=A(function(e){return m.apply(void 0,[l(void 0,"extend-type")].concat([(e||0).type],[n],E((e||0).methods)))},e);return m.apply(void 0,[l(void 0,"do")].concat(E(t),[void 0]))}.call(this)}),K("aset",n.asetExpand=function(e,t,n){switch(arguments.length){case 3:var r=e,i=t,o=n;return m.apply(void 0,[l(void 0,"set!")].concat([m.apply(void 0,[l(void 0,"aget")].concat([r],[i]))],[o]));default:r=e,i=t;var a=n,s=Array.prototype.slice.call(arguments,3);return function(){var e=x(function(e,t){return m.apply(void 0,[l(void 0,"aget")].concat([e],[t]))},m.apply(void 0,[l(void 0,"aget")].concat([r],[i])),b(a,_(s))),t=C(s);return m.apply(void 0,[l(void 0,"set!")].concat([e],[t]))}.call(this)}}),K("alength",n.alengthExpand=function(e){return m.apply(void 0,[l(void 0,".-length")].concat([e]))})},{"./../../ast":"wisp/ast","./../../expander":"wisp/expander","./../../reader":"wisp/reader","./../../runtime":"wisp/runtime","./../../sequence":"wisp/sequence","./../../string":"wisp/string",escodegen:9}],3:[function(require,module,exports){var _ns_={id:"runner.main",doc:void 0},wisp_compiler=require("wisp/compiler"),compile=wisp_compiler.compile,_wisp_runtime=exports._wisp_runtime=require("../runtime.js"),_wisp_sequence=exports._wisp_sequence=require("../sequence.js"),_wisp_string=exports._wisp_string=require("../string.js"),fetchSource=exports.fetchSource=function(e,n){return function(){var t=new XMLHttpRequest;return t.open("GET",e,!0),t.addEventListener("load",function(e){return 200<=t.status&&t.status<300?n(t.responseText):console.error(t.statusText)},!1),t.overrideMimeType&&t.overrideMimeType("text/plain"),t.setRequestHeader("If-Modified-Since","Fri, 01 Jan 1960 00:00:00 GMT"),t.send(null)}.call(this)},runWispCode=exports.runWispCode=function runWispCode(code,url){return function(){var resultø1=compile(code,{"source-uri":url||"inline"}),errorø1=(resultø1||0).error;return errorø1?console.error(errorø1):Function(eval((resultø1||0).code))()}.call(this)},fetchAndRunWispCode=exports.fetchAndRunWispCode=function(t){return fetchSource(t,function(e){return runWispCode(e,t)})},__main__=exports.__main__=function(){return[_wisp_string,_wisp_sequence,_wisp_runtime].forEach(function(t){return Object.keys(t).forEach(function(e){return(window||0)[e]=(t||0)[e]})}),function(){var o=document.getElementsByTagName("script");return function r(){for(var e=r,i=0;e=i<o.length?function(){var e=(o||0)[i],t=e.src,n=e.text;return"application/wisp"==e.type&&(t&&fetchAndRunWispCode(t),n&&runWispCode(n,t)),r[0]=i+1,r}.call(this):void 0,i=r[0],e===r;);return e}.call(this)}.call(this)};window.addEventListener("load",__main__,!1)},{"../runtime.js":"wisp/runtime","../sequence.js":"wisp/sequence","../string.js":"wisp/string","wisp/compiler":"wisp/compiler"}],4:[function(n,e,t){(function(a,l){"use strict";e.exports=function(s,c){var f,d,h={},v={},u=!1,t=n("path");function m(e,t){var n;return e&&"."===e.charAt(0)&&t&&(function(e){var t,n;for(t=0;e[t];t+=1)if("."===(n=e[t]))e.splice(t,1),--t;else if(".."===n){if(1===t&&(".."===e[2]||".."===e[0]))break;0<t&&(e.splice(t-1,2),t-=2)}}(n=(n=(n=t.split("/")).slice(0,n.length-1)).concat(e.split("/"))),e=n.join("/")),e}function y(e,t,n){var r,i,o,a;if(e)i=v[e]={},r=f(c,i,o={id:e,uri:l,exports:i},e);else{if(u)throw new Error("amdefine with no module ID cannot be called more than once per file.");u=!0,i=s.exports,r=f(c,i,o=s,s.id)}t=t&&t.map(function(e){return r(e)}),void 0!==(a="function"==typeof n?n.apply(o.exports,t):n)&&(o.exports=a,e&&(v[e]=o.exports))}function e(e,t,n){Array.isArray(e)?(n=t,t=e,e=void 0):"string"!=typeof e&&(n=e,e=t=void 0),t&&!Array.isArray(t)&&(n=t,t=void 0),t=t||["require","exports","module"],e?h[e]=[e,t,n]:y(e,t,n)}return f=function(n,r,i,o){function e(e,t){if("string"==typeof e)return d(n,r,i,e,o);e=e.map(function(e){return d(n,r,i,e,o)}),t&&a.nextTick(function(){t.apply(null,e)})}return e.toUrl=function(e){return 0===e.indexOf(".")?m(e,t.dirname(i.filename)):e},e},c=c||function(){return s.require.apply(s,arguments)},d=function(e,t,n,r,i){var o,a,s,c,u=r.indexOf("!"),l=r;if(-1!==u)return o=r.substring(0,u),r=r.substring(u+1,r.length),r=(a=d(e,t,n,o,i)).normalize?a.normalize(r,(c=i,function(e){return m(e,c)})):m(r,i),v[r]||a.load(r,f(e,t,n,i),(s=r,p.fromText=function(e,t){throw new Error("amdefine does not implement load.fromText")},p),{}),v[r];if("require"===(r=m(r,i)))return f(e,t,n,i);if("exports"===r)return t;if("module"===r)return n;if(v.hasOwnProperty(r))return v[r];if(h[r])return y.apply(null,h[r]),v[r];if(e)return e(l);throw new Error("No module with ID: "+r);function p(e){v[s]=e}},e.require=function(e){return v[e]?v[e]:h[e]?(y.apply(null,h[e]),v[e]):void 0},e.amd={},e}}).call(this,n("_process"),"/node_modules/amdefine/amdefine.js")},{_process:17,path:16}],5:[function(e,n,t){(function(t){n.exports=function(e){return new t(e).toString("base64")}}).call(this,e("buffer").Buffer)},{buffer:8}],6:[function(e,t,n){"use strict";n.byteLength=function(e){var t=p(e),n=t[0],r=t[1];return 3*(n+r)/4-r},n.toByteArray=function(e){var t,n,r=p(e),i=r[0],o=r[1],a=new l(function(e,t,n){return 3*(t+n)/4-n}(0,i,o)),s=0,c=0<o?i-4:i;for(n=0;n<c;n+=4)t=u[e.charCodeAt(n)]<<18|u[e.charCodeAt(n+1)]<<12|u[e.charCodeAt(n+2)]<<6|u[e.charCodeAt(n+3)],a[s++]=t>>16&255,a[s++]=t>>8&255,a[s++]=255&t;2===o&&(t=u[e.charCodeAt(n)]<<2|u[e.charCodeAt(n+1)]>>4,a[s++]=255&t);1===o&&(t=u[e.charCodeAt(n)]<<10|u[e.charCodeAt(n+1)]<<4|u[e.charCodeAt(n+2)]>>2,a[s++]=t>>8&255,a[s++]=255&t);return a},n.fromByteArray=function(e){for(var t,n=e.length,r=n%3,i=[],o=0,a=n-r;o<a;o+=16383)i.push(c(e,o,a<o+16383?a:o+16383));1==r?(t=e[n-1],i.push(s[t>>2]+s[t<<4&63]+"==")):2==r&&(t=(e[n-2]<<8)+e[n-1],i.push(s[t>>10]+s[t>>4&63]+s[t<<2&63]+"="));return i.join("")};for(var s=[],u=[],l="undefined"!=typeof Uint8Array?Uint8Array:Array,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0,o=r.length;i<o;++i)s[i]=r[i],u[r.charCodeAt(i)]=i;function p(e){var t=e.length;if(0<t%4)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");return-1===n&&(n=t),[n,n===t?0:4-n%4]}function c(e,t,n){for(var r,i,o=[],a=t;a<n;a+=3)r=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),o.push(s[(i=r)>>18&63]+s[i>>12&63]+s[i>>6&63]+s[63&i]);return o.join("")}u["-".charCodeAt(0)]=62,u["_".charCodeAt(0)]=63},{}],7:[function(e,t,n){},{}],8:[function(D,e,P){(function(p){"use strict";var r=D("base64-js"),o=D("ieee754"),e="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;P.Buffer=p,P.SlowBuffer=function(e){+e!=e&&(e=0);return p.alloc(+e)},P.INSPECT_MAX_BYTES=50;var n=2147483647;function a(e){if(n<e)throw new RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return Object.setPrototypeOf(t,p.prototype),t}function p(e,t,n){if("number"!=typeof e)return i(e,t,n);if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return c(e)}function i(e,t,n){if("string"==typeof e)return function(e,t){"string"==typeof t&&""!==t||(t="utf8");if(!p.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var n=0|f(e,t),r=a(n),i=r.write(e,t);i!==n&&(r=r.slice(0,i));return r}(e,t);if(ArrayBuffer.isView(e))return u(e);if(null==e)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(j(e,ArrayBuffer)||e&&j(e.buffer,ArrayBuffer))return function(e,t,n){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(n||0))throw new RangeError('"length" is outside of buffer bounds');var r;r=void 0===t&&void 0===n?new Uint8Array(e):void 0===n?new Uint8Array(e,t):new Uint8Array(e,t,n);return Object.setPrototypeOf(r,p.prototype),r}(e,t,n);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');var r=e.valueOf&&e.valueOf();if(null!=r&&r!==e)return p.from(r,t,n);var i=function(e){if(p.isBuffer(e)){var t=0|l(e.length),n=a(t);return 0===n.length||e.copy(n,0,0,t),n}if(void 0!==e.length)return"number"!=typeof e.length||B(e.length)?a(0):u(e);if("Buffer"===e.type&&Array.isArray(e.data))return u(e.data)}(e);if(i)return i;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return p.from(e[Symbol.toPrimitive]("string"),t,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function s(e){if("number"!=typeof e)throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function c(e){return s(e),a(e<0?0:0|l(e))}function u(e){for(var t=e.length<0?0:0|l(e.length),n=a(t),r=0;r<t;r+=1)n[r]=255&e[r];return n}function l(e){if(n<=e)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+n.toString(16)+" bytes");return 0|e}function f(e,t){if(p.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||j(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);var n=e.length,r=2<arguments.length&&!0===arguments[2];if(!r&&0===n)return 0;for(var i=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return M(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return R(e).length;default:if(i)return r?-1:M(e).length;t=(""+t).toLowerCase(),i=!0}}function d(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function h(e,t,n,r,i){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):2147483647<n?n=2147483647:n<-2147483648&&(n=-2147483648),B(n=+n)&&(n=i?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(i)return-1;n=e.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof t&&(t=p.from(t,r)),p.isBuffer(t))return 0===t.length?-1:v(e,t,n,r,i);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):v(e,[t],n,r,i);throw new TypeError("val must be string, number or Buffer")}function v(e,t,n,r,i){var o,a=1,s=e.length,c=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;s/=a=2,c/=2,n/=2}function u(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}if(i){var l=-1;for(o=n;o<s;o++)if(u(e,o)===u(t,-1===l?0:o-l)){if(-1===l&&(l=o),o-l+1===c)return l*a}else-1!==l&&(o-=o-l),l=-1}else for(s<n+c&&(n=s-c),o=n;0<=o;o--){for(var p=!0,f=0;f<c;f++)if(u(e,o+f)!==u(t,f)){p=!1;break}if(p)return o}return-1}function m(e,t,n,r){n=Number(n)||0;var i=e.length-n;r?i<(r=Number(r))&&(r=i):r=i;var o=t.length;o/2<r&&(r=o/2);for(var a=0;a<r;++a){var s=parseInt(t.substr(2*a,2),16);if(B(s))return a;e[n+a]=s}return a}function y(e,t,n,r){return O(function(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}(t),e,n,r)}function g(e,t,n,r){return O(function(e,t){for(var n,r,i,o=[],a=0;a<e.length&&!((t-=2)<0);++a)n=e.charCodeAt(a),r=n>>8,i=n%256,o.push(i),o.push(r);return o}(t,e.length-n),e,n,r)}function w(e,t,n){return 0===t&&n===e.length?r.fromByteArray(e):r.fromByteArray(e.slice(t,n))}function b(e,t,n){n=Math.min(e.length,n);for(var r=[],i=t;i<n;){var o,a,s,c,u=e[i],l=null,p=239<u?4:223<u?3:191<u?2:1;if(i+p<=n)switch(p){case 1:u<128&&(l=u);break;case 2:128==(192&(o=e[i+1]))&&127<(c=(31&u)<<6|63&o)&&(l=c);break;case 3:o=e[i+1],a=e[i+2],128==(192&o)&&128==(192&a)&&2047<(c=(15&u)<<12|(63&o)<<6|63&a)&&(c<55296||57343<c)&&(l=c);break;case 4:o=e[i+1],a=e[i+2],s=e[i+3],128==(192&o)&&128==(192&a)&&128==(192&s)&&65535<(c=(15&u)<<18|(63&o)<<12|(63&a)<<6|63&s)&&c<1114112&&(l=c)}null===l?(l=65533,p=1):65535<l&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|1023&l),r.push(l),i+=p}return function(e){var t=e.length;if(t<=S)return String.fromCharCode.apply(String,e);var n="",r=0;for(;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=S));return n}(r)}P.kMaxLength=n,(p.TYPED_ARRAY_SUPPORT=function(){try{var e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),42===e.foo()}catch(e){return!1}}())||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(p.prototype,"parent",{enumerable:!0,get:function(){if(p.isBuffer(this))return this.buffer}}),Object.defineProperty(p.prototype,"offset",{enumerable:!0,get:function(){if(p.isBuffer(this))return this.byteOffset}}),"undefined"!=typeof Symbol&&null!=Symbol.species&&p[Symbol.species]===p&&Object.defineProperty(p,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),p.poolSize=8192,p.from=function(e,t,n){return i(e,t,n)},Object.setPrototypeOf(p.prototype,Uint8Array.prototype),Object.setPrototypeOf(p,Uint8Array),p.alloc=function(e,t,n){return i=t,o=n,s(r=e),r<=0?a(r):void 0!==i?"string"==typeof o?a(r).fill(i,o):a(r).fill(i):a(r);var r,i,o},p.allocUnsafe=function(e){return c(e)},p.allocUnsafeSlow=function(e){return c(e)},p.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==p.prototype},p.compare=function(e,t){if(j(e,Uint8Array)&&(e=p.from(e,e.offset,e.byteLength)),j(t,Uint8Array)&&(t=p.from(t,t.offset,t.byteLength)),!p.isBuffer(e)||!p.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;for(var n=e.length,r=t.length,i=0,o=Math.min(n,r);i<o;++i)if(e[i]!==t[i]){n=e[i],r=t[i];break}return n<r?-1:r<n?1:0},p.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},p.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return p.alloc(0);var n;if(void 0===t)for(n=t=0;n<e.length;++n)t+=e[n].length;var r=p.allocUnsafe(t),i=0;for(n=0;n<e.length;++n){var o=e[n];if(j(o,Uint8Array)&&(o=p.from(o)),!p.isBuffer(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(r,i),i+=o.length}return r},p.byteLength=f,p.prototype._isBuffer=!0,p.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)d(this,t,t+1);return this},p.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)d(this,t,t+3),d(this,t+1,t+2);return this},p.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)d(this,t,t+7),d(this,t+1,t+6),d(this,t+2,t+5),d(this,t+3,t+4);return this},p.prototype.toLocaleString=p.prototype.toString=function(){var e=this.length;return 0===e?"":0===arguments.length?b(this,0,e):function(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e=e||"utf8";;)switch(e){case"hex":return E(this,t,n);case"utf8":case"utf-8":return b(this,t,n);case"ascii":return _(this,t,n);case"latin1":case"binary":return x(this,t,n);case"base64":return w(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}.apply(this,arguments)},p.prototype.equals=function(e){if(!p.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===p.compare(this,e)},p.prototype.inspect=function(){var e="",t=P.INSPECT_MAX_BYTES;return e=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(e+=" ... "),"<Buffer "+e+">"},e&&(p.prototype[e]=p.prototype.inspect),p.prototype.compare=function(e,t,n,r,i){if(j(e,Uint8Array)&&(e=p.from(e,e.offset,e.byteLength)),!p.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),t<0||n>e.length||r<0||i>this.length)throw new RangeError("out of range index");if(i<=r&&n<=t)return 0;if(i<=r)return-1;if(n<=t)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(r>>>=0),a=(n>>>=0)-(t>>>=0),s=Math.min(o,a),c=this.slice(r,i),u=e.slice(t,n),l=0;l<s;++l)if(c[l]!==u[l]){o=c[l],a=u[l];break}return o<a?-1:a<o?1:0},p.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},p.prototype.indexOf=function(e,t,n){return h(this,e,t,n,!0)},p.prototype.lastIndexOf=function(e,t,n){return h(this,e,t,n,!1)},p.prototype.write=function(e,t,n,r){if(void 0===t)r="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)r=t,n=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t>>>=0,isFinite(n)?(n>>>=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var i=this.length-t;if((void 0===n||i<n)&&(n=i),0<e.length&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r=r||"utf8";for(var o,a,s,c,u,l,p=!1;;)switch(r){case"hex":return m(this,e,t,n);case"utf8":case"utf-8":return u=t,l=n,O(M(e,(c=this).length-u),c,u,l);case"ascii":return y(this,e,t,n);case"latin1":case"binary":return y(this,e,t,n);case"base64":return o=this,a=t,s=n,O(R(e),o,a,s);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return g(this,e,t,n);default:if(p)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),p=!0}},p.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var S=4096;function _(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;i<n;++i)r+=String.fromCharCode(127&e[i]);return r}function x(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;i<n;++i)r+=String.fromCharCode(e[i]);return r}function E(e,t,n){var r=e.length;(!t||t<0)&&(t=0),(!n||n<0||r<n)&&(n=r);for(var i="",o=t;o<n;++o)i+=T[e[o]];return i}function C(e,t,n){for(var r=e.slice(t,n),i="",o=0;o<r.length;o+=2)i+=String.fromCharCode(r[o]+256*r[o+1]);return i}function A(e,t,n){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(n<e+t)throw new RangeError("Trying to access beyond buffer length")}function q(e,t,n,r,i,o){if(!p.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(i<t||t<o)throw new RangeError('"value" argument is out of bounds');if(n+r>e.length)throw new RangeError("Index out of range")}function k(e,t,n,r){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function I(e,t,n,r,i){return t=+t,n>>>=0,i||k(e,0,n,4),o.write(e,t,n,r,23,4),n+4}function L(e,t,n,r,i){return t=+t,n>>>=0,i||k(e,0,n,8),o.write(e,t,n,r,52,8),n+8}p.prototype.slice=function(e,t){var n=this.length;(e=~~e)<0?(e+=n)<0&&(e=0):n<e&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):n<t&&(t=n),t<e&&(t=e);var r=this.subarray(e,t);return Object.setPrototypeOf(r,p.prototype),r},p.prototype.readUIntLE=function(e,t,n){e>>>=0,t>>>=0,n||A(e,t,this.length);for(var r=this[e],i=1,o=0;++o<t&&(i*=256);)r+=this[e+o]*i;return r},p.prototype.readUIntBE=function(e,t,n){e>>>=0,t>>>=0,n||A(e,t,this.length);for(var r=this[e+--t],i=1;0<t&&(i*=256);)r+=this[e+--t]*i;return r},p.prototype.readUInt8=function(e,t){return e>>>=0,t||A(e,1,this.length),this[e]},p.prototype.readUInt16LE=function(e,t){return e>>>=0,t||A(e,2,this.length),this[e]|this[e+1]<<8},p.prototype.readUInt16BE=function(e,t){return e>>>=0,t||A(e,2,this.length),this[e]<<8|this[e+1]},p.prototype.readUInt32LE=function(e,t){return e>>>=0,t||A(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},p.prototype.readUInt32BE=function(e,t){return e>>>=0,t||A(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},p.prototype.readIntLE=function(e,t,n){e>>>=0,t>>>=0,n||A(e,t,this.length);for(var r=this[e],i=1,o=0;++o<t&&(i*=256);)r+=this[e+o]*i;return(i*=128)<=r&&(r-=Math.pow(2,8*t)),r},p.prototype.readIntBE=function(e,t,n){e>>>=0,t>>>=0,n||A(e,t,this.length);for(var r=t,i=1,o=this[e+--r];0<r&&(i*=256);)o+=this[e+--r]*i;return(i*=128)<=o&&(o-=Math.pow(2,8*t)),o},p.prototype.readInt8=function(e,t){return e>>>=0,t||A(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},p.prototype.readInt16LE=function(e,t){e>>>=0,t||A(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},p.prototype.readInt16BE=function(e,t){e>>>=0,t||A(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},p.prototype.readInt32LE=function(e,t){return e>>>=0,t||A(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},p.prototype.readInt32BE=function(e,t){return e>>>=0,t||A(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},p.prototype.readFloatLE=function(e,t){return e>>>=0,t||A(e,4,this.length),o.read(this,e,!0,23,4)},p.prototype.readFloatBE=function(e,t){return e>>>=0,t||A(e,4,this.length),o.read(this,e,!1,23,4)},p.prototype.readDoubleLE=function(e,t){return e>>>=0,t||A(e,8,this.length),o.read(this,e,!0,52,8)},p.prototype.readDoubleBE=function(e,t){return e>>>=0,t||A(e,8,this.length),o.read(this,e,!1,52,8)