(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){var fscope=require("frequency-viewer");module.exports=function(){addEventListener("message",function(ev){postMessage(fscope.worker(ev.data))})}},{"frequency-viewer":37}],2:[function(require,module,exports){var baudio=require("webaudio");var observable=require("observable");var hyperquest=require("hyperquest");var keycode=require("keycode");document.querySelector("#save").addEventListener("submit",onsubmit);function onsubmit(ev){ev.preventDefault();var title=this.elements.title.value;var href=location.protocol+"//"+location.host+"/"+encodeURIComponent(title)+".json";var r=hyperquest.post(href);r.on("data",function(buf){console.log(buf)});r.end(JSON.stringify({title:title,code:code.value}));if(window.history.pushState){window.history.pushState({},title,"/"+title)}document.querySelector(".history-link").setAttribute("href","/-/history/"+encodeURIComponent(title))}var music=function(t){return 0};var ascope=require("amplitude-viewer")();ascope.appendTo("#ascope");var work=require("webworkify");var w=work(require("./fft.js"));var queue=[];w.addEventListener("message",function(ev){queue.shift()(ev.data)});var fscope=require("frequency-viewer")({worker:function(data,cb){queue.push(cb);w.postMessage(data)}});fscope.appendTo("#fscope");var play=document.querySelector("#play");play.addEventListener("click",togglePlay);ascope.on("click",togglePlay);var paused=false;function togglePlay(){paused=!paused;play.textContent=paused?"play":"pause"}window.addEventListener("resize",function(ev){ascope.resize();fscope.resize()});window.addEventListener("keydown",function(ev){var name=keycode(ev);if(name==="page up"||name==="page down"){ev.preventDefault()}document.body.scrollTop=0});var code=document.querySelector("#code");code.addEventListener("keydown",function(ev){var name=keycode(ev);if(name==="page up"){var x=code.scrollTop-code.offsetHeight;code.scrollTop=Math.max(0,x)}else if(name==="page down"){var x=code.scrollTop+code.offsetHeight;code.scrollTop=Math.min(code.scrollHeight,x)}});var state={};var shoe=require("shoe");var stream=shoe("/sock");var split=require("split");var through=require("through");stream.pipe(split()).pipe(through(function(line){try{var row=JSON.parse(line)}catch(err){return}if(!row||typeof row!=="object")return;var keys=Object.keys(row);for(var i=0;i<keys.length;i++){var key=keys[i];state[key]=row[key]}}));observable.input(code)(function(source){try{music=Function(source)()}catch(err){return console.log(err)}ascope.draw(function(t){return music(t,state)})});setInterval(function f(){if(paused)return;ascope.setTime(time);ascope.draw(function(t){return music(t,state)});fscope.draw(data)},50);var time=0;var data=new Float32Array(4e3);var dataIx=0;var b=baudio(function(t){time=t;if(paused)return 0;var x=music(t,state);data[dataIx++%data.length]=x;return x});b.play()},{"./fft.js":1,"amplitude-viewer":3,"frequency-viewer":37,hyperquest:75,keycode:78,observable:79,shoe:80,split:82,through:84,webaudio:85,webworkify:86}],3:[function(require,module,exports){var fs=require("fs");var html='<div>\n  <div class="sliders"></div>\n  <div class="shield"></div>\n</div>\n';var domify=require("domify");var inherits=require("inherits");var EventEmitter=require("events").EventEmitter;var slideways=require("slideways");module.exports=Scope;inherits(Scope,EventEmitter);function Scope(opts){var self=this;if(!(this instanceof Scope))return new Scope(opts);if(!opts)opts={};this.element=domify(html)[0];this.element.style.width="100%";this.element.style.height="100%";this.svg=createElement("svg");this.svg.setAttribute("width","100%");this.svg.setAttribute("height","100%");this.element.appendChild(this.svg);var p=this.polyline=createElement("polyline");p.setAttribute("stroke",opts.stroke||"cyan");p.setAttribute("stroke-width",opts.strokeWidth||"4px");p.setAttribute("fill","transparent");this.svg.appendChild(this.polyline);var shield=this.element.querySelector(".shield");shield.style.position="absolute";shield.style.top="0px";shield.style.bottom="0px";shield.style.left="0px";shield.style.right="0px";shield.style.zIndex=5;shield.style.backgroundColor="transparent";shield.addEventListener("click",function(ev){self.emit("click",ev)});this.duration=opts.duration||1/50;this.time=0;this.offset=0;var sopts=opts.slider||{min:-1,max:3,init:Math.log(50)/Math.log(10)};this.createSlider(sopts,function(x){self.setDuration(Math.pow(10,-x))});var oopts=opts.offset||{min:-10,max:10,init:0};this.createSlider(oopts,function(x){self.setOffset(x/Math.log(self.duration)/Math.log(10))})}Scope.prototype.appendTo=function(target){if(typeof target==="string")target=document.querySelector(target);target.appendChild(this.element);this._target=target;this.resize()};Scope.prototype.setDuration=function(d){this.duration=d;if(this._lastFn)this.draw(this._lastFn)};Scope.prototype.setTime=function(t){this.time=t};Scope.prototype.setOffset=function(x){this.offset=x*this.duration;if(this._lastFn)this.draw(this._lastFn)};Scope.prototype.resize=function(){if(!this._target)return;var style=window.getComputedStyle(this.svg);this.width=parseInt(style.width);this.height=parseInt(style.height)};Scope.prototype.draw=function(fn){var samples=500;this._lastFn=fn;var points=[];for(var i=0;i<samples;i++){var t=this.offset+this.time+i/samples*this.duration;var res=Math.max(-1,Math.min(1,fn(t)));if(isNaN(res))res=0;var x=this.width*(i/samples);var y=(res+1)/2*(this.height-25*2)+10;points.push(x+","+y)}this.polyline.setAttribute("points",points.join(" "))};Scope.prototype.createSlider=function(opts,f){if(!opts)opts={};var a=slideways(opts);if(f)a.on("value",f);a.appendTo(this.element.querySelector(".sliders"));a.element.style.zIndex=10;return a};function createElement(name){return document.createElementNS("http://www.w3.org/2000/svg",name)}},{domify:4,events:14,fs:10,inherits:5,slideways:6}],4:[function(require,module,exports){module.exports=parse;var map={option:[1,'<select multiple="multiple">',"</select>"],optgroup:[1,'<select multiple="multiple">',"</select>"],legend:[1,"<fieldset>","</fieldset>"],thead:[1,"<table>","</table>"],tbody:[1,"<table>","</table>"],tfoot:[1,"<table>","</table>"],colgroup:[1,"<table>","</table>"],caption:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],th:[3,"<table><tbody><tr>","</tr></tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],_default:[0,"",""]};function parse(html){if("string"!=typeof html)throw new TypeError("String expected");var m=/<([\w:]+)/.exec(html);if(!m)throw new Error("No elements were generated.");var tag=m[1];if(tag=="body"){var el=document.createElement("html");el.innerHTML=html;return[el.removeChild(el.lastChild)]}var wrap=map[tag]||map._default;var depth=wrap[0];var prefix=wrap[1];var suffix=wrap[2];var el=document.createElement("div");el.innerHTML=prefix+html+suffix;while(depth--)el=el.lastChild;return orphan(el.children)}function orphan(els){var ret=[];while(els.length){ret.push(els[0].parentNode.removeChild(els[0]))}return ret}},{}],5:[function(require,module,exports){if(typeof Object.create==="function"){module.exports=function inherits(ctor,superCtor){ctor.super_=superCtor;ctor.prototype=Object.create(superCtor.prototype,{constructor:{value:ctor,enumerable:false,writable:true,configurable:true}})}}else{module.exports=function inherits(ctor,superCtor){ctor.super_=superCtor;var TempCtor=function(){};TempCtor.prototype=superCtor.prototype;ctor.prototype=new TempCtor;ctor.prototype.constructor=ctor}}},{}],6:[function(require,module,exports){(function(process){var hyperglue=require("hyperglue");var EventEmitter=require("events").EventEmitter;var inherits=require("inherits");var html=require("./static/html");var css=require("./static/css");module.exports=Slider;inherits(Slider,EventEmitter);var insertedCss=false;function Slider(opts){if(!(this instanceof Slider))return new Slider(opts);EventEmitter.call(this);var self=this;if(!opts)opts={};this.max=opts.max===undefined?1:opts.max;this.min=opts.min===undefined?0:opts.min;this.snap=opts.snap;process.nextTick(function(){if(opts.init!==undefined){self.set(opts.init)}else if(opts.min!==undefined){self.set(opts.min)}else self.set(0)});if(!insertedCss&&opts.insertCss!==false){var style=document.createElement("style");style.appendChild(document.createTextNode(css));if(document.head.childNodes.length){document.head.insertBefore(style,document.head.childNodes[0])}else{document.head.appendChild(style)}insertedCss=true}var root=this.element=hyperglue(html);var turtle=this.turtle=root.querySelector(".turtle");var runner=root.querySelector(".runner");var down=false;turtle.addEventListener("mousedown",function(ev){ev.preventDefault();turtle.className="turtle pressed";down={x:ev.clientX-root.offsetLeft-turtle.offsetLeft}});root.addEventListener("mousedown",function(ev){ev.preventDefault()});window.addEventListener("mouseup",mouseup);window.addEventListener("mousemove",onmove);function onmove(ev){ev.preventDefault();if(!down)return;var w=self._elementWidth();var x=Math.max(0,Math.min(w,ev.clientX-root.offsetLeft-down.x));var value=x/w;if(isNaN(value))return;self.set(self.interpolate(value))}function mouseup(){down=true;turtle.className="turtle"}}Slider.prototype.appendTo=function(target){if(typeof target==="string"){target=document.querySelector(target)}target.appendChild(this.element)};Slider.prototype.interpolate=function(value){var v=value*(this.max-this.min)+this.min;var res=this.snap?Math.round(v/this.snap)*this.snap:v;return Math.max(this.min,Math.min(this.max,res))};Slider.prototype.set=function(value){value=Math.max(this.min,Math.min(this.max,value));var x=(value-this.min)/(this.max-this.min);this.turtle.style.left=x*this._elementWidth();value=Math.round(value*1e10)/1e10;this.emit("value",value)};Slider.prototype._elementWidth=function(){var style={root:window.getComputedStyle(this.element),turtle:window.getComputedStyle(this.turtle)};return num(style.root.width)-num(style.turtle.width)-num(style.turtle["border-width"])};function num(s){return Number((/^(\d+)/.exec(s)||[0,0])[1])}}).call(this,require("FWaASH"))},{"./static/css":8,"./static/html":9,FWaASH:21,events:14,hyperglue:7,inherits:5}],7:[function(require,module,exports){module.exports=function(src,updates){if(!updates)updates={};var div=src;if(typeof div!=="object"){div=document.createElement("div");div.innerHTML=src.replace(/^\s+|\s+$/g,"");if(div.childNodes.length===1&&div.childNodes[0]&&div.childNodes[0].constructor&&div.childNodes[0].constructor.name!=="Text"){div=div.childNodes[0]}}forEach(objectKeys(updates),function(selector){var value=updates[selector];var nodes=div.querySelectorAll(selector);if(nodes.length===0)return;for(var i=0;i<nodes.length;i++){bind(nodes[i],value)}});return div};function bind(node,value){if(isElement(value)){node.innerHTML="";node.appendChild(value)}else if(value&&typeof value==="object"){forEach(objectKeys(value),function(key){if(key==="_text"){setText(node,value[key])}else if(key==="_html"&&isElement(value[key])){node.innerHTML="";node.appendChild(value[key])}else if(key==="_html"){node.innerHTML=value[key]}else node.setAttribute(key,value[key])})}else setText(node,value)}function forEach(xs,f){if(xs.forEach)return xs.forEach(f);for(var i=0;i<xs.length;i++)f(xs[i],i)}var objectKeys=Object.keys||function(obj){var res=[];for(var key in obj)res.push(key);return res};function isElement(e){return e&&typeof e==="object"&&e.childNodes&&typeof e.appendChild==="function"}function setText(e,s){e.innerHTML="";var txt=document.createTextNode(s);e.appendChild(txt)}},{}],8:[function(require,module,exports){module.exports=[".slideways {","position: relative;","left: 0px;","top: 0px;","display: inline-block;","height: 24px;","width: 150px;","}",".slideways .turtle {","position: absolute;","top: 0px;","left: 0px;","bottom: 0px;","width: 8px;","margin-top: 0px;","margin-bottom: 0px;","background-color: white;","border: 2px solid rgb(52,52,52);","border-radius: 4px;","}",".slideways .turtle.pressed {","background-color: rgb(223,223,223);","}",".slideways .runner {","position: absolute;","top: 8px;","left: 4px;","right: 4px;","height: 5px;","background-color: rgb(96,96,96);","border: 2px solid rgb(52,52,52);","border-radius: 3px;","}"].join("\n")},{}],9:[function(require,module,exports){module.exports=['<div class="slideways">','<div class="runner"></div>','<div class="turtle"></div>',"</div>"].join("\n")},{}],10:[function(require,module,exports){},{}],11:[function(require,module,exports){var base64=require("base64-js");var ieee754=require("ieee754");exports.Buffer=Buffer;exports.SlowBuffer=Buffer;exports.INSPECT_MAX_BYTES=50;Buffer.poolSize=8192;Buffer._useTypedArrays=function(){try{var buf=new ArrayBuffer(0);var arr=new Uint8Array(buf);arr.foo=function(){return 42};return 42===arr.foo()&&typeof arr.subarray==="function"}catch(e){return false}}();function Buffer(subject,encoding,noZero){if(!(this instanceof Buffer))return new Buffer(subject,encoding,noZero);var type=typeof subject;if(encoding==="base64"&&type==="string"){subject=stringtrim(subject);while(subject.length%4!==0){subject=subject+"="}}var length;if(type==="number")length=coerce(subject);else if(type==="string")length=Buffer.byteLength(subject,encoding);else if(type==="object")length=coerce(subject.length);else throw new Error("First argument needs to be a number, array or string.");var buf;if(Buffer._useTypedArrays){buf=Buffer._augment(new Uint8Array(length))}else{buf=this;buf.length=length;buf._isBuffer=true}var i;if(Buffer._useTypedArrays&&typeof subject.byteLength==="number"){buf._set(subject)}else if(isArrayish(subject)){for(i=0;i<length;i++){if(Buffer.isBuffer(subject))buf[i]=subject.readUInt8(i);else buf[i]=subject[i]}}else if(type==="string"){buf.write(subject,0,encoding)}else if(type==="number"&&!Buffer._useTypedArrays&&!noZero){for(i=0;i<length;i++){buf[i]=0}}return buf}Buffer.isEncoding=function(encoding){switch(String(encoding).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return true;default:return false}};Buffer.isBuffer=function(b){return!!(b!==null&&b!==undefined&&b._isBuffer)};Buffer.byteLength=function(str,encoding){var ret;str=str+"";switch(encoding||"utf8"){case"hex":ret=str.length/2;break;case"utf8":case"utf-8":ret=utf8ToBytes(str).length;break;case"ascii":case"binary":case"raw":ret=str.length;break;case"base64":ret=base64ToBytes(str).length;break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":ret=str.length*2;break;default:throw new Error("Unknown encoding")}return ret};Buffer.concat=function(list,totalLength){assert(isArray(list),"Usage: Buffer.concat(list, [totalLength])\n"+"list should be an Array.");if(list.length===0){return new Buffer(0)}else if(list.length===1){return list[0]}var i;if(typeof totalLength!=="number"){totalLength=0;for(i=0;i<list.length;i++){totalLength+=list[i].length}}var buf=new Buffer(totalLength);var pos=0;for(i=0;i<list.length;i++){var item=list[i];item.copy(buf,pos);pos+=item.length}return buf};function _hexWrite(buf,string,offset,length){offset=Number(offset)||0;var remaining=buf.length-offset;if(!length){length=remaining}else{length=Number(length);if(length>remaining){length=remaining}}var strLen=string.length;assert(strLen%2===0,"Invalid hex string");if(length>strLen/2){length=strLen/2}for(var i=0;i<length;i++){var byte=parseInt(string.substr(i*2,2),16);assert(!isNaN(byte),"Invalid hex string");buf[offset+i]=byte}Buffer._charsWritten=i*2;return i}function _utf8Write(buf,string,offset,length){var charsWritten=Buffer._charsWritten=blitBuffer(utf8ToBytes(string),buf,offset,length);return charsWritten}function _asciiWrite(buf,string,offset,length){var charsWritten=Buffer._charsWritten=blitBuffer(asciiToBytes(string),buf,offset,length);return charsWritten}function _binaryWrite(buf,string,offset,length){return _asciiWrite(buf,string,offset,length)}function _base64Write(buf,string,offset,length){var charsWritten=Buffer._charsWritten=blitBuffer(base64ToBytes(string),buf,offset,length);return charsWritten}function _utf16leWrite(buf,string,offset,length){var charsWritten=Buffer._charsWritten=blitBuffer(utf16leToBytes(string),buf,offset,length);return charsWritten}Buffer.prototype.write=function(string,offset,length,encoding){if(isFinite(offset)){if(!isFinite(length)){encoding=length;length=undefined}}else{var swap=encoding;encoding=offset;offset=length;length=swap}offset=Number(offset)||0;var remaining=this.length-offset;if(!length){length=remaining}else{length=Number(length);if(length>remaining){length=remaining}}encoding=String(encoding||"utf8").toLowerCase();var ret;switch(encoding){case"hex":ret=_hexWrite(this,string,offset,length);break;case"utf8":case"utf-8":ret=_utf8Write(this,string,offset,length);break;case"ascii":ret=_asciiWrite(this,string,offset,length);break;case"binary":ret=_binaryWrite(this,string,offset,length);break;case"base64":ret=_base64Write(this,string,offset,length);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":ret=_utf16leWrite(this,string,offset,length);break;default:throw new Error("Unknown encoding")}return ret};Buffer.prototype.toString=function(encoding,start,end){var self=this;encoding=String(encoding||"utf8").toLowerCase();start=Number(start)||0;end=end!==undefined?Number(end):end=self.length;if(end===start)return"";var ret;switch(encoding){case"hex":ret=_hexSlice(self,start,end);break;case"utf8":case"utf-8":ret=_utf8Slice(self,start,end);break;case"ascii":ret=_asciiSlice(self,start,end);break;case"binary":ret=_binarySlice(self,start,end);break;case"base64":ret=_base64Slice(self,start,end);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":ret=_utf16leSlice(self,start,end);break;default:throw new Error("Unknown encoding")}return ret};Buffer.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};Buffer.prototype.copy=function(target,target_start,start,end){var source=this;if(!start)start=0;if(!end&&end!==0)end=this.length;if(!target_start)target_start=0;if(end===start)return;if(target.length===0||source.length===0)return;assert(end>=start,"sourceEnd < sourceStart");assert(target_start>=0&&target_start<target.length,"targetStart out of bounds");assert(start>=0&&start<source.length,"sourceStart out of bounds");assert(end>=0&&end<=source.length,"sourceEnd out of bounds");if(end>this.length)end=this.length;if(target.length-target_start<end-start)end=target.length-target_start+start;var len=end-start;if(len<100||!Buffer._useTypedArrays){for(var i=0;i<len;i++)target[i+target_start]=this[i+start]}else{target._set(this.subarray(start,start+len),target_start)}};function _base64Slice(buf,start,end){if(start===0&&end===buf.length){return base64.fromByteArray(buf)}else{return base64.fromByteArray(buf.slice(start,end))}}function _utf8Slice(buf,start,end){var res="";var tmp="";end=Math.min(buf.length,end);for(var i=start;i<end;i++){if(buf[i]<=127){res+=decodeUtf8Char(tmp)+String.fromCharCode(buf[i]);tmp=""}else{tmp+="%"+buf[i].toString(16)}}return res+decodeUtf8Char(tmp)}function _asciiSlice(buf,start,end){var ret="";end=Math.min(buf.length,end);for(var i=start;i<end;i++)ret+=String.fromCharCode(buf[i]);return ret}function _binarySlice(buf,start,end){return _asciiSlice(buf,start,end)}function _hexSlice(buf,start,end){var len=buf.length;if(!start||start<0)start=0;if(!end||end<0||end>len)end=len;var out="";for(var i=start;i<end;i++){out+=toHex(buf[i])}return out}function _utf16leSlice(buf,start,end){var bytes=buf.slice(start,end);var res="";for(var i=0;i<bytes.length;i+=2){res+=String.fromCharCode(bytes[i]+bytes[i+1]*256)}return res}Buffer.prototype.slice=function(start,end){var len=this.length;start=clamp(start,len,0);end=clamp(end,len,len);if(Buffer._useTypedArrays){return Buffer._augment(this.subarray(start,end))}else{var sliceLen=end-start;var newBuf=new Buffer(sliceLen,undefined,true);for(var i=0;i<sliceLen;i++){newBuf[i]=this[i+start]}return newBuf}};Buffer.prototype.get=function(offset){console.log(".get() is deprecated. Access using array indexes instead.");return this.readUInt8(offset)};Buffer.prototype.set=function(v,offset){console.log(".set() is deprecated. Access using array indexes instead.");return this.writeUInt8(v,offset)};Buffer.prototype.readUInt8=function(offset,noAssert){if(!noAssert){assert(offset!==undefined&&offset!==null,"missing offset");assert(offset<this.length,"Trying to read beyond buffer length")}if(offset>=this.length)return;return this[offset]};function _readUInt16(buf,offset,littleEndian,noAssert){if(!noAssert){assert(typeof littleEndian==="boolean","missing or invalid endian");assert(offset!==undefined&&offset!==null,"missing offset");assert(offset+1<buf.length,"Trying to read beyond buffer length")}var len=buf.length;if(offset>=len)return;var val;if(littleEndian){val=buf[offset];if(offset+1<len)val|=buf[offset+1]<<8}else{val=buf[offset]<<8;if(offset+1<len)val|=buf[offset+1]}return val}Buffer.prototype.readUInt16LE=function(offset,noAssert){return _readUInt16(this,offset,true,noAssert)};Buffer.prototype.readUInt16BE=function(offset,noAssert){return _readUInt16(this,offset,false,noAssert)};function _readUInt32(buf,offset,littleEndian,noAssert){if(!noAssert){assert(typeof littleEndian==="boolean","missing or invalid endian");assert(offset!==undefined&&offset!==null,"missing offset");assert(offset+3<buf.length,"Trying to read beyond buffer length")}var len=buf.length;if(offset>=len)return;var val;if(littleEndian){if(offset+2<len)val=buf[offset+2]<<16;if(offset+1<len)val|=buf[offset+1]<<8;val|=buf[offset];if(offset+3<len)val=val+(buf[offset+3]<<24>>>0)}else{if(offset+1<len)val=buf[offset+1]<<16;if(offset+2<len)val|=buf[offset+2]<<8;if(offset+3<len)val|=buf[offset+3];val=val+(buf[offset]<<24>>>0)}return val}Buffer.prototype.readUInt32LE=function(offset,noAssert){return _readUInt32(this,offset,true,noAssert)};Buffer.prototype.readUInt32BE=function(offset,noAssert){return _readUInt32(this,offset,false,noAssert)};Buffer.prototype.readInt8=function(offset,noAssert){if(!noAssert){assert(offset!==undefined&&offset!==null,"missing offset");assert(offset<this.length,"Trying to read beyond buffer length")}if(offset>=this.length)return;var neg=this[offset]&128;if(neg)return(255-this[offset]+1)*-1;else return this[offset]};function _readInt16(buf,offset,littleEndian,noAssert){if(!noAssert){assert(typeof littleEndian==="boolean","missing or invalid endian");assert(offset!==undefined&&offset!==null,"missing offset");assert(offset+1<buf.length,"Trying to read beyond buffer length")}var len=buf.length;if(offset>=len)return;var val=_readUInt16(buf,offset,littleEndian,true);var neg=val&32768;if(neg)return(65535-val+1)*-1;else return val}Buffer.prototype.readInt16LE=function(offset,noAssert){return _readInt16(this,offset,true,noAssert)};Buffer.prototype.readInt16BE=function(offset,noAssert){return _readInt16(this,offset,false,noAssert)};function _readInt32(buf,offset,littleEndian,noAssert){if(!noAssert){assert(typeof littleEndian==="boolean","missing or invalid endian");assert(offset!==undefined&&offset!==null,"missing offset");assert(offset+3<buf.length,"Trying to read beyond buffer length")}var len=buf.length;if(offset>=len)return;var val=_readUInt32(buf,offset,littleEndian,true);var neg=val&2147483648;if(neg)return(4294967295-val+1)*-1;else return val}Buffer.prototype.readInt32LE=function(offset,noAssert){return _readInt32(this,offset,true,noAssert)};Buffer.prototype.readInt32BE=function(offset,noAssert){return _readInt32(this,offset,false,noAssert)};function _readFloat(buf,offset,littleEndian,noAssert){if(!noAssert){assert(typeof littleEndian==="boolean","missing or invalid endian");assert(offset+3<buf.length,"Trying to read beyond buffer length")}return ieee754.read(buf,offset,littleEndian,23,4)}Buffer.prototype.readFloatLE=function(offset,noAssert){return _readFloat(this,offset,true,noAssert)};Buffer.prototype.readFloatBE=function(offset,noAssert){return _readFloat(this,offset,false,noAssert)};function _readDouble(buf,offset,littleEndian,noAssert){if(!noAssert){assert(typeof littleEndian==="boolean","missing or invalid endian");assert(offset+7<buf.length,"Trying to read beyond buffer length")}return ieee754.read(buf,offset,littleEndian,52,8)}Buffer.prototype.readDoubleLE=function(offset,noAssert){return _readDouble(this,offset,true,noAssert)};Buffer.prototype.readDoubleBE=function(offset,noAssert){return _readDouble(this,offset,false,noAssert)};Buffer.prototype.writeUInt8=function(value,offset,noAssert){if(!noAssert){assert(value!==undefined&&value!==null,"missing value");assert(offset!==undefined&&offset!==null,"missing offset");assert(offset<this.length,"trying to write beyond buffer length");verifuint(value,255)}if(offset>=this.length)return;this[offset]=value};function _writeUInt16(buf,value,offset,littleEndian,noAssert){if(!noAssert){assert(value!==undefined&&value!==null,"missing value");assert(typeof littleEndian==="boolean","missing or invalid endian");assert(offset!==undefined&&offset!==null,"missing offset");assert(offset+1<buf.length,"trying to write beyond buffer length");verifuint(value,65535)}var len=buf.length;if(offset>=len)return;for(var i=0,j=Math.min(len-offset,2);i<j;i++){buf[offset+i]=(value&255<<8*(littleEndian?i:1-i))>>>(littleEndian?i:1-i)*8}}Buffer.prototype.writeUInt16LE=function(value,offset,noAssert){_writeUInt16(this,value,offset,true,noAssert)};Buffer.prototype.writeUInt16BE=function(value,offset,noAssert){_writeUInt16(this,value,offset,false,noAssert)};function _writeUInt32(buf,value,offset,littleEndian,noAssert){if(!noAssert){assert(value!==undefined&&value!==null,"missing value");assert(typeof littleEndian==="boolean","missing or invalid endian");assert(offset!==undefined&&offset!==null,"missing offset");assert(offset+3<buf.length,"trying to write beyond buffer length");verifuint(value,4294967295)}var len=buf.length;if(offset>=len)return;for(var i=0,j=Math.min(len-offset,4);i<j;i++){buf[offset+i]=value>>>(littleEndian?i:3-i)*8&255}}Buffer.prototype.writeUInt32LE=function(value,offset,noAssert){_writeUInt32(this,value,offset,true,noAssert)};Buffer.prototype.writeUInt32BE=function(value,offset,noAssert){_writeUInt32(this,value,offset,false,noAssert)};Buffer.prototype.writeInt8=function(value,offset,noAssert){if(!noAssert){assert(value!==undefined&&value!==null,"missing value");assert(offset!==undefined&&offset!==null,"missing offset");assert(offset<this.length,"Trying to write beyond buffer length");verifsint(value,127,-128)}if(offset>=this.length)return;if(value>=0)this.writeUInt8(value,offset,noAssert);else this.writeUInt8(255+value+1,offset,noAssert)};function _writeInt16(buf,value,offset,littleEndian,noAssert){if(!noAssert){assert(value!==undefined&&value!==null,"missing value");assert(typeof littleEndian==="boolean","missing or invalid endian");assert(offset!==undefined&&offset!==null,"missing offset");assert(offset+1<buf.length,"Trying to write beyond buffer length");verifsint(value,32767,-32768)}var len=buf.length;if(offset>=len)return;if(value>=0)_writeUInt16(buf,value,offset,littleEndian,noAssert);else _writeUInt16(buf,65535+value+1,offset,littleEndian,noAssert)}Buffer.prototype.writeInt16LE=function(value,offset,noAssert){_writeInt16(this,value,offset,true,noAssert)};Buffer.prototype.writeInt16BE=function(value,offset,noAssert){_writeInt16(this,value,offset,false,noAssert)};function _writeInt32(buf,value,offset,littleEndian,noAssert){if(!noAssert){assert(value!==undefined&&value!==null,"missing value");assert(typeof littleEndian==="boolean","missing or invalid endian");assert(offset!==undefined&&offset!==null,"missing offset");assert(offset+3<buf.length,"Trying to write beyond buffer length");verifsint(value,2147483647,-2147483648)}var len=buf.length;if(offset>=len)return;if(value>=0)_writeUInt32(buf,value,offset,littleEndian,noAssert);else _writeUInt32(buf,4294967295+value+1,offset,littleEndian,noAssert)}Buffer.prototype.writeInt32LE=function(value,offset,noAssert){_writeInt32(this,value,offset,true,noAssert)};Buffer.prototype.writeInt32BE=function(value,offset,noAssert){_writeInt32(this,value,offset,false,noAssert)};function _writeFloat(buf,value,offset,littleEndian,noAssert){if(!noAssert){assert(value!==undefined&&value!==null,"missing value");assert(typeof littleEndian==="boolean","missing or invalid endian");assert(offset!==undefined&&offset!==null,"missing offset");assert(offset+3<buf.length,"Trying to write beyond buffer length");verifIEEE754(value,3.4028234663852886e38,-3.4028234663852886e38)}var len=buf.length;if(offset>=len)return;ieee754.write(buf,value,offset,littleEndian,23,4)}Buffer.prototype.writeFloatLE=function(value,offset,noAssert){_writeFloat(this,value,offset,true,noAssert)};Buffer.prototype.writeFloatBE=function(value,offset,noAssert){_writeFloat(this,value,offset,false,noAssert)};function _writeDouble(buf,value,offset,littleEndian,noAssert){if(!noAssert){assert(value!==undefined&&value!==null,"missing value");assert(typeof littleEndian==="boolean","missing or invalid endian");assert(offset!==undefined&&offset!==null,"missing offset");assert(offset+7<buf.length,"Trying to write beyond buffer length");verifIEEE754(value,1.7976931348623157e308,-1.7976931348623157e308)}var len=buf.length;if(offset>=len)return;ieee754.write(buf,value,offset,littleEndian,52,8)}Buffer.prototype.writeDoubleLE=function(value,offset,noAssert){_writeDouble(this,value,offset,true,noAssert)};Buffer.prototype.writeDoubleBE=function(value,offset,noAssert){_writeDouble(this,value,offset,false,noAssert)};Buffer.prototype.fill=function(value,start,end){if(!value)value=0;if(!start)start=0;if(!end)end=this.length;if(typeof value==="string"){value=value.charCodeAt(0)}assert(typeof value==="number"&&!isNaN(value),"value is not a number");assert(end>=start,"end < start");if(end===start)return;if(this.length===0)return;assert(start>=0&&start<this.length,"start out of bounds");assert(end>=0&&end<=this.length,"end out of bounds");for(var i=start;i<end;i++){this[i]=value}};Buffer.prototype.inspect=function(){var out=[];var len=this.length;for(var i=0;i<len;i++){out[i]=toHex(this[i]);if(i===exports.INSPECT_MAX_BYTES){out[i+1]="...";break}}return"<Buffer "+out.join(" ")+">"};Buffer.prototype.toArrayBuffer=function(){if(typeof Uint8Array!=="undefined"){if(Buffer._useTypedArrays){return new Buffer(this).buffer}else{var buf=new Uint8Array(this.length);for(var i=0,len=buf.length;i<len;i+=1)buf[i]=this[i];return buf.buffer}}else{throw new Error("Buffer.toArrayBuffer not supported in this browser")}};function stringtrim(str){if(str.trim)return str.trim();return str.replace(/^\s+|\s+$/g,"")}var BP=Buffer.prototype;Buffer._augment=function(arr){arr._isBuffer=true;arr._get=arr.get;arr._set=arr.set;arr.get=BP.get;arr.set=BP.set;arr.write=BP.write;arr.toString=BP.toString;arr.toLocaleString=BP.toString;arr.toJSON=BP.toJSON;arr.copy=BP.copy;arr.slice=BP.slice;arr.readUInt8=BP.readUInt8;arr.readUInt16LE=BP.readUInt16LE;arr.readUInt16BE=BP.readUInt16BE;arr.readUInt32LE=BP.readUInt32LE;arr.readUInt32BE=BP.readUInt32BE;arr.readInt8=BP.readInt8;arr.readInt16LE=BP.readInt16LE;arr.readInt16BE=BP.readInt16BE;arr.readInt32LE=BP.readInt32LE;arr.readInt32BE=BP.readInt32BE;arr.readFloatLE=BP.readFloatLE;arr.readFloatBE=BP.readFloatBE;arr.readDoubleLE=BP.readDoubleLE;arr.readDoubleBE=BP.readDoubleBE;arr.writeUInt8=BP.writeUInt8;arr.writeUInt16LE=BP.writeUInt16LE;arr.writeUInt16BE=BP.writeUInt16BE;arr.writeUInt32LE=BP.writeUInt32LE;arr.writeUInt32BE=BP.writeUInt32BE;
arr.writeInt8=BP.writeInt8;arr.writeInt16LE=BP.writeInt16LE;arr.writeInt16BE=BP.writeInt16BE;arr.writeInt32LE=BP.writeInt32LE;arr.writeInt32BE=BP.writeInt32BE;arr.writeFloatLE=BP.writeFloatLE;arr.writeFloatBE=BP.writeFloatBE;arr.writeDoubleLE=BP.writeDoubleLE;arr.writeDoubleBE=BP.writeDoubleBE;arr.fill=BP.fill;arr.inspect=BP.inspect;arr.toArrayBuffer=BP.toArrayBuffer;return arr};function clamp(index,len,defaultValue){if(typeof index!=="number")return defaultValue;index=~~index;if(index>=len)return len;if(index>=0)return index;index+=len;if(index>=0)return index;return 0}function coerce(length){length=~~Math.ceil(+length);return length<0?0:length}function isArray(subject){return(Array.isArray||function(subject){return Object.prototype.toString.call(subject)==="[object Array]"})(subject)}function isArrayish(subject){return isArray(subject)||Buffer.isBuffer(subject)||subject&&typeof subject==="object"&&typeof subject.length==="number"}function toHex(n){if(n<16)return"0"+n.toString(16);return n.toString(16)}function utf8ToBytes(str){var byteArray=[];for(var i=0;i<str.length;i++){var b=str.charCodeAt(i);if(b<=127)byteArray.push(str.charCodeAt(i));else{var start=i;if(b>=55296&&b<=57343)i++;var h=encodeURIComponent(str.slice(start,i+1)).substr(1).split("%");for(var j=0;j<h.length;j++)byteArray.push(parseInt(h[j],16))}}return byteArray}function asciiToBytes(str){var byteArray=[];for(var i=0;i<str.length;i++){byteArray.push(str.charCodeAt(i)&255)}return byteArray}function utf16leToBytes(str){var c,hi,lo;var byteArray=[];for(var i=0;i<str.length;i++){c=str.charCodeAt(i);hi=c>>8;lo=c%256;byteArray.push(lo);byteArray.push(hi)}return byteArray}function base64ToBytes(str){return base64.toByteArray(str)}function blitBuffer(src,dst,offset,length){var pos;for(var i=0;i<length;i++){if(i+offset>=dst.length||i>=src.length)break;dst[i+offset]=src[i]}return i}function decodeUtf8Char(str){try{return decodeURIComponent(str)}catch(err){return String.fromCharCode(65533)}}function verifuint(value,max){assert(typeof value==="number","cannot write a non-number as a number");assert(value>=0,"specified a negative value for writing an unsigned value");assert(value<=max,"value is larger than maximum value for type");assert(Math.floor(value)===value,"value has a fractional component")}function verifsint(value,max,min){assert(typeof value==="number","cannot write a non-number as a number");assert(value<=max,"value larger than maximum allowed value");assert(value>=min,"value smaller than minimum allowed value");assert(Math.floor(value)===value,"value has a fractional component")}function verifIEEE754(value,max,min){assert(typeof value==="number","cannot write a non-number as a number");assert(value<=max,"value larger than maximum allowed value");assert(value>=min,"value smaller than minimum allowed value")}function assert(test,message){if(!test)throw new Error(message||"Failed assertion")}},{"base64-js":12,ieee754:13}],12:[function(require,module,exports){var lookup="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";(function(exports){"use strict";var Arr=typeof Uint8Array!=="undefined"?Uint8Array:Array;var PLUS="+".charCodeAt(0);var SLASH="/".charCodeAt(0);var NUMBER="0".charCodeAt(0);var LOWER="a".charCodeAt(0);var UPPER="A".charCodeAt(0);function decode(elt){var code=elt.charCodeAt(0);if(code===PLUS)return 62;if(code===SLASH)return 63;if(code<NUMBER)return-1;if(code<NUMBER+10)return code-NUMBER+26+26;if(code<UPPER+26)return code-UPPER;if(code<LOWER+26)return code-LOWER+26}function b64ToByteArray(b64){var i,j,l,tmp,placeHolders,arr;if(b64.length%4>0){throw new Error("Invalid string. Length must be a multiple of 4")}var len=b64.length;placeHolders="="===b64.charAt(len-2)?2:"="===b64.charAt(len-1)?1:0;arr=new Arr(b64.length*3/4-placeHolders);l=placeHolders>0?b64.length-4:b64.length;var L=0;function push(v){arr[L++]=v}for(i=0,j=0;i<l;i+=4,j+=3){tmp=decode(b64.charAt(i))<<18|decode(b64.charAt(i+1))<<12|decode(b64.charAt(i+2))<<6|decode(b64.charAt(i+3));push((tmp&16711680)>>16);push((tmp&65280)>>8);push(tmp&255)}if(placeHolders===2){tmp=decode(b64.charAt(i))<<2|decode(b64.charAt(i+1))>>4;push(tmp&255)}else if(placeHolders===1){tmp=decode(b64.charAt(i))<<10|decode(b64.charAt(i+1))<<4|decode(b64.charAt(i+2))>>2;push(tmp>>8&255);push(tmp&255)}return arr}function uint8ToBase64(uint8){var i,extraBytes=uint8.length%3,output="",temp,length;function encode(num){return lookup.charAt(num)}function tripletToBase64(num){return encode(num>>18&63)+encode(num>>12&63)+encode(num>>6&63)+encode(num&63)}for(i=0,length=uint8.length-extraBytes;i<length;i+=3){temp=(uint8[i]<<16)+(uint8[i+1]<<8)+uint8[i+2];output+=tripletToBase64(temp)}switch(extraBytes){case 1:temp=uint8[uint8.length-1];output+=encode(temp>>2);output+=encode(temp<<4&63);output+="==";break;case 2:temp=(uint8[uint8.length-2]<<8)+uint8[uint8.length-1];output+=encode(temp>>10);output+=encode(temp>>4&63);output+=encode(temp<<2&63);output+="=";break}return output}exports.toByteArray=b64ToByteArray;exports.fromByteArray=uint8ToBase64})(typeof exports==="undefined"?this.base64js={}:exports)},{}],13:[function(require,module,exports){exports.read=function(buffer,offset,isLE,mLen,nBytes){var e,m,eLen=nBytes*8-mLen-1,eMax=(1<<eLen)-1,eBias=eMax>>1,nBits=-7,i=isLE?nBytes-1:0,d=isLE?-1:1,s=buffer[offset+i];i+=d;e=s&(1<<-nBits)-1;s>>=-nBits;nBits+=eLen;for(;nBits>0;e=e*256+buffer[offset+i],i+=d,nBits-=8);m=e&(1<<-nBits)-1;e>>=-nBits;nBits+=mLen;for(;nBits>0;m=m*256+buffer[offset+i],i+=d,nBits-=8);if(e===0){e=1-eBias}else if(e===eMax){return m?NaN:(s?-1:1)*Infinity}else{m=m+Math.pow(2,mLen);e=e-eBias}return(s?-1:1)*m*Math.pow(2,e-mLen)};exports.write=function(buffer,value,offset,isLE,mLen,nBytes){var e,m,c,eLen=nBytes*8-mLen-1,eMax=(1<<eLen)-1,eBias=eMax>>1,rt=mLen===23?Math.pow(2,-24)-Math.pow(2,-77):0,i=isLE?0:nBytes-1,d=isLE?1:-1,s=value<0||value===0&&1/value<0?1:0;value=Math.abs(value);if(isNaN(value)||value===Infinity){m=isNaN(value)?1:0;e=eMax}else{e=Math.floor(Math.log(value)/Math.LN2);if(value*(c=Math.pow(2,-e))<1){e--;c*=2}if(e+eBias>=1){value+=rt/c}else{value+=rt*Math.pow(2,1-eBias)}if(value*c>=2){e++;c/=2}if(e+eBias>=eMax){m=0;e=eMax}else if(e+eBias>=1){m=(value*c-1)*Math.pow(2,mLen);e=e+eBias}else{m=value*Math.pow(2,eBias-1)*Math.pow(2,mLen);e=0}}for(;mLen>=8;buffer[offset+i]=m&255,i+=d,m/=256,mLen-=8);e=e<<mLen|m;eLen+=mLen;for(;eLen>0;buffer[offset+i]=e&255,i+=d,e/=256,eLen-=8);buffer[offset+i-d]|=s*128}},{}],14:[function(require,module,exports){function EventEmitter(){this._events=this._events||{};this._maxListeners=this._maxListeners||undefined}module.exports=EventEmitter;EventEmitter.EventEmitter=EventEmitter;EventEmitter.prototype._events=undefined;EventEmitter.prototype._maxListeners=undefined;EventEmitter.defaultMaxListeners=10;EventEmitter.prototype.setMaxListeners=function(n){if(!isNumber(n)||n<0||isNaN(n))throw TypeError("n must be a positive number");this._maxListeners=n;return this};EventEmitter.prototype.emit=function(type){var er,handler,len,args,i,listeners;if(!this._events)this._events={};if(type==="error"){if(!this._events.error||isObject(this._events.error)&&!this._events.error.length){er=arguments[1];if(er instanceof Error){throw er}throw TypeError('Uncaught, unspecified "error" event.')}}handler=this._events[type];if(isUndefined(handler))return false;if(isFunction(handler)){switch(arguments.length){case 1:handler.call(this);break;case 2:handler.call(this,arguments[1]);break;case 3:handler.call(this,arguments[1],arguments[2]);break;default:len=arguments.length;args=new Array(len-1);for(i=1;i<len;i++)args[i-1]=arguments[i];handler.apply(this,args)}}else if(isObject(handler)){len=arguments.length;args=new Array(len-1);for(i=1;i<len;i++)args[i-1]=arguments[i];listeners=handler.slice();len=listeners.length;for(i=0;i<len;i++)listeners[i].apply(this,args)}return true};EventEmitter.prototype.addListener=function(type,listener){var m;if(!isFunction(listener))throw TypeError("listener must be a function");if(!this._events)this._events={};if(this._events.newListener)this.emit("newListener",type,isFunction(listener.listener)?listener.listener:listener);if(!this._events[type])this._events[type]=listener;else if(isObject(this._events[type]))this._events[type].push(listener);else this._events[type]=[this._events[type],listener];if(isObject(this._events[type])&&!this._events[type].warned){var m;if(!isUndefined(this._maxListeners)){m=this._maxListeners}else{m=EventEmitter.defaultMaxListeners}if(m&&m>0&&this._events[type].length>m){this._events[type].warned=true;console.error("(node) warning: possible EventEmitter memory "+"leak detected. %d listeners added. "+"Use emitter.setMaxListeners() to increase limit.",this._events[type].length);if(typeof console.trace==="function"){console.trace()}}}return this};EventEmitter.prototype.on=EventEmitter.prototype.addListener;EventEmitter.prototype.once=function(type,listener){if(!isFunction(listener))throw TypeError("listener must be a function");var fired=false;function g(){this.removeListener(type,g);if(!fired){fired=true;listener.apply(this,arguments)}}g.listener=listener;this.on(type,g);return this};EventEmitter.prototype.removeListener=function(type,listener){var list,position,length,i;if(!isFunction(listener))throw TypeError("listener must be a function");if(!this._events||!this._events[type])return this;list=this._events[type];length=list.length;position=-1;if(list===listener||isFunction(list.listener)&&list.listener===listener){delete this._events[type];if(this._events.removeListener)this.emit("removeListener",type,listener)}else if(isObject(list)){for(i=length;i-->0;){if(list[i]===listener||list[i].listener&&list[i].listener===listener){position=i;break}}if(position<0)return this;if(list.length===1){list.length=0;delete this._events[type]}else{list.splice(position,1)}if(this._events.removeListener)this.emit("removeListener",type,listener)}return this};EventEmitter.prototype.removeAllListeners=function(type){var key,listeners;if(!this._events)return this;if(!this._events.removeListener){if(arguments.length===0)this._events={};else if(this._events[type])delete this._events[type];return this}if(arguments.length===0){for(key in this._events){if(key==="removeListener")continue;this.removeAllListeners(key)}this.removeAllListeners("removeListener");this._events={};return this}listeners=this._events[type];if(isFunction(listeners)){this.removeListener(type,listeners)}else{while(listeners.length)this.removeListener(type,listeners[listeners.length-1])}delete this._events[type];return this};EventEmitter.prototype.listeners=function(type){var ret;if(!this._events||!this._events[type])ret=[];else if(isFunction(this._events[type]))ret=[this._events[type]];else ret=this._events[type].slice();return ret};EventEmitter.listenerCount=function(emitter,type){var ret;if(!emitter._events||!emitter._events[type])ret=0;else if(isFunction(emitter._events[type]))ret=1;else ret=emitter._events[type].length;return ret};function isFunction(arg){return typeof arg==="function"}function isNumber(arg){return typeof arg==="number"}function isObject(arg){return typeof arg==="object"&&arg!==null}function isUndefined(arg){return arg===void 0}},{}],15:[function(require,module,exports){var http=module.exports;var EventEmitter=require("events").EventEmitter;var Request=require("./lib/request");var url=require("url");http.request=function(params,cb){if(typeof params==="string"){params=url.parse(params)}if(!params)params={};if(!params.host&&!params.port){params.port=parseInt(window.location.port,10)}if(!params.host&&params.hostname){params.host=params.hostname}if(!params.scheme)params.scheme=window.location.protocol.split(":")[0];if(!params.host){params.host=window.location.hostname||window.location.host}if(/:/.test(params.host)){if(!params.port){params.port=params.host.split(":")[1]}params.host=params.host.split(":")[0]}if(!params.port)params.port=params.scheme=="https"?443:80;var req=new Request(new xhrHttp,params);if(cb)req.on("response",cb);return req};http.get=function(params,cb){params.method="GET";var req=http.request(params,cb);req.end();return req};http.Agent=function(){};http.Agent.defaultMaxSockets=4;var xhrHttp=function(){if(typeof window==="undefined"){throw new Error("no window object present")}else if(window.XMLHttpRequest){return window.XMLHttpRequest}else if(window.ActiveXObject){var axs=["Msxml2.XMLHTTP.6.0","Msxml2.XMLHTTP.3.0","Microsoft.XMLHTTP"];for(var i=0;i<axs.length;i++){try{var ax=new window.ActiveXObject(axs[i]);return function(){if(ax){var ax_=ax;ax=null;return ax_}else{return new window.ActiveXObject(axs[i])}}}catch(e){}}throw new Error("ajax not supported in this browser")}else{throw new Error("ajax not supported in this browser")}}();http.STATUS_CODES={100:"Continue",101:"Switching Protocols",102:"Processing",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",300:"Multiple Choices",301:"Moved Permanently",302:"Moved Temporarily",303:"See Other",304:"Not Modified",305:"Use Proxy",307:"Temporary Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Time-out",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Request Entity Too Large",414:"Request-URI Too Large",415:"Unsupported Media Type",416:"Requested Range Not Satisfiable",417:"Expectation Failed",418:"I'm a teapot",422:"Unprocessable Entity",423:"Locked",424:"Failed Dependency",425:"Unordered Collection",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Request Header Fields Too Large",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Time-out",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",509:"Bandwidth Limit Exceeded",510:"Not Extended",511:"Network Authentication Required"}},{"./lib/request":16,events:14,url:34}],16:[function(require,module,exports){var Stream=require("stream");var Response=require("./response");var Base64=require("Base64");var inherits=require("inherits");var Request=module.exports=function(xhr,params){var self=this;self.writable=true;self.xhr=xhr;self.body=[];self.uri=(params.scheme||"http")+"://"+params.host+(params.port?":"+params.port:"")+(params.path||"/");if(typeof params.withCredentials==="undefined"){params.withCredentials=true}try{xhr.withCredentials=params.withCredentials}catch(e){}xhr.open(params.method||"GET",self.uri,true);self._headers={};if(params.headers){var keys=objectKeys(params.headers);for(var i=0;i<keys.length;i++){var key=keys[i];if(!self.isSafeRequestHeader(key))continue;var value=params.headers[key];self.setHeader(key,value)}}if(params.auth){this.setHeader("Authorization","Basic "+Base64.btoa(params.auth))}var res=new Response;res.on("close",function(){self.emit("close")});res.on("ready",function(){self.emit("response",res)});xhr.onreadystatechange=function(){if(xhr.__aborted)return;res.handle(xhr)}};inherits(Request,Stream);Request.prototype.setHeader=function(key,value){this._headers[key.toLowerCase()]=value};Request.prototype.getHeader=function(key){return this._headers[key.toLowerCase()]};Request.prototype.removeHeader=function(key){delete this._headers[key.toLowerCase()]};Request.prototype.write=function(s){this.body.push(s)};Request.prototype.destroy=function(s){this.xhr.__aborted=true;this.xhr.abort();this.emit("close")};Request.prototype.end=function(s){if(s!==undefined)this.body.push(s);var keys=objectKeys(this._headers);for(var i=0;i<keys.length;i++){var key=keys[i];var value=this._headers[key];if(isArray(value)){for(var j=0;j<value.length;j++){this.xhr.setRequestHeader(key,value[j])}}else this.xhr.setRequestHeader(key,value)}if(this.body.length===0){this.xhr.send("")}else if(typeof this.body[0]==="string"){this.xhr.send(this.body.join(""))}else if(isArray(this.body[0])){var body=[];for(var i=0;i<this.body.length;i++){body.push.apply(body,this.body[i])}this.xhr.send(body)}else if(/Array/.test(Object.prototype.toString.call(this.body[0]))){var len=0;for(var i=0;i<this.body.length;i++){len+=this.body[i].length}var body=new this.body[0].constructor(len);var k=0;for(var i=0;i<this.body.length;i++){var b=this.body[i];for(var j=0;j<b.length;j++){body[k++]=b[j]}}this.xhr.send(body)}else{var body="";for(var i=0;i<this.body.length;i++){body+=this.body[i].toString()}this.xhr.send(body)}};Request.unsafeHeaders=["accept-charset","accept-encoding","access-control-request-headers","access-control-request-method","connection","content-length","cookie","cookie2","content-transfer-encoding","date","expect","host","keep-alive","origin","referer","te","trailer","transfer-encoding","upgrade","user-agent","via"];Request.prototype.isSafeRequestHeader=function(headerName){if(!headerName)return false;return indexOf(Request.unsafeHeaders,headerName.toLowerCase())===-1};var objectKeys=Object.keys||function(obj){var keys=[];for(var key in obj)keys.push(key);return keys};var isArray=Array.isArray||function(xs){return Object.prototype.toString.call(xs)==="[object Array]"};var indexOf=function(xs,x){if(xs.indexOf)return xs.indexOf(x);for(var i=0;i<xs.length;i++){if(xs[i]===x)return i}return-1}},{"./response":17,Base64:18,inherits:20,stream:27}],17:[function(require,module,exports){var Stream=require("stream");var util=require("util");var Response=module.exports=function(res){this.offset=0;this.readable=true};util.inherits(Response,Stream);var capable={streaming:true,status2:true};function parseHeaders(res){var lines=res.getAllResponseHeaders().split(/\r?\n/);var headers={};for(var i=0;i<lines.length;i++){var line=lines[i];if(line==="")continue;var m=line.match(/^([^:]+):\s*(.*)/);if(m){var key=m[1].toLowerCase(),value=m[2];if(headers[key]!==undefined){if(isArray(headers[key])){headers[key].push(value)}else{headers[key]=[headers[key],value]}}else{headers[key]=value}}else{headers[line]=true}}return headers}Response.prototype.getResponse=function(xhr){var respType=String(xhr.responseType).toLowerCase();if(respType==="blob")return xhr.responseBlob||xhr.response;if(respType==="arraybuffer")return xhr.response;return xhr.responseText};Response.prototype.getHeader=function(key){return this.headers[key.toLowerCase()]};Response.prototype.handle=function(res){if(res.readyState===2&&capable.status2){try{this.statusCode=res.status;this.headers=parseHeaders(res)}catch(err){capable.status2=false}if(capable.status2){this.emit("ready")}}else if(capable.streaming&&res.readyState===3){try{if(!this.statusCode){this.statusCode=res.status;this.headers=parseHeaders(res);this.emit("ready")}}catch(err){}try{this._emitData(res)}catch(err){capable.streaming=false}}else if(res.readyState===4){if(!this.statusCode){this.statusCode=res.status;this.emit("ready")}this._emitData(res);if(res.error){this.emit("error",this.getResponse(res))}else this.emit("end");this.emit("close")}};Response.prototype._emitData=function(res){var respBody=this.getResponse(res);if(respBody.toString().match(/ArrayBuffer/)){this.emit("data",new Uint8Array(respBody,this.offset));this.offset=respBody.byteLength;return}if(respBody.length>this.offset){this.emit("data",respBody.slice(this.offset));this.offset=respBody.length}};var isArray=Array.isArray||function(xs){return Object.prototype.toString.call(xs)==="[object Array]"}},{stream:27,util:36}],18:[function(require,module,exports){(function(){var object=typeof exports!="undefined"?exports:this;var chars="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function InvalidCharacterError(message){this.message=message}InvalidCharacterError.prototype=new Error;InvalidCharacterError.prototype.name="InvalidCharacterError";object.btoa||(object.btoa=function(input){for(var block,charCode,idx=0,map=chars,output="";input.charAt(idx|0)||(map="=",idx%1);output+=map.charAt(63&block>>8-idx%1*8)){charCode=input.charCodeAt(idx+=3/4);if(charCode>255){throw new InvalidCharacterError("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.")}block=block<<8|charCode}return output});object.atob||(object.atob=function(input){input=input.replace(/=+$/,"");if(input.length%4==1){throw new InvalidCharacterError("'atob' failed: The string to be decoded is not correctly encoded.")}for(var bc=0,bs,buffer,idx=0,output="";buffer=input.charAt(idx++);~buffer&&(bs=bc%4?bs*64+buffer:buffer,bc++%4)?output+=String.fromCharCode(255&bs>>(-2*bc&6)):0){buffer=chars.indexOf(buffer)}return output})})()},{}],19:[function(require,module,exports){var http=require("http");var https=module.exports;for(var key in http){if(http.hasOwnProperty(key))https[key]=http[key]}https.request=function(params,cb){if(!params)params={};params.scheme="https";return http.request.call(this,params,cb)}},{http:15}],20:[function(require,module,exports){module.exports=require(5)},{}],21:[function(require,module,exports){var process=module.exports={};process.nextTick=function(){var canSetImmediate=typeof window!=="undefined"&&window.setImmediate;var canPost=typeof window!=="undefined"&&window.postMessage&&window.addEventListener;if(canSetImmediate){return function(f){return window.setImmediate(f)}}if(canPost){var queue=[];window.addEventListener("message",function(ev){var source=ev.source;if((source===window||source===null)&&ev.data==="process-tick"){ev.stopPropagation();if(queue.length>0){var fn=queue.shift();fn()}}},true);return function nextTick(fn){queue.push(fn);window.postMessage("process-tick","*")}}return function nextTick(fn){setTimeout(fn,0)}}();process.title="browser";process.browser=true;process.env={};process.argv=[];function noop(){}process.on=noop;process.addListener=noop;process.once=noop;process.off=noop;process.removeListener=noop;process.removeAllListeners=noop;process.emit=noop;process.binding=function(name){throw new Error("process.binding is not supported")};process.cwd=function(){return"/"};process.chdir=function(dir){throw new Error("process.chdir is not supported")}},{}],22:[function(require,module,exports){(function(global){(function(root){var freeExports=typeof exports=="object"&&exports;var freeModule=typeof module=="object"&&module&&module.exports==freeExports&&module;var freeGlobal=typeof global=="object"&&global;if(freeGlobal.global===freeGlobal||freeGlobal.window===freeGlobal){root=freeGlobal}var punycode,maxInt=2147483647,base=36,tMin=1,tMax=26,skew=38,damp=700,initialBias=72,initialN=128,delimiter="-",regexPunycode=/^xn--/,regexNonASCII=/[^ -~]/,regexSeparators=/\x2E|\u3002|\uFF0E|\uFF61/g,errors={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},baseMinusTMin=base-tMin,floor=Math.floor,stringFromCharCode=String.fromCharCode,key;function error(type){throw RangeError(errors[type])}function map(array,fn){var length=array.length;while(length--){array[length]=fn(array[length])}return array}function mapDomain(string,fn){return map(string.split(regexSeparators),fn).join(".")}function ucs2decode(string){var output=[],counter=0,length=string.length,value,extra;while(counter<length){value=string.charCodeAt(counter++);if(value>=55296&&value<=56319&&counter<length){extra=string.charCodeAt(counter++);if((extra&64512)==56320){output.push(((value&1023)<<10)+(extra&1023)+65536)}else{output.push(value);counter--}}else{output.push(value)}}return output}function ucs2encode(array){return map(array,function(value){var output="";if(value>65535){value-=65536;output+=stringFromCharCode(value>>>10&1023|55296);value=56320|value&1023}output+=stringFromCharCode(value);return output}).join("")}function basicToDigit(codePoint){if(codePoint-48<10){return codePoint-22}if(codePoint-65<26){return codePoint-65}if(codePoint-97<26){return codePoint-97}return base}function digitToBasic(digit,flag){return digit+22+75*(digit<26)-((flag!=0)<<5)}function adapt(delta,numPoints,firstTime){var k=0;delta=firstTime?floor(delta/damp):delta>>1;delta+=floor(delta/numPoints);for(;delta>baseMinusTMin*tMax>>1;k+=base){delta=floor(delta/baseMinusTMin)}return floor(k+(baseMinusTMin+1)*delta/(delta+skew))}function decode(input){var output=[],inputLength=input.length,out,i=0,n=initialN,bias=initialBias,basic,j,index,oldi,w,k,digit,t,baseMinusT;basic=input.lastIndexOf(delimiter);if(basic<0){basic=0}for(j=0;j<basic;++j){if(input.charCodeAt(j)>=128){error("not-basic")}output.push(input.charCodeAt(j))}for(index=basic>0?basic+1:0;index<inputLength;){for(oldi=i,w=1,k=base;;k+=base){if(index>=inputLength){error("invalid-input")}digit=basicToDigit(input.charCodeAt(index++));if(digit>=base||digit>floor((maxInt-i)/w)){error("overflow")}i+=digit*w;t=k<=bias?tMin:k>=bias+tMax?tMax:k-bias;if(digit<t){break}baseMinusT=base-t;if(w>floor(maxInt/baseMinusT)){error("overflow")}w*=baseMinusT}out=output.length+1;bias=adapt(i-oldi,out,oldi==0);if(floor(i/out)>maxInt-n){error("overflow")}n+=floor(i/out);i%=out;output.splice(i++,0,n)}return ucs2encode(output)}function encode(input){var n,delta,handledCPCount,basicLength,bias,j,m,q,k,t,currentValue,output=[],inputLength,handledCPCountPlusOne,baseMinusT,qMinusT;input=ucs2decode(input);inputLength=input.length;n=initialN;delta=0;bias=initialBias;for(j=0;j<inputLength;++j){currentValue=input[j];if(currentValue<128){output.push(stringFromCharCode(currentValue))}}handledCPCount=basicLength=output.length;if(basicLength){output.push(delimiter)}while(handledCPCount<inputLength){for(m=maxInt,j=0;j<inputLength;++j){currentValue=input[j];if(currentValue>=n&&currentValue<m){m=currentValue}}handledCPCountPlusOne=handledCPCount+1;if(m-n>floor((maxInt-delta)/handledCPCountPlusOne)){error("overflow")}delta+=(m-n)*handledCPCountPlusOne;n=m;for(j=0;j<inputLength;++j){currentValue=input[j];if(currentValue<n&&++delta>maxInt){error("overflow")}if(currentValue==n){for(q=delta,k=base;;k+=base){t=k<=bias?tMin:k>=bias+tMax?tMax:k-bias;if(q<t){break}qMinusT=q-t;baseMinusT=base-t;output.push(stringFromCharCode(digitToBasic(t+qMinusT%baseMinusT,0)));q=floor(qMinusT/baseMinusT)}output.push(stringFromCharCode(digitToBasic(q,0)));bias=adapt(delta,handledCPCountPlusOne,handledCPCount==basicLength);delta=0;++handledCPCount}}++delta;++n}return output.join("")}function toUnicode(domain){return mapDomain(domain,function(string){return regexPunycode.test(string)?decode(string.slice(4).toLowerCase()):string})}function toASCII(domain){return mapDomain(domain,function(string){return regexNonASCII.test(string)?"xn--"+encode(string):string})}punycode={version:"1.2.4",ucs2:{decode:ucs2decode,encode:ucs2encode},decode:decode,encode:encode,toASCII:toASCII,toUnicode:toUnicode};if(typeof define=="function"&&typeof define.amd=="object"&&define.amd){define("punycode",function(){return punycode})}else if(freeExports&&!freeExports.nodeType){if(freeModule){freeModule.exports=punycode}else{for(key in punycode){punycode.hasOwnProperty(key)&&(freeExports[key]=punycode[key])}}}else{root.punycode=punycode}})(this)}).call(this,typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],23:[function(require,module,exports){"use strict";function hasOwnProperty(obj,prop){return Object.prototype.hasOwnProperty.call(obj,prop)}module.exports=function(qs,sep,eq,options){sep=sep||"&";eq=eq||"=";var obj={};if(typeof qs!=="string"||qs.length===0){return obj}var regexp=/\+/g;qs=qs.split(sep);var maxKeys=1e3;if(options&&typeof options.maxKeys==="number"){maxKeys=options.maxKeys}var len=qs.length;if(maxKeys>0&&len>maxKeys){len=maxKeys}for(var i=0;i<len;++i){var x=qs[i].replace(regexp,"%20"),idx=x.indexOf(eq),kstr,vstr,k,v;if(idx>=0){kstr=x.substr(0,idx);vstr=x.substr(idx+1)}else{kstr=x;vstr=""}k=decodeURIComponent(kstr);v=decodeURIComponent(vstr);if(!hasOwnProperty(obj,k)){obj[k]=v}else if(isArray(obj[k])){obj[k].push(v)}else{obj[k]=[obj[k],v]}}return obj};var isArray=Array.isArray||function(xs){return Object.prototype.toString.call(xs)==="[object Array]"}},{}],24:[function(require,module,exports){"use strict";var stringifyPrimitive=function(v){switch(typeof v){case"string":return v;case"boolean":return v?"true":"false";case"number":return isFinite(v)?v:"";default:return""}};module.exports=function(obj,sep,eq,name){sep=sep||"&";eq=eq||"=";if(obj===null){obj=undefined}if(typeof obj==="object"){return map(objectKeys(obj),function(k){var ks=encodeURIComponent(stringifyPrimitive(k))+eq;if(isArray(obj[k])){return obj[k].map(function(v){return ks+encodeURIComponent(stringifyPrimitive(v))}).join(sep)}else{return ks+encodeURIComponent(stringifyPrimitive(obj[k]))}}).join(sep)}if(!name)return"";return encodeURIComponent(stringifyPrimitive(name))+eq+encodeURIComponent(stringifyPrimitive(obj))};var isArray=Array.isArray||function(xs){return Object.prototype.toString.call(xs)==="[object Array]"};function map(xs,f){if(xs.map)return xs.map(f);var res=[];for(var i=0;i<xs.length;i++){res.push(f(xs[i],i))}return res}var objectKeys=Object.keys||function(obj){var res=[];for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))res.push(key)}return res}},{}],25:[function(require,module,exports){"use strict";exports.decode=exports.parse=require("./decode");exports.encode=exports.stringify=require("./encode")},{"./decode":23,"./encode":24}],26:[function(require,module,exports){module.exports=Duplex;var inherits=require("inherits");var setImmediate=require("process/browser.js").nextTick;var Readable=require("./readable.js");var Writable=require("./writable.js");inherits(Duplex,Readable);Duplex.prototype.write=Writable.prototype.write;Duplex.prototype.end=Writable.prototype.end;Duplex.prototype._write=Writable.prototype._write;function Duplex(options){if(!(this instanceof Duplex))return new Duplex(options);Readable.call(this,options);Writable.call(this,options);if(options&&options.readable===false)this.readable=false;if(options&&options.writable===false)this.writable=false;this.allowHalfOpen=true;if(options&&options.allowHalfOpen===false)this.allowHalfOpen=false;this.once("end",onend)}function onend(){if(this.allowHalfOpen||this._writableState.ended)return;var self=this;setImmediate(function(){self.end()})}},{"./readable.js":30,"./writable.js":32,inherits:20,"process/browser.js":28}],27:[function(require,module,exports){module.exports=Stream;var EE=require("events").EventEmitter;var inherits=require("inherits");inherits(Stream,EE);Stream.Readable=require("./readable.js");Stream.Writable=require("./writable.js");Stream.Duplex=require("./duplex.js");Stream.Transform=require("./transform.js");Stream.PassThrough=require("./passthrough.js");Stream.Stream=Stream;function Stream(){EE.call(this)}Stream.prototype.pipe=function(dest,options){var source=this;function ondata(chunk){if(dest.writable){if(false===dest.write(chunk)&&source.pause){source.pause()}}}source.on("data",ondata);function ondrain(){if(source.readable&&source.resume){source.resume()}}dest.on("drain",ondrain);if(!dest._isStdio&&(!options||options.end!==false)){source.on("end",onend);source.on("close",onclose)}var didOnEnd=false;function onend(){if(didOnEnd)return;didOnEnd=true;dest.end()}function onclose(){if(didOnEnd)return;didOnEnd=true;if(typeof dest.destroy==="function")dest.destroy()}function onerror(er){cleanup();if(EE.listenerCount(this,"error")===0){throw er}}source.on("error",onerror);dest.on("error",onerror);function cleanup(){source.removeListener("data",ondata);dest.removeListener("drain",ondrain);source.removeListener("end",onend);source.removeListener("close",onclose);source.removeListener("error",onerror);dest.removeListener("error",onerror);source.removeListener("end",cleanup);source.removeListener("close",cleanup);dest.removeListener("close",cleanup)}source.on("end",cleanup);source.on("close",cleanup);dest.on("close",cleanup);dest.emit("pipe",source);return dest}},{"./duplex.js":26,"./passthrough.js":29,"./readable.js":30,"./transform.js":31,"./writable.js":32,events:14,inherits:20}],28:[function(require,module,exports){var process=module.exports={};
process.nextTick=function(){var canSetImmediate=typeof window!=="undefined"&&window.setImmediate;var canPost=typeof window!=="undefined"&&window.postMessage&&window.addEventListener;if(canSetImmediate){return function(f){return window.setImmediate(f)}}if(canPost){var queue=[];window.addEventListener("message",function(ev){var source=ev.source;if((source===window||source===null)&&ev.data==="process-tick"){ev.stopPropagation();if(queue.length>0){var fn=queue.shift();fn()}}},true);return function nextTick(fn){queue.push(fn);window.postMessage("process-tick","*")}}return function nextTick(fn){setTimeout(fn,0)}}();process.title="browser";process.browser=true;process.env={};process.argv=[];process.binding=function(name){throw new Error("process.binding is not supported")};process.cwd=function(){return"/"};process.chdir=function(dir){throw new Error("process.chdir is not supported")}},{}],29:[function(require,module,exports){module.exports=PassThrough;var Transform=require("./transform.js");var inherits=require("inherits");inherits(PassThrough,Transform);function PassThrough(options){if(!(this instanceof PassThrough))return new PassThrough(options);Transform.call(this,options)}PassThrough.prototype._transform=function(chunk,encoding,cb){cb(null,chunk)}},{"./transform.js":31,inherits:20}],30:[function(require,module,exports){(function(process){module.exports=Readable;Readable.ReadableState=ReadableState;var EE=require("events").EventEmitter;var Stream=require("./index.js");var Buffer=require("buffer").Buffer;var setImmediate=require("process/browser.js").nextTick;var StringDecoder;var inherits=require("inherits");inherits(Readable,Stream);function ReadableState(options,stream){options=options||{};var hwm=options.highWaterMark;this.highWaterMark=hwm||hwm===0?hwm:16*1024;this.highWaterMark=~~this.highWaterMark;this.buffer=[];this.length=0;this.pipes=null;this.pipesCount=0;this.flowing=false;this.ended=false;this.endEmitted=false;this.reading=false;this.calledRead=false;this.sync=true;this.needReadable=false;this.emittedReadable=false;this.readableListening=false;this.objectMode=!!options.objectMode;this.defaultEncoding=options.defaultEncoding||"utf8";this.ranOut=false;this.awaitDrain=0;this.readingMore=false;this.decoder=null;this.encoding=null;if(options.encoding){if(!StringDecoder)StringDecoder=require("string_decoder").StringDecoder;this.decoder=new StringDecoder(options.encoding);this.encoding=options.encoding}}function Readable(options){if(!(this instanceof Readable))return new Readable(options);this._readableState=new ReadableState(options,this);this.readable=true;Stream.call(this)}Readable.prototype.push=function(chunk,encoding){var state=this._readableState;if(typeof chunk==="string"&&!state.objectMode){encoding=encoding||state.defaultEncoding;if(encoding!==state.encoding){chunk=new Buffer(chunk,encoding);encoding=""}}return readableAddChunk(this,state,chunk,encoding,false)};Readable.prototype.unshift=function(chunk){var state=this._readableState;return readableAddChunk(this,state,chunk,"",true)};function readableAddChunk(stream,state,chunk,encoding,addToFront){var er=chunkInvalid(state,chunk);if(er){stream.emit("error",er)}else if(chunk===null||chunk===undefined){state.reading=false;if(!state.ended)onEofChunk(stream,state)}else if(state.objectMode||chunk&&chunk.length>0){if(state.ended&&!addToFront){var e=new Error("stream.push() after EOF");stream.emit("error",e)}else if(state.endEmitted&&addToFront){var e=new Error("stream.unshift() after end event");stream.emit("error",e)}else{if(state.decoder&&!addToFront&&!encoding)chunk=state.decoder.write(chunk);state.length+=state.objectMode?1:chunk.length;if(addToFront){state.buffer.unshift(chunk)}else{state.reading=false;state.buffer.push(chunk)}if(state.needReadable)emitReadable(stream);maybeReadMore(stream,state)}}else if(!addToFront){state.reading=false}return needMoreData(state)}function needMoreData(state){return!state.ended&&(state.needReadable||state.length<state.highWaterMark||state.length===0)}Readable.prototype.setEncoding=function(enc){if(!StringDecoder)StringDecoder=require("string_decoder").StringDecoder;this._readableState.decoder=new StringDecoder(enc);this._readableState.encoding=enc};var MAX_HWM=8388608;function roundUpToNextPowerOf2(n){if(n>=MAX_HWM){n=MAX_HWM}else{n--;for(var p=1;p<32;p<<=1)n|=n>>p;n++}return n}function howMuchToRead(n,state){if(state.length===0&&state.ended)return 0;if(state.objectMode)return n===0?0:1;if(isNaN(n)||n===null){if(state.flowing&&state.buffer.length)return state.buffer[0].length;else return state.length}if(n<=0)return 0;if(n>state.highWaterMark)state.highWaterMark=roundUpToNextPowerOf2(n);if(n>state.length){if(!state.ended){state.needReadable=true;return 0}else return state.length}return n}Readable.prototype.read=function(n){var state=this._readableState;state.calledRead=true;var nOrig=n;if(typeof n!=="number"||n>0)state.emittedReadable=false;if(n===0&&state.needReadable&&(state.length>=state.highWaterMark||state.ended)){emitReadable(this);return null}n=howMuchToRead(n,state);if(n===0&&state.ended){if(state.length===0)endReadable(this);return null}var doRead=state.needReadable;if(state.length-n<=state.highWaterMark)doRead=true;if(state.ended||state.reading)doRead=false;if(doRead){state.reading=true;state.sync=true;if(state.length===0)state.needReadable=true;this._read(state.highWaterMark);state.sync=false}if(doRead&&!state.reading)n=howMuchToRead(nOrig,state);var ret;if(n>0)ret=fromList(n,state);else ret=null;if(ret===null){state.needReadable=true;n=0}state.length-=n;if(state.length===0&&!state.ended)state.needReadable=true;if(state.ended&&!state.endEmitted&&state.length===0)endReadable(this);return ret};function chunkInvalid(state,chunk){var er=null;if(!Buffer.isBuffer(chunk)&&"string"!==typeof chunk&&chunk!==null&&chunk!==undefined&&!state.objectMode&&!er){er=new TypeError("Invalid non-string/buffer chunk")}return er}function onEofChunk(stream,state){if(state.decoder&&!state.ended){var chunk=state.decoder.end();if(chunk&&chunk.length){state.buffer.push(chunk);state.length+=state.objectMode?1:chunk.length}}state.ended=true;if(state.length>0)emitReadable(stream);else endReadable(stream)}function emitReadable(stream){var state=stream._readableState;state.needReadable=false;if(state.emittedReadable)return;state.emittedReadable=true;if(state.sync)setImmediate(function(){emitReadable_(stream)});else emitReadable_(stream)}function emitReadable_(stream){stream.emit("readable")}function maybeReadMore(stream,state){if(!state.readingMore){state.readingMore=true;setImmediate(function(){maybeReadMore_(stream,state)})}}function maybeReadMore_(stream,state){var len=state.length;while(!state.reading&&!state.flowing&&!state.ended&&state.length<state.highWaterMark){stream.read(0);if(len===state.length)break;else len=state.length}state.readingMore=false}Readable.prototype._read=function(n){this.emit("error",new Error("not implemented"))};Readable.prototype.pipe=function(dest,pipeOpts){var src=this;var state=this._readableState;switch(state.pipesCount){case 0:state.pipes=dest;break;case 1:state.pipes=[state.pipes,dest];break;default:state.pipes.push(dest);break}state.pipesCount+=1;var doEnd=(!pipeOpts||pipeOpts.end!==false)&&dest!==process.stdout&&dest!==process.stderr;var endFn=doEnd?onend:cleanup;if(state.endEmitted)setImmediate(endFn);else src.once("end",endFn);dest.on("unpipe",onunpipe);function onunpipe(readable){if(readable!==src)return;cleanup()}function onend(){dest.end()}var ondrain=pipeOnDrain(src);dest.on("drain",ondrain);function cleanup(){dest.removeListener("close",onclose);dest.removeListener("finish",onfinish);dest.removeListener("drain",ondrain);dest.removeListener("error",onerror);dest.removeListener("unpipe",onunpipe);src.removeListener("end",onend);src.removeListener("end",cleanup);if(!dest._writableState||dest._writableState.needDrain)ondrain()}var errListeners=EE.listenerCount(dest,"error");function onerror(er){unpipe();if(errListeners===0&&EE.listenerCount(dest,"error")===0)dest.emit("error",er)}dest.once("error",onerror);function onclose(){dest.removeListener("finish",onfinish);unpipe()}dest.once("close",onclose);function onfinish(){dest.removeListener("close",onclose);unpipe()}dest.once("finish",onfinish);function unpipe(){src.unpipe(dest)}dest.emit("pipe",src);if(!state.flowing){this.on("readable",pipeOnReadable);state.flowing=true;setImmediate(function(){flow(src)})}return dest};function pipeOnDrain(src){return function(){var dest=this;var state=src._readableState;state.awaitDrain--;if(state.awaitDrain===0)flow(src)}}function flow(src){var state=src._readableState;var chunk;state.awaitDrain=0;function write(dest,i,list){var written=dest.write(chunk);if(false===written){state.awaitDrain++}}while(state.pipesCount&&null!==(chunk=src.read())){if(state.pipesCount===1)write(state.pipes,0,null);else forEach(state.pipes,write);src.emit("data",chunk);if(state.awaitDrain>0)return}if(state.pipesCount===0){state.flowing=false;if(EE.listenerCount(src,"data")>0)emitDataEvents(src);return}state.ranOut=true}function pipeOnReadable(){if(this._readableState.ranOut){this._readableState.ranOut=false;flow(this)}}Readable.prototype.unpipe=function(dest){var state=this._readableState;if(state.pipesCount===0)return this;if(state.pipesCount===1){if(dest&&dest!==state.pipes)return this;if(!dest)dest=state.pipes;state.pipes=null;state.pipesCount=0;this.removeListener("readable",pipeOnReadable);state.flowing=false;if(dest)dest.emit("unpipe",this);return this}if(!dest){var dests=state.pipes;var len=state.pipesCount;state.pipes=null;state.pipesCount=0;this.removeListener("readable",pipeOnReadable);state.flowing=false;for(var i=0;i<len;i++)dests[i].emit("unpipe",this);return this}var i=indexOf(state.pipes,dest);if(i===-1)return this;state.pipes.splice(i,1);state.pipesCount-=1;if(state.pipesCount===1)state.pipes=state.pipes[0];dest.emit("unpipe",this);return this};Readable.prototype.on=function(ev,fn){var res=Stream.prototype.on.call(this,ev,fn);if(ev==="data"&&!this._readableState.flowing)emitDataEvents(this);if(ev==="readable"&&this.readable){var state=this._readableState;if(!state.readableListening){state.readableListening=true;state.emittedReadable=false;state.needReadable=true;if(!state.reading){this.read(0)}else if(state.length){emitReadable(this,state)}}}return res};Readable.prototype.addListener=Readable.prototype.on;Readable.prototype.resume=function(){emitDataEvents(this);this.read(0);this.emit("resume")};Readable.prototype.pause=function(){emitDataEvents(this,true);this.emit("pause")};function emitDataEvents(stream,startPaused){var state=stream._readableState;if(state.flowing){throw new Error("Cannot switch to old mode now.")}var paused=startPaused||false;var readable=false;stream.readable=true;stream.pipe=Stream.prototype.pipe;stream.on=stream.addListener=Stream.prototype.on;stream.on("readable",function(){readable=true;var c;while(!paused&&null!==(c=stream.read()))stream.emit("data",c);if(c===null){readable=false;stream._readableState.needReadable=true}});stream.pause=function(){paused=true;this.emit("pause")};stream.resume=function(){paused=false;if(readable)setImmediate(function(){stream.emit("readable")});else this.read(0);this.emit("resume")};stream.emit("readable")}Readable.prototype.wrap=function(stream){var state=this._readableState;var paused=false;var self=this;stream.on("end",function(){if(state.decoder&&!state.ended){var chunk=state.decoder.end();if(chunk&&chunk.length)self.push(chunk)}self.push(null)});stream.on("data",function(chunk){if(state.decoder)chunk=state.decoder.write(chunk);if(!chunk||!state.objectMode&&!chunk.length)return;var ret=self.push(chunk);if(!ret){paused=true;stream.pause()}});for(var i in stream){if(typeof stream[i]==="function"&&typeof this[i]==="undefined"){this[i]=function(method){return function(){return stream[method].apply(stream,arguments)}}(i)}}var events=["error","close","destroy","pause","resume"];forEach(events,function(ev){stream.on(ev,function(x){return self.emit.apply(self,ev,x)})});self._read=function(n){if(paused){paused=false;stream.resume()}};return self};Readable._fromList=fromList;function fromList(n,state){var list=state.buffer;var length=state.length;var stringMode=!!state.decoder;var objectMode=!!state.objectMode;var ret;if(list.length===0)return null;if(length===0)ret=null;else if(objectMode)ret=list.shift();else if(!n||n>=length){if(stringMode)ret=list.join("");else ret=Buffer.concat(list,length);list.length=0}else{if(n<list[0].length){var buf=list[0];ret=buf.slice(0,n);list[0]=buf.slice(n)}else if(n===list[0].length){ret=list.shift()}else{if(stringMode)ret="";else ret=new Buffer(n);var c=0;for(var i=0,l=list.length;i<l&&c<n;i++){var buf=list[0];var cpy=Math.min(n-c,buf.length);if(stringMode)ret+=buf.slice(0,cpy);else buf.copy(ret,c,0,cpy);if(cpy<buf.length)list[0]=buf.slice(cpy);else list.shift();c+=cpy}}}return ret}function endReadable(stream){var state=stream._readableState;if(state.length>0)throw new Error("endReadable called on non-empty stream");if(!state.endEmitted&&state.calledRead){state.ended=true;setImmediate(function(){if(!state.endEmitted&&state.length===0){state.endEmitted=true;stream.readable=false;stream.emit("end")}})}}function forEach(xs,f){for(var i=0,l=xs.length;i<l;i++){f(xs[i],i)}}function indexOf(xs,x){for(var i=0,l=xs.length;i<l;i++){if(xs[i]===x)return i}return-1}}).call(this,require("FWaASH"))},{"./index.js":27,FWaASH:21,buffer:11,events:14,inherits:20,"process/browser.js":28,string_decoder:33}],31:[function(require,module,exports){module.exports=Transform;var Duplex=require("./duplex.js");var inherits=require("inherits");inherits(Transform,Duplex);function TransformState(options,stream){this.afterTransform=function(er,data){return afterTransform(stream,er,data)};this.needTransform=false;this.transforming=false;this.writecb=null;this.writechunk=null}function afterTransform(stream,er,data){var ts=stream._transformState;ts.transforming=false;var cb=ts.writecb;if(!cb)return stream.emit("error",new Error("no writecb in Transform class"));ts.writechunk=null;ts.writecb=null;if(data!==null&&data!==undefined)stream.push(data);if(cb)cb(er);var rs=stream._readableState;rs.reading=false;if(rs.needReadable||rs.length<rs.highWaterMark){stream._read(rs.highWaterMark)}}function Transform(options){if(!(this instanceof Transform))return new Transform(options);Duplex.call(this,options);var ts=this._transformState=new TransformState(options,this);var stream=this;this._readableState.needReadable=true;this._readableState.sync=false;this.once("finish",function(){if("function"===typeof this._flush)this._flush(function(er){done(stream,er)});else done(stream)})}Transform.prototype.push=function(chunk,encoding){this._transformState.needTransform=false;return Duplex.prototype.push.call(this,chunk,encoding)};Transform.prototype._transform=function(chunk,encoding,cb){throw new Error("not implemented")};Transform.prototype._write=function(chunk,encoding,cb){var ts=this._transformState;ts.writecb=cb;ts.writechunk=chunk;ts.writeencoding=encoding;if(!ts.transforming){var rs=this._readableState;if(ts.needTransform||rs.needReadable||rs.length<rs.highWaterMark)this._read(rs.highWaterMark)}};Transform.prototype._read=function(n){var ts=this._transformState;if(ts.writechunk&&ts.writecb&&!ts.transforming){ts.transforming=true;this._transform(ts.writechunk,ts.writeencoding,ts.afterTransform)}else{ts.needTransform=true}};function done(stream,er){if(er)return stream.emit("error",er);var ws=stream._writableState;var rs=stream._readableState;var ts=stream._transformState;if(ws.length)throw new Error("calling transform done when ws.length != 0");if(ts.transforming)throw new Error("calling transform done when still transforming");return stream.push(null)}},{"./duplex.js":26,inherits:20}],32:[function(require,module,exports){module.exports=Writable;Writable.WritableState=WritableState;var isUint8Array=typeof Uint8Array!=="undefined"?function(x){return x instanceof Uint8Array}:function(x){return x&&x.constructor&&x.constructor.name==="Uint8Array"};var isArrayBuffer=typeof ArrayBuffer!=="undefined"?function(x){return x instanceof ArrayBuffer}:function(x){return x&&x.constructor&&x.constructor.name==="ArrayBuffer"};var inherits=require("inherits");var Stream=require("./index.js");var setImmediate=require("process/browser.js").nextTick;var Buffer=require("buffer").Buffer;inherits(Writable,Stream);function WriteReq(chunk,encoding,cb){this.chunk=chunk;this.encoding=encoding;this.callback=cb}function WritableState(options,stream){options=options||{};var hwm=options.highWaterMark;this.highWaterMark=hwm||hwm===0?hwm:16*1024;this.objectMode=!!options.objectMode;this.highWaterMark=~~this.highWaterMark;this.needDrain=false;this.ending=false;this.ended=false;this.finished=false;var noDecode=options.decodeStrings===false;this.decodeStrings=!noDecode;this.defaultEncoding=options.defaultEncoding||"utf8";this.length=0;this.writing=false;this.sync=true;this.bufferProcessing=false;this.onwrite=function(er){onwrite(stream,er)};this.writecb=null;this.writelen=0;this.buffer=[]}function Writable(options){if(!(this instanceof Writable)&&!(this instanceof Stream.Duplex))return new Writable(options);this._writableState=new WritableState(options,this);this.writable=true;Stream.call(this)}Writable.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe. Not readable."))};function writeAfterEnd(stream,state,cb){var er=new Error("write after end");stream.emit("error",er);setImmediate(function(){cb(er)})}function validChunk(stream,state,chunk,cb){var valid=true;if(!Buffer.isBuffer(chunk)&&"string"!==typeof chunk&&chunk!==null&&chunk!==undefined&&!state.objectMode){var er=new TypeError("Invalid non-string/buffer chunk");stream.emit("error",er);setImmediate(function(){cb(er)});valid=false}return valid}Writable.prototype.write=function(chunk,encoding,cb){var state=this._writableState;var ret=false;if(typeof encoding==="function"){cb=encoding;encoding=null}if(!Buffer.isBuffer(chunk)&&isUint8Array(chunk))chunk=new Buffer(chunk);if(isArrayBuffer(chunk)&&typeof Uint8Array!=="undefined")chunk=new Buffer(new Uint8Array(chunk));if(Buffer.isBuffer(chunk))encoding="buffer";else if(!encoding)encoding=state.defaultEncoding;if(typeof cb!=="function")cb=function(){};if(state.ended)writeAfterEnd(this,state,cb);else if(validChunk(this,state,chunk,cb))ret=writeOrBuffer(this,state,chunk,encoding,cb);return ret};function decodeChunk(state,chunk,encoding){if(!state.objectMode&&state.decodeStrings!==false&&typeof chunk==="string"){chunk=new Buffer(chunk,encoding)}return chunk}function writeOrBuffer(stream,state,chunk,encoding,cb){chunk=decodeChunk(state,chunk,encoding);var len=state.objectMode?1:chunk.length;state.length+=len;var ret=state.length<state.highWaterMark;state.needDrain=!ret;if(state.writing)state.buffer.push(new WriteReq(chunk,encoding,cb));else doWrite(stream,state,len,chunk,encoding,cb);return ret}function doWrite(stream,state,len,chunk,encoding,cb){state.writelen=len;state.writecb=cb;state.writing=true;state.sync=true;stream._write(chunk,encoding,state.onwrite);state.sync=false}function onwriteError(stream,state,sync,er,cb){if(sync)setImmediate(function(){cb(er)});else cb(er);stream.emit("error",er)}function onwriteStateUpdate(state){state.writing=false;state.writecb=null;state.length-=state.writelen;state.writelen=0}function onwrite(stream,er){var state=stream._writableState;var sync=state.sync;var cb=state.writecb;onwriteStateUpdate(state);if(er)onwriteError(stream,state,sync,er,cb);else{var finished=needFinish(stream,state);if(!finished&&!state.bufferProcessing&&state.buffer.length)clearBuffer(stream,state);if(sync){setImmediate(function(){afterWrite(stream,state,finished,cb)})}else{afterWrite(stream,state,finished,cb)}}}function afterWrite(stream,state,finished,cb){if(!finished)onwriteDrain(stream,state);cb();if(finished)finishMaybe(stream,state)}function onwriteDrain(stream,state){if(state.length===0&&state.needDrain){state.needDrain=false;stream.emit("drain")}}function clearBuffer(stream,state){state.bufferProcessing=true;for(var c=0;c<state.buffer.length;c++){var entry=state.buffer[c];var chunk=entry.chunk;var encoding=entry.encoding;var cb=entry.callback;var len=state.objectMode?1:chunk.length;doWrite(stream,state,len,chunk,encoding,cb);if(state.writing){c++;break}}state.bufferProcessing=false;if(c<state.buffer.length)state.buffer=state.buffer.slice(c);else state.buffer.length=0}Writable.prototype._write=function(chunk,encoding,cb){cb(new Error("not implemented"))};Writable.prototype.end=function(chunk,encoding,cb){var state=this._writableState;if(typeof chunk==="function"){cb=chunk;chunk=null;encoding=null}else if(typeof encoding==="function"){cb=encoding;encoding=null}if(typeof chunk!=="undefined"&&chunk!==null)this.write(chunk,encoding);if(!state.ending&&!state.finished)endWritable(this,state,cb)};function needFinish(stream,state){return state.ending&&state.length===0&&!state.finished&&!state.writing}function finishMaybe(stream,state){var need=needFinish(stream,state);if(need){state.finished=true;stream.emit("finish")}return need}function endWritable(stream,state,cb){state.ending=true;finishMaybe(stream,state);if(cb){if(state.finished)setImmediate(cb);else stream.once("finish",cb)}state.ended=true}},{"./index.js":27,buffer:11,inherits:20,"process/browser.js":28}],33:[function(require,module,exports){var Buffer=require("buffer").Buffer;function assertEncoding(encoding){if(encoding&&!Buffer.isEncoding(encoding)){throw new Error("Unknown encoding: "+encoding)}}var StringDecoder=exports.StringDecoder=function(encoding){this.encoding=(encoding||"utf8").toLowerCase().replace(/[-_]/,"");assertEncoding(encoding);switch(this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2;this.detectIncompleteChar=utf16DetectIncompleteChar;break;case"base64":this.surrogateSize=3;this.detectIncompleteChar=base64DetectIncompleteChar;break;default:this.write=passThroughWrite;return}this.charBuffer=new Buffer(6);this.charReceived=0;this.charLength=0};StringDecoder.prototype.write=function(buffer){var charStr="";var offset=0;while(this.charLength){var i=buffer.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:buffer.length;buffer.copy(this.charBuffer,this.charReceived,offset,i);this.charReceived+=i-offset;offset=i;if(this.charReceived<this.charLength){return""}charStr=this.charBuffer.slice(0,this.charLength).toString(this.encoding);var charCode=charStr.charCodeAt(charStr.length-1);if(charCode>=55296&&charCode<=56319){this.charLength+=this.surrogateSize;charStr="";continue}this.charReceived=this.charLength=0;if(i==buffer.length)return charStr;buffer=buffer.slice(i,buffer.length);break}var lenIncomplete=this.detectIncompleteChar(buffer);var end=buffer.length;if(this.charLength){buffer.copy(this.charBuffer,0,buffer.length-lenIncomplete,end);this.charReceived=lenIncomplete;end-=lenIncomplete}charStr+=buffer.toString(this.encoding,0,end);var end=charStr.length-1;var charCode=charStr.charCodeAt(end);if(charCode>=55296&&charCode<=56319){var size=this.surrogateSize;this.charLength+=size;this.charReceived+=size;this.charBuffer.copy(this.charBuffer,size,0,size);this.charBuffer.write(charStr.charAt(charStr.length-1),this.encoding);return charStr.substring(0,end)}return charStr};StringDecoder.prototype.detectIncompleteChar=function(buffer){var i=buffer.length>=3?3:buffer.length;for(;i>0;i--){var c=buffer[buffer.length-i];if(i==1&&c>>5==6){this.charLength=2;break}if(i<=2&&c>>4==14){this.charLength=3;break}if(i<=3&&c>>3==30){this.charLength=4;break}}return i};StringDecoder.prototype.end=function(buffer){var res="";if(buffer&&buffer.length)res=this.write(buffer);if(this.charReceived){var cr=this.charReceived;var buf=this.charBuffer;var enc=this.encoding;res+=buf.slice(0,cr).toString(enc)}return res};function passThroughWrite(buffer){return buffer.toString(this.encoding)}function utf16DetectIncompleteChar(buffer){var incomplete=this.charReceived=buffer.length%2;this.charLength=incomplete?2:0;return incomplete}function base64DetectIncompleteChar(buffer){var incomplete=this.charReceived=buffer.length%3;this.charLength=incomplete?3:0;return incomplete}},{buffer:11}],34:[function(require,module,exports){var punycode=require("punycode");exports.parse=urlParse;exports.resolve=urlResolve;exports.resolveObject=urlResolveObject;exports.format=urlFormat;exports.Url=Url;function Url(){this.protocol=null;this.slashes=null;this.auth=null;this.host=null;this.port=null;this.hostname=null;this.hash=null;this.search=null;this.query=null;this.pathname=null;this.path=null;this.href=null}var protocolPattern=/^([a-z0-9.+-]+:)/i,portPattern=/:[0-9]*$/,delims=["<",">",'"',"`"," ","\r","\n","	"],unwise=["{","}","|","\\","^","`"].concat(delims),autoEscape=["'"].concat(unwise),nonHostChars=["%","/","?",";","#"].concat(autoEscape),hostEndingChars=["/","?","#"],hostnameMaxLen=255,hostnamePartPattern=/^[a-z0-9A-Z_-]{0,63}$/,hostnamePartStart=/^([a-z0-9A-Z_-]{0,63})(.*)$/,unsafeProtocol={javascript:true,"javascript:":true},hostlessProtocol={javascript:true,"javascript:":true},slashedProtocol={http:true,https:true,ftp:true,gopher:true,file:true,"http:":true,"https:":true,"ftp:":true,"gopher:":true,"file:":true},querystring=require("querystring");function urlParse(url,parseQueryString,slashesDenoteHost){if(url&&isObject(url)&&url instanceof Url)return url;var u=new Url;u.parse(url,parseQueryString,slashesDenoteHost);return u}Url.prototype.parse=function(url,parseQueryString,slashesDenoteHost){if(!isString(url)){throw new TypeError("Parameter 'url' must be a string, not "+typeof url)}var rest=url;rest=rest.trim();var proto=protocolPattern.exec(rest);if(proto){proto=proto[0];var lowerProto=proto.toLowerCase();this.protocol=lowerProto;rest=rest.substr(proto.length)}if(slashesDenoteHost||proto||rest.match(/^\/\/[^@\/]+@[^@\/]+/)){var slashes=rest.substr(0,2)==="//";if(slashes&&!(proto&&hostlessProtocol[proto])){rest=rest.substr(2);this.slashes=true}}if(!hostlessProtocol[proto]&&(slashes||proto&&!slashedProtocol[proto])){var hostEnd=-1;for(var i=0;i<hostEndingChars.length;i++){var hec=rest.indexOf(hostEndingChars[i]);if(hec!==-1&&(hostEnd===-1||hec<hostEnd))hostEnd=hec}var auth,atSign;if(hostEnd===-1){atSign=rest.lastIndexOf("@")}else{atSign=rest.lastIndexOf("@",hostEnd)}if(atSign!==-1){auth=rest.slice(0,atSign);rest=rest.slice(atSign+1);this.auth=decodeURIComponent(auth)}hostEnd=-1;for(var i=0;i<nonHostChars.length;i++){var hec=rest.indexOf(nonHostChars[i]);if(hec!==-1&&(hostEnd===-1||hec<hostEnd))hostEnd=hec}if(hostEnd===-1)hostEnd=rest.length;this.host=rest.slice(0,hostEnd);rest=rest.slice(hostEnd);this.parseHost();this.hostname=this.hostname||"";var ipv6Hostname=this.hostname[0]==="["&&this.hostname[this.hostname.length-1]==="]";if(!ipv6Hostname){var hostparts=this.hostname.split(/\./);for(var i=0,l=hostparts.length;i<l;i++){var part=hostparts[i];if(!part)continue;if(!part.match(hostnamePartPattern)){var newpart="";for(var j=0,k=part.length;j<k;j++){if(part.charCodeAt(j)>127){newpart+="x"}else{newpart+=part[j]}}if(!newpart.match(hostnamePartPattern)){var validParts=hostparts.slice(0,i);var notHost=hostparts.slice(i+1);var bit=part.match(hostnamePartStart);if(bit){validParts.push(bit[1]);notHost.unshift(bit[2])}if(notHost.length){rest="/"+notHost.join(".")+rest}this.hostname=validParts.join(".");break}}}}if(this.hostname.length>hostnameMaxLen){this.hostname=""}else{this.hostname=this.hostname.toLowerCase()}if(!ipv6Hostname){var domainArray=this.hostname.split(".");var newOut=[];for(var i=0;i<domainArray.length;++i){var s=domainArray[i];newOut.push(s.match(/[^A-Za-z0-9_-]/)?"xn--"+punycode.encode(s):s)}this.hostname=newOut.join(".")}var p=this.port?":"+this.port:"";var h=this.hostname||"";this.host=h+p;this.href+=this.host;if(ipv6Hostname){this.hostname=this.hostname.substr(1,this.hostname.length-2);if(rest[0]!=="/"){rest="/"+rest}}}if(!unsafeProtocol[lowerProto]){for(var i=0,l=autoEscape.length;i<l;i++){var ae=autoEscape[i];var esc=encodeURIComponent(ae);if(esc===ae){esc=escape(ae)}rest=rest.split(ae).join(esc)}}var hash=rest.indexOf("#");if(hash!==-1){this.hash=rest.substr(hash);rest=rest.slice(0,hash)}var qm=rest.indexOf("?");if(qm!==-1){this.search=rest.substr(qm);this.query=rest.substr(qm+1);if(parseQueryString){this.query=querystring.parse(this.query)}rest=rest.slice(0,qm)}else if(parseQueryString){this.search="";this.query={}}if(rest)this.pathname=rest;if(slashedProtocol[lowerProto]&&this.hostname&&!this.pathname){this.pathname="/"}if(this.pathname||this.search){var p=this.pathname||"";var s=this.search||"";this.path=p+s}this.href=this.format();return this};function urlFormat(obj){if(isString(obj))obj=urlParse(obj);if(!(obj instanceof Url))return Url.prototype.format.call(obj);return obj.format()}Url.prototype.format=function(){var auth=this.auth||"";if(auth){auth=encodeURIComponent(auth);auth=auth.replace(/%3A/i,":");auth+="@"}var protocol=this.protocol||"",pathname=this.pathname||"",hash=this.hash||"",host=false,query="";if(this.host){host=auth+this.host}else if(this.hostname){host=auth+(this.hostname.indexOf(":")===-1?this.hostname:"["+this.hostname+"]");if(this.port){host+=":"+this.port}}if(this.query&&isObject(this.query)&&Object.keys(this.query).length){query=querystring.stringify(this.query)}var search=this.search||query&&"?"+query||"";if(protocol&&protocol.substr(-1)!==":")protocol+=":";if(this.slashes||(!protocol||slashedProtocol[protocol])&&host!==false){host="//"+(host||"");if(pathname&&pathname.charAt(0)!=="/")pathname="/"+pathname}else if(!host){host=""}if(hash&&hash.charAt(0)!=="#")hash="#"+hash;if(search&&search.charAt(0)!=="?")search="?"+search;pathname=pathname.replace(/[?#]/g,function(match){return encodeURIComponent(match)});search=search.replace("#","%23");return protocol+host+pathname+search+hash};function urlResolve(source,relative){return urlParse(source,false,true).resolve(relative)}Url.prototype.resolve=function(relative){return this.resolveObject(urlParse(relative,false,true)).format()};function urlResolveObject(source,relative){if(!source)return relative;return urlParse(source,false,true).resolveObject(relative)}Url.prototype.resolveObject=function(relative){if(isString(relative)){var rel=new Url;rel.parse(relative,false,true);relative=rel}var result=new Url;Object.keys(this).forEach(function(k){result[k]=this[k]},this);result.hash=relative.hash;if(relative.href===""){result.href=result.format();return result}if(relative.slashes&&!relative.protocol){Object.keys(relative).forEach(function(k){if(k!=="protocol")result[k]=relative[k]});if(slashedProtocol[result.protocol]&&result.hostname&&!result.pathname){result.path=result.pathname="/"}result.href=result.format();return result}if(relative.protocol&&relative.protocol!==result.protocol){if(!slashedProtocol[relative.protocol]){Object.keys(relative).forEach(function(k){result[k]=relative[k]});result.href=result.format();return result}result.protocol=relative.protocol;if(!relative.host&&!hostlessProtocol[relative.protocol]){var relPath=(relative.pathname||"").split("/");while(relPath.length&&!(relative.host=relPath.shift()));if(!relative.host)relative.host="";if(!relative.hostname)relative.hostname="";if(relPath[0]!=="")relPath.unshift("");if(relPath.length<2)relPath.unshift("");result.pathname=relPath.join("/")}else{result.pathname=relative.pathname}result.search=relative.search;result.query=relative.query;result.host=relative.host||"";result.auth=relative.auth;result.hostname=relative.hostname||relative.host;result.port=relative.port;if(result.pathname||result.search){var p=result.pathname||"";var s=result.search||"";result.path=p+s}result.slashes=result.slashes||relative.slashes;result.href=result.format();return result}var isSourceAbs=result.pathname&&result.pathname.charAt(0)==="/",isRelAbs=relative.host||relative.pathname&&relative.pathname.charAt(0)==="/",mustEndAbs=isRelAbs||isSourceAbs||result.host&&relative.pathname,removeAllDots=mustEndAbs,srcPath=result.pathname&&result.pathname.split("/")||[],relPath=relative.pathname&&relative.pathname.split("/")||[],psychotic=result.protocol&&!slashedProtocol[result.protocol];
if(psychotic){result.hostname="";result.port=null;if(result.host){if(srcPath[0]==="")srcPath[0]=result.host;else srcPath.unshift(result.host)}result.host="";if(relative.protocol){relative.hostname=null;relative.port=null;if(relative.host){if(relPath[0]==="")relPath[0]=relative.host;else relPath.unshift(relative.host)}relative.host=null}mustEndAbs=mustEndAbs&&(relPath[0]===""||srcPath[0]==="")}if(isRelAbs){result.host=relative.host||relative.host===""?relative.host:result.host;result.hostname=relative.hostname||relative.hostname===""?relative.hostname:result.hostname;result.search=relative.search;result.query=relative.query;srcPath=relPath}else if(relPath.length){if(!srcPath)srcPath=[];srcPath.pop();srcPath=srcPath.concat(relPath);result.search=relative.search;result.query=relative.query}else if(!isNullOrUndefined(relative.search)){if(psychotic){result.hostname=result.host=srcPath.shift();var authInHost=result.host&&result.host.indexOf("@")>0?result.host.split("@"):false;if(authInHost){result.auth=authInHost.shift();result.host=result.hostname=authInHost.shift()}}result.search=relative.search;result.query=relative.query;if(!isNull(result.pathname)||!isNull(result.search)){result.path=(result.pathname?result.pathname:"")+(result.search?result.search:"")}result.href=result.format();return result}if(!srcPath.length){result.pathname=null;if(result.search){result.path="/"+result.search}else{result.path=null}result.href=result.format();return result}var last=srcPath.slice(-1)[0];var hasTrailingSlash=(result.host||relative.host)&&(last==="."||last==="..")||last==="";var up=0;for(var i=srcPath.length;i>=0;i--){last=srcPath[i];if(last=="."){srcPath.splice(i,1)}else if(last===".."){srcPath.splice(i,1);up++}else if(up){srcPath.splice(i,1);up--}}if(!mustEndAbs&&!removeAllDots){for(;up--;up){srcPath.unshift("..")}}if(mustEndAbs&&srcPath[0]!==""&&(!srcPath[0]||srcPath[0].charAt(0)!=="/")){srcPath.unshift("")}if(hasTrailingSlash&&srcPath.join("/").substr(-1)!=="/"){srcPath.push("")}var isAbsolute=srcPath[0]===""||srcPath[0]&&srcPath[0].charAt(0)==="/";if(psychotic){result.hostname=result.host=isAbsolute?"":srcPath.length?srcPath.shift():"";var authInHost=result.host&&result.host.indexOf("@")>0?result.host.split("@"):false;if(authInHost){result.auth=authInHost.shift();result.host=result.hostname=authInHost.shift()}}mustEndAbs=mustEndAbs||result.host&&srcPath.length;if(mustEndAbs&&!isAbsolute){srcPath.unshift("")}if(!srcPath.length){result.pathname=null;result.path=null}else{result.pathname=srcPath.join("/")}if(!isNull(result.pathname)||!isNull(result.search)){result.path=(result.pathname?result.pathname:"")+(result.search?result.search:"")}result.auth=relative.auth||result.auth;result.slashes=result.slashes||relative.slashes;result.href=result.format();return result};Url.prototype.parseHost=function(){var host=this.host;var port=portPattern.exec(host);if(port){port=port[0];if(port!==":"){this.port=port.substr(1)}host=host.substr(0,host.length-port.length)}if(host)this.hostname=host};function isString(arg){return typeof arg==="string"}function isObject(arg){return typeof arg==="object"&&arg!==null}function isNull(arg){return arg===null}function isNullOrUndefined(arg){return arg==null}},{punycode:22,querystring:25}],35:[function(require,module,exports){module.exports=function isBuffer(arg){return arg&&typeof arg==="object"&&typeof arg.copy==="function"&&typeof arg.fill==="function"&&typeof arg.readUInt8==="function"}},{}],36:[function(require,module,exports){(function(process,global){var formatRegExp=/%[sdj%]/g;exports.format=function(f){if(!isString(f)){var objects=[];for(var i=0;i<arguments.length;i++){objects.push(inspect(arguments[i]))}return objects.join(" ")}var i=1;var args=arguments;var len=args.length;var str=String(f).replace(formatRegExp,function(x){if(x==="%%")return"%";if(i>=len)return x;switch(x){case"%s":return String(args[i++]);case"%d":return Number(args[i++]);case"%j":try{return JSON.stringify(args[i++])}catch(_){return"[Circular]"}default:return x}});for(var x=args[i];i<len;x=args[++i]){if(isNull(x)||!isObject(x)){str+=" "+x}else{str+=" "+inspect(x)}}return str};exports.deprecate=function(fn,msg){if(isUndefined(global.process)){return function(){return exports.deprecate(fn,msg).apply(this,arguments)}}if(process.noDeprecation===true){return fn}var warned=false;function deprecated(){if(!warned){if(process.throwDeprecation){throw new Error(msg)}else if(process.traceDeprecation){console.trace(msg)}else{console.error(msg)}warned=true}return fn.apply(this,arguments)}return deprecated};var debugs={};var debugEnviron;exports.debuglog=function(set){if(isUndefined(debugEnviron))debugEnviron=process.env.NODE_DEBUG||"";set=set.toUpperCase();if(!debugs[set]){if(new RegExp("\\b"+set+"\\b","i").test(debugEnviron)){var pid=process.pid;debugs[set]=function(){var msg=exports.format.apply(exports,arguments);console.error("%s %d: %s",set,pid,msg)}}else{debugs[set]=function(){}}}return debugs[set]};function inspect(obj,opts){var ctx={seen:[],stylize:stylizeNoColor};if(arguments.length>=3)ctx.depth=arguments[2];if(arguments.length>=4)ctx.colors=arguments[3];if(isBoolean(opts)){ctx.showHidden=opts}else if(opts){exports._extend(ctx,opts)}if(isUndefined(ctx.showHidden))ctx.showHidden=false;if(isUndefined(ctx.depth))ctx.depth=2;if(isUndefined(ctx.colors))ctx.colors=false;if(isUndefined(ctx.customInspect))ctx.customInspect=true;if(ctx.colors)ctx.stylize=stylizeWithColor;return formatValue(ctx,obj,ctx.depth)}exports.inspect=inspect;inspect.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]};inspect.styles={special:"cyan",number:"yellow","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"};function stylizeWithColor(str,styleType){var style=inspect.styles[styleType];if(style){return"["+inspect.colors[style][0]+"m"+str+"["+inspect.colors[style][1]+"m"}else{return str}}function stylizeNoColor(str,styleType){return str}function arrayToHash(array){var hash={};array.forEach(function(val,idx){hash[val]=true});return hash}function formatValue(ctx,value,recurseTimes){if(ctx.customInspect&&value&&isFunction(value.inspect)&&value.inspect!==exports.inspect&&!(value.constructor&&value.constructor.prototype===value)){var ret=value.inspect(recurseTimes,ctx);if(!isString(ret)){ret=formatValue(ctx,ret,recurseTimes)}return ret}var primitive=formatPrimitive(ctx,value);if(primitive){return primitive}var keys=Object.keys(value);var visibleKeys=arrayToHash(keys);if(ctx.showHidden){keys=Object.getOwnPropertyNames(value)}if(isError(value)&&(keys.indexOf("message")>=0||keys.indexOf("description")>=0)){return formatError(value)}if(keys.length===0){if(isFunction(value)){var name=value.name?": "+value.name:"";return ctx.stylize("[Function"+name+"]","special")}if(isRegExp(value)){return ctx.stylize(RegExp.prototype.toString.call(value),"regexp")}if(isDate(value)){return ctx.stylize(Date.prototype.toString.call(value),"date")}if(isError(value)){return formatError(value)}}var base="",array=false,braces=["{","}"];if(isArray(value)){array=true;braces=["[","]"]}if(isFunction(value)){var n=value.name?": "+value.name:"";base=" [Function"+n+"]"}if(isRegExp(value)){base=" "+RegExp.prototype.toString.call(value)}if(isDate(value)){base=" "+Date.prototype.toUTCString.call(value)}if(isError(value)){base=" "+formatError(value)}if(keys.length===0&&(!array||value.length==0)){return braces[0]+base+braces[1]}if(recurseTimes<0){if(isRegExp(value)){return ctx.stylize(RegExp.prototype.toString.call(value),"regexp")}else{return ctx.stylize("[Object]","special")}}ctx.seen.push(value);var output;if(array){output=formatArray(ctx,value,recurseTimes,visibleKeys,keys)}else{output=keys.map(function(key){return formatProperty(ctx,value,recurseTimes,visibleKeys,key,array)})}ctx.seen.pop();return reduceToSingleString(output,base,braces)}function formatPrimitive(ctx,value){if(isUndefined(value))return ctx.stylize("undefined","undefined");if(isString(value)){var simple="'"+JSON.stringify(value).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return ctx.stylize(simple,"string")}if(isNumber(value))return ctx.stylize(""+value,"number");if(isBoolean(value))return ctx.stylize(""+value,"boolean");if(isNull(value))return ctx.stylize("null","null")}function formatError(value){return"["+Error.prototype.toString.call(value)+"]"}function formatArray(ctx,value,recurseTimes,visibleKeys,keys){var output=[];for(var i=0,l=value.length;i<l;++i){if(hasOwnProperty(value,String(i))){output.push(formatProperty(ctx,value,recurseTimes,visibleKeys,String(i),true))}else{output.push("")}}keys.forEach(function(key){if(!key.match(/^\d+$/)){output.push(formatProperty(ctx,value,recurseTimes,visibleKeys,key,true))}});return output}function formatProperty(ctx,value,recurseTimes,visibleKeys,key,array){var name,str,desc;desc=Object.getOwnPropertyDescriptor(value,key)||{value:value[key]};if(desc.get){if(desc.set){str=ctx.stylize("[Getter/Setter]","special")}else{str=ctx.stylize("[Getter]","special")}}else{if(desc.set){str=ctx.stylize("[Setter]","special")}}if(!hasOwnProperty(visibleKeys,key)){name="["+key+"]"}if(!str){if(ctx.seen.indexOf(desc.value)<0){if(isNull(recurseTimes)){str=formatValue(ctx,desc.value,null)}else{str=formatValue(ctx,desc.value,recurseTimes-1)}if(str.indexOf("\n")>-1){if(array){str=str.split("\n").map(function(line){return"  "+line}).join("\n").substr(2)}else{str="\n"+str.split("\n").map(function(line){return"   "+line}).join("\n")}}}else{str=ctx.stylize("[Circular]","special")}}if(isUndefined(name)){if(array&&key.match(/^\d+$/)){return str}name=JSON.stringify(""+key);if(name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)){name=name.substr(1,name.length-2);name=ctx.stylize(name,"name")}else{name=name.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'");name=ctx.stylize(name,"string")}}return name+": "+str}function reduceToSingleString(output,base,braces){var numLinesEst=0;var length=output.reduce(function(prev,cur){numLinesEst++;if(cur.indexOf("\n")>=0)numLinesEst++;return prev+cur.replace(/\u001b\[\d\d?m/g,"").length+1},0);if(length>60){return braces[0]+(base===""?"":base+"\n ")+" "+output.join(",\n  ")+" "+braces[1]}return braces[0]+base+" "+output.join(", ")+" "+braces[1]}function isArray(ar){return Array.isArray(ar)}exports.isArray=isArray;function isBoolean(arg){return typeof arg==="boolean"}exports.isBoolean=isBoolean;function isNull(arg){return arg===null}exports.isNull=isNull;function isNullOrUndefined(arg){return arg==null}exports.isNullOrUndefined=isNullOrUndefined;function isNumber(arg){return typeof arg==="number"}exports.isNumber=isNumber;function isString(arg){return typeof arg==="string"}exports.isString=isString;function isSymbol(arg){return typeof arg==="symbol"}exports.isSymbol=isSymbol;function isUndefined(arg){return arg===void 0}exports.isUndefined=isUndefined;function isRegExp(re){return isObject(re)&&objectToString(re)==="[object RegExp]"}exports.isRegExp=isRegExp;function isObject(arg){return typeof arg==="object"&&arg!==null}exports.isObject=isObject;function isDate(d){return isObject(d)&&objectToString(d)==="[object Date]"}exports.isDate=isDate;function isError(e){return isObject(e)&&(objectToString(e)==="[object Error]"||e instanceof Error)}exports.isError=isError;function isFunction(arg){return typeof arg==="function"}exports.isFunction=isFunction;function isPrimitive(arg){return arg===null||typeof arg==="boolean"||typeof arg==="number"||typeof arg==="string"||typeof arg==="symbol"||typeof arg==="undefined"}exports.isPrimitive=isPrimitive;exports.isBuffer=require("./support/isBuffer");function objectToString(o){return Object.prototype.toString.call(o)}function pad(n){return n<10?"0"+n.toString(10):n.toString(10)}var months=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function timestamp(){var d=new Date;var time=[pad(d.getHours()),pad(d.getMinutes()),pad(d.getSeconds())].join(":");return[d.getDate(),months[d.getMonth()],time].join(" ")}exports.log=function(){console.log("%s - %s",timestamp(),exports.format.apply(exports,arguments))};exports.inherits=require("inherits");exports._extend=function(origin,add){if(!add||!isObject(add))return origin;var keys=Object.keys(add);var i=keys.length;while(i--){origin[keys[i]]=add[keys[i]]}return origin};function hasOwnProperty(obj,prop){return Object.prototype.hasOwnProperty.call(obj,prop)}}).call(this,require("FWaASH"),typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"./support/isBuffer":35,FWaASH:21,inherits:20}],37:[function(require,module,exports){var ndarray=require("ndarray");var fft=require("ndarray-fft");var mag=require("ndarray-complex").mag;var inherits=require("inherits");var EventEmitter=require("events").EventEmitter;var fs=require("fs");var html='<div id="scope">\n  <div id="sliders"></div>\n</div>\n';var domify=require("domify");var slideways=require("slideways");module.exports=Scope;inherits(Scope,EventEmitter);function Scope(opts){var self=this;if(!(this instanceof Scope))return new Scope(opts);if(!opts)opts={};this.rate=opts.rate||44e3;this._worker=opts.worker||function(data,cb){cb(worker(data))};this.element=domify(html)[0];this.element.style.width="100%";this.element.style.height="100%";this.element.addEventListener("click",function(ev){if(ev.target===self.svg||ev.target===sliders||ev.target===self.polyline){self.emit("click",ev)}});this.svg=createElement("svg");this.svg.setAttribute("width","100%");this.svg.setAttribute("height","100%");this.element.appendChild(this.svg);var p=this.polyline=createElement("polyline");p.setAttribute("fill",opts.fill||"cyan");p.setAttribute("stroke",opts.stroke||"cyan");p.setAttribute("strokeWidth",opts.strokeWidth||"2px");this.svg.appendChild(this.polyline);this.scale=0;this.createSlider({min:-1,max:5,init:0},function(x){self.scale=Math.pow(2,x)})}Scope.prototype.createSlider=function(opts,f){if(!opts)opts={};var a=slideways(opts);if(f)a.on("value",f);a.appendTo(this.element.querySelector("#sliders"));return a};Scope.prototype.appendTo=function(target){if(typeof target==="string")target=document.querySelector(target);target.appendChild(this.element);this._target=target;this.resize()};Scope.prototype.resize=function(){if(!this._target)return;var style=window.getComputedStyle(this._target);this.width=parseInt(style.width);this.height=parseInt(style.height)};module.exports.worker=worker;function worker(input){var data=new Float32Array(input.length);for(var i=0;i<input.length;i++){data[i]=Math.min(1,Math.max(-1,input[i]))}var reals=ndarray(data,[data.length,1]);var imags=ndarray(new Float32Array(data.length),[data.length,1]);fft(1,reals,imags);mag(reals,reals,imags);return reals}Scope.prototype.draw=function(data){var self=this;self._worker(data,function(reals){self._draw(reals)})};Scope.prototype._draw=function(reals){var self=this;var points=["0,"+this.height];var pfreq,pd;for(var i=0;i<reals.data.length;i++){var freq=i*this.rate/reals.data.length;var d=reals.data[i];if(d>1e5){if(pd<1e5){plot(pfreq,pd)}plot(freq,d)}else if(pd>1e5)plot(freq,d);pd=d;pfreq=freq}function plot(freq,d){var x=(Math.log(1+freq)-3)/7*self.width;var y=Math.max(0,self.height-d/1e4*self.scale);points.push(x+","+y)}points.push(this.width+","+this.height);this.polyline.setAttribute("points",points.join(" "))};function createElement(name){return document.createElementNS("http://www.w3.org/2000/svg",name)}},{domify:38,events:14,fs:10,inherits:39,ndarray:69,"ndarray-complex":40,"ndarray-fft":51,slideways:71}],38:[function(require,module,exports){module.exports=require(4)},{}],39:[function(require,module,exports){module.exports=require(5)},{}],40:[function(require,module,exports){"use strict";var ops=require("ndarray-ops");function add(out_r,out_i,a_r,a_i,b_r,b_i){ops.add(out_r,a_r,b_r);ops.add(out_i,a_i,b_i)}exports.add=add;function addeq(out_r,out_i,a_r,a_i){ops.addeq(out_r,a_r);ops.addeq(out_i,a_i)}exports.addeq=addeq;function adds(out_r,out_i,a_r,a_i,s_r,s_i){ops.adds(out_r,a_r,s_r);ops.adds(out_r,a_i,s_i)}exports.adds=adds;function addseq(out_r,out_i,s_r,s_i){ops.addseq(out_r,s_r);ops.addseq(out_i,s_i)}exports.addseq=addseq;function sub(out_r,out_i,a_r,a_i,b_r,b_i){ops.sub(out_r,a_r,b_r);ops.sub(out_i,a_i,b_i)}exports.sub=sub;function subeq(out_r,out_i,a_r,a_i){ops.subeq(out_r,a_r);ops.subeq(out_i,a_i)}exports.subeq=subeq;function subs(out_r,out_i,a_r,a_i,s_r,s_i){ops.subs(out_r,a_r,s_r);ops.subs(out_i,a_i,s_i)}exports.subs=subs;function subseq(out_r,out_i,s_r,s_i){ops.subseq(out_r,s_r);ops.subseq(out_i,s_i)}exports.subseq=subseq;function neg(out_r,out_i,a_r,a_i){ops.neg(out_r,a_r);ops.neg(out_i,a_i)}exports.neg=neg;function negeq(out_r,out_i){ops.negeq(out_r);ops.negeq(out_i)}exports.negeq=negeq;function conj(out_r,out_i,a_r,a_i){ops.assign(out_r,a_r);ops.neg(out_i,a_i)}exports.conj=conj;function conjeq(out_r,out_i){ops.negeq(out_i)}exports.conjeq=conjeq;var mul=require("cwise/lib/wrapper")({args:["array","array","array","array","array","array"],pre:{body:"{}",args:[],thisVars:[],localVars:[]},body:{body:"{var _inline_1_i=_inline_1_arg2_,_inline_1_o=_inline_1_arg3_,_inline_1_t=_inline_1_arg4_,_inline_1_u=_inline_1_arg5_,_inline_1_X=_inline_1_t*(_inline_1_i+_inline_1_o);_inline_1_arg0_=_inline_1_X-_inline_1_o*(_inline_1_t+_inline_1_u),_inline_1_arg1_=_inline_1_X+_inline_1_i*(_inline_1_u-_inline_1_t)}",args:[{name:"_inline_1_arg0_",lvalue:true,rvalue:false,count:1},{name:"_inline_1_arg1_",lvalue:true,rvalue:false,count:1},{name:"_inline_1_arg2_",lvalue:false,rvalue:true,count:1},{name:"_inline_1_arg3_",lvalue:false,rvalue:true,count:1},{name:"_inline_1_arg4_",lvalue:false,rvalue:true,count:1},{name:"_inline_1_arg5_",lvalue:false,rvalue:true,count:1}],thisVars:[],localVars:["_inline_1_X","_inline_1_i","_inline_1_o","_inline_1_t","_inline_1_u"]},post:{body:"{}",args:[],thisVars:[],localVars:[]},debug:false,funcName:"cmul",blockSize:64});var muleq=require("cwise/lib/wrapper")({args:["array","array","array","array"],pre:{body:"{}",args:[],thisVars:[],localVars:[]},body:{body:"{var _inline_4_c=_inline_4_arg2_,_inline_4_f=_inline_4_arg3_,_inline_4_i=_inline_4_arg0_,_inline_4_o=_inline_4_arg1_,_inline_4_t=_inline_4_i*(_inline_4_c+_inline_4_f);_inline_4_arg0_=_inline_4_t-_inline_4_f*(_inline_4_i+_inline_4_o),_inline_4_arg1_=_inline_4_t+_inline_4_c*(_inline_4_o-_inline_4_i)}",args:[{name:"_inline_4_arg0_",lvalue:true,rvalue:true,count:2},{name:"_inline_4_arg1_",lvalue:true,rvalue:true,count:2},{name:"_inline_4_arg2_",lvalue:false,rvalue:true,count:1},{name:"_inline_4_arg3_",lvalue:false,rvalue:true,count:1}],thisVars:[],localVars:["_inline_4_c","_inline_4_f","_inline_4_i","_inline_4_o","_inline_4_t"]},post:{body:"{}",args:[],thisVars:[],localVars:[]},debug:false,funcName:"cmuleq",blockSize:64});var muls=require("cwise/lib/wrapper")({args:["array","array","array","array","scalar","scalar"],pre:{body:"{this_u=_inline_6_arg4_+_inline_6_arg5_,this_v=_inline_6_arg5_-_inline_6_arg4_}",args:[{name:"_inline_6_arg0_",lvalue:false,rvalue:false,count:0},{name:"_inline_6_arg1_",lvalue:false,rvalue:false,count:0},{name:"_inline_6_arg2_",lvalue:false,rvalue:false,count:0},{name:"_inline_6_arg3_",lvalue:false,rvalue:false,count:0},{name:"_inline_6_arg4_",lvalue:false,rvalue:true,count:2},{name:"_inline_6_arg5_",lvalue:false,rvalue:true,count:2}],thisVars:["this_u","this_v"],localVars:[]},body:{body:"{var _inline_7_n=_inline_7_arg2_,_inline_7_r=_inline_7_arg3_,_inline_7_s=_inline_7_arg4_*(_inline_7_n+_inline_7_r);_inline_7_arg0_=_inline_7_s-_inline_7_r*this_u,_inline_7_arg1_=_inline_7_s+_inline_7_n*this_v}",args:[{name:"_inline_7_arg0_",lvalue:true,rvalue:false,count:1},{name:"_inline_7_arg1_",lvalue:true,rvalue:false,count:1},{name:"_inline_7_arg2_",lvalue:false,rvalue:true,count:1},{name:"_inline_7_arg3_",lvalue:false,rvalue:true,count:1},{name:"_inline_7_arg4_",lvalue:false,rvalue:true,count:1}],thisVars:["this_u","this_v"],localVars:["_inline_7_n","_inline_7_r","_inline_7_s"]},post:{body:"{}",args:[],thisVars:[],localVars:[]},debug:false,funcName:"cmuls",blockSize:64});var mulseq=require("cwise/lib/wrapper")({args:["array","array","scalar","scalar"],pre:{body:"{this_u=_inline_9_arg2_+_inline_9_arg3_,this_v=_inline_9_arg3_-_inline_9_arg2_}",args:[{name:"_inline_9_arg0_",lvalue:false,rvalue:false,count:0},{name:"_inline_9_arg1_",lvalue:false,rvalue:false,count:0},{name:"_inline_9_arg2_",lvalue:false,rvalue:true,count:2},{name:"_inline_9_arg3_",lvalue:false,rvalue:true,count:2}],thisVars:["this_u","this_v"],localVars:[]},body:{body:"{var _inline_10_a=_inline_10_arg0_,_inline_10_h=_inline_10_arg1_,_inline_10_n=_inline_10_arg2_*(_inline_10_a+_inline_10_h);_inline_10_arg0_=_inline_10_n-_inline_10_h*this_u,_inline_10_arg1_=_inline_10_n+_inline_10_a*this_v}",args:[{name:"_inline_10_arg0_",lvalue:true,rvalue:true,count:2},{name:"_inline_10_arg1_",lvalue:true,rvalue:true,count:2},{name:"_inline_10_arg2_",lvalue:false,rvalue:true,count:1}],thisVars:["this_u","this_v"],localVars:["_inline_10_a","_inline_10_h","_inline_10_n"]},post:{body:"{}",args:[],thisVars:[],localVars:[]},debug:false,funcName:"cmulseq",blockSize:64});var div=require("cwise/lib/wrapper")({args:["array","array","array","array","array","array"],pre:{body:"{}",args:[],thisVars:[],localVars:[]},body:{body:"{var _inline_13_i=_inline_13_arg2_,_inline_13_o=_inline_13_arg3_,_inline_13_t=_inline_13_arg4_,_inline_13_u=_inline_13_arg5_,_inline_13_X=_inline_13_t*_inline_13_t+_inline_13_u*_inline_13_u,_inline_13_b=_inline_13_t*(_inline_13_i+_inline_13_o);_inline_13_arg0_=(_inline_13_b+_inline_13_o*(_inline_13_t-_inline_13_u))/_inline_13_X,_inline_13_arg1_=(_inline_13_b-_inline_13_i*(_inline_13_u+_inline_13_t))/_inline_13_X}",args:[{name:"_inline_13_arg0_",lvalue:true,rvalue:false,count:1},{name:"_inline_13_arg1_",lvalue:true,rvalue:false,count:1},{name:"_inline_13_arg2_",lvalue:false,rvalue:true,count:1},{name:"_inline_13_arg3_",lvalue:false,rvalue:true,count:1},{name:"_inline_13_arg4_",lvalue:false,rvalue:true,count:1},{name:"_inline_13_arg5_",lvalue:false,rvalue:true,count:1}],thisVars:[],localVars:["_inline_13_X","_inline_13_b","_inline_13_i","_inline_13_o","_inline_13_t","_inline_13_u"]},post:{body:"{}",args:[],thisVars:[],localVars:[]},debug:false,funcName:"cdiv",blockSize:64});var diveq=require("cwise/lib/wrapper")({args:["array","array","array","array"],pre:{body:"{}",args:[],thisVars:[],localVars:[]},body:{body:"{var _inline_16_c=_inline_16_arg0_,_inline_16_f=_inline_16_arg1_,_inline_16_i=_inline_16_arg2_,_inline_16_o=_inline_16_arg3_,_inline_16_t=_inline_16_i*_inline_16_i+_inline_16_o*_inline_16_o,_inline_16_u=_inline_16_i*(_inline_16_c+_inline_16_f);_inline_16_arg0_=(_inline_16_u+_inline_16_f*(_inline_16_i-_inline_16_o))/_inline_16_t,_inline_16_arg1_=(_inline_16_u-_inline_16_c*(_inline_16_o+_inline_16_i))/_inline_16_t}",args:[{name:"_inline_16_arg0_",lvalue:true,rvalue:true,count:2},{name:"_inline_16_arg1_",lvalue:true,rvalue:true,count:2},{name:"_inline_16_arg2_",lvalue:false,rvalue:true,count:1},{name:"_inline_16_arg3_",lvalue:false,rvalue:true,count:1}],thisVars:[],localVars:["_inline_16_c","_inline_16_f","_inline_16_i","_inline_16_o","_inline_16_t","_inline_16_u"]},post:{body:"{}",args:[],thisVars:[],localVars:[]},debug:false,funcName:"cdiveq",blockSize:64});var divs=require("cwise/lib/wrapper")({args:["array","array","array","array","scalar","scalar"],pre:{body:"{var _inline_18_c=_inline_18_arg4_*_inline_18_arg4_+_inline_18_arg5_*_inline_18_arg5_;_inline_18_arg4_/=_inline_18_c,_inline_18_arg5_/=-_inline_18_c,this_c=_inline_18_arg4_,this_u=_inline_18_arg4_+_inline_18_arg5_,this_v=_inline_18_arg5_-_inline_18_arg4_}",args:[{name:"_inline_18_arg0_",lvalue:false,rvalue:false,count:0},{name:"_inline_18_arg1_",lvalue:false,rvalue:false,count:0},{name:"_inline_18_arg2_",lvalue:false,rvalue:false,count:0},{name:"_inline_18_arg3_",lvalue:false,rvalue:false,count:0},{name:"_inline_18_arg4_",lvalue:true,rvalue:true,count:6},{name:"_inline_18_arg5_",lvalue:true,rvalue:true,count:5}],thisVars:["this_c","this_u","this_v"],localVars:["_inline_18_c"]},body:{body:"{var _inline_19_v=_inline_19_arg2_,_inline_19_a=_inline_19_arg3_,_inline_19_c=this_c*(_inline_19_v+_inline_19_a);_inline_19_arg0_=_inline_19_c-_inline_19_a*this_u,_inline_19_arg1_=_inline_19_c+_inline_19_v*this_v}",args:[{name:"_inline_19_arg0_",lvalue:true,rvalue:false,count:1},{name:"_inline_19_arg1_",lvalue:true,rvalue:false,count:1},{name:"_inline_19_arg2_",lvalue:false,rvalue:true,count:1},{name:"_inline_19_arg3_",lvalue:false,rvalue:true,count:1}],thisVars:["this_c","this_u","this_v"],localVars:["_inline_19_a","_inline_19_c","_inline_19_v"]},post:{body:"{}",args:[],thisVars:[],localVars:[]},debug:false,funcName:"cdivs",blockSize:64});var divseq=require("cwise/lib/wrapper")({args:["array","array","scalar","scalar"],pre:{body:"{var _inline_21_v=_inline_21_arg2_*_inline_21_arg2_+_inline_21_arg3_*_inline_21_arg3_;_inline_21_arg2_/=_inline_21_v,_inline_21_arg3_/=-_inline_21_v,this_c=_inline_21_arg2_,this_u=_inline_21_arg2_+_inline_21_arg3_,this_v=_inline_21_arg3_-_inline_21_arg2_}",args:[{name:"_inline_21_arg0_",lvalue:false,rvalue:false,count:0},{name:"_inline_21_arg1_",lvalue:false,rvalue:false,count:0},{name:"_inline_21_arg2_",lvalue:true,rvalue:true,count:6},{name:"_inline_21_arg3_",lvalue:true,rvalue:true,count:5}],thisVars:["this_c","this_u","this_v"],localVars:["_inline_21_v"]},body:{body:"{var _inline_22_h=_inline_22_arg0_,_inline_22_s=_inline_22_arg1_,_inline_22_v=this_c*(_inline_22_h+_inline_22_s);_inline_22_arg0_=_inline_22_v-_inline_22_s*this_u,_inline_22_arg1_=_inline_22_v+_inline_22_h*this_v}",args:[{name:"_inline_22_arg0_",lvalue:true,rvalue:true,count:2},{name:"_inline_22_arg1_",lvalue:true,rvalue:true,count:2}],thisVars:["this_c","this_u","this_v"],localVars:["_inline_22_h","_inline_22_s","_inline_22_v"]},post:{body:"{}",args:[],thisVars:[],localVars:[]},debug:false,funcName:"cdivseq",blockSize:64});var recip=require("cwise/lib/wrapper")({args:["array","array","array","array"],pre:{body:"{}",args:[],thisVars:[],localVars:[]},body:{body:"{var _inline_25_c=_inline_25_arg2_,_inline_25_f=_inline_25_arg3_,_inline_25_i=_inline_25_c*_inline_25_c+_inline_25_f*_inline_25_f;_inline_25_arg0_=_inline_25_c/_inline_25_i,_inline_25_arg1_=-_inline_25_f/_inline_25_i}",args:[{name:"_inline_25_arg0_",lvalue:true,rvalue:false,count:1},{name:"_inline_25_arg1_",lvalue:true,rvalue:false,count:1},{name:"_inline_25_arg2_",lvalue:false,rvalue:true,count:1},{name:"_inline_25_arg3_",lvalue:false,rvalue:true,count:1}],thisVars:[],localVars:["_inline_25_c","_inline_25_f","_inline_25_i"]},post:{body:"{}",args:[],thisVars:[],localVars:[]},debug:false,funcName:"crecip",blockSize:64});var recipeq=require("cwise/lib/wrapper")({args:["array","array"],pre:{body:"{}",args:[],thisVars:[],localVars:[]},body:{body:"{var _inline_28_r=_inline_28_arg0_,_inline_28_v=_inline_28_arg1_,_inline_28_c=_inline_28_r*_inline_28_r+_inline_28_v*_inline_28_v;_inline_28_arg0_=_inline_28_r/_inline_28_c,_inline_28_arg1_=-_inline_28_v/_inline_28_c}",args:[{name:"_inline_28_arg0_",lvalue:true,rvalue:true,count:2},{name:"_inline_28_arg1_",lvalue:true,rvalue:true,count:2}],thisVars:[],localVars:["_inline_28_c","_inline_28_r","_inline_28_v"]},post:{body:"{}",args:[],thisVars:[],localVars:[]},debug:false,funcName:"crecipeq",blockSize:64});var exp=require("cwise/lib/wrapper")({args:["array","array","array","array"],pre:{body:"{this_exp=Math.exp,this_cos=Math.cos,this_sin=Math.sin}",args:[],thisVars:["this_cos","this_exp","this_sin"],localVars:[]},body:{body:"{var _inline_31_n=this_exp(_inline_31_arg2_);_inline_31_arg0_=_inline_31_n*this_cos(_inline_31_arg3_),_inline_31_arg1_=_inline_31_n*this_sin(_inline_31_arg3_)}",args:[{name:"_inline_31_arg0_",lvalue:true,rvalue:false,count:1},{name:"_inline_31_arg1_",lvalue:true,rvalue:false,count:1},{name:"_inline_31_arg2_",lvalue:false,rvalue:true,count:1},{name:"_inline_31_arg3_",lvalue:false,rvalue:true,count:2}],thisVars:["this_cos","this_exp","this_sin"],localVars:["_inline_31_n"]},post:{body:"{}",args:[],thisVars:[],localVars:[]},debug:false,funcName:"cexp",blockSize:64});var expeq=require("cwise/lib/wrapper")({args:["array","array"],pre:{body:"{this_exp=Math.exp,this_cos=Math.cos,this_sin=Math.sin}",args:[],thisVars:["this_cos","this_exp","this_sin"],localVars:[]},body:{body:"{var _inline_34_t=this_exp(_inline_34_arg0_),_inline_34_h=_inline_34_out__ir;_inline_34_arg0_=_inline_34_t*this_cos(_inline_34_h),_inline_34_arg1_=_inline_34_t*this_sin(_inline_34_h)}",args:[{name:"_inline_34_arg0_",lvalue:true,rvalue:true,count:2},{name:"_inline_34_arg1_",lvalue:true,rvalue:false,count:1}],thisVars:["this_cos","this_exp","this_sin"],localVars:["_inline_34_h","_inline_34_out__ir","_inline_34_t"]},post:{body:"{}",args:[],thisVars:[],localVars:[]},debug:false,funcName:"cexpeq",blockSize:64});var mag=require("cwise/lib/wrapper")({args:["array","array","array"],pre:{body:"{}",args:[],thisVars:[],localVars:[]},body:{body:"{_inline_37_arg0_=_inline_37_arg1_*_inline_37_arg1_+_inline_37_arg2_*_inline_37_arg2_}",args:[{name:"_inline_37_arg0_",lvalue:true,rvalue:false,count:1},{name:"_inline_37_arg1_",lvalue:false,rvalue:true,count:2},{name:"_inline_37_arg2_",lvalue:false,rvalue:true,count:2}],thisVars:[],localVars:[]},post:{body:"{}",args:[],thisVars:[],localVars:[]},debug:false,funcName:"cmag",blockSize:64});var abs=require("cwise/lib/wrapper")({args:["array","array","array"],pre:{body:"{this_sqrt=Math.sqrt}",args:[],thisVars:["this_sqrt"],localVars:[]},body:{body:"{_inline_40_arg0_=this_sqrt(_inline_40_arg1_*_inline_40_arg1_+_inline_40_arg2_*_inline_40_arg2_)}",args:[{name:"_inline_40_arg0_",lvalue:true,rvalue:false,count:1},{name:"_inline_40_arg1_",lvalue:false,rvalue:true,count:2},{name:"_inline_40_arg2_",lvalue:false,rvalue:true,count:2}],thisVars:["this_sqrt"],localVars:[]},post:{body:"{}",args:[],thisVars:[],localVars:[]},debug:false,funcName:"cabs",blockSize:64});exports.arg=ops.atan2;exports.mul=mul;exports.muleq=muleq;exports.muls=muls;exports.mulseq=mulseq;exports.div=div;exports.diveq=diveq;exports.divs=divs;exports.divseq=divseq;exports.recip=recip;exports.recipeq=recipeq;exports.exp=exp;exports.expeq=expeq;exports.mag=mag;exports.abs=abs},{"cwise/lib/wrapper":41,"ndarray-ops":46}],41:[function(require,module,exports){module.exports=require("cwise-compiler")},{"cwise-compiler":42}],42:[function(require,module,exports){"use strict";var createThunk=require("./lib/thunk.js");function Procedure(){this.argTypes=[];this.shimArgs=[];this.arrayArgs=[];this.scalarArgs=[];this.offsetArgs=[];this.offsetArgIndex=[];this.indexArgs=[];this.shapeArgs=[];this.funcName="";this.pre=null;this.body=null;this.post=null;this.debug=false}function compileCwise(user_args){var proc=new Procedure;proc.pre=user_args.pre;proc.body=user_args.body;proc.post=user_args.post;var proc_args=user_args.args.slice(0);proc.argTypes=proc_args;for(var i=0;i<proc_args.length;++i){var arg_type=proc_args[i];if(arg_type==="array"){proc.arrayArgs.push(i);proc.shimArgs.push("array"+i);if(i<proc.pre.args.length&&proc.pre.args[i].count>0){throw new Error("cwise: pre() block may not reference array args")}if(i<proc.post.args.length&&proc.post.args[i].count>0){throw new Error("cwise: post() block may not reference array args")}}else if(arg_type==="scalar"){proc.scalarArgs.push(i);proc.shimArgs.push("scalar"+i)}else if(arg_type==="index"){proc.indexArgs.push(i);if(i<proc.pre.args.length&&proc.pre.args[i].count>0){throw new Error("cwise: pre() block may not reference array index")}if(i<proc.body.args.length&&proc.body.args[i].lvalue){throw new Error("cwise: body() block may not write to array index")}if(i<proc.post.args.length&&proc.post.args[i].count>0){throw new Error("cwise: post() block may not reference array index")}}else if(arg_type==="shape"){proc.shapeArgs.push(i);if(i<proc.pre.args.length&&proc.pre.args[i].lvalue){throw new Error("cwise: pre() block may not write to array shape")
}if(i<proc.body.args.length&&proc.body.args[i].lvalue){throw new Error("cwise: body() block may not write to array shape")}if(i<proc.post.args.length&&proc.post.args[i].lvalue){throw new Error("cwise: post() block may not write to array shape")}}else if(typeof arg_type==="object"&&arg_type.offset){proc.argTypes[i]="offset";proc.offsetArgs.push({array:arg_type.array,offset:arg_type.offset});proc.offsetArgIndex.push(i)}else{throw new Error("cwise: Unknown argument type "+proc_args[i])}}if(proc.arrayArgs.length<=0){throw new Error("cwise: No array arguments specified")}if(proc.pre.args.length>proc_args.length){throw new Error("cwise: Too many arguments in pre() block")}if(proc.body.args.length>proc_args.length){throw new Error("cwise: Too many arguments in body() block")}if(proc.post.args.length>proc_args.length){throw new Error("cwise: Too many arguments in post() block")}proc.debug=!!user_args.printCode||!!user_args.debug;proc.funcName=user_args.funcName||"cwise";proc.blockSize=user_args.blockSize||64;return createThunk(proc)}module.exports=compileCwise},{"./lib/thunk.js":44}],43:[function(require,module,exports){"use strict";var uniq=require("uniq");function innerFill(order,proc,body){var dimension=order.length,nargs=proc.arrayArgs.length,has_index=proc.indexArgs.length>0,code=[],vars=[],idx=0,pidx=0,i,j;for(i=0;i<dimension;++i){vars.push(["i",i,"=0"].join(""))}for(j=0;j<nargs;++j){for(i=0;i<dimension;++i){pidx=idx;idx=order[i];if(i===0){vars.push(["d",j,"s",i,"=t",j,"p",idx].join(""))}else{vars.push(["d",j,"s",i,"=(t",j,"p",idx,"-s",pidx,"*t",j,"p",pidx,")"].join(""))}}}code.push("var "+vars.join(","));for(i=dimension-1;i>=0;--i){idx=order[i];code.push(["for(i",i,"=0;i",i,"<s",idx,";++i",i,"){"].join(""))}code.push(body);for(i=0;i<dimension;++i){pidx=idx;idx=order[i];for(j=0;j<nargs;++j){code.push(["p",j,"+=d",j,"s",i].join(""))}if(has_index){if(i>0){code.push(["index[",pidx,"]-=s",pidx].join(""))}code.push(["++index[",idx,"]"].join(""))}code.push("}")}return code.join("\n")}function outerFill(matched,order,proc,body){var dimension=order.length,nargs=proc.arrayArgs.length,blockSize=proc.blockSize,has_index=proc.indexArgs.length>0,code=[];for(var i=0;i<nargs;++i){code.push(["var offset",i,"=p",i].join(""))}for(var i=matched;i<dimension;++i){code.push(["for(var j"+i+"=SS[",order[i],"]|0;j",i,">0;){"].join(""));code.push(["if(j",i,"<",blockSize,"){"].join(""));code.push(["s",order[i],"=j",i].join(""));code.push(["j",i,"=0"].join(""));code.push(["}else{s",order[i],"=",blockSize].join(""));code.push(["j",i,"-=",blockSize,"}"].join(""));if(has_index){code.push(["index[",order[i],"]=j",i].join(""))}}for(var i=0;i<nargs;++i){var indexStr=["offset"+i];for(var j=matched;j<dimension;++j){indexStr.push(["j",j,"*t",i,"p",order[j]].join(""))}code.push(["p",i,"=(",indexStr.join("+"),")"].join(""))}code.push(innerFill(order,proc,body));for(var i=matched;i<dimension;++i){code.push("}")}return code.join("\n")}function countMatches(orders){var matched=0,dimension=orders[0].length;while(matched<dimension){for(var j=1;j<orders.length;++j){if(orders[j][matched]!==orders[0][matched]){return matched}}++matched}return matched}function processBlock(block,proc,dtypes){var code=block.body;var pre=[];var post=[];for(var i=0;i<block.args.length;++i){var carg=block.args[i];if(carg.count<=0){continue}var re=new RegExp(carg.name,"g");var ptrStr="";var arrNum=proc.arrayArgs.indexOf(i);switch(proc.argTypes[i]){case"offset":var offArgIndex=proc.offsetArgIndex.indexOf(i);var offArg=proc.offsetArgs[offArgIndex];arrNum=offArg.array;ptrStr="+q"+offArgIndex;case"array":ptrStr="p"+arrNum+ptrStr;var localStr="l"+i;var arrStr="a"+arrNum;if(carg.count===1){if(dtypes[arrNum]==="generic"){if(carg.lvalue){pre.push(["var ",localStr,"=",arrStr,".get(",ptrStr,")"].join(""));code=code.replace(re,localStr);post.push([arrStr,".set(",ptrStr,",",localStr,")"].join(""))}else{code=code.replace(re,[arrStr,".get(",ptrStr,")"].join(""))}}else{code=code.replace(re,[arrStr,"[",ptrStr,"]"].join(""))}}else if(dtypes[arrNum]==="generic"){pre.push(["var ",localStr,"=",arrStr,".get(",ptrStr,")"].join(""));code=code.replace(re,localStr);if(carg.lvalue){post.push([arrStr,".set(",ptrStr,",",localStr,")"].join(""))}}else{pre.push(["var ",localStr,"=",arrStr,"[",ptrStr,"]"].join(""));code=code.replace(re,localStr);if(carg.lvalue){post.push([arrStr,"[",ptrStr,"]=",localStr].join(""))}}break;case"scalar":code=code.replace(re,"Y"+proc.scalarArgs.indexOf(i));break;case"index":code=code.replace(re,"index");break;case"shape":code=code.replace(re,"shape");break}}return[pre.join("\n"),code,post.join("\n")].join("\n").trim()}function typeSummary(dtypes){var summary=new Array(dtypes.length);var allEqual=true;for(var i=0;i<dtypes.length;++i){var t=dtypes[i];var digits=t.match(/\d+/);if(!digits){digits=""}else{digits=digits[0]}if(t.charAt(0)===0){summary[i]="u"+t.charAt(1)+digits}else{summary[i]=t.charAt(0)+digits}if(i>0){allEqual=allEqual&&summary[i]===summary[i-1]}}if(allEqual){return summary[0]}return summary.join("")}function generateCWiseOp(proc,typesig){var dimension=typesig[1].length|0;var orders=new Array(proc.arrayArgs.length);var dtypes=new Array(proc.arrayArgs.length);var arglist=["SS"];var code=["'use strict'"];var vars=[];for(var j=0;j<dimension;++j){vars.push(["s",j,"=SS[",j,"]"].join(""))}for(var i=0;i<proc.arrayArgs.length;++i){arglist.push("a"+i);arglist.push("t"+i);arglist.push("p"+i);dtypes[i]=typesig[2*i];orders[i]=typesig[2*i+1];for(var j=0;j<dimension;++j){vars.push(["t",i,"p",j,"=t",i,"[",j,"]"].join(""))}}for(var i=0;i<proc.scalarArgs.length;++i){arglist.push("Y"+i)}if(proc.shapeArgs.length>0){vars.push("shape=SS.slice(0)")}if(proc.indexArgs.length>0){var zeros=new Array(dimension);for(var i=0;i<dimension;++i){zeros[i]="0"}vars.push(["index=[",zeros.join(","),"]"].join(""))}for(var i=0;i<proc.offsetArgs.length;++i){var off_arg=proc.offsetArgs[i];var init_string=[];for(var j=0;j<off_arg.offset.length;++j){if(off_arg.offset[j]===0){continue}else if(off_arg.offset[j]===1){init_string.push(["t",off_arg.array,"p",j].join(""))}else{init_string.push([off_arg.offset[j],"*t",off_arg.array,"p",j].join(""))}}if(init_string.length===0){vars.push("q"+i+"=0")}else{vars.push(["q",i,"=",init_string.join("+")].join(""))}}var thisVars=uniq([].concat(proc.pre.thisVars).concat(proc.body.thisVars).concat(proc.post.thisVars));vars=vars.concat(thisVars);code.push("var "+vars.join(","));for(var i=0;i<proc.arrayArgs.length;++i){code.push("p"+i+"|=0")}if(proc.pre.body.length>3){code.push(processBlock(proc.pre,proc,dtypes))}var body=processBlock(proc.body,proc,dtypes);var matched=countMatches(orders);if(matched<dimension){code.push(outerFill(matched,orders[0],proc,body))}else{code.push(innerFill(orders[0],proc,body))}if(proc.post.body.length>3){code.push(processBlock(proc.post,proc,dtypes))}if(proc.debug){console.log("Generated cwise routine for ",typesig,":\n\n",code.join("\n"))}var loopName=[proc.funcName||"unnamed","_cwise_loop_",orders[0].join("s"),"m",matched,typeSummary(dtypes)].join("");var f=new Function(["function ",loopName,"(",arglist.join(","),"){",code.join("\n"),"} return ",loopName].join(""));return f()}module.exports=generateCWiseOp},{uniq:45}],44:[function(require,module,exports){"use strict";var compile=require("./compile.js");function createThunk(proc){var code=["'use strict'","var CACHED={}"];var vars=[];var thunkName=proc.funcName+"_cwise_thunk";code.push(["return function ",thunkName,"(",proc.shimArgs.join(","),"){"].join(""));var typesig=[];var string_typesig=[];var proc_args=[["array",proc.arrayArgs[0],".shape"].join("")];for(var i=0;i<proc.arrayArgs.length;++i){var j=proc.arrayArgs[i];vars.push(["t",j,"=array",j,".dtype,","r",j,"=array",j,".order"].join(""));typesig.push("t"+j);typesig.push("r"+j);string_typesig.push("t"+j);string_typesig.push("r"+j+".join()");proc_args.push("array"+j+".data");proc_args.push("array"+j+".stride");proc_args.push("array"+j+".offset|0")}for(var i=0;i<proc.scalarArgs.length;++i){proc_args.push("scalar"+proc.scalarArgs[i])}vars.push(["type=[",string_typesig.join(","),"].join()"].join(""));vars.push("proc=CACHED[type]");code.push("var "+vars.join(","));code.push(["if(!proc){","CACHED[type]=proc=compile([",typesig.join(","),"])}","return proc(",proc_args.join(","),")}"].join(""));if(proc.debug){console.log("Generated thunk:",code.join("\n"))}var thunk=new Function("compile",code.join("\n"));return thunk(compile.bind(undefined,proc))}module.exports=createThunk},{"./compile.js":43}],45:[function(require,module,exports){"use strict";function unique_pred(list,compare){var ptr=1,len=list.length,a=list[0],b=list[0];for(var i=1;i<len;++i){b=a;a=list[i];if(compare(a,b)){if(i===ptr){ptr++;continue}list[ptr++]=a}}list.length=ptr;return list}function unique_eq(list){var ptr=1,len=list.length,a=list[0],b=list[0];for(var i=1;i<len;++i,b=a){b=a;a=list[i];if(a!==b){if(i===ptr){ptr++;continue}list[ptr++]=a}}list.length=ptr;return list}function unique(list,compare,sorted){if(list.length===0){return list}if(compare){if(!sorted){list.sort(compare)}return unique_pred(list,compare)}if(!sorted){list.sort()}return unique_eq(list)}module.exports=unique},{}],46:[function(require,module,exports){"use strict";var compile=require("cwise-compiler");var EmptyProc={body:"",args:[],thisVars:[],localVars:[]};function fixup(x){if(!x){return EmptyProc}for(var i=0;i<x.args.length;++i){var a=x.args[i];if(i===0){x.args[i]={name:a,lvalue:true,rvalue:!!x.rvalue,count:x.count||1}}else{x.args[i]={name:a,lvalue:false,rvalue:true,count:1}}}if(!x.thisVars){x.thisVars=[]}if(!x.localVars){x.localVars=[]}return x}function pcompile(user_args){return compile({args:user_args.args,pre:fixup(user_args.pre),body:fixup(user_args.body),post:fixup(user_args.proc),funcName:user_args.funcName})}function makeOp(user_args){var args=[];for(var i=0;i<user_args.args.length;++i){args.push("a"+i)}var wrapper=new Function("P",["return function ",user_args.funcName,"_ndarrayops(",args.join(","),") {P(",args.join(","),");return a0}"].join(""));return wrapper(pcompile(user_args))}var assign_ops={add:"+",sub:"-",mul:"*",div:"/",mod:"%",band:"&",bor:"|",bxor:"^",lshift:"<<",rshift:">>",rrshift:">>>"};(function(){for(var id in assign_ops){var op=assign_ops[id];exports[id]=makeOp({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+op+"c"},funcName:id});exports[id+"eq"]=makeOp({args:["array","array"],body:{args:["a","b"],body:"a"+op+"=b"},rvalue:true,funcName:id+"eq"});exports[id+"s"]=makeOp({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+op+"s"},funcName:id+"s"});exports[id+"seq"]=makeOp({args:["array","scalar"],body:{args:["a","s"],body:"a"+op+"=s"},rvalue:true,funcName:id+"seq"})}})();var unary_ops={not:"!",bnot:"~",neg:"-",recip:"1.0/"};(function(){for(var id in unary_ops){var op=unary_ops[id];exports[id]=makeOp({args:["array","array"],body:{args:["a","b"],body:"a="+op+"b"},funcName:id});exports[id+"eq"]=makeOp({args:["array"],body:{args:["a"],body:"a="+op+"a"},rvalue:true,count:2,funcName:id+"eq"})}})();var binary_ops={and:"&&",or:"||",eq:"===",neq:"!==",lt:"<",gt:">",leq:"<=",geq:">="};(function(){for(var id in binary_ops){var op=binary_ops[id];exports[id]=makeOp({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+op+"c"},funcName:id});exports[id+"s"]=makeOp({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+op+"s"},funcName:id+"s"});exports[id+"eq"]=makeOp({args:["array","array"],body:{args:["a","b"],body:"a=a"+op+"b"},rvalue:true,count:2,funcName:id+"eq"});exports[id+"seq"]=makeOp({args:["array","scalar"],body:{args:["a","s"],body:"a=a"+op+"s"},rvalue:true,count:2,funcName:id+"seq"})}})();var math_unary=["abs","acos","asin","atan","ceil","cos","exp","floor","log","round","sin","sqrt","tan"];(function(){for(var i=0;i<math_unary.length;++i){var f=math_unary[i];exports[f]=makeOp({args:["array","array"],pre:{args:[],body:"this_f=Math."+f,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b)",thisVars:["this_f"]},funcName:f});exports[f+"eq"]=makeOp({args:["array"],pre:{args:[],body:"this_f=Math."+f,thisVars:["this_f"]},body:{args:["a"],body:"a=this_f(a)",thisVars:["this_f"]},rvalue:true,count:2,funcName:f+"eq"})}})();var math_comm=["max","min","atan2","pow"];(function(){for(var i=0;i<math_comm.length;++i){var f=math_comm[i];exports[f]=makeOp({args:["array","array","array"],pre:{args:[],body:"this_f=Math."+f,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(b,c)",thisVars:["this_f"]},funcName:f});exports[f+"s"]=makeOp({args:["array","array","scalar"],pre:{args:[],body:"this_f=Math."+f,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(b,c)",thisVars:["this_f"]},funcName:f+"s"});exports[f+"eq"]=makeOp({args:["array","array"],pre:{args:[],body:"this_f=Math."+f,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(a,b)",thisVars:["this_f"]},rvalue:true,count:2,funcName:f+"eq"});exports[f+"seq"]=makeOp({args:["array","scalar"],pre:{args:[],body:"this_f=Math."+f,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(a,b)",thisVars:["this_f"]},rvalue:true,count:2,funcName:f+"seq"})}})();var math_noncomm=["atan2","pow"];(function(){for(var i=0;i<math_noncomm.length;++i){var f=math_noncomm[i];exports[f+"op"]=makeOp({args:["array","array","array"],pre:{args:[],body:"this_f=Math."+f,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(c,b)",thisVars:["this_f"]},funcName:f+"op"});exports[f+"ops"]=makeOp({args:["array","array","scalar"],pre:{args:[],body:"this_f=Math."+f,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(c,b)",thisVars:["this_f"]},funcName:f+"ops"});exports[f+"opeq"]=makeOp({args:["array","array"],pre:{args:[],body:"this_f=Math."+f,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b,a)",thisVars:["this_f"]},rvalue:true,count:2,funcName:f+"opeq"});exports[f+"opseq"]=makeOp({args:["array","scalar"],pre:{args:[],body:"this_f=Math."+f,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b,a)",thisVars:["this_f"]},rvalue:true,count:2,funcName:f+"opseq"})}})();exports.any=compile({args:["array"],pre:EmptyProc,body:{args:[{name:"a",lvalue:false,rvalue:true,count:1}],body:"if(a){return true}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return false"},funcName:"any"});exports.all=compile({args:["array"],pre:EmptyProc,body:{args:[{name:"x",lvalue:false,rvalue:true,count:1}],body:"if(!x){return false}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return true"},funcName:"all"});exports.sum=compile({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:false,rvalue:true,count:1}],body:"this_s+=a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"sum"});exports.prod=compile({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=1"},body:{args:[{name:"a",lvalue:false,rvalue:true,count:1}],body:"this_s*=a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"prod"});exports.norm2squared=compile({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:false,rvalue:true,count:2}],body:"this_s+=a*a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm2squared"});exports.norm2=compile({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:false,rvalue:true,count:2}],body:"this_s+=a*a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return Math.sqrt(this_s)"},funcName:"norm2"});exports.norminf=compile({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:false,rvalue:true,count:4}],body:"if(-a>this_s){this_s=-a}else if(a>this_s){this_s=a}",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norminf"});exports.norm1=compile({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:false,rvalue:true,count:3}],body:"this_s+=a<0?-a:a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm1"});exports.sup=compile({args:["array"],pre:{body:"this_h=-Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_>this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:false,rvalue:true,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}});exports.inf=compile({args:["array"],pre:{body:"this_h=Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_<this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:false,rvalue:true,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}});exports.argmin=compile({args:["index","array","shape"],pre:{body:"{this_v=Infinity;this_i=_inline_0_arg2_.slice(0)}",args:[{name:"_inline_0_arg0_",lvalue:false,rvalue:false,count:0},{name:"_inline_0_arg1_",lvalue:false,rvalue:false,count:0},{name:"_inline_0_arg2_",lvalue:false,rvalue:true,count:1}],thisVars:["this_i","this_v"],localVars:[]},body:{body:"{if(_inline_1_arg1_<this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:false,rvalue:true,count:2},{name:"_inline_1_arg1_",lvalue:false,rvalue:true,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}});exports.argmax=compile({args:["index","array","shape"],pre:{body:"{this_v=-Infinity;this_i=_inline_0_arg2_.slice(0)}",args:[{name:"_inline_0_arg0_",lvalue:false,rvalue:false,count:0},{name:"_inline_0_arg1_",lvalue:false,rvalue:false,count:0},{name:"_inline_0_arg2_",lvalue:false,rvalue:true,count:1}],thisVars:["this_i","this_v"],localVars:[]},body:{body:"{if(_inline_1_arg1_>this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:false,rvalue:true,count:2},{name:"_inline_1_arg1_",lvalue:false,rvalue:true,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}});exports.random=makeOp({args:["array"],pre:{args:[],body:"this_f=Math.random",thisVars:["this_f"]},body:{args:["a"],body:"a=this_f()",thisVars:["this_f"]},funcName:"random"});exports.assign=makeOp({args:["array","array"],body:{args:["a","b"],body:"a=b"},funcName:"assign"});exports.assigns=makeOp({args:["array","scalar"],body:{args:["a","b"],body:"a=b"},funcName:"assigns"});exports.equals=compile({args:["array","array"],pre:EmptyProc,body:{args:[{name:"x",lvalue:false,rvalue:true,count:1},{name:"y",lvalue:false,rvalue:true,count:1}],body:"if(x!==y){return false}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return true"},funcName:"equals"})},{"cwise-compiler":47}],47:[function(require,module,exports){module.exports=require(42)},{"./lib/thunk.js":49}],48:[function(require,module,exports){module.exports=require(43)},{uniq:50}],49:[function(require,module,exports){module.exports=require(44)},{"./compile.js":48}],50:[function(require,module,exports){module.exports=require(45)},{}],51:[function(require,module,exports){"use strict";var ops=require("ndarray-ops");var cwise=require("cwise");var ndarray=require("ndarray");var fftm=require("./lib/fft-matrix.js");var pool=require("typedarray-pool");function ndfft(dir,x,y){var shape=x.shape,d=shape.length,size=1,stride=new Array(d),pad=0,i,j;for(i=d-1;i>=0;--i){stride[i]=size;size*=shape[i];pad=Math.max(pad,fftm.scratchMemory(shape[i]));if(x.shape[i]!==y.shape[i]){throw new Error("Shape mismatch, real and imaginary arrays must have same size")}}var buf_size=4*size+pad;var buffer;if(x.dtype==="array"||x.dtype==="float64"||x.dtype==="custom"){buffer=pool.mallocDouble(buf_size)}else{buffer=pool.mallocFloat(buf_size)}var x1=ndarray(buffer,shape.slice(0),stride,0),y1=ndarray(buffer,shape.slice(0),stride.slice(0),size),x2=ndarray(buffer,shape.slice(0),stride.slice(0),2*size),y2=ndarray(buffer,shape.slice(0),stride.slice(0),3*size),tmp,n,s1,s2,scratch_ptr=4*size;ops.assign(x1,x);ops.assign(y1,y);for(i=d-1;i>=0;--i){fftm(dir,size/shape[i],shape[i],buffer,x1.offset,y1.offset,scratch_ptr);if(i===0){break}n=1;s1=x2.stride;s2=y2.stride;for(j=i-1;j<d;++j){s2[j]=s1[j]=n;n*=shape[j]}for(j=i-2;j>=0;--j){s2[j]=s1[j]=n;n*=shape[j]}ops.assign(x2,x1);ops.assign(y2,y1);tmp=x1;x1=x2;x2=tmp;tmp=y1;y1=y2;y2=tmp}ops.assign(x,x1);ops.assign(y,y1);pool.free(buffer)}module.exports=ndfft},{"./lib/fft-matrix.js":52,cwise:54,ndarray:69,"ndarray-ops":62,"typedarray-pool":68}],52:[function(require,module,exports){var bits=require("bit-twiddle");function fft(dir,nrows,ncols,buffer,x_ptr,y_ptr,scratch_ptr){dir|=0;nrows|=0;ncols|=0;x_ptr|=0;y_ptr|=0;if(bits.isPow2(ncols)){fftRadix2(dir,nrows,ncols,buffer,x_ptr,y_ptr)}else{fftBluestein(dir,nrows,ncols,buffer,x_ptr,y_ptr,scratch_ptr)}}module.exports=fft;function scratchMemory(n){if(bits.isPow2(n)){return 0}return 2*n+4*bits.nextPow2(2*n+1)}module.exports.scratchMemory=scratchMemory;function fftRadix2(dir,nrows,ncols,buffer,x_ptr,y_ptr){dir|=0;nrows|=0;ncols|=0;x_ptr|=0;y_ptr|=0;var nn,i,i1,j,k,i2,l,l1,l2;var c1,c2,t,t1,t2,u1,u2,z,row,a,b,c,d,k1,k2,k3;nn=ncols;m=bits.log2(nn);for(row=0;row<nrows;++row){i2=nn>>1;j=0;for(i=0;i<nn-1;i++){if(i<j){t=buffer[x_ptr+i];buffer[x_ptr+i]=buffer[x_ptr+j];buffer[x_ptr+j]=t;t=buffer[y_ptr+i];buffer[y_ptr+i]=buffer[y_ptr+j];buffer[y_ptr+j]=t}k=i2;while(k<=j){j-=k;k>>=1}j+=k}c1=-1;c2=0;l2=1;for(l=0;l<m;l++){l1=l2;l2<<=1;u1=1;u2=0;for(j=0;j<l1;j++){for(i=j;i<nn;i+=l2){i1=i+l1;a=buffer[x_ptr+i1];b=buffer[y_ptr+i1];c=buffer[x_ptr+i];d=buffer[y_ptr+i];k1=u1*(a+b);k2=a*(u2-u1);k3=b*(u1+u2);t1=k1-k3;t2=k1+k2;buffer[x_ptr+i1]=c-t1;buffer[y_ptr+i1]=d-t2;buffer[x_ptr+i]+=t1;buffer[y_ptr+i]+=t2}k1=c1*(u1+u2);k2=u1*(c2-c1);k3=u2*(c1+c2);u1=k1-k3;u2=k1+k2}c2=Math.sqrt((1-c1)/2);if(dir<0){c2=-c2}c1=Math.sqrt((1+c1)/2)}if(dir<0){var scale_f=1/nn;for(i=0;i<nn;i++){buffer[x_ptr+i]*=scale_f;buffer[y_ptr+i]*=scale_f}}x_ptr+=ncols;y_ptr+=ncols}}function fftBluestein(dir,nrows,ncols,buffer,x_ptr,y_ptr,scratch_ptr){dir|=0;nrows|=0;ncols|=0;x_ptr|=0;y_ptr|=0;scratch_ptr|=0;var m=bits.nextPow2(2*ncols+1),cos_ptr=scratch_ptr,sin_ptr=cos_ptr+ncols,xs_ptr=sin_ptr+ncols,ys_ptr=xs_ptr+m,cft_ptr=ys_ptr+m,sft_ptr=cft_ptr+m,w=-dir*Math.PI/ncols,row,a,b,c,d,k1,k2,k3,i;for(i=0;i<ncols;++i){a=w*(i*i%(ncols*2));c=Math.cos(a);d=Math.sin(a);buffer[cft_ptr+(m-i)]=buffer[cft_ptr+i]=buffer[cos_ptr+i]=c;buffer[sft_ptr+(m-i)]=buffer[sft_ptr+i]=buffer[sin_ptr+i]=d}for(i=ncols;i<=m-ncols;++i){buffer[cft_ptr+i]=0}for(i=ncols;i<=m-ncols;++i){buffer[sft_ptr+i]=0}fftRadix2(1,1,m,buffer,cft_ptr,sft_ptr);if(dir<0){w=1/ncols}else{w=1}for(row=0;row<nrows;++row){for(i=0;i<ncols;++i){a=buffer[x_ptr+i];b=buffer[y_ptr+i];c=buffer[cos_ptr+i];d=-buffer[sin_ptr+i];k1=c*(a+b);k2=a*(d-c);k3=b*(c+d);buffer[xs_ptr+i]=k1-k3;buffer[ys_ptr+i]=k1+k2}for(i=ncols;i<m;++i){buffer[xs_ptr+i]=0}for(i=ncols;i<m;++i){buffer[ys_ptr+i]=0}fftRadix2(1,1,m,buffer,xs_ptr,ys_ptr);for(i=0;i<m;++i){a=buffer[xs_ptr+i];b=buffer[ys_ptr+i];c=buffer[cft_ptr+i];d=buffer[sft_ptr+i];k1=c*(a+b);k2=a*(d-c);k3=b*(c+d);buffer[xs_ptr+i]=k1-k3;buffer[ys_ptr+i]=k1+k2}fftRadix2(-1,1,m,buffer,xs_ptr,ys_ptr);for(i=0;i<ncols;++i){a=buffer[xs_ptr+i];b=buffer[ys_ptr+i];c=buffer[cos_ptr+i];d=-buffer[sin_ptr+i];k1=c*(a+b);k2=a*(d-c);k3=b*(c+d);buffer[x_ptr+i]=w*(k1-k3);buffer[y_ptr+i]=w*(k1+k2)}x_ptr+=ncols;y_ptr+=ncols}}},{"bit-twiddle":53}],53:[function(require,module,exports){"use strict";"use restrict";var INT_BITS=32;exports.INT_BITS=INT_BITS;exports.INT_MAX=2147483647;exports.INT_MIN=-1<<INT_BITS-1;exports.sign=function(v){return(v>0)-(v<0)};exports.abs=function(v){var mask=v>>INT_BITS-1;return(v^mask)-mask};exports.min=function(x,y){return y^(x^y)&-(x<y)};exports.max=function(x,y){return x^(x^y)&-(x<y)};exports.isPow2=function(v){return!(v&v-1)&&!!v};exports.log2=function(v){var r,shift;r=(v>65535)<<4;v>>>=r;shift=(v>255)<<3;v>>>=shift;r|=shift;shift=(v>15)<<2;v>>>=shift;r|=shift;shift=(v>3)<<1;v>>>=shift;r|=shift;return r|v>>1};exports.log10=function(v){return v>=1e9?9:v>=1e8?8:v>=1e7?7:v>=1e6?6:v>=1e5?5:v>=1e4?4:v>=1e3?3:v>=100?2:v>=10?1:0};exports.popCount=function(v){v=v-(v>>>1&1431655765);v=(v&858993459)+(v>>>2&858993459);return(v+(v>>>4)&252645135)*16843009>>>24};function countTrailingZeros(v){var c=32;v&=-v;if(v)c--;if(v&65535)c-=16;if(v&16711935)c-=8;if(v&252645135)c-=4;if(v&858993459)c-=2;if(v&1431655765)c-=1;return c}exports.countTrailingZeros=countTrailingZeros;exports.nextPow2=function(v){v+=v===0;--v;v|=v>>>1;v|=v>>>2;v|=v>>>4;v|=v>>>8;v|=v>>>16;return v+1};exports.prevPow2=function(v){v|=v>>>1;v|=v>>>2;v|=v>>>4;v|=v>>>8;v|=v>>>16;return v-(v>>>1)};exports.parity=function(v){v^=v>>>16;v^=v>>>8;v^=v>>>4;v&=15;return 27030>>>v&1};var REVERSE_TABLE=new Array(256);(function(tab){for(var i=0;i<256;++i){var v=i,r=i,s=7;for(v>>>=1;v;v>>>=1){r<<=1;r|=v&1;--s}tab[i]=r<<s&255}})(REVERSE_TABLE);exports.reverse=function(v){return REVERSE_TABLE[v&255]<<24|REVERSE_TABLE[v>>>8&255]<<16|REVERSE_TABLE[v>>>16&255]<<8|REVERSE_TABLE[v>>>24&255]};exports.interleave2=function(x,y){x&=65535;x=(x|x<<8)&16711935;x=(x|x<<4)&252645135;x=(x|x<<2)&858993459;x=(x|x<<1)&1431655765;y&=65535;y=(y|y<<8)&16711935;y=(y|y<<4)&252645135;y=(y|y<<2)&858993459;y=(y|y<<1)&1431655765;return x|y<<1};exports.deinterleave2=function(v,n){v=v>>>n&1431655765;v=(v|v>>>1)&858993459;v=(v|v>>>2)&252645135;v=(v|v>>>4)&16711935;v=(v|v>>>16)&65535;return v<<16>>16};exports.interleave3=function(x,y,z){x&=1023;x=(x|x<<16)&4278190335;x=(x|x<<8)&251719695;x=(x|x<<4)&3272356035;x=(x|x<<2)&1227133513;y&=1023;y=(y|y<<16)&4278190335;y=(y|y<<8)&251719695;y=(y|y<<4)&3272356035;y=(y|y<<2)&1227133513;x|=y<<1;z&=1023;z=(z|z<<16)&4278190335;z=(z|z<<8)&251719695;z=(z|z<<4)&3272356035;z=(z|z<<2)&1227133513;return x|z<<2};exports.deinterleave3=function(v,n){v=v>>>n&1227133513;v=(v|v>>>2)&3272356035;v=(v|v>>>4)&251719695;v=(v|v>>>8)&4278190335;v=(v|v>>>16)&1023;return v<<22>>22};exports.nextCombination=function(v){var t=v|v-1;return t+1|(~t&-~t)-1>>>countTrailingZeros(v)+1}},{}],54:[function(require,module,exports){"use strict";var parse=require("cwise-parser");var compile=require("cwise-compiler");var REQUIRED_FIELDS=["args","body"];var OPTIONAL_FIELDS=["pre","post","printCode","funcName","blockSize"];function createCWise(user_args){for(var id in user_args){if(REQUIRED_FIELDS.indexOf(id)<0&&OPTIONAL_FIELDS.indexOf(id)<0){console.warn("cwise: Unknown argument '"+id+"' passed to expression compiler")}}for(var i=0;i<REQUIRED_FIELDS.length;++i){if(!user_args[REQUIRED_FIELDS[i]]){throw new Error("cwise: Missing argument: "+REQUIRED_FIELDS[i])}}return compile({args:user_args.args,pre:parse(user_args.pre||function(){}),body:parse(user_args.body),post:parse(user_args.post||function(){}),debug:!!user_args.printCode,funcName:user_args.funcName||user_args.body.name||"cwise",blockSize:user_args.blockSize||64})}module.exports=createCWise},{"cwise-compiler":55,"cwise-parser":59}],55:[function(require,module,exports){"use strict";var createThunk=require("./lib/thunk.js");function Procedure(){this.argTypes=[];this.shimArgs=[];this.arrayArgs=[];this.scalarArgs=[];this.indexArgs=[];this.shapeArgs=[];this.funcName="";this.pre=null;this.body=null;this.post=null;this.debug=false}function compileCwise(user_args){var proc=new Procedure;proc.pre=user_args.pre;proc.body=user_args.body;proc.post=user_args.post;var proc_args=user_args.args.slice(0);proc.argTypes=proc_args;for(var i=0;i<proc_args.length;++i){switch(proc_args[i]){case"array":proc.arrayArgs.push(i);proc.shimArgs.push("array"+i);if(i<proc.pre.args.length&&proc.pre.args[i].count>0){throw new Error("cwise: pre() block may not reference array args")}if(i<proc.post.args.length&&proc.post.args[i].count>0){throw new Error("cwise: post() block may not reference array args")}break;case"scalar":proc.scalarArgs.push(i);proc.shimArgs.push("scalar"+i);break;case"index":proc.indexArgs.push(i);if(i<proc.pre.args.length&&proc.pre.args[i].count>0){throw new Error("cwise: pre() block may not reference array index")}if(i<proc.body.args.length&&proc.body.args[i].lvalue){throw new Error("cwise: body() block may not write to array index")}if(i<proc.post.args.length&&proc.post.args[i].count>0){throw new Error("cwise: post() block may not reference array index")}break;case"shape":proc.shapeArgs.push(i);if(i<proc.pre.args.length&&proc.pre.args[i].lvalue){throw new Error("cwise: pre() block may not write to array shape")}if(i<proc.body.args.length&&proc.body.args[i].lvalue){throw new Error("cwise: body() block may not write to array shape")}if(i<proc.post.args.length&&proc.post.args[i].lvalue){throw new Error("cwise: post() block may not write to array shape")}break;default:throw new Error("cwise: Unknown argument type "+proc_args[i])}}if(proc.arrayArgs.length<=0){throw new Error("cwise: No array arguments specified")}if(proc.pre.args.length>proc_args.length){throw new Error("cwise: Too many arguments in pre() block")}if(proc.body.args.length>proc_args.length){throw new Error("cwise: Too many arguments in body() block")}if(proc.post.args.length>proc_args.length){throw new Error("cwise: Too many arguments in post() block")}proc.debug=!!user_args.printCode||!!user_args.debug;proc.funcName=user_args.funcName||"cwise";proc.blockSize=user_args.blockSize||64;return createThunk(proc)}module.exports=compileCwise},{"./lib/thunk.js":57}],56:[function(require,module,exports){"use strict";var uniq=require("uniq");function innerFill(order,proc,body){var dimension=order.length,nargs=proc.arrayArgs.length,has_index=proc.indexArgs.length>0,code=[],vars=[],idx=0,pidx=0,i,j;for(i=0;i<dimension;++i){vars.push(["i",i,"=0"].join(""))}for(j=0;j<nargs;++j){for(i=0;i<dimension;++i){pidx=idx;idx=order[i];if(i===0){vars.push(["d",j,"s",i,"=t",j,"[",idx,"]"].join(""))}else{vars.push(["d",j,"s",i,"=(t",j,"[",idx,"]-s",pidx,"*t",j,"[",pidx,"])"].join(""))}}}code.push("var "+vars.join(","));for(i=dimension-1;i>=0;--i){idx=order[i];code.push(["for(i",i,"=0;i",i,"<s",idx,";++i",i,"){"].join(""))}code.push(body);for(i=0;i<dimension;++i){pidx=idx;idx=order[i];for(j=0;j<nargs;++j){code.push(["p",j,"+=d",j,"s",i].join(""))}if(has_index){if(i>0){code.push(["index[",pidx,"]-=s",pidx].join(""))}code.push(["++index[",idx,"]"].join(""))}code.push("}")}return code.join("\n")}function outerFill(matched,order,proc,body){var dimension=order.length,nargs=proc.arrayArgs.length,blockSize=proc.blockSize,has_index=proc.indexArgs.length>0,code=[];for(var i=0;i<nargs;++i){code.push(["var offset",i,"=p",i].join(""))}for(var i=matched;i<dimension;++i){code.push(["for(var j"+i+"=SS[",order[i],"]|0;j",i,">0;){"].join(""));code.push(["if(j",i,"<",blockSize,"){"].join(""));code.push(["s",order[i],"=j",i].join(""));code.push(["j",i,"=0"].join(""));code.push(["}else{s",order[i],"=",blockSize].join(""));code.push(["j",i,"-=",blockSize,"}"].join(""));if(has_index){code.push(["index[",order[i],"]=j",i].join(""))}}for(var i=0;i<nargs;++i){var indexStr=["offset"+i];for(var j=matched;j<dimension;++j){indexStr.push(["j",j,"*t",i,"[",order[j],"]"].join(""))}code.push(["p",i,"=(",indexStr.join("+"),")"].join(""))}code.push(innerFill(order,proc,body));for(var i=matched;i<dimension;++i){code.push("}")}return code.join("\n")}function countMatches(orders){var matched=0,dimension=orders[0].length;while(matched<dimension){for(var j=1;j<orders.length;++j){if(orders[j][matched]!==orders[0][matched]){return matched}}++matched}return matched
}function processBlock(block,proc,dtypes){var code=block.body;var pre=[];var post=[];for(var i=0;i<block.args.length;++i){var carg=block.args[i];if(carg.count<=0){continue}var re=new RegExp(carg.name,"g");switch(proc.argTypes[i]){case"array":var arrNum=proc.arrayArgs.indexOf(i);if(carg.count===1){if(dtypes[arrNum]==="generic"){if(carg.lvalue){pre.push(["var l",arrNum,"=a",arrNum,".get(p",arrNum,")"].join(""));code=code.replace(re,"l"+arrNum);post.push(["a",arrNum,".set(p",arrNum,",l",arrNum,")"].join(""))}else{code=code.replace(re,["a",arrNum,".get(p",arrNum,")"].join(""))}}else{code=code.replace(re,["a",arrNum,"[p",arrNum,"]"].join(""))}}else if(dtypes[arrNum]==="generic"){pre.push(["var l",arrNum,"=a",arrNum,".get(p",arrNum,")"].join(""));code=code.replace(re,"l"+arrNum);if(carg.lvalue){post.push(["a",arrNum,".set(p",arrNum,",l",arrNum,")"].join(""))}}else{pre.push(["var l",arrNum,"=a",arrNum,"[p",arrNum,"]"].join(""));code=code.replace(re,"l"+arrNum);if(carg.lvalue){post.push(["a",arrNum,"[p",arrNum,"]=l",arrNum].join(""))}}break;case"scalar":code=code.replace(re,"Y"+proc.scalarArgs.indexOf(i));break;case"index":code=code.replace(re,"index");break;case"shape":code=code.replace(re,"shape");break}}return[pre.join("\n"),code,post.join("\n")].join("\n").trim()}function typeSummary(dtypes){var summary=new Array(dtypes.length);var allEqual=true;for(var i=0;i<dtypes.length;++i){var t=dtypes[i];var digits=t.match(/\d+/);if(!digits){digits=""}else{digits=digits[0]}if(t.charAt(0)===0){summary[i]="u"+t.charAt(1)+digits}else{summary[i]=t.charAt(0)+digits}if(i>0){allEqual=allEqual&&summary[i]===summary[i-1]}}if(allEqual){return summary[0]}return summary.join("")}function generateCWiseOp(proc,typesig){var dimension=typesig[1].length|0;var orders=new Array(proc.arrayArgs.length);var dtypes=new Array(proc.arrayArgs.length);var arglist=["SS"];var code=["'use strict'"];var vars=[];for(var j=0;j<dimension;++j){vars.push(["s",j,"=SS[",j,"]"].join(""))}for(var i=0;i<proc.arrayArgs.length;++i){arglist.push("a"+i);arglist.push("t"+i);arglist.push("p"+i);dtypes[i]=typesig[2*i];orders[i]=typesig[2*i+1]}for(var i=0;i<proc.scalarArgs.length;++i){arglist.push("Y"+i)}if(proc.shapeArgs.length>0){vars.push("shape=SS.slice(0)")}if(proc.indexArgs.length>0){var zeros=new Array(dimension);for(var i=0;i<dimension;++i){zeros[i]="0"}vars.push(["index=[",zeros.join(","),"]"].join(""))}var thisVars=uniq([].concat(proc.pre.thisVars).concat(proc.body.thisVars).concat(proc.post.thisVars));vars=vars.concat(thisVars);code.push("var "+vars.join(","));for(var i=0;i<proc.arrayArgs.length;++i){code.push("p"+i+"|=0")}if(proc.pre.body.length>3){code.push(processBlock(proc.pre,proc,dtypes))}var body=processBlock(proc.body,proc,dtypes);var matched=countMatches(orders);if(matched<dimension){code.push(outerFill(matched,orders[0],proc,body))}else{code.push(innerFill(orders[0],proc,body))}if(proc.post.body.length>3){code.push(processBlock(proc.post,proc,dtypes))}if(proc.debug){console.log("Generated cwise routine for ",typesig,":\n\n",code.join("\n"))}var loopName=[proc.funcName||"unnamed","_cwise_loop_",orders[0].join("s"),"m",matched,typeSummary(dtypes)].join("");var f=new Function(["function ",loopName,"(",arglist.join(","),"){",code.join("\n"),"} return ",loopName].join(""));return f()}module.exports=generateCWiseOp},{uniq:58}],57:[function(require,module,exports){arguments[4][44][0].apply(exports,arguments)},{"./compile.js":56}],58:[function(require,module,exports){"use strict";function unique_pred(list,compare){var ptr=1,len=list.length,a=list[0],b=list[0];for(var i=1;i<len;++i){b=a;a=list[i];if(compare(a,b)){if(i===ptr){ptr++;continue}list[ptr++]=a}}list.length=ptr;return list}function unique_eq(list){var ptr=1,len=list.length,a=list[0],b=list[0];for(var i=1;i<len;++i,b=a){b=a;a=list[i];if(a!==b){if(i===ptr){ptr++;continue}list[ptr++]=a}}list.length=ptr;return list}function unique(list,compare,sorted){if(list.length===0){return[]}if(compare){if(!sorted){list.sort(compare)}return unique_pred(list,compare)}if(!sorted){list.sort()}return unique_eq(list)}module.exports=unique},{}],59:[function(require,module,exports){"use strict";var esprima=require("esprima");var uniq=require("uniq");var PREFIX_COUNTER=0;function CompiledArgument(name,lvalue,rvalue){this.name=name;this.lvalue=lvalue;this.rvalue=rvalue;this.count=0}function CompiledRoutine(body,args,thisVars,localVars){this.body=body;this.args=args;this.thisVars=thisVars;this.localVars=localVars}function isGlobal(identifier){if(identifier==="eval"){throw new Error("cwise-parser: eval() not allowed")}if(typeof window!=="undefined"){return identifier in window}else if(typeof GLOBAL!=="undefined"){return identifier in GLOBAL}else if(typeof self!=="undefined"){return identifier in self}else{return false}}function getArgNames(ast){var params=ast.body[0].expression.callee.params;var names=new Array(params.length);for(var i=0;i<params.length;++i){names[i]=params[i].name}return names}function preprocess(func){var src=["(",func,")()"].join("");var ast=esprima.parse(src,{range:true});var prefix="_inline_"+PREFIX_COUNTER++ +"_";var argNames=getArgNames(ast);var compiledArgs=new Array(argNames.length);for(var i=0;i<argNames.length;++i){compiledArgs[i]=new CompiledArgument([prefix,"arg",i,"_"].join(""),false,false)}var exploded=new Array(src.length);for(var i=0,n=src.length;i<n;++i){exploded[i]=src.charAt(i)}var localVars=[];var thisVars=[];var computedThis=false;function createLocal(id){var nstr=prefix+id.replace(/\_/g,"__");localVars.push(nstr);return nstr}function createThisVar(id){var nstr="this_"+id.replace(/\_/g,"__");thisVars.push(nstr);return nstr}function rewrite(node,nstr){var lo=node.range[0],hi=node.range[1];for(var i=lo+1;i<hi;++i){exploded[i]=""}exploded[lo]=nstr}function escapeString(str){return"'"+str.replace(/\_/g,"\\_").replace(/\'/g,"'")+"'"}function source(node){return exploded.slice(node.range[0],node.range[1]).join("")}var LVALUE=1;var RVALUE=2;function getUsage(node){if(node.parent.type==="AssignmentExpression"){if(node.parent.left===node){if(node.parent.operator==="="){return LVALUE}return LVALUE|RVALUE}}if(node.parent.type==="UpdateExpression"){return LVALUE|RVALUE}return RVALUE}(function visit(node,parent){node.parent=parent;if(node.type==="MemberExpression"){if(node.computed){visit(node.object,node);visit(node.property,node)}else if(node.object.type==="ThisExpression"){rewrite(node,createThisVar(node.property.name))}else{visit(node.object,node)}}else if(node.type==="ThisExpression"){throw new Error("cwise-parser: Computed this is not allowed")}else if(node.type==="Identifier"){var name=node.name;var argNo=argNames.indexOf(name);if(argNo>=0){var carg=compiledArgs[argNo];var usage=getUsage(node);if(usage&LVALUE){carg.lvalue=true}if(usage&RVALUE){carg.rvalue=true}++carg.count;rewrite(node,carg.name)}else if(isGlobal(name)){}else{rewrite(node,createLocal(name))}}else if(node.type==="Literal"){if(typeof node.value==="string"){rewrite(node,escapeString(node.value))}}else if(node.type==="WithStatement"){throw new Error("cwise-parser: with() statements not allowed")}else{var keys=Object.keys(node);for(var i=0,n=keys.length;i<n;++i){if(keys[i]==="parent"){continue}var value=node[keys[i]];if(value){if(value instanceof Array){for(var j=0;j<value.length;++j){if(value[j]&&typeof value[j].type==="string"){visit(value[j],node)}}}else if(typeof value.type==="string"){visit(value,node)}}}}})(ast.body[0].expression.callee.body,undefined);uniq(localVars);uniq(thisVars);var routine=new CompiledRoutine(source(ast.body[0].expression.callee.body),compiledArgs,thisVars,localVars);return routine}module.exports=preprocess},{esprima:60,uniq:61}],60:[function(require,module,exports){(function(root,factory){"use strict";if(typeof define==="function"&&define.amd){define(["exports"],factory)}else if(typeof exports!=="undefined"){factory(exports)}else{factory(root.esprima={})}})(this,function(exports){"use strict";var Token,TokenName,Syntax,PropertyKind,Messages,Regex,source,strict,index,lineNumber,lineStart,length,buffer,state,extra;Token={BooleanLiteral:1,EOF:2,Identifier:3,Keyword:4,NullLiteral:5,NumericLiteral:6,Punctuator:7,StringLiteral:8};TokenName={};TokenName[Token.BooleanLiteral]="Boolean";TokenName[Token.EOF]="<end>";TokenName[Token.Identifier]="Identifier";TokenName[Token.Keyword]="Keyword";TokenName[Token.NullLiteral]="Null";TokenName[Token.NumericLiteral]="Numeric";TokenName[Token.Punctuator]="Punctuator";TokenName[Token.StringLiteral]="String";Syntax={AssignmentExpression:"AssignmentExpression",ArrayExpression:"ArrayExpression",BlockStatement:"BlockStatement",BinaryExpression:"BinaryExpression",BreakStatement:"BreakStatement",CallExpression:"CallExpression",CatchClause:"CatchClause",ConditionalExpression:"ConditionalExpression",ContinueStatement:"ContinueStatement",DoWhileStatement:"DoWhileStatement",DebuggerStatement:"DebuggerStatement",EmptyStatement:"EmptyStatement",ExpressionStatement:"ExpressionStatement",ForStatement:"ForStatement",ForInStatement:"ForInStatement",FunctionDeclaration:"FunctionDeclaration",FunctionExpression:"FunctionExpression",Identifier:"Identifier",IfStatement:"IfStatement",Literal:"Literal",LabeledStatement:"LabeledStatement",LogicalExpression:"LogicalExpression",MemberExpression:"MemberExpression",NewExpression:"NewExpression",ObjectExpression:"ObjectExpression",Program:"Program",Property:"Property",ReturnStatement:"ReturnStatement",SequenceExpression:"SequenceExpression",SwitchStatement:"SwitchStatement",SwitchCase:"SwitchCase",ThisExpression:"ThisExpression",ThrowStatement:"ThrowStatement",TryStatement:"TryStatement",UnaryExpression:"UnaryExpression",UpdateExpression:"UpdateExpression",VariableDeclaration:"VariableDeclaration",VariableDeclarator:"VariableDeclarator",WhileStatement:"WhileStatement",WithStatement:"WithStatement"};PropertyKind={Data:1,Get:2,Set:4};Messages={UnexpectedToken:"Unexpected token %0",UnexpectedNumber:"Unexpected number",UnexpectedString:"Unexpected string",UnexpectedIdentifier:"Unexpected identifier",UnexpectedReserved:"Unexpected reserved word",UnexpectedEOS:"Unexpected end of input",NewlineAfterThrow:"Illegal newline after throw",InvalidRegExp:"Invalid regular expression",UnterminatedRegExp:"Invalid regular expression: missing /",InvalidLHSInAssignment:"Invalid left-hand side in assignment",InvalidLHSInForIn:"Invalid left-hand side in for-in",MultipleDefaultsInSwitch:"More than one default clause in switch statement",NoCatchOrFinally:"Missing catch or finally after try",UnknownLabel:"Undefined label '%0'",Redeclaration:"%0 '%1' has already been declared",IllegalContinue:"Illegal continue statement",IllegalBreak:"Illegal break statement",IllegalReturn:"Illegal return statement",StrictModeWith:"Strict mode code may not include a with statement",StrictCatchVariable:"Catch variable may not be eval or arguments in strict mode",StrictVarName:"Variable name may not be eval or arguments in strict mode",StrictParamName:"Parameter name eval or arguments is not allowed in strict mode",StrictParamDupe:"Strict mode function may not have duplicate parameter names",StrictFunctionName:"Function name may not be eval or arguments in strict mode",StrictOctalLiteral:"Octal literals are not allowed in strict mode.",StrictDelete:"Delete of an unqualified identifier in strict mode.",StrictDuplicateProperty:"Duplicate data property in object literal not allowed in strict mode",AccessorDataProperty:"Object literal may not have data and accessor property with the same name",AccessorGetSet:"Object literal may not have multiple get/set accessors with the same name",StrictLHSAssignment:"Assignment to eval or arguments is not allowed in strict mode",StrictLHSPostfix:"Postfix increment/decrement may not have eval or arguments operand in strict mode",StrictLHSPrefix:"Prefix increment/decrement may not have eval or arguments operand in strict mode",StrictReservedWord:"Use of future reserved word in strict mode"};Regex={NonAsciiIdentifierStart:new RegExp("[ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԧԱ-Ֆՙա-ևא-תװ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࢠࢢ-ࢬऄ-हऽॐक़-ॡॱ-ॷॹ-ॿঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-ళవ-హఽౘౙౠౡಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೞೠೡೱೲഅ-ഌഎ-ഐഒ-ഺഽൎൠൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄງຈຊຍດ-ທນ-ຟມ-ຣລວສຫອ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏼᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛰᜀ-ᜌᜎ-ᜑᜠ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡷᢀ-ᢨᢪᢰ-ᣵᤀ-ᤜᥐ-ᥭᥰ-ᥴᦀ-ᦫᧁ-ᧇᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭋᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᳩ-ᳬᳮ-ᳱᳵᳶᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕℙ-ℝℤΩℨK-ℭℯ-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞⸯ々-〇〡-〩〱-〵〸-〼ぁ-ゖゝ-ゟァ-ヺー-ヿㄅ-ㄭㄱ-ㆎㆠ-ㆺㇰ-ㇿ㐀-䶵一-鿌ꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚗꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-ꞎꞐ-ꞓꞠ-Ɦꟸ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꪀ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꯀ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ﬀ-ﬆﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼＡ-Ｚａ-ｚｦ-ﾾￂ-ￇￊ-ￏￒ-ￗￚ-ￜ]"),NonAsciiIdentifierPart:new RegExp("[ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮ̀-ʹͶͷͺ-ͽΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁ҃-҇Ҋ-ԧԱ-Ֆՙա-և֑-ׇֽֿׁׂׅׄא-תװ-ײؐ-ؚؠ-٩ٮ-ۓە-ۜ۟-۪ۨ-ۼۿܐ-݊ݍ-ޱ߀-ߵߺࠀ-࠭ࡀ-࡛ࢠࢢ-ࢬࣤ-ࣾऀ-ॣ०-९ॱ-ॷॹ-ॿঁ-ঃঅ-ঌএঐও-নপ-রলশ-হ়-ৄেৈো-ৎৗড়ঢ়য়-ৣ০-ৱਁ-ਃਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹ਼ਾ-ੂੇੈੋ-੍ੑਖ਼-ੜਫ਼੦-ੵઁ-ઃઅ-ઍએ-ઑઓ-નપ-રલળવ-હ઼-ૅે-ૉો-્ૐૠ-ૣ૦-૯ଁ-ଃଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହ଼-ୄେୈୋ-୍ୖୗଡ଼ଢ଼ୟ-ୣ୦-୯ୱஂஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹா-ூெ-ைொ-்ௐௗ௦-௯ఁ-ఃఅ-ఌఎ-ఐఒ-నప-ళవ-హఽ-ౄె-ైొ-్ౕౖౘౙౠ-ౣ౦-౯ಂಃಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹ಼-ೄೆ-ೈೊ-್ೕೖೞೠ-ೣ೦-೯ೱೲംഃഅ-ഌഎ-ഐഒ-ഺഽ-ൄെ-ൈൊ-ൎൗൠ-ൣ൦-൯ൺ-ൿංඃඅ-ඖක-නඳ-රලව-ෆ්ා-ුූෘ-ෟෲෳก-ฺเ-๎๐-๙ກຂຄງຈຊຍດ-ທນ-ຟມ-ຣລວສຫອ-ູົ-ຽເ-ໄໆ່-ໍ໐-໙ໜ-ໟༀ༘༙༠-༩༹༵༷༾-ཇཉ-ཬཱ-྄྆-ྗྙ-ྼ࿆က-၉ၐ-ႝႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚ፝-፟ᎀ-ᎏᎠ-Ᏼᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛰᜀ-ᜌᜎ-᜔ᜠ-᜴ᝀ-ᝓᝠ-ᝬᝮ-ᝰᝲᝳក-៓ៗៜ៝០-៩᠋-᠍᠐-᠙ᠠ-ᡷᢀ-ᢪᢰ-ᣵᤀ-ᤜᤠ-ᤫᤰ-᤻᥆-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉ᧐-᧙ᨀ-ᨛᨠ-ᩞ᩠-᩿᩼-᪉᪐-᪙ᪧᬀ-ᭋ᭐-᭙᭫-᭳ᮀ-᯳ᰀ-᰷᱀-᱉ᱍ-ᱽ᳐-᳔᳒-ᳶᴀ-ᷦ᷼-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼ‌‍‿⁀⁔ⁱⁿₐ-ₜ⃐-⃥⃜⃡-⃰ℂℇℊ-ℓℕℙ-ℝℤΩℨK-ℭℯ-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-Ⱞⰰ-ⱞⱠ-ⳤⳫ-ⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯ⵿-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞⷠ-ⷿⸯ々-〇〡-〯〱-〵〸-〼ぁ-ゖ゙゚ゝ-ゟァ-ヺー-ヿㄅ-ㄭㄱ-ㆎㆠ-ㆺㇰ-ㇿ㐀-䶵一-鿌ꀀ-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘫꙀ-꙯ꙴ-꙽ꙿ-ꚗꚟ-꛱ꜗ-ꜟꜢ-ꞈꞋ-ꞎꞐ-ꞓꞠ-Ɦꟸ-ꠧꡀ-ꡳꢀ-꣄꣐-꣙꣠-ꣷꣻ꤀-꤭ꤰ-꥓ꥠ-ꥼꦀ-꧀ꧏ-꧙ꨀ-ꨶꩀ-ꩍ꩐-꩙ꩠ-ꩶꩺꩻꪀ-ꫂꫛ-ꫝꫠ-ꫯꫲ-꫶ꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꯀ-ꯪ꯬꯭꯰-꯹가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ﬀ-ﬆﬓ-ﬗיִ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻ︀-️︠-︦︳︴﹍-﹏ﹰ-ﹴﹶ-ﻼ０-９Ａ-Ｚ＿ａ-ｚｦ-ﾾￂ-ￇￊ-ￏￒ-ￗￚ-ￜ]")};function assert(condition,message){if(!condition){throw new Error("ASSERT: "+message)}}function sliceSource(from,to){return source.slice(from,to)}if(typeof"esprima"[0]==="undefined"){sliceSource=function sliceArraySource(from,to){return source.slice(from,to).join("")}}function isDecimalDigit(ch){return"0123456789".indexOf(ch)>=0}function isHexDigit(ch){return"0123456789abcdefABCDEF".indexOf(ch)>=0}function isOctalDigit(ch){return"01234567".indexOf(ch)>=0}function isWhiteSpace(ch){return ch===" "||ch==="	"||ch===""||ch==="\f"||ch===" "||ch.charCodeAt(0)>=5760&&" ᠎             　﻿".indexOf(ch)>=0}function isLineTerminator(ch){return ch==="\n"||ch==="\r"||ch==="\u2028"||ch==="\u2029"}function isIdentifierStart(ch){return ch==="$"||ch==="_"||ch==="\\"||ch>="a"&&ch<="z"||ch>="A"&&ch<="Z"||ch.charCodeAt(0)>=128&&Regex.NonAsciiIdentifierStart.test(ch)}function isIdentifierPart(ch){return ch==="$"||ch==="_"||ch==="\\"||ch>="a"&&ch<="z"||ch>="A"&&ch<="Z"||ch>="0"&&ch<="9"||ch.charCodeAt(0)>=128&&Regex.NonAsciiIdentifierPart.test(ch)}function isFutureReservedWord(id){switch(id){case"class":case"enum":case"export":case"extends":case"import":case"super":return true}return false}function isStrictModeReservedWord(id){switch(id){case"implements":case"interface":case"package":case"private":case"protected":case"public":case"static":case"yield":case"let":return true}return false}function isRestrictedWord(id){return id==="eval"||id==="arguments"}function isKeyword(id){var keyword=false;switch(id.length){case 2:keyword=id==="if"||id==="in"||id==="do";break;case 3:keyword=id==="var"||id==="for"||id==="new"||id==="try";break;case 4:keyword=id==="this"||id==="else"||id==="case"||id==="void"||id==="with";break;case 5:keyword=id==="while"||id==="break"||id==="catch"||id==="throw";break;case 6:keyword=id==="return"||id==="typeof"||id==="delete"||id==="switch";break;case 7:keyword=id==="default"||id==="finally";break;case 8:keyword=id==="function"||id==="continue"||id==="debugger";break;case 10:keyword=id==="instanceof";break}if(keyword){return true}switch(id){case"const":return true;case"yield":case"let":return true}if(strict&&isStrictModeReservedWord(id)){return true}return isFutureReservedWord(id)}function skipComment(){var ch,blockComment,lineComment;blockComment=false;lineComment=false;while(index<length){ch=source[index];if(lineComment){ch=source[index++];if(isLineTerminator(ch)){lineComment=false;if(ch==="\r"&&source[index]==="\n"){++index}++lineNumber;lineStart=index}}else if(blockComment){if(isLineTerminator(ch)){if(ch==="\r"&&source[index+1]==="\n"){++index}++lineNumber;++index;lineStart=index;if(index>=length){throwError({},Messages.UnexpectedToken,"ILLEGAL")}}else{ch=source[index++];if(index>=length){throwError({},Messages.UnexpectedToken,"ILLEGAL")}if(ch==="*"){ch=source[index];if(ch==="/"){++index;blockComment=false}}}}else if(ch==="/"){ch=source[index+1];if(ch==="/"){index+=2;lineComment=true}else if(ch==="*"){index+=2;blockComment=true;if(index>=length){throwError({},Messages.UnexpectedToken,"ILLEGAL")}}else{break}}else if(isWhiteSpace(ch)){++index}else if(isLineTerminator(ch)){++index;if(ch==="\r"&&source[index]==="\n"){++index}++lineNumber;lineStart=index}else{break}}}function scanHexEscape(prefix){var i,len,ch,code=0;len=prefix==="u"?4:2;for(i=0;i<len;++i){if(index<length&&isHexDigit(source[index])){ch=source[index++];code=code*16+"0123456789abcdef".indexOf(ch.toLowerCase())}else{return""}}return String.fromCharCode(code)}function scanIdentifier(){var ch,start,id,restore;ch=source[index];if(!isIdentifierStart(ch)){return}start=index;if(ch==="\\"){++index;if(source[index]!=="u"){return}++index;restore=index;ch=scanHexEscape("u");if(ch){if(ch==="\\"||!isIdentifierStart(ch)){return}id=ch}else{index=restore;id="u"}}else{id=source[index++]}while(index<length){ch=source[index];if(!isIdentifierPart(ch)){break}if(ch==="\\"){++index;if(source[index]!=="u"){return}++index;restore=index;ch=scanHexEscape("u");if(ch){if(ch==="\\"||!isIdentifierPart(ch)){return}id+=ch}else{index=restore;id+="u"}}else{id+=source[index++]}}if(id.length===1){return{type:Token.Identifier,value:id,lineNumber:lineNumber,lineStart:lineStart,range:[start,index]}}if(isKeyword(id)){return{type:Token.Keyword,value:id,lineNumber:lineNumber,lineStart:lineStart,range:[start,index]}}if(id==="null"){return{type:Token.NullLiteral,value:id,lineNumber:lineNumber,lineStart:lineStart,range:[start,index]}}if(id==="true"||id==="false"){return{type:Token.BooleanLiteral,value:id,lineNumber:lineNumber,lineStart:lineStart,range:[start,index]}}return{type:Token.Identifier,value:id,lineNumber:lineNumber,lineStart:lineStart,range:[start,index]}}function scanPunctuator(){var start=index,ch1=source[index],ch2,ch3,ch4;if(ch1===";"||ch1==="{"||ch1==="}"){++index;return{type:Token.Punctuator,value:ch1,lineNumber:lineNumber,lineStart:lineStart,range:[start,index]}}if(ch1===","||ch1==="("||ch1===")"){++index;return{type:Token.Punctuator,value:ch1,lineNumber:lineNumber,lineStart:lineStart,range:[start,index]}}ch2=source[index+1];if(ch1==="."&&!isDecimalDigit(ch2)){return{type:Token.Punctuator,value:source[index++],lineNumber:lineNumber,lineStart:lineStart,range:[start,index]}}ch3=source[index+2];ch4=source[index+3];if(ch1===">"&&ch2===">"&&ch3===">"){if(ch4==="="){index+=4;return{type:Token.Punctuator,value:">>>=",lineNumber:lineNumber,lineStart:lineStart,range:[start,index]}}}if(ch1==="="&&ch2==="="&&ch3==="="){index+=3;return{type:Token.Punctuator,value:"===",lineNumber:lineNumber,lineStart:lineStart,range:[start,index]}}if(ch1==="!"&&ch2==="="&&ch3==="="){index+=3;return{type:Token.Punctuator,value:"!==",lineNumber:lineNumber,lineStart:lineStart,range:[start,index]}}if(ch1===">"&&ch2===">"&&ch3===">"){index+=3;return{type:Token.Punctuator,value:">>>",lineNumber:lineNumber,lineStart:lineStart,range:[start,index]}}if(ch1==="<"&&ch2==="<"&&ch3==="="){index+=3;return{type:Token.Punctuator,value:"<<=",lineNumber:lineNumber,lineStart:lineStart,range:[start,index]}}if(ch1===">"&&ch2===">"&&ch3==="="){index+=3;return{type:Token.Punctuator,value:">>=",lineNumber:lineNumber,lineStart:lineStart,range:[start,index]}}if(ch2==="="){if("<>=!+-*%&|^/".indexOf(ch1)>=0){index+=2;return{type:Token.Punctuator,value:ch1+ch2,lineNumber:lineNumber,lineStart:lineStart,range:[start,index]}}}if(ch1===ch2&&"+-<>&|".indexOf(ch1)>=0){if("+-<>&|".indexOf(ch2)>=0){index+=2;return{type:Token.Punctuator,value:ch1+ch2,lineNumber:lineNumber,lineStart:lineStart,range:[start,index]}}}if("[]<>+-*%&|^!~?:=/".indexOf(ch1)>=0){return{type:Token.Punctuator,value:source[index++],lineNumber:lineNumber,lineStart:lineStart,range:[start,index]}}}function scanNumericLiteral(){var number,start,ch;ch=source[index];assert(isDecimalDigit(ch)||ch===".","Numeric literal must start with a decimal digit or a decimal point");start=index;number="";if(ch!=="."){number=source[index++];ch=source[index];if(number==="0"){if(ch==="x"||ch==="X"){number+=source[index++];while(index<length){ch=source[index];if(!isHexDigit(ch)){break}number+=source[index++]}if(number.length<=2){throwError({},Messages.UnexpectedToken,"ILLEGAL")}if(index<length){ch=source[index];if(isIdentifierStart(ch)){throwError({},Messages.UnexpectedToken,"ILLEGAL")}}return{type:Token.NumericLiteral,value:parseInt(number,16),lineNumber:lineNumber,lineStart:lineStart,range:[start,index]}}else if(isOctalDigit(ch)){number+=source[index++];while(index<length){ch=source[index];if(!isOctalDigit(ch)){break}number+=source[index++]}if(index<length){ch=source[index];if(isIdentifierStart(ch)||isDecimalDigit(ch)){throwError({},Messages.UnexpectedToken,"ILLEGAL")}}return{type:Token.NumericLiteral,value:parseInt(number,8),octal:true,lineNumber:lineNumber,lineStart:lineStart,range:[start,index]}}if(isDecimalDigit(ch)){throwError({},Messages.UnexpectedToken,"ILLEGAL")}}while(index<length){ch=source[index];if(!isDecimalDigit(ch)){break}number+=source[index++]}}if(ch==="."){number+=source[index++];while(index<length){ch=source[index];if(!isDecimalDigit(ch)){break}number+=source[index++]}}if(ch==="e"||ch==="E"){number+=source[index++];ch=source[index];if(ch==="+"||ch==="-"){number+=source[index++]}ch=source[index];if(isDecimalDigit(ch)){number+=source[index++];while(index<length){ch=source[index];if(!isDecimalDigit(ch)){break}number+=source[index++]}}else{ch="character "+ch;if(index>=length){ch="<end>"}throwError({},Messages.UnexpectedToken,"ILLEGAL")}}if(index<length){ch=source[index];if(isIdentifierStart(ch)){throwError({},Messages.UnexpectedToken,"ILLEGAL")}}return{type:Token.NumericLiteral,value:parseFloat(number),lineNumber:lineNumber,lineStart:lineStart,range:[start,index]}}function scanStringLiteral(){var str="",quote,start,ch,code,unescaped,restore,octal=false;quote=source[index];assert(quote==="'"||quote==='"',"String literal must starts with a quote");start=index;++index;while(index<length){ch=source[index++];if(ch===quote){quote="";break}else if(ch==="\\"){ch=source[index++];if(!isLineTerminator(ch)){switch(ch){case"n":str+="\n";break;case"r":str+="\r";break;case"t":str+="	";break;case"u":case"x":restore=index;unescaped=scanHexEscape(ch);if(unescaped){str+=unescaped}else{index=restore;str+=ch}break;case"b":str+="\b";break;case"f":str+="\f";break;case"v":str+="";break;default:if(isOctalDigit(ch)){code="01234567".indexOf(ch);if(code!==0){octal=true}if(index<length&&isOctalDigit(source[index])){octal=true;code=code*8+"01234567".indexOf(source[index++]);if("0123".indexOf(ch)>=0&&index<length&&isOctalDigit(source[index])){code=code*8+"01234567".indexOf(source[index++])}}str+=String.fromCharCode(code)}else{str+=ch}break}}else{++lineNumber;if(ch==="\r"&&source[index]==="\n"){++index}}}else if(isLineTerminator(ch)){break}else{str+=ch}}if(quote!==""){throwError({},Messages.UnexpectedToken,"ILLEGAL")}return{type:Token.StringLiteral,value:str,octal:octal,lineNumber:lineNumber,lineStart:lineStart,range:[start,index]}}function scanRegExp(){var str,ch,start,pattern,flags,value,classMarker=false,restore,terminated=false;buffer=null;skipComment();start=index;ch=source[index];assert(ch==="/","Regular expression literal must start with a slash");str=source[index++];while(index<length){ch=source[index++];str+=ch;if(ch==="\\"){ch=source[index++];if(isLineTerminator(ch)){throwError({},Messages.UnterminatedRegExp)}str+=ch}else if(classMarker){if(ch==="]"){classMarker=false}}else{if(ch==="/"){terminated=true;break}else if(ch==="["){classMarker=true}else if(isLineTerminator(ch)){throwError({},Messages.UnterminatedRegExp)}}}if(!terminated){throwError({},Messages.UnterminatedRegExp)}pattern=str.substr(1,str.length-2);flags="";while(index<length){ch=source[index];if(!isIdentifierPart(ch)){break}++index;if(ch==="\\"&&index<length){ch=source[index];if(ch==="u"){++index;restore=index;ch=scanHexEscape("u");if(ch){flags+=ch;str+="\\u";for(;restore<index;++restore){str+=source[restore]}}else{index=restore;flags+="u";str+="\\u"}}else{str+="\\"}}else{flags+=ch;str+=ch}}try{value=new RegExp(pattern,flags)}catch(e){throwError({},Messages.InvalidRegExp)}return{literal:str,value:value,range:[start,index]}}function isIdentifierName(token){return token.type===Token.Identifier||token.type===Token.Keyword||token.type===Token.BooleanLiteral||token.type===Token.NullLiteral}function advance(){var ch,token;skipComment();if(index>=length){return{type:Token.EOF,lineNumber:lineNumber,lineStart:lineStart,range:[index,index]}}token=scanPunctuator();if(typeof token!=="undefined"){return token}ch=source[index];if(ch==="'"||ch==='"'){return scanStringLiteral()}if(ch==="."||isDecimalDigit(ch)){return scanNumericLiteral()}token=scanIdentifier();if(typeof token!=="undefined"){return token}throwError({},Messages.UnexpectedToken,"ILLEGAL")}function lex(){var token;if(buffer){index=buffer.range[1];lineNumber=buffer.lineNumber;lineStart=buffer.lineStart;token=buffer;buffer=null;return token}buffer=null;return advance()}function lookahead(){var pos,line,start;if(buffer!==null){return buffer}pos=index;line=lineNumber;start=lineStart;buffer=advance();index=pos;lineNumber=line;lineStart=start;return buffer}function peekLineTerminator(){var pos,line,start,found;pos=index;line=lineNumber;start=lineStart;skipComment();found=lineNumber!==line;index=pos;lineNumber=line;lineStart=start;return found}function throwError(token,messageFormat){var error,args=Array.prototype.slice.call(arguments,2),msg=messageFormat.replace(/%(\d)/g,function(whole,index){return args[index]||""});if(typeof token.lineNumber==="number"){error=new Error("Line "+token.lineNumber+": "+msg);error.index=token.range[0];error.lineNumber=token.lineNumber;error.column=token.range[0]-lineStart+1}else{error=new Error("Line "+lineNumber+": "+msg);error.index=index;error.lineNumber=lineNumber;error.column=index-lineStart+1}throw error}function throwErrorTolerant(){try{throwError.apply(null,arguments)}catch(e){if(extra.errors){extra.errors.push(e)}else{throw e}}}function throwUnexpected(token){if(token.type===Token.EOF){throwError(token,Messages.UnexpectedEOS)}if(token.type===Token.NumericLiteral){throwError(token,Messages.UnexpectedNumber)}if(token.type===Token.StringLiteral){throwError(token,Messages.UnexpectedString)}if(token.type===Token.Identifier){throwError(token,Messages.UnexpectedIdentifier)}if(token.type===Token.Keyword){if(isFutureReservedWord(token.value)){throwError(token,Messages.UnexpectedReserved)}else if(strict&&isStrictModeReservedWord(token.value)){throwErrorTolerant(token,Messages.StrictReservedWord);return}throwError(token,Messages.UnexpectedToken,token.value)}throwError(token,Messages.UnexpectedToken,token.value)}function expect(value){var token=lex();if(token.type!==Token.Punctuator||token.value!==value){throwUnexpected(token)}}function expectKeyword(keyword){var token=lex();if(token.type!==Token.Keyword||token.value!==keyword){throwUnexpected(token)}}function match(value){var token=lookahead();return token.type===Token.Punctuator&&token.value===value}function matchKeyword(keyword){var token=lookahead();return token.type===Token.Keyword&&token.value===keyword}function matchAssign(){var token=lookahead(),op=token.value;if(token.type!==Token.Punctuator){return false}return op==="="||op==="*="||op==="/="||op==="%="||op==="+="||op==="-="||op==="<<="||op===">>="||op===">>>="||op==="&="||op==="^="||op==="|="}function consumeSemicolon(){var token,line;if(source[index]===";"){lex();return}line=lineNumber;skipComment();if(lineNumber!==line){return}if(match(";")){lex();return}token=lookahead();if(token.type!==Token.EOF&&!match("}")){throwUnexpected(token)}}function isLeftHandSide(expr){return expr.type===Syntax.Identifier||expr.type===Syntax.MemberExpression}function parseArrayInitialiser(){var elements=[];expect("[");while(!match("]")){if(match(",")){lex();elements.push(null)}else{elements.push(parseAssignmentExpression());if(!match("]")){expect(",")}}}expect("]");return{type:Syntax.ArrayExpression,elements:elements}}function parsePropertyFunction(param,first){var previousStrict,body;previousStrict=strict;body=parseFunctionSourceElements();if(first&&strict&&isRestrictedWord(param[0].name)){throwErrorTolerant(first,Messages.StrictParamName)}strict=previousStrict;return{type:Syntax.FunctionExpression,id:null,params:param,defaults:[],body:body,rest:null,generator:false,expression:false}}function parseObjectPropertyKey(){var token=lex();if(token.type===Token.StringLiteral||token.type===Token.NumericLiteral){if(strict&&token.octal){throwErrorTolerant(token,Messages.StrictOctalLiteral)}return createLiteral(token)}return{type:Syntax.Identifier,name:token.value}}function parseObjectProperty(){var token,key,id,param;token=lookahead();if(token.type===Token.Identifier){id=parseObjectPropertyKey();if(token.value==="get"&&!match(":")){key=parseObjectPropertyKey();expect("(");expect(")");return{type:Syntax.Property,key:key,value:parsePropertyFunction([]),kind:"get"}}else if(token.value==="set"&&!match(":")){key=parseObjectPropertyKey();expect("(");token=lookahead();if(token.type!==Token.Identifier){expect(")");throwErrorTolerant(token,Messages.UnexpectedToken,token.value);return{type:Syntax.Property,key:key,value:parsePropertyFunction([]),kind:"set"}}else{param=[parseVariableIdentifier()];expect(")");return{type:Syntax.Property,key:key,value:parsePropertyFunction(param,token),kind:"set"}}}else{expect(":");return{type:Syntax.Property,key:id,value:parseAssignmentExpression(),kind:"init"}}}else if(token.type===Token.EOF||token.type===Token.Punctuator){throwUnexpected(token)}else{key=parseObjectPropertyKey();expect(":");return{type:Syntax.Property,key:key,value:parseAssignmentExpression(),kind:"init"}}}function parseObjectInitialiser(){var properties=[],property,name,kind,map={},toString=String;expect("{");while(!match("}")){property=parseObjectProperty();if(property.key.type===Syntax.Identifier){name=property.key.name}else{name=toString(property.key.value)}kind=property.kind==="init"?PropertyKind.Data:property.kind==="get"?PropertyKind.Get:PropertyKind.Set;if(Object.prototype.hasOwnProperty.call(map,name)){if(map[name]===PropertyKind.Data){if(strict&&kind===PropertyKind.Data){throwErrorTolerant({},Messages.StrictDuplicateProperty)}else if(kind!==PropertyKind.Data){throwErrorTolerant({},Messages.AccessorDataProperty)}}else{if(kind===PropertyKind.Data){throwErrorTolerant({},Messages.AccessorDataProperty)}else if(map[name]&kind){throwErrorTolerant({},Messages.AccessorGetSet)}}map[name]|=kind}else{map[name]=kind}properties.push(property);if(!match("}")){expect(",")}}expect("}");return{type:Syntax.ObjectExpression,properties:properties}}function parseGroupExpression(){var expr;expect("(");expr=parseExpression();expect(")");return expr}function parsePrimaryExpression(){var token=lookahead(),type=token.type;if(type===Token.Identifier){return{type:Syntax.Identifier,name:lex().value}}if(type===Token.StringLiteral||type===Token.NumericLiteral){if(strict&&token.octal){throwErrorTolerant(token,Messages.StrictOctalLiteral)
}return createLiteral(lex())}if(type===Token.Keyword){if(matchKeyword("this")){lex();return{type:Syntax.ThisExpression}}if(matchKeyword("function")){return parseFunctionExpression()}}if(type===Token.BooleanLiteral){lex();token.value=token.value==="true";return createLiteral(token)}if(type===Token.NullLiteral){lex();token.value=null;return createLiteral(token)}if(match("[")){return parseArrayInitialiser()}if(match("{")){return parseObjectInitialiser()}if(match("(")){return parseGroupExpression()}if(match("/")||match("/=")){return createLiteral(scanRegExp())}return throwUnexpected(lex())}function parseArguments(){var args=[];expect("(");if(!match(")")){while(index<length){args.push(parseAssignmentExpression());if(match(")")){break}expect(",")}}expect(")");return args}function parseNonComputedProperty(){var token=lex();if(!isIdentifierName(token)){throwUnexpected(token)}return{type:Syntax.Identifier,name:token.value}}function parseNonComputedMember(){expect(".");return parseNonComputedProperty()}function parseComputedMember(){var expr;expect("[");expr=parseExpression();expect("]");return expr}function parseNewExpression(){var expr;expectKeyword("new");expr={type:Syntax.NewExpression,callee:parseLeftHandSideExpression(),arguments:[]};if(match("(")){expr["arguments"]=parseArguments()}return expr}function parseLeftHandSideExpressionAllowCall(){var expr;expr=matchKeyword("new")?parseNewExpression():parsePrimaryExpression();while(match(".")||match("[")||match("(")){if(match("(")){expr={type:Syntax.CallExpression,callee:expr,arguments:parseArguments()}}else if(match("[")){expr={type:Syntax.MemberExpression,computed:true,object:expr,property:parseComputedMember()}}else{expr={type:Syntax.MemberExpression,computed:false,object:expr,property:parseNonComputedMember()}}}return expr}function parseLeftHandSideExpression(){var expr;expr=matchKeyword("new")?parseNewExpression():parsePrimaryExpression();while(match(".")||match("[")){if(match("[")){expr={type:Syntax.MemberExpression,computed:true,object:expr,property:parseComputedMember()}}else{expr={type:Syntax.MemberExpression,computed:false,object:expr,property:parseNonComputedMember()}}}return expr}function parsePostfixExpression(){var expr=parseLeftHandSideExpressionAllowCall(),token;token=lookahead();if(token.type!==Token.Punctuator){return expr}if((match("++")||match("--"))&&!peekLineTerminator()){if(strict&&expr.type===Syntax.Identifier&&isRestrictedWord(expr.name)){throwErrorTolerant({},Messages.StrictLHSPostfix)}if(!isLeftHandSide(expr)){throwErrorTolerant({},Messages.InvalidLHSInAssignment)}expr={type:Syntax.UpdateExpression,operator:lex().value,argument:expr,prefix:false}}return expr}function parseUnaryExpression(){var token,expr;token=lookahead();if(token.type!==Token.Punctuator&&token.type!==Token.Keyword){return parsePostfixExpression()}if(match("++")||match("--")){token=lex();expr=parseUnaryExpression();if(strict&&expr.type===Syntax.Identifier&&isRestrictedWord(expr.name)){throwErrorTolerant({},Messages.StrictLHSPrefix)}if(!isLeftHandSide(expr)){throwErrorTolerant({},Messages.InvalidLHSInAssignment)}expr={type:Syntax.UpdateExpression,operator:token.value,argument:expr,prefix:true};return expr}if(match("+")||match("-")||match("~")||match("!")){expr={type:Syntax.UnaryExpression,operator:lex().value,argument:parseUnaryExpression(),prefix:true};return expr}if(matchKeyword("delete")||matchKeyword("void")||matchKeyword("typeof")){expr={type:Syntax.UnaryExpression,operator:lex().value,argument:parseUnaryExpression(),prefix:true};if(strict&&expr.operator==="delete"&&expr.argument.type===Syntax.Identifier){throwErrorTolerant({},Messages.StrictDelete)}return expr}return parsePostfixExpression()}function parseMultiplicativeExpression(){var expr=parseUnaryExpression();while(match("*")||match("/")||match("%")){expr={type:Syntax.BinaryExpression,operator:lex().value,left:expr,right:parseUnaryExpression()}}return expr}function parseAdditiveExpression(){var expr=parseMultiplicativeExpression();while(match("+")||match("-")){expr={type:Syntax.BinaryExpression,operator:lex().value,left:expr,right:parseMultiplicativeExpression()}}return expr}function parseShiftExpression(){var expr=parseAdditiveExpression();while(match("<<")||match(">>")||match(">>>")){expr={type:Syntax.BinaryExpression,operator:lex().value,left:expr,right:parseAdditiveExpression()}}return expr}function parseRelationalExpression(){var expr,previousAllowIn;previousAllowIn=state.allowIn;state.allowIn=true;expr=parseShiftExpression();while(match("<")||match(">")||match("<=")||match(">=")||previousAllowIn&&matchKeyword("in")||matchKeyword("instanceof")){expr={type:Syntax.BinaryExpression,operator:lex().value,left:expr,right:parseShiftExpression()}}state.allowIn=previousAllowIn;return expr}function parseEqualityExpression(){var expr=parseRelationalExpression();while(match("==")||match("!=")||match("===")||match("!==")){expr={type:Syntax.BinaryExpression,operator:lex().value,left:expr,right:parseRelationalExpression()}}return expr}function parseBitwiseANDExpression(){var expr=parseEqualityExpression();while(match("&")){lex();expr={type:Syntax.BinaryExpression,operator:"&",left:expr,right:parseEqualityExpression()}}return expr}function parseBitwiseXORExpression(){var expr=parseBitwiseANDExpression();while(match("^")){lex();expr={type:Syntax.BinaryExpression,operator:"^",left:expr,right:parseBitwiseANDExpression()}}return expr}function parseBitwiseORExpression(){var expr=parseBitwiseXORExpression();while(match("|")){lex();expr={type:Syntax.BinaryExpression,operator:"|",left:expr,right:parseBitwiseXORExpression()}}return expr}function parseLogicalANDExpression(){var expr=parseBitwiseORExpression();while(match("&&")){lex();expr={type:Syntax.LogicalExpression,operator:"&&",left:expr,right:parseBitwiseORExpression()}}return expr}function parseLogicalORExpression(){var expr=parseLogicalANDExpression();while(match("||")){lex();expr={type:Syntax.LogicalExpression,operator:"||",left:expr,right:parseLogicalANDExpression()}}return expr}function parseConditionalExpression(){var expr,previousAllowIn,consequent;expr=parseLogicalORExpression();if(match("?")){lex();previousAllowIn=state.allowIn;state.allowIn=true;consequent=parseAssignmentExpression();state.allowIn=previousAllowIn;expect(":");expr={type:Syntax.ConditionalExpression,test:expr,consequent:consequent,alternate:parseAssignmentExpression()}}return expr}function parseAssignmentExpression(){var token,expr;token=lookahead();expr=parseConditionalExpression();if(matchAssign()){if(!isLeftHandSide(expr)){throwErrorTolerant({},Messages.InvalidLHSInAssignment)}if(strict&&expr.type===Syntax.Identifier&&isRestrictedWord(expr.name)){throwErrorTolerant(token,Messages.StrictLHSAssignment)}expr={type:Syntax.AssignmentExpression,operator:lex().value,left:expr,right:parseAssignmentExpression()}}return expr}function parseExpression(){var expr=parseAssignmentExpression();if(match(",")){expr={type:Syntax.SequenceExpression,expressions:[expr]};while(index<length){if(!match(",")){break}lex();expr.expressions.push(parseAssignmentExpression())}}return expr}function parseStatementList(){var list=[],statement;while(index<length){if(match("}")){break}statement=parseSourceElement();if(typeof statement==="undefined"){break}list.push(statement)}return list}function parseBlock(){var block;expect("{");block=parseStatementList();expect("}");return{type:Syntax.BlockStatement,body:block}}function parseVariableIdentifier(){var token=lex();if(token.type!==Token.Identifier){throwUnexpected(token)}return{type:Syntax.Identifier,name:token.value}}function parseVariableDeclaration(kind){var id=parseVariableIdentifier(),init=null;if(strict&&isRestrictedWord(id.name)){throwErrorTolerant({},Messages.StrictVarName)}if(kind==="const"){expect("=");init=parseAssignmentExpression()}else if(match("=")){lex();init=parseAssignmentExpression()}return{type:Syntax.VariableDeclarator,id:id,init:init}}function parseVariableDeclarationList(kind){var list=[];do{list.push(parseVariableDeclaration(kind));if(!match(",")){break}lex()}while(index<length);return list}function parseVariableStatement(){var declarations;expectKeyword("var");declarations=parseVariableDeclarationList();consumeSemicolon();return{type:Syntax.VariableDeclaration,declarations:declarations,kind:"var"}}function parseConstLetDeclaration(kind){var declarations;expectKeyword(kind);declarations=parseVariableDeclarationList(kind);consumeSemicolon();return{type:Syntax.VariableDeclaration,declarations:declarations,kind:kind}}function parseEmptyStatement(){expect(";");return{type:Syntax.EmptyStatement}}function parseExpressionStatement(){var expr=parseExpression();consumeSemicolon();return{type:Syntax.ExpressionStatement,expression:expr}}function parseIfStatement(){var test,consequent,alternate;expectKeyword("if");expect("(");test=parseExpression();expect(")");consequent=parseStatement();if(matchKeyword("else")){lex();alternate=parseStatement()}else{alternate=null}return{type:Syntax.IfStatement,test:test,consequent:consequent,alternate:alternate}}function parseDoWhileStatement(){var body,test,oldInIteration;expectKeyword("do");oldInIteration=state.inIteration;state.inIteration=true;body=parseStatement();state.inIteration=oldInIteration;expectKeyword("while");expect("(");test=parseExpression();expect(")");if(match(";")){lex()}return{type:Syntax.DoWhileStatement,body:body,test:test}}function parseWhileStatement(){var test,body,oldInIteration;expectKeyword("while");expect("(");test=parseExpression();expect(")");oldInIteration=state.inIteration;state.inIteration=true;body=parseStatement();state.inIteration=oldInIteration;return{type:Syntax.WhileStatement,test:test,body:body}}function parseForVariableDeclaration(){var token=lex();return{type:Syntax.VariableDeclaration,declarations:parseVariableDeclarationList(),kind:token.value}}function parseForStatement(){var init,test,update,left,right,body,oldInIteration;init=test=update=null;expectKeyword("for");expect("(");if(match(";")){lex()}else{if(matchKeyword("var")||matchKeyword("let")){state.allowIn=false;init=parseForVariableDeclaration();state.allowIn=true;if(init.declarations.length===1&&matchKeyword("in")){lex();left=init;right=parseExpression();init=null}}else{state.allowIn=false;init=parseExpression();state.allowIn=true;if(matchKeyword("in")){if(!isLeftHandSide(init)){throwErrorTolerant({},Messages.InvalidLHSInForIn)}lex();left=init;right=parseExpression();init=null}}if(typeof left==="undefined"){expect(";")}}if(typeof left==="undefined"){if(!match(";")){test=parseExpression()}expect(";");if(!match(")")){update=parseExpression()}}expect(")");oldInIteration=state.inIteration;state.inIteration=true;body=parseStatement();state.inIteration=oldInIteration;if(typeof left==="undefined"){return{type:Syntax.ForStatement,init:init,test:test,update:update,body:body}}return{type:Syntax.ForInStatement,left:left,right:right,body:body,each:false}}function parseContinueStatement(){var token,label=null;expectKeyword("continue");if(source[index]===";"){lex();if(!state.inIteration){throwError({},Messages.IllegalContinue)}return{type:Syntax.ContinueStatement,label:null}}if(peekLineTerminator()){if(!state.inIteration){throwError({},Messages.IllegalContinue)}return{type:Syntax.ContinueStatement,label:null}}token=lookahead();if(token.type===Token.Identifier){label=parseVariableIdentifier();if(!Object.prototype.hasOwnProperty.call(state.labelSet,label.name)){throwError({},Messages.UnknownLabel,label.name)}}consumeSemicolon();if(label===null&&!state.inIteration){throwError({},Messages.IllegalContinue)}return{type:Syntax.ContinueStatement,label:label}}function parseBreakStatement(){var token,label=null;expectKeyword("break");if(source[index]===";"){lex();if(!(state.inIteration||state.inSwitch)){throwError({},Messages.IllegalBreak)}return{type:Syntax.BreakStatement,label:null}}if(peekLineTerminator()){if(!(state.inIteration||state.inSwitch)){throwError({},Messages.IllegalBreak)}return{type:Syntax.BreakStatement,label:null}}token=lookahead();if(token.type===Token.Identifier){label=parseVariableIdentifier();if(!Object.prototype.hasOwnProperty.call(state.labelSet,label.name)){throwError({},Messages.UnknownLabel,label.name)}}consumeSemicolon();if(label===null&&!(state.inIteration||state.inSwitch)){throwError({},Messages.IllegalBreak)}return{type:Syntax.BreakStatement,label:label}}function parseReturnStatement(){var token,argument=null;expectKeyword("return");if(!state.inFunctionBody){throwErrorTolerant({},Messages.IllegalReturn)}if(source[index]===" "){if(isIdentifierStart(source[index+1])){argument=parseExpression();consumeSemicolon();return{type:Syntax.ReturnStatement,argument:argument}}}if(peekLineTerminator()){return{type:Syntax.ReturnStatement,argument:null}}if(!match(";")){token=lookahead();if(!match("}")&&token.type!==Token.EOF){argument=parseExpression()}}consumeSemicolon();return{type:Syntax.ReturnStatement,argument:argument}}function parseWithStatement(){var object,body;if(strict){throwErrorTolerant({},Messages.StrictModeWith)}expectKeyword("with");expect("(");object=parseExpression();expect(")");body=parseStatement();return{type:Syntax.WithStatement,object:object,body:body}}function parseSwitchCase(){var test,consequent=[],statement;if(matchKeyword("default")){lex();test=null}else{expectKeyword("case");test=parseExpression()}expect(":");while(index<length){if(match("}")||matchKeyword("default")||matchKeyword("case")){break}statement=parseStatement();if(typeof statement==="undefined"){break}consequent.push(statement)}return{type:Syntax.SwitchCase,test:test,consequent:consequent}}function parseSwitchStatement(){var discriminant,cases,clause,oldInSwitch,defaultFound;expectKeyword("switch");expect("(");discriminant=parseExpression();expect(")");expect("{");cases=[];if(match("}")){lex();return{type:Syntax.SwitchStatement,discriminant:discriminant,cases:cases}}oldInSwitch=state.inSwitch;state.inSwitch=true;defaultFound=false;while(index<length){if(match("}")){break}clause=parseSwitchCase();if(clause.test===null){if(defaultFound){throwError({},Messages.MultipleDefaultsInSwitch)}defaultFound=true}cases.push(clause)}state.inSwitch=oldInSwitch;expect("}");return{type:Syntax.SwitchStatement,discriminant:discriminant,cases:cases}}function parseThrowStatement(){var argument;expectKeyword("throw");if(peekLineTerminator()){throwError({},Messages.NewlineAfterThrow)}argument=parseExpression();consumeSemicolon();return{type:Syntax.ThrowStatement,argument:argument}}function parseCatchClause(){var param;expectKeyword("catch");expect("(");if(match(")")){throwUnexpected(lookahead())}param=parseVariableIdentifier();if(strict&&isRestrictedWord(param.name)){throwErrorTolerant({},Messages.StrictCatchVariable)}expect(")");return{type:Syntax.CatchClause,param:param,body:parseBlock()}}function parseTryStatement(){var block,handlers=[],finalizer=null;expectKeyword("try");block=parseBlock();if(matchKeyword("catch")){handlers.push(parseCatchClause())}if(matchKeyword("finally")){lex();finalizer=parseBlock()}if(handlers.length===0&&!finalizer){throwError({},Messages.NoCatchOrFinally)}return{type:Syntax.TryStatement,block:block,guardedHandlers:[],handlers:handlers,finalizer:finalizer}}function parseDebuggerStatement(){expectKeyword("debugger");consumeSemicolon();return{type:Syntax.DebuggerStatement}}function parseStatement(){var token=lookahead(),expr,labeledBody;if(token.type===Token.EOF){throwUnexpected(token)}if(token.type===Token.Punctuator){switch(token.value){case";":return parseEmptyStatement();case"{":return parseBlock();case"(":return parseExpressionStatement();default:break}}if(token.type===Token.Keyword){switch(token.value){case"break":return parseBreakStatement();case"continue":return parseContinueStatement();case"debugger":return parseDebuggerStatement();case"do":return parseDoWhileStatement();case"for":return parseForStatement();case"function":return parseFunctionDeclaration();case"if":return parseIfStatement();case"return":return parseReturnStatement();case"switch":return parseSwitchStatement();case"throw":return parseThrowStatement();case"try":return parseTryStatement();case"var":return parseVariableStatement();case"while":return parseWhileStatement();case"with":return parseWithStatement();default:break}}expr=parseExpression();if(expr.type===Syntax.Identifier&&match(":")){lex();if(Object.prototype.hasOwnProperty.call(state.labelSet,expr.name)){throwError({},Messages.Redeclaration,"Label",expr.name)}state.labelSet[expr.name]=true;labeledBody=parseStatement();delete state.labelSet[expr.name];return{type:Syntax.LabeledStatement,label:expr,body:labeledBody}}consumeSemicolon();return{type:Syntax.ExpressionStatement,expression:expr}}function parseFunctionSourceElements(){var sourceElement,sourceElements=[],token,directive,firstRestricted,oldLabelSet,oldInIteration,oldInSwitch,oldInFunctionBody;expect("{");while(index<length){token=lookahead();if(token.type!==Token.StringLiteral){break}sourceElement=parseSourceElement();sourceElements.push(sourceElement);if(sourceElement.expression.type!==Syntax.Literal){break}directive=sliceSource(token.range[0]+1,token.range[1]-1);if(directive==="use strict"){strict=true;if(firstRestricted){throwErrorTolerant(firstRestricted,Messages.StrictOctalLiteral)}}else{if(!firstRestricted&&token.octal){firstRestricted=token}}}oldLabelSet=state.labelSet;oldInIteration=state.inIteration;oldInSwitch=state.inSwitch;oldInFunctionBody=state.inFunctionBody;state.labelSet={};state.inIteration=false;state.inSwitch=false;state.inFunctionBody=true;while(index<length){if(match("}")){break}sourceElement=parseSourceElement();if(typeof sourceElement==="undefined"){break}sourceElements.push(sourceElement)}expect("}");state.labelSet=oldLabelSet;state.inIteration=oldInIteration;state.inSwitch=oldInSwitch;state.inFunctionBody=oldInFunctionBody;return{type:Syntax.BlockStatement,body:sourceElements}}function parseFunctionDeclaration(){var id,param,params=[],body,token,stricted,firstRestricted,message,previousStrict,paramSet;expectKeyword("function");token=lookahead();id=parseVariableIdentifier();if(strict){if(isRestrictedWord(token.value)){throwErrorTolerant(token,Messages.StrictFunctionName)}}else{if(isRestrictedWord(token.value)){firstRestricted=token;message=Messages.StrictFunctionName}else if(isStrictModeReservedWord(token.value)){firstRestricted=token;message=Messages.StrictReservedWord}}expect("(");if(!match(")")){paramSet={};while(index<length){token=lookahead();param=parseVariableIdentifier();if(strict){if(isRestrictedWord(token.value)){stricted=token;message=Messages.StrictParamName}if(Object.prototype.hasOwnProperty.call(paramSet,token.value)){stricted=token;message=Messages.StrictParamDupe}}else if(!firstRestricted){if(isRestrictedWord(token.value)){firstRestricted=token;message=Messages.StrictParamName}else if(isStrictModeReservedWord(token.value)){firstRestricted=token;message=Messages.StrictReservedWord}else if(Object.prototype.hasOwnProperty.call(paramSet,token.value)){firstRestricted=token;message=Messages.StrictParamDupe}}params.push(param);paramSet[param.name]=true;if(match(")")){break}expect(",")}}expect(")");previousStrict=strict;body=parseFunctionSourceElements();if(strict&&firstRestricted){throwError(firstRestricted,message)}if(strict&&stricted){throwErrorTolerant(stricted,message)}strict=previousStrict;return{type:Syntax.FunctionDeclaration,id:id,params:params,defaults:[],body:body,rest:null,generator:false,expression:false}}function parseFunctionExpression(){var token,id=null,stricted,firstRestricted,message,param,params=[],body,previousStrict,paramSet;expectKeyword("function");if(!match("(")){token=lookahead();id=parseVariableIdentifier();if(strict){if(isRestrictedWord(token.value)){throwErrorTolerant(token,Messages.StrictFunctionName)}}else{if(isRestrictedWord(token.value)){firstRestricted=token;message=Messages.StrictFunctionName}else if(isStrictModeReservedWord(token.value)){firstRestricted=token;message=Messages.StrictReservedWord}}}expect("(");if(!match(")")){paramSet={};while(index<length){token=lookahead();param=parseVariableIdentifier();if(strict){if(isRestrictedWord(token.value)){stricted=token;message=Messages.StrictParamName}if(Object.prototype.hasOwnProperty.call(paramSet,token.value)){stricted=token;message=Messages.StrictParamDupe}}else if(!firstRestricted){if(isRestrictedWord(token.value)){firstRestricted=token;message=Messages.StrictParamName}else if(isStrictModeReservedWord(token.value)){firstRestricted=token;message=Messages.StrictReservedWord}else if(Object.prototype.hasOwnProperty.call(paramSet,token.value)){firstRestricted=token;message=Messages.StrictParamDupe}}params.push(param);paramSet[param.name]=true;if(match(")")){break}expect(",")}}expect(")");previousStrict=strict;body=parseFunctionSourceElements();if(strict&&firstRestricted){throwError(firstRestricted,message)}if(strict&&stricted){throwErrorTolerant(stricted,message)}strict=previousStrict;return{type:Syntax.FunctionExpression,id:id,params:params,defaults:[],body:body,rest:null,generator:false,expression:false}}function parseSourceElement(){var token=lookahead();if(token.type===Token.Keyword){switch(token.value){case"const":case"let":return parseConstLetDeclaration(token.value);case"function":return parseFunctionDeclaration();default:return parseStatement()}}if(token.type!==Token.EOF){return parseStatement()}}function parseSourceElements(){var sourceElement,sourceElements=[],token,directive,firstRestricted;while(index<length){token=lookahead();if(token.type!==Token.StringLiteral){break}sourceElement=parseSourceElement();sourceElements.push(sourceElement);if(sourceElement.expression.type!==Syntax.Literal){break}directive=sliceSource(token.range[0]+1,token.range[1]-1);if(directive==="use strict"){strict=true;if(firstRestricted){throwErrorTolerant(firstRestricted,Messages.StrictOctalLiteral)}}else{if(!firstRestricted&&token.octal){firstRestricted=token}}}while(index<length){sourceElement=parseSourceElement();if(typeof sourceElement==="undefined"){break}sourceElements.push(sourceElement)}return sourceElements}function parseProgram(){var program;strict=false;program={type:Syntax.Program,body:parseSourceElements()};return program}function addComment(type,value,start,end,loc){assert(typeof start==="number","Comment must have valid position");if(extra.comments.length>0){if(extra.comments[extra.comments.length-1].range[1]>start){return}}extra.comments.push({type:type,value:value,range:[start,end],loc:loc})}function scanComment(){var comment,ch,loc,start,blockComment,lineComment;comment="";blockComment=false;lineComment=false;while(index<length){ch=source[index];if(lineComment){ch=source[index++];if(isLineTerminator(ch)){loc.end={line:lineNumber,column:index-lineStart-1};lineComment=false;addComment("Line",comment,start,index-1,loc);if(ch==="\r"&&source[index]==="\n"){++index}++lineNumber;lineStart=index;comment=""}else if(index>=length){lineComment=false;comment+=ch;loc.end={line:lineNumber,column:length-lineStart};addComment("Line",comment,start,length,loc)}else{comment+=ch}}else if(blockComment){if(isLineTerminator(ch)){if(ch==="\r"&&source[index+1]==="\n"){++index;comment+="\r\n"}else{comment+=ch}++lineNumber;++index;lineStart=index;if(index>=length){throwError({},Messages.UnexpectedToken,"ILLEGAL")}}else{ch=source[index++];if(index>=length){throwError({},Messages.UnexpectedToken,"ILLEGAL")}comment+=ch;if(ch==="*"){ch=source[index];if(ch==="/"){comment=comment.substr(0,comment.length-1);blockComment=false;++index;loc.end={line:lineNumber,column:index-lineStart};addComment("Block",comment,start,index,loc);comment=""}}}}else if(ch==="/"){ch=source[index+1];if(ch==="/"){loc={start:{line:lineNumber,column:index-lineStart}};start=index;index+=2;lineComment=true;if(index>=length){loc.end={line:lineNumber,column:index-lineStart};lineComment=false;addComment("Line",comment,start,index,loc)}}else if(ch==="*"){start=index;index+=2;blockComment=true;loc={start:{line:lineNumber,column:index-lineStart-2}};if(index>=length){throwError({},Messages.UnexpectedToken,"ILLEGAL")}}else{break}}else if(isWhiteSpace(ch)){++index}else if(isLineTerminator(ch)){++index;if(ch==="\r"&&source[index]==="\n"){++index}++lineNumber;lineStart=index}else{break}}}function filterCommentLocation(){var i,entry,comment,comments=[];for(i=0;i<extra.comments.length;++i){entry=extra.comments[i];comment={type:entry.type,value:entry.value};if(extra.range){comment.range=entry.range}if(extra.loc){comment.loc=entry.loc}comments.push(comment)}extra.comments=comments}function collectToken(){var start,loc,token,range,value;skipComment();start=index;loc={start:{line:lineNumber,column:index-lineStart}};token=extra.advance();loc.end={line:lineNumber,column:index-lineStart};if(token.type!==Token.EOF){range=[token.range[0],token.range[1]];value=sliceSource(token.range[0],token.range[1]);extra.tokens.push({type:TokenName[token.type],value:value,range:range,loc:loc})}return token}function collectRegex(){var pos,loc,regex,token;skipComment();pos=index;loc={start:{line:lineNumber,column:index-lineStart}};regex=extra.scanRegExp();loc.end={line:lineNumber,column:index-lineStart};if(extra.tokens.length>0){token=extra.tokens[extra.tokens.length-1];if(token.range[0]===pos&&token.type==="Punctuator"){if(token.value==="/"||token.value==="/="){extra.tokens.pop()}}}extra.tokens.push({type:"RegularExpression",value:regex.literal,range:[pos,index],loc:loc});return regex}function filterTokenLocation(){var i,entry,token,tokens=[];for(i=0;i<extra.tokens.length;++i){entry=extra.tokens[i];token={type:entry.type,value:entry.value};if(extra.range){token.range=entry.range}if(extra.loc){token.loc=entry.loc}tokens.push(token)}extra.tokens=tokens}function createLiteral(token){return{type:Syntax.Literal,value:token.value}}function createRawLiteral(token){return{type:Syntax.Literal,value:token.value,raw:sliceSource(token.range[0],token.range[1])}}function createLocationMarker(){var marker={};marker.range=[index,index];marker.loc={start:{line:lineNumber,column:index-lineStart},end:{line:lineNumber,column:index-lineStart}};marker.end=function(){this.range[1]=index;this.loc.end.line=lineNumber;this.loc.end.column=index-lineStart};marker.applyGroup=function(node){if(extra.range){node.groupRange=[this.range[0],this.range[1]]}if(extra.loc){node.groupLoc={start:{line:this.loc.start.line,column:this.loc.start.column},end:{line:this.loc.end.line,column:this.loc.end.column}}}};marker.apply=function(node){if(extra.range){node.range=[this.range[0],this.range[1]]}if(extra.loc){node.loc={start:{line:this.loc.start.line,column:this.loc.start.column},end:{line:this.loc.end.line,column:this.loc.end.column}}}};return marker}function trackGroupExpression(){var marker,expr;skipComment();marker=createLocationMarker();expect("(");expr=parseExpression();expect(")");marker.end();marker.applyGroup(expr);return expr}function trackLeftHandSideExpression(){var marker,expr;skipComment();marker=createLocationMarker();expr=matchKeyword("new")?parseNewExpression():parsePrimaryExpression();while(match(".")||match("[")){if(match("[")){expr={type:Syntax.MemberExpression,computed:true,object:expr,property:parseComputedMember()};marker.end();marker.apply(expr)}else{expr={type:Syntax.MemberExpression,computed:false,object:expr,property:parseNonComputedMember()};marker.end();marker.apply(expr)}}return expr}function trackLeftHandSideExpressionAllowCall(){var marker,expr;skipComment();marker=createLocationMarker();expr=matchKeyword("new")?parseNewExpression():parsePrimaryExpression();while(match(".")||match("[")||match("(")){if(match("(")){expr={type:Syntax.CallExpression,callee:expr,arguments:parseArguments()};marker.end();marker.apply(expr)}else if(match("[")){expr={type:Syntax.MemberExpression,computed:true,object:expr,property:parseComputedMember()};marker.end();marker.apply(expr)}else{expr={type:Syntax.MemberExpression,computed:false,object:expr,property:parseNonComputedMember()};marker.end();marker.apply(expr)}}return expr}function filterGroup(node){var n,i,entry;n=Object.prototype.toString.apply(node)==="[object Array]"?[]:{};for(i in node){if(node.hasOwnProperty(i)&&i!=="groupRange"&&i!=="groupLoc"){entry=node[i];if(entry===null||typeof entry!=="object"||entry instanceof RegExp){n[i]=entry}else{n[i]=filterGroup(entry)}}}return n}function wrapTrackingFunction(range,loc){return function(parseFunction){function isBinary(node){return node.type===Syntax.LogicalExpression||node.type===Syntax.BinaryExpression}function visit(node){var start,end;if(isBinary(node.left)){visit(node.left)}if(isBinary(node.right)){visit(node.right)}if(range){if(node.left.groupRange||node.right.groupRange){start=node.left.groupRange?node.left.groupRange[0]:node.left.range[0];end=node.right.groupRange?node.right.groupRange[1]:node.right.range[1];node.range=[start,end]}else if(typeof node.range==="undefined"){start=node.left.range[0];end=node.right.range[1];node.range=[start,end]}}if(loc){if(node.left.groupLoc||node.right.groupLoc){start=node.left.groupLoc?node.left.groupLoc.start:node.left.loc.start;end=node.right.groupLoc?node.right.groupLoc.end:node.right.loc.end;node.loc={start:start,end:end}}else if(typeof node.loc==="undefined"){node.loc={start:node.left.loc.start,end:node.right.loc.end}}}}return function(){var marker,node;skipComment();marker=createLocationMarker();node=parseFunction.apply(null,arguments);marker.end();if(range&&typeof node.range==="undefined"){marker.apply(node)}if(loc&&typeof node.loc==="undefined"){marker.apply(node)}if(isBinary(node)){visit(node)}return node}}}function patch(){var wrapTracking;if(extra.comments){extra.skipComment=skipComment;skipComment=scanComment}if(extra.raw){extra.createLiteral=createLiteral;createLiteral=createRawLiteral}if(extra.range||extra.loc){extra.parseGroupExpression=parseGroupExpression;extra.parseLeftHandSideExpression=parseLeftHandSideExpression;extra.parseLeftHandSideExpressionAllowCall=parseLeftHandSideExpressionAllowCall;parseGroupExpression=trackGroupExpression;parseLeftHandSideExpression=trackLeftHandSideExpression;parseLeftHandSideExpressionAllowCall=trackLeftHandSideExpressionAllowCall;wrapTracking=wrapTrackingFunction(extra.range,extra.loc);extra.parseAdditiveExpression=parseAdditiveExpression;extra.parseAssignmentExpression=parseAssignmentExpression;extra.parseBitwiseANDExpression=parseBitwiseANDExpression;extra.parseBitwiseORExpression=parseBitwiseORExpression;extra.parseBitwiseXORExpression=parseBitwiseXORExpression;extra.parseBlock=parseBlock;extra.parseFunctionSourceElements=parseFunctionSourceElements;extra.parseCatchClause=parseCatchClause;extra.parseComputedMember=parseComputedMember;extra.parseConditionalExpression=parseConditionalExpression;extra.parseConstLetDeclaration=parseConstLetDeclaration;extra.parseEqualityExpression=parseEqualityExpression;extra.parseExpression=parseExpression;extra.parseForVariableDeclaration=parseForVariableDeclaration;extra.parseFunctionDeclaration=parseFunctionDeclaration;extra.parseFunctionExpression=parseFunctionExpression;extra.parseLogicalANDExpression=parseLogicalANDExpression;extra.parseLogicalORExpression=parseLogicalORExpression;extra.parseMultiplicativeExpression=parseMultiplicativeExpression;extra.parseNewExpression=parseNewExpression;extra.parseNonComputedProperty=parseNonComputedProperty;extra.parseObjectProperty=parseObjectProperty;extra.parseObjectPropertyKey=parseObjectPropertyKey;extra.parsePostfixExpression=parsePostfixExpression;extra.parsePrimaryExpression=parsePrimaryExpression;extra.parseProgram=parseProgram;extra.parsePropertyFunction=parsePropertyFunction;extra.parseRelationalExpression=parseRelationalExpression;extra.parseStatement=parseStatement;extra.parseShiftExpression=parseShiftExpression;extra.parseSwitchCase=parseSwitchCase;extra.parseUnaryExpression=parseUnaryExpression;extra.parseVariableDeclaration=parseVariableDeclaration;extra.parseVariableIdentifier=parseVariableIdentifier;parseAdditiveExpression=wrapTracking(extra.parseAdditiveExpression);parseAssignmentExpression=wrapTracking(extra.parseAssignmentExpression);
parseBitwiseANDExpression=wrapTracking(extra.parseBitwiseANDExpression);parseBitwiseORExpression=wrapTracking(extra.parseBitwiseORExpression);parseBitwiseXORExpression=wrapTracking(extra.parseBitwiseXORExpression);parseBlock=wrapTracking(extra.parseBlock);parseFunctionSourceElements=wrapTracking(extra.parseFunctionSourceElements);parseCatchClause=wrapTracking(extra.parseCatchClause);parseComputedMember=wrapTracking(extra.parseComputedMember);parseConditionalExpression=wrapTracking(extra.parseConditionalExpression);parseConstLetDeclaration=wrapTracking(extra.parseConstLetDeclaration);parseEqualityExpression=wrapTracking(extra.parseEqualityExpression);parseExpression=wrapTracking(extra.parseExpression);parseForVariableDeclaration=wrapTracking(extra.parseForVariableDeclaration);parseFunctionDeclaration=wrapTracking(extra.parseFunctionDeclaration);parseFunctionExpression=wrapTracking(extra.parseFunctionExpression);parseLeftHandSideExpression=wrapTracking(parseLeftHandSideExpression);parseLogicalANDExpression=wrapTracking(extra.parseLogicalANDExpression);parseLogicalORExpression=wrapTracking(extra.parseLogicalORExpression);parseMultiplicativeExpression=wrapTracking(extra.parseMultiplicativeExpression);parseNewExpression=wrapTracking(extra.parseNewExpression);parseNonComputedProperty=wrapTracking(extra.parseNonComputedProperty);parseObjectProperty=wrapTracking(extra.parseObjectProperty);parseObjectPropertyKey=wrapTracking(extra.parseObjectPropertyKey);parsePostfixExpression=wrapTracking(extra.parsePostfixExpression);parsePrimaryExpression=wrapTracking(extra.parsePrimaryExpression);parseProgram=wrapTracking(extra.parseProgram);parsePropertyFunction=wrapTracking(extra.parsePropertyFunction);parseRelationalExpression=wrapTracking(extra.parseRelationalExpression);parseStatement=wrapTracking(extra.parseStatement);parseShiftExpression=wrapTracking(extra.parseShiftExpression);parseSwitchCase=wrapTracking(extra.parseSwitchCase);parseUnaryExpression=wrapTracking(extra.parseUnaryExpression);parseVariableDeclaration=wrapTracking(extra.parseVariableDeclaration);parseVariableIdentifier=wrapTracking(extra.parseVariableIdentifier)}if(typeof extra.tokens!=="undefined"){extra.advance=advance;extra.scanRegExp=scanRegExp;advance=collectToken;scanRegExp=collectRegex}}function unpatch(){if(typeof extra.skipComment==="function"){skipComment=extra.skipComment}if(extra.raw){createLiteral=extra.createLiteral}if(extra.range||extra.loc){parseAdditiveExpression=extra.parseAdditiveExpression;parseAssignmentExpression=extra.parseAssignmentExpression;parseBitwiseANDExpression=extra.parseBitwiseANDExpression;parseBitwiseORExpression=extra.parseBitwiseORExpression;parseBitwiseXORExpression=extra.parseBitwiseXORExpression;parseBlock=extra.parseBlock;parseFunctionSourceElements=extra.parseFunctionSourceElements;parseCatchClause=extra.parseCatchClause;parseComputedMember=extra.parseComputedMember;parseConditionalExpression=extra.parseConditionalExpression;parseConstLetDeclaration=extra.parseConstLetDeclaration;parseEqualityExpression=extra.parseEqualityExpression;parseExpression=extra.parseExpression;parseForVariableDeclaration=extra.parseForVariableDeclaration;parseFunctionDeclaration=extra.parseFunctionDeclaration;parseFunctionExpression=extra.parseFunctionExpression;parseGroupExpression=extra.parseGroupExpression;parseLeftHandSideExpression=extra.parseLeftHandSideExpression;parseLeftHandSideExpressionAllowCall=extra.parseLeftHandSideExpressionAllowCall;parseLogicalANDExpression=extra.parseLogicalANDExpression;parseLogicalORExpression=extra.parseLogicalORExpression;parseMultiplicativeExpression=extra.parseMultiplicativeExpression;parseNewExpression=extra.parseNewExpression;parseNonComputedProperty=extra.parseNonComputedProperty;parseObjectProperty=extra.parseObjectProperty;parseObjectPropertyKey=extra.parseObjectPropertyKey;parsePrimaryExpression=extra.parsePrimaryExpression;parsePostfixExpression=extra.parsePostfixExpression;parseProgram=extra.parseProgram;parsePropertyFunction=extra.parsePropertyFunction;parseRelationalExpression=extra.parseRelationalExpression;parseStatement=extra.parseStatement;parseShiftExpression=extra.parseShiftExpression;parseSwitchCase=extra.parseSwitchCase;parseUnaryExpression=extra.parseUnaryExpression;parseVariableDeclaration=extra.parseVariableDeclaration;parseVariableIdentifier=extra.parseVariableIdentifier}if(typeof extra.scanRegExp==="function"){advance=extra.advance;scanRegExp=extra.scanRegExp}}function stringToArray(str){var length=str.length,result=[],i;for(i=0;i<length;++i){result[i]=str.charAt(i)}return result}function parse(code,options){var program,toString;toString=String;if(typeof code!=="string"&&!(code instanceof String)){code=toString(code)}source=code;index=0;lineNumber=source.length>0?1:0;lineStart=0;length=source.length;buffer=null;state={allowIn:true,labelSet:{},inFunctionBody:false,inIteration:false,inSwitch:false};extra={};if(typeof options!=="undefined"){extra.range=typeof options.range==="boolean"&&options.range;extra.loc=typeof options.loc==="boolean"&&options.loc;extra.raw=typeof options.raw==="boolean"&&options.raw;if(typeof options.tokens==="boolean"&&options.tokens){extra.tokens=[]}if(typeof options.comment==="boolean"&&options.comment){extra.comments=[]}if(typeof options.tolerant==="boolean"&&options.tolerant){extra.errors=[]}}if(length>0){if(typeof source[0]==="undefined"){if(code instanceof String){source=code.valueOf()}if(typeof source[0]==="undefined"){source=stringToArray(code)}}}patch();try{program=parseProgram();if(typeof extra.comments!=="undefined"){filterCommentLocation();program.comments=extra.comments}if(typeof extra.tokens!=="undefined"){filterTokenLocation();program.tokens=extra.tokens}if(typeof extra.errors!=="undefined"){program.errors=extra.errors}if(extra.range||extra.loc){program.body=filterGroup(program.body)}}catch(e){throw e}finally{unpatch();extra={}}return program}exports.version="1.0.4";exports.parse=parse;exports.Syntax=function(){var name,types={};if(typeof Object.create==="function"){types=Object.create(null)}for(name in Syntax){if(Syntax.hasOwnProperty(name)){types[name]=Syntax[name]}}if(typeof Object.freeze==="function"){Object.freeze(types)}return types}()})},{}],61:[function(require,module,exports){module.exports=require(58)},{}],62:[function(require,module,exports){"use strict";var compile=require("cwise-compiler");var EmptyProc={body:"",args:[],thisVars:[],localVars:[]};function fixup(x){if(!x){return EmptyProc}for(var i=0;i<x.args.length;++i){var a=x.args[i];if(i===0){x.args[i]={name:a,lvalue:true,rvalue:!!x.rvalue,count:x.count||1}}else{x.args[i]={name:a,lvalue:false,rvalue:true,count:1}}}if(!x.thisVars){x.thisVars=[]}if(!x.localVars){x.localVars=[]}return x}function pcompile(user_args){return compile({args:user_args.args,pre:fixup(user_args.pre),body:fixup(user_args.body),post:fixup(user_args.proc),funcName:user_args.funcName})}function makeOp(user_args){var args=[];for(var i=0;i<user_args.args.length;++i){args.push("a"+i)}var wrapper=new Function("P",["return function ",user_args.funcName,"_ndarrayops(",args.join(","),") {P(",args.join(","),");return a0}"].join(""));return wrapper(pcompile(user_args))}var assign_ops={add:"+",sub:"-",mul:"*",div:"/",mod:"%",band:"&",bor:"|",bxor:"^",lshift:"<<",rshift:">>",rrshift:">>>"};(function(){for(var id in assign_ops){var op=assign_ops[id];exports[id]=makeOp({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+op+"c"},funcName:id});exports[id+"eq"]=makeOp({args:["array","array"],body:{args:["a","b"],body:"a"+op+"=b"},rvalue:true,funcName:id+"eq"});exports[id+"s"]=makeOp({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+op+"s"},funcName:id+"s"});exports[id+"seq"]=makeOp({args:["array","scalar"],body:{args:["a","s"],body:"a"+op+"=s"},rvalue:true,funcName:id+"seq"})}})();var unary_ops={not:"!",bnot:"~",neg:"-",recip:"1.0/"};(function(){for(var id in unary_ops){var op=unary_ops[id];exports[id]=makeOp({args:["array","array"],body:{args:["a","b"],body:"a="+op+"b"},funcName:id});exports[id+"eq"]=makeOp({args:["array"],body:{args:["a"],body:"a="+op+"a"},rvalue:true,count:2,funcName:id+"eq"})}})();var binary_ops={and:"&&",or:"||",eq:"===",neq:"!==",lt:"<",gt:">",leq:"<=",geq:">="};(function(){for(var id in binary_ops){var op=binary_ops[id];exports[id]=makeOp({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+op+"c"},funcName:id});exports[id+"s"]=makeOp({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+op+"s"},funcName:id+"s"});exports[id+"eq"]=makeOp({args:["array","array"],body:{args:["a","b"],body:"a=a"+op+"b"},rvalue:true,count:2,funcName:id+"eq"});exports[id+"seq"]=makeOp({args:["array","scalar"],body:{args:["a","s"],body:"a=a"+op+"s"},rvalue:true,count:2,funcName:id+"seq"})}})();var math_unary=["abs","acos","asin","atan","ceil","cos","exp","floor","log","round","sin","sqrt","tan"];(function(){for(var i=0;i<math_unary.length;++i){var f=math_unary[i];exports[f]=makeOp({args:["array","array"],pre:{args:[],body:"this_f=Math."+f,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b)",thisVars:["this_f"]},funcName:f});exports[f+"eq"]=makeOp({args:["array"],pre:{args:[],body:"this_f=Math."+f,thisVars:["this_f"]},body:{args:["a"],body:"a=this_f(a)",thisVars:["this_f"]},rvalue:true,count:2,funcName:f+"eq"})}})();var math_comm=["max","min","atan2","pow"];(function(){for(var i=0;i<math_comm.length;++i){var f=math_comm[i];exports[f]=makeOp({args:["array","array","array"],pre:{args:[],body:"this_f=Math."+f,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(b,c)",thisVars:["this_f"]},funcName:f});exports[f+"s"]=makeOp({args:["array","array","scalar"],pre:{args:[],body:"this_f=Math."+f,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(b,c)",thisVars:["this_f"]},funcName:f+"s"});exports[f+"eq"]=makeOp({args:["array","array"],pre:{args:[],body:"this_f=Math."+f,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(a,b)",thisVars:["this_f"]},rvalue:true,count:2,funcName:f+"eq"});exports[f+"seq"]=makeOp({args:["array","scalar"],pre:{args:[],body:"this_f=Math."+f,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(a,b)",thisVars:["this_f"]},rvalue:true,count:2,funcName:f+"seq"})}})();var math_noncomm=["atan2","pow"];(function(){for(var i=0;i<math_noncomm.length;++i){var f=math_noncomm[i];exports[f+"op"]=makeOp({args:["array","array","array"],pre:{args:[],body:"this_f=Math."+f,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(c,b)",thisVars:["this_f"]},funcName:f+"op"});exports[f+"ops"]=makeOp({args:["array","array","scalar"],pre:{args:[],body:"this_f=Math."+f,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(c,b)",thisVars:["this_f"]},funcName:f+"ops"});exports[f+"opeq"]=makeOp({args:["array","array"],pre:{args:[],body:"this_f=Math."+f,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b,a)",thisVars:["this_f"]},rvalue:true,count:2,funcName:f+"opeq"});exports[f+"opseq"]=makeOp({args:["array","scalar"],pre:{args:[],body:"this_f=Math."+f,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b,a)",thisVars:["this_f"]},rvalue:true,count:2,funcName:f+"opseq"})}})();exports.any=compile({args:["array"],pre:EmptyProc,body:{args:[{name:"a",lvalue:false,rvalue:true,count:1}],body:"if(a){return true}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return false"},funcName:"any"});exports.all=compile({args:["array"],pre:EmptyProc,body:{args:[{name:"x",lvalue:false,rvalue:true,count:1}],body:"if(!x){return false}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return true"},funcName:"all"});exports.sum=compile({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:false,rvalue:true,count:1}],body:"this_s+=a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"sum"});exports.prod=compile({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=1"},body:{args:[{name:"a",lvalue:false,rvalue:true,count:1}],body:"this_s*=a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"prod"});exports.norm2squared=compile({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:false,rvalue:true,count:2}],body:"this_s+=a*a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm2squared"});exports.norm2=compile({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:false,rvalue:true,count:2}],body:"this_s+=a*a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return Math.sqrt(this_s)"},funcName:"norm2"});exports.norminf=compile({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:false,rvalue:true,count:4}],body:"if(-a>this_s){this_s=-a}else if(a>this_s){this_s=a}",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norminf"});exports.norm1=compile({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:false,rvalue:true,count:3}],body:"this_s+=a<0?-a:a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm1"});exports.sup=compile({args:["array"],pre:{body:"this_h=-Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_>this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:false,rvalue:true,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}});exports.inf=compile({args:["array"],pre:{body:"this_h=Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_<this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:false,rvalue:true,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}});exports.argmin=compile({args:["index","array","shape"],pre:{body:"{this_v=Infinity;this_i=_inline_0_arg2_.slice(0)}",args:[{name:"_inline_0_arg0_",lvalue:false,rvalue:false,count:0},{name:"_inline_0_arg1_",lvalue:false,rvalue:false,count:0},{name:"_inline_0_arg2_",lvalue:false,rvalue:true,count:1}],thisVars:["this_i","this_v"],localVars:[]},body:{body:"{if(_inline_1_arg1_<this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:false,rvalue:true,count:2},{name:"_inline_1_arg1_",lvalue:false,rvalue:true,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}});exports.argmax=compile({args:["index","array","shape"],pre:{body:"{this_v=-Infinity;this_i=_inline_0_arg2_.slice(0)}",args:[{name:"_inline_0_arg0_",lvalue:false,rvalue:false,count:0},{name:"_inline_0_arg1_",lvalue:false,rvalue:false,count:0},{name:"_inline_0_arg2_",lvalue:false,rvalue:true,count:1}],thisVars:["this_i","this_v"],localVars:[]},body:{body:"{if(_inline_1_arg1_>this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:false,rvalue:true,count:2},{name:"_inline_1_arg1_",lvalue:false,rvalue:true,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}});exports.random=makeOp({args:["array"],pre:{args:[],body:"this_f=Math.random",thisVars:["this_f"]},body:{args:["a"],body:"a=this_f()",thisVars:["this_f"]},funcName:"random"});exports.assign=makeOp({args:["array","array"],body:{args:["a","b"],body:"a=b"},funcName:"assign"});exports.assigns=makeOp({args:["array","scalar"],body:{args:["a","b"],body:"a=b"},funcName:"assigns"})},{"cwise-compiler":63}],63:[function(require,module,exports){module.exports=require(55)},{"./lib/thunk.js":65}],64:[function(require,module,exports){module.exports=require(56)},{uniq:66}],65:[function(require,module,exports){arguments[4][44][0].apply(exports,arguments)},{"./compile.js":64}],66:[function(require,module,exports){module.exports=require(58)},{}],67:[function(require,module,exports){"use strict";function dupe_array(count,value,i){var c=count[i]|0;if(c<=0){return[]}var result=new Array(c),j;if(i===count.length-1){for(j=0;j<c;++j){result[j]=value}}else{for(j=0;j<c;++j){result[j]=dupe_array(count,value,i+1)}}return result}function dupe_number(count,value){var result,i;result=new Array(count);for(i=0;i<count;++i){result[i]=value}return result}function dupe(count,value){if(typeof value==="undefined"){value=0}switch(typeof count){case"number":if(count>0){return dupe_number(count|0,value)}break;case"object":if(typeof count.length==="number"){return dupe_array(count,value,0)}break}return[]}module.exports=dupe},{}],68:[function(require,module,exports){(function(global){"use strict";var bits=require("bit-twiddle");var dup=require("dup");if(!global.__TYPEDARRAY_POOL){global.__TYPEDARRAY_POOL={UINT8:dup([32,0]),UINT16:dup([32,0]),UINT32:dup([32,0]),INT8:dup([32,0]),INT16:dup([32,0]),INT32:dup([32,0]),FLOAT:dup([32,0]),DOUBLE:dup([32,0]),DATA:dup([32,0])}}var POOL=global.__TYPEDARRAY_POOL;var UINT8=POOL.UINT8,UINT16=POOL.UINT16,UINT32=POOL.UINT32,INT8=POOL.INT8,INT16=POOL.INT16,INT32=POOL.INT32,FLOAT=POOL.FLOAT,DOUBLE=POOL.DOUBLE,DATA=POOL.DATA;exports.free=function free(array){if(array instanceof ArrayBuffer){var n=array.byteLength|0,log_n=bits.log2(n);DATA[log_n].push(array)}else{var n=array.length|0,log_n=bits.log2(n);if(array instanceof Uint8Array){UINT8[log_n].push(array)}else if(array instanceof Uint16Array){UINT16[log_n].push(array)}else if(array instanceof Uint32Array){UINT32[log_n].push(array)}else if(array instanceof Int8Array){INT8[log_n].push(array)}else if(array instanceof Int16Array){INT16[log_n].push(array)}else if(array instanceof Int32Array){INT32[log_n].push(array)}else if(array instanceof Float32Array){FLOAT[log_n].push(array)}else if(array instanceof Float64Array){DOUBLE[log_n].push(array)}}};exports.freeUint8=function freeUint8(array){UINT8[bits.log2(array.length)].push(array)};exports.freeUint16=function freeUint16(array){UINT16[bits.log2(array.length)].push(array)};exports.freeUint32=function freeUint32(array){UINT32[bits.log2(array.length)].push(array)};exports.freeInt8=function freeInt8(array){INT8[bits.log2(array.length)].push(array)};exports.freeInt16=function freeInt16(array){INT16[bits.log2(array.length)].push(array)};exports.freeInt32=function freeInt32(array){INT32[bits.log2(array.length)].push(array)};exports.freeFloat32=exports.freeFloat=function freeFloat(array){FLOAT[bits.log2(array.length)].push(array)};exports.freeFloat64=exports.freeDouble=function freeDouble(array){DOUBLE[bits.log2(array.length)].push(array)};exports.freeArrayBuffer=function freeArrayBuffer(array){DATA[bits.log2(array.length)].push(array)};exports.malloc=function malloc(n,dtype){n=bits.nextPow2(n);var log_n=bits.log2(n);if(dtype===undefined){var d=DATA[log_n];if(d.length>0){var r=d[d.length-1];d.pop();return r}return new ArrayBuffer(n)}else{switch(dtype){case"uint8":var u8=UINT8[log_n];if(u8.length>0){return u8.pop()}return new Uint8Array(n);break;case"uint16":var u16=UINT16[log_n];if(u16.length>0){return u16.pop()}return new Uint16Array(n);break;case"uint32":var u32=UINT32[log_n];if(u32.length>0){return u32.pop()}return new Uint32Array(n);break;case"int8":var i8=INT8[log_n];if(i8.length>0){return i8.pop()}return new Int8Array(n);break;case"int16":var i16=INT16[log_n];if(i16.length>0){return i16.pop()}return new Int16Array(n);break;case"int32":var i32=INT32[log_n];if(i32.length>0){return i32.pop()}return new Int32Array(n);break;case"float":case"float32":var f=FLOAT[log_n];if(f.length>0){return f.pop()}return new Float32Array(n);break;case"double":case"float64":var dd=DOUBLE[log_n];if(dd.length>0){return dd.pop()}return new Float64Array(n);break;default:return null}}return null};exports.mallocUint8=function mallocUint8(n){n=bits.nextPow2(n);var log_n=bits.log2(n);var cache=UINT8[log_n];if(cache.length>0){return cache.pop()}return new Uint8Array(n)};exports.mallocUint16=function mallocUint16(n){n=bits.nextPow2(n);var log_n=bits.log2(n);var cache=UINT16[log_n];if(cache.length>0){return cache.pop()}return new Uint16Array(n)};exports.mallocUint32=function mallocUint32(n){n=bits.nextPow2(n);var log_n=bits.log2(n);var cache=UINT32[log_n];if(cache.length>0){return cache.pop()}return new Uint32Array(n)};exports.mallocInt8=function mallocInt8(n){n=bits.nextPow2(n);var log_n=bits.log2(n);var cache=INT8[log_n];if(cache.length>0){return cache.pop()}return new Int8Array(n)};exports.mallocInt16=function mallocInt16(n){n=bits.nextPow2(n);var log_n=bits.log2(n);var cache=INT16[log_n];if(cache.length>0){return cache.pop()}return new Int16Array(n)};exports.mallocInt32=function mallocInt32(n){n=bits.nextPow2(n);var log_n=bits.log2(n);var cache=INT32[log_n];if(cache.length>0){return cache.pop()}return new Int32Array(n)};exports.mallocFloat32=exports.mallocFloat=function mallocFloat(n){n=bits.nextPow2(n);var log_n=bits.log2(n);var cache=FLOAT[log_n];if(cache.length>0){return cache.pop()}return new Float32Array(n)};exports.mallocFloat64=exports.mallocDouble=function mallocDouble(n){n=bits.nextPow2(n);var log_n=bits.log2(n);var cache=DOUBLE[log_n];if(cache.length>0){return cache.pop()}return new Float64Array(n)};exports.mallocArrayBuffer=function mallocArrayBuffer(n){n=bits.nextPow2(n);var log_n=bits.log2(n);var cache=DATA[log_n];if(cache.length>0){return cache.pop()}return new ArrayBuffer(n)};exports.clearCache=function clearCache(){for(var i=0;i<32;++i){UINT8[i].length=0;UINT16[i].length=0;UINT32[i].length=0;INT8[i].length=0;INT16[i].length=0;INT32[i].length=0;FLOAT[i].length=0;DOUBLE[i].length=0;DATA[i].length=0}}}).call(this,typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"bit-twiddle":53,dup:67}],69:[function(require,module,exports){(function(Buffer){var iota=require("iota-array");var arrayMethods=["concat","join","slice","toString","indexOf","lastIndexOf","forEach","every","some","filter","map","reduce","reduceRight"];var hasTypedArrays=typeof Float64Array!=="undefined";var hasBuffer=typeof Buffer!=="undefined";function compare1st(a,b){return a[0]-b[0]}function order(){var stride=this.stride;var terms=new Array(stride.length);var i;for(i=0;i<terms.length;++i){terms[i]=[Math.abs(stride[i]),i]}terms.sort(compare1st);var result=new Array(terms.length);for(i=0;i<result.length;++i){result[i]=terms[i][1]}return result}function compileConstructor(dtype,dimension){var className=["View",dimension,"d",dtype].join("");if(dimension<0){className="View_Nil"+dtype}var useGetters=dtype==="generic";if(dimension===-1){var code="function "+className+"(a){this.data=a;};var proto="+className+".prototype;proto.dtype='"+dtype+"';proto.index=function(){return -1};proto.size=0;proto.dimension=-1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function(){return new "+className+"(this.data);};proto.get=proto.set=function(){};proto.pick=function(){return null};return function construct_"+className+"(a){return new "+className+"(a);}";var procedure=new Function(code);return procedure()}else if(dimension===0){var code="function "+className+"(a,d) {this.data = a;this.offset = d};var proto="+className+".prototype;proto.dtype='"+dtype+"';proto.index=function(){return this.offset};proto.dimension=0;proto.size=1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function "+className+"_copy() {return new "+className+"(this.data,this.offset)};proto.pick=function "+className+"_pick(){return TrivialArray(this.data);};proto.valueOf=proto.get=function "+className+"_get(){return "+(useGetters?"this.data.get(this.offset)":"this.data[this.offset]")+"};proto.set=function "+className+"_set(v){return "+(useGetters?"this.data.set(this.offset,v)":"this.data[this.offset]=v")+"};return function construct_"+className+"(a,b,c,d){return new "+className+"(a,d)}";var procedure=new Function("TrivialArray",code);return procedure(CACHED_CONSTRUCTORS[dtype][0])}var code=["'use strict'"];var indices=iota(dimension);var args=indices.map(function(i){return"i"+i});var index_str="this.offset+"+indices.map(function(i){return"this._stride"+i+"*i"+i}).join("+");code.push("function "+className+"(a,"+indices.map(function(i){return"b"+i}).join(",")+","+indices.map(function(i){return"c"+i}).join(",")+",d){this.data=a");for(var i=0;i<dimension;++i){code.push("this._shape"+i+"=b"+i+"|0")}for(var i=0;i<dimension;++i){code.push("this._stride"+i+"=c"+i+"|0")}code.push("this.offset=d|0}","var proto="+className+".prototype","proto.dtype='"+dtype+"'","proto.dimension="+dimension);var strideClassName="VStride"+dimension+"d"+dtype;var shapeClassName="VShape"+dimension+"d"+dtype;var props={stride:strideClassName,shape:shapeClassName};for(var prop in props){var arrayName=props[prop];code.push("function "+arrayName+"(v) {this._v=v} var aproto="+arrayName+".prototype","aproto.length="+dimension);var array_elements=[];for(var i=0;i<dimension;++i){array_elements.push(["this._v._",prop,i].join(""))}code.push("aproto.toJSON=function "+arrayName+"_toJSON(){return ["+array_elements.join(",")+"]}","aproto.valueOf=aproto.toString=function "+arrayName+"_toString(){return ["+array_elements.join(",")+"].join()}");for(var i=0;i<dimension;++i){code.push("Object.defineProperty(aproto,"+i+",{get:function(){return this._v._"+prop+i+"},set:function(v){return this._v._"+prop+i+"=v|0},enumerable:true})")}for(var i=0;i<arrayMethods.length;++i){if(arrayMethods[i]in Array.prototype){code.push("aproto."+arrayMethods[i]+"=Array.prototype."+arrayMethods[i])}}code.push(["Object.defineProperty(proto,'",prop,"',{get:function ",arrayName,"_get(){return new ",arrayName,"(this)},set: function ",arrayName,"_set(v){"].join(""));for(var i=0;i<dimension;++i){code.push("this._"+prop+i+"=v["+i+"]|0")}code.push("return v}})")}code.push("Object.defineProperty(proto,'size',{get:function "+className+"_size(){return "+indices.map(function(i){return"this._shape"+i}).join("*"),"}})");if(dimension===1){code.push("proto.order=[0]")}else{code.push("Object.defineProperty(proto,'order',{get:");if(dimension<4){code.push("function "+className+"_order(){");if(dimension===2){code.push("return (Math.abs(this._stride0)>Math.abs(this._stride1))?[1,0]:[0,1]}})")}else if(dimension===3){code.push("var s0=Math.abs(this._stride0),s1=Math.abs(this._stride1),s2=Math.abs(this._stride2);if(s0>s1){if(s1>s2){return [2,1,0];}else if(s0>s2){return [1,2,0];}else{return [1,0,2];}}else if(s0>s2){return [2,0,1];}else if(s2>s1){return [0,1,2];}else{return [0,2,1];}}})")}}else{code.push("ORDER})")}}code.push("proto.set=function "+className+"_set("+args.join(",")+",v){");if(useGetters){code.push("return this.data.set("+index_str+",v)}")}else{code.push("return this.data["+index_str+"]=v}")}code.push("proto.get=function "+className+"_get("+args.join(",")+"){");if(useGetters){code.push("return this.data.get("+index_str+")}")}else{code.push("return this.data["+index_str+"]}")}code.push("proto.index=function "+className+"_index(",args.join(),"){return "+index_str+"}");code.push("proto.hi=function "+className+"_hi("+args.join(",")+"){return new "+className+"(this.data,"+indices.map(function(i){return["(typeof i",i,"!=='number'||i",i,"<0)?this._shape",i,":i",i,"|0"].join("")}).join(",")+","+indices.map(function(i){return"this._stride"+i}).join(",")+",this.offset)}");var a_vars=indices.map(function(i){return"a"+i+"=this._shape"+i});var c_vars=indices.map(function(i){return"c"+i+"=this._stride"+i});code.push("proto.lo=function "+className+"_lo("+args.join(",")+"){var b=this.offset,d=0,"+a_vars.join(",")+","+c_vars.join(","));for(var i=0;i<dimension;++i){code.push("if(typeof i"+i+"==='number'&&i"+i+">=0){d=i"+i+"|0;b+=c"+i+"*d;a"+i+"-=d}")}code.push("return new "+className+"(this.data,"+indices.map(function(i){return"a"+i}).join(",")+","+indices.map(function(i){return"c"+i}).join(",")+",b)}");code.push("proto.step=function "+className+"_step("+args.join(",")+"){var "+indices.map(function(i){return"a"+i+"=this._shape"+i}).join(",")+","+indices.map(function(i){return"b"+i+"=this._stride"+i}).join(",")+",c=this.offset,d=0,ceil=Math.ceil");for(var i=0;i<dimension;++i){code.push("if(typeof i"+i+"==='number'){d=i"+i+"|0;if(d<0){c+=b"+i+"*(a"+i+"-1);a"+i+"=ceil(-a"+i+"/d)}else{a"+i+"=ceil(a"+i+"/d)}b"+i+"*=d}")}code.push("return new "+className+"(this.data,"+indices.map(function(i){return"a"+i}).join(",")+","+indices.map(function(i){return"b"+i}).join(",")+",c)}");var tShape=new Array(dimension);var tStride=new Array(dimension);for(var i=0;i<dimension;++i){tShape[i]="a[i"+i+"]";tStride[i]="b[i"+i+"]"}code.push("proto.transpose=function "+className+"_transpose("+args+"){"+args.map(function(n,idx){return n+"=("+n+"===undefined?"+idx+":"+n+"|0)"}).join(";"),"var a=this.shape,b=this.stride;return new "+className+"(this.data,"+tShape.join(",")+","+tStride.join(",")+",this.offset)}");code.push("proto.pick=function "+className+"_pick("+args+"){var a=[],b=[],c=this.offset");for(var i=0;i<dimension;++i){code.push("if(typeof i"+i+"==='number'&&i"+i+">=0){c=(c+this._stride"+i+"*i"+i+")|0}else{a.push(this._shape"+i+");b.push(this._stride"+i+")}")}code.push("var ctor=CTOR_LIST[a.length+1];return ctor(this.data,a,b,c)}");code.push("return function construct_"+className+"(data,shape,stride,offset){return new "+className+"(data,"+indices.map(function(i){return"shape["+i+"]"}).join(",")+","+indices.map(function(i){return"stride["+i+"]"}).join(",")+",offset)}");var procedure=new Function("CTOR_LIST","ORDER",code.join("\n"));return procedure(CACHED_CONSTRUCTORS[dtype],order)}function arrayDType(data){if(hasBuffer){if(Buffer.isBuffer(data)){return"buffer"}}if(hasTypedArrays){switch(Object.prototype.toString.call(data)){case"[object Float64Array]":return"float64";case"[object Float32Array]":return"float32";case"[object Int8Array]":return"int8";case"[object Int16Array]":return"int16";case"[object Int32Array]":return"int32";case"[object Uint8Array]":return"uint8";case"[object Uint16Array]":return"uint16";case"[object Uint32Array]":return"uint32";case"[object Uint8ClampedArray]":return"uint8_clamped"}}if(Array.isArray(data)){return"array"}return"generic"}var CACHED_CONSTRUCTORS={float32:[],float64:[],int8:[],int16:[],int32:[],uint8:[],uint16:[],uint32:[],array:[],uint8_clamped:[],buffer:[],generic:[]};(function(){for(var id in CACHED_CONSTRUCTORS){CACHED_CONSTRUCTORS[id].push(compileConstructor(id,-1))}});function wrappedNDArrayCtor(data,shape,stride,offset){if(data===undefined){var ctor=CACHED_CONSTRUCTORS.array[0];return ctor([])}else if(typeof data==="number"){data=[data]}if(shape===undefined){shape=[data.length]}var d=shape.length;if(stride===undefined){stride=new Array(d);for(var i=d-1,sz=1;i>=0;--i){stride[i]=sz;sz*=shape[i]}}if(offset===undefined){offset=0;for(var i=0;i<d;++i){if(stride[i]<0){offset-=(shape[i]-1)*stride[i]}}}var dtype=arrayDType(data);var ctor_list=CACHED_CONSTRUCTORS[dtype];while(ctor_list.length<=d+1){ctor_list.push(compileConstructor(dtype,ctor_list.length-1))}var ctor=ctor_list[d+1];return ctor(data,shape,stride,offset)}module.exports=wrappedNDArrayCtor}).call(this,require("buffer").Buffer)},{buffer:11,"iota-array":70}],70:[function(require,module,exports){"use strict";function iota(n){var result=new Array(n);for(var i=0;i<n;++i){result[i]=i}return result}module.exports=iota},{}],71:[function(require,module,exports){module.exports=require(6)},{"./static/css":73,"./static/html":74,FWaASH:21,events:14,hyperglue:72,inherits:39}],72:[function(require,module,exports){module.exports=require(7)
},{}],73:[function(require,module,exports){module.exports=require(8)},{}],74:[function(require,module,exports){module.exports=require(9)},{}],75:[function(require,module,exports){(function(process,Buffer){var url=require("url");var http=require("http");var https=require("https");var through=require("through");var duplexer=require("duplexer");module.exports=hyperquest;function bind(obj,fn){var args=Array.prototype.slice.call(arguments,2);return function(){var argv=args.concat(Array.prototype.slice.call(arguments));return fn.apply(obj,argv)}}function hyperquest(uri,opts,cb,extra){if(typeof uri==="object"){cb=opts;opts=uri;uri=undefined}if(typeof opts==="function"){cb=opts;opts=undefined}if(!opts)opts={};if(uri!==undefined)opts.uri=uri;if(extra)opts.method=extra.method;var req=new Req(opts);var ws=req.duplex&&through();if(ws)ws.pause();var rs=through();var dup=req.duplex?duplexer(ws,rs):rs;if(!req.duplex){rs.writable=false}dup.request=req;dup.setHeader=bind(req,req.setHeader);dup.setLocation=bind(req,req.setLocation);var closed=false;dup.on("close",function(){closed=true});process.nextTick(function(){if(closed)return;dup.on("close",function(){r.destroy()});var r=req._send();r.on("error",bind(dup,dup.emit,"error"));r.on("response",function(res){dup.response=res;dup.emit("response",res);if(req.duplex)res.pipe(rs);else{res.on("data",function(buf){rs.queue(buf)});res.on("end",function(){rs.queue(null)})}});if(req.duplex){ws.pipe(r);ws.resume()}else r.end()});if(cb){dup.on("error",cb);dup.on("response",bind(dup,cb,null))}return dup}hyperquest.get=hyperquest;hyperquest.post=function(uri,opts,cb){return hyperquest(uri,opts,cb,{method:"POST"})};hyperquest.put=function(uri,opts,cb){return hyperquest(uri,opts,cb,{method:"PUT"})};hyperquest["delete"]=function(uri,opts,cb){return hyperquest(uri,opts,cb,{method:"DELETE"})};function Req(opts){this.headers=opts.headers||{};var method=(opts.method||"GET").toUpperCase();this.method=method;this.duplex=!(method==="GET"||method==="DELETE"||method==="HEAD");this.auth=opts.auth;this.options=opts;if(opts.uri)this.setLocation(opts.uri)}Req.prototype._send=function(){this._sent=true;var headers=this.headers||{};var u=url.parse(this.uri);var au=u.auth||this.auth;if(au){headers.authorization="Basic "+Buffer(au).toString("base64")}var protocol=u.protocol||"";var iface=protocol==="https:"?https:http;var opts={scheme:protocol.replace(/:$/,""),method:this.method,host:u.hostname,port:Number(u.port)||(protocol==="https:"?443:80),path:u.path,agent:false,headers:headers,withCredentials:this.options.withCredentials};if(protocol==="https:"){opts.pfx=this.options.pfx;opts.key=this.options.key;opts.cert=this.options.cert;opts.ca=this.options.ca;opts.ciphers=this.options.ciphers;opts.rejectUnauthorized=this.options.rejectUnauthorized;opts.secureProtocol=this.options.secureProtocol}var req=iface.request(opts);if(req.setTimeout)req.setTimeout(Math.pow(2,32)*1e3);return req};Req.prototype.setHeader=function(key,value){if(this._sent)throw new Error("request already sent");this.headers[key]=value;return this};Req.prototype.setLocation=function(uri){this.uri=uri;return this}}).call(this,require("FWaASH"),require("buffer").Buffer)},{FWaASH:21,buffer:11,duplexer:76,http:15,https:19,through:77,url:34}],76:[function(require,module,exports){var Stream=require("stream");var writeMethods=["write","end","destroy"];var readMethods=["resume","pause"];var readEvents=["data","close"];var slice=Array.prototype.slice;module.exports=duplex;function forEach(arr,fn){if(arr.forEach){return arr.forEach(fn)}for(var i=0;i<arr.length;i++){fn(arr[i],i)}}function duplex(writer,reader){var stream=new Stream;var ended=false;forEach(writeMethods,proxyWriter);forEach(readMethods,proxyReader);forEach(readEvents,proxyStream);reader.on("end",handleEnd);writer.on("drain",function(){stream.emit("drain")});writer.on("error",reemit);reader.on("error",reemit);stream.writable=writer.writable;stream.readable=reader.readable;return stream;function proxyWriter(methodName){stream[methodName]=method;function method(){return writer[methodName].apply(writer,arguments)}}function proxyReader(methodName){stream[methodName]=method;function method(){stream.emit(methodName);var func=reader[methodName];if(func){return func.apply(reader,arguments)}reader.emit(methodName)}}function proxyStream(methodName){reader.on(methodName,reemit);function reemit(){var args=slice.call(arguments);args.unshift(methodName);stream.emit.apply(stream,args)}}function handleEnd(){if(ended){return}ended=true;var args=slice.call(arguments);args.unshift("end");stream.emit.apply(stream,args)}function reemit(err){stream.emit("error",err)}}},{stream:27}],77:[function(require,module,exports){(function(process){var Stream=require("stream");exports=module.exports=through;through.through=through;function through(write,end){write=write||function(data){this.queue(data)};end=end||function(){this.queue(null)};var ended=false,destroyed=false,buffer=[];var stream=new Stream;stream.readable=stream.writable=true;stream.paused=false;stream.write=function(data){write.call(this,data);return!stream.paused};function drain(){while(buffer.length&&!stream.paused){var data=buffer.shift();if(null===data)return stream.emit("end");else stream.emit("data",data)}}stream.queue=stream.push=function(data){buffer.push(data);drain();return stream};stream.on("end",function(){stream.readable=false;if(!stream.writable)process.nextTick(function(){stream.destroy()})});function _end(){stream.writable=false;end.call(stream);if(!stream.readable)stream.destroy()}stream.end=function(data){if(ended)return;ended=true;if(arguments.length)stream.write(data);_end();return stream};stream.destroy=function(){if(destroyed)return;destroyed=true;ended=true;buffer.length=0;stream.writable=stream.readable=false;stream.emit("close");return stream};stream.pause=function(){if(stream.paused)return;stream.paused=true;stream.emit("pause");return stream};stream.resume=function(){if(stream.paused){stream.paused=false}drain();if(!stream.paused)stream.emit("drain");return stream};return stream}}).call(this,require("FWaASH"))},{FWaASH:21,stream:27}],78:[function(require,module,exports){var has={}.hasOwnProperty;exports=module.exports=function(searchInput){if(searchInput&&"object"===typeof searchInput){var hasKeyCode=searchInput.which||searchInput.keyCode||searchInput.charCode;if(hasKeyCode)searchInput=hasKeyCode}if("number"===typeof searchInput)return names[searchInput];var search=String(searchInput);var foundNamedKey=codes[search.toLowerCase()];if(foundNamedKey)return foundNamedKey;var foundNamedKey=aliases[search.toLowerCase()];if(foundNamedKey)return foundNamedKey;if(search.length===1)return search.charCodeAt(0);return undefined};var codes=exports.code=exports.codes={backspace:8,tab:9,enter:13,shift:16,ctrl:17,alt:18,"pause/break":19,"caps lock":20,esc:27,space:32,"page up":33,"page down":34,end:35,home:36,left:37,up:38,right:39,down:40,insert:45,"delete":46,windows:91,"right click":93,"numpad *":106,"numpad +":107,"numpad -":109,"numpad .":110,"numpad /":111,"num lock":144,"scroll lock":145,"my computer":182,"my calculator":183,";":186,"=":187,",":188,"-":189,".":190,"/":191,"`":192,"[":219,"\\":220,"]":221,"'":222};var aliases=exports.aliases={ctl:17,pause:19,"break":19,caps:20,escape:27,pgup:33,pgdn:33,ins:45,del:46,spc:32};for(i=97;i<123;i++)codes[String.fromCharCode(i)]=i-32;for(var i=48;i<58;i++)codes[i-48]=i;for(i=1;i<13;i++)codes["f"+i]=i+111;for(i=0;i<10;i++)codes["numpad "+i]=i+96;var names=exports.names=exports.title={};for(i in codes)names[codes[i]]=i;for(var alias in aliases){codes[alias]=aliases[alias]}},{}],79:[function(require,module,exports){(function(){function bind1(a,b){a(b());b(a)}function bind2(a,b){b(a());a(b);b(a)}function isGet(val){return undefined===val}function isSet(val){return"function"!==typeof val}function isFunction(fun){return"function"===typeof fun}function assertObservable(observable){if(!isFunction(observable))throw new Error("transform expects an observable");return observable}function all(ary,val){for(var k in ary)ary[k](val)}function remove(ary,item){delete ary[ary.indexOf(item)]}function on(emitter,event,listener){(emitter.on||emitter.addEventListener).call(emitter,event,listener,false)}function off(emitter,event,listener){(emitter.removeListener||emitter.removeEventListener||emitter.off).call(emitter,event,listener,false)}function value(initialValue){var _val=initialValue,listeners=[];observable.set=function(val){all(listeners,_val=val)};return observable;function observable(val){return isGet(val)?_val:isSet(val)?all(listeners,_val=val):(listeners.push(val),val(_val),function(){remove(listeners,val)})}}function property(model,key){return function(val){return isGet(val)?model.get(key):isSet(val)?model.set(key,val):(on(model,"change:"+key,val),val(model.get(key)),function(){off(model,"change:"+key,val)})}}function transform(observable,down,up){assertObservable(observable);return function(val){return isGet(val)?down(observable()):isSet(val)?observable((up||down)(val)):observable(function(_val){val(down(_val))})}}function not(observable){return transform(observable,function(v){return!v})}function listen(element,event,attr,listener){function onEvent(){listener(isFunction(attr)?attr():element[attr])}on(element,event,onEvent);onEvent();return function(){off(element,event,onEvent)}}function attribute(element,attr,event){attr=attr||"value";event=event||"input";return function(val){return isGet(val)?element[attr]:isSet(val)?element[attr]=val:listen(element,event,attr,val)}}function select(element){function _attr(){return element[element.selectedIndex].value}function _set(val){for(var i=0;i<element.options.length;i++){if(element.options[i].value==val)element.selectedIndex=i}}return function(val){return isGet(val)?element.options[element.selectedIndex].value:isSet(val)?_set(val):listen(element,"change",_attr,val)}}function toggle(el,up,down){var i=false;return function(val){function onUp(){i||val(i=true)}function onDown(){i&&val(i=false)}return isGet(val)?i:isSet(val)?undefined:(on(el,up,onUp),on(el,down||up,onDown),val(i),function(){off(el,up,onUp);off(el,down||up,onDown)})}}function error(message){throw new Error(message)}function compute(observables,compute){var cur=observables.map(function(e){return e()}),init=true;var v=value();observables.forEach(function(f,i){f(function(val){cur[i]=val;if(init)return;v(compute.apply(null,cur))})});v(compute.apply(null,cur));init=false;v(function(){compute.apply(null,cur)});return v}function boolean(observable,truthy,falsey){return transform(observable,function(val){return val?truthy:falsey},function(val){return val==truthy?true:false})}function signal(){var _val,listeners=[];return function(val){return isGet(val)?_val:isSet(val)?!(_val===val)?all(listeners,_val=val):"":(listeners.push(val),val(_val),function(){remove(listeners,val)})}}var exports=value;exports.bind1=bind1;exports.bind2=bind2;exports.value=value;exports.not=not;exports.property=property;exports.input=exports.attribute=attribute;exports.select=select;exports.compute=compute;exports.transform=transform;exports.boolean=boolean;exports.toggle=toggle;exports.hover=function(e){return toggle(e,"mouseover","mouseout")};exports.focus=function(e){return toggle(e,"focus","blur")};exports.signal=signal;if("object"===typeof module)module.exports=exports;else this.observable=exports})()},{}],80:[function(require,module,exports){var Stream=require("stream");var sockjs=require("sockjs-client");var resolve=require("url").resolve;var parse=require("url").parse;module.exports=function(u,cb){var uri=parse(u).protocol?u:resolve(window.location.href,u);var stream=new Stream;stream.readable=true;stream.writable=true;var ready=false;var buffer=[];var sock=sockjs(uri);stream.sock=sock;stream.write=function(msg){if(!ready||buffer.length)buffer.push(msg);else sock.send(msg)};stream.end=function(msg){if(msg!==undefined)stream.write(msg);if(!ready){stream._ended=true;return}stream.writable=false;sock.close()};stream.destroy=function(){stream._ended=true;stream.writable=stream.readable=false;buffer.length=0;sock.close()};sock.onopen=function(){if(typeof cb==="function")cb();ready=true;for(var i=0;i<buffer.length;i++){sock.send(buffer[i])}buffer=[];stream.emit("connect");if(stream._ended)stream.end()};sock.onmessage=function(e){stream.emit("data",e.data)};sock.onclose=function(){stream.emit("end");stream.writable=false;stream.readable=false};return stream}},{"sockjs-client":81,stream:27,url:34}],81:[function(require,module,exports){var JSON;JSON||(JSON={}),function(){function str(a,b){var c,d,e,f,g=gap,h,i=b[a];i&&typeof i=="object"&&typeof i.toJSON=="function"&&(i=i.toJSON(a)),typeof rep=="function"&&(i=rep.call(b,a,i));switch(typeof i){case"string":return quote(i);case"number":return isFinite(i)?String(i):"null";case"boolean":case"null":return String(i);case"object":if(!i)return"null";gap+=indent,h=[];if(Object.prototype.toString.apply(i)==="[object Array]"){f=i.length;for(c=0;c<f;c+=1)h[c]=str(c,i)||"null";e=h.length===0?"[]":gap?"[\n"+gap+h.join(",\n"+gap)+"\n"+g+"]":"["+h.join(",")+"]",gap=g;return e}if(rep&&typeof rep=="object"){f=rep.length;for(c=0;c<f;c+=1)typeof rep[c]=="string"&&(d=rep[c],e=str(d,i),e&&h.push(quote(d)+(gap?": ":":")+e))}else for(d in i)Object.prototype.hasOwnProperty.call(i,d)&&(e=str(d,i),e&&h.push(quote(d)+(gap?": ":":")+e));e=h.length===0?"{}":gap?"{\n"+gap+h.join(",\n"+gap)+"\n"+g+"}":"{"+h.join(",")+"}",gap=g;return e}}function quote(a){escapable.lastIndex=0;return escapable.test(a)?'"'+a.replace(escapable,function(a){var b=meta[a];return typeof b=="string"?b:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+a+'"'}function f(a){return a<10?"0"+a:a}"use strict",typeof Date.prototype.toJSON!="function"&&(Date.prototype.toJSON=function(a){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z":null},String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(a){return this.valueOf()});var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={"\b":"\\b","	":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},rep;typeof JSON.stringify!="function"&&(JSON.stringify=function(a,b,c){var d;gap="",indent="";if(typeof c=="number")for(d=0;d<c;d+=1)indent+=" ";else typeof c=="string"&&(indent=c);rep=b;if(!b||typeof b=="function"||typeof b=="object"&&typeof b.length=="number")return str("",{"":a});throw new Error("JSON.stringify")}),typeof JSON.parse!="function"&&(JSON.parse=function(text,reviver){function walk(a,b){var c,d,e=a[b];if(e&&typeof e=="object")for(c in e)Object.prototype.hasOwnProperty.call(e,c)&&(d=walk(e,c),d!==undefined?e[c]=d:delete e[c]);return reviver.call(a,b,e)}var j;text=String(text),cx.lastIndex=0,cx.test(text)&&(text=text.replace(cx,function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)}));if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,""))){j=eval("("+text+")");return typeof reviver=="function"?walk({"":j},""):j}throw new SyntaxError("JSON.parse")})}();var SockJS=function(){var _document=document;var _window=window;var utils={};var REventTarget=function(){};REventTarget.prototype.addEventListener=function(eventType,listener){if(!this._listeners){this._listeners={}}if(!(eventType in this._listeners)){this._listeners[eventType]=[]}var arr=this._listeners[eventType];if(utils.arrIndexOf(arr,listener)===-1){arr.push(listener)}return};REventTarget.prototype.removeEventListener=function(eventType,listener){if(!(this._listeners&&eventType in this._listeners)){return}var arr=this._listeners[eventType];var idx=utils.arrIndexOf(arr,listener);if(idx!==-1){if(arr.length>1){this._listeners[eventType]=arr.slice(0,idx).concat(arr.slice(idx+1))}else{delete this._listeners[eventType]}return}return};REventTarget.prototype.dispatchEvent=function(event){var t=event.type;var args=Array.prototype.slice.call(arguments,0);if(this["on"+t]){this["on"+t].apply(this,args)}if(this._listeners&&t in this._listeners){for(var i=0;i<this._listeners[t].length;i++){this._listeners[t][i].apply(this,args)}}};var SimpleEvent=function(type,obj){this.type=type;if(typeof obj!=="undefined"){for(var k in obj){if(!obj.hasOwnProperty(k))continue;this[k]=obj[k]}}};SimpleEvent.prototype.toString=function(){var r=[];for(var k in this){if(!this.hasOwnProperty(k))continue;var v=this[k];if(typeof v==="function")v="[function]";r.push(k+"="+v)}return"SimpleEvent("+r.join(", ")+")"};var EventEmitter=function(events){this.events=events||[]};EventEmitter.prototype.emit=function(type){var that=this;var args=Array.prototype.slice.call(arguments,1);if(!that.nuked&&that["on"+type]){that["on"+type].apply(that,args)}if(utils.arrIndexOf(that.events,type)===-1){utils.log("Event "+JSON.stringify(type)+" not listed "+JSON.stringify(that.events)+" in "+that)}};EventEmitter.prototype.nuke=function(type){var that=this;that.nuked=true;for(var i=0;i<that.events.length;i++){delete that[that.events[i]]}};var random_string_chars="abcdefghijklmnopqrstuvwxyz0123456789_";utils.random_string=function(length,max){max=max||random_string_chars.length;var i,ret=[];for(i=0;i<length;i++){ret.push(random_string_chars.substr(Math.floor(Math.random()*max),1))}return ret.join("")};utils.random_number=function(max){return Math.floor(Math.random()*max)};utils.random_number_string=function(max){var t=(""+(max-1)).length;var p=Array(t+1).join("0");return(p+utils.random_number(max)).slice(-t)};utils.getOrigin=function(url){url+="/";var parts=url.split("/").slice(0,3);return parts.join("/")};utils.isSameOriginUrl=function(url_a,url_b){if(!url_b)url_b=_window.location.href;return url_a.split("/").slice(0,3).join("/")===url_b.split("/").slice(0,3).join("/")};utils.getParentDomain=function(url){if(/^[0-9.]*$/.test(url))return url;if(/^\[/.test(url))return url;if(!/[.]/.test(url))return url;var parts=url.split(".").slice(1);return parts.join(".")};utils.objectExtend=function(dst,src){for(var k in src){if(src.hasOwnProperty(k)){dst[k]=src[k]}}return dst};var WPrefix="_jp";utils.polluteGlobalNamespace=function(){if(!(WPrefix in _window)){_window[WPrefix]={}}};utils.closeFrame=function(code,reason){return"c"+JSON.stringify([code,reason])};utils.userSetCode=function(code){return code===1e3||code>=3e3&&code<=4999};utils.countRTO=function(rtt){var rto;if(rtt>100){rto=3*rtt}else{rto=rtt+200}return rto};utils.log=function(){if(_window.console&&console.log&&console.log.apply){console.log.apply(console,arguments)}};utils.bind=function(fun,that){if(fun.bind){return fun.bind(that)}else{return function(){return fun.apply(that,arguments)}}};utils.flatUrl=function(url){return url.indexOf("?")===-1&&url.indexOf("#")===-1};utils.amendUrl=function(url){var dl=_document.location;if(!url){throw new Error("Wrong url for SockJS")}if(!utils.flatUrl(url)){throw new Error("Only basic urls are supported in SockJS")}if(url.indexOf("//")===0){url=dl.protocol+url}if(url.indexOf("/")===0){url=dl.protocol+"//"+dl.host+url}url=url.replace(/[/]+$/,"");return url};utils.arrIndexOf=function(arr,obj){for(var i=0;i<arr.length;i++){if(arr[i]===obj){return i}}return-1};utils.arrSkip=function(arr,obj){var idx=utils.arrIndexOf(arr,obj);if(idx===-1){return arr.slice()}else{var dst=arr.slice(0,idx);return dst.concat(arr.slice(idx+1))}};utils.isArray=Array.isArray||function(value){return{}.toString.call(value).indexOf("Array")>=0};utils.delay=function(t,fun){if(typeof t==="function"){fun=t;t=0}return setTimeout(fun,t)};var json_escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,json_lookup={"\x00":"\\u0000","":"\\u0001","":"\\u0002","":"\\u0003","":"\\u0004","":"\\u0005","":"\\u0006","":"\\u0007","\b":"\\b","	":"\\t","\n":"\\n","":"\\u000b","\f":"\\f","\r":"\\r","":"\\u000e","":"\\u000f","":"\\u0010","":"\\u0011","":"\\u0012","":"\\u0013","":"\\u0014","":"\\u0015","":"\\u0016","":"\\u0017","":"\\u0018","":"\\u0019","":"\\u001a","":"\\u001b","":"\\u001c","":"\\u001d","":"\\u001e","":"\\u001f",'"':'\\"',"\\":"\\\\","":"\\u007f","":"\\u0080","":"\\u0081","":"\\u0082","":"\\u0083","":"\\u0084","":"\\u0085","":"\\u0086","":"\\u0087","":"\\u0088","":"\\u0089","":"\\u008a","":"\\u008b","":"\\u008c","":"\\u008d","":"\\u008e","":"\\u008f","":"\\u0090","":"\\u0091","":"\\u0092","":"\\u0093","":"\\u0094","":"\\u0095","":"\\u0096","":"\\u0097","":"\\u0098","":"\\u0099","":"\\u009a","":"\\u009b","":"\\u009c","":"\\u009d","":"\\u009e","":"\\u009f","­":"\\u00ad","؀":"\\u0600","؁":"\\u0601","؂":"\\u0602","؃":"\\u0603","؄":"\\u0604","܏":"\\u070f","឴":"\\u17b4","឵":"\\u17b5","‌":"\\u200c","‍":"\\u200d","‎":"\\u200e","‏":"\\u200f","\u2028":"\\u2028","\u2029":"\\u2029","‪":"\\u202a","‫":"\\u202b","‬":"\\u202c","‭":"\\u202d","‮":"\\u202e"," ":"\\u202f","⁠":"\\u2060","⁡":"\\u2061","⁢":"\\u2062","⁣":"\\u2063","⁤":"\\u2064","⁥":"\\u2065","⁦":"\\u2066","⁧":"\\u2067","⁨":"\\u2068","⁩":"\\u2069","⁪":"\\u206a","⁫":"\\u206b","⁬":"\\u206c","⁭":"\\u206d","⁮":"\\u206e","⁯":"\\u206f","﻿":"\\ufeff","￰":"\\ufff0","￱":"\\ufff1","￲":"\\ufff2","￳":"\\ufff3","￴":"\\ufff4","￵":"\\ufff5","￶":"\\ufff6","￷":"\\ufff7","￸":"\\ufff8","￹":"\\ufff9","￺":"\\ufffa","￻":"\\ufffb","￼":"\\ufffc","�":"\\ufffd","":"\\ufffe","":"\\uffff"};var extra_escapable=/[\x00-\x1f\ud800-\udfff\ufffe\uffff\u0300-\u0333\u033d-\u0346\u034a-\u034c\u0350-\u0352\u0357-\u0358\u035c-\u0362\u0374\u037e\u0387\u0591-\u05af\u05c4\u0610-\u0617\u0653-\u0654\u0657-\u065b\u065d-\u065e\u06df-\u06e2\u06eb-\u06ec\u0730\u0732-\u0733\u0735-\u0736\u073a\u073d\u073f-\u0741\u0743\u0745\u0747\u07eb-\u07f1\u0951\u0958-\u095f\u09dc-\u09dd\u09df\u0a33\u0a36\u0a59-\u0a5b\u0a5e\u0b5c-\u0b5d\u0e38-\u0e39\u0f43\u0f4d\u0f52\u0f57\u0f5c\u0f69\u0f72-\u0f76\u0f78\u0f80-\u0f83\u0f93\u0f9d\u0fa2\u0fa7\u0fac\u0fb9\u1939-\u193a\u1a17\u1b6b\u1cda-\u1cdb\u1dc0-\u1dcf\u1dfc\u1dfe\u1f71\u1f73\u1f75\u1f77\u1f79\u1f7b\u1f7d\u1fbb\u1fbe\u1fc9\u1fcb\u1fd3\u1fdb\u1fe3\u1feb\u1fee-\u1fef\u1ff9\u1ffb\u1ffd\u2000-\u2001\u20d0-\u20d1\u20d4-\u20d7\u20e7-\u20e9\u2126\u212a-\u212b\u2329-\u232a\u2adc\u302b-\u302c\uaab2-\uaab3\uf900-\ufa0d\ufa10\ufa12\ufa15-\ufa1e\ufa20\ufa22\ufa25-\ufa26\ufa2a-\ufa2d\ufa30-\ufa6d\ufa70-\ufad9\ufb1d\ufb1f\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40-\ufb41\ufb43-\ufb44\ufb46-\ufb4e\ufff0-\uffff]/g,extra_lookup;var JSONQuote=JSON&&JSON.stringify||function(string){json_escapable.lastIndex=0;if(json_escapable.test(string)){string=string.replace(json_escapable,function(a){return json_lookup[a]})}return'"'+string+'"'};var unroll_lookup=function(escapable){var i;var unrolled={};var c=[];for(i=0;i<65536;i++){c.push(String.fromCharCode(i))}escapable.lastIndex=0;c.join("").replace(escapable,function(a){unrolled[a]="\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4);return""});escapable.lastIndex=0;return unrolled};utils.quote=function(string){var quoted=JSONQuote(string);extra_escapable.lastIndex=0;if(!extra_escapable.test(quoted)){return quoted}if(!extra_lookup)extra_lookup=unroll_lookup(extra_escapable);return quoted.replace(extra_escapable,function(a){return extra_lookup[a]})};var _all_protocols=["websocket","xdr-streaming","xhr-streaming","iframe-eventsource","iframe-htmlfile","xdr-polling","xhr-polling","iframe-xhr-polling","jsonp-polling"];utils.probeProtocols=function(){var probed={};for(var i=0;i<_all_protocols.length;i++){var protocol=_all_protocols[i];probed[protocol]=SockJS[protocol]&&SockJS[protocol].enabled()}return probed};utils.detectProtocols=function(probed,protocols_whitelist,info){var pe={},protocols=[];if(!protocols_whitelist)protocols_whitelist=_all_protocols;for(var i=0;i<protocols_whitelist.length;i++){var protocol=protocols_whitelist[i];pe[protocol]=probed[protocol]}var maybe_push=function(protos){var proto=protos.shift();if(pe[proto]){protocols.push(proto)}else{if(protos.length>0){maybe_push(protos)}}};if(info.websocket!==false){maybe_push(["websocket"])}if(pe["xhr-streaming"]&&!info.null_origin){protocols.push("xhr-streaming")}else{if(pe["xdr-streaming"]&&!info.cookie_needed&&!info.null_origin){protocols.push("xdr-streaming")}else{maybe_push(["iframe-eventsource","iframe-htmlfile"])}}if(pe["xhr-polling"]&&!info.null_origin){protocols.push("xhr-polling")}else{if(pe["xdr-polling"]&&!info.cookie_needed&&!info.null_origin){protocols.push("xdr-polling")}else{maybe_push(["iframe-xhr-polling","jsonp-polling"])}}return protocols};var MPrefix="_sockjs_global";utils.createHook=function(){var window_id="a"+utils.random_string(8);if(!(MPrefix in _window)){var map={};_window[MPrefix]=function(window_id){if(!(window_id in map)){map[window_id]={id:window_id,del:function(){delete map[window_id]}}}return map[window_id]}}return _window[MPrefix](window_id)};utils.attachMessage=function(listener){utils.attachEvent("message",listener)};utils.attachEvent=function(event,listener){if(typeof _window.addEventListener!=="undefined"){_window.addEventListener(event,listener,false)}else{_document.attachEvent("on"+event,listener);_window.attachEvent("on"+event,listener)}};utils.detachMessage=function(listener){utils.detachEvent("message",listener)};utils.detachEvent=function(event,listener){if(typeof _window.addEventListener!=="undefined"){_window.removeEventListener(event,listener,false)}else{_document.detachEvent("on"+event,listener);_window.detachEvent("on"+event,listener)}};var on_unload={};var after_unload=false;var trigger_unload_callbacks=function(){for(var ref in on_unload){on_unload[ref]();delete on_unload[ref]}};var unload_triggered=function(){if(after_unload)return;after_unload=true;trigger_unload_callbacks()};utils.attachEvent("beforeunload",unload_triggered);utils.attachEvent("unload",unload_triggered);utils.unload_add=function(listener){var ref=utils.random_string(8);on_unload[ref]=listener;if(after_unload){utils.delay(trigger_unload_callbacks)}return ref};utils.unload_del=function(ref){if(ref in on_unload)delete on_unload[ref]};utils.createIframe=function(iframe_url,error_callback){var iframe=_document.createElement("iframe");var tref,unload_ref;var unattach=function(){clearTimeout(tref);try{iframe.onload=null}catch(x){}iframe.onerror=null};var cleanup=function(){if(iframe){unattach();setTimeout(function(){if(iframe){iframe.parentNode.removeChild(iframe)}iframe=null},0);utils.unload_del(unload_ref)}};var onerror=function(r){if(iframe){cleanup();error_callback(r)}};var post=function(msg,origin){try{if(iframe&&iframe.contentWindow){iframe.contentWindow.postMessage(msg,origin)}}catch(x){}};iframe.src=iframe_url;iframe.style.display="none";iframe.style.position="absolute";iframe.onerror=function(){onerror("onerror")};iframe.onload=function(){clearTimeout(tref);tref=setTimeout(function(){onerror("onload timeout")},2e3)};_document.body.appendChild(iframe);tref=setTimeout(function(){onerror("timeout")},15e3);unload_ref=utils.unload_add(cleanup);return{post:post,cleanup:cleanup,loaded:unattach}};utils.createHtmlfile=function(iframe_url,error_callback){var doc=new ActiveXObject("htmlfile");var tref,unload_ref;var iframe;var unattach=function(){clearTimeout(tref)};var cleanup=function(){if(doc){unattach();utils.unload_del(unload_ref);iframe.parentNode.removeChild(iframe);iframe=doc=null;CollectGarbage()}};var onerror=function(r){if(doc){cleanup();error_callback(r)}};var post=function(msg,origin){try{if(iframe&&iframe.contentWindow){iframe.contentWindow.postMessage(msg,origin)}}catch(x){}};doc.open();doc.write("<html><s"+"cript>"+'document.domain="'+document.domain+'";'+"</s"+"cript></html>");doc.close();doc.parentWindow[WPrefix]=_window[WPrefix];var c=doc.createElement("div");doc.body.appendChild(c);iframe=doc.createElement("iframe");c.appendChild(iframe);iframe.src=iframe_url;tref=setTimeout(function(){onerror("timeout")},15e3);unload_ref=utils.unload_add(cleanup);return{post:post,cleanup:cleanup,loaded:unattach}};var AbstractXHRObject=function(){};AbstractXHRObject.prototype=new EventEmitter(["chunk","finish"]);AbstractXHRObject.prototype._start=function(method,url,payload,opts){var that=this;try{that.xhr=new XMLHttpRequest}catch(x){}if(!that.xhr){try{that.xhr=new _window.ActiveXObject("Microsoft.XMLHTTP")}catch(x){}}if(_window.ActiveXObject||_window.XDomainRequest){url+=(url.indexOf("?")===-1?"?":"&")+"t="+ +new Date}that.unload_ref=utils.unload_add(function(){that._cleanup(true)});try{that.xhr.open(method,url,true)}catch(e){that.emit("finish",0,"");that._cleanup();return}if(!opts||!opts.no_credentials){that.xhr.withCredentials="true"}if(opts&&opts.headers){for(var key in opts.headers){that.xhr.setRequestHeader(key,opts.headers[key])}}that.xhr.onreadystatechange=function(){if(that.xhr){var x=that.xhr;switch(x.readyState){case 3:try{var status=x.status;var text=x.responseText}catch(x){};if(text&&text.length>0){that.emit("chunk",status,text)}break;case 4:that.emit("finish",x.status,x.responseText);that._cleanup(false);break}}};that.xhr.send(payload)};AbstractXHRObject.prototype._cleanup=function(abort){var that=this;if(!that.xhr)return;utils.unload_del(that.unload_ref);that.xhr.onreadystatechange=function(){};if(abort){try{that.xhr.abort()}catch(x){}}that.unload_ref=that.xhr=null};AbstractXHRObject.prototype.close=function(){var that=this;that.nuke();that._cleanup(true)};var XHRCorsObject=utils.XHRCorsObject=function(){var that=this,args=arguments;utils.delay(function(){that._start.apply(that,args)})};XHRCorsObject.prototype=new AbstractXHRObject;var XHRLocalObject=utils.XHRLocalObject=function(method,url,payload){var that=this;utils.delay(function(){that._start(method,url,payload,{no_credentials:true})})};XHRLocalObject.prototype=new AbstractXHRObject;var XDRObject=utils.XDRObject=function(method,url,payload){var that=this;utils.delay(function(){that._start(method,url,payload)})};XDRObject.prototype=new EventEmitter(["chunk","finish"]);XDRObject.prototype._start=function(method,url,payload){var that=this;var xdr=new XDomainRequest;url+=(url.indexOf("?")===-1?"?":"&")+"t="+ +new Date;var onerror=xdr.ontimeout=xdr.onerror=function(){that.emit("finish",0,"");that._cleanup(false)};xdr.onprogress=function(){that.emit("chunk",200,xdr.responseText)};xdr.onload=function(){that.emit("finish",200,xdr.responseText);that._cleanup(false)};that.xdr=xdr;that.unload_ref=utils.unload_add(function(){that._cleanup(true)});try{that.xdr.open(method,url);that.xdr.send(payload)}catch(x){onerror()}};XDRObject.prototype._cleanup=function(abort){var that=this;if(!that.xdr)return;utils.unload_del(that.unload_ref);that.xdr.ontimeout=that.xdr.onerror=that.xdr.onprogress=that.xdr.onload=null;if(abort){try{that.xdr.abort()}catch(x){}}that.unload_ref=that.xdr=null};XDRObject.prototype.close=function(){var that=this;that.nuke();that._cleanup(true)};utils.isXHRCorsCapable=function(){if(_window.XMLHttpRequest&&"withCredentials"in new XMLHttpRequest){return 1}if(_window.XDomainRequest&&_document.domain){return 2}if(IframeTransport.enabled()){return 3}return 4};var SockJS=function(url,dep_protocols_whitelist,options){if(this===window){return new SockJS(url,dep_protocols_whitelist,options)}var that=this,protocols_whitelist;that._options={devel:false,debug:false,protocols_whitelist:[],info:undefined,rtt:undefined};if(options){utils.objectExtend(that._options,options)}that._base_url=utils.amendUrl(url);that._server=that._options.server||utils.random_number_string(1e3);if(that._options.protocols_whitelist&&that._options.protocols_whitelist.length){protocols_whitelist=that._options.protocols_whitelist}else{if(typeof dep_protocols_whitelist==="string"&&dep_protocols_whitelist.length>0){protocols_whitelist=[dep_protocols_whitelist]
}else if(utils.isArray(dep_protocols_whitelist)){protocols_whitelist=dep_protocols_whitelist}else{protocols_whitelist=null}if(protocols_whitelist){that._debug('Deprecated API: Use "protocols_whitelist" option '+"instead of supplying protocol list as a second "+"parameter to SockJS constructor.")}}that._protocols=[];that.protocol=null;that.readyState=SockJS.CONNECTING;that._ir=createInfoReceiver(that._base_url);that._ir.onfinish=function(info,rtt){that._ir=null;if(info){if(that._options.info){info=utils.objectExtend(info,that._options.info)}if(that._options.rtt){rtt=that._options.rtt}that._applyInfo(info,rtt,protocols_whitelist);that._didClose()}else{that._didClose(1002,"Can't connect to server",true)}}};SockJS.prototype=new REventTarget;SockJS.version="0.3.1.7.ga67f.dirty";SockJS.CONNECTING=0;SockJS.OPEN=1;SockJS.CLOSING=2;SockJS.CLOSED=3;SockJS.prototype._debug=function(){if(this._options.debug)utils.log.apply(utils,arguments)};SockJS.prototype._dispatchOpen=function(){var that=this;if(that.readyState===SockJS.CONNECTING){if(that._transport_tref){clearTimeout(that._transport_tref);that._transport_tref=null}that.readyState=SockJS.OPEN;that.dispatchEvent(new SimpleEvent("open"))}else{that._didClose(1006,"Server lost session")}};SockJS.prototype._dispatchMessage=function(data){var that=this;if(that.readyState!==SockJS.OPEN)return;that.dispatchEvent(new SimpleEvent("message",{data:data}))};SockJS.prototype._dispatchHeartbeat=function(data){var that=this;if(that.readyState!==SockJS.OPEN)return;that.dispatchEvent(new SimpleEvent("heartbeat",{}))};SockJS.prototype._didClose=function(code,reason,force){var that=this;if(that.readyState!==SockJS.CONNECTING&&that.readyState!==SockJS.OPEN&&that.readyState!==SockJS.CLOSING)throw new Error("INVALID_STATE_ERR");if(that._ir){that._ir.nuke();that._ir=null}if(that._transport){that._transport.doCleanup();that._transport=null}var close_event=new SimpleEvent("close",{code:code,reason:reason,wasClean:utils.userSetCode(code)});if(!utils.userSetCode(code)&&that.readyState===SockJS.CONNECTING&&!force){if(that._try_next_protocol(close_event)){return}close_event=new SimpleEvent("close",{code:2e3,reason:"All transports failed",wasClean:false,last_event:close_event})}that.readyState=SockJS.CLOSED;utils.delay(function(){that.dispatchEvent(close_event)})};SockJS.prototype._didMessage=function(data){var that=this;var type=data.slice(0,1);switch(type){case"o":that._dispatchOpen();break;case"a":var payload=JSON.parse(data.slice(1)||"[]");for(var i=0;i<payload.length;i++){that._dispatchMessage(payload[i])}break;case"m":var payload=JSON.parse(data.slice(1)||"null");that._dispatchMessage(payload);break;case"c":var payload=JSON.parse(data.slice(1)||"[]");that._didClose(payload[0],payload[1]);break;case"h":that._dispatchHeartbeat();break}};SockJS.prototype._try_next_protocol=function(close_event){var that=this;if(that.protocol){that._debug("Closed transport:",that.protocol,""+close_event);that.protocol=null}if(that._transport_tref){clearTimeout(that._transport_tref);that._transport_tref=null}while(1){var protocol=that.protocol=that._protocols.shift();if(!protocol){return false}if(SockJS[protocol]&&SockJS[protocol].need_body===true&&(!_document.body||typeof _document.readyState!=="undefined"&&_document.readyState!=="complete")){that._protocols.unshift(protocol);that.protocol="waiting-for-load";utils.attachEvent("load",function(){that._try_next_protocol()});return true}if(!SockJS[protocol]||!SockJS[protocol].enabled(that._options)){that._debug("Skipping transport:",protocol)}else{var roundTrips=SockJS[protocol].roundTrips||1;var to=(that._options.rto||0)*roundTrips||5e3;that._transport_tref=utils.delay(to,function(){if(that.readyState===SockJS.CONNECTING){that._didClose(2007,"Transport timeouted")}});var connid=utils.random_string(8);var trans_url=that._base_url+"/"+that._server+"/"+connid;that._debug("Opening transport:",protocol," url:"+trans_url," RTO:"+that._options.rto);that._transport=new SockJS[protocol](that,trans_url,that._base_url);return true}}};SockJS.prototype.close=function(code,reason){var that=this;if(code&&!utils.userSetCode(code))throw new Error("INVALID_ACCESS_ERR");if(that.readyState!==SockJS.CONNECTING&&that.readyState!==SockJS.OPEN){return false}that.readyState=SockJS.CLOSING;that._didClose(code||1e3,reason||"Normal closure");return true};SockJS.prototype.send=function(data){var that=this;if(that.readyState===SockJS.CONNECTING)throw new Error("INVALID_STATE_ERR");if(that.readyState===SockJS.OPEN){that._transport.doSend(utils.quote(""+data))}return true};SockJS.prototype._applyInfo=function(info,rtt,protocols_whitelist){var that=this;that._options.info=info;that._options.rtt=rtt;that._options.rto=utils.countRTO(rtt);that._options.info.null_origin=!_document.domain;var probed=utils.probeProtocols();that._protocols=utils.detectProtocols(probed,protocols_whitelist,info)};var WebSocketTransport=SockJS.websocket=function(ri,trans_url){var that=this;var url=trans_url+"/websocket";if(url.slice(0,5)==="https"){url="wss"+url.slice(5)}else{url="ws"+url.slice(4)}that.ri=ri;that.url=url;var Constructor=_window.WebSocket||_window.MozWebSocket;that.ws=new Constructor(that.url);that.ws.onmessage=function(e){that.ri._didMessage(e.data)};that.unload_ref=utils.unload_add(function(){that.ws.close()});that.ws.onclose=function(){that.ri._didMessage(utils.closeFrame(1006,"WebSocket connection broken"))}};WebSocketTransport.prototype.doSend=function(data){this.ws.send("["+data+"]")};WebSocketTransport.prototype.doCleanup=function(){var that=this;var ws=that.ws;if(ws){ws.onmessage=ws.onclose=null;ws.close();utils.unload_del(that.unload_ref);that.unload_ref=that.ri=that.ws=null}};WebSocketTransport.enabled=function(){return!!(_window.WebSocket||_window.MozWebSocket)};WebSocketTransport.roundTrips=2;var BufferedSender=function(){};BufferedSender.prototype.send_constructor=function(sender){var that=this;that.send_buffer=[];that.sender=sender};BufferedSender.prototype.doSend=function(message){var that=this;that.send_buffer.push(message);if(!that.send_stop){that.send_schedule()}};BufferedSender.prototype.send_schedule_wait=function(){var that=this;var tref;that.send_stop=function(){that.send_stop=null;clearTimeout(tref)};tref=utils.delay(25,function(){that.send_stop=null;that.send_schedule()})};BufferedSender.prototype.send_schedule=function(){var that=this;if(that.send_buffer.length>0){var payload="["+that.send_buffer.join(",")+"]";that.send_stop=that.sender(that.trans_url,payload,function(){that.send_stop=null;that.send_schedule_wait()});that.send_buffer=[]}};BufferedSender.prototype.send_destructor=function(){var that=this;if(that._send_stop){that._send_stop()}that._send_stop=null};var jsonPGenericSender=function(url,payload,callback){var that=this;if(!("_send_form"in that)){var form=that._send_form=_document.createElement("form");var area=that._send_area=_document.createElement("textarea");area.name="d";form.style.display="none";form.style.position="absolute";form.method="POST";form.enctype="application/x-www-form-urlencoded";form.acceptCharset="UTF-8";form.appendChild(area);_document.body.appendChild(form)}var form=that._send_form;var area=that._send_area;var id="a"+utils.random_string(8);form.target=id;form.action=url+"/jsonp_send?i="+id;var iframe;try{iframe=_document.createElement('<iframe name="'+id+'">')}catch(x){iframe=_document.createElement("iframe");iframe.name=id}iframe.id=id;form.appendChild(iframe);iframe.style.display="none";try{area.value=payload}catch(e){utils.log("Your browser is seriously broken. Go home! "+e.message)}form.submit();var completed=function(e){if(!iframe.onerror)return;iframe.onreadystatechange=iframe.onerror=iframe.onload=null;utils.delay(500,function(){iframe.parentNode.removeChild(iframe);iframe=null});area.value="";callback()};iframe.onerror=iframe.onload=completed;iframe.onreadystatechange=function(e){if(iframe.readyState=="complete")completed()};return completed};var createAjaxSender=function(AjaxObject){return function(url,payload,callback){var xo=new AjaxObject("POST",url+"/xhr_send",payload);xo.onfinish=function(status,text){callback(status)};return function(abort_reason){callback(0,abort_reason)}}};var jsonPGenericReceiver=function(url,callback){var tref;var script=_document.createElement("script");var script2;var close_script=function(frame){if(script2){script2.parentNode.removeChild(script2);script2=null}if(script){clearTimeout(tref);script.parentNode.removeChild(script);script.onreadystatechange=script.onerror=script.onload=script.onclick=null;script=null;callback(frame);callback=null}};var loaded_okay=false;var error_timer=null;script.id="a"+utils.random_string(8);script.src=url;script.type="text/javascript";script.charset="UTF-8";script.onerror=function(e){if(!error_timer){error_timer=setTimeout(function(){if(!loaded_okay){close_script(utils.closeFrame(1006,"JSONP script loaded abnormally (onerror)"))}},1e3)}};script.onload=function(e){close_script(utils.closeFrame(1006,"JSONP script loaded abnormally (onload)"))};script.onreadystatechange=function(e){if(/loaded|closed/.test(script.readyState)){if(script&&script.htmlFor&&script.onclick){loaded_okay=true;try{script.onclick()}catch(x){}}if(script){close_script(utils.closeFrame(1006,"JSONP script loaded abnormally (onreadystatechange)"))}}};if(typeof script.async==="undefined"&&_document.attachEvent){if(!/opera/i.test(navigator.userAgent)){try{script.htmlFor=script.id;script.event="onclick"}catch(x){}script.async=true}else{script2=_document.createElement("script");script2.text="try{var a = document.getElementById('"+script.id+"'); if(a)a.onerror();}catch(x){};";script.async=script2.async=false}}if(typeof script.async!=="undefined"){script.async=true}tref=setTimeout(function(){close_script(utils.closeFrame(1006,"JSONP script loaded abnormally (timeout)"))},35e3);var head=_document.getElementsByTagName("head")[0];head.insertBefore(script,head.firstChild);if(script2){head.insertBefore(script2,head.firstChild)}return close_script};var JsonPTransport=SockJS["jsonp-polling"]=function(ri,trans_url){utils.polluteGlobalNamespace();var that=this;that.ri=ri;that.trans_url=trans_url;that.send_constructor(jsonPGenericSender);that._schedule_recv()};JsonPTransport.prototype=new BufferedSender;JsonPTransport.prototype._schedule_recv=function(){var that=this;var callback=function(data){that._recv_stop=null;if(data){if(!that._is_closing){that.ri._didMessage(data)}}if(!that._is_closing){that._schedule_recv()}};that._recv_stop=jsonPReceiverWrapper(that.trans_url+"/jsonp",jsonPGenericReceiver,callback)};JsonPTransport.enabled=function(){return true};JsonPTransport.need_body=true;JsonPTransport.prototype.doCleanup=function(){var that=this;that._is_closing=true;if(that._recv_stop){that._recv_stop()}that.ri=that._recv_stop=null;that.send_destructor()};var jsonPReceiverWrapper=function(url,constructReceiver,user_callback){var id="a"+utils.random_string(6);var url_id=url+"?c="+escape(WPrefix+"."+id);var callback=function(frame){delete _window[WPrefix][id];user_callback(frame)};var close_script=constructReceiver(url_id,callback);_window[WPrefix][id]=close_script;var stop=function(){if(_window[WPrefix][id]){_window[WPrefix][id](utils.closeFrame(1e3,"JSONP user aborted read"))}};return stop};var AjaxBasedTransport=function(){};AjaxBasedTransport.prototype=new BufferedSender;AjaxBasedTransport.prototype.run=function(ri,trans_url,url_suffix,Receiver,AjaxObject){var that=this;that.ri=ri;that.trans_url=trans_url;that.send_constructor(createAjaxSender(AjaxObject));that.poll=new Polling(ri,Receiver,trans_url+url_suffix,AjaxObject)};AjaxBasedTransport.prototype.doCleanup=function(){var that=this;if(that.poll){that.poll.abort();that.poll=null}};var XhrStreamingTransport=SockJS["xhr-streaming"]=function(ri,trans_url){this.run(ri,trans_url,"/xhr_streaming",XhrReceiver,utils.XHRCorsObject)};XhrStreamingTransport.prototype=new AjaxBasedTransport;XhrStreamingTransport.enabled=function(){return _window.XMLHttpRequest&&"withCredentials"in new XMLHttpRequest&&!/opera/i.test(navigator.userAgent)};XhrStreamingTransport.roundTrips=2;XhrStreamingTransport.need_body=true;var XdrStreamingTransport=SockJS["xdr-streaming"]=function(ri,trans_url){this.run(ri,trans_url,"/xhr_streaming",XhrReceiver,utils.XDRObject)};XdrStreamingTransport.prototype=new AjaxBasedTransport;XdrStreamingTransport.enabled=function(){return!!_window.XDomainRequest};XdrStreamingTransport.roundTrips=2;var XhrPollingTransport=SockJS["xhr-polling"]=function(ri,trans_url){this.run(ri,trans_url,"/xhr",XhrReceiver,utils.XHRCorsObject)};XhrPollingTransport.prototype=new AjaxBasedTransport;XhrPollingTransport.enabled=XhrStreamingTransport.enabled;XhrPollingTransport.roundTrips=2;var XdrPollingTransport=SockJS["xdr-polling"]=function(ri,trans_url){this.run(ri,trans_url,"/xhr",XhrReceiver,utils.XDRObject)};XdrPollingTransport.prototype=new AjaxBasedTransport;XdrPollingTransport.enabled=XdrStreamingTransport.enabled;XdrPollingTransport.roundTrips=2;var IframeTransport=function(){};IframeTransport.prototype.i_constructor=function(ri,trans_url,base_url){var that=this;that.ri=ri;that.origin=utils.getOrigin(base_url);that.base_url=base_url;that.trans_url=trans_url;var iframe_url=base_url+"/iframe.html";if(that.ri._options.devel){iframe_url+="?t="+ +new Date}that.window_id=utils.random_string(8);iframe_url+="#"+that.window_id;that.iframeObj=utils.createIframe(iframe_url,function(r){that.ri._didClose(1006,"Unable to load an iframe ("+r+")")});that.onmessage_cb=utils.bind(that.onmessage,that);utils.attachMessage(that.onmessage_cb)};IframeTransport.prototype.doCleanup=function(){var that=this;if(that.iframeObj){utils.detachMessage(that.onmessage_cb);try{if(that.iframeObj.iframe.contentWindow){that.postMessage("c")}}catch(x){}that.iframeObj.cleanup();that.iframeObj=null;that.onmessage_cb=that.iframeObj=null}};IframeTransport.prototype.onmessage=function(e){var that=this;if(e.origin!==that.origin)return;var window_id=e.data.slice(0,8);var type=e.data.slice(8,9);var data=e.data.slice(9);if(window_id!==that.window_id)return;switch(type){case"s":that.iframeObj.loaded();that.postMessage("s",JSON.stringify([SockJS.version,that.protocol,that.trans_url,that.base_url]));break;case"t":that.ri._didMessage(data);break}};IframeTransport.prototype.postMessage=function(type,data){var that=this;that.iframeObj.post(that.window_id+type+(data||""),that.origin)};IframeTransport.prototype.doSend=function(message){this.postMessage("m",message)};IframeTransport.enabled=function(){var konqueror=navigator&&navigator.userAgent&&navigator.userAgent.indexOf("Konqueror")!==-1;return(typeof _window.postMessage==="function"||typeof _window.postMessage==="object")&&!konqueror};var curr_window_id;var postMessage=function(type,data){if(parent!==_window){parent.postMessage(curr_window_id+type+(data||""),"*")}else{utils.log("Can't postMessage, no parent window.",type,data)}};var FacadeJS=function(){};FacadeJS.prototype._didClose=function(code,reason){postMessage("t",utils.closeFrame(code,reason))};FacadeJS.prototype._didMessage=function(frame){postMessage("t",frame)};FacadeJS.prototype._doSend=function(data){this._transport.doSend(data)};FacadeJS.prototype._doCleanup=function(){this._transport.doCleanup()};utils.parent_origin=undefined;SockJS.bootstrap_iframe=function(){var facade;curr_window_id=_document.location.hash.slice(1);var onMessage=function(e){if(e.source!==parent)return;if(typeof utils.parent_origin==="undefined")utils.parent_origin=e.origin;if(e.origin!==utils.parent_origin)return;var window_id=e.data.slice(0,8);var type=e.data.slice(8,9);var data=e.data.slice(9);if(window_id!==curr_window_id)return;switch(type){case"s":var p=JSON.parse(data);var version=p[0];var protocol=p[1];var trans_url=p[2];var base_url=p[3];if(version!==SockJS.version){utils.log("Incompatibile SockJS! Main site uses:"+' "'+version+'", the iframe:'+' "'+SockJS.version+'".')}if(!utils.flatUrl(trans_url)||!utils.flatUrl(base_url)){utils.log("Only basic urls are supported in SockJS");return}if(!utils.isSameOriginUrl(trans_url)||!utils.isSameOriginUrl(base_url)){utils.log("Can't connect to different domain from within an "+"iframe. ("+JSON.stringify([_window.location.href,trans_url,base_url])+")");return}facade=new FacadeJS;facade._transport=new FacadeJS[protocol](facade,trans_url,base_url);break;case"m":facade._doSend(data);break;case"c":if(facade)facade._doCleanup();facade=null;break}};utils.attachMessage(onMessage);postMessage("s")};var InfoReceiver=function(base_url,AjaxObject){var that=this;utils.delay(function(){that.doXhr(base_url,AjaxObject)})};InfoReceiver.prototype=new EventEmitter(["finish"]);InfoReceiver.prototype.doXhr=function(base_url,AjaxObject){var that=this;var t0=(new Date).getTime();var xo=new AjaxObject("GET",base_url+"/info");var tref=utils.delay(8e3,function(){xo.ontimeout()});xo.onfinish=function(status,text){clearTimeout(tref);tref=null;if(status===200){var rtt=(new Date).getTime()-t0;var info=JSON.parse(text);if(typeof info!=="object")info={};that.emit("finish",info,rtt)}else{that.emit("finish")}};xo.ontimeout=function(){xo.close();that.emit("finish")}};var InfoReceiverIframe=function(base_url){var that=this;var go=function(){var ifr=new IframeTransport;ifr.protocol="w-iframe-info-receiver";var fun=function(r){if(typeof r==="string"&&r.substr(0,1)==="m"){var d=JSON.parse(r.substr(1));var info=d[0],rtt=d[1];that.emit("finish",info,rtt)}else{that.emit("finish")}ifr.doCleanup();ifr=null};var mock_ri={_options:{},_didClose:fun,_didMessage:fun};ifr.i_constructor(mock_ri,base_url,base_url)};if(!_document.body){utils.attachEvent("load",go)}else{go()}};InfoReceiverIframe.prototype=new EventEmitter(["finish"]);var InfoReceiverFake=function(){var that=this;utils.delay(function(){that.emit("finish",{},2e3)})};InfoReceiverFake.prototype=new EventEmitter(["finish"]);var createInfoReceiver=function(base_url){if(utils.isSameOriginUrl(base_url)){return new InfoReceiver(base_url,utils.XHRLocalObject)}switch(utils.isXHRCorsCapable()){case 1:return new InfoReceiver(base_url,utils.XHRCorsObject);case 2:return new InfoReceiver(base_url,utils.XDRObject);case 3:return new InfoReceiverIframe(base_url);default:return new InfoReceiverFake}};var WInfoReceiverIframe=FacadeJS["w-iframe-info-receiver"]=function(ri,_trans_url,base_url){var ir=new InfoReceiver(base_url,utils.XHRLocalObject);ir.onfinish=function(info,rtt){ri._didMessage("m"+JSON.stringify([info,rtt]));ri._didClose()}};WInfoReceiverIframe.prototype.doCleanup=function(){};var EventSourceIframeTransport=SockJS["iframe-eventsource"]=function(){var that=this;that.protocol="w-iframe-eventsource";that.i_constructor.apply(that,arguments)};EventSourceIframeTransport.prototype=new IframeTransport;EventSourceIframeTransport.enabled=function(){return"EventSource"in _window&&IframeTransport.enabled()};EventSourceIframeTransport.need_body=true;EventSourceIframeTransport.roundTrips=3;var EventSourceTransport=FacadeJS["w-iframe-eventsource"]=function(ri,trans_url){this.run(ri,trans_url,"/eventsource",EventSourceReceiver,utils.XHRLocalObject)};EventSourceTransport.prototype=new AjaxBasedTransport;var XhrPollingIframeTransport=SockJS["iframe-xhr-polling"]=function(){var that=this;that.protocol="w-iframe-xhr-polling";that.i_constructor.apply(that,arguments)};XhrPollingIframeTransport.prototype=new IframeTransport;XhrPollingIframeTransport.enabled=function(){return _window.XMLHttpRequest&&IframeTransport.enabled()};XhrPollingIframeTransport.need_body=true;XhrPollingIframeTransport.roundTrips=3;var XhrPollingITransport=FacadeJS["w-iframe-xhr-polling"]=function(ri,trans_url){this.run(ri,trans_url,"/xhr",XhrReceiver,utils.XHRLocalObject)};XhrPollingITransport.prototype=new AjaxBasedTransport;var HtmlFileIframeTransport=SockJS["iframe-htmlfile"]=function(){var that=this;that.protocol="w-iframe-htmlfile";that.i_constructor.apply(that,arguments)};HtmlFileIframeTransport.prototype=new IframeTransport;HtmlFileIframeTransport.enabled=function(){return IframeTransport.enabled()};HtmlFileIframeTransport.need_body=true;HtmlFileIframeTransport.roundTrips=3;var HtmlFileTransport=FacadeJS["w-iframe-htmlfile"]=function(ri,trans_url){this.run(ri,trans_url,"/htmlfile",HtmlfileReceiver,utils.XHRLocalObject)};HtmlFileTransport.prototype=new AjaxBasedTransport;var Polling=function(ri,Receiver,recv_url,AjaxObject){var that=this;that.ri=ri;that.Receiver=Receiver;that.recv_url=recv_url;that.AjaxObject=AjaxObject;that._scheduleRecv()};Polling.prototype._scheduleRecv=function(){var that=this;var poll=that.poll=new that.Receiver(that.recv_url,that.AjaxObject);var msg_counter=0;poll.onmessage=function(e){msg_counter+=1;that.ri._didMessage(e.data)};poll.onclose=function(e){that.poll=poll=poll.onmessage=poll.onclose=null;if(!that.poll_is_closing){if(e.reason==="permanent"){that.ri._didClose(1006,"Polling error ("+e.reason+")")}else{that._scheduleRecv()}}}};Polling.prototype.abort=function(){var that=this;that.poll_is_closing=true;if(that.poll){that.poll.abort()}};var EventSourceReceiver=function(url){var that=this;var es=new EventSource(url);es.onmessage=function(e){that.dispatchEvent(new SimpleEvent("message",{data:unescape(e.data)}))};that.es_close=es.onerror=function(e,abort_reason){var reason=abort_reason?"user":es.readyState!==2?"network":"permanent";that.es_close=es.onmessage=es.onerror=null;es.close();es=null;utils.delay(200,function(){that.dispatchEvent(new SimpleEvent("close",{reason:reason}))})}};EventSourceReceiver.prototype=new REventTarget;EventSourceReceiver.prototype.abort=function(){var that=this;if(that.es_close){that.es_close({},true)}};var _is_ie_htmlfile_capable;var isIeHtmlfileCapable=function(){if(_is_ie_htmlfile_capable===undefined){if("ActiveXObject"in _window){try{_is_ie_htmlfile_capable=!!new ActiveXObject("htmlfile")}catch(x){}}else{_is_ie_htmlfile_capable=false}}return _is_ie_htmlfile_capable};var HtmlfileReceiver=function(url){var that=this;utils.polluteGlobalNamespace();that.id="a"+utils.random_string(6,26);url+=(url.indexOf("?")===-1?"?":"&")+"c="+escape(WPrefix+"."+that.id);var constructor=isIeHtmlfileCapable()?utils.createHtmlfile:utils.createIframe;var iframeObj;_window[WPrefix][that.id]={start:function(){iframeObj.loaded()},message:function(data){that.dispatchEvent(new SimpleEvent("message",{data:data}))},stop:function(){that.iframe_close({},"network")}};that.iframe_close=function(e,abort_reason){iframeObj.cleanup();that.iframe_close=iframeObj=null;delete _window[WPrefix][that.id];that.dispatchEvent(new SimpleEvent("close",{reason:abort_reason}))};iframeObj=constructor(url,function(e){that.iframe_close({},"permanent")})};HtmlfileReceiver.prototype=new REventTarget;HtmlfileReceiver.prototype.abort=function(){var that=this;if(that.iframe_close){that.iframe_close({},"user")}};var XhrReceiver=function(url,AjaxObject){var that=this;var buf_pos=0;that.xo=new AjaxObject("POST",url,null);that.xo.onchunk=function(status,text){if(status!==200)return;while(1){var buf=text.slice(buf_pos);var p=buf.indexOf("\n");if(p===-1)break;buf_pos+=p+1;var msg=buf.slice(0,p);that.dispatchEvent(new SimpleEvent("message",{data:msg}))}};that.xo.onfinish=function(status,text){that.xo.onchunk(status,text);that.xo=null;var reason=status===200?"network":"permanent";that.dispatchEvent(new SimpleEvent("close",{reason:reason}))}};XhrReceiver.prototype=new REventTarget;XhrReceiver.prototype.abort=function(){var that=this;if(that.xo){that.xo.close();that.dispatchEvent(new SimpleEvent("close",{reason:"user"}));that.xo=null}};SockJS.getUtils=function(){return utils};SockJS.getIframeTransport=function(){return IframeTransport};return SockJS}();if("_sockjs_onload"in window)setTimeout(_sockjs_onload,1);if(typeof define==="function"&&define.amd){define("sockjs",[],function(){return SockJS})}if(typeof module==="object"&&module&&module.exports){module.exports=SockJS}},{}],82:[function(require,module,exports){var through=require("through");var Decoder=require("string_decoder").StringDecoder;module.exports=split;function split(matcher,mapper,options){var decoder=new Decoder;var soFar="";var maxLength=options&&options.maxLength;if("function"===typeof matcher)mapper=matcher,matcher=null;if(!matcher)matcher=/\r?\n/;function emit(stream,piece){if(mapper){try{piece=mapper(piece)}catch(err){return stream.emit("error",err)}if("undefined"!==typeof piece)stream.queue(piece)}else stream.queue(piece)}function next(stream,buffer){var pieces=(soFar+buffer).split(matcher);soFar=pieces.pop();if(maxLength&&soFar.length>maxLength)stream.emit("error",new Error("maximum buffer reached"));for(var i=0;i<pieces.length;i++){var piece=pieces[i];emit(stream,piece)}}return through(function(b){next(this,decoder.write(b))},function(){if(decoder.end)next(this,decoder.end());if(soFar!=null)emit(this,soFar);this.queue(null)})}},{string_decoder:33,through:83}],83:[function(require,module,exports){(function(process){var Stream=require("stream");exports=module.exports=through;through.through=through;function through(write,end,opts){write=write||function(data){this.queue(data)};end=end||function(){this.queue(null)};var ended=false,destroyed=false,buffer=[],_ended=false;var stream=new Stream;stream.readable=stream.writable=true;stream.paused=false;stream.autoDestroy=!(opts&&opts.autoDestroy===false);stream.write=function(data){write.call(this,data);return!stream.paused};function drain(){while(buffer.length&&!stream.paused){var data=buffer.shift();if(null===data)return stream.emit("end");else stream.emit("data",data)}}stream.queue=stream.push=function(data){if(_ended)return stream;if(data==null)_ended=true;buffer.push(data);drain();return stream};stream.on("end",function(){stream.readable=false;if(!stream.writable&&stream.autoDestroy)process.nextTick(function(){stream.destroy()})});function _end(){stream.writable=false;end.call(stream);if(!stream.readable&&stream.autoDestroy)stream.destroy()}stream.end=function(data){if(ended)return;ended=true;if(arguments.length)stream.write(data);_end();return stream};stream.destroy=function(){if(destroyed)return;destroyed=true;ended=true;buffer.length=0;stream.writable=stream.readable=false;stream.emit("close");return stream};stream.pause=function(){if(stream.paused)return;stream.paused=true;return stream};stream.resume=function(){if(stream.paused){stream.paused=false;stream.emit("resume")}drain();if(!stream.paused)stream.emit("drain");return stream};return stream}}).call(this,require("FWaASH"))},{FWaASH:21,stream:27}],84:[function(require,module,exports){(function(process){var Stream=require("stream");exports=module.exports=through;through.through=through;function through(write,end){write=write||function(data){this.emit("data",data)};end=end||function(){this.emit("end")};var ended=false,destroyed=false;var stream=new Stream,buffer=[];stream.buffer=buffer;stream.readable=stream.writable=true;stream.paused=false;stream.write=function(data){write.call(this,data);return!stream.paused};function drain(){while(buffer.length&&!stream.paused){var data=buffer.shift();if(null===data)return stream.emit("end");else stream.emit("data",data)}}stream.queue=function(data){buffer.push(data);drain()};stream.on("end",function(){stream.readable=false;if(!stream.writable)process.nextTick(function(){stream.destroy()})});function _end(){stream.writable=false;end.call(stream);if(!stream.readable)stream.destroy()}stream.end=function(data){if(ended)return;ended=true;if(arguments.length)stream.write(data);_end()};stream.destroy=function(){if(destroyed)return;destroyed=true;ended=true;buffer.length=0;stream.writable=stream.readable=false;stream.emit("close")};stream.pause=function(){if(stream.paused)return;stream.paused=true;stream.emit("pause")};stream.resume=function(){if(stream.paused){stream.paused=false}drain();if(!stream.paused)stream.emit("drain")};return stream}}).call(this,require("FWaASH"))},{FWaASH:21,stream:27}],85:[function(require,module,exports){module.exports=function(context,fn){if(typeof context==="function"){var Context=window.AudioContext||window.webkitAudioContext;if(!Context)throw new Error("AudioContext not supported");fn=context;context=new Context}var self=context.createScriptProcessor(2048,1,1);self.fn=fn;self.i=self.t=0;window._SAMPLERATE=self.sampleRate=self.rate=context.sampleRate;self.duration=Infinity;self.recording=false;self.onaudioprocess=function(e){var output=e.outputBuffer.getChannelData(0),input=e.inputBuffer.getChannelData(0);self.tick(output,input)};self.tick=function(output,input){output=output||self._buffer;input=input||[];for(var i=0;i<output.length;i+=1){self.t=self.i/self.rate;self.i+=1;output[i]=self.fn(self.t,self.i,input[i]);if(self.i>=self.duration){self.stop();break}}return output};self.stop=function(){self.disconnect();self.playing=false;if(self.recording){}};self.play=function(opts){if(self.playing)return;self.connect(self.context.destination);self.playing=true;setTimeout(function(){this.node.disconnect()},1e11);return};self.record=function(){};self.reset=function(){self.i=self.t=0};self.createSample=function(duration){self.reset();var buffer=self.context.createBuffer(1,duration,self.context.sampleRate);var blob=buffer.getChannelData(0);self.tick(blob);return buffer};return self};function mergeArgs(opts,args){Object.keys(opts||{}).forEach(function(key){args[key]=opts[key]});return Object.keys(args).reduce(function(acc,key){var dash=key.length===1?"-":"--";return acc.concat(dash+key,args[key])},[])}function signed(n){if(isNaN(n))return 0;var b=Math.pow(2,15);return n>0?Math.min(b-1,Math.floor(b*n-1)):Math.max(-b,Math.ceil(b*n-1))}},{}],86:[function(require,module,exports){var bundleFn=arguments[3];var sources=arguments[4];var cache=arguments[5];var stringify=JSON.stringify;module.exports=function(fn){var keys=[];var wkey;var cacheKeys=Object.keys(cache);for(var i=0,l=cacheKeys.length;i<l;i++){var key=cacheKeys[i];if(cache[key].exports===fn){wkey=key;break}}if(!wkey){wkey=Math.floor(Math.pow(16,8)*Math.random()).toString(16);var wcache={};for(var i=0,l=cacheKeys.length;i<l;i++){var key=cacheKeys[i];wcache[key]=key}sources[wkey]=[Function(["require","module","exports"],"("+fn+")(self)"),wcache]}var skey=Math.floor(Math.pow(16,8)*Math.random()).toString(16);var scache={};scache[wkey]=wkey;sources[skey]=[Function(["require"],"require("+stringify(wkey)+")(self)"),scache];var src="("+bundleFn+")({"+Object.keys(sources).map(function(key){return stringify(key)+":["+sources[key][0]+","+stringify(sources[key][1])+"]"}).join(",")+"},{},["+stringify(skey)+"])";return new Worker(window.URL.createObjectURL(new Blob([src],{type:"text/javascript"})))}},{}]},{},[2]);