From 0ab11e9d6c53166de5876a93a9fc4552caa67cc8 Mon Sep 17 00:00:00 2001 From: sclausen Date: Sun, 2 Dec 2018 21:49:10 +0100 Subject: [PATCH] Missed mqtt.js. --- package.json | 2 +- vendor/mqtt.min.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 vendor/mqtt.min.js diff --git a/package.json b/package.json index d2cd8de..2cac628 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ngx-mqtt", - "version": "6.8.0", + "version": "6.8.1", "description": "ngx mqtt client library", "main": "bundles/ngx-mqtt.min.js", "module": "./src/index.js", diff --git a/vendor/mqtt.min.js b/vendor/mqtt.min.js new file mode 100644 index 0000000..92a5557 --- /dev/null +++ b/vendor/mqtt.min.js @@ -0,0 +1 @@ +(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.mqtt=f()}})(function(){var define,module,exports;return function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;ioptions.properties.topicAliasMaximum||!options.properties.topicAliasMaximum&&opts.properties.topicAlias)){delete packet.properties.topicAlias}}switch(opts.qos){case 1:case 2:this.outgoing[packet.messageId]=callback||nop;this._sendPacket(packet,undefined,opts.cbStorePut);break;default:this._sendPacket(packet,callback,opts.cbStorePut);break}return this};MqttClient.prototype.subscribe=function(){var packet;var args=new Array(arguments.length);for(var i=0;i0){var topic={qos:sub.qos};if(version===5){topic.nl=sub.nl||false;topic.rap=sub.rap||false;topic.rh=sub.rh||0}that._resubscribeTopics[sub.topic]=topic;topics.push(sub.topic)}});that.messageIdToTopic[packet.messageId]=topics}this.outgoing[packet.messageId]=function(err,packet){if(!err){var granted=packet.granted;for(var i=0;i0){this.once("outgoingEmpty",setTimeout.bind(null,finish,10))}else{finish()}return this};MqttClient.prototype.removeOutgoingMessage=function(mid){var cb=this.outgoing[mid];delete this.outgoing[mid];this.outgoingStore.del({messageId:mid},function(){cb(new Error("Message removed"))});return this};MqttClient.prototype.reconnect=function(opts){var that=this;var f=function(){if(opts){that.options.incomingStore=opts.incomingStore;that.options.outgoingStore=opts.outgoingStore}else{that.options.incomingStore=null;that.options.outgoingStore=null}that.incomingStore=that.options.incomingStore||new Store;that.outgoingStore=that.options.outgoingStore||new Store;that.disconnecting=false;that.disconnected=false;that._deferredReconnect=null;that._reconnect()};if(this.disconnecting&&!this.disconnected){this._deferredReconnect=f}else{f()}return this};MqttClient.prototype._reconnect=function(){this.emit("reconnect");this._setupStream()};MqttClient.prototype._setupReconnect=function(){var that=this;if(!that.disconnecting&&!that.reconnectTimer&&that.options.reconnectPeriod>0){if(!this.reconnecting){this.emit("offline");this.reconnecting=true}that.reconnectTimer=setInterval(function(){that._reconnect()},that.options.reconnectPeriod)}};MqttClient.prototype._clearReconnect=function(){if(this.reconnectTimer){clearInterval(this.reconnectTimer);this.reconnectTimer=null}};MqttClient.prototype._cleanUp=function(forced,done){var opts=arguments[2];if(done){this.stream.on("close",done)}if(forced){if(this.options.reconnectPeriod===0&&this.options.clean){flush(this.outgoing)}this.stream.destroy()}else{var packet=xtend({cmd:"disconnect"},opts);this._sendPacket(packet,setImmediate.bind(null,this.stream.end.bind(this.stream)))}if(!this.disconnecting){this._clearReconnect();this._setupReconnect()}if(this.pingTimer!==null){this.pingTimer.clear();this.pingTimer=null}if(done&&!this.connected){this.stream.removeListener("close",done);done()}};MqttClient.prototype._sendPacket=function(packet,cb,cbStorePut){cbStorePut=cbStorePut||nop;if(!this.connected){if((packet.qos||0)===0&&this.queueQoSZero||packet.cmd!=="publish"){this.queue.push({packet:packet,cb:cb})}else if(packet.qos>0){cb=this.outgoing[packet.messageId];this.outgoingStore.put(packet,function(err){if(err){return cb&&cb(err)}cbStorePut()})}else if(cb){cb(new Error("No connection to broker"))}return}this._shiftPingInterval();switch(packet.cmd){case"publish":break;case"pubrel":storeAndSend(this,packet,cb,cbStorePut);return;default:sendPacket(this,packet,cb);return}switch(packet.qos){case 2:case 1:storeAndSend(this,packet,cb,cbStorePut);break;case 0:default:sendPacket(this,packet,cb);break}};MqttClient.prototype._setupPingTimer=function(){var that=this;if(!this.pingTimer&&this.options.keepalive){this.pingResp=true;this.pingTimer=reInterval(function(){that._checkPing()},this.options.keepalive*1e3)}};MqttClient.prototype._shiftPingInterval=function(){if(this.pingTimer&&this.options.keepalive&&this.options.reschedulePings){this.pingTimer.reschedule(this.options.keepalive*1e3)}};MqttClient.prototype._checkPing=function(){if(this.pingResp){this.pingResp=false;this._sendPacket({cmd:"pingreq"})}else{this._cleanUp(true)}};MqttClient.prototype._handlePingresp=function(){this.pingResp=true};MqttClient.prototype._handleConnack=function(packet){var options=this.options;var version=options.protocolVersion;var rc=version===5?packet.reasonCode:packet.returnCode;clearTimeout(this.connackTimer);if(packet.properties){if(packet.properties.topicAliasMaximum){if(!options.properties){options.properties={}}options.properties.topicAliasMaximum=packet.properties.topicAliasMaximum}if(packet.properties.serverKeepAlive&&options.keepalive){options.keepalive=packet.properties.serverKeepAlive;this._shiftPingInterval()}if(packet.properties.maximumPacketSize){if(!options.properties){options.properties={}}options.properties.maximumPacketSize=packet.properties.maximumPacketSize}}if(rc===0){this.reconnecting=false;this._onConnect(packet)}else if(rc>0){var err=new Error("Connection refused: "+errors[rc]);err.code=rc;this.emit("error",err)}};MqttClient.prototype._handlePublish=function(packet,done){done=typeof done!=="undefined"?done:nop;var topic=packet.topic.toString();var message=packet.payload;var qos=packet.qos;var mid=packet.messageId;var that=this;var options=this.options;var validReasonCodes=[0,16,128,131,135,144,145,151,153];switch(qos){case 2:{options.customHandleAcks(topic,message,packet,function(error,code){if(!(error instanceof Error)){code=error;error=null}if(error){return that.emit("error",error)}if(validReasonCodes.indexOf(code)===-1){return that.emit("error",new Error("Wrong reason code for pubrec"))}if(code){that._sendPacket({cmd:"pubrec",messageId:mid,reasonCode:code},done)}else{that.incomingStore.put(packet,function(){that._sendPacket({cmd:"pubrec",messageId:mid},done)})}});break}case 1:{options.customHandleAcks(topic,message,packet,function(error,code){if(!(error instanceof Error)){code=error;error=null}if(error){return that.emit("error",error)}if(validReasonCodes.indexOf(code)===-1){return that.emit("error",new Error("Wrong reason code for puback"))}if(!code){that.emit("message",topic,message,packet)}that.handleMessage(packet,function(err){if(err){return done&&done(err)}that._sendPacket({cmd:"puback",messageId:mid,reasonCode:code},done)})});break}case 0:this.emit("message",topic,message,packet);this.handleMessage(packet,done);break;default:break}};MqttClient.prototype.handleMessage=function(packet,callback){callback()};MqttClient.prototype._handleAck=function(packet){var mid=packet.messageId;var type=packet.cmd;var response=null;var cb=this.outgoing[mid];var that=this;var err;if(!cb){return}switch(type){case"pubcomp":case"puback":var pubackRC=packet.reasonCode;if(pubackRC&&pubackRC>0&&pubackRC!==16){err=new Error("Publish error: "+errors[pubackRC]);err.code=pubackRC;cb(err,packet)}delete this.outgoing[mid];this.outgoingStore.del(packet,cb);break;case"pubrec":response={cmd:"pubrel",qos:2,messageId:mid};var pubrecRC=packet.reasonCode;if(pubrecRC&&pubrecRC>0&&pubrecRC!==16){err=new Error("Publish error: "+errors[pubrecRC]);err.code=pubrecRC;cb(err,packet)}else{this._sendPacket(response)}break;case"suback":delete this.outgoing[mid];for(var grantedI=0;grantedI0){if(this.options.resubscribe){this._resubscribeTopics.resubscribe=true;this.subscribe(this._resubscribeTopics)}else{this._resubscribeTopics={}}}this._firstConnection=false};MqttClient.prototype._onConnect=function(packet){if(this.disconnected){this.emit("connect",packet);return}var that=this;this._setupPingTimer();this._resubscribe();this.connected=true;var outStore=this.outgoingStore.createStream();this.once("close",remove);outStore.on("end",function(){that.removeListener("close",remove);that.emit("connect",packet)});outStore.on("error",function(err){that.removeListener("close",remove);that.emit("error",err)});function remove(){outStore.destroy();outStore=null}function storeDeliver(){if(!outStore){return}var packet=outStore.read(1);var cb;if(!packet){outStore.once("readable",storeDeliver);return}if(!that.disconnecting&&!that.reconnectTimer){cb=that.outgoing[packet.messageId];that.outgoing[packet.messageId]=function(err,status){if(cb){cb(err,status)}storeDeliver()};that._sendPacket(packet)}else if(outStore.destroy){outStore.destroy()}}storeDeliver()};module.exports=MqttClient}).call(this,require("_process"),typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"./store":6,"./validations":7,_process:92,"end-of-stream":17,events:78,inherits:80,"mqtt-packet":85,"readable-stream":106,reinterval:107,xtend:120}],2:[function(require,module,exports){"use strict";var net=require("net");function buildBuilder(client,opts){var port,host;opts.port=opts.port||1883;opts.hostname=opts.hostname||opts.host||"localhost";port=opts.port;host=opts.hostname;return net.createConnection(port,host)}module.exports=buildBuilder},{net:11}],3:[function(require,module,exports){"use strict";var tls=require("tls");function buildBuilder(mqttClient,opts){var connection;opts.port=opts.port||8883;opts.host=opts.hostname||opts.host||"localhost";opts.rejectUnauthorized=opts.rejectUnauthorized!==false;delete opts.path;connection=tls.connect(opts);connection.on("secureConnect",function(){if(opts.rejectUnauthorized&&!connection.authorized){connection.emit("error",new Error("TLS not authorized"))}else{connection.removeListener("error",handleTLSerrors)}});function handleTLSerrors(err){if(opts.rejectUnauthorized){mqttClient.emit("error",err)}connection.end()}connection.on("error",handleTLSerrors);return connection}module.exports=buildBuilder},{tls:11}],4:[function(require,module,exports){(function(process){"use strict";var websocket=require("websocket-stream");var urlModule=require("url");var WSS_OPTIONS=["rejectUnauthorized","ca","cert","key","pfx","passphrase"];var IS_BROWSER=process.title==="browser";function buildUrl(opts,client){var url=opts.protocol+"://"+opts.hostname+":"+opts.port+opts.path;if(typeof opts.transformWsUrl==="function"){url=opts.transformWsUrl(url,opts,client)}return url}function setDefaultOpts(opts){if(!opts.hostname){opts.hostname="localhost"}if(!opts.port){if(opts.protocol==="wss"){opts.port=443}else{opts.port=80}}if(!opts.path){opts.path="/"}if(!opts.wsOptions){opts.wsOptions={}}if(!IS_BROWSER&&opts.protocol==="wss"){WSS_OPTIONS.forEach(function(prop){if(opts.hasOwnProperty(prop)&&!opts.wsOptions.hasOwnProperty(prop)){opts.wsOptions[prop]=opts[prop]}})}}function createWebSocket(client,opts){var websocketSubProtocol=opts.protocolId==="MQIsdp"&&opts.protocolVersion===3?"mqttv3.1":"mqtt";setDefaultOpts(opts);var url=buildUrl(opts,client);return websocket(url,[websocketSubProtocol],opts.wsOptions)}function buildBuilder(client,opts){return createWebSocket(client,opts)}function buildBuilderBrowser(client,opts){if(!opts.hostname){opts.hostname=opts.host}if(!opts.hostname){if(typeof document==="undefined"){throw new Error("Could not determine host. Specify host manually.")}var parsed=urlModule.parse(document.URL);opts.hostname=parsed.hostname;if(!opts.port){opts.port=parsed.port}}return createWebSocket(client,opts)}if(IS_BROWSER){module.exports=buildBuilderBrowser}else{module.exports=buildBuilder}}).call(this,require("_process"))},{_process:92,url:111,"websocket-stream":117}],5:[function(require,module,exports){"use strict";var socketOpen=false;var socketMsgQueue=[];function sendSocketMessage(msg){if(socketOpen){wx.sendSocketMessage({data:msg.buffer||msg})}else{socketMsgQueue.push(msg)}}function WebSocket(url,protocols){var ws={OPEN:1,CLOSING:2,CLOSED:3,readyState:socketOpen?1:0,send:sendSocketMessage,close:wx.closeSocket,onopen:null,onmessage:null,onclose:null,onerror:null};wx.connectSocket({url:url,protocols:protocols});wx.onSocketOpen(function(res){ws.readyState=ws.OPEN;socketOpen=true;for(var i=0;i0){throw new Error("Invalid string. Length must be a multiple of 4")}var validLen=b64.indexOf("=");if(validLen===-1)validLen=len;var placeHoldersLen=validLen===len?0:4-validLen%4;return[validLen,placeHoldersLen]}function byteLength(b64){var lens=getLens(b64);var validLen=lens[0];var placeHoldersLen=lens[1];return(validLen+placeHoldersLen)*3/4-placeHoldersLen}function _byteLength(b64,validLen,placeHoldersLen){return(validLen+placeHoldersLen)*3/4-placeHoldersLen}function toByteArray(b64){var tmp;var lens=getLens(b64);var validLen=lens[0];var placeHoldersLen=lens[1];var arr=new Arr(_byteLength(b64,validLen,placeHoldersLen));var curByte=0;var len=placeHoldersLen>0?validLen-4:validLen;for(var i=0;i>16&255;arr[curByte++]=tmp>>8&255;arr[curByte++]=tmp&255}if(placeHoldersLen===2){tmp=revLookup[b64.charCodeAt(i)]<<2|revLookup[b64.charCodeAt(i+1)]>>4;arr[curByte++]=tmp&255}if(placeHoldersLen===1){tmp=revLookup[b64.charCodeAt(i)]<<10|revLookup[b64.charCodeAt(i+1)]<<4|revLookup[b64.charCodeAt(i+2)]>>2;arr[curByte++]=tmp>>8&255;arr[curByte++]=tmp&255}return arr}function tripletToBase64(num){return lookup[num>>18&63]+lookup[num>>12&63]+lookup[num>>6&63]+lookup[num&63]}function encodeChunk(uint8,start,end){var tmp;var output=[];for(var i=start;ilen2?len2:i+maxChunkLength))}if(extraBytes===1){tmp=uint8[len-1];parts.push(lookup[tmp>>2]+lookup[tmp<<4&63]+"==")}else if(extraBytes===2){tmp=(uint8[len-2]<<8)+uint8[len-1];parts.push(lookup[tmp>>10]+lookup[tmp>>4&63]+lookup[tmp<<2&63]+"=")}return parts.join("")}},{}],10:[function(require,module,exports){var DuplexStream=require("readable-stream/duplex"),util=require("util"),Buffer=require("safe-buffer").Buffer;function BufferList(callback){if(!(this instanceof BufferList))return new BufferList(callback);this._bufs=[];this.length=0;if(typeof callback=="function"){this._callback=callback;var piper=function piper(err){if(this._callback){this._callback(err);this._callback=null}}.bind(this);this.on("pipe",function onPipe(src){src.on("error",piper)});this.on("unpipe",function onUnpipe(src){src.removeListener("error",piper)})}else{this.append(callback)}DuplexStream.call(this)}util.inherits(BufferList,DuplexStream);BufferList.prototype._offset=function _offset(offset){var tot=0,i=0,_t;if(offset===0)return[0,0];for(;ithis.length)srcEnd=this.length;if(srcStart>=this.length)return dst||Buffer.alloc(0);if(srcEnd<=0)return dst||Buffer.alloc(0);var copy=!!dst,off=this._offset(srcStart),len=srcEnd-srcStart,bytes=len,bufoff=copy&&dstStart||0,start=off[1],l,i;if(srcStart===0&&srcEnd==this.length){if(!copy){return this._bufs.length===1?this._bufs[0]:Buffer.concat(this._bufs,this.length)}for(i=0;il){this._bufs[i].copy(dst,bufoff,start)}else{this._bufs[i].copy(dst,bufoff,start,start+bytes);break}bufoff+=l;bytes-=l;if(start)start=0}return dst};BufferList.prototype.shallowSlice=function shallowSlice(start,end){start=start||0;end=end||this.length;if(start<0)start+=this.length;if(end<0)end+=this.length;var startOffset=this._offset(start),endOffset=this._offset(end),buffers=this._bufs.slice(startOffset[0],endOffset[0]+1);if(endOffset[1]==0)buffers.pop();else buffers[buffers.length-1]=buffers[buffers.length-1].slice(0,endOffset[1]);if(startOffset[1]!=0)buffers[0]=buffers[0].slice(startOffset[1]);return new BufferList(buffers)};BufferList.prototype.toString=function toString(encoding,start,end){return this.slice(start,end).toString(encoding)};BufferList.prototype.consume=function consume(bytes){while(this._bufs.length){if(bytes>=this._bufs[0].length){bytes-=this._bufs[0].length;this.length-=this._bufs[0].length;this._bufs.shift()}else{this._bufs[0]=this._bufs[0].slice(bytes);this.length-=bytes;break}}return this};BufferList.prototype.duplicate=function duplicate(){var i=0,copy=new BufferList;for(;iK_MAX_LENGTH){throw new RangeError("Invalid typed array length")}var buf=new Uint8Array(length);buf.__proto__=Buffer.prototype;return buf}function Buffer(arg,encodingOrOffset,length){if(typeof arg==="number"){if(typeof encodingOrOffset==="string"){throw new Error("If encoding is specified then the first argument must be a string")}return allocUnsafe(arg)}return from(arg,encodingOrOffset,length)}if(typeof Symbol!=="undefined"&&Symbol.species&&Buffer[Symbol.species]===Buffer){Object.defineProperty(Buffer,Symbol.species,{value:null,configurable:true,enumerable:false,writable:false})}Buffer.poolSize=8192;function from(value,encodingOrOffset,length){if(typeof value==="number"){throw new TypeError('"value" argument must not be a number')}if(isArrayBuffer(value)||value&&isArrayBuffer(value.buffer)){return fromArrayBuffer(value,encodingOrOffset,length)}if(typeof value==="string"){return fromString(value,encodingOrOffset)}return fromObject(value)}Buffer.from=function(value,encodingOrOffset,length){return from(value,encodingOrOffset,length)};Buffer.prototype.__proto__=Uint8Array.prototype;Buffer.__proto__=Uint8Array;function assertSize(size){if(typeof size!=="number"){throw new TypeError('"size" argument must be of type number')}else if(size<0){throw new RangeError('"size" argument must not be negative')}}function alloc(size,fill,encoding){assertSize(size);if(size<=0){return createBuffer(size)}if(fill!==undefined){return typeof encoding==="string"?createBuffer(size).fill(fill,encoding):createBuffer(size).fill(fill)}return createBuffer(size)}Buffer.alloc=function(size,fill,encoding){return alloc(size,fill,encoding)};function allocUnsafe(size){assertSize(size);return createBuffer(size<0?0:checked(size)|0)}Buffer.allocUnsafe=function(size){return allocUnsafe(size)};Buffer.allocUnsafeSlow=function(size){return allocUnsafe(size)};function fromString(string,encoding){if(typeof encoding!=="string"||encoding===""){encoding="utf8"}if(!Buffer.isEncoding(encoding)){throw new TypeError("Unknown encoding: "+encoding)}var length=byteLength(string,encoding)|0;var buf=createBuffer(length);var actual=buf.write(string,encoding);if(actual!==length){buf=buf.slice(0,actual)}return buf}function fromArrayLike(array){var length=array.length<0?0:checked(array.length)|0;var buf=createBuffer(length);for(var i=0;i=K_MAX_LENGTH){throw new RangeError("Attempt to allocate Buffer larger than maximum "+"size: 0x"+K_MAX_LENGTH.toString(16)+" bytes")}return length|0}function SlowBuffer(length){if(+length!=length){length=0}return Buffer.alloc(+length)}Buffer.isBuffer=function isBuffer(b){return b!=null&&b._isBuffer===true};Buffer.compare=function compare(a,b){if(!Buffer.isBuffer(a)||!Buffer.isBuffer(b)){throw new TypeError("Arguments must be Buffers")}if(a===b)return 0;var x=a.length;var y=b.length;for(var i=0,len=Math.min(x,y);i>>1;case"base64":return base64ToBytes(string).length;default:if(loweredCase)return utf8ToBytes(string).length;encoding=(""+encoding).toLowerCase();loweredCase=true}}}Buffer.byteLength=byteLength;function slowToString(encoding,start,end){var loweredCase=false;if(start===undefined||start<0){start=0}if(start>this.length){return""}if(end===undefined||end>this.length){end=this.length}if(end<=0){return""}end>>>=0;start>>>=0;if(end<=start){return""}if(!encoding)encoding="utf8";while(true){switch(encoding){case"hex":return hexSlice(this,start,end);case"utf8":case"utf-8":return utf8Slice(this,start,end);case"ascii":return asciiSlice(this,start,end);case"latin1":case"binary":return latin1Slice(this,start,end);case"base64":return base64Slice(this,start,end);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return utf16leSlice(this,start,end);default:if(loweredCase)throw new TypeError("Unknown encoding: "+encoding);encoding=(encoding+"").toLowerCase();loweredCase=true}}}Buffer.prototype._isBuffer=true;function swap(b,n,m){var i=b[n];b[n]=b[m];b[m]=i}Buffer.prototype.swap16=function swap16(){var len=this.length;if(len%2!==0){throw new RangeError("Buffer size must be a multiple of 16-bits")}for(var i=0;i0){str=this.toString("hex",0,max).match(/.{2}/g).join(" ");if(this.length>max)str+=" ... "}return""};Buffer.prototype.compare=function compare(target,start,end,thisStart,thisEnd){if(!Buffer.isBuffer(target)){throw new TypeError("Argument must be a Buffer")}if(start===undefined){start=0}if(end===undefined){end=target?target.length:0}if(thisStart===undefined){thisStart=0}if(thisEnd===undefined){thisEnd=this.length}if(start<0||end>target.length||thisStart<0||thisEnd>this.length){throw new RangeError("out of range index")}if(thisStart>=thisEnd&&start>=end){return 0}if(thisStart>=thisEnd){return-1}if(start>=end){return 1}start>>>=0;end>>>=0;thisStart>>>=0;thisEnd>>>=0;if(this===target)return 0;var x=thisEnd-thisStart;var y=end-start;var len=Math.min(x,y);var thisCopy=this.slice(thisStart,thisEnd);var targetCopy=target.slice(start,end);for(var i=0;i2147483647){byteOffset=2147483647}else if(byteOffset<-2147483648){byteOffset=-2147483648}byteOffset=+byteOffset;if(numberIsNaN(byteOffset)){byteOffset=dir?0:buffer.length-1}if(byteOffset<0)byteOffset=buffer.length+byteOffset;if(byteOffset>=buffer.length){if(dir)return-1;else byteOffset=buffer.length-1}else if(byteOffset<0){if(dir)byteOffset=0;else return-1}if(typeof val==="string"){val=Buffer.from(val,encoding)}if(Buffer.isBuffer(val)){if(val.length===0){return-1}return arrayIndexOf(buffer,val,byteOffset,encoding,dir)}else if(typeof val==="number"){val=val&255;if(typeof Uint8Array.prototype.indexOf==="function"){if(dir){return Uint8Array.prototype.indexOf.call(buffer,val,byteOffset)}else{return Uint8Array.prototype.lastIndexOf.call(buffer,val,byteOffset)}}return arrayIndexOf(buffer,[val],byteOffset,encoding,dir)}throw new TypeError("val must be string, number or Buffer")}function arrayIndexOf(arr,val,byteOffset,encoding,dir){var indexSize=1;var arrLength=arr.length;var valLength=val.length;if(encoding!==undefined){encoding=String(encoding).toLowerCase();if(encoding==="ucs2"||encoding==="ucs-2"||encoding==="utf16le"||encoding==="utf-16le"){if(arr.length<2||val.length<2){return-1}indexSize=2;arrLength/=2;valLength/=2;byteOffset/=2}}function read(buf,i){if(indexSize===1){return buf[i]}else{return buf.readUInt16BE(i*indexSize)}}var i;if(dir){var foundIndex=-1;for(i=byteOffset;iarrLength)byteOffset=arrLength-valLength;for(i=byteOffset;i>=0;i--){var found=true;for(var j=0;jremaining){length=remaining}}var strLen=string.length;if(length>strLen/2){length=strLen/2}for(var i=0;i>>0;if(isFinite(length)){length=length>>>0;if(encoding===undefined)encoding="utf8"}else{encoding=length;length=undefined}}else{throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported")}var remaining=this.length-offset;if(length===undefined||length>remaining)length=remaining;if(string.length>0&&(length<0||offset<0)||offset>this.length){throw new RangeError("Attempt to write outside buffer bounds")}if(!encoding)encoding="utf8";var loweredCase=false;for(;;){switch(encoding){case"hex":return hexWrite(this,string,offset,length);case"utf8":case"utf-8":return utf8Write(this,string,offset,length);case"ascii":return asciiWrite(this,string,offset,length);case"latin1":case"binary":return latin1Write(this,string,offset,length);case"base64":return base64Write(this,string,offset,length);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ucs2Write(this,string,offset,length);default:if(loweredCase)throw new TypeError("Unknown encoding: "+encoding);encoding=(""+encoding).toLowerCase();loweredCase=true}}};Buffer.prototype.toJSON=function toJSON(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};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){end=Math.min(buf.length,end);var res=[];var i=start;while(i239?4:firstByte>223?3:firstByte>191?2:1;if(i+bytesPerSequence<=end){var secondByte,thirdByte,fourthByte,tempCodePoint;switch(bytesPerSequence){case 1:if(firstByte<128){codePoint=firstByte}break;case 2:secondByte=buf[i+1];if((secondByte&192)===128){tempCodePoint=(firstByte&31)<<6|secondByte&63;if(tempCodePoint>127){codePoint=tempCodePoint}}break;case 3:secondByte=buf[i+1];thirdByte=buf[i+2];if((secondByte&192)===128&&(thirdByte&192)===128){tempCodePoint=(firstByte&15)<<12|(secondByte&63)<<6|thirdByte&63;if(tempCodePoint>2047&&(tempCodePoint<55296||tempCodePoint>57343)){codePoint=tempCodePoint}}break;case 4:secondByte=buf[i+1];thirdByte=buf[i+2];fourthByte=buf[i+3];if((secondByte&192)===128&&(thirdByte&192)===128&&(fourthByte&192)===128){tempCodePoint=(firstByte&15)<<18|(secondByte&63)<<12|(thirdByte&63)<<6|fourthByte&63;if(tempCodePoint>65535&&tempCodePoint<1114112){codePoint=tempCodePoint}}}}if(codePoint===null){codePoint=65533;bytesPerSequence=1}else if(codePoint>65535){codePoint-=65536;res.push(codePoint>>>10&1023|55296);codePoint=56320|codePoint&1023}res.push(codePoint);i+=bytesPerSequence}return decodeCodePointsArray(res)}var MAX_ARGUMENTS_LENGTH=4096;function decodeCodePointsArray(codePoints){var len=codePoints.length;if(len<=MAX_ARGUMENTS_LENGTH){return String.fromCharCode.apply(String,codePoints)}var res="";var i=0;while(ilen)end=len;var out="";for(var i=start;ilen){start=len}if(end<0){end+=len;if(end<0)end=0}else if(end>len){end=len}if(endlength)throw new RangeError("Trying to access beyond buffer length")}Buffer.prototype.readUIntLE=function readUIntLE(offset,byteLength,noAssert){offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkOffset(offset,byteLength,this.length);var val=this[offset];var mul=1;var i=0;while(++i>>0;byteLength=byteLength>>>0;if(!noAssert){checkOffset(offset,byteLength,this.length)}var val=this[offset+--byteLength];var mul=1;while(byteLength>0&&(mul*=256)){val+=this[offset+--byteLength]*mul}return val};Buffer.prototype.readUInt8=function readUInt8(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,1,this.length);return this[offset]};Buffer.prototype.readUInt16LE=function readUInt16LE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,2,this.length);return this[offset]|this[offset+1]<<8};Buffer.prototype.readUInt16BE=function readUInt16BE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,2,this.length);return this[offset]<<8|this[offset+1]};Buffer.prototype.readUInt32LE=function readUInt32LE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,4,this.length);return(this[offset]|this[offset+1]<<8|this[offset+2]<<16)+this[offset+3]*16777216};Buffer.prototype.readUInt32BE=function readUInt32BE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,4,this.length);return this[offset]*16777216+(this[offset+1]<<16|this[offset+2]<<8|this[offset+3])};Buffer.prototype.readIntLE=function readIntLE(offset,byteLength,noAssert){offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkOffset(offset,byteLength,this.length);var val=this[offset];var mul=1;var i=0;while(++i=mul)val-=Math.pow(2,8*byteLength);return val};Buffer.prototype.readIntBE=function readIntBE(offset,byteLength,noAssert){offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkOffset(offset,byteLength,this.length);var i=byteLength;var mul=1;var val=this[offset+--i];while(i>0&&(mul*=256)){val+=this[offset+--i]*mul}mul*=128;if(val>=mul)val-=Math.pow(2,8*byteLength);return val};Buffer.prototype.readInt8=function readInt8(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,1,this.length);if(!(this[offset]&128))return this[offset];return(255-this[offset]+1)*-1};Buffer.prototype.readInt16LE=function readInt16LE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,2,this.length);var val=this[offset]|this[offset+1]<<8;return val&32768?val|4294901760:val};Buffer.prototype.readInt16BE=function readInt16BE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,2,this.length);var val=this[offset+1]|this[offset]<<8;return val&32768?val|4294901760:val};Buffer.prototype.readInt32LE=function readInt32LE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,4,this.length);return this[offset]|this[offset+1]<<8|this[offset+2]<<16|this[offset+3]<<24};Buffer.prototype.readInt32BE=function readInt32BE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,4,this.length);return this[offset]<<24|this[offset+1]<<16|this[offset+2]<<8|this[offset+3]};Buffer.prototype.readFloatLE=function readFloatLE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,4,this.length);return ieee754.read(this,offset,true,23,4)};Buffer.prototype.readFloatBE=function readFloatBE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,4,this.length);return ieee754.read(this,offset,false,23,4)};Buffer.prototype.readDoubleLE=function readDoubleLE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,8,this.length);return ieee754.read(this,offset,true,52,8)};Buffer.prototype.readDoubleBE=function readDoubleBE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,8,this.length);return ieee754.read(this,offset,false,52,8)};function checkInt(buf,value,offset,ext,max,min){if(!Buffer.isBuffer(buf))throw new TypeError('"buffer" argument must be a Buffer instance');if(value>max||valuebuf.length)throw new RangeError("Index out of range")}Buffer.prototype.writeUIntLE=function writeUIntLE(value,offset,byteLength,noAssert){value=+value;offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert){var maxBytes=Math.pow(2,8*byteLength)-1;checkInt(this,value,offset,byteLength,maxBytes,0)}var mul=1;var i=0;this[offset]=value&255;while(++i>>0;byteLength=byteLength>>>0;if(!noAssert){var maxBytes=Math.pow(2,8*byteLength)-1;checkInt(this,value,offset,byteLength,maxBytes,0)}var i=byteLength-1;var mul=1;this[offset+i]=value&255;while(--i>=0&&(mul*=256)){this[offset+i]=value/mul&255}return offset+byteLength};Buffer.prototype.writeUInt8=function writeUInt8(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,1,255,0);this[offset]=value&255;return offset+1};Buffer.prototype.writeUInt16LE=function writeUInt16LE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,65535,0);this[offset]=value&255;this[offset+1]=value>>>8;return offset+2};Buffer.prototype.writeUInt16BE=function writeUInt16BE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,65535,0);this[offset]=value>>>8;this[offset+1]=value&255;return offset+2};Buffer.prototype.writeUInt32LE=function writeUInt32LE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,4294967295,0);this[offset+3]=value>>>24;this[offset+2]=value>>>16;this[offset+1]=value>>>8;this[offset]=value&255;return offset+4};Buffer.prototype.writeUInt32BE=function writeUInt32BE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,4294967295,0);this[offset]=value>>>24;this[offset+1]=value>>>16;this[offset+2]=value>>>8;this[offset+3]=value&255;return offset+4};Buffer.prototype.writeIntLE=function writeIntLE(value,offset,byteLength,noAssert){value=+value;offset=offset>>>0;if(!noAssert){var limit=Math.pow(2,8*byteLength-1);checkInt(this,value,offset,byteLength,limit-1,-limit)}var i=0;var mul=1;var sub=0;this[offset]=value&255;while(++i>0)-sub&255}return offset+byteLength};Buffer.prototype.writeIntBE=function writeIntBE(value,offset,byteLength,noAssert){value=+value;offset=offset>>>0;if(!noAssert){var limit=Math.pow(2,8*byteLength-1);checkInt(this,value,offset,byteLength,limit-1,-limit)}var i=byteLength-1;var mul=1;var sub=0;this[offset+i]=value&255;while(--i>=0&&(mul*=256)){if(value<0&&sub===0&&this[offset+i+1]!==0){sub=1}this[offset+i]=(value/mul>>0)-sub&255}return offset+byteLength};Buffer.prototype.writeInt8=function writeInt8(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,1,127,-128);if(value<0)value=255+value+1;this[offset]=value&255;return offset+1};Buffer.prototype.writeInt16LE=function writeInt16LE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,32767,-32768);this[offset]=value&255;this[offset+1]=value>>>8;return offset+2};Buffer.prototype.writeInt16BE=function writeInt16BE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,32767,-32768);this[offset]=value>>>8;this[offset+1]=value&255;return offset+2};Buffer.prototype.writeInt32LE=function writeInt32LE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,2147483647,-2147483648);this[offset]=value&255;this[offset+1]=value>>>8;this[offset+2]=value>>>16;this[offset+3]=value>>>24;return offset+4};Buffer.prototype.writeInt32BE=function writeInt32BE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,2147483647,-2147483648);if(value<0)value=4294967295+value+1;this[offset]=value>>>24;this[offset+1]=value>>>16;this[offset+2]=value>>>8;this[offset+3]=value&255;return offset+4};function checkIEEE754(buf,value,offset,ext,max,min){if(offset+ext>buf.length)throw new RangeError("Index out of range");if(offset<0)throw new RangeError("Index out of range")}function writeFloat(buf,value,offset,littleEndian,noAssert){value=+value;offset=offset>>>0;if(!noAssert){checkIEEE754(buf,value,offset,4,34028234663852886e22,-34028234663852886e22)}ieee754.write(buf,value,offset,littleEndian,23,4);return offset+4}Buffer.prototype.writeFloatLE=function writeFloatLE(value,offset,noAssert){return writeFloat(this,value,offset,true,noAssert)};Buffer.prototype.writeFloatBE=function writeFloatBE(value,offset,noAssert){return writeFloat(this,value,offset,false,noAssert)};function writeDouble(buf,value,offset,littleEndian,noAssert){value=+value;offset=offset>>>0;if(!noAssert){checkIEEE754(buf,value,offset,8,17976931348623157e292,-17976931348623157e292)}ieee754.write(buf,value,offset,littleEndian,52,8);return offset+8}Buffer.prototype.writeDoubleLE=function writeDoubleLE(value,offset,noAssert){return writeDouble(this,value,offset,true,noAssert)};Buffer.prototype.writeDoubleBE=function writeDoubleBE(value,offset,noAssert){return writeDouble(this,value,offset,false,noAssert)};Buffer.prototype.copy=function copy(target,targetStart,start,end){if(!Buffer.isBuffer(target))throw new TypeError("argument should be a Buffer");if(!start)start=0;if(!end&&end!==0)end=this.length;if(targetStart>=target.length)targetStart=target.length;if(!targetStart)targetStart=0;if(end>0&&end=this.length)throw new RangeError("Index out of range");if(end<0)throw new RangeError("sourceEnd out of bounds");if(end>this.length)end=this.length;if(target.length-targetStart=0;--i){target[i+targetStart]=this[i+start]}}else{Uint8Array.prototype.set.call(target,this.subarray(start,end),targetStart)}return len};Buffer.prototype.fill=function fill(val,start,end,encoding){if(typeof val==="string"){if(typeof start==="string"){encoding=start;start=0;end=this.length}else if(typeof end==="string"){encoding=end;end=this.length}if(encoding!==undefined&&typeof encoding!=="string"){throw new TypeError("encoding must be a string")}if(typeof encoding==="string"&&!Buffer.isEncoding(encoding)){throw new TypeError("Unknown encoding: "+encoding)}if(val.length===1){var code=val.charCodeAt(0);if(encoding==="utf8"&&code<128||encoding==="latin1"){val=code}}}else if(typeof val==="number"){val=val&255}if(start<0||this.length>>0;end=end===undefined?this.length:end>>>0;if(!val)val=0;var i;if(typeof val==="number"){for(i=start;i55295&&codePoint<57344){if(!leadSurrogate){if(codePoint>56319){if((units-=3)>-1)bytes.push(239,191,189);continue}else if(i+1===length){if((units-=3)>-1)bytes.push(239,191,189);continue}leadSurrogate=codePoint;continue}if(codePoint<56320){if((units-=3)>-1)bytes.push(239,191,189);leadSurrogate=codePoint;continue}codePoint=(leadSurrogate-55296<<10|codePoint-56320)+65536}else if(leadSurrogate){if((units-=3)>-1)bytes.push(239,191,189)}leadSurrogate=null;if(codePoint<128){if((units-=1)<0)break;bytes.push(codePoint)}else if(codePoint<2048){if((units-=2)<0)break;bytes.push(codePoint>>6|192,codePoint&63|128)}else if(codePoint<65536){if((units-=3)<0)break;bytes.push(codePoint>>12|224,codePoint>>6&63|128,codePoint&63|128)}else if(codePoint<1114112){if((units-=4)<0)break;bytes.push(codePoint>>18|240,codePoint>>12&63|128,codePoint>>6&63|128,codePoint&63|128)}else{throw new Error("Invalid code point")}}return bytes}function asciiToBytes(str){var byteArray=[];for(var i=0;i>8;lo=c%256;byteArray.push(lo);byteArray.push(hi)}return byteArray}function base64ToBytes(str){return base64.toByteArray(base64clean(str))}function blitBuffer(src,dst,offset,length){for(var i=0;i=dst.length||i>=src.length)break;dst[i+offset]=src[i]}return i}function isArrayBuffer(obj){return obj instanceof ArrayBuffer||obj!=null&&obj.constructor!=null&&obj.constructor.name==="ArrayBuffer"&&typeof obj.byteLength==="number"}function numberIsNaN(obj){return obj!==obj}},{"base64-js":9,ieee754:79}],13:[function(require,module,exports){(function(Buffer){function isArray(arg){if(Array.isArray){return Array.isArray(arg)}return objectToString(arg)==="[object Array]"}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 objectToString(re)==="[object RegExp]"}exports.isRegExp=isRegExp;function isObject(arg){return typeof arg==="object"&&arg!==null}exports.isObject=isObject;function isDate(d){return objectToString(d)==="[object Date]"}exports.isDate=isDate;function isError(e){return 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=Buffer.isBuffer;function objectToString(o){return Object.prototype.toString.call(o)}}).call(this,{isBuffer:require("../../is-buffer/index.js")})},{"../../is-buffer/index.js":81}],14:[function(require,module,exports){"use strict";var copy=require("es5-ext/object/copy"),normalizeOptions=require("es5-ext/object/normalize-options"),ensureCallable=require("es5-ext/object/valid-callable"),map=require("es5-ext/object/map"),callable=require("es5-ext/object/valid-callable"),validValue=require("es5-ext/object/valid-value"),bind=Function.prototype.bind,defineProperty=Object.defineProperty,hasOwnProperty=Object.prototype.hasOwnProperty,define;define=function(name,desc,options){var value=validValue(desc)&&callable(desc.value),dgs;dgs=copy(desc);delete dgs.writable;delete dgs.value;dgs.get=function(){if(!options.overwriteDefinition&&hasOwnProperty.call(this,name))return value;desc.value=bind.call(value,options.resolveContext?options.resolveContext(this):this);defineProperty(this,name,desc);return this[name]};return dgs};module.exports=function(props){var options=normalizeOptions(arguments[1]);if(options.resolveContext!=null)ensureCallable(options.resolveContext);return map(props,function(desc,name){return define(name,desc,options)})}},{"es5-ext/object/copy":38,"es5-ext/object/map":47,"es5-ext/object/normalize-options":48,"es5-ext/object/valid-callable":53,"es5-ext/object/valid-value":54}],15:[function(require,module,exports){"use strict";var assign=require("es5-ext/object/assign"),normalizeOpts=require("es5-ext/object/normalize-options"),isCallable=require("es5-ext/object/is-callable"),contains=require("es5-ext/string/#/contains"),d;d=module.exports=function(dscr,value){var c,e,w,options,desc;if(arguments.length<2||typeof dscr!=="string"){options=value;value=dscr;dscr=null}else{options=arguments[2]}if(dscr==null){c=w=true;e=false}else{c=contains.call(dscr,"c");e=contains.call(dscr,"e");w=contains.call(dscr,"w")}desc={value:value,configurable:c,enumerable:e,writable:w};return!options?desc:assign(normalizeOpts(options),desc)};d.gs=function(dscr,get,set){var c,e,options,desc;if(typeof dscr!=="string"){options=set;set=get;get=dscr;dscr=null}else{options=arguments[3]}if(get==null){get=undefined}else if(!isCallable(get)){options=get;get=set=undefined}else if(set==null){set=undefined}else if(!isCallable(set)){options=set;set=undefined}if(dscr==null){c=true;e=false}else{c=contains.call(dscr,"c");e=contains.call(dscr,"e")}desc={get:get,set:set,configurable:c,enumerable:e};return!options?desc:assign(normalizeOpts(options),desc)}},{"es5-ext/object/assign":35,"es5-ext/object/is-callable":41,"es5-ext/object/normalize-options":48,"es5-ext/string/#/contains":55}],16:[function(require,module,exports){(function(process,Buffer){var stream=require("readable-stream");var eos=require("end-of-stream");var inherits=require("inherits");var shift=require("stream-shift");var SIGNAL_FLUSH=Buffer.from&&Buffer.from!==Uint8Array.from?Buffer.from([0]):new Buffer([0]);var onuncork=function(self,fn){if(self._corked)self.once("uncork",fn);else fn()};var autoDestroy=function(self,err){if(self._autoDestroy)self.destroy(err)};var destroyer=function(self,end){return function(err){if(err)autoDestroy(self,err.message==="premature close"?null:err);else if(end&&!self._ended)self.end()}};var end=function(ws,fn){if(!ws)return fn();if(ws._writableState&&ws._writableState.finished)return fn();if(ws._writableState)return ws.end(fn);ws.end();fn()};var toStreams2=function(rs){return new stream.Readable({objectMode:true,highWaterMark:16}).wrap(rs)};var Duplexify=function(writable,readable,opts){if(!(this instanceof Duplexify))return new Duplexify(writable,readable,opts);stream.Duplex.call(this,opts);this._writable=null;this._readable=null;this._readable2=null;this._autoDestroy=!opts||opts.autoDestroy!==false;this._forwardDestroy=!opts||opts.destroy!==false;this._forwardEnd=!opts||opts.end!==false;this._corked=1;this._ondrain=null;this._drained=false;this._forwarding=false;this._unwrite=null;this._unread=null;this._ended=false;this.destroyed=false;if(writable)this.setWritable(writable);if(readable)this.setReadable(readable)};inherits(Duplexify,stream.Duplex);Duplexify.obj=function(writable,readable,opts){if(!opts)opts={};opts.objectMode=true;opts.highWaterMark=16;return new Duplexify(writable,readable,opts)};Duplexify.prototype.cork=function(){if(++this._corked===1)this.emit("cork")};Duplexify.prototype.uncork=function(){if(this._corked&&--this._corked===0)this.emit("uncork")};Duplexify.prototype.setWritable=function(writable){if(this._unwrite)this._unwrite();if(this.destroyed){if(writable&&writable.destroy)writable.destroy();return}if(writable===null||writable===false){this.end();return}var self=this;var unend=eos(writable,{writable:true,readable:false},destroyer(this,this._forwardEnd));var ondrain=function(){var ondrain=self._ondrain;self._ondrain=null;if(ondrain)ondrain()};var clear=function(){self._writable.removeListener("drain",ondrain);unend()};if(this._unwrite)process.nextTick(ondrain);this._writable=writable;this._writable.on("drain",ondrain);this._unwrite=clear;this.uncork()};Duplexify.prototype.setReadable=function(readable){if(this._unread)this._unread();if(this.destroyed){if(readable&&readable.destroy)readable.destroy();return}if(readable===null||readable===false){this.push(null);this.resume();return}var self=this;var unend=eos(readable,{writable:false,readable:true},destroyer(this));var onreadable=function(){self._forward()};var onend=function(){self.push(null)};var clear=function(){self._readable2.removeListener("readable",onreadable);self._readable2.removeListener("end",onend);unend()};this._drained=true;this._readable=readable;this._readable2=readable._readableState?readable:toStreams2(readable);this._readable2.on("readable",onreadable);this._readable2.on("end",onend);this._unread=clear;this._forward()};Duplexify.prototype._read=function(){this._drained=true;this._forward()};Duplexify.prototype._forward=function(){if(this._forwarding||!this._readable2||!this._drained)return;this._forwarding=true;var data;while(this._drained&&(data=shift(this._readable2))!==null){if(this.destroyed)continue;this._drained=this.push(data)}this._forwarding=false};Duplexify.prototype.destroy=function(err){if(this.destroyed)return;this.destroyed=true;var self=this;process.nextTick(function(){self._destroy(err)})};Duplexify.prototype._destroy=function(err){if(err){var ondrain=this._ondrain;this._ondrain=null;if(ondrain)ondrain(err);else this.emit("error",err)}if(this._forwardDestroy){if(this._readable&&this._readable.destroy)this._readable.destroy();if(this._writable&&this._writable.destroy)this._writable.destroy()}this.emit("close")};Duplexify.prototype._write=function(data,enc,cb){if(this.destroyed)return cb();if(this._corked)return onuncork(this,this._write.bind(this,data,enc,cb));if(data===SIGNAL_FLUSH)return this._finish(cb);if(!this._writable)return cb();if(this._writable.write(data)===false)this._ondrain=cb;else cb()};Duplexify.prototype._finish=function(cb){var self=this;this.emit("preend");onuncork(this,function(){end(self._forwardEnd&&self._writable,function(){if(self._writableState.prefinished===false)self._writableState.prefinished=true;self.emit("prefinish");onuncork(self,cb)})})};Duplexify.prototype.end=function(data,enc,cb){if(typeof data==="function")return this.end(null,null,data);if(typeof enc==="function")return this.end(data,null,enc);this._ended=true;if(data)this.write(data);if(!this._writableState.ending)this.write(SIGNAL_FLUSH);return stream.Writable.prototype.end.call(this,cb)};module.exports=Duplexify}).call(this,require("_process"),require("buffer").Buffer)},{_process:92,buffer:12,"end-of-stream":17,inherits:80,"readable-stream":106,"stream-shift":109}],17:[function(require,module,exports){var once=require("once");var noop=function(){};var isRequest=function(stream){return stream.setHeader&&typeof stream.abort==="function"};var isChildProcess=function(stream){return stream.stdio&&Array.isArray(stream.stdio)&&stream.stdio.length===3};var eos=function(stream,opts,callback){if(typeof opts==="function")return eos(stream,null,opts);if(!opts)opts={};callback=once(callback||noop);var ws=stream._writableState;var rs=stream._readableState;var readable=opts.readable||opts.readable!==false&&stream.readable;var writable=opts.writable||opts.writable!==false&&stream.writable;var onlegacyfinish=function(){if(!stream.writable)onfinish()};var onfinish=function(){writable=false;if(!readable)callback.call(stream)};var onend=function(){readable=false;if(!writable)callback.call(stream)};var onexit=function(exitCode){callback.call(stream,exitCode?new Error("exited with error code: "+exitCode):null)};var onerror=function(err){callback.call(stream,err)};var onclose=function(){if(readable&&!(rs&&rs.ended))return callback.call(stream,new Error("premature close"));if(writable&&!(ws&&ws.ended))return callback.call(stream,new Error("premature close"))};var onrequest=function(){stream.req.on("finish",onfinish)};if(isRequest(stream)){stream.on("complete",onfinish);stream.on("abort",onclose);if(stream.req)onrequest();else stream.on("request",onrequest)}else if(writable&&!ws){stream.on("end",onlegacyfinish);stream.on("close",onlegacyfinish)}if(isChildProcess(stream))stream.on("exit",onexit);stream.on("end",onend);stream.on("finish",onfinish);if(opts.error!==false)stream.on("error",onerror);stream.on("close",onclose);return function(){stream.removeListener("complete",onfinish);stream.removeListener("abort",onclose);stream.removeListener("request",onrequest);if(stream.req)stream.req.removeListener("finish",onfinish);stream.removeListener("end",onlegacyfinish);stream.removeListener("close",onlegacyfinish);stream.removeListener("finish",onfinish);stream.removeListener("exit",onexit);stream.removeListener("end",onend);stream.removeListener("error",onerror);stream.removeListener("close",onclose)}};module.exports=eos},{once:90}],18:[function(require,module,exports){"use strict";var value=require("../../object/valid-value");module.exports=function(){value(this).length=0;return this}},{"../../object/valid-value":54}],19:[function(require,module,exports){"use strict";var numberIsNaN=require("../../number/is-nan"),toPosInt=require("../../number/to-pos-integer"),value=require("../../object/valid-value"),indexOf=Array.prototype.indexOf,objHasOwnProperty=Object.prototype.hasOwnProperty,abs=Math.abs,floor=Math.floor;module.exports=function(searchElement){var i,length,fromIndex,val;if(!numberIsNaN(searchElement))return indexOf.apply(this,arguments);length=toPosInt(value(this).length);fromIndex=arguments[1];if(isNaN(fromIndex))fromIndex=0;else if(fromIndex>=0)fromIndex=floor(fromIndex);else fromIndex=toPosInt(this.length)-floor(abs(fromIndex));for(i=fromIndex;i=55296&&code<=56319)value+=arrayLike[++i]}value=mapFn?call.call(mapFn,thisArg,value,j):value;if(Context){desc.value=value;defineProperty(arr,j,desc)}else{arr[j]=value}++j}length=j}}if(length===undefined){length=toPosInt(arrayLike.length);if(Context)arr=new Context(length);for(i=0;i0?1:-1}},{}],29:[function(require,module,exports){"use strict";module.exports=require("./is-implemented")()?Number.isNaN:require("./shim")},{"./is-implemented":30,"./shim":31}],30:[function(require,module,exports){"use strict";module.exports=function(){var numberIsNaN=Number.isNaN;if(typeof numberIsNaN!=="function")return false;return!numberIsNaN({})&&numberIsNaN(NaN)&&!numberIsNaN(34)}},{}],31:[function(require,module,exports){"use strict";module.exports=function(value){return value!==value}},{}],32:[function(require,module,exports){"use strict";var sign=require("../math/sign"),abs=Math.abs,floor=Math.floor;module.exports=function(value){if(isNaN(value))return 0;value=Number(value);if(value===0||!isFinite(value))return value;return sign(value)*floor(abs(value))}},{"../math/sign":26}],33:[function(require,module,exports){"use strict";var toInteger=require("./to-integer"),max=Math.max;module.exports=function(value){return max(0,toInteger(value))}},{"./to-integer":32}],34:[function(require,module,exports){"use strict";var callable=require("./valid-callable"),value=require("./valid-value"),bind=Function.prototype.bind,call=Function.prototype.call,keys=Object.keys,objPropertyIsEnumerable=Object.prototype.propertyIsEnumerable;module.exports=function(method,defVal){return function(obj,cb){var list,thisArg=arguments[2],compareFn=arguments[3];obj=Object(value(obj));callable(cb);list=keys(obj);if(compareFn){list.sort(typeof compareFn==="function"?bind.call(compareFn,obj):undefined)}if(typeof method!=="function")method=list[method];return call.call(method,list,function(key,index){if(!objPropertyIsEnumerable.call(obj,key))return defVal;return call.call(cb,thisArg,obj[key],key,obj,index)})}}},{"./valid-callable":53,"./valid-value":54}],35:[function(require,module,exports){"use strict";module.exports=require("./is-implemented")()?Object.assign:require("./shim")},{"./is-implemented":36,"./shim":37}],36:[function(require,module,exports){"use strict";module.exports=function(){var assign=Object.assign,obj;if(typeof assign!=="function")return false;obj={foo:"raz"};assign(obj,{bar:"dwa"},{trzy:"trzy"});return obj.foo+obj.bar+obj.trzy==="razdwatrzy"}},{}],37:[function(require,module,exports){"use strict";var keys=require("../keys"),value=require("../valid-value"),max=Math.max;module.exports=function(dest,src){var error,i,length=max(arguments.length,2),assign;dest=Object(value(dest));assign=function(key){try{dest[key]=src[key]}catch(e){if(!error)error=e}};for(i=1;i-1}},{}],58:[function(require,module,exports){"use strict";var objToString=Object.prototype.toString,id=objToString.call("");module.exports=function(value){return typeof value==="string"||value&&typeof value==="object"&&(value instanceof String||objToString.call(value)===id)||false}},{}],59:[function(require,module,exports){"use strict";var setPrototypeOf=require("es5-ext/object/set-prototype-of"),contains=require("es5-ext/string/#/contains"),d=require("d"),Symbol=require("es6-symbol"),Iterator=require("./");var defineProperty=Object.defineProperty,ArrayIterator;ArrayIterator=module.exports=function(arr,kind){if(!(this instanceof ArrayIterator))throw new TypeError("Constructor requires 'new'");Iterator.call(this,arr);if(!kind)kind="value";else if(contains.call(kind,"key+value"))kind="key+value";else if(contains.call(kind,"key"))kind="key";else kind="value";defineProperty(this,"__kind__",d("",kind))};if(setPrototypeOf)setPrototypeOf(ArrayIterator,Iterator);delete ArrayIterator.prototype.constructor;ArrayIterator.prototype=Object.create(Iterator.prototype,{_resolve:d(function(i){if(this.__kind__==="value")return this.__list__[i];if(this.__kind__==="key+value")return[i,this.__list__[i]];return i})});defineProperty(ArrayIterator.prototype,Symbol.toStringTag,d("c","Array Iterator"))},{"./":62,d:15,"es5-ext/object/set-prototype-of":50,"es5-ext/string/#/contains":55,"es6-symbol":72}],60:[function(require,module,exports){"use strict";var isArguments=require("es5-ext/function/is-arguments"),callable=require("es5-ext/object/valid-callable"),isString=require("es5-ext/string/is-string"),get=require("./get");var isArray=Array.isArray,call=Function.prototype.call,some=Array.prototype.some;module.exports=function(iterable,cb){var mode,thisArg=arguments[2],result,doBreak,broken,i,length,char,code;if(isArray(iterable)||isArguments(iterable))mode="array";else if(isString(iterable))mode="string";else iterable=get(iterable);callable(cb);doBreak=function(){broken=true};if(mode==="array"){some.call(iterable,function(value){call.call(cb,thisArg,value,doBreak);return broken});return}if(mode==="string"){length=iterable.length;for(i=0;i=55296&&code<=56319)char+=iterable[++i]}call.call(cb,thisArg,char,doBreak);if(broken)break}return}result=iterable.next();while(!result.done){call.call(cb,thisArg,result.value,doBreak);if(broken)return;result=iterable.next()}}},{"./get":61,"es5-ext/function/is-arguments":23,"es5-ext/object/valid-callable":53,"es5-ext/string/is-string":58}],61:[function(require,module,exports){"use strict";var isArguments=require("es5-ext/function/is-arguments"),isString=require("es5-ext/string/is-string"),ArrayIterator=require("./array"),StringIterator=require("./string"),iterable=require("./valid-iterable"),iteratorSymbol=require("es6-symbol").iterator;module.exports=function(obj){if(typeof iterable(obj)[iteratorSymbol]==="function")return obj[iteratorSymbol]();if(isArguments(obj))return new ArrayIterator(obj);if(isString(obj))return new StringIterator(obj);return new ArrayIterator(obj)}},{"./array":59,"./string":64,"./valid-iterable":65,"es5-ext/function/is-arguments":23,"es5-ext/string/is-string":58,"es6-symbol":72}],62:[function(require,module,exports){"use strict";var clear=require("es5-ext/array/#/clear"),assign=require("es5-ext/object/assign"),callable=require("es5-ext/object/valid-callable"),value=require("es5-ext/object/valid-value"),d=require("d"),autoBind=require("d/auto-bind"),Symbol=require("es6-symbol");var defineProperty=Object.defineProperty,defineProperties=Object.defineProperties,Iterator;module.exports=Iterator=function(list,context){if(!(this instanceof Iterator))throw new TypeError("Constructor requires 'new'");defineProperties(this,{__list__:d("w",value(list)),__context__:d("w",context),__nextIndex__:d("w",0)});if(!context)return;callable(context.on);context.on("_add",this._onAdd);context.on("_delete",this._onDelete);context.on("_clear",this._onClear)};delete Iterator.prototype.constructor;defineProperties(Iterator.prototype,assign({_next:d(function(){var i;if(!this.__list__)return undefined;if(this.__redo__){i=this.__redo__.shift();if(i!==undefined)return i}if(this.__nextIndex__=this.__nextIndex__)return;++this.__nextIndex__;if(!this.__redo__){defineProperty(this,"__redo__",d("c",[index]));return}this.__redo__.forEach(function(redo,i){if(redo>=index)this.__redo__[i]=++redo},this);this.__redo__.push(index)}),_onDelete:d(function(index){var i;if(index>=this.__nextIndex__)return;--this.__nextIndex__;if(!this.__redo__)return;i=this.__redo__.indexOf(index);if(i!==-1)this.__redo__.splice(i,1);this.__redo__.forEach(function(redo,j){if(redo>index)this.__redo__[j]=--redo},this)}),_onClear:d(function(){if(this.__redo__)clear.call(this.__redo__);this.__nextIndex__=0})})));defineProperty(Iterator.prototype,Symbol.iterator,d(function(){return this}))},{d:15,"d/auto-bind":14,"es5-ext/array/#/clear":18,"es5-ext/object/assign":35,"es5-ext/object/valid-callable":53,"es5-ext/object/valid-value":54,"es6-symbol":72}],63:[function(require,module,exports){"use strict";var isArguments=require("es5-ext/function/is-arguments"),isValue=require("es5-ext/object/is-value"),isString=require("es5-ext/string/is-string");var iteratorSymbol=require("es6-symbol").iterator,isArray=Array.isArray;module.exports=function(value){if(!isValue(value))return false;if(isArray(value))return true;if(isString(value))return true;if(isArguments(value))return true;return typeof value[iteratorSymbol]==="function"}},{"es5-ext/function/is-arguments":23,"es5-ext/object/is-value":43,"es5-ext/string/is-string":58,"es6-symbol":72}],64:[function(require,module,exports){"use strict";var setPrototypeOf=require("es5-ext/object/set-prototype-of"),d=require("d"),Symbol=require("es6-symbol"),Iterator=require("./");var defineProperty=Object.defineProperty,StringIterator;StringIterator=module.exports=function(str){if(!(this instanceof StringIterator))throw new TypeError("Constructor requires 'new'");str=String(str);Iterator.call(this,str);defineProperty(this,"__length__",d("",str.length))};if(setPrototypeOf)setPrototypeOf(StringIterator,Iterator);delete StringIterator.prototype.constructor;StringIterator.prototype=Object.create(Iterator.prototype,{_next:d(function(){if(!this.__list__)return undefined;if(this.__nextIndex__=55296&&code<=56319)return char+this.__list__[this.__nextIndex__++];return char})});defineProperty(StringIterator.prototype,Symbol.toStringTag,d("c","String Iterator"))},{"./":62,d:15,"es5-ext/object/set-prototype-of":50,"es6-symbol":72}],65:[function(require,module,exports){"use strict";var isIterable=require("./is-iterable");module.exports=function(value){if(!isIterable(value))throw new TypeError(value+" is not iterable");return value}},{"./is-iterable":63}],66:[function(require,module,exports){"use strict";module.exports=require("./is-implemented")()?Map:require("./polyfill")},{"./is-implemented":67,"./polyfill":71}],67:[function(require,module,exports){"use strict";module.exports=function(){var map,iterator,result;if(typeof Map!=="function")return false;try{map=new Map([["raz","one"],["dwa","two"],["trzy","three"]])}catch(e){return false}if(String(map)!=="[object Map]")return false;if(map.size!==3)return false;if(typeof map.clear!=="function")return false;if(typeof map.delete!=="function")return false;if(typeof map.entries!=="function")return false;if(typeof map.forEach!=="function")return false;if(typeof map.get!=="function")return false;if(typeof map.has!=="function")return false;if(typeof map.keys!=="function")return false;if(typeof map.set!=="function")return false;if(typeof map.values!=="function")return false;iterator=map.entries();result=iterator.next();if(result.done!==false)return false;if(!result.value)return false;if(result.value[0]!=="raz")return false;if(result.value[1]!=="one")return false;return true}},{}],68:[function(require,module,exports){"use strict";module.exports=function(){if(typeof Map==="undefined")return false;return Object.prototype.toString.call(new Map)==="[object Map]"}()},{}],69:[function(require,module,exports){"use strict";module.exports=require("es5-ext/object/primitive-set")("key","value","key+value")},{"es5-ext/object/primitive-set":49}],70:[function(require,module,exports){"use strict";var setPrototypeOf=require("es5-ext/object/set-prototype-of"),d=require("d"),Iterator=require("es6-iterator"),toStringTagSymbol=require("es6-symbol").toStringTag,kinds=require("./iterator-kinds"),defineProperties=Object.defineProperties,unBind=Iterator.prototype._unBind,MapIterator;MapIterator=module.exports=function(map,kind){if(!(this instanceof MapIterator))return new MapIterator(map,kind);Iterator.call(this,map.__mapKeysData__,map);if(!kind||!kinds[kind])kind="key+value";defineProperties(this,{__kind__:d("",kind),__values__:d("w",map.__mapValuesData__)})};if(setPrototypeOf)setPrototypeOf(MapIterator,Iterator);MapIterator.prototype=Object.create(Iterator.prototype,{constructor:d(MapIterator),_resolve:d(function(i){if(this.__kind__==="value")return this.__values__[i];if(this.__kind__==="key")return this.__list__[i];return[this.__list__[i],this.__values__[i]]}),_unBind:d(function(){this.__values__=null;unBind.call(this)}),toString:d(function(){return"[object Map Iterator]"})});Object.defineProperty(MapIterator.prototype,toStringTagSymbol,d("c","Map Iterator"))},{"./iterator-kinds":69,d:15,"es5-ext/object/set-prototype-of":50,"es6-iterator":62,"es6-symbol":72}],71:[function(require,module,exports){"use strict";var clear=require("es5-ext/array/#/clear"),eIndexOf=require("es5-ext/array/#/e-index-of"),setPrototypeOf=require("es5-ext/object/set-prototype-of"),callable=require("es5-ext/object/valid-callable"),validValue=require("es5-ext/object/valid-value"),d=require("d"),ee=require("event-emitter"),Symbol=require("es6-symbol"),iterator=require("es6-iterator/valid-iterable"),forOf=require("es6-iterator/for-of"),Iterator=require("./lib/iterator"),isNative=require("./is-native-implemented"),call=Function.prototype.call,defineProperties=Object.defineProperties,getPrototypeOf=Object.getPrototypeOf,MapPoly;module.exports=MapPoly=function(){var iterable=arguments[0],keys,values,self;if(!(this instanceof MapPoly))throw new TypeError("Constructor requires 'new'");if(isNative&&setPrototypeOf&&Map!==MapPoly){self=setPrototypeOf(new Map,getPrototypeOf(this))}else{self=this}if(iterable!=null)iterator(iterable);defineProperties(self,{__mapKeysData__:d("c",keys=[]),__mapValuesData__:d("c",values=[])});if(!iterable)return self;forOf(iterable,function(value){var key=validValue(value)[0];value=value[1];if(eIndexOf.call(keys,key)!==-1)return;keys.push(key);values.push(value)},self);return self};if(isNative){if(setPrototypeOf)setPrototypeOf(MapPoly,Map);MapPoly.prototype=Object.create(Map.prototype,{constructor:d(MapPoly)})}ee(defineProperties(MapPoly.prototype,{clear:d(function(){if(!this.__mapKeysData__.length)return;clear.call(this.__mapKeysData__);clear.call(this.__mapValuesData__);this.emit("_clear")}),delete:d(function(key){var index=eIndexOf.call(this.__mapKeysData__,key);if(index===-1)return false;this.__mapKeysData__.splice(index,1);this.__mapValuesData__.splice(index,1);this.emit("_delete",index,key);return true}),entries:d(function(){return new Iterator(this,"key+value")}),forEach:d(function(cb){var thisArg=arguments[1],iterator,result;callable(cb);iterator=this.entries();result=iterator._next();while(result!==undefined){call.call(cb,thisArg,this.__mapValuesData__[result],this.__mapKeysData__[result],this);result=iterator._next()}}),get:d(function(key){var index=eIndexOf.call(this.__mapKeysData__,key);if(index===-1)return;return this.__mapValuesData__[index]}),has:d(function(key){return eIndexOf.call(this.__mapKeysData__,key)!==-1}),keys:d(function(){return new Iterator(this,"key")}),set:d(function(key,value){var index=eIndexOf.call(this.__mapKeysData__,key),emit;if(index===-1){index=this.__mapKeysData__.push(key)-1;emit=true}this.__mapValuesData__[index]=value;if(emit)this.emit("_add",index,key);return this}),size:d.gs(function(){return this.__mapKeysData__.length}),values:d(function(){return new Iterator(this,"value")}),toString:d(function(){return"[object Map]"})}));Object.defineProperty(MapPoly.prototype,Symbol.iterator,d(function(){return this.entries()}));Object.defineProperty(MapPoly.prototype,Symbol.toStringTag,d("c","Map"))},{"./is-native-implemented":68,"./lib/iterator":70,d:15,"es5-ext/array/#/clear":18,"es5-ext/array/#/e-index-of":19,"es5-ext/object/set-prototype-of":50,"es5-ext/object/valid-callable":53,"es5-ext/object/valid-value":54,"es6-iterator/for-of":60,"es6-iterator/valid-iterable":65,"es6-symbol":72,"event-emitter":77}],72:[function(require,module,exports){"use strict";module.exports=require("./is-implemented")()?Symbol:require("./polyfill")},{"./is-implemented":73,"./polyfill":75}],73:[function(require,module,exports){"use strict";var validTypes={object:true,symbol:true};module.exports=function(){var symbol;if(typeof Symbol!=="function")return false;symbol=Symbol("test symbol");try{String(symbol)}catch(e){return false}if(!validTypes[typeof Symbol.iterator])return false;if(!validTypes[typeof Symbol.toPrimitive])return false;if(!validTypes[typeof Symbol.toStringTag])return false;return true}},{}],74:[function(require,module,exports){"use strict";module.exports=function(x){if(!x)return false;if(typeof x==="symbol")return true;if(!x.constructor)return false;if(x.constructor.name!=="Symbol")return false;return x[x.constructor.toStringTag]==="Symbol"}},{}],75:[function(require,module,exports){"use strict";var d=require("d"),validateSymbol=require("./validate-symbol"),create=Object.create,defineProperties=Object.defineProperties,defineProperty=Object.defineProperty,objPrototype=Object.prototype,NativeSymbol,SymbolPolyfill,HiddenSymbol,globalSymbols=create(null),isNativeSafe;if(typeof Symbol==="function"){NativeSymbol=Symbol;try{String(NativeSymbol());isNativeSafe=true}catch(ignore){}}var generateName=function(){var created=create(null);return function(desc){var postfix=0,name,ie11BugWorkaround;while(created[desc+(postfix||"")])++postfix;desc+=postfix||"";created[desc]=true;name="@@"+desc;defineProperty(objPrototype,name,d.gs(null,function(value){if(ie11BugWorkaround)return;ie11BugWorkaround=true;defineProperty(this,name,d(value));ie11BugWorkaround=false}));return name}}();HiddenSymbol=function Symbol(description){if(this instanceof HiddenSymbol)throw new TypeError("Symbol is not a constructor");return SymbolPolyfill(description)};module.exports=SymbolPolyfill=function Symbol(description){var symbol;if(this instanceof Symbol)throw new TypeError("Symbol is not a constructor");if(isNativeSafe)return NativeSymbol(description);symbol=create(HiddenSymbol.prototype);description=description===undefined?"":String(description);return defineProperties(symbol,{__description__:d("",description),__name__:d("",generateName(description))})};defineProperties(SymbolPolyfill,{for:d(function(key){if(globalSymbols[key])return globalSymbols[key];return globalSymbols[key]=SymbolPolyfill(String(key))}),keyFor:d(function(s){var key;validateSymbol(s);for(key in globalSymbols)if(globalSymbols[key]===s)return key}),hasInstance:d("",NativeSymbol&&NativeSymbol.hasInstance||SymbolPolyfill("hasInstance")),isConcatSpreadable:d("",NativeSymbol&&NativeSymbol.isConcatSpreadable||SymbolPolyfill("isConcatSpreadable")),iterator:d("",NativeSymbol&&NativeSymbol.iterator||SymbolPolyfill("iterator")),match:d("",NativeSymbol&&NativeSymbol.match||SymbolPolyfill("match")),replace:d("",NativeSymbol&&NativeSymbol.replace||SymbolPolyfill("replace")),search:d("",NativeSymbol&&NativeSymbol.search||SymbolPolyfill("search")),species:d("",NativeSymbol&&NativeSymbol.species||SymbolPolyfill("species")),split:d("",NativeSymbol&&NativeSymbol.split||SymbolPolyfill("split")),toPrimitive:d("",NativeSymbol&&NativeSymbol.toPrimitive||SymbolPolyfill("toPrimitive")),toStringTag:d("",NativeSymbol&&NativeSymbol.toStringTag||SymbolPolyfill("toStringTag")),unscopables:d("",NativeSymbol&&NativeSymbol.unscopables||SymbolPolyfill("unscopables"))});defineProperties(HiddenSymbol.prototype,{constructor:d(SymbolPolyfill),toString:d("",function(){return this.__name__})});defineProperties(SymbolPolyfill.prototype,{toString:d(function(){return"Symbol ("+validateSymbol(this).__description__+")"}),valueOf:d(function(){return validateSymbol(this)})});defineProperty(SymbolPolyfill.prototype,SymbolPolyfill.toPrimitive,d("",function(){var symbol=validateSymbol(this);if(typeof symbol==="symbol")return symbol;return symbol.toString()}));defineProperty(SymbolPolyfill.prototype,SymbolPolyfill.toStringTag,d("c","Symbol"));defineProperty(HiddenSymbol.prototype,SymbolPolyfill.toStringTag,d("c",SymbolPolyfill.prototype[SymbolPolyfill.toStringTag]));defineProperty(HiddenSymbol.prototype,SymbolPolyfill.toPrimitive,d("c",SymbolPolyfill.prototype[SymbolPolyfill.toPrimitive]))},{"./validate-symbol":76,d:15}],76:[function(require,module,exports){"use strict";var isSymbol=require("./is-symbol");module.exports=function(value){if(!isSymbol(value))throw new TypeError(value+" is not a symbol");return value}},{"./is-symbol":74}],77:[function(require,module,exports){"use strict";var d=require("d"),callable=require("es5-ext/object/valid-callable"),apply=Function.prototype.apply,call=Function.prototype.call,create=Object.create,defineProperty=Object.defineProperty,defineProperties=Object.defineProperties,hasOwnProperty=Object.prototype.hasOwnProperty,descriptor={configurable:true,enumerable:false,writable:true},on,once,off,emit,methods,descriptors,base;on=function(type,listener){var data;callable(listener);if(!hasOwnProperty.call(this,"__ee__")){data=descriptor.value=create(null);defineProperty(this,"__ee__",descriptor);descriptor.value=null}else{data=this.__ee__}if(!data[type])data[type]=listener;else if(typeof data[type]==="object")data[type].push(listener);else data[type]=[data[type],listener];return this};once=function(type,listener){var once,self;callable(listener);self=this;on.call(this,type,once=function(){off.call(self,type,once);apply.call(listener,this,arguments)});once.__eeOnceListener__=listener;return this};off=function(type,listener){var data,listeners,candidate,i;callable(listener);if(!hasOwnProperty.call(this,"__ee__"))return this;data=this.__ee__;if(!data[type])return this;listeners=data[type];if(typeof listeners==="object"){for(i=0;candidate=listeners[i];++i){if(candidate===listener||candidate.__eeOnceListener__===listener){if(listeners.length===2)data[type]=listeners[i?0:1];else listeners.splice(i,1)}}}else{if(listeners===listener||listeners.__eeOnceListener__===listener){delete data[type]}}return this};emit=function(type){var i,l,listener,listeners,args;if(!hasOwnProperty.call(this,"__ee__"))return;listeners=this.__ee__[type];if(!listeners)return;if(typeof listeners==="object"){l=arguments.length;args=new Array(l-1);for(i=1;i1)er=arguments[1];if(er instanceof Error){throw er}else{var err=new Error('Unhandled "error" event. ('+er+")");err.context=er;throw err}return false}handler=events[type];if(!handler)return false;var isFn=typeof handler==="function";len=arguments.length;switch(len){case 1:emitNone(handler,isFn,this);break;case 2:emitOne(handler,isFn,this,arguments[1]);break;case 3:emitTwo(handler,isFn,this,arguments[1],arguments[2]);break;case 4:emitThree(handler,isFn,this,arguments[1],arguments[2],arguments[3]);break;default:args=new Array(len-1);for(i=1;i0&&existing.length>m){existing.warned=true;var w=new Error("Possible EventEmitter memory leak detected. "+existing.length+' "'+String(type)+'" listeners '+"added. Use emitter.setMaxListeners() to "+"increase limit.");w.name="MaxListenersExceededWarning";w.emitter=target;w.type=type;w.count=existing.length;if(typeof console==="object"&&console.warn){console.warn("%s: %s",w.name,w.message)}}}}return target}EventEmitter.prototype.addListener=function addListener(type,listener){return _addListener(this,type,listener,false)};EventEmitter.prototype.on=EventEmitter.prototype.addListener;EventEmitter.prototype.prependListener=function prependListener(type,listener){return _addListener(this,type,listener,true)};function onceWrapper(){if(!this.fired){this.target.removeListener(this.type,this.wrapFn);this.fired=true;switch(arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:var args=new Array(arguments.length);for(var i=0;i=0;i--){if(list[i]===listener||list[i].listener===listener){originalListener=list[i].listener;position=i;break}}if(position<0)return this;if(position===0)list.shift();else spliceOne(list,position);if(list.length===1)events[type]=list[0];if(events.removeListener)this.emit("removeListener",type,originalListener||listener)}return this};EventEmitter.prototype.removeAllListeners=function removeAllListeners(type){var listeners,events,i;events=this._events;if(!events)return this;if(!events.removeListener){if(arguments.length===0){this._events=objectCreate(null);this._eventsCount=0}else if(events[type]){if(--this._eventsCount===0)this._events=objectCreate(null);else delete events[type]}return this}if(arguments.length===0){var keys=objectKeys(events);var key;for(i=0;i=0;i--){this.removeListener(type,listeners[i])}}return this};function _listeners(target,type,unwrap){var events=target._events;if(!events)return[];var evlistener=events[type];if(!evlistener)return[];if(typeof evlistener==="function")return unwrap?[evlistener.listener||evlistener]:[evlistener];return unwrap?unwrapListeners(evlistener):arrayClone(evlistener,evlistener.length)}EventEmitter.prototype.listeners=function listeners(type){return _listeners(this,type,true)};EventEmitter.prototype.rawListeners=function rawListeners(type){return _listeners(this,type,false)};EventEmitter.listenerCount=function(emitter,type){if(typeof emitter.listenerCount==="function"){return emitter.listenerCount(type)}else{return listenerCount.call(emitter,type)}};EventEmitter.prototype.listenerCount=listenerCount;function listenerCount(type){var events=this._events;if(events){var evlistener=events[type];if(typeof evlistener==="function"){return 1}else if(evlistener){return evlistener.length}}return 0}EventEmitter.prototype.eventNames=function eventNames(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};function spliceOne(list,index){for(var i=index,k=i+1,n=list.length;k>1;var nBits=-7;var i=isLE?nBytes-1:0;var d=isLE?-1:1;var 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;var eLen=nBytes*8-mLen-1;var eMax=(1<>1;var rt=mLen===23?Math.pow(2,-24)-Math.pow(2,-77):0;var i=isLE?0:nBytes-1;var d=isLE?1:-1;var 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<0;buffer[offset+i]=e&255,i+=d,e/=256,eLen-=8){}buffer[offset+i-d]|=s*128}},{}],80:[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}}},{}],81:[function(require,module,exports){module.exports=function(obj){return obj!=null&&(isBuffer(obj)||isSlowBuffer(obj)||!!obj._isBuffer)};function isBuffer(obj){return!!obj.constructor&&typeof obj.constructor.isBuffer==="function"&&obj.constructor.isBuffer(obj)}function isSlowBuffer(obj){return typeof obj.readFloatLE==="function"&&typeof obj.slice==="function"&&isBuffer(obj.slice(0,0))}},{}],82:[function(require,module,exports){var toString={}.toString;module.exports=Array.isArray||function(arr){return toString.call(arr)=="[object Array]"}},{}],83:[function(require,module,exports){"use strict";var Buffer=require("safe-buffer").Buffer;var protocol=module.exports;protocol.types={0:"reserved",1:"connect",2:"connack",3:"publish",4:"puback",5:"pubrec",6:"pubrel",7:"pubcomp",8:"subscribe",9:"suback",10:"unsubscribe",11:"unsuback",12:"pingreq",13:"pingresp",14:"disconnect",15:"auth"};protocol.codes={};for(var k in protocol.types){var v=protocol.types[k];protocol.codes[v]=k}protocol.CMD_SHIFT=4;protocol.CMD_MASK=240;protocol.DUP_MASK=8;protocol.QOS_MASK=3;protocol.QOS_SHIFT=1;protocol.RETAIN_MASK=1;protocol.LENGTH_MASK=127;protocol.LENGTH_FIN_MASK=128;protocol.SESSIONPRESENT_MASK=1;protocol.SESSIONPRESENT_HEADER=Buffer.from([protocol.SESSIONPRESENT_MASK]);protocol.CONNACK_HEADER=Buffer.from([protocol.codes["connack"]<>8,0);buffer.writeUInt8(i&255,0+1);return buffer}function generateCache(){for(var i=0;i=0&&length<128)return 1;else if(length>=128&&length<16384)return 2;else if(length>=16384&&length<2097152)return 3;else if(length>=2097152&&length<268435456)return 4;else return 0}function genBufVariableByteInt(num){var digit=0;var pos=0;var length=calcVariableByteIntLength(num);var buffer=Buffer.allocUnsafe(length);do{digit=num%128|0;num=num/128|0;if(num>0)digit=digit|128;buffer.writeUInt8(digit,pos++)}while(num>0);return{data:buffer,length:length}}function generate4ByteBuffer(num){var buffer=Buffer.allocUnsafe(4);buffer.writeUInt32BE(num,0);return buffer}module.exports={cache:cache,generateCache:generateCache,generateNumber:generateBuffer,genBufVariableByteInt:genBufVariableByteInt,generate4ByteBuffer:generate4ByteBuffer}},{"safe-buffer":108}],87:[function(require,module,exports){function Packet(){this.cmd=null;this.retain=false;this.qos=0;this.dup=false;this.length=-1;this.topic=null;this.payload=null}module.exports=Packet},{}],88:[function(require,module,exports){"use strict";var bl=require("bl");var inherits=require("inherits");var EE=require("events").EventEmitter;var Packet=require("./packet");var constants=require("./constants");function Parser(opt){if(!(this instanceof Parser))return new Parser(opt);this.settings=opt||{};this._states=["_parseHeader","_parseLength","_parsePayload","_newPacket"];this._resetState()}inherits(Parser,EE);Parser.prototype._resetState=function(){this.packet=new Packet;this.error=null;this._list=bl();this._stateCounter=0};Parser.prototype.parse=function(buf){if(this.error)this._resetState();this._list.append(buf);while((this.packet.length!==-1||this._list.length>0)&&this[this._states[this._stateCounter]]()&&!this.error){this._stateCounter++;if(this._stateCounter>=this._states.length)this._stateCounter=0}return this._list.length};Parser.prototype._parseHeader=function(){var zero=this._list.readUInt8(0);this.packet.cmd=constants.types[zero>>constants.CMD_SHIFT];this.packet.retain=(zero&constants.RETAIN_MASK)!==0;this.packet.qos=zero>>constants.QOS_SHIFT&constants.QOS_MASK;this.packet.dup=(zero&constants.DUP_MASK)!==0;this._list.consume(1);return true};Parser.prototype._parseLength=function(){var result=this._parseVarByteNum(true);if(result){this.packet.length=result.value;this._list.consume(result.bytes)}return!!result};Parser.prototype._parsePayload=function(){var result=false;if(this.packet.length===0||this._list.length>=this.packet.length){this._pos=0;switch(this.packet.cmd){case"connect":this._parseConnect();break;case"connack":this._parseConnack();break;case"publish":this._parsePublish();break;case"puback":case"pubrec":case"pubrel":case"pubcomp":this._parseConfirmation();break;case"subscribe":this._parseSubscribe();break;case"suback":this._parseSuback();break;case"unsubscribe":this._parseUnsubscribe();break;case"unsuback":this._parseUnsuback();break;case"pingreq":case"pingresp":break;case"disconnect":this._parseDisconnect();break;case"auth":this._parseAuth();break;default:this._emitError(new Error("Not supported"))}result=true}return result};Parser.prototype._parseConnect=function(){var protocolId;var clientId;var topic;var payload;var password;var username;var flags={};var packet=this.packet;protocolId=this._parseString();if(protocolId===null)return this._emitError(new Error("Cannot parse protocolId"));if(protocolId!=="MQTT"&&protocolId!=="MQIsdp"){return this._emitError(new Error("Invalid protocolId"))}packet.protocolId=protocolId;if(this._pos>=this._list.length)return this._emitError(new Error("Packet too short"));packet.protocolVersion=this._list.readUInt8(this._pos);if(packet.protocolVersion!==3&&packet.protocolVersion!==4&&packet.protocolVersion!==5){return this._emitError(new Error("Invalid protocol version"))}this._pos++;if(this._pos>=this._list.length){return this._emitError(new Error("Packet too short"))}flags.username=this._list.readUInt8(this._pos)&constants.USERNAME_MASK;flags.password=this._list.readUInt8(this._pos)&constants.PASSWORD_MASK;flags.will=this._list.readUInt8(this._pos)&constants.WILL_FLAG_MASK;if(flags.will){packet.will={};packet.will.retain=(this._list.readUInt8(this._pos)&constants.WILL_RETAIN_MASK)!==0;packet.will.qos=(this._list.readUInt8(this._pos)&constants.WILL_QOS_MASK)>>constants.WILL_QOS_SHIFT}packet.clean=(this._list.readUInt8(this._pos)&constants.CLEAN_SESSION_MASK)!==0;this._pos++;packet.keepalive=this._parseNum();if(packet.keepalive===-1)return this._emitError(new Error("Packet too short"));if(packet.protocolVersion===5){var properties=this._parseProperties();if(Object.getOwnPropertyNames(properties).length){packet.properties=properties}}clientId=this._parseString();if(clientId===null)return this._emitError(new Error("Packet too short"));packet.clientId=clientId;if(flags.will){if(packet.protocolVersion===5){var willProperties=this._parseProperties();if(Object.getOwnPropertyNames(willProperties).length){packet.will.properties=willProperties}}topic=this._parseString();if(topic===null)return this._emitError(new Error("Cannot parse will topic"));packet.will.topic=topic;payload=this._parseBuffer();if(payload===null)return this._emitError(new Error("Cannot parse will payload"));packet.will.payload=payload}if(flags.username){username=this._parseString();if(username===null)return this._emitError(new Error("Cannot parse username"));packet.username=username}if(flags.password){password=this._parseBuffer();if(password===null)return this._emitError(new Error("Cannot parse password"));packet.password=password}this.settings=packet;return packet};Parser.prototype._parseConnack=function(){var packet=this.packet;if(this._list.length<2)return null;packet.sessionPresent=!!(this._list.readUInt8(this._pos++)&constants.SESSIONPRESENT_MASK);if(this.settings.protocolVersion===5){packet.reasonCode=this._list.readUInt8(this._pos++)}else{packet.returnCode=this._list.readUInt8(this._pos++)}if(packet.returnCode===-1||packet.reasonCode===-1)return this._emitError(new Error("Cannot parse return code"));if(this.settings.protocolVersion===5){var properties=this._parseProperties();if(Object.getOwnPropertyNames(properties).length){packet.properties=properties}}};Parser.prototype._parsePublish=function(){var packet=this.packet;packet.topic=this._parseString();if(packet.topic===null)return this._emitError(new Error("Cannot parse topic"));if(packet.qos>0)if(!this._parseMessageId()){return}if(this.settings.protocolVersion===5){var properties=this._parseProperties();if(Object.getOwnPropertyNames(properties).length){packet.properties=properties}}packet.payload=this._list.slice(this._pos,packet.length)};Parser.prototype._parseSubscribe=function(){var packet=this.packet;var topic;var options;var qos;var rh;var rap;var nl;var subscription;if(packet.qos!==1){return this._emitError(new Error("Wrong subscribe header"))}packet.subscriptions=[];if(!this._parseMessageId()){return}if(this.settings.protocolVersion===5){var properties=this._parseProperties();if(Object.getOwnPropertyNames(properties).length){packet.properties=properties}}while(this._pos>constants.SUBSCRIBE_OPTIONS_NL_SHIFT&constants.SUBSCRIBE_OPTIONS_NL_MASK)!==0;rap=(options>>constants.SUBSCRIBE_OPTIONS_RAP_SHIFT&constants.SUBSCRIBE_OPTIONS_RAP_MASK)!==0;rh=options>>constants.SUBSCRIBE_OPTIONS_RH_SHIFT&constants.SUBSCRIBE_OPTIONS_RH_MASK;subscription={topic:topic,qos:qos};if(this.settings.protocolVersion===5){subscription.nl=nl;subscription.rap=rap;subscription.rh=rh}packet.subscriptions.push(subscription)}};Parser.prototype._parseSuback=function(){var packet=this.packet;this.packet.granted=[];if(!this._parseMessageId()){return}if(this.settings.protocolVersion===5){var properties=this._parseProperties();if(Object.getOwnPropertyNames(properties).length){packet.properties=properties}}while(this._pos2){packet.reasonCode=this._parseByte();var properties=this._parseProperties();if(Object.getOwnPropertyNames(properties).length){packet.properties=properties}}}return true};Parser.prototype._parseDisconnect=function(){var packet=this.packet;if(this.settings.protocolVersion===5){packet.reasonCode=this._parseByte();var properties=this._parseProperties();if(Object.getOwnPropertyNames(properties).length){packet.properties=properties}}return true};Parser.prototype._parseAuth=function(){var packet=this.packet;if(this.settings.protocolVersion!==5){return this._emitError(new Error("Not supported auth packet for this version MQTT"))}packet.reasonCode=this._parseByte();var properties=this._parseProperties();if(Object.getOwnPropertyNames(properties).length){packet.properties=properties}return true};Parser.prototype._parseMessageId=function(){var packet=this.packet;packet.messageId=this._parseNum();if(packet.messageId===null){this._emitError(new Error("Cannot parse messageId"));return false}return true};Parser.prototype._parseString=function(maybeBuffer){var length=this._parseNum();var result;var end=length+this._pos;if(length===-1||end>this._list.length||end>this.packet.length)return null;result=this._list.toString("utf8",this._pos,end);this._pos+=length;return result};Parser.prototype._parseStringPair=function(){return{name:this._parseString(),value:this._parseString()}};Parser.prototype._parseBuffer=function(){var length=this._parseNum();var result;var end=length+this._pos;if(length===-1||end>this._list.length||end>this.packet.length)return null;result=this._list.slice(this._pos,end);this._pos+=length;return result};Parser.prototype._parseNum=function(){if(this._list.length-this._pos<2)return-1;var result=this._list.readUInt16BE(this._pos);this._pos+=2;return result};Parser.prototype._parse4ByteNum=function(){if(this._list.length-this._pos<4)return-1;var result=this._list.readUInt32BE(this._pos);this._pos+=4;return result};Parser.prototype._parseVarByteNum=function(fullInfoFlag){var bytes=0;var mul=1;var length=0;var result=true;var current;var padding=this._pos?this._pos:0;while(bytes<5){current=this._list.readUInt8(padding+bytes++);length+=mul*(current&constants.LENGTH_MASK);mul*=128;if((current&constants.LENGTH_FIN_MASK)===0)break;if(this._list.length<=bytes){result=false;break}}if(padding){this._pos+=bytes}result=result?fullInfoFlag?{bytes:bytes,value:length}:length:false;return result};Parser.prototype._parseByte=function(){var result=this._list.readUInt8(this._pos);this._pos++;return result};Parser.prototype._parseByType=function(type){switch(type){case"byte":{return this._parseByte()!==0}case"int8":{return this._parseByte()}case"int16":{return this._parseNum()}case"int32":{return this._parse4ByteNum()}case"var":{return this._parseVarByteNum()}case"string":{return this._parseString()}case"pair":{return this._parseStringPair()}case"binary":{return this._parseBuffer()}}};Parser.prototype._parseProperties=function(){var length=this._parseVarByteNum();var start=this._pos;var end=start+length;var result={};while(this._pos65535||keepalive%1!==0){stream.emit("error",new Error("Invalid keepalive"));return false}else length+=2;length+=1;if(protocolVersion===5){var propertiesData=getProperties(stream,properties);length+=propertiesData.length}if(will){if(typeof will!=="object"){stream.emit("error",new Error("Invalid will"));return false}if(!will.topic||typeof will.topic!=="string"){stream.emit("error",new Error("Invalid will topic"));return false}else{length+=Buffer.byteLength(will.topic)+2}if(will.payload){if(will.payload.length>=0){if(typeof will.payload==="string"){length+=Buffer.byteLength(will.payload)+2}else{length+=will.payload.length+2}}else{stream.emit("error",new Error("Invalid will payload"));return false}var willProperties={};if(protocolVersion===5){willProperties=getProperties(stream,will.properties);length+=willProperties.length}}}var providedUsername=false;if(username!=null){if(isStringOrBuffer(username)){providedUsername=true;length+=Buffer.byteLength(username)+2}else{stream.emit("error",new Error("Invalid username"));return false}}if(password!=null){if(!providedUsername){stream.emit("error",new Error("Username is required to use password"));return false}if(isStringOrBuffer(password)){length+=byteLength(password)+2}else{stream.emit("error",new Error("Invalid password"));return false}}stream.write(protocol.CONNECT_HEADER);writeVarByteInt(stream,length);writeStringOrBuffer(stream,protocolId);stream.write(protocolVersion===4?protocol.VERSION4:protocolVersion===5?protocol.VERSION5:protocol.VERSION3);var flags=0;flags|=username!=null?protocol.USERNAME_MASK:0;flags|=password!=null?protocol.PASSWORD_MASK:0;flags|=will&&will.retain?protocol.WILL_RETAIN_MASK:0;flags|=will&&will.qos?will.qos<0)writeNumber(stream,id);if(propertiesData!=null){propertiesData.write()}return stream.write(payload)}function confirmation(packet,stream,opts){var version=opts?opts.protocolVersion:4;var settings=packet||{};var type=settings.cmd||"puback";var id=settings.messageId;var dup=settings.dup&&type==="pubrel"?protocol.DUP_MASK:0;var qos=0;var reasonCode=settings.reasonCode;var properties=settings.properties;var length=version===5?3:2;if(type==="pubrel")qos=1;if(typeof id!=="number"){stream.emit("error",new Error("Invalid messageId"));return false}var propertiesData=null;if(version===5){propertiesData=getPropertiesByMaximumPacketSize(stream,properties,opts,length);if(!propertiesData){return false}length+=propertiesData.length}stream.write(protocol.ACKS[type][qos][dup][0]);writeVarByteInt(stream,length);writeNumber(stream,id);if(version===5){stream.write(Buffer.from([reasonCode]))}if(propertiesData!==null){propertiesData.write()}return true}function subscribe(packet,stream,opts){var version=opts?opts.protocolVersion:4;var settings=packet||{};var dup=settings.dup?protocol.DUP_MASK:0;var id=settings.messageId;var subs=settings.subscriptions;var properties=settings.properties;var length=0;if(typeof id!=="number"){stream.emit("error",new Error("Invalid messageId"));return false}else length+=2;var propertiesData=null;if(version===5){propertiesData=getProperties(stream,properties);length+=propertiesData.length}if(typeof subs==="object"&&subs.length){for(var i=0;i2){stream.emit("error",new Error("Invalid subscriptions - invalid Retain Handling"));return false}}length+=Buffer.byteLength(itopic)+2+1}}else{stream.emit("error",new Error("Invalid subscriptions"));return false}stream.write(protocol.SUBSCRIBE_HEADER[1][dup?1:0][0]);writeVarByteInt(stream,length);writeNumber(stream,id);if(propertiesData!==null){propertiesData.write()}var result=true;for(var j=0;jmaximumPacketSize){var currentMayEmptyProp=mayEmptyProps.shift();if(currentMayEmptyProp&&properties[currentMayEmptyProp]){delete properties[currentMayEmptyProp];propertiesData=getProperties(stream,properties)}else{return false}}}return propertiesData}function writeProperties(stream,properties,propertiesLength){writeVarByteInt(stream,propertiesLength);for(var propName in properties){if(properties.hasOwnProperty(propName)&&properties[propName]!==null){var value=properties[propName];var type=protocol.propertiesTypes[propName];switch(type){case"byte":{stream.write(Buffer.from([protocol.properties[propName]]));stream.write(Buffer.from([+value]));break}case"int8":{stream.write(Buffer.from([protocol.properties[propName]]));stream.write(Buffer.from([value]));break}case"binary":{stream.write(Buffer.from([protocol.properties[propName]]));writeStringOrBuffer(stream,value);break}case"int16":{stream.write(Buffer.from([protocol.properties[propName]]));writeNumber(stream,value);break}case"int32":{stream.write(Buffer.from([protocol.properties[propName]]));write4ByteNumber(stream,value);break}case"var":{stream.write(Buffer.from([protocol.properties[propName]]));writeVarByteInt(stream,value);break}case"string":{stream.write(Buffer.from([protocol.properties[propName]]));writeString(stream,value);break}case"pair":{Object.getOwnPropertyNames(value).forEach(function(name){stream.write(Buffer.from([protocol.properties[propName]]));writeStringPair(stream,name.toString(),value[name].toString())});break}default:{stream.emit("error",new Error("Invalid property "+propName));return false}}}}}function byteLength(bufOrString){if(!bufOrString)return 0;else if(bufOrString instanceof Buffer)return bufOrString.length;else return Buffer.byteLength(bufOrString)}function isStringOrBuffer(field){return typeof field==="string"||field instanceof Buffer}module.exports=generate},{"./constants":83,"./numbers":86,"process-nextick-args":91,"safe-buffer":108}],90:[function(require,module,exports){var wrappy=require("wrappy");module.exports=wrappy(once);module.exports.strict=wrappy(onceStrict);once.proto=once(function(){Object.defineProperty(Function.prototype,"once",{value:function(){return once(this)},configurable:true});Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return onceStrict(this)},configurable:true})});function once(fn){var f=function(){if(f.called)return f.value;f.called=true;return f.value=fn.apply(this,arguments)};f.called=false;return f}function onceStrict(fn){var f=function(){if(f.called)throw new Error(f.onceError);f.called=true;return f.value=fn.apply(this,arguments)};var name=fn.name||"Function wrapped with `once`";f.onceError=name+" shouldn't be called more than once";f.called=false;return f}},{wrappy:119}],91:[function(require,module,exports){(function(process){"use strict";if(!process.version||process.version.indexOf("v0.")===0||process.version.indexOf("v1.")===0&&process.version.indexOf("v1.8.")!==0){module.exports={nextTick:nextTick}}else{module.exports=process}function nextTick(fn,arg1,arg2,arg3){if(typeof fn!=="function"){throw new TypeError('"callback" argument must be a function')}var len=arguments.length;var args,i;switch(len){case 0:case 1:return process.nextTick(fn);case 2:return process.nextTick(function afterTickOne(){fn.call(null,arg1)});case 3:return process.nextTick(function afterTickTwo(){fn.call(null,arg1,arg2)});case 4:return process.nextTick(function afterTickThree(){fn.call(null,arg1,arg2,arg3)});default:args=new Array(len-1);i=0;while(i1){for(var i=1;i= 0x80 (not a basic code point)","invalid-input":"Invalid input"},baseMinusTMin=base-tMin,floor=Math.floor,stringFromCharCode=String.fromCharCode,key;function error(type){throw new RangeError(errors[type])}function map(array,fn){var length=array.length;var result=[];while(length--){result[length]=fn(array[length])}return result}function mapDomain(string,fn){var parts=string.split("@");var result="";if(parts.length>1){result=parts[0]+"@";string=parts[1]}string=string.replace(regexSeparators,".");var labels=string.split(".");var encoded=map(labels,fn).join(".");return result+encoded}function ucs2decode(string){var output=[],counter=0,length=string.length,value,extra;while(counter=55296&&value<=56319&&counter65535){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=128){error("not-basic")}output.push(input.charCodeAt(j))}for(index=basic>0?basic+1:0;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(digitfloor(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=n&¤tValuefloor((maxInt-delta)/handledCPCountPlusOne)){error("overflow")}delta+=(m-n)*handledCPCountPlusOne;n=m;for(j=0;jmaxInt){error("overflow")}if(currentValue==n){for(q=delta,k=base;;k+=base){t=k<=bias?tMin:k>=bias+tMax?tMax:k-bias;if(q0&&len>maxKeys){len=maxKeys}for(var i=0;i=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]"}},{}],95:[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 map(obj[k],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;i0){if(typeof chunk!=="string"&&!state.objectMode&&Object.getPrototypeOf(chunk)!==Buffer.prototype){chunk=_uint8ArrayToBuffer(chunk)}if(addToFront){if(state.endEmitted)stream.emit("error",new Error("stream.unshift() after end event"));else addChunk(stream,state,chunk,true)}else if(state.ended){stream.emit("error",new Error("stream.push() after EOF"))}else{state.reading=false;if(state.decoder&&!encoding){chunk=state.decoder.write(chunk);if(state.objectMode||chunk.length!==0)addChunk(stream,state,chunk,false);else maybeReadMore(stream,state)}else{addChunk(stream,state,chunk,false)}}}else if(!addToFront){state.reading=false}}return needMoreData(state)}function addChunk(stream,state,chunk,addToFront){if(state.flowing&&state.length===0&&!state.sync){stream.emit("data",chunk);stream.read(0)}else{state.length+=state.objectMode?1:chunk.length;if(addToFront)state.buffer.unshift(chunk);else state.buffer.push(chunk);if(state.needReadable)emitReadable(stream)}maybeReadMore(stream,state)}function chunkInvalid(state,chunk){var er;if(!_isUint8Array(chunk)&&typeof chunk!=="string"&&chunk!==undefined&&!state.objectMode){er=new TypeError("Invalid non-string/buffer chunk")}return er}function needMoreData(state){return!state.ended&&(state.needReadable||state.length=MAX_HWM){n=MAX_HWM}else{n--;n|=n>>>1;n|=n>>>2;n|=n>>>4;n|=n>>>8;n|=n>>>16;n++}return n}function howMuchToRead(n,state){if(n<=0||state.length===0&&state.ended)return 0;if(state.objectMode)return 1;if(n!==n){if(state.flowing&&state.length)return state.buffer.head.data.length;else return state.length}if(n>state.highWaterMark)state.highWaterMark=computeNewHighWaterMark(n);if(n<=state.length)return n;if(!state.ended){state.needReadable=true;return 0}return state.length}Readable.prototype.read=function(n){debug("read",n);n=parseInt(n,10);var state=this._readableState;var nOrig=n;if(n!==0)state.emittedReadable=false;if(n===0&&state.needReadable&&(state.length>=state.highWaterMark||state.ended)){debug("read: emitReadable",state.length,state.ended);if(state.length===0&&state.ended)endReadable(this);else 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;debug("need readable",doRead);if(state.length===0||state.length-n0)ret=fromList(n,state);else ret=null;if(ret===null){state.needReadable=true;n=0}else{state.length-=n}if(state.length===0){if(!state.ended)state.needReadable=true;if(nOrig!==n&&state.ended)endReadable(this)}if(ret!==null)this.emit("data",ret);return ret};function onEofChunk(stream,state){if(state.ended)return;if(state.decoder){var chunk=state.decoder.end();if(chunk&&chunk.length){state.buffer.push(chunk);state.length+=state.objectMode?1:chunk.length}}state.ended=true;emitReadable(stream)}function emitReadable(stream){var state=stream._readableState;state.needReadable=false;if(!state.emittedReadable){debug("emitReadable",state.flowing);state.emittedReadable=true;if(state.sync)pna.nextTick(emitReadable_,stream);else emitReadable_(stream)}}function emitReadable_(stream){debug("emit readable");stream.emit("readable");flow(stream)}function maybeReadMore(stream,state){if(!state.readingMore){state.readingMore=true;pna.nextTick(maybeReadMore_,stream,state)}}function maybeReadMore_(stream,state){var len=state.length;while(!state.reading&&!state.flowing&&!state.ended&&state.length1&&indexOf(state.pipes,dest)!==-1)&&!cleanedUp){debug("false write response, pause",src._readableState.awaitDrain);src._readableState.awaitDrain++;increasedAwaitDrain=true}src.pause()}}function onerror(er){debug("onerror",er);unpipe();dest.removeListener("error",onerror);if(EElistenerCount(dest,"error")===0)dest.emit("error",er)}prependListener(dest,"error",onerror);function onclose(){dest.removeListener("finish",onfinish);unpipe()}dest.once("close",onclose);function onfinish(){debug("onfinish");dest.removeListener("close",onclose);unpipe()}dest.once("finish",onfinish);function unpipe(){debug("unpipe");src.unpipe(dest)}dest.emit("pipe",src);if(!state.flowing){debug("pipe resume");src.resume()}return dest};function pipeOnDrain(src){return function(){var state=src._readableState;debug("pipeOnDrain",state.awaitDrain);if(state.awaitDrain)state.awaitDrain--;if(state.awaitDrain===0&&EElistenerCount(src,"data")){state.flowing=true;flow(src)}}}Readable.prototype.unpipe=function(dest){var state=this._readableState;var unpipeInfo={hasUnpiped:false};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;state.flowing=false;if(dest)dest.emit("unpipe",this,unpipeInfo);return this}if(!dest){var dests=state.pipes;var len=state.pipesCount;state.pipes=null;state.pipesCount=0;state.flowing=false;for(var i=0;i=state.length){if(state.decoder)ret=state.buffer.join("");else if(state.buffer.length===1)ret=state.buffer.head.data;else ret=state.buffer.concat(state.length);state.buffer.clear()}else{ret=fromListPartial(n,state.buffer,state.decoder)}return ret}function fromListPartial(n,list,hasStrings){var ret;if(nstr.length?str.length:n;if(nb===str.length)ret+=str;else ret+=str.slice(0,n);n-=nb;if(n===0){if(nb===str.length){++c;if(p.next)list.head=p.next;else list.head=list.tail=null}else{list.head=p;p.data=str.slice(nb)}break}++c}list.length-=c;return ret}function copyFromBuffer(n,list){var ret=Buffer.allocUnsafe(n);var p=list.head;var c=1;p.data.copy(ret);n-=p.data.length;while(p=p.next){var buf=p.data;var nb=n>buf.length?buf.length:n;buf.copy(ret,ret.length-n,0,nb);n-=nb;if(n===0){if(nb===buf.length){++c;if(p.next)list.head=p.next;else list.head=list.tail=null}else{list.head=p;p.data=buf.slice(nb)}break}++c}list.length-=c;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.ended=true;pna.nextTick(endReadableNT,state,stream)}}function endReadableNT(state,stream){if(!state.endEmitted&&state.length===0){state.endEmitted=true;stream.readable=false;stream.emit("end")}}function indexOf(xs,x){for(var i=0,l=xs.length;i-1?setImmediate:pna.nextTick;var Duplex;Writable.WritableState=WritableState;var util=require("core-util-is");util.inherits=require("inherits");var internalUtil={deprecate:require("util-deprecate")};var Stream=require("./internal/streams/stream");var Buffer=require("safe-buffer").Buffer;var OurUint8Array=global.Uint8Array||function(){};function _uint8ArrayToBuffer(chunk){return Buffer.from(chunk)}function _isUint8Array(obj){return Buffer.isBuffer(obj)||obj instanceof OurUint8Array}var destroyImpl=require("./internal/streams/destroy");util.inherits(Writable,Stream);function nop(){}function WritableState(options,stream){Duplex=Duplex||require("./_stream_duplex");options=options||{};var isDuplex=stream instanceof Duplex;this.objectMode=!!options.objectMode;if(isDuplex)this.objectMode=this.objectMode||!!options.writableObjectMode;var hwm=options.highWaterMark;var writableHwm=options.writableHighWaterMark;var defaultHwm=this.objectMode?16:16*1024;if(hwm||hwm===0)this.highWaterMark=hwm;else if(isDuplex&&(writableHwm||writableHwm===0))this.highWaterMark=writableHwm;else this.highWaterMark=defaultHwm;this.highWaterMark=Math.floor(this.highWaterMark);this.finalCalled=false;this.needDrain=false;this.ending=false;this.ended=false;this.finished=false;this.destroyed=false;var noDecode=options.decodeStrings===false;this.decodeStrings=!noDecode;this.defaultEncoding=options.defaultEncoding||"utf8";this.length=0;this.writing=false;this.corked=0;this.sync=true;this.bufferProcessing=false;this.onwrite=function(er){onwrite(stream,er)};this.writecb=null;this.writelen=0;this.bufferedRequest=null;this.lastBufferedRequest=null;this.pendingcb=0;this.prefinished=false;this.errorEmitted=false;this.bufferedRequestCount=0;this.corkedRequestsFree=new CorkedRequest(this)}WritableState.prototype.getBuffer=function getBuffer(){var current=this.bufferedRequest;var out=[];while(current){out.push(current);current=current.next}return out};(function(){try{Object.defineProperty(WritableState.prototype,"buffer",{get:internalUtil.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer "+"instead.","DEP0003")})}catch(_){}})();var realHasInstance;if(typeof Symbol==="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]==="function"){realHasInstance=Function.prototype[Symbol.hasInstance];Object.defineProperty(Writable,Symbol.hasInstance,{value:function(object){if(realHasInstance.call(this,object))return true;if(this!==Writable)return false;return object&&object._writableState instanceof WritableState}})}else{realHasInstance=function(object){return object instanceof this}}function Writable(options){Duplex=Duplex||require("./_stream_duplex");if(!realHasInstance.call(Writable,this)&&!(this instanceof Duplex)){return new Writable(options)}this._writableState=new WritableState(options,this);this.writable=true;if(options){if(typeof options.write==="function")this._write=options.write;if(typeof options.writev==="function")this._writev=options.writev;if(typeof options.destroy==="function")this._destroy=options.destroy;if(typeof options.final==="function")this._final=options.final}Stream.call(this)}Writable.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))};function writeAfterEnd(stream,cb){var er=new Error("write after end");stream.emit("error",er);pna.nextTick(cb,er)}function validChunk(stream,state,chunk,cb){var valid=true;var er=false;if(chunk===null){er=new TypeError("May not write null values to stream")}else if(typeof chunk!=="string"&&chunk!==undefined&&!state.objectMode){er=new TypeError("Invalid non-string/buffer chunk")}if(er){stream.emit("error",er);pna.nextTick(cb,er);valid=false}return valid}Writable.prototype.write=function(chunk,encoding,cb){var state=this._writableState;var ret=false;var isBuf=!state.objectMode&&_isUint8Array(chunk);if(isBuf&&!Buffer.isBuffer(chunk)){chunk=_uint8ArrayToBuffer(chunk)}if(typeof encoding==="function"){cb=encoding;encoding=null}if(isBuf)encoding="buffer";else if(!encoding)encoding=state.defaultEncoding;if(typeof cb!=="function")cb=nop;if(state.ended)writeAfterEnd(this,cb);else if(isBuf||validChunk(this,state,chunk,cb)){state.pendingcb++;ret=writeOrBuffer(this,state,isBuf,chunk,encoding,cb)}return ret};Writable.prototype.cork=function(){var state=this._writableState;state.corked++};Writable.prototype.uncork=function(){var state=this._writableState;if(state.corked){state.corked--;if(!state.writing&&!state.corked&&!state.finished&&!state.bufferProcessing&&state.bufferedRequest)clearBuffer(this,state)}};Writable.prototype.setDefaultEncoding=function setDefaultEncoding(encoding){if(typeof encoding==="string")encoding=encoding.toLowerCase();if(!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((encoding+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+encoding);this._writableState.defaultEncoding=encoding;return this};function decodeChunk(state,chunk,encoding){if(!state.objectMode&&state.decodeStrings!==false&&typeof chunk==="string"){chunk=Buffer.from(chunk,encoding)}return chunk}Object.defineProperty(Writable.prototype,"writableHighWaterMark",{enumerable:false,get:function(){return this._writableState.highWaterMark}});function writeOrBuffer(stream,state,isBuf,chunk,encoding,cb){if(!isBuf){var newChunk=decodeChunk(state,chunk,encoding);if(chunk!==newChunk){isBuf=true;encoding="buffer";chunk=newChunk}}var len=state.objectMode?1:chunk.length;state.length+=len;var ret=state.length0)this.tail.next=entry;else this.head=entry;this.tail=entry;++this.length};BufferList.prototype.unshift=function unshift(v){var entry={data:v,next:this.head};if(this.length===0)this.tail=entry;this.head=entry;++this.length};BufferList.prototype.shift=function shift(){if(this.length===0)return;var ret=this.head.data;if(this.length===1)this.head=this.tail=null;else this.head=this.head.next;--this.length;return ret};BufferList.prototype.clear=function clear(){this.head=this.tail=null;this.length=0};BufferList.prototype.join=function join(s){if(this.length===0)return"";var p=this.head;var ret=""+p.data;while(p=p.next){ret+=s+p.data}return ret};BufferList.prototype.concat=function concat(n){if(this.length===0)return Buffer.alloc(0);if(this.length===1)return this.head.data;var ret=Buffer.allocUnsafe(n>>>0);var p=this.head;var i=0;while(p){copyBuffer(p.data,ret,i);i+=p.data.length;p=p.next}return ret};return BufferList}();if(util&&util.inspect&&util.inspect.custom){module.exports.prototype[util.inspect.custom]=function(){var obj=util.inspect({length:this.length});return this.constructor.name+" "+obj}}},{"safe-buffer":108,util:11}],104:[function(require,module,exports){"use strict";var pna=require("process-nextick-args");function destroy(err,cb){var _this=this;var readableDestroyed=this._readableState&&this._readableState.destroyed;var writableDestroyed=this._writableState&&this._writableState.destroyed;if(readableDestroyed||writableDestroyed){if(cb){cb(err)}else if(err&&(!this._writableState||!this._writableState.errorEmitted)){pna.nextTick(emitErrorNT,this,err)}return this}if(this._readableState){this._readableState.destroyed=true}if(this._writableState){this._writableState.destroyed=true}this._destroy(err||null,function(err){if(!cb&&err){pna.nextTick(emitErrorNT,_this,err);if(_this._writableState){_this._writableState.errorEmitted=true}}else if(cb){cb(err)}});return this}function undestroy(){if(this._readableState){this._readableState.destroyed=false;this._readableState.reading=false;this._readableState.ended=false;this._readableState.endEmitted=false}if(this._writableState){this._writableState.destroyed=false;this._writableState.ended=false;this._writableState.ending=false;this._writableState.finished=false;this._writableState.errorEmitted=false}}function emitErrorNT(self,err){self.emit("error",err)}module.exports={destroy:destroy,undestroy:undestroy}},{"process-nextick-args":91}],105:[function(require,module,exports){module.exports=require("events").EventEmitter},{events:78}],106:[function(require,module,exports){exports=module.exports=require("./lib/_stream_readable.js");exports.Stream=exports;exports.Readable=exports;exports.Writable=require("./lib/_stream_writable.js");exports.Duplex=require("./lib/_stream_duplex.js");exports.Transform=require("./lib/_stream_transform.js");exports.PassThrough=require("./lib/_stream_passthrough.js")},{"./lib/_stream_duplex.js":98,"./lib/_stream_passthrough.js":99,"./lib/_stream_readable.js":100,"./lib/_stream_transform.js":101,"./lib/_stream_writable.js":102}],107:[function(require,module,exports){"use strict";function ReInterval(callback,interval,args){var self=this;this._callback=callback;this._args=args;this._interval=setInterval(callback,interval,this._args);this.reschedule=function(interval){if(!interval)interval=self._interval;if(self._interval)clearInterval(self._interval);self._interval=setInterval(self._callback,interval,self._args)};this.clear=function(){if(self._interval){clearInterval(self._interval);self._interval=undefined}};this.destroy=function(){if(self._interval){clearInterval(self._interval)}self._callback=undefined;self._interval=undefined;self._args=undefined}}function reInterval(){if(typeof arguments[0]!=="function")throw new Error("callback needed");if(typeof arguments[1]!=="number")throw new Error("interval needed");var args;if(arguments.length>0){args=new Array(arguments.length-2);for(var i=0;i>5===6)return 2;else if(byte>>4===14)return 3;else if(byte>>3===30)return 4;return byte>>6===2?-1:-2}function utf8CheckIncomplete(self,buf,i){var j=buf.length-1;if(j=0){if(nb>0)self.lastNeed=nb-1;return nb}if(--j=0){if(nb>0)self.lastNeed=nb-2;return nb}if(--j=0){if(nb>0){if(nb===2)nb=0;else self.lastNeed=nb-3}return nb}return 0}function utf8CheckExtraBytes(self,buf,p){if((buf[0]&192)!==128){self.lastNeed=0;return"�"}if(self.lastNeed>1&&buf.length>1){if((buf[1]&192)!==128){self.lastNeed=1;return"�"}if(self.lastNeed>2&&buf.length>2){if((buf[2]&192)!==128){self.lastNeed=2;return"�"}}}}function utf8FillLast(buf){var p=this.lastTotal-this.lastNeed;var r=utf8CheckExtraBytes(this,buf,p);if(r!==undefined)return r;if(this.lastNeed<=buf.length){buf.copy(this.lastChar,p,0,this.lastNeed);return this.lastChar.toString(this.encoding,0,this.lastTotal)}buf.copy(this.lastChar,p,0,buf.length);this.lastNeed-=buf.length}function utf8Text(buf,i){var total=utf8CheckIncomplete(this,buf,i);if(!this.lastNeed)return buf.toString("utf8",i);this.lastTotal=total;var end=buf.length-(total-this.lastNeed);buf.copy(this.lastChar,0,end);return buf.toString("utf8",i,end)}function utf8End(buf){var r=buf&&buf.length?this.write(buf):"";if(this.lastNeed)return r+"�";return r}function utf16Text(buf,i){if((buf.length-i)%2===0){var r=buf.toString("utf16le",i);if(r){var c=r.charCodeAt(r.length-1);if(c>=55296&&c<=56319){this.lastNeed=2;this.lastTotal=4;this.lastChar[0]=buf[buf.length-2];this.lastChar[1]=buf[buf.length-1];return r.slice(0,-1)}}return r}this.lastNeed=1;this.lastTotal=2;this.lastChar[0]=buf[buf.length-1];return buf.toString("utf16le",i,buf.length-1)}function utf16End(buf){var r=buf&&buf.length?this.write(buf):"";if(this.lastNeed){var end=this.lastTotal-this.lastNeed;return r+this.lastChar.toString("utf16le",0,end)}return r}function base64Text(buf,i){var n=(buf.length-i)%3;if(n===0)return buf.toString("base64",i);this.lastNeed=3-n;this.lastTotal=3;if(n===1){this.lastChar[0]=buf[buf.length-1]}else{this.lastChar[0]=buf[buf.length-2];this.lastChar[1]=buf[buf.length-1]}return buf.toString("base64",i,buf.length-n)}function base64End(buf){var r=buf&&buf.length?this.write(buf):"";if(this.lastNeed)return r+this.lastChar.toString("base64",0,3-this.lastNeed);return r}function simpleWrite(buf){return buf.toString(this.encoding)}function simpleEnd(buf){return buf&&buf.length?this.write(buf):""}},{"safe-buffer":108}],111:[function(require,module,exports){"use strict";var punycode=require("punycode");var util=require("./util");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]*$/,simplePathPattern=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,delims=["<",">",'"',"`"," ","\r","\n","\t"],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&&util.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(!util.isString(url)){throw new TypeError("Parameter 'url' must be a string, not "+typeof url)}var queryIndex=url.indexOf("?"),splitter=queryIndex!==-1&&queryIndex127){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){this.hostname=punycode.toASCII(this.hostname)}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;i0?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(!util.isNull(result.pathname)||!util.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||srcPath.length>1)&&(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(!util.isNull(result.pathname)||!util.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}},{"./util":112,punycode:93,querystring:96}],112:[function(require,module,exports){"use strict";module.exports={isString:function(arg){return typeof arg==="string"},isObject:function(arg){return typeof arg==="object"&&arg!==null},isNull:function(arg){return arg===null},isNullOrUndefined:function(arg){return arg==null}}},{}],113:[function(require,module,exports){(function(global){module.exports=deprecate;function deprecate(fn,msg){if(config("noDeprecation")){return fn}var warned=false;function deprecated(){if(!warned){if(config("throwDeprecation")){throw new Error(msg)}else if(config("traceDeprecation")){console.trace(msg)}else{console.warn(msg)}warned=true}return fn.apply(this,arguments)}return deprecated}function config(name){try{if(!global.localStorage)return false}catch(_){return false}var val=global.localStorage[name];if(null==val)return false;return String(val).toLowerCase()==="true"}}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],114:[function(require,module,exports){arguments[4][80][0].apply(exports,arguments)},{dup:80}],115:[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"}},{}],116:[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=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=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-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("_process"),typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"./support/isBuffer":115,_process:92,inherits:114}],117:[function(require,module,exports){(function(process,global){"use strict";var Transform=require("readable-stream").Transform;var duplexify=require("duplexify");var WS=require("ws");var Buffer=require("safe-buffer").Buffer;module.exports=WebSocketStream;function buildProxy(options,socketWrite,socketEnd){var proxy=new Transform({objectMode:options.objectMode});proxy._write=socketWrite;proxy._flush=socketEnd;return proxy}function WebSocketStream(target,protocols,options){var stream,socket;var isBrowser=process.title==="browser";var isNative=!!global.WebSocket;var socketWrite=isBrowser?socketWriteBrowser:socketWriteNode;if(protocols&&!Array.isArray(protocols)&&"object"===typeof protocols){options=protocols;protocols=null;if(typeof options.protocol==="string"||Array.isArray(options.protocol)){protocols=options.protocol}}if(!options)options={};if(options.objectMode===undefined){options.objectMode=!(options.binary===true||options.binary===undefined)}var proxy=buildProxy(options,socketWrite,socketEnd);if(!options.objectMode){proxy._writev=writev}var bufferSize=options.browserBufferSize||1024*512;var bufferTimeout=options.browserBufferTimeout||1e3;if(typeof target==="object"){socket=target}else{if(isNative&&isBrowser){socket=new WS(target,protocols)}else{socket=new WS(target,protocols,options)}socket.binaryType="arraybuffer"}if(socket.readyState===socket.OPEN){stream=proxy}else{stream=duplexify.obj();socket.onopen=onopen}stream.socket=socket;socket.onclose=onclose;socket.onerror=onerror;socket.onmessage=onmessage;proxy.on("close",destroy);var coerceToBuffer=!options.objectMode;function socketWriteNode(chunk,enc,next){if(socket.readyState!==socket.OPEN){next();return}if(coerceToBuffer&&typeof chunk==="string"){chunk=Buffer.from(chunk,"utf8")}socket.send(chunk,next)}function socketWriteBrowser(chunk,enc,next){if(socket.bufferedAmount>bufferSize){setTimeout(socketWriteBrowser,bufferTimeout,chunk,enc,next);return}if(coerceToBuffer&&typeof chunk==="string"){chunk=Buffer.from(chunk,"utf8")}try{socket.send(chunk)}catch(err){return next(err)}next()}function socketEnd(done){socket.close();done()}function onopen(){stream.setReadable(proxy);stream.setWritable(proxy);stream.emit("connect")}function onclose(){stream.end();stream.destroy()}function onerror(err){stream.destroy(err)}function onmessage(event){var data=event.data;if(data instanceof ArrayBuffer)data=Buffer.from(data);else data=Buffer.from(data,"utf8");proxy.push(data)}function destroy(){socket.close()}function writev(chunks,cb){var buffers=new Array(chunks.length);for(var i=0;i