UNPKG

webp2p

Version:

The server-less signaling channel for WebRTC

54 lines (53 loc) 123 kB
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ (function (process){ function noop(e){e&&console.error(e)}function WebP2P(e){function n(e){d.emit("error",new Error(e))}function r(e,n,r){var t=new RTCPeerConnection({iceServers:v},{optional:[{DtlsSrtpKeyAgreement:!0}]});return t.addEventListener("icecandidate",function(e){if(!e.candidate){var t=this.localDescription.type,o=this.localDescription.sdp;t==n?r(o):console.error(t+" SDP type is not equal to "+n+" callback type")}}),t.addEventListener("signalingstatechange",function(){if("stable"==t.signalingState){var n=t._channels||[];h.add(e,t,n);var r=D[e];r&&(delete D[e],r.callback(null,t,n)),d.emit("peerconnection",t,n)}}),Object.defineProperty(t,"sessionID",{value:e}),t}function t(e,n){var r=(e.from,e.dest);if(r==d.sessionID)return console.error("Ignored message send to us",e);if(--e.ttl<=0)return console.warn("TTL achieved:",e);var r=e.dest;e=e.pack();for(var t,o=0;t=h._connectors[o];o++)if(t.sessionID==r)return t.send(e);h.send(e,n),g.send(e,n)}function o(e){var n=h.get(e);if(n){var r="["+d.sessionID+"] Already connected to "+e;console.log(r);var t={code:-1,message:r,ttl:MAX_TTL_DEFAULT};return t}var o=D[e];if(o){var r="["+d.sessionID+"] Already requested connection to "+e;if(console.log(r),d.sessionID<e){console.log("["+d.sessionID+"] Higher precedence than "+e+", sending error");var t={code:-2,message:r,ttl:MAX_TTL_DEFAULT};return t}return delete D[e],p.cancel(o.message),o.peerConnection.close(),console.debug("["+d.sessionID+"] Lower precedence than "+e+", request canceled"),o.callback}}function s(e,n){var r=h.get(e);if(!r){var t=D[e];if(!t){var o=c(e,n);o.addEventListener("signalingstatechange",function(){"stable"==o.signalingState&&n.increaseConnections()})}}}function i(e,s){var i=e.from,c=e.dest;if(c==d.sessionID){console.log("["+c+"] Received connection request from "+i);var a=o(i);if(a&&a.code)return e.reply(a);var l=r(i,"answer",function(n){var r={sdp:n,ttl:MAX_TTL_DEFAULT};e.reply(null,r)});l.setRemoteDescription(new RTCSessionDescription({sdp:e.sdp,type:"offer"}),function(){l.createAnswer(function(e){l.setLocalDescription(e,null,n)},n)},n),a&&l.addEventListener("signalingstatechange",function(){if("stable"==l.signalingState){var e=l._channels||[];a(null,l,e)}}),l.addEventListener("datachannel",function(e){var n=e.channel,r=l._channels||[];r.push(n),l._channels=r})}else t(e,s)}function c(e,t,o,s){var i=r(e,"offer",function(n){var r={sdp:n,ttl:s?MAX_TTL_DEFAULT:1};s=s||noop;var o=p.encode("offer",r,e,function(e,n){return e?s(e):void a(n)});D[e]={callback:s,message:o,peerConnection:i},t instanceof Array?t.forEach(function(e){e.send(o)}):t.send(o)});o=[d.routingLabel].concat(u,o);for(var c,l=i._channels=[],f=0;c=o[f];f++){var v=i.createDataChannel(c);l.push(v),v.addEventListener("close",function(){l.splice(l.indexOf(v),1)})}var g={mandatory:{OfferToReceiveAudio:!1,OfferToReceiveVideo:!1}};return i.createOffer(function(e){i.setLocalDescription(e,null,n)},n,g),i}function a(e){var r=e.from;console.debug("["+d.sessionID+"] Received answer from "+r);var t=D[r];t?t.peerConnection.setRemoteDescription(new RTCSessionDescription({sdp:e.sdp,type:"answer"}),null,n):console.warn("["+d.sessionID+"] Connection with peer '"+r+"' was not previously requested")}function l(e){e.on("connected",function(){g.status!=h.status&&d.emit("connected")}),e.on("disconnected",function(){g.status==h.status&&d.emit("disconnected")}),e.on("offer",i),e.on("answer",t),e.on("error",t)}var d=this;e=e||{};var u=e.commonLabels||[],f=e.handshake_servers,v=freeice(e.iceServers);Object.defineProperty(this,"routingLabel",{value:e.routingLabel||"webp2p"}),Object.defineProperty(this,"sessionID",{value:e.sessionID||uuid.v4()});var e={max_retries:3,peerID:this.sessionID},p=new RpcBuilder(packer,e),g=new HandshakeManager(p,f),h=new PeersManager(p,d.routingLabel);this.__defineGetter__("status",function(){return"connected"==h.status?"connected":g.status}),this.__defineGetter__("peers",function(){return h.peers});var D={};this.connectTo=function(e,n,r){if(n instanceof Function){if(r)throw new SyntaxError("Nothing can be defined after the callback");r=n,n=void 0}if(e==d.sessionID)return r(new Error("Connecting to ourself"));var t=h.get(e);if(t){var o="["+d.sessionID+"] Already connected to "+e;console.log(o);var s=t._channels||[];return void r(null,t,s)}var i=D[e];if(i){var o="["+d.sessionID+"] Already requested connection to "+e;console.log(o);var t=i.peerConnection;return void t.addEventListener("signalingstatechange",function(){if("stable"==t.signalingState){var e=t._channels||[];r(null,t,e)}})}c(e,[g,h],n,r)},g.on("connected",function(){d.emit("handshakeManager.connected",g)}),g.on("disconnected",function(){d.emit("handshakeManager.disconnected",g)}),h.on("connected",function(){d.emit("peersManager.connected",h)}),h.on("disconnected",function(){d.emit("peersManager.disconnected",h)}),l(g),l(h),g.on("presence",s),this.close=function(){g.close(),h.close(),p.close()},process.on("exit",function(){d.close()})}var EventEmitter=require("events").EventEmitter,inherits=require("inherits"),freeice=require("freeice"),uuid=require("uuid"),wrtc=require("wrtc"),RTCPeerConnection=wrtc.RTCPeerConnection,RTCSessionDescription=wrtc.RTCSessionDescription;require("process-events-shim");var RpcBuilder=require("rpc-builder"),HandshakeManager=require("./managers/HandshakeManager"),PeersManager=require("./managers/PeersManager"),packer=require("./packer");const MAX_TTL_DEFAULT=5;inherits(WebP2P,EventEmitter),module.exports=WebP2P; }).call(this,require("FWaASH")) },{"./managers/HandshakeManager":9,"./managers/PeersManager":11,"./packer":12,"FWaASH":19,"events":17,"freeice":27,"inherits":37,"process-events-shim":38,"rpc-builder":40,"uuid":46,"wrtc":47}],2:[function(require,module,exports){ function Connector_PubNub(e,n,r){HandshakeConnector.call(this,r);var o=this,c=n.channel,t=PUBNUB.init(e);t.subscribe({channel:c,restore:!1,backfill:!1,connect:o._open,message:o._message,disconnect:o._close,error:function(e){o._error(new Error(e?e.error:"Undefined error"))}}),this.close=function(){t.unsubscribe({channel:c}),o._close()},this.send=function(e){t.publish({channel:c,message:e})}}var inherits=require("inherits"),HandshakeConnector=require("./core/HandshakeConnector"),PUBNUB=require("pubnub");inherits(Connector_PubNub,HandshakeConnector),Connector_PubNub.prototype.max_connections=50,Object.defineProperty(Connector_PubNub.prototype,"max_chars",{value:1800}),module.exports=Connector_PubNub; },{"./core/HandshakeConnector":5,"inherits":37,"pubnub":48}],3:[function(require,module,exports){ function Connector(){EventEmitter.call(this);var e=this;this._open=function(){e.emit("open")},this._message=function(t){e.emit("message",t)},this._close=function(){e.emit("close")},this._error=function(t){e.emit("error",t)}}var inherits=require("inherits"),EventEmitter=require("events").EventEmitter;inherits(Connector,EventEmitter),Connector.prototype.close=function(){throw new TypeError("Connector.close should be defined in a child class")},Connector.prototype.send=function(){throw new TypeError("Connector.send should be defined in a child class")},module.exports=Connector; },{"events":17,"inherits":37}],4:[function(require,module,exports){ function Connector_DataChannel(e){Connector.call(this);var n=this;e.addEventListener("open",n._open),e.addEventListener("message",function(e){n._message(e.data)}),e.addEventListener("close",n._close),e.addEventListener("error",n._error),this.close=function(){e.close()},this.send=function(n){e.send(n)}}var inherits=require("inherits"),Connector=require("./Connector");inherits(Connector_DataChannel,Connector),module.exports=Connector_DataChannel; },{"./Connector":3,"inherits":37}],5:[function(require,module,exports){ function HandshakeConnector(n){Connector.call(this);var o=this;void 0!=n&&(this.max_connections=Math.min(n,this.max_connections)),this.shouldConnect=function(){return!0};var e=0;this.increaseConnections=function(){e++,e>=o.max_connections&&o.close()}}var inherits=require("inherits"),Connector=require("./Connector");inherits(HandshakeConnector,Connector),HandshakeConnector.prototype.max_connections=Number.POSITIVE_INFINITY,module.exports=HandshakeConnector; },{"./Connector":3,"inherits":37}],6:[function(require,module,exports){ function Connector_xRTML(e,n,o){HandshakeConnector.call(this,o);var t=this,i=n.channel,r=new ortcNodeclient;r.setClusterUrl("http://ortc-developers.realtime.co/server/2.1/"),r.onConnected=function(){r.subscribe(i,!0,function(e,n,o){t._message(o)})},r.onSubscribed=this._open.bind(this),r.onUnsubscribed=this._close.bind(this),r.onException=function(e,n){t._error(n)},r.connect(e.application_key,e.authentication_token),this.close=function(){r.unsubscribe(i)},this.send=function(e){r.send(i,e)}}var inherits=require("inherits"),HandshakeConnector=require("./core/HandshakeConnector"),ortcNodeclient=require("ibtrealtimesjnode").IbtRealTimeSJNode;inherits(Connector_xRTML,HandshakeConnector),module.exports=Connector_xRTML; },{"./core/HandshakeConnector":5,"ibtrealtimesjnode":32,"inherits":37}],7:[function(require,module,exports){ const ERROR_NETWORK_UNKNOWN={id:0,msg:"Unable to fetch handshake servers configuration"},ERROR_NETWORK_OFFLINE={id:1,msg:"There's no available network"},ERROR_REQUEST_FAILURE={id:2,msg:"Unable to fetch handshake servers configuration"},ERROR_REQUEST_EMPTY={id:3,msg:"Handshake servers configuration is empty"},ERROR_NO_PEERS={id:4,msg:"Not connected to any peer"};exports.ERROR_NETWORK_UNKNOWN=ERROR_NETWORK_UNKNOWN,exports.ERROR_NETWORK_OFFLINE=ERROR_NETWORK_OFFLINE,exports.ERROR_REQUEST_FAILURE=ERROR_REQUEST_FAILURE,exports.ERROR_REQUEST_EMPTY=ERROR_REQUEST_EMPTY,exports.ERROR_NO_PEERS=ERROR_NO_PEERS; },{}],8:[function(require,module,exports){ var HandshakeConnector=require("./connectors/core/HandshakeConnector"),WebP2P=require("./WebP2P");module.exports=WebP2P,module.exports.HandshakeConnector=HandshakeConnector; },{"./WebP2P":1,"./connectors/core/HandshakeConnector":5}],9:[function(require,module,exports){ function HandshakeManager(n,r){function e(r){var e=r.type,o=r.config_init,a=r.config_mess,i=r.max_connections,c=s[e];if(!c)throw Error("Invalid handshake server type '"+e+"'");var d=new c(o,a,i);t._initConnector(d),d.on("open",function(){d.send(n.encode("presence"))});var u=d._messageUnpacked;return d._messageUnpacked=function(n){"presence"==n.method?d.shouldConnect()&&t.emit("presence",n.params.from,d):u.call(d,n)},d}function o(){if(!a.length)throw Error("No handshake servers defined");for(;i<a.length;i++){var n=e(a[i]);return void n.on("close",function(){i++,o()})}i=0}Manager.call(this,n);var t=this,s={};this.registerConnectorConstructor=function(n,r){s[n]=r},this.registerConnectorConstructor("PubNub",Connector_PubNub),this.registerConnectorConstructor("xRTML",Connector_xRTML);var a=[],i=0,c=[];this.addConfigs_byObject=function(n){var r=s[n.type];return r?void(r.prototype.max_connections!=Number.POSITIVE_INFINITY||n.max_connections?(a.push(n),"disconnected"==t.status&&o()):(c.push(n),e(n))):console.error("Invalid handshake server config: ",n)},r&&this.addConfigs(r)}var inherits=require("inherits"),Manager=require("./Manager"),errors=require("../errors"),Connector_PubNub=require("../connectors/PubNub"),Connector_xRTML=require("../connectors/xRTML");inherits(HandshakeManager,Manager),HandshakeManager.prototype.addConfigs=function(n){return"string"==typeof n?this.addConfigs_byUri(n):n instanceof Array?this.addConfigs_byArray(n):void this.addConfigs_byObject(n)},HandshakeManager.prototype.addConfigs_byArray=function(n){for(var r,e=0;r=n[e];e++)this.addConfigs_byObject(r)},HandshakeManager.prototype.addConfigs_byUri=function(n){function r(n){e.emit("error",n)}var e=this,o=new XMLHttpRequest;o.open("GET",n),o.onload=function(){if(200==this.status){var n=JSON.parse(o.response);n.length?e.addConfigs_byArray(n):r(errors.ERROR_REQUEST_EMPTY)}else r(errors.ERROR_REQUEST_FAILURE)},o.onerror=function(){r(navigator.onLine?errors.ERROR_NETWORK_UNKNOWN:errors.ERROR_NETWORK_OFFLINE)},o.send()},module.exports=HandshakeManager; },{"../connectors/PubNub":2,"../connectors/xRTML":6,"../errors":7,"./Manager":10,"inherits":37}],10:[function(require,module,exports){ function Manager(e){EventEmitter.call(this);var n=this;this._connectors=[],this.__defineGetter__("status",function(){return this._connectors.length?"connected":"disconnected"}),this._initConnector=function(t){t.on("open",function(){n._connectors.push(t),1==n._connectors.length&&n.emit("connected")}),t.on("close",function(){n._connectors.splice(n._connectors.indexOf(t),1),0==n._connectors.length&&n.emit("disconnected")}),t.on("error",function(e){t.close(),n.emit("error",e)}),t._messageUnpacked=function(e){var o=e.method,r=e.params;switch(o){case"offer":r.reply=function(n,o){return e.reply(n,o,t)};case"answer":case"error":r.pack=function(){return e.pack()},n.emit(o,r,t);break;default:console.error("Unknown message method '"+o+"'",e)}},t.on("message",function(n){n=e.decode(n),n&&(n.stored?t.send(n):t._messageUnpacked(n))})}}var EventEmitter=require("events").EventEmitter,inherits=require("inherits");inherits(Manager,EventEmitter),Manager.prototype.close=function(){for(var e,n=0;e=this._connectors[n];n++)e.close()},Manager.prototype.send=function(e,n){for(var t,o=0;t=this._connectors[o];o++)t!==n&&t.send(e)},module.exports=Manager; },{"events":17,"inherits":37}],11:[function(require,module,exports){ function PeersManager(e,n){function t(e){var n=new Connector_DataChannel(e);return r._initConnector(n),n}function a(e,a){if(e.label==n){var r=t(e);return r.sessionID=a,r}}Manager.call(this,e);var r=this,i={};this.__defineGetter__("peers",function(){return i}),this.add=function(e,n,t){function r(n){var t=n.channel,i=a(t,e);i&&n.target.removeEventListener("datachannel",r)}if(n.addEventListener("signalingstatechange",function(){"closed"==n.signalingState&&delete i[e]}),t.length)for(var s,o=0;(s=t[o])&&!a(s,e);o++);else n.addEventListener("datachannel",r);i[e]=n},this.get=function(e){return i[e]};var s=this.close;this.close=function(){for(var e in i)i[e].close();s.call(this)}}var inherits=require("inherits"),Manager=require("./Manager"),Connector_DataChannel=require("../connectors/core/DataChannel");inherits(PeersManager,Manager),module.exports=PeersManager; },{"../connectors/core/DataChannel":4,"./Manager":10,"inherits":37}],12:[function(require,module,exports){ function pack(e,r){var s=new Array(6),a=e.params||{},o=e.method;switch(o){case"error":s[0]=ERROR;break;case"presence":s[0]=PRESENCE;break;case"offer":s[0]=OFFER;break;case"answer":s[0]=ANSWER;break;default:var n=new Error("Unknown message method '"+o+"'");throw n.message=e,n}return s[1]=a.from,"presence"!=o&&(s[2]=a.dest,s[3]=r,s[4]=a.ttl,s[5]=a.sdp||a.message),JSON.stringify(s)}function unpack(e){var r={},s={};e=JSON.parse(e);var a=e[0];switch(a){case ERROR:r.method="error";break;case PRESENCE:r.method="presence";break;case OFFER:r.method="offer";break;case ANSWER:r.method="answer";break;default:var o=new Error("Unknown message method '"+a+"'");throw o.message=e,o}return s.from=e[1],a!=PRESENCE&&(s.dest=e[2],a==ERROR||a==ANSWER?r.ack=e[3]:r.id=e[3],s.ttl=e[4],a==ERROR?s.message=e[5]:s.sdp=e[5]),r.params=s,r}const ERROR=0,PRESENCE=1,OFFER=2,ANSWER=3;var responseMethods={presence:"offer",offer:{error:"error",response:"answer"}};exports.pack=pack,exports.unpack=unpack,exports.responseMethods=responseMethods; },{}],13:[function(require,module,exports){ },{}],14:[function(require,module,exports){ function Buffer(e,t,r){if(!(this instanceof Buffer))return new Buffer(e,t,r);var n=typeof e;if("base64"===t&&"string"===n)for(e=stringtrim(e);e.length%4!==0;)e+="=";var i;if("number"===n)i=coerce(e);else if("string"===n)i=Buffer.byteLength(e,t);else{if("object"!==n)throw new Error("First argument needs to be a number, array or string.");i=coerce(e.length)}var s;Buffer._useTypedArrays?s=Buffer._augment(new Uint8Array(i)):(s=this,s.length=i,s._isBuffer=!0);var a;if(Buffer._useTypedArrays&&"number"==typeof e.byteLength)s._set(e);else if(isArrayish(e))for(a=0;i>a;a++)Buffer.isBuffer(e)?s[a]=e.readUInt8(a):s.writeInt8(e[a],a);else if("string"===n)s.write(e,0,t);else if("number"===n&&!Buffer._useTypedArrays&&!r)for(a=0;i>a;a++)s[a]=0;return s}function hexWrite(e,t,r,n){r=Number(r)||0;var i=e.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;var s=t.length;assert(s%2===0,"Invalid hex string"),n>s/2&&(n=s/2);for(var a=0;n>a;a++){var o=parseInt(t.substr(2*a,2),16);assert(!isNaN(o),"Invalid hex string"),e[r+a]=o}return a}function utf8Write(e,t,r,n){var i=blitBuffer(utf8ToBytes(t),e,r,n);return i}function asciiWrite(e,t,r,n){var i=blitBuffer(asciiToBytes(t),e,r,n);return i}function binaryWrite(e,t,r,n){return asciiWrite(e,t,r,n)}function base64Write(e,t,r,n){var i=blitBuffer(base64ToBytes(t),e,r,n);return i}function utf16leWrite(e,t,r,n){var i=blitBuffer(utf16leToBytes(t),e,r,n);return i}function base64Slice(e,t,r){return base64.fromByteArray(0===t&&r===e.length?e:e.slice(t,r))}function utf8Slice(e,t,r){var n="",i="";r=Math.min(e.length,r);for(var s=t;r>s;s++)e[s]<=127?(n+=decodeUtf8Char(i)+String.fromCharCode(e[s]),i=""):i+="%"+e[s].toString(16);return n+decodeUtf8Char(i)}function asciiSlice(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;r>i;i++)n+=String.fromCharCode(e[i]);return n}function binarySlice(e,t,r){return asciiSlice(e,t,r)}function hexSlice(e,t,r){var n=e.length;(!t||0>t)&&(t=0),(!r||0>r||r>n)&&(r=n);for(var i="",s=t;r>s;s++)i+=toHex(e[s]);return i}function utf16leSlice(e,t,r){for(var n=e.slice(t,r),i="",s=0;s<n.length;s+=2)i+=String.fromCharCode(n[s]+256*n[s+1]);return i}function readUInt16(e,t,r,n){n||(assert("boolean"==typeof r,"missing or invalid endian"),assert(void 0!==t&&null!==t,"missing offset"),assert(t+1<e.length,"Trying to read beyond buffer length"));var i=e.length;if(!(t>=i)){var s;return r?(s=e[t],i>t+1&&(s|=e[t+1]<<8)):(s=e[t]<<8,i>t+1&&(s|=e[t+1])),s}}function readUInt32(e,t,r,n){n||(assert("boolean"==typeof r,"missing or invalid endian"),assert(void 0!==t&&null!==t,"missing offset"),assert(t+3<e.length,"Trying to read beyond buffer length"));var i=e.length;if(!(t>=i)){var s;return r?(i>t+2&&(s=e[t+2]<<16),i>t+1&&(s|=e[t+1]<<8),s|=e[t],i>t+3&&(s+=e[t+3]<<24>>>0)):(i>t+1&&(s=e[t+1]<<16),i>t+2&&(s|=e[t+2]<<8),i>t+3&&(s|=e[t+3]),s+=e[t]<<24>>>0),s}}function readInt16(e,t,r,n){n||(assert("boolean"==typeof r,"missing or invalid endian"),assert(void 0!==t&&null!==t,"missing offset"),assert(t+1<e.length,"Trying to read beyond buffer length"));var i=e.length;if(!(t>=i)){var s=readUInt16(e,t,r,!0),a=32768&s;return a?-1*(65535-s+1):s}}function readInt32(e,t,r,n){n||(assert("boolean"==typeof r,"missing or invalid endian"),assert(void 0!==t&&null!==t,"missing offset"),assert(t+3<e.length,"Trying to read beyond buffer length"));var i=e.length;if(!(t>=i)){var s=readUInt32(e,t,r,!0),a=2147483648&s;return a?-1*(4294967295-s+1):s}}function readFloat(e,t,r,n){return n||(assert("boolean"==typeof r,"missing or invalid endian"),assert(t+3<e.length,"Trying to read beyond buffer length")),ieee754.read(e,t,r,23,4)}function readDouble(e,t,r,n){return n||(assert("boolean"==typeof r,"missing or invalid endian"),assert(t+7<e.length,"Trying to read beyond buffer length")),ieee754.read(e,t,r,52,8)}function writeUInt16(e,t,r,n,i){i||(assert(void 0!==t&&null!==t,"missing value"),assert("boolean"==typeof n,"missing or invalid endian"),assert(void 0!==r&&null!==r,"missing offset"),assert(r+1<e.length,"trying to write beyond buffer length"),verifuint(t,65535));var s=e.length;if(!(r>=s)){for(var a=0,o=Math.min(s-r,2);o>a;a++)e[r+a]=(t&255<<8*(n?a:1-a))>>>8*(n?a:1-a);return r+2}}function writeUInt32(e,t,r,n,i){i||(assert(void 0!==t&&null!==t,"missing value"),assert("boolean"==typeof n,"missing or invalid endian"),assert(void 0!==r&&null!==r,"missing offset"),assert(r+3<e.length,"trying to write beyond buffer length"),verifuint(t,4294967295));var s=e.length;if(!(r>=s)){for(var a=0,o=Math.min(s-r,4);o>a;a++)e[r+a]=t>>>8*(n?a:3-a)&255;return r+4}}function writeInt16(e,t,r,n,i){i||(assert(void 0!==t&&null!==t,"missing value"),assert("boolean"==typeof n,"missing or invalid endian"),assert(void 0!==r&&null!==r,"missing offset"),assert(r+1<e.length,"Trying to write beyond buffer length"),verifsint(t,32767,-32768));var s=e.length;if(!(r>=s))return t>=0?writeUInt16(e,t,r,n,i):writeUInt16(e,65535+t+1,r,n,i),r+2}function writeInt32(e,t,r,n,i){i||(assert(void 0!==t&&null!==t,"missing value"),assert("boolean"==typeof n,"missing or invalid endian"),assert(void 0!==r&&null!==r,"missing offset"),assert(r+3<e.length,"Trying to write beyond buffer length"),verifsint(t,2147483647,-2147483648));var s=e.length;if(!(r>=s))return t>=0?writeUInt32(e,t,r,n,i):writeUInt32(e,4294967295+t+1,r,n,i),r+4}function writeFloat(e,t,r,n,i){i||(assert(void 0!==t&&null!==t,"missing value"),assert("boolean"==typeof n,"missing or invalid endian"),assert(void 0!==r&&null!==r,"missing offset"),assert(r+3<e.length,"Trying to write beyond buffer length"),verifIEEE754(t,3.4028234663852886e38,-3.4028234663852886e38));var s=e.length;if(!(r>=s))return ieee754.write(e,t,r,n,23,4),r+4}function writeDouble(e,t,r,n,i){i||(assert(void 0!==t&&null!==t,"missing value"),assert("boolean"==typeof n,"missing or invalid endian"),assert(void 0!==r&&null!==r,"missing offset"),assert(r+7<e.length,"Trying to write beyond buffer length"),verifIEEE754(t,1.7976931348623157e308,-1.7976931348623157e308));var s=e.length;if(!(r>=s))return ieee754.write(e,t,r,n,52,8),r+8}function stringtrim(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function clamp(e,t,r){return"number"!=typeof e?r:(e=~~e,e>=t?t:e>=0?e:(e+=t,e>=0?e:0))}function coerce(e){return e=~~Math.ceil(+e),0>e?0:e}function isArray(e){return(Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)})(e)}function isArrayish(e){return isArray(e)||Buffer.isBuffer(e)||e&&"object"==typeof e&&"number"==typeof e.length}function toHex(e){return 16>e?"0"+e.toString(16):e.toString(16)}function utf8ToBytes(e){for(var t=[],r=0;r<e.length;r++){var n=e.charCodeAt(r);if(127>=n)t.push(n);else{var i=r;n>=55296&&57343>=n&&r++;for(var s=encodeURIComponent(e.slice(i,r+1)).substr(1).split("%"),a=0;a<s.length;a++)t.push(parseInt(s[a],16))}}return t}function asciiToBytes(e){for(var t=[],r=0;r<e.length;r++)t.push(255&e.charCodeAt(r));return t}function utf16leToBytes(e){for(var t,r,n,i=[],s=0;s<e.length;s++)t=e.charCodeAt(s),r=t>>8,n=t%256,i.push(n),i.push(r);return i}function base64ToBytes(e){return base64.toByteArray(e)}function blitBuffer(e,t,r,n){for(var i=0;n>i&&!(i+r>=t.length||i>=e.length);i++)t[i+r]=e[i];return i}function decodeUtf8Char(e){try{return decodeURIComponent(e)}catch(t){return String.fromCharCode(65533)}}function verifuint(e,t){assert("number"==typeof e,"cannot write a non-number as a number"),assert(e>=0,"specified a negative value for writing an unsigned value"),assert(t>=e,"value is larger than maximum value for type"),assert(Math.floor(e)===e,"value has a fractional component")}function verifsint(e,t,r){assert("number"==typeof e,"cannot write a non-number as a number"),assert(t>=e,"value larger than maximum allowed value"),assert(e>=r,"value smaller than minimum allowed value"),assert(Math.floor(e)===e,"value has a fractional component")}function verifIEEE754(e,t,r){assert("number"==typeof e,"cannot write a non-number as a number"),assert(t>=e,"value larger than maximum allowed value"),assert(e>=r,"value smaller than minimum allowed value")}function assert(e,t){if(!e)throw new Error(t||"Failed assertion")}var base64=require("base64-js"),ieee754=require("ieee754");exports.Buffer=Buffer,exports.SlowBuffer=Buffer,exports.INSPECT_MAX_BYTES=50,Buffer.poolSize=8192,Buffer._useTypedArrays=function(){try{var e=new ArrayBuffer(0),t=new Uint8Array(e);return t.foo=function(){return 42},42===t.foo()&&"function"==typeof t.subarray}catch(r){return!1}}(),Buffer.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},Buffer.isBuffer=function(e){return!(null===e||void 0===e||!e._isBuffer)},Buffer.byteLength=function(e,t){var r;switch(e=e.toString(),t||"utf8"){case"hex":r=e.length/2;break;case"utf8":case"utf-8":r=utf8ToBytes(e).length;break;case"ascii":case"binary":case"raw":r=e.length;break;case"base64":r=base64ToBytes(e).length;break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":r=2*e.length;break;default:throw new Error("Unknown encoding")}return r},Buffer.concat=function(e,t){if(assert(isArray(e),"Usage: Buffer.concat(list[, length])"),0===e.length)return new Buffer(0);if(1===e.length)return e[0];var r;if(void 0===t)for(t=0,r=0;r<e.length;r++)t+=e[r].length;var n=new Buffer(t),i=0;for(r=0;r<e.length;r++){var s=e[r];s.copy(n,i),i+=s.length}return n},Buffer.compare=function(e,t){assert(Buffer.isBuffer(e)&&Buffer.isBuffer(t),"Arguments must be Buffers");for(var r=e.length,n=t.length,i=0,s=Math.min(r,n);s>i&&e[i]===t[i];i++);return i!==s&&(r=e[i],n=t[i]),n>r?-1:r>n?1:0},Buffer.prototype.write=function(e,t,r,n){if(isFinite(t))isFinite(r)||(n=r,r=void 0);else{var i=n;n=t,t=r,r=i}t=Number(t)||0;var s=this.length-t;r?(r=Number(r),r>s&&(r=s)):r=s,n=String(n||"utf8").toLowerCase();var a;switch(n){case"hex":a=hexWrite(this,e,t,r);break;case"utf8":case"utf-8":a=utf8Write(this,e,t,r);break;case"ascii":a=asciiWrite(this,e,t,r);break;case"binary":a=binaryWrite(this,e,t,r);break;case"base64":a=base64Write(this,e,t,r);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":a=utf16leWrite(this,e,t,r);break;default:throw new Error("Unknown encoding")}return a},Buffer.prototype.toString=function(e,t,r){var n=this;if(e=String(e||"utf8").toLowerCase(),t=Number(t)||0,r=void 0===r?n.length:Number(r),r===t)return"";var i;switch(e){case"hex":i=hexSlice(n,t,r);break;case"utf8":case"utf-8":i=utf8Slice(n,t,r);break;case"ascii":i=asciiSlice(n,t,r);break;case"binary":i=binarySlice(n,t,r);break;case"base64":i=base64Slice(n,t,r);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":i=utf16leSlice(n,t,r);break;default:throw new Error("Unknown encoding")}return i},Buffer.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},Buffer.prototype.equals=function(e){return assert(Buffer.isBuffer(e),"Argument must be a Buffer"),0===Buffer.compare(this,e)},Buffer.prototype.compare=function(e){return assert(Buffer.isBuffer(e),"Argument must be a Buffer"),Buffer.compare(this,e)},Buffer.prototype.copy=function(e,t,r,n){var i=this;if(r||(r=0),n||0===n||(n=this.length),t||(t=0),n!==r&&0!==e.length&&0!==i.length){assert(n>=r,"sourceEnd < sourceStart"),assert(t>=0&&t<e.length,"targetStart out of bounds"),assert(r>=0&&r<i.length,"sourceStart out of bounds"),assert(n>=0&&n<=i.length,"sourceEnd out of bounds"),n>this.length&&(n=this.length),e.length-t<n-r&&(n=e.length-t+r);var s=n-r;if(100>s||!Buffer._useTypedArrays)for(var a=0;s>a;a++)e[a+t]=this[a+r];else e._set(this.subarray(r,r+s),t)}},Buffer.prototype.slice=function(e,t){var r=this.length;if(e=clamp(e,r,0),t=clamp(t,r,r),Buffer._useTypedArrays)return Buffer._augment(this.subarray(e,t));for(var n=t-e,i=new Buffer(n,void 0,!0),s=0;n>s;s++)i[s]=this[s+e];return i},Buffer.prototype.get=function(e){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(e)},Buffer.prototype.set=function(e,t){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(e,t)},Buffer.prototype.readUInt8=function(e,t){return t||(assert(void 0!==e&&null!==e,"missing offset"),assert(e<this.length,"Trying to read beyond buffer length")),e>=this.length?void 0:this[e]},Buffer.prototype.readUInt16LE=function(e,t){return readUInt16(this,e,!0,t)},Buffer.prototype.readUInt16BE=function(e,t){return readUInt16(this,e,!1,t)},Buffer.prototype.readUInt32LE=function(e,t){return readUInt32(this,e,!0,t)},Buffer.prototype.readUInt32BE=function(e,t){return readUInt32(this,e,!1,t)},Buffer.prototype.readInt8=function(e,t){if(t||(assert(void 0!==e&&null!==e,"missing offset"),assert(e<this.length,"Trying to read beyond buffer length")),!(e>=this.length)){var r=128&this[e];return r?-1*(255-this[e]+1):this[e]}},Buffer.prototype.readInt16LE=function(e,t){return readInt16(this,e,!0,t)},Buffer.prototype.readInt16BE=function(e,t){return readInt16(this,e,!1,t)},Buffer.prototype.readInt32LE=function(e,t){return readInt32(this,e,!0,t)},Buffer.prototype.readInt32BE=function(e,t){return readInt32(this,e,!1,t)},Buffer.prototype.readFloatLE=function(e,t){return readFloat(this,e,!0,t)},Buffer.prototype.readFloatBE=function(e,t){return readFloat(this,e,!1,t)},Buffer.prototype.readDoubleLE=function(e,t){return readDouble(this,e,!0,t)},Buffer.prototype.readDoubleBE=function(e,t){return readDouble(this,e,!1,t)},Buffer.prototype.writeUInt8=function(e,t,r){return r||(assert(void 0!==e&&null!==e,"missing value"),assert(void 0!==t&&null!==t,"missing offset"),assert(t<this.length,"trying to write beyond buffer length"),verifuint(e,255)),t>=this.length?void 0:(this[t]=e,t+1)},Buffer.prototype.writeUInt16LE=function(e,t,r){return writeUInt16(this,e,t,!0,r)},Buffer.prototype.writeUInt16BE=function(e,t,r){return writeUInt16(this,e,t,!1,r)},Buffer.prototype.writeUInt32LE=function(e,t,r){return writeUInt32(this,e,t,!0,r)},Buffer.prototype.writeUInt32BE=function(e,t,r){return writeUInt32(this,e,t,!1,r)},Buffer.prototype.writeInt8=function(e,t,r){return r||(assert(void 0!==e&&null!==e,"missing value"),assert(void 0!==t&&null!==t,"missing offset"),assert(t<this.length,"Trying to write beyond buffer length"),verifsint(e,127,-128)),t>=this.length?void 0:(e>=0?this.writeUInt8(e,t,r):this.writeUInt8(255+e+1,t,r),t+1)},Buffer.prototype.writeInt16LE=function(e,t,r){return writeInt16(this,e,t,!0,r)},Buffer.prototype.writeInt16BE=function(e,t,r){return writeInt16(this,e,t,!1,r)},Buffer.prototype.writeInt32LE=function(e,t,r){return writeInt32(this,e,t,!0,r)},Buffer.prototype.writeInt32BE=function(e,t,r){return writeInt32(this,e,t,!1,r)},Buffer.prototype.writeFloatLE=function(e,t,r){return writeFloat(this,e,t,!0,r)},Buffer.prototype.writeFloatBE=function(e,t,r){return writeFloat(this,e,t,!1,r)},Buffer.prototype.writeDoubleLE=function(e,t,r){return writeDouble(this,e,t,!0,r)},Buffer.prototype.writeDoubleBE=function(e,t,r){return writeDouble(this,e,t,!1,r)},Buffer.prototype.fill=function(e,t,r){if(e||(e=0),t||(t=0),r||(r=this.length),assert(r>=t,"end < start"),r!==t&&0!==this.length){assert(t>=0&&t<this.length,"start out of bounds"),assert(r>=0&&r<=this.length,"end out of bounds");var n;if("number"==typeof e)for(n=t;r>n;n++)this[n]=e;else{var i=utf8ToBytes(e.toString()),s=i.length;for(n=t;r>n;n++)this[n]=i[n%s]}return this}},Buffer.prototype.inspect=function(){for(var e=[],t=this.length,r=0;t>r;r++)if(e[r]=toHex(this[r]),r===exports.INSPECT_MAX_BYTES){e[r+1]="...";break}return"<Buffer "+e.join(" ")+">"},Buffer.prototype.toArrayBuffer=function(){if("undefined"!=typeof Uint8Array){if(Buffer._useTypedArrays)return new Buffer(this).buffer;for(var e=new Uint8Array(this.length),t=0,r=e.length;r>t;t+=1)e[t]=this[t];return e.buffer}throw new Error("Buffer.toArrayBuffer not supported in this browser")};var BP=Buffer.prototype;Buffer._augment=function(e){return e._isBuffer=!0,e._get=e.get,e._set=e.set,e.get=BP.get,e.set=BP.set,e.write=BP.write,e.toString=BP.toString,e.toLocaleString=BP.toString,e.toJSON=BP.toJSON,e.equals=BP.equals,e.compare=BP.compare,e.copy=BP.copy,e.slice=BP.slice,e.readUInt8=BP.readUInt8,e.readUInt16LE=BP.readUInt16LE,e.readUInt16BE=BP.readUInt16BE,e.readUInt32LE=BP.readUInt32LE,e.readUInt32BE=BP.readUInt32BE,e.readInt8=BP.readInt8,e.readInt16LE=BP.readInt16LE,e.readInt16BE=BP.readInt16BE,e.readInt32LE=BP.readInt32LE,e.readInt32BE=BP.readInt32BE,e.readFloatLE=BP.readFloatLE,e.readFloatBE=BP.readFloatBE,e.readDoubleLE=BP.readDoubleLE,e.readDoubleBE=BP.readDoubleBE,e.writeUInt8=BP.writeUInt8,e.writeUInt16LE=BP.writeUInt16LE,e.writeUInt16BE=BP.writeUInt16BE,e.writeUInt32LE=BP.writeUInt32LE,e.writeUInt32BE=BP.writeUInt32BE,e.writeInt8=BP.writeInt8,e.writeInt16LE=BP.writeInt16LE,e.writeInt16BE=BP.writeInt16BE,e.writeInt32LE=BP.writeInt32LE,e.writeInt32BE=BP.writeInt32BE,e.writeFloatLE=BP.writeFloatLE,e.writeFloatBE=BP.writeFloatBE,e.writeDoubleLE=BP.writeDoubleLE,e.writeDoubleBE=BP.writeDoubleBE,e.fill=BP.fill,e.inspect=BP.inspect,e.toArrayBuffer=BP.toArrayBuffer,e}; },{"base64-js":15,"ieee754":16}],15:[function(require,module,exports){ var lookup="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";!function(){"use strict";function r(r){var t=r.charCodeAt(0);return t===a?62:t===h?63:o>t?-1:o+10>t?t-o+26+26:A+26>t?t-A:c+26>t?t-c+26:void 0}function t(t){function e(r){u[l++]=r}var a,h,o,c,A,u;if(t.length%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var i=t.length;A="="===t.charAt(i-2)?2:"="===t.charAt(i-1)?1:0,u=new n(3*t.length/4-A),o=A>0?t.length-4:t.length;var l=0;for(a=0,h=0;o>a;a+=4,h+=3)c=r(t.charAt(a))<<18|r(t.charAt(a+1))<<12|r(t.charAt(a+2))<<6|r(t.charAt(a+3)),e((16711680&c)>>16),e((65280&c)>>8),e(255&c);return 2===A?(c=r(t.charAt(a))<<2|r(t.charAt(a+1))>>4,e(255&c)):1===A&&(c=r(t.charAt(a))<<10|r(t.charAt(a+1))<<4|r(t.charAt(a+2))>>2,e(c>>8&255),e(255&c)),u}function e(r){function t(r){return lookup.charAt(r)}function e(r){return t(r>>18&63)+t(r>>12&63)+t(r>>6&63)+t(63&r)}var n,a,h,o=r.length%3,c="";for(n=0,h=r.length-o;h>n;n+=3)a=(r[n]<<16)+(r[n+1]<<8)+r[n+2],c+=e(a);switch(o){case 1:a=r[r.length-1],c+=t(a>>2),c+=t(a<<4&63),c+="==";break;case 2:a=(r[r.length-2]<<8)+r[r.length-1],c+=t(a>>10),c+=t(a>>4&63),c+=t(a<<2&63),c+="="}return c}var n="undefined"!=typeof Uint8Array?Uint8Array:Array,a=("0".charCodeAt(0),"+".charCodeAt(0)),h="/".charCodeAt(0),o="0".charCodeAt(0),c="a".charCodeAt(0),A="A".charCodeAt(0);module.exports.toByteArray=t,module.exports.fromByteArray=e}(); },{}],16:[function(require,module,exports){ exports.read=function(o,t,a,r,h){var M,p,w=8*h-r-1,f=(1<<w)-1,e=f>>1,i=-7,n=a?h-1:0,s=a?-1:1,N=o[t+n];for(n+=s,M=N&(1<<-i)-1,N>>=-i,i+=w;i>0;M=256*M+o[t+n],n+=s,i-=8);for(p=M&(1<<-i)-1,M>>=-i,i+=r;i>0;p=256*p+o[t+n],n+=s,i-=8);if(0===M)M=1-e;else{if(M===f)return p?0/0:1/0*(N?-1:1);p+=Math.pow(2,r),M-=e}return(N?-1:1)*p*Math.pow(2,M-r)},exports.write=function(o,t,a,r,h,M){var p,w,f,e=8*M-h-1,i=(1<<e)-1,n=i>>1,s=23===h?Math.pow(2,-24)-Math.pow(2,-77):0,N=r?0:M-1,u=r?1:-1,l=0>t||0===t&&0>1/t?1:0;for(t=Math.abs(t),isNaN(t)||1/0===t?(w=isNaN(t)?1:0,p=i):(p=Math.floor(Math.log(t)/Math.LN2),t*(f=Math.pow(2,-p))<1&&(p--,f*=2),t+=p+n>=1?s/f:s*Math.pow(2,1-n),t*f>=2&&(p++,f/=2),p+n>=i?(w=0,p=i):p+n>=1?(w=(t*f-1)*Math.pow(2,h),p+=n):(w=t*Math.pow(2,n-1)*Math.pow(2,h),p=0));h>=8;o[a+N]=255&w,N+=u,w/=256,h-=8);for(p=p<<h|w,e+=h;e>0;o[a+N]=255&p,N+=u,p/=256,e-=8);o[a+N-u]|=128*l}; },{}],17:[function(require,module,exports){ function EventEmitter(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function isFunction(e){return"function"==typeof e}function isNumber(e){return"number"==typeof e}function isObject(e){return"object"==typeof e&&null!==e}function isUndefined(e){return void 0===e}module.exports=EventEmitter,EventEmitter.EventEmitter=EventEmitter,EventEmitter.prototype._events=void 0,EventEmitter.prototype._maxListeners=void 0,EventEmitter.defaultMaxListeners=10,EventEmitter.prototype.setMaxListeners=function(e){if(!isNumber(e)||0>e||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},EventEmitter.prototype.emit=function(e){var t,n,s,i,r,o;if(this._events||(this._events={}),"error"===e&&(!this._events.error||isObject(this._events.error)&&!this._events.error.length))throw t=arguments[1],t instanceof Error?t:TypeError('Uncaught, unspecified "error" event.');if(n=this._events[e],isUndefined(n))return!1;if(isFunction(n))switch(arguments.length){case 1:n.call(this);break;case 2:n.call(this,arguments[1]);break;case 3:n.call(this,arguments[1],arguments[2]);break;default:for(s=arguments.length,i=new Array(s-1),r=1;s>r;r++)i[r-1]=arguments[r];n.apply(this,i)}else if(isObject(n)){for(s=arguments.length,i=new Array(s-1),r=1;s>r;r++)i[r-1]=arguments[r];for(o=n.slice(),s=o.length,r=0;s>r;r++)o[r].apply(this,i)}return!0},EventEmitter.prototype.addListener=function(e,t){var n;if(!isFunction(t))throw TypeError("listener must be a function");if(this._events||(this._events={}),this._events.newListener&&this.emit("newListener",e,isFunction(t.listener)?t.listener:t),this._events[e]?isObject(this._events[e])?this._events[e].push(t):this._events[e]=[this._events[e],t]:this._events[e]=t,isObject(this._events[e])&&!this._events[e].warned){var n;n=isUndefined(this._maxListeners)?EventEmitter.defaultMaxListeners:this._maxListeners,n&&n>0&&this._events[e].length>n&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace())}return this},EventEmitter.prototype.on=EventEmitter.prototype.addListener,EventEmitter.prototype.once=function(e,t){function n(){this.removeListener(e,n),s||(s=!0,t.apply(this,arguments))}if(!isFunction(t))throw TypeError("listener must be a function");var s=!1;return n.listener=t,this.on(e,n),this},EventEmitter.prototype.removeListener=function(e,t){var n,s,i,r;if(!isFunction(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(n=this._events[e],i=n.length,s=-1,n===t||isFunction(n.listener)&&n.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(isObject(n)){for(r=i;r-->0;)if(n[r]===t||n[r].listener&&n[r].listener===t){s=r;break}if(0>s)return this;1===n.length?(n.length=0,delete this._events[e]):n.splice(s,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},EventEmitter.prototype.removeAllListeners=function(e){var t,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(n=this._events[e],isFunction(n))this.removeListener(e,n);else for(;n.length;)this.removeListener(e,n[n.length-1]);return delete this._events[e],this},EventEmitter.prototype.listeners=function(e){var t;return t=this._events&&this._events[e]?isFunction(this._events[e])?[this._events[e]]:this._events[e].slice():[]},EventEmitter.listenerCount=function(e,t){var n;return n=e._events&&e._events[t]?isFunction(e._events[t])?1:e._events[t].length:0}; },{}],18:[function(require,module,exports){ (function (process){ function normalizeArray(r,t){for(var e=0,n=r.length-1;n>=0;n--){var s=r[n];"."===s?r.splice(n,1):".."===s?(r.splice(n,1),e++):e&&(r.splice(n,1),e--)}if(t)for(;e--;e)r.unshift("..");return r}function filter(r,t){if(r.filter)return r.filter(t);for(var e=[],n=0;n<r.length;n++)t(r[n],n,r)&&e.push(r[n]);return e}var splitPathRe=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,splitPath=function(r){return splitPathRe.exec(r).slice(1)};exports.resolve=function(){for(var r="",t=!1,e=arguments.length-1;e>=-1&&!t;e--){var n=e>=0?arguments[e]:process.cwd();if("string"!=typeof n)throw new TypeError("Arguments to path.resolve must be strings");n&&(r=n+"/"+r,t="/"===n.charAt(0))}return r=normalizeArray(filter(r.split("/"),function(r){return!!r}),!t).join("/"),(t?"/":"")+r||"."},exports.normalize=function(r){var t=exports.isAbsolute(r),e="/"===substr(r,-1);return r=normalizeArray(filter(r.split("/"),function(r){return!!r}),!t).join("/"),r||t||(r="."),r&&e&&(r+="/"),(t?"/":"")+r},exports.isAbsolute=function(r){return"/"===r.charAt(0)},exports.join=function(){var r=Array.prototype.slice.call(arguments,0);return exports.normalize(filter(r,function(r){if("string"!=typeof r)throw new TypeError("Arguments to path.join must be strings");return r}).join("/"))},exports.relative=function(r,t){function e(r){for(var t=0;t<r.length&&""===r[t];t++);for(var e=r.length-1;e>=0&&""===r[e];e--);return t>e?[]:r.slice(t,e-t+1)}r=exports.resolve(r).substr(1),t=exports.resolve(t).substr(1);for(var n=e(r.split("/")),s=e(t.split("/")),i=Math.min(n.length,s.length),o=i,u=0;i>u;u++)if(n[u]!==s[u]){o=u;break}for(var l=[],u=o;u<n.length;u++)l.push("..");return l=l.concat(s.slice(o)),l.join("/")},exports.sep="/",exports.delimiter=":",exports.dirname=function(r){var t=splitPath(r),e=t[0],n=t[1];return e||n?(n&&(n=n.substr(0,n.length-1)),e+n):"."},exports.basename=function(r,t){var e=splitPath(r)[2];return t&&e.substr(-1*t.length)===t&&(e=e.substr(0,e.length-t.length)),e},exports.extname=function(r){return splitPath(r)[3]};var substr="b"==="ab".substr(-1)?function(r,t,e){return r.substr(t,e)}:function(r,t,e){return 0>t&&(t=r.length+t),r.substr(t,e)}; }).call(this,require("FWaASH")) },{"FWaASH":19}],19:[function(require,module,exports){ function noop(){}var process=module.exports={};process.nextTick=function(){var o="undefined"!=typeof window&&window.setImmediate,e="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(o)return function(o){return window.setImmediate(o)};if(e){var s=[];return window.addEventListener("message",function(o){var e=o.source;if((e===window||null===e)&&"process-tick"===o.data&&(o.stopPropagation(),s.length>0)){var n=s.shift();n()}},!0),function(o){s.push(o),window.postMessage("process-tick","*")}}return function(o){setTimeout(o,0)}}(),process.title="browser",process.browser=!0,process.env={},process.argv=[],process.on=noop,process.addListener=noop,process.once=noop,process.off=noop,process.removeListener=noop,process.removeAllListeners=noop,process.emit=noop,process.binding=function(){throw new Error("process.binding is not supported")},process.cwd=function(){return"/"},process.chdir=function(){throw new Error("process.chdir is not supported")}; },{}],20:[function(require,module,exports){ (function (global){ !function(o){function e(o){throw RangeError(L[o])}function n(o,e){for(var n=o.length;n--;)o[n]=e(o[n]);return o}function t(o,e){return n(o.split(S),e).join(".")}function r(o){for(var e,n,t=[],r=0,u=o.length;u>r;)e=o.charCodeAt(r++),e>=55296&&56319>=e&&u>r?(n=o.charCodeAt(r++),56320==(64512&n)?t.push(((1023&e)<<10)+(1023&n)+65536):(t.push(e),r--)):t.push(e);return t}function u(o){return n(o,function(o){var e="";return o>65535&&(o-=65536,e+=R(o>>>10&1023|55296),o=56320|1023&o),e+=R(o)}).join("")}function i(o){return 10>o-48?o-22:26>o-65?o-65:26>o-97?o-97:x}function f(o,e){return o+22+75*(26>o)-((0!=e)<<5)}function c(o,e,n){var t=0;for(o=n?P(o/m):o>>1,o+=P(o/e);o>M*C>>1;t+=x)o=P(o/M);return P(t+(M+1)*o/(o+j))}function l(o){var n,t,r,f,l,d,s,a,p,h,v=[],g=o.length,w=0,j=I,m=A;for(t=o.lastIndexOf(F),0>t&&(t=0),r=0;t>r;++r)o.charCodeAt(r)>=128&&e("not-basic"),v.push(o.charCodeAt(r));for(f=t>0?t+1:0;g>f;){for(l=w,d=1,s=x;f>=g&&e("invalid-input"),a=i(o.charCodeAt(f++)),(a>=x||a>P((b-w)/d))&&e("overflow"),w+=a*d,p=m>=s?y:s>=m+C?C:s-m,!(p>a);s+=x)h=x-p,d>P(b/h)&&e("overflow"),d*=h;n=v.length+1,m=c(w-l,n,0==l),P(w/n)>b-j&&e("overflow"),j+=P(w/n),w%=n,v.splice(w++,0,j)}return u(v)}function d(o){var n,t,u,i,l,d,s,a,p,h,v,g,w,j,m,E=[];for(o=r(o),g=o.length,n=I,t=0,l=A,d=0;g>d;++d)v=o[d],128>v&&E.push(R(v));for(u=i=E.length,i&&E.push(F);g>u;){for(s=b,d=0;g>d;++d)v=o[d],v>=n&&s>v&&(s=v);for(w=u+1,s-n>P((b-t)/w)&&e("overflow"),t+=(s-n)*w,n=s,d=0;g>d;++d)if(v=o[d],n>v&&++t>b&&e("overflow"),v==n){for(a=t,p=x;h=l>=p?y:p>=l+C?C:p-l,!(h>a);p+=x)m=a-h,j=x-h,E.push(R(f(h+m%j,0))),a=P(m/j);E.push(R(f(a,0))),l=c(t,w,u==i),t=0,++u}++t,++n}return E.join("")}function s(o){return t(o,function(o){return E.test(o)?l(o.slice(4).toLowerCase()):o})}function a(o){return t(o,function(o){return O.test(o)?"xn--"+d(o):o})}var p="object"==typeof exports&&exports,h="object"==typeof module&&module&&module.exports==p&&module,v="object"==typeof global&&global;(v.global===v||v.window===v)&&(o=v);var g,w,b=2147483647,x=36,y=1,C=26,j=38,m=700,A=72,I=128,F="-",E=/^xn--/,O=/[^ -~]/,S=/\x2E|\u3002|\uFF0E|\uFF61/g,L={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},M=x-y,P=Math.floor,R=String.fromCharCode;if(g={version:"1.2.4",ucs2:{decode:r,encode:u},decode:l,encode:d,toASCII:a,toUnicode:s},"function"==typeof define&&"object"==typeof define.amd&&define.amd)define("punycode",function(){return g});else if(p&&!p.nodeType)if(h)h.exports=g;else for(w in g)g.hasOwnProperty(w)&&(p[w]=g[w]);else o.punycode=g}(this); }).call(this,typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) },{}],21:[function(require,module,exports){ "use strict";function hasOwnProperty(r,e){return Object.prototype.hasOwnProperty.call(r,e)}module.exports=function(r,e,t,n){e=e||"&",t=t||"=";var o={};if("string"!=typeof r||0===r.length)return o;var a=/\+/g;r=r.split(e);var s=1e3;n&&"number"==typeof n.maxKeys&&(s=n.maxKeys);var p=r.length;s>0&&p>s&&(p=s);for(var y=0;p>y;++y){var u,c,i,l,f=r[y].replace(a,"%20"),v=f.indexOf(t);v>=0?(u=f.substr(0,v),c=f.substr(v+1)):(u=f,c=""),i=decodeURIComponent(u),l=decodeURIComponent(c),hasOwnProperty(o,i)?isArray(o[i])?o[i].push(l):o[i]=[o[i],l]:o[i]=l}return o};var isArray=Array.isArray||function(r){return"[object Array]"===Object.prototype.toString.call(r)}; },{}],22:[function(require,module,exports){ "use strict";function map(r,e){if(r.map)return r.map(e);for(var t=[],n=0;n<r.length;n++)t.push(e(r[n],n));return t}var stringifyPrimitive=function(r){switch(typeof r){case"string":return r;case"boolean":return r?"true":"false";case"number":return isFinite(r)?r:"";default:return""}};module.exports=function(r,e,t,n){return e=e||"&",t=t||"=",null===r&&(r=void 0),"object"==typeof r?map(objectKeys(r),function(n){var i=encodeURIComponent(stringifyPrimitive(n))+t;return isArray(r[n])?map(r[n],function(r){return i+encodeURIComponent(stringifyPrimitive(r))}).join(e):i+encodeURIComponent(stringifyPrimitive(r[n]))}).join(e):n?encodeURIComponent(stringifyPrimitive(n))+t+encodeURIComponent(stringifyPrimitive(r)):""};var isArray=Array.isArray||function(r){return"[object Array]"===Object.prototype.toString.call(r)},objectKeys=Object.keys||function(r){var e=[];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&e.push(t);return e}; },{}],23:[function(require,module,exports){ "use strict";exports.decode=exports.parse=require("./decode"),exports.encode=exports.stringify=require("./encode"); },{"./decode":21,"./encode":22}],24:[function(require,module,exports){ 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}function urlParse(t,s,e){if(t&&isObject(t)&&t instanceof Url)return t;var h=new Url;return h.parse(t,s,e),h}function urlFormat(t){return isString(t)&&(t=urlParse(t)),t instanceof Url?t.format():Url.prototype.format.call(t)}function urlResolve(t,s){return urlParse(t,!1,!0).resolve(s)}function urlResolveObject(t,s){return t?urlParse(t,!1,!0).resolveObject(s):s}function isString(t){return"string"==typeof t}function isObject(t){return"object"==typeof t&&null!==t}function isNull(t){return null===t}function isNullOrUndefined(t){return null==t}var punycode=require("punycode");exports.parse=urlParse,exports.resolve=urlResolve,exports.resolveObject=urlResolveObject,exports.format=urlFormat,exports.Url=Url;var protocolPattern=/^([a-z0-9.+-]+:)/i,portPattern=/:[0-9]*$/,delims=["<",">",'"',"`"," ","\r","\n"," "],unwise=["{","}","|","\\","^","`"].concat(delims),autoEscape=["'"].concat(unwise),nonHostChars=["%","/","?",";","#"].concat(autoEscape),hostEndingChars=["/","?","#"],hostnameMaxLen=255,hostnamePartPattern=/^[a-z0-9A-Z_-]{0,63}$/,hostnamePartStart=/^([a-z0-9A-Z_-]{0,63})(.*)$/,unsafeProtocol={javascript:!0,"javascript:":!0},hostlessProtocol={javascript:!0,"javascript:":!0},slashedProtocol={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},querystring=require("querystring");Url.prototype.parse=function(t,s,e){if(!isString(t))throw new TypeError("Parameter 'url' must be a string, not "+typeof t);var h=t;h=h.trim();var r=protocolPattern.exec(h);if(r){r=r[0];var o=r.toLowerCase();this.protocol=o,h=h.substr(r.length)}if(e||r||h.match(/^\/\/[^@\/]+@[^@\/]+/)){var a="//"===h.substr(0,2);!a||r&&hostlessProtocol[r]||(h=h.substr(2),this.slashes=!0)}if(!hostlessProtocol[r]&&(a||r&&!slashedProtocol[r])){for(var n=-1,i=0;i<hostEndingChars.length;i++){var l=h.indexOf(hostEndingChars[i]);-1!==l&&(-1===n||n>l)&&(n=l)}var c,u;u=-1===n?h.lastIndexOf("@"):h.lastIndexOf("@",n),-1!==u&&(c=h.slice(0,u),h=h.slice(u+1),this.auth=decodeURIComponent(c)),n=-1;for(var i=0;i<nonHostChars.length;i++){var l=h.indexOf(nonHostChars[i]);-1!==l&&(-1===n||n>l)&&(n=l)}-1===n&&(n=h.length),this.host=h.slice(0,n),h=h.slice(n),this.parseHost(),this.hostname=this.hostname||"";var p="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!p)for(var f=this.hostname.split(/\./),i=0,m=f.length;m>i;i++){var v=f[i];if(v&&!v.match(hostnamePartPattern)){for(var g="",y=0,d=v.length;d>y;y++)g+=v.charCodeAt(y)>127?"x":v[y];if(!g.match(hostnamePartPattern)){var P=f.slice(0,i),b=f.slice(i+1),j=v.match(hostnamePartStart);j&&(P.push(j[1]),b.unshi