!function(t,e){"object"==typeofexports&&"undefined"!=typeofmodule?module.exports=e():"function"==typeofdefine&&define.amd?define(e):(t="undefined"!=typeofglobalThis?globalThis:t||self).io=e()}(this,(function(){"use strict";functiont(e){returnt="function"==typeofSymbol&&"symbol"==typeofSymbol.iterator?function(t){returntypeoft}:function(t){returnt&&"function"==typeofSymbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeoft},t(e)}functione(t,e){if(!(tinstanceofe))thrownewTypeError("Cannot call a class as a function")}functionn(t,e){for(varn=0;n<e.length;n++){varr=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"inr&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}functionr(t,e,r){returne&&n(t.prototype,e),r&&n(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}functioni(){returni=Object.assign?Object.assign.bind():function(t){for(vare=1;e<arguments.length;e++){varn=arguments[e];for(varrinn)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}returnt},i.apply(this,arguments)}functiono(t,e){if("function"!=typeofe&&null!==e)thrownewTypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&a(t,e)}functions(t){returns=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){returnt.__proto__||Object.getPrototypeOf(t)},s(t)}functiona(t,e){returna=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){returnt.__proto__=e,t},a(t,e)}functionc(){if("undefined"==typeofReflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeofProxy)return!0;try{returnBoolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}functionu(t,e,n){returnu=c()?Reflect.construct.bind():function(t,e,n){varr=[null];r.push.apply(r,e);vari=new(Function.bind.apply(t,r));returnn&&a(i,n.prototype),i},u.apply(null,arguments)}functionh(t){vare="function"==typeofMap?newMap:void0;returnh=function(t){if(null===t||(n=t,-1===Function.toString.call(n).indexOf("[native code]")))returnt;varn;if("function"!=typeoft)thrownewTypeError("Super expression must either be null or a function");if(void0!==e){if(e.has(t))returne.get(t);e.set(t,r)}functionr(){returnu(t,arguments,s(this).constructor)}returnr.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),a(r,t)},h(t)}functionf(t){if(void0===t)thrownewReferenceError("this hasn't been initialised - super() hasn't been called");returnt}functionl(t,e){if(e&&("object"==typeofe||"function"==typeofe))returne;if(void0!==e)thrownewTypeError("Derived constructors may only return object or undefined");returnf(t)}functionp(t){vare=c();returnfunction(){varn,r=s(t);if(e){vari=s(this).constructor;n=Reflect.construct(r,arguments,i)}elsen=r.apply(this,arguments);returnl(this,n)}}functiond(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=s(t)););returnt}functiony(){returny="undefined"!=typeofReflect&&Reflect.get?Reflect.get.bind():function(t,e,n){varr=d(t,e);if(r){vari=Object.getOwnPropertyDescriptor(r,e);returni.get?i.get.call(arguments.length<3?t:n):i.value}},y.apply(this,arguments)}functionv(t,e){(null==e||e>t.length)&&(e=t.length);for(varn=0,r=newArray(e);n<e;n++)r[n]=t[n];returnr}functiong(t,e){varn="undefined"!=typeofSymbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeoft)returnv(t,e);varn=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?v(t,e):void0}}(t))||e&&t&&"number"==typeoft.length){n&&(t=n);varr=0,i=function(){};return{s:i,n:function(){returnr>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throwt},f:i}}thrownewTypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}varo,s=!0,a=!1;return{s:function(){n=n.call(t)},n:function(){vart=n.next();returns=t.done,t},e:function(t){a=!0,o=t},f:function(){try{s||null==n.return||n.return()}finally{if(a)throwo}}}}varm=Object.create(null);m.open="0",m.close="1",m.ping="2",m.pong="3",m.message="4",m.upgrade="5",m.noop="6";vark=Object.create(null);Object.keys(m).forEach((function(t){k[m[t]]=t}));for(varb={type:"error",data:"parser error"},w="function"==typeofBlob||"undefined"!=typeofBlob&&"[object BlobConstructor]"===Object.prototype.toString.call(Blob),_="function"==typeofArrayBuffer,E=function(t,e,n){varr,i=t.type,o=t.data;returnw&&oinstanceofBlob?e?n(o):O(o,n):_&&(oinstanceofArrayBuffer||(r=o,"function"==typeofArrayBuffer.isView?ArrayBuffer.isView(r):r&&r.bufferinstanceofArrayBuffer))?e?n(o):O(newBlob([o]),n):n(m[i]+(o||""))},O=function(t,e){varn=newFileReader;returnn.onload=function(){vart=n.result.split(",")[1];e("b"+t)},n.readAsDataURL(t)},A="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",R="undefined"==typeofUint8Array?[]:newUint8Array(256),T=0;T<A.length;T++)R[A.charCodeAt(T)]=T;varC="function"==typeofArrayBuffer,B=function(t,e){if("string"!=typeoft)return{type:"message",data:N(t,e)};varn=t.charAt(0);return"b"===n?{type:"message",data:S(t.substring(1),e)}:k[n]?t.length>1?{type:k[n],data:t.substring(1)}:{type:k[n]}:b},S=function(t,e){if(C){varn=function(t){vare,n,r,i,o,s=.75*t.length,a=t.length,c=0;"="===t[t.length-1]&&(s--,"="===t[t.length-2]&&s--);varu=newArrayBuffer(s),h=newUint8Array(u);for(e=0;e<a;e+=4)n=R[t.charCodeAt(e)],r=R[t.charCodeAt(e+1)],i=R[t.charCodeAt(e+2)],o=R[t.charCodeAt(e+3)],h[c++]=n<<2|r>>4,h[c++]=(15&r)<<4|i>>2,h[c++]=(3&i)<<6|63&o;returnu}(t);returnN(n,e)}return{base64:!0,data:t}},N=function(t,e){return"blob"===e&&tinstanceofArrayBuffer?newBlob([t]):t},x=String.fromCharCode(30);functionL(t){if(t)returnfunction(t){for(vareinL.prototype)t[e]=L.prototype[e];returnt}(t)}L.prototype.on=L.prototype.addEventListener=function(t,e){returnthis._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this},L.prototype.once=function(t,e){functionn(){this.off(t,n),e.apply(this,arguments)}returnn.fn=e,this.on(t,n),this},L.prototype.off=L.prototype.removeListener=L.prototype.removeAllListeners=L.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)returnthis._callbacks={},this;varn,r=this._callbacks["$"+t];if(!r)returnthis;if(1==arguments.length)returndeletethis._callbacks["$"+t],this;for(vari=0;i<r.length;i++)if((n=r[i])===e||n.fn===e){r.splice(i,1);break}return0===r.length&&deletethis._callbacks["$"+t],this},L.prototype.emit=function(t){this._callbacks=this._callbacks||{};for(vare=newArray(arguments.length-1),n=this._callbacks["$"+t],r=1;r<arguments.length;r++)e[r-1]=arguments[r];if(n){r=0;for(vari=(n=n.slice(0)).length;r<i;++r)n[r].apply(this,e)}returnthis},L.prototype.emitReserved=L.prototype.emit,L.prototype.listeners=function(t){returnthis._callbacks=this._callbacks||{},this._callbacks["$"+t]||[]},L.prototype.hasListeners=function(t){return!!this.listeners(t).length};varP="undefined"!=typeofself?self:"undefined"!=typeofwindow?window:Function("return this")();functionj(t){for(vare=arguments.length,n=newArray(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];returnn.reduce((function(e,n){returnt.hasOwnProperty(n)&&(e[n]=t[n]),e}),{})}varq=P.setTimeout,I=P.clearTimeout;functionD(t,e){e.useNativeTimers?(t.setTimeoutFn=q.bind(P),t.clearTimeoutFn=I.bind(P)):(t.setTimeoutFn=P.setTimeout.bind(P),t.clearTimeoutFn=P.clearTimeout.bind(P))}varF,M=function(t){o(i,t);varn=p(i);functioni(t,r,o){vars;returne(this,i),(s=n.call(this,t)).description=r,s.context=o,s.type="TransportError",s}returnr(i)}(h(Error)),U=function(t){o(i,t);varn=p(i);functioni(t){varr;returne(this,i),(r=n.call(this)).writable=!1,D(f(r),t),r.opts=t,r.query=t.query,r.socket=t.socket,r}returnr(i,[{key:"onError",value:function(t,e,n){returny(s(i.prototype),"emitReserved",this).call(this,"error",newM(t,e,n)),this}},{key:"open",value:function(){returnthis.readyState="opening",this.doOpen(),this}},{key:"close",value:function(){return"opening"!==this.readyState&&"open"!==this.readyState||(this.doClose(),this.onClose()),this}},{key:"send",value:function(t){"open"===this.readyState&&this.write(t)}},{key:"onOpen",value:function(){this.readyState="open",this.writable=!0,y(s(i.prototype),"emitReserved",this).call(this,"open")}},{key:"onData",value:function(t){vare=B(t,this.socket.binaryType);this.onPacket(e)}},{key:"onPacket",value:function(t){y(s(i.prototype),"emitReserved",this).call(this,"packet",t)}},{key:"onClose",value:function(t){this.readyState="closed",y(s(i.prototype),"emitReserved",this).call(this,"close",t)}},{key:"pause",value:function(t){}}]),i}(L),V="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),H={},K=0,Y=0;functionz(t){vare="";do{e=V[t%64]+e,t=Math.floor(t/64)}while(t>0);returne}functionW(){vart=z(+newDate);returnt!==F?(K=0,F=t):t+"."+z(K++)}for(;Y<64;Y++)H[V[Y]]=Y;function$(t){vare="";for(varnint)t.hasOwnProperty(n)&&(e.length&&(e+="&"),e+=encodeURIComponent(n)+"="+encodeURIComponent(t[n]));returne}functionJ(t){for(vare={},n=t.split("&"),r=0,i=n.length;r<i;r++){varo=n[r].split("=");e[decodeURIComponent(o[0])]=decodeURIComponent(o[1])}returne}varQ=!1;try{Q="undefined"!=typeofXMLHttpRequest&&"withCredentials"innewXMLHttpRequest}catch(t){}varX=Q;functionG(t){vare=t.xdomain;try{if("undefined"!=typeofXMLHttpRequest&&(!e||X))returnnewXMLHttpRequest}catch(t){}if(!e)try{returnnew(P[["Active"].concat("Object").join("X")])("Microsoft.XMLHTTP")}catch(t){}}functionZ(){}vartt=null!=newG({xdomain:!1}).responseType,et=function(t){o(s,t);varn=p(s);functions(t){varr;if(e(this,s),(r=n.call(this,t)).polling=!1,"undefined"!=typeoflocation){vari="https:"===location.protocol,o=location.port;o||(o=i?"443":"80"),r.xd="undefined"!=typeoflocation&&t.hostname!==location.hostname||o!==t.port,r.xs=t.secure!==i}vara=t&&t.forceBase64;returnr.supportsBinary=tt&&!a,r}returnr(s,[{key:"name",get:function(){return"polling"}},{key:"doOpen",value:function(){this.poll()}},{key:"pause",value:function(t){vare=this;this.readyState="pausing";varn=function(){e.readyState="paused",t()};if(this.polling||!this.writable){varr=0;this.polling&&(r++,this.once("pollComplete",(function(){--r||n()}))),this.writable||(r++,this.once("drain",(function(){--r||n()})))}elsen()}},{key:"poll",value:function(){this.polling=!0,this.doPoll(),this.emitReserved("poll")}},{key:"onData",value:function(t){vare=this;(function(t,e){for(varn=t.split(x),r=[],i=0;i<n.length;i++){varo=B(n[i],e);if(r.push(o),"error"===o.type)break}returnr})(t,this.socket.binaryType).forEach((function(t){if("opening"===e.readyState&&"open"===t.type&&e.onOpen(),"close"===t.type)returne.onClose({description:"transport closed by the server"}),!1;e.onPacket(t)})),"closed"!==this.readyState&&(this.polling=!1,this.emitReserved("pollComplete"),"open"===this.readyState&&this.poll())}},{key:"doClose",value:function(){vart=this,e=function(){t.write([{type:"close"}])};"open"===this.readyState?e():this.once("open",e)}},{key:"write",value:function(t){vare=this;this.writable=!1,function(t,e){varn=t.length,r=newArray(n),i=0;t.forEach((function(t,o){E(t,!1,(function(t){r[o]=t,++i===n&&e(r.join(x))}))}))}(t,(function(t){e.doWrite(t,(function(){e.writable=!0,e.emitReserved("drain")}))}))}},{key:"uri",value:function(){vart=this.query||{},e=this.opts.secure?"https":"http",n="";!1!==this.opts.timestampRequests&&(t[this.opts.timestampParam]=W()),this.supportsBinary||t.sid||(t.b64=1),this.opts.port&&("https"===e&&443!==Number(this.opts.port)||"http"===e&&80!==Number(this.opts.port))&&(n=":"+this.opts.port);varr=$(t);returne+"://"+(-1!==this.opts.hostname.indexOf(":")?"["+this.opts.hostname+"]":this.opts.hostname)+n+this.opts.path+(r.length?"?"+r:"")}},{key:"request",value:function(){vart=arguments.length>0&&void0!==arguments[0]?arguments[0]:{};returni(t,{xd:this.xd,xs:this.xs},this.opts),newnt(this.uri(),t)}},{key:"doWrite",value:function(t,e){varn=this,r=this.request({method:"POST",data:t});r.on("success",e),r.on("error",(function(t,e){n.onError("xhr post error",t,e)}))}},{key:"doPoll",value:function(){vart=this,e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(function(e,n){t.onError("xhr poll error",e,n)})),this.pollXhr=e}}]),s}(U),nt=function(t){o(i,t);varn=p(i);functioni(t,r){varo;returne(this,i),D(f(o=n.call(this)),r),o.opts=r,o.method=r.method||"GET",o.uri=t,o.async=!1!==r.async,o.data=void0!==r.data?r.data:null,o.create(),o}returnr(i,[{key:"create",value:function(){vart=this,e=j(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");e.xdomain=!!this.opts.xd,e.xscheme=!!this.opts.xs;varn=this.xhr=newG(e);try{n.open(this.method,this.uri,this.async);try{if(this.opts.extraHeaders)for(varrinn.setDisableHeaderCheck&&n.setDisableHeaderCheck(!0),this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(r)&&n.setRequestHeader(r,this.opts.extraHeaders[r])}catch(t){}if("POST"===this.method)try{n.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(t){}try{n.setRequestHeader("Accept","*/*")}catch(t){}"withCredentials"inn&&(n.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(n.timeout=this.opts.requestTimeout),n.onreadystatechange=function(){4===n.readyState&&(200===n.status||1223===n.status?t.onLoad():t.setTimeoutFn((function(){t.onError("number"==typeofn.status?n.status:0)}),0))},n.send(this.data)}catch(e){returnvoidthis.setTimeoutFn((function(){t.onError(e)}),0)}"undefined"!=typeofdocument&&(this.index=i.requestsCount++,i.requests[this.index]=this)}},{key:"onError",value:function(t){this.emitReserved("error",t,this.xhr),this.cleanup(!0)}},{key:"cleanup",value:function(t){if(void0!==this.xhr&&null!==this.xhr){if(this.xhr.onreadystatechange=Z,t)try{this.xhr.abort()}catch(t){}"undefined"!=typeofdocument&&deletei.requests[this.index],this.xhr=null}}},{key:"onLoad",value:function(){vart=this.xhr.responseText;null!==t&&(this.emitReserved("data",t),this.emitReserved("success"),this.cleanup())}},{key:"abort",value:function(){this.cleanup()}}]),i}(L);if(nt.requestsCount=0,nt.requests={},"undefined"!=typeofdocument)if("function"==typeofattachEvent)attachEvent("onunload",rt);elseif("function"==typeofaddEventListener){addEventListener("onpagehide"inP?"pagehide":"unload",rt,!1)}functionrt(){for(vartinnt.requests)nt.requests.hasOwnProperty(t)&&nt.requests[t].abort()}varit="function"==typeofPromise&&"function"==typeofPromise.resolve?function(t){returnPromise.resolve().then(t)}:function(t,e){returne(t,0)},ot=P.WebSocket||P.MozWebSocket,st="undefined"!=typeofnavigator&&"string"==typeofnavigator.product&&"reactnative"===navigator.product.toLowerCase(),at=function(t){o(i,t);varn=p(i);functioni(t){varr;returne(this,i),(r=n.call(this,t)).supportsBinary=!t.forceBase64,r}returnr(i,[{key:"name",get:function(){return"websocket"}},{key:"doOpen",value:function(){if(this.check()){vart=this.uri(),e=this.opts.protocols,n=st?{}:j(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(n.headers=this.opts.extraHeaders);try{this.ws=st?newot(t,e,n):e?newot(t,e):newot(t)}catch(t){returnthis.emitReserved("error",t)}this.ws.binaryType=this.socket.binaryType||"arraybuffer",this.addEventListeners()}}},{key:"addEventListeners",value:function(){vart=this;this.ws.onopen=function(){t.opts.autoUnref&&t.ws._socket.unref(),t.onOpen()},this.ws.onclose=function(e){returnt.onClose({description:"websocket connection closed",context:e})},this.ws.onmessage=function(e){returnt.onData(e.data)},this.ws.onerror=function(e){returnt.onError("websocket error",e)}}},{key:"write",value:function(t){vare=this;this.writable=!1;for(varn=function(n){varr=t[n],i=n===t.length-1;E(r,e.supportsBinary,(function(t){try{e.ws.send(t)}catch(t){}i&&it((function(){e.writable=!0,e.emitReserved("drain")}),e.setTimeoutFn)}))},r=0;r<t.length;r++)n(r)}},{key:"doClose",value:function(){void0!==this.ws&&(this.ws.close(),this.ws=null)}},{key:"uri",value:function(){vart=this.query||{},e=this.opts.secure?"wss":"ws",n="";this.opts.port&&("wss"===e&&443!==Number(this.opts.port)||"ws"===e&&80!==Number(this.opts.port))&&(n=":"+this.opts.port),this.opts.timestampRequests&&(t[this.opts.timestampParam]=W()),this.supportsBinary||(t.b64=1);varr=$(t);returne+"://"+(-1!==this.opts.hostname.indexOf(":")?"["+this.opts.hostname+"]":this.opts.hostname)+n+this.opts.path+(r.length?"?"+r:"")}},{key:"check",value:function(){return!!ot}}]),i}(U),ct={websocket:at,polling:et},ut=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,ht=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];functionft(t){vare=t,n=t.indexOf("["),r=t.indexOf("]");-1!=n&&-1!=r&&(t=t.substring(0,n)+t.substring(n,r).replace(/:/g,";")+t.substring(r,t.length));for(vari,o,s=ut.exec(t||""),a={},c=14;c--;)a[ht[c]]=s[c]||"";return-1!=n&&-1!=r&&(a.source=e,a.host=a.host.substring(1,a.host.length-1).replace(/;/g,":"),a.authority=a.authority.replace("[","").replace("]","").replace(/;/g,":"),a.ipv6uri=!0),a.pathNames=function(t,e){varn=/\/{2,9}/g,r=e.replace(n,"/").split("/");"/"!=e.slice(0,1)&&0!==e.length||r.splice(0,1);"/"==e.slice(-1)&&r.splice(r.length-1,1);returnr}(0,a.path),a.queryKey=(i=a.query,o={},i.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,(function(t,e,n){e&&(o[e]=n)})),o),a}varlt=function(n){o(a,n);vars=p(a);functiona(n){varr,o=arguments.length>1&&void0!==arguments[1]?arguments[1]:{};returne(this,a),(r=s.call(this)).writeBuffer=[],n&&"object"===t(n)&&(o=n,n=null),n?(n=ft(n),o.hostname=n.host,o.secure="https"===n.protocol||"wss"===n.protocol,o.port=n.port,n.query&&(o.query=n.query)):o.host&&(o.hostname=ft(o.host).host),D(f(r),o),r.secure=null!=o.secure?o.secure:"undefined"!=typeoflocation&&"https:"===location.protocol,o.hostname&&!o.port&&(o.port=r.secure?"443":"80"),r.hostname=o.hostname||("undefined"!=typeoflocation?location.hostname:"localhost"),r.port=o.port||("undefined"!=typeoflocation&&location.port?location.port:r.secure?"443":"80"),r.transports=o.transports||["polling","websocket"],r.writeBuffer=[],r.prevBufferLen=0,r.opts=i({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!0},o),r.opts.path=r.opts.path.replace(/\/$/,"")+(r.opts.addTrailingSlash?"/":""),"string"==typeofr.opts.query&&(r.opts.query=J(r.opts.query)),r.id=null,r.upgrades=null,r.pingInterval=null,r.pingTimeout=null,r.pingTimeoutTimer=null,"function"==typeofaddEventListener&&(r.opts.closeOnBeforeunload&&(r.beforeunloadEventListener=function(){r.transport&&(r.transport.removeAllListeners(),r.transport.close())},addEventListener("beforeunload",r.beforeunloadEventListener,!1)),"localhost"!==r.hostname&&(r.offlineEventListener=function(){r.onClose("transport close",{description:"network connection lost"})},addEventListener("offline",r.offlineEventListener,!1))),r.open(),r}returnr(a,[{key:"createTransport",value:function(t){vare=i({},this.opts.query);e.EIO=4,e.transport=t,this.id&&(e.sid=this.id);varn=i({},this.opts.transportOptions[t],this.opts,{query:e,socket:this,hostname:this.hostname,secure:this.secure,port:this.port});returnnewct[t](n)}},{key:"open",value:function(){vart,e=this;if(this.opts.rememberUpgrade&&a.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket"))t="websocket";else{if(0===this.transports.length)returnvoidthis.setTimeoutFn((function(){e.emitReserved("error","No transports available")}),0);t=this.transports[0]}this.readyState="opening";try{t=this.createTransport(t)}catch(t){returnthis.transports.shift(),voidthis.open()}t.open(),this.setTransport(t)}},{key:"setTransport",value:function(t){vare=this;this.transport&&this.transport.removeAllListeners(),this.transport=t,t.on("drain",this.onDrain.bind(this)).on("packet",this.onPacket.bind(this)).on("error",this.onError.bind(this)).on("close",(function(t){returne.onClose("transport close",t)}))}},{key:"probe",value:function(t){vare=this,n=this.createTransport(t),r=!1;a.priorWebsocketSuccess=!1;vari=function(){r||(n.send([{type:"ping",data:"probe"}]),n.once("packet",(function(t){if(!r)if("pong"===t.type&&"probe"===t.data){if(e.upgrading=!0,e.emitReserved("upgrading",n),!n)return;a.priorWebsocketSuccess="websocket"===n.name,e.transport.pause((function(){r||"closed"!==e.readyState&&(f(),e.setTransport(n),n.send([{type:"upgrade"}]),e.emitReserved("upgrade",n),n=null,e.upgrading=!1,e.flush())}))}else{vari=newError("probe error");i.transport=n.name,e.emitReserved("upgradeError",i)}})))};functiono(){r||(r=!0,f(),n.close(),n=null)}vars=function(t){varr=newError("probe error: "+t);r.transport=n.name,o(),e.emitReserved("upgradeError",r)};functionc(){s("transport closed")}functionu(){s("socket closed")}functionh(t){n&&t.name!==n.name&&o()}varf=function(){n.removeListener("open",i),n.removeListener("error",s),n.removeListener("close",c),e.off("close",u),e.off("upgrading",h)};n.once("open",i),n.once("error",s),n.once("close",c),this.once("close",u),this.once("upgrading",h),n.open()}},{key:"onOpen",value:function(){if(this.readyState="open",a.priorWebsocketSuccess="websocket"===this.transport.name,this.emitReserved("open"),this.flush(),"open"===this.readyState&&this.opts.upgrade)for(vart=0,e=this.upgrades.length;t<e;t++)this.probe(this.upgrades[t])}},{key:"onPacket",value:function(t){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState)switch(this.emitReserved("packet",t),this.emitReserved("heartbeat"),t.type){case"open":this.onHandshake(JSON.parse(t.data));break;case"ping":this.resetPingTimeout(),this.sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong");break;case"error":vare=newError("server error");e.code=t.data,this.onError(e);break;case"message":this.emitReserved("data",t.data),this.emitReserved("message",t.data)}}},{key:"onHandshake",value:function(t){this.emitReserved("handshake",t),this.id=t.sid,this.transport.query.sid=t.sid,this.upgrades=this.filterUpgrades(t.upgrades),this.pingInterval=t.pingInterval,this.pingTimeout=t.pingTimeout,this.maxPayload=t.maxPayload,this.onOpen(),"closed"!==this.readyState&&this.resetPingTimeout()}},{key:"resetPingTimeout",value:function(){vart=this;this.clearTimeoutFn(this.pingTimeoutTimer),this.pingTimeoutTimer=this.setTimeoutFn((function(){t.onClose("ping timeout")}),this.pingInterval+this.pingTimeout),this.opts.autoUnref&&this.pingTimeoutTimer.unref()}},{key:"onDrain",value:function(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,0===this.writeBuffer.length?this.emitReserved("drain"):this.flush()}},{key:"flush",value:function(){if("closed"!==this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){vart=this.getWritablePackets();this.transport.send(t),this.prevBufferLen=t.length,this.emitReserved("flush")}}},{key:"getWritablePackets",value:function(){if(!(this.maxPayload&&"polling"===this.transport.name&&this.writeBuffer.length>1))returnthis.writeBuffer;for(vart,e=1,n=0;n<this.writeBuffer.length;n++){varr=this.writeBuffer[n].data;if(r&&(e+="string"==typeof(t=r)?function(t){for(vare=0,n=0,r=0,i=t.length;r<i;r++)(e=t.charCodeAt(r))<128?n+=1:e<2048?n+=2:e<55296||e>=57344?n+=3:(r++,n+=4);returnn}(t):Math.ceil(1.33*(t.byteLength||t.size))),n>0&&e>this.maxPayload)returnthis.writeBuffer.slice(0,n);e+=2}returnthis.writeBuffer}},{key:"write",value:function(t,e,n){returnthis.sendPacket("message",t,e,n),this}},{key:"send",value:function(t,e,n){returnthis.sendPacket("message",t,e,n),this}},{key:"sendPacket",value:function(t,e,n,r){if("function"==typeofe&&(r=e,e=void0),"function"==typeofn&&(r=n,n=null),"closing"!==this.readyState&&"closed"!==this.readyState){(n=n||{}).compress=!1!==n.compress;vari={type:t,data:e,options:n};this.emitReserved("packetCreate",i),this.writeBuffer.push(i),r&&this.once("flush",r),this.flush()}}},{key:"close",value:function(){vart=this,e=function(){t.onClose("forced close"),t.transport.close()},n=functionn(){t.off("upgrade",n),t.off("upgradeError",n),e()},r=function(){t.once("upgrade",n),t.once("upgradeError",n)};return"opening"!==this.readyState&&"open"!==this.readyState||(this.readyState="closing",this.writeBuffer.length?this.once("drain",(function(){t.upgrading?r():e()})):this.upgrading?r():e()),this}},{key:"onError",value:function(t){a.priorWebsocketSuccess=!1,this.emitReserved("error",t),this.onClose("transport error",t)}},{key:"onClose",value:function(t,e){"opening"!==this.readyState&&"open"!==this.readyState&&"closing"!==this.readyState||(this.clearTimeoutFn(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),"function"==typeofremoveEventListener&&(removeEventListener("beforeunload",this.beforeunloadEventListener,!1),removeEventListener("offline",this.offlineEventListener,!1)),this.readyState="closed",this.id=null,this.emitReserved("close",t,e),this.writeBuffer=[],this.prevBufferLen=0)}},{key:"filterUpgrades",value:function(t){for(vare=[],n=0,r=t.length;n<r;n++)~this.transports.indexOf(t[n])&&e.push(t[n]);returne}}]),a}(L);lt.protocol=4,lt.protocol;varpt="function"==typeofArrayBuffer,dt=Object.prototype.toString,yt="function"==typeofBlob||"undefined"!=typeofBlob&&"[object BlobConstructor]"===dt.call(Blob),vt="function"==typeofFile||"undefined"!=typeofFile&&"[object FileConstructor]"===dt.call(File);functiongt(t){returnpt&&(tinstanceofArrayBuffer||function(t){return"function"==typeofArrayBuffer.isView?ArrayBuffer.isView(t):t.bufferinstanceofArrayBuffer}(t))||yt&&tinstanceofBlob||vt&&tinstanceofFile}functionmt(e,n){if(!e||"object"!==t(e))return!1;if(Array.isArray(e)){for(varr=0,i=e.length;r<i;r++)if(mt(e[r]))return!0;return!1}if(gt(e))return!0;if(e.toJSON&&"function"==typeofe.toJSON&&1===arguments.length)returnmt(e.toJSON(),!0);for(varoine)if(Object.prototype.hasOwnProperty.call(e,o)&&mt(e[o]))return!0;return!1}functionkt(t){vare=[],n=t.data,r=t;returnr.data=bt(n,e),r.attachments=e.length,{packet:r,buffers:e}}functionbt(e,n){if(!e)returne;if(gt(e)){varr={_placeholder:!0,num:n.length};returnn.push(e),r}if(Array.isArray(e)){for(vari=newArray(e.length),o=0;o<e.length;o++)i[o]=bt(e[o],n);returni}if("object"===t(e)&&!(einstanceofDate)){vars={};for(varaine)Object.prototype.hasOwnProperty.call(e,a)&&(s[a]=bt(e[a],n));returns}returne}functionwt(t,e){returnt.data=_t(t.data,e),deletet.attachments,t}function_t(e,n){if(!e)returne;if(e&&!0===e._placeholder){if("number"==typeofe.num&&e.num>=0&&e.num<n.length)returnn[e.num];thrownewError("illegal attachments")}if(Array.isArray(e))for(varr=0;r<e.length;r++)e[r]=_t(e[r],n);elseif("object"===t(e))for(variine)Object.prototype.hasOwnProperty.call(e,i)&&(e[i]=_t(e[i],n));returne}varEt;!function(t){t[t.CONNECT=0]="CONNECT",t[t.DISCONNECT=1]="DISCONNECT",t[t.EVENT=2]="EVENT",t[t.ACK=3]="ACK",t[t.CONNECT_ERROR=4]="CONNECT_ERROR",t[t.BINARY_EVENT=5]="BINARY_EVENT",t[t.BINARY_ACK=6]="BINARY_ACK"}(Et||(Et={}));varOt=function(){functiont(n){e(this,t),this.replacer=n}returnr(t,[{key:"encode",value:function(t){returnt.type!==Et.EVENT&&t.type!==Et.ACK||!mt(t)?[this.encodeAsString(t)]:this.encodeAsBinary({type:t.type===Et.EVENT?Et.BINARY_EVENT:Et.BINARY_ACK,nsp:t.nsp,data:t.data,id:t.id})}},{key:"encodeAsString",value:function(t){vare=""+t.type;returnt.type!==Et.BINARY_EVENT&&t.type!==Et.BINARY_ACK||(e+=t.attachments+"-"),t.nsp&&"/"!==t.nsp&&(e+=t.nsp+","),null!=t.id&&(e+=t.id),null!=t.data&&(e+=JSON.stringify(t.data,this.replacer)),e}},{key:"encodeAsBinary",value:function(t){vare=kt(t),n=this.encodeAsString(e.packet),r=e.buffers;returnr.unshift(n),r}}]),t}(),At=function(n){o(a,n);vari=p(a);functiona(t){varn;returne(this,a),(n=i.call(this)).reviver=t,n}returnr(a,[{key:"add",value:function(t){vare;if("string"==typeoft){if(this.reconstructor)thrownewError("got plaintext data when reconstructing a packet");varn=(e=this.decodeString(t)).type===Et.BINARY_EVENT;n||e.type===Et.BINARY_ACK?(e.type=n?Et.EVENT:Et.ACK,this.reconstructor=newRt(e),0===e.attachments&&y(s(a.prototype),"emitReserved",this).call(this,"decoded",e)):y(s(a.prototype),"emitReserved",this).call(this,"decoded",e)}else{if(!gt(t)&&!t.base64)thrownewError("Unknown type: "+t);if(!this.reconstructor)thrownewError("got binary data when not reconstructing a packet");(e=this.reconstructor.takeBinaryData(t))&&(this.reconstructor=null,y(s(a.prototype),"emitReserved",this).call(this,"decoded",e))}}},{key:"decodeString",value:function(t){vare=0,n={type:Number(t.charAt(0))};if(void0===Et[n.type])thrownewError("unknown packet type "+n.type);if(n.type===Et.BINARY_EVENT||n.type===Et.BINARY_ACK){for(varr=e+1;"-"!==t.charAt(++e)&&e!=t.length;);vari=t.substring(r,e);if(i!=Number(i)||"-"!==t.charAt(e))thrownewError("Illegal attachments");n.attachments=Number(i)}if("/"===t.charAt(e+1)){for(varo=e+1;++e;){if(","===t.charAt(e))break;if(e===t.length)break}n.nsp=t.substring(o,e)}elsen.nsp="/";vars=t.charAt(e+1);if(""!==s&&Number(s)==s){for(varc=e+1;++e;){varu=t.charAt(e);if(null==u||Number(u)!=u){--e;break}if(e===t.length)break}n.id=Number(t.substring(c,e+1))}if(t.charAt(++e)){varh=this.tryParse(t.substr(e));if(!a.isPayloadValid(n.type,h))thrownewError("invalid payload");n.data=h}returnn}},{key:"tryParse",value:function(t){try{returnJSON.parse(t,this.reviver)}catch(t){return!1}}},{key:"destroy",value:function(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}],[{key:"isPayloadValid",value:function(e,n){switch(e){caseEt.CONNECT:return"object"===t(n);caseEt.DISCONNECT:returnvoid0===n;caseEt.CONNECT_ERROR:return"string"==typeofn||"object"===t(n);caseEt.EVENT:caseEt.BINARY_EVENT:returnArray.isArray(n)&&n.length>0;caseEt.ACK:caseEt.BINARY_ACK:returnArray.isArray(n)}}}]),a}(L),Rt=function(){functiont(n){e(this,t),this.packet=n,this.buffers=[],this.reconPack=n}returnr(t,[{key:"takeBinaryData",value:function(t){if(this.buffers.push(t),this.buffers.length===this.reconPack.attachments){vare=wt(this.reconPack,this.buffers);returnthis.finishedReconstruction(),e}returnnull}},{key:"finishedReconstruction",value:function(){this.reconPack=null,this.buffers=[]}}]),t}(),Tt=Object.freeze({__proto__:null,protocol:5,getPacketType(){returnEt},Encoder:Ot,Decoder:At});functionCt(t,e,n){returnt.on(e,n),function(){t.off(e,n)}}varBt=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),St=function(t){o(a,t);varn=p(a);functiona(t,r,o){vars;returne(this,a),(s=n.call(this)).connected=!1,s.recovered=!1,s.receiveBuffer=[],s.sendBuffer=[],s._queue=[],s.ids=0,s.acks={},s.flags={},s.io=t,s.nsp=r,o&&o.auth&&(s.auth=o.auth),s._opts=i({},o),s.io._autoConnect&&s.open(),s}returnr(a,[{key:"disconnected",get:function(){return!this.connected}},{key:"subEvents",value:function(){if(!this.subs){vart=this.io;this.subs=[Ct(t,"open",this.onopen.bind(this)),Ct(t,"packet",this.onpacket.bind(this)),Ct(t,"error",this.onerror.bind(this)),Ct(t,"close",this.onclose.bind(this))]}}},{key:"active",get:function(){return!!this.subs}},{key:"connect",value:function(){returnthis.connected||(this.subEvents(),this.io._reconnecting||this.io.open(),"open"===this.io._readyState&&this.onopen()),this}},{key:"open",value:function(){returnthis.connect()}},{key:"send",value:function(){for(vart=arguments.length,e=newArray(t),n=0;n<t;n++)e[n]=arguments[n];returne.unshift("message"),this.emit.apply(this,e),this}},{key:"emit",value:function(t){if(Bt.hasOwnProperty(t))thrownewError('"'+t.toString()+'" is a reserved event name');for(vare=arguments.length,n=newArray(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];if(n.unshift(t),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)returnthis._addToQueue(n),this;vari={type:Et.EVENT,data:n,options:{}};if(i.options.compress=!1!==this.flags.compress,"function"==typeofn[n.length-1]){varo=this.ids++,s=n.pop();this._registerAckCallback(o,s),i.id=o}vara=this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable,c=this.flags.volatile&&(!a||!this.connected);returnc||(this.connected?(this.notifyOutgoingListeners(i),this.packet(i)):this.sendBuffer.push(i)),this.flags={},this}},{key:"_registerAckCallback",value:function(t,e){varn,r=this,i=null!==(n=this.flags.timeout)&&void0!==n?n:this._opts.ackTimeout;if(void0!==i){varo=this.io.setTimeoutFn((function(){deleter.acks[t];for(varn=0;n<r.sendBuffer.length;n++)r.sendBuffer[n].id===t&&r.sendBuffer.splice(n,1);e.call(r,newError("operation has timed out"))}),i);this.acks[t]=function(){r.io.clearTimeoutFn(o);for(vart=arguments.length,n=newArray(t),i=0;i<t;i++)n[i]=arguments[i];e.apply(r,[null].concat(n))}}elsethis.acks[t]=e}},{key:"emitWithAck",value:function(t){for(vare=this,n=arguments.length,r=newArray(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];varo=void0!==this.flags.timeout||void0!==this._opts.ackTimeout;returnnewPromise((function(n,i){r.push((function(t,e){returno?t?i(t):n(e):n(t)})),e.emit.apply(e,[t].concat(r))}))}},{key:"_addToQueue",value:function(t){vare,n=this;"function"==typeoft[t.length-1]&&(e=t.pop());varr={id:this.ids++,tryCount:0,pending:!1,args:t,flags:i({fromQueue:!0},this.flags)};t.push((function(t){if(r===n._queue[0]){vari=null!==t;if(i)r.tryCount>n._opts.retries&&(n._queue.shift(),e&&e(t));elseif(n._queue.shift(),e){for(varo=arguments.length,s=newArray(o>1?o-1:0),a=1;a<o;a++)s[a-1]=arguments[a];e.apply(void0,[null].concat(s))}returnr.pending=!1,n._drainQueue()}})),this._queue.push(r),this._drainQueue()}},{key:"_drainQueue",value:function(){if(0!==this._queue.length){vart=this._queue[0];if(!t.pending){t.pending=!0,t.tryCount++;vare=this.ids;this.ids=t.id,this.flags=t.flags,this.emit.apply(this,t.args),this.ids=e}}}},{key:"packet",value:function(t){t.nsp=this.nsp,this.io._packet(t)}},{key:"onopen",value:function(){vart=this;"function"==typeofthis.auth?this.auth((function(e){t._sendConnectPacket(e)})):this._sendConnectPacket(this.auth)}},{key:"_sendConnectPacket",value:function(t){this.packet({type:Et.CONNECT,data:this._pid?i({pid:this._pid,offset:this._lastOffset},t):t})}},{key:"onerror",value:function(t){this.connected||this.emitReserved("connect_error",t)}},{key:"onclose",value:function(t,e){this.connected=!1,deletethis.id,this.emitReserved("disconnect",t,e)}},{key:"onpacket",value:function(t){if(t.nsp===this.nsp)switch(t.type){caseEt.CONNECT:t.data&&t.data.sid?this.onconnect(t.data.sid,t.data.pid):this.emitReserved("connect_error",newError("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;caseEt.EVENT:caseEt.BINARY_EVENT:this.onevent(t);break;caseEt.ACK:caseEt.BINARY_ACK:this.onack(t);break;caseEt.DISCONNECT:this.ondisconnect();break;caseEt.CONNECT_ERROR:this.destroy();vare=newError(t.data.message);e.data=t.data.data,this.emitReserved("connect_error",e)}}},{key:"onevent",value:function(t){vare=t.data||[];null!=t.id&&e.push(this.ack(t.id)),this.connected?this.emitEvent(e):this.receiveBuffer.push(Object.freeze(e))}},{key:"emitEvent",value:function(t){if(this._anyListeners&&this._anyListeners.length){vare,n=g(this._anyListeners.slice());try{for(n.s();!(e=n.n()).done;){e.value.apply(this,t)}}catch(t){n.e(t)}finally{n.f()}}y(s(a.prototype),"emit",this).apply(this,t),this._pid&&t.length&&"string"==typeoft[t.length-1]&&(this._lastOffset=t[t.length-1])}},{key:"ack",value:function(t){vare=this,n=!1;returnfunction(){if(!n){n=!0;for(varr=arguments.length,i=newArray(r),o=0;o<r;o++)i[o]=arguments[o];e.packet({type:Et.ACK,id:t,data:i})}}}},{key:"onack",value:function(t){vare=this.acks[t.id];"function"==typeofe&&(e.apply(this,t.data),deletethis.acks[t.id])}},{key:"onconnect",value:function(t,e){this.id=t,this.recovered=e&&this._pid===e,this._pid=e,this.connected=!0,this.emitBuffered(),this.emitReserved("connect")}},{key:"emitBuffered",value:function(){vart=this;this.receiveBuffer.forEach((function(e){returnt.emitEvent(e)})),this.receiveBuffer=[],this.sendBuffer.forEach((function(e){t.notifyOutgoingListeners(e),t.packet(e)})),this.sendBuffer=[]}},{key:"ondisconnect",value:function(){this.destroy(),this.onclose("io server disconnect")}},{key:"destroy",value:function(){this.subs&&(this.subs.forEach((function(t){returnt()})),this.subs=void0),this.io._destroy(this)}},{key:"disconnect",value:function(){returnthis.connected&&this.packet({type:Et.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}},{key:"close",value:function(){returnthis.disconnect()}},{key:"compress",value:function(t){returnthis.flags.compress=t,this}},{key:"volatile",get:function(){returnthis.flags.volatile=!0,this}},{key:"timeout",value:function(t){returnthis.flags.timeout=t,this}},{key:"onAny",value:function(t){returnthis._anyListeners=this._anyListeners||[],this._anyListeners.push(t),this}},{key:"prependAny",value:function(t){returnthis._anyListeners=this._anyListeners||[],this._anyListeners.unshift(t),this}},{key:"offAny",value:function(t){if(!this._anyListeners)returnthis;if(t){for(vare=this._anyListeners,n=0;n<e.length;n++)if(t===e[n])returne.splice(n,1),this}elsethis._anyListeners=[];returnthis}},{key:"listenersAny",value:function(){returnthis._anyListeners||[]}},{key:"onAnyOutgoing",value:function(t){returnthis._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(t),this}},{key:"prependAnyOutgoing",value:function(t){returnthis._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(t),this}},{key:"offAnyOutgoing",value:function(t){if(!this._anyOutgoingListeners)returnthis;if(t){for(vare=this._anyOutgoingListeners,n=0;n<e.length;n++)if(t===e[n])returne.splice(n,1),this}elsethis._anyOutgoingListeners=[];returnthis}},{key:"listenersAnyOutgoing",value:function(){returnthis._anyOutgoingListeners||[]}},{key:"notifyOutgoingListeners",value:function(t){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){vare,n=g(this._anyOutgoingListeners.slice());try{for(n.s();!(e=n.n()).done;){e.value.apply(this,t.data)}}catch(t){n.e(t)}finally{n.f()}}}}]),a}(L);functionNt(t){t=t||{},this.ms=t.min||100,this.max=t.max||1e4,this.factor=t.factor||2,this.jitter=t.jitter>0&&t.jitter<=1?t.jitter:0,this.attempts=0}Nt.prototype.duration=function(){vart=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){vare=Math.random(),n=Math.floor(e*this.jitter*t);t=0==(1&Math.floor(10*e))?t-n:t+n}return0|Math.min(t,this.max)},Nt.prototype.reset=function(){this.attempts=0},Nt.prototype.setMin=function(t){this.ms=t},Nt.prototype.setMax=function(t){this.max=t},Nt.prototype.setJitter=function(t){this.jitter=t};varxt=function(n){o(s,n);vari=p(s);functions(n,r){varo,a;e(this,s),(o=i.call(this)).nsps={},o.subs=[],n&&"object"===t(n)&&(r=n,n=void0),(r=r||{}).path=r.path||"/socket.io",o.opts=r,D(f(o),r),o.reconnection(!1!==r.reconnection),o.reconnectionAttempts(r.reconnectionAttempts||1/0),o.reconnectionDelay(r.reconnectionDelay||1e3),o.reconnectionDelayMax(r.reconnectionDelayMax||5e3),o.randomizationFactor(null!==(a=r.randomizationFactor)&&void0!==a?a:.5),o.backoff=newNt({min:o.reconnectionDelay(),max:o.reconnectionDelayMax(),jitter:o.randomizationFactor()}),o.timeout(null==r.timeout?2e4:r.timeout),o._readyState="closed",o.uri=n;varc=r.parser||Tt;returno.encoder=newc.Encoder,o.decoder=newc.Decoder,o._autoConnect=!1!==r.autoConnect,o._autoConnect&&o.open(),o}returnr(s,[{key:"reconnection",value:function(t){returnarguments.length?(this._reconnection=!!t,this):this._reconnection}},{key:"reconnectionAttempts",value:function(t){returnvoid0===t?this._reconnectionAttempts:(this._reconnectionAttempts=t,this)}},{key:"reconnectionDelay",value:function(t){vare;returnvoid0===t?this._reconnectionDelay:(this._reconnectionDelay=t,null===(e=this.backoff)||void0===e||e.setMin(t),this)}},{key:"randomizationFactor",value:function(t){vare;returnvoid0===t?this._randomizationFactor:(this._randomizationFactor=t,null===(e=this.backoff)||void0===e||e.setJitter(t),this)}},{key:"reconnectionDelayMax",value:function(t){vare;returnvoid0===t?this._reconnectionDelayMax:(this._reconnectionDelayMax=t,null===(e=this.backoff)||void0===e||e.setMax(t),this)}},{key:"timeout",value:function(t){returnarguments.length?(this._timeout=t,this):this._timeout}},{key:"maybeReconnectOnOpen",value:function(){!this._reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()}},{key:"open",value:function(t){vare=this;if(~this._readyState.indexOf("open"))returnthis;this.engine=newlt(this.uri,this.opts);varn=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;vari=Ct(n,"open",(function(){r.onopen(),t&&t()})),o=Ct(n,"error",(function(n){r.cleanup(),r._readyState="closed",e.emitReserved("error",n),t?t(n):r.maybeReconnectOnOpen()}));if(!1!==this._timeout){vars=this._timeout;0===s&&i();vara=this.setTimeoutFn((function(){i(),n.close(),n.emit("error",newError("timeout"))}),s);this.opts.autoUnref&&a.unref(),this.subs.push((function(){clearTimeout(a)}))}returnthis.subs.push(i),this.subs.push(o),this}},{key:"connect",value:function(t){returnthis.open(t)}},{key:"onopen",value:function(){this.cleanup(),this._readyState="open",this.emitReserved("open");vart=this.engine;this.subs.push(Ct(t,"ping",this.onping.bind(this)),Ct(t,"data",this.ondata.bind(this)),Ct(t,"error",this.onerror.bind(this)),Ct(t,"close",this.onclose.bind(this)),Ct(this.decoder,"decoded",this.ondecoded.bind(this)))}},{key:"onping",value:function(){this.emitReserved("ping")}},{key:"ondata",value:function(t){try{this.decoder.add(t)}catch(t){this.onclose("parse error",t)}}},{key:"ondecoded",value:function(t){vare=this;it((function(){e.emitReserved("packet",t)}),this.setTimeoutFn)}},{key:"onerror",value:function(t){this.emitReserved("error",t)}},{key:"socket",value:function(t,e){varn=this.nsps[t];returnn||(n=newSt(this,t,e),this.nsps[t]=n),this._autoConnect&&n.connect(),n}},{key:"_destroy",value:function(t){for(vare=0,n=Object.keys(this.nsps);e<n.length;e++){varr=n[e];if(this.nsps[r].active)return}this._close()}},{key:"_packet",value:function(t){for(vare=this.encoder.encode(t),n=0;n<e.length;n++)this.engine.write(e[n],t.options)}},{key:"cleanup",value:function(){this.subs.forEach((function(t){returnt()})),this.subs.length=0,this.decoder.destroy()}},{key:"_close",value:function(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close"),this.engine&&this.engine.close()}},{key:"disconnect",value:function(){returnthis._close()}},{key:"onclose",value:function(t,e){this.cleanup(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",t,e),this._reconnection&&!this.skipReconnect&&this.reconnect()}},{key:"reconnect",value:function(){vart=this;if(this._reconnecting||this.skipReconnect)returnthis;vare=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{varn=this.backoff.duration();this._reconnecting=!0;varr=this.setTimeoutFn((function(){e.skipReconnect||(t.emitReserved("reconnect_attempt",e.backoff.attempts),e.skipReconnect||e.open((function(n){n?(e._reconnecting=!1,e.reconnect(),t.emitReserved("reconnect_error",n)):e.onreconnect()})))}),n);this.opts.autoUnref&&r.unref(),this.subs.push((function(){clearTimeout(r)}))}}},{key:"onreconnect",value:function(){vart=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",t)}}]),s}(L),Lt={};functionPt(e,n){"object"===t(e)&&(n=e,e=void0);varr,i=function(t){vare=arguments.length>1&&void0!==arguments[1]?arguments[1]:"",n=arguments.length>2?arguments[2]:void0,r=t;n=n||"undefined"!=typeoflocation&&location,null==t&&(t=n.protocol+"//"+n.host),"string"==typeoft&&("/"===t.charAt(0)&&(t="/"===t.charAt(1)?n.protocol+t:n.host+t),/^(https?|wss?):\/\//.test(t)||(t=void0!==n?n.protocol+"//"+t:"https://"+t),r=ft(t)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port="80":/^(http|ws)s$/.test(r.protocol)&&(r.port="443")),r.path=r.path||"/";vari=-1!==r.host.indexOf(":")?"["+r.host+"]":r.host;returnr.id=r.protocol+"://"+i+":"+r.port+e,r.href=r.protocol+"://"+i+(n&&n.port===r.port?"":":"+r.port),r}(e,(n=n||{}).path||"/socket.io"),o=i.source,s=i.id,a=i.path,c=Lt[s]&&ainLt[s].nsps;returnn.forceNew||n["force new connection"]||!1===n.multiplex||c?r=newxt(o,n):(Lt[s]||(Lt[s]=newxt(o,n)),r=Lt[s]),i.query&&!n.query&&(n.query=i.queryKey),r.socket(i.path,n)}returni(Pt,{Manager:xt,Socket:St,io:Pt,connect:Pt}),Pt}));