UNPKG

xcloudsdk

Version:

xcloud sdk

1 lines 55.2 kB
!function(t){var e={};function s(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,s),i.l=!0,i.exports}s.m=t,s.c=e,s.d=function(t,e,n){s.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},s.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},s.t=function(t,e){if(1&e&&(t=s(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(s.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)s.d(n,i,function(e){return t[e]}.bind(null,i));return n},s.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return s.d(e,"a",e),e},s.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},s.p="",s(s.s=4)}([function(t,e,s){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.appSdkBase=void 0;e.appSdkBase=class{constructor(t){this.ModuleName=t}init(){console.log("sdkBase init")}consolePlatform(){return uni.getSystemInfoSync().platform}exceFuncListen(t,e,...s){this.consolePlatform();try{console.log("sdkBase exceFunc",t,s),uni.requireNativePlugin("XcloudSDK").invokeAndKeepAlive(Object.assign({funcName:t},s),t=>{var s=JSON.parse(t);null!=s.Data&&e(s.Data),console.log(t)})}catch(t){uni.showToast({title:"error"+t,icon:"none"})}}exceFunc(t,...e){this.consolePlatform(),console.log("sdkBase exceFunc",t,e);var s=uni.requireNativePlugin("XcloudSDK");return new Promise((n,i)=>{try{s.invoke(Object.assign({funcName:t},e),t=>{n(JSON.parse(t)),console.log(t)})}catch(t){i(t)}})}}},function(t,e,s){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.webSdkBase=void 0;e.webSdkBase=class{constructor(t){this.ModuleName=t}}},function(t,e,s){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.SdkResult=void 0;const n=s(10);Object.defineProperty(e,"SdkResult",{enumerable:!0,get:function(){return n.SdkResult}})},function(t,e,s){"use strict";var n=this&&this.__awaiter||function(t,e,s,n){return new(s||(s=Promise))((function(i,r){function o(t){try{c(n.next(t))}catch(t){r(t)}}function a(t){try{c(n.throw(t))}catch(t){r(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof s?e:new s((function(t){t(e)}))).then(o,a)}c((n=n.apply(t,e||[])).next())}))};Object.defineProperty(e,"__esModule",{value:!0}),e.SyncEachObj=e.SyncEach=void 0;let i=function(t,e){return n(this,void 0,void 0,(function*(){var s=t.shift(),n=!0;if(s&&(n=yield e(s)),n&&t.length>0)return i(t,e)}))};e.SyncEach=function(t,e){return n(this,void 0,void 0,(function*(){if(t&&!(t.length<1)){var s=t.slice(0);return i(s,e)}}))};e.SyncEachObj=function(t,s,i){return n(this,void 0,void 0,(function*(){var n=[],r=!0,o=(n=null==i?Object.getOwnPropertyNames(t):i).shift();if(o){var a=t[o];r=yield s(a,o)}if(r&&n.length>0)return(0,e.SyncEachObj)(t,s,n)}))}},function(t,e,s){"use strict";var n,i=this&&this.__createBinding||(Object.create?function(t,e,s,n){void 0===n&&(n=s);var i=Object.getOwnPropertyDescriptor(e,s);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[s]}}),Object.defineProperty(t,n,i)}:function(t,e,s,n){void 0===n&&(n=s),t[n]=e[s]}),r=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),o=this&&this.__importStar||(n=function(t){return(n=Object.getOwnPropertyNames||function(t){var e=[];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(e[e.length]=s);return e})(t)},function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var s=n(t),o=0;o<s.length;o++)"default"!==s[o]&&i(e,t,s[o]);return r(e,t),e}),a=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.CloudPrint=e.Device=e.User=e.Is_Mobile=void 0;const c=a(s(5)),h=o(s(6)),u=o(s(11));e.Is_Mobile=c.default.IsMobile();const l=e.Is_Mobile?h.User:u.User;e.User=l;const p=e.Is_Mobile?h.Device:u.Device;e.Device=p;const d=e.Is_Mobile?h.CloudPrint:u.CloudPrint;e.CloudPrint=d,window.xcloudsdk={User:l,Device:p,CloudPrint:d}},function(t,e,s){"use strict";Object.defineProperty(e,"__esModule",{value:!0});class n{static IsMobile(){var t=!0;try{t=n.regex_mobile.test(navigator.userAgent)}catch(t){}return t}}n.regex_mobile=/Android|webOS|iPhone|iPad|iPod|BlackBerry/i,e.default=n},function(t,e,s){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.CloudPrint=e.Device=e.User=void 0;const i=n(s(7));e.Device=i.default;const r=n(s(8));e.User=r.default;const o=n(s(9));e.CloudPrint=o.default},function(t,e,s){"use strict";Object.defineProperty(e,"__esModule",{value:!0});const n=s(0);class i extends n.appSdkBase{constructor(){super("Device")}PdaBarcodeListener(t){this.exceFuncListen("PdaBarcodeListener",t)}}e.default=new i},function(t,e,s){"use strict";Object.defineProperty(e,"__esModule",{value:!0});const n=s(0);class i extends n.appSdkBase{constructor(){super("User")}getToken(){return this.exceFunc("GetToken")}getUserInfo(){return this.exceFunc("GetUserInfo")}}e.default=new i},function(t,e,s){"use strict";var n=this&&this.__awaiter||function(t,e,s,n){return new(s||(s=Promise))((function(i,r){function o(t){try{c(n.next(t))}catch(t){r(t)}}function a(t){try{c(n.throw(t))}catch(t){r(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof s?e:new s((function(t){t(e)}))).then(o,a)}c((n=n.apply(t,e||[])).next())}))};Object.defineProperty(e,"__esModule",{value:!0});const i=s(2),r=s(3),o=s(0);class a extends o.appSdkBase{constructor(){super("Print"),this.isOpen=!1,this.socketTask=null,this.printerList=[],this.printResult=[]}startHeartbeat(){this.hearteatInterval&&clearInterval(this.hearteatInterval),this.hearteatInterval=setInterval(()=>{this.socketTask&&this.isOpen&&this.socketTask.send({data:"3"})},1e4)}close(){this.isOpen=!1,clearInterval(this.hearteatInterval)}Init(t){return this.socketTask&&this.socketTask.close({}),new Promise((e,s)=>{this.socketTask=uni.connectSocket({url:t.wssUrl,complete:()=>{}}),this.socketTask.onMessage(t=>n(this,void 0,void 0,(function*(){var s;console.log("收到服务器内容:"+t.data);var o=t.data,a=["","",""],c=/^([0-9]{1,2})(.*?)$/gi.exec(o);null!=c&&(a=c);const h=a[1],u=a[2];if("2"==h)null===(s=this.socketTask)||void 0===s||s.send({data:"3"});else if("0"==h)this.startHeartbeat();else if("42"==h){const t=JSON.parse(u),s=t[0];if(Array.isArray(t)&&2==t.length)switch(s){case"clients":this.printerList=[],yield(0,r.SyncEachObj)(t[1],(t,e)=>n(this,void 0,void 0,(function*(){if(t&&t.printerList){const e=t.printerList;e&&e.length>0&&this.printerList.push(...e.map(e=>({displayName:e.displayName,name:e.name,description:e.description,status:e.status,hostName:t.hostname,isDefault:e.isDefault,ip:t.ip,client:t.clientId})))}return!0})));break;case"printerList":const o=t[1];o.length>0&&(this.printerList=o.map(t=>({displayName:t.displayName,name:t.name,hostName:t.server.hostname,isDefault:t.isDefault,ip:t.server.ip,client:t.server.clientId,description:t.description,status:t.status}))),e(i.SdkResult.Success(this.printerList));break;case"render-print-success":case"error":case"render-print-error":this.printResult.forEach(e=>{e(s,t[1])}),this.printResult=[]}}else console.log("code:"+t.data)}))),this.socketTask.onOpen(e=>{this.isOpen=!0,console.log("WebSocket 连接已打开"),uni.sendSocketMessage({data:"40"+JSON.stringify({token:t.token})})}),this.socketTask.onClose(t=>{this.close(),console.log("WebSocket 已关闭!")}),this.socketTask.onError(t=>{this.close(),s(t),console.log("WebSocket 连接打开失败,请检查!")})})}Print(t,e,s,n){return new Promise((r,o)=>{let a=this.printerList.find(t=>t.client==s&&t.isDefault);if(n&&(a=this.printerList.find(t=>t.client==s&&t.name===n)),a){this.printResult.push((t,e)=>{var s=null==e?void 0:e.msg;t.includes("print-success")?r(i.SdkResult.Success(s||"打印成功!")):r(i.SdkResult.Fail(s||"打印失败,请联系管理员!"))});const s={data:e,template:t,client:a.client,printer:n?a.name:"",pageSize:{height:1e3*t.panels[0].height,width:1e3*t.panels[0].width}};this.socketTask&&this.isOpen&&this.socketTask.send({data:`42["render-print",${JSON.stringify(s)}]`})}else o(i.SdkResult.Fail("没有找到打印机或连接未打开!"))})}Close(){var t;return null===(t=this.socketTask)||void 0===t||t.close({}),i.SdkResult.Success(null)}}e.default=new a},function(t,e,s){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.SdkResult=void 0;class n{constructor(){this.Code=0,this.ErrorMessage="",this.Data=null}static Fail(t,e=-1){let s=new n;return s.Code=e,s.ErrorMessage=t,s}static Success(t){let e=new n;return e.Code=0,e.Data=t,e}get IsSuccess(){return 0==this.Code}ToJson(){return JSON.stringify(this)}}e.SdkResult=n},function(t,e,s){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.CloudPrint=e.Device=e.User=void 0;const i=n(s(12));e.Device=i.default;const r=n(s(13));e.User=r.default;const o=n(s(14));e.CloudPrint=o.default},function(t,e,s){"use strict";Object.defineProperty(e,"__esModule",{value:!0});const n=s(1);class i extends n.webSdkBase{constructor(){super("Device")}PdaBarcodeListener(t){throw new Error("Method not implemented.")}}e.default=new i},function(t,e,s){"use strict";Object.defineProperty(e,"__esModule",{value:!0});const n=s(1);class i extends n.webSdkBase{constructor(){super("User")}getToken(){throw new Error("Method not implemented.")}getUserInfo(){throw new Error("Method not implemented.")}}e.default=new i},function(t,e,s){"use strict";var n=this&&this.__awaiter||function(t,e,s,n){return new(s||(s=Promise))((function(i,r){function o(t){try{c(n.next(t))}catch(t){r(t)}}function a(t){try{c(n.throw(t))}catch(t){r(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof s?e:new s((function(t){t(e)}))).then(o,a)}c((n=n.apply(t,e||[])).next())}))};Object.defineProperty(e,"__esModule",{value:!0});const i=s(15),r=s(2),o=s(3),a=s(1);class c extends a.webSdkBase{constructor(){super("Print"),this.isOpen=!1,this.socket=null,this.printerList=[],this.printResultCallbacks=[]}Init(t){return this.socket&&(this.socket.disconnect(),this.socket=null),new Promise((e,s)=>{this.socket=(0,i.io)(t.wssUrl.replace("/socket.io",""),{transports:["websocket"],autoConnect:!1,auth:{token:t.token}}),this.socket.on("connect",()=>{var e;this.isOpen=!0,null===(e=this.socket)||void 0===e||e.emit(t.token),console.log("Socket.IO 连接已打开")}),this.socket.on("disconnect",t=>{this.isOpen=!1,this.socket=null,console.log("Socket.IO 已断开连接:",t)}),this.socket.on("connect_error",t=>{this.isOpen=!1,this.socket=null,console.error("Socket.IO 连接错误:",t),s(r.SdkResult.Fail("Socket.IO 连接失败: "+t))}),this.socket.on("clients",t=>n(this,void 0,void 0,(function*(){this.printerList=[],yield(0,o.SyncEachObj)(t,(t,e)=>n(this,void 0,void 0,(function*(){if(t&&t.printerList){const s=t.printerList;s&&s.length>0&&this.printerList.push(...s.map(s=>({displayName:s.displayName,name:s.name,description:s.description,status:s.status,hostName:t.hostname,isDefault:s.isDefault,ip:t.ip,client:e})))}return!0}))),e(r.SdkResult.Success(this.printerList))}))),this.socket.on("render-print-success",t=>{this.printResultCallbacks.forEach(e=>e("render-print-success",t)),this.printResultCallbacks=[]}),this.socket.on("error",t=>{this.printResultCallbacks.forEach(e=>e("error",t)),this.printResultCallbacks=[]}),this.socket.on("render-print-error",t=>{this.printResultCallbacks.forEach(e=>e("render-print-error",t)),this.printResultCallbacks=[]}),this.socket.connect()})}Print(t,e,s,n){return new Promise((i,o)=>{let a=this.printerList.find(t=>t.client==s&&t.isDefault);if(n&&(a=this.printerList.find(t=>t.client==s&&t.name===n)),a&&this.socket&&this.isOpen){this.printResultCallbacks.push((t,e)=>{const s=null==e?void 0:e.msg;t.includes("print-success")?i(r.SdkResult.Success(s||"打印成功!")):i(r.SdkResult.Fail(s||"打印失败,请联系管理员!"))});const s={data:e,template:t,client:a.client,printer:n?a.name:"",pageSize:{height:1e3*t.panels[0].height,width:1e3*t.panels[0].width}};this.socket.emit("render-print",s)}else o(r.SdkResult.Fail("没有找到打印机或连接未打开!"))})}Close(){return this.socket&&(this.socket.disconnect(),this.socket=null,this.isOpen=!1),r.SdkResult.Success(null)}}e.default=new c},function(t,e,s){"use strict";s.r(e),s.d(e,"protocol",(function(){return ft})),s.d(e,"Manager",(function(){return St})),s.d(e,"Socket",(function(){return wt})),s.d(e,"io",(function(){return Tt})),s.d(e,"connect",(function(){return Tt})),s.d(e,"default",(function(){return Tt})),s.d(e,"Fetch",(function(){return rt})),s.d(e,"NodeXHR",(function(){return H})),s.d(e,"XHR",(function(){return H})),s.d(e,"NodeWebSocket",(function(){return z})),s.d(e,"WebSocket",(function(){return z})),s.d(e,"WebTransport",(function(){return $}));var n={};s.r(n),s.d(n,"protocol",(function(){return ft})),s.d(n,"PacketType",(function(){return yt})),s.d(n,"Encoder",(function(){return gt})),s.d(n,"Decoder",(function(){return _t}));const i=Object.create(null);i.open="0",i.close="1",i.ping="2",i.pong="3",i.message="4",i.upgrade="5",i.noop="6";const r=Object.create(null);Object.keys(i).forEach(t=>{r[i[t]]=t});const o={type:"error",data:"parser error"},a="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Object.prototype.toString.call(Blob),c="function"==typeof ArrayBuffer,h=t=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(t):t&&t.buffer instanceof ArrayBuffer,u=({type:t,data:e},s,n)=>a&&e instanceof Blob?s?n(e):l(e,n):c&&(e instanceof ArrayBuffer||h(e))?s?n(e):l(new Blob([e]),n):n(i[t]+(e||"")),l=(t,e)=>{const s=new FileReader;return s.onload=function(){const t=s.result.split(",")[1];e("b"+(t||""))},s.readAsDataURL(t)};function p(t){return t instanceof Uint8Array?t:t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}let d;const f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",y="undefined"==typeof Uint8Array?[]:new Uint8Array(256);for(let t=0;t<f.length;t++)y[f.charCodeAt(t)]=t;const g="function"==typeof ArrayBuffer,m=(t,e)=>{if("string"!=typeof t)return{type:"message",data:b(t,e)};const s=t.charAt(0);if("b"===s)return{type:"message",data:_(t.substring(1),e)};return r[s]?t.length>1?{type:r[s],data:t.substring(1)}:{type:r[s]}:o},_=(t,e)=>{if(g){const s=(t=>{let e,s,n,i,r,o=.75*t.length,a=t.length,c=0;"="===t[t.length-1]&&(o--,"="===t[t.length-2]&&o--);const h=new ArrayBuffer(o),u=new Uint8Array(h);for(e=0;e<a;e+=4)s=y[t.charCodeAt(e)],n=y[t.charCodeAt(e+1)],i=y[t.charCodeAt(e+2)],r=y[t.charCodeAt(e+3)],u[c++]=s<<2|n>>4,u[c++]=(15&n)<<4|i>>2,u[c++]=(3&i)<<6|63&r;return h})(t);return b(s,e)}return{base64:!0,data:t}},b=(t,e)=>{switch(e){case"blob":return t instanceof Blob?t:new Blob([t]);case"arraybuffer":default:return t instanceof ArrayBuffer?t:t.buffer}},v=String.fromCharCode(30);function k(){return new TransformStream({transform(t,e){!function(t,e){a&&t.data instanceof Blob?t.data.arrayBuffer().then(p).then(e):c&&(t.data instanceof ArrayBuffer||h(t.data))?e(p(t.data)):u(t,!1,t=>{d||(d=new TextEncoder),e(d.encode(t))})}(t,s=>{const n=s.length;let i;if(n<126)i=new Uint8Array(1),new DataView(i.buffer).setUint8(0,n);else if(n<65536){i=new Uint8Array(3);const t=new DataView(i.buffer);t.setUint8(0,126),t.setUint16(1,n)}else{i=new Uint8Array(9);const t=new DataView(i.buffer);t.setUint8(0,127),t.setBigUint64(1,BigInt(n))}t.data&&"string"!=typeof t.data&&(i[0]|=128),e.enqueue(i),e.enqueue(s)})}})}let w;function O(t){return t.reduce((t,e)=>t+e.length,0)}function S(t,e){if(t[0].length===e)return t.shift();const s=new Uint8Array(e);let n=0;for(let i=0;i<e;i++)s[i]=t[0][n++],n===t[0].length&&(t.shift(),n=0);return t.length&&n<t[0].length&&(t[0]=t[0].slice(n)),s}function E(t){if(t)return function(t){for(var e in E.prototype)t[e]=E.prototype[e];return t}(t)}E.prototype.on=E.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this},E.prototype.once=function(t,e){function s(){this.off(t,s),e.apply(this,arguments)}return s.fn=e,this.on(t,s),this},E.prototype.off=E.prototype.removeListener=E.prototype.removeAllListeners=E.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)return 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},E.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},E.prototype.emitReserved=E.prototype.emit,E.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks["$"+t]||[]},E.prototype.hasListeners=function(t){return!!this.listeners(t).length};const T="function"==typeof Promise&&"function"==typeof Promise.resolve?t=>Promise.resolve().then(t):(t,e)=>e(t,0),R="undefined"!=typeof self?self:"undefined"!=typeof window?window:Function("return this")();function C(t,...e){return e.reduce((e,s)=>(t.hasOwnProperty(s)&&(e[s]=t[s]),e),{})}const A=R.setTimeout,x=R.clearTimeout;function B(t,e){e.useNativeTimers?(t.setTimeoutFn=A.bind(R),t.clearTimeoutFn=x.bind(R)):(t.setTimeoutFn=R.setTimeout.bind(R),t.clearTimeoutFn=R.clearTimeout.bind(R))}function P(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}class N extends Error{constructor(t,e,s){super(t),this.description=e,this.context=s,this.type="TransportError"}}class L extends E{constructor(t){super(),this.writable=!1,B(this,t),this.opts=t,this.query=t.query,this.socket=t.socket,this.supportsBinary=!t.forceBase64}onError(t,e,s){return super.emitReserved("error",new N(t,e,s)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return"opening"!==this.readyState&&"open"!==this.readyState||(this.doClose(),this.onClose()),this}send(t){"open"===this.readyState&&this.write(t)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(t){const e=m(t,this.socket.binaryType);this.onPacket(e)}onPacket(t){super.emitReserved("packet",t)}onClose(t){this.readyState="closed",super.emitReserved("close",t)}pause(t){}createUri(t,e={}){return t+"://"+this._hostname()+this._port()+this.opts.path+this._query(e)}_hostname(){const t=this.opts.hostname;return-1===t.indexOf(":")?t:"["+t+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(443!==this.opts.port)||!this.opts.secure&&80!==Number(this.opts.port))?":"+this.opts.port:""}_query(t){const e=function(t){let e="";for(let s in t)t.hasOwnProperty(s)&&(e.length&&(e+="&"),e+=encodeURIComponent(s)+"="+encodeURIComponent(t[s]));return e}(t);return e.length?"?"+e:""}}class j extends L{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(t){this.readyState="pausing";const e=()=>{this.readyState="paused",t()};if(this._polling||!this.writable){let t=0;this._polling&&(t++,this.once("pollComplete",(function(){--t||e()}))),this.writable||(t++,this.once("drain",(function(){--t||e()})))}else e()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(t){((t,e)=>{const s=t.split(v),n=[];for(let t=0;t<s.length;t++){const i=m(s[t],e);if(n.push(i),"error"===i.type)break}return n})(t,this.socket.binaryType).forEach(t=>{if("opening"===this.readyState&&"open"===t.type&&this.onOpen(),"close"===t.type)return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(t)}),"closed"!==this.readyState&&(this._polling=!1,this.emitReserved("pollComplete"),"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,r)=>{u(t,!1,t=>{n[r]=t,++i===s&&e(n.join(v))})})})(t,t=>{this.doWrite(t,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const t=this.opts.secure?"https":"http",e=this.query||{};return!1!==this.opts.timestampRequests&&(e[this.opts.timestampParam]=P()),this.supportsBinary||e.sid||(e.b64=1),this.createUri(t,e)}}let D=!1;try{D="undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest}catch(t){}const M=D;function q(){}class I extends j{constructor(t){if(super(t),"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.hostname||s!==t.port}}doWrite(t,e){const s=this.request({method:"POST",data:t});s.on("success",e),s.on("error",(t,e)=>{this.onError("xhr post error",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}}class U extends E{constructor(t,e,s){super(),this.createRequest=t,B(this,s),this._opts=s,this._method=s.method||"GET",this._uri=e,this._data=void 0!==s.data?s.data:null,this._create()}_create(){var t;const e=C(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");e.xdomain=!!this._opts.xd;const s=this._xhr=this.createRequest(e);try{s.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){s.setDisableHeaderCheck&&s.setDisableHeaderCheck(!0);for(let t in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(t)&&s.setRequestHeader(t,this._opts.extraHeaders[t])}}catch(t){}if("POST"===this._method)try{s.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(t){}try{s.setRequestHeader("Accept","*/*")}catch(t){}null===(t=this._opts.cookieJar)||void 0===t||t.addCookies(s),"withCredentials"in s&&(s.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(s.timeout=this._opts.requestTimeout),s.onreadystatechange=()=>{var t;3===s.readyState&&(null===(t=this._opts.cookieJar)||void 0===t||t.parseCookies(s.getResponseHeader("set-cookie"))),4===s.readyState&&(200===s.status||1223===s.status?this._onLoad():this.setTimeoutFn(()=>{this._onError("number"==typeof s.status?s.status:0)},0))},s.send(this._data)}catch(t){return void this.setTimeoutFn(()=>{this._onError(t)},0)}"undefined"!=typeof document&&(this._index=U.requestsCount++,U.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=q,t)try{this._xhr.abort()}catch(t){}"undefined"!=typeof document&&delete U.requests[this._index],this._xhr=null}}_onLoad(){const t=this._xhr.responseText;null!==t&&(this.emitReserved("data",t),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}if(U.requestsCount=0,U.requests={},"undefined"!=typeof document)if("function"==typeof attachEvent)attachEvent("onunload",F);else if("function"==typeof addEventListener){addEventListener("onpagehide"in R?"pagehide":"unload",F,!1)}function F(){for(let t in U.requests)U.requests.hasOwnProperty(t)&&U.requests[t].abort()}const V=function(){const t=W({xdomain:!1});return t&&null!==t.responseType}();class H extends I{constructor(t){super(t);const e=t&&t.forceBase64;this.supportsBinary=V&&!e}request(t={}){return Object.assign(t,{xd:this.xd},this.opts),new U(W,this.uri(),t)}}function W(t){const e=t.xdomain;try{if("undefined"!=typeof XMLHttpRequest&&(!e||M))return new XMLHttpRequest}catch(t){}if(!e)try{return new(R[["Active"].concat("Object").join("X")])("Microsoft.XMLHTTP")}catch(t){}}const J="undefined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase();class K extends L{get name(){return"websocket"}doOpen(){const t=this.uri(),e=this.opts.protocols,s=J?{}:C(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(s.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(t,e,s)}catch(t){return this.emitReserved("error",t)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=t=>this.onClose({description:"websocket 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(let e=0;e<t.length;e++){const s=t[e],n=e===t.length-1;u(s,this.supportsBinary,t=>{try{this.doWrite(s,t)}catch(t){}n&&T(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){void 0!==this.ws&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const t=this.opts.secure?"wss":"ws",e=this.query||{};return this.opts.timestampRequests&&(e[this.opts.timestampParam]=P()),this.supportsBinary||(e.b64=1),this.createUri(t,e)}}const Y=R.WebSocket||R.MozWebSocket;class z extends K{createSocket(t,e,s){return J?new Y(t,e,s):e?new Y(t,e):new Y(t)}doWrite(t,e){this.ws.send(e)}}class $ extends L{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(t){return this.emitReserved("error",t)}this._transport.closed.then(()=>{this.onClose()}).catch(t=>{this.onError("webtransport error",t)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(t=>{const e=function(t,e){w||(w=new TextDecoder);const s=[];let n=0,i=-1,r=!1;return new TransformStream({transform(a,c){for(s.push(a);;){if(0===n){if(O(s)<1)break;const t=S(s,1);r=128==(128&t[0]),i=127&t[0],n=i<126?3:126===i?1:2}else if(1===n){if(O(s)<2)break;const t=S(s,2);i=new DataView(t.buffer,t.byteOffset,t.length).getUint16(0),n=3}else if(2===n){if(O(s)<8)break;const t=S(s,8),e=new DataView(t.buffer,t.byteOffset,t.length),r=e.getUint32(0);if(r>Math.pow(2,21)-1){c.enqueue(o);break}i=r*Math.pow(2,32)+e.getUint32(4),n=3}else{if(O(s)<i)break;const t=S(s,i);c.enqueue(m(r?t:w.decode(t),e)),n=0}if(0===i||i>t){c.enqueue(o);break}}}})}(Number.MAX_SAFE_INTEGER,this.socket.binaryType),s=t.readable.pipeThrough(e).getReader(),n=k();n.readable.pipeTo(t.writable),this._writer=n.writable.getWriter();const i=()=>{s.read().then(({done:t,value:e})=>{t||(this.onPacket(e),i())}).catch(t=>{})};i();const r={type:"open"};this.query.sid&&(r.data=`{"sid":"${this.query.sid}"}`),this._writer.write(r).then(()=>this.onOpen())})})}write(t){this.writable=!1;for(let e=0;e<t.length;e++){const s=t[e],n=e===t.length-1;this._writer.write(s).then(()=>{n&&T(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var t;null===(t=this._transport)||void 0===t||t.close()}}const X={websocket:z,webtransport:$,polling:H},Q=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,G=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function Z(t){if(t.length>8e3)throw"URI too long";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.substring(n,t.length));let i=Q.exec(t||""),r={},o=14;for(;o--;)r[G[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=e.replace(/\/{2,9}/g,"/").split("/");"/"!=e.slice(0,1)&&0!==e.length||s.splice(0,1);"/"==e.slice(-1)&&s.splice(s.length-1,1);return s}(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}const tt="function"==typeof addEventListener&&"function"==typeof removeEventListener,et=[];tt&&addEventListener("offline",()=>{et.forEach(t=>t())},!1);class st extends E{constructor(t,e){if(super(),this.binaryType="arraybuffer",this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,t&&"object"==typeof t&&(e=t,t=null),t){const s=Z(t);e.hostname=s.host,e.secure="https"===s.protocol||"wss"===s.protocol,e.port=s.port,s.query&&(e.query=s.query)}else e.host&&(e.hostname=Z(e.host).host);B(this,e),this.secure=null!=e.secure?e.secure:"undefined"!=typeof location&&"https:"===location.protocol,e.hostname&&!e.port&&(e.port=this.secure?"443":"80"),this.hostname=e.hostname||("undefined"!=typeof location?location.hostname:"localhost"),this.port=e.port||("undefined"!=typeof location&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},e.transports.forEach(t=>{const e=t.prototype.name;this.transports.push(e),this._transportsByName[e]=t}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},e),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),"string"==typeof this.opts.query&&(this.opts.query=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)),tt&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),"localhost"!==this.hostname&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},et.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),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,{query:e,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[t]);return new this._transportsByName[t](s)}_open(){if(0===this.transports.length)return void this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);const t=this.opts.rememberUpgrade&&st.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket")?"websocket":this.transports[0];this.readyState="opening";const e=this.createTransport(t);e.open(),this.setTransport(e)}setTransport(t){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",t=>this._onClose("transport close",t))}onOpen(){this.readyState="open",st.priorWebsocketSuccess="websocket"===this.transport.name,this.emitReserved("open"),this.flush()}_onPacket(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._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const 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)}}onHandshake(t){this.emitReserved("handshake",t),this.id=t.sid,this.transport.query.sid=t.sid,this._pingInterval=t.pingInterval,this._pingTimeout=t.pingTimeout,this._maxPayload=t.maxPayload,this.onOpen(),"closed"!==this.readyState&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const t=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+t,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},t),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,0===this.writeBuffer.length?this.emitReserved("drain"):this.flush()}flush(){if("closed"!==this.readyState&&this.transport.writable&&!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.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<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}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const t=Date.now()>this._pingTimeoutTime;return t&&(this._pingTimeoutTime=0,T(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),t}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("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()}close(){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"!==this.readyState||(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?s():t()}):this.upgrading?s():t()),this}_onError(t){if(st.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&"opening"===this.readyState)return this.transports.shift(),this._open();this.emitReserved("error",t),this._onClose("transport error",t)}_onClose(t,e){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),tt&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const t=et.indexOf(this._offlineEventListener);-1!==t&&et.splice(t,1)}this.readyState="closed",this.id=null,this.emitReserved("close",t,e),this.writeBuffer=[],this._prevBufferLen=0}}}st.protocol=4;class nt extends st{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),"open"===this.readyState&&this.opts.upgrade)for(let t=0;t<this._upgrades.length;t++)this._probe(this._upgrades[t])}_probe(t){let e=this.createTransport(t),s=!1;st.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;st.priorWebsocketSuccess="websocket"===e.name,this.transport.pause(()=>{s||"closed"!==this.readyState&&(h(),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.emitReserved("upgradeError",t)}}))};function i(){s||(s=!0,h(),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 a(){r("socket closed")}function c(t){e&&t.name!==e.name&&i()}const h=()=>{e.removeListener("open",n),e.removeListener("error",r),e.removeListener("close",o),this.off("close",a),this.off("upgrading",c)};e.once("open",n),e.once("error",r),e.once("close",o),this.once("close",a),this.once("upgrading",c),-1!==this._upgrades.indexOf("webtransport")&&"webtransport"!==t?this.setTimeoutFn(()=>{s||e.open()},200):e.open()}onHandshake(t){this._upgrades=this._filterUpgrades(t.upgrades),super.onHandshake(t)}_filterUpgrades(t){const e=[];for(let s=0;s<t.length;s++)~this.transports.indexOf(t[s])&&e.push(t[s]);return e}}class it extends nt{constructor(t,e={}){const s="object"==typeof t?t:e;(!s.transports||s.transports&&"string"==typeof s.transports[0])&&(s.transports=(s.transports||["polling","websocket","webtransport"]).map(t=>X[t]).filter(t=>!!t)),super(t,s)}}class rt extends j{doPoll(){this._fetch().then(t=>{if(!t.ok)return this.onError("fetch read error",t.status,t);t.text().then(t=>this.onData(t))}).catch(t=>{this.onError("fetch read error",t)})}doWrite(t,e){this._fetch(t).then(t=>{if(!t.ok)return this.onError("fetch write error",t.status,t);e()}).catch(t=>{this.onError("fetch write error",t)})}_fetch(t){var e;const s=void 0!==t,n=new Headers(this.opts.extraHeaders);return s&&n.set("content-type","text/plain;charset=UTF-8"),null===(e=this.socket._cookieJar)||void 0===e||e.appendCookies(n),fetch(this.uri(),{method:s?"POST":"GET",body:s?t:null,headers:n,credentials:this.opts.withCredentials?"include":"omit"}).then(t=>{var e;return null===(e=this.socket._cookieJar)||void 0===e||e.parseCookies(t.headers.getSetCookie()),t})}}const ot="function"==typeof ArrayBuffer,at=Object.prototype.toString,ct="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===at.call(Blob),ht="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===at.call(File);function ut(t){return ot&&(t instanceof ArrayBuffer||(t=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(t):t.buffer instanceof ArrayBuffer)(t))||ct&&t instanceof Blob||ht&&t instanceof File}function lt(t){const e=[],s=t.data,n=t;return n.data=function t(e,s){if(!e)return e;if(ut(e)){const t={_placeholder:!0,num:s.length};return s.push(e),t}if(Array.isArray(e)){const n=new Array(e.length);for(let i=0;i<e.length;i++)n[i]=t(e[i],s);return n}if("object"==typeof e&&!(e instanceof Date)){const n={};for(const i in e)Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=t(e[i],s));return n}return e}(s,e),n.attachments=e.length,{packet:n,buffers:e}}function pt(t,e){return t.data=function t(e,s){if(!e)return e;if(e&&!0===e._placeholder){if("number"==typeof e.num&&e.num>=0&&e.num<s.length)return s[e.num];throw new Error("illegal attachments")}if(Array.isArray(e))for(let n=0;n<e.length;n++)e[n]=t(e[n],s);else if("object"==typeof e)for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(e[n]=t(e[n],s));return e}(t.data,e),delete t.attachments,t}const dt=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],ft=5;var yt;!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"}(yt||(yt={}));class gt{constructor(t){this.replacer=t}encode(t){return t.type!==yt.EVENT&&t.type!==yt.ACK||!function t(e,s){if(!e||"object"!=typeof e)return!1;if(Array.isArray(e)){for(let s=0,n=e.length;s<n;s++)if(t(e[s]))return!0;return!1}if(ut(e))return!0;if(e.toJSON&&"function"==typeof e.toJSON&&1===arguments.length)return t(e.toJSON(),!0);for(const s in e)if(Object.prototype.hasOwnProperty.call(e,s)&&t(e[s]))return!0;return!1}(t)?[this.encodeAsString(t)]:this.encodeAsBinary({type:t.type===yt.EVENT?yt.BINARY_EVENT:yt.BINARY_ACK,nsp:t.nsp,data:t.data,id:t.id})}encodeAsString(t){let e=""+t.type;return t.type!==yt.BINARY_EVENT&&t.type!==yt.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=lt(t),s=this.encodeAsString(e.packet),n=e.buffers;return n.unshift(s),n}}function mt(t){return"[object Object]"===Object.prototype.toString.call(t)}class _t extends E{constructor(t){super(),this.reviver=t}add(t){let e;if("string"==typeof t){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");e=this.decodeString(t);const s=e.type===yt.BINARY_EVENT;s||e.type===yt.BINARY_ACK?(e.type=s?yt.EVENT:yt.ACK,this.reconstructor=new bt(e),0===e.attachments&&super.emitReserved("decoded",e)):super.emitReserved("decoded",e)}else{if(!ut(t)&&!t.base64)throw new Error("Unknown type: "+t);if(!this.reconstructor)throw new Error("got binary data when not reconstructing a packet");e=this.reconstructor.takeBinaryData(t),e&&(this.reconstructor=null,super.emitReserved("decoded",e))}}decodeString(t){let e=0;const s={type:Number(t.charAt(0))};if(void 0===yt[s.type])throw new Error("unknown packet type "+s.type);if(s.type===yt.BINARY_EVENT||s.type===yt.BINARY_ACK){const n=e+1;for(;"-"!==t.charAt(++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.charAt(e+1)){const n=e+1;for(;++e;){if(","===t.charAt(e))break;if(e===t.length)break}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)){const n=this.tryParse(t.substr(e));if(!_t.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){return!1}}static isPayloadValid(t,e){switch(t){case yt.CONNECT:return mt(e);case yt.DISCONNECT:return void 0===e;case yt.CONNECT_ERROR:return"string"==typeof e||mt(e);case yt.EVENT:case yt.BINARY_EVENT:return Array.isArray(e)&&("number"==typeof e[0]||"string"==typeof e[0]&&-1===dt.indexOf(e[0]));case yt.ACK:case yt.BINARY_ACK:return Array.isArray(e)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class bt{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=pt(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}function vt(t,e,s){return t.on(e,s),function(){t.off(e,s)}}const kt=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class wt extends E{constructor(t,e,s){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=t,this.nsp=e,s&&s.auth&&(this.auth=s.auth),this._opts=Object.assign({},s),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const t=this.io;this.subs=[vt(t,"open",this.onopen.bind(this)),vt(t,"packet",this.onpacket.bind(this)),vt(t,"error",this.onerror.bind(this)),vt(t,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected||(this.subEvents(),this.io._reconnecting||this.io.open(),"open"===this.io._readyState&&this.onopen()),this}open(){return this.connect()}send(...t){return t.unshift("message"),this.emit.apply(this,t),this}emit(t,...e){var s,n,i;if(kt.hasOwnProperty(t))throw new Error('"'+t.toString()+'" is a reserved event name');if(e.unshift(t),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(e),this;const r={type:yt.EVENT,data:e,options:{}};if(r.options.compress=!1!==this.flags.compress,"function"==typeof e[e.length-1]){const t=this.ids++,s=e.pop();this._registerAckCallback(t,s),r.id=t}const o=null===(n=null===(s=this.io.engine)||void 0===s?void 0:s.transport)||void 0===n?void 0:n.writable,a=this.connected&&!(null===(i=this.io.engine)||void 0===i?void 0:i._hasPingExpired());return this.flags.volatile&&!o||(a?(this.notifyOutgoingListeners(r),this.packet(r)):this.sendBuffer.push(r)),this.flags={},this}_registerAckCallback(t,e){var s;const n=null!==(s=this.flags.timeout)&&void 0!==s?s:this._opts.ackTimeout;if(void 0===n)return void(this.acks[t]=e);const i=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"))},n),r=(...t)=>{this.io.clearTimeoutFn(i),e.apply(this,t)};r.withError=!0,this.acks[t]=r}emitWithAck(t,...e){return new Promise((s,n)=>{const i=(t,e)=>t?n(t):s(e);i.withError=!0,e.push(i),this.emit(t,...e)})}_addToQueue(t){let e;"function"==typeof t[t.length-1]&&(e=t.pop());const s={id:this._queueSeq++,tryCount:0,pending:!1,args:t,flags:Object.assign({fromQueue:!0},this.flags)};t.push((t,...n)=>{if(s!==this._queue[0])return;return null!==t?s.tryCount>this._opts.retries&&(this._queue.shift(),e&&e(t)):(this._queue.shift(),e&&e(null,...n)),s.pending=!1,this._drainQueue()}),this._queue.push(s),this._drainQueue()}_drainQueue(t=!1){if(!this.connected||0===this._queue.length)return;const e=this._queue[0];e.pending&&!t||(e.pending=!0,e.tryCount++,this.flags=e.flags,this.emit.apply(this,e.args))}packet(t){t.nsp=this.nsp,this.io._packet(t)}onopen(){"function"==typeof this.auth?this.auth(t=>{this._sendConnectPacket(t)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(t){this.packet({type:yt.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},t):t})}onerror(t){this.connected||this.emitReserved("connect_error",t)}onclose(t,e){this.connected=!1,delete this.id,this.emitReserved("disconnect",t,e),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(t=>{if(!this.sendBuffer.some(e=>String(e.id)===t)){const e=this.acks[t];delete this.acks[t],e.withError&&e.call(this,new Error("socket has been disconnected"))}})}onpacket(t){if(t.nsp===this.nsp)switch(t.type){case yt.CONNECT:t.data&&t.data.sid?this.onconnect(t.data.sid,t.data.pid):this.emitReserved("connect_error",new Error("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;case yt.EVENT:case yt.BINARY_EVENT:this.onevent(t);break;case yt.ACK:case yt.BINARY_ACK:this.onack(t);break;case yt.DISCONNECT:this.ondisconnect();break;case yt.CONNECT_ERROR:this.destroy();const e=new Error(t.data.message);e.data=t.data.data,this.emitReserved("connect_error",e)}}onevent(t){const 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),this._pid&&t.length&&"string"==typeof t[t.length-1]&&(this._lastOffset=t[t.length-1])}ack(t){const e=this;let s=!1;return function(...n){s||(s=!0,e.packet({type:yt.ACK,id:t,data:n}))}}onack(t){const e=this.acks[t.id];"function"==typeof e&&(delete this.acks[t.id],e.withError&&t.data.unshift(null),e.apply(this,t.data))}onconnect(t,e){this.id=t,this.recovered=e&&this._pid===e,this._pid=e,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach(t=>this.emitEvent(t)),this.receiveBuffer=[],this.sendBuffer.forEach(t=>{this.notifyOutgoingListeners(t),this.packet(t)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(t=>t()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:yt.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(t){return this.flags.compress=t,this}get volatile(){return this.flags.volatile=!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._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._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(t),this}prependAnyOutgoing(t){return this._anyOutgoingListeners=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.splice(s,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(t){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const e=this._anyOutgoingListeners.slice();for(const s of e)s.apply(this,t.data)}}}function Ot(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}Ot.prototype.duration=function(){var t=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),s=Math.floor(e*this.jitter*t);t=0==(1&Math.floor(10*e))?t-s:t+s}return 0|Math.min(t,this.max)},Ot.prototype.reset=function(){this.attempts=0},Ot.prototype.setMin=function(t){this.ms=t},Ot.prototype.setMax=function(t){this.max=t},Ot.prototype.setJitter=function(t){this.jitter=t};class St extends E{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,B(th