@freeboardgame.org/boardgame.io
Version:
library for turn-based games
1 lines • 180 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("react"),require("three")):"function"==typeof define&&define.amd?define(["react","three"],t):(e=e||self).BoardgameIO=t(e.React,e.THREE)}(this,function(e,t){"use strict";var n="default"in e?e.default:e;function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function a(e,t,n){return t&&i(e.prototype,t),n&&i(e,n),e}function s(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function c(){return(c=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function u(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){s(e,t,n[t])})}return e}function l(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&h(e,t)}function p(e){return(p=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function h(e,t){return(h=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function f(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function d(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function y(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?d(e):t}function v(e){return function(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);t<e.length;t++)n[t]=e[t];return n}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}var g=function(e){var t,n=e.Symbol;return"function"==typeof n?n.observable?t=n.observable:(t=n("observable"),n.observable=t):t="@@observable",t}("undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof module?module:Function("return this")()),m=function(){return Math.random().toString(36).substring(7).split("").join(".")},b={INIT:"@@redux/INIT"+m(),REPLACE:"@@redux/REPLACE"+m(),PROBE_UNKNOWN_ACTION:function(){return"@@redux/PROBE_UNKNOWN_ACTION"+m()}};function w(e,t,n){var r;if("function"==typeof t&&"function"==typeof n||"function"==typeof n&&"function"==typeof arguments[3])throw new Error("It looks like you are passing several store enhancers to createStore(). This is not supported. Instead, compose them together to a single function");if("function"==typeof t&&void 0===n&&(n=t,t=void 0),void 0!==n){if("function"!=typeof n)throw new Error("Expected the enhancer to be a function.");return n(w)(e,t)}if("function"!=typeof e)throw new Error("Expected the reducer to be a function.");var o=e,i=t,a=[],s=a,c=!1;function u(){s===a&&(s=a.slice())}function l(){if(c)throw new Error("You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.");return i}function p(e){if("function"!=typeof e)throw new Error("Expected the listener to be a function.");if(c)throw new Error("You may not call store.subscribe() while the reducer is executing. If you would like to be notified after the store has been updated, subscribe from a component and invoke store.getState() in the callback to access the latest state. See https://redux.js.org/api-reference/store#subscribe(listener) for more details.");var t=!0;return u(),s.push(e),function(){if(t){if(c)throw new Error("You may not unsubscribe from a store listener while the reducer is executing. See https://redux.js.org/api-reference/store#subscribe(listener) for more details.");t=!1,u();var n=s.indexOf(e);s.splice(n,1)}}}function h(e){if(!function(e){if("object"!=typeof e||null===e)return!1;for(var t=e;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}(e))throw new Error("Actions must be plain objects. Use custom middleware for async actions.");if(void 0===e.type)throw new Error('Actions may not have an undefined "type" property. Have you misspelled a constant?');if(c)throw new Error("Reducers may not dispatch actions.");try{c=!0,i=o(i,e)}finally{c=!1}for(var t=a=s,n=0;n<t.length;n++){(0,t[n])()}return e}return h({type:b.INIT}),(r={dispatch:h,subscribe:p,getState:l,replaceReducer:function(e){if("function"!=typeof e)throw new Error("Expected the nextReducer to be a function.");o=e,h({type:b.REPLACE})}})[g]=function(){var e,t=p;return(e={subscribe:function(e){if("object"!=typeof e||null===e)throw new TypeError("Expected the observer to be an object.");function n(){e.next&&e.next(l())}return n(),{unsubscribe:t(n)}}})[g]=function(){return this},e},r}function k(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function x(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return 0===t.length?function(e){return e}:1===t.length?t[0]:t.reduce(function(e,t){return function(){return e(t.apply(void 0,arguments))}})}function C(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(e){return function(){var n=e.apply(void 0,arguments),r=function(){throw new Error("Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")},o={getState:n.getState,dispatch:function(){return r.apply(void 0,arguments)}},i=t.map(function(e){return e(o)});return function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){k(e,t,n[t])})}return e}({},n,{dispatch:r=x.apply(void 0,i)(n.dispatch)})}}}var D="MAKE_MOVE",E="GAME_EVENT",O="REDO",P="RESET",I="SYNC",_="UNDO",M="UPDATE",S=function(e,t,n,r){return{type:D,payload:{type:e,args:t,playerID:n,credentials:r}}},A=function(e,t,n,r){return{type:E,payload:{type:e,args:t,playerID:n,credentials:r}}},T=function(e,t,n,r){return{type:E,payload:{type:e,args:t,playerID:n,credentials:r},automatic:!0}},j=function(e,t){return{type:I,state:e,log:t,clientOnly:!0}},R=function(e,t){return{type:M,state:e,deltalog:t,clientOnly:!0}},N=function(e){return{type:P,state:e,clientOnly:!0}},B=function(){return{type:_}},z=function(){return{type:O}},L=Object.freeze({makeMove:S,gameEvent:A,automaticGameEvent:T,sync:j,update:R,reset:N,undo:B,redo:z});var F="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function q(e,t){return e(t={exports:{}},t.exports),t.exports}var U=/^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,G=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],H=function(e){var t=e,n=e.indexOf("["),r=e.indexOf("]");-1!=n&&-1!=r&&(e=e.substring(0,n)+e.substring(n,r).replace(/:/g,";")+e.substring(r,e.length));for(var o=U.exec(e||""),i={},a=14;a--;)i[G[a]]=o[a]||"";return-1!=n&&-1!=r&&(i.source=t,i.host=i.host.substring(1,i.host.length-1).replace(/;/g,":"),i.authority=i.authority.replace("[","").replace("]","").replace(/;/g,":"),i.ipv6uri=!0),i},X=1e3,Y=60*X,W=60*Y,K=24*W,V=365.25*K,J=function(e,t){t=t||{};var n,r=typeof e;if("string"===r&&e.length>0)return function(e){if((e=String(e)).length>100)return;var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(!t)return;var n=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return n*V;case"days":case"day":case"d":return n*K;case"hours":case"hour":case"hrs":case"hr":case"h":return n*W;case"minutes":case"minute":case"mins":case"min":case"m":return n*Y;case"seconds":case"second":case"secs":case"sec":case"s":return n*X;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}(e);if("number"===r&&!1===isNaN(e))return t.long?Z(n=e,K,"day")||Z(n,W,"hour")||Z(n,Y,"minute")||Z(n,X,"second")||n+" ms":function(e){if(e>=K)return Math.round(e/K)+"d";if(e>=W)return Math.round(e/W)+"h";if(e>=Y)return Math.round(e/Y)+"m";if(e>=X)return Math.round(e/X)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function Z(e,t,n){if(!(e<t))return e<1.5*t?Math.floor(e/t)+" "+n:Math.ceil(e/t)+" "+n+"s"}var $=q(function(e,t){function n(e){var n;function o(){if(o.enabled){var e=o,r=+new Date,i=r-(n||r);e.diff=i,e.prev=n,e.curr=r,n=r;for(var a=new Array(arguments.length),s=0;s<a.length;s++)a[s]=arguments[s];a[0]=t.coerce(a[0]),"string"!=typeof a[0]&&a.unshift("%O");var c=0;a[0]=a[0].replace(/%([a-zA-Z%])/g,function(n,r){if("%%"===n)return n;c++;var o=t.formatters[r];if("function"==typeof o){var i=a[c];n=o.call(e,i),a.splice(c,1),c--}return n}),t.formatArgs.call(e,a),(o.log||t.log||console.log.bind(console)).apply(e,a)}}return o.namespace=e,o.enabled=t.enabled(e),o.useColors=t.useColors(),o.color=function(e){var n,r=0;for(n in e)r=(r<<5)-r+e.charCodeAt(n),r|=0;return t.colors[Math.abs(r)%t.colors.length]}(e),o.destroy=r,"function"==typeof t.init&&t.init(o),t.instances.push(o),o}function r(){var e=t.instances.indexOf(this);return-1!==e&&(t.instances.splice(e,1),!0)}(t=e.exports=n.debug=n.default=n).coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){t.enable("")},t.enable=function(e){var n;t.save(e),t.names=[],t.skips=[];var r=("string"==typeof e?e:"").split(/[\s,]+/),o=r.length;for(n=0;n<o;n++)r[n]&&("-"===(e=r[n].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.substr(1)+"$")):t.names.push(new RegExp("^"+e+"$")));for(n=0;n<t.instances.length;n++){var i=t.instances[n];i.enabled=t.enabled(i.namespace)}},t.enabled=function(e){if("*"===e[e.length-1])return!0;var n,r;for(n=0,r=t.skips.length;n<r;n++)if(t.skips[n].test(e))return!1;for(n=0,r=t.names.length;n<r;n++)if(t.names[n].test(e))return!0;return!1},t.humanize=J,t.instances=[],t.names=[],t.skips=[],t.formatters={}}),Q=($.coerce,$.disable,$.enable,$.enabled,$.humanize,$.instances,$.names,$.skips,$.formatters,q(function(e,t){function n(){var e;try{e=t.storage.debug}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e}(t=e.exports=$).log=function(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)},t.formatArgs=function(e){var n=this.useColors;if(e[0]=(n?"%c":"")+this.namespace+(n?" %c":" ")+e[0]+(n?"%c ":" ")+"+"+t.humanize(this.diff),!n)return;var r="color: "+this.color;e.splice(1,0,r,"color: inherit");var o=0,i=0;e[0].replace(/%[a-zA-Z%]/g,function(e){"%%"!==e&&(o++,"%c"===e&&(i=o))}),e.splice(i,0,r)},t.save=function(e){try{null==e?t.storage.removeItem("debug"):t.storage.debug=e}catch(e){}},t.load=n,t.useColors=function(){if("undefined"!=typeof window&&window.process&&"renderer"===window.process.type)return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(e){}}(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},t.enable(n())})),ee=(Q.log,Q.formatArgs,Q.save,Q.load,Q.useColors,Q.storage,Q.colors,Q("socket.io-client:url")),te=function(e,t){var n=e;t=t||"undefined"!=typeof location&&location,null==e&&(e=t.protocol+"//"+t.host);"string"==typeof e&&("/"===e.charAt(0)&&(e="/"===e.charAt(1)?t.protocol+e:t.host+e),/^(https?|wss?):\/\//.test(e)||(ee("protocol-less url %s",e),e=void 0!==t?t.protocol+"//"+e:"https://"+e),ee("parse %s",e),n=H(e));n.port||(/^(http|ws)$/.test(n.protocol)?n.port="80":/^(http|ws)s$/.test(n.protocol)&&(n.port="443"));n.path=n.path||"/";var r=-1!==n.host.indexOf(":")?"["+n.host+"]":n.host;return n.id=n.protocol+"://"+r+":"+n.port,n.href=n.protocol+"://"+r+(t&&t.port===n.port?"":":"+n.port),n};var ne=q(function(e){function t(e){if(e)return function(e){for(var n in t.prototype)e[n]=t.prototype[n];return e}(e)}e.exports=t,t.prototype.on=t.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},t.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},t.prototype.off=t.prototype.removeListener=t.prototype.removeAllListeners=t.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,r=this._callbacks["$"+e];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var o=0;o<r.length;o++)if((n=r[o])===t||n.fn===t){r.splice(o,1);break}return this},t.prototype.emit=function(e){this._callbacks=this._callbacks||{};var t=[].slice.call(arguments,1),n=this._callbacks["$"+e];if(n)for(var r=0,o=(n=n.slice(0)).length;r<o;++r)n[r].apply(this,t);return this},t.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},t.prototype.hasListeners=function(e){return!!this.listeners(e).length}}),re={}.toString,oe=Array.isArray||function(e){return"[object Array]"==re.call(e)},ie=function(e){return ae&&Buffer.isBuffer(e)||se&&(e instanceof ArrayBuffer||ce(e))},ae="function"==typeof Buffer&&"function"==typeof Buffer.isBuffer,se="function"==typeof ArrayBuffer,ce=function(e){return"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer};var ue=Object.prototype.toString,le="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===ue.call(Blob),pe="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===ue.call(File);var he={deconstructPacket:function(e){var t=[],n=e.data,r=e;return r.data=function e(t,n){if(!t)return t;if(ie(t)){var r={_placeholder:!0,num:n.length};return n.push(t),r}if(oe(t)){for(var o=new Array(t.length),i=0;i<t.length;i++)o[i]=e(t[i],n);return o}if("object"==typeof t&&!(t instanceof Date)){var o={};for(var a in t)o[a]=e(t[a],n);return o}return t}(n,t),r.attachments=t.length,{packet:r,buffers:t}},reconstructPacket:function(e,t){return e.data=function e(t,n){if(!t)return t;if(t&&t._placeholder)return n[t.num];if(oe(t))for(var r=0;r<t.length;r++)t[r]=e(t[r],n);else if("object"==typeof t)for(var o in t)t[o]=e(t[o],n);return t}(e.data,t),e.attachments=void 0,e},removeBlobs:function(e,t){var n=0,r=e;!function e(o,i,a){if(!o)return o;if(le&&o instanceof Blob||pe&&o instanceof File){n++;var s=new FileReader;s.onload=function(){a?a[i]=this.result:r=this.result,--n||t(r)},s.readAsArrayBuffer(o)}else if(oe(o))for(var c=0;c<o.length;c++)e(o[c],c,o);else if("object"==typeof o&&!ie(o))for(var u in o)e(o[u],u,o)}(r),n||t(r)}},fe=q(function(e,t){var n=Q("socket.io-parser");function r(){}t.protocol=4,t.types=["CONNECT","DISCONNECT","EVENT","ACK","ERROR","BINARY_EVENT","BINARY_ACK"],t.CONNECT=0,t.DISCONNECT=1,t.EVENT=2,t.ACK=3,t.ERROR=4,t.BINARY_EVENT=5,t.BINARY_ACK=6,t.Encoder=r,t.Decoder=a;var o=t.ERROR+'"encode error"';function i(e){var r=""+e.type;if(t.BINARY_EVENT!==e.type&&t.BINARY_ACK!==e.type||(r+=e.attachments+"-"),e.nsp&&"/"!==e.nsp&&(r+=e.nsp+","),null!=e.id&&(r+=e.id),null!=e.data){var i=function(e){try{return JSON.stringify(e)}catch(e){return!1}}(e.data);if(!1===i)return o;r+=i}return n("encoded %j as %s",e,r),r}function a(){this.reconstructor=null}function s(e){this.reconPack=e,this.buffers=[]}function c(e){return{type:t.ERROR,data:"parser error: "+e}}r.prototype.encode=function(e,r){(n("encoding packet %j",e),t.BINARY_EVENT===e.type||t.BINARY_ACK===e.type)?function(e,t){he.removeBlobs(e,function(e){var n=he.deconstructPacket(e),r=i(n.packet),o=n.buffers;o.unshift(r),t(o)})}(e,r):r([i(e)])},ne(a.prototype),a.prototype.add=function(e){var r;if("string"==typeof e)r=function(e){var r=0,o={type:Number(e.charAt(0))};if(null==t.types[o.type])return c("unknown packet type "+o.type);if(t.BINARY_EVENT===o.type||t.BINARY_ACK===o.type){for(var i="";"-"!==e.charAt(++r)&&(i+=e.charAt(r),r!=e.length););if(i!=Number(i)||"-"!==e.charAt(r))throw new Error("Illegal attachments");o.attachments=Number(i)}if("/"===e.charAt(r+1))for(o.nsp="";++r;){var a=e.charAt(r);if(","===a)break;if(o.nsp+=a,r===e.length)break}else o.nsp="/";var s=e.charAt(r+1);if(""!==s&&Number(s)==s){for(o.id="";++r;){var a=e.charAt(r);if(null==a||Number(a)!=a){--r;break}if(o.id+=e.charAt(r),r===e.length)break}o.id=Number(o.id)}if(e.charAt(++r)){var u=function(e){try{return JSON.parse(e)}catch(e){return!1}}(e.substr(r)),l=!1!==u&&(o.type===t.ERROR||oe(u));if(!l)return c("invalid payload");o.data=u}return n("decoded %s as %j",e,o),o}(e),t.BINARY_EVENT===r.type||t.BINARY_ACK===r.type?(this.reconstructor=new s(r),0===this.reconstructor.reconPack.attachments&&this.emit("decoded",r)):this.emit("decoded",r);else{if(!ie(e)&&!e.base64)throw new Error("Unknown type: "+e);if(!this.reconstructor)throw new Error("got binary data when not reconstructing a packet");(r=this.reconstructor.takeBinaryData(e))&&(this.reconstructor=null,this.emit("decoded",r))}},a.prototype.destroy=function(){this.reconstructor&&this.reconstructor.finishedReconstruction()},s.prototype.takeBinaryData=function(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){var t=he.reconstructPacket(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null},s.prototype.finishedReconstruction=function(){this.reconPack=null,this.buffers=[]}}),de=(fe.protocol,fe.types,fe.CONNECT,fe.DISCONNECT,fe.EVENT,fe.ACK,fe.ERROR,fe.BINARY_EVENT,fe.BINARY_ACK,fe.Encoder,fe.Decoder,q(function(e){try{e.exports="undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest}catch(t){e.exports=!1}})),ye=function(e){var t=e.xdomain,n=e.xscheme,r=e.enablesXDR;try{if("undefined"!=typeof XMLHttpRequest&&(!t||de))return new XMLHttpRequest}catch(e){}try{if("undefined"!=typeof XDomainRequest&&!n&&r)return new XDomainRequest}catch(e){}if(!t)try{return new(self[["Active"].concat("Object").join("X")])("Microsoft.XMLHTTP")}catch(e){}},ve=Object.keys||function(e){var t=[],n=Object.prototype.hasOwnProperty;for(var r in e)n.call(e,r)&&t.push(r);return t},ge={}.toString,me=Array.isArray||function(e){return"[object Array]"==ge.call(e)},be=Object.prototype.toString,we="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===be.call(Blob),ke="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===be.call(File),xe=function e(t){if(!t||"object"!=typeof t)return!1;if(me(t)){for(var n=0,r=t.length;n<r;n++)if(e(t[n]))return!0;return!1}if("function"==typeof Buffer&&Buffer.isBuffer&&Buffer.isBuffer(t)||"function"==typeof ArrayBuffer&&t instanceof ArrayBuffer||we&&t instanceof Blob||ke&&t instanceof File)return!0;if(t.toJSON&&"function"==typeof t.toJSON&&1===arguments.length)return e(t.toJSON(),!0);for(var o in t)if(Object.prototype.hasOwnProperty.call(t,o)&&e(t[o]))return!0;return!1};var Ce=function(e,t,n){var r=e.byteLength;if(t=t||0,n=n||r,e.slice)return e.slice(t,n);if(t<0&&(t+=r),n<0&&(n+=r),n>r&&(n=r),t>=r||t>=n||0===r)return new ArrayBuffer(0);for(var o=new Uint8Array(e),i=new Uint8Array(n-t),a=t,s=0;a<n;a++,s++)i[s]=o[a];return i.buffer},De=function(e,t,n){var r=!1;return n=n||Ee,o.count=e,0===e?t():o;function o(e,i){if(o.count<=0)throw new Error("after called too many times");--o.count,e?(r=!0,t(e),t=n):0!==o.count||r||t(null,i)}};function Ee(){}var Oe,Pe,Ie,_e=String.fromCharCode;function Me(e){for(var t,n,r=[],o=0,i=e.length;o<i;)(t=e.charCodeAt(o++))>=55296&&t<=56319&&o<i?56320==(64512&(n=e.charCodeAt(o++)))?r.push(((1023&t)<<10)+(1023&n)+65536):(r.push(t),o--):r.push(t);return r}function Se(e,t){if(e>=55296&&e<=57343){if(t)throw Error("Lone surrogate U+"+e.toString(16).toUpperCase()+" is not a scalar value");return!1}return!0}function Ae(e,t){return _e(e>>t&63|128)}function Te(e,t){if(0==(4294967168&e))return _e(e);var n="";return 0==(4294965248&e)?n=_e(e>>6&31|192):0==(4294901760&e)?(Se(e,t)||(e=65533),n=_e(e>>12&15|224),n+=Ae(e,6)):0==(4292870144&e)&&(n=_e(e>>18&7|240),n+=Ae(e,12),n+=Ae(e,6)),n+=_e(63&e|128)}function je(){if(Ie>=Pe)throw Error("Invalid byte index");var e=255&Oe[Ie];if(Ie++,128==(192&e))return 63&e;throw Error("Invalid continuation byte")}function Re(e){var t,n;if(Ie>Pe)throw Error("Invalid byte index");if(Ie==Pe)return!1;if(t=255&Oe[Ie],Ie++,0==(128&t))return t;if(192==(224&t)){if((n=(31&t)<<6|je())>=128)return n;throw Error("Invalid continuation byte")}if(224==(240&t)){if((n=(15&t)<<12|je()<<6|je())>=2048)return Se(n,e)?n:65533;throw Error("Invalid continuation byte")}if(240==(248&t)&&(n=(7&t)<<18|je()<<12|je()<<6|je())>=65536&&n<=1114111)return n;throw Error("Invalid UTF-8 detected")}var Ne={version:"2.1.2",encode:function(e,t){for(var n=!1!==(t=t||{}).strict,r=Me(e),o=r.length,i=-1,a="";++i<o;)a+=Te(r[i],n);return a},decode:function(e,t){var n=!1!==(t=t||{}).strict;Oe=Me(e),Pe=Oe.length,Ie=0;for(var r,o=[];!1!==(r=Re(n));)o.push(r);return function(e){for(var t,n=e.length,r=-1,o="";++r<n;)(t=e[r])>65535&&(o+=_e((t-=65536)>>>10&1023|55296),t=56320|1023&t),o+=_e(t);return o}(o)}},Be=q(function(e,t){!function(){for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n=new Uint8Array(256),r=0;r<e.length;r++)n[e.charCodeAt(r)]=r;t.encode=function(t){var n,r=new Uint8Array(t),o=r.length,i="";for(n=0;n<o;n+=3)i+=e[r[n]>>2],i+=e[(3&r[n])<<4|r[n+1]>>4],i+=e[(15&r[n+1])<<2|r[n+2]>>6],i+=e[63&r[n+2]];return o%3==2?i=i.substring(0,i.length-1)+"=":o%3==1&&(i=i.substring(0,i.length-2)+"=="),i},t.decode=function(e){var t,r,o,i,a,s=.75*e.length,c=e.length,u=0;"="===e[e.length-1]&&(s--,"="===e[e.length-2]&&s--);var l=new ArrayBuffer(s),p=new Uint8Array(l);for(t=0;t<c;t+=4)r=n[e.charCodeAt(t)],o=n[e.charCodeAt(t+1)],i=n[e.charCodeAt(t+2)],a=n[e.charCodeAt(t+3)],p[u++]=r<<2|o>>4,p[u++]=(15&o)<<4|i>>2,p[u++]=(3&i)<<6|63&a;return l}}()}),ze=(Be.encode,Be.decode,void 0!==ze?ze:"undefined"!=typeof WebKitBlobBuilder?WebKitBlobBuilder:"undefined"!=typeof MSBlobBuilder?MSBlobBuilder:"undefined"!=typeof MozBlobBuilder&&MozBlobBuilder),Le=function(){try{return 2===new Blob(["hi"]).size}catch(e){return!1}}(),Fe=Le&&function(){try{return 2===new Blob([new Uint8Array([1,2])]).size}catch(e){return!1}}(),qe=ze&&ze.prototype.append&&ze.prototype.getBlob;function Ue(e){return e.map(function(e){if(e.buffer instanceof ArrayBuffer){var t=e.buffer;if(e.byteLength!==t.byteLength){var n=new Uint8Array(e.byteLength);n.set(new Uint8Array(t,e.byteOffset,e.byteLength)),t=n.buffer}return t}return e})}function Ge(e,t){t=t||{};var n=new ze;return Ue(e).forEach(function(e){n.append(e)}),t.type?n.getBlob(t.type):n.getBlob()}function He(e,t){return new Blob(Ue(e),t||{})}"undefined"!=typeof Blob&&(Ge.prototype=Blob.prototype,He.prototype=Blob.prototype);var Xe=Le?Fe?Blob:He:qe?Ge:void 0,Ye=q(function(e,t){var n;"undefined"!=typeof ArrayBuffer&&(n=Be);var r="undefined"!=typeof navigator&&/Android/i.test(navigator.userAgent),o="undefined"!=typeof navigator&&/PhantomJS/i.test(navigator.userAgent),i=r||o;t.protocol=3;var a=t.packets={open:0,close:1,ping:2,pong:3,message:4,upgrade:5,noop:6},s=ve(a),c={type:"error",data:"parser error"};function u(e,t,n){for(var r=new Array(e.length),o=De(e.length,n),i=function(e,n,o){t(n,function(t,n){r[e]=n,o(t,r)})},a=0;a<e.length;a++)i(a,e[a],o)}t.encodePacket=function(e,n,r,o){"function"==typeof n&&(o=n,n=!1),"function"==typeof r&&(o=r,r=null);var s=void 0===e.data?void 0:e.data.buffer||e.data;if("undefined"!=typeof ArrayBuffer&&s instanceof ArrayBuffer)return function(e,n,r){if(!n)return t.encodeBase64Packet(e,r);var o=e.data,i=new Uint8Array(o),s=new Uint8Array(1+o.byteLength);s[0]=a[e.type];for(var c=0;c<i.length;c++)s[c+1]=i[c];return r(s.buffer)}(e,n,o);if(void 0!==Xe&&s instanceof Xe)return function(e,n,r){if(!n)return t.encodeBase64Packet(e,r);if(i)return function(e,n,r){if(!n)return t.encodeBase64Packet(e,r);var o=new FileReader;return o.onload=function(){t.encodePacket({type:e.type,data:o.result},n,!0,r)},o.readAsArrayBuffer(e.data)}(e,n,r);var o=new Uint8Array(1);o[0]=a[e.type];var s=new Xe([o.buffer,e.data]);return r(s)}(e,n,o);if(s&&s.base64)return function(e,n){var r="b"+t.packets[e.type]+e.data.data;return n(r)}(e,o);var c=a[e.type];return void 0!==e.data&&(c+=r?Ne.encode(String(e.data),{strict:!1}):String(e.data)),o(""+c)},t.encodeBase64Packet=function(e,n){var r,o="b"+t.packets[e.type];if(void 0!==Xe&&e.data instanceof Xe){var i=new FileReader;return i.onload=function(){var e=i.result.split(",")[1];n(o+e)},i.readAsDataURL(e.data)}try{r=String.fromCharCode.apply(null,new Uint8Array(e.data))}catch(t){for(var a=new Uint8Array(e.data),s=new Array(a.length),c=0;c<a.length;c++)s[c]=a[c];r=String.fromCharCode.apply(null,s)}return o+=btoa(r),n(o)},t.decodePacket=function(e,n,r){if(void 0===e)return c;if("string"==typeof e){if("b"===e.charAt(0))return t.decodeBase64Packet(e.substr(1),n);if(r&&!1===(e=function(e){try{e=Ne.decode(e,{strict:!1})}catch(e){return!1}return e}(e)))return c;var o=e.charAt(0);return Number(o)==o&&s[o]?e.length>1?{type:s[o],data:e.substring(1)}:{type:s[o]}:c}o=new Uint8Array(e)[0];var i=Ce(e,1);return Xe&&"blob"===n&&(i=new Xe([i])),{type:s[o],data:i}},t.decodeBase64Packet=function(e,t){var r=s[e.charAt(0)];if(!n)return{type:r,data:{base64:!0,data:e.substr(1)}};var o=n.decode(e.substr(1));return"blob"===t&&Xe&&(o=new Xe([o])),{type:r,data:o}},t.encodePayload=function(e,n,r){"function"==typeof n&&(r=n,n=null);var o=xe(e);if(n&&o)return Xe&&!i?t.encodePayloadAsBlob(e,r):t.encodePayloadAsArrayBuffer(e,r);if(!e.length)return r("0:");u(e,function(e,r){t.encodePacket(e,!!o&&n,!1,function(e){r(null,function(e){return e.length+":"+e}(e))})},function(e,t){return r(t.join(""))})},t.decodePayload=function(e,n,r){if("string"!=typeof e)return t.decodePayloadAsBinary(e,n,r);var o;if("function"==typeof n&&(r=n,n=null),""===e)return r(c,0,1);for(var i,a,s="",u=0,l=e.length;u<l;u++){var p=e.charAt(u);if(":"===p){if(""===s||s!=(i=Number(s)))return r(c,0,1);if(s!=(a=e.substr(u+1,i)).length)return r(c,0,1);if(a.length){if(o=t.decodePacket(a,n,!1),c.type===o.type&&c.data===o.data)return r(c,0,1);if(!1===r(o,u+i,l))return}u+=i,s=""}else s+=p}return""!==s?r(c,0,1):void 0},t.encodePayloadAsArrayBuffer=function(e,n){if(!e.length)return n(new ArrayBuffer(0));u(e,function(e,n){t.encodePacket(e,!0,!0,function(e){return n(null,e)})},function(e,t){var r=t.reduce(function(e,t){var n;return e+(n="string"==typeof t?t.length:t.byteLength).toString().length+n+2},0),o=new Uint8Array(r),i=0;return t.forEach(function(e){var t="string"==typeof e,n=e;if(t){for(var r=new Uint8Array(e.length),a=0;a<e.length;a++)r[a]=e.charCodeAt(a);n=r.buffer}o[i++]=t?0:1;var s=n.byteLength.toString();for(a=0;a<s.length;a++)o[i++]=parseInt(s[a]);o[i++]=255;for(r=new Uint8Array(n),a=0;a<r.length;a++)o[i++]=r[a]}),n(o.buffer)})},t.encodePayloadAsBlob=function(e,n){u(e,function(e,n){t.encodePacket(e,!0,!0,function(e){var t=new Uint8Array(1);if(t[0]=1,"string"==typeof e){for(var r=new Uint8Array(e.length),o=0;o<e.length;o++)r[o]=e.charCodeAt(o);e=r.buffer,t[0]=0}var i=(e instanceof ArrayBuffer?e.byteLength:e.size).toString(),a=new Uint8Array(i.length+1);for(o=0;o<i.length;o++)a[o]=parseInt(i[o]);if(a[i.length]=255,Xe){var s=new Xe([t.buffer,a.buffer,e]);n(null,s)}})},function(e,t){return n(new Xe(t))})},t.decodePayloadAsBinary=function(e,n,r){"function"==typeof n&&(r=n,n=null);for(var o=e,i=[];o.byteLength>0;){for(var a=new Uint8Array(o),s=0===a[0],u="",l=1;255!==a[l];l++){if(u.length>310)return r(c,0,1);u+=a[l]}o=Ce(o,2+u.length),u=parseInt(u);var p=Ce(o,0,u);if(s)try{p=String.fromCharCode.apply(null,new Uint8Array(p))}catch(e){var h=new Uint8Array(p);p="";for(l=0;l<h.length;l++)p+=String.fromCharCode(h[l])}i.push(p),o=Ce(o,u)}var f=i.length;i.forEach(function(e,o){r(t.decodePacket(e,n,!0),o,f)})}}),We=(Ye.protocol,Ye.packets,Ye.encodePacket,Ye.encodeBase64Packet,Ye.decodePacket,Ye.decodeBase64Packet,Ye.encodePayload,Ye.decodePayload,Ye.encodePayloadAsArrayBuffer,Ye.encodePayloadAsBlob,Ye.decodePayloadAsBinary,Ke);function Ke(e){this.path=e.path,this.hostname=e.hostname,this.port=e.port,this.secure=e.secure,this.query=e.query,this.timestampParam=e.timestampParam,this.timestampRequests=e.timestampRequests,this.readyState="",this.agent=e.agent||!1,this.socket=e.socket,this.enablesXDR=e.enablesXDR,this.pfx=e.pfx,this.key=e.key,this.passphrase=e.passphrase,this.cert=e.cert,this.ca=e.ca,this.ciphers=e.ciphers,this.rejectUnauthorized=e.rejectUnauthorized,this.forceNode=e.forceNode,this.isReactNative=e.isReactNative,this.extraHeaders=e.extraHeaders,this.localAddress=e.localAddress}ne(Ke.prototype),Ke.prototype.onError=function(e,t){var n=new Error(e);return n.type="TransportError",n.description=t,this.emit("error",n),this},Ke.prototype.open=function(){return"closed"!==this.readyState&&""!==this.readyState||(this.readyState="opening",this.doOpen()),this},Ke.prototype.close=function(){return"opening"!==this.readyState&&"open"!==this.readyState||(this.doClose(),this.onClose()),this},Ke.prototype.send=function(e){if("open"!==this.readyState)throw new Error("Transport not open");this.write(e)},Ke.prototype.onOpen=function(){this.readyState="open",this.writable=!0,this.emit("open")},Ke.prototype.onData=function(e){var t=Ye.decodePacket(e,this.socket.binaryType);this.onPacket(t)},Ke.prototype.onPacket=function(e){this.emit("packet",e)},Ke.prototype.onClose=function(){this.readyState="closed",this.emit("close")};var Ve,Je={encode:function(e){var t="";for(var n in e)e.hasOwnProperty(n)&&(t.length&&(t+="&"),t+=encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return t},decode:function(e){for(var t={},n=e.split("&"),r=0,o=n.length;r<o;r++){var i=n[r].split("=");t[decodeURIComponent(i[0])]=decodeURIComponent(i[1])}return t}},Ze=function(e,t){var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e},$e="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),Qe=64,et={},tt=0,nt=0;function rt(e){var t="";do{t=$e[e%Qe]+t,e=Math.floor(e/Qe)}while(e>0);return t}function ot(){var e=rt(+new Date);return e!==Ve?(tt=0,Ve=e):e+"."+rt(tt++)}for(;nt<Qe;nt++)et[$e[nt]]=nt;ot.encode=rt,ot.decode=function(e){var t=0;for(nt=0;nt<e.length;nt++)t=t*Qe+et[e.charAt(nt)];return t};var it=ot,at=Q("engine.io-client:polling"),st=ut,ct=null!=new ye({xdomain:!1}).responseType;function ut(e){var t=e&&e.forceBase64;ct&&!t||(this.supportsBinary=!1),We.call(this,e)}Ze(ut,We),ut.prototype.name="polling",ut.prototype.doOpen=function(){this.poll()},ut.prototype.pause=function(e){var t=this;function n(){at("paused"),t.readyState="paused",e()}if(this.readyState="pausing",this.polling||!this.writable){var r=0;this.polling&&(at("we are currently polling - waiting to pause"),r++,this.once("pollComplete",function(){at("pre-pause polling complete"),--r||n()})),this.writable||(at("we are currently writing - waiting to pause"),r++,this.once("drain",function(){at("pre-pause writing complete"),--r||n()}))}else n()},ut.prototype.poll=function(){at("polling"),this.polling=!0,this.doPoll(),this.emit("poll")},ut.prototype.onData=function(e){var t=this;at("polling got data %s",e);Ye.decodePayload(e,this.socket.binaryType,function(e,n,r){if("opening"===t.readyState&&t.onOpen(),"close"===e.type)return t.onClose(),!1;t.onPacket(e)}),"closed"!==this.readyState&&(this.polling=!1,this.emit("pollComplete"),"open"===this.readyState?this.poll():at('ignoring poll - transport state "%s"',this.readyState))},ut.prototype.doClose=function(){var e=this;function t(){at("writing close packet"),e.write([{type:"close"}])}"open"===this.readyState?(at("transport open - closing"),t()):(at("transport not open - deferring close"),this.once("open",t))},ut.prototype.write=function(e){var t=this;this.writable=!1;var n=function(){t.writable=!0,t.emit("drain")};Ye.encodePayload(e,this.supportsBinary,function(e){t.doWrite(e,n)})},ut.prototype.uri=function(){var e=this.query||{},t=this.secure?"https":"http",n="";return!1!==this.timestampRequests&&(e[this.timestampParam]=it()),this.supportsBinary||e.sid||(e.b64=1),e=Je.encode(e),this.port&&("https"===t&&443!==Number(this.port)||"http"===t&&80!==Number(this.port))&&(n=":"+this.port),e.length&&(e="?"+e),t+"://"+(-1!==this.hostname.indexOf(":")?"["+this.hostname+"]":this.hostname)+n+this.path+e};var lt=Q("engine.io-client:polling-xhr"),pt=dt,ht=yt;function ft(){}function dt(e){if(st.call(this,e),this.requestTimeout=e.requestTimeout,this.extraHeaders=e.extraHeaders,"undefined"!=typeof location){var t="https:"===location.protocol,n=location.port;n||(n=t?443:80),this.xd="undefined"!=typeof location&&e.hostname!==location.hostname||n!==e.port,this.xs=e.secure!==t}}function yt(e){this.method=e.method||"GET",this.uri=e.uri,this.xd=!!e.xd,this.xs=!!e.xs,this.async=!1!==e.async,this.data=void 0!==e.data?e.data:null,this.agent=e.agent,this.isBinary=e.isBinary,this.supportsBinary=e.supportsBinary,this.enablesXDR=e.enablesXDR,this.requestTimeout=e.requestTimeout,this.pfx=e.pfx,this.key=e.key,this.passphrase=e.passphrase,this.cert=e.cert,this.ca=e.ca,this.ciphers=e.ciphers,this.rejectUnauthorized=e.rejectUnauthorized,this.extraHeaders=e.extraHeaders,this.create()}if(Ze(dt,st),dt.prototype.supportsBinary=!0,dt.prototype.request=function(e){return(e=e||{}).uri=this.uri(),e.xd=this.xd,e.xs=this.xs,e.agent=this.agent||!1,e.supportsBinary=this.supportsBinary,e.enablesXDR=this.enablesXDR,e.pfx=this.pfx,e.key=this.key,e.passphrase=this.passphrase,e.cert=this.cert,e.ca=this.ca,e.ciphers=this.ciphers,e.rejectUnauthorized=this.rejectUnauthorized,e.requestTimeout=this.requestTimeout,e.extraHeaders=this.extraHeaders,new yt(e)},dt.prototype.doWrite=function(e,t){var n="string"!=typeof e&&void 0!==e,r=this.request({method:"POST",data:e,isBinary:n}),o=this;r.on("success",t),r.on("error",function(e){o.onError("xhr post error",e)}),this.sendXhr=r},dt.prototype.doPoll=function(){lt("xhr poll");var e=this.request(),t=this;e.on("data",function(e){t.onData(e)}),e.on("error",function(e){t.onError("xhr poll error",e)}),this.pollXhr=e},ne(yt.prototype),yt.prototype.create=function(){var e={agent:this.agent,xdomain:this.xd,xscheme:this.xs,enablesXDR:this.enablesXDR};e.pfx=this.pfx,e.key=this.key,e.passphrase=this.passphrase,e.cert=this.cert,e.ca=this.ca,e.ciphers=this.ciphers,e.rejectUnauthorized=this.rejectUnauthorized;var t=this.xhr=new ye(e),n=this;try{lt("xhr open %s: %s",this.method,this.uri),t.open(this.method,this.uri,this.async);try{if(this.extraHeaders)for(var r in t.setDisableHeaderCheck&&t.setDisableHeaderCheck(!0),this.extraHeaders)this.extraHeaders.hasOwnProperty(r)&&t.setRequestHeader(r,this.extraHeaders[r])}catch(e){}if("POST"===this.method)try{this.isBinary?t.setRequestHeader("Content-type","application/octet-stream"):t.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(e){}try{t.setRequestHeader("Accept","*/*")}catch(e){}"withCredentials"in t&&(t.withCredentials=!0),this.requestTimeout&&(t.timeout=this.requestTimeout),this.hasXDR()?(t.onload=function(){n.onLoad()},t.onerror=function(){n.onError(t.responseText)}):t.onreadystatechange=function(){if(2===t.readyState)try{var e=t.getResponseHeader("Content-Type");n.supportsBinary&&"application/octet-stream"===e&&(t.responseType="arraybuffer")}catch(e){}4===t.readyState&&(200===t.status||1223===t.status?n.onLoad():setTimeout(function(){n.onError(t.status)},0))},lt("xhr data %s",this.data),t.send(this.data)}catch(e){return void setTimeout(function(){n.onError(e)},0)}"undefined"!=typeof document&&(this.index=yt.requestsCount++,yt.requests[this.index]=this)},yt.prototype.onSuccess=function(){this.emit("success"),this.cleanup()},yt.prototype.onData=function(e){this.emit("data",e),this.onSuccess()},yt.prototype.onError=function(e){this.emit("error",e),this.cleanup(!0)},yt.prototype.cleanup=function(e){if(void 0!==this.xhr&&null!==this.xhr){if(this.hasXDR()?this.xhr.onload=this.xhr.onerror=ft:this.xhr.onreadystatechange=ft,e)try{this.xhr.abort()}catch(e){}"undefined"!=typeof document&&delete yt.requests[this.index],this.xhr=null}},yt.prototype.onLoad=function(){var e;try{var t;try{t=this.xhr.getResponseHeader("Content-Type")}catch(e){}e="application/octet-stream"===t&&this.xhr.response||this.xhr.responseText}catch(e){this.onError(e)}null!=e&&this.onData(e)},yt.prototype.hasXDR=function(){return"undefined"!=typeof XDomainRequest&&!this.xs&&this.enablesXDR},yt.prototype.abort=function(){this.cleanup()},yt.requestsCount=0,yt.requests={},"undefined"!=typeof document)if("function"==typeof attachEvent)attachEvent("onunload",gt);else if("function"==typeof addEventListener){var vt="onpagehide"in self?"pagehide":"unload";addEventListener(vt,gt,!1)}function gt(){for(var e in yt.requests)yt.requests.hasOwnProperty(e)&&yt.requests[e].abort()}pt.Request=ht;var mt,bt=Dt,wt=/\n/g,kt=/\\n/g;function xt(){}function Ct(){return"undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==F?F:{}}function Dt(e){if(st.call(this,e),this.query=this.query||{},!mt){var t=Ct();mt=t.___eio=t.___eio||[]}this.index=mt.length;var n=this;mt.push(function(e){n.onData(e)}),this.query.j=this.index,"function"==typeof addEventListener&&addEventListener("beforeunload",function(){n.script&&(n.script.onerror=xt)},!1)}Ze(Dt,st),Dt.prototype.supportsBinary=!1,Dt.prototype.doClose=function(){this.script&&(this.script.parentNode.removeChild(this.script),this.script=null),this.form&&(this.form.parentNode.removeChild(this.form),this.form=null,this.iframe=null),st.prototype.doClose.call(this)},Dt.prototype.doPoll=function(){var e=this,t=document.createElement("script");this.script&&(this.script.parentNode.removeChild(this.script),this.script=null),t.async=!0,t.src=this.uri(),t.onerror=function(t){e.onError("jsonp poll error",t)};var n=document.getElementsByTagName("script")[0];n?n.parentNode.insertBefore(t,n):(document.head||document.body).appendChild(t),this.script=t,"undefined"!=typeof navigator&&/gecko/i.test(navigator.userAgent)&&setTimeout(function(){var e=document.createElement("iframe");document.body.appendChild(e),document.body.removeChild(e)},100)},Dt.prototype.doWrite=function(e,t){var n=this;if(!this.form){var r,o=document.createElement("form"),i=document.createElement("textarea"),a=this.iframeId="eio_iframe_"+this.index;o.className="socketio",o.style.position="absolute",o.style.top="-1000px",o.style.left="-1000px",o.target=a,o.method="POST",o.setAttribute("accept-charset","utf-8"),i.name="d",o.appendChild(i),document.body.appendChild(o),this.form=o,this.area=i}function s(){c(),t()}function c(){if(n.iframe)try{n.form.removeChild(n.iframe)}catch(e){n.onError("jsonp polling iframe removal error",e)}try{var e='<iframe src="javascript:0" name="'+n.iframeId+'">';r=document.createElement(e)}catch(e){(r=document.createElement("iframe")).name=n.iframeId,r.src="javascript:0"}r.id=n.iframeId,n.form.appendChild(r),n.iframe=r}this.form.action=this.uri(),c(),e=e.replace(kt,"\\\n"),this.area.value=e.replace(wt,"\\n");try{this.form.submit()}catch(e){}this.iframe.attachEvent?this.iframe.onreadystatechange=function(){"complete"===n.iframe.readyState&&s()}:this.iframe.onload=s};var Et,Ot,Pt=Q("engine.io-client:websocket");if("undefined"==typeof self)try{Ot={}}catch(e){}else Et=self.WebSocket||self.MozWebSocket;var It=Et||Ot,_t=Mt;function Mt(e){e&&e.forceBase64&&(this.supportsBinary=!1),this.perMessageDeflate=e.perMessageDeflate,this.usingBrowserWebSocket=Et&&!e.forceNode,this.protocols=e.protocols,this.usingBrowserWebSocket||(It=Ot),We.call(this,e)}Ze(Mt,We),Mt.prototype.name="websocket",Mt.prototype.supportsBinary=!0,Mt.prototype.doOpen=function(){if(this.check()){var e=this.uri(),t=this.protocols,n={agent:this.agent,perMessageDeflate:this.perMessageDeflate};n.pfx=this.pfx,n.key=this.key,n.passphrase=this.passphrase,n.cert=this.cert,n.ca=this.ca,n.ciphers=this.ciphers,n.rejectUnauthorized=this.rejectUnauthorized,this.extraHeaders&&(n.headers=this.extraHeaders),this.localAddress&&(n.localAddress=this.localAddress);try{this.ws=this.usingBrowserWebSocket&&!this.isReactNative?t?new It(e,t):new It(e):new It(e,t,n)}catch(e){return this.emit("error",e)}void 0===this.ws.binaryType&&(this.supportsBinary=!1),this.ws.supports&&this.ws.supports.binary?(this.supportsBinary=!0,this.ws.binaryType="nodebuffer"):this.ws.binaryType="arraybuffer",this.addEventListeners()}},Mt.prototype.addEventListeners=function(){var e=this;this.ws.onopen=function(){e.onOpen()},this.ws.onclose=function(){e.onClose()},this.ws.onmessage=function(t){e.onData(t.data)},this.ws.onerror=function(t){e.onError("websocket error",t)}},Mt.prototype.write=function(e){var t=this;this.writable=!1;for(var n=e.length,r=0,o=n;r<o;r++)!function(e){Ye.encodePacket(e,t.supportsBinary,function(r){if(!t.usingBrowserWebSocket){var o={};if(e.options&&(o.compress=e.options.compress),t.perMessageDeflate)("string"==typeof r?Buffer.byteLength(r):r.length)<t.perMessageDeflate.threshold&&(o.compress=!1)}try{t.usingBrowserWebSocket?t.ws.send(r):t.ws.send(r,o)}catch(e){Pt("websocket closed before onclose event")}--n||i()})}(e[r]);function i(){t.emit("flush"),setTimeout(function(){t.writable=!0,t.emit("drain")},0)}},Mt.prototype.onClose=function(){We.prototype.onClose.call(this)},Mt.prototype.doClose=function(){void 0!==this.ws&&this.ws.close()},Mt.prototype.uri=function(){var e=this.query||{},t=this.secure?"wss":"ws",n="";return this.port&&("wss"===t&&443!==Number(this.port)||"ws"===t&&80!==Number(this.port))&&(n=":"+this.port),this.timestampRequests&&(e[this.timestampParam]=it()),this.supportsBinary||(e.b64=1),(e=Je.encode(e)).length&&(e="?"+e),t+"://"+(-1!==this.hostname.indexOf(":")?"["+this.hostname+"]":this.hostname)+n+this.path+e},Mt.prototype.check=function(){return!(!It||"__initialize"in It&&this.name===Mt.prototype.name)};var St={polling:function(e){var t=!1,n=!1,r=!1!==e.jsonp;if("undefined"!=typeof location){var o="https:"===location.protocol,i=location.port;i||(i=o?443:80),t=e.hostname!==location.hostname||i!==e.port,n=e.secure!==o}if(e.xdomain=t,e.xscheme=n,"open"in new ye(e)&&!e.forceJSONP)return new pt(e);if(!r)throw new Error("JSONP disabled");return new bt(e)},websocket:_t},At=[].indexOf,Tt=function(e,t){if(At)return e.indexOf(t);for(var n=0;n<e.length;++n)if(e[n]===t)return n;return-1},jt=Q("engine.io-client:socket"),Rt=Nt;function Nt(e,t){if(!(this instanceof Nt))return new Nt(e,t);t=t||{},e&&"object"==typeof e&&(t=e,e=null),e?(e=H(e),t.hostname=e.host,t.secure="https"===e.protocol||"wss"===e.protocol,t.port=e.port,e.query&&(t.query=e.query)):t.host&&(t.hostname=H(t.host).host),this.secure=null!=t.secure?t.secure:"undefined"!=typeof location&&"https:"===location.protocol,t.hostname&&!t.port&&(t.port=this.secure?"443":"80"),this.agent=t.agent||!1,this.hostname=t.hostname||("undefined"!=typeof location?location.hostname:"localhost"),this.port=t.port||("undefined"!=typeof location&&location.port?location.port:this.secure?443:80),this.query=t.query||{},"string"==typeof this.query&&(this.query=Je.decode(this.query)),this.upgrade=!1!==t.upgrade,this.path=(t.path||"/engine.io").replace(/\/$/,"")+"/",this.forceJSONP=!!t.forceJSONP,this.jsonp=!1!==t.jsonp,this.forceBase64=!!t.forceBase64,this.enablesXDR=!!t.enablesXDR,this.timestampParam=t.timestampParam||"t",this.timestampRequests=t.timestampRequests,this.transports=t.transports||["polling","websocket"],this.transportOptions=t.transportOptions||{},this.readyState="",this.writeBuffer=[],this.prevBufferLen=0,this.policyPort=t.policyPort||843,this.rememberUpgrade=t.rememberUpgrade||!1,this.binaryType=null,this.onlyBinaryUpgrades=t.onlyBinaryUpgrades,this.perMessageDeflate=!1!==t.perMessageDeflate&&(t.perMessageDeflate||{}),!0===this.perMessageDeflate&&(this.perMessageDeflate={}),this.perMessageDeflate&&null==this.perMessageDeflate.threshold&&(this.perMessageDeflate.threshold=1024),this.pfx=t.pfx||null,this.key=t.key||null,this.passphrase=t.passphrase||null,this.cert=t.cert||null,this.ca=t.ca||null,this.ciphers=t.ciphers||null,this.rejectUnauthorized=void 0===t.rejectUnauthorized||t.rejectUnauthorized,this.forceNode=!!t.forceNode,this.isReactNative="undefined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase(),("undefined"==typeof self||this.isReactNative)&&(t.extraHeaders&&Object.keys(t.extraHeaders).length>0&&(this.extraHeaders=t.extraHeaders),t.localAddress&&(this.localAddress=t.localAddress)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingIntervalTimer=null,this.pingTimeoutTimer=null,this.open()}Nt.priorWebsocketSuccess=!1,ne(Nt.prototype),Nt.protocol=Ye.protocol,Nt.Socket=Nt,Nt.Transport=We,Nt.transports=St,Nt.parser=Ye,Nt.prototype.createTransport=function(e){jt('creating transport "%s"',e);var t=function(e){var t={};for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return t}(this.query);t.EIO=Ye.protocol,t.transport=e;var n=this.transportOptions[e]||{};return this.id&&(t.sid=this.id),new St[e]({query:t,socket:this,agent:n.agent||this.agent,hostname:n.hostname||this.hostname,port:n.port||this.port,secure:n.secure||this.secure,path:n.path||this.path,forceJSONP:n.forceJSONP||this.forceJSONP,jsonp:n.jsonp||this.jsonp,forceBase64:n.forceBase64||this.forceBase64,enablesXDR:n.enablesXDR||this.enablesXDR,timestampRequests:n.timestampRequests||this.timestampRequests,timestampParam:n.timestampParam||this.timestampParam,policyPort:n.policyPort||this.policyPort,pfx:n.pfx||this.pfx,key:n.key||this.key,passphrase:n.passphrase||this.passphrase,cert:n.cert||this.cert,ca:n.ca||this.ca,ciphers:n.ciphers||this.ciphers,rejectUnauthorized:n.rejectUnauthorized||this.rejectUnauthorized,perMessageDeflate:n.perMessageDeflate||this.perMessageDeflate,extraHeaders:n.extraHeaders||this.extraHeaders,forceNode:n.forceNode||this.forceNode,localAddress:n.localAddress||this.localAddress,requestTimeout:n.requestTimeout||this.requestTimeout,protocols:n.protocols||void 0,isReactNative:this.isReactNative})},Nt.prototype.open=function(){var e;if(this.rememberUpgrade&&Nt.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket"))e="websocket";else{if(0===this.transports.length){var t=this;return void setTimeout(function(){t.emit("error","No transports available")},0)}e=this.transports[0]}this.readyState="opening";try{e=this.createTransport(e)}catch(e){return this.transports.shift(),void this.open()}e.open(),this.setTransport(e)},Nt.prototype.setTransport=function(e){jt("setting transport %s",e.name);var t=this;this.transport&&(jt("clearing existing transport %s",this.transport.name),this.transport.removeAllListeners()),this.transport=e,e.on("drain",function(){t.onDrain()}).on("packet",function(e){t.onPacket(e)}).on("error",function(e){t.onError(e)}).on("close",function(){t.onClose("transport close")})},Nt.prototype.probe=function(e){jt('probing transport "%s"',e);var t=this.createTransport(e,{probe:1}),n=!1,r=this;function o(){if(r.onlyBinaryUpgrades){var o=!this.supportsBinary&&r.transport.supportsBinary;n=n||o}n||(jt('probe transport "%s" opened',e),t.send([{type:"ping",data:"probe"}]),t.once("packet",function(o){if(