beam-interactive-node2
Version:
A NodeJS and Browser compatible client for mixer.com's interactive 2 Protocol
1 lines • 130 kB
JavaScript
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.interactive=e():t.interactive=e()}(this,function(){return function(t){function e(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,e),o.l=!0,o.exports}var r={};return e.m=t,e.c=r,e.i=function(t){return t},e.d=function(t,r,n){e.o(t,r)||Object.defineProperty(t,r,{configurable:!1,enumerable:!0,get:n})},e.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(r,"a",r),r},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=38)}([function(t,e){var r;r=function(){return this}();try{r=r||Function("return this")()||(0,eval)("this")}catch(t){"object"==typeof window&&(r=window)}t.exports=r},function(t,e){function r(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function n(t){return"function"==typeof t}function o(t){return"number"==typeof t}function i(t){return"object"==typeof t&&null!==t}function s(t){return void 0===t}t.exports=r,r.EventEmitter=r,r.prototype._events=void 0,r.prototype._maxListeners=void 0,r.defaultMaxListeners=10,r.prototype.setMaxListeners=function(t){if(!o(t)||t<0||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},r.prototype.emit=function(t){var e,r,o,a,u,c;if(this._events||(this._events={}),"error"===t&&(!this._events.error||i(this._events.error)&&!this._events.error.length)){if((e=arguments[1])instanceof Error)throw e;var h=new Error('Uncaught, unspecified "error" event. ('+e+")");throw h.context=e,h}if(r=this._events[t],s(r))return!1;if(n(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:a=Array.prototype.slice.call(arguments,1),r.apply(this,a)}else if(i(r))for(a=Array.prototype.slice.call(arguments,1),c=r.slice(),o=c.length,u=0;u<o;u++)c[u].apply(this,a);return!0},r.prototype.addListener=function(t,e){var o;if(!n(e))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",t,n(e.listener)?e.listener:e),this._events[t]?i(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,i(this._events[t])&&!this._events[t].warned&&(o=s(this._maxListeners)?r.defaultMaxListeners:this._maxListeners)&&o>0&&this._events[t].length>o&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),"function"==typeof console.trace&&console.trace()),this},r.prototype.on=r.prototype.addListener,r.prototype.once=function(t,e){function r(){this.removeListener(t,r),o||(o=!0,e.apply(this,arguments))}if(!n(e))throw TypeError("listener must be a function");var o=!1;return r.listener=e,this.on(t,r),this},r.prototype.removeListener=function(t,e){var r,o,s,a;if(!n(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(r=this._events[t],s=r.length,o=-1,r===e||n(r.listener)&&r.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(i(r)){for(a=s;a-- >0;)if(r[a]===e||r[a].listener&&r[a].listener===e){o=a;break}if(o<0)return this;1===r.length?(r.length=0,delete this._events[t]):r.splice(o,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},r.prototype.removeAllListeners=function(t){var e,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[t]&&delete this._events[t],this;if(0===arguments.length){for(e in this._events)"removeListener"!==e&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(r=this._events[t],n(r))this.removeListener(t,r);else if(r)for(;r.length;)this.removeListener(t,r[r.length-1]);return delete this._events[t],this},r.prototype.listeners=function(t){return this._events&&this._events[t]?n(this._events[t])?[this._events[t]]:this._events[t].slice():[]},r.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(n(e))return 1;if(e)return e.length}return 0},r.listenerCount=function(t,e){return t.listenerCount(e)}},function(t,e,r){"use strict";var n=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])};return function(e,r){function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(e,"__esModule",{value:!0});var o=function(t){function e(e){var r=t.call(this)||this;if(r.message=e,Error.captureStackTrace)return Error.captureStackTrace(r,r.constructor),r;var n=(new Error).stack.split("\n");return n.splice(1,1),r.stack=n.join("\n"),r}return n(e,t),e.setProto=function(t){if(Object.setPrototypeOf)return void Object.setPrototypeOf(t,this.prototype);t.__proto__=this.prototype},e}(Error);e.BaseError=o;var i=function(t){function e(){var r=t.call(this,"Packet was cancelled or socket was closed before a reply was received.")||this;return e.setProto(r),r}return n(e,t),e}(o);e.CancelledError=i;var s=function(t){function e(r,n,o){var i=t.call(this,n)||this;return i.code=r,i.res=o,e.setProto(i),i}return n(e,t),e.prototype.cause=function(){return this.res},e}(o);e.HTTPError=s;var a=function(t){function e(r,n){var o=t.call(this,"You don't have permission to "+r+" from "+n+"!")||this;return e.setProto(o),o}return n(e,t),e}(o);e.PermissionDeniedError=a;var u=function(t){function e(r){var n=t.call(this,r)||this;return e.setProto(n),n}return n(e,t),e}(o);e.TimeoutError=u;var c=function(t){function e(r){var n=t.call(this,r)||this;return e.setProto(n),n}return n(e,t),e}(o);e.MessageParseError=c;var h=function(t){function e(r){var n=t.call(this,r)||this;return e.setProto(n),n}return n(e,t),e}(o);e.NoInteractiveServersAvailable=h;!function(t){function e(e){if(t.errors[e.code]){var n=new t.errors[e.code](e.message,e.code);return n.path=e.path,n}return new r(e.message,e.code)}var r=function(t){function e(r,n){var o=t.call(this,r)||this;return o.code=n,e.setProto(o),o}return n(e,t),e}(o);t.Base=r,t.errors={},t.startOfRange=4e3,t.fromSocketMessage=e;var i=function(t){function e(r){var n=t.call(this,r,1011)||this;return e.setProto(n),n}return n(e,t),e}(r);t.CloseUnknown=i,t.errors[1011]=i;var s=function(t){function e(r){var n=t.call(this,r,1012)||this;return e.setProto(n),n}return n(e,t),e}(r);t.CloseRestarting=s,t.errors[1012]=s;var a=function(t){function e(r){var n=t.call(this,r,4e3)||this;return e.setProto(n),n}return n(e,t),e}(r);t.InvalidPayload=a,t.errors[4e3]=a;var u=function(t){function e(r){var n=t.call(this,r,4001)||this;return e.setProto(n),n}return n(e,t),e}(r);t.PayloadDecompression=u,t.errors[4001]=u;var c=function(t){function e(r){var n=t.call(this,r,4002)||this;return e.setProto(n),n}return n(e,t),e}(r);t.UnknownPacketType=c,t.errors[4002]=c;var h=function(t){function e(r){var n=t.call(this,r,4003)||this;return e.setProto(n),n}return n(e,t),e}(r);t.UnknownMethodName=h,t.errors[4003]=h;var f=function(t){function e(r){var n=t.call(this,r,4004)||this;return e.setProto(n),n}return n(e,t),e}(r);t.InvalidMethodArguments=f,t.errors[4004]=f;var l=function(t){function e(r){var n=t.call(this,r,4006)||this;return e.setProto(n),n}return n(e,t),e}(r);t.InvalidTransactionId=l,t.errors[4006]=l;var p=function(t){function e(r){var n=t.call(this,r,4007)||this;return e.setProto(n),n}return n(e,t),e}(r);t.NotEnoughSparks=p,t.errors[4007]=p;var d=function(t){function e(r){var n=t.call(this,r,4008)||this;return e.setProto(n),n}return n(e,t),e}(r);t.UnknownGroup=d,t.errors[4008]=d;var y=function(t){function e(r){var n=t.call(this,r,4009)||this;return e.setProto(n),n}return n(e,t),e}(r);t.GroupAlreadyExists=y,t.errors[4009]=y;var v=function(t){function e(r){var n=t.call(this,r,4010)||this;return e.setProto(n),n}return n(e,t),e}(r);t.UnknownSceneId=v,t.errors[4010]=v;var g=function(t){function e(r){var n=t.call(this,r,4011)||this;return e.setProto(n),n}return n(e,t),e}(r);t.SceneAlreadyExists=g,t.errors[4011]=g;var m=function(t){function e(r){var n=t.call(this,r,4012)||this;return e.setProto(n),n}return n(e,t),e}(r);t.UnknownControlId=m,t.errors[4012]=m;var b=function(t){function e(r){var n=t.call(this,r,4013)||this;return e.setProto(n),n}return n(e,t),e}(r);t.ControlAlreadyExists=b,t.errors[4013]=b;var w=function(t){function e(r){var n=t.call(this,r,4014)||this;return e.setProto(n),n}return n(e,t),e}(r);t.UnknownControlType=w,t.errors[4014]=w;var _=function(t){function e(r){var n=t.call(this,r,4015)||this;return e.setProto(n),n}return n(e,t),e}(r);t.UnknownParticipant=_,t.errors[4015]=_;var S=function(t){function e(r){var n=t.call(this,r,4016)||this;return e.setProto(n),n}return n(e,t),e}(r);t.SessionClosing=S,t.errors[4016]=S;var C=function(t){function e(r){var n=t.call(this,r,4017)||this;return e.setProto(n),n}return n(e,t),e}(r);t.OutOfMemory=C,t.errors[4017]=C;var E=function(t){function e(r){var n=t.call(this,r,4018)||this;return e.setProto(n),n}return n(e,t),e}(r);t.CannotDeleteDefault=E,t.errors[4018]=E;var P=function(t){function e(r){var n=t.call(this,r,4019)||this;return e.setProto(n),n}return n(e,t),e}(r);t.CannotAuthenticate=P,t.errors[4019]=P;var T=function(t){function e(r){var n=t.call(this,r,4020)||this;return e.setProto(n),n}return n(e,t),e}(r);t.NoInteractiveVersion=T,t.errors[4020]=T;var k=function(t){function e(r){var n=t.call(this,r,4021)||this;return e.setProto(n),n}return n(e,t),e}(r);t.SessionConflict=k,t.errors[4021]=k;var x=function(t){function e(r){var n=t.call(this,r,4022)||this;return e.setProto(n),n}return n(e,t),e}(r);t.ChannelNotInteractive=x,t.errors[4022]=x;var O=function(t){function e(r){var n=t.call(this,r,4999)||this;return e.setProto(n),n}return n(e,t),e}(r);t.BadUserInput=O,t.errors[4999]=O}(e.InteractiveError||(e.InteractiveError={}))},function(t,e){"function"==typeof Object.create?t.exports=function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:t.exports=function(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}},function(t,e,r){"use strict";var n=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])};return function(e,r){function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),o=this&&this.__assign||Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++){e=arguments[r];for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])}return t};Object.defineProperty(e,"__esModule",{value:!0});var i=r(1),s=r(10),a=function(t){function e(e){var r=t.call(this)||this;return s.merge(r,e),r}return n(e,t),e.prototype.setScene=function(t){this.scene=t},e.prototype.setClient=function(t){this.client=t},e.prototype.receiveInput=function(t,e){this.emit(t.input.event,t,e)},e.prototype.sendInput=function(t){return t.controlID=this.controlID,this.client.giveInput(t)},e.prototype.disable=function(){return this.updateAttribute("disabled",!0)},e.prototype.enable=function(){return this.updateAttribute("disabled",!1)},e.prototype.updateAttribute=function(t,e){var r={};return r.controlID=this.controlID,r[t]=e,this.client.updateControls({sceneID:this.scene.sceneID,controls:[r]})},e.prototype.onUpdate=function(t){s.merge(this,t),this.emit("updated",this)},e.prototype.update=function(t){var e=o({},t,{controlID:this.controlID});return this.client.updateControls({sceneID:this.scene.sceneID,controls:[e]})},e.prototype.destroy=function(){this.emit("deleted",this)},e}(i.EventEmitter);e.Control=a},function(t,e){function r(){throw new Error("setTimeout has not been defined")}function n(){throw new Error("clearTimeout has not been defined")}function o(t){if(h===setTimeout)return setTimeout(t,0);if((h===r||!h)&&setTimeout)return h=setTimeout,setTimeout(t,0);try{return h(t,0)}catch(e){try{return h.call(null,t,0)}catch(e){return h.call(this,t,0)}}}function i(t){if(f===clearTimeout)return clearTimeout(t);if((f===n||!f)&&clearTimeout)return f=clearTimeout,clearTimeout(t);try{return f(t)}catch(e){try{return f.call(null,t)}catch(e){return f.call(this,t)}}}function s(){y&&p&&(y=!1,p.length?d=p.concat(d):v=-1,d.length&&a())}function a(){if(!y){var t=o(s);y=!0;for(var e=d.length;e;){for(p=d,d=[];++v<e;)p&&p[v].run();v=-1,e=d.length}p=null,y=!1,i(t)}}function u(t,e){this.fun=t,this.array=e}function c(){}var h,f,l=t.exports={};!function(){try{h="function"==typeof setTimeout?setTimeout:r}catch(t){h=r}try{f="function"==typeof clearTimeout?clearTimeout:n}catch(t){f=n}}();var p,d=[],y=!1,v=-1;l.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)e[r-1]=arguments[r];d.push(new u(t,e)),1!==d.length||y||o(a)},u.prototype.run=function(){this.fun.apply(null,this.array)},l.title="browser",l.browser=!0,l.env={},l.argv=[],l.version="",l.versions={},l.on=c,l.addListener=c,l.once=c,l.off=c,l.removeListener=c,l.removeAllListeners=c,l.emit=c,l.prependListener=c,l.prependOnceListener=c,l.listeners=function(t){return[]},l.binding=function(t){throw new Error("process.binding is not supported")},l.cwd=function(){return"/"},l.chdir=function(t){throw new Error("process.chdir is not supported")},l.umask=function(){return 0}},function(t,e,r){"use strict";function n(t){if(!(this instanceof n))return new n(t);c.call(this,t),h.call(this,t),t&&!1===t.readable&&(this.readable=!1),t&&!1===t.writable&&(this.writable=!1),this.allowHalfOpen=!0,t&&!1===t.allowHalfOpen&&(this.allowHalfOpen=!1),this.once("end",o)}function o(){this.allowHalfOpen||this._writableState.ended||s.nextTick(i,this)}function i(t){t.end()}var s=r(11),a=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};t.exports=n;var u=r(8);u.inherits=r(3);var c=r(22),h=r(24);u.inherits(n,c);for(var f=a(h.prototype),l=0;l<f.length;l++){var p=f[l];n.prototype[p]||(n.prototype[p]=h.prototype[p])}Object.defineProperty(n.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(n.prototype,"destroyed",{get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed&&this._writableState.destroyed)},set:function(t){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=t,this._writableState.destroyed=t)}}),n.prototype._destroy=function(t,e){this.push(null),this.end(),s.nextTick(e,t)}},function(t,e,r){"use strict";(function(t){function n(){return i.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function o(t,e){if(n()<e)throw new RangeError("Invalid typed array length");return i.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e),t.__proto__=i.prototype):(null===t&&(t=new i(e)),t.length=e),t}function i(t,e,r){if(!(i.TYPED_ARRAY_SUPPORT||this instanceof i))return new i(t,e,r);if("number"==typeof t){if("string"==typeof e)throw new Error("If encoding is specified then the first argument must be a string");return c(this,t)}return s(this,t,e,r)}function s(t,e,r,n){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer?l(t,e,r,n):"string"==typeof e?h(t,e,r):p(t,e)}function a(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function u(t,e,r,n){return a(e),e<=0?o(t,e):void 0!==r?"string"==typeof n?o(t,e).fill(r,n):o(t,e).fill(r):o(t,e)}function c(t,e){if(a(e),t=o(t,e<0?0:0|d(e)),!i.TYPED_ARRAY_SUPPORT)for(var r=0;r<e;++r)t[r]=0;return t}function h(t,e,r){if("string"==typeof r&&""!==r||(r="utf8"),!i.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|v(e,r);t=o(t,n);var s=t.write(e,r);return s!==n&&(t=t.slice(0,s)),t}function f(t,e){var r=e.length<0?0:0|d(e.length);t=o(t,r);for(var n=0;n<r;n+=1)t[n]=255&e[n];return t}function l(t,e,r,n){if(e.byteLength,r<0||e.byteLength<r)throw new RangeError("'offset' is out of bounds");if(e.byteLength<r+(n||0))throw new RangeError("'length' is out of bounds");return e=void 0===r&&void 0===n?new Uint8Array(e):void 0===n?new Uint8Array(e,r):new Uint8Array(e,r,n),i.TYPED_ARRAY_SUPPORT?(t=e,t.__proto__=i.prototype):t=f(t,e),t}function p(t,e){if(i.isBuffer(e)){var r=0|d(e.length);return t=o(t,r),0===t.length?t:(e.copy(t,0,0,r),t)}if(e){if("undefined"!=typeof ArrayBuffer&&e.buffer instanceof ArrayBuffer||"length"in e)return"number"!=typeof e.length||V(e.length)?o(t,0):f(t,e);if("Buffer"===e.type&&Z(e.data))return f(t,e.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function d(t){if(t>=n())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+n().toString(16)+" bytes");return 0|t}function y(t){return+t!=t&&(t=0),i.alloc(+t)}function v(t,e){if(i.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var r=t.length;if(0===r)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return W(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return X(t).length;default:if(n)return W(t).length;e=(""+e).toLowerCase(),n=!0}}function g(t,e,r){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if(r>>>=0,e>>>=0,r<=e)return"";for(t||(t="utf8");;)switch(t){case"hex":return I(this,e,r);case"utf8":case"utf-8":return x(this,e,r);case"ascii":return A(this,e,r);case"latin1":case"binary":return R(this,e,r);case"base64":return k(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return M(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function m(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function b(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=i.from(e,n)),i.isBuffer(e))return 0===e.length?-1:w(t,e,r,n,o);if("number"==typeof e)return e&=255,i.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):w(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function w(t,e,r,n,o){function i(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}var s=1,a=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s=2,a/=2,u/=2,r/=2}var c;if(o){var h=-1;for(c=r;c<a;c++)if(i(t,c)===i(e,-1===h?0:c-h)){if(-1===h&&(h=c),c-h+1===u)return h*s}else-1!==h&&(c-=c-h),h=-1}else for(r+u>a&&(r=a-u),c=r;c>=0;c--){for(var f=!0,l=0;l<u;l++)if(i(t,c+l)!==i(e,l)){f=!1;break}if(f)return c}return-1}function _(t,e,r,n){r=Number(r)||0;var o=t.length-r;n?(n=Number(n))>o&&(n=o):n=o;var i=e.length;if(i%2!=0)throw new TypeError("Invalid hex string");n>i/2&&(n=i/2);for(var s=0;s<n;++s){var a=parseInt(e.substr(2*s,2),16);if(isNaN(a))return s;t[r+s]=a}return s}function S(t,e,r,n){return J(W(e,t.length-r),t,r,n)}function C(t,e,r,n){return J(z(e),t,r,n)}function E(t,e,r,n){return C(t,e,r,n)}function P(t,e,r,n){return J(X(e),t,r,n)}function T(t,e,r,n){return J(Y(e,t.length-r),t,r,n)}function k(t,e,r){return 0===e&&r===t.length?$.fromByteArray(t):$.fromByteArray(t.slice(e,r))}function x(t,e,r){r=Math.min(t.length,r);for(var n=[],o=e;o<r;){var i=t[o],s=null,a=i>239?4:i>223?3:i>191?2:1;if(o+a<=r){var u,c,h,f;switch(a){case 1:i<128&&(s=i);break;case 2:u=t[o+1],128==(192&u)&&(f=(31&i)<<6|63&u)>127&&(s=f);break;case 3:u=t[o+1],c=t[o+2],128==(192&u)&&128==(192&c)&&(f=(15&i)<<12|(63&u)<<6|63&c)>2047&&(f<55296||f>57343)&&(s=f);break;case 4:u=t[o+1],c=t[o+2],h=t[o+3],128==(192&u)&&128==(192&c)&&128==(192&h)&&(f=(15&i)<<18|(63&u)<<12|(63&c)<<6|63&h)>65535&&f<1114112&&(s=f)}}null===s?(s=65533,a=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|1023&s),n.push(s),o+=a}return O(n)}function O(t){var e=t.length;if(e<=Q)return String.fromCharCode.apply(String,t);for(var r="",n=0;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=Q));return r}function A(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;o<r;++o)n+=String.fromCharCode(127&t[o]);return n}function R(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;o<r;++o)n+=String.fromCharCode(t[o]);return n}function I(t,e,r){var n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);for(var o="",i=e;i<r;++i)o+=F(t[i]);return o}function M(t,e,r){for(var n=t.slice(e,r),o="",i=0;i<n.length;i+=2)o+=String.fromCharCode(n[i]+256*n[i+1]);return o}function j(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function D(t,e,r,n,o,s){if(!i.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||e<s)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function U(t,e,r,n){e<0&&(e=65535+e+1);for(var o=0,i=Math.min(t.length-r,2);o<i;++o)t[r+o]=(e&255<<8*(n?o:1-o))>>>8*(n?o:1-o)}function L(t,e,r,n){e<0&&(e=4294967295+e+1);for(var o=0,i=Math.min(t.length-r,4);o<i;++o)t[r+o]=e>>>8*(n?o:3-o)&255}function B(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function q(t,e,r,n,o){return o||B(t,e,r,4,3.4028234663852886e38,-3.4028234663852886e38),K.write(t,e,r,n,23,4),r+4}function N(t,e,r,n,o){return o||B(t,e,r,8,1.7976931348623157e308,-1.7976931348623157e308),K.write(t,e,r,n,52,8),r+8}function H(t){if(t=G(t).replace(tt,""),t.length<2)return"";for(;t.length%4!=0;)t+="=";return t}function G(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function F(t){return t<16?"0"+t.toString(16):t.toString(16)}function W(t,e){e=e||1/0;for(var r,n=t.length,o=null,i=[],s=0;s<n;++s){if((r=t.charCodeAt(s))>55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(s+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function z(t){for(var e=[],r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}function Y(t,e){for(var r,n,o,i=[],s=0;s<t.length&&!((e-=2)<0);++s)r=t.charCodeAt(s),n=r>>8,o=r%256,i.push(o),i.push(n);return i}function X(t){return $.toByteArray(H(t))}function J(t,e,r,n){for(var o=0;o<n&&!(o+r>=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function V(t){return t!==t}var $=r(47),K=r(51),Z=r(21);e.Buffer=i,e.SlowBuffer=y,e.INSPECT_MAX_BYTES=50,i.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.TYPED_ARRAY_SUPPORT:function(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(t){return!1}}(),e.kMaxLength=n(),i.poolSize=8192,i._augment=function(t){return t.__proto__=i.prototype,t},i.from=function(t,e,r){return s(null,t,e,r)},i.TYPED_ARRAY_SUPPORT&&(i.prototype.__proto__=Uint8Array.prototype,i.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&i[Symbol.species]===i&&Object.defineProperty(i,Symbol.species,{value:null,configurable:!0})),i.alloc=function(t,e,r){return u(null,t,e,r)},i.allocUnsafe=function(t){return c(null,t)},i.allocUnsafeSlow=function(t){return c(null,t)},i.isBuffer=function(t){return!(null==t||!t._isBuffer)},i.compare=function(t,e){if(!i.isBuffer(t)||!i.isBuffer(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var r=t.length,n=e.length,o=0,s=Math.min(r,n);o<s;++o)if(t[o]!==e[o]){r=t[o],n=e[o];break}return r<n?-1:n<r?1:0},i.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},i.concat=function(t,e){if(!Z(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return i.alloc(0);var r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;var n=i.allocUnsafe(e),o=0;for(r=0;r<t.length;++r){var s=t[r];if(!i.isBuffer(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(n,o),o+=s.length}return n},i.byteLength=v,i.prototype._isBuffer=!0,i.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)m(this,e,e+1);return this},i.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)m(this,e,e+3),m(this,e+1,e+2);return this},i.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)m(this,e,e+7),m(this,e+1,e+6),m(this,e+2,e+5),m(this,e+3,e+4);return this},i.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?x(this,0,t):g.apply(this,arguments)},i.prototype.equals=function(t){if(!i.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===i.compare(this,t)},i.prototype.inspect=function(){var t="",r=e.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(t+=" ... ")),"<Buffer "+t+">"},i.prototype.compare=function(t,e,r,n,o){if(!i.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,n>>>=0,o>>>=0,this===t)return 0;for(var s=o-n,a=r-e,u=Math.min(s,a),c=this.slice(n,o),h=t.slice(e,r),f=0;f<u;++f)if(c[f]!==h[f]){s=c[f],a=h[f];break}return s<a?-1:a<s?1:0},i.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},i.prototype.indexOf=function(t,e,r){return b(this,t,e,r,!0)},i.prototype.lastIndexOf=function(t,e,r){return b(this,t,e,r,!1)},i.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e|=0,isFinite(r)?(r|=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return _(this,t,e,r);case"utf8":case"utf-8":return S(this,t,e,r);case"ascii":return C(this,t,e,r);case"latin1":case"binary":return E(this,t,e,r);case"base64":return P(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},i.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var Q=4096;i.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,t<0?(t+=r)<0&&(t=0):t>r&&(t=r),e<0?(e+=r)<0&&(e=0):e>r&&(e=r),e<t&&(e=t);var n;if(i.TYPED_ARRAY_SUPPORT)n=this.subarray(t,e),n.__proto__=i.prototype;else{var o=e-t;n=new i(o,void 0);for(var s=0;s<o;++s)n[s]=this[s+t]}return n},i.prototype.readUIntLE=function(t,e,r){t|=0,e|=0,r||j(t,e,this.length);for(var n=this[t],o=1,i=0;++i<e&&(o*=256);)n+=this[t+i]*o;return n},i.prototype.readUIntBE=function(t,e,r){t|=0,e|=0,r||j(t,e,this.length);for(var n=this[t+--e],o=1;e>0&&(o*=256);)n+=this[t+--e]*o;return n},i.prototype.readUInt8=function(t,e){return e||j(t,1,this.length),this[t]},i.prototype.readUInt16LE=function(t,e){return e||j(t,2,this.length),this[t]|this[t+1]<<8},i.prototype.readUInt16BE=function(t,e){return e||j(t,2,this.length),this[t]<<8|this[t+1]},i.prototype.readUInt32LE=function(t,e){return e||j(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},i.prototype.readUInt32BE=function(t,e){return e||j(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},i.prototype.readIntLE=function(t,e,r){t|=0,e|=0,r||j(t,e,this.length);for(var n=this[t],o=1,i=0;++i<e&&(o*=256);)n+=this[t+i]*o;return o*=128,n>=o&&(n-=Math.pow(2,8*e)),n},i.prototype.readIntBE=function(t,e,r){t|=0,e|=0,r||j(t,e,this.length);for(var n=e,o=1,i=this[t+--n];n>0&&(o*=256);)i+=this[t+--n]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*e)),i},i.prototype.readInt8=function(t,e){return e||j(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},i.prototype.readInt16LE=function(t,e){e||j(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},i.prototype.readInt16BE=function(t,e){e||j(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},i.prototype.readInt32LE=function(t,e){return e||j(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},i.prototype.readInt32BE=function(t,e){return e||j(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},i.prototype.readFloatLE=function(t,e){return e||j(t,4,this.length),K.read(this,t,!0,23,4)},i.prototype.readFloatBE=function(t,e){return e||j(t,4,this.length),K.read(this,t,!1,23,4)},i.prototype.readDoubleLE=function(t,e){return e||j(t,8,this.length),K.read(this,t,!0,52,8)},i.prototype.readDoubleBE=function(t,e){return e||j(t,8,this.length),K.read(this,t,!1,52,8)},i.prototype.writeUIntLE=function(t,e,r,n){if(t=+t,e|=0,r|=0,!n){D(this,t,e,r,Math.pow(2,8*r)-1,0)}var o=1,i=0;for(this[e]=255&t;++i<r&&(o*=256);)this[e+i]=t/o&255;return e+r},i.prototype.writeUIntBE=function(t,e,r,n){if(t=+t,e|=0,r|=0,!n){D(this,t,e,r,Math.pow(2,8*r)-1,0)}var o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},i.prototype.writeUInt8=function(t,e,r){return t=+t,e|=0,r||D(this,t,e,1,255,0),i.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},i.prototype.writeUInt16LE=function(t,e,r){return t=+t,e|=0,r||D(this,t,e,2,65535,0),i.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):U(this,t,e,!0),e+2},i.prototype.writeUInt16BE=function(t,e,r){return t=+t,e|=0,r||D(this,t,e,2,65535,0),i.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):U(this,t,e,!1),e+2},i.prototype.writeUInt32LE=function(t,e,r){return t=+t,e|=0,r||D(this,t,e,4,4294967295,0),i.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):L(this,t,e,!0),e+4},i.prototype.writeUInt32BE=function(t,e,r){return t=+t,e|=0,r||D(this,t,e,4,4294967295,0),i.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):L(this,t,e,!1),e+4},i.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e|=0,!n){var o=Math.pow(2,8*r-1);D(this,t,e,r,o-1,-o)}var i=0,s=1,a=0;for(this[e]=255&t;++i<r&&(s*=256);)t<0&&0===a&&0!==this[e+i-1]&&(a=1),this[e+i]=(t/s>>0)-a&255;return e+r},i.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e|=0,!n){var o=Math.pow(2,8*r-1);D(this,t,e,r,o-1,-o)}var i=r-1,s=1,a=0;for(this[e+i]=255&t;--i>=0&&(s*=256);)t<0&&0===a&&0!==this[e+i+1]&&(a=1),this[e+i]=(t/s>>0)-a&255;return e+r},i.prototype.writeInt8=function(t,e,r){return t=+t,e|=0,r||D(this,t,e,1,127,-128),i.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},i.prototype.writeInt16LE=function(t,e,r){return t=+t,e|=0,r||D(this,t,e,2,32767,-32768),i.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):U(this,t,e,!0),e+2},i.prototype.writeInt16BE=function(t,e,r){return t=+t,e|=0,r||D(this,t,e,2,32767,-32768),i.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):U(this,t,e,!1),e+2},i.prototype.writeInt32LE=function(t,e,r){return t=+t,e|=0,r||D(this,t,e,4,2147483647,-2147483648),i.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):L(this,t,e,!0),e+4},i.prototype.writeInt32BE=function(t,e,r){return t=+t,e|=0,r||D(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),i.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):L(this,t,e,!1),e+4},i.prototype.writeFloatLE=function(t,e,r){return q(this,t,e,!0,r)},i.prototype.writeFloatBE=function(t,e,r){return q(this,t,e,!1,r)},i.prototype.writeDoubleLE=function(t,e,r){return N(this,t,e,!0,r)},i.prototype.writeDoubleBE=function(t,e,r){return N(this,t,e,!1,r)},i.prototype.copy=function(t,e,r,n){if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r);var o,s=n-r;if(this===t&&r<e&&e<n)for(o=s-1;o>=0;--o)t[o+e]=this[o+r];else if(s<1e3||!i.TYPED_ARRAY_SUPPORT)for(o=0;o<s;++o)t[o+e]=this[o+r];else Uint8Array.prototype.set.call(t,this.subarray(r,r+s),e);return s},i.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),1===t.length){var o=t.charCodeAt(0);o<256&&(t=o)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!i.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof t&&(t&=255);if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0);var s;if("number"==typeof t)for(s=e;s<r;++s)this[s]=t;else{var a=i.isBuffer(t)?t:W(new i(t,n).toString()),u=a.length;for(s=0;s<r-e;++s)this[s+e]=a[s%u]}return this};var tt=/[^+\/0-9A-Za-z-_]/g}).call(e,r(0))},function(t,e,r){(function(t){function r(t){return Array.isArray?Array.isArray(t):"[object Array]"===v(t)}function n(t){return"boolean"==typeof t}function o(t){return null===t}function i(t){return null==t}function s(t){return"number"==typeof t}function a(t){return"string"==typeof t}function u(t){return"symbol"==typeof t}function c(t){return void 0===t}function h(t){return"[object RegExp]"===v(t)}function f(t){return"object"==typeof t&&null!==t}function l(t){return"[object Date]"===v(t)}function p(t){return"[object Error]"===v(t)||t instanceof Error}function d(t){return"function"==typeof t}function y(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t}function v(t){return Object.prototype.toString.call(t)}e.isArray=r,e.isBoolean=n,e.isNull=o,e.isNullOrUndefined=i,e.isNumber=s,e.isString=a,e.isSymbol=u,e.isUndefined=c,e.isRegExp=h,e.isObject=f,e.isDate=l,e.isError=p,e.isFunction=d,e.isPrimitive=y,e.isBuffer=t.isBuffer}).call(e,r(7).Buffer)},function(t,e,r){"use strict";function n(t,e,r){return void 0===r&&(r=12e4),new Promise(function(n,o){var i=!1,s=function(t){i=!0,n(t)};t.once(e,s),setTimeout(function(){i||(t.removeListener(e,s),o(new a.TimeoutError("Expected to get event "+e)))},r)})}function o(t,e){var r=new a.TimeoutError(t);return new Promise(function(t,n){setTimeout(function(){return n(r)},e)})}function i(t,e){return new Promise(function(r){setTimeout(function(){return r(e)},t)})}function s(t,e){return void 0===e&&(e=function(){return null}),function(r){if(!(r instanceof t))throw r;return e(r)}}Object.defineProperty(e,"__esModule",{value:!0});var a=r(2);e.resolveOn=n,e.timeout=o,e.delay=i,e.only=s},function(t,e,r){"use strict";function n(t,e){return Object.assign(t,o(t,e))}Object.defineProperty(e,"__esModule",{value:!0});var o=r(49);e.merge=n},function(t,e,r){"use strict";(function(e){function r(t,r,n,o){if("function"!=typeof t)throw new TypeError('"callback" argument must be a function');var i,s,a=arguments.length;switch(a){case 0:case 1:return e.nextTick(t);case 2:return e.nextTick(function(){t.call(null,r)});case 3:return e.nextTick(function(){t.call(null,r,n)});case 4:return e.nextTick(function(){t.call(null,r,n,o)});default:for(i=new Array(a-1),s=0;s<i.length;)i[s++]=arguments[s];return e.nextTick(function(){t.apply(null,i)})}}!e.version||0===e.version.indexOf("v0.")||0===e.version.indexOf("v1.")&&0!==e.version.indexOf("v1.8.")?t.exports={nextTick:r}:t.exports=e}).call(e,r(5))},function(t,e,r){function n(t,e){for(var r in t)e[r]=t[r]}function o(t,e,r){return s(t,e,r)}var i=r(7),s=i.Buffer;s.from&&s.alloc&&s.allocUnsafe&&s.allocUnsafeSlow?t.exports=i:(n(i,e),e.Buffer=o),n(s,o),o.from=function(t,e,r){if("number"==typeof t)throw new TypeError("Argument must not be a number");return s(t,e,r)},o.alloc=function(t,e,r){if("number"!=typeof t)throw new TypeError("Argument must be a number");var n=s(t);return void 0!==e?"string"==typeof r?n.fill(e,r):n.fill(e):n.fill(0),n},o.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return s(t)},o.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return i.SlowBuffer(t)}},function(t,e,r){"use strict";var n=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])};return function(e,r){function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(e,"__esModule",{value:!0});var o=r(1),i=r(2),s=r(18),a=r(39),u=r(9),c=r(17);!function(t){t[t.Participant=0]="Participant",t[t.GameClient=1]="GameClient"}(e.ClientType||(e.ClientType={}));var h=function(t){function e(e){var r=t.call(this)||this;return r.methodHandler=new s.MethodHandlerManager,r.clientType=e,r.state=new a.State(e),r.state.setClient(r),r.methodHandler.addHandler("hello",function(){r.emit("hello")}),r}return n(e,t),e.prototype.processMethod=function(t){return this.methodHandler.handle(t)},e.prototype.createSocket=function(t){var e=this;this.socket&&(this.socket.getState()!==c.SocketState.Closing&&this.socket.close(),this.socket=null),this.socket=new c.InteractiveSocket(t),this.socket.on("method",function(t){var r=e.processMethod(t);if(r)return void e.reply(r);var n=e.state.processMethod(t);n&&e.reply(n)}),this.socket.on("open",function(){return e.emit("open")}),this.socket.on("error",function(t){return e.emit("error",t)}),this.socket.on("message",function(t){return e.emit("message",t)}),this.socket.on("send",function(t){return e.emit("send",t)}),this.socket.on("close",function(t){return e.emit("close",t)})},e.prototype.setOptions=function(t){this.socket.setOptions(t)},e.prototype.open=function(t){var e=this;return this.state.reset(),this.createSocket(t),this.socket.connect(),u.resolveOn(this,"open").then(function(){return e})},e.prototype.close=function(){this.socket&&this.socket.close()},e.prototype.setCompression=function(t){var e=this;return this.socket.execute("setCompression",{params:t}).then(function(t){e.socket.setOptions({compressionScheme:t.scheme})})},e.prototype.reply=function(t){return this.socket.reply(t)},e.prototype.getScenes=function(){return this.execute("getScenes",null,!1)},e.prototype.synchronizeScenes=function(){var t=this;return this.getScenes().then(function(e){return t.state.synchronizeScenes(e)})},e.prototype.getGroups=function(){return this.execute("getGroups",null,!1)},e.prototype.synchronizeGroups=function(){var t=this;return this.getGroups().then(function(e){return t.state.synchronizeGroups(e)})},e.prototype.synchronizeState=function(){return Promise.all([this.synchronizeGroups(),this.synchronizeScenes()])},e.prototype.getTime=function(){return this.execute("getTime",null,!1).then(function(t){return t.time})},e.prototype.execute=function(t,e,r){return this.socket.execute(t,e,r)},e.prototype.createControls=function(t){throw new i.PermissionDeniedError("createControls","Participant")},e.prototype.createGroups=function(t){throw new i.PermissionDeniedError("createGroups","Participant")},e.prototype.createScene=function(t){throw new i.PermissionDeniedError("createScene","Participant")},e.prototype.createScenes=function(t){throw new i.PermissionDeniedError("createScenes","Participant")},e.prototype.updateControls=function(t){throw new i.PermissionDeniedError("updateControls","Participant")},e.prototype.updateGroups=function(t){throw new i.PermissionDeniedError("updateGroups","Participant")},e.prototype.updateScenes=function(t){throw new i.PermissionDeniedError("updateScenes","Participant")},e.prototype.updateParticipants=function(t){throw new i.PermissionDeniedError("updateParticipants","Participant")},e.prototype.giveInput=function(t){throw new i.PermissionDeniedError("giveInput","GameClient")},e.prototype.deleteControls=function(t){throw new i.PermissionDeniedError("deleteControls","Participant")},e.prototype.deleteGroup=function(t){throw new i.PermissionDeniedError("deleteGroup","Participant")},e.prototype.deleteScene=function(t){throw new i.PermissionDeniedError("deleteScene","Participant")},e.prototype.ready=function(t){throw new i.PermissionDeniedError("ready","Participant")},e}(o.EventEmitter);e.Client=h},function(t,e,r){"use strict";function n(){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 o(t,e,r){if(t&&c.isObject(t)&&t instanceof n)return t;var o=new n;return o.parse(t,e,r),o}function i(t){return c.isString(t)&&(t=o(t)),t instanceof n?t.format():n.prototype.format.call(t)}function s(t,e){return o(t,!1,!0).resolve(e)}function a(t,e){return t?o(t,!1,!0).resolveObject(e):e}var u=r(52),c=r(62);e.parse=o,e.resolve=s,e.resolveObject=a,e.format=i,e.Url=n;var h=/^([a-z0-9.+-]+:)/i,f=/:[0-9]*$/,l=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,p=["<",">",'"',"`"," ","\r","\n","\t"],d=["{","}","|","\\","^","`"].concat(p),y=["'"].concat(d),v=["%","/","?",";","#"].concat(y),g=["/","?","#"],m=/^[+a-z0-9A-Z_-]{0,63}$/,b=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,w={javascript:!0,"javascript:":!0},_={javascript:!0,"javascript:":!0},S={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},C=r(55);n.prototype.parse=function(t,e,r){if(!c.isString(t))throw new TypeError("Parameter 'url' must be a string, not "+typeof t);var n=t.indexOf("?"),o=-1!==n&&n<t.indexOf("#")?"?":"#",i=t.split(o),s=/\\/g;i[0]=i[0].replace(s,"/"),t=i.join(o);var a=t;if(a=a.trim(),!r&&1===t.split("#").length){var f=l.exec(a);if(f)return this.path=a,this.href=a,this.pathname=f[1],f[2]?(this.search=f[2],this.query=e?C.parse(this.search.substr(1)):this.search.substr(1)):e&&(this.search="",this.query={}),this}var p=h.exec(a);if(p){p=p[0];var d=p.toLowerCase();this.protocol=d,a=a.substr(p.length)}if(r||p||a.match(/^\/\/[^@\/]+@[^@\/]+/)){var E="//"===a.substr(0,2);!E||p&&_[p]||(a=a.substr(2),this.slashes=!0)}if(!_[p]&&(E||p&&!S[p])){for(var P=-1,T=0;T<g.length;T++){var k=a.indexOf(g[T]);-1!==k&&(-1===P||k<P)&&(P=k)}var x,O;O=-1===P?a.lastIndexOf("@"):a.lastIndexOf("@",P),-1!==O&&(x=a.slice(0,O),a=a.slice(O+1),this.auth=decodeURIComponent(x)),P=-1;for(var T=0;T<v.length;T++){var k=a.indexOf(v[T]);-1!==k&&(-1===P||k<P)&&(P=k)}-1===P&&(P=a.length),this.host=a.slice(0,P),a=a.slice(P),this.parseHost(),this.hostname=this.hostname||"";var A="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!A)for(var R=this.hostname.split(/\./),T=0,I=R.length;T<I;T++){var M=R[T];if(M&&!M.match(m)){for(var j="",D=0,U=M.length;D<U;D++)M.charCodeAt(D)>127?j+="x":j+=M[D];if(!j.match(m)){var L=R.slice(0,T),B=R.slice(T+1),q=M.match(b);q&&(L.push(q[1]),B.unshift(q[2])),B.length&&(a="/"+B.join(".")+a),this.hostname=L.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),A||(this.hostname=u.toASCII(this.hostname));var N=this.port?":"+this.port:"",H=this.hostname||"";this.host=H+N,this.href+=this.host,A&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==a[0]&&(a="/"+a))}if(!w[d])for(var T=0,I=y.length;T<I;T++){var G=y[T];if(-1!==a.indexOf(G)){var F=encodeURIComponent(G);F===G&&(F=escape(G)),a=a.split(G).join(F)}}var W=a.indexOf("#");-1!==W&&(this.hash=a.substr(W),a=a.slice(0,W));var z=a.indexOf("?");if(-1!==z?(this.search=a.substr(z),this.query=a.substr(z+1),e&&(this.query=C.parse(this.query)),a=a.slice(0,z)):e&&(this.search="",this.query={}),a&&(this.pathname=a),S[d]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){var N=this.pathname||"",Y=this.search||"";this.path=N+Y}return this.href=this.format(),this},n.prototype.format=function(){var t=this.auth||"";t&&(t=encodeURIComponent(t),t=t.replace(/%3A/i,":"),t+="@");var e=this.protocol||"",r=this.pathname||"",n=this.hash||"",o=!1,i="";this.host?o=t+this.host:this.hostname&&(o=t+(-1===this.hostname.indexOf(":")?this.hostname:"["+this.hostname+"]"),this.port&&(o+=":"+this.port)),this.query&&c.isObject(this.query)&&Object.keys(this.query).length&&(i=C.stringify(this.query));var s=this.search||i&&"?"+i||"";return e&&":"!==e.substr(-1)&&(e+=":"),this.slashes||(!e||S[e])&&!1!==o?(o="//"+(o||""),r&&"/"!==r.charAt(0)&&(r="/"+r)):o||(o=""),n&&"#"!==n.charAt(0)&&(n="#"+n),s&&"?"!==s.charAt(0)&&(s="?"+s),r=r.replace(/[?#]/g,function(t){return encodeURIComponent(t)}),s=s.replace("#","%23"),e+o+r+s+n},n.prototype.resolve=function(t){return this.resolveObject(o(t,!1,!0)).format()},n.prototype.resolveObject=function(t){if(c.isString(t)){var e=new n;e.parse(t,!1,!0),t=e}for(var r=new n,o=Object.keys(this),i=0;i<o.length;i++){var s=o[i];r[s]=this[s]}if(r.hash=t.hash,""===t.href)return r.href=r.format(),r;if(t.slashes&&!t.protocol){for(var a=Object.keys(t),u=0;u<a.length;u++){var h=a[u];"protocol"!==h&&(r[h]=t[h])}return S[r.protocol]&&r.hostname&&!r.pathname&&(r.path=r.pathname="/"),r.href=r.format(),r}if(t.protocol&&t.protocol!==r.protocol){if(!S[t.protocol]){for(var f=Object.keys(t),l=0;l<f.length;l++){var p=f[l];r[p]=t[p]}return r.href=r.format(),r}if(r.protocol=t.protocol,t.host||_[t.protocol])r.pathname=t.pathname;else{for(var d=(t.pathname||"").split("/");d.length&&!(t.host=d.shift()););t.host||(t.host=""),t.hostname||(t.hostname=""),""!==d[0]&&d.unshift(""),d.length<2&&d.unshift(""),r.pathname=d.join("/")}if(r.search=t.search,r.query=t.query,r.host=t.host||"",r.auth=t.auth,r.hostname=t.hostname||t.host,r.port=t.port,r.pathname||r.search){var y=r.pathname||"",v=r.search||"";r.path=y+v}return r.slashes=r.slashes||t.slashes,r.href=r.format(),r}var g=r.pathname&&"/"===r.pathname.charAt(0),m=t.host||t.pathname&&"/"===t.pathname.charAt(0),b=m||g||r.host&&t.pathname,w=b,C=r.pathname&&r.pathname.split("/")||[],d=t.pathname&&t.pathname.split("/")||[],E=r.protocol&&!S[r.protocol];if(E&&(r.hostname="",r.port=null,r.host&&(""===C[0]?C[0]=r.host:C.unshift(r.host)),r.host="",t.protocol&&(t.hostname=null,t.port=null,t.host&&(""===d[0]?d[0]=t.host:d.unshift(t.host)),t.host=null),b=b&&(""===d[0]||""===C[0])),m)r.host=t.host||""===t.host?t.host:r.host,r.hostname=t.hostname||""===t.hostname?t.hostname:r.hostname,r.search=t.search,r.query=t.query,C=d;else if(d.length)C||(C=[]),C.pop(),C=C.concat(d),r.search=t.search,r.query=t.query;else if(!c.isNullOrUndefined(t.search)){if(E){r.hostname=r.host=C.shift();var P=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@");P&&(r.auth=P.shift(),r.host=r.hostname=P.shift())}return r.search=t.search,r.query=t.query,c.isNull(r.pathname)&&c.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.href=r.format(),r}if(!C.length)return r.pathname=null,r.search?r.path="/"+r.search:r.path=null,r.href=r.format(),r;for(var T=C.slice(-1)[0],k=(r.host||t.host||C.length>1)&&("."===T||".."===T)||""===T,x=0,O=C.length;O>=0;O--)T=C[O],"."===T?C.splice(O,1):".."===T?(C.splice(O,1),x++):x&&(C.splice(O,1),x--);if(!b&&!w)for(;x--;x)C.unshift("..");!b||""===C[0]||C[0]&&"/"===C[0].charAt(0)||C.unshift(""),k&&"/"!==C.join("/").substr(-1)&&C.push("");var A=""===C[0]||C[0]&&"/"===C[0].charAt(0);if(E){r.hostname=r.host=A?"":C.length?C.shift():"";var P=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@");P&&(r.auth=P.shift(),r.host=r.hostname=P.shift())}return b=b||r.host&&C.length,b&&!A&&C.unshift(""),C.length?r.pathname=C.join("/"):(r.pathname=null,r.path=null),c.isNull(r.pathname)&&c.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.auth=t.auth||r.auth,r.slashes=r.slashes||t.slashes,r.href=r.format(),r},n.prototype.parseHost=function(){var t=this.host,e=f.exec(t);e&&(e=e[0],":"!==e&&(this.port=e.substr(1)),t=t.substr(0,t.length-e.length)),t&&(this.hostname=t)}},function(t,e,r){"use strict";var n=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])};return function(e,r){function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.definePr