"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "dist/socket.io.esm.min.js" between
socket.io-client-4.5.1.tar.gz and socket.io-client-4.5.2.tar.gz

About: Socket.IO client is a Javascript client library for the browser (or a Node.js client) that enables real-time communication with an Socket.IO server.

socket.io.esm.min.js  (socket.io-client-4.5.1):socket.io.esm.min.js  (socket.io-client-4.5.2)
/*! /*!
* Socket.IO v4.5.1 * Socket.IO v4.5.2
* (c) 2014-2022 Guillermo Rauch * (c) 2014-2022 Guillermo Rauch
* Released under the MIT License. * Released under the MIT License.
*/ */
const t=Object.create(null);t.open="0",t.close="1",t.ping="2",t.pong="3",t.messa ge="4",t.upgrade="5",t.noop="6";const e=Object.create(null);Object.keys(t).forEa ch((s=>{e[t[s]]=s}));const s={type:"error",data:"parser error"},n="function"==ty peof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Object.prototy pe.toString.call(Blob),i="function"==typeof ArrayBuffer,r=({type:e,data:s},r,a)= >{return n&&s instanceof Blob?r?a(s):o(s,a):i&&(s instanceof ArrayBuffer||(h=s," function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(h):h&&h.buffer instanceo f ArrayBuffer))?r?a(s):o(new Blob([s]),a):a(t[e]+(s||""));var h},o=(t,e)=>{const s=new FileReader;return s.onload=function(){const t=s.result.split(",")[1];e("b "+t)},s.readAsDataURL(t)};for(var a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopq rstuvwxyz0123456789+/",h="undefined"==typeof Uint8Array?[]:new Uint8Array(256),c =0;c<a.length;c++)h[a.charCodeAt(c)]=c;const p="function"==typeof ArrayBuffer,u= (t,n)=>{if("string"!=typeof t)return{type:"message",data:d(t,n)};const i=t.charA t(0);if("b"===i)return{type:"message",data:l(t.substring(1),n)};return e[i]?t.le ngth>1?{type:e[i],data:t.substring(1)}:{type:e[i]}:s},l=(t,e)=>{if(p){const s=fu nction(t){var e,s,n,i,r,o=.75*t.length,a=t.length,c=0;"="===t[t.length-1]&&(o--, "="===t[t.length-2]&&o--);var p=new ArrayBuffer(o),u=new Uint8Array(p);for(e=0;e <a;e+=4)s=h[t.charCodeAt(e)],n=h[t.charCodeAt(e+1)],i=h[t.charCodeAt(e+2)],r=h[t .charCodeAt(e+3)],u[c++]=s<<2|n>>4,u[c++]=(15&n)<<4|i>>2,u[c++]=(3&i)<<6|63&r;re turn p}(t);return d(s,e)}return{base64:!0,data:t}},d=(t,e)=>"blob"===e&&t instan ceof ArrayBuffer?new Blob([t]):t,f=String.fromCharCode(30);function y(t){if(t)re turn function(t){for(var e in y.prototype)t[e]=y.prototype[e];return t}(t)}y.pro totype.on=y.prototype.addEventListener=function(t,e){return this._callbacks=this ._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this },y.prototype.once=function(t,e){function s(){this.off(t,s),e.apply(this,argumen ts)}return s.fn=e,this.on(t,s),this},y.prototype.off=y.prototype.removeListener= y.prototype.removeAllListeners=y.prototype.removeEventListener=function(t,e){if( this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={ },this;var s,n=this._callbacks["$"+t];if(!n)return this;if(1==arguments.length)r eturn delete this._callbacks["$"+t],this;for(var i=0;i<n.length;i++)if((s=n[i])= ==e||s.fn===e){n.splice(i,1);break}return 0===n.length&&delete this._callbacks[" $"+t],this},y.prototype.emit=function(t){this._callbacks=this._callbacks||{};for (var e=new Array(arguments.length-1),s=this._callbacks["$"+t],n=1;n<arguments.le ngth;n++)e[n-1]=arguments[n];if(s){n=0;for(var i=(s=s.slice(0)).length;n<i;++n)s [n].apply(this,e)}return this},y.prototype.emitReserved=y.prototype.emit,y.proto type.listeners=function(t){return this._callbacks=this._callbacks||{},this._call backs["$"+t]||[]},y.prototype.hasListeners=function(t){return!!this.listeners(t) .length};var g="undefined"!=typeof self?self:"undefined"!=typeof window?window:F unction("return this")();function m(t,...e){return e.reduce(((e,s)=>(t.hasOwnPro perty(s)&&(e[s]=t[s]),e)),{})}const b=setTimeout,v=clearTimeout;function k(t,e){ e.useNativeTimers?(t.setTimeoutFn=b.bind(g),t.clearTimeoutFn=v.bind(g)):(t.setTi meoutFn=setTimeout.bind(g),t.clearTimeoutFn=clearTimeout.bind(g))}class w extend s Error{constructor(t,e,s){super(t),this.description=e,this.context=s,this.type= "TransportError"}}class _ extends y{constructor(t){super(),this.writable=!1,k(th is,t),this.opts=t,this.query=t.query,this.readyState="",this.socket=t.socket}onE rror(t,e,s){return super.emitReserved("error",new w(t,e,s)),this}open(){return"c losed"!==this.readyState&&""!==this.readyState||(this.readyState="opening",this. doOpen()),this}close(){return"opening"!==this.readyState&&"open"!==this.readySta te||(this.doClose(),this.onClose()),this}send(t){"open"===this.readyState&&this. write(t)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("op en")}onData(t){const e=u(t,this.socket.binaryType);this.onPacket(e)}onPacket(t){ super.emitReserved("packet",t)}onClose(t){this.readyState="closed",super.emitRes erved("close",t)}}const E="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopq rstuvwxyz-_".split(""),A={};let R,O=0,C=0;function T(t){let e="";do{e=E[t%64]+e, t=Math.floor(t/64)}while(t>0);return e}function B(){const t=T(+new Date);return t!==R?(O=0,R=t):t+"."+T(O++)}for(;C<64;C++)A[E[C]]=C;function N(t){let e="";for( let s in t)t.hasOwnProperty(s)&&(e.length&&(e+="&"),e+=encodeURIComponent(s)+"=" +encodeURIComponent(t[s]));return e}let x=!1;try{x="undefined"!=typeof XMLHttpRe quest&&"withCredentials"in new XMLHttpRequest}catch(t){}const S=x;function L(t){ const e=t.xdomain;try{if("undefined"!=typeof XMLHttpRequest&&(!e||S))return new XMLHttpRequest}catch(t){}if(!e)try{return new(g[["Active"].concat("Object").join ("X")])("Microsoft.XMLHTTP")}catch(t){}}function P(){}const j=null!=new L({xdoma in:!1}).responseType;class q extends y{constructor(t,e){super(),k(this,e),this.o pts=e,this.method=e.method||"GET",this.uri=t,this.async=!1!==e.async,this.data=v oid 0!==e.data?e.data:null,this.create()}create(){const t=m(this.opts,"agent","p fx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t .xdomain=!!this.opts.xd,t.xscheme=!!this.opts.xs;const e=this.xhr=new L(t);try{e .open(this.method,this.uri,this.async);try{if(this.opts.extraHeaders){e.setDisab leHeaderCheck&&e.setDisableHeaderCheck(!0);for(let t in this.opts.extraHeaders)t his.opts.extraHeaders.hasOwnProperty(t)&&e.setRequestHeader(t,this.opts.extraHea ders[t])}}catch(t){}if("POST"===this.method)try{e.setRequestHeader("Content-type ","text/plain;charset=UTF-8")}catch(t){}try{e.setRequestHeader("Accept","*/*")}c atch(t){}"withCredentials"in e&&(e.withCredentials=this.opts.withCredentials),th is.opts.requestTimeout&&(e.timeout=this.opts.requestTimeout),e.onreadystatechang e=()=>{4===e.readyState&&(200===e.status||1223===e.status?this.onLoad():this.set TimeoutFn((()=>{this.onError("number"==typeof e.status?e.status:0)}),0))},e.send (this.data)}catch(t){return void this.setTimeoutFn((()=>{this.onError(t)}),0)}"u ndefined"!=typeof document&&(this.index=q.requestsCount++,q.requests[this.index] =this)}onError(t){this.emitReserved("error",t,this.xhr),this.cleanup(!0)}cleanup (t){if(void 0!==this.xhr&&null!==this.xhr){if(this.xhr.onreadystatechange=P,t)tr y{this.xhr.abort()}catch(t){}"undefined"!=typeof document&&delete q.requests[thi s.index],this.xhr=null}}onLoad(){const t=this.xhr.responseText;null!==t&&(this.e mitReserved("data",t),this.emitReserved("success"),this.cleanup())}abort(){this. cleanup()}}if(q.requestsCount=0,q.requests={},"undefined"!=typeof document)if("f unction"==typeof attachEvent)attachEvent("onunload",I);else if("function"==typeo f addEventListener){addEventListener("onpagehide"in g?"pagehide":"unload",I,!1)} function I(){for(let t in q.requests)q.requests.hasOwnProperty(t)&&q.requests[t] .abort()}const D="function"==typeof Promise&&"function"==typeof Promise.resolve? t=>Promise.resolve().then(t):(t,e)=>e(t,0),F=g.WebSocket||g.MozWebSocket,M="unde fined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===na vigator.product.toLowerCase();class U extends _{constructor(t){super(t),this.sup portsBinary=!t.forceBase64}get name(){return"websocket"}doOpen(){if(!this.check( ))return;const t=this.uri(),e=this.opts.protocols,s=M?{}:m(this.opts,"agent","pe rMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthori zed","localAddress","protocolVersion","origin","maxPayload","family","checkServe rIdentity");this.opts.extraHeaders&&(s.headers=this.opts.extraHeaders);try{this. ws=M?new F(t,e,s):e?new F(t,e):new F(t)}catch(t){return this.emitReserved("error ",t)}this.ws.binaryType=this.socket.binaryType||"arraybuffer",this.addEventListe ners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._soc ket.unref(),this.onOpen()},this.ws.onclose=t=>this.onClose({description:"websock et connection closed",context:t}),this.ws.onmessage=t=>this.onData(t.data),this. ws.onerror=t=>this.onError("websocket error",t)}write(t){this.writable=!1;for(le t e=0;e<t.length;e++){const s=t[e],n=e===t.length-1;r(s,this.supportsBinary,(t=> {try{this.ws.send(t)}catch(t){}n&&D((()=>{this.writable=!0,this.emitReserved("dr ain")}),this.setTimeoutFn)}))}}doClose(){void 0!==this.ws&&(this.ws.close(),this .ws=null)}uri(){let t=this.query||{};const e=this.opts.secure?"wss":"ws";let s=" ";this.opts.port&&("wss"===e&&443!==Number(this.opts.port)||"ws"===e&&80!==Numbe r(this.opts.port))&&(s=":"+this.opts.port),this.opts.timestampRequests&&(t[this. opts.timestampParam]=B()),this.supportsBinary||(t.b64=1);const n=N(t);return e+" ://"+(-1!==this.opts.hostname.indexOf(":")?"["+this.opts.hostname+"]":this.opts. hostname)+s+this.opts.path+(n.length?"?"+n:"")}check(){return!(!F||"__initialize "in F&&this.name===U.prototype.name)}}const V={websocket:U,polling:class extends _{constructor(t){if(super(t),this.polling=!1,"undefined"!=typeof location){cons t e="https:"===location.protocol;let s=location.port;s||(s=e?"443":"80"),this.xd ="undefined"!=typeof location&&t.hostname!==location.hostname||s!==t.port,this.x s=t.secure!==e}const e=t&&t.forceBase64;this.supportsBinary=j&&!e}get name(){ret urn"polling"}doOpen(){this.poll()}pause(t){this.readyState="pausing";const e=()= >{this.readyState="paused",t()};if(this.polling||!this.writable){let t=0;this.po lling&&(t++,this.once("pollComplete",(function(){--t||e()}))),this.writable||(t+ +,this.once("drain",(function(){--t||e()})))}else e()}poll(){this.polling=!0,thi s.doPoll(),this.emitReserved("poll")}onData(t){((t,e)=>{const s=t.split(f),n=[]; for(let t=0;t<s.length;t++){const i=u(s[t],e);if(n.push(i),"error"===i.type)brea k}return n})(t,this.socket.binaryType).forEach((t=>{if("opening"===this.readySta te&&"open"===t.type&&this.onOpen(),"close"===t.type)return this.onClose({descrip tion:"transport closed by the server"}),!1;this.onPacket(t)})),"closed"!==this.r eadyState&&(this.polling=!1,this.emitReserved("pollComplete"),"open"===this.read yState&&this.poll())}doClose(){const t=()=>{this.write([{type:"close"}])};"open" ===this.readyState?t():this.once("open",t)}write(t){this.writable=!1,((t,e)=>{co nst s=t.length,n=new Array(s);let i=0;t.forEach(((t,o)=>{r(t,!1,(t=>{n[o]=t,++i= ==s&&e(n.join(f))}))}))})(t,(t=>{this.doWrite(t,(()=>{this.writable=!0,this.emit Reserved("drain")}))}))}uri(){let t=this.query||{};const e=this.opts.secure?"htt ps":"http";let s="";!1!==this.opts.timestampRequests&&(t[this.opts.timestampPara m]=B()),this.supportsBinary||t.sid||(t.b64=1),this.opts.port&&("https"===e&&443! ==Number(this.opts.port)||"http"===e&&80!==Number(this.opts.port))&&(s=":"+this. opts.port);const n=N(t);return e+"://"+(-1!==this.opts.hostname.indexOf(":")?"[" +this.opts.hostname+"]":this.opts.hostname)+s+this.opts.path+(n.length?"?"+n:"") }request(t={}){return Object.assign(t,{xd:this.xd,xs:this.xs},this.opts),new q(t his.uri(),t)}doWrite(t,e){const s=this.request({method:"POST",data:t});s.on("suc cess",e),s.on("error",((t,e)=>{this.onError("xhr post error",t,e)}))}doPoll(){co nst t=this.request();t.on("data",this.onData.bind(this)),t.on("error",((t,e)=>{t his.onError("xhr poll error",t,e)})),this.pollXhr=t}}},H=/^(?:(?![^:@]+:[^:@\/]* @)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){ 2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[? #]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,K=["source","protocol","autho rity","userInfo","user","password","host","port","relative","path","directory"," file","query","anchor"];function Y(t){const e=t,s=t.indexOf("["),n=t.indexOf("]" );-1!=s&&-1!=n&&(t=t.substring(0,s)+t.substring(s,n).replace(/:/g,";")+t.substri ng(n,t.length));let i=H.exec(t||""),r={},o=14;for(;o--;)r[K[o]]=i[o]||"";return- 1!=s&&-1!=n&&(r.source=e,r.host=r.host.substring(1,r.host.length-1).replace(/;/g ,":"),r.authority=r.authority.replace("[","").replace("]","").replace(/;/g,":"), r.ipv6uri=!0),r.pathNames=function(t,e){const s=/\/{2,9}/g,n=e.replace(s,"/").sp lit("/");"/"!=e.substr(0,1)&&0!==e.length||n.splice(0,1);"/"==e.substr(e.length- 1,1)&&n.splice(n.length-1,1);return n}(0,r.path),r.queryKey=function(t,e){const s={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,(function(t,e,n){e&&(s[e]=n)}) ),s}(0,r.query),r}class z extends y{constructor(t,e={}){super(),t&&"object"==typ eof t&&(e=t,t=null),t?(t=Y(t),e.hostname=t.host,e.secure="https"===t.protocol||" wss"===t.protocol,e.port=t.port,t.query&&(e.query=t.query)):e.host&&(e.hostname= Y(e.host).host),k(this,e),this.secure=null!=e.secure?e.secure:"undefined"!=typeo f location&&"https:"===location.protocol,e.hostname&&!e.port&&(e.port=this.secur e?"443":"80"),this.hostname=e.hostname||("undefined"!=typeof location?location.h ostname:"localhost"),this.port=e.port||("undefined"!=typeof location&&location.p ort?location.port:this.secure?"443":"80"),this.transports=e.transports||["pollin g","websocket"],this.readyState="",this.writeBuffer=[],this.prevBufferLen=0,this .opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,ti mestampParam:"t",rememberUpgrade:!1,rejectUnauthorized:!0,perMessageDeflate:{thr eshold:1024},transportOptions:{},closeOnBeforeunload:!0},e),this.opts.path=this. opts.path.replace(/\/$/,"")+"/","string"==typeof this.opts.query&&(this.opts.que ry=function(t){let e={},s=t.split("&");for(let t=0,n=s.length;t<n;t++){let n=s[t ].split("=");e[decodeURIComponent(n[0])]=decodeURIComponent(n[1])}return e}(this .opts.query)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTi meout=null,this.pingTimeoutTimer=null,"function"==typeof addEventListener&&(this .opts.closeOnBeforeunload&&addEventListener("beforeunload",(()=>{this.transport& &(this.transport.removeAllListeners(),this.transport.close())}),!1),"localhost"! ==this.hostname&&(this.offlineEventListener=()=>{this.onClose("transport close", {description:"network connection lost"})},addEventListener("offline",this.offlin eEventListener,!1))),this.open()}createTransport(t){const e=Object.assign({},thi s.opts.query);e.EIO=4,e.transport=t,this.id&&(e.sid=this.id);const s=Object.assi gn({},this.opts.transportOptions[t],this.opts,{query:e,socket:this,hostname:this .hostname,secure:this.secure,port:this.port});return new V[t](s)}open(){let t;if (this.opts.rememberUpgrade&&z.priorWebsocketSuccess&&-1!==this.transports.indexO f("websocket"))t="websocket";else{if(0===this.transports.length)return void this .setTimeoutFn((()=>{this.emitReserved("error","No transports available")}),0);t= this.transports[0]}this.readyState="opening";try{t=this.createTransport(t)}catch (t){return this.transports.shift(),void this.open()}t.open(),this.setTransport(t )}setTransport(t){this.transport&&this.transport.removeAllListeners(),this.trans port=t,t.on("drain",this.onDrain.bind(this)).on("packet",this.onPacket.bind(this )).on("error",this.onError.bind(this)).on("close",(t=>this.onClose("transport cl ose",t)))}probe(t){let e=this.createTransport(t),s=!1;z.priorWebsocketSuccess=!1 ;const n=()=>{s||(e.send([{type:"ping",data:"probe"}]),e.once("packet",(t=>{if(! s)if("pong"===t.type&&"probe"===t.data){if(this.upgrading=!0,this.emitReserved(" upgrading",e),!e)return;z.priorWebsocketSuccess="websocket"===e.name,this.transp ort.pause((()=>{s||"closed"!==this.readyState&&(c(),this.setTransport(e),e.send( [{type:"upgrade"}]),this.emitReserved("upgrade",e),e=null,this.upgrading=!1,this .flush())}))}else{const t=new Error("probe error");t.transport=e.name,this.emitR eserved("upgradeError",t)}})))};function i(){s||(s=!0,c(),e.close(),e=null)}cons t r=t=>{const s=new Error("probe error: "+t);s.transport=e.name,i(),this.emitRes erved("upgradeError",s)};function o(){r("transport closed")}function a(){r("sock et closed")}function h(t){e&&t.name!==e.name&&i()}const c=()=>{e.removeListener( "open",n),e.removeListener("error",r),e.removeListener("close",o),this.off("clos e",a),this.off("upgrading",h)};e.once("open",n),e.once("error",r),e.once("close" ,o),this.once("close",a),this.once("upgrading",h),e.open()}onOpen(){if(this.read yState="open",z.priorWebsocketSuccess="websocket"===this.transport.name,this.emi tReserved("open"),this.flush(),"open"===this.readyState&&this.opts.upgrade&&this .transport.pause){let t=0;const e=this.upgrades.length;for(;t<e;t++)this.probe(t his.upgrades[t])}}onPacket(t){if("opening"===this.readyState||"open"===this.read yState||"closing"===this.readyState)switch(this.emitReserved("packet",t),this.em itReserved("heartbeat"),t.type){case"open":this.onHandshake(JSON.parse(t.data)); break;case"ping":this.resetPingTimeout(),this.sendPacket("pong"),this.emitReserv ed("ping"),this.emitReserved("pong");break;case"error":const e=new Error("server error");e.code=t.data,this.onError(e);break;case"message":this.emitReserved("da ta",t.data),this.emitReserved("message",t.data)}}onHandshake(t){this.emitReserve d("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.readyStat e&&this.resetPingTimeout()}resetPingTimeout(){this.clearTimeoutFn(this.pingTimeo utTimer),this.pingTimeoutTimer=this.setTimeoutFn((()=>{this.onClose("ping timeou t")}),this.pingInterval+this.pingTimeout),this.opts.autoUnref&&this.pingTimeoutT imer.unref()}onDrain(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBu fferLen=0,0===this.writeBuffer.length?this.emitReserved("drain"):this.flush()}fl ush(){if("closed"!==this.readyState&&this.transport.writable&&!this.upgrading&&t his.writeBuffer.length){const t=this.getWritablePackets();this.transport.send(t) ,this.prevBufferLen=t.length,this.emitReserved("flush")}}getWritablePackets(){if (!(this.maxPayload&&"polling"===this.transport.name&&this.writeBuffer.length>1)) return this.writeBuffer;let t=1;for(let s=0;s<this.writeBuffer.length;s++){const n=this.writeBuffer[s].data;if(n&&(t+="string"==typeof(e=n)?function(t){let e=0, s=0;for(let n=0,i=t.length;n<i;n++)e=t.charCodeAt(n),e<128?s+=1:e<2048?s+=2:e<55 296||e>=57344?s+=3:(n++,s+=4);return s}(e):Math.ceil(1.33*(e.byteLength||e.size) )),s>0&&t>this.maxPayload)return this.writeBuffer.slice(0,s);t+=2}var e;return t his.writeBuffer}write(t,e,s){return this.sendPacket("message",t,e,s),this}send(t ,e,s){return this.sendPacket("message",t,e,s),this}sendPacket(t,e,s,n){if("funct ion"==typeof e&&(n=e,e=void 0),"function"==typeof s&&(n=s,s=null),"closing"===th is.readyState||"closed"===this.readyState)return;(s=s||{}).compress=!1!==s.compr ess;const i={type:t,data:e,options:s};this.emitReserved("packetCreate",i),this.w riteBuffer.push(i),n&&this.once("flush",n),this.flush()}close(){const t=()=>{thi s.onClose("forced close"),this.transport.close()},e=()=>{this.off("upgrade",e),t his.off("upgradeError",e),t()},s=()=>{this.once("upgrade",e),this.once("upgradeE rror",e)};return"opening"!==this.readyState&&"open"!==this.readyState||(this.rea dyState="closing",this.writeBuffer.length?this.once("drain",(()=>{this.upgrading ?s():t()})):this.upgrading?s():t()),this}onError(t){z.priorWebsocketSuccess=!1,t his.emitReserved("error",t),this.onClose("transport error",t)}onClose(t,e){"open ing"!==this.readyState&&"open"!==this.readyState&&"closing"!==this.readyState||( this.clearTimeoutFn(this.pingTimeoutTimer),this.transport.removeAllListeners("cl ose"),this.transport.close(),this.transport.removeAllListeners(),"function"==typ eof removeEventListener&&removeEventListener("offline",this.offlineEventListener ,!1),this.readyState="closed",this.id=null,this.emitReserved("close",t,e),this.w riteBuffer=[],this.prevBufferLen=0)}filterUpgrades(t){const e=[];let s=0;const n =t.length;for(;s<n;s++)~this.transports.indexOf(t[s])&&e.push(t[s]);return e}}z. protocol=4;const W="function"==typeof ArrayBuffer,$=Object.prototype.toString,J= "function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"=== $.call(Blob),X="function"==typeof File||"undefined"!=typeof File&&"[object FileC onstructor]"===$.call(File);function G(t){return W&&(t instanceof ArrayBuffer||( t=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(t):t.buffer instance of ArrayBuffer)(t))||J&&t instanceof Blob||X&&t instanceof File}function Q(t,e){ if(!t||"object"!=typeof t)return!1;if(Array.isArray(t)){for(let e=0,s=t.length;e <s;e++)if(Q(t[e]))return!0;return!1}if(G(t))return!0;if(t.toJSON&&"function"==ty peof t.toJSON&&1===arguments.length)return Q(t.toJSON(),!0);for(const e in t)if( Object.prototype.hasOwnProperty.call(t,e)&&Q(t[e]))return!0;return!1}function Z( t){const e=[],s=t.data,n=t;return n.data=tt(s,e),n.attachments=e.length,{packet: n,buffers:e}}function tt(t,e){if(!t)return t;if(G(t)){const s={_placeholder:!0,n um:e.length};return e.push(t),s}if(Array.isArray(t)){const s=new Array(t.length) ;for(let n=0;n<t.length;n++)s[n]=tt(t[n],e);return s}if("object"==typeof t&&!(t instanceof Date)){const s={};for(const n in t)Object.prototype.hasOwnProperty.ca ll(t,n)&&(s[n]=tt(t[n],e));return s}return t}function et(t,e){return t.data=st(t .data,e),t.attachments=void 0,t}function st(t,e){if(!t)return t;if(t&&t._placeho lder)return e[t.num];if(Array.isArray(t))for(let s=0;s<t.length;s++)t[s]=st(t[s] ,e);else if("object"==typeof t)for(const s in t)Object.prototype.hasOwnProperty. call(t,s)&&(t[s]=st(t[s],e));return t}const nt=5;var it;!function(t){t[t.CONNECT =0]="CONNECT",t[t.DISCONNECT=1]="DISCONNECT",t[t.EVENT=2]="EVENT",t[t.ACK=3]="AC K",t[t.CONNECT_ERROR=4]="CONNECT_ERROR",t[t.BINARY_EVENT=5]="BINARY_EVENT",t[t.B INARY_ACK=6]="BINARY_ACK"}(it||(it={}));class rt extends y{constructor(t){super( ),this.reviver=t}add(t){let e;if("string"==typeof t)e=this.decodeString(t),e.typ e===it.BINARY_EVENT||e.type===it.BINARY_ACK?(this.reconstructor=new ot(e),0===e. attachments&&super.emitReserved("decoded",e)):super.emitReserved("decoded",e);el se{if(!G(t)&&!t.base64)throw new Error("Unknown type: "+t);if(!this.reconstructo r)throw new Error("got binary data when not reconstructing a packet");e=this.rec onstructor.takeBinaryData(t),e&&(this.reconstructor=null,super.emitReserved("dec oded",e))}}decodeString(t){let e=0;const s={type:Number(t.charAt(0))};if(void 0= ==it[s.type])throw new Error("unknown packet type "+s.type);if(s.type===it.BINAR Y_EVENT||s.type===it.BINARY_ACK){const n=e+1;for(;"-"!==t.charAt(++e)&&e!=t.leng th;);const i=t.substring(n,e);if(i!=Number(i)||"-"!==t.charAt(e))throw new Error ("Illegal attachments");s.attachments=Number(i)}if("/"===t.charAt(e+1)){const n= e+1;for(;++e;){if(","===t.charAt(e))break;if(e===t.length)break}s.nsp=t.substrin g(n,e)}else s.nsp="/";const n=t.charAt(e+1);if(""!==n&&Number(n)==n){const n=e+1 ;for(;++e;){const s=t.charAt(e);if(null==s||Number(s)!=s){--e;break}if(e===t.len gth)break}s.id=Number(t.substring(n,e+1))}if(t.charAt(++e)){const n=this.tryPars e(t.substr(e));if(!rt.isPayloadValid(s.type,n))throw new Error("invalid payload" );s.data=n}return s}tryParse(t){try{return JSON.parse(t,this.reviver)}catch(t){r eturn!1}}static isPayloadValid(t,e){switch(t){case it.CONNECT:return"object"==ty peof e;case it.DISCONNECT:return void 0===e;case it.CONNECT_ERROR:return"string" ==typeof e||"object"==typeof e;case it.EVENT:case it.BINARY_EVENT:return Array.i sArray(e)&&e.length>0;case it.ACK:case it.BINARY_ACK:return Array.isArray(e)}}de stroy(){this.reconstructor&&this.reconstructor.finishedReconstruction()}}class o t{constructor(t){this.packet=t,this.buffers=[],this.reconPack=t}takeBinaryData(t ){if(this.buffers.push(t),this.buffers.length===this.reconPack.attachments){cons t t=et(this.reconPack,this.buffers);return this.finishedReconstruction(),t}retur n null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}var at=Obje ct.freeze({__proto__:null,protocol:5,get PacketType(){return it},Encoder:class{c onstructor(t){this.replacer=t}encode(t){return t.type!==it.EVENT&&t.type!==it.AC K||!Q(t)?[this.encodeAsString(t)]:(t.type=t.type===it.EVENT?it.BINARY_EVENT:it.B INARY_ACK,this.encodeAsBinary(t))}encodeAsString(t){let e=""+t.type;return t.typ e!==it.BINARY_EVENT&&t.type!==it.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}encodeAsBinary(t){const e=Z(t),s=this.encodeAsString(e.pa cket),n=e.buffers;return n.unshift(s),n}},Decoder:rt});function ht(t,e,s){return t.on(e,s),function(){t.off(e,s)}}const ct=Object.freeze({connect:1,connect_erro r:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class pt exten ds y{constructor(t,e,s){super(),this.connected=!1,this.receiveBuffer=[],this.sen dBuffer=[],this.ids=0,this.acks={},this.flags={},this.io=t,this.nsp=e,s&&s.auth& &(this.auth=s.auth),this.io._autoConnect&&this.open()}get disconnected(){return! this.connected}subEvents(){if(this.subs)return;const t=this.io;this.subs=[ht(t," open",this.onopen.bind(this)),ht(t,"packet",this.onpacket.bind(this)),ht(t,"erro r",this.onerror.bind(this)),ht(t,"close",this.onclose.bind(this))]}get active(){ return!!this.subs}connect(){return this.connected||(this.subEvents(),this.io._re connecting||this.io.open(),"open"===this.io._readyState&&this.onopen()),this}ope n(){return this.connect()}send(...t){return t.unshift("message"),this.emit.apply (this,t),this}emit(t,...e){if(ct.hasOwnProperty(t))throw new Error('"'+t+'" is a reserved event name');e.unshift(t);const s={type:it.EVENT,data:e,options:{}};if (s.options.compress=!1!==this.flags.compress,"function"==typeof e[e.length-1]){c onst t=this.ids++,n=e.pop();this._registerAckCallback(t,n),s.id=t}const n=this.i o.engine&&this.io.engine.transport&&this.io.engine.transport.writable;return thi s.flags.volatile&&(!n||!this.connected)||(this.connected?(this.notifyOutgoingLis teners(s),this.packet(s)):this.sendBuffer.push(s)),this.flags={},this}_registerA ckCallback(t,e){const s=this.flags.timeout;if(void 0===s)return void(this.acks[t ]=e);const n=this.io.setTimeoutFn((()=>{delete this.acks[t];for(let e=0;e<this.s endBuffer.length;e++)this.sendBuffer[e].id===t&&this.sendBuffer.splice(e,1);e.ca ll(this,new Error("operation has timed out"))}),s);this.acks[t]=(...t)=>{this.io .clearTimeoutFn(n),e.apply(this,[null,...t])}}packet(t){t.nsp=this.nsp,this.io._ packet(t)}onopen(){"function"==typeof this.auth?this.auth((t=>{this.packet({type :it.CONNECT,data:t})})):this.packet({type:it.CONNECT,data:this.auth})}onerror(t) {this.connected||this.emitReserved("connect_error",t)}onclose(t,e){this.connecte d=!1,delete this.id,this.emitReserved("disconnect",t,e)}onpacket(t){if(t.nsp===t his.nsp)switch(t.type){case it.CONNECT:if(t.data&&t.data.sid){const e=t.data.sid ;this.onconnect(e)}else this.emitReserved("connect_error",new Error("It seems yo u are trying to reach a Socket.IO server in v2.x with a v3.x client, but they ar e not compatible (more information here: https://socket.io/docs/v3/migrating-fro m-2-x-to-3-0/)"));break;case it.EVENT:case it.BINARY_EVENT:this.onevent(t);break ;case it.ACK:case it.BINARY_ACK:this.onack(t);break;case it.DISCONNECT:this.ondi sconnect();break;case it.CONNECT_ERROR:this.destroy();const e=new Error(t.data.m essage);e.data=t.data.data,this.emitReserved("connect_error",e)}}onevent(t){cons t e=t.data||[];null!=t.id&&e.push(this.ack(t.id)),this.connected?this.emitEvent( e):this.receiveBuffer.push(Object.freeze(e))}emitEvent(t){if(this._anyListeners& &this._anyListeners.length){const e=this._anyListeners.slice();for(const s of e) s.apply(this,t)}super.emit.apply(this,t)}ack(t){const e=this;let s=!1;return fun ction(...n){s||(s=!0,e.packet({type:it.ACK,id:t,data:n}))}}onack(t){const e=this .acks[t.id];"function"==typeof e&&(e.apply(this,t.data),delete this.acks[t.id])} onconnect(t){this.id=t,this.connected=!0,this.emitBuffered(),this.emitReserved(" connect")}emitBuffered(){this.receiveBuffer.forEach((t=>this.emitEvent(t))),this .receiveBuffer=[],this.sendBuffer.forEach((t=>{this.notifyOutgoingListeners(t),t his.packet(t)})),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose(" io server disconnect")}destroy(){this.subs&&(this.subs.forEach((t=>t())),this.su bs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packe t({type:it.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client d isconnect"),this}close(){return this.disconnect()}compress(t){return this.flags. compress=t,this}get volatile(){return this.flags.volatile=!0,this}timeout(t){ret urn this.flags.timeout=t,this}onAny(t){return this._anyListeners=this._anyListen ers||[],this._anyListeners.push(t),this}prependAny(t){return this._anyListeners= this._anyListeners||[],this._anyListeners.unshift(t),this}offAny(t){if(!this._an yListeners)return this;if(t){const e=this._anyListeners;for(let s=0;s<e.length;s ++)if(t===e[s])return e.splice(s,1),this}else this._anyListeners=[];return this} listenersAny(){return this._anyListeners||[]}onAnyOutgoing(t){return this._anyOu tgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(t ),this}prependAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoing Listeners||[],this._anyOutgoingListeners.unshift(t),this}offAnyOutgoing(t){if(!t his._anyOutgoingListeners)return this;if(t){const e=this._anyOutgoingListeners;f or(let s=0;s<e.length;s++)if(t===e[s])return e.splice(s,1),this}else this._anyOu tgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingLi steners||[]}notifyOutgoingListeners(t){if(this._anyOutgoingListeners&&this._anyO utgoingListeners.length){const e=this._anyOutgoingListeners.slice();for(const s of e)s.apply(this,t.data)}}}function ut(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}ut.prototype.duration=function(){var t=this.ms*Math.pow(this.fa ctor,this.attempts++);if(this.jitter){var e=Math.random(),s=Math.floor(e*this.ji tter*t);t=0==(1&Math.floor(10*e))?t-s:t+s}return 0|Math.min(t,this.max)},ut.prot otype.reset=function(){this.attempts=0},ut.prototype.setMin=function(t){this.ms= t},ut.prototype.setMax=function(t){this.max=t},ut.prototype.setJitter=function(t ){this.jitter=t};class lt extends y{constructor(t,e){var s;super(),this.nsps={}, this.subs=[],t&&"object"==typeof t&&(e=t,t=void 0),(e=e||{}).path=e.path||"/sock et.io",this.opts=e,k(this,e),this.reconnection(!1!==e.reconnection),this.reconne ctionAttempts(e.reconnectionAttempts||1/0),this.reconnectionDelay(e.reconnection Delay||1e3),this.reconnectionDelayMax(e.reconnectionDelayMax||5e3),this.randomiz ationFactor(null!==(s=e.randomizationFactor)&&void 0!==s?s:.5),this.backoff=new ut({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.ran domizationFactor()}),this.timeout(null==e.timeout?2e4:e.timeout),this._readyStat e="closed",this.uri=t;const n=e.parser||at;this.encoder=new n.Encoder,this.decod er=new n.Decoder,this._autoConnect=!1!==e.autoConnect,this._autoConnect&&this.op en()}reconnection(t){return arguments.length?(this._reconnection=!!t,this):this. _reconnection}reconnectionAttempts(t){return void 0===t?this._reconnectionAttemp ts:(this._reconnectionAttempts=t,this)}reconnectionDelay(t){var e;return void 0= ==t?this._reconnectionDelay:(this._reconnectionDelay=t,null===(e=this.backoff)|| void 0===e||e.setMin(t),this)}randomizationFactor(t){var e;return void 0===t?thi s._randomizationFactor:(this._randomizationFactor=t,null===(e=this.backoff)||voi d 0===e||e.setJitter(t),this)}reconnectionDelayMax(t){var e;return void 0===t?th is._reconnectionDelayMax:(this._reconnectionDelayMax=t,null===(e=this.backoff)|| void 0===e||e.setMax(t),this)}timeout(t){return arguments.length?(this._timeout= t,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnec tion&&0===this.backoff.attempts&&this.reconnect()}open(t){if(~this._readyState.i ndexOf("open"))return this;this.engine=new z(this.uri,this.opts);const e=this.en gine,s=this;this._readyState="opening",this.skipReconnect=!1;const n=ht(e,"open" ,(function(){s.onopen(),t&&t()})),i=ht(e,"error",(e=>{s.cleanup(),s._readyState= "closed",this.emitReserved("error",e),t?t(e):s.maybeReconnectOnOpen()}));if(!1!= =this._timeout){const t=this._timeout;0===t&&n();const s=this.setTimeoutFn((()=> {n(),e.close(),e.emit("error",new Error("timeout"))}),t);this.opts.autoUnref&&s. unref(),this.subs.push((function(){clearTimeout(s)}))}return this.subs.push(n),t his.subs.push(i),this}connect(t){return this.open(t)}onopen(){this.cleanup(),thi s._readyState="open",this.emitReserved("open");const t=this.engine;this.subs.pus h(ht(t,"ping",this.onping.bind(this)),ht(t,"data",this.ondata.bind(this)),ht(t," error",this.onerror.bind(this)),ht(t,"close",this.onclose.bind(this)),ht(this.de coder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}o ndata(t){this.decoder.add(t)}ondecoded(t){this.emitReserved("packet",t)}onerror( t){this.emitReserved("error",t)}socket(t,e){let s=this.nsps[t];return s||(s=new pt(this,t,e),this.nsps[t]=s),s}_destroy(t){const e=Object.keys(this.nsps);for(co nst t of e){if(this.nsps[t].active)return}this._close()}_packet(t){const e=this. encoder.encode(t);for(let s=0;s<e.length;s++)this.engine.write(e[s],t.options)}c leanup(){this.subs.forEach((t=>t())),this.subs.length=0,this.decoder.destroy()}_ close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close") ,this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(t,e) {this.cleanup(),this.backoff.reset(),this._readyState="closed",this.emitReserved ("close",t,e),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnec t(){if(this._reconnecting||this.skipReconnect)return this;const t=this;if(this.b ackoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserv ed("reconnect_failed"),this._reconnecting=!1;else{const e=this.backoff.duration( );this._reconnecting=!0;const s=this.setTimeoutFn((()=>{t.skipReconnect||(this.e mitReserved("reconnect_attempt",t.backoff.attempts),t.skipReconnect||t.open((e=> {e?(t._reconnecting=!1,t.reconnect(),this.emitReserved("reconnect_error",e)):t.o nreconnect()})))}),e);this.opts.autoUnref&&s.unref(),this.subs.push((function(){ clearTimeout(s)}))}}onreconnect(){const t=this.backoff.attempts;this._reconnecti ng=!1,this.backoff.reset(),this.emitReserved("reconnect",t)}}const dt={};functio n ft(t,e){"object"==typeof t&&(e=t,t=void 0);const s=function(t,e="",s){let n=t; s=s||"undefined"!=typeof location&&location,null==t&&(t=s.protocol+"//"+s.host), "string"==typeof t&&("/"===t.charAt(0)&&(t="/"===t.charAt(1)?s.protocol+t:s.host +t),/^(https?|wss?):\/\//.test(t)||(t=void 0!==s?s.protocol+"//"+t:"https://"+t) ,n=Y(t)),n.port||(/^(http|ws)$/.test(n.protocol)?n.port="80":/^(http|ws)s$/.test (n.protocol)&&(n.port="443")),n.path=n.path||"/";const i=-1!==n.host.indexOf(":" )?"["+n.host+"]":n.host;return n.id=n.protocol+"://"+i+":"+n.port+e,n.href=n.pro tocol+"://"+i+(s&&s.port===n.port?"":":"+n.port),n}(t,(e=e||{}).path||"/socket.i o"),n=s.source,i=s.id,r=s.path,o=dt[i]&&r in dt[i].nsps;let a;return e.forceNew| |e["force new connection"]||!1===e.multiplex||o?a=new lt(n,e):(dt[i]||(dt[i]=new lt(n,e)),a=dt[i]),s.query&&!e.query&&(e.query=s.queryKey),a.socket(s.path,e)}Ob ject.assign(ft,{Manager:lt,Socket:pt,io:ft,connect:ft});export{lt as Manager,pt as Socket,ft as connect,ft as default,ft as io,nt as protocol}; const t=Object.create(null);t.open="0",t.close="1",t.ping="2",t.pong="3",t.messa ge="4",t.upgrade="5",t.noop="6";const e=Object.create(null);Object.keys(t).forEa ch((s=>{e[t[s]]=s}));const s={type:"error",data:"parser error"},n="function"==ty peof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Object.prototy pe.toString.call(Blob),i="function"==typeof ArrayBuffer,r=({type:e,data:s},r,h)= >{return n&&s instanceof Blob?r?h(s):o(s,h):i&&(s instanceof ArrayBuffer||(a=s," function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(a):a&&a.buffer instanceo f ArrayBuffer))?r?h(s):o(new Blob([s]),h):h(t[e]+(s||""));var a},o=(t,e)=>{const s=new FileReader;return s.onload=function(){const t=s.result.split(",")[1];e("b "+t)},s.readAsDataURL(t)},h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxy z0123456789+/",a="undefined"==typeof Uint8Array?[]:new Uint8Array(256);for(let t =0;t<h.length;t++)a[h.charCodeAt(t)]=t;const c="function"==typeof ArrayBuffer,p= (t,n)=>{if("string"!=typeof t)return{type:"message",data:l(t,n)};const i=t.charA t(0);if("b"===i)return{type:"message",data:u(t.substring(1),n)};return e[i]?t.le ngth>1?{type:e[i],data:t.substring(1)}:{type:e[i]}:s},u=(t,e)=>{if(c){const s=(t =>{let e,s,n,i,r,o=.75*t.length,h=t.length,c=0;"="===t[t.length-1]&&(o--,"="===t [t.length-2]&&o--);const p=new ArrayBuffer(o),u=new Uint8Array(p);for(e=0;e<h;e+ =4)s=a[t.charCodeAt(e)],n=a[t.charCodeAt(e+1)],i=a[t.charCodeAt(e+2)],r=a[t.char CodeAt(e+3)],u[c++]=s<<2|n>>4,u[c++]=(15&n)<<4|i>>2,u[c++]=(3&i)<<6|63&r;return p})(t);return l(s,e)}return{base64:!0,data:t}},l=(t,e)=>"blob"===e&&t instanceof ArrayBuffer?new Blob([t]):t,d=String.fromCharCode(30);function f(t){if(t)return function(t){for(var e in f.prototype)t[e]=f.prototype[e];return t}(t)}f.prototy pe.on=f.prototype.addEventListener=function(t,e){return this._callbacks=this._ca llbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this},f. prototype.once=function(t,e){function s(){this.off(t,s),e.apply(this,arguments)} return s.fn=e,this.on(t,s),this},f.prototype.off=f.prototype.removeListener=f.pr ototype.removeAllListeners=f.prototype.removeEventListener=function(t,e){if(this ._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},th is;var s,n=this._callbacks["$"+t];if(!n)return this;if(1==arguments.length)retur n delete this._callbacks["$"+t],this;for(var i=0;i<n.length;i++)if((s=n[i])===e| |s.fn===e){n.splice(i,1);break}return 0===n.length&&delete this._callbacks["$"+t ],this},f.prototype.emit=function(t){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),s=this._callbacks["$"+t],n=1;n<arguments.length ;n++)e[n-1]=arguments[n];if(s){n=0;for(var i=(s=s.slice(0)).length;n<i;++n)s[n]. apply(this,e)}return this},f.prototype.emitReserved=f.prototype.emit,f.prototype .listeners=function(t){return this._callbacks=this._callbacks||{},this._callback s["$"+t]||[]},f.prototype.hasListeners=function(t){return!!this.listeners(t).len gth};const y="undefined"!=typeof self?self:"undefined"!=typeof window?window:Fun ction("return this")();function g(t,...e){return e.reduce(((e,s)=>(t.hasOwnPrope rty(s)&&(e[s]=t[s]),e)),{})}const m=setTimeout,b=clearTimeout;function v(t,e){e. useNativeTimers?(t.setTimeoutFn=m.bind(y),t.clearTimeoutFn=b.bind(y)):(t.setTime outFn=setTimeout.bind(y),t.clearTimeoutFn=clearTimeout.bind(y))}class k extends Error{constructor(t,e,s){super(t),this.description=e,this.context=s,this.type="T ransportError"}}class w extends f{constructor(t){super(),this.writable=!1,v(this ,t),this.opts=t,this.query=t.query,this.readyState="",this.socket=t.socket}onErr or(t,e,s){return super.emitReserved("error",new k(t,e,s)),this}open(){return"clo sed"!==this.readyState&&""!==this.readyState||(this.readyState="opening",this.do Open()),this}close(){return"opening"!==this.readyState&&"open"!==this.readyState ||(this.doClose(),this.onClose()),this}send(t){"open"===this.readyState&&this.wr ite(t)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open ")}onData(t){const e=p(t,this.socket.binaryType);this.onPacket(e)}onPacket(t){su per.emitReserved("packet",t)}onClose(t){this.readyState="closed",super.emitReser ved("close",t)}}const _="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrs tuvwxyz-_".split(""),E={};let A,R=0,O=0;function C(t){let e="";do{e=_[t%64]+e,t= Math.floor(t/64)}while(t>0);return e}function T(){const t=C(+new Date);return t! ==A?(R=0,A=t):t+"."+C(R++)}for(;O<64;O++)E[_[O]]=O;function B(t){let e="";for(le t s in t)t.hasOwnProperty(s)&&(e.length&&(e+="&"),e+=encodeURIComponent(s)+"="+e ncodeURIComponent(t[s]));return e}let N=!1;try{N="undefined"!=typeof XMLHttpRequ est&&"withCredentials"in new XMLHttpRequest}catch(t){}const x=N;function S(t){co nst e=t.xdomain;try{if("undefined"!=typeof XMLHttpRequest&&(!e||x))return new XM LHttpRequest}catch(t){}if(!e)try{return new(y[["Active"].concat("Object").join(" X")])("Microsoft.XMLHTTP")}catch(t){}}function L(){}const P=null!=new S({xdomain :!1}).responseType;class j extends f{constructor(t,e){super(),v(this,e),this.opt s=e,this.method=e.method||"GET",this.uri=t,this.async=!1!==e.async,this.data=voi d 0!==e.data?e.data:null,this.create()}create(){const t=g(this.opts,"agent","pfx ","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.x domain=!!this.opts.xd,t.xscheme=!!this.opts.xs;const e=this.xhr=new S(t);try{e.o pen(this.method,this.uri,this.async);try{if(this.opts.extraHeaders){e.setDisable HeaderCheck&&e.setDisableHeaderCheck(!0);for(let t in this.opts.extraHeaders)thi s.opts.extraHeaders.hasOwnProperty(t)&&e.setRequestHeader(t,this.opts.extraHeade rs[t])}}catch(t){}if("POST"===this.method)try{e.setRequestHeader("Content-type", "text/plain;charset=UTF-8")}catch(t){}try{e.setRequestHeader("Accept","*/*")}cat ch(t){}"withCredentials"in e&&(e.withCredentials=this.opts.withCredentials),this .opts.requestTimeout&&(e.timeout=this.opts.requestTimeout),e.onreadystatechange= ()=>{4===e.readyState&&(200===e.status||1223===e.status?this.onLoad():this.setTi meoutFn((()=>{this.onError("number"==typeof e.status?e.status:0)}),0))},e.send(t his.data)}catch(t){return void this.setTimeoutFn((()=>{this.onError(t)}),0)}"und efined"!=typeof document&&(this.index=j.requestsCount++,j.requests[this.index]=t his)}onError(t){this.emitReserved("error",t,this.xhr),this.cleanup(!0)}cleanup(t ){if(void 0!==this.xhr&&null!==this.xhr){if(this.xhr.onreadystatechange=L,t)try{ this.xhr.abort()}catch(t){}"undefined"!=typeof document&&delete j.requests[this. index],this.xhr=null}}onLoad(){const t=this.xhr.responseText;null!==t&&(this.emi tReserved("data",t),this.emitReserved("success"),this.cleanup())}abort(){this.cl eanup()}}if(j.requestsCount=0,j.requests={},"undefined"!=typeof document)if("fun ction"==typeof attachEvent)attachEvent("onunload",q);else if("function"==typeof addEventListener){addEventListener("onpagehide"in y?"pagehide":"unload",q,!1)}fu nction q(){for(let t in j.requests)j.requests.hasOwnProperty(t)&&j.requests[t].a bort()}const I="function"==typeof Promise&&"function"==typeof Promise.resolve?t= >Promise.resolve().then(t):(t,e)=>e(t,0),D=y.WebSocket||y.MozWebSocket,F="undefi ned"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navi gator.product.toLowerCase();const M={websocket:class extends w{constructor(t){su per(t),this.supportsBinary=!t.forceBase64}get name(){return"websocket"}doOpen(){ if(!this.check())return;const t=this.uri(),e=this.opts.protocols,s=F?{}:g(this.o pts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers"," rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","fami ly","checkServerIdentity");this.opts.extraHeaders&&(s.headers=this.opts.extraHea ders);try{this.ws=F?new D(t,e,s):e?new D(t,e):new D(t)}catch(t){return this.emit Reserved("error",t)}this.ws.binaryType=this.socket.binaryType||"arraybuffer",thi s.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnre f&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=t=>this.onClose({descr iption:"websocket connection closed",context:t}),this.ws.onmessage=t=>this.onDat a(t.data),this.ws.onerror=t=>this.onError("websocket error",t)}write(t){this.wri table=!1;for(let e=0;e<t.length;e++){const s=t[e],n=e===t.length-1;r(s,this.supp ortsBinary,(t=>{try{this.ws.send(t)}catch(t){}n&&I((()=>{this.writable=!0,this.e mitReserved("drain")}),this.setTimeoutFn)}))}}doClose(){void 0!==this.ws&&(this. ws.close(),this.ws=null)}uri(){let t=this.query||{};const e=this.opts.secure?"ws s":"ws";let s="";this.opts.port&&("wss"===e&&443!==Number(this.opts.port)||"ws"= ==e&&80!==Number(this.opts.port))&&(s=":"+this.opts.port),this.opts.timestampReq uests&&(t[this.opts.timestampParam]=T()),this.supportsBinary||(t.b64=1);const n= B(t);return e+"://"+(-1!==this.opts.hostname.indexOf(":")?"["+this.opts.hostname +"]":this.opts.hostname)+s+this.opts.path+(n.length?"?"+n:"")}check(){return!!D} },polling:class extends w{constructor(t){if(super(t),this.polling=!1,"undefined" !=typeof location){const e="https:"===location.protocol;let s=location.port;s||( s=e?"443":"80"),this.xd="undefined"!=typeof location&&t.hostname!==location.host name||s!==t.port,this.xs=t.secure!==e}const e=t&&t.forceBase64;this.supportsBina ry=P&&!e}get name(){return"polling"}doOpen(){this.poll()}pause(t){this.readyStat e="pausing";const e=()=>{this.readyState="paused",t()};if(this.polling||!this.wr itable){let t=0;this.polling&&(t++,this.once("pollComplete",(function(){--t||e() }))),this.writable||(t++,this.once("drain",(function(){--t||e()})))}else e()}pol l(){this.polling=!0,this.doPoll(),this.emitReserved("poll")}onData(t){((t,e)=>{c onst s=t.split(d),n=[];for(let t=0;t<s.length;t++){const i=p(s[t],e);if(n.push(i ),"error"===i.type)break}return n})(t,this.socket.binaryType).forEach((t=>{if("o pening"===this.readyState&&"open"===t.type&&this.onOpen(),"close"===t.type)retur n this.onClose({description:"transport closed by the server"}),!1;this.onPacket( t)})),"closed"!==this.readyState&&(this.polling=!1,this.emitReserved("pollComple te"),"open"===this.readyState&&this.poll())}doClose(){const t=()=>{this.write([{ type:"close"}])};"open"===this.readyState?t():this.once("open",t)}write(t){this. writable=!1,((t,e)=>{const s=t.length,n=new Array(s);let i=0;t.forEach(((t,o)=>{ r(t,!1,(t=>{n[o]=t,++i===s&&e(n.join(d))}))}))})(t,(t=>{this.doWrite(t,(()=>{thi s.writable=!0,this.emitReserved("drain")}))}))}uri(){let t=this.query||{};const e=this.opts.secure?"https":"http";let s="";!1!==this.opts.timestampRequests&&(t[ this.opts.timestampParam]=T()),this.supportsBinary||t.sid||(t.b64=1),this.opts.p ort&&("https"===e&&443!==Number(this.opts.port)||"http"===e&&80!==Number(this.op ts.port))&&(s=":"+this.opts.port);const n=B(t);return e+"://"+(-1!==this.opts.ho stname.indexOf(":")?"["+this.opts.hostname+"]":this.opts.hostname)+s+this.opts.p ath+(n.length?"?"+n:"")}request(t={}){return Object.assign(t,{xd:this.xd,xs:this .xs},this.opts),new j(this.uri(),t)}doWrite(t,e){const s=this.request({method:"P OST",data:t});s.on("success",e),s.on("error",((t,e)=>{this.onError("xhr post err or",t,e)}))}doPoll(){const t=this.request();t.on("data",this.onData.bind(this)), t.on("error",((t,e)=>{this.onError("xhr poll error",t,e)})),this.pollXhr=t}}},U= /^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)? @)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![ ^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,V=["so urce","protocol","authority","userInfo","user","password","host","port","relativ e","path","directory","file","query","anchor"];function H(t){const e=t,s=t.index Of("["),n=t.indexOf("]");-1!=s&&-1!=n&&(t=t.substring(0,s)+t.substring(s,n).repl ace(/:/g,";")+t.substring(n,t.length));let i=U.exec(t||""),r={},o=14;for(;o--;)r [V[o]]=i[o]||"";return-1!=s&&-1!=n&&(r.source=e,r.host=r.host.substring(1,r.host .length-1).replace(/;/g,":"),r.authority=r.authority.replace("[","").replace("]" ,"").replace(/;/g,":"),r.ipv6uri=!0),r.pathNames=function(t,e){const s=/\/{2,9}/ g,n=e.replace(s,"/").split("/");"/"!=e.substr(0,1)&&0!==e.length||n.splice(0,1); "/"==e.substr(e.length-1,1)&&n.splice(n.length-1,1);return n}(0,r.path),r.queryK ey=function(t,e){const s={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,(functi on(t,e,n){e&&(s[e]=n)})),s}(0,r.query),r}class K extends f{constructor(t,e={}){s uper(),t&&"object"==typeof t&&(e=t,t=null),t?(t=H(t),e.hostname=t.host,e.secure= "https"===t.protocol||"wss"===t.protocol,e.port=t.port,t.query&&(e.query=t.query )):e.host&&(e.hostname=H(e.host).host),v(this,e),this.secure=null!=e.secure?e.se cure:"undefined"!=typeof location&&"https:"===location.protocol,e.hostname&&!e.p ort&&(e.port=this.secure?"443":"80"),this.hostname=e.hostname||("undefined"!=typ eof location?location.hostname:"localhost"),this.port=e.port||("undefined"!=type of location&&location.port?location.port:this.secure?"443":"80"),this.transports =e.transports||["polling","websocket"],this.readyState="",this.writeBuffer=[],th is.prevBufferLen=0,this.opts=Object.assign({path:"/engine.io",agent:!1,withCrede ntials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,rejectUnauthorized:!0 ,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!0}, e),this.opts.path=this.opts.path.replace(/\/$/,"")+"/","string"==typeof this.opt s.query&&(this.opts.query=function(t){let e={},s=t.split("&");for(let t=0,n=s.le ngth;t<n;t++){let n=s[t].split("=");e[decodeURIComponent(n[0])]=decodeURICompone nt(n[1])}return e}(this.opts.query)),this.id=null,this.upgrades=null,this.pingIn terval=null,this.pingTimeout=null,this.pingTimeoutTimer=null,"function"==typeof addEventListener&&(this.opts.closeOnBeforeunload&&addEventListener("beforeunload ",(()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.clos e())}),!1),"localhost"!==this.hostname&&(this.offlineEventListener=()=>{this.onC lose("transport close",{description:"network connection lost"})},addEventListene r("offline",this.offlineEventListener,!1))),this.open()}createTransport(t){const e=Object.assign({},this.opts.query);e.EIO=4,e.transport=t,this.id&&(e.sid=this. id);const s=Object.assign({},this.opts.transportOptions[t],this.opts,{query:e,so cket:this,hostname:this.hostname,secure:this.secure,port:this.port});return new M[t](s)}open(){let t;if(this.opts.rememberUpgrade&&K.priorWebsocketSuccess&&-1!= =this.transports.indexOf("websocket"))t="websocket";else{if(0===this.transports. length)return void this.setTimeoutFn((()=>{this.emitReserved("error","No transpo rts available")}),0);t=this.transports[0]}this.readyState="opening";try{t=this.c reateTransport(t)}catch(t){return this.transports.shift(),void this.open()}t.ope n(),this.setTransport(t)}setTransport(t){this.transport&&this.transport.removeAl lListeners(),this.transport=t,t.on("drain",this.onDrain.bind(this)).on("packet", this.onPacket.bind(this)).on("error",this.onError.bind(this)).on("close",(t=>thi s.onClose("transport close",t)))}probe(t){let e=this.createTransport(t),s=!1;K.p riorWebsocketSuccess=!1;const n=()=>{s||(e.send([{type:"ping",data:"probe"}]),e. once("packet",(t=>{if(!s)if("pong"===t.type&&"probe"===t.data){if(this.upgrading =!0,this.emitReserved("upgrading",e),!e)return;K.priorWebsocketSuccess="websocke t"===e.name,this.transport.pause((()=>{s||"closed"!==this.readyState&&(c(),this. setTransport(e),e.send([{type:"upgrade"}]),this.emitReserved("upgrade",e),e=null ,this.upgrading=!1,this.flush())}))}else{const t=new Error("probe error");t.tran sport=e.name,this.emitReserved("upgradeError",t)}})))};function i(){s||(s=!0,c() ,e.close(),e=null)}const r=t=>{const s=new Error("probe error: "+t);s.transport= e.name,i(),this.emitReserved("upgradeError",s)};function o(){r("transport closed ")}function h(){r("socket closed")}function a(t){e&&t.name!==e.name&&i()}const c =()=>{e.removeListener("open",n),e.removeListener("error",r),e.removeListener("c lose",o),this.off("close",h),this.off("upgrading",a)};e.once("open",n),e.once("e rror",r),e.once("close",o),this.once("close",h),this.once("upgrading",a),e.open( )}onOpen(){if(this.readyState="open",K.priorWebsocketSuccess="websocket"===this. transport.name,this.emitReserved("open"),this.flush(),"open"===this.readyState&& this.opts.upgrade&&this.transport.pause){let t=0;const e=this.upgrades.length;fo r(;t<e;t++)this.probe(this.upgrades[t])}}onPacket(t){if("opening"===this.readySt ate||"open"===this.readyState||"closing"===this.readyState)switch(this.emitReser ved("packet",t),this.emitReserved("heartbeat"),t.type){case"open":this.onHandsha ke(JSON.parse(t.data));break;case"ping":this.resetPingTimeout(),this.sendPacket( "pong"),this.emitReserved("ping"),this.emitReserved("pong");break;case"error":co nst e=new Error("server error");e.code=t.data,this.onError(e);break;case"message ":this.emitReserved("data",t.data),this.emitReserved("message",t.data)}}onHandsh ake(t){this.emitReserved("handshake",t),this.id=t.sid,this.transport.query.sid=t .sid,this.upgrades=this.filterUpgrades(t.upgrades),this.pingInterval=t.pingInter val,this.pingTimeout=t.pingTimeout,this.maxPayload=t.maxPayload,this.onOpen(),"c losed"!==this.readyState&&this.resetPingTimeout()}resetPingTimeout(){this.clearT imeoutFn(this.pingTimeoutTimer),this.pingTimeoutTimer=this.setTimeoutFn((()=>{th is.onClose("ping timeout")}),this.pingInterval+this.pingTimeout),this.opts.autoU nref&&this.pingTimeoutTimer.unref()}onDrain(){this.writeBuffer.splice(0,this.pre vBufferLen),this.prevBufferLen=0,0===this.writeBuffer.length?this.emitReserved(" drain"):this.flush()}flush(){if("closed"!==this.readyState&&this.transport.writa ble&&!this.upgrading&&this.writeBuffer.length){const t=this.getWritablePackets() ;this.transport.send(t),this.prevBufferLen=t.length,this.emitReserved("flush")}} getWritablePackets(){if(!(this.maxPayload&&"polling"===this.transport.name&&this .writeBuffer.length>1))return this.writeBuffer;let t=1;for(let s=0;s<this.writeB uffer.length;s++){const n=this.writeBuffer[s].data;if(n&&(t+="string"==typeof(e= n)?function(t){let e=0,s=0;for(let n=0,i=t.length;n<i;n++)e=t.charCodeAt(n),e<12 8?s+=1:e<2048?s+=2:e<55296||e>=57344?s+=3:(n++,s+=4);return s}(e):Math.ceil(1.33 *(e.byteLength||e.size))),s>0&&t>this.maxPayload)return this.writeBuffer.slice(0 ,s);t+=2}var e;return this.writeBuffer}write(t,e,s){return this.sendPacket("mess age",t,e,s),this}send(t,e,s){return this.sendPacket("message",t,e,s),this}sendPa cket(t,e,s,n){if("function"==typeof e&&(n=e,e=void 0),"function"==typeof s&&(n=s ,s=null),"closing"===this.readyState||"closed"===this.readyState)return;(s=s||{} ).compress=!1!==s.compress;const i={type:t,data:e,options:s};this.emitReserved(" packetCreate",i),this.writeBuffer.push(i),n&&this.once("flush",n),this.flush()}c lose(){const t=()=>{this.onClose("forced close"),this.transport.close()},e=()=>{ this.off("upgrade",e),this.off("upgradeError",e),t()},s=()=>{this.once("upgrade" ,e),this.once("upgradeError",e)};return"opening"!==this.readyState&&"open"!==thi s.readyState||(this.readyState="closing",this.writeBuffer.length?this.once("drai n",(()=>{this.upgrading?s():t()})):this.upgrading?s():t()),this}onError(t){K.pri orWebsocketSuccess=!1,this.emitReserved("error",t),this.onClose("transport error ",t)}onClose(t,e){"opening"!==this.readyState&&"open"!==this.readyState&&"closin g"!==this.readyState||(this.clearTimeoutFn(this.pingTimeoutTimer),this.transport .removeAllListeners("close"),this.transport.close(),this.transport.removeAllList eners(),"function"==typeof removeEventListener&&removeEventListener("offline",th is.offlineEventListener,!1),this.readyState="closed",this.id=null,this.emitReser ved("close",t,e),this.writeBuffer=[],this.prevBufferLen=0)}filterUpgrades(t){con st e=[];let s=0;const n=t.length;for(;s<n;s++)~this.transports.indexOf(t[s])&&e. push(t[s]);return e}}K.protocol=4;const Y="function"==typeof ArrayBuffer,z=Objec t.prototype.toString,W="function"==typeof Blob||"undefined"!=typeof Blob&&"[obje ct BlobConstructor]"===z.call(Blob),$="function"==typeof File||"undefined"!=type of File&&"[object FileConstructor]"===z.call(File);function J(t){return Y&&(t in stanceof ArrayBuffer||(t=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isVi ew(t):t.buffer instanceof ArrayBuffer)(t))||W&&t instanceof Blob||$&&t instanceo f File}function X(t,e){if(!t||"object"!=typeof t)return!1;if(Array.isArray(t)){f or(let e=0,s=t.length;e<s;e++)if(X(t[e]))return!0;return!1}if(J(t))return!0;if(t .toJSON&&"function"==typeof t.toJSON&&1===arguments.length)return X(t.toJSON(),! 0);for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e)&&X(t[e]))return !0;return!1}function G(t){const e=[],s=t.data,n=t;return n.data=Q(s,e),n.attachm ents=e.length,{packet:n,buffers:e}}function Q(t,e){if(!t)return t;if(J(t)){const s={_placeholder:!0,num:e.length};return e.push(t),s}if(Array.isArray(t)){const s=new Array(t.length);for(let n=0;n<t.length;n++)s[n]=Q(t[n],e);return s}if("obj ect"==typeof t&&!(t instanceof Date)){const s={};for(const n in t)Object.prototy pe.hasOwnProperty.call(t,n)&&(s[n]=Q(t[n],e));return s}return t}function Z(t,e){ return t.data=tt(t.data,e),t.attachments=void 0,t}function tt(t,e){if(!t)return t;if(t&&t._placeholder)return e[t.num];if(Array.isArray(t))for(let s=0;s<t.lengt h;s++)t[s]=tt(t[s],e);else if("object"==typeof t)for(const s in t)Object.prototy pe.hasOwnProperty.call(t,s)&&(t[s]=tt(t[s],e));return t}const et=5;var st;!funct ion(t){t[t.CONNECT=0]="CONNECT",t[t.DISCONNECT=1]="DISCONNECT",t[t.EVENT=2]="EVE NT",t[t.ACK=3]="ACK",t[t.CONNECT_ERROR=4]="CONNECT_ERROR",t[t.BINARY_EVENT=5]="B INARY_EVENT",t[t.BINARY_ACK=6]="BINARY_ACK"}(st||(st={}));class nt extends f{con structor(t){super(),this.reviver=t}add(t){let e;if("string"==typeof t)e=this.dec odeString(t),e.type===st.BINARY_EVENT||e.type===st.BINARY_ACK?(this.reconstructo r=new it(e),0===e.attachments&&super.emitReserved("decoded",e)):super.emitReserv ed("decoded",e);else{if(!J(t)&&!t.base64)throw new Error("Unknown type: "+t);if( !this.reconstructor)throw new Error("got binary data when not reconstructing a p acket");e=this.reconstructor.takeBinaryData(t),e&&(this.reconstructor=null,super .emitReserved("decoded",e))}}decodeString(t){let e=0;const s={type:Number(t.char At(0))};if(void 0===st[s.type])throw new Error("unknown packet type "+s.type);if (s.type===st.BINARY_EVENT||s.type===st.BINARY_ACK){const n=e+1;for(;"-"!==t.char At(++e)&&e!=t.length;);const i=t.substring(n,e);if(i!=Number(i)||"-"!==t.charAt( e))throw new Error("Illegal attachments");s.attachments=Number(i)}if("/"===t.cha rAt(e+1)){const n=e+1;for(;++e;){if(","===t.charAt(e))break;if(e===t.length)brea k}s.nsp=t.substring(n,e)}else s.nsp="/";const n=t.charAt(e+1);if(""!==n&&Number( n)==n){const n=e+1;for(;++e;){const s=t.charAt(e);if(null==s||Number(s)!=s){--e; break}if(e===t.length)break}s.id=Number(t.substring(n,e+1))}if(t.charAt(++e)){co nst n=this.tryParse(t.substr(e));if(!nt.isPayloadValid(s.type,n))throw new Error ("invalid payload");s.data=n}return s}tryParse(t){try{return JSON.parse(t,this.r eviver)}catch(t){return!1}}static isPayloadValid(t,e){switch(t){case st.CONNECT: return"object"==typeof e;case st.DISCONNECT:return void 0===e;case st.CONNECT_ER ROR:return"string"==typeof e||"object"==typeof e;case st.EVENT:case st.BINARY_EV ENT:return Array.isArray(e)&&e.length>0;case st.ACK:case st.BINARY_ACK:return Ar ray.isArray(e)}}destroy(){this.reconstructor&&this.reconstructor.finishedReconst ruction()}}class it{constructor(t){this.packet=t,this.buffers=[],this.reconPack= t}takeBinaryData(t){if(this.buffers.push(t),this.buffers.length===this.reconPack .attachments){const t=Z(this.reconPack,this.buffers);return this.finishedReconst ruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffer s=[]}}var rt=Object.freeze({__proto__:null,protocol:5,get PacketType(){return st },Encoder:class{constructor(t){this.replacer=t}encode(t){return t.type!==st.EVEN T&&t.type!==st.ACK||!X(t)?[this.encodeAsString(t)]:(t.type=t.type===st.EVENT?st. BINARY_EVENT:st.BINARY_ACK,this.encodeAsBinary(t))}encodeAsString(t){let e=""+t. type;return t.type!==st.BINARY_EVENT&&t.type!==st.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}encodeAsBinary(t){const e=G(t),s=this.en codeAsString(e.packet),n=e.buffers;return n.unshift(s),n}},Decoder:nt});function ot(t,e,s){return t.on(e,s),function(){t.off(e,s)}}const ht=Object.freeze({conne ct:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1 });class at extends f{constructor(t,e,s){super(),this.connected=!1,this.receiveB uffer=[],this.sendBuffer=[],this.ids=0,this.acks={},this.flags={},this.io=t,this .nsp=e,s&&s.auth&&(this.auth=s.auth),this.io._autoConnect&&this.open()}get disco nnected(){return!this.connected}subEvents(){if(this.subs)return;const t=this.io; this.subs=[ot(t,"open",this.onopen.bind(this)),ot(t,"packet",this.onpacket.bind( this)),ot(t,"error",this.onerror.bind(this)),ot(t,"close",this.onclose.bind(this ))]}get active(){return!!this.subs}connect(){return this.connected||(this.subEve nts(),this.io._reconnecting||this.io.open(),"open"===this.io._readyState&&this.o nopen()),this}open(){return this.connect()}send(...t){return t.unshift("message" ),this.emit.apply(this,t),this}emit(t,...e){if(ht.hasOwnProperty(t))throw new Er ror('"'+t.toString()+'" is a reserved event name');e.unshift(t);const s={type:st .EVENT,data:e,options:{}};if(s.options.compress=!1!==this.flags.compress,"functi on"==typeof e[e.length-1]){const t=this.ids++,n=e.pop();this._registerAckCallbac k(t,n),s.id=t}const n=this.io.engine&&this.io.engine.transport&&this.io.engine.t ransport.writable;return this.flags.volatile&&(!n||!this.connected)||(this.conne cted?(this.notifyOutgoingListeners(s),this.packet(s)):this.sendBuffer.push(s)),t his.flags={},this}_registerAckCallback(t,e){const s=this.flags.timeout;if(void 0 ===s)return void(this.acks[t]=e);const n=this.io.setTimeoutFn((()=>{delete this. acks[t];for(let e=0;e<this.sendBuffer.length;e++)this.sendBuffer[e].id===t&&this .sendBuffer.splice(e,1);e.call(this,new Error("operation has timed out"))}),s);t his.acks[t]=(...t)=>{this.io.clearTimeoutFn(n),e.apply(this,[null,...t])}}packet (t){t.nsp=this.nsp,this.io._packet(t)}onopen(){"function"==typeof this.auth?this .auth((t=>{this.packet({type:st.CONNECT,data:t})})):this.packet({type:st.CONNECT ,data:this.auth})}onerror(t){this.connected||this.emitReserved("connect_error",t )}onclose(t,e){this.connected=!1,delete this.id,this.emitReserved("disconnect",t ,e)}onpacket(t){if(t.nsp===this.nsp)switch(t.type){case st.CONNECT:if(t.data&&t. data.sid){const e=t.data.sid;this.onconnect(e)}else this.emitReserved("connect_e rror",new Error("It seems you are trying to reach a Socket.IO server in v2.x wit h a v3.x client, but they are not compatible (more information here: https://soc ket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case st.EVENT:case st.BINARY _EVENT:this.onevent(t);break;case st.ACK:case st.BINARY_ACK:this.onack(t);break; case st.DISCONNECT:this.ondisconnect();break;case st.CONNECT_ERROR:this.destroy( );const e=new Error(t.data.message);e.data=t.data.data,this.emitReserved("connec t_error",e)}}onevent(t){const e=t.data||[];null!=t.id&&e.push(this.ack(t.id)),th is.connected?this.emitEvent(e):this.receiveBuffer.push(Object.freeze(e))}emitEve nt(t){if(this._anyListeners&&this._anyListeners.length){const e=this._anyListene rs.slice();for(const s of e)s.apply(this,t)}super.emit.apply(this,t)}ack(t){cons t e=this;let s=!1;return function(...n){s||(s=!0,e.packet({type:st.ACK,id:t,data :n}))}}onack(t){const e=this.acks[t.id];"function"==typeof e&&(e.apply(this,t.da ta),delete this.acks[t.id])}onconnect(t){this.id=t,this.connected=!0,this.emitBu ffered(),this.emitReserved("connect")}emitBuffered(){this.receiveBuffer.forEach( (t=>this.emitEvent(t))),this.receiveBuffer=[],this.sendBuffer.forEach((t=>{this. notifyOutgoingListeners(t),this.packet(t)})),this.sendBuffer=[]}ondisconnect(){t his.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.su bs.forEach((t=>t())),this.subs=void 0),this.io._destroy(this)}disconnect(){retur n this.connected&&this.packet({type:st.DISCONNECT}),this.destroy(),this.connecte d&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}co mpress(t){return this.flags.compress=t,this}get volatile(){return this.flags.vol atile=!0,this}timeout(t){return this.flags.timeout=t,this}onAny(t){return this._ anyListeners=this._anyListeners||[],this._anyListeners.push(t),this}prependAny(t ){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(t) ,this}offAny(t){if(!this._anyListeners)return this;if(t){const e=this._anyListen ers;for(let s=0;s<e.length;s++)if(t===e[s])return e.splice(s,1),this}else this._ anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOu tgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this. _anyOutgoingListeners.push(t),this}prependAnyOutgoing(t){return this._anyOutgoin gListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(t), this}offAnyOutgoing(t){if(!this._anyOutgoingListeners)return this;if(t){const e= this._anyOutgoingListeners;for(let s=0;s<e.length;s++)if(t===e[s])return e.splic e(s,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing( ){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(t){if(this._anyO utgoingListeners&&this._anyOutgoingListeners.length){const e=this._anyOutgoingLi steners.slice();for(const s of e)s.apply(this,t.data)}}}function ct(t){t=t||{},t his.ms=t.min||100,this.max=t.max||1e4,this.factor=t.factor||2,this.jitter=t.jitt er>0&&t.jitter<=1?t.jitter:0,this.attempts=0}ct.prototype.duration=function(){va r t=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.ran dom(),s=Math.floor(e*this.jitter*t);t=0==(1&Math.floor(10*e))?t-s:t+s}return 0|M ath.min(t,this.max)},ct.prototype.reset=function(){this.attempts=0},ct.prototype .setMin=function(t){this.ms=t},ct.prototype.setMax=function(t){this.max=t},ct.pr ototype.setJitter=function(t){this.jitter=t};class pt extends f{constructor(t,e) {var s;super(),this.nsps={},this.subs=[],t&&"object"==typeof t&&(e=t,t=void 0),( e=e||{}).path=e.path||"/socket.io",this.opts=e,v(this,e),this.reconnection(!1!== e.reconnection),this.reconnectionAttempts(e.reconnectionAttempts||1/0),this.reco nnectionDelay(e.reconnectionDelay||1e3),this.reconnectionDelayMax(e.reconnection DelayMax||5e3),this.randomizationFactor(null!==(s=e.randomizationFactor)&&void 0 !==s?s:.5),this.backoff=new ct({min:this.reconnectionDelay(),max:this.reconnecti onDelayMax(),jitter:this.randomizationFactor()}),this.timeout(null==e.timeout?2e 4:e.timeout),this._readyState="closed",this.uri=t;const n=e.parser||rt;this.enco der=new n.Encoder,this.decoder=new n.Decoder,this._autoConnect=!1!==e.autoConnec t,this._autoConnect&&this.open()}reconnection(t){return arguments.length?(this._ reconnection=!!t,this):this._reconnection}reconnectionAttempts(t){return void 0= ==t?this._reconnectionAttempts:(this._reconnectionAttempts=t,this)}reconnectionD elay(t){var e;return void 0===t?this._reconnectionDelay:(this._reconnectionDelay =t,null===(e=this.backoff)||void 0===e||e.setMin(t),this)}randomizationFactor(t) {var e;return void 0===t?this._randomizationFactor:(this._randomizationFactor=t, null===(e=this.backoff)||void 0===e||e.setJitter(t),this)}reconnectionDelayMax(t ){var e;return void 0===t?this._reconnectionDelayMax:(this._reconnectionDelayMax =t,null===(e=this.backoff)||void 0===e||e.setMax(t),this)}timeout(t){return argu ments.length?(this._timeout=t,this):this._timeout}maybeReconnectOnOpen(){!this._ reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()}op en(t){if(~this._readyState.indexOf("open"))return this;this.engine=new K(this.ur i,this.opts);const e=this.engine,s=this;this._readyState="opening",this.skipReco nnect=!1;const n=ot(e,"open",(function(){s.onopen(),t&&t()})),i=ot(e,"error",(e= >{s.cleanup(),s._readyState="closed",this.emitReserved("error",e),t?t(e):s.maybe ReconnectOnOpen()}));if(!1!==this._timeout){const t=this._timeout;0===t&&n();con st s=this.setTimeoutFn((()=>{n(),e.close(),e.emit("error",new Error("timeout"))} ),t);this.opts.autoUnref&&s.unref(),this.subs.push((function(){clearTimeout(s)}) )}return this.subs.push(n),this.subs.push(i),this}connect(t){return this.open(t) }onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const t=this.engine;this.subs.push(ot(t,"ping",this.onping.bind(this)),ot(t,"data",th is.ondata.bind(this)),ot(t,"error",this.onerror.bind(this)),ot(t,"close",this.on close.bind(this)),ot(this.decoder,"decoded",this.ondecoded.bind(this)))}onping() {this.emitReserved("ping")}ondata(t){try{this.decoder.add(t)}catch(t){this.onclo se("parse error")}}ondecoded(t){this.emitReserved("packet",t)}onerror(t){this.em itReserved("error",t)}socket(t,e){let s=this.nsps[t];return s||(s=new at(this,t, e),this.nsps[t]=s),s}_destroy(t){const e=Object.keys(this.nsps);for(const t of e ){if(this.nsps[t].active)return}this._close()}_packet(t){const e=this.encoder.en code(t);for(let s=0;s<e.length;s++)this.engine.write(e[s],t.options)}cleanup(){t his.subs.forEach((t=>t())),this.subs.length=0,this.decoder.destroy()}_close(){th is.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close"),this.engi ne&&this.engine.close()}disconnect(){return this._close()}onclose(t,e){this.clea nup(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",t ,e),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(thi s._reconnecting||this.skipReconnect)return this;const t=this;if(this.backoff.att empts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconn ect_failed"),this._reconnecting=!1;else{const e=this.backoff.duration();this._re connecting=!0;const s=this.setTimeoutFn((()=>{t.skipReconnect||(this.emitReserve d("reconnect_attempt",t.backoff.attempts),t.skipReconnect||t.open((e=>{e?(t._rec onnecting=!1,t.reconnect(),this.emitReserved("reconnect_error",e)):t.onreconnect ()})))}),e);this.opts.autoUnref&&s.unref(),this.subs.push((function(){clearTimeo ut(s)}))}}onreconnect(){const t=this.backoff.attempts;this._reconnecting=!1,this .backoff.reset(),this.emitReserved("reconnect",t)}}const ut={};function lt(t,e){ "object"==typeof t&&(e=t,t=void 0);const s=function(t,e="",s){let n=t;s=s||"unde fined"!=typeof location&&location,null==t&&(t=s.protocol+"//"+s.host),"string"== typeof t&&("/"===t.charAt(0)&&(t="/"===t.charAt(1)?s.protocol+t:s.host+t),/^(htt ps?|wss?):\/\//.test(t)||(t=void 0!==s?s.protocol+"//"+t:"https://"+t),n=H(t)),n .port||(/^(http|ws)$/.test(n.protocol)?n.port="80":/^(http|ws)s$/.test(n.protoco l)&&(n.port="443")),n.path=n.path||"/";const i=-1!==n.host.indexOf(":")?"["+n.ho st+"]":n.host;return n.id=n.protocol+"://"+i+":"+n.port+e,n.href=n.protocol+":// "+i+(s&&s.port===n.port?"":":"+n.port),n}(t,(e=e||{}).path||"/socket.io"),n=s.so urce,i=s.id,r=s.path,o=ut[i]&&r in ut[i].nsps;let h;return e.forceNew||e["force new connection"]||!1===e.multiplex||o?h=new pt(n,e):(ut[i]||(ut[i]=new pt(n,e)), h=ut[i]),s.query&&!e.query&&(e.query=s.queryKey),h.socket(s.path,e)}Object.assig n(lt,{Manager:pt,Socket:at,io:lt,connect:lt});export{pt as Manager,at as Socket, lt as connect,lt as default,lt as io,et as protocol};
//# sourceMappingURL=socket.io.esm.min.js.map //# sourceMappingURL=socket.io.esm.min.js.map
 End of changes. 2 change blocks. 
2 lines changed or deleted 2 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)